Loading include/media/stagefright/SimpleDecodingSource.h +2 −1 Original line number Diff line number Diff line Loading @@ -71,12 +71,13 @@ private: // Construct this using a codec, source and looper. SimpleDecodingSource( const sp<MediaCodec> &codec, const sp<IMediaSource> &source, const sp<ALooper> &looper, bool usingSurface, const sp<AMessage> &format); bool usingSurface, bool isVorbis, const sp<AMessage> &format); sp<MediaCodec> mCodec; sp<IMediaSource> mSource; sp<ALooper> mLooper; bool mUsingSurface; bool mIsVorbis; enum State { INIT, STARTED, Loading media/libstagefright/SimpleDecodingSource.cpp +20 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <media/ICrypto.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/foundation/ALooper.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/foundation/AUtils.h> Loading Loading @@ -74,7 +75,10 @@ sp<SimpleDecodingSource> SimpleDecodingSource::Create( err = codec->getOutputFormat(&format); } if (err == OK) { return new SimpleDecodingSource(codec, source, looper, surface != NULL, format); return new SimpleDecodingSource(codec, source, looper, surface != NULL, strcmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS) == 0, format); } ALOGD("Failed to configure codec '%s'", componentName.c_str()); Loading @@ -90,11 +94,12 @@ sp<SimpleDecodingSource> SimpleDecodingSource::Create( SimpleDecodingSource::SimpleDecodingSource( const sp<MediaCodec> &codec, const sp<IMediaSource> &source, const sp<ALooper> &looper, bool usingSurface, const sp<AMessage> &format) bool usingSurface, bool isVorbis, const sp<AMessage> &format) : mCodec(codec), mSource(source), mLooper(looper), mUsingSurface(usingSurface), mIsVorbis(isVorbis), mProtectedState(format) { mCodec->getName(&mComponentName); } Loading Loading @@ -280,16 +285,25 @@ status_t SimpleDecodingSource::doRead( if (in_buf != NULL) { int64_t timestampUs = 0; CHECK(in_buf->meta_data()->findInt64(kKeyTime, ×tampUs)); if (in_buf->range_length() > in_buffer->capacity()) { if (in_buf->range_length() + (mIsVorbis ? 4 : 0) > in_buffer->capacity()) { ALOGW("'%s' received %zu input bytes for buffer of size %zu", mComponentName.c_str(), in_buf->range_length(), in_buffer->capacity()); in_buf->range_length() + (mIsVorbis ? 4 : 0), in_buffer->capacity()); } size_t cpLen = min(in_buf->range_length(), in_buffer->capacity()); memcpy(in_buffer->base(), (uint8_t *)in_buf->data() + in_buf->range_offset(), min(in_buf->range_length(), in_buffer->capacity())); cpLen ); if (mIsVorbis) { int32_t numPageSamples; if (!in_buf->meta_data()->findInt32(kKeyValidSamples, &numPageSamples)) { numPageSamples = -1; } memcpy(in_buffer->base() + cpLen, &numPageSamples, sizeof(numPageSamples)); } res = mCodec->queueInputBuffer( in_ix, 0 /* offset */, in_buf->range_length(), in_ix, 0 /* offset */, in_buf->range_length() + (mIsVorbis ? 4 : 0), timestampUs, 0 /* flags */); if (res != OK) { ALOGI("[%s] failed to queue input buffer #%zu", mComponentName.c_str(), in_ix); Loading Loading
include/media/stagefright/SimpleDecodingSource.h +2 −1 Original line number Diff line number Diff line Loading @@ -71,12 +71,13 @@ private: // Construct this using a codec, source and looper. SimpleDecodingSource( const sp<MediaCodec> &codec, const sp<IMediaSource> &source, const sp<ALooper> &looper, bool usingSurface, const sp<AMessage> &format); bool usingSurface, bool isVorbis, const sp<AMessage> &format); sp<MediaCodec> mCodec; sp<IMediaSource> mSource; sp<ALooper> mLooper; bool mUsingSurface; bool mIsVorbis; enum State { INIT, STARTED, Loading
media/libstagefright/SimpleDecodingSource.cpp +20 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <media/ICrypto.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/foundation/ALooper.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/foundation/AUtils.h> Loading Loading @@ -74,7 +75,10 @@ sp<SimpleDecodingSource> SimpleDecodingSource::Create( err = codec->getOutputFormat(&format); } if (err == OK) { return new SimpleDecodingSource(codec, source, looper, surface != NULL, format); return new SimpleDecodingSource(codec, source, looper, surface != NULL, strcmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS) == 0, format); } ALOGD("Failed to configure codec '%s'", componentName.c_str()); Loading @@ -90,11 +94,12 @@ sp<SimpleDecodingSource> SimpleDecodingSource::Create( SimpleDecodingSource::SimpleDecodingSource( const sp<MediaCodec> &codec, const sp<IMediaSource> &source, const sp<ALooper> &looper, bool usingSurface, const sp<AMessage> &format) bool usingSurface, bool isVorbis, const sp<AMessage> &format) : mCodec(codec), mSource(source), mLooper(looper), mUsingSurface(usingSurface), mIsVorbis(isVorbis), mProtectedState(format) { mCodec->getName(&mComponentName); } Loading Loading @@ -280,16 +285,25 @@ status_t SimpleDecodingSource::doRead( if (in_buf != NULL) { int64_t timestampUs = 0; CHECK(in_buf->meta_data()->findInt64(kKeyTime, ×tampUs)); if (in_buf->range_length() > in_buffer->capacity()) { if (in_buf->range_length() + (mIsVorbis ? 4 : 0) > in_buffer->capacity()) { ALOGW("'%s' received %zu input bytes for buffer of size %zu", mComponentName.c_str(), in_buf->range_length(), in_buffer->capacity()); in_buf->range_length() + (mIsVorbis ? 4 : 0), in_buffer->capacity()); } size_t cpLen = min(in_buf->range_length(), in_buffer->capacity()); memcpy(in_buffer->base(), (uint8_t *)in_buf->data() + in_buf->range_offset(), min(in_buf->range_length(), in_buffer->capacity())); cpLen ); if (mIsVorbis) { int32_t numPageSamples; if (!in_buf->meta_data()->findInt32(kKeyValidSamples, &numPageSamples)) { numPageSamples = -1; } memcpy(in_buffer->base() + cpLen, &numPageSamples, sizeof(numPageSamples)); } res = mCodec->queueInputBuffer( in_ix, 0 /* offset */, in_buf->range_length(), in_ix, 0 /* offset */, in_buf->range_length() + (mIsVorbis ? 4 : 0), timestampUs, 0 /* flags */); if (res != OK) { ALOGI("[%s] failed to queue input buffer #%zu", mComponentName.c_str(), in_ix); Loading