Ignore:
Timestamp:
Oct 19, 2006 3:49:47 PM (18 years ago)
Author:
bennylp
Message:

Support for MP3 recording for Win32 target. Also added "--rec-file" and "--auto-rec" option in pjsua to record voice conversion. The "--rec-file" option will record to either .WAV or .MP3 depending on the file extension.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r765 r783  
    803803                                           pjsua_recorder_id *p_id) 
    804804{ 
     805    enum Format 
     806    { 
     807        FMT_UNKNOWN, 
     808        FMT_WAV, 
     809        FMT_MP3, 
     810    }; 
    805811    unsigned slot, file_id; 
    806812    char path[128]; 
     813    pj_str_t ext; 
    807814    pjmedia_port *port; 
    808815    pj_status_t status; 
    809816 
     817    /* Filename must present */ 
     818    PJ_ASSERT_RETURN(filename != NULL, PJ_EINVAL); 
     819 
    810820    /* 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); 
    812822 
    813823    /* Don't support file format at present */ 
     
    819829    if (pjsua_var.rec_cnt >= PJ_ARRAY_SIZE(pjsua_var.recorder)) 
    820830        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    } 
    821846 
    822847    PJSUA_LOCK(); 
     
    836861    pj_memcpy(path, filename->ptr, filename->slen); 
    837862    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 
    844883    if (status != PJ_SUCCESS) { 
    845884        PJSUA_UNLOCK(); 
Note: See TracChangeset for help on using the changeset viewer.