gmyth-stream/server/0.3/lib/transcoder.py
author morphbr
Tue Jun 05 12:32:43 2007 +0100 (2007-06-05)
branchtrunk
changeset 744 ef4fb30176dd
child 800 2b1824e138b1
permissions -rw-r--r--
[svn r750] * GMyth-Streamer
- Download's status capability
     1 #!/usr/bin/env python
     2 
     3 __author__ = "Gustavo Sverzut Barbieri / Artur Duque de Souza"
     4 __author_email__ = "barbieri@gmail.com / artur.souza@indt.org.br"
     5 __license__ = "GPL"
     6 __version__ = "0.4"
     7 
     8 __all__ = ("Transcoder")
     9 
    10 class Transcoder(object):
    11     """Transcoder's Class: parent class to implement
    12     a plugin for transcoding data."""
    13     priority = 0   # negative values have higher priorities
    14     name = None # to be used in requests
    15     status = None
    16     log = None
    17     tid = -1
    18 
    19     def __init__(self, params):
    20         self.params = params
    21     # __init__()
    22 
    23 
    24     def params_first(self, key, default=None):
    25         if default is None:
    26             return self.params[key][0]
    27         else:
    28             try:
    29                 return self.params[key][0]
    30             except:
    31                 return default
    32     # params_first()
    33 
    34 
    35     def get_mimetype(self):
    36         mux = self.params_first("mux", "mpg")
    37 
    38         if mux == "mpeg":
    39             return "video/mpeg"
    40         elif mux == "avi":
    41             return "video/x-msvideo"
    42         else:
    43             return "application/octet-stream"
    44     # get_mimetype()
    45 
    46     def start(self, outfile):
    47         return True
    48     # start()
    49 
    50 
    51     def stop(self):
    52         return True
    53     # stop()
    54 
    55     def __str__(self):
    56         return '%s: %s( params=%s ) - Status: %s%%' % \
    57                (self.__class__.__name__, self.tid,
    58                 self.params, self.status)
    59     # __str__()
    60 # Transcoder