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 HashTablesocketHashTable (UsageEnvironment &env, Boolean createIfNotPresent=True)
static SocketDescriptorlookupSocketDescriptor (UsageEnvironment &env, int sockNum, Boolean createIfNotFound=True)
static void removeSocketDescription (UsageEnvironment &env, int sockNum)
static void deregisterSocket (UsageEnvironment &env, int sockNum, unsigned char streamChannelId)


Function Documentation

static void deregisterSocket ( UsageEnvironment env,
int  sockNum,
unsigned char  streamChannelId 
) [static]

Definition at line 160 of file RTPInterface.cpp.

References SocketDescriptor::deregisterRTPInterface(), env, False, lookupSocketDescriptor(), and NULL.

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

00160                                                                                                 {
00161   SocketDescriptor* socketDescriptor = lookupSocketDescriptor(env, sockNum, False);
00162   if (socketDescriptor != NULL) {
00163     socketDescriptor->deregisterRTPInterface(streamChannelId);
00164         // Note: This may delete "socketDescriptor",
00165         // if no more interfaces are using this socket
00166   }
00167 }

static SocketDescriptor* lookupSocketDescriptor ( UsageEnvironment env,
int  sockNum,
Boolean  createIfNotFound = True 
) [static]

Definition at line 78 of file RTPInterface.cpp.

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

Referenced by deregisterSocket(), RTPInterface::setServerRequestAlternativeByteHandler(), and RTPInterface::startNetworkReading().

00078                                                                                                                      {
00079   HashTable* table = socketHashTable(env, createIfNotFound);
00080   if (table == NULL) return NULL;
00081 
00082   char const* key = (char const*)(long)sockNum;
00083   SocketDescriptor* socketDescriptor = (SocketDescriptor*)(table->Lookup(key));
00084   if (socketDescriptor == NULL) {
00085     if (createIfNotFound) {
00086       socketDescriptor = new SocketDescriptor(env, sockNum);
00087       table->Add((char const*)(long)(sockNum), socketDescriptor);
00088     } else if (table->IsEmpty()) {
00089       // We can also delete the table (to reclaim space):
00090       _Tables* ourTables = _Tables::getOurTables(env);
00091       delete table;
00092       ourTables->socketTable = NULL;
00093       ourTables->reclaimIfPossible();
00094     }
00095   }
00096 
00097   return socketDescriptor;
00098 }

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

Definition at line 100 of file RTPInterface.cpp.

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

Referenced by SocketDescriptor::~SocketDescriptor().

00100                                                                         {
00101   char const* key = (char const*)(long)sockNum;
00102   HashTable* table = socketHashTable(env);
00103   table->Remove(key);
00104 
00105   if (table->IsEmpty()) {
00106     // We can also delete the table (to reclaim space):
00107     _Tables* ourTables = _Tables::getOurTables(env);
00108     delete table;
00109     ourTables->socketTable = NULL;
00110     ourTables->reclaimIfPossible();
00111   }
00112 }

static HashTable* socketHashTable ( UsageEnvironment env,
Boolean  createIfNotPresent = True 
) [static]

Definition at line 37 of file RTPInterface.cpp.

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

Referenced by MediaSubsession::initiate(), lookupSocketDescriptor(), and removeSocketDescription().

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


Generated on Thu May 30 08:15:27 2013 for live by  doxygen 1.5.2