Originally committed as revision 3031 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2004/04/19 00:26:57... | ... |
@@ -26,6 +26,7 @@ |
26 | 26 |
typedef struct FLVFrame { |
27 | 27 |
int type; |
28 | 28 |
int timestamp; |
29 |
+ int reserved; |
|
29 | 30 |
int flags; |
30 | 31 |
uint8_t *data; |
31 | 32 |
int size; |
... | ... |
@@ -38,6 +39,7 @@ typedef struct FLVContext { |
38 | 38 |
int initDelay; |
39 | 39 |
int64_t sampleCount; |
40 | 40 |
int64_t frameCount; |
41 |
+ int reserved; |
|
41 | 42 |
FLVFrame *frames; |
42 | 43 |
} FLVContext; |
43 | 44 |
|
... | ... |
@@ -119,10 +121,18 @@ static int mp3info(void *data, int *byteSize, int *samplesPerFrame, int *sampleR |
119 | 119 |
} |
120 | 120 |
#endif // CONFIG_MP3LAME |
121 | 121 |
|
122 |
+static void put_be24(ByteIOContext *pb, int value) |
|
123 |
+{ |
|
124 |
+ put_byte(pb, (value>>16) & 0xFF ); |
|
125 |
+ put_byte(pb, (value>> 8) & 0xFF ); |
|
126 |
+ put_byte(pb, (value>> 0) & 0xFF ); |
|
127 |
+} |
|
128 |
+ |
|
122 | 129 |
static int flv_write_header(AVFormatContext *s) |
123 | 130 |
{ |
124 | 131 |
ByteIOContext *pb = &s->pb; |
125 | 132 |
FLVContext *flv = s->priv_data; |
133 |
+ int i; |
|
126 | 134 |
|
127 | 135 |
av_set_pts_info(s, 24, 1, 1000); /* 24 bit pts in ms */ |
128 | 136 |
|
... | ... |
@@ -138,17 +148,22 @@ static int flv_write_header(AVFormatContext *s) |
138 | 138 |
put_byte(pb,0); // delayed write |
139 | 139 |
put_be32(pb,9); |
140 | 140 |
put_be32(pb,0); |
141 |
+ |
|
142 |
+ for(i=0; i<s->nb_streams; i++){ |
|
143 |
+ AVCodecContext *enc = &s->streams[i]->codec; |
|
144 |
+ if(enc->codec_tag == 5){ |
|
145 |
+ put_byte(pb,8); // message type |
|
146 |
+ put_be24(pb,0); // include flags |
|
147 |
+ put_be24(pb,0); // time stamp |
|
148 |
+ put_be32(pb,0); // reserved |
|
149 |
+ put_be32(pb,11); // size |
|
150 |
+ flv->reserved=5; |
|
151 |
+ } |
|
152 |
+ } |
|
141 | 153 |
|
142 | 154 |
return 0; |
143 | 155 |
} |
144 | 156 |
|
145 |
-static void put_be24(ByteIOContext *pb, int value) |
|
146 |
-{ |
|
147 |
- put_byte(pb, (value>>16) & 0xFF ); |
|
148 |
- put_byte(pb, (value>> 8) & 0xFF ); |
|
149 |
- put_byte(pb, (value>> 0) & 0xFF ); |
|
150 |
-} |
|
151 |
- |
|
152 | 157 |
static void InsertSorted(FLVContext *flv, FLVFrame *frame) |
153 | 158 |
{ |
154 | 159 |
if ( !flv->frames ) { |
... | ... |
@@ -157,7 +172,7 @@ static void InsertSorted(FLVContext *flv, FLVFrame *frame) |
157 | 157 |
FLVFrame *trav = flv->frames; |
158 | 158 |
FLVFrame *prev = 0; |
159 | 159 |
for (;trav;) { |
160 |
- if ( trav->timestamp >= frame->timestamp ) { |
|
160 |
+ if ( trav->timestamp > frame->timestamp) { |
|
161 | 161 |
frame->next = trav; |
162 | 162 |
if ( prev ) { |
163 | 163 |
prev->next = frame; |
... | ... |
@@ -177,10 +192,11 @@ static void InsertSorted(FLVContext *flv, FLVFrame *frame) |
177 | 177 |
|
178 | 178 |
static void DumpFrame(ByteIOContext *pb, FLVFrame *frame) |
179 | 179 |
{ |
180 |
+//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); |
|
180 | 181 |
put_byte(pb,frame->type); // message type |
181 | 182 |
put_be24(pb,frame->size+1); // include flags |
182 | 183 |
put_be24(pb,frame->timestamp); // time stamp |
183 |
- put_be32(pb,0); // reserved |
|
184 |
+ put_be32(pb,frame->reserved); // reserved |
|
184 | 185 |
put_byte(pb,frame->flags); |
185 | 186 |
put_buffer(pb, frame->data, frame->size); |
186 | 187 |
put_be32(pb,frame->size+1+11); // reserved |
... | ... |
@@ -236,6 +252,7 @@ static int flv_write_packet(AVFormatContext *s, int stream_index, |
236 | 236 |
frame->size = size; |
237 | 237 |
frame->data = av_malloc(size); |
238 | 238 |
frame->timestamp = timestamp; |
239 |
+ frame->reserved= flv->reserved; |
|
239 | 240 |
memcpy(frame->data,buf,size); |
240 | 241 |
|
241 | 242 |
// av_log(s, AV_LOG_DEBUG, "type:%d pts: %lld size:%d\n", enc->codec_type, timestamp, size); |