Ignore:
Timestamp:
Jun 27, 2008 9:12:12 PM (12 years ago)
Author:
nanang
Message:

Ticket #543:

  • added options to run.py
  • passing options in runall.py to run.py
  • removing userdata in module callback functions
File:
1 edited

Legend:

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

    r2075 r2078  
    2222 
    2323# Load configuration 
    24 cfg_file = imp.load_source("cfg_file", sys.argv[2]) 
     24cfg_file = imp.load_source("cfg_file", ARGS[1]) 
    2525 
    2626# PESQ configs 
    27 # PESQ_THRESHOLD specifies the minimum acceptable PESQ MOS value, so test can be declared successful 
    28 PESQ = "tools/pesq.exe" 
    29 PESQ_DEFAULT_THRESHOLD = 3.4 
     27PESQ = "tools/pesq.exe"                 # PESQ executable path 
     28PESQ_DEFAULT_THRESHOLD = 3.4            # Default minimum acceptable PESQ MOS value 
    3029 
    31 # UserData 
    32 class mod_pesq_user_data: 
    33         # Sample rate option for PESQ 
    34         pesq_sample_rate_opt = "" 
    35         # Input/Reference filename 
    36         input_filename = "" 
    37         # Output/Degraded filename 
    38         output_filename = "" 
     30# PESQ params 
     31pesq_sample_rate_opt = ""               # Sample rate option for PESQ 
     32input_filename  = ""                    # Input/Reference filename 
     33output_filename = ""                    # Output/Degraded filename 
     34 
    3935 
    4036# Test body function 
    41 def test_func(t, user_data): 
     37def test_func(t): 
     38        global pesq_sample_rate_opt 
     39        global input_filename 
     40        global output_filename 
    4241 
    4342        ua1 = t.process[0] 
     
    4544 
    4645        # Get input file name 
    47         user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1) 
     46        input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1) 
    4847 
    4948        # Get output file name 
    50         user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 
     49        output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 
    5150 
    5251        # Get WAV input length, in seconds 
    53         fin = wave.open(user_data.input_filename, "r") 
     52        fin = wave.open(input_filename, "r") 
    5453        if fin == None: 
    5554                raise TestError("Failed opening input WAV file") 
     
    6059 
    6160        # Get clock rate of the output 
    62         mo_clock_rate = re.compile("\.(\d+)\.wav").search(user_data.output_filename) 
     61        mo_clock_rate = re.compile("\.(\d+)\.wav").search(output_filename) 
    6362        if (mo_clock_rate==None): 
    6463                raise TestError("Cannot compare input & output, incorrect output filename format") 
     
    7372        # (PESQ evaluates only files whose same clock rate & channel count) 
    7473        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) 
     74            if re.search("\.\d+\.\d+\.wav", input_filename) != None: 
     75                    input_filename = re.sub("\.\d+\.\d+\.wav", "." + str(channel_count) + "."+clock_rate+".wav", input_filename) 
    7876            else: 
    79                     user_data.input_filename = re.sub("\.\d+\.wav",  
    80                                                       "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 
     77                    input_filename = re.sub("\.\d+\.wav", "." + str(channel_count) + "."+clock_rate+".wav", input_filename) 
    8178 
    8279        if (clock_rate != "8") & (clock_rate != "16"): 
     
    8481 
    8582        # Get conference clock rate of UA2 for PESQ sample rate option 
    86         user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 
     83        pesq_sample_rate_opt = "+" + clock_rate + "000" 
    8784 
    8885        # UA1 making call 
     
    114111 
    115112# Post body function 
    116 def post_func(t, user_data): 
     113def post_func(t): 
     114        global pesq_sample_rate_opt 
     115        global input_filename 
     116        global output_filename 
     117 
    117118        endpt = t.process[0] 
    118119 
    119120        # Execute PESQ 
    120         fullcmd = PESQ + " " + user_data.pesq_sample_rate_opt + " " + user_data.input_filename + " " + user_data.output_filename 
     121        fullcmd = PESQ + " " + pesq_sample_rate_opt + " " + input_filename + " " + output_filename 
    121122        endpt.trace("Popen " + fullcmd) 
    122123        pesq_proc = subprocess.Popen(fullcmd, stdout=subprocess.PIPE, universal_newlines=True) 
     
    147148test.test_func = test_func 
    148149test.post_func = post_func 
    149 test.user_data = mod_pesq_user_data() 
    150150 
Note: See TracChangeset for help on using the changeset viewer.