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 #ifdef OHOS_H265_DEMUXER 46 #define FLV_VIDEO_FRAMETYPE_MASK 0x70 47 #else 48 #define FLV_VIDEO_FRAMETYPE_MASK 0xf0 49 #endif 50 51 #define AMF_END_OF_OBJECT 0x09 52 53 #define KEYFRAMES_TAG "keyframes" 54 #define KEYFRAMES_TIMESTAMP_TAG "times" 55 #define KEYFRAMES_BYTEOFFSET_TAG "filepositions" 56 57 58 enum { 59 FLV_HEADER_FLAG_HASVIDEO = 1, 60 FLV_HEADER_FLAG_HASAUDIO = 4, 61 }; 62 63 enum FlvTagType { 64 FLV_TAG_TYPE_AUDIO = 0x08, 65 FLV_TAG_TYPE_VIDEO = 0x09, 66 FLV_TAG_TYPE_META = 0x12, 67 }; 68 69 enum { 70 FLV_STREAM_TYPE_VIDEO, 71 FLV_STREAM_TYPE_AUDIO, 72 FLV_STREAM_TYPE_SUBTITLE, 73 FLV_STREAM_TYPE_DATA, 74 FLV_STREAM_TYPE_NB, 75 }; 76 77 enum { 78 FLV_MONO = 0, 79 FLV_STEREO = 1, 80 }; 81 82 enum { 83 FLV_SAMPLESSIZE_8BIT = 0, 84 FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET, 85 }; 86 87 enum { 88 FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */ 89 FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET, 90 FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET, 91 FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET, 92 }; 93 94 enum { 95 FLV_CODECID_PCM = 0, 96 FLV_CODECID_ADPCM = 1 << FLV_AUDIO_CODECID_OFFSET, 97 FLV_CODECID_MP3 = 2 << FLV_AUDIO_CODECID_OFFSET, 98 FLV_CODECID_PCM_LE = 3 << FLV_AUDIO_CODECID_OFFSET, 99 FLV_CODECID_NELLYMOSER_16KHZ_MONO = 4 << FLV_AUDIO_CODECID_OFFSET, 100 FLV_CODECID_NELLYMOSER_8KHZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET, 101 FLV_CODECID_NELLYMOSER = 6 << FLV_AUDIO_CODECID_OFFSET, 102 FLV_CODECID_PCM_ALAW = 7 << FLV_AUDIO_CODECID_OFFSET, 103 FLV_CODECID_PCM_MULAW = 8 << FLV_AUDIO_CODECID_OFFSET, 104 FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET, 105 FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET, 106 }; 107 108 enum { 109 FLV_CODECID_H263 = 2, 110 FLV_CODECID_SCREEN = 3, 111 FLV_CODECID_VP6 = 4, 112 FLV_CODECID_VP6A = 5, 113 FLV_CODECID_SCREEN2 = 6, 114 FLV_CODECID_H264 = 7, 115 FLV_CODECID_REALH263= 8, 116 FLV_CODECID_MPEG4 = 9, 117 #ifdef OHOS_H265_DEMUXER 118 FLV_CODECID_HEVC = 12, 119 #endif 120 }; 121 122 #ifdef OHOS_H265_DEMUXER 123 enum { 124 PacketTypeSequenceStart = 0, 125 PacketTypeCodedFrames = 1, 126 PacketTypeSequenceEnd = 2, 127 PacketTypeCodedFramesX = 3, 128 PacketTypeMetadata = 4, 129 PacketTypeMPEG2TSSequenceStart = 5, 130 }; 131 #endif 132 133 enum { 134 FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< key frame (for AVC, a seekable frame) 135 FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< inter frame (for AVC, a non-seekable frame) 136 FLV_FRAME_DISP_INTER = 3 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< disposable inter frame (H.263 only) 137 FLV_FRAME_GENERATED_KEY = 4 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< generated key frame (reserved for server use only) 138 FLV_FRAME_VIDEO_INFO_CMD = 5 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< video info/command frame 139 }; 140 141 typedef enum { 142 AMF_DATA_TYPE_NUMBER = 0x00, 143 AMF_DATA_TYPE_BOOL = 0x01, 144 AMF_DATA_TYPE_STRING = 0x02, 145 AMF_DATA_TYPE_OBJECT = 0x03, 146 AMF_DATA_TYPE_NULL = 0x05, 147 AMF_DATA_TYPE_UNDEFINED = 0x06, 148 AMF_DATA_TYPE_REFERENCE = 0x07, 149 AMF_DATA_TYPE_MIXEDARRAY = 0x08, 150 AMF_DATA_TYPE_OBJECT_END = 0x09, 151 AMF_DATA_TYPE_ARRAY = 0x0a, 152 AMF_DATA_TYPE_DATE = 0x0b, 153 AMF_DATA_TYPE_LONG_STRING = 0x0c, 154 AMF_DATA_TYPE_UNSUPPORTED = 0x0d, 155 } AMFDataType; 156 157 #endif /* AVFORMAT_FLV_H */ 158