diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | qtmultimedia.pro | 2 | ||||
-rw-r--r-- | src/plugins/blackberry/common/windowgrabber.cpp | 48 | ||||
-rw-r--r-- | src/plugins/blackberry/common/windowgrabber.h | 1 | ||||
-rw-r--r-- | src/plugins/blackberry/mediaplayer/bbplayervideorenderercontrol.cpp | 8 |
5 files changed, 52 insertions, 9 deletions
diff --git a/.qmake.conf b/.qmake.conf index 6aa780ca2..a7e09bffc 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,4 +1,4 @@ load(qt_build_config) CONFIG += qt_example_installs -MODULE_VERSION = 5.1.0 +MODULE_VERSION = 5.1.1 diff --git a/qtmultimedia.pro b/qtmultimedia.pro index 672cbc942..ed4a1bfc9 100644 --- a/qtmultimedia.pro +++ b/qtmultimedia.pro @@ -1,3 +1,5 @@ +requires(qtHaveModule(gui)) + load(configure) qtCompileTest(openal) win32 { diff --git a/src/plugins/blackberry/common/windowgrabber.cpp b/src/plugins/blackberry/common/windowgrabber.cpp index db070d8e5..144b5a693 100644 --- a/src/plugins/blackberry/common/windowgrabber.cpp +++ b/src/plugins/blackberry/common/windowgrabber.cpp @@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE WindowGrabber::WindowGrabber(QObject *parent) : QObject(parent), m_screenBuffer(0), + m_screenBufferWidth(-1), + m_screenBufferHeight(-1), m_active(false), m_screenContextInitialized(false), m_screenPixmapInitialized(false), @@ -145,7 +147,8 @@ void WindowGrabber::start() } int size[2] = { 0, 0 }; - result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, size); + + result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, size); if (result != 0) { cleanup(); qWarning() << "WindowGrabber: cannot get window size:" << strerror(errno); @@ -155,7 +158,18 @@ void WindowGrabber::start() m_screenBufferWidth = size[0]; m_screenBufferHeight = size[1]; - result = screen_set_pixmap_property_iv(m_screenPixmap, SCREEN_PROPERTY_BUFFER_SIZE, size); + updateFrameSize(); + + m_timer.start(); + + m_active = true; +} + +void WindowGrabber::updateFrameSize() +{ + int size[2] = { m_screenBufferWidth, m_screenBufferHeight }; + + int result = screen_set_pixmap_property_iv(m_screenPixmap, SCREEN_PROPERTY_BUFFER_SIZE, size); if (result != 0) { cleanup(); qWarning() << "WindowGrabber: cannot set pixmap size:" << strerror(errno); @@ -191,10 +205,6 @@ void WindowGrabber::start() qWarning() << "WindowGrabber: cannot get pixmap buffer stride:" << strerror(errno); return; } - - m_timer.start(); - - m_active = true; } void WindowGrabber::stop() @@ -284,7 +294,31 @@ QByteArray WindowGrabber::windowGroupId() const void WindowGrabber::grab() { - const int result = screen_read_window(m_window, m_screenPixmapBuffer, 0, 0, 0); + int size[2] = { 0, 0 }; + + int result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, size); + if (result != 0) { + cleanup(); + qWarning() << "WindowGrabber: cannot get window size:" << strerror(errno); + return; + } + + if (m_screenBufferWidth != size[0] || m_screenBufferHeight != size[1]) { + // The source viewport size changed, so we have to adapt our buffers + + if (m_screenPixmapBufferInitialized) { + screen_destroy_pixmap_buffer(m_screenPixmap); + m_screenPixmapBufferInitialized = false; + } + + m_screenBufferWidth = size[0]; + m_screenBufferHeight = size[1]; + + updateFrameSize(); + } + + const int rect[] = { 0, 0, m_screenBufferWidth, m_screenBufferHeight }; + result = screen_read_window(m_window, m_screenPixmapBuffer, 1, rect, 0); if (result != 0) return; diff --git a/src/plugins/blackberry/common/windowgrabber.h b/src/plugins/blackberry/common/windowgrabber.h index 547742da1..f8e3686a2 100644 --- a/src/plugins/blackberry/common/windowgrabber.h +++ b/src/plugins/blackberry/common/windowgrabber.h @@ -79,6 +79,7 @@ private slots: private: void cleanup(); + void updateFrameSize(); QTimer m_timer; diff --git a/src/plugins/blackberry/mediaplayer/bbplayervideorenderercontrol.cpp b/src/plugins/blackberry/mediaplayer/bbplayervideorenderercontrol.cpp index 096ae55ec..d9226d91f 100644 --- a/src/plugins/blackberry/mediaplayer/bbplayervideorenderercontrol.cpp +++ b/src/plugins/blackberry/mediaplayer/bbplayervideorenderercontrol.cpp @@ -142,8 +142,14 @@ void BbPlayerVideoRendererControl::resume() void BbPlayerVideoRendererControl::frameGrabbed(const QImage &frame) { if (m_surface) { - if (!m_surface->isActive()) + if (!m_surface->isActive()) { m_surface->start(QVideoSurfaceFormat(frame.size(), QVideoFrame::Format_ARGB32)); + } else { + if (m_surface->surfaceFormat().frameSize() != frame.size()) { + m_surface->stop(); + m_surface->start(QVideoSurfaceFormat(frame.size(), QVideoFrame::Format_ARGB32)); + } + } m_surface->present(frame.copy()); } |