equal
deleted
inserted
replaced
43 #include <QtCore/qdebug.h> |
43 #include <QtCore/qdebug.h> |
44 #include <QtCore/qvariant.h> |
44 #include <QtCore/qvariant.h> |
45 #include <qvideosurfaceformat.h> |
45 #include <qvideosurfaceformat.h> |
46 |
46 |
47 #include "qxvideosurface_maemo5_p.h" |
47 #include "qxvideosurface_maemo5_p.h" |
|
48 |
|
49 //#define DEBUG_XV_SURFACE |
48 |
50 |
49 struct XvFormatRgb |
51 struct XvFormatRgb |
50 { |
52 { |
51 QVideoFrame::PixelFormat pixelFormat; |
53 QVideoFrame::PixelFormat pixelFormat; |
52 int bits_per_pixel; |
54 int bits_per_pixel; |
160 void QXVideoSurface::setWinId(WId id) |
162 void QXVideoSurface::setWinId(WId id) |
161 { |
163 { |
162 if (id == m_winId) |
164 if (id == m_winId) |
163 return; |
165 return; |
164 |
166 |
|
167 #ifdef DEBUG_XV_SURFACE |
|
168 qDebug() << "QXVideoSurface::setWinId" << id; |
|
169 #endif |
|
170 |
165 if (m_image) |
171 if (m_image) |
166 XFree(m_image); |
172 XFree(m_image); |
167 |
173 |
168 if (m_gc) { |
174 if (m_gc) { |
169 XFreeGC(QX11Info::display(), m_gc); |
175 XFreeGC(QX11Info::display(), m_gc); |
171 } |
177 } |
172 |
178 |
173 if (m_portId != 0) |
179 if (m_portId != 0) |
174 XvUngrabPort(QX11Info::display(), m_portId, 0); |
180 XvUngrabPort(QX11Info::display(), m_portId, 0); |
175 |
181 |
|
182 QList<QVideoFrame::PixelFormat> prevFormats = m_supportedPixelFormats; |
176 m_supportedPixelFormats.clear(); |
183 m_supportedPixelFormats.clear(); |
177 m_formatIds.clear(); |
184 m_formatIds.clear(); |
178 |
185 |
179 m_winId = id; |
186 m_winId = id; |
180 |
187 |
193 m_image = 0; |
200 m_image = 0; |
194 |
201 |
195 QAbstractVideoSurface::stop(); |
202 QAbstractVideoSurface::stop(); |
196 } |
203 } |
197 |
204 |
198 emit supportedFormatsChanged(); |
205 if (m_supportedPixelFormats != prevFormats) { |
|
206 #ifdef DEBUG_XV_SURFACE |
|
207 qDebug() << "QXVideoSurface: supportedFormatsChanged"; |
|
208 #endif |
|
209 emit supportedFormatsChanged(); |
|
210 } |
199 } |
211 } |
200 |
212 |
201 QRect QXVideoSurface::displayRect() const |
213 QRect QXVideoSurface::displayRect() const |
202 { |
214 { |
203 return m_displayRect; |
215 return m_displayRect; |
256 return QList<QVideoFrame::PixelFormat>(); |
268 return QList<QVideoFrame::PixelFormat>(); |
257 } |
269 } |
258 |
270 |
259 bool QXVideoSurface::start(const QVideoSurfaceFormat &format) |
271 bool QXVideoSurface::start(const QVideoSurfaceFormat &format) |
260 { |
272 { |
261 //qDebug() << "QXVideoSurface::start" << format; |
273 #ifdef DEBUG_XV_SURFACE |
|
274 qDebug() << "QXVideoSurface::start" << format; |
|
275 #endif |
262 |
276 |
263 m_lastFrame = QVideoFrame(); |
277 m_lastFrame = QVideoFrame(); |
264 |
278 |
265 if (m_image) |
279 if (m_image) |
266 XFree(m_image); |
280 XFree(m_image); |
294 m_shminfo.shmid = shmget(IPC_PRIVATE, image->data_size, IPC_CREAT | 0777); |
308 m_shminfo.shmid = shmget(IPC_PRIVATE, image->data_size, IPC_CREAT | 0777); |
295 m_shminfo.shmaddr = image->data = (char*)shmat(m_shminfo.shmid, 0, 0); |
309 m_shminfo.shmaddr = image->data = (char*)shmat(m_shminfo.shmid, 0, 0); |
296 m_shminfo.readOnly = False; |
310 m_shminfo.readOnly = False; |
297 |
311 |
298 if (!XShmAttach(QX11Info::display(), &m_shminfo)) { |
312 if (!XShmAttach(QX11Info::display(), &m_shminfo)) { |
299 //qDebug() << "XShmAttach failed"; |
313 qWarning() << "XShmAttach failed" << format; |
300 return false; |
314 return false; |
301 } |
315 } |
302 |
316 |
303 if (!image) { |
317 if (!image) { |
304 setError(ResourceError); |
318 setError(ResourceError); |
429 for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) |
443 for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) |
430 portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; |
444 portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; |
431 } |
445 } |
432 } |
446 } |
433 XvFreeAdaptorInfo(adaptors); |
447 XvFreeAdaptorInfo(adaptors); |
434 } |
448 } |
|
449 |
|
450 if (!portFound) |
|
451 qWarning() << "QXVideoSurface::findPort: failed to find XVideo port"; |
435 |
452 |
436 return portFound; |
453 return portFound; |
437 } |
454 } |
438 |
455 |
439 void QXVideoSurface::querySupportedFormats() |
456 void QXVideoSurface::querySupportedFormats() |
470 break; |
487 break; |
471 } |
488 } |
472 } |
489 } |
473 XFree(imageFormats); |
490 XFree(imageFormats); |
474 } |
491 } |
475 } |
492 |
|
493 #ifdef DEBUG_XV_SURFACE |
|
494 qDebug() << "Supported pixel formats:" << m_supportedPixelFormats; |
|
495 #endif |
|
496 |
|
497 } |