Changeset 4016 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Apr 4, 2012 5:05:50 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r3999 r4016 44 44 #define RING_INTERVAL 3000 45 45 46 #define MAX_AVI 4 46 47 47 48 /* Call specific data */ … … 136 137 struct app_vid vid; 137 138 unsigned aud_cnt; 139 140 /* AVI to play */ 141 unsigned avi_cnt; 142 pj_str_t avi[MAX_AVI]; 143 pj_bool_t avi_auto_play; 144 pjmedia_vid_dev_index avi_dev_id; 145 pjsua_conf_port_id avi_slot; 138 146 } app_config; 139 147 … … 330 338 puts (" --vcapture-dev=id Video capture device ID (default=-1)"); 331 339 puts (" --vrender-dev=id Video render device ID (default=-1)"); 340 puts (" --play-avi=FILE Load this AVI as virtual capture device"); 341 puts (" --auto-play-avi Automatically play the AVI media to call"); 332 342 #endif 333 343 … … 400 410 cfg->ringback_slot = PJSUA_INVALID_ID; 401 411 cfg->ring_slot = PJSUA_INVALID_ID; 412 413 cfg->avi_dev_id = PJMEDIA_VID_INVALID_DEV; 414 cfg->avi_slot = PJSUA_INVALID_ID; 402 415 403 416 for (i=0; i<PJ_ARRAY_SIZE(cfg->acc_cfg); ++i) … … 577 590 OPT_TIMER, OPT_TIMER_SE, OPT_TIMER_MIN_SE, 578 591 OPT_VIDEO, OPT_EXTRA_AUDIO, 579 OPT_VCAPTURE_DEV, OPT_VRENDER_DEV, 592 OPT_VCAPTURE_DEV, OPT_VRENDER_DEV, OPT_PLAY_AVI, OPT_AUTO_PLAY_AVI 580 593 }; 581 594 struct pj_getopt_option long_options[] = { … … 703 716 { "vcapture-dev", 1, 0, OPT_VCAPTURE_DEV}, 704 717 { "vrender-dev", 1, 0, OPT_VRENDER_DEV}, 718 { "play-avi", 1, 0, OPT_PLAY_AVI}, 719 { "auto-play-avi", 0, 0, OPT_AUTO_PLAY_AVI}, 705 720 { NULL, 0, 0, 0} 706 721 }; … … 1496 1511 cfg->vid.vrender_dev = atoi(pj_optarg); 1497 1512 cur_acc->vid_rend_dev = cfg->vid.vrender_dev; 1513 break; 1514 1515 case OPT_PLAY_AVI: 1516 if (app_config.avi_cnt >= MAX_AVI) { 1517 PJ_LOG(1,(THIS_FILE, "Too many AVIs")); 1518 return -1; 1519 } 1520 app_config.avi[app_config.avi_cnt++] = pj_str(pj_optarg); 1521 break; 1522 1523 case OPT_AUTO_PLAY_AVI: 1524 app_config.avi_auto_play = PJ_TRUE; 1498 1525 break; 1499 1526 … … 2082 2109 if (config->vid.vrender_dev != PJMEDIA_VID_DEFAULT_RENDER_DEV) { 2083 2110 pj_ansi_sprintf(line, "--vrender-dev %d\n", config->vid.vrender_dev); 2111 pj_strcat2(&cfg, line); 2112 } 2113 for (i=0; i<config->avi_cnt; ++i) { 2114 pj_ansi_sprintf(line, "--play-avi %s\n", config->avi[i].ptr); 2115 pj_strcat2(&cfg, line); 2116 } 2117 if (config->avi_auto_play) { 2118 pj_ansi_sprintf(line, "--auto-play-avi\n"); 2084 2119 pj_strcat2(&cfg, line); 2085 2120 } … … 2788 2823 pjsua_conf_connect(app_config.wav_port, call_conf_slot); 2789 2824 connect_sound = PJ_FALSE; 2825 } 2826 2827 /* Stream AVI, if desired */ 2828 if (app_config.avi_auto_play && 2829 app_config.avi_slot != PJSUA_INVALID_ID) 2830 { 2831 pjsua_conf_connect(app_config.avi_slot, call_conf_slot); 2790 2832 } 2791 2833 … … 3976 4018 acc_cfg->vid_cap_dev = app_config.vid.vcapture_dev; 3977 4019 acc_cfg->vid_rend_dev = app_config.vid.vrender_dev; 4020 4021 if (app_config.avi_auto_play && 4022 app_config.avi_dev_id != PJMEDIA_VID_INVALID_DEV) 4023 { 4024 acc_cfg->vid_cap_dev = app_config.avi_dev_id; 4025 } 3978 4026 } 3979 4027 … … 5636 5684 } 5637 5685 5686 /* Create AVI player virtual devices */ 5687 if (app_config.avi_cnt) { 5688 #if PJMEDIA_VIDEO_DEV_HAS_AVI 5689 pjmedia_vid_dev_factory *avi_factory; 5690 5691 status = pjmedia_avi_dev_create_factory(pjsua_get_pool_factory(), 5692 app_config.avi_cnt, 5693 &avi_factory); 5694 if (status != PJ_SUCCESS) { 5695 PJ_PERROR(1,(THIS_FILE, status, "Error creating AVI factory")); 5696 goto on_error; 5697 } 5698 5699 for (i=0; i<app_config.avi_cnt; ++i) { 5700 pjmedia_avi_dev_param avdp; 5701 pjmedia_vid_dev_index avid; 5702 unsigned strm_idx, strm_cnt; 5703 5704 pjmedia_avi_dev_param_default(&avdp); 5705 avdp.path = app_config.avi[i]; 5706 5707 status = pjmedia_avi_dev_alloc(avi_factory, &avdp, &avid); 5708 if (status != PJ_SUCCESS) { 5709 PJ_PERROR(1,(THIS_FILE, status, 5710 "Error creating AVI player for %.*s", 5711 (int)avdp.path.slen, avdp.path.ptr)); 5712 goto on_error; 5713 } 5714 5715 PJ_LOG(4,(THIS_FILE, "AVI player %.*s created, dev_id=%d", 5716 (int)avdp.title.slen, avdp.title.ptr, avid)); 5717 app_config.avi_dev_id = avid; 5718 5719 strm_cnt = pjmedia_avi_streams_get_num_streams(avdp.avi_streams); 5720 for (strm_idx=0; strm_idx<strm_cnt; ++strm_idx) { 5721 pjmedia_port *aud; 5722 pjmedia_format *fmt; 5723 pjsua_conf_port_id slot; 5724 char fmt_name[5]; 5725 5726 aud = pjmedia_avi_streams_get_stream(avdp.avi_streams, 5727 strm_idx); 5728 fmt = &aud->info.fmt; 5729 5730 pjmedia_fourcc_name(fmt->id, fmt_name); 5731 5732 if (fmt->id == PJMEDIA_FORMAT_PCM) { 5733 status = pjsua_conf_add_port(app_config.pool, aud, 5734 &slot); 5735 if (status == PJ_SUCCESS) { 5736 PJ_LOG(4,(THIS_FILE, 5737 "AVI %.*s: audio added to slot %d", 5738 (int)avdp.title.slen, avdp.title.ptr, 5739 slot)); 5740 app_config.avi_slot = slot; 5741 } 5742 } else { 5743 PJ_LOG(4,(THIS_FILE, 5744 "AVI %.*s: audio ignored, format=%s", 5745 (int)avdp.title.slen, avdp.title.ptr, 5746 fmt_name)); 5747 } 5748 } 5749 } 5750 #else 5751 PJ_LOG(2,(THIS_FILE, 5752 "Warning: --play-avi is ignored because AVI is disabled")); 5753 #endif /* PJMEDIA_VIDEO_DEV_HAS_AVI */ 5754 } 5755 5638 5756 /* Add UDP transport unless it's disabled. */ 5639 5757 if (!app_config.no_udp) {
Note: See TracChangeset
for help on using the changeset viewer.