Mercurial > mplayer.hg
annotate stream/stream_bd.c @ 31909:349f13e9d27b
Add const to pointer argument.
author | reimar |
---|---|
date | Sat, 21 Aug 2010 09:27:15 +0000 |
parents | b1ba93bcedb1 |
children | 5f57e2bd697f |
rev | line source |
---|---|
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
1 /* |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
2 * Bluray stream playback |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
3 * by cRTrn13 <crtrn13-at-gmail.com> 2009 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
4 * |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
5 * This file is part of MPlayer. |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
6 * |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
7 * MPlayer is free software; you can redistribute it and/or modify |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
10 * (at your option) any later version. |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
11 * |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
12 * MPlayer is distributed in the hope that it will be useful, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
16 * |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License along |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
18 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
20 */ |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
21 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
22 #include <stdio.h> |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
23 #include <limits.h> |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
24 #include "libavutil/common.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
25 #include "libavutil/aes.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
26 #include "libavutil/sha.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
27 #include "libmpdemux/demuxer.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
28 #include "libavutil/intreadwrite.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
29 #include "m_struct.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
30 #include "m_option.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
31 #include "stream.h" |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
32 #include "stream_bd.h" |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
33 |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
34 static const int BD_UNIT_SIZE = 6144; |
31874
cedbffa1629d
Make it possible to use relative, http:// etc. paths with bd://
reimar
parents:
31873
diff
changeset
|
35 static const char BD_UKF_PATH[] = "%s/AACS/Unit_Key_RO.inf"; |
cedbffa1629d
Make it possible to use relative, http:// etc. paths with bd://
reimar
parents:
31873
diff
changeset
|
36 static const char BD_M2TS_PATH[] = "%s/BDMV/STREAM/%05d.m2ts"; |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
37 static const char BD_CLIPINF_PATH[] = "%s/BDMV/CLIPINF/%05d.clpi"; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
38 |
31873 | 39 static const char DEFAULT_BD_DEVICE[] = "/mnt/bd"; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
40 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
41 static const struct stream_priv_s { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
42 int title; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
43 char *device; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
44 } stream_priv_dflts = { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
45 0, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
46 NULL |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
47 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
48 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
49 // Format: bd://[title][</mntlocation>] |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
50 // --> e.g.: bd://117/media/THE_MUMMY/ |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
51 // --> or bd://152 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
52 // instead of directly, mount location can also be gotten through -dvd-device |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
53 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
54 static const m_option_t stream_opts_fields[] = { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
55 { "hostname", ST_OFF(title), CONF_TYPE_INT, M_OPT_RANGE, 0, 99999, NULL}, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
56 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL}, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
57 { NULL, NULL, 0, 0, 0, 0, NULL } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
58 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
59 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
60 static const struct m_struct_st stream_opts = { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
61 "bd", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
62 sizeof(struct stream_priv_s), |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
63 &stream_priv_dflts, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
64 stream_opts_fields |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
65 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
66 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
67 typedef union { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
68 uint64_t u64[2]; |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
69 uint8_t u8[16]; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
70 } key; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
71 |
31845 | 72 static const key BD_CBC_IV = { |
73 .u8 = { | |
74 0x0b, 0xa0, 0xf8, 0xdd, 0xfe, 0xa6, 0x1f, 0xb3, | |
75 0xd8, 0xdf, 0x9f, 0x56, 0x6a, 0x05, 0x0f, 0x78 | |
76 } | |
77 }; | |
78 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
79 struct uks { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
80 int count; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
81 key *keys; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
82 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
83 |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
84 // This is just a guess |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
85 #define LANG_NAME_LEN 20 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
86 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
87 struct lang_map { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
88 int id; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
89 int type; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
90 char lang_name[LANG_NAME_LEN + 1]; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
91 }; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
92 |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
93 struct bd_priv { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
94 key vuk; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
95 key iv; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
96 int title; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
97 const char *device; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
98 stream_t *title_file; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
99 struct AVAES *aescbc; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
100 struct AVAES *aeseed; |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
101 off_t pos; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
102 struct uks uks; |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
103 int nr_lang_maps; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
104 struct lang_map *lang_maps; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
105 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
106 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
107 static void bd_stream_close(stream_t *s) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
108 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
109 struct bd_priv *bd = s->priv; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
110 free_stream(bd->title_file); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
111 av_free(bd->aescbc); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
112 av_free(bd->aeseed); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
113 free(bd->uks.keys); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
114 free(bd); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
115 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
116 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
117 static int bd_stream_seek(stream_t *s, off_t pos) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
118 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
119 struct bd_priv *bd = s->priv; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
120 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
121 // must seek to start of unit |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
122 pos -= pos % BD_UNIT_SIZE; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
123 if (!stream_seek(bd->title_file, pos)) { |
31848 | 124 s->eof = 1; |
125 return 0; | |
126 } | |
127 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
128 bd->pos = pos; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
129 s->pos = pos; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
130 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
131 return 1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
132 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
133 |
31909 | 134 static int find_vuk(struct bd_priv *bd, const uint8_t discid[20]) |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
135 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
136 char filename[PATH_MAX]; |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
137 const char *home; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
138 int vukfound = 0; |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
139 stream_t *file; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
140 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
141 // look up discid in KEYDB.cfg to get VUK |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
142 home = getenv("HOME"); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
143 snprintf(filename, sizeof(filename), "%s/.dvdcss/KEYDB.cfg", home); |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
144 file = open_stream(filename, NULL, NULL); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
145 if (!file) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
146 mp_msg(MSGT_OPEN,MSGL_ERR, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
147 "Cannot open VUK database file %s\n", filename); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
148 return 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
149 } |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
150 while (!stream_eof(file)) { |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
151 int i; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
152 char line[1024]; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
153 uint8_t id[20]; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
154 char d[200]; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
155 char *vst; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
156 unsigned int byte; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
157 |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
158 stream_read_line(file, line, sizeof(line), 0); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
159 // file is built up this way: |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
160 // DISCID = title | V | VUK |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
161 // or |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
162 // DISCID = title | key-pair |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
163 // key-pair = V | VUK |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
164 // or D | Date |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
165 // or M | M-key??? |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
166 // or I | I-Key |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
167 // can be followed by ; and comment |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
168 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
169 //This means: first string up to whitespace is discid |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
170 sscanf(line, "%40s", d); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
171 for (i = 0; i < 20; ++i) { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
172 if (sscanf(&d[i*2], "%2x", &byte) != 1) |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
173 break; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
174 id[i] = byte; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
175 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
176 if (memcmp(id, discid, 20) != 0) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
177 continue; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
178 mp_msg(MSGT_OPEN, MSGL_V, "KeyDB found Entry for DiscID:\n%s\n", line); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
179 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
180 vst = strstr(line, "| V |"); |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
181 if (vst == 0) |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
182 break; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
183 sscanf(&vst[6], "%32s", d); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
184 for (i = 0; i < 16; i++) { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
185 if (sscanf(&d[i*2], "%2x", &byte) != 1) |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
186 break; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
187 bd->vuk.u8[i] = byte; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
188 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
189 vukfound = 1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
190 } |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
191 free_stream(file); |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
192 return vukfound; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
193 } |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
194 |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
195 static int bd_get_uks(struct bd_priv *bd) |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
196 { |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
197 unsigned char *buf; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
198 size_t file_size; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
199 int pos; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
200 int i, j; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
201 struct AVAES *a; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
202 struct AVSHA *asha; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
203 stream_t *file; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
204 char filename[PATH_MAX]; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
205 uint8_t discid[20]; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
206 |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
207 snprintf(filename, sizeof(filename), BD_UKF_PATH, bd->device); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
208 file = open_stream(filename, NULL, NULL); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
209 if (!file) { |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
210 mp_msg(MSGT_OPEN, MSGL_ERR, |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
211 "Cannot open file %s to get UK and DiscID\n", filename); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
212 return 0; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
213 } |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
214 file_size = file->end_pos; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
215 if (file_size <= 0 || file_size > 10 * 1024* 1024) { |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
216 mp_msg(MSGT_OPEN, MSGL_ERR, "File %s too large\n", filename); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
217 free_stream(file); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
218 return 0; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
219 } |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
220 buf = av_malloc(file_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
221 stream_read(file, buf, file_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
222 free_stream(file); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
223 |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
224 // get discid from file |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
225 asha = av_malloc(av_sha_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
226 av_sha_init(asha, 160); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
227 av_sha_update(asha, buf, file_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
228 av_sha_final(asha, discid); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
229 av_free(asha); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
230 |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
231 if (!find_vuk(bd, discid)) { |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
232 mp_msg(MSGT_OPEN, MSGL_ERR, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
233 "No Volume Unique Key (VUK) found for this Disc: "); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
234 for (j = 0; j < 20; j++) mp_msg(MSGT_OPEN, MSGL_ERR, "%02x", discid[j]); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
235 mp_msg(MSGT_OPEN, MSGL_ERR, "\n"); |
31907 | 236 av_free(buf); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
237 return 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
238 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
239 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
240 pos = AV_RB32(buf); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
241 if (pos < file_size) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
242 int key_pos = pos + 48; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
243 int max_count = (file_size - key_pos - 16) / 48; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
244 bd->uks.count = AV_RB16(&buf[pos]); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
245 if (max_count < bd->uks.count) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
246 mp_msg(MSGT_OPEN, MSGL_ERR, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
247 "File to small for key count %i, using %i\n", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
248 bd->uks.count, max_count); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
249 bd->uks.count = max_count; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
250 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
251 bd->uks.keys = calloc(bd->uks.count, sizeof(key)); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
252 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
253 a = av_malloc(av_aes_size); |
31908 | 254 av_aes_init(a, bd->vuk.u8, 128, 1); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
255 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
256 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BD_DISCID="); |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
257 for (j = 0; j < 20; j++) |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
258 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02x", discid[j]); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
259 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
260 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BD_VUK="); |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
261 for (j = 0; j < 20; j++) |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
262 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02x", discid[j]); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
263 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
264 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
265 for (i = 0; i < bd->uks.count; i++) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
266 av_aes_crypt(a, bd->uks.keys[i].u8, &buf[key_pos], 1, NULL, 1); // decrypt unit key |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
267 key_pos += 48; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
268 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
269 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
270 av_free(a); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
271 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
272 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
273 av_free(buf); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
274 return 1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
275 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
276 |
31846
3f84ee74869d
Minor optimization/simplification and document the alignment requirements
reimar
parents:
31845
diff
changeset
|
277 // NOTE: we assume buf is sufficiently aligned to 64 bit read/writes |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
278 static off_t bd_read(struct bd_priv *bd, uint8_t *buf, int len) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
279 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
280 int read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
281 len &= ~15; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
282 if (!len) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
283 return 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
284 |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
285 read_len = stream_read(bd->title_file, buf, len); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
286 if (read_len != len) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
287 return -1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
288 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
289 if (bd->pos % BD_UNIT_SIZE) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
290 // decrypt in place |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
291 av_aes_crypt(bd->aescbc, buf, buf, len / 16, bd->iv.u8, 1); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
292 } else { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
293 // reset aes context as at start of unit |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
294 key enc_seed; |
31845 | 295 bd->iv = BD_CBC_IV; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
296 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
297 // perform encryption of first 16 bytes of unit (seed) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
298 av_aes_crypt(bd->aeseed, enc_seed.u8, buf, 1, NULL, 0); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
299 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
300 // perform xor |
31846
3f84ee74869d
Minor optimization/simplification and document the alignment requirements
reimar
parents:
31845
diff
changeset
|
301 enc_seed.u64[0] ^= AV_RN64A(buf); |
3f84ee74869d
Minor optimization/simplification and document the alignment requirements
reimar
parents:
31845
diff
changeset
|
302 enc_seed.u64[1] ^= AV_RN64A(buf + 8); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
303 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
304 // set uk AES-CBC key from enc_seed and BD_CBC_IV |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
305 av_aes_init(bd->aescbc, enc_seed.u8, 128, 1); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
306 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
307 // decrypt |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
308 av_aes_crypt(bd->aescbc, &buf[16], &buf[16], |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
309 (len - 16) / 16, bd->iv.u8, 1); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
310 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
311 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
312 bd->pos += read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
313 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
314 return read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
315 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
316 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
317 static int bd_stream_fill_buffer(stream_t *s, char *buf, int len) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
318 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
319 int read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
320 struct bd_priv *bd = s->priv; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
321 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
322 read_len = bd_read(bd, buf, len); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
323 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
324 s->pos = bd->pos; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
325 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
326 return read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
327 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
328 |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
329 static int is_video_type(int type) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
330 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
331 switch (type) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
332 case 1: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
333 case 2: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
334 case 0x10: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
335 case 0x1b: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
336 case 0xD1: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
337 case 0xEA: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
338 return 1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
339 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
340 return 0; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
341 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
342 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
343 static int is_audio_type(int type) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
344 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
345 switch (type) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
346 case 3: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
347 case 4: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
348 case 0x0f: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
349 case 0x11: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
350 case 0x81: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
351 case 0x8A: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
352 case 0x82: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
353 case 0x85: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
354 case 0x86: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
355 return 1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
356 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
357 return 0; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
358 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
359 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
360 static int is_sub_type(int type) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
361 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
362 switch (type) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
363 case 0x90: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
364 return 1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
365 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
366 return 0; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
367 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
368 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
369 const char *bd_lang_from_id(stream_t *s, int id) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
370 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
371 struct bd_priv *bd = s->priv; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
372 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
373 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
374 if (bd->lang_maps[i].id == id) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
375 return bd->lang_maps[i].lang_name; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
376 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
377 return NULL; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
378 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
379 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
380 int bd_aid_from_lang(stream_t *s, const char *lang) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
381 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
382 struct bd_priv *bd = s->priv; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
383 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
384 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
385 if (is_audio_type(bd->lang_maps[i].type) && |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
386 strstr(bd->lang_maps[i].lang_name, lang)) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
387 return bd->lang_maps[i].id; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
388 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
389 return -1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
390 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
391 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
392 int bd_sid_from_lang(stream_t *s, const char *lang) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
393 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
394 struct bd_priv *bd = s->priv; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
395 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
396 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
397 if (is_sub_type(bd->lang_maps[i].type) && |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
398 strstr(bd->lang_maps[i].lang_name, lang)) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
399 return bd->lang_maps[i].id; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
400 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
401 return -1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
402 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
403 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
404 static void get_clipinf(struct bd_priv *bd) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
405 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
406 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
407 int langmap_offset, index_offset, end_offset; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
408 char filename[PATH_MAX]; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
409 stream_t *file; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
410 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
411 snprintf(filename, sizeof(filename), BD_CLIPINF_PATH, bd->device, bd->title); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
412 file = open_stream(filename, NULL, NULL); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
413 if (!file) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
414 mp_msg(MSGT_OPEN, MSGL_ERR, "Cannot open clipinf %s\n", filename); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
415 return; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
416 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
417 if (stream_read_qword(file) != AV_RB64("HDMV0200")) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
418 mp_msg(MSGT_OPEN, MSGL_ERR, "Unknown clipinf format\n"); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
419 return; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
420 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
421 stream_read_dword(file); // unknown offset |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
422 langmap_offset = stream_read_dword(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
423 index_offset = stream_read_dword(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
424 end_offset = stream_read_dword(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
425 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
426 // read language <-> stream id mappings |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
427 stream_seek(file, langmap_offset); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
428 stream_read_dword(file); // size |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
429 stream_skip(file, 8); // unknown |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
430 bd->nr_lang_maps = stream_read_char(file); // number of entries |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
431 stream_read_char(file); // unknown |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
432 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
433 bd->lang_maps = calloc(bd->nr_lang_maps, sizeof(*bd->lang_maps)); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
434 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
435 int type; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
436 bd->lang_maps[i].id = stream_read_word(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
437 stream_read_char(file); // unknown |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
438 type = stream_read_char(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
439 if (!is_video_type(type) && !is_audio_type(type) && !is_sub_type(type)) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
440 mp_msg(MSGT_OPEN, MSGL_WARN, "Unknown type %x in clipinf\n", type); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
441 bd->lang_maps[i].type = type; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
442 stream_read(file, bd->lang_maps[i].lang_name, LANG_NAME_LEN); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
443 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
444 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
445 free_stream(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
446 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
447 |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
448 static int bd_stream_open(stream_t *s, int mode, void* opts, int* file_format) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
449 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
450 char filename[PATH_MAX]; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
451 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
452 struct stream_priv_s* p = opts; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
453 struct bd_priv *bd = calloc(1, sizeof(*bd)); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
454 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
455 if (p->device) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
456 bd->device = p->device; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
457 else if (dvd_device) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
458 bd->device = dvd_device; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
459 else |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
460 bd->device = DEFAULT_BD_DEVICE; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
461 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
462 s->sector_size = BD_UNIT_SIZE; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
463 s->flags = STREAM_READ | MP_STREAM_SEEK; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
464 s->fill_buffer = bd_stream_fill_buffer; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
465 s->seek = bd_stream_seek; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
466 s->close = bd_stream_close; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
467 s->start_pos = 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
468 s->priv = bd; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
469 s->type = STREAMTYPE_BD; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
470 s->url = strdup("bd://"); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
471 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
472 bd->pos = 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
473 bd->title = p->title; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
474 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
475 // get and decrypt unit keys |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
476 if (!bd_get_uks(bd)) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
477 return STREAM_ERROR; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
478 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
479 bd->aescbc = av_malloc(av_aes_size); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
480 bd->aeseed = av_malloc(av_aes_size); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
481 |
31847 | 482 // set up AES key from uk |
483 av_aes_init(bd->aeseed, bd->uks.keys[0].u8, 128, 0); | |
484 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
485 snprintf(filename, sizeof(filename), BD_M2TS_PATH, bd->device, bd->title); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
486 mp_msg(MSGT_OPEN, MSGL_STATUS, "Opening %s\n", filename); |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
487 bd->title_file = open_stream(filename, NULL, NULL); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
488 if (!bd->title_file) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
489 return STREAM_ERROR; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
490 s->end_pos = bd->title_file->end_pos; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
491 |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
492 get_clipinf(bd); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
493 |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
494 return STREAM_OK; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
495 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
496 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
497 const stream_info_t stream_info_bd = { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
498 "Bluray", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
499 "bd", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
500 "cRTrn13", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
501 "", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
502 bd_stream_open, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
503 { "bd", NULL }, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
504 &stream_opts, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
505 1 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
506 }; |