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.
8 class FrameReadError(Exception):
12 class FrameGenerator(object):
13 """ Defines an interface for reading input frames.
16 _generator: A reference to the created generator.
18 __metaclass__
= abc
.ABCMeta
21 """ Initializes the FrameGenerator object. """
22 self
._generator
= self
._CreateGenerator
()
25 def _CreateGenerator(self
):
26 """ Creates a new generator.
28 Implemented in derived classes.
31 FrameReadError: A error occurred in reading the frame.
33 raise NotImplementedError
38 A reference to the created generator.
40 return self
._generator
43 def CurrentTimestamp(self
):
45 float, The timestamp of the current frame in milliseconds.
47 raise NotImplementedError
50 def CurrentFrameNumber(self
):
52 int, The frame index of the current frame.
54 raise NotImplementedError
59 The dimensions of the frame sequence as a tuple int (width, height).
60 This value should be constant across frames.
62 raise NotImplementedError