rtpsession: Add callback to get the current time
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>
Fri, 27 Aug 2010 20:11:06 +0000 (16:11 -0400)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 1 Feb 2011 17:28:51 +0000 (18:28 +0100)
gst/rtpmanager/gstrtpsession.c
gst/rtpmanager/rtpsession.c
gst/rtpmanager/rtpsession.h

index 994c53b..b1223d6 100644 (file)
@@ -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);
+}
index cf73043..a60e7c0 100644 (file)
@@ -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;
+  }
 }
 
 /**
@@ -884,6 +888,24 @@ rtp_session_set_reconsider_callback (RTPSession * sess,
 }
 
 /**
+ * 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
  * @bandwidth: the bandwidth allocated
index 9510942..3746a9b 100644 (file)
@@ -134,6 +134,17 @@ 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
  * @RTPSessionSendRTP: callback for sending 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);