diff --git a/app/src/app_base.h b/app/src/app_base.h index 30bbc963c..9ce3fdddd 100644 --- a/app/src/app_base.h +++ b/app/src/app_base.h @@ -548,7 +548,8 @@ struct st_app_context { struct st_app_tx_st20p_session* tx_st20p_sessions; int tx_st20p_session_cnt; - uint8_t rx_sip_addr[MTL_PORT_MAX][MTL_IP_ADDR_LEN]; /* rx source IP */ + uint8_t rx_sip_addr[MTL_PORT_MAX][MTL_IP_ADDR_LEN]; /* rx source IP */ + uint8_t rx_mcast_sip_addr[MTL_PORT_MAX][MTL_IP_ADDR_LEN]; /* rx multicast source IP */ struct st_app_rx_video_session* rx_video_sessions; int rx_video_session_cnt; diff --git a/app/src/args.c b/app/src/args.c index 50efa8a74..e72566335 100644 --- a/app/src/args.c +++ b/app/src/args.c @@ -24,6 +24,8 @@ enum st_args_cmd { ST_ARG_R_NETMASK, ST_ARG_P_GATEWAY, ST_ARG_R_GATEWAY, + ST_ARG_P_RX_MCAST_SIP, + ST_ARG_R_RX_MCAST_SIP, ST_ARG_TX_VIDEO_URL = 0x200, ST_ARG_TX_VIDEO_SESSIONS_CNT, @@ -143,6 +145,8 @@ static struct option st_app_args_options[] = { {"r_netmask", required_argument, 0, ST_ARG_R_NETMASK}, {"p_gateway", required_argument, 0, ST_ARG_P_GATEWAY}, {"r_gateway", required_argument, 0, ST_ARG_R_GATEWAY}, + {"p_rx_mcast_sip", required_argument, 0, ST_ARG_P_RX_MCAST_SIP}, + {"r_rx_mcast_sip", required_argument, 0, ST_ARG_R_RX_MCAST_SIP}, {"tx_video_url", required_argument, 0, ST_ARG_TX_VIDEO_URL}, {"tx_video_sessions_count", required_argument, 0, ST_ARG_TX_VIDEO_SESSIONS_CNT}, @@ -397,6 +401,12 @@ int st_app_parse_args(struct st_app_context* ctx, struct mtl_init_params* p, int case ST_ARG_R_GATEWAY: inet_pton(AF_INET, optarg, p->gateway[MTL_PORT_R]); break; + case ST_ARG_P_RX_MCAST_SIP: + inet_pton(AF_INET, optarg, ctx->rx_mcast_sip_addr[MTL_PORT_P]); + break; + case ST_ARG_R_RX_MCAST_SIP: + inet_pton(AF_INET, optarg, ctx->rx_mcast_sip_addr[MTL_PORT_R]); + break; case ST_ARG_TX_VIDEO_URL: snprintf(ctx->tx_video_url, sizeof(ctx->tx_video_url), "%s", optarg); break; diff --git a/app/src/rx_ancillary_app.c b/app/src/rx_ancillary_app.c index 1b6daeed4..c03fd1f3a 100644 --- a/app/src/rx_ancillary_app.c +++ b/app/src/rx_ancillary_app.c @@ -130,6 +130,9 @@ static int app_rx_anc_init(struct st_app_context* ctx, st_json_ancillary_session anc ? st_json_ip(ctx, &anc->base, MTL_SESSION_PORT_P) : ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy(ops.mcast_sip_addr[MTL_SESSION_PORT_P], + anc ? anc->base.mcast_src_ip[MTL_PORT_P] : ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf(ops.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", anc ? anc->base.inf[MTL_SESSION_PORT_P]->name : ctx->para.port[MTL_PORT_P]); ops.udp_port[MTL_SESSION_PORT_P] = anc ? anc->base.udp_port : (10200 + s->idx); @@ -138,6 +141,9 @@ static int app_rx_anc_init(struct st_app_context* ctx, st_json_ancillary_session anc ? st_json_ip(ctx, &anc->base, MTL_SESSION_PORT_R) : ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy(ops.mcast_sip_addr[MTL_SESSION_PORT_R], + anc ? anc->base.mcast_src_ip[MTL_PORT_R] : ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf(ops.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", anc ? anc->base.inf[MTL_SESSION_PORT_R]->name : ctx->para.port[MTL_PORT_R]); ops.udp_port[MTL_SESSION_PORT_R] = anc ? anc->base.udp_port : (10200 + s->idx); diff --git a/app/src/rx_audio_app.c b/app/src/rx_audio_app.c index 9e7366662..1d1e5fd35 100644 --- a/app/src/rx_audio_app.c +++ b/app/src/rx_audio_app.c @@ -231,6 +231,10 @@ static int app_rx_audio_init(struct st_app_context* ctx, st_json_audio_session_t audio ? st_json_ip(ctx, &audio->base, MTL_SESSION_PORT_P) : ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_P], + audio ? audio->base.mcast_src_ip[MTL_PORT_P] : ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf( ops.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", audio ? audio->base.inf[MTL_SESSION_PORT_P]->name : ctx->para.port[MTL_PORT_P]); @@ -240,6 +244,10 @@ static int app_rx_audio_init(struct st_app_context* ctx, st_json_audio_session_t audio ? st_json_ip(ctx, &audio->base, MTL_SESSION_PORT_R) : ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_R], + audio ? audio->base.mcast_src_ip[MTL_PORT_R] : ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf(ops.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", audio ? audio->base.inf[MTL_PORT_R]->name : ctx->para.port[MTL_PORT_R]); ops.udp_port[MTL_SESSION_PORT_R] = audio ? audio->base.udp_port : (10100 + s->idx); diff --git a/app/src/rx_st20p_app.c b/app/src/rx_st20p_app.c index 415cacc4e..400403901 100644 --- a/app/src/rx_st20p_app.c +++ b/app/src/rx_st20p_app.c @@ -199,6 +199,10 @@ static int app_rx_st20p_init(struct st_app_context* ctx, st20p ? st_json_ip(ctx, &st20p->base, MTL_SESSION_PORT_P) : ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_P], + st20p ? st20p->base.mcast_src_ip[MTL_PORT_P] : ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf( ops.port.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", st20p ? st20p->base.inf[MTL_SESSION_PORT_P]->name : ctx->para.port[MTL_PORT_P]); @@ -208,6 +212,10 @@ static int app_rx_st20p_init(struct st_app_context* ctx, st20p ? st_json_ip(ctx, &st20p->base, MTL_SESSION_PORT_R) : ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_R], + st20p ? st20p->base.mcast_src_ip[MTL_PORT_R] : ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf( ops.port.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", st20p ? st20p->base.inf[MTL_SESSION_PORT_R]->name : ctx->para.port[MTL_PORT_R]); diff --git a/app/src/rx_st20r_app.c b/app/src/rx_st20r_app.c index a2d551110..c5cc76fa0 100644 --- a/app/src/rx_st20r_app.c +++ b/app/src/rx_st20r_app.c @@ -259,6 +259,10 @@ static int app_rx_st20r_init(struct st_app_context* ctx, st_json_video_session_t video ? st_json_ip(ctx, &video->base, MTL_SESSION_PORT_P) : ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_P], + video ? video->base.mcast_src_ip[MTL_PORT_P] : ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf(ops.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", video ? video->base.inf[MTL_PORT_P]->name : ctx->para.port[MTL_PORT_P]); ops.udp_port[MTL_SESSION_PORT_P] = video ? video->base.udp_port : (10000 + s->idx); @@ -267,6 +271,10 @@ static int app_rx_st20r_init(struct st_app_context* ctx, st_json_video_session_t video ? st_json_ip(ctx, &video->base, MTL_SESSION_PORT_R) : ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_R], + video ? video->base.mcast_src_ip[MTL_PORT_R] : ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf( ops.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", video ? video->base.inf[MTL_SESSION_PORT_R]->name : ctx->para.port[MTL_PORT_R]); diff --git a/app/src/rx_st22_app.c b/app/src/rx_st22_app.c index 963415e2e..97f9c4a95 100644 --- a/app/src/rx_st22_app.c +++ b/app/src/rx_st22_app.c @@ -192,12 +192,16 @@ static int app_rx_st22_init(struct st_app_context* ctx, struct st22_app_rx_sessi ops.priv = s; ops.num_port = ctx->para.num_ports; memcpy(ops.sip_addr[MTL_SESSION_PORT_P], ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy(ops.mcast_sip_addr[MTL_SESSION_PORT_P], ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf(ops.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", ctx->para.port[MTL_PORT_P]); ops.udp_port[MTL_SESSION_PORT_P] = 15000 + s->idx; if (ops.num_port > 1) { memcpy(ops.sip_addr[MTL_SESSION_PORT_R], ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy(ops.mcast_sip_addr[MTL_SESSION_PORT_R], ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf(ops.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", ctx->para.port[MTL_PORT_R]); ops.udp_port[MTL_SESSION_PORT_R] = 15000 + s->idx; diff --git a/app/src/rx_st22p_app.c b/app/src/rx_st22p_app.c index 88dbe4e17..fd3f33590 100644 --- a/app/src/rx_st22p_app.c +++ b/app/src/rx_st22p_app.c @@ -144,6 +144,10 @@ static int app_rx_st22p_init(struct st_app_context* ctx, st22p ? st_json_ip(ctx, &st22p->base, MTL_SESSION_PORT_P) : ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_P], + st22p ? st22p->base.mcast_src_ip[MTL_PORT_P] : ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf( ops.port.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", st22p ? st22p->base.inf[MTL_SESSION_PORT_P]->name : ctx->para.port[MTL_PORT_P]); @@ -153,6 +157,10 @@ static int app_rx_st22p_init(struct st_app_context* ctx, st22p ? st_json_ip(ctx, &st22p->base, MTL_SESSION_PORT_R) : ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_R], + st22p ? st22p->base.mcast_src_ip[MTL_PORT_R] : ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf( ops.port.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", st22p ? st22p->base.inf[MTL_SESSION_PORT_R]->name : ctx->para.port[MTL_PORT_R]); diff --git a/app/src/rx_video_app.c b/app/src/rx_video_app.c index 9a8844ab0..6bee129ba 100644 --- a/app/src/rx_video_app.c +++ b/app/src/rx_video_app.c @@ -502,6 +502,10 @@ static int app_rx_video_init(struct st_app_context* ctx, st_json_video_session_t video ? st_json_ip(ctx, &video->base, MTL_SESSION_PORT_P) : ctx->rx_sip_addr[MTL_PORT_P], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_P], + video ? video->base.mcast_src_ip[MTL_PORT_P] : ctx->rx_mcast_sip_addr[MTL_PORT_P], + MTL_IP_ADDR_LEN); snprintf( ops.port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s", video ? video->base.inf[MTL_SESSION_PORT_P]->name : ctx->para.port[MTL_PORT_P]); @@ -511,6 +515,10 @@ static int app_rx_video_init(struct st_app_context* ctx, st_json_video_session_t video ? st_json_ip(ctx, &video->base, MTL_SESSION_PORT_R) : ctx->rx_sip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN); + memcpy( + ops.mcast_sip_addr[MTL_SESSION_PORT_R], + video ? video->base.mcast_src_ip[MTL_PORT_R] : ctx->rx_mcast_sip_addr[MTL_PORT_R], + MTL_IP_ADDR_LEN); snprintf( ops.port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s", video ? video->base.inf[MTL_SESSION_PORT_R]->name : ctx->para.port[MTL_PORT_R]); diff --git a/lib/src/st2110/st_rx_ancillary_session.c b/lib/src/st2110/st_rx_ancillary_session.c index 27b800008..e1c76b1a1 100644 --- a/lib/src/st2110/st_rx_ancillary_session.c +++ b/lib/src/st2110/st_rx_ancillary_session.c @@ -277,7 +277,8 @@ static int rx_ancillary_session_init_mcast(struct mtl_main_impl* impl, info("%s(%d), skip mcast join for port %d\n", __func__, s->idx, i); return 0; } - ret = mt_mcast_join(impl, mt_ip_to_u32(ops->sip_addr[i]), 0, + ret = mt_mcast_join(impl, mt_ip_to_u32(ops->sip_addr[i]), + mt_ip_to_u32(ops->mcast_sip_addr[i]), mt_port_logic2phy(s->port_maps, i)); if (ret < 0) return ret; } diff --git a/lib/src/st2110/st_rx_audio_session.c b/lib/src/st2110/st_rx_audio_session.c index 2439456e2..8a3070f9e 100644 --- a/lib/src/st2110/st_rx_audio_session.c +++ b/lib/src/st2110/st_rx_audio_session.c @@ -678,7 +678,8 @@ static int rx_audio_session_init_mcast(struct mtl_main_impl* impl, info("%s(%d), skip mcast join for port %d\n", __func__, s->idx, i); return 0; } - ret = mt_mcast_join(impl, mt_ip_to_u32(ops->sip_addr[i]), 0, + ret = mt_mcast_join(impl, mt_ip_to_u32(ops->sip_addr[i]), + mt_ip_to_u32(ops->mcast_sip_addr[i]), mt_port_logic2phy(s->port_maps, i)); if (ret < 0) return ret; } diff --git a/lib/src/st2110/st_rx_video_session.c b/lib/src/st2110/st_rx_video_session.c index d09deb09e..6beaa034e 100644 --- a/lib/src/st2110/st_rx_video_session.c +++ b/lib/src/st2110/st_rx_video_session.c @@ -2701,7 +2701,8 @@ static int rv_init_mcast(struct mtl_main_impl* impl, struct st_rx_video_session_ info("%s(%d), skip mcast join for port %d\n", __func__, s->idx, i); return 0; } - ret = mt_mcast_join(impl, mt_ip_to_u32(ops->sip_addr[i]), 0, port); + ret = mt_mcast_join(impl, mt_ip_to_u32(ops->sip_addr[i]), + mt_ip_to_u32(ops->mcast_sip_addr[i]), port); if (ret < 0) return ret; }