[MPlayer-dev-eng] [PATCH] Initial Bluray support

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Sep 13 13:00:11 CEST 2009


On Sun, Sep 13, 2009 at 01:01:19PM +0300, Jonathan Nell wrote:
> Also, i'm having a problem with stream_t end_pos. The off_t should be
> big enough to take the size of the bluray title (it's 64 bits isn't
> it?) but for some reason this doesn't work (even when compiling for
> x64).

Are you using MinGW? MinGW never finished the 64 bit file access support,
you need the patches from e.g. here:
http://oss.netfarm.it/mplayer/misc/file64_mingw.diff

I'd also find it preferable if the code use more FFmpeg style (e.g. 4
spaces indentation, { for functions on a new line, ...).
That is not my absolutely preferred style either (I admit yours is even
closer), but consistency is IMO worth it.

> +  struct stream_priv_s* p=(struct stream_priv_s *)opts;

Useless cast.

> +  bd_priv_t *bd=malloc(sizeof(bd_priv_t));

sizeof(*bd) is nicer IMO.

> +  memset(bd,0,sizeof(bd_priv_t));

Use calloc instead of malloc+memset.

> +  s->priv=(void *)bd;

Useless cast.

> +  *file_format = DEMUXER_TYPE_LAVF;

Huh?

> +  // change vuk ascii hex into byte array
> +  for(i=0;i<16;++i) {
> +    if(sscanf(p->vuk,"%2x",&byte)!=1) break;
> +    bd->vuk[i]=byte;
> +    p->vuk+=2;
> +  }

libmpdemux/demux_lavf already has a function for that.

> +  bd_priv_t *bd = ((bd_priv_t *)(s->priv));

Useless cast and useless ()

> +  char filename[200];
> +
> +  sprintf(filename,BD_UKF_PATH,bd->device);

Use snprintf, particularly since bd->device is arbitrary data that could
even come from a playlist the user has no control over and filename is
on the stack (or to put it more clearly: as it is it is a security hole big
enough for a 1000l cola truck).

> +  pos=buf[0]<<24|buf[1]<<16|buf[2]<<8|(buf[3]&0xff);
> +  bd->uks.count=buf[pos]<<8|(buf[pos+1]&0xff);

AV_RB32, AV_RB16.
And check that pos is valid (i.e. within the buffer).

> +  bd->uks.keys=malloc(sizeof(struct uk)*bd->uks.count);

calloc would probably be simpler, since speed does not really matter.

> +/* For some reason libavutil aes code doesn't work, so using openssl for now (-lcrypto)
> +      a=av_malloc(av_aes_size);
> +      av_aes_init(a,bd->vuk,128,0);
> +      av_aes_crypt(a,bd->uks.keys[i].dec_key,bd->uks.keys[i].enc_key,1,NULL,0);
> +      free(a);
> +*/
> +      AES_KEY aes_key;
> +      AES_set_decrypt_key(bd->vuk, 128, &aes_key);
> +      AES_decrypt(bd->uks.keys[i].enc_key, bd->uks.keys[i].dec_key, &aes_key);

That "some reason" is that whenever you decrypt with OpenSSL you ask
libavutil to encrypt and the other way round.
The parameter is called "decrypt" and the doxy says "@param decrypt 0
for encryption, 1 for decryption" so if you set it to 0 it is no
surprise it doesn't work for decryption.



More information about the MPlayer-dev-eng mailing list