Mercurial > mplayer.hg
annotate stream/stream_bd.c @ 37078:7471626e943e
Relocate add_vf().
Additionally, add doxygen comment.
author | ib |
---|---|
date | Thu, 24 Apr 2014 13:31:52 +0000 |
parents | 389d43c448b3 |
children |
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 /* |
32519 | 2 * Blu-ray stream playback |
31836
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> |
31914 | 24 #include <ctype.h> |
35903 | 25 #include <strings.h> |
26 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
27 #include "libavutil/common.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
28 #include "libavutil/aes.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
29 #include "libavutil/sha.h" |
34648
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
30 #include "libavutil/avstring.h" |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
31 #include "libmpdemux/demuxer.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
32 #include "libavutil/intreadwrite.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
33 #include "m_struct.h" |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
34 #include "m_option.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
32531
diff
changeset
|
35 #include "mp_msg.h" |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
36 #include "stream.h" |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
37 #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
|
38 |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 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
|
43 |
31873 | 44 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
|
45 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
46 static const struct stream_priv_s { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
47 int title; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
48 char *device; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
49 } stream_priv_dflts = { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
50 0, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
51 NULL |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
52 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
53 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
54 // Format: bd://[title][</mntlocation>] |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
55 // --> 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
|
56 // --> or bd://152 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
57 // 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
|
58 #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
|
59 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
|
60 { "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
|
61 { "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
|
62 { 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
|
63 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
64 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
65 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
|
66 "bd", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
67 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
|
68 &stream_priv_dflts, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
69 stream_opts_fields |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
70 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
71 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
72 typedef union { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
73 uint64_t u64[2]; |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
74 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
|
75 } key; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
76 |
31845 | 77 static const key BD_CBC_IV = { |
78 .u8 = { | |
79 0x0b, 0xa0, 0xf8, 0xdd, 0xfe, 0xa6, 0x1f, 0xb3, | |
80 0xd8, 0xdf, 0x9f, 0x56, 0x6a, 0x05, 0x0f, 0x78 | |
81 } | |
82 }; | |
83 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
84 struct uks { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
85 int count; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
86 key *keys; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
87 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
88 |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
89 // This is just a guess |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
90 #define LANG_NAME_LEN 20 |
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 struct lang_map { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
93 int id; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
94 int type; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
95 char lang_name[LANG_NAME_LEN + 1]; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
96 }; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
97 |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
98 struct bd_priv { |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
99 key vuk; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
100 key iv; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
101 int title; |
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
102 const char *device; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
103 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
|
104 struct AVAES *aescbc; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
105 struct AVAES *aeseed; |
35885
3389262720da
Fix previous commit, off_t must be replaced by int64_t
reimar
parents:
35881
diff
changeset
|
106 int64_t pos; |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
107 struct uks uks; |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
108 int nr_lang_maps; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
109 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
|
110 }; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
111 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
112 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
|
113 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
114 struct bd_priv *bd = s->priv; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
115 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
|
116 av_free(bd->aescbc); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
117 av_free(bd->aeseed); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
118 free(bd->uks.keys); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
119 free(bd); |
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 |
35885
3389262720da
Fix previous commit, off_t must be replaced by int64_t
reimar
parents:
35881
diff
changeset
|
122 static int bd_stream_seek(stream_t *s, int64_t pos) |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
123 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
124 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
|
125 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
126 // 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
|
127 pos -= pos % BD_UNIT_SIZE; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
128 if (!stream_seek(bd->title_file, pos)) { |
31848 | 129 s->eof = 1; |
130 return 0; | |
131 } | |
132 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
133 bd->pos = pos; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
134 s->pos = pos; |
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 return 1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
137 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
138 |
31910 | 139 #define ID_STR_LEN 41 |
140 static void id2str(const uint8_t *id, int idlen, char dst[ID_STR_LEN]) | |
141 { | |
142 int i; | |
143 idlen = FFMIN(idlen, 20); | |
144 for (i = 0; i < idlen; i++) | |
31911 | 145 snprintf(dst + 2*i, 3, "%02"PRIX8, id[i]); |
31910 | 146 } |
147 | |
31909 | 148 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
|
149 { |
31917
d0d09a75bb17
Check stream_read_line result instead of checking stream_eof,
reimar
parents:
31916
diff
changeset
|
150 char line[1024]; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
151 char filename[PATH_MAX]; |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
152 const char *home; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
153 int vukfound = 0; |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
154 stream_t *file; |
31912
c8935911ca00
Simplify searching for discid by comparing the string representations.
reimar
parents:
31911
diff
changeset
|
155 char idstr[ID_STR_LEN]; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
156 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
157 // 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
|
158 home = getenv("HOME"); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
159 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
|
160 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
|
161 if (!file) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
162 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
|
163 "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
|
164 return 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
165 } |
31912
c8935911ca00
Simplify searching for discid by comparing the string representations.
reimar
parents:
31911
diff
changeset
|
166 id2str(discid, 20, idstr); |
31917
d0d09a75bb17
Check stream_read_line result instead of checking stream_eof,
reimar
parents:
31916
diff
changeset
|
167 while (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
|
168 char *vst; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
169 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
170 // 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
|
171 // DISCID = title | V | VUK |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
172 // or |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
173 // DISCID = title | key-pair |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
174 // key-pair = V | VUK |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
175 // or D | Date |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
176 // or M | M-key??? |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
177 // or I | I-Key |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
178 // 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
|
179 |
31912
c8935911ca00
Simplify searching for discid by comparing the string representations.
reimar
parents:
31911
diff
changeset
|
180 if (strncasecmp(line, idstr, 40)) |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
181 continue; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
182 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
|
183 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
184 vst = strstr(line, "| V |"); |
31913 | 185 if (!vst) |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
186 break; |
31914 | 187 vst += 6; |
188 while (isspace(*vst)) vst++; | |
31916
6b45e5fb9dc4
Fix reading of VUK: actually fail if the key is incomplete instead
reimar
parents:
31915
diff
changeset
|
189 if (sscanf(vst, "%16"SCNx64, &bd->vuk.u64[0]) != 1) |
31914 | 190 continue; |
31916
6b45e5fb9dc4
Fix reading of VUK: actually fail if the key is incomplete instead
reimar
parents:
31915
diff
changeset
|
191 if (sscanf(vst + 16, "%16"SCNx64, &bd->vuk.u64[1]) != 1) |
6b45e5fb9dc4
Fix reading of VUK: actually fail if the key is incomplete instead
reimar
parents:
31915
diff
changeset
|
192 continue; |
6b45e5fb9dc4
Fix reading of VUK: actually fail if the key is incomplete instead
reimar
parents:
31915
diff
changeset
|
193 bd->vuk.u64[0] = av_be2ne64(bd->vuk.u64[0]); |
6b45e5fb9dc4
Fix reading of VUK: actually fail if the key is incomplete instead
reimar
parents:
31915
diff
changeset
|
194 bd->vuk.u64[1] = av_be2ne64(bd->vuk.u64[1]); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
195 vukfound = 1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
196 } |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
197 free_stream(file); |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
198 return vukfound; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
199 } |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
200 |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
201 static int bd_get_uks(struct bd_priv *bd) |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
202 { |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
203 unsigned char *buf; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
204 size_t file_size; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
205 int pos; |
31910 | 206 int i; |
31906
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
207 struct AVAES *a; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
208 struct AVSHA *asha; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
209 stream_t *file; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
210 char filename[PATH_MAX]; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
211 uint8_t discid[20]; |
31910 | 212 char idstr[ID_STR_LEN]; |
31906
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 snprintf(filename, sizeof(filename), BD_UKF_PATH, bd->device); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
215 file = open_stream(filename, NULL, NULL); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
216 if (!file) { |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
217 mp_msg(MSGT_OPEN, MSGL_ERR, |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
218 "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
|
219 return 0; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
220 } |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
221 file_size = file->end_pos; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
222 if (file_size <= 0 || file_size > 10 * 1024* 1024) { |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
223 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
|
224 free_stream(file); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
225 return 0; |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
226 } |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
227 buf = av_malloc(file_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
228 stream_read(file, buf, file_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
229 free_stream(file); |
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 // get discid from file |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
232 asha = av_malloc(av_sha_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
233 av_sha_init(asha, 160); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
234 av_sha_update(asha, buf, file_size); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
235 av_sha_final(asha, discid); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
236 av_free(asha); |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
237 |
0a895a0ce15a
Extract reading KEDB.cfg into a separate function.
reimar
parents:
31877
diff
changeset
|
238 if (!find_vuk(bd, discid)) { |
31910 | 239 id2str(discid, 20, idstr); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
240 mp_msg(MSGT_OPEN, MSGL_ERR, |
31910 | 241 "No Volume Unique Key (VUK) found for this Disc: %s\n", idstr); |
31907 | 242 av_free(buf); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
243 return 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
244 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
245 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
246 pos = AV_RB32(buf); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
247 if (pos < file_size) { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 "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
|
254 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
|
255 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
|
256 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
257 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
|
258 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
259 a = av_malloc(av_aes_size); |
31908 | 260 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
|
261 |
31910 | 262 id2str(discid, 20, idstr); |
263 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BD_DISCID=%s\n", idstr); | |
264 id2str(bd->vuk.u8, 16, idstr); | |
265 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BD_VUK=%s\n", idstr); | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
266 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
267 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
|
268 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
|
269 key_pos += 48; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
270 } |
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 av_free(a); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
273 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
274 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
275 av_free(buf); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
276 return 1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
277 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
278 |
31846
3f84ee74869d
Minor optimization/simplification and document the alignment requirements
reimar
parents:
31845
diff
changeset
|
279 // NOTE: we assume buf is sufficiently aligned to 64 bit read/writes |
35885
3389262720da
Fix previous commit, off_t must be replaced by int64_t
reimar
parents:
35881
diff
changeset
|
280 static int64_t bd_read(struct bd_priv *bd, uint8_t *buf, int len) |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
281 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
282 int read_len; |
32530
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
283 int unit_offset = bd->pos % BD_UNIT_SIZE; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
284 len &= ~15; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
285 if (!len) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
286 return 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
287 |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
288 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
|
289 if (read_len != len) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
290 return -1; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
291 |
32530
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
292 if (unit_offset) { |
32531
48ee2c151251
100l, add forgotten FFMIN to fix small reads (-nocache) with bd:// protocol.
reimar
parents:
32530
diff
changeset
|
293 int decrypt_len = FFMIN(len, BD_UNIT_SIZE - unit_offset); |
32530
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
294 av_aes_crypt(bd->aescbc, buf, buf, decrypt_len / 16, bd->iv.u8, 1); |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
295 buf += decrypt_len; |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
296 len -= decrypt_len; |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
297 } |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
298 while (len) { |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
299 int decrypt_len = FFMIN(len, BD_UNIT_SIZE); |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
300 // 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
|
301 key enc_seed; |
31845 | 302 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
|
303 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
304 // 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
|
305 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
|
306 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
307 // perform xor |
31846
3f84ee74869d
Minor optimization/simplification and document the alignment requirements
reimar
parents:
31845
diff
changeset
|
308 enc_seed.u64[0] ^= AV_RN64A(buf); |
3f84ee74869d
Minor optimization/simplification and document the alignment requirements
reimar
parents:
31845
diff
changeset
|
309 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
|
310 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
311 // 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
|
312 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
|
313 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
314 // decrypt |
31840
af68430bf5de
whitespace cosmetics: prettyprinting, move statements to the next line.
diego
parents:
31836
diff
changeset
|
315 av_aes_crypt(bd->aescbc, &buf[16], &buf[16], |
32530
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
316 (decrypt_len - 16) / 16, bd->iv.u8, 1); |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
317 buf += decrypt_len; |
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
318 len -= decrypt_len; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
319 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
320 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
321 bd->pos += read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
322 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
323 return read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
324 } |
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 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
|
327 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
328 int read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
329 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
|
330 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
331 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
|
332 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
333 s->pos = bd->pos; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
334 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
335 return read_len; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
336 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
337 |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
338 static int is_video_type(int type) |
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 switch (type) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
341 case 1: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
342 case 2: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
343 case 0x10: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
344 case 0x1b: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
345 case 0xD1: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
346 case 0xEA: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
347 return 1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
348 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
349 return 0; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
350 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
351 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
352 static int is_audio_type(int type) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
353 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
354 switch (type) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
355 case 3: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
356 case 4: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
357 case 0x0f: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
358 case 0x11: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
359 case 0x81: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
360 case 0x8A: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
361 case 0x82: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
362 case 0x85: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
363 case 0x86: |
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 static int is_sub_type(int type) |
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 switch (type) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
372 case 0x90: |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
373 return 1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
374 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
375 return 0; |
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 |
34648
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
378 static const char *bd_lang_from_id(stream_t *s, int id) |
31877
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 struct bd_priv *bd = s->priv; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
381 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
382 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
383 if (bd->lang_maps[i].id == id) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
384 return bd->lang_maps[i].lang_name; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
385 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
386 return NULL; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
387 } |
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 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
|
390 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
391 struct bd_priv *bd = s->priv; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
392 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
393 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
394 if (is_audio_type(bd->lang_maps[i].type) && |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
395 strstr(bd->lang_maps[i].lang_name, lang)) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
396 return bd->lang_maps[i].id; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
397 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
398 return -1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
399 } |
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 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
|
402 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
403 struct bd_priv *bd = s->priv; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
404 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
405 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
406 if (is_sub_type(bd->lang_maps[i].type) && |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
407 strstr(bd->lang_maps[i].lang_name, lang)) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
408 return bd->lang_maps[i].id; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
409 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
410 return -1; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
411 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
412 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
413 static void get_clipinf(struct bd_priv *bd) |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
414 { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
415 int i; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
416 int langmap_offset, index_offset, end_offset; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
417 char filename[PATH_MAX]; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
418 stream_t *file; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
419 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
420 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
|
421 file = open_stream(filename, NULL, NULL); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
422 if (!file) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
423 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
|
424 return; |
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 if (stream_read_qword(file) != AV_RB64("HDMV0200")) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
427 mp_msg(MSGT_OPEN, MSGL_ERR, "Unknown clipinf format\n"); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
428 return; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
429 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
430 stream_read_dword(file); // unknown offset |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
431 langmap_offset = stream_read_dword(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
432 index_offset = stream_read_dword(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
433 end_offset = stream_read_dword(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
434 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
435 // read language <-> stream id mappings |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
436 stream_seek(file, langmap_offset); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
437 stream_read_dword(file); // size |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
438 stream_skip(file, 8); // unknown |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
439 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
|
440 stream_read_char(file); // unknown |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
441 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
442 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
|
443 for (i = 0; i < bd->nr_lang_maps; i++) { |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
444 int type; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
445 bd->lang_maps[i].id = stream_read_word(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
446 stream_read_char(file); // unknown |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
447 type = stream_read_char(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
448 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
|
449 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
|
450 bd->lang_maps[i].type = type; |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
451 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
|
452 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
453 |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
454 free_stream(file); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
455 } |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
456 |
34648
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
457 static int bd_stream_control(stream_t *s, int cmd, void *arg) |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
458 { |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
459 switch (cmd) { |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
460 case STREAM_CTRL_GET_LANG: |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
461 { |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
462 struct stream_lang_req *req = arg; |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
463 const char *lang = bd_lang_from_id(s, req->id); |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
464 if (!lang) |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
465 return STREAM_ERROR; |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
466 av_strlcpy(req->buf, lang, sizeof(req->buf)); |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
467 return STREAM_OK; |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
468 } |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
469 } |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
470 return STREAM_UNSUPPORTED; |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
471 } |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
472 |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
473 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
|
474 { |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
475 char filename[PATH_MAX]; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
476 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
477 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
|
478 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
|
479 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
480 if (p->device) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
481 bd->device = p->device; |
32326
4189a8951568
Use bluray_device variable also for bd:// instead of dvd_device
reimar
parents:
31917
diff
changeset
|
482 else if (bluray_device) |
4189a8951568
Use bluray_device variable also for bd:// instead of dvd_device
reimar
parents:
31917
diff
changeset
|
483 bd->device = bluray_device; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
484 else |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
485 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
|
486 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
487 s->sector_size = BD_UNIT_SIZE; |
32530
4157eca96947
Support reading larger blocks in one go for bd:// protocol.
reimar
parents:
32519
diff
changeset
|
488 s->read_chunk = 32 * BD_UNIT_SIZE; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
489 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
|
490 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
|
491 s->seek = bd_stream_seek; |
34648
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34174
diff
changeset
|
492 s->control = bd_stream_control; |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
493 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
|
494 s->start_pos = 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
495 s->priv = bd; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
496 s->type = STREAMTYPE_BD; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
497 s->url = strdup("bd://"); |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
498 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
499 bd->pos = 0; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
500 bd->title = p->title; |
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 // 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
|
503 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
|
504 return STREAM_ERROR; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
505 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
506 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
|
507 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
|
508 |
31847 | 509 // set up AES key from uk |
510 av_aes_init(bd->aeseed, bd->uks.keys[0].u8, 128, 0); | |
511 | |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
512 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
|
513 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
|
514 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
|
515 if (!bd->title_file) |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
516 return STREAM_ERROR; |
31872
66b846665274
Use the stream functions instead of the fopen/fread/fclose interface
reimar
parents:
31848
diff
changeset
|
517 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
|
518 |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
519 get_clipinf(bd); |
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31874
diff
changeset
|
520 |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
521 return STREAM_OK; |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
522 } |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
523 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
524 const stream_info_t stream_info_bd = { |
32519 | 525 "Blu-ray", |
31836
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
526 "bd", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
527 "cRTrn13", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
528 "", |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
529 bd_stream_open, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
530 { "bd", NULL }, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
531 &stream_opts, |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
532 1 |
dcd515ac5f6c
Add support for bd:// streams as a test for a part of the AACS algorithm.
reimar
parents:
diff
changeset
|
533 }; |