summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-06-23 16:43:24 -0400
committerWim Taymans <wim.taymans@collabora.co.uk>2011-02-01 18:28:51 +0100
commita61bb9e94b23f6dbed0319d6f018a8d857b2edcb (patch)
treef4ed3ef0c5acb8fee28b17224a829ca06c5d6d62
parent7350d2adfad6d6d3bef63fb793739204048612c5 (diff)
rtpsession: Send GstForceKeyUnit event in response to received RTCP PLI
-rw-r--r--gst/rtpmanager/gstrtpsession.c18
-rw-r--r--gst/rtpmanager/rtpsession.c23
-rw-r--r--gst/rtpmanager/rtpsession.h16
3 files changed, 56 insertions, 1 deletions
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index cc784c83e..994c53ba8 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -257,6 +257,8 @@ static GstFlowReturn gst_rtp_session_sync_rtcp (RTPSession * sess,
static gint gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload,
gpointer user_data);
static void gst_rtp_session_reconsider (RTPSession * sess, gpointer user_data);
+static void gst_rtp_session_request_key_unit (RTPSession * sess,
+ gboolean all_headers, gpointer user_data);
static RTPSessionCallbacks callbacks = {
gst_rtp_session_process_rtp,
@@ -264,7 +266,8 @@ static RTPSessionCallbacks callbacks = {
gst_rtp_session_sync_rtcp,
gst_rtp_session_send_rtcp,
gst_rtp_session_clock_rate,
- gst_rtp_session_reconsider
+ gst_rtp_session_reconsider,
+ gst_rtp_session_request_key_unit
};
/* GObject vmethods */
@@ -2143,3 +2146,16 @@ wrong_pad:
return;
}
}
+
+static void
+gst_rtp_session_request_key_unit (RTPSession * sess,
+ gboolean all_headers, gpointer user_data)
+{
+ GstRtpSession *rtpsession = GST_RTP_SESSION (user_data);
+ GstEvent *event;
+
+ event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
+ gst_structure_new ("GstForceKeyUnit",
+ "all-headers", G_TYPE_BOOLEAN, all_headers, NULL));
+ gst_pad_push_event (rtpsession->send_rtp_sink, event);
+}
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index 32973c0b6..d3a7a548f 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -769,6 +769,10 @@ rtp_session_set_callbacks (RTPSession * sess, RTPSessionCallbacks * callbacks,
sess->callbacks.reconsider = callbacks->reconsider;
sess->reconsider_user_data = user_data;
}
+ if (callbacks->request_key_unit) {
+ sess->callbacks.request_key_unit = callbacks->request_key_unit;
+ sess->request_key_unit_user_data = user_data;
+ }
}
/**
@@ -2042,6 +2046,25 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
if (src)
rtp_source_retain_rtcp_packet (src, packet, arrival->running_time);
}
+
+ if (rtp_source_get_ssrc (sess->source) == media_ssrc) {
+ switch (type) {
+ case GST_RTCP_TYPE_PSFB:
+ switch (fbtype) {
+ case GST_RTCP_PSFB_TYPE_PLI:
+ if (sess->callbacks.request_key_unit)
+ sess->callbacks.request_key_unit (sess, FALSE,
+ sess->request_key_unit_user_data);
+ break;
+ default:
+ break;
+ }
+ break;
+ case GST_RTCP_TYPE_RTPFB:
+ default:
+ break;
+ }
+ }
}
/**
diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h
index 3113247ce..0cc1f6bfd 100644
--- a/gst/rtpmanager/rtpsession.h
+++ b/gst/rtpmanager/rtpsession.h
@@ -121,12 +121,26 @@ typedef gint (*RTPSessionClockRate) (RTPSession *sess, guint8 payload, gpointer
typedef void (*RTPSessionReconsider) (RTPSession *sess, gpointer user_data);
/**
+ * RTPSessionRequestKeyUnit:
+ * @sess: an #RTPSession
+ * @all_headers: %TRUE if "all-headers" property should be set on the key unit
+ * request
+ * @user_data: user data specified when registering
+*
+ * Asks the encoder to produce a key unit as soon as possibly within the
+ * bandwidth constraints
+ */
+typedef void (*RTPSessionRequestKeyUnit) (RTPSession *sess,
+ gboolean all_headers, gpointer user_data);
+
+/**
* RTPSessionCallbacks:
* @RTPSessionProcessRTP: callback to process RTP packets
* @RTPSessionSendRTP: callback for sending RTP packets
* @RTPSessionSendRTCP: callback for sending RTCP packets
* @RTPSessionSyncRTCP: callback for handling SR packets
* @RTPSessionReconsider: callback for reconsidering the timeout
+ * @RTPSessionRequestKeyUnit: callback for requesting a new key unit
*
* These callbacks can be installed on the session manager to get notification
* when RTP and RTCP packets are ready for further processing. These callbacks
@@ -139,6 +153,7 @@ typedef struct {
RTPSessionSendRTCP send_rtcp;
RTPSessionClockRate clock_rate;
RTPSessionReconsider reconsider;
+ RTPSessionRequestKeyUnit request_key_unit;
} RTPSessionCallbacks;
/**
@@ -197,6 +212,7 @@ struct _RTPSession {
gpointer sync_rtcp_user_data;
gpointer clock_rate_user_data;
gpointer reconsider_user_data;
+ gpointer request_key_unit_user_data;
RTPSessionStats stats;