47 , m_deviceManager(0) |
47 , m_deviceManager(0) |
48 , m_effectManager(0) |
48 , m_effectManager(0) |
49 , m_debugLevel(Warning) |
49 , m_debugLevel(Warning) |
50 , m_isValid(false) |
50 , m_isValid(false) |
51 { |
51 { |
|
52 // In order to support reloading, we only set the app name once... |
|
53 static bool first = true; |
|
54 if (first) { |
|
55 first = false; |
|
56 g_set_application_name(qApp->applicationName().toUtf8()); |
|
57 } |
|
58 |
52 GError *err = 0; |
59 GError *err = 0; |
53 bool wasInit = gst_init_check(0, 0, &err); //init gstreamer: must be called before any gst-related functions |
60 bool wasInit = gst_init_check(0, 0, &err); //init gstreamer: must be called before any gst-related functions |
54 if (err) |
61 if (err) |
55 g_error_free(err); |
62 g_error_free(err); |
56 |
63 |
57 qRegisterMetaType<Message>("Message"); |
64 qRegisterMetaType<Message>("Message"); |
58 |
65 #ifndef QT_NO_PROPERTIES |
59 setProperty("identifier", QLatin1String("phonon_gstreamer")); |
66 setProperty("identifier", QLatin1String("phonon_gstreamer")); |
60 setProperty("backendName", QLatin1String("Gstreamer")); |
67 setProperty("backendName", QLatin1String("Gstreamer")); |
61 setProperty("backendComment", QLatin1String("Gstreamer plugin for Phonon")); |
68 setProperty("backendComment", QLatin1String("Gstreamer plugin for Phonon")); |
62 setProperty("backendVersion", QLatin1String("0.2")); |
69 setProperty("backendVersion", QLatin1String("0.2")); |
63 setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); |
70 setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); |
|
71 #endif //QT_NO_PROPERTIES |
64 |
72 |
65 //check if we should enable debug output |
73 //check if we should enable debug output |
66 QString debugLevelString = qgetenv("PHONON_GST_DEBUG"); |
74 QString debugLevelString = qgetenv("PHONON_GST_DEBUG"); |
67 int debugLevel = debugLevelString.toInt(); |
75 int debugLevel = debugLevelString.toInt(); |
68 if (debugLevel > 3) //3 is maximum |
76 if (debugLevel > 3) //3 is maximum |
115 case AudioOutputClass: { |
122 case AudioOutputClass: { |
116 AudioOutput *ao = new AudioOutput(this, parent); |
123 AudioOutput *ao = new AudioOutput(this, parent); |
117 m_audioOutputs.append(ao); |
124 m_audioOutputs.append(ao); |
118 return ao; |
125 return ao; |
119 } |
126 } |
|
127 #ifndef QT_NO_PHONON_EFFECT |
120 case EffectClass: |
128 case EffectClass: |
121 return new AudioEffect(this, args[0].toInt(), parent); |
129 return new AudioEffect(this, args[0].toInt(), parent); |
122 |
130 #endif //QT_NO_PHONON_EFFECT |
123 case AudioDataOutputClass: |
131 case AudioDataOutputClass: |
124 logMessage("createObject() : AudioDataOutput not implemented"); |
132 logMessage("createObject() : AudioDataOutput not implemented"); |
125 break; |
133 break; |
126 |
134 |
|
135 #ifndef QT_NO_PHONON_VIDEO |
127 case VideoDataOutputClass: |
136 case VideoDataOutputClass: |
128 logMessage("createObject() : VideoDataOutput not implemented"); |
137 logMessage("createObject() : VideoDataOutput not implemented"); |
129 break; |
138 break; |
130 |
139 |
131 case VideoWidgetClass: { |
140 case VideoWidgetClass: { |
132 QWidget *widget = qobject_cast<QWidget*>(parent); |
141 QWidget *widget = qobject_cast<QWidget*>(parent); |
133 return new VideoWidget(this, widget); |
142 return new VideoWidget(this, widget); |
134 } |
143 } |
135 |
144 #endif //QT_NO_PHONON_VIDEO |
|
145 #ifndef QT_NO_PHONON_VOLUMEFADEREFFECT |
136 case VolumeFaderEffectClass: |
146 case VolumeFaderEffectClass: |
137 return new VolumeFaderEffect(this, parent); |
147 return new VolumeFaderEffect(this, parent); |
|
148 #endif //QT_NO_PHONON_VOLUMEFADEREFFECT |
138 |
149 |
139 case VisualizationClass: //Fall through |
150 case VisualizationClass: //Fall through |
140 default: |
151 default: |
141 logMessage("createObject() : Backend object not available"); |
152 logMessage("createObject() : Backend object not available"); |
142 } |
153 } |
201 GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); |
212 GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); |
202 for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { |
213 for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { |
203 GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); |
214 GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); |
204 QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); |
215 QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); |
205 |
216 |
206 if (klass == QLatin1String("Codec/Decoder/Audio") || |
217 if (klass == QLatin1String("Codec/Decoder") || |
207 klass == QLatin1String("Codec/Decoder/Video")) { |
218 klass == QLatin1String("Codec/Decoder/Audio") || |
|
219 klass == QLatin1String("Codec/Decoder/Video") || |
|
220 klass == QLatin1String("Codec/Demuxer") || |
|
221 klass == QLatin1String("Codec/Demuxer/Audio") || |
|
222 klass == QLatin1String("Codec/Demuxer/Video") || |
|
223 klass == QLatin1String("Codec/Parser") || |
|
224 klass == QLatin1String("Codec/Parser/Audio") || |
|
225 klass == QLatin1String("Codec/Parser/Video")) { |
208 |
226 |
209 const GList *static_templates; |
227 const GList *static_templates; |
210 GstElementFactory *factory = GST_ELEMENT_FACTORY(feature); |
228 GstElementFactory *factory = GST_ELEMENT_FACTORY(feature); |
211 static_templates = gst_element_factory_get_static_pad_templates(factory); |
229 static_templates = gst_element_factory_get_static_pad_templates(factory); |
212 |
230 |
274 return ret; |
292 return ret; |
275 |
293 |
276 switch (type) { |
294 switch (type) { |
277 case Phonon::AudioOutputDeviceType: { |
295 case Phonon::AudioOutputDeviceType: { |
278 QList<AudioDevice> audioDevices = deviceManager()->audioOutputDevices(); |
296 QList<AudioDevice> audioDevices = deviceManager()->audioOutputDevices(); |
279 if (index >= 0 && index < audioDevices.size()) { |
297 foreach(const AudioDevice &device, audioDevices) { |
280 ret.insert("name", audioDevices[index].gstId); |
298 if (device.id == index) { |
281 ret.insert("description", audioDevices[index].description); |
299 ret.insert("name", device.gstId); |
282 ret.insert("icon", QLatin1String("audio-card")); |
300 ret.insert("description", device.description); |
|
301 ret.insert("icon", QLatin1String("audio-card")); |
|
302 break; |
|
303 } |
283 } |
304 } |
284 } |
305 } |
285 break; |
306 break; |
286 |
307 |
287 case Phonon::EffectType: { |
308 case Phonon::EffectType: { |