gst/rtpmanager/: Post a message when the SDES infor changes for a source.

Original commit message from CVS:
* gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_class_init),
(gst_rtp_bin_handle_message):
* gst/rtpmanager/gstrtpsession.c: (source_get_sdes_structure),
(on_ssrc_sdes):
Post a message when the SDES infor changes for a source.
* gst/rtpmanager/rtpsession.c:
* gst/rtpmanager/rtpsource.c:
Update some comments.
This commit is contained in:
Wim Taymans 2007-12-10 18:36:04 +00:00
parent 5c1c4a4477
commit 8b973428f3
5 changed files with 130 additions and 4 deletions

View file

@ -1,3 +1,15 @@
2007-12-10 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_class_init),
(gst_rtp_bin_handle_message):
* gst/rtpmanager/gstrtpsession.c: (source_get_sdes_structure),
(on_ssrc_sdes):
Post a message when the SDES infor changes for a source.
* gst/rtpmanager/rtpsession.c:
* gst/rtpmanager/rtpsource.c:
Update some comments.
2007-12-10 Wim Taymans <wim.taymans@collabora.co.uk>
Based on patch by: <mutex at runbox dot com>
@ -150,7 +162,6 @@
* sys/dvb/dvbbasebin.c:
Make sure initial pids are added properly to filter,
>>>>>>> 1.2909
2007-12-05 Andy Wingo <wingo@pobox.com>
* gst/switch/gstswitch.c (gst_switch_set_property): Don't push

View file

@ -1021,6 +1021,7 @@ static GstStateChangeReturn gst_rtp_bin_change_state (GstElement * element,
static GstPad *gst_rtp_bin_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name);
static void gst_rtp_bin_release_pad (GstElement * element, GstPad * pad);
static void gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message);
static void gst_rtp_bin_clear_pt_map (GstRtpBin * bin);
GST_BOILERPLATE (GstRtpBin, gst_rtp_bin, GstBin, GST_TYPE_BIN);
@ -1054,9 +1055,11 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBinClass *gstbin_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbin_class = (GstBinClass *) klass;
g_type_class_add_private (klass, sizeof (GstRtpBinPrivate));
@ -1244,6 +1247,8 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_bin_release_pad);
gstbin_class->handle_message = GST_DEBUG_FUNCPTR (gst_rtp_bin_handle_message);
klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_bin_clear_pt_map);
GST_DEBUG_CATEGORY_INIT (gst_rtp_bin_debug, "rtpbin", 0, "RTP bin");
@ -1470,6 +1475,50 @@ gst_rtp_bin_provide_clock (GstElement * element)
return GST_CLOCK_CAST (gst_object_ref (rtpbin->provided_clock));
}
static void
gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
{
GstRtpBin *rtpbin;
rtpbin = GST_RTP_BIN (bin);
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ELEMENT:
{
const GstStructure *s = gst_message_get_structure (message);
/* we change the structure name and add the session ID to it */
if (gst_structure_has_name (s, "GstRTPSessionSDES")) {
GSList *walk;
/* find the session, the message source has it */
for (walk = rtpbin->sessions; walk; walk = g_slist_next (walk)) {
GstRtpBinSession *sess = (GstRtpBinSession *) walk->data;
/* if we found the session, change message. else we exit the loop and
* leave the message unchanged */
if (GST_OBJECT_CAST (sess->session) == GST_MESSAGE_SRC (message)) {
message = gst_message_make_writable (message);
s = gst_message_get_structure (message);
gst_structure_set_name ((GstStructure *) s, "GstRTPBinSDES");
gst_structure_set ((GstStructure *) s, "session", G_TYPE_UINT,
sess->id, NULL);
break;
}
}
}
/* fallthrough to forward the modified message to the parent */
}
default:
{
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
break;
}
}
}
static void
calc_ntp_ns_base (GstRtpBin * bin)
{

View file

@ -338,9 +338,75 @@ on_ssrc_active (RTPSession * session, RTPSource * src, GstRtpSession * sess)
src->ssrc);
}
static GstStructure *
source_get_sdes_structure (RTPSource * src)
{
GstStructure *result;
GValue val = { 0 };
gchar *str;
result = gst_structure_empty_new ("GstRTPSessionSDES");
gst_structure_set (result, "ssrc", G_TYPE_UINT, src->ssrc, NULL);
g_value_init (&val, G_TYPE_STRING);
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_CNAME);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "cname", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_NAME);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "name", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_EMAIL);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "email", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_PHONE);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "phone", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_LOC);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "location", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_TOOL);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "tool", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_NOTE);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "note", &val);
}
str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_PRIV);
if (str) {
g_value_take_string (&val, str);
gst_structure_set_value (result, "priv", &val);
}
return result;
}
static void
on_ssrc_sdes (RTPSession * session, RTPSource * src, GstRtpSession * sess)
{
GstStructure *s;
GstMessage *m;
/* convert the new SDES info into a message */
RTP_SESSION_LOCK (session);
s = source_get_sdes_structure (src);
RTP_SESSION_UNLOCK (session);
m = gst_message_new_custom (GST_MESSAGE_ELEMENT, GST_OBJECT (sess), s);
gst_element_post_message (GST_ELEMENT_CAST (sess), m);
g_signal_emit (sess, gst_rtp_session_signals[SIGNAL_ON_SSRC_SDES], 0,
src->ssrc);
}

View file

@ -1221,7 +1221,7 @@ rtp_session_process_rr (RTPSession * sess, GstRTCPPacket * packet,
rtp_session_process_rb (sess, source, packet, arrival);
}
/* FIXME, we're just printing this for now... */
/* Get SDES items and store them in the SSRC */
static void
rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival)

View file

@ -600,7 +600,7 @@ rtp_source_set_sdes_string (RTPSource * src, GstRTCPSDESType type,
* @data remains valid until the next call to rtp_source_set_sdes().
*
* Returns: %TRUE if @type was valid and @data and @len contain valid
* data.
* data. @data can be NULL when the item was unset.
*/
gboolean
rtp_source_get_sdes (RTPSource * src, GstRTCPSDESType type, guint8 ** data,
@ -627,7 +627,7 @@ rtp_source_get_sdes (RTPSource * src, GstRTCPSDESType type, guint8 ** data,
* Get the SDES item of @type from @src.
*
* Returns: a null-terminated copy of the SDES item or NULL when @type was not
* valid. g_free() after usage.
* valid or the SDES item was unset. g_free() after usage.
*/
gchar *
rtp_source_get_sdes_string (RTPSource * src, GstRTCPSDESType type)