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