Changeset 2075
- Timestamp:
- Jun 27, 2008 4:18:13 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 10 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/clock.h
r2039 r2075 122 122 * @param pool Pool to allocate memory. 123 123 * @param clock_rate Number of samples per second. 124 * @param channel_count Number of channel. 124 125 * @param samples_per_frame Number of samples per frame. This argument 125 * along with clock_rate , specifies the interval126 * of each clock run (or clock ticks).126 * along with clock_rate and channel_count, specifies 127 * the interval of each clock run (or clock ticks). 127 128 * @param options Bitmask of pjmedia_clock_options. 128 129 * @param cb Callback to be called for each clock tick. … … 135 136 PJ_DECL(pj_status_t) pjmedia_clock_create( pj_pool_t *pool, 136 137 unsigned clock_rate, 138 unsigned channel_count, 137 139 unsigned samples_per_frame, 138 140 unsigned options, -
pjproject/trunk/pjmedia/src/pjmedia/clock_thread.c
r2039 r2075 56 56 PJ_DEF(pj_status_t) pjmedia_clock_create( pj_pool_t *pool, 57 57 unsigned clock_rate, 58 unsigned channel_count, 58 59 unsigned samples_per_frame, 59 60 unsigned options, … … 75 76 return status; 76 77 77 clock->interval.u64 = samples_per_frame * clock->freq.u64 / clock_rate; 78 clock->interval.u64 = samples_per_frame * clock->freq.u64 / 79 channel_count / clock_rate; 78 80 clock->next_tick.u64 = 0; 79 81 clock->timestamp.u64 = 0; -
pjproject/trunk/pjmedia/src/pjmedia/master_port.c
r2039 r2075 53 53 pjmedia_master_port *m; 54 54 unsigned clock_rate; 55 unsigned channel_count; 55 56 unsigned samples_per_frame; 56 57 unsigned bytes_per_frame; … … 65 66 PJMEDIA_ENCCLOCKRATE); 66 67 67 /* Both ports MUST have equal ptime */68 PJ_ASSERT_RETURN(u_port->info. clock_rate/u_port->info.samples_per_frame==69 d_port->info. clock_rate/d_port->info.samples_per_frame,68 /* Both ports MUST have equal samples per frame */ 69 PJ_ASSERT_RETURN(u_port->info.samples_per_frame== 70 d_port->info.samples_per_frame, 70 71 PJMEDIA_ENCSAMPLESPFRAME); 72 73 /* Both ports MUST have equal channel count */ 74 PJ_ASSERT_RETURN(u_port->info.channel_count == d_port->info.channel_count, 75 PJMEDIA_ENCCHANNEL); 71 76 72 77 … … 74 79 clock_rate = u_port->info.clock_rate; 75 80 samples_per_frame = u_port->info.samples_per_frame; 81 channel_count = u_port->info.channel_count; 76 82 77 83 … … 103 109 104 110 /* Create media clock */ 105 status = pjmedia_clock_create(pool, clock_rate, samples_per_frame, 106 options, &clock_callback, m, &m->clock); 111 status = pjmedia_clock_create(pool, clock_rate, channel_count, 112 samples_per_frame, options, &clock_callback, 113 m, &m->clock); 107 114 if (status != PJ_SUCCESS) { 108 115 pj_lock_destroy(m->lock); -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
r2063 r2075 50 50 user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 51 51 52 # Find appropriate clock rate for the input file 52 # Get WAV input length, in seconds 53 fin = wave.open(user_data.input_filename, "r") 54 if fin == None: 55 raise TestError("Failed opening input WAV file") 56 inwavlen = fin.getnframes() * 1.0 / fin.getframerate() 57 inwavlen += 0.2 58 fin.close() 59 print "WAV input len = " + str(inwavlen) + "s" 60 61 # Get clock rate of the output 53 62 mo_clock_rate = re.compile("\.(\d+)\.wav").search(user_data.output_filename) 54 63 if (mo_clock_rate==None): 55 64 raise TestError("Cannot compare input & output, incorrect output filename format") 56 65 clock_rate = mo_clock_rate.group(1) 57 user_data.input_filename = re.sub("\.\d+\.wav", "."+clock_rate+".wav", user_data.input_filename) 66 67 # Get channel count of the output 68 channel_count = 1 69 if re.search("--stereo", ua2.inst_param.arg) != None: 70 channel_count = 2 71 72 # Get matched input file from output file 73 # (PESQ evaluates only files whose same clock rate & channel count) 74 if channel_count == 2: 75 if re.search("\.\d+\.\d+\.wav", user_data.input_filename) != None: 76 user_data.input_filename = re.sub("\.\d+\.\d+\.wav", 77 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 78 else: 79 user_data.input_filename = re.sub("\.\d+\.wav", 80 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 58 81 59 82 if (clock_rate != "8") & (clock_rate != "16"): … … 62 85 # Get conference clock rate of UA2 for PESQ sample rate option 63 86 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 64 65 # Get WAV input length, in seconds66 fin = wave.open(user_data.input_filename, "r")67 if fin == None:68 raise TestError("Failed opening input WAV file")69 inwavlen = fin.getnframes() // fin.getframerate()70 if (fin.getnframes() % fin.getframerate()) > 0:71 inwavlen = inwavlen + 172 fin.close()73 87 74 88 # UA1 making call … … 110 124 111 125 # Parse ouput 112 mo_pesq_out = re.compile("Prediction[^=]+=\s+([\ d\.]+)\s*").search(pesq_out[0])126 mo_pesq_out = re.compile("Prediction[^=]+=\s+([\-\d\.]+)\s*").search(pesq_out[0]) 113 127 if (mo_pesq_out == None): 114 128 raise TestError("Failed to fetch PESQ result")
Note: See TracChangeset
for help on using the changeset viewer.