47 #include <sbIDeviceCapabilities.h>
85 NS_ENSURE_ARG_POINTER(_retval);
103 sbDeviceStatistics::OnEnumeratedItem(
sbIMediaList* aMediaList,
108 NS_ENSURE_ARG_POINTER(aMediaList);
109 NS_ENSURE_ARG_POINTER(aMediaItem);
110 NS_ENSURE_ARG_POINTER(_retval);
129 sbDeviceStatistics::OnEnumerationEnd(
sbIMediaList* aMediaList,
130 nsresult aStatusCode)
156 NS_ENSURE_ARG_POINTER(aDevice);
157 NS_ENSURE_ARG_POINTER(aDeviceStatistics);
163 nsRefPtr<sbDeviceStatistics>
165 NS_ENSURE_TRUE(deviceStatistics, NS_ERROR_OUT_OF_MEMORY);
166 rv = deviceStatistics->Initialize(aDevice);
167 NS_ENSURE_SUCCESS(rv, rv);
170 deviceStatistics.forget(aDeviceStatistics);
186 NS_ENSURE_ARG_POINTER(aLibrary);
192 rv = ClearLibraryStatistics(aLibrary);
193 NS_ENSURE_SUCCESS(rv, rv);
196 rv = aLibrary->EnumerateAllItems(
this,
198 NS_ENSURE_SUCCESS(rv, rv);
214 NS_ENSURE_ARG_POINTER(aLibrary);
220 rv = ClearLibraryStatistics(aLibrary);
221 NS_ENSURE_SUCCESS(rv, rv);
237 NS_ENSURE_ARG_POINTER(aMediaItem);
243 rv = UpdateForItem(aMediaItem, PR_TRUE);
244 NS_ENSURE_SUCCESS(rv, rv);
260 NS_ENSURE_ARG_POINTER(aMediaItem);
266 rv = UpdateForItem(aMediaItem, PR_FALSE);
267 NS_ENSURE_SUCCESS(rv, rv);
284 NS_ENSURE_ARG_POINTER(aLibrary);
290 rv = ClearLibraryStatistics(aLibrary);
291 NS_ENSURE_SUCCESS(rv, rv);
309 nsAutoLock autoStatLock(mStatLock);
315 nsAutoLock autoStatLock(mStatLock);
316 mAudioCount = aAudioCount;
321 nsAutoLock autoStatLock(mStatLock);
323 PR_MAX(static_cast<PRInt32>(mAudioCount) + aAddAudioCount, 0);
324 mAudioCount = audioCount;
334 nsAutoLock autoStatLock(mStatLock);
340 nsAutoLock autoStatLock(mStatLock);
341 mAudioUsed = aAudioUsed;
346 nsAutoLock autoStatLock(mStatLock);
348 PR_MAX(static_cast<PRInt64>(mAudioUsed) + aAddAudioUsed, 0);
349 mAudioUsed = audioUsed;
359 nsAutoLock autoStatLock(mStatLock);
360 return mAudioPlayTime;
365 nsAutoLock autoStatLock(mStatLock);
366 mAudioPlayTime = aAudioPlayTime;
371 nsAutoLock autoStatLock(mStatLock);
372 PRInt64 audioPlayTime =
373 PR_MAX(static_cast<PRInt64>(mAudioPlayTime) + aAddAudioPlayTime, 0);
374 mAudioPlayTime = audioPlayTime;
384 nsAutoLock autoStatLock(mStatLock);
390 nsAutoLock autoStatLock(mStatLock);
391 mVideoCount = aVideoCount;
396 nsAutoLock autoStatLock(mStatLock);
398 PR_MAX(static_cast<PRInt32>(mVideoCount) + aAddVideoCount, 0);
399 mVideoCount = videoCount;
409 nsAutoLock autoStatLock(mStatLock);
415 nsAutoLock autoStatLock(mStatLock);
416 mVideoUsed = aVideoUsed;
421 nsAutoLock autoStatLock(mStatLock);
423 PR_MAX(static_cast<PRInt64>(mVideoUsed) + aAddVideoUsed, 0);
424 mVideoUsed = videoUsed;
434 nsAutoLock autoStatLock(mStatLock);
435 return mVideoPlayTime;
440 nsAutoLock autoStatLock(mStatLock);
441 mVideoPlayTime = aVideoPlayTime;
446 nsAutoLock autoStatLock(mStatLock);
447 PRInt64 videoPlayTime =
448 PR_MAX(static_cast<PRInt64>(mVideoPlayTime) + aAddVideoPlayTime, 0);
449 mVideoPlayTime = videoPlayTime;
459 nsAutoLock autoStatLock(mStatLock);
465 nsAutoLock autoStatLock(mStatLock);
466 mImageCount = aImageCount;
471 nsAutoLock autoStatLock(mStatLock);
473 PR_MAX(static_cast<PRInt32>(mImageCount) + aAddImageCount, 0);
484 nsAutoLock autoStatLock(mStatLock);
490 nsAutoLock autoStatLock(mStatLock);
491 mImageUsed = aImageUsed;
496 nsAutoLock autoStatLock(mStatLock);
498 PR_MAX(static_cast<PRInt64>(mImageUsed) + aAddImageUsed, 0);
513 sbDeviceStatistics::sbDeviceStatistics() :
532 sbDeviceStatistics::~sbDeviceStatistics()
536 nsAutoLock::DestroyLock(mStatLock);
549 sbDeviceStatistics::Initialize(
class sbBaseDevice* aDevice)
552 NS_ENSURE_ARG_POINTER(aDevice);
555 mBaseDevice = aDevice;
558 mStatLock = nsAutoLock::NewLock(__FILE__
"::mStatLock");
559 NS_ENSURE_TRUE(mStatLock, NS_ERROR_OUT_OF_MEMORY);
575 NS_ENSURE_ARG_POINTER(aLibrary);
602 sbDeviceStatistics::UpdateForItem(
sbIMediaItem* aMediaItem,
606 NS_ENSURE_ARG_POINTER(aMediaItem);
612 nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(aMediaItem, &rv);
613 if (NS_SUCCEEDED(rv))
617 PRUint32 contentType;
624 PRInt32 itemCountUpdate;
628 itemCountUpdate = -1;
631 PRInt64 itemUsedUpdate;
632 rv = aMediaItem->GetContentLength(&itemUsedUpdate);
633 NS_ENSURE_SUCCESS(rv, rv);
635 itemUsedUpdate = -itemUsedUpdate;
638 PRInt64 itemPlayTimeUpdate = 0;
642 if (NS_SUCCEEDED(rv)) {
643 if (PR_sscanf(NS_ConvertUTF16toUTF8(duration).
get(),
645 &itemPlayTimeUpdate) == 0) {
646 itemPlayTimeUpdate = 0;
650 itemPlayTimeUpdate = -itemPlayTimeUpdate;
nsresult RemoveLibrary(sbIDeviceLibrary *aLibrary)
nsresult RemoveAllItems(sbIDeviceLibrary *aLibrary)
void SetVideoCount(PRUint32 aVideoCount)
void AddImageUsed(PRInt64 aAddImageUsed)
void AddVideoCount(PRInt32 aAddVideoCount)
NS_DECL_ISUPPORTS static NS_DECL_SBIMEDIALISTENUMERATIONLISTENER nsresult New(class sbBaseDevice *aDevice, sbDeviceStatistics **aDeviceStatistics)
const PRUint32 CONTENT_UNKNOWN
void AddAudioUsed(PRInt64 aAddAudioUsed)
nsresult AddLibrary(sbIDeviceLibrary *aLibrary)
void AddImageCount(PRInt32 aAddImageCount)
void SetVideoPlayTime(PRUint64 aVideoPlayTime)
void AddAudioPlayTime(PRInt64 aAddAudioPlayTime)
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceStatistics, sbIMediaListEnumerationListener) NS_IMETHODIMP sbDeviceStatistics
Called when enumeration is about to begin.
void SetAudioCount(PRUint32 aAudioCount)
const PRUint32 CONTENT_VIDEO
void AddAudioCount(PRInt32 aAddAudioCount)
virtual nsresult GetItemContentType(sbIMediaItem *aMediaItem, PRUint32 *aContentType)
#define SB_PROPERTY_DURATION
nsresult AddItem(sbIMediaItem *aMediaItem)
void AddVideoUsed(PRInt64 aAddVideoUsed)
nsresult RemoveItem(sbIMediaItem *aMediaItem)
void SetImageUsed(PRUint64 aImageUsed)
void SetVideoUsed(PRUint64 aVideoUsed)
Songbird Device Statistics Definitions.
void AddVideoPlayTime(PRInt64 aAddVideoPlayTime)
const PRUint32 CONTENT_AUDIO
void SetImageCount(PRUint32 aImageCount)
void SetAudioUsed(PRUint64 aAudioUsed)
void SetAudioPlayTime(PRUint64 aAudioPlayTime)