/* $Id$ */ /* * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __PJMEDIA_VID_STREAM_H__ #define __PJMEDIA_VID_STREAM_H__ /** * @file vid_stream.h * @brief Video Stream. */ #include #include #include #include #include #include #include #include #include PJ_BEGIN_DECL /** * @defgroup PJMED_VID_STRM Video streams * @ingroup PJMEDIA_PORT * @brief Video communication via the network * @{ * * 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 @ref PJMEDIA_PORT), * 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: * - an instance of video codec (see @ref PJMEDIA_VID_CODEC), * - an @ref PJMED_JBUF, * - two instances of RTP sessions (#pjmedia_rtp_session, one for each * direction), * - one instance of RTCP session (#pjmedia_rtcp_session), * - and a reference to video transport to send and receive packets * to/from the network (see @ref PJMEDIA_TRANSPORT). * * 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 of video stream sending rate control. */ typedef enum pjmedia_vid_stream_rc_method { /** * No sending rate control. All outgoing RTP packets will be transmitted * immediately right after encoding process is done. */ PJMEDIA_VID_STREAM_RC_NONE = 0, /** * 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. */ PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING = 1 } pjmedia_vid_stream_rc_method; /** * Structure of configuration settings for video stream sending rate control. */ typedef struct pjmedia_vid_stream_rc_config { /** * Rate control method. * * Default: PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING. */ pjmedia_vid_stream_rc_method method; /** * Upstream/outgoing bandwidth. If this is set to zero, the video stream * will use codec maximum bitrate setting. * * Default: 0 (follow codec maximum bitrate). */ unsigned bandwidth; } pjmedia_vid_stream_rc_config; /** * Structure of configuration settings for video stream sending keyframe * after it is created. */ typedef struct pjmedia_vid_stream_sk_config { /** * The number of keyframe to be sent after the stream is created. * * Default: PJMEDIA_VID_STREAM_START_KEYFRAME_CNT */ unsigned count; /** * The keyframe sending interval after the stream is created. * * Default: PJMEDIA_VID_STREAM_START_KEYFRAME_INTERVAL_MSEC */ unsigned interval; } pjmedia_vid_stream_sk_config; /** * This structure describes video stream information. Each video stream * corresponds to one "m=" line in SDP session descriptor, and it has * its own RTP/RTCP socket pair. */ typedef struct pjmedia_vid_stream_info { pjmedia_type type; /**< Media type (audio, video) */ pjmedia_tp_proto proto; /**< Transport protocol (RTP/AVP, etc.) */ pjmedia_dir dir; /**< Media direction. */ pj_sockaddr rem_addr; /**< Remote RTP address */ pj_sockaddr rem_rtcp; /**< Optional remote RTCP address. If sin_family is zero, the RTP address will be calculated from RTP. */ pj_bool_t rtcp_mux; /**< Use RTP and RTCP multiplexing. */ pjmedia_rtcp_fb_info loc_rtcp_fb; /**< Local RTCP-FB info. */ pjmedia_rtcp_fb_info rem_rtcp_fb; /**< Remote RTCP-FB info. */ unsigned tx_pt; /**< Outgoing codec paylaod type. */ unsigned rx_pt; /**< Incoming codec paylaod type. */ pj_uint32_t ssrc; /**< RTP SSRC. */ pj_str_t cname; /**< RTCP CNAME. */ pj_bool_t has_rem_ssrc;/**