Manages reading and writing metadata to and from sbIMediaItem objects and media files. More...
#include <sbFileMetadataService.h>
Public Member Functions | |
NS_DECL_ISUPPORTS NS_DECL_SBIFILEMETADATASERVICE NS_DECL_SBPIFILEMETADATASERVICE NS_DECL_NSIOBSERVER | sbFileMetadataService () |
virtual | ~sbFileMetadataService () |
nsresult | Init () |
nsresult | GetQueuedJobItem (PRBool aMainThreadOnly, sbMetadataJobItem **aJobItem) |
nsresult | PutProcessedJobItem (sbMetadataJobItem *aJobItem) |
nsresult | GetJobItemIsBlocked (sbMetadataJobItem *aJobItem, PRBool *aJobItemIsBlocked) |
Public Member Functions inherited from sbIFileMetadataService | |
sbIJobProgress | read (in nsIArray aMediaItemArray) |
Start a processing job to read metadata from the files associated with the given media items. More... | |
sbIJobProgress | write (in nsIArray aMediaItemArray, in nsIStringEnumerator aRequiredProperties) |
Start a processing job to write metadata from the given media items back to their associated files. More... | |
void | restartProcessors (in unsigned short aProcessorsToRestart) |
Restart the processors. More... | |
Public Member Functions inherited from sbPIFileMetadataService | |
void | AddBlacklistURL (in ACString aURL) |
Protected Member Functions | |
nsresult | ProxiedRestartProcessors (PRUint16 aProcessorsToRestart) |
Proxied version of RestartProcessors present on the sbIFileMetadataService interface. More... | |
nsresult | ProxiedStartJob (nsIArray *aMediaItemsArray, nsIStringEnumerator *aRequiredProperties, sbMetadataJob::JobType aJobType, sbIJobProgress **_retval) |
nsresult | StartJob (nsIArray *aMediaItemsArray, nsIStringEnumerator *aRequiredProperties, sbMetadataJob::JobType aJobType, sbIJobProgress **_retval) |
nsresult | Shutdown () |
nsresult | EnsureWritePermitted () |
nsresult | UpdateDataRemotes (PRInt64 aJobCount) |
Protected Attributes | |
nsCOMPtr< sbIDataRemote > | mDataCurrentMetadataJobs |
nsRefPtr < sbMainThreadMetadataProcessor > | mMainThreadProcessor |
nsRefPtr < sbBackgroundThreadMetadataProcessor > | mBackgroundThreadProcessor |
PRBool | mInitialized |
PRBool | mRunning |
nsCOMPtr< nsITimer > | mNotificationTimer |
PRLock * | mJobLock |
nsTArray< nsRefPtr < sbMetadataJob > > | mJobArray |
PRUint32 | mNextJobIndex |
nsRefPtr< sbMetadataCrashTracker > | mCrashTracker |
nsCOMPtr< sbIMediacoreManager > | mMediacoreManager |
Additional Inherited Members | |
Public Attributes inherited from sbIFileMetadataService | |
const unsigned short | MAIN_THREAD_PROCESSOR = 1 |
Main Thread Processor Flag for restartProcessors. More... | |
const unsigned short | BACKGROUND_THREAD_PROCESSOR = 2 |
Background Thread Processor Flag for restartProcessors. More... | |
Manages reading and writing metadata to and from sbIMediaItem objects and media files.
Supports the creation of threaded read/write jobs for local media (URIs beginning with file://), and timer driven read jobs for remote media.
Simplified Architecture:
[ Processor ] [ Service ] | |-Create-----—>[ Job ]-Create—>[ Handler ]
<---------—Start– | ||
---|---|---|
–GetQueuedItem-—> | -GetQueuedItem-—> | |
|–Read/Write--------------------------------------------—>| | | | |–PutProcessedItem->|-PutProcessedItem->|
The complexity results from the fact that much of the work can only be done on the main thread (due to limitations of sbIMetadataHandlers and Mozilla APIs).
In theory we could do everything on the main thread, but since some handlers do blocking IO this is very undesirable. Instead we run some safe sbIMetadataHandlers on a background thread, and use timers to do all other work on the main thread.
Additional Notes:
All interactions other than GetQueuedJobItem and PutProcessedJobItem must be performed on the main thread.
Definition at line 127 of file sbFileMetadataService.h.
NS_DECL_ISUPPORTS NS_DECL_SBIFILEMETADATASERVICE NS_DECL_SBPIFILEMETADATASERVICE NS_DECL_NSIOBSERVER sbFileMetadataService::sbFileMetadataService | ( | ) |
|
virtual |
Definition at line 97 of file sbFileMetadataService.cpp.
|
protected |
Return NS_OK if write jobs are permitted, or NS_ERROR_NOT_AVAILABLE if not.
May prompt the user to permit write jobs.
Definition at line 690 of file sbFileMetadataService.cpp.
nsresult sbFileMetadataService::GetJobItemIsBlocked | ( | sbMetadataJobItem * | aJobItem, |
PRBool * | aJobItemIsBlocked | ||
) |
If completion of the job item specified by aJobItem is blocked (e.g., writing to a playing file), return true in aJobItemIsBlocked; otherwise, return false.
aJobItem | Job item to check. |
aJobItemIsBlocked | If true, job item is blocked. |
Definition at line 524 of file sbFileMetadataService.cpp.
nsresult sbFileMetadataService::GetQueuedJobItem | ( | PRBool | aMainThreadOnly, |
sbMetadataJobItem ** | aJobItem | ||
) |
Take a waiting job item for processing from the next active job.
Rotates through available jobs so that they are processed in parallel.
May be called off of the main thread.
aMainThreadOnly | If true, will return a job item that needs to be run on the main thread due to implementation details. |
aJobItem | The job item to be processed |
Definition at line 421 of file sbFileMetadataService.cpp.
nsresult sbFileMetadataService::Init | ( | ) |
Called automatically on first GetService()
Definition at line 107 of file sbFileMetadataService.cpp.
|
protected |
Proxied version of RestartProcessors present on the sbIFileMetadataService interface.
Definition at line 238 of file sbFileMetadataService.cpp.
|
protected |
Calls StartJob on the main thread, proxying if necessary.
aMediaItemsArray | Array of sbIMediaItems |
aRequiredProperties | String Enumerator of the properties to be written, null for read. |
aJobType | Operation to perform (TYPE_READ or TYPE_WRITE) |
Definition at line 283 of file sbFileMetadataService.cpp.
nsresult sbFileMetadataService::PutProcessedJobItem | ( | sbMetadataJobItem * | aJobItem | ) |
Give back a job item after processing has been attempted.
May be called off of the main thread.
aJobItem | The job item that has been processed |
Definition at line 498 of file sbFileMetadataService.cpp.
|
protected |
Called automatically on library manager shutdown
Definition at line 145 of file sbFileMetadataService.cpp.
|
protected |
Create and begin a new job to process the given media items
Notes:
aMediaItemsArray | Array of sbIMediaItems |
aRequiredProperties | String Enumerator of the properties to be written, null for read. |
aJobType | Operation to perform (TYPE_READ or TYPE_WRITE) |
Definition at line 320 of file sbFileMetadataService.cpp.
|
protected |
Update the legacy dataremote flags based on the job count. Note that job count is passed as a param because UpdateDataRemotes is to be called while mJobArray is locked.
Definition at line 755 of file sbFileMetadataService.cpp.
|
protected |
Definition at line 249 of file sbFileMetadataService.h.
|
protected |
Definition at line 269 of file sbFileMetadataService.h.
|
protected |
Definition at line 244 of file sbFileMetadataService.h.
|
protected |
Definition at line 251 of file sbFileMetadataService.h.
|
protected |
Definition at line 261 of file sbFileMetadataService.h.
|
protected |
Definition at line 258 of file sbFileMetadataService.h.
|
protected |
Definition at line 247 of file sbFileMetadataService.h.
|
protected |
Definition at line 272 of file sbFileMetadataService.h.
|
protected |
Definition at line 265 of file sbFileMetadataService.h.
|
protected |
Definition at line 255 of file sbFileMetadataService.h.
|
protected |
Definition at line 252 of file sbFileMetadataService.h.