summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2010-01-28 07:28:36 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2010-01-28 07:28:36 (GMT)
commitb220901d125b6c440426577b10d5c7463bf49964 (patch)
tree18544fc56ac59c7021ddd3a9dff8f9301d8eba63 /src/plugins
parent1e7dc2be019a5cb278d5ca72702dfbac846bf3e7 (diff)
downloadQt-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
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp7
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h1
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp16
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h3
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h2
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm5
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h2
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm10
8 files changed, 45 insertions, 1 deletions
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)