video_stream_encoder_resource.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_H_
  11. #define VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_H_
  12. #include <string>
  13. #include <vector>
  14. #include "absl/types/optional.h"
  15. #include "api/adaptation/resource.h"
  16. #include "api/task_queue/task_queue_base.h"
  17. #include "call/adaptation/adaptation_constraint.h"
  18. #include "rtc_base/synchronization/mutex.h"
  19. #include "rtc_base/synchronization/sequence_checker.h"
  20. namespace webrtc {
  21. class VideoStreamEncoderResource : public Resource {
  22. public:
  23. ~VideoStreamEncoderResource() override;
  24. // Registering task queues must be performed as part of initialization.
  25. void RegisterEncoderTaskQueue(TaskQueueBase* encoder_queue);
  26. // Resource implementation.
  27. std::string Name() const override;
  28. void SetResourceListener(ResourceListener* listener) override;
  29. protected:
  30. explicit VideoStreamEncoderResource(std::string name);
  31. void OnResourceUsageStateMeasured(ResourceUsageState usage_state);
  32. // The caller is responsible for ensuring the task queue is still valid.
  33. TaskQueueBase* encoder_queue() const;
  34. private:
  35. mutable Mutex lock_;
  36. const std::string name_;
  37. // Treated as const after initialization.
  38. TaskQueueBase* encoder_queue_;
  39. ResourceListener* listener_ RTC_GUARDED_BY(lock_);
  40. };
  41. } // namespace webrtc
  42. #endif // VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_H_