1 /* 2 * Copyright (C) 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 HARDWARE_GOOGLE_MEDIA_C2_V1_0_UTILS_INPUTSURFACECONNECTION_H 18 #define HARDWARE_GOOGLE_MEDIA_C2_V1_0_UTILS_INPUTSURFACECONNECTION_H 19 20 #include <codec2/hidl/1.0/Component.h> 21 22 #include <hardware/google/media/c2/1.0/IComponent.h> 23 #include <hardware/google/media/c2/1.0/IInputSurfaceConnection.h> 24 25 #include <media/stagefright/bqhelper/GraphicBufferSource.h> 26 27 #include <hidl/HidlSupport.h> 28 #include <hidl/Status.h> 29 30 #include <C2Component.h> 31 32 #include <memory> 33 #include <mutex> 34 35 namespace hardware { 36 namespace google { 37 namespace media { 38 namespace c2 { 39 namespace V1_0 { 40 namespace utils { 41 42 using ::android::hardware::Return; 43 using ::android::hardware::Void; 44 using ::android::sp; 45 using ::android::GraphicBufferSource; 46 47 struct InputSurfaceConnection : public IInputSurfaceConnection { 48 49 virtual Return<Status> disconnect() override; 50 51 protected: 52 53 InputSurfaceConnection( 54 const sp<GraphicBufferSource>& source, 55 const std::shared_ptr<C2Component>& component); 56 57 InputSurfaceConnection( 58 const sp<GraphicBufferSource>& source, 59 const sp<IComponent>& component); 60 61 bool init(); 62 63 friend struct InputSurface; 64 65 InputSurfaceConnection() = delete; 66 InputSurfaceConnection(const InputSurfaceConnection&) = delete; 67 void operator=(const InputSurfaceConnection&) = delete; 68 69 struct Impl; 70 71 std::mutex mMutex; 72 sp<GraphicBufferSource> mSource; 73 sp<Impl> mImpl; 74 75 virtual ~InputSurfaceConnection() override; 76 }; 77 78 } // namespace utils 79 } // namespace V1_0 80 } // namespace c2 81 } // namespace media 82 } // namespace google 83 } // namespace hardware 84 85 #endif // HARDWARE_GOOGLE_MEDIA_C2_V1_0_UTILS_INPUTSURFACECONNECTION_H 86