Skip to content

Commit

Permalink
Exposing video bitrate allocator into API
Browse files Browse the repository at this point in the history
In order to have public video bitrate allocator factory, the video bitrate allocator has be part of
the api.

Bug: webrtc:9513
Change-Id: Ia2e5ab9eb988c710c1ac492afccc470a92544aa2
Reviewed-on: https://webrtc-review.googlesource.com/88083
Reviewed-by: Stefan Holmer <[email protected]>
Reviewed-by: Rasmus Brandt <[email protected]>
Reviewed-by: Erik Språng <[email protected]>
Commit-Queue: Jiawei Ou <[email protected]>
Cr-Commit-Position: refs/heads/master@{#24073}
  • Loading branch information
Jiawei Ou authored and Commit Bot committed Jul 23, 2018
1 parent f7a64ec commit 4206a0a
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 36 deletions.
12 changes: 12 additions & 0 deletions api/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,18 @@ if (rtc_include_tests) {
]
}

rtc_source_set("mock_video_bitrate_allocator") {
testonly = true
sources = [
"test/mock_video_bitrate_allocator.h",
]

deps = [
"../api/video:video_bitrate_allocator",
"../test:test_support",
]
}

rtc_source_set("mock_video_codec_factory") {
testonly = true
sources = [
Expand Down
28 changes: 28 additions & 0 deletions api/test/mock_video_bitrate_allocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#ifndef API_TEST_MOCK_VIDEO_BITRATE_ALLOCATOR_H_
#define API_TEST_MOCK_VIDEO_BITRATE_ALLOCATOR_H_

#include "api/video/video_bitrate_allocator.h"
#include "test/gmock.h"

namespace webrtc {

class MockVideoBitrateAllocator : public webrtc::VideoBitrateAllocator {
MOCK_METHOD2(GetAllocation,
VideoBitrateAllocation(uint32_t total_bitrate,
uint32_t framerate));
MOCK_METHOD1(GetPreferredBitrateBps, uint32_t(uint32_t framerate));
};

} // namespace webrtc

#endif // API_TEST_MOCK_VIDEO_BITRATE_ALLOCATOR_H_
10 changes: 10 additions & 0 deletions api/video/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ rtc_source_set("video_bitrate_allocation") {
]
}

rtc_source_set("video_bitrate_allocator") {
visibility = [ "*" ]
sources = [
"video_bitrate_allocator.h",
]
deps = [
":video_bitrate_allocation",
]
}

rtc_source_set("video_stream_decoder") {
visibility = [ "*" ]
sources = [
Expand Down
38 changes: 38 additions & 0 deletions api/video/video_bitrate_allocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#ifndef API_VIDEO_VIDEO_BITRATE_ALLOCATOR_H_
#define API_VIDEO_VIDEO_BITRATE_ALLOCATOR_H_

#include "api/video/video_bitrate_allocation.h"

namespace webrtc {

class VideoBitrateAllocator {
public:
VideoBitrateAllocator() {}
virtual ~VideoBitrateAllocator() {}

virtual VideoBitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
uint32_t framerate) = 0;
};

class VideoBitrateAllocationObserver {
public:
VideoBitrateAllocationObserver() {}
virtual ~VideoBitrateAllocationObserver() {}

virtual void OnBitrateAllocationUpdated(
const VideoBitrateAllocation& allocation) = 0;
};

} // namespace webrtc

#endif // API_VIDEO_VIDEO_BITRATE_ALLOCATOR_H_
1 change: 1 addition & 0 deletions common_video/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rtc_static_library("common_video") {
"..:webrtc_common",
"../:typedefs",
"../api/video:video_bitrate_allocation",
"../api/video:video_bitrate_allocator",
"../api/video:video_frame",
"../api/video:video_frame_i420",
"../media:rtc_h264_profile_id",
Expand Down
24 changes: 1 addition & 23 deletions common_video/include/video_bitrate_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@
#ifndef COMMON_VIDEO_INCLUDE_VIDEO_BITRATE_ALLOCATOR_H_
#define COMMON_VIDEO_INCLUDE_VIDEO_BITRATE_ALLOCATOR_H_

#include "api/video/video_bitrate_allocation.h"

namespace webrtc {

class VideoBitrateAllocator {
public:
VideoBitrateAllocator() {}
virtual ~VideoBitrateAllocator() {}

virtual VideoBitrateAllocation GetAllocation(uint32_t total_bitrate,
uint32_t framerate) = 0;
};

class VideoBitrateAllocationObserver {
public:
VideoBitrateAllocationObserver() {}
virtual ~VideoBitrateAllocationObserver() {}

virtual void OnBitrateAllocationUpdated(
const VideoBitrateAllocation& allocation) = 0;
};

} // namespace webrtc
#include "api/video/video_bitrate_allocator.h"

#endif // COMMON_VIDEO_INCLUDE_VIDEO_BITRATE_ALLOCATOR_H_
2 changes: 2 additions & 0 deletions modules/rtp_rtcp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ rtc_static_library("rtp_rtcp") {
"../../api:transport_api",
"../../api/audio_codecs:audio_codecs_api",
"../../api/video:video_bitrate_allocation",
"../../api/video:video_bitrate_allocator",
"../../api/video_codecs:video_codecs_api",
"../../common_video",
"../../logging:rtc_event_audio",
Expand Down Expand Up @@ -426,6 +427,7 @@ if (rtc_include_tests) {
"../../api:libjingle_peerconnection_api",
"../../api:transport_api",
"../../api/video:video_bitrate_allocation",
"../../api/video:video_bitrate_allocator",
"../../api/video:video_frame",
"../../api/video_codecs:video_codecs_api",
"../../call:rtp_receiver",
Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/rtcp_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <vector>

#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_bitrate_allocator.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h"
#include "modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#include "api/array_view.h"
#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_bitrate_allocator.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtcp_packet.h"
Expand Down
5 changes: 5 additions & 0 deletions modules/video_coding/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ rtc_static_library("video_coding") {
"../../:typedefs",
"../../api:fec_controller_api",
"../../api/video:encoded_frame",
"../../api/video:video_bitrate_allocator",
"../../api/video:video_frame",
"../../api/video:video_frame_i420",
"../../api/video_codecs:video_codecs_api",
Expand Down Expand Up @@ -261,6 +262,7 @@ rtc_source_set("video_coding_utility") {
"..:module_api",
"../..:webrtc_common",
"../../:typedefs",
"../../api/video:video_bitrate_allocator",
"../../api/video_codecs:video_codecs_api",
"../../common_video",
"../../modules/rtp_rtcp",
Expand Down Expand Up @@ -445,6 +447,7 @@ rtc_static_library("webrtc_vp9_helpers") {
deps = [
":video_codec_interface",
"../..:webrtc_common",
"../../api/video:video_bitrate_allocator",
"../../api/video_codecs:video_codecs_api",
"../../common_video",
"../../rtc_base:checks",
Expand Down Expand Up @@ -596,6 +599,7 @@ if (rtc_include_tests) {
"../..:webrtc_common",
"../../:typedefs",
"../../api:videocodec_test_fixture_api",
"../../api/video:video_bitrate_allocator",
"../../api/video:video_frame",
"../../api/video:video_frame_i420",
"../../api/video_codecs:video_codecs_api",
Expand Down Expand Up @@ -834,6 +838,7 @@ if (rtc_include_tests) {
"../../api:create_simulcast_test_fixture_api",
"../../api:simulcast_test_fixture_api",
"../../api:videocodec_test_fixture_api",
"../../api/video:video_bitrate_allocator",
"../../api/video:video_frame",
"../../api/video:video_frame_i420",
"../../api/video_codecs:video_codecs_api",
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/codecs/test/videoprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include "api/test/videocodec_test_fixture.h"
#include "api/test/videocodec_test_stats.h"
#include "api/video/video_bitrate_allocator.h"
#include "api/video/video_frame.h"
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
#include "rtc_base/buffer.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/codecs/vp9/svc_rate_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include <vector>

#include "api/video/video_bitrate_allocator.h"
#include "api/video_codecs/video_codec.h"
#include "common_video/include/video_bitrate_allocator.h"

namespace webrtc {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#ifndef MODULES_VIDEO_CODING_UTILITY_DEFAULT_VIDEO_BITRATE_ALLOCATOR_H_
#define MODULES_VIDEO_CODING_UTILITY_DEFAULT_VIDEO_BITRATE_ALLOCATOR_H_

#include "api/video/video_bitrate_allocator.h"
#include "api/video_codecs/video_codec.h"
#include "common_video/include/video_bitrate_allocator.h"

namespace webrtc {

Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/utility/simulcast_rate_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <memory>
#include <vector>

#include "api/video/video_bitrate_allocator.h"
#include "api/video_codecs/video_encoder.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "rtc_base/constructormagic.h"

namespace webrtc {
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/video_codec_initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "modules/video_coding/include/video_codec_initializer.h"

#include "api/video/video_bitrate_allocator.h"
#include "api/video_codecs/video_encoder.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/video_coding/codecs/vp9/svc_config.h"
#include "modules/video_coding/codecs/vp9/svc_rate_allocator.h"
#include "modules/video_coding/include/video_coding_defines.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/video_codec_initializer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/

#include "modules/video_coding/include/video_codec_initializer.h"
#include "api/video/video_bitrate_allocator.h"
#include "api/video_codecs/video_encoder.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/video_coding/codecs/vp8/temporal_layers.h"
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
#include "rtc_base/refcountedobject.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/video_coding_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include <algorithm>
#include <utility>

#include "api/video/video_bitrate_allocator.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_coding/encoded_frame.h"
#include "modules/video_coding/include/video_codec_initializer.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/video_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#include <algorithm> // std::max

#include "api/video/video_bitrate_allocator.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_coding/encoded_frame.h"
#include "modules/video_coding/include/video_codec_interface.h"
Expand Down
1 change: 1 addition & 0 deletions video/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ rtc_static_library("video") {
"../api:fec_controller_api",
"../api:libjingle_peerconnection_api",
"../api:transport_api",
"../api/video:video_bitrate_allocator",
"../api/video:video_frame",
"../api/video:video_frame_i420",
"../api/video:video_stream_encoder",
Expand Down
2 changes: 1 addition & 1 deletion video/video_send_stream_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <unordered_set>
#include <vector>

#include "api/video/video_bitrate_allocator.h"
#include "call/bitrate_allocator.h"
#include "call/rtp_video_sender_interface.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/utility/include/process_thread.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
#include "rtc_base/weak_ptr.h"
Expand Down
2 changes: 1 addition & 1 deletion video/video_stream_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <utility>

#include "api/video/i420_buffer.h"
#include "common_video/include/video_bitrate_allocator.h"
#include "api/video/video_bitrate_allocator.h"
#include "common_video/include/video_frame.h"
#include "modules/video_coding/include/video_codec_initializer.h"
#include "modules/video_coding/include/video_coding.h"
Expand Down
2 changes: 1 addition & 1 deletion video/video_stream_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <string>
#include <vector>

#include "api/video/video_bitrate_allocator.h"
#include "api/video/video_rotation.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_stream_encoder_interface.h"
#include "api/video_codecs/video_encoder.h"
#include "call/video_send_stream.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/include/video_bitrate_allocator.h"
#include "modules/video_coding/include/video_coding_defines.h"
#include "modules/video_coding/utility/quality_scaler.h"
#include "modules/video_coding/video_coding_impl.h"
Expand Down

0 comments on commit 4206a0a

Please sign in to comment.