vid_codec_util.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJMEDIA_VID_CODEC_UTIL_H__
  20. #define __PJMEDIA_VID_CODEC_UTIL_H__
  21. /**
  22. * @file vid_codec_util.h
  23. * @brief Video codec utilities.
  24. */
  25. #include <pjmedia/vid_codec.h>
  26. #include <pjmedia/sdp_neg.h>
  27. PJ_BEGIN_DECL
  28. /**
  29. * Definition of H.263 parameters.
  30. */
  31. typedef struct pjmedia_vid_codec_h263_fmtp
  32. {
  33. unsigned mpi_cnt; /**< # of parsed MPI param */
  34. struct mpi {
  35. pjmedia_rect_size size; /**< Picture size/resolution */
  36. unsigned val; /**< MPI value */
  37. } mpi[32]; /**< Minimum Picture Interval parameter */
  38. } pjmedia_vid_codec_h263_fmtp;
  39. /**
  40. * Parse SDP fmtp of H.263.
  41. *
  42. * @param fmtp The H.263 SDP fmtp to be parsed.
  43. * @param h263_fmtp The parsing result.
  44. *
  45. * @return PJ_SUCCESS on success.
  46. */
  47. PJ_DECL(pj_status_t) pjmedia_vid_codec_h263_parse_fmtp(
  48. const pjmedia_codec_fmtp *fmtp,
  49. pjmedia_vid_codec_h263_fmtp *h263_fmtp);
  50. /**
  51. * Parse, negotiate, and apply the encoding and decoding SDP fmtp of H.263
  52. * in the specified codec parameter.
  53. *
  54. * @param param The codec parameter.
  55. *
  56. * @return PJ_SUCCESS on success.
  57. */
  58. PJ_DECL(pj_status_t) pjmedia_vid_codec_h263_apply_fmtp(
  59. pjmedia_vid_codec_param *param);
  60. /**
  61. * Definition of H.264 parameters.
  62. */
  63. typedef struct pjmedia_vid_codec_h264_fmtp
  64. {
  65. /* profile-level-id */
  66. pj_uint8_t profile_idc; /**< Profile ID */
  67. pj_uint8_t profile_iop; /**< Profile constraints bits */
  68. pj_uint8_t level; /**< Level */
  69. /* packetization-mode */
  70. pj_uint8_t packetization_mode; /**< Packetization mode */
  71. /* max-mbps, max-fs, max-cpb, max-dpb, and max-br */
  72. unsigned max_mbps; /**< Max macroblock processing rate */
  73. unsigned max_fs; /**< Max frame size (in macroblocks) */
  74. unsigned max_cpb; /**< Max coded picture buffer size */
  75. unsigned max_dpb; /**< Max decoded picture buffer size */
  76. unsigned max_br; /**< Max video bit rate */
  77. /* sprop-parameter-sets, in NAL units */
  78. pj_size_t sprop_param_sets_len; /**< Parameter set length */
  79. pj_uint8_t sprop_param_sets[256]; /**< Parameter set (SPS & PPS),
  80. in NAL unit bitstream */
  81. } pjmedia_vid_codec_h264_fmtp;
  82. /**
  83. * Parse SDP fmtp of H.264.
  84. *
  85. * @param fmtp The H.264 SDP fmtp to be parsed.
  86. * @param h264_fmtp The parsing result.
  87. *
  88. * @return PJ_SUCCESS on success.
  89. */
  90. PJ_DECL(pj_status_t) pjmedia_vid_codec_h264_parse_fmtp(
  91. const pjmedia_codec_fmtp *fmtp,
  92. pjmedia_vid_codec_h264_fmtp *h264_fmtp);
  93. /**
  94. * Match H.264 format in the SDP media offer and answer. This will compare
  95. * H.264 identifier parameters in SDP fmtp, i.e: "profile-level-id" and
  96. * "packetization-mode" fields. For better interoperability, when the option
  97. * #PJMEDIA_SDP_NEG_FMT_MATCH_ALLOW_MODIFY_ANSWER is set, this function
  98. * may update the answer so the parameters in the answer match to ones
  99. * in the offer.
  100. *
  101. * @param pool The memory pool.
  102. * @param offer The SDP media offer.
  103. * @param o_fmt_idx Index of the H.264 format in the SDP media offer.
  104. * @param answer The SDP media answer.
  105. * @param a_fmt_idx Index of the H.264 format in the SDP media answer.
  106. * @param option The format matching option, see
  107. * #pjmedia_sdp_neg_fmt_match_flag.
  108. *
  109. * @return PJ_SUCCESS when the formats in offer and answer match.
  110. */
  111. PJ_DECL(pj_status_t) pjmedia_vid_codec_h264_match_sdp(
  112. pj_pool_t *pool,
  113. pjmedia_sdp_media *offer,
  114. unsigned o_fmt_idx,
  115. pjmedia_sdp_media *answer,
  116. unsigned a_fmt_idx,
  117. unsigned option);
  118. /**
  119. * Parse and apply the encoding and decoding SDP fmtp of H.264 in the
  120. * specified codec parameter. This will validate size and fps to conform
  121. * to H.264 level specified in SDP fmtp "profile-level-id".
  122. *
  123. * @param param The codec parameter.
  124. *
  125. * @return PJ_SUCCESS on success.
  126. */
  127. PJ_DECL(pj_status_t) pjmedia_vid_codec_h264_apply_fmtp(
  128. pjmedia_vid_codec_param *param);
  129. /**
  130. * Definition of VPX parameters.
  131. */
  132. typedef struct pjmedia_vid_codec_vpx_fmtp
  133. {
  134. unsigned max_fr; /**< Max frame rate */
  135. unsigned max_fs; /**< Max frame size (in macroblocks) */
  136. pj_uint8_t profile_id; /**< Profile ID */
  137. } pjmedia_vid_codec_vpx_fmtp;
  138. /**
  139. * Parse SDP fmtp of VPX.
  140. *
  141. * @param fmtp The VPX SDP fmtp to be parsed.
  142. * @param vpx_fmtp The parsing result.
  143. *
  144. * @return PJ_SUCCESS on success.
  145. */
  146. PJ_DECL(pj_status_t) pjmedia_vid_codec_vpx_parse_fmtp(
  147. const pjmedia_codec_fmtp *fmtp,
  148. pjmedia_vid_codec_vpx_fmtp *vpx_fmtp);
  149. /**
  150. * Parse and apply the encoding and decoding SDP fmtp of VPX in the
  151. * specified codec parameter. This will validate size and fps to conform
  152. * to VPX level specified in SDP fmtp "max-fr" and "max-fs".
  153. *
  154. * @param param The codec parameter.
  155. *
  156. * @return PJ_SUCCESS on success.
  157. */
  158. PJ_DECL(pj_status_t) pjmedia_vid_codec_vpx_apply_fmtp(
  159. pjmedia_vid_codec_param *param);
  160. PJ_END_DECL
  161. #endif /* __PJMEDIA_VID_CODEC_UTIL_H__ */