[GStreamer] video orientation support
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jun 2016 08:32:06 +0000 (08:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jun 2016 08:32:06 +0000 (08:32 +0000)
commit5e2e4846d5e20278dd6689f6eb3815891c155f1b
tree583d77953e06162a3fdcf29551dd4442cead1f8e
parent14aadbbcb4f37c76d089017a0c9179c075afed89
[GStreamer] video orientation support
https://bugs.webkit.org/show_bug.cgi?id=148524

Patch by Miguel Gomez <magomez@igalia.com> on 2016-06-21
Reviewed by Philippe Normand.

Source/WebCore:

Rotate video frames to follow the orientation metadata in the video file.
When accelerated compositing is disabled, the rotation is performed by a videoflip element added
to the playbin.
When accelerated compositing is enabled, the rotation is peformed by the TextureMapper in response
to a rotation flag set on the frame buffers.

Test: media/video-orientation.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::handleMessage):
Handle the GST_MESSAGE_TAG message from the bin.
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
Add the videflip element to the bin when accelerated compositing is disabled.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::GstVideoFrameHolder::GstVideoFrameHolder):
Receive and use extra flags for the TextureMapper.
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::naturalSize):
When using accelerated compositing, transpose the video size if the rotation is 90 or 270 degrees.
(WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor):
Add rotation flag to frame holder and layer buffer.
(WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper):
Use rotation flag when requesting the TextureMapper to draw.
(WebCore::MediaPlayerPrivateGStreamerBase::setVideoSourceRotation):
Function to store the video rotation.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
Add bits to store the video rotation.
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
Modify the patternTransform according to the rotation flag passed.
* platform/graphics/texmap/TextureMapperGL.h:
Add new flags to handle the video souce rotation.
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
(WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
Change the drawTexture method used so custom flags can be passed.
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
(WebCore::TextureMapperPlatformLayerBuffer::setExtraFlags):
New method to set TextureMapper flags.

LayoutTests:

Test whether the video is properly being displayed by checking the video
element size.

* media/content/no-rotation.mp4: Added.
* media/content/rotation-180.mp4: Added.
* media/content/rotation-270.mp4: Added.
* media/content/rotation-90.mp4: Added.
* media/video-orientation-expected.txt: Added.
* media/video-orientation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/media/content/no-rotation.mp4 [new file with mode: 0644]
LayoutTests/media/content/rotation-180.mp4 [new file with mode: 0644]
LayoutTests/media/content/rotation-270.mp4 [new file with mode: 0644]
LayoutTests/media/content/rotation-90.mp4 [new file with mode: 0644]
LayoutTests/media/video-orientation-expected.txt [new file with mode: 0644]
LayoutTests/media/video-orientation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h