From eb5eef38198b38d97b573be550657ba64ccba299 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 4 May 2010 11:46:42 -0700 Subject: Support for Ogg Vorbis decoding in stagefright. Set the magic property media.stagefright.enable-vorbis to true to use the new implementation instead of the standalon vorbis player for file-based playback. HTTP streaming of vorbis content will always go through stagefright. Change-Id: Ie3843a99fadb22372f89540d0f8d65196e0c2af8 related-to-bug: 2654400 --- media/libmediaplayerservice/MediaPlayerService.cpp | 42 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'media/libmediaplayerservice/MediaPlayerService.cpp') diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index a6d8d2c..3e1f4a5 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -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; } } -- cgit v1.1