sipxmedialib  Version 3.3
StreamWAVFormatDecoder.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 _StreamWAVFormatDecoder_h_
17 #define _StreamWAVFormatDecoder_h_
18 
19 // SYSTEM INCLUDES
20 // APPLICATION INCLUDES
22 #include "os/OsDefs.h"
23 #include "os/OsStatus.h"
24 #include "os/OsTask.h"
25 #include "os/OsBSem.h"
26 
27 // DEFINES
28 // MACROS
29 // EXTERNAL FUNCTIONS
30 // EXTERNAL VARIABLES
31 // CONSTANTS
32 // STRUCTS
33 struct WAVChunkID
34 {
35  char ckID[4]; // chunk id 'RIFF'
36  unsigned long ckSize; // chunk size
37 };
38 
40 {
41  unsigned short formatTag; // format tag currently pcm
42  unsigned short nChannels; // number of channels
43  unsigned long nSamplesPerSec; // sample rate in hz
44  unsigned long nAvgBytesPerSec; // average bytes per second
45  unsigned short nBlockAlign; // number of bytes per sample
46  unsigned short nBitsPerSample; // number of bits in a sample
47 };
48 
49 
50 // TYPEDEFS
51 // FORWARD DECLARATIONS
52 
53 //:A WAV format Decoder
55 {
56 /* //////////////////////////// PUBLIC //////////////////////////////////// */
57 public:
58 
59 /* ============================ CREATORS ================================== */
61 
63  //:Default constructor
64 
65  virtual
67  //:Destructor
68 
70 
71 /* ============================ MANIPULATORS ============================== */
73 
74  virtual OsStatus init();
75  //:Initializes the decoder
76 
77  virtual OsStatus free();
78  //:Frees all resources consumed by the decoder
79 
80  virtual OsStatus begin();
81  //:Begins decoding
82 
83  virtual OsStatus end();
84  //:Ends decoding
85 
87 
88 /* ============================ ACCESSORS ================================= */
90 
91 
92  virtual OsStatus toString(UtlString& string);
93  //:Renders a string describing this decoder.
94  // This is often used for debugging purposes.
95 
97 
98 /* ============================ INQUIRY =================================== */
100 
101 
102  virtual UtlBoolean isDecoding();
103  //:Gets the decoding status. TRUE indicates decoding activity, false
104  //:indicates the decoder has completed.
105 
106  virtual UtlBoolean validDecoder();
107  //:Determines if this is a valid decoder given the associated data
108  //:source.
109  // The data source is "peeked" for data, so that the stream's
110  // data is not disturbed.
111 
113 
114 /* //////////////////////////// PROTECTED ///////////////////////////////// */
115 protected:
116 
117  StreamWAVFormatDecoder(const StreamWAVFormatDecoder& rStreamWAVFormatDecoder);
118  //:Copy constructor (not supported)
119 
120  StreamWAVFormatDecoder& operator=(const StreamWAVFormatDecoder& rhs);
121  //:Assignment operator (not supported)
122 
123  int run(void* pArgs);
124  //:Thread entry point
125 
126  UtlBoolean nextDataChunk(int& iLength);
127  //:Advances the mCurrentChunk to the next data chunk within the stream
128 
129 /* //////////////////////////// PRIVATE /////////////////////////////////// */
130 private:
131  UtlBoolean mbEnd ; // Has the decoder completed?
132  OsBSem mSemExited ; // Have we successfully exited?
133  struct FORMATChunkInfo mFormatChunk ;
134 };
135 
136 /* ============================ INLINE METHODS ============================ */
137 
138 #endif // _StreamWAVFormatDecoder_h_
139 
140 #endif // DISABLE_STREAM_PLAYER ]
An abstraction definition of a stream data source.
Definition: StreamDataSource.h:47
unsigned short nChannels
Definition: StreamWAVFormatDecoder.h:42
Definition: StreamWAVFormatDecoder.h:39
Definition: StreamQueueingFormatDecoder.h:41
OsBSem mSemExited
Definition: StreamWAVFormatDecoder.h:132
unsigned short nBlockAlign
Definition: StreamWAVFormatDecoder.h:45
Definition: StreamWAVFormatDecoder.h:33
unsigned long ckSize
Definition: StreamWAVFormatDecoder.h:36
unsigned long nSamplesPerSec
Definition: StreamWAVFormatDecoder.h:43
char ckID[4]
Definition: StreamWAVFormatDecoder.h:35
unsigned long nAvgBytesPerSec
Definition: StreamWAVFormatDecoder.h:44
UtlBoolean mbEnd
Definition: StreamWAVFormatDecoder.h:131
unsigned short formatTag
Definition: StreamWAVFormatDecoder.h:41
unsigned short nBitsPerSample
Definition: StreamWAVFormatDecoder.h:46
Definition: StreamWAVFormatDecoder.h:54