diff options
author | Martijn Kaijser <martijn@xbmc.org> | 2015-12-28 13:12:28 +0100 |
---|---|---|
committer | Martijn Kaijser <martijn@xbmc.org> | 2015-12-28 13:12:28 +0100 |
commit | ce88c48113bf0aa1503cd65b3b8bdcd8f7b9b654 (patch) | |
tree | 9b6acae42d30af334aac9debfd433581c7aeae42 | |
parent | 8164fe22d49afb9b44372824bb239bed60ef10a5 (diff) | |
parent | 00dcc0ac0e12b220c0cfed32ed4ba11e34fa8535 (diff) |
Merge pull request #8673 from koying/droidRotate
FIX: [droid] handle video rotation
-rw-r--r-- | xbmc/android/jni/MediaFormat.cpp | 6 | ||||
-rw-r--r-- | xbmc/android/jni/MediaFormat.h | 1 | ||||
-rw-r--r-- | xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp | 15 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp | 11 |
4 files changed, 33 insertions, 0 deletions
diff --git a/xbmc/android/jni/MediaFormat.cpp b/xbmc/android/jni/MediaFormat.cpp index 09bc55cc0e..eb508542d7 100644 --- a/xbmc/android/jni/MediaFormat.cpp +++ b/xbmc/android/jni/MediaFormat.cpp @@ -40,6 +40,7 @@ std::string CJNIMediaFormat::KEY_IS_ADTS; std::string CJNIMediaFormat::KEY_CHANNEL_MASK; std::string CJNIMediaFormat::KEY_AAC_PROFILE; std::string CJNIMediaFormat::KEY_FLAC_COMPRESSION_LEVEL; +std::string CJNIMediaFormat::KEY_ROTATION; const char *CJNIMediaFormat::m_classname = "android/media/MediaFormat"; void CJNIMediaFormat::PopulateStaticFields() @@ -62,6 +63,11 @@ void CJNIMediaFormat::PopulateStaticFields() KEY_CHANNEL_MASK = jcast<std::string>(get_static_field<jhstring>(clazz, "KEY_CHANNEL_MASK")); KEY_AAC_PROFILE = jcast<std::string>(get_static_field<jhstring>(clazz, "KEY_AAC_PROFILE")); KEY_FLAC_COMPRESSION_LEVEL = jcast<std::string>(get_static_field<jhstring>(clazz, "KEY_FLAC_COMPRESSION_LEVEL")); + + if(GetSDKVersion() >= 23) + { + KEY_ROTATION = jcast<std::string>(get_static_field<jhstring>(clazz, "KEY_ROTATION")); + } } } diff --git a/xbmc/android/jni/MediaFormat.h b/xbmc/android/jni/MediaFormat.h index 8380604d6d..af99ff7407 100644 --- a/xbmc/android/jni/MediaFormat.h +++ b/xbmc/android/jni/MediaFormat.h @@ -60,6 +60,7 @@ public: static std::string KEY_CHANNEL_MASK; static std::string KEY_AAC_PROFILE; static std::string KEY_FLAC_COMPRESSION_LEVEL; + static std::string KEY_ROTATION; private: CJNIMediaFormat(); diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index 75c2dda87a..1c4715aadd 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -628,6 +628,21 @@ void CLinuxRendererGLES::RenderUpdateVideo(bool clear, DWORD flags, DWORD alpha) break; } + // Handle orientation + switch (m_renderOrientation) + { + case 90: + case 270: + { + int diff = (int) ((dstRect.Height() - dstRect.Width()) / 2); + dstRect = CRect(dstRect.x1 - diff, dstRect.y1, dstRect.x2 + diff, dstRect.y2); + break; + } + + default: + break; + } + mci->RenderUpdate(srcRect, dstRect); } } diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index 4ae4039001..8a7c5cd670 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -347,6 +347,12 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio return false; } + 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; + } + m_drop = false; m_hints = hints; @@ -904,6 +910,11 @@ bool CDVDVideoCodecAndroidMediaCodec::ConfigureMediaCodec(void) m_mime.c_str(), m_hints.width, m_hints.height); // some android devices forget to default the demux input max size mediaformat.setInteger(CJNIMediaFormat::KEY_MAX_INPUT_SIZE, 0); + if (CJNIMediaFormat::GetSDKVersion() >= 23 && m_render_surface) + { + // Handle rotation + mediaformat.setInteger(CJNIMediaFormat::KEY_ROTATION, m_hints.orientation); + } // handle codec extradata if (m_hints.extrasize) |