Avi Drissman | d6cdf9b | 2022-09-15 19:52:53 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_H_ |
| 6 | #define REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_H_ |
| 7 | |
| 8 | #include "base/callback_forward.h" |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 9 | |
Lambros Lambrou | ba22449 | 2021-10-28 21:46:24 | [diff] [blame] | 10 | namespace webrtc { |
| 11 | class DesktopFrame; |
| 12 | } // namespace webrtc |
| 13 | |
Joe Downing | 39d710e | 2022-08-25 20:11:45 | [diff] [blame] | 14 | namespace remoting::protocol { |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 15 | |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 16 | // An abstract interface for frame schedulers, which are responsible for |
| 17 | // scheduling when video frames are captured and for defining encoding |
| 18 | // parameters for each frame. |
Joe Downing | 87a28e1 | 2022-08-29 18:12:04 | [diff] [blame] | 19 | class WebrtcFrameScheduler { |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 20 | public: |
Lambros Lambrou | c574b8f | 2021-04-19 22:45:50 | [diff] [blame] | 21 | WebrtcFrameScheduler() = default; |
Joe Downing | 87a28e1 | 2022-08-29 18:12:04 | [diff] [blame] | 22 | virtual ~WebrtcFrameScheduler() = default; |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 23 | |
| 24 | // Starts the scheduler. |capture_callback| will be called whenever a new |
| 25 | // frame should be captured. |
Lambros Lambrou | c574b8f | 2021-04-19 22:45:50 | [diff] [blame] | 26 | virtual void Start(const base::RepeatingClosure& capture_callback) = 0; |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 27 | |
| 28 | // Pause and resumes the scheduler. |
| 29 | virtual void Pause(bool pause) = 0; |
| 30 | |
Joe Downing | 39d710e | 2022-08-25 20:11:45 | [diff] [blame] | 31 | // Called after |frame| has been captured. |frame| may be set to nullptr if |
| 32 | // the capture request failed. |
Lambros Lambrou | ba22449 | 2021-10-28 21:46:24 | [diff] [blame] | 33 | virtual void OnFrameCaptured(const webrtc::DesktopFrame* frame) = 0; |
Lambros Lambrou | 0fd556ae | 2021-11-09 17:19:49 | [diff] [blame] | 34 | |
Joe Downing | 39d710e | 2022-08-25 20:11:45 | [diff] [blame] | 35 | // Called when WebRTC requests the VideoTrackSource to provide frames at a |
| 36 | // maximum framerate. |
Lambros Lambrou | 0fd556ae | 2021-11-09 17:19:49 | [diff] [blame] | 37 | virtual void SetMaxFramerateFps(int max_framerate_fps) = 0; |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 38 | }; |
| 39 | |
Joe Downing | 39d710e | 2022-08-25 20:11:45 | [diff] [blame] | 40 | } // namespace remoting::protocol |
sergeyu | 0eaa513 | 2016-09-20 01:39:34 | [diff] [blame] | 41 | |
| 42 | #endif // REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_H_ |