Get a list of file formats supported by a WMDM device
This commit is contained in:
parent
5001a5b3d1
commit
3e174b01b6
|
@ -212,3 +212,47 @@ bool WmdmDevice::DeleteFromStorage(const DeleteJob& job) {
|
|||
void WmdmDevice::FinishDelete(bool success) {
|
||||
FinishCopy(success);
|
||||
}
|
||||
|
||||
QList<Song::FileType> WmdmDevice::SupportedFiletypes() {
|
||||
QList<Song::FileType> ret;
|
||||
WmdmThread thread;
|
||||
|
||||
// Get the device
|
||||
WmdmLister* wmdm_lister = static_cast<WmdmLister*>(lister());
|
||||
QString canonical_name = wmdm_lister->DeviceCanonicalName(unique_id());
|
||||
IWMDMDevice* device = thread.GetDeviceByCanonicalName(canonical_name);
|
||||
|
||||
// Get a list of supported formats
|
||||
uint32_t format_count = 0;
|
||||
uint32_t mime_count = 0;
|
||||
_WAVEFORMATEX* formats;
|
||||
wchar_t** mime_types;
|
||||
|
||||
if (device->GetFormatSupport(
|
||||
&formats, &format_count, &mime_types, &mime_count)) {
|
||||
qWarning() << "Unable to get a list of supported formats for device" << canonical_name;
|
||||
device->Release();
|
||||
return ret;
|
||||
}
|
||||
device->Release();
|
||||
|
||||
// Find known mime types
|
||||
for (int i=0 ; i<mime_count ; ++i) {
|
||||
QString type = QString::fromWCharArray(mime_types[i]);
|
||||
if (type == "audio/mp3" || type == "audio/mpeg")
|
||||
ret << Song::Type_Mpeg;
|
||||
else if (type == "audio/x-ms-wma")
|
||||
ret << Song::Type_Asf;
|
||||
else if (type == "audio/wav")
|
||||
ret << Song::Type_Wav;
|
||||
else if (type == "audio/mp4")
|
||||
ret << Song::Type_Mp4;
|
||||
else if (type == "audio/ogg" || type == "audio/vorbis")
|
||||
ret << Song::Type_OggVorbis;
|
||||
}
|
||||
|
||||
CoTaskMemFree(formats);
|
||||
CoTaskMemFree(mime_types);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
void Init();
|
||||
|
||||
QList<Song::FileType> SupportedFiletypes();
|
||||
|
||||
void StartCopy();
|
||||
bool CopyToStorage(const CopyJob& job);
|
||||
void FinishCopy(bool success);
|
||||
|
|
Loading…
Reference in New Issue