Group PJMED_ENDPT

group PJMED_ENDPT

The media endpoint acts as placeholder for endpoint capabilities. Each media endpoint will have a codec manager to manage list of codecs installed in the endpoint and a sound device factory.

A reference to media endpoint instance is required when application wants to create a media session (pjmedia_session_create()).

Typedefs

typedef void (*pjmedia_endpt_exit_callback)(pjmedia_endpt *endpt)

Type of callback to register to pjmedia_endpt_atexit().

Enums

enum pjmedia_endpt_flag

This enumeration describes various flags that can be set or retrieved in the media endpoint, by using pjmedia_endpt_set_flag() and pjmedia_endpt_get_flag() respectively.

Values:

enumerator PJMEDIA_ENDPT_HAS_TELEPHONE_EVENT_FLAG

This flag controls whether telephony-event should be offered in SDP. Value is boolean.

Functions

void pjmedia_endpt_create_sdp_param_default(pjmedia_endpt_create_sdp_param *param)

Call this function to initialize pjmedia_endpt_create_sdp_param with default values.

Parameters:

param – The param to be initialized.

pj_status_t pjmedia_endpt_create2(pj_pool_factory *pf, pj_ioqueue_t *ioqueue, unsigned worker_cnt, pjmedia_endpt **p_endpt)

Create an instance of media endpoint.

Parameters:
  • pf – Pool factory, which will be used by the media endpoint throughout its lifetime.

  • ioqueue – Optional ioqueue instance to be registered to the endpoint. The ioqueue instance is used to poll all RTP and RTCP sockets. If this argument is NULL, the endpoint will create an internal ioqueue instance.

  • worker_cnt – Specify the number of worker threads to be created to poll the ioqueue.

  • p_endpt – Pointer to receive the endpoint instance.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_create(pj_pool_factory *pf, pj_ioqueue_t *ioqueue, unsigned worker_cnt, pjmedia_endpt **p_endpt)

Create an instance of media endpoint and initialize audio subsystem.

Parameters:
  • pf – Pool factory, which will be used by the media endpoint throughout its lifetime.

  • ioqueue – Optional ioqueue instance to be registered to the endpoint. The ioqueue instance is used to poll all RTP and RTCP sockets. If this argument is NULL, the endpoint will create an internal ioqueue instance.

  • worker_cnt – Specify the number of worker threads to be created to poll the ioqueue.

  • p_endpt – Pointer to receive the endpoint instance.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_destroy2(pjmedia_endpt *endpt)

Destroy media endpoint instance.

Parameters:

endpt – Media endpoint instance.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_destroy(pjmedia_endpt *endpt)

Destroy media endpoint instance and shutdown audio subsystem.

Parameters:

endpt – Media endpoint instance.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_set_flag(pjmedia_endpt *endpt, pjmedia_endpt_flag flag, const void *value)

Change the value of a flag.

Parameters:
  • endpt – Media endpoint.

  • flag – The flag.

  • value – Pointer to the value to be set.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_get_flag(pjmedia_endpt *endpt, pjmedia_endpt_flag flag, void *value)

Retrieve the value of a flag.

Parameters:
  • endpt – Media endpoint.

  • flag – The flag.

  • value – Pointer to store the result.

Returns:

PJ_SUCCESS on success.

pj_ioqueue_t *pjmedia_endpt_get_ioqueue(pjmedia_endpt *endpt)

Get the ioqueue instance of the media endpoint.

Parameters:

endpt – The media endpoint instance.

Returns:

The ioqueue instance of the media endpoint.

unsigned pjmedia_endpt_get_thread_count(pjmedia_endpt *endpt)

Get the number of worker threads on the media endpoint

Parameters:

endpt – The media endpoint instance.

Returns:

The number of worker threads on the media endpoint

pj_thread_t *pjmedia_endpt_get_thread(pjmedia_endpt *endpt, unsigned index)

Get a reference to one of the worker threads of the media endpoint

Parameters:
  • endpt – The media endpoint instance.

  • index – The index of the thread: 0<= index < thread_cnt

Returns:

pj_thread_t or NULL

pj_status_t pjmedia_endpt_stop_threads(pjmedia_endpt *endpt)

Stop and destroy the worker threads of the media endpoint

Parameters:

endpt – The media endpoint instance.

Returns:

PJ_SUCCESS on success.

pj_pool_t *pjmedia_endpt_create_pool(pjmedia_endpt *endpt, const char *name, pj_size_t initial, pj_size_t increment)

Request the media endpoint to create pool.

Parameters:
  • endpt – The media endpoint instance.

  • name – Name to be assigned to the pool.

  • initial – Initial pool size, in bytes.

  • increment – Increment size, in bytes.

Returns:

Memory pool.

pjmedia_codec_mgr *pjmedia_endpt_get_codec_mgr(pjmedia_endpt *endpt)

Get the codec manager instance of the media endpoint.

Parameters:

endpt – The media endpoint instance.

Returns:

The instance of codec manager belonging to this media endpoint.

pj_status_t pjmedia_endpt_create_sdp(pjmedia_endpt *endpt, pj_pool_t *pool, unsigned stream_cnt, const pjmedia_sock_info sock_info[], pjmedia_sdp_session **p_sdp)

Create a SDP session description that describes the endpoint capability.

Parameters:
  • endpt – The media endpoint.

  • pool – Pool to use to create the SDP descriptor.

  • stream_cnt – Number of elements in the sock_info array. This also denotes the maximum number of streams (i.e. the “m=” lines) that will be created in the SDP. By convention, if this value is greater than one, the first media will be audio and the remaining media is video.

  • sock_info – Array of socket transport information. One transport is needed for each media stream, and each transport consists of an RTP and RTCP socket pair.

  • p_sdp – Pointer to receive SDP session descriptor.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_create_base_sdp(pjmedia_endpt *endpt, pj_pool_t *pool, const pj_str_t *sess_name, const pj_sockaddr *origin, pjmedia_sdp_session **p_sdp)

Create a “blank” SDP session description. The SDP will contain basic SDP fields such as origin, time, and name, but without any media lines.

Parameters:
  • endpt – The media endpoint.

  • pool – Pool to allocate memory from.

  • sess_name – Optional SDP session name, or NULL to use default value.

  • origin – Address to put in the origin field.

  • p_sdp – Pointer to receive the created SDP session.

Returns:

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjmedia_endpt_create_audio_sdp(pjmedia_endpt *endpt, pj_pool_t *pool, const pjmedia_sock_info *si, const pjmedia_endpt_create_sdp_param *options, pjmedia_sdp_media **p_m)

Create SDP media line for audio media.

Parameters:
  • endpt – The media endpoint.

  • pool – Pool to allocate memory from.

  • si – Socket information.

  • options – Options parameter, can be NULL. If set to NULL, default values will be used.

  • p_m – Pointer to receive the created SDP media.

Returns:

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjmedia_endpt_create_video_sdp(pjmedia_endpt *endpt, pj_pool_t *pool, const pjmedia_sock_info *si, const pjmedia_endpt_create_sdp_param *options, pjmedia_sdp_media **p_m)

Create SDP media line for video media.

Parameters:
  • endpt – The media endpoint.

  • pool – Pool to allocate memory from.

  • si – Socket information.

  • options – Options parameter, can be NULL. If set to NULL, default values will be used.

  • p_m – Pointer to receive the created SDP media.

Returns:

PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjmedia_endpt_dump(pjmedia_endpt *endpt)

Dump media endpoint capabilities.

Parameters:

endpt – The media endpoint.

Returns:

PJ_SUCCESS on success.

pj_status_t pjmedia_endpt_atexit(pjmedia_endpt *endpt, pjmedia_endpt_exit_callback func)

Register cleanup function to be called by media endpoint when pjmedia_endpt_destroy() is called. Note that application should not use or access any endpoint resource (such as pool, ioqueue) from within the callback as such resource may have been released when the callback function is invoked.

Parameters:
  • endpt – The media endpoint.

  • func – The function to be registered.

Returns:

PJ_SUCCESS on success.

struct pjmedia_endpt_create_sdp_param
#include <endpoint.h>

This structure specifies various settings that can be passed when creating audio/video sdp.

Public Members

pjmedia_dir dir

Direction of the media.

Default: PJMEDIA_DIR_ENCODING_DECODING