forked from RTE-Dev/REDPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedMediaPlayBack.h
More file actions
272 lines (208 loc) · 9.79 KB
/
RedMediaPlayBack.h
File metadata and controls
272 lines (208 loc) · 9.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
//
// RedMediaPlayback.h
// RedPlayer
//
// Created by zijie on 2023/12/19.
// Copyright © 2023 Xiaohongshu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/// Enum for RedScalingMode
typedef NS_ENUM(NSInteger, RedScalingMode) {
RedScalingModeNone, ///< No scaling
RedScalingModeAspectFit, ///< Uniform scale until one dimension fits
RedScalingModeAspectFill, ///< Uniform scale until the movie fills the visible bounds. One dimension may have clipped contents
RedScalingModeFill ///< Non-uniform scale. Both render dimensions will exactly match the visible bounds
};
/// Enum for RedPlaybackState
typedef NS_ENUM(NSInteger, RedPlaybackState) {
RedPlaybackStateStopped, ///< Playback is stopped
RedPlaybackStatePlaying, ///< Playback is playing
RedPlaybackStatePaused, ///< Playback is paused
RedPlaybackStateInterrupted, ///< Playback is interrupted
RedPlaybackStateSeekingForward, ///< Playback is seeking forward
RedPlaybackStateSeekingBackward ///< Playback is seeking backward
};
/// Enum for RedLoadState
typedef NS_OPTIONS(NSUInteger, RedLoadState) {
RedLoadStateUnknown = 0, ///< Unknown load state
RedLoadStatePlayable = 1 << 0, ///< State when playable
RedLoadStatePlaythroughOK = 1 << 1, ///< Playback will be automatically started in this state when shouldAutoplay is YES
RedLoadStateStalled = 1 << 2, ///< Playback will be automatically paused in this state, if started
};
/// Enum for RedFinishReason
typedef NS_ENUM(NSInteger, RedFinishReason) {
RedFinishReasonPlaybackEnded, ///< Playback ended
RedFinishReasonPlaybackError, ///< Playback error
RedFinishReasonUserExited ///< User exited
};
/// Enum for RedVideoFirstRenderingReason
typedef NS_ENUM(NSInteger,RedVideoFirstRenderingReason){
RedVideoFirstRenderingReasonStart, ///< Start rendering
RedVideoFirstRenderingReasonWaitStart ///< Wait start rendering
};
/// Enum for RedRenderType
typedef NS_ENUM(NSUInteger, RedRenderType) {
RedRenderTypeOpenGL, ///< OpenGL render type
RedRenderTypeMetal, ///< Metal render type
RedRenderTypeSampleBufferDisplayLayer, ///< Sample buffer display layer render type
};
#pragma mark RedMediaPlayback
@protocol RedMediaPlayback <NSObject>
/// The view associated with the playback.
@property (nonatomic, readonly) UIView *view;
/// The current playback time.
@property (nonatomic) NSTimeInterval currentPlaybackTime;
/// The total duration of the media.
@property (nonatomic, readonly) NSTimeInterval duration;
/// The duration of media that can be played without buffering.
@property (nonatomic, readonly) NSTimeInterval playableDuration;
/// The buffering progress as a percentage.
@property (nonatomic, readonly) NSInteger bufferingProgress;
/// Indicates whether the playback is prepared to play.
@property (nonatomic, readonly) BOOL isPreparedToPlay;
/// The current playback state.
@property (nonatomic, readonly) RedPlaybackState playbackState;
/// The current load state.
@property (nonatomic, readonly) RedLoadState loadState;
/// Indicates whether seeking is in progress.
@property (nonatomic, readonly) int isSeekBuffering;
/// Indicates audio synchronization status.
@property (nonatomic, readonly) int isAudioSync;
/// Indicates video synchronization status.
@property (nonatomic, readonly) int isVideoSync;
/// The real cached bytes for video.
@property (nonatomic, readonly) int64_t videoRealCachedBytes;
/// The total file size of the video.
@property (nonatomic, readonly) int64_t videoFileSize;
/// The maximum buffer size.
@property (nonatomic, readonly) int64_t maxBufferSize;
/// The current buffer size for video.
@property (nonatomic, readonly) int64_t videoBufferBytes;
/// The current buffer size for audio.
@property (nonatomic, readonly) int64_t audioBufferBytes;
/// Video decode per second.
@property (nonatomic, readonly) float vdps;
/// Video render frames per second.
@property (nonatomic, readonly) float vRenderFps;
/// The duration of cached content.
@property (nonatomic, readonly) int64_t cachedDuration;
/// The natural size of the media.
@property (nonatomic, readonly) CGSize naturalSize;
/// The scaling mode for video playback.
@property (nonatomic) RedScalingMode scalingMode;
/// Indicates whether autoplay is enabled.
@property (nonatomic) BOOL shouldAutoplay;
/// The playback rate.
@property (nonatomic) float playbackRate;
/// The playback volume.
@property (nonatomic) float playbackVolume;
/// Indicates whether soft decoding is enabled.
@property (nonatomic, readonly) BOOL isSoftDecoding;
/// Indicates whether to pause the GLView background.
@property (nonatomic) BOOL notPauseGlviewBackground;
/// Frames per second in metadata.
@property(nonatomic, readonly) CGFloat fpsInMeta;
/// Sets the content URL for playback.
- (void)setContentURL:(NSURL *)URL;
/// Sets the content string for playback.
- (void)setContentString:(NSString *)aString;
/// Sets the content URL list for playback.
- (void)setContentURLList:(NSString *)aString;
/// Prepares the media for playback.
- (void)prepareToPlay;
/// Starts playback.
- (void)play;
/// Pauses playback.
- (void)pause;
/// Returns whether the media is currently playing.
- (BOOL)isPlaying;
/// Shuts down the media playback.
- (void)shutdown;
/// Sets whether to pause in the background.
- (void)setPauseInBackground:(BOOL)pause;
/// Retrieves the current playback URL.
- (NSString *)getPlayUrl;
/// Seeks to the specified playback time.
- (BOOL)seekCurrentPlaybackTime:(NSTimeInterval)aCurrentPlaybackTime;
/// Returns the rate of dropped packets before decoding.
- (float)dropPacketRateBeforeDecode;
/// Returns the rate of dropped frames.
- (float)dropFrameRate;
/// Returns the loop setting.
- (int)getLoop;
/// Sets the loop setting.
- (void)setLoop:(int)loop;
/// Returns whether the audio is muted.
- (BOOL)getMute;
/// Sets the mute status.
- (void)setMute:(BOOL)muted;
/// Sets the video cache directory.
- (void)setVideoCacheDir:(NSString *)dir;
/// Sets whether HDR is enabled.
- (void)setEnableHDR:(BOOL)enable;
/// Sets whether Video Toolbox is enabled.
- (void)setEnableVTB:(BOOL)enable;
/// Sets whether video is live source.
- (void)setLiveMode:(BOOL)enable;
/// Returns whether Video Toolbox is open.
- (BOOL)isVideoToolboxOpen;
/// Retrieves debug information for video.
- (NSDictionary *)getVideoDebugInfo;
#pragma mark - Notifications
#ifdef __cplusplus
#define RED_EXTERN extern "C" __attribute__((visibility ("default")))
#else
#define RED_EXTERN extern __attribute__((visibility ("default")))
#endif
// -----------------------------------------------------------------------------
// MPMediaPlayback.h
/// Notification posted when the prepared state changes for an object conforming to MPMediaPlayback protocol.
RED_EXTERN NSString *const RedMediaPlaybackIsPreparedToPlayDidChangeNotification;
// -----------------------------------------------------------------------------
// MPMoviePlayerController.h
// Movie Player Notifications
/// Notification posted when the scaling mode changes.
RED_EXTERN NSString* const RedPlayerScalingModeDidChangeNotification;
/// Notification posted when movie playback ends or a user exits playback.
RED_EXTERN NSString* const RedPlayerPlaybackDidFinishNotification;
RED_EXTERN NSString* const RedPlayerPlaybackDidFinishReasonUserInfoKey; // NSNumber (REDMPMovieFinishReason)
RED_EXTERN NSString *const RedPlayerPlaybackDidFinishErrorUserInfoKey; // NSNumber (errorCode)
RED_EXTERN NSString *const RedPlayerPlaybackDidFinishDetailedErrorUserInfoKey; // NSNumber (errorCode), more detailed error code
/// Notification posted when the playback state changes, either programmatically or by the user.
RED_EXTERN NSString* const RedPlayerPlaybackStateDidChangeNotification;
/// Notification posted when the network load state changes.
RED_EXTERN NSString* const RedPlayerLoadStateDidChangeNotification;
// -----------------------------------------------------------------------------
// Movie Property Notifications
/// Notification posted when natural size is available after calling -prepareToPlay.
RED_EXTERN NSString* const RedPlayerNaturalSizeAvailableNotification;
// -----------------------------------------------------------------------------
// Extend Notifications
RED_EXTERN NSString *const RedPlayerVideoDecoderOpenNotification;
RED_EXTERN NSString *const RedPlayerFirstVideoFrameRenderedNotification;
RED_EXTERN NSString *const RedPlayerFirstVideoFrameRenderedNotificationUserInfo;
RED_EXTERN NSString *const RedPlayerFirstAudioFrameRenderedNotification;
RED_EXTERN NSString *const RedPlayerFirstAudioFrameDecodedNotification;
RED_EXTERN NSString *const RedPlayerFirstVideoFrameDecodedNotification;
RED_EXTERN NSString *const RedPlayerOpenInputNotification;
RED_EXTERN NSString *const RedPlayerFindStreamInfoNotification;
RED_EXTERN NSString *const RedPlayerComponentOpenNotification;
RED_EXTERN NSString *const RedPlayerDidSeekCompleteNotification;
RED_EXTERN NSString *const RedPlayerDidSeekCompleteTargetKey;
RED_EXTERN NSString *const RedPlayerDidSeekCompleteErrorKey;
RED_EXTERN NSString *const RedPlayerDidAccurateSeekCompleteCurPos;
RED_EXTERN NSString *const RedPlayerAccurateSeekCompleteNotification;
RED_EXTERN NSString *const RedPlayerSeekAudioStartNotification;
RED_EXTERN NSString *const RedPlayerSeekVideoStartNotification;
RED_EXTERN NSString *const RedPlayerVideoFirstPacketInDecoderNotification;
RED_EXTERN NSString *const RedPlayerVideoStartOnPlayingNotification;
RED_EXTERN NSString *const RedPlayerCacheDidFinishNotification;
RED_EXTERN NSString *const RedPlayerCacheURLUserInfoKey; // NSURL
// Network
RED_EXTERN NSString *const RedPlayerUrlChangeMsgNotification;
RED_EXTERN NSString *const RedPlayerUrlChangeCurUrlKey;
RED_EXTERN NSString *const RedPlayerUrlChangeCurUrlHttpCodeKey;
RED_EXTERN NSString *const RedPlayerUrlChangeNextUrlKey;
RED_EXTERN NSString *const RedPlayerMessageTimeUserInfoKey;
@end