From 97f362db7fa1fad9a0258bdb5e218b80dab93031 Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Thu, 25 Jun 2015 08:17:52 +0000 Subject: Re #1861: Initial implementation of video orientation support - Utility to resize and rotate video frame - Support for iOS + sample - pjsua API to set video device's orientation git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5118 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua.h | 26 ++++++++++++++++++++++++++ pjsip/src/pjsua-lib/pjsua_vid.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) (limited to 'pjsip') diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 56c3c82a..8cc91f28 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -6599,6 +6599,32 @@ PJ_DECL(unsigned) pjsua_vid_dev_count(void); PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id, pjmedia_vid_dev_info *vdi); +/** + * Check whether the video capture device is currently active, i.e. if + * a video preview has been started or there is a video call using + * the device. This function will return PJ_FALSE for video renderer device. + * + * @param id The video device index. + * + * @return PJ_TRUE if active, PJ_FALSE otherwise. + */ +PJ_DECL(pj_bool_t) pjsua_vid_dev_is_active(pjmedia_vid_dev_index id); + +/** + * Set the orientation of the video device. The function only works + * for video capture device and if the device is currently active (i.e. + * a video preview has been started or there is a video call using the device). + * Application can check if a video device is active by calling + * #pjsua_vid_dev_is_active(). + * + * @param id The video device index. + * @param orient Video device orientation. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_dev_set_orient(pjmedia_vid_dev_index id, + pjmedia_orient orient); + /** * Enum all video devices installed in the system. * diff --git a/pjsip/src/pjsua-lib/pjsua_vid.c b/pjsip/src/pjsua-lib/pjsua_vid.c index e2bbab40..54d23ad2 100644 --- a/pjsip/src/pjsua-lib/pjsua_vid.c +++ b/pjsip/src/pjsua-lib/pjsua_vid.c @@ -32,6 +32,8 @@ #define PJSUA_HIDE_WINDOW 0 +static pjsua_vid_win_id vid_preview_get_win(pjmedia_vid_dev_index id, + pj_bool_t running_only); static void free_vid_win(pjsua_vid_win_id wid); /***************************************************************************** @@ -213,6 +215,41 @@ PJ_DEF(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id, return pjmedia_vid_dev_get_info(id, vdi); } +/* + * Check whether the video device is currently active. + */ +PJ_DEF(pj_bool_t) pjsua_vid_dev_is_active(pjmedia_vid_dev_index id) +{ + pjsua_vid_win_id wid = vid_preview_get_win(id, PJ_FALSE); + + return (wid != PJSUA_INVALID_ID? PJ_TRUE: PJ_FALSE); +} + +/* + * Set the orientation of the video device. + */ +PJ_DEF(pj_status_t) pjsua_vid_dev_set_orient( pjmedia_vid_dev_index id, + pjmedia_orient orient) +{ + pjsua_vid_win *w; + pjmedia_vid_dev_stream *cap_dev; + pjsua_vid_win_id wid = vid_preview_get_win(id, PJ_FALSE); + + if (wid == PJSUA_INVALID_ID) { + PJ_LOG(3, (THIS_FILE, "Unable to set orientation for video dev %d: " + "device not active", id)); + return PJ_ENOTFOUND; + } + + w = &pjsua_var.win[wid]; + + cap_dev = pjmedia_vid_port_get_stream(w->vp_cap); + + return pjmedia_vid_dev_stream_set_cap(cap_dev, + PJMEDIA_VID_DEV_CAP_ORIENTATION, + &orient); +} + /* * Enum all video devices installed in the system. */ -- cgit v1.2.3