sipxmedialib  Version 3.3
StreamQueueingFormatDecoder.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 _StreamQueueingFormatDecoder_h_
16 #define _StreamQueueingFormatDecoder_h_
17 
18 // SYSTEM INCLUDES
19 #include "time.h"
20 
21 // APPLICATION INCLUDES
22 #include "mp/StreamFormatDecoder.h"
23 #include "os/OsDefs.h"
24 #include "os/OsMsgPool.h"
25 #include "os/OsMsgQ.h"
26 #include "os/OsStatus.h"
27 #include "os/OsMutex.h"
28 
29 // DEFINES
30 // MACROS
31 // EXTERNAL FUNCTIONS
32 // EXTERNAL VARIABLES
33 // CONSTANTS
34 // STRUCTS
35 // TYPEDEFS
36 // FORWARD DECLARATIONS
37 
38 //:The Stream Queueing Format Decoder builds upon the abstract
39 //:StreamFormatDecoder by adding a mechanism to queue a max number
40 //:of rendered frames.
42 {
43 /* //////////////////////////// PUBLIC //////////////////////////////////// */
44 public:
45 
46 /* ============================ CREATORS ================================== */
48 
50  int iQueueLength);
51  //:Constructs a queueing format decoder given a data source and queue
52  //:length
53 
54  virtual
56  //:Destructor
57 
59 
60 /* ============================ MANIPULATORS ============================== */
62 
63  virtual OsStatus getFrame(unsigned short* samples);
64  //: Gets the next available frame
66 
67  virtual OsStatus queueFrame(const unsigned short* pSamples);
68  //: Queues a frame of data
69 
70  virtual OsStatus queueEndOfFrames();
71  //: Queues an end of frame marker. This informs MprFromStream that the
72  //: Stream has ended.
73 
74  virtual OsStatus drain();
75  //: Drains any queued frames
76 
78 
79 /* ============================ ACCESSORS ================================= */
81 
82 
83  int getMaxQueueLength() ;
84  //: Gets the maximum number of frames that can be queued before the
85  //: queueing routines will block.
86 
87  int getNumQueuedFrames() ;
88  //: Gets the current number of queued frames.
89 
91 
92 /* ============================ INQUIRY =================================== */
94 
95 
97 
98 /* //////////////////////////// PROTECTED ///////////////////////////////// */
99 protected:
100 
101  StreamQueueingFormatDecoder(const StreamQueueingFormatDecoder& rStreamQueueingFormatDecoder);
102  //:Copy constructor (not supported)
103 
105  //:Assignment operator (not supported)
106 
107 /* //////////////////////////// PRIVATE /////////////////////////////////// */
108 private:
109  OsMsgQ mMsgqFrames ; // Queue of frames
110  OsMsgPool mMsgPool; // Pool for msg containers
111  int miMaxQueueLength ; // Max size of the queue length
112  UtlBoolean mbReportThrottle ; // Should this report throttles?
113  UtlBoolean mbDraining ;
114 
115  static OsMutex mMutReport ;// Thread safety for performance monitoring
116 
117  static time_t sLastReported ; // When we last reported status
118 
119  static unsigned int sDeltaFrames ; // Frames since last report
120  static unsigned int sDeltaStreams ; // Streams since last report
121  static unsigned int sDeltaUnderruns ;// Underruns since last report
122  static unsigned int sDeltaThrottles ;// Throttles since last report
123 
124  static unsigned int sTotalFrames ; // Cumulative number of frames
125  static unsigned int sTotalStreams ; // Cumulative number of streams
126  static unsigned int sTotalUnderruns ;// Cumulative number of underruns
127  static unsigned int sTotalThrottles ;// Cumulative number of throttles
128 
129  static void reportFrame(UtlBoolean bUnderrun) ;
130  //:Reports that a frame has been processed by media processing.
131 
132  static void reportThrottle() ;
133  //: Reports that the decoder has been throttled (decoding faster
134  //: then data is being requested).
135 
136  static void reportStream() ;
137  //:Reports that a stream has been created
138 };
139 
140 /* ============================ INLINE METHODS ============================ */
141 
142 #endif // _StreamQueueingFormatDecoder_h_
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
static void reportStream()
Definition: StreamQueueingFormatDecoder.cpp:302
An abstraction definition of a stream data source.
Definition: StreamDataSource.h:47
StreamQueueingFormatDecoder(StreamDataSource *pDataSource, int iQueueLength)
Definition: StreamQueueingFormatDecoder.cpp:50
int getMaxQueueLength()
Definition: StreamQueueingFormatDecoder.cpp:196
static unsigned int sTotalStreams
Definition: StreamQueueingFormatDecoder.h:125
virtual ~StreamQueueingFormatDecoder()
Definition: StreamQueueingFormatDecoder.cpp:66
virtual OsStatus getFrame(unsigned short *samples)
Definition: StreamQueueingFormatDecoder.cpp:73
virtual OsStatus queueFrame(const unsigned short *pSamples)
returns OS_SUCCESS if a frame is available
Definition: StreamQueueingFormatDecoder.cpp:119
UtlBoolean mbReportThrottle
Definition: StreamQueueingFormatDecoder.h:112
static unsigned int sDeltaUnderruns
Definition: StreamQueueingFormatDecoder.h:121
static void reportFrame(UtlBoolean bUnderrun)
Definition: StreamQueueingFormatDecoder.cpp:237
static OsMutex mMutReport
Definition: StreamQueueingFormatDecoder.h:115
virtual OsStatus queueEndOfFrames()
Definition: StreamQueueingFormatDecoder.cpp:156
OsMsgPool mMsgPool
Definition: StreamQueueingFormatDecoder.h:110
static unsigned int sTotalUnderruns
Definition: StreamQueueingFormatDecoder.h:126
Definition: StreamQueueingFormatDecoder.h:41
UtlBoolean mbDraining
Definition: StreamQueueingFormatDecoder.h:113
static unsigned int sDeltaStreams
Definition: StreamQueueingFormatDecoder.h:120
static unsigned int sDeltaFrames
Definition: StreamQueueingFormatDecoder.h:119
static unsigned int sDeltaThrottles
Definition: StreamQueueingFormatDecoder.h:122
int miMaxQueueLength
Definition: StreamQueueingFormatDecoder.h:111
static unsigned int sTotalThrottles
Definition: StreamQueueingFormatDecoder.h:127
OsMsgQ mMsgqFrames
Definition: StreamQueueingFormatDecoder.h:109
int getNumQueuedFrames()
Definition: StreamQueueingFormatDecoder.cpp:202
Definition: StreamFormatDecoder.h:50
static void reportThrottle()
Definition: StreamQueueingFormatDecoder.cpp:294
StreamQueueingFormatDecoder & operator=(const StreamQueueingFormatDecoder &rhs)
Definition: StreamQueueingFormatDecoder.cpp:223
virtual OsStatus drain()
Definition: StreamQueueingFormatDecoder.cpp:176
static unsigned int sTotalFrames
Definition: StreamQueueingFormatDecoder.h:124
static time_t sLastReported
Definition: StreamQueueingFormatDecoder.h:117