h263_packetizer.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (C) 2008-2011 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_H263_PACKETIZER_H__
  19. #define __PJMEDIA_H263_PACKETIZER_H__
  20. /**
  21. * @file h263_packetizer.h
  22. * @brief Packetizes/unpacketizes H.263 bitstream into RTP payload.
  23. */
  24. #include <pj/pool.h>
  25. #include <pj/types.h>
  26. PJ_BEGIN_DECL
  27. /**
  28. * Opaque declaration for H.263 packetizer.
  29. */
  30. typedef struct pjmedia_h263_packetizer pjmedia_h263_packetizer;
  31. /**
  32. * Enumeration of H.263 packetization modes.
  33. */
  34. typedef enum
  35. {
  36. /**
  37. * H.263 RTP packetization using RFC 4629.
  38. */
  39. PJMEDIA_H263_PACKETIZER_MODE_RFC4629,
  40. /**
  41. * H.263 RTP packetization using legacy RFC 2190.
  42. * This is currently not supported.
  43. */
  44. PJMEDIA_H263_PACKETIZER_MODE_RFC2190,
  45. } pjmedia_h263_packetizer_mode;
  46. /**
  47. * H.263 packetizer configuration.
  48. */
  49. typedef struct pjmedia_h263_packetizer_cfg
  50. {
  51. /**
  52. * Maximum payload length.
  53. * Default: PJMEDIA_MAX_MTU
  54. */
  55. int mtu;
  56. /**
  57. * Packetization mode.
  58. * Default: PJMEDIA_H263_PACKETIZER_MODE_RFC4629
  59. */
  60. pjmedia_h263_packetizer_mode mode;
  61. } pjmedia_h263_packetizer_cfg;
  62. /**
  63. * Create H.263 packetizer.
  64. *
  65. * @param pool The memory pool.
  66. * @param cfg Packetizer settings, if NULL, default setting
  67. * will be used.
  68. * @param p_pktz Pointer to receive the packetizer.
  69. *
  70. * @return PJ_SUCCESS on success.
  71. */
  72. PJ_DECL(pj_status_t) pjmedia_h263_packetizer_create(
  73. pj_pool_t *pool,
  74. const pjmedia_h263_packetizer_cfg *cfg,
  75. pjmedia_h263_packetizer **p_pktz);
  76. /**
  77. * Generate an RTP payload from a H.263 picture bitstream. Note that this
  78. * function will apply in-place processing, so the bitstream may be modified
  79. * during the packetization.
  80. *
  81. * @param pktz The packetizer.
  82. * @param bits The picture bitstream to be packetized.
  83. * @param bits_len The length of the bitstream.
  84. * @param bits_pos The bitstream offset to be packetized.
  85. * @param payload The output payload.
  86. * @param payload_len The output payload length.
  87. *
  88. * @return PJ_SUCCESS on success.
  89. */
  90. PJ_DECL(pj_status_t) pjmedia_h263_packetize(pjmedia_h263_packetizer *pktz,
  91. pj_uint8_t *bits,
  92. pj_size_t bits_len,
  93. unsigned *bits_pos,
  94. pj_uint8_t **payload,
  95. pj_size_t *payload_len);
  96. /**
  97. * Append an RTP payload to an H.263 picture bitstream. Note that in case of
  98. * noticing packet lost, application should keep calling this function with
  99. * payload pointer set to NULL, as the packetizer need to update its internal
  100. * state.
  101. *
  102. * @param pktz The packetizer.
  103. * @param payload The payload to be unpacketized.
  104. * @param payload_len The payload length.
  105. * @param bits The bitstream buffer.
  106. * @param bits_size The bitstream buffer size.
  107. * @param bits_pos The bitstream offset to put the unpacketized payload
  108. * in the bitstream, upon return, this will be updated
  109. * to the latest offset as a result of the unpacketized
  110. * payload.
  111. *
  112. * @return PJ_SUCCESS on success.
  113. */
  114. PJ_DECL(pj_status_t) pjmedia_h263_unpacketize(pjmedia_h263_packetizer *pktz,
  115. const pj_uint8_t *payload,
  116. pj_size_t payload_len,
  117. pj_uint8_t *bits,
  118. pj_size_t bits_size,
  119. unsigned *bits_pos);
  120. PJ_END_DECL
  121. #endif /* __PJMEDIA_H263_PACKETIZER_H__ */