summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRobert Shih <robertshih@google.com>2014-09-13 00:23:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-13 00:24:00 +0000
commitf6454e6d69f2ebb7b25c8e5275a0f301af8bca04 (patch)
treed4ea107ce1f98bdaa03a36aee2be71201a89b28a /media
parent61cd63a51c87dde24c9b163033937fa304864512 (diff)
parentf69c996864844e8f669308af8412cede043062a2 (diff)
downloadframeworks_av-f6454e6d69f2ebb7b25c8e5275a0f301af8bca04.zip
frameworks_av-f6454e6d69f2ebb7b25c8e5275a0f301af8bca04.tar.gz
frameworks_av-f6454e6d69f2ebb7b25c8e5275a0f301af8bca04.tar.bz2
Merge "LiveSession: re-buffer on under run to avoid stutter" into lmp-dev
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp36
-rw-r--r--media/libstagefright/httplive/LiveSession.h2
2 files changed, 37 insertions, 1 deletions
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 83481bc..5f566ca 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -81,6 +81,7 @@ LiveSession::LiveSession(
mDiscontinuities.add(indexToType(i), new AnotherPacketSource(NULL /* meta */));
mPacketSources.add(indexToType(i), new AnotherPacketSource(NULL /* meta */));
mPacketSources2.add(indexToType(i), new AnotherPacketSource(NULL /* meta */));
+ mBuffering[i] = false;
}
}
@@ -133,8 +134,26 @@ status_t LiveSession::dequeueAccessUnit(
sp<AnotherPacketSource> packetSource = mPacketSources.valueFor(stream);
+ ssize_t idx = typeToIndex(stream);
if (!packetSource->hasBufferAvailable(&finalResult)) {
- return finalResult == OK ? -EAGAIN : finalResult;
+ if (finalResult == OK) {
+ mBuffering[idx] = true;
+ return -EAGAIN;
+ } else {
+ return finalResult;
+ }
+ }
+
+ if (mBuffering[idx]) {
+ if (mSwitchInProgress
+ || packetSource->isFinished(0)
+ || packetSource->getEstimatedDurationUs() > 10000000ll) {
+ mBuffering[idx] = false;
+ }
+ }
+
+ if (mBuffering[idx]) {
+ return -EAGAIN;
}
// wait for counterpart
@@ -567,6 +586,21 @@ LiveSession::StreamType LiveSession::indexToType(int idx) {
return (StreamType)(1 << idx);
}
+// static
+ssize_t LiveSession::typeToIndex(int32_t type) {
+ switch (type) {
+ case STREAMTYPE_AUDIO:
+ return 0;
+ case STREAMTYPE_VIDEO:
+ return 1;
+ case STREAMTYPE_SUBTITLES:
+ return 2;
+ default:
+ return -1;
+ };
+ return -1;
+}
+
void LiveSession::onConnect(const sp<AMessage> &msg) {
AString url;
CHECK(msg->findString("url", &url));
diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h
index 8a800da..26df543 100644
--- a/media/libstagefright/httplive/LiveSession.h
+++ b/media/libstagefright/httplive/LiveSession.h
@@ -153,6 +153,7 @@ private:
sp<IMediaHTTPService> mHTTPService;
bool mInPreparationPhase;
+ bool mBuffering[kMaxStreams];
sp<HTTPBase> mHTTPDataSource;
KeyedVector<String8, String8> mExtraHeaders;
@@ -242,6 +243,7 @@ private:
static int SortByBandwidth(const BandwidthItem *, const BandwidthItem *);
static StreamType indexToType(int idx);
+ static ssize_t typeToIndex(int32_t type);
void changeConfiguration(
int64_t timeUs, size_t bandwidthIndex, bool pickTrack = false);