testProgs/testRelay.cpp File Reference

#include <liveMedia.hh>
#include "BasicUsageEnvironment.hh"
#include "GroupsockHelper.hh"

Include dependency graph for testRelay.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Variables

UsageEnvironmentenv


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file testRelay.cpp.

References BasicUDPSink::createNew(), BasicUDPSource::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, maxPacketSize, NULL, our_inet_addr(), MediaSink::startPlaying(), and UsageEnvironment::taskScheduler().

00030                                 {
00031   // Begin by setting up our usage environment:
00032   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
00033   env = BasicUsageEnvironment::createNew(*scheduler);
00034 
00035   // Create a 'groupsock' for the input multicast group,port:
00036   char const* inputAddressStr
00037 #ifdef USE_SSM
00038     = "232.255.42.42";
00039 #else
00040     = "239.255.42.42";
00041 #endif
00042   struct in_addr inputAddress;
00043   inputAddress.s_addr = our_inet_addr(inputAddressStr);
00044 
00045   Port const inputPort(8888);
00046   unsigned char const inputTTL = 0; // we're only reading from this mcast group
00047 
00048 #ifdef USE_SSM
00049   char* sourceAddressStr = "aaa.bbb.ccc.ddd";
00050                            // replace this with the real source address
00051   struct in_addr sourceFilterAddress;
00052   sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr);
00053 
00054   Groupsock inputGroupsock(*env, inputAddress, sourceFilterAddress, inputPort);
00055 #else
00056   Groupsock inputGroupsock(*env, inputAddress, inputPort, inputTTL);
00057 #endif
00058 
00059   // Then create a liveMedia 'source' object, encapsulating this groupsock:
00060   FramedSource* source = BasicUDPSource::createNew(*env, &inputGroupsock);
00061 
00062 
00063   // Create a 'groupsock' for the destination address and port:
00064   char const* outputAddressStr = "239.255.43.43"; // this could also be unicast
00065     // Note: You may change "outputAddressStr" to use a different multicast
00066     // (or unicast address), but do *not* change it to use the same multicast
00067     // address as "inputAddressStr".
00068   struct in_addr outputAddress;
00069   outputAddress.s_addr = our_inet_addr(outputAddressStr);
00070 
00071   Port const outputPort(4444);
00072   unsigned char const outputTTL = 255;
00073 
00074   Groupsock outputGroupsock(*env, outputAddress, outputPort, outputTTL);
00075 
00076   // Then create a liveMedia 'sink' object, encapsulating this groupsock:
00077   unsigned const maxPacketSize = 65536; // allow for large UDP packets
00078   MediaSink* sink = BasicUDPSink::createNew(*env, &outputGroupsock, maxPacketSize);
00079 
00080 
00081   // Now, start playing, feeding the sink object from the source:
00082   sink->startPlaying(*source, NULL, NULL);
00083 
00084   env->taskScheduler().doEventLoop(); // does not return
00085 
00086   return 0; // only to prevent compiler warning
00087 }


Variable Documentation

UsageEnvironment* env

Definition at line 25 of file testRelay.cpp.


Generated on Thu May 17 07:14:46 2012 for live by  doxygen 1.5.2