ClientSession Class Reference

<class description="" goes="" here=""> <short description=""> More...

#include <ClientSession.hpp>

Inheritance diagram for ClientSession:

VThread List of all members.

Public Types

enum  ClientSessionState {
  SESSION_ERR, SESSION_CLOSED, SESSION_CONNECTED, SESSION_INITIALIZED,
  SESSION_PLAYING, SESSION_PAUSED
}

Public Member Functions

 ClientSession (const char *uri, IO *videoOutput, IO *audioOutput, TerminalCapabilities *tc, bool enableRtx, bool visualize=false)
 creates a socket to the given server.
 ClientSession (const char *uri, IO *vout, IO *aout, UserPreferences *up, bool enableRtx, bool visualize=false)
 creates a socket to the given server.
 ClientSession (const char *videoUri, const char *proxyUri, IO *vout, IO *aout, UserPreferences *up, bool enableRtx, bool visualize=false)
 ClientSession (int socket, const struct sockaddr_in *server, const char *uri, IO *vout, IO *aout, TerminalCapabilities *c, bool enableRtx, bool visualize=false)
 socket: the raw socket for initializing the session control channel.
void construct (const char *uri)
bool sendResponse (const char *str, int bytes)
 writes the string to the session control channel
int readRequest (char *str, const int MAX_BYTES)
 reads at most
bool connect ()
 actually does a describe
bool play (bool with_caching=false)
bool pause (u32 sessionKey)
bool tearDown (u32 sessionKey)
void run ()
void setUrl (const char *&uri, bool makeExactMatch=true)
 deep-copies uri, sets mp4Stream by asking the cacheManager
const ContainerInfogetContainerInfo () const
const list< DataChannel * > & getDataChannels () const
DataChannelgetDataChannel (int esId)
 searches an existing DataChannel within this session for the given
void setDataChannel (DataChannel *dc)
 simply appends
ClientSessionState getState () const
const char * getUrl () const
int getControlSocket () const
sockaddr_in * getDestInfo ()
void setOutput (IO *out)
 sets output at the client
bool setRtxInfoForES (u32 esId, rtx_info *rtx)
 creates a rtx_group for the given input params
rtx_group * getRtxGroup (u32 esId)
 returns an rtx_group for the esId, or NULL

Protected Attributes

char * url
 the url of the source/destination file
int sessionControlChannel
 the control channel.
list< DataChannel * > channels
 the List of all DataChannels that this Session manages.
ContainerInfomp4Stream
 Information about the video.
ClientSessionState state
 the current state of the video
RTSPprotocol
 The protocol used to parse requests and generate replies.
sockaddr_in * server
TerminalCapabilitiestermCap
 buffers the termCap from the response, and then passes it to the client which is created during SETUP
UserPreferences * usrPref
std::map< u32, DataSink *,
struct intCompare > 
clientObj
 the client object needed to render the received data to the screen
IOvideoOut
IOaudioOut
list< rtx_group * > rtxInfo
 stores for each ES an optional retransmission wish
bool rtxEnabled
bool decodeData

Detailed Description

<class description="" goes="" here=""> <short description="">

Author:
Michael Kropfberger and Peter Schojer
Version:
Id
ClientSession.hpp,v 1.17 2006/01/20 15:37:53 mkropfbe Exp

Definition at line 79 of file ClientSession.hpp.


Constructor & Destructor Documentation

ClientSession::ClientSession const char *  uri,
IO videoOutput,
IO audioOutput,
TerminalCapabilities tc,
bool  enableRtx,
bool  visualize = false
 

creates a socket to the given server.

If the url is invalid or anyhing goes wrong, the state is set to SESSION_ERR. Otherwise the state is set to SESSION_CLOSED Definition at line 139 of file ClientSession.cpp.

References mp4Stream, protocol, and termCap.

00140 { 00141 rtxEnabled=enableRtx; 00142 videoOut=vout; 00143 audioOut=aout; 00144 termCap=tc; 00145 mp4Stream=NULL; 00146 protocol = NULL; 00147 usrPref = NULL; 00148 decodeData=visualize; 00149 this->construct(uri); 00150 00151 }

ClientSession::ClientSession const char *  uri,
IO vout,
IO aout,
UserPreferences *  up,
bool  enableRtx,
bool  visualize = false
 

creates a socket to the given server.

If the url is invalid or anyhing goes wrong, the state is set to SESSION_ERR. Otherwise the state is set to SESSION_CLOSED Definition at line 85 of file ClientSession.cpp.

References mp4Stream, protocol, and termCap.

00086 { 00087 printf("\033[31mXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ClientSession UP: %p XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n\033[0m", up ); 00088 printf(uri); 00089 printf("\nX: min: %i, max: %i, best: %i\n", up->dimX.min, up->dimX.max, up->dimX.best); 00090 printf("B: min: %i, max: %i, best: %i\n", up->bitrate.min, up->bitrate.max, up->bitrate.best); 00091 printf("\n\n"); 00092 rtxEnabled=enableRtx; 00093 videoOut=vout; 00094 audioOut=aout; 00095 mp4Stream=NULL; 00096 protocol=NULL; 00097 assert(up); 00098 usrPref = up; 00099 // assert(up->pay); 00100 termCap=NULL; 00101 this->construct(uri); 00102 decodeData=visualize; 00103 }

ClientSession::ClientSession int  socket,
const struct sockaddr_in *  server,
const char *  uri,
IO vout,
IO aout,
TerminalCapabilities c,
bool  enableRtx,
bool  visualize = false
 

socket: the raw socket for initializing the session control channel.

the server info is deep-copied Definition at line 186 of file ClientSession.cpp.

References mp4Stream, protocol, sessionControlChannel, state, termCap, and url.

00188 { 00189 rtxEnabled=enableRtx; 00190 state = SESSION_CLOSED; 00191 videoOut=vout; 00192 audioOut=aout; 00193 mp4Stream=NULL; 00194 usrPref = NULL; 00195 sessionControlChannel = socket; 00196 00197 if (serv) { 00198 server = new sockaddr_in(); 00199 memcpy(server, serv, sizeof(sockaddr_in)); 00200 } else { 00201 server = NULL; 00202 } 00203 00204 termCap=tc; 00205 00206 protocol = new RTSP(); 00207 if(!uri) 00208 url = NULL; 00209 else { 00210 url=new char[strlen(uri)+1]; 00211 strcpy(url,uri); 00212 } 00213 decodeData=visualize; 00214 };


Member Function Documentation

DataChannel* ClientSession::getDataChannel int  esId  ) 
 

searches an existing DataChannel within this session for the given

Parameters:
esId. NULL is returned if no DC exists

int ClientSession::readRequest char *  str,
const int  MAX_BYTES
 

reads at most

Parameters:
MAX_BYTES-1 bytes from a socket and sets '' at the end of the string. This method is blocking, it stores the read data in
str,@param return contains the bytes read. returns a negative value in case of error, returns 0 if the client closed the socket
Definition at line 278 of file ClientSession.cpp.

References sessionControlChannel, and state.

Referenced by connect().

00279 { 00280 dprintf_full("\033[32mClientSession::readRequest( %p, %i )\n\033[0m", str, MAX_BYTES); 00281 if ( state == SESSION_ERR ) 00282 return -1; 00283 00284 int n=0; 00285 int total=0; 00286 memset(str,0,MAX_BYTES); 00287 00288 do { 00289 // n == 0 if connection closed 00290 // n < 0 if error 00291 n=recv(sessionControlChannel,str+total,MAX_BYTES-1-total,0); 00292 dprintf_full("ClientSession::readRequest: partial %i total %i\r\n",n,total); 00293 dprintf_full("ClientSession::readRequest:X%sX\r\n",str+total); 00294 if(n<=0) 00295 break; 00296 total+=n; 00297 } 00298 while(n>0 && !(total>3 && str[total-4]=='\r' && str[total-3]=='\n' && 00299 str[total-2]=='\r' && str[total-1]=='\n')); 00300 00301 dprintf_full("ClientSession::readRequest: %i\r\n",total);fflush(stdout); 00302 return total; 00303 };

void ClientSession::setDataChannel DataChannel dc  )  [inline]
 

simply appends

Parameters:
dc to the list of DataChannels. No checking is done, if an entry already exists for the ElementaryStream
Definition at line 133 of file ClientSession.hpp.

References channels.

00133 { 00134 dprintf_full("\033[31mAdded DataChannel !\033[0m\n"); 00135 channels.push_front(dc); 00136 }

void ClientSession::setUrl const char *&  uri,
bool  makeExactMatch = true
 

deep-copies uri, sets mp4Stream by asking the cacheManager

Parameters:
makeExactMatch decides on possible server-side transcoding

Member Data Documentation

list<DataChannel*> ClientSession::channels [protected]
 

the List of all DataChannels that this Session manages.

1 DataChannel = 1 ESDefinition at line 175 of file ClientSession.hpp.

Referenced by setDataChannel().

RTSP* ClientSession::protocol [protected]
 

The protocol used to parse requests and generate replies.

FIXME: we hard-code to RTSP, redesign needed for http Definition at line 182 of file ClientSession.hpp.

Referenced by ClientSession(), and connect().

int ClientSession::sessionControlChannel [protected]
 

the control channel.

Supported protocol is currently RTSP might add http later if requiredDefinition at line 171 of file ClientSession.hpp.

Referenced by ClientSession(), readRequest(), and sendResponse().


The documentation for this class was generated from the following files: