summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/AwesomePlayer.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-09-08 14:32:20 -0700
committerAndreas Huber <andih@google.com>2010-10-07 11:41:43 -0700
commit2a4d22d79e927f2245537921e10fc5fda1c47a29 (patch)
tree1452ec4c157a5f701d4aea84f2107477d5324d94 /media/libstagefright/AwesomePlayer.cpp
parent2b82e9652ba049e754c2cc74e381282f231d5fbf (diff)
downloadframeworks_av-2a4d22d79e927f2245537921e10fc5fda1c47a29.zip
frameworks_av-2a4d22d79e927f2245537921e10fc5fda1c47a29.tar.gz
frameworks_av-2a4d22d79e927f2245537921e10fc5fda1c47a29.tar.bz2
Work to support switching transport streams mid-stream and signalling discontinuities to the decoder.
Change-Id: I7150e5e7342e1117c524856b204aadcb763e06ed related-to-bug: 2368598
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp52
1 files changed, 49 insertions, 3 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 3d0d108..8c17aab 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -561,6 +561,39 @@ void AwesomePlayer::onBufferingUpdate() {
postBufferingEvent_l();
}
+void AwesomePlayer::partial_reset_l() {
+ // Only reset the video renderer and shut down the video decoder.
+ // Then instantiate a new video decoder and resume video playback.
+
+ mVideoRenderer.clear();
+
+ if (mLastVideoBuffer) {
+ mLastVideoBuffer->release();
+ mLastVideoBuffer = NULL;
+ }
+
+ if (mVideoBuffer) {
+ mVideoBuffer->release();
+ mVideoBuffer = NULL;
+ }
+
+ {
+ mVideoSource->stop();
+
+ // The following hack is necessary to ensure that the OMX
+ // component is completely released by the time we may try
+ // to instantiate it again.
+ wp<MediaSource> tmp = mVideoSource;
+ mVideoSource.clear();
+ while (tmp.promote() != NULL) {
+ usleep(1000);
+ }
+ IPCThreadState::self()->flushCommands();
+ }
+
+ CHECK_EQ(OK, initVideoDecoder(OMXCodec::kIgnoreCodecSpecificData));
+}
+
void AwesomePlayer::onStreamDone() {
// Posted whenever any stream finishes playing.
@@ -570,7 +603,21 @@ void AwesomePlayer::onStreamDone() {
}
mStreamDoneEventPending = false;
- if (mStreamDoneStatus != ERROR_END_OF_STREAM) {
+ if (mStreamDoneStatus == INFO_DISCONTINUITY) {
+ // This special status is returned because an http live stream's
+ // video stream switched to a different bandwidth at this point
+ // and future data may have been encoded using different parameters.
+ // This requires us to shutdown the video decoder and reinstantiate
+ // a fresh one.
+
+ LOGV("INFO_DISCONTINUITY");
+
+ CHECK(mVideoSource != NULL);
+
+ partial_reset_l();
+ postVideoEvent_l();
+ return;
+ } else if (mStreamDoneStatus != ERROR_END_OF_STREAM) {
LOGV("MEDIA_ERROR %d", mStreamDoneStatus);
notifyListener_l(
@@ -939,8 +986,7 @@ void AwesomePlayer::setVideoSource(sp<MediaSource> source) {
mVideoTrack = source;
}
-status_t AwesomePlayer::initVideoDecoder() {
- uint32_t flags = 0;
+status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
mVideoSource = OMXCodec::Create(
mClient.interface(), mVideoTrack->getFormat(),
false, // createEncoder