Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaptureImplDirectShow.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 #pragma once
24 
25 #include "cinder/Cinder.h"
26 #include "cinder/Capture.h"
27 #include "cinder/Surface.h"
28 #include "msw/videoInput/videoInput.h"
29 
30 namespace cinder {
31 
33  public:
34  class Device;
35 
36  CaptureImplDirectShow( int32_t width, int32_t height, const Capture::DeviceRef device );
37  CaptureImplDirectShow( int32_t width, int32_t height );
39 
40  void start();
41  void stop();
42 
43  bool isCapturing();
44  bool checkNewFrame() const;
45 
46  int32_t getWidth() const { return mWidth; }
47  int32_t getHeight() const { return mHeight; }
48 
49  Surface8u getSurface() const;
50 
51  const Capture::DeviceRef getDevice() const { return mDevice; }
52 
53  static const std::vector<Capture::DeviceRef>& getDevices( bool forceRefresh = false );
54 
55  class Device : public Capture::Device {
56  public:
57  bool checkAvailable() const;
58  bool isConnected() const;
60 
61  Device( const std::string &name, int uniqueId ) : Capture::Device(), mUniqueId( uniqueId ) { mName = name; }
62  protected:
63  int mUniqueId;
64  };
65  protected:
66  void init( int32_t width, int32_t height, const Capture::Device &device );
67 
68  int mDeviceID;
69  // this maintains a reference to the mgr so that we don't destroy it before
70  // the last Capture is destroyed
71  std::shared_ptr<class CaptureMgr> mMgrPtr;
73  std::shared_ptr<class SurfaceCache> mSurfaceCache;
74 
75  int32_t mWidth, mHeight;
78 
79  static bool sDevicesEnumerated;
80  static std::vector<Capture::DeviceRef> sDevices;
81 };
82 
83 } //namespace
84 
void stop()
Definition: CaptureImplDirectShow.cpp:178
Definition: CaptureImplDirectShow.h:32
Definition: Capture.h:61
int32_t getWidth() const
Definition: CaptureImplDirectShow.h:46
int mUniqueId
Definition: CaptureImplDirectShow.h:63
int DeviceIdentifier
Definition: Capture.h:109
const Capture::DeviceRef getDevice() const
Definition: CaptureImplDirectShow.h:51
GLsizei const GLchar ** string
Definition: GLee.h:2427
GLenum GLsizei width
Definition: GLee.h:969
void start()
Definition: CaptureImplDirectShow.cpp:165
Definition: CaptureImplDirectShow.h:55
bool mIsCapturing
Definition: CaptureImplDirectShow.h:72
Device(const std::string &name, int uniqueId)
Definition: CaptureImplDirectShow.h:61
~CaptureImplDirectShow()
Definition: CaptureImplDirectShow.cpp:160
bool isConnected() const
Returns whether the device is currently connected.
Definition: CaptureImplDirectShow.cpp:122
static bool sDevicesEnumerated
Definition: CaptureImplDirectShow.h:79
static std::vector< Capture::DeviceRef > sDevices
Definition: CaptureImplDirectShow.h:80
std::string mName
Definition: Capture.h:134
static const std::vector< Capture::DeviceRef > & getDevices(bool forceRefresh=false)
Definition: CaptureImplDirectShow.cpp:127
GLenum GLsizei GLsizei height
Definition: GLee.h:1029
Capture::DeviceRef mDevice
Definition: CaptureImplDirectShow.h:77
int32_t mHeight
Definition: CaptureImplDirectShow.h:75
std::shared_ptr< class CaptureMgr > mMgrPtr
Definition: CaptureImplDirectShow.h:71
Capture::DeviceIdentifier getUniqueId() const
Returns the OS-specific unique identifier.
Definition: CaptureImplDirectShow.h:59
bool checkAvailable() const
Returns whether the device is available for use.
Definition: CaptureImplDirectShow.cpp:117
Surface8u getSurface() const
Definition: CaptureImplDirectShow.cpp:196
int32_t mWidth
Definition: CaptureImplDirectShow.h:75
GLuint const GLchar * name
Definition: GLee.h:2259
Surface8u mCurrentFrame
Definition: CaptureImplDirectShow.h:76
bool checkNewFrame() const
Definition: CaptureImplDirectShow.cpp:191
Definition: Capture.h:113
void init(int32_t width, int32_t height, const Capture::Device &device)
std::shared_ptr< class SurfaceCache > mSurfaceCache
Definition: CaptureImplDirectShow.h:73
int mDeviceID
Definition: CaptureImplDirectShow.h:68
CaptureImplDirectShow(int32_t width, int32_t height, const Capture::DeviceRef device)
Definition: CaptureImplDirectShow.cpp:143
std::shared_ptr< Device > DeviceRef
Definition: Capture.h:63
bool isCapturing()
Definition: CaptureImplDirectShow.cpp:186
int32_t getHeight() const
Definition: CaptureImplDirectShow.h:47