MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / amf_parse_object

Function amf_parse_object

libavformat/flvdec.c:616–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616static int amf_parse_object(AVFormatContext *s, AVStream *astream,
617 AVStream *vstream, const char *key,
618 int64_t max_pos, int depth)
619{
620 AVCodecParameters *apar, *vpar;
621 FLVContext *flv = s->priv_data;
622 AVIOContext *ioc;
623 AMFDataType amf_type;
624 char str_val[1024];
625 double num_val;
626 amf_date date;
627
628 if (depth > MAX_DEPTH)
629 return AVERROR_PATCHWELCOME;
630
631 num_val = 0;
632 ioc = s->pb;
633 if (avio_feof(ioc))
634 return AVERROR_EOF;
635 amf_type = avio_r8(ioc);
636
637 switch (amf_type) {
638 case AMF_DATA_TYPE_NUMBER:
639 num_val = av_int2double(avio_rb64(ioc));
640 break;
641 case AMF_DATA_TYPE_BOOL:
642 num_val = avio_r8(ioc);
643 break;
644 case AMF_DATA_TYPE_STRING:
645 if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) {
646 av_log(s, AV_LOG_ERROR, "AMF_DATA_TYPE_STRING parsing failed\n");
647 return -1;
648 }
649 break;
650 case AMF_DATA_TYPE_OBJECT:
651 if (key &&
652 (ioc->seekable & AVIO_SEEKABLE_NORMAL) &&
653 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
654 if (parse_keyframes_index(s, ioc, max_pos) < 0)
655 av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
656 else
657 add_keyframes_index(s);
658 while (avio_tell(ioc) < max_pos - 2 &&
659 amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
660 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
661 depth + 1) < 0)
662 return -1; // if we couldn't skip, bomb out.
663 if (avio_r8(ioc) != AMF_END_OF_OBJECT) {
664 av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_OBJECT\n");
665 return -1;
666 }
667 break;
668 case AMF_DATA_TYPE_NULL:
669 case AMF_DATA_TYPE_UNDEFINED:
670 case AMF_DATA_TYPE_UNSUPPORTED:
671 break; // these take up no additional space
672 case AMF_DATA_TYPE_MIXEDARRAY:
673 {

Callers 2

flv_read_metabodyFunction · 0.85

Calls 15

avio_feofFunction · 0.85
avio_r8Function · 0.85
av_int2doubleFunction · 0.85
avio_rb64Function · 0.85
amf_get_stringFunction · 0.85
av_logFunction · 0.85
parse_keyframes_indexFunction · 0.85
add_keyframes_indexFunction · 0.85
avio_tellFunction · 0.85
avio_skipFunction · 0.85
avio_rb32Function · 0.85
avio_rb16Function · 0.85

Tested by

no test coverage detected