On Thu, Apr 14, 2011 at 01:32:39PM +0200, Luca Barbato wrote:
> Since the container is relatively simple adding it is straightforward.
> ---
> libavformat/flvenc.c | 43 +++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 41 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index 7ffe995..51180c9 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -173,7 +173,7 @@ static int flv_write_header(AVFormatContext *s)
> {
> AVIOContext *pb = s->pb;
> FLVContext *flv = s->priv_data;
> - AVCodecContext *audio_enc = NULL, *video_enc = NULL;
> + AVCodecContext *audio_enc = NULL, *video_enc = NULL, *data_enc = NULL;
> int i;
> double framerate = 0.0;
> int metadata_size_pos, data_size;
> @@ -200,6 +200,14 @@ static int flv_write_header(AVFormatContext *s)
> audio_enc = enc;
> if (get_audio_flags(enc)<0) return -1;
> break;
> + case AVMEDIA_TYPE_DATA:
> + if (enc->codec_id != CODEC_ID_TEXT) {
> + av_log(enc, AV_LOG_ERROR,
> + "codec not compatible with flv\n");
> + return -1;
> + }
> + data_enc = enc;
> + break;
> default:
> av_log(enc, AV_LOG_ERROR, "codec not compatible with flv\n");
> return -1;
> @@ -241,7 +249,7 @@ static int flv_write_header(AVFormatContext *s)
>
> /* mixed array (hash) with size and string/type/data tuples */
> avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
> - avio_wb32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and
> file size
> + avio_wb32(pb, 5*!!video_enc + 5*!!audio_enc + 2 + 1*!!data_enc); // +2
> for duration and file size
>
> put_amf_string(pb, "duration");
> flv->duration_offset= avio_tell(pb);
> @@ -287,6 +295,11 @@ static int flv_write_header(AVFormatContext *s)
> put_amf_string(pb, tag->value);
> }
>
> + if (data_enc) {
> + put_amf_string(pb, "data-stream");
> + put_amf_double(pb, data_enc->codec_id);
> + }
> +
I don't think it's good idea to put lavc internal codec ID here, the rest
looks ok.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel