- Timestamp:
- Jul 7, 2011 7:46:33 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_media.c
r3579 r3609 276 276 #endif /* PJMEDIA_HAS_L16_CODEC */ 277 277 278 #if PJMEDIA_HAS_VIDEO279 status = pjmedia_video_format_mgr_create(pjsua_var.pool, 64, 0, NULL);280 if (status != PJ_SUCCESS) {281 pjsua_perror(THIS_FILE, "Error creating PJMEDIA video format manager",282 status);283 return status;284 }285 286 status = pjmedia_converter_mgr_create(pjsua_var.pool, NULL);287 if (status != PJ_SUCCESS) {288 pjsua_perror(THIS_FILE, "Error creating PJMEDIA converter manager",289 status);290 return status;291 }292 293 status = pjmedia_vid_codec_mgr_create(pjsua_var.pool, NULL);294 if (status != PJ_SUCCESS) {295 pjsua_perror(THIS_FILE, "Error creating PJMEDIA video codec manager",296 status);297 return status;298 }299 300 status = pjmedia_vid_dev_subsys_init(&pjsua_var.cp.factory);301 if (status != PJ_SUCCESS) {302 pjsua_perror(THIS_FILE, "Error creating PJMEDIA video subsystem",303 status);304 return status;305 }306 #endif307 308 #if PJMEDIA_HAS_VIDEO && PJMEDIA_HAS_FFMPEG_CODEC309 /* Init ffmpeg video codecs */310 status = pjmedia_codec_ffmpeg_init(NULL, &pjsua_var.cp.factory);311 if (status != PJ_SUCCESS) {312 pjsua_perror(THIS_FILE, "Error initializing ffmpeg library",313 status);314 return status;315 }316 #endif317 278 318 279 /* Save additional conference bridge parameters for future … … 337 298 } 338 299 339 340 300 /* Init conference bridge. */ 341 301 status = pjmedia_conf_create(pjsua_var.pool, … … 375 335 #endif 376 336 337 /* Video */ 338 #if PJMEDIA_HAS_VIDEO 339 status = pjsua_vid_subsys_init(); 340 if (status != PJ_SUCCESS) 341 return status; 342 #endif 343 377 344 return PJ_SUCCESS; 378 345 } … … 472 439 pj_timer_entry_init(&pjsua_var.snd_idle_timer, PJ_FALSE, NULL, 473 440 &close_snd_timer_cb); 441 442 /* Video */ 443 #if PJMEDIA_HAS_VIDEO 444 status = pjsua_vid_subsys_start(); 445 if (status != PJ_SUCCESS) 446 return status; 447 #endif 474 448 475 449 /* Perform NAT detection */ … … 539 513 if (pjsua_var.med_endpt) { 540 514 541 /* Videodev */542 515 # if PJMEDIA_HAS_VIDEO 543 pj media_vid_dev_subsys_shutdown();516 pjsua_vid_subsys_destroy(); 544 517 # endif 545 546 /* ffmpeg */547 # if PJMEDIA_HAS_VIDEO && PJMEDIA_HAS_FFMPEG_CODEC548 pjmedia_codec_ffmpeg_deinit();549 # endif550 551 518 /* Shutdown all codecs: */ 552 519 # if PJMEDIA_HAS_SPEEX_CODEC … … 3938 3905 3939 3906 3940 #if PJMEDIA_HAS_VIDEO3941 3942 /*****************************************************************************3943 * Video codecs.3944 */3945 3946 /*3947 * Enum all supported video codecs in the system.3948 */3949 PJ_DEF(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],3950 unsigned *p_count )3951 {3952 pjmedia_vid_codec_info info[32];3953 unsigned i, j, count, prio[32];3954 pj_status_t status;3955 3956 count = PJ_ARRAY_SIZE(info);3957 status = pjmedia_vid_codec_mgr_enum_codecs(NULL, &count, info, prio);3958 if (status != PJ_SUCCESS) {3959 *p_count = 0;3960 return status;3961 }3962 3963 for (i=0, j=0; i<count && j<*p_count; ++i) {3964 if (info[i].has_rtp_pack) {3965 pj_bzero(&id[j], sizeof(pjsua_codec_info));3966 3967 pjmedia_vid_codec_info_to_id(&info[i], id[j].buf_, sizeof(id[j].buf_));3968 id[j].codec_id = pj_str(id[j].buf_);3969 id[j].priority = (pj_uint8_t) prio[i];3970 3971 if (id[j].codec_id.slen < sizeof(id[j].buf_)) {3972 id[j].desc.ptr = id[j].codec_id.ptr + id[j].codec_id.slen + 1;3973 pj_strncpy(&id[j].desc, &info[i].encoding_desc,3974 sizeof(id[j].buf_) - id[j].codec_id.slen - 1);3975 }3976 3977 ++j;3978 }3979 }3980 3981 *p_count = j;3982 3983 return PJ_SUCCESS;3984 }3985 3986 3987 /*3988 * Change video codec priority.3989 */3990 PJ_DEF(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,3991 pj_uint8_t priority )3992 {3993 const pj_str_t all = { NULL, 0 };3994 3995 if (codec_id->slen==1 && *codec_id->ptr=='*')3996 codec_id = &all;3997 3998 return pjmedia_vid_codec_mgr_set_codec_priority(NULL, codec_id,3999 priority);4000 }4001 4002 4003 /*4004 * Get video codec parameters.4005 */4006 PJ_DEF(pj_status_t) pjsua_vid_codec_get_param(4007 const pj_str_t *codec_id,4008 pjmedia_vid_codec_param *param)4009 {4010 const pj_str_t all = { NULL, 0 };4011 const pjmedia_vid_codec_info *info;4012 unsigned count = 1;4013 pj_status_t status;4014 4015 if (codec_id->slen==1 && *codec_id->ptr=='*')4016 codec_id = &all;4017 4018 status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id,4019 &count, &info, NULL);4020 if (status != PJ_SUCCESS)4021 return status;4022 4023 if (count != 1)4024 return (count > 1? PJ_ETOOMANY : PJ_ENOTFOUND);4025 4026 status = pjmedia_vid_codec_mgr_get_default_param(NULL, info, param);4027 return status;4028 }4029 4030 4031 /*4032 * Set video codec parameters.4033 */4034 PJ_DEF(pj_status_t) pjsua_vid_codec_set_param(4035 const pj_str_t *codec_id,4036 const pjmedia_vid_codec_param *param)4037 {4038 const pjmedia_vid_codec_info *info[2];4039 unsigned count = 2;4040 pj_status_t status;4041 4042 status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id,4043 &count, info, NULL);4044 if (status != PJ_SUCCESS)4045 return status;4046 4047 /* Codec ID should be specific */4048 if (count > 1) {4049 pj_assert(!"Codec ID is not specific");4050 return PJ_ETOOMANY;4051 }4052 4053 status = pjmedia_vid_codec_mgr_set_default_param(NULL, pjsua_var.pool,4054 info[0], param);4055 return status;4056 }4057 4058 4059 /*****************************************************************************4060 * Video devices.4061 */4062 4063 /*4064 * Enum all video devices installed in the system.4065 */4066 PJ_DEF(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],4067 unsigned *count)4068 {4069 unsigned i, dev_count;4070 4071 dev_count = pjmedia_vid_dev_count();4072 4073 if (dev_count > *count) dev_count = *count;4074 4075 for (i=0; i<dev_count; ++i) {4076 pj_status_t status;4077 4078 status = pjmedia_vid_dev_get_info(i, &info[i]);4079 if (status != PJ_SUCCESS)4080 return status;4081 }4082 4083 *count = dev_count;4084 4085 return PJ_SUCCESS;4086 }4087 4088 4089 /*4090 * Get currently active video devices.4091 */4092 PJ_DEF(pj_status_t) pjsua_vid_get_dev(int *capture_dev, int *render_dev)4093 {4094 if (capture_dev)4095 *capture_dev = pjsua_var.vcap_dev;4096 if (render_dev)4097 *render_dev = pjsua_var.vrdr_dev;4098 4099 return PJ_SUCCESS;4100 }4101 4102 4103 /*4104 * Select video device for the next video sessions.4105 */4106 PJ_DEF(pj_status_t) pjsua_vid_set_dev(int capture_dev, int render_dev)4107 {4108 pjmedia_vid_dev_info info;4109 pj_status_t status;4110 4111 if (capture_dev < 0)4112 capture_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;4113 if (render_dev < 0)4114 render_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV;4115 4116 status = pjmedia_vid_dev_get_info(capture_dev, &info);4117 if (status != PJ_SUCCESS)4118 return status;4119 4120 status = pjmedia_vid_dev_get_info(render_dev, &info);4121 if (status != PJ_SUCCESS)4122 return status;4123 4124 pjsua_var.vcap_dev = capture_dev;4125 pjsua_var.vrdr_dev = render_dev;4126 4127 return PJ_SUCCESS;4128 }4129 4130 4131 /*4132 * Configure video device setting to the video device being used.4133 */4134 PJ_DEF(pj_status_t) pjsua_vid_set_setting(pjmedia_vid_dev_cap cap,4135 const void *pval,4136 pj_bool_t keep)4137 {4138 PJ_UNUSED_ARG(cap);4139 PJ_UNUSED_ARG(pval);4140 PJ_UNUSED_ARG(keep);4141 return PJ_ENOTSUP;4142 }4143 4144 4145 /*4146 * Retrieve a video device setting.4147 */4148 PJ_DEF(pj_status_t) pjsua_vid_get_setting(pjmedia_vid_dev_cap cap,4149 void *pval)4150 {4151 PJ_UNUSED_ARG(cap);4152 PJ_UNUSED_ARG(pval);4153 return PJ_ENOTSUP;4154 }4155 4156 #endif /* PJMEDIA_HAS_VIDEO */
Note: See TracChangeset
for help on using the changeset viewer.