summaryrefslogtreecommitdiff
path: root/pjmedia/include/pjmedia/wav_playlist.h
blob: 19ee1144d111e49f4ed19bb76db3b8b55bbe8569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* $Id$ */
/* 
 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */
#ifndef __PJMEDIA_WAV_PLAYLIST_H__
#define __PJMEDIA_WAV_PLAYLIST_H__

/**
 * @file wav_playlist.h
 * @brief WAV file playlist.
 */
#include <pjmedia/wav_port.h>



PJ_BEGIN_DECL


/**
 * @defgroup PJMEDIA_WAV_PLAYLIST WAV File Play List
 * @ingroup PJMEDIA_PORT
 * @brief WAV File Playlist
 * @{
 * The WAV play list port enables application to play back multiple
 * WAV files in a playlist.
 */

/**
 * Create a WAV playlist from the array of WAV file names. The WAV
 * files must have the same clock rate, number of channels, and bits
 * per sample, or otherwise this function will return error.
 *
 * @param pool		Pool to create memory buffers for this port.
 * @param port_label	Optional label to set as the port name.
 * @param file_list	Array of WAV file names.
 * @param file_count	Number of files in the array.
 * @param ptime		The duration (in miliseconds) of each frame read
 *			from this port. If the value is zero, the default
 *			duration (20ms) will be used.
 * @param options	Optional options. Application may specify 
 *			PJMEDIA_FILE_NO_LOOP to prevent play back loop.
 * @param buff_size	Buffer size to be allocated. If the value is zero or
 *			negative, the port will use default buffer size (which
 *			is about 4KB).
 * @param p_port	Pointer to receive the file port instance.
 *
 * @return		PJ_SUCCESS on success, or the appropriate error code.
 */
PJ_DECL(pj_status_t) pjmedia_wav_playlist_create(pj_pool_t *pool,
						 const pj_str_t *port_label,
						 const pj_str_t file_list[],
						 int file_count,
						 unsigned ptime,
						 unsigned options,
						 pj_ssize_t buff_size,
						 pjmedia_port **p_port);


/**
 * Register a callback to be called when the file reading has reached the
 * end of file of the last file. If the file is set to play repeatedly, 
 * then the callback will be called multiple times. Note that only one 
 * callback can be registered for each file port.
 *
 * @param port		The WAV play list port.
 * @param user_data	User data to be specified in the callback
 * @param cb		Callback to be called. If the callback returns non-
 *			PJ_SUCCESS, the playback will stop. Note that if
 *			application destroys the file port in the callback,
 *			it must return non-PJ_SUCCESS here.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t)
pjmedia_wav_playlist_set_eof_cb(pjmedia_port *port,
			        void *user_data,
			        pj_status_t (*cb)(pjmedia_port *port,
						  void *usr_data));


/**
 * @}
 */


PJ_END_DECL


#endif	/* __PJMEDIA_WAV_PLAYLIST_H__ */