Thread based media clock provider.
More...
A master port has two media ports connected to it, and by convention thay are called downstream and upstream ports. The media stream flowing to the downstream port is called encoding or send direction, and media stream flowing to the upstream port is called decoding or receive direction (imagine the downstream as stream to remote endpoint, and upstream as local media port; media flowing to remote endpoint (downstream) will need to be encoded before it is transmitted to remote endpoint).
A master port internally has an instance of Clock Generator, which provides the essensial timing for the master port. The Clock Generator runs asynchronously, and whenever a clock tick expires, a callback will be called, and the master port performs the following tasks:
- it calls
get_frame()
from the downstream port, when give the frame to the upstream port by calling put_frame
to the upstream port, and
- performs the same task, but on the reverse direction (i.e. get the stream from upstream port and give it to the downstream port).
Because master port enables media stream to flow automatically, it is said that the master port supplies Clock/Timing to the media ports interconnection.
◆ pjmedia_master_port
Opaque declaration for master port.
◆ pjmedia_master_port_create()
Create a master port.
- Parameters
-
pool | Pool to allocate master port from. |
u_port | Upstream port. |
d_port | Downstream port. |
options | Options flags, from bitmask combinations from pjmedia_clock_options. |
p_m | Pointer to receive the master port instance. |
- Returns
- PJ_SUCCESS on success.
◆ pjmedia_master_port_start()
Start the media flow.
- Parameters
-
- Returns
- PJ_SUCCESS on success.
◆ pjmedia_master_port_stop()
Stop the media flow.
- Parameters
-
- Returns
- PJ_SUCCESS on success.
◆ pjmedia_master_port_wait()
Poll the master port clock and execute the callback when the clock tick has elapsed. This operation is only valid if the master port is created with PJMEDIA_CLOCK_NO_ASYNC flag.
- Parameters
-
m | The master port. |
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.
◆ pjmedia_master_port_set_uport()
Change the upstream port. Note that application is responsible to destroy current upstream port (the one that is going to be replaced with the new port).
- Parameters
-
m | The master port. |
port | Port to be used for upstream port. |
- Returns
- PJ_SUCCESS on success.
◆ pjmedia_master_port_get_uport()
Get the upstream port.
- Parameters
-
- Returns
- The upstream port.
◆ pjmedia_master_port_set_dport()
Change the downstream port. Note that application is responsible to destroy current downstream port (the one that is going to be replaced with the new port).
- Parameters
-
m | The master port. |
port | Port to be used for downstream port. |
- Returns
- PJ_SUCCESS on success.
◆ pjmedia_master_port_get_dport()
Get the downstream port.
- Parameters
-
- Returns
- The downstream port.
◆ pjmedia_master_port_destroy()
Destroy the master port, and optionally destroy the upstream and downstream ports.
- Parameters
-
m | The master port. |
destroy_ports | If non-zero, the function will destroy both upstream and downstream ports too. |
- Returns
- PJ_SUCCESS on success.
References PJ_END_DECL.