From cfb795ad383f69e60d5fbdcd4283aa2145056827 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 31 Oct 2013 10:14:37 +0100 Subject: [PATCH] add a UUID based on a 32 bit hash for each processor --- timeside/api.py | 5 +++++ timeside/core.py | 8 ++++++++ timeside/grapher/waveform_transparent.py | 1 + 3 files changed, 14 insertions(+) diff --git a/timeside/api.py b/timeside/api.py index ad2b374..8f53cd4 100644 --- a/timeside/api.py +++ b/timeside/api.py @@ -96,6 +96,11 @@ class IProcessor(Interface): duration """ + @staticmethod + def uuid(): + """Return the UUID of the processor""" + + class IEncoder(IProcessor): """Encoder driver interface. Each encoder is expected to support a specific format.""" diff --git a/timeside/core.py b/timeside/core.py index 06323cb..d477ca4 100644 --- a/timeside/core.py +++ b/timeside/core.py @@ -24,6 +24,7 @@ from timeside.exceptions import Error, ApiError import re import time import numpy +import random __all__ = ['Processor', 'MetaProcessor', 'implements', 'abstract', 'interfacedoc', 'processors', 'get_processor', 'ProcessPipe', @@ -68,6 +69,9 @@ class Processor(Component): abstract() implements(IProcessor) + def __init__(self): + self.UUID = "%08x" % random.getrandbits(32) + @interfacedoc def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None): @@ -123,6 +127,10 @@ class Processor(Component): def mediainfo(self): return self.source_mediainfo + @interfacedoc + def uuid(self): + return self.UUID + def __del__(self): self.release() diff --git a/timeside/grapher/waveform_transparent.py b/timeside/grapher/waveform_transparent.py index 3fd21a3..0e5b246 100644 --- a/timeside/grapher/waveform_transparent.py +++ b/timeside/grapher/waveform_transparent.py @@ -24,6 +24,7 @@ from timeside.api import IGrapher from timeside.grapher.core import * from timeside.grapher.waveform_simple import Waveform + class WaveformTransparent(Waveform): """ Builds a PIL image representing a waveform of the audio stream. Adds pixels iteratively thanks to the adapter providing fixed size frame buffers. -- 2.39.5