C client to receive udp/rtp stream broadcasted by vlc

About encoding, codec settings, muxers and filter usage
giorgino
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Oct 2009 12:09

C client to receive udp/rtp stream broadcasted by vlc

Postby giorgino » 23 Oct 2009 14:27

Hi all,
I know that an interesting feature of VLC is that to tune a stream and broadcast it with a multicast address in the network using udp. In this way with another vlc that acts as a client we can receive that stream and visualize it. I would like to do the same thing, but I wouldn't use another vlc as a client, but I would usea program that I have written(on Linux). I have not problem for part regarding video, while my problem is that to be able to connect to the udp (I believe udp with rtp) to have to disposition the broadcasted stream. Anyone can give me some suggestions about this issue?

A good day to all!

giorgino
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Oct 2009 12:09

Re: C client to receive udp/rtp stream broadcasted by vlc

Postby giorgino » 26 Oct 2009 17:52

I downloaded DVBLast and I would like to write a network
client, but I have problem to establish the connection with the udp socket
opened by the DVBLast.
I wrote the following code but I don't understand were
I make wrong. the client remains stopped on the readv in the sense that doesn't receive any packets although server is transmitting.

int main(int argc, char* argv[])
{

uint8_t p_rtp_hdr
[RTP_SIZE];
input_t *p_input=NULL;

struct iovec p_iov[NB_BLOCKS + 1];

int i,p_read;
p_input = malloc( sizeof(input_t) );


int sockd
= socket(AF_INET, SOCK_DGRAM, 0);

if (sockd < 0)
{
fprintf
(stderr, "Error, socket() failed: %s\n", strerror(errno));
return 1;

}


struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));

addr.sin_family = AF_INET;
//memcpy(&addr.sin_addr.s_addr, pServer->h_addr,
pServer->h_length);
addr.sin_addr.s_addr = inet_addr(argv[1]);
addr.sin_port
= htons(1234);


int returnStatus = connect(sockd,(struct sockaddr*)&addr,
sizeof(addr));

p_iov[0].iov_base = p_rtp_hdr;
p_iov[0].iov_len = sizeof
(p_rtp_hdr);

for ( i = 1; i < NB_BLOCKS + 1; i++ )
{
block_t
*p_block = malloc(sizeof(block_t));
p_input->pp_blocks[i-1]=p_block;

p_iov.iov_base = p_input->pp_blocks[i-1];
p_iov.iov_len =
TS_SIZE;
printf("size %d \n",TS_SIZE);
}


while((p_read =
readv(sockd, p_iov, NB_BLOCKS+1)) < 0 )
{


printf("packets
read %d \n",p_read);


}//

return 1;

}


If you can help
me I will be very grateful to you.
Thanks and have a nice day

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

Re: C client to receive udp/rtp stream broadcasted by vlc

Postby Rémi Denis-Courmont » 26 Oct 2009 17:58

Either your bind address is wrong, or you are firewalled, or you need to subscribe to a multicast group.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

giorgino
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Oct 2009 12:09

Re: C client to receive udp/rtp stream broadcasted by vlc

Postby giorgino » 26 Oct 2009 18:29

Hi and thank you for the answer.

I'm not firewalled and checking the code for the server, there isn't any multicast group. Packets are sent to an unicast address and using netstat I see two connection established one with the server and one with the client both at 127.0.0.1:1234
But the client doesn't receive any packets.

I'm sure that I'm writing something wrong but I'm new of this issue so at the moment i'm not able to understand where I'm mistaking.

Any other suggestion?

giorgino
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Oct 2009 12:09

Re: C client to receive udp/rtp stream broadcasted by vlc

Postby giorgino » 27 Oct 2009 11:47

Solved.
As Rèmi said it was a problem of bind.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 29 guests