diff --git a/MP42/MP42File.h b/MP42/MP42File.h index 956f8e2..0f00a3d 100644 --- a/MP42/MP42File.h +++ b/MP42/MP42File.h @@ -45,7 +45,7 @@ typedef enum MP42Status : NSInteger { @class MP42Muxer; /** - * MP42File + * A MP42File object is an object that represents a mp4 file. */ @interface MP42File : NSObject { @private @@ -148,10 +148,13 @@ typedef enum MP42Status : NSInteger { /** * Add a track to the mp4 file. + * The track will be copied, the new track instance will be returned. * * @param track A MP42Track instance. + * + * @return the copied track */ -- (void)addTrack:(MP42Track *)track; +- (MP42Track *)addTrack:(MP42Track *)track; /** * Removes a track at the index. @@ -200,8 +203,30 @@ typedef enum MP42Status : NSInteger { */ - (BOOL)optimize; +/** + * Exports a MP42File object. + * + * @param url An NSURL object that specifies a url to a file. + * @param attributes An NSDictionary object that specifies the desired operation and its options, + * @param outError A pointer to an NSError object; if the operation fails, an NSError object is returned in this location. + * + * @return YES if the movie file was successfully created, NO otherwise. + */ - (BOOL)writeToUrl:(NSURL *)url withAttributes:(NSDictionary *)attributes error:(NSError **)outError; + +/** + * Updates a MP42File object. + * + * @param attributes An NSDictionary object that specifies the desired operation and its options. + * @param outError A pointer to an NSError object; if the operation fails, an NSError object is returned in this location. + * + * @return YES if the movie file was successfully created, NO otherwise. + */ - (BOOL)updateMP4FileWithAttributes:(NSDictionary *)attributes error:(NSError **)outError; + +/** + * Cancels a write/update operation. + */ - (void)cancel; @end diff --git a/MP42/MP42File.m b/MP42/MP42File.m index bd82e60..110e758 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -365,10 +365,12 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { #pragma mark - Editing -- (void)addTrack:(MP42Track *)track { +- (MP42Track *)addTrack:(MP42Track *)track { NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to add a track while the file is open for writing"); NSAssert(![self.itracks containsObject:track], @"Unsupported operation: trying to add a track that is already present."); + track = [track copy]; + track.sourceId = track.Id; track.Id = 0; track.muxed = NO; @@ -408,6 +410,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { } [self.itracks addObject:track]; + [track release]; + + return track; } - (void)removeTrackAtIndex:(NSUInteger)index {