Remove compatibility workarounds
[x264.git] / output / flv_bytestream.h
blob868221153ec8cc626eab28d6d5536a949fd296e7
1 /*****************************************************************************
2 * flv_bytestream.h: flv muxer utilities
3 *****************************************************************************
4 * Copyright (C) 2009-2019 x264 project
6 * Authors: Kieran Kunhya <kieran@kunhya.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 * This program is also available under a commercial proprietary license.
23 * For more information, contact us at licensing@x264.com.
24 *****************************************************************************/
26 #ifndef X264_FLV_BYTESTREAM_H
27 #define X264_FLV_BYTESTREAM_H
29 /* offsets for packed values */
30 #define FLV_AUDIO_SAMPLESSIZE_OFFSET 1
31 #define FLV_AUDIO_SAMPLERATE_OFFSET 2
32 #define FLV_AUDIO_CODECID_OFFSET 4
34 #define FLV_VIDEO_FRAMETYPE_OFFSET 4
36 /* bitmasks to isolate specific values */
37 #define FLV_AUDIO_CHANNEL_MASK 0x01
38 #define FLV_AUDIO_SAMPLESIZE_MASK 0x02
39 #define FLV_AUDIO_SAMPLERATE_MASK 0x0c
40 #define FLV_AUDIO_CODECID_MASK 0xf0
42 #define FLV_VIDEO_CODECID_MASK 0x0f
43 #define FLV_VIDEO_FRAMETYPE_MASK 0xf0
45 #define AMF_END_OF_OBJECT 0x09
47 enum
49 FLV_HEADER_FLAG_HASVIDEO = 1,
50 FLV_HEADER_FLAG_HASAUDIO = 4,
53 enum
55 FLV_TAG_TYPE_AUDIO = 0x08,
56 FLV_TAG_TYPE_VIDEO = 0x09,
57 FLV_TAG_TYPE_META = 0x12,
60 enum
62 FLV_MONO = 0,
63 FLV_STEREO = 1,
66 enum
68 FLV_SAMPLESSIZE_8BIT = 0,
69 FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET,
72 enum
74 FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */
75 FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET,
76 FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET,
77 FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET,
80 enum
82 FLV_CODECID_MP3 = 2 << FLV_AUDIO_CODECID_OFFSET,
83 FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET,
86 enum
88 FLV_CODECID_H264 = 7,
91 enum
93 FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET,
94 FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET,
97 typedef enum
99 AMF_DATA_TYPE_NUMBER = 0x00,
100 AMF_DATA_TYPE_BOOL = 0x01,
101 AMF_DATA_TYPE_STRING = 0x02,
102 AMF_DATA_TYPE_OBJECT = 0x03,
103 AMF_DATA_TYPE_NULL = 0x05,
104 AMF_DATA_TYPE_UNDEFINED = 0x06,
105 AMF_DATA_TYPE_REFERENCE = 0x07,
106 AMF_DATA_TYPE_MIXEDARRAY = 0x08,
107 AMF_DATA_TYPE_OBJECT_END = 0x09,
108 AMF_DATA_TYPE_ARRAY = 0x0a,
109 AMF_DATA_TYPE_DATE = 0x0b,
110 AMF_DATA_TYPE_LONG_STRING = 0x0c,
111 AMF_DATA_TYPE_UNSUPPORTED = 0x0d,
112 } AMFDataType;
114 typedef struct flv_buffer
116 uint8_t *data;
117 unsigned d_cur;
118 unsigned d_max;
119 FILE *fp;
120 uint64_t d_total;
121 } flv_buffer;
123 flv_buffer *flv_create_writer( const char *filename );
124 int flv_append_data( flv_buffer *c, uint8_t *data, unsigned size );
125 int flv_write_byte( flv_buffer *c, uint8_t *byte );
126 int flv_flush_data( flv_buffer *c );
127 void flv_rewrite_amf_be24( flv_buffer *c, unsigned length, unsigned start );
129 uint64_t flv_dbl2int( double value );
130 void flv_put_byte( flv_buffer *c, uint8_t b );
131 void flv_put_be32( flv_buffer *c, uint32_t val );
132 void flv_put_be64( flv_buffer *c, uint64_t val );
133 void flv_put_be16( flv_buffer *c, uint16_t val );
134 void flv_put_be24( flv_buffer *c, uint32_t val );
135 void flv_put_tag( flv_buffer *c, const char *tag );
136 void flv_put_amf_string( flv_buffer *c, const char *str );
137 void flv_put_amf_double( flv_buffer *c, double d );
139 #endif