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

Commit 662292ae authored by Andreas Huber's avatar Andreas Huber
Browse files

Better diagnostics in the stagefright commandline tool, support for playing...

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 to "-a".

related-to-bug: 2553359
Change-Id: Ic49eb89feb62474d9513bc21571e0e8fe3a15e0b
parent 15683534
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

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

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

#include "SineSource.h"

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

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

    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;
        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, "       -t(humbnail) extract video thumbnail or album art\n");
    fprintf(stderr, "       -s(oftware) prefer software codec\n");
    fprintf(stderr, "       -o playback audio\n");
}

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

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

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

            case '?':
            case 'h':
            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;
    argv += optind;

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

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

        bool isJPEG = false;

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

        if (isJPEG) {
            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 {
            sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
            if (extractor == NULL) {
                fprintf(stderr, "could not create data source\n");
                fprintf(stderr, "could not create extractor.\n");
                return -1;
            }

@@ -492,6 +535,17 @@ int main(int argc, char **argv) {
                if (!audioOnly && !strncasecmp(mime, "video/", 6)) {
                    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;
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
                (numChannels == 2)
                    ? AudioSystem::CHANNEL_OUT_STEREO
                    : AudioSystem::CHANNEL_OUT_MONO,
                8192, 0, &AudioCallback, this, 0);
                0, 0, &AudioCallback, this, 0);

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