Changeset 156
- Timestamp:
- 07/13/07 11:46:51 (1 year ago)
- Files:
-
- trunk/SapphireMetaData.h (modified) (1 diff)
- trunk/SapphireMetaData.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SapphireMetaData.h
r150 r156 145 145 - (float)duration; 146 146 - (int)sampleRate; 147 - (UInt32)audioFormatID; 147 148 - (int)episodeNumber; 148 149 - (int)seasonNumber; trunk/SapphireMetaData.m
r155 r156 19 19 #define DIRS_KEY @"Dirs" 20 20 #define META_VERSION_KEY @"Version" 21 #define META_FILE_VERSION 121 #define META_FILE_VERSION 2 22 22 #define META_COLLECTION_VERSION 2 23 23 … … 32 32 #define SAMPLE_RATE_KEY @"Sample Rate" 33 33 #define VIDEO_DESC_KEY @"Video Description" 34 #define AUDIO_FORMAT_KEY @"Audio Format" 34 35 35 36 @implementation NSString (episodeSorting) … … 1104 1105 /*Get the audio track*/ 1105 1106 QTTrack *track = [audioTracks objectAtIndex:0]; 1107 NSString *formatText = [track attributeForKey:@"QTTrackFormatSummaryAttribute"]; 1108 if(formatText != nil) 1109 [fileMeta setObject:formatText forKey:AUDIO_DESC_KEY]; 1106 1110 QTMedia *media = [track media]; 1107 1111 audioSampleRate = [media attributeForKey:QTMediaTimeScaleAttribute]; 1108 1112 if(media != nil) 1109 1113 { 1110 /*Get the audio description*/1114 /*Get the audio format*/ 1111 1115 Media qtMedia = [media quickTimeMedia]; 1112 1116 Handle sampleDesc = NewHandle(1); 1113 1117 GetMediaSampleDescription(qtMedia, 1, (SampleDescriptionHandle)sampleDesc); 1114 CFStringRef userText = nil;1118 AudioStreamBasicDescription asbd; 1115 1119 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); 1117 1121 DisposeHandle(sampleDesc); 1118 1122 1119 if( userText != nil)1123 if(propSize != 0) 1120 1124 { 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]; 1124 1128 } 1125 1129 } … … 1133 1137 /*Get the video track*/ 1134 1138 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]; 1154 1142 } 1155 1143 /*Add the meta data*/ … … 1299 1287 { 1300 1288 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]; 1301 1299 } 1302 1300
