plc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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_PLC_H__
  20. #define __PJMEDIA_PLC_H__
  21. /**
  22. * @file plc.h
  23. * @brief Packet Lost Concealment (PLC) API.
  24. */
  25. #include <pjmedia/types.h>
  26. /**
  27. * @defgroup PJMED_PLC Packet Lost Concealment (PLC)
  28. * @ingroup PJMEDIA_FRAME_OP
  29. * @brief Packet lost compensation algorithm
  30. * @{
  31. *
  32. * This section describes PJMEDIA's implementation of Packet Lost
  33. * Concealment algorithm. This algorithm is used to implement PLC for
  34. * codecs that do not have built-in support for one (e.g. G.711 or GSM
  35. * codecs).
  36. *
  37. * The PLC algorithm (either built-in or external) is embedded in
  38. * PJMEDIA codec instance, and application can conceal lost frames
  39. * by calling <b><tt>recover()</tt></b> member of the codec's member
  40. * operation (#pjmedia_codec_op).
  41. *
  42. * See also @ref plc_codec for more info.
  43. */
  44. PJ_BEGIN_DECL
  45. /**
  46. * Opaque declaration for PLC.
  47. */
  48. typedef struct pjmedia_plc pjmedia_plc;
  49. /**
  50. * Create PLC session. This function will select the PLC algorithm to
  51. * use based on the arguments.
  52. *
  53. * @param pool Pool to allocate memory for the PLC.
  54. * @param clock_rate Media sampling rate.
  55. * @param samples_per_frame Number of samples per frame.
  56. * @param options Must be zero for now.
  57. * @param p_plc Pointer to receive the PLC instance.
  58. *
  59. * @return PJ_SUCCESS on success.
  60. */
  61. PJ_DECL(pj_status_t) pjmedia_plc_create( pj_pool_t *pool,
  62. unsigned clock_rate,
  63. unsigned samples_per_frame,
  64. unsigned options,
  65. pjmedia_plc **p_plc);
  66. /**
  67. * Save a good frame to PLC.
  68. *
  69. * @param plc The PLC session.
  70. * @param frame The good frame to be stored to PLC. This frame
  71. * must have the same length as the configured
  72. * samples per frame.
  73. *
  74. * @return PJ_SUCCESS on success.
  75. */
  76. PJ_DECL(pj_status_t) pjmedia_plc_save( pjmedia_plc *plc,
  77. pj_int16_t *frame );
  78. /**
  79. * Generate a replacement for lost frame.
  80. *
  81. * @param plc The PLC session.
  82. * @param frame Buffer to receive the generated frame. This buffer
  83. * must be able to store the frame.
  84. *
  85. * @return PJ_SUCCESS on success.
  86. */
  87. PJ_DECL(pj_status_t) pjmedia_plc_generate( pjmedia_plc *plc,
  88. pj_int16_t *frame );
  89. PJ_END_DECL
  90. /**
  91. * @}
  92. */
  93. #endif /* __PJMEDIA_PLC_H__ */