4 /**********************************************************
5 * First off, some value transformer to easily play with
8 @interface VLCFloat10000FoldTransformer : NSObject
11 @implementation VLCFloat10000FoldTransformer
13 + (Class)transformedValueClass
15 return [NSNumber class];
18 + (BOOL)allowsReverseTransformation
23 - (id)transformedValue:(id)value
25 if( !value ) return nil;
27 if(![value respondsToSelector: @selector(floatValue)])
29 [NSException raise: NSInternalInconsistencyException
30 format: @"Value (%@) does not respond to -floatValue.",
35 return [NSNumber numberWithFloat: [value floatValue]*10000.];
38 - (id)reverseTransformedValue:(id)value
40 if( !value ) return nil;
42 if(![value respondsToSelector: @selector(floatValue)])
44 [NSException raise: NSInternalInconsistencyException
45 format: @"Value (%@) does not respond to -floatValue.",
50 return [NSNumber numberWithFloat: [value floatValue]/10000.];
55 /**********************************************************
56 * @implementation Controller
59 @implementation Controller
62 if(self = [super init])
64 VLCFloat10000FoldTransformer *float100fold;
65 float100fold = [[[VLCFloat10000FoldTransformer alloc] init] autorelease];
66 [NSValueTransformer setValueTransformer:(id)float100fold forName:@"Float10000FoldTransformer"];
68 self.streamSession = nil;
69 selectedStreamOutput = [[NSNumber alloc] initWithInt:0];
74 @synthesize streamSession;
75 @synthesize selectedStreamOutput;
79 [window setShowsResizeIndicator:NO];
80 [NSApp setDelegate: self];
83 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
85 [VLCLibrary sharedLibrary];
93 - (void)setMedia:(VLCMedia *)newMedia
96 media = [newMedia retain];
97 NSRect newFrame = [window frameRectForContentRect:[conversionView frame]];
98 [[window animator] setFrame:NSMakeRect([window frame].origin.x, [window frame].origin.y+NSHeight([window frame])-NSHeight(newFrame), NSWidth(newFrame), NSHeight(newFrame)) display:YES];
99 [[window animator] setContentView:conversionView];
100 [window setMinSize:newFrame.size];
101 [window setMaxSize:NSMakeSize(10000., NSHeight(newFrame))];
102 [window setShowsResizeIndicator:YES];
105 + (NSSet *)keyPathsForValuesAffectingOutputFilePath
107 return [NSSet setWithObjects:@"media.metaDictionary.title", nil];
109 - (NSString *)outputFilePath
111 return [NSString stringWithFormat:[@"~/Movies/iPod Converted/%@.mp4" stringByExpandingTildeInPath],
112 [[self.media metaDictionary] objectForKey:@"title"]];
115 - (IBAction)convert:(id)sender
117 self.streamSession = [VLCStreamSession streamSession];
118 if([selectedStreamOutput intValue] == 0)
120 [self.streamSession setStreamOutput:
121 [VLCStreamOutput ipodStreamOutputWithFilePath:
122 [self outputFilePath]
127 /* This doesn't really is useful for the iPod/iPhone...
128 * But one day we'll figure that out */
129 NSRunAlertPanelRelativeToWindow(@"Warning", @"We can't really stream to the iPod/iPhone for now...\n\nSo we're just streaming using the RTP protocol, and annoucing it via SAP.\n\n(Launch the SAP VLC service discovery module to see it).", @"OK", nil, nil, window);
130 [self.streamSession setStreamOutput:
131 [VLCStreamOutput rtpBroadcastStreamOutput]];
135 NSLog(@"Using %@", self.streamSession.streamOutput );
137 [self.streamSession setMedia:self.media];
138 [self.streamSession startStreaming];
140 [openConvertedFileButton setImage:[[NSWorkspace sharedWorkspace] iconForFile:[self outputFilePath]]];
143 - (IBAction)openConvertedFile:(id)sender
145 [[NSWorkspace sharedWorkspace] openFile:[self outputFilePath]];
147 - (IBAction)openConvertedEnclosingFolder:(id)sender
149 [[NSWorkspace sharedWorkspace] openFile:[[self outputFilePath] stringByDeletingLastPathComponent]];