Hello everyone,
I want to configure native WebRTC peerconnection_client, peerconnection_server and necessary source libraries that are used in order to enable clients receive RTP packets from different UDP ports and merge them. For example, there are two clients c1 and c2. Normally, c1's local port address is 33000 and c2's local port address is 43000. c1 sends RTP packets from port number 33000 to 43000 of c2. This works. In my scenario, I want to able 2 peers receive RTP packets from multiple ports. For instance, when c2 receives a UDP packet from "33001" (not 33000), it should be able to pass RTP packet to application layer.
The use case is:
I want to be able to separate SVC encoded video stream into different UDP ports. For instance, when c1 sends (encoded 2 spatial layer) the base layer video packets, it should be delivered from port number 33000 and the enhancement layer video packets should be delivered from port number 33001. Since, they have appropriate RTP header information, they (in my opinion) should automatically be merged at application layer. In summary, I want to send layered coded video stream from different UDP ports according to their layer IDs.
What have I done so far:
I modified "basicpacketsocketfactory.cc" file, BasicPacketSocketFactory::CreateUdpSocket(args) function. Here, I created extra socket named socket2 with min_port number 33001 (while I create first socket as 33000) and I externed that socket2 pointer. THEN, I modified "asyncudpsocket.h" and "asyncudpsocket.cc" files. I put an extra class field (socket) named socket2_ (like socket_) and initialized it by using socket2 that I externed from "basicpacketsocketfactory.cc" and used functions below in constructor:
socket_->SignalReadEvent.connect(this, &AsyncUDPSocket::OnReadEvent);
socket_->SignalWriteEvent.connect(this, &AsyncUDPSocket::OnWriteEvent);
socket2_->SignalReadEvent.connect(this, &AsyncUDPSocket::OnReadEvent);
socket2_->SignalWriteEvent.connect(this, &AsyncUDPSocket::OnWriteEvent);
and here in "asyncudpsocket.cc" class I am trying to send some of the udp packets from this second socket of which port is 33001.
Result:
For beginning, I am not separating layers into different UDP ports, but I am changing the sending socket after a while. When I start to send UDP packets from this second port, c2 is not able to pass these packets to appropirate places. Sending and receiving process are successful, but video is freezing. There was a "Received non-STUN packet from unknown address" failure, however it is fixed by changing Port::OnReadPacket function in "port.cc" at c2's source code. Although, it does not consider packets coming from 33001 as non-STUN packet, it also does not deliver RTP packet to decoder and so on.
My question is:
What should I do in order to successfully separate these packets into different ports at the receiver side. Consider c2 as receiver side. I want c2 to be able receive RTP packets from both remote port number 33000 and remote port number 33001 and merge those RTP packets.
Thank you for your time.