sbDeviceStatistics.h
Go to the documentation of this file.
1 /* vim: set sw=2 :miv */
2 /*
3 //
4 // BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2009 POTI, Inc.
9 // http://songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the "GPL").
13 //
14 // Software distributed under the License is distributed
15 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 // END SONGBIRD GPL
25 //
26 */
27 
28 #ifndef SBDEVICESTATISTICS_H_
29 #define SBDEVICESTATISTICS_H_
30 
36 //------------------------------------------------------------------------------
37 //
38 // Device statistics imported services.
39 //
40 //------------------------------------------------------------------------------
41 
42 // Songbird imports.
43 #include <sbIDeviceLibrary.h>
44 #include <sbIMediaListListener.h>
45 
46 // Mozilla imports.
47 #include <nsAutoLock.h>
48 #include <nsCOMPtr.h>
49 
50 
51 //------------------------------------------------------------------------------
52 //
53 // Device statistics services classes.
54 //
55 //------------------------------------------------------------------------------
56 
62 {
63  //----------------------------------------------------------------------------
64  //
65  // Public interface.
66  //
67  //----------------------------------------------------------------------------
68 
69 public:
70 
71  //
72  // Implemented interfaces.
73  //
74 
76  NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
77 
78 
79  //
80  // Public device statistics services.
81  //
82 
83  static nsresult New(class sbBaseDevice* aDevice,
84  sbDeviceStatistics** aDeviceStatistics);
85 
86  nsresult AddLibrary(sbIDeviceLibrary* aLibrary);
87 
88  nsresult RemoveLibrary(sbIDeviceLibrary* aLibrary);
89 
90  nsresult AddItem(sbIMediaItem* aMediaItem);
91 
92  nsresult RemoveItem(sbIMediaItem* aMediaItem);
93 
94  nsresult RemoveAllItems(sbIDeviceLibrary* aLibrary);
95 
96 
97  //
98  // Setter/getter services.
99  //
100 
101  // Audio count.
102  PRUint32 AudioCount();
103 
104  void SetAudioCount(PRUint32 aAudioCount);
105 
106  void AddAudioCount(PRInt32 aAddAudioCount);
107 
108  // Audio used.
109  PRUint64 AudioUsed();
110 
111  void SetAudioUsed(PRUint64 aAudioUsed);
112 
113  void AddAudioUsed(PRInt64 aAddAudioUsed);
114 
115  // Audio play time.
116  PRUint64 AudioPlayTime();
117 
118  void SetAudioPlayTime(PRUint64 aAudioPlayTime);
119 
120  void AddAudioPlayTime(PRInt64 aAddAudioPlayTime);
121 
122  // Video count.
123  PRUint32 VideoCount();
124 
125  void SetVideoCount(PRUint32 aVideoCount);
126 
127  void AddVideoCount(PRInt32 aAddVideoCount);
128 
129  // Video used.
130  PRUint64 VideoUsed();
131 
132  void SetVideoUsed(PRUint64 aVideoUsed);
133 
134  void AddVideoUsed(PRInt64 aAddVideoUsed);
135 
136  // Video play time.
137  PRUint64 VideoPlayTime();
138 
139  void SetVideoPlayTime(PRUint64 aVideoPlayTime);
140 
141  void AddVideoPlayTime(PRInt64 aAddVideoPlayTime);
142 
143  // Image count.
144  PRUint32 ImageCount();
145 
146  void SetImageCount(PRUint32 aImageCount);
147 
148  void AddImageCount(PRInt32 aAddImageCount);
149 
150  // Image used.
151  PRUint64 ImageUsed();
152 
153  void SetImageUsed(PRUint64 aImageUsed);
154 
155  void AddImageUsed(PRInt64 aAddImageUsed);
156 
157 
158  //----------------------------------------------------------------------------
159  //
160  // Private interface.
161  //
162  //----------------------------------------------------------------------------
163 
164 private:
165 
166  //
167  // mBaseDevice Base device for statistics. Used to interface
168  // to base device class. Don't keep a reference to
169  // the device to avoid a cycle.
170  //
171  // mStatLock Lock used for serializing access to statistics.
172  // mAudioCount Count of the number of audio items.
173  // mAudioUsed Count of the number of bytes used for audio.
174  // mAudioPlayTime Total audio playback time in microseconds.
175  // mVideoCount Count of the number of video items.
176  // mVideoUsed Count of the number of bytes used for video.
177  // mVideoPlayTime Total video playback time in microseconds.
178  // mVideoCount Count of the number of image items.
179  // mVideoUsed Count of the number of bytes used for images.
180  //
181 
182  class sbBaseDevice* mBaseDevice;
183 
184  PRLock * mStatLock;
185  PRUint32 mAudioCount;
186  PRUint64 mAudioUsed;
187  PRUint64 mAudioPlayTime;
188  PRUint32 mVideoCount;
189  PRUint64 mVideoUsed;
190  PRUint64 mVideoPlayTime;
191  PRUint32 mImageCount;
192  PRUint64 mImageUsed;
193 
194 
195  //
196  // Private device statistics services.
197  //
198 
200 
201  virtual ~sbDeviceStatistics();
202 
203  nsresult Initialize(class sbBaseDevice* aDevice);
204 
205  nsresult ClearLibraryStatistics(sbIDeviceLibrary* aLibrary);
206 
207  nsresult UpdateForItem(sbIMediaItem* aMediaItem,
208  PRBool aItemAdded);
209 
210 
211  // Prevent derivation.
213 };
214 
215 #endif /* SBDEVICESTATISTICS_H_ */
216 
nsresult RemoveLibrary(sbIDeviceLibrary *aLibrary)
nsresult RemoveAllItems(sbIDeviceLibrary *aLibrary)
void SetVideoCount(PRUint32 aVideoCount)
void AddImageUsed(PRInt64 aAddImageUsed)
Interface used to enumerate the items in a media list.
void AddVideoCount(PRInt32 aAddVideoCount)
NS_DECL_ISUPPORTS static NS_DECL_SBIMEDIALISTENUMERATIONLISTENER nsresult New(class sbBaseDevice *aDevice, sbDeviceStatistics **aDeviceStatistics)
void AddAudioUsed(PRInt64 aAddAudioUsed)
nsresult AddLibrary(sbIDeviceLibrary *aLibrary)
void AddImageCount(PRInt32 aAddImageCount)
void SetVideoPlayTime(PRUint64 aVideoPlayTime)
void AddAudioPlayTime(PRInt64 aAddAudioPlayTime)
void SetAudioCount(PRUint32 aAudioCount)
void AddAudioCount(PRInt32 aAddAudioCount)
nsresult AddItem(sbIMediaItem *aMediaItem)
void AddVideoUsed(PRInt64 aAddVideoUsed)
friend class sbDeviceStatistics
Definition: sbBaseDevice.h:645
nsresult RemoveItem(sbIMediaItem *aMediaItem)
void SetImageUsed(PRUint64 aImageUsed)
void SetVideoUsed(PRUint64 aVideoUsed)
void AddVideoPlayTime(PRInt64 aAddVideoPlayTime)
Interface that defines a single item of media in the system.
void SetImageCount(PRUint32 aImageCount)
void SetAudioUsed(PRUint64 aAudioUsed)
void SetAudioPlayTime(PRUint64 aAudioPlayTime)