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

Commit e083d0a2 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Support for Ogg Vorbis decoding in stagefright." into froyo

parents 01451756 eb5eef38
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ extern const char *MEDIA_MIMETYPE_AUDIO_RAW;

extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
extern const char *MEDIA_MIMETYPE_CONTAINER_VORBIS;

}  // namespace android

+35 −7
Original line number Diff line number Diff line
@@ -678,6 +678,26 @@ static player_type getDefaultPlayerType() {
    return PV_PLAYER;
}

// By default we use the VORBIS_PLAYER for vorbis playback (duh!),
// but if the magic property is set we will use our new experimental
// stagefright code instead.
static player_type OverrideStagefrightForVorbis(player_type player) {
    if (player != VORBIS_PLAYER) {
        return player;
    }

#if BUILD_WITH_FULL_STAGEFRIGHT
    char value[PROPERTY_VALUE_MAX];
    if (property_get("media.stagefright.enable-vorbis", value, NULL)
        && (!strcmp(value, "1") || !strcmp(value, "true"))) {
        return STAGEFRIGHT_PLAYER;
    }
#endif

    return VORBIS_PLAYER;
}


player_type getPlayerType(int fd, int64_t offset, int64_t length)
{
    char buf[20];
@@ -689,7 +709,7 @@ player_type getPlayerType(int fd, int64_t offset, int64_t length)

    // Ogg vorbis?
    if (ident == 0x5367674f) // 'OggS'
        return VORBIS_PLAYER;
        return OverrideStagefrightForVorbis(VORBIS_PLAYER);

#ifndef NO_OPENCORE
    if (ident == 0x75b22630) {
@@ -725,6 +745,13 @@ player_type getPlayerType(const char* url)
        return TEST_PLAYER;
    }

    bool useStagefrightForHTTP = false;
    char value[PROPERTY_VALUE_MAX];
    if (property_get("media.stagefright.enable-http", value, NULL)
        && (!strcmp(value, "1") || !strcasecmp(value, "true"))) {
        useStagefrightForHTTP = true;
    }

    // use MidiFile for MIDI extensions
    int lenURL = strlen(url);
    for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
@@ -732,17 +759,18 @@ player_type getPlayerType(const char* url)
        int start = lenURL - len;
        if (start > 0) {
            if (!strncmp(url + start, FILE_EXTS[i].extension, len)) {
                return FILE_EXTS[i].playertype;
                if (FILE_EXTS[i].playertype == VORBIS_PLAYER
                    && !strncasecmp(url, "http://", 7)
                    && useStagefrightForHTTP) {
                    return STAGEFRIGHT_PLAYER;
                }
                return OverrideStagefrightForVorbis(FILE_EXTS[i].playertype);
            }
        }
    }

    if (!strncasecmp(url, "http://", 7)) {
        char value[PROPERTY_VALUE_MAX];
        if (!property_get("media.stagefright.enable-http", value, NULL)
            || (strcmp(value, "1") && strcasecmp(value, "true"))) {
            // For now, we're going to use PV for http-based playback
            // by default until we can clear up a few more issues.
        if (!useStagefrightForHTTP) {
            return PV_PLAYER;
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ LOCAL_SRC_FILES += \
        StagefrightMetadataRetriever.cpp \
        TimeSource.cpp            \
        TimedEventQueue.cpp       \
        VorbisExtractor.cpp       \
        WAVExtractor.cpp          \
        string.cpp

+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "include/MP3Extractor.h"
#include "include/MPEG4Extractor.h"
#include "include/WAVExtractor.h"
#include "include/VorbisExtractor.h"

#include <media/stagefright/CachingDataSource.h>
#include <media/stagefright/DataSource.h>
@@ -92,6 +93,7 @@ void DataSource::RegisterDefaultSniffers() {
    RegisterSniffer(SniffMPEG4);
    RegisterSniffer(SniffAMR);
    RegisterSniffer(SniffWAV);
    RegisterSniffer(SniffVorbis);
}

// static
+1 −0
Original line number Diff line number Diff line
@@ -34,5 +34,6 @@ const char *MEDIA_MIMETYPE_AUDIO_RAW = "audio/raw";

const char *MEDIA_MIMETYPE_CONTAINER_MPEG4 = "video/mpeg4";
const char *MEDIA_MIMETYPE_CONTAINER_WAV = "audio/wav";
const char *MEDIA_MIMETYPE_CONTAINER_VORBIS = "application/ogg";

}  // namespace android
Loading