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
|
//
// JMXAppDelegate.m
// JMX
//
// Created by Igor Sutton on 8/24/10.
// Copyright 2010 StrayDev.com. All rights reserved.
//
// This file is part of JMX
//
// JMX is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Foobar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JMX. If not, see <http://www.gnu.org/licenses/>.
//
#import "JMXAppDelegate.h"
#import "JMXContext.h"
#import "JMXVideoMixer.h"
#import "JMXQtMovieEntity.h"
#import "JMXOpenGLScreen.h"
#import "JMXImageEntity.h"
#import "JMXQtVideoCaptureEntity.h"
#import "JMXAudioFileEntity.h"
#import "JMXCoreAudioOutput.h"
#import "JMXQtAudioCaptureEntity.h"
#import "JMXAudioMixer.h"
#import "JMXAudioSpectrumAnalyzer.h"
#import "JMXCoreImageFilter.h"
#import "JMXTextEntity.h"
#import "JMXScriptFile.h"
#import "JMXScriptLive.h"
#import "JMXPhidgetEncoderEntity.h"
#import "JMXGlobals.h"
#import "JMXLibraryTableView.h"
#import "JMXHIDInputEntity.h"
#import "CIAlphaBlend.h"
#import "CIAdditiveBlur.h"
@implementation JMXAppDelegate
@synthesize window, batchMode, consoleView, libraryTableView;
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
JMXContext *sharedContext = [JMXContext sharedContext];
[sharedContext registerClass:[JMXVideoMixer class]];
[sharedContext registerClass:[JMXImageEntity class]];
[sharedContext registerClass:[JMXOpenGLScreen class]];
[sharedContext registerClass:[JMXQtVideoCaptureEntity class]];
[sharedContext registerClass:[JMXQtMovieEntity class]];
[sharedContext registerClass:[JMXCoreAudioOutput class]];
[sharedContext registerClass:[JMXQtAudioCaptureEntity class]];
[sharedContext registerClass:[JMXAudioFileEntity class]];
[sharedContext registerClass:[JMXAudioMixer class]];
[sharedContext registerClass:[JMXAudioSpectrumAnalyzer class]];
[sharedContext registerClass:[JMXCoreImageFilter class]];
[sharedContext registerClass:[JMXTextEntity class]];
[sharedContext registerClass:[JMXScriptFile class]];
[sharedContext registerClass:[JMXScriptLive class]];
[sharedContext registerClass:[JMXHIDInputEntity class]];
[CIAlphaBlend class]; // trigger initialize to have the filter registered and available in the videomixer
[CIAdditiveBlur class];
if (CPhidgetEncoder_create != NULL) {
// XXX - exception case for weakly linked Phidget library
// if it's not available at runtime we don't want to register the phidget-related entities
// or the application will crash when the user tries accessing them
[sharedContext registerClass:[JMXPhidgetEncoderEntity class]];
}
INFO("Registered %ul entities", (unsigned int)[[sharedContext registeredClasses] count]);
[libraryTableView reloadData];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
if (argv.count) {
JMXScriptFile *file = [[JMXScriptFile alloc] init];
file.active = YES;
batchMode = YES;
NSString *filePath = [argv objectAtIndex:0];
[argv removeObjectAtIndex:0];
file.arguments = argv;
file.path = filePath;
[window setIsVisible:NO];
}
}
- (void)awakeFromNib
{
[super awakeFromNib];
argv = [[NSMutableArray alloc] initWithCapacity:10];
}
- (id)copyWithZone:(NSZone *)zone
{
// we don't want copies, but we want to use such objects as keys of a dictionary
// so we still need to conform to the 'copying' protocol,
// but since we are to be considered 'immutable' we can adopt what described at the end of :
// http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/Articles/mmImplementCopy.html
return [self retain];
}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
[argv addObject:filename];
if (argv.count == 1)
return YES;
return NO;
}
- (void)updateOutput:(NSString*)msg
{
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n", msg]
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[NSColor whiteColor],
NSForegroundColorAttributeName,
[NSFont fontWithName:@"Courier" size:12],
NSFontAttributeName,
nil]];
[[consoleView textStorage] appendAttributedString:attrString];
[consoleView scrollRangeToVisible:NSMakeRange([[[consoleView textStorage] characters] count], 0)];
[attrString release];
}
- (void)logMessage:(NSString *)message, ...
{
va_list args;
va_start(args, message);
if ([window isVisible]) {
//NSString *msg = [[NSString alloc] initWithCString:buf encoding:NSASCIIStringEncoding];
NSString *msg = [[[NSString alloc] initWithFormat:message arguments:args] autorelease];
// same as above... we really need to avoid updating the textview in a different thread
[self performSelectorOnMainThread:@selector(updateOutput:)
withObject:msg waitUntilDone:NO];
} else if (message) {
NSLogv(message, args);
}
va_end(args);
}
@end
|