Skip to content

Commit

Permalink
Implemented audio and subtitle selection
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@62 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
titer committed Apr 17, 2006
1 parent b30c3a7 commit c1dbdec
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ if $(OS) = MACOSX
macosx/English.lproj/InfoPlist.strings
macosx/English.lproj/MainMenu.nib/classes.nib
macosx/English.lproj/MainMenu.nib/info.nib
macosx/English.lproj/MainMenu.nib/keyedobjects.nib ;
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
macosx/ExpressController.h macosx/ExpressController.m
macosx/English.lproj/Express.nib/classes.nib
macosx/English.lproj/Express.nib/info.nib
macosx/English.lproj/Express.nib/keyedobjects.nib ;

OSXApp HandBrake.app : $(OSX_SRC) $(HB_LIBS) ;

# Package
Expand Down
1 change: 1 addition & 0 deletions libhb/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ struct hb_audio_s
{
int id;
char lang[1024];
char lang_simple[1024];
int codec;
int rate;
int bitrate;
Expand Down
2 changes: 2 additions & 0 deletions libhb/dvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
lang_for_code( vts->vtsi_mat->vts_audio_attr[i].lang_code ),
audio->codec == HB_ACODEC_AC3 ? "AC3" : ( audio->codec ==
HB_ACODEC_MPGA ? "MPEG" : "LPCM" ) );
snprintf( audio->lang_simple, sizeof( audio->lang_simple ), "%s",
lang_for_code( vts->vtsi_mat->vts_audio_attr[i].lang_code ) );

hb_log( "scan: id=%x, lang=%s", audio->id,
audio->lang );
Expand Down
2 changes: 2 additions & 0 deletions macosx/English.lproj/Express.nib/classes.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion macosx/English.lproj/Express.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified macosx/English.lproj/Express.nib/keyedobjects.nib
Binary file not shown.
2 changes: 2 additions & 0 deletions macosx/ExpressController.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
IBOutlet NSPopUpButton * fConvertFolderPopUp;
IBOutlet NSPopUpButton * fConvertFormatPopUp;
IBOutlet NSPopUpButton * fConvertAspectPopUp;
IBOutlet NSPopUpButton * fConvertAudioPopUp;
IBOutlet NSPopUpButton * fConvertSubtitlePopUp;
IBOutlet NSTextField * fConvertInfoString;
IBOutlet NSProgressIndicator * fConvertIndicator;
NSMutableArray * fConvertCheckArray;
Expand Down
67 changes: 64 additions & 3 deletions macosx/ExpressController.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ - (void) openGo: (id) sender

- (void) convertGo: (id) sender
{
int i;
int i, j;

for( i = 0; i < hb_list_count( fList ); i++ )
{
Expand Down Expand Up @@ -241,7 +241,47 @@ - (void) convertGo: (id) sender
hb_set_size( job, aspect, pixels );

job->vquality = -1.0;
job->file = strdup( [[NSString stringWithFormat:

const char * lang;

/* Audio selection */
hb_audio_t * audio;
lang = [[fConvertAudioPopUp titleOfSelectedItem] UTF8String];
job->audios[0] = -1;
for( j = 0; j < hb_list_count( title->list_audio ); j++ )
{
/* Choose the first track that matches the language */
audio = hb_list_item( title->list_audio, j );
if( !strcmp( lang, audio->lang_simple ) )
{
job->audios[0] = j;
break;
}
}
if( job->audios[0] == -1 )
{
/* If the language isn't available in this title, choose
the first track */
job->audios[0] = 0;
}
job->audios[1] = -1;

/* Subtitle selection */
hb_subtitle_t * subtitle;
lang = [[fConvertSubtitlePopUp titleOfSelectedItem] UTF8String];
job->subtitle = -1;
for( j = 0; j < hb_list_count( title->list_subtitle ); j++ )
{
/* Choose the first track that matches the language */
subtitle = hb_list_item( title->list_subtitle, j );
if( !strcmp( lang, subtitle->lang ) )
{
job->subtitle = j;
break;
}
}

job->file = strdup( [[NSString stringWithFormat:
@"%@/%p - Title %d.mp4", fConvertFolderString, self,
title->index] UTF8String] );
hb_add( fHandle, job );
Expand Down Expand Up @@ -355,16 +395,37 @@ - (void) openTimer: (NSTimer *) timer

- (void) convertShow
{
int i;
int i, j;

fConvertCheckArray = [[NSMutableArray alloc] initWithCapacity:
hb_list_count( fList )];
[fConvertAudioPopUp removeAllItems];
[fConvertSubtitlePopUp removeAllItems];
[fConvertSubtitlePopUp addItemWithTitle: @"None"];
for( i = 0; i < hb_list_count( fList ); i++ )
{
/* Default is to convert titles longer than 30 minutes. */
hb_title_t * title = hb_list_item( fList, i );
[fConvertCheckArray addObject: [NSNumber numberWithBool:
( 60 * title->hours + title->minutes > 30 )]];

/* Update audio popup */
hb_audio_t * audio;
for( j = 0; j < hb_list_count( title->list_audio ); j++ )
{
audio = hb_list_item( title->list_audio, j );
[fConvertAudioPopUp addItemWithTitle:
[NSString stringWithUTF8String: audio->lang_simple]];
}

/* Update subtitle popup */
hb_subtitle_t * subtitle;
for( j = 0; j < hb_list_count( title->list_subtitle ); j++ )
{
subtitle = hb_list_item( title->list_subtitle, j );
[fConvertSubtitlePopUp addItemWithTitle:
[NSString stringWithUTF8String: subtitle->lang]];
}
}
[fConvertTableView reloadData];

Expand Down

0 comments on commit c1dbdec

Please sign in to comment.