[FFmpeg-devel] [PATCH] Detect Windows Media DRM protected files and display warning

Justin Ruggles justin.ruggles
Fri Oct 9 22:44:42 CEST 2009


Daniel G. Taylor wrote:

> On Fri, 2009-10-09 at 14:03 +0200, Benjamin Larsson wrote:
>> In this case decryption is possible if the key is provided. I think it 
>> would be preferable if this message is only printed it there is no key 
>> specified.
> 
> Good point, I wasn't aware FFmpeg could do that. Updated patch attached
> which only displays the messages when AVFormatContext has no decryption
> key set. If a key is set then it's assumed the user knows the content is
> encrypted.
> 
> Take care,
> 

> Index: libavformat/asfdec.c
> ===================================================================
> --- libavformat/asfdec.c	(revision 20192)
> +++ libavformat/asfdec.c	(working copy)
> @@ -531,6 +531,24 @@
>  #endif
>          } else if (url_feof(pb)) {
>              return -1;
> +        } else if (!guidcmp(&g, &ff_asf_content_encryption)) {
> +            if (!s->keylen) {
> +                av_log(s, AV_LOG_WARNING, "DRM protected stream detected, "
> +                       "decoding will likely fail!\n");
> +            }
> +            url_fseek(pb, gsize - 24, SEEK_CUR);
> +        } else if (!guidcmp(&g, &ff_asf_ext_content_encryption)) {
> +            if (!s->keylen) {
> +                av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, "
> +                       "decoding will likely fail!\n");
> +            }
> +            url_fseek(pb, gsize - 24, SEEK_CUR);
> +        } else if (!guidcmp(&g, &ff_asf_digital_signature)) {
> +            if (!s->keylen) {
> +                av_log(s, AV_LOG_WARNING, "Digital signature detected, "
> +                       "decoding will likely fail!\n");
> +            }
> +            url_fseek(pb, gsize - 24, SEEK_CUR);
>          } else {
>              url_fseek(pb, gsize - 24, SEEK_CUR);
>          }


If you put the guid checks inside the last else, you can factor out the
duplicated url_fseek() and combine each guid and keylen check.

-Justin




More information about the ffmpeg-devel mailing list