On 12/05/12 12:35, Martin Storsjö wrote:

> Is this "type => 'foo', text => 'bar'" structure standardized anywhere
> or used by any other existing application?

> I agree with Anton, this isn't really nice. Some define for the track
> ids for audio/video/data might be useful.

We need to decide what to do with track ids so far I just followed the
current layout.


> Unrelated, please split it to a separate patch

Uff, ok.


>> +                    av_log(s, AV_LOG_ERROR,
>> +                                "codec not compatible with flv\n");
>> +                    return AVERROR_INVALIDDATA;
> 
> Indentation off

Right


> Is this a convention used by anything else other than this muxer/demuxer
> pair?

I'm sure not.

>>     while ((tag = av_dict_get(s->metadata, "", tag,
>> AV_DICT_IGNORE_SUFFIX))) {
>>         put_amf_string(pb, tag->key);
>>         avio_w8(pb, AMF_DATA_TYPE_STRING);
>> @@ -396,7 +419,8 @@ static int flv_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>     else
>>         flags_size= 1;
>>
>> -    if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
>> +    switch (enc->codec_type) {
>> +    case AVMEDIA_TYPE_VIDEO:
>>         avio_w8(pb, FLV_TAG_TYPE_VIDEO);
>>
>>         flags = enc->codec_tag;
>> @@ -406,15 +430,22 @@ static int flv_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>         }
>>
>>         flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
>> FLV_FRAME_INTER;
>> -    } else {
>> -        assert(enc->codec_type == AVMEDIA_TYPE_AUDIO);
>> +    break;
>> +    case AVMEDIA_TYPE_AUDIO:
>>         flags = get_audio_flags(s, enc);
>>
>>         assert(size);
>>
>>         avio_w8(pb, FLV_TAG_TYPE_AUDIO);
>> -    }
>> +    break;
>>
>> +    case AVMEDIA_TYPE_DATA:
>> +        avio_w8(pb, FLV_TAG_TYPE_META);
>> +    break;
>> +    default:
>> +        return AVERROR(EINVAL);
>> +    break;
>> +    }
>>     if (enc->codec_id == CODEC_ID_H264) {
>>         /* check if extradata looks like MP4 */
>>         if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1) {
>> @@ -446,7 +477,31 @@ static int flv_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>     avio_wb24(pb,ts);
>>     avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
>>     avio_wb24(pb,flv->reserved);
>> +
>> +    if (enc->codec_type == AVMEDIA_TYPE_DATA) {
>> +        int data_size;
>> +        int metadata_size_pos = avio_tell(pb);
>> +        avio_w8(pb, AMF_DATA_TYPE_STRING);
>> +        put_amf_string(pb, "onTextData");
>> +        avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
>> +        avio_wb32(pb, 2);
>> +        put_amf_string(pb, "type");
>> +        avio_w8(pb, AMF_DATA_TYPE_STRING);
>> +        put_amf_string(pb, "Text");
>> +        put_amf_string(pb, "text");
>> +        avio_w8(pb, AMF_DATA_TYPE_STRING);
>> +        put_amf_string(pb, pkt->data);
>> +        put_amf_string(pb, "");
>> +        avio_w8(pb, AMF_END_OF_OBJECT);
>> +        /* write total size of tag */
>> +        data_size = avio_tell(pb) - metadata_size_pos;
>> +        avio_seek(pb, metadata_size_pos - 10, SEEK_SET);
>> +        avio_wb24(pb, data_size);
>> +        avio_seek(pb, data_size + 10 - 3, SEEK_CUR);
>> +        avio_wb32(pb, data_size + 11);
>> +    } else {
>>     avio_w8(pb,flags);
>> +
>>     if (enc->codec_id == CODEC_ID_VP6)
> 
> Unrelated extra line :-)

Ok..

> Other than the nitpicks and things to clarify, the actual code is ok for
> me.

Let me split it more.


-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to