Mercurial > libavformat.hg
changeset 446:35447449b8b4 libavformat
various fixes
author | michael |
---|---|
date | Sun, 18 Apr 2004 15:26:57 +0000 |
parents | c1f88671135b |
children | 94aa265c18b9 |
files | flvenc.c |
diffstat | 1 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/flvenc.c Sat Apr 17 12:04:59 2004 +0000 +++ b/flvenc.c Sun Apr 18 15:26:57 2004 +0000 @@ -26,6 +26,7 @@ typedef struct FLVFrame { int type; int timestamp; + int reserved; int flags; uint8_t *data; int size; @@ -38,6 +39,7 @@ int initDelay; int64_t sampleCount; int64_t frameCount; + int reserved; FLVFrame *frames; } FLVContext; @@ -119,10 +121,18 @@ } #endif // CONFIG_MP3LAME +static void put_be24(ByteIOContext *pb, int value) +{ + put_byte(pb, (value>>16) & 0xFF ); + put_byte(pb, (value>> 8) & 0xFF ); + put_byte(pb, (value>> 0) & 0xFF ); +} + static int flv_write_header(AVFormatContext *s) { ByteIOContext *pb = &s->pb; FLVContext *flv = s->priv_data; + int i; av_set_pts_info(s, 24, 1, 1000); /* 24 bit pts in ms */ @@ -138,17 +148,22 @@ put_byte(pb,0); // delayed write put_be32(pb,9); put_be32(pb,0); + + for(i=0; i<s->nb_streams; i++){ + AVCodecContext *enc = &s->streams[i]->codec; + if(enc->codec_tag == 5){ + put_byte(pb,8); // message type + put_be24(pb,0); // include flags + put_be24(pb,0); // time stamp + put_be32(pb,0); // reserved + put_be32(pb,11); // size + flv->reserved=5; + } + } return 0; } -static void put_be24(ByteIOContext *pb, int value) -{ - put_byte(pb, (value>>16) & 0xFF ); - put_byte(pb, (value>> 8) & 0xFF ); - put_byte(pb, (value>> 0) & 0xFF ); -} - static void InsertSorted(FLVContext *flv, FLVFrame *frame) { if ( !flv->frames ) { @@ -157,7 +172,7 @@ FLVFrame *trav = flv->frames; FLVFrame *prev = 0; for (;trav;) { - if ( trav->timestamp >= frame->timestamp ) { + if ( trav->timestamp > frame->timestamp) { frame->next = trav; if ( prev ) { prev->next = frame; @@ -177,10 +192,11 @@ static void DumpFrame(ByteIOContext *pb, FLVFrame *frame) { +//av_log(NULL, AV_LOG_DEBUG, "T%02X S%d T%d R%d F%02X ... R%08X\n", frame->type, frame->size+1, frame->timestamp, 0, frame->flags, frame->size+1+11); put_byte(pb,frame->type); // message type put_be24(pb,frame->size+1); // include flags put_be24(pb,frame->timestamp); // time stamp - put_be32(pb,0); // reserved + put_be32(pb,frame->reserved); // reserved put_byte(pb,frame->flags); put_buffer(pb, frame->data, frame->size); put_be32(pb,frame->size+1+11); // reserved @@ -236,6 +252,7 @@ frame->size = size; frame->data = av_malloc(size); frame->timestamp = timestamp; + frame->reserved= flv->reserved; memcpy(frame->data,buf,size); // av_log(s, AV_LOG_DEBUG, "type:%d pts: %lld size:%d\n", enc->codec_type, timestamp, size);