blob: 365a41d7b42f0796371dd07326cd72df6c6e56e7 [file] [log] [blame]
Sungtak Lee64c9d932024-03-26 03:46:53 +00001/*
2 * Copyright 2024, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <aidl/android/media/BnAidlNode.h>
20#include <codec2/hidl/client.h>
21
22namespace android {
23
24struct C2NodeImpl;
25
26/**
27 * Thin Codec2 AIdL encoder HAL wrapper for InputSurface
28 */
29class C2AidlNode : public ::aidl::android::media::BnAidlNode {
30public:
31 explicit C2AidlNode(const std::shared_ptr<Codec2Client::Component> &comp);
32 ~C2AidlNode() override = default;
33
34 // IAidlNode
35 ::ndk::ScopedAStatus freeNode() override;
36
Sungtak Lee64c9d932024-03-26 03:46:53 +000037 ::ndk::ScopedAStatus getConsumerUsage(int64_t *_aidl_return) override;
38
39 ::ndk::ScopedAStatus getInputBufferParams(
40 ::aidl::android::media::IAidlNode::InputBufferParams *_aidl_return) override;
41
42 ::ndk::ScopedAStatus setConsumerUsage(int64_t usage) override;
43
44 ::ndk::ScopedAStatus setAdjustTimestampGapUs(int32_t gapUs) override;
45
46 ::ndk::ScopedAStatus setInputSurface(
47 const std::shared_ptr<::aidl::android::media::IAidlBufferSource>&
48 bufferSource) override;
49
50 ::ndk::ScopedAStatus submitBuffer(
51 int32_t buffer,
52 const ::aidl::android::hardware::HardwareBuffer& hBuffer,
53 int32_t flags,
54 int64_t timestampUs,
55 const ::ndk::ScopedFileDescriptor& fence) override;
56
57 ::ndk::ScopedAStatus onDataSpaceChanged(
58 int dataSpace, int aspects, int pixelFormat) override;
59
60 /**
61 * Returns underlying IAidlBufferSource object.
62 */
63 std::shared_ptr<::aidl::android::media::IAidlBufferSource> getSource();
64
65 /**
66 * Configure the frame size.
67 */
68 void setFrameSize(uint32_t width, uint32_t height);
69
70 /**
71 * Clean up work item reference.
72 *
73 * \param index input work index
74 */
75 void onInputBufferDone(c2_cntr64_t index);
76
77 /**
78 * Returns dataspace information from GraphicBufferSource.
79 */
80 android_dataspace getDataspace();
81
82 /**
83 * Returns dataspace information from GraphicBufferSource.
84 */
85 uint32_t getPixelFormat();
86
87 /**
88 * Sets priority of the queue thread.
89 */
90 void setPriority(int priority);
91
92private:
93 std::shared_ptr<C2NodeImpl> mImpl;
94};
95
96} // namespace android
97