(Auto)update libjingle 81702493-> 81755413
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7860 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
3cd26b677a
commit
a85307737c
@ -396,6 +396,8 @@
|
||||
'media/other/linphonemediaengine.h',
|
||||
'media/sctp/sctpdataengine.cc',
|
||||
'media/sctp/sctpdataengine.h',
|
||||
'media/webrtc/simulcast.cc',
|
||||
'media/webrtc/simulcast.h',
|
||||
'media/webrtc/webrtccommon.h',
|
||||
'media/webrtc/webrtcexport.h',
|
||||
'media/webrtc/webrtcmediaengine.cc',
|
||||
|
423
talk/media/webrtc/simulcast.cc
Executable file
423
talk/media/webrtc/simulcast.cc
Executable file
@ -0,0 +1,423 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
namespace cricket {
|
||||
|
||||
struct SimulcastFormat {
|
||||
int width;
|
||||
int height;
|
||||
// The maximum number of simulcast layers can be used for
|
||||
// resolutions at |widthxheigh|.
|
||||
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];
|
||||
// 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];
|
||||
// The minimum bitrate needed for encoding stream at |widthxheight|.
|
||||
int min_bitrate_kbps[SBM_COUNT];
|
||||
};
|
||||
|
||||
// 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[] = {
|
||||
{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}}
|
||||
};
|
||||
|
||||
// Multiway: Number of temporal layers for each simulcast stream, for maximum
|
||||
// possible number of simulcast streams |kMaxSimulcastStreams|. The array
|
||||
// goes from lowest resolution at position 0 to highest resolution.
|
||||
// For example, first three elements correspond to say: QVGA, VGA, WHD.
|
||||
static const int
|
||||
kDefaultConferenceNumberOfTemporalLayers[webrtc::kMaxSimulcastStreams] =
|
||||
{3, 3, 3, 3};
|
||||
|
||||
static const int kScreencastWithTemporalLayerTargetVideoBitrate = 100;
|
||||
static const int kScreencastWithTemporalLayerMaxVideoBitrate = 1000;
|
||||
|
||||
void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32>* ssrcs) {
|
||||
const SsrcGroup* sim_group = sp.get_ssrc_group(kSimSsrcGroupSemantics);
|
||||
if (sim_group) {
|
||||
ssrcs->insert(
|
||||
ssrcs->end(), sim_group->ssrcs.begin(), sim_group->ssrcs.end());
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
if (*width < *height) {
|
||||
int temp = *width;
|
||||
*width = *height;
|
||||
*height = temp;
|
||||
}
|
||||
}
|
||||
|
||||
int FindSimulcastFormatIndex(int width, int height) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(kSimulcastFormats); ++i) {
|
||||
if (width >= kSimulcastFormats[i].width &&
|
||||
height >= kSimulcastFormats[i].height) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(kSimulcastFormats); ++i) {
|
||||
if (width >= kSimulcastFormats[i].width &&
|
||||
height >= kSimulcastFormats[i].height &&
|
||||
max_layers == kSimulcastFormats[i].max_layers) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
const int base2_exponent = static_cast<int>(simulcast_layers) - 1;
|
||||
return ((size >> base2_exponent) << base2_exponent);
|
||||
}
|
||||
|
||||
size_t FindSimulcastMaxLayers(int width, int height) {
|
||||
int index = FindSimulcastFormatIndex(width, height);
|
||||
if (index == -1) {
|
||||
return -1;
|
||||
}
|
||||
return kSimulcastFormats[index].max_layers;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
int FindSimulcastTargetBitrateBps(int width,
|
||||
int height,
|
||||
size_t max_layers,
|
||||
SimulcastBitrateMode highest_enabled) {
|
||||
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;
|
||||
}
|
||||
|
||||
int FindSimulcastMinBitrateBps(int width,
|
||||
int height,
|
||||
size_t max_layers,
|
||||
SimulcastBitrateMode highest_enabled) {
|
||||
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;
|
||||
}
|
||||
|
||||
bool SlotSimulcastMaxResolution(size_t max_layers, int* width, int* height) {
|
||||
int index = FindSimulcastFormatIndex(*width, *height, max_layers);
|
||||
if (index == -1) {
|
||||
LOG(LS_ERROR) << "SlotSimulcastMaxResolution";
|
||||
return false;
|
||||
}
|
||||
|
||||
*width = kSimulcastFormats[index].width;
|
||||
*height = kSimulcastFormats[index].height;
|
||||
LOG(LS_INFO) << "SlotSimulcastMaxResolution to width:" << *width
|
||||
<< " height:" << *height;
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams) {
|
||||
int total_max_bitrate_bps = 0;
|
||||
for (size_t s = 0; s < streams.size() - 1; ++s) {
|
||||
total_max_bitrate_bps += streams[s].target_bitrate_bps;
|
||||
}
|
||||
total_max_bitrate_bps += streams.back().max_bitrate_bps;
|
||||
return total_max_bitrate_bps;
|
||||
}
|
||||
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
size_t max_streams,
|
||||
SimulcastBitrateMode bitrate_mode,
|
||||
int width,
|
||||
int height,
|
||||
int min_bitrate_bps,
|
||||
int max_bitrate_bps,
|
||||
int max_qp,
|
||||
int max_framerate) {
|
||||
size_t simulcast_layers = FindSimulcastMaxLayers(width, height);
|
||||
if (simulcast_layers > max_streams) {
|
||||
// If the number of SSRCs in the group differs from our target
|
||||
// number of simulcast streams for current resolution, switch down
|
||||
// to a resolution that matches our number of SSRCs.
|
||||
if (!SlotSimulcastMaxResolution(max_streams, &width, &height)) {
|
||||
return std::vector<webrtc::VideoStream>();
|
||||
}
|
||||
simulcast_layers = max_streams;
|
||||
}
|
||||
std::vector<webrtc::VideoStream> streams;
|
||||
streams.resize(simulcast_layers);
|
||||
|
||||
// Format width and height has to be divisible by |2 ^ number_streams - 1|.
|
||||
width = NormalizeSimulcastSize(width, simulcast_layers);
|
||||
height = NormalizeSimulcastSize(height, simulcast_layers);
|
||||
|
||||
// Add simulcast sub-streams from lower resolution to higher resolutions.
|
||||
// Add simulcast streams, from highest resolution (|s| = number_streams -1)
|
||||
// to lowest resolution at |s| = 0.
|
||||
for (size_t s = simulcast_layers - 1;; --s) {
|
||||
streams[s].width = width;
|
||||
streams[s].height = height;
|
||||
// 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_qp = max_qp;
|
||||
streams[s].max_framerate = max_framerate;
|
||||
width /= 2;
|
||||
height /= 2;
|
||||
if (s == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Spend additional bits to boost the max stream.
|
||||
int bitrate_left_bps = max_bitrate_bps - GetTotalMaxBitrateBps(streams);
|
||||
if (bitrate_left_bps > 0) {
|
||||
streams.back().max_bitrate_bps += bitrate_left_bps;
|
||||
}
|
||||
|
||||
// Make sure the first stream respects the bitrate minimum.
|
||||
if (streams[0].min_bitrate_bps < min_bitrate_bps) {
|
||||
streams[0].min_bitrate_bps = min_bitrate_bps;
|
||||
}
|
||||
|
||||
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->minBitrate * 1000,
|
||||
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> 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 " << codec.simulcastStream[i].numberOfTemporalLayers
|
||||
<< " temporal layers";
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec) {
|
||||
codec->codecSpecific.VP8.numberOfTemporalLayers = 2;
|
||||
codec->maxBitrate = kScreencastWithTemporalLayerMaxVideoBitrate;
|
||||
codec->targetBitrate = kScreencastWithTemporalLayerTargetVideoBitrate;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
108
talk/media/webrtc/simulcast.h
Executable file
108
talk/media/webrtc/simulcast.h
Executable file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef TALK_MEDIA_WEBRTC_SIMULCAST_H_
|
||||
#define TALK_MEDIA_WEBRTC_SIMULCAST_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
};
|
||||
|
||||
// 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);
|
||||
|
||||
// Get the ssrcs of the SIM group from the stream params.
|
||||
void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32>* ssrcs);
|
||||
|
||||
// Get simulcast settings.
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
size_t max_streams,
|
||||
SimulcastBitrateMode bitrate_mode,
|
||||
int width,
|
||||
int height,
|
||||
int min_bitrate_bps,
|
||||
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);
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_MEDIA_WEBRTC_SIMULCAST_H_
|
@ -43,6 +43,7 @@
|
||||
#include "talk/media/base/videorenderer.h"
|
||||
#include "talk/media/devices/filevideocapturer.h"
|
||||
#include "talk/media/webrtc/constants.h"
|
||||
#include "talk/media/webrtc/simulcast.h"
|
||||
#include "talk/media/webrtc/webrtcpassthroughrender.h"
|
||||
#include "talk/media/webrtc/webrtctexturevideoframe.h"
|
||||
#include "talk/media/webrtc/webrtcvideocapturer.h"
|
||||
@ -64,6 +65,8 @@
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/experiments.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/vp8_factory.h"
|
||||
#include "webrtc/system_wrappers/interface/field_trial.h"
|
||||
|
||||
namespace {
|
||||
@ -97,6 +100,58 @@ bool Changed(cricket::Settable<T> proposed,
|
||||
return proposed.Get(value) && proposed != original;
|
||||
}
|
||||
|
||||
// Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory.
|
||||
class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory {
|
||||
public:
|
||||
// EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned
|
||||
// by e.g. PeerConnectionFactory.
|
||||
explicit EncoderFactoryAdapter(cricket::WebRtcVideoEncoderFactory* factory)
|
||||
: factory_(factory) {}
|
||||
virtual ~EncoderFactoryAdapter() {}
|
||||
|
||||
// Implement webrtc::VideoEncoderFactory.
|
||||
virtual webrtc::VideoEncoder* Create() OVERRIDE {
|
||||
return factory_->CreateVideoEncoder(webrtc::kVideoCodecVP8);
|
||||
}
|
||||
|
||||
virtual void Destroy(webrtc::VideoEncoder* encoder) OVERRIDE {
|
||||
return factory_->DestroyVideoEncoder(encoder);
|
||||
}
|
||||
|
||||
private:
|
||||
cricket::WebRtcVideoEncoderFactory* factory_;
|
||||
};
|
||||
|
||||
// Wrap encoder factory to a simulcast encoder factory.
|
||||
class SimulcastEncoderFactory : public cricket::WebRtcVideoEncoderFactory {
|
||||
public:
|
||||
// SimulcastEncoderFactory doesn't take ownership of |factory|, which is owned
|
||||
// by e.g. PeerConnectionFactory.
|
||||
explicit SimulcastEncoderFactory(cricket::WebRtcVideoEncoderFactory* factory)
|
||||
: factory_(factory) {}
|
||||
virtual ~SimulcastEncoderFactory() {}
|
||||
|
||||
virtual webrtc::VideoEncoder* CreateVideoEncoder(
|
||||
webrtc::VideoCodecType type) OVERRIDE {
|
||||
ASSERT(type == webrtc::kVideoCodecVP8);
|
||||
ASSERT(factory_ != NULL);
|
||||
return new webrtc::SimulcastEncoderAdapter(
|
||||
webrtc::scoped_ptr<webrtc::VideoEncoderFactory>(
|
||||
new EncoderFactoryAdapter(factory_)).Pass());
|
||||
}
|
||||
|
||||
virtual const std::vector<VideoCodec>& codecs() const OVERRIDE {
|
||||
return factory_->codecs();
|
||||
}
|
||||
|
||||
virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) OVERRIDE {
|
||||
delete encoder;
|
||||
}
|
||||
|
||||
private:
|
||||
cricket::WebRtcVideoEncoderFactory* factory_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace cricket {
|
||||
@ -1097,6 +1152,11 @@ WebRtcVideoEngine::~WebRtcVideoEngine() {
|
||||
if (initialized_) {
|
||||
Terminate();
|
||||
}
|
||||
|
||||
if (simulcast_encoder_factory_) {
|
||||
SetExternalEncoderFactory(NULL);
|
||||
}
|
||||
|
||||
tracing_->SetTraceCallback(NULL);
|
||||
// Test to see if the media processor was deregistered properly.
|
||||
ASSERT(SignalMediaFrame.is_empty());
|
||||
@ -1615,6 +1675,20 @@ void WebRtcVideoEngine::SetExternalDecoderFactory(
|
||||
|
||||
void WebRtcVideoEngine::SetExternalEncoderFactory(
|
||||
WebRtcVideoEncoderFactory* encoder_factory) {
|
||||
// Deleted after WebRtcVideoEngine::SetExternalEncoderFactory is
|
||||
// completed, which will remove the references to it.
|
||||
rtc::scoped_ptr<WebRtcVideoEncoderFactory> old_factory(
|
||||
simulcast_encoder_factory_.release());
|
||||
if (encoder_factory) {
|
||||
const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& codecs =
|
||||
encoder_factory->codecs();
|
||||
if (codecs.size() == 1 && codecs[0].type == webrtc::kVideoCodecVP8) {
|
||||
simulcast_encoder_factory_.reset(
|
||||
new SimulcastEncoderFactory(encoder_factory));
|
||||
encoder_factory = simulcast_encoder_factory_.get();
|
||||
}
|
||||
}
|
||||
|
||||
if (encoder_factory_ == encoder_factory)
|
||||
return;
|
||||
|
||||
@ -3010,6 +3084,13 @@ bool WebRtcVideoMediaChannel::SetOptions(const VideoOptions &options) {
|
||||
VideoOptions original = options_;
|
||||
options_.SetAll(options);
|
||||
|
||||
bool use_simulcast_adapter;
|
||||
if (options.use_simulcast_adapter.Get(&use_simulcast_adapter) &&
|
||||
options.use_simulcast_adapter != original.use_simulcast_adapter) {
|
||||
webrtc::VP8EncoderFactoryConfig::set_use_simulcast_adapter(
|
||||
use_simulcast_adapter);
|
||||
}
|
||||
|
||||
// Set CPU options and codec options for all send channels.
|
||||
for (SendChannelMap::iterator iter = send_channels_.begin();
|
||||
iter != send_channels_.end(); ++iter) {
|
||||
@ -3775,6 +3856,8 @@ void WebRtcVideoMediaChannel::LogSendCodecChange(const std::string& reason) {
|
||||
if (send_rtx_type_ != -1) {
|
||||
LOG(LS_INFO) << "RTX payload type: " << send_rtx_type_;
|
||||
}
|
||||
|
||||
LogSimulcastSubstreams(vie_codec);
|
||||
}
|
||||
|
||||
bool WebRtcVideoMediaChannel::SetReceiveCodecs(
|
||||
@ -4004,6 +4087,29 @@ bool WebRtcVideoMediaChannel::ConfigureVieCodecFromSendParams(
|
||||
}
|
||||
}
|
||||
|
||||
if (webrtc::kVideoCodecVP8 == codec.codecType) {
|
||||
ConfigureSimulcastTemporalLayers(
|
||||
kDefaultNumberOfTemporalLayers, &codec);
|
||||
if (IsSimulcastStream(send_params.stream)) {
|
||||
codec.codecSpecific.VP8.automaticResizeOn = false;
|
||||
// TODO(pthatcher): Pass in options in VideoSendParams.
|
||||
VideoOptions options;
|
||||
GetOptions(&options);
|
||||
if (ConferenceModeIsEnabled()) {
|
||||
ConfigureSimulcastCodec(send_params.stream, options, &codec);
|
||||
}
|
||||
}
|
||||
|
||||
if (last_captured_frame_info.screencast) {
|
||||
// Use existing bitrate if not in conference mode.
|
||||
if (ConferenceModeIsEnabled()) {
|
||||
ConfigureConferenceModeScreencastCodec(&codec);
|
||||
}
|
||||
|
||||
DisableSimulcastCodec(&codec);
|
||||
}
|
||||
}
|
||||
|
||||
*codec_out = codec;
|
||||
return true;
|
||||
}
|
||||
@ -4045,6 +4151,12 @@ void WebRtcVideoMediaChannel::SanitizeBitrates(
|
||||
codec->startBitrate = current_target_bitrate;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the start bitrate is larger than lowest layer's min bitrate.
|
||||
if (codec->numberOfSimulcastStreams > 1 &&
|
||||
codec->startBitrate < codec->simulcastStream[0].minBitrate) {
|
||||
codec->startBitrate = codec->simulcastStream[0].minBitrate;
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcVideoMediaChannel::OnMessage(rtc::Message* msg) {
|
||||
@ -4193,11 +4305,11 @@ bool WebRtcVideoMediaChannel::SetLimitedNumberOfSendSsrcs(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVideoMediaChannel::SetSendSsrcs(
|
||||
int channel_id, const StreamParams& sp,
|
||||
const webrtc::VideoCodec& codec) {
|
||||
// TODO(pthatcher): Support more than one primary SSRC per stream.
|
||||
return SetLimitedNumberOfSendSsrcs(channel_id, sp, 1);
|
||||
bool WebRtcVideoMediaChannel::SetSendSsrcs(int channel_id,
|
||||
const StreamParams& sp,
|
||||
const webrtc::VideoCodec& codec) {
|
||||
size_t limit = codec.numberOfSimulcastStreams;
|
||||
return SetLimitedNumberOfSendSsrcs(channel_id, sp, limit);
|
||||
}
|
||||
|
||||
void WebRtcVideoMediaChannel::MaybeConnectCapturer(VideoCapturer* capturer) {
|
||||
|
@ -219,6 +219,7 @@ class WebRtcVideoEngine : public sigslot::has_slots<>,
|
||||
rtc::scoped_ptr<ViETraceWrapper> tracing_;
|
||||
WebRtcVoiceEngine* voice_engine_;
|
||||
rtc::scoped_ptr<webrtc::VideoRender> render_module_;
|
||||
rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_;
|
||||
WebRtcVideoEncoderFactory* encoder_factory_;
|
||||
WebRtcVideoDecoderFactory* decoder_factory_;
|
||||
std::vector<VideoCodec> video_codecs_;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "talk/media/base/videocapturer.h"
|
||||
#include "talk/media/base/videorenderer.h"
|
||||
#include "talk/media/webrtc/constants.h"
|
||||
#include "talk/media/webrtc/simulcast.h"
|
||||
#include "talk/media/webrtc/webrtcvideocapturer.h"
|
||||
#include "talk/media/webrtc/webrtcvideoengine.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframe.h"
|
||||
@ -184,15 +185,43 @@ static std::vector<webrtc::RtpExtension> FilterRtpExtensions(
|
||||
WebRtcVideoEncoderFactory2::~WebRtcVideoEncoderFactory2() {
|
||||
}
|
||||
|
||||
std::vector<webrtc::VideoStream>
|
||||
WebRtcVideoEncoderFactory2::CreateSimulcastVideoStreams(
|
||||
const VideoCodec& codec,
|
||||
const VideoOptions& options,
|
||||
size_t num_streams) {
|
||||
// Use default factory for non-simulcast.
|
||||
int max_qp = kDefaultQpMax;
|
||||
codec.GetParam(kCodecParamMaxQuantization, &max_qp);
|
||||
|
||||
int min_bitrate_kbps;
|
||||
if (!codec.GetParam(kCodecParamMinBitrate, &min_bitrate_kbps) ||
|
||||
min_bitrate_kbps < kMinVideoBitrate) {
|
||||
min_bitrate_kbps = kMinVideoBitrate;
|
||||
}
|
||||
|
||||
int max_bitrate_kbps;
|
||||
if (!codec.GetParam(kCodecParamMaxBitrate, &max_bitrate_kbps)) {
|
||||
max_bitrate_kbps = 0;
|
||||
}
|
||||
|
||||
return GetSimulcastConfig(
|
||||
num_streams,
|
||||
GetSimulcastBitrateMode(options),
|
||||
codec.width,
|
||||
codec.height,
|
||||
min_bitrate_kbps * 1000,
|
||||
max_bitrate_kbps * 1000,
|
||||
max_qp,
|
||||
codec.framerate != 0 ? codec.framerate : kDefaultVideoMaxFramerate);
|
||||
}
|
||||
|
||||
std::vector<webrtc::VideoStream> WebRtcVideoEncoderFactory2::CreateVideoStreams(
|
||||
const VideoCodec& codec,
|
||||
const VideoOptions& options,
|
||||
size_t num_streams) {
|
||||
if (num_streams != 1) {
|
||||
LOG(LS_WARNING) << "Unsupported number of streams (" << num_streams
|
||||
<< "), falling back to one.";
|
||||
num_streams = 1;
|
||||
}
|
||||
if (num_streams != 1)
|
||||
return CreateSimulcastVideoStreams(codec, options, num_streams);
|
||||
|
||||
webrtc::VideoStream stream;
|
||||
stream.width = codec.width;
|
||||
|
@ -106,6 +106,7 @@ class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler {
|
||||
VideoRenderer* default_renderer_;
|
||||
};
|
||||
|
||||
// TODO(pbos): Remove this class and just inline configuring code.
|
||||
class WebRtcVideoEncoderFactory2 {
|
||||
public:
|
||||
virtual ~WebRtcVideoEncoderFactory2();
|
||||
@ -114,6 +115,11 @@ class WebRtcVideoEncoderFactory2 {
|
||||
const VideoOptions& options,
|
||||
size_t num_streams);
|
||||
|
||||
std::vector<webrtc::VideoStream> CreateSimulcastVideoStreams(
|
||||
const VideoCodec& codec,
|
||||
const VideoOptions& options,
|
||||
size_t num_streams);
|
||||
|
||||
virtual void* CreateVideoEncoderSettings(const VideoCodec& codec,
|
||||
const VideoOptions& options);
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "talk/media/base/testutils.h"
|
||||
#include "talk/media/base/videoengine_unittest.h"
|
||||
#include "talk/media/webrtc/fakewebrtcvideoengine.h"
|
||||
#include "talk/media/webrtc/simulcast.h"
|
||||
#include "talk/media/webrtc/webrtcvideochannelfactory.h"
|
||||
#include "talk/media/webrtc/webrtcvideoengine2.h"
|
||||
#include "talk/media/webrtc/webrtcvideoengine2_unittest.h"
|
||||
@ -40,8 +41,13 @@
|
||||
#include "webrtc/video_encoder.h"
|
||||
|
||||
namespace {
|
||||
static const int kDefaultQpMax = 56;
|
||||
static const int kDefaultFramerate = 30;
|
||||
static const int kMinBitrateBps = 30000;
|
||||
|
||||
static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30, 0);
|
||||
static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30, 0);
|
||||
static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30, 0);
|
||||
|
||||
static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30, 0);
|
||||
static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30, 0);
|
||||
@ -51,6 +57,7 @@ static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0, 0);
|
||||
static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0);
|
||||
|
||||
static const uint32 kSsrcs1[] = {1};
|
||||
static const uint32 kSsrcs3[] = {1, 2, 3};
|
||||
static const uint32 kRtxSsrcs1[] = {4};
|
||||
static const char kUnsupportedExtensionName[] =
|
||||
"urn:ietf:params:rtp-hdrext:unsupported";
|
||||
@ -1897,4 +1904,451 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsReportsUpperResolution) {
|
||||
EXPECT_EQ(90, info.senders[0].send_frame_height);
|
||||
}
|
||||
|
||||
class WebRtcVideoEngine2SimulcastTest : public testing::Test {
|
||||
public:
|
||||
WebRtcVideoEngine2SimulcastTest()
|
||||
: engine_codecs_(engine_.codecs()) {
|
||||
assert(!engine_codecs_.empty());
|
||||
|
||||
bool codec_set = false;
|
||||
for (size_t i = 0; i < engine_codecs_.size(); ++i) {
|
||||
if (engine_codecs_[i].name == "red") {
|
||||
default_red_codec_ = engine_codecs_[i];
|
||||
} else if (engine_codecs_[i].name == "ulpfec") {
|
||||
default_ulpfec_codec_ = engine_codecs_[i];
|
||||
} else if (engine_codecs_[i].name == "rtx") {
|
||||
default_rtx_codec_ = engine_codecs_[i];
|
||||
} else if (!codec_set) {
|
||||
default_codec_ = engine_codecs_[i];
|
||||
codec_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
assert(codec_set);
|
||||
}
|
||||
|
||||
protected:
|
||||
WebRtcVideoEngine2 engine_;
|
||||
VideoCodec default_codec_;
|
||||
VideoCodec default_red_codec_;
|
||||
VideoCodec default_ulpfec_codec_;
|
||||
VideoCodec default_rtx_codec_;
|
||||
// TODO(pbos): Remove engine_codecs_ unless used a lot.
|
||||
std::vector<VideoCodec> engine_codecs_;
|
||||
};
|
||||
|
||||
class WebRtcVideoChannel2SimulcastTest : public WebRtcVideoEngine2SimulcastTest,
|
||||
public WebRtcCallFactory {
|
||||
public:
|
||||
WebRtcVideoChannel2SimulcastTest() : fake_call_(NULL) {}
|
||||
|
||||
virtual void SetUp() OVERRIDE {
|
||||
engine_.SetCallFactory(this);
|
||||
engine_.Init(rtc::Thread::Current());
|
||||
channel_.reset(engine_.CreateChannel(VideoOptions(), NULL));
|
||||
ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory.";
|
||||
last_ssrc_ = 123;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual webrtc::Call* CreateCall(
|
||||
const webrtc::Call::Config& config) OVERRIDE {
|
||||
assert(fake_call_ == NULL);
|
||||
fake_call_ = new FakeCall(config);
|
||||
return fake_call_;
|
||||
}
|
||||
|
||||
void VerifySimulcastSettings(const VideoCodec& codec,
|
||||
VideoOptions::HighestBitrate bitrate_mode,
|
||||
size_t num_configured_streams,
|
||||
size_t expected_num_streams,
|
||||
SimulcastBitrateMode simulcast_bitrate_mode) {
|
||||
cricket::VideoOptions options;
|
||||
options.video_highest_bitrate.Set(bitrate_mode);
|
||||
EXPECT_TRUE(channel_->SetOptions(options));
|
||||
|
||||
std::vector<VideoCodec> codecs;
|
||||
codecs.push_back(codec);
|
||||
ASSERT_TRUE(channel_->SetSendCodecs(codecs));
|
||||
|
||||
std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs3);
|
||||
assert(num_configured_streams <= ssrcs.size());
|
||||
ssrcs.resize(num_configured_streams);
|
||||
|
||||
FakeVideoSendStream* stream =
|
||||
AddSendStream(CreateSimStreamParams("cname", ssrcs));
|
||||
|
||||
std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
|
||||
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,
|
||||
kMinBitrateBps,
|
||||
0,
|
||||
kDefaultQpMax,
|
||||
codec.framerate != 0 ? codec.framerate : kDefaultFramerate);
|
||||
|
||||
ASSERT_EQ(expected_streams.size(), video_streams.size());
|
||||
|
||||
size_t num_streams = video_streams.size();
|
||||
for (size_t i = 0; i < num_streams; ++i) {
|
||||
EXPECT_EQ(expected_streams[i].width, video_streams[i].width);
|
||||
EXPECT_EQ(expected_streams[i].height, video_streams[i].height);
|
||||
|
||||
EXPECT_GT(video_streams[i].max_framerate, 0);
|
||||
EXPECT_EQ(expected_streams[i].max_framerate,
|
||||
video_streams[i].max_framerate);
|
||||
|
||||
EXPECT_GT(video_streams[i].min_bitrate_bps, 0);
|
||||
EXPECT_EQ(expected_streams[i].min_bitrate_bps,
|
||||
video_streams[i].min_bitrate_bps);
|
||||
|
||||
EXPECT_GT(video_streams[i].target_bitrate_bps, 0);
|
||||
EXPECT_EQ(expected_streams[i].target_bitrate_bps,
|
||||
video_streams[i].target_bitrate_bps);
|
||||
|
||||
EXPECT_GT(video_streams[i].max_bitrate_bps, 0);
|
||||
EXPECT_EQ(expected_streams[i].max_bitrate_bps,
|
||||
video_streams[i].max_bitrate_bps);
|
||||
|
||||
EXPECT_GT(video_streams[i].max_qp, 0);
|
||||
EXPECT_EQ(expected_streams[i].max_qp, video_streams[i].max_qp);
|
||||
|
||||
EXPECT_FALSE(expected_streams[i].temporal_layer_thresholds_bps.empty());
|
||||
EXPECT_EQ(expected_streams[i].temporal_layer_thresholds_bps,
|
||||
video_streams[i].temporal_layer_thresholds_bps);
|
||||
}
|
||||
|
||||
EXPECT_EQ(kMinBitrateBps, video_streams[0].min_bitrate_bps);
|
||||
}
|
||||
|
||||
FakeVideoSendStream* AddSendStream() {
|
||||
return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
|
||||
}
|
||||
|
||||
FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
|
||||
size_t num_streams =
|
||||
fake_call_->GetVideoSendStreams().size();
|
||||
EXPECT_TRUE(channel_->AddSendStream(sp));
|
||||
std::vector<FakeVideoSendStream*> streams =
|
||||
fake_call_->GetVideoSendStreams();
|
||||
EXPECT_EQ(num_streams + 1, streams.size());
|
||||
return streams[streams.size() - 1];
|
||||
}
|
||||
|
||||
std::vector<FakeVideoSendStream*> GetFakeSendStreams() {
|
||||
return fake_call_->GetVideoSendStreams();
|
||||
}
|
||||
|
||||
FakeVideoReceiveStream* AddRecvStream() {
|
||||
return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++));
|
||||
}
|
||||
|
||||
FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) {
|
||||
size_t num_streams =
|
||||
fake_call_->GetVideoReceiveStreams().size();
|
||||
EXPECT_TRUE(channel_->AddRecvStream(sp));
|
||||
std::vector<FakeVideoReceiveStream*> streams =
|
||||
fake_call_->GetVideoReceiveStreams();
|
||||
EXPECT_EQ(num_streams + 1, streams.size());
|
||||
return streams[streams.size() - 1];
|
||||
}
|
||||
|
||||
FakeCall* fake_call_;
|
||||
rtc::scoped_ptr<VideoMediaChannel> channel_;
|
||||
uint32 last_ssrc_;
|
||||
};
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
|
||||
VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Test that we normalize send codec format size in simulcast.
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
|
||||
cricket::VideoCodec codec(kVp8Codec270p);
|
||||
codec.width += 1;
|
||||
codec.height += 1;
|
||||
VerifySimulcastSettings(codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL);
|
||||
}
|
||||
|
||||
// Test that if we add a stream with RTX SSRC's, SSRC's get set correctly.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that if we get too few ssrcs are given in AddSendStream(),
|
||||
// only supported sub-streams will be added.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TooFewSimulcastSsrcs) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that even more than enough ssrcs are given in AddSendStream(),
|
||||
// only supported sub-streams will be added.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_MoreThanEnoughSimulcastSscrs) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that SetSendStreamFormat works well with simulcast.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_SetSendStreamFormatWithSimulcast) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that simulcast send codec is reset on new video frame size.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_ResetSimulcastSendCodecOnNewFrameSize) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that simulcast send codec is reset on new portait mode video frame.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_ResetSimulcastSendCodecOnNewPortaitFrame) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_SetBandwidthInConferenceWithSimulcast) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that sending screencast frames in conference mode changes
|
||||
// bitrate.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_SetBandwidthScreencastInConference) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test AddSendStream with simulcast rejects bad StreamParams.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_AddSendStreamWithBadStreamParams) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test AddSendStream with simulcast sets ssrc and cname correctly.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_AddSendStreamWithSimulcast) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test RemoveSendStream with simulcast.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_RemoveSendStreamWithSimulcast) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test AddSendStream after send codec has already been set will reset
|
||||
// send codec with simulcast settings.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_AddSimulcastStreamAfterSetSendCodec) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_GetStatsWithMultipleSsrcs) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test receiving channel(s) local ssrc is set to the same as the first
|
||||
// simulcast sending ssrc.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_AddSimulcastStreamAfterCreatingRecvChannels) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test 1:1 call never turn on simulcast.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_NoSimulcastWith1on1) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test SetOptions with OPT_CONFERENCE flag.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_SetOptionsWithConferenceMode) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that two different streams can have different formats.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_MultipleSendStreamsDifferentFormats) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToOutputFormat) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToCpuLoad) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToCpuLoadDisabled) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_TestAdaptWithCpuOveruseObserver) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test that codec is not reset for every frame sent in non-conference and
|
||||
// non-screencast mode.
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_DontResetCodecOnSendFrame) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_UseSimulcastAdapterOnVp8OnlyFactory) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_DontUseSimulcastAdapterOnNoneVp8Factory) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoEngine2SimulcastTest,
|
||||
DISABLED_DontUseSimulcastAdapterOnMultipleCodecsFactory) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x800) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x720) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_960x540) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_960x600) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_640x400) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_640x360) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_480x300) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
DISABLED_DISABLED_SimulcastSend_480x270) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_320x200) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_320x180) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test reset send codec with simulcast.
|
||||
// Disabled per b/6773425
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
DISABLED_DISABLED_SimulcastResetSendCodec) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Test simulcast streams are decodeable with expected sizes.
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastStreams) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Simulcast and resolution resizing should be turned off when screencasting
|
||||
// but not otherwise.
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_ScreencastRendering) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Ensures that the correct settings are applied to the codec when single
|
||||
// temporal layer screencasting is enabled, and that the correct simulcast
|
||||
// settings are reapplied when disabling screencasting.
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
DISABLED_OneTemporalLayerScreencastSettings) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
|
||||
// Ensures that the correct settings are applied to the codec when two temporal
|
||||
// layer screencasting is enabled, and that the correct simulcast settings are
|
||||
// reapplied when disabling screencasting.
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
DISABLED_TwoTemporalLayerScreencastSettings) {
|
||||
// TODO(pbos): Implement.
|
||||
FAIL() << "Not implemented.";
|
||||
}
|
||||
} // namespace cricket
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user