From 1c562a65ea883c368b200079126fdb9623451212 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 10 Aug 2016 18:51:53 +0200 Subject: [PATCH] Switch to FourCC instead of NSStrings for media type and formats. --- MP42/MP42AACImporter.mm | 2 +- MP42/MP42AC3Importer.m | 2 +- MP42/MP42AVFImporter.m | 116 +------------- MP42/MP42AudioConverter.m | 48 +----- MP42/MP42AudioTrack.m | 8 +- MP42/MP42BitmapSubConverter.m | 10 +- MP42/MP42CCImporter.m | 2 +- MP42/MP42ChapterTrack.m | 12 +- MP42/MP42ClosedCaptionTrack.m | 10 +- MP42/MP42EditListsReconstructor.h | 2 +- MP42/MP42EditListsReconstructor.m | 6 +- MP42/MP42File.h | 2 +- MP42/MP42File.m | 55 +++---- MP42/MP42H264Importer.mm | 2 +- MP42/MP42MediaFormat.h | 190 ++++++++++++++++------- MP42/MP42MkvImporter.m | 59 ++++--- MP42/MP42Muxer.m | 37 +++-- MP42/MP42PrivateUtilities.h | 2 +- MP42/MP42PrivateUtilities.m | 66 ++++---- MP42/MP42SrtImporter.m | 2 +- MP42/MP42SubUtilities.h | 4 +- MP42/MP42SubUtilities.m | 17 +- MP42/MP42SubtitleTrack.m | 12 +- MP42/MP42Track.h | 12 +- MP42/MP42Track.m | 19 +-- MP42/MP42Utilities.h | 4 +- MP42/MP42Utilities.m | 54 +++++-- MP42/MP42VideoTrack.m | 10 +- MP42/MP42VobSubImporter.m | 2 +- MP42/MP42XMLReader.h | 4 +- MP42/MP42XMLReader.m | 10 +- MP42Foundation.xcodeproj/project.pbxproj | 2 + 32 files changed, 374 insertions(+), 409 deletions(-) diff --git a/MP42/MP42AACImporter.mm b/MP42/MP42AACImporter.mm index 0538b39..e6cb426 100644 --- a/MP42/MP42AACImporter.mm +++ b/MP42/MP42AACImporter.mm @@ -728,7 +728,7 @@ static bool GetFirstHeader(FILE* inFile) MP42AudioTrack *newTrack = [[MP42AudioTrack alloc] init]; - newTrack.format = MP42AudioFormatAAC; + newTrack.format = kMP42AudioCodecType_MPEG4AAC; newTrack.sourceURL = self.fileURL; if (!inFile) { diff --git a/MP42/MP42AC3Importer.m b/MP42/MP42AC3Importer.m index f4e75a7..3e17499 100644 --- a/MP42/MP42AC3Importer.m +++ b/MP42/MP42AC3Importer.m @@ -273,7 +273,7 @@ static bool GetFirstHeader(FILE* inFile) MP42AudioTrack *newTrack = [[MP42AudioTrack alloc] init]; - newTrack.format = MP42AudioFormatAC3; + newTrack.format = kMP42AudioCodecType_AC3; newTrack.sourceURL = self.fileURL; if (!inFile) { diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 07e6df0..3a9e1b3 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -51,128 +51,24 @@ return @[@"mov", @"mp4", @"m4v", @"m4a", @"m2ts", @"ts", @"mts", @"ac3", @"eac3", @"ec3", @"webvtt", @"vtt"]; } -- (NSString *)formatForTrack:(AVAssetTrack *)track { - NSString *result = @""; +- (FourCharCode)formatForTrack:(AVAssetTrack *)track { + FourCharCode result = 0; CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)track.formatDescriptions.firstObject; if (formatDescription) { FourCharCode code = CMFormatDescriptionGetMediaSubType(formatDescription); switch (code) { - case kCMVideoCodecType_H264: - result = MP42VideoFormatH264; - break; - case 'hev1': - case kCMVideoCodecType_HEVC: - result = MP42VideoFormatH265; - break; - case kCMVideoCodecType_MPEG4Video: - result = MP42VideoFormatMPEG4Visual; - break; - case kCMVideoCodecType_MPEG2Video: - result = MP42VideoFormatMPEG2; - break; - case kCMVideoCodecType_MPEG1Video: - result = MP42VideoFormatMPEG1; - break; - case kCMVideoCodecType_AppleProRes422: - case kCMVideoCodecType_AppleProRes422HQ: - case kCMVideoCodecType_AppleProRes422LT: - case kCMVideoCodecType_AppleProRes422Proxy: - case kCMVideoCodecType_AppleProRes4444: - result = MP42VideoFormatProRes; - break; - case kCMVideoCodecType_SorensonVideo3: - result = MP42VideoFormatSorenson3; - break; - case 'png ': - result = MP42VideoFormatPNG; - break; - case kAudioFormatMPEG4AAC: - result = MP42AudioFormatAAC; - break; - case kAudioFormatMPEG4AAC_HE: - case kAudioFormatMPEG4AAC_HE_V2: - result = MP42AudioFormatHEAAC; - break; - case kAudioFormatLinearPCM: - result = MP42AudioFormatPCM; - break; - case kAudioFormatAppleLossless: - result = MP42AudioFormatALAC; - break; - case kAudioFormatAC3: case 'ms \0': - result = MP42AudioFormatAC3; - break; - case kAudioFormatEnhancedAC3: - result = MP42AudioFormatEAC3; - break; - case kAudioFormatMPEGLayer1: - case kAudioFormatMPEGLayer2: - case kAudioFormatMPEGLayer3: - result = MP42AudioFormatMP3; - break; - case kAudioFormatAMR: - result = MP42AudioFormatAMR; - break; - case kAudioFormatAppleIMA4: - result = @"IMA 4:1"; - break; - case kCMTextFormatType_QTText: - result = MP42SubtitleFormatText; - break; - case kCMTextFormatType_3GText: - result = MP42SubtitleFormatTx3g; - break; - case kCMSubtitleFormatType_WebVTT: - result = MP42SubtitleFormatWebVTT; + result = kMP42AudioCodecType_AC3; break; case 'SRT ': - result = MP42SubtitleFormatText; + result = kMP42SubtitleCodecType_Text; break; case 'SSA ': - result = MP42SubtitleFormatSSA; - break; - case kCMClosedCaptionFormatType_CEA608: - result = MP42ClosedCaptionFormatCEA608; - break; - case kCMClosedCaptionFormatType_CEA708: - result = MP42ClosedCaptionFormatCEA708; - break; - case kCMClosedCaptionFormatType_ATSC: - result = @"ATSC/52 part-4"; - break; - case kCMTimeCodeFormatType_TimeCode32: - case kCMTimeCodeFormatType_TimeCode64: - case kCMTimeCodeFormatType_Counter32: - case kCMTimeCodeFormatType_Counter64: - result = MP42TimeCodeFormat; - break; - case kCMVideoCodecType_JPEG: - result = MP42VideoFormatJPEG; - break; - case kCMVideoCodecType_DVCNTSC: - case kCMVideoCodecType_DVCPAL: - result = MP42VideoFormatDV; - break; - case kCMVideoCodecType_DVCProPAL: - case kCMVideoCodecType_DVCPro50NTSC: - case kCMVideoCodecType_DVCPro50PAL: - result = @"DVCPro"; - break; - case kCMVideoCodecType_DVCPROHD720p60: - case kCMVideoCodecType_DVCPROHD720p50: - case kCMVideoCodecType_DVCPROHD1080i60: - case kCMVideoCodecType_DVCPROHD1080i50: - case kCMVideoCodecType_DVCPROHD1080p30: - case kCMVideoCodecType_DVCPROHD1080p25: - result = @"DVCProHD"; - break; - case 'AVdn': - result = @"DNxHD"; + result = kMP42SubtitleCodecType_SSA; break; default: - result = @"Unknown"; + result = code; break; } } diff --git a/MP42/MP42AudioConverter.m b/MP42/MP42AudioConverter.m index 1c50638..377e320 100644 --- a/MP42/MP42AudioConverter.m +++ b/MP42/MP42AudioConverter.m @@ -67,50 +67,7 @@ asbd.mSampleRate = [track.muxer_helper->importer timescaleForTrack:track];; asbd.mChannelsPerFrame = track.sourceChannels; - NSString *format = track.sourceFormat; - - if ([format isEqualToString:MP42AudioFormatAAC]) { - asbd.mFormatID = kAudioFormatMPEG4AAC; - } - else if ([format isEqualToString:MP42AudioFormatALAC]) { - asbd.mFormatID = kAudioFormatAppleLossless; - } - else if ([format isEqualToString:MP42AudioFormatVorbis]) { - asbd.mFormatID = 'XiVs'; - } - else if ([format isEqualToString:MP42AudioFormatFLAC]) { - asbd.mFormatID = 'XiFL'; - } - else if ([format isEqualToString:MP42AudioFormatAC3]) { - asbd.mFormatID = kAudioFormatAC3; - asbd.mFramesPerPacket = 1536; - } - else if ([format isEqualToString:MP42AudioFormatEAC3]) { - asbd.mFormatID = kAudioFormatEnhancedAC3; - asbd.mFramesPerPacket = 1536; - } - else if ([format isEqualToString:MP42AudioFormatDTS]) { - asbd.mFormatID = 'DTS '; - } - else if ([format isEqualToString:MP42AudioFormatMP1]) { - asbd.mFormatID = kAudioFormatMPEGLayer1; - asbd.mFramesPerPacket = 1152; - } - else if ([format isEqualToString:MP42AudioFormatMP2]) { - asbd.mFormatID = kAudioFormatMPEGLayer2; - asbd.mFramesPerPacket = 1152; - } - else if ([format isEqualToString:MP42AudioFormatMP3]) { - asbd.mFormatID = kAudioFormatMPEGLayer3; - asbd.mFramesPerPacket = 1152; - } - else if ([format isEqualToString:MP42AudioFormatTrueHD]) { - asbd.mFormatID = 'trhd'; - } - else if ([format isEqualToString:MP42AudioFormatOpus]) { - asbd.mFormatID = 'Opus'; - } - else if ([format isEqualToString:MP42AudioFormatPCM]) { + if (track.sourceFormat == kMP42AudioCodecType_LinearPCM) { AudioStreamBasicDescription temp = [track.muxer_helper->importer audioDescriptionForTrack:track]; if (temp.mFormatID) { asbd = temp; @@ -119,6 +76,9 @@ asbd.mFormatID = kAudioFormatLinearPCM; } } + else { + asbd.mFormatID = track.sourceFormat; + } return asbd; } diff --git a/MP42/MP42AudioTrack.m b/MP42/MP42AudioTrack.m index cfc1562..15dbb4c 100644 --- a/MP42/MP42AudioTrack.m +++ b/MP42/MP42AudioTrack.m @@ -38,7 +38,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig); if (self) { MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.volume", &_volume); - _mediaType = MP42MediaTypeAudio; + _mediaType = kMP42MediaType_Audio; u_int8_t audioType = MP4GetTrackEsdsObjectTypeId(fileHandle, _trackId); @@ -123,7 +123,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig); _language = @"Unknown"; _volume = 1; _mixdownType = SBDolbyPlIIMixdown; - _mediaType = MP42MediaTypeAudio; + _mediaType = kMP42MediaType_Audio; } return self; @@ -199,7 +199,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig); } - (NSString *)defaultName { - return MP42MediaTypeAudio; + return @"Sound Track"; } - (void)dealloc @@ -249,7 +249,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig); - (NSString *)formatSummary { - return [NSString stringWithFormat:@"%@, %u ch", _format, (unsigned int)_channels]; + return [NSString stringWithFormat:@"%@, %u ch", @(FourCC2Str(_format)), (unsigned int)_channels]; } - (NSString *)description { diff --git a/MP42/MP42BitmapSubConverter.m b/MP42/MP42BitmapSubConverter.m index 84ad515..de0f232 100644 --- a/MP42/MP42BitmapSubConverter.m +++ b/MP42/MP42BitmapSubConverter.m @@ -385,12 +385,12 @@ { if ((self = [super init])) { FFInitFFmpeg(); - NSString *format = track.sourceFormat; + MP42SubtitleCodecType format = track.sourceFormat; - if ([format isEqualToString:MP42SubtitleFormatVobSub]) { + if (format == kMP42SubtitleCodecType_VobSub) { avCodec = avcodec_find_decoder(AV_CODEC_ID_DVD_SUBTITLE); } - else if ([format isEqualToString:MP42SubtitleFormatPGS]) { + else if (format == kMP42SubtitleCodecType_PGS) { avCodec = avcodec_find_decoder(AV_CODEC_ID_HDMV_PGS_SUBTITLE); } @@ -416,13 +416,13 @@ _ocr = [[MP42OCRWrapper alloc] initWithLanguage:track.language extendedLanguageTag:track.extendedLanguageTag]; - if ([format isEqualToString:MP42SubtitleFormatVobSub]) { + if (format == kMP42SubtitleCodecType_VobSub) { // Launch the vobsub decoder thread. decoderThread = [[NSThread alloc] initWithTarget:self selector:@selector(VobSubDecoderThreadMainRoutine) object:nil]; [decoderThread setName:@"VobSub Decoder"]; [decoderThread start]; } - else if ([format isEqualToString:MP42SubtitleFormatPGS]) { + else if (format == kMP42SubtitleCodecType_PGS) { // Launch the pgs decoder thread. decoderThread = [[NSThread alloc] initWithTarget:self selector:@selector(PGSDecoderThreadMainRoutine) object:nil]; [decoderThread setName:@"PGS Decoder"]; diff --git a/MP42/MP42CCImporter.m b/MP42/MP42CCImporter.m index bf15c01..c325671 100644 --- a/MP42/MP42CCImporter.m +++ b/MP42/MP42CCImporter.m @@ -28,7 +28,7 @@ MP42Track *newTrack = [[MP42ClosedCaptionTrack alloc] init]; newTrack.name = @"Closed Caption Track"; - newTrack.format = MP42ClosedCaptionFormatCEA608; + newTrack.format = kMP42ClosedCaptionCodecType_CEA608; newTrack.sourceURL = self.fileURL; [self addTrack:newTrack]; diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index 5fe3596..8d95afa 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -22,12 +22,12 @@ { if ((self = [super init])) { _name = [self defaultName]; - _format = MP42SubtitleFormatText; + _format = kMP42SubtitleCodecType_Text; _language = @"English"; _isEdited = NO; _muxed = NO; _enabled = NO; - _mediaType = MP42MediaTypeText; + _mediaType = kMP42MediaType_Text; chapters = [[NSMutableArray alloc] init]; } @@ -46,10 +46,10 @@ } if (!_format) { - _format = MP42SubtitleFormatText; + _format = kMP42SubtitleCodecType_Text; } - _mediaType = MP42MediaTypeText; + _mediaType = kMP42MediaType_Text; chapters = [[NSMutableArray alloc] init]; MP4Chapter_t *chapter_list = NULL; @@ -87,13 +87,13 @@ { if ((self = [super init])) { _name = [self defaultName]; - _format = MP42SubtitleFormatText; + _format = kMP42SubtitleCodecType_Text; _sourceURL = [URL retain]; _language = @"English"; _isEdited = YES; _muxed = NO; _enabled = NO; - _mediaType = MP42MediaTypeText; + _mediaType = kMP42MediaType_Text; _areChaptersEdited = YES; chapters = [[NSMutableArray alloc] init]; diff --git a/MP42/MP42ClosedCaptionTrack.m b/MP42/MP42ClosedCaptionTrack.m index 5f650af..b5e78f5 100644 --- a/MP42/MP42ClosedCaptionTrack.m +++ b/MP42/MP42ClosedCaptionTrack.m @@ -17,7 +17,7 @@ self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle]; if (self) { - _mediaType = MP42MediaTypeClosedCaption; + _mediaType = kMP42MediaType_ClosedCaption; } return self; @@ -27,8 +27,8 @@ { if ((self = [super init])) { _name = [self defaultName]; - _format = MP42ClosedCaptionFormatCEA608; - _mediaType = MP42MediaTypeClosedCaption; + _format = kMP42ClosedCaptionCodecType_CEA608; + _mediaType = kMP42MediaType_ClosedCaption; } return self; @@ -46,7 +46,9 @@ } - (NSString *)defaultName { - return MP42MediaTypeClosedCaption; + // TODO + return @"Closed Caption"; + //return kMP42MediaType_ClosedCaption; } - (void)dealloc diff --git a/MP42/MP42EditListsReconstructor.h b/MP42/MP42EditListsReconstructor.h index 6e94ca8..0636e5e 100644 --- a/MP42/MP42EditListsReconstructor.h +++ b/MP42/MP42EditListsReconstructor.h @@ -18,7 +18,7 @@ */ @interface MP42EditListsReconstructor : NSObject -- (instancetype)initWithMediaFormat:(NSString *)format; +- (instancetype)initWithMediaFormat:(FourCharCode)format; - (void)addSample:(MP42SampleBuffer *)sample; - (void)done; diff --git a/MP42/MP42EditListsReconstructor.m b/MP42/MP42EditListsReconstructor.m index 555d9c3..6d427fa 100644 --- a/MP42/MP42EditListsReconstructor.m +++ b/MP42/MP42EditListsReconstructor.m @@ -38,7 +38,7 @@ return self; } -- (instancetype)initWithMediaFormat:(NSString *)format { +- (instancetype)initWithMediaFormat:(FourCharCode)format { self = [super init]; if (self) { _priorityQueue = [[MP42Heap alloc] initWithCapacity:32 andComparator:^NSComparisonResult(MP42SampleBuffer * obj1, MP42SampleBuffer * obj2) { @@ -46,11 +46,11 @@ }]; - if ([format isEqualToString:MP42AudioFormatAAC]) { + if (format == kMP42AudioCodecType_MPEG4AAC) { _priming = 2112; _primingTimescale = 48000; } - else if ([format isEqualToString:MP42AudioFormatHEAAC]) + else if (format == kMP42AudioCodecType_MPEG4AAC_HE) { _priming = 4224; _primingTimescale = 48000; diff --git a/MP42/MP42File.h b/MP42/MP42File.h index 6f3dd0b..89b007e 100644 --- a/MP42/MP42File.h +++ b/MP42/MP42File.h @@ -107,7 +107,7 @@ typedef void (^MP42FileProgressHandler)(double progress); * * @return An NSArray of MP42Tracks; may be empty if no tracks of the specified media type are available. */ -- (NSArray *)tracksWithMediaType:(NSString *)mediaType; +- (NSArray *)tracksWithMediaType:(MP42MediaType)mediaType; /** * Add a track to the mp4 file. diff --git a/MP42/MP42File.m b/MP42/MP42File.m index 58c08b6..8015a8b 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -76,10 +76,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { @interface MP42File () { @private - MP42FileHandle _fileHandle; NSURL *_fileURL; - MP42Status _status; BOOL _cancelled; MP42FileProgressHandler _progressHandler; @@ -87,8 +85,6 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { NSMutableArray<__kindof MP42Track *> *_tracks; NSMutableArray *_tracksToBeDeleted; MP42Metadata *_metadata; - MP42Muxer *_muxer; - NSMutableDictionary *_importers; BOOL _hasFileRepresentation; } @@ -102,13 +98,6 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { @property(nonatomic, readwrite) MP42Status status; @property(nonatomic, retain) MP42Muxer *muxer; -- (void)reconnectReferences; - -- (void)removeMuxedTrack:(MP42Track *)track; -- (void)organizeAlternateGroupsForMediaType:(NSString *)mediaType withGroupID:(NSUInteger)groupID; - -- (BOOL)createChaptersPreview; - @end @implementation MP42File @@ -271,7 +260,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { // Ugly hack to check for the previews track for (MP42Track *track in _tracks) { - if ([track.format isEqualToString:MP42VideoFormatJPEG]) { + if (track.format == kMP42VideoCodecType_JPEG) { previewsId = track.trackId; } } @@ -403,11 +392,11 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { return nil; } -- (NSArray *)tracksWithMediaType:(NSString *)mediaType { +- (NSArray *)tracksWithMediaType:(MP42MediaType)mediaType { NSMutableArray *tracks = [NSMutableArray array]; for (MP42Track *track in self.itracks) { - if ([track.mediaType isEqualToString:mediaType]) + if (track.mediaType == mediaType) [tracks addObject:track]; } @@ -440,7 +429,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { track.sourceFormat = track.format; if ([track isMemberOfClass:[MP42AudioTrack class]]) { MP42AudioTrack *audioTrack = (MP42AudioTrack *)track; - track.format = MP42AudioFormatAAC; + track.format = kMP42AudioCodecType_MPEG4AAC; audioTrack.sourceChannels = audioTrack.channels; if ([audioTrack.mixdownType isEqualToString:SBMonoMixdown] || audioTrack.sourceChannels == 1) { audioTrack.channels = 1; @@ -448,7 +437,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { audioTrack.channels = 2; } } else if ([track isMemberOfClass:[MP42SubtitleTrack class]]) { - track.format = MP42SubtitleFormatTx3g; + track.format = kMP42SubtitleCodecType_3GText; } } @@ -517,7 +506,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { [track release]; } -- (void)organizeAlternateGroupsForMediaType:(NSString *)mediaType withGroupID:(NSUInteger)groupID { +- (void)organizeAlternateGroupsForMediaType:(MP42MediaType)mediaType withGroupID:(NSUInteger)groupID { NSArray *tracks = [self tracksWithMediaType:mediaType]; BOOL enabled = NO; @@ -544,12 +533,12 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { - (void)organizeAlternateGroups { NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to organize alternate groups while the file is open for writing"); - NSArray *typeToOrganize = @[MP42MediaTypeVideo, - MP42MediaTypeAudio, - MP42MediaTypeSubtitle]; + MP42MediaType typeToOrganize[] = {kMP42MediaType_Video, + kMP42MediaType_Audio, + kMP42MediaType_Subtitle}; - for (NSUInteger i = 0; i < typeToOrganize.count; i++) { - [self organizeAlternateGroupsForMediaType:[typeToOrganize objectAtIndex:i] + for (NSUInteger i = 0; i < 3; i++) { + [self organizeAlternateGroupsForMediaType:typeToOrganize[i] withGroupID:i]; } @@ -828,8 +817,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { [self.muxer addTrack:track]; } else { // We don't know how to handle this type of track. + // FIXME NSError *error = MP42Error(@"Unsupported track", - [NSString stringWithFormat:@"%@, %@, has not been muxed.", track.name, track.format], + [NSString stringWithFormat:@"%@, %u, has not been muxed.", track.name, (unsigned int)track.format], 201); [_logger writeErrorToLog:error]; @@ -986,11 +976,11 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { chapterTrack = (MP42ChapterTrack *)track; if ([track isMemberOfClass:[MP42VideoTrack class]] && - ![track.format isEqualToString:MP42VideoFormatJPEG] + !(track.format == kMP42VideoCodecType_JPEG) && !refTrack) refTrack = (MP42VideoTrack *)track; - if ([track.format isEqualToString:MP42VideoFormatJPEG] && !jpegTrack) + if (track.format == kMP42VideoCodecType_JPEG && !jpegTrack) jpegTrack = track.trackId; } @@ -1014,16 +1004,16 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { } if ([track isMemberOfClass:[MP42VideoTrack class]] && - ![track.format isEqualToString:MP42VideoFormatJPEG] + !(track.format == kMP42VideoCodecType_JPEG) && !refTrack) { refTrack = (MP42VideoTrack *)track; } - if ([track.format isEqualToString:MP42VideoFormatJPEG] && !jpegTrack) { + if ((track.format == kMP42VideoCodecType_JPEG) && !jpegTrack) { jpegTrack = track.trackId; } - if ([track.format isEqualToString:MP42VideoFormatH264]) { + if (track.format == kMP42VideoCodecType_H264) { if ((((MP42VideoTrack *)track).origProfile) == 110) { decodable = 0; } @@ -1078,13 +1068,14 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { NSMutableArray *availableFallbackTracks = [[NSMutableArray alloc] init]; NSMutableArray *needFallbackTracks = [[NSMutableArray alloc] init]; - for (MP42AudioTrack *track in [self tracksWithMediaType:MP42MediaTypeAudio] ) { - if (([track.format isEqualToString:MP42AudioFormatAC3] || - [track.format isEqualToString:MP42AudioFormatEAC3]) && + for (MP42AudioTrack *track in [self tracksWithMediaType:kMP42MediaType_Audio] ) { + if ((track.format == kMP42AudioCodecType_AC3 || + track.format == kMP42AudioCodecType_EnhancedAC3) && track.fallbackTrack == nil) { [needFallbackTracks addObject:track]; } - else if ([track.format isEqualToString:MP42AudioFormatAAC]) { + else if (track.format == kMP42AudioCodecType_MPEG4AAC || + track.format == kMP42AudioCodecType_MPEG4AAC_HE) { [availableFallbackTracks addObject:track]; } } diff --git a/MP42/MP42H264Importer.mm b/MP42/MP42H264Importer.mm index f81c4f9..5b31914 100644 --- a/MP42/MP42H264Importer.mm +++ b/MP42/MP42H264Importer.mm @@ -1364,7 +1364,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height MP42VideoTrack *newTrack = [[MP42VideoTrack alloc] init]; - newTrack.format = MP42VideoFormatH264; + newTrack.format = kMP42VideoCodecType_H264; newTrack.sourceURL = self.fileURL; if (!inFile) { diff --git a/MP42/MP42MediaFormat.h b/MP42/MP42MediaFormat.h index e251149..adb57b9 100644 --- a/MP42/MP42MediaFormat.h +++ b/MP42/MP42MediaFormat.h @@ -20,71 +20,157 @@ extern NSString *const MP42FileTypeM4A; extern NSString *const MP42FileTypeM4B; extern NSString *const MP42FileTypeM4R; -// Media Type -extern NSString *const MP42MediaTypeVideo; -extern NSString *const MP42MediaTypeAudio; -extern NSString *const MP42MediaTypeText; -extern NSString *const MP42MediaTypeClosedCaption; -extern NSString *const MP42MediaTypeSubtitle; -extern NSString *const MP42MediaTypeTimecode; -extern NSString *const MP42MediaTypeMetadata; -extern NSString *const MP42MediaTypeMuxed; +#include +#if TARGET_RT_BIG_ENDIAN +# define FourCC2Str(fourcc) (const char[]){*((char*)&fourcc), *(((char*)&fourcc)+1), *(((char*)&fourcc)+2), *(((char*)&fourcc)+3),0} +#else +# define FourCC2Str(fourcc) (const char[]){*(((char*)&fourcc)+3), *(((char*)&fourcc)+2), *(((char*)&fourcc)+1), *(((char*)&fourcc)+0),0} +#endif +static FourCharCode kMP42MediaType_Unknown = 'unkn'; + +// Media Type +typedef FourCharCode MP42MediaType; +enum : MP42MediaType +{ + kMP42MediaType_Video = 'vide', + kMP42MediaType_Audio = 'soun', + kMP42MediaType_Muxed = 'muxx', + kMP42MediaType_Text = 'text', + kMP42MediaType_ClosedCaption = 'clcp', + kMP42MediaType_Subtitle = 'sbtl', + kMP42MediaType_TimeCode = 'tmcd', + kMP42MediaType_Metadata = 'meta', +}; // Video Format -extern NSString *const MP42VideoFormatH265; -extern NSString *const MP42VideoFormatH264; -extern NSString *const MP42VideoFormatMPEG4Visual; -extern NSString *const MP42VideoFormatSorenson; -extern NSString *const MP42VideoFormatSorenson3; -extern NSString *const MP42VideoFormatMPEG1; -extern NSString *const MP42VideoFormatMPEG2; -extern NSString *const MP42VideoFormatDV; -extern NSString *const MP42VideoFormatPNG; -extern NSString *const MP42VideoFormatAnimation; -extern NSString *const MP42VideoFormatProRes; -extern NSString *const MP42VideoFormatJPEG; -extern NSString *const MP42VideoFormatMotionJPEG; -extern NSString *const MP42VideoFormatFairPlay; +typedef FourCharCode MP42VideoCodecType; +enum : MP42VideoCodecType +{ + kMP42VideoCodecType_Animation = 'rle ', + kMP42VideoCodecType_Cinepak = 'cvid', + kMP42VideoCodecType_JPEG = 'jpeg', + kMP42VideoCodecType_JPEG_OpenDML = 'dmb1', + kMP42VideoCodecType_PNG = 'png ', + kMP42VideoCodecType_H263 = 'h263', + kMP42VideoCodecType_H264 = 'avc1', + kMP42VideoCodecType_HEVC = 'hvc1', + kMP42VideoCodecType_HEVC_2 = 'hev1', + kMP42VideoCodecType_MPEG4Video = 'mp4v', + kMP42VideoCodecType_MPEG2Video = 'mp2v', + kMP42VideoCodecType_MPEG1Video = 'mp1v', + kMP42VideoCodecType_SorensonVideo = 'SVQ1', + kMP42VideoCodecType_SorensonVideo3 = 'SVQ3', + + kMP42VideoCodecType_Theora = 'theo', + kMP42VideoCodecType_VP8 = 'VP8 ', + kMP42VideoCodecType_VP9 = 'VP9 ', + + kMP42VideoCodecType_AppleProRes4444 = 'ap4h', + kMP42VideoCodecType_AppleProRes422HQ = 'apch', + kMP42VideoCodecType_AppleProRes422 = 'apcn', + kMP42VideoCodecType_AppleProRes422LT = 'apcs', + kMP42VideoCodecType_AppleProRes422Proxy = 'apco', + + kMP42VideoCodecType_DVCNTSC = 'dvc ', + kMP42VideoCodecType_DVCPAL = 'dvcp', + kMP42VideoCodecType_DVCProPAL = 'dvpp', + kMP42VideoCodecType_DVCPro50NTSC = 'dv5n', + kMP42VideoCodecType_DVCPro50PAL = 'dv5p', + kMP42VideoCodecType_DVCPROHD720p60 = 'dvhp', + kMP42VideoCodecType_DVCPROHD720p50 = 'dvhq', + kMP42VideoCodecType_DVCPROHD1080i60 = 'dvh6', + kMP42VideoCodecType_DVCPROHD1080i50 = 'dvh5', + kMP42VideoCodecType_DVCPROHD1080p30 = 'dvh3', + kMP42VideoCodecType_DVCPROHD1080p25 = 'dvh2', + + kMP42VideoCodecType_FairPlay = 'drmi', +}; // Audio Format -extern NSString *const MP42AudioFormatAAC; -extern NSString *const MP42AudioFormatHEAAC; -extern NSString *const MP42AudioFormatMP1; -extern NSString *const MP42AudioFormatMP2; -extern NSString *const MP42AudioFormatMP3; -extern NSString *const MP42AudioFormatVorbis; -extern NSString *const MP42AudioFormatFLAC; -extern NSString *const MP42AudioFormatALAC; -extern NSString *const MP42AudioFormatAC3; -extern NSString *const MP42AudioFormatEAC3; -extern NSString *const MP42AudioFormatDTS; -extern NSString *const MP42AudioFormatTrueHD; -extern NSString *const MP42AudioFormatOpus; -extern NSString *const MP42AudioFormatAMR; -extern NSString *const MP42AudioFormatPCM; -extern NSString *const MP42AudioFormatFairPlay; +typedef FourCharCode MP42AudioCodecType; +enum : MP42AudioCodecType +{ + kMP42AudioCodecType_LinearPCM = 'lpcm', + kMP42AudioCodecType_AC3 = 'ac-3', + kMP42AudioCodecType_60958AC3 = 'cac3', + kMP42AudioCodecType_AppleIMA4 = 'ima4', + kMP42AudioCodecType_MPEG4AAC = 'aac ', + kMP42AudioCodecType_MPEG4CELP = 'celp', + kMP42AudioCodecType_MPEG4HVXC = 'hvxc', + kMP42AudioCodecType_MPEG4TwinVQ = 'twvq', + kMP42AudioCodecType_MACE3 = 'MAC3', + kMP42AudioCodecType_MACE6 = 'MAC6', + kMP42AudioCodecType_ULaw = 'ulaw', + kMP42AudioCodecType_ALaw = 'alaw', + kMP42AudioCodecType_QDesign = 'QDMC', + kMP42AudioCodecType_QDesign2 = 'QDM2', + kMP42AudioCodecType_QUALCOMM = 'Qclp', + kMP42AudioCodecType_MPEGLayer1 = '.mp1', + kMP42AudioCodecType_MPEGLayer2 = '.mp2', + kMP42AudioCodecType_MPEGLayer3 = '.mp3', + kMP42AudioCodecType_TimeCode = 'time', + kMP42AudioCodecType_MIDIStream = 'midi', + kMP42AudioCodecType_ParameterValueStream = 'apvs', + kMP42AudioCodecType_AppleLossless = 'alac', + kMP42AudioCodecType_MPEG4AAC_HE = 'aach', + kMP42AudioCodecType_MPEG4AAC_LD = 'aacl', + kMP42AudioCodecType_MPEG4AAC_ELD = 'aace', + kMP42AudioCodecType_MPEG4AAC_ELD_SBR = 'aacf', + kMP42AudioCodecType_MPEG4AAC_ELD_V2 = 'aacg', + kMP42AudioCodecType_MPEG4AAC_HE_V2 = 'aacp', + kMP42AudioCodecType_MPEG4AAC_Spatial = 'aacs', + kMP42AudioCodecType_AMR = 'samr', + kMP42AudioCodecType_AMR_WB = 'sawb', + kMP42AudioCodecType_Audible = 'AUDB', + kMP42AudioCodecType_iLBC = 'ilbc', + kMP42AudioCodecType_DVIIntelIMA = 0x6D730011, + kMP42AudioCodecType_MicrosoftGSM = 0x6D730031, + kMP42AudioCodecType_AES3 = 'aes3', + kMP42AudioCodecType_EnhancedAC3 = 'ec-3', + kMP42AudioCodecType_FLAC = 'XiFL', + kMP42AudioCodecType_Vorbis = 'XiVs', + kMP42AudioCodecType_DTS = 'DTS ', + kMP42AudioCodecType_TrueHD = 'trhd', + kMP42AudioCodecType_MLP = 'mlp ', + kMP42AudioCodecType_Opus = 'Opus', + kMP42AudioCodecType_FairPlay = 'drms' +}; // Subtitle Format -extern NSString *const MP42SubtitleFormatWebVTT; -extern NSString *const MP42SubtitleFormatTx3g; -extern NSString *const MP42SubtitleFormatText; -extern NSString *const MP42SubtitleFormatVobSub; -extern NSString *const MP42SubtitleFormatPGS; -extern NSString *const MP42SubtitleFormatSSA; -extern NSString *const MP42SubtitleFormatFairPlay; - +typedef FourCharCode MP42SubtitleCodecType; +enum : MP42SubtitleCodecType +{ + kMP42SubtitleCodecType_Text = 'text', + kMP42SubtitleCodecType_3GText = 'tx3g', + kMP42SubtitleCodecType_WebVTT = 'wvtt', + kMP42SubtitleCodecType_VobSub = 'subp', + kMP42SubtitleCodecType_PGS = 'PGS ', + kMP42SubtitleCodecType_SSA = 'SSA ', + kMP42SubtitleCodecType_FairPlay = 'wvtt', +}; // Closed Caption Fromat -extern NSString *const MP42ClosedCaptionFormatCEA608; -extern NSString *const MP42ClosedCaptionFormatCEA708; -extern NSString *const MP42ClosedCaptionFormatFairPlay; - +typedef FourCharCode MP42ClosedCaptionCodecType; +enum : MP42ClosedCaptionCodecType +{ + kMP42ClosedCaptionCodecType_CEA608 = 'c608', + kMP42ClosedCaptionCodecType_CEA708 = 'c708', + kMP42ClosedCaptionCodecType_ATSC = 'atcc', + kMP42ClosedCaptionCodecType_FairPlay = 'p608' +}; // TimeCode Format -extern NSString *const MP42TimeCodeFormat; +typedef FourCharCode MP42TimeCodeFormatType; +enum : MP42TimeCodeFormatType +{ + kMP42TimeCodeFormatType_TimeCode32 = 'tmcd', + kMP42TimeCodeFormatType_TimeCode64 = 'tc64', + kCMP42TimeCodeFormatType_Counter32 = 'cn32', + kMP42TimeCodeFormatType_Counter64 = 'cn64' +}; // Audio downmixes extern NSString * const SBMonoMixdown; diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index eeccd6d..6ead11d 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -234,7 +234,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t newTrack.startOffset = [self matroskaTrackStartTime:mkvTrack Id:i]; } - if ([newTrack.format isEqualToString:MP42VideoFormatH264]) { + if (newTrack.format == kMP42VideoCodecType_H264) { uint8_t *avcCAtom = (uint8_t *)malloc(mkvTrack->CodecPrivateSize); // mkv stores h.264 avcC in CodecPrivate memcpy(avcCAtom, mkvTrack->CodecPrivate, mkvTrack->CodecPrivateSize); if (mkvTrack->CodecPrivateSize >= 3) { @@ -397,72 +397,71 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t return trackSizes; } -- (NSString *)matroskaCodecIDToHumanReadableName:(TrackInfo *)track +- (FourCharCode)matroskaCodecIDToHumanReadableName:(TrackInfo *)track { if (track->CodecID) { if (!strcmp(track->CodecID, "V_MPEG4/ISO/AVC")) - return MP42VideoFormatH264; + return kMP42VideoCodecType_H264; else if (!strcmp(track->CodecID, "A_AAC") || !strcmp(track->CodecID, "A_AAC/MPEG4/LC") || !strcmp(track->CodecID, "A_AAC/MPEG2/LC")) - return MP42AudioFormatAAC; + return kMP42AudioCodecType_MPEG4AAC; else if (!strcmp(track->CodecID, "A_AC3")) - return MP42AudioFormatAC3; + return kMP42AudioCodecType_AC3; else if (!strcmp(track->CodecID, "A_EAC3")) - return MP42AudioFormatEAC3; + return kMP42AudioCodecType_EnhancedAC3; else if (!strcmp(track->CodecID, "V_MPEG4/ISO/SP")) - return MP42VideoFormatMPEG4Visual; + return kMP42VideoCodecType_MPEG4Video; else if (!strcmp(track->CodecID, "V_MPEG4/ISO/ASP")) - return MP42VideoFormatMPEG4Visual; + return kMP42VideoCodecType_MPEG4Video; else if (!strcmp(track->CodecID, "V_MPEG2")) - return MP42VideoFormatMPEG2; + return kMP42VideoCodecType_MPEG2Video; else if (!strcmp(track->CodecID, "A_DTS")) - return MP42AudioFormatDTS; + return kMP42AudioCodecType_DTS; else if (!strcmp(track->CodecID, "A_OPUS")) - return MP42AudioFormatOpus; + return kMP42AudioCodecType_Opus; else if (!strcmp(track->CodecID, "A_VORBIS")) - return MP42AudioFormatVorbis; + return kMP42AudioCodecType_Vorbis; else if (!strcmp(track->CodecID, "A_FLAC")) - return MP42AudioFormatFLAC; + return kMP42AudioCodecType_FLAC; else if (!strcmp(track->CodecID, "A_MPEG/L1")) - return MP42AudioFormatMP1; + return kMP42AudioCodecType_MPEGLayer1; else if (!strcmp(track->CodecID, "A_MPEG/L2")) - return MP42AudioFormatMP2; + return kMP42AudioCodecType_MPEGLayer2; else if (!strcmp(track->CodecID, "A_MPEG/L3")) - return MP42AudioFormatMP3; + return kMP42AudioCodecType_MPEGLayer3; else if (!strcmp(track->CodecID, "A_TRUEHD")) - return MP42AudioFormatTrueHD; + return kMP42AudioCodecType_TrueHD; else if (!strcmp(track->CodecID, "A_MLP")) - return @"MLP"; + return kMP42AudioCodecType_MLP; else if (!strcmp(track->CodecID, "S_TEXT/UTF8")) - return MP42SubtitleFormatText; + return kMP42SubtitleCodecType_Text; else if (!strcmp(track->CodecID, "S_TEXT/ASS") || !strcmp(track->CodecID, "S_TEXT/SSA")) - return MP42SubtitleFormatSSA; + return kMP42SubtitleCodecType_SSA; else if (!strcmp(track->CodecID, "S_VOBSUB")) - return MP42SubtitleFormatVobSub; + return kMP42SubtitleCodecType_VobSub; else if (!strcmp(track->CodecID, "S_HDMV/PGS")) { - return MP42SubtitleFormatPGS; + return kMP42SubtitleCodecType_PGS; } else if (!strcmp(track->CodecID, "V_MPEGH/ISO/HEVC")) { - return MP42VideoFormatH265; + return kMP42VideoCodecType_HEVC_2; } else if (!strcmp(track->CodecID, "V_THEORA")) { - return @"Theora"; + return kMP42VideoCodecType_Theora; } else if (!strcmp(track->CodecID, "V_VP8")) { - return @"VP8"; + return kMP42VideoCodecType_VP8; } else if (!strcmp(track->CodecID, "V_VP9")) { - return @"VP9"; + return kMP42VideoCodecType_VP9; } - else { - return [NSString stringWithUTF8String:track->CodecID]; + return kMP42MediaType_Unknown; } } else { - return @"Unknown"; + return kMP42MediaType_Unknown; } } @@ -993,7 +992,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t } if (demuxHelper->previousSample) { - if ([track.mediaType isEqualToString:MP42MediaTypeSubtitle]) { + if (track.mediaType == kMP42MediaType_Subtitle) { demuxHelper->previousSample->duration = 100; } diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index f0a44d2..941f83a 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -113,7 +113,7 @@ helper->converter = audioConverter; } - if ([track isMemberOfClass:[MP42SubtitleTrack class]] && ([track.sourceFormat isEqualToString:MP42SubtitleFormatVobSub] || [track.sourceFormat isEqualToString:MP42SubtitleFormatPGS]) && track.needConversion) { + if ([track isMemberOfClass:[MP42SubtitleTrack class]] && (track.sourceFormat == kMP42SubtitleCodecType_VobSub || track.sourceFormat == kMP42SubtitleCodecType_PGS) && track.needConversion) { MP42BitmapSubConverter *subConverter = [[MP42BitmapSubConverter alloc] initWithTrack:(MP42SubtitleTrack *)track error:outError]; @@ -127,11 +127,11 @@ helper->converter = subConverter; } else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && track.needConversion) { - track.format = MP42SubtitleFormatTx3g; + track.format = kMP42SubtitleCodecType_3GText; } // H.264 video track - if ([track isMemberOfClass:[MP42VideoTrack class]] && [track.format isEqualToString:MP42VideoFormatH264]) { + if ([track isMemberOfClass:[MP42VideoTrack class]] && track.format == kMP42VideoCodecType_H264) { if (magicCookie.length < sizeof(uint8_t) * 6) { continue; @@ -186,22 +186,25 @@ } // H.265 video track - else if ([track isMemberOfClass:[MP42VideoTrack class]] && [track.format isEqualToString:MP42VideoFormatH265]) { + else if ([track isMemberOfClass:[MP42VideoTrack class]] && track.format == kMP42VideoCodecType_HEVC) { if (magicCookie.length < sizeof(uint8_t) * 6) { continue; } - //NSSize size = [helper->importer sizeForTrack:track]; - //uint8_t *hvCCAtom = (uint8_t *)magicCookie.bytes; + NSSize size = [helper->importer sizeForTrack:track]; - NSAssert(NO, @"H.265 muxing not implemented yet"); + dstTrackId = MP4AddH265VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION, size.width, size.height); + + if (dstTrackId) { + MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hev1.hvcC.content", magicCookie.bytes, magicCookie.length); + } [helper->importer setActiveTrack:track]; } // MPEG-4 Visual video track - else if ([track isMemberOfClass:[MP42VideoTrack class]] && [track.format isEqualToString:MP42VideoFormatMPEG4Visual]) { + else if ([track isMemberOfClass:[MP42VideoTrack class]] && track.format == kMP42VideoCodecType_MPEG4Video) { MP4SetVideoProfileLevel(_fileHandle, MPEG4_SP_L3); // Add video track dstTrackId = MP4AddVideoTrack(_fileHandle, timeScale, @@ -219,7 +222,7 @@ } // Photo-JPEG video track - else if ([track isMemberOfClass:[MP42VideoTrack class]] && [track.format isEqualToString:MP42VideoFormatJPEG]) { + else if ([track isMemberOfClass:[MP42VideoTrack class]] && track.format == kMP42VideoCodecType_JPEG) { // Add video track dstTrackId = MP4AddJpegVideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION, [(MP42VideoTrack*)track width], [(MP42VideoTrack*)track height]); @@ -229,7 +232,7 @@ // AAC audio track else if ([track isMemberOfClass:[MP42AudioTrack class]] && - ([track.format isEqualToString:MP42AudioFormatAAC] || [track.format isEqualToString:MP42AudioFormatHEAAC])) { + (track.format == kMP42AudioCodecType_MPEG4AAC || track.format == kMP42AudioCodecType_MPEG4AAC_HE)) { dstTrackId = MP4AddAudioTrack(_fileHandle, timeScale, 1024, MP4_MPEG4_AUDIO_TYPE); @@ -244,7 +247,7 @@ } // AC-3 audio track - else if ([track isMemberOfClass:[MP42AudioTrack class]] && [track.format isEqualToString:MP42AudioFormatAC3]) { + else if ([track isMemberOfClass:[MP42AudioTrack class]] && track.format == kMP42AudioCodecType_AC3) { if ([magicCookie length] < sizeof(uint64_t) * 6) continue; @@ -263,14 +266,14 @@ } // EAC-3 audio tack - else if ([track isMemberOfClass:[MP42AudioTrack class]] && [track.format isEqualToString:MP42AudioFormatEAC3]) { + else if ([track isMemberOfClass:[MP42AudioTrack class]] && track.format == kMP42AudioCodecType_EnhancedAC3) { dstTrackId = MP4AddEAC3AudioTrack(_fileHandle, timeScale, magicCookie.bytes, magicCookie.length); [helper->importer setActiveTrack:track]; } // ALAC audio track - else if ([track isMemberOfClass:[MP42AudioTrack class]] && [track.format isEqualToString:MP42AudioFormatALAC]) { + else if ([track isMemberOfClass:[MP42AudioTrack class]] && track.format == kMP42AudioCodecType_AppleLossless) { dstTrackId = MP4AddALACAudioTrack(_fileHandle, timeScale); if (magicCookie.length) { @@ -281,7 +284,7 @@ } // DTS audio track - else if ([track isMemberOfClass:[MP42AudioTrack class]] && [track.format isEqualToString:MP42AudioFormatDTS]) { + else if ([track isMemberOfClass:[MP42AudioTrack class]] && track.format == kMP42AudioCodecType_DTS) { dstTrackId = MP4AddAudioTrack(_fileHandle, timeScale, 512, 0xA9); @@ -291,7 +294,7 @@ } // 3GPP text track - else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && [track.format isEqualToString:MP42SubtitleFormatTx3g]) { + else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && track.format == kMP42SubtitleCodecType_3GText) { NSSize subSize = NSMakeSize(0, 0); NSSize videoSize = NSMakeSize(0, 0); @@ -383,7 +386,7 @@ } // VobSub bitmap track - else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && [track.format isEqualToString:MP42SubtitleFormatVobSub]) { + else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && track.format == kMP42SubtitleCodecType_VobSub) { if (magicCookie.length < sizeof(uint32_t) * 16) continue; @@ -408,7 +411,7 @@ } // WebVTT - else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && [track.format isEqualToString:MP42SubtitleFormatWebVTT]) { + else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && track.format ==kMP42SubtitleCodecType_WebVTT) { NSSize videoSize = [helper->importer sizeForTrack:track]; for (id workingTrack in _workingTracks) diff --git a/MP42/MP42PrivateUtilities.h b/MP42/MP42PrivateUtilities.h index 5f685d0..c40ef06 100644 --- a/MP42/MP42PrivateUtilities.h +++ b/MP42/MP42PrivateUtilities.h @@ -41,7 +41,7 @@ MP4TrackId findFirstVideoTrack(MP4FileHandle fileHandle); uint16_t getFixedVideoWidth(MP4FileHandle fileHandle, MP4TrackId videoTrack); NSString* getTrackName(MP4FileHandle fileHandle, MP4TrackId videoTrack); -NSString* getHumanReadableTrackMediaDataName(MP4FileHandle fileHandle, MP4TrackId videoTrack); +FourCharCode getHumanReadableTrackMediaDataName(MP4FileHandle fileHandle, MP4TrackId Id); NSString* getHumanReadableTrackLanguage(MP4FileHandle fileHandle, MP4TrackId videoTrack); NSString* getFilenameLanguage(CFStringRef filename); diff --git a/MP42/MP42PrivateUtilities.m b/MP42/MP42PrivateUtilities.m index 840421c..5684dbc 100644 --- a/MP42/MP42PrivateUtilities.m +++ b/MP42/MP42PrivateUtilities.m @@ -173,7 +173,7 @@ uint16_t getFixedVideoWidth(MP4FileHandle fileHandle, MP4TrackId Id) return videoWidth; } -NSString* getTrackName(MP4FileHandle fileHandle, MP4TrackId Id) +NSString * getTrackName(MP4FileHandle fileHandle, MP4TrackId Id) { char *trackName; @@ -206,67 +206,71 @@ NSString* getTrackName(MP4FileHandle fileHandle, MP4TrackId Id) return NSLocalizedString(@"Unknown Track", @"Unknown Track"); } -NSString* getHumanReadableTrackMediaDataName(MP4FileHandle fileHandle, MP4TrackId Id) +FourCharCode getHumanReadableTrackMediaDataName(MP4FileHandle fileHandle, MP4TrackId Id) { const char* type = MP4GetTrackType(fileHandle, Id); const char* dataName = MP4GetTrackMediaDataName(fileHandle, Id); if (dataName) { - if (!strcmp(dataName, "avc1")) - return MP42VideoFormatH264; - else if (!strcmp(dataName, "hev1")) - return MP42VideoFormatH265; + if (!strcmp(dataName, "avc1")) { + return kMP42VideoCodecType_H264; + } + else if (!strcmp(dataName, "hev1")) { + return kMP42VideoCodecType_HEVC_2; + } else if (!strcmp(dataName, "mp4a")) { uint8_t audiotype = MP4GetTrackEsdsObjectTypeId(fileHandle, Id); if (audiotype == MP4_MPEG4_AUDIO_TYPE) - return MP42AudioFormatAAC; + return kMP42AudioCodecType_MPEG4AAC; else if (audiotype == MP4_MPEG2_AUDIO_TYPE) - return MP42AudioFormatMP3; + return kMP42AudioCodecType_MPEGLayer3; else if (audiotype == 0xA9) - return MP42AudioFormatDTS; + return kMP42AudioCodecType_DTS; } else if (!strcmp(dataName, "alac")) - return MP42AudioFormatALAC; + return kMP42AudioCodecType_AppleLossless; else if (!strcmp(dataName, "ac-3")) - return MP42AudioFormatAC3; + return kMP42AudioCodecType_AC3; else if (!strcmp(dataName, "ec-3")) - return MP42AudioFormatEAC3; + return kMP42AudioCodecType_EnhancedAC3; else if (!strcmp(dataName, "mp4v")) - return MP42VideoFormatMPEG4Visual; + return kMP42VideoCodecType_MPEG4Video; else if (!strcmp(dataName, "text")) - return MP42SubtitleFormatText; + return kMP42SubtitleCodecType_Text; else if (!strcmp(dataName, "tx3g")) - return MP42SubtitleFormatTx3g; + return kMP42SubtitleCodecType_3GText; else if (!strcmp(dataName, "wvtt")) - return MP42SubtitleFormatWebVTT; + return kMP42SubtitleCodecType_WebVTT; else if (!strcmp(dataName, "c608")) - return MP42ClosedCaptionFormatCEA608; + return kMP42ClosedCaptionCodecType_CEA608; else if (!strcmp(dataName, "c708")) - return MP42ClosedCaptionFormatCEA708; + return kMP42ClosedCaptionCodecType_CEA708; else if (!strcmp(dataName, "samr")) - return MP42AudioFormatAMR; + return kMP42AudioCodecType_AMR; else if (!strcmp(dataName, "jpeg")) - return MP42VideoFormatJPEG; + return kMP42VideoCodecType_JPEG; else if (!strcmp(dataName, "rtp ")) - return @"Hint"; + return 'rtp '; else if (!strcmp(dataName, "drms")) - return MP42AudioFormatFairPlay; + return kMP42AudioCodecType_FairPlay; else if (!strcmp(dataName, "drmi")) - return MP42VideoFormatFairPlay; + return kMP42VideoCodecType_FairPlay; else if (!strcmp(dataName, "p608")) - return MP42ClosedCaptionFormatFairPlay; + return kMP42ClosedCaptionCodecType_FairPlay; else if (!strcmp(dataName, "tmcd")) - return MP42TimeCodeFormat; + return kMP42TimeCodeFormatType_TimeCode32; else if (!strcmp(dataName, "mp4s") && !strcmp(type, "subp")) - return MP42SubtitleFormatVobSub; + return kMP42SubtitleCodecType_PGS; - else - return [NSString stringWithUTF8String:dataName]; + else { + // FIXME + return kMP42MediaType_Unknown; + } } - return @"Unknown"; + return kMP42MediaType_Unknown; } -NSString* getHumanReadableTrackLanguage(MP4FileHandle fileHandle, MP4TrackId Id) +NSString * getHumanReadableTrackLanguage(MP4FileHandle fileHandle, MP4TrackId Id) { NSString *language; char lang[4] = ""; @@ -278,7 +282,7 @@ NSString* getHumanReadableTrackLanguage(MP4FileHandle fileHandle, MP4TrackId Id) // if the subtitle filename is something like title.en.srt or movie.fre.srt // this function detects it and returns the subtitle language -NSString* getFilenameLanguage(CFStringRef filename) +NSString * getFilenameLanguage(CFStringRef filename) { CFRange findResult; CFStringRef baseName = NULL; diff --git a/MP42/MP42SrtImporter.m b/MP42/MP42SrtImporter.m index be8c49d..f89cae4 100644 --- a/MP42/MP42SrtImporter.m +++ b/MP42/MP42SrtImporter.m @@ -35,7 +35,7 @@ MP42SubtitleTrack *newTrack = [[MP42SubtitleTrack alloc] init]; - newTrack.format = MP42SubtitleFormatTx3g; + newTrack.format = kMP42SubtitleCodecType_3GText; newTrack.sourceURL = self.fileURL; newTrack.alternate_group = 2; newTrack.language = getFilenameLanguage((CFStringRef)self.fileURL.path); diff --git a/MP42/MP42SubUtilities.h b/MP42/MP42SubUtilities.h index 33cae4e..dcccda2 100644 --- a/MP42/MP42SubUtilities.h +++ b/MP42/MP42SubUtilities.h @@ -20,8 +20,8 @@ unsigned top; unsigned forced; } --(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e; --(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e top_pos:(unsigned)p forced:(unsigned)f; +-(instancetype)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e; +-(instancetype)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e top_pos:(unsigned)p forced:(unsigned)f; @end @interface SBSubSerializer : NSObject diff --git a/MP42/MP42SubUtilities.m b/MP42/MP42SubUtilities.m index 24d95f3..1d3aa6e 100644 --- a/MP42/MP42SubUtilities.m +++ b/MP42/MP42SubUtilities.m @@ -11,7 +11,8 @@ #import "MP42HtmlParser.h" @implementation SBSubSerializer --(id)init + +-(instancetype)init { if ((self = [super init])) { lines = [[NSMutableArray alloc] init]; @@ -41,15 +42,6 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b, return kCFCompareEqualTo; } -/*static int cmp_uint(const void *a, const void *b) -{ - unsigned av = *(unsigned*)a, bv = *(unsigned*)b; - - if (av > bv) return 1; - if (av < bv) return -1; - return 0; -}*/ - -(void)addLine:(SBSubLine *)line { if (line->begin_time >= line->end_time) { @@ -198,10 +190,12 @@ canOutput: { return [NSString stringWithFormat:@"lines left: %lu finished inputting: %d",(unsigned long)[lines count],finished]; } + @end @implementation SBSubLine --(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e + +-(instancetype)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e { if ((self = [super init])) { if ([l characterAtIndex:[l length]-1] != '\n') l = [l stringByAppendingString:@"\n"]; @@ -234,6 +228,7 @@ canOutput: { return [NSString stringWithFormat:@"\"%@\", from %d s to %d s",[line substringToIndex:[line length]-1],begin_time,end_time]; } + @end unsigned ParseSubTime(const char *time, unsigned secondScale, BOOL hasSign) diff --git a/MP42/MP42SubtitleTrack.m b/MP42/MP42SubtitleTrack.m index 822098f..7f40d82 100644 --- a/MP42/MP42SubtitleTrack.m +++ b/MP42/MP42SubtitleTrack.m @@ -28,9 +28,9 @@ if (self) { - _mediaType = MP42MediaTypeSubtitle; + _mediaType = kMP42MediaType_Subtitle; - if (![_format isEqualToString:MP42SubtitleFormatVobSub]) { + if (_format != kMP42SubtitleCodecType_VobSub) { uint64_t width, height; MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", &width); @@ -71,8 +71,8 @@ { if ((self = [super init])) { _name = [self defaultName]; - _format = MP42SubtitleFormatTx3g; - _mediaType = MP42MediaTypeSubtitle; + _format = kMP42SubtitleCodecType_3GText; + _mediaType = kMP42MediaType_Subtitle; } return self; @@ -134,7 +134,7 @@ [super writeToFile:fileHandle error:outError]; } - if (![_format isEqualToString:MP42SubtitleFormatVobSub]) { + if (_format != kMP42SubtitleCodecType_VobSub) { MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", self.trackHeight); MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", self.trackWidth); @@ -452,7 +452,7 @@ static void insertTagsFromStyleRecord(style_record record, NSMutableString *samp } - (NSString *)defaultName { - return MP42MediaTypeSubtitle; + return @"Subtitles Track"; } - (void)dealloc diff --git a/MP42/MP42Track.h b/MP42/MP42Track.h index abe15d6..82f1f0b 100644 --- a/MP42/MP42Track.h +++ b/MP42/MP42Track.h @@ -19,9 +19,9 @@ NS_ASSUME_NONNULL_BEGIN MP42TrackId _trackId; NSURL *_sourceURL; - NSString *_format; - NSString *_sourceFormat; - NSString *_mediaType; + FourCharCode _format; + FourCharCode _sourceFormat; + MP42MediaType _mediaType; NSString *_name; NSString *_language; @@ -44,9 +44,9 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readwrite) MP42TrackId sourceId; @property(nonatomic, readwrite, copy) NSURL *sourceURL; -@property(nonatomic, readwrite, copy) NSString *format; -@property(nonatomic, readwrite, copy) NSString *sourceFormat; -@property(nonatomic, readonly, copy) NSString *mediaType; +@property(nonatomic, readwrite) FourCharCode format; +@property(nonatomic, readwrite) FourCharCode sourceFormat; +@property(nonatomic, readonly) MP42MediaType mediaType; @property(nonatomic, readwrite, copy) NSString *name; @property(nonatomic, readwrite, copy) NSString *language; diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index b29dc2d..4fd56d7 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -50,7 +50,7 @@ _updatedProperty = [[NSMutableDictionary alloc] init]; if (fileHandle) { - _format = [getHumanReadableTrackMediaDataName(fileHandle, _trackId) retain]; + _format = getHumanReadableTrackMediaDataName(fileHandle, _trackId); _name = [getTrackName(fileHandle, _trackId) retain]; _language = [getHumanReadableTrackLanguage(fileHandle, _trackId) retain]; @@ -131,8 +131,8 @@ copy->_sourceId = _sourceId; copy->_sourceURL = [_sourceURL retain]; - copy->_sourceFormat = [_sourceFormat copy]; - copy->_format = [_format copy]; + copy->_sourceFormat = _sourceFormat; + copy->_format = _format; copy->_name = [_name copy]; copy->_language = [_language copy]; copy->_extendedLanguageTag = [_extendedLanguageTag copy]; @@ -336,7 +336,7 @@ - (NSString *)formatSummary { - return [[_format retain] autorelease]; + return @(FourCC2Str(_format)); } - (void)encodeWithCoder:(NSCoder *)coder @@ -367,8 +367,8 @@ [coder encodeObject:_sourceURL forKey:@"sourceURL"]; #endif - [coder encodeObject:_sourceFormat forKey:@"sourceFormat"]; - [coder encodeObject:_format forKey:@"format"]; + [coder encodeInteger:_sourceFormat forKey:@"sourceFormat"]; + [coder encodeInteger:_format forKey:@"format"]; [coder encodeObject:_name forKey:@"name"]; [coder encodeObject:_language forKey:@"language"]; [coder encodeObject:_extendedLanguageTag forKey:@"extendedLanguageTag"]; @@ -415,8 +415,8 @@ _sourceURL = [[decoder decodeObjectForKey:@"sourceURL"] retain]; } - _sourceFormat = [[decoder decodeObjectForKey:@"sourceFormat"] retain]; - _format = [[decoder decodeObjectForKey:@"format"] retain]; + _sourceFormat = [decoder decodeIntegerForKey:@"sourceFormat"]; + _format = [decoder decodeIntegerForKey:@"format"]; _name = [[decoder decodeObjectForKey:@"name"] retain]; _language = [[decoder decodeObjectForKey:@"language"] retain]; _extendedLanguageTag = [[decoder decodeObjectForKey:@"extendedLanguageTag"] retain]; @@ -462,13 +462,10 @@ [_updatedProperty release]; [_mediaCharacteristicTags release]; - [_format release]; [_sourceURL release]; [_name release]; [_language release]; [_extendedLanguageTag release]; - [_mediaType release]; - [_sourceFormat release]; [super dealloc]; } diff --git a/MP42/MP42Utilities.h b/MP42/MP42Utilities.h index 0051327..8014132 100644 --- a/MP42/MP42Utilities.h +++ b/MP42/MP42Utilities.h @@ -13,8 +13,8 @@ NS_ASSUME_NONNULL_BEGIN NSString * StringFromTime(long long time, long timeScale); MP42Duration TimeFromString(NSString *SMPTE_string, MP42Duration timeScale); -BOOL isTrackMuxable(NSString * formatName); -BOOL trackNeedConversion(NSString * formatName); +BOOL isTrackMuxable(FourCharCode formatName); +BOOL trackNeedConversion(FourCharCode formatName); int isHdVideo(uint64_t width, uint64_t height); diff --git a/MP42/MP42Utilities.m b/MP42/MP42Utilities.m index 877c69f..888088d 100644 --- a/MP42/MP42Utilities.m +++ b/MP42/MP42Utilities.m @@ -36,21 +36,55 @@ MP42Duration TimeFromString(NSString *time_string, MP42Duration timeScale) return ParseSubTime(time_string.UTF8String, timeScale, NO); } -BOOL isTrackMuxable(NSString *formatName) +BOOL isTrackMuxable(FourCharCode format) { - NSArray *supportedFormats = @[MP42VideoFormatH265, MP42VideoFormatH264, MP42VideoFormatMPEG4Visual, MP42AudioFormatAAC, MP42AudioFormatHEAAC, MP42AudioFormatALAC, - MP42AudioFormatAC3, MP42AudioFormatEAC3, MP42AudioFormatDTS, MP42SubtitleFormatTx3g, MP42SubtitleFormatText, - MP42ClosedCaptionFormatCEA608, MP42VideoFormatJPEG, MP42SubtitleFormatVobSub, MP42SubtitleFormatWebVTT]; + FourCharCode supportedFormats[] = {kMP42VideoCodecType_HEVC, + kMP42VideoCodecType_H264, + kMP42VideoCodecType_MPEG4Video, + kMP42VideoCodecType_JPEG, + kMP42AudioCodecType_MPEG4AAC, + kMP42AudioCodecType_MPEG4AAC_HE, + kMP42AudioCodecType_AppleLossless, + kMP42AudioCodecType_AC3, + kMP42AudioCodecType_EnhancedAC3, + kMP42AudioCodecType_DTS, + kMP42SubtitleCodecType_3GText, + kMP42SubtitleCodecType_Text, + kMP42ClosedCaptionCodecType_CEA608, + kMP42VideoCodecType_JPEG, + kMP42SubtitleCodecType_VobSub, + kMP42SubtitleCodecType_WebVTT, + 0}; - return [supportedFormats containsObject:formatName]; + for (FourCharCode *currentFormat = supportedFormats; *currentFormat; currentFormat++) { + if (*currentFormat == format) { + return YES; + } + } + + return NO; } -BOOL trackNeedConversion(NSString *formatName) { - NSArray *supportedConversionFormats = @[MP42AudioFormatVorbis, MP42AudioFormatFLAC, MP42AudioFormatMP1, MP42AudioFormatMP2, MP42AudioFormatMP3, MP42AudioFormatOpus, - MP42AudioFormatTrueHD, MP42SubtitleFormatSSA, MP42SubtitleFormatText, MP42SubtitleFormatPGS]; +BOOL trackNeedConversion(FourCharCode format) { + FourCharCode supportedConversionFormats[] = {kMP42AudioCodecType_Vorbis, + kMP42AudioCodecType_FLAC, + kMP42AudioCodecType_MPEGLayer1, + kMP42AudioCodecType_MPEGLayer2, + kMP42AudioCodecType_MPEGLayer3, + kMP42AudioCodecType_Opus, + kMP42AudioCodecType_TrueHD, + kMP42SubtitleCodecType_SSA, + kMP42SubtitleCodecType_Text, + kMP42SubtitleCodecType_PGS, + 0}; - return [supportedConversionFormats containsObject:formatName]; -} + for (FourCharCode *currentFormat = supportedConversionFormats; *currentFormat; currentFormat++) { + if (*currentFormat == format) { + return YES; + } + } + + return NO;} int isHdVideo(uint64_t width, uint64_t height) { diff --git a/MP42/MP42VideoTrack.m b/MP42/MP42VideoTrack.m index 44610c5..a95da0a 100644 --- a/MP42/MP42VideoTrack.m +++ b/MP42/MP42VideoTrack.m @@ -46,7 +46,7 @@ width = MP4GetTrackVideoWidth(fileHandle, _trackId); } - _mediaType = MP42MediaTypeVideo; + _mediaType = kMP42MediaType_Video; MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", &trackWidth); MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", &trackHeight); @@ -82,7 +82,7 @@ MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", &vertOffD); } - if ([_format isEqualToString:MP42VideoFormatH264]) { + if (_format == kMP42VideoCodecType_H264) { MP4GetTrackH264ProfileLevel(fileHandle, (MP4TrackId)trackID, &_origProfile, &_origLevel); _newProfile = _origProfile; _newLevel = _origLevel; @@ -97,7 +97,7 @@ if ((self = [super init])) { _name = [self defaultName]; _language = @"Unknown"; - _mediaType = MP42MediaTypeVideo; + _mediaType = kMP42MediaType_Video; } return self; @@ -160,7 +160,7 @@ horizOffN, horizOffD, vertOffN, vertOffD); } - if ([_format isEqualToString:MP42VideoFormatH264]) { + if (_format == kMP42VideoCodecType_H264) { if (_updatedProperty[@"profile"]) { MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*[0].avcC.AVCProfileIndication", _newProfile); _origProfile = _newProfile; @@ -177,7 +177,7 @@ } - (NSString *)defaultName { - return MP42MediaTypeVideo; + return @"Video Track"; } @synthesize width; diff --git a/MP42/MP42VobSubImporter.m b/MP42/MP42VobSubImporter.m index 6a27f3b..9c0ba1a 100644 --- a/MP42/MP42VobSubImporter.m +++ b/MP42/MP42VobSubImporter.m @@ -238,7 +238,7 @@ static NSArray * LoadVobSubSubtitles(NSURL *theDirectory, NSStr for (SBVobSubTrack *track in _VobSubTracks) { MP42SubtitleTrack *newTrack = [[MP42SubtitleTrack alloc] init]; - newTrack.format = MP42SubtitleFormatVobSub; + newTrack.format = kMP42SubtitleCodecType_VobSub; newTrack.sourceURL = self.fileURL; newTrack.alternate_group = 2; newTrack.trackId = count++; diff --git a/MP42/MP42XMLReader.h b/MP42/MP42XMLReader.h index 23139ee..3622b7f 100644 --- a/MP42/MP42XMLReader.h +++ b/MP42/MP42XMLReader.h @@ -12,9 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @class MP42Metadata; -@interface MP42XMLReader : NSObject { - MP42Metadata *mMetadata; -} +@interface MP42XMLReader : NSObject - (instancetype)initWithURL:(NSURL *)url error:(NSError **)error; diff --git a/MP42/MP42XMLReader.m b/MP42/MP42XMLReader.m index c277b22..f71602e 100644 --- a/MP42/MP42XMLReader.m +++ b/MP42/MP42XMLReader.m @@ -11,22 +11,20 @@ @implementation MP42XMLReader -@synthesize mMetadata; - - (instancetype)initWithURL:(NSURL *)url error:(NSError **)error { if (self = [super init]) { NSXMLDocument *xml = [[NSXMLDocument alloc] initWithContentsOfURL:url options:0 error:NULL]; if (xml) { NSError *err; - mMetadata = [[MP42Metadata alloc] init]; + _mMetadata = [[MP42Metadata alloc] init]; NSArray *nodes = [xml nodesForXPath:@"./movie" error:&err]; if ([nodes count] == 1) - [self metadata:mMetadata forNode:[nodes objectAtIndex:0]]; + [self metadata:_mMetadata forNode:[nodes objectAtIndex:0]]; nodes = [xml nodesForXPath:@"./video" error:&err]; if ([nodes count] == 1) - [self metadata2:mMetadata forNode:[nodes objectAtIndex:0]]; + [self metadata2:_mMetadata forNode:[nodes objectAtIndex:0]]; } [xml release]; } @@ -127,7 +125,7 @@ - (void)dealloc { - [mMetadata release]; + [_mMetadata release]; [super dealloc]; } diff --git a/MP42Foundation.xcodeproj/project.pbxproj b/MP42Foundation.xcodeproj/project.pbxproj index b995048..d80d912 100644 --- a/MP42Foundation.xcodeproj/project.pbxproj +++ b/MP42Foundation.xcodeproj/project.pbxproj @@ -1218,6 +1218,7 @@ ); MACOSX_DEPLOYMENT_TARGET = 10.9; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = ""; @@ -1267,6 +1268,7 @@ ); MACOSX_DEPLOYMENT_TARGET = 10.9; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = "";