/usr/include/sipxtapi/mp/MprDecode.h is in libsipxtapi-dev 3.3.0~test17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | //
// Copyright (C) 2006-2012 SIPez LLC. All rights reserved.
//
// Copyright (C) 2004-2008 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////
#ifndef _MprDecode_h_ /* [ */
#define _MprDecode_h_
// SYSTEM INCLUDES
// APPLICATION INCLUDES
#include "mp/MpMisc.h"
#include "mp/MpRtpBuf.h"
#include "mp/MpAudioResource.h"
#include "mp/MpFlowGraphMsg.h"
#include "mp/MpResourceMsg.h"
#include "mp/MpDecoderPayloadMap.h"
#include "mp/MpJitterBufferEstimation.h"
#include "sdp/SdpCodec.h"
#include "os/OsBSem.h"
// DEFINES
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
class MpDecoderBase;
class MprRecorder;
class MpJitterBuffer;
class MprDejitter;
class MpPlcBase;
/// The "Decode" media processing resource
class MprDecode : public MpAudioResource
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
static const UtlContainableType TYPE; ///< Class name, used for run-time checks.
/* ============================ CREATORS ================================== */
///@name Creators
//@{
/// Constructor
MprDecode(const UtlString &rName,
const UtlString &plcName = "");
/// Destructor
virtual
~MprDecode();
//@}
/* ============================ MANIPULATORS ============================== */
///@name Manipulators
//@{
/// Reset decoder to the initial state to be able process new stream.
static OsStatus reset(const UtlString& namedResource, OsMsgQ& fgQ);
/// Reset decoder to the initial state to be able process new stream.
virtual void reset();
/// Provide set of codecs this decode resource will be able to decode.
static OsStatus selectCodecs(const UtlString& namedResource,
OsMsgQ& fgQ,
SdpCodec* codecs[],
int numCodecs);
/// Clear set of codecs this resource is able to decode.
static OsStatus deselectCodecs(const UtlString& namedResource,
OsMsgQ& fgQ);
/// Change PLC algorithm to one with given name. THIS METHOD DOES NOT WORK!
static OsStatus setPlc(const UtlString& namedResource,
OsMsgQ& fgQ,
const UtlString& plcName = "");
/**<
* Sends an MPRM_SET_PLC message to the named MprDecode resource
* within the flowgraph who's queue is supplied. When the message
* is received, the above resource will change PLC algorithm to
* chosen one.
*
* @param[in] namedResource - the name of the resource to send a message to.
* @param[in] fgQ - the queue of the flowgraph containing the resource which
* the message is to be received by.
* @param[in] plcName - name of PLC algorithm to use.
* See MpJitterBuffer::setPlc() for more details.
* @returns the result of attempting to queue the message to this resource.
*/
/// Pair this decode resource with the dejitter resource.
void setMyDejitter(MprDejitter* newDJ, UtlBoolean ownDj);
/**<
* If \p ownDj is TRUE, then dejitter instance will be freed in
* the destructor of this decoder.
*/
/// @copy_doc MpResource::pushBuffer
virtual OsStatus pushBuffer(int inputPort, MpBufPtr& inputBuffer);
/// Add incoming RTP packet to the decoding queue
OsStatus pushPacket(MpRtpBufPtr &pRtp);
/**<
* @warning This method swaps \p pRtp with some other packet in the dejitter
* buffer. So you should dispose \p pRtp pointer asap after calling
* this method.
*
* @return OS_SUCCESS on success
* @return OS_LIMIT_REACHED if too many codecs used in incoming RTP packets
*/
/// @copydoc MpResource::setConnectionId()
void setConnectionId(MpConnectionID connectionId);
/// @copydoc MpResource::setStreamId()
void setStreamId(int connectionId);
//@}
/* ============================ ACCESSORS ================================= */
///@name Accessors
//@{
/// @copydoc UtlContainable::getContainableType()
UtlContainableType getContainableType() const;
/// @copydoc MpResource::getCurrentLatency()
virtual OsStatus getCurrentLatency(int &latency, int input=0, int output=0) const;
//@}
/* ============================ INQUIRY =================================== */
///@name Inquiry
//@{
//@}
/* //////////////////////////// PROTECTED ///////////////////////////////// */
protected:
/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
typedef enum
{
MPRM_SET_PLC = MpResourceMsg::MPRM_EXTERNAL_MESSAGE_START,
MPRM_DESELCT_CODECS,
MPRM_RESET
} AddlResMsgTypes;
MpJitterBuffer* mpJB; ///< Pointer to JitterBuffer instance
UtlBoolean mIsJBInitialized; ///< Is JB initialized or not?
MprDejitter* mpMyDJ; ///< Dejitter instance, used by this decoder.
UtlBoolean mOwnDJ; ///< Is dejitter owned by this decoder?
UtlBoolean mIsStreamInitialized; ///< Have we received at least one packet?
struct StreamState
{
unsigned sampleRate; ///< Sample rate of this stream.
UtlBoolean isFirstRtpPulled; ///< Have we got first packet from JB queue?
RtpSeq rtpStreamSeq; ///< Current sequence number of RTP stream.
RtpTimestamp rtpStreamPosition; ///< Current pulling JB position (in RTP timestamp units).
int32_t rtpStreamHint; ///< Recommended playback position (in RTP timestamp units).
uint32_t playbackStreamPosition; ///< Current playback position (in RTP timestamp units).
unsigned playbackFrameSize; ///< Stream frame size of this stream (in RTP timestamp units).
uint8_t rtpPayloadType; ///< Current RTP payload type.
uint32_t dejitterLength; ///< Difference between newest received RTP packet's
///< timestamp and latest pulled packet's timestamp.
} mStreamState;
RtpSeq mLastPulledSeq; ///< Sequence number of last pulled packet
MpJitterBufferEstimation *mpJbEstimationState; ///< State of JB delay estimation.
/// List of the codecs to be used to decode media.
/**
* Pointer to array of length mNumCurrentCodecs of MpDecoderBase*'s
* which represent the codecs, or NULL if mNumCurrentCodecs == 0.
*/
MpDecoderBase** mpCurrentCodecs;
int mNumCurrentCodecs; ///< Length of mpCurrentCodecs array.
UtlBoolean mEnableG722Hack; ///< Should we cheat with RTP clock rate in case
///< G.722 is selected. According to section 4.5.2
///< of RFC 3551 we should use 8K RTP clock rate
///< instead of 16K for G.722 because of historical
///< error in RFC 1890.
int mG722HackPayloadType; ///< RTP payload type to which we should apply
///< G.722 RTP clock rate workaround. Set to -1
///< if workaround is not enabled.
///< See mEnableG722Hack for better description.
/// Similar list of all codecs that have ever been listed on mpCurrentCodecs.
MpDecoderBase** mpPrevCodecs;
int mNumPrevCodecs; ///< Length of mpPrevCodecs array.
MpDecoderPayloadMap mDecoderMap; ///< Mapping of payload types to decoder instances.
virtual UtlBoolean doProcessFrame(MpBufPtr inBufs[],
MpBufPtr outBufs[],
int inBufsSize,
int outBufsSize,
UtlBoolean isEnabled,
int samplesPerFrame,
int samplesPerSecond);
/// Decode RTP packet if it belongs to signaling codec.
UtlBoolean tryDecodeAsSignalling(const MpRtpBufPtr &rtp);
/**<
* @retval TRUE - packet was decoded as signaling
* @retval FALSE - packet is not signaling
*/
/// @copydoc MpResource::setFlowGraph()
OsStatus setFlowGraph(MpFlowGraphBase* pFlowGraph);
/// Handle new style messages for this resource.
virtual UtlBoolean handleMessage(MpResourceMsg& rMsg);
/// Replace mpCurrentCodecs with pCodecs.
UtlBoolean handleSelectCodecs(SdpCodec* pCodecs[], int numCodecs);
/**<
* Copy the codecs in mpCurrentCodecs onto mpPrevCodecs and deletes pCodecs.
*/
/// @brief Remove all codecs from mpCurrentCodecs, transferring them to
/// mpPrevCodecs.
UtlBoolean handleDeselectCodecs(UtlBoolean shouldLock = TRUE);
/// Remove one codec from mpConnection's payload type decoder table.
UtlBoolean handleDeselectCodec(MpDecoderBase* pDecoder);
/**<
* @note Caller must hold mLock.
*/
/// Change PLC algorithm to one provided.
UtlBoolean handleSetPlc(const UtlString &plcName);
/// Handle MPRM_RESET message.
UtlBoolean handleReset();
/// @copydoc MpResource::handleDisable()
UtlBoolean handleDisable();
/// Delete the array of previously used codecs
void deletePriorCodecs();
/// Copy constructor (not implemented for this class)
MprDecode(const MprDecode& rMprDecode);
/// Assignment operator (not implemented for this class)
MprDecode& operator=(const MprDecode& rhs);
};
/* ============================ INLINE METHODS ============================ */
#endif /* _MprDecode_h_ ] */
|