Skip to content

Commit

Permalink
Parse SSRC used for retransmissions by Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero committed Aug 26, 2015
1 parent 9355a07 commit 3c5413c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,12 +1280,17 @@ void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint component_i
} else {
/* Bundled streams, check SSRC */
guint32 packet_ssrc = ntohl(header->ssrc);
video = (stream->video_ssrc_peer == packet_ssrc ? 1 : 0);
video = ((stream->video_ssrc_peer == packet_ssrc || stream->video_ssrc_peer_rtx == packet_ssrc) ? 1 : 0);
if(!video && stream->audio_ssrc_peer != packet_ssrc) {
/* FIXME In case it happens, we should check what it is: maybe retransmissions with a different SSRC? */
/* FIXME In case it happens, we should check what it is */
JANUS_LOG(LOG_WARN, "Not video and not audio? dropping (SSRC %"SCNu32")...\n", packet_ssrc);
return;
}
if(stream->video_ssrc_peer_rtx == packet_ssrc) {
/* FIXME This is a video retransmission: set the regular peer SSRC so
* that we avoid outgoing SRTP errors in case we got the packet already */
header->ssrc = htonl(stream->video_ssrc_peer);
}
//~ JANUS_LOG(LOG_VERB, "[RTP] Bundling: this is %s (video=%"SCNu64", audio=%"SCNu64", got %ld)\n",
//~ video ? "video" : "audio", stream->video_ssrc_peer, stream->audio_ssrc_peer, ntohl(header->ssrc));
}
Expand Down Expand Up @@ -2184,6 +2189,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
audio_stream->video_ssrc = g_random_int(); /* FIXME Should we look for conflicts? */
}
audio_stream->video_ssrc_peer = 0; /* FIXME Right now we don't know what this will be */
audio_stream->video_ssrc_peer_rtx = 0; /* FIXME Right now we don't know what this will be */
janus_mutex_init(&audio_stream->mutex);
audio_stream->components = g_hash_table_new(NULL, NULL);
g_hash_table_insert(handle->streams, GUINT_TO_POINTER(handle->audio_id), audio_stream);
Expand Down Expand Up @@ -2333,6 +2339,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
video_stream->dtls_role = offer ? JANUS_DTLS_ROLE_CLIENT : JANUS_DTLS_ROLE_ACTPASS;
video_stream->video_ssrc = g_random_int(); /* FIXME Should we look for conflicts? */
video_stream->video_ssrc_peer = 0; /* FIXME Right now we don't know what this will be */
video_stream->video_ssrc_peer_rtx = 0; /* FIXME Right now we don't know what this will be */
video_stream->audio_ssrc = 0;
video_stream->audio_ssrc_peer = 0;
video_stream->components = g_hash_table_new(NULL, NULL);
Expand Down
2 changes: 2 additions & 0 deletions ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ struct janus_ice_stream {
guint32 audio_ssrc_peer;
/*! \brief Video SSRC of the peer for this stream (may be bundled) */
guint32 video_ssrc_peer;
/*! \brief Video retransmissions SSRC of the peer for this stream (may be bundled) */
guint32 video_ssrc_peer_rtx;
/*! \brief RTP payload type of this stream */
gint payload_type;
/*! \brief DTLS role of the gateway for this stream */
Expand Down
4 changes: 4 additions & 0 deletions janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,7 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
if(handle->streams && handle->video_stream) {
handle->audio_stream->video_ssrc = handle->video_stream->video_ssrc;
handle->audio_stream->video_ssrc_peer = handle->video_stream->video_ssrc_peer;
handle->audio_stream->video_ssrc_peer_rtx = handle->video_stream->video_ssrc_peer_rtx;
janus_ice_stream_free(handle->streams, handle->video_stream);
}
handle->video_stream = NULL;
Expand Down Expand Up @@ -3385,6 +3386,8 @@ json_t *janus_admin_stream_summary(janus_ice_stream *stream) {
json_object_set_new(ss, "audio-peer", json_integer(stream->audio_ssrc_peer));
if(stream->video_ssrc_peer)
json_object_set_new(ss, "video-peer", json_integer(stream->video_ssrc_peer));
if(stream->video_ssrc_peer_rtx)
json_object_set_new(ss, "video-peer-rtx", json_integer(stream->video_ssrc_peer_rtx));
json_object_set_new(s, "ssrc", ss);
json_t *components = json_array();
if(stream->rtp_component) {
Expand Down Expand Up @@ -3756,6 +3759,7 @@ json_t *janus_handle_sdp(janus_plugin_session *handle, janus_plugin *plugin, con
if(ice_handle->streams && ice_handle->video_stream) {
ice_handle->audio_stream->video_ssrc = ice_handle->video_stream->video_ssrc;
ice_handle->audio_stream->video_ssrc_peer = ice_handle->video_stream->video_ssrc_peer;
ice_handle->audio_stream->video_ssrc_peer_rtx = ice_handle->video_stream->video_ssrc_peer_rtx;
janus_ice_stream_free(ice_handle->streams, ice_handle->video_stream);
}
ice_handle->video_stream = NULL;
Expand Down
6 changes: 6 additions & 0 deletions sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ int janus_sdp_parse_ssrc(janus_ice_stream *stream, const char *ssrc_attr, int vi
if(stream->video_ssrc_peer == 0) {
stream->video_ssrc_peer = ssrc;
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Peer video SSRC: %u\n", handle->handle_id, stream->video_ssrc_peer);
} else if(stream->video_ssrc_peer != ssrc) {
/* FIXME We assume the second SSRC we get is the one Chrome associates with retransmissions, e.g.
* a=ssrc-group:FID 586466331 2053167359 (SSRC SSRC-rtx)
* SSRC group FID: https://tools.ietf.org/html/rfc3388#section-7 */
stream->video_ssrc_peer_rtx = ssrc;
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Peer video SSRC (rtx): %u\n", handle->handle_id, stream->video_ssrc_peer_rtx);
}
} else {
if(stream->audio_ssrc_peer == 0) {
Expand Down

0 comments on commit 3c5413c

Please sign in to comment.