Android 下的PVPlayer的实现
2010-09-10 01:08:00 来源:WEB开发网return mem;
}
player_type playerType = getPlayerType(url);
LOGV("player type = %d", playerType);
// create the right type of player
sp
player = android::createPlayer(playerType, cache.get(), cache->notify);
if (player == NULL) goto Exit;
if (player->hardwareOutput()) goto Exit;
static_cast
// set data source
if (player->setDataSource(url) != NO_ERROR) goto Exit;
LOGV("prepare");
player->prepareAsync();
LOGV("wait for prepare");
if (cache->wait() != NO_ERROR) goto Exit;
LOGV("start");
player->start();
LOGV("wait for playback complete");
if (cache->wait() != NO_ERROR) goto Exit;
mem = new MemoryBase(cache->getHeap(), 0, cache->size());
*pSampleRate = cache->sampleRate();
*pNumChannels = cache->channelCount();
*pFormat = cache->format();
LOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat);
Exit:
if (player != 0) player->reset();
return mem;
}
这个工程有这样几步,准备,然后等待准备完成,然后开始,然后等待start完成,完成之后就可以得到解码后的数据。上面的几个接口函数基本上是没有什么东西的,下面我们具体来看这个PVPlayer怎么实现的。主要看他的几个私有函数:
static void do_nothing(status_t s, void *cookie, bool cancelled) { }
static void run_init(status_t s, void *cookie, bool cancelled);
static void run_set_video_surface(status_t s, void *cookie, bool cancelled);
static void run_set_audio_output(status_t s, void *cookie, bool
更多精彩
赞助商链接