diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-01-28 07:28:36 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2010-01-28 07:28:36 (GMT) |
commit | b220901d125b6c440426577b10d5c7463bf49964 (patch) | |
tree | 18544fc56ac59c7021ddd3a9dff8f9301d8eba63 | |
parent | 1e7dc2be019a5cb278d5ca72702dfbac846bf3e7 (diff) | |
download | Qt-b220901d125b6c440426577b10d5c7463bf49964.zip Qt-b220901d125b6c440426577b10d5c7463bf49964.tar.gz Qt-b220901d125b6c440426577b10d5c7463bf49964.tar.bz2 |
Add an audioAvailable property to QMediaPlayer.
from: Andrew den Exter committed 00373999 to qtmobility/qtm-multimedia
12 files changed, 92 insertions, 1 deletions
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index 878af0a..0853597 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -282,6 +282,7 @@ QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags, QMediaSer connect(d->control, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); connect(d->control, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged(qint64))); + connect(d->control, SIGNAL(audioAvailableChanged(bool)), SIGNAL(audioAvailableChanged(bool))); connect(d->control, SIGNAL(videoAvailableChanged(bool)), SIGNAL(videoAvailableChanged(bool))); connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); @@ -402,6 +403,16 @@ int QMediaPlayer::bufferStatus() const return 0; } +bool QMediaPlayer::isAudioAvailable() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->isAudioAvailable(); + + return false; +} + bool QMediaPlayer::isVideoAvailable() const { Q_D(const QMediaPlayer); @@ -841,6 +852,15 @@ QStringList QMediaPlayer::supportedMimeTypes(Flags flags) */ /*! + \property QMediaPlayer::audioAvailable + \brief the audio availabilty status for the current media. + + As the life time of QMediaPlayer can be longer than the playback of one + QMediaContent, this property may change over time, the + audioAvailableChanged signal can be used to monitor it's status. +*/ + +/*! \property QMediaPlayer::videoAvailable \brief the video availability status for the current media. @@ -902,6 +922,12 @@ QStringList QMediaPlayer::supportedMimeTypes(Flags flags) */ /*! + \fn void QMediaPlayer::audioAvailableChanged(bool available) + + Signals the availability of audio content has changed to \a available. +*/ + +/*! \fn void QMediaPlayer::videoAvailableChanged(bool videoAvailable) Signal the availability of visual content has changed to \a videoAvailable. diff --git a/src/multimedia/playback/qmediaplayer.h b/src/multimedia/playback/qmediaplayer.h index 4de2b5e..dc9d4f0 100644 --- a/src/multimedia/playback/qmediaplayer.h +++ b/src/multimedia/playback/qmediaplayer.h @@ -66,6 +66,7 @@ class Q_MULTIMEDIA_EXPORT QMediaPlayer : public QMediaObject Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) Q_PROPERTY(int bufferStatus READ bufferStatus NOTIFY bufferStatusChanged) + Q_PROPERTY(bool audioAvailable READ isAudioAvailable NOTIFY audioAvailableChanged) Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged) Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) @@ -131,6 +132,7 @@ public: int volume() const; bool isMuted() const; + bool isAudioAvailable() const; bool isVideoAvailable() const; int bufferStatus() const; @@ -165,6 +167,7 @@ Q_SIGNALS: void volumeChanged(int volume); void mutedChanged(bool muted); + void audioAvailableChanged(bool audioAvailable); void videoAvailableChanged(bool videoAvailable); void bufferStatusChanged(int percentFilled); diff --git a/src/multimedia/playback/qmediaplayercontrol.cpp b/src/multimedia/playback/qmediaplayercontrol.cpp index 90e3a8c..95ffade 100644 --- a/src/multimedia/playback/qmediaplayercontrol.cpp +++ b/src/multimedia/playback/qmediaplayercontrol.cpp @@ -220,6 +220,22 @@ QMediaPlayerControl::QMediaPlayerControl(QObject *parent): */ /*! + \fn QMediaPlayerControl::isAudioAvailable() const + + Identifies if there is audio output available for the current media. + + Returns true if audio output is available and false otherwise. +*/ + +/*! + \fn QMediaPlayerControl::audioAvailableChanged(bool audio) + + Signals that there has been a change in the availability of \a audio output. + + \sa isAudioAvailable() +*/ + +/*! \fn QMediaPlayerControl::isVideoAvailable() const Identifies if there is video output available for the current media. diff --git a/src/multimedia/playback/qmediaplayercontrol.h b/src/multimedia/playback/qmediaplayercontrol.h index ac3fc45..a7e418b 100644 --- a/src/multimedia/playback/qmediaplayercontrol.h +++ b/src/multimedia/playback/qmediaplayercontrol.h @@ -82,6 +82,7 @@ public: virtual int bufferStatus() const = 0; + virtual bool isAudioAvailable() const = 0; virtual bool isVideoAvailable() const = 0; virtual bool isSeekable() const = 0; @@ -107,6 +108,7 @@ Q_SIGNALS: void mediaStatusChanged(QMediaPlayer::MediaStatus status); void volumeChanged(int volume); void mutedChanged(bool muted); + void audioAvailableChanged(bool audioAvailable); void videoAvailableChanged(bool videoAvailable); void bufferStatusChanged(int percentFilled); void seekableChanged(bool); diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index 7dd8375..f008e81 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -80,6 +80,8 @@ QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *sessio this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); connect(m_session,SIGNAL(bufferingProgressChanged(int)), this, SIGNAL(bufferStatusChanged(int))); + connect(m_session, SIGNAL(audioAvailableChanged(bool)), + this, SIGNAL(audioAvailableChanged(bool))); connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool))); connect(m_session, SIGNAL(seekableChanged(bool)), @@ -236,6 +238,11 @@ void QGstreamerPlayerControl::setVideoOutput(QObject *output) m_session->setVideoRenderer(output); } +bool QGstreamerPlayerControl::isAudioAvailable() const +{ + return m_session->isAudioAvailable(); +} + bool QGstreamerPlayerControl::isVideoAvailable() const { return m_session->isVideoAvailable(); diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h index 7fb2349..ae0f8b6 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h @@ -79,6 +79,7 @@ public: int volume() const; bool isMuted() const; + bool isAudioAvailable() const; bool isVideoAvailable() const; void setVideoOutput(QObject *output); diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp index 93d97cf..93151e1 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp @@ -63,6 +63,7 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent) m_volume(100), m_playbackRate(1.0), m_muted(false), + m_audioAvailable(false), m_videoAvailable(false), m_seekable(false), m_lastPosition(0), @@ -231,6 +232,11 @@ bool QGstreamerPlayerSession::isMuted() const return m_muted; } +bool QGstreamerPlayerSession::isAudioAvailable() const +{ + return m_audioAvailable; +} + void QGstreamerPlayerSession::setVideoRenderer(QObject *videoOutput) { m_renderer = qobject_cast<QGstreamerVideoRendererInterface*>(videoOutput); @@ -565,6 +571,7 @@ void QGstreamerPlayerSession::getStreamsInfo() } //check if video is available: + bool haveAudio = false; bool haveVideo = false; // m_streamProperties.clear(); // m_streamTypes.clear(); @@ -578,6 +585,9 @@ void QGstreamerPlayerSession::getStreamsInfo() g_object_get(G_OBJECT(m_playbin), "n-video", &videoStreamsCount, NULL); g_object_get(G_OBJECT(m_playbin), "n-text", &textStreamsCount, NULL); + haveAudio = audioStreamsCount > 0; + haveVideo = videoStreamsCount > 0; + m_playbin2StreamOffset[QMediaStreamsControl::AudioStream] = 0; m_playbin2StreamOffset[QMediaStreamsControl::VideoStream] = audioStreamsCount; m_playbin2StreamOffset[QMediaStreamsControl::SubPictureStream] = audioStreamsCount+videoStreamsCount; @@ -648,6 +658,8 @@ void QGstreamerPlayerSession::getStreamsInfo() if (type == GST_STREAM_TYPE_VIDEO) haveVideo = true; + else if (type == GST_STREAM_TYPE_AUDIO) + hasAudio = true; // QMediaStreamsControl::StreamType streamType = QMediaStreamsControl::UnknownStream; // @@ -674,6 +686,10 @@ void QGstreamerPlayerSession::getStreamsInfo() } #endif + if (haveAudio != m_audioAvailable) { + m_audioAvailable = haveAudio; + emit audioAvailableChanged(m_audioAvailable); + } if (haveVideo != m_videoAvailable) { m_videoAvailable = haveVideo; emit videoAvailableChanged(m_videoAvailable); diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h index f855727..0da5f8f 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h @@ -84,6 +84,7 @@ public: bool isMuted() const; void setVideoRenderer(QObject *renderer); + bool isAudioAvailable() const; bool isVideoAvailable() const; bool isSeekable() const; @@ -120,6 +121,7 @@ signals: void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus); void volumeChanged(int volume); void mutedStateChanged(bool muted); + void audioAvailalbeChanged(bool audioAvailable); void videoAvailableChanged(bool videoAvailable); void bufferingChanged(bool buffering); void bufferingProgressChanged(int percentFilled); @@ -154,6 +156,7 @@ private: int m_volume; qreal m_playbackRate; bool m_muted; + bool m_audioAvailable; bool m_videoAvailable; bool m_seekable; diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h index da86949..907d13d 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h @@ -82,13 +82,13 @@ public: int volume() const; bool isMuted() const; + bool isAudioAvailable() const; bool isVideoAvailable() const; bool isSeekable() const; QMediaTimeRange availablePlaybackRanges() const; - qreal playbackRate() const; void setPlaybackRate(qreal rate); diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm index b74f434..0f4ac41 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm @@ -71,6 +71,7 @@ void QT7PlayerControl::setSession(QT7PlayerSession *session) this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int))); connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); + connect(m_session, SIGNAL(audioAvailableChanged(bool)), this, SIGNAL(audioAvailableChanged(bool))); connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool))); connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); } @@ -177,6 +178,10 @@ void QT7PlayerControl::setMedia(const QMediaContent &content, QIODevice *stream) emit mediaChanged(content); } +bool QT7PlayerControl::isAudioAvailable() const +{ + return m_session->isAudioAvailable(); +} bool QT7PlayerControl::isVideoAvailable() const { diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h index 55505ee..2a6bab7 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h @@ -87,6 +87,7 @@ public: int volume() const; bool isMuted() const; + bool isAudioAvailable() const; bool isVideoAvailable() const; bool isSeekable() const; @@ -112,6 +113,7 @@ signals: void mediaStatusChanged(QMediaPlayer::MediaStatus status); void volumeChanged(int volume); void mutedChanged(bool muted); + void audioAvailableChanged(bool audioAvailable); void videoAvailableChanged(bool videoAvailable); void error(int error, const QString &errorString); diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm index 3131a90..d9bb646 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm @@ -373,6 +373,7 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) } emit durationChanged(duration()); + emit audioAvailableChanged(isAudioAvailable()); emit videoAvailableChanged(isVideoAvailable()); [(QTMovie*)m_QTMovie setMuted:m_muted]; @@ -380,6 +381,15 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) } } +bool QT7PlayerSession::isAudioAvailable() const +{ + if (!m_QTMovie) + return false; + + AutoReleasePool pool; + return [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieHasAudioAttribute"] boolValue] == YES; +} + bool QT7PlayerSession::isVideoAvailable() const { if (!m_QTMovie) |