From e09a2951e063ec1f683f8851ed205f40111ebd1b Mon Sep 17 00:00:00 2001 From: Zhao Halley Date: Mon, 12 Aug 2013 08:34:33 +0800 Subject: [PATCH] Add video support of wayland platform (x86/vaapi) - Add video platform: SharedVideoPlatformSurfaceTizenWayland - disable WTF_USE_TIZEN_GSTREAMER_VIDEO_SET_SINK when vaapisink is possible (x86) - deal with the difference of surface id (m_bufferHandle) and native surface (wl_surface) for wayland platform surface - Accept 'frame-rendered' signal to update video layer - only luma component is rendered Change-Id: I1a1cc519c9778f9deaeb471fb50297abb88bfd50 --- Source/WebCore/PlatformTizen.cmake | 1 + .../gstreamer/MediaPlayerPrivateGStreamer.cpp | 15 +++- .../tizen/SharedVideoPlatformSurfaceTizen.cpp | 4 + .../tizen/SharedVideoPlatformSurfaceTizen.h | 1 + .../graphics/gstreamer/tizen/VideoLayerTizen.cpp | 45 +++++++++-- .../SharedVideoPlatformSurfaceTizenWayland.cpp | 86 ++++++++++++++++++++++ .../tizen/SharedVideoPlatformSurfaceTizenWayland.h | 59 +++++++++++++++ Source/cmake/OptionsTizen.cmake | 2 +- 8 files changed, 204 insertions(+), 9 deletions(-) create mode 100644 Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.cpp create mode 100644 Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.h diff --git a/Source/WebCore/PlatformTizen.cmake b/Source/WebCore/PlatformTizen.cmake index e2b10d2..cf4b9ca 100755 --- a/Source/WebCore/PlatformTizen.cmake +++ b/Source/WebCore/PlatformTizen.cmake @@ -236,6 +236,7 @@ IF (WTF_USE_ACCELERATED_COMPOSITING AND ENABLE_WEBKIT2) platform/graphics/surfaces/wayland/WaylandDisplay.cpp platform/graphics/surfaces/wayland/WaylandSurface.cpp platform/graphics/surfaces/wayland/GraphicsSurfaceWayland.cpp + platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.cpp ) ENDIF() ENDIF() diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index f9a9d69..1530578 100755 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -236,7 +236,7 @@ static GstBusSyncReply mediaPlayerPrivateSyncHandler(GstBus* bus, GstMessage* me if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT) return GST_BUS_PASS; #ifdef GST_API_VERSION_1 - if (gst_is_video_overlay_prepare_window_handle_message(message)) + if (!gst_is_video_overlay_prepare_window_handle_message(message)) #else if (!gst_structure_has_name (message->structure, "prepare-xid")) #endif @@ -1110,6 +1110,15 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) LOG_MEDIA_MESSAGE("Duration changed"); durationChanged(); break; + case GST_MESSAGE_ELEMENT: +#ifdef GST_API_VERSION_1 + if (gst_structure_has_name (structure, "frame-rendered")) { +#else + if (gst_structure_has_name (message->structure, "frame-rendered")) { +#endif + m_videoLayer->notifySyncRequired(); + } + break; default: LOG_MEDIA_MESSAGE("Unhandled GStreamer message type: %s", GST_MESSAGE_TYPE_NAME(message)); @@ -2363,6 +2372,7 @@ IntSize MediaPlayerPrivateGStreamer::scaleHDVideoToDisplaySize(int videoWidth, i #endif void MediaPlayerPrivateGStreamer::xWindowIdPrepared(GstMessage* message) { +#if !PLATFORM(WAYLAND) #if USE(ACCELERATED_VIDEO_VAAPI) int displayWidth, displayHeight; #endif @@ -2391,6 +2401,9 @@ void MediaPlayerPrivateGStreamer::xWindowIdPrepared(GstMessage* message) m_videoSize = IntSize(videoWidth, videoHeight); #endif m_videoLayer->setOverlay(m_videoSize); +#else + m_videoLayer->setOverlay(IntSize(1,1)); +#endif } #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) diff --git a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp index dad93d1..a6ce375 100644 --- a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp @@ -36,6 +36,8 @@ #if PLATFORM(X11) #include "SharedVideoPlatformSurfaceTizenX.h" +#elif PLATFORM(WAYLAND) +#include "SharedVideoPlatformSurfaceTizenWayland.h" #endif namespace WebCore { @@ -44,6 +46,8 @@ PassOwnPtr SharedVideoPlatformSurfaceTizen::cre { #if PLATFORM(X11) return adoptPtr(new SharedVideoPlatformSurfaceTizenX(size)); +#elif PLATFORM(WAYLAND) + return adoptPtr(new SharedVideoPlatformSurfaceTizenWayland(size)); #else return nullptr; #endif diff --git a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h index f828c26..9bd4469 100644 --- a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h +++ b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h @@ -55,6 +55,7 @@ public: void copySurface(SharedVideoPlatformSurfaceTizen*, CopySurfaceType); void platformSurfaceUpdated(); int graphicsSurfaceFlags() const; + virtual void *nativeVideoSurface() {return (void*)m_bufferHandle;}; protected: SharedVideoPlatformSurfaceTizen(const IntSize&); diff --git a/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp b/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp index d462bea..cff81fb 100644 --- a/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp @@ -34,14 +34,29 @@ #endif #include #include +#if PLATFORM(X11) +// no header file is required for X, becase media pipeline creates X connecttion of its own. +#elif PLATFORM(WAYLAND) +#include "WaylandDisplay.h" +#endif #else +#if PLATFORM(X11) #include #include #include +#elif PLATFORM(WAYLAND) +// note-1: +// there is no implementation of wayland platform for !TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE, +// because it is not possible to composite wl_surface by cairo. +#endif #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) #if !ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) || USE(TIZEN_GSTREAMER_VIDEO_SET_SINK) +#if PLATFORM(X11) static Display* g_nativeDisplay = 0; +#elif PLATFORM(WAYLAND) +// see above note-1 +#endif #endif namespace WebCore { @@ -61,12 +76,17 @@ VideoLayerTizen::VideoLayerTizen(HTMLMediaElement* media) #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) && !USE(TIZEN_GSTREAMER_VIDEO_SET_SINK) : m_videoSink(0) #else +#if PLATFORM(X11) : m_platformSurfaceID(0) , m_nativeWindow(0) +#elif PLATFORM(WAYLAND) +// see above note-1 +#endif #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) , m_media(media) { -#if !ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) || USE(TIZEN_GSTREAMER_VIDEO_SET_SINK) +#if (!ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) || USE(TIZEN_GSTREAMER_VIDEO_SET_SINK)) +#if PLATFORM(X11) if (!g_nativeDisplay) g_nativeDisplay = XOpenDisplay(0); @@ -77,6 +97,9 @@ VideoLayerTizen::VideoLayerTizen(HTMLMediaElement* media) 0, 0, 1, 1, 0, BlackPixel(g_nativeDisplay, 0), WhitePixel(g_nativeDisplay, 0)); XFlush(g_nativeDisplay); +#elif PLATFORM(WAYLAND) +// see above note-1 +#endif #endif } @@ -93,6 +116,7 @@ VideoLayerTizen::~VideoLayerTizen() m_videoSink = 0; #else +#if PLATFORM(X11) if (m_platformSurfaceID) { XFreePixmap(g_nativeDisplay, m_platformSurfaceID); m_platformSurfaceID = 0; @@ -101,6 +125,9 @@ VideoLayerTizen::~VideoLayerTizen() XDestroyWindow(g_nativeDisplay, m_nativeWindow); m_nativeWindow = 0; } +#elif PLATFORM(WAYLAND) +// see above note-1 +#endif #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) } @@ -147,7 +174,11 @@ GstElement* VideoLayerTizen::createVideoSink() #else setVaapiEnv(); GstElement* videoSink = gst_element_factory_make("vaapisink", "vaapisink"); +#if PLATFORM(X11) g_object_set(videoSink, "is-pixmap", 1, NULL); +#elif PLATFORM(WAYLAND) + g_object_set(videoSink, "wl-display", WaylandDisplay::instance()->nativeDisplay(), NULL); +#endif #endif m_videoSink = videoSink; @@ -188,14 +219,12 @@ void VideoLayerTizen::setOverlay(IntSize size) m_platformSurface->copySurface(m_platformSurfaceToBeRemoved.get(), SharedVideoPlatformSurfaceTizen::FitToWidth); #ifdef GST_API_VERSION_1 - gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(m_videoSink), m_platformSurface->handle()); + gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(m_videoSink), (guintptr)m_platformSurface->nativeVideoSurface()); #else - gst_x_overlay_set_window_handle(GST_X_OVERLAY(m_videoSink), m_platformSurface->handle()); + gst_x_overlay_set_window_handle(GST_X_OVERLAY(m_videoSink), (guintptr)m_platformSurface->nativeVideoSurface()); #endif #if !USE(ACCELERATED_VIDEO_VAAPI) g_object_set(m_videoSink, "rotate", 0, NULL); -#else - g_object_set(m_videoSink, "is-pixmap", 1, NULL); #endif } @@ -204,11 +233,10 @@ void VideoLayerTizen::paintCurrentFrameInContext(GraphicsContext* context, const if (m_platformSurface) m_platformSurface->paintCurrentFrameInContext(context, rect); } - #else - void VideoLayerTizen::paintVideoLayer(IntSize videoSize) { +#if PLATFORM(X11) if (videoSize.isEmpty()) return; @@ -233,6 +261,9 @@ void VideoLayerTizen::paintVideoLayer(IntSize videoSize) XFlush(g_nativeDisplay); syncLayer(this); +#elif PLATFORM(WAYLAND) + notImplemented(); +#endif } #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) diff --git a/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.cpp b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.cpp new file mode 100644 index 0000000..788c663 --- /dev/null +++ b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if PLATFORM(WAYLAND) && USE(EGL) +#include "SharedVideoPlatformSurfaceTizenWayland.h" +#include "GraphicsSurface.h" +#include "WaylandDisplay.h" +#include "NotImplemented.h" + +namespace WebCore { + +SharedVideoPlatformSurfaceTizenWayland::SharedVideoPlatformSurfaceTizenWayland(const IntSize& size) + : SharedVideoPlatformSurfaceTizen(size) +{ + m_surface = WaylandDisplay::instance()->createSurface(); + + if (!m_surface) { + LOG_ERROR("Failed to create surface."); + destroy(); + return; + } + + m_bufferHandle = m_surface->handle(); +} + +SharedVideoPlatformSurfaceTizenWayland::~SharedVideoPlatformSurfaceTizenWayland() +{ + destroy(); +} + +void *SharedVideoPlatformSurfaceTizenWayland::nativeVideoSurface() +{ + return m_surface->wlSurface(); +} + +void SharedVideoPlatformSurfaceTizenWayland::destroy() +{ + if (m_surface) + m_surface->deleteFrameCallBack(); + + m_surface = nullptr; + m_bufferHandle = 0; +} + +void SharedVideoPlatformSurfaceTizenWayland::platformPaintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) +{ + notImplemented(); +} + +void SharedVideoPlatformSurfaceTizenWayland::platformCopySurface(SharedVideoPlatformSurfaceTizen* other, float xPosition, float xScale, float yPosition, float yScale) +{ + notImplemented(); +} + +void SharedVideoPlatformSurfaceTizenWayland::clearPlatformSurface() +{ + notImplemented(); +} + +} + +#endif diff --git a/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.h b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.h new file mode 100644 index 0000000..15a5c0a --- /dev/null +++ b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenWayland.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SharedVideoPlatformSurfaceTizenWayland_h +#define SharedVideoPlatformSurfaceTizenWayland_h + +#if PLATFORM(WAYLAND) + +#include "SharedVideoPlatformSurfaceTizen.h" +#include "WaylandSurface.h" + +namespace WebCore { + +class SharedVideoPlatformSurfaceTizenWayland : public SharedVideoPlatformSurfaceTizen { +public: + SharedVideoPlatformSurfaceTizenWayland(const IntSize&); + virtual ~SharedVideoPlatformSurfaceTizenWayland(); + virtual void* nativeVideoSurface(); + +protected: + virtual void platformCopySurface(SharedVideoPlatformSurfaceTizen* other, float xPosition, float xScale, float yPosition, float yScale) OVERRIDE; + virtual void platformPaintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) OVERRIDE; + virtual void destroy(); +private: + void clearPlatformSurface(); + void registerDamageHandler(); + void unregisterDamageHandler(); + + OwnPtr m_surface; +}; + +} + +#endif + +#endif + diff --git a/Source/cmake/OptionsTizen.cmake b/Source/cmake/OptionsTizen.cmake index dd523fd..50f12bb 100644 --- a/Source/cmake/OptionsTizen.cmake +++ b/Source/cmake/OptionsTizen.cmake @@ -309,7 +309,7 @@ IF (WTF_USE_TILED_BACKING_STORE) ADD_DEFINITIONS(-DWTF_USE_TEXTURE_MAPPER=1) ENDIF () -IF (ENABLE_TIZEN_GSTREAMER_VIDEO_SET_SINK) +IF (ENABLE_TIZEN_GSTREAMER_VIDEO_SET_SINK AND NOT ("${EFL_TARGET}" STREQUAL "i386")) SET(WTF_USE_TIZEN_GSTREAMER_VIDEO_SET_SINK 1) ADD_DEFINITIONS(-DWTF_USE_TIZEN_GSTREAMER_VIDEO_SET_SINK=1) ENDIF () -- 2.7.4