sipxmedialib  Version 3.3
StreamFormatDecoder.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 
15 #ifndef _StreamFormatDecoder_h_
16 #define _StreamFormatDecoder_h_
17 
18 // SYSTEM INCLUDES
19 
20 // APPLICATION INCLUDES
21 #include <utl/UtlString.h>
22 
23 #include "mp/StreamDefs.h"
24 #include "os/OsStatus.h"
25 
26 // DEFINES
27 // MACROS
28 // EXTERNAL FUNCTIONS
29 // EXTERNAL VARIABLES
30 // CONSTANTS
31 // STRUCTS
32 // TYPEDEFS
33 typedef enum // Format Decoder Event
34 {
35  DecodingStartedEvent, // Started Decoding
36  DecodingUnderrunEvent, // Supply cannot meet demand
37  DecodingThrottledEvent, // Being throttled in frame generation
38  DecodingCompletedEvent, // Completed decoding
39  DecodingErrorEvent // Error while decoding
40 
42 
43 // FORWARD DECLARATIONS
45 class StreamDataSource;
46 
47 //:Define an abstract Stream Format Decoder. The Stream Format Decoder
48 //:pulls data from an abstract data source and decodes the data for playback
49 //:on an xpressa phone.
51 {
52 /* //////////////////////////// PUBLIC //////////////////////////////////// */
53 public:
54 
55 /* ============================ CREATORS ================================== */
57 
59  //:Constructs a decoder given a data source
60 
61  virtual ~StreamFormatDecoder();
62  //:Destructor
63 
65 
66 /* ============================ MANIPULATORS ============================== */
68 
69  virtual OsStatus init() = 0 ;
70  //:Initializes the decoder
71 
72  virtual OsStatus free() = 0 ;
73  //:Frees all resources consumed by the decoder
74 
75  virtual OsStatus begin() = 0 ;
76  //:Begins decoding
77 
78  virtual OsStatus end() = 0 ;
79  //:Ends decoding
80 
81  virtual OsStatus getFrame(unsigned short* pSamples) = 0 ;
82  //:Gets the next available frame.
84 
85  void setListener(StreamDecoderListener* pListener);
86  //:Sets a listener to receive StreamDecoderEvents.
87 
89 
90 /* ============================ ACCESSORS ================================= */
92 
93 
94  virtual OsStatus toString(UtlString& string) = 0 ;
95  //:Renders a string describing this decoder.
96  // This is often used for debugging purposes.
97 
99  //:Gets the the data source for this decoder
100 
102 
103 /* ============================ INQUIRY =================================== */
105 
106 
107  virtual UtlBoolean isDecoding() = 0 ;
108  //:Gets the decoding status. TRUE indicates decoding activity, false
109  //:indicates the decoder has completed.
110 
111  virtual UtlBoolean validDecoder() = 0 ;
112  //:Determines if this is a valid decoder given the associated data
113  //:source.
114  // The data source is "peeked" for data, so that the stream's
115  // data is not disturbed.
116 
117 /* ============================ TESTING =================================== */
118 
119 #ifdef MP_STREAM_DEBUG /* [ */
120 static const char* getEventString(StreamDecoderEvent event);
121 #endif /* MP_STREAM_DEBUG ] */
122 
123 
125 
126 /* //////////////////////////// PROTECTED ///////////////////////////////// */
127 protected:
128 
129  StreamFormatDecoder(const StreamFormatDecoder& rStreamFormatDecoder);
130  //:Copy constructor
131 
133  //:Assignment operator
134 
135  virtual void fireEvent(StreamDecoderEvent event);
136  //:Fire an event to an interested consumer.
137 
138 
139 /* //////////////////////////// PRIVATE /////////////////////////////////// */
140 private:
141  StreamDecoderListener *mpListener ; // Stream Decoder Listener
142  StreamDataSource* mpDataSource ; // Abstract Data Source
143 };
144 
145 /* ============================ INLINE METHODS ============================ */
146 
147 #endif // _StreamFormatDecoder_h_
Definition: StreamFormatDecoder.h:35
void setListener(StreamDecoderListener *pListener)
returns TRUE if a frame is available, otherwise false
Definition: StreamFormatDecoder.cpp:43
An abstraction definition of a stream data source.
Definition: StreamDataSource.h:47
virtual UtlBoolean isDecoding()=0
Definition: StreamFormatDecoder.h:39
virtual void fireEvent(StreamDecoderEvent event)
Definition: StreamFormatDecoder.cpp:108
virtual OsStatus end()=0
StreamDecoderEvent
Definition: StreamFormatDecoder.h:33
Definition: StreamDecoderListener.h:32
virtual ~StreamFormatDecoder()
Definition: StreamFormatDecoder.cpp:36
virtual OsStatus begin()=0
StreamDataSource * getDataSource()
Definition: StreamFormatDecoder.cpp:51
virtual OsStatus free()=0
virtual OsStatus toString(UtlString &string)=0
virtual OsStatus getFrame(unsigned short *pSamples)=0
virtual OsStatus init()=0
Definition: StreamFormatDecoder.h:36
StreamDecoderListener * mpListener
Definition: StreamFormatDecoder.h:141
StreamFormatDecoder(StreamDataSource *pDataSource)
Definition: StreamFormatDecoder.cpp:29
Definition: StreamFormatDecoder.h:50
StreamFormatDecoder & operator=(const StreamFormatDecoder &rhs)
Definition: StreamFormatDecoder.cpp:98
StreamDataSource * mpDataSource
Definition: StreamFormatDecoder.h:142
virtual UtlBoolean validDecoder()=0
Definition: StreamFormatDecoder.h:38
Definition: StreamFormatDecoder.h:37