blob: a7c328e46df8260a2b3091eb44aed31ab758d469 [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
37 ::ndk::ScopedAStatus sendCommand(int32_t cmd, int32_t param) override;
38
39 ::ndk::ScopedAStatus getConsumerUsage(int64_t *_aidl_return) override;
40
41 ::ndk::ScopedAStatus getInputBufferParams(
42 ::aidl::android::media::IAidlNode::InputBufferParams *_aidl_return) override;
43
44 ::ndk::ScopedAStatus setConsumerUsage(int64_t usage) override;
45
46 ::ndk::ScopedAStatus setAdjustTimestampGapUs(int32_t gapUs) override;
47
48 ::ndk::ScopedAStatus setInputSurface(
49 const std::shared_ptr<::aidl::android::media::IAidlBufferSource>&
50 bufferSource) override;
51
52 ::ndk::ScopedAStatus submitBuffer(
53 int32_t buffer,
54 const ::aidl::android::hardware::HardwareBuffer& hBuffer,
55 int32_t flags,
56 int64_t timestampUs,
57 const ::ndk::ScopedFileDescriptor& fence) override;
58
59 ::ndk::ScopedAStatus onDataSpaceChanged(
60 int dataSpace, int aspects, int pixelFormat) override;
61
62 /**
63 * Returns underlying IAidlBufferSource object.
64 */
65 std::shared_ptr<::aidl::android::media::IAidlBufferSource> getSource();
66
67 /**
68 * Configure the frame size.
69 */
70 void setFrameSize(uint32_t width, uint32_t height);
71
72 /**
73 * Clean up work item reference.
74 *
75 * \param index input work index
76 */
77 void onInputBufferDone(c2_cntr64_t index);
78
79 /**
80 * Returns dataspace information from GraphicBufferSource.
81 */
82 android_dataspace getDataspace();
83
84 /**
85 * Returns dataspace information from GraphicBufferSource.
86 */
87 uint32_t getPixelFormat();
88
89 /**
90 * Sets priority of the queue thread.
91 */
92 void setPriority(int priority);
93
94private:
95 std::shared_ptr<C2NodeImpl> mImpl;
96};
97
98} // namespace android
99