2014-05-13 11:07:01 +00:00
|
|
|
/*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
2014-05-13 11:07:01 +00:00
|
|
|
*
|
2016-02-07 20:46:45 -08:00
|
|
|
* 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.
|
2014-05-13 11:07:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/webrtcvideoengine2.h"
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2016-03-21 04:15:50 -07:00
|
|
|
#include <stdio.h>
|
2015-01-05 18:51:13 +00:00
|
|
|
#include <algorithm>
|
2014-07-20 15:27:35 +00:00
|
|
|
#include <set>
|
2014-05-13 11:07:01 +00:00
|
|
|
#include <string>
|
2016-10-02 23:45:26 -07:00
|
|
|
#include <utility>
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2017-01-10 07:44:26 -08:00
|
|
|
#include "webrtc/api/video/i420_buffer.h"
|
2016-03-20 06:15:43 -07:00
|
|
|
#include "webrtc/base/copyonwritebuffer.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/logging.h"
|
|
|
|
|
#include "webrtc/base/stringutils.h"
|
2015-07-16 10:27:16 -07:00
|
|
|
#include "webrtc/base/timeutils.h"
|
2015-10-20 23:00:48 -07:00
|
|
|
#include "webrtc/base/trace_event.h"
|
2016-12-07 04:52:58 -08:00
|
|
|
#include "webrtc/call/call.h"
|
2016-11-16 00:48:13 -08:00
|
|
|
#include "webrtc/common_video/h264/profile_level_id.h"
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/constants.h"
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
#include "webrtc/media/engine/internalencoderfactory.h"
|
2016-12-01 00:27:27 -08:00
|
|
|
#include "webrtc/media/engine/internaldecoderfactory.h"
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/simulcast.h"
|
2016-11-15 06:30:54 -08:00
|
|
|
#include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h"
|
2016-11-22 01:43:03 -08:00
|
|
|
#include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h"
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/webrtcmediaengine.h"
|
|
|
|
|
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
|
|
|
|
#include "webrtc/media/engine/webrtcvoiceengine.h"
|
2015-05-07 11:41:09 +02:00
|
|
|
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/field_trial.h"
|
2014-10-29 15:28:39 +00:00
|
|
|
#include "webrtc/video_decoder.h"
|
2014-09-17 09:02:25 +00:00
|
|
|
#include "webrtc/video_encoder.h"
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
2014-10-14 04:25:33 +00:00
|
|
|
namespace {
|
2015-05-07 11:41:09 +02:00
|
|
|
|
2016-11-22 02:16:47 -08:00
|
|
|
// Three things happen when the FlexFEC field trial is enabled:
|
|
|
|
|
// 1) FlexFEC is exposed in the default codec list, eventually showing up
|
|
|
|
|
// in the default SDP. (See InternalEncoderFactory ctor.)
|
|
|
|
|
// 2) FlexFEC send parameters are set in the VideoSendStream config.
|
|
|
|
|
// 3) FlexFEC receive parameters are set in the FlexfecReceiveStream config,
|
|
|
|
|
// and the corresponding object is instantiated.
|
|
|
|
|
const char kFlexfecFieldTrialName[] = "WebRTC-FlexFEC-03";
|
|
|
|
|
|
|
|
|
|
bool IsFlexfecFieldTrialEnabled() {
|
2017-02-28 08:50:47 -08:00
|
|
|
return webrtc::field_trial::IsEnabled(kFlexfecFieldTrialName);
|
2016-11-22 02:16:47 -08:00
|
|
|
}
|
|
|
|
|
|
2015-05-07 11:41:09 +02:00
|
|
|
// 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.
|
|
|
|
|
webrtc::VideoEncoder* Create() override {
|
2016-10-28 07:43:45 -07:00
|
|
|
return factory_->CreateVideoEncoder(VideoCodec(kVp8CodecName));
|
2015-05-07 11:41:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Destroy(webrtc::VideoEncoder* encoder) override {
|
|
|
|
|
return factory_->DestroyVideoEncoder(encoder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
cricket::WebRtcVideoEncoderFactory* const factory_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// An encoder factory that wraps Create requests for simulcastable codec types
|
|
|
|
|
// with a webrtc::SimulcastEncoderAdapter. Non simulcastable codec type
|
|
|
|
|
// requests are just passed through to the contained encoder factory.
|
|
|
|
|
class WebRtcSimulcastEncoderFactory
|
|
|
|
|
: public cricket::WebRtcVideoEncoderFactory {
|
|
|
|
|
public:
|
|
|
|
|
// WebRtcSimulcastEncoderFactory doesn't take ownership of |factory|, which is
|
|
|
|
|
// owned by e.g. PeerConnectionFactory.
|
|
|
|
|
explicit WebRtcSimulcastEncoderFactory(
|
|
|
|
|
cricket::WebRtcVideoEncoderFactory* factory)
|
|
|
|
|
: factory_(factory) {}
|
|
|
|
|
|
|
|
|
|
static bool UseSimulcastEncoderFactory(
|
2016-10-28 07:43:45 -07:00
|
|
|
const std::vector<cricket::VideoCodec>& codecs) {
|
2015-05-07 11:41:09 +02:00
|
|
|
// If any codec is VP8, use the simulcast factory. If asked to create a
|
|
|
|
|
// non-VP8 codec, we'll just return a contained factory encoder directly.
|
|
|
|
|
for (const auto& codec : codecs) {
|
2016-10-28 07:43:45 -07:00
|
|
|
if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) {
|
2015-05-07 11:41:09 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::VideoEncoder* CreateVideoEncoder(
|
2016-10-28 07:43:45 -07:00
|
|
|
const cricket::VideoCodec& codec) override {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(factory_ != NULL);
|
2015-05-07 11:41:09 +02:00
|
|
|
// If it's a codec type we can simulcast, create a wrapped encoder.
|
2016-10-28 07:43:45 -07:00
|
|
|
if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) {
|
2015-05-07 11:41:09 +02:00
|
|
|
return new webrtc::SimulcastEncoderAdapter(
|
|
|
|
|
new EncoderFactoryAdapter(factory_));
|
|
|
|
|
}
|
2016-10-28 07:43:45 -07:00
|
|
|
webrtc::VideoEncoder* encoder = factory_->CreateVideoEncoder(codec);
|
2015-05-07 11:41:09 +02:00
|
|
|
if (encoder) {
|
|
|
|
|
non_simulcast_encoders_.push_back(encoder);
|
|
|
|
|
}
|
|
|
|
|
return encoder;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 07:43:45 -07:00
|
|
|
const std::vector<cricket::VideoCodec>& supported_codecs() const override {
|
|
|
|
|
return factory_->supported_codecs();
|
2015-05-07 11:41:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EncoderTypeHasInternalSource(
|
|
|
|
|
webrtc::VideoCodecType type) const override {
|
|
|
|
|
return factory_->EncoderTypeHasInternalSource(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) override {
|
|
|
|
|
// Check first to see if the encoder wasn't wrapped in a
|
|
|
|
|
// SimulcastEncoderAdapter. In that case, ask the factory to destroy it.
|
|
|
|
|
if (std::remove(non_simulcast_encoders_.begin(),
|
|
|
|
|
non_simulcast_encoders_.end(),
|
|
|
|
|
encoder) != non_simulcast_encoders_.end()) {
|
|
|
|
|
factory_->DestroyVideoEncoder(encoder);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Otherwise, SimulcastEncoderAdapter can be deleted directly, and will call
|
|
|
|
|
// DestroyVideoEncoder on the factory for individual encoder instances.
|
|
|
|
|
delete encoder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2016-11-02 11:08:29 -07:00
|
|
|
// Disable overloaded virtual function warning. TODO(magjed): Remove once
|
|
|
|
|
// http://crbug/webrtc/6402 is fixed.
|
|
|
|
|
using cricket::WebRtcVideoEncoderFactory::CreateVideoEncoder;
|
|
|
|
|
|
2015-05-07 11:41:09 +02:00
|
|
|
cricket::WebRtcVideoEncoderFactory* factory_;
|
|
|
|
|
// A list of encoders that were created without being wrapped in a
|
|
|
|
|
// SimulcastEncoderAdapter.
|
|
|
|
|
std::vector<webrtc::VideoEncoder*> non_simulcast_encoders_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void AddDefaultFeedbackParams(VideoCodec* codec) {
|
|
|
|
|
codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir));
|
|
|
|
|
codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty));
|
|
|
|
|
codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli));
|
|
|
|
|
codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty));
|
2015-11-20 18:05:48 -08:00
|
|
|
codec->AddFeedbackParam(
|
|
|
|
|
FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty));
|
2015-05-07 11:41:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-14 04:25:33 +00:00
|
|
|
static std::string CodecVectorToString(const std::vector<VideoCodec>& codecs) {
|
|
|
|
|
std::stringstream out;
|
|
|
|
|
out << '{';
|
|
|
|
|
for (size_t i = 0; i < codecs.size(); ++i) {
|
|
|
|
|
out << codecs[i].ToString();
|
|
|
|
|
if (i != codecs.size() - 1) {
|
|
|
|
|
out << ", ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out << '}';
|
|
|
|
|
return out.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool ValidateCodecFormats(const std::vector<VideoCodec>& codecs) {
|
|
|
|
|
bool has_video = false;
|
|
|
|
|
for (size_t i = 0; i < codecs.size(); ++i) {
|
|
|
|
|
if (!codecs[i].ValidateCodecFormat()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (codecs[i].GetCodecType() == VideoCodec::CODEC_VIDEO) {
|
|
|
|
|
has_video = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!has_video) {
|
|
|
|
|
LOG(LS_ERROR) << "Setting codecs without a video codec is invalid: "
|
|
|
|
|
<< CodecVectorToString(codecs);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-25 14:17:23 +01:00
|
|
|
static bool ValidateStreamParams(const StreamParams& sp) {
|
|
|
|
|
if (sp.ssrcs.empty()) {
|
|
|
|
|
LOG(LS_ERROR) << "No SSRCs in stream parameters: " << sp.ToString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
std::vector<uint32_t> primary_ssrcs;
|
2015-03-25 14:17:23 +01:00
|
|
|
sp.GetPrimarySsrcs(&primary_ssrcs);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
std::vector<uint32_t> rtx_ssrcs;
|
2015-03-25 14:17:23 +01:00
|
|
|
sp.GetFidSsrcs(primary_ssrcs, &rtx_ssrcs);
|
|
|
|
|
for (uint32_t rtx_ssrc : rtx_ssrcs) {
|
|
|
|
|
bool rtx_ssrc_present = false;
|
|
|
|
|
for (uint32_t sp_ssrc : sp.ssrcs) {
|
|
|
|
|
if (sp_ssrc == rtx_ssrc) {
|
|
|
|
|
rtx_ssrc_present = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!rtx_ssrc_present) {
|
|
|
|
|
LOG(LS_ERROR) << "RTX SSRC '" << rtx_ssrc
|
|
|
|
|
<< "' missing from StreamParams ssrcs: " << sp.ToString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!rtx_ssrcs.empty() && primary_ssrcs.size() != rtx_ssrcs.size()) {
|
|
|
|
|
LOG(LS_ERROR)
|
|
|
|
|
<< "RTX SSRCs exist, but don't cover all SSRCs (unsupported): "
|
|
|
|
|
<< sp.ToString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 01:59:29 -07:00
|
|
|
// Returns true if the given codec is disallowed from doing simulcast.
|
|
|
|
|
bool IsCodecBlacklistedForSimulcast(const std::string& codec_name) {
|
2015-11-10 05:16:26 -08:00
|
|
|
return CodecNamesEq(codec_name, kH264CodecName) ||
|
|
|
|
|
CodecNamesEq(codec_name, kVp9CodecName);
|
2015-08-27 01:59:29 -07:00
|
|
|
}
|
|
|
|
|
|
2015-09-08 09:21:43 +02:00
|
|
|
// The selected thresholds for QVGA and VGA corresponded to a QP around 10.
|
|
|
|
|
// The change in QP declined above the selected bitrates.
|
|
|
|
|
static int GetMaxDefaultVideoBitrateKbps(int width, int height) {
|
|
|
|
|
if (width * height <= 320 * 240) {
|
|
|
|
|
return 600;
|
|
|
|
|
} else if (width * height <= 640 * 480) {
|
|
|
|
|
return 1700;
|
|
|
|
|
} else if (width * height <= 960 * 540) {
|
|
|
|
|
return 2000;
|
|
|
|
|
} else {
|
|
|
|
|
return 2500;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-29 00:04:41 -08:00
|
|
|
|
2016-03-21 04:15:50 -07:00
|
|
|
bool GetVp9LayersFromFieldTrialGroup(int* num_spatial_layers,
|
|
|
|
|
int* num_temporal_layers) {
|
|
|
|
|
std::string group = webrtc::field_trial::FindFullName("WebRTC-SupportVP9SVC");
|
|
|
|
|
if (group.empty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (sscanf(group.c_str(), "EnabledByFlag_%dSL%dTL", num_spatial_layers,
|
|
|
|
|
num_temporal_layers) != 2) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-03-31 00:36:49 -07:00
|
|
|
const int kMaxSpatialLayers = 2;
|
2016-03-21 04:15:50 -07:00
|
|
|
if (*num_spatial_layers > kMaxSpatialLayers || *num_spatial_layers < 1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const int kMaxTemporalLayers = 3;
|
|
|
|
|
if (*num_temporal_layers > kMaxTemporalLayers || *num_temporal_layers < 1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetDefaultVp9SpatialLayers() {
|
|
|
|
|
int num_sl;
|
|
|
|
|
int num_tl;
|
|
|
|
|
if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) {
|
|
|
|
|
return num_sl;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetDefaultVp9TemporalLayers() {
|
|
|
|
|
int num_sl;
|
|
|
|
|
int num_tl;
|
|
|
|
|
if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) {
|
|
|
|
|
return num_tl;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2016-10-02 23:45:26 -07:00
|
|
|
|
|
|
|
|
class EncoderStreamFactory
|
|
|
|
|
: public webrtc::VideoEncoderConfig::VideoStreamFactoryInterface {
|
|
|
|
|
public:
|
|
|
|
|
EncoderStreamFactory(std::string codec_name,
|
|
|
|
|
int max_qp,
|
|
|
|
|
int max_framerate,
|
|
|
|
|
bool is_screencast,
|
|
|
|
|
bool conference_mode)
|
|
|
|
|
: codec_name_(codec_name),
|
|
|
|
|
max_qp_(max_qp),
|
|
|
|
|
max_framerate_(max_framerate),
|
|
|
|
|
is_screencast_(is_screencast),
|
|
|
|
|
conference_mode_(conference_mode) {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::vector<webrtc::VideoStream> CreateEncoderStreams(
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
const webrtc::VideoEncoderConfig& encoder_config) override {
|
2017-01-26 06:12:26 -08:00
|
|
|
if (is_screencast_ &&
|
|
|
|
|
(!conference_mode_ || !cricket::UseSimulcastScreenshare())) {
|
|
|
|
|
RTC_DCHECK_EQ(1, encoder_config.number_of_streams);
|
|
|
|
|
}
|
|
|
|
|
if (encoder_config.number_of_streams > 1 ||
|
|
|
|
|
(CodecNamesEq(codec_name_, kVp8CodecName) && is_screencast_ &&
|
|
|
|
|
conference_mode_)) {
|
2016-10-02 23:45:26 -07:00
|
|
|
return GetSimulcastConfig(encoder_config.number_of_streams, width, height,
|
|
|
|
|
encoder_config.max_bitrate_bps, max_qp_,
|
2017-01-26 06:12:26 -08:00
|
|
|
max_framerate_, is_screencast_);
|
2016-10-02 23:45:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For unset max bitrates set default bitrate for non-simulcast.
|
|
|
|
|
int max_bitrate_bps =
|
|
|
|
|
(encoder_config.max_bitrate_bps > 0)
|
|
|
|
|
? encoder_config.max_bitrate_bps
|
|
|
|
|
: GetMaxDefaultVideoBitrateKbps(width, height) * 1000;
|
|
|
|
|
|
|
|
|
|
webrtc::VideoStream stream;
|
|
|
|
|
stream.width = width;
|
|
|
|
|
stream.height = height;
|
|
|
|
|
stream.max_framerate = max_framerate_;
|
|
|
|
|
stream.min_bitrate_bps = kMinVideoBitrateKbps * 1000;
|
|
|
|
|
stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps;
|
|
|
|
|
stream.max_qp = max_qp_;
|
|
|
|
|
|
|
|
|
|
if (CodecNamesEq(codec_name_, kVp9CodecName) && !is_screencast_) {
|
|
|
|
|
stream.temporal_layer_thresholds_bps.resize(
|
|
|
|
|
GetDefaultVp9TemporalLayers() - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<webrtc::VideoStream> streams;
|
|
|
|
|
streams.push_back(stream);
|
|
|
|
|
return streams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::string codec_name_;
|
|
|
|
|
const int max_qp_;
|
|
|
|
|
const int max_framerate_;
|
|
|
|
|
const bool is_screencast_;
|
|
|
|
|
const bool conference_mode_;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-14 04:25:33 +00:00
|
|
|
} // namespace
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2016-02-12 06:39:40 +01:00
|
|
|
// Constants defined in webrtc/media/engine/constants.h
|
2015-05-07 11:41:09 +02:00
|
|
|
// TODO(pbos): Move these to a separate constants.cc file.
|
2016-10-02 23:45:26 -07:00
|
|
|
const int kMinVideoBitrateKbps = 30;
|
2015-05-07 11:41:09 +02:00
|
|
|
|
|
|
|
|
const int kVideoMtu = 1200;
|
|
|
|
|
const int kVideoRtpBufferSize = 65536;
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
// This constant is really an on/off, lower-level configurable NACK history
|
|
|
|
|
// duration hasn't been implemented.
|
|
|
|
|
static const int kNackHistoryMs = 1000;
|
|
|
|
|
|
2014-09-18 20:23:05 +00:00
|
|
|
static const int kDefaultQpMax = 56;
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
static const int kDefaultRtcpReceiverReportSsrc = 1;
|
|
|
|
|
|
2016-08-11 08:41:18 -07:00
|
|
|
// Minimum time interval for logging stats.
|
|
|
|
|
static const int64_t kStatsLogIntervalMs = 10000;
|
|
|
|
|
|
2016-10-28 07:43:45 -07:00
|
|
|
static std::vector<VideoCodec> GetSupportedCodecs(
|
|
|
|
|
const WebRtcVideoEncoderFactory* external_encoder_factory);
|
|
|
|
|
|
2016-09-27 03:52:02 -07:00
|
|
|
rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings(
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
const VideoCodec& codec) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
bool is_screencast = parameters_.options.is_screencast.value_or(false);
|
2015-09-09 14:32:14 +02:00
|
|
|
// No automatic resizing when using simulcast or screencast.
|
|
|
|
|
bool automatic_resize =
|
|
|
|
|
!is_screencast && parameters_.config.rtp.ssrcs.size() == 1;
|
2015-04-28 10:01:41 +02:00
|
|
|
bool frame_dropping = !is_screencast;
|
|
|
|
|
bool denoising;
|
2015-10-26 11:18:18 -07:00
|
|
|
bool codec_default_denoising = false;
|
2015-04-28 10:01:41 +02:00
|
|
|
if (is_screencast) {
|
|
|
|
|
denoising = false;
|
|
|
|
|
} else {
|
2015-10-26 11:18:18 -07:00
|
|
|
// Use codec default if video_noise_reduction is unset.
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
codec_default_denoising = !parameters_.options.video_noise_reduction;
|
|
|
|
|
denoising = parameters_.options.video_noise_reduction.value_or(false);
|
2015-04-28 10:01:41 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-27 01:36:03 -08:00
|
|
|
if (CodecNamesEq(codec.name, kH264CodecName)) {
|
2016-09-27 03:52:02 -07:00
|
|
|
webrtc::VideoCodecH264 h264_settings =
|
|
|
|
|
webrtc::VideoEncoder::GetDefaultH264Settings();
|
|
|
|
|
h264_settings.frameDroppingOn = frame_dropping;
|
|
|
|
|
return new rtc::RefCountedObject<
|
|
|
|
|
webrtc::VideoEncoderConfig::H264EncoderSpecificSettings>(h264_settings);
|
2016-01-27 01:36:03 -08:00
|
|
|
}
|
2015-04-21 20:24:50 +08:00
|
|
|
if (CodecNamesEq(codec.name, kVp8CodecName)) {
|
2016-09-27 03:52:02 -07:00
|
|
|
webrtc::VideoCodecVP8 vp8_settings =
|
|
|
|
|
webrtc::VideoEncoder::GetDefaultVp8Settings();
|
|
|
|
|
vp8_settings.automaticResizeOn = automatic_resize;
|
2015-10-26 11:18:18 -07:00
|
|
|
// VP8 denoising is enabled by default.
|
2016-09-27 03:52:02 -07:00
|
|
|
vp8_settings.denoisingOn = codec_default_denoising ? true : denoising;
|
|
|
|
|
vp8_settings.frameDroppingOn = frame_dropping;
|
|
|
|
|
return new rtc::RefCountedObject<
|
|
|
|
|
webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
|
2014-07-22 16:29:54 +00:00
|
|
|
}
|
2015-04-21 20:24:50 +08:00
|
|
|
if (CodecNamesEq(codec.name, kVp9CodecName)) {
|
2016-09-27 03:52:02 -07:00
|
|
|
webrtc::VideoCodecVP9 vp9_settings =
|
|
|
|
|
webrtc::VideoEncoder::GetDefaultVp9Settings();
|
2016-03-21 04:15:50 -07:00
|
|
|
if (is_screencast) {
|
|
|
|
|
// TODO(asapersson): Set to 2 for now since there is a DCHECK in
|
|
|
|
|
// VideoSendStream::ReconfigureVideoEncoder.
|
2016-09-27 03:52:02 -07:00
|
|
|
vp9_settings.numberOfSpatialLayers = 2;
|
2016-03-21 04:15:50 -07:00
|
|
|
} else {
|
2016-09-27 03:52:02 -07:00
|
|
|
vp9_settings.numberOfSpatialLayers = GetDefaultVp9SpatialLayers();
|
2016-03-21 04:15:50 -07:00
|
|
|
}
|
2015-10-26 11:18:18 -07:00
|
|
|
// VP9 denoising is disabled by default.
|
2016-09-27 03:52:02 -07:00
|
|
|
vp9_settings.denoisingOn = codec_default_denoising ? false : denoising;
|
|
|
|
|
vp9_settings.frameDroppingOn = frame_dropping;
|
|
|
|
|
return new rtc::RefCountedObject<
|
|
|
|
|
webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
|
2014-11-07 13:21:04 +00:00
|
|
|
}
|
2016-09-27 03:52:02 -07:00
|
|
|
return nullptr;
|
2014-07-22 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
2014-08-12 23:17:13 +00:00
|
|
|
DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler()
|
2016-02-04 01:24:52 -08:00
|
|
|
: default_recv_ssrc_(0), default_sink_(NULL) {}
|
2014-08-12 23:17:13 +00:00
|
|
|
|
|
|
|
|
UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc(
|
2015-03-06 15:35:19 +00:00
|
|
|
WebRtcVideoChannel2* channel,
|
2014-08-12 23:17:13 +00:00
|
|
|
uint32_t ssrc) {
|
2017-02-17 15:46:43 -08:00
|
|
|
if (default_recv_ssrc_ != 0) { // Already one default stream, so replace it.
|
|
|
|
|
channel->RemoveRecvStream(default_recv_ssrc_);
|
|
|
|
|
default_recv_ssrc_ = 0;
|
2014-08-12 23:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamParams sp;
|
|
|
|
|
sp.ssrcs.push_back(ssrc);
|
|
|
|
|
LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << ".";
|
2015-03-06 15:35:19 +00:00
|
|
|
if (!channel->AddRecvStream(sp, true)) {
|
2014-08-12 23:17:13 +00:00
|
|
|
LOG(LS_WARNING) << "Could not create default receive stream.";
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-04 01:24:52 -08:00
|
|
|
channel->SetSink(ssrc, default_sink_);
|
2014-08-12 23:17:13 +00:00
|
|
|
default_recv_ssrc_ = ssrc;
|
|
|
|
|
return kDeliverPacket;
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>*
|
2016-02-04 01:24:52 -08:00
|
|
|
DefaultUnsignalledSsrcHandler::GetDefaultSink() const {
|
|
|
|
|
return default_sink_;
|
2014-08-12 23:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 01:24:52 -08:00
|
|
|
void DefaultUnsignalledSsrcHandler::SetDefaultSink(
|
2014-08-12 23:17:13 +00:00
|
|
|
VideoMediaChannel* channel,
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
|
2016-02-04 01:24:52 -08:00
|
|
|
default_sink_ = sink;
|
2014-08-12 23:17:13 +00:00
|
|
|
if (default_recv_ssrc_ != 0) {
|
2016-02-04 01:24:52 -08:00
|
|
|
channel->SetSink(default_recv_ssrc_, default_sink_);
|
2014-08-12 23:17:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 12:26:33 +02:00
|
|
|
WebRtcVideoEngine2::WebRtcVideoEngine2()
|
|
|
|
|
: initialized_(false),
|
2014-09-23 09:40:22 +00:00
|
|
|
external_decoder_factory_(NULL),
|
|
|
|
|
external_encoder_factory_(NULL) {
|
2014-08-26 11:08:06 +00:00
|
|
|
LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()";
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WebRtcVideoEngine2::~WebRtcVideoEngine2() {
|
|
|
|
|
LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2";
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 09:04:09 +02:00
|
|
|
void WebRtcVideoEngine2::Init() {
|
2014-05-13 11:07:01 +00:00
|
|
|
LOG(LS_INFO) << "WebRtcVideoEngine2::Init";
|
|
|
|
|
initialized_ = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel(
|
2015-09-15 12:26:33 +02:00
|
|
|
webrtc::Call* call,
|
2016-02-12 02:27:06 -08:00
|
|
|
const MediaConfig& config,
|
2015-09-15 12:26:33 +02:00
|
|
|
const VideoOptions& options) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(initialized_);
|
2015-09-15 12:26:33 +02:00
|
|
|
LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString();
|
2016-11-08 01:12:54 -08:00
|
|
|
return new WebRtcVideoChannel2(call, config, options,
|
2016-02-12 02:27:06 -08:00
|
|
|
external_encoder_factory_,
|
|
|
|
|
external_decoder_factory_);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-28 06:02:22 -08:00
|
|
|
std::vector<VideoCodec> WebRtcVideoEngine2::codecs() const {
|
|
|
|
|
return GetSupportedCodecs(external_encoder_factory_);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-07 10:45:43 +01:00
|
|
|
RtpCapabilities WebRtcVideoEngine2::GetCapabilities() const {
|
|
|
|
|
RtpCapabilities capabilities;
|
|
|
|
|
capabilities.header_extensions.push_back(
|
2016-05-26 11:24:55 -07:00
|
|
|
webrtc::RtpExtension(webrtc::RtpExtension::kTimestampOffsetUri,
|
|
|
|
|
webrtc::RtpExtension::kTimestampOffsetDefaultId));
|
2015-12-07 10:45:43 +01:00
|
|
|
capabilities.header_extensions.push_back(
|
2016-05-26 11:24:55 -07:00
|
|
|
webrtc::RtpExtension(webrtc::RtpExtension::kAbsSendTimeUri,
|
|
|
|
|
webrtc::RtpExtension::kAbsSendTimeDefaultId));
|
2015-12-07 10:45:43 +01:00
|
|
|
capabilities.header_extensions.push_back(
|
2016-05-26 11:24:55 -07:00
|
|
|
webrtc::RtpExtension(webrtc::RtpExtension::kVideoRotationUri,
|
|
|
|
|
webrtc::RtpExtension::kVideoRotationDefaultId));
|
2016-09-02 12:36:49 +02:00
|
|
|
capabilities.header_extensions.push_back(webrtc::RtpExtension(
|
|
|
|
|
webrtc::RtpExtension::kTransportSequenceNumberUri,
|
|
|
|
|
webrtc::RtpExtension::kTransportSequenceNumberDefaultId));
|
2016-06-08 00:24:21 -07:00
|
|
|
capabilities.header_extensions.push_back(
|
|
|
|
|
webrtc::RtpExtension(webrtc::RtpExtension::kPlayoutDelayUri,
|
|
|
|
|
webrtc::RtpExtension::kPlayoutDelayDefaultId));
|
2015-12-07 10:45:43 +01:00
|
|
|
return capabilities;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-23 09:40:22 +00:00
|
|
|
void WebRtcVideoEngine2::SetExternalDecoderFactory(
|
|
|
|
|
WebRtcVideoDecoderFactory* decoder_factory) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(!initialized_);
|
2014-09-23 09:40:22 +00:00
|
|
|
external_decoder_factory_ = decoder_factory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebRtcVideoEngine2::SetExternalEncoderFactory(
|
|
|
|
|
WebRtcVideoEncoderFactory* encoder_factory) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(!initialized_);
|
2015-01-14 16:26:23 +00:00
|
|
|
if (external_encoder_factory_ == encoder_factory)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// No matter what happens we shouldn't hold on to a stale
|
|
|
|
|
// WebRtcSimulcastEncoderFactory.
|
|
|
|
|
simulcast_encoder_factory_.reset();
|
|
|
|
|
|
|
|
|
|
if (encoder_factory &&
|
|
|
|
|
WebRtcSimulcastEncoderFactory::UseSimulcastEncoderFactory(
|
2016-10-28 07:43:45 -07:00
|
|
|
encoder_factory->supported_codecs())) {
|
2015-01-14 16:26:23 +00:00
|
|
|
simulcast_encoder_factory_.reset(
|
|
|
|
|
new WebRtcSimulcastEncoderFactory(encoder_factory));
|
|
|
|
|
encoder_factory = simulcast_encoder_factory_.get();
|
|
|
|
|
}
|
2014-09-23 09:40:22 +00:00
|
|
|
external_encoder_factory_ = encoder_factory;
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
// This is a helper function for AppendVideoCodecs below. It will return the
|
|
|
|
|
// first unused dynamic payload type (in the range [96, 127]), or nothing if no
|
|
|
|
|
// payload type is unused.
|
|
|
|
|
static rtc::Optional<int> NextFreePayloadType(
|
|
|
|
|
const std::vector<VideoCodec>& codecs) {
|
|
|
|
|
static const int kFirstDynamicPayloadType = 96;
|
|
|
|
|
static const int kLastDynamicPayloadType = 127;
|
|
|
|
|
bool is_payload_used[1 + kLastDynamicPayloadType - kFirstDynamicPayloadType] =
|
|
|
|
|
{false};
|
|
|
|
|
for (const VideoCodec& codec : codecs) {
|
|
|
|
|
if (kFirstDynamicPayloadType <= codec.id &&
|
|
|
|
|
codec.id <= kLastDynamicPayloadType) {
|
|
|
|
|
is_payload_used[codec.id - kFirstDynamicPayloadType] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = kFirstDynamicPayloadType; i <= kLastDynamicPayloadType; ++i) {
|
|
|
|
|
if (!is_payload_used[i - kFirstDynamicPayloadType])
|
|
|
|
|
return rtc::Optional<int>(i);
|
|
|
|
|
}
|
|
|
|
|
// No free payload type.
|
|
|
|
|
return rtc::Optional<int>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is a helper function for GetSupportedCodecs below. It will append new
|
|
|
|
|
// unique codecs from |input_codecs| to |unified_codecs|. It will add default
|
|
|
|
|
// feedback params to the codecs and will also add an associated RTX codec for
|
2017-01-13 07:15:54 -08:00
|
|
|
// recognized codecs (VP8, VP9, H264, and RED).
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
static void AppendVideoCodecs(const std::vector<VideoCodec>& input_codecs,
|
|
|
|
|
std::vector<VideoCodec>* unified_codecs) {
|
|
|
|
|
for (VideoCodec codec : input_codecs) {
|
|
|
|
|
const rtc::Optional<int> payload_type =
|
|
|
|
|
NextFreePayloadType(*unified_codecs);
|
|
|
|
|
if (!payload_type)
|
|
|
|
|
return;
|
|
|
|
|
codec.id = *payload_type;
|
|
|
|
|
// TODO(magjed): Move the responsibility of setting these parameters to the
|
|
|
|
|
// encoder factories instead.
|
2017-01-13 07:15:54 -08:00
|
|
|
if (codec.name != kRedCodecName && codec.name != kUlpfecCodecName &&
|
|
|
|
|
codec.name != kFlexfecCodecName)
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
AddDefaultFeedbackParams(&codec);
|
|
|
|
|
// Don't add same codec twice.
|
|
|
|
|
if (FindMatchingCodec(*unified_codecs, codec))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
unified_codecs->push_back(codec);
|
|
|
|
|
|
|
|
|
|
// Add associated RTX codec for recognized codecs.
|
|
|
|
|
// TODO(deadbeef): Should we add RTX codecs for external codecs whose names
|
|
|
|
|
// we don't recognize?
|
|
|
|
|
if (CodecNamesEq(codec.name, kVp8CodecName) ||
|
|
|
|
|
CodecNamesEq(codec.name, kVp9CodecName) ||
|
|
|
|
|
CodecNamesEq(codec.name, kH264CodecName) ||
|
|
|
|
|
CodecNamesEq(codec.name, kRedCodecName)) {
|
|
|
|
|
const rtc::Optional<int> rtx_payload_type =
|
|
|
|
|
NextFreePayloadType(*unified_codecs);
|
|
|
|
|
if (!rtx_payload_type)
|
|
|
|
|
return;
|
|
|
|
|
unified_codecs->push_back(
|
|
|
|
|
VideoCodec::CreateRtxCodec(*rtx_payload_type, codec.id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 07:43:45 -07:00
|
|
|
static std::vector<VideoCodec> GetSupportedCodecs(
|
|
|
|
|
const WebRtcVideoEncoderFactory* external_encoder_factory) {
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
const std::vector<VideoCodec> internal_codecs =
|
|
|
|
|
InternalEncoderFactory().supported_codecs();
|
|
|
|
|
LOG(LS_INFO) << "Internally supported codecs: "
|
|
|
|
|
<< CodecVectorToString(internal_codecs);
|
2014-10-14 04:25:33 +00:00
|
|
|
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
std::vector<VideoCodec> unified_codecs;
|
|
|
|
|
AppendVideoCodecs(internal_codecs, &unified_codecs);
|
2014-10-14 04:25:33 +00:00
|
|
|
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
if (external_encoder_factory != nullptr) {
|
|
|
|
|
const std::vector<VideoCodec>& external_codecs =
|
|
|
|
|
external_encoder_factory->supported_codecs();
|
|
|
|
|
AppendVideoCodecs(external_codecs, &unified_codecs);
|
|
|
|
|
LOG(LS_INFO) << "Codecs supported by the external encoder factory: "
|
|
|
|
|
<< CodecVectorToString(external_codecs);
|
|
|
|
|
}
|
2016-11-17 08:51:59 -08:00
|
|
|
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
return unified_codecs;
|
2014-10-14 04:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoChannel2(
|
2015-09-15 12:26:33 +02:00
|
|
|
webrtc::Call* call,
|
2016-02-12 02:27:06 -08:00
|
|
|
const MediaConfig& config,
|
2014-10-20 11:07:07 +00:00
|
|
|
const VideoOptions& options,
|
2014-10-14 04:25:33 +00:00
|
|
|
WebRtcVideoEncoderFactory* external_encoder_factory,
|
2015-01-14 17:29:27 +00:00
|
|
|
WebRtcVideoDecoderFactory* external_decoder_factory)
|
2016-02-12 02:27:06 -08:00
|
|
|
: VideoMediaChannel(config),
|
|
|
|
|
call_(call),
|
2015-09-15 12:26:33 +02:00
|
|
|
unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
|
2016-03-01 04:29:59 -08:00
|
|
|
video_config_(config.video),
|
2014-10-14 04:25:33 +00:00
|
|
|
external_encoder_factory_(external_encoder_factory),
|
2016-03-16 02:22:50 -07:00
|
|
|
external_decoder_factory_(external_decoder_factory),
|
2016-05-17 16:33:30 +02:00
|
|
|
default_send_options_(options),
|
2016-08-11 08:41:18 -07:00
|
|
|
last_stats_log_ms_(-1) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
2016-02-17 07:24:50 -08:00
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
|
|
|
|
|
sending_ = false;
|
2016-11-08 01:12:54 -08:00
|
|
|
recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory));
|
2014-07-22 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
WebRtcVideoChannel2::~WebRtcVideoChannel2() {
|
2015-03-27 15:58:11 +01:00
|
|
|
for (auto& kv : send_streams_)
|
|
|
|
|
delete kv.second;
|
|
|
|
|
for (auto& kv : receive_streams_)
|
|
|
|
|
delete kv.second;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-08 01:12:54 -08:00
|
|
|
rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>
|
|
|
|
|
WebRtcVideoChannel2::SelectSendVideoCodec(
|
|
|
|
|
const std::vector<VideoCodecSettings>& remote_mapped_codecs) const {
|
|
|
|
|
const std::vector<VideoCodec> local_supported_codecs =
|
2016-10-28 07:43:45 -07:00
|
|
|
GetSupportedCodecs(external_encoder_factory_);
|
2016-11-08 01:12:54 -08:00
|
|
|
// Select the first remote codec that is supported locally.
|
|
|
|
|
for (const VideoCodecSettings& remote_mapped_codec : remote_mapped_codecs) {
|
2016-11-12 09:53:04 -08:00
|
|
|
// For H264, we will limit the encode level to the remote offered level
|
|
|
|
|
// regardless if level asymmetry is allowed or not. This is strictly not
|
|
|
|
|
// following the spec in https://tools.ietf.org/html/rfc6184#section-8.2.2
|
|
|
|
|
// since we should limit the encode level to the lower of local and remote
|
|
|
|
|
// level when level asymmetry is not allowed.
|
|
|
|
|
if (FindMatchingCodec(local_supported_codecs, remote_mapped_codec.codec))
|
2016-11-08 01:12:54 -08:00
|
|
|
return rtc::Optional<VideoCodecSettings>(remote_mapped_codec);
|
2014-11-03 14:46:44 +00:00
|
|
|
}
|
2016-11-08 01:12:54 -08:00
|
|
|
// No remote codec was supported.
|
|
|
|
|
return rtc::Optional<VideoCodecSettings>();
|
2014-11-03 14:46:44 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-20 17:19:20 -07:00
|
|
|
bool WebRtcVideoChannel2::ReceiveCodecsHaveChanged(
|
|
|
|
|
std::vector<VideoCodecSettings> before,
|
|
|
|
|
std::vector<VideoCodecSettings> after) {
|
|
|
|
|
if (before.size() != after.size()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// The receive codec order doesn't matter, so we sort the codecs before
|
|
|
|
|
// comparing. This is necessary because currently the
|
|
|
|
|
// only way to change the send codec is to munge SDP, which causes
|
|
|
|
|
// the receive codec list to change order, which causes the streams
|
|
|
|
|
// to be recreates which causes a "blink" of black video. In order
|
|
|
|
|
// to support munging the SDP in this way without recreating receive
|
|
|
|
|
// streams, we ignore the order of the received codecs so that
|
|
|
|
|
// changing the order doesn't cause this "blink".
|
|
|
|
|
auto comparison =
|
|
|
|
|
[](const VideoCodecSettings& codec1, const VideoCodecSettings& codec2) {
|
|
|
|
|
return codec1.codec.id > codec2.codec.id;
|
|
|
|
|
};
|
|
|
|
|
std::sort(before.begin(), before.end(), comparison);
|
|
|
|
|
std::sort(after.begin(), after.end(), comparison);
|
2016-04-13 10:07:16 -07:00
|
|
|
return before != after;
|
2015-08-20 17:19:20 -07:00
|
|
|
}
|
|
|
|
|
|
2016-01-27 16:45:21 +01:00
|
|
|
bool WebRtcVideoChannel2::GetChangedSendParameters(
|
|
|
|
|
const VideoSendParameters& params,
|
|
|
|
|
ChangedSendParameters* changed_params) const {
|
|
|
|
|
if (!ValidateCodecFormats(params.codecs) ||
|
|
|
|
|
!ValidateRtpExtensions(params.extensions)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 01:12:54 -08:00
|
|
|
// Select one of the remote codecs that will be used as send codec.
|
|
|
|
|
const rtc::Optional<VideoCodecSettings> selected_send_codec =
|
|
|
|
|
SelectSendVideoCodec(MapCodecs(params.codecs));
|
2016-01-27 16:45:21 +01:00
|
|
|
|
2016-11-08 01:12:54 -08:00
|
|
|
if (!selected_send_codec) {
|
2016-01-27 16:45:21 +01:00
|
|
|
LOG(LS_ERROR) << "No video codecs supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 01:12:54 -08:00
|
|
|
if (!send_codec_ || *selected_send_codec != *send_codec_)
|
|
|
|
|
changed_params->codec = selected_send_codec;
|
2016-01-27 16:45:21 +01:00
|
|
|
|
2016-01-28 15:58:41 -08:00
|
|
|
// Handle RTP header extensions.
|
2016-01-27 16:45:21 +01:00
|
|
|
std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions(
|
|
|
|
|
params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true);
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
if (!send_rtp_extensions_ || (*send_rtp_extensions_ != filtered_extensions)) {
|
2016-01-27 16:45:21 +01:00
|
|
|
changed_params->rtp_header_extensions =
|
|
|
|
|
rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-28 15:58:41 -08:00
|
|
|
// Handle max bitrate.
|
2016-04-26 17:15:23 -07:00
|
|
|
if (params.max_bandwidth_bps != send_params_.max_bandwidth_bps &&
|
2016-01-27 16:45:21 +01:00
|
|
|
params.max_bandwidth_bps >= 0) {
|
|
|
|
|
// 0 uncaps max bitrate (-1).
|
|
|
|
|
changed_params->max_bandwidth_bps = rtc::Optional<int>(
|
|
|
|
|
params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 05:25:36 -08:00
|
|
|
// Handle conference mode.
|
|
|
|
|
if (params.conference_mode != send_params_.conference_mode) {
|
|
|
|
|
changed_params->conference_mode =
|
|
|
|
|
rtc::Optional<bool>(params.conference_mode);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-28 15:58:41 -08:00
|
|
|
// Handle RTCP mode.
|
2016-01-27 16:45:21 +01:00
|
|
|
if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) {
|
|
|
|
|
changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>(
|
|
|
|
|
params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize
|
|
|
|
|
: webrtc::RtcpMode::kCompound);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 02:27:06 -08:00
|
|
|
rtc::DiffServCodePoint WebRtcVideoChannel2::PreferredDscp() const {
|
|
|
|
|
return rtc::DSCP_AF41;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters");
|
2015-12-02 08:05:01 -08:00
|
|
|
LOG(LS_INFO) << "SetSendParameters: " << params.ToString();
|
2016-01-27 16:45:21 +01:00
|
|
|
ChangedSendParameters changed_params;
|
|
|
|
|
if (!GetChangedSendParameters(params, &changed_params)) {
|
2015-12-09 12:37:51 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-01-27 16:45:21 +01:00
|
|
|
|
|
|
|
|
if (changed_params.codec) {
|
|
|
|
|
const VideoCodecSettings& codec_settings = *changed_params.codec;
|
|
|
|
|
send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings);
|
|
|
|
|
LOG(LS_INFO) << "Using codec: " << codec_settings.codec.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changed_params.rtp_header_extensions) {
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
send_rtp_extensions_ = changed_params.rtp_header_extensions;
|
2016-01-27 16:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
2016-04-26 17:15:23 -07:00
|
|
|
if (changed_params.codec || changed_params.max_bandwidth_bps) {
|
|
|
|
|
if (send_codec_) {
|
|
|
|
|
// TODO(holmer): Changing the codec parameters shouldn't necessarily mean
|
|
|
|
|
// that we change the min/max of bandwidth estimation. Reevaluate this.
|
|
|
|
|
bitrate_config_ = GetBitrateConfigForCodec(send_codec_->codec);
|
|
|
|
|
if (!changed_params.codec) {
|
|
|
|
|
// If the codec isn't changing, set the start bitrate to -1 which means
|
|
|
|
|
// "unchanged" so that BWE isn't affected.
|
|
|
|
|
bitrate_config_.start_bitrate_bps = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (params.max_bandwidth_bps >= 0) {
|
|
|
|
|
// Note that max_bandwidth_bps intentionally takes priority over the
|
|
|
|
|
// bitrate config for the codec. This allows FEC to be applied above the
|
|
|
|
|
// codec target bitrate.
|
|
|
|
|
// TODO(pbos): Figure out whether b=AS means max bitrate for this
|
|
|
|
|
// WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC),
|
|
|
|
|
// in which case this should not set a Call::BitrateConfig but rather
|
|
|
|
|
// reconfigure all senders.
|
|
|
|
|
bitrate_config_.max_bitrate_bps =
|
|
|
|
|
params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps;
|
2016-01-27 16:45:21 +01:00
|
|
|
}
|
|
|
|
|
call_->SetBitrateConfig(bitrate_config_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2015-12-09 12:37:51 -08:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
for (auto& kv : send_streams_) {
|
2016-01-27 16:45:21 +01:00
|
|
|
kv.second->SetSendParameters(changed_params);
|
|
|
|
|
}
|
2016-03-18 15:02:07 -07:00
|
|
|
if (changed_params.codec || changed_params.rtcp_mode) {
|
|
|
|
|
// Update receive feedback parameters from new codec or RTCP mode.
|
2016-01-27 16:45:21 +01:00
|
|
|
LOG(LS_INFO)
|
|
|
|
|
<< "SetFeedbackOptions on all the receive streams because the send "
|
2016-03-18 15:02:07 -07:00
|
|
|
"codec or RTCP mode has changed.";
|
2016-01-27 16:45:21 +01:00
|
|
|
for (auto& kv : receive_streams_) {
|
|
|
|
|
RTC_DCHECK(kv.second != nullptr);
|
2016-03-18 15:02:07 -07:00
|
|
|
kv.second->SetFeedbackParameters(
|
|
|
|
|
HasNack(send_codec_->codec), HasRemb(send_codec_->codec),
|
|
|
|
|
HasTransportCc(send_codec_->codec),
|
|
|
|
|
params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize
|
|
|
|
|
: webrtc::RtcpMode::kCompound);
|
2016-01-27 16:45:21 +01:00
|
|
|
}
|
2015-12-09 12:37:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
send_params_ = params;
|
|
|
|
|
return true;
|
2015-08-07 16:05:34 -07:00
|
|
|
}
|
2016-04-20 16:23:10 -07:00
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters(
|
2016-03-16 19:07:43 -07:00
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
auto it = send_streams_.find(ssrc);
|
|
|
|
|
if (it == send_streams_.end()) {
|
2016-05-16 11:40:30 -07:00
|
|
|
LOG(LS_WARNING) << "Attempting to get RTP send parameters for stream "
|
|
|
|
|
<< "with ssrc " << ssrc << " which doesn't exist.";
|
2016-03-16 19:07:43 -07:00
|
|
|
return webrtc::RtpParameters();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 16:23:10 -07:00
|
|
|
webrtc::RtpParameters rtp_params = it->second->GetRtpParameters();
|
|
|
|
|
// Need to add the common list of codecs to the send stream-specific
|
|
|
|
|
// RTP parameters.
|
|
|
|
|
for (const VideoCodec& codec : send_params_.codecs) {
|
|
|
|
|
rtp_params.codecs.push_back(codec.ToCodecParameters());
|
|
|
|
|
}
|
|
|
|
|
return rtp_params;
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
bool WebRtcVideoChannel2::SetRtpSendParameters(
|
2016-03-16 19:07:43 -07:00
|
|
|
uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters) {
|
2016-05-16 11:40:30 -07:00
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRtpSendParameters");
|
2016-03-16 19:07:43 -07:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
auto it = send_streams_.find(ssrc);
|
|
|
|
|
if (it == send_streams_.end()) {
|
2016-05-16 11:40:30 -07:00
|
|
|
LOG(LS_ERROR) << "Attempting to set RTP send parameters for stream "
|
|
|
|
|
<< "with ssrc " << ssrc << " which doesn't exist.";
|
2016-03-16 19:07:43 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 16:23:10 -07:00
|
|
|
// TODO(deadbeef): Handle setting parameters with a list of codecs in a
|
|
|
|
|
// different order (which should change the send codec).
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters current_parameters = GetRtpSendParameters(ssrc);
|
|
|
|
|
if (current_parameters.codecs != parameters.codecs) {
|
|
|
|
|
LOG(LS_ERROR) << "Using SetParameters to change the set of codecs "
|
|
|
|
|
<< "is not currently supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 19:07:43 -07:00
|
|
|
return it->second->SetRtpParameters(parameters);
|
|
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters WebRtcVideoChannel2::GetRtpReceiveParameters(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
auto it = receive_streams_.find(ssrc);
|
|
|
|
|
if (it == receive_streams_.end()) {
|
|
|
|
|
LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream "
|
|
|
|
|
<< "with ssrc " << ssrc << " which doesn't exist.";
|
|
|
|
|
return webrtc::RtpParameters();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(deadbeef): Return stream-specific parameters.
|
|
|
|
|
webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding();
|
|
|
|
|
for (const VideoCodec& codec : recv_params_.codecs) {
|
|
|
|
|
rtp_params.codecs.push_back(codec.ToCodecParameters());
|
|
|
|
|
}
|
2016-06-22 00:46:15 -07:00
|
|
|
rtp_params.encodings[0].ssrc = it->second->GetFirstPrimarySsrc();
|
2016-05-16 11:40:30 -07:00
|
|
|
return rtp_params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WebRtcVideoChannel2::SetRtpReceiveParameters(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRtpReceiveParameters");
|
|
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
auto it = receive_streams_.find(ssrc);
|
|
|
|
|
if (it == receive_streams_.end()) {
|
|
|
|
|
LOG(LS_ERROR) << "Attempting to set RTP receive parameters for stream "
|
|
|
|
|
<< "with ssrc " << ssrc << " which doesn't exist.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc);
|
|
|
|
|
if (current_parameters != parameters) {
|
|
|
|
|
LOG(LS_ERROR) << "Changing the RTP receive parameters is currently "
|
|
|
|
|
<< "unsupported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-28 15:58:41 -08:00
|
|
|
bool WebRtcVideoChannel2::GetChangedRecvParameters(
|
|
|
|
|
const VideoRecvParameters& params,
|
|
|
|
|
ChangedRecvParameters* changed_params) const {
|
|
|
|
|
if (!ValidateCodecFormats(params.codecs) ||
|
|
|
|
|
!ValidateRtpExtensions(params.extensions)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle receive codecs.
|
|
|
|
|
const std::vector<VideoCodecSettings> mapped_codecs =
|
|
|
|
|
MapCodecs(params.codecs);
|
|
|
|
|
if (mapped_codecs.empty()) {
|
|
|
|
|
LOG(LS_ERROR) << "SetRecvParameters called without any video codecs.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 01:12:54 -08:00
|
|
|
// Verify that every mapped codec is supported locally.
|
|
|
|
|
const std::vector<VideoCodec> local_supported_codecs =
|
|
|
|
|
GetSupportedCodecs(external_encoder_factory_);
|
|
|
|
|
for (const VideoCodecSettings& mapped_codec : mapped_codecs) {
|
2016-11-12 09:53:04 -08:00
|
|
|
if (!FindMatchingCodec(local_supported_codecs, mapped_codec.codec)) {
|
2016-11-08 01:12:54 -08:00
|
|
|
LOG(LS_ERROR) << "SetRecvParameters called with unsupported video codec: "
|
|
|
|
|
<< mapped_codec.codec.ToString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-01-28 15:58:41 -08:00
|
|
|
}
|
|
|
|
|
|
2016-11-08 01:12:54 -08:00
|
|
|
if (ReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) {
|
2016-01-28 15:58:41 -08:00
|
|
|
changed_params->codec_settings =
|
2016-11-08 01:12:54 -08:00
|
|
|
rtc::Optional<std::vector<VideoCodecSettings>>(mapped_codecs);
|
2016-01-28 15:58:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle RTP header extensions.
|
|
|
|
|
std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions(
|
|
|
|
|
params.extensions, webrtc::RtpExtension::IsSupportedForVideo, false);
|
|
|
|
|
if (filtered_extensions != recv_rtp_extensions_) {
|
|
|
|
|
changed_params->rtp_header_extensions =
|
|
|
|
|
rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters");
|
2015-12-02 08:05:01 -08:00
|
|
|
LOG(LS_INFO) << "SetRecvParameters: " << params.ToString();
|
2016-01-28 15:58:41 -08:00
|
|
|
ChangedRecvParameters changed_params;
|
|
|
|
|
if (!GetChangedRecvParameters(params, &changed_params)) {
|
2015-12-09 12:37:51 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-01-28 15:58:41 -08:00
|
|
|
if (changed_params.rtp_header_extensions) {
|
|
|
|
|
recv_rtp_extensions_ = *changed_params.rtp_header_extensions;
|
|
|
|
|
}
|
|
|
|
|
if (changed_params.codec_settings) {
|
|
|
|
|
LOG(LS_INFO) << "Changing recv codecs from "
|
|
|
|
|
<< CodecSettingsVectorToString(recv_codecs_) << " to "
|
|
|
|
|
<< CodecSettingsVectorToString(*changed_params.codec_settings);
|
|
|
|
|
recv_codecs_ = *changed_params.codec_settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2015-12-09 12:37:51 -08:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
for (auto& kv : receive_streams_) {
|
2016-01-28 15:58:41 -08:00
|
|
|
kv.second->SetRecvParameters(changed_params);
|
2015-12-09 12:37:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recv_params_ = params;
|
|
|
|
|
return true;
|
2015-08-07 16:05:34 -07:00
|
|
|
}
|
|
|
|
|
|
2015-08-20 17:19:20 -07:00
|
|
|
std::string WebRtcVideoChannel2::CodecSettingsVectorToString(
|
|
|
|
|
const std::vector<VideoCodecSettings>& codecs) {
|
|
|
|
|
std::stringstream out;
|
|
|
|
|
out << '{';
|
|
|
|
|
for (size_t i = 0; i < codecs.size(); ++i) {
|
|
|
|
|
out << codecs[i].codec.ToString();
|
|
|
|
|
if (i != codecs.size() - 1) {
|
|
|
|
|
out << ", ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out << '}';
|
|
|
|
|
return out.str();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) {
|
2015-10-30 02:47:38 -07:00
|
|
|
if (!send_codec_) {
|
2014-05-13 11:07:01 +00:00
|
|
|
LOG(LS_VERBOSE) << "GetSendCodec: No send codec set.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-10-30 02:47:38 -07:00
|
|
|
*codec = send_codec_->codec;
|
2014-05-13 11:07:01 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WebRtcVideoChannel2::SetSend(bool send) {
|
2016-04-11 11:45:14 +02:00
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSend");
|
2014-05-13 11:07:01 +00:00
|
|
|
LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false");
|
2015-10-30 02:47:38 -07:00
|
|
|
if (send && !send_codec_) {
|
2014-05-13 11:07:01 +00:00
|
|
|
LOG(LS_ERROR) << "SetSend(true) called before setting codec.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-03-22 15:42:00 -07:00
|
|
|
{
|
|
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
for (const auto& kv : send_streams_) {
|
|
|
|
|
kv.second->SetSend(send);
|
|
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
sending_ = send;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-08 02:23:55 -07:00
|
|
|
// TODO(nisse): The enable argument was used for mute logic which has
|
2016-06-02 16:23:38 -07:00
|
|
|
// been moved to VideoBroadcaster. So remove the argument from this
|
|
|
|
|
// method.
|
|
|
|
|
bool WebRtcVideoChannel2::SetVideoSend(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
bool enable,
|
|
|
|
|
const VideoOptions* options,
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
|
2016-01-27 16:45:21 +01:00
|
|
|
TRACE_EVENT0("webrtc", "SetVideoSend");
|
2016-06-02 16:23:38 -07:00
|
|
|
RTC_DCHECK(ssrc != 0);
|
2016-01-27 16:45:21 +01:00
|
|
|
LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable
|
2016-06-02 16:23:38 -07:00
|
|
|
<< ", options: " << (options ? options->ToString() : "nullptr")
|
|
|
|
|
<< ", source = " << (source ? "(source)" : "nullptr") << ")";
|
2016-01-27 16:45:21 +01:00
|
|
|
|
2016-06-02 16:23:38 -07:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
|
|
|
|
const auto& kv = send_streams_.find(ssrc);
|
|
|
|
|
if (kv == send_streams_.end()) {
|
|
|
|
|
// Allow unknown ssrc only if source is null.
|
|
|
|
|
RTC_CHECK(source == nullptr);
|
|
|
|
|
LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc;
|
|
|
|
|
return false;
|
2015-09-10 01:57:14 -07:00
|
|
|
}
|
2016-06-02 16:23:38 -07:00
|
|
|
|
|
|
|
|
return kv->second->SetVideoSend(enable, options, source);
|
2015-09-10 01:57:14 -07:00
|
|
|
}
|
|
|
|
|
|
2015-03-26 16:23:04 +01:00
|
|
|
bool WebRtcVideoChannel2::ValidateSendSsrcAvailability(
|
|
|
|
|
const StreamParams& sp) const {
|
2016-02-12 13:30:57 +01:00
|
|
|
for (uint32_t ssrc : sp.ssrcs) {
|
2015-03-26 16:23:04 +01:00
|
|
|
if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) {
|
|
|
|
|
LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WebRtcVideoChannel2::ValidateReceiveSsrcAvailability(
|
|
|
|
|
const StreamParams& sp) const {
|
2016-02-12 13:30:57 +01:00
|
|
|
for (uint32_t ssrc : sp.ssrcs) {
|
2015-03-26 16:23:04 +01:00
|
|
|
if (receive_ssrcs_.find(ssrc) != receive_ssrcs_.end()) {
|
|
|
|
|
LOG(LS_ERROR) << "Receive stream with SSRC '" << ssrc
|
|
|
|
|
<< "' already exists.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) {
|
|
|
|
|
LOG(LS_INFO) << "AddSendStream: " << sp.ToString();
|
2015-03-25 14:17:23 +01:00
|
|
|
if (!ValidateStreamParams(sp))
|
2014-05-13 11:07:01 +00:00
|
|
|
return false;
|
|
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
2015-03-26 16:23:04 +01:00
|
|
|
|
|
|
|
|
if (!ValidateSendSsrcAvailability(sp))
|
2014-05-13 11:07:01 +00:00
|
|
|
return false;
|
2015-03-26 16:23:04 +01:00
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (uint32_t used_ssrc : sp.ssrcs)
|
2015-03-26 16:23:04 +01:00
|
|
|
send_ssrcs_.insert(used_ssrc);
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2015-09-08 05:13:22 -07:00
|
|
|
webrtc::VideoSendStream::Config config(this);
|
2016-03-01 04:29:59 -08:00
|
|
|
config.suspend_below_min_bitrate = video_config_.suspend_below_min_bitrate;
|
2016-11-28 13:11:13 -08:00
|
|
|
config.periodic_alr_bandwidth_probing =
|
|
|
|
|
video_config_.periodic_alr_bandwidth_probing;
|
2016-03-16 02:22:50 -07:00
|
|
|
WebRtcVideoSendStream* stream = new WebRtcVideoSendStream(
|
2016-09-01 01:17:40 -07:00
|
|
|
call_, sp, std::move(config), default_send_options_,
|
|
|
|
|
external_encoder_factory_, video_config_.enable_cpu_overuse_detection,
|
2016-03-16 02:22:50 -07:00
|
|
|
bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_,
|
|
|
|
|
send_params_);
|
2014-07-17 08:51:46 +00:00
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = sp.first_ssrc();
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(ssrc != 0);
|
2014-05-13 11:07:01 +00:00
|
|
|
send_streams_[ssrc] = stream;
|
|
|
|
|
|
|
|
|
|
if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) {
|
|
|
|
|
rtcp_receiver_report_ssrc_ = ssrc;
|
2015-08-20 17:19:20 -07:00
|
|
|
LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added "
|
|
|
|
|
"a send stream.";
|
2015-05-22 18:48:36 +02:00
|
|
|
for (auto& kv : receive_streams_)
|
|
|
|
|
kv.second->SetLocalSsrc(ssrc);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
if (sending_) {
|
2016-03-22 15:42:00 -07:00
|
|
|
stream->SetSend(true);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool WebRtcVideoChannel2::RemoveSendStream(uint32_t ssrc) {
|
2014-05-13 11:07:01 +00:00
|
|
|
LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
|
|
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
WebRtcVideoSendStream* removed_stream;
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
|
2014-10-08 14:48:08 +00:00
|
|
|
send_streams_.find(ssrc);
|
|
|
|
|
if (it == send_streams_.end()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (uint32_t old_ssrc : it->second->GetSsrcs())
|
2015-03-26 16:23:04 +01:00
|
|
|
send_ssrcs_.erase(old_ssrc);
|
|
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
removed_stream = it->second;
|
|
|
|
|
send_streams_.erase(it);
|
2015-10-21 17:21:10 +02:00
|
|
|
|
|
|
|
|
// Switch receiver report SSRCs, the one in use is no longer valid.
|
|
|
|
|
if (rtcp_receiver_report_ssrc_ == ssrc) {
|
|
|
|
|
rtcp_receiver_report_ssrc_ = send_streams_.empty()
|
|
|
|
|
? kDefaultRtcpReceiverReportSsrc
|
|
|
|
|
: send_streams_.begin()->first;
|
|
|
|
|
LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because the "
|
|
|
|
|
"previous local SSRC was removed.";
|
|
|
|
|
|
|
|
|
|
for (auto& kv : receive_streams_) {
|
|
|
|
|
kv.second->SetLocalSsrc(rtcp_receiver_report_ssrc_);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
delete removed_stream;
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-26 16:23:04 +01:00
|
|
|
void WebRtcVideoChannel2::DeleteReceiveStream(
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream* stream) {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (uint32_t old_ssrc : stream->GetSsrcs())
|
2015-03-26 16:23:04 +01:00
|
|
|
receive_ssrcs_.erase(old_ssrc);
|
|
|
|
|
delete stream;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp) {
|
2015-03-06 15:35:19 +00:00
|
|
|
return AddRecvStream(sp, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp,
|
|
|
|
|
bool default_stream) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
2015-05-07 14:07:48 +02:00
|
|
|
|
2015-03-25 14:17:23 +01:00
|
|
|
LOG(LS_INFO) << "AddRecvStream" << (default_stream ? " (default stream)" : "")
|
|
|
|
|
<< ": " << sp.ToString();
|
|
|
|
|
if (!ValidateStreamParams(sp))
|
|
|
|
|
return false;
|
2014-05-13 11:07:01 +00:00
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = sp.first_ssrc();
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(ssrc != 0); // TODO(pbos): Is this ever valid?
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
2015-03-26 16:23:04 +01:00
|
|
|
// Remove running stream if this was a default stream.
|
2016-02-17 07:24:50 -08:00
|
|
|
const auto& prev_stream = receive_streams_.find(ssrc);
|
2015-03-26 16:23:04 +01:00
|
|
|
if (prev_stream != receive_streams_.end()) {
|
|
|
|
|
if (default_stream || !prev_stream->second->IsDefaultStream()) {
|
|
|
|
|
LOG(LS_ERROR) << "Receive stream for SSRC '" << ssrc
|
|
|
|
|
<< "' already exists.";
|
|
|
|
|
return false;
|
2015-03-06 15:35:19 +00:00
|
|
|
}
|
2015-03-26 16:23:04 +01:00
|
|
|
DeleteReceiveStream(prev_stream->second);
|
|
|
|
|
receive_streams_.erase(prev_stream);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-26 16:23:04 +01:00
|
|
|
if (!ValidateReceiveSsrcAvailability(sp))
|
|
|
|
|
return false;
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (uint32_t used_ssrc : sp.ssrcs)
|
2015-03-26 16:23:04 +01:00
|
|
|
receive_ssrcs_.insert(used_ssrc);
|
|
|
|
|
|
2015-08-28 04:07:10 -07:00
|
|
|
webrtc::VideoReceiveStream::Config config(this);
|
2017-01-13 07:41:19 -08:00
|
|
|
webrtc::FlexfecReceiveStream::Config flexfec_config(this);
|
2016-11-22 02:16:47 -08:00
|
|
|
ConfigureReceiverRtp(&config, &flexfec_config, sp);
|
2014-10-31 12:59:34 +00:00
|
|
|
|
2016-03-23 04:48:10 -07:00
|
|
|
config.disable_prerenderer_smoothing =
|
|
|
|
|
video_config_.disable_prerenderer_smoothing;
|
2017-01-10 05:18:15 -08:00
|
|
|
config.sync_group = sp.sync_label;
|
2015-05-11 12:48:12 +02:00
|
|
|
|
2015-03-26 16:23:04 +01:00
|
|
|
receive_streams_[ssrc] = new WebRtcVideoReceiveStream(
|
2016-06-10 17:58:01 +02:00
|
|
|
call_, sp, std::move(config), external_decoder_factory_, default_stream,
|
2016-11-22 02:16:47 -08:00
|
|
|
recv_codecs_, flexfec_config);
|
2014-07-18 09:35:58 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebRtcVideoChannel2::ConfigureReceiverRtp(
|
|
|
|
|
webrtc::VideoReceiveStream::Config* config,
|
2017-01-13 07:41:19 -08:00
|
|
|
webrtc::FlexfecReceiveStream::Config* flexfec_config,
|
2014-07-18 09:35:58 +00:00
|
|
|
const StreamParams& sp) const {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = sp.first_ssrc();
|
2014-07-18 09:35:58 +00:00
|
|
|
|
|
|
|
|
config->rtp.remote_ssrc = ssrc;
|
|
|
|
|
config->rtp.local_ssrc = rtcp_receiver_report_ssrc_;
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
// TODO(pbos): This protection is against setting the same local ssrc as
|
|
|
|
|
// remote which is not permitted by the lower-level API. RTCP requires a
|
|
|
|
|
// corresponding sender SSRC. Figure out what to do when we don't have
|
|
|
|
|
// (receive-only) or know a good local SSRC.
|
2014-07-18 09:35:58 +00:00
|
|
|
if (config->rtp.remote_ssrc == config->rtp.local_ssrc) {
|
|
|
|
|
if (config->rtp.local_ssrc != kDefaultRtcpReceiverReportSsrc) {
|
|
|
|
|
config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc;
|
2014-05-13 11:07:01 +00:00
|
|
|
} else {
|
2014-07-18 09:35:58 +00:00
|
|
|
config->rtp.local_ssrc = kDefaultRtcpReceiverReportSsrc + 1;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-10 05:18:15 -08:00
|
|
|
// Whether or not the receive stream sends reduced size RTCP is determined
|
|
|
|
|
// by the send params.
|
|
|
|
|
// TODO(deadbeef): Once we change "send_params" to "sender_params" and
|
|
|
|
|
// "recv_params" to "receiver_params", we should get this out of
|
|
|
|
|
// receiver_params_.
|
|
|
|
|
config->rtp.rtcp_mode = send_params_.rtcp.reduced_size
|
|
|
|
|
? webrtc::RtcpMode::kReducedSize
|
|
|
|
|
: webrtc::RtcpMode::kCompound;
|
|
|
|
|
|
|
|
|
|
config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false;
|
|
|
|
|
config->rtp.transport_cc =
|
|
|
|
|
send_codec_ ? HasTransportCc(send_codec_->codec) : false;
|
|
|
|
|
|
2017-02-03 04:43:41 -08:00
|
|
|
sp.GetFidSsrc(ssrc, &config->rtp.rtx_ssrc);
|
|
|
|
|
|
|
|
|
|
config->rtp.extensions = recv_rtp_extensions_;
|
|
|
|
|
|
2017-01-10 05:18:15 -08:00
|
|
|
// TODO(brandtr): Generalize when we add support for multistream protection.
|
2017-01-13 07:41:19 -08:00
|
|
|
if (sp.GetFecFrSsrc(ssrc, &flexfec_config->remote_ssrc)) {
|
2017-01-10 05:18:15 -08:00
|
|
|
flexfec_config->protected_media_ssrcs = {ssrc};
|
2017-01-13 07:41:19 -08:00
|
|
|
flexfec_config->local_ssrc = config->rtp.local_ssrc;
|
|
|
|
|
flexfec_config->rtcp_mode = config->rtp.rtcp_mode;
|
2017-02-03 04:43:41 -08:00
|
|
|
// TODO(brandtr): We should be spec-compliant and set |transport_cc| here
|
|
|
|
|
// based on the rtcp-fb for the FlexFEC codec, not the media codec.
|
2017-01-13 07:41:19 -08:00
|
|
|
flexfec_config->transport_cc = config->rtp.transport_cc;
|
|
|
|
|
flexfec_config->rtp_header_extensions = config->rtp.extensions;
|
2017-01-10 05:18:15 -08:00
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool WebRtcVideoChannel2::RemoveRecvStream(uint32_t ssrc) {
|
2014-05-13 11:07:01 +00:00
|
|
|
LOG(LS_INFO) << "RemoveRecvStream: " << ssrc;
|
|
|
|
|
if (ssrc == 0) {
|
2014-08-12 23:17:13 +00:00
|
|
|
LOG(LS_ERROR) << "RemoveRecvStream with 0 ssrc is not supported.";
|
|
|
|
|
return false;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator stream =
|
2014-05-13 11:07:01 +00:00
|
|
|
receive_streams_.find(ssrc);
|
|
|
|
|
if (stream == receive_streams_.end()) {
|
|
|
|
|
LOG(LS_ERROR) << "Stream not found for ssrc: " << ssrc;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-26 16:23:04 +01:00
|
|
|
DeleteReceiveStream(stream->second);
|
2014-05-13 11:07:01 +00:00
|
|
|
receive_streams_.erase(stream);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
bool WebRtcVideoChannel2::SetSink(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
|
2016-06-02 16:23:38 -07:00
|
|
|
LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " "
|
|
|
|
|
<< (sink ? "(ptr)" : "nullptr");
|
2014-05-13 11:07:01 +00:00
|
|
|
if (ssrc == 0) {
|
2016-02-04 01:24:52 -08:00
|
|
|
default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink);
|
2014-07-18 09:35:58 +00:00
|
|
|
return true;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-08 14:48:08 +00:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it =
|
2014-07-18 09:35:58 +00:00
|
|
|
receive_streams_.find(ssrc);
|
|
|
|
|
if (it == receive_streams_.end()) {
|
|
|
|
|
return false;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 01:24:52 -08:00
|
|
|
it->second->SetSink(sink);
|
2014-05-13 11:07:01 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 08:54:32 +00:00
|
|
|
bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) {
|
2016-03-08 14:24:13 -08:00
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::GetStats");
|
2016-08-11 08:41:18 -07:00
|
|
|
|
|
|
|
|
// Log stats periodically.
|
|
|
|
|
bool log_stats = false;
|
|
|
|
|
int64_t now_ms = rtc::TimeMillis();
|
|
|
|
|
if (last_stats_log_ms_ == -1 ||
|
|
|
|
|
now_ms - last_stats_log_ms_ > kStatsLogIntervalMs) {
|
|
|
|
|
last_stats_log_ms_ = now_ms;
|
|
|
|
|
log_stats = true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 11:11:55 +00:00
|
|
|
info->Clear();
|
2016-08-11 08:41:18 -07:00
|
|
|
FillSenderStats(info, log_stats);
|
|
|
|
|
FillReceiverStats(info, log_stats);
|
2016-11-14 02:28:16 -08:00
|
|
|
FillSendAndReceiveCodecStats(info);
|
2014-12-11 13:26:09 +00:00
|
|
|
webrtc::Call::Stats stats = call_->GetStats();
|
|
|
|
|
FillBandwidthEstimationStats(stats, info);
|
|
|
|
|
if (stats.rtt_ms != -1) {
|
|
|
|
|
for (size_t i = 0; i < info->senders.size(); ++i) {
|
|
|
|
|
info->senders[i].rtt_ms = stats.rtt_ms;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-11 08:41:18 -07:00
|
|
|
|
|
|
|
|
if (log_stats)
|
|
|
|
|
LOG(LS_INFO) << stats.ToString(now_ms);
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-11 08:41:18 -07:00
|
|
|
void WebRtcVideoChannel2::FillSenderStats(VideoMediaInfo* video_media_info,
|
|
|
|
|
bool log_stats) {
|
2014-10-08 14:48:08 +00:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
|
2014-07-18 11:11:55 +00:00
|
|
|
send_streams_.begin();
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
it != send_streams_.end(); ++it) {
|
2016-08-11 08:41:18 -07:00
|
|
|
video_media_info->senders.push_back(
|
|
|
|
|
it->second->GetVideoSenderInfo(log_stats));
|
2014-07-18 11:11:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-11 08:41:18 -07:00
|
|
|
void WebRtcVideoChannel2::FillReceiverStats(VideoMediaInfo* video_media_info,
|
|
|
|
|
bool log_stats) {
|
2014-10-08 14:48:08 +00:00
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it =
|
2014-07-18 11:11:55 +00:00
|
|
|
receive_streams_.begin();
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
it != receive_streams_.end(); ++it) {
|
2016-08-11 08:41:18 -07:00
|
|
|
video_media_info->receivers.push_back(
|
|
|
|
|
it->second->GetVideoReceiverInfo(log_stats));
|
2014-07-18 11:11:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebRtcVideoChannel2::FillBandwidthEstimationStats(
|
2014-12-11 13:26:09 +00:00
|
|
|
const webrtc::Call::Stats& stats,
|
2014-07-18 11:11:55 +00:00
|
|
|
VideoMediaInfo* video_media_info) {
|
2014-11-05 14:05:29 +00:00
|
|
|
BandwidthEstimationInfo bwe_info;
|
|
|
|
|
bwe_info.available_send_bandwidth = stats.send_bandwidth_bps;
|
|
|
|
|
bwe_info.available_recv_bandwidth = stats.recv_bandwidth_bps;
|
|
|
|
|
bwe_info.bucket_delay = stats.pacer_delay_ms;
|
|
|
|
|
|
|
|
|
|
// Get send stream bitrate stats.
|
|
|
|
|
rtc::CritScope stream_lock(&stream_crit_);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator stream =
|
2014-11-05 14:05:29 +00:00
|
|
|
send_streams_.begin();
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
stream != send_streams_.end(); ++stream) {
|
2014-11-05 14:05:29 +00:00
|
|
|
stream->second->FillBandwidthEstimationInfo(&bwe_info);
|
|
|
|
|
}
|
|
|
|
|
video_media_info->bw_estimations.push_back(bwe_info);
|
2014-07-18 11:11:55 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 02:28:16 -08:00
|
|
|
void WebRtcVideoChannel2::FillSendAndReceiveCodecStats(
|
|
|
|
|
VideoMediaInfo* video_media_info) {
|
|
|
|
|
for (const VideoCodec& codec : send_params_.codecs) {
|
|
|
|
|
webrtc::RtpCodecParameters codec_params = codec.ToCodecParameters();
|
|
|
|
|
video_media_info->send_codecs.insert(
|
|
|
|
|
std::make_pair(codec_params.payload_type, std::move(codec_params)));
|
|
|
|
|
}
|
|
|
|
|
for (const VideoCodec& codec : recv_params_.codecs) {
|
|
|
|
|
webrtc::RtpCodecParameters codec_params = codec.ToCodecParameters();
|
|
|
|
|
video_media_info->receive_codecs.insert(
|
|
|
|
|
std::make_pair(codec_params.payload_type, std::move(codec_params)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
void WebRtcVideoChannel2::OnPacketReceived(
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer* packet,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time) {
|
2015-09-08 05:36:15 -07:00
|
|
|
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
|
|
|
|
|
packet_time.not_before);
|
2014-05-14 13:58:13 +00:00
|
|
|
const webrtc::PacketReceiver::DeliveryStatus delivery_result =
|
2015-09-08 05:36:15 -07:00
|
|
|
call_->Receiver()->DeliverPacket(
|
|
|
|
|
webrtc::MediaType::VIDEO,
|
2016-03-20 06:15:43 -07:00
|
|
|
packet->cdata(), packet->size(),
|
2015-09-08 05:36:15 -07:00
|
|
|
webrtc_packet_time);
|
2014-05-14 13:58:13 +00:00
|
|
|
switch (delivery_result) {
|
|
|
|
|
case webrtc::PacketReceiver::DELIVERY_OK:
|
|
|
|
|
return;
|
|
|
|
|
case webrtc::PacketReceiver::DELIVERY_PACKET_ERROR:
|
|
|
|
|
return;
|
|
|
|
|
case webrtc::PacketReceiver::DELIVERY_UNKNOWN_SSRC:
|
|
|
|
|
break;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = 0;
|
2016-03-20 06:15:43 -07:00
|
|
|
if (!GetRtpSsrc(packet->cdata(), packet->size(), &ssrc)) {
|
2014-05-13 11:07:01 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 11:27:55 -07:00
|
|
|
int payload_type = 0;
|
2016-03-20 06:15:43 -07:00
|
|
|
if (!GetRtpPayloadType(packet->cdata(), packet->size(), &payload_type)) {
|
2015-07-10 11:27:55 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// See if this payload_type is registered as one that usually gets its own
|
2016-11-22 02:16:47 -08:00
|
|
|
// SSRC (RTX) or at least is safe to drop either way (FEC). If it is, and
|
2015-07-10 11:27:55 -07:00
|
|
|
// it wasn't handled above by DeliverPacket, that means we don't know what
|
|
|
|
|
// stream it associates with, and we shouldn't ever create an implicit channel
|
|
|
|
|
// for these.
|
|
|
|
|
for (auto& codec : recv_codecs_) {
|
|
|
|
|
if (payload_type == codec.rtx_payload_type ||
|
2016-10-04 23:28:39 -07:00
|
|
|
payload_type == codec.ulpfec.red_rtx_payload_type ||
|
2016-11-22 02:16:47 -08:00
|
|
|
payload_type == codec.ulpfec.ulpfec_payload_type ||
|
2016-12-19 09:41:04 -08:00
|
|
|
payload_type == codec.flexfec_payload_type) {
|
2015-07-10 11:27:55 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 23:17:13 +00:00
|
|
|
switch (unsignalled_ssrc_handler_->OnUnsignalledSsrc(this, ssrc)) {
|
|
|
|
|
case UnsignalledSsrcHandler::kDropPacket:
|
|
|
|
|
return;
|
|
|
|
|
case UnsignalledSsrcHandler::kDeliverPacket:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2015-09-08 05:36:15 -07:00
|
|
|
if (call_->Receiver()->DeliverPacket(
|
|
|
|
|
webrtc::MediaType::VIDEO,
|
2016-03-20 06:15:43 -07:00
|
|
|
packet->cdata(), packet->size(),
|
2015-09-08 05:36:15 -07:00
|
|
|
webrtc_packet_time) != webrtc::PacketReceiver::DELIVERY_OK) {
|
2014-08-12 23:17:13 +00:00
|
|
|
LOG(LS_WARNING) << "Failed to deliver RTP packet on re-delivery.";
|
2014-05-13 11:07:01 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebRtcVideoChannel2::OnRtcpReceived(
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer* packet,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time) {
|
2015-09-08 05:36:15 -07:00
|
|
|
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
|
|
|
|
|
packet_time.not_before);
|
2015-11-18 13:47:16 +01:00
|
|
|
// TODO(pbos): Check webrtc::PacketReceiver::DELIVERY_OK once we deliver
|
|
|
|
|
// for both audio and video on the same path. Since BundleFilter doesn't
|
|
|
|
|
// filter RTCP anymore incoming RTCP packets could've been going to audio (so
|
|
|
|
|
// logging failures spam the log).
|
|
|
|
|
call_->Receiver()->DeliverPacket(
|
|
|
|
|
webrtc::MediaType::VIDEO,
|
2016-03-20 06:15:43 -07:00
|
|
|
packet->cdata(), packet->size(),
|
2015-11-18 13:47:16 +01:00
|
|
|
webrtc_packet_time);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebRtcVideoChannel2::OnReadyToSend(bool ready) {
|
2014-09-03 16:17:12 +00:00
|
|
|
LOG(LS_VERBOSE) << "OnReadyToSend: " << (ready ? "Ready." : "Not ready.");
|
2016-03-22 15:32:27 -07:00
|
|
|
call_->SignalChannelNetworkState(
|
|
|
|
|
webrtc::MediaType::VIDEO,
|
|
|
|
|
ready ? webrtc::kNetworkUp : webrtc::kNetworkDown);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-29 17:27:21 -07:00
|
|
|
void WebRtcVideoChannel2::OnNetworkRouteChanged(
|
|
|
|
|
const std::string& transport_name,
|
2016-04-19 15:41:36 -07:00
|
|
|
const rtc::NetworkRoute& network_route) {
|
|
|
|
|
call_->OnNetworkRouteChanged(transport_name, network_route);
|
2016-03-29 17:27:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-11-08 02:50:09 -08:00
|
|
|
void WebRtcVideoChannel2::OnTransportOverheadChanged(
|
|
|
|
|
int transport_overhead_per_packet) {
|
|
|
|
|
call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO,
|
|
|
|
|
transport_overhead_per_packet);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) {
|
|
|
|
|
MediaChannel::SetInterface(iface);
|
|
|
|
|
// Set the RTP recv/send buffer to a bigger size
|
|
|
|
|
MediaChannel::SetOption(NetworkInterface::ST_RTP,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Socket::OPT_RCVBUF,
|
2014-05-13 11:07:01 +00:00
|
|
|
kVideoRtpBufferSize);
|
|
|
|
|
|
2014-10-28 17:37:17 +00:00
|
|
|
// Speculative change to increase the outbound socket buffer size.
|
|
|
|
|
// In b/15152257, we are seeing a significant number of packets discarded
|
|
|
|
|
// due to lack of socket buffer space, although it's not yet clear what the
|
|
|
|
|
// ideal value should be.
|
|
|
|
|
MediaChannel::SetOption(NetworkInterface::ST_RTP,
|
|
|
|
|
rtc::Socket::OPT_SNDBUF,
|
|
|
|
|
kVideoRtpBufferSize);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-02 03:39:33 -07:00
|
|
|
bool WebRtcVideoChannel2::SendRtp(const uint8_t* data,
|
|
|
|
|
size_t len,
|
|
|
|
|
const webrtc::PacketOptions& options) {
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
|
2015-10-15 07:26:07 -07:00
|
|
|
rtc::PacketOptions rtc_options;
|
|
|
|
|
rtc_options.packet_id = options.packet_id;
|
|
|
|
|
return MediaChannel::SendPacket(&packet, rtc_options);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) {
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
|
2015-10-15 07:26:07 -07:00
|
|
|
return MediaChannel::SendRtcp(&packet, rtc::PacketOptions());
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-06 10:49:19 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters::
|
|
|
|
|
VideoSendStreamParameters(
|
2016-09-01 01:17:40 -07:00
|
|
|
webrtc::VideoSendStream::Config config,
|
2014-06-06 10:49:19 +00:00
|
|
|
const VideoOptions& options,
|
2015-03-27 15:58:11 +01:00
|
|
|
int max_bitrate_bps,
|
2015-11-10 22:34:18 +01:00
|
|
|
const rtc::Optional<VideoCodecSettings>& codec_settings)
|
2016-09-01 01:17:40 -07:00
|
|
|
: config(std::move(config)),
|
2015-03-27 15:58:11 +01:00
|
|
|
options(options),
|
|
|
|
|
max_bitrate_bps(max_bitrate_bps),
|
2016-10-02 23:45:26 -07:00
|
|
|
conference_mode(false),
|
2015-10-30 02:47:38 -07:00
|
|
|
codec_settings(codec_settings) {}
|
2014-06-06 10:49:19 +00:00
|
|
|
|
2015-05-19 23:09:35 +02:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder(
|
|
|
|
|
webrtc::VideoEncoder* encoder,
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
const cricket::VideoCodec& codec,
|
2015-05-19 23:09:35 +02:00
|
|
|
bool external)
|
|
|
|
|
: encoder(encoder),
|
|
|
|
|
external_encoder(nullptr),
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
codec(codec),
|
2015-05-19 23:09:35 +02:00
|
|
|
external(external) {
|
|
|
|
|
if (external) {
|
|
|
|
|
external_encoder = encoder;
|
|
|
|
|
this->encoder =
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
new webrtc::VideoEncoderSoftwareFallbackWrapper(codec, encoder);
|
2015-05-19 23:09:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
|
|
|
|
|
webrtc::Call* call,
|
2015-08-28 04:07:10 -07:00
|
|
|
const StreamParams& sp,
|
2016-09-01 01:17:40 -07:00
|
|
|
webrtc::VideoSendStream::Config config,
|
2016-03-16 02:22:50 -07:00
|
|
|
const VideoOptions& options,
|
2014-10-14 04:25:33 +00:00
|
|
|
WebRtcVideoEncoderFactory* external_encoder_factory,
|
2016-02-29 00:04:41 -08:00
|
|
|
bool enable_cpu_overuse_detection,
|
2015-03-27 15:58:11 +01:00
|
|
|
int max_bitrate_bps,
|
2015-11-10 22:34:18 +01:00
|
|
|
const rtc::Optional<VideoCodecSettings>& codec_settings,
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions,
|
2015-12-09 12:37:51 -08:00
|
|
|
// TODO(deadbeef): Don't duplicate information between send_params,
|
|
|
|
|
// rtp_extensions, options, etc.
|
|
|
|
|
const VideoSendParameters& send_params)
|
2016-02-29 00:04:41 -08:00
|
|
|
: worker_thread_(rtc::Thread::Current()),
|
|
|
|
|
ssrcs_(sp.ssrcs),
|
2015-05-28 13:39:50 +02:00
|
|
|
ssrc_groups_(sp.ssrc_groups),
|
2015-04-22 13:21:30 +02:00
|
|
|
call_(call),
|
2016-11-01 11:45:46 -07:00
|
|
|
enable_cpu_overuse_detection_(enable_cpu_overuse_detection),
|
2016-04-08 02:23:55 -07:00
|
|
|
source_(nullptr),
|
2014-10-14 04:25:33 +00:00
|
|
|
external_encoder_factory_(external_encoder_factory),
|
2017-01-26 06:12:26 -08:00
|
|
|
internal_encoder_factory_(new InternalEncoderFactory()),
|
2016-02-29 00:04:41 -08:00
|
|
|
stream_(nullptr),
|
2016-09-16 07:53:41 -07:00
|
|
|
encoder_sink_(nullptr),
|
2016-09-01 01:17:40 -07:00
|
|
|
parameters_(std::move(config), options, max_bitrate_bps, codec_settings),
|
2016-03-16 19:07:43 -07:00
|
|
|
rtp_parameters_(CreateRtpParametersWithOneEncoding()),
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
allocated_encoder_(nullptr, cricket::VideoCodec(), false),
|
2017-01-13 05:57:25 -08:00
|
|
|
sending_(false) {
|
2014-07-17 08:51:46 +00:00
|
|
|
parameters_.config.rtp.max_packet_size = kVideoMtu;
|
2016-02-17 05:25:36 -08:00
|
|
|
parameters_.conference_mode = send_params.conference_mode;
|
2014-07-17 08:51:46 +00:00
|
|
|
|
|
|
|
|
sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs);
|
2016-11-22 02:16:47 -08:00
|
|
|
|
2017-01-06 23:05:37 -08:00
|
|
|
// ValidateStreamParams should prevent this from happening.
|
|
|
|
|
RTC_CHECK(!parameters_.config.rtp.ssrcs.empty());
|
|
|
|
|
rtp_parameters_.encodings[0].ssrc =
|
|
|
|
|
rtc::Optional<uint32_t>(parameters_.config.rtp.ssrcs[0]);
|
|
|
|
|
|
2016-11-22 02:16:47 -08:00
|
|
|
// RTX.
|
2014-07-17 08:51:46 +00:00
|
|
|
sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
|
|
|
|
|
¶meters_.config.rtp.rtx.ssrcs);
|
2016-11-22 02:16:47 -08:00
|
|
|
|
|
|
|
|
// FlexFEC.
|
|
|
|
|
// TODO(brandtr): This code needs to be generalized when we add support for
|
|
|
|
|
// multistream protection.
|
|
|
|
|
if (IsFlexfecFieldTrialEnabled()) {
|
|
|
|
|
uint32_t flexfec_ssrc;
|
|
|
|
|
bool flexfec_enabled = false;
|
|
|
|
|
for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) {
|
|
|
|
|
if (sp.GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)) {
|
|
|
|
|
if (flexfec_enabled) {
|
|
|
|
|
LOG(LS_INFO) << "Multiple FlexFEC streams proposed by remote, but "
|
|
|
|
|
"our implementation only supports a single FlexFEC "
|
|
|
|
|
"stream. Will not enable FlexFEC for proposed "
|
|
|
|
|
"stream with SSRC: "
|
|
|
|
|
<< flexfec_ssrc << ".";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flexfec_enabled = true;
|
2017-01-16 06:59:19 -08:00
|
|
|
parameters_.config.rtp.flexfec.ssrc = flexfec_ssrc;
|
2016-11-22 02:16:47 -08:00
|
|
|
parameters_.config.rtp.flexfec.protected_media_ssrcs = {primary_ssrc};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-17 08:51:46 +00:00
|
|
|
parameters_.config.rtp.c_name = sp.cname;
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
if (rtp_extensions) {
|
|
|
|
|
parameters_.config.rtp.extensions = *rtp_extensions;
|
|
|
|
|
}
|
2015-12-09 12:37:51 -08:00
|
|
|
parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size
|
|
|
|
|
? webrtc::RtcpMode::kReducedSize
|
|
|
|
|
: webrtc::RtcpMode::kCompound;
|
2015-10-30 02:47:38 -07:00
|
|
|
if (codec_settings) {
|
2017-02-28 13:23:26 -08:00
|
|
|
bool force_encoder_allocation = false;
|
|
|
|
|
SetCodec(*codec_settings, force_encoder_allocation);
|
2014-07-17 08:51:46 +00:00
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
|
2014-07-17 08:51:46 +00:00
|
|
|
if (stream_ != NULL) {
|
|
|
|
|
call_->DestroyVideoSendStream(stream_);
|
|
|
|
|
}
|
2014-10-14 04:25:33 +00:00
|
|
|
DestroyVideoEncoder(&allocated_encoder_);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-02 16:23:38 -07:00
|
|
|
bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend(
|
|
|
|
|
bool enable,
|
|
|
|
|
const VideoOptions* options,
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
|
2016-06-02 16:23:38 -07:00
|
|
|
TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend");
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2016-04-08 02:23:55 -07:00
|
|
|
|
2016-06-02 16:23:38 -07:00
|
|
|
// Ignore |options| pointer if |enable| is false.
|
|
|
|
|
bool options_present = enable && options;
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
if (options_present) {
|
|
|
|
|
VideoOptions old_options = parameters_.options;
|
|
|
|
|
parameters_.options.SetAll(*options);
|
2017-02-28 13:23:26 -08:00
|
|
|
if (parameters_.options.is_screencast.value_or(false) !=
|
|
|
|
|
old_options.is_screencast.value_or(false) &&
|
|
|
|
|
parameters_.codec_settings) {
|
|
|
|
|
// If screen content settings change, we may need to recreate the codec
|
|
|
|
|
// instance so that the correct type is used.
|
|
|
|
|
|
|
|
|
|
bool force_encoder_allocation = true;
|
|
|
|
|
SetCodec(*parameters_.codec_settings, force_encoder_allocation);
|
|
|
|
|
// Mark screenshare parameter as being updated, then test for any other
|
|
|
|
|
// changes that may require codec reconfiguration.
|
|
|
|
|
old_options.is_screencast = options->is_screencast;
|
|
|
|
|
}
|
2016-10-02 23:45:26 -07:00
|
|
|
if (parameters_.options != old_options) {
|
|
|
|
|
ReconfigureEncoder();
|
2016-06-02 16:23:38 -07:00
|
|
|
}
|
2016-10-02 23:45:26 -07:00
|
|
|
}
|
2016-06-02 16:23:38 -07:00
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
if (source_ && stream_) {
|
|
|
|
|
stream_->SetSource(
|
|
|
|
|
nullptr, webrtc::VideoSendStream::DegradationPreference::kBalanced);
|
|
|
|
|
}
|
|
|
|
|
// Switch to the new source.
|
|
|
|
|
source_ = source;
|
|
|
|
|
if (source && stream_) {
|
|
|
|
|
// Do not adapt resolution for screen content as this will likely
|
|
|
|
|
// result in blurry and unreadable text.
|
2017-01-13 05:57:25 -08:00
|
|
|
// |this| acts like a VideoSource to make sure SinkWants are handled on the
|
|
|
|
|
// correct thread.
|
2016-11-01 11:45:46 -07:00
|
|
|
stream_->SetSource(
|
|
|
|
|
this, enable_cpu_overuse_detection_ &&
|
|
|
|
|
!parameters_.options.is_screencast.value_or(false)
|
|
|
|
|
? webrtc::VideoSendStream::DegradationPreference::kBalanced
|
|
|
|
|
: webrtc::VideoSendStream::DegradationPreference::
|
|
|
|
|
kMaintainResolution);
|
2016-04-08 02:23:55 -07:00
|
|
|
}
|
2016-06-02 16:23:38 -07:00
|
|
|
return true;
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
const std::vector<uint32_t>&
|
2015-03-26 16:23:04 +01:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const {
|
|
|
|
|
return ssrcs_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-14 04:25:33 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder(
|
2017-02-28 13:23:26 -08:00
|
|
|
const VideoCodec& codec,
|
|
|
|
|
bool force_encoder_allocation) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2014-10-14 04:25:33 +00:00
|
|
|
// Do not re-create encoders of the same type.
|
2017-02-28 13:23:26 -08:00
|
|
|
if (!force_encoder_allocation && codec == allocated_encoder_.codec &&
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
allocated_encoder_.encoder != nullptr) {
|
2014-10-14 04:25:33 +00:00
|
|
|
return allocated_encoder_;
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
// Try creating external encoder.
|
|
|
|
|
if (external_encoder_factory_ != nullptr &&
|
|
|
|
|
FindMatchingCodec(external_encoder_factory_->supported_codecs(), codec)) {
|
2014-10-14 04:25:33 +00:00
|
|
|
webrtc::VideoEncoder* encoder =
|
2016-10-28 07:43:45 -07:00
|
|
|
external_encoder_factory_->CreateVideoEncoder(codec);
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
if (encoder != nullptr)
|
|
|
|
|
return AllocatedEncoder(encoder, codec, true /* is_external */);
|
2014-10-14 04:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
// Try creating internal encoder.
|
2017-01-26 06:12:26 -08:00
|
|
|
if (FindMatchingCodec(internal_encoder_factory_->supported_codecs(), codec)) {
|
|
|
|
|
if (parameters_.encoder_config.content_type ==
|
|
|
|
|
webrtc::VideoEncoderConfig::ContentType::kScreen &&
|
|
|
|
|
parameters_.conference_mode && UseSimulcastScreenshare()) {
|
|
|
|
|
// TODO(sprang): Remove this adapter once libvpx supports simulcast with
|
|
|
|
|
// same-resolution substreams.
|
|
|
|
|
WebRtcSimulcastEncoderFactory adapter_factory(
|
|
|
|
|
internal_encoder_factory_.get());
|
|
|
|
|
return AllocatedEncoder(adapter_factory.CreateVideoEncoder(codec), codec,
|
|
|
|
|
false /* is_external */);
|
|
|
|
|
}
|
|
|
|
|
return AllocatedEncoder(
|
|
|
|
|
internal_encoder_factory_->CreateVideoEncoder(codec), codec,
|
|
|
|
|
false /* is_external */);
|
2014-10-14 04:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This shouldn't happen, we should not be trying to create something we don't
|
|
|
|
|
// support.
|
2017-01-12 02:24:27 -08:00
|
|
|
RTC_NOTREACHED();
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
return AllocatedEncoder(NULL, cricket::VideoCodec(), false);
|
2014-10-14 04:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder(
|
|
|
|
|
AllocatedEncoder* encoder) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2014-10-14 04:25:33 +00:00
|
|
|
if (encoder->external) {
|
2015-05-19 23:09:35 +02:00
|
|
|
external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder);
|
2014-10-14 04:25:33 +00:00
|
|
|
}
|
2015-05-19 23:09:35 +02:00
|
|
|
delete encoder->encoder;
|
2014-10-14 04:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-01 04:29:59 -08:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec(
|
2017-02-28 13:23:26 -08:00
|
|
|
const VideoCodecSettings& codec_settings,
|
|
|
|
|
bool force_encoder_allocation) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
parameters_.encoder_config = CreateVideoEncoderConfig(codec_settings.codec);
|
2016-11-28 15:21:39 -08:00
|
|
|
RTC_DCHECK_GT(parameters_.encoder_config.number_of_streams, 0);
|
2014-11-07 10:54:43 +00:00
|
|
|
|
2017-02-28 13:23:26 -08:00
|
|
|
AllocatedEncoder new_encoder =
|
|
|
|
|
CreateVideoEncoder(codec_settings.codec, force_encoder_allocation);
|
2014-10-14 04:25:33 +00:00
|
|
|
parameters_.config.encoder_settings.encoder = new_encoder.encoder;
|
2016-02-05 11:13:28 +01:00
|
|
|
parameters_.config.encoder_settings.full_overuse_time = new_encoder.external;
|
2014-07-17 08:51:46 +00:00
|
|
|
parameters_.config.encoder_settings.payload_name = codec_settings.codec.name;
|
|
|
|
|
parameters_.config.encoder_settings.payload_type = codec_settings.codec.id;
|
2015-09-03 18:24:44 -07:00
|
|
|
if (new_encoder.external) {
|
2016-11-22 10:16:57 -08:00
|
|
|
webrtc::VideoCodecType type =
|
|
|
|
|
webrtc::PayloadNameToCodecType(codec_settings.codec.name)
|
|
|
|
|
.value_or(webrtc::kVideoCodecUnknown);
|
2015-09-03 18:24:44 -07:00
|
|
|
parameters_.config.encoder_settings.internal_source =
|
|
|
|
|
external_encoder_factory_->EncoderTypeHasInternalSource(type);
|
2017-01-09 10:06:28 -08:00
|
|
|
} else {
|
|
|
|
|
parameters_.config.encoder_settings.internal_source = false;
|
2015-09-03 18:24:44 -07:00
|
|
|
}
|
2016-10-04 23:28:39 -07:00
|
|
|
parameters_.config.rtp.ulpfec = codec_settings.ulpfec;
|
2017-01-16 06:59:19 -08:00
|
|
|
parameters_.config.rtp.flexfec.payload_type =
|
2016-12-19 09:41:04 -08:00
|
|
|
codec_settings.flexfec_payload_type;
|
2014-07-17 08:51:46 +00:00
|
|
|
|
|
|
|
|
// Set RTX payload type if RTX is enabled.
|
|
|
|
|
if (!parameters_.config.rtp.rtx.ssrcs.empty()) {
|
2015-03-20 19:52:56 +00:00
|
|
|
if (codec_settings.rtx_payload_type == -1) {
|
|
|
|
|
LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX "
|
|
|
|
|
"payload type. Ignoring.";
|
|
|
|
|
parameters_.config.rtp.rtx.ssrcs.clear();
|
|
|
|
|
} else {
|
|
|
|
|
parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type;
|
|
|
|
|
}
|
2014-07-17 08:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-11 14:34:58 +02:00
|
|
|
parameters_.config.rtp.nack.rtp_history_ms =
|
|
|
|
|
HasNack(codec_settings.codec) ? kNackHistoryMs : 0;
|
2014-07-17 08:51:46 +00:00
|
|
|
|
2015-10-30 02:47:38 -07:00
|
|
|
parameters_.codec_settings =
|
2015-11-10 22:34:18 +01:00
|
|
|
rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings);
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetCodec.";
|
2014-05-13 11:07:01 +00:00
|
|
|
RecreateWebRtcStream();
|
2014-10-14 04:25:33 +00:00
|
|
|
if (allocated_encoder_.encoder != new_encoder.encoder) {
|
|
|
|
|
DestroyVideoEncoder(&allocated_encoder_);
|
|
|
|
|
allocated_encoder_ = new_encoder;
|
|
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-09 12:37:51 -08:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters(
|
2016-01-27 16:45:21 +01:00
|
|
|
const ChangedSendParameters& params) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
|
|
|
|
// |recreate_stream| means construction-time parameters have changed and the
|
|
|
|
|
// sending stream needs to be reset with the new config.
|
|
|
|
|
bool recreate_stream = false;
|
|
|
|
|
if (params.rtcp_mode) {
|
|
|
|
|
parameters_.config.rtp.rtcp_mode = *params.rtcp_mode;
|
|
|
|
|
recreate_stream = true;
|
|
|
|
|
}
|
|
|
|
|
if (params.rtp_header_extensions) {
|
|
|
|
|
parameters_.config.rtp.extensions = *params.rtp_header_extensions;
|
|
|
|
|
recreate_stream = true;
|
|
|
|
|
}
|
|
|
|
|
if (params.max_bandwidth_bps) {
|
|
|
|
|
parameters_.max_bitrate_bps = *params.max_bandwidth_bps;
|
|
|
|
|
ReconfigureEncoder();
|
|
|
|
|
}
|
|
|
|
|
if (params.conference_mode) {
|
|
|
|
|
parameters_.conference_mode = *params.conference_mode;
|
|
|
|
|
}
|
2016-03-10 18:32:00 +01:00
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
// Set codecs and options.
|
|
|
|
|
if (params.codec) {
|
2017-02-28 13:23:26 -08:00
|
|
|
bool force_encoder_allocation = false;
|
|
|
|
|
SetCodec(*params.codec, force_encoder_allocation);
|
2016-10-02 23:45:26 -07:00
|
|
|
recreate_stream = false; // SetCodec has already recreated the stream.
|
|
|
|
|
} else if (params.conference_mode && parameters_.codec_settings) {
|
2017-02-28 13:23:26 -08:00
|
|
|
bool force_encoder_allocation = false;
|
|
|
|
|
SetCodec(*parameters_.codec_settings, force_encoder_allocation);
|
2016-10-02 23:45:26 -07:00
|
|
|
recreate_stream = false; // SetCodec has already recreated the stream.
|
|
|
|
|
}
|
|
|
|
|
if (recreate_stream) {
|
|
|
|
|
LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters";
|
|
|
|
|
RecreateWebRtcStream();
|
|
|
|
|
}
|
2015-12-09 12:37:51 -08:00
|
|
|
}
|
|
|
|
|
|
2016-03-16 19:07:43 -07:00
|
|
|
bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpParameters(
|
|
|
|
|
const webrtc::RtpParameters& new_parameters) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2016-03-16 19:07:43 -07:00
|
|
|
if (!ValidateRtpParameters(new_parameters)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
bool reconfigure_encoder = new_parameters.encodings[0].max_bitrate_bps !=
|
|
|
|
|
rtp_parameters_.encodings[0].max_bitrate_bps;
|
2016-03-16 19:07:43 -07:00
|
|
|
rtp_parameters_ = new_parameters;
|
2016-04-20 16:23:10 -07:00
|
|
|
// Codecs are currently handled at the WebRtcVideoChannel2 level.
|
|
|
|
|
rtp_parameters_.codecs.clear();
|
2016-10-02 23:45:26 -07:00
|
|
|
if (reconfigure_encoder) {
|
|
|
|
|
ReconfigureEncoder();
|
|
|
|
|
}
|
2016-03-22 15:42:00 -07:00
|
|
|
// Encoding may have been activated/deactivated.
|
|
|
|
|
UpdateSendState();
|
2016-03-16 19:07:43 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-22 15:42:00 -07:00
|
|
|
webrtc::RtpParameters
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::GetRtpParameters() const {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2016-03-22 15:42:00 -07:00
|
|
|
return rtp_parameters_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 19:07:43 -07:00
|
|
|
bool WebRtcVideoChannel2::WebRtcVideoSendStream::ValidateRtpParameters(
|
|
|
|
|
const webrtc::RtpParameters& rtp_parameters) {
|
2017-01-06 23:05:37 -08:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2016-03-16 19:07:43 -07:00
|
|
|
if (rtp_parameters.encodings.size() != 1) {
|
|
|
|
|
LOG(LS_ERROR)
|
|
|
|
|
<< "Attempted to set RtpParameters without exactly one encoding";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-01-06 23:05:37 -08:00
|
|
|
if (rtp_parameters.encodings[0].ssrc != rtp_parameters_.encodings[0].ssrc) {
|
|
|
|
|
LOG(LS_ERROR) << "Attempted to set RtpParameters with modified SSRC";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-03-16 19:07:43 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-22 15:42:00 -07:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::UpdateSendState() {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2016-03-22 15:42:00 -07:00
|
|
|
// TODO(deadbeef): Need to handle more than one encoding in the future.
|
|
|
|
|
RTC_DCHECK(rtp_parameters_.encodings.size() == 1u);
|
|
|
|
|
if (sending_ && rtp_parameters_.encodings[0].active) {
|
|
|
|
|
RTC_DCHECK(stream_ != nullptr);
|
|
|
|
|
stream_->Start();
|
|
|
|
|
} else {
|
|
|
|
|
if (stream_ != nullptr) {
|
|
|
|
|
stream_->Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-07 10:54:43 +00:00
|
|
|
webrtc::VideoEncoderConfig
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
|
|
|
|
|
const VideoCodec& codec) const {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2014-11-07 10:54:43 +00:00
|
|
|
webrtc::VideoEncoderConfig encoder_config;
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
bool is_screencast = parameters_.options.is_screencast.value_or(false);
|
|
|
|
|
if (is_screencast) {
|
2014-11-07 10:54:43 +00:00
|
|
|
encoder_config.min_transmit_bitrate_bps =
|
2016-02-12 02:27:06 -08:00
|
|
|
1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0);
|
2015-04-28 10:01:41 +02:00
|
|
|
encoder_config.content_type =
|
|
|
|
|
webrtc::VideoEncoderConfig::ContentType::kScreen;
|
2014-11-07 10:54:43 +00:00
|
|
|
} else {
|
|
|
|
|
encoder_config.min_transmit_bitrate_bps = 0;
|
2015-04-28 10:01:41 +02:00
|
|
|
encoder_config.content_type =
|
|
|
|
|
webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo;
|
2014-11-07 10:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-27 01:59:29 -07:00
|
|
|
// By default, the stream count for the codec configuration should match the
|
|
|
|
|
// number of negotiated ssrcs. But if the codec is blacklisted for simulcast
|
2017-01-26 06:12:26 -08:00
|
|
|
// or a screencast (and not in simulcast screenshare experiment), only
|
|
|
|
|
// configure a single stream.
|
2016-10-02 23:45:26 -07:00
|
|
|
encoder_config.number_of_streams = parameters_.config.rtp.ssrcs.size();
|
2017-01-26 06:12:26 -08:00
|
|
|
if (IsCodecBlacklistedForSimulcast(codec.name) ||
|
|
|
|
|
(is_screencast && !UseSimulcastScreenshare())) {
|
2016-10-02 23:45:26 -07:00
|
|
|
encoder_config.number_of_streams = 1;
|
2015-08-27 01:59:29 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-04 12:09:01 -08:00
|
|
|
int stream_max_bitrate = parameters_.max_bitrate_bps;
|
|
|
|
|
if (rtp_parameters_.encodings[0].max_bitrate_bps) {
|
|
|
|
|
stream_max_bitrate =
|
|
|
|
|
MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),
|
|
|
|
|
parameters_.max_bitrate_bps);
|
|
|
|
|
}
|
2016-10-02 23:45:26 -07:00
|
|
|
|
|
|
|
|
int codec_max_bitrate_kbps;
|
|
|
|
|
if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps)) {
|
|
|
|
|
stream_max_bitrate = codec_max_bitrate_kbps * 1000;
|
2016-03-21 04:15:50 -07:00
|
|
|
}
|
2016-10-02 23:45:26 -07:00
|
|
|
encoder_config.max_bitrate_bps = stream_max_bitrate;
|
|
|
|
|
|
|
|
|
|
int max_qp = kDefaultQpMax;
|
|
|
|
|
codec.GetParam(kCodecParamMaxQuantization, &max_qp);
|
|
|
|
|
encoder_config.video_stream_factory =
|
|
|
|
|
new rtc::RefCountedObject<EncoderStreamFactory>(
|
2016-10-24 01:21:16 -07:00
|
|
|
codec.name, max_qp, kDefaultVideoMaxFramerate, is_screencast,
|
2016-10-02 23:45:26 -07:00
|
|
|
parameters_.conference_mode);
|
2014-11-07 10:54:43 +00:00
|
|
|
return encoder_config;
|
|
|
|
|
}
|
|
|
|
|
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::ReconfigureEncoder() {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
|
|
|
|
if (!stream_) {
|
|
|
|
|
// The webrtc::VideoSendStream |stream_|has not yet been created but other
|
|
|
|
|
// parameters has changed.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 15:21:39 -08:00
|
|
|
RTC_DCHECK_GT(parameters_.encoder_config.number_of_streams, 0);
|
2014-09-03 15:25:49 +00:00
|
|
|
|
2015-10-30 02:47:38 -07:00
|
|
|
RTC_CHECK(parameters_.codec_settings);
|
|
|
|
|
VideoCodecSettings codec_settings = *parameters_.codec_settings;
|
2014-09-03 15:25:49 +00:00
|
|
|
|
2014-11-07 10:54:43 +00:00
|
|
|
webrtc::VideoEncoderConfig encoder_config =
|
Avoid unnecessary HW video encoder reconfiguration
This change reduces the number of times the Android hardware video
encoder is reconfigured when making an outgoing call. With this change,
the encoder should only be initialized once as opposed to the ~3 times
it happens currently.
Before the fix, the following sequence of events caused the extra
reconfigurations:
1. After the SetLocalDescription call, the WebRtcVideoSendStream is created.
All frames from the camera are dropped until the corresponding
VideoSendStream is created.
2. SetRemoteDescription() triggers the VideoSendStream creation. At
this point, the encoder is configured for the first time, with the
frame dimensions set to a low resolution default (176x144).
3. When the first video frame is received from the camera after the
VideoSendStreamIsCreated, the encoder is reconfigured to the correct
dimensions. If we are using the Android hardware encoder, the default
configuration is set to encode from a memory buffer (use_surface=false).
4. When the frame is passed down to the encoder in
androidmediaencoder_jni.cc EncodeOnCodecThread(), it may be stored in
a texture instead of a memory buffer. In this case, yet another
reconfiguration takes place to enable encoding from a texture.
5. Even if the resolution and texture flag were known at the start of
the call, there would be a reconfiguration involved if the camera is
rotated (such as when making a call from a phone in portrait orientation).
The reason for that is that at construction time, WebRtcVideoEngine2
sets the VideoSinkWants structure parameter to request frames rotated
by the source; the early frames will then arrive in portrait resolution.
When the remote description is finally set, if the rotation RTP extension
is supported by the remote receiver, the source is asked to provide
non-rotated frames. The very next frame will then arrive in landscape
resolution with a non-zero rotation value to be applied by the receiver.
Since the encoder was configured with the last (portrait) frame size,
it's going to need to be reconfigured again.
The fix makes the following changes:
1. WebRtcVideoSendStream::OnFrame() now caches the last seen frame
dimensions, and whether the frame was stored in a texture.
2. When the encoder is configured the first time
(WebRtcVideoSendStream::SetCodec()) - the last seen frame dimensions
are used instead of the default dimensions.
3. A flag that indicates if encoding is to be done from a texture has
been added to the webrtc::VideoStream and webrtc::VideoCodec structs,
and it's been wired up to be passed down all the way to the JNI code in
androidmediaencoder_jni.cc.
4. MediaCodecVideoEncoder::InitEncode is now reading the is_surface
flag from the VideoCodec structure instead of guessing the default as
false. This way we end up with the correct encoder configuration the
first time around.
5. WebRtcVideoSendStream now takes an optimistic guess and requests non-
rotated frames when the supported RtpExtensions list is not available.
This makes the "early" frames arrive non-rotated, and the cached dimensions
will be correct for the common case when the rotation extension is supported.
If the other side is an older endpoint which does not support rotation,
the encoder will have to be reconfigured - but it's better to penalize the
uncommon case rather than the common one.
Review-Url: https://codereview.webrtc.org/2067103002
Cr-Commit-Position: refs/heads/master@{#13173}
2016-06-16 12:08:03 -07:00
|
|
|
CreateVideoEncoderConfig(codec_settings.codec);
|
2014-11-07 10:54:43 +00:00
|
|
|
|
2015-04-28 10:01:41 +02:00
|
|
|
encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings(
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
codec_settings.codec);
|
2014-07-22 16:29:54 +00:00
|
|
|
|
2016-09-01 01:17:40 -07:00
|
|
|
stream_->ReconfigureVideoEncoder(encoder_config.Copy());
|
2014-09-19 12:30:25 +00:00
|
|
|
|
|
|
|
|
encoder_config.encoder_specific_settings = NULL;
|
2014-07-22 16:29:54 +00:00
|
|
|
|
2016-09-01 01:17:40 -07:00
|
|
|
parameters_.encoder_config = std::move(encoder_config);
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-22 15:42:00 -07:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSend(bool send) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2016-03-22 15:42:00 -07:00
|
|
|
sending_ = send;
|
|
|
|
|
UpdateSendState();
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-16 07:53:41 -07:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::RemoveSink(
|
2017-01-13 05:57:25 -08:00
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2017-01-13 05:57:25 -08:00
|
|
|
RTC_DCHECK(encoder_sink_ == sink);
|
|
|
|
|
encoder_sink_ = nullptr;
|
|
|
|
|
source_->RemoveSink(sink);
|
2016-11-01 11:45:46 -07:00
|
|
|
}
|
2016-10-02 23:45:26 -07:00
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::AddOrUpdateSink(
|
2017-01-13 05:57:25 -08:00
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
|
2016-11-01 11:45:46 -07:00
|
|
|
const rtc::VideoSinkWants& wants) {
|
|
|
|
|
if (worker_thread_ == rtc::Thread::Current()) {
|
|
|
|
|
// AddOrUpdateSink is called on |worker_thread_| if this is the first
|
|
|
|
|
// registration of |sink|.
|
|
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2017-01-13 05:57:25 -08:00
|
|
|
encoder_sink_ = sink;
|
|
|
|
|
source_->AddOrUpdateSink(encoder_sink_, wants);
|
2016-10-02 23:45:26 -07:00
|
|
|
} else {
|
2016-11-01 11:45:46 -07:00
|
|
|
// Subsequent calls to AddOrUpdateSink will happen on the encoder task
|
|
|
|
|
// queue.
|
2017-01-13 05:57:25 -08:00
|
|
|
invoker_.AsyncInvoke<void>(
|
|
|
|
|
RTC_FROM_HERE, worker_thread_, [this, sink, wants] {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
|
|
|
|
// |sink| may be invalidated after this task was posted since
|
|
|
|
|
// RemoveSink is called on the worker thread.
|
|
|
|
|
bool encoder_sink_valid = (sink == encoder_sink_);
|
|
|
|
|
if (source_ && encoder_sink_valid) {
|
|
|
|
|
source_->AddOrUpdateSink(encoder_sink_, wants);
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-02-29 00:04:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-11 08:41:18 -07:00
|
|
|
VideoSenderInfo WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo(
|
|
|
|
|
bool log_stats) {
|
2014-07-18 11:11:55 +00:00
|
|
|
VideoSenderInfo info;
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
|
|
|
|
for (uint32_t ssrc : parameters_.config.rtp.ssrcs)
|
|
|
|
|
info.add_ssrc(ssrc);
|
2015-02-23 16:39:07 +00:00
|
|
|
|
2016-11-14 02:28:16 -08:00
|
|
|
if (parameters_.codec_settings) {
|
2016-10-02 23:45:26 -07:00
|
|
|
info.codec_name = parameters_.codec_settings->codec.name;
|
2016-11-17 23:43:29 -08:00
|
|
|
info.codec_payload_type = rtc::Optional<int>(
|
|
|
|
|
parameters_.codec_settings->codec.id);
|
2016-11-14 02:28:16 -08:00
|
|
|
}
|
2014-07-18 11:11:55 +00:00
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
if (stream_ == NULL)
|
|
|
|
|
return info;
|
2014-08-12 20:55:10 +00:00
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
webrtc::VideoSendStream::Stats stats = stream_->GetStats();
|
2016-08-11 08:41:18 -07:00
|
|
|
|
|
|
|
|
if (log_stats)
|
|
|
|
|
LOG(LS_INFO) << stats.ToString(rtc::TimeMillis());
|
|
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
info.adapt_changes = stats.number_of_cpu_adapt_changes;
|
2016-04-05 15:23:49 +02:00
|
|
|
info.adapt_reason =
|
2016-11-01 11:45:46 -07:00
|
|
|
stats.cpu_limited_resolution ? ADAPTREASON_CPU : ADAPTREASON_NONE;
|
2016-02-29 00:04:41 -08:00
|
|
|
|
2015-12-14 02:08:12 -08:00
|
|
|
// Get bandwidth limitation info from stream_->GetStats().
|
|
|
|
|
// Input resolution (output from video_adapter) can be further scaled down or
|
|
|
|
|
// higher video layer(s) can be dropped due to bitrate constraints.
|
|
|
|
|
// Note, adapt_changes only include changes from the video_adapter.
|
|
|
|
|
if (stats.bw_limited_resolution)
|
2016-04-05 15:23:49 +02:00
|
|
|
info.adapt_reason |= ADAPTREASON_BANDWIDTH;
|
2015-12-14 02:08:12 -08:00
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
info.encoder_implementation_name = stats.encoder_implementation_name;
|
2015-05-28 13:39:50 +02:00
|
|
|
info.ssrc_groups = ssrc_groups_;
|
2014-07-18 11:11:55 +00:00
|
|
|
info.framerate_input = stats.input_frame_rate;
|
|
|
|
|
info.framerate_sent = stats.encode_frame_rate;
|
2015-02-26 12:19:31 +00:00
|
|
|
info.avg_encode_ms = stats.avg_encode_time_ms;
|
|
|
|
|
info.encode_usage_percent = stats.encode_usage_percent;
|
2016-10-24 01:46:43 -07:00
|
|
|
info.frames_encoded = stats.frames_encoded;
|
2016-10-31 06:53:47 -07:00
|
|
|
info.qp_sum = stats.qp_sum;
|
2014-07-18 11:11:55 +00:00
|
|
|
|
2015-02-23 16:39:07 +00:00
|
|
|
info.nominal_bitrate = stats.media_bitrate_bps;
|
2016-09-29 11:48:50 +02:00
|
|
|
info.preferred_bitrate = stats.preferred_media_bitrate_bps;
|
2015-02-23 16:39:07 +00:00
|
|
|
|
2014-12-01 15:23:21 +00:00
|
|
|
info.send_frame_width = 0;
|
|
|
|
|
info.send_frame_height = 0;
|
2015-02-25 10:42:16 +00:00
|
|
|
for (std::map<uint32_t, webrtc::VideoSendStream::StreamStats>::iterator it =
|
2014-07-18 11:11:55 +00:00
|
|
|
stats.substreams.begin();
|
2015-02-25 10:42:16 +00:00
|
|
|
it != stats.substreams.end(); ++it) {
|
2014-07-18 11:11:55 +00:00
|
|
|
// TODO(pbos): Wire up additional stats, such as padding bytes.
|
2015-02-25 10:42:16 +00:00
|
|
|
webrtc::VideoSendStream::StreamStats stream_stats = it->second;
|
2015-01-22 09:39:59 +00:00
|
|
|
info.bytes_sent += stream_stats.rtp_stats.transmitted.payload_bytes +
|
|
|
|
|
stream_stats.rtp_stats.transmitted.header_bytes +
|
|
|
|
|
stream_stats.rtp_stats.transmitted.padding_bytes;
|
|
|
|
|
info.packets_sent += stream_stats.rtp_stats.transmitted.packets;
|
2014-07-18 11:11:55 +00:00
|
|
|
info.packets_lost += stream_stats.rtcp_stats.cumulative_lost;
|
2015-02-25 10:42:16 +00:00
|
|
|
if (stream_stats.width > info.send_frame_width)
|
|
|
|
|
info.send_frame_width = stream_stats.width;
|
|
|
|
|
if (stream_stats.height > info.send_frame_height)
|
|
|
|
|
info.send_frame_height = stream_stats.height;
|
2015-02-19 12:47:00 +00:00
|
|
|
info.firs_rcvd += stream_stats.rtcp_packet_type_counts.fir_packets;
|
|
|
|
|
info.nacks_rcvd += stream_stats.rtcp_packet_type_counts.nack_packets;
|
|
|
|
|
info.plis_rcvd += stream_stats.rtcp_packet_type_counts.pli_packets;
|
2014-07-18 11:11:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!stats.substreams.empty()) {
|
|
|
|
|
// TODO(pbos): Report fraction lost per SSRC.
|
2015-02-25 10:42:16 +00:00
|
|
|
webrtc::VideoSendStream::StreamStats first_stream_stats =
|
|
|
|
|
stats.substreams.begin()->second;
|
2014-07-18 11:11:55 +00:00
|
|
|
info.fraction_lost =
|
|
|
|
|
static_cast<float>(first_stream_stats.rtcp_stats.fraction_lost) /
|
|
|
|
|
(1 << 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-05 14:05:29 +00:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::FillBandwidthEstimationInfo(
|
|
|
|
|
BandwidthEstimationInfo* bwe_info) {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2014-11-05 14:05:29 +00:00
|
|
|
if (stream_ == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
webrtc::VideoSendStream::Stats stats = stream_->GetStats();
|
2015-02-25 10:42:16 +00:00
|
|
|
for (std::map<uint32_t, webrtc::VideoSendStream::StreamStats>::iterator it =
|
2014-11-05 14:05:29 +00:00
|
|
|
stats.substreams.begin();
|
2015-02-25 10:42:16 +00:00
|
|
|
it != stats.substreams.end(); ++it) {
|
2014-11-05 14:05:29 +00:00
|
|
|
bwe_info->transmit_bitrate += it->second.total_bitrate_bps;
|
|
|
|
|
bwe_info->retransmit_bitrate += it->second.retransmit_bitrate_bps;
|
|
|
|
|
}
|
2015-02-26 13:15:22 +00:00
|
|
|
bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps;
|
2015-02-23 16:39:07 +00:00
|
|
|
bwe_info->actual_enc_bitrate += stats.media_bitrate_bps;
|
2014-11-05 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() {
|
2016-10-02 23:45:26 -07:00
|
|
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
2014-05-13 11:07:01 +00:00
|
|
|
if (stream_ != NULL) {
|
|
|
|
|
call_->DestroyVideoSendStream(stream_);
|
|
|
|
|
}
|
2014-06-06 10:49:19 +00:00
|
|
|
|
2015-10-30 02:47:38 -07:00
|
|
|
RTC_CHECK(parameters_.codec_settings);
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
RTC_DCHECK_EQ((parameters_.encoder_config.content_type ==
|
|
|
|
|
webrtc::VideoEncoderConfig::ContentType::kScreen),
|
|
|
|
|
parameters_.options.is_screencast.value_or(false))
|
|
|
|
|
<< "encoder content type inconsistent with screencast option";
|
2014-09-19 12:30:25 +00:00
|
|
|
parameters_.encoder_config.encoder_specific_settings =
|
New flag is_screencast in VideoOptions.
This cl copies the value of cricket::VideoCapturer::IsScreencast into
a flag in VideoOptions. It is passed on via the chain
VideortpSender::SetVideoSend
WebRtcVideoChannel2::SetVideoSend
WebRtcVideoChannel2::SetOptions
WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions
Where it's used, in
WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame, we can look it up
in parameters_, instead of calling capturer_->IsScreencast().
Doesn't touch screencast logic related to cpu adaptation, since that
code is in flux in a different cl.
Also drop the is_screencast flag from the Dimensions struct, and drop separate options argument from ConfigureVideoEncoderSettings and SetCodecAndOptions, instead always using the options recorded in VideoSendStreamParameters::options.
In the tests, changed FakeVideoCapturer::is_screencast to be a construction time flag. Generally, unittests of screencast have to both use a capturer configured for screencast, and set the screencast flag using SetSendParameters. Since the automatic connection via VideoSource and VideoRtpSender isn't involved in the unit tests.
Note that using SetSendParameters to set the screencast flag doesn't make sense, since it's not per-stream. SetVideoSend would be more appropriate. That should be fixed if/when we drop VideoOptions from SetSendParameters.
BUG=webrtc:5426
R=pbos@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1711763003 .
Cr-Commit-Position: refs/heads/master@{#11837}
2016-03-02 11:41:36 +01:00
|
|
|
ConfigureVideoEncoderSettings(parameters_.codec_settings->codec);
|
2014-09-19 12:30:25 +00:00
|
|
|
|
2016-09-01 01:17:40 -07:00
|
|
|
webrtc::VideoSendStream::Config config = parameters_.config.Copy();
|
2015-03-20 19:52:56 +00:00
|
|
|
if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) {
|
|
|
|
|
LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX "
|
|
|
|
|
"payload type the set codec. Ignoring RTX.";
|
|
|
|
|
config.rtp.rtx.ssrcs.clear();
|
|
|
|
|
}
|
2016-09-01 01:17:40 -07:00
|
|
|
stream_ = call_->CreateVideoSendStream(std::move(config),
|
|
|
|
|
parameters_.encoder_config.Copy());
|
2014-07-22 16:29:54 +00:00
|
|
|
|
2014-09-19 12:30:25 +00:00
|
|
|
parameters_.encoder_config.encoder_specific_settings = NULL;
|
2014-07-22 16:29:54 +00:00
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
if (source_) {
|
|
|
|
|
// Do not adapt resolution for screen content as this will likely result in
|
|
|
|
|
// blurry and unreadable text.
|
2017-01-13 05:57:25 -08:00
|
|
|
// |this| acts like a VideoSource to make sure SinkWants are handled on the
|
|
|
|
|
// correct thread.
|
2016-11-01 11:45:46 -07:00
|
|
|
stream_->SetSource(
|
|
|
|
|
this, enable_cpu_overuse_detection_ &&
|
|
|
|
|
!parameters_.options.is_screencast.value_or(false)
|
|
|
|
|
? webrtc::VideoSendStream::DegradationPreference::kBalanced
|
|
|
|
|
: webrtc::VideoSendStream::DegradationPreference::
|
|
|
|
|
kMaintainResolution);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 17:16:54 -07:00
|
|
|
// Call stream_->Start() if necessary conditions are met.
|
|
|
|
|
UpdateSendState();
|
2014-05-13 11:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 09:35:58 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(
|
|
|
|
|
webrtc::Call* call,
|
2015-05-28 13:39:50 +02:00
|
|
|
const StreamParams& sp,
|
2016-06-10 17:58:01 +02:00
|
|
|
webrtc::VideoReceiveStream::Config config,
|
2014-10-29 15:28:39 +00:00
|
|
|
WebRtcVideoDecoderFactory* external_decoder_factory,
|
2015-03-06 15:35:19 +00:00
|
|
|
bool default_stream,
|
2016-11-22 02:16:47 -08:00
|
|
|
const std::vector<VideoCodecSettings>& recv_codecs,
|
2017-01-13 07:41:19 -08:00
|
|
|
const webrtc::FlexfecReceiveStream::Config& flexfec_config)
|
2014-07-18 09:35:58 +00:00
|
|
|
: call_(call),
|
2016-06-22 00:46:15 -07:00
|
|
|
stream_params_(sp),
|
2014-07-18 09:35:58 +00:00
|
|
|
stream_(NULL),
|
2015-03-06 15:35:19 +00:00
|
|
|
default_stream_(default_stream),
|
2016-06-10 17:58:01 +02:00
|
|
|
config_(std::move(config)),
|
2016-11-22 02:16:47 -08:00
|
|
|
flexfec_config_(flexfec_config),
|
|
|
|
|
flexfec_stream_(nullptr),
|
2014-10-29 15:28:39 +00:00
|
|
|
external_decoder_factory_(external_decoder_factory),
|
2016-01-28 04:47:08 -08:00
|
|
|
sink_(NULL),
|
2015-01-27 09:57:01 +00:00
|
|
|
first_frame_timestamp_(-1),
|
|
|
|
|
estimated_remote_start_ntp_time_ms_(0) {
|
2014-07-18 09:35:58 +00:00
|
|
|
config_.renderer = this;
|
2016-01-28 15:58:41 -08:00
|
|
|
std::vector<AllocatedDecoder> old_decoders;
|
|
|
|
|
ConfigureCodecs(recv_codecs, &old_decoders);
|
|
|
|
|
RecreateWebRtcStream();
|
|
|
|
|
RTC_DCHECK(old_decoders.empty());
|
2014-07-18 09:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-18 19:42:03 +02:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder::
|
|
|
|
|
AllocatedDecoder(webrtc::VideoDecoder* decoder,
|
|
|
|
|
webrtc::VideoCodecType type,
|
|
|
|
|
bool external)
|
|
|
|
|
: decoder(decoder),
|
|
|
|
|
external_decoder(nullptr),
|
|
|
|
|
type(type),
|
|
|
|
|
external(external) {
|
|
|
|
|
if (external) {
|
|
|
|
|
external_decoder = decoder;
|
|
|
|
|
this->decoder =
|
|
|
|
|
new webrtc::VideoDecoderSoftwareFallbackWrapper(type, external_decoder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 09:35:58 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() {
|
2017-01-23 06:59:13 -08:00
|
|
|
if (flexfec_stream_) {
|
|
|
|
|
call_->DestroyFlexfecReceiveStream(flexfec_stream_);
|
|
|
|
|
}
|
2014-07-18 09:35:58 +00:00
|
|
|
call_->DestroyVideoReceiveStream(stream_);
|
2014-11-03 14:46:44 +00:00
|
|
|
ClearDecoders(&allocated_decoders_);
|
2014-07-18 09:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
const std::vector<uint32_t>&
|
2015-03-26 16:23:04 +01:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetSsrcs() const {
|
2016-06-22 00:46:15 -07:00
|
|
|
return stream_params_.ssrcs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::Optional<uint32_t>
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetFirstPrimarySsrc() const {
|
|
|
|
|
std::vector<uint32_t> primary_ssrcs;
|
|
|
|
|
stream_params_.GetPrimarySsrcs(&primary_ssrcs);
|
|
|
|
|
|
|
|
|
|
if (primary_ssrcs.empty()) {
|
|
|
|
|
LOG(LS_WARNING) << "Empty primary ssrcs vector, returning empty optional";
|
|
|
|
|
return rtc::Optional<uint32_t>();
|
|
|
|
|
} else {
|
|
|
|
|
return rtc::Optional<uint32_t>(primary_ssrcs[0]);
|
|
|
|
|
}
|
2015-03-26 16:23:04 +01:00
|
|
|
}
|
|
|
|
|
|
2014-11-03 14:46:44 +00:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder(
|
|
|
|
|
std::vector<AllocatedDecoder>* old_decoders,
|
|
|
|
|
const VideoCodec& codec) {
|
2016-11-22 10:16:57 -08:00
|
|
|
webrtc::VideoCodecType type = webrtc::PayloadNameToCodecType(codec.name)
|
|
|
|
|
.value_or(webrtc::kVideoCodecUnknown);
|
2014-10-29 15:28:39 +00:00
|
|
|
|
2014-11-03 14:46:44 +00:00
|
|
|
for (size_t i = 0; i < old_decoders->size(); ++i) {
|
|
|
|
|
if ((*old_decoders)[i].type == type) {
|
|
|
|
|
AllocatedDecoder decoder = (*old_decoders)[i];
|
|
|
|
|
(*old_decoders)[i] = old_decoders->back();
|
|
|
|
|
old_decoders->pop_back();
|
|
|
|
|
return decoder;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-29 15:28:39 +00:00
|
|
|
|
2014-11-03 14:46:44 +00:00
|
|
|
if (external_decoder_factory_ != NULL) {
|
|
|
|
|
webrtc::VideoDecoder* decoder =
|
2016-06-22 00:46:15 -07:00
|
|
|
external_decoder_factory_->CreateVideoDecoderWithParams(
|
|
|
|
|
type, {stream_params_.id});
|
2014-11-03 14:46:44 +00:00
|
|
|
if (decoder != NULL) {
|
2016-12-01 00:27:27 -08:00
|
|
|
return AllocatedDecoder(decoder, type, true /* is_external */);
|
2014-11-03 14:46:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-10-29 15:28:39 +00:00
|
|
|
|
2016-12-01 00:27:27 -08:00
|
|
|
InternalDecoderFactory internal_decoder_factory;
|
|
|
|
|
return AllocatedDecoder(internal_decoder_factory.CreateVideoDecoderWithParams(
|
|
|
|
|
type, {stream_params_.id}),
|
|
|
|
|
type, false /* is_external */);
|
2014-11-03 14:46:44 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-28 15:58:41 -08:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ConfigureCodecs(
|
|
|
|
|
const std::vector<VideoCodecSettings>& recv_codecs,
|
|
|
|
|
std::vector<AllocatedDecoder>* old_decoders) {
|
|
|
|
|
*old_decoders = allocated_decoders_;
|
2014-11-03 14:46:44 +00:00
|
|
|
allocated_decoders_.clear();
|
|
|
|
|
config_.decoders.clear();
|
|
|
|
|
for (size_t i = 0; i < recv_codecs.size(); ++i) {
|
|
|
|
|
AllocatedDecoder allocated_decoder =
|
2016-01-28 15:58:41 -08:00
|
|
|
CreateOrReuseVideoDecoder(old_decoders, recv_codecs[i].codec);
|
2014-11-03 14:46:44 +00:00
|
|
|
allocated_decoders_.push_back(allocated_decoder);
|
2014-07-18 09:35:58 +00:00
|
|
|
|
2014-11-03 14:46:44 +00:00
|
|
|
webrtc::VideoReceiveStream::Decoder decoder;
|
|
|
|
|
decoder.decoder = allocated_decoder.decoder;
|
|
|
|
|
decoder.payload_type = recv_codecs[i].codec.id;
|
|
|
|
|
decoder.payload_name = recv_codecs[i].codec.name;
|
2016-11-25 03:56:37 -08:00
|
|
|
decoder.codec_params = recv_codecs[i].codec.params;
|
2014-11-03 14:46:44 +00:00
|
|
|
config_.decoders.push_back(decoder);
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #1 id:1 of https://codereview.webrtc.org/2649323010/ )
Reason for revert:
Downstream project relied on changed struct.
Transition made possible by https://codereview.webrtc.org/2655243006/.
Original issue's description:
> Revert of Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters. (patchset #7 id:160001 of https://codereview.webrtc.org/2646073004/ )
>
> Reason for revert:
> Breaks internal downstream project.
>
> Original issue's description:
> > Make RTX pt/apt reconfigurable by calling WebRtcVideoChannel2::SetRecvParameters.
> >
> > Prior to this CL, received RTX (associated) payload types were only configured
> > when WebRtcVideoChannel2::AddRecvStream was called. In the same method, the RTX
> > SSRC was set up.
> >
> > After this CL, the RTX (associated) payload types are set in
> > WebRtcVideoChannel2::SetRecvParameters, which is the appropriate place to set
> > them. The RTX SSRC is still set in WebRtcVideoChannel2::AddRecvStream, since
> > that is the code path that sets other SSRCs.
> >
> > As part of this fix, the VideoReceiveStream::Config::Rtp struct is changed.
> > We remove the possibility for each video payload type to have an associated
> > specific RTX SSRC. Although the config previously allowed for this, all payload
> > types always had the same RTX SSRC set, and the underlying RtpPayloadRegistry
> > did not support multiple SSRCs. This change to the config struct should thus not
> > have any functional impact. The change does however affect the RtcEventLog, since
> > that is used for storing the VideoReceiveStream::Configs. For simplicity,
> > this CL does not change the event log proto definitions, instead duplicating
> > the serialized RTX SSRCs such that they fit in the existing proto definition.
> >
> > BUG=webrtc:7011
> >
> > Review-Url: https://codereview.webrtc.org/2646073004
> > Cr-Commit-Position: refs/heads/master@{#16302}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fe2bef39cd2a5c891a49f7320514fb04324dc66c
>
> TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,brandtr@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7011
>
> Review-Url: https://codereview.webrtc.org/2649323010
> Cr-Commit-Position: refs/heads/master@{#16307}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e4974953ce0d03a60fae7659b199a6a62a79fa30
TBR=stefan@webrtc.org,magjed@webrtc.org,terelius@webrtc.org,kjellander@webrtc.org,kjellander@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
# NOTREECHECKS=true
# NOTRY=true
BUG=webrtc:7011
Review-Url: https://codereview.webrtc.org/2654163006
Cr-Commit-Position: refs/heads/master@{#16322}
2017-01-27 04:53:07 -08:00
|
|
|
config_.rtp.rtx_payload_types.clear();
|
|
|
|
|
for (const VideoCodecSettings& recv_codec : recv_codecs) {
|
|
|
|
|
config_.rtp.rtx_payload_types[recv_codec.codec.id] =
|
|
|
|
|
recv_codec.rtx_payload_type;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 23:28:39 -07:00
|
|
|
config_.rtp.ulpfec = recv_codecs.front().ulpfec;
|
2017-01-13 07:41:19 -08:00
|
|
|
flexfec_config_.payload_type = recv_codecs.front().flexfec_payload_type;
|
2016-12-19 09:41:04 -08:00
|
|
|
|
2014-07-25 19:01:32 +00:00
|
|
|
config_.rtp.nack.rtp_history_ms =
|
2015-04-21 20:24:50 +08:00
|
|
|
HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0;
|
2014-07-18 09:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-22 18:48:36 +02:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc(
|
|
|
|
|
uint32_t local_ssrc) {
|
2015-09-17 00:24:34 -07:00
|
|
|
// TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You
|
|
|
|
|
// should not be able to create a sender with the same SSRC as a receiver, but
|
|
|
|
|
// right now this can't be done due to unittests depending on receiving what
|
|
|
|
|
// they are sending from the same MediaChannel.
|
2015-08-20 17:19:20 -07:00
|
|
|
if (local_ssrc == config_.rtp.remote_ssrc) {
|
|
|
|
|
LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are "
|
|
|
|
|
"unchanged; local_ssrc=" << local_ssrc;
|
2015-05-22 18:48:36 +02:00
|
|
|
return;
|
2015-08-20 17:19:20 -07:00
|
|
|
}
|
2015-05-22 18:48:36 +02:00
|
|
|
|
|
|
|
|
config_.rtp.local_ssrc = local_ssrc;
|
2017-01-17 01:33:54 -08:00
|
|
|
flexfec_config_.local_ssrc = local_ssrc;
|
2015-08-20 17:19:20 -07:00
|
|
|
LOG(LS_INFO)
|
|
|
|
|
<< "RecreateWebRtcStream (recv) because of SetLocalSsrc; local_ssrc="
|
|
|
|
|
<< local_ssrc;
|
2015-05-22 18:48:36 +02:00
|
|
|
RecreateWebRtcStream();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-20 18:05:48 -08:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFeedbackParameters(
|
|
|
|
|
bool nack_enabled,
|
|
|
|
|
bool remb_enabled,
|
2016-03-18 15:02:07 -07:00
|
|
|
bool transport_cc_enabled,
|
|
|
|
|
webrtc::RtcpMode rtcp_mode) {
|
2015-05-11 14:34:58 +02:00
|
|
|
int nack_history_ms = nack_enabled ? kNackHistoryMs : 0;
|
|
|
|
|
if (config_.rtp.nack.rtp_history_ms == nack_history_ms &&
|
2015-11-20 18:05:48 -08:00
|
|
|
config_.rtp.remb == remb_enabled &&
|
2016-03-18 15:02:07 -07:00
|
|
|
config_.rtp.transport_cc == transport_cc_enabled &&
|
|
|
|
|
config_.rtp.rtcp_mode == rtcp_mode) {
|
2015-11-20 18:05:48 -08:00
|
|
|
LOG(LS_INFO)
|
|
|
|
|
<< "Ignoring call to SetFeedbackParameters because parameters are "
|
|
|
|
|
"unchanged; nack="
|
|
|
|
|
<< nack_enabled << ", remb=" << remb_enabled
|
|
|
|
|
<< ", transport_cc=" << transport_cc_enabled;
|
2015-05-11 12:48:12 +02:00
|
|
|
return;
|
2015-05-11 14:34:58 +02:00
|
|
|
}
|
|
|
|
|
config_.rtp.remb = remb_enabled;
|
|
|
|
|
config_.rtp.nack.rtp_history_ms = nack_history_ms;
|
2015-11-20 18:05:48 -08:00
|
|
|
config_.rtp.transport_cc = transport_cc_enabled;
|
2016-03-18 15:02:07 -07:00
|
|
|
config_.rtp.rtcp_mode = rtcp_mode;
|
2017-02-03 04:43:41 -08:00
|
|
|
// TODO(brandtr): We should be spec-compliant and set |transport_cc| here
|
|
|
|
|
// based on the rtcp-fb for the FlexFEC codec, not the media codec.
|
|
|
|
|
flexfec_config_.transport_cc = config_.rtp.transport_cc;
|
|
|
|
|
flexfec_config_.rtcp_mode = config_.rtp.rtcp_mode;
|
2015-11-20 18:05:48 -08:00
|
|
|
LOG(LS_INFO)
|
|
|
|
|
<< "RecreateWebRtcStream (recv) because of SetFeedbackParameters; nack="
|
|
|
|
|
<< nack_enabled << ", remb=" << remb_enabled
|
|
|
|
|
<< ", transport_cc=" << transport_cc_enabled;
|
2015-05-11 12:48:12 +02:00
|
|
|
RecreateWebRtcStream();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-09 12:37:51 -08:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvParameters(
|
2016-01-28 15:58:41 -08:00
|
|
|
const ChangedRecvParameters& params) {
|
|
|
|
|
bool needs_recreation = false;
|
|
|
|
|
std::vector<AllocatedDecoder> old_decoders;
|
|
|
|
|
if (params.codec_settings) {
|
|
|
|
|
ConfigureCodecs(*params.codec_settings, &old_decoders);
|
|
|
|
|
needs_recreation = true;
|
|
|
|
|
}
|
|
|
|
|
if (params.rtp_header_extensions) {
|
|
|
|
|
config_.rtp.extensions = *params.rtp_header_extensions;
|
2017-02-03 04:43:41 -08:00
|
|
|
flexfec_config_.rtp_header_extensions = *params.rtp_header_extensions;
|
2016-01-28 15:58:41 -08:00
|
|
|
needs_recreation = true;
|
|
|
|
|
}
|
|
|
|
|
if (needs_recreation) {
|
|
|
|
|
LOG(LS_INFO) << "RecreateWebRtcStream (recv) because of SetRecvParameters";
|
|
|
|
|
RecreateWebRtcStream();
|
|
|
|
|
ClearDecoders(&old_decoders);
|
|
|
|
|
}
|
2015-12-09 12:37:51 -08:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 09:35:58 +00:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() {
|
2017-01-27 06:47:55 -08:00
|
|
|
if (stream_) {
|
|
|
|
|
call_->DestroyVideoReceiveStream(stream_);
|
|
|
|
|
stream_ = nullptr;
|
|
|
|
|
}
|
2016-11-22 02:16:47 -08:00
|
|
|
if (flexfec_stream_) {
|
|
|
|
|
call_->DestroyFlexfecReceiveStream(flexfec_stream_);
|
|
|
|
|
flexfec_stream_ = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (IsFlexfecFieldTrialEnabled() && flexfec_config_.IsCompleteAndEnabled()) {
|
2017-01-13 07:41:19 -08:00
|
|
|
flexfec_stream_ = call_->CreateFlexfecReceiveStream(flexfec_config_);
|
2016-11-22 02:16:47 -08:00
|
|
|
flexfec_stream_->Start();
|
|
|
|
|
}
|
2017-01-27 06:47:55 -08:00
|
|
|
stream_ = call_->CreateVideoReceiveStream(config_.Copy());
|
|
|
|
|
stream_->Start();
|
2014-07-18 09:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-03 14:46:44 +00:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders(
|
|
|
|
|
std::vector<AllocatedDecoder>* allocated_decoders) {
|
|
|
|
|
for (size_t i = 0; i < allocated_decoders->size(); ++i) {
|
|
|
|
|
if ((*allocated_decoders)[i].external) {
|
2014-10-29 15:28:39 +00:00
|
|
|
external_decoder_factory_->DestroyVideoDecoder(
|
2015-05-18 19:42:03 +02:00
|
|
|
(*allocated_decoders)[i].external_decoder);
|
2014-10-29 15:28:39 +00:00
|
|
|
}
|
2015-05-18 19:42:03 +02:00
|
|
|
delete (*allocated_decoders)[i].decoder;
|
2014-10-29 15:28:39 +00:00
|
|
|
}
|
2014-11-03 14:46:44 +00:00
|
|
|
allocated_decoders->clear();
|
2014-10-29 15:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-21 01:27:56 -07:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::OnFrame(
|
|
|
|
|
const webrtc::VideoFrame& frame) {
|
2016-01-28 04:47:08 -08:00
|
|
|
rtc::CritScope crit(&sink_lock_);
|
2015-01-27 09:57:01 +00:00
|
|
|
|
|
|
|
|
if (first_frame_timestamp_ < 0)
|
|
|
|
|
first_frame_timestamp_ = frame.timestamp();
|
|
|
|
|
int64_t rtp_time_elapsed_since_first_frame =
|
|
|
|
|
(timestamp_wraparound_handler_.Unwrap(frame.timestamp()) -
|
|
|
|
|
first_frame_timestamp_);
|
|
|
|
|
int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame /
|
|
|
|
|
(cricket::kVideoCodecClockrate / 1000);
|
|
|
|
|
if (frame.ntp_time_ms() > 0)
|
|
|
|
|
estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms;
|
|
|
|
|
|
2016-01-28 04:47:08 -08:00
|
|
|
if (sink_ == NULL) {
|
|
|
|
|
LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink.";
|
2014-07-18 09:35:58 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Make cricket::VideoFrame inherit webrtc::VideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2402853002/ )
This cl now makes cricket::VideoFrame and cricket::WebRtcVideoFrame aliases for webrtc::VideoFrame.
Reason for revert:
Fixing backwards compatibility issues.
Original issue's description:
> Revert of Make cricket::VideoFrame inherit webrtc::VideoFrame. (patchset #9 id:160001 of https://codereview.webrtc.org/2315663002/ )
>
> Reason for revert:
> Breaks compile for Chromium builds:
> https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/10761
> https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/18142
>
> FAILED: obj/remoting/protocol/protocol/webrtc_video_renderer_adapter.o
> ../../remoting/protocol/webrtc_video_renderer_adapter.cc:110:52: error: no member named 'transport_frame_id' in 'cricket::VideoFrame'
> weak_factory_.GetWeakPtr(), frame.transport_frame_id(),
> ~~~~~ ^
> 1 error generated.
>
> Please run chromium trybots as described at https://webrtc.org/contributing/#tryjobs-on-chromium-trybots before relanding.
>
> Original issue's description:
> > Make cricket::VideoFrame inherit webrtc::VideoFrame. Delete
> > all methods but a few constructors. And similarly for the
> > subclass cricket::WebRtcVideoFrame.
> >
> > TBR=tkchin@webrtc.org # Added an include line
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/dda6ec008a0fc8d52e118814fb779032e8931968
> > Cr-Commit-Position: refs/heads/master@{#14576}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,pthatcher@chromium.org,tkchin@webrtc.org,nisse@webrtc.org
> NOTRY=True
> NOPRESUBMIT=True
> BUG=webrtc:5682
>
> Committed: https://crrev.com/d36dd499c8f253cbcf37364c2a070c2e8c7100e9
> Cr-Commit-Position: refs/heads/master@{#14583}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,pthatcher@chromium.org,tkchin@webrtc.org,kjellander@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2411953002
Cr-Commit-Position: refs/heads/master@{#14678}
2016-10-19 00:30:30 -07:00
|
|
|
sink_->OnFrame(frame);
|
2014-07-18 09:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-06 15:35:19 +00:00
|
|
|
bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const {
|
|
|
|
|
return default_stream_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-28 04:47:08 -08:00
|
|
|
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink(
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
|
2016-01-28 04:47:08 -08:00
|
|
|
rtc::CritScope crit(&sink_lock_);
|
|
|
|
|
sink_ = sink;
|
2014-07-18 09:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 07:35:32 -07:00
|
|
|
std::string
|
|
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType(
|
|
|
|
|
int payload_type) {
|
|
|
|
|
for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) {
|
|
|
|
|
if (decoder.payload_type == payload_type) {
|
|
|
|
|
return decoder.payload_name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 11:11:55 +00:00
|
|
|
VideoReceiverInfo
|
2016-08-11 08:41:18 -07:00
|
|
|
WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetVideoReceiverInfo(
|
|
|
|
|
bool log_stats) {
|
2014-07-18 11:11:55 +00:00
|
|
|
VideoReceiverInfo info;
|
2016-06-22 00:46:15 -07:00
|
|
|
info.ssrc_groups = stream_params_.ssrc_groups;
|
2014-07-18 11:11:55 +00:00
|
|
|
info.add_ssrc(config_.rtp.remote_ssrc);
|
|
|
|
|
webrtc::VideoReceiveStream::Stats stats = stream_->GetStats();
|
2015-12-18 16:01:11 +01:00
|
|
|
info.decoder_implementation_name = stats.decoder_implementation_name;
|
2016-11-14 02:28:16 -08:00
|
|
|
if (stats.current_payload_type != -1) {
|
2016-11-17 23:43:29 -08:00
|
|
|
info.codec_payload_type = rtc::Optional<int>(
|
|
|
|
|
stats.current_payload_type);
|
2016-11-14 02:28:16 -08:00
|
|
|
}
|
2015-01-22 09:39:59 +00:00
|
|
|
info.bytes_rcvd = stats.rtp_stats.transmitted.payload_bytes +
|
|
|
|
|
stats.rtp_stats.transmitted.header_bytes +
|
|
|
|
|
stats.rtp_stats.transmitted.padding_bytes;
|
|
|
|
|
info.packets_rcvd = stats.rtp_stats.transmitted.packets;
|
2015-04-22 14:52:45 +02:00
|
|
|
info.packets_lost = stats.rtcp_stats.cumulative_lost;
|
|
|
|
|
info.fraction_lost =
|
|
|
|
|
static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8);
|
2014-07-18 11:11:55 +00:00
|
|
|
|
|
|
|
|
info.framerate_rcvd = stats.network_frame_rate;
|
|
|
|
|
info.framerate_decoded = stats.decode_frame_rate;
|
|
|
|
|
info.framerate_output = stats.render_frame_rate;
|
2016-08-30 00:45:45 -07:00
|
|
|
info.frame_width = stats.width;
|
|
|
|
|
info.frame_height = stats.height;
|
2014-07-18 11:11:55 +00:00
|
|
|
|
2015-02-19 12:47:00 +00:00
|
|
|
{
|
2016-01-28 04:47:08 -08:00
|
|
|
rtc::CritScope frame_cs(&sink_lock_);
|
2015-02-19 12:47:00 +00:00
|
|
|
info.capture_start_ntp_time_ms = estimated_remote_start_ntp_time_ms_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-25 10:42:16 +00:00
|
|
|
info.decode_ms = stats.decode_ms;
|
|
|
|
|
info.max_decode_ms = stats.max_decode_ms;
|
|
|
|
|
info.current_delay_ms = stats.current_delay_ms;
|
|
|
|
|
info.target_delay_ms = stats.target_delay_ms;
|
|
|
|
|
info.jitter_buffer_ms = stats.jitter_buffer_ms;
|
|
|
|
|
info.min_playout_delay_ms = stats.min_playout_delay_ms;
|
|
|
|
|
info.render_delay_ms = stats.render_delay_ms;
|
2017-01-20 03:56:50 -08:00
|
|
|
info.frames_received = stats.frame_counts.key_frames +
|
|
|
|
|
stats.frame_counts.delta_frames;
|
2016-10-26 07:09:24 -07:00
|
|
|
info.frames_decoded = stats.frames_decoded;
|
2017-01-23 07:21:55 -08:00
|
|
|
info.frames_rendered = stats.frames_rendered;
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
info.qp_sum = stats.qp_sum;
|
2015-02-25 10:42:16 +00:00
|
|
|
|
2015-08-28 07:35:32 -07:00
|
|
|
info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type);
|
|
|
|
|
|
2015-02-19 12:47:00 +00:00
|
|
|
info.firs_sent = stats.rtcp_packet_type_counts.fir_packets;
|
|
|
|
|
info.plis_sent = stats.rtcp_packet_type_counts.pli_packets;
|
|
|
|
|
info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets;
|
2014-07-18 11:11:55 +00:00
|
|
|
|
2016-08-11 08:41:18 -07:00
|
|
|
if (log_stats)
|
|
|
|
|
LOG(LS_INFO) << stats.ToString(rtc::TimeMillis());
|
|
|
|
|
|
2014-07-18 11:11:55 +00:00
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings()
|
2016-12-19 09:41:04 -08:00
|
|
|
: flexfec_payload_type(-1), rtx_payload_type(-1) {}
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2014-11-07 10:54:43 +00:00
|
|
|
bool WebRtcVideoChannel2::VideoCodecSettings::operator==(
|
|
|
|
|
const WebRtcVideoChannel2::VideoCodecSettings& other) const {
|
2016-11-22 02:16:47 -08:00
|
|
|
return codec == other.codec && ulpfec == other.ulpfec &&
|
2016-12-19 09:41:04 -08:00
|
|
|
flexfec_payload_type == other.flexfec_payload_type &&
|
|
|
|
|
rtx_payload_type == other.rtx_payload_type;
|
2014-11-07 10:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-22 18:41:14 +02:00
|
|
|
bool WebRtcVideoChannel2::VideoCodecSettings::operator!=(
|
|
|
|
|
const WebRtcVideoChannel2::VideoCodecSettings& other) const {
|
|
|
|
|
return !(*this == other);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
std::vector<WebRtcVideoChannel2::VideoCodecSettings>
|
|
|
|
|
WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(!codecs.empty());
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
std::vector<VideoCodecSettings> video_codecs;
|
|
|
|
|
std::map<int, bool> payload_used;
|
2014-06-13 11:47:28 +00:00
|
|
|
std::map<int, VideoCodec::CodecType> payload_codec_type;
|
2015-02-23 21:28:22 +00:00
|
|
|
// |rtx_mapping| maps video payload type to rtx payload type.
|
|
|
|
|
std::map<int, int> rtx_mapping;
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2016-10-04 23:28:39 -07:00
|
|
|
webrtc::UlpfecConfig ulpfec_config;
|
2016-11-22 02:16:47 -08:00
|
|
|
int flexfec_payload_type = -1;
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
for (size_t i = 0; i < codecs.size(); ++i) {
|
|
|
|
|
const VideoCodec& in_codec = codecs[i];
|
|
|
|
|
int payload_type = in_codec.id;
|
|
|
|
|
|
|
|
|
|
if (payload_used[payload_type]) {
|
|
|
|
|
LOG(LS_ERROR) << "Payload type already registered: "
|
|
|
|
|
<< in_codec.ToString();
|
|
|
|
|
return std::vector<VideoCodecSettings>();
|
|
|
|
|
}
|
|
|
|
|
payload_used[payload_type] = true;
|
2014-06-13 11:47:28 +00:00
|
|
|
payload_codec_type[payload_type] = in_codec.GetCodecType();
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
switch (in_codec.GetCodecType()) {
|
|
|
|
|
case VideoCodec::CODEC_RED: {
|
|
|
|
|
// RED payload type, should not have duplicates.
|
2016-11-22 02:16:47 -08:00
|
|
|
RTC_DCHECK_EQ(-1, ulpfec_config.red_payload_type);
|
2016-10-04 23:28:39 -07:00
|
|
|
ulpfec_config.red_payload_type = in_codec.id;
|
2014-05-13 11:07:01 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case VideoCodec::CODEC_ULPFEC: {
|
|
|
|
|
// ULPFEC payload type, should not have duplicates.
|
2016-11-22 02:16:47 -08:00
|
|
|
RTC_DCHECK_EQ(-1, ulpfec_config.ulpfec_payload_type);
|
2016-10-04 23:28:39 -07:00
|
|
|
ulpfec_config.ulpfec_payload_type = in_codec.id;
|
2014-05-13 11:07:01 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 03:03:41 -08:00
|
|
|
case VideoCodec::CODEC_FLEXFEC: {
|
2016-11-22 02:16:47 -08:00
|
|
|
// FlexFEC payload type, should not have duplicates.
|
|
|
|
|
RTC_DCHECK_EQ(-1, flexfec_payload_type);
|
|
|
|
|
flexfec_payload_type = in_codec.id;
|
2016-11-07 03:03:41 -08:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
case VideoCodec::CODEC_RTX: {
|
|
|
|
|
int associated_payload_type;
|
|
|
|
|
if (!in_codec.GetParam(kCodecParamAssociatedPayloadType,
|
2015-02-17 20:36:28 +00:00
|
|
|
&associated_payload_type) ||
|
|
|
|
|
!IsValidRtpPayloadType(associated_payload_type)) {
|
|
|
|
|
LOG(LS_ERROR)
|
|
|
|
|
<< "RTX codec with invalid or no associated payload type: "
|
|
|
|
|
<< in_codec.ToString();
|
2014-05-13 11:07:01 +00:00
|
|
|
return std::vector<VideoCodecSettings>();
|
|
|
|
|
}
|
|
|
|
|
rtx_mapping[associated_payload_type] = in_codec.id;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case VideoCodec::CODEC_VIDEO:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
video_codecs.push_back(VideoCodecSettings());
|
|
|
|
|
video_codecs.back().codec = in_codec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// One of these codecs should have been a video codec. Only having FEC
|
|
|
|
|
// parameters into this code is a logic error.
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(!video_codecs.empty());
|
2014-05-13 11:07:01 +00:00
|
|
|
|
2014-06-13 11:47:28 +00:00
|
|
|
for (std::map<int, int>::const_iterator it = rtx_mapping.begin();
|
|
|
|
|
it != rtx_mapping.end();
|
|
|
|
|
++it) {
|
|
|
|
|
if (!payload_used[it->first]) {
|
|
|
|
|
LOG(LS_ERROR) << "RTX mapped to payload not in codec list.";
|
|
|
|
|
return std::vector<VideoCodecSettings>();
|
|
|
|
|
}
|
2015-04-21 20:24:50 +08:00
|
|
|
if (payload_codec_type[it->first] != VideoCodec::CODEC_VIDEO &&
|
|
|
|
|
payload_codec_type[it->first] != VideoCodec::CODEC_RED) {
|
|
|
|
|
LOG(LS_ERROR) << "RTX not mapped to regular video codec or RED codec.";
|
2014-06-13 11:47:28 +00:00
|
|
|
return std::vector<VideoCodecSettings>();
|
|
|
|
|
}
|
2015-04-21 20:24:50 +08:00
|
|
|
|
2016-10-04 23:28:39 -07:00
|
|
|
if (it->first == ulpfec_config.red_payload_type) {
|
|
|
|
|
ulpfec_config.red_rtx_payload_type = it->second;
|
2015-04-21 20:24:50 +08:00
|
|
|
}
|
2014-06-13 11:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:07:01 +00:00
|
|
|
for (size_t i = 0; i < video_codecs.size(); ++i) {
|
2016-10-04 23:28:39 -07:00
|
|
|
video_codecs[i].ulpfec = ulpfec_config;
|
2016-12-19 09:41:04 -08:00
|
|
|
video_codecs[i].flexfec_payload_type = flexfec_payload_type;
|
2015-04-21 20:24:50 +08:00
|
|
|
if (rtx_mapping[video_codecs[i].codec.id] != 0 &&
|
|
|
|
|
rtx_mapping[video_codecs[i].codec.id] !=
|
2016-10-04 23:28:39 -07:00
|
|
|
ulpfec_config.red_payload_type) {
|
2014-05-13 11:07:01 +00:00
|
|
|
video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return video_codecs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|