1 /* 2 * Copyright (C) 2020 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_MEDIA_RESOURCE_POLICY_INTERFACE_H 18 #define ANDROID_MEDIA_RESOURCE_POLICY_INTERFACE_H 19 #include <memory> 20 namespace android { 21 22 class ResourcePolicyCallbackInterface; 23 24 // Interface for the SessionController to control the resource status updates. 25 class ResourcePolicyInterface { 26 public: 27 // Set the associated callback interface to send the events when resource 28 // status changes. (Set to nullptr will stop the updates.) 29 virtual void setCallback(const std::shared_ptr<ResourcePolicyCallbackInterface>& cb) = 0; 30 virtual void setPidResourceLost(pid_t pid) = 0; 31 32 protected: 33 virtual ~ResourcePolicyInterface() = default; 34 }; 35 36 // Interface for notifying the SessionController of a change in resource status. 37 class ResourcePolicyCallbackInterface { 38 public: 39 // Called when codec resources become available. The controller may use this 40 // as a signal to attempt restart transcoding sessions that were previously 41 // paused due to temporary resource loss. 42 virtual void onResourceAvailable() = 0; 43 44 protected: 45 virtual ~ResourcePolicyCallbackInterface() = default; 46 }; 47 48 } // namespace android 49 #endif // ANDROID_MEDIA_RESOURCE_POLICY_INTERFACE_H 50