forked from btrask/EasyCapViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathECVCaptureDevice.h
151 lines (123 loc) · 5.04 KB
/
ECVCaptureDevice.h
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
/* Copyright (c) 2009-2010, Ben Trask
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY BEN TRASK ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL BEN TRASK BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
#import <IOKit/usb/IOUSBLib.h>
#import <QTKit/QTKit.h>
// Models
@class ECVVideoStorage;
@class ECVPixelBuffer;
@class ECVVideoFrame;
// Controllers
#import "ECVConfigController.h"
// Other Sources
#if defined(ECV_ENABLE_AUDIO)
#import "ECVAudioDevice.h"
@class ECVAudioPipe;
#endif
@class ECVReadWriteLock;
// External
@class BTUserDefaults;
extern NSString *const ECVDeinterlacingModeKey;
extern NSString *const ECVBrightnessKey;
extern NSString *const ECVContrastKey;
extern NSString *const ECVHueKey;
extern NSString *const ECVSaturationKey;
extern NSString *const ECVCaptureDeviceErrorDomain;
extern NSString *const ECVCaptureDeviceVolumeDidChangeNotification;
#define ECVPauseWhile(obj, code) do {\
ECVCaptureDevice *const __obj = (obj);\
BOOL const __p = [__obj isPlaying];\
if(__p) [__obj setPlaying:NO];\
({code});\
if(__p) [__obj setPlaying:YES];\
} while(NO)
@interface ECVCaptureDevice : NSDocument <ECVCaptureDeviceConfiguring
#if defined(ECV_ENABLE_AUDIO)
, ECVAudioDeviceDelegate
#endif
>
{
@private
BTUserDefaults *_defaults;
#if !defined(ECV_NO_CONTROLLERS)
ECVReadWriteLock *_windowControllersLock;
NSMutableArray *_windowControllers2;
#endif
io_service_t _service;
NSString *_productName;
io_object_t _deviceRemovedNotification;
IOUSBDeviceInterface320 **_deviceInterface;
IOUSBInterfaceInterface300 **_interfaceInterface;
UInt32 _frameTime;
Class _deinterlacingMode;
ECVVideoStorage *_videoStorage;
NSConditionLock *_playLock;
#if defined(ECV_ENABLE_AUDIO)
ECVAudioInput *_audioInput;
ECVAudioOutput *_audioOutput;
ECVAudioPipe *_audioPreviewingPipe;
NSTimeInterval _audioStopTime;
BOOL _muted;
CGFloat _volume;
BOOL _upconvertsFromMono;
#endif
}
+ (NSArray *)deviceClasses;
+ (void)registerDeviceClass:(Class)cls; // Add the device to ECVDevices.plist instead, if possible.
+ (void)unregisterDeviceClass:(Class)cls;
+ (NSDictionary *)deviceDictionary;
+ (NSDictionary *)matchingDictionary;
+ (NSArray *)devicesWithIterator:(io_iterator_t)iterator;
- (id)initWithService:(io_service_t)service error:(out NSError **)outError;
- (void)noteDeviceRemoved;
- (void)workspaceWillSleep:(NSNotification *)aNotif;
@property(assign, getter = isPlaying) BOOL playing;
- (void)togglePlaying;
@property(nonatomic, assign) Class deinterlacingMode;
@property(readonly) BTUserDefaults *defaults;
@property(readonly) ECVVideoStorage *videoStorage;
@property(readonly) NSUInteger simultaneousTransfers;
@property(readonly) NSUInteger microframesPerTransfer;
- (void)startPlaying;
- (void)threadMain_play;
- (void)threaded_nextFieldType:(ECVFieldType)fieldType;
- (void)threaded_drawPixelBuffer:(ECVPixelBuffer *)buffer atPoint:(ECVIntegerPoint)point;
- (BOOL)setAlternateInterface:(u_int8_t)alternateSetting;
- (BOOL)controlRequestWithType:(u_int8_t)type request:(UInt8 const)request value:(UInt16 const)v index:(UInt16 const)i length:(UInt16 const)length data:(inout void *const)data;
- (BOOL)readRequest:(UInt8 const)request value:(UInt16 const)v index:(UInt16 const)i length:(UInt16 const)length data:(out void *const)data;
- (BOOL)writeRequest:(UInt8 const)request value:(UInt16 const)v index:(UInt16 const)i length:(UInt16 const)length data:(in void *const)data;
#if defined(ECV_ENABLE_AUDIO)
@property(readonly) ECVAudioInput *audioInputOfCaptureHardware;
@property(nonatomic, retain) ECVAudioInput *audioInput;
@property(nonatomic, retain) ECVAudioOutput *audioOutput;
- (BOOL)startAudio;
- (void)stopAudio;
#endif
@end
@interface ECVCaptureDevice(ECVAbstract)
@property(readonly) BOOL requiresHighSpeed;
@property(readonly) ECVIntegerSize captureSize;
@property(readonly) UInt8 isochReadingPipe;
@property(readonly) QTTime frameRate;
@property(readonly) OSType pixelFormatType;
- (BOOL)threaded_play;
- (BOOL)threaded_pause;
- (BOOL)threaded_watchdog;
- (void)threaded_readBytes:(UInt8 const *)bytes length:(size_t)length;
@end