[Pkg-voip-commits] [janus] 84/163: Allow rtpmap/fmtp to be overridden when creating RTSP mountpoints (fixes #972)

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:12 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 ecc0607f4f53946a58228782b199ff4aca7d515b
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Mon Sep 4 13:07:43 2017 +0200

    Allow rtpmap/fmtp to be overridden when creating RTSP mountpoints (fixes #972)
---
 conf/janus.plugin.streaming.cfg.sample.in |  6 ++++
 plugins/janus_streaming.c                 | 60 +++++++++++++++++++++++--------
 2 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/conf/janus.plugin.streaming.cfg.sample.in b/conf/janus.plugin.streaming.cfg.sample.in
index b703166..87c9e2b 100644
--- a/conf/janus.plugin.streaming.cfg.sample.in
+++ b/conf/janus.plugin.streaming.cfg.sample.in
@@ -46,6 +46,11 @@
 ; rtsp_pwd = RTSP authorization password (only if type=rtsp)
 ; rtspiface = network interface or IP address to bind to, if any (binds to all otherwise), when receiving RTSP streams
 ;
+; Notice that, for 'rtsp' mountpoints, normally the plugin uses the exact
+; SDP rtpmap and fmtp attributes the remote camera or RTSP server sent.
+; In case the values set remotely are known to conflict with WebRTC viewers,
+; you can override both using the settings introduced above.
+;
 ; To test the [gstreamer-sample] example, check the test_gstreamer.sh
 ; script in the plugins/streams folder. To test the live and on-demand
 ; audio file streams, instead, the install.sh installation script
@@ -132,6 +137,7 @@ secret = adminpwd
 ; authentication will only work if you installed libcurl >= 7.45.0)
 ; NOTE WELL: the plugin does NOT transcode, so the RTSP stream MUST be
 ; in a format the browser can digest (e.g., VP8 or H.264 baseline for video)
+; Again, you can override rtpmap and/or fmtp, if needed
 ;
 ;[rtsp-test]
 ;type = rtsp
diff --git a/plugins/janus_streaming.c b/plugins/janus_streaming.c
index 0ac4a6e..686ed92 100644
--- a/plugins/janus_streaming.c
+++ b/plugins/janus_streaming.c
@@ -276,7 +276,11 @@ static struct janus_json_parameter rtsp_parameters[] = {
 	{"rtsp_user", JSON_STRING, 0},
 	{"rtsp_pwd", JSON_STRING, 0},
 	{"audio", JANUS_JSON_BOOL, 0},
+	{"audiortpmap", JSON_STRING, 0},
+	{"audiofmtp", JSON_STRING, 0},
 	{"video", JANUS_JSON_BOOL, 0},
+	{"videortpmap", JSON_STRING, 0},
+	{"videofmtp", JSON_STRING, 0},
 	{"rtspiface", JSON_STRING, 0}
 };
 #endif
@@ -477,7 +481,9 @@ janus_streaming_mountpoint *janus_streaming_create_file_source(
 janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
 		uint64_t id, char *name, char *desc,
 		char *url, char *username, char *password,
-		gboolean doaudio, gboolean dovideo, const janus_network_address *iface);
+		gboolean doaudio, char *artpmap, char *afmtp,
+		gboolean dovideo, char *vrtpmap, char *vfmtp,
+		const janus_network_address *iface);
 
 
 typedef struct janus_streaming_message {
@@ -985,7 +991,11 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
 				janus_config_item *username = janus_config_get_item(cat, "rtsp_user");
 				janus_config_item *password = janus_config_get_item(cat, "rtsp_pwd");
 				janus_config_item *audio = janus_config_get_item(cat, "audio");
+				janus_config_item *artpmap = janus_config_get_item(cat, "audiortpmap");
+				janus_config_item *afmtp = janus_config_get_item(cat, "audiofmtp");
 				janus_config_item *video = janus_config_get_item(cat, "video");
+				janus_config_item *vrtpmap = janus_config_get_item(cat, "videortpmap");
+				janus_config_item *vfmtp = janus_config_get_item(cat, "videofmtp");
 				janus_config_item *iface = janus_config_get_item(cat, "rtspiface");
 				janus_network_address iface_value;
 				if(file == NULL || file->value == NULL) {
@@ -1031,7 +1041,12 @@ int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
 						(char *)file->value,
 						username ? (char *)username->value : NULL,
 						password ? (char *)password->value : NULL,
-						doaudio, dovideo,
+						doaudio,
+						artpmap ? (char *)artpmap->value : NULL,
+						afmtp ? (char *)afmtp->value : NULL,
+						dovideo,
+						vrtpmap ? (char *)vrtpmap->value : NULL,
+						vfmtp ? (char *)vfmtp->value : NULL,
 						iface && iface->value ? &iface_value : NULL)) == NULL) {
 					JANUS_LOG(LOG_ERR, "Error creating 'rtsp' stream '%s'...\n", cat->name);
 					cl = cl->next;
@@ -1727,7 +1742,11 @@ struct janus_plugin_result *janus_streaming_handle_message(janus_plugin_session
 			json_t *desc = json_object_get(root, "description");
 			json_t *is_private = json_object_get(root, "is_private");
 			json_t *audio = json_object_get(root, "audio");
+			json_t *audiortpmap = json_object_get(root, "audiortpmap");
+			json_t *audiofmtp = json_object_get(root, "audiofmtp");
 			json_t *video = json_object_get(root, "video");
+			json_t *videortpmap = json_object_get(root, "videortpmap");
+			json_t *videofmtp = json_object_get(root, "videofmtp");
 			json_t *url = json_object_get(root, "url");
 			json_t *username = json_object_get(root, "rtsp_user");
 			json_t *password = json_object_get(root, "rtsp_pwd");
@@ -1759,7 +1778,9 @@ struct janus_plugin_result *janus_streaming_handle_message(janus_plugin_session
 					(char *)json_string_value(url),
 					username ? (char *)json_string_value(username) : NULL,
 					password ? (char *)json_string_value(password) : NULL,
-					doaudio, dovideo, &multicast_iface);
+					doaudio, (char *)json_string_value(audiortpmap), (char *)json_string_value(audiofmtp),
+					dovideo, (char *)json_string_value(videortpmap), (char *)json_string_value(videofmtp),
+					&multicast_iface);
 			if(mp == NULL) {
 				JANUS_LOG(LOG_ERR, "Error creating 'rtsp' stream...\n");
 				error_code = JANUS_STREAMING_ERROR_CANT_CREATE;
@@ -3608,17 +3629,17 @@ static int janus_streaming_rtsp_connect_to_server(janus_streaming_mountpoint *mp
 		}
 	}
 
-	/* Update the source */
+	/* Update the source (but check if rtpmap/fmtp need to be overridden) */
 	mp->codecs.audio_pt = doaudio ? apt : -1;
-	g_free(mp->codecs.audio_rtpmap);
-	g_free(mp->codecs.audio_fmtp);
-	mp->codecs.audio_rtpmap = doaudio ? g_strdup(artpmap) : NULL;
-	mp->codecs.audio_fmtp = doaudio ? g_strdup(afmtp) : NULL;
+	if(mp->codecs.audio_rtpmap == NULL)
+		mp->codecs.audio_rtpmap = doaudio ? g_strdup(artpmap) : NULL;
+	if(mp->codecs.audio_fmtp == NULL)
+		mp->codecs.audio_fmtp = doaudio ? g_strdup(afmtp) : NULL;
 	mp->codecs.video_pt = dovideo ? vpt : -1;
-	g_free(mp->codecs.video_rtpmap);
-	g_free(mp->codecs.video_fmtp);
-	mp->codecs.video_rtpmap = dovideo ? g_strdup(vrtpmap) : NULL;
-	mp->codecs.video_fmtp = dovideo ? g_strdup(vfmtp) : NULL;
+	if(mp->codecs.video_rtpmap == NULL)
+		mp->codecs.video_rtpmap = dovideo ? g_strdup(vrtpmap) : NULL;
+	if(mp->codecs.video_fmtp == NULL)
+		mp->codecs.video_fmtp = dovideo ? g_strdup(vfmtp) : NULL;
 	source->audio_fd = audio_fds.fd;
 	source->audio_rtcp_fd = audio_fds.rtcp_fd;
 	source->video_fd[0] = video_fds.fd;
@@ -3658,7 +3679,9 @@ static int janus_streaming_rtsp_play(janus_streaming_rtp_source *source) {
 janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
 		uint64_t id, char *name, char *desc,
 		char *url, char *username, char *password,
-		gboolean doaudio, gboolean dovideo, const janus_network_address *iface) {
+		gboolean doaudio, char *artpmap, char *afmtp,
+		gboolean dovideo, char *vrtpmap, char *vfmtp,
+		const janus_network_address *iface) {
 	if(url == NULL) {
 		JANUS_LOG(LOG_ERR, "Can't add 'rtsp' stream, missing url...\n");
 		return NULL;
@@ -3731,6 +3754,13 @@ janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
 	live_rtsp->listeners = NULL;
 	live_rtsp->destroyed = 0;
 	janus_mutex_init(&live_rtsp->mutex);
+	/* We may have to override the rtpmap and/or fmtp for audio and/or video */
+	live_rtsp->codecs.audio_rtpmap = doaudio ? (artpmap ? g_strdup(artpmap) : NULL) : NULL;
+	live_rtsp->codecs.audio_fmtp = doaudio ? (afmtp ? g_strdup(afmtp) : NULL) : NULL;
+	live_rtsp->codecs.video_rtpmap = dovideo ? (vrtpmap ? g_strdup(vrtpmap) : NULL) : NULL;
+	live_rtsp->codecs.video_fmtp = dovideo ? (vfmtp ? g_strdup(vfmtp) : NULL) : NULL;
+		live_rtsp->codecs.audio_rtpmap, live_rtsp->codecs.audio_fmtp,
+		live_rtsp->codecs.video_rtpmap, live_rtsp->codecs.video_fmtp);
 	/* Now connect to the RTSP server */
 	if(janus_streaming_rtsp_connect_to_server(live_rtsp) < 0) {
 		/* Error connecting, get rid of the mountpoint */
@@ -3765,7 +3795,9 @@ janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
 janus_streaming_mountpoint *janus_streaming_create_rtsp_source(
 		uint64_t id, char *name, char *desc,
 		char *url, char *username, char *password,
-		gboolean doaudio, gboolean dovideo, const janus_network_address *iface) {
+		gboolean doaudio, char *audiortpmap, char *audiofmtp,
+		gboolean dovideo, char *videortpmap, char *videofmtp,
+		const janus_network_address *iface) {
 	JANUS_LOG(LOG_ERR, "RTSP need libcurl\n");
 	return NULL;
 }

-- 
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