sbBaseMediacoreFactory.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 "sbBaseMediacoreFactory.h"
32 
33 #include <sbIMediacore.h>
34 
39 #ifdef PR_LOGGING
40 static PRLogModuleInfo* gBaseMediacoreFactory = nsnull;
41 #define TRACE(args) PR_LOG(gBaseMediacoreFactory, PR_LOG_DEBUG, args)
42 #define LOG(args) PR_LOG(gBaseMediacoreFactory, PR_LOG_WARN, args)
43 #else
44 #define TRACE(args) /* nothing */
45 #define LOG(args) /* nothing */
46 #endif
47 
50 
52 : mMonitor(nsnull)
53 {
54  MOZ_COUNT_CTOR(sbBaseMediacoreFactory);
55 
56 #ifdef PR_LOGGING
57  if (!gBaseMediacoreFactory)
58  gBaseMediacoreFactory= PR_NewLogModule("sbBaseMediacoreFactory");
59 #endif
60 
61  TRACE(("sbBaseMediacoreFactory[0x%x] - Created", this));
62 }
63 
65 {
66  TRACE(("sbBaseMediacoreFactory[0x%x] - Destroyed", this));
67  MOZ_COUNT_DTOR(sbBaseMediacoreFactory);
68 
69  if(mMonitor) {
70  nsAutoMonitor::DestroyMonitor(mMonitor);
71  }
72 }
73 
74 nsresult
76 {
77  TRACE(("sbBaseMediacoreFactory[0x%x] - InitBaseMediacoreFactory", this));
78 
79  mMonitor = nsAutoMonitor::NewMonitor("sbBaseMediacoreFactory::mMonitor");
80  NS_ENSURE_TRUE(mMonitor, NS_ERROR_OUT_OF_MEMORY);
81 
83 }
84 
85 nsresult
86 sbBaseMediacoreFactory::SetContractID(const nsAString &aContractID)
87 {
88  TRACE(("sbBaseMediacoreFactory[0x%x] - Init", this));
89  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
90 
91  nsAutoMonitor mon(mMonitor);
92  mContractID = aContractID;
93 
94  return NS_OK;
95 }
96 
97 nsresult
99 {
100  TRACE(("sbBaseMediacoreFactory[0x%x] - Init", this));
101  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
102 
103  nsAutoMonitor mon(mMonitor);
104  mName = aName;
105 
106  return NS_OK;
107 }
108 
109 NS_IMETHODIMP
110 sbBaseMediacoreFactory::GetContractID(nsAString & aContractID)
111 {
112  TRACE(("sbBaseMediacoreFactory[0x%x] - Init", this));
113  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
114 
115  nsAutoMonitor mon(mMonitor);
116  aContractID = mContractID;
117 
118  return NS_OK;
119 }
120 
121 NS_IMETHODIMP
122 sbBaseMediacoreFactory::GetName(nsAString & aName)
123 {
124  TRACE(("sbBaseMediacoreFactory[0x%x] - Init", this));
125  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
126 
127  nsAutoMonitor mon(mMonitor);
128  aName = mName;
129 
130  return NS_OK;
131 }
132 
133 NS_IMETHODIMP
134 sbBaseMediacoreFactory::GetCapabilities(
135  sbIMediacoreCapabilities * *aCapabilities)
136 {
137  TRACE(("sbBaseMediacoreFactory[0x%x] - GetCapabilities", this));
138  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
139  NS_ENSURE_ARG_POINTER(aCapabilities);
140 
141  nsAutoMonitor mon(mMonitor);
142  return OnGetCapabilities(aCapabilities);
143 }
144 
145 NS_IMETHODIMP
146 sbBaseMediacoreFactory::Create(const nsAString & aInstanceName,
147  sbIMediacore **_retval)
148 {
149  TRACE(("sbBaseMediacoreFactory[0x%x] - Create", this));
150  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
151  NS_ENSURE_ARG_POINTER(_retval);
152 
153  nsAutoMonitor mon(mMonitor);
154 
155  nsresult rv = OnCreate(aInstanceName, _retval);
156  NS_ENSURE_SUCCESS(rv, rv);
157  NS_ENSURE_TRUE(*_retval, NS_ERROR_UNEXPECTED);
158 
159  NS_ADDREF(*_retval);
160 
161  return NS_OK;
162 }
163 
164 /*virtual*/ nsresult
166 {
178  return NS_ERROR_NOT_IMPLEMENTED;
179 }
180 
181 /*virtual*/ nsresult
183  sbIMediacoreCapabilities **aCapabilities)
184 {
195  return NS_ERROR_NOT_IMPLEMENTED;
196 }
197 
198 /*virtual*/ nsresult
199 sbBaseMediacoreFactory::OnCreate(const nsAString &aInstanceName,
200  sbIMediacore **_retval)
201 {
208  return NS_ERROR_NOT_IMPLEMENTED;
209 }
virtual nsresult OnCreate(const nsAString &aInstanceName, sbIMediacore **_retval)
return NS_OK
nsresult SetContractID(const nsAString &aContractID)
nsresult SetName(const nsAString &aName)
Songbird Base Mediacore Factory Definition.
NS_IMPL_THREADSAFE_ISUPPORTS1(sbBaseMediacoreFactory, sbIMediacoreFactory) sbBaseMediacoreFactory
#define TRACE(args)
_updateCookies aName
virtual nsresult OnInitBaseMediacoreFactory()
virtual nsresult OnGetCapabilities(sbIMediacoreCapabilities **aCapabilities)