47 #include "qgstreamervideoencode.h" |
47 #include "qgstreamervideoencode.h" |
48 #include "qgstreamerbushelper.h" |
48 #include "qgstreamerbushelper.h" |
49 #include "qgstreamerv4l2input.h" |
49 #include "qgstreamerv4l2input.h" |
50 #include "qgstreamercapturemetadatacontrol.h" |
50 #include "qgstreamercapturemetadatacontrol.h" |
51 |
51 |
52 #include "qgstreamervideooutputcontrol.h" |
|
53 #include "qgstreameraudioinputendpointselector.h" |
52 #include "qgstreameraudioinputendpointselector.h" |
54 #include "qgstreamervideoinputdevicecontrol.h" |
53 #include "qgstreamervideoinputdevicecontrol.h" |
55 |
54 |
56 #include "qgstreamervideooverlay.h" |
55 #include "qgstreamervideooverlay.h" |
57 #include "qgstreamervideorenderer.h" |
56 #include "qgstreamervideorenderer.h" |
163 m_videoInput, SLOT(setDevice(QString))); |
162 m_videoInput, SLOT(setDevice(QString))); |
164 |
163 |
165 if (m_videoInputDevice->deviceCount()) |
164 if (m_videoInputDevice->deviceCount()) |
166 m_videoInput->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice())); |
165 m_videoInput->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice())); |
167 |
166 |
168 m_videoOutput = new QGstreamerVideoOutputControl(this); |
|
169 connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), |
|
170 this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); |
|
171 |
|
172 m_videoRenderer = new QGstreamerVideoRenderer(this); |
167 m_videoRenderer = new QGstreamerVideoRenderer(this); |
173 m_videoRendererFactory = new QGstreamerVideoRendererWrapper(m_videoRenderer); |
168 m_videoRendererFactory = new QGstreamerVideoRendererWrapper(m_videoRenderer); |
174 m_videoWindow = new QGstreamerVideoOverlay(this); |
169 |
175 m_videoWindowFactory = new QGstreamerVideoRendererWrapper(m_videoWindow); |
170 #ifndef QT_NO_XVIDEO |
176 |
171 QGstreamerVideoOverlay *videoWindow = new QGstreamerVideoOverlay(this); |
177 m_videoWidgetControl = new QGstreamerVideoWidgetControl(this); |
172 m_videoWindow = videoWindow; |
178 m_videoWidgetFactory = new QGstreamerVideoRendererWrapper(m_videoWidgetControl); |
173 m_videoWindowFactory = new QGstreamerVideoRendererWrapper(videoWindow); |
179 |
174 |
180 m_videoOutput->setAvailableOutputs(QList<QVideoOutputControl::Output>() |
175 QGstreamerVideoWidgetControl *videoWidget = new QGstreamerVideoWidgetControl(this); |
181 << QVideoOutputControl::RendererOutput |
176 m_videoWidgetControl = videoWidget; |
182 << QVideoOutputControl::WindowOutput |
177 m_videoWidgetFactory = new QGstreamerVideoRendererWrapper(videoWidget); |
183 << QVideoOutputControl::WidgetOutput); |
178 #endif |
184 } |
179 } |
185 |
180 |
186 if (!m_captureSession) { |
181 if (!m_captureSession) { |
187 qWarning() << "Service type is not supported:" << service; |
182 qWarning() << "Service type is not supported:" << service; |
188 return; |
183 return; |
201 |
196 |
202 QGstreamerCaptureService::~QGstreamerCaptureService() |
197 QGstreamerCaptureService::~QGstreamerCaptureService() |
203 { |
198 { |
204 } |
199 } |
205 |
200 |
206 QMediaControl *QGstreamerCaptureService::control(const char *name) const |
201 QMediaControl *QGstreamerCaptureService::requestControl(const char *name) |
207 { |
202 { |
208 if (!m_captureSession) |
203 if (!m_captureSession) |
209 return 0; |
204 return 0; |
210 |
205 |
211 if (qstrcmp(name, QVideoOutputControl_iid) == 0) |
|
212 return m_videoOutput; |
|
213 |
|
214 if (qstrcmp(name, QVideoRendererControl_iid) == 0) |
|
215 return m_videoRenderer; |
|
216 |
|
217 if (qstrcmp(name, QVideoWindowControl_iid) == 0) |
|
218 return m_videoWindow; |
|
219 |
|
220 if (qstrcmp(name, QVideoWidgetControl_iid) == 0) |
|
221 return m_videoWidgetControl; |
|
222 |
|
223 if (qstrcmp(name,QAudioEndpointSelector_iid) == 0) |
206 if (qstrcmp(name,QAudioEndpointSelector_iid) == 0) |
224 return m_audioInputEndpointSelector; |
207 return m_audioInputEndpointSelector; |
225 |
208 |
226 if (qstrcmp(name,QVideoDeviceControl_iid) == 0) |
209 if (qstrcmp(name,QVideoDeviceControl_iid) == 0) |
227 return m_videoInputDevice; |
210 return m_videoInputDevice; |
236 return m_captureSession->videoEncodeControl(); |
219 return m_captureSession->videoEncodeControl(); |
237 |
220 |
238 if (qstrcmp(name,QMediaContainerControl_iid) == 0) |
221 if (qstrcmp(name,QMediaContainerControl_iid) == 0) |
239 return m_captureSession->mediaContainerControl(); |
222 return m_captureSession->mediaContainerControl(); |
240 |
223 |
241 if (qstrcmp(name,QMetaDataControl_iid) == 0) |
224 if (qstrcmp(name,QMetaDataWriterControl_iid) == 0) |
242 return m_metaDataControl; |
225 return m_metaDataControl; |
243 |
226 |
|
227 if (!m_videoOutput) { |
|
228 if (qstrcmp(name, QVideoRendererControl_iid) == 0) { |
|
229 m_videoOutput = m_videoRenderer; |
|
230 m_captureSession->setVideoPreview(m_videoRendererFactory); |
|
231 } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { |
|
232 m_videoOutput = m_videoWindow; |
|
233 m_captureSession->setVideoPreview(m_videoWindowFactory); |
|
234 } else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) { |
|
235 m_captureSession->setVideoPreview(m_videoWidgetFactory); |
|
236 m_videoOutput = m_videoWidgetControl; |
|
237 } |
|
238 |
|
239 if (m_videoOutput) |
|
240 return m_videoOutput; |
|
241 } |
|
242 |
244 return 0; |
243 return 0; |
245 } |
244 } |
246 |
245 |
247 void QGstreamerCaptureService::videoOutputChanged(QVideoOutputControl::Output output) |
246 void QGstreamerCaptureService::releaseControl(QMediaControl *control) |
248 { |
247 { |
249 switch (output) { |
248 if (control && control == m_videoOutput) { |
250 case QVideoOutputControl::NoOutput: |
249 m_videoOutput = 0; |
251 m_captureSession->setVideoPreview(0); |
250 m_captureSession->setVideoPreview(0); |
252 break; |
251 } |
253 case QVideoOutputControl::RendererOutput: |
252 } |
254 m_captureSession->setVideoPreview(m_videoRendererFactory); |
|
255 break; |
|
256 case QVideoOutputControl::WindowOutput: |
|
257 m_captureSession->setVideoPreview(m_videoWindowFactory); |
|
258 break; |
|
259 case QVideoOutputControl::WidgetOutput: |
|
260 m_captureSession->setVideoPreview(m_videoWidgetFactory); |
|
261 break; |
|
262 default: |
|
263 qWarning("Invalid video output selection"); |
|
264 m_captureSession->setVideoPreview(0); |
|
265 break; |
|
266 } |
|
267 } |
|