Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / internal / image_processing / frame_generator.py
blobb701418e9903c5d565030f830a4eee13776b4a7b
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import abc
8 class FrameReadError(Exception):
9 pass
12 class FrameGenerator(object):
13 """ Defines an interface for reading input frames.
15 Attributes:
16 _generator: A reference to the created generator.
17 """
18 __metaclass__ = abc.ABCMeta
20 def __init__(self):
21 """ Initializes the FrameGenerator object. """
22 self._generator = self._CreateGenerator()
24 @abc.abstractmethod
25 def _CreateGenerator(self):
26 """ Creates a new generator.
28 Implemented in derived classes.
30 Raises:
31 FrameReadError: A error occurred in reading the frame.
32 """
33 raise NotImplementedError
35 @property
36 def Generator(self):
37 """ Returns:
38 A reference to the created generator.
39 """
40 return self._generator
42 @abc.abstractproperty
43 def CurrentTimestamp(self):
44 """ Returns:
45 float, The timestamp of the current frame in milliseconds.
46 """
47 raise NotImplementedError
49 @abc.abstractproperty
50 def CurrentFrameNumber(self):
51 """ Returns:
52 int, The frame index of the current frame.
53 """
54 raise NotImplementedError
56 @abc.abstractproperty
57 def Dimensions(self):
58 """ Returns:
59 The dimensions of the frame sequence as a tuple int (width, height).
60 This value should be constant across frames.
61 """
62 raise NotImplementedError