#include <liveMedia.hh>#include "BasicUsageEnvironment.hh"#include "GroupsockHelper.hh"Include dependency graph for testReplicator.cpp:

Go to the source code of this file.
Functions | |
| void | startReplicaUDPSink (StreamReplicator *replicator, char const *outputAddressStr, portNumBits outputPortNum) |
| void | startReplicaFileSink (StreamReplicator *replicator, char const *outputFileName) |
| int | main (int argc, char **argv) |
Variables | |
| UsageEnvironment * | env |
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 35 of file testReplicator.cpp.
References StreamReplicator::createNew(), BasicUDPSource::createNew(), BasicUsageEnvironment::createNew(), BasicTaskScheduler::createNew(), TaskScheduler::doEventLoop(), env, our_inet_addr(), startReplicaFileSink(), startReplicaUDPSink(), and UsageEnvironment::taskScheduler().
00035 { 00036 // Begin by setting up our usage environment: 00037 TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 00038 env = BasicUsageEnvironment::createNew(*scheduler); 00039 00040 // Create a 'groupsock' for the input multicast group,port: 00041 char const* inputAddressStr 00042 #ifdef USE_SSM 00043 = "232.255.42.42"; 00044 #else 00045 = "239.255.42.42"; 00046 #endif 00047 struct in_addr inputAddress; 00048 inputAddress.s_addr = our_inet_addr(inputAddressStr); 00049 00050 Port const inputPort(8888); 00051 unsigned char const inputTTL = 0; // we're only reading from this mcast group 00052 00053 #ifdef USE_SSM 00054 char* sourceAddressStr = "aaa.bbb.ccc.ddd"; 00055 // replace this with the real source address 00056 struct in_addr sourceFilterAddress; 00057 sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr); 00058 00059 Groupsock inputGroupsock(*env, inputAddress, sourceFilterAddress, inputPort); 00060 #else 00061 Groupsock inputGroupsock(*env, inputAddress, inputPort, inputTTL); 00062 #endif 00063 00064 // Then create a liveMedia 'source' object, encapsulating this groupsock: 00065 FramedSource* source = BasicUDPSource::createNew(*env, &inputGroupsock); 00066 00067 // And feed this into a 'stream replicator': 00068 StreamReplicator* replicator = StreamReplicator::createNew(*env, source); 00069 00070 // Then create a network (UDP) 'sink' object to receive a replica of the input stream, and start it. 00071 // If you wish, you can duplicate this line - with different network addresses and ports - to create multiple output UDP streams: 00072 startReplicaUDPSink(replicator, "239.255.43.43", 4444); 00073 00074 // Then create a file 'sink' object to receive a replica of the input stream, and start it. 00075 // If you wish, you can duplicate this line - with a different file name - to create multiple output files: 00076 startReplicaFileSink(replicator, "test.out"); 00077 00078 // Finally, enter the 'event loop' (which is where most of the 'real work' in a LIVE555-based application gets done): 00079 env->taskScheduler().doEventLoop(); // does not return 00080 00081 return 0; // only to prevent compiler warning 00082 }
| void startReplicaFileSink | ( | StreamReplicator * | replicator, | |
| char const * | outputFileName | |||
| ) |
Definition at line 105 of file testReplicator.cpp.
References FileSink::createNew(), StreamReplicator::createStreamReplica(), env, NULL, and MediaSink::startPlaying().
Referenced by main().
00105 { 00106 // Begin by creating an input stream from our replicator: 00107 FramedSource* source = replicator->createStreamReplica(); 00108 00109 // Then create a 'file sink' object to receive thie replica stream: 00110 MediaSink* sink = FileSink::createNew(*env, outputFileName); 00111 00112 // Now, start playing, feeding the sink object from the source: 00113 sink->startPlaying(*source, NULL, NULL); 00114 }
| void startReplicaUDPSink | ( | StreamReplicator * | replicator, | |
| char const * | outputAddressStr, | |||
| portNumBits | outputPortNum | |||
| ) |
Definition at line 84 of file testReplicator.cpp.
References BasicUDPSink::createNew(), StreamReplicator::createStreamReplica(), env, maxPacketSize, NULL, our_inet_addr(), and MediaSink::startPlaying().
Referenced by main().
00084 { 00085 // Begin by creating an input stream from our replicator: 00086 FramedSource* source = replicator->createStreamReplica(); 00087 00088 // Create a 'groupsock' for the destination address and port: 00089 struct in_addr outputAddress; 00090 outputAddress.s_addr = our_inet_addr(outputAddressStr); 00091 00092 Port const outputPort(outputPortNum); 00093 unsigned char const outputTTL = 255; 00094 00095 Groupsock* outputGroupsock = new Groupsock(*env, outputAddress, outputPort, outputTTL); 00096 00097 // Then create a liveMedia 'sink' object, encapsulating this groupsock: 00098 unsigned const maxPacketSize = 65536; // allow for large UDP packets 00099 MediaSink* sink = BasicUDPSink::createNew(*env, outputGroupsock, maxPacketSize); 00100 00101 // Now, start playing, feeding the sink object from the source: 00102 sink->startPlaying(*source, NULL, NULL); 00103 }
Definition at line 27 of file testReplicator.cpp.
1.5.2