1 /*
2 **
3 ** Copyright 2023, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 #ifndef ANDROID_MEDIA_IRESOURCEMODEL_H_
19 #define ANDROID_MEDIA_IRESOURCEMODEL_H_
20 
21 #include <memory>
22 #include <vector>
23 
24 #include <aidl/android/media/IResourceManagerClient.h>
25 #include <aidl/android/media/MediaResourceParcel.h>
26 
27 namespace android {
28 
29 struct ClientInfo;
30 struct ReclaimRequestInfo;
31 
32 /*
33  * Interface that defines Resource Model.
34  *
35  * This provides an interface that manages the resource model.
36  * The primary functionality of the implementation of this resource model is to:
37  *  1. Define a resource model for a device (or family of devices)
38  *    For example (and not limited to):
39  *      - Can a secure codec coexist with another secure or unsecured codec?
40  *      - How many codecs can coexist?
41  *      - Can one type of codecs (for example avc) coexist with another type of codec
42  *        (for example hevc) independently? OR are they sharing the common
43  *        resource pool?
44  *  2. Provide a list of clients that hold requesting resources.
45  */
46 class IResourceModel {
47 public:
IResourceModel()48     IResourceModel() {}
49 
~IResourceModel()50     virtual ~IResourceModel() {}
51 
52     /*
53      * Get a list of all clients that holds the resources requested.
54      * This implementation uses the ResourceModel to select the clients.
55      *
56      * @param[in]  reclaimRequestInfo Information about the Reclaim request
57      * @param[out] clients The list of clients that hold the resources in question.
58      *
59      * @return true if there aren't any resource conflicts and false otherwise.
60      */
61     virtual bool getAllClients(const ReclaimRequestInfo& reclaimRequestInfo,
62                                std::vector<ClientInfo>& clients) = 0;
63 };
64 
65 } // namespace android
66 
67 #endif  // ANDROID_MEDIA_IRESOURCEMODEL_H_
68