aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Kaijser <martijn@xbmc.org>2017-01-02 19:12:02 +0100
committerGitHub <noreply@github.com>2017-01-02 19:12:02 +0100
commit2fb0a61958ca0bcac557a289a1092cd2bd993c00 (patch)
treeecb392ff99d530e0f9f862e197fcc666e8c604fe
parent7c34a6a950a83bd0cfe904ba12607d42653d026d (diff)
parentc7950a07881926e2a333784d507dc6a421457435 (diff)
Merge pull request #11342 from MartijnKaijser/11337
reADD: [amcs] Handle Rotation
-rw-r--r--xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp12
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp57
2 files changed, 69 insertions, 0 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp
index 389f175188..c73b0bb51a 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp
@@ -370,6 +370,11 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio
// Won't work reliably
return false;
}
+ else if (hints.orientation && m_render_surface && CJNIMediaFormat::GetSDKVersion() < 23)
+ {
+ CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open - %s\n", "Surface does not support orientation before API 23");
+ return false;
+ }
else if (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_VIDEOPLAYER_USEMEDIACODEC) &&
!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_VIDEOPLAYER_USEMEDIACODECSURFACE))
return false;
@@ -964,6 +969,13 @@ bool CDVDVideoCodecAndroidMediaCodec::ConfigureMediaCodec(void)
// some android devices forget to default the demux input max size
mediaformat.setInteger(CJNIMediaFormat::KEY_MAX_INPUT_SIZE, 0);
+ if (CJNIBase::GetSDKVersion() >= 23 && m_render_surface)
+ {
+ // Handle rotation
+ mediaformat.setInteger(CJNIMediaFormat::KEY_ROTATION, m_hints.orientation);
+ }
+
+
// handle codec extradata
if (m_hints.extrasize)
{
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp
index 1d759b5b45..a7287c6b72 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp
@@ -147,6 +147,63 @@ bool CRendererMediaCodecSurface::RenderHook(int index)
break;
}
+
+ // Handle orientation
+ switch (m_renderOrientation)
+ {
+ case 90:
+ case 270:
+ {
+ int diffX = 0;
+ int diffY = 0;
+ int centerX = 0;
+ int centerY = 0;
+
+ int newWidth = dstRect.Height(); // new width is old height
+ int newHeight = dstRect.Width(); // new height is old width
+ int diffWidth = newWidth - dstRect.Width(); // difference between old and new width
+ int diffHeight = newHeight - dstRect.Height(); // difference between old and new height
+
+ // if the new width is bigger then the old or
+ // the new height is bigger then the old - we need to scale down
+ if (diffWidth > 0 || diffHeight > 0 )
+ {
+ float aspectRatio = GetAspectRatio();
+ // scale to fit screen width because
+ // the difference in width is bigger then the
+ // difference in height
+ if (diffWidth > diffHeight)
+ {
+ newWidth = dstRect.Width(); // clamp to the width of the old dest rect
+ newHeight *= aspectRatio;
+ }
+ else // scale to fit screen height
+ {
+ newHeight = dstRect.Height(); // clamp to the height of the old dest rect
+ newWidth /= aspectRatio;
+ }
+ }
+
+ // calculate the center point of the view
+ centerX = m_viewRect.x1 + m_viewRect.Width() / 2;
+ centerY = m_viewRect.y1 + m_viewRect.Height() / 2;
+
+ // calculate the number of pixels we need to go in each
+ // x direction from the center point
+ diffX = newWidth / 2;
+ // calculate the number of pixels we need to go in each
+ // y direction from the center point
+ diffY = newHeight / 2;
+
+ dstRect = CRect(centerX - diffX, centerY - diffY, centerX + diffX, centerY + diffY);
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
mci->RenderUpdate(srcRect, dstRect);
}
return true;