]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/wizard.m
Rename vlc_input_item_* functions to input_Item* for consistency
[vlc] / modules / gui / macosx / wizard.m
index 1080874d47790c214d675f1538c8b6d0b10ec771..0dadbc206f97c34915a8e256f59d2225c8d7168d 100644 (file)
@@ -583,7 +583,7 @@ static VLCWizard *_o_sharedInstance = nil;
                 NSMutableArray * tempArray = [[NSMutableArray alloc] init];
                 while( x != y )
                 {
-                    playlist_item_t *p_item = 
+                    playlist_item_t *p_item =
                         [[o_t2_tbl_plst itemAtRow: 
                             [[o_t2_tbl_plst selectedRowIndexes] 
                             indexGreaterThanOrEqualToIndex: x]] pointerValue];
@@ -591,7 +591,7 @@ static VLCWizard *_o_sharedInstance = nil;
                     if( p_item->i_children <= 0 )
                     {
                         [tempArray addObject: [NSString stringWithUTF8String:
-                        p_item->input.psz_uri]];
+                        p_item->p_input->psz_uri]];
                         stop = NO;
                     }
                     else
@@ -650,7 +650,7 @@ static VLCWizard *_o_sharedInstance = nil;
             /* disable all codecs which don't support MPEG PS, MPEG TS, MPEG 1,
              * OGG, RAW or ASF */
             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
-            [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating"];
+            [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating point"];
             
         } else if ( mode == 1 )
         {
@@ -663,7 +663,7 @@ static VLCWizard *_o_sharedInstance = nil;
             [o_t4_pop_audioCodec removeItemWithTitle:@"FLAC"];
             [o_t4_pop_audioCodec removeItemWithTitle:@"Speex"];
             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
-            [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating"];
+            [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating point"];
             
             [o_t4_pop_videoCodec removeItemWithTitle:@"MPEG-1 Video"];
             [o_t4_pop_videoCodec removeItemWithTitle:@"MPEG-2 Video"];
@@ -673,7 +673,6 @@ static VLCWizard *_o_sharedInstance = nil;
             [o_t4_pop_videoCodec removeItemWithTitle:@"Theora"];
         } else {
             /* RTP/UDP Unicast/Multicast Streaming */
-            
             [o_userSelections setObject: [[NSNumber numberWithInt: mode] \
                 stringValue] forKey:@"stmgMhd"];
             
@@ -682,7 +681,7 @@ static VLCWizard *_o_sharedInstance = nil;
             [o_t4_pop_audioCodec removeItemWithTitle:@"FLAC"];
             [o_t4_pop_audioCodec removeItemWithTitle:@"Speex"];
             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
-            [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating"];
+            [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating point"];
         }
 
         /* store the destination and check whether is it empty */
@@ -1167,7 +1166,7 @@ static VLCWizard *_o_sharedInstance = nil;
                 NSBeginInformationalAlertSheet(_NS("No folder selected"), \
                     _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
                     [NSString stringWithFormat: @"%@\n\n%@", _NS("A directory "
-                    "where to save the files has to be selected"),
+                    "where to save the files has to be selected."),
                     _NS("Enter either a valid path or use the \"Choose...\" " \
                     "button to select a location.")]);
             else
@@ -1176,7 +1175,7 @@ static VLCWizard *_o_sharedInstance = nil;
                     [NSString stringWithFormat: @"%@\n\n%@", _NS("A file " \
                     "where to save the stream has to be selected."),
                     _NS("Enter either a valid path or use the \"Choose\" " \
-                    "button to select a location")]);
+                    "button to select a location.")]);
         } else {
             /* create a string containing the requested suffix for later usage */
             NSString * theEncapFormat = [[o_encapFormats objectAtIndex:
@@ -1195,25 +1194,53 @@ static VLCWizard *_o_sharedInstance = nil;
                 NSMutableString * tempString = [[NSMutableString alloc] init];
                 while( x != y )
                 {
+                    NSString * fileNameToUse;
+                    /* check whether the extension is hidden or not. 
+                     * if not, remove it
+                     * we need the casting to make GCC4 happy */
+                    if( (int)[[[NSFileManager defaultManager] fileAttributesAtPath: \
+                        [[o_userSelections objectForKey:@"pathToStrm"] \
+                        objectAtIndex: x] traverseLink: NO] objectForKey: \
+                        NSFileExtensionHidden] == YES )
+                        fileNameToUse = [NSString stringWithString:
+                            [[NSFileManager defaultManager] displayNameAtPath:
+                            [[o_userSelections objectForKey:@"pathToStrm"]
+                            objectAtIndex: x]]];
+                    else
+                    {
+                        int z = 0;
+                        int count = [[[[NSFileManager defaultManager] \
+                            displayNameAtPath: \
+                            [[o_userSelections objectForKey:@"pathToStrm"] \
+                            objectAtIndex: x]] \
+                            componentsSeparatedByString: @"."] count];
+                        fileNameToUse = @"";
+                        while( z < (count - 1) )
+                        {
+                            fileNameToUse = [fileNameToUse stringByAppendingString:
+                                [[[[NSFileManager defaultManager] \
+                                displayNameAtPath: \
+                                [[o_userSelections objectForKey:@"pathToStrm"] \
+                                objectAtIndex: x]] \
+                                componentsSeparatedByString: @"."] \
+                                objectAtIndex: z]];
+                            z += 1;
+                        }
+                    }
                     tempString = [NSString stringWithFormat: @"%@%@.%@",
                         [o_t7_fld_filePath stringValue],
-                        [[NSFileManager defaultManager] displayNameAtPath:
-                        [[o_userSelections objectForKey:@"pathToStrm"]
-                        objectAtIndex: x]],theEncapFormat];
+                        fileNameToUse, theEncapFormat];
                     if( [[NSFileManager defaultManager] fileExistsAtPath: \
                         tempString] )
                     {
                         /* we don't wanna overwrite existing files, so add an
                          * int to the file-name */
-                        int additionalInt = 0;
+                        int additionalInt = 1;
                         while( additionalInt < 100 )
                         {
-                            tempString = [NSString stringWithFormat:@"%@%@.%i.%@",
+                            tempString = [NSString stringWithFormat:@"%@%@ %i.%@",
                                 [o_t7_fld_filePath stringValue],
-                                [[NSFileManager defaultManager] displayNameAtPath:
-                                [[o_userSelections objectForKey:@"pathToStrm"]
-                                objectAtIndex: x]], additionalInt,
-                                theEncapFormat];
+                                fileNameToUse, additionalInt, theEncapFormat];
                             if(! [[NSFileManager defaultManager] \
                                 fileExistsAtPath: tempString] )
                                 break;
@@ -1250,61 +1277,58 @@ static VLCWizard *_o_sharedInstance = nil;
     {
         intf_thread_t * p_intf = VLCIntf;
 
-        playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_intf,
-                            VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
-        if( p_playlist )
+        playlist_t * p_playlist = pl_Yield( p_intf );
+
+        int x = 0;
+        int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
+        while( x != y )
         {
-            int x = 0;
-            int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
-            while( x != y )
+            /* we need a temp. variable here to work-around a GCC4-bug */
+            NSString *tempString = [NSString stringWithFormat: \
+                @"%@ (%i/%i)", _NS("Streaming/Transcoding Wizard"), \
+                ( x + 1 ), y];
+            input_item_t *p_input = input_ItemNew( p_playlist, \
+                [[[o_userSelections objectForKey:@"pathToStrm"] \
+                objectAtIndex:x] UTF8String], \
+                [tempString UTF8String] );
+            input_ItemAddOption( p_input, [[[o_userSelections \
+                objectForKey:@"opts"] objectAtIndex: x] UTF8String]);
+
+            if(! [[o_userSelections objectForKey:@"partExtractFrom"] \
+                isEqualToString:@""] )
             {
-                /* we need a temp. variable here to work-around a GCC4-bug */
-                NSString *tempString = [NSString stringWithFormat: \
-                    @"%@ (%i/%i)", _NS("Streaming/Transcoding Wizard"), \
-                    ( x + 1 ), y];
-                playlist_item_t *p_item = playlist_ItemNew( p_playlist, \
-                    [[[o_userSelections objectForKey:@"pathToStrm"] \
-                    objectAtIndex:x] UTF8String], \
-                    [tempString UTF8String] );
-                playlist_ItemAddOption( p_item, [[[o_userSelections \
-                    objectForKey:@"opts"] objectAtIndex: x] UTF8String]);
-
-                if(! [[o_userSelections objectForKey:@"partExtractFrom"] \
-                    isEqualToString:@""] )
-                {
-                    playlist_ItemAddOption( p_item, [[NSString \
-                        stringWithFormat: @"start-time=%@", [o_userSelections \
-                        objectForKey: @"partExtractFrom"]] UTF8String] );
-                }
+                input_ItemAddOption( p_input, [[NSString \
+                    stringWithFormat: @"start-time=%@", [o_userSelections \
+                    objectForKey: @"partExtractFrom"]] UTF8String] );
+            }
 
-                if(! [[o_userSelections objectForKey:@"partExtractTo"] \
-                    isEqualToString:@""] )
-                {
-                    playlist_ItemAddOption( p_item, [[NSString \
-                        stringWithFormat: @"stop-time=%@", [o_userSelections \
-                        objectForKey: @"partExtractTo"]] UTF8String] );
-                }
+            if(! [[o_userSelections objectForKey:@"partExtractTo"] \
+                isEqualToString:@""] )
+            {
+                input_ItemAddOption( p_input, [[NSString \
+                    stringWithFormat: @"stop-time=%@", [o_userSelections \
+                    objectForKey: @"partExtractTo"]] UTF8String] );
+            }
 
-                playlist_ItemAddOption( p_item, [[NSString stringWithFormat: \
-                    @"ttl=%@", [o_userSelections objectForKey:@"ttl"]] \
-                    UTF8String] );
+            input_ItemAddOption( p_input, [[NSString stringWithFormat: \
+                @"ttl=%@", [o_userSelections objectForKey:@"ttl"]] \
+                UTF8String] );
 
-                playlist_AddItem( p_playlist, p_item, PLAYLIST_STOP, PLAYLIST_END );
-                
-                if( x == 0 )
-                    /* play the first item and add the others afterwards */ 
-                    playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
+            playlist_PlaylistAddInput( p_playlist, p_input, PLAYLIST_STOP, PLAYLIST_END );
 
-                x += 1;
+            if( x == 0 )
+            {
+                /* play the first item and add the others afterwards */
+                playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
+                playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL,
+                          p_item );
             }
 
-            playlist_ViewUpdate( p_playlist, VIEW_CATEGORY );
-
-            vlc_object_release(p_playlist);
-        } else {
-            msg_Err( p_intf, "unable to find playlist" );
+            x += 1;
         }
 
+        vlc_object_release( p_playlist );
+
         /* close the window, since we are done */
         [o_wizard_window close];
     }
@@ -1419,8 +1443,15 @@ static VLCWizard *_o_sharedInstance = nil;
         [o_t8_fld_destination setStringValue: @"-"];
         [o_t8_fld_ttl setStringValue: @"-"];
         [o_t8_fld_sap setStringValue: @"-"];
-        [o_t8_fld_saveFileTo setStringValue: [o_userSelections objectForKey: \
-            @"trnscdFilePath"]];
+        /* do only show the destination of the first item and add a counter, if needed */
+        if( [[o_userSelections objectForKey: @"trnscdFilePath"] count] > 1 )
+            [o_t8_fld_saveFileTo setStringValue: \
+                [NSString stringWithFormat: @"%@ (+%i)", \
+                [[o_userSelections objectForKey: @"trnscdFilePath"] objectAtIndex:0], \
+                ([[o_userSelections objectForKey: @"trnscdFilePath"] count] - 1)]];
+        else
+            [o_t8_fld_saveFileTo setStringValue: \
+                [[o_userSelections objectForKey: @"trnscdFilePath"] objectAtIndex:0]];
     }
     [o_t8_fld_encapFormat setStringValue: [[o_encapFormats objectAtIndex: \
         [[o_userSelections objectForKey:@"encapFormat"] intValue]] objectAtIndex:1]];