| 1358 | } |
| 1359 | |
| 1360 | static int read_key(HLSContext *c, struct playlist *pls, struct segment *seg) |
| 1361 | { |
| 1362 | AVIOContext *pb = NULL; |
| 1363 | |
| 1364 | int ret = open_url(pls->parent, &pb, seg->key, &c->avio_opts, NULL, NULL); |
| 1365 | if (ret < 0) { |
| 1366 | av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s, %s\n", |
| 1367 | seg->key, av_err2str(ret)); |
| 1368 | return ret; |
| 1369 | } |
| 1370 | |
| 1371 | ret = avio_read(pb, pls->key, sizeof(pls->key)); |
| 1372 | ff_format_io_close(pls->parent, &pb); |
| 1373 | if (ret != sizeof(pls->key)) { |
| 1374 | if (ret < 0) { |
| 1375 | av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s, %s\n", |
| 1376 | seg->key, av_err2str(ret)); |
| 1377 | } else { |
| 1378 | av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s, read bytes %d != %zu\n", |
| 1379 | seg->key, ret, sizeof(pls->key)); |
| 1380 | ret = AVERROR_INVALIDDATA; |
| 1381 | } |
| 1382 | |
| 1383 | return ret; |
| 1384 | } |
| 1385 | |
| 1386 | av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url)); |
| 1387 | |
| 1388 | return 0; |
| 1389 | } |
| 1390 | |
| 1391 | static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, AVIOContext **in) |
| 1392 | { |
no test coverage detected