187 m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0); |
189 m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0); |
188 |
190 |
189 if (m_image) { |
191 if (m_image) { |
190 m_image = 0; |
192 m_image = 0; |
191 |
193 |
192 if (!start(surfaceFormat())) |
194 if (!start(surfaceFormat())) { |
193 QAbstractVideoSurface::stop(); |
195 QAbstractVideoSurface::stop(); |
194 } |
196 qWarning() << "Failed to start video surface with format" << surfaceFormat(); |
195 } else if (m_image) { |
197 } |
196 m_image = 0; |
198 } |
197 |
199 } else { |
198 QAbstractVideoSurface::stop(); |
200 qWarning() << "Failed to find XVideo port"; |
|
201 if (m_image) { |
|
202 m_image = 0; |
|
203 |
|
204 QAbstractVideoSurface::stop(); |
|
205 } |
199 } |
206 } |
200 |
207 |
201 emit supportedFormatsChanged(); |
208 emit supportedFormatsChanged(); |
202 } |
209 } |
203 |
210 |
207 } |
214 } |
208 |
215 |
209 void QX11VideoSurface::setDisplayRect(const QRect &rect) |
216 void QX11VideoSurface::setDisplayRect(const QRect &rect) |
210 { |
217 { |
211 m_displayRect = rect; |
218 m_displayRect = rect; |
|
219 } |
|
220 |
|
221 QRect QX11VideoSurface::viewport() const |
|
222 { |
|
223 return m_viewport; |
|
224 } |
|
225 |
|
226 void QX11VideoSurface::setViewport(const QRect &rect) |
|
227 { |
|
228 m_viewport = rect; |
212 } |
229 } |
213 |
230 |
214 int QX11VideoSurface::brightness() const |
231 int QX11VideoSurface::brightness() const |
215 { |
232 { |
216 return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); |
233 return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); |
438 unsigned int count = 0; |
455 unsigned int count = 0; |
439 XvAdaptorInfo *adaptors = 0; |
456 XvAdaptorInfo *adaptors = 0; |
440 bool portFound = false; |
457 bool portFound = false; |
441 |
458 |
442 if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) { |
459 if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) { |
|
460 #ifdef Q_WS_MAEMO_5 |
|
461 //the overlay xvideo adapter fails to switch winId, |
|
462 //prefer the "SGX Textured Video" adapter instead |
|
463 for (unsigned int i = count-1; i >=0 && !portFound; --i) { |
|
464 #else |
443 for (unsigned int i = 0; i < count && !portFound; ++i) { |
465 for (unsigned int i = 0; i < count && !portFound; ++i) { |
|
466 #endif |
444 if (adaptors[i].type & XvImageMask) { |
467 if (adaptors[i].type & XvImageMask) { |
445 m_portId = adaptors[i].base_id; |
468 m_portId = adaptors[i].base_id; |
446 |
469 |
447 for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) |
470 for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) |
448 portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; |
471 portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; |