2 * Copyright (C) 2011 Igalia S.L
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "GRefPtrGStreamer.h"
28 template <> GRefPtr<GstElement> adoptGRef(GstElement* ptr)
30 ASSERT(!ptr || !g_object_is_floating(G_OBJECT(ptr)));
31 return GRefPtr<GstElement>(ptr, GRefPtrAdopt);
34 template <> GstElement* refGPtr<GstElement>(GstElement* ptr)
37 gst_object_ref_sink(GST_OBJECT(ptr));
42 template <> void derefGPtr<GstElement>(GstElement* ptr)
45 gst_object_unref(ptr);
48 template <> GRefPtr<GstPad> adoptGRef(GstPad* ptr)
50 ASSERT(!ptr || !g_object_is_floating(G_OBJECT(ptr)));
51 return GRefPtr<GstPad>(ptr, GRefPtrAdopt);
54 template <> GstPad* refGPtr<GstPad>(GstPad* ptr)
57 gst_object_ref_sink(GST_OBJECT(ptr));
62 template <> void derefGPtr<GstPad>(GstPad* ptr)
65 gst_object_unref(GST_OBJECT(ptr));
68 template <> GRefPtr<GstPadTemplate> adoptGRef(GstPadTemplate* ptr)
70 ASSERT(!ptr || !g_object_is_floating(G_OBJECT(ptr)));
71 return GRefPtr<GstPadTemplate>(ptr, GRefPtrAdopt);
74 template <> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr)
77 gst_object_ref_sink(GST_OBJECT(ptr));
82 template <> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr)
85 gst_object_unref(GST_OBJECT(ptr));
88 template <> GRefPtr<GstCaps> adoptGRef(GstCaps* ptr)
90 return GRefPtr<GstCaps>(ptr, GRefPtrAdopt);
93 template <> GstCaps* refGPtr<GstCaps>(GstCaps* ptr)
100 template <> void derefGPtr<GstCaps>(GstCaps* ptr)
106 template <> GRefPtr<GstContext> adoptGRef(GstContext* ptr)
108 ASSERT(!g_object_is_floating(G_OBJECT(ptr)));
109 return GRefPtr<GstContext>(ptr, GRefPtrAdopt);
112 template <> GstContext* refGPtr<GstContext>(GstContext* ptr)
115 gst_context_ref(ptr);
119 template <> void derefGPtr<GstContext>(GstContext* ptr)
122 gst_context_unref(ptr);
125 template <> GRefPtr<GstTask> adoptGRef(GstTask* ptr)
127 ASSERT(!g_object_is_floating(G_OBJECT(ptr)));
128 return GRefPtr<GstTask>(ptr, GRefPtrAdopt);
131 template <> GstTask* refGPtr<GstTask>(GstTask* ptr)
134 gst_object_ref_sink(GST_OBJECT(ptr));
139 template <> void derefGPtr<GstTask>(GstTask* ptr)
142 gst_object_unref(ptr);
145 template <> GRefPtr<GstBus> adoptGRef(GstBus* ptr)
147 ASSERT(!g_object_is_floating(G_OBJECT(ptr)));
148 return GRefPtr<GstBus>(ptr, GRefPtrAdopt);
151 template <> GstBus* refGPtr<GstBus>(GstBus* ptr)
154 gst_object_ref_sink(GST_OBJECT(ptr));
159 template <> void derefGPtr<GstBus>(GstBus* ptr)
162 gst_object_unref(ptr);
165 template <> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr)
167 ASSERT(!g_object_is_floating(G_OBJECT(ptr)));
168 return GRefPtr<GstElementFactory>(ptr, GRefPtrAdopt);
171 template <> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr)
174 gst_object_ref_sink(GST_OBJECT(ptr));
179 template <> void derefGPtr<GstElementFactory>(GstElementFactory* ptr)
182 gst_object_unref(ptr);
185 template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr)
187 return GRefPtr<GstBuffer>(ptr, GRefPtrAdopt);
190 template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr)
198 template<> void derefGPtr<GstBuffer>(GstBuffer* ptr)
201 gst_buffer_unref(ptr);
204 template<> GRefPtr<GstBufferList> adoptGRef(GstBufferList* ptr)
206 return GRefPtr<GstBufferList>(ptr, GRefPtrAdopt);
209 template<> GstBufferList* refGPtr<GstBufferList>(GstBufferList* ptr)
212 gst_buffer_list_ref(ptr);
217 template<> void derefGPtr<GstBufferList>(GstBufferList* ptr)
220 gst_buffer_list_unref(ptr);
223 template<> GRefPtr<GstSample> adoptGRef(GstSample* ptr)
225 return GRefPtr<GstSample>(ptr, GRefPtrAdopt);
228 template<> GstSample* refGPtr<GstSample>(GstSample* ptr)
236 template<> void derefGPtr<GstSample>(GstSample* ptr)
239 gst_sample_unref(ptr);
242 template<> GRefPtr<GstTagList> adoptGRef(GstTagList* ptr)
244 return GRefPtr<GstTagList>(ptr, GRefPtrAdopt);
247 template<> GstTagList* refGPtr<GstTagList>(GstTagList* ptr)
250 gst_tag_list_ref(ptr);
255 template<> void derefGPtr<GstTagList>(GstTagList* ptr)
258 gst_tag_list_unref(ptr);
261 template<> GRefPtr<GstEvent> adoptGRef(GstEvent* ptr)
263 return GRefPtr<GstEvent>(ptr, GRefPtrAdopt);
266 template<> GstEvent* refGPtr<GstEvent>(GstEvent* ptr)
274 template<> void derefGPtr<GstEvent>(GstEvent* ptr)
277 gst_event_unref(ptr);
280 template<> GRefPtr<GstToc> adoptGRef(GstToc* ptr)
282 return GRefPtr<GstToc>(ptr, GRefPtrAdopt);
285 template<> GstToc* refGPtr<GstToc>(GstToc* ptr)
288 return gst_toc_ref(ptr);
293 template<> void derefGPtr<GstToc>(GstToc* ptr)
299 template<> GRefPtr<GstMessage> adoptGRef(GstMessage* ptr)
301 return GRefPtr<GstMessage>(ptr, GRefPtrAdopt);
304 template<> GstMessage* refGPtr<GstMessage>(GstMessage* ptr)
307 return gst_message_ref(ptr);
312 template<> void derefGPtr<GstMessage>(GstMessage* ptr)
315 gst_message_unref(ptr);
318 template <> GRefPtr<WebKitVideoSink> adoptGRef(WebKitVideoSink* ptr)
320 ASSERT(!ptr || !g_object_is_floating(G_OBJECT(ptr)));
321 return GRefPtr<WebKitVideoSink>(ptr, GRefPtrAdopt);
324 template <> WebKitVideoSink* refGPtr<WebKitVideoSink>(WebKitVideoSink* ptr)
327 gst_object_ref_sink(GST_OBJECT(ptr));
332 template <> void derefGPtr<WebKitVideoSink>(WebKitVideoSink* ptr)
335 gst_object_unref(GST_OBJECT(ptr));
338 template <> GRefPtr<WebKitWebSrc> adoptGRef(WebKitWebSrc* ptr)
340 ASSERT(!ptr || !g_object_is_floating(G_OBJECT(ptr)));
341 return GRefPtr<WebKitWebSrc>(ptr, GRefPtrAdopt);
344 template <> WebKitWebSrc* refGPtr<WebKitWebSrc>(WebKitWebSrc* ptr)
347 gst_object_ref_sink(GST_OBJECT(ptr));
352 template <> void derefGPtr<WebKitWebSrc>(WebKitWebSrc* ptr)
355 gst_object_unref(GST_OBJECT(ptr));
360 #endif // USE(GSTREAMER)