WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJMEDIA Reference

Memory/Buffer-based Playback Port

Media playback from a fixed size memory buffer. More...

Enumerations

enum  pjmedia_mem_player_option { PJMEDIA_MEM_NO_LOOP = 1 }
 

Functions

pj_status_t pjmedia_mem_player_create (pj_pool_t *pool, const void *buffer, pj_size_t size, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_port **p_port)
 
pj_status_t pjmedia_mem_player_set_eof_cb (pjmedia_port *port, void *user_data, pj_status_t(*cb)(pjmedia_port *port, void *usr_data))
 
pj_status_t pjmedia_mem_player_set_eof_cb2 (pjmedia_port *port, void *user_data, void(*cb)(pjmedia_port *port, void *usr_data))
 

Detailed Description

A memory/buffer based playback port is used to play media from a fixed size buffer. This is useful over WAV File Player for situation where filesystems are not available in the target system.

Enumeration Type Documentation

◆ pjmedia_mem_player_option

Memory player options.

Enumerator
PJMEDIA_MEM_NO_LOOP 

Tell the memory player to return NULL frame when the whole buffer has been played instead of rewinding the buffer back to start position.

Function Documentation

◆ pjmedia_mem_player_create()

pj_status_t pjmedia_mem_player_create ( pj_pool_t pool,
const void *  buffer,
pj_size_t  size,
unsigned  clock_rate,
unsigned  channel_count,
unsigned  samples_per_frame,
unsigned  bits_per_sample,
unsigned  options,
pjmedia_port **  p_port 
)

Create the buffer based playback to play the media from the specified buffer.

Parameters
poolPool to allocate memory for the port structure.
bufferThe buffer to play the media from, which should be available throughout the life time of the port. The player plays the media directly from this buffer (i.e. no copying is done).
sizeThe size of the buffer, in bytes.
clock_rateSampling rate.
channel_countNumber of channels.
samples_per_frameNumber of samples per frame.
bits_per_sampleNumber of bits per sample.
optionsOption flags, see pjmedia_mem_player_option
p_portPointer to receive the port instance.
Returns
PJ_SUCCESS on success, or the appropriate error code.

◆ pjmedia_mem_player_set_eof_cb()

pj_status_t pjmedia_mem_player_set_eof_cb ( pjmedia_port port,
void *  user_data,
pj_status_t(*)(pjmedia_port *port, void *usr_data)  cb 
)

Register a callback to be called when the buffer reading has reached the end of buffer. If the player is set to play repeatedly, then the callback will be called multiple times. Note that only one callback can be registered for each player port.

Parameters
portThe memory player port.
user_dataUser data to be specified in the callback
cbCallback to be called. If the callback returns non- PJ_SUCCESS, the playback will stop. Note that if application destroys the player port in the callback, it must return non-PJ_SUCCESS here.
Returns
PJ_SUCCESS on success.

◆ pjmedia_mem_player_set_eof_cb2()

pj_status_t pjmedia_mem_player_set_eof_cb2 ( pjmedia_port port,
void *  user_data,
void(*)(pjmedia_port *port, void *usr_data)  cb 
)

Register a callback to be called when the buffer reading has reached the end of buffer. If the player is set to play repeatedly, then the callback will be called multiple times. Note that only one callback can be registered for each player port.

Parameters
portThe memory player port.
user_dataUser data to be specified in the callback
cbCallback to be called. Note that if application wishes to stop the playback, it can disconnect the port in the callback, and only after all connections have been removed could the application safely destroy the port.
Returns
PJ_SUCCESS on success.

 


PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.