sipxmedialib  Version 3.3
MpStreamFeeder.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 #ifndef DISABLE_STREAM_PLAYER // [
15 
16 #ifndef _MpStreamFeeder_h_
17 #define _MpStreamFeeder_h_
18 
19 // SYSTEM INCLUDES
20 
21 // APPLICATION INCLUDES
22 #include "os/OsDefs.h"
23 #include "os/OsTask.h"
24 #include "os/OsCSem.h"
25 #include "os/OsMsgQ.h"
26 #include "os/OsMutex.h"
27 #include "net/Url.h"
28 #include "mp/StreamDefs.h"
31 
32 // DEFINES
33 #define INCL_RAW_DECODER // Include the RAW decoder
34 #define INCL_WAV_DECODER // Include the WAV decoder
35 // #define INCL_MP3_DECODER // Include the MP3 decoder
36 
37 
38 // MACROS
39 // EXTERNAL FUNCTIONS
40 // CONSTANTS
41 // STRUCTS
42 // TYPEDEFS
43 
44 //: Feeder states (match player states for the most part, but add a
45 //: realizing and rendering states)
46 typedef enum
47 {
55 
56 } FeederState ;
57 
58 // FORWARD DECLARATIONS
59 class StreamFormatDecoder ;
60 class StreamDataSource ;
61 class OsNotification ;
62 
66 
91 {
92 /* //////////////////////////// PUBLIC //////////////////////////////////// */
93 public:
94 
95 /* ============================ CREATORS ================================== */
97 
98  MpStreamFeeder(Url resource, int flags);
100 
102  MpStreamFeeder(UtlString* pBuffer, int flags);
103 
105  virtual ~MpStreamFeeder();
111 /* ============================ MANIPULATORS ============================== */
112 
115  OsStatus realize() ;
116 
118  OsStatus render() ;
124  OsStatus rewind() ;
126  // This may result in re-prefetching data in cases.
127 
128  OsStatus stop();
130 
132  OsStatus setEventHandler(OsNotification* pEventHandler) ;
135  void markPaused(UtlBoolean bPaused) ;
138 
140 
141 /* ============================ ACCESSORS ================================= */
143 
144 
146  OsStatus getFrame(unsigned short *samples) ;
147 
149  UtlBoolean isMarkedPaused() ;
150 
152  OsStatus getFlags(int &flags) ;
153 
156 
158  void fromStreamUpdate(FeederEvent event) ;
159 
161 
162 /* ============================ INQUIRY =================================== */
164 
165 
167  UtlBoolean isValidStateChange(FeederState source, FeederState target) ;
168 
169 /* ============================ TESTING =================================== */
170 
171 #ifdef MP_STREAM_DEBUG /* [ */
172 static const char* getEventString(FeederEvent event);
173 #endif /* MP_STREAM_DEBUG ] */
174 
176 
177 /* //////////////////////////// PROTECTED ///////////////////////////////// */
178 protected:
180  void fireEvent(FeederEvent eventType) ;
181 
183  void setState(FeederState state);
184 
186  virtual void decoderUpdate(StreamFormatDecoder* pDecoder, StreamDecoderEvent event) ;
187 
189  virtual void dataSourceUpdate(StreamDataSource* pDataSource, StreamDataSourceEvent event) ;
190 
191 #ifdef MP_STREAM_DEBUG /* [ */
192  const char* getDataSourceEventString(StreamDataSourceEvent);
193  const char* getDecoderEventString(StreamDecoderEvent);
194  const char* getFeederEventString(FeederEvent event);
195 #endif /* MP_STREAM_DEBUG ] */
196 
197 
198 /* //////////////////////////// PRIVATE /////////////////////////////////// */
199 private:
200  static int s_iInstanceCount ;
201 
205  int mFlags ;
206 
207  UtlBoolean m_bMarkedPaused;
208  OsNotification* m_pEventHandler;
210  OsMutex m_eventGuard;
211 
213 
215  void initDecodingSource() ;
216 
217 };
218 
219 /* ============================ INLINE METHODS ============================ */
220 
221 #endif // _MpStreamFeeder_h_
222 
223 #endif // DISABLE_STREAM_PLAYER ]
static int s_iInstanceCount
Definition: MpStreamFeeder.h:200
virtual void dataSourceUpdate(StreamDataSource *pDataSource, StreamDataSourceEvent event)
Call back for data source updates.
Definition: MpStreamFeeder.cpp:492
UtlBoolean isValidStateChange(FeederState source, FeederState target)
Is the transition from state source to target valid?
Definition: MpStreamFeeder.cpp:321
An abstraction definition of a stream data source.
Definition: StreamDataSource.h:47
OsMutex m_eventGuard
Definition: MpStreamFeeder.h:210
StreamDataSourceEvent
Definition: StreamDataSource.h:31
void markPaused(UtlBoolean bPaused)
Definition: MpStreamFeeder.cpp:258
Definition: MpStreamFeeder.h:53
OsStatus getFrame(unsigned short *samples)
Get a frames worth of data (80 samples per frame) ;.
Definition: MpStreamFeeder.cpp:283
virtual void decoderUpdate(StreamFormatDecoder *pDecoder, StreamDecoderEvent event)
Call back for decoder updates.
Definition: MpStreamFeeder.cpp:517
OsStatus setEventHandler(OsNotification *pEventHandler)
Stop collecting/rendering data.
Definition: MpStreamFeeder.cpp:265
UtlBoolean m_bMarkedPaused
Is this marked as paused?
Definition: MpStreamFeeder.h:207
Definition: MpStreamFeeder.h:52
FeederState getState()
Query the state for this renderer.
Definition: MpStreamFeeder.cpp:312
void setState(FeederState state)
Sets the internal renderer state.
Definition: MpStreamFeeder.cpp:460
StreamDecoderEvent
Definition: StreamFormatDecoder.h:33
Definition: StreamDecoderListener.h:32
OsStatus realize()
Initiates the connection with the outbound party to validate the connection. Buffers are allocated at...
Definition: MpStreamFeeder.cpp:126
StreamFormatDecoder * m_pFormatDecoder
Decoder.
Definition: MpStreamFeeder.h:203
StreamDataSource * m_pDataSource
Data Source.
Definition: MpStreamFeeder.h:204
The MpStreamFeed coordinates with the data source and decoder to ready the input stream and then plug...
Definition: MpStreamFeeder.h:90
int m_iInstanceId
Definition: MpStreamFeeder.h:209
void fromStreamUpdate(FeederEvent event)
Called by the MprFromStream resource when events changes.
Definition: MpStreamFeeder.cpp:510
Definition: StreamDataSourceListener.h:32
OsStatus stop()
Definition: MpStreamFeeder.cpp:235
OsStatus getFlags(int &flags)
Get the flags for this renderer.
Definition: MpStreamFeeder.cpp:304
OsStatus rewind()
Rewind the data source to the prefetched state.
Definition: MpStreamFeeder.cpp:205
Definition: StreamFormatDecoder.h:50
int mFlags
Flags given at creation.
Definition: MpStreamFeeder.h:205
OsNotification * m_pEventHandler
Event sink.
Definition: MpStreamFeeder.h:208
Definition: MpStreamFeeder.h:49
void fireEvent(FeederEvent eventType)
Fires renderer event to interested consumers.
Definition: MpStreamFeeder.cpp:383
Definition: MpStreamFeeder.h:51
OsStatus render()
Begin downloading and decoding data.
Definition: MpStreamFeeder.cpp:176
virtual ~MpStreamFeeder()
Destructor.
Definition: MpStreamFeeder.cpp:425
FeederState m_state
State of the Feeder.
Definition: MpStreamFeeder.h:202
Definition: MpStreamFeeder.h:54
void initDecodingSource()
Construction helper: initialize the decoding source.
Definition: MpStreamFeeder.cpp:549
FeederState
Definition: MpStreamFeeder.h:46
MpStreamFeeder(Url resource, int flags)
Constructor accepting a url resource, type, and cache all flag.
Definition: MpStreamFeeder.cpp:58
Definition: MpStreamFeeder.h:50
FeederEvent
Definition: StreamDefs.h:44
UtlBoolean isMarkedPaused()
Has the rendered been marked as paused?
Definition: MpStreamFeeder.cpp:297
Definition: MpStreamFeeder.h:48