I have to receive MPEG2-TS RTP packets from a VLC server on port 1234 and loopback this MPEG2-TS payload as UDP packets to a Port 2300.
So I have taken testMPEG2TransportReceiver.cpp as reference and added udpsink portion of code from testRelay.cpp with certain modifications.
But no udp packets are reaching port 2300.
My test program looks like -
int main(int argc, char** argv) {
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
env = BasicUsageEnvironment::createNew(*scheduler);
// Create the data sink for 'stdout':
//sessionState.sink = FileSink::createNew(*env, "stdout");
// Note: The string "stdout" is handled as a special case.
// A real file name could have been used instead.
// Create 'groupsocks' for RTP and RTCP:
char const* sessionAddressStr
ifdef USE_SSM
else
//= "239.255.42.42";
= "0.0.0.0";
// Note: If the session is unicast rather than multicast,
// then replace this string with "0.0.0.0"
endif
const unsigned short rtpPortNum = 1234;
const unsigned short rtcpPortNum = rtpPortNum+1;
ifndef USE_SSM
const unsigned char ttl = 1; // low, in case routers don't admin scope
endif
struct in_addr sessionAddress;
sessionAddress.s_addr = our_inet_addr(sessionAddressStr);
const Port rtpPort(rtpPortNum);
const Port rtcpPort(rtcpPortNum);
ifdef USE_SSM
char* sourceAddressStr = "aaa.bbb.ccc.ddd";
// replace this with the real source address
struct in_addr sourceFilterAddress;
sourceFilterAddress.s_addr = our_inet_addr(sourceAddressStr);
Groupsock rtpGroupsock(_env, sessionAddress, sourceFilterAddress, rtpPort);
Groupsock rtcpGroupsock(_env, sessionAddress, sourceFilterAddress, rtcpPort);
rtcpGroupsock.changeDestinationParameters(sourceFilterAddress,0,~0);
// our RTCP "RR"s are sent back using unicast
else
Groupsock rtpGroupsock(_env, sessionAddress, rtpPort, ttl);
Groupsock rtcpGroupsock(_env, sessionAddress, rtcpPort, ttl);
endif
// Create the data source: a "MPEG-2 TransportStream RTP source" (which uses a 'simple' RTP payload format):
sessionState.source = SimpleRTPSource::createNew(_env, &rtpGroupsock, 33, 90000, "video/MP2T", 0, False /_no 'M' bit*/);
// Create (and start) a 'RTCP instance' for the RTP source:
const unsigned estimatedSessionBandwidth = 160; // in kbps; for RTCP b/w share
const unsigned maxCNAMElen = 100;
unsigned char CNAME[maxCNAMElen+1];
gethostname((char_)CNAME, maxCNAMElen);
CNAME[maxCNAMElen] = '\0'; // just in case
sessionState.rtcpInstance
= RTCPInstance::createNew(_env, &rtcpGroupsock,
estimatedSessionBandwidth, CNAME,
NULL /* we're a client */, sessionState.source);
// Note: This starts RTCP running automatically
// Create a 'groupsock' for the destination address and port:
char const* outputAddressStr = "127.0.0.1"; // this could also be unicast
// Note: You may change "outputAddressStr" to use a different multicast
// (or unicast address), but do not change it to use the same multicast
// address as "inputAddressStr".
struct in_addr outputAddress;
outputAddress.s_addr = our_inet_addr(outputAddressStr);
Port const outputPort(2300);
unsigned char const outputTTL = 255;
Groupsock outputGroupsock(*env, outputAddress, outputPort, outputTTL);
// Then create a liveMedia 'sink' object, encapsulating this groupsock:
unsigned const maxPacketSize = 65536; // allow for large UDP packets
//unsigned const maxPacketSize = 1316;
MediaSink* sink = BasicUDPSink::createNew(*env, &outputGroupsock, maxPacketSize);
// Now, start playing, feeding the sink object from the source:
_env << "Begin sending multicast stream...\n";
sink->startPlaying(_sessionState.source, NULL, NULL);
env->taskScheduler().doEventLoop(); // does not return
return 0; // only to prevent compiler warning
}
Can you let know what's the issue.