~phablet-team/+junk/qtmultimedia-declarative-playlist

« back to all changes in this revision

Viewing changes to src/plugins/wmf/player/mfvideorenderercontrol.cpp

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-05-23 19:47:12 UTC
  • mfrom: (1.1.1) (7.1.2 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130523194712-ng8dawnyetljbjkv
Tags: 5.0.2-2ubuntu2
Update libqt5multimedia5.symbols for qreal substitutions for armhf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
2
**
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
5
5
**
6
6
** This file is part of the Qt Mobility Components.
40
40
****************************************************************************/
41
41
 
42
42
#include "mfvideorenderercontrol.h"
43
 
#include <mferror.h>
 
43
#include "mfglobal.h"
 
44
#ifdef QT_OPENGL_ES_2_ANGLE
 
45
#include "evrcustompresenter.h"
 
46
#endif
44
47
#include <qabstractvideosurface.h>
45
48
#include <qvideosurfaceformat.h>
46
49
#include <qtcore/qtimer.h>
114
117
        MapMode m_mapMode;
115
118
    };
116
119
 
117
 
    template<class T>
118
 
    class AsyncCallback : public IMFAsyncCallback
119
 
    {
120
 
    public:
121
 
        typedef HRESULT (T::*InvokeFn)(IMFAsyncResult *pAsyncResult);
122
 
 
123
 
        AsyncCallback(T *pParent, InvokeFn fn) : m_pParent(pParent), m_pInvokeFn(fn)
124
 
        {
125
 
        }
126
 
 
127
 
        // IUnknown
128
 
        STDMETHODIMP QueryInterface(REFIID iid, void** ppv)
129
 
        {
130
 
            if (!ppv)
131
 
            {
132
 
                return E_POINTER;
133
 
            }
134
 
            if (iid == __uuidof(IUnknown))
135
 
            {
136
 
                *ppv = static_cast<IUnknown*>(static_cast<IMFAsyncCallback*>(this));
137
 
            }
138
 
            else if (iid == __uuidof(IMFAsyncCallback))
139
 
            {
140
 
                *ppv = static_cast<IMFAsyncCallback*>(this);
141
 
            }
142
 
            else
143
 
            {
144
 
                *ppv = NULL;
145
 
                return E_NOINTERFACE;
146
 
            }
147
 
            AddRef();
148
 
            return S_OK;
149
 
        }
150
 
        STDMETHODIMP_(ULONG) AddRef()
151
 
        {
152
 
            // Delegate to parent class.
153
 
            return m_pParent->AddRef();
154
 
        }
155
 
        STDMETHODIMP_(ULONG) Release()
156
 
        {
157
 
            // Delegate to parent class.
158
 
            return m_pParent->Release();
159
 
        }
160
 
 
161
 
        // IMFAsyncCallback methods
162
 
        STDMETHODIMP GetParameters(DWORD*, DWORD*)
163
 
        {
164
 
            // Implementation of this method is optional.
165
 
            return E_NOTIMPL;
166
 
        }
167
 
 
168
 
        STDMETHODIMP Invoke(IMFAsyncResult* pAsyncResult)
169
 
        {
170
 
            return (m_pParent->*m_pInvokeFn)(pAsyncResult);
171
 
        }
172
 
 
173
 
        T *m_pParent;
174
 
        InvokeFn m_pInvokeFn;
175
 
    };
176
 
 
177
 
 
178
120
    // Custom interface for handling IMFStreamSink::PlaceMarker calls asynchronously.
179
121
    MIDL_INTERFACE("a3ff32de-1031-438a-8b47-82f8acda59b7")
180
122
    IMarker : public IUnknown
2134
2076
    , m_surface(0)
2135
2077
    , m_currentActivate(0)
2136
2078
    , m_callback(0)
 
2079
#ifdef QT_OPENGL_ES_2_ANGLE
 
2080
    , m_presenterActivate(0)
 
2081
#endif
2137
2082
{
2138
2083
}
2139
2084
 
2147
2092
    if (m_surface)
2148
2093
        m_surface->stop();
2149
2094
 
 
2095
#ifdef QT_OPENGL_ES_2_ANGLE
 
2096
    if (m_presenterActivate) {
 
2097
        m_presenterActivate->ShutdownObject();
 
2098
        m_presenterActivate->Release();
 
2099
        m_presenterActivate = NULL;
 
2100
    }
 
2101
#endif
 
2102
 
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()));
2175
2128
    }
2176
2129
 
 
2130
#ifdef QT_OPENGL_ES_2_ANGLE
 
2131
    if (m_presenterActivate)
 
2132
        m_presenterActivate->setSurface(m_surface);
 
2133
    else
 
2134
#endif
2177
2135
    if (m_currentActivate)
2178
2136
        static_cast<VideoRendererActivate*>(m_currentActivate)->setSurface(m_surface);
2179
2137
}
2180
2138
 
2181
2139
void MFVideoRendererControl::customEvent(QEvent *event)
2182
2140
{
 
2141
#ifdef QT_OPENGL_ES_2_ANGLE
 
2142
    if (m_presenterActivate)
 
2143
        return;
 
2144
#endif
 
2145
 
2183
2146
    if (!m_currentActivate)
2184
2147
        return;
2185
2148
 
2193
2156
            present();
2194
2157
        return;
2195
2158
    }
2196
 
    QChildEvent *childEvent = dynamic_cast<QChildEvent*>(event);
2197
 
    if (!childEvent) {
 
2159
    if (event->type() >= MediaStream::StartSurface) {
 
2160
        QChildEvent *childEvent = static_cast<QChildEvent*>(event);
 
2161
        static_cast<MediaStream*>(childEvent->child())->customEvent(event);
 
2162
    } else {
2198
2163
        QObject::customEvent(event);
2199
 
        return;
2200
2164
    }
2201
 
    static_cast<MediaStream*>(childEvent->child())->customEvent(event);
2202
2165
}
2203
2166
 
2204
2167
void MFVideoRendererControl::supportedFormatsChanged()
2205
2168
{
 
2169
#ifdef QT_OPENGL_ES_2_ANGLE
 
2170
    if (m_presenterActivate)
 
2171
        m_presenterActivate->supportedFormatsChanged();
 
2172
    else
 
2173
#endif
2206
2174
    if (m_currentActivate)
2207
2175
        static_cast<VideoRendererActivate*>(m_currentActivate)->supportedFormatsChanged();
2208
2176
}
2209
2177
 
2210
2178
void MFVideoRendererControl::present()
2211
2179
{
 
2180
#ifdef QT_OPENGL_ES_2_ANGLE
 
2181
    if (m_presenterActivate)
 
2182
        return;
 
2183
#endif
 
2184
 
2212
2185
    if (m_currentActivate)
2213
2186
        static_cast<VideoRendererActivate*>(m_currentActivate)->present();
2214
2187
}
2215
2188
 
2216
2189
IMFActivate* MFVideoRendererControl::createActivate()
2217
2190
{
 
2191
    Q_ASSERT(m_surface);
 
2192
 
2218
2193
    clear();
2219
2194
 
 
2195
#ifdef QT_OPENGL_ES_2_ANGLE
 
2196
    // We can use the EVR with our custom presenter only if the surface supports OpenGL
 
2197
    // texture handles
 
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);
 
2203
        }
 
2204
    }
 
2205
 
 
2206
    if (!m_currentActivate)
 
2207
#endif
2220
2208
    m_currentActivate = new VideoRendererActivate(this);
2221
 
    if (m_surface)
2222
 
        setSurface(m_surface);
 
2209
 
 
2210
    setSurface(m_surface);
2223
2211
 
2224
2212
    return m_currentActivate;
2225
2213
}