qtmobility/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QGSTREAMERPLAYERSESSION_H
       
    43 #define QGSTREAMERPLAYERSESSION_H
       
    44 
       
    45 #include <QObject>
       
    46 #include <QUrl>
       
    47 #include "qgstreamerplayercontrol.h"
       
    48 #include "qgstreamerbushelper.h"
       
    49 #include <qmediaplayer.h>
       
    50 #include <qmediastreamscontrol.h>
       
    51 
       
    52 #include <gst/gst.h>
       
    53 
       
    54 class QGstreamerBusHelper;
       
    55 class QGstreamerMessage;
       
    56 
       
    57 class QGstreamerVideoRendererInterface;
       
    58 
       
    59 QTM_USE_NAMESPACE
       
    60 
       
    61 class QGstreamerPlayerSession : public QObject, public QGstreamerSyncEventFilter
       
    62 {
       
    63 Q_OBJECT
       
    64 
       
    65 public:
       
    66     QGstreamerPlayerSession(QObject *parent);
       
    67     virtual ~QGstreamerPlayerSession();
       
    68 
       
    69     QUrl url() const;
       
    70 
       
    71     QMediaPlayer::State state() const { return m_state; }
       
    72     QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
       
    73 
       
    74     qint64 duration() const;
       
    75     qint64 position() const;
       
    76 
       
    77     bool isBuffering() const;
       
    78 
       
    79     int bufferingProgress() const;
       
    80 
       
    81     int volume() const;
       
    82     bool isMuted() const;
       
    83 
       
    84     bool isAudioAvailable() const;
       
    85 
       
    86     void setVideoRenderer(QObject *renderer);
       
    87     bool isVideoAvailable() const;
       
    88 
       
    89     bool isSeekable() const;
       
    90 
       
    91     qreal playbackRate() const;
       
    92     void setPlaybackRate(qreal rate);
       
    93 
       
    94     QMap<QByteArray ,QVariant> tags() const { return m_tags; }
       
    95     QMap<QtMedia::MetaData,QVariant> streamProperties(int streamNumber) const { return m_streamProperties[streamNumber]; }
       
    96     int streamCount() const { return m_streamProperties.count(); }
       
    97     QMediaStreamsControl::StreamType streamType(int streamNumber) { return m_streamTypes.value(streamNumber, QMediaStreamsControl::UnknownStream); }
       
    98 
       
    99     int activeStream(QMediaStreamsControl::StreamType streamType) const;
       
   100     void setActiveStream(QMediaStreamsControl::StreamType streamType, int streamNumber);
       
   101 
       
   102     bool processSyncMessage(const QGstreamerMessage &message);
       
   103 
       
   104 public slots:
       
   105     void load(const QUrl &url);
       
   106 
       
   107     void play();
       
   108     void pause();
       
   109     void stop();
       
   110 
       
   111     void seek(qint64 pos);
       
   112 
       
   113     void setVolume(int volume);
       
   114     void setMuted(bool muted);
       
   115 
       
   116 signals:
       
   117     void durationChanged(qint64 duration);
       
   118     void positionChanged(qint64 position);
       
   119     void stateChanged(QMediaPlayer::State state);
       
   120     void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus);
       
   121     void volumeChanged(int volume);
       
   122     void mutedStateChanged(bool muted);
       
   123     void audioAvailableChanged(bool audioAvailable);
       
   124     void videoAvailableChanged(bool videoAvailable);
       
   125     void bufferingChanged(bool buffering);
       
   126     void bufferingProgressChanged(int percentFilled);
       
   127     void playbackFinished();
       
   128     void tagsChanged();
       
   129     void streamsChanged();
       
   130     void seekableChanged(bool);
       
   131 
       
   132 private slots:
       
   133     void busMessage(const QGstreamerMessage &message);
       
   134     void getStreamsInfo();
       
   135     void setSeekable(bool);
       
   136 
       
   137 private:
       
   138     void setMediaStatus(QMediaPlayer::MediaStatus);
       
   139 
       
   140     QUrl m_url;
       
   141     QMediaPlayer::State m_state;
       
   142     QMediaPlayer::MediaStatus m_mediaStatus;
       
   143     QGstreamerBusHelper* m_busHelper;
       
   144     GstElement* m_playbin;
       
   145     GstElement* m_nullVideoOutput;
       
   146     GstBus* m_bus;
       
   147     QGstreamerVideoRendererInterface *m_renderer;
       
   148 
       
   149     QMap<QByteArray, QVariant> m_tags;
       
   150     QList< QMap<QtMedia::MetaData,QVariant> > m_streamProperties;
       
   151     QList<QMediaStreamsControl::StreamType> m_streamTypes;
       
   152     QMap<QMediaStreamsControl::StreamType, int> m_playbin2StreamOffset;
       
   153 
       
   154 
       
   155     int m_volume;
       
   156     qreal m_playbackRate;
       
   157     bool m_muted;
       
   158     bool m_audioAvailable;
       
   159     bool m_videoAvailable;
       
   160     bool m_seekable;
       
   161 
       
   162     qint64 m_lastPosition;
       
   163     qint64 m_duration;
       
   164 };
       
   165 
       
   166 #endif // QGSTREAMERPLAYERSESSION_H