summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive
diff options
context:
space:
mode:
authorLeena Winterrowd <lenhardw@codeaurora.org>2014-12-04 14:03:03 -0800
committerLajos Molnar <lajos@google.com>2015-01-28 21:52:09 -0800
commita93fd2be99d21629bed504b9b7df035fc2f54562 (patch)
treebacc1924137d3e0e749a1ba47756f3c80eaa1718 /media/libstagefright/httplive
parent9aff25fb41f516ac26f9d1983a25402909f1e77a (diff)
downloadframeworks_av-a93fd2be99d21629bed504b9b7df035fc2f54562.zip
frameworks_av-a93fd2be99d21629bed504b9b7df035fc2f54562.tar.gz
frameworks_av-a93fd2be99d21629bed504b9b7df035fc2f54562.tar.bz2
stagefright: httplive: Decouple block size from bandwidth estimate
A very small block size in PlaylistFetcher can lead to framework overhead and difficulty streaming high bitrate content, but since HTTPBase keeps a constant history of the past 100 HTTP reads, the block size directly affects bandwidth estimation and in turn, switching latency. Add setBandwidthHistorySize() to HTTPBase to allow setting the history size for bandwidth estimation. Call this within LiveSession based on the current block size to ensure that the number of bytes used for estimating bandwidth does not change if the block size is changed in PlaylistFetcher. Since a single TCP/IP packet can contain up to 64k of data, increase the block size in PlaylistFetcher from 2k to lcm(188, 1024) or 47k to avoid inaccuracies in read timings due to up to a comparable 47 reads from the same locally-cached packet instead of from the network. Also make HTTPBase::addBandwidthMeasurement() virtual to allow bandwidth estimation extensions that do not rely on a history list. Bug: 18821145 Change-Id: I5f957be01f5346e74cfb7eeb150ca4b397ad5798
Diffstat (limited to 'media/libstagefright/httplive')
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp10
-rw-r--r--media/libstagefright/httplive/LiveSession.h2
-rw-r--r--media/libstagefright/httplive/PlaylistFetcher.cpp3
-rw-r--r--media/libstagefright/httplive/PlaylistFetcher.h2
4 files changed, 15 insertions, 2 deletions
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index e163985..9daab3b 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -49,6 +49,9 @@
namespace android {
+// Number of recently-read bytes to use for bandwidth estimation
+const size_t LiveSession::kBandwidthHistoryBytes = 200 * 1024;
+
LiveSession::LiveSession(
const sp<AMessage> &notify, uint32_t flags,
const sp<IMediaHTTPService> &httpService)
@@ -84,6 +87,13 @@ LiveSession::LiveSession(
mPacketSources2.add(indexToType(i), new AnotherPacketSource(NULL /* meta */));
mBuffering[i] = false;
}
+
+ size_t numHistoryItems = kBandwidthHistoryBytes /
+ PlaylistFetcher::kDownloadBlockSize + 1;
+ if (numHistoryItems < 5) {
+ numHistoryItems = 5;
+ }
+ mHTTPDataSource->setBandwidthHistorySize(numHistoryItems);
}
LiveSession::~LiveSession() {
diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h
index 896a8fc..dfb5e59 100644
--- a/media/libstagefright/httplive/LiveSession.h
+++ b/media/libstagefright/httplive/LiveSession.h
@@ -114,6 +114,8 @@ private:
kWhatSwitchDown = 'sDwn',
};
+ static const size_t kBandwidthHistoryBytes;
+
struct BandwidthItem {
size_t mPlaylistIndex;
unsigned long mBandwidth;
diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp
index 07c86e5..4a97803 100644
--- a/media/libstagefright/httplive/PlaylistFetcher.cpp
+++ b/media/libstagefright/httplive/PlaylistFetcher.cpp
@@ -49,7 +49,8 @@ namespace android {
// static
const int64_t PlaylistFetcher::kMinBufferedDurationUs = 10000000ll;
const int64_t PlaylistFetcher::kMaxMonitorDelayUs = 3000000ll;
-const int32_t PlaylistFetcher::kDownloadBlockSize = 2048;
+// LCM of 188 (size of a TS packet) & 1k works well
+const int32_t PlaylistFetcher::kDownloadBlockSize = 47 * 1024;
const int32_t PlaylistFetcher::kNumSkipFrames = 5;
PlaylistFetcher::PlaylistFetcher(
diff --git a/media/libstagefright/httplive/PlaylistFetcher.h b/media/libstagefright/httplive/PlaylistFetcher.h
index 2788451..67161a9 100644
--- a/media/libstagefright/httplive/PlaylistFetcher.h
+++ b/media/libstagefright/httplive/PlaylistFetcher.h
@@ -35,6 +35,7 @@ struct String8;
struct PlaylistFetcher : public AHandler {
static const int64_t kMinBufferedDurationUs;
+ static const int32_t kDownloadBlockSize;
enum {
kWhatStarted,
@@ -95,7 +96,6 @@ private:
};
static const int64_t kMaxMonitorDelayUs;
- static const int32_t kDownloadBlockSize;
static const int32_t kNumSkipFrames;
static bool bufferStartsWithTsSyncByte(const sp<ABuffer>& buffer);