sbGStreamerTranscode.h
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-2009 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 
27 #ifndef _SB_GSTREAMER_TRANSCODE_H_
28 #define _SB_GSTREAMER_TRANSCODE_H_
29 
30 #include <nsCOMPtr.h>
31 #include <nsCOMArray.h>
32 #include <nsITimer.h>
33 #include <nsTArray.h>
34 #include <nsStringGlue.h>
35 
36 #include <gst/gst.h>
37 
38 #include "sbITranscodeJob.h"
39 #include "sbITranscodeProfile.h"
40 #include "sbIJobProgress.h"
41 #include "sbIJobCancelable.h"
42 
43 #include "sbGStreamerPipeline.h"
44 
45 // {67623837-fea5-4005-b475-e34b738635c4}
46 #define SB_GSTREAMER_TRANSCODE_CID \
47  { 0x67623837, 0xfea5, 0x4005, \
48  { 0xb4, 0x75, 0xe3, 0x4b, 0x73, 0x86, 0x35, 0xc4 } }
49 
50 #define SB_GSTREAMER_TRANSCODE_CONTRACTID "@songbirdnest.com/Songbird/Mediacore/Transcode/GStreamer;1"
51 #define SB_GSTREAMER_TRANSCODE_CLASSNAME "GStreamerTranscode"
52 
53 
55  public sbITranscodeJob,
56  public sbIJobProgressTime,
57  public sbIJobCancelable,
58  public nsITimerCallback
59 {
60 public:
62  NS_DECL_NSICLASSINFO
63  NS_DECL_SBITRANSCODEJOB
64  NS_DECL_SBIJOBPROGRESS
65  NS_DECL_SBIJOBPROGRESSTIME
66  NS_DECL_SBIJOBCANCELABLE
67  NS_DECL_NSITIMERCALLBACK
68 
70 
71  virtual nsresult BuildPipeline();
72  NS_IMETHOD PlayPipeline();
73  NS_IMETHOD StopPipeline();
74 
75 private:
76  virtual ~sbGStreamerTranscode();
77 
78  nsresult LocalizeString(const nsAString& aName, nsAString& aValue);
79  nsresult OnJobProgress();
80 
81  void HandleErrorMessage(GstMessage *message);
82  void HandleEOSMessage(GstMessage *message);
83 
84  GstClockTime QueryPosition();
85  GstClockTime QueryDuration();
86 
87  nsresult StartProgressReporting();
88  nsresult StopProgressReporting();
89 
90  GstElement *BuildTranscodePipeline(sbITranscodeProfile *aProfile);
91  nsresult BuildPipelineString(nsCString description, nsACString &pipeline);
92  nsresult BuildPipelineFragmentFromProfile(sbITranscodeProfile *aProfile,
93  nsACString &pipelineFragment);
94  nsresult GetContainer(nsAString &container, nsIArray *properties,
95  nsACString &gstMuxer);
96  nsresult GetAudioCodec(nsAString &codec, nsIArray *properties,
97  nsACString &gstCodec);
98  nsresult AddImageToTagList(GstTagList *aTags, nsIInputStream *aStream);
99 
100  nsCOMPtr<sbIPropertyArray> mMetadata;
101  nsCOMPtr<nsIInputStream> mImageStream;
102 
103  nsString mSourceURI;
104  nsString mDestURI;
105  nsCOMPtr<sbITranscodeProfile> mProfile;
106 
107  PRUint16 mStatus;
108  nsTArray<nsString> mErrorMessages;
109 
110  nsCOMArray<sbIJobProgressListener> mProgressListeners;
111  nsCOMPtr<nsITimer> mProgressTimer;
112 
113  nsCOMPtr<nsIArray> mAvailableProfiles;
114 
115 protected:
116  /* additional members */
117 };
118 
119 #endif // _SB_GSTREAMER_TRANSCODE_H_
onPageChanged aValue
Definition: FeedWriter.js:1395
An object defining a transcoding profile.
virtual nsresult BuildPipeline()
Generic interface extending sbIJobProgress that can track expected time, etc in addition to abstract ...
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBITRANSCODEJOB NS_DECL_SBIJOBPROGRESS NS_DECL_SBIJOBPROGRESSTIME NS_DECL_SBIJOBCANCELABLE NS_DECL_NSITIMERCALLBACK sbGStreamerTranscode()
GstMessage * message
_updateCookies aName
An object capable of transcoding a source URI to a destination file.
nsITimerCallback