| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "content/common/content_export.h" | |
| 10 #include "ui/gfx/geometry/size.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 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() {} | |
| 22 | |
| 23 virtual void SetStream(const uint8_t* ptr, size_t size) = 0; | |
| 24 | |
| 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; | |
| 28 | |
| 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; | |
| 34 | |
| 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. | |
| 44 }; | |
| 45 | |
| 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; | |
| 50 | |
| 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; | |
| 56 | |
| 57 private: | |
| 58 DISALLOW_COPY_AND_ASSIGN(AcceleratedVideoDecoder); | |
| 59 }; | |
| 60 | |
| 61 } // namespace content | |
| 62 | |
| 63 #endif // CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_ | |
| OLD | NEW |