• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "absl/types/optional.h"
18 #include "api/adaptation/resource.h"
19 #include "api/rtp_parameters.h"
20 #include "api/scoped_refptr.h"
21 #include "api/task_queue/task_queue_base.h"
22 #include "api/video/video_adaptation_counters.h"
23 #include "api/video/video_frame.h"
24 #include "call/adaptation/adaptation_constraint.h"
25 #include "call/adaptation/adaptation_listener.h"
26 #include "call/adaptation/encoder_settings.h"
27 #include "call/adaptation/video_source_restrictions.h"
28 
29 namespace webrtc {
30 
31 class ResourceLimitationsListener {
32  public:
33   virtual ~ResourceLimitationsListener();
34 
35   // The limitations on a resource were changed. This does not mean the current
36   // video restrictions have changed.
37   virtual void OnResourceLimitationChanged(
38       rtc::scoped_refptr<Resource> resource,
39       const std::map<rtc::scoped_refptr<Resource>, VideoAdaptationCounters>&
40           resource_limitations) = 0;
41 };
42 
43 // The Resource Adaptation Processor is responsible for reacting to resource
44 // usage measurements (e.g. overusing or underusing CPU). When a resource is
45 // overused the Processor is responsible for performing mitigations in order to
46 // consume less resources.
47 class ResourceAdaptationProcessorInterface {
48  public:
49   virtual ~ResourceAdaptationProcessorInterface();
50 
51   virtual void SetResourceAdaptationQueue(
52       TaskQueueBase* resource_adaptation_queue) = 0;
53 
54   virtual void AddResourceLimitationsListener(
55       ResourceLimitationsListener* limitations_listener) = 0;
56   virtual void RemoveResourceLimitationsListener(
57       ResourceLimitationsListener* limitations_listener) = 0;
58   // Starts or stops listening to resources, effectively enabling or disabling
59   // processing. May be called from anywhere.
60   // TODO(https://crbug.com/webrtc/11172): Automatically register and unregister
61   // with AddResource() and RemoveResource() instead. When the processor is
62   // multi-stream aware, stream-specific resouces will get added and removed
63   // over time.
64   virtual void AddResource(rtc::scoped_refptr<Resource> resource) = 0;
65   virtual std::vector<rtc::scoped_refptr<Resource>> GetResources() const = 0;
66   virtual void RemoveResource(rtc::scoped_refptr<Resource> resource) = 0;
67 };
68 
69 }  // namespace webrtc
70 
71 #endif  // CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_
72