1 /*
2  * Copyright 2018 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 #ifndef CODEC2_HIDL_V1_0_UTILS_INPUTSURFACE_H
18 #define CODEC2_HIDL_V1_0_UTILS_INPUTSURFACE_H
19 
20 #include <codec2/hidl/1.0/ComponentStore.h>
21 
22 #include <android/hardware/graphics/bufferqueue/2.0/IGraphicBufferProducer.h>
23 #include <android/hardware/media/c2/1.0/IInputSink.h>
24 #include <android/hardware/media/c2/1.0/IInputSurface.h>
25 #include <hidl/Status.h>
26 #include <media/stagefright/bqhelper/GraphicBufferSource.h>
27 
28 #include <util/C2InterfaceHelper.h>
29 
30 namespace android {
31 namespace hardware {
32 namespace media {
33 namespace c2 {
34 namespace V1_0 {
35 namespace utils {
36 
37 using ::android::hardware::hidl_handle;
38 using ::android::hardware::hidl_string;
39 using ::android::hardware::hidl_vec;
40 using ::android::hardware::Return;
41 using ::android::hardware::Void;
42 using ::android::sp;
43 
44 struct InputSurface : public IInputSurface {
45 
46     typedef ::android::hardware::graphics::bufferqueue::V2_0::
47             IGraphicBufferProducer HGraphicBufferProducer;
48 
49     typedef ::android::
50             GraphicBufferSource GraphicBufferSource;
51 
52     virtual Return<sp<HGraphicBufferProducer>> getGraphicBufferProducer() override;
53 
54     virtual Return<sp<IConfigurable>> getConfigurable() override;
55 
56     virtual Return<void> connect(
57             const sp<IInputSink>& sink,
58             connect_cb _hidl_cb) override;
59 
60     InputSurface(
61             const std::shared_ptr<ParameterCache>& cache,
62             const std::shared_ptr<C2ReflectorHelper>& reflector,
63             const sp<HGraphicBufferProducer>& base,
64             const sp<GraphicBufferSource>& source);
65 
66 protected:
67 
68     class Interface;
69     class ConfigurableIntf;
70 
71     std::shared_ptr<ParameterCache> mParameterCache;
72     sp<HGraphicBufferProducer> mProducer;
73     sp<GraphicBufferSource> mSource;
74     std::shared_ptr<Interface> mIntf;
75     sp<CachedConfigurable> mConfigurable;
76 
77     virtual ~InputSurface() override = default;
78 };
79 
80 }  // namespace utils
81 }  // namespace V1_0
82 }  // namespace c2
83 }  // namespace media
84 }  // namespace hardware
85 }  // namespace android
86 
87 #endif  // CODEC2_HIDL_V1_0_UTILS_INPUTSURFACE_H
88