Cosmetiscs.

This commit is contained in:
Damiano Galassi committed 2014-03-27 10:01:18 +01:00
1 parent 618b52140c
commit 60cf96a6af
1 file changed
+18 -35
+18 -35
View File
@@ -36,8 +36,7 @@
@implementation MP42AVFImporter @implementation MP42AVFImporter
- (NSString *)formatForTrack:(AVAssetTrack *)track; - (NSString *)formatForTrack:(AVAssetTrack *)track {
{
NSString *result = @""; NSString *result = @"";
CMFormatDescriptionRef formatDescription = NULL; CMFormatDescriptionRef formatDescription = NULL;
@@ -159,13 +158,11 @@
return result; return result;
} }
- (NSString*)langForTrack: (AVAssetTrack *)track - (NSString *)langForTrack:(AVAssetTrack *)track {
{
return [NSString stringWithUTF8String:lang_for_qtcode([[track languageCode] integerValue])->eng_name]; return [NSString stringWithUTF8String:lang_for_qtcode([[track languageCode] integerValue])->eng_name];
} }
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError - (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError {
{
if ((self = [super init])) { if ((self = [super init])) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -308,8 +305,7 @@
return self; return self;
} }
-(void)convertMetadata -(void)convertMetadata {
{
NSArray *items = nil; NSArray *items = nil;
NSDictionary *commonItemsDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Name", AVMetadataCommonKeyTitle, NSDictionary *commonItemsDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Name", AVMetadataCommonKeyTitle,
//nil, AVMetadataCommonKeyCreator, //nil, AVMetadataCommonKeyCreator,
@@ -343,7 +339,7 @@
if ([items count]) if ([items count])
[_metadata setTag:[[items lastObject] value] forKey:[commonItemsDict objectForKey:commonKey]]; [_metadata setTag:[[items lastObject] value] forKey:[commonItemsDict objectForKey:commonKey]];
} }
items = [AVMetadataItem metadataItemsFromArray:_localAsset.commonMetadata withKey:AVMetadataCommonKeyArtwork keySpace:AVMetadataKeySpaceCommon]; items = [AVMetadataItem metadataItemsFromArray:_localAsset.commonMetadata withKey:AVMetadataCommonKeyArtwork keySpace:AVMetadataKeySpaceCommon];
if ([items count]) { if ([items count]) {
id artworkData = [[items lastObject] value]; id artworkData = [[items lastObject] value];
@@ -518,10 +514,9 @@
} }
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (NSUInteger)timescaleForTrack:(MP42Track *)track {
{
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:[track sourceId]]; AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:[track sourceId]];
CMFormatDescriptionRef formatDescription = NULL; CMFormatDescriptionRef formatDescription = NULL;
NSArray *formatDescriptions = assetTrack.formatDescriptions; NSArray *formatDescriptions = assetTrack.formatDescriptions;
if ([formatDescriptions count] > 0) if ([formatDescriptions count] > 0)
@@ -538,15 +533,13 @@
return [assetTrack naturalTimeScale]; return [assetTrack naturalTimeScale];
} }
- (NSSize)sizeForTrack:(MP42Track *)track - (NSSize)sizeForTrack:(MP42Track *)track {
{ MP42VideoTrack *currentTrack = (MP42VideoTrack *)track;
MP42VideoTrack* currentTrack = (MP42VideoTrack*) track;
return NSMakeSize([currentTrack width], [currentTrack height]); return NSMakeSize([currentTrack width], [currentTrack height]);
} }
- (NSData*)magicCookieForTrack:(MP42Track *)track - (NSData *)magicCookieForTrack:(MP42Track *)track {
{
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:[track sourceId]]; AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:[track sourceId]];
CMFormatDescriptionRef formatDescription = NULL; CMFormatDescriptionRef formatDescription = NULL;
@@ -567,9 +560,7 @@
magicCookie = CFDictionaryGetValue(atoms, @"esds"); magicCookie = CFDictionaryGetValue(atoms, @"esds");
return (NSData*)magicCookie; return (NSData*)magicCookie;
} } else if ([[assetTrack mediaType] isEqualToString:AVMediaTypeAudio]) {
else if ([[assetTrack mediaType] isEqualToString:AVMediaTypeAudio]) {
size_t cookieSizeOut; size_t cookieSizeOut;
const void *magicCookie = CMAudioFormatDescriptionGetMagicCookie(formatDescription, &cookieSizeOut); const void *magicCookie = CMAudioFormatDescriptionGetMagicCookie(formatDescription, &cookieSizeOut);
@@ -580,8 +571,7 @@
ReadESDSDescExt((void*)magicCookie, &buffer, &size, 0); ReadESDSDescExt((void*)magicCookie, &buffer, &size, 0);
return [NSData dataWithBytes:buffer length:size]; return [NSData dataWithBytes:buffer length:size];
} } else if (code == kAudioFormatAppleLossless) {
else if (code == kAudioFormatAppleLossless) {
if (cookieSizeOut > 48) { if (cookieSizeOut > 48) {
// Remove unneeded parts of the cookie, as describred in ALACMagicCookieDescription.txt // Remove unneeded parts of the cookie, as describred in ALACMagicCookieDescription.txt
magicCookie += 24; magicCookie += 24;
@@ -589,8 +579,7 @@
} }
return [NSData dataWithBytes:magicCookie length:cookieSizeOut]; return [NSData dataWithBytes:magicCookie length:cookieSizeOut];
} } else if (code == kAudioFormatAC3) {
else if (code == kAudioFormatAC3) {
OSStatus err = noErr; OSStatus err = noErr;
size_t channelLayoutSize = 0; size_t channelLayoutSize = 0;
const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription); const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
@@ -648,8 +637,7 @@
return [ac3Info autorelease]; return [ac3Info autorelease];
} } else if (cookieSizeOut)
else if (cookieSizeOut)
return [NSData dataWithBytes:magicCookie length:cookieSizeOut]; return [NSData dataWithBytes:magicCookie length:cookieSizeOut];
} }
} }
@@ -688,8 +676,7 @@
//#define SB_AVF_DEBUG //#define SB_AVF_DEBUG
- (void)demux:(id)sender - (void)demux:(id)sender {
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
BOOL success = YES; BOOL success = YES;
@@ -973,8 +960,7 @@
[pool release]; [pool release];
} }
- (void)startReading - (void)startReading {
{
[super startReading]; [super startReading];
if (!_demuxerThread && !_done) { if (!_demuxerThread && !_done) {
@@ -984,8 +970,7 @@
} }
} }
- (BOOL)cleanUp:(MP4FileHandle)fileHandle - (BOOL)cleanUp:(MP4FileHandle)fileHandle {
{
uint32_t timescale = MP4GetTimeScale(fileHandle); uint32_t timescale = MP4GetTimeScale(fileHandle);
for (MP42Track *track in _inputTracks) { for (MP42Track *track in _inputTracks) {
@@ -1017,10 +1002,8 @@
return YES; return YES;
} }
- (void) dealloc - (void) dealloc {
{
[_localAsset release]; [_localAsset release];
[super dealloc]; [super dealloc];
} }