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 ANDROID_HARDWARE_MEDIA_BUFFERPOOL_V2_0_OBSERVER_H 18 #define ANDROID_HARDWARE_MEDIA_BUFFERPOOL_V2_0_OBSERVER_H 19 20 #include <android/hardware/media/bufferpool/2.0/IObserver.h> 21 #include <hidl/MQDescriptor.h> 22 #include <hidl/Status.h> 23 #include "BufferPoolClient.h" 24 25 namespace android { 26 namespace hardware { 27 namespace media { 28 namespace bufferpool { 29 namespace V2_0 { 30 namespace implementation { 31 32 using ::android::hardware::hidl_array; 33 using ::android::hardware::hidl_memory; 34 using ::android::hardware::hidl_string; 35 using ::android::hardware::hidl_vec; 36 using ::android::hardware::Return; 37 using ::android::hardware::Void; 38 using ::android::sp; 39 40 struct Observer : public IObserver { 41 // Methods from ::android::hardware::media::bufferpool::V2_0::IObserver follow. 42 Return<void> onMessage(int64_t connectionId, uint32_t msgId) override; 43 44 ~Observer(); 45 46 void addClient(ConnectionId connectionId, 47 const std::weak_ptr<BufferPoolClient> &wclient); 48 49 void delClient(ConnectionId connectionId); 50 51 private: 52 Observer(); 53 54 friend struct ClientManager; 55 56 std::mutex mLock; 57 std::map<ConnectionId, const std::weak_ptr<BufferPoolClient>> mClients; 58 }; 59 60 } // namespace implementation 61 } // namespace V2_0 62 } // namespace bufferpool 63 } // namespace media 64 } // namespace hardware 65 } // namespace android 66 67 #endif // ANDROID_HARDWARE_MEDIA_BUFFERPOOL_V2_0_OBSERVER_H 68