resolved conflicts for merge of 31dc911a to gingerbread-plus-aosp

Change-Id: I2f51b2120b3c552566d91a7dc498a5e8b130205f
This commit is contained in:
Andreas Huber
2010-11-08 11:50:14 -08:00
11 changed files with 243 additions and 91 deletions

View File

@@ -115,7 +115,8 @@ public:
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight) = 0; size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees) = 0;
// Note: These methods are _not_ virtual, it exists as a wrapper around // Note: These methods are _not_ virtual, it exists as a wrapper around
// the virtual "createRenderer" method above facilitating extraction // the virtual "createRenderer" method above facilitating extraction
@@ -125,14 +126,16 @@ public:
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight); size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees);
sp<IOMXRenderer> createRendererFromJavaSurface( sp<IOMXRenderer> createRendererFromJavaSurface(
JNIEnv *env, jobject javaSurface, JNIEnv *env, jobject javaSurface,
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight); size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees);
}; };
struct omx_message { struct omx_message {

View File

@@ -32,6 +32,14 @@ extern android::VideoRenderer *createRenderer(
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight); size_t decodedWidth, size_t decodedHeight);
extern android::VideoRenderer *createRendererWithRotation(
const android::sp<android::ISurface> &surface,
const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight,
int32_t rotationDegrees);
extern android::OMXPluginBase *createOMXPlugin(); extern android::OMXPluginBase *createOMXPlugin();
#endif // HARDWARE_API_H_ #endif // HARDWARE_API_H_

View File

@@ -32,6 +32,7 @@ enum {
kKeyMIMEType = 'mime', // cstring kKeyMIMEType = 'mime', // cstring
kKeyWidth = 'widt', // int32_t kKeyWidth = 'widt', // int32_t
kKeyHeight = 'heig', // int32_t kKeyHeight = 'heig', // int32_t
kKeyRotation = 'rotA', // int32_t (angle in degrees)
kKeyIFramesInterval = 'ifiv', // int32_t kKeyIFramesInterval = 'ifiv', // int32_t
kKeyStride = 'strd', // int32_t kKeyStride = 'strd', // int32_t
kKeySliceHeight = 'slht', // int32_t kKeySliceHeight = 'slht', // int32_t

View File

@@ -38,11 +38,13 @@ sp<IOMXRenderer> IOMX::createRenderer(
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight) { size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees) {
return createRenderer( return createRenderer(
surface->getISurface(), surface->getISurface(),
componentName, colorFormat, encodedWidth, encodedHeight, componentName, colorFormat, encodedWidth, encodedHeight,
displayWidth, displayHeight); displayWidth, displayHeight,
rotationDegrees);
} }
sp<IOMXRenderer> IOMX::createRendererFromJavaSurface( sp<IOMXRenderer> IOMX::createRendererFromJavaSurface(
@@ -50,7 +52,8 @@ sp<IOMXRenderer> IOMX::createRendererFromJavaSurface(
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight) { size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees) {
jclass surfaceClass = env->FindClass("android/view/Surface"); jclass surfaceClass = env->FindClass("android/view/Surface");
if (surfaceClass == NULL) { if (surfaceClass == NULL) {
LOGE("Can't find android/view/Surface"); LOGE("Can't find android/view/Surface");
@@ -67,7 +70,8 @@ sp<IOMXRenderer> IOMX::createRendererFromJavaSurface(
return createRenderer( return createRenderer(
surface, componentName, colorFormat, encodedWidth, surface, componentName, colorFormat, encodedWidth,
encodedHeight, displayWidth, displayHeight); encodedHeight, displayWidth, displayHeight,
rotationDegrees);
} }
class BpOMX : public BpInterface<IOMX> { class BpOMX : public BpInterface<IOMX> {
@@ -349,7 +353,8 @@ public:
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight) { size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
@@ -360,6 +365,7 @@ public:
data.writeInt32(encodedHeight); data.writeInt32(encodedHeight);
data.writeInt32(displayWidth); data.writeInt32(displayWidth);
data.writeInt32(displayHeight); data.writeInt32(displayHeight);
data.writeInt32(rotationDegrees);
remote()->transact(CREATE_RENDERER, data, &reply); remote()->transact(CREATE_RENDERER, data, &reply);
@@ -682,11 +688,13 @@ status_t BnOMX::onTransact(
size_t encodedHeight = (size_t)data.readInt32(); size_t encodedHeight = (size_t)data.readInt32();
size_t displayWidth = (size_t)data.readInt32(); size_t displayWidth = (size_t)data.readInt32();
size_t displayHeight = (size_t)data.readInt32(); size_t displayHeight = (size_t)data.readInt32();
int32_t rotationDegrees = data.readInt32();
sp<IOMXRenderer> renderer = sp<IOMXRenderer> renderer =
createRenderer(isurface, componentName, colorFormat, createRenderer(isurface, componentName, colorFormat,
encodedWidth, encodedHeight, encodedWidth, encodedHeight,
displayWidth, displayHeight); displayWidth, displayHeight,
rotationDegrees);
reply->writeStrongBinder(renderer->asBinder()); reply->writeStrongBinder(renderer->asBinder());

View File

@@ -103,12 +103,14 @@ struct AwesomeLocalRenderer : public AwesomeRenderer {
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
const sp<ISurface> &surface, const sp<ISurface> &surface,
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight) size_t decodedWidth, size_t decodedHeight,
int32_t rotationDegrees)
: mTarget(NULL), : mTarget(NULL),
mLibHandle(NULL) { mLibHandle(NULL) {
init(previewOnly, componentName, init(previewOnly, componentName,
colorFormat, surface, displayWidth, colorFormat, surface, displayWidth,
displayHeight, decodedWidth, decodedHeight); displayHeight, decodedWidth, decodedHeight,
rotationDegrees);
} }
virtual void render(MediaBuffer *buffer) { virtual void render(MediaBuffer *buffer) {
@@ -141,7 +143,8 @@ private:
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
const sp<ISurface> &surface, const sp<ISurface> &surface,
size_t displayWidth, size_t displayHeight, 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(const AwesomeLocalRenderer &);
AwesomeLocalRenderer &operator=(const AwesomeLocalRenderer &);; AwesomeLocalRenderer &operator=(const AwesomeLocalRenderer &);;
@@ -153,7 +156,8 @@ void AwesomeLocalRenderer::init(
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
const sp<ISurface> &surface, const sp<ISurface> &surface,
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight) { size_t decodedWidth, size_t decodedHeight,
int32_t rotationDegrees) {
if (!previewOnly) { if (!previewOnly) {
// We will stick to the vanilla software-color-converting renderer // We will stick to the vanilla software-color-converting renderer
// for "previewOnly" mode, to avoid unneccessarily switching overlays // for "previewOnly" mode, to avoid unneccessarily switching overlays
@@ -162,6 +166,14 @@ void AwesomeLocalRenderer::init(
mLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW); mLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW);
if (mLibHandle) { 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)( typedef VideoRenderer *(*CreateRendererFunc)(
const sp<ISurface> &surface, const sp<ISurface> &surface,
const char *componentName, const char *componentName,
@@ -169,17 +181,36 @@ void AwesomeLocalRenderer::init(
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight); size_t decodedWidth, size_t decodedHeight);
CreateRendererFunc func = CreateRendererWithRotationFunc funcWithRotation =
(CreateRendererFunc)dlsym( (CreateRendererWithRotationFunc)dlsym(
mLibHandle, mLibHandle,
"_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20" "_Z26createRendererWithRotationRKN7android2spINS_8"
"OMX_COLOR_FORMATTYPEjjjj"); "ISurfaceEEEPKc20OMX_COLOR_FORMATTYPEjjjji");
if (func) { if (funcWithRotation) {
mTarget = mTarget =
(*func)(surface, componentName, colorFormat, (*funcWithRotation)(
displayWidth, displayHeight, surface, componentName, colorFormat,
decodedWidth, decodedHeight); 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) { if (mTarget == NULL) {
mTarget = new SoftwareRenderer( mTarget = new SoftwareRenderer(
colorFormat, surface, displayWidth, displayHeight, 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(kKeyWidth, &decodedWidth));
CHECK(meta->findInt32(kKeyHeight, &decodedHeight)); CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
int32_t rotationDegrees;
if (!mVideoTrack->getFormat()->findInt32(
kKeyRotation, &rotationDegrees)) {
rotationDegrees = 0;
}
mVideoRenderer.clear(); mVideoRenderer.clear();
// Must ensure that mVideoRenderer's destructor is actually executed // Must ensure that mVideoRenderer's destructor is actually executed
@@ -821,7 +858,8 @@ void AwesomePlayer::initRenderer_l() {
mISurface, component, mISurface, component,
(OMX_COLOR_FORMATTYPE)format, (OMX_COLOR_FORMATTYPE)format,
decodedWidth, decodedHeight, decodedWidth, decodedHeight,
mVideoWidth, mVideoHeight)); mVideoWidth, mVideoHeight,
rotationDegrees));
} else { } else {
// Other decoders are instantiated locally and as a consequence // Other decoders are instantiated locally and as a consequence
// allocate their buffers in local address space. // allocate their buffers in local address space.
@@ -831,7 +869,7 @@ void AwesomePlayer::initRenderer_l() {
(OMX_COLOR_FORMATTYPE)format, (OMX_COLOR_FORMATTYPE)format,
mISurface, mISurface,
mVideoWidth, mVideoHeight, mVideoWidth, mVideoHeight,
decodedWidth, decodedHeight); decodedWidth, decodedHeight, rotationDegrees);
} }
} }
} }
@@ -1671,7 +1709,22 @@ void AwesomePlayer::finishAsyncPrepare_l() {
if (mVideoWidth < 0 || mVideoHeight < 0) { if (mVideoWidth < 0 || mVideoHeight < 0) {
notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0); notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0);
} else { } 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); notifyListener_l(MEDIA_PREPARED);
@@ -1803,7 +1856,8 @@ status_t AwesomePlayer::resume() {
state->mVideoWidth, state->mVideoWidth,
state->mVideoHeight, state->mVideoHeight,
state->mDecodedWidth, state->mDecodedWidth,
state->mDecodedHeight); state->mDecodedHeight,
0);
mVideoRendererIsPreview = true; mVideoRendererIsPreview = true;

View File

@@ -27,11 +27,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/DataSource.h> #include <media/stagefright/DataSource.h>
#include "include/ESDS.h" #include "include/ESDS.h"
#include <media/stagefright/MediaBuffer.h> #include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferGroup.h> #include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaSource.h> #include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h> #include <media/stagefright/MetaData.h>
@@ -766,55 +766,11 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
case FOURCC('t', 'k', 'h', 'd'): case FOURCC('t', 'k', 'h', 'd'):
{ {
if (chunk_data_size < 4) { status_t err;
return ERROR_MALFORMED; if ((err = parseTrackHeader(data_offset, chunk_data_size)) != OK) {
return err;
} }
uint8_t version;
if (mDataSource->readAt(data_offset, &version, 1) < 1) {
return ERROR_IO;
}
uint64_t ctime, mtime, duration;
int32_t id;
uint32_t width, height;
if (version == 1) {
if (chunk_data_size != 36 + 60) {
return ERROR_MALFORMED;
}
uint8_t buffer[36 + 60];
if (mDataSource->readAt(
data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) {
return ERROR_IO;
}
ctime = U64_AT(&buffer[4]);
mtime = U64_AT(&buffer[12]);
id = U32_AT(&buffer[20]);
duration = U64_AT(&buffer[28]);
width = U32_AT(&buffer[88]);
height = U32_AT(&buffer[92]);
} else if (version == 0) {
if (chunk_data_size != 24 + 60) {
return ERROR_MALFORMED;
}
uint8_t buffer[24 + 60];
if (mDataSource->readAt(
data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) {
return ERROR_IO;
}
ctime = U32_AT(&buffer[4]);
mtime = U32_AT(&buffer[8]);
id = U32_AT(&buffer[12]);
duration = U32_AT(&buffer[20]);
width = U32_AT(&buffer[76]);
height = U32_AT(&buffer[80]);
}
mLastTrack->meta->setInt32(kKeyTrackID, id);
*offset += chunk_size; *offset += chunk_size;
break; break;
} }
@@ -1275,6 +1231,91 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
return OK; return OK;
} }
status_t MPEG4Extractor::parseTrackHeader(
off_t data_offset, off_t data_size) {
if (data_size < 4) {
return ERROR_MALFORMED;
}
uint8_t version;
if (mDataSource->readAt(data_offset, &version, 1) < 1) {
return ERROR_IO;
}
size_t dynSize = (version == 1) ? 36 : 24;
uint8_t buffer[36 + 60];
if (data_size != (off_t)dynSize + 60) {
return ERROR_MALFORMED;
}
if (mDataSource->readAt(
data_offset, buffer, data_size) < (ssize_t)data_size) {
return ERROR_IO;
}
uint64_t ctime, mtime, duration;
int32_t id;
if (version == 1) {
ctime = U64_AT(&buffer[4]);
mtime = U64_AT(&buffer[12]);
id = U32_AT(&buffer[20]);
duration = U64_AT(&buffer[28]);
} else if (version == 0) {
ctime = U32_AT(&buffer[4]);
mtime = U32_AT(&buffer[8]);
id = U32_AT(&buffer[12]);
duration = U32_AT(&buffer[20]);
}
mLastTrack->meta->setInt32(kKeyTrackID, id);
size_t matrixOffset = dynSize + 16;
int32_t a00 = U32_AT(&buffer[matrixOffset]);
int32_t a01 = U32_AT(&buffer[matrixOffset + 4]);
int32_t dx = U32_AT(&buffer[matrixOffset + 8]);
int32_t a10 = U32_AT(&buffer[matrixOffset + 12]);
int32_t a11 = U32_AT(&buffer[matrixOffset + 16]);
int32_t dy = U32_AT(&buffer[matrixOffset + 20]);
#if 0
LOGI("x' = %.2f * x + %.2f * y + %.2f",
a00 / 65536.0f, a01 / 65536.0f, dx / 65536.0f);
LOGI("y' = %.2f * x + %.2f * y + %.2f",
a10 / 65536.0f, a11 / 65536.0f, dy / 65536.0f);
#endif
uint32_t rotationDegrees;
static const int32_t kFixedOne = 0x10000;
if (a00 == kFixedOne && a01 == 0 && a10 == 0 && a11 == kFixedOne) {
// Identity, no rotation
rotationDegrees = 0;
} else if (a00 == 0 && a01 == kFixedOne && a10 == -kFixedOne && a11 == 0) {
rotationDegrees = 90;
} else if (a00 == 0 && a01 == -kFixedOne && a10 == kFixedOne && a11 == 0) {
rotationDegrees = 270;
} else if (a00 == -kFixedOne && a01 == 0 && a10 == 0 && a11 == -kFixedOne) {
rotationDegrees = 180;
} else {
LOGW("We only support 0,90,180,270 degree rotation matrices");
rotationDegrees = 0;
}
if (rotationDegrees != 0) {
mLastTrack->meta->setInt32(kKeyRotation, rotationDegrees);
}
#if 0
uint32_t width = U32_AT(&buffer[dynSize + 52]);
uint32_t height = U32_AT(&buffer[dynSize + 56]);
#endif
return OK;
}
status_t MPEG4Extractor::parseMetaData(off_t offset, size_t size) { status_t MPEG4Extractor::parseMetaData(off_t offset, size_t size) {
if (size < 4) { if (size < 4) {
return ERROR_MALFORMED; return ERROR_MALFORMED;
@@ -1588,7 +1629,7 @@ MPEG4Source::MPEG4Source(
const uint8_t *ptr = (const uint8_t *)data; const uint8_t *ptr = (const uint8_t *)data;
CHECK(size >= 7); CHECK(size >= 7);
CHECK_EQ(ptr[0], 1); // configurationVersion == 1 CHECK_EQ((unsigned)ptr[0], 1u); // configurationVersion == 1
// The number of bytes used to encode the length of a NAL unit. // The number of bytes used to encode the length of a NAL unit.
mNALLengthSize = 1 + (ptr[4] & 3); mNALLengthSize = 1 + (ptr[4] & 3);
@@ -1736,7 +1777,7 @@ status_t MPEG4Source::read(
} }
uint32_t sampleTime; uint32_t sampleTime;
CHECK_EQ(OK, mSampleTable->getMetaDataForSample( CHECK_EQ((status_t)OK, mSampleTable->getMetaDataForSample(
sampleIndex, NULL, NULL, &sampleTime)); sampleIndex, NULL, NULL, &sampleTime));
if (mode == ReadOptions::SEEK_CLOSEST) { if (mode == ReadOptions::SEEK_CLOSEST) {
@@ -1783,7 +1824,7 @@ status_t MPEG4Source::read(
err = mGroup->acquire_buffer(&mBuffer); err = mGroup->acquire_buffer(&mBuffer);
if (err != OK) { if (err != OK) {
CHECK_EQ(mBuffer, NULL); CHECK(mBuffer == NULL);
return err; return err;
} }
} }

View File

@@ -30,7 +30,8 @@ SoftwareRenderer::SoftwareRenderer(
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
const sp<ISurface> &surface, const sp<ISurface> &surface,
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight) size_t decodedWidth, size_t decodedHeight,
int32_t rotationDegrees)
: mColorFormat(colorFormat), : mColorFormat(colorFormat),
mConverter(colorFormat, OMX_COLOR_Format16bitRGB565), mConverter(colorFormat, OMX_COLOR_Format16bitRGB565),
mISurface(surface), mISurface(surface),
@@ -56,10 +57,20 @@ SoftwareRenderer::SoftwareRenderer(
CHECK(mMemoryHeap->heapID() >= 0); CHECK(mMemoryHeap->heapID() >= 0);
CHECK(mConverter.isValid()); CHECK(mConverter.isValid());
uint32_t orientation;
switch (rotationDegrees) {
case 0: orientation = ISurface::BufferHeap::ROT_0; break;
case 90: orientation = ISurface::BufferHeap::ROT_90; break;
case 180: orientation = ISurface::BufferHeap::ROT_180; break;
case 270: orientation = ISurface::BufferHeap::ROT_270; break;
default: orientation = ISurface::BufferHeap::ROT_0; break;
}
ISurface::BufferHeap bufferHeap( ISurface::BufferHeap bufferHeap(
mDisplayWidth, mDisplayHeight, mDisplayWidth, mDisplayHeight,
mDecodedWidth, mDecodedHeight, mDecodedWidth, mDecodedHeight,
PIXEL_FORMAT_RGB_565, PIXEL_FORMAT_RGB_565,
orientation, 0,
mMemoryHeap); mMemoryHeap);
status_t err = mISurface->registerBuffers(bufferHeap); status_t err = mISurface->registerBuffers(bufferHeap);

View File

@@ -88,6 +88,8 @@ private:
bool mIsDrm; bool mIsDrm;
status_t parseDrmSINF(off_t *offset, off_t data_offset); status_t parseDrmSINF(off_t *offset, off_t data_offset);
status_t parseTrackHeader(off_t data_offset, off_t data_size);
MPEG4Extractor(const MPEG4Extractor &); MPEG4Extractor(const MPEG4Extractor &);
MPEG4Extractor &operator=(const MPEG4Extractor &); MPEG4Extractor &operator=(const MPEG4Extractor &);
}; };

View File

@@ -92,7 +92,8 @@ public:
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight); size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees);
virtual void binderDied(const wp<IBinder> &the_late_who); virtual void binderDied(const wp<IBinder> &the_late_who);

View File

@@ -33,7 +33,8 @@ public:
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
const sp<ISurface> &surface, const sp<ISurface> &surface,
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight); size_t decodedWidth, size_t decodedHeight,
int32_t rotationDegrees = 0);
virtual ~SoftwareRenderer(); virtual ~SoftwareRenderer();

View File

@@ -459,7 +459,8 @@ sp<IOMXRenderer> OMX::createRenderer(
const char *componentName, const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat, OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight, size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight) { size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees) {
Mutex::Autolock autoLock(mLock); Mutex::Autolock autoLock(mLock);
VideoRenderer *impl = NULL; VideoRenderer *impl = NULL;
@@ -467,6 +468,14 @@ sp<IOMXRenderer> OMX::createRenderer(
void *libHandle = dlopen("libstagefrighthw.so", RTLD_NOW); void *libHandle = dlopen("libstagefrighthw.so", RTLD_NOW);
if (libHandle) { if (libHandle) {
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)( typedef VideoRenderer *(*CreateRendererFunc)(
const sp<ISurface> &surface, const sp<ISurface> &surface,
const char *componentName, const char *componentName,
@@ -474,22 +483,35 @@ sp<IOMXRenderer> OMX::createRenderer(
size_t displayWidth, size_t displayHeight, size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight); size_t decodedWidth, size_t decodedHeight);
CreateRendererFunc func = CreateRendererWithRotationFunc funcWithRotation =
(CreateRendererFunc)dlsym( (CreateRendererWithRotationFunc)dlsym(
libHandle, libHandle,
"_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20" "_Z26createRendererWithRotationRKN7android2spINS_8"
"OMX_COLOR_FORMATTYPEjjjj"); "ISurfaceEEEPKc20OMX_COLOR_FORMATTYPEjjjji");
if (func) { if (funcWithRotation) {
impl = (*func)(surface, componentName, colorFormat, impl = (*funcWithRotation)(
displayWidth, displayHeight, encodedWidth, encodedHeight); surface, componentName, colorFormat,
displayWidth, displayHeight, encodedWidth, encodedHeight,
rotationDegrees);
} else {
CreateRendererFunc func =
(CreateRendererFunc)dlsym(
libHandle,
"_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20"
"OMX_COLOR_FORMATTYPEjjjj");
if (impl) { if (func) {
impl = new SharedVideoRenderer(libHandle, impl); impl = (*func)(surface, componentName, colorFormat,
libHandle = NULL; displayWidth, displayHeight, encodedWidth, encodedHeight);
} }
} }
if (impl) {
impl = new SharedVideoRenderer(libHandle, impl);
libHandle = NULL;
}
if (libHandle) { if (libHandle) {
dlclose(libHandle); dlclose(libHandle);
libHandle = NULL; libHandle = NULL;