Refactoring wmf plugin
make mf startup/shutdwon inside plugin instead of player component make sourceresolver a common component for a wmf related tasks. Change-Id: I49cdc4fa512a62398a68cd2be2f522f567d11c7c Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
@@ -52,7 +52,6 @@
|
|||||||
#include "mfplayerservice.h"
|
#include "mfplayerservice.h"
|
||||||
#include "mfplayersession.h"
|
#include "mfplayersession.h"
|
||||||
#include "mfmetadatacontrol.h"
|
#include "mfmetadatacontrol.h"
|
||||||
int MFPlayerService::s_refCount = 0;
|
|
||||||
|
|
||||||
MFPlayerService::MFPlayerService(QObject *parent)
|
MFPlayerService::MFPlayerService(QObject *parent)
|
||||||
: QMediaService(parent)
|
: QMediaService(parent)
|
||||||
@@ -62,11 +61,6 @@ MFPlayerService::MFPlayerService(QObject *parent)
|
|||||||
#endif
|
#endif
|
||||||
, m_videoRendererControl(0)
|
, m_videoRendererControl(0)
|
||||||
{
|
{
|
||||||
s_refCount++;
|
|
||||||
if (s_refCount == 1) {
|
|
||||||
CoInitialize(NULL);
|
|
||||||
MFStartup(MF_VERSION);
|
|
||||||
}
|
|
||||||
m_audioEndpointControl = new MFAudioEndpointControl(this);
|
m_audioEndpointControl = new MFAudioEndpointControl(this);
|
||||||
m_session = new MFPlayerSession(this);
|
m_session = new MFPlayerSession(this);
|
||||||
m_player = new MFPlayerControl(m_session);
|
m_player = new MFPlayerControl(m_session);
|
||||||
@@ -85,12 +79,6 @@ MFPlayerService::~MFPlayerService()
|
|||||||
|
|
||||||
m_session->close();
|
m_session->close();
|
||||||
m_session->Release();
|
m_session->Release();
|
||||||
|
|
||||||
s_refCount--;
|
|
||||||
if (s_refCount == 0) {
|
|
||||||
MFShutdown();
|
|
||||||
CoUninitialize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMediaControl* MFPlayerService::requestControl(const char *name)
|
QMediaControl* MFPlayerService::requestControl(const char *name)
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
MFPlayerControl *m_player;
|
MFPlayerControl *m_player;
|
||||||
MFMetaDataControl *m_metaDataControl;
|
MFMetaDataControl *m_metaDataControl;
|
||||||
static int s_refCount;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
#include "mfmetadatacontrol.h"
|
#include "mfmetadatacontrol.h"
|
||||||
#include <Mferror.h>
|
#include <Mferror.h>
|
||||||
#include <nserror.h>
|
#include <nserror.h>
|
||||||
#include <sourceresolver.h>
|
#include "sourceresolver.h"
|
||||||
|
|
||||||
//#define DEBUG_MEDIAFOUNDATION
|
//#define DEBUG_MEDIAFOUNDATION
|
||||||
//#define TEST_STREAMING
|
//#define TEST_STREAMING
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ DEFINES += QMEDIA_MEDIAFOUNDATION_PLAYER
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/mfplayerservice.h \
|
$$PWD/mfplayerservice.h \
|
||||||
$$PWD/mfplayersession.h \
|
$$PWD/mfplayersession.h \
|
||||||
$$PWD/mfstream.h \
|
|
||||||
$$PWD/sourceresolver.h \
|
|
||||||
$$PWD/mfplayercontrol.h \
|
$$PWD/mfplayercontrol.h \
|
||||||
$$PWD/mfvideorenderercontrol.h \
|
$$PWD/mfvideorenderercontrol.h \
|
||||||
$$PWD/mfaudioendpointcontrol.h \
|
$$PWD/mfaudioendpointcontrol.h \
|
||||||
@@ -17,8 +15,6 @@ HEADERS += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/mfplayerservice.cpp \
|
$$PWD/mfplayerservice.cpp \
|
||||||
$$PWD/mfplayersession.cpp \
|
$$PWD/mfplayersession.cpp \
|
||||||
$$PWD/mfstream.cpp \
|
|
||||||
$$PWD/sourceresolver.cpp \
|
|
||||||
$$PWD/mfplayercontrol.cpp \
|
$$PWD/mfplayercontrol.cpp \
|
||||||
$$PWD/mfvideorenderercontrol.cpp \
|
$$PWD/mfvideorenderercontrol.cpp \
|
||||||
$$PWD/mfaudioendpointcontrol.cpp \
|
$$PWD/mfaudioendpointcontrol.cpp \
|
||||||
|
|||||||
@@ -12,8 +12,18 @@ load(qt_plugin)
|
|||||||
|
|
||||||
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
|
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
|
||||||
|
|
||||||
HEADERS += wmfserviceplugin.h
|
DEPENDPATH += .
|
||||||
SOURCES += wmfserviceplugin.cpp
|
INCLUDEPATH += .
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
wmfserviceplugin.h \
|
||||||
|
mfstream.h \
|
||||||
|
sourceresolver.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
wmfserviceplugin.cpp \
|
||||||
|
mfstream.cpp \
|
||||||
|
sourceresolver.cpp
|
||||||
|
|
||||||
include (player/player.pri)
|
include (player/player.pri)
|
||||||
|
|
||||||
|
|||||||
@@ -48,19 +48,46 @@
|
|||||||
#include "mfplayerservice.h"
|
#include "mfplayerservice.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <mfapi.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static int g_refCount = 0;
|
||||||
|
void addRefCount()
|
||||||
|
{
|
||||||
|
g_refCount++;
|
||||||
|
if (g_refCount == 1) {
|
||||||
|
CoInitialize(NULL);
|
||||||
|
MFStartup(MF_VERSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseRefCount()
|
||||||
|
{
|
||||||
|
g_refCount--;
|
||||||
|
if (g_refCount == 0) {
|
||||||
|
MFShutdown();
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QMediaService* WMFServicePlugin::create(QString const& key)
|
QMediaService* WMFServicePlugin::create(QString const& key)
|
||||||
{
|
{
|
||||||
#ifdef QMEDIA_MEDIAFOUNDATION_PLAYER
|
#ifdef QMEDIA_MEDIAFOUNDATION_PLAYER
|
||||||
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
|
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) {
|
||||||
|
addRefCount();
|
||||||
return new MFPlayerService;
|
return new MFPlayerService;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//qDebug() << "unsupported key:" << key;
|
//qDebug() << "unsupported key:" << key;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMFServicePlugin::release(QMediaService *service)
|
void WMFServicePlugin::release(QMediaService *service)
|
||||||
{
|
{
|
||||||
|
releaseRefCount();
|
||||||
delete service;
|
delete service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user