BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJMEDIA Reference

Video communication via the network. More...

Data Structures

struct  pjmedia_vid_stream_rc_config
 
struct  pjmedia_vid_stream_sk_config
 
struct  pjmedia_vid_stream_info
 

Typedefs

typedef struct pjmedia_vid_stream pjmedia_vid_stream
 

Enumerations

enum  pjmedia_vid_stream_rc_method {
  PJMEDIA_VID_STREAM_RC_NONE = 0,
  PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING = 1
}
 

Functions

pj_status_t pjmedia_vid_stream_info_from_sdp (pjmedia_vid_stream_info *si, pj_pool_t *pool, pjmedia_endpt *endpt, const pjmedia_sdp_session *local, const pjmedia_sdp_session *remote, unsigned stream_idx)
 
void pjmedia_vid_stream_rc_config_default (pjmedia_vid_stream_rc_config *cfg)
 
void pjmedia_vid_stream_sk_config_default (pjmedia_vid_stream_sk_config *cfg)
 
pj_status_t pjmedia_vid_stream_create (pjmedia_endpt *endpt, pj_pool_t *pool, pjmedia_vid_stream_info *info, pjmedia_transport *tp, void *user_data, pjmedia_vid_stream **p_stream)
 
pj_status_t pjmedia_vid_stream_destroy (pjmedia_vid_stream *stream)
 
pj_status_t pjmedia_vid_stream_get_port (pjmedia_vid_stream *stream, pjmedia_dir dir, pjmedia_port **p_port)
 
pjmedia_transportpjmedia_vid_stream_get_transport (pjmedia_vid_stream *st)
 
pj_status_t pjmedia_vid_stream_get_stat (const pjmedia_vid_stream *stream, pjmedia_rtcp_stat *stat)
 
pj_status_t pjmedia_vid_stream_reset_stat (pjmedia_vid_stream *stream)
 
pj_status_t pjmedia_vid_stream_get_stat_jbuf (const pjmedia_vid_stream *stream, pjmedia_jb_state *state)
 
pj_status_t pjmedia_vid_stream_get_info (const pjmedia_vid_stream *stream, pjmedia_vid_stream_info *info)
 
pj_status_t pjmedia_vid_stream_start (pjmedia_vid_stream *stream)
 
pj_bool_t pjmedia_vid_stream_is_running (pjmedia_vid_stream *stream, pjmedia_dir dir)
 
pj_status_t pjmedia_vid_stream_pause (pjmedia_vid_stream *stream, pjmedia_dir dir)
 
pj_status_t pjmedia_vid_stream_resume (pjmedia_vid_stream *stream, pjmedia_dir dir)
 
pj_status_t pjmedia_vid_stream_send_keyframe (pjmedia_vid_stream *stream)
 
pj_status_t pjmedia_vid_stream_send_rtcp_sdes (pjmedia_vid_stream *stream)
 
pj_status_t pjmedia_vid_stream_send_rtcp_bye (pjmedia_vid_stream *stream)
 
pj_status_t pjmedia_vid_stream_get_rtp_session_info (pjmedia_vid_stream *stream, pjmedia_stream_rtp_sess_info *session_info)
 

Detailed Description

A video stream is a bidirectional video communication between two endpoints. It corresponds to a video media description ("m=video" line) in SDP session descriptor.

A video stream consists of two unidirectional channels:

  • encoding channel, which transmits unidirectional video to remote, and
  • decoding channel, which receives unidirectional media from remote.

A video stream exports two media port interface (see Media Ports Framework), one for each direction, and application normally uses this interface to interconnect the stream to other PJMEDIA components, e.g: the video capture port supplies frames to the encoding port and video renderer consumes frames from the decoding port.

A video stream internally manages the following objects:

Video streams are created by calling pjmedia_vid_stream_create(), specifying pjmedia_stream_info structure in the parameter. Application can construct the pjmedia_vid_stream_info structure manually, or use pjmedia_vid_stream_info_from_sdp() function to construct the #pjmedia_vid stream_info from local and remote SDP session descriptors.

Enumeration Type Documentation

◆ pjmedia_vid_stream_rc_method

Enumeration of video stream sending rate control.

Enumerator
PJMEDIA_VID_STREAM_RC_NONE 

No sending rate control. All outgoing RTP packets will be transmitted immediately right after encoding process is done.

PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING 

Simple blocking. Each outgoing RTP packet transmission may be delayed to avoid peak bandwidth that is much higher than specified. The thread invoking the video stream put_frame(), e.g: video capture device thread, will be blocked whenever transmission delay takes place.

Function Documentation

◆ pjmedia_vid_stream_info_from_sdp()

pj_status_t pjmedia_vid_stream_info_from_sdp ( pjmedia_vid_stream_info si,
pj_pool_t pool,
pjmedia_endpt endpt,
const pjmedia_sdp_session local,
const pjmedia_sdp_session remote,
unsigned  stream_idx 
)

This function will initialize the video stream info based on information in both SDP session descriptors for the specified stream index. The remaining information will be taken from default codec parameters. If socket info array is specified, the socket will be copied to the session info as well.

Parameters
siStream info structure to be initialized.
poolPool to allocate memory.
endptPJMEDIA endpoint instance.
localLocal SDP session descriptor.
remoteRemote SDP session descriptor.
stream_idxMedia stream index in the session descriptor.
Returns
PJ_SUCCESS if stream info is successfully initialized.

◆ pjmedia_vid_stream_rc_config_default()

void pjmedia_vid_stream_rc_config_default ( pjmedia_vid_stream_rc_config cfg)

Initialize the video stream rate control with default settings.

Parameters
cfgVideo stream rate control structure to be initialized.

◆ pjmedia_vid_stream_sk_config_default()

void pjmedia_vid_stream_sk_config_default ( pjmedia_vid_stream_sk_config cfg)

Initialize the video stream send keyframe with default settings.

Parameters
cfgVideo stream send keyframe structure to be initialized.

◆ pjmedia_vid_stream_create()

pj_status_t pjmedia_vid_stream_create ( pjmedia_endpt endpt,
pj_pool_t pool,
pjmedia_vid_stream_info info,
pjmedia_transport tp,
void *  user_data,
pjmedia_vid_stream **  p_stream 
)

Create a video stream based on the specified parameter. After the video stream has been created, application normally would want to get the media port interface of the stream, by calling pjmedia_vid_stream_get_port(). The media port interface exports put_frame() and get_frame() function, used to transmit and receive media frames from the stream.

Without application calling put_frame() and get_frame(), there will be no media frames transmitted or received by the stream.

Parameters
endptMedia endpoint.
poolOptional pool to allocate memory for the stream. If this is not specified, one will be created internally. A large number of memory may be needed because jitter buffer needs to preallocate some storage.
infoStream information to create the stream. Upon return, this info will be updated with the information from the instantiated codec. Note that if the "pool" argument is NULL, some fields in this "info" parameter will be allocated from the internal pool of the stream, which means that they will only remain valid as long as the stream is not destroyed.
tpMedia transport instance used to transmit and receive RTP/RTCP packets to/from the underlying network.
user_dataArbitrary user data (for future callback feature).
p_streamPointer to receive the video stream.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_destroy()

pj_status_t pjmedia_vid_stream_destroy ( pjmedia_vid_stream *  stream)

Destroy the video stream.

Parameters
streamThe video stream.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_get_port()

pj_status_t pjmedia_vid_stream_get_port ( pjmedia_vid_stream *  stream,
pjmedia_dir  dir,
pjmedia_port **  p_port 
)

Get the media port interface of the stream. The media port interface declares put_frame() and get_frame() function, which is the only way for application to transmit and receive media frames from the stream. As bidirectional video streaming may have different video formats in the encoding and decoding direction, there are two media ports exported by the video stream, one for each direction.

Parameters
streamThe video stream.
dirThe video direction.
p_portPointer to receive the port interface.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_get_transport()

pjmedia_transport* pjmedia_vid_stream_get_transport ( pjmedia_vid_stream *  st)

Get the media transport object associated with this stream.

Parameters
stThe video stream.
Returns
The transport object being used by the stream.

◆ pjmedia_vid_stream_get_stat()

pj_status_t pjmedia_vid_stream_get_stat ( const pjmedia_vid_stream *  stream,
pjmedia_rtcp_stat stat 
)

Get the stream statistics. See also pjmedia_stream_get_stat_jbuf()

Parameters
streamThe video stream.
statMedia stream statistics.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_reset_stat()

pj_status_t pjmedia_vid_stream_reset_stat ( pjmedia_vid_stream *  stream)

Reset the video stream statistics.

Parameters
streamThe video stream.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_get_stat_jbuf()

pj_status_t pjmedia_vid_stream_get_stat_jbuf ( const pjmedia_vid_stream *  stream,
pjmedia_jb_state state 
)

Get current jitter buffer state. See also pjmedia_stream_get_stat()

Parameters
streamThe video stream.
stateJitter buffer state.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_get_info()

pj_status_t pjmedia_vid_stream_get_info ( const pjmedia_vid_stream *  stream,
pjmedia_vid_stream_info info 
)

Get the stream info.

Parameters
streamThe video stream.
infoVideo stream info.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_start()

pj_status_t pjmedia_vid_stream_start ( pjmedia_vid_stream *  stream)

Start the video stream. This will start the appropriate channels in the video stream, depending on the video direction that was set when the stream was created.

Parameters
streamThe video stream.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_is_running()

pj_bool_t pjmedia_vid_stream_is_running ( pjmedia_vid_stream *  stream,
pjmedia_dir  dir 
)

Query if the stream is started on the specified direction.

Parameters
streamThe video stream.
dirThe direction to be checked.
Returns
PJ_TRUE if stream is started.

◆ pjmedia_vid_stream_pause()

pj_status_t pjmedia_vid_stream_pause ( pjmedia_vid_stream *  stream,
pjmedia_dir  dir 
)

Pause stream channels.

Parameters
streamThe video stream.
dirWhich channel direction to pause.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_resume()

pj_status_t pjmedia_vid_stream_resume ( pjmedia_vid_stream *  stream,
pjmedia_dir  dir 
)

Resume stream channels.

Parameters
streamThe video stream.
dirWhich channel direction to resume.
Returns
PJ_SUCCESS on success;

◆ pjmedia_vid_stream_send_keyframe()

pj_status_t pjmedia_vid_stream_send_keyframe ( pjmedia_vid_stream *  stream)

Force stream to send video keyframe on the next transmission.

Parameters
streamThe video stream.
Returns
PJ_SUCCESS on success;

◆ pjmedia_vid_stream_send_rtcp_sdes()

pj_status_t pjmedia_vid_stream_send_rtcp_sdes ( pjmedia_vid_stream *  stream)

Send RTCP SDES for the media stream.

Parameters
streamThe media stream.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_send_rtcp_bye()

pj_status_t pjmedia_vid_stream_send_rtcp_bye ( pjmedia_vid_stream *  stream)

Send RTCP BYE for the media stream.

Parameters
streamThe media stream.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_stream_get_rtp_session_info()

pj_status_t pjmedia_vid_stream_get_rtp_session_info ( pjmedia_vid_stream *  stream,
pjmedia_stream_rtp_sess_info session_info 
)

Get the RTP session information of the video media stream. This function can be useful for app with custom media transport to inject/filter some outgoing/incoming proprietary packets into normal video RTP traffics. This will return the original pointer to the internal states of the stream, and generally it is not advisable for app to modify them.

Parameters
streamThe video media stream.
session_infoThe stream session info.
Returns
PJ_SUCCESS on success.

 


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