1
/* $Id: mem_port.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJMEDIA_MEM_PORT_H__
21
#define __PJMEDIA_MEM_PORT_H__
25
* @brief Memory based media playback/capture port
27
#include <pjmedia/port.h>
33
* @defgroup PJMEDIA_MEM_PLAYER Memory/Buffer-based Playback Port
34
* @ingroup PJMEDIA_PORT
35
* @brief Media playback from a fixed size memory buffer
38
* A memory/buffer based playback port is used to play media from a fixed
39
* size buffer. This is useful over @ref PJMEDIA_FILE_PLAY for
40
* situation where filesystems are not available in the target system.
45
* Memory player options.
47
enum pjmedia_mem_player_option
50
* Tell the memory player to return NULL frame when the whole
51
* buffer has been played instead of rewinding the buffer back
54
PJMEDIA_MEM_NO_LOOP = 1
59
* Create the buffer based playback to play the media from the specified
62
* @param pool Pool to allocate memory for the port structure.
63
* @param buffer The buffer to play the media from, which should
64
* be available throughout the life time of the port.
65
* The player plays the media directly from this
66
* buffer (i.e. no copying is done).
67
* @param size The size of the buffer, in bytes.
68
* @param clock_rate Sampling rate.
69
* @param channel_count Number of channels.
70
* @param samples_per_frame Number of samples per frame.
71
* @param bits_per_sample Number of bits per sample.
72
* @param options Option flags, see #pjmedia_mem_player_option
73
* @param p_port Pointer to receive the port instance.
75
* @return PJ_SUCCESS on success, or the appropriate
78
PJ_DECL(pj_status_t) pjmedia_mem_player_create(pj_pool_t *pool,
82
unsigned channel_count,
83
unsigned samples_per_frame,
84
unsigned bits_per_sample,
86
pjmedia_port **p_port );
90
* Register a callback to be called when the buffer reading has reached the
91
* end of buffer. If the player is set to play repeatedly, then the callback
92
* will be called multiple times. Note that only one callback can be
93
* registered for each player port.
95
* @param port The memory player port.
96
* @param user_data User data to be specified in the callback
97
* @param cb Callback to be called. If the callback returns non-
98
* PJ_SUCCESS, the playback will stop. Note that if
99
* application destroys the player port in the callback,
100
* it must return non-PJ_SUCCESS here.
102
* @return PJ_SUCCESS on success.
105
pjmedia_mem_player_set_eof_cb( pjmedia_port *port,
107
pj_status_t (*cb)(pjmedia_port *port,
116
* @defgroup PJMEDIA_MEM_CAPTURE Memory/Buffer-based Capture Port
117
* @ingroup PJMEDIA_PORT
118
* @brief Media capture to fixed size memory buffer
121
* A memory based capture is used to save media streams to a fixed size
122
* buffer. This is useful over @ref PJMEDIA_FILE_REC for
123
* situation where filesystems are not available in the target system.
127
* Create media port to capture/record media into a fixed size buffer.
129
* @param pool Pool to allocate memory for the port structure.
130
* @param buffer The buffer to record the media to, which should
131
* be available throughout the life time of the port.
132
* @param size The maximum size of the buffer, in bytes.
133
* @param clock_rate Sampling rate.
134
* @param channel_count Number of channels.
135
* @param samples_per_frame Number of samples per frame.
136
* @param bits_per_sample Number of bits per sample.
137
* @param options Option flags.
138
* @param p_port Pointer to receive the port instance.
140
* @return PJ_SUCCESS on success, or the appropriate
143
PJ_DECL(pj_status_t) pjmedia_mem_capture_create(pj_pool_t *pool,
147
unsigned channel_count,
148
unsigned samples_per_frame,
149
unsigned bits_per_sample,
151
pjmedia_port **p_port);
155
* Register a callback to be called when no space left in the buffer.
156
* Note that when a callback is registered, this callback will also be
157
* called when application destroys the port and the callback has not
158
* been called before.
160
* @param port The memory recorder port.
161
* @param user_data User data to be specified in the callback
162
* @param cb Callback to be called. If the callback returns non-
163
* PJ_SUCCESS, the recording will stop. In other cases
164
* recording will be restarted and the rest of the frame
165
* will be stored starting from the beginning of the
166
* buffer. Note that if application destroys the capture
167
* port in the callback, it must return non-PJ_SUCCESS
170
* @return PJ_SUCCESS on success.
173
pjmedia_mem_capture_set_eof_cb(pjmedia_port *port,
175
pj_status_t (*cb)(pjmedia_port *port,
179
* Return the current size of the recorded data in the buffer.
181
* @param port The memory recorder port.
182
* @return The size of buffer data..
185
pjmedia_mem_capture_get_size(pjmedia_port *port);
195
#endif /* __PJMEDIA_MEM_PORT_H__ */