diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-02-03 20:53:20 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-02-03 20:53:20 -0800 |
commit | 87975df10f6f82f1fbd13fd1fac949ed4071f853 (patch) | |
tree | 91671550355947f998f527b33d68e14ba032b9d2 | |
parent | 412640a09129c377a03dd81a28a61ed266a19e96 (diff) | |
parent | 5b80804e1d30899d5368d0ca1d1824174722f3f5 (diff) | |
download | android_hardware_qcom_media-87975df10f6f82f1fbd13fd1fac949ed4071f853.tar.gz android_hardware_qcom_media-87975df10f6f82f1fbd13fd1fac949ed4071f853.tar.bz2 android_hardware_qcom_media-87975df10f6f82f1fbd13fd1fac949ed4071f853.zip |
Merge "DashPlayer: Fix in DashCodec for Adapative Streaming"
-rw-r--r-- | dashplayer/DashCodec.cpp | 55 | ||||
-rw-r--r-- | dashplayer/DashCodec.h | 2 |
2 files changed, 42 insertions, 15 deletions
diff --git a/dashplayer/DashCodec.cpp b/dashplayer/DashCodec.cpp index d50247f6..51e58654 100644 --- a/dashplayer/DashCodec.cpp +++ b/dashplayer/DashCodec.cpp @@ -377,7 +377,8 @@ DashCodec::DashCodec() mEncoderDelay(0), mEncoderPadding(0), mChannelMaskPresent(false), - mChannelMask(0){ + mChannelMask(0), + mAdaptivePlayback(false){ mUninitializedState = new UninitializedState(this); mLoadedState = new LoadedState(this); mLoadedToIdleState = new LoadedToIdleState(this); @@ -616,6 +617,11 @@ status_t DashCodec::allocateOutputBuffersFromNativeWindow() { OMX_U32 newBufferCount = def.nBufferCountMin + minUndequeuedBufs; def.nBufferCountActual = newBufferCount; + //Keep an extra buffer for smooth streaming + if (mAdaptivePlayback) { + def.nBufferCountActual += 1; + } + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); @@ -973,7 +979,6 @@ status_t DashCodec::configureCodec( // surfaces as they never had to respond to changes in the // crop window, and we don't trust that they will be able to. int usageBits = 0; - bool canDoAdaptivePlayback; sp<NativeWindowWrapper> windowWrapper( static_cast<NativeWindowWrapper *>(obj.get())); @@ -983,27 +988,31 @@ status_t DashCodec::configureCodec( nativeWindow.get(), NATIVE_WINDOW_CONSUMER_USAGE_BITS, &usageBits) != OK) { - canDoAdaptivePlayback = false; } else { - canDoAdaptivePlayback = + mAdaptivePlayback = (usageBits & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) == 0; } - - int32_t maxWidth = 0, maxHeight = 0; - if (canDoAdaptivePlayback && - msg->findInt32("max-width", &maxWidth) && - msg->findInt32("max-height", &maxHeight)) { + int32_t maxWidth = MAX_WIDTH; + int32_t maxHeight = MAX_HEIGHT; + if (mAdaptivePlayback) { ALOGV("[%s] prepareForAdaptivePlayback(%ldx%ld)", mComponentName.c_str(), maxWidth, maxHeight); err = mOMX->prepareForAdaptivePlayback( mNode, kPortIndexOutput, OMX_TRUE, maxWidth, maxHeight); - ALOGW_IF(err != OK, - "[%s] prepareForAdaptivePlayback failed w/ err %d", + if (err != OK) + { + ALOGE("[%s] prepareForAdaptivePlayback failed w/ err %d", + mComponentName.c_str(), err); + } + else + { + ALOGV("[%s] prepareForAdaptivePlayback : Success", mComponentName.c_str(), err); } + } // allow failure err = OK; } else { @@ -1011,7 +1020,7 @@ status_t DashCodec::configureCodec( } } - if (video) { + if (!strncasecmp(mime, "video/", 6)) { if (encoder) { err = setupVideoEncoder(mime, msg); } else { @@ -1020,6 +1029,11 @@ status_t DashCodec::configureCodec( || !msg->findInt32("height", &height)) { err = INVALID_OPERATION; } else { + //override height & width with max for smooth streaming + if (mAdaptivePlayback) { + width = MAX_WIDTH; + height = MAX_HEIGHT; + } err = setupVideoDecoder(mime, width, height); } } @@ -2988,8 +3002,7 @@ bool DashCodec::BaseState::onOMXFillBufferDone( mCodec->mPortEOS[kPortIndexOutput] = true; break; } - - if (!mCodec->mIsEncoder && !mCodec->mSentFormat) { + if (!mCodec->mIsEncoder && !mCodec->mSentFormat && !mCodec->mAdaptivePlayback) { mCodec->sendFormatChange(); } @@ -3016,6 +3029,12 @@ bool DashCodec::BaseState::onOMXFillBufferDone( sp<AMessage> reply = new AMessage(kWhatOutputBufferDrained, mCodec->id()); + if (!mCodec->mPostFormat && mCodec->mAdaptivePlayback){ + ALOGV("Resolution will change from this buffer, set a flag"); + reply->setInt32("resChange", 1); + mCodec->mPostFormat = true; + } + reply->setPointer("buffer-id", info->mBufferID); notify->setMessage("reply", reply); @@ -3048,6 +3067,14 @@ void DashCodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) { BufferInfo *info = mCodec->findBufferByID(kPortIndexOutput, bufferID, &index); CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_DOWNSTREAM); + if (mCodec->mAdaptivePlayback) { + int32_t resChange = 0; + if (msg->findInt32("resChange", &resChange) && resChange == 1) { + ALOGV("Resolution change is sent to native window now "); + mCodec->sendFormatChange(); + msg->setInt32("resChange", 0); + } + } int32_t render; if (mCodec->mNativeWindow != NULL && msg->findInt32("render", &render) && render != 0) { diff --git a/dashplayer/DashCodec.h b/dashplayer/DashCodec.h index 1261fbee..7848bcbe 100644 --- a/dashplayer/DashCodec.h +++ b/dashplayer/DashCodec.h @@ -277,7 +277,7 @@ private: status_t internalError = UNKNOWN_ERROR); status_t requestIDRFrame(); - + bool mAdaptivePlayback; Vector<OMX_PARAM_PORTDEFINITIONTYPE*> mFormats; Vector<OMX_CONFIG_RECTTYPE*> mOutputCrops; DISALLOW_EVIL_CONSTRUCTORS(DashCodec); |