From: Olivier Guilyardi Date: Thu, 26 Nov 2009 20:53:13 +0000 (+0000) Subject: encode api: revert to methods instead of data members (format, description, ..),... X-Git-Tag: 0.3.2~222 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d4f140a076e256a4f4012289b0ef4ecbb2fd7f73;p=timeside.git encode api: revert to methods instead of data members (format, description, ..), for support of __doc__ --- diff --git a/encode/api.py b/encode/api.py index ef4bd20..628b1dd 100644 --- a/encode/api.py +++ b/encode/api.py @@ -24,22 +24,13 @@ from timeside.core import Interface, TimeSideError class IEncoder(Interface): """Encoder driver interface""" - format = "" - """Encoding format as a short string Example: "MP3", "OGG", "AVI", ... """ - - description = "" - """String describing what this encoding format provides, is good - for, etc... The description is meant to help the end user decide what - format is good for him/her """ - - file_extension = "" - """Filename extension corresponding to this encoding format""" - - mime_type = "" - """Mime type corresponding to this encoding format""" + # Remark: the method prototypes do not include any self or cls argument + # because an interface is meant to show what methods a class must expose + # from the caller's point of view. However, when implementing the class + # you'll obviously want to include this extra argument. # FIXME: this constructor conflicts with the core component architecture - def __init__(self, output, nchannels, samplerate): + def __init__(output, nchannels, samplerate): """The constructor must always accept the output, nchannels and samplerate arguments. It may accepts extra arguments such as bitrate, depth, etc.., but these must be optionnal, that is have a default value. @@ -49,23 +40,40 @@ class IEncoder(Interface): block of binary data. """ - def set_metadata(self, metadata): + def format(): + """Return the encode/encoding format as a short string + Example: "MP3", "OGG", "AVI", ... + """ + + def description(): + """Return a string describing what this encode format provides, is good + for, etc... The description is meant to help the end user decide what + format is good for him/her + """ + + def file_extension(): + """Return the filename extension corresponding to this encode format""" + + def mime_type(): + """Return the mime type corresponding to this encode format""" + + def set_metadata(metadata): """metadata is a tuple containing tuples for each descriptor return by the dc.Ressource of the item, in the model order : ((name1, value1),(name2, value2),(name1, value3), ...)""" - def update(self): + def update(): """Updates the metadata into the file passed as the output argument to the constructor. This method can't be called in streaming mode.""" - def process(self, frames): + def process(frames): """Encode the frames passed as a numpy array, where columns are channels. In streaming mode the callback passed to the constructor is called whenever a block of encoded data is ready.""" - def finish(self): + def finish(): """Flush the encoded data and close the output file/stream. Calling this method may cause the streaming callback to be called if in streaming mode."""