主要调用awesomeplay.cpp的函数来实现音视频等功能,可以说是对awesomeplay.cpp的封装,进一步抽象,然后提供给上层调用,主要的调用者是MediaPlayerService.cpp。提供的API如下:
1. StagefrightPlayer::StagefrightPlayer():mPlayer(new AwesomePlayer)
l AwesomePlayer对象赋值给mPlayer,这里完成真正的初始化工作,后面使用mPlayer较多
2. StagefrightPlayer::~StagefrightPlayer()
3. status_tStagefrightPlayer::initCheck()//检查上面的初始化是否完成
4. status_tStagefrightPlayer::setDataSource//封装了status_tAwesomePlayer::setDataSource_l()
5. status_tStagefrightPlayer::setDataSource
6. status_tStagefrightPlayer::setVideoSurface(const sp<ISurface> &surface) //设置视频播放的界面
7. status_tStagefrightPlayer::prepare() {
returnmPlayer->prepare();
}
8. status_tStagefrightPlayer::prepareAsync()
9. status_tStagefrightPlayer::start()
10. status_tStagefrightPlayer::stop()
11. status_tStagefrightPlayer::pause()
12. boolStagefrightPlayer::isPlaying()
13. status_tStagefrightPlayer::seekTo(int msec) //用来控制播放的命令
14. status_tStagefrightPlayer::getCurrentPosition(int *msec)
15. status_tStagefrightPlayer::getDuration(int *msec)
16. status_tStagefrightPlayer::reset()
17. status_tStagefrightPlayer::setLooping(int loop) //设置循环
18. player_typeStagefrightPlayer::playerType() //选择播放引擎是STAGEFRIGHT_PLAYER? PV_PLAYER ? 或者 SONIVOX_PLAYER
19. status_tStagefrightPlayer::suspend() //挂起
20. status_tStagefrightPlayer::resume() //唤醒
21. status_tStagefrightPlayer::invoke//调用
22. voidStagefrightPlayer::setAudioSink(const sp<AudioSink> &audioSink) //设置音频输出:解码后的数据
23. status_tStagefrightPlayer::getMetadata //获取媒体元数据