AVFoundation: Enable use of QMediaPlayer for audio on iOS
This commit disables the video components of the AVFoundation mediaplayer backend when building for iOS and enables the use of QMediaPlayer with audio assets. Change-Id: Iadd6f9c61ed1e656301326e90a22cbca6428b654 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
d3531cb0cc
commit
17a700292a
@@ -63,9 +63,6 @@ ANDROID_BUNDLED_FILES += \
|
|||||||
MODULE_PLUGIN_TYPES = \
|
MODULE_PLUGIN_TYPES = \
|
||||||
mediaservice
|
mediaservice
|
||||||
|
|
||||||
mac {
|
|
||||||
LIBS += -framework AppKit -framework QuartzCore -framework QTKit
|
|
||||||
}
|
|
||||||
win32:LIBS += -luuid
|
win32:LIBS += -luuid
|
||||||
|
|
||||||
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
|
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += camera \
|
!ios: SUBDIRS += camera
|
||||||
mediaplayer
|
|
||||||
|
SUBDIRS += mediaplayer
|
||||||
|
|||||||
@@ -43,11 +43,13 @@
|
|||||||
#include "avfmediaplayersession.h"
|
#include "avfmediaplayersession.h"
|
||||||
#include "avfmediaplayercontrol.h"
|
#include "avfmediaplayercontrol.h"
|
||||||
#include "avfmediaplayermetadatacontrol.h"
|
#include "avfmediaplayermetadatacontrol.h"
|
||||||
#include "avfvideooutput.h"
|
#if defined(Q_OS_OSX)
|
||||||
#include "avfvideorenderercontrol.h"
|
# include "avfvideooutput.h"
|
||||||
|
# include "avfvideorenderercontrol.h"
|
||||||
|
|
||||||
#ifndef QT_NO_WIDGETS
|
# ifndef QT_NO_WIDGETS
|
||||||
#include "avfvideowidgetcontrol.h"
|
# include "avfvideowidgetcontrol.h"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
@@ -83,7 +85,7 @@ QMediaControl *AVFMediaPlayerService::requestControl(const char *name)
|
|||||||
|
|
||||||
if (qstrcmp(name, QMetaDataReaderControl_iid) == 0)
|
if (qstrcmp(name, QMetaDataReaderControl_iid) == 0)
|
||||||
return m_playerMetaDataControl;
|
return m_playerMetaDataControl;
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
|
if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
|
||||||
if (!m_videoOutput)
|
if (!m_videoOutput)
|
||||||
m_videoOutput = new AVFVideoRendererControl(this);
|
m_videoOutput = new AVFVideoRendererControl(this);
|
||||||
@@ -91,7 +93,7 @@ QMediaControl *AVFMediaPlayerService::requestControl(const char *name)
|
|||||||
m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
|
m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
|
||||||
return m_videoOutput;
|
return m_videoOutput;
|
||||||
}
|
}
|
||||||
#ifndef QT_NO_WIDGETS
|
# ifndef QT_NO_WIDGETS
|
||||||
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
||||||
if (!m_videoOutput)
|
if (!m_videoOutput)
|
||||||
m_videoOutput = new AVFVideoWidgetControl(this);
|
m_videoOutput = new AVFVideoWidgetControl(this);
|
||||||
@@ -99,8 +101,8 @@ QMediaControl *AVFMediaPlayerService::requestControl(const char *name)
|
|||||||
m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
|
m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
|
||||||
return m_videoOutput;
|
return m_videoOutput;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +111,7 @@ void AVFMediaPlayerService::releaseControl(QMediaControl *control)
|
|||||||
#ifdef QT_DEBUG_AVF
|
#ifdef QT_DEBUG_AVF
|
||||||
qDebug() << Q_FUNC_INFO << control;
|
qDebug() << Q_FUNC_INFO << control;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
if (m_videoOutput == control) {
|
if (m_videoOutput == control) {
|
||||||
AVFVideoRendererControl *renderControl = qobject_cast<AVFVideoRendererControl*>(m_videoOutput);
|
AVFVideoRendererControl *renderControl = qobject_cast<AVFVideoRendererControl*>(m_videoOutput);
|
||||||
if (renderControl)
|
if (renderControl)
|
||||||
@@ -118,4 +120,5 @@ void AVFMediaPlayerService::releaseControl(QMediaControl *control)
|
|||||||
m_session->setVideoOutput(0);
|
m_session->setVideoOutput(0);
|
||||||
delete control;
|
delete control;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,9 +240,11 @@ static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMe
|
|||||||
m_player = [AVPlayer playerWithPlayerItem:m_playerItem];
|
m_player = [AVPlayer playerWithPlayerItem:m_playerItem];
|
||||||
[m_player retain];
|
[m_player retain];
|
||||||
|
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
//Set the initial volume on new player object
|
//Set the initial volume on new player object
|
||||||
if (self.session)
|
if (self.session)
|
||||||
m_player.volume = m_session->volume() / 100.0f;
|
m_player.volume = m_session->volume() / 100.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
//Create a new player layer if we don't have one already
|
//Create a new player layer if we don't have one already
|
||||||
if (!m_playerLayer)
|
if (!m_playerLayer)
|
||||||
@@ -735,10 +737,12 @@ void AVFMediaPlayerSession::setVolume(int volume)
|
|||||||
|
|
||||||
m_volume = volume;
|
m_volume = volume;
|
||||||
|
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
AVPlayer *player = [(AVFMediaPlayerSessionObserver*)m_observer player];
|
AVPlayer *player = [(AVFMediaPlayerSessionObserver*)m_observer player];
|
||||||
if (player) {
|
if (player) {
|
||||||
[[(AVFMediaPlayerSessionObserver*)m_observer player] setVolume:m_volume / 100.0f];
|
[[(AVFMediaPlayerSessionObserver*)m_observer player] setVolume:m_volume / 100.0f];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_EMIT volumeChanged(m_volume);
|
Q_EMIT volumeChanged(m_volume);
|
||||||
}
|
}
|
||||||
@@ -752,9 +756,9 @@ void AVFMediaPlayerSession::setMuted(bool muted)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_muted = muted;
|
m_muted = muted;
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
[[(AVFMediaPlayerSessionObserver*)m_observer player] setMuted:m_muted];
|
[[(AVFMediaPlayerSessionObserver*)m_observer player] setMuted:m_muted];
|
||||||
|
#endif
|
||||||
Q_EMIT mutedChanged(muted);
|
Q_EMIT mutedChanged(muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,32 +20,39 @@ HEADERS += \
|
|||||||
avfmediaplayermetadatacontrol.h \
|
avfmediaplayermetadatacontrol.h \
|
||||||
avfmediaplayerservice.h \
|
avfmediaplayerservice.h \
|
||||||
avfmediaplayersession.h \
|
avfmediaplayersession.h \
|
||||||
avfmediaplayerserviceplugin.h \
|
avfmediaplayerserviceplugin.h
|
||||||
avfvideorenderercontrol.h \
|
|
||||||
avfdisplaylink.h \
|
|
||||||
avfvideoframerenderer.h \
|
|
||||||
avfvideooutput.h
|
|
||||||
|
|
||||||
OBJECTIVE_SOURCES += \
|
OBJECTIVE_SOURCES += \
|
||||||
avfmediaplayercontrol.mm \
|
avfmediaplayercontrol.mm \
|
||||||
avfmediaplayermetadatacontrol.mm \
|
avfmediaplayermetadatacontrol.mm \
|
||||||
avfmediaplayerservice.mm \
|
avfmediaplayerservice.mm \
|
||||||
avfmediaplayerserviceplugin.mm \
|
avfmediaplayerserviceplugin.mm \
|
||||||
avfmediaplayersession.mm \
|
avfmediaplayersession.mm
|
||||||
avfvideorenderercontrol.mm \
|
|
||||||
avfdisplaylink.mm \
|
|
||||||
avfvideoframerenderer.mm \
|
|
||||||
avfvideooutput.mm
|
|
||||||
|
|
||||||
qtHaveModule(widgets) {
|
!ios {
|
||||||
QT += multimediawidgets-private opengl
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
avfvideowidgetcontrol.h \
|
avfvideorenderercontrol.h \
|
||||||
avfvideowidget.h
|
avfdisplaylink.h \
|
||||||
|
avfvideoframerenderer.h \
|
||||||
|
avfvideooutput.h
|
||||||
OBJECTIVE_SOURCES += \
|
OBJECTIVE_SOURCES += \
|
||||||
avfvideowidgetcontrol.mm \
|
avfvideorenderercontrol.mm \
|
||||||
avfvideowidget.mm
|
avfdisplaylink.mm \
|
||||||
|
avfvideoframerenderer.mm \
|
||||||
|
avfvideooutput.mm
|
||||||
|
|
||||||
|
LIBS += -framework QuartzCore -framework AppKit
|
||||||
|
|
||||||
|
qtHaveModule(widgets) {
|
||||||
|
QT += multimediawidgets-private opengl
|
||||||
|
HEADERS += \
|
||||||
|
avfvideowidgetcontrol.h \
|
||||||
|
avfvideowidget.h
|
||||||
|
|
||||||
|
OBJECTIVE_SOURCES += \
|
||||||
|
avfvideowidgetcontrol.mm \
|
||||||
|
avfvideowidget.mm
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
|
|||||||
@@ -47,10 +47,9 @@ unix:!mac {
|
|||||||
mac:!simulator {
|
mac:!simulator {
|
||||||
SUBDIRS += audiocapture
|
SUBDIRS += audiocapture
|
||||||
|
|
||||||
!ios {
|
config_avfoundation: SUBDIRS += avfoundation
|
||||||
SUBDIRS += qt7
|
|
||||||
config_avfoundation: SUBDIRS += avfoundation
|
!ios: SUBDIRS += qt7
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config_opensles {
|
config_opensles {
|
||||||
|
|||||||
Reference in New Issue
Block a user