音视频观测器
- iOS
更新时间不可用
AgoraRtcMediaPlayerGetVideoPixelFormat
设置原始视频数据的格式。
- (AgoraVideoFormat)AgoraRtcMediaPlayerGetVideoPixelFormat NS_SWIFT_NAME(AgoraRtcMediaPlayerGetVideoPixelFormat());你需要在调用 setVideoFrameDelegate: 方法时注册回调。当媒体播放器接收到每一帧视频时,会触发该回调。你可以在该回调的返回值中设置期望的视频数据格式。
返回值
你为原始视频数据设置的期望格式,详见 AgoraVideoFormat。默认情况下,原始视频像素格式(AgoraVideoFormatDefault)可能是 I420 或 CVPixelBufferRef。
所属接口类
AgoraRtcMediaPlayer:didReceivePixelBuffer:
媒体播放器接收到视频源的像素缓冲区时触发的回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didReceivePixelBuffer:(CVPixelBufferRef _Nonnull)pixelBuffer NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didReceivePixelBuffer:));触发该回调以报告类型为 CVPixelBufferRef 的像素缓冲区的详细信息。你可以使用这些信息进行图像处理与分析、自定义渲染等。
调用时机
该回调在媒体播放器接收到视频源的像素缓冲区时被触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 媒体播放器对象,详见 AgoraRtcMediaPlayerProtocol。 |
pixelBuffer |
所属接口类
AgoraRtcMediaPlayer:didReceiveVideoFrame:
每次播放器接收到视频帧时触发的回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didReceiveVideoFrame:(AgoraOutputVideoFrame * _Nonnull)videoFrame NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didReceiveVideoFrame:));调用时机
该回调在播放器每次接收到视频帧时被触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器对象。详见 AgoraRtcMediaPlayerProtocol。 |
videoFrame | 视频帧信息。详见 AgoraOutputVideoFrame。 |
所属接口类
AgoraRtcMediaPlayer:volumeIndicationDidReceive:
报告媒体播放器的音量。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
volumeIndicationDidReceive:(NSInteger)volume NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:volumeIndicationDidReceive:));该回调每 200 毫秒触发一次,用于报告当前媒体播放器的音量。
触发时机
该回调每 200 毫秒触发一次。
参数
| 参数名 | 描述 |
|---|---|
playerKit | |
volume |
所属接口类
AgoraRtcMediaPlayer:didReceiveAudioFrame:
每次播放器接收到音频帧时触发的回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didReceiveAudioFrame:(AgoraAudioFrame* _Nonnull)audioFrame NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didReceiveAudioFrame:));注册音频帧观察器后,每次播放器接收到音频帧时,都会触发该回调,报告音频帧的详细信息。
触发时机
每次播放器接收到音频帧时触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例,详见 AgoraRtcMediaPlayerProtocol。 |
audioFrame | 音频帧信息,详见 AgoraAudioFrame。 |
所属接口类
AgoraRtcMediaPlayer:didReceiveData:length:
接收到媒体元数据时触发的回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didReceiveData:(NSString *_Nullable)data
length:(NSInteger)length NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didReceiveData:length:));播放器接收到媒体元数据时,会触发该回调并上报媒体元数据的详细信息。
触发时机
该回调在播放器接收到媒体元数据时触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例。详见 AgoraRtcMediaPlayerProtocol。 |
data | |
length |
所属接口类
AgoraRtcMediaPlayer:didPlayBufferUpdated:
报告缓冲数据可支持的播放时长。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didPlayBufferUpdated:(NSInteger)playCachedBuffer NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didPlayBufferUpdated:));- 当缓冲数据可支持的播放时长小于阈值(默认值为 0)时,SDK 返回
AgoraMediaPlayerEventBufferLow(6)。 - 当缓冲数据可支持的播放时长大于阈值(默认值为 0)时,SDK 返回
AgoraMediaPlayerEventBufferRecover(7)。
触发时机
播放在线媒体资源时,SDK 每两秒触发一次该回调。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例。详见 AgoraRtcMediaPlayerProtocol。 |
playCachedBuffer |
所属接口类
AgoraRtcMediaPlayer:didOccurEvent:elapsedTime:message:
上报播放器事件。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didOccurEvent:(AgoraMediaPlayerEvent)eventCode
elapsedTime:(NSInteger)elapsedTime
message:(NSString *_Nullable)message NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didOccur:elapsedTime:message:));调用 seekToPosition: 方法后,SDK 会触发该回调,上报跳转播放位置操作的结果。
触发时机
该回调在你调用 seekToPosition: 方法后触发,用于上报跳转播放位置操作的结果。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例。详见 AgoraRtcMediaPlayerProtocol。 |
eventCode | 播放器事件类型。详见 AgoraMediaPlayerEvent。 |
elapsedTime | |
message |
所属接口类
AgoraRtcMediaPlayer:infoUpdated:
媒体播放器相关信息发生变化时的回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit infoUpdated:(AgoraMediaPlayerUpdatedInfo *_Nonnull)info NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:infoUpdated:));你可以通过该回调获取媒体播放器的最新信息,用于故障排查。
触发时机
该回调在媒体播放器相关信息发生变化时被触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 媒体播放器对象。详见 AgoraRtcMediaPlayerProtocol。 |
info | 媒体播放器相关的信息。详见 AgoraMediaPlayerUpdatedInfo。 |
所属接口类
AgoraRtcMediaPlayer:didChangedToState:reason:
播放状态发生变化时触发的回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didChangedToState:(AgoraMediaPlayerState)state
reason:(AgoraMediaPlayerReason)reason NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didChangedTo:reason:));播放状态发生变化时触发的回调。
触发时机
该回调在媒体播放器播放状态发生变化时被触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 媒体播放器实例。详见 AgoraRtcMediaPlayerProtocol。 |
state | 播放状态。详见 AgoraMediaPlayerState。 |
reason | 播放状态变化的原因。详见 AgoraMediaPlayerReason。 |
所属接口类
AgoraRtcMediaPlayer:playerSrcInfoDidChange:from:
媒体文件播放源信息变化回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit playerSrcInfoDidChange:(AgoraMediaPlayerSrcInfo *_Nonnull)to from:(AgoraMediaPlayerSrcInfo *_Nonnull)from NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:playerSrcInfoDidChange:from:));该回调在播放媒体文件过程中每两秒触发一次,用于报告播放源信息的变化。
触发时机
该回调在播放媒体文件过程中每两秒触发一次。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例。详见 AgoraRtcMediaPlayerProtocol。 |
to | 变更后的媒体播放器源信息。详见 AgoraMediaPlayerSrcInfo。 |
from | 变更前的媒体播放器源信息。详见 AgoraMediaPlayerSrcInfo。 |
所属接口类
AgoraRtcMediaPlayer:didChangedToPosition:atTimestamp:
播放进度回调。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didChangedToPosition:(NSInteger)positionMs
atTimestamp:(NSTimeInterval)timestampMs NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didChangedTo:atTimestamp:));该回调在播放过程中每秒触发一次,用于报告当前播放进度。
触发时机
该回调在播放过程中每秒触发一次。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例。详见 AgoraRtcMediaPlayerProtocol。 |
positionMs | |
timestampMs |
所属接口类
AgoraRtcMediaPlayer:didPreloadEvent:
上报预加载媒体资源的事件。
- (void)AgoraRtcMediaPlayer:(id<AgoraRtcMediaPlayerProtocol> _Nonnull)playerKit
didPreloadEvent:(AgoraMediaPlayerPreloadEvent)event NS_SWIFT_NAME(AgoraRtcMediaPlayer(_:didPreloadEvent:));触发时机
该回调在媒体资源预加载过程中发生事件时被触发。
参数
| 参数名 | 描述 |
|---|---|
playerKit | 播放器实例,详见 AgoraRtcMediaPlayerProtocol。 |
event | 预加载媒体资源时发生的事件,详见 AgoraMediaPlayerPreloadEvent。 |