-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMXAudioTrackWrapper.m
56 lines (42 loc) · 1.53 KB
/
MXAudioTrackWrapper.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
//
// MXAudioTrackWrapper.m
// Muxer
//
// Created by Ryan Walklin on 12/25/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "MXAudioTrackWrapper.h"
@implementation MXAudioTrackWrapper
@synthesize trackName;
@synthesize esConfig;
@synthesize esConfigSize;
@synthesize channelCount;
@synthesize language;
-(void)readTrackDescription
{
// Override to read type-specific info
MP4FileHandle *sourceHandle = MP4Read([trackSourcePath UTF8String], MP4_VERBOSITY);
if (sourceHandle != MP4_INVALID_FILE_HANDLE)
{
samplerate = MP4GetTrackTimeScale(sourceHandle, trackSourceID);
uint8_t byteProperty[1024];
uint32_t bytePropertySize;
if (MP4GetTrackBytesProperty(sourceHandle, trackSourceID, "udta.name.value", (uint8_t**)&byteProperty, &bytePropertySize))
{
if (bytePropertySize > 0)
{
byteProperty[bytePropertySize] = '\0';
trackName = [NSString stringWithCharacters:(const unichar *)byteProperty length:bytePropertySize];
}
else trackName = @"Default audio";
}
else trackName = @"Default audio";
MP4GetTrackESConfiguration(sourceHandle, trackSourceID, &esConfig, &esConfigSize);
channelCount = MP4GetTrackAudioChannels(sourceHandle, trackSourceID);
MP4GetTrackIntegerProperty(sourceHandle, trackSourceID, "mdia.mdhd.language", (uint64_t *)&language);
MP4Close(sourceHandle);
trackDescription = [NSDictionary dictionaryWithObject:[NSString stringWithUTF8String:MP4FileInfo([trackSourcePath UTF8String], trackSourceID)]
forKey:@"generic_track"];
}
}
@end