WEB开发网
开发学院手机开发Android 开发 Android 下的PVPlayer的实现 阅读

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 playersp cache = new AudioCac

return mem;

}

player_type playerType = getPlayerType(url);

LOGV("player type = %d", playerType);

// create the right type of player

sp cache = new AudioCache(url);

player = android::createPlayer(playerType, cache.get(), cache->notify);

if (player == NULL) goto Exit;

if (player->hardwareOutput()) goto Exit;

static_cast(player.get())->setAudioSink(cache);

// 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

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:Android PVPlayer 实现

编辑录入:coldstar [复制链接] [打 印]
赞助商链接