93 } else if ((hr = m_oleObject->SetClientSite(this)) != S_OK) { |
93 } else if ((hr = m_oleObject->SetClientSite(this)) != S_OK) { |
94 qWarning("Failed to set site, %x: %s", hr, qwmp_error_string(hr)); |
94 qWarning("Failed to set site, %x: %s", hr, qwmp_error_string(hr)); |
95 } |
95 } |
96 |
96 |
97 if (m_embedMode == LocalEmbed) { |
97 if (m_embedMode == LocalEmbed) { |
98 m_videoOutputControl = new QWmpVideoOutputControl; |
98 m_oleVideoOverlay = new QWmpVideoOverlay(m_player, m_oleObject, this); |
99 m_videoOutputControl->setAvailableOutputs(QList<QVideoOutputControl::Output>() |
|
100 << QVideoOutputControl::WindowOutput); |
|
101 |
|
102 connect(m_videoOutputControl, SIGNAL(outputChanged(QVideoOutputControl::Output)), |
|
103 this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); |
|
104 #ifdef QWMP_EVR |
99 #ifdef QWMP_EVR |
105 IWMPVideoRenderConfig *config = 0; |
100 IWMPVideoRenderConfig *config = 0; |
106 if (m_player->QueryInterface( |
101 if (m_player->QueryInterface( |
107 __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) { |
102 __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) { |
108 if (HINSTANCE evrHwnd = LoadLibrary(L"evr")) { |
103 if (HINSTANCE evrHwnd = LoadLibrary(L"evr")) { |
112 m_evrVideoOverlay, SLOT(openStateChanged(long))); |
107 m_evrVideoOverlay, SLOT(openStateChanged(long))); |
113 } |
108 } |
114 |
109 |
115 config->Release(); |
110 config->Release(); |
116 } |
111 } |
117 |
112 #endif |
118 if (!m_evrVideoOverlay) { |
113 } |
119 #else |
|
120 { |
|
121 #endif |
|
122 m_oleVideoOverlay = new QWmpVideoOverlay(m_player, m_oleObject, this); |
|
123 m_player->put_uiMode(QAutoBStr(L"none")); |
|
124 } |
|
125 } |
|
126 |
|
127 m_metaData = new QWmpMetaData(m_player, m_events); |
114 m_metaData = new QWmpMetaData(m_player, m_events); |
128 m_playlist = new QWmpPlaylistControl(m_player, m_events); |
115 m_playlist = new QWmpPlaylistControl(m_player, m_events); |
129 m_control = new QWmpPlayerControl(m_player, m_events); |
116 m_control = new QWmpPlayerControl(m_player, m_events); |
130 } |
117 } |
131 } |
118 } |
153 m_player->Release(); |
139 m_player->Release(); |
154 |
140 |
155 Q_ASSERT(m_ref == 1); |
141 Q_ASSERT(m_ref == 1); |
156 } |
142 } |
157 |
143 |
158 QMediaControl *QWmpPlayerService::control(const char *name) const |
144 QMediaControl *QWmpPlayerService::requestControl(const char *name) |
159 { |
145 { |
160 if (qstrcmp(name, QMediaPlayerControl_iid) == 0) { |
146 if (qstrcmp(name, QMediaPlayerControl_iid) == 0) { |
161 return m_control; |
147 return m_control; |
162 } else if (qstrcmp(name, QMetaDataControl_iid) == 0) { |
148 } else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) { |
163 return m_metaData; |
149 return m_metaData; |
164 } else if (qstrcmp(name, QMediaPlaylistControl_iid) == 0) { |
150 } else if (qstrcmp(name, QMediaPlaylistControl_iid) == 0) { |
165 return m_playlist; |
151 return m_playlist; |
166 } else if (qstrcmp(name, QVideoOutputControl_iid) == 0) { |
152 } else if (qstrcmp(name, QVideoWindowControl_iid) == 0 |
167 return m_videoOutputControl; |
153 && m_embedMode == LocalEmbed |
168 } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { |
154 && m_player |
169 #ifdef QWMP_EVR |
155 && !m_activeVideoOverlay) { |
170 if (m_evrVideoOverlay) |
156 #ifdef QWMP_EVR |
171 return m_evrVideoOverlay; |
|
172 #endif |
|
173 return m_oleVideoOverlay; |
|
174 } else { |
|
175 return 0; |
|
176 } |
|
177 } |
|
178 |
|
179 void QWmpPlayerService::videoOutputChanged(QVideoOutputControl::Output output) |
|
180 { |
|
181 if (m_oleVideoOverlay) { |
|
182 m_oleVideoOverlay->setEnabled(output == QVideoOutputControl::WindowOutput); |
|
183 #ifdef QWMP_EVR |
|
184 } else if (m_evrVideoOverlay) { |
|
185 IWMPVideoRenderConfig *config = 0; |
157 IWMPVideoRenderConfig *config = 0; |
186 if (m_player->QueryInterface( |
158 if (m_player->QueryInterface( |
187 __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) { |
159 __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) { |
188 if (output == QVideoOutputControl::WindowOutput) |
160 if (HINSTANCE evrHwnd = LoadLibrary(L"evr")) { |
189 config->put_presenterActivate(static_cast<IMFActivate *>(m_evrVideoOverlay)); |
161 m_evrVideoOverlay = new QEvrVideoOverlay(evrHwnd); |
190 else |
162 |
191 config->put_presenterActivate(0); |
163 if (SUCCEEDED(config->put_presenterActivate( |
192 |
164 static_cast<IMFActivate *>(m_evrVideoOverlay)))) { |
|
165 connect(m_events, SIGNAL(OpenStateChange(long)), |
|
166 m_evrVideoOverlay, SLOT(openStateChanged(long))); |
|
167 } else { |
|
168 delete m_evrVideoOverlay; |
|
169 |
|
170 m_evrVideoOverlay = 0; |
|
171 } |
|
172 } |
193 config->Release(); |
173 config->Release(); |
194 } |
174 } |
195 #endif |
175 |
|
176 if (m_evrVideoOverlay) { |
|
177 m_activeVideoOverlay = m_evrVideoOverlay; |
|
178 |
|
179 return m_evrVideoOverlay; |
|
180 } else |
|
181 #endif |
|
182 if (SUCCEEDED(m_player->put_uiMode(QAutoBStr(L"none")))) { |
|
183 m_oleVideoOverlay->setEnabled(true); |
|
184 |
|
185 m_activeVideoOverlay = m_oleVideoOverlay; |
|
186 |
|
187 return m_oleVideoOverlay; |
|
188 } |
|
189 } |
|
190 return 0; |
|
191 } |
|
192 |
|
193 void QWmpPlayerService::releaseControl(QMediaControl *control) |
|
194 { |
|
195 if (!control) { |
|
196 qWarning("QMediaService::releaseControl():" |
|
197 " Attempted release of null control"); |
|
198 #ifdef QWMP_EVR |
|
199 } else if (control == m_evrVideoOverlay) { |
|
200 |
|
201 IWMPVideoRenderConfig *config = 0; |
|
202 if (m_player->QueryInterface( |
|
203 __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) { |
|
204 config->put_presenterActivate(0); |
|
205 config->Release(); |
|
206 } |
|
207 |
|
208 delete m_evrVideoOverlay; |
|
209 |
|
210 m_evrVideoOverlay = 0; |
|
211 m_activeVideoOverlay = 0; |
|
212 #endif |
|
213 } else if (control == m_oleVideoOverlay) { |
|
214 m_player->put_uiMode(QAutoBStr(L"invisible")); |
|
215 |
|
216 m_activeVideoOverlay = 0; |
196 } |
217 } |
197 } |
218 } |
198 |
219 |
199 // IUnknown |
220 // IUnknown |
200 HRESULT QWmpPlayerService::QueryInterface(REFIID riid, void **object) |
221 HRESULT QWmpPlayerService::QueryInterface(REFIID riid, void **object) |