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