Skip to content

Commit

Permalink
Fix broken switch when using remote publishers (fixes meetecho#3444)
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero authored and Alexander Malaev committed Oct 8, 2024
1 parent 82fb5ba commit c6694ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/plugins/janus_videoroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,7 @@ typedef struct janus_videoroom_publisher {
GHashTable *remote_recipients;
/* In case this is a remote publisher */
gboolean remote; /* Whether this is a remote publisher */
uint32_t remote_ssrc_offset; /* SSRC offset to apply to the incoming RTP traffic */
int remote_fd, remote_rtcp_fd, pipefd[2]; /* Remote publisher sockets */
struct sockaddr_storage rtcp_addr; /* RTCP address of the remote publisher */
GThread *remote_thread; /* Remote publisher incoming packets thread */
Expand Down Expand Up @@ -7932,6 +7933,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
publisher->vcodec = JANUS_VIDEOCODEC_NONE;
publisher->data_mindex = -1;
publisher->remote = TRUE;
publisher->remote_ssrc_offset = janus_random_uint32();
publisher->remote_fd = fd;
publisher->remote_rtcp_fd = rtcp_fd;
publisher->server_id = server_id ? g_strdup(json_string_value(server_id)) : NULL;
Expand Down Expand Up @@ -14109,6 +14111,9 @@ static void *janus_videoroom_remote_publisher_thread(void *user_data) {
pkt.extensions.max_delay = max;
}
}
/* Apply an SSRC offset to avoid issues when switching,
* see https://github.com/meetecho/janus-gateway/issues/3444 */
rtp->ssrc = htonl(ntohl(rtp->ssrc) + publisher->remote_ssrc_offset);
/* Now handle the packet as if coming from a regular publisher */
janus_videoroom_incoming_rtp_internal(publisher->session, publisher, &pkt);
}
Expand Down

0 comments on commit c6694ea

Please sign in to comment.