summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-06-07 12:06:52 +0200
committerLiang Qi <liang.qi@qt.io>2017-06-07 12:52:58 +0200
commit7fdb88a86b0782e7170eefe3dfe7ab3e9c81f847 (patch)
tree0fb34738dd5b4abd222ffac7b25f904c456006d9 /src/plugins
parentbadecdbc46df6ada383f1dfd006fa3dfff1706c6 (diff)
parenta6cc1af0546ab10701c10475315139ebb50ad1e5 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf Change-Id: I20470ed193e818eefedd975d89f755fb9d673241
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/src/common/qandroidvideooutput.cpp52
-rw-r--r--src/plugins/android/src/common/qandroidvideooutput.h2
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcamerasession.cpp2
-rw-r--r--src/plugins/android/src/wrappers/jni/androidcamera.cpp14
-rw-r--r--src/plugins/android/src/wrappers/jni/androidcamera.h1
-rw-r--r--src/plugins/avfoundation/camera/avfmediarecordercontrol.mm10
-rw-r--r--src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm8
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm5
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h4
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm133
-rw-r--r--src/plugins/common/evr/evrcustompresenter.cpp4
-rw-r--r--src/plugins/common/evr/evrcustompresenter.h8
-rw-r--r--src/plugins/common/evr/evrd3dpresentengine.cpp4
-rw-r--r--src/plugins/common/evr/evrd3dpresentengine.h10
-rw-r--r--src/plugins/common/evr/evrhelpers.cpp4
-rw-r--r--src/plugins/common/evr/evrhelpers.h4
-rw-r--r--src/plugins/common/evr/evrvideowindowcontrol.h4
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp20
-rw-r--r--src/plugins/directshow/camera/dscamerasession.h2
-rw-r--r--src/plugins/directshow/common/common.pri19
-rw-r--r--src/plugins/directshow/common/directshowbasefilter.cpp (renamed from src/plugins/directshow/helpers/directshowbasefilter.cpp)38
-rw-r--r--src/plugins/directshow/common/directshowbasefilter.h (renamed from src/plugins/directshow/helpers/directshowbasefilter.h)38
-rw-r--r--src/plugins/directshow/common/directshoweventloop.cpp (renamed from src/plugins/directshow/helpers/directshoweventloop.cpp)4
-rw-r--r--src/plugins/directshow/common/directshoweventloop.h (renamed from src/plugins/directshow/helpers/directshoweventloop.h)4
-rw-r--r--src/plugins/directshow/common/directshowglobal.h (renamed from src/plugins/directshow/helpers/directshowglobal.h)0
-rw-r--r--src/plugins/directshow/common/directshowmediatype.cpp (renamed from src/plugins/directshow/helpers/directshowmediatype.cpp)5
-rw-r--r--src/plugins/directshow/common/directshowmediatype.h (renamed from src/plugins/directshow/helpers/directshowmediatype.h)5
-rw-r--r--src/plugins/directshow/common/directshowmediatypeenum.cpp (renamed from src/plugins/directshow/helpers/directshowmediatypeenum.cpp)36
-rw-r--r--src/plugins/directshow/common/directshowmediatypeenum.h80
-rw-r--r--src/plugins/directshow/common/directshowobject.cpp (renamed from src/plugins/directshow/helpers/directshowobject.cpp)3
-rw-r--r--src/plugins/directshow/common/directshowobject.h (renamed from src/plugins/directshow/helpers/directshowobject.h)38
-rw-r--r--src/plugins/directshow/common/directshowpin.cpp (renamed from src/plugins/directshow/helpers/directshowpin.cpp)38
-rw-r--r--src/plugins/directshow/common/directshowpin.h (renamed from src/plugins/directshow/helpers/directshowpin.h)38
-rw-r--r--src/plugins/directshow/common/directshowpinenum.cpp (renamed from src/plugins/directshow/helpers/directshowpinenum.cpp)4
-rw-r--r--src/plugins/directshow/common/directshowpinenum.h (renamed from src/plugins/directshow/helpers/directshowpinenum.h)4
-rw-r--r--src/plugins/directshow/common/directshowutils.cpp (renamed from src/plugins/directshow/helpers/directshowutils.cpp)4
-rw-r--r--src/plugins/directshow/common/directshowutils.h (renamed from src/plugins/directshow/helpers/directshowutils.h)0
-rw-r--r--src/plugins/directshow/common/directshowvideobuffer.cpp (renamed from src/plugins/directshow/helpers/directshowvideobuffer.cpp)4
-rw-r--r--src/plugins/directshow/common/directshowvideobuffer.h (renamed from src/plugins/directshow/helpers/directshowvideobuffer.h)3
-rw-r--r--src/plugins/directshow/directshow.pro1
-rw-r--r--src/plugins/directshow/dsserviceplugin.cpp5
-rw-r--r--src/plugins/directshow/dsserviceplugin.h4
-rw-r--r--src/plugins/directshow/helpers/directshowmediatypeenum.h72
-rw-r--r--src/plugins/directshow/helpers/helpers.pri24
-rw-r--r--src/plugins/directshow/player/directshowaudioendpointcontrol.cpp4
-rw-r--r--src/plugins/directshow/player/directshowaudioendpointcontrol.h6
-rw-r--r--src/plugins/directshow/player/directshowevrvideowindowcontrol.h4
-rw-r--r--src/plugins/directshow/player/directshowioreader.cpp4
-rw-r--r--src/plugins/directshow/player/directshowioreader.h3
-rw-r--r--src/plugins/directshow/player/directshowiosource.cpp4
-rw-r--r--src/plugins/directshow/player/directshowiosource.h4
-rw-r--r--src/plugins/directshow/player/directshowmetadatacontrol.h6
-rw-r--r--src/plugins/directshow/player/directshowplayercontrol.h4
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.cpp344
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.h63
-rw-r--r--src/plugins/directshow/player/directshowvideorenderercontrol.h6
-rw-r--r--src/plugins/directshow/player/player.pri2
-rw-r--r--src/plugins/directshow/player/videosurfacefilter.cpp4
-rw-r--r--src/plugins/directshow/player/videosurfacefilter.h4
-rw-r--r--src/plugins/directshow/player/vmr9videowindowcontrol.h4
60 files changed, 916 insertions, 312 deletions
diff --git a/src/plugins/android/src/common/qandroidvideooutput.cpp b/src/plugins/android/src/common/qandroidvideooutput.cpp
index 1d0df27f2..b425b9d89 100644
--- a/src/plugins/android/src/common/qandroidvideooutput.cpp
+++ b/src/plugins/android/src/common/qandroidvideooutput.cpp
@@ -86,11 +86,12 @@ void OpenGLResourcesDeleter::deleteShaderProgramHelper(void *prog)
class AndroidTextureVideoBuffer : public QAbstractVideoBuffer
{
public:
- AndroidTextureVideoBuffer(QAndroidTextureVideoOutput *output)
+ AndroidTextureVideoBuffer(QAndroidTextureVideoOutput *output, const QSize &size)
: QAbstractVideoBuffer(GLTextureHandle)
+ , m_mapMode(NotMapped)
, m_output(output)
+ , m_size(size)
, m_textureUpdated(false)
- , m_mapMode(NotMapped)
{
}
@@ -100,8 +101,7 @@ public:
uchar *map(MapMode mode, int *numBytes, int *bytesPerLine)
{
- if (m_mapMode == NotMapped && mode == ReadOnly) {
- updateFrame();
+ if (m_mapMode == NotMapped && mode == ReadOnly && updateFrame()) {
m_mapMode = mode;
m_image = m_output->m_fbo->toImage();
@@ -126,24 +126,41 @@ public:
QVariant handle() const
{
AndroidTextureVideoBuffer *that = const_cast<AndroidTextureVideoBuffer*>(this);
- that->updateFrame();
+ if (!that->updateFrame())
+ return QVariant();
+
return m_output->m_fbo->texture();
}
private:
- void updateFrame()
+ bool updateFrame()
{
- if (!m_textureUpdated) {
- // update the video texture (called from the render thread)
- m_output->renderFrameToFbo();
- m_textureUpdated = true;
- }
+ // Even though the texture was updated in a previous call, we need to re-check
+ // that this has not become a stale buffer, e.g., if the output size changed or
+ // has since became invalid.
+ if (!m_output->m_nativeSize.isValid())
+ return false;
+
+ // Size changed
+ if (m_output->m_nativeSize != m_size)
+ return false;
+
+ // In the unlikely event that we don't have a valid fbo, but have a valid size,
+ // force an update.
+ const bool forceUpdate = !m_output->m_fbo;
+
+ if (m_textureUpdated && !forceUpdate)
+ return true;
+
+ // update the video texture (called from the render thread)
+ return (m_textureUpdated = m_output->renderFrameToFbo());
}
- QAndroidTextureVideoOutput *m_output;
- bool m_textureUpdated;
MapMode m_mapMode;
+ QAndroidTextureVideoOutput *m_output;
QImage m_image;
+ QSize m_size;
+ bool m_textureUpdated;
};
QAndroidTextureVideoOutput::QAndroidTextureVideoOutput(QObject *parent)
@@ -267,7 +284,6 @@ AndroidSurfaceTexture *QAndroidTextureVideoOutput::surfaceTexture()
void QAndroidTextureVideoOutput::setVideoSize(const QSize &size)
{
QMutexLocker locker(&m_mutex);
-
if (m_nativeSize == size)
return;
@@ -297,7 +313,7 @@ void QAndroidTextureVideoOutput::onFrameAvailable()
if (!m_nativeSize.isValid() || !m_surface)
return;
- QAbstractVideoBuffer *buffer = new AndroidTextureVideoBuffer(this);
+ QAbstractVideoBuffer *buffer = new AndroidTextureVideoBuffer(this, m_nativeSize);
QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_BGR32);
if (m_surface->isActive() && (m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat()
@@ -316,12 +332,12 @@ void QAndroidTextureVideoOutput::onFrameAvailable()
m_surface->present(frame);
}
-void QAndroidTextureVideoOutput::renderFrameToFbo()
+bool QAndroidTextureVideoOutput::renderFrameToFbo()
{
QMutexLocker locker(&m_mutex);
if (!m_nativeSize.isValid() || !m_surfaceTexture)
- return;
+ return false;
createGLResources();
@@ -376,6 +392,8 @@ void QAndroidTextureVideoOutput::renderFrameToFbo()
glEnable(GL_SCISSOR_TEST);
if (blendEnabled)
glEnable(GL_BLEND);
+
+ return true;
}
void QAndroidTextureVideoOutput::createGLResources()
diff --git a/src/plugins/android/src/common/qandroidvideooutput.h b/src/plugins/android/src/common/qandroidvideooutput.h
index a12db75a2..936e4c40b 100644
--- a/src/plugins/android/src/common/qandroidvideooutput.h
+++ b/src/plugins/android/src/common/qandroidvideooutput.h
@@ -112,7 +112,7 @@ private Q_SLOTS:
private:
bool initSurfaceTexture();
- void renderFrameToFbo();
+ bool renderFrameToFbo();
void createGLResources();
QMutex m_mutex;
diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
index b0dd7d900..a7f0254ee 100644
--- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
@@ -176,7 +176,7 @@ bool QAndroidCameraSession::open()
m_status = QCamera::LoadingStatus;
emit statusChanged(m_status);
- m_camera = AndroidCamera::open(m_selectedCamera);
+ m_camera = AndroidCamera::requestCameraPermission() ? AndroidCamera::open(m_selectedCamera) : nullptr;
if (m_camera) {
connect(m_camera, SIGNAL(pictureExposed()), this, SLOT(onCameraPictureExposed()));
diff --git a/src/plugins/android/src/wrappers/jni/androidcamera.cpp b/src/plugins/android/src/wrappers/jni/androidcamera.cpp
index 0f2a43531..e3afddd59 100644
--- a/src/plugins/android/src/wrappers/jni/androidcamera.cpp
+++ b/src/plugins/android/src/wrappers/jni/androidcamera.cpp
@@ -42,6 +42,7 @@
#include "androidsurfacetexture.h"
#include "androidsurfaceview.h"
#include "qandroidmultimediautils.h"
+#include "qandroidglobal.h"
#include <qstringlist.h>
#include <qdebug.h>
@@ -55,6 +56,11 @@ QT_BEGIN_NAMESPACE
static const char QtCameraListenerClassName[] = "org/qtproject/qt5/android/multimedia/QtCameraListener";
+static QString cameraPermissionKey()
+{
+ return QStringLiteral("android.permission.CAMERA");
+}
+
typedef QHash<int, AndroidCamera *> CameraMap;
Q_GLOBAL_STATIC(CameraMap, cameras)
Q_GLOBAL_STATIC(QReadWriteLock, rwLock)
@@ -756,6 +762,9 @@ QJNIObjectPrivate AndroidCamera::getCameraObject()
int AndroidCamera::getNumberOfCameras()
{
+ if (!requestCameraPermission())
+ return 0;
+
return QJNIObjectPrivate::callStaticMethod<jint>("android/hardware/Camera",
"getNumberOfCameras");
}
@@ -790,6 +799,11 @@ void AndroidCamera::getCameraInfo(int id, AndroidCameraInfo *info)
}
}
+bool AndroidCamera::requestCameraPermission()
+{
+ return qt_androidRequestPermission(cameraPermissionKey());
+}
+
void AndroidCamera::startPreview()
{
Q_D(AndroidCamera);
diff --git a/src/plugins/android/src/wrappers/jni/androidcamera.h b/src/plugins/android/src/wrappers/jni/androidcamera.h
index e58a81f8e..5ae141f01 100644
--- a/src/plugins/android/src/wrappers/jni/androidcamera.h
+++ b/src/plugins/android/src/wrappers/jni/androidcamera.h
@@ -201,6 +201,7 @@ public:
static int getNumberOfCameras();
static void getCameraInfo(int id, AndroidCameraInfo *info);
+ static bool requestCameraPermission();
static bool initJNI(JNIEnv *env);
diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm
index 79bf2e932..02261027d 100644
--- a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm
+++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm
@@ -306,14 +306,16 @@ void AVFMediaRecorderControl::setState(QMediaRecorder::State state)
} break;
case QMediaRecorder::StoppedState:
{
- m_state = QMediaRecorder::StoppedState;
+ m_lastStatus = QMediaRecorder::FinalizingStatus;
+ Q_EMIT statusChanged(m_lastStatus);
[m_movieOutput stopRecording];
unapplySettings();
}
}
updateStatus();
- Q_EMIT stateChanged(m_state);
+ if (state != m_state)
+ Q_EMIT stateChanged(m_state);
}
void AVFMediaRecorderControl::setMuted(bool muted)
@@ -341,6 +343,10 @@ void AVFMediaRecorderControl::handleRecordingStarted()
void AVFMediaRecorderControl::handleRecordingFinished()
{
m_recordingFinished = true;
+ if (m_state != QMediaRecorder::StoppedState) {
+ m_state = QMediaRecorder::StoppedState;
+ Q_EMIT stateChanged(m_state);
+ }
updateStatus();
}
diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm
index 5f604e9a0..d657dc17d 100644
--- a/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm
+++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm
@@ -340,7 +340,7 @@ void AVFMediaRecorderControlIOS::assetWriterFinished()
Q_ASSERT(cameraControl);
const QMediaRecorder::Status lastStatus = m_lastStatus;
-
+ const QMediaRecorder::State lastState = m_state;
if (cameraControl->captureMode() & QCamera::CaptureVideo)
m_lastStatus = QMediaRecorder::LoadedStatus;
else
@@ -350,9 +350,11 @@ void AVFMediaRecorderControlIOS::assetWriterFinished()
m_service->videoOutput()->resetCaptureDelegate();
[m_service->session()->captureSession() startRunning];
-
+ m_state = QMediaRecorder::StoppedState;
if (m_lastStatus != lastStatus)
Q_EMIT statusChanged(m_lastStatus);
+ if (m_state != lastState)
+ Q_EMIT stateChanged(m_state);
}
void AVFMediaRecorderControlIOS::captureModeChanged(QCamera::CaptureModes newMode)
@@ -403,10 +405,8 @@ void AVFMediaRecorderControlIOS::cameraStatusChanged(QCamera::Status newStatus)
void AVFMediaRecorderControlIOS::stopWriter()
{
if (m_lastStatus == QMediaRecorder::RecordingStatus) {
- m_state = QMediaRecorder::StoppedState;
m_lastStatus = QMediaRecorder::FinalizingStatus;
- Q_EMIT stateChanged(m_state);
Q_EMIT statusChanged(m_lastStatus);
[m_writer stop];
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm
index 7f6168dea..5f7bae1c8 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm
@@ -97,9 +97,12 @@ const QIODevice *AVFMediaPlayerControl::mediaStream() const
void AVFMediaPlayerControl::setMedia(const QMediaContent &content, QIODevice *stream)
{
+ const QMediaContent oldContent = m_session->media();
+
m_session->setMedia(content, stream);
- Q_EMIT mediaChanged(content);
+ if (content != oldContent)
+ Q_EMIT mediaChanged(content);
}
qint64 AVFMediaPlayerControl::position() const
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h
index 5696faf15..ef854e23f 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h
@@ -99,10 +99,12 @@ public Q_SLOTS:
void setMuted(bool muted);
void processEOS();
- void processLoadStateChange();
+ void processLoadStateChange(QMediaPlayer::State newState);
void processPositionChange();
void processMediaLoadError();
+ void processLoadStateChange();
+ void processLoadStateFailure();
Q_SIGNALS:
void positionChanged(qint64 position);
void durationChanged(qint64 duration);
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
index e15c2e44a..f4eb8a4ea 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
@@ -324,7 +324,7 @@ static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMe
[self assetFailedToPrepareForPlayback:playerItem.error];
if (self.session)
- QMetaObject::invokeMethod(m_session, "processLoadStateChange", Qt::AutoConnection);
+ QMetaObject::invokeMethod(m_session, "processLoadStateFailure", Qt::AutoConnection);
}
break;
}
@@ -474,27 +474,29 @@ void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *st
if (content.isNull() || content.canonicalUrl().isEmpty()) {
m_mediaStatus = QMediaPlayer::NoMedia;
- m_state = QMediaPlayer::StoppedState;
-
if (m_mediaStatus != oldMediaStatus)
Q_EMIT mediaStatusChanged(m_mediaStatus);
+ m_state = QMediaPlayer::StoppedState;
if (m_state != oldState)
Q_EMIT stateChanged(m_state);
return;
- } else {
-
- m_mediaStatus = QMediaPlayer::LoadingMedia;
- if (m_mediaStatus != oldMediaStatus)
- Q_EMIT mediaStatusChanged(m_mediaStatus);
}
+ m_mediaStatus = QMediaPlayer::LoadingMedia;
+ if (m_mediaStatus != oldMediaStatus)
+ Q_EMIT mediaStatusChanged(m_mediaStatus);
+
//Load AVURLAsset
//initialize asset using content's URL
NSString *urlString = [NSString stringWithUTF8String:content.canonicalUrl().toEncoded().constData()];
NSURL *url = [NSURL URLWithString:urlString];
[(AVFMediaPlayerSessionObserver*)m_observer setURL:url];
+
+ m_state = QMediaPlayer::StoppedState;
+ if (m_state != oldState)
+ Q_EMIT stateChanged(m_state);
}
qint64 AVFMediaPlayerSession::position() const
@@ -639,7 +641,9 @@ void AVFMediaPlayerSession::setPosition(qint64 pos)
m_requestedPosition = pos;
Q_EMIT positionChanged(m_requestedPosition);
return;
- } else if (!isSeekable()) {
+ }
+
+ if (!isSeekable()) {
if (m_requestedPosition != -1) {
m_requestedPosition = -1;
Q_EMIT positionChanged(position());
@@ -655,9 +659,14 @@ void AVFMediaPlayerSession::setPosition(qint64 pos)
newTime.value = (pos / 1000.0f) * newTime.timescale;
[playerItem seekToTime:newTime];
- //reset the EndOfMedia status position is changed after playback is finished
- if (m_mediaStatus == QMediaPlayer::EndOfMedia)
- processLoadStateChange();
+ Q_EMIT positionChanged(pos);
+
+ // Reset media status if the current status is EndOfMedia
+ if (m_mediaStatus == QMediaPlayer::EndOfMedia) {
+ QMediaPlayer::MediaStatus newMediaStatus = (m_state == QMediaPlayer::PausedState) ? QMediaPlayer::BufferedMedia
+ : QMediaPlayer::LoadedMedia;
+ Q_EMIT mediaStatusChanged((m_mediaStatus = newMediaStatus));
+ }
}
void AVFMediaPlayerSession::play()
@@ -666,27 +675,28 @@ void AVFMediaPlayerSession::play()
qDebug() << Q_FUNC_INFO << "currently: " << m_state;
#endif
- if (m_state == QMediaPlayer::PlayingState)
+ if (m_mediaStatus == QMediaPlayer::NoMedia || m_mediaStatus == QMediaPlayer::InvalidMedia)
return;
- m_state = QMediaPlayer::PlayingState;
+ if (m_state == QMediaPlayer::PlayingState)
+ return;
if (m_videoOutput) {
m_videoOutput->setLayer([(AVFMediaPlayerSessionObserver*)m_observer playerLayer]);
}
- //reset the EndOfMedia status if the same file is played again
- if (m_mediaStatus == QMediaPlayer::EndOfMedia) {
+ // Reset media status if the current status is EndOfMedia
+ if (m_mediaStatus == QMediaPlayer::EndOfMedia)
setPosition(0);
- processLoadStateChange();
- }
if (m_mediaStatus == QMediaPlayer::LoadedMedia || m_mediaStatus == QMediaPlayer::BufferedMedia) {
// Setting the rate starts playback
[[(AVFMediaPlayerSessionObserver*)m_observer player] setRate:m_rate];
}
- //processLoadStateChange();
+ m_state = QMediaPlayer::PlayingState;
+ processLoadStateChange();
+
Q_EMIT stateChanged(m_state);
}
@@ -696,6 +706,9 @@ void AVFMediaPlayerSession::pause()
qDebug() << Q_FUNC_INFO << "currently: " << m_state;
#endif
+ if (m_mediaStatus == QMediaPlayer::NoMedia)
+ return;
+
if (m_state == QMediaPlayer::PausedState)
return;
@@ -705,13 +718,13 @@ void AVFMediaPlayerSession::pause()
m_videoOutput->setLayer([(AVFMediaPlayerSessionObserver*)m_observer playerLayer]);
}
- //reset the EndOfMedia status if the same file is played again
+ [[(AVFMediaPlayerSessionObserver*)m_observer player] pause];
+
+ // Reset media status if the current status is EndOfMedia
if (m_mediaStatus == QMediaPlayer::EndOfMedia)
- processLoadStateChange();
+ setPosition(0);
- [[(AVFMediaPlayerSessionObserver*)m_observer player] pause];
- //processLoadStateChange();
Q_EMIT stateChanged(m_state);
}
@@ -724,7 +737,6 @@ void AVFMediaPlayerSession::stop()
if (m_state == QMediaPlayer::StoppedState)
return;
- m_state = QMediaPlayer::StoppedState;
// AVPlayer doesn't have stop(), only pause() and play().
[[(AVFMediaPlayerSessionObserver*)m_observer player] pause];
setPosition(0);
@@ -733,9 +745,11 @@ void AVFMediaPlayerSession::stop()
m_videoOutput->setLayer(0);
}
- processLoadStateChange();
- Q_EMIT stateChanged(m_state);
+ if (m_mediaStatus == QMediaPlayer::BufferedMedia)
+ Q_EMIT mediaStatusChanged((m_mediaStatus = QMediaPlayer::LoadedMedia));
+
Q_EMIT positionChanged(position());
+ Q_EMIT stateChanged((m_state = QMediaPlayer::StoppedState));
}
void AVFMediaPlayerSession::setVolume(int volume)
@@ -782,6 +796,8 @@ void AVFMediaPlayerSession::processEOS()
#endif
Q_EMIT positionChanged(position());
m_mediaStatus = QMediaPlayer::EndOfMedia;
+ Q_EMIT mediaStatusChanged(m_mediaStatus);
+
m_state = QMediaPlayer::StoppedState;
// At this point, frames should not be rendered anymore.
@@ -789,23 +805,26 @@ void AVFMediaPlayerSession::processEOS()
if (m_videoOutput)
m_videoOutput->setLayer(0);
- Q_EMIT mediaStatusChanged(m_mediaStatus);
Q_EMIT stateChanged(m_state);
}
-void AVFMediaPlayerSession::processLoadStateChange()
+void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState)
{
AVPlayerStatus currentStatus = [[(AVFMediaPlayerSessionObserver*)m_observer player] status];
#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << currentStatus;
+ qDebug() << Q_FUNC_INFO << currentStatus << ", " << m_mediaStatus << ", " << newState;
#endif
- QMediaPlayer::MediaStatus newStatus = QMediaPlayer::NoMedia;
- bool isPlaying = (m_state != QMediaPlayer::StoppedState);
+ if (m_mediaStatus == QMediaPlayer::NoMedia)
+ return;
if (currentStatus == AVPlayerStatusReadyToPlay) {
+
+ QMediaPlayer::MediaStatus newStatus = m_mediaStatus;
+
AVPlayerItem *playerItem = [(AVFMediaPlayerSessionObserver*)m_observer playerItem];
+
if (playerItem) {
// Check each track for audio and video content
AVAssetTrack *videoTrack = nil;
@@ -832,35 +851,52 @@ void AVFMediaPlayerSession::processLoadStateChange()
videoTrack.naturalSize.width,
videoTrack.naturalSize.height);
- if (m_videoOutput && m_state != QMediaPlayer::StoppedState) {
+ if (m_videoOutput && newState != QMediaPlayer::StoppedState) {
m_videoOutput->setLayer(playerLayer);
}
}
- }
- qint64 currentDuration = duration();
- if (m_duration != currentDuration)
- Q_EMIT durationChanged(m_duration = currentDuration);
+ qint64 currentDuration = duration();
+ if (m_duration != currentDuration)
+ Q_EMIT durationChanged(m_duration = currentDuration);
- if (m_requestedPosition != -1) {
- setPosition(m_requestedPosition);
- m_requestedPosition = -1;
+ if (m_requestedPosition != -1) {
+ setPosition(m_requestedPosition);
+ m_requestedPosition = -1;
+ }
}
- newStatus = isPlaying ? QMediaPlayer::BufferedMedia : QMediaPlayer::LoadedMedia;
+ newStatus = (newState != QMediaPlayer::StoppedState) ? QMediaPlayer::BufferedMedia
+ : QMediaPlayer::LoadedMedia;
+
+ if (newStatus != m_mediaStatus)
+ Q_EMIT mediaStatusChanged((m_mediaStatus = newStatus));
- if (m_state == QMediaPlayer::PlayingState && [(AVFMediaPlayerSessionObserver*)m_observer player]) {
- // Setting the rate is enough to start playback, no need to call play()
- [[(AVFMediaPlayerSessionObserver*)m_observer player] setRate:m_rate];
- }
}
- if (newStatus != m_mediaStatus)
- Q_EMIT mediaStatusChanged(m_mediaStatus = newStatus);
+ if (newState == QMediaPlayer::PlayingState && [(AVFMediaPlayerSessionObserver*)m_observer player]) {
+ // Setting the rate is enough to start playback, no need to call play()
+ [[(AVFMediaPlayerSessionObserver*)m_observer player] setRate:m_rate];
+ }
+}
+
+
+void AVFMediaPlayerSession::processLoadStateChange()
+{
+ processLoadStateChange(m_state);
+}
+
+
+void AVFMediaPlayerSession::processLoadStateFailure()
+{
+ Q_EMIT stateChanged((m_state = QMediaPlayer::StoppedState));
}
void AVFMediaPlayerSession::processPositionChange()
{
+ if (m_state == QMediaPlayer::StoppedState)
+ return;
+
Q_EMIT positionChanged(position());
}
@@ -871,10 +907,7 @@ void AVFMediaPlayerSession::processMediaLoadError()
Q_EMIT positionChanged(position());
}
- m_mediaStatus = QMediaPlayer::InvalidMedia;
- m_state = QMediaPlayer::StoppedState;
+ Q_EMIT mediaStatusChanged((m_mediaStatus = QMediaPlayer::InvalidMedia));
Q_EMIT error(QMediaPlayer::FormatError, tr("Failed to load media"));
- Q_EMIT mediaStatusChanged(m_mediaStatus);
- Q_EMIT stateChanged(m_state);
}
diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp
index 7a26afd10..38e8c3a8f 100644
--- a/src/plugins/common/evr/evrcustompresenter.cpp
+++ b/src/plugins/common/evr/evrcustompresenter.cpp
@@ -53,6 +53,8 @@
#include <float.h>
#include <evcode.h>
+QT_BEGIN_NAMESPACE
+
const static MFRatio g_DefaultFrameRate = { 30, 1 };
static const DWORD SCHEDULER_TIMEOUT = 5000;
static const MFTIME ONE_SECOND = 10000000;
@@ -2044,3 +2046,5 @@ static QVideoFrame::PixelFormat pixelFormatFromMediaType(IMFMediaType *type)
return QVideoFrame::Format_Invalid;
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/common/evr/evrcustompresenter.h b/src/plugins/common/evr/evrcustompresenter.h
index 67ae61991..5c240ea95 100644
--- a/src/plugins/common/evr/evrcustompresenter.h
+++ b/src/plugins/common/evr/evrcustompresenter.h
@@ -49,14 +49,12 @@
#include "evrdefs.h"
QT_BEGIN_NAMESPACE
-class QAbstractVideoSurface;
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
class EVRCustomPresenter;
class D3DPresentEngine;
+class QAbstractVideoSurface;
+
template<class T>
class AsyncCallback : public IMFAsyncCallback
{
@@ -375,4 +373,6 @@ private:
bool qt_evr_setCustomPresenter(IUnknown *evr, EVRCustomPresenter *presenter);
+QT_END_NAMESPACE
+
#endif // EVRCUSTOMPRESENTER_H
diff --git a/src/plugins/common/evr/evrd3dpresentengine.cpp b/src/plugins/common/evr/evrd3dpresentengine.cpp
index ae3d69fc2..4bc2bac83 100644
--- a/src/plugins/common/evr/evrd3dpresentengine.cpp
+++ b/src/plugins/common/evr/evrd3dpresentengine.cpp
@@ -57,6 +57,8 @@
static const int PRESENTER_BUFFER_COUNT = 3;
+QT_BEGIN_NAMESPACE
+
#ifdef MAYBE_ANGLE
EGLWrapper::EGLWrapper()
@@ -642,3 +644,5 @@ done:
}
#endif // MAYBE_ANGLE
+
+QT_END_NAMESPACE
diff --git a/src/plugins/common/evr/evrd3dpresentengine.h b/src/plugins/common/evr/evrd3dpresentengine.h
index d181689ec..18a7409fa 100644
--- a/src/plugins/common/evr/evrd3dpresentengine.h
+++ b/src/plugins/common/evr/evrd3dpresentengine.h
@@ -50,10 +50,6 @@
# define MAYBE_ANGLE
#endif
-QT_BEGIN_NAMESPACE
-class QAbstractVideoSurface;
-QT_END_NAMESPACE
-
struct IDirect3D9Ex;
struct IDirect3DDevice9Ex;
struct IDirect3DDeviceManager9;
@@ -66,7 +62,9 @@ struct IMFMediaType;
static const GUID MFSamplePresenter_SampleCounter =
{ 0xb0bb83cc, 0xf10f, 0x4e2e, { 0xaa, 0x2b, 0x29, 0xea, 0x5e, 0x92, 0xef, 0x85 } };
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
+
+class QAbstractVideoSurface;
#ifdef MAYBE_ANGLE
@@ -153,4 +151,6 @@ private:
friend class IMFSampleVideoBuffer;
};
+QT_END_NAMESPACE
+
#endif // EVRD3DPRESENTENGINE_H
diff --git a/src/plugins/common/evr/evrhelpers.cpp b/src/plugins/common/evr/evrhelpers.cpp
index 2e9d4fae6..f4710b1a0 100644
--- a/src/plugins/common/evr/evrhelpers.cpp
+++ b/src/plugins/common/evr/evrhelpers.cpp
@@ -46,6 +46,8 @@
#define D3DFMT_NV12 (D3DFORMAT)MAKEFOURCC ('N', 'V', '1', '2')
#endif
+QT_BEGIN_NAMESPACE
+
HRESULT qt_evr_getFourCC(IMFMediaType *type, DWORD *fourCC)
{
if (!fourCC)
@@ -180,3 +182,5 @@ D3DFORMAT qt_evr_D3DFormatFromPixelFormat(QVideoFrame::PixelFormat format)
return D3DFMT_UNKNOWN;
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/common/evr/evrhelpers.h b/src/plugins/common/evr/evrhelpers.h
index 54ab8b848..d2fdfdcae 100644
--- a/src/plugins/common/evr/evrhelpers.h
+++ b/src/plugins/common/evr/evrhelpers.h
@@ -43,7 +43,7 @@
#include "evrdefs.h"
#include <qvideoframe.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
template<class T>
static inline void qt_evr_safe_release(T **unk)
@@ -93,5 +93,7 @@ inline HRESULT qt_evr_getFrameRate(IMFMediaType *pType, MFRatio *pRatio)
QVideoFrame::PixelFormat qt_evr_pixelFormatFromD3DFormat(D3DFORMAT format);
D3DFORMAT qt_evr_D3DFormatFromPixelFormat(QVideoFrame::PixelFormat format);
+QT_END_NAMESPACE
+
#endif // EVRHELPERS_H
diff --git a/src/plugins/common/evr/evrvideowindowcontrol.h b/src/plugins/common/evr/evrvideowindowcontrol.h
index 7994b1b5e..fcfe20958 100644
--- a/src/plugins/common/evr/evrvideowindowcontrol.h
+++ b/src/plugins/common/evr/evrvideowindowcontrol.h
@@ -44,7 +44,7 @@
#include "evrdefs.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class EvrVideoWindowControl : public QVideoWindowControl
{
@@ -104,4 +104,6 @@ private:
IMFVideoProcessor *m_processor;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 40e54a94d..3f1187baa 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -334,6 +334,26 @@ void DSCameraSession::setImageProcessingParameter(
}
}
+bool DSCameraSession::getCameraControlInterface(IAMCameraControl **cameraControl) const
+{
+ if (!m_sourceFilter) {
+ qCDebug(qtDirectShowPlugin, "getCameraControlInterface failed: No capture filter!");
+ return false;
+ }
+
+ if (!cameraControl) {
+ qCDebug(qtDirectShowPlugin, "getCameraControlInterface failed: Invalid out argument!");
+ return false;
+ }
+
+ if (FAILED(m_sourceFilter->QueryInterface(IID_IAMCameraControl, reinterpret_cast<void **>(cameraControl)))) {
+ qCDebug(qtDirectShowPlugin, "getCameraControlInterface failed: Querying camera control failed!");
+ return false;
+ }
+
+ return true;
+}
+
bool DSCameraSession::load()
{
unload();
diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h
index 37730736f..6b6cb49b2 100644
--- a/src/plugins/directshow/camera/dscamerasession.h
+++ b/src/plugins/directshow/camera/dscamerasession.h
@@ -118,6 +118,8 @@ public:
QCameraImageProcessingControl::ProcessingParameter,
const QVariant &);
+ bool getCameraControlInterface(IAMCameraControl **cameraControl) const;
+
Q_SIGNALS:
void statusChanged(QCamera::Status);
void imageExposed(int id);
diff --git a/src/plugins/directshow/common/common.pri b/src/plugins/directshow/common/common.pri
index 9b7c1e3f4..06f8582ac 100644
--- a/src/plugins/directshow/common/common.pri
+++ b/src/plugins/directshow/common/common.pri
@@ -1,11 +1,30 @@
INCLUDEPATH += $$PWD
HEADERS += \
+ $$PWD/directshowbasefilter.h \
+ $$PWD/directshoweventloop.h \
+ $$PWD/directshowglobal.h \
+ $$PWD/directshowmediatype.h \
+ $$PWD/directshowmediatypeenum.h \
+ $$PWD/directshowobject.h \
+ $$PWD/directshowpin.h \
+ $$PWD/directshowpinenum.h \
+ $$PWD/directshowvideobuffer.h \
+ $$PWD/directshowutils.h \
$$PWD/directshowvideoprobecontrol.h \
$$PWD/directshowaudioprobecontrol.h \
$$PWD/directshowsamplegrabber.h
SOURCES += \
+ $$PWD/directshowbasefilter.cpp \
+ $$PWD/directshoweventloop.cpp \
+ $$PWD/directshowmediatype.cpp \
+ $$PWD/directshowmediatypeenum.cpp \
+ $$PWD/directshowobject.cpp \
+ $$PWD/directshowpin.cpp \
+ $$PWD/directshowpinenum.cpp \
+ $$PWD/directshowvideobuffer.cpp \
+ $$PWD/directshowutils.cpp \
$$PWD/directshowvideoprobecontrol.cpp \
$$PWD/directshowaudioprobecontrol.cpp \
$$PWD/directshowsamplegrabber.cpp
diff --git a/src/plugins/directshow/helpers/directshowbasefilter.cpp b/src/plugins/directshow/common/directshowbasefilter.cpp
index fbf0f6204..342f0c271 100644
--- a/src/plugins/directshow/helpers/directshowbasefilter.cpp
+++ b/src/plugins/directshow/common/directshowbasefilter.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -35,6 +41,8 @@
#include "directshowpinenum.h"
+QT_BEGIN_NAMESPACE
+
DirectShowBaseFilter::DirectShowBaseFilter()
: m_mutex(QMutex::Recursive)
, m_state(State_Stopped)
@@ -265,3 +273,5 @@ HRESULT DirectShowBaseFilter::QueryVendorInfo(LPWSTR *pVendorInfo)
Q_UNUSED(pVendorInfo);
return E_NOTIMPL;
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshowbasefilter.h b/src/plugins/directshow/common/directshowbasefilter.h
index cc8588044..9a2f44567 100644
--- a/src/plugins/directshow/helpers/directshowbasefilter.h
+++ b/src/plugins/directshow/common/directshowbasefilter.h
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -36,7 +42,7 @@
#include "directshowpin.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowBaseFilter : public DirectShowObject
, public IBaseFilter
@@ -90,4 +96,6 @@ private:
Q_DISABLE_COPY(DirectShowBaseFilter)
};
+QT_END_NAMESPACE
+
#endif // DIRECTSHOWBASEFILTER_H
diff --git a/src/plugins/directshow/helpers/directshoweventloop.cpp b/src/plugins/directshow/common/directshoweventloop.cpp
index 87f969e42..ef85c0429 100644
--- a/src/plugins/directshow/helpers/directshoweventloop.cpp
+++ b/src/plugins/directshow/common/directshoweventloop.cpp
@@ -42,6 +42,8 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qcoreevent.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowPostedEvent
{
public:
@@ -146,3 +148,5 @@ void DirectShowEventLoop::processEvents()
locker.relock();
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshoweventloop.h b/src/plugins/directshow/common/directshoweventloop.h
index 09d986de7..609e53134 100644
--- a/src/plugins/directshow/helpers/directshoweventloop.h
+++ b/src/plugins/directshow/common/directshoweventloop.h
@@ -46,6 +46,8 @@
#include <qt_windows.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowPostedEvent;
class DirectShowEventLoop : public QObject
@@ -73,4 +75,6 @@ private:
QMutex m_mutex;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/helpers/directshowglobal.h b/src/plugins/directshow/common/directshowglobal.h
index 5f391710e..5f391710e 100644
--- a/src/plugins/directshow/helpers/directshowglobal.h
+++ b/src/plugins/directshow/common/directshowglobal.h
diff --git a/src/plugins/directshow/helpers/directshowmediatype.cpp b/src/plugins/directshow/common/directshowmediatype.cpp
index d9ddf8248..65882806c 100644
--- a/src/plugins/directshow/helpers/directshowmediatype.cpp
+++ b/src/plugins/directshow/common/directshowmediatype.cpp
@@ -134,6 +134,11 @@ void DirectShowMediaType::copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *sourc
clear(*target);
+ copyToUninitialized(target, source);
+}
+
+void DirectShowMediaType::copyToUninitialized(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source)
+{
*target = *source;
if (source->cbFormat > 0) {
diff --git a/src/plugins/directshow/helpers/directshowmediatype.h b/src/plugins/directshow/common/directshowmediatype.h
index 7849ca9b0..7f495f3b2 100644
--- a/src/plugins/directshow/helpers/directshowmediatype.h
+++ b/src/plugins/directshow/common/directshowmediatype.h
@@ -47,7 +47,7 @@
#include <dvdmedia.h>
#include <QtCore/qglobal.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowMediaType
{
@@ -72,6 +72,7 @@ public:
static void init(AM_MEDIA_TYPE *type);
static void copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source);
+ static void copyToUninitialized(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source);
static void move(AM_MEDIA_TYPE *target, AM_MEDIA_TYPE **source);
static void move(AM_MEDIA_TYPE *target, AM_MEDIA_TYPE &source);
static void clear(AM_MEDIA_TYPE &type);
@@ -91,4 +92,6 @@ private:
Q_DECLARE_TYPEINFO(DirectShowMediaType, Q_MOVABLE_TYPE);
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/helpers/directshowmediatypeenum.cpp b/src/plugins/directshow/common/directshowmediatypeenum.cpp
index a58993f7f..8fbdf7dea 100644
--- a/src/plugins/directshow/helpers/directshowmediatypeenum.cpp
+++ b/src/plugins/directshow/common/directshowmediatypeenum.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -72,7 +78,7 @@ HRESULT DirectShowMediaTypeEnum::Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMedia
for (ULONG i = 0; i < count; ++i, ++m_index) {
ppMediaTypes[i] = reinterpret_cast<AM_MEDIA_TYPE *>(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)));
- DirectShowMediaType::copy(ppMediaTypes[i], &m_mediaTypes.at(m_index));
+ DirectShowMediaType::copyToUninitialized(ppMediaTypes[i], &m_mediaTypes.at(m_index));
}
if (pcFetched)
diff --git a/src/plugins/directshow/common/directshowmediatypeenum.h b/src/plugins/directshow/common/directshowmediatypeenum.h
new file mode 100644
index 000000000..9b058fc5b
--- /dev/null
+++ b/src/plugins/directshow/common/directshowmediatypeenum.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DIRECTSHOWMEDIATYPEENUM_H
+#define DIRECTSHOWMEDIATYPEENUM_H
+
+#include "directshowobject.h"
+#include <qlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class DirectShowPin;
+class DirectShowMediaType;
+
+class DirectShowMediaTypeEnum : public DirectShowObject
+ , public IEnumMediaTypes
+{
+ DIRECTSHOW_OBJECT
+
+public:
+ DirectShowMediaTypeEnum(DirectShowPin *pin);
+ DirectShowMediaTypeEnum(const QList<DirectShowMediaType> &types);
+ ~DirectShowMediaTypeEnum();
+
+ // DirectShowObject
+ HRESULT getInterface(REFIID riid, void **ppvObject);
+
+ // IEnumMediaTypes
+ STDMETHODIMP Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched);
+ STDMETHODIMP Skip(ULONG cMediaTypes);
+ STDMETHODIMP Reset();
+ STDMETHODIMP Clone(IEnumMediaTypes **ppEnum);
+
+private:
+ Q_DISABLE_COPY(DirectShowMediaTypeEnum)
+
+ DirectShowPin *m_pin;
+ QList<DirectShowMediaType> m_mediaTypes;
+ int m_index;
+};
+
+QT_END_NAMESPACE
+
+#endif // DIRECTSHOWMEDIATYPEENUM_H
diff --git a/src/plugins/directshow/helpers/directshowobject.cpp b/src/plugins/directshow/common/directshowobject.cpp
index b9d989f6e..db1817a8d 100644
--- a/src/plugins/directshow/helpers/directshowobject.cpp
+++ b/src/plugins/directshow/common/directshowobject.cpp
@@ -39,6 +39,8 @@
#include "directshowobject.h"
+QT_BEGIN_NAMESPACE
+
DirectShowObject::DirectShowObject()
: m_ref(1)
{
@@ -81,3 +83,4 @@ HRESULT GetInterface(IUnknown *pUnk, void **ppv)
return S_OK;
}
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshowobject.h b/src/plugins/directshow/common/directshowobject.h
index 3aba06f46..cfac16f61 100644
--- a/src/plugins/directshow/helpers/directshowobject.h
+++ b/src/plugins/directshow/common/directshowobject.h
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -36,7 +42,7 @@
#include "directshowglobal.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowObject
{
@@ -71,4 +77,6 @@ public: \
return unref(); \
};
+QT_END_NAMESPACE
+
#endif // DIRECTSHOWOBJECT_H
diff --git a/src/plugins/directshow/helpers/directshowpin.cpp b/src/plugins/directshow/common/directshowpin.cpp
index f501747f9..b49c3f8a4 100644
--- a/src/plugins/directshow/helpers/directshowpin.cpp
+++ b/src/plugins/directshow/common/directshowpin.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -39,6 +45,8 @@
#include <qdebug.h>
+QT_BEGIN_NAMESPACE
+
DirectShowPin::DirectShowPin(DirectShowBaseFilter *filter, const QString &name, PIN_DIRECTION direction)
: m_mutex(QMutex::Recursive)
, m_filter(filter)
@@ -728,3 +736,5 @@ HRESULT DirectShowInputPin::ReceiveCanBlock()
return outputPins == 0 ? S_OK : S_FALSE;
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshowpin.h b/src/plugins/directshow/common/directshowpin.h
index b8207abae..97e808384 100644
--- a/src/plugins/directshow/helpers/directshowpin.h
+++ b/src/plugins/directshow/common/directshowpin.h
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -40,7 +46,7 @@
#include <qstring.h>
#include <qmutex.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowBaseFilter;
@@ -181,4 +187,6 @@ private:
Q_DISABLE_COPY(DirectShowInputPin)
};
+QT_END_NAMESPACE
+
#endif // DIRECTSHOWPIN_H
diff --git a/src/plugins/directshow/helpers/directshowpinenum.cpp b/src/plugins/directshow/common/directshowpinenum.cpp
index 61aca8b9c..910bba77d 100644
--- a/src/plugins/directshow/helpers/directshowpinenum.cpp
+++ b/src/plugins/directshow/common/directshowpinenum.cpp
@@ -40,6 +40,8 @@
#include "directshowpinenum.h"
#include "directshowbasefilter.h"
+QT_BEGIN_NAMESPACE
+
DirectShowPinEnum::DirectShowPinEnum(DirectShowBaseFilter *filter)
: m_filter(filter)
, m_index(0)
@@ -124,3 +126,5 @@ HRESULT DirectShowPinEnum::Clone(IEnumPins **ppEnum)
return E_POINTER;
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshowpinenum.h b/src/plugins/directshow/common/directshowpinenum.h
index 84c2a7579..77214e376 100644
--- a/src/plugins/directshow/helpers/directshowpinenum.h
+++ b/src/plugins/directshow/common/directshowpinenum.h
@@ -45,7 +45,7 @@
#include <QtCore/qlist.h>
#include "directshowpin.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowBaseFilter;
@@ -76,4 +76,6 @@ private:
int m_index;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/helpers/directshowutils.cpp b/src/plugins/directshow/common/directshowutils.cpp
index d9701fd99..96fabd6da 100644
--- a/src/plugins/directshow/helpers/directshowutils.cpp
+++ b/src/plugins/directshow/common/directshowutils.cpp
@@ -39,6 +39,8 @@
#include "directshowutils.h"
+QT_BEGIN_NAMESPACE
+
/**
* @brief DirectShowUtils::isPinConnected
* @param pin
@@ -307,3 +309,5 @@ bool DirectShowUtils::connectFilters(IGraphBuilder *graph,
return SUCCEEDED(*hrOut);
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshowutils.h b/src/plugins/directshow/common/directshowutils.h
index 09c81c257..09c81c257 100644
--- a/src/plugins/directshow/helpers/directshowutils.h
+++ b/src/plugins/directshow/common/directshowutils.h
diff --git a/src/plugins/directshow/helpers/directshowvideobuffer.cpp b/src/plugins/directshow/common/directshowvideobuffer.cpp
index 3204e9f7e..7f94da97e 100644
--- a/src/plugins/directshow/helpers/directshowvideobuffer.cpp
+++ b/src/plugins/directshow/common/directshowvideobuffer.cpp
@@ -39,6 +39,8 @@
#include "directshowvideobuffer.h"
+QT_BEGIN_NAMESPACE
+
DirectShowVideoBuffer::DirectShowVideoBuffer(IMediaSample *sample, int bytesPerLine)
: QAbstractVideoBuffer(NoHandle)
, m_sample(sample)
@@ -82,3 +84,5 @@ QAbstractVideoBuffer::MapMode DirectShowVideoBuffer::mapMode() const
{
return m_mapMode;
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/helpers/directshowvideobuffer.h b/src/plugins/directshow/common/directshowvideobuffer.h
index 10089c75a..85e02b53d 100644
--- a/src/plugins/directshow/helpers/directshowvideobuffer.h
+++ b/src/plugins/directshow/common/directshowvideobuffer.h
@@ -44,6 +44,8 @@
#include <qabstractvideobuffer.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowVideoBuffer : public QAbstractVideoBuffer
{
public:
@@ -63,5 +65,6 @@ private:
MapMode m_mapMode;
};
+QT_END_NAMESPACE
#endif
diff --git a/src/plugins/directshow/directshow.pro b/src/plugins/directshow/directshow.pro
index 35301474f..2857f87d9 100644
--- a/src/plugins/directshow/directshow.pro
+++ b/src/plugins/directshow/directshow.pro
@@ -11,7 +11,6 @@ SOURCES += dsserviceplugin.cpp
mingw: DEFINES += NO_DSHOW_STRSAFE
include(common/common.pri)
-include(helpers/helpers.pri)
qtConfig(directshow-player): include(player/player.pri)
include(camera/camera.pri)
diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp
index 9060bac7c..51be7e500 100644
--- a/src/plugins/directshow/dsserviceplugin.cpp
+++ b/src/plugins/directshow/dsserviceplugin.cpp
@@ -75,9 +75,6 @@ extern const CLSID CLSID_VideoInputDeviceCategory;
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qtDirectShowPlugin, "qt.multimedia.plugins.directshow")
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
static int g_refCount = 0;
void addRefCount()
@@ -157,3 +154,5 @@ QString DSServicePlugin::deviceDescription(const QByteArray &service, const QByt
}
return QString();
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/dsserviceplugin.h b/src/plugins/directshow/dsserviceplugin.h
index b7ac6a86e..f57262e37 100644
--- a/src/plugins/directshow/dsserviceplugin.h
+++ b/src/plugins/directshow/dsserviceplugin.h
@@ -43,7 +43,7 @@
#include <QtMultimedia/private/qtmultimediaglobal_p.h>
#include "qmediaserviceproviderplugin.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DSServicePlugin
: public QMediaServiceProviderPlugin
@@ -74,4 +74,6 @@ public:
QString deviceDescription(const QByteArray &service, const QByteArray &device);
};
+QT_END_NAMESPACE
+
#endif // DSSERVICEPLUGIN_H
diff --git a/src/plugins/directshow/helpers/directshowmediatypeenum.h b/src/plugins/directshow/helpers/directshowmediatypeenum.h
deleted file mode 100644
index 050df0881..000000000
--- a/src/plugins/directshow/helpers/directshowmediatypeenum.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIRECTSHOWMEDIATYPEENUM_H
-#define DIRECTSHOWMEDIATYPEENUM_H
-
-#include "directshowobject.h"
-#include <qlist.h>
-
-QT_USE_NAMESPACE
-
-class DirectShowPin;
-class DirectShowMediaType;
-
-class DirectShowMediaTypeEnum : public DirectShowObject
- , public IEnumMediaTypes
-{
- DIRECTSHOW_OBJECT
-
-public:
- DirectShowMediaTypeEnum(DirectShowPin *pin);
- DirectShowMediaTypeEnum(const QList<DirectShowMediaType> &types);
- ~DirectShowMediaTypeEnum();
-
- // DirectShowObject
- HRESULT getInterface(REFIID riid, void **ppvObject);
-
- // IEnumMediaTypes
- STDMETHODIMP Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched);
- STDMETHODIMP Skip(ULONG cMediaTypes);
- STDMETHODIMP Reset();
- STDMETHODIMP Clone(IEnumMediaTypes **ppEnum);
-
-private:
- Q_DISABLE_COPY(DirectShowMediaTypeEnum)
-
- DirectShowPin *m_pin;
- QList<DirectShowMediaType> m_mediaTypes;
- int m_index;
-};
-
-#endif // DIRECTSHOWMEDIATYPEENUM_H
diff --git a/src/plugins/directshow/helpers/helpers.pri b/src/plugins/directshow/helpers/helpers.pri
deleted file mode 100644
index ca883eeb8..000000000
--- a/src/plugins/directshow/helpers/helpers.pri
+++ /dev/null
@@ -1,24 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/directshowbasefilter.h \
- $$PWD/directshoweventloop.h \
- $$PWD/directshowglobal.h \
- $$PWD/directshowmediatype.h \
- $$PWD/directshowmediatypeenum.h \
- $$PWD/directshowobject.h \
- $$PWD/directshowpin.h \
- $$PWD/directshowpinenum.h \
- $$PWD/directshowvideobuffer.h \
- $$PWD/directshowutils.h
-
-SOURCES += \
- $$PWD/directshowbasefilter.cpp \
- $$PWD/directshoweventloop.cpp \
- $$PWD/directshowmediatype.cpp \
- $$PWD/directshowmediatypeenum.cpp \
- $$PWD/directshowobject.cpp \
- $$PWD/directshowpin.cpp \
- $$PWD/directshowpinenum.cpp \
- $$PWD/directshowvideobuffer.cpp \
- $$PWD/directshowutils.cpp
diff --git a/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp b/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp
index f4e75f4e2..78733972a 100644
--- a/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp
+++ b/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp
@@ -42,6 +42,8 @@
#include "directshowglobal.h"
#include "directshowplayerservice.h"
+QT_BEGIN_NAMESPACE
+
DirectShowAudioEndpointControl::DirectShowAudioEndpointControl(
DirectShowPlayerService *service, QObject *parent)
: QAudioOutputSelectorControl(parent)
@@ -157,3 +159,5 @@ void DirectShowAudioEndpointControl::updateEndpoints()
oleMalloc->Release();
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/player/directshowaudioendpointcontrol.h b/src/plugins/directshow/player/directshowaudioendpointcontrol.h
index 2d1763ea3..e0e6a1545 100644
--- a/src/plugins/directshow/player/directshowaudioendpointcontrol.h
+++ b/src/plugins/directshow/player/directshowaudioendpointcontrol.h
@@ -44,9 +44,9 @@
#include <dshow.h>
-class DirectShowPlayerService;
+QT_BEGIN_NAMESPACE
-QT_USE_NAMESPACE
+class DirectShowPlayerService;
class DirectShowAudioEndpointControl : public QAudioOutputSelectorControl
{
@@ -76,5 +76,7 @@ private:
QString m_activeEndpoint;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/directshowevrvideowindowcontrol.h b/src/plugins/directshow/player/directshowevrvideowindowcontrol.h
index 5aa304bca..fb661780f 100644
--- a/src/plugins/directshow/player/directshowevrvideowindowcontrol.h
+++ b/src/plugins/directshow/player/directshowevrvideowindowcontrol.h
@@ -44,7 +44,7 @@
struct IBaseFilter;
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowEvrVideoWindowControl : public EvrVideoWindowControl
{
@@ -58,4 +58,6 @@ private:
IBaseFilter *m_evrFilter;
};
+QT_END_NAMESPACE
+
#endif // DIRECTSHOWEVRVIDEOWINDOWCONTROL_H
diff --git a/src/plugins/directshow/player/directshowioreader.cpp b/src/plugins/directshow/player/directshowioreader.cpp
index a35124b1e..7f3303633 100644
--- a/src/plugins/directshow/player/directshowioreader.cpp
+++ b/src/plugins/directshow/player/directshowioreader.cpp
@@ -48,6 +48,8 @@
#include <QtCore/qiodevice.h>
#include <QtCore/qthread.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowSampleRequest
{
public:
@@ -492,3 +494,5 @@ void DirectShowIOReader::flushRequests()
m_readyHead = m_readyTail;
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/player/directshowioreader.h b/src/plugins/directshow/player/directshowioreader.h
index deb5d5327..2d62c0b95 100644
--- a/src/plugins/directshow/player/directshowioreader.h
+++ b/src/plugins/directshow/player/directshowioreader.h
@@ -48,7 +48,6 @@
QT_BEGIN_NAMESPACE
class QIODevice;
-QT_END_NAMESPACE
class DirectShowEventLoop;
class DirectShowIOSource;
@@ -115,4 +114,6 @@ private:
QWaitCondition m_wait;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/directshowiosource.cpp b/src/plugins/directshow/player/directshowiosource.cpp
index 96b4b14bf..b3aa3fab9 100644
--- a/src/plugins/directshow/player/directshowiosource.cpp
+++ b/src/plugins/directshow/player/directshowiosource.cpp
@@ -47,6 +47,8 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qurl.h>
+QT_BEGIN_NAMESPACE
+
static const GUID directshow_subtypes[] =
{
MEDIASUBTYPE_NULL,
@@ -581,3 +583,5 @@ HRESULT DirectShowIOSource::QueryDirection(PIN_DIRECTION *pPinDir)
return S_OK;
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/player/directshowiosource.h b/src/plugins/directshow/player/directshowiosource.h
index 702bfed61..43df6c34f 100644
--- a/src/plugins/directshow/player/directshowiosource.h
+++ b/src/plugins/directshow/player/directshowiosource.h
@@ -46,6 +46,8 @@
#include <QtCore/qfile.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowIOSource
: public IBaseFilter
, public IAMFilterMiscFlags
@@ -131,4 +133,6 @@ private:
QMutex m_mutex;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.h b/src/plugins/directshow/player/directshowmetadatacontrol.h
index b42b48c67..3d2fa5e8e 100644
--- a/src/plugins/directshow/player/directshowmetadatacontrol.h
+++ b/src/plugins/directshow/player/directshowmetadatacontrol.h
@@ -48,9 +48,7 @@
#include <QtCore/qcoreevent.h>
-class DirectShowPlayerService;
-
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowMetaDataControl : public QMetaDataReaderControl
{
@@ -83,4 +81,6 @@ private:
bool m_available;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/directshowplayercontrol.h b/src/plugins/directshow/player/directshowplayercontrol.h
index 184951544..fd2c21c38 100644
--- a/src/plugins/directshow/player/directshowplayercontrol.h
+++ b/src/plugins/directshow/player/directshowplayercontrol.h
@@ -49,7 +49,7 @@
#include "directshowplayerservice.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class DirectShowPlayerControl : public QMediaPlayerControl
{
@@ -148,4 +148,6 @@ private:
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index 5fbb6ef05..de427f781 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -53,7 +53,11 @@
#include "directshowiosource.h"
#include "directshowplayercontrol.h"
#include "directshowvideorenderercontrol.h"
-
+#include "directshowutils.h"
+#include "directshowglobal.h"
+#include "directshowaudioprobecontrol.h"
+#include "directshowvideoprobecontrol.h"
+#include "directshowsamplegrabber.h"
#if QT_CONFIG(evr)
#include "directshowevrvideowindowcontrol.h"
@@ -68,6 +72,11 @@
#include <QtCore/qdir.h>
#include <QtCore/qthread.h>
#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qsize.h>
+
+#include <QtMultimedia/qaudiobuffer.h>
+#include <QtMultimedia/qvideoframe.h>
+#include <QtMultimedia/private/qmemoryvideobuffer_p.h>
#if QT_CONFIG(wmsdk)
# include <wmsdk.h>
@@ -77,6 +86,8 @@
# include <comdef.h>
#endif
+QT_BEGIN_NAMESPACE
+
Q_GLOBAL_STATIC(DirectShowEventLoop, qt_directShowEventLoop)
static QString comError(HRESULT hr)
@@ -115,6 +126,10 @@ DirectShowPlayerService::DirectShowPlayerService(QObject *parent)
, m_videoRendererControl(0)
, m_videoWindowControl(0)
, m_audioEndpointControl(0)
+ , m_audioProbeControl(nullptr)
+ , m_videoProbeControl(nullptr)
+ , m_audioSampleGrabber(nullptr)
+ , m_videoSampleGrabber(nullptr)
, m_taskThread(0)
, m_loop(qt_directShowEventLoop())
, m_pendingTasks(0)
@@ -174,6 +189,8 @@ DirectShowPlayerService::~DirectShowPlayerService()
delete m_metaDataControl;
delete m_videoRendererControl;
delete m_videoWindowControl;
+ delete m_audioProbeControl;
+ delete m_videoProbeControl;
::CloseHandle(m_taskHandle);
}
@@ -217,6 +234,18 @@ QMediaControl *DirectShowPlayerService::requestControl(const char *name)
return m_videoWindowControl;
}
+ } else if (qstrcmp(name, QMediaAudioProbeControl_iid) == 0) {
+ if (!m_audioProbeControl)
+ m_audioProbeControl = new DirectShowAudioProbeControl();
+ m_audioProbeControl->ref();
+ updateAudioProbe();
+ return m_audioProbeControl;
+ } else if (qstrcmp(name, QMediaVideoProbeControl_iid) == 0) {
+ if (!m_videoProbeControl)
+ m_videoProbeControl = new DirectShowVideoProbeControl();
+ m_videoProbeControl->ref();
+ updateVideoProbe();
+ return m_videoProbeControl;
}
return 0;
}
@@ -238,6 +267,20 @@ void DirectShowPlayerService::releaseControl(QMediaControl *control)
delete m_videoWindowControl;
m_videoWindowControl = 0;
+ } else if (control == m_audioProbeControl) {
+ if (!m_audioProbeControl->deref()) {
+ DirectShowAudioProbeControl *old = m_audioProbeControl;
+ m_audioProbeControl = nullptr;
+ updateAudioProbe();
+ delete old;
+ }
+ } else if (control == m_videoProbeControl) {
+ if (!m_videoProbeControl->deref()) {
+ DirectShowVideoProbeControl *old = m_videoProbeControl;
+ m_videoProbeControl = nullptr;
+ updateVideoProbe();
+ delete old;
+ }
}
}
@@ -347,6 +390,10 @@ void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker)
m_pendingTasks |= SetAudioOutput;
if (m_videoOutput)
m_pendingTasks |= SetVideoOutput;
+ if (m_audioProbeControl)
+ m_pendingTasks |= SetAudioProbe;
+ if (m_videoProbeControl)
+ m_pendingTasks |= SetVideoProbe;
if (m_rate != 1.0)
m_pendingTasks |= SetRate;
@@ -432,6 +479,18 @@ void DirectShowPlayerService::doRender(QMutexLocker *locker)
m_executedTasks |= SetVideoOutput;
}
+ if (m_pendingTasks & SetAudioProbe) {
+ doSetAudioProbe(locker);
+ m_pendingTasks ^= SetAudioProbe;
+ m_executedTasks |= SetAudioProbe;
+ }
+
+ if (m_pendingTasks & SetVideoProbe) {
+ doSetVideoProbe(locker);
+ m_pendingTasks ^= SetVideoProbe;
+ m_executedTasks |= SetVideoProbe;
+ }
+
IFilterGraph2 *graph = m_graph;
graph->AddRef();
@@ -599,6 +658,9 @@ void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker)
control->Release();
}
+ doReleaseAudioProbe(locker);
+ doReleaseVideoProbe(locker);
+
if (m_source) {
m_source->Release();
m_source = 0;
@@ -612,6 +674,139 @@ void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker)
m_loop->wake();
}
+void DirectShowPlayerService::doSetVideoProbe(QMutexLocker *locker)
+{
+ Q_UNUSED(locker);
+
+ if (!m_graph) {
+ qCWarning(qtDirectShowPlugin, "Attempting to set a video probe without a valid graph!");
+ return;
+ }
+
+ // Create the sample grabber, if necessary.
+ if (!m_videoSampleGrabber) {
+ m_videoSampleGrabber = new DirectShowSampleGrabber;
+ connect(m_videoSampleGrabber, &DirectShowSampleGrabber::bufferAvailable, this, &DirectShowPlayerService::onVideoBufferAvailable);
+ }
+
+ if (FAILED(m_graph->AddFilter(m_videoSampleGrabber->filter(), L"Video Sample Grabber"))) {
+ qCWarning(qtDirectShowPlugin, "Failed to add the video sample grabber into the graph!");
+ return;
+ }
+
+ // TODO: Make util function for getting this, so it's easy to keep it in sync.
+ static const GUID subtypes[] = { MEDIASUBTYPE_ARGB32,
+ MEDIASUBTYPE_RGB32,
+ MEDIASUBTYPE_RGB24,
+ MEDIASUBTYPE_RGB565,
+ MEDIASUBTYPE_RGB555,
+ MEDIASUBTYPE_AYUV,
+ MEDIASUBTYPE_I420,
+ MEDIASUBTYPE_IYUV,
+ MEDIASUBTYPE_YV12,
+ MEDIASUBTYPE_UYVY,
+ MEDIASUBTYPE_YUYV,
+ MEDIASUBTYPE_YUY2,
+ MEDIASUBTYPE_NV12,
+ MEDIASUBTYPE_MJPG,
+ MEDIASUBTYPE_IMC1,
+ MEDIASUBTYPE_IMC2,
+ MEDIASUBTYPE_IMC3,
+ MEDIASUBTYPE_IMC4 };
+
+ // Negotiate the subtype
+ DirectShowMediaType mediaType(AM_MEDIA_TYPE { MEDIATYPE_Video });
+ const int items = (sizeof subtypes / sizeof(GUID));
+ bool connected = false;
+ for (int i = 0; i != items; ++i) {
+ mediaType->subtype = subtypes[i];
+ m_videoSampleGrabber->setMediaType(&mediaType);
+ if (SUCCEEDED(DirectShowUtils::connectFilters(m_graph, m_source, m_videoSampleGrabber->filter(), true)))
+ connected = true;
+ break;
+ }
+
+ if (!connected) {
+ qCWarning(qtDirectShowPlugin, "Unable to connect the video probe!");
+ return;
+ }
+
+ m_videoSampleGrabber->start(DirectShowSampleGrabber::CallbackMethod::BufferCB);
+}
+
+void DirectShowPlayerService::doSetAudioProbe(QMutexLocker *locker)
+{
+ Q_UNUSED(locker);
+
+ if (!m_graph) {
+ qCWarning(qtDirectShowPlugin, "Attempting to set an audio probe without a valid graph!");
+ return;
+ }
+
+ // Create the sample grabber, if necessary.
+ if (!m_audioSampleGrabber) {
+ m_audioSampleGrabber = new DirectShowSampleGrabber;
+ connect(m_audioSampleGrabber, &DirectShowSampleGrabber::bufferAvailable, this, &DirectShowPlayerService::onAudioBufferAvailable);
+ }
+
+ static const AM_MEDIA_TYPE mediaType { MEDIATYPE_Audio, MEDIASUBTYPE_PCM };
+ m_audioSampleGrabber->setMediaType(&mediaType);
+
+ if (FAILED(m_graph->AddFilter(m_audioSampleGrabber->filter(), L"Audio Sample Grabber"))) {
+ qCWarning(qtDirectShowPlugin, "Failed to add the audio sample grabber into the graph!");
+ return;
+ }
+
+ if (FAILED(DirectShowUtils::connectFilters(m_graph, m_source, m_audioSampleGrabber->filter(), true))) {
+ qCWarning(qtDirectShowPlugin, "Failed to connect the audio sample grabber");
+ return;
+ }
+
+ m_audioSampleGrabber->start(DirectShowSampleGrabber::CallbackMethod::BufferCB);
+}
+
+void DirectShowPlayerService::doReleaseVideoProbe(QMutexLocker *locker)
+{
+ Q_UNUSED(locker);
+
+ if (!m_graph)
+ return;
+
+ if (!m_videoSampleGrabber)
+ return;
+
+ m_videoSampleGrabber->stop();
+ HRESULT hr = m_graph->RemoveFilter(m_videoSampleGrabber->filter());
+ if (FAILED(hr)) {
+ qCWarning(qtDirectShowPlugin, "Failed to remove the video sample grabber!");
+ return;
+ }
+
+ m_videoSampleGrabber->deleteLater();
+ m_videoSampleGrabber = nullptr;
+}
+
+void DirectShowPlayerService::doReleaseAudioProbe(QMutexLocker *locker)
+{
+ Q_UNUSED(locker);
+
+ if (!m_graph)
+ return;
+
+ if (!m_audioSampleGrabber)
+ return;
+
+ m_audioSampleGrabber->stop();
+ HRESULT hr = m_graph->RemoveFilter(m_audioSampleGrabber->filter());
+ if (FAILED(hr)) {
+ qCWarning(qtDirectShowPlugin, "Failed to remove the audio sample grabber!");
+ return;
+ }
+
+ m_audioSampleGrabber->deleteLater();
+ m_audioSampleGrabber = nullptr;
+}
+
int DirectShowPlayerService::findStreamTypes(IBaseFilter *source) const
{
QVarLengthArray<IBaseFilter *, 16> filters;
@@ -1119,6 +1314,40 @@ void DirectShowPlayerService::setVideoOutput(IBaseFilter *filter)
}
}
+void DirectShowPlayerService::updateAudioProbe()
+{
+ QMutexLocker locker(&m_mutex);
+
+ // Set/Activate the audio probe.
+ if (m_graph) {
+ // If we don't have a audio probe, then stop and release the audio sample grabber
+ if (!m_audioProbeControl && (m_executedTasks & SetAudioProbe)) {
+ m_pendingTasks |= ReleaseAudioProbe;
+ ::SetEvent(m_taskHandle);
+ m_loop->wait(&m_mutex);
+ } else if (m_audioProbeControl) {
+ m_pendingTasks |= SetAudioProbe;
+ }
+ }
+}
+
+void DirectShowPlayerService::updateVideoProbe()
+{
+ QMutexLocker locker(&m_mutex);
+
+ // Set/Activate the video probe.
+ if (m_graph) {
+ // If we don't have a video probe, then stop and release the video sample grabber
+ if (!m_videoProbeControl && (m_executedTasks & SetVideoProbe)) {
+ m_pendingTasks |= ReleaseVideoProbe;
+ ::SetEvent(m_taskHandle);
+ m_loop->wait(&m_mutex);
+ } else if (m_videoProbeControl){
+ m_pendingTasks |= SetVideoProbe;
+ }
+ }
+}
+
void DirectShowPlayerService::doReleaseVideoOutput(QMutexLocker *locker)
{
Q_UNUSED(locker)
@@ -1215,6 +1444,97 @@ void DirectShowPlayerService::videoOutputChanged()
setVideoOutput(m_videoRendererControl->filter());
}
+void DirectShowPlayerService::onAudioBufferAvailable(double time, quint8 *buffer, long len)
+{
+ QMutexLocker locker(&m_mutex);
+ if (!m_audioProbeControl || !m_audioSampleGrabber)
+ return;
+
+ DirectShowMediaType mt(AM_MEDIA_TYPE { GUID_NULL });
+ const bool ok = m_audioSampleGrabber->getConnectedMediaType(&mt);
+ if (!ok)
+ return;
+
+ if (mt->majortype != MEDIATYPE_Audio)
+ return;
+
+ if (mt->subtype != MEDIASUBTYPE_PCM)
+ return;
+
+ const bool isWfx = ((mt->formattype == FORMAT_WaveFormatEx) && (mt->cbFormat >= sizeof(WAVEFORMATEX)));
+ WAVEFORMATEX *wfx = isWfx ? reinterpret_cast<WAVEFORMATEX *>(mt->pbFormat) : nullptr;
+
+ if (!wfx)
+ return;
+
+ if (wfx->wFormatTag != WAVE_FORMAT_PCM && wfx->wFormatTag != WAVE_FORMAT_EXTENSIBLE)
+ return;
+
+ if ((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) && (wfx->cbSize >= sizeof(WAVEFORMATEXTENSIBLE))) {
+ WAVEFORMATEXTENSIBLE *wfxe = reinterpret_cast<WAVEFORMATEXTENSIBLE *>(wfx);
+ if (wfxe->SubFormat != KSDATAFORMAT_SUBTYPE_PCM)
+ return;
+ }
+
+ QAudioFormat format;
+ format.setSampleRate(wfx->nSamplesPerSec);
+ format.setChannelCount(wfx->nChannels);
+ format.setSampleSize(wfx->wBitsPerSample);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ if (format.sampleSize() == 8)
+ format.setSampleType(QAudioFormat::UnSignedInt);
+ else
+ format.setSampleType(QAudioFormat::SignedInt);
+
+ const quint64 startTime = quint64(time * 1000.);
+ QAudioBuffer audioBuffer(QByteArray(reinterpret_cast<const char *>(buffer), len),
+ format,
+ startTime);
+
+ Q_EMIT m_audioProbeControl->audioBufferProbed(audioBuffer);
+}
+
+void DirectShowPlayerService::onVideoBufferAvailable(double time, quint8 *buffer, long len)
+{
+ Q_UNUSED(time);
+ Q_UNUSED(buffer);
+ Q_UNUSED(len);
+
+ QMutexLocker locker(&m_mutex);
+ if (!m_videoProbeControl || !m_videoSampleGrabber)
+ return;
+
+ DirectShowMediaType mt(AM_MEDIA_TYPE { GUID_NULL });
+ const bool ok = m_videoSampleGrabber->getConnectedMediaType(&mt);
+ if (!ok)
+ return;
+
+ if (mt->majortype != MEDIATYPE_Video)
+ return;
+
+ QVideoFrame::PixelFormat format = DirectShowMediaType::pixelFormatFromType(&mt);
+ if (format == QVideoFrame::Format_Invalid) {
+ qCWarning(qtDirectShowPlugin, "Invalid format, stopping video probes!");
+ m_videoSampleGrabber->stop();
+ return;
+ }
+
+ const QVideoSurfaceFormat &videoFormat = DirectShowMediaType::videoFormatFromType(&mt);
+ if (!videoFormat.isValid())
+ return;
+
+ const QSize &size = videoFormat.frameSize();
+
+ const int bytesPerLine = DirectShowMediaType::bytesPerLine(videoFormat);
+ QByteArray data(reinterpret_cast<const char *>(buffer), len);
+ QVideoFrame frame(new QMemoryVideoBuffer(data, bytesPerLine),
+ size,
+ format);
+
+ Q_EMIT m_videoProbeControl->videoFrameProbed(frame);
+}
+
void DirectShowPlayerService::graphEvent(QMutexLocker *locker)
{
Q_UNUSED(locker)
@@ -1403,6 +1723,16 @@ void DirectShowPlayerService::run()
m_executingTask = ReleaseVideoOutput;
doReleaseVideoOutput(&locker);
+ } else if (m_pendingTasks & ReleaseAudioProbe) {
+ m_pendingTasks ^= ReleaseAudioProbe;
+ m_executingTask = ReleaseAudioProbe;
+
+ doReleaseAudioProbe(&locker);
+ } else if (m_pendingTasks & ReleaseVideoProbe) {
+ m_pendingTasks ^= ReleaseVideoProbe;
+ m_executingTask = ReleaseVideoProbe;
+
+ doReleaseVideoProbe(&locker);
} else if (m_pendingTasks & SetUrlSource) {
m_pendingTasks ^= SetUrlSource;
m_executingTask = SetUrlSource;
@@ -1413,6 +1743,16 @@ void DirectShowPlayerService::run()
m_executingTask = SetStreamSource;
doSetStreamSource(&locker);
+ } else if (m_pendingTasks & SetAudioProbe) {
+ m_pendingTasks ^= SetAudioProbe;
+ m_executingTask = SetAudioProbe;
+
+ doSetAudioProbe(&locker);
+ } else if (m_pendingTasks & SetVideoProbe) {
+ m_pendingTasks ^= SetVideoProbe;
+ m_executingTask = SetVideoProbe;
+
+ doSetVideoProbe(&locker);
} else if (m_pendingTasks & Render) {
m_pendingTasks ^= Render;
m_executingTask = Render;
@@ -1454,3 +1794,5 @@ void DirectShowPlayerService::run()
m_executingTask = 0;
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h
index d933bd660..676d88fb5 100644
--- a/src/plugins/directshow/player/directshowplayerservice.h
+++ b/src/plugins/directshow/player/directshowplayerservice.h
@@ -55,17 +55,18 @@
#include <QtCore/qurl.h>
#include <QtCore/qwaitcondition.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowAudioEndpointControl;
class DirectShowMetaDataControl;
class DirectShowPlayerControl;
class DirectShowVideoRendererControl;
+class DirectShowAudioProbeControl;
+class DirectShowVideoProbeControl;
+class DirectShowSampleGrabber;
-QT_BEGIN_NAMESPACE
class QMediaContent;
class QVideoWindowControl;
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
class DirectShowPlayerService : public QMediaService
{
@@ -105,10 +106,16 @@ protected:
private Q_SLOTS:
void videoOutputChanged();
+ void onAudioBufferAvailable(double time, quint8 *buffer, long len);
+ void onVideoBufferAvailable(double time, quint8 *buffer, long len);
+
private:
void releaseGraph();
void updateStatus();
+ void updateAudioProbe();
+ void updateVideoProbe();
+
int findStreamTypes(IBaseFilter *source) const;
int findStreamType(IPin *pin) const;
@@ -129,29 +136,40 @@ private:
void doReleaseAudioOutput(QMutexLocker *locker);
void doReleaseVideoOutput(QMutexLocker *locker);
void doReleaseGraph(QMutexLocker *locker);
+ void doSetVideoProbe(QMutexLocker *locker);
+ void doSetAudioProbe(QMutexLocker *locker);
+ void doReleaseVideoProbe(QMutexLocker *locker);
+ void doReleaseAudioProbe(QMutexLocker *locker);
void graphEvent(QMutexLocker *locker);
enum Task
{
- Shutdown = 0x0001,
- SetUrlSource = 0x0002,
- SetStreamSource = 0x0004,
+ Shutdown = 0x00001,
+ SetUrlSource = 0x00002,
+ SetStreamSource = 0x00004,
SetSource = SetUrlSource | SetStreamSource,
- SetAudioOutput = 0x0008,
- SetVideoOutput = 0x0010,
+ SetAudioOutput = 0x00008,
+ SetVideoOutput = 0x00010,
SetOutputs = SetAudioOutput | SetVideoOutput,
- Render = 0x0020,
- FinalizeLoad = 0x0040,
- SetRate = 0x0080,
- Seek = 0x0100,
- Play = 0x0200,
- Pause = 0x0400,
- Stop = 0x0800,
- ReleaseGraph = 0x1000,
- ReleaseAudioOutput = 0x2000,
- ReleaseVideoOutput = 0x4000,
- ReleaseFilters = ReleaseGraph | ReleaseAudioOutput | ReleaseVideoOutput
+ SetAudioProbe = 0x00020,
+ SetVideoProbe = 0x00040,
+ SetProbes = SetAudioProbe | SetVideoProbe,
+ Render = 0x00080,
+ FinalizeLoad = 0x00100,
+ SetRate = 0x00200,
+ Seek = 0x00400,
+ Play = 0x00800,
+ Pause = 0x01000,
+ Stop = 0x02000,
+ ReleaseGraph = 0x04000,
+ ReleaseAudioOutput = 0x08000,
+ ReleaseVideoOutput = 0x10000,
+ ReleaseAudioProbe = 0x20000,
+ ReleaseVideoProbe = 0x40000,
+ ReleaseFilters = ReleaseGraph | ReleaseAudioOutput
+ | ReleaseVideoOutput | ReleaseAudioProbe
+ | ReleaseVideoProbe
};
enum Event
@@ -180,6 +198,10 @@ private:
DirectShowVideoRendererControl *m_videoRendererControl;
QVideoWindowControl *m_videoWindowControl;
DirectShowAudioEndpointControl *m_audioEndpointControl;
+ DirectShowAudioProbeControl *m_audioProbeControl;
+ DirectShowVideoProbeControl *m_videoProbeControl;
+ DirectShowSampleGrabber *m_audioSampleGrabber;
+ DirectShowSampleGrabber *m_videoSampleGrabber;
QThread *m_taskThread;
DirectShowEventLoop *m_loop;
@@ -213,5 +235,6 @@ private:
friend class DirectShowPlayerServiceThread;
};
+QT_END_NAMESPACE
#endif
diff --git a/src/plugins/directshow/player/directshowvideorenderercontrol.h b/src/plugins/directshow/player/directshowvideorenderercontrol.h
index 36c5b2248..ce515a329 100644
--- a/src/plugins/directshow/player/directshowvideorenderercontrol.h
+++ b/src/plugins/directshow/player/directshowvideorenderercontrol.h
@@ -47,13 +47,13 @@
#include <QtMultimedia/private/qtmultimedia-config_p.h>
+QT_BEGIN_NAMESPACE
+
class DirectShowEventLoop;
#if QT_CONFIG(evr)
class EVRCustomPresenter;
#endif
-QT_USE_NAMESPACE
-
class DirectShowVideoRendererControl : public QVideoRendererControl
{
Q_OBJECT
@@ -78,4 +78,6 @@ private:
#endif
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/player.pri b/src/plugins/directshow/player/player.pri
index 59ac5a330..9111cc545 100644
--- a/src/plugins/directshow/player/player.pri
+++ b/src/plugins/directshow/player/player.pri
@@ -3,6 +3,8 @@ INCLUDEPATH += $$PWD
QMAKE_USE += directshow
LIBS += -lgdi32
+mingw: LIBS_PRIVATE += -lksuser
+
qtHaveModule(widgets): QT += widgets
HEADERS += \
diff --git a/src/plugins/directshow/player/videosurfacefilter.cpp b/src/plugins/directshow/player/videosurfacefilter.cpp
index 13f767a85..656cd5a7c 100644
--- a/src/plugins/directshow/player/videosurfacefilter.cpp
+++ b/src/plugins/directshow/player/videosurfacefilter.cpp
@@ -49,6 +49,8 @@
#include <initguid.h>
+QT_BEGIN_NAMESPACE
+
Q_LOGGING_CATEGORY(qLcRenderFilter, "qt.multimedia.plugins.directshow.renderfilter")
// { e23cad72-153d-406c-bf3f-4c4b523d96f2 }
@@ -786,3 +788,5 @@ bool VideoSurfaceFilter::event(QEvent *e)
return QObject::event(e);
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/directshow/player/videosurfacefilter.h b/src/plugins/directshow/player/videosurfacefilter.h
index 6d6cc7593..ad253d564 100644
--- a/src/plugins/directshow/player/videosurfacefilter.h
+++ b/src/plugins/directshow/player/videosurfacefilter.h
@@ -49,8 +49,8 @@
#include <qwaitcondition.h>
QT_BEGIN_NAMESPACE
+
class QAbstractVideoSurface;
-QT_END_NAMESPACE
class DirectShowEventLoop;
class VideoSurfaceInputPin;
@@ -157,4 +157,6 @@ private:
friend class VideoSurfaceInputPin;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/directshow/player/vmr9videowindowcontrol.h b/src/plugins/directshow/player/vmr9videowindowcontrol.h
index 6f6e55362..ed3b53233 100644
--- a/src/plugins/directshow/player/vmr9videowindowcontrol.h
+++ b/src/plugins/directshow/player/vmr9videowindowcontrol.h
@@ -46,7 +46,7 @@
#include <d3d9.h>
#include <vmr9.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class Vmr9VideoWindowControl : public QVideoWindowControl
{
@@ -103,4 +103,6 @@ private:
bool m_fullScreen;
};
+QT_END_NAMESPACE
+
#endif