tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

resource_adaptation_processor_interface.h (2389B)


      1 /*
      2 *  Copyright 2020 The WebRTC Project Authors. All rights reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_
     12 #define CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_
     13 
     14 #include <map>
     15 #include <vector>
     16 
     17 #include "api/adaptation/resource.h"
     18 #include "api/scoped_refptr.h"
     19 #include "api/video/video_adaptation_counters.h"
     20 
     21 namespace webrtc {
     22 
     23 class ResourceLimitationsListener {
     24 public:
     25  virtual ~ResourceLimitationsListener();
     26 
     27  // The limitations on a resource were changed. This does not mean the current
     28  // video restrictions have changed.
     29  virtual void OnResourceLimitationChanged(
     30      scoped_refptr<Resource> resource,
     31      const std::map<scoped_refptr<Resource>, VideoAdaptationCounters>&
     32          resource_limitations) = 0;
     33 };
     34 
     35 // The Resource Adaptation Processor is responsible for reacting to resource
     36 // usage measurements (e.g. overusing or underusing CPU). When a resource is
     37 // overused the Processor is responsible for performing mitigations in order to
     38 // consume less resources.
     39 class ResourceAdaptationProcessorInterface {
     40 public:
     41  virtual ~ResourceAdaptationProcessorInterface();
     42 
     43  virtual void AddResourceLimitationsListener(
     44      ResourceLimitationsListener* limitations_listener) = 0;
     45  virtual void RemoveResourceLimitationsListener(
     46      ResourceLimitationsListener* limitations_listener) = 0;
     47  // Starts or stops listening to resources, effectively enabling or disabling
     48  // processing. May be called from anywhere.
     49  // TODO(https://crbug.com/webrtc/11172): Automatically register and unregister
     50  // with AddResource() and RemoveResource() instead. When the processor is
     51  // multi-stream aware, stream-specific resouces will get added and removed
     52  // over time.
     53  virtual void AddResource(scoped_refptr<Resource> resource) = 0;
     54  virtual std::vector<scoped_refptr<Resource>> GetResources() const = 0;
     55  virtual void RemoveResource(scoped_refptr<Resource> resource) = 0;
     56 };
     57 
     58 }  // namespace webrtc
     59 
     60 #endif  // CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_