[Pkg-voip-commits] [janus] 34/163: Merge branch 'master' into vp8-simulcast

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:06 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 8a7de5f419f932963ca11a51c75b7eb34c76baa0
Merge: 2320be4 5f5b80d
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Wed Jul 26 18:54:39 2017 +0200

    Merge branch 'master' into vp8-simulcast

 apierror.c                    |  1 -
 config.c                      | 31 +++++++-------
 configure.ac                  |  4 ++
 events.c                      |  1 +
 ice.c                         | 48 ++++++++++++++-------
 ice.h                         |  8 ++++
 ip-utils.c                    |  3 +-
 janus.c                       | 10 +++--
 plugins/janus_audiobridge.c   | 24 ++++-------
 plugins/janus_echotest.c      |  8 ++--
 plugins/janus_recordplay.c    | 35 +++++++++-------
 plugins/janus_sip.c           | 98 +++++++++++++++++++++++++++++++++++--------
 plugins/janus_streaming.c     | 92 ++++++++++++++++++++++------------------
 plugins/janus_textroom.c      | 18 ++++----
 plugins/janus_videocall.c     | 16 +++----
 plugins/janus_videoroom.c     | 41 +++++++++++-------
 plugins/janus_voicemail.c     |  2 +-
 postprocessing/pp-g711.c      |  1 +
 postprocessing/pp-webm.c      |  2 +-
 rtcp.c                        | 36 +++++++++-------
 rtcp.h                        | 10 ++---
 rtp.c                         | 18 +-------
 sdp-utils.c                   |  6 ---
 transports/janus_http.c       | 20 +++++++--
 transports/janus_pfunix.c     |  3 +-
 transports/janus_rabbitmq.c   |  2 +-
 transports/janus_websockets.c |  4 ++
 27 files changed, 323 insertions(+), 219 deletions(-)

diff --cc plugins/janus_echotest.c
index c9083dd,6bd2562..d6e3fe2
--- a/plugins/janus_echotest.c
+++ b/plugins/janus_echotest.c
@@@ -185,17 -184,7 +185,17 @@@ typedef struct janus_echotest_session 
  	gboolean has_data;
  	gboolean audio_active;
  	gboolean video_active;
- 	uint64_t bitrate, peer_bitrate;
 -	uint32_t bitrate;
++	uint32_t bitrate, peer_bitrate;
 +	janus_rtp_switching_context context;
 +	uint32_t ssrc[3];		/* Only needed in case VP8 simulcasting is involved */
 +	int rtpmapid_extmap_id;	/* Only needed in case Firefox's RID-based simulcasting is involved */
 +	char *rid[3];			/* Only needed in case Firefox's RID-based simulcasting is involved */
 +	int substream;			/* Which simulcast substream we should forward back */
 +	int substream_target;	/* As above, but to handle transitions (e.g., wait for keyframe) */
 +	int templayer;			/* Which simulcast temporal layer we should forward back */
 +	int templayer_target;	/* As above, but to handle transitions (e.g., wait for keyframe) */
 +	gint64 last_relayed;	/* When we relayed the last packet (used to detect when substreams become unavailable) */
 +	janus_vp8_simulcast_context simulcast_context;
  	janus_recorder *arc;	/* The Janus recorder instance for this user's audio, if enabled */
  	janus_recorder *vrc;	/* The Janus recorder instance for this user's video, if enabled */
  	janus_recorder *drc;	/* The Janus recorder instance for this user's data, if enabled */
@@@ -667,22 -515,12 +667,22 @@@ void janus_echotest_incoming_rtcp(janus
  		}
  		if(session->destroyed)
  			return;
- 		guint64 bitrate = janus_rtcp_get_remb(buf, len);
+ 		guint32 bitrate = janus_rtcp_get_remb(buf, len);
  		if(bitrate > 0) {
  			/* If a REMB arrived, make sure we cap it to our configuration, and send it as a video RTCP */
 -			if(session->bitrate > 0)
 -				janus_rtcp_cap_remb(buf, len, session->bitrate);
 -			gateway->relay_rtcp(handle, 1, buf, len);
 +			session->peer_bitrate = bitrate;
 +			if(session->bitrate > 0) {
 +				char rtcpbuf[32];
 +				int numssrc = 1;
 +				if(session->ssrc[1])
 +					numssrc++;
 +				if(session->ssrc[2])
 +					numssrc++;
 +				int remblen = janus_rtcp_remb_ssrcs((char *)(&rtcpbuf), sizeof(rtcpbuf), session->bitrate, numssrc);
 +				gateway->relay_rtcp(handle, 1, rtcpbuf, remblen);
 +			} else {
 +				gateway->relay_rtcp(handle, 1, buf, len);
 +			}
  			return;
  		}
  		gateway->relay_rtcp(handle, video, buf, len);
@@@ -745,17 -583,12 +745,17 @@@ void janus_echotest_slow_link(janus_plu
  			session->bitrate = session->bitrate/2;
  			if(session->bitrate < 64*1024)
  				session->bitrate = 64*1024;
- 			JANUS_LOG(LOG_WARN, "Getting a lot of NACKs (slow %s) for %s, forcing a lower REMB: %"SCNu64"\n",
+ 			JANUS_LOG(LOG_WARN, "Getting a lot of NACKs (slow %s) for %s, forcing a lower REMB: %"SCNu32"\n",
  				uplink ? "uplink" : "downlink", video ? "video" : "audio", session->bitrate);
  			/* ... and send a new REMB back */
 -			char rtcpbuf[24];
 -			janus_rtcp_remb((char *)(&rtcpbuf), 24, session->bitrate);
 -			gateway->relay_rtcp(handle, 1, rtcpbuf, 24);
 +			char rtcpbuf[32];
 +			int numssrc = 1;
 +			if(session->ssrc[1])
 +				numssrc++;
 +			if(session->ssrc[2])
 +				numssrc++;
 +			int remblen = janus_rtcp_remb_ssrcs((char *)(&rtcpbuf), sizeof(rtcpbuf), session->bitrate, numssrc);
 +			gateway->relay_rtcp(handle, 1, rtcpbuf, remblen);
  			/* As a last thing, notify the user about this */
  			json_t *event = json_object();
  			json_object_set_new(event, "echotest", json_string("event"));
@@@ -958,18 -759,14 +958,18 @@@ static void *janus_echotest_handler(voi
  		}
  		if(bitrate) {
  			session->bitrate = json_integer_value(bitrate);
- 			JANUS_LOG(LOG_VERB, "Setting video bitrate: %"SCNu64"\n", session->bitrate);
+ 			JANUS_LOG(LOG_VERB, "Setting video bitrate: %"SCNu32"\n", session->bitrate);
  			if(session->bitrate > 0) {
  				/* FIXME Generate a new REMB (especially useful for Firefox, which doesn't send any we can cap later) */
 -				char buf[24];
 -				memset(buf, 0, 24);
 -				janus_rtcp_remb((char *)&buf, 24, session->bitrate);
 +				char rtcpbuf[32];
 +				int numssrc = 1;
 +				if(session->ssrc[1])
 +					numssrc++;
 +				if(session->ssrc[2])
 +					numssrc++;
 +				int remblen = janus_rtcp_remb_ssrcs((char *)(&rtcpbuf), sizeof(rtcpbuf), session->bitrate, numssrc);
  				JANUS_LOG(LOG_VERB, "Sending REMB\n");
 -				gateway->relay_rtcp(session->handle, 1, buf, 24);
 +				gateway->relay_rtcp(session->handle, 1, rtcpbuf, remblen);
  				/* FIXME How should we handle a subsequent "no limit" bitrate? */
  			}
  		}
diff --cc plugins/janus_streaming.c
index 023921e,cf4fed6..c014c77
--- a/plugins/janus_streaming.c
+++ b/plugins/janus_streaming.c
@@@ -2941,19 -2786,13 +2941,19 @@@ static int janus_streaming_get_fd_port(
  
  /* Helpers to destroy a streaming mountpoint. */
  static void janus_streaming_rtp_source_free(janus_streaming_rtp_source *source) {
- 	if(source->audio_fd > 0) {
+ 	if(source->audio_fd > -1) {
  		close(source->audio_fd);
  	}
- 	if(source->video_fd[0] > 0) {
 -	if(source->video_fd > -1) {
 -		close(source->video_fd);
++	if(source->video_fd[0] > -1) {
 +		close(source->video_fd[0]);
 +	}
- 	if(source->video_fd[1] > 0) {
++	if(source->video_fd[1] > -1) {
 +		close(source->video_fd[1]);
 +	}
- 	if(source->video_fd[2] > 0) {
++	if(source->video_fd[2] > -1) {
 +		close(source->video_fd[2]);
  	}
- 	if(source->data_fd > 0) {
+ 	if(source->data_fd > -1) {
  		close(source->data_fd);
  	}
  #ifdef HAVE_LIBCURL
@@@ -3100,13 -2938,13 +3100,13 @@@ janus_streaming_mountpoint *janus_strea
  			return NULL;
  		}
  	}
 -	int video_fd = -1;
 +	int video_fd[3] = {-1, -1, -1};
  	if(dovideo) {
 -		video_fd = janus_streaming_create_fd(vport, vmcast ? inet_addr(vmcast) : INADDR_ANY, viface,
 +		video_fd[0] = janus_streaming_create_fd(vport, vmcast ? inet_addr(vmcast) : INADDR_ANY, viface,
  			"Video", "video", name ? name : tempname);
 -		if(video_fd < 0) {
 +		if(video_fd[0] < 0) {
  			JANUS_LOG(LOG_ERR, "Can't bind to port %d for video...\n", vport);
- 			if(audio_fd > 0)
+ 			if(audio_fd > -1)
  				close(audio_fd);
  			janus_mutex_unlock(&mountpoints_mutex);
  			return NULL;
@@@ -3149,14 -2957,10 +3149,14 @@@
  			"Data", "data", name ? name : tempname);
  		if(data_fd < 0) {
  			JANUS_LOG(LOG_ERR, "Can't bind to port %d for data...\n", dport);
- 			if(audio_fd > 0)
+ 			if(audio_fd > -1)
  				close(audio_fd);
- 			if(video_fd[0] > 0)
 -			if(video_fd > -1)
 -				close(video_fd);
++			if(video_fd[0] > -1)
 +				close(video_fd[0]);
- 			if(video_fd[1] > 0)
++			if(video_fd[1] > -1)
 +				close(video_fd[1]);
- 			if(video_fd[2] > 0)
++			if(video_fd[2] > -1)
 +				close(video_fd[2]);
  			janus_mutex_unlock(&mountpoints_mutex);
  			return NULL;
  		}
@@@ -4055,9 -3850,8 +4053,10 @@@ static void *janus_streaming_relay_thre
  				JANUS_LOG(LOG_WARN, "[%s] %"SCNi64"s passed with no media, trying to reconnect the RTSP stream\n",
  					name, (now - source->reconnect_timer)/G_USEC_PER_SEC);
  				audio_fd = -1;
 -				video_fd = -1;
 +				video_fd[0] = -1;
 +				video_fd[1] = -1;
 +				video_fd[2] = -1;
+ 				data_fd = -1;
  				source->reconnect_timer = now;
  				source->reconnecting = TRUE;
  				/* Let's clean up the source first */
@@@ -4071,19 -3865,11 +4070,19 @@@
  					close(source->audio_fd);
  				}
  				source->audio_fd = -1;
- 				if(source->video_fd[0] > 0) {
 -				if(source->video_fd > -1) {
 -					close(source->video_fd);
++				if(source->video_fd[0] > -1) {
 +					close(source->video_fd[0]);
 +				}
 +				source->video_fd[0] = -1;
- 				if(source->video_fd[1] > 0) {
++				if(source->video_fd[1] > -1) {
 +					close(source->video_fd[1]);
  				}
 -				source->video_fd = -1;
 +				source->video_fd[1] = -1;
- 				if(source->video_fd[2] > 0) {
++				if(source->video_fd[2] > -1) {
 +					close(source->video_fd[2]);
 +				}
 +				source->video_fd[2] = -1;
- 				if(source->data_fd > 0) {
+ 				if(source->data_fd > -1) {
  					close(source->data_fd);
  				}
  				source->data_fd = -1;
@@@ -4108,8 -3894,9 +4107,9 @@@
  						/* Everything should be back to normal, let's update the file descriptors */
  						JANUS_LOG(LOG_WARN, "[%s] Reconnected to the RTSP server, streaming again\n", name);
  						audio_fd = source->audio_fd;
 -						video_fd = source->video_fd;
 +						video_fd[0] = source->video_fd[0];
- 						ka_timeout = (source->ka_timeout*G_USEC_PER_SEC)/2;
+ 						data_fd = source->data_fd;
+ 						ka_timeout = ((gint64)source->ka_timeout*G_USEC_PER_SEC)/2;
  					}
  				}
  				source->reconnect_timer = janus_get_monotonic_time();
@@@ -4263,7 -4033,11 +4267,11 @@@
  					source->reconnect_timer = janus_get_monotonic_time();
  #endif
  					addrlen = sizeof(remote);
 -					bytes = recvfrom(video_fd, buffer, 1500, 0, (struct sockaddr*)&remote, &addrlen);
 +					bytes = recvfrom(fds[i].fd, buffer, 1500, 0, (struct sockaddr*)&remote, &addrlen);
+ 					if(bytes < 0) {
+ 						/* Failed to read? */
+ 						continue;
+ 					}
  					//~ JANUS_LOG(LOG_VERB, "************************\nGot %d bytes on the video channel...\n", bytes);
  					rtp_header *rtp = (rtp_header *)buffer;
  					/* First of all, let's check if this is (part of) a keyframe that we may need to save it for future reference */
diff --cc plugins/janus_videocall.c
index 407e86f,094f2e7..fcd6e45
--- a/plugins/janus_videocall.c
+++ b/plugins/janus_videocall.c
@@@ -358,25 -357,13 +358,25 @@@ typedef struct janus_videocall_session 
  	gchar *username;
  	gboolean has_audio;
  	gboolean has_video;
 +	gboolean has_data;
  	gboolean audio_active;
  	gboolean video_active;
- 	uint64_t bitrate;
+ 	uint32_t bitrate;
  	guint16 slowlink_count;
  	struct janus_videocall_session *peer;
 +	janus_rtp_switching_context context;
 +	uint32_t ssrc[3];		/* Only needed in case VP8 simulcasting is involved */
 +	int rtpmapid_extmap_id;	/* Only needed in case Firefox's RID-based simulcasting is involved */
 +	char *rid[3];			/* Only needed in case Firefox's RID-based simulcasting is involved */
 +	int substream;			/* Which simulcast substream we should forward back */
 +	int substream_target;	/* As above, but to handle transitions (e.g., wait for keyframe) */
 +	int templayer;			/* Which simulcast temporal layer we should forward back */
 +	int templayer_target;	/* As above, but to handle transitions (e.g., wait for keyframe) */
 +	gint64 last_relayed;	/* When we relayed the last packet (used to detect when substreams become unavailable) */
 +	janus_vp8_simulcast_context simulcast_context;
  	janus_recorder *arc;	/* The Janus recorder instance for this user's audio, if enabled */
  	janus_recorder *vrc;	/* The Janus recorder instance for this user's video, if enabled */
 +	janus_recorder *drc;	/* The Janus recorder instance for this user's data, if enabled */
  	janus_mutex rec_mutex;	/* Mutex to protect the recorders from race conditions */
  	volatile gint hangingup;
  	gint64 destroyed;	/* Time at which this session was marked as destroyed */
diff --cc plugins/janus_videoroom.c
index 8b1c5f5,60c410d..a2ed729
--- a/plugins/janus_videoroom.c
+++ b/plugins/janus_videoroom.c
@@@ -2460,10 -2379,17 +2460,16 @@@ void janus_videoroom_incoming_rtp(janus
  				rtp->type = rtp_forward->payload_type;
  			if(rtp_forward->ssrc > 0)
  				rtp->ssrc = htonl(rtp_forward->ssrc);
 -			if(video && rtp_forward->is_video) {
 +			if(video && rtp_forward->is_video && rtp_forward->substream == sc) {
- 				sendto(participant->udp_sock, buf, len, 0, (struct sockaddr*)&rtp_forward->serv_addr, sizeof(rtp_forward->serv_addr));
+ 				if(sendto(participant->udp_sock, buf, len, 0, (struct sockaddr*)&rtp_forward->serv_addr, sizeof(rtp_forward->serv_addr)) < 0) {
+ 					JANUS_LOG(LOG_HUGE, "Error forwarding RTP video packet for %s... %s (len=%d)...\n",
+ 						participant->display, strerror(errno), len);
+ 				}
 -			}
 -			else if(!video && !rtp_forward->is_video && !rtp_forward->is_data) {
 +			} else if(!video && !rtp_forward->is_video && !rtp_forward->is_data) {
- 				sendto(participant->udp_sock, buf, len, 0, (struct sockaddr*)&rtp_forward->serv_addr, sizeof(rtp_forward->serv_addr));
+ 				if(sendto(participant->udp_sock, buf, len, 0, (struct sockaddr*)&rtp_forward->serv_addr, sizeof(rtp_forward->serv_addr)) < 0) {
+ 					JANUS_LOG(LOG_HUGE, "Error forwarding RTP audio packet for %s... %s (len=%d)...\n",
+ 						participant->display, strerror(errno), len);
+ 				}
  			}
  			/* Restore original values of payload type and SSRC before going on */
  			rtp->type = pt;
diff --cc rtcp.c
index 89c8c1a,8444e37..a887368
--- a/rtcp.c
+++ b/rtcp.c
@@@ -870,16 -872,8 +872,16 @@@ int janus_rtcp_sdes(char *packet, int l
  }
  
  /* Generate a new REMB message */
- int janus_rtcp_remb(char *packet, int len, uint64_t bitrate) {
+ int janus_rtcp_remb(char *packet, int len, uint32_t bitrate) {
 -	if(packet == NULL || len != 24)
 +	/* By default we assume a single SSRC will be set */
 +	return janus_rtcp_remb_ssrcs(packet, len, bitrate, 1);
 +}
 +
- int janus_rtcp_remb_ssrcs(char *packet, int len, uint64_t bitrate, uint8_t numssrc) {
++int janus_rtcp_remb_ssrcs(char *packet, int len, uint32_t bitrate, uint8_t numssrc) {
 +	if(packet == NULL || numssrc == 0)
 +		return -1;
 +	int min_len = 20 + numssrc*4;
 +	if(len < min_len)
  		return -1;
  	memset(packet, 0, len);
  	rtcp_header *rtcp = (rtcp_header *)packet;
@@@ -913,8 -909,8 +917,8 @@@
  	_ptrRTCPData[1] = (uint8_t)((newbrexp << 2) + ((newbrmantissa >> 16) & 0x03));
  	_ptrRTCPData[2] = (uint8_t)(newbrmantissa >> 8);
  	_ptrRTCPData[3] = (uint8_t)(newbrmantissa);
- 	JANUS_LOG(LOG_HUGE, "[REMB] bitrate=%"SCNu64" (%d bytes)\n", bitrate, 4*(ntohs(rtcp->length)+1));
+ 	JANUS_LOG(LOG_HUGE, "[REMB] bitrate=%"SCNu32" (%d bytes)\n", bitrate, 4*(ntohs(rtcp->length)+1));
 -	return 24;
 +	return min_len;
  }
  
  /* Generate a new FIR message */
diff --cc rtcp.h
index 84ecc2a,b4338c1..99238f8
--- a/rtcp.h
+++ b/rtcp.h
@@@ -365,16 -363,8 +363,16 @@@ int janus_rtcp_sdes(char *packet, int l
   * @param[in] len The message data length in bytes (MUST be 24)
   * @param[in] bitrate The bitrate to report (e.g., 128000)
   * @returns The message data length in bytes, if successful, -1 on errors */
- int janus_rtcp_remb(char *packet, int len, uint64_t bitrate);
+ int janus_rtcp_remb(char *packet, int len, uint32_t bitrate);
  
 +/*! \brief Method to generate a new RTCP REMB message to cap the reported bitrate, but for more SSRCs
 + * @param[in] packet The buffer data (MUST be at least 24 chars)
 + * @param[in] len The message data length in bytes (MUST be 24)
 + * @param[in] bitrate The bitrate to report (e.g., 128000)
 + * @param[in] numssrc The number of SSRCs to include in the request
 + * @returns The message data length in bytes, if successful, -1 on errors */
- int janus_rtcp_remb_ssrcs(char *packet, int len, uint64_t bitrate, uint8_t numssrc);
++int janus_rtcp_remb_ssrcs(char *packet, int len, uint32_t bitrate, uint8_t numssrc);
 +
  /*! \brief Method to generate a new RTCP FIR message to request a key frame
   * @param[in] packet The buffer data (MUST be at least 20 chars)
   * @param[in] len The message data length in bytes (MUST be 20)

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