From c0996e6b903e1deaf4ef9ee08da9288bc75fac57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 27 Aug 2010 16:11:06 -0400 Subject: [PATCH] rtpsession: Add callback to get the current time --- gst/rtpmanager/gstrtpsession.c | 13 ++++++++++++- gst/rtpmanager/rtpsession.c | 22 ++++++++++++++++++++++ gst/rtpmanager/rtpsession.h | 17 +++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index 994c53ba8a..b1223d6585 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -259,6 +259,8 @@ static gint gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload, 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 GstClockTime gst_rtp_session_request_time (RTPSession * session, + gpointer user_data); static RTPSessionCallbacks callbacks = { gst_rtp_session_process_rtp, @@ -267,7 +269,8 @@ static RTPSessionCallbacks callbacks = { gst_rtp_session_send_rtcp, gst_rtp_session_clock_rate, gst_rtp_session_reconsider, - gst_rtp_session_request_key_unit + gst_rtp_session_request_key_unit, + gst_rtp_session_request_time }; /* GObject vmethods */ @@ -2159,3 +2162,11 @@ gst_rtp_session_request_key_unit (RTPSession * sess, "all-headers", G_TYPE_BOOLEAN, all_headers, NULL)); gst_pad_push_event (rtpsession->send_rtp_sink, event); } + +static GstClockTime +gst_rtp_session_request_time (RTPSession * session, gpointer user_data) +{ + GstRtpSession *rtpsession = GST_RTP_SESSION (user_data); + + return gst_clock_get_time (rtpsession->priv->sysclock); +} diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index cf73043f60..a60e7c0945 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -773,6 +773,10 @@ rtp_session_set_callbacks (RTPSession * sess, RTPSessionCallbacks * callbacks, sess->callbacks.request_key_unit = callbacks->request_key_unit; sess->request_key_unit_user_data = user_data; } + if (callbacks->request_time) { + sess->callbacks.request_time = callbacks->request_time; + sess->request_time_user_data = user_data; + } } /** @@ -883,6 +887,24 @@ rtp_session_set_reconsider_callback (RTPSession * sess, sess->reconsider_user_data = user_data; } +/** + * rtp_session_set_request_time_callback: + * @sess: an #RTPSession + * @callback: callback to set + * @user_data: user data passed in the callback + * + * Configure only the request_time callback + */ +void +rtp_session_set_request_time_callback (RTPSession * sess, + RTPSessionRequestTime callback, gpointer user_data) +{ + g_return_if_fail (RTP_IS_SESSION (sess)); + + sess->callbacks.request_time = callback; + sess->request_time_user_data = user_data; +} + /** * rtp_session_set_bandwidth: * @sess: an #RTPSession diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h index 95109425d8..3746a9b721 100644 --- a/gst/rtpmanager/rtpsession.h +++ b/gst/rtpmanager/rtpsession.h @@ -133,6 +133,17 @@ typedef void (*RTPSessionReconsider) (RTPSession *sess, gpointer user_data); typedef void (*RTPSessionRequestKeyUnit) (RTPSession *sess, gboolean all_headers, gpointer user_data); +/** + * RTPSessionRequestTime: + * @sess: an #RTPSession + * @user_data: user data specified when registering + * + * This callback will be called when @sess needs the current time. The time + * should be returned as a #GstClockTime + */ +typedef GstClockTime (*RTPSessionRequestTime) (RTPSession *sess, + gpointer user_data); + /** * RTPSessionCallbacks: * @RTPSessionProcessRTP: callback to process RTP packets @@ -154,6 +165,7 @@ typedef struct { RTPSessionClockRate clock_rate; RTPSessionReconsider reconsider; RTPSessionRequestKeyUnit request_key_unit; + RTPSessionRequestTime request_time; } RTPSessionCallbacks; /** @@ -213,6 +225,7 @@ struct _RTPSession { gpointer clock_rate_user_data; gpointer reconsider_user_data; gpointer request_key_unit_user_data; + gpointer request_time_user_data; RTPSessionStats stats; @@ -278,6 +291,10 @@ void rtp_session_set_clock_rate_callback (RTPSession * sess, void rtp_session_set_reconsider_callback (RTPSession * sess, RTPSessionReconsider callback, gpointer user_data); +void rtp_session_set_request_time_callback (RTPSession * sess, + RTPSessionRequestTime callback, + gpointer user_data); + void rtp_session_set_bandwidth (RTPSession *sess, gdouble bandwidth); gdouble rtp_session_get_bandwidth (RTPSession *sess); void rtp_session_set_rtcp_fraction (RTPSession *sess, gdouble fraction);