avi_stream.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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_AVI_STREAM_H__
  19. #define __PJMEDIA_AVI_STREAM_H__
  20. /**
  21. * @file avi_stream.h
  22. * @brief AVI file player.
  23. */
  24. #include <pjmedia/port.h>
  25. PJ_BEGIN_DECL
  26. /**
  27. * @defgroup PJMEDIA_AVI_FILE_PLAY AVI File Player
  28. * @ingroup PJMEDIA_PORT
  29. * @brief Video and audio playback from AVI file
  30. * @{
  31. */
  32. /**
  33. * AVI file player options.
  34. */
  35. enum pjmedia_avi_file_player_option
  36. {
  37. /**
  38. * Tell the file player to return NULL frame when the whole
  39. * file has been played.
  40. */
  41. PJMEDIA_AVI_FILE_NO_LOOP = 1
  42. };
  43. /**
  44. * AVI stream data type.
  45. */
  46. typedef pjmedia_port pjmedia_avi_stream;
  47. /**
  48. * Opaque data type for AVI streams. AVI streams is a collection of
  49. * zero or more AVI stream.
  50. */
  51. typedef struct pjmedia_avi_streams pjmedia_avi_streams;
  52. /**
  53. * Create avi streams to play an AVI file. AVI player supports
  54. * reading AVI file with uncompressed video format and
  55. * 16 bit PCM or compressed G.711 A-law/U-law audio format.
  56. *
  57. * @param pool Pool to create the streams.
  58. * @param filename File name to open.
  59. * @param flags Avi streams creation flags.
  60. * @param p_streams Pointer to receive the avi streams instance.
  61. *
  62. * @return PJ_SUCCESS on success.
  63. */
  64. PJ_DECL(pj_status_t)
  65. pjmedia_avi_player_create_streams(pj_pool_t *pool,
  66. const char *filename,
  67. unsigned flags,
  68. pjmedia_avi_streams **p_streams);
  69. /**
  70. * Get the number of AVI stream.
  71. *
  72. * @param streams The AVI streams.
  73. *
  74. * @return The number of AVI stream.
  75. */
  76. PJ_DECL(unsigned)
  77. pjmedia_avi_streams_get_num_streams(pjmedia_avi_streams *streams);
  78. /**
  79. * Return the idx-th stream of the AVI streams.
  80. *
  81. * @param streams The AVI streams.
  82. * @param idx The stream index.
  83. *
  84. * @return The AVI stream or NULL if it does not exist.
  85. */
  86. PJ_DECL(pjmedia_avi_stream *)
  87. pjmedia_avi_streams_get_stream(pjmedia_avi_streams *streams,
  88. unsigned idx);
  89. /**
  90. * Return an AVI stream with a certain media type from the AVI streams.
  91. *
  92. * @param streams The AVI streams.
  93. * @param start_idx The starting index.
  94. * @param media_type The media type of the stream.
  95. *
  96. * @return The AVI stream or NULL if it does not exist.
  97. */
  98. PJ_DECL(pjmedia_avi_stream *)
  99. pjmedia_avi_streams_get_stream_by_media(pjmedia_avi_streams *streams,
  100. unsigned start_idx,
  101. pjmedia_type media_type);
  102. /**
  103. * Return the media port of an AVI stream.
  104. *
  105. * @param stream The AVI stream.
  106. *
  107. * @return The media port.
  108. */
  109. PJ_INLINE(pjmedia_port *)
  110. pjmedia_avi_stream_get_port(pjmedia_avi_stream *stream)
  111. {
  112. return (pjmedia_port *)stream;
  113. }
  114. /**
  115. * Get the data length, in bytes.
  116. *
  117. * @param stream The AVI stream.
  118. *
  119. * @return The length of the data, in bytes. Upon error it will
  120. * return negative value.
  121. */
  122. PJ_DECL(pj_ssize_t) pjmedia_avi_stream_get_len(pjmedia_avi_stream *stream);
  123. #if !DEPRECATED_FOR_TICKET_2251
  124. /**
  125. * Register a callback to be called when the file reading has reached the
  126. * end of file. If the file is set to play repeatedly, then the callback
  127. * will be called multiple times. Note that only one callback can be
  128. * registered for each AVI stream.
  129. *
  130. * @param stream The AVI stream.
  131. * @param user_data User data to be specified in the callback
  132. * @param cb Callback to be called. If the callback returns non-
  133. * PJ_SUCCESS, the playback will stop. Note that if
  134. * application destroys the file port in the callback,
  135. * it must return non-PJ_SUCCESS here.
  136. *
  137. * @return PJ_SUCCESS on success.
  138. */
  139. PJ_DECL(pj_status_t)
  140. pjmedia_avi_stream_set_eof_cb(pjmedia_avi_stream *stream,
  141. void *user_data,
  142. pj_status_t (*cb)(pjmedia_avi_stream *stream,
  143. void *usr_data));
  144. #endif
  145. /**
  146. * Register a callback to be called when the file reading has reached the
  147. * end of file. If the file is set to play repeatedly, then the callback
  148. * will be called multiple times. Note that only one callback can be
  149. * registered for each AVI stream.
  150. *
  151. * @param stream The AVI stream.
  152. * @param user_data User data to be specified in the callback
  153. * @param cb Callback to be called. Note that if
  154. * application wishes to stop the playback, it
  155. * can disconnect the port in the callback, and
  156. * only after all connections have been removed
  157. * could the application safely destroy the port.
  158. *
  159. * @return PJ_SUCCESS on success.
  160. */
  161. PJ_DECL(pj_status_t)
  162. pjmedia_avi_stream_set_eof_cb2(pjmedia_avi_stream *stream,
  163. void *user_data,
  164. void (*cb)(pjmedia_avi_stream *stream,
  165. void *usr_data));
  166. /**
  167. * @}
  168. */
  169. PJ_END_DECL
  170. #endif /* __PJMEDIA_AVI_STREAM_H__ */