[Pkg-voip-commits] [janus] 99/163: Notify VideoRoom publishers and subscribers about codecs This solves the problem of subscribers getting an SDP they can't process (e.g., Safari with an SDP containing VP8), as when receiving info on a new publisher they can look at the codec and decide to only subscribe to the media streams they support This also helps publishers hide the local webcam display, if it turns out their video stream has been rejected (e.g., Safari publishing H.264 only in a VP8 room)

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:18 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.5-1
in repository janus.

commit bcea14357a7834cd24c435af54942ed79562da4e
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Thu Sep 7 12:02:03 2017 +0200

    Notify VideoRoom publishers and subscribers about codecs
    This solves the problem of subscribers getting an SDP they can't process (e.g., Safari with an SDP containing VP8), as when receiving info on a new publisher they can look at the codec and decide to only subscribe to the media streams they support
    This also helps publishers hide the local webcam display, if it turns out their video stream has been rejected (e.g., Safari publishing H.264 only in a VP8 room)
---
 html/videoroomtest.js     | 38 +++++++++++++++++++++++++++++++++-----
 plugins/janus_videoroom.c | 19 +++++++++++++++++++
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/html/videoroomtest.js b/html/videoroomtest.js
index c17a13d..f6636d3 100644
--- a/html/videoroomtest.js
+++ b/html/videoroomtest.js
@@ -170,8 +170,10 @@ $(document).ready(function() {
 												for(var f in list) {
 													var id = list[f]["id"];
 													var display = list[f]["display"];
-													Janus.debug("  >> [" + id + "] " + display);
-													newRemoteFeed(id, display)
+													var audio = list[f]["audio_codec"];
+													var video = list[f]["video_codec"];
+													Janus.debug("  >> [" + id + "] " + display + " (audio: " + audio + ", video: " + video + ")");
+													newRemoteFeed(id, display, audio, video);
 												}
 											}
 										} else if(event === "destroyed") {
@@ -189,8 +191,10 @@ $(document).ready(function() {
 												for(var f in list) {
 													var id = list[f]["id"];
 													var display = list[f]["display"];
-													Janus.debug("  >> [" + id + "] " + display);
-													newRemoteFeed(id, display)
+													var audio = list[f]["audio_codec"];
+													var video = list[f]["video_codec"];
+													Janus.debug("  >> [" + id + "] " + display + " (audio: " + audio + ", video: " + video + ")");
+													newRemoteFeed(id, display, audio, video);
 												}
 											} else if(msg["leaving"] !== undefined && msg["leaving"] !== null) {
 												// One of the publishers has gone away?
@@ -252,6 +256,25 @@ $(document).ready(function() {
 										Janus.debug("Handling SDP as well...");
 										Janus.debug(jsep);
 										sfutest.handleRemoteJsep({jsep: jsep});
+										// Check if any of the media we wanted to publish has
+										// been rejected (e.g., wrong or unsupported codec)
+										var audio = msg["audio_codec"];
+										if(mystream && mystream.getAudioTracks() && mystream.getAudioTracks().length > 0 && !audio) {
+											// Audio has been rejected
+											toastr.warning("Our audio stream has been rejected, viewers won't hear us");
+										}
+										var video = msg["video_codec"];
+										if(mystream && mystream.getVideoTracks() && mystream.getVideoTracks().length > 0 && !video) {
+											// Video has been rejected
+											toastr.warning("Our video stream has been rejected, viewers won't hear us");
+											// Hide the webcam video
+											$('#myvideo').hide();
+											$('#videolocal').append(
+												'<div class="no-video-container">' +
+													'<i class="fa fa-video-camera fa-5 no-video-icon" style="height: 100%;"></i>' +
+													'<span class="no-video-text" style="font-size: 16px;">Video rejected, no webcam</span>' +
+												'</div>');
+										}
 									}
 								},
 								onlocalstream: function(stream) {
@@ -409,7 +432,7 @@ function unpublishOwnFeed() {
 	sfutest.send({"message": unpublish});
 }
 
-function newRemoteFeed(id, display) {
+function newRemoteFeed(id, display, audio, video) {
 	// A new feed has been published, create a new plugin handle and attach to it as a listener
 	var remoteFeed = null;
 	janus.attach(
@@ -427,6 +450,11 @@ function newRemoteFeed(id, display) {
 				// publisher is sending them, set the 'offer_audio', 'offer_video' or
 				// 'offer_data' properties to false (they're true by default), e.g.:
 				// 		listen["offer_video"] = false;
+				// For example, if the publisher is VP8 and this is Safari, let's avoid video
+				if(video === "vp8" && adapter.browserDetails.browser === "safari") {
+					toastr.warning("Publisher is using VP8, but Safari doesn't support it: disabling video");
+					listen["offer_video"] = false;
+				}
 				remoteFeed.send({"message": listen});
 			},
 			error: function(error) {
diff --git a/plugins/janus_videoroom.c b/plugins/janus_videoroom.c
index 7a2f3c8..c400a6b 100644
--- a/plugins/janus_videoroom.c
+++ b/plugins/janus_videoroom.c
@@ -1210,7 +1210,11 @@ json_t *janus_videoroom_query_session(janus_plugin_session *handle) {
 					json_object_set_new(info, "viewers", json_integer(g_slist_length(participant->listeners)));
 				json_t *media = json_object();
 				json_object_set_new(media, "audio", participant->audio ? json_true() : json_false());
+				if(participant->audio)
+					json_object_set_new(media, "audio_codec", json_string(janus_videoroom_audiocodec_name(participant->room->acodec)));
 				json_object_set_new(media, "video", participant->video ? json_true() : json_false());
+				if(participant->video)
+					json_object_set_new(media, "video_codec", json_string(janus_videoroom_videocodec_name(participant->room->acodec)));
 				json_object_set_new(media, "data", participant->data ? json_true() : json_false());
 				json_object_set_new(info, "media", media);
 				json_object_set_new(info, "bitrate", json_integer(participant->bitrate));
@@ -2500,6 +2504,10 @@ void janus_videoroom_setup_media(janus_plugin_session *handle) {
 			json_object_set_new(pl, "id", json_integer(participant->user_id));
 			if(participant->display)
 				json_object_set_new(pl, "display", json_string(participant->display));
+			if(participant->audio)
+				json_object_set_new(pl, "audio_codec", json_string(janus_videoroom_audiocodec_name(participant->room->acodec)));
+			if(participant->video)
+				json_object_set_new(pl, "video_codec", json_string(janus_videoroom_videocodec_name(participant->room->acodec)));
 			json_array_append_new(list, pl);
 			json_t *pub = json_object();
 			json_object_set_new(pub, "videoroom", json_string("event"));
@@ -3319,6 +3327,10 @@ static void *janus_videoroom_handler(void *data) {
 					json_object_set_new(pl, "id", json_integer(p->user_id));
 					if(p->display)
 						json_object_set_new(pl, "display", json_string(p->display));
+					if(p->audio)
+						json_object_set_new(pl, "audio_codec", json_string(janus_videoroom_audiocodec_name(p->room->acodec)));
+					if(p->video)
+						json_object_set_new(pl, "video_codec", json_string(janus_videoroom_videocodec_name(p->room->acodec)));
 					if(p->audio_level_extmap_id > 0)
 						json_object_set_new(pl, "talking", p->talking ? json_true() : json_false());
 					json_array_append_new(list, pl);
@@ -4149,6 +4161,13 @@ static void *janus_videoroom_handler(void *data) {
 				JANUS_LOG(LOG_VERB, "Per the answer, the publisher %s going to send an audio stream\n", participant->audio ? "is" : "is NOT");
 				JANUS_LOG(LOG_VERB, "Per the answer, the publisher %s going to send a video stream\n", participant->video ? "is" : "is NOT");
 				JANUS_LOG(LOG_VERB, "Per the answer, the publisher %s going to open a data channel\n", participant->data ? "is" : "is NOT");
+				/* Update the event with info on the codecs that we'll be handling */
+				if(event) {
+					if(participant->audio)
+						json_object_set_new(event, "audio_codec", json_string(janus_videoroom_audiocodec_name(participant->room->acodec)));
+					if(participant->video)
+						json_object_set_new(event, "video_codec", json_string(janus_videoroom_videocodec_name(participant->room->acodec)));
+				}
 				/* Also add a bandwidth SDP attribute if we're capping the bitrate in the room */
 				if(participant->firefox) {	/* Don't add any b=AS attribute for Chrome */
 					janus_sdp_mline *m = janus_sdp_mline_find(answer, JANUS_SDP_VIDEO);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list