1
1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
4
** Contact: http://www.qt-project.org/legal
6
6
** This file is part of the Qt Mobility Components.
40
40
****************************************************************************/
42
42
#include "mfvideorenderercontrol.h"
44
#ifdef QT_OPENGL_ES_2_ANGLE
45
#include "evrcustompresenter.h"
44
47
#include <qabstractvideosurface.h>
45
48
#include <qvideosurfaceformat.h>
46
49
#include <qtcore/qtimer.h>
114
117
MapMode m_mapMode;
118
class AsyncCallback : public IMFAsyncCallback
121
typedef HRESULT (T::*InvokeFn)(IMFAsyncResult *pAsyncResult);
123
AsyncCallback(T *pParent, InvokeFn fn) : m_pParent(pParent), m_pInvokeFn(fn)
128
STDMETHODIMP QueryInterface(REFIID iid, void** ppv)
134
if (iid == __uuidof(IUnknown))
136
*ppv = static_cast<IUnknown*>(static_cast<IMFAsyncCallback*>(this));
138
else if (iid == __uuidof(IMFAsyncCallback))
140
*ppv = static_cast<IMFAsyncCallback*>(this);
145
return E_NOINTERFACE;
150
STDMETHODIMP_(ULONG) AddRef()
152
// Delegate to parent class.
153
return m_pParent->AddRef();
155
STDMETHODIMP_(ULONG) Release()
157
// Delegate to parent class.
158
return m_pParent->Release();
161
// IMFAsyncCallback methods
162
STDMETHODIMP GetParameters(DWORD*, DWORD*)
164
// Implementation of this method is optional.
168
STDMETHODIMP Invoke(IMFAsyncResult* pAsyncResult)
170
return (m_pParent->*m_pInvokeFn)(pAsyncResult);
174
InvokeFn m_pInvokeFn;
178
120
// Custom interface for handling IMFStreamSink::PlaceMarker calls asynchronously.
179
121
MIDL_INTERFACE("a3ff32de-1031-438a-8b47-82f8acda59b7")
180
122
IMarker : public IUnknown
2148
2093
m_surface->stop();
2095
#ifdef QT_OPENGL_ES_2_ANGLE
2096
if (m_presenterActivate) {
2097
m_presenterActivate->ShutdownObject();
2098
m_presenterActivate->Release();
2099
m_presenterActivate = NULL;
2150
2103
if (m_currentActivate) {
2151
2104
m_currentActivate->ShutdownObject();
2152
2105
m_currentActivate->Release();
2174
2127
connect(m_surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged()));
2130
#ifdef QT_OPENGL_ES_2_ANGLE
2131
if (m_presenterActivate)
2132
m_presenterActivate->setSurface(m_surface);
2177
2135
if (m_currentActivate)
2178
2136
static_cast<VideoRendererActivate*>(m_currentActivate)->setSurface(m_surface);
2181
2139
void MFVideoRendererControl::customEvent(QEvent *event)
2141
#ifdef QT_OPENGL_ES_2_ANGLE
2142
if (m_presenterActivate)
2183
2146
if (!m_currentActivate)
2196
QChildEvent *childEvent = dynamic_cast<QChildEvent*>(event);
2159
if (event->type() >= MediaStream::StartSurface) {
2160
QChildEvent *childEvent = static_cast<QChildEvent*>(event);
2161
static_cast<MediaStream*>(childEvent->child())->customEvent(event);
2198
2163
QObject::customEvent(event);
2201
static_cast<MediaStream*>(childEvent->child())->customEvent(event);
2204
2167
void MFVideoRendererControl::supportedFormatsChanged()
2169
#ifdef QT_OPENGL_ES_2_ANGLE
2170
if (m_presenterActivate)
2171
m_presenterActivate->supportedFormatsChanged();
2206
2174
if (m_currentActivate)
2207
2175
static_cast<VideoRendererActivate*>(m_currentActivate)->supportedFormatsChanged();
2210
2178
void MFVideoRendererControl::present()
2180
#ifdef QT_OPENGL_ES_2_ANGLE
2181
if (m_presenterActivate)
2212
2185
if (m_currentActivate)
2213
2186
static_cast<VideoRendererActivate*>(m_currentActivate)->present();
2216
2189
IMFActivate* MFVideoRendererControl::createActivate()
2191
Q_ASSERT(m_surface);
2195
#ifdef QT_OPENGL_ES_2_ANGLE
2196
// We can use the EVR with our custom presenter only if the surface supports OpenGL
2198
if (!m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty()) {
2199
// Create the EVR media sink, but replace the presenter with our own
2200
if (SUCCEEDED(MFCreateVideoRendererActivate(::GetShellWindow(), &m_currentActivate))) {
2201
m_presenterActivate = new EVRCustomPresenterActivate;
2202
m_currentActivate->SetUnknown(MF_ACTIVATE_CUSTOM_VIDEO_PRESENTER_ACTIVATE, m_presenterActivate);
2206
if (!m_currentActivate)
2220
2208
m_currentActivate = new VideoRendererActivate(this);
2222
setSurface(m_surface);
2210
setSurface(m_surface);
2224
2212
return m_currentActivate;