flv.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. * @file
  24. * FLV common header
  25. */
  26. #ifndef AVFORMAT_FLV_H
  27. #define AVFORMAT_FLV_H
  28. /* offsets for packed values */
  29. #define FLV_AUDIO_SAMPLESSIZE_OFFSET 1
  30. #define FLV_AUDIO_SAMPLERATE_OFFSET 2
  31. #define FLV_AUDIO_CODECID_OFFSET 4
  32. #define FLV_VIDEO_FRAMETYPE_OFFSET 4
  33. /* bitmasks to isolate specific values */
  34. #define FLV_AUDIO_CHANNEL_MASK 0x01
  35. #define FLV_AUDIO_SAMPLESIZE_MASK 0x02
  36. #define FLV_AUDIO_SAMPLERATE_MASK 0x0c
  37. #define FLV_AUDIO_CODECID_MASK 0xf0
  38. #define FLV_VIDEO_CODECID_MASK 0x0f
  39. #define FLV_VIDEO_FRAMETYPE_MASK 0xf0
  40. #define AMF_END_OF_OBJECT 0x09
  41. #define KEYFRAMES_TAG "keyframes"
  42. #define KEYFRAMES_TIMESTAMP_TAG "times"
  43. #define KEYFRAMES_BYTEOFFSET_TAG "filepositions"
  44. enum {
  45. FLV_HEADER_FLAG_HASVIDEO = 1,
  46. FLV_HEADER_FLAG_HASAUDIO = 4,
  47. };
  48. enum FlvTagType {
  49. FLV_TAG_TYPE_AUDIO = 0x08,
  50. FLV_TAG_TYPE_VIDEO = 0x09,
  51. FLV_TAG_TYPE_META = 0x12,
  52. };
  53. enum {
  54. FLV_STREAM_TYPE_VIDEO,
  55. FLV_STREAM_TYPE_AUDIO,
  56. FLV_STREAM_TYPE_SUBTITLE,
  57. FLV_STREAM_TYPE_DATA,
  58. FLV_STREAM_TYPE_NB,
  59. };
  60. enum {
  61. FLV_MONO = 0,
  62. FLV_STEREO = 1,
  63. };
  64. enum {
  65. FLV_SAMPLESSIZE_8BIT = 0,
  66. FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET,
  67. };
  68. enum {
  69. FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */
  70. FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET,
  71. FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET,
  72. FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET,
  73. };
  74. enum {
  75. FLV_CODECID_PCM = 0,
  76. FLV_CODECID_ADPCM = 1 << FLV_AUDIO_CODECID_OFFSET,
  77. FLV_CODECID_MP3 = 2 << FLV_AUDIO_CODECID_OFFSET,
  78. FLV_CODECID_PCM_LE = 3 << FLV_AUDIO_CODECID_OFFSET,
  79. FLV_CODECID_NELLYMOSER_16KHZ_MONO = 4 << FLV_AUDIO_CODECID_OFFSET,
  80. FLV_CODECID_NELLYMOSER_8KHZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
  81. FLV_CODECID_NELLYMOSER = 6 << FLV_AUDIO_CODECID_OFFSET,
  82. FLV_CODECID_PCM_ALAW = 7 << FLV_AUDIO_CODECID_OFFSET,
  83. FLV_CODECID_PCM_MULAW = 8 << FLV_AUDIO_CODECID_OFFSET,
  84. FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET,
  85. FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET,
  86. };
  87. enum {
  88. FLV_CODECID_H263 = 2,
  89. FLV_CODECID_SCREEN = 3,
  90. FLV_CODECID_VP6 = 4,
  91. FLV_CODECID_VP6A = 5,
  92. FLV_CODECID_SCREEN2 = 6,
  93. FLV_CODECID_H264 = 7,
  94. FLV_CODECID_REALH263= 8,
  95. FLV_CODECID_MPEG4 = 9,
  96. };
  97. enum {
  98. FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< key frame (for AVC, a seekable frame)
  99. FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< inter frame (for AVC, a non-seekable frame)
  100. FLV_FRAME_DISP_INTER = 3 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< disposable inter frame (H.263 only)
  101. FLV_FRAME_GENERATED_KEY = 4 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< generated key frame (reserved for server use only)
  102. FLV_FRAME_VIDEO_INFO_CMD = 5 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< video info/command frame
  103. };
  104. typedef enum {
  105. AMF_DATA_TYPE_NUMBER = 0x00,
  106. AMF_DATA_TYPE_BOOL = 0x01,
  107. AMF_DATA_TYPE_STRING = 0x02,
  108. AMF_DATA_TYPE_OBJECT = 0x03,
  109. AMF_DATA_TYPE_NULL = 0x05,
  110. AMF_DATA_TYPE_UNDEFINED = 0x06,
  111. AMF_DATA_TYPE_REFERENCE = 0x07,
  112. AMF_DATA_TYPE_MIXEDARRAY = 0x08,
  113. AMF_DATA_TYPE_OBJECT_END = 0x09,
  114. AMF_DATA_TYPE_ARRAY = 0x0a,
  115. AMF_DATA_TYPE_DATE = 0x0b,
  116. AMF_DATA_TYPE_LONG_STRING = 0x0c,
  117. AMF_DATA_TYPE_UNSUPPORTED = 0x0d,
  118. } AMFDataType;
  119. #endif /* AVFORMAT_FLV_H */