sbMediacoreCapabilities.cpp
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
32 
33 #include <nsCOMPtr.h>
34 
39 #ifdef PR_LOGGING
40 static PRLogModuleInfo* gMediacoreCapabilities = nsnull;
41 #define TRACE(args) PR_LOG(gMediacoreCapabilities , PR_LOG_DEBUG, args)
42 #define LOG(args) PR_LOG(gMediacoreCapabilities , PR_LOG_WARN, args)
43 #else
44 #define TRACE(args) /* nothing */
45 #define LOG(args) /* nothing */
46 #endif
47 
50 
52 : mLock(nsnull)
53 , mSupportsAudioPlayback(PR_FALSE)
54 , mSupportsVideoPlayback(PR_FALSE)
55 , mSupportsImagePlayback(PR_FALSE)
56 , mSupportsAudioTranscode(PR_FALSE)
57 , mSupportsVideoTranscode(PR_FALSE)
58 , mSupportsImageTranscode(PR_FALSE)
59 {
60  MOZ_COUNT_CTOR(sbMediacoreCapabilities);
61 
62 #ifdef PR_LOGGING
63  if (!gMediacoreCapabilities)
64  gMediacoreCapabilities = PR_NewLogModule("sbMediacoreCapabilities");
65 #endif
66 
67  TRACE(("sbMediacoreCapabilities[0x%x] - Created", this));
68 }
69 
71 {
72  TRACE(("sbMediacoreCapabilities[0x%x] - Destroyed", this));
73 
74  MOZ_COUNT_DTOR(sbMediacoreCapabilities);
75 
76  if(mLock) {
77  nsAutoLock::DestroyLock(mLock);
78  }
79 }
80 
81 nsresult
83 {
84  TRACE(("sbMediacoreCapabilities[0x%x] - Init", this));
85 
86  mLock = nsAutoLock::NewLock("sbMediacoreCapabilities::mLock");
87  NS_ENSURE_TRUE(mLock, NS_ERROR_OUT_OF_MEMORY);
88 
89  return NS_OK;
90 }
91 
92 nsresult
94  const sbStringArray &aAudioExtensions)
95 {
96  TRACE(("sbMediacoreCapabilities[0x%x] - SetAudioExtensions", this));
97 
98  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
99 
100  nsAutoLock lock(mLock);
101  mAudioExtensions = aAudioExtensions;
102 
103  return NS_OK;
104 }
105 
106 nsresult
108  const sbStringArray &aVideoExtensions)
109 {
110  TRACE(("sbMediacoreCapabilities[0x%x] - SetVideoExtensions", this));
111 
112  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
113 
114  nsAutoLock lock(mLock);
115  mVideoExtensions = aVideoExtensions;
116 
117  return NS_OK;
118 }
119 
120 nsresult
122  const sbStringArray &aImageExtensions)
123 {
124  TRACE(("sbMediacoreCapabilities[0x%x] - SetImageExtensions", this));
125 
126  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
127 
128  nsAutoLock lock(mLock);
129  mImageExtensions = aImageExtensions;
130 
131  return NS_OK;
132 }
133 
134 nsresult
136 {
137  TRACE(("sbMediacoreCapabilities[0x%x] - SetSupportsAudioPlayback", this));
138 
139  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
140 
141  nsAutoLock lock(mLock);
142  mSupportsAudioPlayback = aSupportsAudioPlayback;
143 
144  return NS_OK;
145 }
146 
147 nsresult
149 {
150  TRACE(("sbMediacoreCapabilities[0x%x] - SetSupportsVideoPlayback", this));
151 
152  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
153 
154  nsAutoLock lock(mLock);
155  mSupportsVideoPlayback = aSupportsVideoPlayback;
156 
157  return NS_OK;
158 }
159 
160 nsresult
162 {
163  TRACE(("sbMediacoreCapabilities[0x%x] - SetSupportsImagePlayback", this));
164 
165  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
166 
167  nsAutoLock lock(mLock);
168  mSupportsImagePlayback = aSupportsImagePlayback;
169 
170  return NS_OK;
171 }
172 
173 nsresult
175 {
176  TRACE(("sbMediacoreCapabilities[0x%x] - SetSupportsAudioTranscode", this));
177 
178  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
179 
180  nsAutoLock lock(mLock);
181  mSupportsAudioTranscode = aSupportsAudioTranscode;
182 
183  return NS_OK;
184 }
185 
186 nsresult
188 {
189  TRACE(("sbMediacoreCapabilities[0x%x] - SetSupportsVideoTranscode", this));
190 
191  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
192 
193  nsAutoLock lock(mLock);
194  mSupportsVideoTranscode = aSupportsVideoTranscode;
195 
196  return NS_OK;
197 }
198 
199 nsresult
201 {
202  TRACE(("sbMediacoreCapabilities[0x%x] - SetSupportsImageTranscode", this));
203 
204  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
205 
206  nsAutoLock lock(mLock);
207  mSupportsImageTranscode = aSupportsImageTranscode;
208 
209  return NS_OK;
210 }
211 
212 NS_IMETHODIMP
213 sbMediacoreCapabilities::GetAudioExtensions(nsIStringEnumerator * *aAudioExtensions)
214 {
215  TRACE(("sbMediacoreCapabilities[0x%x] - GetAudioExtensions", this));
216 
217  NS_ENSURE_ARG_POINTER(aAudioExtensions);
218  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
219 
220  nsAutoLock lock(mLock);
221  nsCOMPtr<nsIStringEnumerator> audioExtensions =
223  NS_ENSURE_TRUE(audioExtensions, NS_ERROR_OUT_OF_MEMORY);
224 
225  audioExtensions.forget(aAudioExtensions);
226 
227  return NS_OK;
228 }
229 
230 NS_IMETHODIMP
231 sbMediacoreCapabilities::GetVideoExtensions(nsIStringEnumerator * *aVideoExtensions)
232 {
233  TRACE(("sbMediacoreCapabilities[0x%x] - GetVideoExtensions", this));
234 
235  NS_ENSURE_ARG_POINTER(aVideoExtensions);
236  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
237 
238  nsAutoLock lock(mLock);
239  nsCOMPtr<nsIStringEnumerator> videoExtensions =
241  NS_ENSURE_TRUE(videoExtensions, NS_ERROR_OUT_OF_MEMORY);
242 
243  videoExtensions.forget(aVideoExtensions);
244 
245  return NS_OK;
246 }
247 
248 NS_IMETHODIMP
249 sbMediacoreCapabilities::GetImageExtensions(nsIStringEnumerator * *aImageExtensions)
250 {
251  TRACE(("sbMediacoreCapabilities[0x%x] - GetImageExtensions", this));
252 
253  NS_ENSURE_ARG_POINTER(aImageExtensions);
254  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
255 
256  nsAutoLock lock(mLock);
257  nsCOMPtr<nsIStringEnumerator> imageExtensions =
259  NS_ENSURE_TRUE(imageExtensions, NS_ERROR_OUT_OF_MEMORY);
260 
261  imageExtensions.forget(aImageExtensions);
262 
263  return NS_OK;
264 }
265 
266 NS_IMETHODIMP
267 sbMediacoreCapabilities::GetSupportsAudioPlayback(PRBool *aSupportsAudioPlayback)
268 {
269  TRACE(("sbMediacoreCapabilities[0x%x] - GetSupportsAudioPlayback", this));
270 
271  NS_ENSURE_ARG_POINTER(aSupportsAudioPlayback);
272  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
273 
274  nsAutoLock lock(mLock);
275  *aSupportsAudioPlayback = mSupportsAudioPlayback;
276 
277  return NS_OK;
278 }
279 
280 NS_IMETHODIMP
281 sbMediacoreCapabilities::GetSupportsVideoPlayback(PRBool *aSupportsVideoPlayback)
282 {
283  TRACE(("sbMediacoreCapabilities[0x%x] - GetSupportsVideoPlayback", this));
284 
285  NS_ENSURE_ARG_POINTER(aSupportsVideoPlayback);
286  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
287 
288  nsAutoLock lock(mLock);
289  *aSupportsVideoPlayback = mSupportsVideoPlayback;
290 
291  return NS_OK;
292 }
293 
294 NS_IMETHODIMP
295 sbMediacoreCapabilities::GetSupportsImagePlayback(PRBool *aSupportsImagePlayback)
296 {
297  TRACE(("sbMediacoreCapabilities[0x%x] - GetSupportsImagePlayback", this));
298 
299  NS_ENSURE_ARG_POINTER(aSupportsImagePlayback);
300  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
301 
302  nsAutoLock lock(mLock);
303  *aSupportsImagePlayback = mSupportsImagePlayback;
304 
305  return NS_OK;
306 }
307 
308 NS_IMETHODIMP
309 sbMediacoreCapabilities::GetSupportsAudioTranscode(PRBool *aSupportsAudioTranscode)
310 {
311  TRACE(("sbMediacoreCapabilities[0x%x] - GetSupportsAudioTranscode", this));
312 
313  NS_ENSURE_ARG_POINTER(aSupportsAudioTranscode);
314  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
315 
316  nsAutoLock lock(mLock);
317  *aSupportsAudioTranscode = mSupportsAudioTranscode;
318 
319  return NS_OK;
320 }
321 
322 NS_IMETHODIMP
323 sbMediacoreCapabilities::GetSupportsVideoTranscode(PRBool *aSupportsVideoTranscode)
324 {
325  TRACE(("sbMediacoreCapabilities[0x%x] - GetSupportsVideoTranscode", this));
326 
327  NS_ENSURE_ARG_POINTER(aSupportsVideoTranscode);
328  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
329 
330  nsAutoLock lock(mLock);
331  *aSupportsVideoTranscode = mSupportsVideoTranscode;
332 
333  return NS_OK;
334 }
335 
336 NS_IMETHODIMP
337 sbMediacoreCapabilities::GetSupportsImageTranscode(PRBool *aSupportsImageTranscode)
338 {
339  TRACE(("sbMediacoreCapabilities[0x%x] - GetSupportsImageTranscode", this));
340 
341  NS_ENSURE_ARG_POINTER(aSupportsImageTranscode);
342  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
343 
344  nsAutoLock lock(mLock);
345  *aSupportsImageTranscode = mSupportsImageTranscode;
346 
347  return NS_OK;
348 }
nsresult SetSupportsAudioTranscode(PRBool aSupportsAudioTranscode)
return NS_OK
readonly attribute nsIStringEnumerator videoExtensions
Video file extensions (eg. avi, mpg, mov, ...)
readonly attribute nsIStringEnumerator imageExtensions
Image file extensions (eg. jpg, tiff, png, ...)
nsresult SetSupportsImageTranscode(PRBool aSupportsImageTranscode)
readonly attribute nsIStringEnumerator audioExtensions
Audio file extensions (eg. mp3, aac, m4a, ...)
nsresult SetSupportsImagePlayback(PRBool aSupportsImagePlayback)
nsresult SetSupportsVideoTranscode(PRBool aSupportsVideoTranscode)
Songbird Mediacore Capabilities Definition.
nsresult SetAudioExtensions(const sbStringArray &aAudioExtensions)
nsresult SetSupportsVideoPlayback(PRBool aSupportsVideoPlayback)
nsresult SetSupportsAudioPlayback(PRBool aSupportsAudioPlayback)
#define TRACE(args)
nsresult SetImageExtensions(const sbStringArray &aImageExtensions)
nsresult SetVideoExtensions(const sbStringArray &aVideoExtensions)
NS_IMPL_THREADSAFE_ISUPPORTS1(sbMediacoreCapabilities, sbIMediacoreCapabilities) sbMediacoreCapabilities