1 /*
2  * Copyright (C) 2023 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 #pragma once
18 
19 #include <stdint.h>
20 #include <map>
21 
22 #include <aidl/android/hardware/camera/device/StreamBuffer.h>
23 
24 #include "CachedStreamBuffer.h"
25 
26 namespace android {
27 namespace hardware {
28 namespace camera {
29 namespace provider {
30 namespace implementation {
31 
32 using aidl::android::hardware::camera::device::StreamBuffer;
33 
34 struct StreamBufferCache {
35     StreamBufferCache() = default;
36     CachedStreamBuffer* update(const StreamBuffer& sb);
37     void remove(int64_t bufferId);
38     void clearStreamInfo();
39 
40 private:
41     // std::map is to keep iterators valid after `insert`
42     std::map<int64_t, CachedStreamBuffer> mCache;
43 
44     StreamBufferCache(const StreamBufferCache&) = delete;
45     StreamBufferCache& operator=(const StreamBufferCache&) = delete;
46     StreamBufferCache(StreamBufferCache&&) = delete;
47     StreamBufferCache& operator=(StreamBufferCache&&) = delete;
48 };
49 
50 }  // namespace implementation
51 }  // namespace provider
52 }  // namespace camera
53 }  // namespace hardware
54 }  // namespace android
55