Add Windows Media Foundation backend for QMediaPlayer
Task-number:QTMOBILITY-1606 Reviewed-by: Michael Goddard (cherry picked from commit bdf3a9b39661cfb836245139d02e95e854646a7e) (cherry picked from commit 8d2370953eb32bf44a037244e0d9f9b484875f7a) Change-Id: I07790b8c540a04e4e19a3d018a4884a773e980bf Reviewed-on: http://codereview.qt.nokia.com/2086 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Ling Hu <ling.hu@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
e45902822c
commit
1e4dda9710
52
config.tests/wmf/main.cpp
Normal file
52
config.tests/wmf/main.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
#include <mferror.h>
|
||||
#include <d3d9.h>
|
||||
#include <evr9.h>
|
||||
#include <mmdeviceapi.h>
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
10
config.tests/wmf/wmf.pro
Normal file
10
config.tests/wmf/wmf.pro
Normal file
@@ -0,0 +1,10 @@
|
||||
CONFIG -= qt
|
||||
CONFIG += console
|
||||
TEMPLATE = app
|
||||
|
||||
# Input
|
||||
SOURCES += main.cpp
|
||||
|
||||
LIBS += -lstrmiids -ldmoguids -luuid -lmsdmo -lole32 -loleaut32 -lMf -lMfuuid -lMfplat -lPropsys
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ SOURCES += dsserviceplugin.cpp
|
||||
|
||||
!contains(config_test_wmsdk, yes): DEFINES += QT_NO_WMSDK
|
||||
|
||||
include (player/player.pri)
|
||||
contains(config_test_wmf, no): include (player/player.pri)
|
||||
include (camera/camera.pri)
|
||||
|
||||
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
#ifdef QMEDIA_DIRECTSHOW_CAMERA
|
||||
#include <dshow.h>
|
||||
#include "dscameraservice.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ win32 {
|
||||
|
||||
win32 {
|
||||
contains(config_test_directshow, yes): SUBDIRS += directshow
|
||||
contains(config_test_wmf, yes) : SUBDIRS += wmf
|
||||
}
|
||||
|
||||
simulator: SUBDIRS += simulator
|
||||
|
||||
351
src/plugins/wmf/player/evr9videowindowcontrol.cpp
Normal file
351
src/plugins/wmf/player/evr9videowindowcontrol.cpp
Normal file
@@ -0,0 +1,351 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "evr9videowindowcontrol.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
Evr9VideoWindowControl::Evr9VideoWindowControl(QObject *parent)
|
||||
: QVideoWindowControl(parent)
|
||||
, m_windowId(0)
|
||||
, m_dirtyValues(0)
|
||||
, m_aspectRatioMode(Qt::KeepAspectRatio)
|
||||
, m_brightness(0)
|
||||
, m_contrast(0)
|
||||
, m_hue(0)
|
||||
, m_saturation(0)
|
||||
, m_fullScreen(false)
|
||||
, m_currentActivate(0)
|
||||
, m_evrSink(0)
|
||||
, m_displayControl(0)
|
||||
{
|
||||
if (FAILED(MFCreateVideoRendererActivate(0, &m_currentActivate))) {
|
||||
qWarning() << "Failed to create evr video renderer activate!";
|
||||
return;
|
||||
}
|
||||
if (FAILED(m_currentActivate->ActivateObject(IID_IMFMediaSink, (LPVOID*)(&m_evrSink)))) {
|
||||
qWarning() << "Failed to activate evr media sink!";
|
||||
return;
|
||||
}
|
||||
if (FAILED(MFGetService(m_evrSink, MR_VIDEO_RENDER_SERVICE, IID_PPV_ARGS(&m_displayControl)))) {
|
||||
qWarning() << "Failed to get display control from evr media sink!";
|
||||
return;
|
||||
}
|
||||
if (FAILED(MFGetService(m_evrSink, MR_VIDEO_MIXER_SERVICE, IID_PPV_ARGS(&m_processor)))) {
|
||||
qWarning() << "Failed to get video processor from evr media sink!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Evr9VideoWindowControl::~Evr9VideoWindowControl()
|
||||
{
|
||||
if (m_processor)
|
||||
m_processor->Release();
|
||||
if (m_displayControl)
|
||||
m_displayControl->Release();
|
||||
if (m_evrSink)
|
||||
m_evrSink->Release();
|
||||
if (m_currentActivate) {
|
||||
m_currentActivate->ShutdownObject();
|
||||
m_currentActivate->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WId Evr9VideoWindowControl::winId() const
|
||||
{
|
||||
return m_windowId;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setWinId(WId id)
|
||||
{
|
||||
m_windowId = id;
|
||||
|
||||
if (QWidget *widget = QWidget::find(m_windowId)) {
|
||||
const QColor color = widget->palette().color(QPalette::Window);
|
||||
|
||||
m_windowColor = RGB(color.red(), color.green(), color.blue());
|
||||
}
|
||||
|
||||
if (m_displayControl) {
|
||||
m_displayControl->SetVideoWindow(m_windowId);
|
||||
}
|
||||
}
|
||||
|
||||
QRect Evr9VideoWindowControl::displayRect() const
|
||||
{
|
||||
return m_displayRect;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setDisplayRect(const QRect &rect)
|
||||
{
|
||||
m_displayRect = rect;
|
||||
|
||||
if (m_displayControl) {
|
||||
RECT displayRect = { rect.left(), rect.top(), rect.right() + 1, rect.bottom() + 1 };
|
||||
QSize sourceSize = nativeSize();
|
||||
|
||||
RECT sourceRect = { 0, 0, sourceSize.width(), sourceSize.height() };
|
||||
|
||||
if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) {
|
||||
QSize clippedSize = rect.size();
|
||||
clippedSize.scale(sourceRect.right, sourceRect.bottom, Qt::KeepAspectRatio);
|
||||
|
||||
sourceRect.left = (sourceRect.right - clippedSize.width()) / 2;
|
||||
sourceRect.top = (sourceRect.bottom - clippedSize.height()) / 2;
|
||||
sourceRect.right = sourceRect.left + clippedSize.width();
|
||||
sourceRect.bottom = sourceRect.top + clippedSize.height();
|
||||
}
|
||||
|
||||
if (sourceSize.width() > 0 && sourceSize.height() > 0) {
|
||||
MFVideoNormalizedRect sourceNormRect;
|
||||
sourceNormRect.left = float(sourceRect.left) / float(sourceRect.right);
|
||||
sourceNormRect.top = float(sourceRect.top) / float(sourceRect.bottom);
|
||||
sourceNormRect.right = float(sourceRect.right) / float(sourceRect.right);
|
||||
sourceNormRect.bottom = float(sourceRect.bottom) / float(sourceRect.bottom);
|
||||
m_displayControl->SetVideoPosition(&sourceNormRect, &displayRect);
|
||||
} else {
|
||||
m_displayControl->SetVideoPosition(NULL, &displayRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Evr9VideoWindowControl::isFullScreen() const
|
||||
{
|
||||
return m_fullScreen;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setFullScreen(bool fullScreen)
|
||||
{
|
||||
if (m_fullScreen == fullScreen)
|
||||
return;
|
||||
emit fullScreenChanged(m_fullScreen = fullScreen);
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::repaint()
|
||||
{
|
||||
QSize size = nativeSize();
|
||||
if (size.width() > 0 && size.height() > 0
|
||||
&& m_displayControl
|
||||
&& SUCCEEDED(m_displayControl->RepaintVideo())) {
|
||||
return;
|
||||
}
|
||||
|
||||
PAINTSTRUCT paint;
|
||||
if (HDC dc = ::BeginPaint(m_windowId, &paint)) {
|
||||
HPEN pen = ::CreatePen(PS_SOLID, 1, m_windowColor);
|
||||
HBRUSH brush = ::CreateSolidBrush(m_windowColor);
|
||||
::SelectObject(dc, pen);
|
||||
::SelectObject(dc, brush);
|
||||
|
||||
::Rectangle(
|
||||
dc,
|
||||
m_displayRect.left(),
|
||||
m_displayRect.top(),
|
||||
m_displayRect.right() + 1,
|
||||
m_displayRect.bottom() + 1);
|
||||
|
||||
::DeleteObject(pen);
|
||||
::DeleteObject(brush);
|
||||
::EndPaint(m_windowId, &paint);
|
||||
}
|
||||
}
|
||||
|
||||
QSize Evr9VideoWindowControl::nativeSize() const
|
||||
{
|
||||
QSize size;
|
||||
if (m_displayControl) {
|
||||
SIZE sourceSize;
|
||||
if (SUCCEEDED(m_displayControl->GetNativeVideoSize(&sourceSize, 0)))
|
||||
size = QSize(sourceSize.cx, sourceSize.cy);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
Qt::AspectRatioMode Evr9VideoWindowControl::aspectRatioMode() const
|
||||
{
|
||||
return m_aspectRatioMode;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
{
|
||||
m_aspectRatioMode = mode;
|
||||
|
||||
if (m_displayControl) {
|
||||
switch (mode) {
|
||||
case Qt::IgnoreAspectRatio:
|
||||
//comment from MSDN: Do not maintain the aspect ratio of the video. Stretch the video to fit the output rectangle.
|
||||
m_displayControl->SetAspectRatioMode(MFVideoARMode_None);
|
||||
break;
|
||||
case Qt::KeepAspectRatio:
|
||||
//comment from MSDN: Preserve the aspect ratio of the video by letterboxing or within the output rectangle.
|
||||
m_displayControl->SetAspectRatioMode(MFVideoARMode_PreservePicture);
|
||||
break;
|
||||
case Qt::KeepAspectRatioByExpanding:
|
||||
//for this mode, more adjustment will be done in setDisplayRect
|
||||
m_displayControl->SetAspectRatioMode(MFVideoARMode_PreservePicture);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
setDisplayRect(m_displayRect);
|
||||
}
|
||||
}
|
||||
|
||||
int Evr9VideoWindowControl::brightness() const
|
||||
{
|
||||
return m_brightness;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setBrightness(int brightness)
|
||||
{
|
||||
if (m_brightness == brightness)
|
||||
return;
|
||||
|
||||
m_brightness = brightness;
|
||||
|
||||
m_dirtyValues |= DXVA2_ProcAmp_Brightness;
|
||||
|
||||
setProcAmpValues();
|
||||
|
||||
emit brightnessChanged(brightness);
|
||||
}
|
||||
|
||||
int Evr9VideoWindowControl::contrast() const
|
||||
{
|
||||
return m_contrast;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setContrast(int contrast)
|
||||
{
|
||||
if (m_contrast == contrast)
|
||||
return;
|
||||
|
||||
m_contrast = contrast;
|
||||
|
||||
m_dirtyValues |= DXVA2_ProcAmp_Contrast;
|
||||
|
||||
setProcAmpValues();
|
||||
|
||||
emit contrastChanged(contrast);
|
||||
}
|
||||
|
||||
int Evr9VideoWindowControl::hue() const
|
||||
{
|
||||
return m_hue;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setHue(int hue)
|
||||
{
|
||||
if (m_hue == hue)
|
||||
return;
|
||||
|
||||
m_hue = hue;
|
||||
|
||||
m_dirtyValues |= DXVA2_ProcAmp_Hue;
|
||||
|
||||
setProcAmpValues();
|
||||
|
||||
emit hueChanged(hue);
|
||||
}
|
||||
|
||||
int Evr9VideoWindowControl::saturation() const
|
||||
{
|
||||
return m_saturation;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setSaturation(int saturation)
|
||||
{
|
||||
if (m_saturation == saturation)
|
||||
return;
|
||||
|
||||
m_saturation = saturation;
|
||||
|
||||
m_dirtyValues |= DXVA2_ProcAmp_Saturation;
|
||||
|
||||
setProcAmpValues();
|
||||
|
||||
emit saturationChanged(saturation);
|
||||
}
|
||||
|
||||
IMFActivate* Evr9VideoWindowControl::currentActivate() const
|
||||
{
|
||||
return m_currentActivate;
|
||||
}
|
||||
|
||||
void Evr9VideoWindowControl::setProcAmpValues()
|
||||
{
|
||||
if (m_processor) {
|
||||
DXVA2_ProcAmpValues values;
|
||||
if (m_dirtyValues & DXVA2_ProcAmp_Brightness) {
|
||||
values.Brightness = scaleProcAmpValue(DXVA2_ProcAmp_Brightness, m_brightness);
|
||||
}
|
||||
if (m_dirtyValues & DXVA2_ProcAmp_Contrast) {
|
||||
values.Contrast = scaleProcAmpValue(DXVA2_ProcAmp_Contrast, m_contrast);
|
||||
}
|
||||
if (m_dirtyValues & DXVA2_ProcAmp_Hue) {
|
||||
values.Hue = scaleProcAmpValue(DXVA2_ProcAmp_Hue, m_hue);
|
||||
}
|
||||
if (m_dirtyValues & DXVA2_ProcAmp_Saturation) {
|
||||
values.Saturation = scaleProcAmpValue(DXVA2_ProcAmp_Saturation, m_saturation);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(m_processor->SetProcAmpValues(0, &values))) {
|
||||
m_dirtyValues = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DXVA2_Fixed32 Evr9VideoWindowControl::scaleProcAmpValue(DWORD prop, int value) const
|
||||
{
|
||||
float scaledValue = 0.0;
|
||||
|
||||
DXVA2_ValueRange range;
|
||||
if (SUCCEEDED(m_processor->GetProcAmpRange(prop, &range))) {
|
||||
scaledValue = DXVA2FixedToFloat(range.DefaultValue);
|
||||
if (value > 0)
|
||||
scaledValue += float(value) * (DXVA2FixedToFloat(range.MaxValue) - DXVA2FixedToFloat(range.DefaultValue)) / 100;
|
||||
else if (value < 0)
|
||||
scaledValue -= float(value) * (DXVA2FixedToFloat(range.MinValue) - DXVA2FixedToFloat(range.DefaultValue)) / 100;
|
||||
}
|
||||
|
||||
return DXVA2FloatToFixed(scaledValue);
|
||||
}
|
||||
111
src/plugins/wmf/player/evr9videowindowcontrol.h
Normal file
111
src/plugins/wmf/player/evr9videowindowcontrol.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef EVR9VIDEOWINDOWCONTROL_H
|
||||
#define EVR9VIDEOWINDOWCONTROL_H
|
||||
|
||||
#include "../../src/multimedia/qvideowindowcontrol.h"
|
||||
|
||||
#include <Mfidl.h>
|
||||
#include <d3d9.h>
|
||||
#include <Evr9.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class Evr9VideoWindowControl : public QVideoWindowControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Evr9VideoWindowControl(QObject *parent = 0);
|
||||
~Evr9VideoWindowControl();
|
||||
|
||||
WId winId() const;
|
||||
void setWinId(WId id);
|
||||
|
||||
QRect displayRect() const;
|
||||
void setDisplayRect(const QRect &rect);
|
||||
|
||||
bool isFullScreen() const;
|
||||
void setFullScreen(bool fullScreen);
|
||||
|
||||
void repaint();
|
||||
|
||||
QSize nativeSize() const;
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode);
|
||||
|
||||
int brightness() const;
|
||||
void setBrightness(int brightness);
|
||||
|
||||
int contrast() const;
|
||||
void setContrast(int contrast);
|
||||
|
||||
int hue() const;
|
||||
void setHue(int hue);
|
||||
|
||||
int saturation() const;
|
||||
void setSaturation(int saturation);
|
||||
|
||||
IMFActivate* currentActivate() const;
|
||||
|
||||
private:
|
||||
void setProcAmpValues();
|
||||
DXVA2_Fixed32 scaleProcAmpValue(DWORD prop, int value) const;
|
||||
|
||||
WId m_windowId;
|
||||
COLORREF m_windowColor;
|
||||
DWORD m_dirtyValues;
|
||||
Qt::AspectRatioMode m_aspectRatioMode;
|
||||
QRect m_displayRect;
|
||||
int m_brightness;
|
||||
int m_contrast;
|
||||
int m_hue;
|
||||
int m_saturation;
|
||||
bool m_fullScreen;
|
||||
|
||||
IMFActivate *m_currentActivate;
|
||||
IMFMediaSink *m_evrSink;
|
||||
IMFVideoDisplayControl *m_displayControl;
|
||||
IMFVideoProcessor *m_processor;
|
||||
};
|
||||
|
||||
#endif
|
||||
162
src/plugins/wmf/player/mfaudioendpointcontrol.cpp
Normal file
162
src/plugins/wmf/player/mfaudioendpointcontrol.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "QtCore/qdebug.h"
|
||||
#include "mfaudioendpointcontrol.h"
|
||||
|
||||
MFAudioEndpointControl::MFAudioEndpointControl(QObject *parent)
|
||||
: QAudioEndpointSelector(parent)
|
||||
, m_currentActivate(0)
|
||||
{
|
||||
updateEndpoints();
|
||||
setActiveEndpoint(m_defaultEndpoint);
|
||||
}
|
||||
|
||||
MFAudioEndpointControl::~MFAudioEndpointControl()
|
||||
{
|
||||
foreach (LPWSTR wstrID, m_devices)
|
||||
CoTaskMemFree(wstrID);
|
||||
|
||||
if (m_currentActivate)
|
||||
m_currentActivate->Release();
|
||||
}
|
||||
|
||||
QList<QString> MFAudioEndpointControl::availableEndpoints() const
|
||||
{
|
||||
return m_devices.keys();
|
||||
}
|
||||
|
||||
QString MFAudioEndpointControl::endpointDescription(const QString &name) const
|
||||
{
|
||||
return name.section(QLatin1Char('\\'), -1);
|
||||
}
|
||||
|
||||
QString MFAudioEndpointControl::defaultEndpoint() const
|
||||
{
|
||||
return m_defaultEndpoint;
|
||||
}
|
||||
|
||||
QString MFAudioEndpointControl::activeEndpoint() const
|
||||
{
|
||||
return m_activeEndpoint;
|
||||
}
|
||||
|
||||
void MFAudioEndpointControl::setActiveEndpoint(const QString &name)
|
||||
{
|
||||
if (m_activeEndpoint == name)
|
||||
return;
|
||||
QMap<QString, LPWSTR>::iterator it = m_devices.find(name);
|
||||
if (it == m_devices.end())
|
||||
return;
|
||||
|
||||
LPWSTR wstrID = *it;
|
||||
IMFActivate *activate = NULL;
|
||||
HRESULT hr = MFCreateAudioRendererActivate(&activate);
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Failed to create audio renderer activate";
|
||||
return;
|
||||
}
|
||||
|
||||
if (wstrID) {
|
||||
hr = activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, wstrID);
|
||||
} else {
|
||||
//This is the default one that has been inserted in updateEndpoints(),
|
||||
//so give the activate a hint that we want to use the device for multimedia playback
|
||||
//then the media foundation will choose an apropriate one.
|
||||
|
||||
//from MSDN:
|
||||
//The ERole enumeration defines constants that indicate the role that the system has assigned to an audio endpoint device.
|
||||
//eMultimedia: Music, movies, narration, and live music recording.
|
||||
hr = activate->SetUINT32(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ROLE, eMultimedia);
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Failed to set attribute for audio device" << name;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_currentActivate)
|
||||
m_currentActivate->Release();
|
||||
m_currentActivate = activate;
|
||||
m_activeEndpoint = name;
|
||||
}
|
||||
|
||||
IMFActivate* MFAudioEndpointControl::currentActivate() const
|
||||
{
|
||||
return m_currentActivate;
|
||||
}
|
||||
|
||||
void MFAudioEndpointControl::updateEndpoints()
|
||||
{
|
||||
m_defaultEndpoint = QString::fromLatin1("Default");
|
||||
m_devices.insert(m_defaultEndpoint, NULL);
|
||||
|
||||
IMMDeviceEnumerator *pEnum = NULL;
|
||||
HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
|
||||
NULL, CLSCTX_ALL,
|
||||
__uuidof(IMMDeviceEnumerator),
|
||||
(void**)&pEnum);
|
||||
if (SUCCEEDED(hr)) {
|
||||
IMMDeviceCollection *pDevices = NULL;
|
||||
hr = pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDevices);
|
||||
if (SUCCEEDED(hr)) {
|
||||
UINT count;
|
||||
hr = pDevices->GetCount(&count);
|
||||
if (SUCCEEDED(hr)) {
|
||||
for (UINT i = 0; i < count; ++i) {
|
||||
IMMDevice *pDevice = NULL;
|
||||
hr = pDevices->Item(i, &pDevice);
|
||||
if (SUCCEEDED(hr)) {
|
||||
LPWSTR wstrID = NULL;
|
||||
hr = pDevice->GetId(&wstrID);
|
||||
if (SUCCEEDED(hr)) {
|
||||
QString deviceId = QString::fromWCharArray(wstrID);
|
||||
m_devices.insert(deviceId, wstrID);
|
||||
}
|
||||
pDevice->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
pDevices->Release();
|
||||
}
|
||||
pEnum->Release();
|
||||
}
|
||||
}
|
||||
84
src/plugins/wmf/player/mfaudioendpointcontrol.h
Normal file
84
src/plugins/wmf/player/mfaudioendpointcontrol.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MFAUDIOENDPOINTCONTROL_H
|
||||
#define MFAUDIOENDPOINTCONTROL_H
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
#include <mmdeviceapi.h>
|
||||
|
||||
#include "../../src/multimedia/qaudioendpointselector.h"
|
||||
|
||||
class MFPlayerService;
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class MFAudioEndpointControl : public QAudioEndpointSelector
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MFAudioEndpointControl(QObject *parent = 0);
|
||||
~MFAudioEndpointControl();
|
||||
|
||||
QList<QString> availableEndpoints() const;
|
||||
|
||||
QString endpointDescription(const QString &name) const;
|
||||
|
||||
QString defaultEndpoint() const;
|
||||
QString activeEndpoint() const;
|
||||
|
||||
void setActiveEndpoint(const QString& name);
|
||||
|
||||
IMFActivate* currentActivate() const;
|
||||
|
||||
private:
|
||||
void updateEndpoints();
|
||||
|
||||
QString m_defaultEndpoint;
|
||||
QString m_activeEndpoint;
|
||||
QMap<QString, LPWSTR> m_devices;
|
||||
IMFActivate *m_currentActivate;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
246
src/plugins/wmf/player/mfmetadatacontrol.cpp
Normal file
246
src/plugins/wmf/player/mfmetadatacontrol.cpp
Normal file
@@ -0,0 +1,246 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mfmetadatacontrol.h"
|
||||
#include "mfplayerservice.h"
|
||||
#include "Propkey.h"
|
||||
|
||||
//#define DEBUG_MEDIAFOUNDATION
|
||||
|
||||
MFMetaDataControl::MFMetaDataControl(QObject *parent)
|
||||
: QMetaDataReaderControl(parent)
|
||||
, m_metaData(0)
|
||||
, m_content(0)
|
||||
{
|
||||
}
|
||||
|
||||
MFMetaDataControl::~MFMetaDataControl()
|
||||
{
|
||||
if (m_metaData)
|
||||
m_metaData->Release();
|
||||
if (m_content)
|
||||
m_content->Release();
|
||||
}
|
||||
|
||||
bool MFMetaDataControl::isMetaDataAvailable() const
|
||||
{
|
||||
return m_content || m_metaData;
|
||||
}
|
||||
|
||||
QVariant MFMetaDataControl::metaData(QtMultimediaKit::MetaData key) const
|
||||
{
|
||||
QVariant value;
|
||||
if (!isMetaDataAvailable())
|
||||
return value;
|
||||
|
||||
int index = m_availableMetaDatas.indexOf(key);
|
||||
if (index < 0)
|
||||
return value;
|
||||
|
||||
PROPVARIANT var;
|
||||
PropVariantInit(&var);
|
||||
HRESULT hr = S_FALSE;
|
||||
if (m_content)
|
||||
hr = m_content->GetValue(m_commonKeys[index], &var);
|
||||
else if (m_metaData)
|
||||
hr = m_metaData->GetProperty(m_commonNames[index].utf16(), &var);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
value = convertValue(var);
|
||||
|
||||
PropVariantClear(&var);
|
||||
return value;
|
||||
}
|
||||
|
||||
QVariant MFMetaDataControl::convertValue(const PROPVARIANT& var) const
|
||||
{
|
||||
QVariant value;
|
||||
//form MSDN: http://msdn.microsoft.com/en-us/library/ff384862%28v=VS.85%29.aspx
|
||||
//it seems that those 4 types are enough for media foundation metadata
|
||||
//add more later if necessary
|
||||
switch (var.vt) {
|
||||
case VT_LPWSTR:
|
||||
value = QString::fromUtf16(var.pwszVal);
|
||||
break;
|
||||
case VT_UI4:
|
||||
value = uint(var.ulVal);
|
||||
break;
|
||||
case VT_UI8:
|
||||
value = qulonglong(var.uhVal.QuadPart);
|
||||
break;
|
||||
case VT_BOOL:
|
||||
value = bool(var.boolVal);
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
QList<QtMultimediaKit::MetaData> MFMetaDataControl::availableMetaData() const
|
||||
{
|
||||
return m_availableMetaDatas;
|
||||
}
|
||||
|
||||
QVariant MFMetaDataControl::extendedMetaData(const QString &key) const
|
||||
{
|
||||
QVariant value;
|
||||
HRESULT hr = S_FALSE;
|
||||
PROPVARIANT var;
|
||||
PropVariantInit(&var);
|
||||
if (m_content) {
|
||||
int index = m_extendedMetaDatas.indexOf(key);
|
||||
if (index >= 0) {
|
||||
hr = m_content->GetValue(m_extendedKeys[index], &var);
|
||||
}
|
||||
} else if (m_metaData) {
|
||||
hr = m_metaData->GetProperty(key.utf16(), &var);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
value = convertValue(var);
|
||||
|
||||
PropVariantClear(&var);
|
||||
return value;
|
||||
}
|
||||
|
||||
QStringList MFMetaDataControl::availableExtendedMetaData() const
|
||||
{
|
||||
return m_extendedMetaDatas;
|
||||
}
|
||||
|
||||
void MFMetaDataControl::updateSource(IMFPresentationDescriptor* sourcePD, IMFMediaSource* mediaSource)
|
||||
{
|
||||
if (m_metaData) {
|
||||
m_metaData->Release();
|
||||
m_metaData = 0;
|
||||
}
|
||||
|
||||
if (m_content) {
|
||||
m_content->Release();
|
||||
m_content = 0;
|
||||
}
|
||||
|
||||
m_availableMetaDatas.clear();
|
||||
m_commonKeys.clear();
|
||||
m_commonNames.clear();
|
||||
m_extendedMetaDatas.clear();
|
||||
m_extendedKeys.clear();
|
||||
|
||||
if (SUCCEEDED(MFGetService(mediaSource, MF_PROPERTY_HANDLER_SERVICE, IID_PPV_ARGS(&m_content)))) {
|
||||
DWORD cProps;
|
||||
if (SUCCEEDED(m_content->GetCount(&cProps))) {
|
||||
for (DWORD i = 0; i < cProps; i++)
|
||||
{
|
||||
PROPERTYKEY key;
|
||||
if (FAILED(m_content->GetAt(i, &key)))
|
||||
continue;
|
||||
bool common = true;
|
||||
if (key == PKEY_Author) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Author);
|
||||
} else if (key == PKEY_Title) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Title);
|
||||
} else if (key == PKEY_ParentalRating) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::ParentalRating);
|
||||
} else if (key == PKEY_Comment) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Description);
|
||||
} else if (key == PKEY_Copyright) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Copyright);
|
||||
//TODO: add more common keys
|
||||
} else {
|
||||
common = false;
|
||||
//TODO: add more extended keys
|
||||
}
|
||||
if (common)
|
||||
m_commonKeys.push_back(key);
|
||||
}
|
||||
} else {
|
||||
m_content->Release();
|
||||
m_content = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_content) {
|
||||
//fallback to Vista approach
|
||||
IMFMetadataProvider *provider = NULL;
|
||||
if (SUCCEEDED(MFGetService(mediaSource, MF_METADATA_PROVIDER_SERVICE, IID_PPV_ARGS(&provider)))) {
|
||||
if (SUCCEEDED(provider->GetMFMetadata(sourcePD, 0, 0, &m_metaData))) {
|
||||
PROPVARIANT varNames;
|
||||
PropVariantInit(&varNames);
|
||||
if (SUCCEEDED(m_metaData->GetAllPropertyNames(&varNames)) && varNames.vt == (VT_VECTOR | VT_LPWSTR)) {
|
||||
ULONG cElements = varNames.calpwstr.cElems;
|
||||
for (ULONG i = 0; i < cElements; i++)
|
||||
{
|
||||
const WCHAR* sName = varNames.calpwstr.pElems[i];
|
||||
#ifdef DEBUG_MEDIAFOUNDATION
|
||||
qDebug() << "metadata: " << QString::fromUtf16(sName);
|
||||
#endif
|
||||
bool common = true;
|
||||
if (wcscmp(sName, L"Author") == 0) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Author);
|
||||
} else if (wcscmp(sName, L"Title") == 0) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Title);
|
||||
} else if (wcscmp(sName, L"Rating") == 0) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::ParentalRating);
|
||||
} else if (wcscmp(sName, L"Description") == 0) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Description);
|
||||
} else if (wcscmp(sName, L"Copyright") == 0) {
|
||||
m_availableMetaDatas.push_back(QtMultimediaKit::Copyright);
|
||||
//TODO: add more common keys
|
||||
} else {
|
||||
common = false;
|
||||
m_extendedMetaDatas.push_back(QString::fromUtf16(sName));
|
||||
}
|
||||
if (common)
|
||||
m_commonNames.push_back(QString::fromUtf16(sName));
|
||||
}
|
||||
}
|
||||
PropVariantClear(&varNames);
|
||||
} else {
|
||||
qWarning("Failed to get IMFMetadata");
|
||||
}
|
||||
provider->Release();
|
||||
} else {
|
||||
qWarning("Failed to get IMFMetadataProvider from source");
|
||||
}
|
||||
}
|
||||
|
||||
emit metaDataChanged();
|
||||
emit metaDataAvailableChanged(m_metaData || m_content);
|
||||
}
|
||||
80
src/plugins/wmf/player/mfmetadatacontrol.h
Normal file
80
src/plugins/wmf/player/mfmetadatacontrol.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MFMETADATACONTROL_H
|
||||
#define MFMETADATACONTROL_H
|
||||
|
||||
#include <qmetadatareadercontrol.h>
|
||||
#include "Mfidl.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class MFMetaDataControl : public QMetaDataReaderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MFMetaDataControl(QObject *parent = 0);
|
||||
~MFMetaDataControl();
|
||||
|
||||
bool isMetaDataAvailable() const;
|
||||
|
||||
QVariant metaData(QtMultimediaKit::MetaData key) const;
|
||||
QList<QtMultimediaKit::MetaData> availableMetaData() const;
|
||||
|
||||
QVariant extendedMetaData(const QString &key) const;
|
||||
QStringList availableExtendedMetaData() const;
|
||||
|
||||
void updateSource(IMFPresentationDescriptor* sourcePD, IMFMediaSource* mediaSource);
|
||||
|
||||
private:
|
||||
QVariant convertValue(const PROPVARIANT& var) const;
|
||||
IPropertyStore *m_content; //for Windows7
|
||||
IMFMetadata *m_metaData; //for Vista
|
||||
|
||||
QList<QtMultimediaKit::MetaData> m_availableMetaDatas;
|
||||
QList<PROPERTYKEY> m_commonKeys; //for Windows7
|
||||
QStringList m_commonNames; //for Vista
|
||||
|
||||
QStringList m_extendedMetaDatas;
|
||||
QList<PROPERTYKEY> m_extendedKeys; //for Windows7
|
||||
};
|
||||
|
||||
#endif
|
||||
311
src/plugins/wmf/player/mfplayercontrol.cpp
Normal file
311
src/plugins/wmf/player/mfplayercontrol.cpp
Normal file
@@ -0,0 +1,311 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "mfplayercontrol.h"
|
||||
#include <qtcore/qdebug.h>
|
||||
|
||||
//#define DEBUG_MEDIAFOUNDATION
|
||||
|
||||
MFPlayerControl::MFPlayerControl(MFPlayerSession *session)
|
||||
: QMediaPlayerControl(session)
|
||||
, m_state(QMediaPlayer::StoppedState)
|
||||
, m_videoAvailable(false)
|
||||
, m_audioAvailable(false)
|
||||
, m_duration(-1)
|
||||
, m_seekable(false)
|
||||
, m_session(session)
|
||||
{
|
||||
QObject::connect(m_session, SIGNAL(statusChanged()), this, SLOT(handleStatusChanged()));
|
||||
QObject::connect(m_session, SIGNAL(videoAvailable()), this, SLOT(handleVideoAvailable()));
|
||||
QObject::connect(m_session, SIGNAL(audioAvailable()), this, SLOT(handleAudioAvailable()));
|
||||
QObject::connect(m_session, SIGNAL(durationUpdate(qint64)), this, SLOT(handleDurationUpdate(qint64)));
|
||||
QObject::connect(m_session, SIGNAL(seekableUpdate(bool)), this, SLOT(handleSeekableUpdate(bool)));
|
||||
QObject::connect(m_session, SIGNAL(error(QMediaPlayer::Error, QString, bool)), this, SLOT(handleError(QMediaPlayer::Error, QString, bool)));
|
||||
QObject::connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64)));
|
||||
QObject::connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
|
||||
QObject::connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
|
||||
QObject::connect(m_session, SIGNAL(playbackRateChanged(qreal)), this, SIGNAL(playbackRateChanged(qreal)));
|
||||
QObject::connect(m_session, SIGNAL(bufferStatusChanged(int)), this, SIGNAL(bufferStatusChanged(int)));
|
||||
}
|
||||
|
||||
MFPlayerControl::~MFPlayerControl()
|
||||
{
|
||||
}
|
||||
|
||||
void MFPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream)
|
||||
{
|
||||
stop();
|
||||
m_media = media;
|
||||
m_stream = stream;
|
||||
resetAudioVideoAvailable();
|
||||
handleDurationUpdate(-1);
|
||||
handleSeekableUpdate(false);
|
||||
m_session->load(media, stream);
|
||||
emit mediaChanged(m_media);
|
||||
}
|
||||
|
||||
void MFPlayerControl::play()
|
||||
{
|
||||
if (m_state == QMediaPlayer::PlayingState)
|
||||
return;
|
||||
if (QMediaPlayer::InvalidMedia == m_session->status())
|
||||
m_session->load(m_media, m_stream);
|
||||
|
||||
switch (m_session->status()) {
|
||||
case QMediaPlayer::UnknownMediaStatus:
|
||||
case QMediaPlayer::NoMedia:
|
||||
case QMediaPlayer::InvalidMedia:
|
||||
return;
|
||||
case QMediaPlayer::LoadedMedia:
|
||||
case QMediaPlayer::BufferingMedia:
|
||||
case QMediaPlayer::BufferedMedia:
|
||||
case QMediaPlayer::EndOfMedia:
|
||||
changeState(QMediaPlayer::PlayingState);
|
||||
m_session->start();
|
||||
break;
|
||||
default: //Loading/Stalled
|
||||
changeState(QMediaPlayer::PlayingState);
|
||||
break;
|
||||
}
|
||||
refreshState();
|
||||
}
|
||||
|
||||
void MFPlayerControl::pause()
|
||||
{
|
||||
if (m_state != QMediaPlayer::PlayingState)
|
||||
return;
|
||||
changeState(QMediaPlayer::PausedState);
|
||||
m_session->pause();
|
||||
refreshState();
|
||||
}
|
||||
|
||||
void MFPlayerControl::stop()
|
||||
{
|
||||
if (m_state == QMediaPlayer::StoppedState)
|
||||
return;
|
||||
changeState(QMediaPlayer::StoppedState);
|
||||
m_session->stop();
|
||||
refreshState();
|
||||
}
|
||||
|
||||
void MFPlayerControl::changeState(QMediaPlayer::State state)
|
||||
{
|
||||
if (m_state == state)
|
||||
return;
|
||||
m_state = state;
|
||||
m_stateDirty = true;
|
||||
}
|
||||
|
||||
void MFPlayerControl::refreshState()
|
||||
{
|
||||
if (!m_stateDirty)
|
||||
return;
|
||||
m_stateDirty = false;
|
||||
#ifdef DEBUG_MEDIAFOUNDATION
|
||||
qDebug() << "MFPlayerControl::emit stateChanged" << m_state;
|
||||
#endif
|
||||
emit stateChanged(m_state);
|
||||
}
|
||||
|
||||
void MFPlayerControl::handleStatusChanged()
|
||||
{
|
||||
QMediaPlayer::MediaStatus status = m_session->status();
|
||||
switch (status) {
|
||||
case QMediaPlayer::EndOfMedia:
|
||||
changeState(QMediaPlayer::StoppedState);
|
||||
break;
|
||||
case QMediaPlayer::InvalidMedia:
|
||||
break;
|
||||
case QMediaPlayer::LoadedMedia:
|
||||
case QMediaPlayer::BufferingMedia:
|
||||
case QMediaPlayer::BufferedMedia:
|
||||
if (m_state == QMediaPlayer::PlayingState)
|
||||
m_session->start();
|
||||
break;
|
||||
}
|
||||
emit mediaStatusChanged(m_session->status());
|
||||
refreshState();
|
||||
}
|
||||
|
||||
void MFPlayerControl::handleVideoAvailable()
|
||||
{
|
||||
if (m_videoAvailable)
|
||||
return;
|
||||
m_videoAvailable = true;
|
||||
emit videoAvailableChanged(m_videoAvailable);
|
||||
}
|
||||
|
||||
void MFPlayerControl::handleAudioAvailable()
|
||||
{
|
||||
if (m_audioAvailable)
|
||||
return;
|
||||
m_audioAvailable = true;
|
||||
emit audioAvailableChanged(m_audioAvailable);
|
||||
}
|
||||
|
||||
void MFPlayerControl::resetAudioVideoAvailable()
|
||||
{
|
||||
bool videoDirty = false;
|
||||
if (m_videoAvailable) {
|
||||
m_videoAvailable = false;
|
||||
videoDirty = true;
|
||||
}
|
||||
if (m_audioAvailable) {
|
||||
m_audioAvailable = false;
|
||||
emit audioAvailableChanged(m_audioAvailable);
|
||||
}
|
||||
if (videoDirty)
|
||||
emit videoAvailableChanged(m_videoAvailable);
|
||||
}
|
||||
|
||||
void MFPlayerControl::handleDurationUpdate(qint64 duration)
|
||||
{
|
||||
if (m_duration == duration)
|
||||
return;
|
||||
m_duration = duration;
|
||||
emit durationChanged(m_duration);
|
||||
}
|
||||
|
||||
void MFPlayerControl::handleSeekableUpdate(bool seekable)
|
||||
{
|
||||
if (m_seekable == seekable)
|
||||
return;
|
||||
m_seekable = seekable;
|
||||
emit seekableChanged(m_seekable);
|
||||
}
|
||||
|
||||
QMediaPlayer::State MFPlayerControl::state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
QMediaPlayer::MediaStatus MFPlayerControl::mediaStatus() const
|
||||
{
|
||||
return m_session->status();
|
||||
}
|
||||
|
||||
qint64 MFPlayerControl::duration() const
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
|
||||
qint64 MFPlayerControl::position() const
|
||||
{
|
||||
return m_session->position();
|
||||
}
|
||||
|
||||
void MFPlayerControl::setPosition(qint64 position)
|
||||
{
|
||||
if (!m_seekable || position == m_session->position())
|
||||
return;
|
||||
m_session->setPosition(position);
|
||||
}
|
||||
|
||||
int MFPlayerControl::volume() const
|
||||
{
|
||||
return m_session->volume();
|
||||
}
|
||||
|
||||
void MFPlayerControl::setVolume(int volume)
|
||||
{
|
||||
m_session->setVolume(volume);
|
||||
}
|
||||
|
||||
bool MFPlayerControl::isMuted() const
|
||||
{
|
||||
return m_session->isMuted();
|
||||
}
|
||||
|
||||
void MFPlayerControl::setMuted(bool muted)
|
||||
{
|
||||
m_session->setMuted(muted);
|
||||
}
|
||||
|
||||
int MFPlayerControl::bufferStatus() const
|
||||
{
|
||||
return m_session->bufferStatus();
|
||||
}
|
||||
|
||||
bool MFPlayerControl::isAudioAvailable() const
|
||||
{
|
||||
return m_audioAvailable;
|
||||
}
|
||||
|
||||
bool MFPlayerControl::isVideoAvailable() const
|
||||
{
|
||||
return m_videoAvailable;
|
||||
}
|
||||
|
||||
bool MFPlayerControl::isSeekable() const
|
||||
{
|
||||
return m_seekable;
|
||||
}
|
||||
|
||||
QMediaTimeRange MFPlayerControl::availablePlaybackRanges() const
|
||||
{
|
||||
return m_session->availablePlaybackRanges();
|
||||
}
|
||||
|
||||
qreal MFPlayerControl::playbackRate() const
|
||||
{
|
||||
return m_session->playbackRate();
|
||||
}
|
||||
|
||||
void MFPlayerControl::setPlaybackRate(qreal rate)
|
||||
{
|
||||
m_session->setPlaybackRate(rate);
|
||||
}
|
||||
|
||||
QMediaContent MFPlayerControl::media() const
|
||||
{
|
||||
return m_media;
|
||||
}
|
||||
|
||||
const QIODevice* MFPlayerControl::mediaStream() const
|
||||
{
|
||||
return m_stream;
|
||||
}
|
||||
|
||||
void MFPlayerControl::handleError(QMediaPlayer::Error errorCode, const QString& errorString, bool isFatal)
|
||||
{
|
||||
if (isFatal)
|
||||
stop();
|
||||
emit error(int(errorCode), errorString);
|
||||
}
|
||||
124
src/plugins/wmf/player/mfplayercontrol.h
Normal file
124
src/plugins/wmf/player/mfplayercontrol.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MFPLAYERCONTROL_H
|
||||
#define MFPLAYERCONTROL_H
|
||||
|
||||
#include "qmediacontent.h"
|
||||
#include "qmediaplayercontrol.h"
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
|
||||
#include "mfplayersession.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class MFPlayerControl : public QMediaPlayerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MFPlayerControl(MFPlayerSession *session);
|
||||
~MFPlayerControl();
|
||||
|
||||
QMediaPlayer::State state() const;
|
||||
|
||||
QMediaPlayer::MediaStatus mediaStatus() const;
|
||||
|
||||
qint64 duration() const;
|
||||
|
||||
qint64 position() const;
|
||||
void setPosition(qint64 position);
|
||||
|
||||
int volume() const;
|
||||
void setVolume(int volume);
|
||||
|
||||
bool isMuted() const;
|
||||
void setMuted(bool muted);
|
||||
|
||||
int bufferStatus() const;
|
||||
|
||||
bool isAudioAvailable() const;
|
||||
bool isVideoAvailable() const;
|
||||
|
||||
bool isSeekable() const;
|
||||
|
||||
QMediaTimeRange availablePlaybackRanges() const;
|
||||
|
||||
qreal playbackRate() const;
|
||||
void setPlaybackRate(qreal rate);
|
||||
|
||||
QMediaContent media() const;
|
||||
const QIODevice *mediaStream() const;
|
||||
void setMedia(const QMediaContent &media, QIODevice *stream);
|
||||
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleStatusChanged();
|
||||
void handleVideoAvailable();
|
||||
void handleAudioAvailable();
|
||||
void handleDurationUpdate(qint64 duration);
|
||||
void handleSeekableUpdate(bool seekable);
|
||||
void handleError(QMediaPlayer::Error errorCode, const QString& errorString, bool isFatal);
|
||||
|
||||
private:
|
||||
void changeState(QMediaPlayer::State state);
|
||||
void resetAudioVideoAvailable();
|
||||
void refreshState();
|
||||
|
||||
QMediaPlayer::State m_state;
|
||||
bool m_stateDirty;
|
||||
QMediaPlayer::MediaStatus m_status;
|
||||
QMediaPlayer::Error m_error;
|
||||
|
||||
bool m_videoAvailable;
|
||||
bool m_audioAvailable;
|
||||
qint64 m_duration;
|
||||
bool m_seekable;
|
||||
|
||||
QIODevice *m_stream;
|
||||
QMediaContent m_media;
|
||||
MFPlayerSession *m_session;
|
||||
};
|
||||
|
||||
#endif
|
||||
154
src/plugins/wmf/player/mfplayerservice.cpp
Normal file
154
src/plugins/wmf/player/mfplayerservice.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "qmediacontent.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include "mfplayercontrol.h"
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
#include "evr9videowindowcontrol.h"
|
||||
#endif
|
||||
#include "mfvideorenderercontrol.h"
|
||||
#include "mfaudioendpointcontrol.h"
|
||||
#include "mfplayerservice.h"
|
||||
#include "mfplayersession.h"
|
||||
#include "mfmetadatacontrol.h"
|
||||
|
||||
MFPlayerService::MFPlayerService(QObject *parent)
|
||||
: QMediaService(parent)
|
||||
, m_session(0)
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
, m_videoWindowControl(0)
|
||||
#endif
|
||||
, m_videoRendererControl(0)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
MFStartup(MF_VERSION);
|
||||
m_session = new MFPlayerSession(this);
|
||||
m_player = new MFPlayerControl(m_session);
|
||||
m_audioEndpointControl = new MFAudioEndpointControl(this);
|
||||
m_metaDataControl = new MFMetaDataControl(this);
|
||||
}
|
||||
|
||||
MFPlayerService::~MFPlayerService()
|
||||
{
|
||||
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
if (m_videoWindowControl)
|
||||
delete m_videoWindowControl;
|
||||
#endif
|
||||
|
||||
if (m_videoRendererControl)
|
||||
delete m_videoRendererControl;
|
||||
|
||||
delete m_session;
|
||||
|
||||
MFShutdown();
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
QMediaControl* MFPlayerService::requestControl(const char *name)
|
||||
{
|
||||
if (qstrcmp(name, QMediaPlayerControl_iid) == 0) {
|
||||
return m_player;
|
||||
} else if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) {
|
||||
return m_audioEndpointControl;
|
||||
} else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) {
|
||||
return m_metaDataControl;
|
||||
} else if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
if (!m_videoRendererControl && !m_videoWindowControl) {
|
||||
#else
|
||||
if (!m_videoRendererControl) {
|
||||
#endif
|
||||
m_videoRendererControl = new MFVideoRendererControl;
|
||||
return m_videoRendererControl;
|
||||
}
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
} else if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
|
||||
if (!m_videoRendererControl && !m_videoWindowControl) {
|
||||
m_videoWindowControl = new Evr9VideoWindowControl;
|
||||
return m_videoWindowControl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MFPlayerService::releaseControl(QMediaControl *control)
|
||||
{
|
||||
if (!control) {
|
||||
qWarning("QMediaService::releaseControl():"
|
||||
" Attempted release of null control");
|
||||
} else if (control == m_videoRendererControl) {
|
||||
m_videoRendererControl->setSurface(0);
|
||||
delete m_videoRendererControl;
|
||||
m_videoRendererControl = 0;
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
} else if (control == m_videoWindowControl) {
|
||||
delete m_videoWindowControl;
|
||||
m_videoWindowControl = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
MFAudioEndpointControl* MFPlayerService::audioEndpointControl() const
|
||||
{
|
||||
return m_audioEndpointControl;
|
||||
}
|
||||
|
||||
MFVideoRendererControl* MFPlayerService::videoRendererControl() const
|
||||
{
|
||||
return m_videoRendererControl;
|
||||
}
|
||||
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
Evr9VideoWindowControl* MFPlayerService::videoWindowControl() const
|
||||
{
|
||||
return m_videoWindowControl;
|
||||
}
|
||||
#endif
|
||||
|
||||
MFMetaDataControl* MFPlayerService::metaDataControl() const
|
||||
{
|
||||
return m_metaDataControl;
|
||||
}
|
||||
96
src/plugins/wmf/player/mfplayerservice.h
Normal file
96
src/plugins/wmf/player/mfplayerservice.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MFPLAYERSERVICE_H
|
||||
#define MFPLAYERSERVICE_H
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
|
||||
#include "qmediaplayer.h"
|
||||
#include "qmediaresource.h"
|
||||
#include "qmediaservice.h"
|
||||
#include "qmediatimerange.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaContent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
class Evr9VideoWindowControl;
|
||||
#endif
|
||||
class MFAudioEndpointControl;
|
||||
class MFVideoRendererControl;
|
||||
class MFPlayerControl;
|
||||
class MFMetaDataControl;
|
||||
class MFPlayerSession;
|
||||
|
||||
class MFPlayerService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MFPlayerService(QObject *parent = 0);
|
||||
~MFPlayerService();
|
||||
|
||||
QMediaControl* requestControl(const char *name);
|
||||
void releaseControl(QMediaControl *control);
|
||||
|
||||
MFAudioEndpointControl* audioEndpointControl() const;
|
||||
MFVideoRendererControl* videoRendererControl() const;
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
Evr9VideoWindowControl* videoWindowControl() const;
|
||||
#endif
|
||||
MFMetaDataControl* metaDataControl() const;
|
||||
|
||||
private:
|
||||
MFPlayerSession *m_session;
|
||||
MFVideoRendererControl *m_videoRendererControl;
|
||||
MFAudioEndpointControl *m_audioEndpointControl;
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
Evr9VideoWindowControl *m_videoWindowControl;
|
||||
#endif
|
||||
MFPlayerControl *m_player;
|
||||
MFMetaDataControl *m_metaDataControl;
|
||||
};
|
||||
|
||||
#endif
|
||||
1388
src/plugins/wmf/player/mfplayersession.cpp
Normal file
1388
src/plugins/wmf/player/mfplayersession.cpp
Normal file
File diff suppressed because it is too large
Load Diff
212
src/plugins/wmf/player/mfplayersession.h
Normal file
212
src/plugins/wmf/player/mfplayersession.h
Normal file
@@ -0,0 +1,212 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MFPLAYERSESSION_H
|
||||
#define MFPLAYERSESSION_H
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
|
||||
#include "qmediaplayer.h"
|
||||
#include "qmediaresource.h"
|
||||
#include "qmediaservice.h"
|
||||
#include "qmediatimerange.h"
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qwaitcondition.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaContent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class SourceResolver;
|
||||
#ifndef Q_WS_SIMULATOR
|
||||
class Evr9VideoWindowControl;
|
||||
#endif
|
||||
class MFAudioEndpointControl;
|
||||
class MFVideoRendererControl;
|
||||
class MFPlayerControl;
|
||||
class MFMetaDataControl;
|
||||
|
||||
class MFPlayerSession : public QObject, public IMFAsyncCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class SourceResolver;
|
||||
public:
|
||||
MFPlayerSession(QObject *parent = 0);
|
||||
~MFPlayerSession();
|
||||
|
||||
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject);
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
STDMETHODIMP Invoke(IMFAsyncResult *pResult);
|
||||
|
||||
STDMETHODIMP GetParameters(DWORD *pdwFlags, DWORD *pdwQueue)
|
||||
{
|
||||
Q_UNUSED(pdwFlags);
|
||||
Q_UNUSED(pdwQueue);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
void load(const QMediaContent &media, QIODevice *stream);
|
||||
void stop();
|
||||
void start();
|
||||
void pause();
|
||||
|
||||
QMediaPlayer::MediaStatus status() const;
|
||||
qint64 position();
|
||||
void setPosition(qint64 position);
|
||||
qreal playbackRate() const;
|
||||
void setPlaybackRate(qreal rate);
|
||||
int volume() const;
|
||||
void setVolume(int volume);
|
||||
bool isMuted() const;
|
||||
void setMuted(bool muted);
|
||||
int bufferStatus();
|
||||
QMediaTimeRange availablePlaybackRanges();
|
||||
|
||||
void changeStatus(QMediaPlayer::MediaStatus newStatus);
|
||||
|
||||
Q_SIGNALS:
|
||||
void error(QMediaPlayer::Error error, QString errorString, bool isFatal);
|
||||
void sessionEvent(IMFMediaEvent *sessionEvent);
|
||||
void statusChanged();
|
||||
void audioAvailable();
|
||||
void videoAvailable();
|
||||
void durationUpdate(qint64 duration);
|
||||
void seekableUpdate(bool seekable);
|
||||
void positionChanged(qint64 position);
|
||||
void playbackRateChanged(qreal rate);
|
||||
void volumeChanged(int volume);
|
||||
void mutedChanged(bool muted);
|
||||
void bufferStatusChanged(int percentFilled);
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleMediaSourceReady();
|
||||
void handleSessionEvent(IMFMediaEvent *sessionEvent);
|
||||
void handleSourceError(long hr);
|
||||
|
||||
private:
|
||||
IMFMediaSession *m_session;
|
||||
IMFPresentationClock *m_presentationClock;
|
||||
IMFRateControl *m_rateControl;
|
||||
IMFRateSupport *m_rateSupport;
|
||||
IMFSimpleAudioVolume *m_volumeControl;
|
||||
IPropertyStore *m_netsourceStatistics;
|
||||
PROPVARIANT m_varStart;
|
||||
UINT64 m_duration;
|
||||
|
||||
enum Command
|
||||
{
|
||||
CmdNone = 0,
|
||||
CmdStop,
|
||||
CmdStart,
|
||||
CmdPause,
|
||||
CmdSeek,
|
||||
CmdSeekResume,
|
||||
};
|
||||
|
||||
void clear();
|
||||
void setPositionInternal(qint64 position, Command requestCmd);
|
||||
void setPlaybackRateInternal(qreal rate);
|
||||
void commitRateChange(qreal rate, BOOL isThin);
|
||||
bool canScrub() const;
|
||||
void scrub(bool enableScrub);
|
||||
bool m_scrubbing;
|
||||
float m_restoreRate;
|
||||
|
||||
SourceResolver *m_sourceResolver;
|
||||
HANDLE m_hCloseEvent;
|
||||
|
||||
enum MediaType
|
||||
{
|
||||
Unknown = 0,
|
||||
Audio = 1,
|
||||
Video = 2,
|
||||
};
|
||||
DWORD m_mediaTypes;
|
||||
|
||||
enum PendingState
|
||||
{
|
||||
NoPending = 0,
|
||||
CmdPending,
|
||||
SeekPending,
|
||||
};
|
||||
|
||||
struct SeekState
|
||||
{
|
||||
void setCommand(Command cmd) {
|
||||
prevCmd = command;
|
||||
command = cmd;
|
||||
}
|
||||
Command command;
|
||||
Command prevCmd;
|
||||
float rate; // Playback rate
|
||||
BOOL isThin; // Thinned playback?
|
||||
qint64 start; // Start position
|
||||
};
|
||||
SeekState m_state; // Current nominal state.
|
||||
SeekState m_request; // Pending request.
|
||||
PendingState m_pendingState;
|
||||
float m_pendingRate;
|
||||
void updatePendingCommands(Command command);
|
||||
|
||||
QMediaPlayer::MediaStatus m_status;
|
||||
bool m_canScrub;
|
||||
int m_volume;
|
||||
bool m_muted;
|
||||
|
||||
void createSession();
|
||||
void setupPlaybackTopology(IMFMediaSource *source, IMFPresentationDescriptor *sourcePD);
|
||||
IMFTopologyNode* addSourceNode(IMFTopology* topology, IMFMediaSource* source,
|
||||
IMFPresentationDescriptor* presentationDesc, IMFStreamDescriptor *streamDesc);
|
||||
IMFTopologyNode* addOutputNode(IMFStreamDescriptor *streamDesc, MediaType& mediaType, IMFTopology* topology, DWORD sinkID);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
361
src/plugins/wmf/player/mfstream.cpp
Normal file
361
src/plugins/wmf/player/mfstream.cpp
Normal file
@@ -0,0 +1,361 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mfstream.h"
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
|
||||
//MFStream is added for supporting QIODevice type of media source.
|
||||
//It is used to delegate invocations from media foundation(through IMFByteStream) to QIODevice.
|
||||
|
||||
MFStream::MFStream(QIODevice *stream, bool ownStream)
|
||||
: m_cRef(1)
|
||||
, m_stream(stream)
|
||||
, m_ownStream(ownStream)
|
||||
, m_currentReadResult(0)
|
||||
{
|
||||
//Move to the thread of the stream object
|
||||
//to make sure invocations on stream
|
||||
//are happened in the same thread of stream object
|
||||
this->moveToThread(stream->thread());
|
||||
connect(stream, SIGNAL(readyRead()), this, SLOT(handleReadyRead()));
|
||||
}
|
||||
|
||||
MFStream::~MFStream()
|
||||
{
|
||||
if (m_currentReadResult)
|
||||
m_currentReadResult->Release();
|
||||
if (m_ownStream)
|
||||
m_stream->deleteLater();
|
||||
}
|
||||
|
||||
//from IUnknown
|
||||
STDMETHODIMP MFStream::QueryInterface(REFIID riid, LPVOID *ppvObject)
|
||||
{
|
||||
if (!ppvObject)
|
||||
return E_POINTER;
|
||||
if (riid == IID_IMFByteStream) {
|
||||
*ppvObject = static_cast<IMFByteStream*>(this);
|
||||
} else if (riid == IID_IUnknown) {
|
||||
*ppvObject = static_cast<IUnknown*>(this);
|
||||
} else {
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) MFStream::AddRef(void)
|
||||
{
|
||||
return InterlockedIncrement(&m_cRef);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) MFStream::Release(void)
|
||||
{
|
||||
LONG cRef = InterlockedDecrement(&m_cRef);
|
||||
if (cRef == 0) {
|
||||
this->deleteLater();
|
||||
}
|
||||
return cRef;
|
||||
}
|
||||
|
||||
|
||||
//from IMFByteStream
|
||||
STDMETHODIMP MFStream::GetCapabilities(DWORD *pdwCapabilities)
|
||||
{
|
||||
if (!pdwCapabilities)
|
||||
return E_INVALIDARG;
|
||||
*pdwCapabilities = MFBYTESTREAM_IS_READABLE;
|
||||
if (!m_stream->isSequential())
|
||||
*pdwCapabilities |= MFBYTESTREAM_IS_SEEKABLE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::GetLength(QWORD *pqwLength)
|
||||
{
|
||||
if (!pqwLength)
|
||||
return E_INVALIDARG;
|
||||
QMutexLocker locker(&m_mutex);
|
||||
*pqwLength = QWORD(m_stream->size());
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::SetLength(QWORD)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::GetCurrentPosition(QWORD *pqwPosition)
|
||||
{
|
||||
if (!pqwPosition)
|
||||
return E_INVALIDARG;
|
||||
QMutexLocker locker(&m_mutex);
|
||||
*pqwPosition = m_stream->pos();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::SetCurrentPosition(QWORD qwPosition)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
//SetCurrentPosition may happend during the BeginRead/EndRead pair,
|
||||
//refusing to execute SetCurrentPosition during that time seems to be
|
||||
//the simplest workable solution
|
||||
if (m_currentReadResult)
|
||||
return S_FALSE;
|
||||
|
||||
bool seekOK = m_stream->seek(qint64(qwPosition));
|
||||
if (seekOK)
|
||||
return S_OK;
|
||||
else
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::IsEndOfStream(BOOL *pfEndOfStream)
|
||||
{
|
||||
if (!pfEndOfStream)
|
||||
return E_INVALIDARG;
|
||||
QMutexLocker locker(&m_mutex);
|
||||
*pfEndOfStream = m_stream->atEnd() ? TRUE : FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::Read(BYTE *pb, ULONG cb, ULONG *pcbRead)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
qint64 read = m_stream->read((char*)(pb), qint64(cb));
|
||||
if (pcbRead)
|
||||
*pcbRead = ULONG(read);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::BeginRead(BYTE *pb, ULONG cb, IMFAsyncCallback *pCallback,
|
||||
IUnknown *punkState)
|
||||
{
|
||||
if (!pCallback || !pb)
|
||||
return E_INVALIDARG;
|
||||
|
||||
Q_ASSERT(m_currentReadResult == NULL);
|
||||
|
||||
AsyncReadState *state = new (std::nothrow) AsyncReadState(pb, cb);
|
||||
if (state == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
HRESULT hr = MFCreateAsyncResult(state, pCallback, punkState, &m_currentReadResult);
|
||||
state->Release();
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
|
||||
return hr;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::EndRead(IMFAsyncResult* pResult, ULONG *pcbRead)
|
||||
{
|
||||
if (!pcbRead)
|
||||
return E_INVALIDARG;
|
||||
IUnknown *pUnk;
|
||||
pResult->GetObject(&pUnk);
|
||||
AsyncReadState *state = static_cast<AsyncReadState*>(pUnk);
|
||||
*pcbRead = state->bytesRead();
|
||||
pUnk->Release();
|
||||
|
||||
m_currentReadResult->Release();
|
||||
m_currentReadResult = NULL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::Write(const BYTE *, ULONG, ULONG *)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::BeginWrite(const BYTE *, ULONG ,
|
||||
IMFAsyncCallback *,
|
||||
IUnknown *)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::EndWrite(IMFAsyncResult *,
|
||||
ULONG *)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::Seek(
|
||||
MFBYTESTREAM_SEEK_ORIGIN SeekOrigin,
|
||||
LONGLONG llSeekOffset,
|
||||
DWORD,
|
||||
QWORD *pqwCurrentPosition)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_currentReadResult)
|
||||
return S_FALSE;
|
||||
|
||||
qint64 pos = qint64(llSeekOffset);
|
||||
switch (SeekOrigin) {
|
||||
case msoCurrent:
|
||||
pos += m_stream->pos();
|
||||
break;
|
||||
}
|
||||
bool seekOK = m_stream->seek(pos);
|
||||
if (*pqwCurrentPosition)
|
||||
*pqwCurrentPosition = pos;
|
||||
if (seekOK)
|
||||
return S_OK;
|
||||
else
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::Flush()
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP MFStream::Close()
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_ownStream)
|
||||
m_stream->close();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void MFStream::doRead()
|
||||
{
|
||||
bool readDone = true;
|
||||
IUnknown *pUnk = NULL;
|
||||
HRESULT hr = m_currentReadResult->GetObject(&pUnk);
|
||||
if (SUCCEEDED(hr)) {
|
||||
//do actual read
|
||||
AsyncReadState *state = static_cast<AsyncReadState*>(pUnk);
|
||||
ULONG cbRead;
|
||||
Read(state->pb(), state->cb() - state->bytesRead(), &cbRead);
|
||||
pUnk->Release();
|
||||
|
||||
state->setBytesRead(cbRead + state->bytesRead());
|
||||
if (state->cb() > state->bytesRead() && !m_stream->atEnd()) {
|
||||
readDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (readDone) {
|
||||
//now inform the original caller
|
||||
m_currentReadResult->SetStatus(hr);
|
||||
MFInvokeCallback(m_currentReadResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MFStream::handleReadyRead()
|
||||
{
|
||||
doRead();
|
||||
}
|
||||
|
||||
void MFStream::customEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() != QEvent::User) {
|
||||
QObject::customEvent(event);
|
||||
return;
|
||||
}
|
||||
doRead();
|
||||
}
|
||||
|
||||
//AsyncReadState is a helper class used in BeginRead for asynchronous operation
|
||||
//to record some BeginRead parameters, so these parameters could be
|
||||
//used later when actually executing the read operation in another thread.
|
||||
MFStream::AsyncReadState::AsyncReadState(BYTE *pb, ULONG cb)
|
||||
: m_cRef(1)
|
||||
, m_pb(pb)
|
||||
, m_cb(cb)
|
||||
, m_cbRead(0)
|
||||
{
|
||||
}
|
||||
|
||||
//from IUnknown
|
||||
STDMETHODIMP MFStream::AsyncReadState::QueryInterface(REFIID riid, LPVOID *ppvObject)
|
||||
{
|
||||
if (!ppvObject)
|
||||
return E_POINTER;
|
||||
|
||||
if (riid == IID_IUnknown) {
|
||||
*ppvObject = static_cast<IUnknown*>(this);
|
||||
} else {
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) MFStream::AsyncReadState::AddRef(void)
|
||||
{
|
||||
return InterlockedIncrement(&m_cRef);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) MFStream::AsyncReadState::Release(void)
|
||||
{
|
||||
LONG cRef = InterlockedDecrement(&m_cRef);
|
||||
if (cRef == 0)
|
||||
delete this;
|
||||
// For thread safety, return a temporary variable.
|
||||
return cRef;
|
||||
}
|
||||
|
||||
BYTE* MFStream::AsyncReadState::pb() const
|
||||
{
|
||||
return m_pb;
|
||||
}
|
||||
|
||||
ULONG MFStream::AsyncReadState::cb() const
|
||||
{
|
||||
return m_cb;
|
||||
}
|
||||
|
||||
ULONG MFStream::AsyncReadState::bytesRead() const
|
||||
{
|
||||
return m_cbRead;
|
||||
}
|
||||
|
||||
void MFStream::AsyncReadState::setBytesRead(ULONG cbRead)
|
||||
{
|
||||
m_cbRead = cbRead;
|
||||
}
|
||||
149
src/plugins/wmf/player/mfstream.h
Normal file
149
src/plugins/wmf/player/mfstream.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef MFSTREAM_H
|
||||
#define MFSTREAM_H
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qiodevice.h>
|
||||
#include <QtCore/qcoreevent.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class MFStream : public QObject, public IMFByteStream
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MFStream(QIODevice *stream, bool ownStream);
|
||||
|
||||
~MFStream();
|
||||
|
||||
//from IUnknown
|
||||
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject);
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
|
||||
//from IMFByteStream
|
||||
STDMETHODIMP GetCapabilities(DWORD *pdwCapabilities);
|
||||
|
||||
STDMETHODIMP GetLength(QWORD *pqwLength);
|
||||
|
||||
STDMETHODIMP SetLength(QWORD);
|
||||
|
||||
STDMETHODIMP GetCurrentPosition(QWORD *pqwPosition);
|
||||
|
||||
STDMETHODIMP SetCurrentPosition(QWORD qwPosition);
|
||||
|
||||
STDMETHODIMP IsEndOfStream(BOOL *pfEndOfStream);
|
||||
|
||||
STDMETHODIMP Read(BYTE *pb, ULONG cb, ULONG *pcbRead);
|
||||
|
||||
STDMETHODIMP BeginRead(BYTE *pb, ULONG cb, IMFAsyncCallback *pCallback,
|
||||
IUnknown *punkState);
|
||||
|
||||
STDMETHODIMP EndRead(IMFAsyncResult* pResult, ULONG *pcbRead);
|
||||
|
||||
STDMETHODIMP Write(const BYTE *, ULONG, ULONG *);
|
||||
|
||||
STDMETHODIMP BeginWrite(const BYTE *, ULONG ,
|
||||
IMFAsyncCallback *,
|
||||
IUnknown *);
|
||||
|
||||
STDMETHODIMP EndWrite(IMFAsyncResult *,
|
||||
ULONG *);
|
||||
|
||||
STDMETHODIMP Seek(
|
||||
MFBYTESTREAM_SEEK_ORIGIN SeekOrigin,
|
||||
LONGLONG llSeekOffset,
|
||||
DWORD,
|
||||
QWORD *pqwCurrentPosition);
|
||||
|
||||
STDMETHODIMP Flush();
|
||||
|
||||
STDMETHODIMP Close();
|
||||
|
||||
private:
|
||||
class AsyncReadState : public IUnknown
|
||||
{
|
||||
public:
|
||||
AsyncReadState(BYTE *pb, ULONG cb);
|
||||
|
||||
//from IUnknown
|
||||
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject);
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
BYTE* pb() const;
|
||||
ULONG cb() const;
|
||||
ULONG bytesRead() const;
|
||||
|
||||
void setBytesRead(ULONG cbRead);
|
||||
|
||||
private:
|
||||
long m_cRef;
|
||||
BYTE *m_pb;
|
||||
ULONG m_cb;
|
||||
ULONG m_cbRead;
|
||||
};
|
||||
|
||||
long m_cRef;
|
||||
QIODevice *m_stream;
|
||||
bool m_ownStream;
|
||||
DWORD m_workQueueId;
|
||||
QMutex m_mutex;
|
||||
|
||||
void doRead();
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleReadyRead();
|
||||
|
||||
protected:
|
||||
void customEvent(QEvent *event);
|
||||
IMFAsyncResult *m_currentReadResult;
|
||||
};
|
||||
|
||||
#endif
|
||||
2201
src/plugins/wmf/player/mfvideorenderercontrol.cpp
Normal file
2201
src/plugins/wmf/player/mfvideorenderercontrol.cpp
Normal file
File diff suppressed because it is too large
Load Diff
76
src/plugins/wmf/player/mfvideorenderercontrol.h
Normal file
76
src/plugins/wmf/player/mfvideorenderercontrol.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MFVIDEORENDERERCONTROL_H
|
||||
#define MFVIDEORENDERERCONTROL_H
|
||||
|
||||
#include "../../src/multimedia/qvideorenderercontrol.h"
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class MFVideoRendererControl : public QVideoRendererControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MFVideoRendererControl(QObject *parent = 0);
|
||||
~MFVideoRendererControl();
|
||||
|
||||
QAbstractVideoSurface *surface() const;
|
||||
void setSurface(QAbstractVideoSurface *surface);
|
||||
|
||||
IMFActivate* currentActivate() const;
|
||||
|
||||
protected:
|
||||
void customEvent(QEvent *event);
|
||||
|
||||
private Q_SLOTS:
|
||||
void supportedFormatsChanged();
|
||||
void present();
|
||||
|
||||
private:
|
||||
QAbstractVideoSurface *m_surface;
|
||||
IMFActivate *m_currentActivate;
|
||||
IMFSampleGrabberSinkCallback *m_callback;
|
||||
};
|
||||
|
||||
#endif
|
||||
30
src/plugins/wmf/player/player.pri
Normal file
30
src/plugins/wmf/player/player.pri
Normal file
@@ -0,0 +1,30 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
LIBS += -lstrmiids -ldmoguids -luuid -lmsdmo -lole32 -loleaut32 -lMf -lMfuuid -lMfplat -lPropsys
|
||||
|
||||
DEFINES += QMEDIA_MEDIAFOUNDATION_PLAYER
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/mfplayerservice.h \
|
||||
$$PWD/mfplayersession.h \
|
||||
$$PWD/mfstream.h \
|
||||
$$PWD/sourceresolver.h \
|
||||
$$PWD/mfplayercontrol.h \
|
||||
$$PWD/mfvideorenderercontrol.h \
|
||||
$$PWD/mfaudioendpointcontrol.h \
|
||||
$$PWD/mfmetadatacontrol.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/mfplayerservice.cpp \
|
||||
$$PWD/mfplayersession.cpp \
|
||||
$$PWD/mfstream.cpp \
|
||||
$$PWD/sourceresolver.cpp \
|
||||
$$PWD/mfplayercontrol.cpp \
|
||||
$$PWD/mfvideorenderercontrol.cpp \
|
||||
$$PWD/mfaudioendpointcontrol.cpp \
|
||||
$$PWD/mfmetadatacontrol.cpp
|
||||
|
||||
!simulator {
|
||||
HEADERS += $$PWD/evr9videowindowcontrol.h
|
||||
SOURCES += $$PWD/evr9videowindowcontrol.cpp
|
||||
}
|
||||
318
src/plugins/wmf/player/sourceresolver.cpp
Normal file
318
src/plugins/wmf/player/sourceresolver.cpp
Normal file
@@ -0,0 +1,318 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mfplayersession.h"
|
||||
#include "mfstream.h"
|
||||
#include "sourceresolver.h"
|
||||
#include <Mferror.h>
|
||||
#include <nserror.h>
|
||||
#include <QtCore/qfile.h>
|
||||
|
||||
/*
|
||||
SourceResolver is separated from MFPlayerSession to handle the work of resolving a media source
|
||||
asynchronously. You call SourceResolver::load to request resolving a media source asynchronously,
|
||||
and it will emit mediaSourceReady() when resolving is done. You can call SourceResolver::cancel to
|
||||
stop the previous load operation if there is any.
|
||||
*/
|
||||
|
||||
SourceResolver::SourceResolver(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_cRef(1)
|
||||
, m_cancelCookie(0)
|
||||
, m_sourceResolver(0)
|
||||
, m_mediaSource(0)
|
||||
, m_stream(0)
|
||||
{
|
||||
}
|
||||
|
||||
SourceResolver::~SourceResolver()
|
||||
{
|
||||
shutdown();
|
||||
if (m_cancelCookie)
|
||||
m_cancelCookie->Release();
|
||||
if (m_sourceResolver)
|
||||
m_sourceResolver->Release();
|
||||
}
|
||||
|
||||
STDMETHODIMP SourceResolver::QueryInterface(REFIID riid, LPVOID *ppvObject)
|
||||
{
|
||||
if (!ppvObject)
|
||||
return E_POINTER;
|
||||
if (riid == IID_IUnknown) {
|
||||
*ppvObject = static_cast<IUnknown*>(this);
|
||||
} else if (riid == IID_IMFAsyncCallback) {
|
||||
*ppvObject = static_cast<IMFAsyncCallback*>(this);
|
||||
} else {
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) SourceResolver::AddRef(void)
|
||||
{
|
||||
return InterlockedIncrement(&m_cRef);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) SourceResolver::Release(void)
|
||||
{
|
||||
LONG cRef = InterlockedDecrement(&m_cRef);
|
||||
if (cRef == 0)
|
||||
this->deleteLater();
|
||||
return cRef;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SourceResolver::Invoke(IMFAsyncResult *pAsyncResult)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;
|
||||
IUnknown* pSource = NULL;
|
||||
State *state = static_cast<State*>(pAsyncResult->GetStateNoAddRef());
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
if (state->fromStream())
|
||||
hr = m_sourceResolver->EndCreateObjectFromByteStream(pAsyncResult, &ObjectType, &pSource);
|
||||
else
|
||||
hr = m_sourceResolver->EndCreateObjectFromURL(pAsyncResult, &ObjectType, &pSource);
|
||||
|
||||
if (state->sourceResolver() != m_sourceResolver) {
|
||||
//This is a cancelled one
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (m_cancelCookie) {
|
||||
m_cancelCookie->Release();
|
||||
m_cancelCookie = NULL;
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
emit error(hr);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (m_mediaSource) {
|
||||
m_mediaSource->Release();
|
||||
m_mediaSource = NULL;
|
||||
}
|
||||
|
||||
hr = pSource->QueryInterface(IID_PPV_ARGS(&m_mediaSource));
|
||||
if (FAILED(hr)) {
|
||||
emit error(hr);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
emit mediaSourceReady();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SourceResolver::GetParameters(DWORD*, DWORD*)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
void SourceResolver::load(QMediaResourceList& resources, QIODevice* stream)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
HRESULT hr = S_OK;
|
||||
if (!m_sourceResolver)
|
||||
hr = MFCreateSourceResolver(&m_sourceResolver);
|
||||
|
||||
if (m_stream) {
|
||||
m_stream->Release();
|
||||
m_stream = NULL;
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Failed to create Source Resolver!";
|
||||
emit error(hr);
|
||||
} else if (stream) {
|
||||
if (resources.count() > 0) {
|
||||
QMediaResource resource = resources.takeFirst();
|
||||
QUrl url = resource.url();
|
||||
m_stream = new MFStream(stream, false);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
}
|
||||
} else {
|
||||
hr = MF_E_UNSUPPORTED_BYTESTREAM_TYPE;
|
||||
qWarning() << "Can't load stream without a hint of MIME type in a url";
|
||||
emit error(hr);
|
||||
}
|
||||
} else {
|
||||
QMediaResource resource = resources.takeFirst();
|
||||
QUrl url = resource.url();
|
||||
#ifdef DEBUG_MEDIAFOUNDATION
|
||||
qDebug() << "loading :" << url;
|
||||
qDebug() << "url path =" << url.path().mid(1);
|
||||
#endif
|
||||
#ifdef TEST_STREAMING
|
||||
//Testing stream function
|
||||
if (url.scheme() == QLatin1String("file")) {
|
||||
stream = new QFile(url.path().mid(1), this);
|
||||
if (stream->open(QIODevice::ReadOnly)) {
|
||||
m_stream = new MFStream(stream, true);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
}
|
||||
} else {
|
||||
delete stream;
|
||||
emit error(QMediaPlayer::FormatError);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (url.scheme() == QLatin1String("qrc")) {
|
||||
// If the canonical URL refers to a Qt resource, open with QFile and use
|
||||
// the stream playback capability to play.
|
||||
stream = new QFile(QLatin1Char(':') + url.path(), this);
|
||||
if (stream->open(QIODevice::ReadOnly)) {
|
||||
m_stream = new MFStream(stream, true);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
}
|
||||
} else {
|
||||
delete stream;
|
||||
emit error(QMediaPlayer::FormatError);
|
||||
}
|
||||
} else {
|
||||
hr = m_sourceResolver->BeginCreateObjectFromURL(reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, false));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported url scheme!";
|
||||
emit error(hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SourceResolver::cancel()
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_cancelCookie) {
|
||||
m_sourceResolver->CancelObjectCreation(m_cancelCookie);
|
||||
m_cancelCookie->Release();
|
||||
m_cancelCookie = NULL;
|
||||
m_sourceResolver->Release();
|
||||
m_sourceResolver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SourceResolver::shutdown()
|
||||
{
|
||||
if (m_mediaSource) {
|
||||
m_mediaSource->Shutdown();
|
||||
m_mediaSource->Release();
|
||||
m_mediaSource = NULL;
|
||||
}
|
||||
|
||||
if (m_stream) {
|
||||
m_stream->Release();
|
||||
m_stream = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
IMFMediaSource* SourceResolver::mediaSource() const
|
||||
{
|
||||
return m_mediaSource;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
SourceResolver::State::State(IMFSourceResolver *sourceResolver, bool fromStream)
|
||||
: m_cRef(1)
|
||||
, m_sourceResolver(sourceResolver)
|
||||
, m_fromStream(fromStream)
|
||||
{
|
||||
sourceResolver->AddRef();
|
||||
}
|
||||
|
||||
SourceResolver::State::~State()
|
||||
{
|
||||
m_sourceResolver->Release();
|
||||
}
|
||||
|
||||
STDMETHODIMP SourceResolver::State::QueryInterface(REFIID riid, LPVOID *ppvObject)
|
||||
{
|
||||
if (!ppvObject)
|
||||
return E_POINTER;
|
||||
if (riid == IID_IUnknown) {
|
||||
*ppvObject = static_cast<IUnknown*>(this);
|
||||
} else {
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) SourceResolver::State::AddRef(void)
|
||||
{
|
||||
return InterlockedIncrement(&m_cRef);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) SourceResolver::State::Release(void)
|
||||
{
|
||||
LONG cRef = InterlockedDecrement(&m_cRef);
|
||||
if (cRef == 0)
|
||||
delete this;
|
||||
// For thread safety, return a temporary variable.
|
||||
return cRef;
|
||||
}
|
||||
|
||||
IMFSourceResolver* SourceResolver::State::sourceResolver() const
|
||||
{
|
||||
return m_sourceResolver;
|
||||
}
|
||||
|
||||
bool SourceResolver::State::fromStream() const
|
||||
{
|
||||
return m_fromStream;
|
||||
}
|
||||
|
||||
106
src/plugins/wmf/player/sourceresolver.h
Normal file
106
src/plugins/wmf/player/sourceresolver.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SOURCERESOLVER_H
|
||||
#define SOURCERESOLVER_H
|
||||
|
||||
#include "mfstream.h"
|
||||
#include "qmediaresource.h"
|
||||
|
||||
class SourceResolver: public QObject, public IMFAsyncCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SourceResolver(QObject *parent);
|
||||
|
||||
~SourceResolver();
|
||||
|
||||
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject);
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Invoke(IMFAsyncResult *pAsyncResult);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetParameters(DWORD*, DWORD*);
|
||||
|
||||
void load(QMediaResourceList& resources, QIODevice* stream);
|
||||
|
||||
void cancel();
|
||||
|
||||
void shutdown();
|
||||
|
||||
IMFMediaSource* mediaSource() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void error(long hr);
|
||||
void mediaSourceReady();
|
||||
|
||||
private:
|
||||
class State : public IUnknown
|
||||
{
|
||||
public:
|
||||
State(IMFSourceResolver *sourceResolver, bool fromStream);
|
||||
~State();
|
||||
|
||||
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject);
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
IMFSourceResolver* sourceResolver() const;
|
||||
bool fromStream() const;
|
||||
|
||||
private:
|
||||
long m_cRef;
|
||||
IMFSourceResolver *m_sourceResolver;
|
||||
bool m_fromStream;
|
||||
};
|
||||
|
||||
long m_cRef;
|
||||
IUnknown *m_cancelCookie;
|
||||
IMFSourceResolver *m_sourceResolver;
|
||||
IMFMediaSource *m_mediaSource;
|
||||
MFStream *m_stream;
|
||||
QMutex m_mutex;
|
||||
};
|
||||
|
||||
#endif
|
||||
16
src/plugins/wmf/wmf.pro
Normal file
16
src/plugins/wmf/wmf.pro
Normal file
@@ -0,0 +1,16 @@
|
||||
load(qt_module)
|
||||
|
||||
TARGET = wmfengine
|
||||
QT += multimediakit-private network
|
||||
PLUGIN_TYPE=mediaservice
|
||||
|
||||
load(qt_plugin)
|
||||
|
||||
DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE}
|
||||
|
||||
DEPENDPATH += .
|
||||
|
||||
HEADERS += wmfserviceplugin.h
|
||||
SOURCES += wmfserviceplugin.cpp
|
||||
|
||||
include (player/player.pri)
|
||||
97
src/plugins/wmf/wmfserviceplugin.cpp
Normal file
97
src/plugins/wmf/wmfserviceplugin.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
#include "wmfserviceplugin.h"
|
||||
#ifdef QMEDIA_MEDIAFOUNDATION_PLAYER
|
||||
#include "mfplayerservice.h"
|
||||
#endif
|
||||
#include <qmediaserviceprovider.h>
|
||||
|
||||
QStringList WMFServicePlugin::keys() const
|
||||
{
|
||||
return QStringList()
|
||||
#ifdef QMEDIA_MEDIAFOUNDATION_PLAYER
|
||||
<< QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
QMediaService* WMFServicePlugin::create(QString const& key)
|
||||
{
|
||||
#ifdef QMEDIA_MEDIAFOUNDATION_PLAYER
|
||||
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return new MFPlayerService;
|
||||
#endif
|
||||
|
||||
//qDebug() << "unsupported key:" << key;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WMFServicePlugin::release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features WMFServicePlugin::supportedFeatures(
|
||||
const QByteArray &service) const
|
||||
{
|
||||
if (service == Q_MEDIASERVICE_MEDIAPLAYER)
|
||||
return QMediaServiceProviderHint::StreamPlayback;
|
||||
else
|
||||
return QMediaServiceProviderHint::Features();
|
||||
}
|
||||
|
||||
QList<QByteArray> WMFServicePlugin::devices(const QByteArray &service) const
|
||||
{
|
||||
return QList<QByteArray>();
|
||||
}
|
||||
|
||||
QString WMFServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(qtmedia_wmfengine, WMFServicePlugin);
|
||||
|
||||
68
src/plugins/wmf/wmfserviceplugin.h
Normal file
68
src/plugins/wmf/wmfserviceplugin.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** 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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef WMFSERVICEPLUGIN_H
|
||||
#define WMFSERVICEPLUGIN_H
|
||||
|
||||
#include "qmediaserviceproviderplugin.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class WMFServicePlugin
|
||||
: public QMediaServiceProviderPlugin
|
||||
, public QMediaServiceSupportedDevicesInterface
|
||||
, public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
public:
|
||||
QStringList keys() const;
|
||||
QMediaService* create(QString const& key);
|
||||
void release(QMediaService *service);
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const;
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const;
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device);
|
||||
};
|
||||
|
||||
#endif // DSSERVICEPLUGIN_H
|
||||
@@ -38,6 +38,7 @@
|
||||
"directshow" => {},
|
||||
"wmsdk" => {},
|
||||
"wmp" => {},
|
||||
"wmf" => {},
|
||||
"evr" => {},
|
||||
|
||||
# Linux tests
|
||||
|
||||
Reference in New Issue
Block a user