This CL adds Resource, ResourceConsumer, ResourceConsumerConfiguration and ResourceAdaptationProcessor and implements the algorithm outlined in https://docs.google.com/presentation/d/13jyqCWNpIa873iKT6yDuB5Q5ma-c0CvxBpX--0tCclY/edit?usp=sharing. Simply put, if any resource (such as "CPU") is overusing, the most expensive consumer (e.g. encoded stream) is adapted one step down. If all resources are underusing, the least expensive consumer is adapted one step up. The current resources, consumers and configurations are all fakes; this CL has no effect on the current adaptation algorithms used in practise, but it lays down the foundation for future work in this area. Bug: webrtc:11167, webrtc:11168, webrtc:11169 Change-Id: I4054ec7728a52a49e137eee6fa67fa27debd9254 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161237 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30053}
59 lines
2.0 KiB
C++
59 lines
2.0 KiB
C++
/*
|
|
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef CALL_ADAPTATION_RESOURCE_H_
|
|
#define CALL_ADAPTATION_RESOURCE_H_
|
|
|
|
#include <string>
|
|
|
|
namespace webrtc {
|
|
|
|
enum class ResourceUsageState {
|
|
// Action is needed to minimze the load on this resource.
|
|
kOveruse,
|
|
// No action needed for this resource, increasing the load on this resource
|
|
// is not allowed.
|
|
kStable,
|
|
// Increasing the load on this resource is allowed.
|
|
kUnderuse,
|
|
};
|
|
|
|
// A Resource is something which can be measured as "overused", "stable" or
|
|
// "underused". For example, if we are overusing CPU we may need to lower the
|
|
// resolution of one of the streams. In other words, one of the ResourceConumers
|
|
// - representing an encoder - needs to be reconfigured with a different
|
|
// ResourceConsumerConfiguration - representing a different encoder setting.
|
|
//
|
|
// This is an abstract class used by the ResourceAdaptationProcessor to make
|
|
// decisions about which configurations to use. How a resource is measured or
|
|
// what measurements map to different ResourceUsageState values is
|
|
// implementation-specific.
|
|
class Resource {
|
|
public:
|
|
virtual ~Resource();
|
|
|
|
// Informational, not formally part of the decision-making process.
|
|
virtual std::string Name() const = 0;
|
|
virtual std::string UsageUnitsOfMeasurement() const = 0;
|
|
// Valid ranges are implementation-specific.
|
|
virtual double CurrentUsage() const = 0;
|
|
|
|
// The current usage state of this resource. Used by the
|
|
// ResourceAdaptationProcessor to calculate the desired consumer
|
|
// configurations.
|
|
virtual ResourceUsageState CurrentUsageState() const = 0;
|
|
|
|
std::string ToString() const;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // CALL_ADAPTATION_RESOURCE_H_
|