94 }; |
94 }; |
95 |
95 |
96 QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent) |
96 QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent) |
97 : QVideoWidgetControl(parent) |
97 : QVideoWidgetControl(parent) |
98 , m_videoSink(0) |
98 , m_videoSink(0) |
99 , m_widget(new QGstreamerVideoWidget) |
99 , m_widget(0) |
100 , m_fullScreen(false) |
100 , m_fullScreen(false) |
101 { |
101 { |
|
102 } |
|
103 |
|
104 QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl() |
|
105 { |
|
106 if (m_videoSink) |
|
107 gst_object_unref(GST_OBJECT(m_videoSink)); |
|
108 |
|
109 delete m_widget; |
|
110 } |
|
111 |
|
112 void QGstreamerVideoWidgetControl::createVideoWidget() |
|
113 { |
|
114 if (m_widget) |
|
115 return; |
|
116 |
|
117 m_widget = new QGstreamerVideoWidget; |
|
118 |
102 m_widget->installEventFilter(this); |
119 m_widget->installEventFilter(this); |
103 m_windowId = m_widget->winId(); |
120 m_windowId = m_widget->winId(); |
104 |
121 |
105 m_videoSink = gst_element_factory_make ("xvimagesink", NULL); |
122 m_videoSink = gst_element_factory_make ("xvimagesink", NULL); |
106 if (m_videoSink) { |
123 if (m_videoSink) { |
127 gst_object_sink (GST_OBJECT (m_videoSink)); |
144 gst_object_sink (GST_OBJECT (m_videoSink)); |
128 |
145 |
129 |
146 |
130 } |
147 } |
131 |
148 |
132 QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl() |
|
133 { |
|
134 if (m_videoSink) |
|
135 gst_object_unref(GST_OBJECT(m_videoSink)); |
|
136 |
|
137 delete m_widget; |
|
138 } |
|
139 |
|
140 GstElement *QGstreamerVideoWidgetControl::videoSink() |
149 GstElement *QGstreamerVideoWidgetControl::videoSink() |
141 { |
150 { |
|
151 createVideoWidget(); |
142 return m_videoSink; |
152 return m_videoSink; |
143 } |
153 } |
144 |
154 |
145 bool QGstreamerVideoWidgetControl::eventFilter(QObject *object, QEvent *e) |
155 bool QGstreamerVideoWidgetControl::eventFilter(QObject *object, QEvent *e) |
146 { |
156 { |
147 if (object == m_widget) { |
157 if (m_widget && object == m_widget) { |
148 if (e->type() == QEvent::ParentChange || e->type() == QEvent::Show) { |
158 if (e->type() == QEvent::ParentChange || e->type() == QEvent::Show) { |
149 WId newWId = m_widget->winId(); |
159 WId newWId = m_widget->winId(); |
150 if (newWId != m_windowId) { |
160 if (newWId != m_windowId) { |
151 m_windowId = newWId; |
161 m_windowId = newWId; |
152 // Even if we have created a winId at this point, other X applications |
162 // Even if we have created a winId at this point, other X applications |
254 |
266 |
255 int QGstreamerVideoWidgetControl::brightness() const |
267 int QGstreamerVideoWidgetControl::brightness() const |
256 { |
268 { |
257 int brightness = 0; |
269 int brightness = 0; |
258 |
270 |
259 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) |
271 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) |
260 g_object_get(G_OBJECT(m_videoSink), "brightness", &brightness, NULL); |
272 g_object_get(G_OBJECT(m_videoSink), "brightness", &brightness, NULL); |
261 |
273 |
262 return brightness / 10; |
274 return brightness / 10; |
263 } |
275 } |
264 |
276 |
265 void QGstreamerVideoWidgetControl::setBrightness(int brightness) |
277 void QGstreamerVideoWidgetControl::setBrightness(int brightness) |
266 { |
278 { |
267 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) { |
279 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) { |
268 g_object_set(G_OBJECT(m_videoSink), "brightness", brightness * 10, NULL); |
280 g_object_set(G_OBJECT(m_videoSink), "brightness", brightness * 10, NULL); |
269 |
281 |
270 emit brightnessChanged(brightness); |
282 emit brightnessChanged(brightness); |
271 } |
283 } |
272 } |
284 } |
273 |
285 |
274 int QGstreamerVideoWidgetControl::contrast() const |
286 int QGstreamerVideoWidgetControl::contrast() const |
275 { |
287 { |
276 int contrast = 0; |
288 int contrast = 0; |
277 |
289 |
278 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) |
290 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) |
279 g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL); |
291 g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL); |
280 |
292 |
281 return contrast / 10; |
293 return contrast / 10; |
282 } |
294 } |
283 |
295 |
284 void QGstreamerVideoWidgetControl::setContrast(int contrast) |
296 void QGstreamerVideoWidgetControl::setContrast(int contrast) |
285 { |
297 { |
286 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) { |
298 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) { |
287 g_object_set(G_OBJECT(m_videoSink), "contrast", contrast * 10, NULL); |
299 g_object_set(G_OBJECT(m_videoSink), "contrast", contrast * 10, NULL); |
288 |
300 |
289 emit contrastChanged(contrast); |
301 emit contrastChanged(contrast); |
290 } |
302 } |
291 } |
303 } |
292 |
304 |
293 int QGstreamerVideoWidgetControl::hue() const |
305 int QGstreamerVideoWidgetControl::hue() const |
294 { |
306 { |
295 int hue = 0; |
307 int hue = 0; |
296 |
308 |
297 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) |
309 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) |
298 g_object_get(G_OBJECT(m_videoSink), "hue", &hue, NULL); |
310 g_object_get(G_OBJECT(m_videoSink), "hue", &hue, NULL); |
299 |
311 |
300 return hue / 10; |
312 return hue / 10; |
301 } |
313 } |
302 |
314 |
303 void QGstreamerVideoWidgetControl::setHue(int hue) |
315 void QGstreamerVideoWidgetControl::setHue(int hue) |
304 { |
316 { |
305 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) { |
317 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) { |
306 g_object_set(G_OBJECT(m_videoSink), "hue", hue * 10, NULL); |
318 g_object_set(G_OBJECT(m_videoSink), "hue", hue * 10, NULL); |
307 |
319 |
308 emit hueChanged(hue); |
320 emit hueChanged(hue); |
309 } |
321 } |
310 } |
322 } |
311 |
323 |
312 int QGstreamerVideoWidgetControl::saturation() const |
324 int QGstreamerVideoWidgetControl::saturation() const |
313 { |
325 { |
314 int saturation = 0; |
326 int saturation = 0; |
315 |
327 |
316 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) |
328 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) |
317 g_object_get(G_OBJECT(m_videoSink), "saturation", &saturation, NULL); |
329 g_object_get(G_OBJECT(m_videoSink), "saturation", &saturation, NULL); |
318 |
330 |
319 return saturation / 10; |
331 return saturation / 10; |
320 } |
332 } |
321 |
333 |
322 void QGstreamerVideoWidgetControl::setSaturation(int saturation) |
334 void QGstreamerVideoWidgetControl::setSaturation(int saturation) |
323 { |
335 { |
324 if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) { |
336 if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) { |
325 g_object_set(G_OBJECT(m_videoSink), "saturation", saturation * 10, NULL); |
337 g_object_set(G_OBJECT(m_videoSink), "saturation", saturation * 10, NULL); |
326 |
338 |
327 emit saturationChanged(saturation); |
339 emit saturationChanged(saturation); |
328 } |
340 } |
329 } |
341 } |