Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaptureImplAvFoundation.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #include "cinder/Cinder.h"
24 #include "cinder/Surface.h"
25 #include "cinder/Capture.h"
26 #import <AVFoundation/AVFoundation.h>
27 #include <vector>
28 
29 namespace cinder {
30 
32  public:
33  CaptureImplAvFoundationDevice( AVCaptureDevice *device );
35 
36  bool checkAvailable() const;
37  bool isConnected() const;
38  Capture::DeviceIdentifier getUniqueId() const { return mUniqueId; }
39  bool isFrontFacing() const { return mFrontFacing; }
40  void* getNative() const { return mNativeDevice; }
41  private:
42  Capture::DeviceIdentifier mUniqueId;
43  AVCaptureDevice *mNativeDevice;
44  bool mFrontFacing;
45 };
46 
47 } //namespace
48 
49 @interface CaptureImplAvFoundation : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate> {
50  AVCaptureSession *mSession;
51  CVPixelBufferRef mWorkingPixelBuffer;
52  cinder::Surface8u mCurrentFrame;
53  NSString *mDeviceUniqueId;
54 
56  bool mHasNewFrame;
57  bool mIsCapturing;
58  int32_t mWidth, mHeight;
59  int32_t mSurfaceChannelOrderCode;
60  int32_t mExposedFrameBytesPerRow;
61  int32_t mExposedFrameHeight;
62  int32_t mExposedFrameWidth;
63 }
64 
65 + (const std::vector<cinder::Capture::DeviceRef>&)getDevices:(BOOL)forceRefresh;
66 
67 - (id)initWithDevice:(const cinder::Capture::DeviceRef)device width:(int)width height:(int)height;
68 - (bool)prepareStartCapture;
69 - (void)startCapture;
70 - (void)stopCapture;
71 - (bool)isCapturing;
72 - (cinder::Surface8u)getCurrentFrame;
73 - (bool)checkNewFrame;
74 - (const cinder::Capture::DeviceRef)getDevice;
75 - (int32_t)getWidth;
76 - (int32_t)getHeight;
77 - (int32_t)getCurrentFrameBytesPerRow;
78 - (int32_t)getCurrentFrameWidth;
79 - (int32_t)getCurrentFrameHeight;
80 
81 @end
bool checkAvailable() const
Returns whether the device is available for use.
Definition: CaptureImplAvFoundation.mm:44
int DeviceIdentifier
Definition: Capture.h:109
CaptureImplAvFoundationDevice(AVCaptureDevice *device)
Definition: CaptureImplAvFoundation.mm:30
bool isFrontFacing() const
Definition: CaptureImplAvFoundation.h:39
typedef void(APIENTRYP GLEEPFNGLBLENDCOLORPROC)(GLclampf red
~CaptureImplAvFoundationDevice()
Definition: CaptureImplAvFoundation.mm:39
Capture::DeviceIdentifier getUniqueId() const
Returns the OS-specific unique identifier.
Definition: CaptureImplAvFoundation.h:38
std::shared_ptr< class Device > DeviceRef
Definition: Device.h:36
void * getNative() const
Definition: CaptureImplAvFoundation.h:40
Definition: CaptureImplAvFoundation.h:31
Definition: Capture.h:113
GLuint id
Definition: GLee.h:2035
bool isConnected() const
Returns whether the device is currently connected.
Definition: CaptureImplAvFoundation.mm:49
std::shared_ptr< Device > DeviceRef
Definition: Capture.h:63