diff options
author | dynaflash <[email protected]> | 2009-07-16 18:36:08 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2009-07-16 18:36:08 +0000 |
commit | 8bb7d25bba2dc06e8541f07583897c4030a1bc3c (patch) | |
tree | ea0073de04a728eaed1cb5f2fc43b4abe172601a /macosx/Controller.mm | |
parent | a13d7753343d914e2e25ac32ca756b3025b48de2 (diff) |
MacGui: srt subtitle support initial implementation
- Allows adding an external srt sub file as a subtitle source.
-- Adds fields for srt language, char code and offset in ms.
- Known issues: adding the srt file to the sources list also adds a new subtitle track for that source, however to "set" it you have to click on it.
- srt subtitles do not seem to work in preview even if set to default.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2699 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.mm')
-rw-r--r-- | macosx/Controller.mm | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 712622aaa..f7e79c484 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -2924,6 +2924,24 @@ bool one_burned = FALSE; subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle); + /* if we are getting the subtitles from an external srt file */ + if ([[tempObject objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"]) + { + hb_subtitle_config_t sub_config; + + sub_config.offset = [[tempObject objectForKey:@"subtitleTrackSrtOffset"] intValue]; + + /* we need to srncpy file path and char code */ + strncpy(sub_config.src_filename, [[tempObject objectForKey:@"subtitleSourceSrtFilePath"] UTF8String], 128); + strncpy(sub_config.src_codeset, [[tempObject objectForKey:@"subtitleTrackSrtCharCode"] UTF8String], 40); + + sub_config.force = 0; + sub_config.dest = hb_subtitle_config_s::PASSTHRUSUB; + sub_config.default_track = def; + + hb_srt_add( job, &sub_config, [[tempObject objectForKey:@"subtitleTrackSrtLanguageIso3"] UTF8String]); + } + if (subt != NULL) { [self writeToActivityLog: "Setting Subtitle: %s", subt]; @@ -3440,6 +3458,27 @@ bool one_burned = FALSE; subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle); + /* if we are getting the subtitles from an external srt file */ + if ([[tempObject objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"]) + { + hb_subtitle_config_t sub_config; + + sub_config.offset = [[tempObject objectForKey:@"subtitleTrackSrtOffset"] intValue]; + + /* we need to srncpy file name and codeset */ + //sub_config.src_filename = [[tempObject objectForKey:@"subtitleSourceSrtFilePath"] UTF8String]; + strncpy(sub_config.src_filename, [[tempObject objectForKey:@"subtitleSourceSrtFilePath"] UTF8String], 128); + //sub_config.src_codeset = [[tempObject objectForKey:@"subtitleTrackSrtCharCode"] UTF8String]; + strncpy(sub_config.src_codeset, [[tempObject objectForKey:@"subtitleTrackSrtCharCode"] UTF8String], 40); + + sub_config.force = 0; + sub_config.dest = hb_subtitle_config_s::PASSTHRUSUB; + sub_config.default_track = def; + + hb_srt_add( job, &sub_config, [[tempObject objectForKey:@"subtitleTrackSrtLanguageIso3"] UTF8String]); + } + + if (subt != NULL) { [self writeToActivityLog: "Setting Subtitle: %s", subt]; @@ -5660,6 +5699,51 @@ the user is using "Custom" settings by determining the sender*/ //[self customSettingUsed: sender]; } +#pragma mark - + +- (IBAction) browseImportSrtFile: (id) sender +{ + + NSOpenPanel * panel; + + panel = [NSOpenPanel openPanel]; + [panel setAllowsMultipleSelection: NO]; + [panel setCanChooseFiles: YES]; + [panel setCanChooseDirectories: NO ]; + NSString * sourceDirectory; + if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSrtImportDirectory"]) + { + sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSrtImportDirectory"]; + } + else + { + sourceDirectory = @"~/Desktop"; + sourceDirectory = [sourceDirectory stringByExpandingTildeInPath]; + } + /* we open up the browse srt sheet here and call for browseImportSrtFileDone after the sheet is closed */ + NSArray *fileTypes = [NSArray arrayWithObjects:@"plist", @"srt", nil]; + [panel beginSheetForDirectory: sourceDirectory file: nil types: fileTypes + modalForWindow: fWindow modalDelegate: self + didEndSelector: @selector( browseImportSrtFileDone:returnCode:contextInfo: ) + contextInfo: sender]; +} + +- (void) browseImportSrtFileDone: (NSSavePanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo +{ + if( returnCode == NSOKButton ) + { + NSString *importSrtDirectory = [[sheet filename] stringByDeletingLastPathComponent]; + NSString *importSrtFilePath = [sheet filename]; + [[NSUserDefaults standardUserDefaults] setObject:importSrtDirectory forKey:@"LastSrtImportDirectory"]; + + /* now pass the string off to fSubtitlesDelegate to add the srt file to the dropdown */ + [fSubtitlesDelegate createSubtitleSrtTrack:importSrtFilePath]; + + [fSubtitlesTable reloadData]; + + } +} #pragma mark - #pragma mark Open New Windows |