43 #include "qgstreamercapturesession.h" |
43 #include "qgstreamercapturesession.h" |
44 #include "qgstreamerrecordercontrol.h" |
44 #include "qgstreamerrecordercontrol.h" |
45 #include "qgstreamermediacontainercontrol.h" |
45 #include "qgstreamermediacontainercontrol.h" |
46 #include "qgstreameraudioencode.h" |
46 #include "qgstreameraudioencode.h" |
47 #include "qgstreamervideoencode.h" |
47 #include "qgstreamervideoencode.h" |
48 #include "qgstreamerimageencode.h" |
|
49 #include "qgstreamerbushelper.h" |
48 #include "qgstreamerbushelper.h" |
50 #include "qgstreamercameracontrol.h" |
49 #include "qgstreamerv4l2input.h" |
51 #include "qgstreamercapturemetadatacontrol.h" |
50 #include "qgstreamercapturemetadatacontrol.h" |
52 |
51 |
53 #include "qgstreamervideooutputcontrol.h" |
52 #include "qgstreamervideooutputcontrol.h" |
54 #include "qgstreameraudioinputendpointselector.h" |
53 #include "qgstreameraudioinputendpointselector.h" |
55 #include "qgstreamervideoinputdevicecontrol.h" |
54 #include "qgstreamervideoinputdevicecontrol.h" |
56 #include "qgstreamerimagecapturecontrol.h" |
|
57 |
55 |
58 #include "qgstreamervideooverlay.h" |
56 #include "qgstreamervideooverlay.h" |
59 #include "qgstreamervideorenderer.h" |
57 #include "qgstreamervideorenderer.h" |
60 |
58 |
61 #include "qgstreamervideowidget.h" |
59 #include "qgstreamervideowidget.h" |
62 |
60 |
63 #include <qmediaserviceprovider.h> |
61 #include <qmediaserviceprovider.h> |
|
62 |
|
63 #include <QtCore/qdebug.h> |
64 |
64 |
65 |
65 |
66 class QGstreamerVideoRendererWrapper : public QGstreamerElementFactory |
66 class QGstreamerVideoRendererWrapper : public QGstreamerElementFactory |
67 { |
67 { |
68 public: |
68 public: |
80 gst_object_unref(GST_OBJECT(m_bin)); |
80 gst_object_unref(GST_OBJECT(m_bin)); |
81 } |
81 } |
82 |
82 |
83 GstElement *buildElement() |
83 GstElement *buildElement() |
84 { |
84 { |
|
85 #ifdef Q_WS_MAEMO_5 |
|
86 return m_element = m_videoRenderer->videoSink(); |
|
87 #endif |
85 if (m_bin == NULL) { |
88 if (m_bin == NULL) { |
86 GstBin * bin = GST_BIN(gst_bin_new(NULL)); |
89 GstBin * bin = GST_BIN(gst_bin_new(NULL)); |
87 |
90 |
88 m_colorspace = gst_element_factory_make("ffmpegcolorspace", NULL); |
91 m_colorspace = gst_element_factory_make("ffmpegcolorspace", NULL); |
89 m_element = m_videoRenderer->videoSink(); |
92 m_element = m_videoRenderer->videoSink(); |
128 initialized = true; |
131 initialized = true; |
129 gst_init(NULL, NULL); |
132 gst_init(NULL, NULL); |
130 } |
133 } |
131 |
134 |
132 m_captureSession = 0; |
135 m_captureSession = 0; |
133 m_cameraControl = 0; |
|
134 m_metaDataControl = 0; |
136 m_metaDataControl = 0; |
135 |
137 |
|
138 m_videoInput = 0; |
136 m_audioInputEndpointSelector = 0; |
139 m_audioInputEndpointSelector = 0; |
137 m_videoInputDevice = 0; |
140 m_videoInputDevice = 0; |
138 |
141 |
139 m_videoOutput = 0; |
142 m_videoOutput = 0; |
140 m_videoRenderer = 0; |
143 m_videoRenderer = 0; |
141 m_videoRendererFactory = 0; |
144 m_videoRendererFactory = 0; |
142 m_videoWindow = 0; |
145 m_videoWindow = 0; |
143 m_videoWindowFactory = 0; |
146 m_videoWindowFactory = 0; |
144 m_videoWidgetControl = 0; |
147 m_videoWidgetControl = 0; |
145 m_videoWidgetFactory = 0; |
148 m_videoWidgetFactory = 0; |
146 m_imageCaptureControl = 0; |
|
147 |
|
148 |
149 |
149 if (service == Q_MEDIASERVICE_AUDIOSOURCE) { |
150 if (service == Q_MEDIASERVICE_AUDIOSOURCE) { |
150 m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::Audio, this); |
151 m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::Audio, this); |
151 } |
152 } |
152 |
153 |
153 if (service == Q_MEDIASERVICE_CAMERA) { |
154 bool captureVideo = false; |
154 m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::AudioAndVideo, this); |
155 |
155 m_cameraControl = new QGstreamerCameraControl(m_captureSession); |
156 if (captureVideo) { |
156 m_captureSession->setVideoInput(m_cameraControl); |
157 m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::AudioAndVideo, this); |
157 m_videoInputDevice = new QGstreamerVideoInputDeviceControl(m_captureSession); |
158 m_videoInput = new QGstreamerV4L2Input(this); |
158 m_imageCaptureControl = new QGstreamerImageCaptureControl(m_captureSession); |
159 m_captureSession->setVideoInput(m_videoInput); |
|
160 m_videoInputDevice = new QGstreamerVideoInputDeviceControl(this); |
159 |
161 |
160 connect(m_videoInputDevice, SIGNAL(selectedDeviceChanged(QString)), |
162 connect(m_videoInputDevice, SIGNAL(selectedDeviceChanged(QString)), |
161 m_cameraControl, SLOT(setDevice(QString))); |
163 m_videoInput, SLOT(setDevice(QString))); |
162 |
164 |
163 if (m_videoInputDevice->deviceCount()) |
165 if (m_videoInputDevice->deviceCount()) |
164 m_cameraControl->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice())); |
166 m_videoInput->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice())); |
165 |
167 |
166 m_videoOutput = new QGstreamerVideoOutputControl(this); |
168 m_videoOutput = new QGstreamerVideoOutputControl(this); |
167 connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), |
169 connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), |
168 this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); |
170 this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); |
169 |
171 |
179 << QVideoOutputControl::RendererOutput |
181 << QVideoOutputControl::RendererOutput |
180 << QVideoOutputControl::WindowOutput |
182 << QVideoOutputControl::WindowOutput |
181 << QVideoOutputControl::WidgetOutput); |
183 << QVideoOutputControl::WidgetOutput); |
182 } |
184 } |
183 |
185 |
|
186 if (!m_captureSession) { |
|
187 qWarning() << "Service type is not supported:" << service; |
|
188 return; |
|
189 } |
|
190 |
184 m_audioInputEndpointSelector = new QGstreamerAudioInputEndpointSelector(this); |
191 m_audioInputEndpointSelector = new QGstreamerAudioInputEndpointSelector(this); |
185 connect(m_audioInputEndpointSelector, SIGNAL(activeEndpointChanged(QString)), m_captureSession, SLOT(setCaptureDevice(QString))); |
192 connect(m_audioInputEndpointSelector, SIGNAL(activeEndpointChanged(QString)), m_captureSession, SLOT(setCaptureDevice(QString))); |
186 |
193 |
187 if (m_captureSession && m_audioInputEndpointSelector->availableEndpoints().size() > 0) |
194 if (m_captureSession && m_audioInputEndpointSelector->availableEndpoints().size() > 0) |
188 m_captureSession->setCaptureDevice(m_audioInputEndpointSelector->defaultEndpoint()); |
195 m_captureSession->setCaptureDevice(m_audioInputEndpointSelector->defaultEndpoint()); |
196 { |
203 { |
197 } |
204 } |
198 |
205 |
199 QMediaControl *QGstreamerCaptureService::control(const char *name) const |
206 QMediaControl *QGstreamerCaptureService::control(const char *name) const |
200 { |
207 { |
|
208 if (!m_captureSession) |
|
209 return 0; |
|
210 |
201 if (qstrcmp(name, QVideoOutputControl_iid) == 0) |
211 if (qstrcmp(name, QVideoOutputControl_iid) == 0) |
202 return m_videoOutput; |
212 return m_videoOutput; |
203 |
213 |
204 if (qstrcmp(name, QVideoRendererControl_iid) == 0) |
214 if (qstrcmp(name, QVideoRendererControl_iid) == 0) |
205 return m_videoRenderer; |
215 return m_videoRenderer; |
223 return m_captureSession->audioEncodeControl(); |
233 return m_captureSession->audioEncodeControl(); |
224 |
234 |
225 if (qstrcmp(name,QVideoEncoderControl_iid) == 0) |
235 if (qstrcmp(name,QVideoEncoderControl_iid) == 0) |
226 return m_captureSession->videoEncodeControl(); |
236 return m_captureSession->videoEncodeControl(); |
227 |
237 |
228 if (qstrcmp(name,QImageEncoderControl_iid) == 0) |
|
229 return m_captureSession->imageEncodeControl(); |
|
230 |
|
231 |
|
232 if (qstrcmp(name,QMediaContainerControl_iid) == 0) |
238 if (qstrcmp(name,QMediaContainerControl_iid) == 0) |
233 return m_captureSession->mediaContainerControl(); |
239 return m_captureSession->mediaContainerControl(); |
234 |
240 |
235 if (qstrcmp(name,QCameraControl_iid) == 0) |
|
236 return m_cameraControl; |
|
237 |
|
238 if (qstrcmp(name,QMetaDataControl_iid) == 0) |
241 if (qstrcmp(name,QMetaDataControl_iid) == 0) |
239 return m_metaDataControl; |
242 return m_metaDataControl; |
240 |
|
241 if (qstrcmp(name, QImageCaptureControl_iid) == 0) |
|
242 return m_imageCaptureControl; |
|
243 |
243 |
244 return 0; |
244 return 0; |
245 } |
245 } |
246 |
246 |
247 void QGstreamerCaptureService::videoOutputChanged(QVideoOutputControl::Output output) |
247 void QGstreamerCaptureService::videoOutputChanged(QVideoOutputControl::Output output) |