diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 184f3c6..0ce1154 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -13,6 +13,10 @@ #import "MP42File.h" #import "MP42Image.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + #import #import diff --git a/MP42/MP42AudioConverter.m b/MP42/MP42AudioConverter.m index 0201ea8..fa90ca0 100644 --- a/MP42/MP42AudioConverter.m +++ b/MP42/MP42AudioConverter.m @@ -14,15 +14,10 @@ #import "MP42Fifo.h" #import "MP42Utilities.h" -#import "MP42Track_Muxer.h" +#import "MP42Track+Muxer.h" #define FIFO_DURATION (0.5f) -NSString * const SBMonoMixdown = @"SBMonoMixdown"; -NSString * const SBStereoMixdown = @"SBStereoMixdown"; -NSString * const SBDolbyMixdown = @"SBDolbyMixdown"; -NSString * const SBDolbyPlIIMixdown = @"SBDolbyPlIIMixdown"; - @interface NSString (VersionStringCompare) - (BOOL)isVersionStringOlderThan:(NSString *)older; @end diff --git a/MP42/MP42BitmapSubConverter.m b/MP42/MP42BitmapSubConverter.m index 05b6314..810d44d 100644 --- a/MP42/MP42BitmapSubConverter.m +++ b/MP42/MP42BitmapSubConverter.m @@ -14,6 +14,10 @@ #import "MP42OCRWrapper.h" #import "MP42SubUtilities.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + #define REGISTER_DECODER(x) { \ extern AVCodec ff_##x##_decoder; \ avcodec_register(&ff_##x##_decoder); } diff --git a/MP42/MP42File.m b/MP42/MP42File.m index 0710c0f..23c1212 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -12,6 +12,7 @@ #import "MP42SubUtilities.h" #import "MP42Utilities.h" #import "MP42Languages.h" +#import "MP42Track+Muxer.h" #import @@ -27,6 +28,46 @@ NSString * const MP42GenerateChaptersPreviewTrack = @"MP42ChaptersPreview"; NSString * const MP42CustomChaptersPreviewTrack = @"MP42CustomChaptersPreview"; NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups"; +static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap) +{ + const char* level; + + if ([[NSUserDefaults standardUserDefaults] valueForKey:@"Debug"]) { + switch (loglevel) { + case 0: + level = "None"; + break; + case 1: + level = "Error"; + break; + case 2: + level = "Warning"; + break; + case 3: + level = "Info"; + break; + case 4: + level = "Verbose1"; + break; + case 5: + level = "Verbose2"; + break; + case 6: + level = "Verbose3"; + break; + case 7: + level = "Verbose4"; + break; + default: + level = "Unknown"; + break; + } + printf("%s: ", level); + vprintf(fmt, ap); + printf("\n"); + } +} + @interface MP42File () { MP4FileHandle _fileHandle; NSURL *_fileURL; @@ -55,9 +96,7 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups"; @end -@implementation MP42File { - -} +@implementation MP42File - (id)init { diff --git a/MP42/MP42FileImporter.h b/MP42/MP42FileImporter.h index c299237..de912fe 100644 --- a/MP42/MP42FileImporter.h +++ b/MP42/MP42FileImporter.h @@ -9,12 +9,8 @@ #import #import +#import "MP42MediaFormat.h" #import "MP42Sample.h" -#import "MP42Utilities.h" - -#import "mp4v2.h" - -#import "MP42Track_Muxer.h" @class MP42Sample; @class MP42Metadata; diff --git a/MP42/MP42FileImporter.m b/MP42/MP42FileImporter.m index 187de36..89700b0 100644 --- a/MP42/MP42FileImporter.m +++ b/MP42/MP42FileImporter.m @@ -18,15 +18,17 @@ #import "MP42Track.h" #import "MP42Fifo.h" -#import "MP42Track_Muxer.h" - #if !__LP64__ #import "MP42QTImporter.h" #endif #import "MP42AVFImporter.h" -#include "MP42AudioConverter.h" +#import "MP42AudioConverter.h" + +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" @implementation MP42FileImporter diff --git a/MP42/MP42H264Importer.h b/MP42/MP42H264Importer.h index 9c832a0..d9cc41f 100644 --- a/MP42/MP42H264Importer.h +++ b/MP42/MP42H264Importer.h @@ -9,6 +9,10 @@ #import #import "MP42FileImporter.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + typedef struct framerate_t { uint32_t code; uint32_t timescale; diff --git a/MP42/MP42MediaFormat.h b/MP42/MP42MediaFormat.h index 3ce08cf..fc5360a 100644 --- a/MP42/MP42MediaFormat.h +++ b/MP42/MP42MediaFormat.h @@ -8,7 +8,7 @@ #import -/* MP4 API types */ +/* MP4 primitive types */ typedef void* MP42FileHandle; typedef uint32_t MP42TrackId; typedef uint64_t MP42Duration; @@ -75,4 +75,10 @@ extern NSString *const MP42ClosedCaptionFormatCEA708; // TimeCode Format -extern NSString *const MP42TimeCodeFormat; \ No newline at end of file +extern NSString *const MP42TimeCodeFormat; + +// Audio downmixes +extern NSString * const SBMonoMixdown; +extern NSString * const SBStereoMixdown; +extern NSString * const SBDolbyMixdown; +extern NSString * const SBDolbyPlIIMixdown; \ No newline at end of file diff --git a/MP42/MP42MediaFormat.m b/MP42/MP42MediaFormat.m index 81af0be..e45b345 100644 --- a/MP42/MP42MediaFormat.m +++ b/MP42/MP42MediaFormat.m @@ -69,4 +69,10 @@ NSString *const MP42ClosedCaptionFormatCEA708 = @"CEA-708"; // TimeCode Format -NSString *const MP42TimeCodeFormat = @"TimeCode"; \ No newline at end of file +NSString *const MP42TimeCodeFormat = @"TimeCode"; + +// Audio Downmixes +NSString * const SBMonoMixdown = @"SBMonoMixdown"; +NSString * const SBStereoMixdown = @"SBStereoMixdown"; +NSString * const SBDolbyMixdown = @"SBDolbyMixdown"; +NSString * const SBDolbyPlIIMixdown = @"SBDolbyPlIIMixdown"; \ No newline at end of file diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index 62cba9f..245bd91 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -16,6 +16,10 @@ #import "MatroskaFile.h" #include "avutil.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + u_int32_t MP4AV_Ac3GetSamplingRate(u_int8_t* pHdr); @interface MatroskaSample : NSObject { diff --git a/MP42/MP42Mp4Importer.m b/MP42/MP42Mp4Importer.m index f7a68bf..6bd8d1a 100644 --- a/MP42/MP42Mp4Importer.m +++ b/MP42/MP42Mp4Importer.m @@ -10,6 +10,10 @@ #import "MP42Languages.h" #import "MP42Sample.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + @interface MP4DemuxkHelper : NSObject { @public MP4SampleId currentSampleId; diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index 20a951f..522a302 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -13,6 +13,10 @@ #import "MP42AudioConverter.h" #import "MP42BitmapSubConverter.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + @implementation MP42Muxer - (instancetype)init diff --git a/MP42/MP42SrtImporter.m b/MP42/MP42SrtImporter.m index 08195b2..54d772c 100644 --- a/MP42/MP42SrtImporter.m +++ b/MP42/MP42SrtImporter.m @@ -12,6 +12,10 @@ #import "MP42SubUtilities.h" #import "MP42Languages.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" + @implementation MP42SrtImporter - (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError diff --git a/MP42/MP42Track_Muxer.h b/MP42/MP42Track+Muxer.h similarity index 100% rename from MP42/MP42Track_Muxer.h rename to MP42/MP42Track+Muxer.h diff --git a/MP42/MP42Track.h b/MP42/MP42Track.h index ff91b51..b9fdcfb 100644 --- a/MP42/MP42Track.h +++ b/MP42/MP42Track.h @@ -40,6 +40,8 @@ MP42Duration _duration; NSMutableDictionary *_updatedProperty; + + void *_helper; } - (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index 5ffb38c..a9fa1e6 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -13,14 +13,7 @@ #import "MP42Fifo.h" #import "MP42Languages.h" -#import "MP42Track_Muxer.h" - -@interface MP42Track () { - - muxer_helper *_helper; -} - -@end +#import "MP42Track+Muxer.h" @implementation MP42Track @@ -93,10 +86,10 @@ [copy->_updatedProperty release]; copy->_updatedProperty = [_updatedProperty mutableCopy]; - if (_helper) { + /*if (_helper) { copy->_helper = calloc(1, sizeof(muxer_helper)); copy->_helper->importer = _helper->importer; - } + }*/ } return copy; @@ -352,21 +345,22 @@ - (MP42SampleBuffer *)copyNextSample { MP42SampleBuffer *sample = nil; + muxer_helper * helper = (muxer_helper *)_helper; - if (_helper->converter) { - if ([_helper->importer done]) - [_helper->converter setInputDone]; + if (helper->converter) { + if ([helper->importer done]) + [helper->converter setInputDone]; - if ([_helper->converter encoderDone]) - _helper->done = YES; + if ([helper->converter encoderDone]) + helper->done = YES; - sample = [_helper->converter copyEncodedSample]; + sample = [helper->converter copyEncodedSample]; } else { - if ([_helper->fifo isEmpty] && [_helper->importer done]) - _helper->done = YES; + if ([helper->fifo isEmpty] && [helper->importer done]) + helper->done = YES; - if ([_helper->fifo count]) - sample = [_helper->fifo deque]; + if ([helper->fifo count]) + sample = [helper->fifo deque]; } return sample; diff --git a/MP42/MP42VobSubImporter.m b/MP42/MP42VobSubImporter.m index 06aa7cc..ecf104d 100644 --- a/MP42/MP42VobSubImporter.m +++ b/MP42/MP42VobSubImporter.m @@ -11,6 +11,9 @@ #import "MP42Languages.h" #import "MP42File.h" +#import "mp4v2.h" +#import "MP42Utilities.h" +#import "MP42Track+Muxer.h" @interface SBVobSubSample : NSObject { diff --git a/MP42Foundation.xcodeproj/project.pbxproj b/MP42Foundation.xcodeproj/project.pbxproj index 42820db..6ac1417 100644 --- a/MP42Foundation.xcodeproj/project.pbxproj +++ b/MP42Foundation.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ A947BA9B1824F0B3004C734B /* Ratings.json in Resources */ = {isa = PBXBuildFile; fileRef = A947BA9A1824F0B3004C734B /* Ratings.json */; }; - A989F1001823AB2E0070AD8C /* MP42Track_Muxer.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F0FF1823AB2E0070AD8C /* MP42Track_Muxer.h */; }; + A989F1001823AB2E0070AD8C /* MP42Track+Muxer.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F0FF1823AB2E0070AD8C /* MP42Track+Muxer.h */; }; A989F10F1823B3B40070AD8C /* MP42TextSample.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F10D1823B3B40070AD8C /* MP42TextSample.h */; settings = {ATTRIBUTES = (Public, ); }; }; A989F1101823B3B40070AD8C /* MP42TextSample.m in Sources */ = {isa = PBXBuildFile; fileRef = A989F10E1823B3B40070AD8C /* MP42TextSample.m */; }; A9B9C1F1182391DF00416A4E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9B9C1F0182391DF00416A4E /* Cocoa.framework */; }; @@ -41,7 +41,7 @@ A9B9C27A1823923200416A4E /* MP42Fifo.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C22F1823923100416A4E /* MP42Fifo.m */; }; A9B9C27B1823923200416A4E /* MP42File.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2301823923100416A4E /* MP42File.h */; settings = {ATTRIBUTES = (Public, ); }; }; A9B9C27C1823923200416A4E /* MP42File.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2311823923100416A4E /* MP42File.m */; }; - A9B9C27D1823923200416A4E /* MP42FileImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2321823923100416A4E /* MP42FileImporter.h */; }; + A9B9C27D1823923200416A4E /* MP42FileImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2321823923100416A4E /* MP42FileImporter.h */; settings = {ATTRIBUTES = (Public, ); }; }; A9B9C27E1823923200416A4E /* MP42FileImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2331823923100416A4E /* MP42FileImporter.m */; }; A9B9C27F1823923200416A4E /* MP42H264Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2341823923100416A4E /* MP42H264Importer.h */; }; A9B9C2801823923200416A4E /* MP42H264Importer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2351823923100416A4E /* MP42H264Importer.mm */; }; @@ -161,7 +161,7 @@ /* Begin PBXFileReference section */ A947BA9A1824F0B3004C734B /* Ratings.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Ratings.json; sourceTree = ""; }; - A989F0FF1823AB2E0070AD8C /* MP42Track_Muxer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42Track_Muxer.h; sourceTree = ""; }; + A989F0FF1823AB2E0070AD8C /* MP42Track+Muxer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MP42Track+Muxer.h"; sourceTree = ""; }; A989F10D1823B3B40070AD8C /* MP42TextSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42TextSample.h; sourceTree = ""; }; A989F10E1823B3B40070AD8C /* MP42TextSample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42TextSample.m; sourceTree = ""; }; A9B9C1ED182391DF00416A4E /* MP42Foundation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MP42Foundation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -464,7 +464,7 @@ children = ( A9B9C2421823923100416A4E /* MP42Muxer.h */, A9B9C2431823923100416A4E /* MP42Muxer.m */, - A989F0FF1823AB2E0070AD8C /* MP42Track_Muxer.h */, + A989F0FF1823AB2E0070AD8C /* MP42Track+Muxer.h */, A9B9C2481823923100416A4E /* MP42Sample.h */, A9B9C2491823923100416A4E /* MP42Sample.m */, A9B9C22D1823923100416A4E /* MP42ConverterProtocol.h */, @@ -571,12 +571,12 @@ A989F10F1823B3B40070AD8C /* MP42TextSample.h in Headers */, A9B9C2831823923200416A4E /* MP42Image.h in Headers */, A9B9C2C41823957800416A4E /* MP42Languages.h in Headers */, + A9B9C27D1823923200416A4E /* MP42FileImporter.h in Headers */, A9B9C2911823923200416A4E /* MP42QTImporter.h in Headers */, A9B9C28F1823923200416A4E /* MP42OCRWrapper.h in Headers */, A9B9C2811823923200416A4E /* MP42HtmlParser.h in Headers */, A9B9C2A61823923200416A4E /* downmix.h in Headers */, A9B9C2AA1823923200416A4E /* MatroskaParser.h in Headers */, - A9B9C27D1823923200416A4E /* MP42FileImporter.h in Headers */, A9B9C26E1823923200416A4E /* MP42AVFImporter.h in Headers */, A9B9C2791823923200416A4E /* MP42Fifo.h in Headers */, A9B9C2CF182396A100416A4E /* MP42Ratings.h in Headers */, @@ -598,7 +598,7 @@ A9B9C29D1823923200416A4E /* MP42Utilities.h in Headers */, A9B9C2661823923200416A4E /* MP42AACImporter.h in Headers */, A9B9C2681823923200416A4E /* MP42AC3Importer.h in Headers */, - A989F1001823AB2E0070AD8C /* MP42Track_Muxer.h in Headers */, + A989F1001823AB2E0070AD8C /* MP42Track+Muxer.h in Headers */, A9B9C26A1823923200416A4E /* MP42AudioConverter.h in Headers */, A9B9C2A11823923200416A4E /* MP42VobSubImporter.h in Headers */, A9B9C2AC1823923200416A4E /* mbs.h in Headers */, diff --git a/MP42Foundation.xcodeproj/project.xcworkspace/xcuserdata/damians.xcuserdatad/UserInterfaceState.xcuserstate b/MP42Foundation.xcodeproj/project.xcworkspace/xcuserdata/damians.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..3677a67 Binary files /dev/null and b/MP42Foundation.xcodeproj/project.xcworkspace/xcuserdata/damians.xcuserdatad/UserInterfaceState.xcuserstate differ