/
MP42FileImporter.m
112 lines (95 loc) · 3.48 KB
/
MP42FileImporter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// MP42FileImporter.m
// Subler
//
// Created by Damiano Galassi on 31/01/10.
// Copyright 2010 Damiano Galassi All rights reserved.
//
#import "MP42FileImporter.h"
#import "MP42MkvImporter.h"
#import "MP42Mp4Importer.h"
#import "MP42SrtImporter.h"
#import "MP42CCImporter.h"
#import "MP42AC3Importer.h"
#import "MP42AACImporter.h"
#import "MP42H264Importer.h"
#if !__LP64__
#import "MP42QTImporter.h"
#endif
#import "MP42AVFImporter.h"
@implementation MP42FileImporter
- (id)initWithDelegate:(id)del andFile:(NSURL *)URL error:(NSError **)outError
{
[self release];
self = nil;
if ([[URL pathExtension] caseInsensitiveCompare: @"mkv"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"mka"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"mks"] == NSOrderedSame)
self = [[MP42MkvImporter alloc] initWithDelegate:del andFile:URL error:outError];
else if ([[URL pathExtension] caseInsensitiveCompare: @"mp4"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"m4v"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"m4a"] == NSOrderedSame)
self = [[MP42Mp4Importer alloc] initWithDelegate:del andFile:URL error:outError];
else if ([[URL pathExtension] caseInsensitiveCompare: @"srt"] == NSOrderedSame)
self = [[MP42SrtImporter alloc] initWithDelegate:del andFile:URL error:outError];
else if ([[URL pathExtension] caseInsensitiveCompare: @"scc"] == NSOrderedSame)
self = [[MP42CCImporter alloc] initWithDelegate:del andFile:URL error:outError];
else if ([[URL pathExtension] caseInsensitiveCompare: @"ac3"] == NSOrderedSame)
self = [[MP42AC3Importer alloc] initWithDelegate:del andFile:URL error:outError];
else if ([[URL pathExtension] caseInsensitiveCompare: @"aac"] == NSOrderedSame)
self = [[MP42AACImporter alloc] initWithDelegate:del andFile:URL error:outError];
else if ([[URL pathExtension] caseInsensitiveCompare: @"264"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"h264"] == NSOrderedSame)
self = [[MP42H264Importer alloc] initWithDelegate:del andFile:URL error:outError];
//#if __MAC_OS_X_VERSION_MAX_ALLOWED > 1060
// If we are on 10.7, use the AVFoundation path
else if (NSClassFromString(@"AVAsset")) {
if ([[URL pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"m2ts"] == NSOrderedSame ||
[[URL pathExtension] caseInsensitiveCompare: @"mts"] == NSOrderedSame ) {
self = [[MP42AVFImporter alloc] initWithDelegate:del andFile:URL error:outError];
}
}
//#endif
#if !__LP64__
else if ([[URL pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame) {
self = [[MP42QTImporter alloc] initWithDelegate:del andFile:URL error:outError];
}
#endif
return self;
}
- (NSUInteger)timescaleForTrack:(MP42Track *)track{
return 0;
}
- (NSSize)sizeForTrack:(MP42Track *)track{
return NSMakeSize(0,0);
}
- (NSData*)magicCookieForTrack:(MP42Track *)track{
return nil;
}
- (void)setActiveTrack:(MP42Track *)track
{
}
- (MP42SampleBuffer*)copyNextSample
{
return nil;
}
- (MP42SampleBuffer*)nextSampleForTrack:(MP42Track *)track
{
return nil;
}
- (CGFloat)progress
{
return 0;
}
- (BOOL)cleanUp:(MP4FileHandle) fileHandle
{
return NO;
}
- (void)cancel
{
isCancelled = YES;
}
@synthesize metadata;
@synthesize tracksArray;
@end