stagefright
stagefright是android froyo版本引入的多媒体架构。
android 4.1代码:
文件目录 frameworks/av/media/libstagefright/
生成库libstagefright.so
主要的module:awesomeplayer
其在MediaPlayerService中构造:
player_type getPlayerType(const char* url)
{
// m3u8 使用NU_PLAYER
if (!strncasecmp("http://", url, 7)
|| !strncasecmp("https://", url, 8)) {
size_t len = strlen(url);
if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
return NU_PLAYER;
}
if(len >= 4 && !strcasecmp(".mpd", &url[len - 4])){
return NU_PLAYER;
}
if (strstr(url,"m3u8")) {
return NU_PLAYER;
}
//rtsp rtp 使用NU_PLAYER
if (!strncasecmp("rtsp://", url, 7)) {
return NU_PLAYER;
}
if (!strncasecmp("aahRX://", url, 8)) {
return AAH_RX_PLAYER;
}
if (!strncasecmp("rtp://", url, 6)) {
return NU_PLAYER;
}
// use MidiFile for MIDI extensions
int lenURL = strlen(url);
for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
int len = strlen(FILE_EXTS[i].extension);
int start = lenURL - len;
if (start > 0) {
if (!strncasecmp(url + start, FILE_EXTS[i].extension, len)) {
return FILE_EXTS[i].playertype;
}
}
}
return getDefaultPlayerType();
}
static player_type getDefaultPlayerType() {
char value[PROPERTY_VALUE_MAX];
if (property_get("media.stagefright.use-nuplayer", value, NULL)
&& (!strcmp("1", value) || !strcasecmp("true", value))) {
return NU_PLAYER;
}
//正常的default Player 为STAGEFRIGHT_PLAYER
return STAGEFRIGHT_PLAYER;
}
static sp<MediaPlayerBase> createPlayer(player_type playerType, void* cookie,
notify_callback_f notifyFunc)
{
//创建StagefrightPlayer
switch (playerType) {
case STAGEFRIGHT_PLAYER:
ALOGV(" create StagefrightPlayer");
p = new StagefrightPlayer;
break;
}