@@ -2419,6 +2419,7 @@ typedef struct janus_videoroom_publisher {
2419
2419
GHashTable *remote_recipients;
2420
2420
/* In case this is a remote publisher */
2421
2421
gboolean remote; /* Whether this is a remote publisher */
2422
+ uint32_t remote_ssrc_offset; /* SSRC offset to apply to the incoming RTP traffic */
2422
2423
int remote_fd, remote_rtcp_fd, pipefd[2]; /* Remote publisher sockets */
2423
2424
struct sockaddr_storage rtcp_addr; /* RTCP address of the remote publisher */
2424
2425
GThread *remote_thread; /* Remote publisher incoming packets thread */
@@ -7697,6 +7698,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
7697
7698
publisher->vcodec = JANUS_VIDEOCODEC_NONE;
7698
7699
publisher->data_mindex = -1;
7699
7700
publisher->remote = TRUE;
7701
+ publisher->remote_ssrc_offset = janus_random_uint32();
7700
7702
publisher->remote_fd = fd;
7701
7703
publisher->remote_rtcp_fd = rtcp_fd;
7702
7704
pipe(publisher->pipefd);
@@ -7794,9 +7796,9 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
7794
7796
ps->simulcast = json_is_true(json_object_get(s, "simulcast"));
7795
7797
ps->svc = json_is_true(json_object_get(s, "svc"));
7796
7798
if(ps->simulcast) {
7797
- ps->vssrc[0] = REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP);
7798
- ps->vssrc[1] = REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 1;
7799
- ps->vssrc[2] = REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 2;
7799
+ ps->vssrc[0] = publisher->remote_ssrc_offset + REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP);
7800
+ ps->vssrc[1] = publisher->remote_ssrc_offset + REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 1;
7801
+ ps->vssrc[2] = publisher->remote_ssrc_offset + REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 2;
7800
7802
}
7801
7803
}
7802
7804
int video_orient_extmap_id = json_integer_value(json_object_get(s, "videoorient_ext_id"));
@@ -8072,9 +8074,9 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
8072
8074
ps->simulcast = json_is_true(json_object_get(s, "simulcast"));
8073
8075
ps->svc = json_is_true(json_object_get(s, "svc"));
8074
8076
if(ps->simulcast) {
8075
- ps->vssrc[0] = REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP);
8076
- ps->vssrc[1] = REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 1;
8077
- ps->vssrc[2] = REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 2;
8077
+ ps->vssrc[0] = publisher->remote_ssrc_offset + REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP);
8078
+ ps->vssrc[1] = publisher->remote_ssrc_offset + REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 1;
8079
+ ps->vssrc[2] = publisher->remote_ssrc_offset + REMOTE_PUBLISHER_BASE_SSRC + (mindex*REMOTE_PUBLISHER_SSRC_STEP) + 2;
8078
8080
}
8079
8081
}
8080
8082
int video_orient_extmap_id = json_integer_value(json_object_get(s, "videoorient_ext_id"));
@@ -13682,6 +13684,9 @@ static void *janus_videoroom_remote_publisher_thread(void *user_data) {
13682
13684
pkt.extensions.max_delay = max;
13683
13685
}
13684
13686
}
13687
+ /* Apply an SSRC offset to avoid issues when switching,
13688
+ * see https://github.com/meetecho/janus-gateway/issues/3444 */
13689
+ rtp->ssrc = htonl(ntohl(rtp->ssrc) + publisher->remote_ssrc_offset);
13685
13690
/* Now handle the packet as if coming from a regular publisher */
13686
13691
janus_videoroom_incoming_rtp_internal(publisher->session, publisher, &pkt);
13687
13692
}
0 commit comments