qtmobility/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayerservice.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    45 
    45 
    46 #include "qgstreamerplayerservice.h"
    46 #include "qgstreamerplayerservice.h"
    47 #include "qgstreamerplayercontrol.h"
    47 #include "qgstreamerplayercontrol.h"
    48 #include "qgstreamerplayersession.h"
    48 #include "qgstreamerplayersession.h"
    49 #include "qgstreamermetadataprovider.h"
    49 #include "qgstreamermetadataprovider.h"
    50 #include "qgstreamervideooutputcontrol.h"
       
    51 
    50 
    52 #include "qgstreamervideooverlay.h"
    51 #include "qgstreamervideooverlay.h"
    53 #include "qgstreamervideorenderer.h"
    52 #include "qgstreamervideorenderer.h"
    54 
    53 
    55 #include "qgstreamervideowidget.h"
    54 #include "qgstreamervideowidget.h"
    57 
    56 
    58 #include <qmediaplaylistnavigator.h>
    57 #include <qmediaplaylistnavigator.h>
    59 #include <qmediaplaylist.h>
    58 #include <qmediaplaylist.h>
    60 
    59 
    61 QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
    60 QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
    62      QMediaService(parent)
    61      QMediaService(parent),
       
    62      m_videoOutput(0),
       
    63      m_videoRenderer(0),
       
    64      m_videoWindow(0),
       
    65      m_videoWidget(0)
    63 {
    66 {
    64     m_session = new QGstreamerPlayerSession(this);
    67     m_session = new QGstreamerPlayerSession(this);
    65     m_control = new QGstreamerPlayerControl(m_session, this);
    68     m_control = new QGstreamerPlayerControl(m_session, this);
    66     m_metaData = new QGstreamerMetaDataProvider(m_session, this);
    69     m_metaData = new QGstreamerMetaDataProvider(m_session, this);
    67     m_videoOutput = new QGstreamerVideoOutputControl(this);
       
    68     m_streamsControl = new QGstreamerStreamsControl(m_session,this);
    70     m_streamsControl = new QGstreamerStreamsControl(m_session,this);
    69 
    71 
    70     connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)),
       
    71             this, SLOT(videoOutputChanged(QVideoOutputControl::Output)));
       
    72     m_videoRenderer = new QGstreamerVideoRenderer(this);
    72     m_videoRenderer = new QGstreamerVideoRenderer(this);
       
    73 #if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
    73     m_videoWindow = new QGstreamerVideoOverlay(this);
    74     m_videoWindow = new QGstreamerVideoOverlay(this);
    74     m_videoWidget = new QGstreamerVideoWidgetControl(this);
    75     m_videoWidget = new QGstreamerVideoWidgetControl(this);
    75 
    76 #endif
    76     m_videoOutput->setAvailableOutputs(QList<QVideoOutputControl::Output>()
       
    77             << QVideoOutputControl::RendererOutput
       
    78             << QVideoOutputControl::WindowOutput
       
    79             << QVideoOutputControl::WidgetOutput);
       
    80 }
    77 }
    81 
    78 
    82 QGstreamerPlayerService::~QGstreamerPlayerService()
    79 QGstreamerPlayerService::~QGstreamerPlayerService()
    83 {
    80 {
    84 }
    81 }
    85 
    82 
    86 QMediaControl *QGstreamerPlayerService::control(const char *name) const
    83 QMediaControl *QGstreamerPlayerService::requestControl(const char *name)
    87 {
    84 {
    88     if (qstrcmp(name,QMediaPlayerControl_iid) == 0)
    85     if (qstrcmp(name,QMediaPlayerControl_iid) == 0)
    89         return m_control;
    86         return m_control;
    90 
    87 
    91     if (qstrcmp(name,QMetaDataControl_iid) == 0)
    88     if (qstrcmp(name,QMetaDataReaderControl_iid) == 0)
    92         return m_metaData;
    89         return m_metaData;
    93 
    90 
    94     if (qstrcmp(name,QMediaStreamsControl_iid) == 0)
    91     if (qstrcmp(name,QMediaStreamsControl_iid) == 0)
    95         return m_streamsControl;
    92         return m_streamsControl;
    96 
    93 
    97     if (qstrcmp(name, QVideoOutputControl_iid) == 0)
    94     if (!m_videoOutput) {
    98         return m_videoOutput;
    95         if (qstrcmp(name, QVideoWidgetControl_iid) == 0)
       
    96             m_videoOutput = m_videoWidget;
       
    97         else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
       
    98             m_videoOutput = m_videoRenderer;
       
    99         else  if (qstrcmp(name, QVideoWindowControl_iid) == 0)
       
   100             m_videoOutput = m_videoWindow;
    99 
   101 
   100     if (qstrcmp(name, QVideoWidgetControl_iid) == 0)
   102         if (m_videoOutput) {
   101         return m_videoWidget;
   103             m_control->setVideoOutput(m_videoOutput);
   102 
   104             return m_videoOutput;
   103     if (qstrcmp(name, QVideoRendererControl_iid) == 0)
   105         }
   104         return m_videoRenderer;
   106     }
   105 
       
   106     if (qstrcmp(name, QVideoWindowControl_iid) == 0)
       
   107         return m_videoWindow;
       
   108 
   107 
   109     return 0;
   108     return 0;
   110 }
   109 }
   111 
   110 
   112 void QGstreamerPlayerService::videoOutputChanged(QVideoOutputControl::Output output)
   111 void QGstreamerPlayerService::releaseControl(QMediaControl *control)
   113 {
   112 {
   114     switch (output) {
   113     if (control == m_videoOutput) {
   115     case QVideoOutputControl::NoOutput:
   114         m_videoOutput = 0;
   116         m_control->setVideoOutput(0);
   115         m_control->setVideoOutput(0);
   117         break;
       
   118     case QVideoOutputControl::RendererOutput:
       
   119         m_control->setVideoOutput(m_videoRenderer);
       
   120         break;
       
   121     case QVideoOutputControl::WindowOutput:
       
   122         m_control->setVideoOutput(m_videoWindow);
       
   123         break;
       
   124     case QVideoOutputControl::WidgetOutput:
       
   125         m_control->setVideoOutput(m_videoWidget);
       
   126         break;
       
   127     default:
       
   128         qWarning("Invalid video output selection");
       
   129         break;
       
   130     }
   116     }
   131 }
   117 }
   132 
   118