-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMXTrackWrapper.m
63 lines (51 loc) · 1.46 KB
/
MXTrackWrapper.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
//
// MXTrackWrapper.m
// Muxer
//
// Created by Ryan Walklin on 12/23/08.
// Copyright 2008 Ryan Walklin. All rights reserved.
//
#import "MXTrackWrapper.h"
@implementation MXTrackWrapper
@synthesize trackSourcePath;
@synthesize trackSourceID;
@synthesize trackTargetID;
@synthesize trackDescription;
@synthesize samplerate;
@synthesize bitrate;
@synthesize duration;
-(id)initWithSourcePath:(NSString *)source trackID:(NSInteger)trackID
{
if ((self = [super init]))
{
trackSourcePath = source;
trackSourceID = trackID;
}
[self readTrackType];
return self;
}
-(void)readTrackType
{
// Override to read type-specific info
MP4FileHandle *sourceHandle = MP4Read([trackSourcePath UTF8String], MP4_VERBOSITY);
if (sourceHandle != MP4_INVALID_FILE_HANDLE)
{
trackType = (char *)MP4GetTrackType(sourceHandle, trackSourceID);
bitrate = (double)MP4GetTrackBitRate(sourceHandle, trackSourceID) / 1024;
duration = (double)MP4ConvertFromTrackDuration(sourceHandle, trackSourceID, MP4GetTrackDuration(sourceHandle, trackSourceID), MP4_MSECS_TIME_SCALE) / 1000;
samplerate = MP4GetTrackTimeScale(sourceHandle, trackSourceID);
MP4Close(sourceHandle);
[self readTrackDescription];
}
}
-(void)readTrackDescription
{
trackDescription = [NSDictionary dictionaryWithObject:[NSString stringWithUTF8String:MP4FileInfo([trackSourcePath UTF8String], trackSourceID)]
forKey:@"generic_track"];
}
-(void)finalize
{
free(trackType);
[super finalize];
}
@end