From 40b276ea7bc5dfd815c79b93b83bdc9ef24f2cc1 Mon Sep 17 00:00:00 2001 From: "pthatcher@webrtc.org" Date: Fri, 12 Dec 2014 02:44:30 +0000 Subject: [PATCH] Cleanup little things found when refactoring. R=juberti@google.com Review URL: https://webrtc-codereview.appspot.com/33519004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7880 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/app/webrtc/webrtcsession.cc | 1 + talk/media/base/fakemediaengine.h | 2 +- talk/media/base/mediachannel.h | 21 ++++----------------- talk/media/base/videocommon.h | 10 +++++++--- talk/media/webrtc/webrtcvideoengine.cc | 19 +++++++++++++++++++ talk/session/media/call.cc | 3 ++- talk/session/media/call.h | 1 - webrtc/base/sigslot.h | 1 + 8 files changed, 35 insertions(+), 23 deletions(-) diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc index f651af5c4f..683efac13f 100644 --- a/talk/app/webrtc/webrtcsession.cc +++ b/talk/app/webrtc/webrtcsession.cc @@ -48,6 +48,7 @@ #include "webrtc/base/logging.h" #include "webrtc/base/stringencode.h" #include "webrtc/base/stringutils.h" +#include "webrtc/p2p/base/portallocator.h" using cricket::ContentInfo; using cricket::ContentInfos; diff --git a/talk/media/base/fakemediaengine.h b/talk/media/base/fakemediaengine.h index ff6ae16d18..c5de3230ef 100644 --- a/talk/media/base/fakemediaengine.h +++ b/talk/media/base/fakemediaengine.h @@ -167,7 +167,7 @@ template class RtpHelper : public Base { } // TODO(perkj): This is to support legacy unit test that only check one // sending stream. - const uint32 send_ssrc() { + uint32 send_ssrc() const { if (send_streams_.empty()) return 0; return send_streams_[0].first_ssrc(); diff --git a/talk/media/base/mediachannel.h b/talk/media/base/mediachannel.h index 5e03ef91d3..cb50490c02 100644 --- a/talk/media/base/mediachannel.h +++ b/talk/media/base/mediachannel.h @@ -84,7 +84,7 @@ class Settable { return set_ ? val_ : default_value; } - virtual void Set(T val) { + void Set(T val) { set_ = true; val_ = val; } @@ -126,19 +126,6 @@ class Settable { T val_; }; -class SettablePercent : public Settable { - public: - virtual void Set(float val) { - if (val < 0) { - val = 0; - } - if (val > 1.0) { - val = 1.0; - } - Settable::Set(val); - } -}; - template static std::string ToStringIfSet(const char* key, const Settable& val) { std::string str; @@ -431,11 +418,11 @@ struct VideoOptions { // Use conference mode? Settable conference_mode; // Threshhold for process cpu adaptation. (Process limit) - SettablePercent process_adaptation_threshhold; + Settable process_adaptation_threshhold; // Low threshhold for cpu adaptation. (Adapt up) - SettablePercent system_low_adaptation_threshhold; + Settable system_low_adaptation_threshhold; // High threshhold for cpu adaptation. (Adapt down) - SettablePercent system_high_adaptation_threshhold; + Settable system_high_adaptation_threshhold; // Specify buffered mode latency in milliseconds. Settable buffered_mode_latency; // Set DSCP value for packet sent from video channel. diff --git a/talk/media/base/videocommon.h b/talk/media/base/videocommon.h index a175c131af..fc055800e6 100644 --- a/talk/media/base/videocommon.h +++ b/talk/media/base/videocommon.h @@ -129,11 +129,15 @@ enum FourCC { // 1 Auxiliary compressed YUV format set aside for capturer. FOURCC_H264 = FOURCC('H', '2', '6', '4'), - - // Match any fourcc. - FOURCC_ANY = 0xFFFFFFFF, }; +// Match any fourcc. + +// We move this out of the enum because using it in many places caused +// the compiler to get grumpy, presumably since the above enum is +// backed by an int. +static const uint32 FOURCC_ANY = 0xFFFFFFFF; + // Converts fourcc aliases into canonical ones. uint32 CanonicalFourCC(uint32 fourcc); diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index 139d508249..1785cc265a 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -87,6 +87,22 @@ cricket::VideoFormat VideoFormatFromVieCodec(const webrtc::VideoCodec& codec) { return CreateVideoFormat(codec.width, codec.height, codec.maxFramerate); } +template +void Clamp(cricket::Settable* box, T min, T max) { + T val; + if (!box->Get(&val)) { + return; + } + if (val < min) { + box->Set(min); + return; + } + if (val > max) { + box->Set(max); + return; + } +} + template bool Changed(cricket::Settable proposed, cricket::Settable original) { @@ -3080,6 +3096,9 @@ bool WebRtcVideoMediaChannel::SetOptions(const VideoOptions &options) { VideoOptions original = options_; options_.SetAll(options); + Clamp(&options_.system_low_adaptation_threshhold, 0.0f, 1.0f); + Clamp(&options_.system_high_adaptation_threshhold, 0.0f, 1.0f); + bool use_simulcast_adapter; if (options.use_simulcast_adapter.Get(&use_simulcast_adapter) && options.use_simulcast_adapter != original.use_simulcast_adapter) { diff --git a/talk/session/media/call.cc b/talk/session/media/call.cc index 7e59ac6a6c..784be9422c 100644 --- a/talk/session/media/call.cc +++ b/talk/session/media/call.cc @@ -482,7 +482,8 @@ cricket::VideoFormat ScreencastFormatFromFps(int fps) { // case, it can't be 0x0, or the CaptureManager will fail to use it. return cricket::VideoFormat( 1, 1, - cricket::VideoFormat::FpsToInterval(fps), cricket::FOURCC_ANY); + cricket::VideoFormat::FpsToInterval(fps), + cricket::FOURCC_ANY); } bool Call::StartScreencast(Session* session, diff --git a/talk/session/media/call.h b/talk/session/media/call.h index 5a2d49b3db..f9920436f4 100644 --- a/talk/session/media/call.h +++ b/talk/session/media/call.h @@ -76,7 +76,6 @@ class AudioSourceProxy: public AudioSourceContext, public sigslot::has_slots<> { void OnMediaStreamsUpdate(Call* call, cricket::Session*, const cricket::MediaStreams&, const cricket::MediaStreams&); - AudioSourceContext* audio_source_context_; Call* call_; }; diff --git a/webrtc/base/sigslot.h b/webrtc/base/sigslot.h index 990d2efb76..df26683a83 100644 --- a/webrtc/base/sigslot.h +++ b/webrtc/base/sigslot.h @@ -430,6 +430,7 @@ namespace sigslot { class _signal_base_interface { public: + virtual ~_signal_base_interface() {} virtual void slot_disconnect(has_slots_interface* pslot) = 0; virtual void slot_duplicate(const has_slots_interface* poldslot, has_slots_interface* pnewslot) = 0; };