Changeset 1493


Ignore:
Timestamp:
Oct 12, 2007 5:24:32 AM (17 years ago)
Author:
bennylp
Message:

Ticket #398: Initial support for Secret Rabbit Code (aka libsamplerate) sample rate conversionl library

Location:
pjproject/trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/build/Makefile

    r1202 r1493  
    4646                        g711.o jbuf.o master_port.o mem_capture.o mem_player.o \ 
    4747                        null_port.o plc_common.o port.o splitcomb.o \ 
    48                         resample_resample.o \ 
     48                        resample_resample.o resample_libsamplerate.o \ 
    4949                        resample_port.o rtcp.o rtp.o sdp.o sdp_cmp.o sdp_neg.o \ 
    5050                        session.o silencedet.o sound_port.o stream.o \ 
  • pjproject/trunk/pjmedia/build/pjmedia.dsp

    r1177 r1493  
    182182# Begin Source File 
    183183 
     184SOURCE=..\src\pjmedia\resample_libsamplerate.c 
     185# End Source File 
     186# Begin Source File 
     187 
    184188SOURCE=..\src\pjmedia\resample_port.c 
    185189# End Source File 
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r1486 r1493  
    128128 
    129129/* 
    130  * **   THIS MACRO IS DEPRECATED in 0.6.   ** 
    131  * ** See libresample for configuring this ** 
    132  * 
    133  * Include small filter table in resample. 
    134  * This adds about 9KB in rdata. 
    135  */ 
    136 /* 
    137 #ifndef PJMEDIA_HAS_SMALL_FILTER 
    138 #   define PJMEDIA_HAS_SMALL_FILTER         1 
    139 #endif 
    140 */ 
    141  
    142 /* 
    143  * **   THIS MACRO IS DEPRECATED in 0.6.   ** 
    144  * ** See libresample for configuring this ** 
    145  * 
    146  * Include large filter table in resample. 
    147  * This adds about 32KB in rdata. 
    148  */ 
    149 /* 
    150 #ifndef PJMEDIA_HAS_LARGE_FILTER 
    151 #   define PJMEDIA_HAS_LARGE_FILTER         1 
    152 #endif 
    153 */ 
    154  
    155 /** 
    156  * Specify whether libresample should be used for the sampling 
    157  * rate conversion. This macro and PJMEDIA_HAS_SPEEX_RESAMPLE 
    158  * are mutually exclusive.  
    159  * 
    160  * Default: 1 (Yes) 
    161  */ 
    162 #ifndef PJMEDIA_HAS_LIBRESAMPLE 
    163 #   define PJMEDIA_HAS_LIBRESAMPLE          1 
    164 #endif 
    165  
    166  
    167 /** 
    168  * Specify whether Speex sample rate convertor should be used for the 
    169  * sampling rate conversion. This macro and PJMEDIA_HAS_LIBRESAMPLE 
    170  * are mutually exclusive. 
    171  * 
    172  * Default: 0 
    173  */ 
    174 #ifndef PJMEDIA_HAS_SPEEX_RESAMPLE 
    175 #   define PJMEDIA_HAS_SPEEX_RESAMPLE       0 
    176 #endif 
    177  
     130 * Warn about obsolete macros. 
     131 * 
     132 * PJMEDIA_HAS_SMALL_FILTER has been deprecated in 0.7. 
     133 */ 
     134#if defined(PJMEDIA_HAS_SMALL_FILTER) 
     135#   ifdef _MSC_VER 
     136#       pragma message("Warning: PJMEDIA_HAS_SMALL_FILTER macro is deprecated"\ 
     137                       " and has no effect") 
     138#   else 
     139#       warning "PJMEDIA_HAS_SMALL_FILTER macro is deprecated and has no effect" 
     140#   endif 
     141#endif 
     142 
     143 
     144/* 
     145 * Warn about obsolete macros. 
     146 * 
     147 * PJMEDIA_HAS_LARGE_FILTER has been deprecated in 0.7. 
     148 */ 
     149#if defined(PJMEDIA_HAS_LARGE_FILTER) 
     150#   ifdef _MSC_VER 
     151#       pragma message("Warning: PJMEDIA_HAS_LARGE_FILTER macro is deprecated"\ 
     152                       " and has no effect") 
     153#   else 
     154#       warning "PJMEDIA_HAS_LARGE_FILTER macro is deprecated" 
     155#   endif 
     156#endif 
     157 
     158 
     159/* 
     160 * These macros are obsolete in 0.7.1 so it will trigger compilation error. 
     161 * Please use PJMEDIA_RESAMPLE_IMP to select the resample implementation 
     162 * to use. 
     163 */ 
     164#ifdef PJMEDIA_HAS_LIBRESAMPLE 
     165#   error "PJMEDIA_HAS_LIBRESAMPLE macro is deprecated. Use '#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE'" 
     166#endif 
     167 
     168#ifdef PJMEDIA_HAS_SPEEX_RESAMPLE 
     169#   error "PJMEDIA_HAS_SPEEX_RESAMPLE macro is deprecated. Use '#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_SPEEX'" 
     170#endif 
     171 
     172 
     173/* 
     174 * Sample rate conversion backends. 
     175 * Select one of these backends in PJMEDIA_RESAMPLE_IMP. 
     176 */ 
     177#define PJMEDIA_RESAMPLE_NONE               1   /**< No resampling.         */ 
     178#define PJMEDIA_RESAMPLE_LIBRESAMPLE        2   /**< Sample rate conversion  
     179                                                     using libresample.  */ 
     180#define PJMEDIA_RESAMPLE_SPEEX              3   /**< Sample rate conversion  
     181                                                     using Speex. */ 
     182#define PJMEDIA_RESAMPLE_LIBSAMPLERATE      4   /**< Sample rate conversion  
     183                                                     using libsamplerate  
     184                                                     (a.k.a Secret Rabbit Code) 
     185                                                 */ 
     186 
     187/** 
     188 * Select which resample implementation to use. Currently pjmedia supports: 
     189 *  - #PJMEDIA_RESAMPLE_LIBRESAMPLE, to use libresample-1.7, this is the default 
     190 *    implementation to be used. 
     191 *  - #PJMEDIA_RESAMPLE_LIBSAMPLERATE, to use libsamplerate implementation 
     192 *    (a.k.a. Secret Rabbit Code). 
     193 *  - #PJMEDIA_RESAMPLE_SPEEX, to use experimental sample rate conversion in 
     194 *    Speex library. 
     195 *  - #PJMEDIA_RESAMPLE_NONE, to disable sample rate conversion. Any calls to 
     196 *    resample function will return error. 
     197 * 
     198 * Default is PJMEDIA_RESAMPLE_LIBRESAMPLE 
     199 */ 
     200#ifndef PJMEDIA_RESAMPLE_IMP 
     201#   define PJMEDIA_RESAMPLE_IMP             PJMEDIA_RESAMPLE_LIBRESAMPLE 
     202#endif 
     203 
     204 
     205/** 
     206 * Specify whether libsamplerate, when used, should be linked statically 
     207 * into the application. This option is only useful for Visual Studio 
     208 * projects, and when this static linking is enabled 
     209 */ 
    178210 
    179211 
  • pjproject/trunk/pjmedia/src/pjmedia/resample_resample.c

    r1266 r1493  
    2626 
    2727 
    28 #if defined(PJMEDIA_HAS_LIBRESAMPLE) && PJMEDIA_HAS_LIBRESAMPLE != 0 
     28#if PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_LIBRESAMPLE 
    2929 
    3030#include <third_party/resample/include/resamplesubs.h> 
     
    216216 
    217217 
    218 #else /* PJMEDIA_HAS_LIBRESAMPLE */ 
     218#elif PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_NONE 
    219219 
    220220/* 
    221221 * This is the configuration when sample rate conversion is disabled. 
    222222 */ 
    223 struct pjmedia_resample 
    224 { 
    225         unsigned samples_per_frame; 
    226 }; 
    227  
    228223PJ_DEF(pj_status_t) pjmedia_resample_create( pj_pool_t *pool, 
    229224                                             pj_bool_t high_quality, 
     
    235230                                             pjmedia_resample **p_resample)  
    236231{ 
    237         pjmedia_resample *resample; 
    238          
    239         PJ_ASSERT_RETURN(rate_in == rate_out, PJ_EINVALIDOP); 
    240  
    241         PJ_UNUSED_ARG(high_quality); 
    242         PJ_UNUSED_ARG(large_filter); 
    243         PJ_UNUSED_ARG(channel_count); 
    244         PJ_UNUSED_ARG(rate_in); 
    245         PJ_UNUSED_ARG(rate_out); 
    246                  
    247         resample = PJ_POOL_ZALLOC_T(pool, pjmedia_resample); 
    248         resample->samples_per_frame = samples_per_frame; 
    249          
    250         *p_resample = resample; 
    251          
    252         return PJ_SUCCESS; 
     232    PJ_UNUSED_ARG(pool); 
     233    PJ_UNUSED_ARG(high_quality); 
     234    PJ_UNUSED_ARG(large_filter); 
     235    PJ_UNUSED_ARG(channel_count); 
     236    PJ_UNUSED_ARG(rate_in); 
     237    PJ_UNUSED_ARG(rate_out); 
     238    PJ_UNUSED_ARG(samples_per_frame); 
     239    PJ_UNUSED_ARG(p_resample); 
     240 
     241    return PJ_EINVALIDOP; 
    253242} 
    254243 
     
    257246                                   pj_int16_t *output )  
    258247{ 
    259         pjmedia_copy_samples(output, input, resample->samples_per_frame); 
     248    PJ_UNUSED_ARG(resample); 
     249    PJ_UNUSED_ARG(input); 
     250    PJ_UNUSED_ARG(output); 
    260251} 
    261252 
    262253PJ_DEF(unsigned) pjmedia_resample_get_input_size(pjmedia_resample *resample)  
    263254{ 
    264         return resample->samples_per_frame; 
     255    PJ_UNUSED_ARG(resample); 
     256    return 0; 
    265257} 
    266258 
    267259PJ_DEF(void) pjmedia_resample_destroy(pjmedia_resample *resample)  
    268260{ 
    269         PJ_UNUSED_ARG(resample); 
    270 } 
    271  
    272 #endif  /* PJMEDIA_HAS_LIBRESAMPLE */ 
    273  
     261    PJ_UNUSED_ARG(resample); 
     262} 
     263 
     264#endif  /* PJMEDIA_RESAMPLE_IMP */ 
     265 
  • pjproject/trunk/pjmedia/src/pjmedia/resample_speex.c

    r1177 r1493  
    2323#include <pj/pool.h> 
    2424 
    25 #if defined(PJMEDIA_HAS_SPEEX_RESAMPLE) && PJMEDIA_HAS_SPEEX_RESAMPLE != 0 
     25#if PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_SPEEX 
    2626 
    2727#include <speex/speex_resampler.h> 
     
    119119} 
    120120 
    121 #else /* PJMEDIA_HAS_SPEEX_RESAMPLE */ 
     121#else /* PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_SPEEX */ 
    122122 
    123123int pjmedia_resample_speex_excluded; 
    124124 
    125 #endif  /* PJMEDIA_HAS_SPEEX_RESAMPLE */ 
     125#endif  /* PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_SPEEX */ 
    126126 
Note: See TracChangeset for help on using the changeset viewer.