sbBaseMediacore.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 
31 #include "sbBaseMediacore.h"
32 
33 #include <nsIClassInfoImpl.h>
34 #include <nsIProgrammingLanguage.h>
35 
36 #include <nsMemory.h>
37 
42 #ifdef PR_LOGGING
43 static PRLogModuleInfo* gBaseMediacore = nsnull;
44 #define TRACE(args) PR_LOG(gBaseMediacore, PR_LOG_DEBUG, args)
45 #define LOG(args) PR_LOG(gBaseMediacore, PR_LOG_WARN, args)
46 #else
47 #define TRACE(args) /* nothing */
48 #define LOG(args) /* nothing */
49 #endif
50 
54 
58 
59 NS_DECL_CLASSINFO(sbBaseMediacore)
60 NS_IMPL_THREADSAFE_CI(sbBaseMediacore)
61 
62 sbBaseMediacore::sbBaseMediacore()
63 : mMonitor(nsnull)
64 {
65  MOZ_COUNT_CTOR(sbBaseMediacore);
66 
67 #ifdef PR_LOGGING
68  if (!gBaseMediacore)
69  gBaseMediacore = PR_NewLogModule("sbBaseMediacore");
70 #endif
71 
72  TRACE(("sbBaseMediacore[0x%x] - Created", this));
73 }
74 
76 {
77  TRACE(("sbBaseMediacore[0x%x] - Destroyed", this));
78  MOZ_COUNT_DTOR(sbBaseMediacore);
79 
80  if (mMonitor) {
81  nsAutoMonitor::DestroyMonitor(mMonitor);
82  }
83 }
84 
85 nsresult
87 {
88  TRACE(("sbBaseMediacore[0x%x] - InitBaseMediacore", this));
89 
90  mMonitor = nsAutoMonitor::NewMonitor("sbBaseMediacore::mMonitor");
91  NS_ENSURE_TRUE(mMonitor, NS_ERROR_OUT_OF_MEMORY);
92 
93  return OnInitBaseMediacore();
94 }
95 
96 nsresult
97 sbBaseMediacore::SetInstanceName(const nsAString &aInstanceName)
98 {
99  TRACE(("sbBaseMediacore[0x%x] - SetInstanceName", this));
100  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
101 
102  nsAutoMonitor mon(mMonitor);
103  mInstanceName = aInstanceName;
104 
105  return NS_OK;
106 }
107 
108 nsresult
110 {
111  TRACE(("sbBaseMediacore[0x%x] - SetCapabilities", this));
112  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
113  NS_ENSURE_ARG_POINTER(aCapabilities);
114 
115  nsAutoMonitor mon(mMonitor);
116  mCapabilities = aCapabilities;
117 
118  return NS_OK;
119 }
120 
121 nsresult
123 {
124  TRACE(("sbBaseMediacore[0x%x] - SetStatus", this));
125  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
126  NS_ENSURE_ARG_POINTER(aStatus);
127 
128  nsAutoMonitor mon(mMonitor);
129  mStatus = aStatus;
130 
131  return NS_OK;
132 }
133 
134 NS_IMETHODIMP
135 sbBaseMediacore::GetInstanceName(nsAString & aInstanceName)
136 {
137  TRACE(("sbBaseMediacore[0x%x] - GetInstanceName", this));
138  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
139 
140  nsAutoMonitor mon(mMonitor);
141  aInstanceName = mInstanceName;
142 
143  return NS_OK;
144 }
145 
146 NS_IMETHODIMP
147 sbBaseMediacore::GetCapabilities(sbIMediacoreCapabilities * *aCapabilities)
148 {
149  TRACE(("sbBaseMediacore[0x%x] - GetCapabilities", this));
150  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
151  NS_ENSURE_ARG_POINTER(aCapabilities);
152 
153  nsresult rv = OnGetCapabilities();
154  NS_ENSURE_SUCCESS(rv, rv);
155 
156  nsAutoMonitor mon(mMonitor);
157  NS_IF_ADDREF(*aCapabilities = mCapabilities);
158 
159  return NS_OK;
160 }
161 
162 NS_IMETHODIMP
163 sbBaseMediacore::GetStatus(sbIMediacoreStatus* *aStatus)
164 {
165  TRACE(("sbBaseMediacore[0x%x] - GetLastStatusEvent", this));
166  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
167  NS_ENSURE_ARG_POINTER(aStatus);
168 
169  nsAutoMonitor mon(mMonitor);
170  NS_IF_ADDREF(*aStatus = mStatus);
171 
172  return NS_OK;
173 }
174 
175 NS_IMETHODIMP
176 sbBaseMediacore::GetSequencer(sbIMediacoreSequencer* *aSequencer)
177 {
178  TRACE(("sbBaseMediacore[0x%x] - GetSequencer", this));
179  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
180  NS_ENSURE_ARG_POINTER(aSequencer);
181 
182  nsAutoMonitor mon(mMonitor);
183  NS_IF_ADDREF(*aSequencer = mSequencer);
184 
185  return NS_OK;
186 }
187 
188 NS_IMETHODIMP
189 sbBaseMediacore::SetSequencer(sbIMediacoreSequencer *aSequencer)
190 {
191  TRACE(("sbBaseMediacore[0x%x] - GetSequencer", this));
192  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
193  NS_ENSURE_ARG_POINTER(aSequencer);
194 
195  nsresult rv = OnSetSequencer(aSequencer);
196  NS_ENSURE_SUCCESS(rv, rv);
197 
198  nsAutoMonitor mon(mMonitor);
199  mSequencer = aSequencer;
200 
201  return NS_OK;
202 }
203 
204 NS_IMETHODIMP
205 sbBaseMediacore::Shutdown()
206 {
207  TRACE(("sbBaseMediacore[0x%x] - Shutdown", this));
208  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
209 
210  return OnShutdown();
211 }
212 
213 /*virtual*/ nsresult
215 {
224  return NS_ERROR_NOT_IMPLEMENTED;
225 }
226 
227 /*virtual*/ nsresult
229 {
239  return NS_ERROR_NOT_IMPLEMENTED;
240 }
241 
242 /*virtual*/ nsresult
244 {
260  return NS_OK;
261 }
262 
263 /*virtual*/ nsresult
265 {
275  return NS_ERROR_NOT_IMPLEMENTED;
276 }
277 
nsresult InitBaseMediacore()
virtual ~sbBaseMediacore()
return NS_OK
virtual nsresult OnInitBaseMediacore()
nsresult SetCapabilities(sbIMediacoreCapabilities *aCapabilities)
PRMonitor * mMonitor
NS_IMPL_THREADSAFE_CI(sbMediaListEnumeratorWrapper)
nsCOMPtr< sbIMediacoreCapabilities > mCapabilities
Songbird Base Mediacore Definition.
nsCOMPtr< sbIMediacoreStatus > mStatus
nsCOMPtr< sbIMediacoreSequencer > mSequencer
nsString mInstanceName
nsresult SetStatus(sbIMediacoreStatus *aStatus)
nsresult SetInstanceName(const nsAString &aInstanceName)
virtual nsresult OnShutdown()
sbIJobCancelable NS_DECL_CLASSINFO(sbGstreamerMediaInspector)
virtual nsresult OnSetSequencer(sbIMediacoreSequencer *aSequencer)
virtual nsresult OnGetCapabilities()
NS_IMPL_CI_INTERFACE_GETTER2(sbDataRemoteWrapper, sbIDataRemote, nsIClassInfo) sbDataRemoteWrapper
#define TRACE(args)
NS_IMPL_THREADSAFE_ISUPPORTS2(sbBaseMediacore, sbIMediacore, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER2(sbBaseMediacore