webrtc_m130/common_types.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

236 lines
6.8 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 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.
*/
#include "common_types.h" // NOLINT(build/include)
#include <string.h>
#include <algorithm>
#include <limits>
#include <type_traits>
#include "rtc_base/checks.h"
#include "rtc_base/stringutils.h"
namespace webrtc {
VideoCodec::VideoCodec()
: codecType(kVideoCodecUnknown),
plName(),
plType(0),
width(0),
height(0),
startBitrate(0),
maxBitrate(0),
minBitrate(0),
targetBitrate(0),
maxFramerate(0),
active(true),
qpMax(0),
numberOfSimulcastStreams(0),
simulcastStream(),
spatialLayers(),
mode(kRealtimeVideo),
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
expect_encode_from_texture(false),
timing_frame_thresholds({0, 0}),
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
codec_specific_() {}
VideoCodecVP8* VideoCodec::VP8() {
RTC_DCHECK_EQ(codecType, kVideoCodecVP8);
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
return &codec_specific_.VP8;
}
const VideoCodecVP8& VideoCodec::VP8() const {
RTC_DCHECK_EQ(codecType, kVideoCodecVP8);
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
return codec_specific_.VP8;
}
VideoCodecVP9* VideoCodec::VP9() {
RTC_DCHECK_EQ(codecType, kVideoCodecVP9);
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
return &codec_specific_.VP9;
}
const VideoCodecVP9& VideoCodec::VP9() const {
RTC_DCHECK_EQ(codecType, kVideoCodecVP9);
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
return codec_specific_.VP9;
}
VideoCodecH264* VideoCodec::H264() {
RTC_DCHECK_EQ(codecType, kVideoCodecH264);
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
return &codec_specific_.H264;
}
const VideoCodecH264& VideoCodec::H264() const {
RTC_DCHECK_EQ(codecType, kVideoCodecH264);
Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491613005/ ) Reason for revert: More downstream issues fixed again. Original issue's description: > Revert of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2494683006/ ) > > Reason for revert: > Another downstream error. > > Original issue's description: > > Reland of Declare VideoCodec.codec_specific_info private (patchset #1 id:1 of https://codereview.webrtc.org/2491933002/ ) > > > > Reason for revert: > > Relanding, now that downstream issues have been fixed. > > > > Original issue's description: > > > Revert of Declare VideoCodec.codec_specific_info private (patchset #5 id:80001 of https://codereview.webrtc.org/2452963002/ ) > > > > > > Reason for revert: > > > Broke a google3 build > > > > > > Original issue's description: > > > > Declare VideoCodec.codec_specific_info private > > > > > > > > This completes the privatization of the codec specific > > > > information in VideoCodec. > > > > > > > > BUG=webrtc:6603 > > > > > > > > Committed: https://crrev.com/792738640234d81c916ac4458ac72286cb2548a4 > > > > Cr-Commit-Position: refs/heads/master@{#15013} > > > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:6603 > > > > > > Committed: https://crrev.com/7fe6db91d99cf6d43874651bcca56092cf869e2f > > > Cr-Commit-Position: refs/heads/master@{#15027} > > > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > > # Skipping CQ checks because original CL landed less than 1 days ago. > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > BUG=webrtc:6603 > > > > Committed: https://crrev.com/c63fb3a0d3b9b2081a6a5e6e238d8ee595dca2a2 > > Cr-Commit-Position: refs/heads/master@{#15041} > > TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6603 > > Committed: https://crrev.com/281459896124685d355d37388ee2290b55015594 > Cr-Commit-Position: refs/heads/master@{#15042} TBR=tommi@chromium.org,magjed@chromium.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6603 Review-Url: https://codereview.webrtc.org/2508853002 Cr-Commit-Position: refs/heads/master@{#15117}
2016-11-16 23:23:04 -08:00
return codec_specific_.H264;
}
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
static const char* kPayloadNameVp8 = "VP8";
static const char* kPayloadNameVp9 = "VP9";
static const char* kPayloadNameH264 = "H264";
static const char* kPayloadNameI420 = "I420";
static const char* kPayloadNameRED = "RED";
static const char* kPayloadNameULPFEC = "ULPFEC";
static const char* kPayloadNameGeneric = "Generic";
Revert "Reland "Rename stereo video codec to multiplex"" This reverts commit 4954a77cf81e6793245f52d485834acd3e6eab1c. Reason for revert: Breaks downstream build which was depending on the name "kVideoCodecStereo". Will need to do some sort of trickery to make this change without breaking the relevant code. Sorry. :( Original change's description: > Reland "Rename stereo video codec to multiplex" > > This is a reland of bbdabe50db0cf09f6007dda12a6476dc4602b174. > This was reverted because of breaking internal build. I contacted sheriff > and looked at logs but cannot find anything related to this CL. This was landed > with #3850 build which caused exception, but 3847-3855 seem to all have failed. > I am relanding to see if it will work this time or it will give some related > error message that can guide me. > > Original change's description: > > Rename stereo video codec to multiplex > > > > This CL only does the rename from"stereo" to multiplex". With this we have a > > better name that doesn't clash with audio's usage of stereo. > > > > Bug: webrtc:7671 > > Change-Id: Iebc3fc20839025f1bc8bcf0e16141bf9744ef652 > > Reviewed-on: https://webrtc-review.googlesource.com/43242 > > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#21769} > > TBR=niklas.enbom@webrtc.org > > Bug: webrtc:7671 > Change-Id: I5934abad1ce28acf02842ea8ee2af7768a826eb8 > Reviewed-on: https://webrtc-review.googlesource.com/44520 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21780} TBR=sprang@webrtc.org,niklas.enbom@webrtc.org,qiangchen@chromium.org,emircan@webrtc.org Change-Id: I0a71327c2ddfdd030b1e058cd6a41b1689836719 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7671 Reviewed-on: https://webrtc-review.googlesource.com/44621 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21783}
2018-01-27 00:45:14 +00:00
static const char* kPayloadNameStereo = "Stereo";
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
static bool CodecNamesEq(const char* name1, const char* name2) {
return _stricmp(name1, name2) == 0;
}
const char* CodecTypeToPayloadString(VideoCodecType type) {
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
switch (type) {
case kVideoCodecVP8:
return kPayloadNameVp8;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
case kVideoCodecVP9:
return kPayloadNameVp9;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
case kVideoCodecH264:
return kPayloadNameH264;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
case kVideoCodecI420:
return kPayloadNameI420;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
case kVideoCodecRED:
return kPayloadNameRED;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
case kVideoCodecULPFEC:
return kPayloadNameULPFEC;
// Other codecs default to generic.
Revert "Reland "Rename stereo video codec to multiplex"" This reverts commit 4954a77cf81e6793245f52d485834acd3e6eab1c. Reason for revert: Breaks downstream build which was depending on the name "kVideoCodecStereo". Will need to do some sort of trickery to make this change without breaking the relevant code. Sorry. :( Original change's description: > Reland "Rename stereo video codec to multiplex" > > This is a reland of bbdabe50db0cf09f6007dda12a6476dc4602b174. > This was reverted because of breaking internal build. I contacted sheriff > and looked at logs but cannot find anything related to this CL. This was landed > with #3850 build which caused exception, but 3847-3855 seem to all have failed. > I am relanding to see if it will work this time or it will give some related > error message that can guide me. > > Original change's description: > > Rename stereo video codec to multiplex > > > > This CL only does the rename from"stereo" to multiplex". With this we have a > > better name that doesn't clash with audio's usage of stereo. > > > > Bug: webrtc:7671 > > Change-Id: Iebc3fc20839025f1bc8bcf0e16141bf9744ef652 > > Reviewed-on: https://webrtc-review.googlesource.com/43242 > > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#21769} > > TBR=niklas.enbom@webrtc.org > > Bug: webrtc:7671 > Change-Id: I5934abad1ce28acf02842ea8ee2af7768a826eb8 > Reviewed-on: https://webrtc-review.googlesource.com/44520 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21780} TBR=sprang@webrtc.org,niklas.enbom@webrtc.org,qiangchen@chromium.org,emircan@webrtc.org Change-Id: I0a71327c2ddfdd030b1e058cd6a41b1689836719 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7671 Reviewed-on: https://webrtc-review.googlesource.com/44621 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21783}
2018-01-27 00:45:14 +00:00
case kVideoCodecStereo:
case kVideoCodecFlexfec:
case kVideoCodecGeneric:
case kVideoCodecUnknown:
return kPayloadNameGeneric;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
}
return kPayloadNameGeneric;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
}
VideoCodecType PayloadStringToCodecType(const std::string& name) {
if (CodecNamesEq(name.c_str(), kPayloadNameVp8))
return kVideoCodecVP8;
if (CodecNamesEq(name.c_str(), kPayloadNameVp9))
return kVideoCodecVP9;
if (CodecNamesEq(name.c_str(), kPayloadNameH264))
return kVideoCodecH264;
if (CodecNamesEq(name.c_str(), kPayloadNameI420))
return kVideoCodecI420;
if (CodecNamesEq(name.c_str(), kPayloadNameRED))
return kVideoCodecRED;
if (CodecNamesEq(name.c_str(), kPayloadNameULPFEC))
return kVideoCodecULPFEC;
Revert "Reland "Rename stereo video codec to multiplex"" This reverts commit 4954a77cf81e6793245f52d485834acd3e6eab1c. Reason for revert: Breaks downstream build which was depending on the name "kVideoCodecStereo". Will need to do some sort of trickery to make this change without breaking the relevant code. Sorry. :( Original change's description: > Reland "Rename stereo video codec to multiplex" > > This is a reland of bbdabe50db0cf09f6007dda12a6476dc4602b174. > This was reverted because of breaking internal build. I contacted sheriff > and looked at logs but cannot find anything related to this CL. This was landed > with #3850 build which caused exception, but 3847-3855 seem to all have failed. > I am relanding to see if it will work this time or it will give some related > error message that can guide me. > > Original change's description: > > Rename stereo video codec to multiplex > > > > This CL only does the rename from"stereo" to multiplex". With this we have a > > better name that doesn't clash with audio's usage of stereo. > > > > Bug: webrtc:7671 > > Change-Id: Iebc3fc20839025f1bc8bcf0e16141bf9744ef652 > > Reviewed-on: https://webrtc-review.googlesource.com/43242 > > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#21769} > > TBR=niklas.enbom@webrtc.org > > Bug: webrtc:7671 > Change-Id: I5934abad1ce28acf02842ea8ee2af7768a826eb8 > Reviewed-on: https://webrtc-review.googlesource.com/44520 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21780} TBR=sprang@webrtc.org,niklas.enbom@webrtc.org,qiangchen@chromium.org,emircan@webrtc.org Change-Id: I0a71327c2ddfdd030b1e058cd6a41b1689836719 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7671 Reviewed-on: https://webrtc-review.googlesource.com/44621 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21783}
2018-01-27 00:45:14 +00:00
if (CodecNamesEq(name.c_str(), kPayloadNameStereo))
return kVideoCodecStereo;
return kVideoCodecGeneric;
}
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
const uint32_t BitrateAllocation::kMaxBitrateBps =
std::numeric_limits<uint32_t>::max();
BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{}, has_bitrate_{} {}
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
bool BitrateAllocation::SetBitrate(size_t spatial_index,
size_t temporal_index,
uint32_t bitrate_bps) {
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
RTC_CHECK_LT(temporal_index, kMaxTemporalStreams);
RTC_CHECK_LE(bitrates_[spatial_index][temporal_index], sum_);
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
uint64_t new_bitrate_sum_bps = sum_;
new_bitrate_sum_bps -= bitrates_[spatial_index][temporal_index];
new_bitrate_sum_bps += bitrate_bps;
if (new_bitrate_sum_bps > kMaxBitrateBps)
return false;
bitrates_[spatial_index][temporal_index] = bitrate_bps;
has_bitrate_[spatial_index][temporal_index] = true;
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
sum_ = static_cast<uint32_t>(new_bitrate_sum_bps);
return true;
}
bool BitrateAllocation::HasBitrate(size_t spatial_index,
size_t temporal_index) const {
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
RTC_CHECK_LT(temporal_index, kMaxTemporalStreams);
return has_bitrate_[spatial_index][temporal_index];
}
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
uint32_t BitrateAllocation::GetBitrate(size_t spatial_index,
size_t temporal_index) const {
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
RTC_CHECK_LT(temporal_index, kMaxTemporalStreams);
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
return bitrates_[spatial_index][temporal_index];
}
// Whether the specific spatial layers has the bitrate set in any of its
// temporal layers.
bool BitrateAllocation::IsSpatialLayerUsed(size_t spatial_index) const {
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
for (int i = 0; i < kMaxTemporalStreams; ++i) {
if (has_bitrate_[spatial_index][i])
return true;
}
return false;
}
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
// Get the sum of all the temporal layer for a specific spatial layer.
uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const {
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
uint32_t sum = 0;
for (int i = 0; i < kMaxTemporalStreams; ++i)
sum += bitrates_[spatial_index][i];
return sum;
}
std::string BitrateAllocation::ToString() const {
if (sum_ == 0)
return "BitrateAllocation [ [] ]";
// TODO(sprang): Replace this stringstream with something cheaper.
std::ostringstream oss;
oss << "BitrateAllocation [";
uint32_t spatial_cumulator = 0;
for (int si = 0; si < kMaxSpatialLayers; ++si) {
RTC_DCHECK_LE(spatial_cumulator, sum_);
if (spatial_cumulator == sum_)
break;
const uint32_t layer_sum = GetSpatialLayerSum(si);
if (layer_sum == sum_) {
oss << " [";
} else {
if (si > 0)
oss << ",";
oss << std::endl << " [";
}
spatial_cumulator += layer_sum;
uint32_t temporal_cumulator = 0;
for (int ti = 0; ti < kMaxTemporalStreams; ++ti) {
RTC_DCHECK_LE(temporal_cumulator, layer_sum);
if (temporal_cumulator == layer_sum)
break;
if (ti > 0)
oss << ", ";
uint32_t bitrate = bitrates_[si][ti];
oss << bitrate;
temporal_cumulator += bitrate;
}
oss << "]";
}
RTC_DCHECK_EQ(spatial_cumulator, sum_);
oss << " ]";
return oss.str();
}
std::ostream& BitrateAllocation::operator<<(std::ostream& os) const {
os << ToString();
return os;
}
} // namespace webrtc