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 protected: 61 62 class Interface; 63 class ConfigurableIntf; 64 65 sp<ComponentStore> mStore; 66 sp<HGraphicBufferProducer> mProducer; 67 sp<GraphicBufferSource> mSource; 68 std::shared_ptr<Interface> mIntf; 69 sp<CachedConfigurable> mConfigurable; 70 71 InputSurface( 72 const sp<ComponentStore>& store, 73 const std::shared_ptr<C2ReflectorHelper>& reflector, 74 const sp<HGraphicBufferProducer>& base, 75 const sp<GraphicBufferSource>& source); 76 77 virtual ~InputSurface() override = default; 78 79 friend struct ComponentStore; 80 81 }; 82 83 84 } // namespace utils 85 } // namespace V1_0 86 } // namespace c2 87 } // namespace media 88 } // namespace hardware 89 } // namespace android 90 91 #endif // CODEC2_HIDL_V1_0_UTILS_INPUTSURFACE_H 92