-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLocalCameraController.m
More file actions
95 lines (80 loc) · 2.02 KB
/
Copy pathLocalCameraController.m
File metadata and controls
95 lines (80 loc) · 2.02 KB
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
//
// LocalCameraController.m
// Gawker
//
// Created by Phil Piwonka on 10/9/05.
// Copyright 2005 Phil Piwonka. All rights reserved.
//
#import "LocalCameraController.h"
#import "CameraImageSource.h"
#import "ImageServer.h"
#import "LapseMovie.h"
@interface LocalCameraController (PrivateMethods)
- (void)recordTimerFired:(NSTimer *)timer;
@end
@implementation LocalCameraController
- (id)initWithDelegate:(id)newDelegate cameraName:(NSString *)name
{
if (self = [super initWithDelegate:newDelegate]) {
//
// Create Image Source
imageSource = [[CameraImageSource alloc] initWithCameraName:name];
[self registerForNotifications];
}
return self;
}
- (id)initWithDelegate:(id)newDelegate
{
return [self initWithDelegate:newDelegate
cameraName:[NSString stringWithString:@"Camera"]];
}
- (id)init
{
return [self initWithDelegate:nil
cameraName:[NSString stringWithString:@"Camera"]];
}
- (void)dealloc
{
NSLog(@"LocalCameraController -dealloc");
[super dealloc];
}
- (void)captureFrameAtInterval:(double)interval
{
if (recordTimer) {
[recordTimer invalidate];
[recordTimer release];
recordTimer = nil;
}
recordTimer = [[NSTimer scheduledTimerWithTimeInterval:interval
target:self
selector:@selector(recordTimerFired:)
userInfo:nil
repeats:YES] retain];
}
- (NSDate *)nextFrameTime
{
NSDate *fireDate = nil;
if (isRecording) {
fireDate = [recordTimer fireDate];
}
return fireDate;
}
- (BOOL)stopRecording
{
if (isRecording) {
//
// Release and invalidate timer.
//
[recordTimer invalidate];
[recordTimer release];
recordTimer = nil;
}
return [super stopRecording];
}
@end
@implementation LocalCameraController (PrivateMethods)
- (void)recordTimerFired:(NSTimer *)timer
{
[self recordCurrentImage];
}
@end