summaryrefslogtreecommitdiffstats
path: root/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm')
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm74
1 files changed, 43 insertions, 31 deletions
diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm
index a14981a..b046672 100644
--- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm
+++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm
@@ -132,15 +132,19 @@ static OSStatus readMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, QT
UInt32 propFlags;
OSStatus err = QTMetaDataGetItemPropertyInfo(metaDataRef, item, propClass, id, &type, &propSize, &propFlags);
-
- *value = malloc(propSize);
-
- err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size);
-
- if (type == 'code' || type == 'itsk' || type == 'itlk') {
- // convert from native endian to big endian
- OSTypePtr pType = (OSTypePtr)*value;
- *pType = EndianU32_NtoB(*pType);
+ if (err == noErr) {
+ *value = malloc(propSize);
+ if (*value != 0) {
+ err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size);
+
+ if (err == noErr && (type == 'code' || type == 'itsk' || type == 'itlk')) {
+ // convert from native endian to big endian
+ OSTypePtr pType = (OSTypePtr)*value;
+ *pType = EndianU32_NtoB(*pType);
+ }
+ }
+ else
+ return -1;
}
return err;
@@ -153,10 +157,14 @@ static UInt32 getMetaType(QTMetaDataRef metaDataRef, QTMetaDataItem item)
OSStatus err = readMetaValue(
metaDataRef, item, kPropertyClass_MetaDataItem, kQTMetaDataItemPropertyID_DataType, &value, &ignore);
- UInt32 type = *((UInt32 *) value);
- if (value)
- free(value);
- return type;
+ if (err == noErr) {
+ UInt32 type = *((UInt32 *) value);
+ if (value)
+ free(value);
+ return type;
+ }
+
+ return 0;
}
static QString cFStringToQString(CFStringRef str)
@@ -179,23 +187,26 @@ static QString getMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, SInt
QTPropertyValuePtr value = 0;
ByteCount size = 0;
OSStatus err = readMetaValue(metaDataRef, item, kPropertyClass_MetaDataItem, id, &value, &size);
-
QString string;
- UInt32 dataType = getMetaType(metaDataRef, item);
- switch (dataType){
- case kQTMetaDataTypeUTF8:
- case kQTMetaDataTypeMacEncodedText:
- string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false));
- break;
- case kQTMetaDataTypeUTF16BE:
- string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false));
- break;
- default:
- break;
+
+ if (err == noErr) {
+ UInt32 dataType = getMetaType(metaDataRef, item);
+ switch (dataType){
+ case kQTMetaDataTypeUTF8:
+ case kQTMetaDataTypeMacEncodedText:
+ string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false));
+ break;
+ case kQTMetaDataTypeUTF16BE:
+ string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false));
+ break;
+ default:
+ break;
+ }
+
+ if (value)
+ free(value);
}
- if (value)
- free(value);
return string;
}
@@ -234,10 +245,11 @@ void QT7PlayerMetaDataControl::updateTags()
#ifdef QUICKTIME_C_API_AVAILABLE
QTMetaDataRef metaDataRef;
OSStatus err = QTCopyMovieMetaData([movie quickTimeMovie], &metaDataRef);
-
- readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap);
- readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap);
- readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap);
+ if (err == noErr) {
+ readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap);
+ readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap);
+ readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap);
+ }
#else
NSString *name = [movie attributeForKey:@"QTMovieDisplayNameAttribute"];
metaMap.insert(QLatin1String("nam"), QString::fromUtf8([name UTF8String]));