tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/webkit-efl.git] / Source / WebCore / platform / graphics / gstreamer / GRefPtrGStreamer.cpp
1 /*
2  *  Copyright (C) 2011 Igalia S.L
3  *
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.
8  *
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.
13  *
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
17  */
18
19
20 #include "config.h"
21 #include "GRefPtrGStreamer.h"
22 #include "GStreamerVersioning.h"
23
24 #if USE(GSTREAMER) || ENABLE(TIZEN_WEB_AUDIO)
25 #include <gst/gstelement.h>
26
27 namespace WTF {
28
29 template <> GRefPtr<GstElement> adoptGRef(GstElement* ptr)
30 {
31     ASSERT(!ptr || !GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
32     return GRefPtr<GstElement>(ptr, GRefPtrAdopt);
33 }
34
35 template <> GstElement* refGPtr<GstElement>(GstElement* ptr)
36 {
37     if (ptr)
38         webkitGstObjectRefSink(GST_OBJECT(ptr));
39
40     return ptr;
41 }
42
43 template <> void derefGPtr<GstElement>(GstElement* ptr)
44 {
45     if (ptr)
46         gst_object_unref(ptr);
47 }
48
49 template <> GRefPtr<GstPad> adoptGRef(GstPad* ptr)
50 {
51     ASSERT(!ptr || !GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
52     return GRefPtr<GstPad>(ptr, GRefPtrAdopt);
53 }
54
55 template <> GstPad* refGPtr<GstPad>(GstPad* ptr)
56 {
57     if (ptr)
58         webkitGstObjectRefSink(GST_OBJECT(ptr));
59
60     return ptr;
61 }
62
63 template <> void derefGPtr<GstPad>(GstPad* ptr)
64 {
65     if (ptr)
66         gst_object_unref(GST_OBJECT(ptr));
67 }
68
69 template <> GRefPtr<GstPadTemplate> adoptGRef(GstPadTemplate* ptr)
70 {
71     ASSERT(!ptr || !GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
72     return GRefPtr<GstPadTemplate>(ptr, GRefPtrAdopt);
73 }
74
75 template <> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr)
76 {
77     if (ptr)
78         webkitGstObjectRefSink(GST_OBJECT(ptr));
79
80     return ptr;
81 }
82
83 template <> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr)
84 {
85     if (ptr)
86         gst_object_unref(GST_OBJECT(ptr));
87 }
88
89 template <> GstCaps* refGPtr<GstCaps>(GstCaps* ptr)
90 {
91     if (ptr)
92         gst_caps_ref(ptr);
93     return ptr;
94 }
95
96 template <> void derefGPtr<GstCaps>(GstCaps* ptr)
97 {
98     if (ptr)
99         gst_caps_unref(ptr);
100 }
101
102
103 template <> GRefPtr<GstTask> adoptGRef(GstTask* ptr)
104 {
105     ASSERT(!GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
106     return GRefPtr<GstTask>(ptr, GRefPtrAdopt);
107 }
108
109 template <> GstTask* refGPtr<GstTask>(GstTask* ptr)
110 {
111     if (ptr)
112         webkitGstObjectRefSink(GST_OBJECT(ptr));
113
114     return ptr;
115 }
116
117 template <> void derefGPtr<GstTask>(GstTask* ptr)
118 {
119     if (ptr)
120         gst_object_unref(ptr);
121 }
122
123 template <> GRefPtr<GstBus> adoptGRef(GstBus* ptr)
124 {
125     ASSERT(!GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
126     return GRefPtr<GstBus>(ptr, GRefPtrAdopt);
127 }
128
129 template <> GstBus* refGPtr<GstBus>(GstBus* ptr)
130 {
131     if (ptr)
132         webkitGstObjectRefSink(GST_OBJECT(ptr));
133
134     return ptr;
135 }
136
137 template <> void derefGPtr<GstBus>(GstBus* ptr)
138 {
139     if (ptr)
140         gst_object_unref(ptr);
141 }
142
143 template <> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr)
144 {
145     ASSERT(!GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
146     return GRefPtr<GstElementFactory>(ptr, GRefPtrAdopt);
147 }
148
149 template <> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr)
150 {
151     if (ptr)
152         webkitGstObjectRefSink(GST_OBJECT(ptr));
153
154     return ptr;
155 }
156
157 template <> void derefGPtr<GstElementFactory>(GstElementFactory* ptr)
158 {
159     if (ptr)
160         gst_object_unref(ptr);
161 }
162
163 }
164 #endif // USE(GSTREAMER)