Commit 9f97f7c5 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '93c04e09'

* commit '93c04e09':
  Expose metadata found in onCuePoint events in .flv files.
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents f01a1281 93c04e09
...@@ -458,45 +458,47 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, ...@@ -458,45 +458,47 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
return -1; return -1;
} }
// only look for metadata values when we are not nested and key != NULL if (key) {
if (depth == 1 && key) { // stream info doesn't live any deeper than the first object
acodec = astream ? astream->codec : NULL; if (depth == 1) {
vcodec = vstream ? vstream->codec : NULL; acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
if (amf_type == AMF_DATA_TYPE_NUMBER ||
amf_type == AMF_DATA_TYPE_BOOL) { if (amf_type == AMF_DATA_TYPE_NUMBER ||
if (!strcmp(key, "duration")) amf_type == AMF_DATA_TYPE_BOOL) {
s->duration = num_val * AV_TIME_BASE; if (!strcmp(key, "duration"))
else if (!strcmp(key, "videodatarate") && vcodec && s->duration = num_val * AV_TIME_BASE;
0 <= (int)(num_val * 1024.0)) else if (!strcmp(key, "videodatarate") && vcodec &&
vcodec->bit_rate = num_val * 1024.0; 0 <= (int)(num_val * 1024.0))
else if (!strcmp(key, "audiodatarate") && acodec && vcodec->bit_rate = num_val * 1024.0;
0 <= (int)(num_val * 1024.0)) else if (!strcmp(key, "audiodatarate") && acodec &&
acodec->bit_rate = num_val * 1024.0; 0 <= (int)(num_val * 1024.0))
else if (!strcmp(key, "datastream")) { acodec->bit_rate = num_val * 1024.0;
AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA); else if (!strcmp(key, "datastream")) {
if (!st) AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
return AVERROR(ENOMEM); if (!st)
st->codec->codec_id = AV_CODEC_ID_TEXT; return AVERROR(ENOMEM);
} else if (flv->trust_metadata) { st->codec->codec_id = AV_CODEC_ID_TEXT;
if (!strcmp(key, "videocodecid") && vcodec) { } else if (flv->trust_metadata) {
flv_set_video_codec(s, vstream, num_val, 0); if (!strcmp(key, "videocodecid") && vcodec) {
} else if (!strcmp(key, "audiocodecid") && acodec) { flv_set_video_codec(s, vstream, num_val, 0);
int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET; } else if (!strcmp(key, "audiocodecid") && acodec) {
flv_set_audio_codec(s, astream, acodec, id); int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
} else if (!strcmp(key, "audiosamplerate") && acodec) { flv_set_audio_codec(s, astream, acodec, id);
acodec->sample_rate = num_val; } else if (!strcmp(key, "audiosamplerate") && acodec) {
} else if (!strcmp(key, "audiosamplesize") && acodec) { acodec->sample_rate = num_val;
acodec->bits_per_coded_sample = num_val; } else if (!strcmp(key, "audiosamplesize") && acodec) {
} else if (!strcmp(key, "stereo") && acodec) { acodec->bits_per_coded_sample = num_val;
acodec->channels = num_val + 1; } else if (!strcmp(key, "stereo") && acodec) {
acodec->channel_layout = acodec->channels == 2 ? acodec->channels = num_val + 1;
AV_CH_LAYOUT_STEREO : acodec->channel_layout = acodec->channels == 2 ?
AV_CH_LAYOUT_MONO; AV_CH_LAYOUT_STEREO :
} else if (!strcmp(key, "width") && vcodec) { AV_CH_LAYOUT_MONO;
vcodec->width = num_val; } else if (!strcmp(key, "width") && vcodec) {
} else if (!strcmp(key, "height") && vcodec) { vcodec->width = num_val;
vcodec->height = num_val; } else if (!strcmp(key, "height") && vcodec) {
vcodec->height = num_val;
}
} }
} }
} }
...@@ -560,7 +562,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) ...@@ -560,7 +562,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
if (!strcmp(buffer, "onTextData")) if (!strcmp(buffer, "onTextData"))
return 1; return 1;
if (strcmp(buffer, "onMetaData")) if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint"))
return -1; return -1;
// find the streams now so that amf_parse_object doesn't need to do // find the streams now so that amf_parse_object doesn't need to do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment