sbTranscodingConfigurator.cpp
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
26 
27 #include <nsIURI.h>
28 #include <nsIWritablePropertyBag2.h>
29 
30 #include <sbITranscodeError.h>
31 
32 #include <sbStringUtils.h>
33 
36 
38  : mConfigurateState(CONFIGURATE_NOT_STARTED),
39  mInputFormat(nsnull),
40  mUseMuxer(PR_FALSE),
41  mMuxer(SBVoidString()),
42  mUseVideoEncoder(PR_FALSE),
43  mVideoEncoder(SBVoidString()),
44  mUseAudioEncoder(PR_FALSE),
45  mAudioEncoder(SBVoidString()),
46  mVideoFormat(nsnull),
47  mAudioFormat(nsnull),
48  mVideoEncoderProperties(nsnull),
49  mAudioEncoderProperties(nsnull)
50 {
51  // Nothing to do yet.
52 }
53 
55 {
56  // Nothing to do yet
57 }
58 
59 /* attribute readonly nsIArray availableProfiles; */
60 NS_IMETHODIMP
61 sbTranscodingConfigurator::GetAvailableProfiles(nsIArray **aArray)
62 {
63  NS_ENSURE_ARG_POINTER(aArray);
64 
65  return NS_ERROR_NOT_IMPLEMENTED;
66 }
67 
68 /* attribute nsIURI inputUri; */
69 NS_IMETHODIMP
70 sbTranscodingConfigurator::GetInputUri(nsIURI * *aInputUri)
71 {
72  NS_ENSURE_ARG_POINTER(aInputUri);
73  NS_IF_ADDREF(*aInputUri = mInputUri);
74  return NS_OK;
75 }
76 NS_IMETHODIMP
77 sbTranscodingConfigurator::SetInputUri(nsIURI * aInputUri)
78 {
79  mInputUri = aInputUri;
80  return NS_OK;
81 }
82 
87 NS_IMETHODIMP
88 sbTranscodingConfigurator::GetInputFormat(sbIMediaFormat **aInputFormat)
89 {
90  NS_ENSURE_ARG_POINTER(aInputFormat);
91  NS_IF_ADDREF(*aInputFormat = mInputFormat);
92  return NS_OK;
93 }
94 
100 NS_IMETHODIMP
101 sbTranscodingConfigurator::SetInputFormat(sbIMediaFormat *aInputFormat)
102 {
103  NS_ENSURE_FALSE(mConfigurateState >= CONFIGURATE_FINISHED,
104  NS_ERROR_ALREADY_INITIALIZED);
105  NS_ENSURE_ARG(aInputFormat);
106  mInputFormat = aInputFormat;
107  return NS_OK;
108 }
109 
110 /* readonly attribute sbITranscodeError lastError; */
111 NS_IMETHODIMP
112 sbTranscodingConfigurator::GetLastError(sbITranscodeError * *aLastError)
113 {
114  NS_ENSURE_ARG_POINTER(aLastError);
115  NS_IF_ADDREF(*aLastError = mLastError);
116  return NS_OK;
117 }
118 
119 /* void determineOutputType (); */
120 NS_IMETHODIMP
121 sbTranscodingConfigurator::DetermineOutputType()
122 {
123  NS_NOTYETIMPLEMENTED("sbTranscodingConfigurator::DetermineOutputType");
124  return NS_ERROR_NOT_IMPLEMENTED;
125 }
126 
132 NS_IMETHODIMP
133 sbTranscodingConfigurator::GetMuxer(nsAString &aMuxer)
134 {
135  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
136  NS_ERROR_NOT_INITIALIZED);
137  aMuxer = mMuxer;
138  return NS_OK;
139 }
140 
144 NS_IMETHODIMP
145 sbTranscodingConfigurator::GetUseMuxer(PRBool *aUseMuxer)
146 {
147  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
148  NS_ERROR_NOT_INITIALIZED);
149  *aUseMuxer = mUseMuxer;
150  return NS_OK;
151 }
152 
153 /* readonly attribute ACString fileExtension; */
154 NS_IMETHODIMP
155 sbTranscodingConfigurator::GetFileExtension(nsACString & aFileExtension)
156 {
157  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
158  NS_ERROR_NOT_INITIALIZED);
159  aFileExtension = mFileExtension;
160  return NS_OK;
161 }
162 
166 NS_IMETHODIMP
167 sbTranscodingConfigurator::GetUseAudioEncoder(PRBool *aUseAudioEncoder)
168 {
169  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
170  NS_ERROR_NOT_INITIALIZED);
171  *aUseAudioEncoder = mUseAudioEncoder;
172  return NS_OK;
173 }
174 
180 NS_IMETHODIMP
181 sbTranscodingConfigurator::GetAudioEncoder(nsAString &aAudioEncoder)
182 {
183  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
184  NS_ERROR_NOT_INITIALIZED);
185  aAudioEncoder = mAudioEncoder;
186  return NS_OK;
187 }
188 
192 NS_IMETHODIMP
193 sbTranscodingConfigurator::GetUseVideoEncoder(PRBool *aUseVideoEncoder)
194 {
195  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
196  NS_ERROR_NOT_INITIALIZED);
197  *aUseVideoEncoder = mUseVideoEncoder;
198  return NS_OK;
199 }
200 
206 NS_IMETHODIMP
207 sbTranscodingConfigurator::GetVideoEncoder(nsAString &aVideoEncoder)
208 {
209  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_OUTPUT_SET,
210  NS_ERROR_NOT_INITIALIZED);
211  aVideoEncoder = mVideoEncoder;
212  return NS_OK;
213 }
214 
219 NS_IMETHODIMP
220 sbTranscodingConfigurator::Configurate(void)
221 {
222  NS_NOTYETIMPLEMENTED("sbTranscodingConfigurator::Configurate");
223  return NS_ERROR_NOT_IMPLEMENTED;
224 }
225 
231 NS_IMETHODIMP
232 sbTranscodingConfigurator::GetVideoFormat(sbIMediaFormatVideo **aVideoFormat)
233 {
234  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_FINISHED,
235  NS_ERROR_NOT_INITIALIZED);
236  NS_ENSURE_ARG_POINTER(aVideoFormat);
237  NS_IF_ADDREF(*aVideoFormat = mVideoFormat);
238  return NS_OK;
239 }
240 
246 NS_IMETHODIMP
247 sbTranscodingConfigurator::GetAudioFormat(sbIMediaFormatAudio **aAudioFormat)
248 {
249  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_FINISHED,
250  NS_ERROR_NOT_INITIALIZED);
251  NS_ENSURE_ARG_POINTER(aAudioFormat);
252  NS_IF_ADDREF(*aAudioFormat = mAudioFormat);
253  return NS_OK;
254 }
255 
261 NS_IMETHODIMP
262 sbTranscodingConfigurator::GetVideoEncoderProperties(
263  nsIPropertyBag **aVideoEncoderProperties)
264 {
265  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_FINISHED,
266  NS_ERROR_NOT_INITIALIZED);
267  NS_ENSURE_ARG_POINTER(aVideoEncoderProperties);
268  nsresult rv;
269  rv = CallQueryInterface(mVideoEncoderProperties, aVideoEncoderProperties);
270  NS_ENSURE_SUCCESS(rv, rv);
271  return NS_OK;
272 }
273 
279 NS_IMETHODIMP
280 sbTranscodingConfigurator::GetAudioEncoderProperties(
281  nsIPropertyBag **aAudioEncoderProperties)
282 {
283  NS_ENSURE_TRUE(mConfigurateState >= CONFIGURATE_FINISHED,
284  NS_ERROR_NOT_INITIALIZED);
285  NS_ENSURE_ARG_POINTER(aAudioEncoderProperties);
286  nsresult rv;
287  rv = CallQueryInterface(mAudioEncoderProperties, aAudioEncoderProperties);
288  NS_ENSURE_SUCCESS(rv, rv);
289  return NS_OK;
290 }
return NS_OK
Base interface for all Transcoding Configurators. This interface should be implemented by any Configu...
nsCOMPtr< sbITranscodeError > mLastError
nsCOMPtr< sbIMediaFormat > mInputFormat
nsCOMPtr< sbIMediaFormatVideo > mVideoFormat
nsCOMPtr< nsIWritablePropertyBag2 > mAudioEncoderProperties
NS_IMPL_THREADSAFE_ISUPPORTS1(sbTranscodingConfigurator, sbITranscodingConfigurator) sbTranscodingConfigurator
nsCOMPtr< nsIWritablePropertyBag2 > mVideoEncoderProperties
nsCOMPtr< sbIMediaFormatAudio > mAudioFormat