diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2011-09-27 05:24:06 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2011-09-27 05:24:06 +0000 |
commit | ba2dc4a7b2dc047fafca1f64c3503f0b1d40e473 (patch) | |
tree | 213670834574f38022cc009e6530d78d039238f8 /pjsip | |
parent | 6fe9c8763fd075ddd2affec20e4a9d880dc0bdb7 (diff) |
Close #1360: implementated video orientation (currently only for video devices).
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3774 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 15 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_vid.c | 60 |
2 files changed, 75 insertions, 0 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index f768438d..e3ba048a 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -5718,6 +5718,21 @@ PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid, PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid, const pjmedia_rect_size *size); +/** + * Rotate the video window. This function will change the video orientation + * and also possibly the video window size (width and height get swapped). + * This operation is not valid for native windows (pjsua_vid_win_info.is_native + * =PJ_TRUE), on which native windowing API must be used instead. + * + * @param wid The video window ID. + * @param angle The rotation angle in degrees, must be multiple of 90. + * Specify positive value for clockwise rotation or + * negative value for counter-clockwise rotation. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_win_rotate(pjsua_vid_win_id wid, + int angle); /* diff --git a/pjsip/src/pjsua-lib/pjsua_vid.c b/pjsip/src/pjsua-lib/pjsua_vid.c index ddce5324..fe9c5925 100644 --- a/pjsip/src/pjsua-lib/pjsua_vid.c +++ b/pjsip/src/pjsua-lib/pjsua_vid.c @@ -1363,6 +1363,66 @@ PJ_DEF(pj_status_t) pjsua_vid_win_set_size( pjsua_vid_win_id wid, return status; } +/* + * Set video orientation. + */ +PJ_DEF(pj_status_t) pjsua_vid_win_rotate( pjsua_vid_win_id wid, + int angle) +{ + pjsua_vid_win *w; + pjmedia_vid_dev_stream *s; + pjmedia_orient orient; + pj_status_t status; + + PJ_ASSERT_RETURN(wid >= 0 && wid < PJSUA_MAX_VID_WINS, PJ_EINVAL); + PJ_ASSERT_RETURN((angle % 90) == 0, PJ_EINVAL); + + /* Normalize angle, so it must be 0, 90, 180, or 270. */ + angle %= 360; + if (angle < 0) + angle += 360; + + /* Convert angle to pjmedia_orient */ + switch(angle) { + case 0: + /* No rotation */ + return PJ_SUCCESS; + case 90: + orient = PJMEDIA_ORIENT_ROTATE_90DEG; + break; + case 180: + orient = PJMEDIA_ORIENT_ROTATE_180DEG; + break; + case 270: + orient = PJMEDIA_ORIENT_ROTATE_270DEG; + break; + default: + pj_assert(!"Angle must have been validated"); + return PJ_EBUG; + } + + PJSUA_LOCK(); + w = &pjsua_var.win[wid]; + if (w->vp_rend == NULL) { + /* Native window */ + PJSUA_UNLOCK(); + return PJ_EINVAL; + } + + s = pjmedia_vid_port_get_stream(w->vp_rend); + if (s == NULL) { + PJSUA_UNLOCK(); + return PJ_EINVAL; + } + + status = pjmedia_vid_dev_stream_set_cap(s, + PJMEDIA_VID_DEV_CAP_ORIENTATION, &orient); + + PJSUA_UNLOCK(); + + return status; +} + static void call_get_vid_strm_info(pjsua_call *call, int *first_active, |