sbGStreamerMediaInspector.h
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 
25 #ifndef _SB_GSTREAMER_MEDIAINSPECTOR_H_
26 #define _SB_GSTREAMER_MEDIAINSPECTOR_H_
27 
28 #include <nsCOMPtr.h>
29 #include <nsTArray.h>
30 #include <nsStringGlue.h>
31 #include <nsIClassInfo.h>
32 #include <nsITimer.h>
33 
34 #include "sbIJobProgress.h"
35 #include "sbIJobCancelable.h"
36 #include "sbIMediaInspector.h"
37 #include "sbIMediaFormatMutable.h"
38 
39 #include "sbGStreamerPipeline.h"
40 
41 #include <gst/gst.h>
42 
44  public sbIMediaInspector,
45  public sbIJobProgress,
46  public sbIJobCancelable,
47  public nsITimerCallback
48 {
49 public:
51  NS_DECL_NSICLASSINFO
52  NS_DECL_SBIMEDIAINSPECTOR
53  NS_DECL_SBIJOBPROGRESS
54  NS_DECL_SBIJOBCANCELABLE
55  NS_DECL_NSITIMERCALLBACK
56 
58 
59 private:
60  virtual ~sbGStreamerMediaInspector();
61 
62  nsresult OnJobProgress();
63 
64  NS_IMETHOD StopPipeline();
65  virtual nsresult BuildPipeline();
66 
67  nsresult StartTimeoutTimer();
68  nsresult StopTimeoutTimer();
69  nsresult CleanupPipeline();
70  void ResetStatus();
71  nsresult CompleteInspection();
72 
73  nsresult PadAdded(GstPad *srcPad);
74  nsresult FakesinkEvent(GstPad *srcPad, GstEvent *event, PRBool isAudio);
75  nsresult ProcessPipelineForInfo();
76  nsresult ProcessContainerProperties(
77  sbIMediaFormatContainerMutable *aContainerFormat,
78  GstStructure *aStructure);
79  nsresult ProcessVideo(sbIMediaFormatVideo **aVideoFormat);
80  nsresult ProcessVideoCaps(sbIMediaFormatVideoMutable *format, GstCaps *caps);
81  nsresult ProcessVideoProperties(sbIMediaFormatVideoMutable *aVideoFormat,
82  GstStructure *aStructure);
83  nsresult ProcessAudio(sbIMediaFormatAudio **aAudioFormat);
84  nsresult ProcessAudioProperties(sbIMediaFormatAudioMutable *aAudioFormat,
85  GstStructure *aStructure);
86  nsresult InspectorateElement (GstElement *element);
87 
88  void HandleStateChangeMessage(GstMessage *message);
89  void HandleErrorMessage(GstMessage *message);
90 
91  static void fakesink_audio_event_cb (GstPad *pad, GstEvent *event,
92  sbGStreamerMediaInspector *inspector);
93 
94  static void fakesink_video_event_cb (GstPad *pad, GstEvent *event,
95  sbGStreamerMediaInspector *inspector);
96 
97  static void decodebin_pad_added_cb (GstElement *element, GstPad *pad,
98  sbGStreamerMediaInspector *inspector);
99 
100  nsCOMPtr<sbIMediaFormatMutable> mMediaFormat;
101 
102  PRUint16 mStatus;
103  nsTArray<nsString> mErrorMessages;
104  nsCOMArray<sbIJobProgressListener> mProgressListeners;
105  nsCOMPtr<nsITimer> mTimeoutTimer;
106 
107  nsString mSourceURI;
108 
109  PRBool mFinished;
110  PRBool mIsPaused;
111  PRBool mTooComplexForCurrentImplementation;
112 
113  GstElement *mDecodeBin;
114  GstPad *mVideoSrc;
115  GstPad *mAudioSrc;
116 
117  GstPad *mAudioDecoderSink;
118  GstPad *mVideoDecoderSink;
119  GstPad *mDemuxerSink;
120  guint mAudioBitRate;
121  guint mVideoBitRate;
122 
123 };
124 
125 #define SB_GSTREAMER_MEDIAINSPECTOR_CLASSNAME \
126  "sbGStreamerMediaInspector"
127 #define SB_GSTREAMER_MEDIAINSPECTOR_DESCRIPTION \
128  "Songbird GStreamer Media Inspector"
129 // SB_MEDIAINSPECTOR_CONTRACTID is defined in sbIMediaInspector.idl/.h
130 #define SB_GSTREAMER_MEDIAINSPECTOR_CONTRACTID \
131  SB_MEDIAINSPECTOR_CONTRACTID
132 #define SB_GSTREAMER_MEDIAINSPECTOR_CID \
133  {0x200782a4, 0x07c6, 0x4ec7, {0xa3, 0x31, 0xb8, 0x88, 0x87, 0x36, 0x80, 0xa6}}
134 
135 #endif // _SB_GSTREAMER_MEDIAINSPECTOR_H_
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBIMEDIAINSPECTOR NS_DECL_SBIJOBPROGRESS NS_DECL_SBIJOBCANCELABLE NS_DECL_NSITIMERCALLBACK sbGStreamerMediaInspector()
Generic interface for exposing long running jobs to the UI.
var event
GstMessage * message
nsITimerCallback