Changeset 156

Show
Ignore:
Timestamp:
07/13/07 11:46:51 (1 year ago)
Author:
gbooker
Message:
  • Added getting the audio type so AC3 data can be detected
  • A more elegant way to get the track description

Note: this requires a re-import in order to get the audio type

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireMetaData.h

    r150 r156  
    145145- (float)duration; 
    146146- (int)sampleRate; 
     147- (UInt32)audioFormatID; 
    147148- (int)episodeNumber; 
    148149- (int)seasonNumber; 
  • trunk/SapphireMetaData.m

    r155 r156  
    1919#define DIRS_KEY                                        @"Dirs" 
    2020#define META_VERSION_KEY                        @"Version" 
    21 #define META_FILE_VERSION                       1 
     21#define META_FILE_VERSION                       2 
    2222#define META_COLLECTION_VERSION         2 
    2323 
     
    3232#define SAMPLE_RATE_KEY                         @"Sample Rate" 
    3333#define VIDEO_DESC_KEY                          @"Video Description" 
     34#define AUDIO_FORMAT_KEY                        @"Audio Format" 
    3435 
    3536@implementation NSString (episodeSorting) 
     
    11041105                        /*Get the audio track*/ 
    11051106                        QTTrack *track = [audioTracks objectAtIndex:0]; 
     1107                        NSString *formatText = [track attributeForKey:@"QTTrackFormatSummaryAttribute"]; 
     1108                        if(formatText != nil) 
     1109                                [fileMeta setObject:formatText forKey:AUDIO_DESC_KEY]; 
    11061110                        QTMedia *media = [track media]; 
    11071111                        audioSampleRate = [media attributeForKey:QTMediaTimeScaleAttribute]; 
    11081112                        if(media != nil) 
    11091113                        { 
    1110                                 /*Get the audio description*/ 
     1114                                /*Get the audio format*/ 
    11111115                                Media qtMedia = [media quickTimeMedia]; 
    11121116                                Handle sampleDesc = NewHandle(1); 
    11131117                                GetMediaSampleDescription(qtMedia, 1, (SampleDescriptionHandle)sampleDesc); 
    1114                                 CFStringRef userText = nil
     1118                                AudioStreamBasicDescription asbd
    11151119                                ByteCount       propSize = 0; 
    1116                                 QTSoundDescriptionGetProperty((SoundDescriptionHandle)sampleDesc, kQTPropertyClass_SoundDescription, kQTSoundDescriptionPropertyID_UserReadableText, sizeof(userText), &userText, &propSize); 
     1120                                QTSoundDescriptionGetProperty((SoundDescriptionHandle)sampleDesc, kQTPropertyClass_SoundDescription, kQTSoundDescriptionPropertyID_AudioStreamBasicDescription, sizeof(asbd), &asbd, &propSize); 
    11171121                                DisposeHandle(sampleDesc); 
    11181122                                 
    1119                                 if(userText != nil
     1123                                if(propSize != 0
    11201124                                { 
    1121                                         /*Set the description*/ 
    1122                                         [fileMeta setObject:(NSString *)userText forKey:AUDIO_DESC_KEY]; 
    1123                                         CFRelease(userText)
     1125                                        /*Set the format*/ 
     1126                                        NSNumber *format = [NSNumber numberWithUnsignedInt:asbd.mFormatID]; 
     1127                                        [fileMeta setObject:format forKey:AUDIO_FORMAT_KEY]
    11241128                                } 
    11251129                        } 
     
    11331137                        /*Get the video track*/ 
    11341138                        QTTrack *track = [videoTracks objectAtIndex:0]; 
    1135                         QTMedia *media = [track media]; 
    1136                         if(media != nil) 
    1137                         { 
    1138                                 /*Get the video description*/ 
    1139                                 Media qtMedia = [media quickTimeMedia]; 
    1140                                 Handle sampleDesc = NewHandle(1); 
    1141                                 GetMediaSampleDescription(qtMedia, 1, (SampleDescriptionHandle)sampleDesc); 
    1142                                 CFStringRef userText = nil; 
    1143                                 ByteCount       propSize = 0; 
    1144                                 ICMImageDescriptionGetProperty((ImageDescriptionHandle)sampleDesc, kQTPropertyClass_ImageDescription, kICMImageDescriptionPropertyID_SummaryString, sizeof(userText), &userText, &propSize); 
    1145                                 DisposeHandle(sampleDesc); 
    1146                                  
    1147                                 if(userText != nil) 
    1148                                 { 
    1149                                         /*Set the description*/ 
    1150                                         [fileMeta setObject:(NSString *)userText forKey:VIDEO_DESC_KEY]; 
    1151                                         CFRelease(userText); 
    1152                                 } 
    1153                         } 
     1139                        NSString *formatText = [track attributeForKey:QTTrackDisplayNameAttribute]; 
     1140                        if(formatText != nil) 
     1141                                [fileMeta setObject:formatText forKey:VIDEO_DESC_KEY];                   
    11541142                } 
    11551143                /*Add the meta data*/ 
     
    12991287{ 
    13001288        return [[metaData objectForKey:SAMPLE_RATE_KEY] intValue]; 
     1289} 
     1290 
     1291/*! 
     1292 * @brief Returns the audio format of the file 
     1293 * 
     1294 * @return The audio format of the file 
     1295 */ 
     1296- (UInt32)audioFormatID 
     1297{ 
     1298        return [[metaData objectForKey:AUDIO_FORMAT_KEY] unsignedIntValue]; 
    13011299} 
    13021300