Example #1
0
    def run (self, manager):

        if self.alias not in manager.aliases2ports:
            print "free_buffer: Wrong alias specified"
            sys.exit(1)

        if self.pid not in manager.aliases2ports[self.alias]:
            print "free_buffer: Wrong port index specified"
            sys.exit(1)

        port = manager.aliases2ports[self.alias][self.pid]

        if port.allocation_count == 0:
            print "free_buffer: Nothing to free "
            sys.exit(1)

        config = get_config()
        handle = config.handles[self.alias]

        if self.howmany.lower() == "all":
            self.howmany = port.nBufferCountActual
        else:
            self.howmany = int(self.howmany)

        if self.howmany == 0:
            print "free_buffer: Need to free at least 1 buffer"
            sys.exit(1)

        if port.allocation_count < self.howmany:
            print "free_buffer: Too many buffers to be freed"
            sys.exit(1)

        config = get_config()
        handle = config.handles[self.alias]

        libc = CDLL('libc.so.6')
        for i in range(port.deallocation_count,
                       port.deallocation_count + self.howmany):


            omxerror = OMX_FreeBuffer(handle, int(self.pid), port.headers[i])

            # NOTE: We simply don't bother deleting the buffers that we would
            # have allocated if we were using OMX_UseBuffer

        port.allocation_count   -= self.howmany
        port.deallocation_count += self.howmany

        if port.allocation_count == 0:
            del port.headers[:]
Example #2
0
    def run (self, manager):

        if self.alias not in manager.aliases2ports:
            print "free_buffer: Wrong alias specified"
            sys.exit(1)

        if self.pid not in manager.aliases2ports[self.alias]:
            print "free_buffer: Wrong port index specified"
            sys.exit(1)

        port = manager.aliases2ports[self.alias][self.pid]

        if port.allocation_count == 0:
            print "free_buffer: Nothing to free "
            sys.exit(1)

        config = get_config()
        handle = config.handles[self.alias]

        if self.howmany.lower() == "all":
            self.howmany = port.nBufferCountActual
        else:
            self.howmany = int(self.howmany)

        if self.howmany == 0:
            print "free_buffer: Need to free at least 1 buffer"
            sys.exit(1)

        if port.allocation_count < self.howmany:
            print "free_buffer: Too many buffers to be freed"
            sys.exit(1)

        config = get_config()
        handle = config.handles[self.alias]

        libc = CDLL('libc.so.6')
        for i in range(port.deallocation_count,
                       port.deallocation_count + self.howmany):


            omxerror = OMX_FreeBuffer(handle, int(self.pid), port.headers[i])

            # NOTE: We simply don't bother deleting the buffers that we would
            # have allocated if we were using OMX_UseBuffer

        port.allocation_count   -= self.howmany
        port.deallocation_count += self.howmany

        if port.allocation_count == 0:
            del port.headers[:]
Example #3
0
def my_evt_hdler(a, b, c, d, e, f):
    evtstr = get_string_from_il_enum(c, "OMX_Event")
    config = get_config()
    name = str()
    name = config.cnames2[a]

    if (c == OMX_EventCmdComplete):
        config.cmdevents[a].set()
        cmdstr = get_string_from_il_enum(d, "OMX_Command")
        if (d == OMX_CommandStateSet):
            statestr = get_string_from_il_enum(e, "OMX_State")
            log_line ()
            log_api("EventHandler '%s'" % (name))
            log_line ()
            log_line ("Received -> '%s' '%s' '%s'" \
                            % (evtstr, cmdstr, statestr), 1)
    elif (c == OMX_EventBufferFlag):
        config.eosevents[a].set()
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' Port '%d'" \
                        % (evtstr, d), 1)
    elif (c == OMX_EventPortSettingsChanged):
        config.settings_changed_events[a].set()
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' Port '%d'" \
                        % (evtstr, d), 1)

    return 0
Example #4
0
 def run(self):
     config = get_config()
     try:
         for dir in os.listdir(config.tagsdir):
             print dir
     except OSError:
         print "No tags installed"
Example #5
0
def my_ebd_cback(a, b, c):
    config = get_config()
    name = config.cnames2[a]
    alias = config.aliases[name]
    handle = config.handles[alias]
    config.base_profile_mgr.empty_buffer_done(handle, alias, c)
    return 0
Example #6
0
    def run(self, quiet=False, output=None):
        if not self.runner:
            raise RuntimeError("no test runner defined for '%s'" %
                               self.suitename)
        config = get_config()
        uuid = str(uuid1())
        suitesdir = os.path.join(config.suitesdir, self.suitename)
        resultname = ""
        if not output:
            # Generate a unique name for the dir where the suite's log files
            # will be stored
            resultname = (self.suitename +
                          str(time.mktime(datetime.utcnow().timetuple())))
            self.resultsdir = os.path.join(config.resultsdir, resultname)
            os.makedirs(self.resultsdir)
        else:
            self.resultsdir = output
            if not os.path.exists(self.resultsdir):
                os.makedirs(self.resultsdir)

        result = 0
        try:
            os.chdir(suitesdir)
            scriptpath = glob.glob(os.path.join(suitesdir, '*.xml'))[0]
            result = self.runner.run(scriptpath, self.resultsdir, quiet=quiet)
            self._savetestdata(uuid)
        finally:
            os.chdir(self.origdir)
        return result
Example #7
0
def my_fbd_cback(a, b, c):
    config = get_config()
    name   = config.cnames2[a]
    alias  = config.aliases[name]
    handle = config.handles[alias]
    config.base_profile_mgr.fill_buffer_done(handle,alias,c)
    return 0
Example #8
0
 def run(self):
     config = get_config()
     try:
         for dir in os.listdir(config.tagsdir):
             print dir
     except OSError:
         print "No tags installed"
Example #9
0
    def run(self, quiet=False, output=None):
        if not self.runner:
            raise RuntimeError("no test runner defined for '%s'" %
                                self.suitename)
        config = get_config()
        uuid = str(uuid1())
        suitesdir = os.path.join(config.suitesdir, self.suitename)
        resultname = ""
        if not output:
            # Generate a unique name for the dir where the suite's log files
            # will be stored
            resultname = (self.suitename +
                          str(time.mktime(datetime.utcnow().timetuple())))
            self.resultsdir = os.path.join(config.resultsdir, resultname)
            os.makedirs(self.resultsdir)
        else:
            self.resultsdir = output
            if not os.path.exists (self.resultsdir):
                os.makedirs(self.resultsdir)

        result = 0
        try:
            os.chdir(suitesdir)
            scriptpath = glob.glob( os.path.join(suitesdir, '*.xml') )[0]
            result = self.runner.run(scriptpath,
                            self.resultsdir, quiet=quiet)
            self._savetestdata(uuid)
        finally:
            os.chdir(self.origdir)
        return result
Example #10
0
    def install(self):
        """Install the test tag.

        This creates an install directory under the user's XDG_DATA_HOME
        directory to mark that the tag is installed.  The installer's
        install() method is then called from this directory to complete any
        test specific install that may be needed.
        """
        #if not self.installer:
        #    raise RuntimeError("no installer defined for '%s'" %
        #                        self.tagsdir)

        config = get_config()
        tagsdir = os.path.join(config.tagsdir, self.tagsdir)
        if os.path.exists(tagsdir):
            raise RuntimeError("%s is already installed" % self.tagsdir)
        os.makedirs(tagsdir)
        os.chdir(tagsdir)
        #try:
        #    self.installer.install()
        #except Exception as strerror:
        #    self.uninstall()
        #    raise
        #finally:
        os.chdir(self.origdir)
Example #11
0
    def install(self):
        """Install the test tag.

        This creates an install directory under the user's XDG_DATA_HOME
        directory to mark that the tag is installed.  The installer's
        install() method is then called from this directory to complete any
        test specific install that may be needed.
        """
        #if not self.installer:
        #    raise RuntimeError("no installer defined for '%s'" %
        #                        self.tagsdir)

        config = get_config()
        tagsdir = os.path.join(config.tagsdir, self.tagsdir)
        if os.path.exists(tagsdir):
            raise RuntimeError("%s is already installed" % self.tagsdir)
        os.makedirs(tagsdir)
        os.chdir(tagsdir)
        #try:
        #    self.installer.install()
        #except Exception as strerror:
        #    self.uninstall()
        #    raise
        #finally:
        os.chdir(self.origdir)
Example #12
0
 def parse(self, resultname):
     if not self.parser:
         raise RuntimeError("no test parser defined for '%s'" %
                            self.suitename)
     config = get_config()
     resultsdir = os.path.join(config.resultsdir, resultname)
     os.chdir(resultsdir)
     self.parser.parse()
     os.chdir(self.origdir)
Example #13
0
 def parse(self, resultname):
     if not self.parser:
         raise RuntimeError("no test parser defined for '%s'" %
                             self.suitename)
     config = get_config()
     resultsdir = os.path.join(config.resultsdir, resultname)
     os.chdir(resultsdir)
     self.parser.parse()
     os.chdir(self.origdir)
Example #14
0
def run_suite(scriptpath):

    tree = et()
    tree.parse(scriptpath)
    titer = tree.iter()

    config = get_config()

    suites = []
    cases = []
    errors = dict()
    last_tag = dict()
    case = ""
    for elem in titer:

        if elem.tag == "Suite":
            continue

        if elem.tag == "Case":
            case  = elem.get('name')
            log_line ("Use Case : '%s'"  % case)
            cases.append(case)
            errors[case] = 0
            result = 0
            continue

        if result == 0:
            tag_func = get_tag(elem.tag)
            if not tag_func:
                log_line ("Tag '%s' not found. Exiting."  % elem.tag)
                sys.exit(1)

            result = tag_func.run(elem, config)
            if result != 0:
                log_result (elem.tag, get_string_from_il_enum(result, "OMX_Error"))
                errors[case] = result
            last_tag[case] = elem.tag

    if result != 0:
        config.base_profile_mgr.stop()

    log_line()
    log_line()
    log_line("-------------------------------------------------------------------")
    msg = "SUITE EXECUTION SUMMARY : " + str(len(cases)) + " test cases executed"
    log_result (msg, get_string_from_il_enum(result, "OMX_Error"))
    last_error = 0
    for case in cases:
        msg = "CASE : " + case + " (last tag was '" + last_tag[case] + "')"
        log_result (msg, get_string_from_il_enum(errors[case], "OMX_Error"))
        if errors[case] != 0:
            last_error = errors[case]
    log_line()
    log_line("-------------------------------------------------------------------")
    log_line()

    return last_error
Example #15
0
 def _installscript(self):
     if not self.scriptpath:
         return 0
     config = get_config()
     suitesdir = os.path.join(config.suitesdir, self.suitename)
     cmd = "cp %s" % "".join(self.scriptpath)
     cmd = "%s %s" % (cmd, "".join(suitesdir))
     rc, output = getstatusoutput(cmd)
     if rc:
         raise RuntimeError("Dependency installation failed. %d : %s" %(rc,output))
Example #16
0
 def _installscript(self):
     if not self.scriptpath:
         return 0
     config = get_config()
     suitesdir = os.path.join(config.suitesdir, self.suitename)
     cmd = "cp %s" % "".join(self.scriptpath)
     cmd = "%s %s" % (cmd, "".join(suitesdir))
     rc, output = getstatusoutput(cmd)
     if rc:
         raise RuntimeError("Dependency installation failed. %d : %s" %
                            (rc, output))
Example #17
0
    def uninstall(self):
        """Uninstall the test tag.

        Uninstalling just recursively removes the test specific directory
        under the user's XDG_DATA_HOME directory.  This will both mark
        the test as removed, and clean up any files that were downloaded
        or installed under that directory.  Dependencies are intentionally
        not removed by this.
        """
        os.chdir(self.origdir)
        config = get_config()
        path = os.path.join(config.tagsdir, self.tagsdir)
        if os.path.exists(path):
            shutil.rmtree(path)
Example #18
0
    def uninstall(self):
        """Uninstall the test suite.

        Uninstalling just recursively removes the test specific directory
        under the user's XDG_DATA_HOME directory.  This will both mark
        the test as removed, and clean up any files that were downloaded
        or installed under that directory.  Dependencies are intentionally
        not removed by this.
        """
        os.chdir(self.origdir)
        config = get_config()
        path = os.path.join(config.suitesdir, self.suitename)
        if os.path.exists(path):
            shutil.rmtree(path)
Example #19
0
    def run(self):
        from skema.suiteutils import suiteloader

        if len(self.args) != 1:
            print "please specify the name of the suite to run"
            sys.exit(1)
        suite = suiteloader(self.args[0])
        try:
            return suite.run(quiet=self.opts.quiet, output=self.opts.output)

        except Exception as strerror:
            print "Suite execution error: %s" % strerror
            config = get_config()
            config.base_profile_mgr.stop()
            sys.exit(1)
Example #20
0
    def run(self):
        from skema.suiteutils import suiteloader

        if len(self.args) != 1:
            print "please specify the name of the suite to run"
            sys.exit(1)
        suite = suiteloader(self.args[0])
        try:
            return suite.run(quiet=self.opts.quiet, output=self.opts.output)

        except Exception as strerror:
            print "Suite execution error: %s" % strerror
            print (format_exc())
            config = get_config()
            config.base_profile_mgr.stop()
            sys.exit(1)
Example #21
0
    def run (self, manager):

        if self.alias not in manager.aliases2ports:
            print "free_buffer: Wrong alias specified"
            sys.exit(1)

        if self.pid not in manager.aliases2ports[self.alias]:
            print "free_buffer: Wrong port index specified"
            sys.exit(1)

        port = manager.aliases2ports[self.alias][self.pid]

        if port.is_input:
            port.fd = open(port.uri, "rb")
        else:
            port.fd = open(port.uri, "wb")

        config = get_config()
        handle = config.handles[self.alias]

        for i in range(0, port.nBufferCountActual):
            if port.is_input:

                buf        = port.fd.read(port.nBufferSize)
                read_bytes = len(buf)

                memmove(port.headers[i].contents.pBuffer, buf, read_bytes)

                port.headers[i].contents.nFilledLen = read_bytes
                if read_bytes < port.nBufferSize:
                    port.headers[i].contents.nFlags = 1
                    port.EOS                        = True

                OMX_EmptyThisBuffer(handle, port.headers[i])

                if port.EOS:
                    return

            else:
                port.fd.write(port.buffers[i])
                OMX_FillThisBuffer(handle, port.headers[i])
Example #22
0
    def run (self, manager):

        if self.alias not in manager.aliases2ports:
            print "free_buffer: Wrong alias specified"
            sys.exit(1)

        if self.pid not in manager.aliases2ports[self.alias]:
            print "free_buffer: Wrong port index specified"
            sys.exit(1)

        port = manager.aliases2ports[self.alias][self.pid]

        if port.is_input:
            port.fd = open(port.uri, "rb")
        else:
            port.fd = open(port.uri, "wb")

        config = get_config()
        handle = config.handles[self.alias]

        for i in range(0, port.nBufferCountActual):
            if port.is_input:
                buf        = port.fd.read(port.nBufferSize)
                read_bytes = len(buf)

                if port.headers[i].contents.pBuffer:
                    memmove(port.headers[i].contents.pBuffer, buf, read_bytes)

                port.headers[i].contents.nFilledLen = read_bytes
                if read_bytes < port.nBufferSize:
                    port.headers[i].contents.nFlags = 1
                    port.EOS                        = True

                OMX_EmptyThisBuffer(handle, port.headers[i])

                if port.EOS:
                    return

            else:
                port.fd.write(port.buffers[i])
                OMX_FillThisBuffer(handle, port.headers[i])
Example #23
0
    def _runsteps(self, scriptpath, resultsdir, quiet=False):
        outputlog = os.path.join(resultsdir, 'outputlog.txt')
        outputlog2 = os.path.join(resultsdir, 'outputlog2.txt')
        logging.basicConfig (filename=outputlog2, filemode='w', \
                                 format='%(asctime)s - %(levelname)s : %(message)s', \
                                 level=logging.DEBUG)
        logging.info("log")

        result = 0
        with open(outputlog, 'a') as fd:
            config = get_config()
            config.quiet = quiet
            temp = config.fd
            config.fd = fd
            result = run_suite(scriptpath)
            log_line()
            log_line ("Log files located in '%s'" % resultsdir)
            log_line()
            config.fd = temp

        logging.shutdown()
        return result
Example #24
0
    def _runsteps(self, scriptpath, resultsdir, quiet=False):
        outputlog = os.path.join(resultsdir, 'outputlog.txt')
        outputlog2 = os.path.join(resultsdir, 'outputlog2.txt')
        logging.basicConfig (filename=outputlog2, filemode='w', \
                                 format='%(asctime)s - %(levelname)s : %(message)s', \
                                 level=logging.DEBUG)
        logging.info("log")

        result = 0
        with open(outputlog, 'a') as fd:
            config = get_config()
            config.quiet = quiet
            temp = config.fd
            config.fd = fd
            result = run_suite(scriptpath)
            log_line()
            log_line("Log files located in '%s'" % resultsdir)
            log_line()
            config.fd = temp

        logging.shutdown()
        return result
Example #25
0
def run_suite(scriptpath):

    tree = et()
    tree.parse(scriptpath)
    titer = tree.iter()

    config = get_config()

    suites = []
    cases = []
    errors = dict()
    last_tag = dict()
    case = ""
    for elem in titer:

        if elem.tag == "Suite":
            continue

        if elem.tag == "Case":
            case = elem.get('name')
            log_line("Use Case : '%s'" % case)
            cases.append(case)
            errors[case] = 0
            result = 0
            continue

        if result == 0:
            tag_func = get_tag(elem.tag)
            if not tag_func:
                log_line("Tag '%s' not found. Exiting." % elem.tag)
                sys.exit(1)

            result = tag_func.run(elem, config)
            if result != 0:
                log_result(elem.tag,
                           get_string_from_il_enum(result, "OMX_Error"))
                errors[case] = result
            last_tag[case] = elem.tag
Example #26
0
def printit(line):
    config = get_config ()
    config.fd.writelines (line + '\n')
    if (config.quiet == False):
        print (line)
Example #27
0
    def run (self, manager):

        if self.alias not in manager.aliases2ports:
            print "allocate_buffer: Wrong alias specified"
            sys.exit(1)

        if self.pid not in manager.aliases2ports[self.alias]:
            print "allocate_buffer: Wrong port index specified"
            sys.exit(1)

        port = manager.aliases2ports[self.alias][self.pid]

        config = get_config()
        handle = config.handles[self.alias]

        # Retrieve the port definition
        indexstr                = "OMX_IndexParamPortDefinition"
        index                   = get_il_enum_from_string(indexstr)
        param_type              = omxil12_indexes[indexstr]
        param_struct            = param_type()
        param_struct.nSize      = sizeof(param_type)
        param_struct.nPortIndex = int(self.pid)

        omxerror = OMX_GetParameter(handle, index, byref(param_struct))
        interror = int(omxerror & 0xffffffff)
        err = get_string_from_il_enum(interror, "OMX_Error")

        port.nBufferCountActual = param_struct.nBufferCountActual
        port.nBufferSize        = param_struct.nBufferSize

        dirstr = get_string_from_il_enum \
            (getattr(param_struct, "eDir"), "OMX_Dir")

        if "OMX_DirInput" == dirstr:
            port.is_input = True
        else:
            port.is_input       = False

        if self.howmany.lower() == "all":
            self.howmany = port.nBufferCountActual
        else:
            self.howmany = int(self.howmany)
            log_line ("Allocate %d total" % self.howmany)

        if self.howmany == 0:
            print "allocate_buffer: Need to allocate at least 1 buffer"
            sys.exit(1)

        if port.allocation_count + self.howmany > \
                port.nBufferCountActual:
            print "allocate_buffer: Need to allocate at most " \
                "nBufferCountActual buffers"
            sys.exit(1)

        libc = CDLL('libc.so.6')
        for i in range(port.allocation_count,
                       port.allocation_count + self.howmany):

            p_header = POINTER(OMX_BUFFERHEADERTYPE)()

            if port.allocator:
                buf = (c_ubyte * port.nBufferSize)()
                omxerror = OMX_UseBuffer(handle,
                                         byref(p_header),
                                         param_struct.nPortIndex,
                                         None,
                                         port.nBufferSize,
                                         buf)
            else:
                omxerror = OMX_AllocateBuffer(handle,
                                              byref(p_header),
                                              param_struct.nPortIndex,
                                              None,
                                              port.nBufferSize)

            port.headers.append(p_header)
            port.buffers.append(buf)

        port.allocation_count += self.howmany
Example #28
0
def my_evt_hdler(a, b, c, d, e, f):
    evtstr = get_string_from_il_enum(c, "OMX_Event")
    config = get_config()
    name = str()
    name = config.cnames2[a]

    if (c == OMX_EventCmdComplete):
        config.cmdevents[a].set()
        cmdstr       = get_string_from_il_enum(d, "OMX_Command")
        if (d == OMX_CommandStateSet):
            statestr = get_string_from_il_enum(e, "OMX_State")
            log_line ()
            log_api("EventHandler '%s'" % (name))
            log_line ()
            log_line ("Received -> '%s' '%s' '%s'"         \
                            % (evtstr, cmdstr, statestr), 1)
    elif (c == OMX_EventBufferFlag):
        config.eosevents[a].set()
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' Port '%d'"             \
                        % (evtstr, d), 1)
    elif (c == OMX_EventPortSettingsChanged):
        config.settings_changed_events[a].set()
        idxstr = get_string_from_il_enum(e, "OMX_Index")
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' Port '%d' Index '%s'"             \
                        % (evtstr, d, idxstr), 1)
    elif (c == OMX_EventPortFormatDetected):
        config.format_detected_events[a].set()
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' Port '%d'"             \
                        % (evtstr, d), 1)
    elif (c == OMX_EventError):
        interror     = int(d & 0xffffffff)
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' '%s' Port '%d'"        \
                  % (evtstr, get_string_from_il_enum(interror, "OMX_Error"), e), 1)
        if len(config.ignored_error_events) != 0:
            if interror in config.ignored_error_events[a]:
                log_line ("Ignored -> '%s' '%s' Port '%d'" \
                          % (evtstr, get_string_from_il_enum(interror, "OMX_Error"), e), 1)
            else:
                config.error_events[a].append(interror)
        else:
            config.error_events[a].append(interror)
    else:
        log_line ()
        log_api("EventHandler '%s'"  % (name))
        log_line ()
        log_line ("Received -> '%s' Port '%d'"      \
                  % (evtstr, d), 1)

    return 0
Example #29
0
def my_evt_hdler(a, b, c, d, e, f):
    evtstr = get_string_from_il_enum(c, "OMX_Event")
    config = get_config()
    name = str()
    name = config.cnames2[a]

    if (c == OMX_EventCmdComplete):
        config.cmdevents[a].set()
        cmdstr = get_string_from_il_enum(d, "OMX_Command")
        if (d == OMX_CommandStateSet):
            statestr = get_string_from_il_enum(e, "OMX_State")
            log_line()
            log_api("EventHandler '%s'" % (name))
            log_line()
            log_line ("Received -> '%s' '%s' '%s'"         \
                            % (evtstr, cmdstr, statestr), 1)
    elif (c == OMX_EventBufferFlag):
        config.eosevents[a].set()
        log_line()
        log_api("EventHandler '%s'" % (name))
        log_line()
        log_line ("Received -> '%s' Port '%d'"             \
                        % (evtstr, d), 1)
    elif (c == OMX_EventPortSettingsChanged):
        config.settings_changed_events[a].set()
        idxstr = get_string_from_il_enum(e, "OMX_Index")
        log_line()
        log_api("EventHandler '%s'" % (name))
        log_line()
        log_line ("Received -> '%s' Port '%d' Index '%s'"             \
                  % (evtstr, d, idxstr), 1)


#         if name == "OMX.Aratelia.video_decoder.vp8" and d == 0:
#             os.kill(PID, signal.SIGUSR1)
    elif (c == OMX_EventPortFormatDetected):
        config.format_detected_events[a].set()
        log_line()
        log_api("EventHandler '%s'" % (name))
        log_line()
        log_line ("Received -> '%s' Port '%d'"             \
                        % (evtstr, d), 1)
    elif (c == OMX_EventError):
        interror = int(d & 0xffffffff)
        log_line()
        log_api("EventHandler '%s'" % (name))
        log_line()
        log_line ("Received -> '%s' '%s' Port '%d'"        \
                  % (evtstr, get_string_from_il_enum(interror, "OMX_Error"), e), 1)
        if len(config.ignored_error_events) != 0:
            if interror in config.ignored_error_events[a]:
                log_line ("Ignored -> '%s' '%s' Port '%d'" \
                          % (evtstr, get_string_from_il_enum(interror, "OMX_Error"), e), 1)
            else:
                config.error_events[a].append(interror)
        else:
            config.error_events[a].append(interror)
    else:
        log_line()
        log_api("EventHandler '%s'" % (name))
        log_line()
        log_line ("Received -> '%s' Port '%d'"      \
                  % (evtstr, d), 1)

    return 0
Example #30
0
def printit(line):
    config = get_config()
    config.fd.writelines(line + '\n')
    if (config.quiet == False):
        print(line)
Example #31
0
    def run (self, manager):

        if self.alias not in manager.aliases2ports:
            print "use_egl_images: Wrong alias specified"
            sys.exit(1)

        if self.pid not in manager.aliases2ports[self.alias]:
            print "use_egl_images: Wrong port index specified"
            sys.exit(1)

        port = manager.aliases2ports[self.alias][self.pid]

        config = get_config()
        handle = config.handles[self.alias]

        # Retrieve the port definition
        indexstr                = "OMX_IndexParamPortDefinition"
        index                   = get_il_enum_from_string(indexstr)
        param_type              = omxil12_indexes[indexstr]
        param_struct            = param_type()
        param_struct.nSize      = sizeof(param_type)
        param_struct.nPortIndex = int(self.pid)

        omxerror = OMX_GetParameter(handle, index, byref(param_struct))
        interror = int(omxerror & 0xffffffff)
        err = get_string_from_il_enum(interror, "OMX_Error")

        port.nBufferCountActual = param_struct.nBufferCountActual
        port.nBufferSize        = param_struct.nBufferSize

        dirstr = get_string_from_il_enum \
            (getattr(param_struct, "eDir"), "OMX_Dir")

        if "OMX_DirInput" == dirstr:
            port.is_input = True
        else:
            port.is_input = False

        if self.howmany.lower() == "all":
            self.howmany = port.nBufferCountActual
        else:
            self.howmany = int(self.howmany)
            log_line ("Allocate %d total" % self.howmany)

        if self.howmany == 0:
            print "use_egl_images: Need to allocate at least 1 buffer"
            sys.exit(1)

        if port.allocation_count + self.howmany > \
                port.nBufferCountActual:
            print "use_egl_images: Need to allocate at most " \
                "nBufferCountActual buffers"
            sys.exit(1)

        libc = CDLL('libc.so.6')
        for i in range(port.allocation_count,
                       port.allocation_count + self.howmany):

            p_header = POINTER(OMX_BUFFERHEADERTYPE)()

            if port.allocator:
                print "use_egl_images: Port can't be allocate buffers. " \
                    "Invalid test setup."
                sys.exit(1)

            eglimage = (c_ubyte * port.nBufferSize)()
            omxerror = OMX_UseEGLImage(handle,
                                       byref(p_header),
                                       param_struct.nPortIndex,
                                       None,
                                       eglimage)

            port.headers.append(p_header)
            port.buffers.append(eglimage)

        port.allocation_count += self.howmany