A new device for VDR

  • Hi to all,


    I'm currently writing a new plugin for VDR to add a new device corresponding to the triple-play box provided by my ISP (Freebox from FREE french ISP). With this box we can get Live-TV broadcast provided through a RTSP server.


    So I wrote a (very early) release of plugin which can read the RTSP stream with the help of the Live555 media library (please see http://www.live555.com/ for more info about this). For now is seems to work. Well only "seems" because the video I get through this plugin is very "choppy" and after a few seconds, the RTSP server gives up and closes the connection (I only get some "buffer" and "clean" messages on the console which seem not really to be errors one).


    To help debugging, I replaced the RTSP server URL with a local TS video file (correctly set as it works perfectly with VLC and.MPLAYER for example). Here again is the video very "choppy" so I think my implementation is not good enough...


    Actually, I started coding from the demo skybox plugin provided with VDR but I'm not sure how all this works. I understood I have to code a GetTSPacket. Here is how I made it :


    1- implement OpenDvr which is declaring some variables
    2- implement GetTSPacket this way :
    Create a tsBuffer to read more than 188 bytes at a time

    Code
    tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(2), CardIndex() + 1);


    Read buffer :

    Code
    Data = tsBuffer->Get();


    Make some PID conversion, if needed, before returning the data


    Did I something wrong ? I'm not sure I really understood the relationship between GetTSPacket which wants only 1 packet at a time, and the ringBuffer (implemented by the cTSBuffer class) which reads a lot of data in one shot.


    BTW: even if some frames seem to be dropped, I never get any buffer overflow message.


    Could someone help me (I can provide some code for analyze purpose if needed) or tell me what can be wrong in the implementation described above ?


    Thanks in advance.
    Olivier.

  • There are tons of things that can go wrong. I've done some work too to get RTSP streaming working with my Streamplayer plugin, also using liveMedia as base. I never got it playing really smooth either. In contrast to you, my plugin is not running as a device though, just as playback device providing PES packets that I create from the two ES streams.


    How did you integrate the need of liveMedia to run a low latency task scheduler together with VDR? I am running the liveMedia task scheduler in a thread, and added some functionality to halt the thread, so I can do safe cross-thread access from the VDR main loop for user interaction - quite a dirty hack. Video data is leaving the thread through VDR buffers.


    For me, I think that I still have some bottle-neck somewhere in the data feed that causes drops. If you want to take a peek on my un-finished code, just contact me.


    Cheers,


    Udo

  • Hi Urig,


    Well, I just opened a livemedia Taskcheduler in CDevice derived class. As the stream provided by my ISP has only one subsession (MP2T stream), I use a very dirty hack to make it work : I directly access to the subsession socket number and pass this descriptor when calling the cTSBuffer constructor (I know, its bad but it works ;)).
    Here is how I made it :

    Code
    [...]
    fd_dvr = subsession->rtpSource()->RTPgs()->socketNum();
    [...]
    tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(2), CardIndex() + 1);
    [...]
    Data = tsBuffer->Get();


    Please note that all lines aboves are not in the same function.


    Anyway, as stated in my previous post, even if fd_dvr points to a local video file (in TS format of course) instead of the RTSP server, the video is not played smoothly and some (many ?) frames are dropped. So I think I have another problem with my implementation (and maybe another with the livemedia lib but I'll try to solve it, if any, after the current one).


    So, I'm interested in your code and can show you mine if you want. This way maybe we will find some solution...


    Best regards,
    Olivier.

  • Its just guessing, but there may be some blocking calls in your code that limit the transfer. You need to read often from the network buffers to avoid overflows there, and you need to feed data into VDR to avoid underflows there. It may also help to increase network buffer sizes, I found a "increaseReceiveBufferTo" call in VLC media player for this.


    I've attached a development diff against streamplayer-0.1.3. All things are still quite rough, and you may need to adapt some paths in the Makefile to compile it. But it should be able to play rtsp:// URLs, though I never got it to play steady for more than a minute.
    There's also a lot of debug output in there if you put DEFINES +=-D_DEBUG into streamplayer/Make.config.


    Cheers,


    Udo

  • Thanks for your information. I'll study carefully what you posted.


    You'll find attached a very basic version of my device code. Actually, I commented out all the code relating to livemedia lib to simplify reading and debugging. Please note that this code is some kind of fork of sky demo plugin which shoukd work correctly (well, I guess, I don't have any skybox). Note also that all this is very dirty as there are many unuseful code for testing purpose.


    Currently with this code, you can only read a stream from /tmp/test.m2t file and the displayed video is very choppy. Even sometimes, it doesn't display at all ("No Signal" on the screen). I noticed that if I put some printf to stderr in cFreeboxDevice::GetTSPacket function, the situation seems to be a bit better (but not much more indeed). I think the problem I have when using livemedia lib is the same as the one observed here (nothing to do with livemedia implementation but timing related). I really can't figure what happens as the code is not so different as the skydemo one...


    If you have some idea/suggestion, it would be nice...
    Cheers,
    Olivier.

  • Hi Udo,


    I checked what you sent previously but I have some problem to make it work in my environment. Actually nothing is displayed when I try to play from test server provided with liveMedia library. streamplayer plugin was compiled with DEBUG option. You'll find attached here 2 log files I get when I respectively call the RTSP stream server via streamplayer plugin and openRTSP test prog (provided with LiveMedia).


    I also tried to read the test server stream vi VLC and it works flawlessly, as with openRTSP prog so I think my server is OK.


    I don't really see why streamplayer complains about a non-existent video nor audio subsession. They do exist...
    Do you have some idea to diagnose this ?
    Thank for your help.


    Cheers,
    Olivier.

  • Hi to all,


    Finally, I tried a completely new approach to make this stuff work and this one is OK :coolgr


    So now I have a very early release which seems stable. Although I developped this
    device in order to make the freebox (Triple-play box provided by Free ISP in France) a new source for VDR, it should work with most RTSP stream servers. Well, I didn't try to connect on servers differents than those provided by my ISP, but at least this plugins works with the test program (testOnDemandRTSPServer server) included in LiveMedia library archive. For now I just made tests with MP2T streams...


    Before I make this plugin available, I have to write some installation guidelines (specially to describe how to manage the plugin config file), which I'll do before end of next week...


    Besides, would someone advice me about the correct process to distribute this plugin (I never did this before and I don't own any website) ?


    Thanks in advance.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!