Browse Source

lib: picture: refactor format validation

Use a separate function to list the picture formats supported by libvlc,
easing the addition of new ones and improving the code readability in
client code.
pull/162/head
Alexandre Janniaux 4 years ago
committed by Jean-Baptiste Kempf
parent
commit
979147c35a
  1. 15
      lib/picture.c

15
lib/picture.c

@ -93,11 +93,24 @@ static const struct vlc_block_callbacks block_cbs =
libvlc_picture_block_release,
};
static bool IsSupportedByLibVLC(vlc_fourcc_t fcc)
{
switch (fcc)
{
case VLC_CODEC_PNG:
case VLC_CODEC_JPEG:
return true;
default:
return false;
}
}
static libvlc_picture_t* libvlc_picture_from_attachment( input_attachment_t* attachment )
{
vlc_fourcc_t fcc = image_Mime2Fourcc( attachment->psz_mime );
if ( fcc != VLC_CODEC_PNG && fcc != VLC_CODEC_JPEG )
if (!IsSupportedByLibVLC(fcc))
return NULL;
libvlc_picture_t *pic = malloc( sizeof( *pic ) );
if ( unlikely( pic == NULL ) )
return NULL;

Loading…
Cancel
Save