sbGStreamerTranscodeAudioConfigurator.h
Go to the documentation of this file.
1 /* vim: set sw=2 */
2 /*
3  *=BEGIN SONGBIRD GPL
4  *
5  * This file is part of the Songbird web player.
6  *
7  * Copyright(c) 2005-2009 POTI, Inc.
8  * http://www.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 #ifndef _SB_GSTREAMER_TRANSCODE_AUDIO_CONFIGURATOR_H_
27 #define _SB_GSTREAMER_TRANSCODE_AUDIO_CONFIGURATOR_H_
28 
29 // {b61e78ec-9aa1-4505-b16c-e33819bca705}
30 #define SB_GSTREAMER_TRANSCODE_AUDIO_CONFIGURATOR_CID \
31  { 0xb61e78ec, 0x9aa1, 0x4505, \
32  { 0xb1, 0x6c, 0xe3, 0x38, 0x19, 0xbc, 0xa7, 0x05 } }
33 
34 #define SB_GSTREAMER_TRANSCODE_AUDIO_CONFIGURATOR_CONTRACTID \
35  "@songbirdnest.com/Songbird/Mediacore/Transcode/Configurator/Audio/GStreamer;1"
36 #define SB_GSTREAMER_TRANSCODE_AUDIO_CONFIGURATOR_CLASSNAME \
37  "GStreamerTranscodeAudioConfigurator"
38 
40 
41 #include <sbITranscodingConfigurator.h>
42 #include <sbITranscodeProfile.h>
43 #include <sbPIGstTranscodingConfigurator.h>
44 
45 #include <nsCOMPtr.h>
46 #include <nsDataHashtable.h>
47 
48 class nsIArray;
49 class nsIWritablePropertyBag;
50 
51 class sbIDevice;
53 class sbIAudioFormatType;
54 
58 {
59 public:
61  NS_DECL_SBIDEVICETRANSCODINGCONFIGURATOR
62 
63  // forward most of sbITranscodingConfigurator to the base class
64  #define FORWARD_TO_BASE(METHOD, PROTO, ARGS) \
65  NS_IMETHOD METHOD PROTO { return sbTranscodingConfigurator::METHOD(ARGS); }
66 
67  FORWARD_TO_BASE(GetInputUri, (nsIURI ** aUri), aUri)
68  FORWARD_TO_BASE(SetInputUri, (nsIURI * aUri), aUri)
69  FORWARD_TO_BASE(GetInputFormat, (sbIMediaFormat * *aInputFormat), aInputFormat)
70  FORWARD_TO_BASE(SetInputFormat, (sbIMediaFormat * aInputFormat), aInputFormat)
71  FORWARD_TO_BASE(GetLastError, (sbITranscodeError * *aLastError), aLastError)
72  FORWARD_TO_BASE(GetMuxer, (nsAString & aMuxer), aMuxer)
73  FORWARD_TO_BASE(GetUseMuxer, (PRBool *aUseMuxer), aUseMuxer)
74  FORWARD_TO_BASE(GetFileExtension, (nsACString & aFileExtension), aFileExtension)
75  FORWARD_TO_BASE(GetVideoEncoder, (nsAString & aVideoEncoder), aVideoEncoder)
76  FORWARD_TO_BASE(GetUseVideoEncoder, (PRBool *aUseVideoEncoder), aUseVideoEncoder)
77  FORWARD_TO_BASE(GetVideoFormat, (sbIMediaFormatVideo * *aVideoFormat), aVideoFormat)
78  FORWARD_TO_BASE(GetAudioEncoder, (nsAString & aAudioEncoder), aAudioEncoder)
79  FORWARD_TO_BASE(GetUseAudioEncoder, (PRBool *aUseAudioEncoder), aUseAudioEncoder)
80  FORWARD_TO_BASE(GetAudioFormat, (sbIMediaFormatAudio * *aAudioFormat), aAudioFormat)
81  FORWARD_TO_BASE(GetVideoEncoderProperties, (nsIPropertyBag * *aVideoEncoderProperties), aVideoEncoderProperties)
82  FORWARD_TO_BASE(GetAudioEncoderProperties, (nsIPropertyBag * *aAudioEncoderProperties), aAudioEncoderProperties)
83 
84  #undef FORWARD_TO_BASE
85 
86  /*
87  * re-implement determineOutputType() and configurate() to have the
88  * configuration logic specific to gstreamer-based configuration for devices
89  */
90  NS_IMETHOD DetermineOutputType();
91  NS_IMETHOD Configurate();
92 
93  NS_IMETHOD GetAvailableProfiles(nsIArray **aProfiles);
94 
96 
97 protected:
99 
109  nsresult EnsureProfileAvailable(sbITranscodeProfile *aProfile);
110 
112  sbIAudioFormatType **aFormat);
113 
124  nsresult SelectProfile();
125 
126  /* Select the audio format (sample rate, channels, etc) to encode to */
127  nsresult SelectOutputAudioFormat();
128 
135  nsresult SetAudioProperties();
136 
143  nsresult CopyPropertiesIntoBag(nsIArray * aSrcProps,
144  nsIWritablePropertyBag * aDstBag,
145  PRBool aIsVideo);
146 
147  /* For each property in the property array, get a value from the device
148  * preferences and apply it to the property.
149  */
150  nsresult ApplyPreferencesToPropertyArray(sbIDevice *aDevice,
151  nsIArray *aPropertyArray,
152  nsString aPrefNameBase);
153 
154 protected:
159  nsCString muxer;
160  nsCString audioEncoder;
161  nsCString videoEncoder;
162  };
163  nsDataHashtable<nsISupportsHashKey, EncoderProfileData> mElementNames;
164 
168  nsCOMPtr<sbIDevice> mDevice;
173  nsCOMPtr<nsIArray> mAvailableProfiles;
177  nsCOMPtr<sbITranscodeProfile> mSelectedProfile;
182  nsCOMPtr<sbIAudioFormatType> mSelectedFormat;
183 
189 
194 };
195 
196 #endif // _SB_GSTREAMER_TRANSCODE_AUDIO_CONFIGURATOR_H_
NS_IMETHOD GetUseAudioEncoder(PRBool *aUseAudioEncoder)
NS_IMETHOD GetUseVideoEncoder(PRBool *aUseVideoEncoder)
NS_IMETHOD GetVideoEncoderProperties(nsIPropertyBag **aVideoEncoderProperties)
NS_IMETHOD GetAudioFormat(sbIMediaFormatAudio **aAudioFormat)
NS_IMETHOD GetVideoFormat(sbIMediaFormatVideo **aVideoFormat)
NS_IMETHOD GetInputFormat(sbIMediaFormat **aInputFormat)
NS_IMETHOD GetAudioEncoderProperties(nsIPropertyBag **aAudioEncoderProperties)
nsresult CopyPropertiesIntoBag(nsIArray *aSrcProps, nsIWritablePropertyBag *aDstBag, PRBool aIsVideo)
NS_IMETHOD GetLastError(sbITranscodeError **aLastError)
An object defining a transcoding profile.
NS_IMETHOD GetVideoEncoder(nsAString &aVideoEncoder)
NS_IMETHOD GetAudioEncoder(nsAString &aAudioEncoder)
nsresult EnsureProfileAvailable(sbITranscodeProfile *aProfile)
nsDataHashtable< nsISupportsHashKey, EncoderProfileData > mElementNames
NS_IMETHOD GetFileExtension(nsACString &aFileExtension)
nsresult CheckProfileSupportedByDevice(sbITranscodeProfile *aProfile, sbIAudioFormatType **aFormat)
#define FORWARD_TO_BASE(METHOD, PROTO, ARGS)
NS_IMETHOD SetInputFormat(sbIMediaFormat *aInputFormat)
nsresult ApplyPreferencesToPropertyArray(sbIDevice *aDevice, nsIArray *aPropertyArray, nsString aPrefNameBase)