UPAVPlayer.h
4.57 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
//
// UPAVPlayer.h
// UPAVPlayerDemo
//
// Created by DING FENG on 2/16/16.
// Copyright © 2016 upyun.com. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "UPLiveSDKConfig.h"
typedef NS_ENUM(NSInteger, UPAVPlayerStatus) {
UPAVPlayerStatusIdle,
UPAVPlayerStatusPlaying_buffering,
UPAVPlayerStatusPlaying,
UPAVPlayerStatusPause,
UPAVPlayerStatusFailed
};
typedef NS_ENUM(NSInteger, UPAVStreamStatus) {
UPAVStreamStatusIdle,
UPAVStreamStatusConnecting,
UPAVStreamStatusReady,
};
typedef void(^AudioBufferListReleaseBlock)(AudioBufferList *audioBufferListe);
@interface UPAVPlayerStreamInfo : NSObject
@property (nonatomic) float duration;
@property (nonatomic) BOOL canPause;
@property (nonatomic) BOOL canSeek;
@property (nonatomic, strong) NSDictionary *descriptionInfo;
@end
@interface UPAVPlayerDashboard: NSObject
@property (nonatomic, readonly) NSString *url;
@property (nonatomic, readonly) NSString *serverIp;
@property (nonatomic, readonly) NSString *serverName;
@property (nonatomic, readonly) int cid;
@property (nonatomic, readonly) int pid;
@property (nonatomic, readonly) float fps;
@property (nonatomic, readonly) float bps;
@property (nonatomic, readonly) int vCachedFrames;
@property (nonatomic, readonly) int aCachedFrames;
@property (readonly, nonatomic) int decodedVFrameNum;//解码的视频包数量
@property (readonly, nonatomic) int decodedVKeyFrameNum;//解码的关键帧
@property (readonly, nonatomic) int decodedAFrameNum;//解码的音频包数量
@end
@class UPAVPlayer;
@protocol UPAVPlayerDelegate <NSObject>
//播放器状态
@optional
- (void)player:(UPAVPlayer *)player playerStatusDidChange:(UPAVPlayerStatus)playerStatus;
- (void)player:(UPAVPlayer *)player displayPositionDidChange:(float)position;
- (void)player:(UPAVPlayer *)player bufferingProgressDidChange:(float)progress;
@required
- (void)player:(UPAVPlayer *)player playerError:(NSError *)error;
//视频流状态
@optional
- (void)player:(UPAVPlayer *)player streamStatusDidChange:(UPAVStreamStatus)streamStatus;
- (void)player:(UPAVPlayer *)player streamInfoDidReceive:(UPAVPlayerStreamInfo *)streamInfo;
//字幕流回调
@optional
- (void)player:(UPAVPlayer *)player subtitle:(NSString *)text atPosition:(CGFloat)position shouldDisplay:(CGFloat)duration;
/*
播放音频数据的回调.
用途如:读取并播放音频文件,同时将音频数据送入混音器来当作背景音乐。
*/
@optional
- (void)player:(UPAVPlayer *)audioManager
willRenderBuffer:(AudioBufferList *)audioBufferList
timeStamp:(const AudioTimeStamp *)inTimeStamp
frames:(UInt32)inNumberFrames
info:(AudioStreamBasicDescription)asbd
block:(AudioBufferListReleaseBlock)release;
@end
@interface UPAVPlayer : NSObject
@property (nonatomic, strong, readonly) UIView *playView;
@property (nonatomic, strong, readonly) UPAVPlayerDashboard *dashboard;
@property (nonatomic, strong, readonly) UPAVPlayerStreamInfo *streamInfo;
@property (nonatomic, assign, readonly) UPAVPlayerStatus playerStatus;
@property (nonatomic, assign, readonly) UPAVStreamStatus streamStatus;
@property (nonatomic, assign) NSTimeInterval bufferingTime;//(0.1s -- 10s)
@property (nonatomic, assign) CGFloat volume;
@property (nonatomic, assign) CGFloat bright;
@property (nonatomic, assign) BOOL mute;
@property (nonatomic, assign) int type;
@property (nonatomic, assign) NSTimeInterval timeoutForBuffering;//视频缓冲超时,默认 60s
@property (nonatomic, assign) NSTimeInterval timeoutForOpenFile;//打开文件超时,默认 10s
@property (nonatomic, assign) NSUInteger maxNumForReopenFile;//打开文件重试次数限制,默认 1 次,最大 10 次
@property (nonatomic, copy) NSString *url;
@property (nonatomic, copy) NSDictionary *headerDic;
@property (nonatomic, assign, readonly) float displayPosition;//视频播放到的时间点
@property (nonatomic, assign, readonly) float streamPosition;//视频流读取到的时间点
@property (nonatomic, assign, readonly) float audioPosition;//音频播放到的时间点
@property (nonatomic, weak) id<UPAVPlayerDelegate> delegate;
@property (nonatomic) BOOL lipSynchOn;//音画同步,默认值 YES
@property (nonatomic) int lipSynchMode;//0:音频向视频同步, 视频向标准时间轴同步;1:视频向音频同步,音频按照原采样率连续播放。 默认值 为 1。
- (instancetype)initWithURL:(NSString *)url;
- (void)setFrame:(CGRect)frame;
- (void)connect;
- (void)play;
- (void)pause;
- (void)stop;
- (void)seekToTime:(CGFloat)position;
@end