tdav_codec_h264_rtp.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO 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 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO 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.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tdav_codec_h264_rtp.h
  23. * @brief H.264 payloader/depayloder as per RFC 3984
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango.org>
  26. *
  27. */
  28. #ifndef TINYDAV_CODEC_H264_RTP_H
  29. #define TINYDAV_CODEC_H264_RTP_H
  30. #include "tinydav_config.h"
  31. #include "tsk_common.h"
  32. TDAV_BEGIN_DECLS
  33. #if !defined(H264_RTP_PAYLOAD_SIZE)
  34. # define H264_RTP_PAYLOAD_SIZE 1300
  35. #endif
  36. #define H264_START_CODE_PREFIX_SIZE 4
  37. struct tdav_codec_h264_common_s;
  38. extern uint8_t H264_START_CODE_PREFIX[4];
  39. typedef enum profile_idc_e {
  40. profile_idc_none = 0,
  41. profile_idc_baseline = 66,
  42. profile_idc_extended = 88,
  43. profile_idc_main = 77,
  44. profile_idc_high = 100
  45. }
  46. profile_idc_t;
  47. typedef struct profile_iop_s {
  48. unsigned constraint_set0_flag:1;
  49. unsigned constraint_set1_flag:1;
  50. unsigned constraint_set2_flag:1;
  51. unsigned reserved_zero_5bits:5;
  52. }
  53. profile_iop_t;
  54. typedef enum level_idc_e {
  55. level_idc_none = 0,
  56. level_idc_1_0 = 10,
  57. level_idc_1_b = 14,
  58. level_idc_1_1 = 11,
  59. level_idc_1_2 = 12,
  60. level_idc_1_3 = 13,
  61. level_idc_2_0 = 20,
  62. level_idc_2_1 = 21,
  63. level_idc_2_2 = 22,
  64. level_idc_3_0 = 30,
  65. level_idc_3_1 = 31,
  66. level_idc_3_2 = 32,
  67. level_idc_4_0 = 40,
  68. level_idc_4_1 = 41,
  69. level_idc_4_2 = 42,
  70. level_idc_5_0 = 50,
  71. level_idc_5_1 = 51,
  72. level_idc_5_2 = 52,
  73. }
  74. level_idc_t;
  75. /* 5.2. Common Structure of the RTP Payload Format
  76. Type Packet Type name Section
  77. ---------------------------------------------------------
  78. 0 undefined -
  79. 1-23 NAL unit Single NAL unit packet per H.264 5.6
  80. 24 STAP-A Single-time aggregation packet 5.7.1
  81. 25 STAP-B Single-time aggregation packet 5.7.1
  82. 26 MTAP16 Multi-time aggregation packet 5.7.2
  83. 27 MTAP24 Multi-time aggregation packet 5.7.2
  84. 28 FU-A Fragmentation unit 5.8
  85. 29 FU-B Fragmentation unit 5.8
  86. 30-31 undefined -
  87. */
  88. typedef enum nal_unit_type_e {
  89. undefined_0 = 0,
  90. nal_unit,
  91. stap_a = 24,
  92. stap_b = 25,
  93. mtap16 = 26,
  94. mtap24 = 27,
  95. fu_a = 28,
  96. fu_b = 29,
  97. undefined_30 = 30,
  98. undefined_31 = 31
  99. }
  100. nal_unit_type_t;
  101. int tdav_codec_h264_parse_profile(const char* profile_level_id, profile_idc_t *p_idc, profile_iop_t *p_iop, level_idc_t *l_idc);
  102. int tdav_codec_h264_get_pay(const void* in_data, tsk_size_t in_size, const void** out_data, tsk_size_t *out_size, tsk_bool_t* append_scp, tsk_bool_t* end_of_unit);
  103. void tdav_codec_h264_rtp_encap(struct tdav_codec_h264_common_s* self, const uint8_t* pdata, tsk_size_t size);
  104. void tdav_codec_h264_rtp_callback(struct tdav_codec_h264_common_s *self, const void *data, tsk_size_t size, tsk_bool_t marker);
  105. TDAV_END_DECLS
  106. #endif /* TINYDAV_CODEC_H264_RTP_H */