1 // Copyright 2020 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 ANDROID_V4L2_CODEC2_COMPONENTS_VIDEO_DECODER_H 6 #define ANDROID_V4L2_CODEC2_COMPONENTS_VIDEO_DECODER_H 7 8 #include <stdint.h> 9 #include <memory> 10 11 #include <base/callback.h> 12 13 #include <v4l2_codec2/common/VideoTypes.h> 14 #include <v4l2_codec2/components/BitstreamBuffer.h> 15 #include <v4l2_codec2/components/VideoFrame.h> 16 #include <v4l2_codec2/components/VideoFramePool.h> 17 18 namespace android { 19 20 class VideoDecoder { 21 public: 22 enum class DecodeStatus { 23 kOk = 0, // Everything went as planned. 24 kAborted, // Read aborted due to Flush() during pending read. 25 kError, // Decoder returned decode error. 26 }; 27 static const char* DecodeStatusToString(DecodeStatus status); 28 29 using GetPoolCB = 30 base::RepeatingCallback<void(std::unique_ptr<VideoFramePool>*, const media::Size& size, 31 HalPixelFormat pixelFormat, size_t numOutputBuffers)>; 32 using DecodeCB = base::OnceCallback<void(DecodeStatus)>; 33 using OutputCB = base::RepeatingCallback<void(std::unique_ptr<VideoFrame>)>; 34 using ErrorCB = base::RepeatingCallback<void()>; 35 36 virtual ~VideoDecoder(); 37 38 virtual void decode(std::unique_ptr<BitstreamBuffer> buffer, DecodeCB decodeCb) = 0; 39 virtual void drain(DecodeCB drainCb) = 0; 40 virtual void flush() = 0; 41 }; 42 43 } // namespace android 44 45 #endif // ANDROID_V4L2_CODEC2_COMPONENTS_VIDEO_DECODER_H 46