wav_playlist.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_WAV_PLAYLIST_H__
  20. #define __PJMEDIA_WAV_PLAYLIST_H__
  21. /**
  22. * @file wav_playlist.h
  23. * @brief WAV file playlist.
  24. */
  25. #include <pjmedia/wav_port.h>
  26. PJ_BEGIN_DECL
  27. /**
  28. * @defgroup PJMEDIA_WAV_PLAYLIST WAV File Play List
  29. * @ingroup PJMEDIA_PORT
  30. * @brief Audio playback of multiple WAV files
  31. * @{
  32. *
  33. * The WAV play list port enables application to play back multiple
  34. * WAV files in a playlist.
  35. */
  36. /**
  37. * Create a WAV playlist from the array of WAV file names. The WAV
  38. * files must have the same clock rate, number of channels, and bits
  39. * per sample, or otherwise this function will return error.
  40. *
  41. * @param pool Pool to create memory buffers for this port.
  42. * @param port_label Optional label to set as the port name.
  43. * @param file_list Array of WAV file names.
  44. * Each filename's length must be smaller than
  45. * PJ_MAXPATH.
  46. * @param file_count Number of files in the array.
  47. * @param ptime The duration (in miliseconds) of each frame read
  48. * from this port. If the value is zero, the default
  49. * duration (20ms) will be used.
  50. * @param options Optional options. Application may specify
  51. * PJMEDIA_FILE_NO_LOOP to prevent play back loop.
  52. * @param buff_size Buffer size to be allocated. If the value is zero or
  53. * negative, the port will use default buffer size (which
  54. * is about 4KB).
  55. * @param p_port Pointer to receive the file port instance.
  56. *
  57. * @return PJ_SUCCESS on success, or the appropriate error code.
  58. */
  59. PJ_DECL(pj_status_t) pjmedia_wav_playlist_create(pj_pool_t *pool,
  60. const pj_str_t *port_label,
  61. const pj_str_t file_list[],
  62. int file_count,
  63. unsigned ptime,
  64. unsigned options,
  65. pj_ssize_t buff_size,
  66. pjmedia_port **p_port);
  67. #if !DEPRECATED_FOR_TICKET_2251
  68. /**
  69. * Register a callback to be called when the file reading has reached the
  70. * end of file of the last file. If the file is set to play repeatedly,
  71. * then the callback will be called multiple times. Note that only one
  72. * callback can be registered for each file port.
  73. *
  74. * @param port The WAV play list port.
  75. * @param user_data User data to be specified in the callback
  76. * @param cb Callback to be called. If the callback returns non-
  77. * PJ_SUCCESS, the playback will stop. Note that if
  78. * application destroys the file port in the callback,
  79. * it must return non-PJ_SUCCESS here.
  80. *
  81. * @return PJ_SUCCESS on success.
  82. */
  83. PJ_DECL(pj_status_t)
  84. pjmedia_wav_playlist_set_eof_cb(pjmedia_port *port,
  85. void *user_data,
  86. pj_status_t (*cb)(pjmedia_port *port,
  87. void *usr_data));
  88. #endif
  89. /**
  90. * Register a callback to be called when the file reading has reached the
  91. * end of file of the last file. If the file is set to play repeatedly,
  92. * then the callback will be called multiple times. Note that only one
  93. * callback can be registered for each file port.
  94. *
  95. * @param port The WAV play list port.
  96. * @param user_data User data to be specified in the callback
  97. * @param cb Callback to be called. Note that if
  98. * application wishes to stop the playback, it
  99. * can disconnect the port in the callback, and
  100. * only after all connections have been removed
  101. * could the application safely destroy the port.
  102. *
  103. * @return PJ_SUCCESS on success.
  104. */
  105. PJ_DECL(pj_status_t)
  106. pjmedia_wav_playlist_set_eof_cb2(pjmedia_port *port,
  107. void *user_data,
  108. void (*cb)(pjmedia_port *port,
  109. void *usr_data));
  110. /**
  111. * @}
  112. */
  113. PJ_END_DECL
  114. #endif /* __PJMEDIA_WAV_PLAYLIST_H__ */