OpenCores学习(3)--PVPlayer 引擎设计

PVPlayer引擎是PVPlayer SDK的心脏。它接收和处理所有PVPlayer SDK从用户和管理PVMF播放多媒体所需的组成及相关业务的请求。其任务应用和简化高级控制。这个PVPlayer引擎也侦测,处理,和过滤事件和信息生成多媒体播放操 作控制。

3.1 PVPlayerInterface API

       PVPlayer用户界面PVPlayer引擎通过PVPlayerInterface接口类来确定是否有一种适配接口用 户和PVPlayer引擎。PVPlayerInterface是一种OSCL-based接口和遵循公共接口,除了多媒体播放特定api,PVPlayerInterface提供方法检索SDK信息、操纵和取消的命令。并描述PVPlayerInterface API,指的是一种PVPlayerInterface API文档生成的支持的标记。

3.2 异步操作

       The PVPlayer engine processes most commands initiated by API calls asynchronously. There are some commands that are processed synchronously and they can be differentiated by the return value. Synchronous commands return a PVMF status code which tells the user whether the command succeeded or not and if it did fail, what the error was. All asynchronous commands return a command ID. For the user to be notified of asynchronous command completion, the user must specify a callback handler when instantiating PVPlayer engine via the factory function. When the asynchronous command completes, PVPlayer engine calls the callback handler with the command ID for the command, command status, and any other relevant data. To process the command asynchronously, the PVPlayer engine is implemented as an active object, which gets to run according to the active scheduler running in the thread. The PVPlayer engine expects scheduler to be available when instantiated and the engine itself will not directly create a thread or scheduler.

With asynchronous commands, there is a possibility of commands not completing in expected time. To deal with this issue, PVPlayer engine provides standard PV SDK APIs to cancel a specific or all issued commands. The user of PVPlayer SDK can use these APIs to cancel any request that did not complete in time or are not needed due to changing circumstances. In PVPlayer engine, it might have to deal with lower level components that behave asynchronously. To prevent an unresponsive lower level component from blocking PVPlayer engine operation, PVPlayer engine has timeout handling for any asynchronous commands that it issues. When timeout does occur, the asynchronous command is canceled and is handled appropriately (e.g. command failure, error event).

3.3 事件处理

  The PVPlayer engine notifies the user of errors and other information not related to API calls as unsolicited events. The notification is handled by making a callback on handlers specified by the user of PVPlayer engine. There are two callback handlers, one for error events and one for informational events, that must be specified by the user when instantiating PVPlayer engine via the factory function.

3.4 引擎框架

       下面的图表说明了应用程序使用PVPlayer引擎的接口PVPlayerInterface时直接适配。PVPlayerFactory处理实例化组件和destoryPVPlayerEngine对象。所有PVPlayer引擎的api提供PVPlayerInterfacePVPlayerEngine采用三种回收处理过的应用,PVCommandStatusObserver,PVInformationalObserver,PVErrorEventObserver,通知申请上述指令完成同步误差和信息的事件。

OpenCores学习(3)--PVPlayer <wbr>引擎设计

       图二 类图

3.5 状态机

OpenCores学习(3)--PVPlayer <wbr>引擎设计



图三 状态机

       PVPlayer 引擎实例化后状态为IDLE,IDLE状态时,可以调用AddDataSource() 来指定需要回放的多媒体 数据,然后调用 init()初始化数据并且状态转为INITIALIZED,在进入INITIALIZED

 

状态的时候,用户可以获取媒体的tracksmetadata,并且可以调用 AddDataSink()去指定具体的data sinks 去回放.

 

       在所有的data sinks添加后,用户调用Prepare(),使引擎建立相关的PVMF节点,并为数据流指定多媒体播放的数据源 和数据接收器,建立需要播放的数据流队列.用户在PREPARED状态时调用Start()进入到STARTED状态,启动多媒体播放.在调用Stop()后回到INITIALIZED状态并且刷新多媒体数据流.

 

       STARTED状态时,用户也可以调用 Pause(). Stop().调用Stop()后停止回放,刷新所有数据流,并且使引擎回到初始化状态.调用Pause(),会停止回放,但不会刷新数据流,而且可以调用Resume()继续从暂停的地方播放.PAUSED状态时可以调用Stop()使引擎回到初始化状态.

 

       调用Stop()回到INITIALIZED状态后,数据队列可以通过调用AddDataSink()RemoveDataSink()来添加和删除.在调用Prepare()\Start()重新回放,但是关闭回到IDLE状态时,或需要重新打开另一个媒体文件时,需要调用Reset().因为在IDLE状态调用RemoveDataSink()不能删除所有数据队列.调用Reset(),又回到起始状态,流程如上一样.如果用户想退出PVPlayer,也可以调用Reset(),PREPARED, STARTED,PAUSED状态时都可以调用该函数.

 

       如果PVPlayer引擎收到错误信息或从其它组件传来 错误事件后,引擎会发送ERROR状态并且尝试恢复.如果这个错误是不可恢复的,刚引擎会清空所有状态和数据列回到IDLE状态.此时用户应该等待PVMFInfoErrorHandlingComplete informational event.

 

       以上是这个状态机的简要 描述,具体参考OPENCORE源码.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值