- Timestamp:
- Mar 22, 2011 9:49:23 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.