]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/ConvertAndSave.m
macosx: add custom numberformatter to goto time field to only allow digits and :
[vlc] / modules / gui / macosx / ConvertAndSave.m
index a5c85dcc8690b79a3583420cc8a92d984186891b..3356ae446e8f4c09aa9d00e56a27bcd904c98590 100644 (file)
@@ -44,7 +44,7 @@
 #define ASF 12
 /* 13-15 are present, but not set */
 
-@interface VLCConvertAndSave ()
+@interface VLCConvertAndSave (Internal)
 - (void)updateDropView;
 - (void)updateOKButton;
 - (void)resetCustomizationSheetBasedOnProfile:(NSString *)profileString;
@@ -53,6 +53,7 @@
 - (NSString *)composedOptions;
 - (void)updateCurrentProfile;
 - (void)storeProfilesOnDisk;
+- (void)recreateProfilePopup;
 @end
 
 @implementation VLCConvertAndSave
@@ -110,6 +111,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
     [defaults registerDefaults:appDefaults];
     [defaultProfiles release];
+    [defaultProfileNames release];
 }
 
 + (VLCConvertAndSave *)sharedInstance
@@ -144,8 +146,8 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (void)awakeFromNib
 {
-    [_window setTitle: _NS("Convert & Save")];
-    [_ok_btn setTitle: _NS("Save")];
+    [_window setTitle: _NS("Convert & Stream")];
+    [_ok_btn setTitle: _NS("Go!")];
     [_drop_lbl setStringValue: _NS("Drop media here")];
     [_drop_btn setTitle: _NS("Open media...")];
     [_profile_lbl setStringValue: _NS("Choose Profile")];
@@ -182,18 +184,10 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [_customize_aud_codec_lbl setStringValue: _NS("Codec")];
     [_customize_aud_bitrate_lbl setStringValue: _NS("Bitrate")];
     [_customize_aud_channels_lbl setStringValue: _NS("Channels")];
-    [_customize_aud_samplerate_lbl setStringValue: _NS("Sample Rate")];
+    [_customize_aud_samplerate_lbl setStringValue: _NS("Samplerate")];
     [_customize_subs_ckb setTitle: _NS("Subtitles")];
     [_customize_subs_overlay_ckb setTitle: _NS("Overlay subtitles on the video")];
-    [_addProfile_title_lbl setStringValue:_NS("Save as new profile")];
-    [_addProfile_subtitle_lbl setStringValue:_NS("Enter a name for the new profile:")];
-    [_addProfile_cancel_btn setTitle:_NS("Cancel")];
-    [_addProfile_ok_btn setTitle:_NS("Save")];
-    [_deleteProfile_title_lbl setStringValue:_NS("Remove a profile")];
-    [_deleteProfile_subtitle_lbl setStringValue:_NS("Select the profile you would like to remove:")];
-    [_deleteProfile_cancel_btn setTitle:_NS("Cancel")];
-    [_deleteProfile_ok_btn setTitle:_NS("Remove")];
-    [_stream_ok_btn setTitle:_NS("Close")];
+    [_stream_ok_btn setTitle:_NS("OK")];
     [_stream_destination_lbl setStringValue:_NS("Stream Destination")];
     [_stream_announcement_lbl setStringValue:_NS("Stream Announcement")];
     [_stream_type_lbl setStringValue:_NS("Type")];
@@ -203,13 +197,12 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [_stream_ttl_stepper setEnabled:NO];
     [_stream_port_lbl setStringValue:_NS("Port")];
     [_stream_sap_ckb setStringValue:_NS("SAP Announcement")];
-    [_stream_http_ckb setStringValue:_NS("HTTP Announcement")];
-    [_stream_rtsp_ckb setStringValue:_NS("RTSP Announcement")];
-    [_stream_sdp_ckb setStringValue:_NS("Export SDP as file")];
+    [[_stream_sdp_matrix cellWithTag:0] setTitle:_NS("None")];
+    [[_stream_sdp_matrix cellWithTag:1] setTitle:_NS("HTTP Announcement")];
+    [[_stream_sdp_matrix cellWithTag:2] setTitle:_NS("RTSP Announcement")];
+    [[_stream_sdp_matrix cellWithTag:3] setTitle:_NS("Export SDP as file")];
     [_stream_sap_ckb setState:NSOffState];
-    [_stream_http_ckb setState:NSOffState];
-    [_stream_rtsp_ckb setState:NSOffState];
-    [_stream_sdp_ckb setState:NSOffState];
+    [_stream_sdp_matrix setEnabled:NO];
 
     /* there is no way to hide single cells, so replace the existing ones with empty cells.. */
     id blankCell = [[[NSCell alloc] init] autorelease];
@@ -224,18 +217,12 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [self setProfileNames: [defaults arrayForKey:@"CASProfileNames"]];
     [self recreateProfilePopup];
 
-    _videoCodecs = [[NSArray alloc] initWithObjects:
-                    [NSArray arrayWithObjects:@"MPEG-1", @"MPEG-2", @"MPEG-4", @"DIVX 1", @"DIVX 2", @"DIVX 3", @"H.263", @"H.264", @"VP8", @"WMV1", @"WMV2", @"M-JPEG", @"Theora", @"Dirac", nil],
-                    [NSArray arrayWithObjects:@"mpgv", @"mp2v", @"mp4v", @"DIV1", @"DIV2", @"DIV3", @"H263", @"h264", @"VP80", @"WMV1", @"WMV2", @"MJPG", @"theo", @"drac", nil],
-                    nil];
-    _audioCodecs = [[NSArray alloc] initWithObjects:
-                    [NSArray arrayWithObjects:@"MPEG Audio", @"MP3", @"MPEG 4 Audio (AAC)", @"A52/AC-3", @"Vorbis", @"Flac", @"Speex", @"WAV", @"WMA2", nil],
-                    [NSArray arrayWithObjects:@"mpga", @"mp3", @"mp4a", @"a52", @"vorb", @"flac", @"spx", @"s16l", @"wma2", nil],
-                    nil];
-    _subsCodecs = [[NSArray alloc] initWithObjects:
-                   [NSArray arrayWithObjects:@"DVB subtitle", @"T.140", nil],
-                   [NSArray arrayWithObjects:@"dvbs", @"t140", nil],
-                   nil];
+    _videoCodecs = @[@[@"MPEG-1", @"MPEG-2", @"MPEG-4", @"DIVX 1", @"DIVX 2", @"DIVX 3", @"H.263", @"H.264", @"VP8", @"WMV1", @"WMV2", @"M-JPEG", @"Theora", @"Dirac"],
+  @[@"mpgv", @"mp2v", @"mp4v", @"DIV1", @"DIV2", @"DIV3", @"H263", @"h264", @"VP80", @"WMV1", @"WMV2", @"MJPG", @"theo", @"drac"]];
+    _audioCodecs = @[@[@"MPEG Audio", @"MP3", @"MPEG 4 Audio (AAC)", @"A52/AC-3", @"Vorbis", @"Flac", @"Speex", @"WAV", @"WMA2"],
+                    @[@"mpga", @"mp3", @"mp4a", @"a52", @"vorb", @"flac", @"spx", @"s16l", @"wma2"]];
+    _subsCodecs = @[@[@"DVB subtitle", @"T.140"],
+                   @[@"dvbs", @"t140"]];
 
     [_customize_vid_codec_pop removeAllItems];
     [_customize_vid_scale_pop removeAllItems];
@@ -243,9 +230,9 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [_customize_aud_samplerate_pop removeAllItems];
     [_customize_subs_pop removeAllItems];
 
-    [_customize_vid_codec_pop addItemsWithTitles:[_videoCodecs objectAtIndex:0]];
-    [_customize_aud_codec_pop addItemsWithTitles:[_audioCodecs objectAtIndex:0]];
-    [_customize_subs_pop addItemsWithTitles:[_subsCodecs objectAtIndex:0]];
+    [_customize_vid_codec_pop addItemsWithTitles:_videoCodecs[0]];
+    [_customize_aud_codec_pop addItemsWithTitles:_audioCodecs[0]];
+    [_customize_subs_pop addItemsWithTitles:_subsCodecs[0]];
 
     [_customize_aud_samplerate_pop addItemWithTitle:@"8000"];
     [_customize_aud_samplerate_pop addItemWithTitle:@"11025"];
@@ -264,7 +251,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
     [_ok_btn setEnabled: NO];
 
-    [self resetCustomizationSheetBasedOnProfile:[self.profileValueList objectAtIndex:0]];
+    [self resetCustomizationSheetBasedOnProfile:self.profileValueList[0]];
 }
 
 # pragma mark -
@@ -280,6 +267,19 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (IBAction)finalizePanel:(id)sender
 {
+    if (b_streaming) {
+        if ([[[_stream_type_pop selectedItem] title] isEqualToString:@"HTTP"]) {
+            NSString *muxformat = self.currentProfile[0];
+            if ([muxformat isEqualToString:@"wav"] || [muxformat isEqualToString:@"mov"] || [muxformat isEqualToString:@"mp4"] || [muxformat isEqualToString:@"mkv"]) {
+                NSBeginInformationalAlertSheet(_NS("Invalid container format for HTTP streaming"), _NS("OK"), @"", @"", _window,
+                                               nil, nil, nil, nil,
+                                               _NS("Media encapsulated as %@ cannot be streamed through the HTTP protocol for technical reasons."),
+                                               [[self currentEncapsulationFormatAsFileExtension:YES] uppercaseString]);
+                return;
+            }
+        }
+    }
+
     playlist_t * p_playlist = pl_Get(VLCIntf);
 
     input_item_t *p_input = input_item_New([_MRL UTF8String], [[_dropin_media_lbl stringValue] UTF8String]);
@@ -287,23 +287,25 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
         return;
 
     input_item_AddOption(p_input, [[self composedOptions] UTF8String], VLC_INPUT_OPTION_TRUSTED);
+    if (b_streaming)
+        input_item_AddOption(p_input, [[NSString stringWithFormat:@"ttl=%@", [_stream_ttl_fld stringValue]] UTF8String], VLC_INPUT_OPTION_TRUSTED);
 
     int returnValue;
-    returnValue = playlist_AddInput( p_playlist, p_input, PLAYLIST_STOP, PLAYLIST_END, true, pl_Unlocked );
+    returnValue = playlist_AddInput(p_playlist, p_input, PLAYLIST_STOP, PLAYLIST_END, true, pl_Unlocked);
 
     if (returnValue == VLC_SUCCESS) {
         /* let's "play" */
         PL_LOCK;
-        playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
-        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, NULL,
-                         p_item );
+        playlist_item_t *p_item = playlist_ItemGetByInput(p_playlist, p_input);
+        playlist_Control(p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, NULL,
+                         p_item);
         PL_UNLOCK;
     }
     else
-        msg_Err( VLCIntf, "CAS: playlist add input failed :(");
+        msg_Err(VLCIntf, "CAS: playlist add input failed :(");
 
     /* we're done with this input */
-    vlc_gc_decref( p_input );
+    vlc_gc_decref(p_input);
 
     [_window performClose:sender];
 }
@@ -318,7 +320,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [openPanel beginSheetModalForWindow:_window completionHandler:^(NSInteger returnCode) {
         if (returnCode == NSOKButton)
         {
-            [self setMRL: [NSString stringWithUTF8String:vlc_path2uri([[[openPanel URL] path] UTF8String], NULL)]];
+            [self setMRL: @(vlc_path2uri([[[openPanel URL] path] UTF8String], NULL))];
             [self updateOKButton];
             [self updateDropView];
         }
@@ -329,7 +331,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 {
     NSUInteger index = [_profile_pop indexOfSelectedItem];
     if (index < ([self.profileValueList count] - 1))
-        [self resetCustomizationSheetBasedOnProfile:[self.profileValueList objectAtIndex:index]];
+        [self resetCustomizationSheetBasedOnProfile:self.profileValueList[index]];
 }
 
 - (IBAction)customizeProfile:(id)sender
@@ -348,77 +350,29 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (IBAction)newProfileAction:(id)sender
 {
-    if (sender == _customize_newProfile_btn) {
-        [_addProfile_name_fld setStringValue:@""];
-        [NSApp beginSheet:_addProfile_panel modalForWindow:_customize_panel modalDelegate:self didEndSelector:NULL contextInfo:nil];
-    } else {
-        [_addProfile_panel orderOut:sender];
-        [NSApp endSheet: _addProfile_panel];
-
-        if (sender == _addProfile_ok_btn && [[_addProfile_name_fld stringValue] length] > 0) {
-            /* prepare current data */
-            [self updateCurrentProfile];
-
-            /* add profile to arrays */
-            NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
-            [workArray addObject:[_addProfile_name_fld stringValue]];
-            [self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
-            [workArray release];
-            workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
-            [workArray addObject:[[[NSArray alloc] initWithArray:self.currentProfile] autorelease]];
-            [self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
-            [workArray release];
-
-            /* update UI */
-            [self recreateProfilePopup];
-            [_profile_pop selectItemWithTitle:[_addProfile_name_fld stringValue]];
-
-            /* update internals */
-            [self switchProfile:sender];
-            [self storeProfilesOnDisk];
-        }
-    }
+    /* show panel */
+    VLCEnterTextPanel * panel = [VLCEnterTextPanel sharedInstance];
+    [panel setTitle: _NS("Save as new profile")];
+    [panel setSubTitle: _NS("Enter a name for the new profile:")];
+    [panel setCancelButtonLabel: _NS("Cancel")];
+    [panel setOKButtonLabel: _NS("Save")];
+    [panel setTarget:self];
+
+    [panel runModalForWindow:_customize_panel];
 }
 
 - (IBAction)deleteProfileAction:(id)sender
 {
-    if (sender == _deleteProfile_cancel_btn) {
-        /* close panel */
-        [_deleteProfile_panel orderOut:sender];
-        [NSApp endSheet: _deleteProfile_panel];
-    } else if (sender == _deleteProfile_ok_btn) {
-        /* close panel */
-        [_deleteProfile_panel orderOut:sender];
-        [NSApp endSheet: _deleteProfile_panel];
-
-        /* remove requested profile from the arrays */
-        NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
-        [workArray removeObjectAtIndex:[_deleteProfile_pop indexOfSelectedItem]];
-        [self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
-        [workArray release];
-        workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
-        [workArray removeObjectAtIndex:[_deleteProfile_pop indexOfSelectedItem]];
-        [self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
-        [workArray release];
-
-        /* update UI */
-        [_profile_pop removeAllItems];
-        [_profile_pop addItemsWithTitles:self.profileNames];
-        [_profile_pop addItemWithTitle:_NS("Custom")];
-        [[_profile_pop menu] addItem:[NSMenuItem separatorItem]];
-        [_profile_pop addItemWithTitle:_NS("Organize Profiles")];
-        [[_profile_pop lastItem] setTarget: self];
-        [[_profile_pop lastItem] setAction: @selector(deleteProfileAction:)];
-
-        /* update internals */
-        [self switchProfile:sender];
-        [self storeProfilesOnDisk];
-    } else {
-        /* show panel */
-        [_deleteProfile_pop removeAllItems];
-        [_deleteProfile_pop addItemsWithTitles:self.profileNames];
-        [NSApp beginSheet:_deleteProfile_panel modalForWindow:_window modalDelegate:self didEndSelector:NULL contextInfo:nil];
-    }
+    /* show panel */
+    VLCSelectItemInPopupPanel * panel = [VLCSelectItemInPopupPanel sharedInstance];
+    [panel setTitle:_NS("Remove a profile")];
+    [panel setSubTitle:_NS("Select the profile you would like to remove:")];
+    [panel setOKButtonLabel:_NS("Remove")];
+    [panel setCancelButtonLabel:_NS("Cancel")];
+    [panel setPopupButtonContent:self.profileNames];
+    [panel setTarget:self];
+
+    [panel runModalForWindow:_window];
 }
 
 - (IBAction)iWantAFile:(id)sender
@@ -470,7 +424,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [saveFilePanel setCanSelectHiddenExtension: YES];
     [saveFilePanel setCanCreateDirectories: YES];
     if ([[_customize_encap_matrix selectedCell] tag] != RAW) // there is no clever guess for this
-        [saveFilePanel setAllowedFileTypes:[NSArray arrayWithObject:[self currentEncapsulationFormatAsFileExtension:YES]]];
+        [saveFilePanel setAllowedFileTypes:@[[self currentEncapsulationFormatAsFileExtension:YES]]];
     [saveFilePanel beginSheetModalForWindow:_window completionHandler:^(NSInteger returnCode) {
         if (returnCode == NSOKButton) {
             [self setOutputDestination:[[saveFilePanel URL] path]];
@@ -493,42 +447,41 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (IBAction)closeStreamPanel:(id)sender
 {
-    NSMutableString * labelContent = [[NSMutableString alloc] initWithFormat:@"%@ @ %@:%@", [_stream_type_pop titleOfSelectedItem], [_stream_address_fld stringValue], [_stream_port_fld stringValue]];
+    /* provide a summary of the user selections */
+    NSMutableString * labelContent = [[NSMutableString alloc] initWithFormat:_NS("%@ stream to %@:%@"), [_stream_type_pop titleOfSelectedItem], [_stream_address_fld stringValue], [_stream_port_fld stringValue]];
 
-    if ([_stream_type_pop indexOfSelectedItem] > 1) {
-        [labelContent appendFormat:@" TTL:%@", [_stream_ttl_fld stringValue]];
-        if ([_stream_sap_ckb state] || [_stream_rtsp_ckb state] || [_stream_http_ckb state] || [_stream_sdp_ckb state])
-            [labelContent appendFormat:@" — %@:\"%@\" (", _NS("Channel"), [_stream_channel_fld stringValue]];
+    if ([_stream_type_pop indexOfSelectedItem] > 1)
+        [labelContent appendFormat:@" (\"%@\")", [_stream_channel_fld stringValue]];
 
-        BOOL b_gotSomething;
-        if (_stream_sap_ckb) {
-            [labelContent appendString:@"SAP"];
-            b_gotSomething = YES;
-        }
-        if (_stream_rtsp_ckb) {
-            if (b_gotSomething)
-                [labelContent appendString:@", "];
-            [labelContent appendString:@"RTSP"];
-            b_gotSomething = YES;
-        }
-        if (_stream_http_ckb) {
-            if (b_gotSomething)
-                [labelContent appendString:@", "];
-            [labelContent appendString:@"HTTP"];
-            b_gotSomething = YES;
-        }
-        if ([_stream_sdp_ckb state]) {
-            if (b_gotSomething)
-                [labelContent appendString:@", "];
-            [labelContent appendString:@"SDP"];
-        }
-
-        if ([_stream_sap_ckb state] || [_stream_rtsp_ckb state] || [_stream_http_ckb state] || [_stream_sdp_ckb state])
-            [labelContent appendString:@")"];
-    }
     [_destination_stream_lbl setStringValue:labelContent];
     [labelContent release];
 
+    /* catch obvious errors */
+    if (![[_stream_address_fld stringValue] length] > 0) {
+        NSBeginInformationalAlertSheet(_NS("No Address given"),
+                                       _NS("OK"), @"", @"", _stream_panel, nil, nil, nil, nil,
+                                       @"%@", _NS("In order to stream, a valid destination address is required."));
+        return;
+    }
+
+    if ([_stream_sap_ckb state] && ![[_stream_channel_fld stringValue] length] > 0) {
+        NSBeginInformationalAlertSheet(_NS("No Channel Name given"),
+                                       _NS("OK"), @"", @"", _stream_panel, nil, nil, nil, nil,
+                                       @"%@", _NS("SAP stream announcement is enabled. However, no channel name is provided."));
+        return;
+    }
+
+    if ([_stream_sdp_matrix isEnabled] && [_stream_sdp_matrix selectedCell] != [_stream_sdp_matrix cellWithTag:0] && ![[_stream_sdp_fld stringValue] length] > 0) {
+        NSBeginInformationalAlertSheet(_NS("No SDP URL given"),
+                                       _NS("OK"), @"", @"", _stream_panel, nil, nil, nil, nil,
+                                       @"%@", _NS("A SDP export is requested, but no URL is provided."));
+        return;
+    }
+
+    /* store destination for further reference and update UI */
+    [self setOutputDestination: [_stream_address_fld stringValue]];
+    [self updateOKButton];
+
     [_stream_panel orderOut:sender];
     [NSApp endSheet: _stream_panel];
 }
@@ -540,62 +493,72 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
         [_stream_ttl_fld setEnabled:NO];
         [_stream_ttl_stepper setEnabled:NO];
         [_stream_sap_ckb setEnabled:NO];
-        [_stream_rtsp_ckb setEnabled:NO];
-        [_stream_http_ckb setEnabled:NO];
-        [_stream_sdp_ckb setEnabled:NO];
+        [_stream_sdp_matrix setEnabled:NO];
     } else if (index == 2) { // RTP
         [_stream_ttl_fld setEnabled:YES];
         [_stream_ttl_stepper setEnabled:YES];
         [_stream_sap_ckb setEnabled:YES];
-        [_stream_rtsp_ckb setEnabled:YES];
-        [_stream_http_ckb setEnabled:YES];
-        [_stream_sdp_ckb setEnabled:YES];
-        [_stream_channel_fld setEnabled:YES];
-        [_stream_sdp_fld setEnabled:[_stream_sdp_ckb state]];
+        [_stream_sdp_matrix setEnabled:YES];
     } else { // UDP
         [_stream_ttl_fld setEnabled:YES];
         [_stream_ttl_stepper setEnabled:YES];
         [_stream_sap_ckb setEnabled:YES];
-        [_stream_rtsp_ckb setEnabled:NO];
-        [_stream_http_ckb setEnabled:NO];
-        [_stream_sdp_ckb setEnabled:NO];
-        [_stream_channel_fld setEnabled:YES];
+        [_stream_sdp_matrix setEnabled:NO];
     }
+    [self streamAnnouncementToggle:sender];
 }
 
 - (IBAction)streamAnnouncementToggle:(id)sender
 {
-    [_stream_sdp_fld setEnabled:[_stream_sdp_ckb state]];
+    [_stream_channel_fld setEnabled:[_stream_sap_ckb state] && [_stream_sap_ckb isEnabled]];
+    [_stream_sdp_fld setEnabled:[_stream_sdp_matrix isEnabled] && ([_stream_sdp_matrix selectedCell] != [_stream_sdp_matrix cellWithTag:0])];
+
+    if ([[_stream_sdp_matrix selectedCell] tag] == 3)
+        [_stream_sdp_browsefile_btn setEnabled: YES];
+    else
+        [_stream_sdp_browsefile_btn setEnabled: NO];
+}
+
+- (IBAction)sdpFileLocationSelector:(id)sender
+{
+    NSSavePanel * saveFilePanel = [NSSavePanel savePanel];
+    [saveFilePanel setCanSelectHiddenExtension: YES];
+    [saveFilePanel setCanCreateDirectories: YES];
+    [saveFilePanel setAllowedFileTypes:@[@"sdp"]];
+    [saveFilePanel beginSheetModalForWindow:_stream_panel completionHandler:^(NSInteger returnCode) {
+        if (returnCode == NSOKButton)
+            [_stream_sdp_fld setStringValue:[[saveFilePanel URL] path]];
+    }];
 }
 
 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
 {
     NSPasteboard *paste = [sender draggingPasteboard];
-    NSArray *types = [NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil];
+    NSArray *types = @[NSFilenamesPboardType, @"VLCPlaylistItemPboardType"];
     NSString *desired_type = [paste availableTypeFromArray: types];
     NSData *carried_data = [paste dataForType: desired_type];
 
-    if( carried_data ) {
-        if( [desired_type isEqualToString:NSFilenamesPboardType] ) {
+    if (carried_data) {
+        if ([desired_type isEqualToString:NSFilenamesPboardType]) {
             NSArray *values = [[paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
 
             if ([values count] > 0) {
-                [self setMRL: [NSString stringWithUTF8String:vlc_path2uri([[values objectAtIndex:0] UTF8String], NULL)]];
+                [self setMRL: @(vlc_path2uri([values[0] UTF8String], NULL))];
                 [self updateOKButton];
                 [self updateDropView];
                 return YES;
             }
-        } else if( [desired_type isEqualToString:@"VLCPlaylistItemPboardType"] ) {
+        } else if ([desired_type isEqualToString:@"VLCPlaylistItemPboardType"]) {
             NSArray * array = [[[VLCMain sharedInstance] playlist] draggedItems];
             NSUInteger count = [array count];
             if (count > 0) {
-                playlist_t * p_playlist = pl_Get( VLCIntf );
+                playlist_t * p_playlist = pl_Get(VLCIntf);
                 playlist_item_t * p_item = NULL;
 
                 PL_LOCK;
                 /* let's look for the first proper input item */
                 for (NSUInteger x = 0; x < count; x++) {
-                    p_item = [[array objectAtIndex:x] pointerValue];
+                    p_item = [array[x] pointerValue];
                     if (p_item) {
                         if (p_item->p_input) {
                             if (p_item->p_input->psz_uri != nil) {
@@ -617,6 +580,62 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     return NO;
 }
 
+- (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text
+{
+    if (value == NSOKButton) {
+        if ([text length] > 0) {
+            /* prepare current data */
+            [self updateCurrentProfile];
+
+            /* add profile to arrays */
+            NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
+            [workArray addObject:text];
+            [self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
+            [workArray release];
+            workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
+            [workArray addObject:[[[NSArray alloc] initWithArray:self.currentProfile] autorelease]];
+            [self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
+            [workArray release];
+
+            /* update UI */
+            [self recreateProfilePopup];
+            [_profile_pop selectItemWithTitle:text];
+
+            /* update internals */
+            [self switchProfile:self];
+            [self storeProfilesOnDisk];
+        }
+    }
+}
+
+- (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item
+{
+    if (value == NSOKButton) {
+        /* remove requested profile from the arrays */
+        NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
+        [workArray removeObjectAtIndex:item];
+        [self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
+        [workArray release];
+        workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
+        [workArray removeObjectAtIndex:item];
+        [self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
+        [workArray release];
+
+        /* update UI */
+        [_profile_pop removeAllItems];
+        [_profile_pop addItemsWithTitles:self.profileNames];
+        [_profile_pop addItemWithTitle:_NS("Custom")];
+        [[_profile_pop menu] addItem:[NSMenuItem separatorItem]];
+        [_profile_pop addItemWithTitle:_NS("Organize Profiles...")];
+        [[_profile_pop lastItem] setTarget: self];
+        [[_profile_pop lastItem] setAction: @selector(deleteProfileAction:)];
+
+        /* update internals */
+        [self switchProfile:self];
+        [self storeProfilesOnDisk];
+    }
+}
+
 # pragma mark -
 # pragma mark Private Functionality
 - (void)updateDropView
@@ -665,57 +684,57 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
         return;
     }
 
-    [self selectCellByEncapsulationFormat:[components objectAtIndex:0]];
-    [_customize_vid_ckb setState:[[components objectAtIndex:1] intValue]];
-    [_customize_aud_ckb setState:[[components objectAtIndex:2] intValue]];
-    [_customize_subs_ckb setState:[[components objectAtIndex:3] intValue]];
-    [_customize_vid_bitrate_fld setStringValue:[components objectAtIndex:5]];
-    [_customize_vid_scale_pop selectItemWithTitle:[components objectAtIndex:6]];
-    [_customize_vid_framerate_fld setStringValue:[components objectAtIndex:7]];
-    [_customize_vid_width_fld setStringValue:[components objectAtIndex:8]];
-    [_customize_vid_height_fld setStringValue:[components objectAtIndex:9]];
-    [_customize_aud_bitrate_fld setStringValue:[components objectAtIndex:11]];
-    [_customize_aud_channels_fld setStringValue:[components objectAtIndex:12]];
-    [_customize_aud_samplerate_pop selectItemWithTitle:[components objectAtIndex:13]];
-    [_customize_subs_overlay_ckb setState:[[components objectAtIndex:15] intValue]];
+    [self selectCellByEncapsulationFormat:components[0]];
+    [_customize_vid_ckb setState:[components[1] intValue]];
+    [_customize_aud_ckb setState:[components[2] intValue]];
+    [_customize_subs_ckb setState:[components[3] intValue]];
+    [_customize_vid_bitrate_fld setStringValue:components[5]];
+    [_customize_vid_scale_pop selectItemWithTitle:components[6]];
+    [_customize_vid_framerate_fld setStringValue:components[7]];
+    [_customize_vid_width_fld setStringValue:components[8]];
+    [_customize_vid_height_fld setStringValue:components[9]];
+    [_customize_aud_bitrate_fld setStringValue:components[11]];
+    [_customize_aud_channels_fld setStringValue:components[12]];
+    [_customize_aud_samplerate_pop selectItemWithTitle:components[13]];
+    [_customize_subs_overlay_ckb setState:[components[15] intValue]];
 
     /* since there is no proper lookup mechanism in arrays, we need to implement a string specific one ourselves */
-    NSArray * tempArray = [_videoCodecs objectAtIndex:1];
+    NSArray * tempArray = _videoCodecs[1];
     NSUInteger count = [tempArray count];
-    NSString * searchString = [components objectAtIndex:4];
+    NSString * searchString = components[4];
     if ([searchString isEqualToString:@"none"] || [searchString isEqualToString:@"0"]) {
         [_customize_vid_codec_pop selectItemAtIndex:-1];
     } else {
         for (NSUInteger x = 0; x < count; x++) {
-            if ([[tempArray objectAtIndex:x] isEqualToString: searchString]) {
+            if ([tempArray[x] isEqualToString: searchString]) {
                 [_customize_vid_codec_pop selectItemAtIndex:x];
                 break;
             }
         }
     }
 
-    tempArray = [_audioCodecs objectAtIndex:1];
+    tempArray = _audioCodecs[1];
     count = [tempArray count];
-    searchString = [components objectAtIndex:10];
+    searchString = components[10];
     if ([searchString isEqualToString:@"none"] || [searchString isEqualToString:@"0"]) {
         [_customize_aud_codec_pop selectItemAtIndex:-1];
     } else {
         for (NSUInteger x = 0; x < count; x++) {
-            if ([[tempArray objectAtIndex:x] isEqualToString: searchString]) {
+            if ([tempArray[x] isEqualToString: searchString]) {
                 [_customize_aud_codec_pop selectItemAtIndex:x];
                 break;
             }
         }
     }
 
-    tempArray = [_subsCodecs objectAtIndex:1];
+    tempArray = _subsCodecs[1];
     count = [tempArray count];
-    searchString = [components objectAtIndex:14];
+    searchString = components[14];
     if ([searchString isEqualToString:@"none"] || [searchString isEqualToString:@"0"]) {
         [_customize_subs_pop selectItemAtIndex:-1];
     } else {
         for (NSUInteger x = 0; x < count; x++) {
-            if ([[tempArray objectAtIndex:x] isEqualToString: searchString]) {
+            if ([tempArray[x] isEqualToString: searchString]) {
                 [_customize_subs_pop selectItemAtIndex:x];
                 break;
             }
@@ -729,35 +748,35 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 {
     if ([format isEqualToString:@"ts"])
         [_customize_encap_matrix selectCellWithTag:MPEGTS];
-    else if([format isEqualToString:@"webm"])
+    else if ([format isEqualToString:@"webm"])
         [_customize_encap_matrix selectCellWithTag:WEBM];
-    else if([format isEqualToString:@"ogg"])
+    else if ([format isEqualToString:@"ogg"])
         [_customize_encap_matrix selectCellWithTag:OGG];
-    else if([format isEqualToString:@"ogm"])
+    else if ([format isEqualToString:@"ogm"])
         [_customize_encap_matrix selectCellWithTag:OGG];
-    else if([format isEqualToString:@"mp4"])
+    else if ([format isEqualToString:@"mp4"])
         [_customize_encap_matrix selectCellWithTag:MP4];
-    else if([format isEqualToString:@"mov"])
+    else if ([format isEqualToString:@"mov"])
         [_customize_encap_matrix selectCellWithTag:MP4];
-    else if([format isEqualToString:@"ps"])
+    else if ([format isEqualToString:@"ps"])
         [_customize_encap_matrix selectCellWithTag:MPEGPS];
-    else if([format isEqualToString:@"mpjpeg"])
+    else if ([format isEqualToString:@"mpjpeg"])
         [_customize_encap_matrix selectCellWithTag:MJPEG];
-    else if([format isEqualToString:@"wav"])
+    else if ([format isEqualToString:@"wav"])
         [_customize_encap_matrix selectCellWithTag:WAV];
-    else if([format isEqualToString:@"flv"])
+    else if ([format isEqualToString:@"flv"])
         [_customize_encap_matrix selectCellWithTag:FLV];
-    else if([format isEqualToString:@"mpeg1"])
+    else if ([format isEqualToString:@"mpeg1"])
         [_customize_encap_matrix selectCellWithTag:MPEG1];
-    else if([format isEqualToString:@"mkv"])
+    else if ([format isEqualToString:@"mkv"])
         [_customize_encap_matrix selectCellWithTag:MKV];
-    else if([format isEqualToString:@"raw"])
+    else if ([format isEqualToString:@"raw"])
         [_customize_encap_matrix selectCellWithTag:RAW];
-    else if([format isEqualToString:@"avi"])
+    else if ([format isEqualToString:@"avi"])
         [_customize_encap_matrix selectCellWithTag:AVI];
-    else if([format isEqualToString:@"asf"])
+    else if ([format isEqualToString:@"asf"])
         [_customize_encap_matrix selectCellWithTag:ASF];
-    else if([format isEqualToString:@"wmv"])
+    else if ([format isEqualToString:@"wmv"])
         [_customize_encap_matrix selectCellWithTag:ASF];
     else
         msg_Err(VLCIntf, "CAS: unknown encap format requested for customization");
@@ -834,48 +853,81 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 - (NSString *)composedOptions
 {
     NSMutableString *composedOptions = [[NSMutableString alloc] initWithString:@":sout=#transcode{"];
-    if ([[self.currentProfile objectAtIndex:1] intValue]) {
+    if ([self.currentProfile[1] intValue]) {
         // video is enabled
-        [composedOptions appendFormat:@"vcodec=%@", [self.currentProfile objectAtIndex:4]];
-        if (![[self.currentProfile objectAtIndex:4] isEqualToString:@"none"]) {
-            if ([[self.currentProfile objectAtIndex:5] intValue] > 0) // bitrate
-                [composedOptions appendFormat:@",vb=%@", [self.currentProfile objectAtIndex:5]];
-            if ([[self.currentProfile objectAtIndex:6] floatValue] > 0.) // scale
-                [composedOptions appendFormat:@",scale=%@", [self.currentProfile objectAtIndex:6]];
-            if ([[self.currentProfile objectAtIndex:7] floatValue] > 0.) // fps
-                [composedOptions appendFormat:@",fps=%@", [self.currentProfile objectAtIndex:7]];
-            if ([[self.currentProfile objectAtIndex:8] intValue] > 0) // width
-                [composedOptions appendFormat:@",width=%@", [self.currentProfile objectAtIndex:8]];
-            if ([[self.currentProfile objectAtIndex:9] intValue] > 0) // height
-                [composedOptions appendFormat:@",height=%@", [self.currentProfile objectAtIndex:9]];
+        [composedOptions appendFormat:@"vcodec=%@", self.currentProfile[4]];
+        if (![self.currentProfile[4] isEqualToString:@"none"]) {
+            if ([self.currentProfile[5] intValue] > 0) // bitrate
+                [composedOptions appendFormat:@",vb=%@", self.currentProfile[5]];
+            if ([self.currentProfile[6] floatValue] > 0.) // scale
+                [composedOptions appendFormat:@",scale=%@", self.currentProfile[6]];
+            if ([self.currentProfile[7] floatValue] > 0.) // fps
+                [composedOptions appendFormat:@",fps=%@", self.currentProfile[7]];
+            if ([self.currentProfile[8] intValue] > 0) // width
+                [composedOptions appendFormat:@",width=%@", self.currentProfile[8]];
+            if ([self.currentProfile[9] intValue] > 0) // height
+                [composedOptions appendFormat:@",height=%@", self.currentProfile[9]];
         }
     }
-    if ([[self.currentProfile objectAtIndex:2] intValue]) {
+    if ([self.currentProfile[2] intValue]) {
         // audio is enabled
 
         // add another comma in case video is enabled
-        if ([[self.currentProfile objectAtIndex:1] intValue])
+        if ([self.currentProfile[1] intValue])
             [composedOptions appendString:@","];
 
-        [composedOptions appendFormat:@"acodec=%@", [self.currentProfile objectAtIndex:10]];
-        if (![[self.currentProfile objectAtIndex:10] isEqualToString:@"none"]) {
-            [composedOptions appendFormat:@",ab=%@", [self.currentProfile objectAtIndex:11]]; // bitrate
-            [composedOptions appendFormat:@",channels=%@", [self.currentProfile objectAtIndex:12]]; // channel number
-            [composedOptions appendFormat:@",samplerate=%@", [self.currentProfile objectAtIndex:13]]; // sample rate
+        [composedOptions appendFormat:@"acodec=%@", self.currentProfile[10]];
+        if (![self.currentProfile[10] isEqualToString:@"none"]) {
+            [composedOptions appendFormat:@",ab=%@", self.currentProfile[11]]; // bitrate
+            [composedOptions appendFormat:@",channels=%@", self.currentProfile[12]]; // channel number
+            [composedOptions appendFormat:@",samplerate=%@", self.currentProfile[13]]; // sample rate
         }
     }
-    if ([self.currentProfile objectAtIndex:3]) {
+    if (self.currentProfile[3]) {
         // subtitles enabled
-        [composedOptions appendFormat:@",scodec=%@", [self.currentProfile objectAtIndex:14]];
-        if ([[self.currentProfile objectAtIndex:15] intValue])
+        [composedOptions appendFormat:@",scodec=%@", self.currentProfile[14]];
+        if ([self.currentProfile[15] intValue])
             [composedOptions appendFormat:@",soverlay"];
     }
 
-    // add muxer
-    [composedOptions appendFormat:@"}:standard{mux=%@", [self.currentProfile objectAtIndex:0]];
+    if (!b_streaming) {
+        /* file transcoding */
+        // add muxer
+        [composedOptions appendFormat:@"}:standard{mux=%@", self.currentProfile[0]];
 
-    // add output destination (file only at this point)
-    [composedOptions appendFormat:@",dst=%@,access=file}", _outputDestination];
+        // add output destination
+        [composedOptions appendFormat:@",access=file{no-overwrite},dst=%@}", _outputDestination];
+    } else {
+        /* streaming */
+        if ([[[_stream_type_pop selectedItem] title] isEqualToString:@"RTP"])
+            [composedOptions appendFormat:@":rtp{mux=ts,dst=%@,port=%@", _outputDestination, [_stream_port_fld stringValue]];
+        else if ([[[_stream_type_pop selectedItem] title] isEqualToString:@"UDP"])
+            [composedOptions appendFormat:@":standard{mux=ts,dst=%@,port=%@,access=udp", _outputDestination, [_stream_port_fld stringValue]];
+        else if ([[[_stream_type_pop selectedItem] title] isEqualToString:@"MMSH"])
+            [composedOptions appendFormat:@":standard{mux=asfh,dst=%@,port=%@,access=mmsh", _outputDestination, [_stream_port_fld stringValue]];
+        else
+            [composedOptions appendFormat:@":standard{mux=%@,dst=%@,port=%@,access=http", self.currentProfile[0], [_stream_port_fld stringValue], _outputDestination];
+
+        if ([_stream_sap_ckb state])
+            [composedOptions appendFormat:@",sap,name=\"%@\"", [_stream_channel_fld stringValue]];
+        if ([_stream_sdp_matrix selectedCell] != [_stream_sdp_matrix cellWithTag:0]) {
+            NSInteger tag = [[_stream_sdp_matrix selectedCell] tag];
+            switch (tag) {
+                case 1:
+                    [composedOptions appendFormat:@",sdp=\"http://%@\"", [_stream_sdp_fld stringValue]];
+                    break;
+                case 2:
+                    [composedOptions appendFormat:@",sdp=\"rtsp://%@\"", [_stream_sdp_fld stringValue]];
+                    break;
+                case 3:
+                    [composedOptions appendFormat:@",sdp=\"file://%s\"", vlc_path2uri([[_stream_sdp_fld stringValue] UTF8String], NULL)];
+                default:
+                    break;
+            }
+        }
+
+        [composedOptions appendString:@"} :sout-keep"];
+    }
 
     NSString * returnString = [NSString stringWithString:composedOptions];
     [composedOptions release];
@@ -894,7 +946,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [self.currentProfile addObject: [NSString stringWithFormat:@"%li", [_customize_subs_ckb state]]];
     i = [_customize_vid_codec_pop indexOfSelectedItem];
     if (i >= 0)
-        [self.currentProfile addObject: [[_videoCodecs objectAtIndex:1] objectAtIndex:i]];
+        [self.currentProfile addObject: _videoCodecs[1][i]];
     else
         [self.currentProfile addObject: @"none"];
     [self.currentProfile addObject: [NSString stringWithFormat:@"%i", [_customize_vid_bitrate_fld intValue]]];
@@ -904,7 +956,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [self.currentProfile addObject: [NSString stringWithFormat:@"%i", [_customize_vid_height_fld intValue]]];
     i = [_customize_aud_codec_pop indexOfSelectedItem];
     if (i >= 0)
-        [self.currentProfile addObject: [[_audioCodecs objectAtIndex:1] objectAtIndex:i]];
+        [self.currentProfile addObject: _audioCodecs[1][i]];
     else
         [self.currentProfile addObject: @"none"];
     [self.currentProfile addObject: [NSString stringWithFormat:@"%i", [_customize_aud_bitrate_fld intValue]]];
@@ -912,7 +964,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [self.currentProfile addObject: [[_customize_aud_samplerate_pop selectedItem] title]];
     i = [_customize_subs_pop indexOfSelectedItem];
     if (i >= 0)
-        [self.currentProfile addObject: [[_subsCodecs objectAtIndex:1] objectAtIndex:i]];
+        [self.currentProfile addObject: _subsCodecs[1][i]];
     else
         [self.currentProfile addObject: @"none"];
     [self.currentProfile addObject: [NSString stringWithFormat:@"%li", [_customize_subs_overlay_ckb state]]];
@@ -946,7 +998,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (void)awakeFromNib
 {
-    [self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
+    [self registerForDraggedTypes:@[NSFilenamesPboardType, @"VLCPlaylistItemPboardType"]];
 }
 
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
@@ -954,8 +1006,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     b_activeDragAndDrop = YES;
     [self setNeedsDisplay:YES];
 
-    if (OSX_SNOW_LEOPARD || OSX_LION)
-        [[NSCursor dragCopyCursor] set];
+    [[NSCursor dragCopyCursor] set];
 
     if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
         return NSDragOperationGeneric;
@@ -1013,7 +1064,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (void)awakeFromNib
 {
-    [self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
+    [self registerForDraggedTypes:@[NSFilenamesPboardType, @"VLCPlaylistItemPboardType"]];
 }
 
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
@@ -1042,7 +1093,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (void)awakeFromNib
 {
-    [self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
+    [self registerForDraggedTypes:@[NSFilenamesPboardType, @"VLCPlaylistItemPboardType"]];
 }
 
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender