Re: [PATCH] Complete PLI handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/12/2019 10:49, Nanang Izzuddin wrote:
> Hi Saúl,
> 
> Actually we've also just implemented it, please check
> https://trac.pjsip.org/repos/ticket/1437. I've checked your patch and I
> think all the features have also covered by the ticket (please let us
> know if something is missing), perhaps the difference is just who do the
> RTCP sending, instead of PJSUA-LIB (side by side with the SIP INFO
> method), the ticket does it in video stream. Also the ticket includes
> SDP attribute generation to signal RTCP-FB PLI capability.
> 

Hi again Nanag!

I just spent some time rebasing my changes on top of latest master
(thanks for syncing up GitHub, it make my life heaps easier!). Great
work folks, most of my patches are no longer necessary!

There is, however, one thing whicch AFAICT is not currently implemented
by PJSUA: sending a PLI when PJMEDIA_EVENT_KEYFRAME_MISSING is received
and PJSUA_VID_REQ_KEYFRAME_RTCP_PLI is set.

The attached patches add this functionality. The first one exposes a
pjmedia_vid_stream_send_rtcp_pli function which the second patch uses.

Please let me know what you think and if you need me to make any
changes. Keeping our patches at the minimum is my goal :-)


Cheers,

-- 
Saúl
From cae233ef0f09caab0dff2d2a87f48264cded8a88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= <s@xxxxxxxxxx>
Date: Thu, 13 Feb 2020 11:42:48 +0100
Subject: [PATCH] vid_stream: add API for sending an RTCP PLI

---
 pjmedia/include/pjmedia/vid_stream.h | 12 ++++++++++++
 pjmedia/src/pjmedia/vid_stream.c     | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/pjmedia/include/pjmedia/vid_stream.h b/pjmedia/include/pjmedia/vid_stream.h
index 395148698..e80a727ce 100644
--- a/pjmedia/include/pjmedia/vid_stream.h
+++ b/pjmedia/include/pjmedia/vid_stream.h
@@ -454,6 +454,18 @@ PJ_DECL(pj_status_t) pjmedia_vid_stream_send_rtcp_sdes(
 PJ_DECL(pj_status_t) pjmedia_vid_stream_send_rtcp_bye(
 						pjmedia_vid_stream *stream);
 
+
+/**
+ * Send RTCP PLI for the media stream.
+ *
+ * @param stream	The media stream.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_vid_stream_send_rtcp_pli(
+						pjmedia_vid_stream *stream);
+
+
 /**
  * Get the RTP session information of the video media stream. This function 
  * can be useful for app with custom media transport to inject/filter some 
diff --git a/pjmedia/src/pjmedia/vid_stream.c b/pjmedia/src/pjmedia/vid_stream.c
index 13ddc1052..d711f16a7 100644
--- a/pjmedia/src/pjmedia/vid_stream.c
+++ b/pjmedia/src/pjmedia/vid_stream.c
@@ -2392,6 +2392,22 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_send_rtcp_bye(
 }
 
 
+/*
+ * Send RTCP PLI.
+ */
+PJ_DEF(pj_status_t) pjmedia_vid_stream_send_rtcp_pli(
+						pjmedia_vid_stream *stream)
+{
+    PJ_ASSERT_RETURN(stream, PJ_EINVAL);
+
+    if (stream->enc && stream->transport) {
+	return send_rtcp(stream, PJ_FALSE, PJ_FALSE, PJ_FALSE, PJ_TRUE);
+    }
+
+    return PJ_SUCCESS;
+}
+
+
 /*
  * Initialize the video stream rate control with default settings.
  */
From 7925ac188dae0f8b372abef0393d1d6be2230a0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= <s@xxxxxxxxxx>
Date: Thu, 28 Nov 2019 14:35:20 +0100
Subject: [PATCH] pjsua: also send RTCP PLI when a keyframe is missing

---
 pjsip/include/pjsua-lib/pjsua.h   |  1 -
 pjsip/src/pjsua-lib/pjsua_media.c | 29 ++++++++++++++++++++++-------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 155725217..8db15ac58 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -4670,7 +4670,6 @@ typedef enum pjsua_vid_req_keyframe_method
 
     /**
      * Requesting keyframe via Picture Loss Indication of RTCP feedback.
-     * This is currently not supported.
      */
     PJSUA_VID_REQ_KEYFRAME_RTCP_PLI	= 2
 
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index c55ab8050..3d6bb021c 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -1518,15 +1518,17 @@ pj_status_t call_media_on_event(pjmedia_event *event,
 			 event->src, event->epub));
 
     switch(event->type) {
-	case PJMEDIA_EVENT_KEYFRAME_MISSING:
+	case PJMEDIA_EVENT_KEYFRAME_MISSING: {
+	    pj_timestamp now;
+
+	    pj_get_timestamp(&now);
+	    if (pj_elapsed_msec(&call_med->last_req_keyframe, &now) <
+		    PJSUA_VID_REQ_KEYFRAME_INTERVAL) {
+			break;
+	    }
+
 	    if (call->opt.req_keyframe_method & PJSUA_VID_REQ_KEYFRAME_SIP_INFO)
 	    {
-		pj_timestamp now;
-
-		pj_get_timestamp(&now);
-		if (pj_elapsed_msec(&call_med->last_req_keyframe, &now) >=
-		    PJSUA_VID_REQ_KEYFRAME_INTERVAL)
-		{
 		    pjsua_msg_data msg_data;
 		    const pj_str_t SIP_INFO = {"INFO", 4};
 		    const char *BODY_TYPE = "application/media_control+xml";
@@ -1550,9 +1552,22 @@ pj_status_t call_media_on_event(pjmedia_event *event,
 		    } else {
 			call_med->last_req_keyframe = now;
 		    }
+	    }
+
+	    if (call->opt.req_keyframe_method & PJSUA_VID_REQ_KEYFRAME_RTCP_PLI)
+	    {
+		PJ_LOG(4,(THIS_FILE,
+			"Sending video keyframe request via RTCP PLI"));
+		status = pjmedia_vid_stream_send_rtcp_pli(call_med->strm.v.stream);
+		if (status != PJ_SUCCESS) {
+			PJ_PERROR(3,(THIS_FILE, status,
+				  "Failed requesting keyframe via RTCP PLI"));
+		} else {
+			call_med->last_req_keyframe = now;
 		}
 	    }
 	    break;
+	}
 
 #if PJSUA_HAS_VIDEO
 	case PJMEDIA_EVENT_FMT_CHANGED:
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux