resource_adaptation_processor_interface.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_
  11. #define CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_
  12. #include <map>
  13. #include <vector>
  14. #include "absl/types/optional.h"
  15. #include "api/adaptation/resource.h"
  16. #include "api/rtp_parameters.h"
  17. #include "api/scoped_refptr.h"
  18. #include "api/task_queue/task_queue_base.h"
  19. #include "api/video/video_adaptation_counters.h"
  20. #include "api/video/video_frame.h"
  21. #include "call/adaptation/adaptation_constraint.h"
  22. #include "call/adaptation/encoder_settings.h"
  23. #include "call/adaptation/video_source_restrictions.h"
  24. namespace webrtc {
  25. class ResourceLimitationsListener {
  26. public:
  27. virtual ~ResourceLimitationsListener();
  28. // The limitations on a resource were changed. This does not mean the current
  29. // video restrictions have changed.
  30. virtual void OnResourceLimitationChanged(
  31. rtc::scoped_refptr<Resource> resource,
  32. const std::map<rtc::scoped_refptr<Resource>, VideoAdaptationCounters>&
  33. resource_limitations) = 0;
  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. virtual void SetTaskQueue(TaskQueueBase* task_queue) = 0;
  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(rtc::scoped_refptr<Resource> resource) = 0;
  54. virtual std::vector<rtc::scoped_refptr<Resource>> GetResources() const = 0;
  55. virtual void RemoveResource(rtc::scoped_refptr<Resource> resource) = 0;
  56. };
  57. } // namespace webrtc
  58. #endif // CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_