1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gmyth-stream/server/0.3/lib/transcoder.py Tue Aug 07 16:00:18 2007 +0100
1.3 @@ -0,0 +1,60 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +__author__ = "Gustavo Sverzut Barbieri / Artur Duque de Souza"
1.7 +__author_email__ = "barbieri@gmail.com / artur.souza@indt.org.br"
1.8 +__license__ = "GPL"
1.9 +__version__ = "0.4"
1.10 +
1.11 +__all__ = ("Transcoder")
1.12 +
1.13 +class Transcoder(object):
1.14 + """Transcoder's Class: parent class to implement
1.15 + a plugin for transcoding data."""
1.16 + priority = 0 # negative values have higher priorities
1.17 + name = None # to be used in requests
1.18 + status = None
1.19 + log = None
1.20 + tid = -1
1.21 +
1.22 + def __init__(self, params):
1.23 + self.params = params
1.24 + # __init__()
1.25 +
1.26 +
1.27 + def params_first(self, key, default=None):
1.28 + if default is None:
1.29 + return self.params[key][0]
1.30 + else:
1.31 + try:
1.32 + return self.params[key][0]
1.33 + except:
1.34 + return default
1.35 + # params_first()
1.36 +
1.37 +
1.38 + def get_mimetype(self):
1.39 + mux = self.params_first("mux", "mpg")
1.40 +
1.41 + if mux == "mpeg":
1.42 + return "video/mpeg"
1.43 + elif mux == "avi":
1.44 + return "video/x-msvideo"
1.45 + else:
1.46 + return "application/octet-stream"
1.47 + # get_mimetype()
1.48 +
1.49 + def start(self, outfile):
1.50 + return True
1.51 + # start()
1.52 +
1.53 +
1.54 + def stop(self):
1.55 + return True
1.56 + # stop()
1.57 +
1.58 + def __str__(self):
1.59 + return '%s: %s( params=%s ) - Status: %s%%' % \
1.60 + (self.__class__.__name__, self.tid,
1.61 + self.params, self.status)
1.62 + # __str__()
1.63 +# Transcoder