Changeset 3471
- Timestamp:
- Mar 22, 2011 9:49:23 AM (14 years ago)
- Location:
- pjproject/branches/projects/2.0-dev/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjsip/include/pjsua-lib/pjsua.h
r3463 r3471 4935 4935 4936 4936 /***************************************************************************** 4937 * Video devices. 4938 */ 4939 4940 /** 4941 * Enum all video devices installed in the system. 4942 * 4943 * @param info Array of info to be initialized. 4944 * @param count On input, specifies max elements in the array. 4945 * On return, it contains actual number of elements 4946 * that have been initialized. 4947 * 4948 * @return PJ_SUCCESS on success, or the appropriate error code. 4949 */ 4950 PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[], 4951 unsigned *count); 4952 4953 4954 /** 4955 * Get currently active video devices. If video devices has not been created 4956 * (for example when pjsua_start() is not called), it is possible that 4957 * the function returns PJ_SUCCESS with -1 as device IDs. 4958 * 4959 * @param capture_dev On return it will be filled with device ID of the 4960 * capture device. 4961 * @param render_dev On return it will be filled with device ID of the 4962 * device ID of the render device. 4963 * 4964 * @return PJ_SUCCESS on success, or the appropriate error code. 4965 */ 4966 PJ_DECL(pj_status_t) pjsua_vid_get_dev(int *capture_dev, int *render_dev); 4967 4968 4969 /** 4970 * Select video device for the next video sessions. 4971 * 4972 * @param capture_dev Device ID of the capture device. 4973 * @param render_dev Device ID of the render device. 4974 * 4975 * @return PJ_SUCCESS on success, or the appropriate error code. 4976 */ 4977 PJ_DECL(pj_status_t) pjsua_vid_set_dev(int capture_dev, int render_dev); 4978 4979 4980 /** 4981 * Configure video device setting to the video device being used. If video 4982 * device is currently active, the function will forward the setting to the 4983 * video device instance to be applied immediately, if it supports it. 4984 * 4985 * The setting will be saved for future opening of the video device, if the 4986 * "keep" argument is set to non-zero. If the video device is currently 4987 * inactive, and the "keep" argument is false, this function will return 4988 * error. 4989 * 4990 * Note that in case the setting is kept for future use, it will be applied 4991 * to any devices, even when application has changed the video device to be 4992 * used. 4993 * 4994 * See also #pjmedia_vid_dev_stream_set_cap() for more information about 4995 * setting an video device capability. 4996 * 4997 * @param cap The video device setting to change. 4998 * @param pval Pointer to value. Please see #pjmedia_vid_dev_cap 4999 * documentation about the type of value to be 5000 * supplied for each setting. 5001 * @param keep Specify whether the setting is to be kept for future 5002 * use. 5003 * 5004 * @return PJ_SUCCESS on success or the appropriate error code. 5005 */ 5006 PJ_DECL(pj_status_t) pjsua_vid_set_setting(pjmedia_vid_dev_cap cap, 5007 const void *pval, 5008 pj_bool_t keep); 5009 5010 /** 5011 * Retrieve a video device setting. If video device is currently active, 5012 * the function will forward the request to the video device. If video device 5013 * is currently inactive, and if application had previously set the setting 5014 * and mark the setting as kept, then that setting will be returned. 5015 * Otherwise, this function will return error. 5016 * 5017 * @param cap The video device setting to retrieve. 5018 * @param pval Pointer to receive the value. 5019 * Please see #pjmedia_vid_dev_cap documentation about 5020 * the type of value to be supplied for each setting. 5021 * 5022 * @return PJ_SUCCESS on success or the appropriate error code. 5023 */ 5024 PJ_DECL(pj_status_t) pjsua_vid_get_setting(pjmedia_vid_dev_cap cap, 5025 void *pval); 5026 5027 5028 /***************************************************************************** 4937 5029 * Codecs. 4938 5030 */ … … 4990 5082 PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, 4991 5083 const pjmedia_codec_param *param); 5084 5085 /***************************************************************************** 5086 * Video codecs. 5087 */ 5088 5089 /** 5090 * Enum all supported video codecs in the system. 5091 * 5092 * @param id Array of ID to be initialized. 5093 * @param count On input, specifies max elements in the array. 5094 * On return, it contains actual number of elements 5095 * that have been initialized. 5096 * 5097 * @return PJ_SUCCESS on success, or the appropriate error code. 5098 */ 5099 PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[], 5100 unsigned *count ); 5101 5102 5103 /** 5104 * Change video codec priority. 5105 * 5106 * @param codec_id Codec ID, which is a string that uniquely identify 5107 * the codec (such as "H263/90000"). Please see pjsua 5108 * manual or pjmedia codec reference for details. 5109 * @param priority Codec priority, 0-255, where zero means to disable 5110 * the codec. 5111 * 5112 * @return PJ_SUCCESS on success, or the appropriate error code. 5113 */ 5114 PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id, 5115 pj_uint8_t priority ); 5116 5117 5118 /** 5119 * Get video codec parameters. 5120 * 5121 * @param codec_id Codec ID. 5122 * @param param Structure to receive video codec parameters. 5123 * 5124 * @return PJ_SUCCESS on success, or the appropriate error code. 5125 */ 5126 PJ_DECL(pj_status_t) pjsua_vid_codec_get_param( 5127 const pj_str_t *codec_id, 5128 pjmedia_vid_codec_param *param); 5129 5130 5131 /** 5132 * Set video codec parameters. 5133 * 5134 * @param codec_id Codec ID. 5135 * @param param Codec parameter to set. Set to NULL to reset 5136 * codec parameter to library default settings. 5137 * 5138 * @return PJ_SUCCESS on success, or the appropriate error code. 5139 */ 5140 PJ_DECL(pj_status_t) pjsua_vid_codec_set_param( 5141 const pj_str_t *codec_id, 5142 const pjmedia_vid_codec_param *param); 5143 4992 5144 4993 5145 #if DISABLED_FOR_TICKET_1185 -
pjproject/branches/projects/2.0-dev/pjsip/include/pjsua-lib/pjsua_internal.h
r3465 r3471 384 384 385 385 386 /* Video device */ 387 pjmedia_vid_dev_index vcap_dev; /**< Capture device ID. */ 388 pjmedia_vid_dev_index vrdr_dev; /**< Playback device ID. */ 389 386 390 /* File players: */ 387 391 unsigned player_cnt;/**< Number of file players. */ -
pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_core.c
r3463 r3471 635 635 pjsua_var.play_dev = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV; 636 636 637 /* Set default video device ID */ 638 pjsua_var.vcap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 639 pjsua_var.vrdr_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; 640 637 641 /* Init caching pool. */ 638 642 pj_caching_pool_init(&pjsua_var.cp, NULL, 0); -
pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_media.c
r3463 r3471 59 59 } 60 60 61 62 PJ_DECL(pj_status_t) 63 pjmedia_libswscale_converter_init(pjmedia_converter_mgr *mgr, 64 pj_pool_t *pool); 65 61 66 /** 62 67 * Init media subsystems. … … 310 315 if (status != PJ_SUCCESS) { 311 316 pjsua_perror(THIS_FILE, "Error initializing ffmpeg library", 317 status); 318 return status; 319 } 320 #endif 321 322 #if PJMEDIA_HAS_VIDEO && PJMEDIA_HAS_LIBSWSCALE && PJMEDIA_HAS_LIBAVUTIL 323 status = pjmedia_libswscale_converter_init(NULL, pjsua_var.pool); 324 if (status != PJ_SUCCESS) { 325 pjsua_perror(THIS_FILE, "Error initializing libswscale converter", 312 326 status); 313 327 return status; … … 1837 1851 call_med->strm.a.stream = NULL; 1838 1852 } 1839 } else if (call_med->type == PJMEDIA_TYPE_VIDEO) { 1853 } 1854 1855 #if PJMEDIA_HAS_VIDEO 1856 else if (call_med->type == PJMEDIA_TYPE_VIDEO) { 1840 1857 pjmedia_vid_stream *strm = call_med->strm.v.stream; 1841 1858 … … 1873 1890 } 1874 1891 } 1892 #endif 1875 1893 1876 1894 PJ_LOG(4,(THIS_FILE, "Media session call%02d:%d is destroyed", … … 2134 2152 } 2135 2153 2154 2155 #if PJMEDIA_HAS_VIDEO 2156 2136 2157 static pj_status_t video_channel_update(pjsua_call_media *call_med, 2137 2158 pj_pool_t *tmp_pool, … … 2212 2233 #endif 2213 2234 2235 /* Try to get shared format ID between the capture device and 2236 * the encoder to avoid format conversion in the capture device. 2237 */ 2238 if (si->dir & PJMEDIA_DIR_ENCODING) { 2239 pjmedia_vid_dev_info dev_info; 2240 pjmedia_vid_codec_info *codec_info = &si->codec_info; 2241 unsigned i, j; 2242 2243 status = pjmedia_vid_dev_get_info(pjsua_var.vcap_dev, &dev_info); 2244 if (status != PJ_SUCCESS) 2245 return status; 2246 2247 /* Find matched format ID */ 2248 for (i = 0; i < codec_info->dec_fmt_id_cnt; ++i) { 2249 for (j = 0; j < dev_info.fmt_cnt; ++j) { 2250 if (codec_info->dec_fmt_id[i] == 2251 (pjmedia_format_id)dev_info.fmt[j].id) 2252 { 2253 /* Apply the matched format ID to the codec */ 2254 si->codec_param->dec_fmt.id = codec_info->dec_fmt_id[i]; 2255 /* Force outer loop to break */ 2256 i = codec_info->dec_fmt_id_cnt; 2257 break; 2258 } 2259 } 2260 } 2261 } 2262 2214 2263 /* Create session based on session info. */ 2215 2264 status = pjmedia_vid_stream_create(pjsua_var.med_endpt, NULL, si, … … 2235 2284 2236 2285 status = pjmedia_vid_dev_default_param( 2237 tmp_pool, PJMEDIA_VID_DEFAULT_RENDER_DEV,2286 tmp_pool, pjsua_var.vrdr_dev, 2238 2287 &vport_param.vidparam); 2239 2288 if (status != PJ_SUCCESS) … … 2275 2324 2276 2325 status = pjmedia_vid_dev_default_param( 2277 tmp_pool, PJMEDIA_VID_DEFAULT_CAPTURE_DEV,2326 tmp_pool, pjsua_var.vcap_dev, 2278 2327 &vport_param.vidparam); 2279 2328 if (status != PJ_SUCCESS) … … 2282 2331 pjmedia_format_copy(&vport_param.vidparam.fmt, 2283 2332 &media_port->info.fmt); 2284 2285 2333 vport_param.vidparam.dir = PJMEDIA_DIR_CAPTURE; 2286 2334 vport_param.active = PJ_TRUE; … … 2353 2401 } 2354 2402 2403 #endif 2404 2355 2405 2356 2406 pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, … … 2395 2445 } 2396 2446 break; 2447 #if PJMEDIA_HAS_VIDEO 2397 2448 case PJMEDIA_TYPE_VIDEO: 2398 2449 status = video_channel_update(call_med, tmp_pool, 2399 2450 local_sdp, remote_sdp); 2400 2451 break; 2452 #endif 2401 2453 default: 2402 2454 break; … … 3772 3824 3773 3825 if (count != 1) 3774 return PJ_ENOTFOUND;3826 return (count > 1? PJ_ETOOMANY : PJ_ENOTFOUND); 3775 3827 3776 3828 status = pjmedia_codec_mgr_get_default_param( codec_mgr, info, param); … … 3809 3861 return status; 3810 3862 } 3863 3864 3865 #if PJMEDIA_HAS_VIDEO 3866 3867 /***************************************************************************** 3868 * Video codecs. 3869 */ 3870 3871 /* 3872 * Enum all supported video codecs in the system. 3873 */ 3874 PJ_DEF(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[], 3875 unsigned *p_count ) 3876 { 3877 pjmedia_vid_codec_info info[32]; 3878 unsigned i, j, count, prio[32]; 3879 pj_status_t status; 3880 3881 count = PJ_ARRAY_SIZE(info); 3882 status = pjmedia_vid_codec_mgr_enum_codecs(NULL, &count, info, prio); 3883 if (status != PJ_SUCCESS) { 3884 *p_count = 0; 3885 return status; 3886 } 3887 3888 for (i=0, j=0; i<count && j<*p_count; ++i) { 3889 if (info[i].has_rtp_pack) { 3890 pjmedia_vid_codec_info_to_id(&info[i], id[j].buf_, sizeof(id[j].buf_)); 3891 id[j].codec_id = pj_str(id[j].buf_); 3892 id[j].priority = (pj_uint8_t) prio[i]; 3893 ++j; 3894 } 3895 } 3896 3897 *p_count = j; 3898 3899 return PJ_SUCCESS; 3900 } 3901 3902 3903 /* 3904 * Change video codec priority. 3905 */ 3906 PJ_DEF(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id, 3907 pj_uint8_t priority ) 3908 { 3909 const pj_str_t all = { NULL, 0 }; 3910 3911 if (codec_id->slen==1 && *codec_id->ptr=='*') 3912 codec_id = &all; 3913 3914 return pjmedia_vid_codec_mgr_set_codec_priority(NULL, codec_id, 3915 priority); 3916 } 3917 3918 3919 /* 3920 * Get video codec parameters. 3921 */ 3922 PJ_DEF(pj_status_t) pjsua_vid_codec_get_param( 3923 const pj_str_t *codec_id, 3924 pjmedia_vid_codec_param *param) 3925 { 3926 const pj_str_t all = { NULL, 0 }; 3927 const pjmedia_vid_codec_info *info; 3928 unsigned count = 1; 3929 pj_status_t status; 3930 3931 if (codec_id->slen==1 && *codec_id->ptr=='*') 3932 codec_id = &all; 3933 3934 status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id, 3935 &count, &info, NULL); 3936 if (status != PJ_SUCCESS) 3937 return status; 3938 3939 if (count != 1) 3940 return (count > 1? PJ_ETOOMANY : PJ_ENOTFOUND); 3941 3942 status = pjmedia_vid_codec_mgr_get_default_param(NULL, info, param); 3943 return status; 3944 } 3945 3946 3947 /* 3948 * Set video codec parameters. 3949 */ 3950 PJ_DEF(pj_status_t) pjsua_vid_codec_set_param( 3951 const pj_str_t *codec_id, 3952 const pjmedia_vid_codec_param *param) 3953 { 3954 const pjmedia_vid_codec_info *info[2]; 3955 unsigned count = 2; 3956 pj_status_t status; 3957 3958 status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id, 3959 &count, info, NULL); 3960 if (status != PJ_SUCCESS) 3961 return status; 3962 3963 /* Codec ID should be specific */ 3964 if (count > 1) { 3965 pj_assert(!"Codec ID is not specific"); 3966 return PJ_ETOOMANY; 3967 } 3968 3969 status = pjmedia_vid_codec_mgr_set_default_param(NULL, pjsua_var.pool, 3970 info[0], param); 3971 return status; 3972 } 3973 3974 3975 /***************************************************************************** 3976 * Video devices. 3977 */ 3978 3979 /* 3980 * Enum all video devices installed in the system. 3981 */ 3982 PJ_DEF(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[], 3983 unsigned *count) 3984 { 3985 unsigned i, dev_count; 3986 3987 dev_count = pjmedia_vid_dev_count(); 3988 3989 if (dev_count > *count) dev_count = *count; 3990 3991 for (i=0; i<dev_count; ++i) { 3992 pj_status_t status; 3993 3994 status = pjmedia_vid_dev_get_info(i, &info[i]); 3995 if (status != PJ_SUCCESS) 3996 return status; 3997 } 3998 3999 *count = dev_count; 4000 4001 return PJ_SUCCESS; 4002 } 4003 4004 4005 /* 4006 * Get currently active video devices. 4007 */ 4008 PJ_DEF(pj_status_t) pjsua_vid_get_dev(int *capture_dev, int *render_dev) 4009 { 4010 if (capture_dev) 4011 *capture_dev = pjsua_var.vcap_dev; 4012 if (render_dev) 4013 *render_dev = pjsua_var.vrdr_dev; 4014 4015 return PJ_SUCCESS; 4016 } 4017 4018 4019 /* 4020 * Select video device for the next video sessions. 4021 */ 4022 PJ_DEF(pj_status_t) pjsua_vid_set_dev(int capture_dev, int render_dev) 4023 { 4024 pjmedia_vid_dev_info info; 4025 pj_status_t status; 4026 4027 if (capture_dev < 0) 4028 capture_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 4029 if (render_dev < 0) 4030 render_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; 4031 4032 status = pjmedia_vid_dev_get_info(capture_dev, &info); 4033 if (status != PJ_SUCCESS) 4034 return status; 4035 4036 status = pjmedia_vid_dev_get_info(render_dev, &info); 4037 if (status != PJ_SUCCESS) 4038 return status; 4039 4040 pjsua_var.vcap_dev = capture_dev; 4041 pjsua_var.vrdr_dev = render_dev; 4042 4043 return PJ_SUCCESS; 4044 } 4045 4046 4047 /* 4048 * Configure video device setting to the video device being used. 4049 */ 4050 PJ_DECL(pj_status_t) pjsua_vid_set_setting(pjmedia_vid_dev_cap cap, 4051 const void *pval, 4052 pj_bool_t keep) 4053 { 4054 PJ_UNUSED_ARG(cap); 4055 PJ_UNUSED_ARG(pval); 4056 PJ_UNUSED_ARG(keep); 4057 return PJ_ENOTSUP; 4058 } 4059 4060 4061 /* 4062 * Retrieve a video device setting. 4063 */ 4064 PJ_DECL(pj_status_t) pjsua_vid_get_setting(pjmedia_aud_dev_cap cap, 4065 void *pval) 4066 { 4067 PJ_UNUSED_ARG(cap); 4068 PJ_UNUSED_ARG(pval); 4069 return PJ_ENOTSUP; 4070 } 4071 4072 #endif /* PJMEDIA_HAS_VIDEO */
Note: See TracChangeset
for help on using the changeset viewer.