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_INPUTSURFACECONNECTION_H 18 #define CODEC2_HIDL_V1_0_UTILS_INPUTSURFACECONNECTION_H 19 20 #include <codec2/hidl/1.0/Component.h> 21 #include <codec2/hidl/1.0/Configurable.h> 22 23 #include <android/hardware/media/c2/1.0/IComponent.h> 24 #include <android/hardware/media/c2/1.0/IConfigurable.h> 25 #include <android/hardware/media/c2/1.0/IInputSurfaceConnection.h> 26 27 #include <media/stagefright/bqhelper/GraphicBufferSource.h> 28 29 #include <hidl/HidlSupport.h> 30 #include <hidl/Status.h> 31 32 #include <C2Component.h> 33 34 #include <memory> 35 #include <mutex> 36 37 namespace android { 38 namespace hardware { 39 namespace media { 40 namespace c2 { 41 namespace V1_0 { 42 namespace utils { 43 44 using ::android::hardware::Return; 45 using ::android::hardware::Void; 46 using ::android::sp; 47 using ::android::GraphicBufferSource; 48 49 // An InputSurfaceConnection connects an InputSurface to a sink, which may be an 50 // IInputSink or a local C2Component. This can be specified by choosing the 51 // corresponding constructor. The reason for distinguishing these two cases is 52 // that when an InputSurfaceConnection lives in the same process as the 53 // component that processes the buffers, data parceling is not needed. 54 struct InputSurfaceConnection : public IInputSurfaceConnection { 55 56 virtual Return<Status> disconnect() override; 57 58 virtual Return<sp<IConfigurable>> getConfigurable() override; 59 60 protected: 61 62 InputSurfaceConnection( 63 const sp<GraphicBufferSource>& source, 64 const std::shared_ptr<C2Component>& comp, 65 const sp<ComponentStore>& store); 66 67 InputSurfaceConnection( 68 const sp<GraphicBufferSource>& source, 69 const sp<IInputSink>& sink, 70 const sp<ComponentStore>& store); 71 72 bool init(); 73 74 friend struct InputSurface; 75 76 InputSurfaceConnection() = delete; 77 InputSurfaceConnection(const InputSurfaceConnection&) = delete; 78 void operator=(const InputSurfaceConnection&) = delete; 79 80 struct Impl; 81 82 std::mutex mImplMutex; 83 sp<Impl> mImpl; 84 sp<CachedConfigurable> mConfigurable; 85 86 virtual ~InputSurfaceConnection() override; 87 }; 88 89 } // namespace utils 90 } // namespace V1_0 91 } // namespace c2 92 } // namespace media 93 } // namespace hardware 94 } // namespace android 95 96 #endif // CODEC2_HIDL_V1_0_UTILS_INPUTSURFACECONNECTION_H 97