Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce25d85a authored by Leena Winterrowd's avatar Leena Winterrowd Committed by Android Git Automerger
Browse files

am a93fd2be: stagefright: httplive: Decouple block size from bandwidth estimate

* commit 'a93fd2be':
  stagefright: httplive: Decouple block size from bandwidth estimate
parents 0512881b a93fd2be
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ HTTPBase::HTTPBase()
      mTotalTransferBytes(0),
      mPrevBandwidthMeasureTimeUs(0),
      mPrevEstimatedBandWidthKbps(0),
      mBandWidthCollectFreqMs(5000) {
      mBandWidthCollectFreqMs(5000),
      mMaxBandwidthHistoryItems(100) {
}

void HTTPBase::addBandwidthMeasurement(
@@ -50,7 +51,7 @@ void HTTPBase::addBandwidthMeasurement(
    mTotalTransferBytes += numBytes;

    mBandwidthHistory.push_back(entry);
    if (++mNumBandwidthHistoryItems > 100) {
    if (++mNumBandwidthHistoryItems > mMaxBandwidthHistoryItems) {
        BandwidthEntry *entry = &*mBandwidthHistory.begin();
        mTotalTransferTimeUs -= entry->mDelayUs;
        mTotalTransferBytes -= entry->mNumBytes;
@@ -104,6 +105,10 @@ status_t HTTPBase::setBandwidthStatCollectFreq(int32_t freqMs) {
    return OK;
}

void HTTPBase::setBandwidthHistorySize(size_t numHistoryItems) {
    mMaxBandwidthHistoryItems = numHistoryItems;
}

// static
void HTTPBase::RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag) {
    int res = qtaguid_tagSocket(sockfd, kTag, uid);
+10 −0
Original line number Diff line number Diff line
@@ -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() {
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ private:
        kWhatSwitchDown                 = 'sDwn',
    };

    static const size_t kBandwidthHistoryBytes;

    struct BandwidthItem {
        size_t mPlaylistIndex;
        unsigned long mBandwidth;
+2 −1
Original line number Diff line number Diff line
@@ -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(
+1 −1
Original line number Diff line number Diff line
@@ -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);
Loading