30 #include <nsAlgorithm.h>
31 #include <nsArrayUtils.h>
32 #include <nsAutoPtr.h>
35 #include <nsComponentManagerUtils.h>
36 #include <nsIDOMWindow.h>
37 #include <nsIDialogParamBlock.h>
38 #include <nsIMutableArray.h>
40 #include <nsISimpleEnumerator.h>
41 #include <nsIStandardURL.h>
42 #include <nsISupportsArray.h>
45 #include <nsIWindowWatcher.h>
47 #include <nsThreadUtils.h>
51 #include "sbIDeviceCapabilities.h"
52 #include "sbIDeviceContent.h"
53 #include "sbIDeviceErrorMonitor.h"
54 #include "sbIDeviceHelper.h"
55 #include "sbIDeviceLibrary.h"
56 #include "sbIDeviceLibraryMediaSyncSettings.h"
57 #include "sbIDeviceLibrarySyncSettings.h"
58 #include "sbIDeviceRegistrar.h"
59 #include "sbIMediaItem.h"
60 #include <sbIMediaItemDownloader.h>
61 #include <sbIMediaItemDownloadService.h>
62 #include "sbIMediaList.h"
63 #include "sbIMediaListListener.h"
64 #include <sbITranscodeProfile.h>
65 #include <sbITranscodeManager.h>
66 #include <sbIPrompter.h>
67 #include "sbIWindowWatcher.h"
77 #include <sbIMediaInspector.h>
80 static PRLogModuleInfo* gDeviceUtilsLog = NULL;
83 if (!gDeviceUtilsLog) \
84 gDeviceUtilsLog = PR_NewLogModule("sbDeviceUtils"); \
85 PR_LOG(gDeviceUtilsLog, PR_LOG_WARN, args); \
89 if (!gDeviceUtilsLog) \
90 gDeviceUtilsLog = PR_NewLogModule("sbDeviceUtils"); \
91 PR_LOG(gDeviceUtilsLog, PR_LOG_DEBUG, args); \
94 #define LOG(args) PR_BEGIN_MACRO PR_END_MACRO
95 #define TRACE(args) PR_BEGIN_MACRO PR_END_MACRO
102 NS_DECL_SBICALLWITHWINDOWCALLBACK
106 PRInt64 aSpaceNeeded,
107 PRInt64 aSpaceAvailable,
111 nsCOMPtr<sbIDevice> mDevice;
112 nsCOMPtr<sbIDeviceLibrary> mLibrary;
114 PRInt64 mSpaceNeeded;
115 PRInt64 mSpaceAvailable;
124 NS_ENSURE_ARG_POINTER(aParent);
125 NS_ENSURE_ARG_POINTER(aItem);
126 NS_ENSURE_ARG_POINTER(_retval);
130 nsString kIllegalChars = NS_ConvertASCIItoUTF16(FILE_ILLEGAL_CHARACTERS);
131 kIllegalChars.AppendLiteral(FILE_PATH_SEPARATOR);
133 nsCOMPtr<nsIFile>
file;
134 rv = aParent->Clone(getter_AddRefs(file));
139 NS_ENSURE_SUCCESS(rv, rv);
140 if (!propValue.IsEmpty()) {
142 rv = file->Append(propValue);
143 NS_ENSURE_SUCCESS(rv, rv);
148 NS_ENSURE_SUCCESS(rv, rv);
149 if (!propValue.IsEmpty()) {
151 rv = file->Append(propValue);
152 NS_ENSURE_SUCCESS(rv, rv);
155 nsCOMPtr<nsIURI> itemUri;
156 rv = aItem->GetContentSrc(getter_AddRefs(itemUri));
157 NS_ENSURE_SUCCESS(rv, rv);
159 nsCOMPtr<nsIURL> itemUrl = do_QueryInterface(itemUri, &rv);
160 NS_ENSURE_SUCCESS(rv, rv);
163 rv = itemUrl->GetFileName(fileCName);
164 NS_ENSURE_SUCCESS(rv, rv);
166 nsString fileName = NS_ConvertUTF8toUTF16(fileCName);
168 rv = file->Append(fileName);
169 NS_ENSURE_SUCCESS(rv, rv);
186 PRInt32 *aAbortFlag = nsnull)
196 NS_ENSURE_ARG_POINTER(_retval);
198 PRBool abortRequests = PR_FALSE;
214 NS_ENSURE_ARG_POINTER(aItem);
215 NS_ENSURE_ARG_POINTER(_retval);
217 PRBool abortRequests = PR_FALSE;
226 nsresult rv = aItem->SetProperty(
mId,
mValue);
227 NS_ENSURE_SUCCESS(rv, rv);
251 const nsAString& aPropertyId,
252 const nsAString& aPropertyValue,
256 NS_ENSURE_ARG_POINTER(aMediaList);
258 nsRefPtr<sbDeviceUtilsBulkSetPropertyEnumerationListener>
listener =
262 NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
264 if (!aPropertyFilter) {
266 return aMediaList->EnumerateAllItems(listener,
271 return aMediaList->EnumerateItemsByProperties(aPropertyFilter,
278 nsAString
const & aProperty,
283 NS_ASSERTION(aMediaList,
"Attempting to delete null media list");
285 nsCOMPtr<nsIArray>
array;
286 rv = aMediaList->GetItemsByProperty(aProperty,
288 getter_AddRefs(array));
289 if (NS_SUCCEEDED(rv)) {
291 nsCOMPtr<nsISimpleEnumerator> enumerator;
292 rv = array->Enumerate(getter_AddRefs(enumerator));
293 NS_ENSURE_SUCCESS(rv, rv);
295 return aMediaList->RemoveSome(enumerator);
298 else if (rv == NS_ERROR_NOT_AVAILABLE) {
310 NS_LITERAL_STRING(
"0"));
318 NS_ASSERTION(aDevice,
"Getting device library with no device");
319 NS_ASSERTION(aItem,
"Getting device library for nothing");
320 NS_ASSERTION(_retval,
"null retval");
324 nsCOMPtr<sbILibrary> ownerLibrary;
325 rv = aItem->GetLibrary(getter_AddRefs(ownerLibrary));
326 NS_ENSURE_SUCCESS(rv, rv);
329 NS_ENSURE_SUCCESS(rv, rv);
336 const nsCString& aSpec,
340 NS_ENSURE_ARG_POINTER(aDeviceLibrary);
341 NS_ENSURE_ARG_POINTER(aURI);
347 nsCOMPtr<sbIDevice> device;
348 rv = aDeviceLibrary->GetDevice(getter_AddRefs(device));
349 NS_ENSURE_SUCCESS(rv, rv);
352 char deviceIDString[NSID_LENGTH];
355 NS_ENSURE_SUCCESS(rv, rv);
356 deviceID->ToProvidedString(deviceIDString);
360 rv = aDeviceLibrary->GetGuid(guid);
361 NS_ENSURE_SUCCESS(rv, rv);
364 nsCAutoString baseURISpec;
365 baseURISpec.Assign(
"x-device:///");
366 baseURISpec.Append(deviceIDString);
367 baseURISpec.Append(
"/");
368 baseURISpec.Append(NS_ConvertUTF16toUTF8(guid));
369 baseURISpec.Append(
"/");
372 nsCOMPtr<nsIStandardURL>
373 baseStandardURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
374 NS_ENSURE_SUCCESS(rv, rv);
375 rv = baseStandardURL->Init(nsIStandardURL::URLTYPE_NO_AUTHORITY,
380 NS_ENSURE_SUCCESS(rv, rv);
381 nsCOMPtr<nsIURI> baseURI = do_QueryInterface(baseStandardURL, &rv);
382 NS_ENSURE_SUCCESS(rv, rv);
385 nsCOMPtr<nsIStandardURL>
386 standardURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
387 NS_ENSURE_SUCCESS(rv, rv);
388 rv = standardURL->Init(nsIStandardURL::URLTYPE_NO_AUTHORITY,
393 NS_ENSURE_SUCCESS(rv, rv);
396 rv = CallQueryInterface(standardURL, aURI);
397 NS_ENSURE_SUCCESS(rv, rv);
407 NS_ASSERTION(aDevice,
"Getting device library with no device");
408 NS_ASSERTION(aLibrary,
"Getting device library for nothing");
409 NS_ASSERTION(_retval,
"null retval");
414 nsCOMPtr<sbIDeviceContent> content;
415 rv = aDevice->GetContent(getter_AddRefs(content));
416 NS_ENSURE_SUCCESS(rv, rv);
418 nsCOMPtr<nsIArray> libraries;
419 rv = content->GetLibraries(getter_AddRefs(libraries));
420 NS_ENSURE_SUCCESS(rv, rv);
422 PRUint32 libraryCount;
423 rv = libraries->GetLength(&libraryCount);
424 NS_ENSURE_SUCCESS(rv, rv);
426 for (PRUint32 index = 0; index < libraryCount; ++index) {
427 nsCOMPtr<sbIDeviceLibrary> deviceLib =
428 do_QueryElementAt(libraries, index, &rv);
432 PRBool equalsLibrary;
433 rv = aLibrary->Equals(deviceLib, &equalsLibrary);
434 NS_ENSURE_SUCCESS(rv, rv);
437 deviceLib.forget(_retval);
443 return NS_ERROR_FAILURE;
449 const nsAString& aDevicePersistentId,
452 NS_ENSURE_ARG_POINTER(aLibrary);
453 NS_ENSURE_ARG_POINTER(aItem);
458 nsCOMPtr<nsIArray> mediaItemList;
459 rv = aLibrary->GetItemsByProperty
462 getter_AddRefs(mediaItemList));
463 if (rv == NS_ERROR_NOT_AVAILABLE)
464 return NS_ERROR_NOT_AVAILABLE;
465 NS_ENSURE_SUCCESS(rv, rv);
471 rv = mediaItemList->GetLength(&length);
472 NS_ENSURE_SUCCESS(rv, rv);
473 for (PRUint32
i = 0;
i < length;
i++) {
475 nsCOMPtr<sbIMediaItem> mediaItem;
476 rv = mediaItemList->QueryElementAt(
i,
478 getter_AddRefs(mediaItem));
479 NS_ENSURE_SUCCESS(rv, rv);
482 nsAutoString devicePersistentId;
483 rv = mediaItem->GetProperty
486 NS_ENSURE_SUCCESS(rv, rv);
487 if (aDevicePersistentId.Equals(devicePersistentId)) {
488 mediaItem.forget(aItem);
493 return NS_ERROR_NOT_AVAILABLE;
499 const nsAString& aDevicePersistentId,
502 NS_ENSURE_ARG_POINTER(aLibrary);
503 NS_ENSURE_ARG_POINTER(aItem);
508 nsCOMPtr<sbIMediaItem> deviceMediaItem;
509 rv = GetMediaItemByDevicePersistentId(aLibrary,
511 getter_AddRefs(deviceMediaItem));
512 NS_ENSURE_SUCCESS(rv, rv);
516 NS_ENSURE_SUCCESS(rv, rv);
524 PRUint64* aWriteLength)
527 NS_ENSURE_ARG_POINTER(aMediaItem);
528 NS_ENSURE_ARG_POINTER(aWriteLength);
537 nsCOMPtr<sbIMediaItemDownloadService> downloadService =
538 do_GetService(
"@songbirdnest.com/Songbird/MediaItemDownloadService;1", &rv);
539 NS_ENSURE_SUCCESS(rv, rv);
542 nsCOMPtr<sbIMediaItemDownloader> downloader;
543 rv = downloadService->GetDownloader(aMediaItem,
545 getter_AddRefs(downloader));
546 NS_ENSURE_SUCCESS(rv, rv);
551 rv = downloader->GetDownloadSize(aMediaItem,
554 NS_ENSURE_SUCCESS(rv, rv);
561 NS_ENSURE_SUCCESS(rv, rv);
562 NS_ENSURE_TRUE(contentLength >= 0, NS_ERROR_FAILURE);
574 PRInt64 aSpaceNeeded,
575 PRInt64 aSpaceAvailable,
578 NS_ENSURE_ARG_POINTER(aDevice);
579 NS_ENSURE_ARG_POINTER(aLibrary);
580 NS_ENSURE_ARG_POINTER(aAbort);
585 nsRefPtr<sbDeviceUtilsQueryUserSpaceExceeded> query;
587 NS_ENSURE_TRUE(query, NS_ERROR_OUT_OF_MEMORY);
588 rv = query->Query(aDevice, aLibrary, aSpaceNeeded, aSpaceAvailable, aAbort);
589 NS_ENSURE_SUCCESS(rv, rv);
597 NS_ENSURE_ARG_POINTER(aAbort);
605 nsCOMPtr<sbIPrompter> prompter =
607 NS_ENSURE_SUCCESS(rv, rv);
608 rv = prompter->SetWaitForWindow(PR_FALSE);
609 NS_ENSURE_SUCCESS(rv, rv);
612 nsAString
const& title =
620 PRUint32 buttonFlags = nsIPromptService::STD_YES_NO_BUTTONS;
623 PRInt32 buttonPressed;
624 rv = prompter->ConfirmEx(nsnull,
625 title.BeginReading(),
626 message.BeginReading(),
634 NS_ENSURE_SUCCESS(rv, rv);
637 *aAbort = (buttonPressed == 0);
645 NS_ENSURE_ARG_POINTER(aDevice);
648 nsCOMPtr<sbIDeviceErrorMonitor> errMonitor =
649 do_GetService(
"@songbirdnest.com/device/error-monitor-service;1", &rv);
650 NS_ENSURE_SUCCESS(rv, rv);
653 rv = errMonitor->DeviceHasErrors(aDevice, EmptyString(), 0, &hasErrors);
654 NS_ENSURE_SUCCESS(rv, rv);
660 nsCOMPtr<sbIPrompter> prompter =
662 NS_ENSURE_SUCCESS(rv, rv);
663 rv = prompter->SetWaitForWindow(PR_FALSE);
664 NS_ENSURE_SUCCESS(rv, rv);
667 nsAString
const& title =
675 PRUint32 buttonFlags = nsIPromptService::STD_YES_NO_BUTTONS;
678 PRInt32 buttonPressed;
679 rv = prompter->ConfirmEx(nsnull,
680 title.BeginReading(),
681 message.BeginReading(),
689 NS_ENSURE_SUCCESS(rv, rv);
691 if (buttonPressed == 0) {
703 NS_ENSURE_ARG_POINTER(aDevice);
717 nsCOMPtr<nsIDialogParamBlock> dialogBlock =
718 do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID, &rv);
719 NS_ENSURE_SUCCESS(rv, rv);
723 rv = dialogBlock->SetString(0, NS_LITERAL_STRING(
"").
get());
724 NS_ENSURE_SUCCESS(rv, rv);
726 rv = dialogBlock->SetString(1, NS_LITERAL_STRING(
"ripping").
get());
727 NS_ENSURE_SUCCESS(rv, rv);
730 nsCOMPtr<nsIMutableArray> objects =
731 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
732 NS_ENSURE_SUCCESS(rv, rv);
734 rv = objects->AppendElement(aDevice, PR_FALSE);
735 NS_ENSURE_SUCCESS(rv, rv);
737 nsCOMPtr<sbIDeviceErrorMonitor> errMonitor =
738 do_GetService(
"@songbirdnest.com/device/error-monitor-service;1", &rv);
739 NS_ENSURE_SUCCESS(rv, rv);
740 nsCOMPtr<nsIArray> errorStrings;
741 rv = errMonitor->GetDeviceErrors(aDevice,
744 getter_AddRefs(errorStrings));
745 NS_ENSURE_SUCCESS(rv, rv);
746 rv = objects->AppendElement(errorStrings, PR_FALSE);
747 NS_ENSURE_SUCCESS(rv, rv);
749 rv = dialogBlock->SetObjects(objects);
750 NS_ENSURE_SUCCESS(rv, rv);
753 nsCOMPtr<nsISupports>
arguments = do_QueryInterface(dialogBlock, &rv);
754 NS_ENSURE_SUCCESS(rv, rv);
757 nsCOMPtr<sbIPrompter> prompter =
759 NS_ENSURE_SUCCESS(rv, rv);
760 rv = prompter->SetWaitForWindow(PR_FALSE);
761 NS_ENSURE_SUCCESS(rv, rv);
764 nsCOMPtr<nsIDOMWindow> dialogWindow;
765 rv = prompter->OpenDialog(nsnull,
766 NS_LITERAL_STRING(
"chrome://songbird/content/xul/device/deviceErrorDialog.xul"),
767 NS_LITERAL_STRING(
"device_error_dialog"),
768 NS_LITERAL_STRING(
"chrome,centerscreen,model=yes,titlebar=no"),
770 getter_AddRefs(dialogWindow));
771 NS_ENSURE_SUCCESS(rv, rv);
780 NS_ENSURE_ARG_POINTER(aDevice);
787 PRBool deviceIsLinked;
788 nsCOMPtr<nsIVariant> deviceSyncPartnerIDVariant;
789 nsAutoString deviceSyncPartnerID;
790 rv = aDevice->GetPreference(NS_LITERAL_STRING(
"SyncPartner"),
791 getter_AddRefs(deviceSyncPartnerIDVariant));
792 if (NS_SUCCEEDED(rv)) {
793 rv = deviceSyncPartnerIDVariant->GetAsAString(deviceSyncPartnerID);
794 NS_ENSURE_SUCCESS(rv, rv);
795 deviceIsLinked = PR_TRUE;
797 deviceIsLinked = PR_FALSE;
801 nsAutoString localSyncPartnerID;
803 NS_ENSURE_SUCCESS(rv, rv);
806 PRBool isLinkedLocally = PR_FALSE;
808 isLinkedLocally = deviceSyncPartnerID.Equals(localSyncPartnerID);
811 if (!isLinkedLocally) {
812 rv = aDevice->SetPreference(NS_LITERAL_STRING(
"SyncPartner"),
814 NS_ENSURE_SUCCESS(rv, rv);
820 SB_AUTO_CLASS(sbAutoNSMemoryPtr,
void*, !!mValue, NS_Free(mValue), mValue = nsnull);
824 nsCOMPtr<sbIDeviceCapabilities> capabilities;
825 nsresult rv = aDevice->GetCapabilities(getter_AddRefs(capabilities));
826 NS_ENSURE_SUCCESS(rv,
false);
828 bool supported =
false;
829 PRUint32 * functionTypes;
830 PRUint32 functionTypesLength;
831 rv = capabilities->GetSupportedFunctionTypes(&functionTypesLength,
833 NS_ENSURE_SUCCESS(rv,
false);
834 sbAutoNSMemoryPtr functionTypesPtr(functionTypes);
835 for (PRUint32 functionType = 0;
836 !supported && functionType < functionTypesLength;
838 PRUint32 * contentTypes;
839 PRUint32 contentTypesLength;
840 rv = capabilities->GetSupportedContentTypes(functionTypes[functionType],
843 NS_ENSURE_SUCCESS(rv,
false);
844 sbAutoNSMemoryPtr contentTypesPtr(contentTypes);
845 PRUint32 *
const end = contentTypes + contentTypesLength;
846 PRUint32
const CONTENT_PLAYLIST =
848 supported = std::find(contentTypes,
850 CONTENT_PLAYLIST) != end;
867 NS_ENSURE_ARG_POINTER(aWindow);
872 nsCOMPtr<sbIDeviceHelper> deviceHelper =
873 do_GetService(
"@songbirdnest.com/Songbird/Device/Base/Helper;1", &rv);
874 NS_ENSURE_SUCCESS(rv, rv);
878 rv = deviceHelper->QueryUserSpaceExceeded(aWindow,
884 NS_ENSURE_SUCCESS(rv, rv);
895 PRInt64 aSpaceNeeded,
896 PRInt64 aSpaceAvailable,
904 mSpaceNeeded = aSpaceNeeded;
905 mSpaceAvailable = aSpaceAvailable;
909 nsCOMPtr<sbIWindowWatcher> windowWatcher;
910 windowWatcher = do_GetService(
"@songbirdnest.com/Songbird/window-watcher;1",
912 NS_ENSURE_SUCCESS(rv, rv);
913 rv = windowWatcher->CallWithWindow(NS_LITERAL_STRING(
"Songbird:Main"),
916 NS_ENSURE_SUCCESS(rv, rv);
982 const PRInt32
K = 1000;
990 TRACE((
"%s: %s", __FUNCTION__, NS_LossyConvertUTF16toASCII(aValue).
get()));
992 if (aValue.IsEmpty()) {
995 PRUint32
val = aValue.ToInteger(&rv, 10);
1013 PRUint32 & aBitRate,
1014 PRUint32 & aSampleRate)
1016 TRACE((
"%s", __FUNCTION__));
1017 NS_ENSURE_ARG_POINTER(aItem);
1023 nsString contentURL;
1026 NS_ENSURE_SUCCESS(rv, rv);
1030 if (rv == NS_ERROR_NOT_AVAILABLE)
1032 NS_ENSURE_SUCCESS(rv, rv);
1037 NS_ENSURE_SUCCESS(rv, rv);
1041 nsString sampleRate;
1044 NS_ENSURE_SUCCESS(rv, rv);
1062 PRUint32 & aSampleRate,
1063 PRUint32 & aChannels,
1064 PRUint32 & aBitRate)
1066 TRACE((
"%s", __FUNCTION__));
1067 NS_ENSURE_ARG_POINTER(aItem);
1073 nsString contentURL;
1076 NS_ENSURE_SUCCESS(rv, rv);
1080 if (rv == NS_ERROR_NOT_AVAILABLE)
1082 NS_ENSURE_SUCCESS(rv, rv);
1087 NS_ENSURE_SUCCESS(rv, rv);
1091 nsString sampleRate;
1094 NS_ENSURE_SUCCESS(rv, rv);
1101 NS_ENSURE_SUCCESS(rv, rv);
1117 TRACE((
"%s", __FUNCTION__));
1118 NS_ENSURE_ARG_POINTER(aURI);
1123 nsCAutoString uriSpec;
1124 rv = aURI->GetSpec(uriSpec);
1125 NS_ENSURE_SUCCESS(rv, rv);
1128 return GetFormatTypeForURL(NS_ConvertUTF8toUTF16(uriSpec), aFormatType);
1138 (
const nsAString& aURL,
1141 TRACE((
"%s", __FUNCTION__));
1143 PRInt32
const lastDot = aURL.RFind(NS_LITERAL_STRING(
"."));
1144 if (lastDot != -1) {
1145 nsDependentSubstring fileExtension(aURL,
1147 aURL.Length() - lastDot - 1);
1148 nsCAutoString extension = NS_ConvertUTF16toUTF8(fileExtension);
1149 ToLowerCase(extension);
1150 for (PRUint32 index = 0;
1155 if (extension.EqualsLiteral(entry.
Extension)) {
1156 TRACE((
"%s: ext %s type %s container %s codec %s",
1159 aFormatType =
entry;
1165 return NS_ERROR_NOT_AVAILABLE;
1175 (
const nsAString& aMimeType,
1176 const PRUint32 aContentType,
1177 nsTArray<sbExtensionToContentFormatEntry_t>& aFormatTypeList)
1179 TRACE((
"%s", __FUNCTION__));
1181 aFormatTypeList.Clear();
1182 for (PRUint32 index = 0;
1188 if (aMimeType.EqualsLiteral(entry.
MimeType) &&
1190 TRACE((
"%s: ext %s type %s container %s codec %s",
1193 NS_ENSURE_TRUE(aFormatTypeList.AppendElement(entry),
1194 NS_ERROR_OUT_OF_MEMORY);
1211 const nsAString& aCodec,
1212 nsAString& aMimeType)
1214 TRACE((
"%s", __FUNCTION__));
1217 for (PRUint32 index = 0;
1230 aCodec.EqualsLiteral(entry.
Codec)) {
1231 TRACE((
"%s: container %s codec %s mime type %s",
1233 aMimeType.AssignLiteral(entry.
MimeType);
1238 return NS_ERROR_NOT_AVAILABLE;
1256 PRUint32 aContentType,
1257 nsAString & aContainerFormat,
1258 nsAString & aVideoType,
1259 nsAString & aAudioType,
1266 TRACE((
"%s", __FUNCTION__));
1268 switch (aContentType) {
1270 nsCOMPtr<sbIAudioFormatType> audioFormat =
1271 do_QueryInterface(aFormatType);
1274 audioFormat->GetContainerFormat(temp);
1275 aContainerFormat = NS_ConvertASCIItoUTF16(temp);
1276 audioFormat->GetAudioCodec(temp);
1277 aCodec = NS_ConvertASCIItoUTF16(temp);
1278 if (aBitRateRange) {
1279 audioFormat->GetSupportedBitrates(aBitRateRange);
1281 if (aSampleRateRange) {
1282 audioFormat->GetSupportedSampleRates(aSampleRateRange);
1288 nsCOMPtr<sbIImageFormatType> imageFormat =
1289 do_QueryInterface(aFormatType);
1292 imageFormat->GetImageFormat(temp);
1293 aContainerFormat = NS_ConvertASCIItoUTF16(temp);
1294 if (aBitRateRange) {
1295 *aBitRateRange = nsnull;
1297 if (aSampleRateRange) {
1298 *aSampleRateRange = nsnull;
1304 nsCOMPtr<sbIVideoFormatType> videoFormat =
1305 do_QueryInterface(aFormatType);
1308 nsCOMPtr<sbIDevCapVideoStream> videoStream;
1309 rv = videoFormat->GetVideoStream(getter_AddRefs(videoStream));
1310 NS_ENSURE_SUCCESS(rv, rv);
1312 nsCOMPtr<sbIDevCapAudioStream> audioStream;
1313 rv = videoFormat->GetAudioStream(getter_AddRefs(audioStream));
1314 nsCString videoType;
1315 if (aBitRateRange && videoStream) {
1316 videoStream->GetSupportedBitRates(aBitRateRange);
1317 rv = videoStream->GetType(videoType);
1318 NS_ENSURE_SUCCESS(rv, rv);
1319 aVideoType = NS_ConvertASCIItoUTF16(videoType);
1321 nsCString audioType;
1322 if (aSampleRateRange && audioStream) {
1323 audioStream->GetSupportedSampleRates(aSampleRateRange);
1324 rv = audioStream->GetType(audioType);
1325 NS_ENSURE_SUCCESS(rv, rv);
1326 aAudioType = NS_ConvertASCIItoUTF16(audioType);
1329 if (aSampleRateRange) {
1330 *aSampleRateRange = nsnull;
1335 NS_WARNING(
"Unexpected content type in GetContainerFormatAndCodec");
1336 if (aBitRateRange) {
1337 *aBitRateRange = nsnull;
1339 if (aSampleRateRange) {
1340 *aSampleRateRange = nsnull;
1354 "@songbirdnest.com/Songbird/Mediacore/TranscodeManager;1", &rv);
1355 NS_ENSURE_SUCCESS(rv, rv);
1357 rv = tcManager->GetTranscodeProfiles(aType, aProfiles);
1358 NS_ENSURE_SUCCESS(rv, rv);
1366 nsIArray **aProfiles)
1368 TRACE((
"%s", __FUNCTION__));
1369 NS_ENSURE_ARG_POINTER(aDevice);
1370 NS_ENSURE_ARG_POINTER(aProfiles);
1374 nsCOMPtr<nsIMutableArray> supportedProfiles = do_CreateInstance(
1376 NS_ENSURE_SUCCESS(rv, rv);
1378 nsCOMPtr<nsIArray> profiles;
1380 NS_ENSURE_SUCCESS(rv, rv);
1382 nsCOMPtr<sbIDeviceCapabilities> devCaps;
1383 rv = aDevice->GetCapabilities(getter_AddRefs(devCaps));
1384 NS_ENSURE_SUCCESS(rv, rv);
1387 static PRUint32 contentTypes[] = {
1394 for (PRUint32 contentTypeIndex = 0;
1395 contentTypeIndex < NS_ARRAY_LENGTH(contentTypes);
1398 PRUint32
const contentType = contentTypes[contentTypeIndex];
1399 TRACE((
"%s: Finding profiles for content type %d", __FUNCTION__, contentType));
1400 PRUint32 mimeTypesLength;
1402 rv = devCaps->GetSupportedMimeTypes(contentType,
1407 if (rv != NS_ERROR_NOT_AVAILABLE) {
1408 NS_ENSURE_SUCCESS(rv, rv);
1410 if (NS_SUCCEEDED(rv)) {
1411 TRACE((
"%s: Checking %d mime types for type %d", __FUNCTION__,
1412 mimeTypesLength, contentType));
1414 for (PRUint32 mimeTypeIndex = 0;
1415 mimeTypeIndex < mimeTypesLength && NS_SUCCEEDED(rv);
1418 TRACE((
"%s: Checking mime type %s", __FUNCTION__,
1419 mimeTypes[mimeTypeIndex]));
1421 mimeType.AssignLiteral(mimeTypes[mimeTypeIndex]);
1422 NS_Free(mimeTypes[mimeTypeIndex]);
1425 PRUint32 formatTypeCount;
1426 rv = devCaps->GetFormatTypes(contentType,
1430 NS_ENSURE_SUCCESS (rv, rv);
1434 for (PRUint32 formatIndex = 0;
1435 formatIndex < formatTypeCount;
1438 nsCOMPtr<nsISupports> formatTypeSupports = formatTypes[formatIndex];
1440 nsString containerFormat;
1450 NS_ENSURE_SUCCESS(rv, rv);
1451 TRACE((
"%s: Checking format %d with container %s, video %s, audio %s, codec %s",
1452 __FUNCTION__, formatIndex,
1453 NS_ConvertUTF16toUTF8(containerFormat).BeginReading(),
1454 NS_ConvertUTF16toUTF8(videoType).BeginReading(),
1455 NS_ConvertUTF16toUTF8(audioType).BeginReading(),
1456 NS_ConvertUTF16toUTF8(codec).BeginReading()));
1460 rv = profiles->GetLength(&length);
1461 NS_ENSURE_SUCCESS(rv, rv);
1463 for (PRUint32 index = 0;
1464 index < length && NS_SUCCEEDED(rv);
1467 nsCOMPtr<sbITranscodeProfile> profile = do_QueryElementAt(profiles,
1470 NS_ENSURE_SUCCESS(rv, rv);
1471 nsString profileContainerFormat;
1472 rv = profile->GetContainerFormat(profileContainerFormat);
1473 NS_ENSURE_SUCCESS(rv, rv);
1475 PRUint32 profileType;
1476 rv = profile->GetType(&profileType);
1477 NS_ENSURE_SUCCESS(rv, rv);
1479 nsString audioCodec;
1480 rv = profile->GetAudioCodec(audioCodec);
1481 NS_ENSURE_SUCCESS(rv, rv);
1483 nsString videoCodec;
1484 rv = profile->GetVideoCodec(videoCodec);
1486 if (TranscodeToCapsContentTypeMap[profileType] == contentType &&
1487 profileContainerFormat.Equals(containerFormat))
1490 audioCodec.Equals(codec)) ||
1492 videoCodec.Equals(codec)))
1494 TRACE((
"%s: Adding this format", __FUNCTION__));
1495 rv = supportedProfiles->AppendElement(profile, PR_FALSE);
1496 NS_ENSURE_SUCCESS(rv, rv);
1506 rv = CallQueryInterface(supportedProfiles.get(), aProfiles);
1507 NS_ENSURE_SUCCESS(rv, rv);
1520 if (!aValue || !aRange) {
1525 NS_ENSURE_SUCCESS(rv, PR_FALSE);
1527 return inRange != PR_FALSE;
1542 PRUint32 & aBitRate,
1543 PRUint32 & aSampleRate,
1545 bool & aNeedsTranscoding)
1547 TRACE((
"%s", __FUNCTION__));
1548 nsCOMPtr<sbIDeviceCapabilities> devCaps;
1549 nsresult rv = aDevice->GetCapabilities(getter_AddRefs(devCaps));
1550 NS_ENSURE_SUCCESS(rv, rv);
1552 PRInt32
const devCapContentType =
1555 nsString itemContainerFormat;
1558 itemCodec.AssignLiteral(aFormatType.
Codec);
1560 LOG((
"Determining if item needs transcoding\n\tItem Container: '%s'\n\tItem Codec: '%s'",
1561 NS_LossyConvertUTF16toASCII(itemContainerFormat).
get(),
1562 NS_LossyConvertUTF16toASCII(itemCodec).
get()));
1564 PRUint32 mimeTypesLength;
1566 rv = devCaps->GetSupportedMimeTypes(devCapContentType,
1570 if (NS_SUCCEEDED(rv) && mimeTypesLength > 0) {
1571 aNeedsTranscoding =
true;
1572 for (PRUint32 mimeTypesIndex = 0;
1573 mimeTypesIndex < mimeTypesLength;
1576 NS_ConvertASCIItoUTF16 mimeType(mimeTypes[mimeTypesIndex]);
1578 PRUint32 formatTypeCount;
1579 rv = devCaps->GetFormatTypes(devCapContentType,
1583 NS_ENSURE_SUCCESS (rv, rv);
1587 for (PRUint32 formatIndex = 0;
1588 formatIndex < formatTypeCount;
1591 nsCOMPtr<nsISupports> formatType = formatTypes[formatIndex];
1592 nsString containerFormat;
1595 nsCOMPtr<sbIDevCapRange> bitRateRange;
1596 nsCOMPtr<sbIDevCapRange> sampleRateRange;
1605 getter_AddRefs(bitRateRange),
1606 getter_AddRefs(sampleRateRange));
1607 if (NS_SUCCEEDED(rv)) {
1609 LOG((
"Comparing container and codec\n\tCaps Container: '%s'\n\tCaps Codec: '%s'",
1610 NS_LossyConvertUTF16toASCII(containerFormat).
get(),
1611 NS_LossyConvertUTF16toASCII(codec).
get()));
1615 if (containerFormat.Equals(itemContainerFormat) &&
1616 codec.Equals(itemCodec) &&
1620 TRACE((
"%s: no transcoding needed, matches mime type '%s' "
1621 "container '%s' codec '%s'",
1622 __FUNCTION__, mimeTypes[mimeTypesIndex],
1623 NS_LossyConvertUTF16toASCII(containerFormat).
get(),
1624 NS_LossyConvertUTF16toASCII(codec).
get()));
1625 aNeedsTranscoding =
false;
1631 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mimeTypesLength, mimeTypes);
1634 TRACE((
"%s: no information on device, assuming no transcoding needed",
1636 aNeedsTranscoding =
false;
1638 TRACE((
"%s: result %s", __FUNCTION__, aNeedsTranscoding ?
"yes" :
"no"));
1646 bool & aNeedsTranscoding)
1648 TRACE((
"%s", __FUNCTION__));
1649 nsCOMPtr<sbIDeviceCapabilities> devCaps;
1650 nsresult rv = aDevice->GetCapabilities(getter_AddRefs(devCaps));
1651 NS_ENSURE_SUCCESS(rv, rv);
1653 PRInt32
const devCapContentType =
1654 TranscodeToCapsContentTypeMap[aTranscodeType];
1656 nsCOMPtr<sbIDeviceCapsCompatibility> devCompatible =
1658 NS_ENSURE_SUCCESS(rv, rv);
1659 rv = devCompatible->Initialize(devCaps, aMediaFormat, devCapContentType);
1660 NS_ENSURE_SUCCESS(rv, rv);
1663 rv = devCompatible->Compare(&compatible);
1664 NS_ENSURE_SUCCESS(rv, rv);
1666 aNeedsTranscoding = !compatible;
1673 PRUint32 aTranscodeType,
1677 nsCOMPtr<sbIDeviceTranscodingConfigurator> configurator;
1679 configurator = do_CreateInstance(
1680 "@songbirdnest.com/Songbird/Mediacore/Transcode/Configurator/"
1681 "Audio/GStreamer;1", &rv);
1682 NS_ENSURE_SUCCESS(rv, rv);
1685 configurator = do_CreateInstance(
1686 "@songbirdnest.com/Songbird/Mediacore/Transcode/Configurator/"
1687 "Device/GStreamer;1", &rv);
1688 NS_ENSURE_SUCCESS(rv, rv);
1691 NS_ADDREF (*aConfigurator = configurator);
1698 nsIArray* aPropertyArray,
1699 nsString aPrefNameBase)
1703 if(!aPropertyArray) {
1708 PRUint32 numProperties;
1709 rv = aPropertyArray->GetLength(&numProperties);
1710 NS_ENSURE_SUCCESS(rv, rv);
1712 for (PRUint32
i = 0;
i < numProperties;
i++) {
1713 nsCOMPtr<sbITranscodeProfileProperty>
property =
1714 do_QueryElementAt(aPropertyArray,
i, &rv);
1715 NS_ENSURE_SUCCESS(rv, rv);
1718 rv =
property->GetPropertyName(propName);
1719 NS_ENSURE_SUCCESS(rv, rv);
1721 nsString prefName = aPrefNameBase;
1722 prefName.AppendLiteral(
".");
1723 prefName.Append(propName);
1725 nsCOMPtr<nsIVariant> prefVariant;
1726 rv = aDevice->GetPreference(prefName, getter_AddRefs(prefVariant));
1727 NS_ENSURE_SUCCESS(rv, rv);
1731 rv = prefVariant->GetDataType(&dataType);
1732 NS_ENSURE_SUCCESS(rv, rv);
1733 if (dataType != nsIDataType::VTYPE_VOID &&
1734 dataType != nsIDataType::VTYPE_EMPTY)
1736 rv =
property->SetValue(prefVariant);
1737 NS_ENSURE_SUCCESS(rv, rv);
1746 nsCString &aExtension)
1748 NS_ENSURE_TRUE(aProfile, NS_ERROR_UNEXPECTED);
1751 nsresult rv = aProfile->GetContainerFormat(temp);
1752 NS_ENSURE_SUCCESS(rv, rv);
1753 NS_ConvertUTF16toUTF8 containerFormat(temp);
1755 rv = aProfile->GetAudioCodec(temp);
1756 NS_ENSURE_SUCCESS(rv, rv);
1757 NS_ConvertUTF16toUTF8 codec(temp);
1759 for (PRUint32 index = 0;
1765 codec.Equals(entry.
Codec)) {
1766 aExtension.AssignLiteral(entry.
Extension);
1770 return NS_ERROR_NOT_AVAILABLE;
1776 nsCString &aContainer,
1778 nsCString &aVideoType,
1779 nsCString &aAudioType)
1781 for (PRUint32 index = 0;
1788 if (aMimeType.EqualsLiteral(entry.
MimeType)) {
1790 aCodec.AssignLiteral(entry.
Codec);
1791 aVideoType.AssignLiteral(entry.
VideoType);
1792 aAudioType.AssignLiteral(entry.
AudioType);
1797 return NS_ERROR_NOT_AVAILABLE;
1805 nsString isDRMProtected;
1808 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_AVAILABLE,
1809 "sbDeviceUtils::IsItemDRMProtected Unexpected error, "
1811 return NS_SUCCEEDED(rv) && isDRMProtected.EqualsLiteral(
"1");
1816 PRUint32 *aContentType,
1817 PRUint32 *aFunctionType)
1820 NS_ENSURE_ARG_POINTER(aMediaItem);
1821 NS_ENSURE_ARG_POINTER(aContentType);
1822 NS_ENSURE_ARG_POINTER(aFunctionType);
1829 nsString itemContentType;
1830 rv = aMediaItem->GetContentType(itemContentType);
1831 NS_ENSURE_SUCCESS(rv, rv);
1833 PRUint32 contentType, functionType;
1834 if (itemContentType.Equals(NS_LITERAL_STRING(
"audio"))) {
1838 else if (itemContentType.Equals(NS_LITERAL_STRING(
"video"))) {
1842 else if (itemContentType.Equals(NS_LITERAL_STRING(
"image"))) {
1847 NS_WARNING(
"sbDeviceUtils::GetDeviceCapsTypeFromMediaItem: "
1848 "returning unknown device capabilities type");
1853 *aContentType = contentType;
1854 *aFunctionType = functionType;
1860 PRUint32 *aContentType,
1861 PRUint32 *aFunctionType)
1863 NS_ENSURE_ARG_POINTER(aContentType);
1864 NS_ENSURE_ARG_POINTER(aFunctionType);
1866 PRUint32 contentType, functionType;
1877 NS_WARNING(
"sbDeviceUtils::GetDeviceCapsTypeFromListContentType: "
1878 "returning unknown device capabilities type");
1883 *aContentType = contentType;
1884 *aFunctionType = functionType;
1893 NS_ENSURE_TRUE(aDevice, PR_FALSE);
1894 NS_ENSURE_TRUE(aMediaItem, PR_FALSE);
1898 PRUint32 contentType, functionType;
1902 NS_ENSURE_SUCCESS(rv, PR_FALSE);
1904 nsCOMPtr<sbIDeviceCapabilities> capabilities;
1905 rv = aDevice->GetCapabilities(getter_AddRefs(capabilities));
1906 NS_ENSURE_SUCCESS(rv, PR_FALSE);
1909 rv = capabilities->SupportsContent(functionType,
1912 NS_ENSURE_SUCCESS(rv, PR_FALSE);
1919 PRUint16 aListContentType)
1921 NS_ENSURE_TRUE(aDevice, PR_FALSE);
1925 PRUint32 contentType, functionType;
1929 NS_ENSURE_TRUE(NS_SUCCEEDED(rv), PR_FALSE);
1931 nsCOMPtr<sbIDeviceCapabilities> capabilities;
1932 rv = aDevice->GetCapabilities(getter_AddRefs(capabilities));
1933 NS_ENSURE_SUCCESS(rv, PR_FALSE);
1936 rv = capabilities->SupportsContent(functionType,
1939 NS_ENSURE_SUCCESS(rv, PR_FALSE);
1947 PRUint32 aContentType,
1948 nsTArray<nsString>& aFileExtensionList)
1951 NS_ENSURE_ARG_POINTER(aDevice);
1957 nsCOMPtr<sbIDeviceCapabilities> caps;
1958 rv = aDevice->GetCapabilities(getter_AddRefs(caps));
1959 NS_ENSURE_SUCCESS(rv, rv);
1963 char** mimeTypeList;
1964 PRUint32 mimeTypeCount;
1965 rv = caps->GetSupportedMimeTypes(aContentType, &mimeTypeCount, &mimeTypeList);
1966 if (rv == NS_ERROR_NOT_AVAILABLE)
1968 NS_ENSURE_SUCCESS(rv, rv);
1972 for (PRUint32
i = 0;
i < mimeTypeCount; ++
i) {
1974 nsTArray<sbExtensionToContentFormatEntry_t> formatTypeList;
1976 (NS_ConvertASCIItoUTF16(mimeTypeList[
i]),
1979 NS_ENSURE_SUCCESS(rv, rv);
1982 for (PRUint32 j = 0; j < formatTypeList.Length(); ++j) {
1984 NS_ConvertASCIItoUTF16 extension(formatTypeList[j].
Extension);
1985 if (!aFileExtensionList.Contains(extension)) {
1986 aFileExtensionList.AppendElement(extension);
1997 PRUint32 aMediaType,
2000 NS_ASSERTION(aDevLib,
"aDevLib is null");
2002 nsCOMPtr<sbIDeviceLibrarySyncSettings> syncSettings;
2003 nsresult rv = aDevLib->GetSyncSettings(getter_AddRefs(syncSettings));
2004 NS_ENSURE_SUCCESS(rv, rv);
2008 NS_ENSURE_SUCCESS(rv, rv);
2015 PRUint32 aMediaType,
2016 PRUint32 & aMgmtType)
2018 NS_ASSERTION(aDevLib,
"aDevLib is null");
2021 nsCOMPtr<sbIDeviceLibraryMediaSyncSettings> mediaSyncSettings;
2024 getter_AddRefs(mediaSyncSettings));
2025 NS_ENSURE_SUCCESS(rv, rv);
2027 rv = mediaSyncSettings->GetMgmtType(&aMgmtType);
2028 NS_ENSURE_SUCCESS(rv, rv);
2037 NS_ENSURE_ARG_POINTER(aDeviceLibrary);
2042 nsCOMPtr<sbIDeviceContent> content;
2043 rv = aDevice->GetContent(getter_AddRefs(content));
2044 NS_ENSURE_SUCCESS(rv, rv);
2046 nsCOMPtr<nsIArray> libraries;
2047 rv = content->GetLibraries(getter_AddRefs(libraries));
2048 NS_ENSURE_SUCCESS(rv, rv);
2050 PRUint32 libraryCount;
2051 rv = libraries->GetLength(&libraryCount);
2052 NS_ENSURE_SUCCESS(rv, rv);
2054 for (PRUint32 index = 0; index < libraryCount; ++index) {
2055 nsCOMPtr<sbIDeviceLibrary> deviceLib =
2056 do_QueryElementAt(libraries, index, &rv);
2060 nsString deviceLibGuid;
2061 rv = deviceLib->GetGuid(deviceLibGuid);
2062 NS_ENSURE_SUCCESS(rv, rv);
2064 if (deviceLibGuid.Equals(aDeviceLibGuid)) {
2065 deviceLib.forget(aDeviceLibrary);
2070 *aDeviceLibrary = nsnull;
2075 nsID
const * aDeviceID,
2078 NS_ENSURE_ARG_POINTER(aDeviceLibrary);
2082 nsCOMPtr<sbIDeviceLibrary> deviceLibrary;
2084 nsCOMPtr<sbIDeviceRegistrar> deviceRegistrar =
2085 do_GetService(
"@songbirdnest.com/Songbird/DeviceManager;2", &rv);
2088 nsCOMPtr<sbIDevice> device;
2089 rv = deviceRegistrar->GetDevice(aDeviceID, getter_AddRefs(device));
2090 NS_ENSURE_SUCCESS(rv, rv);
2093 NS_ENSURE_SUCCESS(rv, rv);
2096 nsCOMPtr<nsIArray> devices;
2097 rv = deviceRegistrar->GetDevices(getter_AddRefs(devices));
2098 NS_ENSURE_SUCCESS(rv, rv);
2099 nsCOMPtr<sbIDevice> device;
2101 rv = devices->GetLength(&length);
2102 for (PRUint32 index = 0; index < length && !deviceLibrary; ++index) {
2103 device = do_QueryElementAt(devices, index, &rv);
2104 NS_ENSURE_SUCCESS(rv, rv);
2107 NS_ENSURE_SUCCESS(rv, rv);
2111 deviceLibrary.forget(aDeviceLibrary);
2121 NS_ENSURE_ARG_POINTER(aMediaItem);
2122 NS_ENSURE_ARG_POINTER(aTargetLibrary);
2123 NS_ENSURE_ARG_POINTER(aSyncItem);
2130 NS_ENSURE_SUCCESS(rv, rv);
2135 nsCOMPtr<sbILibrary> sourceLibrary;
2136 rv = aMediaItem->GetLibrary(getter_AddRefs(sourceLibrary));
2137 NS_ENSURE_SUCCESS(rv, rv);
2140 nsAutoString outerGUID;
2143 NS_ENSURE_SUCCESS(rv, rv);
2144 if (!outerGUID.IsEmpty()) {
2146 nsCOMPtr<sbIMediaItem> outerMediaItem;
2147 rv = sourceLibrary->GetMediaItem(outerGUID, getter_AddRefs(outerMediaItem));
2148 NS_ENSURE_SUCCESS(rv, rv);
2154 NS_ENSURE_SUCCESS(rv, rv);
2160 nsAutoString storageGUID;
2163 NS_ENSURE_SUCCESS(rv, rv);
2164 if (!storageGUID.IsEmpty()) {
2166 nsCOMPtr<sbIMediaItem> storageMediaItem;
2167 rv = sourceLibrary->GetMediaItem(storageGUID,
2168 getter_AddRefs(storageMediaItem));
2169 NS_ENSURE_SUCCESS(rv, rv);
2175 NS_ENSURE_SUCCESS(rv, rv);
2181 *aSyncItem = nsnull;
2190 NS_ENSURE_ARG_POINTER(aMediaItem);
2194 NS_NAMED_LITERAL_STRING(SB_PROPERTY_TRUE,
"1");
2195 NS_NAMED_LITERAL_STRING(SB_PROPERTY_FALSE,
"0");
2197 nsCOMPtr<sbIMediaItem> itemInDeviceLibrary;
2200 getter_AddRefs(itemInDeviceLibrary));
2201 NS_ENSURE_SUCCESS(rv, rv);
2202 if (itemInDeviceLibrary) {
2203 nsString inMainLibrary;
2204 rv = itemInDeviceLibrary->GetProperty(
2207 NS_ENSURE_SUCCESS(rv, rv);
2209 if (NS_FAILED(rv) || inMainLibrary.IsVoid()) {
2210 inMainLibrary = SB_PROPERTY_FALSE;
2213 const PRBool isMarked =
2214 !inMainLibrary.Equals(SB_PROPERTY_FALSE) ? PR_TRUE : PR_FALSE;
2215 if (aMark != isMarked) {
2216 rv = itemInDeviceLibrary->SetProperty(
2218 aMark ? SB_PROPERTY_TRUE : SB_PROPERTY_FALSE);
2219 NS_ENSURE_SUCCESS(rv, rv);
2230 mIgnoring(PR_FALSE),
2231 mListenerType(LIBRARY),
2233 NS_ASSERTION(aItem,
"aItem is null");
2234 NS_ADDREF(mMediaItem);
2241 NS_RELEASE(mMediaItem);
2253 if (mIgnoring != aIgnore) {
2256 if ((mListenerType &
LIBRARY) != 0) {
2264 mIgnoring = aIgnore;
2274 #define LOG_MODULE(aLogModule, args) PR_LOG(aLogModule, PR_LOG_WARN, args)
2277 #define __FUNCTION__ __PRETTY_FUNCTION__
2280 static nsresult LogFormatType(PRUint32 aContentType,
2281 const nsAString & aFormat,
2283 PRLogModuleInfo *aLogModule);
2286 const nsAString & aFormat,
2287 PRLogModuleInfo *aLogModule);
2290 const nsAString & aFormat,
2291 PRLogModuleInfo *aLogModule);
2294 const nsAString & aFormat,
2295 PRLogModuleInfo *aLogModule);
2297 static nsresult LogSizeArray(nsIArray *aSizeArray, PRLogModuleInfo *aLogModule);
2301 PRLogModuleInfo *aLogModule);
2306 PRLogModuleInfo *aLogModule)
2308 NS_ENSURE_ARG_POINTER(aDeviceCaps);
2309 NS_ENSURE_ARG_POINTER(aLogModule);
2313 LOG_MODULE(aLogModule,
2314 (
"DEVICE CAPS:\n===============================================\n"));
2316 PRUint32 functionTypeCount;
2317 PRUint32 *functionTypes;
2318 rv = aDeviceCaps->GetSupportedFunctionTypes(&functionTypeCount,
2320 NS_ENSURE_SUCCESS(rv, rv);
2321 sbAutoNSMemoryPtr functionTypesPtr(functionTypes);
2322 for (PRUint32 functionType = 0;
2323 functionType < functionTypeCount;
2326 PRUint32 *contentTypes;
2327 PRUint32 contentTypesLength;
2329 rv = aDeviceCaps->GetSupportedContentTypes(functionTypes[functionType],
2330 &contentTypesLength,
2332 NS_ENSURE_SUCCESS(rv, rv);
2334 sbAutoNSMemoryPtr contentTypesPtr(contentTypes);
2336 for (PRUint32 contentType = 0;
2337 contentType < contentTypesLength;
2340 PRUint32 mimeTypesCount;
2342 rv = aDeviceCaps->GetSupportedMimeTypes(contentTypes[contentType],
2345 NS_ENSURE_SUCCESS(rv, rv);
2348 for (PRUint32 mimeType = 0; mimeType < mimeTypesCount; mimeType++) {
2349 rv = LogFormatType(contentTypes[contentType],
2350 NS_ConvertUTF8toUTF16(mimeTypes[mimeType]),
2358 LOG_MODULE(aLogModule,
2359 (
"\n===============================================\n"));
2365 LogFormatType(PRUint32 aContentType,
2366 const nsAString & aFormat,
2368 PRLogModuleInfo *aLogModule)
2370 NS_ENSURE_ARG_POINTER(aDeviceCaps);
2371 NS_ENSURE_ARG_POINTER(aLogModule);
2375 PRUint32 formatTypeCount;
2376 rv = aDeviceCaps->GetFormatTypes(aContentType,
2380 NS_ENSURE_SUCCESS(rv, rv);
2384 for (PRUint32 formatIndex = 0;
2385 formatIndex < formatTypeCount;
2388 nsCOMPtr<nsISupports> formatSupports = formatTypes[formatIndex];
2391 nsCOMPtr<sbIAudioFormatType> audioFormatType =
2392 do_QueryInterface(formatSupports, &rv);
2393 if (NS_SUCCEEDED(rv) && audioFormatType) {
2394 rv = LogAudioFormatType(audioFormatType, aFormat, aLogModule);
2395 NS_ENSURE_SUCCESS(rv, rv);
2398 nsCOMPtr<sbIVideoFormatType> videoFormatType =
2399 do_QueryInterface(formatSupports, &rv);
2400 if (NS_SUCCEEDED(rv) && videoFormatType) {
2401 rv = LogVideoFormatType(videoFormatType, aFormat, aLogModule);
2402 NS_ENSURE_SUCCESS(rv, rv);
2406 nsCOMPtr<sbIImageFormatType> imageFormatType =
2407 do_QueryInterface(formatSupports, &rv);
2408 if (NS_SUCCEEDED(rv) && imageFormatType) {
2409 rv = LogImageFormatType(imageFormatType, aFormat, aLogModule);
2410 NS_ENSURE_SUCCESS(rv, rv);
2421 const nsAString & aFormat,
2422 PRLogModuleInfo *aLogModule)
2424 NS_ENSURE_ARG_POINTER(aImageFormatType);
2425 NS_ENSURE_ARG_POINTER(aLogModule);
2429 nsString format(aFormat);
2430 LOG_MODULE(aLogModule, (
" *** IMAGE FORMAT TYPE '%s' ***",
2431 NS_ConvertUTF16toUTF8(format).
get()));
2433 nsCString imgFormat;
2434 rv = aImageFormatType->GetImageFormat(imgFormat);
2435 NS_ENSURE_SUCCESS(rv, rv);
2437 nsCOMPtr<sbIDevCapRange> widths;
2438 rv = aImageFormatType->GetSupportedWidths(getter_AddRefs(widths));
2439 NS_ENSURE_SUCCESS(rv, rv);
2441 nsCOMPtr<sbIDevCapRange> heights;
2442 rv = aImageFormatType->GetSupportedHeights(getter_AddRefs(heights));
2443 NS_ENSURE_SUCCESS(rv, rv);
2445 nsCOMPtr<nsIArray> sizes;
2446 rv = aImageFormatType->GetSupportedExplicitSizes(getter_AddRefs(sizes));
2447 NS_ENSURE_SUCCESS(rv, rv);
2449 LOG_MODULE(aLogModule, (
" * image format: %s", imgFormat.get()));
2451 LOG_MODULE(aLogModule, (
" * image widths:\n"));;
2452 rv = LogRange(widths, PR_TRUE, aLogModule);
2453 NS_ENSURE_SUCCESS(rv, rv);
2455 LOG_MODULE(aLogModule, (
" * image heights:\n"));
2456 rv = LogRange(heights, PR_TRUE, aLogModule);
2457 NS_ENSURE_SUCCESS(rv, rv);
2459 LOG_MODULE(aLogModule, (
" * image supported sizes:\n"));
2460 rv = LogSizeArray(sizes, aLogModule);
2461 NS_ENSURE_SUCCESS(rv, rv);
2464 LOG_MODULE(aLogModule, (
"\n"));
2470 const nsAString & aFormat,
2471 PRLogModuleInfo *aLogModule)
2473 NS_ENSURE_ARG_POINTER(aVideoFormatType);
2474 NS_ENSURE_ARG_POINTER(aLogModule);
2478 nsString format(aFormat);
2479 LOG_MODULE(aLogModule, (
" *** VIDEO FORMAT TYPE '%s' ***",
2480 NS_ConvertUTF16toUTF8(format).
get()));
2482 nsCString containerType;
2483 rv = aVideoFormatType->GetContainerType(containerType);
2484 NS_ENSURE_SUCCESS(rv, rv);
2486 nsCOMPtr<sbIDevCapVideoStream> videoStream;
2487 rv = aVideoFormatType->GetVideoStream(getter_AddRefs(videoStream));
2488 NS_ENSURE_SUCCESS(rv, rv);
2490 nsCString videoStreamType;
2491 rv = videoStream->GetType(videoStreamType);
2492 NS_ENSURE_SUCCESS(rv, rv);
2494 nsCOMPtr<nsIArray> videoSizes;
2495 rv = videoStream->GetSupportedExplicitSizes(getter_AddRefs(videoSizes));
2496 NS_ENSURE_SUCCESS(rv, rv);
2498 nsCOMPtr<sbIDevCapRange> videoWidths;
2499 rv = videoStream->GetSupportedWidths(getter_AddRefs(videoWidths));
2500 NS_ENSURE_SUCCESS(rv, rv);
2502 nsCOMPtr<sbIDevCapRange> videoHeights;
2503 rv = videoStream->GetSupportedHeights(getter_AddRefs(videoHeights));
2504 NS_ENSURE_SUCCESS(rv, rv);
2506 nsCOMPtr<sbIDevCapRange> videoBitrates;
2507 rv = videoStream->GetSupportedBitRates(getter_AddRefs(videoBitrates));
2508 NS_ENSURE_SUCCESS(rv, rv);
2513 LOG_MODULE(aLogModule, (
" * videostream type = %s)", videoStreamType.get()));
2515 LOG_MODULE(aLogModule, (
" * videostream supported widths:"));
2516 rv = LogRange(videoWidths, PR_TRUE, aLogModule);
2518 LOG_MODULE(aLogModule, (
" * videosream supported heights:"));
2519 rv = LogRange(videoHeights, PR_TRUE, aLogModule);
2521 LOG_MODULE(aLogModule, (
" * videostream bitrates:"));
2522 rv = LogRange(videoBitrates, PR_TRUE, aLogModule);
2524 PRBool supportsPARRange = PR_FALSE;
2525 rv = videoStream->GetDoesSupportPARRange(&supportsPARRange);
2526 if (NS_SUCCEEDED(rv) && supportsPARRange) {
2528 nsCOMPtr<sbIDevCapFraction> minSupportedPAR;
2529 rv = videoStream->GetMinimumSupportedPAR(getter_AddRefs(minSupportedPAR));
2530 NS_ENSURE_SUCCESS(rv, rv);
2532 nsCOMPtr<sbIDevCapFraction> maxSupportedPAR;
2533 rv = videoStream->GetMaximumSupportedPAR(getter_AddRefs(maxSupportedPAR));
2534 NS_ENSURE_SUCCESS(rv, rv);
2536 rv = minSupportedPAR->GetNumerator(&num);
2537 NS_ENSURE_SUCCESS(rv, rv);
2538 rv = minSupportedPAR->GetDenominator(&den);
2539 NS_ENSURE_SUCCESS(rv, rv);
2540 LOG_MODULE(aLogModule, (
" * videostream min PAR: %i/%i", num, den));
2542 rv = maxSupportedPAR->GetNumerator(&num);
2543 NS_ENSURE_SUCCESS(rv, rv);
2544 rv = maxSupportedPAR->GetDenominator(&den);
2545 NS_ENSURE_SUCCESS(rv, rv);
2546 LOG_MODULE(aLogModule, (
" * videostream max PAR: %i/%i", num, den));
2550 nsCOMPtr<nsIArray> supportedPARs;
2551 rv = videoStream->GetSupportedPARs(getter_AddRefs(supportedPARs));
2552 NS_ENSURE_SUCCESS(rv, rv);
2554 PRUint32 length = 0;
2555 rv = supportedPARs->GetLength(&length);
2556 NS_ENSURE_SUCCESS(rv, rv);
2558 LOG_MODULE(aLogModule, (
" * videostream PAR count: %i", length));
2560 for (PRUint32
i = 0;
i < length;
i++) {
2561 nsCOMPtr<sbIDevCapFraction> curFraction =
2562 do_QueryElementAt(supportedPARs,
i, &rv);
2563 NS_ENSURE_SUCCESS(rv, rv);
2565 rv = curFraction->GetNumerator(&num);
2566 NS_ENSURE_SUCCESS(rv, rv);
2567 rv = curFraction->GetDenominator(&den);
2568 NS_ENSURE_SUCCESS(rv, rv);
2570 LOG_MODULE(aLogModule, (
" - %i/%i", num, den));
2574 PRBool supportsFrameRange = PR_FALSE;
2575 rv = videoStream->GetDoesSupportFrameRateRange(&supportsFrameRange);
2576 if (NS_SUCCEEDED(rv) && supportsFrameRange) {
2577 nsCOMPtr<sbIDevCapFraction> minFrameRate;
2578 rv = videoStream->GetMinimumSupportedFrameRate(
2579 getter_AddRefs(minFrameRate));
2580 NS_ENSURE_SUCCESS(rv, rv);
2582 nsCOMPtr<sbIDevCapFraction> maxFrameRate;
2583 rv = videoStream->GetMaximumSupportedFrameRate(
2584 getter_AddRefs(maxFrameRate));
2585 NS_ENSURE_SUCCESS(rv, rv);
2587 rv = minFrameRate->GetNumerator(&num);
2588 NS_ENSURE_SUCCESS(rv, rv);
2589 rv = minFrameRate->GetDenominator(&den);
2590 NS_ENSURE_SUCCESS(rv, rv);
2591 LOG_MODULE(aLogModule, (
" * videostream min framerate: %i/%i", num, den));
2593 rv = maxFrameRate->GetNumerator(&num);
2594 NS_ENSURE_SUCCESS(rv, rv);
2595 rv = maxFrameRate->GetDenominator(&den);
2596 NS_ENSURE_SUCCESS(rv, rv);
2597 LOG_MODULE(aLogModule, (
" * videostream max framerate: %i/%i", num, den));
2600 nsCOMPtr<nsIArray> frameRates;
2601 rv = videoStream->GetSupportedFrameRates(getter_AddRefs(frameRates));
2602 NS_ENSURE_SUCCESS(rv, rv);
2604 PRUint32 length = 0;
2605 rv = frameRates->GetLength(&length);
2606 NS_ENSURE_SUCCESS(rv, rv);
2608 LOG_MODULE(aLogModule, (
" * videostream framerate count: %i", length));
2610 for (PRUint32
i = 0;
i < length;
i++) {
2611 nsCOMPtr<sbIDevCapFraction> curFraction =
2612 do_QueryElementAt(frameRates,
i, &rv);
2613 NS_ENSURE_SUCCESS(rv, rv);
2615 rv = curFraction->GetNumerator(&num);
2616 NS_ENSURE_SUCCESS(rv, rv);
2617 rv = curFraction->GetDenominator(&den);
2618 NS_ENSURE_SUCCESS(rv, rv);
2620 LOG_MODULE(aLogModule, (
" - %i/%i", num, den));
2624 nsCOMPtr<sbIDevCapAudioStream> audioStream;
2625 rv = aVideoFormatType->GetAudioStream(getter_AddRefs(audioStream));
2626 NS_ENSURE_SUCCESS(rv, rv);
2628 nsCString audioStreamType;
2629 rv = audioStream->GetType(audioStreamType);
2630 NS_ENSURE_SUCCESS(rv, rv);
2632 nsCOMPtr<sbIDevCapRange> audioBitrates;
2633 rv = audioStream->GetSupportedBitRates(getter_AddRefs(audioBitrates));
2634 NS_ENSURE_SUCCESS(rv, rv);
2636 nsCOMPtr<sbIDevCapRange> audioSamplerates;
2637 rv = audioStream->GetSupportedSampleRates(getter_AddRefs(audioSamplerates));
2638 NS_ENSURE_SUCCESS(rv, rv);
2640 nsCOMPtr<sbIDevCapRange> audioChannels;
2641 rv = audioStream->GetSupportedChannels(getter_AddRefs(audioChannels));
2642 NS_ENSURE_SUCCESS(rv, rv);
2644 LOG_MODULE(aLogModule, (
" * audiostream type = %s", audioStreamType.get()));
2646 LOG_MODULE(aLogModule, (
" * audiostream bitrates:"));
2647 rv = LogRange(audioBitrates, PR_TRUE, aLogModule);
2649 LOG_MODULE(aLogModule, (
" * audiostream samplerates:"));
2650 rv = LogRange(audioSamplerates, PR_FALSE, aLogModule);
2652 LOG_MODULE(aLogModule, (
" * audiostream channels"));
2653 rv = LogRange(audioChannels, PR_TRUE, aLogModule);
2656 LOG_MODULE(aLogModule, (
"\n"));
2662 const nsAString & aFormat,
2663 PRLogModuleInfo *aLogModule)
2665 NS_ENSURE_ARG_POINTER(aAudioFormatType);
2666 NS_ENSURE_ARG_POINTER(aLogModule);
2670 nsString format(aFormat);
2671 LOG_MODULE(aLogModule, (
" *** AUDIO FORMAT TYPE '%s' ***",
2672 NS_ConvertUTF16toUTF8(format).
get()));
2674 nsCString audioCodec;
2675 rv = aAudioFormatType->GetAudioCodec(audioCodec);
2676 NS_ENSURE_SUCCESS(rv, rv);
2678 nsCString containerFormat;
2679 rv = aAudioFormatType->GetContainerFormat(containerFormat);
2680 NS_ENSURE_SUCCESS(rv, rv);
2682 nsCOMPtr<sbIDevCapRange> bitrates;
2683 rv = aAudioFormatType->GetSupportedBitrates(getter_AddRefs(bitrates));
2684 NS_ENSURE_SUCCESS(rv, rv);
2686 nsCOMPtr<sbIDevCapRange> samplerates;
2687 rv = aAudioFormatType->GetSupportedSampleRates(getter_AddRefs(samplerates));
2688 NS_ENSURE_SUCCESS(rv, rv);
2690 nsCOMPtr<sbIDevCapRange> channels;
2691 rv = aAudioFormatType->GetSupportedChannels(getter_AddRefs(channels));
2692 NS_ENSURE_SUCCESS(rv, rv);
2695 LOG_MODULE(aLogModule, (
" * audioCodec = %s", audioCodec.get()));
2696 LOG_MODULE(aLogModule, (
" * containerFormat = %s", containerFormat.get()));
2698 LOG_MODULE(aLogModule, (
" * audio bitrates:"));
2699 rv = LogRange(bitrates, PR_TRUE, aLogModule);
2700 NS_ENSURE_SUCCESS(rv, rv);
2702 LOG_MODULE(aLogModule, (
" * audio samplerates:"));
2703 rv = LogRange(samplerates, PR_FALSE, aLogModule);
2704 NS_ENSURE_SUCCESS(rv, rv);
2706 LOG_MODULE(aLogModule, (
" * audio channels:"));
2707 rv = LogRange(channels, PR_TRUE, aLogModule);
2708 NS_ENSURE_SUCCESS(rv, rv);
2711 LOG_MODULE(aLogModule, (
"\n"));
2716 LogSizeArray(nsIArray *aSizeArray, PRLogModuleInfo *aLogModule)
2718 NS_ENSURE_ARG_POINTER(aSizeArray);
2719 NS_ENSURE_ARG_POINTER(aLogModule);
2722 PRUint32 arrayCount = 0;
2723 rv = aSizeArray->GetLength(&arrayCount);
2724 NS_ENSURE_SUCCESS(rv, rv);
2726 for (PRUint32
i = 0;
i < arrayCount;
i++) {
2727 nsCOMPtr<sbIImageSize> curImageSize =
2728 do_QueryElementAt(aSizeArray,
i, &rv);
2729 NS_ENSURE_SUCCESS(rv, rv);
2732 rv = curImageSize->GetWidth(&width);
2733 NS_ENSURE_SUCCESS(rv, rv);
2735 rv = curImageSize->GetHeight(&height);
2736 NS_ENSURE_SUCCESS(rv, rv);
2738 LOG_MODULE(aLogModule, (
" - %i x %i", width, height));
2747 PRLogModuleInfo *aLogModule)
2749 NS_ENSURE_ARG_POINTER(aRange);
2750 NS_ENSURE_ARG_POINTER(aLogModule);
2754 PRInt32
min, max, step;
2755 rv = aRange->GetMin(&min);
2756 NS_ENSURE_SUCCESS(rv, rv);
2757 rv = aRange->GetMax(&max);
2758 NS_ENSURE_SUCCESS(rv, rv);
2759 rv = aRange->GetStep(&step);
2760 NS_ENSURE_SUCCESS(rv, rv);
2762 LOG_MODULE(aLogModule, (
" - min: %i", min));
2763 LOG_MODULE(aLogModule, (
" - max: %i", max));
2764 LOG_MODULE(aLogModule, (
" - step: %i", step));
2767 PRUint32 valueCount = 0;
2768 rv = aRange->GetValueCount(&valueCount);
2769 NS_ENSURE_SUCCESS(rv, rv);
2771 for (PRUint32
i = 0;
i < valueCount;
i++) {
2772 PRInt32 curValue = 0;
2774 NS_ENSURE_SUCCESS(rv, rv);
2776 LOG_MODULE(aLogModule, (
" - %i", curValue));
2788 const char *
const LOG_DEVICE_INFO_PREF =
"log_device_info";
2792 NS_ENSURE_SUCCESS(rv, rv);
2794 return prefBranch.
GetBoolPref(LOG_DEVICE_INFO_PREF, PR_FALSE) != PR_FALSE;
2802 return NS_LITERAL_CSTRING(
"Device Unknown");
2806 nsString deviceIdentifier;
2807 rv = aDevice->GetName(deviceIdentifier);
2808 if (NS_FAILED(rv)) {
2809 deviceIdentifier.Truncate();
2812 result = NS_LossyConvertUTF16toASCII(deviceIdentifier);
2814 rv = aDevice->GetId(&deviceID);
2816 NS_ENSURE_SUCCESS(rv, result);
2818 char volumeGUID[NSID_LENGTH];
2819 deviceID->ToProvidedString(volumeGUID);
2821 if (!result.IsEmpty()) {
2822 result.Append(NS_LITERAL_CSTRING(
"-"));
2824 result.Append(volumeGUID);
PRUint32 const MAP_FILE_EXTENSION_CONTENT_FORMAT_LENGTH
const unsigned long TRANSCODE_TYPE_IMAGE
static nsresult GetTranscodeProfiles(PRUint32 aType, nsIArray **aProfiles)
static nsresult GetOriginMediaItemByDevicePersistentId(sbILibrary *aLibrary, const nsAString &aDevicePersistentId, sbIMediaItem **aItem)
static nsresult GetTranscodedFileExtension(sbITranscodeProfile *aProfile, nsCString &aExtension)
const PRUint32 FUNCTION_AUDIO_PLAYBACK
A callback interface that is called with a window.
const PRUint32 FUNCTION_VIDEO_PLAYBACK
static nsresult GetContentLength(sbIMediaItem *aItem, PRInt64 *_retval=nsnull)
#define SB_PROPERTY_SAMPLERATE
static nsresult GetItemInLibrary(sbIMediaItem *aItem, sbILibrary *aLibrary, sbIMediaItem **_retval)
[UNIMPLEMENTED UNTIL AFTER 0.3]
static nsresult ShowDeviceErrors(sbIDevice *aDevice)
NS_DECL_ISUPPORTS NS_DECL_SBICALLWITHWINDOWCALLBACK nsresult Query(sbIDevice *aDevice, sbIDeviceLibrary *aLibrary, PRInt64 aSpaceNeeded, PRInt64 aSpaceAvailable, PRBool *aAbort)
const PRUint32 CONTENT_IMAGE
#define SB_PROPERTY_CHANNELS
static nsresult BulkSetProperty(sbIMediaList *aMediaList, const nsAString &aPropertyId, const nsAString &aPropertyValue, sbIPropertyArray *aPropertyFilter=nsnull, PRInt32 *aAbortFlag=nsnull)
static nsresult SetLinkedSyncPartner(sbIDevice *aDevice)
virtual ~sbDeviceUtilsBulkSetPropertyEnumerationListener()
NS_DECL_ISUPPORTS NS_IMETHODIMP OnEnumerationBegin(sbIMediaList *aMediaList, PRUint16 *_retval)
static nsresult QueryUserAbortRip(PRBool *aAbort)
#define SB_PROPERTY_ISDRMPROTECTED
sbDeviceUtilsBulkSetPropertyEnumerationListener(const nsAString &aId, const nsAString &aValue, PRInt32 *aAbortFlag=nsnull)
static nsresult QueryUserViewErrors(sbIDevice *aDevice)
const PRUint32 CONTENT_UNKNOWN
static nsresult SetOriginIsInMainLibrary(sbIMediaItem *aMediaItem, sbILibrary *aDevLibrary, PRBool aMark)
#define SB_THREADSAFE_ARRAY_CONTRACTID
static nsresult GetDeviceLibraryForItem(sbIDevice *aDevice, sbIMediaItem *aItem, sbIDeviceLibrary **_retval)
static nsresult NewDeviceLibraryURI(sbIDeviceLibrary *aDeviceLibrary, const nsCString &aSpec, nsIURI **aURI)
static bool IsItemDRMProtected(sbIMediaItem *aMediaItem)
static nsresult GetDeviceCapsTypeFromListContentType(PRUint16 aListContentType, PRUint32 *aContentType, PRUint32 *aFunctionType)
#define SB_PROPERTY_DEVICE_PERSISTENT_ID
void nsString_ReplaceChar(nsAString &aString, const nsAString &aOldChars, const PRUnichar aNewChar)
const unsigned long TRANSCODE_TYPE_AUDIO
const unsigned long TRANSCODE_TYPE_UNKNOWN
An object defining a transcoding profile.
static nsresult GetOriginItem(sbIMediaItem *aItem, sbIMediaItem **_retval)
sbDeviceListenerIgnore(sbBaseDevice *aDevice, PRUint32 aListenerType=ALL)
Songbird Variant Utility Definitions.
#define SONGBIRD_PROMPTER_CONTRACTID
static nsresult QueryUserSpaceExceeded(sbIDevice *aDevice, sbIDeviceLibrary *aLibrary, PRInt64 aSpaceNeeded, PRInt64 aSpaceAvailable, PRBool *aAbort)
static nsresult GetOrganizedPath(nsIFile *aParent, sbIMediaItem *aItem, nsIFile **_retval)
static nsresult ApplyPropertyPreferencesToProfile(sbIDevice *aDevice, nsIArray *aPropertyArray, nsString aPrefNameBase)
const PRUint32 CONTENT_PLAYLIST
#define SB_PROPERTY_BITRATE
const unsigned long MEDIATYPE_IMAGE
static nsresult GetSupportedTranscodeProfiles(PRUint32 aType, sbIDevice *aDevice, nsIArray **aProfiles)
#define DEVICE_PREF_BRANCH
static PRUint32 TranscodeToCapsContentTypeMap[]
const unsigned long TRANSCODE_TYPE_AUDIO_VIDEO
SB_AUTO_CLASS(sbAutoNSMemoryPtr, void *,!!mValue, NS_Free(mValue), mValue=nsnull)
static nsresult GetDeviceCapsTypeFromMediaItem(sbIMediaItem *aMediaItem, PRUint32 *aContentType, PRUint32 *aFunctionType)
const PRUint32 CONTENT_VIDEO
#define SB_PROPERTY_STORAGEGUID
static PRBool IsMediaItemSupported(sbIDevice *aDevice, sbIMediaItem *aMediaItem)
static nsresult GetFormatTypesForMimeType(const nsAString &aMimeType, const PRUint32 aContentType, nsTArray< sbExtensionToContentFormatEntry_t > &aFormatTypeList)
For a MIME type, get format information describing it (extension, mime type, etc. ...
static nsresult GetFormatTypeForURL(const nsAString &aURL, sbExtensionToContentFormatEntry_t &aFormatType)
For a URL, get format information describing it (extension, mime type, etc.
NS_IMETHODIMP OnEnumeratedItem(sbIMediaList *aMediaList, sbIMediaItem *aItem, PRUint16 *_retval)
static nsresult GetCodecAndContainerForMimeType(nsCString aMimeType, nsCString &aContainer, nsCString &aCodec, nsCString &aVideoType, nsCString &aAudioType)
NS_IMETHODIMP OnEnumerationEnd(sbIMediaList *aMediaList, nsresult aStatusCode)
#define SB_PROPERTY_OUTERGUID
const sbCreateProxiedComponent do_ProxiedGetService(const nsCID &aCID, nsresult *error=0)
static nsresult GetDeviceWriteLength(sbIDeviceLibrary *aDeviceLibrary, sbIMediaItem *aMediaItem, PRUint64 *aWriteLength)
nsresult UnignoreMediaItem(sbIMediaItem *aItem)
static bool ArePlaylistsSupported(sbIDevice *aDevice)
BogusChannel prototype contentLength
void SetIgnore(PRBool aIgnore)
static nsresult GetFormatTypeForURI(nsIURI *aURI, sbExtensionToContentFormatEntry_t &aFormatType)
For a URI, get format information describing it (extension, mime type, etc.
this _dialogInput val(dateText)
static nsresult GetFormatTypeForItem(sbIMediaItem *aItem, sbExtensionToContentFormatEntry_t &aFormatType, PRUint32 &aBitRate, PRUint32 &aSampleRate)
For a media item, get format information describing it (extension, mime type, etc.
static bool ShouldLogDeviceInfo()
#define SB_PROPERTY_ORIGIN_IS_IN_MAIN_LIBRARY
static nsresult GetSyncItemInLibrary(sbIMediaItem *aMediaItem, sbILibrary *aTargetLibrary, sbIMediaItem **aSyncItem)
Media library abstraction.
#define SB_PROPERTY_ARTISTNAME
static nsCString GetDeviceIdentifier(sbIDevice *aDevice)
nsresult SetIgnoreMediaListListeners(PRBool aIgnoreListener)
static nsresult GetMediaItemByDevicePersistentId(sbILibrary *aLibrary, const nsAString &aDevicePersistentId, sbIMediaItem **aItem)
const PRUint32 FUNCTION_UNKNOWN
return!aWindow arguments!aWindow arguments[0]
const PRUint32 FUNCTION_IMAGE_DISPLAY
sbExtensionToContentFormatEntry_t const MAP_FILE_EXTENSION_CONTENT_FORMAT[]
nsresult IgnoreMediaItem(sbIMediaItem *aItem)
static nsresult DeleteByProperty(sbIMediaList *aMediaList, nsAString const &aProperty, nsAString const &aValue)
nsresult SetIgnoreLibraryListener(PRBool aIgnoreListener)
static PRBool IsMediaListContentTypeSupported(sbIDevice *aDevice, PRUint16 aListContentType)
static nsresult DoesItemNeedTranscoding(sbExtensionToContentFormatEntry_t &aFormatType, PRUint32 &aBitRate, PRUint32 &aSampleRate, sbIDevice *aDevice, bool &aNeedsTranscoding)
Determine if an item needs transcoding.
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceUtilsBulkSetPropertyEnumerationListener, sbIMediaListEnumerationListener)
#define SB_PROPERTY_ALBUMNAME
const PRUint32 CONTENT_AUDIO
boolean IsValueInRange(in long aValue)
~sbDeviceListenerIgnore()
static nsresult GetDeviceLibraryForLibrary(sbIDevice *aDevice, sbILibrary *aLibrary, sbIDeviceLibrary **_retval)
long GetValue(in unsigned long aIndex)
static nsresult GetAudioMimeTypeForFormatTypes(const nsAString &aContainer, const nsAString &aCodec, nsAString &aMimeType)
static nsresult GetMediaSettings(sbIDeviceLibrary *aDevLib, PRUint32 aMediaType, sbIDeviceLibraryMediaSyncSettings **aMediaSettings)
static nsresult GetMgmtTypeForMedia(sbIDeviceLibrary *aDevLib, PRUint32 aMediaType, PRUint32 &aMgmtType)
#define SB_PROPERTY_AVAILABILITY
static nsresult DeleteUnavailableItems(sbIMediaList *aMediaList)
#define SB_PROPERTY_CONTENTURL
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
#define SONGBIRD_DEVICECAPSCOMPATIBILITY_CONTRACTID
static bool IsValueInRange(PRInt32 aValue, sbIDevCapRange *aRange)
_getSelectedPageStyle s i
static nsresult GetTranscodingConfigurator(PRUint32 aTranscodeType, sbIDeviceTranscodingConfigurator **aConfigurator)
static nsresult GetContainerFormatAndCodec(nsISupports *aFormatType, PRUint32 aContentType, nsAString &aContainerFormat, nsAString &aVideoType, nsAString &aAudioType, nsAString &aCodec, sbIDevCapRange **aBitRateRange=nsnull, sbIDevCapRange **aSampleRateRange=nsnull)
nsresult GetMainLibraryId(nsAString &aLibraryId)
static nsresult GetDeviceLibrary(nsAString const &aDeviceLibGuid, sbIDevice *aDevice, sbIDeviceLibrary **aDeviceLibrar)
static nsresult AddSupportedFileExtensions(sbIDevice *aDevice, PRUint32 aContentType, nsTArray< nsString > &aFileExtensionList)
static PRInt32 ParseInteger(nsAString const &aValue)
char const * ContainerFormat
function Extension(aItem)
PRBool GetBoolPref(const char *aKey, PRBool aDefault)