Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / common / gpu / media / accelerated_video_decoder.h
blobb0ba93506ff6e86e91e1141698c6802cc25c5cf2
1 // Copyright 2015 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 #ifndef CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_H_
8 #include "base/macros.h"
9 #include "content/common/content_export.h"
10 #include "ui/gfx/geometry/size.h"
12 namespace content {
14 // An AcceleratedVideoDecoder is a video decoder that requires support from an
15 // external accelerator (typically a hardware accelerator) to partially offload
16 // the decode process after parsing stream headers, and performing reference
17 // frame and state management.
18 class CONTENT_EXPORT AcceleratedVideoDecoder {
19 public:
20 AcceleratedVideoDecoder() {}
21 virtual ~AcceleratedVideoDecoder() {}
23 virtual void SetStream(const uint8_t* ptr, size_t size) = 0;
25 // Have the decoder flush its state and trigger output of all previously
26 // decoded surfaces. Return false on failure.
27 virtual bool Flush() WARN_UNUSED_RESULT = 0;
29 // Stop (pause) decoding, discarding all remaining inputs and outputs,
30 // but do not flush decoder state, so that playback can be resumed later,
31 // possibly from a different location.
32 // To be called during decoding.
33 virtual void Reset() = 0;
35 enum DecodeResult {
36 kDecodeError, // Error while decoding.
37 // TODO(posciak): unsupported streams are currently treated as error
38 // in decoding; in future it could perhaps be possible to fall back
39 // to software decoding instead.
40 // kStreamError, // Error in stream.
41 kAllocateNewSurfaces, // Need a new set of surfaces to be allocated.
42 kRanOutOfStreamData, // Need more stream data to proceed.
43 kRanOutOfSurfaces, // Waiting for the client to free up output surfaces.
46 // Try to decode more of the stream, returning decoded frames asynchronously.
47 // Return when more stream is needed, when we run out of free surfaces, when
48 // we need a new set of them, or when an error occurs.
49 virtual DecodeResult Decode() WARN_UNUSED_RESULT = 0;
51 // Return dimensions/required number of output surfaces that client should
52 // be ready to provide for the decoder to function properly.
53 // To be used after Decode() returns kNeedNewSurfaces.
54 virtual gfx::Size GetPicSize() const = 0;
55 virtual size_t GetRequiredNumOfPictures() const = 0;
57 private:
58 DISALLOW_COPY_AND_ASSIGN(AcceleratedVideoDecoder);
61 } // namespace content
63 #endif // CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_H_