rtpsession: Add callback to get the current time

This commit is contained in:
Olivier Crête 2010-08-27 16:11:06 -04:00 committed by Wim Taymans
parent a630c68fc3
commit c0996e6b90
3 changed files with 51 additions and 1 deletions

View 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);
}

View 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;
}
}
/**
@ -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

View file

@ -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);