diff options
author | Andreas Huber <andih@google.com> | 2010-11-08 11:50:14 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-11-08 11:56:08 -0800 |
commit | 3baff73198ce852fa60080bd32703028298b4d65 (patch) | |
tree | 91c41492bf470b1a3facc7da5b3dad6d97ffbd6c /media/libstagefright/AwesomePlayer.cpp | |
parent | 4974d5eaf838d893c418b85bd47f6f114d9b5aaa (diff) | |
parent | 85d9b4225d024bb0d602b48bd6d5219cbebd7b8e (diff) | |
download | frameworks_av-3baff73198ce852fa60080bd32703028298b4d65.zip frameworks_av-3baff73198ce852fa60080bd32703028298b4d65.tar.gz frameworks_av-3baff73198ce852fa60080bd32703028298b4d65.tar.bz2 |
resolved conflicts for merge of 31dc911a to gingerbread-plus-aosp
Change-Id: I2f51b2120b3c552566d91a7dc498a5e8b130205f
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 88 |
1 files changed, 71 insertions, 17 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index e0bcdc3..e65c943 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -103,12 +103,14 @@ struct AwesomeLocalRenderer : public AwesomeRenderer { OMX_COLOR_FORMATTYPE colorFormat, const sp<ISurface> &surface, size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight) + size_t decodedWidth, size_t decodedHeight, + int32_t rotationDegrees) : mTarget(NULL), mLibHandle(NULL) { init(previewOnly, componentName, colorFormat, surface, displayWidth, - displayHeight, decodedWidth, decodedHeight); + displayHeight, decodedWidth, decodedHeight, + rotationDegrees); } virtual void render(MediaBuffer *buffer) { @@ -141,7 +143,8 @@ private: OMX_COLOR_FORMATTYPE colorFormat, const sp<ISurface> &surface, size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight); + size_t decodedWidth, size_t decodedHeight, + int32_t rotationDegrees); AwesomeLocalRenderer(const AwesomeLocalRenderer &); AwesomeLocalRenderer &operator=(const AwesomeLocalRenderer &);; @@ -153,7 +156,8 @@ void AwesomeLocalRenderer::init( OMX_COLOR_FORMATTYPE colorFormat, const sp<ISurface> &surface, size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight) { + size_t decodedWidth, size_t decodedHeight, + int32_t rotationDegrees) { if (!previewOnly) { // We will stick to the vanilla software-color-converting renderer // for "previewOnly" mode, to avoid unneccessarily switching overlays @@ -162,6 +166,14 @@ void AwesomeLocalRenderer::init( mLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW); if (mLibHandle) { + typedef VideoRenderer *(*CreateRendererWithRotationFunc)( + const sp<ISurface> &surface, + const char *componentName, + OMX_COLOR_FORMATTYPE colorFormat, + size_t displayWidth, size_t displayHeight, + size_t decodedWidth, size_t decodedHeight, + int32_t rotationDegrees); + typedef VideoRenderer *(*CreateRendererFunc)( const sp<ISurface> &surface, const char *componentName, @@ -169,17 +181,36 @@ void AwesomeLocalRenderer::init( size_t displayWidth, size_t displayHeight, size_t decodedWidth, size_t decodedHeight); - CreateRendererFunc func = - (CreateRendererFunc)dlsym( + CreateRendererWithRotationFunc funcWithRotation = + (CreateRendererWithRotationFunc)dlsym( mLibHandle, - "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20" - "OMX_COLOR_FORMATTYPEjjjj"); + "_Z26createRendererWithRotationRKN7android2spINS_8" + "ISurfaceEEEPKc20OMX_COLOR_FORMATTYPEjjjji"); - if (func) { + if (funcWithRotation) { mTarget = - (*func)(surface, componentName, colorFormat, - displayWidth, displayHeight, - decodedWidth, decodedHeight); + (*funcWithRotation)( + surface, componentName, colorFormat, + displayWidth, displayHeight, + decodedWidth, decodedHeight, + rotationDegrees); + } else { + if (rotationDegrees != 0) { + LOGW("renderer does not support rotation."); + } + + CreateRendererFunc func = + (CreateRendererFunc)dlsym( + mLibHandle, + "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20" + "OMX_COLOR_FORMATTYPEjjjj"); + + if (func) { + mTarget = + (*func)(surface, componentName, colorFormat, + displayWidth, displayHeight, + decodedWidth, decodedHeight); + } } } } @@ -187,7 +218,7 @@ void AwesomeLocalRenderer::init( if (mTarget == NULL) { mTarget = new SoftwareRenderer( colorFormat, surface, displayWidth, displayHeight, - decodedWidth, decodedHeight); + decodedWidth, decodedHeight, rotationDegrees); } } @@ -806,6 +837,12 @@ void AwesomePlayer::initRenderer_l() { CHECK(meta->findInt32(kKeyWidth, &decodedWidth)); CHECK(meta->findInt32(kKeyHeight, &decodedHeight)); + int32_t rotationDegrees; + if (!mVideoTrack->getFormat()->findInt32( + kKeyRotation, &rotationDegrees)) { + rotationDegrees = 0; + } + mVideoRenderer.clear(); // Must ensure that mVideoRenderer's destructor is actually executed @@ -821,7 +858,8 @@ void AwesomePlayer::initRenderer_l() { mISurface, component, (OMX_COLOR_FORMATTYPE)format, decodedWidth, decodedHeight, - mVideoWidth, mVideoHeight)); + mVideoWidth, mVideoHeight, + rotationDegrees)); } else { // Other decoders are instantiated locally and as a consequence // allocate their buffers in local address space. @@ -831,7 +869,7 @@ void AwesomePlayer::initRenderer_l() { (OMX_COLOR_FORMATTYPE)format, mISurface, mVideoWidth, mVideoHeight, - decodedWidth, decodedHeight); + decodedWidth, decodedHeight, rotationDegrees); } } } @@ -1671,7 +1709,22 @@ void AwesomePlayer::finishAsyncPrepare_l() { if (mVideoWidth < 0 || mVideoHeight < 0) { notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0); } else { - notifyListener_l(MEDIA_SET_VIDEO_SIZE, mVideoWidth, mVideoHeight); + int32_t rotationDegrees; + if (!mVideoTrack->getFormat()->findInt32( + kKeyRotation, &rotationDegrees)) { + rotationDegrees = 0; + } + +#if 1 + if (rotationDegrees == 90 || rotationDegrees == 270) { + notifyListener_l( + MEDIA_SET_VIDEO_SIZE, mVideoHeight, mVideoWidth); + } else +#endif + { + notifyListener_l( + MEDIA_SET_VIDEO_SIZE, mVideoWidth, mVideoHeight); + } } notifyListener_l(MEDIA_PREPARED); @@ -1803,7 +1856,8 @@ status_t AwesomePlayer::resume() { state->mVideoWidth, state->mVideoHeight, state->mDecodedWidth, - state->mDecodedHeight); + state->mDecodedHeight, + 0); mVideoRendererIsPreview = true; |