Agora RTC Objective-C API Reference Refactor

AgoraMediaPlayerKit.h
Go to the documentation of this file.
1 //
2 // AgoraMediaPlayerKit.h
3 // AgoraMediaPlayer
4 //
5 // Copyright © 2019 agora. All rights reserved.
6 //
7
8 #import <AudioToolbox/AudioToolbox.h>
9 #import <Foundation/Foundation.h>
10 #import <VideoToolbox/VideoToolbox.h>
11 #if TARGET_OS_IPHONE
12 #import <UIKit/UIKit.h>
13 typedef UIView View;
14 #elif TARGET_OS_MAC
15 #import <AppKit/AppKit.h>
16 typedef NSView View;
17 #endif
18 NS_ASSUME_NONNULL_BEGIN
19 // external key
24 #define kMediaPlayerRealTimeStreamAnalyzeDuration @"analyzeduration"
25
30 #define kMediaPlayerDisableAudio @"audio_disable"
31
36 #define kMediaPlayerDisableVideo @"video_disable"
37
39 typedef NS_ENUM(NSInteger, AgoraMediaPlayerState) {
41 AgoraMediaPlayerStateIdle = 0,
43 AgoraMediaPlayerStateOpening = 1,
45 AgoraMediaPlayerStateOpenCompleted = 2,
47 AgoraMediaPlayerStatePlaying = 3,
49 AgoraMediaPlayerStatePaused = 4,
51 AgoraMediaPlayerStatePlayBackCompleted = 5,
53 AgoraMediaPlayerStatePlayBackAllLoopsCompleted = 6,
55 AgoraMediaPlayerStateStopped = 7,
57 AgoraMediaPlayerStatePausingInternal = 50,
59 AgoraMediaPlayerStateStoppingInternal = 51,
61 AgoraMediaPlayerStateSeekingInternal = 52,
63 AgoraMediaPlayerStateGettingInternal = 53,
65 AgoraMediaPlayerStateNoneInternal = 54,
67 AgoraMediaPlayerStateDoNothingInternal = 55,
68
70 AgoraMediaPlayerStateFailed = 100,
71 };
73 typedef NS_ENUM(NSInteger, AgoraMediaPlayerError) {
75 AgoraMediaPlayerErrorNone = 0,
77 AgoraMediaPlayerErrorInvalidArguments = -1,
79 AgoraMediaPlayerErrorInternal = -2,
81 AgoraMediaPlayerErrorNoSource = -3,
83 AgoraMediaPlayerErrorInvalidMediaSource = -4,
85 AgoraMediaPlayerErrorUnknowStreamType = -5,
87 AgoraMediaPlayerErrorObjNotInitialized = -6,
89 AgoraMediaPlayerErrorCodecNotSupported = -7,
91 AgoraMediaPlayerErrorVideoRenderFailed = -8,
93 AgoraMediaPlayerErrorInvalidState = -9,
95 AgoraMediaPlayerErrorUrlNotFound = -10,
97 AgoraMediaPlayerErrorInvalidConnectState = -11,
99 AgoraMediaPlayerErrorSrcBufferUnderflow = -12,
100 };
104 typedef NS_ENUM(NSInteger, AgoraMediaPlayerEvent) {
106 AgoraMediaPlayerEventSeekBegin = 0,
108 AgoraMediaPlayerEventSeekComplete = 1,
110 AgoraMediaPlayerEventSeekError = 2,
112 AgoraMediaPlayerEventAudioTrackChanged = 5,
114 AgoraMediaPlayerEventBufferLow = 6,
116 AgoraMediaPlayerEventBufferRecover = 7,
117
118
119 };
120
124 typedef NS_ENUM(NSUInteger, AgoraMediaPlayerMetaDataType) {
126 AgoraMediaPlayerMetaDataTypeUnknown = 0,
128 AgoraMediaPlayerMetaDataTypeSEI = 1,
129 };
130
132 typedef NS_ENUM(NSInteger, AgoraMediaPixelFormat) {
135 AgoraMediaPixelFormatUnknown = 0,
138 AgoraMediaPixelFormatI420 = 1,
141 AgoraMediaPixelFormatBGRA = 2,
144 AgoraMediaPixelFormatI422 = 3,
147 AgoraMediaPixelFormatNV12 = 8,
148 };
150 typedef NS_ENUM(NSInteger, AgoraMediaStreamType) {
152 AgoraMediaStreamTypeUnknow = 0,
154 AgoraMediaStreamTypeVideo = 1,
156 AgoraMediaStreamTypeAudio = 2,
158 AgoraMediaStreamTypeSubtitle = 3,
159 };
161 typedef NS_ENUM(NSUInteger, AgoraMediaPlayerRenderMode) {
165 AgoraMediaPlayerRenderModeHidden = 1,
166
171 AgoraMediaPlayerRenderModeFit = 2,
172 };
173 @class AgoraMediaPlayer;
174
175 @class AgoraMediaStreamInfo;
177 @protocol AgoraMediaPlayerDelegate <NSObject>
178
179 @optional
180
189 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
190 didChangedToState:(AgoraMediaPlayerState)state
191 error:(AgoraMediaPlayerError)error NS_SWIFT_NAME(AgoraMediaPlayer(_:didChangedToState:error:));
192
202 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
203 didChangedToPosition:(NSInteger)position NS_SWIFT_NAME(AgoraMediaPlayer(_:didChangedToPosition:));
204
211 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
212 didOccurEvent:(AgoraMediaPlayerEvent)event NS_SWIFT_NAME(AgoraMediaPlayer(_:didOccurEvent:));
213
227 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
228 metaDataType:(AgoraMediaPlayerMetaDataType)type
229 didReceiveData:(NSString *)data
230 length:(NSInteger)length NS_SWIFT_NAME(AgoraMediaPlayer(_:metaDataType:didReceiveData:length:));
241 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
242 didReceiveVideoFrame:(CVPixelBufferRef)pixelBuffer NS_SWIFT_NAME(AgoraMediaPlayer(_:didReceiveVideoFrame:));
253 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
254 didReceiveAudioFrame:(CMSampleBufferRef)audioFrame NS_SWIFT_NAME(AgoraMediaPlayer(_:didReceiveAudioFrame:));
255
271 - (void)AgoraMediaPlayer:(AgoraMediaPlayer *_Nonnull)playerKit
272 didPlayBufferUpdated:(NSInteger)playCachedBuffer NS_SWIFT_NAME(AgoraMediaPlayer(_:didPlayBufferUpdated:));
273
274 @end
275
279 __attribute__((visibility("default"))) @interface AgoraMediaStreamInfo : NSObject
281 @property(nonatomic, assign) NSInteger streamIndex;
283 @property(nonatomic, assign) AgoraMediaStreamType streamType;
285 @property(nonatomic, copy) NSString *_Nonnull codecName;
287 @property(nonatomic, copy) NSString *_Nullable language;
289 @property(nonatomic, assign) NSInteger videoFrameRate;
291 @property(nonatomic, assign) NSInteger videoBitRate;
293 @property(nonatomic, assign) NSInteger videoWidth;
295 @property(nonatomic, assign) NSInteger videoHeight;
297 @property(nonatomic, assign) NSInteger audioSampleRate;
299 @property(nonatomic, assign) NSInteger audioChannels;
301 @property(nonatomic, assign) NSInteger duration;
303 @property(nonatomic, assign) NSInteger rotation;
304
305 @end
306
308 __attribute__((visibility("default"))) @interface AgoraMediaPlayer : NSObject
314 @property(nonatomic, assign) BOOL mute;
316 @property(nonatomic, assign) NSInteger volume;
318 @property(nonatomic, readonly) AgoraMediaPlayerState state;
319 @property(nonatomic, weak) id<AgoraMediaPlayerDelegate> _Nullable delegate;
326 - (instancetype)initWithDelegate:(id<AgoraMediaPlayerDelegate>)delegate NS_SWIFT_NAME(initWithDelegate(_:));
345 - (instancetype)initWithDelegate:(id<AgoraMediaPlayerDelegate>)delegate voiceChatMode:(bool)enableVoiceChatMode NS_SWIFT_NAME(initWithDelegate(_:voiceChatMode:));
346
351 - (void)setView:(View *_Nullable)view NS_SWIFT_NAME(setView(_:));
352
357 - (void)setRenderMode:(AgoraMediaPlayerRenderMode)mode NS_SWIFT_NAME(setRenderMode(_:));
358
366 - (void)open:(NSString *)url startPos:(NSInteger)startPos NS_SWIFT_NAME(open(_:startPos:));
367
373 - (void)play NS_SWIFT_NAME(play());
374
379 - (void)pause NS_SWIFT_NAME(pause());
380
383 - (void)stop NS_SWIFT_NAME(stop());
384
392 - (void)seekToPosition:(NSInteger)position NS_SWIFT_NAME(seek(ToPosition:));
393
403 - (int)mute:(bool)isMute NS_SWIFT_NAME(mute(_:));
404
411 - (bool)getMute NS_SWIFT_NAME(getMute());
412
419 - (int)adjustVolume:(int)volume NS_SWIFT_NAME(adjustVolume(_:));
420
425 - (NSInteger)getPlayPosition NS_SWIFT_NAME(getPlayPosition());
426
432 - (NSInteger)getDuration NS_SWIFT_NAME(getDuration());
433
440 - (AgoraMediaPlayerState)getPlayerState NS_SWIFT_NAME(getPlayerState());
441
448 - (NSInteger)getStreamCount NS_SWIFT_NAME(getStreamCount());
449
457 - (AgoraMediaStreamInfo *_Nullable)getStreamByIndex:(int)index NS_SWIFT_NAME(getStreamBy(_:));
458
470 - (void)setLogFile:(NSString *)filePath NS_SWIFT_NAME(setLogFile(_:));
471
489 - (void)setLogFilter:(NSInteger)filter NS_SWIFT_NAME(setLogFilter(_:));
490
491
504 - (void)setPlayerOptionInt:(NSString *)key value:(NSInteger)value NS_SWIFT_NAME(setPlayerOptionInt(_:value:));
505
518 - (void)setPlayerOptionString:(NSString *)key value:(NSString *)value NS_SWIFT_NAME(setPlayerOptionString(_:value:));
519
520
528 - (void)setPlaybackSpeed:(NSInteger)speed NS_SWIFT_NAME(setPlaybackSpeed(_:));
542 - (void)selectAudioTrack:(NSInteger)index NS_SWIFT_NAME(selectAudioTrack(_:));
543
551 - (NSString *)getPlayerSdkVersion NS_SWIFT_NAME(getPlayerSdkVersion());
562 - (void)setLoopCount:(NSInteger)loopCount NS_SWIFT_NAME(setLoopCount(_:));
579 - (void)destroy NS_SWIFT_NAME(destroy());
589 - (void)setExternalSubtitle:(NSString *)url NS_SWIFT_NAME(setExternalSubtitle(_:));
590
591 @end
592
593 NS_ASSUME_NONNULL_END
AgoraMediaPlayerRenderModeHidden
@ AgoraMediaPlayerRenderModeHidden
Definition: AgoraMediaPlayerKit.h:165
AgoraMediaPlayerErrorVideoRenderFailed
@ AgoraMediaPlayerErrorVideoRenderFailed
Definition: AgoraMediaPlayerKit.h:91
AgoraMediaPlayerStateIdle
@ AgoraMediaPlayerStateIdle
Definition: AgoraMediaPlayerKit.h:41
AgoraMediaPlayerState
AgoraMediaPlayerState
Player state.
Definition: AgoraEnumerates.h:2735
AgoraMediaPlayerDelegate-p
Definition: AgoraMediaPlayerKit.h:177
AgoraMediaPlayerStatePausingInternal
@ AgoraMediaPlayerStatePausingInternal
Definition: AgoraMediaPlayerKit.h:57
AgoraMediaPlayerStatePaused
@ AgoraMediaPlayerStatePaused
Definition: AgoraMediaPlayerKit.h:49
AgoraMediaStreamTypeSubtitle
@ AgoraMediaStreamTypeSubtitle
Definition: AgoraMediaPlayerKit.h:158
AgoraMediaPlayerErrorInvalidConnectState
@ AgoraMediaPlayerErrorInvalidConnectState
Definition: AgoraMediaPlayerKit.h:97
AgoraMediaPlayerError
AgoraMediaPlayerError
Definition: AgoraEnumerates.h:2804
AgoraMediaPlayerEventAudioTrackChanged
@ AgoraMediaPlayerEventAudioTrackChanged
Definition: AgoraMediaPlayerKit.h:112
AgoraMediaPlayerEventSeekComplete
@ AgoraMediaPlayerEventSeekComplete
Definition: AgoraMediaPlayerKit.h:108
AgoraMediaStreamTypeUnknow
@ AgoraMediaStreamTypeUnknow
Definition: AgoraMediaPlayerKit.h:152
AgoraMediaPlayerEventBufferRecover
@ AgoraMediaPlayerEventBufferRecover
Definition: AgoraMediaPlayerKit.h:116
AgoraMediaPlayerErrorSrcBufferUnderflow
@ AgoraMediaPlayerErrorSrcBufferUnderflow
Definition: AgoraMediaPlayerKit.h:99
AgoraMediaPlayerStateDoNothingInternal
@ AgoraMediaPlayerStateDoNothingInternal
Definition: AgoraMediaPlayerKit.h:67
View
UIView View
Definition: AgoraMediaPlayerKit.h:13
AgoraMediaPlayerStatePlaying
@ AgoraMediaPlayerStatePlaying
Definition: AgoraMediaPlayerKit.h:47
AgoraMediaPlayerErrorObjNotInitialized
@ AgoraMediaPlayerErrorObjNotInitialized
Definition: AgoraMediaPlayerKit.h:87
AgoraMediaPlayerStateFailed
@ AgoraMediaPlayerStateFailed
Definition: AgoraMediaPlayerKit.h:70
AgoraMediaPixelFormat
AgoraMediaPixelFormat
Definition: AgoraMediaPlayerKit.h:132
AgoraMediaPixelFormatUnknown
@ AgoraMediaPixelFormatUnknown
Definition: AgoraMediaPlayerKit.h:135
AgoraMediaPlayerStatePlayBackAllLoopsCompleted
@ AgoraMediaPlayerStatePlayBackAllLoopsCompleted
Definition: AgoraMediaPlayerKit.h:53
AgoraMediaPixelFormatI420
@ AgoraMediaPixelFormatI420
Definition: AgoraMediaPlayerKit.h:138
AgoraMediaPlayerErrorUrlNotFound
@ AgoraMediaPlayerErrorUrlNotFound
Definition: AgoraMediaPlayerKit.h:95
AgoraMediaStreamTypeAudio
@ AgoraMediaStreamTypeAudio
Definition: AgoraMediaPlayerKit.h:156
AgoraMediaPlayerEventSeekError
@ AgoraMediaPlayerEventSeekError
Definition: AgoraMediaPlayerKit.h:110
AgoraMediaPlayerEvent
AgoraMediaPlayerEvent
Definition: AgoraEnumerates.h:2846
AgoraMediaPlayerStateOpenCompleted
@ AgoraMediaPlayerStateOpenCompleted
Definition: AgoraMediaPlayerKit.h:45
AgoraMediaPlayerState
AgoraMediaPlayerState
Definition: AgoraMediaPlayerKit.h:39
AgoraMediaPixelFormatBGRA
@ AgoraMediaPixelFormatBGRA
Definition: AgoraMediaPlayerKit.h:141
AgoraMediaStreamType
AgoraMediaStreamType
Definition: AgoraEnumerates.h:2720
AgoraMediaPlayerMetaDataTypeUnknown
@ AgoraMediaPlayerMetaDataTypeUnknown
Definition: AgoraMediaPlayerKit.h:126
AgoraMediaPlayerMetaDataType
AgoraMediaPlayerMetaDataType
Definition: AgoraEnumerates.h:2898
AgoraMediaPlayerStateOpening
@ AgoraMediaPlayerStateOpening
Definition: AgoraMediaPlayerKit.h:43
AgoraMediaPlayerErrorCodecNotSupported
@ AgoraMediaPlayerErrorCodecNotSupported
Definition: AgoraMediaPlayerKit.h:89
AgoraMediaPlayerStateStopped
@ AgoraMediaPlayerStateStopped
Definition: AgoraMediaPlayerKit.h:55
AgoraMediaPixelFormatI422
@ AgoraMediaPixelFormatI422
Definition: AgoraMediaPlayerKit.h:144
AgoraMediaPlayerStateGettingInternal
@ AgoraMediaPlayerStateGettingInternal
Definition: AgoraMediaPlayerKit.h:63
AgoraMediaPlayerErrorNoSource
@ AgoraMediaPlayerErrorNoSource
Definition: AgoraMediaPlayerKit.h:81
AgoraMediaPlayerErrorInvalidMediaSource
@ AgoraMediaPlayerErrorInvalidMediaSource
Definition: AgoraMediaPlayerKit.h:83
AgoraMediaPlayerErrorNone
@ AgoraMediaPlayerErrorNone
Definition: AgoraMediaPlayerKit.h:75
AgoraMediaPlayerErrorInvalidState
@ AgoraMediaPlayerErrorInvalidState
Definition: AgoraMediaPlayerKit.h:93
AgoraMediaPlayerRenderModeFit
@ AgoraMediaPlayerRenderModeFit
Definition: AgoraMediaPlayerKit.h:171
AgoraMediaPlayerStatePlayBackCompleted
@ AgoraMediaPlayerStatePlayBackCompleted
Definition: AgoraMediaPlayerKit.h:51
AgoraMediaPixelFormatNV12
@ AgoraMediaPixelFormatNV12
Definition: AgoraMediaPlayerKit.h:147
AgoraMediaPlayerErrorUnknowStreamType
@ AgoraMediaPlayerErrorUnknowStreamType
Definition: AgoraMediaPlayerKit.h:85
AgoraMediaPlayerEventBufferLow
@ AgoraMediaPlayerEventBufferLow
Definition: AgoraMediaPlayerKit.h:114
AgoraMediaPlayerStateNoneInternal
@ AgoraMediaPlayerStateNoneInternal
Definition: AgoraMediaPlayerKit.h:65
AgoraMediaPlayerRenderMode
AgoraMediaPlayerRenderMode
Definition: AgoraEnumerates.h:2789
AgoraMediaStreamTypeVideo
@ AgoraMediaStreamTypeVideo
Definition: AgoraMediaPlayerKit.h:154
AgoraMediaPlayerMetaDataTypeSEI
@ AgoraMediaPlayerMetaDataTypeSEI
Definition: AgoraMediaPlayerKit.h:128
AgoraMediaPlayerEventSeekBegin
@ AgoraMediaPlayerEventSeekBegin
Definition: AgoraMediaPlayerKit.h:106
AgoraMediaPlayerErrorInternal
@ AgoraMediaPlayerErrorInternal
Definition: AgoraMediaPlayerKit.h:79
AgoraMediaPlayerStateStoppingInternal
@ AgoraMediaPlayerStateStoppingInternal
Definition: AgoraMediaPlayerKit.h:59
AgoraMediaPlayerErrorInvalidArguments
@ AgoraMediaPlayerErrorInvalidArguments
Definition: AgoraMediaPlayerKit.h:77
AgoraMediaPlayerStateSeekingInternal
@ AgoraMediaPlayerStateSeekingInternal
Definition: AgoraMediaPlayerKit.h:61