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

Commit b72d3180 authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am 81046c8c: Merge "Various changes to improve rtsp networking, reduce packet...

am 81046c8c: Merge "Various changes to improve rtsp networking, reduce packet loss and adapt to ALooper API changes." into gingerbread

Merge commit '81046c8c' into gingerbread-plus-aosp

* commit '81046c8c':
  Various changes to improve rtsp networking, reduce packet loss and adapt to ALooper API changes.
parents 1cb7b2e9 81046c8c
Loading
Loading
Loading
Loading
+36 −5
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <media/IMediaPlayerService.h>
#include <media/stagefright/foundation/ALooper.h>
#include "include/ARTSPController.h"
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/JPEGSource.h>
@@ -365,6 +367,9 @@ int main(int argc, char **argv) {
    gPlaybackAudio = false;
    gWriteMP4 = false;

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

    int res;
    while ((res = getopt(argc, argv, "han:lm:b:ptsow:k")) >= 0) {
        switch (res) {
@@ -576,7 +581,8 @@ int main(int argc, char **argv) {

        sp<DataSource> dataSource = DataSource::CreateFromURI(filename);

        if (strncasecmp(filename, "sine:", 5) && dataSource == NULL) {
        if ((strncasecmp(filename, "sine:", 5)
                && strncasecmp(filename, "rtsp://", 7)) && dataSource == NULL) {
            fprintf(stderr, "Unable to create data source.\n");
            return 1;
        }
@@ -601,11 +607,29 @@ int main(int argc, char **argv) {
            }
            mediaSource = new SineSource(sampleRate, 1);
        } else {
            sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
            sp<MediaExtractor> extractor;

            if (!strncasecmp("rtsp://", filename, 7)) {
                if (looper == NULL) {
                    looper = new ALooper;
                    looper->start();
                }

                rtspController = new ARTSPController(looper);
                status_t err = rtspController->connect(filename);
                if (err != OK) {
                    fprintf(stderr, "could not connect to rtsp server.\n");
                    return -1;
                }

                extractor = rtspController.get();
            } else {
                extractor = MediaExtractor::Create(dataSource);
                if (extractor == NULL) {
                    fprintf(stderr, "could not create extractor.\n");
                    return -1;
                }
            }

            size_t numTracks = extractor->countTracks();

@@ -654,6 +678,13 @@ int main(int argc, char **argv) {
        } else {
            playSource(&client, mediaSource);
        }

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

            sleep(3);
        }
    }

    client.disconnect();
+3 −1
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ struct ALooper : public RefBase {

    status_t start(
            bool runOnCallingThread = false,
            bool canCallJava = false);
            bool canCallJava = false,
            int32_t priority = PRIORITY_DEFAULT
            );

    status_t stop();

+3 −2
Original line number Diff line number Diff line
@@ -73,7 +73,8 @@ void ALooper::unregisterHandler(handler_id handlerID) {
    gLooperRoster.unregisterHandler(handlerID);
}

status_t ALooper::start(bool runOnCallingThread, bool canCallJava) {
status_t ALooper::start(
        bool runOnCallingThread, bool canCallJava, int32_t priority) {
    if (runOnCallingThread) {
        {
            Mutex::Autolock autoLock(mLock);
@@ -99,7 +100,7 @@ status_t ALooper::start(bool runOnCallingThread, bool canCallJava) {

    mThread = new LooperThread(this, canCallJava);

    status_t err = mThread->run("ALooper");
    status_t err = mThread->run("ALooper", priority);
    if (err != OK) {
        mThread.clear();
    }
+5 −0
Original line number Diff line number Diff line
@@ -144,6 +144,11 @@ void AMPEG4AudioAssembler::submitAccessUnit() {

    accessUnit->meta()->setInt64("ntp-time", ntpTime);

#if 0
    printf(mAccessUnitDamaged ? "X" : ".");
    fflush(stdout);
#endif

    if (mAccessUnitDamaged) {
        accessUnit->meta()->setInt32("damaged", true);
    }
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ status_t ARTSPController::connect(const char *url) {
    }

    mHandler = new MyHandler(url, mLooper);
    mHandler->connect();

    sleep(10);

    return OK;
@@ -48,6 +50,7 @@ void ARTSPController::disconnect() {
        return;
    }

    mHandler->disconnect();
    mHandler.clear();
}

Loading