/usr/include/sipxtapi/mp/MpStreamQueuePlayer.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 | //
// Copyright (C) 2006 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2004-2006 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 _MpStreamQueuePlayer_h_
#define _MpStreamQueuePlayer_h_
#ifndef DISABLE_STREAM_PLAYER // [
// SYSTEM INCLUDES
// APPLICATION INCLUDES
#include "mp/MpPlayer.h"
#include "mp/MpPlayerListener.h"
#include "mp/StreamDefs.h"
#include "net/Url.h"
#include "os/OsBSem.h"
#include "os/OsDefs.h"
#include "os/OsMsgQ.h"
#include "os/OsServerTask.h"
#include "os/OsStatus.h"
#include "os/OsRWMutex.h"
#include "os/OsQueuedEvent.h"
// DEFINES
#define DEFAULT_QUEUE_LENGTH 64 // Default length of queue
#define EXPAND_QUEUE_LENGTH 16 // Queue grows by this much
// Player impotence- If define, the queue player doesn't actually do
// anything, however, will still fire off events, etc.
#undef PLAYER_STUBS
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
class UtlString ;
class MpStreamPlayer ;
class MpQueuePlayerListener ;
//:Class short description which may consist of multiple lines (note the ':')
// Class detailed description which may extend to multiple lines
class MpStreamQueuePlayer : public OsServerTask, protected MpPlayerListener
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
typedef enum
{
SourceUrl,
SourceBuffer
} SourceType;
/* ============================ CREATORS ================================== */
///@name Creators
//@{
MpStreamQueuePlayer(OsMsgQ* pMsgQ, const char* pTarget = NULL);
//:Constructor accepting a msgQ
virtual
~MpStreamQueuePlayer();
//:Destructor
//@}
/* ============================ MANIPULATORS ============================== */
///@name Manipulators
//@{
virtual OsStatus add(Url& url, int flags) ;
//:Queues a URL for playing
//
//!param url - Url identifing the source data stream
//!param flags - Playing flags (see StreamDefs.h)
virtual OsStatus add(UtlString* pBuffer, int flags) ;
//:Queues a UtlString for playing
//
//!param pBuffer - Net Buffer containing buffered audio data. The
// MpStreamPlayer resource will delete the pBuffer upon destruction
// of itself.
//!param flags - Playing flags (see StreamDefs.h)
virtual OsStatus play() ;
//:Begins playing any queued streams
virtual OsStatus reset() ;
//: Resets the queue player state by stopping and removing all
//: playing entries.
virtual OsStatus destroy() ;
//: Marks the player as destroy and frees all allocated resources
// in media processing.
virtual OsStatus clear() ;
//: Clears any queued entries that have not yet been scheduled for play.
// These entries include streams added after invoking "play()".
virtual OsStatus wait(const OsTime& rTimeout = OsTime::OS_INFINITY) ;
//: Wait until all play list items are finished playing
OsStatus addListener(MpQueuePlayerListener* pListener) ;
//:Adds a player listener to receive notifications when this player
//:changes state
OsStatus removeListener(MpQueuePlayerListener* pListener) ;
//:Removes a previously added player listener. This listener will
// cease to receive state change notifications.
//@}
/* ============================ ACCESSORS ================================= */
///@name Accessors
//@{
//@}
/* ============================ INQUIRY =================================== */
///@name Inquiry
//@{
UtlBoolean isPlaying() ;
//:Is the Queue player playing (or about to play)
//@}
/* //////////////////////////// PROTECTED ///////////////////////////////// */
protected:
MpStreamQueuePlayer(const MpStreamQueuePlayer& rMpStreamQueuePlayer);
//:Copy constructor
MpStreamQueuePlayer& operator=(const MpStreamQueuePlayer& rhs);
//:Assignment operator
virtual UtlBoolean handleMessage(OsMsg& rMsg) ;
//:Handles an incoming message
// If the message is not one that the object is prepared to process,
// the handleMessage() method in the derived class should return FALSE
// which will cause the OsMessageTask::handleMessage() method to be
// invoked on the message.
void handleReset() ;
void handlePlayNext() ;
void handleDequeue() ;
void handleRemoveFailed() ;
UtlBoolean isPlayingStream(MpPlayer* pPlayer) ;
//:Is the specified player the active/playing stream?
void setFailedPlayer(MpPlayer* pPlayer) ;
//:Designates the the player as failed
virtual void playerRealized(MpPlayerEvent& event) ;
//: The player has been realized
virtual void playerPrefetched(MpPlayerEvent& event) ;
//: The player's data source has been prefetched
virtual void playerPlaying(MpPlayerEvent& event) ;
//: The player has begun playing.
virtual void playerPaused(MpPlayerEvent& event) ;
//: The player has been paused
virtual void playerStopped(MpPlayerEvent& event) ;
//: The player has been stopped
virtual void playerFailed(MpPlayerEvent& event) ;
//: The player has failed
void fireQueuePlayerStarted() ;
void fireQueuePlayerStopped() ;
void fireQueuePlayerAdvanced() ;
/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
enum
{
EVENT_DEQUEUE,
EVENT_PLAY_NEXT,
EVENT_REMOVE_FAILED,
EVENT_PLAY_RESET
} ;
struct PlaylistQueue // Definition for a playlist entry
{
MpStreamPlayer* pPlayer ;
UtlBoolean bFailed ;
} ;
OsMsgQ* mpMsgQ ; // Queue to deliever MpStreamMsg commands
UtlString mTarget ; // Target Id (CallId)
OsBSem mSemQueueChange; // Guard for queue changes
OsBSem mSemWaitSynch; // Gives some for block on for waiters
OsQueuedEvent* mpQueueEvent; // Used for dequeuing
struct PlaylistQueue* mToPlayQueue; // db of entries
int mToPlayQueueLength ; // Physical size of queue
int mNumToPlayElements ; // Current number of queued elements
struct PlaylistQueue* mPlayingQueue; // db of entries
int mPlayingQueueLength ;
int mNumPlayingElements ; // Current number of queued elements
UtlBoolean mbFatalError ; // Something REALLY bad has happened (can't create thread)
int expandQueue(struct PlaylistQueue*& queue, int currentLength, int desiredLength) ;
void swapQueues(struct PlaylistQueue*& queue1, int& queueLength1,
struct PlaylistQueue*& queue2, int& queueLength2) ;
struct PlayerListenerDb // Data structure used to maintain listeners
{
UtlBoolean inUse ; // Is the entry in use?
MpQueuePlayerListener* pListener ; // Reference to listener
} ;
PlayerListenerDb mListenerDb[MAX_PLAYER_LISTENERS] ; // DB of listeners
OsRWMutex mListenerMutex; // Used to make it thread-safe when adding/removing and using listeners
};
/* ============================ INLINE METHODS ============================ */
#endif // DISABLE_STREAM_PLAYER ]
#endif // _MpStreamQueuePlayer_h_
|