• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * FLV common header
3  *
4  * Copyright (c) 2006 The FFmpeg Project
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg 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 GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * FLV common header
26  */
27 
28 #ifndef AVFORMAT_FLV_H
29 #define AVFORMAT_FLV_H
30 
31 /* offsets for packed values */
32 #define FLV_AUDIO_SAMPLESSIZE_OFFSET 1
33 #define FLV_AUDIO_SAMPLERATE_OFFSET  2
34 #define FLV_AUDIO_CODECID_OFFSET     4
35 
36 #define FLV_VIDEO_FRAMETYPE_OFFSET   4
37 
38 /* bitmasks to isolate specific values */
39 #define FLV_AUDIO_CHANNEL_MASK    0x01
40 #define FLV_AUDIO_SAMPLESIZE_MASK 0x02
41 #define FLV_AUDIO_SAMPLERATE_MASK 0x0c
42 #define FLV_AUDIO_CODECID_MASK    0xf0
43 
44 #define FLV_VIDEO_CODECID_MASK    0x0f
45 #define FLV_VIDEO_FRAMETYPE_MASK  0xf0
46 
47 #define AMF_END_OF_OBJECT         0x09
48 
49 #define KEYFRAMES_TAG            "keyframes"
50 #define KEYFRAMES_TIMESTAMP_TAG  "times"
51 #define KEYFRAMES_BYTEOFFSET_TAG "filepositions"
52 
53 
54 enum {
55     FLV_HEADER_FLAG_HASVIDEO = 1,
56     FLV_HEADER_FLAG_HASAUDIO = 4,
57 };
58 
59 enum FlvTagType {
60     FLV_TAG_TYPE_AUDIO = 0x08,
61     FLV_TAG_TYPE_VIDEO = 0x09,
62     FLV_TAG_TYPE_META  = 0x12,
63 };
64 
65 enum {
66     FLV_STREAM_TYPE_VIDEO,
67     FLV_STREAM_TYPE_AUDIO,
68     FLV_STREAM_TYPE_SUBTITLE,
69     FLV_STREAM_TYPE_DATA,
70     FLV_STREAM_TYPE_NB,
71 };
72 
73 enum {
74     FLV_MONO   = 0,
75     FLV_STEREO = 1,
76 };
77 
78 enum {
79     FLV_SAMPLESSIZE_8BIT  = 0,
80     FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET,
81 };
82 
83 enum {
84     FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */
85     FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET,
86     FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET,
87     FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET,
88 };
89 
90 enum {
91     FLV_CODECID_PCM                  = 0,
92     FLV_CODECID_ADPCM                = 1 << FLV_AUDIO_CODECID_OFFSET,
93     FLV_CODECID_MP3                  = 2 << FLV_AUDIO_CODECID_OFFSET,
94     FLV_CODECID_PCM_LE               = 3 << FLV_AUDIO_CODECID_OFFSET,
95     FLV_CODECID_NELLYMOSER_16KHZ_MONO = 4 << FLV_AUDIO_CODECID_OFFSET,
96     FLV_CODECID_NELLYMOSER_8KHZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
97     FLV_CODECID_NELLYMOSER           = 6 << FLV_AUDIO_CODECID_OFFSET,
98     FLV_CODECID_PCM_ALAW             = 7 << FLV_AUDIO_CODECID_OFFSET,
99     FLV_CODECID_PCM_MULAW            = 8 << FLV_AUDIO_CODECID_OFFSET,
100     FLV_CODECID_AAC                  = 10<< FLV_AUDIO_CODECID_OFFSET,
101     FLV_CODECID_SPEEX                = 11<< FLV_AUDIO_CODECID_OFFSET,
102 };
103 
104 enum {
105     FLV_CODECID_H263    = 2,
106     FLV_CODECID_SCREEN  = 3,
107     FLV_CODECID_VP6     = 4,
108     FLV_CODECID_VP6A    = 5,
109     FLV_CODECID_SCREEN2 = 6,
110     FLV_CODECID_H264    = 7,
111     FLV_CODECID_REALH263= 8,
112     FLV_CODECID_MPEG4   = 9,
113 };
114 
115 enum {
116     FLV_FRAME_KEY            = 1 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< key frame (for AVC, a seekable frame)
117     FLV_FRAME_INTER          = 2 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< inter frame (for AVC, a non-seekable frame)
118     FLV_FRAME_DISP_INTER     = 3 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< disposable inter frame (H.263 only)
119     FLV_FRAME_GENERATED_KEY  = 4 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< generated key frame (reserved for server use only)
120     FLV_FRAME_VIDEO_INFO_CMD = 5 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< video info/command frame
121 };
122 
123 typedef enum {
124     AMF_DATA_TYPE_NUMBER      = 0x00,
125     AMF_DATA_TYPE_BOOL        = 0x01,
126     AMF_DATA_TYPE_STRING      = 0x02,
127     AMF_DATA_TYPE_OBJECT      = 0x03,
128     AMF_DATA_TYPE_NULL        = 0x05,
129     AMF_DATA_TYPE_UNDEFINED   = 0x06,
130     AMF_DATA_TYPE_REFERENCE   = 0x07,
131     AMF_DATA_TYPE_MIXEDARRAY  = 0x08,
132     AMF_DATA_TYPE_OBJECT_END  = 0x09,
133     AMF_DATA_TYPE_ARRAY       = 0x0a,
134     AMF_DATA_TYPE_DATE        = 0x0b,
135     AMF_DATA_TYPE_LONG_STRING = 0x0c,
136     AMF_DATA_TYPE_UNSUPPORTED = 0x0d,
137 } AMFDataType;
138 
139 #endif /* AVFORMAT_FLV_H */
140