25 #ifndef _SB_GSTREAMER_AUDIO_PROCESSOR_H_
26 #define _SB_GSTREAMER_AUDIO_PROCESSOR_H_
29 #include <nsCOMArray.h>
31 #include <nsIClassInfo.h>
34 #include <gst/app/gstappsink.h>
35 #include <gst/base/gstadapter.h>
37 #include <sbIMediaItem.h>
38 #include <sbIMediacoreAudioProcessor.h>
39 #include <sbIMediacoreAudioProcessorListener.h>
49 NS_DECL_SBIMEDIACOREAUDIOPROCESSOR
54 virtual ~sbGStreamerAudioProcessor();
56 virtual nsresult BuildPipeline();
58 virtual void HandleMessage(GstMessage *
message);
60 virtual nsresult OnDestroyPipeline(GstElement *pipeline);
63 nsresult DecoderPadAdded (GstElement *uridecodebin, GstPad *pad);
64 nsresult DecoderNoMorePads (GstElement *uridecodebin);
65 nsresult AppsinkNewBuffer(GstElement *appsink);
66 nsresult AppsinkEOS(GstElement *appsink);
69 static void decodebin_pad_added_cb (GstElement *
element, GstPad *pad,
70 sbGStreamerAudioProcessor *processor);
71 static void decodebin_no_more_pads_cb (GstElement *element,
72 sbGStreamerAudioProcessor *processor);
73 static void appsink_new_buffer_cb (GstElement *element,
74 sbGStreamerAudioProcessor *processor);
75 static void appsink_eos_cb (GstElement *element,
76 sbGStreamerAudioProcessor *processor);
82 nsresult ConfigureInitialCapsfilter(GstElement *capsfilter);
86 nsresult ReconfigureCapsfilter();
90 nsresult SendEventAsync(PRUint32 eventType, nsIVariant *eventDetails);
93 nsresult SendEventSync(PRUint32 eventType, nsIVariant *eventDetails);
96 nsresult SendEventInternal(PRUint32 eventType,
97 nsCOMPtr<nsIVariant> eventDetails);
101 nsresult SendErrorEvent(PRUint32 errorCode,
const char *errorName);
107 nsresult ScheduleSendDataIfAvailable();
110 PRBool HasEnoughData();
117 nsresult ScheduleSendData();
122 void SendDataToListener();
125 PRUint32 GetDurationFromBuffer(GstBuffer *buf);
128 PRUint64 GetSampleNumberFromBuffer(GstBuffer *buf);
132 nsresult DoStreamStart();
135 nsresult DetermineFormat();
138 nsCOMPtr<sbIMediacoreAudioProcessorListener> mListener;
141 PRUint32 mConstraintChannelCount;
142 PRUint32 mConstraintSampleRate;
143 PRUint32 mConstraintAudioFormat;
144 PRUint32 mConstraintBlockSize;
148 PRUint32 mConstraintBlockSizeBytes;
151 nsCOMPtr<sbIMediaItem> mMediaItem;
159 GstAdapter *mAdapter;
162 GstAppSink *mAppSink;
166 GstElement *mCapsFilter;
174 PRBool mFoundAudioPad;
189 PRBool mIsEndOfSection;
193 PRBool mHasSentError;
201 PRUint64 mSampleNumber;
206 PRUint64 mExpectedNextSampleNumber;
210 PRUint32 mAudioFormat;
222 PRUint32 mBuffersAvailable;
228 GstBuffer *mPendingBuffer;
232 #define SB_GSTREAMER_AUDIO_PROCESSOR_CLASSNAME \
233 "sbGStreamerAudioProcessor"
234 #define SB_GSTREAMER_AUDIO_PROCESSOR_DESCRIPTION \
235 "Songbird GStreamer Audio Processing API Implementation"
236 #define SB_GSTREAMER_AUDIO_PROCESSOR_CONTRACTID \
237 "@songbirdnest.com/Songbird/Mediacore/GStreamer/AudioProcessor;1"
238 #define SB_GSTREAMER_AUDIO_PROCESSOR_CID \
239 {0x490fef6b, 0xfed9, 0x4243, {0xa2, 0x80, 0x6b, 0xb1, 0x8a, 0x28, 0x3d, 0xfa}}
241 #endif // _SB_GSTREAMER_AUDIO_PROCESSOR_H_
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBIMEDIACOREAUDIOPROCESSOR sbGStreamerAudioProcessor()