From 18061c77b205207a29aeb61414c1040affeeae3b Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Wed, 18 Mar 2015 08:25:24 +0000 Subject: Re #1823 (PJSUA2 Video API): Add Pjsua2 Video Window API and Pjsua API to set output window git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4996 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua.h | 14 ++++ pjsip/include/pjsua2/call.hpp | 7 ++ pjsip/include/pjsua2/media.hpp | 163 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 184 insertions(+) (limited to 'pjsip/include') diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 1ebde412..e730790c 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -6814,6 +6814,20 @@ 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); +/** + * Set output window. This operation is valid only when the underlying + * video device supports PJMEDIA_VIDEO_DEV_CAP_OUTPUT_WINDOW capability AND + * allows the output window to be changed on-the-fly. Currently it is only + * supported on Android. + * + * @param wid The video window ID. + * @param win The new output window. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_vid_win_set_win(pjsua_vid_win_id wid, + const pjmedia_vid_dev_hwnd *win); + /** * Rotate the video window. This function will change the video orientation * and also possibly the video window size (width and height get swapped). diff --git a/pjsip/include/pjsua2/call.hpp b/pjsip/include/pjsua2/call.hpp index 510ad64d..0614270e 100644 --- a/pjsip/include/pjsua2/call.hpp +++ b/pjsip/include/pjsua2/call.hpp @@ -412,6 +412,13 @@ struct CallMediaInfo */ pjsua_vid_win_id videoIncomingWindowId; + /** + * The video window instance for incoming video. Only valid if + * videoIncomingWindowId is not PJSUA_INVALID_ID and + * the media type is video. + */ + VideoWindow videoWindow; + /** * The video capture device for outgoing transmission, if any, * or PJMEDIA_VID_INVALID_DEV. Only valid if the media type is video. diff --git a/pjsip/include/pjsua2/media.hpp b/pjsip/include/pjsua2/media.hpp index 99dd532e..181001e4 100644 --- a/pjsip/include/pjsua2/media.hpp +++ b/pjsip/include/pjsua2/media.hpp @@ -1325,6 +1325,169 @@ private: friend class Endpoint; }; + +/************************************************************************* +* Video media +*/ + +/** + * Representation of media coordinate. + */ +struct MediaCoordinate +{ + int x; /**< X position of the coordinate */ + int y; /**< Y position of the coordinate */ +}; + +/** + * Representation of media size. + */ +struct MediaSize +{ + unsigned w; /**< The width. */ + unsigned h; /**< The height. */ +}; + +/** + * Window handle. + */ +typedef struct WindowHandle { + void *window; /**< Window */ + void *display; /**< Display */ +} WindowHandle; + +/** + * Video window handle. + */ +struct VideoWindowHandle +{ + /** + * The window handle type. + */ + pjmedia_vid_dev_hwnd_type type; + + /** + * The window handle. + */ + WindowHandle handle; +}; + +/** + * This structure describes video window info. + */ +typedef struct VideoWindowInfo +{ + /** + * Flag to indicate whether this window is a native window, + * such as created by built-in preview device. If this field is + * true, only the video window handle field of this + * structure is valid. + */ + bool isNative; + + /** + * Video window handle. + */ + VideoWindowHandle winHandle; + + /** + * Renderer device ID. + */ + int renderDeviceId; + + /** + * Window show status. The window is hidden if false. + */ + bool show; + + /** + * Window position. + */ + MediaCoordinate pos; + + /** + * Window size. + */ + MediaSize size; + +} VideoWindowInfo; + +/** + * Video window. + */ +class VideoWindow +{ +public: + /** + * Constructor + */ + VideoWindow(int win_id); + + /** + * Get window info. + * + * @return video window info. + */ + VideoWindowInfo getInfo() const throw(Error); + + /** + * Show or hide window. This operation is not valid for native windows + * (VideoWindowInfo.isNative=true), on which native windowing API + * must be used instead. + * + * @param show Set to true to show the window, false to + * hide the window. + * + */ + void Show(bool show) throw(Error); + + /** + * Set video window position. This operation is not valid for native windows + * (VideoWindowInfo.isNative=true), on which native windowing API + * must be used instead. + * + * @param pos The window position. + * + */ + void setPos(const MediaCoordinate &pos) throw(Error); + + /** + * Resize window. This operation is not valid for native windows + * (VideoWindowInfo.isNative=true), on which native windowing API + * must be used instead. + * + * @param size The new window size. + * + */ + void setSize(const MediaSize &size) throw(Error); + + /** + * 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 (VideoWindowInfo.isNative + * =true), on which native windowing API must be used instead. + * + * @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. + */ + void rotate(int angle) throw(Error); + + /** + * Set output window. This operation is valid only when the underlying + * video device supports PJMEDIA_VIDEO_DEV_CAP_OUTPUT_WINDOW capability AND + * allows the output window to be changed on-the-fly, otherwise Error will + * be thrown. Currently it is only supported on Android. + * + * @param win The new output window. + */ + void setWindow(const VideoWindowHandle &win) throw(Error); + +private: + pjsua_vid_win_id winId; +}; + /************************************************************************* * Codec management */ -- cgit v1.2.3