Browse code

Detect Windows Media DRM protected files and display warning if no key was provided.

Patch by Daniel G. Taylor, dan programmer-art org

Originally committed as revision 20209 to svn://svn.ffmpeg.org/ffmpeg/trunk

Daniel G. Taylor authored on 2009/10/12 08:09:33
Showing 3 changed files
... ...
@@ -116,6 +116,18 @@ const ff_asf_guid ff_asf_language_guid = {
116 116
     0xa9, 0x46, 0x43, 0x7c, 0xe0, 0xef, 0xfc, 0x4b, 0xb2, 0x29, 0x39, 0x3e, 0xde, 0x41, 0x5c, 0x85
117 117
 };
118 118
 
119
+const ff_asf_guid ff_asf_content_encryption = {
120
+    0xfb, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 0xc9, 0x55, 0xfc, 0x6e
121
+};
122
+
123
+const ff_asf_guid ff_asf_ext_content_encryption = {
124
+    0x14, 0xe6, 0x8a, 0x29, 0x22, 0x26, 0x17, 0x4c, 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c
125
+};
126
+
127
+const ff_asf_guid ff_asf_digital_signature = {
128
+    0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 0xc9, 0x55, 0xfc, 0x6e
129
+};
130
+
119 131
 const AVMetadataConv ff_asf_metadata_conv[] = {
120 132
     { "AlbumArtist", "artist"    },
121 133
     { "AlbumTitle" , "album"     },
... ...
@@ -160,6 +160,9 @@ extern const ff_asf_guid ff_asf_ext_stream_audio_stream;
160 160
 extern const ff_asf_guid ff_asf_metadata_header;
161 161
 extern const ff_asf_guid ff_asf_my_guid;
162 162
 extern const ff_asf_guid ff_asf_language_guid;
163
+extern const ff_asf_guid ff_asf_content_encryption;
164
+extern const ff_asf_guid ff_asf_ext_content_encryption;
165
+extern const ff_asf_guid ff_asf_digital_signature;
163 166
 
164 167
 extern const AVMetadataConv ff_asf_metadata_conv[];
165 168
 
... ...
@@ -532,6 +532,15 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
532 532
         } else if (url_feof(pb)) {
533 533
             return -1;
534 534
         } else {
535
+            if (!s->keylen) {
536
+                if (!guidcmp(&g, &ff_asf_content_encryption)) {
537
+                    av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n");
538
+                } else if (!guidcmp(&g, &ff_asf_ext_content_encryption)) {
539
+                    av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, decoding will likely fail!\n");
540
+                } else if (!guidcmp(&g, &ff_asf_digital_signature)) {
541
+                    av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n");
542
+                }
543
+            }
535 544
             url_fseek(pb, gsize - 24, SEEK_CUR);
536 545
         }
537 546
     }