gst/rtpmanager/: Make it possible to use different user_data for each of the callbacks.

Original commit message from CVS:
Patch by: Youness Alaoui <youness dot alaoui at collabora dot co dot uk>
* gst/rtpmanager/gstrtpsession.c: (gst_rtp_session_clock_rate):
* gst/rtpmanager/rtpsession.c: (rtp_session_set_callbacks),
(rtp_session_set_process_rtp_callback),
(rtp_session_set_send_rtp_callback),
(rtp_session_set_send_rtcp_callback),
(rtp_session_set_sync_rtcp_callback),
(rtp_session_set_clock_rate_callback),
(rtp_session_set_reconsider_callback), (source_push_rtp),
(source_clock_rate), (rtp_session_process_bye),
(rtp_session_process_rtcp), (rtp_session_send_bye),
(rtp_session_on_timeout):
* gst/rtpmanager/rtpsession.h:
Make it possible to use different user_data for each of the callbacks.
Fixes #508587.
This commit is contained in:
Youness Alaoui 2008-01-11 16:45:57 +00:00 committed by Tim-Philipp Müller
parent c6d892420a
commit 03d9faf5fa
3 changed files with 174 additions and 22 deletions

View file

@ -286,8 +286,8 @@ static void gst_rtp_session_reconsider (RTPSession * sess, gpointer user_data);
static RTPSessionCallbacks callbacks = {
gst_rtp_session_process_rtp,
gst_rtp_session_send_rtp,
gst_rtp_session_send_rtcp,
gst_rtp_session_sync_rtcp,
gst_rtp_session_send_rtcp,
gst_rtp_session_clock_rate,
gst_rtp_session_reconsider
};
@ -1188,6 +1188,8 @@ gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload,
GST_RTP_SESSION_LOCK (rtpsession);
ipayload = payload; /* make compiler happy */
caps = g_hash_table_lookup (priv->ptmap, GINT_TO_POINTER (ipayload));
/* TODO : check if we should really goto done. This will return -1
* instead of the clock rate of the caps we just found! */
if (caps)
goto done;
@ -1208,6 +1210,7 @@ gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload,
gst_rtp_session_cache_caps (rtpsession, caps);
/* TODO : This is where we should 'goto' */
s = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (s, "clock-rate", &result))
goto no_clock_rate;

View file

@ -23,7 +23,6 @@
#include <gst/rtp/gstrtcpbuffer.h>
#include <gst/netbuffer/gstnetbuffer.h>
#include "gstrtpbin-marshal.h"
#include "rtpsession.h"
@ -536,13 +535,138 @@ rtp_session_set_callbacks (RTPSession * sess, RTPSessionCallbacks * callbacks,
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.process_rtp = callbacks->process_rtp;
sess->callbacks.send_rtp = callbacks->send_rtp;
sess->callbacks.send_rtcp = callbacks->send_rtcp;
sess->callbacks.sync_rtcp = callbacks->sync_rtcp;
sess->callbacks.clock_rate = callbacks->clock_rate;
sess->callbacks.reconsider = callbacks->reconsider;
sess->user_data = user_data;
if (callbacks->process_rtp) {
sess->callbacks.process_rtp = callbacks->process_rtp;
sess->process_rtp_user_data = user_data;
}
if (callbacks->send_rtp) {
sess->callbacks.send_rtp = callbacks->send_rtp;
sess->send_rtp_user_data = user_data;
}
if (callbacks->send_rtcp) {
sess->callbacks.send_rtcp = callbacks->send_rtcp;
sess->send_rtcp_user_data = user_data;
}
if (callbacks->sync_rtcp) {
sess->callbacks.sync_rtcp = callbacks->sync_rtcp;
sess->sync_rtcp_user_data = user_data;
}
if (callbacks->clock_rate) {
sess->callbacks.clock_rate = callbacks->clock_rate;
sess->clock_rate_user_data = user_data;
}
if (callbacks->reconsider) {
sess->callbacks.reconsider = callbacks->reconsider;
sess->reconsider_user_data = user_data;
}
}
/**
* rtp_session_set_process_rtp_callback:
* @sess: an #RTPSession
* @callback: callback to set
* @user_data: user data passed in the callback
*
* Configure only the process_rtp callback to be notified of the process_rtp action.
*/
void
rtp_session_set_process_rtp_callback (RTPSession * sess,
RTPSessionProcessRTP callback, gpointer user_data)
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.process_rtp = callback;
sess->process_rtp_user_data = user_data;
}
/**
* rtp_session_set_send_rtp_callback:
* @sess: an #RTPSession
* @callback: callback to set
* @user_data: user data passed in the callback
*
* Configure only the send_rtp callback to be notified of the send_rtp action.
*/
void
rtp_session_set_send_rtp_callback (RTPSession * sess,
RTPSessionSendRTP callback, gpointer user_data)
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.send_rtp = callback;
sess->send_rtp_user_data = user_data;
}
/**
* rtp_session_set_send_rtcp_callback:
* @sess: an #RTPSession
* @callback: callback to set
* @user_data: user data passed in the callback
*
* Configure only the send_rtcp callback to be notified of the send_rtcp action.
*/
void
rtp_session_set_send_rtcp_callback (RTPSession * sess,
RTPSessionSendRTCP callback, gpointer user_data)
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.send_rtcp = callback;
sess->send_rtcp_user_data = user_data;
}
/**
* rtp_session_set_sync_rtcp_callback:
* @sess: an #RTPSession
* @callback: callback to set
* @user_data: user data passed in the callback
*
* Configure only the sync_rtcp callback to be notified of the sync_rtcp action.
*/
void
rtp_session_set_sync_rtcp_callback (RTPSession * sess,
RTPSessionSyncRTCP callback, gpointer user_data)
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.sync_rtcp = callback;
sess->sync_rtcp_user_data = user_data;
}
/**
* rtp_session_set_clock_rate_callback:
* @sess: an #RTPSession
* @callback: callback to set
* @user_data: user data passed in the callback
*
* Configure only the clock_rate callback to be notified of the clock_rate action.
*/
void
rtp_session_set_clock_rate_callback (RTPSession * sess,
RTPSessionClockRate callback, gpointer user_data)
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.clock_rate = callback;
sess->clock_rate_user_data = user_data;
}
/**
* rtp_session_set_reconsider_callback:
* @sess: an #RTPSession
* @callback: callback to set
* @user_data: user data passed in the callback
*
* Configure only the reconsider callback to be notified of the reconsider action.
*/
void
rtp_session_set_reconsider_callback (RTPSession * sess,
RTPSessionReconsider callback, gpointer user_data)
{
g_return_if_fail (RTP_IS_SESSION (sess));
sess->callbacks.reconsider = callback;
sess->reconsider_user_data = user_data;
}
/**
@ -686,7 +810,7 @@ source_push_rtp (RTPSource * source, GstBuffer * buffer, RTPSession * session)
if (session->callbacks.send_rtp)
result =
session->callbacks.send_rtp (session, source, buffer,
session->user_data);
session->send_rtp_user_data);
else
gst_buffer_unref (buffer);
@ -697,7 +821,7 @@ source_push_rtp (RTPSource * source, GstBuffer * buffer, RTPSession * session)
if (session->callbacks.process_rtp)
result =
session->callbacks.process_rtp (session, source, buffer,
session->user_data);
session->process_rtp_user_data);
else
gst_buffer_unref (buffer);
}
@ -712,7 +836,9 @@ source_clock_rate (RTPSource * source, guint8 pt, RTPSession * session)
gint result;
if (session->callbacks.clock_rate)
result = session->callbacks.clock_rate (session, pt, session->user_data);
result =
session->callbacks.clock_rate (session, pt,
session->clock_rate_user_data);
else
result = -1;
@ -1343,7 +1469,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
/* notify app of reconsideration */
if (sess->callbacks.reconsider)
sess->callbacks.reconsider (sess, sess->user_data);
sess->callbacks.reconsider (sess, sess->reconsider_user_data);
}
}
@ -1450,7 +1576,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer)
/* notify caller of sr packets in the callback */
if (is_sr && sess->callbacks.sync_rtcp)
result = sess->callbacks.sync_rtcp (sess, sess->source, buffer,
sess->user_data);
sess->sync_rtcp_user_data);
else
gst_buffer_unref (buffer);
@ -1600,7 +1726,7 @@ rtp_session_send_bye (RTPSession * sess, const gchar * reason)
/* notify app of reconsideration */
if (sess->callbacks.reconsider)
sess->callbacks.reconsider (sess, sess->user_data);
sess->callbacks.reconsider (sess, sess->reconsider_user_data);
done:
RTP_SESSION_UNLOCK (sess);
@ -1985,7 +2111,7 @@ rtp_session_on_timeout (RTPSession * sess, GstClockTime time, guint64 ntpnstime)
if (sess->callbacks.send_rtcp)
result = sess->callbacks.send_rtcp (sess, sess->source, data.rtcp,
sess->user_data);
sess->send_rtcp_user_data);
else
gst_buffer_unref (data.rtcp);
}

View file

@ -85,10 +85,10 @@ typedef GstFlowReturn (*RTPSessionSendRTCP) (RTPSession *sess, RTPSource *src, G
* RTPSessionSyncRTCP:
* @sess: an #RTPSession
* @src: the #RTPSource
* @buffer: the RTCP buffer ready for sending
* @buffer: the RTCP buffer ready for synchronisation
* @user_data: user data specified when registering
*
* This callback will be called when @sess has and SR @buffer ready for doing
* This callback will be called when @sess has an SR @buffer ready for doing
* synchronisation between streams.
*
* Returns: a #GstFlowReturn.
@ -133,8 +133,8 @@ typedef void (*RTPSessionReconsider) (RTPSession *sess, gpointer user_data);
typedef struct {
RTPSessionProcessRTP process_rtp;
RTPSessionSendRTP send_rtp;
RTPSessionSendRTCP send_rtcp;
RTPSessionSyncRTCP sync_rtcp;
RTPSessionSendRTCP send_rtcp;
RTPSessionClockRate clock_rate;
RTPSessionReconsider reconsider;
} RTPSessionCallbacks;
@ -177,8 +177,13 @@ struct _RTPSession {
gchar *bye_reason;
gboolean sent_bye;
RTPSessionCallbacks callbacks;
gpointer user_data;
RTPSessionCallbacks callbacks;
gpointer process_rtp_user_data;
gpointer send_rtp_user_data;
gpointer send_rtcp_user_data;
gpointer sync_rtcp_user_data;
gpointer clock_rate_user_data;
gpointer reconsider_user_data;
RTPSessionStats stats;
@ -211,9 +216,27 @@ GType rtp_session_get_type (void);
/* create and configure */
RTPSession* rtp_session_new (void);
void rtp_session_set_callbacks (RTPSession *sess,
void rtp_session_set_callbacks (RTPSession *sess,
RTPSessionCallbacks *callbacks,
gpointer user_data);
void rtp_session_set_process_rtp_callback (RTPSession * sess,
RTPSessionProcessRTP callback,
gpointer user_data);
void rtp_session_set_send_rtp_callback (RTPSession * sess,
RTPSessionSendRTP callback,
gpointer user_data);
void rtp_session_set_send_rtcp_callback (RTPSession * sess,
RTPSessionSendRTCP callback,
gpointer user_data);
void rtp_session_set_sync_rtcp_callback (RTPSession * sess,
RTPSessionSyncRTCP callback,
gpointer user_data);
void rtp_session_set_clock_rate_callback (RTPSession * sess,
RTPSessionClockRate callback,
gpointer user_data);
void rtp_session_set_reconsider_callback (RTPSession * sess,
RTPSessionReconsider 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);