Skip to content

Commit

Permalink
Get ECVComponent working again.
Browse files Browse the repository at this point in the history
  • Loading branch information
btrask committed Mar 23, 2013
1 parent 0e52467 commit 31270d2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ECVComponent.m
Expand Up @@ -35,6 +35,7 @@
#import "ECVICM.h"

typedef struct {
BOOL playing;
ECVCaptureDevice *device;
ICMCompressionSessionRef compressionSession;
ICMEncodedFrameRef encodedFrame;
Expand Down Expand Up @@ -232,8 +233,7 @@ static ICMCompressionSessionRef ECVCompressionSessionCreate(ECVCStorage *const s
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
[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 source in [self->device supportedVideoSources]) {
for(id const format in [self->device supportedVideoFormats]) {
[self->inputCombinations addObject:[NSDictionary dictionaryWithObjectsAndKeys:
source, ECVVideoSourceObject,
Expand All @@ -256,7 +256,7 @@ static ICMCompressionSessionRef ECVCompressionSessionCreate(ECVCStorage *const s
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
NSDictionary *const inputCombination = [self->inputCombinations objectAtIndex:videoInput];
NSString *const sourceLabel = [self->device localizedStringForVideoSourceObject:[inputCombination objectForKey:ECVVideoSourceObject]];
NSString *const sourceLabel = [[inputCombination objectForKey:ECVVideoSourceObject] localizedName];
NSString *const formatLabel = [[inputCombination objectForKey:ECVVideoFormatObject] localizedName];
CFStringGetPascalString((CFStringRef)[NSString stringWithFormat:@"%@ - %@", sourceLabel, formatLabel], name, 256, kCFStringEncodingUTF8);
[pool drain];
Expand All @@ -267,7 +267,7 @@ static ICMCompressionSessionRef ECVCompressionSessionCreate(ECVCStorage *const s
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
NSDictionary *const inputCombination = [NSDictionary dictionaryWithObjectsAndKeys:
[self->device videoSourceObject], ECVVideoSourceObject,
[self->device videoSource], ECVVideoSourceObject,
[self->device videoFormat], ECVVideoFormatObject,
nil];
NSUInteger i = [self->inputCombinations indexOfObject:inputCombination];
Expand All @@ -281,7 +281,7 @@ static ICMCompressionSessionRef ECVCompressionSessionCreate(ECVCStorage *const s
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
NSDictionary *const inputCombination = [self->inputCombinations objectAtIndex:input];
[self->device setVideoSourceObject:[inputCombination objectForKey:ECVVideoSourceObject]];
[self->device setVideoSource:[inputCombination objectForKey:ECVVideoSourceObject]];
[self->device setVideoFormat:[inputCombination objectForKey:ECVVideoFormatObject]];
[pool drain];
return noErr;
Expand Down Expand Up @@ -338,7 +338,9 @@ static ICMCompressionSessionRef ECVCompressionSessionCreate(ECVCStorage *const s
{
ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
[self->device setPaused:!state];
if(state) [self->device play];
else [self->device stop];
self->playing = !!state;
ICMCompressionSessionRelease(self->compressionSession);
self->compressionSession = state ? ECVCompressionSessionCreate(self) : NULL;
[pool drain];
Expand All @@ -360,7 +362,7 @@ static ICMCompressionSessionRef ECVCompressionSessionCreate(ECVCStorage *const s
{
// ECV_DEBUG_LOG();
NSAutoreleasePool *const pool = [[NSAutoreleasePool alloc] init];
if([self->device isPaused]) {
if(!self->playing) {
[pool drain];
return badCallOrderErr;
}
Expand Down

0 comments on commit 31270d2

Please sign in to comment.