Convert MP42FileImporter to ARC, and clean up some imports.
This commit is contained in:
13 files changed
+225
-262
No files matched your search
@@ -13,7 +13,6 @@
|
|||||||
#import "MP42File.h"
|
#import "MP42File.h"
|
||||||
#import "MP42PrivateUtilities.h"
|
#import "MP42PrivateUtilities.h"
|
||||||
#import "MP42FormatUtilites.h"
|
#import "MP42FormatUtilites.h"
|
||||||
#import "MP42Fifo.h"
|
|
||||||
#import "MP42Sample.h"
|
#import "MP42Sample.h"
|
||||||
#import "MP42Track+Private.h"
|
#import "MP42Track+Private.h"
|
||||||
|
|
||||||
|
|||||||
+47
-38
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
@implementation MP42AVFImporter {
|
@implementation MP42AVFImporter {
|
||||||
AVAsset *_localAsset;
|
AVAsset *_localAsset;
|
||||||
|
NSMutableArray<AVFDemuxHelper *> *_helpers;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray<NSString *> *)supportedFileFormats {
|
+ (NSArray<NSString *> *)supportedFileFormats {
|
||||||
@@ -82,6 +83,7 @@
|
|||||||
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError {
|
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError {
|
||||||
if ((self = [super initWithURL:fileURL])) {
|
if ((self = [super initWithURL:fileURL])) {
|
||||||
_localAsset = [AVAsset assetWithURL:self.fileURL];
|
_localAsset = [AVAsset assetWithURL:self.fileURL];
|
||||||
|
_helpers = [NSMutableArray array];
|
||||||
|
|
||||||
NSArray<AVAssetTrack *> *tracks = [_localAsset tracks];
|
NSArray<AVAssetTrack *> *tracks = [_localAsset tracks];
|
||||||
CMTime globaDuration = _localAsset.duration;
|
CMTime globaDuration = _localAsset.duration;
|
||||||
@@ -920,8 +922,8 @@
|
|||||||
demuxHelper->assetReaderOutput = assetReaderOutput;
|
demuxHelper->assetReaderOutput = assetReaderOutput;
|
||||||
demuxHelper->editsConstructor = [[MP42EditListsReconstructor alloc] init];
|
demuxHelper->editsConstructor = [[MP42EditListsReconstructor alloc] init];
|
||||||
|
|
||||||
track.demuxerHelper = demuxHelper;
|
|
||||||
helpers[index] = demuxHelper;
|
helpers[index] = demuxHelper;
|
||||||
|
[_helpers addObject:demuxHelper];
|
||||||
|
|
||||||
totalDataLength += track.dataLength;
|
totalDataLength += track.dataLength;
|
||||||
}
|
}
|
||||||
@@ -1175,49 +1177,56 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)cleanUp:(MP4FileHandle)fileHandle {
|
- (AVFDemuxHelper *)helperWithTrackID:(MP4TrackId)trackID
|
||||||
|
{
|
||||||
|
for (AVFDemuxHelper *helper in _helpers) {
|
||||||
|
if (helper->sourceID == trackID) {
|
||||||
|
return helper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)cleanUp:(MP42Track *)track fileHandle:(MP4FileHandle)fileHandle {
|
||||||
uint32_t timescale = MP4GetTimeScale(fileHandle);
|
uint32_t timescale = MP4GetTimeScale(fileHandle);
|
||||||
|
|
||||||
for (MP42Track *track in self.outputsTracks) {
|
MP4Duration trackDuration = 0;
|
||||||
MP4Duration trackDuration = 0;
|
MP4TrackId trackId = track.trackId;
|
||||||
MP4TrackId trackId = track.trackId;
|
|
||||||
|
|
||||||
MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId];
|
AVFDemuxHelper *helper = [self helperWithTrackID:track.sourceId];
|
||||||
|
MP42EditListsReconstructor *editsConstructor = helper->editsConstructor;
|
||||||
|
|
||||||
AVFDemuxHelper *helper = inputTrack.demuxerHelper;
|
// Make sure the sample offsets are all positive.
|
||||||
MP42EditListsReconstructor *editsConstructor = helper->editsConstructor;
|
if (editsConstructor.minOffset < 0) {
|
||||||
|
MP4SampleId samplesCount = MP4GetTrackNumberOfSamples(fileHandle, trackId);
|
||||||
// Make sure the sample offsets are all positive.
|
for (unsigned int i = 0; i < samplesCount; i++) {
|
||||||
if (editsConstructor.minOffset < 0) {
|
MP4SetSampleRenderingOffset(fileHandle,
|
||||||
MP4SampleId samplesCount = MP4GetTrackNumberOfSamples(fileHandle, trackId);
|
trackId,
|
||||||
for (unsigned int i = 0; i < samplesCount; i++) {
|
1 + i,
|
||||||
MP4SetSampleRenderingOffset(fileHandle,
|
MP4GetSampleRenderingOffset(fileHandle, trackId, 1 + i) - editsConstructor.minOffset);
|
||||||
trackId,
|
|
||||||
1 + i,
|
|
||||||
MP4GetSampleRenderingOffset(fileHandle, trackId, 1 + i) - editsConstructor.minOffset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add back the new constructed edit lists.
|
|
||||||
for (uint64_t i = 0; i < helper->editsConstructor.editsCount; i++) {
|
|
||||||
CMTimeRange timeRange = editsConstructor.edits[i];
|
|
||||||
CMTime duration = CMTimeConvertScale(timeRange.duration, timescale, kCMTimeRoundingMethod_Default);
|
|
||||||
int64_t offset = editsConstructor.minOffset < 0 ? editsConstructor.minOffset : 0;
|
|
||||||
int64_t offset2 = editsConstructor.minOffset > 0 && timeRange.start.value == 0 ? editsConstructor.minOffset : 0;
|
|
||||||
MP4Timestamp startTime = timeRange.start.value == -1 ? -1 : timeRange.start.value - offset + offset2;
|
|
||||||
|
|
||||||
MP4AddTrackEdit(fileHandle, trackId, MP4_INVALID_EDIT_ID,
|
|
||||||
startTime,
|
|
||||||
duration.value, 0);
|
|
||||||
|
|
||||||
trackDuration += duration.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackDuration) {
|
|
||||||
MP4SetTrackIntegerProperty(fileHandle, trackId, "tkhd.duration", trackDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add back the new constructed edit lists.
|
||||||
|
for (uint64_t i = 0; i < helper->editsConstructor.editsCount; i++) {
|
||||||
|
CMTimeRange timeRange = editsConstructor.edits[i];
|
||||||
|
CMTime duration = CMTimeConvertScale(timeRange.duration, timescale, kCMTimeRoundingMethod_Default);
|
||||||
|
int64_t offset = editsConstructor.minOffset < 0 ? editsConstructor.minOffset : 0;
|
||||||
|
int64_t offset2 = editsConstructor.minOffset > 0 && timeRange.start.value == 0 ? editsConstructor.minOffset : 0;
|
||||||
|
MP4Timestamp startTime = timeRange.start.value == -1 ? -1 : timeRange.start.value - offset + offset2;
|
||||||
|
|
||||||
|
MP4AddTrackEdit(fileHandle, trackId, MP4_INVALID_EDIT_ID,
|
||||||
|
startTime,
|
||||||
|
duration.value, 0);
|
||||||
|
|
||||||
|
trackDuration += duration.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trackDuration) {
|
||||||
|
MP4SetTrackIntegerProperty(fileHandle, trackId, "tkhd.duration", trackDuration);
|
||||||
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property (nonatomic, copy) NSArray<MP42Track *> *inputTracks;
|
@property (nonatomic, copy) NSArray<MP42Track *> *inputTracks;
|
||||||
@property (nonatomic, copy) NSArray<MP42Track *> *outputsTracks;
|
@property (nonatomic, copy) NSArray<MP42Track *> *outputsTracks;
|
||||||
|
|
||||||
- (MP42Track *)inputTrackWithTrackID:(MP42TrackId)trackId;
|
|
||||||
|
|
||||||
- (void)setActiveTrack:(MP42Track *)track;
|
- (void)setActiveTrack:(MP42Track *)track;
|
||||||
|
|
||||||
- (void)startReading;
|
- (void)startReading;
|
||||||
- (void)cancelReading;
|
- (void)cancelReading;
|
||||||
|
|
||||||
- (void)enqueue:(MP42SampleBuffer *)sample;
|
- (void)enqueue:(MP42SampleBuffer * NS_RELEASES_ARGUMENT)sample;
|
||||||
|
|
||||||
@property (nonatomic, readwrite) double progress;
|
@property (nonatomic, readwrite) double progress;
|
||||||
@property (nonatomic, readonly, getter=isCancelled) BOOL cancelled;
|
@property (nonatomic, readonly, getter=isCancelled) BOOL cancelled;
|
||||||
@@ -49,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (NSSize)sizeForTrack:(MP42Track *)track;
|
- (NSSize)sizeForTrack:(MP42Track *)track;
|
||||||
- (nullable NSData *)magicCookieForTrack:(MP42Track *)track;
|
- (nullable NSData *)magicCookieForTrack:(MP42Track *)track;
|
||||||
- (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42Track *)track;
|
- (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42Track *)track;
|
||||||
- (BOOL)cleanUp:(MP42FileHandle)fileHandle;
|
- (BOOL)cleanUp:(MP42Track *)track fileHandle:(MP42FileHandle)fileHandle;
|
||||||
|
|
||||||
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track;
|
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track;
|
||||||
- (BOOL)supportsPreciseTimestamps;
|
- (BOOL)supportsPreciseTimestamps;
|
||||||
|
|||||||
+14
-72
@@ -18,11 +18,8 @@
|
|||||||
#import "MP42AVFImporter.h"
|
#import "MP42AVFImporter.h"
|
||||||
|
|
||||||
#import "MP42Track.h"
|
#import "MP42Track.h"
|
||||||
#import "MP42Fifo.h"
|
|
||||||
|
|
||||||
#import "MP42AudioConverter.h"
|
|
||||||
#import "MP42Track+Muxer.h"
|
|
||||||
#import "MP42Track+Private.h"
|
#import "MP42Track+Private.h"
|
||||||
|
#import "MP42Track+Muxer.h"
|
||||||
|
|
||||||
#import "mp4v2.h"
|
#import "mp4v2.h"
|
||||||
|
|
||||||
@@ -35,9 +32,6 @@ static NSArray<Class> *_fileImporters;
|
|||||||
static NSArray<NSString *> *_supportedFileFormats;
|
static NSArray<NSString *> *_supportedFileFormats;
|
||||||
|
|
||||||
@implementation MP42FileImporter {
|
@implementation MP42FileImporter {
|
||||||
@private
|
|
||||||
NSURL *_fileURL;
|
|
||||||
|
|
||||||
NSMutableArray<MP42Track *> *_tracksArray;
|
NSMutableArray<MP42Track *> *_tracksArray;
|
||||||
|
|
||||||
NSMutableArray<MP42Track *> *_inputTracks;
|
NSMutableArray<MP42Track *> *_inputTracks;
|
||||||
@@ -53,7 +47,7 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
|
|
||||||
+ (void)initialize {
|
+ (void)initialize {
|
||||||
if (self == [MP42FileImporter class]) {
|
if (self == [MP42FileImporter class]) {
|
||||||
_fileImporters = [@[[MP42MkvImporter class],
|
_fileImporters = @[[MP42MkvImporter class],
|
||||||
[MP42Mp4Importer class],
|
[MP42Mp4Importer class],
|
||||||
[MP42SrtImporter class],
|
[MP42SrtImporter class],
|
||||||
[MP42CCImporter class],
|
[MP42CCImporter class],
|
||||||
@@ -61,7 +55,7 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
[MP42H264Importer class],
|
[MP42H264Importer class],
|
||||||
[MP42VobSubImporter class],
|
[MP42VobSubImporter class],
|
||||||
[MP42AVFImporter class],
|
[MP42AVFImporter class],
|
||||||
[MP42AC3Importer class]] retain];
|
[MP42AC3Importer class]];
|
||||||
|
|
||||||
NSMutableArray<NSString *> *formats = [[NSMutableArray alloc] init];
|
NSMutableArray<NSString *> *formats = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
@@ -70,7 +64,6 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
}
|
}
|
||||||
|
|
||||||
_supportedFileFormats = [formats copy];
|
_supportedFileFormats = [formats copy];
|
||||||
[formats release];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,19 +77,16 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
|
|
||||||
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)error;
|
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)error;
|
||||||
{
|
{
|
||||||
[self release];
|
|
||||||
self = nil;
|
self = nil;
|
||||||
|
|
||||||
// Initialize the right file importer subclass
|
// Initialize the right file importer subclass
|
||||||
for (Class c in _fileImporters) {
|
for (Class c in _fileImporters) {
|
||||||
if ([c canInitWithFileType:fileURL.pathExtension]) {
|
if ([c canInitWithFileType:fileURL.pathExtension]) {
|
||||||
|
|
||||||
[self release];
|
|
||||||
|
|
||||||
self = [[c alloc] initWithURL:fileURL error:error];
|
self = [[c alloc] initWithURL:fileURL error:error];
|
||||||
if (self) {
|
if (self) {
|
||||||
for (MP42Track *track in _tracksArray) {
|
for (MP42Track *track in _tracksArray) {
|
||||||
track.muxer_helper->importer = self;
|
track.importer = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -111,7 +101,7 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_fileURL = [fileURL retain];
|
_fileURL = fileURL;
|
||||||
_tracksArray = [[NSMutableArray alloc] init];
|
_tracksArray = [[NSMutableArray alloc] init];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@@ -120,32 +110,8 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
for (MP42Track *track in _inputTracks) {
|
for (MP42Track *track in _inputTracks) {
|
||||||
[track.muxer_helper->demuxer_context release];
|
[track free_muxer_helper];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MP42Track *track in _outputsTracks) {
|
|
||||||
[track.muxer_helper->fifo release];
|
|
||||||
[track.muxer_helper->converter release];
|
|
||||||
}
|
|
||||||
|
|
||||||
[_metadata release];
|
|
||||||
[_tracksArray release]; _tracksArray = nil;
|
|
||||||
[_inputTracks release]; _inputTracks = nil;
|
|
||||||
[_outputsTracks release]; _outputsTracks = nil;
|
|
||||||
|
|
||||||
[_fileURL release]; _fileURL = nil;
|
|
||||||
[_demuxerThread release]; _demuxerThread = nil;
|
|
||||||
|
|
||||||
if (_doneSem) {
|
|
||||||
dispatch_release(_doneSem);
|
|
||||||
}
|
|
||||||
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSURL *)fileURL
|
|
||||||
{
|
|
||||||
return _fileURL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addTrack:(MP42Track *)track
|
- (void)addTrack:(MP42Track *)track
|
||||||
@@ -160,17 +126,17 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
|
|
||||||
- (NSArray<MP42Track *> *)inputTracks
|
- (NSArray<MP42Track *> *)inputTracks
|
||||||
{
|
{
|
||||||
return [[_inputTracks copy] autorelease];
|
return [_inputTracks copy];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray<MP42Track *> *)outputsTracks
|
- (NSArray<MP42Track *> *)outputsTracks
|
||||||
{
|
{
|
||||||
return [[_outputsTracks copy] autorelease];
|
return [_outputsTracks copy];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMetadata:(MP42Metadata * _Nonnull)metadata
|
- (void)setMetadata:(MP42Metadata * _Nonnull)metadata
|
||||||
{
|
{
|
||||||
_metadata = [metadata retain];
|
_metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize tracks = _tracksArray;
|
@synthesize tracks = _tracksArray;
|
||||||
@@ -220,7 +186,7 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)cleanUp:(MP4FileHandle)fileHandle
|
- (BOOL)cleanUp:(MP42Track *)track fileHandle:(MP4FileHandle)fileHandle
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -247,10 +213,6 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
|
|
||||||
- (void)startReading
|
- (void)startReading
|
||||||
{
|
{
|
||||||
for (MP42Track *track in _outputsTracks) {
|
|
||||||
track.muxer_helper->fifo = [[MP42Fifo alloc] init];
|
|
||||||
}
|
|
||||||
|
|
||||||
_doneSem = dispatch_semaphore_create(0);
|
_doneSem = dispatch_semaphore_create(0);
|
||||||
|
|
||||||
if (!_demuxerThread) {
|
if (!_demuxerThread) {
|
||||||
@@ -274,15 +236,11 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
dispatch_semaphore_wait(_doneSem, DISPATCH_TIME_FOREVER);
|
dispatch_semaphore_wait(_doneSem, DISPATCH_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enqueue:(MP42SampleBuffer *)sample
|
- (void)enqueue:(MP42SampleBuffer * NS_RELEASES_ARGUMENT)sample
|
||||||
{
|
{
|
||||||
for (MP42Track *track in _outputsTracks) {
|
for (MP42Track *track in _outputsTracks) {
|
||||||
if (track.sourceId == sample->trackId) {
|
if (track.sourceId == sample->trackId) {
|
||||||
if (track.muxer_helper->converter) {
|
[track enqueue:sample];
|
||||||
[track.muxer_helper->converter addSample:sample];
|
|
||||||
} else {
|
|
||||||
[track.muxer_helper->fifo enqueue:sample];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,13 +253,8 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
for (MP42Track *track in _outputsTracks) {
|
for (MP42Track *track in _outputsTracks) {
|
||||||
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
|
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
|
||||||
sample->flags |= MP42SampleBufferFlagEndOfFile;
|
sample->flags |= MP42SampleBufferFlagEndOfFile;
|
||||||
|
sample->trackId = track.sourceId;
|
||||||
if (track.muxer_helper->converter) {
|
[self enqueue:sample];
|
||||||
[track.muxer_helper->converter addSample:sample];
|
|
||||||
} else {
|
|
||||||
[track.muxer_helper->fifo enqueue:sample];
|
|
||||||
}
|
|
||||||
[sample release];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,15 +279,4 @@ static NSArray<NSString *> *_supportedFileFormats;
|
|||||||
return _cancelled;
|
return _cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (MP42Track *)inputTrackWithTrackID:(MP4TrackId)trackId
|
|
||||||
{
|
|
||||||
for (MP42Track *track in _inputTracks) {
|
|
||||||
if (track.sourceId == trackId) {
|
|
||||||
return track;;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
#import "MP42H264Importer.h"
|
#import "MP42H264Importer.h"
|
||||||
#import "MP42FileImporter+Private.h"
|
#import "MP42FileImporter+Private.h"
|
||||||
|
#import "MP42Sample.h"
|
||||||
|
|
||||||
#import "MP42Languages.h"
|
#import "MP42Languages.h"
|
||||||
#import "MP42File.h"
|
#import "MP42File.h"
|
||||||
#import "MP42Track+Muxer.h"
|
|
||||||
#import "MP42Track+Private.h"
|
#import "MP42Track+Private.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -1634,9 +1634,8 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)cleanUp:(MP4FileHandle)fileHandle
|
- (BOOL)cleanUp:(MP42Track *)track fileHandle:(MP4FileHandle)fileHandle
|
||||||
{
|
{
|
||||||
MP42Track *track = self.inputTracks.lastObject;
|
|
||||||
MP4TrackId trackId = track.trackId;
|
MP4TrackId trackId = track.trackId;
|
||||||
|
|
||||||
if (h264_dpb.dpb.size_min > 0) {
|
if (h264_dpb.dpb.size_min > 0) {
|
||||||
|
|||||||
+73
-67
@@ -183,12 +183,14 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation MP42MkvImporter {
|
@implementation MP42MkvImporter
|
||||||
@private
|
{
|
||||||
struct MatroskaFile *_matroskaFile;
|
struct MatroskaFile *_matroskaFile;
|
||||||
struct StdIoStream *_ioStream;
|
struct StdIoStream *_ioStream;
|
||||||
|
|
||||||
u_int64_t _fileDuration;
|
u_int64_t _fileDuration;
|
||||||
|
|
||||||
|
NSMutableArray<MatroskaDemuxHelper *> *_helpers;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray<NSString *> *)supportedFileFormats {
|
+ (NSArray<NSString *> *)supportedFileFormats {
|
||||||
@@ -204,6 +206,7 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
|||||||
if ((self = [super initWithURL:fileURL])) {
|
if ((self = [super initWithURL:fileURL])) {
|
||||||
_ioStream = calloc(1, sizeof(StdIoStream));
|
_ioStream = calloc(1, sizeof(StdIoStream));
|
||||||
_matroskaFile = openMatroskaFile(self.fileURL.fileSystemRepresentation, _ioStream);
|
_matroskaFile = openMatroskaFile(self.fileURL.fileSystemRepresentation, _ioStream);
|
||||||
|
_helpers = [NSMutableArray array];
|
||||||
|
|
||||||
if (!_matroskaFile) {
|
if (!_matroskaFile) {
|
||||||
if (outError) {
|
if (outError) {
|
||||||
@@ -789,26 +792,22 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
const unsigned int bufferSize = 20;
|
const unsigned int bufferSize = 20;
|
||||||
unsigned long TrackMask = ~0;
|
unsigned long TrackMask = ~0;
|
||||||
|
|
||||||
NSArray<MP42Track *> *tracks = self.tracks;
|
|
||||||
NSArray<MP42Track *> *inputTracks = self.inputTracks;
|
NSArray<MP42Track *> *inputTracks = self.inputTracks;
|
||||||
|
|
||||||
NSInteger tracksNumber = tracks.count;
|
NSInteger tracksNumber = inputTracks.count;
|
||||||
MatroskaDemuxHelper * helpers[tracksNumber];
|
MatroskaDemuxHelper * helpers[tracksNumber];
|
||||||
|
|
||||||
for (NSUInteger index = 0; index < tracksNumber; index += 1) {
|
for (NSUInteger index = 0; index < tracksNumber; index += 1) {
|
||||||
MP42Track *track = tracks[index];
|
MP42Track *track = inputTracks[index];
|
||||||
if ([inputTracks containsObject:track]) {
|
|
||||||
|
|
||||||
MatroskaDemuxHelper *demuxHelper = [[MatroskaDemuxHelper alloc] init];
|
MatroskaDemuxHelper *demuxHelper = [[MatroskaDemuxHelper alloc] init];
|
||||||
demuxHelper->sourceID = track.sourceId;
|
demuxHelper->sourceID = track.sourceId;
|
||||||
demuxHelper->trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId);
|
demuxHelper->trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId);
|
||||||
|
|
||||||
helpers[index] = demuxHelper;
|
helpers[index] = demuxHelper;
|
||||||
|
[_helpers addObject:demuxHelper];
|
||||||
|
|
||||||
track.demuxerHelper = demuxHelper;
|
TrackMask &= ~(1l << track.sourceId);
|
||||||
|
|
||||||
TrackMask &= ~(1l << track.sourceId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mask other tracks because we don't need them
|
// mask other tracks because we don't need them
|
||||||
@@ -1035,11 +1034,11 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MP42Track *track in inputTracks) {
|
for (NSUInteger index = 0; index < tracksNumber; index += 1) {
|
||||||
MatroskaDemuxHelper *demuxHelper = track.demuxerHelper;
|
MatroskaDemuxHelper *demuxHelper = helpers[index];
|
||||||
|
TrackInfo *trackInfo = demuxHelper->trackInfo;
|
||||||
|
|
||||||
if (demuxHelper->queue) {
|
if (demuxHelper->queue) {
|
||||||
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, [track sourceId]);
|
|
||||||
|
|
||||||
while ([demuxHelper->queue count]) {
|
while ([demuxHelper->queue count]) {
|
||||||
if (demuxHelper->bufferFlush == 1) {
|
if (demuxHelper->bufferFlush == 1) {
|
||||||
@@ -1081,7 +1080,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
sample->offset = offset / 10000.0f;
|
sample->offset = offset / 10000.0f;
|
||||||
sample->decodeTimestamp = StartTime;
|
sample->decodeTimestamp = StartTime;
|
||||||
sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0;
|
sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0;
|
||||||
sample->trackId = track.sourceId;
|
sample->trackId = demuxHelper->sourceID;
|
||||||
|
|
||||||
demuxHelper->samplesWritten++;
|
demuxHelper->samplesWritten++;
|
||||||
|
|
||||||
@@ -1109,7 +1108,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
|
|
||||||
if (demuxHelper->ss) {
|
if (demuxHelper->ss) {
|
||||||
MP42SampleBuffer *sample = nil;
|
MP42SampleBuffer *sample = nil;
|
||||||
MP4TrackId dstTrackId = track.sourceId;
|
MP4TrackId dstTrackId = demuxHelper->sourceID;
|
||||||
SBSubSerializer *ss = demuxHelper->ss;
|
SBSubSerializer *ss = demuxHelper->ss;
|
||||||
|
|
||||||
[ss setFinished:YES];
|
[ss setFinished:YES];
|
||||||
@@ -1138,7 +1137,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (demuxHelper->previousSample) {
|
if (demuxHelper->previousSample) {
|
||||||
if (track.mediaType == kMP42MediaType_Subtitle) {
|
if (trackInfo->Type == TT_SUB) {
|
||||||
demuxHelper->previousSample->duration = 100;
|
demuxHelper->previousSample->duration = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1151,57 +1150,64 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)cleanUp:(MP4FileHandle)fileHandle
|
- (MatroskaDemuxHelper *)helperWithTrackID:(MP4TrackId)trackID
|
||||||
{
|
{
|
||||||
for (MP42Track *track in self.outputsTracks) {
|
for (MatroskaDemuxHelper *helper in _helpers) {
|
||||||
MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId];
|
if (helper->sourceID == trackID) {
|
||||||
|
return helper;
|
||||||
MatroskaDemuxHelper *demuxHelper = inputTrack.demuxerHelper;
|
|
||||||
MP4TrackId trackId = track.trackId;
|
|
||||||
|
|
||||||
if (demuxHelper->minDisplayOffset != 0) {
|
|
||||||
|
|
||||||
for (unsigned int i = 1; i <= demuxHelper->samplesWritten; i++) {
|
|
||||||
int64_t correctedOffset = MP4GetSampleRenderingOffset(fileHandle, trackId, i) - demuxHelper->minDisplayOffset;
|
|
||||||
MP4SetSampleRenderingOffset(fileHandle,
|
|
||||||
trackId,
|
|
||||||
i,
|
|
||||||
correctedOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle, trackId,
|
|
||||||
MP4GetTrackDuration(fileHandle, trackId),
|
|
||||||
MP4GetTimeScale(fileHandle));
|
|
||||||
|
|
||||||
|
|
||||||
// Add an empty edit list if the first pts is not 0.
|
|
||||||
if (demuxHelper->startTime > 0) {
|
|
||||||
MP4Duration emptyDuration = MP4ConvertFromTrackDuration(fileHandle, trackId,
|
|
||||||
demuxHelper->startTime / 10000.0f,
|
|
||||||
MP4GetTimeScale(fileHandle));
|
|
||||||
|
|
||||||
MP4AddTrackEdit(fileHandle, trackId, MP4_INVALID_EDIT_ID, -1, emptyDuration, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
MP4AddTrackEdit(fileHandle,
|
|
||||||
trackId,
|
|
||||||
MP4_INVALID_EDIT_ID,
|
|
||||||
- demuxHelper->minDisplayOffset + demuxHelper->startTime / 10000.0f,
|
|
||||||
editDuration,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle, trackId,
|
|
||||||
MP4GetTrackDuration(fileHandle, trackId),
|
|
||||||
MP4GetTimeScale(fileHandle));
|
|
||||||
|
|
||||||
MP4AddTrackEdit(fileHandle,
|
return nil;
|
||||||
trackId,
|
}
|
||||||
MP4_INVALID_EDIT_ID,
|
|
||||||
0,
|
- (BOOL)cleanUp:(MP42Track *)track fileHandle:(MP4FileHandle)fileHandle
|
||||||
editDuration,
|
{
|
||||||
0);
|
MatroskaDemuxHelper *demuxHelper = [self helperWithTrackID:track.sourceId];
|
||||||
|
MP4TrackId trackId = track.trackId;
|
||||||
|
|
||||||
|
if (demuxHelper->minDisplayOffset != 0) {
|
||||||
|
|
||||||
|
for (unsigned int i = 1; i <= demuxHelper->samplesWritten; i++) {
|
||||||
|
int64_t correctedOffset = MP4GetSampleRenderingOffset(fileHandle, trackId, i) - demuxHelper->minDisplayOffset;
|
||||||
|
MP4SetSampleRenderingOffset(fileHandle,
|
||||||
|
trackId,
|
||||||
|
i,
|
||||||
|
correctedOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle, trackId,
|
||||||
|
MP4GetTrackDuration(fileHandle, trackId),
|
||||||
|
MP4GetTimeScale(fileHandle));
|
||||||
|
|
||||||
|
|
||||||
|
// Add an empty edit list if the first pts is not 0.
|
||||||
|
if (demuxHelper->startTime > 0) {
|
||||||
|
MP4Duration emptyDuration = MP4ConvertFromTrackDuration(fileHandle, trackId,
|
||||||
|
demuxHelper->startTime / 10000.0f,
|
||||||
|
MP4GetTimeScale(fileHandle));
|
||||||
|
|
||||||
|
MP4AddTrackEdit(fileHandle, trackId, MP4_INVALID_EDIT_ID, -1, emptyDuration, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
MP4AddTrackEdit(fileHandle,
|
||||||
|
trackId,
|
||||||
|
MP4_INVALID_EDIT_ID,
|
||||||
|
- demuxHelper->minDisplayOffset + demuxHelper->startTime / 10000.0f,
|
||||||
|
editDuration,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle, trackId,
|
||||||
|
MP4GetTrackDuration(fileHandle, trackId),
|
||||||
|
MP4GetTimeScale(fileHandle));
|
||||||
|
|
||||||
|
MP4AddTrackEdit(fileHandle,
|
||||||
|
trackId,
|
||||||
|
MP4_INVALID_EDIT_ID,
|
||||||
|
0,
|
||||||
|
editDuration,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
|||||||
+26
-28
@@ -362,39 +362,37 @@ typedef struct MP4DemuxHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)cleanUp:(MP4FileHandle)dstFileHandle
|
- (BOOL)cleanUp:(MP42Track *)track fileHandle:(MP4FileHandle)dstFileHandle
|
||||||
{
|
{
|
||||||
for (MP42Track *track in self.outputsTracks) {
|
MP4TrackId srcTrackId = track.sourceId;
|
||||||
MP4TrackId srcTrackId = track.sourceId;
|
MP4TrackId dstTrackId = track.trackId;
|
||||||
MP4TrackId dstTrackId = track.trackId;
|
|
||||||
|
|
||||||
MP4Duration trackDuration = 0;
|
MP4Duration trackDuration = 0;
|
||||||
uint32_t i = 1, trackEditCount = MP4GetTrackNumberOfEdits(_fileHandle, srcTrackId);
|
uint32_t i = 1, trackEditCount = MP4GetTrackNumberOfEdits(_fileHandle, srcTrackId);
|
||||||
while (i <= trackEditCount) {
|
while (i <= trackEditCount) {
|
||||||
MP4Timestamp editMediaStart = MP4GetTrackEditMediaStart(_fileHandle, srcTrackId, i);
|
MP4Timestamp editMediaStart = MP4GetTrackEditMediaStart(_fileHandle, srcTrackId, i);
|
||||||
MP4Duration editDuration = MP4ConvertFromMovieDuration(_fileHandle,
|
MP4Duration editDuration = MP4ConvertFromMovieDuration(_fileHandle,
|
||||||
MP4GetTrackEditDuration(_fileHandle, srcTrackId, i),
|
MP4GetTrackEditDuration(_fileHandle, srcTrackId, i),
|
||||||
MP4GetTimeScale(dstFileHandle));
|
MP4GetTimeScale(dstFileHandle));
|
||||||
trackDuration += editDuration;
|
trackDuration += editDuration;
|
||||||
int8_t editDwell = MP4GetTrackEditDwell(_fileHandle, srcTrackId, i);
|
int8_t editDwell = MP4GetTrackEditDwell(_fileHandle, srcTrackId, i);
|
||||||
|
|
||||||
MP4AddTrackEdit(dstFileHandle, dstTrackId, i, editMediaStart, editDuration, editDwell);
|
MP4AddTrackEdit(dstFileHandle, dstTrackId, i, editMediaStart, editDuration, editDwell);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (trackEditCount) {
|
if (trackEditCount) {
|
||||||
MP4SetTrackIntegerProperty(dstFileHandle, dstTrackId, "tkhd.duration", trackDuration);
|
MP4SetTrackIntegerProperty(dstFileHandle, dstTrackId, "tkhd.duration", trackDuration);
|
||||||
}
|
}
|
||||||
else if (MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1)) {
|
else if (MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1)) {
|
||||||
uint32_t firstFrameOffset = MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1);
|
uint32_t firstFrameOffset = MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1);
|
||||||
|
|
||||||
MP4Duration editDuration = MP4ConvertFromTrackDuration(_fileHandle,
|
MP4Duration editDuration = MP4ConvertFromTrackDuration(_fileHandle,
|
||||||
srcTrackId,
|
srcTrackId,
|
||||||
MP4GetTrackDuration(_fileHandle, srcTrackId),
|
MP4GetTrackDuration(_fileHandle, srcTrackId),
|
||||||
MP4GetTimeScale(dstFileHandle));
|
MP4GetTimeScale(dstFileHandle));
|
||||||
|
|
||||||
MP4AddTrackEdit(dstFileHandle, dstTrackId, MP4_INVALID_EDIT_ID, firstFrameOffset,
|
MP4AddTrackEdit(dstFileHandle, dstTrackId, MP4_INVALID_EDIT_ID, firstFrameOffset,
|
||||||
editDuration, 0);
|
editDuration, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
|||||||
+5
-6
@@ -20,10 +20,10 @@
|
|||||||
#import "MP42FormatUtilites.h"
|
#import "MP42FormatUtilites.h"
|
||||||
#import "MP42PrivateUtilities.h"
|
#import "MP42PrivateUtilities.h"
|
||||||
#import "MP42Track+Private.h"
|
#import "MP42Track+Private.h"
|
||||||
|
#import "MP42Track+Muxer.h"
|
||||||
|
|
||||||
@implementation MP42Muxer
|
@implementation MP42Muxer
|
||||||
{
|
{
|
||||||
@private
|
|
||||||
MP4FileHandle _fileHandle;
|
MP4FileHandle _fileHandle;
|
||||||
|
|
||||||
id <MP42MuxerDelegate> _delegate;
|
id <MP42MuxerDelegate> _delegate;
|
||||||
@@ -548,8 +548,6 @@
|
|||||||
// If all tracks are done, exit the loop
|
// If all tracks are done, exit the loop
|
||||||
if (done == tracksCount) {
|
if (done == tracksCount) {
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
done = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update progress
|
// Update progress
|
||||||
@@ -596,9 +594,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop the importers and clean ups
|
// Stop the importers and clean ups
|
||||||
for (MP42FileImporter *importerHelper in trackImportersArray) {
|
if (!_cancelled) {
|
||||||
if (!_cancelled) {
|
for (MP42FileImporter *importerHelper in trackImportersArray) {
|
||||||
[importerHelper cleanUp:_fileHandle];
|
for (MP42Track *track in importerHelper.outputsTracks)
|
||||||
|
[importerHelper cleanUp:track fileHandle:_fileHandle];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-12
@@ -8,24 +8,21 @@
|
|||||||
|
|
||||||
#import "MP42Track.h"
|
#import "MP42Track.h"
|
||||||
#import "MP42FileImporter.h"
|
#import "MP42FileImporter.h"
|
||||||
#import "MP42Fifo.h"
|
|
||||||
#import "MP42ConverterProtocol.h"
|
#import "MP42ConverterProtocol.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
typedef struct muxer_helper {
|
|
||||||
// Input helpers
|
|
||||||
MP42FileImporter *importer;
|
|
||||||
id demuxer_context;
|
|
||||||
|
|
||||||
// Output helpers
|
|
||||||
id <MP42ConverterProtocol> converter;
|
|
||||||
MP42Fifo<MP42SampleBuffer *> *fifo;
|
|
||||||
} muxer_helper;
|
|
||||||
|
|
||||||
@interface MP42Track (MP42TrackMuxerExtentions)
|
@interface MP42Track (MP42TrackMuxerExtentions)
|
||||||
|
|
||||||
@property (nonatomic, readonly, nullable) muxer_helper *muxer_helper;
|
- (id <MP42ConverterProtocol>)converter;
|
||||||
|
- (void)setConverter:(id <MP42ConverterProtocol>)converter;
|
||||||
|
|
||||||
|
- (void)enqueue:(MP42SampleBuffer *)sample;
|
||||||
|
- (MP42SampleBuffer *)copyNextSample;
|
||||||
|
|
||||||
|
- (void *)copy_muxer_helper;
|
||||||
|
- (void *)create_muxer_helper;
|
||||||
|
- (void)free_muxer_helper;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
+45
-16
@@ -8,25 +8,29 @@
|
|||||||
|
|
||||||
#import "MP42Track+Muxer.h"
|
#import "MP42Track+Muxer.h"
|
||||||
#import "MP42FileImporter+Private.h"
|
#import "MP42FileImporter+Private.h"
|
||||||
|
#import "MP42Fifo.h"
|
||||||
|
|
||||||
|
typedef struct muxer_helper {
|
||||||
|
// Input helpers
|
||||||
|
MP42FileImporter *importer;
|
||||||
|
|
||||||
|
// Output helpers
|
||||||
|
id <MP42ConverterProtocol> converter;
|
||||||
|
MP42Fifo<MP42SampleBuffer *> *fifo;
|
||||||
|
} muxer_helper;
|
||||||
|
|
||||||
|
@interface MP42Track (MP42TrackMuxerExtensions)
|
||||||
|
|
||||||
|
@property (nonatomic, readonly, nullable) muxer_helper *muxer_helper;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation MP42Track (MP42TrackMuxerExtentions)
|
@implementation MP42Track (MP42TrackMuxerExtentions)
|
||||||
|
|
||||||
@dynamic muxer_helper;
|
|
||||||
|
|
||||||
- (id)demuxerHelper {
|
|
||||||
muxer_helper *helper = (muxer_helper *)_helper;
|
|
||||||
return helper->demuxer_context;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setDemuxerHelper:(id)demuxerHelper {
|
|
||||||
[demuxerHelper retain];
|
|
||||||
muxer_helper *helper = (muxer_helper *)_helper;
|
|
||||||
helper->demuxer_context = demuxerHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (MP42FileImporter *)importer
|
- (MP42FileImporter *)importer
|
||||||
{
|
{
|
||||||
return self.muxer_helper->importer;
|
muxer_helper *helper = (muxer_helper *)_helper;
|
||||||
|
return helper->importer;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setImporter:(MP42FileImporter *)importer
|
- (void)setImporter:(MP42FileImporter *)importer
|
||||||
@@ -34,20 +38,28 @@
|
|||||||
self.muxer_helper->importer = importer;
|
self.muxer_helper->importer = importer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (MP42Fifo<MP42SampleBuffer *> *)fifo
|
||||||
|
{
|
||||||
|
muxer_helper *helper = (muxer_helper *)_helper;
|
||||||
|
return helper->fifo;
|
||||||
|
}
|
||||||
|
|
||||||
- (id <MP42ConverterProtocol>)converter
|
- (id <MP42ConverterProtocol>)converter
|
||||||
{
|
{
|
||||||
return self.muxer_helper->converter;
|
muxer_helper *helper = (muxer_helper *)_helper;
|
||||||
|
return helper->converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setConverter:(id <MP42ConverterProtocol>)converter
|
- (void)setConverter:(id <MP42ConverterProtocol>)converter
|
||||||
{
|
{
|
||||||
self.muxer_helper->converter = converter;
|
self.muxer_helper->converter = [converter retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void *)copy_muxer_helper
|
- (void *)copy_muxer_helper
|
||||||
{
|
{
|
||||||
muxer_helper *copy = calloc(1, sizeof(muxer_helper));
|
muxer_helper *copy = calloc(1, sizeof(muxer_helper));
|
||||||
copy->importer = ((muxer_helper *)_helper)->importer;
|
copy->importer = ((muxer_helper *)_helper)->importer;
|
||||||
|
copy->fifo = [[MP42Fifo alloc] init];
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
@@ -55,9 +67,26 @@
|
|||||||
- (void *)create_muxer_helper
|
- (void *)create_muxer_helper
|
||||||
{
|
{
|
||||||
muxer_helper *helper = calloc(1, sizeof(muxer_helper));
|
muxer_helper *helper = calloc(1, sizeof(muxer_helper));
|
||||||
|
helper->fifo = [[MP42Fifo alloc] init];
|
||||||
return helper;
|
return helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)free_muxer_helper {
|
||||||
|
muxer_helper *helper = (muxer_helper *)_helper;
|
||||||
|
[helper->fifo release];
|
||||||
|
[helper->converter release];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)enqueue:(MP42SampleBuffer *)sample
|
||||||
|
{
|
||||||
|
muxer_helper *helper = (muxer_helper *)_helper;
|
||||||
|
if (helper->converter) {
|
||||||
|
[helper->converter addSample:sample];
|
||||||
|
} else {
|
||||||
|
[helper->fifo enqueue:sample];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (MP42SampleBuffer *)copyNextSample {
|
- (MP42SampleBuffer *)copyNextSample {
|
||||||
muxer_helper *helper = (muxer_helper *)_helper;
|
muxer_helper *helper = (muxer_helper *)_helper;
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class MP42FileImporter;
|
@class MP42FileImporter;
|
||||||
@class MP42SampleBuffer;
|
|
||||||
@protocol MP42ConverterProtocol;
|
|
||||||
|
|
||||||
@interface MP42Track (Private)
|
@interface MP42Track (Private)
|
||||||
|
|
||||||
@@ -37,14 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@property (nonatomic, readwrite) MP42FileImporter *importer;
|
@property (nonatomic, readwrite) MP42FileImporter *importer;
|
||||||
|
|
||||||
@property (nonatomic, readwrite) id<MP42ConverterProtocol> converter;
|
|
||||||
@property (nonatomic, readwrite) id demuxerHelper;
|
|
||||||
|
|
||||||
- (MP42SampleBuffer *)copyNextSample;
|
|
||||||
|
|
||||||
- (void *)copy_muxer_helper;
|
|
||||||
- (void *)create_muxer_helper;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
+1
-4
@@ -9,12 +9,9 @@
|
|||||||
#import "MP42Track.h"
|
#import "MP42Track.h"
|
||||||
#import "MP42PrivateUtilities.h"
|
#import "MP42PrivateUtilities.h"
|
||||||
#import "MP42Utilities.h"
|
#import "MP42Utilities.h"
|
||||||
#import "MP42FileImporter.h"
|
|
||||||
#import "MP42Sample.h"
|
|
||||||
#import "MP42Fifo.h"
|
|
||||||
#import "MP42Languages.h"
|
#import "MP42Languages.h"
|
||||||
|
|
||||||
#import "MP42Track+Private.h"
|
#import "MP42Track+Muxer.h"
|
||||||
|
|
||||||
@interface MP42Track ()
|
@interface MP42Track ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
A9B9C27B1823923200416A4E /* MP42File.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2301823923100416A4E /* MP42File.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
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 */; };
|
A9B9C27C1823923200416A4E /* MP42File.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2311823923100416A4E /* MP42File.m */; };
|
||||||
A9B9C27D1823923200416A4E /* MP42FileImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2321823923100416A4E /* MP42FileImporter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
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 */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
A9B9C27E1823923200416A4E /* MP42FileImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2331823923100416A4E /* MP42FileImporter.m */; };
|
||||||
A9B9C27F1823923200416A4E /* MP42H264Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2341823923100416A4E /* MP42H264Importer.h */; };
|
A9B9C27F1823923200416A4E /* MP42H264Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2341823923100416A4E /* MP42H264Importer.h */; };
|
||||||
A9B9C2801823923200416A4E /* MP42H264Importer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2351823923100416A4E /* MP42H264Importer.mm */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };
|
A9B9C2801823923200416A4E /* MP42H264Importer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2351823923100416A4E /* MP42H264Importer.mm */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };
|
||||||
A9B9C2811823923200416A4E /* MP42HtmlParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2361823923100416A4E /* MP42HtmlParser.h */; };
|
A9B9C2811823923200416A4E /* MP42HtmlParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2361823923100416A4E /* MP42HtmlParser.h */; };
|
||||||
|
|||||||
Reference in new issue
Block a user