Skip to content

Commit c2dbb17

Browse files
committed
Merge branch 'master' into libconfig
2 parents a6904a7 + 7ce6037 commit c2dbb17

35 files changed

+358
-259
lines changed

conf/janus.plugin.videoroom.jcfg.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ room-1234: {
5151
fir_freq = 10
5252
#audiocodec = "opus"
5353
#videocodec = "vp8"
54+
#transport_wide_cc_ext = true
5455
record = false
5556
#rec_dir = "/path/to/recordings-folder"
5657
}
@@ -68,4 +69,5 @@ room-5678: {
6869
fir_freq = 10
6970
videocodec = "vp9"
7071
video_svc = true
72+
#transport_wide_cc_ext = true
7173
}

html/videoroomtest.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ $(document).ready(function() {
109109
Janus.debug("Consent dialog should be " + (on ? "on" : "off") + " now");
110110
if(on) {
111111
// Darken screen and show hint
112-
$.blockUI({
112+
$.blockUI({
113113
message: '<div><img src="up_arrow.png"/></div>',
114114
css: {
115115
border: 'none',
@@ -457,20 +457,20 @@ function newRemoteFeed(id, display, audio, video) {
457457
Janus.log("Plugin attached! (" + remoteFeed.getPlugin() + ", id=" + remoteFeed.getId() + ")");
458458
Janus.log(" -- This is a subscriber");
459459
// We wait for the plugin to send us an offer
460-
var listen = { "request": "join", "room": myroom, "ptype": "subscriber", "feed": id, "private_id": mypvtid };
460+
var subscribe = { "request": "join", "room": myroom, "ptype": "subscriber", "feed": id, "private_id": mypvtid };
461461
// In case you don't want to receive audio, video or data, even if the
462462
// publisher is sending them, set the 'offer_audio', 'offer_video' or
463463
// 'offer_data' properties to false (they're true by default), e.g.:
464-
// listen["offer_video"] = false;
464+
// subscribe["offer_video"] = false;
465465
// For example, if the publisher is VP8 and this is Safari, let's avoid video
466466
if(video !== "h264" && Janus.webRTCAdapter.browserDetails.browser === "safari") {
467467
if(video)
468468
video = video.toUpperCase()
469469
toastr.warning("Publisher is using " + video + ", but Safari doesn't support it: disabling video");
470-
listen["offer_video"] = false;
470+
subscribe["offer_video"] = false;
471471
}
472472
remoteFeed.videoCodec = video;
473-
remoteFeed.send({"message": listen});
473+
remoteFeed.send({"message": subscribe});
474474
},
475475
error: function(error) {
476476
Janus.error(" -- Error attaching plugin...", error);
@@ -624,7 +624,7 @@ function newRemoteFeed(id, display, audio, video) {
624624
$('#novideo'+remoteFeed.rfindex).remove();
625625
$('#curbitrate'+remoteFeed.rfindex).remove();
626626
$('#curres'+remoteFeed.rfindex).remove();
627-
if(bitrateTimer[remoteFeed.rfindex] !== null && bitrateTimer[remoteFeed.rfindex] !== null)
627+
if(bitrateTimer[remoteFeed.rfindex] !== null && bitrateTimer[remoteFeed.rfindex] !== null)
628628
clearInterval(bitrateTimer[remoteFeed.rfindex]);
629629
bitrateTimer[remoteFeed.rfindex] = null;
630630
remoteFeed.simulcastStarted = false;

ice.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,10 +2286,11 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
22862286
janus_mutex_unlock(&stream->mutex);
22872287
}
22882288
}
2289-
if(video && stream->rtx_nacked[vindex] != NULL) {
2289+
if(video) {
22902290
/* Check if this packet is a duplicate: can happen with RFC4588 */
22912291
guint16 seqno = ntohs(header->seq_number);
2292-
int nstate = GPOINTER_TO_INT(g_hash_table_lookup(stream->rtx_nacked[vindex], GUINT_TO_POINTER(seqno)));
2292+
int nstate = stream->rtx_nacked[vindex] ?
2293+
GPOINTER_TO_INT(g_hash_table_lookup(stream->rtx_nacked[vindex], GUINT_TO_POINTER(seqno))) : 0;
22932294
if(nstate == 1) {
22942295
/* Packet was NACKed and this is the first time we receive it: change state to received */
22952296
JANUS_LOG(LOG_HUGE, "[%"SCNu64"] Received NACKed packet %"SCNu16" (SSRC %"SCNu32", vindex %d)...\n",
@@ -2300,6 +2301,16 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
23002301
JANUS_LOG(LOG_HUGE, "[%"SCNu64"] Detected duplicate packet %"SCNu16" (SSRC %"SCNu32", vindex %d)...\n",
23012302
handle->handle_id, seqno, packet_ssrc, vindex);
23022303
return;
2304+
} else if(rtx && nstate == 0) {
2305+
/* We received a retransmission for a packet we didn't NACK: drop it
2306+
* FIXME This seems to happen with Chrome when RFC4588 is enabled: in that case,
2307+
* Chrome sends the first packet ~8 times as a retransmission, probably to ensure
2308+
* we receive it, since the first packet cannot be NACKed (NACKs are triggered
2309+
* when there's a gap in between two packets, and the first doesn't have a reference)
2310+
* Rather than dropping, we should add a better check in the future */
2311+
JANUS_LOG(LOG_HUGE, "[%"SCNu64"] Got a retransmission for non-NACKed packet %"SCNu16" (SSRC %"SCNu32", vindex %d)...\n",
2312+
handle->handle_id, seqno, packet_ssrc, vindex);
2313+
return;
23032314
}
23042315
}
23052316
/* Backup the RTP header before passing it to the proper RTP switching context */
@@ -2399,7 +2410,8 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
23992410

24002411
/* Update the RTCP context as well */
24012412
rtcp_context *rtcp_ctx = video ? stream->video_rtcp_ctx[vindex] : stream->audio_rtcp_ctx;
2402-
janus_rtcp_process_incoming_rtp(rtcp_ctx, buf, buflen);
2413+
gboolean count_lost = ((!video && !component->do_audio_nacks) || (video && !component->do_video_nacks)) ? TRUE : FALSE;
2414+
janus_rtcp_process_incoming_rtp(rtcp_ctx, buf, buflen, count_lost);
24032415

24042416
/* Keep track of RTP sequence numbers, in case we need to NACK them */
24052417
/* Note: unsigned int overflow/underflow wraps (defined behavior) */
@@ -2466,6 +2478,7 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
24662478
} else if(cur_seq->state == SEQ_MISSING && now - cur_seq->ts > SEQ_MISSING_WAIT) {
24672479
JANUS_LOG(LOG_HUGE, "[%"SCNu64"] Missed sequence number %"SCNu16" (%s stream #%d), sending 1st NACK\n",
24682480
handle->handle_id, cur_seq->seq, video ? "video" : "audio", vindex);
2481+
rtcp_ctx->lost++;
24692482
nacks = g_slist_prepend(nacks, GUINT_TO_POINTER(cur_seq->seq));
24702483
cur_seq->state = SEQ_NACKED;
24712484
if(video && janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RFC4588_RTX)) {
@@ -3949,7 +3962,8 @@ static gboolean janus_ice_outgoing_traffic_handle(janus_ice_handle *handle, janu
39493962
janus_rtp_header *header = (janus_rtp_header *)pkt->data;
39503963
guint32 timestamp = ntohl(header->timestamp);
39513964
guint16 seq = ntohs(header->seq_number);
3952-
JANUS_LOG(LOG_ERR, "[%"SCNu64"] ... SRTP protect error... %s (len=%d-->%d, ts=%"SCNu32", seq=%"SCNu16")...\n", handle->handle_id, janus_srtp_error_str(res), pkt->length, protected, timestamp, seq);
3965+
JANUS_LOG(LOG_DBG, "[%"SCNu64"] ... SRTP protect error... %s (len=%d-->%d, ts=%"SCNu32", seq=%"SCNu16")...\n",
3966+
handle->handle_id, janus_srtp_error_str(res), pkt->length, protected, timestamp, seq);
39533967
janus_ice_free_rtp_packet(p);
39543968
} else {
39553969
/* Shoot! */

ice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ struct janus_ice_stream {
354354
/*! \brief Codecs used by this stream */
355355
char *audio_codec, *video_codec;
356356
/*! \brief Pointer to function to check if a packet is a keyframe (depends on negotiated codec) */
357-
gboolean (* video_is_keyframe)(char* buffer, int len);
357+
gboolean (* video_is_keyframe)(const char* buffer, int len);
358358
/*! \brief Media direction */
359359
gboolean audio_send, audio_recv, video_send, video_recv;
360360
/*! \brief RTCP context for the audio stream */
@@ -378,7 +378,7 @@ struct janus_ice_stream {
378378
/*! \brief Wether we do transport wide cc for video */
379379
gboolean do_transport_wide_cc;
380380
/*! \brief Transport wide cc rtp ext ID */
381-
guint transport_wide_cc_ext_id;
381+
gint transport_wide_cc_ext_id;
382382
/*! \brief Last received transport wide seq num */
383383
guint32 transport_wide_cc_last_seq_num;
384384
/*! \brief Last transport wide seq num sent on feedback */

janus.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ int janus_process_incoming_request(janus_request *request) {
12271227
} else {
12281228
/* Check if transport wide CC is supported */
12291229
int transport_wide_cc_ext_id = janus_rtp_header_extension_get_id(jsep_sdp, JANUS_RTP_EXTMAP_TRANSPORT_WIDE_CC);
1230-
handle->stream->do_transport_wide_cc = TRUE;
1230+
handle->stream->do_transport_wide_cc = transport_wide_cc_ext_id > 0 ? TRUE : FALSE;
12311231
handle->stream->transport_wide_cc_ext_id = transport_wide_cc_ext_id;
12321232
}
12331233
} else {
@@ -2333,6 +2333,11 @@ json_t *janus_admin_stream_summary(janus_ice_stream *stream) {
23332333
json_object_set_new(sc, "video-codec", json_string(stream->video_codec));
23342334
json_object_set_new(s, "codecs", sc);
23352335
}
2336+
json_t *bwe = json_object();
2337+
json_object_set_new(bwe, "twcc", stream->do_transport_wide_cc ? json_true() : json_false());
2338+
if(stream->transport_wide_cc_ext_id >= 0)
2339+
json_object_set_new(bwe, "twcc-ext-id", json_integer(stream->transport_wide_cc_ext_id));
2340+
json_object_set_new(s, "bwe", bwe);
23362341
json_t *components = json_array();
23372342
if(stream->component) {
23382343
json_t *c = janus_admin_component_summary(stream->component);
@@ -2922,12 +2927,6 @@ json_t *janus_plugin_handle_sdp(janus_plugin_session *plugin_session, janus_plug
29222927
janus_mutex_unlock(&ice_handle->mutex);
29232928
return NULL;
29242929
}
2925-
if (!offer) {
2926-
/* Check if transport wide CC is supported */
2927-
int transport_wide_cc_ext_id = janus_rtp_header_extension_get_id(sdp, JANUS_RTP_EXTMAP_TRANSPORT_WIDE_CC);
2928-
stream->do_transport_wide_cc = TRUE;
2929-
stream->transport_wide_cc_ext_id = transport_wide_cc_ext_id;
2930-
}
29312930
if(janus_flags_is_set(&ice_handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RFC4588_RTX) &&
29322931
stream->rtx_payload_types == NULL) {
29332932
/* Make sure we have a list of rtx payload types to generate, if needed */

plugins/janus_audiobridge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,13 +1506,14 @@ void janus_audiobridge_destroy(void) {
15061506
/* FIXME We should destroy the sessions cleanly */
15071507
janus_mutex_lock(&sessions_mutex);
15081508
g_hash_table_destroy(sessions);
1509+
sessions = NULL;
15091510
janus_mutex_unlock(&sessions_mutex);
15101511
janus_mutex_lock(&rooms_mutex);
15111512
g_hash_table_destroy(rooms);
1513+
rooms = NULL;
15121514
janus_mutex_unlock(&rooms_mutex);
15131515
g_async_queue_unref(messages);
15141516
messages = NULL;
1515-
sessions = NULL;
15161517

15171518
janus_config_destroy(config);
15181519
g_free(admin_key);

0 commit comments

Comments
 (0)