Changeset 358
- Timestamp:
- Mar 24, 2006 8:41:20 PM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 added
- 1 deleted
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/Makefile
r355 r358 65 65 export PJMEDIA_SRCDIR = ../src/pjmedia 66 66 export PJMEDIA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 67 codec.o conference.o endpoint.o errno.o file_p ort.o \68 g711.o jbuf.o null_port.o port.o resample.o r tcp.o \69 rt p.o sdp.o sdp_cmp.o sdp_neg.o session.o silencedet.o \67 codec.o conference.o endpoint.o errno.o file_player.o \ 68 g711.o jbuf.o null_port.o port.o resample.o resample_port.o \ 69 rtcp.o rtp.o sdp.o sdp_cmp.o sdp_neg.o session.o silencedet.o \ 70 70 sound_port.o stream.o $(SOUND_OBJS) $(NULLSOUND_OBJS) 71 71 -
pjproject/trunk/pjmedia/build/pjmedia.dsp
r321 r358 66 66 # PROP Target_Dir "" 67 67 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /D "_DEBUG" /D "PA_NO_ASIO" /D "PA_NO_ WMME" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /D "_DEBUG" /D "PA_NO_ASIO" /D "PA_NO_DS" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c 69 69 # SUBTRACT CPP /YX 70 70 # ADD BASE RSC /l 0x409 /d "_DEBUG" … … 109 109 # Begin Source File 110 110 111 SOURCE=..\src\pjmedia\file_port.c 111 SOURCE=..\src\pjmedia\file_player.c 112 # End Source File 113 # Begin Source File 114 115 SOURCE=..\src\pjmedia\file_writer.c 112 116 # End Source File 113 117 # Begin Source File … … 141 145 # Begin Source File 142 146 147 SOURCE=..\src\pjmedia\resample_port.c 148 # End Source File 149 # Begin Source File 150 143 151 SOURCE=..\src\pjmedia\rtcp.c 144 152 # End Source File … … 174 182 175 183 SOURCE=..\src\pjmedia\stream.c 184 # End Source File 185 # Begin Source File 186 187 SOURCE=..\src\pjmedia\wave.c 176 188 # End Source File 177 189 # End Group -
pjproject/trunk/pjmedia/include/pjmedia.h
r355 r358 35 35 #include <pjmedia/null_port.h> 36 36 #include <pjmedia/port.h> 37 #include <pjmedia/resample.h> 37 38 #include <pjmedia/rtcp.h> 38 39 #include <pjmedia/rtp.h> -
pjproject/trunk/pjmedia/include/pjmedia/config.h
r347 r358 69 69 70 70 71 /** 72 * Default file player/writer buffer size. 73 */ 74 #ifndef PJMEDIA_FILE_PORT_BUFSIZE 75 # define PJMEDIA_FILE_PORT_BUFSIZE 4000 76 #endif 77 78 71 79 #endif /* __PJMEDIA_CONFIG_H__ */ 72 80 -
pjproject/trunk/pjmedia/include/pjmedia/errno.h
r334 r358 441 441 */ 442 442 #define PJMEDIA_EWAVETOOSHORT (PJMEDIA_ERRNO_START+182) /* 220182 */ 443 /** 444 * @hideinitializer 445 * Sound frame is too large for file buffer. 446 */ 447 #define PJMEDIA_EFRMFILETOOBIG (PJMEDIA_ERRNO_START+183) /* 220183 */ 443 448 444 449 -
pjproject/trunk/pjmedia/include/pjmedia/file_port.h
r222 r358 27 27 28 28 29 29 30 PJ_BEGIN_DECL 30 31 31 32 32 33 /** 33 * Create file player port. 34 * Create a media port to play streams from a WAV file. 35 * 36 * @param pool Pool to create memory buffers for this port. 37 * @param filename File name to open. 38 * @param flags Port creation flags. 39 * @param buf_size Buffer size to be allocated. If the value is zero or 40 * negative, the port will use default buffer size (which 41 * is about 4KB). 42 * @param user_data User data to be associated with the file player port. 43 * @param p_port Pointer to receive the file port instance. 44 * 45 * @return PJ_SUCCESS on success. 34 46 */ 35 47 PJ_DECL(pj_status_t) pjmedia_file_player_port_create( pj_pool_t *pool, … … 42 54 43 55 56 /** 57 * Create a media port to record streams to a WAV file. Note that the port 58 * must be closed properly (with #pjmedia_port_destroy()) so that the WAV 59 * header can be filled with correct values (such as the file length). 60 * 61 * @param pool Pool to create memory buffers for this port. 62 * @param filename File name. 63 * @param flags Port creation flags. 64 * @param buf_size Buffer size to be allocated. If the value is zero or 65 * negative, the port will use default buffer size (which 66 * is about 4KB). 67 * @param user_data User data to be associated with the file writer port. 68 * @param p_port Pointer to receive the file port instance. 69 * 70 * @return PJ_SUCCESS on success. 71 */ 72 PJ_DECL(pj_status_t) pjmedia_file_writer_port_create( pj_pool_t *pool, 73 const char *filename, 74 unsigned sampling_rate, 75 unsigned channel_count, 76 unsigned samples_per_frame, 77 unsigned bits_per_sample, 78 unsigned flags, 79 pj_ssize_t buff_size, 80 void *user_data, 81 pjmedia_port **p_port ); 82 83 84 85 44 86 PJ_END_DECL 45 87 -
pjproject/trunk/pjmedia/include/pjmedia/resample.h
r277 r358 26 26 * @brief Sample rate converter. 27 27 */ 28 #include "pjmedia/types.h" 28 #include <pjmedia/types.h> 29 #include <pjmedia/port.h> 30 29 31 30 32 PJ_BEGIN_DECL 33 34 /* 35 * This file declares two types of API: 36 * 37 * Application can use #pjmedia_resample_create() and #pjmedia_resample_run() 38 * to convert a frame from source rate to destination rate. The inpuit frame 39 * must have a constant length. 40 * 41 * Alternatively, application can create a resampling port with 42 * #pjmedia_resample_port_create() and connect the port to other ports to 43 * change the sampling rate of the samples. 44 */ 45 31 46 32 47 /** … … 60 75 61 76 /** 62 * Resample a frame. 77 * Use the resample session to resample a frame. The frame must have the 78 * same size and settings as the resample session, or otherwise the 79 * behavior is undefined. 63 80 * 64 81 * @param resample The resample session. … … 71 88 72 89 90 /** 91 * Get the input frame size of a resample session. 92 * 93 * @param resample The resample session. 94 * 95 * @return The frame size, in number of samples. 96 */ 97 PJ_DECL(unsigned) pjmedia_resample_get_input_size(pjmedia_resample *resample); 98 99 100 /** 101 * Create a resample port. This creates a bidirectional resample session, 102 * which will resample frames when the port's get_frame() and put_frame() 103 * is called. 104 * 105 * When the resample port's get_frame() is called, this port will get 106 * a frame from the downstream port and resample the frame to the upstream 107 * port's clock rate before returning it to the caller. 108 * 109 * When the resample port's put_frame() is called, this port will resample 110 * the frame to the downstream's port clock rate before giving the frame 111 * to the downstream port. 112 * 113 * @param pool Pool to allocate the structure and buffers. 114 * @param high_quality If true, then high quality conversion will be 115 * used, at the expense of more CPU and memory, 116 * because temporary buffer needs to be created. 117 * @param large_filter If true, large filter size will be used. 118 * @param downstream_rate The sampling rate of the downstream port. 119 * @param upstream_rate The sampling rate of the upstream port. 120 * @param channel_count The number of channels. This argument is only 121 * used for the port information. It does not 122 * change the behavior of the resample port. 123 * @param samples_per_frame Number of samples per frame from the downstream 124 * port. 125 * @param p_port Pointer to receive the resample port instance. 126 * 127 * @return PJ_SUCCESS on success. 128 */ 129 PJ_DECL(pj_status_t) pjmedia_resample_port_create( pj_pool_t *pool, 130 pj_bool_t high_quality, 131 pj_bool_t large_filter, 132 unsigned downstream_rate, 133 unsigned upstream_rate, 134 unsigned channel_count, 135 unsigned samples_per_frame, 136 pjmedia_port **p_port ); 137 138 73 139 PJ_END_DECL 74 140 -
pjproject/trunk/pjmedia/include/pjmedia/wave.h
r341 r358 33 33 #define PJMEDIA_WAVE_TAG ('E'<<24|'V'<<16|'A'<<8|'W') 34 34 #define PJMEDIA_FMT_TAG (' '<<24|'t'<<16|'m'<<8|'f') 35 #define PJMEDIA_DATA_TAG ('a'<<24|'t'<<16|'a'<<8|'d') 35 36 36 37 … … 70 71 71 72 73 /** 74 * On big-endian hosts, this function swaps the byte order of the values 75 * in the WAVE header fields. On little-endian hosts, this function does 76 * nothing. 77 * 78 * Application SHOULD call this function after reading the WAVE header 79 * chunks from a file. 80 * 81 * @param hdr The WAVE header. 82 */ 83 PJ_DECL(void) pjmedia_wave_hdr_file_to_host( pjmedia_wave_hdr *hdr ); 84 85 86 /** 87 * On big-endian hosts, this function swaps the byte order of the values 88 * in the WAVE header fields. On little-endian hosts, this function does 89 * nothing. 90 * 91 * Application SHOULD call this function before writing the WAVE header 92 * to a file. 93 * 94 * @param hdr The WAVE header. 95 */ 96 PJ_DECL(void) pjmedia_wave_hdr_host_to_file( pjmedia_wave_hdr *hdr ); 97 98 72 99 PJ_END_DECL 73 100 -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r352 r358 29 29 #include <pj/string.h> 30 30 31 /* CONF_DEBUG enables detailed operation of the conference bridge. 32 * Beware that it prints large amounts of logs (several lines per frame). 33 */ 31 34 //#define CONF_DEBUG 32 35 #ifdef CONF_DEBUG 33 36 # include <stdio.h> 34 # define TRACE_(x) {printf x; fflush(stdout); }37 # define TRACE_(x) PJ_LOG(5,x) 35 38 #else 36 39 # define TRACE_(x) 40 #endif 41 42 43 /* REC_FILE macro enables recording of the samples written to the sound 44 * device. The file contains RAW PCM data with no header, and has the 45 * same settings (clock rate etc) as the conference bridge. 46 * This should only be enabled when debugging audio quality *only*. 47 */ 48 //#define REC_FILE "confrec.pcm" 49 #ifdef REC_FILE 50 static FILE *fhnd_rec; 37 51 #endif 38 52 … … 967 981 pj_assert(count == conf->samples_per_frame); 968 982 983 TRACE_((THIS_FILE, "read_port %.*s: count=%d", 984 (int)cport->name.slen, cport->name.ptr, 985 count)); 986 969 987 /* If port's samples per frame and sampling rate matches conference 970 988 * bridge's settings, get the frame directly from the port. … … 976 994 f.buf = frame; 977 995 f.size = count * BYTES_PER_SAMPLE; 996 997 TRACE_((THIS_FILE, " get_frame %.*s: count=%d", 998 (int)cport->name.slen, cport->name.ptr, 999 count)); 978 1000 979 1001 status = (cport->port->get_frame)(cport->port, &f); … … 998 1020 f.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 999 1021 1022 TRACE_((THIS_FILE, " get_frame, count=%d", 1023 cport->samples_per_frame)); 1024 1000 1025 status = pjmedia_port_get_frame(cport->port, &f); 1001 1026 … … 1006 1031 1007 1032 if (f.type != PJMEDIA_FRAME_TYPE_AUDIO) { 1033 TRACE_((THIS_FILE, " get_frame returned non-audio")); 1008 1034 zero_samples( cport->rx_buf + cport->rx_buf_count, 1009 1035 cport->samples_per_frame); … … 1011 1037 1012 1038 cport->rx_buf_count += cport->samples_per_frame; 1039 1040 TRACE_((THIS_FILE, " rx buffer size is now %d", 1041 cport->rx_buf_count)); 1013 1042 1014 1043 pj_assert(cport->rx_buf_count <= cport->rx_buf_cap); … … 1023 1052 unsigned src_count; 1024 1053 1054 TRACE_((THIS_FILE, " resample, input count=%d", 1055 pjmedia_resample_get_input_size(cport->rx_resample))); 1056 1025 1057 pjmedia_resample_run( cport->rx_resample,cport->rx_buf, frame); 1026 1058 … … 1033 1065 } 1034 1066 1067 TRACE_((THIS_FILE, " rx buffer size is now %d", 1068 cport->rx_buf_count)); 1069 1035 1070 } else { 1036 1071 … … 1068 1103 frame.size = 0; 1069 1104 1070 if (cport->port && cport->port->put_frame) 1105 if (cport->port && cport->port->put_frame) { 1071 1106 pjmedia_port_put_frame(cport->port, &frame); 1107 } 1072 1108 1073 1109 cport->tx_level = 0; … … 1112 1148 } 1113 1149 1114 } else {1150 } else if (cport->sources) { 1115 1151 /* No need to adjust signal level. */ 1116 1152 for (j=0; j<conf->samples_per_frame; ++j) { 1117 1153 buf[j] = unsigned2pcm(cport->mix_buf[j] / cport->sources); 1118 1154 } 1155 } else { 1156 // Not necessarry. Buffer has been zeroed before. 1157 // zero_samples(buf, conf->samples_per_frame); 1158 pj_assert(buf[0] == 0); 1119 1159 } 1120 1160 … … 1155 1195 frame.timestamp.u64 = timestamp; 1156 1196 1197 TRACE_((THIS_FILE, "put_frame %.*s, count=%d", 1198 (int)cport->name.slen, cport->name.ptr, 1199 frame.size / BYTES_PER_SAMPLE)); 1200 1157 1201 return pjmedia_port_put_frame(cport->port, &frame); 1158 1202 } else … … 1186 1230 pj_status_t status; 1187 1231 1232 TRACE_((THIS_FILE, "write_port %.*s: count=%d", 1233 (int)cport->name.slen, cport->name.ptr, 1234 cport->samples_per_frame)); 1235 1188 1236 if (cport->port) { 1189 1237 pjmedia_frame frame; … … 1193 1241 frame.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 1194 1242 frame.timestamp.u64 = timestamp; 1243 1244 TRACE_((THIS_FILE, "put_frame %.*s, count=%d", 1245 (int)cport->name.slen, cport->name.ptr, 1246 frame.size / BYTES_PER_SAMPLE)); 1195 1247 1196 1248 status = pjmedia_port_put_frame(cport->port, &frame); … … 1206 1258 } 1207 1259 1260 TRACE_((THIS_FILE, " tx_buf count now is %d", 1261 cport->tx_buf_count)); 1262 1208 1263 return status; 1209 1264 } … … 1222 1277 unsigned ci, cj, i, j; 1223 1278 1279 TRACE_((THIS_FILE, "- clock -")); 1280 1224 1281 /* Check that correct size is specified. */ 1225 1282 pj_assert(frame->size == conf->samples_per_frame * … … 1228 1285 /* Must lock mutex (must we??) */ 1229 1286 pj_mutex_lock(conf->mutex); 1230 1231 TRACE_(("p"));1232 1287 1233 1288 /* Zero all port's temporary buffers. */ … … 1245 1300 mix_buf = conf_port->mix_buf; 1246 1301 1247 for (j=0; j<conf->samples_per_frame; ++j) 1248 mix_buf[j] = 0; 1302 for (j=0; j<conf->samples_per_frame; ++j) mix_buf[j] = 0; 1249 1303 } 1250 1304 … … 1422 1476 /* Return sound playback frame. */ 1423 1477 if (conf->ports[0]->sources) { 1478 TRACE_((THIS_FILE, "write to audio, count=%d", 1479 conf->samples_per_frame)); 1480 1424 1481 copy_samples( frame->buf, (pj_int16_t*)conf->ports[0]->mix_buf, 1425 1482 conf->samples_per_frame); … … 1432 1489 1433 1490 pj_mutex_unlock(conf->mutex); 1491 1492 #ifdef REC_FILE 1493 if (fhnd_rec == NULL) 1494 fhnd_rec = fopen(REC_FILE, "wb"); 1495 if (fhnd_rec) 1496 fwrite(frame->buf, frame->size, 1, fhnd_rec); 1497 #endif 1434 1498 1435 1499 return PJ_SUCCESS; … … 1448 1512 pj_int16_t *target_snd_buf; 1449 1513 unsigned i; 1450 1451 TRACE_(("r"));1452 1514 1453 1515 /* Check for correct size. */ -
pjproject/trunk/pjmedia/src/pjmedia/errno.c
r355 r358 123 123 { PJMEDIA_EWAVEUNSUPP, "Unsupported WAVE file format" }, 124 124 { PJMEDIA_EWAVETOOSHORT, "WAVE file too short" }, 125 { PJMEDIA_EFRMFILETOOBIG, "Sound frame too large for file buffer"}, 125 126 126 127 /* Sound device errors: */ -
pjproject/trunk/pjmedia/src/pjmedia/file_player.c
r357 r358 31 31 32 32 33 #ifndef PJMEDIA_FILE_PORT_BUFSIZE 34 # define PJMEDIA_FILE_PORT_BUFSIZE 4000 35 #endif 36 37 38 #define SIGNATURE ('F'<<24|'I'<<16|'L'<<8|'E') 33 #define SIGNATURE ('F'<<24|'P'<<16|'L'<<8|'Y') 34 #define BYTES_PER_SAMPLE 2 35 39 36 40 37 #if 1 … … 45 42 46 43 #if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0 47 PJ_INLINE(pj_int16_t) swap16(pj_int16_t val)48 {49 pj_uint8_t *p = (pj_uint8_t*)&val;50 pj_uint8_t tmp = *p;51 *p = *(p+1);52 *(p+1) = tmp;53 return val;54 }55 PJ_INLINE(pj_int32_t) swap32(pj_int32_t val)56 {57 pj_uint8_t *p = (pj_uint8_t*)&val;58 pj_uint8_t tmp = *p;59 *p = *(p+3);60 *(p+3) = tmp;61 tmp = *(p+1);62 *(p+1) = *(p+2);63 *(p+2) = tmp;64 return val;65 }66 # define SWAP16(val16) swap16(val16)67 # define SWAP32(val32) swap32(val32)68 44 static void samples_to_host(pj_int16_t *samples, unsigned count) 69 45 { 70 46 unsigned i; 71 47 for (i=0; i<count; ++i) { 72 samples[i] = SWAP16(samples[i]);48 samples[i] = pj_swap16(samples[i]); 73 49 } 74 50 } 75 51 #else 76 # define SWAP16(val16) (val16)77 # define SWAP32(val32) (val32)78 52 # define samples_to_host(samples,count) 79 53 #endif … … 171 145 172 146 /* Convert samples to host rep */ 173 samples_to_host((pj_int16_t*)fport->buf, fport->bufsize/ 2);147 samples_to_host((pj_int16_t*)fport->buf, fport->bufsize/BYTES_PER_SAMPLE); 174 148 175 149 return PJ_SUCCESS; 176 150 } 177 178 179 /*180 * Change the endianness of WAVE header fields.181 */182 void pjmedia_wave_hdr_swap_bytes( pjmedia_wave_hdr *hdr )183 {184 hdr->riff_hdr.riff = SWAP32(hdr->riff_hdr.riff);185 hdr->riff_hdr.file_len = SWAP32(hdr->riff_hdr.file_len);186 hdr->riff_hdr.wave = SWAP32(hdr->riff_hdr.wave);187 188 hdr->fmt_hdr.fmt = SWAP32(hdr->fmt_hdr.fmt);189 hdr->fmt_hdr.len = SWAP32(hdr->fmt_hdr.len);190 hdr->fmt_hdr.fmt_tag = SWAP16(hdr->fmt_hdr.fmt_tag);191 hdr->fmt_hdr.nchan = SWAP16(hdr->fmt_hdr.nchan);192 hdr->fmt_hdr.sample_rate = SWAP32(hdr->fmt_hdr.sample_rate);193 hdr->fmt_hdr.bytes_per_sec = SWAP32(hdr->fmt_hdr.bytes_per_sec);194 hdr->fmt_hdr.block_align = SWAP16(hdr->fmt_hdr.block_align);195 hdr->fmt_hdr.bits_per_sample = SWAP16(hdr->fmt_hdr.bits_per_sample);196 197 hdr->data_hdr.data = SWAP32(hdr->data_hdr.data);198 hdr->data_hdr.len = SWAP32(hdr->data_hdr.len);199 }200 201 202 #if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0203 # define normalize_wave_hdr(hdr) pjmedia_wave_hdr_swap_bytes(hdr)204 #else205 # define normalize_wave_hdr(hdr)206 #endif207 151 208 152 … … 224 168 225 169 PJ_UNUSED_ARG(flags); 226 PJ_UNUSED_ARG(buff_size);227 170 228 171 /* Check arguments. */ … … 266 209 } 267 210 268 /* Normalize WAVE header fields value (only used in big-endian hosts) */ 269 normalize_wave_hdr(&wave_hdr); 211 /* Normalize WAVE header fields values from little-endian to host 212 * byte order. 213 */ 214 pjmedia_wave_hdr_file_to_host(&wave_hdr); 270 215 271 216 /* Validate WAVE file. */ … … 292 237 293 238 /* Block align must be 2*nchannels */ 294 if (wave_hdr.fmt_hdr.block_align != wave_hdr.fmt_hdr.nchan* 2) {239 if (wave_hdr.fmt_hdr.block_align != wave_hdr.fmt_hdr.nchan*BYTES_PER_SAMPLE) { 295 240 pj_file_close(fport->fd); 296 241 return PJMEDIA_EWAVEUNSUPP; … … 327 272 /* Create file buffer. 328 273 */ 329 fport->bufsize = PJMEDIA_FILE_PORT_BUFSIZE; 274 if (buff_size < 1) buff_size = PJMEDIA_FILE_PORT_BUFSIZE; 275 fport->bufsize = buff_size; 330 276 331 277 … … 355 301 356 302 PJ_LOG(4,(THIS_FILE, 357 "File p ort '%.*s' created: clock=%dKHz, bufsize=%uKB, "303 "File player '%.*s' created: samp.rate=%d, ch=%d, bufsize=%uKB, " 358 304 "filesize=%luKB", 359 305 (int)fport->base.info.name.slen, 360 306 fport->base.info.name.ptr, 361 fport->base.info.sample_rate/1000, 307 fport->base.info.sample_rate, 308 fport->base.info.channel_count, 362 309 fport->bufsize / 1000, 363 310 (unsigned long)(fport->fsize / 1000))); … … 390 337 pj_assert(fport->base.info.signature == SIGNATURE); 391 338 392 frame_size = fport->base.info.bytes_per_frame; 393 pj_assert(frame->size == frame_size); 339 //frame_size = fport->base.info.bytes_per_frame; 340 //pj_assert(frame->size == frame_size); 341 frame_size = frame->size; 394 342 395 343 /* Copy frame from buffer. */ -
pjproject/trunk/pjmedia/src/pjmedia/pasound.c
r352 r358 132 132 } 133 133 134 if (statusFlags & pa InputUnderflow)134 if (statusFlags & paOutputUnderflow) 135 135 ++stream->underflow; 136 if (statusFlags & pa InputOverflow)136 if (statusFlags & paOutputOverflow) 137 137 ++stream->overflow; 138 138 … … 240 240 int sampleFormat; 241 241 const PaDeviceInfo *paDevInfo = NULL; 242 const PaHostApiInfo *paHostApiInfo = NULL; 242 243 unsigned paFrames; 243 244 PaError err; … … 292 293 inputParam.suggestedLatency = paDevInfo->defaultLowInputLatency; 293 294 295 paHostApiInfo = Pa_GetHostApiInfo(paDevInfo->hostApi); 296 294 297 /* Frames in PortAudio is number of samples in a single channel */ 295 298 paFrames = samples_per_frame / channel_count; … … 303 306 } 304 307 305 PJ_LOG(5,(THIS_FILE, "%s opening device %s for recording, sample rate=%d,"306 " channel count=%d, "307 " %d bits per sample, %d samples per buffer",308 PJ_LOG(5,(THIS_FILE, "%s opening device %s (%s) for recording, sample " 309 "rate=%d, ch=%d, " 310 "bits=%d, %d samples per frame", 308 311 (err==0 ? "Success" : "Error"), 309 paDevInfo->name, clock_rate, channel_count, 312 paDevInfo->name, paHostApiInfo->name, 313 clock_rate, channel_count, 310 314 bits_per_sample, samples_per_frame)); 311 315 … … 329 333 int sampleFormat; 330 334 const PaDeviceInfo *paDevInfo = NULL; 335 const PaHostApiInfo *paHostApiInfo = NULL; 331 336 unsigned paFrames; 332 337 PaError err; … … 381 386 outputParam.suggestedLatency = paDevInfo->defaultLowInputLatency; 382 387 388 paHostApiInfo = Pa_GetHostApiInfo(paDevInfo->hostApi); 389 383 390 /* Frames in PortAudio is number of samples in a single channel */ 384 391 paFrames = samples_per_frame / channel_count; … … 392 399 } 393 400 394 PJ_LOG(5,(THIS_FILE, "%s opening device %s for playing, sample rate=%d,"395 " channel count=%d, "396 " %d bits per sample, %d samples per frame",401 PJ_LOG(5,(THIS_FILE, "%s opening device %s(%s) for playing, sample rate=%d" 402 ", ch=%d, " 403 "bits=%d, %d samples per frame", 397 404 (err==0 ? "Success" : "Error"), 398 paDevInfo->name, clock_rate, channel_count, 405 paDevInfo->name, paHostApiInfo->name, 406 clock_rate, channel_count, 399 407 bits_per_sample, samples_per_frame)); 400 408 … … 426 434 const PaDeviceInfo *paRecDevInfo = NULL; 427 435 const PaDeviceInfo *paPlayDevInfo = NULL; 436 const PaHostApiInfo *paRecHostApiInfo = NULL; 437 const PaHostApiInfo *paPlayHostApiInfo = NULL; 428 438 unsigned paFrames; 429 439 PaError err; … … 498 508 inputParam.suggestedLatency = paRecDevInfo->defaultLowInputLatency; 499 509 510 paRecHostApiInfo = Pa_GetHostApiInfo(paRecDevInfo->hostApi); 511 500 512 pj_memset(&outputParam, 0, sizeof(outputParam)); 501 513 outputParam.device = play_id; … … 503 515 outputParam.hostApiSpecificStreamInfo = NULL; 504 516 outputParam.sampleFormat = sampleFormat; 505 outputParam.suggestedLatency = paPlayDevInfo->defaultLowInputLatency; 517 outputParam.suggestedLatency = paPlayDevInfo->defaultLowOutputLatency; 518 519 paPlayHostApiInfo = Pa_GetHostApiInfo(paPlayDevInfo->hostApi); 506 520 507 521 /* Frames in PortAudio is number of samples in a single channel */ … … 516 530 } 517 531 518 PJ_LOG(5,(THIS_FILE, "%s opening device %s /%s for recording and playback,"519 " sample rate=%d, channel count=%d, "520 " %d bits per sample, %d samples per buffer",532 PJ_LOG(5,(THIS_FILE, "%s opening device %s(%s)/%s(%s) for recording and " 533 "playback, sample rate=%d, ch=%d, " 534 "bits=%d, %d samples per frame", 521 535 (err==0 ? "Success" : "Error"), 522 paRecDevInfo->name, paPlayDevInfo->name, 536 paRecDevInfo->name, paRecHostApiInfo->name, 537 paPlayDevInfo->name, paPlayHostApiInfo->name, 523 538 clock_rate, channel_count, 524 539 bits_per_sample, samples_per_frame)); -
pjproject/trunk/pjmedia/src/pjmedia/port.c
r335 r358 36 36 PJ_ASSERT_RETURN(pool && upstream_port && downstream_port, PJ_EINVAL); 37 37 38 #if 0 38 39 /* They both MUST have the same media type. */ 39 40 PJ_ASSERT_RETURN(upstream_port->info.type == … … 58 59 downstream_port->info.bytes_per_frame, 59 60 PJMEDIA_ENCBYTES); 61 #endif 60 62 61 63 /* Create mutual attachment. */ 62 status = upstream_port->on_downstream_connect( pool, upstream_port, 63 downstream_port ); 64 if (status != PJ_SUCCESS) 65 return status; 64 if (upstream_port->on_downstream_connect) { 65 status = upstream_port->on_downstream_connect( pool, upstream_port, 66 downstream_port ); 67 if (status != PJ_SUCCESS) 68 return status; 69 } 66 70 67 status = downstream_port->on_upstream_connect( pool, downstream_port, 68 upstream_port ); 69 if (status != PJ_SUCCESS) 70 return status; 71 if (downstream_port->on_upstream_connect) { 72 status = downstream_port->on_upstream_connect( pool, downstream_port, 73 upstream_port ); 74 if (status != PJ_SUCCESS) 75 return status; 76 } 71 77 72 78 /* Save the attachment. */ -
pjproject/trunk/pjmedia/src/pjmedia/resample.c
r347 r358 499 499 */ 500 500 if (rate_out < rate_in) { 501 high_quality = 0;501 //high_quality = 0; 502 502 } 503 503 … … 580 580 */ 581 581 dst_buf = resample->buffer + resample->xoff*2; 582 for (i=0; i<resample->frame_size; ++i) 583 dst_buf[i] = input[i]; 582 for (i=0; i<resample->frame_size; ++i) dst_buf[i] = input[i]; 584 583 585 584 if (resample->factor >= 1) { … … 633 632 } 634 633 } 634 635 PJ_DEF(unsigned) pjmedia_resample_get_input_size(pjmedia_resample *resample) 636 { 637 PJ_ASSERT_RETURN(resample != NULL, 0); 638 return resample->frame_size; 639 } 640 -
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r352 r358 71 71 goto no_frame; 72 72 73 /* Must supply the required samples */ 74 pj_assert(frame.size == size); 75 73 76 return PJ_SUCCESS; 74 77
Note: See TracChangeset
for help on using the changeset viewer.