[MPlayer-dev-eng] [PATCH] change demuxer for radio from "rawaudio" to "audio"

Vladimir Voroshilov voroshil at gmail.com
Sun Jul 22 15:41:35 CEST 2007


Hi, Nico

2007/7/22, Nico Sabbi <nsabbi at email.it>:
> Vladimir Voroshilov wrote:
>
> > Hi, All
> >
> > I want to know is fill_wav_header routine looks ok?
> > Without objections i'll apply patch in 24h.
> >
> > With this patch passing "-rawaudio rate=" in command line no more
> > requred.
> >
> >------------------------------------------------------------------------
> >
> >
> > /*****************************************************************
> >+ * \brief fills first given buffer with WAVE header
> >+ * \param priv private data structure
> >+ * \param buffer buffer to store header to
> >+ * \param max_len buffer capacity
> >+ *
> >+ * \return length of hesder (44)
> >+ *
> >+ * This routine allows radio driver to use DEMUXER_TYPE_AUDIO and provide
> >+ * correct samplerate, channels paramaters to it. Avoid user to specify
> >+ * them in command line.
> >+ * WAVE header will be passed to demuxer as first data chunk
> >+ */
> >+static int fill_wav_header(radio_priv_t* priv, char* buffer, int max_len){
> >+    int fake_length=0; //real data length in WAV is unknown
> >+    int bits_per_sample=16;
> >+
> >+    if(max_len<44)
> >+        return 0;
> >+    *(uint32_t*)(buffer   )=le2me_32(0x46464952);    //RIFF
> >+    *(uint32_t*)(buffer+ 4)=le2me_32(fake_length+36);//file+Header length-8
> >+    *(uint32_t*)(buffer+ 8)=le2me_32(0x45564157);    //WAVE
> >+    *(uint32_t*)(buffer+12)=le2me_32(0x20746d66);    //"fmt "
> >+    *(uint32_t*)(buffer+16)=le2me_32(16);            //WAVEFORMATEX length
> >+    *(uint16_t*)(buffer+20)=le2me_16(1);             //PCM
> >+    *(uint16_t*)(buffer+22)=le2me_16(radio_param_achannels);
> >+    *(uint32_t*)(buffer+24)=le2me_32(radio_param_arate);
> >+    *(uint32_t*)(buffer+28)=le2me_32(bits_per_sample*radio_param_achannels*radio_param_arate/8);
> >+    *(uint16_t*)(buffer+32)=le2me_16(bits_per_sample*radio_param_achannels/8);
> >+    *(uint16_t*)(buffer+34)=le2me_16(bits_per_sample);
> >+    *(uint32_t*)(buffer+36)=le2me_32(0x61746164);    //"data"
> >+    *(uint32_t*)(buffer+40)=le2me_32(fake_length);   //file length
> >+    return 44;
> >+}
> >+
> >
> >
>
> I'm not the maintener of that part of code but I'm against such nonsense:
> code like that belongs to muxers. If you want to avoid passing the
> samplerate
> you can find cleaner solutions (STREAM_CTL/DEMUXER_CTL come to mind)

There is currently only one solution except above - touching grobal
ariables directly.
I don't like it. Above methods looks much better.

I don't know where call such demuxer ioctl from and how STREAM_CTL can help me.

Moreover such ioctls will be very demuxer-specific.  There is not much
common code.
.
There is another solution (i'm not sure is it acceptable or not) -
create demuxer from inside stream and tweak properties of created
sh_audio  or similar structure.

-- 
Regards,
Vladimir Voroshilov     mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719



More information about the MPlayer-dev-eng mailing list