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