Switch to FourCC instead of NSStrings for media type and formats.
This commit is contained in:
1 parent
978b65eb22
commit
3816364957
7 files changed
+62
-54
No files matched your search
@@ -42,13 +42,14 @@
|
||||
|
||||
_fallbacks = [[NSMutableArray alloc] init];
|
||||
|
||||
if ([self.soundTrack.format isEqualToString:MP42AudioFormatAC3] ||
|
||||
[self.soundTrack.format isEqualToString:MP42AudioFormatEAC3]) {
|
||||
if (self.soundTrack.format == kMP42AudioCodecType_AC3 ||
|
||||
self.soundTrack.format == kMP42AudioCodecType_EnhancedAC3) {
|
||||
NSInteger i = 1;
|
||||
NSInteger selectedItem = 0;
|
||||
|
||||
for (MP42AudioTrack *fileTrack in [self.file tracksWithMediaType:MP42MediaTypeAudio]) {
|
||||
if ([fileTrack.format isEqualToString:MP42AudioFormatAAC]) {
|
||||
for (MP42AudioTrack *fileTrack in [self.file tracksWithMediaType:kMP42MediaType_Audio]) {
|
||||
if (fileTrack.format == kMP42AudioCodecType_MPEG4AAC ||
|
||||
fileTrack.format == kMP42AudioCodecType_MPEG4AAC_HE) {
|
||||
NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%@ - %@ - %@",
|
||||
fileTrack.trackId ? [NSString stringWithFormat:@"%d", fileTrack.trackId] : @"na",
|
||||
fileTrack.name,
|
||||
@@ -78,7 +79,7 @@
|
||||
NSInteger i = 1;
|
||||
NSInteger selectedItem = 0;
|
||||
|
||||
for (MP42SubtitleTrack *fileTrack in [self.file tracksWithMediaType:MP42MediaTypeSubtitle]) {
|
||||
for (MP42SubtitleTrack *fileTrack in [self.file tracksWithMediaType:kMP42MediaType_Subtitle]) {
|
||||
NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%@ - %@ - %@",
|
||||
fileTrack.trackId ? [NSString stringWithFormat:@"%d", fileTrack.trackId] : @"na",
|
||||
fileTrack.name,
|
||||
|
||||
@@ -120,7 +120,7 @@ static NSString *getLevelName(uint8_t level) {
|
||||
|
||||
[alternateGroup selectItemAtIndex:(NSInteger)track.alternate_group];
|
||||
|
||||
if ([track.format isEqualToString:MP42VideoFormatH264] && track.origProfile && track.origLevel) {
|
||||
if (track.format == kMP42VideoCodecType_H264 && track.origProfile && track.origLevel) {
|
||||
profileLevelUnchanged.title = [NSString stringWithFormat:@"Current profile: %@ @ %@",
|
||||
getProfileName(track.origProfile), getLevelName(track.origLevel)];
|
||||
if ((track.origProfile == track.newProfile) && (track.origLevel == track.newLevel)) {
|
||||
@@ -165,7 +165,7 @@ static NSString *getLevelName(uint8_t level) {
|
||||
|
||||
NSInteger i = 1;
|
||||
NSInteger selectedItem = 0;
|
||||
for (MP42SubtitleTrack *fileTrack in [mp4file tracksWithMediaType:MP42MediaTypeSubtitle]) {
|
||||
for (MP42SubtitleTrack *fileTrack in [mp4file tracksWithMediaType:kMP42MediaType_Subtitle]) {
|
||||
NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%@ - %@ - %@",
|
||||
fileTrack.trackId ? [NSString stringWithFormat:@"%d", fileTrack.trackId] : @"NA",
|
||||
fileTrack.name,
|
||||
|
||||
+40
-29
@@ -67,11 +67,11 @@
|
||||
_importCheckArray = [[NSMutableArray alloc] initWithCapacity:_tracks.count];
|
||||
_actionArray = [[NSMutableArray alloc] initWithCapacity:_tracks.count];
|
||||
|
||||
for (id object in _tracks) {
|
||||
for (MP42Track *object in _tracks) {
|
||||
if ([object isKindOfClass:[MP42Track class]]) {
|
||||
|
||||
// Set the checkbox state
|
||||
if (isTrackMuxable([object format]) || trackNeedConversion([object format])) {
|
||||
if (isTrackMuxable(object.format) || trackNeedConversion(object.format)) {
|
||||
[_importCheckArray addObject:@YES];
|
||||
} else {
|
||||
[_importCheckArray addObject:@NO];
|
||||
@@ -79,12 +79,12 @@
|
||||
|
||||
// Set the action menu selection
|
||||
// AC-3 Specific actions
|
||||
if (([[object format] isEqualToString:MP42AudioFormatAC3] || [[object format] isEqualToString:MP42AudioFormatEAC3]) &&
|
||||
if ((object.format == kMP42AudioCodecType_AC3 || object.format == kMP42AudioCodecType_EnhancedAC3) &&
|
||||
[[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioConvertAC3"] boolValue]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioKeepAC3"] boolValue] &&
|
||||
[object fallbackTrack] == nil) {
|
||||
[(MP42AudioTrack *)object fallbackTrack] == nil) {
|
||||
[_actionArray addObject:@6];
|
||||
} else if ([object fallbackTrack]) {
|
||||
} else if ([(MP42AudioTrack *)object fallbackTrack]) {
|
||||
[_actionArray addObject:@0];
|
||||
} else {
|
||||
[_actionArray addObject:@([[[NSUserDefaults standardUserDefaults]
|
||||
@@ -92,12 +92,12 @@
|
||||
}
|
||||
}
|
||||
// DTS Specific actions
|
||||
else if ([[object format] isEqualToString:MP42AudioFormatDTS] &&
|
||||
else if (object.format == kMP42AudioCodecType_DTS &&
|
||||
[[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioConvertDts"] boolValue]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioKeepDts"] boolValue] &&
|
||||
[object fallbackTrack] == nil) {
|
||||
[(MP42AudioTrack *)object fallbackTrack] == nil) {
|
||||
[_actionArray addObject:@6];
|
||||
} else if ([object fallbackTrack]) {
|
||||
} else if ([(MP42AudioTrack *)object fallbackTrack]) {
|
||||
[_actionArray addObject:@0];
|
||||
} else {
|
||||
[_actionArray addObject:@([[[NSUserDefaults standardUserDefaults]
|
||||
@@ -105,12 +105,12 @@
|
||||
}
|
||||
}
|
||||
// Vobsub
|
||||
else if ([[object format] isEqualToString:MP42SubtitleFormatVobSub] &&
|
||||
else if (object.format == kMP42SubtitleCodecType_VobSub &&
|
||||
[[[NSUserDefaults standardUserDefaults] valueForKey:@"SBSubtitleConvertBitmap"] boolValue]) {
|
||||
[_actionArray addObject:@1];
|
||||
}
|
||||
// Generic actions
|
||||
else if (!trackNeedConversion([object format])) {
|
||||
else if (!trackNeedConversion(object.format)) {
|
||||
[_actionArray addObject:@0];
|
||||
}
|
||||
else if ([object isMemberOfClass:[MP42AudioTrack class]]) {
|
||||
@@ -148,9 +148,9 @@
|
||||
- (BOOL)onlyContainsSubtitleTracks
|
||||
{
|
||||
BOOL onlySubtitle = YES;
|
||||
for (id track in _tracks) {
|
||||
for (MP42Track *track in _tracks) {
|
||||
if ([track isKindOfClass:[MP42Track class]]) {
|
||||
if (![track isMemberOfClass:[MP42SubtitleTrack class]] || ![((MP42Track *)track).format isEqualToString:MP42SubtitleFormatTx3g])
|
||||
if (![track isMemberOfClass:[MP42SubtitleTrack class]] || track.format != kMP42SubtitleCodecType_3GText)
|
||||
onlySubtitle = NO;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@
|
||||
}
|
||||
[actionCell.menu addItem:item];
|
||||
|
||||
NSArray<NSString *> *formatArray = @[MP42SubtitleFormatTx3g];
|
||||
NSArray<NSString *> *formatArray = @[@"Tx3g"];
|
||||
for (NSString *format in formatArray) {
|
||||
item = [[NSMenuItem alloc] initWithTitle:format action:NULL keyEquivalent:@""];
|
||||
item.tag = tag++;
|
||||
@@ -287,9 +287,9 @@
|
||||
[actionCell.menu addItem:item];
|
||||
}
|
||||
|
||||
if ([track.format isEqualTo:MP42AudioFormatAC3] ||
|
||||
[track.format isEqualTo:MP42AudioFormatEAC3] ||
|
||||
[track.format isEqualTo:MP42AudioFormatDTS])
|
||||
if (track.format == kMP42AudioCodecType_AC3 ||
|
||||
track.format == kMP42AudioCodecType_EnhancedAC3 ||
|
||||
track.format == kMP42AudioCodecType_DTS)
|
||||
{
|
||||
item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"AAC + Passthru", @"File Import action menu item.") action:NULL keyEquivalent:@""];
|
||||
item.tag = tag++;
|
||||
@@ -324,26 +324,37 @@
|
||||
}
|
||||
|
||||
if ([object isKindOfClass:[MP42Track class]]) {
|
||||
if( [tableColumn.identifier isEqualToString: @"check"] )
|
||||
MP42Track *track = object;
|
||||
|
||||
if ([tableColumn.identifier isEqualToString: @"check"] ) {
|
||||
return _importCheckArray[rowIndex];
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"trackId"])
|
||||
return [NSString stringWithFormat:@"%d", [object trackId]];
|
||||
if ([tableColumn.identifier isEqualToString:@"trackId"]) {
|
||||
return [NSString stringWithFormat:@"%d", track.trackId];
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"trackName"])
|
||||
return [object name];
|
||||
if ([tableColumn.identifier isEqualToString:@"trackName"]) {
|
||||
return track.name;
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"trackInfo"])
|
||||
return [object format];
|
||||
// FIXME
|
||||
if ([tableColumn.identifier isEqualToString:@"trackInfo"]) {
|
||||
FourCharCode format = track.format;
|
||||
return @(FourCC2Str(format));
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"trackDuration"])
|
||||
return [object timeString];
|
||||
if ([tableColumn.identifier isEqualToString:@"trackDuration"]) {
|
||||
return track.timeString;
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"trackLanguage"])
|
||||
return [object language];
|
||||
if ([tableColumn.identifier isEqualToString:@"trackLanguage"]) {
|
||||
return track.language;
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"trackAction"])
|
||||
if ([tableColumn.identifier isEqualToString:@"trackAction"]) {
|
||||
return _actionArray[rowIndex];
|
||||
}
|
||||
} else if ([tableColumn isEqual:tableView.tableColumns[1]]) {
|
||||
return object;
|
||||
}
|
||||
@@ -356,7 +367,7 @@
|
||||
forTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
if ([tableColumn.identifier isEqualToString: @"check"]) {
|
||||
if ([tableColumn.identifier isEqualToString:@"check"]) {
|
||||
_importCheckArray[rowIndex] = anObject;
|
||||
}
|
||||
if ([tableColumn.identifier isEqualToString:@"trackAction"]) {
|
||||
|
||||
@@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*
|
||||
* @return an array of NSString with the supported tags.
|
||||
*/
|
||||
+ (NSArray<NSString *> *)predefinedTagsForMediaType:(NSString *)mediaType;
|
||||
+ (NSArray<NSString *> *)predefinedTagsForMediaType:(MP42MediaType)mediaType;
|
||||
|
||||
/**
|
||||
* Returns the localized human readable title of a partical tag.
|
||||
@@ -78,19 +78,19 @@ NS_ASSUME_NONNULL_END
|
||||
@"public.translation.voice-over", @"public.translation"];
|
||||
}
|
||||
|
||||
+ (NSArray<NSString *> *)predefinedTagsForMediaType:(NSString *)mediaType {
|
||||
+ (NSArray<NSString *> *)predefinedTagsForMediaType:(MP42MediaType)mediaType {
|
||||
NSMutableArray *tags = [NSMutableArray array];
|
||||
[tags addObjectsFromArray:@[@"public.main-program-content",
|
||||
@"public.auxiliary-content"]];
|
||||
|
||||
if ([mediaType isEqualToString:MP42MediaTypeAudio]) {
|
||||
if (mediaType == kMP42MediaType_Audio) {
|
||||
[tags addObjectsFromArray:@[@"public.accessibility.describes-video",
|
||||
@"public.translation.dubbed",
|
||||
@"public.translation.voice-over"]];
|
||||
}
|
||||
|
||||
else if ([mediaType isEqualToString:MP42MediaTypeSubtitle] ||
|
||||
[mediaType isEqualToString:MP42MediaTypeClosedCaption]) {
|
||||
else if (mediaType == kMP42MediaType_Subtitle ||
|
||||
mediaType == kMP42MediaType_ClosedCaption) {
|
||||
|
||||
[tags addObjectsFromArray:@[@"public.subtitles.forced-only",
|
||||
@"public.accessibility.transcribes-spoken-dialog",
|
||||
@@ -99,9 +99,9 @@ NS_ASSUME_NONNULL_END
|
||||
|
||||
}
|
||||
|
||||
if ([mediaType isEqualToString:MP42MediaTypeSubtitle] ||
|
||||
[mediaType isEqualToString:MP42MediaTypeClosedCaption] ||
|
||||
[mediaType isEqualToString:MP42MediaTypeAudio]) {
|
||||
if (mediaType == kMP42MediaType_Subtitle ||
|
||||
mediaType == kMP42MediaType_ClosedCaption ||
|
||||
mediaType == kMP42MediaType_Audio) {
|
||||
|
||||
[tags addObjectsFromArray:@[@"public.translation"]];
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
// Search for metadata
|
||||
MP42Metadata *metadata = [self searchMetadataForFile:item.fileURL];
|
||||
|
||||
for (MP42Track *track in [item.mp4File tracksWithMediaType:MP42MediaTypeVideo])
|
||||
for (MP42Track *track in [item.mp4File tracksWithMediaType:kMP42MediaType_Video])
|
||||
if ([track isKindOfClass:[MP42VideoTrack class]]) {
|
||||
MP42VideoTrack *videoTrack = (MP42VideoTrack *)track;
|
||||
int hdVideo = isHdVideo((uint64_t)videoTrack.trackWidth, (uint64_t)videoTrack.trackHeight);
|
||||
|
||||
@@ -173,7 +173,8 @@
|
||||
|
||||
for (MP42Track *track in fileImporter.tracks) {
|
||||
// AC-3 track, we might need to do the aac + ac3 trick.
|
||||
if ([track.format isEqualToString:MP42AudioFormatAC3]) {
|
||||
if (track.format == kMP42AudioCodecType_AC3 ||
|
||||
track.format == kMP42AudioCodecType_EnhancedAC3) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioConvertAC3"] boolValue]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioKeepAC3"] boolValue] &&
|
||||
!((MP42AudioTrack *)track).fallbackTrack) {
|
||||
@@ -192,7 +193,7 @@
|
||||
}
|
||||
|
||||
// DTS -> convert only if specified in the prefs.
|
||||
if ([track.format isEqualToString:MP42AudioFormatDTS]) {
|
||||
if (track.format == kMP42AudioCodecType_DTS) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioConvertDts"] boolValue]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioKeepDts"] boolValue]) {
|
||||
MP42AudioTrack *copy = [track copy];
|
||||
@@ -209,7 +210,8 @@
|
||||
}
|
||||
|
||||
// VobSub -> only if specified in the prefs.
|
||||
if (([track.format isEqualToString:MP42SubtitleFormatVobSub] && [[[NSUserDefaults standardUserDefaults] valueForKey:@"SBSubtitleConvertBitmap"] boolValue]))
|
||||
if ((track.format == kMP42SubtitleCodecType_VobSub &&
|
||||
[[[NSUserDefaults standardUserDefaults] valueForKey:@"SBSubtitleConvertBitmap"] boolValue]))
|
||||
track.needConversion = YES;
|
||||
|
||||
// If an audio track needs to be converted, apply the mixdown from the preferences.
|
||||
|
||||
@@ -1247,7 +1247,6 @@
|
||||
C05733CC08A9546B00998B17 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
CLANG_ANALYZER_LOCALIZABILITY = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
@@ -1282,7 +1281,6 @@
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
GCC_WARN_PEDANTIC = YES;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
@@ -1299,7 +1297,6 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = macosx;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
@@ -1308,7 +1305,6 @@
|
||||
C05733CD08A9546B00998B17 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ANALYZER_LOCALIZABILITY = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
@@ -1339,7 +1335,6 @@
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
GCC_WARN_PEDANTIC = YES;
|
||||
GCC_WARN_SHADOW = YES;
|
||||
@@ -1356,7 +1351,6 @@
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = macosx;
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
name = Release;
|
||||
|
||||
Reference in new issue
Block a user