vpx_packetizer.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2020 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJMEDIA_VPX_PACKETIZER_H__
  19. #define __PJMEDIA_VPX_PACKETIZER_H__
  20. /**
  21. * @file vpx_packetizer.h
  22. * @brief Packetizes VPX bitstream into RTP payload and vice versa.
  23. */
  24. #include <pj/types.h>
  25. PJ_BEGIN_DECL
  26. /**
  27. * Opaque declaration for VPX packetizer.
  28. */
  29. typedef struct pjmedia_vpx_packetizer pjmedia_vpx_packetizer;
  30. /**
  31. * VPX packetizer setting.
  32. */
  33. typedef struct pjmedia_vpx_packetizer_cfg
  34. {
  35. /**
  36. * VPX format id.
  37. * Default: PJMEDIA_FORMAT_VP8
  38. */
  39. pj_uint32_t fmt_id;
  40. /**
  41. * MTU size.
  42. * Default: PJMEDIA_MAX_VID_PAYLOAD_SIZE
  43. */
  44. unsigned mtu;
  45. }
  46. pjmedia_vpx_packetizer_cfg;
  47. /**
  48. * Use this function to initialize VPX packetizer config.
  49. *
  50. * @param cfg The VPX packetizer config to be initialized.
  51. */
  52. PJ_DECL(void) pjmedia_vpx_packetizer_cfg_default(
  53. pjmedia_vpx_packetizer_cfg *cfg);
  54. /**
  55. * Create VPX packetizer.
  56. *
  57. * @param pool The memory pool.
  58. * @param cfg Packetizer settings, if NULL, default setting
  59. * will be used.
  60. * @param p_pktz Pointer to receive the packetizer.
  61. *
  62. * @return PJ_SUCCESS on success.
  63. */
  64. PJ_DECL(pj_status_t) pjmedia_vpx_packetizer_create(
  65. pj_pool_t *pool,
  66. const pjmedia_vpx_packetizer_cfg *cfg,
  67. pjmedia_vpx_packetizer **p_pktz);
  68. /**
  69. * Generate an RTP payload from a VPX picture bitstream. Note that this
  70. * function will apply in-place processing, so the bitstream may be modified
  71. * during the packetization.
  72. *
  73. * @param pktz The packetizer.
  74. * @param bits_len The length of the bitstream.
  75. * @param bits_pos The bitstream offset to be packetized.
  76. * @param is_keyframe The frame is keyframe.
  77. * @param payload The output payload.
  78. * @param payload_len The output payload length, on input it represents max
  79. * payload length.
  80. *
  81. * @return PJ_SUCCESS on success.
  82. */
  83. PJ_DECL(pj_status_t) pjmedia_vpx_packetize(const pjmedia_vpx_packetizer *pktz,
  84. pj_size_t bits_len,
  85. unsigned *bits_pos,
  86. pj_bool_t is_keyframe,
  87. pj_uint8_t **payload,
  88. pj_size_t *payload_len);
  89. /**
  90. * Append an RTP payload to an VPX picture bitstream. Note that in case of
  91. * noticing packet lost, application should keep calling this function with
  92. * payload pointer set to NULL, as the packetizer need to update its internal
  93. * state.
  94. *
  95. * @param pktz The packetizer.
  96. * @param payload The payload to be unpacketized.
  97. * @param payload_len The payload length.
  98. * @param payload_desc_len The payload description length.
  99. *
  100. * @return PJ_SUCCESS on success.
  101. */
  102. PJ_DECL(pj_status_t) pjmedia_vpx_unpacketize(pjmedia_vpx_packetizer *pktz,
  103. const pj_uint8_t *payload,
  104. pj_size_t payload_len,
  105. unsigned *payload_desc_len);
  106. PJ_END_DECL
  107. #endif /* __PJMEDIA_VPX_PACKETIZER_H__ */