aboutsummaryrefslogtreecommitdiff
path: root/components/include/v4l2_codec2
diff options
context:
space:
mode:
Diffstat (limited to 'components/include/v4l2_codec2')
-rw-r--r--components/include/v4l2_codec2/components/VideoDecoder.h8
-rw-r--r--components/include/v4l2_codec2/components/VideoEncoder.h10
-rw-r--r--components/include/v4l2_codec2/components/VideoFramePool.h23
3 files changed, 21 insertions, 20 deletions
diff --git a/components/include/v4l2_codec2/components/VideoDecoder.h b/components/include/v4l2_codec2/components/VideoDecoder.h
index 5b2da41..3e3fec4 100644
--- a/components/include/v4l2_codec2/components/VideoDecoder.h
+++ b/components/include/v4l2_codec2/components/VideoDecoder.h
@@ -26,11 +26,11 @@ public:
};
static const char* DecodeStatusToString(DecodeStatus status);
- using GetPoolCB = base::RepeatingCallback<std::unique_ptr<VideoFramePool>(
+ using GetPoolCB = ::base::RepeatingCallback<std::unique_ptr<VideoFramePool>(
const ui::Size& size, HalPixelFormat pixelFormat, size_t numOutputBuffers)>;
- using DecodeCB = base::OnceCallback<void(DecodeStatus)>;
- using OutputCB = base::RepeatingCallback<void(std::unique_ptr<VideoFrame>)>;
- using ErrorCB = base::RepeatingCallback<void()>;
+ using DecodeCB = ::base::OnceCallback<void(DecodeStatus)>;
+ using OutputCB = ::base::RepeatingCallback<void(std::unique_ptr<VideoFrame>)>;
+ using ErrorCB = ::base::RepeatingCallback<void()>;
virtual ~VideoDecoder();
diff --git a/components/include/v4l2_codec2/components/VideoEncoder.h b/components/include/v4l2_codec2/components/VideoEncoder.h
index 5f23541..7e5a3c2 100644
--- a/components/include/v4l2_codec2/components/VideoEncoder.h
+++ b/components/include/v4l2_codec2/components/VideoEncoder.h
@@ -47,13 +47,13 @@ public:
};
using FetchOutputBufferCB =
- base::RepeatingCallback<void(uint32_t, std::unique_ptr<BitstreamBuffer>* buffer)>;
+ ::base::RepeatingCallback<void(uint32_t, std::unique_ptr<BitstreamBuffer>* buffer)>;
// TODO(dstaessens): Change callbacks to OnceCallback provided when requesting encode/drain.
- using InputBufferDoneCB = base::RepeatingCallback<void(uint64_t)>;
- using OutputBufferDoneCB = base::RepeatingCallback<void(
+ using InputBufferDoneCB = ::base::RepeatingCallback<void(uint64_t)>;
+ using OutputBufferDoneCB = ::base::RepeatingCallback<void(
size_t, int64_t, bool, std::unique_ptr<BitstreamBuffer> buffer)>;
- using DrainDoneCB = base::RepeatingCallback<void(bool)>;
- using ErrorCB = base::RepeatingCallback<void()>;
+ using DrainDoneCB = ::base::RepeatingCallback<void(bool)>;
+ using ErrorCB = ::base::RepeatingCallback<void()>;
virtual ~VideoEncoder() = default;
diff --git a/components/include/v4l2_codec2/components/VideoFramePool.h b/components/include/v4l2_codec2/components/VideoFramePool.h
index 2978eed..6bebc37 100644
--- a/components/include/v4l2_codec2/components/VideoFramePool.h
+++ b/components/include/v4l2_codec2/components/VideoFramePool.h
@@ -44,12 +44,13 @@ public:
private:
// |blockPool| is the C2BlockPool that we fetch graphic blocks from.
+ // |maxBufferCount| maximum number of buffer that should should provide to client
// |size| is the resolution size of the required graphic blocks.
// |pixelFormat| is the pixel format of the required graphic blocks.
// |isSecure| indicates the video stream is encrypted or not.
// All public methods and the callbacks should be run on |taskRunner|.
- VideoFramePool(std::shared_ptr<C2BlockPool> blockPool, const ui::Size& size,
- HalPixelFormat pixelFormat, C2MemoryUsage memoryUsage,
+ VideoFramePool(std::shared_ptr<C2BlockPool> blockPool, const size_t maxBufferCount,
+ const ui::Size& size, HalPixelFormat pixelFormat, C2MemoryUsage memoryUsage,
scoped_refptr<::base::SequencedTaskRunner> taskRunner);
bool initialize();
void destroyTask();
@@ -59,20 +60,20 @@ private:
void getVideoFrameTask();
void onVideoFrameReady(std::optional<FrameWithBlockId> frameWithBlockId);
- // Ask |blockPool| to allocate the specified number of buffers.
- // |bufferCount| is the number of requested buffers.
- static c2_status_t requestNewBufferSet(C2BlockPool& blockPool, int32_t bufferCount,
- const ui::Size& size, uint32_t format,
- C2MemoryUsage usage);
+ // Returns true if a buffer shall not be handed to client.
+ bool shouldDropBuffer(uint32_t bufferId);
static std::optional<uint32_t> getBufferIdFromGraphicBlock(C2BlockPool& blockPool,
const C2Block2D& block);
- // Ask |blockPool| to notify when a block is available via |cb|.
- // Return true if |blockPool| supports notifying buffer available.
- static bool setNotifyBlockAvailableCb(C2BlockPool& blockPool, ::base::OnceClosure cb);
-
std::shared_ptr<C2BlockPool> mBlockPool;
+
+ // Holds the number of maximum amount of buffers that VideoFramePool
+ // should provide to client.
+ size_t mMaxBufferCount;
+ // Contains known buffer ids that are valid for the pool.
+ std::set<uint32_t> mBuffers;
+
const ui::Size mSize;
const HalPixelFormat mPixelFormat;
const C2MemoryUsage mMemoryUsage;