forked from mitzpettel/Vidi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBDVGrabber.h
executable file
·189 lines (161 loc) · 4.9 KB
/
DBDVGrabber.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//
// DBDVGrabber.h
// Vidi
//
// Created by Mitz Pettel on Wed Jan 22 2003.
// Copyright (c) 2003, 2004, 2006, 2007 Mitz Pettel. All rights reserved.
//
#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#import <IOKit/DV/DVFamily.h>
struct DBDVFrameInfo {
ScheduledSoundHeaderPtr sndHead;
void *frameBuffer;
unsigned timesPainted;
BOOL needsPlaying;
BOOL needsWriting;
QElemPtr freeQElem;
QElemPtr playQElem;
QElemPtr writeQElem;
};
typedef struct DBDVFrameInfo DBDVFrameInfo;
typedef DBDVFrameInfo *DBDVFrameInfoPtr;
struct DBDVGrabberSharedMemory {
void *baseAddress;
DBDVFrameInfo *currentlyPlayingFrame;
unsigned numUnpainted;
unsigned char buffer[0];
};
typedef struct DBDVGrabberSharedMemory DBDVGrabberSharedMemory;
struct DBFrameQElem {
struct QElem *qLink;
short qType;
DBDVFrameInfoPtr frameInfo;
};
typedef struct DBFrameQElem DBFrameQElem;
typedef DBFrameQElem *DBFrameQElemPtr;
typedef unsigned long DBTVFrequency;
typedef enum _DBDVInputSource {
DBTunerInput,
DBCompositeInput,
DBSVideoInput,
DBRadioInput,
DBUnknownInput
} DBDVInputSource;
typedef enum _DBDVColorSystem {
DBNTSCSystem = 0,
DBPALBGSystem = 1,
DBSECAMSystem = 2
} DBDVColorSystem;
typedef enum _DBDVFormat {
DBNTSCFormat = 0,
DBPALFormat = 1,
DBUnknownFormat
} DBDVFormat;
@protocol DBDVGrabber
- (DBDVFormat)DVFormat;
- (DBDVColorSystem)colorSystem;
- (void)setBrightness:(UInt8)b contrast:(SInt8)c saturation:(SInt8)s hue:(SInt8)h;
- (void)setVolume:(int)volume;
- (int)volume;
- (BOOL)hasTuner;
- (BOOL)hasRadioTuner;
- (unsigned)firmwareVersion;
- (NSString *)tunerDisplayName;
@end
@interface DBDVGrabber : NSObject <DBDVGrabber> {
NSFileHandle *_fileHandle;
NSFileHandle *_nextFileHandle;
ComponentInstance _controlComponent;
NSDictionary *_tunerInfo;
unsigned _firmwareVersion;
// _supposedCurrentFrequency is used for the frequency-switching logic.
// We have no way of querying the tuner for its real frequency, do we?
DBTVFrequency _supposedCurrentFrequency;
UInt8 _brightness;
SInt8 _contrast;
SInt8 _saturation;
SInt8 _hue;
IONotificationPortRef _notificationPort;
int _frameSize;
DVNotificationID _DVNotificationID;
DVDeviceID _deviceID;
DVDeviceRefNum _deviceRefNum;
BOOL _deviceHasAVC;
SndChannelPtr _soundChannel;
unsigned long _bytesWrittenToFile;
unsigned long _chunkSize;
int _volume;
SInt16 _DVFormat;
NSLock *_readerLock;
NSLock *_writerLock;
NSLock *_fileLock;
id _delegate;
int _sharedMemoryFile;
int _framesToDrop;
SoundConverter _soundConverter;
void *_soundOutputBuffer;
unsigned long _soundFramesWrittenToFile;
BOOL _audioOnly;
UnsignedFixed _audioSampleRate;
int _audioSampleSize;
int _audioChannels;
OSType _audioCompression;
NSData *_audioCompressionParams;
io_object_t _powerNotifier;
@public
BOOL _isLogging;
DBDVGrabberSharedMemory *_sharedMemory;
BOOL _audioEnabled;
BOOL _soundStarted;
BOOL _isGrabbing;
BOOL _isRecording;
DBFrameQElemPtr _currentlyPlaying;
int _numFullBuffers;
int _numToBePlayed;
QHdr _freeForWriting;
QHdr _toBePlayed;
QHdr _toBeWritten;
BOOL _errorSentToMainThread;
io_connect_t _root_power_port;
}
- (BOOL)getTunerInfo;
- (BOOL)deviceAdded:(DVDeviceID)deviceID;
- (void)deviceRemoved;
- (void)setFile:(NSFileHandle *)file;
- (void)setChunkSize:(unsigned long)size;
- (void)setAudioRecording:(BOOL)flag sampleRate:(UnsignedFixed)rate sampleSize:(int)size channels:(int)chans compression:(OSType)codec parameters:(NSData *)params;
- (void)setDelegate:(id)anObject;
- (id)delegate;
- (void)getBrightness:(UInt8 *)b contrast:(SInt8 *)c saturation:(SInt8 *)s hue:(SInt8 *)h;
- (OSErr)doAVCCommand:(UInt8 *)cmd length:(int)len;
- (OSErr)doAVCCommand:(UInt8 *)cmd length:(int)len response:(UInt8 *)rsp size:(int *)bufflen;
- (void)doPictureSettingsCommand;
- (void)setAudioSamplingRate;
- (BOOL)startGrabbing;
- (void)stopGrabbing;
- (BOOL)isGrabbing;
- (BOOL)hasDevice;
- (BOOL)canStartGrabbing;
- (void)setInputSource:(DBDVInputSource)source;
- (DBDVInputSource)inputSource;
- (void)setFrequency:(DBTVFrequency)freq;
- (void)setRadioFrequency:(DBTVFrequency)freq;
- (void)startRecording;
- (void)stopRecording;
- (BOOL)isRecording;
- (void)dropNextFrames:(int)frames;
- (BOOL)isAudioEnabled;
- (void)setAudioEnabled:(BOOL)flag;
- (unsigned)bufferCount;
@end
@interface NSObject (DBDVGrabberDelegate)
- (void)grabberDidAcquireDevice:(DBDVGrabber *)grabber;
- (void)grabberDidLoseDevice:(DBDVGrabber *)grabber;
- (void)grabberDidStartRecording:(DBDVGrabber *)grabber;
- (void)grabberDidStopRecording:(DBDVGrabber *)grabber;
- (void)grabberDidStartGrabbing:(DBDVGrabber *)grabber;
- (void)grabberDidStopGrabbing:(DBDVGrabber *)grabber;
- (NSFileHandle *)grabberNeedsNextFileHandle;
- (void)grabberHadErrorWriting:(DBDVGrabber *)grabber;
@end