| 493 | }; |
| 494 | |
| 495 | static struct rendition *new_rendition(HLSContext *c, struct rendition_info *info, |
| 496 | const char *url_base) |
| 497 | { |
| 498 | struct rendition *rend; |
| 499 | enum AVMediaType type = AVMEDIA_TYPE_UNKNOWN; |
| 500 | char *characteristic; |
| 501 | char *chr_ptr; |
| 502 | char *saveptr; |
| 503 | |
| 504 | if (!strcmp(info->type, "AUDIO")) |
| 505 | type = AVMEDIA_TYPE_AUDIO; |
| 506 | else if (!strcmp(info->type, "VIDEO")) |
| 507 | type = AVMEDIA_TYPE_VIDEO; |
| 508 | else if (!strcmp(info->type, "SUBTITLES")) |
| 509 | type = AVMEDIA_TYPE_SUBTITLE; |
| 510 | else if (!strcmp(info->type, "CLOSED-CAPTIONS")) |
| 511 | /* CLOSED-CAPTIONS is ignored since we do not support CEA-608 CC in |
| 512 | * AVC SEI RBSP anyway */ |
| 513 | return NULL; |
| 514 | |
| 515 | if (type == AVMEDIA_TYPE_UNKNOWN) { |
| 516 | av_log(c->ctx, AV_LOG_WARNING, "Can't support the type: %s\n", info->type); |
| 517 | return NULL; |
| 518 | } |
| 519 | |
| 520 | /* URI is mandatory for subtitles as per spec */ |
| 521 | if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0]) { |
| 522 | av_log(c->ctx, AV_LOG_ERROR, "The URI tag is REQUIRED for subtitle.\n"); |
| 523 | return NULL; |
| 524 | } |
| 525 | |
| 526 | rend = av_mallocz(sizeof(struct rendition)); |
| 527 | if (!rend) |
| 528 | return NULL; |
| 529 | |
| 530 | dynarray_add(&c->renditions, &c->n_renditions, rend); |
| 531 | |
| 532 | rend->type = type; |
| 533 | strcpy(rend->group_id, info->group_id); |
| 534 | strcpy(rend->language, info->language); |
| 535 | strcpy(rend->name, info->name); |
| 536 | |
| 537 | /* add the playlist if this is an external rendition */ |
| 538 | if (info->uri[0]) { |
| 539 | rend->playlist = new_playlist(c, info->uri, url_base); |
| 540 | if (rend->playlist) { |
| 541 | if (type == AVMEDIA_TYPE_SUBTITLE) { |
| 542 | rend->playlist->is_subtitle = 1; |
| 543 | rend->playlist->is_id3_timestamped = 0; |
| 544 | } |
| 545 | dynarray_add(&rend->playlist->renditions, |
| 546 | &rend->playlist->n_renditions, rend); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | if (info->assoc_language[0]) { |
| 551 | size_t langlen = strlen(rend->language); |
| 552 | if (langlen < sizeof(rend->language) - 3) { |
no test coverage detected