2 * This file is part of the Nice GLib ICE library.
4 * (C) 2006, 2007 Collabora Ltd.
5 * Contact: Dafydd Harries
6 * (C) 2006, 2007 Nokia Corporation. All rights reserved.
7 * Contact: Kai Vehmanen
9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS" basis,
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
16 * for the specific language governing rights and limitations under the
19 * The Original Code is the Nice GLib ICE library.
21 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
22 * Corporation. All Rights Reserved.
25 * Dafydd Harries, Collabora Ltd.
27 * Alternatively, the contents of this file may be used under the terms of the
28 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
29 * case the provisions of LGPL are applicable instead of those above. If you
30 * wish to allow use of your version of this file only under the terms of the
31 * LGPL and not to allow others to use your version of this file under the
32 * MPL, indicate your decision by deleting the provisions above and replace
33 * them with the notice and other provisions required by the LGPL. If you do
34 * not delete the provisions above, a recipient may use your version of this
35 * file under either the MPL or the LGPL.
41 #include "gstnicesink.h"
44 GST_DEBUG_CATEGORY_STATIC (nicesink_debug
);
45 #define GST_CAT_DEFAULT nicesink_debug
48 gst_nice_sink_render (
49 GstBaseSink
*basesink
,
53 gst_nice_sink_set_property (
60 gst_nice_sink_get_property (
67 gst_nice_sink_dispose (GObject
*object
);
69 static GstStateChangeReturn
70 gst_nice_sink_change_state (
72 GstStateChange transition
);
74 static GstStaticPadTemplate gst_nice_sink_sink_template
=
75 GST_STATIC_PAD_TEMPLATE (
81 G_DEFINE_TYPE (GstNiceSink
, gst_nice_sink
, GST_TYPE_BASE_SINK
);
91 gst_nice_sink_class_init (GstNiceSinkClass
*klass
)
93 GstBaseSinkClass
*gstbasesink_class
;
94 GstElementClass
*gstelement_class
;
95 GObjectClass
*gobject_class
;
97 GST_DEBUG_CATEGORY_INIT (nicesink_debug
, "nicesink",
100 gstbasesink_class
= (GstBaseSinkClass
*) klass
;
101 gstbasesink_class
->render
= GST_DEBUG_FUNCPTR (gst_nice_sink_render
);
103 gobject_class
= (GObjectClass
*) klass
;
104 gobject_class
->set_property
= gst_nice_sink_set_property
;
105 gobject_class
->get_property
= gst_nice_sink_get_property
;
106 gobject_class
->dispose
= gst_nice_sink_dispose
;
108 gstelement_class
= (GstElementClass
*) klass
;
109 gstelement_class
->change_state
= gst_nice_sink_change_state
;
111 gst_element_class_add_pad_template (gstelement_class
,
112 gst_static_pad_template_get (&gst_nice_sink_sink_template
));
113 #if GST_CHECK_VERSION (1,0,0)
114 gst_element_class_set_metadata (gstelement_class
,
116 gst_element_class_set_details_simple (gstelement_class
,
120 "Interactive UDP connectivity establishment",
121 "Dafydd Harries <dafydd.harries@collabora.co.uk>");
124 g_object_class_install_property (gobject_class
, PROP_AGENT
,
125 g_param_spec_object (
128 "The NiceAgent this source is bound to",
132 g_object_class_install_property (gobject_class
, PROP_STREAM
,
136 "The ID of the stream to read from",
142 g_object_class_install_property (gobject_class
, PROP_COMPONENT
,
146 "The ID of the component to read from",
154 gst_nice_sink_init (GstNiceSink
*sink
)
159 gst_nice_sink_render (GstBaseSink
*basesink
, GstBuffer
*buffer
)
161 GstNiceSink
*nicesink
= GST_NICE_SINK (basesink
);
163 #if GST_CHECK_VERSION (1,0,0)
166 gst_buffer_map (buffer
, &info
, GST_MAP_READ
);
168 nice_agent_send (nicesink
->agent
, nicesink
->stream_id
,
169 nicesink
->component_id
, info
.size
, (gchar
*) info
.data
);
171 gst_buffer_unmap (buffer
, &info
);
173 nice_agent_send (nicesink
->agent
, nicesink
->stream_id
,
174 nicesink
->component_id
, GST_BUFFER_SIZE (buffer
),
175 (gchar
*) GST_BUFFER_DATA (buffer
));
183 gst_nice_sink_dispose (GObject
*object
)
185 GstNiceSink
*sink
= GST_NICE_SINK (object
);
188 g_object_unref (sink
->agent
);
191 G_OBJECT_CLASS (gst_nice_sink_parent_class
)->dispose (object
);
195 gst_nice_sink_set_property (
201 GstNiceSink
*sink
= GST_NICE_SINK (object
);
207 GST_ERROR_OBJECT (object
,
208 "Changing the agent on a nice sink not allowed");
210 sink
->agent
= g_value_dup_object (value
);
214 sink
->stream_id
= g_value_get_uint (value
);
218 sink
->component_id
= g_value_get_uint (value
);
222 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
228 gst_nice_sink_get_property (
234 GstNiceSink
*sink
= GST_NICE_SINK (object
);
239 g_value_set_object (value
, sink
->agent
);
243 g_value_set_uint (value
, sink
->stream_id
);
247 g_value_set_uint (value
, sink
->component_id
);
251 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
256 static GstStateChangeReturn
257 gst_nice_sink_change_state (GstElement
* element
, GstStateChange transition
)
260 GstStateChangeReturn ret
;
262 sink
= GST_NICE_SINK (element
);
264 switch (transition
) {
265 case GST_STATE_CHANGE_NULL_TO_READY
:
266 if (sink
->agent
== NULL
)
268 GST_ERROR_OBJECT (element
,
269 "Trying to start Nice sink without an agent set");
270 return GST_STATE_CHANGE_FAILURE
;
277 ret
= GST_ELEMENT_CLASS (gst_nice_sink_parent_class
)->change_state (element
,