blob: 42bd7c1325beb8e8ec321eba12fdb212a681dcde [file] [log] [blame]
Sungtak Leec7f9e2c2018-09-14 16:23:40 -07001/*
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
25namespace android {
26namespace hardware {
27namespace media {
28namespace bufferpool {
29namespace V2_0 {
30namespace implementation {
31
32using ::android::hardware::hidl_array;
33using ::android::hardware::hidl_memory;
34using ::android::hardware::hidl_string;
35using ::android::hardware::hidl_vec;
36using ::android::hardware::Return;
37using ::android::hardware::Void;
38using ::android::sp;
39
40struct 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
51private:
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