blob: 1891eda1a5c4c36072afa1a456e129caccdae788 [file] [log] [blame]
Girish0ac5c212023-11-23 09:14:03 +00001/*
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_DEFAULTRESOURCEMODEL_H_
19#define ANDROID_MEDIA_DEFAULTRESOURCEMODEL_H_
20
21#include "IResourceModel.h"
22
23namespace android {
24
25class ResourceTracker;
26
27/*
28 * Implements the Default Resource Model that handles:
29 * - coexistence of secure codec with another secure/non-secure codecs
30 * - sharing resources among other codecs
31 */
32class DefaultResourceModel : public IResourceModel {
33public:
34 DefaultResourceModel(const std::shared_ptr<ResourceTracker>& resourceTracker,
35 bool supportsMultipleSecureCodecs = true,
36 bool supportsSecureWithNonSecureCodec = true);
37 virtual ~DefaultResourceModel();
38
39 /*
40 * Set the codec co-existence properties
41 */
42 void config(bool supportsMultipleSecureCodecs, bool supportsSecureWithNonSecureCodec) {
43 mSupportsMultipleSecureCodecs = supportsMultipleSecureCodecs;
44 mSupportsSecureWithNonSecureCodec = supportsSecureWithNonSecureCodec;
45 }
46
47 /*
48 * Get a list of all clients that holds the resources requested.
49 * This implementation uses the ResourceModel to select the clients.
50 *
51 * @param[in] reclaimRequestInfo Information about the Reclaim request
52 * @param[out] cliens The list of clients that hold the resources in question.
53 *
54 * @return true if there aren't any resource conflicts and false otherwise.
55 */
56 bool getAllClients(const ReclaimRequestInfo& reclaimRequestInfo,
57 std::vector<ClientInfo>& clients) override;
58
59protected:
60 bool getCodecClients(const ReclaimRequestInfo& reclaimRequestInfo,
61 std::vector<ClientInfo>& clients);
62
63protected:
64 // Keeping these protected to allow extending this implementation
65 // by other resource models.
66 bool mSupportsMultipleSecureCodecs;
67 bool mSupportsSecureWithNonSecureCodec;
68 std::shared_ptr<ResourceTracker> mResourceTracker;
69};
70
71} // namespace android
72
73#endif // ANDROID_MEDIA_DEFAULTRESOURCEMODEL_H_