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

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

am d760afc3: am 30e9c2d4: am db281311: Merge "Better diagnostics in the...

am d760afc3: am 30e9c2d4: am db281311: Merge "Better diagnostics in the stagefright commandline tool, support for playing sine-tones using a filename of "sine:[samplingrate]", i.e. sine:44100. Support for playing audio through to the speakers by using "-o" in addition
parents eee53a7d d760afc3
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -5,7 +5,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include $(CLEAR_VARS)


LOCAL_SRC_FILES:=       \
LOCAL_SRC_FILES:=       \
	stagefright.cpp
	stagefright.cpp \
	SineSource.cpp


LOCAL_SHARED_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
	libstagefright libmedia libutils libbinder
	libstagefright libmedia libutils libbinder
+57 −3
Original line number Original line Diff line number Diff line
@@ -20,9 +20,12 @@
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>


#include "SineSource.h"

#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <binder/ProcessState.h>
#include <media/IMediaPlayerService.h>
#include <media/IMediaPlayerService.h>
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/CachingDataSource.h>
#include <media/stagefright/CachingDataSource.h>
#include <media/stagefright/FileSource.h>
#include <media/stagefright/FileSource.h>
#include <media/stagefright/HTTPDataSource.h>
#include <media/stagefright/HTTPDataSource.h>
@@ -42,6 +45,7 @@ static long gNumRepetitions;
static long gMaxNumFrames;  // 0 means decode all available.
static long gMaxNumFrames;  // 0 means decode all available.
static long gReproduceBug;  // if not -1.
static long gReproduceBug;  // if not -1.
static bool gPreferSoftwareCodec;
static bool gPreferSoftwareCodec;
static bool gPlaybackAudio;


static int64_t getNowUs() {
static int64_t getNowUs() {
    struct timeval tv;
    struct timeval tv;
@@ -73,7 +77,20 @@ static void playSource(OMXClient *client, const sp<MediaSource> &source) {


    rawSource->start();
    rawSource->start();


    if (gReproduceBug >= 3 && gReproduceBug <= 5) {
    if (gPlaybackAudio) {
        AudioPlayer *player = new AudioPlayer(NULL);
        player->setSource(rawSource);

        player->start(true /* sourceAlreadyStarted */);

        status_t finalStatus;
        while (!player->reachedEOS(&finalStatus)) {
            usleep(100000ll);
        }

        delete player;
        player = NULL;
    } else if (gReproduceBug >= 3 && gReproduceBug <= 5) {
        int64_t durationUs;
        int64_t durationUs;
        CHECK(meta->findInt64(kKeyDuration, &durationUs));
        CHECK(meta->findInt64(kKeyDuration, &durationUs));


@@ -245,6 +262,7 @@ static void usage(const char *me) {
    fprintf(stderr, "       -p(rofiles) dump decoder profiles supported\n");
    fprintf(stderr, "       -p(rofiles) dump decoder profiles supported\n");
    fprintf(stderr, "       -t(humbnail) extract video thumbnail or album art\n");
    fprintf(stderr, "       -t(humbnail) extract video thumbnail or album art\n");
    fprintf(stderr, "       -s(oftware) prefer software codec\n");
    fprintf(stderr, "       -s(oftware) prefer software codec\n");
    fprintf(stderr, "       -o playback audio\n");
}
}


int main(int argc, char **argv) {
int main(int argc, char **argv) {
@@ -258,9 +276,10 @@ int main(int argc, char **argv) {
    gMaxNumFrames = 0;
    gMaxNumFrames = 0;
    gReproduceBug = -1;
    gReproduceBug = -1;
    gPreferSoftwareCodec = false;
    gPreferSoftwareCodec = false;
    gPlaybackAudio = false;


    int res;
    int res;
    while ((res = getopt(argc, argv, "han:lm:b:pts")) >= 0) {
    while ((res = getopt(argc, argv, "han:lm:b:ptso")) >= 0) {
        switch (res) {
        switch (res) {
            case 'a':
            case 'a':
            {
            {
@@ -314,6 +333,12 @@ int main(int argc, char **argv) {
                break;
                break;
            }
            }


            case 'o':
            {
                gPlaybackAudio = true;
                break;
            }

            case '?':
            case '?':
            case 'h':
            case 'h':
            default:
            default:
@@ -325,6 +350,11 @@ int main(int argc, char **argv) {
        }
        }
    }
    }


    if (gPlaybackAudio && !audioOnly) {
        // This doesn't make any sense if we're decoding the video track.
        gPlaybackAudio = false;
    }

    argc -= optind;
    argc -= optind;
    argv += optind;
    argv += optind;


@@ -456,6 +486,11 @@ int main(int argc, char **argv) {
            dataSource = new FileSource(filename);
            dataSource = new FileSource(filename);
        }
        }


        if (dataSource == NULL) {
            fprintf(stderr, "Unable to create data source.\n");
            return 1;
        }

        bool isJPEG = false;
        bool isJPEG = false;


        size_t len = strlen(filename);
        size_t len = strlen(filename);
@@ -467,10 +502,18 @@ int main(int argc, char **argv) {


        if (isJPEG) {
        if (isJPEG) {
            mediaSource = new JPEGSource(dataSource);
            mediaSource = new JPEGSource(dataSource);
        } else if (!strncasecmp("sine:", filename, 5)) {
            char *end;
            long sampleRate = strtol(filename + 5, &end, 10);

            if (end == filename + 5) {
                sampleRate = 44100;
            }
            mediaSource = new SineSource(sampleRate, 1);
        } else {
        } else {
            sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
            sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
            if (extractor == NULL) {
            if (extractor == NULL) {
                fprintf(stderr, "could not create data source\n");
                fprintf(stderr, "could not create extractor.\n");
                return -1;
                return -1;
            }
            }


@@ -492,6 +535,17 @@ int main(int argc, char **argv) {
                if (!audioOnly && !strncasecmp(mime, "video/", 6)) {
                if (!audioOnly && !strncasecmp(mime, "video/", 6)) {
                    break;
                    break;
                }
                }

                meta = NULL;
            }

            if (meta == NULL) {
                fprintf(stderr,
                        "No suitable %s track found. The '-a' option will "
                        "target audio tracks only, the default is to target "
                        "video tracks only.\n",
                        audioOnly ? "audio" : "video");
                return -1;
            }
            }


            int64_t thumbTimeUs;
            int64_t thumbTimeUs;
+1 −1
Original line number Original line Diff line number Diff line
@@ -102,7 +102,7 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
                (numChannels == 2)
                (numChannels == 2)
                    ? AudioSystem::CHANNEL_OUT_STEREO
                    ? AudioSystem::CHANNEL_OUT_STEREO
                    : AudioSystem::CHANNEL_OUT_MONO,
                    : AudioSystem::CHANNEL_OUT_MONO,
                8192, 0, &AudioCallback, this, 0);
                0, 0, &AudioCallback, this, 0);


        if ((err = mAudioTrack->initCheck()) != OK) {
        if ((err = mAudioTrack->initCheck()) != OK) {
            delete mAudioTrack;
            delete mAudioTrack;