liveMedia/RTPInterface.cpp File Reference

#include "RTPInterface.hh"
#include <GroupsockHelper.hh>
#include <stdio.h>

Include dependency graph for RTPInterface.cpp:

Go to the source code of this file.

Data Structures

class  SocketDescriptor

Functions

static void sendRTPOverTCP (unsigned char *packet, unsigned packetSize, int socketNum, unsigned char streamChannelId)
static HashTablesocketHashTable (UsageEnvironment &env)
static SocketDescriptorlookupSocketDescriptor (UsageEnvironment &env, int sockNum)
static void removeSocketDescription (UsageEnvironment &env, int sockNum)

Variables

Boolean RTPOverTCP_OK = True


Function Documentation

static SocketDescriptor* lookupSocketDescriptor ( UsageEnvironment env,
int  sockNum 
) [static]

Definition at line 68 of file RTPInterface.cpp.

References env, HashTable::Lookup(), and socketHashTable().

Referenced by RTPInterface::startNetworkReading(), and RTPInterface::stopNetworkReading().

00069                                                              {
00070   char const* key = (char const*)(long)sockNum;
00071   return (SocketDescriptor*)(socketHashTable(env)->Lookup(key));
00072 }

static void removeSocketDescription ( UsageEnvironment env,
int  sockNum 
) [static]

Definition at line 74 of file RTPInterface.cpp.

References env, _Tables::getOurTables(), HashTable::IsEmpty(), NULL, HashTable::Remove(), and socketHashTable().

Referenced by SocketDescriptor::deregisterRTPInterface().

00074                                                                         {
00075   char const* key = (char const*)(long)sockNum;
00076   HashTable* table = socketHashTable(env);
00077   table->Remove(key);
00078 
00079   if (table->IsEmpty()) {
00080     // We can also delete the table (to reclaim space):
00081     _Tables* ourTables = _Tables::getOurTables(env);
00082     delete table;
00083     ourTables->socketTable = NULL;
00084     ourTables->reclaimIfPossible();
00085   }
00086 }

void sendRTPOverTCP ( unsigned char *  packet,
unsigned  packetSize,
int  socketNum,
unsigned char  streamChannelId 
) [static]

Definition at line 245 of file RTPInterface.cpp.

References False, and RTPOverTCP_OK.

Referenced by RTPInterface::sendPacket().

00246                                                                   {
00247 #ifdef DEBUG
00248   fprintf(stderr, "sendRTPOverTCP: %d bytes over channel %d (socket %d)\n",
00249           packetSize, streamChannelId, socketNum); fflush(stderr);
00250 #endif
00251   // Send RTP over TCP, using the encoding defined in
00252   // RFC 2326, section 10.12:
00253   do {
00254     char const dollar = '$';
00255     if (send(socketNum, &dollar, 1, 0) != 1) break;
00256     if (send(socketNum, (char*)&streamChannelId, 1, 0) != 1) break;
00257 
00258     char netPacketSize[2];
00259     netPacketSize[0] = (char) ((packetSize&0xFF00)>>8);
00260     netPacketSize[1] = (char) (packetSize&0xFF);
00261     if (send(socketNum, netPacketSize, 2, 0) != 2) break;
00262 
00263     if (send(socketNum, (char*)packet, packetSize, 0) != (int)packetSize) break;
00264 
00265 #ifdef DEBUG
00266     fprintf(stderr, "sendRTPOverTCP: completed\n"); fflush(stderr);
00267 #endif
00268 
00269     return;
00270   } while (0);
00271 
00272   RTPOverTCP_OK = False; // HACK #####
00273 #ifdef DEBUG
00274   fprintf(stderr, "sendRTPOverTCP: failed!\n"); fflush(stderr);
00275 #endif
00276 }

static HashTable* socketHashTable ( UsageEnvironment env  )  [static]

Definition at line 40 of file RTPInterface.cpp.

References HashTable::create(), env, _Tables::getOurTables(), NULL, ONE_WORD_HASH_KEYS, and _Tables::socketTable.

Referenced by lookupSocketDescriptor(), removeSocketDescription(), and RTPInterface::startNetworkReading().

00040                                                          {
00041   _Tables* ourTables = _Tables::getOurTables(env);
00042   if (ourTables->socketTable == NULL) {
00043     // Create a new socket number -> SocketDescriptor mapping table:
00044     ourTables->socketTable = HashTable::create(ONE_WORD_HASH_KEYS);
00045   }
00046   return (HashTable*)(ourTables->socketTable);
00047 }


Variable Documentation

Boolean RTPOverTCP_OK = True

Definition at line 109 of file RTPInterface.cpp.

Referenced by RTPInterface::addStreamSocket(), RTPInterface::handleRead(), and sendRTPOverTCP().


Generated on Tue Oct 7 15:39:13 2008 for live by  doxygen 1.5.2