blob: febb21bf0279556025297206ed9e53104235de9d [file] [log] [blame]
Sungtak Lee8fc3ca42022-12-07 07:45:45 +00001/*
Sungtak Lee76937c62022-12-07 11:42:03 +00002 * Copyright (C) 2022 The Android Open Source Project
Sungtak Lee8fc3ca42022-12-07 07:45:45 +00003 *
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 Lee76937c62022-12-07 11:42:03 +000017#pragma once
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000018
Sungtak Lee76937c62022-12-07 11:42:03 +000019#include <map>
20#include <memory>
21#include <mutex>
22#include <aidl/android/hardware/media/bufferpool2/BnObserver.h>
23#include <bufferpool2/BufferPoolTypes.h>
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000024
Sungtak Lee76937c62022-12-07 11:42:03 +000025namespace aidl::android::hardware::media::bufferpool2::implementation {
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000026
Sungtak Lee76937c62022-12-07 11:42:03 +000027class BufferPoolClient;
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000028
Sungtak Lee76937c62022-12-07 11:42:03 +000029struct Observer : public BnObserver {
30 ::ndk::ScopedAStatus onMessage(int64_t in_connectionId, int32_t in_msgId) override;
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000031
32 ~Observer();
33
34 void addClient(ConnectionId connectionId,
35 const std::weak_ptr<BufferPoolClient> &wclient);
36
37 void delClient(ConnectionId connectionId);
38
39private:
40 Observer();
41
Sungtak Lee76937c62022-12-07 11:42:03 +000042 friend class ::ndk::SharedRefBase;
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000043
44 std::mutex mLock;
45 std::map<ConnectionId, const std::weak_ptr<BufferPoolClient>> mClients;
46};
47
Sungtak Lee76937c62022-12-07 11:42:03 +000048} // namespace aidl::android::hardware::media::bufferpool2::implementation
Sungtak Lee8fc3ca42022-12-07 07:45:45 +000049