Record video from two streams rtp at the same time

This forum is about all development around libVLC.
Sputnik
New Cone
New Cone
Posts: 3
Joined: 14 Oct 2014 20:48

Record video from two streams rtp at the same time

Postby Sputnik » 14 Oct 2014 21:05

Hi every one,

¿It is possible recording, with libVLC, two videos at the same time from two different streams that share the same SSRC? yes i know that there is a RFC...but it is a "feature" not documented by other people....

My two sdp files are

one.sdp
v=0
m=video 1234 RTP/AVP 112
c=IN IP4 239.11.11.1
a=rtpmap:112 H264/90000

two.sdp
v=0
m=video 1234 RTP/AVP 112
c=IN IP4 239.11.12.1
a=rtpmap:112 H264/90000


I only have one network interface with one ip address. I tried with vlc and all i got is the same video on both sides..

Thanks a million

Rémi Denis-Courmont
Developer
Developer
Posts: 15272
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Record video from two streams rtp at the same time

Postby Rémi Denis-Courmont » 14 Oct 2014 21:10

VLC does not care about SSRCs as long as it´s not to the same address/port.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Sputnik
New Cone
New Cone
Posts: 3
Joined: 14 Oct 2014 20:48

Re: Record video from two streams rtp at the same time

Postby Sputnik » 15 Oct 2014 08:17

VLC does not care about SSRCs as long as it´s not to the same address/port.
Thanks for your quick response Denis, but if vlc doesn't care about SSRC who is possible this situation? i record the same two videos (not in sync) with two concurrents vlc. each one joined to a different multicast ip rtp streams. both streams use the same dest port 1234

Sputnik
New Cone
New Cone
Posts: 3
Joined: 14 Oct 2014 20:48

Re: Record video from two streams rtp at the same time

Postby Sputnik » 16 Oct 2014 15:48

I figured out the usage of the ssrc, reviewing the source code i found this piece of code interesting:

/**
* Initializes a new RTP source within an RTP session.
*/
static rtp_source_t *
rtp_source_create (demux_t *demux, const rtp_session_t *session,
uint32_t ssrc, uint16_t init_seq)
{
rtp_source_t *source;

source = malloc (sizeof (*source) + (sizeof (void *) * session->ptc));
if (source == NULL)
return NULL;

source->ssrc = ssrc;
source->jitter = 0;
source->ref_rtp = 0;
/* TODO: use VLC_TS_0, but VLC does not like negative PTS at the moment */
source->ref_ntp = UINT64_C (1) << 62;
source->max_seq = source->bad_seq = init_seq;
source->last_seq = init_seq - 1;
source->blocks = NULL;

/* Initializes all payload */
for (unsigned i = 0; i < session->ptc; i++)
source->opaque = session->ptv.init (demux);

msg_Dbg (demux, "added RTP source (%08x)", ssrc);
return source;
}


So the ssrc are the key to distinguish video streams, the RFC is clear https://www.ietf.org/rfc/rfc1889.txt

8. SSRC Identifier Allocation and Use

The SSRC identifier carried in the RTP header and in various fields
of RTCP packets is a random 32-bit number that is required to be
globally unique within an RTP session. It is crucial that the number
be chosen with care in order that participants on the same network or
starting at the same time are not likely to choose the same number.

It is not sufficient to use the local network address (such as an
IPv4 address) for the identifier because the address may not be
unique. Since RTP translators and mixers enable interoperation among
multiple networks with different address spaces, the allocation
patterns for addresses within two spaces might result in a much
higher rate of collision than would occur with random allocation.

Multiple sources running on one host would also conflict.

It is also not sufficient to obtain an SSRC identifier simply by
calling random() without carefully initializing the state. An example
of how to generate a random identifier is presented in Appendix A.6.


Thx a lot


Return to “Development around libVLC”

Who is online

Users browsing this forum: Jona and 35 guests