qtmobility/plugins/multimedia/gstreamer/mediacapture/qgstreamercaptureservice.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 11 06b8e2af4411
--- a/qtmobility/plugins/multimedia/gstreamer/mediacapture/qgstreamercaptureservice.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/plugins/multimedia/gstreamer/mediacapture/qgstreamercaptureservice.cpp	Mon May 03 13:18:40 2010 +0300
@@ -45,15 +45,13 @@
 #include "qgstreamermediacontainercontrol.h"
 #include "qgstreameraudioencode.h"
 #include "qgstreamervideoencode.h"
-#include "qgstreamerimageencode.h"
 #include "qgstreamerbushelper.h"
-#include "qgstreamercameracontrol.h"
+#include "qgstreamerv4l2input.h"
 #include "qgstreamercapturemetadatacontrol.h"
 
 #include "qgstreamervideooutputcontrol.h"
 #include "qgstreameraudioinputendpointselector.h"
 #include "qgstreamervideoinputdevicecontrol.h"
-#include "qgstreamerimagecapturecontrol.h"
 
 #include "qgstreamervideooverlay.h"
 #include "qgstreamervideorenderer.h"
@@ -62,6 +60,8 @@
 
 #include <qmediaserviceprovider.h>
 
+#include <QtCore/qdebug.h>
+
 
 class QGstreamerVideoRendererWrapper : public QGstreamerElementFactory
 {
@@ -82,6 +82,9 @@
 
     GstElement *buildElement()
     {
+#ifdef Q_WS_MAEMO_5
+        return m_element = m_videoRenderer->videoSink();
+#endif
         if (m_bin == NULL) {
             GstBin * bin = GST_BIN(gst_bin_new(NULL));
 
@@ -130,9 +133,9 @@
     }
 
     m_captureSession = 0;
-    m_cameraControl = 0;
     m_metaDataControl = 0;
 
+    m_videoInput = 0;
     m_audioInputEndpointSelector = 0;
     m_videoInputDevice = 0;
 
@@ -143,25 +146,24 @@
     m_videoWindowFactory = 0;
     m_videoWidgetControl = 0;
     m_videoWidgetFactory = 0;
-    m_imageCaptureControl = 0;
-
 
     if (service == Q_MEDIASERVICE_AUDIOSOURCE) {
         m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::Audio, this);
     }
 
-   if (service == Q_MEDIASERVICE_CAMERA) {
-        m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::AudioAndVideo, this);
-        m_cameraControl = new QGstreamerCameraControl(m_captureSession);
-        m_captureSession->setVideoInput(m_cameraControl);
-        m_videoInputDevice = new QGstreamerVideoInputDeviceControl(m_captureSession);
-        m_imageCaptureControl = new QGstreamerImageCaptureControl(m_captureSession);
+    bool captureVideo = false;
+
+    if (captureVideo) {
+        m_captureSession = new QGstreamerCaptureSession(QGstreamerCaptureSession::AudioAndVideo, this);        
+        m_videoInput = new QGstreamerV4L2Input(this);
+        m_captureSession->setVideoInput(m_videoInput);
+        m_videoInputDevice = new QGstreamerVideoInputDeviceControl(this);
 
         connect(m_videoInputDevice, SIGNAL(selectedDeviceChanged(QString)),
-                m_cameraControl, SLOT(setDevice(QString)));
+                m_videoInput, SLOT(setDevice(QString)));
 
         if (m_videoInputDevice->deviceCount())
-            m_cameraControl->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice()));
+            m_videoInput->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice()));
 
         m_videoOutput = new QGstreamerVideoOutputControl(this);
         connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)),
@@ -181,6 +183,11 @@
                                            << QVideoOutputControl::WidgetOutput);
     }
 
+    if (!m_captureSession) {
+        qWarning() << "Service type is not supported:" << service;
+        return;
+    }
+
     m_audioInputEndpointSelector = new QGstreamerAudioInputEndpointSelector(this);
     connect(m_audioInputEndpointSelector, SIGNAL(activeEndpointChanged(QString)), m_captureSession, SLOT(setCaptureDevice(QString)));
 
@@ -198,6 +205,9 @@
 
 QMediaControl *QGstreamerCaptureService::control(const char *name) const
 {
+    if (!m_captureSession)
+        return 0;
+
     if (qstrcmp(name, QVideoOutputControl_iid) == 0)
         return m_videoOutput;
 
@@ -225,22 +235,12 @@
     if (qstrcmp(name,QVideoEncoderControl_iid) == 0)
         return m_captureSession->videoEncodeControl();
 
-    if (qstrcmp(name,QImageEncoderControl_iid) == 0)
-        return m_captureSession->imageEncodeControl();
-
-
     if (qstrcmp(name,QMediaContainerControl_iid) == 0)
         return m_captureSession->mediaContainerControl();
 
-    if (qstrcmp(name,QCameraControl_iid) == 0)
-        return m_cameraControl;
-
     if (qstrcmp(name,QMetaDataControl_iid) == 0)
         return m_metaDataControl;
 
-    if (qstrcmp(name, QImageCaptureControl_iid) == 0)
-        return m_imageCaptureControl;
-
     return 0;
 }
 
@@ -265,4 +265,3 @@
         break;
     }
 }
-