(Auto)update libjingle 78106439-> 78193292

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7482 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
buildbot@webrtc.org 2014-10-21 19:29:16 +00:00
parent def1e97ed2
commit 1288cbb704
3 changed files with 62 additions and 62 deletions

View File

@ -66,6 +66,18 @@
namespace { namespace {
cricket::VideoFormat CreateVideoFormat(int width, int height, int framerate) {
return cricket::VideoFormat(
width,
height,
cricket::VideoFormat::FpsToInterval(framerate),
cricket::FOURCC_ANY);
}
cricket::VideoFormat VideoFormatFromCodec(const cricket::VideoCodec& codec) {
return CreateVideoFormat(codec.width, codec.height, codec.framerate);
}
template <class T> template <class T>
bool Changed(cricket::Settable<T> proposed, bool Changed(cricket::Settable<T> proposed,
cricket::Settable<T> original) { cricket::Settable<T> original) {
@ -172,10 +184,12 @@ static bool IsRembEnabled(const VideoCodec& codec) {
} }
struct FlushBlackFrameData : public rtc::MessageData { struct FlushBlackFrameData : public rtc::MessageData {
FlushBlackFrameData(uint32 s, int64 t) : ssrc(s), timestamp(t) { FlushBlackFrameData(uint32 s, int64 t, int i)
: ssrc(s), timestamp(t), interval(i) {
} }
uint32 ssrc; uint32 ssrc;
int64 timestamp; int64 timestamp;
int interval;
}; };
class WebRtcRenderAdapter : public webrtc::ExternalRenderer { class WebRtcRenderAdapter : public webrtc::ExternalRenderer {
@ -602,7 +616,6 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
video_capturer_(NULL), video_capturer_(NULL),
encoder_observer_(channel_id), encoder_observer_(channel_id),
external_capture_(external_capture), external_capture_(external_capture),
interval_(0),
cpu_monitor_(cpu_monitor), cpu_monitor_(cpu_monitor),
old_adaptation_changes_(0) { old_adaptation_changes_(0) {
} }
@ -625,20 +638,11 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
} }
void set_video_format(const VideoFormat& video_format) { void set_video_format(const VideoFormat& video_format) {
video_format_ = video_format; video_format_ = video_format;
if (video_format_ != cricket::VideoFormat()) {
interval_ = video_format_.interval;
}
CoordinatedVideoAdapter* adapter = video_adapter(); CoordinatedVideoAdapter* adapter = video_adapter();
if (adapter) { if (adapter) {
adapter->OnOutputFormatRequest(video_format_); adapter->OnOutputFormatRequest(video_format_);
} }
} }
void set_interval(int64 interval) {
if (video_format() == cricket::VideoFormat()) {
interval_ = interval;
}
}
int64 interval() { return interval_; }
int CurrentAdaptReason() const { int CurrentAdaptReason() const {
if (!video_adapter()) { if (!video_adapter()) {
@ -657,11 +661,8 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
void set_stream_params(const StreamParams& sp) { void set_stream_params(const StreamParams& sp) {
stream_params_.reset(new StreamParams(sp)); stream_params_.reset(new StreamParams(sp));
} }
void ClearStreamParams() { stream_params_.reset(); } bool IsActive() { return stream_params() != NULL; }
bool has_ssrc(uint32 local_ssrc) const { void Deactivate() { stream_params_.reset(); }
return !stream_params_ ? false :
stream_params_->has_ssrc(local_ssrc);
}
WebRtcLocalStreamInfo* local_stream_info() { WebRtcLocalStreamInfo* local_stream_info() {
return &local_stream_info_; return &local_stream_info_;
} }
@ -839,8 +840,6 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
WebRtcLocalStreamInfo local_stream_info_; WebRtcLocalStreamInfo local_stream_info_;
int64 interval_;
rtc::CpuMonitor* cpu_monitor_; rtc::CpuMonitor* cpu_monitor_;
rtc::scoped_ptr<WebRtcOveruseObserver> overuse_observer_; rtc::scoped_ptr<WebRtcOveruseObserver> overuse_observer_;
@ -1103,11 +1102,8 @@ bool WebRtcVideoEngine::SetDefaultCodec(const VideoCodec& codec) {
} }
ASSERT(!video_codecs_.empty()); ASSERT(!video_codecs_.empty());
default_codec_format_ = VideoFormat( default_codec_format_ = VideoFormatFromCodec(video_codecs_[0]);
video_codecs_[0].width,
video_codecs_[0].height,
VideoFormat::FpsToInterval(video_codecs_[0].framerate),
FOURCC_ANY);
return true; return true;
} }
@ -1774,15 +1770,15 @@ bool WebRtcVideoMediaChannel::MaybeRegisterExternalEncoder(
const webrtc::VideoCodec& codec) { const webrtc::VideoCodec& codec) {
// Codec type not supported or encoder already registered, so // Codec type not supported or encoder already registered, so
// nothing to do. // nothing to do.
if (!engine()->IsExternalEncoderCodecType(codec.codecType) if (!engine()->IsExternalEncoderCodecType(codec.codecType) ||
|| send_channel->IsEncoderRegistered(codec.plType)) { send_channel->IsEncoderRegistered(codec.plType)) {
return true; return true;
} }
webrtc::VideoEncoder* encoder = webrtc::VideoEncoder* encoder =
engine()->CreateExternalEncoder(codec.codecType); engine()->CreateExternalEncoder(codec.codecType);
if (!encoder) { if (!encoder) {
// No encoder factor, so nothing to do. // No external encoder created, so nothing to do.
return true; return true;
} }
@ -1897,7 +1893,7 @@ bool WebRtcVideoMediaChannel::AddSendStream(const StreamParams& sp) {
// If the default channel is already used for sending create a new channel // If the default channel is already used for sending create a new channel
// otherwise use the default channel for sending. // otherwise use the default channel for sending.
int channel_id = kChannelIdUnset; int channel_id = kChannelIdUnset;
if (!DefaultSendChannelInUse()) { if (!DefaultSendChannelIsActive()) {
channel_id = default_channel_id_; channel_id = default_channel_id_;
} else { } else {
if (!CreateChannel(ssrc_key, MD_SEND, &channel_id)) { if (!CreateChannel(ssrc_key, MD_SEND, &channel_id)) {
@ -1955,9 +1951,9 @@ bool WebRtcVideoMediaChannel::RemoveSendStream(uint32 ssrc) {
} }
WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrcKey(ssrc_key); WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrcKey(ssrc_key);
int channel_id = send_channel->channel_id(); int channel_id = send_channel->channel_id();
if (IsDefaultChannelId(channel_id) && !send_channel->stream_params()) { if (IsDefaultChannelId(channel_id) && !send_channel->IsActive()) {
// Default channel will still exist. However, if stream_params() is NULL // Default channel will still exist. However, there is no stream
// there is no stream to remove. // to remove.
return false; return false;
} }
if (sending_) { if (sending_) {
@ -1979,7 +1975,7 @@ bool WebRtcVideoMediaChannel::RemoveSendStream(uint32 ssrc) {
// The receive channels depend on the default channel, recycle it instead. // The receive channels depend on the default channel, recycle it instead.
if (IsDefaultChannelId(channel_id)) { if (IsDefaultChannelId(channel_id)) {
SetCapturer(GetDefaultSendChannelSsrc(), NULL); SetCapturer(GetDefaultSendChannelSsrc(), NULL);
send_channel->ClearStreamParams(); send_channel->Deactivate();
} else { } else {
return DeleteSendChannel(ssrc_key); return DeleteSendChannel(ssrc_key);
} }
@ -1995,7 +1991,7 @@ bool WebRtcVideoMediaChannel::AddRecvStream(const StreamParams& sp) {
// TODO(zhurunz) Remove this once BWE works properly across different send // TODO(zhurunz) Remove this once BWE works properly across different send
// and receive channels. // and receive channels.
// Reuse default channel for recv stream in 1:1 call. // Reuse default channel for recv stream in 1:1 call.
if (!InConferenceMode() && first_receive_ssrc_ == kSsrcUnset) { if (!ConferenceModeIsEnabled() && first_receive_ssrc_ == kSsrcUnset) {
LOG(LS_INFO) << "Recv stream " << sp.first_ssrc() LOG(LS_INFO) << "Recv stream " << sp.first_ssrc()
<< " reuse default channel #" << " reuse default channel #"
<< default_channel_id_; << default_channel_id_;
@ -2211,11 +2207,11 @@ bool WebRtcVideoMediaChannel::SendIntraFrame() {
bool WebRtcVideoMediaChannel::HasReadySendChannels() { bool WebRtcVideoMediaChannel::HasReadySendChannels() {
return !send_channels_.empty() && return !send_channels_.empty() &&
((send_channels_.size() > 1) || DefaultSendChannelInUse()); ((send_channels_.size() > 1) || DefaultSendChannelIsActive());
} }
bool WebRtcVideoMediaChannel::DefaultSendChannelInUse() { bool WebRtcVideoMediaChannel::DefaultSendChannelIsActive() {
return GetDefaultSendChannel() && GetDefaultSendChannel()->stream_params(); return GetDefaultSendChannel() && GetDefaultSendChannel()->IsActive();
} }
bool WebRtcVideoMediaChannel::GetSendChannelSsrcKey(uint32 local_ssrc, bool WebRtcVideoMediaChannel::GetSendChannelSsrcKey(uint32 local_ssrc,
@ -2240,7 +2236,8 @@ bool WebRtcVideoMediaChannel::GetSendChannelSsrcKey(uint32 local_ssrc,
for (SendChannelMap::iterator iter = send_channels_.begin(); for (SendChannelMap::iterator iter = send_channels_.begin();
iter != send_channels_.end(); ++iter) { iter != send_channels_.end(); ++iter) {
WebRtcVideoChannelSendInfo* send_channel = iter->second; WebRtcVideoChannelSendInfo* send_channel = iter->second;
if (send_channel->has_ssrc(local_ssrc)) { if (send_channel->stream_params() != NULL &&
send_channel->stream_params()->has_ssrc(local_ssrc)) {
*ssrc_key = iter->first; *ssrc_key = iter->first;
return true; return true;
} }
@ -2284,7 +2281,7 @@ bool WebRtcVideoMediaChannel::CreateSendChannelSsrcKey(uint32 local_ssrc,
// this point a duplicate SSRC has been detected. // this point a duplicate SSRC has been detected.
return false; return false;
} }
if (!DefaultSendChannelInUse()) { if (!DefaultSendChannelIsActive()) {
// |ssrc_key| should be kDefaultChannelSsrcKey here as the default // |ssrc_key| should be kDefaultChannelSsrcKey here as the default
// channel should be re-used whenever it is not used. // channel should be re-used whenever it is not used.
*ssrc_key = kDefaultChannelSsrcKey; *ssrc_key = kDefaultChannelSsrcKey;
@ -2310,7 +2307,7 @@ int WebRtcVideoMediaChannel::GetSendChannelNum(VideoCapturer* capturer) {
} }
uint32 WebRtcVideoMediaChannel::GetDefaultSendChannelSsrc() { uint32 WebRtcVideoMediaChannel::GetDefaultSendChannelSsrc() {
if (!DefaultSendChannelInUse()) { if (!DefaultSendChannelIsActive()) {
return 0; return 0;
} }
return GetDefaultSendChannel()->stream_params()->first_ssrc(); return GetDefaultSendChannel()->stream_params()->first_ssrc();
@ -2418,8 +2415,7 @@ bool WebRtcVideoMediaChannel::GetStats(const StatsOptions& options,
WebRtcVideoChannelSendInfo* send_channel = iter->second; WebRtcVideoChannelSendInfo* send_channel = iter->second;
const int channel_id = send_channel->channel_id(); const int channel_id = send_channel->channel_id();
VideoSenderInfo sinfo; VideoSenderInfo sinfo;
const StreamParams* send_params = send_channel->stream_params(); if (!send_channel->IsActive()) {
if (!send_params) {
// This should only happen if the default vie channel is not in use. // This should only happen if the default vie channel is not in use.
// This can happen if no streams have ever been added or the stream // This can happen if no streams have ever been added or the stream
// corresponding to the default channel has been removed. Note that // corresponding to the default channel has been removed. Note that
@ -2439,6 +2435,7 @@ bool WebRtcVideoMediaChannel::GetStats(const StatsOptions& options,
WebRtcLocalStreamInfo* channel_stream_info = WebRtcLocalStreamInfo* channel_stream_info =
send_channel->local_stream_info(); send_channel->local_stream_info();
const StreamParams* send_params = send_channel->stream_params();
for (size_t i = 0; i < send_params->ssrcs.size(); ++i) { for (size_t i = 0; i < send_params->ssrcs.size(); ++i) {
sinfo.add_ssrc(send_params->ssrcs[i]); sinfo.add_ssrc(send_params->ssrcs[i]);
} }
@ -2723,7 +2720,8 @@ bool WebRtcVideoMediaChannel::SetCapturer(uint32 ssrc,
} }
const int64 timestamp = send_channel->local_stream_info()->time_stamp(); const int64 timestamp = send_channel->local_stream_info()->time_stamp();
if (send_codec_) { if (send_codec_) {
QueueBlackFrame(ssrc, timestamp, send_codec_->maxFramerate); QueueBlackFrame(ssrc, timestamp,
VideoFormat::FpsToInterval(send_codec_->maxFramerate));
} }
return true; return true;
} }
@ -2745,7 +2743,7 @@ void WebRtcVideoMediaChannel::OnPacketReceived(
int processing_channel_id = GetRecvChannelId(ssrc); int processing_channel_id = GetRecvChannelId(ssrc);
if (processing_channel_id == kChannelIdUnset) { if (processing_channel_id == kChannelIdUnset) {
// Allocate an unsignalled recv channel for processing in conference mode. // Allocate an unsignalled recv channel for processing in conference mode.
if (!InConferenceMode()) { if (!ConferenceModeIsEnabled()) {
// If we can't find or allocate one, use the default. // If we can't find or allocate one, use the default.
processing_channel_id = default_channel_id_; processing_channel_id = default_channel_id_;
} else if (!CreateUnsignalledRecvChannel(ssrc, &processing_channel_id)) { } else if (!CreateUnsignalledRecvChannel(ssrc, &processing_channel_id)) {
@ -3458,6 +3456,8 @@ bool WebRtcVideoMediaChannel::ConfigureSending(int channel_id,
LOG_RTCERR2(ConnectCaptureDevice, vie_capture, channel_id); LOG_RTCERR2(ConnectCaptureDevice, vie_capture, channel_id);
return false; return false;
} }
// Set up a new send channel.
rtc::scoped_ptr<WebRtcVideoChannelSendInfo> send_channel( rtc::scoped_ptr<WebRtcVideoChannelSendInfo> send_channel(
new WebRtcVideoChannelSendInfo(channel_id, vie_capture, new WebRtcVideoChannelSendInfo(channel_id, vie_capture,
external_capture, external_capture,
@ -3549,7 +3549,7 @@ bool WebRtcVideoMediaChannel::SetNackFec(int channel_id,
int fec_payload_type, int fec_payload_type,
bool nack_enabled) { bool nack_enabled) {
bool enable = (red_payload_type != -1 && fec_payload_type != -1 && bool enable = (red_payload_type != -1 && fec_payload_type != -1 &&
!InConferenceMode()); !ConferenceModeIsEnabled());
if (enable) { if (enable) {
if (engine_->vie()->rtp()->SetHybridNACKFECStatus( if (engine_->vie()->rtp()->SetHybridNACKFECStatus(
channel_id, nack_enabled, red_payload_type, fec_payload_type) != 0) { channel_id, nack_enabled, red_payload_type, fec_payload_type) != 0) {
@ -3659,8 +3659,6 @@ bool WebRtcVideoMediaChannel::SetSendCodec(
return false; return false;
} }
} }
send_channel->set_interval(
cricket::VideoFormat::FpsToInterval(target_codec.maxFramerate));
return true; return true;
} }
@ -3987,10 +3985,9 @@ void WebRtcVideoMediaChannel::SanitizeBitrates(
} }
void WebRtcVideoMediaChannel::OnMessage(rtc::Message* msg) { void WebRtcVideoMediaChannel::OnMessage(rtc::Message* msg) {
FlushBlackFrameData* black_frame_data = FlushBlackFrameData* data = static_cast<FlushBlackFrameData*>(msg->pdata);
static_cast<FlushBlackFrameData*>(msg->pdata); FlushBlackFrame(data->ssrc, data->timestamp, data->interval);
FlushBlackFrame(black_frame_data->ssrc, black_frame_data->timestamp); delete data;
delete black_frame_data;
} }
int WebRtcVideoMediaChannel::SendPacket(int channel, const void* data, int WebRtcVideoMediaChannel::SendPacket(int channel, const void* data,
@ -4007,19 +4004,18 @@ int WebRtcVideoMediaChannel::SendRTCPPacket(int channel,
} }
void WebRtcVideoMediaChannel::QueueBlackFrame(uint32 ssrc, int64 timestamp, void WebRtcVideoMediaChannel::QueueBlackFrame(uint32 ssrc, int64 timestamp,
int framerate) { int interval) {
if (timestamp) { if (timestamp) {
FlushBlackFrameData* black_frame_data = new FlushBlackFrameData( FlushBlackFrameData* black_frame_data = new FlushBlackFrameData(
ssrc, ssrc, timestamp, interval);
timestamp);
const int delay_ms = static_cast<int>( const int delay_ms = static_cast<int>(
2 * cricket::VideoFormat::FpsToInterval(framerate) * 2 * interval * rtc::kNumMillisecsPerSec / rtc::kNumNanosecsPerSec);
rtc::kNumMillisecsPerSec / rtc::kNumNanosecsPerSec);
worker_thread()->PostDelayed(delay_ms, this, 0, black_frame_data); worker_thread()->PostDelayed(delay_ms, this, 0, black_frame_data);
} }
} }
void WebRtcVideoMediaChannel::FlushBlackFrame(uint32 ssrc, int64 timestamp) { void WebRtcVideoMediaChannel::FlushBlackFrame(
uint32 ssrc, int64 timestamp, int interval) {
WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc); WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
if (!send_channel) { if (!send_channel) {
return; return;
@ -4041,7 +4037,7 @@ void WebRtcVideoMediaChannel::FlushBlackFrame(uint32 ssrc, int64 timestamp) {
WebRtcVideoFrame black_frame; WebRtcVideoFrame black_frame;
// Black frame is not screencast. // Black frame is not screencast.
const bool screencasting = false; const bool screencasting = false;
const int64 timestamp_delta = send_channel->interval(); const int64 timestamp_delta = interval;
if (!black_frame.InitToBlack(send_codec_->width, send_codec_->height, 1, 1, if (!black_frame.InitToBlack(send_codec_->width, send_codec_->height, 1, 1,
last_frame_elapsed_time + timestamp_delta, last_frame_elapsed_time + timestamp_delta,
last_frame_time_stamp + timestamp_delta) || last_frame_time_stamp + timestamp_delta) ||
@ -4094,7 +4090,7 @@ bool WebRtcVideoMediaChannel::SetHeaderExtension(ExtensionSetterFunction setter,
bool WebRtcVideoMediaChannel::SetPrimaryAndRtxSsrcs( bool WebRtcVideoMediaChannel::SetPrimaryAndRtxSsrcs(
int channel_id, int idx, uint32 primary_ssrc, int channel_id, int idx, uint32 primary_ssrc,
const StreamParams& send_params) { const StreamParams& sp) {
LOG(LS_INFO) << "Set primary ssrc " << primary_ssrc LOG(LS_INFO) << "Set primary ssrc " << primary_ssrc
<< " on channel " << channel_id << " idx " << idx; << " on channel " << channel_id << " idx " << idx;
if (engine()->vie()->rtp()->SetLocalSSRC( if (engine()->vie()->rtp()->SetLocalSSRC(
@ -4105,7 +4101,7 @@ bool WebRtcVideoMediaChannel::SetPrimaryAndRtxSsrcs(
} }
uint32 rtx_ssrc = 0; uint32 rtx_ssrc = 0;
if (send_params.GetFidSsrc(primary_ssrc, &rtx_ssrc)) { if (sp.GetFidSsrc(primary_ssrc, &rtx_ssrc)) {
LOG(LS_INFO) << "Set rtx ssrc " << rtx_ssrc LOG(LS_INFO) << "Set rtx ssrc " << rtx_ssrc
<< " on channel " << channel_id << " idx " << idx; << " on channel " << channel_id << " idx " << idx;
if (engine()->vie()->rtp()->SetLocalSSRC( if (engine()->vie()->rtp()->SetLocalSSRC(

View File

@ -316,6 +316,10 @@ class WebRtcVideoMediaChannel : public rtc::MessageHandler,
virtual int SendPacket(int channel, const void* data, int len) OVERRIDE; virtual int SendPacket(int channel, const void* data, int len) OVERRIDE;
virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE; virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE;
bool ConferenceModeIsEnabled() const {
return options_.conference_mode.GetWithDefaultIfUnset(false);
}
// Checks the current bitrate estimate and modifies the bitrates // Checks the current bitrate estimate and modifies the bitrates
// accordingly, including converting kAutoBandwidth to the correct defaults. // accordingly, including converting kAutoBandwidth to the correct defaults.
virtual void SanitizeBitrates( virtual void SanitizeBitrates(
@ -387,7 +391,7 @@ class WebRtcVideoMediaChannel : public rtc::MessageHandler,
bool SendIntraFrame(int channel_id); bool SendIntraFrame(int channel_id);
bool HasReadySendChannels(); bool HasReadySendChannels();
bool DefaultSendChannelInUse(); bool DefaultSendChannelIsActive();
// Returns the ssrc key corresponding to the provided local SSRC in // Returns the ssrc key corresponding to the provided local SSRC in
// |ssrc_key|. The return value is true upon success. If the local // |ssrc_key|. The return value is true upon success. If the local
@ -420,8 +424,8 @@ class WebRtcVideoMediaChannel : public rtc::MessageHandler,
bool RemoveCapturer(uint32 ssrc); bool RemoveCapturer(uint32 ssrc);
rtc::MessageQueue* worker_thread() { return engine_->worker_thread(); } rtc::MessageQueue* worker_thread() { return engine_->worker_thread(); }
void QueueBlackFrame(uint32 ssrc, int64 timestamp, int framerate); void QueueBlackFrame(uint32 ssrc, int64 timestamp, int interval);
void FlushBlackFrame(uint32 ssrc, int64 timestamp); void FlushBlackFrame(uint32 ssrc, int64 timestamp, int interval);
void SetNetworkTransmissionState(bool is_transmitting); void SetNetworkTransmissionState(bool is_transmitting);

View File

@ -1475,7 +1475,7 @@ TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidthOption) {
kMaxBandwidthKbps, kMinBandwidthKbps, kStartBandwidthKbps); kMaxBandwidthKbps, kMinBandwidthKbps, kStartBandwidthKbps);
// Set the start bitrate option. // Set the start bitrate option.
int kBoostedStartBandwidthKbps = 1000; unsigned int kBoostedStartBandwidthKbps = 1000;
ASSERT_NE(kStartBandwidthKbps, kBoostedStartBandwidthKbps); ASSERT_NE(kStartBandwidthKbps, kBoostedStartBandwidthKbps);
cricket::VideoOptions options; cricket::VideoOptions options;
options.video_start_bitrate.Set(kBoostedStartBandwidthKbps); options.video_start_bitrate.Set(kBoostedStartBandwidthKbps);