Changeset 783 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
- Timestamp:
- Oct 19, 2006 3:49:47 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r765 r783 803 803 pjsua_recorder_id *p_id) 804 804 { 805 enum Format 806 { 807 FMT_UNKNOWN, 808 FMT_WAV, 809 FMT_MP3, 810 }; 805 811 unsigned slot, file_id; 806 812 char path[128]; 813 pj_str_t ext; 807 814 pjmedia_port *port; 808 815 pj_status_t status; 809 816 817 /* Filename must present */ 818 PJ_ASSERT_RETURN(filename != NULL, PJ_EINVAL); 819 810 820 /* Don't support max_size at present */ 811 PJ_ASSERT_RETURN(max_size == 0 , PJ_EINVAL);821 PJ_ASSERT_RETURN(max_size == 0 || max_size == -1, PJ_EINVAL); 812 822 813 823 /* Don't support file format at present */ … … 819 829 if (pjsua_var.rec_cnt >= PJ_ARRAY_SIZE(pjsua_var.recorder)) 820 830 return PJ_ETOOMANY; 831 832 /* Determine the file format */ 833 ext.ptr = filename->ptr + filename->slen - 4; 834 ext.slen = 4; 835 836 if (pj_stricmp2(&ext, ".wav") == 0) 837 file_format = FMT_WAV; 838 else if (pj_stricmp2(&ext, ".mp3") == 0) 839 file_format = FMT_MP3; 840 else { 841 PJ_LOG(1,(THIS_FILE, "pjsua_recorder_create() error: unable to " 842 "determine file format for %.*s", 843 (int)filename->slen, filename->ptr)); 844 return PJ_ENOTSUP; 845 } 821 846 822 847 PJSUA_LOCK(); … … 836 861 pj_memcpy(path, filename->ptr, filename->slen); 837 862 path[filename->slen] = '\0'; 838 status = pjmedia_wav_writer_port_create(pjsua_var.pool, path, 839 pjsua_var.media_cfg.clock_rate, 840 pjsua_var.mconf_cfg.channel_count, 841 pjsua_var.mconf_cfg.samples_per_frame, 842 pjsua_var.mconf_cfg.bits_per_sample, 843 options, 0, &port); 863 864 if (file_format == FMT_WAV) { 865 status = pjmedia_wav_writer_port_create(pjsua_var.pool, path, 866 pjsua_var.media_cfg.clock_rate, 867 pjsua_var.mconf_cfg.channel_count, 868 pjsua_var.mconf_cfg.samples_per_frame, 869 pjsua_var.mconf_cfg.bits_per_sample, 870 options, 0, &port); 871 } else if (file_format == FMT_MP3) { 872 status = pjmedia_mp3_writer_port_create(pjsua_var.pool, path, 873 pjsua_var.media_cfg.clock_rate, 874 pjsua_var.mconf_cfg.channel_count, 875 pjsua_var.mconf_cfg.samples_per_frame, 876 pjsua_var.mconf_cfg.bits_per_sample, 877 NULL, &port); 878 } else { 879 port = NULL; 880 status = PJ_ENOTSUP; 881 } 882 844 883 if (status != PJ_SUCCESS) { 845 884 PJSUA_UNLOCK();
Note: See TracChangeset
for help on using the changeset viewer.