From ba2dc4a7b2dc047fafca1f64c3503f0b1d40e473 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 27 Sep 2011 05:24:06 +0000 Subject: 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 --- pjmedia/include/pjmedia-videodev/videodev.h | 19 +++++++++++++++ pjmedia/include/pjmedia/event.h | 7 +++++- pjmedia/include/pjmedia/types.h | 37 +++++++++++++++++++++++++++++ pjmedia/src/pjmedia-videodev/videodev.c | 4 ++++ 4 files changed, 66 insertions(+), 1 deletion(-) (limited to 'pjmedia') diff --git a/pjmedia/include/pjmedia-videodev/videodev.h b/pjmedia/include/pjmedia-videodev/videodev.h index 0c3d4c82..208b96c6 100644 --- a/pjmedia/include/pjmedia-videodev/videodev.h +++ b/pjmedia/include/pjmedia-videodev/videodev.h @@ -193,6 +193,18 @@ typedef enum pjmedia_vid_dev_cap */ PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW = 64, + /** + * Support for changing video orientation in renderer and querying + * video orientation info in capture. Changing video orientation in + * a renderer will potentially affect the size of render window, + * i.e: width and height swap. When a capture device supports this + * capability, it will generate event PJMEDIA_EVENT_ORIENT_CHANGED + * (see #pjmedia_event) everytime the capture orientation is changed. + * + * The value of this capability is pjmedia_orient. + */ + PJMEDIA_VID_DEV_CAP_ORIENTATION = 128, + /** * End of standard capability */ @@ -369,6 +381,13 @@ typedef struct pjmedia_vid_dev_param */ pj_bool_t native_preview; + /** + * Video orientation. This setting is optional and is only used if + * PJMEDIA_VID_DEV_CAP_ORIENTATION capability is supported and is + * set in the flags. + */ + pjmedia_orient orient; + } pjmedia_vid_dev_param; diff --git a/pjmedia/include/pjmedia/event.h b/pjmedia/include/pjmedia/event.h index ddcffc02..259f7264 100644 --- a/pjmedia/include/pjmedia/event.h +++ b/pjmedia/include/pjmedia/event.h @@ -78,7 +78,12 @@ typedef enum pjmedia_event_type /** * Video decoding error due to missing key frame event. */ - PJMEDIA_EVENT_KEY_FRAME_MISSING = PJMEDIA_FOURCC('I', 'F', 'R', 'M') + PJMEDIA_EVENT_KEY_FRAME_MISSING = PJMEDIA_FOURCC('I', 'F', 'R', 'M'), + + /** + * Video orientation has been changed event. + */ + PJMEDIA_EVENT_ORIENT_CHANGED = PJMEDIA_FOURCC('O', 'R', 'N', 'T') } pjmedia_event_type; diff --git a/pjmedia/include/pjmedia/types.h b/pjmedia/include/pjmedia/types.h index 6a660f0c..20e93d69 100644 --- a/pjmedia/include/pjmedia/types.h +++ b/pjmedia/include/pjmedia/types.h @@ -191,6 +191,43 @@ typedef struct pjmedia_rect pjmedia_rect_size size; /**< The size. */ } pjmedia_rect; +/** + * Enumeration for video/picture orientation. + */ +typedef enum pjmedia_orient +{ + /** + * Unknown orientation. + */ + PJMEDIA_ORIENT_UNKNOWN, + + /** + * Natural orientation, e.g: sky upside on landscape view, head upside + * on human portrait. + */ + PJMEDIA_ORIENT_NATURAL, + + /** + * Specifies that the video/picture needs to be rotated 90 degrees + * clockwise to be displayed in natural orientation. + */ + PJMEDIA_ORIENT_ROTATE_90DEG, + + /** + * Specifies that the video/picture needs to be rotated 180 degrees + * clockwise to be displayed in natural orientation. + */ + PJMEDIA_ORIENT_ROTATE_180DEG, + + /** + * Specifies that the video/picture needs to be rotated 270 degrees + * clockwise to be displayed in natural orientation. + */ + PJMEDIA_ORIENT_ROTATE_270DEG + +} pjmedia_orient; + + /** * Macro for packing format from a four character code, similar to FOURCC. */ diff --git a/pjmedia/src/pjmedia-videodev/videodev.c b/pjmedia/src/pjmedia-videodev/videodev.c index f2523d79..6921f67b 100644 --- a/pjmedia/src/pjmedia-videodev/videodev.c +++ b/pjmedia/src/pjmedia-videodev/videodev.c @@ -45,6 +45,7 @@ static struct cap_info DEFINE_CAP("position", "Renderer position"), DEFINE_CAP("hide", "Renderer hide"), DEFINE_CAP("preview", "Input preview"), + DEFINE_CAP("orientation", "Video orientation") }; @@ -179,6 +180,9 @@ static pj_status_t get_cap_pointer(const pjmedia_vid_dev_param *param, case PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW: FIELD_INFO(native_preview); break; + case PJMEDIA_VID_DEV_CAP_ORIENTATION: + FIELD_INFO(orient); + break; default: return PJMEDIA_EVID_INVCAP; } -- cgit v1.2.3