Chromium Code Reviews| 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/callback_forward.h" | |
| 9 #include "base/callback_helpers.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "content/common/content_export.h" | |
| 12 #include "ui/gfx/geometry/size.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 // An AcceleratedVideoDecoder is a video decoder that requires support from an | |
| 17 // external accelerator (typically a hardware accelerator) to partially offload | |
| 18 // the decode process after parsing stream headers, and performing reference | |
| 19 // frame and state management. | |
| 20 class CONTENT_EXPORT AcceleratedVideoDecoder { | |
|
Owen Lin
2015/01/09 09:56:14
I didn't see how the decoded frames be returned in
Pawel Osciak
2015/01/09 13:50:31
I'm also not happy with this detail, I agree. I wa
| |
| 21 public: | |
| 22 AcceleratedVideoDecoder() {} | |
| 23 virtual ~AcceleratedVideoDecoder() {} | |
| 24 | |
| 25 virtual void SetStream(const uint8* ptr, size_t size) = 0; | |
| 26 | |
| 27 // Have the decoder flush its state and trigger output of all previously | |
| 28 // decoded surfaces. Return false on failure. | |
| 29 virtual bool Flush() WARN_UNUSED_RESULT = 0; | |
| 30 | |
| 31 // To be called during decoding. | |
| 32 // Stop (pause) decoding, discarding all remaining inputs and outputs, | |
| 33 // but do not flush decoder state, so that the playback can be resumed later, | |
| 34 // possibly from a different location. | |
| 35 virtual void Reset() = 0; | |
| 36 | |
| 37 // Decode result codes. | |
| 38 enum DecResult { | |
| 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 DecResult 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 kNeedNewSurfaces. | |
| 57 virtual gfx::Size GetPicSize() = 0; | |
|
Owen Lin
2015/01/09 09:56:14
Would it be better to move into those Accelerator?
Pawel Osciak
2015/01/09 13:50:31
We still need to return from Decode(), because we
| |
| 58 virtual size_t GetRequiredNumOfPictures() = 0; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(AcceleratedVideoDecoder); | |
| 61 }; | |
| 62 | |
| 63 } // namespace content | |
| 64 | |
| 65 #endif // CONTENT_COMMON_GPU_MEDIA_ACCELERATED_VIDEO_DECODER_ | |
| OLD | NEW |