flv.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 {
  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_DATA,
  57. FLV_STREAM_TYPE_NB,
  58. };
  59. enum {
  60. FLV_MONO = 0,
  61. FLV_STEREO = 1,
  62. };
  63. enum {
  64. FLV_SAMPLESSIZE_8BIT = 0,
  65. FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET,
  66. };
  67. enum {
  68. FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */
  69. FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET,
  70. FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET,
  71. FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET,
  72. };
  73. enum {
  74. FLV_CODECID_PCM = 0,
  75. FLV_CODECID_ADPCM = 1 << FLV_AUDIO_CODECID_OFFSET,
  76. FLV_CODECID_MP3 = 2 << FLV_AUDIO_CODECID_OFFSET,
  77. FLV_CODECID_PCM_LE = 3 << FLV_AUDIO_CODECID_OFFSET,
  78. FLV_CODECID_NELLYMOSER_16KHZ_MONO = 4 << FLV_AUDIO_CODECID_OFFSET,
  79. FLV_CODECID_NELLYMOSER_8KHZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
  80. FLV_CODECID_NELLYMOSER = 6 << FLV_AUDIO_CODECID_OFFSET,
  81. FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET,
  82. FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET,
  83. };
  84. enum {
  85. FLV_CODECID_H263 = 2,
  86. FLV_CODECID_SCREEN = 3,
  87. FLV_CODECID_VP6 = 4,
  88. FLV_CODECID_VP6A = 5,
  89. FLV_CODECID_SCREEN2 = 6,
  90. FLV_CODECID_H264 = 7,
  91. FLV_CODECID_REALH263= 8,
  92. FLV_CODECID_MPEG4 = 9,
  93. };
  94. enum {
  95. FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET,
  96. FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET,
  97. FLV_FRAME_DISP_INTER = 3 << FLV_VIDEO_FRAMETYPE_OFFSET,
  98. };
  99. typedef enum {
  100. AMF_DATA_TYPE_NUMBER = 0x00,
  101. AMF_DATA_TYPE_BOOL = 0x01,
  102. AMF_DATA_TYPE_STRING = 0x02,
  103. AMF_DATA_TYPE_OBJECT = 0x03,
  104. AMF_DATA_TYPE_NULL = 0x05,
  105. AMF_DATA_TYPE_UNDEFINED = 0x06,
  106. AMF_DATA_TYPE_REFERENCE = 0x07,
  107. AMF_DATA_TYPE_MIXEDARRAY = 0x08,
  108. AMF_DATA_TYPE_OBJECT_END = 0x09,
  109. AMF_DATA_TYPE_ARRAY = 0x0a,
  110. AMF_DATA_TYPE_DATE = 0x0b,
  111. AMF_DATA_TYPE_LONG_STRING = 0x0c,
  112. AMF_DATA_TYPE_UNSUPPORTED = 0x0d,
  113. } AMFDataType;
  114. #endif /* AVFORMAT_FLV_H */