Help! libvlc for receiving and playing rtp stream!

This forum is about all development around libVLC.
arjunen
New Cone
New Cone
Posts: 8
Joined: 11 Jan 2009 21:25

Help! libvlc for receiving and playing rtp stream!

Postby arjunen » 24 Sep 2009 22:11

Hello Guys,

I have been using vlc player for receiving h264 RTP streams and playing it. I create a sdp file and do "vlc sample.sdp", vlc gets the RTP stream and displays the video. I want to do the same using libvlc. I got the sample code from the libvlc tutorial and I modified it a little bit.. below is the sample code.

Once I start the code it just exits after a second.... it does not play the the RTP stream.

But the "vlc player" can play the RTP stream with the same sdp file (see below).

Can anyone please help me figure out what I am doing wrong or what I should do to make it work!!! I am playing with the code for more than 5 to 6 hrs to make it work. :(

Code :

Code: Select all

#include <stdio.h> #include <stdlib.h> #include <vlc/vlc.h> static void raise(libvlc_exception_t * ex) { if (libvlc_exception_raised (ex)) { fprintf (stderr, "error: %s\n", libvlc_exception_get_message(ex)); exit (-1); } } int main(int argc, char* argv[]) { const char * const vlc_args[] = { "-I", "ncurses", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ }; // "--demux=h264" }; libvlc_exception_t ex; libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; libvlc_exception_init (&ex); /* init vlc modules, should be done only once */ inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &ex); raise (&ex); /* Create a new item */ m = libvlc_media_new (inst, "test.sdp", &ex); raise (&ex); /* XXX: demo art and meta information fetching */ /* Create a media player playing environement */ mp = libvlc_media_player_new_from_media (m, &ex); raise (&ex); /* No need to keep the media now */ libvlc_media_release (m); #if 0 /* This is a non working code that show how to hooks into a window, * if we have a window around */ libvlc_drawable_t drawable = xdrawable; /* or on windows */ libvlc_drawable_t drawable = hwnd; libvlc_media_player_set_drawable (mp, drawable, &ex); raise (&ex); #endif /* play the media_player */ libvlc_media_player_play (mp, &ex); /* Play the video clip, until it ends */ while(1){ sleep(1); if(!(libvlc_media_player_is_playing(mp,&ex))){ break; } } //sleep (10); /* Let it play a bit */ /* Stop playing */ libvlc_media_player_stop (mp, &ex); /* Free the media_player */ libvlc_media_player_release (mp); libvlc_release (inst); raise (&ex); return 0; }
The above code works for playing movies etc.,

Sample sdp file:

Code: Select all

v=0 o=2007 8000 8000 IN IP4 0.0.0.0 s=SIP Call t=0 0 m=video 1234 RTP/AVP 96 c=IN IP4 172.16.101.87 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1
Any help is highly appreciated.

Thanks
Arjunen

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 39 guests