Page 1 of 1
C client to receive udp/rtp stream broadcasted by vlc
Posted: 23 Oct 2009 14:27
by giorgino
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!
Re: C client to receive udp/rtp stream broadcasted by vlc
Posted: 26 Oct 2009 17:52
by giorgino
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
Re: C client to receive udp/rtp stream broadcasted by vlc
Posted: 26 Oct 2009 17:58
by Rémi Denis-Courmont
Either your bind address is wrong, or you are firewalled, or you need to subscribe to a multicast group.
Re: C client to receive udp/rtp stream broadcasted by vlc
Posted: 26 Oct 2009 18:29
by giorgino
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?
Re: C client to receive udp/rtp stream broadcasted by vlc
Posted: 27 Oct 2009 11:47
by giorgino
Solved.
As Rèmi said it was a problem of bind.