From e485c1bee41247d998f62fae1cdf0edd7fb93925 Mon Sep 17 00:00:00 2001 From: Riza Sulistyo Date: Wed, 1 Jul 2015 02:20:12 +0000 Subject: Re #1863: Initial implementation of PJSUA2 Video Codec API and Video Device API. - Codec management (enum codec, set prio, get param, set param) - Device management (enum dev, dev count, dev info). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5123 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua2/endpoint.hpp | 60 +++++++++++++++++++-- pjsip/include/pjsua2/media.hpp | 109 +++++++++++++++++++++++++++++++++++++- 2 files changed, 163 insertions(+), 6 deletions(-) (limited to 'pjsip/include') diff --git a/pjsip/include/pjsua2/endpoint.hpp b/pjsip/include/pjsua2/endpoint.hpp index 0001da1b..7d71231a 100644 --- a/pjsip/include/pjsua2/endpoint.hpp +++ b/pjsip/include/pjsua2/endpoint.hpp @@ -1069,6 +1069,13 @@ public: */ AudDevManager &audDevManager(); + /** + * Get the instance of Video Device Manager. + * + * @return The Video Device Manager. + */ + VidDevManager &vidDevManager(); + /************************************************************************* * Codec management operations */ @@ -1095,10 +1102,10 @@ public: /** * Get codec parameters. * - * @param codec_id Codec ID. + * @param codec_id Codec ID. * - * @return Codec parameters. If codec is not found, Error - * will be thrown. + * @return Codec parameters. If codec is not found, Error + * will be thrown. * */ CodecParam codecGetParam(const string &codec_id) const throw(Error); @@ -1114,6 +1121,47 @@ public: void codecSetParam(const string &codec_id, const CodecParam param) throw(Error); + /** + * Enum all supported video codecs in the system. + * + * @return Array of video codec info. + */ + const CodecInfoVector &videoCodecEnum() throw(Error); + + /** + * 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. + * + */ + void videoCodecSetPriority(const string &codec_id, + pj_uint8_t priority) throw(Error); + + /** + * Get video codec parameters. + * + * @param codec_id Codec ID. + * + * @return Codec parameters. If codec is not found, Error + * will be thrown. + * + */ + CodecParam videoCodecGetParam(const string &codec_id) const throw(Error); + + /** + * 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. + * + */ + void videoCodecSetParam(const string &codec_id, + const CodecParam param) throw(Error); public: /* @@ -1182,7 +1230,9 @@ private: LogWriter *writer; // Custom writer, if any AudioMediaVector mediaList; AudDevManager audioDevMgr; + VidDevManager videoDevMgr; CodecInfoVector codecInfoList; + CodecInfoVector videoCodecInfoList; std::map threadDescMap; /* Pending logging */ @@ -1316,7 +1366,9 @@ private: unsigned flags); private: - void clearCodecInfoList(); + void clearCodecInfoList(CodecInfoVector &codec_list); + void updateCodecInfoList(pjsua_codec_info pj_codec[], unsigned count, + CodecInfoVector &codec_list); }; diff --git a/pjsip/include/pjsua2/media.hpp b/pjsip/include/pjsua2/media.hpp index 16df4ca5..c3bf6e2d 100644 --- a/pjsip/include/pjsua2/media.hpp +++ b/pjsip/include/pjsua2/media.hpp @@ -89,12 +89,22 @@ struct MediaFormatAudio : public MediaFormat */ struct MediaFormatVideo : public MediaFormat { - unsigned width; /**< Video width. */ - unsigned height; /**< Video height. */ + unsigned width; /**< Video width. */ + unsigned height; /**< Video height. */ int fpsNum; /**< Frames per second numerator. */ int fpsDenum; /**< Frames per second denumerator. */ pj_uint32_t avgBps; /**< Average bitrate. */ pj_uint32_t maxBps; /**< Maximum bitrate. */ + + /** + * Construct from pjmedia_format. + */ + void fromPj(const pjmedia_format &format); + + /** + * Export to pjmedia_format. + */ + pjmedia_format toPj() const; }; /** Array of MediaFormat */ @@ -1587,6 +1597,101 @@ private: pjmedia_vid_dev_index devId; }; +/** + * Video device information structure. + */ +struct VideoDevInfo +{ + /** + * The device name + */ + string name; + + /** + * The underlying driver name + */ + string driver; + + /** + * The supported direction of the video device, i.e. whether it supports + * capture only, render only, or both. + */ + pjmedia_dir dir; + + /** + * Device capabilities, as bitmask combination of #pjmedia_vid_dev_cap + */ + unsigned caps; + + /** + * Array of supported video formats. Some fields in each supported video + * format may be set to zero or of "unknown" value, to indicate that the + * value is unknown or should be ignored. When these value are not set + * to zero, it indicates that the exact format combination is being used. + */ + MediaFormatVector fmt; + + /** + * Construct from pjmedia_vid_dev_info. + */ + void fromPj(const pjmedia_vid_dev_info &dev_info); + + /** + * Destructor. + */ + ~VideoDevInfo(); +}; + +/** Array of video device info */ +typedef std::vector VideoDevInfoVector; + +/** + * Video device manager. + */ +class VidDevManager { +public: + /** + * Get the number of video devices installed in the system. + * + * @return The number of devices. + */ + unsigned getDevCount(); + + /** + * Retrieve the video device info for the specified device index. + * + * @param dev_id The video device id + * + * @return The list of video device info + */ + VideoDevInfo getDevInfo(int dev_id) const throw(Error); + + /** + * Enum all video devices installed in the system. + * + * @return The list of video device info + */ + const VideoDevInfoVector &enumDev() throw(Error); + +private: + VideoDevInfoVector videoDevList; + + void clearVideoDevList(); + + /** + * Constructor. + */ + VidDevManager(); + + /** + * Destructor. + */ + ~VidDevManager(); + + friend class Endpoint; +}; + + /************************************************************************* * Codec management */ -- cgit v1.2.3