1 /*
2 * BluRay (libbluray) protocol
3 *
4 * Copyright (c) 2012 Petri Hintukainen <phintuka <at> users.sourceforge.net>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <libbluray/bluray.h>
24
28
29 #define BLURAY_PROTO_PREFIX "bluray:"
30 #define MIN_PLAYLIST_LENGTH 180 /* 3 min */
31
34
36
40 /*int region;*/
42
43 #define OFFSET(x) offsetof(BlurayContext, x)
48 /*{"region", "bluray player region code (1 = region A, 2 = region B, 4 = region C)", OFFSET(region), AV_OPT_TYPE_INT, { .i64=0 }, 0, 3, AV_OPT_FLAG_DECODING_PARAM },*/
50 };
51
57 };
58
59
61 {
63 const BLURAY_DISC_INFO *disc_info;
64
65 disc_info = bd_get_disc_info(bd->
bd);
66 if (!disc_info) {
68 return -1;
69 }
70
71 if (!disc_info->bluray_detected) {
73 return -1;
74 }
75
76 /* AACS */
77 if (disc_info->aacs_detected && !disc_info->aacs_handled) {
78 if (!disc_info->libaacs_detected) {
80 "Media stream encrypted with AACS, install and configure libaacs\n");
81 } else {
83 }
84 return -1;
85 }
86
87 /* BD+ */
88 if (disc_info->bdplus_detected && !disc_info->bdplus_handled) {
89 /*
90 if (!disc_info->libbdplus_detected) {
91 av_log(h, AV_LOG_ERROR,
92 "Media stream encrypted with BD+, install and configure libbdplus");
93 } else {
94 */
96 /*}*/
97 return -1;
98 }
99
100 return 0;
101 }
102
104 {
108 }
109
110 return 0;
111 }
112
114 {
116 int num_title_idx;
117 const char *diskname = path;
118
120
121 bd->
bd = bd_open(diskname,
NULL);
125 }
126
127 /* check if disc can be played */
130 }
131
132 /* setup player registers */
133 /* region code has no effect without menus
134 if (bd->region > 0 && bd->region < 5) {
135 av_log(h, AV_LOG_INFO, "setting region code to %d (%c)\n", bd->region, 'A' + (bd->region - 1));
136 bd_set_player_setting(bd->bd, BLURAY_PLAYER_SETTING_REGION_CODE, bd->region);
137 }
138 */
139
140 /* load title list */
143 if (num_title_idx < 1) {
145 }
146
147 /* if playlist was not given, select longest playlist */
151 for (
i = 0;
i < num_title_idx;
i++) {
152 BLURAY_TITLE_INFO *
info = bd_get_title_info(bd->
bd,
i, 0);
153
156 ((
int)(
info->duration / 90000) / 3600),
157 ((
int)(
info->duration / 90000) % 3600) / 60,
158 ((
int)(
info->duration / 90000) % 60));
159
163 }
164
165 bd_free_title_info(
info);
166 }
168 }
169
170 /* select playlist */
171 if (bd_select_playlist(bd->
bd, bd->
playlist) <= 0) {
174 }
175
176 /* select angle */
177 if (bd->
angle >= 0) {
178 bd_select_angle(bd->
bd, bd->
angle);
179 }
180
181 /* select chapter */
183 bd_seek_chapter(bd->
bd, bd->
chapter - 1);
184 }
185
186 return 0;
187 }
188
190 {
193
194 if (!bd || !bd->
bd) {
196 }
197
199
201 }
202
204 {
206
207 if (!bd || !bd->
bd) {
209 }
210
211 switch (whence) {
212 case SEEK_SET:
213 case SEEK_CUR:
214 case SEEK_END:
215 return bd_seek(bd->
bd,
pos);
216
218 return bd_get_title_size(bd->
bd);
219 }
220
223 }
224
225
234 };