xref: /aosp_15_r20/external/webrtc/api/video/video_bitrate_allocator.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2016 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 API_VIDEO_VIDEO_BITRATE_ALLOCATOR_H_
12 #define API_VIDEO_VIDEO_BITRATE_ALLOCATOR_H_
13 
14 #include "api/units/data_rate.h"
15 #include "api/video/video_bitrate_allocation.h"
16 
17 namespace webrtc {
18 
19 struct VideoBitrateAllocationParameters {
20   VideoBitrateAllocationParameters(uint32_t total_bitrate_bps,
21                                    uint32_t framerate);
22   VideoBitrateAllocationParameters(DataRate total_bitrate, double framerate);
23   VideoBitrateAllocationParameters(DataRate total_bitrate,
24                                    DataRate stable_bitrate,
25                                    double framerate);
26   ~VideoBitrateAllocationParameters();
27 
28   DataRate total_bitrate;
29   DataRate stable_bitrate;
30   double framerate;
31 };
32 
33 class VideoBitrateAllocator {
34  public:
VideoBitrateAllocator()35   VideoBitrateAllocator() {}
~VideoBitrateAllocator()36   virtual ~VideoBitrateAllocator() {}
37 
38   virtual VideoBitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
39                                                uint32_t framerate);
40 
41   virtual VideoBitrateAllocation Allocate(
42       VideoBitrateAllocationParameters parameters);
43 
44   // Deprecated: Only used to work around issues with the legacy conference
45   // screenshare mode and shouldn't be needed by any subclasses.
46   virtual void SetLegacyConferenceMode(bool enabled);
47 };
48 
49 class VideoBitrateAllocationObserver {
50  public:
VideoBitrateAllocationObserver()51   VideoBitrateAllocationObserver() {}
~VideoBitrateAllocationObserver()52   virtual ~VideoBitrateAllocationObserver() {}
53 
54   virtual void OnBitrateAllocationUpdated(
55       const VideoBitrateAllocation& allocation) = 0;
56 };
57 
58 }  // namespace webrtc
59 
60 #endif  // API_VIDEO_VIDEO_BITRATE_ALLOCATOR_H_
61