[MPlayer-dev-eng] help request for a dvb-input patch

Bertrand Baudet bertrand_baudet at yahoo.com
Sat Sep 14 05:29:18 CEST 2002


Check this link:

http://www.linuxtv.org/mailinglists/linux-dvb/2002/02-2002/msg00014.html

Have you tried this? If yes, why didn't it work for you?
If no, you won a STFW.

Anyway, there are a lot of problems with the following code sample.


On Friday 13 September 2002 04:40 pm, nsabbi at libero.it wrote:
> Hi, I'm trying to write a patch to enable input from my Hauppage Nova
> dvb card (without hardware mpeg decoder).
> Tuning and the flow of data in MPEG PS format are working correctly
> (thanks to dvbstream! ), but I don't fully understand how the
> mechanism of streaming works.
>
> The initial part of the patch (in dvb_streaming_start) looks like:

---------------------------------------------------------------------------------
> str_ctrl = (streaming_ctrl_t *) malloc(sizeof(streaming_ctrl_t));
>         if(str_ctrl == NULL)
>         {
>                 fprintf(stderr, "ALLOCAZIONE STREAMING_CTRL
> FALLITA\n");
>                 return -1;
>         }
>
>         memset(str_ctrl, 0, sizeof(streaming_ctrl_t));
----------------------------------------------------------------------------------

Use streaming_ctrl_new() instead.
Don't use the buffer directly, actually you should never have to use it,
everything is done by cache2.

I only use this buffer in HTTP requests when the HTTP response contains
a content. It allows me to put this content back into the buffer so it can be
consumed by the nop_streaming_read which is called by the demuxer 
(throught the read function pointer in the streaming_ctrl struct).
Once this buffer is empty it will never grow back again. That's the role
of cache2.
I could have got rid of this internal buffer, but it would have required
to read byte by byte from the socket to avoid to read too far. This allows
me to read by block from the socket.

>         stream->streaming_ctrl = str_ctrl;
>         stream->fd = fd_dvr;
>

------------------------------------------------------------------------------------
>         //stream->streaming_ctrl->buffer = (char *)
> malloc(BUFFER_SIZE*1000UL);
>
>         #define MYSIZE 8192
>
>         stream->streaming_ctrl->buffer = (char*)malloc(MYSIZE);
>         if( stream->streaming_ctrl->buffer==NULL )
>         {
>                 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation
> failed\n");
>                 return -1;
>         }
>         stream->streaming_ctrl->buffer_size = MYSIZE;
----------------------------------------------------------------------------------------
remove the above.

>
>
>         global_s = stream->streaming_ctrl;
>         fprintf(stderr, "GLOBAL_S: %p\n", global_s);
>
>         stream->streaming_ctrl->streaming_read = dvb_streaming_read;
>         stream->streaming_ctrl->streaming_seek = dvb_streaming_seek;
>         //stream->streaming_ctrl->prebuffer_size = 8192;  // KBytes
>         stream->streaming_ctrl->buffering = 0;
>         stream->streaming_ctrl->status = streaming_playing_e;
> (I tried buffering=1 sooner).
>
>
> In dvb_streaming_read I put a copy of nop_streaming_read plus all the
> necessary code to read from the card (if the buffer isn't full
> enough).
>
> The code that fills the buffer is triggered as a call_back of a
> function of mpegtools:
> 	init_ipack(&pa, IPACKS, my_write_out, 1);
>         init_ipack(&pv, IPACKS, my_write_out, 1);
>
> This trigger is working, because in my_write_out I
> 1) flush the received b
> t's a real
> mpeg ps);
> 2) try to fill the buffer of stream->streaming_ctrl->buffer and to
> update buffer_pos, but here is the problem: the members buffer,
> buffer_size and buffer_pos are aways reported as 0, so nothing goes
> on!

Please don't play with those variables they are only used internally.

> Please, can anyone explain how the mechanism of streaming works?
> I will appreciate any suggestion.
> Thanks very much,


Check the above link and if doesn't work for you, I can help you but I need
more information and the input stream. The streaming layer was done to read
from a file descriptor, I think it can be change to not be restricted to a fd,
but I need to know more about the input stream.

Bertrand



More information about the MPlayer-dev-eng mailing list