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

Commit b5590846 authored by Andreas Huber's avatar Andreas Huber
Browse files

Squashed commit of the following:

commit 9254c845d7c82976fd4b8be406ce4b17eeb0e119
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 3 15:26:12 2010 -0800

    Remove obsolete code from the cached data source.

    Change-Id: I794b986ac8977cbc834dff189221a636ba564e36

commit 2ee33711064c58c53ba65ed9e63dd4b01ec2380e
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 3 15:23:13 2010 -0800

    LiveSource is dead, long live LiveSession.

    Change-Id: Ibcd0731ecf9c94f0b3e5db3d53d012d9da2a1c66

commit 9eabb2c3cd8571ab859bdeae0aa7f655c414d8fa
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 3 12:49:31 2010 -0800

    Respect explicitly signalled discontinuities.

    Change-Id: I3c0c16a2de7a99742d25db7d1b2ff0258de52271

commit 7f7f7b6b906b6ece6e4d43af7fd5f494e805c5e5
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 3 11:45:57 2010 -0800

    Better protection against syncword emulation in AAC ADTS content.

    Change-Id: I867e80a4556dd46d24ab3e781177c248a5221719

commit fe765766582efcc350aed01135ea603576adccf6
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 3 09:15:59 2010 -0800

    New implementation of http live driving code.

    Change-Id: I31ddf3d6a0d5929b121be704a2b9c3d6775f7737

Change-Id: Id8d1829c8fcb173756965013f848c1d426ef1048
parent 768ec6f2
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
#include <media/IMediaPlayerService.h>
#include <media/stagefright/foundation/ALooper.h>
#include "include/ARTSPController.h"
#include "include/LiveSource.h"
#include "include/LiveSession.h"
#include "include/NuCachedSource2.h"
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/DataSource.h>
@@ -560,6 +560,7 @@ int main(int argc, char **argv) {

    sp<ALooper> looper;
    sp<ARTSPController> rtspController;
    sp<LiveSession> liveSession;

    int res;
    while ((res = getopt(argc, argv, "han:lm:b:ptsow:kx")) >= 0) {
@@ -852,8 +853,15 @@ int main(int argc, char **argv) {
                String8 uri("http://");
                uri.append(filename + 11);

                dataSource = new LiveSource(uri.string());
                dataSource = new NuCachedSource2(dataSource);
                if (looper == NULL) {
                    looper = new ALooper;
                    looper->start();
                }
                liveSession = new LiveSession;
                looper->registerHandler(liveSession);

                liveSession->connect(uri.string());
                dataSource = liveSession->getDataSource();

                extractor =
                    MediaExtractor::Create(
+17 −5
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@

#include "include/ARTSPController.h"
#include "include/AwesomePlayer.h"
#include "include/LiveSource.h"
#include "include/SoftwareRenderer.h"
#include "include/NuCachedSource2.h"
#include "include/ThrottledSource.h"
@@ -51,6 +50,7 @@
#include <surfaceflinger/Surface.h>

#include <media/stagefright/foundation/ALooper.h>
#include "include/LiveSession.h"

#define USE_SURFACE_ALLOC 1

@@ -634,6 +634,11 @@ void AwesomePlayer::reset_l() {
        mRTSPController.clear();
    }

    if (mLiveSession != NULL) {
        mLiveSession->disconnect();
        mLiveSession.clear();
    }

    mRTPPusher.clear();
    mRTCPPusher.clear();
    mRTPSession.clear();
@@ -1659,16 +1664,23 @@ status_t AwesomePlayer::finishSetDataSource_l() {
        String8 uri("http://");
        uri.append(mUri.string() + 11);

        sp<LiveSource> liveSource = new LiveSource(uri.string());
        if (mLooper == NULL) {
            mLooper = new ALooper;
            mLooper->setName("httplive");
            mLooper->start();
        }

        mLiveSession = new LiveSession;
        mLooper->registerHandler(mLiveSession);

        mCachedSource = new NuCachedSource2(liveSource);
        dataSource = mCachedSource;
        mLiveSession->connect(uri.string());
        dataSource = mLiveSession->getDataSource();

        sp<MediaExtractor> extractor =
            MediaExtractor::Create(dataSource, MEDIA_MIMETYPE_CONTAINER_MPEG2TS);

        static_cast<MPEG2TSExtractor *>(extractor.get())
            ->setLiveSource(liveSource);
            ->setLiveSession(mLiveSession);

        return setDataSource_l(extractor);
    } else if (!strncmp("rtsp://gtalk/", mUri.string(), 13)) {
+2 −44
Original line number Diff line number Diff line
@@ -179,8 +179,7 @@ NuCachedSource2::NuCachedSource2(const sp<DataSource> &source)
      mFinalStatus(OK),
      mLastAccessPos(0),
      mFetching(true),
      mLastFetchTimeUs(-1),
      mSuspended(false) {
      mLastFetchTimeUs(-1) {
    mLooper->setName("NuCachedSource2");
    mLooper->registerHandler(mReflector);
    mLooper->start();
@@ -223,12 +222,6 @@ void NuCachedSource2::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }

        case kWhatSuspend:
        {
            onSuspend();
            break;
        }

        default:
            TRESPASS();
    }
@@ -270,7 +263,6 @@ void NuCachedSource2::onFetch() {

    bool keepAlive =
        !mFetching
            && !mSuspended
            && mFinalStatus == OK
            && ALooper::GetNowUs() >= mLastFetchTimeUs + kKeepAliveIntervalUs;

@@ -287,7 +279,7 @@ void NuCachedSource2::onFetch() {
            LOGI("Cache full, done prefetching for now");
            mFetching = false;
        }
    } else if (!mSuspended) {
    } else {
        Mutex::Autolock autoLock(mLock);
        restartPrefetcherIfNecessary_l();
    }
@@ -478,40 +470,6 @@ status_t NuCachedSource2::seekInternal_l(off64_t offset) {
    return OK;
}

void NuCachedSource2::clearCacheAndResume() {
    LOGV("clearCacheAndResume");

    Mutex::Autolock autoLock(mLock);

    CHECK(mSuspended);

    mCacheOffset = 0;
    mFinalStatus = OK;
    mLastAccessPos = 0;
    mLastFetchTimeUs = -1;

    size_t totalSize = mCache->totalSize();
    CHECK_EQ(mCache->releaseFromStart(totalSize), totalSize);

    mFetching = true;
    mSuspended = false;
}

void NuCachedSource2::suspend() {
    (new AMessage(kWhatSuspend, mReflector->id()))->post();

    while (!mSuspended) {
        usleep(10000);
    }
}

void NuCachedSource2::onSuspend() {
    Mutex::Autolock autoLock(mLock);

    mFetching = false;
    mSuspended = true;
}

void NuCachedSource2::resumeFetchingIfNecessary() {
    Mutex::Autolock autoLock(mLock);

+1 −1
Original line number Diff line number Diff line
@@ -456,7 +456,7 @@ void NuHTTPDataSource::applyTimeoutResponse() {
bool NuHTTPDataSource::estimateBandwidth(int32_t *bandwidth_bps) {
    Mutex::Autolock autoLock(mLock);

    if (mNumBandwidthHistoryItems < 10) {
    if (mNumBandwidthHistoryItems < 2) {
        return false;
    }

+4 −3
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:=               \
        LiveSource.cpp  \
        LiveDataSource.cpp      \
        LiveSession.cpp         \
        M3UParser.cpp           \

LOCAL_C_INCLUDES:= \
Loading