diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2011-07-19 03:42:28 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2011-07-19 03:42:28 +0000 |
commit | cd283c8825c9a94400f27735acb1c9385e90ffc8 (patch) | |
tree | 56d5722310fa8957ce5d1ba7cbd137cf8802dcc7 /pjsip/include/pjsua-lib | |
parent | ed8f8d08abba9040f769e922aa0c1adbde86fbbc (diff) |
Re #1326: Initial code integration from branch 2.0-dev to trunk as "2.0-pre-alpha-svn".
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3664 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include/pjsua-lib')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 755 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua_internal.h | 160 |
2 files changed, 831 insertions, 84 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index d3c2c759..bf72a4c1 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -250,6 +250,9 @@ PJ_BEGIN_DECL /** Constant to identify invalid ID for all sorts of IDs. */ #define PJSUA_INVALID_ID (-1) +/** Disabled features temporarily for media reorganization */ +#define DISABLED_FOR_TICKET_1185 0 + /** Call identification */ typedef int pjsua_call_id; @@ -282,8 +285,6 @@ typedef struct pjsua_msg_data pjsua_msg_data; # define PJSUA_ACC_MAX_PROXIES 8 #endif -#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) - /** * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED, * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY. @@ -303,8 +304,6 @@ typedef struct pjsua_msg_data pjsua_msg_data; #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1 #endif -#endif - /** * Controls whether PJSUA-LIB should add ICE media feature tag * parameter (the ";+sip.ice" parameter) to Contact header if ICE @@ -325,6 +324,132 @@ typedef struct pjsua_msg_data pjsua_msg_data; # define PJSUA_ACQUIRE_CALL_TIMEOUT 2000 #endif +/** + * Is video enabled. + */ +#ifndef PJSUA_HAS_VIDEO +# define PJSUA_HAS_VIDEO PJMEDIA_HAS_VIDEO +#endif + +/** + * This enumeration represents pjsua state. + */ +typedef enum pjsua_state +{ + /** + * The library has not been initialized. + */ + PJSUA_STATE_NULL, + + /** + * After pjsua_create() is called but before pjsua_init() is called. + */ + PJSUA_STATE_CREATED, + + /** + * After pjsua_init() is called but before pjsua_start() is called. + */ + PJSUA_STATE_INIT, + + /** + * After pjsua_start() is called but before everything is running. + */ + PJSUA_STATE_STARTING, + + /** + * After pjsua_start() is called and before pjsua_destroy() is called. + */ + PJSUA_STATE_RUNNING, + + /** + * After pjsua_destroy() is called but before the function returns. + */ + PJSUA_STATE_CLOSING + +} pjsua_state; + + +/** + * This enumeration represents video stream operation on a call. + * See also #pjsua_call_vid_strm_op_param for further info. + */ +typedef enum pjsua_call_vid_strm_op +{ + /** + * Add a new video stream. + */ + PJSUA_CALL_VID_STRM_ADD, + + /** + * Remove/disable an existing video stream. + */ + PJSUA_CALL_VID_STRM_REMOVE, + + /** + * Change direction of a video stream. + */ + PJSUA_CALL_VID_STRM_CHANGE_DIR, + + /** + * Change capture device of a video stream. + */ + PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, + + /** + * Start transmitting video stream. + */ + PJSUA_CALL_VID_STRM_START_TRANSMIT, + + /** + * Stop transmitting video stream. + */ + PJSUA_CALL_VID_STRM_STOP_TRANSMIT, + +} pjsua_call_vid_strm_op; + + +/** + * Parameters for video stream operation on a call. + */ +typedef struct pjsua_call_vid_strm_op_param +{ + /** + * Specify the media stream index. This can be set to -1 to denote + * the default video stream in the call, which is the first active + * video stream or any first video stream if none is active. + * + * This field is valid for all video stream operations, except + * PJSUA_CALL_VID_STRM_ADD. + * + * Default: -1 (first active video stream, or any first video stream + * if none is active) + */ + int med_idx; + + /** + * Specify the media stream direction. + * + * This field is valid for the following video stream operations: + * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR. + * + * Default: PJMEDIA_DIR_ENCODING_DECODING + */ + pjmedia_dir dir; + + /** + * Specify the video capture device ID. This can be set to + * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture + * device as configured in the account. + * + * This field is valid for the following video stream operations: + * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV. + * + * Default: capture device configured in account. + */ + pjmedia_vid_dev_index cap_dev; + +} pjsua_call_vid_strm_op_param; + /** * Logging configuration, which can be (optionally) specified when calling @@ -483,7 +608,7 @@ typedef struct pjsua_callback * media port then will be added to the conference bridge instead. * * @param call_id Call identification. - * @param sess Media session for the call. + * @param strm Media stream. * @param stream_idx Stream index in the media session. * @param p_port On input, it specifies the media port of the * stream. Application may modify this pointer to @@ -491,7 +616,7 @@ typedef struct pjsua_callback * to the conference bridge. */ void (*on_stream_created)(pjsua_call_id call_id, - pjmedia_session *sess, + pjmedia_stream *strm, unsigned stream_idx, pjmedia_port **p_port); @@ -500,11 +625,11 @@ typedef struct pjsua_callback * conference bridge and about to be destroyed. * * @param call_id Call identification. - * @param sess Media session for the call. + * @param strm Media stream. * @param stream_idx Stream index in the media session. */ void (*on_stream_destroyed)(pjsua_call_id call_id, - pjmedia_session *sess, + pjmedia_stream *strm, unsigned stream_idx); /** @@ -918,6 +1043,38 @@ typedef struct pjsua_callback void (*on_ice_transport_error)(int index, pj_ice_strans_op op, pj_status_t status, void *param); + /** + * Callback when the sound device is about to be opened or closed. + * This callback will be called even when null sound device or no + * sound device is configured by the application (i.e. the + * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs). + * This API is mostly useful when the application wants to manage + * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()), + * to get notified when it should open or close the sound device. + * + * @param operation The value will be set to 0 to signal that sound + * device is about to be closed, and 1 to be opened. + * + * @return The callback must return PJ_SUCCESS at the moment. + */ + pj_status_t (*on_snd_dev_operation)(int operation); + + /** + * Notification about media events such as video notifications. This + * callback will most likely be called from media threads, thus + * application must not perform heavy processing in this callback. + * Especially, application must not destroy the call or media in this + * callback. If application needs to perform more complex tasks to + * handle the event, it should post the task to another thread. + * + * @param call_id The call id. + * @param med_idx The media stream index. + * @param event The media event. + */ + void (*on_call_media_event)(pjsua_call_id call_id, + unsigned med_idx, + pjmedia_event *event); + } pjsua_callback; @@ -1154,7 +1311,6 @@ typedef struct pjsua_config */ pj_str_t user_agent; -#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) /** * Specify default value of secure media transport usage. * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and @@ -1184,15 +1340,14 @@ typedef struct pjsua_config int srtp_secure_signaling; /** - * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose + * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose * duplicated media in SDP offer, i.e: unsecured and secured version. - * Otherwise, the SDP media will be composed as unsecured media but + * Otherwise, the SDP media will be composed as unsecured media but * with SDP "crypto" attribute. * * Default: PJ_FALSE */ pj_bool_t srtp_optional_dup_offer; -#endif /** * Disconnect other call legs when more than one 2xx responses for @@ -1353,6 +1508,14 @@ PJ_DECL(pj_status_t) pjsua_destroy(void); /** + * Retrieve pjsua state. + * + * @return pjsua state. + */ +PJ_DECL(pjsua_state) pjsua_get_state(void); + + +/** * Poll pjsua for events, and if necessary block the caller thread for * the specified maximum interval (in miliseconds). * @@ -2093,7 +2256,6 @@ typedef enum pjsua_call_hold_type # define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264 #endif - /** * This structure describes account configuration to be specified when * adding a new account with #pjsua_acc_add(). Application MUST initialize @@ -2398,7 +2560,76 @@ typedef struct pjsua_acc_config */ pj_str_t ka_data; -#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) + /** + * Maximum number of simultaneous active audio streams to be allowed + * for calls on this account. Setting this to zero will disable audio + * in calls on this account. + * + * Default: 1 + */ + unsigned max_audio_cnt; + + /** + * Maximum number of simultaneous active video streams to be allowed + * for calls on this account. Setting this to zero will disable video + * in calls on this account, regardless of other video settings. + * + * Default: 1 + */ + unsigned max_video_cnt; + + /** + * Specify whether incoming video should be shown to screen by default. + * This applies to incoming call (INVITE), incoming re-INVITE, and + * incoming UPDATE requests. + * + * Regardless of this setting, application can detect incoming video + * by implementing \a on_call_media_state() callback and enumerating + * the media stream(s) with #pjsua_call_get_info(). Once incoming + * video is recognised, application may retrieve the window associated + * with the incoming video and show or hide it with + * #pjsua_vid_win_set_show(). + * + * Default: PJ_FALSE + */ + pj_bool_t vid_in_auto_show; + + /** + * Specify whether outgoing video should be activated by default when + * making outgoing calls and/or when incoming video is detected. This + * applies to incoming and outgoing calls, incoming re-INVITE, and + * incoming UPDATE. If the setting is non-zero, outgoing video + * transmission will be started as soon as response to these requests + * is sent (or received). + * + * Regardless of the value of this setting, application can start and + * stop outgoing video transmission with #pjsua_call_set_vid_out(). + * + * Default: PJ_FALSE + */ + pj_bool_t vid_out_auto_transmit; + + /** + * Specify the default capture device to be used by this account. If + * \a vid_out_auto_transmit is enabled, this device will be used for + * capturing video. + * + * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV + */ + pjmedia_vid_dev_index vid_cap_dev; + + /** + * Specify the default rendering device to be used by this account. + * + * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV + */ + pjmedia_vid_dev_index vid_rend_dev; + + /** + * Media transport config. + */ + pjsua_transport_config rtp_cfg; + /** * Specify whether secure media transport should be used for this account. * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and @@ -2422,15 +2653,14 @@ typedef struct pjsua_acc_config int srtp_secure_signaling; /** - * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose + * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose * duplicated media in SDP offer, i.e: unsecured and secured version. - * Otherwise, the SDP media will be composed as unsecured media but + * Otherwise, the SDP media will be composed as unsecured media but * with SDP "crypto" attribute. * * Default: PJ_FALSE */ pj_bool_t srtp_optional_dup_offer; -#endif /** * Specify interval of auto registration retry upon registration failure @@ -2926,6 +3156,17 @@ PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id, # define PJSUA_MAX_CALLS 32 #endif +/** + * Maximum active video windows + */ +#ifndef PJSUA_MAX_VID_WINS +# define PJSUA_MAX_VID_WINS 16 +#endif + +/** + * Video window ID. + */ +typedef int pjsua_vid_win_id; /** @@ -2934,19 +3175,29 @@ PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id, */ typedef enum pjsua_call_media_status { - /** Call currently has no media */ + /** + * Call currently has no media, or the media is not used. + */ PJSUA_CALL_MEDIA_NONE, - /** The media is active */ + /** + * The media is active + */ PJSUA_CALL_MEDIA_ACTIVE, - /** The media is currently put on hold by local endpoint */ + /** + * The media is currently put on hold by local endpoint + */ PJSUA_CALL_MEDIA_LOCAL_HOLD, - /** The media is currently put on hold by remote endpoint */ + /** + * The media is currently put on hold by remote endpoint + */ PJSUA_CALL_MEDIA_REMOTE_HOLD, - /** The media has reported error (e.g. ICE negotiation) */ + /** + * The media has reported error (e.g. ICE negotiation) + */ PJSUA_CALL_MEDIA_ERROR } pjsua_call_media_status; @@ -2993,15 +3244,59 @@ typedef struct pjsua_call_info /** The reason phrase describing the status. */ pj_str_t last_status_text; - /** Call media status. */ + /** Media status of the first audio stream. */ pjsua_call_media_status media_status; - /** Media direction */ + /** Media direction of the first audio stream. */ pjmedia_dir media_dir; - /** The conference port number for the call */ + /** The conference port number for the first audio stream. */ pjsua_conf_port_id conf_slot; + /** Number of media streams in this call */ + unsigned media_cnt; + + /** Array of media stream information */ + struct + { + /** Media index in SDP. */ + unsigned index; + + /** Media type. */ + pjmedia_type type; + + /** Media direction. */ + pjmedia_dir dir; + + /** Call media status. */ + pjsua_call_media_status status; + + /** The specific media stream info. */ + union { + /** Audio stream */ + struct { + /** The conference port number for the call. */ + pjsua_conf_port_id conf_slot; + } aud; + + /** Video stream */ + struct { + /** + * The window id for incoming video, if any, or + * PJSUA_INVALID_ID. + */ + pjsua_vid_win_id win_in; + + /** The video capture device for outgoing transmission, + * if any, or PJMEDIA_VID_INVALID_DEV + */ + pjmedia_vid_dev_index cap_dev; + + } vid; + } stream; + + } media[PJMEDIA_MAX_SDP_MEDIA]; + /** Up-to-date call connected duration (zero when call is not * established) */ @@ -3049,6 +3344,41 @@ typedef enum pjsua_call_flag } pjsua_call_flag; + +/** + * Media stream info. + */ +typedef struct pjsua_stream_info +{ + /** Media type of this stream. */ + pjmedia_type type; + + /** Stream info (union). */ + union { + /** Audio stream info */ + pjmedia_stream_info aud; + + /** Video stream info */ + pjmedia_vid_stream_info vid; + } info; + +} pjsua_stream_info; + + +/** + * Media stream statistic. + */ +typedef struct pjsua_stream_stat +{ + /** RTCP statistic. */ + pjmedia_rtcp_stat rtcp; + + /** Jitter buffer statistic. */ + pjmedia_jb_state jbuf; + +} pjsua_stream_stat; + + /** * Get maximum number of calls configured in pjsua. * @@ -3122,37 +3452,11 @@ PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id); /** - * Retrieve the media session associated with this call. Note that the media - * session may not be available depending on the current call's media status - * (the pjsua_call_media_status information in pjsua_call_info). Application - * may use the media session to retrieve more detailed information about the - * call's media. - * - * @param call_id Call identification. - * - * @return Call media session. - */ -PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id); - - -/** - * Retrieve the media transport instance that is used for this call. - * Application may use the media transport to query more detailed information - * about the media transport. - * - * @param cid Call identification (the call_id). - * - * @return Call media transport. - */ -PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid); - - -/** * Get the conference port identification associated with the call. * * @param call_id Call identification. * - * @return Conference port ID, or PJSUA_INVALID_ID when the + * @return Conference port ID, or PJSUA_INVALID_ID when the * media has not been established or is not active. */ PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id); @@ -3504,6 +3808,80 @@ PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id, const char *indent); /** + * Get the media stream index of the default video stream in the call. + * Typically this will just retrieve the stream index of the first + * activated video stream in the call. + * + * @param call_id Call identification. + * + * @return The media stream index or -1 if no video stream + * is present in the call. + */ +PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id); + + +/** + * Add, remove, modify, and/or manipulate video media stream for the + * specified call. This may trigger a re-INVITE or UPDATE to be sent + * for the call. + * + * @param call_id Call identification. + * @param op The video stream operation to be performed, + * possible values are #pjsua_call_vid_strm_op. + * @param param The parameters for the video stream operation, + * or NULL for the default parameter values + * (see #pjsua_call_vid_strm_op_param). + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pjsua_call_set_vid_strm ( + pjsua_call_id call_id, + pjsua_call_vid_strm_op op, + const pjsua_call_vid_strm_op_param *param); + + +/** + * Get media stream info for the specified media index. + * + * @param call_id The call identification. + * @param med_idx Media stream index. + * @param psi To be filled with the stream info. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id, + unsigned med_idx, + pjsua_stream_info *psi); + +/** + * Get media stream statistic for the specified media index. + * + * @param call_id The call identification. + * @param med_idx Media stream index. + * @param psi To be filled with the stream statistic. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id, + unsigned med_idx, + pjsua_stream_stat *stat); + +/** + * Get media transport info for the specified media index. + * + * @param call_id The call identification. + * @param med_idx Media stream index. + * @param t To be filled with the transport info. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pjsua_call_get_transport_info(pjsua_call_id call_id, + unsigned med_idx, + pjmedia_transport_info *t); + + + +/** * @} */ @@ -4311,9 +4689,14 @@ typedef struct pjsua_codec_info pj_uint8_t priority; /** + * Codec description. + */ + pj_str_t desc; + + /** * Internal buffer. */ - char buf_[32]; + char buf_[64]; } pjsua_codec_info; @@ -4374,8 +4757,6 @@ typedef struct pjsua_media_transport } pjsua_media_transport; - - /** * Get maxinum number of conference ports. * @@ -4923,8 +5304,7 @@ PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, const pjmedia_codec_param *param); - - +#if DISABLED_FOR_TICKET_1185 /** * Create UDP media transports for all the calls. This function creates * one UDP media transport for each call. @@ -4935,7 +5315,7 @@ PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, * * @return PJ_SUCCESS on success, or the appropriate error code. */ -PJ_DECL(pj_status_t) +PJ_DECL(pj_status_t) pjsua_media_transports_create(const pjsua_transport_config *cfg); @@ -4952,17 +5332,274 @@ pjsua_media_transports_create(const pjsua_transport_config *cfg); * * @return PJ_SUCCESS on success, or the appropriate error code. */ -PJ_DECL(pj_status_t) +PJ_DECL(pj_status_t) pjsua_media_transports_attach( pjsua_media_transport tp[], unsigned count, pj_bool_t auto_delete); +#endif +/* end of MEDIA API */ /** * @} */ +/***************************************************************************** + * VIDEO API + */ + + +/** + * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video + * @ingroup PJSUA_LIB + * @brief Video support + * @{ + */ + +/* + * Video devices API + */ + +/** + * Get the number of video devices installed in the system. + * + * @return The number of devices. + */ +PJ_DECL(unsigned) pjsua_vid_dev_count(void); + +/** + * Retrieve the video device info for the specified device index. + * + * @param id The device index. + * @param vdi Device info to be initialized. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id, + pjmedia_vid_dev_info *vdi); + +/** + * Enum all video devices installed in the system. + * + * @param info Array of info to be initialized. + * @param count On input, specifies max elements in the array. + * On return, it contains actual number of elements + * that have been initialized. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[], + unsigned *count); + + +/* + * Video preview API + */ + +/** + * Parameters for starting video preview with pjsua_vid_preview_start(). + * Application should initialize this structure with + * pjsua_vid_preview_param_default(). + */ +typedef struct pjsua_vid_preview_param +{ + /** + * Device ID for the video renderer to be used for rendering the + * capture stream for preview. + */ + pjmedia_vid_dev_index rend_id; +} pjsua_vid_preview_param; + + +/** + * Start video preview window for the specified capture device. + * + * @param id The capture device ID where its preview will be + * started. + * @param prm Optional video preview parameters. Specify NULL + * to use default values. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id, + pjsua_vid_preview_param *prm); + +/** + * Get the preview window handle associated with the capture device, if any. + * + * @param id The capture device ID. + * + * @return The window ID of the preview window for the + * specified capture device ID, or NULL if preview + * does not exist. + */ +PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id); + +/** + * Stop video preview. + * + * @param id The capture device ID. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id); + + +/* + * Video window manipulation API. + */ + +/** + * This structure describes video window info. + */ +typedef struct pjsua_vid_win_info +{ + /** + * Window show status. The window is hidden if false. + */ + pj_bool_t show; + + /** + * Window position. + */ + pjmedia_coord pos; + + /** + * Window size. + */ + pjmedia_rect_size size; + +} pjsua_vid_win_info; + + +/** + * Enumerates all video windows. + * + * @param id Array of window ID to be initialized. + * @param count On input, specifies max elements in the array. + * On return, it contains actual number of elements + * that have been initialized. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_enum_wins(pjsua_vid_win_id wids[], + unsigned *count); + + +/** + * Get window info. + * + * @param wid The video window ID. + * @param wi The video window info to be initialized. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid, + pjsua_vid_win_info *wi); + +/** + * Show or hide window. + * + * @param wid The video window ID. + * @param show Set to PJ_TRUE to show the window, PJ_FALSE to + * hide the window. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid, + pj_bool_t show); + +/** + * Set video window position. + * + * @param wid The video window ID. + * @param pos The window position. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid, + const pjmedia_coord *pos); + +/** + * Resize window. + * + * @param wid The video window ID. + * @param size The new window size. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid, + const pjmedia_rect_size *size); + + + +/* + * Video codecs API + */ + +/** + * Enum all supported video codecs in the system. + * + * @param id Array of ID to be initialized. + * @param count On input, specifies max elements in the array. + * On return, it contains actual number of elements + * that have been initialized. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[], + unsigned *count ); + + +/** + * Change video codec priority. + * + * @param codec_id Codec ID, which is a string that uniquely identify + * the codec (such as "H263/90000"). Please see pjsua + * manual or pjmedia codec reference for details. + * @param priority Codec priority, 0-255, where zero means to disable + * the codec. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id, + pj_uint8_t priority ); + + +/** + * Get video codec parameters. + * + * @param codec_id Codec ID. + * @param param Structure to receive video codec parameters. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_codec_get_param( + const pj_str_t *codec_id, + pjmedia_vid_codec_param *param); + + +/** + * Set video codec parameters. + * + * @param codec_id Codec ID. + * @param param Codec parameter to set. Set to NULL to reset + * codec parameter to library default settings. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_codec_set_param( + const pj_str_t *codec_id, + const pjmedia_vid_codec_param *param); + + + +/* end of VIDEO API */ +/** + * @} + */ + /** * @} diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index 92c9dce1..e712d9d3 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -39,16 +39,81 @@ typedef enum pjsua_med_tp_st PJSUA_MED_TP_INIT, /** Running (media_start() has been called) */ - PJSUA_MED_TP_RUNNING + PJSUA_MED_TP_RUNNING, + + /** Disabled (transport is initialized, but media is being disabled) */ + PJSUA_MED_TP_DISABLED } pjsua_med_tp_st; +/** Forward decl of pjsua call */ +typedef struct pjsua_call pjsua_call; + + +/** + * Call's media stream. + */ +typedef struct pjsua_call_media +{ + pjsua_call *call; /**< Parent call. */ + pjmedia_type type; /**< Media type. */ + unsigned idx; /**< This media index in parent call. */ + pjsua_call_media_status state; /**< Media state. */ + pjmedia_dir dir; /**< Media direction. */ + + /** The stream */ + struct { + /** Audio stream */ + struct { + pjmedia_stream *stream; /**< The audio stream. */ + int conf_slot; /**< Slot # in conference bridge. */ + } a; + + /** Video stream */ + struct { + pjmedia_vid_stream *stream; /**< The video stream. */ + pjsua_vid_win_id cap_win_id;/**< The video capture window */ + pjsua_vid_win_id rdr_win_id;/**< The video render window */ + pjmedia_vid_dev_index cap_dev; /**< The video capture device */ + pjmedia_vid_dev_index rdr_dev; /**< The video-in render device */ + } v; + + } strm; + + pj_uint32_t ssrc; /**< RTP SSRC */ + pj_uint32_t rtp_tx_ts; /**< Initial RTP timestamp for sender. */ + pj_uint16_t rtp_tx_seq;/**< Initial RTP sequence for sender. */ + pj_uint8_t rtp_tx_seq_ts_set; + /**< Bitmask flags if initial RTP sequence + and/or timestamp for sender are set. + bit 0/LSB : sequence flag + bit 1 : timestamp flag */ + + pjmedia_transport *tp; /**< Current media transport (can be 0) */ + pj_status_t tp_ready; /**< Media transport status. */ + pjmedia_transport *tp_orig; /**< Original media transport */ + pj_bool_t tp_auto_del; /**< May delete media transport */ + pjsua_med_tp_st tp_st; /**< Media transport state */ + pj_sockaddr rtp_addr; /**< Current RTP source address + (used to update ICE default + address) */ + pjmedia_srtp_use rem_srtp_use; /**< Remote's SRTP usage policy. */ + + pjmedia_event_subscription esub_rend;/**< Subscribe renderer events. */ + pjmedia_event_subscription esub_cap;/**< Subscribe capture events. */ +} pjsua_call_media; + +/** + * Maximum number of SDP "m=" lines to be supported. + */ +#define PJSUA_MAX_CALL_MEDIA PJMEDIA_MAX_SDP_MEDIA + /** * Structure to be attached to invite dialog. * Given a dialog "dlg", application can retrieve this structure * by accessing dlg->mod_data[pjsua.mod.id]. */ -typedef struct pjsua_call +struct pjsua_call { unsigned index; /**< Index in pjsua array. */ pjsip_inv_session *inv; /**< The invite session. */ @@ -63,31 +128,14 @@ typedef struct pjsua_call int secure_level;/**< Signaling security level. */ pjsua_call_hold_type call_hold_type; /**< How to do call hold. */ pj_bool_t local_hold;/**< Flag for call-hold by local. */ - pjsua_call_media_status media_st;/**< Media state. */ - pjmedia_dir media_dir; /**< Media direction. */ - pjmedia_session *session; /**< The media session. */ - int audio_idx; /**< Index of m=audio in SDP. */ - pj_uint32_t ssrc; /**< RTP SSRC */ - pj_uint32_t rtp_tx_ts; /**< Initial RTP timestamp for sender. */ - pj_uint16_t rtp_tx_seq;/**< Initial RTP sequence for sender. */ - pj_uint8_t rtp_tx_seq_ts_set; - /**< Bitmask flags if initial RTP sequence - and/or timestamp for sender are set. - bit 0/LSB : sequence flag - bit 1 : timestamp flag */ - int conf_slot; /**< Slot # in conference bridge. */ + + unsigned med_cnt; /**< Number of media in SDP. */ + pjsua_call_media media[PJSUA_MAX_CALL_MEDIA]; /**< Array of media */ + int audio_idx; /**< First active audio media. */ + pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this call was triggered by xfer. */ - pjmedia_transport *med_tp; /**< Current media transport. */ - pj_status_t med_tp_ready;/**< Media transport status. */ - pjmedia_transport *med_orig; /**< Original media transport */ - pj_bool_t med_tp_auto_del; /**< May delete media transport */ - pjsua_med_tp_st med_tp_st; /**< Media transport state */ - pj_sockaddr med_rtp_addr; /**< Current RTP source address - (used to update ICE default - address) */ pj_stun_nat_type rem_nat_type; /**< NAT type of remote endpoint. */ - pjmedia_srtp_use rem_srtp_use; /**< Remote's SRTP usage policy. */ char last_text_buf_[128]; /**< Buffer for last_text. */ @@ -99,7 +147,7 @@ typedef struct pjsua_call } lock_codec; /**< Data for codec locking when answer contains multiple codecs. */ -} pjsua_call; +}; /** @@ -259,6 +307,23 @@ typedef struct pjsua_stun_resolve pj_stun_sock *stun_sock; /**< Testing STUN sock */ } pjsua_stun_resolve; +typedef enum pjsua_vid_win_type +{ + PJSUA_WND_TYPE_NONE, + PJSUA_WND_TYPE_PREVIEW, + PJSUA_WND_TYPE_STREAM +} pjsua_vid_win_type; + +typedef struct pjsua_vid_win +{ + pjsua_vid_win_type type; /**< Type. */ + pj_pool_t *pool; /**< Own pool. */ + unsigned ref_cnt; /**< Reference counter. */ + pjmedia_vid_port *vp_cap; /**< Capture vidport. */ + pjmedia_vid_port *vp_rend; /**< Renderer vidport */ + pjmedia_port *tee; /**< Video tee */ + pjmedia_vid_dev_index preview_cap_id;/* Capture dev id */ +} pjsua_vid_win; /** * Global pjsua application data. @@ -270,6 +335,7 @@ struct pjsua_data pj_caching_pool cp; /**< Global pool factory. */ pj_pool_t *pool; /**< pjsua's private pool. */ pj_mutex_t *mutex; /**< Mutex protection for this data */ + pjsua_state state; /**< Library state. */ /* Logging: */ pjsua_logging_config log_cfg; /**< Current logging config. */ @@ -339,7 +405,11 @@ struct pjsua_data pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */ pjmedia_master_port *null_snd; /**< Master port for null sound. */ pjmedia_port *null_port; /**< Null port. */ + pj_bool_t snd_is_on; /**< Media flow is currently active */ + /* Video device */ + pjmedia_vid_dev_index vcap_dev; /**< Capture device ID. */ + pjmedia_vid_dev_index vrdr_dev; /**< Playback device ID. */ /* File players: */ unsigned player_cnt;/**< Number of file players. */ @@ -348,6 +418,11 @@ struct pjsua_data /* File recorders: */ unsigned rec_cnt; /**< Number of file recorders. */ pjsua_file_data recorder[PJSUA_MAX_RECORDERS];/**< Array of recs.*/ + + /* Video windows */ +#if PJSUA_HAS_VIDEO + pjsua_vid_win win[PJSUA_MAX_VID_WINS]; /**< Array of windows */ +#endif }; @@ -402,6 +477,9 @@ PJ_INLINE(pjsua_im_data*) pjsua_im_data_dup(pj_pool_t *pool, #define PJSUA_UNLOCK() #endif +/* Core */ +void pjsua_set_state(pjsua_state new_state); + /****** * STUN resolution */ @@ -438,6 +516,17 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, const pjmedia_sdp_session *remote_sdp); pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id); +pj_status_t pjsua_call_media_init(pjsua_call_media *call_med, + pjmedia_type type, + const pjsua_transport_config *tcfg, + int security_level, + int *sip_err_code); +pj_status_t video_channel_update(pjsua_call_media *call_med, + pj_pool_t *tmp_pool, + const pjmedia_sdp_session *local_sdp, + const pjmedia_sdp_session *remote_sdp); +void stop_video_stream(pjsua_call_media *call_med); + /** * Init presence. @@ -579,6 +668,27 @@ void print_call(const char *title, int call_id, char *buf, pj_size_t size); +/* + * Video + */ +pj_status_t pjsua_vid_subsys_init(void); +pj_status_t pjsua_vid_subsys_start(void); +pj_status_t pjsua_vid_subsys_destroy(void); + +PJ_INLINE(void) pjsua_vid_win_reset(pjsua_vid_win_id wid) +{ +#if PJSUA_HAS_VIDEO + pjsua_vid_win *w = &pjsua_var.win[wid]; + pj_pool_t *pool = w->pool; + + pj_bzero(w, sizeof(*w)); + if (pool) pj_pool_reset(pool); + w->ref_cnt = 0; + w->pool = pool; + w->preview_cap_id = PJMEDIA_VID_INVALID_DEV; +#endif +} + PJ_END_DECL |