win32 fixes
[libav.git] / libav / rm.c
CommitLineData
de6d9b64
FB
1/*
2 * "Real" compatible mux and demux.
3 * Copyright (c) 2000, 2001 Gerard Lantau.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
de6d9b64
FB
19#include "avformat.h"
20
21/* in ms */
22#define BUFFER_DURATION 0
23
24typedef struct {
25 int nb_packets;
26 int packet_total_size;
27 int packet_max_size;
28 /* codec related output */
29 int bit_rate;
30 float frame_rate;
31 int nb_frames; /* current frame number */
32 int total_frames; /* total number of frames */
33 int num;
34 AVCodecContext *enc;
35} StreamInfo;
36
37typedef struct {
38 StreamInfo streams[2];
39 StreamInfo *audio_stream, *video_stream;
40 int data_pos; /* position of the data after the header */
41 int nb_packets;
42} RMContext;
43
44static void put_str(ByteIOContext *s, const char *tag)
45{
46 put_be16(s,strlen(tag));
47 while (*tag) {
48 put_byte(s, *tag++);
49 }
50}
51
52static void put_str8(ByteIOContext *s, const char *tag)
53{
54 put_byte(s, strlen(tag));
55 while (*tag) {
56 put_byte(s, *tag++);
57 }
58}
59
60static void rv10_write_header(AVFormatContext *ctx,
61 int data_size, int index_pos)
62{
63 RMContext *rm = ctx->priv_data;
64 ByteIOContext *s = &ctx->pb;
65 StreamInfo *stream;
66 unsigned char *data_offset_ptr, *start_ptr;
67 const char *desc, *mimetype;
68 int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
69 int bit_rate, v, duration, flags, data_pos;
70
71 start_ptr = s->buf_ptr;
72
73 put_tag(s, ".RMF");
74 put_be32(s,18); /* header size */
75 put_be16(s,0);
76 put_be32(s,0);
77 put_be32(s,4 + ctx->nb_streams); /* num headers */
78
79 put_tag(s,"PROP");
80 put_be32(s, 50);
81 put_be16(s, 0);
82 packet_max_size = 0;
83 packet_total_size = 0;
84 nb_packets = 0;
85 bit_rate = 0;
86 duration = 0;
87 for(i=0;i<ctx->nb_streams;i++) {
88 StreamInfo *stream = &rm->streams[i];
89 bit_rate += stream->bit_rate;
90 if (stream->packet_max_size > packet_max_size)
91 packet_max_size = stream->packet_max_size;
92 nb_packets += stream->nb_packets;
93 packet_total_size += stream->packet_total_size;
94 /* select maximum duration */
95 v = (int) (1000.0 * (float)stream->total_frames / stream->frame_rate);
96 if (v > duration)
97 duration = v;
98 }
99 put_be32(s, bit_rate); /* max bit rate */
100 put_be32(s, bit_rate); /* avg bit rate */
101 put_be32(s, packet_max_size); /* max packet size */
102 if (nb_packets > 0)
103 packet_avg_size = packet_total_size / nb_packets;
104 else
105 packet_avg_size = 0;
106 put_be32(s, packet_avg_size); /* avg packet size */
107 put_be32(s, nb_packets); /* num packets */
108 put_be32(s, duration); /* duration */
109 put_be32(s, BUFFER_DURATION); /* preroll */
110 put_be32(s, index_pos); /* index offset */
111 /* computation of data the data offset */
112 data_offset_ptr = s->buf_ptr;
113 put_be32(s, 0); /* data offset : will be patched after */
114 put_be16(s, ctx->nb_streams); /* num streams */
115 flags = 1 | 2; /* save allowed & perfect play */
116 if (url_is_streamed(s))
117 flags |= 4; /* live broadcast */
118 put_be16(s, flags);
119
120 /* comments */
121
122 put_tag(s,"CONT");
123 size = strlen(ctx->title) + strlen(ctx->author) + strlen(ctx->copyright) +
124 strlen(ctx->comment) + 4 * 2 + 10;
125 put_be32(s,size);
126 put_be16(s,0);
127 put_str(s, ctx->title);
128 put_str(s, ctx->author);
129 put_str(s, ctx->copyright);
130 put_str(s, ctx->comment);
131
132 for(i=0;i<ctx->nb_streams;i++) {
133 int codec_data_size;
134
135 stream = &rm->streams[i];
136
137 if (stream->enc->codec_type == CODEC_TYPE_AUDIO) {
138 desc = "The Audio Stream";
139 mimetype = "audio/x-pn-realaudio";
140 codec_data_size = 73;
141 } else {
142 desc = "The Video Stream";
143 mimetype = "video/x-pn-realvideo";
144 codec_data_size = 34;
145 }
146
147 put_tag(s,"MDPR");
148 size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size;
149 put_be32(s, size);
150 put_be16(s, 0);
151
152 put_be16(s, i); /* stream number */
153 put_be32(s, stream->bit_rate); /* max bit rate */
154 put_be32(s, stream->bit_rate); /* avg bit rate */
155 put_be32(s, stream->packet_max_size); /* max packet size */
156 if (stream->nb_packets > 0)
157 packet_avg_size = stream->packet_total_size /
158 stream->nb_packets;
159 else
160 packet_avg_size = 0;
161 put_be32(s, packet_avg_size); /* avg packet size */
162 put_be32(s, 0); /* start time */
163 put_be32(s, BUFFER_DURATION); /* preroll */
164 /* duration */
165 put_be32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
166 put_str8(s, desc);
167 put_str8(s, mimetype);
168 put_be32(s, codec_data_size);
169
170 if (stream->enc->codec_type == CODEC_TYPE_AUDIO) {
171 int coded_frame_size, fscode, sample_rate;
172 sample_rate = stream->enc->sample_rate;
173 coded_frame_size = (stream->enc->bit_rate *
174 stream->enc->frame_size) / (8 * sample_rate);
175 /* audio codec info */
176 put_tag(s, ".ra");
177 put_byte(s, 0xfd);
178 put_be32(s, 0x00040000); /* version */
179 put_tag(s, ".ra4");
180 put_be32(s, 0x01b53530); /* stream length */
181 put_be16(s, 4); /* unknown */
182 put_be32(s, 0x39); /* header size */
183
184 switch(sample_rate) {
185 case 48000:
186 case 24000:
187 case 12000:
188 fscode = 1;
189 break;
190 default:
191 case 44100:
192 case 22050:
193 case 11025:
194 fscode = 2;
195 break;
196 case 32000:
197 case 16000:
198 case 8000:
199 fscode = 3;
200 }
201 put_be16(s, fscode); /* codec additional info, for AC3, seems
202 to be a frequency code */
203 /* special hack to compensate rounding errors... */
204 if (coded_frame_size == 557)
205 coded_frame_size--;
206 put_be32(s, coded_frame_size); /* frame length */
207 put_be32(s, 0x51540); /* unknown */
208 put_be32(s, 0x249f0); /* unknown */
209 put_be32(s, 0x249f0); /* unknown */
210 put_be16(s, 0x01);
211 /* frame length : seems to be very important */
212 put_be16(s, coded_frame_size);
213 put_be32(s, 0); /* unknown */
214 put_be16(s, stream->enc->sample_rate); /* sample rate */
215 put_be32(s, 0x10); /* unknown */
216 put_be16(s, stream->enc->channels);
217 put_str8(s, "Int0"); /* codec name */
218 put_str8(s, "dnet"); /* codec name */
219 put_be16(s, 0); /* title length */
220 put_be16(s, 0); /* author length */
221 put_be16(s, 0); /* copyright length */
222 put_byte(s, 0); /* end of header */
223 } else {
224 /* video codec info */
225 put_be32(s,34); /* size */
226 put_tag(s,"VIDORV10");
227 put_be16(s, stream->enc->width);
228 put_be16(s, stream->enc->height);
229 put_be16(s, 24); /* frames per seconds ? */
230 put_be32(s,0); /* unknown meaning */
231 put_be16(s, 12); /* unknown meaning */
232 put_be32(s,0); /* unknown meaning */
233 put_be16(s, 8); /* unknown meaning */
234 /* Seems to be the codec version: only use basic H263. The next
235 versions seems to add a diffential DC coding as in
236 MPEG... nothing new under the sun */
237 put_be32(s,0x10000000);
238 //put_be32(s,0x10003000);
239 }
240 }
241
242 /* patch data offset field */
243 data_pos = s->buf_ptr - start_ptr;
244 rm->data_pos = data_pos;
245 data_offset_ptr[0] = data_pos >> 24;
246 data_offset_ptr[1] = data_pos >> 16;
247 data_offset_ptr[2] = data_pos >> 8;
248 data_offset_ptr[3] = data_pos;
249
250 /* data stream */
251 put_tag(s,"DATA");
252 put_be32(s,data_size + 10 + 8);
253 put_be16(s,0);
254
255 put_be32(s, nb_packets); /* number of packets */
256 put_be32(s,0); /* next data header */
257}
258
259static void write_packet_header(AVFormatContext *ctx, StreamInfo *stream,
260 int length, int key_frame)
261{
262 int timestamp;
263 ByteIOContext *s = &ctx->pb;
264
265 stream->nb_packets++;
266 stream->packet_total_size += length;
267 if (length > stream->packet_max_size)
268 stream->packet_max_size = length;
269
270 put_be16(s,0); /* version */
271 put_be16(s,length + 12);
272 put_be16(s, stream->num); /* stream number */
273 timestamp = (1000 * (float)stream->nb_frames) / stream->frame_rate;
274 put_be32(s, timestamp); /* timestamp */
275 put_byte(s, 0); /* reserved */
276 put_byte(s, key_frame ? 2 : 0); /* flags */
277}
278
279static int rm_write_header(AVFormatContext *s)
280{
281 StreamInfo *stream;
282 RMContext *rm;
283 int n;
284 AVCodecContext *codec;
285
286 rm = malloc(sizeof(RMContext));
287 if (!rm)
288 return -1;
289 memset(rm, 0, sizeof(RMContext));
290 s->priv_data = rm;
291
292 for(n=0;n<s->nb_streams;n++) {
293 s->streams[n]->id = n;
294 codec = &s->streams[n]->codec;
295 stream = &rm->streams[n];
296 memset(stream, 0, sizeof(StreamInfo));
297 stream->num = n;
298 stream->bit_rate = codec->bit_rate;
299 stream->enc = codec;
300
301 switch(codec->codec_type) {
302 case CODEC_TYPE_AUDIO:
303 rm->audio_stream = stream;
304 stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size;
305 /* XXX: dummy values */
306 stream->packet_max_size = 1024;
307 stream->nb_packets = 0;
308 stream->total_frames = stream->nb_packets;
309 break;
310 case CODEC_TYPE_VIDEO:
311 rm->video_stream = stream;
312 stream->frame_rate = (float)codec->frame_rate / (float)FRAME_RATE_BASE;
313 /* XXX: dummy values */
314 stream->packet_max_size = 4096;
315 stream->nb_packets = 0;
316 stream->total_frames = stream->nb_packets;
317 break;
318 }
319 }
320
321 rv10_write_header(s, 0, 0);
322 put_flush_packet(&s->pb);
323 return 0;
324}
325
326static int rm_write_audio(AVFormatContext *s, UINT8 *buf, int size)
327{
8be1c656 328 UINT8 *buf1;
de6d9b64
FB
329 RMContext *rm = s->priv_data;
330 ByteIOContext *pb = &s->pb;
331 StreamInfo *stream = rm->audio_stream;
332 int i;
333
8be1c656
FB
334 /* XXX: suppress this malloc */
335 buf1= (UINT8*) malloc( size * sizeof(UINT8) );
336
de6d9b64
FB
337 write_packet_header(s, stream, size, stream->enc->key_frame);
338
339 /* for AC3, the words seems to be reversed */
340 for(i=0;i<size;i+=2) {
341 buf1[i] = buf[i+1];
342 buf1[i+1] = buf[i];
343 }
344 put_buffer(pb, buf1, size);
345 put_flush_packet(pb);
346 stream->nb_frames++;
8be1c656 347 free(buf1);
de6d9b64
FB
348 return 0;
349}
350
351static int rm_write_video(AVFormatContext *s, UINT8 *buf, int size)
352{
353 RMContext *rm = s->priv_data;
354 ByteIOContext *pb = &s->pb;
355 StreamInfo *stream = rm->video_stream;
356 int key_frame = stream->enc->key_frame;
357
358 /* XXX: this is incorrect: should be a parameter */
359
360 /* Well, I spent some time finding the meaning of these bits. I am
361 not sure I understood everything, but it works !! */
362#if 1
363 write_packet_header(s, stream, size + 7, key_frame);
364 /* bit 7: '1' if final packet of a frame converted in several packets */
365 put_byte(pb, 0x81);
366 /* bit 7: '1' if I frame. bits 6..0 : sequence number in current
367 frame starting from 1 */
368 if (key_frame) {
369 put_byte(pb, 0x81);
370 } else {
371 put_byte(pb, 0x01);
372 }
373 put_be16(pb, 0x4000 | (size)); /* total frame size */
374 put_be16(pb, 0x4000 | (size)); /* offset from the start or the end */
375#else
376 /* full frame */
377 write_packet_header(s, size + 6);
378 put_byte(pb, 0xc0);
379 put_be16(pb, 0x4000 | size); /* total frame size */
380 put_be16(pb, 0x4000 + packet_number * 126); /* position in stream */
381#endif
382 put_byte(pb, stream->nb_frames & 0xff);
383
384 put_buffer(pb, buf, size);
385 put_flush_packet(pb);
386
387 stream->nb_frames++;
388 return 0;
389}
390
391static int rm_write_packet(AVFormatContext *s, int stream_index,
392 UINT8 *buf, int size)
393{
394 if (s->streams[stream_index]->codec.codec_type ==
395 CODEC_TYPE_AUDIO)
396 return rm_write_audio(s, buf, size);
397 else
398 return rm_write_video(s, buf, size);
399}
400
401static int rm_write_trailer(AVFormatContext *s)
402{
403 RMContext *rm = s->priv_data;
404 int data_size, index_pos, i;
405 ByteIOContext *pb = &s->pb;
406
407 if (!url_is_streamed(&s->pb)) {
408 /* end of file: finish to write header */
409 index_pos = url_fseek(pb, 0, SEEK_CUR);
410 data_size = index_pos - rm->data_pos;
411
412 /* index */
413 put_tag(pb, "INDX");
414 put_be32(pb, 10 + 10 * s->nb_streams);
415 put_be16(pb, 0);
416
417 for(i=0;i<s->nb_streams;i++) {
418 put_be32(pb, 0); /* zero indices */
419 put_be16(pb, i); /* stream number */
420 put_be32(pb, 0); /* next index */
421 }
422 /* undocumented end header */
423 put_be32(pb, 0);
424 put_be32(pb, 0);
425
426 url_fseek(pb, 0, SEEK_SET);
427 for(i=0;i<s->nb_streams;i++)
428 rm->streams[i].total_frames = rm->streams[i].nb_frames;
429 rv10_write_header(s, data_size, index_pos);
430 } else {
431 /* undocumented end header */
432 put_be32(pb, 0);
433 put_be32(pb, 0);
434 }
435 put_flush_packet(pb);
436
437 free(rm);
438 return 0;
439}
440
441/***************************************************/
442
443static void get_str(ByteIOContext *pb, char *buf, int buf_size)
444{
445 int len, i;
446 char *q;
447
448 len = get_be16(pb);
449 q = buf;
450 for(i=0;i<len;i++) {
451 if (i < buf_size - 1)
452 *q++ = get_byte(pb);
453 }
454 *q = '\0';
455}
456
457static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
458{
459 int len, i;
460 char *q;
461
462 len = get_byte(pb);
463 q = buf;
464 for(i=0;i<len;i++) {
465 if (i < buf_size - 1)
466 *q++ = get_byte(pb);
467 }
468 *q = '\0';
469}
470
471static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
472{
473 RMContext *rm;
474 AVStream *st;
475 ByteIOContext *pb = &s->pb;
476 unsigned int tag, v;
477 int tag_size, size, codec_data_size, i;
478 INT64 codec_pos;
479 unsigned int h263_hack_version;
480 char buf[128];
481
482 if (get_le32(pb) != MKTAG('.', 'R', 'M', 'F'))
483 return -EIO;
484 rm = av_mallocz(sizeof(RMContext));
485 if (!rm)
486 return -ENOMEM;
487 s->priv_data = rm;
488
489 get_be32(pb); /* header size */
490 get_be16(pb);
491 get_be32(pb);
492 get_be32(pb); /* number of headers */
493
494 for(;;) {
495 if (url_feof(pb))
496 goto fail;
497 tag = get_le32(pb);
498 tag_size = get_be32(pb);
499 get_be16(pb);
500#if 0
501 printf("tag=%c%c%c%c (%08x) size=%d\n",
502 (tag) & 0xff,
503 (tag >> 8) & 0xff,
504 (tag >> 16) & 0xff,
505 (tag >> 24) & 0xff,
506 tag,
507 tag_size);
508#endif
509 if (tag_size < 10)
510 goto fail;
511 switch(tag) {
512 case MKTAG('P', 'R', 'O', 'P'):
513 /* file header */
514 get_be32(pb); /* max bit rate */
515 get_be32(pb); /* avg bit rate */
516 get_be32(pb); /* max packet size */
517 get_be32(pb); /* avg packet size */
518 get_be32(pb); /* nb packets */
519 get_be32(pb); /* duration */
520 get_be32(pb); /* preroll */
521 get_be32(pb); /* index offset */
522 get_be32(pb); /* data offset */
523 get_be16(pb); /* nb streams */
524 get_be16(pb); /* flags */
525 break;
526 case MKTAG('C', 'O', 'N', 'T'):
527 get_str(pb, s->title, sizeof(s->title));
528 get_str(pb, s->author, sizeof(s->author));
529 get_str(pb, s->copyright, sizeof(s->copyright));
530 get_str(pb, s->comment, sizeof(s->comment));
531 break;
532 case MKTAG('M', 'D', 'P', 'R'):
533 st = av_mallocz(sizeof(AVStream));
534 if (!st)
535 goto fail;
536 s->streams[s->nb_streams++] = st;
537 st->id = get_be16(pb);
538 get_be32(pb); /* max bit rate */
539 st->codec.bit_rate = get_be32(pb); /* bit rate */
540 get_be32(pb); /* max packet size */
541 get_be32(pb); /* avg packet size */
542 get_be32(pb); /* start time */
543 get_be32(pb); /* preroll */
544 get_be32(pb); /* duration */
545 get_str8(pb, buf, sizeof(buf)); /* desc */
546 get_str8(pb, buf, sizeof(buf)); /* mimetype */
547 codec_data_size = get_be32(pb);
548 codec_pos = url_ftell(pb);
549
550 v = get_be32(pb);
551 if (v == MKTAG(0xfd, 'a', 'r', '.')) {
552 /* ra type header */
553 get_be32(pb); /* version */
554 get_be32(pb); /* .ra4 */
555 get_be32(pb);
556 get_be16(pb);
557 get_be32(pb); /* header size */
558 get_be16(pb); /* add codec info */
559 get_be32(pb); /* coded frame size */
560 get_be32(pb); /* ??? */
561 get_be32(pb); /* ??? */
562 get_be32(pb); /* ??? */
563 get_be16(pb); /* 1 */
564 get_be16(pb); /* coded frame size */
565 get_be32(pb);
566 st->codec.sample_rate = get_be16(pb);
567 get_be32(pb);
568 st->codec.channels = get_be16(pb);
569 get_str8(pb, buf, sizeof(buf)); /* desc */
570 get_str8(pb, buf, sizeof(buf)); /* desc */
571 st->codec.codec_type = CODEC_TYPE_AUDIO;
572 if (!strcmp(buf, "dnet")) {
573 st->codec.codec_id = CODEC_ID_AC3;
574 } else {
575 st->codec.codec_id = CODEC_ID_NONE;
576 nstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name),
577 buf);
578 }
579 } else {
580 if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
581 fail1:
582 fprintf(stderr, "Unsupported video codec\n");
583 goto fail;
584 }
585 st->codec.codec_tag = get_le32(pb);
586 if (st->codec.codec_tag != MKTAG('R', 'V', '1', '0'))
587 goto fail1;
588 st->codec.width = get_be16(pb);
589 st->codec.height = get_be16(pb);
590 st->codec.frame_rate = get_be16(pb) * FRAME_RATE_BASE;
591 st->codec.codec_type = CODEC_TYPE_VIDEO;
592 get_be32(pb);
593 get_be16(pb);
594 get_be32(pb);
595 get_be16(pb);
596 /* modification of h263 codec version (!) */
597 h263_hack_version = get_be32(pb);
598 switch(h263_hack_version) {
599 case 0x10000000:
600 st->codec.sub_id = 0;
601 st->codec.codec_id = CODEC_ID_RV10;
602 break;
603 case 0x10003000:
604 case 0x10003001:
605 st->codec.sub_id = 3;
606 st->codec.codec_id = CODEC_ID_RV10;
607 break;
608 default:
609 /* not handled */
610 st->codec.codec_id = CODEC_ID_NONE;
611 break;
612 }
613 }
614 /* skip codec info */
615 size = url_ftell(pb) - codec_pos;
616 url_fskip(pb, codec_data_size - size);
617 break;
618 case MKTAG('D', 'A', 'T', 'A'):
619 goto header_end;
620 default:
621 /* unknown tag: skip it */
622 url_fskip(pb, tag_size - 10);
623 break;
624 }
625 }
626 header_end:
627 rm->nb_packets = get_be32(pb); /* number of packets */
628 get_be32(pb); /* next data header */
629 return 0;
630
631 fail:
632 for(i=0;i<s->nb_streams;i++) {
633 free(s->streams[i]);
634 }
635 return -EIO;
636}
637
638static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
639{
640 RMContext *rm = s->priv_data;
641 ByteIOContext *pb = &s->pb;
642 AVStream *st;
643 int len, num, timestamp, i, tmp, j;
644 UINT8 *ptr;
645
646 redo:
647 if (rm->nb_packets == 0)
648 return -EIO;
649 get_be16(pb);
650 len = get_be16(pb);
651 if (len < 12)
652 return -EIO;
653 num = get_be16(pb);
654 timestamp = get_be32(pb);
655 get_byte(pb); /* reserved */
656 get_byte(pb); /* flags */
657 rm->nb_packets--;
658 len -= 12;
659
660 st = NULL;
661 for(i=0;i<s->nb_streams;i++) {
662 st = s->streams[i];
663 if (num == st->id)
664 break;
665 }
666 if (i == s->nb_streams) {
667 /* skip packet if unknown number */
668 url_fskip(pb, len);
669 goto redo;
670 }
671
672 av_new_packet(pkt, len);
673 pkt->stream_index = i;
674 get_buffer(pb, pkt->data, len);
675 /* for AC3, needs to swap bytes */
676 if (st->codec.codec_id == CODEC_ID_AC3) {
677 ptr = pkt->data;
678 for(j=0;j<len;j+=2) {
679 tmp = ptr[0];
680 ptr[0] = ptr[1];
681 ptr[1] = tmp;
682 ptr += 2;
683 }
684 }
685 return 0;
686}
687
688static int rm_read_close(AVFormatContext *s)
689{
690 RMContext *rm = s->priv_data;
691 free(rm);
692 return 0;
693}
694
695AVFormat rm_format = {
696 "rm",
697 "rm format",
698 "audio/x-pn-realaudio",
699 "rm,ra",
700 CODEC_ID_AC3,
701 CODEC_ID_RV10,
702 rm_write_header,
703 rm_write_packet,
704 rm_write_trailer,
705
706 rm_read_header,
707 rm_read_packet,
708 rm_read_close,
709};