Beispiel #1
0
    def headerlog_parse(self):
        file = get_result_path() + self.dict['Log']        
        begin_frameno = self.dict['BeginFrameNo']
        end_frameno = self.dict['EndFrameNo']
        fps = self.dict['FPS']
        windowsize = self.dict['WindowSize']

        min_bitrate = 0
        max_bitrate = 0
        max_ssize = 0
        min_ssize = 0
        min_scnt = 0
        max_scnt = 0
        min_i_interval = 0
        max_i_interval = 0
        min_idr_interval = 0
        max_idr_interval = 0

        self.cli.download(file,'hlog')

        if not os.path.isfile('hlog'):
            print 'log not exist'
        else:
            fd = open('hlog')

            slice_size = 0
            slice_no = 0
        i_no = 0
        pre_idr_fno = 0
        idr_no = 0
        idr_interval = 0

        self.rt_dict.setdefault('MaxBitrate',max_bitrate)
        self.rt_dict.setdefault('MinBitrate',min_bitrate)
        self.rt_dict.setdefault('MaxSliceSize',max_ssize)
        self.rt_dict.setdefault('MinSliceSize',min_ssize)
        self.rt_dict.setdefault('MaxSliceNum',max_scnt)
        self.rt_dict.setdefault('MinSliceNum',min_scnt)
        self.rt_dict.setdefault('MaxIDRInterval',max_idr_interval)
        self.rt_dict.setdefault('MinIDRInterval',min_idr_interval)

        self.cli.teardown()
        return self.rt_dict
Beispiel #2
0
    def headerlog_parse(self):
        file = get_result_path() + self.dict['Log']
        begin_frameno = self.dict['BeginFrameNo']
        end_frameno = self.dict['EndFrameNo']
        fps = self.dict['FPS']
        windowsize = self.dict['WindowSize']

        min_bitrate = 0
        max_bitrate = 0
        max_ssize = 0
        min_ssize = 0
        min_scnt = 0
        max_scnt = 0
        min_i_interval = 0
        max_i_interval = 0
        min_idr_interval = 0
        max_idr_interval = 0

        self.cli.download(file, 'hlog')

        if not os.path.isfile('hlog'):
            print 'log not exist'
        else:
            fd = open('hlog')

            slice_size = 0
            slice_no = 0
        i_no = 0
        pre_idr_fno = 0
        idr_no = 0
        idr_interval = 0

        self.rt_dict.setdefault('MaxBitrate', max_bitrate)
        self.rt_dict.setdefault('MinBitrate', min_bitrate)
        self.rt_dict.setdefault('MaxSliceSize', max_ssize)
        self.rt_dict.setdefault('MinSliceSize', min_ssize)
        self.rt_dict.setdefault('MaxSliceNum', max_scnt)
        self.rt_dict.setdefault('MinSliceNum', min_scnt)
        self.rt_dict.setdefault('MaxIDRInterval', max_idr_interval)
        self.rt_dict.setdefault('MinIDRInterval', min_idr_interval)

        self.cli.teardown()
        return self.rt_dict
Beispiel #3
0
 def camera(self):
     result = check_android_sdk()
     if not result:
         raise TestException('Error: please run setup.py to install Android SDK')
     if self.stepType == 0 or self.stepType == 10:
         if self.stepType == 10:
             return "noResult"
     
     if self.stepType == 0 or self.stepType == 20:
         print "\nCase preparation: \n"
         SOURCE_CLIP_PATH = '/sdcard/DCIM/Camera/'
         TARGET_CLIP_PATH = get_result_path() + 'VideoCapture/'
         self.cli.execute("rm -rf " + SOURCE_CLIP_PATH + '*')
         self.cli.execute("mkdir -p " + TARGET_CLIP_PATH)
         
         sensor_flag = self.par_dict.get('Sensor', ' ')
         if sensor_flag is None or sensor_flag.strip() == '' or sensor_flag.strip().lower() not in ['front', 'back']:
             raise TestException('ERROR: No Sensor element found or the value of Sensor element should be Front or Back')
         if sensor_flag.lower() == 'front':
             sensor_resolution = FRONT_SENSOR_RESOLUTION
             script_pre = 'Default_Cam_Front_'
         else:
             sensor_resolution = BACK_SENSOR_RESOLUTION
             script_pre = 'Default_Cam_Back_'
             
         duration = self.par_dict.get('Duration', '')
         try:
             duration = int(duration)
         except (ValueError, TypeError), e:
             raise TestException("Error:  no Duration element found or the value of Duration element  must be a number")
         
         resolution = self.par_dict.get('Resolution', '')
         if resolution.strip() == '1080p_modified':
             self.cli.execute_on_host('root')
             self.cli.execute_on_host('remount')
             self.cli.upload('resource/settings/media_profiles.xml', '/etc/')
             self.cli.execute_on_host('reboot')
             time.sleep(120)
             self.cli.execute('svc power stayon usb')
             execute_command_on_server('./resource/settings/unlock.sh ' + self.dev_dict['serialNumber'], False)
         if resolution is None or resolution.strip() == '' or resolution.strip() not in sensor_resolution:
             raise TestException("Error:  no Resolution element found or the value of Resolution element  must be the value in " + ','.join(sensor_resolution))
         if self.platform is not None and self.platform.lower() == 'mfld_r3':
             cmd = 'am start -n com.android.camera/.Camera'
         elif self.platform is not None and self.platform.lower() == 'mfld_r4':
             cmd = 'am start -n com.android.gallery3d/com.android.camera.CameraLauncher'
         elif self.platform is not None and self.platform.lower() == 'ctp':
             cmd = 'am start -n com.android.gallery3d/com.android.camera.CameraLauncher'
         else:
             raise TestException('Error: please specify platform: ctp or mfld_r3 or mfld_r4')
         self.cli.execute(cmd)
         
         if self.caseFolderName.lower().find('zoom_max') != -1:
             pre_script_directory = 'default_camera_zoom'
             script_name = script_pre + resolution.strip() + '.mr'
         elif self.caseFolderName.lower().find('timelapse') != -1:
             pre_script_directory = 'default_camera_timelapse'
             timelapse = self.par_dict.get('Timelapse', '').strip()
             if timelapse == '':
                 raise TestException("Error: no Timelapse element found.")
             timelapse_dict = {'off': '0s', '1': '1s', '1.5': '1s5', '2': '2s', '2.5': '2s5', 
                               '3': '3s', '5': '5s', '10': '10s'}
             script_name = script_pre + resolution.strip() + '-' + timelapse_dict[timelapse.strip().lower()] + '.mr'
         else:
             pre_script_directory = 'default_camera'
             script_name = script_pre + resolution.strip() + '.mr'
             
         if self.platform.lower().find('mfld') != -1:
             script_folder = 'MFLD'
         elif self.platform.lower() == 'ctp':
             script_folder = 'CTP'
             
         cmd = 'resource/monkeyrunner/scripts/monkey_playback.py ' + ' resource/video_caputure_script/' + script_folder + '/' + pre_script_directory + '/' + script_name
         print cmd
         stdout, stderr = execute_command_on_server(cmd, False)
         # press back key, and exit camera UI
         cmd = 'input keyevent 4'
         self.cli.execute(cmd)
         self.cli.execute(cmd)
         # get the clip name for mediainfo
         stdout, stderr = self.cli.execute("ls -al " + SOURCE_CLIP_PATH + ' | grep ^-')
         dirList = stdout.split('\n')
         outputName = ''
         for eachdir in dirList:
             outputName = outputName + (eachdir.split(' ')[-1])
         outputName = outputName.strip()
         
         #pull the clip to test_repo
         os.system("mkdir -p " + path.resultClip_path + '/' + self.caseFolderName + '/')
         self.cli.execute('mv '+ SOURCE_CLIP_PATH + outputName + ' ' + TARGET_CLIP_PATH)
         self.cli.download(TARGET_CLIP_PATH + outputName + " ", path.resultClip_path + '/' + self.caseFolderName + '/')
         
         #obtain mediainfo result on result clip            
         mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' + self.caseFolderName + '/' + outputName)
         for eachItem in mediainfo_dict:           
             self.rt_dict.setdefault(eachItem, mediainfo_dict[eachItem])
         return self.rt_dict 
Beispiel #4
0
        self.Clip_Path = get_clip_path()

    def jpeg_decode(self):
        try:
            inputFile = self.dict['InputFile'].strip()
        except KeyError, e:
            raise TestException(
                "Error: no InputFile element found in Parameter element")
        try:
            OutputFile = self.dict['OutputFile'].strip()
        except KeyError, e:
            raise TestException(
                "Error: no OutputFile element found in Parameter element")
        prefix = get_clip_path() + 'Image/'

        result_path = get_result_path() + 'JPEG_Decode/'
        mkdir_cmd = 'mkdir -p ' + result_path
        self.cli.execute_test(mkdir_cmd, self.step_id)
        cmd = 'djpeg -bmp ' + prefix + inputFile + ' ' + result_path + OutputFile
        self.cli.execute_test(cmd, self.step_id)
        stdout, stderr = self.cli.execute_test(
            'cksum ' + result_path + OutputFile, self.step_id)
        bmp_crc = stdout.split('/')[0].strip()
        self.rt_dict.setdefault('Image_CRC', bmp_crc)
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 30:
            if self.stepType == 30:
                return "noResult"

        return self.rt_dict
Beispiel #5
0
    def decode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item + "', please check the case profile.")
        try:
            if not cmp(self.dict['Format'], 'H263'):
                vld = 'mpeg4vld'
            else:
                vld = self.dict['Format'].lower() + 'vld'
        except KeyError:
            raise TestException("Error: no Format element found in Parameter element ")
        try:
            inp = self.Clip_Path + self.dict['Format'] + '/' + self.dict['InputFile']
        except KeyError:
            raise TestException("Error: no InputFile element found in Parameter element ")
        outp = ''
        if self.dict.get('CRC') is None or not cmp(self.dict['CRC'], 'Off'):
            crcp = ''
        else:
            crcp = ' -c'

        if self.dict.get('Window') is None or not cmp(self.dict['Window'], 'Off'):
            wdp = ''
        else:
            wdp = ' -n'

        if self.dict.get('FPS') is None or not cmp(self.dict['FPS'], 'Off'):
            fpsp = ''
        else:
            fpsp = ' -r '+ self.dict['FPS']

        if self.dict.get('Rotation') is None or not cmp(self.dict['Rotation'], 'Off'):
            rp = ''
        else:
            rp = ' -z ' + self.dict['Rotation']

        if self.dict.get('Headerlog') is None or not cmp(self.dict['Headerlog'], 'Off'):
            hp = ''
        else:
            hp = ' -headerlog ' +  get_result_path() + self.dict['Headerlog']
            

        if self.dict.get('FullScreen') is None or not cmp(self.dict['FullScreen'], 'Off'):
            fsp = ''
        else:
            fsp = ' -k'

        if self.dict.get('Display') is None or not cmp(self.dict['Display'],'overlay'):
            dp = ''
        else:
            dp = 'PSB_VIDEO_CTEXTURE=1 '

        cmd = dp + self.prefix + vld + ' -x -i ' + inp + outp + crcp + wdp + fpsp + rp + hp + fsp
        print cmd
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"
        
        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r') 
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id)) 
                outfile = open('log' + str(self.step_id), 'r')
            stdout = outfile.read()
            outfile.close()
            
            outfile='log' + str(self.step_id)
            dp = DataParser()
            try:
                crc_value = self.dict['CRC']
            except KeyError, e:
                raise TestException("Error: no CRC element found ")
Beispiel #6
0
        try:
            if cmp(self.dict1['Platform'], 'MFLD'):
                set = ''
            else:
                set = 'MFLD=1 '
        except KeyError, e:
            raise TestException("Error: no Platform element found in device's profile ")

        if self.dict.get('Format') is None or self.dict.get('Resolution') is None or self.dict.get('IntraPeriod') is None:
            self.tc_dict.setdefault('rt','F')
            return self.tc_dict

        if self.dict.get('RecYUV') is None or not cmp(self.dict['RecYUV'],'Off'):
            recp = ''
        else:
            recp = ' -recyuv ' +  get_result_path() + self.dict['RecYUV']

        if self.dict['IntraPeriod'] is None or not cmp(self.dict['IntraPeriod'],'Off'):
            itpp = ''
        else:
            itpp = ' -intracnt ' + self.dict['IntraPeriod']

        if self.dict['IDRPeriod'] is None or not cmp(self.dict['IDRPeriod'],'Off'):
            idrp = ''
        else:
            idrp = ' -idrcnt ' + self.dict['IDRPeriod']

        if self.dict['QP'] is None or not cmp(self.dict['QP'],'Off'):
            qpp = ''
        else:
            qpp = ' -qpluma ' + self.dict['QP']
Beispiel #7
0
    def decode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")
        try:
            if not cmp(self.dict['Format'], 'H264'):
                videoFormat = 1
            elif not cmp(self.dict['Format'], 'MPEG4'):
                videoFormat = 2
            elif not cmp(self.dict['Format'], 'H263'):
                videoFormat = 3
            elif not cmp(self.dict['Format'], 'VC1'):
                videoFormat = 4
            else:
                raise TestException(
                    "Error: Invalid text in Format element in case configuration file."
                )
        except KeyError:
            raise TestException(
                "Error: no Format element found in Parameter element.")
        try:
            input = self.Clip_Path + self.dict['Format'] + '/' + self.dict[
                'InputFile']
        except KeyError:
            raise TestException(
                "Error: no InputFile element found in Parameter element ")
        try:
            output = get_result_path() + self.dict['OutputFile']
        except KeyError:
            raise TestException(
                "Error: no OutputFile element found in Parameter element ")

        try:
            resolution = self.dict['Resolution']
        except KeyError:
            raise TestException(
                "Error: no Resolution element found in Parameter element ")
        try:
            maxwidth = resolution.split('x')[0]
            maxheight = resolution.split('x')[1]
        except IndexError:
            raise TestException(
                "Error: the text in Resolution element must be in the format of NUMBERxNUMBER "
            )

        try:
            decodeSpeed = self.dict['DecodeSpeed']
        except KeyError:
            raise TestException(
                "Error: no DecodeSpeed element found in Parameter element ")

        cmd = "VideoDecTest " + input + ' ' + output + ' ' + str(
            videoFormat) + ' ' + str(maxwidth) + ' ' + str(
                maxheight) + ' ' + decodeSpeed
        print "Command:"
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r')
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
            stdout = outfile.read()
            outfile.close()

            #obtain FPS
            str1 = stdout.find("(seconds)") + 12
            str2 = stdout[str1:str1 + 30].find('\n')
            fps = stdout[str1:str1 + str2].replace('\n', '').replace(
                ' ', '').replace('\r', '')
            self.rt_dict.setdefault('FPS', fps)

            #obtain YV12_CRC
            YV12_CRC = stdout.split('\n')[-2].replace(' ',
                                                      '').replace('\r', '')
            self.rt_dict.setdefault('YV12_CRC', YV12_CRC)

            #download output file
            #self.cli.download(get_result_path() + self.dict['OutputFile'], path.result_path + '/' + self.caseFolderName + '/')

            #delete files
            self.cli.execute("rm " + get_result_path() +
                             self.dict['OutputFile'])
Beispiel #8
0
    def encode(self):

        print "Command for va_log detection:"

        #enable va_log
        stdout, stderr = self.cli.execute(
            "echo \\\"LIBVA_TRACE=/data/1\\\" > /etc/libva.conf")

        #delete original
        stdout, stderr = self.cli.execute("rm -rf /data/1.*")

        print ""

        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")

        try:
            if not cmp(self.dict['Format'], 'H264'):
                encodeFormat = 7
            elif not cmp(self.dict['Format'], 'MPEG4'):
                encodeFormat = 4
            elif not cmp(self.dict['Format'], 'H263'):
                encodeFormat = 3
            else:
                raise TestException(
                    "Error: Invalid text in Format element in case configuration file."
                )
        except KeyError:
            raise TestException(
                "Error: no Format element found in Parameter element.")

        try:
            input = self.Clip_Path + "YUV/" + self.dict['InputFile']
        except KeyError:
            raise TestException(
                "Error: no InputFile element found in Parameter element ")
        try:
            output = get_result_path() + self.dict['OutputFile']
        except KeyError:
            raise TestException(
                "Error: no OutputFile element found in Parameter element ")

        try:
            resolution = self.dict['Resolution']
        except KeyError:
            raise TestException(
                "Error: no Resolution element found in Parameter element ")
        try:
            width = resolution.split('x')[0]
            height = resolution.split('x')[1]
        except IndexError:
            raise TestException(
                "Error: the text in Resolution element must be in the format of NUMBERxNUMBER "
            )

        try:
            speed = self.dict['Speed']
            if speed == 'Off':
                speed = '0'
        except KeyError:
            raise TestException(
                "Error: no Speed element found in Parameter element ")

        try:
            bitRate = self.dict['BitRate']
            if bitRate == 'Off':
                bitRate = '0'
        except KeyError:
            raise TestException(
                "Error: no BitRate element found in Parameter element ")

        try:
            framerate = self.dict['Framerate']
            if framerate == 'Off':
                framerate = '15'
        except KeyError:
            raise TestException(
                "Error: no Framerate element found in Parameter element ")

        try:
            level = self.dict['Level'].replace('L', '')
            if encodeFormat == 7:
                if level == 'Off':
                    level = '0'
                elif level == '1':
                    level = '1'
                elif level == '1b':
                    level = '2'
                elif level == '1.1':
                    level = '4'
                elif level == '1.2':
                    level = '8'
                elif level == '1.3':
                    level = '10'
                elif level == '2.0':
                    level = '20'
                elif level == '2.1':
                    level = '40'
                elif level == '2.2':
                    level = '80'
                elif level == '3.0':
                    level = '100'
                elif level == '3.1':
                    level = '200'
                elif level == '3.2':
                    level = '400'
                elif level == '4.0':
                    level = '800'
                elif level == '4.1':
                    level = '1000'
                elif level == '4.2':
                    level = '2000'
                elif level == '5.0':
                    level = '4000'
                elif level == '5.1':
                    level = '8000'
            elif encodeFormat == 3:
                if level == 'Off':
                    level = '0'
                elif level == '10':
                    level = '1'
                elif level == '20':
                    level = '2'
                elif level == '30':
                    level = '4'
                elif level == '40':
                    level = '8'
                elif level == '50':
                    level = '10'
                elif level == '60':
                    level = '20'
                elif level == '70':
                    level = '40'
            elif encodeFormat == 4:
                if level == 'Off':
                    level = '0'
                elif level == '1':
                    level = '1'
                elif level == '2':
                    level = '2'
                elif level == '3':
                    level = '4'
                elif level == '4':
                    level = '8'
                elif level == '5':
                    level = '7FFFFFFF'
        except KeyError:
            raise TestException(
                "Error: no Level element found in Parameter element ")

        try:
            nalsize = self.dict['NalSize']
            if nalsize == 'Off':
                nalsize = '0'
        except KeyError:
            raise TestException(
                "Error: no NalSize element found in Parameter element ")

        try:
            CIFrames = self.dict['CIFrames']
            if CIFrames == 'Off':
                CIFrames = '0'
        except KeyError:
            raise TestException(
                "Error: no CIFrames element found in Parameter element ")

        try:
            profile = self.dict['Profile']
            if encodeFormat == 7:
                if profile == 'Off':
                    profile = '0'
                elif profile == 'BP':
                    profile = '1'
                elif profile == 'MP':
                    profile = '2'
                elif profile == 'EP':
                    profile = '4'
                elif profile == 'HP':
                    profile = '8'
            elif encodeFormat == 3:
                if profile == 'Off':
                    profile = '0'
                elif profile == 'BP':
                    profile = '1'
            elif encodeFormat == 4:
                if profile == 'Off':
                    profile = '0'
                elif profile == 'SP':
                    profile = '1'
                elif profile == 'MP':
                    profile = '8'
        except KeyError:
            raise TestException(
                "Error: no Profile element found in Parameter element ")

        try:
            rcMode = self.dict['RcMode']
            if rcMode == 'VBR':
                rcMode = '1'
            elif rcMode == 'CBR':
                rcMode = '2'
            else:
                rcMode = '0'
        except KeyError:
            raise TestException(
                "Error: no RcMode element found in Parameter element ")
        try:
            VUIEnable = self.dict['VUIEnable']
            if VUIEnable == 'Off':
                VUIEnable = '0'
        except KeyError:
            raise TestException(
                "Error: no VUIEnable element found in Parameter element ")

        try:
            testtype = self.dict['TestType']
        except KeyError:
            raise TestException(
                "Error: no TestType element found in Parameter element ")

        try:
            referenceframe = self.dict['Referenceframe']
            if referenceframe == 'Off':
                referenceframe = '0'
        except KeyError:
            raise TestException(
                "Error: no Referenceframe element found in Parameter element ")

        try:
            testtimes = self.dict['TestTimes']
        except KeyError:
            raise TestException(
                "Error: no TestTimes element found in Parameter element ")

        if encodeFormat == 7:
            cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(
                encodeFormat
            ) + ' ' + level + ' ' + nalsize + ' ' + CIFrames + ' ' + profile + ' ' + rcMode + ' ' + VUIEnable + ' ' + testtype + ' ' + referenceframe + ' ' + testtimes
        else:
            cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(
                encodeFormat
            ) + ' ' + rcMode + ' ' + CIFrames + ' ' + profile + ' ' + level + ' 0 0 ' + testtype + ' ' + referenceframe + ' ' + testtimes

        print "Command:"
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            #download clip if it does not exist in self.Clip_Path + 'YUV/'
            stdout, stderr = self.cli.execute("ls " + input)
            flag = stdout.find("No such file or directory")
            if flag < 0:
                pass
            else:
                print '\nDownloading %s ......' % self.dict['InputFile']
                status, output = commands.getstatusoutput(
                    "wget --no-proxy " + conf.VIDEO_CLIP_DOWNLOAD_PATH +
                    self.dict['InputFile'])
                if status != 0:
                    print inred(
                        "Error: failed download " + self.dict['InputFile'] +
                        ", maybe the clip storing address is invalid!\n")
                else:
                    print ingreen(self.dict['InputFile'] +
                                  " downloaded successfully.\n")
                    print("Push " + self.dict['InputFile'] +
                          " into device ......")
                    self.cli.upload(self.dict['InputFile'],
                                    self.Clip_Path + 'YUV/')
                    os.system("rm -rf " + self.dict['InputFile'])

            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r')
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
            stdout = outfile.read()
            outfile.close()

            #obtain FPS
            str1 = stdout.find("Average frames per second") + 28
            str2 = stdout[str1:str1 + 50].find('\n')
            fps = stdout[str1:str1 + str2].replace('\n', '').replace(
                ' ', '').replace('\r', '')
            self.rt_dict.setdefault('FPS', fps)

            #obtain attrib[1].value
            stdout_text, stderr = self.cli.execute("head /data/1.* -n 20")
            flag = stdout_text.find("attrib_list[1].value") + 23
            if flag == 22:
                print inred("No attrib_list[1].value found in va_log.")
                attrib_value = "Off"
            else:
                attrib_value = stdout_text[flag:flag + 10]
            self.rt_dict.setdefault('AttribValue', attrib_value)
Beispiel #9
0
    def decode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item + "', please check the case profile.")
        try:
            if not cmp(self.dict['Format'], 'H264'):
                videoFormat = 1
            elif not cmp(self.dict['Format'], 'MPEG4'):
                videoFormat = 2
            elif not cmp(self.dict['Format'], 'H263'):
                videoFormat = 3
            elif not cmp(self.dict['Format'], 'VC1'):
                videoFormat = 4
            else:
                raise TestException("Error: Invalid text in Format element in case configuration file.")
        except KeyError:
            raise TestException("Error: no Format element found in Parameter element.")
        try:
            input = self.Clip_Path + self.dict['Format'] + '/' + self.dict['InputFile']
        except KeyError:
            raise TestException("Error: no InputFile element found in Parameter element ")
        try:
            output = get_result_path() + self.dict['OutputFile']
        except KeyError:
            raise TestException("Error: no OutputFile element found in Parameter element ")
        
        try:
            resolution = self.dict['Resolution'] 
        except KeyError:
            raise TestException("Error: no Resolution element found in Parameter element ")
        try:
            maxwidth = resolution.split('x')[0]
            maxheight = resolution.split('x')[1]
        except IndexError:
            raise TestException("Error: the text in Resolution element must be in the format of NUMBERxNUMBER ")

        try:
            decodeSpeed = self.dict['DecodeSpeed'] 
        except KeyError:
            raise TestException("Error: no DecodeSpeed element found in Parameter element ")
        
        cmd = "VideoDecTest " + input + ' ' + output + ' ' + str(videoFormat) + ' ' + str(maxwidth) + ' ' + str(maxheight) + ' ' + decodeSpeed 
        print "Command:"
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)
        
        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"
        
        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device        
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r') 
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
            stdout = outfile.read()
            outfile.close()
            
            #obtain FPS
            str1 = stdout.find("(seconds)") + 12
            str2 = stdout[str1: str1+30].find('\n')
            fps = stdout[str1:str1+str2].replace('\n', '').replace(' ', '').replace('\r', '')
            self.rt_dict.setdefault('FPS', fps)
            
            #obtain YV12_CRC
            YV12_CRC = stdout.split('\n')[-2].replace(' ', '').replace('\r', '')
            self.rt_dict.setdefault('YV12_CRC', YV12_CRC)
            
            #download output file
            #self.cli.download(get_result_path() + self.dict['OutputFile'], path.result_path + '/' + self.caseFolderName + '/')
            
            #delete files
            self.cli.execute("rm " + get_result_path() + self.dict['OutputFile']) 
Beispiel #10
0
 def audioDecode(self):
     for item in self.dict:
         if self.dict[item] == None:
             raise TestException("Error: No text in element '" + item + "', please check the case profile.")
     try:
         if self.dict['Format'] in ['mp3', 'amr', 'awb', 'aac']:
             pass
         else:
             print inred("Error: Invalid text in Format element in case configuration file. You may not find the clip.")
         format = self.dict['Format']
     except KeyError:
         raise TestException("Error: no Format element found in Parameter element.")
     try:
         input = self.Clip_Path + self.dict['Format'] + '/' + self.dict['InputFile']
     except KeyError:
         raise TestException("Error: no InputFile element found in Parameter element ")
     try:
         output = get_result_path() + self.dict['OutputFile']
     except KeyError:
         raise TestException("Error: no OutputFile element found in Parameter element ")
     try:
         playback = self.dict['Playback'] 
         if playback == 'Off':
             playback = '0'
     except KeyError:
         raise TestException("Error: no Playback element found in Parameter element ")
     
     typeString = input.split('.')[-1]
     if typeString == 'mp3':
         type = '0'
     elif typeString == 'amr':
         type = '1'
     elif typeString == 'awb':
         type = '2'
     elif typeString == 'aac':
         type = '3'
     else:
         print inred("Unknown input file extension name, type set to 0.")
         type = '0'
     
     cmd = "AudioDecTest " + input + ' ' + output + ' ' + type + ' ' + playback
     print "Command:"
     print cmd
     print ""
     self.rt_dict.setdefault('cmd', cmd)
     
     if self.stepType == 0 or self.stepType == 10:
         if self.stepType == 10:
             return "noResult"
     
     if self.stepType == 0 or self.stepType == 20:
         #execute in remote device 
         '''
         print "Execute Output: "
         stdout,stderr = self.cli.execute(cmd)
         if stdout == '':
             raise TestException("Error: No content in log. You may use a wrong test tool or wrong platform ")
         outfile = open('log' + str(self.step_id), 'w+')
         outfile.writelines(stderr)
         outfile.writelines(stdout)
         outfile.close()
         '''
         
         print "Execute Output: \n"
         self.cli.execute_test(cmd, self.step_id)
         try:
             outfile = open('log' + str(self.step_id), 'r') 
         except IOError, e:
             print inred("Error: cannot generat log.")
             os.system("touch log" + str(self.step_id)) 
         stdout = outfile.read()
         outfile.close()
         
         #download output file
         self.cli.download(get_result_path() + self.dict['OutputFile'], path.result_path + '/' + self.caseFolderName + '/')
         
         #obtain MD5 value
         status, output = commands.getstatusoutput("md5sum " + path.result_path + '/' + self.caseFolderName + '/' + self.dict['OutputFile'])
         if status == 0:
             md5 = output.split(' ')[0]
         else:
             md5 = ''
             print inred("cannot obtain MD5 value because no result clip generated or no md5sum command!")
             
         #delete result clip
         status, output = commands.getstatusoutput("rm -rf " + path.result_path + '/' + self.caseFolderName + '/' + self.dict['OutputFile'])
         self.cli.execute("rm " + get_result_path() + self.dict['OutputFile'])
                         
         self.rt_dict.setdefault('MD5', md5)  
Beispiel #11
0
 def encode(self):
     
     print "Command for va_log detection:"
             
     #enable va_log
     stdout,stderr = self.cli.execute("echo \\\"LIBVA_TRACE=/data/1\\\" > /etc/libva.conf")
     
     #delete original 
     stdout,stderr = self.cli.execute("rm -rf /data/1.*")
     
     print ""
     
     for item in self.dict:
         if self.dict[item] == None:
             raise TestException("Error: No text in element '" + item + "', please check the case profile.")
     
     try:
         if not cmp(self.dict['Format'], 'H264'):
             encodeFormat = 7
         elif not cmp(self.dict['Format'], 'MPEG4'):
             encodeFormat = 4
         elif not cmp(self.dict['Format'], 'H263'):
             encodeFormat = 3
         else:
             raise TestException("Error: Invalid text in Format element in case configuration file.")
     except KeyError:
         raise TestException("Error: no Format element found in Parameter element.")
     
     try:
         input = self.Clip_Path + "YUV/" + self.dict['InputFile']
     except KeyError:
         raise TestException("Error: no InputFile element found in Parameter element ")
     try:
         output = get_result_path() + self.dict['OutputFile']
     except KeyError:
         raise TestException("Error: no OutputFile element found in Parameter element ")
     
     try:
         resolution = self.dict['Resolution']
     except KeyError:
         raise TestException("Error: no Resolution element found in Parameter element ")
     try:
         width = resolution.split('x')[0]
         height = resolution.split('x')[1]
     except IndexError:
         raise TestException("Error: the text in Resolution element must be in the format of NUMBERxNUMBER ")
      
     try:
         speed = self.dict['Speed']
         if speed == 'Off':
             speed = '0'
     except KeyError:
         raise TestException("Error: no Speed element found in Parameter element ") 
     
     try:
         bitRate = self.dict['BitRate']
         if bitRate == 'Off':
             bitRate = '0'
     except KeyError:
         raise TestException("Error: no BitRate element found in Parameter element ")
     
     try:
         framerate = self.dict['Framerate']
         if framerate == 'Off':
             framerate = '15'
     except KeyError:
         raise TestException("Error: no Framerate element found in Parameter element ")
     
     try:
         level = self.dict['Level'].replace('L', '')
         if encodeFormat == 7:
             if level == 'Off':
                 level = '0'
             elif level == '1':
                 level = '1'
             elif level == '1b':
                 level = '2' 
             elif level == '1.1':
                 level = '4' 
             elif level == '1.2':
                 level = '8'  
             elif level == '1.3':
                 level = '10'
             elif level == '2.0':
                 level = '20'
             elif level == '2.1':
                 level = '40'
             elif level == '2.2':
                 level = '80'
             elif level == '3.0':
                 level = '100'
             elif level == '3.1':
                 level = '200'
             elif level == '3.2':
                 level = '400'
             elif level == '4.0':
                 level = '800'
             elif level == '4.1':
                 level = '1000'
             elif level == '4.2':
                 level = '2000'
             elif level == '5.0':
                 level = '4000'
             elif level == '5.1':
                 level = '8000'
         elif encodeFormat == 3:
             if level == 'Off':
                 level = '0'
             elif level == '10':
                 level = '1'
             elif level == '20':
                 level = '2'
             elif level == '30':
                 level = '4'
             elif level == '40':
                 level = '8'
             elif level == '50':
                 level = '10'
             elif level == '60':
                 level = '20'
             elif level == '70':
                 level = '40'
         elif encodeFormat == 4:
             if level == 'Off':
                 level = '0'
             elif level == '1':
                 level = '1'
             elif level == '2':
                 level = '2'
             elif level == '3':
                 level = '4'
             elif level == '4':
                 level = '8'
             elif level == '5':
                 level = '7FFFFFFF'
     except KeyError:
         raise TestException("Error: no Level element found in Parameter element ")
     
     try:
         nalsize = self.dict['NalSize']
         if nalsize == 'Off':
             nalsize = '0'
     except KeyError:
         raise TestException("Error: no NalSize element found in Parameter element ")
     
     try:
         CIFrames = self.dict['CIFrames']
         if CIFrames == 'Off':
             CIFrames = '0'
     except KeyError:
         raise TestException("Error: no CIFrames element found in Parameter element ")
     
     try:
         profile = self.dict['Profile']
         if encodeFormat == 7:
             if profile == 'Off':
                 profile = '0'
             elif profile == 'BP':
                 profile = '1'
             elif profile == 'MP':
                 profile = '2' 
             elif profile == 'EP':
                 profile = '4' 
             elif profile == 'HP':
                 profile = '8'  
         elif encodeFormat == 3:
             if profile == 'Off':
                 profile = '0'
             elif profile == 'BP':
                 profile = '1'
         elif encodeFormat == 4:
             if profile == 'Off':
                 profile = '0'
             elif profile == 'SP':
                 profile = '1'
             elif profile == 'MP':
                 profile = '8'
     except KeyError:
         raise TestException("Error: no Profile element found in Parameter element ")
     
     try:
         rcMode = self.dict['RcMode']
         if rcMode == 'VBR':
             rcMode = '1'
         elif rcMode == 'CBR':
             rcMode = '2'
         else:
             rcMode = '0'
     except KeyError:
         raise TestException("Error: no RcMode element found in Parameter element ")
     try:
         VUIEnable = self.dict['VUIEnable']
         if VUIEnable == 'Off':
             VUIEnable = '0'
     except KeyError:
         raise TestException("Error: no VUIEnable element found in Parameter element ")
     
     try:
         testtype = self.dict['TestType']
     except KeyError:
         raise TestException("Error: no TestType element found in Parameter element ")
     
     try:
         referenceframe = self.dict['Referenceframe']
         if referenceframe == 'Off':
             referenceframe = '0'
     except KeyError:
         raise TestException("Error: no Referenceframe element found in Parameter element ")
     
     try:
         testtimes = self.dict['TestTimes']
     except KeyError:
         raise TestException("Error: no TestTimes element found in Parameter element ")
     
     if encodeFormat == 7:
         cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(encodeFormat) + ' ' + level + ' ' + nalsize + ' ' + CIFrames + ' ' + profile + ' ' + rcMode + ' ' + VUIEnable + ' ' + testtype + ' ' + referenceframe + ' ' + testtimes 
     else:
         cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(encodeFormat) + ' ' + rcMode + ' ' + CIFrames + ' ' + profile + ' ' + level + ' 0 0 ' + testtype + ' ' + referenceframe + ' ' + testtimes
    
     print "Command:"
     print cmd
     print ""
     self.rt_dict.setdefault('cmd', cmd)
     
     if self.stepType == 0 or self.stepType == 10:        
         #download clip if it does not exist in self.Clip_Path + 'YUV/'
         stdout, stderr = self.cli.execute("ls " + input)
         flag = stdout.find("No such file or directory")
         if flag < 0:
             pass
         else:
             print '\nDownloading %s ......' %self.dict['InputFile']
             status, output = commands.getstatusoutput("wget --no-proxy " + conf.VIDEO_CLIP_DOWNLOAD_PATH + self.dict['InputFile'])
             if status != 0:
                 print inred("Error: failed download " + self.dict['InputFile'] + ", maybe the clip storing address is invalid!\n")
             else:
                 print ingreen(self.dict['InputFile'] + " downloaded successfully.\n")
                 print ("Push " + self.dict['InputFile'] + " into device ......")
                 self.cli.upload(self.dict['InputFile'], self.Clip_Path + 'YUV/')
                 os.system("rm -rf " + self.dict['InputFile'])
             
         if self.stepType == 10:
             return "noResult"
     
     if self.stepType == 0 or self.stepType == 20:
         #execute in remote device
         print "Execute Output: \n"
         self.cli.execute_test(cmd, self.step_id)
         try:
             outfile = open('log' + str(self.step_id), 'r') 
         except IOError, e:
             print inred("Error: cannot generat log.")
             os.system("touch log" + str(self.step_id))
         stdout = outfile.read()
         outfile.close()
         
         #obtain FPS
         str1 = stdout.find("Average frames per second") + 28
         str2 = stdout[str1: str1+50].find('\n')
         fps = stdout[str1:str1+str2].replace('\n', '').replace(' ', '').replace('\r', '')
         self.rt_dict.setdefault('FPS', fps)
         
         #obtain attrib[1].value
         stdout_text,stderr = self.cli.execute("head /data/1.* -n 20")
         flag = stdout_text.find("attrib_list[1].value") + 23
         if flag == 22 :
             print inred("No attrib_list[1].value found in va_log.")
             attrib_value = "Off"
         else:
             attrib_value = stdout_text[flag : flag+10]                
         self.rt_dict.setdefault('AttribValue', attrib_value)
Beispiel #12
0
        self.cli = accessor(self.dict1)
        self.Clip_Path = get_clip_path()

    
    def jpeg_decode(self):
        try:
            inputFile = self.dict['InputFile'].strip()
        except KeyError, e:
            raise TestException("Error: no InputFile element found in Parameter element")
        try:
            OutputFile = self.dict['OutputFile'].strip()
        except KeyError, e:
            raise TestException("Error: no OutputFile element found in Parameter element")
        prefix = get_clip_path() + 'Image/'
        
        result_path = get_result_path() + 'JPEG_Decode/'
        mkdir_cmd = 'mkdir -p ' + result_path
        self.cli.execute_test(mkdir_cmd, self.step_id)
        cmd = 'djpeg -bmp ' + prefix + inputFile + ' ' + result_path + OutputFile
        self.cli.execute_test(cmd, self.step_id)
        stdout, stderr = self.cli.execute_test('cksum ' + result_path + OutputFile, self.step_id)
        bmp_crc = stdout.split('/')[0].strip()
        self.rt_dict.setdefault('Image_CRC', bmp_crc)
        self.rt_dict.setdefault('cmd', cmd)
            
        if self.stepType == 0 or self.stepType == 30:
            if self.stepType == 30:
                return "noResult"
            
        return self.rt_dict
    
Beispiel #13
0
    def decode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")
        try:
            if not cmp(self.dict['Format'], 'H263'):
                vld = 'mpeg4vld'
            else:
                vld = self.dict['Format'].lower() + 'vld'
        except KeyError:
            raise TestException(
                "Error: no Format element found in Parameter element ")
        try:
            inp = self.Clip_Path + self.dict['Format'] + '/' + self.dict[
                'InputFile']
        except KeyError:
            raise TestException(
                "Error: no InputFile element found in Parameter element ")
        outp = ''
        if self.dict.get('CRC') is None or not cmp(self.dict['CRC'], 'Off'):
            crcp = ''
        else:
            crcp = ' -c'

        if self.dict.get('Window') is None or not cmp(self.dict['Window'],
                                                      'Off'):
            wdp = ''
        else:
            wdp = ' -n'

        if self.dict.get('FPS') is None or not cmp(self.dict['FPS'], 'Off'):
            fpsp = ''
        else:
            fpsp = ' -r ' + self.dict['FPS']

        if self.dict.get('Rotation') is None or not cmp(
                self.dict['Rotation'], 'Off'):
            rp = ''
        else:
            rp = ' -z ' + self.dict['Rotation']

        if self.dict.get('Headerlog') is None or not cmp(
                self.dict['Headerlog'], 'Off'):
            hp = ''
        else:
            hp = ' -headerlog ' + get_result_path() + self.dict['Headerlog']

        if self.dict.get('FullScreen') is None or not cmp(
                self.dict['FullScreen'], 'Off'):
            fsp = ''
        else:
            fsp = ' -k'

        if self.dict.get('Display') is None or not cmp(self.dict['Display'],
                                                       'overlay'):
            dp = ''
        else:
            dp = 'PSB_VIDEO_CTEXTURE=1 '

        cmd = dp + self.prefix + vld + ' -x -i ' + inp + outp + crcp + wdp + fpsp + rp + hp + fsp
        print cmd
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r')
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
                outfile = open('log' + str(self.step_id), 'r')
            stdout = outfile.read()
            outfile.close()

            outfile = 'log' + str(self.step_id)
            dp = DataParser()
            try:
                crc_value = self.dict['CRC']
            except KeyError, e:
                raise TestException("Error: no CRC element found ")
Beispiel #14
0
    def encode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")

        #obtain outputfile
        output = get_result_path() + self.dict['OutputFile']

        # check if output exist
        cmd = 'test -d ' + get_result_path(
        ) + " && echo 'directory exists' || echo 'directory not found'"
        stdout, stderr = self.cli.execute(cmd)
        print stdout, stderr
        if stdout.strip() == 'directory not found':
            cmd = 'mkdir -p ' + get_result_path()
            self.cli.execute(cmd)
        #obtain bitrate
        if not cmp(self.dict['VideoBitrate'], 'Off'):
            bitrate = ''
        else:
            bitrate = "--bitrate " + self.dict['VideoBitrate']

        #obtain framerate
        if not cmp(self.dict['Framerate'], 'Off'):
            framerate = ''
        else:
            framerate = "--framerate " + self.dict['Framerate']

        #obtain audiocodec
        if not cmp(self.dict['Audiocodec'].replace(' ', ''), 'amr'):
            ac = "--audiocodec amr"
        elif not cmp(self.dict['Audiocodec'].replace(' ', ''), 'awb'):
            ac = "--audiocodec awb"
        elif not cmp(self.dict['Audiocodec'].replace(' ', ''), 'aac'):
            ac = "--audiocodec aac"
        else:
            ac = '--audiocodec aac'

        #obtain videocodec
        if not cmp(self.dict['Videocodec'], 'h263'):
            vc = "--videocodec h263"
        elif not cmp(self.dict['Videocodec'], 'h264'):
            vc = "--videocodec h264"
        elif not cmp(self.dict['Videocodec'], 'mpeg4'):
            vc = "--videocodec mpeg4"
        else:
            vc = ''

        #obtain format
        if not cmp(self.dict['Format'], '3gp'):
            format = "--format 3gp"
        elif not cmp(self.dict['Format'], 'mp4'):
            format = "--format mp4"
        else:
            format = ''

        #obtain resolution
        if not cmp(self.dict['Resolution'], 'Off'):
            resolution = ''
        else:
            resolution = "--resolution " + self.dict['Resolution']

        #obtain duration
        if not cmp(self.dict['Duration'], 'Off'):
            duration = ''
        else:
            duration = "--duration " + self.dict['Duration']

        #obtain mode
        if not cmp(self.dict['Mode'], 'av'):
            mode = "--mode av"
        elif not cmp(self.dict['Mode'], 'vo'):
            mode = "--mode vo"
        elif not cmp(self.dict['Mode'], 'ao'):
            mode = "--mode ao"
        else:
            mode = ''

        #obtain audio bitrate
        if not cmp(self.dict['AudioBitrate'], 'Off'):
            audiobitrate = ''
        else:
            audiobitrate = "--audiobitrate " + self.dict['AudioBitrate']

        #obtain audio sampling rate
        if not cmp(self.dict['AudioSampleRate'], 'Off'):
            audiosamplerate = ''
        else:
            audiosamplerate = "--samplingrate " + self.dict[
                'AudioSampleRate'] + " --EnableChSampling"

        #generate cmd
        cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiobitrate + ' ' + audiosamplerate
        #        cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiosamplerate
        print ""
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:

            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r')
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
            stdout = outfile.read()
            outfile.close()

            #pull result clip to host
            os.system("mkdir -p " + path.resultClip_path + '/' +
                      self.caseFolderName + '/')
            self.cli.download(
                output, path.resultClip_path + '/' + self.caseFolderName + '/')

            #obtain mediainfo result from result clip
            mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' +
                                            self.caseFolderName + '/' +
                                            self.dict['OutputFile'])
            for eachItem in mediainfo_dict:
                self.rt_dict.setdefault(eachItem, mediainfo_dict[eachItem])
Beispiel #15
0
    def audioDecode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")
        try:
            if self.dict['Format'] in ['mp3', 'amr', 'awb', 'aac']:
                pass
            else:
                print inred(
                    "Error: Invalid text in Format element in case configuration file. You may not find the clip."
                )
            format = self.dict['Format']
        except KeyError:
            raise TestException(
                "Error: no Format element found in Parameter element.")
        try:
            input = self.Clip_Path + self.dict['Format'] + '/' + self.dict[
                'InputFile']
        except KeyError:
            raise TestException(
                "Error: no InputFile element found in Parameter element ")
        try:
            output = get_result_path() + self.dict['OutputFile']
        except KeyError:
            raise TestException(
                "Error: no OutputFile element found in Parameter element ")
        try:
            playback = self.dict['Playback']
            if playback == 'Off':
                playback = '0'
        except KeyError:
            raise TestException(
                "Error: no Playback element found in Parameter element ")

        typeString = input.split('.')[-1]
        if typeString == 'mp3':
            type = '0'
        elif typeString == 'amr':
            type = '1'
        elif typeString == 'awb':
            type = '2'
        elif typeString == 'aac':
            type = '3'
        else:
            print inred("Unknown input file extension name, type set to 0.")
            type = '0'

        cmd = "AudioDecTest " + input + ' ' + output + ' ' + type + ' ' + playback
        print "Command:"
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device
            '''
            print "Execute Output: "
            stdout,stderr = self.cli.execute(cmd)
            if stdout == '':
                raise TestException("Error: No content in log. You may use a wrong test tool or wrong platform ")
            outfile = open('log' + str(self.step_id), 'w+')
            outfile.writelines(stderr)
            outfile.writelines(stdout)
            outfile.close()
            '''

            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r')
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
            stdout = outfile.read()
            outfile.close()

            #download output file
            self.cli.download(
                get_result_path() + self.dict['OutputFile'],
                path.result_path + '/' + self.caseFolderName + '/')

            #obtain MD5 value
            status, output = commands.getstatusoutput("md5sum " +
                                                      path.result_path + '/' +
                                                      self.caseFolderName +
                                                      '/' +
                                                      self.dict['OutputFile'])
            if status == 0:
                md5 = output.split(' ')[0]
            else:
                md5 = ''
                print inred(
                    "cannot obtain MD5 value because no result clip generated or no md5sum command!"
                )

            #delete result clip
            status, output = commands.getstatusoutput("rm -rf " +
                                                      path.result_path + '/' +
                                                      self.caseFolderName +
                                                      '/' +
                                                      self.dict['OutputFile'])
            self.cli.execute("rm " + get_result_path() +
                             self.dict['OutputFile'])

            self.rt_dict.setdefault('MD5', md5)
Beispiel #16
0
    def encode(self):
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item + "', please check the case profile.")
        
        #obtain outputfile
        output = get_result_path() + self.dict['OutputFile']
        
        # check if output exist
        cmd = 'test -d ' + get_result_path() + " && echo 'directory exists' || echo 'directory not found'"
        stdout, stderr = self.cli.execute(cmd)
        print stdout, stderr
        if stdout.strip() == 'directory not found':
            cmd = 'mkdir -p ' + get_result_path()
            self.cli.execute(cmd)
        #obtain bitrate
        if not cmp(self.dict['VideoBitrate'], 'Off'):
            bitrate = '' 
        else:  
            bitrate = "--bitrate " + self.dict['VideoBitrate']
            
        #obtain framerate
        if not cmp(self.dict['Framerate'], 'Off'):
            framerate = '' 
        else:  
            framerate = "--framerate " + self.dict['Framerate']
            
        #obtain audiocodec
        if not cmp(self.dict['Audiocodec'].replace(' ',''), 'amr'):
            ac = "--audiocodec amr"
        elif not cmp(self.dict['Audiocodec'].replace(' ',''), 'awb'):
            ac = "--audiocodec awb"
        elif not cmp(self.dict['Audiocodec'].replace(' ',''), 'aac'):
            ac = "--audiocodec aac"
        else:
            ac = '--audiocodec aac'
            
        #obtain videocodec
        if not cmp(self.dict['Videocodec'], 'h263'):
            vc = "--videocodec h263"
        elif not cmp(self.dict['Videocodec'], 'h264'):
            vc = "--videocodec h264"
        elif not cmp(self.dict['Videocodec'], 'mpeg4'):
            vc = "--videocodec mpeg4"
        else:
            vc = ''
            
        #obtain format
        if not cmp(self.dict['Format'], '3gp'):
            format = "--format 3gp"
        elif not cmp(self.dict['Format'], 'mp4'):
            format = "--format mp4"
        else:
            format = ''
            
        #obtain resolution
        if not cmp(self.dict['Resolution'], 'Off'):
            resolution = '' 
        else:  
            resolution = "--resolution " + self.dict['Resolution']
            
        #obtain duration
        if not cmp(self.dict['Duration'], 'Off'):
            duration = '' 
        else:  
            duration = "--duration " + self.dict['Duration']
            
        #obtain mode
        if not cmp(self.dict['Mode'], 'av'):
            mode = "--mode av"
        elif not cmp(self.dict['Mode'], 'vo'):
            mode = "--mode vo"
        elif not cmp(self.dict['Mode'], 'ao'):
            mode = "--mode ao"
        else:
            mode = ''

        #obtain audio bitrate
        if not cmp(self.dict['AudioBitrate'], 'Off'):
            audiobitrate = ''
        else:
            audiobitrate = "--audiobitrate " + self.dict['AudioBitrate']

        #obtain audio sampling rate
        if not cmp(self.dict['AudioSampleRate'], 'Off'):
            audiosamplerate = ''
        else:
            audiosamplerate = "--samplingrate " + self.dict['AudioSampleRate'] + " --EnableChSampling"
            
        #generate cmd
        cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiobitrate + ' ' + audiosamplerate
#        cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiosamplerate
        print ""
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)
        
        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"
        
        if self.stepType == 0 or self.stepType == 20:
            
            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r') 
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id)) 
            stdout = outfile.read()
            outfile.close()
            
            #pull result clip to host
            os.system("mkdir -p " + path.resultClip_path + '/' + self.caseFolderName + '/')
            self.cli.download(output, path.resultClip_path + '/' + self.caseFolderName + '/')
            
            #obtain mediainfo result from result clip
            mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' + self.caseFolderName + '/' + self.dict['OutputFile'])
            for eachItem in mediainfo_dict:
                self.rt_dict.setdefault(eachItem, mediainfo_dict[eachItem])
Beispiel #17
0
            else:
                set = 'MFLD=1 '
        except KeyError, e:
            raise TestException(
                "Error: no Platform element found in device's profile ")

        if self.dict.get('Format') is None or self.dict.get(
                'Resolution') is None or self.dict.get('IntraPeriod') is None:
            self.tc_dict.setdefault('rt', 'F')
            return self.tc_dict

        if self.dict.get('RecYUV') is None or not cmp(self.dict['RecYUV'],
                                                      'Off'):
            recp = ''
        else:
            recp = ' -recyuv ' + get_result_path() + self.dict['RecYUV']

        if self.dict['IntraPeriod'] is None or not cmp(
                self.dict['IntraPeriod'], 'Off'):
            itpp = ''
        else:
            itpp = ' -intracnt ' + self.dict['IntraPeriod']

        if self.dict['IDRPeriod'] is None or not cmp(self.dict['IDRPeriod'],
                                                     'Off'):
            idrp = ''
        else:
            idrp = ' -idrcnt ' + self.dict['IDRPeriod']

        if self.dict['QP'] is None or not cmp(self.dict['QP'], 'Off'):
            qpp = ''