Ignore:
Timestamp:
Jun 25, 2008 6:18:32 PM (16 years ago)
Author:
nanang
Message:

Ticket #543: Updated mod_pseq & mod_media_playrec.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py

    r2038 r2052  
    3939# Test body function 
    4040def test_func(t, user_data): 
    41         # module debugging purpose 
    42         #user_data.pesq_sample_rate_opt = "+16000" 
    43         #user_data.input_filename = "wavs/input.16.wav" 
    44         #user_data.output_filename = "wavs/tmp.16.wav" 
    45         #return 
    46  
    4741        ua1 = t.process[0] 
    4842        ua2 = t.process[1] 
    4943 
    50         # Get conference clock rate of UA2 for PESQ sample rate option 
    51         ua2.send("cl") 
    52         clock_rate_line = ua2.expect("Port \#00\[\d+KHz") 
    53         if (clock_rate_line == None): 
    54                 raise TestError("Failed getting") 
    55         clock_rate = re.match("Port \#00\[(\d+)KHz", clock_rate_line).group(1) 
    56         user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 
    57  
    5844        # Get input file name 
    59         ua1.sync_stdout() 
    60         ua1.send("dc") 
    61         line = ua1.expect(const.MEDIA_PLAY_FILE) 
    62         user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).match(line).group(1) 
     45        user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1) 
    6346 
    6447        # Get output file name 
    65         ua2.sync_stdout() 
    66         ua2.send("dc") 
    67         line = ua2.expect(const.MEDIA_REC_FILE) 
    68         user_data.output_filename = re.compile(const.MEDIA_REC_FILE).match(line).group(1) 
     48        user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 
    6949 
    7050        # Find appropriate clock rate for the input file 
    71         clock_rate = re.compile(".+(\.\d+\.wav)$").match(user_data.output_filename) 
    72         if (clock_rate==None): 
     51        mo_clock_rate = re.compile("\.(\d+)\.wav").search(user_data.output_filename) 
     52        if (mo_clock_rate==None): 
    7353                raise TestError("Cannot compare input & output, incorrect output filename format") 
    74         user_data.input_filename = re.sub("\.\d+\.wav$", clock_rate.group(1), user_data.input_filename) 
     54        clock_rate = mo_clock_rate.group(1) 
     55        user_data.input_filename = re.sub("\.\d+\.wav", "."+clock_rate+".wav", user_data.input_filename) 
    7556 
    76         time.sleep(1) 
    77         ua1.sync_stdout() 
    78         ua2.sync_stdout() 
     57        if (clock_rate != "8") & (clock_rate != "16"): 
     58                raise TestError("PESQ only works on clock rate 8kHz or 16kHz, clock rate used = "+clock_rate+ "kHz") 
     59 
     60        # Get conference clock rate of UA2 for PESQ sample rate option 
     61        user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 
    7962 
    8063        # UA1 making call 
     
    8265        ua1.send(t.inst_params[1].uri) 
    8366        ua1.expect(const.STATE_CALLING) 
    84          
     67        ua2.expect(const.STATE_CONFIRMED) 
     68 
     69        # Disconnect mic -> rec file to avoid echo recorded when using sound device 
     70        ua2.send("cd 0 1") 
     71 
    8572        # Auto answer, auto play, auto hangup 
    8673        # Just wait for call disconnected 
    87  
    88         if ua1.expect(const.STATE_CONFIRMED, False)==None: 
    89                 raise TestError("Call failed") 
    90         ua2.expect(const.STATE_CONFIRMED) 
    91  
    92         while True: 
     74        # Assumed WAV input is no more than 30 secs 
     75        while 1: 
    9376                line = ua2.proc.stdout.readline() 
    9477                if line == "": 
    9578                        raise TestError(ua2.name + ": Premature EOF") 
     79 
    9680                # Search for disconnected text 
    9781                if re.search(const.STATE_DISCONNECTED, line) != None: 
     
    116100        # Evaluate the similarity value 
    117101        pesq_res = mo_pesq_out.group(1) 
    118         if (pesq_res >= PESQ_THRESHOLD): 
     102        if (float(pesq_res) >= PESQ_THRESHOLD): 
    119103                endpt.trace("Success, PESQ result=" + pesq_res) 
    120104        else: 
Note: See TracChangeset for help on using the changeset viewer.