pjsip logo pjsip.org
Open source SIP stack and media stack for presence, im/instant messaging, and multimedia communication
Loading

HOME

SIP/media Features
High Performance SIP
Small Footprint SIP
Symbian Port

FAQ

Documentation

Licensing

Download

Development (Trac)

Projects using pjsip

Mailing List

Open Source Links


About: PJLIB, PJLIB-UTIL, PJSIP, and PJMEDIA are created by: Benny Prijono
<bennylp@pjsip.org>


 

Home --> Documentations --> PJMEDIA Reference

Clock Generator
[Clock/Timing]

Interface for generating clock. More...

Typedefs

typedef typedefPJ_BEGIN_DECL
struct pjmedia_clock 
pjmedia_clock
typedef void pjmedia_clock_callback (const pj_timestamp *ts, void *user_data)

Enumerations

enum  pjmedia_clock_options {
  PJMEDIA_CLOCK_NO_ASYNC = 1,
  PJMEDIA_CLOCK_NO_HIGHEST_PRIO = 2
}

Functions

pj_status_t pjmedia_clock_create (pj_pool_t *pool, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned options, pjmedia_clock_callback *cb, void *user_data, pjmedia_clock **p_clock)
pj_status_t pjmedia_clock_start (pjmedia_clock *clock)
pj_status_t pjmedia_clock_stop (pjmedia_clock *clock)
pj_bool_t pjmedia_clock_wait (pjmedia_clock *clock, pj_bool_t wait, pj_timestamp *ts)
pj_status_t pjmedia_clock_destroy (pjmedia_clock *clock)

Detailed Description

The clock generator provides the application with media timing, and it is used by the Master Port for its sound clock.

The clock generator may be configured to run asynchronously (the default behavior) or synchronously. When it is run asynchronously, it will call the application's callback every time the clock tick expires. When it is run synchronously, application must continuously polls the clock generator to synchronize the timing.


Typedef Documentation

typedef typedefPJ_BEGIN_DECL struct pjmedia_clock pjmedia_clock

Opaque declaration for media clock.

typedef void pjmedia_clock_callback(const pj_timestamp *ts, void *user_data)

Type of media clock callback.

Parameters:
ts Current timestamp, in samples.
user_data Application data that is passed when the clock was created.

Enumeration Type Documentation

Options when creating the clock.

Enumerator:
PJMEDIA_CLOCK_NO_ASYNC 

Prevents the clock from running asynchronously. In this case, application must poll the clock continuously by calling pjmedia_clock_wait() in order to synchronize timing.

PJMEDIA_CLOCK_NO_HIGHEST_PRIO 

Prevent the clock from setting it's thread to highest priority.


Function Documentation

pj_status_t pjmedia_clock_create ( pj_pool_t pool,
unsigned  clock_rate,
unsigned  channel_count,
unsigned  samples_per_frame,
unsigned  options,
pjmedia_clock_callback cb,
void *  user_data,
pjmedia_clock **  p_clock 
)

Create media clock.

Parameters:
pool Pool to allocate memory.
clock_rate Number of samples per second.
channel_count Number of channel.
samples_per_frame Number of samples per frame. This argument along with clock_rate and channel_count, specifies the interval of each clock run (or clock ticks).
options Bitmask of pjmedia_clock_options.
cb Callback to be called for each clock tick.
user_data User data, which will be passed to the callback.
p_clock Pointer to receive the clock instance.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjmedia_clock_start ( pjmedia_clock clock  ) 

Start the clock. For clock created with asynchronous flag set to TRUE, this may start a worker thread for the clock (depending on the backend clock implementation being used).

Parameters:
clock The media clock.
Returns:
PJ_SUCCES on success.
pj_status_t pjmedia_clock_stop ( pjmedia_clock clock  ) 

Stop the clock.

Parameters:
clock The media clock.
Returns:
PJ_SUCCES on success.
pj_bool_t pjmedia_clock_wait ( pjmedia_clock clock,
pj_bool_t  wait,
pj_timestamp ts 
)

Poll the media clock, and execute the callback when the clock tick has elapsed. This operation is only valid if the clock is created with async flag set to FALSE.

Parameters:
clock The media clock.
wait If non-zero, then the function will block until a clock tick elapsed and callback has been called.
ts Optional argument to receive the current timestamp.
Returns:
Non-zero if clock tick has elapsed, or FALSE if the function returns before a clock tick has elapsed.
pj_status_t pjmedia_clock_destroy ( pjmedia_clock clock  ) 

Destroy the clock.

Parameters:
clock The media clock.
Returns:
PJ_SUCCES on success.

 


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