Remove simulcast bitrate modes.
Instead always use the SBM_VERY_HIGH setting. BUG=webrtc:4885 R=hta@webrtc.org, mflodman@webrtc.org Review URL: https://codereview.webrtc.org/1407693005 Cr-Commit-Position: refs/heads/master@{#10305}
This commit is contained in:
parent
6ca1ac4283
commit
be16f79818
@ -116,10 +116,6 @@ const char MediaConstraintsInterface::kCpuOveruseEncodeUsage[] =
|
||||
"googCpuOveruseEncodeUsage";
|
||||
const char MediaConstraintsInterface::kHighStartBitrate[] =
|
||||
"googHighStartBitrate";
|
||||
const char MediaConstraintsInterface::kHighBitrate[] =
|
||||
"googHighBitrate";
|
||||
const char MediaConstraintsInterface::kVeryHighBitrate[] =
|
||||
"googVeryHighBitrate";
|
||||
const char MediaConstraintsInterface::kPayloadPadding[] = "googPayloadPadding";
|
||||
|
||||
|
||||
|
||||
@ -133,8 +133,6 @@ class MediaConstraintsInterface {
|
||||
static const char kCpuOveruseEncodeRsdThreshold[];
|
||||
static const char kCpuOveruseEncodeUsage[]; // googCpuOveruseEncodeUsage
|
||||
static const char kHighStartBitrate[]; // googHighStartBitrate
|
||||
static const char kHighBitrate[]; // googHighBitrate
|
||||
static const char kVeryHighBitrate[]; // googVeryHighBitrate
|
||||
static const char kPayloadPadding[]; // googPayloadPadding
|
||||
|
||||
// The prefix of internal-only constraints whose JS set values should be
|
||||
|
||||
@ -696,22 +696,6 @@ bool WebRtcSession::Initialize(
|
||||
MediaConstraintsInterface::kHighStartBitrate,
|
||||
&video_options_.video_start_bitrate);
|
||||
|
||||
if (FindConstraint(
|
||||
constraints,
|
||||
MediaConstraintsInterface::kVeryHighBitrate,
|
||||
&value,
|
||||
NULL)) {
|
||||
video_options_.video_highest_bitrate.Set(
|
||||
cricket::VideoOptions::VERY_HIGH);
|
||||
} else if (FindConstraint(
|
||||
constraints,
|
||||
MediaConstraintsInterface::kHighBitrate,
|
||||
&value,
|
||||
NULL)) {
|
||||
video_options_.video_highest_bitrate.Set(
|
||||
cricket::VideoOptions::HIGH);
|
||||
}
|
||||
|
||||
SetOptionFromOptionalConstraint(constraints,
|
||||
MediaConstraintsInterface::kCombinedAudioVideoBwe,
|
||||
&audio_options_.combined_audio_video_bwe);
|
||||
|
||||
@ -62,7 +62,6 @@ class VideoRenderer;
|
||||
const int kMinRtpHeaderExtensionId = 1;
|
||||
const int kMaxRtpHeaderExtensionId = 255;
|
||||
const int kScreencastDefaultFps = 5;
|
||||
const int kHighStartBitrate = 1500;
|
||||
|
||||
// Used in AudioOptions and VideoOptions to signify "unset" values.
|
||||
template <class T>
|
||||
@ -288,12 +287,6 @@ struct AudioOptions {
|
||||
// We are moving all of the setting of options to structs like this,
|
||||
// but some things currently still use flags.
|
||||
struct VideoOptions {
|
||||
enum HighestBitrate {
|
||||
NORMAL,
|
||||
HIGH,
|
||||
VERY_HIGH
|
||||
};
|
||||
|
||||
VideoOptions() {
|
||||
process_adaptation_threshhold.Set(kProcessCpuThreshold);
|
||||
system_low_adaptation_threshhold.Set(kLowSystemCpuThreshold);
|
||||
@ -307,7 +300,6 @@ struct VideoOptions {
|
||||
video_adapt_third.SetFrom(change.video_adapt_third);
|
||||
video_noise_reduction.SetFrom(change.video_noise_reduction);
|
||||
video_start_bitrate.SetFrom(change.video_start_bitrate);
|
||||
video_highest_bitrate.SetFrom(change.video_highest_bitrate);
|
||||
cpu_overuse_detection.SetFrom(change.cpu_overuse_detection);
|
||||
cpu_underuse_threshold.SetFrom(change.cpu_underuse_threshold);
|
||||
cpu_overuse_threshold.SetFrom(change.cpu_overuse_threshold);
|
||||
@ -335,7 +327,6 @@ struct VideoOptions {
|
||||
video_adapt_third == o.video_adapt_third &&
|
||||
video_noise_reduction == o.video_noise_reduction &&
|
||||
video_start_bitrate == o.video_start_bitrate &&
|
||||
video_highest_bitrate == o.video_highest_bitrate &&
|
||||
cpu_overuse_detection == o.cpu_overuse_detection &&
|
||||
cpu_underuse_threshold == o.cpu_underuse_threshold &&
|
||||
cpu_overuse_threshold == o.cpu_overuse_threshold &&
|
||||
@ -365,7 +356,6 @@ struct VideoOptions {
|
||||
ost << ToStringIfSet("video adapt third", video_adapt_third);
|
||||
ost << ToStringIfSet("noise reduction", video_noise_reduction);
|
||||
ost << ToStringIfSet("start bitrate", video_start_bitrate);
|
||||
ost << ToStringIfSet("highest video bitrate", video_highest_bitrate);
|
||||
ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection);
|
||||
ost << ToStringIfSet("cpu underuse threshold", cpu_underuse_threshold);
|
||||
ost << ToStringIfSet("cpu overuse threshold", cpu_overuse_threshold);
|
||||
@ -400,8 +390,6 @@ struct VideoOptions {
|
||||
Settable<bool> video_noise_reduction;
|
||||
// Experimental: Enable WebRtc higher start bitrate?
|
||||
Settable<int> video_start_bitrate;
|
||||
// Set highest bitrate mode for video.
|
||||
Settable<HighestBitrate> video_highest_bitrate;
|
||||
// Enable WebRTC Cpu Overuse Detection, which is a new version of the CPU
|
||||
// adaptation algorithm. So this option will override the
|
||||
// |adapt_input_to_cpu_usage|.
|
||||
|
||||
@ -27,12 +27,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "talk/media/base/mediachannel.h" // For VideoOptions
|
||||
#include "talk/media/base/streamparams.h"
|
||||
#include "talk/media/webrtc/simulcast.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/common_types.h" // For webrtc::VideoCodec
|
||||
#include "webrtc/system_wrappers/interface/field_trial.h"
|
||||
namespace cricket {
|
||||
|
||||
@ -44,26 +42,26 @@ struct SimulcastFormat {
|
||||
size_t max_layers;
|
||||
// The maximum bitrate for encoding stream at |widthxheight|, when we are
|
||||
// not sending the next higher spatial stream.
|
||||
int max_bitrate_kbps[SBM_COUNT];
|
||||
int max_bitrate_kbps;
|
||||
// The target bitrate for encoding stream at |widthxheight|, when this layer
|
||||
// is not the highest layer (i.e., when we are sending another higher spatial
|
||||
// stream).
|
||||
int target_bitrate_kbps[SBM_COUNT];
|
||||
int target_bitrate_kbps;
|
||||
// The minimum bitrate needed for encoding stream at |widthxheight|.
|
||||
int min_bitrate_kbps[SBM_COUNT];
|
||||
int min_bitrate_kbps;
|
||||
};
|
||||
|
||||
// These tables describe from which resolution we can use how many
|
||||
// simulcast layers at what bitrates (maximum, target, and minimum).
|
||||
// Important!! Keep this table from high resolution to low resolution.
|
||||
const SimulcastFormat kSimulcastFormats[] = {
|
||||
{1920, 1080, 3, {5000, 5000, 5000}, {4000, 4000, 4000}, {800, 800, 800}},
|
||||
{1280, 720, 3, {1200, 1200, 2500}, {1200, 1200, 2500}, {500, 600, 600}},
|
||||
{960, 540, 3, {900, 900, 900}, {900, 900, 900}, {350, 450, 450}},
|
||||
{640, 360, 2, {500, 700, 700}, {500, 500, 500}, {100, 150, 150}},
|
||||
{480, 270, 2, {350, 450, 450}, {350, 350, 350}, {100, 150, 150}},
|
||||
{320, 180, 1, {100, 200, 200}, {100, 150, 150}, {30, 30, 30}},
|
||||
{0, 0, 1, {100, 200, 200}, {100, 150, 150}, {30, 30, 30}}
|
||||
{1920, 1080, 3, 5000, 4000, 800},
|
||||
{1280, 720, 3, 2500, 2500, 600},
|
||||
{960, 540, 3, 900, 900, 450},
|
||||
{640, 360, 2, 700, 500, 150},
|
||||
{480, 270, 2, 450, 350, 150},
|
||||
{320, 180, 1, 200, 150, 30},
|
||||
{0, 0, 1, 200, 150, 30}
|
||||
};
|
||||
|
||||
// Multiway: Number of temporal layers for each simulcast stream, for maximum
|
||||
@ -82,22 +80,6 @@ void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs) {
|
||||
}
|
||||
}
|
||||
|
||||
SimulcastBitrateMode GetSimulcastBitrateMode(
|
||||
const VideoOptions& options) {
|
||||
VideoOptions::HighestBitrate bitrate_mode;
|
||||
if (options.video_highest_bitrate.Get(&bitrate_mode)) {
|
||||
switch (bitrate_mode) {
|
||||
case VideoOptions::HIGH:
|
||||
return SBM_HIGH;
|
||||
case VideoOptions::VERY_HIGH:
|
||||
return SBM_VERY_HIGH;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SBM_NORMAL;
|
||||
}
|
||||
|
||||
void MaybeExchangeWidthHeight(int* width, int* height) {
|
||||
// |kSimulcastFormats| assumes |width| >= |height|. If not, exchange them
|
||||
// before comparing.
|
||||
@ -133,23 +115,6 @@ int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SimulcastBitrateMode FindSimulcastBitrateMode(
|
||||
size_t max_layers,
|
||||
int stream_idx,
|
||||
SimulcastBitrateMode highest_enabled) {
|
||||
|
||||
if (highest_enabled > SBM_NORMAL) {
|
||||
// We want high or very high for all layers if enabled.
|
||||
return highest_enabled;
|
||||
}
|
||||
if (kSimulcastFormats[stream_idx].max_layers == max_layers) {
|
||||
// We want high for the top layer.
|
||||
return SBM_HIGH;
|
||||
}
|
||||
// And normal for everything else.
|
||||
return SBM_NORMAL;
|
||||
}
|
||||
|
||||
// Simulcast stream width and height must both be dividable by
|
||||
// |2 ^ simulcast_layers - 1|.
|
||||
int NormalizeSimulcastSize(int size, size_t simulcast_layers) {
|
||||
@ -168,44 +133,30 @@ size_t FindSimulcastMaxLayers(int width, int height) {
|
||||
// TODO(marpan): Investigate if we should return 0 instead of -1 in
|
||||
// FindSimulcast[Max/Target/Min]Bitrate functions below, since the
|
||||
// codec struct max/min/targeBitrates are unsigned.
|
||||
int FindSimulcastMaxBitrateBps(int width,
|
||||
int height,
|
||||
size_t max_layers,
|
||||
SimulcastBitrateMode highest_enabled) {
|
||||
int FindSimulcastMaxBitrateBps(int width, int height, size_t max_layers) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
const SimulcastBitrateMode bitrate_mode = FindSimulcastBitrateMode(
|
||||
max_layers, format_index, highest_enabled);
|
||||
return kSimulcastFormats[format_index].max_bitrate_kbps[bitrate_mode] * 1000;
|
||||
return kSimulcastFormats[format_index].max_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
int FindSimulcastTargetBitrateBps(int width,
|
||||
int height,
|
||||
size_t max_layers,
|
||||
SimulcastBitrateMode highest_enabled) {
|
||||
size_t max_layers) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
const SimulcastBitrateMode bitrate_mode = FindSimulcastBitrateMode(
|
||||
max_layers, format_index, highest_enabled);
|
||||
return kSimulcastFormats[format_index].target_bitrate_kbps[bitrate_mode] *
|
||||
1000;
|
||||
return kSimulcastFormats[format_index].target_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
int FindSimulcastMinBitrateBps(int width,
|
||||
int height,
|
||||
size_t max_layers,
|
||||
SimulcastBitrateMode highest_enabled) {
|
||||
int FindSimulcastMinBitrateBps(int width, int height, size_t max_layers) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
}
|
||||
const SimulcastBitrateMode bitrate_mode = FindSimulcastBitrateMode(
|
||||
max_layers, format_index, highest_enabled);
|
||||
return kSimulcastFormats[format_index].min_bitrate_kbps[bitrate_mode] * 1000;
|
||||
return kSimulcastFormats[format_index].min_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
bool SlotSimulcastMaxResolution(size_t max_layers, int* width, int* height) {
|
||||
@ -233,7 +184,6 @@ int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams) {
|
||||
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
size_t max_streams,
|
||||
SimulcastBitrateMode bitrate_mode,
|
||||
int width,
|
||||
int height,
|
||||
int max_bitrate_bps,
|
||||
@ -265,12 +215,12 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
// TODO(pbos): Fill actual temporal-layer bitrate thresholds.
|
||||
streams[s].temporal_layer_thresholds_bps.resize(
|
||||
kDefaultConferenceNumberOfTemporalLayers[s] - 1);
|
||||
streams[s].max_bitrate_bps = FindSimulcastMaxBitrateBps(
|
||||
width, height, simulcast_layers, bitrate_mode);
|
||||
streams[s].target_bitrate_bps = FindSimulcastTargetBitrateBps(
|
||||
width, height, simulcast_layers, bitrate_mode);
|
||||
streams[s].min_bitrate_bps = FindSimulcastMinBitrateBps(
|
||||
width, height, simulcast_layers, bitrate_mode);
|
||||
streams[s].max_bitrate_bps =
|
||||
FindSimulcastMaxBitrateBps(width, height, simulcast_layers);
|
||||
streams[s].target_bitrate_bps =
|
||||
FindSimulcastTargetBitrateBps(width, height, simulcast_layers);
|
||||
streams[s].min_bitrate_bps =
|
||||
FindSimulcastMinBitrateBps(width, height, simulcast_layers);
|
||||
streams[s].max_qp = max_qp;
|
||||
streams[s].max_framerate = max_framerate;
|
||||
width /= 2;
|
||||
@ -289,126 +239,6 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
return streams;
|
||||
}
|
||||
|
||||
bool ConfigureSimulcastCodec(
|
||||
int number_ssrcs,
|
||||
SimulcastBitrateMode bitrate_mode,
|
||||
webrtc::VideoCodec* codec) {
|
||||
std::vector<webrtc::VideoStream> streams =
|
||||
GetSimulcastConfig(static_cast<size_t>(number_ssrcs),
|
||||
bitrate_mode,
|
||||
static_cast<int>(codec->width),
|
||||
static_cast<int>(codec->height),
|
||||
codec->maxBitrate * 1000,
|
||||
codec->qpMax,
|
||||
codec->maxFramerate);
|
||||
// Add simulcast sub-streams from lower resolution to higher resolutions.
|
||||
codec->numberOfSimulcastStreams = static_cast<unsigned int>(streams.size());
|
||||
codec->width = static_cast<unsigned short>(streams.back().width);
|
||||
codec->height = static_cast<unsigned short>(streams.back().height);
|
||||
// When using simulcast, |codec->maxBitrate| is set to the sum of the max
|
||||
// bitrates over all streams. For a given stream |s|, the max bitrate for that
|
||||
// stream is set by |simulcastStream[s].targetBitrate|, if it is not the
|
||||
// highest resolution stream, otherwise it is set by
|
||||
// |simulcastStream[s].maxBitrate|.
|
||||
|
||||
for (size_t s = 0; s < streams.size(); ++s) {
|
||||
codec->simulcastStream[s].width =
|
||||
static_cast<unsigned short>(streams[s].width);
|
||||
codec->simulcastStream[s].height =
|
||||
static_cast<unsigned short>(streams[s].height);
|
||||
codec->simulcastStream[s].numberOfTemporalLayers =
|
||||
static_cast<unsigned int>(
|
||||
streams[s].temporal_layer_thresholds_bps.size() + 1);
|
||||
codec->simulcastStream[s].minBitrate = streams[s].min_bitrate_bps / 1000;
|
||||
codec->simulcastStream[s].targetBitrate =
|
||||
streams[s].target_bitrate_bps / 1000;
|
||||
codec->simulcastStream[s].maxBitrate = streams[s].max_bitrate_bps / 1000;
|
||||
codec->simulcastStream[s].qpMax = streams[s].max_qp;
|
||||
}
|
||||
|
||||
codec->maxBitrate =
|
||||
static_cast<unsigned int>(GetTotalMaxBitrateBps(streams) / 1000);
|
||||
|
||||
codec->codecSpecific.VP8.numberOfTemporalLayers =
|
||||
kDefaultConferenceNumberOfTemporalLayers[0];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConfigureSimulcastCodec(
|
||||
const StreamParams& sp,
|
||||
const VideoOptions& options,
|
||||
webrtc::VideoCodec* codec) {
|
||||
std::vector<uint32_t> ssrcs;
|
||||
GetSimulcastSsrcs(sp, &ssrcs);
|
||||
SimulcastBitrateMode bitrate_mode = GetSimulcastBitrateMode(options);
|
||||
return ConfigureSimulcastCodec(static_cast<int>(ssrcs.size()), bitrate_mode,
|
||||
codec);
|
||||
}
|
||||
|
||||
void ConfigureSimulcastTemporalLayers(
|
||||
int num_temporal_layers, webrtc::VideoCodec* codec) {
|
||||
for (size_t i = 0; i < codec->numberOfSimulcastStreams; ++i) {
|
||||
codec->simulcastStream[i].numberOfTemporalLayers = num_temporal_layers;
|
||||
}
|
||||
}
|
||||
|
||||
void DisableSimulcastCodec(webrtc::VideoCodec* codec) {
|
||||
// TODO(hellner): the proper solution is to uncomment the next code line
|
||||
// and remove the lines following it in this condition. This is pending
|
||||
// b/7012070 being fixed.
|
||||
// codec->numberOfSimulcastStreams = 0;
|
||||
// It is possible to set non simulcast without the above line. However,
|
||||
// the max bitrate for every simulcast layer must be set to 0. Further,
|
||||
// there is a sanity check making sure that the aspect ratio is the same
|
||||
// for all simulcast layers. The for-loop makes sure that the sanity check
|
||||
// does not fail.
|
||||
if (codec->numberOfSimulcastStreams > 0) {
|
||||
const int ratio = codec->width / codec->height;
|
||||
for (int i = 0; i < codec->numberOfSimulcastStreams - 1; ++i) {
|
||||
// Min/target bitrate has to be zero not to influence padding
|
||||
// calculations in VideoEngine.
|
||||
codec->simulcastStream[i].minBitrate = 0;
|
||||
codec->simulcastStream[i].targetBitrate = 0;
|
||||
codec->simulcastStream[i].maxBitrate = 0;
|
||||
codec->simulcastStream[i].width =
|
||||
codec->simulcastStream[i].height * ratio;
|
||||
codec->simulcastStream[i].numberOfTemporalLayers = 1;
|
||||
}
|
||||
// The for loop above did not set the bitrate of the highest layer.
|
||||
codec->simulcastStream[codec->numberOfSimulcastStreams - 1]
|
||||
.minBitrate = 0;
|
||||
codec->simulcastStream[codec->numberOfSimulcastStreams - 1]
|
||||
.targetBitrate = 0;
|
||||
codec->simulcastStream[codec->numberOfSimulcastStreams - 1].
|
||||
maxBitrate = 0;
|
||||
// The highest layer has to correspond to the non-simulcast resolution.
|
||||
codec->simulcastStream[codec->numberOfSimulcastStreams - 1].
|
||||
width = codec->width;
|
||||
codec->simulcastStream[codec->numberOfSimulcastStreams - 1].
|
||||
height = codec->height;
|
||||
codec->simulcastStream[codec->numberOfSimulcastStreams - 1].
|
||||
numberOfTemporalLayers = 1;
|
||||
// TODO(hellner): the maxFramerate should also be set here according to
|
||||
// the screencasts framerate. Doing so will break some
|
||||
// unittests.
|
||||
}
|
||||
}
|
||||
|
||||
void LogSimulcastSubstreams(const webrtc::VideoCodec& codec) {
|
||||
for (size_t i = 0; i < codec.numberOfSimulcastStreams; ++i) {
|
||||
LOG(LS_INFO) << "Simulcast substream " << i << ": "
|
||||
<< codec.simulcastStream[i].width << "x"
|
||||
<< codec.simulcastStream[i].height << "@"
|
||||
<< codec.simulcastStream[i].minBitrate << "-"
|
||||
<< codec.simulcastStream[i].maxBitrate << "kbps"
|
||||
<< " with "
|
||||
<< static_cast<int>(
|
||||
codec.simulcastStream[i].numberOfTemporalLayers)
|
||||
<< " temporal layers";
|
||||
}
|
||||
}
|
||||
|
||||
static const int kScreenshareMinBitrateKbps = 50;
|
||||
static const int kScreenshareMaxBitrateKbps = 6000;
|
||||
static const int kScreenshareDefaultTl0BitrateKbps = 200;
|
||||
@ -458,16 +288,4 @@ bool ScreenshareLayerConfig::FromFieldTrialGroup(
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec) {
|
||||
codec->codecSpecific.VP8.numberOfTemporalLayers = 2;
|
||||
codec->codecSpecific.VP8.automaticResizeOn = false;
|
||||
ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault();
|
||||
|
||||
// For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked
|
||||
// on the VideoCodec struct as target and max bitrates, respectively.
|
||||
// See eg. webrtc::VP8EncoderImpl::SetRates().
|
||||
codec->targetBitrate = config.tl0_bitrate_kbps;
|
||||
codec->maxBitrate = config.tl1_bitrate_kbps;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -33,21 +33,9 @@
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/config.h"
|
||||
|
||||
namespace webrtc {
|
||||
struct VideoCodec;
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
struct VideoOptions;
|
||||
struct StreamParams;
|
||||
|
||||
enum SimulcastBitrateMode {
|
||||
SBM_NORMAL = 0,
|
||||
SBM_HIGH,
|
||||
SBM_VERY_HIGH,
|
||||
SBM_COUNT
|
||||
};
|
||||
|
||||
// Config for use with screen cast when temporal layers are enabled.
|
||||
struct ScreenshareLayerConfig {
|
||||
public:
|
||||
@ -68,57 +56,18 @@ struct ScreenshareLayerConfig {
|
||||
// TODO(pthatcher): Write unit tests just for these functions,
|
||||
// independent of WebrtcVideoEngine.
|
||||
|
||||
// Get the simulcast bitrate mode to use based on
|
||||
// options.video_highest_bitrate.
|
||||
SimulcastBitrateMode GetSimulcastBitrateMode(
|
||||
const VideoOptions& options);
|
||||
int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams);
|
||||
|
||||
// Get the ssrcs of the SIM group from the stream params.
|
||||
void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs);
|
||||
|
||||
// Get simulcast settings.
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
size_t max_streams,
|
||||
SimulcastBitrateMode bitrate_mode,
|
||||
int width,
|
||||
int height,
|
||||
int max_bitrate_bps,
|
||||
int max_qp,
|
||||
int max_framerate);
|
||||
|
||||
// Set the codec->simulcastStreams, codec->width, and codec->height
|
||||
// based on the number of ssrcs to use and the bitrate mode to use.
|
||||
bool ConfigureSimulcastCodec(int number_ssrcs,
|
||||
SimulcastBitrateMode bitrate_mode,
|
||||
webrtc::VideoCodec* codec);
|
||||
|
||||
// Set the codec->simulcastStreams, codec->width, and codec->height
|
||||
// based on the video options (to get the simulcast bitrate mode) and
|
||||
// the stream params (to get the number of ssrcs). This is really a
|
||||
// convenience function.
|
||||
bool ConfigureSimulcastCodec(const StreamParams& sp,
|
||||
const VideoOptions& options,
|
||||
webrtc::VideoCodec* codec);
|
||||
|
||||
// Set the numberOfTemporalLayers in each codec->simulcastStreams[i].
|
||||
// Apparently it is useful to do this at a different time than
|
||||
// ConfigureSimulcastCodec.
|
||||
// TODO(pthatcher): Figure out why and put this code into
|
||||
// ConfigureSimulcastCodec.
|
||||
void ConfigureSimulcastTemporalLayers(
|
||||
int num_temporal_layers, webrtc::VideoCodec* codec);
|
||||
|
||||
// Turn off all simulcasting for the given codec.
|
||||
void DisableSimulcastCodec(webrtc::VideoCodec* codec);
|
||||
|
||||
// Log useful info about each of the simulcast substreams of the
|
||||
// codec.
|
||||
void LogSimulcastSubstreams(const webrtc::VideoCodec& codec);
|
||||
|
||||
// Configure the codec's bitrate and temporal layers so that it's good
|
||||
// for a screencast in conference mode. Technically, this shouldn't
|
||||
// go in simulcast.cc. But it's closely related.
|
||||
void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec);
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(size_t max_streams,
|
||||
int width,
|
||||
int height,
|
||||
int max_bitrate_bps,
|
||||
int max_qp,
|
||||
int max_framerate);
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
|
||||
@ -432,8 +432,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateSimulcastVideoStreams(
|
||||
codec.GetParam(kCodecParamMaxQuantization, &max_qp);
|
||||
|
||||
return GetSimulcastConfig(
|
||||
num_streams, GetSimulcastBitrateMode(options), codec.width, codec.height,
|
||||
max_bitrate_bps, max_qp,
|
||||
num_streams, codec.width, codec.height, max_bitrate_bps, max_qp,
|
||||
codec.framerate != 0 ? codec.framerate : kDefaultVideoMaxFramerate);
|
||||
}
|
||||
|
||||
|
||||
@ -2089,17 +2089,13 @@ TEST_F(WebRtcVideoChannel2Test,
|
||||
std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
|
||||
ASSERT_GT(streams.size(), 1u)
|
||||
<< "Without simulcast this test doesn't make sense.";
|
||||
int initial_max_bitrate_bps = 0;
|
||||
for (auto& video_stream : streams)
|
||||
initial_max_bitrate_bps += video_stream.max_bitrate_bps;
|
||||
int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
|
||||
EXPECT_GT(initial_max_bitrate_bps, 0);
|
||||
|
||||
parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
|
||||
EXPECT_TRUE(channel_->SetSendParameters(parameters));
|
||||
streams = stream->GetVideoStreams();
|
||||
int increased_max_bitrate_bps = 0;
|
||||
for (auto& video_stream : streams)
|
||||
increased_max_bitrate_bps += video_stream.max_bitrate_bps;
|
||||
int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
|
||||
EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps);
|
||||
|
||||
EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr));
|
||||
@ -3006,12 +3002,9 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
|
||||
protected:
|
||||
void VerifySimulcastSettings(const VideoCodec& codec,
|
||||
VideoOptions::HighestBitrate bitrate_mode,
|
||||
size_t num_configured_streams,
|
||||
size_t expected_num_streams,
|
||||
SimulcastBitrateMode simulcast_bitrate_mode) {
|
||||
size_t expected_num_streams) {
|
||||
cricket::VideoSendParameters parameters;
|
||||
parameters.options.video_highest_bitrate.Set(bitrate_mode);
|
||||
parameters.codecs.push_back(codec);
|
||||
ASSERT_TRUE(channel_->SetSendParameters(parameters));
|
||||
|
||||
@ -3036,12 +3029,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
ASSERT_EQ(expected_num_streams, video_streams.size());
|
||||
|
||||
std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig(
|
||||
num_configured_streams,
|
||||
simulcast_bitrate_mode,
|
||||
codec.width,
|
||||
codec.height,
|
||||
0,
|
||||
kDefaultQpMax,
|
||||
num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax,
|
||||
codec.framerate != 0 ? codec.framerate : kDefaultFramerate);
|
||||
|
||||
ASSERT_EQ(expected_streams.size(), video_streams.size());
|
||||
@ -3128,34 +3116,11 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
|
||||
VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL);
|
||||
VerifySimulcastSettings(kVp8Codec, 2, 2);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
|
||||
VerifySimulcastSettings(
|
||||
kVp8Codec720p, VideoOptions::NORMAL, 3, 3, SBM_NORMAL);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
SetSendCodecsWith2SimulcastStreamsHighBitrateMode) {
|
||||
VerifySimulcastSettings(kVp8Codec, VideoOptions::HIGH, 2, 2, SBM_HIGH);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
SetSendCodecsWith3SimulcastStreamsHighBitrateMode) {
|
||||
VerifySimulcastSettings(kVp8Codec720p, VideoOptions::HIGH, 3, 3, SBM_HIGH);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
SetSendCodecsWith2SimulcastStreamsVeryHighBitrateMode) {
|
||||
VerifySimulcastSettings(
|
||||
kVp8Codec, VideoOptions::VERY_HIGH, 2, 2, SBM_VERY_HIGH);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
SetSendCodecsWith3SimulcastStreamsVeryHighBitrateMode) {
|
||||
VerifySimulcastSettings(
|
||||
kVp8Codec720p, VideoOptions::VERY_HIGH, 3, 3, SBM_VERY_HIGH);
|
||||
VerifySimulcastSettings(kVp8Codec720p, 3, 3);
|
||||
}
|
||||
|
||||
// Test that we normalize send codec format size in simulcast.
|
||||
@ -3163,7 +3128,7 @@ TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
|
||||
cricket::VideoCodec codec(kVp8Codec270p);
|
||||
codec.width += 1;
|
||||
codec.height += 1;
|
||||
VerifySimulcastSettings(codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL);
|
||||
VerifySimulcastSettings(codec, 2, 2);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x800) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user