Permalink
Browse files

List sources and formats together as inputs in ECVComponent. This is …

…lousy for a lot of reasons, but it's the best solution I can think of.
  • Loading branch information...
1 parent 1eab305 commit eb70cfbdb33d9eb16f7f9b430bbd71b51508e37b @btrask committed Jul 14, 2011
Showing with 38 additions and 36 deletions.
  1. +34 −5 ECVComponent.m
  2. +1 −6 ECVComponentConfiguring.h
  3. +3 −25 ECVSTK1160Device.m
View
@@ -36,6 +36,7 @@
typedef struct {
ECVCaptureDevice<ECVComponentConfiguring> *device;
CFMutableDictionaryRef frameByBuffer;
+ NSMutableArray *inputCombinations;
TimeBase timeBase;
} ECVCStorage;
@@ -79,6 +80,9 @@
return noErr;\
}
+static NSString *const ECVVideoSourceObject = @"ECVVideoSourceObjectKey";
+static NSString *const ECVVideoFormatObject = @"ECVVideoFormatObjectKey";
+
static Rect ECVNSRectToRect(NSRect r)
{
return (Rect){NSMinX(r), NSMinY(r), NSMaxX(r), NSMaxY(r)};
@@ -118,6 +122,7 @@ static Rect ECVNSRectToRect(NSRect r)
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
[self->device release];
CFRelease(self->frameByBuffer);
+ [self->inputCombinations release];
free(self);
[pool drain];
return noErr;
@@ -162,39 +167,63 @@ static Rect ECVNSRectToRect(NSRect r)
{
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
- *inputs = [self->device numberOfInputs] - 1;
+ [self->inputCombinations release];
+ self->inputCombinations = [[NSMutableArray alloc] init];
+ for(id const source in [self->device allVideoSourceObjects]) {
+ if(![self->device isValidVideoSourceObject:source]) continue;
+ for(id const format in [self->device allVideoFormatObjects]) {
+ if(![self->device isValidVideoFormatObject:format]) continue;
+ [self->inputCombinations addObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ source, ECVVideoSourceObject,
+ format, ECVVideoFormatObject,
+ nil]];
+ }
+ }
+ *inputs = MIN(SHRT_MAX, [self->inputCombinations count] - 1);
[pool drain];
return noErr;
}
ECV_VDIG_FUNCTION(GetInputFormat, short input, short *format)
{
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
- *format = [self->device inputFormatForInputAtIndex:input];
+ *format = [self->device inputFormatForVideoSourceObject:[[self->inputCombinations objectAtIndex:input] objectForKey:ECVVideoSourceObject]];
[pool drain];
return noErr;
}
ECV_VDIG_FUNCTION(GetInputName, long videoInput, Str255 name)
{
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
- CFStringGetPascalString((CFStringRef)[self->device localizedStringForInputAtIndex:videoInput], name, 256, kCFStringEncodingUTF8);
+ NSDictionary *const inputCombination = [self->inputCombinations objectAtIndex:videoInput];
+ NSString *const sourceLabel = [self->device localizedStringForVideoSourceObject:[inputCombination objectForKey:ECVVideoSourceObject]];
+ NSString *const formatLabel = [self->device localizedStringForVideoFormatObject:[inputCombination objectForKey:ECVVideoFormatObject]];
+ CFStringGetPascalString((CFStringRef)[NSString stringWithFormat:@"%@ - %@", sourceLabel, formatLabel], name, 256, kCFStringEncodingUTF8);
[pool drain];
return noErr;
}
ECV_VDIG_FUNCTION(GetInput, short *input)
{
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
- *input = [self->device inputIndex];
+ NSDictionary *const inputCombination = [NSDictionary dictionaryWithObjectsAndKeys:
+ [self->device videoSourceObject], ECVVideoSourceObject,
+ [self->device videoFormatObject], ECVVideoFormatObject,
+ nil];
+ NSUInteger i = [self->inputCombinations indexOfObject:inputCombination];
+ if(NSNotFound == i) i = 0;
+ *input = MIN(SHRT_MAX, i);
[pool drain];
return noErr;
}
ECV_VDIG_FUNCTION(SetInput, short input)
{
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
- [self->device setInputIndex:input];
+ ECVLog(ECVNotice, @"TESTING TESTING %hd", input);
+ NSDictionary *const inputCombination = [self->inputCombinations objectAtIndex:input];
+ [self->device setVideoSourceObject:[inputCombination objectForKey:ECVVideoSourceObject]];
+ [self->device setVideoFormatObject:[inputCombination objectForKey:ECVVideoFormatObject]];
[pool drain];
return noErr;
}
@@ -22,12 +22,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
@protocol ECVComponentConfiguring
@property(readonly) long inputCapabilityFlags;
-
-@property(readonly) short numberOfInputs;
-@property(nonatomic, assign) short inputIndex;
-- (short)inputFormatForInputAtIndex:(short)i;
-- (NSString *)localizedStringForInputAtIndex:(long)i;
-
+- (short)inputFormatForVideoSourceObject:(id)obj;
@property(nonatomic, assign) short inputStandard;
@end
View
@@ -426,24 +426,9 @@ - (long)inputCapabilityFlags
{
return digiInDoesNTSC | digiInDoesPAL | digiInDoesSECAM | digiInDoesColor | digiInDoesComposite | digiInDoesSVideo;
}
-
-#pragma mark -
-
-- (short)numberOfInputs
-{
- return [[self allVideoSourceObjects] count];
-}
-- (short)inputIndex
-{
- return [[self allVideoSourceObjects] indexOfObject:[self videoSourceObject]];
-}
-- (void)setInputIndex:(short)i
+- (short)inputFormatForVideoSourceObject:(id)obj
{
- [self setVideoSourceObject:[[self allVideoSourceObjects] objectAtIndex:i]];
-}
-- (short)inputFormatForInputAtIndex:(short)i
-{
- switch([[[self allVideoSourceObjects] objectAtIndex:i] unsignedIntegerValue]) {
+ switch([obj unsignedIntegerValue]) {
case ECVSTK1160SVideoInput:
return sVideoIn;
case ECVSTK1160Composite1Input:
@@ -452,17 +437,10 @@ - (short)inputFormatForInputAtIndex:(short)i
case ECVSTK1160Composite4Input:
return compositeIn;
default:
- ECVAssertNotReached(@"Invalid input %hi.", i);
+ ECVAssertNotReached(@"Invalid video source %lu.", (unsigned long)[obj unsignedIntegerValue]);
return 0;
}
}
-- (NSString *)localizedStringForInputAtIndex:(long)i
-{
- return [self localizedStringForVideoSourceObject:[[self allVideoSourceObjects] objectAtIndex:i]];
-}
-
-#pragma mark -
-
- (short)inputStandard
{
switch([self videoFormat]) {

0 comments on commit eb70cfb

Please sign in to comment.