Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 1 | /* |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 2 | * Copyright (C) 2022 The Android Open Source Project |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 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 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 17 | #pragma once |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 18 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 19 | #include <map> |
| 20 | #include <memory> |
| 21 | #include <mutex> |
| 22 | #include <aidl/android/hardware/media/bufferpool2/BnObserver.h> |
| 23 | #include <bufferpool2/BufferPoolTypes.h> |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 24 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 25 | namespace aidl::android::hardware::media::bufferpool2::implementation { |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 26 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 27 | class BufferPoolClient; |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 28 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 29 | struct Observer : public BnObserver { |
| 30 | ::ndk::ScopedAStatus onMessage(int64_t in_connectionId, int32_t in_msgId) override; |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 31 | |
| 32 | ~Observer(); |
| 33 | |
| 34 | void addClient(ConnectionId connectionId, |
| 35 | const std::weak_ptr<BufferPoolClient> &wclient); |
| 36 | |
| 37 | void delClient(ConnectionId connectionId); |
| 38 | |
| 39 | private: |
| 40 | Observer(); |
| 41 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 42 | friend class ::ndk::SharedRefBase; |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 43 | |
| 44 | std::mutex mLock; |
| 45 | std::map<ConnectionId, const std::weak_ptr<BufferPoolClient>> mClients; |
| 46 | }; |
| 47 | |
Sungtak Lee | 8878a13 | 2022-12-07 11:42:03 +0000 | [diff] [blame^] | 48 | } // namespace aidl::android::hardware::media::bufferpool2::implementation |
Sungtak Lee | 97e1dfb | 2022-12-07 07:45:45 +0000 | [diff] [blame] | 49 | |