diff --git a/MP42/MP42File.h b/MP42/MP42File.h index d4732dc..da5f7f0 100644 --- a/MP42/MP42File.h +++ b/MP42/MP42File.h @@ -119,18 +119,11 @@ typedef void (^MP42FileProgressHandler)(double progress); - (void)addTrack:(MP42Track *)track; /** - * Removes a track at the index. + * Removes the passed tracks. * - * @param index The track index. + * @param tracks A NSArray of tracks. */ -- (void)removeTrackAtIndex:(NSUInteger)index; - -/** - * Removes the tracks at the passed indexes. - * - * @param indexes A NSIndexSet of indexes. - */ -- (void)removeTracksAtIndexes:(NSIndexSet *)indexes; +- (void)removeTracks:(NSArray *)tracks; - (void)moveTrackAtIndex:(NSUInteger)index toIndex:(NSUInteger)newIndex; diff --git a/MP42/MP42File.m b/MP42/MP42File.m index cb3de9c..43e9cd5 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -482,16 +482,10 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { [self.itracks addObject:track]; } -- (void)removeTrackAtIndex:(NSUInteger)index { +- (void)removeTracks:(NSArray *)tracks { NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to remove a track while the file is open for writing"); - [self removeTracksAtIndexes:[NSIndexSet indexSetWithIndex:index]]; -} - -- (void)removeTracksAtIndexes:(NSIndexSet *)indexes { - NSUInteger index = [indexes firstIndex]; - while (index != NSNotFound) { - MP42Track *track = [self.itracks objectAtIndex:index]; + for (MP42Track *track in tracks) { // track is muxed, it needs to be removed from the file if (track.muxed) [_tracksToBeDeleted addObject:track]; @@ -511,10 +505,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { a.forcedTrack = nil; } } - index = [indexes indexGreaterThanIndex:index]; } - [self.itracks removeObjectsAtIndexes:indexes]; + [self.itracks removeObjectsInArray:tracks]; } - (void)moveTrackAtIndex:(NSUInteger)index toIndex:(NSUInteger)newIndex { diff --git a/MP42/MP42Track.h b/MP42/MP42Track.h index 5f3018f..4f06c22 100644 --- a/MP42/MP42Track.h +++ b/MP42/MP42Track.h @@ -48,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSString *timeString; @property (nonatomic, readonly) NSString *formatSummary; +- (BOOL)exportToURL:(NSURL *)url error:(NSError * __autoreleasing *)error; + @end NS_ASSUME_NONNULL_END diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index cefddb5..993e70a 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -323,6 +323,11 @@ return localizedDisplayName(_mediaType, self.targetFormat); } +- (BOOL)exportToURL:(NSURL *)url error:(NSError * __autoreleasing *)error +{ + return YES; +} + #pragma mark - NSSecureCoding + (BOOL)supportsSecureCoding