reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofAVFoundationVideoPlayer.h
Go to the documentation of this file.
1//
2// ofAVFoundationVideoPlayer.h
3// Created by Lukasz Karluk on 06/07/14.
4// Merged with code by Sam Kronick, James George and Elie Zananiri.
5//
6
7//----------------------------------------------------------
8#import <Foundation/Foundation.h>
9#import <AVFoundation/AVFoundation.h>
10#import <Accelerate/Accelerate.h>
11#import <CoreMedia/CoreMedia.h>
12
13
14//----------------------------------------------------------
15#include <TargetConditionals.h>
16#if (TARGET_IPHONE_SIMULATOR) || (TARGET_OS_IPHONE) || (TARGET_IPHONE)
17#define TARGET_IOS
18#else
19#define TARGET_OSX
20#endif
21
22
23#define USE_VIDEO_OUTPUT (defined(MAC_OS_X_VERSION_10_8) || defined(iOS6))
24
25// so we are independend from oF in this class
31
32
33//---------------------------------------------------------- video player.
34@interface ofAVFoundationVideoPlayer : NSObject {
35#if defined(USE_VIDEO_OUTPUT)
36 CMVideoFormatDescriptionRef _videoInfo;
37#endif
38
40
41 CMSampleBufferRef videoSampleBuffer;
42 CMSampleBufferRef audioSampleBuffer;
47 CMTime duration;
49 float volume;
50 float speed;
51 float frameRate;
52
53 NSInteger videoWidth;
54 NSInteger videoHeight;
55
57
59 BOOL bReady;
60 BOOL bLoaded;
65 BOOL bWasPlayingBackwards; // for optimisation
69 BOOL bSampleVideo; // default to YES
70 BOOL bSampleAudio; // default to NO
72 BOOL bStream;
76
77 NSLock* asyncLock;
78 NSCondition* deallocCond;
79}
80
81@property (nonatomic, strong) AVPlayer * player;
82@property (nonatomic, strong) AVAsset * asset;
83@property (nonatomic, strong) AVPlayerItem * playerItem;
84
85
86@property (nonatomic, strong) AVAssetReader * assetReader;
87@property (nonatomic, strong) AVAssetReaderTrackOutput * assetReaderVideoTrackOutput;
88@property (nonatomic, strong) AVAssetReaderTrackOutput * assetReaderAudioTrackOutput;
89
90#if defined(USE_VIDEO_OUTPUT)
91@property (nonatomic, strong) AVPlayerItemVideoOutput *videoOutput;
92#endif
93
94
95- (BOOL)loadWithFile:(NSString*)file async:(BOOL)bAsync;
96- (BOOL)loadWithPath:(NSString*)path async:(BOOL)bAsync;
97- (BOOL)loadWithURL:(NSURL*)url async:(BOOL)bAsync stream:(BOOL)isStream;
98- (void)unloadVideoAsync;
99- (void)unloadVideo;
100
101- (void)update;
102
103- (void)play;
104- (void)pause;
105- (void)togglePlayPause;
106- (void)stop;
107
108- (void)stepByCount:(long)frames;
109
110- (void)seekToStart;
111- (void)seekToEnd;
112- (void)seekToTime:(CMTime)time;
113- (void)seekToTime:(CMTime)time withTolerance:(CMTime)tolerance;
114
115- (BOOL)isReady;
116- (BOOL)isLoaded;
117- (BOOL)isPlaying;
118- (BOOL)isPaused;
119- (BOOL)isNewFrame;
120- (BOOL)isFinished;
121
122- (void)setEnableVideoSampling:(BOOL)value;
123- (void)setEnableAudioSampling:(BOOL)value;
124- (void)setSynchSampleTime:(CMTime)time;
125- (void)setSynchSampleTimeInSec:(double)time;
126
127- (CMTime)getVideoSampleTime;
128- (double)getVideoSampleTimeInSec;
129- (CMTime)getAudioSampleTime;
130- (double)getAudioSampleTimeInSec;
131- (CMSampleBufferRef)getVideoSampleBuffer;
132- (CMSampleBufferRef)getAudioSampleBuffer;
133- (CVImageBufferRef)getCurrentFrame;
134
135- (NSInteger)getWidth;
136- (NSInteger)getHeight;
137- (CMTime)getCurrentTime;
138- (double)getCurrentTimeInSec;
139- (CMTime)getDuration;
140- (double)getDurationInSec;
141- (int)getDurationInFrames;
142- (int)getCurrentFrameNum;
143- (float)getFrameRate;
144
145- (void)setFrame:(int)frame;
146- (void)setPosition:(float)position;
147- (float)getPosition;
148- (void)setVolume:(float)volume;
149- (float)getVolume;
150- (void)setLoop:(playerLoopType)loop;
151- (playerLoopType)getLoop;
152- (void)setSpeed:(float)speed;
153- (float)getSpeed;
154- (void)setAutoplay:(BOOL)bAutoplay;
155- (BOOL)getAutoplay;
156- (void)setWillBeUpdatedExternally:(BOOL)value;
157- (void)close;
158- (void)setStreaming:(BOOL)value;
159
160
161@end
Definition ofAVFoundationVideoPlayer.h:34
NSLock * asyncLock
Definition ofAVFoundationVideoPlayer.h:77
CMTime synchSampleTime
Definition ofAVFoundationVideoPlayer.h:46
float frameRate
Definition ofAVFoundationVideoPlayer.h:51
BOOL bIsStopped
Definition ofAVFoundationVideoPlayer.h:75
BOOL bReady
Definition ofAVFoundationVideoPlayer.h:59
BOOL bSeeking
Definition ofAVFoundationVideoPlayer.h:68
NSCondition * deallocCond
Definition ofAVFoundationVideoPlayer.h:78
float positionBeforeReady
Definition ofAVFoundationVideoPlayer.h:74
CMTime audioSampleTime
Definition ofAVFoundationVideoPlayer.h:45
BOOL bNewFrame
Definition ofAVFoundationVideoPlayer.h:63
int frameBeforeReady
Definition ofAVFoundationVideoPlayer.h:73
CMSampleBufferRef audioSampleBuffer
Definition ofAVFoundationVideoPlayer.h:42
BOOL bUpdateFirstFrame
Definition ofAVFoundationVideoPlayer.h:62
BOOL bWasPlayingBackwards
Definition ofAVFoundationVideoPlayer.h:65
BOOL bWillBeUpdatedExternally
Definition ofAVFoundationVideoPlayer.h:58
BOOL bSampleVideo
Definition ofAVFoundationVideoPlayer.h:69
CMTime videoSampleTime
Definition ofAVFoundationVideoPlayer.h:43
CMTime videoSampleTimePrev
Definition ofAVFoundationVideoPlayer.h:44
BOOL bPlayStateBeforeLoad
Definition ofAVFoundationVideoPlayer.h:61
BOOL bLoaded
Definition ofAVFoundationVideoPlayer.h:60
float volume
Definition ofAVFoundationVideoPlayer.h:49
NSInteger videoWidth
Definition ofAVFoundationVideoPlayer.h:53
CMVideoFormatDescriptionRef _videoInfo
Definition ofAVFoundationVideoPlayer.h:36
BOOL bIsUnloaded
Definition ofAVFoundationVideoPlayer.h:71
BOOL bPlaying
Definition ofAVFoundationVideoPlayer.h:64
CMSampleBufferRef videoSampleBuffer
Definition ofAVFoundationVideoPlayer.h:41
playerLoopType loop
Definition ofAVFoundationVideoPlayer.h:56
NSInteger videoHeight
Definition ofAVFoundationVideoPlayer.h:54
float speed
Definition ofAVFoundationVideoPlayer.h:50
BOOL bStream
Definition ofAVFoundationVideoPlayer.h:72
BOOL bAutoPlayOnLoad
Definition ofAVFoundationVideoPlayer.h:67
id timeObserver
Definition ofAVFoundationVideoPlayer.h:39
CMTime duration
Definition ofAVFoundationVideoPlayer.h:47
BOOL bSampleAudio
Definition ofAVFoundationVideoPlayer.h:70
CMTime currentTime
Definition ofAVFoundationVideoPlayer.h:48
BOOL bFinished
Definition ofAVFoundationVideoPlayer.h:66
enum _playerLoopType playerLoopType
_playerLoopType
Definition ofAVFoundationVideoPlayer.h:26
@ LOOP_PALINDROME
Definition ofAVFoundationVideoPlayer.h:28
@ LOOP_NONE
Definition ofAVFoundationVideoPlayer.h:27
@ LOOP_NORMAL
Definition ofAVFoundationVideoPlayer.h:29