Skip to content

Commit

Permalink
add mcast_sip to app and st2110 lib
Browse files Browse the repository at this point in the history
Signed-off-by: Ric Li <[email protected]>
  • Loading branch information
ricmli committed Dec 6, 2023
1 parent 966e4c5 commit b98e7bf
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/src/app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions app/src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions app/src/rx_ancillary_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions app/src/rx_audio_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions app/src/rx_st20p_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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]);
Expand Down
8 changes: 8 additions & 0 deletions app/src/rx_st20r_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]);
Expand Down
4 changes: 4 additions & 0 deletions app/src/rx_st22_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions app/src/rx_st22p_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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]);
Expand Down
8 changes: 8 additions & 0 deletions app/src/rx_video_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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]);
Expand Down
3 changes: 2 additions & 1 deletion lib/src/st2110/st_rx_ancillary_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/st2110/st_rx_audio_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/st2110/st_rx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b98e7bf

Please sign in to comment.