diff --git a/api/array_view.h b/api/array_view.h index 4c1fc8650a..efc642d6fc 100644 --- a/api/array_view.h +++ b/api/array_view.h @@ -11,8 +11,8 @@ #ifndef API_ARRAY_VIEW_H_ #define API_ARRAY_VIEW_H_ -#include #include +#include #include #include "rtc_base/checks.h" diff --git a/api/audio/audio_frame.cc b/api/audio/audio_frame.cc index b477a17f22..75d30b0ba2 100644 --- a/api/audio/audio_frame.cc +++ b/api/audio/audio_frame.cc @@ -66,7 +66,8 @@ void AudioFrame::UpdateFrame(uint32_t timestamp, } void AudioFrame::CopyFrom(const AudioFrame& src) { - if (this == &src) return; + if (this == &src) + return; timestamp_ = src.timestamp_; elapsed_time_ms_ = src.elapsed_time_ms_; @@ -116,7 +117,9 @@ void AudioFrame::Mute() { muted_ = true; } -bool AudioFrame::muted() const { return muted_; } +bool AudioFrame::muted() const { + return muted_; +} // static const int16_t* AudioFrame::empty_data() { diff --git a/api/audio/audio_frame.h b/api/audio/audio_frame.h index 39840e5e6a..d80868acc4 100644 --- a/api/audio/audio_frame.h +++ b/api/audio/audio_frame.h @@ -43,11 +43,7 @@ class AudioFrame { kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t), }; - enum VADActivity { - kVadActive = 0, - kVadPassive = 1, - kVadUnknown = 2 - }; + enum VADActivity { kVadActive = 0, kVadPassive = 1, kVadUnknown = 2 }; enum SpeechType { kNormalSpeech = 0, kPLC = 1, @@ -66,9 +62,12 @@ class AudioFrame { // ResetWithoutMuting() to skip this wasteful zeroing. void ResetWithoutMuting(); - void UpdateFrame(uint32_t timestamp, const int16_t* data, - size_t samples_per_channel, int sample_rate_hz, - SpeechType speech_type, VADActivity vad_activity, + void UpdateFrame(uint32_t timestamp, + const int16_t* data, + size_t samples_per_channel, + int sample_rate_hz, + SpeechType speech_type, + VADActivity vad_activity, size_t num_channels = 1); void CopyFrom(const AudioFrame& src); diff --git a/api/audio/test/audio_frame_unittest.cc b/api/audio/test/audio_frame_unittest.cc index 2a41e76f2c..b969d90a4c 100644 --- a/api/audio/test/audio_frame_unittest.cc +++ b/api/audio/test/audio_frame_unittest.cc @@ -87,9 +87,8 @@ TEST(AudioFrameTest, CopyFrom) { AudioFrame frame2; int16_t samples[kNumChannels * kSamplesPerChannel] = {17}; - frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, - kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, - kNumChannels); + frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz, + AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels); frame1.CopyFrom(frame2); EXPECT_EQ(frame2.timestamp_, frame1.timestamp_); diff --git a/api/audio_codecs/audio_encoder.h b/api/audio_codecs/audio_encoder.h index 7ad9ba4d09..d277a194b5 100644 --- a/api/audio_codecs/audio_encoder.h +++ b/api/audio_codecs/audio_encoder.h @@ -220,9 +220,8 @@ class AudioEncoder { // Provides target audio bitrate and corresponding probing interval of // the bandwidth estimator to this encoder to allow it to adapt. - virtual void OnReceivedUplinkBandwidth( - int target_audio_bitrate_bps, - rtc::Optional bwe_period_ms); + virtual void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps, + rtc::Optional bwe_period_ms); // Provides RTT to this encoder to allow it to adapt. virtual void OnReceivedRtt(int rtt_ms); diff --git a/api/audio_options.h b/api/audio_options.h index 5d698424eb..28f03b6164 100644 --- a/api/audio_options.h +++ b/api/audio_options.h @@ -112,7 +112,7 @@ struct AudioOptions { ost << ToStringIfSet("residual_echo_detector", residual_echo_detector); ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov); ost << ToStringIfSet("tx_agc_digital_compression_gain", - tx_agc_digital_compression_gain); + tx_agc_digital_compression_gain); ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe); ost << ToStringIfSet("audio_network_adaptor", audio_network_adaptor); diff --git a/api/candidate.h b/api/candidate.h index a1f45c215e..6e0547b5e2 100644 --- a/api/candidate.h +++ b/api/candidate.h @@ -46,14 +46,14 @@ class Candidate { Candidate(const Candidate&); ~Candidate(); - const std::string & id() const { return id_; } - void set_id(const std::string & id) { id_ = id; } + const std::string& id() const { return id_; } + void set_id(const std::string& id) { id_ = id; } int component() const { return component_; } void set_component(int component) { component_ = component; } - const std::string & protocol() const { return protocol_; } - void set_protocol(const std::string & protocol) { protocol_ = protocol; } + const std::string& protocol() const { return protocol_; } + void set_protocol(const std::string& protocol) { protocol_ = protocol; } // The protocol used to talk to relay. const std::string& relay_protocol() const { return relay_protocol_; } @@ -61,10 +61,8 @@ class Candidate { relay_protocol_ = protocol; } - const rtc::SocketAddress & address() const { return address_; } - void set_address(const rtc::SocketAddress & address) { - address_ = address; - } + const rtc::SocketAddress& address() const { return address_; } + void set_address(const rtc::SocketAddress& address) { address_ = address; } uint32_t priority() const { return priority_; } void set_priority(const uint32_t priority) { priority_ = priority; } @@ -91,17 +89,17 @@ class Candidate { } // TODO(honghaiz): Change to usernameFragment or ufrag. - const std::string & username() const { return username_; } - void set_username(const std::string & username) { username_ = username; } + const std::string& username() const { return username_; } + void set_username(const std::string& username) { username_ = username; } - const std::string & password() const { return password_; } - void set_password(const std::string & password) { password_ = password; } + const std::string& password() const { return password_; } + void set_password(const std::string& password) { password_ = password; } - const std::string & type() const { return type_; } - void set_type(const std::string & type) { type_ = type; } + const std::string& type() const { return type_; } + void set_type(const std::string& type) { type_ = type; } - const std::string & network_name() const { return network_name_; } - void set_network_name(const std::string & network_name) { + const std::string& network_name() const { return network_name_; } + void set_network_name(const std::string& network_name) { network_name_ = network_name; } @@ -127,24 +125,17 @@ class Candidate { uint16_t network_id() const { return network_id_; } void set_network_id(uint16_t network_id) { network_id_ = network_id; } - const std::string& foundation() const { - return foundation_; - } + const std::string& foundation() const { return foundation_; } void set_foundation(const std::string& foundation) { foundation_ = foundation; } - const rtc::SocketAddress & related_address() const { - return related_address_; - } - void set_related_address( - const rtc::SocketAddress & related_address) { + const rtc::SocketAddress& related_address() const { return related_address_; } + void set_related_address(const rtc::SocketAddress& related_address) { related_address_ = related_address; } const std::string& tcptype() const { return tcptype_; } - void set_tcptype(const std::string& tcptype) { - tcptype_ = tcptype; - } + void set_tcptype(const std::string& tcptype) { tcptype_ = tcptype; } // The name of the transport channel of this candidate. // TODO(phoglund): remove. @@ -164,13 +155,9 @@ class Candidate { // given one when looking for a matching candidate to remove. bool MatchesForRemoval(const Candidate& c) const; - std::string ToString() const { - return ToStringInternal(false); - } + std::string ToString() const { return ToStringInternal(false); } - std::string ToSensitiveString() const { - return ToStringInternal(true); - } + std::string ToSensitiveString() const { return ToStringInternal(true); } uint32_t GetPriority(uint32_t type_preference, int network_adapter_preference, diff --git a/api/datachannelinterface.h b/api/datachannelinterface.h index afeb17377f..85e6fa67f9 100644 --- a/api/datachannelinterface.h +++ b/api/datachannelinterface.h @@ -61,14 +61,10 @@ struct DataChannelInit { // as binary or text. struct DataBuffer { DataBuffer(const rtc::CopyOnWriteBuffer& data, bool binary) - : data(data), - binary(binary) { - } + : data(data), binary(binary) {} // For convenience for unit tests. explicit DataBuffer(const std::string& text) - : data(text.data(), text.length()), - binary(false) { - } + : data(text.data(), text.length()), binary(false) {} size_t size() const { return data.size(); } rtc::CopyOnWriteBuffer data; diff --git a/api/dtmfsenderinterface.h b/api/dtmfsenderinterface.h index 8f0ab71206..e61b8edd90 100644 --- a/api/dtmfsenderinterface.h +++ b/api/dtmfsenderinterface.h @@ -67,7 +67,8 @@ class DtmfSenderInterface : public rtc::RefCountInterface { // If InsertDtmf is called on the same object while an existing task for this // object to generate DTMF is still running, the previous task is canceled. // Returns true on success and false on failure. - virtual bool InsertDtmf(const std::string& tones, int duration, + virtual bool InsertDtmf(const std::string& tones, + int duration, int inter_tone_gap) = 0; // Returns the track given as argument to the constructor. Only exists for diff --git a/api/fakemetricsobserver.cc b/api/fakemetricsobserver.cc index beb30c2c18..cd8de392a3 100644 --- a/api/fakemetricsobserver.cc +++ b/api/fakemetricsobserver.cc @@ -36,7 +36,7 @@ void FakeMetricsObserver::IncrementEnumCounter( } void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type, - int value) { + int value) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK_EQ(histogram_samples_[type], 0); histogram_samples_[type] = value; diff --git a/api/fakemetricsobserver.h b/api/fakemetricsobserver.h index 3adc5a6547..1f5b7043b2 100644 --- a/api/fakemetricsobserver.h +++ b/api/fakemetricsobserver.h @@ -28,8 +28,7 @@ class FakeMetricsObserver : public MetricsObserverInterface { void IncrementEnumCounter(PeerConnectionEnumCounterType, int counter, int counter_max) override; - void AddHistogramSample(PeerConnectionMetricsName type, - int value) override; + void AddHistogramSample(PeerConnectionMetricsName type, int value) override; // Accessors to be used by the tests. int GetEnumCounter(PeerConnectionEnumCounterType type, int counter) const; diff --git a/api/jsep.h b/api/jsep.h index 8fd2dacf65..011849073a 100644 --- a/api/jsep.h +++ b/api/jsep.h @@ -205,9 +205,7 @@ class CreateSessionDescriptionObserver : public rtc::RefCountInterface { // is deprecated; in order to let clients remove the old version, it has a // default implementation. If both versions are unimplemented, the // result will be a runtime error (stack overflow). This is intentional. - virtual void OnFailure(RTCError error) { - OnFailure(error.message()); - } + virtual void OnFailure(RTCError error) { OnFailure(error.message()); } virtual void OnFailure(const std::string& error) { OnFailure(RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error))); } diff --git a/api/jsepicecandidate.h b/api/jsepicecandidate.h index dae6121ead..4801a040b6 100644 --- a/api/jsepicecandidate.h +++ b/api/jsepicecandidate.h @@ -28,7 +28,8 @@ namespace webrtc { class JsepIceCandidate : public IceCandidateInterface { public: JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index); - JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index, + JsepIceCandidate(const std::string& sdp_mid, + int sdp_mline_index, const cricket::Candidate& candidate); ~JsepIceCandidate(); // |err| may be null. @@ -39,9 +40,7 @@ class JsepIceCandidate : public IceCandidateInterface { virtual std::string sdp_mid() const { return sdp_mid_; } virtual int sdp_mline_index() const { return sdp_mline_index_; } - virtual const cricket::Candidate& candidate() const { - return candidate_; - } + virtual const cricket::Candidate& candidate() const { return candidate_; } virtual std::string server_url() const { return candidate_.url(); } @@ -64,9 +63,7 @@ class JsepCandidateCollection : public IceCandidateCollection { JsepCandidateCollection(JsepCandidateCollection&& o) : candidates_(std::move(o.candidates_)) {} ~JsepCandidateCollection(); - virtual size_t count() const { - return candidates_.size(); - } + virtual size_t count() const { return candidates_.size(); } virtual bool HasCandidate(const IceCandidateInterface* candidate) const; // Adds and takes ownership of the JsepIceCandidate. // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is diff --git a/api/jsepsessiondescription.h b/api/jsepsessiondescription.h index 70bb27710a..d70829e0fb 100644 --- a/api/jsepsessiondescription.h +++ b/api/jsepsessiondescription.h @@ -41,8 +41,8 @@ class JsepSessionDescription : public SessionDescriptionInterface { // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is // more clear. bool Initialize(cricket::SessionDescription* description, - const std::string& session_id, - const std::string& session_version); + const std::string& session_id, + const std::string& session_version); virtual cricket::SessionDescription* description() { return description_.get(); @@ -50,12 +50,8 @@ class JsepSessionDescription : public SessionDescriptionInterface { virtual const cricket::SessionDescription* description() const { return description_.get(); } - virtual std::string session_id() const { - return session_id_; - } - virtual std::string session_version() const { - return session_version_; - } + virtual std::string session_id() const { return session_id_; } + virtual std::string session_version() const { return session_version_; } virtual SdpType GetType() const { return type_; } virtual std::string type() const { return SdpTypeToString(type_); } // Allows changing the type. Used for testing. diff --git a/api/mediaconstraintsinterface.cc b/api/mediaconstraintsinterface.cc index 8358644407..50a26de627 100644 --- a/api/mediaconstraintsinterface.cc +++ b/api/mediaconstraintsinterface.cc @@ -89,8 +89,7 @@ const char MediaConstraintsInterface::kMaxFrameRate[] = "maxFrameRate"; const char MediaConstraintsInterface::kMinFrameRate[] = "minFrameRate"; // Audio constraints. -const char MediaConstraintsInterface::kEchoCancellation[] = - "echoCancellation"; +const char MediaConstraintsInterface::kEchoCancellation[] = "echoCancellation"; const char MediaConstraintsInterface::kGoogEchoCancellation[] = "googEchoCancellation"; const char MediaConstraintsInterface::kExtendedFilterEchoCancellation[] = @@ -107,8 +106,7 @@ const char MediaConstraintsInterface::kExperimentalNoiseSuppression[] = "googNoiseSuppression2"; const char MediaConstraintsInterface::kIntelligibilityEnhancer[] = "intelligibilityEnhancer"; -const char MediaConstraintsInterface::kHighpassFilter[] = - "googHighpassFilter"; +const char MediaConstraintsInterface::kHighpassFilter[] = "googHighpassFilter"; const char MediaConstraintsInterface::kTypingNoiseDetection[] = "googTypingNoiseDetection"; const char MediaConstraintsInterface::kAudioMirroring[] = "googAudioMirroring"; @@ -125,11 +123,9 @@ const char MediaConstraintsInterface::kOfferToReceiveVideo[] = "OfferToReceiveVideo"; const char MediaConstraintsInterface::kVoiceActivityDetection[] = "VoiceActivityDetection"; -const char MediaConstraintsInterface::kIceRestart[] = - "IceRestart"; +const char MediaConstraintsInterface::kIceRestart[] = "IceRestart"; // Google specific constraint for BUNDLE enable/disable. -const char MediaConstraintsInterface::kUseRtpMux[] = - "googUseRtpMUX"; +const char MediaConstraintsInterface::kUseRtpMux[] = "googUseRtpMUX"; // Below constraints should be used during PeerConnection construction. const char MediaConstraintsInterface::kEnableDtlsSrtp[] = @@ -150,11 +146,11 @@ const char MediaConstraintsInterface::kCpuOveruseDetection[] = "googCpuOveruseDetection"; const char MediaConstraintsInterface::kPayloadPadding[] = "googPayloadPadding"; - // Set |value| to the value associated with the first appearance of |key|, or // return false if |key| is not found. bool MediaConstraintsInterface::Constraints::FindFirst( - const std::string& key, std::string* value) const { + const std::string& key, + std::string* value) const { for (Constraints::const_iterator iter = begin(); iter != end(); ++iter) { if (iter->key == key) { *value = iter->value; @@ -165,7 +161,8 @@ bool MediaConstraintsInterface::Constraints::FindFirst( } bool FindConstraint(const MediaConstraintsInterface* constraints, - const std::string& key, bool* value, + const std::string& key, + bool* value, size_t* mandatory_constraints) { return ::FindConstraint(constraints, key, value, mandatory_constraints); } @@ -192,9 +189,9 @@ void CopyConstraintsIntoRtcConfiguration( } FindConstraint(constraints, MediaConstraintsInterface::kEnableDscp, &configuration->media_config.enable_dscp, nullptr); - FindConstraint( - constraints, MediaConstraintsInterface::kCpuOveruseDetection, - &configuration->media_config.video.enable_cpu_adaptation, nullptr); + FindConstraint(constraints, MediaConstraintsInterface::kCpuOveruseDetection, + &configuration->media_config.video.enable_cpu_adaptation, + nullptr); FindConstraint(constraints, MediaConstraintsInterface::kEnableRtpDataChannels, &configuration->enable_rtp_data_channel, nullptr); // Find Suspend Below Min Bitrate constraint. diff --git a/api/mediaconstraintsinterface.h b/api/mediaconstraintsinterface.h index 90661b893a..91043d25ea 100644 --- a/api/mediaconstraintsinterface.h +++ b/api/mediaconstraintsinterface.h @@ -39,8 +39,7 @@ class MediaConstraintsInterface { struct Constraint { Constraint() {} Constraint(const std::string& key, const std::string value) - : key(key), value(value) { - } + : key(key), value(value) {} std::string key; std::string value; }; @@ -54,12 +53,12 @@ class MediaConstraintsInterface { // Specified by draft-alvestrand-constraints-resolution-00b static const char kMinAspectRatio[]; // minAspectRatio static const char kMaxAspectRatio[]; // maxAspectRatio - static const char kMaxWidth[]; // maxWidth - static const char kMinWidth[]; // minWidth - static const char kMaxHeight[]; // maxHeight - static const char kMinHeight[]; // minHeight - static const char kMaxFrameRate[]; // maxFrameRate - static const char kMinFrameRate[]; // minFrameRate + static const char kMaxWidth[]; // maxWidth + static const char kMinWidth[]; // minWidth + static const char kMaxHeight[]; // maxHeight + static const char kMinHeight[]; // minHeight + static const char kMaxFrameRate[]; // maxFrameRate + static const char kMinFrameRate[]; // minFrameRate // Constraint keys used by a local audio source. static const char kEchoCancellation[]; // echoCancellation @@ -68,15 +67,15 @@ class MediaConstraintsInterface { static const char kGoogEchoCancellation[]; // googEchoCancellation static const char kExtendedFilterEchoCancellation[]; // googEchoCancellation2 - static const char kDAEchoCancellation[]; // googDAEchoCancellation - static const char kAutoGainControl[]; // googAutoGainControl - static const char kExperimentalAutoGainControl[]; // googAutoGainControl2 - static const char kNoiseSuppression[]; // googNoiseSuppression + static const char kDAEchoCancellation[]; // googDAEchoCancellation + static const char kAutoGainControl[]; // googAutoGainControl + static const char kExperimentalAutoGainControl[]; // googAutoGainControl2 + static const char kNoiseSuppression[]; // googNoiseSuppression static const char kExperimentalNoiseSuppression[]; // googNoiseSuppression2 - static const char kIntelligibilityEnhancer[]; // intelligibilityEnhancer - static const char kHighpassFilter[]; // googHighpassFilter + static const char kIntelligibilityEnhancer[]; // intelligibilityEnhancer + static const char kHighpassFilter[]; // googHighpassFilter static const char kTypingNoiseDetection[]; // googTypingNoiseDetection - static const char kAudioMirroring[]; // googAudioMirroring + static const char kAudioMirroring[]; // googAudioMirroring static const char kAudioNetworkAdaptorConfig[]; // goodAudioNetworkAdaptorConfig @@ -85,15 +84,15 @@ class MediaConstraintsInterface { // Constraint keys for CreateOffer / CreateAnswer // Specified by the W3C PeerConnection spec - static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo - static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio + static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo + static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio static const char kVoiceActivityDetection[]; // VoiceActivityDetection - static const char kIceRestart[]; // IceRestart + static const char kIceRestart[]; // IceRestart // These keys are google specific. static const char kUseRtpMux[]; // googUseRtpMUX // Constraints values. - static const char kValueTrue[]; // true + static const char kValueTrue[]; // true static const char kValueFalse[]; // false // PeerConnection constraint keys. @@ -108,12 +107,12 @@ class MediaConstraintsInterface { static const char kEnableIPv6[]; // googIPv6 // Temporary constraint to enable suspend below min bitrate feature. static const char kEnableVideoSuspendBelowMinBitrate[]; - // googSuspendBelowMinBitrate + // googSuspendBelowMinBitrate // Constraint to enable combined audio+video bandwidth estimation. static const char kCombinedAudioVideoBwe[]; // googCombinedAudioVideoBwe - static const char kScreencastMinBitrate[]; // googScreencastMinBitrate - static const char kCpuOveruseDetection[]; // googCpuOveruseDetection - static const char kPayloadPadding[]; // googPayloadPadding + static const char kScreencastMinBitrate[]; // googScreencastMinBitrate + static const char kCpuOveruseDetection[]; // googCpuOveruseDetection + static const char kPayloadPadding[]; // googPayloadPadding // The prefix of internal-only constraints whose JS set values should be // stripped by Chrome before passed down to Libjingle. @@ -126,7 +125,8 @@ class MediaConstraintsInterface { }; bool FindConstraint(const MediaConstraintsInterface* constraints, - const std::string& key, bool* value, + const std::string& key, + bool* value, size_t* mandatory_constraints); bool FindConstraint(const MediaConstraintsInterface* constraints, diff --git a/api/mediastreaminterface.h b/api/mediastreaminterface.h index 195ecc6a50..38ae3fc6a3 100644 --- a/api/mediastreaminterface.h +++ b/api/mediastreaminterface.h @@ -60,12 +60,7 @@ class NotifierInterface { class MediaSourceInterface : public rtc::RefCountInterface, public NotifierInterface { public: - enum SourceState { - kInitializing, - kLive, - kEnded, - kMuted - }; + enum SourceState { kInitializing, kLive, kEnded, kMuted }; virtual SourceState state() const = 0; @@ -116,9 +111,8 @@ class MediaStreamTrackInterface : public rtc::RefCountInterface, // on the worker thread via a VideoTrack. A custom implementation of a source // can inherit AdaptedVideoTrackSource instead of directly implementing this // interface. -class VideoTrackSourceInterface - : public MediaSourceInterface, - public rtc::VideoSourceInterface { +class VideoTrackSourceInterface : public MediaSourceInterface, + public rtc::VideoSourceInterface { public: struct Stats { // Original size of captured frame, before video adaptation. @@ -156,9 +150,8 @@ class VideoTrackSourceInterface // PeerConnectionFactory::CreateVideoTrack can be used for creating a VideoTrack // that ensures thread safety and that all methods are called on the right // thread. -class VideoTrackInterface - : public MediaStreamTrackInterface, - public rtc::VideoSourceInterface { +class VideoTrackInterface : public MediaStreamTrackInterface, + public rtc::VideoSourceInterface { public: // Video track content hint, used to override the source is_screencast // property. @@ -276,7 +269,7 @@ class AudioTrackInterface : public MediaStreamTrackInterface { public: // TODO(deadbeef): Figure out if the following interface should be const or // not. - virtual AudioSourceInterface* GetSource() const = 0; + virtual AudioSourceInterface* GetSource() const = 0; // Add/Remove a sink that will receive the audio data from the track. virtual void AddSink(AudioTrackSinkInterface* sink) = 0; @@ -297,10 +290,8 @@ class AudioTrackInterface : public MediaStreamTrackInterface { ~AudioTrackInterface() override = default; }; -typedef std::vector > - AudioTrackVector; -typedef std::vector > - VideoTrackVector; +typedef std::vector > AudioTrackVector; +typedef std::vector > VideoTrackVector; // C++ version of https://www.w3.org/TR/mediacapture-streams/#mediastream. // @@ -317,10 +308,10 @@ class MediaStreamInterface : public rtc::RefCountInterface, virtual AudioTrackVector GetAudioTracks() = 0; virtual VideoTrackVector GetVideoTracks() = 0; - virtual rtc::scoped_refptr - FindAudioTrack(const std::string& track_id) = 0; - virtual rtc::scoped_refptr - FindVideoTrack(const std::string& track_id) = 0; + virtual rtc::scoped_refptr FindAudioTrack( + const std::string& track_id) = 0; + virtual rtc::scoped_refptr FindVideoTrack( + const std::string& track_id) = 0; virtual bool AddTrack(AudioTrackInterface* track) = 0; virtual bool AddTrack(VideoTrackInterface* track) = 0; diff --git a/api/mediastreamproxy.h b/api/mediastreamproxy.h index 3f261db0a8..4c544595aa 100644 --- a/api/mediastreamproxy.h +++ b/api/mediastreamproxy.h @@ -21,22 +21,22 @@ namespace webrtc { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(MediaStream) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_CONSTMETHOD0(std::string, id) - PROXY_METHOD0(AudioTrackVector, GetAudioTracks) - PROXY_METHOD0(VideoTrackVector, GetVideoTracks) - PROXY_METHOD1(rtc::scoped_refptr, - FindAudioTrack, - const std::string&) - PROXY_METHOD1(rtc::scoped_refptr, - FindVideoTrack, - const std::string&) - PROXY_METHOD1(bool, AddTrack, AudioTrackInterface*) - PROXY_METHOD1(bool, AddTrack, VideoTrackInterface*) - PROXY_METHOD1(bool, RemoveTrack, AudioTrackInterface*) - PROXY_METHOD1(bool, RemoveTrack, VideoTrackInterface*) - PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) - PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_CONSTMETHOD0(std::string, id) +PROXY_METHOD0(AudioTrackVector, GetAudioTracks) +PROXY_METHOD0(VideoTrackVector, GetVideoTracks) +PROXY_METHOD1(rtc::scoped_refptr, + FindAudioTrack, + const std::string&) +PROXY_METHOD1(rtc::scoped_refptr, + FindVideoTrack, + const std::string&) +PROXY_METHOD1(bool, AddTrack, AudioTrackInterface*) +PROXY_METHOD1(bool, AddTrack, VideoTrackInterface*) +PROXY_METHOD1(bool, RemoveTrack, AudioTrackInterface*) +PROXY_METHOD1(bool, RemoveTrack, VideoTrackInterface*) +PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) +PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) END_PROXY_MAP() } // namespace webrtc diff --git a/api/mediastreamtrackproxy.h b/api/mediastreamtrackproxy.h index 57a7695599..77b7bad9b4 100644 --- a/api/mediastreamtrackproxy.h +++ b/api/mediastreamtrackproxy.h @@ -25,39 +25,39 @@ namespace webrtc { // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(AudioTrack) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_CONSTMETHOD0(std::string, kind) - PROXY_CONSTMETHOD0(std::string, id) - PROXY_CONSTMETHOD0(TrackState, state) - PROXY_CONSTMETHOD0(bool, enabled) - PROXY_CONSTMETHOD0(AudioSourceInterface*, GetSource) - PROXY_METHOD1(void, AddSink, AudioTrackSinkInterface*) - PROXY_METHOD1(void, RemoveSink, AudioTrackSinkInterface*) - PROXY_METHOD1(bool, GetSignalLevel, int*) - PROXY_METHOD0(rtc::scoped_refptr, GetAudioProcessor) - PROXY_METHOD1(bool, set_enabled, bool) - PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) - PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_CONSTMETHOD0(std::string, kind) +PROXY_CONSTMETHOD0(std::string, id) +PROXY_CONSTMETHOD0(TrackState, state) +PROXY_CONSTMETHOD0(bool, enabled) +PROXY_CONSTMETHOD0(AudioSourceInterface*, GetSource) +PROXY_METHOD1(void, AddSink, AudioTrackSinkInterface*) +PROXY_METHOD1(void, RemoveSink, AudioTrackSinkInterface*) +PROXY_METHOD1(bool, GetSignalLevel, int*) +PROXY_METHOD0(rtc::scoped_refptr, GetAudioProcessor) +PROXY_METHOD1(bool, set_enabled, bool) +PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) +PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) END_PROXY_MAP() BEGIN_PROXY_MAP(VideoTrack) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_CONSTMETHOD0(std::string, kind) - PROXY_CONSTMETHOD0(std::string, id) - PROXY_CONSTMETHOD0(TrackState, state) - PROXY_CONSTMETHOD0(bool, enabled) - PROXY_METHOD1(bool, set_enabled, bool) - PROXY_CONSTMETHOD0(ContentHint, content_hint) - PROXY_METHOD1(void, set_content_hint, ContentHint) - PROXY_WORKER_METHOD2(void, - AddOrUpdateSink, - rtc::VideoSinkInterface*, - const rtc::VideoSinkWants&) - PROXY_WORKER_METHOD1(void, RemoveSink, rtc::VideoSinkInterface*) - PROXY_CONSTMETHOD0(VideoTrackSourceInterface*, GetSource) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_CONSTMETHOD0(std::string, kind) +PROXY_CONSTMETHOD0(std::string, id) +PROXY_CONSTMETHOD0(TrackState, state) +PROXY_CONSTMETHOD0(bool, enabled) +PROXY_METHOD1(bool, set_enabled, bool) +PROXY_CONSTMETHOD0(ContentHint, content_hint) +PROXY_METHOD1(void, set_content_hint, ContentHint) +PROXY_WORKER_METHOD2(void, + AddOrUpdateSink, + rtc::VideoSinkInterface*, + const rtc::VideoSinkWants&) +PROXY_WORKER_METHOD1(void, RemoveSink, rtc::VideoSinkInterface*) +PROXY_CONSTMETHOD0(VideoTrackSourceInterface*, GetSource) - PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) - PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) +PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) +PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) END_PROXY_MAP() } // namespace webrtc diff --git a/api/mediatypes.h b/api/mediatypes.h index 93ce1a231d..076fc0420c 100644 --- a/api/mediatypes.h +++ b/api/mediatypes.h @@ -15,11 +15,7 @@ namespace cricket { -enum MediaType { - MEDIA_TYPE_AUDIO, - MEDIA_TYPE_VIDEO, - MEDIA_TYPE_DATA -}; +enum MediaType { MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO, MEDIA_TYPE_DATA }; std::string MediaTypeToString(MediaType type); // Aborts on invalid string. Only expected to be used on strings that are diff --git a/api/notifier.h b/api/notifier.h index ceeda4de55..e5c61c9667 100644 --- a/api/notifier.h +++ b/api/notifier.h @@ -23,8 +23,7 @@ namespace webrtc { template class Notifier : public T { public: - Notifier() { - } + Notifier() {} virtual void RegisterObserver(ObserverInterface* observer) { RTC_DCHECK(observer != nullptr); diff --git a/api/ortc/sessiondescription_unittest.cc b/api/ortc/sessiondescription_unittest.cc index fd6f43de43..e4611c6c6b 100644 --- a/api/ortc/sessiondescription_unittest.cc +++ b/api/ortc/sessiondescription_unittest.cc @@ -20,4 +20,4 @@ TEST_F(SessionDescriptionTest, CreateSessionDescription) { EXPECT_EQ(-1, s.session_id()); EXPECT_EQ("0", s.session_version()); } -} +} // namespace webrtc diff --git a/api/ortc/srtptransportinterface.h b/api/ortc/srtptransportinterface.h index 41c8ccc9c1..4b757e400c 100644 --- a/api/ortc/srtptransportinterface.h +++ b/api/ortc/srtptransportinterface.h @@ -11,9 +11,9 @@ #ifndef API_ORTC_SRTPTRANSPORTINTERFACE_H_ #define API_ORTC_SRTPTRANSPORTINTERFACE_H_ +#include "api/cryptoparams.h" #include "api/ortc/rtptransportinterface.h" #include "api/rtcerror.h" -#include "api/cryptoparams.h" namespace webrtc { diff --git a/api/peerconnectionfactoryproxy.h b/api/peerconnectionfactoryproxy.h index 13f8a99697..eea5b5565c 100644 --- a/api/peerconnectionfactoryproxy.h +++ b/api/peerconnectionfactoryproxy.h @@ -24,50 +24,53 @@ namespace webrtc { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(PeerConnectionFactory) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - // Use the overloads of CreateVideoSource that take raw VideoCapturer - // pointers from PeerConnectionFactoryInterface. - // TODO(deadbeef): Remove this using statement once those overloads are - // removed. - using PeerConnectionFactoryInterface::CreateVideoSource; - PROXY_METHOD1(void, SetOptions, const Options&) - PROXY_METHOD5(rtc::scoped_refptr, - CreatePeerConnection, - const PeerConnectionInterface::RTCConfiguration&, - const MediaConstraintsInterface*, - std::unique_ptr, - std::unique_ptr, - PeerConnectionObserver*); - PROXY_METHOD4(rtc::scoped_refptr, - CreatePeerConnection, - const PeerConnectionInterface::RTCConfiguration&, - std::unique_ptr, - std::unique_ptr, - PeerConnectionObserver*); - PROXY_METHOD2(rtc::scoped_refptr, - CreatePeerConnection, - const PeerConnectionInterface::RTCConfiguration&, - PeerConnectionDependencies); - PROXY_METHOD1(rtc::scoped_refptr, - CreateLocalMediaStream, const std::string&) - PROXY_METHOD1(rtc::scoped_refptr, - CreateAudioSource, - const cricket::AudioOptions&) - PROXY_METHOD2(rtc::scoped_refptr, - CreateVideoSource, - std::unique_ptr, - const MediaConstraintsInterface*) - PROXY_METHOD1(rtc::scoped_refptr, - CreateVideoSource, - std::unique_ptr) - PROXY_METHOD2(rtc::scoped_refptr, - CreateVideoTrack, - const std::string&, - VideoTrackSourceInterface*) - PROXY_METHOD2(rtc::scoped_refptr, - CreateAudioTrack, const std::string&, AudioSourceInterface*) - PROXY_METHOD2(bool, StartAecDump, rtc::PlatformFile, int64_t) - PROXY_METHOD0(void, StopAecDump) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +// Use the overloads of CreateVideoSource that take raw VideoCapturer +// pointers from PeerConnectionFactoryInterface. +// TODO(deadbeef): Remove this using statement once those overloads are +// removed. +using PeerConnectionFactoryInterface::CreateVideoSource; +PROXY_METHOD1(void, SetOptions, const Options&) +PROXY_METHOD5(rtc::scoped_refptr, + CreatePeerConnection, + const PeerConnectionInterface::RTCConfiguration&, + const MediaConstraintsInterface*, + std::unique_ptr, + std::unique_ptr, + PeerConnectionObserver*); +PROXY_METHOD4(rtc::scoped_refptr, + CreatePeerConnection, + const PeerConnectionInterface::RTCConfiguration&, + std::unique_ptr, + std::unique_ptr, + PeerConnectionObserver*); +PROXY_METHOD2(rtc::scoped_refptr, + CreatePeerConnection, + const PeerConnectionInterface::RTCConfiguration&, + PeerConnectionDependencies); +PROXY_METHOD1(rtc::scoped_refptr, + CreateLocalMediaStream, + const std::string&) +PROXY_METHOD1(rtc::scoped_refptr, + CreateAudioSource, + const cricket::AudioOptions&) +PROXY_METHOD2(rtc::scoped_refptr, + CreateVideoSource, + std::unique_ptr, + const MediaConstraintsInterface*) +PROXY_METHOD1(rtc::scoped_refptr, + CreateVideoSource, + std::unique_ptr) +PROXY_METHOD2(rtc::scoped_refptr, + CreateVideoTrack, + const std::string&, + VideoTrackSourceInterface*) +PROXY_METHOD2(rtc::scoped_refptr, + CreateAudioTrack, + const std::string&, + AudioSourceInterface*) +PROXY_METHOD2(bool, StartAecDump, rtc::PlatformFile, int64_t) +PROXY_METHOD0(void, StopAecDump) END_PROXY_MAP() } // namespace webrtc diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index 567c0260c6..c1ef6f6e56 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -116,13 +116,13 @@ namespace rtc { class SSLIdentity; class Thread; -} +} // namespace rtc namespace cricket { class MediaEngineInterface; class WebRtcVideoDecoderFactory; class WebRtcVideoEncoderFactory; -} +} // namespace cricket namespace webrtc { class AudioDeviceModule; @@ -139,10 +139,8 @@ class StreamCollectionInterface : public rtc::RefCountInterface { virtual size_t count() = 0; virtual MediaStreamInterface* at(size_t index) = 0; virtual MediaStreamInterface* find(const std::string& label) = 0; - virtual MediaStreamTrackInterface* FindAudioTrack( - const std::string& id) = 0; - virtual MediaStreamTrackInterface* FindVideoTrack( - const std::string& id) = 0; + virtual MediaStreamTrackInterface* FindAudioTrack(const std::string& id) = 0; + virtual MediaStreamTrackInterface* FindVideoTrack(const std::string& id) = 0; protected: // Dtor protected as objects shouldn't be deleted via this interface. @@ -262,10 +260,7 @@ class PeerConnectionInterface : public rtc::RefCountInterface { kCandidateNetworkPolicyLowCost }; - enum ContinualGatheringPolicy { - GATHER_ONCE, - GATHER_CONTINUALLY - }; + enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY }; enum class RTCConfigurationType { // A configuration that is safer to use, despite not having the best @@ -634,14 +629,12 @@ class PeerConnectionInterface : public rtc::RefCountInterface { // Accessor methods to active local streams. // This method is not supported with kUnifiedPlan semantics. Please use // GetSenders() instead. - virtual rtc::scoped_refptr - local_streams() = 0; + virtual rtc::scoped_refptr local_streams() = 0; // Accessor methods to remote streams. // This method is not supported with kUnifiedPlan semantics. Please use // GetReceivers() instead. - virtual rtc::scoped_refptr - remote_streams() = 0; + virtual rtc::scoped_refptr remote_streams() = 0; // Add a new MediaStream to be sent on this PeerConnection. // Note that a SessionDescription negotiation is needed before the @@ -1374,9 +1367,9 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface { VideoTrackSourceInterface* source) = 0; // Creates an new AudioTrack. At the moment |source| can be null. - virtual rtc::scoped_refptr - CreateAudioTrack(const std::string& label, - AudioSourceInterface* source) = 0; + virtual rtc::scoped_refptr CreateAudioTrack( + const std::string& label, + AudioSourceInterface* source) = 0; // Starts AEC dump using existing file. Takes ownership of |file| and passes // it on to VoiceEngine (via other objects) immediately, which will take @@ -1394,7 +1387,7 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface { // Dtor and ctor protected as objects shouldn't be created or deleted via // this interface. PeerConnectionFactoryInterface() {} - ~PeerConnectionFactoryInterface() {} // NOLINT + ~PeerConnectionFactoryInterface() {} // NOLINT }; // Create a new instance of PeerConnectionFactoryInterface. diff --git a/api/peerconnectionproxy.h b/api/peerconnectionproxy.h index 3abcf96f60..1e16ecf124 100644 --- a/api/peerconnectionproxy.h +++ b/api/peerconnectionproxy.h @@ -23,132 +23,132 @@ namespace webrtc { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(PeerConnection) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD0(rtc::scoped_refptr, local_streams) - PROXY_METHOD0(rtc::scoped_refptr, remote_streams) - PROXY_METHOD1(bool, AddStream, MediaStreamInterface*) - PROXY_METHOD1(void, RemoveStream, MediaStreamInterface*) - PROXY_METHOD2(RTCErrorOr>, - AddTrack, - rtc::scoped_refptr, - const std::vector&); - PROXY_METHOD2(rtc::scoped_refptr, - AddTrack, - MediaStreamTrackInterface*, - std::vector) - PROXY_METHOD1(bool, RemoveTrack, RtpSenderInterface*) - PROXY_METHOD1(RTCErrorOr>, - AddTransceiver, - rtc::scoped_refptr) - PROXY_METHOD2(RTCErrorOr>, - AddTransceiver, - rtc::scoped_refptr, - const RtpTransceiverInit&) - PROXY_METHOD1(RTCErrorOr>, - AddTransceiver, - cricket::MediaType) - PROXY_METHOD2(RTCErrorOr>, - AddTransceiver, - cricket::MediaType, - const RtpTransceiverInit&) - PROXY_METHOD1(rtc::scoped_refptr, - CreateDtmfSender, - AudioTrackInterface*) - PROXY_METHOD2(rtc::scoped_refptr, - CreateSender, - const std::string&, - const std::string&) - PROXY_CONSTMETHOD0(std::vector>, - GetSenders) - PROXY_CONSTMETHOD0(std::vector>, - GetReceivers) - PROXY_CONSTMETHOD0(std::vector>, - GetTransceivers) - PROXY_METHOD3(bool, - GetStats, - StatsObserver*, - MediaStreamTrackInterface*, - StatsOutputLevel) - PROXY_METHOD1(void, GetStats, RTCStatsCollectorCallback*) - PROXY_METHOD2(void, - GetStats, - rtc::scoped_refptr, - rtc::scoped_refptr); - PROXY_METHOD2(void, - GetStats, - rtc::scoped_refptr, - rtc::scoped_refptr); - PROXY_METHOD2(rtc::scoped_refptr, - CreateDataChannel, - const std::string&, - const DataChannelInit*) - PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, local_description) - PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, remote_description) - PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, - pending_local_description) - PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, - pending_remote_description) - PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, - current_local_description) - PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, - current_remote_description) - PROXY_METHOD2(void, - CreateOffer, - CreateSessionDescriptionObserver*, - const MediaConstraintsInterface*) - PROXY_METHOD2(void, - CreateAnswer, - CreateSessionDescriptionObserver*, - const MediaConstraintsInterface*) - PROXY_METHOD2(void, - CreateOffer, - CreateSessionDescriptionObserver*, - const RTCOfferAnswerOptions&) - PROXY_METHOD2(void, - CreateAnswer, - CreateSessionDescriptionObserver*, - const RTCOfferAnswerOptions&) - PROXY_METHOD2(void, - SetLocalDescription, - SetSessionDescriptionObserver*, - SessionDescriptionInterface*) - PROXY_METHOD2(void, - SetRemoteDescription, - SetSessionDescriptionObserver*, - SessionDescriptionInterface*) - PROXY_METHOD2(void, - SetRemoteDescription, - std::unique_ptr, - rtc::scoped_refptr); - PROXY_METHOD0(PeerConnectionInterface::RTCConfiguration, GetConfiguration); - PROXY_METHOD2(bool, - SetConfiguration, - const PeerConnectionInterface::RTCConfiguration&, - RTCError*); - PROXY_METHOD1(bool, - SetConfiguration, - const PeerConnectionInterface::RTCConfiguration&); - PROXY_METHOD1(bool, AddIceCandidate, const IceCandidateInterface*) - PROXY_METHOD1(bool, - RemoveIceCandidates, - const std::vector&); - PROXY_METHOD1(void, SetAudioPlayout, bool) - PROXY_METHOD1(void, SetAudioRecording, bool) - PROXY_METHOD1(void, RegisterUMAObserver, UMAObserver*) - PROXY_METHOD1(RTCError, SetBitrate, const BitrateSettings&); - PROXY_METHOD1(void, - SetBitrateAllocationStrategy, - std::unique_ptr); - PROXY_METHOD0(SignalingState, signaling_state) - PROXY_METHOD0(IceConnectionState, ice_connection_state) - PROXY_METHOD0(IceGatheringState, ice_gathering_state) - PROXY_METHOD2(bool, StartRtcEventLog, rtc::PlatformFile, int64_t) - PROXY_METHOD2(bool, - StartRtcEventLog, - std::unique_ptr, - int64_t); - PROXY_METHOD0(void, StopRtcEventLog) - PROXY_METHOD0(void, Close) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_METHOD0(rtc::scoped_refptr, local_streams) +PROXY_METHOD0(rtc::scoped_refptr, remote_streams) +PROXY_METHOD1(bool, AddStream, MediaStreamInterface*) +PROXY_METHOD1(void, RemoveStream, MediaStreamInterface*) +PROXY_METHOD2(RTCErrorOr>, + AddTrack, + rtc::scoped_refptr, + const std::vector&); +PROXY_METHOD2(rtc::scoped_refptr, + AddTrack, + MediaStreamTrackInterface*, + std::vector) +PROXY_METHOD1(bool, RemoveTrack, RtpSenderInterface*) +PROXY_METHOD1(RTCErrorOr>, + AddTransceiver, + rtc::scoped_refptr) +PROXY_METHOD2(RTCErrorOr>, + AddTransceiver, + rtc::scoped_refptr, + const RtpTransceiverInit&) +PROXY_METHOD1(RTCErrorOr>, + AddTransceiver, + cricket::MediaType) +PROXY_METHOD2(RTCErrorOr>, + AddTransceiver, + cricket::MediaType, + const RtpTransceiverInit&) +PROXY_METHOD1(rtc::scoped_refptr, + CreateDtmfSender, + AudioTrackInterface*) +PROXY_METHOD2(rtc::scoped_refptr, + CreateSender, + const std::string&, + const std::string&) +PROXY_CONSTMETHOD0(std::vector>, + GetSenders) +PROXY_CONSTMETHOD0(std::vector>, + GetReceivers) +PROXY_CONSTMETHOD0(std::vector>, + GetTransceivers) +PROXY_METHOD3(bool, + GetStats, + StatsObserver*, + MediaStreamTrackInterface*, + StatsOutputLevel) +PROXY_METHOD1(void, GetStats, RTCStatsCollectorCallback*) +PROXY_METHOD2(void, + GetStats, + rtc::scoped_refptr, + rtc::scoped_refptr); +PROXY_METHOD2(void, + GetStats, + rtc::scoped_refptr, + rtc::scoped_refptr); +PROXY_METHOD2(rtc::scoped_refptr, + CreateDataChannel, + const std::string&, + const DataChannelInit*) +PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, local_description) +PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, remote_description) +PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, + pending_local_description) +PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, + pending_remote_description) +PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, + current_local_description) +PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, + current_remote_description) +PROXY_METHOD2(void, + CreateOffer, + CreateSessionDescriptionObserver*, + const MediaConstraintsInterface*) +PROXY_METHOD2(void, + CreateAnswer, + CreateSessionDescriptionObserver*, + const MediaConstraintsInterface*) +PROXY_METHOD2(void, + CreateOffer, + CreateSessionDescriptionObserver*, + const RTCOfferAnswerOptions&) +PROXY_METHOD2(void, + CreateAnswer, + CreateSessionDescriptionObserver*, + const RTCOfferAnswerOptions&) +PROXY_METHOD2(void, + SetLocalDescription, + SetSessionDescriptionObserver*, + SessionDescriptionInterface*) +PROXY_METHOD2(void, + SetRemoteDescription, + SetSessionDescriptionObserver*, + SessionDescriptionInterface*) +PROXY_METHOD2(void, + SetRemoteDescription, + std::unique_ptr, + rtc::scoped_refptr); +PROXY_METHOD0(PeerConnectionInterface::RTCConfiguration, GetConfiguration); +PROXY_METHOD2(bool, + SetConfiguration, + const PeerConnectionInterface::RTCConfiguration&, + RTCError*); +PROXY_METHOD1(bool, + SetConfiguration, + const PeerConnectionInterface::RTCConfiguration&); +PROXY_METHOD1(bool, AddIceCandidate, const IceCandidateInterface*) +PROXY_METHOD1(bool, + RemoveIceCandidates, + const std::vector&); +PROXY_METHOD1(void, SetAudioPlayout, bool) +PROXY_METHOD1(void, SetAudioRecording, bool) +PROXY_METHOD1(void, RegisterUMAObserver, UMAObserver*) +PROXY_METHOD1(RTCError, SetBitrate, const BitrateSettings&); +PROXY_METHOD1(void, + SetBitrateAllocationStrategy, + std::unique_ptr); +PROXY_METHOD0(SignalingState, signaling_state) +PROXY_METHOD0(IceConnectionState, ice_connection_state) +PROXY_METHOD0(IceGatheringState, ice_gathering_state) +PROXY_METHOD2(bool, StartRtcEventLog, rtc::PlatformFile, int64_t) +PROXY_METHOD2(bool, + StartRtcEventLog, + std::unique_ptr, + int64_t); +PROXY_METHOD0(void, StopRtcEventLog) +PROXY_METHOD0(void, Close) END_PROXY_MAP() } // namespace webrtc diff --git a/api/proxy.h b/api/proxy.h index dd7182e554..c8962efed7 100644 --- a/api/proxy.h +++ b/api/proxy.h @@ -64,8 +64,10 @@ namespace webrtc { template class ReturnType { public: - template - void Invoke(C* c, M m) { r_ = (c->*m)(); } + template + void Invoke(C* c, M m) { + r_ = (c->*m)(); + } template void Invoke(C* c, M m, T1 a1) { r_ = (c->*m)(std::move(a1)); @@ -78,13 +80,22 @@ class ReturnType { void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3) { r_ = (c->*m)(std::move(a1), std::move(a2), std::move(a3)); } - template + template void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4) { r_ = (c->*m)(std::move(a1), std::move(a2), std::move(a3), std::move(a4)); } - template + template void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { r_ = (c->*m)(std::move(a1), std::move(a2), std::move(a3), std::move(a4), std::move(a5)); @@ -99,8 +110,10 @@ class ReturnType { template <> class ReturnType { public: - template - void Invoke(C* c, M m) { (c->*m)(); } + template + void Invoke(C* c, M m) { + (c->*m)(); + } template void Invoke(C* c, M m, T1 a1) { (c->*m)(std::move(a1)); @@ -119,9 +132,8 @@ class ReturnType { namespace internal { -class SynchronousMethodCall - : public rtc::MessageData, - public rtc::MessageHandler { +class SynchronousMethodCall : public rtc::MessageData, + public rtc::MessageHandler { public: explicit SynchronousMethodCall(rtc::MessageHandler* proxy); ~SynchronousMethodCall() override; @@ -138,8 +150,7 @@ class SynchronousMethodCall } // namespace internal template -class MethodCall0 : public rtc::Message, - public rtc::MessageHandler { +class MethodCall0 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(); MethodCall0(C* c, Method m) : c_(c), m_(m) {} @@ -150,7 +161,7 @@ class MethodCall0 : public rtc::Message, } private: - void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } + void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } C* c_; Method m_; @@ -158,8 +169,7 @@ class MethodCall0 : public rtc::Message, }; template -class ConstMethodCall0 : public rtc::Message, - public rtc::MessageHandler { +class ConstMethodCall0 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)() const; ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {} @@ -177,9 +187,8 @@ class ConstMethodCall0 : public rtc::Message, ReturnType r_; }; -template -class MethodCall1 : public rtc::Message, - public rtc::MessageHandler { +template +class MethodCall1 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(T1 a1); MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(std::move(a1)) {} @@ -198,9 +207,8 @@ class MethodCall1 : public rtc::Message, T1 a1_; }; -template -class ConstMethodCall1 : public rtc::Message, - public rtc::MessageHandler { +template +class ConstMethodCall1 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(T1 a1) const; ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(std::move(a1)) {} @@ -220,8 +228,7 @@ class ConstMethodCall1 : public rtc::Message, }; template -class MethodCall2 : public rtc::Message, - public rtc::MessageHandler { +class MethodCall2 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(T1 a1, T2 a2); MethodCall2(C* c, Method m, T1 a1, T2 a2) @@ -245,8 +252,7 @@ class MethodCall2 : public rtc::Message, }; template -class MethodCall3 : public rtc::Message, - public rtc::MessageHandler { +class MethodCall3 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(T1 a1, T2 a2, T3 a3); MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3) @@ -274,10 +280,13 @@ class MethodCall3 : public rtc::Message, T3 a3_; }; -template -class MethodCall4 : public rtc::Message, - public rtc::MessageHandler { +template +class MethodCall4 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4); MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4) @@ -308,10 +317,14 @@ class MethodCall4 : public rtc::Message, T4 a4_; }; -template -class MethodCall5 : public rtc::Message, - public rtc::MessageHandler { +template +class MethodCall5 : public rtc::Message, public rtc::MessageHandler { public: typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) @@ -344,7 +357,6 @@ class MethodCall5 : public rtc::Message, T5 a5_; }; - // Helper macros to reduce code duplication. #define PROXY_MAP_BOILERPLATE(c) \ template \ @@ -359,8 +371,12 @@ class MethodCall5 : public rtc::Message, const INTERNAL_CLASS* internal() const { return c_; } \ INTERNAL_CLASS* internal() { return c_; } +// clang-format off +// clang-format would put the semicolon alone, +// leading to a presubmit error (cpplint.py) #define END_PROXY_MAP() \ }; +// clang-format on #define SIGNALING_PROXY_MAP_BOILERPLATE(c) \ protected: \ diff --git a/api/rtp_headers.h b/api/rtp_headers.h index e82d121040..3318e60733 100644 --- a/api/rtp_headers.h +++ b/api/rtp_headers.h @@ -22,9 +22,9 @@ #include "api/video/video_rotation.h" #include "api/video/video_timing.h" +#include "common_types.h" // NOLINT(build/include) #include "rtc_base/checks.h" #include "rtc_base/deprecation.h" -#include "common_types.h" // NOLINT(build/include) #include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/api/rtpreceiverinterface.h b/api/rtpreceiverinterface.h index 0e32eae8cb..30eb6677cc 100644 --- a/api/rtpreceiverinterface.h +++ b/api/rtpreceiverinterface.h @@ -128,17 +128,17 @@ class RtpReceiverInterface : public rtc::RefCountInterface { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_CONSTMETHOD0(rtc::scoped_refptr, track) - PROXY_CONSTMETHOD0(std::vector>, - streams) - PROXY_CONSTMETHOD0(cricket::MediaType, media_type) - PROXY_CONSTMETHOD0(std::string, id) - PROXY_CONSTMETHOD0(RtpParameters, GetParameters); - PROXY_METHOD1(bool, SetParameters, const RtpParameters&) - PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); - PROXY_CONSTMETHOD0(std::vector, GetSources); - END_PROXY_MAP() +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_CONSTMETHOD0(rtc::scoped_refptr, track) +PROXY_CONSTMETHOD0(std::vector>, + streams) +PROXY_CONSTMETHOD0(cricket::MediaType, media_type) +PROXY_CONSTMETHOD0(std::string, id) +PROXY_CONSTMETHOD0(RtpParameters, GetParameters); +PROXY_METHOD1(bool, SetParameters, const RtpParameters&) +PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); +PROXY_CONSTMETHOD0(std::vector, GetSources); +END_PROXY_MAP() } // namespace webrtc diff --git a/api/rtpsenderinterface.h b/api/rtpsenderinterface.h index 0f235bdbfd..e933614bcb 100644 --- a/api/rtpsenderinterface.h +++ b/api/rtpsenderinterface.h @@ -70,17 +70,17 @@ class RtpSenderInterface : public rtc::RefCountInterface { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(RtpSender) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*) - PROXY_CONSTMETHOD0(rtc::scoped_refptr, track) - PROXY_CONSTMETHOD0(uint32_t, ssrc) - PROXY_CONSTMETHOD0(cricket::MediaType, media_type) - PROXY_CONSTMETHOD0(std::string, id) - PROXY_CONSTMETHOD0(std::vector, stream_ids) - PROXY_METHOD0(RtpParameters, GetParameters); - PROXY_METHOD1(RTCError, SetParameters, const RtpParameters&) - PROXY_CONSTMETHOD0(rtc::scoped_refptr, GetDtmfSender); - END_PROXY_MAP() +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*) +PROXY_CONSTMETHOD0(rtc::scoped_refptr, track) +PROXY_CONSTMETHOD0(uint32_t, ssrc) +PROXY_CONSTMETHOD0(cricket::MediaType, media_type) +PROXY_CONSTMETHOD0(std::string, id) +PROXY_CONSTMETHOD0(std::vector, stream_ids) +PROXY_METHOD0(RtpParameters, GetParameters); +PROXY_METHOD1(RTCError, SetParameters, const RtpParameters&) +PROXY_CONSTMETHOD0(rtc::scoped_refptr, GetDtmfSender); +END_PROXY_MAP() } // namespace webrtc diff --git a/api/stats/rtcstats.h b/api/stats/rtcstats.h index 887d602042..1ca7b2c529 100644 --- a/api/stats/rtcstats.h +++ b/api/stats/rtcstats.h @@ -78,7 +78,7 @@ class RTCStats { // Downcasts the stats object to an |RTCStats| subclass |T|. DCHECKs that the // object is of type |T|. - template + template const T& cast_to() const { RTC_DCHECK_EQ(type(), T::kType); return static_cast(*this); @@ -90,8 +90,7 @@ class RTCStats { // shall be reserved in the vector (so that subclasses can allocate a vector // with room for both parent and child members without it having to resize). virtual std::vector - MembersOfThisObjectAndAncestors( - size_t additional_capacity) const; + MembersOfThisObjectAndAncestors(size_t additional_capacity) const; std::string const id_; int64_t timestamp_us_; @@ -138,18 +137,18 @@ class RTCStats { // bar("bar") { // } // -#define WEBRTC_RTCSTATS_DECL() \ - public: \ - static const char kType[]; \ - \ - std::unique_ptr copy() const override; \ - const char* type() const override; \ - \ - protected: \ - std::vector \ - MembersOfThisObjectAndAncestors( \ - size_t local_var_additional_capacity) const override; \ - \ +#define WEBRTC_RTCSTATS_DECL() \ + public: \ + static const char kType[]; \ + \ + std::unique_ptr copy() const override; \ + const char* type() const override; \ + \ + protected: \ + std::vector \ + MembersOfThisObjectAndAncestors(size_t local_var_additional_capacity) \ + const override; \ + \ public: #define WEBRTC_RTCSTATS_IMPL(this_class, parent_class, type_str, ...) \ @@ -159,20 +158,17 @@ class RTCStats { return std::unique_ptr(new this_class(*this)); \ } \ \ - const char* this_class::type() const { \ - return this_class::kType; \ - } \ + const char* this_class::type() const { return this_class::kType; } \ \ std::vector \ this_class::MembersOfThisObjectAndAncestors( \ size_t local_var_additional_capacity) const { \ const webrtc::RTCStatsMemberInterface* local_var_members[] = { \ - __VA_ARGS__ \ - }; \ + __VA_ARGS__}; \ size_t local_var_members_count = \ sizeof(local_var_members) / sizeof(local_var_members[0]); \ - std::vector local_var_members_vec =\ - parent_class::MembersOfThisObjectAndAncestors( \ + std::vector \ + local_var_members_vec = parent_class::MembersOfThisObjectAndAncestors( \ local_var_members_count + local_var_additional_capacity); \ RTC_DCHECK_GE( \ local_var_members_vec.capacity() - local_var_members_vec.size(), \ @@ -191,21 +187,21 @@ class RTCStatsMemberInterface { public: // Member value types. enum Type { - kBool, // bool - kInt32, // int32_t - kUint32, // uint32_t - kInt64, // int64_t - kUint64, // uint64_t - kDouble, // double - kString, // std::string + kBool, // bool + kInt32, // int32_t + kUint32, // uint32_t + kInt64, // int64_t + kUint64, // uint64_t + kDouble, // double + kString, // std::string - kSequenceBool, // std::vector - kSequenceInt32, // std::vector - kSequenceUint32, // std::vector - kSequenceInt64, // std::vector - kSequenceUint64, // std::vector - kSequenceDouble, // std::vector - kSequenceString, // std::vector + kSequenceBool, // std::vector + kSequenceInt32, // std::vector + kSequenceUint32, // std::vector + kSequenceInt64, // std::vector + kSequenceUint64, // std::vector + kSequenceDouble, // std::vector + kSequenceString, // std::vector }; virtual ~RTCStatsMemberInterface() {} @@ -229,7 +225,7 @@ class RTCStatsMemberInterface { // instead. virtual std::string ValueToJson() const = 0; - template + template const T& cast_to() const { RTC_DCHECK_EQ(type(), T::kType); return static_cast(*this); @@ -247,20 +243,17 @@ class RTCStatsMemberInterface { // specialized in rtcstats.cc, using a different |T| results in a linker error // (undefined reference to |kType|). The supported types are the ones described // by |RTCStatsMemberInterface::Type|. -template +template class RTCStatsMember : public RTCStatsMemberInterface { public: static const Type kType; explicit RTCStatsMember(const char* name) - : RTCStatsMemberInterface(name, false), - value_() {} + : RTCStatsMemberInterface(name, false), value_() {} RTCStatsMember(const char* name, const T& value) - : RTCStatsMemberInterface(name, true), - value_(value) {} + : RTCStatsMemberInterface(name, true), value_(value) {} RTCStatsMember(const char* name, T&& value) - : RTCStatsMemberInterface(name, true), - value_(std::move(value)) {} + : RTCStatsMemberInterface(name, true), value_(std::move(value)) {} explicit RTCStatsMember(const RTCStatsMember& other) : RTCStatsMemberInterface(other.name_, other.is_defined_), value_(other.value_) {} diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index 842fca8cb2..7e6bcd3228 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -209,8 +209,9 @@ class RTCIceCandidateStats : public RTCStats { RTCStatsMember deleted; // = false protected: - RTCIceCandidateStats( - const std::string& id, int64_t timestamp_us, bool is_remote); + RTCIceCandidateStats(const std::string& id, + int64_t timestamp_us, + bool is_remote); RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote); }; @@ -258,9 +259,11 @@ class RTCMediaStreamTrackStats final : public RTCStats { public: WEBRTC_RTCSTATS_DECL(); - RTCMediaStreamTrackStats(const std::string& id, int64_t timestamp_us, + RTCMediaStreamTrackStats(const std::string& id, + int64_t timestamp_us, const char* kind); - RTCMediaStreamTrackStats(std::string&& id, int64_t timestamp_us, + RTCMediaStreamTrackStats(std::string&& id, + int64_t timestamp_us, const char* kind); RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other); ~RTCMediaStreamTrackStats() override; diff --git a/api/stats/rtcstatsreport.h b/api/stats/rtcstatsreport.h index 8485a08e08..f7410b39f7 100644 --- a/api/stats/rtcstatsreport.h +++ b/api/stats/rtcstatsreport.h @@ -76,7 +76,7 @@ class RTCStatsReport : public rtc::RefCountInterface { // Gets the subset of stats that are of type |T|, where |T| is any class // descending from |RTCStats|. - template + template std::vector GetStatsOfType() const { std::vector stats_of_type; for (const RTCStats& stats : *this) { diff --git a/api/statstypes.cc b/api/statstypes.cc index 49a00bb37e..ceba28d20f 100644 --- a/api/statstypes.cc +++ b/api/statstypes.cc @@ -98,8 +98,7 @@ class TypedIntId : public StatsReport::IdBase { } std::string ToString() const override { - return std::string(InternalTypeToString(type_)) + - kSeparator + + return std::string(InternalTypeToString(type_)) + kSeparator + rtc::ToString(id_); } @@ -109,7 +108,8 @@ class TypedIntId : public StatsReport::IdBase { class IdWithDirection : public TypedId { public: - IdWithDirection(StatsReport::StatsType type, const std::string& id, + IdWithDirection(StatsReport::StatsType type, + const std::string& id, StatsReport::Direction direction) : TypedId(type, id), direction_(direction) {} @@ -132,39 +132,34 @@ class IdWithDirection : public TypedId { class CandidateId : public TypedId { public: CandidateId(bool local, const std::string& id) - : TypedId(local ? - StatsReport::kStatsReportTypeIceLocalCandidate : - StatsReport::kStatsReportTypeIceRemoteCandidate, - id) { - } + : TypedId(local ? StatsReport::kStatsReportTypeIceLocalCandidate + : StatsReport::kStatsReportTypeIceRemoteCandidate, + id) {} - std::string ToString() const override { - return "Cand-" + id_; - } + std::string ToString() const override { return "Cand-" + id_; } }; class ComponentId : public StatsReport::IdBase { public: ComponentId(const std::string& content_name, int component) - : ComponentId(StatsReport::kStatsReportTypeComponent, content_name, - component) {} + : ComponentId(StatsReport::kStatsReportTypeComponent, + content_name, + component) {} bool Equals(const IdBase& other) const override { return IdBase::Equals(other) && - static_cast(other).component_ == component_ && - static_cast(other).content_name_ == content_name_; + static_cast(other).component_ == component_ && + static_cast(other).content_name_ == + content_name_; } - std::string ToString() const override { - return ToString("Channel-"); - } + std::string ToString() const override { return ToString("Channel-"); } protected: - ComponentId(StatsReport::StatsType type, const std::string& content_name, + ComponentId(StatsReport::StatsType type, + const std::string& content_name, int component) - : IdBase(type), - content_name_(content_name), - component_(component) {} + : IdBase(type), content_name_(content_name), component_(component) {} std::string ToString(const char* prefix) const { std::string ret(prefix); @@ -182,13 +177,14 @@ class ComponentId : public StatsReport::IdBase { class CandidatePairId : public ComponentId { public: CandidatePairId(const std::string& content_name, int component, int index) - : ComponentId(StatsReport::kStatsReportTypeCandidatePair, content_name, - component), + : ComponentId(StatsReport::kStatsReportTypeCandidatePair, + content_name, + component), index_(index) {} bool Equals(const IdBase& other) const override { return ComponentId::Equals(other) && - static_cast(other).index_ == index_; + static_cast(other).index_ == index_; } std::string ToString() const override { @@ -207,7 +203,9 @@ class CandidatePairId : public ComponentId { StatsReport::IdBase::IdBase(StatsType type) : type_(type) {} StatsReport::IdBase::~IdBase() {} -StatsReport::StatsType StatsReport::IdBase::type() const { return type_; } +StatsReport::StatsType StatsReport::IdBase::type() const { + return type_; +} bool StatsReport::IdBase::Equals(const IdBase& other) const { return other.type_ == type_; @@ -316,8 +314,8 @@ bool StatsReport::Value::operator==(const char* value) const { } bool StatsReport::Value::operator==(int64_t value) const { - return type_ == kInt ? value_.int_ == static_cast(value) : - (type_ == kInt64 ? value_.int64_ == value : false); + return type_ == kInt ? value_.int_ == static_cast(value) + : (type_ == kInt64 ? value_.int64_ == value : false); } bool StatsReport::Value::operator==(bool value) const { @@ -699,7 +697,9 @@ StatsReport::Id StatsReport::NewTypedIntId(StatsType type, int id) { // static StatsReport::Id StatsReport::NewIdWithDirection( - StatsType type, const std::string& id, StatsReport::Direction direction) { + StatsType type, + const std::string& id, + StatsReport::Direction direction) { return Id(new RefCountedObject(type, id, direction)); } @@ -709,16 +709,17 @@ StatsReport::Id StatsReport::NewCandidateId(bool local, const std::string& id) { } // static -StatsReport::Id StatsReport::NewComponentId( - const std::string& content_name, int component) { +StatsReport::Id StatsReport::NewComponentId(const std::string& content_name, + int component) { return Id(new RefCountedObject(content_name, component)); } // static -StatsReport::Id StatsReport::NewCandidatePairId( - const std::string& content_name, int component, int index) { - return Id(new RefCountedObject( - content_name, component, index)); +StatsReport::Id StatsReport::NewCandidatePairId(const std::string& content_name, + int component, + int index) { + return Id( + new RefCountedObject(content_name, component, index)); } const char* StatsReport::TypeToString() const { @@ -763,8 +764,7 @@ void StatsReport::AddBoolean(StatsReport::StatsValueName name, bool value) { values_[name] = ValuePtr(new Value(name, value)); } -void StatsReport::AddId(StatsReport::StatsValueName name, - const Id& value) { +void StatsReport::AddId(StatsReport::StatsValueName name, const Id& value) { const Value* found = FindValue(name); if (!found || !(*found == value)) values_[name] = ValuePtr(new Value(name, value)); @@ -775,8 +775,7 @@ const StatsReport::Value* StatsReport::FindValue(StatsValueName name) const { return it == values_.end() ? nullptr : it->second.get(); } -StatsCollection::StatsCollection() { -} +StatsCollection::StatsCollection() {} StatsCollection::~StatsCollection() { RTC_DCHECK(thread_checker_.CalledOnValidThread()); @@ -816,8 +815,9 @@ StatsReport* StatsCollection::FindOrAddNew(const StatsReport::Id& id) { StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(id.get()); - Container::iterator it = std::find_if(list_.begin(), list_.end(), - [&id](const StatsReport* r)->bool { return r->id()->Equals(id); }); + Container::iterator it = std::find_if( + list_.begin(), list_.end(), + [&id](const StatsReport* r) -> bool { return r->id()->Equals(id); }); if (it != end()) { StatsReport* report = new StatsReport((*it)->id()); delete *it; @@ -831,8 +831,9 @@ StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) { // will be returned. StatsReport* StatsCollection::Find(const StatsReport::Id& id) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); - Container::iterator it = std::find_if(list_.begin(), list_.end(), - [&id](const StatsReport* r)->bool { return r->id()->Equals(id); }); + Container::iterator it = std::find_if( + list_.begin(), list_.end(), + [&id](const StatsReport* r) -> bool { return r->id()->Equals(id); }); return it == list_.end() ? nullptr : *it; } diff --git a/api/statstypes.h b/api/statstypes.h index 4eac02df80..857b1afaa7 100644 --- a/api/statstypes.h +++ b/api/statstypes.h @@ -369,13 +369,14 @@ class StatsReport { static Id NewBandwidthEstimationId(); static Id NewTypedId(StatsType type, const std::string& id); static Id NewTypedIntId(StatsType type, int id); - static Id NewIdWithDirection( - StatsType type, const std::string& id, Direction direction); + static Id NewIdWithDirection(StatsType type, + const std::string& id, + Direction direction); static Id NewCandidateId(bool local, const std::string& id); - static Id NewComponentId( - const std::string& content_name, int component); - static Id NewCandidatePairId( - const std::string& content_name, int component, int index); + static Id NewComponentId(const std::string& content_name, int component); + static Id NewCandidatePairId(const std::string& content_name, + int component, + int index); const Id& id() const { return id_; } StatsType type() const { return id_->type(); } diff --git a/api/test/create_videocodec_test_fixture.cc b/api/test/create_videocodec_test_fixture.cc index 007d91b0cc..94b3dff8c9 100644 --- a/api/test/create_videocodec_test_fixture.cc +++ b/api/test/create_videocodec_test_fixture.cc @@ -22,13 +22,12 @@ namespace test { using Config = VideoCodecTestFixture::Config; -std::unique_ptr -CreateVideoCodecTestFixture(const Config& config) { +std::unique_ptr CreateVideoCodecTestFixture( + const Config& config) { return rtc::MakeUnique(config); } -std::unique_ptr -CreateVideoCodecTestFixture( +std::unique_ptr CreateVideoCodecTestFixture( const Config& config, std::unique_ptr decoder_factory, std::unique_ptr encoder_factory) { diff --git a/api/test/fakeconstraints.h b/api/test/fakeconstraints.h index 2010400aa4..429826cc93 100644 --- a/api/test/fakeconstraints.h +++ b/api/test/fakeconstraints.h @@ -21,16 +21,12 @@ namespace webrtc { class FakeConstraints : public webrtc::MediaConstraintsInterface { public: - FakeConstraints() { } - virtual ~FakeConstraints() { } + FakeConstraints() {} + virtual ~FakeConstraints() {} - virtual const Constraints& GetMandatory() const { - return mandatory_; - } + virtual const Constraints& GetMandatory() const { return mandatory_; } - virtual const Constraints& GetOptional() const { - return optional_; - } + virtual const Constraints& GetOptional() const { return optional_; } template void AddMandatory(const std::string& key, const T& value) { diff --git a/api/turncustomizer.h b/api/turncustomizer.h index 517abcc8f0..85c4e77c9c 100644 --- a/api/turncustomizer.h +++ b/api/turncustomizer.h @@ -18,7 +18,6 @@ class PortInterface; class StunMessage; } // namespace cricket - namespace webrtc { class TurnCustomizer { diff --git a/api/video/encoded_frame.cc b/api/video/encoded_frame.cc index a0ec1d63f5..ec8877cb36 100644 --- a/api/video/encoded_frame.cc +++ b/api/video/encoded_frame.cc @@ -13,9 +13,13 @@ namespace webrtc { namespace video_coding { -bool EncodedFrame::delayed_by_retransmission() const { return 0; } +bool EncodedFrame::delayed_by_retransmission() const { + return 0; +} -uint32_t EncodedFrame::Timestamp() const { return timestamp; } +uint32_t EncodedFrame::Timestamp() const { + return timestamp; +} } // namespace video_coding } // namespace webrtc diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc index 66071e1ec0..8d239f320d 100644 --- a/api/video/i420_buffer.cc +++ b/api/video/i420_buffer.cc @@ -34,8 +34,7 @@ int I420DataSize(int height, int stride_y, int stride_u, int stride_v) { } // namespace I420Buffer::I420Buffer(int width, int height) - : I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) { -} + : I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) {} I420Buffer::I420Buffer(int width, int height, @@ -47,9 +46,9 @@ I420Buffer::I420Buffer(int width, stride_y_(stride_y), stride_u_(stride_u), stride_v_(stride_v), - data_(static_cast(AlignedMalloc( - I420DataSize(height, stride_y, stride_u, stride_v), - kBufferAlignment))) { + data_(static_cast( + AlignedMalloc(I420DataSize(height, stride_y, stride_u, stride_v), + kBufferAlignment))) { RTC_DCHECK_GT(width, 0); RTC_DCHECK_GT(height, 0); RTC_DCHECK_GE(stride_y, width); @@ -57,8 +56,7 @@ I420Buffer::I420Buffer(int width, RTC_DCHECK_GE(stride_v, (width + 1) / 2); } -I420Buffer::~I420Buffer() { -} +I420Buffer::~I420Buffer() {} // static rtc::scoped_refptr I420Buffer::Create(int width, int height) { @@ -71,34 +69,34 @@ rtc::scoped_refptr I420Buffer::Create(int width, int stride_y, int stride_u, int stride_v) { - return new rtc::RefCountedObject( - width, height, stride_y, stride_u, stride_v); + return new rtc::RefCountedObject(width, height, stride_y, + stride_u, stride_v); } // static rtc::scoped_refptr I420Buffer::Copy( const I420BufferInterface& source) { - return Copy(source.width(), source.height(), - source.DataY(), source.StrideY(), - source.DataU(), source.StrideU(), - source.DataV(), source.StrideV()); + return Copy(source.width(), source.height(), source.DataY(), source.StrideY(), + source.DataU(), source.StrideU(), source.DataV(), + source.StrideV()); } // static -rtc::scoped_refptr I420Buffer::Copy( - int width, int height, - const uint8_t* data_y, int stride_y, - const uint8_t* data_u, int stride_u, - const uint8_t* data_v, int stride_v) { +rtc::scoped_refptr I420Buffer::Copy(int width, + int height, + const uint8_t* data_y, + int stride_y, + const uint8_t* data_u, + int stride_u, + const uint8_t* data_v, + int stride_v) { // Note: May use different strides than the input data. rtc::scoped_refptr buffer = Create(width, height); - RTC_CHECK_EQ(0, libyuv::I420Copy(data_y, stride_y, - data_u, stride_u, - data_v, stride_v, - buffer->MutableDataY(), buffer->StrideY(), - buffer->MutableDataU(), buffer->StrideU(), - buffer->MutableDataV(), buffer->StrideV(), - width, height)); + RTC_CHECK_EQ(0, libyuv::I420Copy(data_y, stride_y, data_u, stride_u, data_v, + stride_v, buffer->MutableDataY(), + buffer->StrideY(), buffer->MutableDataU(), + buffer->StrideU(), buffer->MutableDataV(), + buffer->StrideV(), width, height)); return buffer; } @@ -120,14 +118,13 @@ rtc::scoped_refptr I420Buffer::Rotate( rtc::scoped_refptr buffer = I420Buffer::Create(rotated_width, rotated_height); - RTC_CHECK_EQ(0, libyuv::I420Rotate( - src.DataY(), src.StrideY(), - src.DataU(), src.StrideU(), - src.DataV(), src.StrideV(), - buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(), - buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(), - src.width(), src.height(), - static_cast(rotation))); + RTC_CHECK_EQ(0, + libyuv::I420Rotate( + src.DataY(), src.StrideY(), src.DataU(), src.StrideU(), + src.DataV(), src.StrideV(), buffer->MutableDataY(), + buffer->StrideY(), buffer->MutableDataU(), buffer->StrideU(), + buffer->MutableDataV(), buffer->StrideV(), src.width(), + src.height(), static_cast(rotation))); return buffer; } @@ -179,9 +176,9 @@ uint8_t* I420Buffer::MutableDataV() { void I420Buffer::SetBlack(I420Buffer* buffer) { RTC_CHECK(libyuv::I420Rect(buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(), buffer->StrideU(), - buffer->MutableDataV(), buffer->StrideV(), - 0, 0, buffer->width(), buffer->height(), - 0, 128, 128) == 0); + buffer->MutableDataV(), buffer->StrideV(), 0, 0, + buffer->width(), buffer->height(), 0, 128, + 128) == 0); } void I420Buffer::CropAndScaleFrom(const I420BufferInterface& src, @@ -202,20 +199,16 @@ void I420Buffer::CropAndScaleFrom(const I420BufferInterface& src, offset_x = uv_offset_x * 2; offset_y = uv_offset_y * 2; - const uint8_t* y_plane = - src.DataY() + src.StrideY() * offset_y + offset_x; + const uint8_t* y_plane = src.DataY() + src.StrideY() * offset_y + offset_x; const uint8_t* u_plane = src.DataU() + src.StrideU() * uv_offset_y + uv_offset_x; const uint8_t* v_plane = src.DataV() + src.StrideV() * uv_offset_y + uv_offset_x; - int res = libyuv::I420Scale(y_plane, src.StrideY(), - u_plane, src.StrideU(), - v_plane, src.StrideV(), - crop_width, crop_height, - MutableDataY(), StrideY(), - MutableDataU(), StrideU(), - MutableDataV(), StrideV(), - width(), height(), libyuv::kFilterBox); + int res = + libyuv::I420Scale(y_plane, src.StrideY(), u_plane, src.StrideU(), v_plane, + src.StrideV(), crop_width, crop_height, MutableDataY(), + StrideY(), MutableDataU(), StrideU(), MutableDataV(), + StrideV(), width(), height(), libyuv::kFilterBox); RTC_DCHECK_EQ(res, 0); } @@ -226,10 +219,8 @@ void I420Buffer::CropAndScaleFrom(const I420BufferInterface& src) { const int crop_height = std::min(src.height(), height() * src.width() / width()); - CropAndScaleFrom( - src, - (src.width() - crop_width) / 2, (src.height() - crop_height) / 2, - crop_width, crop_height); + CropAndScaleFrom(src, (src.width() - crop_width) / 2, + (src.height() - crop_height) / 2, crop_width, crop_height); } void I420Buffer::ScaleFrom(const I420BufferInterface& src) { diff --git a/api/video/i420_buffer.h b/api/video/i420_buffer.h index 2bd37bd422..282b2426ca 100644 --- a/api/video/i420_buffer.h +++ b/api/video/i420_buffer.h @@ -36,11 +36,14 @@ class I420Buffer : public I420BufferInterface { return Copy(*buffer.GetI420()); } - static rtc::scoped_refptr Copy( - int width, int height, - const uint8_t* data_y, int stride_y, - const uint8_t* data_u, int stride_u, - const uint8_t* data_v, int stride_v); + static rtc::scoped_refptr Copy(int width, + int height, + const uint8_t* data_y, + int stride_y, + const uint8_t* data_u, + int stride_u, + const uint8_t* data_v, + int stride_v); // Returns a rotated copy of |src|. static rtc::scoped_refptr Rotate(const I420BufferInterface& src, diff --git a/api/video/video_content_type.cc b/api/video/video_content_type.cc index 149b4f9926..9ba3ece79b 100644 --- a/api/video/video_content_type.cc +++ b/api/video/video_content_type.cc @@ -68,19 +68,16 @@ bool SetSimulcastId(VideoContentType* content_type, uint8_t simulcast_id) { return true; } -uint8_t GetExperimentId( - const VideoContentType& content_type) { +uint8_t GetExperimentId(const VideoContentType& content_type) { return (static_cast(content_type) & kExperimentBitsMask) >> kExperimentShift; } -uint8_t GetSimulcastId( - const VideoContentType& content_type) { +uint8_t GetSimulcastId(const VideoContentType& content_type) { return (static_cast(content_type) & kSimulcastBitsMask) >> kSimulcastShift; } -bool IsScreenshare( - const VideoContentType& content_type) { +bool IsScreenshare(const VideoContentType& content_type) { return (static_cast(content_type) & kScreenshareBitsMask) > 0; } diff --git a/api/video/video_frame.h b/api/video/video_frame.h index bd5482025a..bd08346cb5 100644 --- a/api/video/video_frame.h +++ b/api/video/video_frame.h @@ -13,8 +13,8 @@ #include -#include "api/video/video_rotation.h" #include "api/video/video_frame_buffer.h" +#include "api/video/video_rotation.h" namespace webrtc { diff --git a/api/video_codecs/video_codec.cc b/api/video_codecs/video_codec.cc index c5d9ea96d6..6eccb00ebb 100644 --- a/api/video_codecs/video_codec.cc +++ b/api/video_codecs/video_codec.cc @@ -46,21 +46,18 @@ bool VideoCodecVP9::operator==(const VideoCodecVP9& other) const { bool VideoCodecH264::operator==(const VideoCodecH264& other) const { return (frameDroppingOn == other.frameDroppingOn && keyFrameInterval == other.keyFrameInterval && - spsLen == other.spsLen && - ppsLen == other.ppsLen && + spsLen == other.spsLen && ppsLen == other.ppsLen && profile == other.profile && (spsLen == 0 || memcmp(spsData, other.spsData, spsLen) == 0) && (ppsLen == 0 || memcmp(ppsData, other.ppsData, ppsLen) == 0)); } bool SpatialLayer::operator==(const SpatialLayer& other) const { - return (width == other.width && - height == other.height && + return (width == other.width && height == other.height && numberOfTemporalLayers == other.numberOfTemporalLayers && maxBitrate == other.maxBitrate && targetBitrate == other.targetBitrate && - minBitrate == other.minBitrate && - qpMax == other.qpMax && + minBitrate == other.minBitrate && qpMax == other.qpMax && active == other.active); } diff --git a/api/videosourceproxy.h b/api/videosourceproxy.h index f2d8be0681..0bb6d48389 100644 --- a/api/videosourceproxy.h +++ b/api/videosourceproxy.h @@ -11,8 +11,8 @@ #ifndef API_VIDEOSOURCEPROXY_H_ #define API_VIDEOSOURCEPROXY_H_ -#include "api/proxy.h" #include "api/mediastreaminterface.h" +#include "api/proxy.h" namespace webrtc { @@ -21,19 +21,19 @@ namespace webrtc { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. BEGIN_PROXY_MAP(VideoTrackSource) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_CONSTMETHOD0(SourceState, state) - PROXY_CONSTMETHOD0(bool, remote) - PROXY_CONSTMETHOD0(bool, is_screencast) - PROXY_CONSTMETHOD0(rtc::Optional, needs_denoising) - PROXY_METHOD1(bool, GetStats, Stats*) - PROXY_WORKER_METHOD2(void, - AddOrUpdateSink, - rtc::VideoSinkInterface*, - const rtc::VideoSinkWants&) - PROXY_WORKER_METHOD1(void, RemoveSink, rtc::VideoSinkInterface*) - PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) - PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_CONSTMETHOD0(SourceState, state) +PROXY_CONSTMETHOD0(bool, remote) +PROXY_CONSTMETHOD0(bool, is_screencast) +PROXY_CONSTMETHOD0(rtc::Optional, needs_denoising) +PROXY_METHOD1(bool, GetStats, Stats*) +PROXY_WORKER_METHOD2(void, + AddOrUpdateSink, + rtc::VideoSinkInterface*, + const rtc::VideoSinkWants&) +PROXY_WORKER_METHOD1(void, RemoveSink, rtc::VideoSinkInterface*) +PROXY_METHOD1(void, RegisterObserver, ObserverInterface*) +PROXY_METHOD1(void, UnregisterObserver, ObserverInterface*) END_PROXY_MAP() } // namespace webrtc diff --git a/audio/audio_level.cc b/audio/audio_level.cc index f1c5b68dc1..3b8df9778e 100644 --- a/audio/audio_level.cc +++ b/audio/audio_level.cc @@ -47,10 +47,12 @@ double AudioLevel::TotalDuration() const { void AudioLevel::ComputeLevel(const AudioFrame& audioFrame, double duration) { // Check speech level (works for 2 channels as well) - int16_t abs_value = audioFrame.muted() ? 0 : - WebRtcSpl_MaxAbsValueW16( - audioFrame.data(), - audioFrame.samples_per_channel_ * audioFrame.num_channels_); + int16_t abs_value = + audioFrame.muted() + ? 0 + : WebRtcSpl_MaxAbsValueW16( + audioFrame.data(), + audioFrame.samples_per_channel_ * audioFrame.num_channels_); // Protect member access using a lock since this method is called on a // dedicated audio thread in the RecordedDataIsAvailable() callback. diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index b52563bed1..6f43576eec 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -102,8 +102,7 @@ AudioReceiveStream::AudioReceiveStream( const rtc::scoped_refptr& audio_state, webrtc::RtcEventLog* event_log, std::unique_ptr channel_proxy) - : audio_state_(audio_state), - channel_proxy_(std::move(channel_proxy)) { + : audio_state_(audio_state), channel_proxy_(std::move(channel_proxy)) { RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.rtp.remote_ssrc; RTC_DCHECK(receiver_controller); RTC_DCHECK(packet_router); @@ -120,9 +119,8 @@ AudioReceiveStream::AudioReceiveStream( channel_proxy_->RegisterReceiverCongestionControlObjects(packet_router); // Register with transport. - rtp_stream_receiver_ = - receiver_controller->CreateReceiver(config.rtp.remote_ssrc, - channel_proxy_.get()); + rtp_stream_receiver_ = receiver_controller->CreateReceiver( + config.rtp.remote_ssrc, channel_proxy_.get()); ConfigureStream(this, config, true); } @@ -273,9 +271,7 @@ absl::optional AudioReceiveStream::GetInfo() const { return absl::nullopt; } if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs, - &info.capture_time_ntp_frac, - nullptr, - nullptr, + &info.capture_time_ntp_frac, nullptr, nullptr, &info.capture_time_source_clock) != 0) { return absl::nullopt; } @@ -329,8 +325,8 @@ const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { return config_; } -const AudioSendStream* - AudioReceiveStream::GetAssociatedSendStreamForTesting() const { +const AudioSendStream* AudioReceiveStream::GetAssociatedSendStreamForTesting() + const { RTC_DCHECK_RUN_ON(&worker_thread_checker_); return associated_send_stream_; } diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc index 07a23e320b..51635f6e9c 100644 --- a/audio/audio_receive_stream_unittest.cc +++ b/audio/audio_receive_stream_unittest.cc @@ -59,18 +59,16 @@ const unsigned int kSpeechOutputLevel = 99; const double kTotalOutputEnergy = 0.25; const double kTotalOutputDuration = 0.5; -const CallStatistics kCallStats = { - 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; -const CodecInst kCodecInst = { - 123, "codec_name_recv", 96000, -187, 0, -103}; +const CallStatistics kCallStats = {345, 678, 901, 234, -12, + 3456, 7890, 567, 890, 123}; +const CodecInst kCodecInst = {123, "codec_name_recv", 96000, -187, 0, -103}; const NetworkStatistics kNetworkStats = { 123, 456, false, 789012, 3456, 123, 456, 0, {}, 789, 12, 345, 678, 901, 0, -1, -1, -1, -1, -1, 0}; const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); struct ConfigHelper { - ConfigHelper() - : ConfigHelper(new rtc::RefCountedObject()) {} + ConfigHelper() : ConfigHelper(new rtc::RefCountedObject()) {} explicit ConfigHelper(rtc::scoped_refptr audio_mixer) : audio_mixer_(audio_mixer) { @@ -88,23 +86,21 @@ struct ConfigHelper { EXPECT_CALL(*channel_proxy_, SetRemoteSSRC(kRemoteSsrc)).Times(1); EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 15)).Times(1); EXPECT_CALL(*channel_proxy_, - RegisterReceiverCongestionControlObjects(&packet_router_)) - .Times(1); + RegisterReceiverCongestionControlObjects(&packet_router_)) + .Times(1); EXPECT_CALL(*channel_proxy_, ResetReceiverCongestionControlObjects()) .Times(1); EXPECT_CALL(*channel_proxy_, RegisterTransport(nullptr)).Times(2); testing::Expectation expect_set = - EXPECT_CALL(*channel_proxy_, SetRtcEventLog(&event_log_)) - .Times(1); + EXPECT_CALL(*channel_proxy_, SetRtcEventLog(&event_log_)).Times(1); EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) .Times(1) .After(expect_set); EXPECT_CALL(*channel_proxy_, DisassociateSendChannel()).Times(1); EXPECT_CALL(*channel_proxy_, SetReceiveCodecs(_)) - .WillRepeatedly( - Invoke([](const std::map& codecs) { - EXPECT_THAT(codecs, testing::IsEmpty()); - })); + .WillRepeatedly(Invoke([](const std::map& codecs) { + EXPECT_THAT(codecs, testing::IsEmpty()); + })); stream_config_.rtp.local_ssrc = kLocalSsrc; stream_config_.rtp.remote_ssrc = kRemoteSsrc; @@ -120,11 +116,8 @@ struct ConfigHelper { std::unique_ptr CreateAudioReceiveStream() { return std::unique_ptr( new internal::AudioReceiveStream( - &rtp_stream_receiver_controller_, - &packet_router_, - stream_config_, - audio_state_, - &event_log_, + &rtp_stream_receiver_controller_, &packet_router_, stream_config_, + audio_state_, &event_log_, std::unique_ptr(channel_proxy_))); } @@ -323,7 +316,7 @@ TEST(AudioReceiveStreamTest, SetGain) { ConfigHelper helper; auto recv_stream = helper.CreateAudioReceiveStream(); EXPECT_CALL(*helper.channel_proxy(), - SetChannelOutputVolumeScaling(FloatEq(0.765f))); + SetChannelOutputVolumeScaling(FloatEq(0.765f))); recv_stream->SetGain(0.765f); } @@ -371,10 +364,10 @@ TEST(AudioReceiveStreamTest, ReconfigureWithUpdatedConfig) { new_config.rtp.nack.rtp_history_ms = 300 + 20; new_config.rtp.extensions.clear(); new_config.rtp.extensions.push_back( - RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId + 1)); - new_config.rtp.extensions.push_back(RtpExtension( - RtpExtension::kTransportSequenceNumberUri, - kTransportSequenceNumberId + 1)); + RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId + 1)); + new_config.rtp.extensions.push_back( + RtpExtension(RtpExtension::kTransportSequenceNumberUri, + kTransportSequenceNumberId + 1)); new_config.decoder_map.emplace(1, SdpAudioFormat("foo", 8000, 1)); MockVoEChannelProxy& channel_proxy = *helper.channel_proxy(); diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 8ed78eb461..d2e26cdc95 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -218,8 +218,7 @@ void AudioSendStream::ConfigureStream( new_config.rtp.nack.rtp_history_ms / 20); } - if (first_time || - new_config.send_transport != old_config.send_transport) { + if (first_time || new_config.send_transport != old_config.send_transport) { if (old_config.send_transport) { channel_proxy->RegisterTransport(nullptr); } @@ -326,7 +325,8 @@ void AudioSendStream::SendAudioData(std::unique_ptr audio_frame) { } bool AudioSendStream::SendTelephoneEvent(int payload_type, - int payload_frequency, int event, + int payload_frequency, + int event, int duration_ms) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel_proxy_->SetSendTelephoneEventPayloadType(payload_type, @@ -415,8 +415,7 @@ uint32_t AudioSendStream::OnBitrateUpdated(uint32_t bitrate_bps, if (bitrate_bps == 0) { bitrate_bps = config_.min_bitrate_bps; } - RTC_DCHECK_GE(bitrate_bps, - static_cast(config_.min_bitrate_bps)); + RTC_DCHECK_GE(bitrate_bps, static_cast(config_.min_bitrate_bps)); // The bitrate allocator might allocate an higher than max configured bitrate // if there is room, to allow for, as example, extra FEC. Ignore that for now. const uint32_t max_bitrate_bps = config_.max_bitrate_bps; diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index efc9c0e8fe..ba87202bbe 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -70,7 +70,9 @@ class AudioSendStream final : public webrtc::AudioSendStream, void Start() override; void Stop() override; void SendAudioData(std::unique_ptr audio_frame) override; - bool SendTelephoneEvent(int payload_type, int payload_frequency, int event, + bool SendTelephoneEvent(int payload_type, + int payload_frequency, + int event, int duration_ms) override; void SetMuted(bool muted) override; webrtc::AudioSendStream::Stats GetStats() const override; diff --git a/audio/audio_send_stream_tests.cc b/audio/audio_send_stream_tests.cc index 3f96c3350f..7deeff3b4d 100644 --- a/audio/audio_send_stream_tests.cc +++ b/audio/audio_send_stream_tests.cc @@ -20,15 +20,9 @@ class AudioSendTest : public SendTest { public: AudioSendTest() : SendTest(CallTest::kDefaultTimeoutMs) {} - size_t GetNumVideoStreams() const override { - return 0; - } - size_t GetNumAudioStreams() const override { - return 1; - } - size_t GetNumFlexfecStreams() const override { - return 0; - } + size_t GetNumVideoStreams() const override { return 0; } + size_t GetNumAudioStreams() const override { return 1; } + size_t GetNumFlexfecStreams() const override { return 0; } }; } // namespace diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index d0bc45f4f7..f84aaaf1c9 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -56,8 +56,8 @@ const double kEchoReturnLoss = -65; const double kEchoReturnLossEnhancement = 101; const double kResidualEchoLikelihood = -1.0f; const double kResidualEchoLikelihoodMax = 23.0f; -const CallStatistics kCallStats = { - 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; +const CallStatistics kCallStats = {1345, 1678, 1901, 1234, 112, + 13456, 17890, 1567, -1890, -1123}; const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; const int kTelephoneEventPayloadType = 123; const int kTelephoneEventPayloadFrequency = 65432; @@ -181,9 +181,8 @@ struct ConfigHelper { TimeInterval* active_lifetime() { return &active_lifetime_; } static void AddBweToConfig(AudioSendStream::Config* config) { - config->rtp.extensions.push_back( - RtpExtension(RtpExtension::kTransportSequenceNumberUri, - kTransportSequenceNumberId)); + config->rtp.extensions.push_back(RtpExtension( + RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); config->send_codec_spec->transport_cc_enabled = true; } @@ -254,13 +253,14 @@ struct ConfigHelper { void SetupMockForSendTelephoneEvent() { EXPECT_TRUE(channel_proxy_); - EXPECT_CALL(*channel_proxy_, - SetSendTelephoneEventPayloadType(kTelephoneEventPayloadType, - kTelephoneEventPayloadFrequency)) - .WillOnce(Return(true)); - EXPECT_CALL(*channel_proxy_, + EXPECT_CALL(*channel_proxy_, SetSendTelephoneEventPayloadType( + kTelephoneEventPayloadType, + kTelephoneEventPayloadFrequency)) + .WillOnce(Return(true)); + EXPECT_CALL( + *channel_proxy_, SendTelephoneEventOutband(kTelephoneEventCode, kTelephoneEventDuration)) - .WillOnce(Return(true)); + .WillOnce(Return(true)); } void SetupMockForGetStats() { @@ -355,9 +355,9 @@ TEST(AudioSendStreamTest, SendTelephoneEvent) { ConfigHelper helper(false, true); auto send_stream = helper.CreateAudioSendStream(); helper.SetupMockForSendTelephoneEvent(); - EXPECT_TRUE(send_stream->SendTelephoneEvent(kTelephoneEventPayloadType, - kTelephoneEventPayloadFrequency, kTelephoneEventCode, - kTelephoneEventDuration)); + EXPECT_TRUE(send_stream->SendTelephoneEvent( + kTelephoneEventPayloadType, kTelephoneEventPayloadFrequency, + kTelephoneEventCode, kTelephoneEventDuration)); } TEST(AudioSendStreamTest, SetMuted) { @@ -518,7 +518,7 @@ TEST(AudioSendStreamTest, ReconfigureTransportCcResetsFirst) { EXPECT_CALL(*helper.channel_proxy(), ResetSenderCongestionControlObjects()) .Times(1); EXPECT_CALL(*helper.channel_proxy(), RegisterSenderCongestionControlObjects( - helper.transport(), Ne(nullptr))) + helper.transport(), Ne(nullptr))) .Times(1); } send_stream->Reconfigure(new_config); diff --git a/audio/audio_state.cc b/audio/audio_state.cc index d738884e8d..bff818e926 100644 --- a/audio/audio_state.cc +++ b/audio/audio_state.cc @@ -27,8 +27,7 @@ namespace internal { AudioState::AudioState(const AudioState::Config& config) : config_(config), - audio_transport_(config_.audio_mixer, - config_.audio_processing.get()) { + audio_transport_(config_.audio_mixer, config_.audio_processing.get()) { process_thread_checker_.DetachFromThread(); RTC_DCHECK(config_.audio_mixer); RTC_DCHECK(config_.audio_device_module); @@ -50,7 +49,7 @@ void AudioState::AddReceivingStream(webrtc::AudioReceiveStream* stream) { RTC_DCHECK_EQ(0, receiving_streams_.count(stream)); receiving_streams_.insert(stream); if (!config_.audio_mixer->AddSource( - static_cast(stream))) { + static_cast(stream))) { RTC_DLOG(LS_ERROR) << "Failed to add source to mixer."; } @@ -79,7 +78,8 @@ void AudioState::RemoveReceivingStream(webrtc::AudioReceiveStream* stream) { } void AudioState::AddSendingStream(webrtc::AudioSendStream* stream, - int sample_rate_hz, size_t num_channels) { + int sample_rate_hz, + size_t num_channels) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); auto& properties = sending_streams_[stream]; properties.sample_rate_hz = sample_rate_hz; @@ -121,8 +121,7 @@ void AudioState::SetPlayout(bool enabled) { } } else { config_.audio_device_module->StopPlayout(); - null_audio_poller_ = - rtc::MakeUnique(&audio_transport_); + null_audio_poller_ = rtc::MakeUnique(&audio_transport_); } } } diff --git a/audio/audio_state.h b/audio/audio_state.h index d4e4e3fd3c..689534b0ee 100644 --- a/audio/audio_state.h +++ b/audio/audio_state.h @@ -39,9 +39,7 @@ class AudioState final : public webrtc::AudioState { RTC_DCHECK(config_.audio_processing); return config_.audio_processing.get(); } - AudioTransport* audio_transport() override { - return &audio_transport_; - } + AudioTransport* audio_transport() override { return &audio_transport_; } void SetPlayout(bool enabled) override; void SetRecording(bool enabled) override; @@ -60,7 +58,8 @@ class AudioState final : public webrtc::AudioState { void RemoveReceivingStream(webrtc::AudioReceiveStream* stream); void AddSendingStream(webrtc::AudioSendStream* stream, - int sample_rate_hz, size_t num_channels); + int sample_rate_hz, + size_t num_channels); void RemoveSendingStream(webrtc::AudioSendStream* stream); private: diff --git a/audio/audio_state_unittest.cc b/audio/audio_state_unittest.cc index e825ec6116..dc622df00d 100644 --- a/audio/audio_state_unittest.cc +++ b/audio/audio_state_unittest.cc @@ -71,8 +71,7 @@ std::vector Create10msTestData(int sample_rate_hz, const float inc = (2 * 3.14159265f * 1000) / sample_rate_hz; float w = 0.f; for (int i = 0; i < samples_per_channel; ++i) { - audio_data[i * num_channels] = - static_cast(32767.f * std::sin(w)); + audio_data[i * num_channels] = static_cast(32767.f * std::sin(w)); w += inc; } return audio_data; @@ -111,16 +110,18 @@ TEST(AudioStateTest, RecordedAudioArrivesAtSingleStream) { MockAudioSendStream stream; audio_state->AddSendingStream(&stream, 8000, 2); - EXPECT_CALL(stream, SendAudioDataForMock(testing::AllOf( - testing::Field(&AudioFrame::sample_rate_hz_, testing::Eq(8000)), - testing::Field(&AudioFrame::num_channels_, testing::Eq(2u))))) - .WillOnce( - // Verify that channels are not swapped by default. - testing::Invoke([](AudioFrame* audio_frame) { - auto levels = ComputeChannelLevels(audio_frame); - EXPECT_LT(0u, levels[0]); - EXPECT_EQ(0u, levels[1]); - })); + EXPECT_CALL( + stream, + SendAudioDataForMock(testing::AllOf( + testing::Field(&AudioFrame::sample_rate_hz_, testing::Eq(8000)), + testing::Field(&AudioFrame::num_channels_, testing::Eq(2u))))) + .WillOnce( + // Verify that channels are not swapped by default. + testing::Invoke([](AudioFrame* audio_frame) { + auto levels = ComputeChannelLevels(audio_frame); + EXPECT_LT(0u, levels[0]); + EXPECT_EQ(0u, levels[1]); + })); MockAudioProcessing* ap = static_cast(audio_state->audio_processing()); EXPECT_CALL(*ap, set_stream_delay_ms(0)); @@ -132,8 +133,8 @@ TEST(AudioStateTest, RecordedAudioArrivesAtSingleStream) { auto audio_data = Create10msTestData(kSampleRate, kNumChannels); uint32_t new_mic_level = 667; audio_state->audio_transport()->RecordedDataIsAvailable( - &audio_data[0], kSampleRate / 100, kNumChannels * 2, - kNumChannels, kSampleRate, 0, 0, 0, false, new_mic_level); + &audio_data[0], kSampleRate / 100, kNumChannels * 2, kNumChannels, + kSampleRate, 0, 0, 0, false, new_mic_level); EXPECT_EQ(667u, new_mic_level); audio_state->RemoveSendingStream(&stream); @@ -149,24 +150,28 @@ TEST(AudioStateTest, RecordedAudioArrivesAtMultipleStreams) { audio_state->AddSendingStream(&stream_1, 8001, 2); audio_state->AddSendingStream(&stream_2, 32000, 1); - EXPECT_CALL(stream_1, SendAudioDataForMock(testing::AllOf( - testing::Field(&AudioFrame::sample_rate_hz_, testing::Eq(16000)), - testing::Field(&AudioFrame::num_channels_, testing::Eq(1u))))) - .WillOnce( - // Verify that there is output signal. - testing::Invoke([](AudioFrame* audio_frame) { - auto levels = ComputeChannelLevels(audio_frame); - EXPECT_LT(0u, levels[0]); - })); - EXPECT_CALL(stream_2, SendAudioDataForMock(testing::AllOf( - testing::Field(&AudioFrame::sample_rate_hz_, testing::Eq(16000)), - testing::Field(&AudioFrame::num_channels_, testing::Eq(1u))))) - .WillOnce( - // Verify that there is output signal. - testing::Invoke([](AudioFrame* audio_frame) { - auto levels = ComputeChannelLevels(audio_frame); - EXPECT_LT(0u, levels[0]); - })); + EXPECT_CALL( + stream_1, + SendAudioDataForMock(testing::AllOf( + testing::Field(&AudioFrame::sample_rate_hz_, testing::Eq(16000)), + testing::Field(&AudioFrame::num_channels_, testing::Eq(1u))))) + .WillOnce( + // Verify that there is output signal. + testing::Invoke([](AudioFrame* audio_frame) { + auto levels = ComputeChannelLevels(audio_frame); + EXPECT_LT(0u, levels[0]); + })); + EXPECT_CALL( + stream_2, + SendAudioDataForMock(testing::AllOf( + testing::Field(&AudioFrame::sample_rate_hz_, testing::Eq(16000)), + testing::Field(&AudioFrame::num_channels_, testing::Eq(1u))))) + .WillOnce( + // Verify that there is output signal. + testing::Invoke([](AudioFrame* audio_frame) { + auto levels = ComputeChannelLevels(audio_frame); + EXPECT_LT(0u, levels[0]); + })); MockAudioProcessing* ap = static_cast(audio_state->audio_processing()); EXPECT_CALL(*ap, set_stream_delay_ms(5)); @@ -178,8 +183,8 @@ TEST(AudioStateTest, RecordedAudioArrivesAtMultipleStreams) { auto audio_data = Create10msTestData(kSampleRate, kNumChannels); uint32_t new_mic_level = 667; audio_state->audio_transport()->RecordedDataIsAvailable( - &audio_data[0], kSampleRate / 100, kNumChannels * 2, - kNumChannels, kSampleRate, 5, 0, 0, true, new_mic_level); + &audio_data[0], kSampleRate / 100, kNumChannels * 2, kNumChannels, + kSampleRate, 5, 0, 0, true, new_mic_level); EXPECT_EQ(667u, new_mic_level); audio_state->RemoveSendingStream(&stream_1); @@ -210,8 +215,8 @@ TEST(AudioStateTest, EnableChannelSwap) { auto audio_data = Create10msTestData(kSampleRate, kNumChannels); uint32_t new_mic_level = 667; audio_state->audio_transport()->RecordedDataIsAvailable( - &audio_data[0], kSampleRate / 100, kNumChannels * 2, - kNumChannels, kSampleRate, 0, 0, 0, false, new_mic_level); + &audio_data[0], kSampleRate / 100, kNumChannels * 2, kNumChannels, + kSampleRate, 0, 0, 0, false, new_mic_level); EXPECT_EQ(667u, new_mic_level); audio_state->RemoveSendingStream(&stream); @@ -230,8 +235,8 @@ TEST(AudioStateTest, InputLevelStats) { auto audio_data = Create10msSilentTestData(kSampleRate, kNumChannels); uint32_t new_mic_level = 667; audio_state->audio_transport()->RecordedDataIsAvailable( - &audio_data[0], kSampleRate / 100, kNumChannels * 2, - kNumChannels, kSampleRate, 0, 0, 0, false, new_mic_level); + &audio_data[0], kSampleRate / 100, kNumChannels * 2, kNumChannels, + kSampleRate, 0, 0, 0, false, new_mic_level); auto stats = audio_state->GetAudioInputStats(); EXPECT_EQ(0, stats.audio_level); EXPECT_THAT(stats.total_energy, testing::DoubleEq(0.0)); @@ -244,8 +249,8 @@ TEST(AudioStateTest, InputLevelStats) { uint32_t new_mic_level = 667; for (int i = 0; i < 10; ++i) { audio_state->audio_transport()->RecordedDataIsAvailable( - &audio_data[0], kSampleRate / 100, kNumChannels * 2, - kNumChannels, kSampleRate, 0, 0, 0, false, new_mic_level); + &audio_data[0], kSampleRate / 100, kNumChannels * 2, kNumChannels, + kSampleRate, 0, 0, 0, false, new_mic_level); } auto stats = audio_state->GetAudioInputStats(); EXPECT_EQ(32767, stats.audio_level); diff --git a/audio/audio_transport_impl.cc b/audio/audio_transport_impl.cc index f9b0311ccb..44e95aa909 100644 --- a/audio/audio_transport_impl.cc +++ b/audio/audio_transport_impl.cc @@ -83,8 +83,7 @@ int Resample(const AudioFrame& frame, AudioTransportImpl::AudioTransportImpl(AudioMixer* mixer, AudioProcessing* audio_processing) - : audio_processing_(audio_processing), - mixer_(mixer) { + : audio_processing_(audio_processing), mixer_(mixer) { RTC_DCHECK(mixer); RTC_DCHECK(audio_processing); } @@ -125,9 +124,8 @@ int32_t AudioTransportImpl::RecordedDataIsAvailable( } std::unique_ptr audio_frame(new AudioFrame()); - InitializeCaptureFrame(sample_rate, send_sample_rate_hz, - number_of_channels, send_num_channels, - audio_frame.get()); + InitializeCaptureFrame(sample_rate, send_sample_rate_hz, number_of_channels, + send_num_channels, audio_frame.get()); voe::RemixAndResample(static_cast(audio_data), number_of_frames, number_of_channels, sample_rate, &capture_resampler_, audio_frame.get()); @@ -175,13 +173,13 @@ int32_t AudioTransportImpl::RecordedDataIsAvailable( // Mix all received streams, feed the result to the AudioProcessing module, then // resample the result to the requested output rate. int32_t AudioTransportImpl::NeedMorePlayData(const size_t nSamples, - const size_t nBytesPerSample, - const size_t nChannels, - const uint32_t samplesPerSec, - void* audioSamples, - size_t& nSamplesOut, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms) { + const size_t nBytesPerSample, + const size_t nChannels, + const uint32_t samplesPerSec, + void* audioSamples, + size_t& nSamplesOut, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) { RTC_DCHECK_EQ(sizeof(int16_t) * nChannels, nBytesPerSample); RTC_DCHECK_GE(nChannels, 1); RTC_DCHECK_LE(nChannels, 2); @@ -210,12 +208,12 @@ int32_t AudioTransportImpl::NeedMorePlayData(const size_t nSamples, // Used by Chromium - same as NeedMorePlayData() but because Chrome has its // own APM instance, does not call audio_processing_->ProcessReverseStream(). void AudioTransportImpl::PullRenderData(int bits_per_sample, - int sample_rate, - size_t number_of_channels, - size_t number_of_frames, - void* audio_data, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms) { + int sample_rate, + size_t number_of_channels, + size_t number_of_frames, + void* audio_data, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) { RTC_DCHECK_EQ(bits_per_sample, 16); RTC_DCHECK_GE(number_of_channels, 1); RTC_DCHECK_LE(number_of_channels, 2); @@ -237,7 +235,8 @@ void AudioTransportImpl::PullRenderData(int bits_per_sample, } void AudioTransportImpl::UpdateSendingStreams( - std::vector streams, int send_sample_rate_hz, + std::vector streams, + int send_sample_rate_hz, size_t send_num_channels) { rtc::CritScope lock(&capture_lock_); sending_streams_ = std::move(streams); diff --git a/audio/audio_transport_impl.h b/audio/audio_transport_impl.h index 4e6e0470f1..3a3155cdbd 100644 --- a/audio/audio_transport_impl.h +++ b/audio/audio_transport_impl.h @@ -30,8 +30,7 @@ class AudioSendStream; class AudioTransportImpl : public AudioTransport { public: - AudioTransportImpl(AudioMixer* mixer, - AudioProcessing* audio_processing); + AudioTransportImpl(AudioMixer* mixer, AudioProcessing* audio_processing); ~AudioTransportImpl() override; int32_t RecordedDataIsAvailable(const void* audioSamples, @@ -63,12 +62,11 @@ class AudioTransportImpl : public AudioTransport { int64_t* ntp_time_ms) override; void UpdateSendingStreams(std::vector streams, - int send_sample_rate_hz, size_t send_num_channels); + int send_sample_rate_hz, + size_t send_num_channels); void SetStereoChannelSwapping(bool enable); bool typing_noise_detected() const; - const voe::AudioLevel& audio_level() const { - return audio_level_; - } + const voe::AudioLevel& audio_level() const { return audio_level_; } private: // Shared. diff --git a/audio/channel.cc b/audio/channel.cc index ecde1725bd..7eafd52a4a 100644 --- a/audio/channel.cc +++ b/audio/channel.cc @@ -20,8 +20,8 @@ #include "api/array_view.h" #include "audio/utility/audio_frame_operations.h" #include "call/rtp_transport_controller_send_interface.h" -#include "logging/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_audio_playout.h" +#include "logging/rtc_event_log/rtc_event_log.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "modules/audio_coding/codecs/audio_format_conversion.h" #include "modules/audio_device/include/audio_device.h" @@ -943,9 +943,8 @@ int32_t Channel::ReceivedRTCPPacket(const uint8_t* data, size_t length) { uint32_t ntp_secs = 0; uint32_t ntp_frac = 0; uint32_t rtp_timestamp = 0; - if (0 != - _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, - &rtp_timestamp)) { + if (0 != _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, + &rtp_timestamp)) { // Waiting for RTCP. return 0; } @@ -993,7 +992,7 @@ int Channel::SendTelephoneEventOutband(int event, int duration_ms) { return -1; } if (_rtpRtcpModule->SendTelephoneEventOutband( - event, duration_ms, kTelephoneEventAttenuationdB) != 0) { + event, duration_ms, kTelephoneEventAttenuationdB) != 0) { RTC_DLOG(LS_ERROR) << "SendTelephoneEventOutband() failed to send event"; return -1; } diff --git a/audio/channel_proxy.cc b/audio/channel_proxy.cc index e37d9d78fe..bac681f3b7 100644 --- a/audio/channel_proxy.cc +++ b/audio/channel_proxy.cc @@ -22,8 +22,8 @@ namespace webrtc { namespace voe { ChannelProxy::ChannelProxy() {} -ChannelProxy::ChannelProxy(std::unique_ptr channel) : - channel_(std::move(channel)) { +ChannelProxy::ChannelProxy(std::unique_ptr channel) + : channel_(std::move(channel)) { RTC_DCHECK(channel_); module_process_thread_checker_.DetachFromThread(); } @@ -92,7 +92,7 @@ void ChannelProxy::RegisterSenderCongestionControlObjects( RtcpBandwidthObserver* bandwidth_observer) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel_->RegisterSenderCongestionControlObjects(transport, - bandwidth_observer); + bandwidth_observer); } void ChannelProxy::RegisterReceiverCongestionControlObjects( @@ -172,7 +172,7 @@ bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type, int payload_frequency) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel_->SetSendTelephoneEventPayloadType(payload_type, - payload_frequency) == 0; + payload_frequency) == 0; } bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) { diff --git a/audio/channel_proxy.h b/audio/channel_proxy.h index d285042630..00298512eb 100644 --- a/audio/channel_proxy.h +++ b/audio/channel_proxy.h @@ -108,8 +108,7 @@ class ChannelProxy : public RtpPacketSinkInterface { virtual void SetTransportOverhead(int transport_overhead_per_packet); virtual void AssociateSendChannel(const ChannelProxy& send_channel_proxy); virtual void DisassociateSendChannel(); - virtual void GetRtpRtcp(RtpRtcp** rtp_rtcp, - RtpReceiver** rtp_receiver) const; + virtual void GetRtpRtcp(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver) const; virtual uint32_t GetPlayoutTimestamp() const; virtual void SetMinimumPlayoutDelay(int delay_ms); virtual bool GetRecCodec(CodecInst* codec_inst) const; diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index 186a108d9d..7396dd1840 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -31,8 +31,7 @@ class MockVoEChannelProxy : public voe::ChannelProxy { return SetEncoderForMock(payload_type, &encoder); } MOCK_METHOD2(SetEncoderForMock, - bool(int payload_type, - std::unique_ptr* encoder)); + bool(int payload_type, std::unique_ptr* encoder)); MOCK_METHOD1( ModifyEncoder, void(rtc::FunctionView*)> modifier)); @@ -59,8 +58,8 @@ class MockVoEChannelProxy : public voe::ChannelProxy { MOCK_CONST_METHOD0(GetTotalOutputEnergy, double()); MOCK_CONST_METHOD0(GetTotalOutputDuration, double()); MOCK_CONST_METHOD0(GetDelayEstimate, uint32_t()); - MOCK_METHOD2(SetSendTelephoneEventPayloadType, bool(int payload_type, - int payload_frequency)); + MOCK_METHOD2(SetSendTelephoneEventPayloadType, + bool(int payload_type, int payload_frequency)); MOCK_METHOD2(SendTelephoneEventOutband, bool(int event, int duration_ms)); MOCK_METHOD2(SetBitrate, void(int bitrate_bps, int64_t probing_interval_ms)); MOCK_METHOD1(SetSink, void(AudioSinkInterface* sink)); @@ -71,8 +70,8 @@ class MockVoEChannelProxy : public voe::ChannelProxy { MOCK_METHOD1(SetChannelOutputVolumeScaling, void(float scaling)); MOCK_METHOD1(SetRtcEventLog, void(RtcEventLog* event_log)); MOCK_METHOD2(GetAudioFrameWithInfo, - AudioMixer::Source::AudioFrameInfo(int sample_rate_hz, - AudioFrame* audio_frame)); + AudioMixer::Source::AudioFrameInfo(int sample_rate_hz, + AudioFrame* audio_frame)); MOCK_CONST_METHOD0(PreferredSampleRate, int()); // GMock doesn't like move-only types, like std::unique_ptr. virtual void ProcessAndEncodeAudio(std::unique_ptr audio_frame) { @@ -84,8 +83,8 @@ class MockVoEChannelProxy : public voe::ChannelProxy { MOCK_METHOD1(AssociateSendChannel, void(const ChannelProxy& send_channel_proxy)); MOCK_METHOD0(DisassociateSendChannel, void()); - MOCK_CONST_METHOD2(GetRtpRtcp, void(RtpRtcp** rtp_rtcp, - RtpReceiver** rtp_receiver)); + MOCK_CONST_METHOD2(GetRtpRtcp, + void(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver)); MOCK_CONST_METHOD0(GetPlayoutTimestamp, uint32_t()); MOCK_METHOD1(SetMinimumPlayoutDelay, void(int delay_ms)); MOCK_CONST_METHOD1(GetRecCodec, bool(CodecInst* codec_inst)); diff --git a/audio/remix_resample.cc b/audio/remix_resample.cc index 69038cd0c9..eda70c7c37 100644 --- a/audio/remix_resample.cc +++ b/audio/remix_resample.cc @@ -68,9 +68,9 @@ void RemixAndResample(const int16_t* src_data, // how much to zero here; or 2) make resampler accept a hint that the input is // zeroed. const size_t src_length = samples_per_channel * audio_ptr_num_channels; - int out_length = resampler->Resample(audio_ptr, src_length, - dst_frame->mutable_data(), - AudioFrame::kMaxDataSizeSamples); + int out_length = + resampler->Resample(audio_ptr, src_length, dst_frame->mutable_data(), + AudioFrame::kMaxDataSizeSamples); if (out_length == -1) { FATAL() << "Resample failed: audio_ptr = " << audio_ptr << ", src_length = " << src_length diff --git a/audio/remix_resample_unittest.cc b/audio/remix_resample_unittest.cc index 1d8cce7cc4..f1fb5f7dd0 100644 --- a/audio/remix_resample_unittest.cc +++ b/audio/remix_resample_unittest.cc @@ -113,7 +113,8 @@ void VerifyParams(const AudioFrame& ref_frame, const AudioFrame& test_frame) { // Computes the best SNR based on the error between |ref_frame| and // |test_frame|. It allows for up to a |max_delay| in samples between the // signals to compensate for the resampling delay. -float ComputeSNR(const AudioFrame& ref_frame, const AudioFrame& test_frame, +float ComputeSNR(const AudioFrame& ref_frame, + const AudioFrame& test_frame, size_t max_delay) { VerifyParams(ref_frame, test_frame); float best_snr = 0; @@ -123,8 +124,9 @@ float ComputeSNR(const AudioFrame& ref_frame, const AudioFrame& test_frame, float variance = 0; const int16_t* ref_frame_data = ref_frame.data(); const int16_t* test_frame_data = test_frame.data(); - for (size_t i = 0; i < ref_frame.samples_per_channel_ * - ref_frame.num_channels_ - delay; i++) { + for (size_t i = 0; + i < ref_frame.samples_per_channel_ * ref_frame.num_channels_ - delay; + i++) { int error = ref_frame_data[i] - test_frame_data[i + delay]; mse += error * error; variance += ref_frame_data[i] * ref_frame_data[i]; @@ -145,7 +147,7 @@ void VerifyFramesAreEqual(const AudioFrame& ref_frame, const AudioFrame& test_frame) { VerifyParams(ref_frame, test_frame); const int16_t* ref_frame_data = ref_frame.data(); - const int16_t* test_frame_data = test_frame.data(); + const int16_t* test_frame_data = test_frame.data(); for (size_t i = 0; i < ref_frame.samples_per_channel_ * ref_frame.num_channels_; i++) { EXPECT_EQ(ref_frame_data[i], test_frame_data[i]); @@ -161,8 +163,8 @@ void UtilityTest::RunResampleTest(int src_channels, const int16_t kSrcCh2 = 15; const int16_t kSrcCh3 = 22; const int16_t kSrcCh4 = 8; - const float resampling_factor = (1.0 * src_sample_rate_hz) / - dst_sample_rate_hz; + const float resampling_factor = + (1.0 * src_sample_rate_hz) / dst_sample_rate_hz; const float dst_ch1 = resampling_factor * kSrcCh1; const float dst_ch2 = resampling_factor * kSrcCh2; const float dst_ch3 = resampling_factor * kSrcCh3; @@ -206,7 +208,7 @@ void UtilityTest::RunResampleTest(int src_channels, static_cast(dst_sample_rate_hz) / src_sample_rate_hz * kInputKernelDelaySamples * dst_channels * 2); printf("(%d, %d Hz) -> (%d, %d Hz) ", // SNR reported on the same line later. - src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz); + src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz); RemixAndResample(src_frame_, &resampler, &dst_frame_); if (src_sample_rate_hz == 96000 && dst_sample_rate_hz == 8000) { @@ -258,8 +260,7 @@ TEST_F(UtilityTest, RemixAndResampleSucceeds) { for (int src_rate = 0; src_rate < kSampleRatesSize; src_rate++) { for (int dst_rate = 0; dst_rate < kSampleRatesSize; dst_rate++) { - for (int src_channel = 0; src_channel < kSrcChannelsSize; - src_channel++) { + for (int src_channel = 0; src_channel < kSrcChannelsSize; src_channel++) { for (int dst_channel = 0; dst_channel < kDstChannelsSize; dst_channel++) { RunResampleTest(kSrcChannels[src_channel], kSampleRates[src_rate], diff --git a/audio/test/audio_end_to_end_test.cc b/audio/test/audio_end_to_end_test.cc index 84ad4f0240..820b46444e 100644 --- a/audio/test/audio_end_to_end_test.cc +++ b/audio/test/audio_end_to_end_test.cc @@ -67,15 +67,15 @@ test::PacketTransport* AudioEndToEndTest::CreateSendTransport( } test::PacketTransport* AudioEndToEndTest::CreateReceiveTransport( - SingleThreadedTaskQueueForTesting* task_queue) { + SingleThreadedTaskQueueForTesting* task_queue) { return new test::PacketTransport( task_queue, nullptr, this, test::PacketTransport::kReceiver, test::CallTest::payload_type_map_, GetNetworkPipeConfig()); } void AudioEndToEndTest::ModifyAudioConfigs( - AudioSendStream::Config* send_config, - std::vector* receive_configs) { + AudioSendStream::Config* send_config, + std::vector* receive_configs) { // Large bitrate by default. const webrtc::SdpAudioFormat kDefaultFormat("opus", 48000, 2, {{"stereo", "1"}}); diff --git a/audio/test/low_bandwidth_audio_test.cc b/audio/test/low_bandwidth_audio_test.cc index f53f7b6d55..169f4bf592 100644 --- a/audio/test/low_bandwidth_audio_test.cc +++ b/audio/test/low_bandwidth_audio_test.cc @@ -13,10 +13,12 @@ #include "system_wrappers/include/sleep.h" #include "test/testsupport/fileutils.h" -DEFINE_int(sample_rate_hz, 16000, +DEFINE_int(sample_rate_hz, + 16000, "Sample rate (Hz) of the produced audio files."); -DEFINE_bool(quick, false, +DEFINE_bool(quick, + false, "Don't do the full audio recording. " "Used to quickly check that the test runs without crashing."); @@ -42,7 +44,7 @@ class AudioQualityTest : public AudioEndToEndTest { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); return webrtc::test::OutputPath() + "LowBandwidth_" + test_info->name() + - "_" + FileSampleRateSuffix() + ".wav"; + "_" + FileSampleRateSuffix() + ".wav"; } std::unique_ptr CreateCapturer() override { @@ -69,22 +71,21 @@ class AudioQualityTest : public AudioEndToEndTest { // Output information about the input and output audio files so that further // processing can be done by an external process. - printf("TEST %s %s %s\n", test_info->name(), - AudioInputFile().c_str(), AudioOutputFile().c_str()); + printf("TEST %s %s %s\n", test_info->name(), AudioInputFile().c_str(), + AudioOutputFile().c_str()); } }; class Mobile2GNetworkTest : public AudioQualityTest { - void ModifyAudioConfigs(AudioSendStream::Config* send_config, + void ModifyAudioConfigs( + AudioSendStream::Config* send_config, std::vector* receive_configs) override { send_config->send_codec_spec = AudioSendStream::Config::SendCodecSpec( test::CallTest::kAudioSendPayloadType, {"OPUS", 48000, 2, - {{"maxaveragebitrate", "6000"}, - {"ptime", "60"}, - {"stereo", "1"}}}); + {{"maxaveragebitrate", "6000"}, {"ptime", "60"}, {"stereo", "1"}}}); } FakeNetworkPipe::Config GetNetworkPipeConfig() const override { diff --git a/audio/transport_feedback_packet_loss_tracker_unittest.cc b/audio/transport_feedback_packet_loss_tracker_unittest.cc index b190c62c05..2f9bf68444 100644 --- a/audio/transport_feedback_packet_loss_tracker_unittest.cc +++ b/audio/transport_feedback_packet_loss_tracker_unittest.cc @@ -412,34 +412,30 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, InsertionCompletesTwoPairs) { TEST_P(TransportFeedbackPacketLossTrackerTest, SanityGapsInSequenceNumbers) { TransportFeedbackPacketLossTracker tracker(50 * kDefaultSendIntervalMs, 5, 1); - SendPackets(&tracker, - {static_cast(base_), - static_cast(base_ + 2), - static_cast(base_ + 4), - static_cast(base_ + 6), - static_cast(base_ + 8)}, - kDefaultSendIntervalMs); + SendPackets( + &tracker, + {static_cast(base_), static_cast(base_ + 2), + static_cast(base_ + 4), static_cast(base_ + 6), + static_cast(base_ + 8)}, + kDefaultSendIntervalMs); // Gaps in sequence numbers not considered as gaps in window, because only // those sequence numbers which were associated with the stream count. // Expected window contents: [] -> [11011]. AddTransportFeedbackAndValidate( // Note: Left packets belong to this stream, right ones ignored. - &tracker, base_, {true, false, - true, false, - false, false, - true, false, - true, true}); + &tracker, base_, + {true, false, true, false, false, false, true, false, true, true}); ValidatePacketLossStatistics(tracker, 1.0f / 5.0f, 1.0f / 4.0f); // Create gap by sending [base + 10] but not acking it. // Note: Acks for [base + 11] and [base + 13] ignored (other stream). // Expected window contents: [11011] -> [11011-GAP-01]. - SendPackets(&tracker, - {static_cast(base_ + 10), - static_cast(base_ + 12), - static_cast(base_ + 14)}, - kDefaultSendIntervalMs); + SendPackets( + &tracker, + {static_cast(base_ + 10), static_cast(base_ + 12), + static_cast(base_ + 14)}, + kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_ + 11, {false, false, false, true, true}); ValidatePacketLossStatistics(tracker, 2.0f / 7.0f, 2.0f / 5.0f); diff --git a/audio/utility/audio_frame_operations.cc b/audio/utility/audio_frame_operations.cc index ed7b7a8b8c..fb1f3b0771 100644 --- a/audio/utility/audio_frame_operations.cc +++ b/audio/utility/audio_frame_operations.cc @@ -159,7 +159,8 @@ void AudioFrameOperations::QuadToMono(const int16_t* src_audio, for (size_t i = 0; i < samples_per_channel; i++) { dst_audio[i] = (static_cast(src_audio[4 * i]) + src_audio[4 * i + 1] + - src_audio[4 * i + 2] + src_audio[4 * i + 3]) >> 2; + src_audio[4 * i + 2] + src_audio[4 * i + 3]) >> + 2; } } diff --git a/audio/utility/audio_frame_operations_unittest.cc b/audio/utility/audio_frame_operations_unittest.cc index 1d08d7ee41..76f1dcdb52 100644 --- a/audio/utility/audio_frame_operations_unittest.cc +++ b/audio/utility/audio_frame_operations_unittest.cc @@ -50,27 +50,29 @@ void SetFrameData(int16_t left, int16_t right, AudioFrame* frame) { void SetFrameData(int16_t data, AudioFrame* frame) { int16_t* frame_data = frame->mutable_data(); - for (size_t i = 0; - i < frame->samples_per_channel_ * frame->num_channels_; i++) { + for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; + i++) { frame_data[i] = data; } } void VerifyFramesAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { EXPECT_EQ(frame1.num_channels_, frame2.num_channels_); - EXPECT_EQ(frame1.samples_per_channel_, - frame2.samples_per_channel_); + EXPECT_EQ(frame1.samples_per_channel_, frame2.samples_per_channel_); const int16_t* frame1_data = frame1.data(); const int16_t* frame2_data = frame2.data(); for (size_t i = 0; i < frame1.samples_per_channel_ * frame1.num_channels_; - i++) { + i++) { EXPECT_EQ(frame1_data[i], frame2_data[i]); } EXPECT_EQ(frame1.muted(), frame2.muted()); } -void InitFrame(AudioFrame* frame, size_t channels, size_t samples_per_channel, - int16_t left_data, int16_t right_data) { +void InitFrame(AudioFrame* frame, + size_t channels, + size_t samples_per_channel, + int16_t left_data, + int16_t right_data) { RTC_DCHECK(frame); RTC_DCHECK_GE(2, channels); RTC_DCHECK_GE(AudioFrame::kMaxDataSizeSamples, @@ -90,7 +92,9 @@ int16_t GetChannelData(const AudioFrame& frame, size_t channel, size_t index) { return frame.data()[index * frame.num_channels_ + channel]; } -void VerifyFrameDataBounds(const AudioFrame& frame, size_t channel, int16_t max, +void VerifyFrameDataBounds(const AudioFrame& frame, + size_t channel, + int16_t max, int16_t min) { for (size_t i = 0; i < frame.samples_per_channel_; ++i) { int16_t s = GetChannelData(frame, channel, i); diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 9119545ab9..3b4a939b25 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -150,8 +150,10 @@ class AudioSendStream { std::unique_ptr audio_frame) = 0; // TODO(solenberg): Make payload_type a config property instead. - virtual bool SendTelephoneEvent(int payload_type, int payload_frequency, - int event, int duration_ms) = 0; + virtual bool SendTelephoneEvent(int payload_type, + int payload_frequency, + int event, + int duration_ms) = 0; virtual void SetMuted(bool muted) = 0; diff --git a/call/audio_state.h b/call/audio_state.h index a85cd86e5f..104f493fb6 100644 --- a/call/audio_state.h +++ b/call/audio_state.h @@ -42,7 +42,8 @@ class AudioState : public rtc::RefCountInterface { struct Stats { // Audio peak level (max(abs())), linearly on the interval [0,32767]. int32_t audio_level = -1; - // See: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy + // See: + // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy double total_energy = 0.0f; double total_duration = 0.0f; }; diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc index 7227b8fea7..c7049ba211 100644 --- a/call/bitrate_allocator.cc +++ b/call/bitrate_allocator.cc @@ -110,8 +110,7 @@ void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps, for (auto& config : bitrate_observer_configs_) { uint32_t allocated_bitrate = allocation[config.observer]; uint32_t protection_bitrate = config.observer->OnBitrateUpdated( - allocated_bitrate, last_fraction_loss_, last_rtt_, - last_bwe_period_ms_); + allocated_bitrate, last_fraction_loss_, last_rtt_, last_bwe_period_ms_); if (allocated_bitrate == 0 && config.allocated_bitrate_bps > 0) { if (target_bitrate_bps > 0) diff --git a/call/bitrate_allocator.h b/call/bitrate_allocator.h index 9913c4ffd8..36d05de607 100644 --- a/call/bitrate_allocator.h +++ b/call/bitrate_allocator.h @@ -205,8 +205,7 @@ class BitrateAllocator : public BitrateAllocatorInterface { int max_multiplier, ObserverAllocation* allocation) RTC_RUN_ON(&sequenced_checker_); - bool EnoughBitrateForAllObservers(uint32_t bitrate, - uint32_t sum_min_bitrates) + bool EnoughBitrateForAllObservers(uint32_t bitrate, uint32_t sum_min_bitrates) RTC_RUN_ON(&sequenced_checker_); // From the available |bitrate|, each observer will be allocated a diff --git a/call/bitrate_allocator_unittest.cc b/call/bitrate_allocator_unittest.cc index b325f518c2..7814655358 100644 --- a/call/bitrate_allocator_unittest.cc +++ b/call/bitrate_allocator_unittest.cc @@ -78,7 +78,7 @@ class TestBitrateObserver : public BitrateAllocatorObserver { namespace { constexpr int64_t kDefaultProbingIntervalMs = 3000; const double kDefaultBitratePriority = 1.0; -} +} // namespace class BitrateAllocatorTest : public ::testing::Test { protected: @@ -295,14 +295,14 @@ TEST_F(BitrateAllocatorTestNoEnforceMin, ThreeBitrateObservers) { allocator_->OnNetworkChanged(300000, 0, 0, kDefaultProbingIntervalMs); EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_bps_); // Min bitrate. EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_bps_); // Min bitrate. - EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_bps_); // Nothing. + EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_bps_); // Nothing. // Increased BWE, but still below the sum of configured min bitrates for all // observers and too little for observer 3. 1 and 2 will share the rest. allocator_->OnNetworkChanged(500000, 0, 0, kDefaultProbingIntervalMs); EXPECT_EQ(200000u, bitrate_observer_1.last_bitrate_bps_); // Min + split. EXPECT_EQ(300000u, bitrate_observer_2.last_bitrate_bps_); // Min + split. - EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_bps_); // Nothing. + EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_bps_); // Nothing. // Below min for all. allocator_->OnNetworkChanged(10000, 0, 0, kDefaultProbingIntervalMs); diff --git a/call/call.cc b/call/call.cc index be94f6ab20..88b2a7936b 100644 --- a/call/call.cc +++ b/call/call.cc @@ -118,7 +118,7 @@ std::unique_ptr CreateRtcLogStreamConfig( const int* search = FindKeyByValue(config.rtp.rtx_associated_payload_types, d.payload_type); rtclog_config->codecs.emplace_back(d.payload_name, d.payload_type, - search ? *search : 0); + search ? *search : 0); } return rtclog_config; } @@ -239,7 +239,8 @@ class Call final : public webrtc::Call, bool has_packet_feedback) override; private: - DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, + DeliveryStatus DeliverRtcp(MediaType media_type, + const uint8_t* packet, size_t length); DeliveryStatus DeliverRtp(MediaType media_type, rtc::CopyOnWriteBuffer packet, diff --git a/call/call.h b/call/call.h index d2971be5d5..5f700b614f 100644 --- a/call/call.h +++ b/call/call.h @@ -30,12 +30,7 @@ namespace webrtc { -enum class MediaType { - ANY, - AUDIO, - VIDEO, - DATA -}; +enum class MediaType { ANY, AUDIO, VIDEO, DATA }; class PacketReceiver { public: diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 204134dd19..0d24c20261 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -49,12 +49,8 @@ namespace webrtc { class CallPerfTest : public test::CallTest { protected: - enum class FecMode { - kOn, kOff - }; - enum class CreateOrder { - kAudioFirst, kVideoFirst - }; + enum class FecMode { kOn, kOff }; + enum class CreateOrder { kAudioFirst, kVideoFirst }; void TestAudioVideoSync(FecMode fec, CreateOrder create_first, float video_ntp_speed, @@ -545,8 +541,7 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { void ModifyVideoConfigs( VideoSendStream::Config* send_config, std::vector* receive_configs, - VideoEncoderConfig* encoder_config) override { - } + VideoEncoderConfig* encoder_config) override {} void PerformTest() override { EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; @@ -643,7 +638,9 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { RunBaseTest(&test); } -TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); } +TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { + TestMinTransmitBitrate(true); +} TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) { TestMinTransmitBitrate(false); @@ -938,11 +935,9 @@ void CallPerfTest::TestMinAudioVideoBitrate( // TODO(bugs.webrtc.org/8878) #if defined(WEBRTC_MAC) -#define MAYBE_MinVideoAndAudioBitrate \ - DISABLED_MinVideoAndAudioBitrate +#define MAYBE_MinVideoAndAudioBitrate DISABLED_MinVideoAndAudioBitrate #else -#define MAYBE_MinVideoAndAudioBitrate \ - MinVideoAndAudioBitrate +#define MAYBE_MinVideoAndAudioBitrate MinVideoAndAudioBitrate #endif TEST_F(CallPerfTest, MAYBE_MinVideoAndAudioBitrate) { TestMinAudioVideoBitrate(false, 110, 40, -10, 10000, 70000, 200000); diff --git a/call/call_unittest.cc b/call/call_unittest.cc index 745de5923a..c963be686a 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -15,8 +15,8 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/test/mock_audio_mixer.h" -#include "audio/audio_send_stream.h" #include "audio/audio_receive_stream.h" +#include "audio/audio_send_stream.h" #include "call/audio_state.h" #include "call/call.h" #include "logging/rtc_event_log/rtc_event_log.h" @@ -250,7 +250,6 @@ TEST(CallTest, MultipleFlexfecReceiveStreamsProtectingSingleVideoStream) { } } - TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) { constexpr uint32_t kSSRC = 12345; CallHelper call; @@ -277,5 +276,4 @@ TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) { EXPECT_EQ(rtp_state1.media_has_been_sent, rtp_state2.media_has_been_sent); } - } // namespace webrtc diff --git a/call/flexfec_receive_stream.h b/call/flexfec_receive_stream.h index 19f945e11e..d64cb26f70 100644 --- a/call/flexfec_receive_stream.h +++ b/call/flexfec_receive_stream.h @@ -16,8 +16,8 @@ #include #include -#include "api/rtp_headers.h" #include "api/call/transport.h" +#include "api/rtp_headers.h" #include "api/rtpparameters.h" #include "call/rtp_packet_sink_interface.h" #include "common_types.h" // NOLINT(build/include) diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 6f4227dcf9..2767d7f75f 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -75,8 +75,7 @@ RampUpTester::RampUpTester(size_t num_video_streams, EXPECT_LE(num_audio_streams_, 1u); } -RampUpTester::~RampUpTester() { -} +RampUpTester::~RampUpTester() {} Call::Config RampUpTester::GetSenderCallConfig() { Call::Config call_config(&event_log_); diff --git a/call/rtp_demuxer_unittest.cc b/call/rtp_demuxer_unittest.cc index af6cbee3e9..8cb9f86ece 100644 --- a/call/rtp_demuxer_unittest.cc +++ b/call/rtp_demuxer_unittest.cc @@ -346,8 +346,8 @@ TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByRsid) { } for (size_t i = 0; i < arraysize(rsids); i++) { - auto packet = CreatePacketWithSsrcRsid(rtc::checked_cast(i), - rsids[i]); + auto packet = + CreatePacketWithSsrcRsid(rtc::checked_cast(i), rsids[i]); EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); } @@ -361,8 +361,8 @@ TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByMid) { } for (size_t i = 0; i < arraysize(mids); i++) { - auto packet = CreatePacketWithSsrcMid(rtc::checked_cast(i), - mids[i]); + auto packet = + CreatePacketWithSsrcMid(rtc::checked_cast(i), mids[i]); EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); } diff --git a/call/rtp_stream_receiver_controller.cc b/call/rtp_stream_receiver_controller.cc index da58e59990..af431ab1cd 100644 --- a/call/rtp_stream_receiver_controller.cc +++ b/call/rtp_stream_receiver_controller.cc @@ -44,9 +44,8 @@ RtpStreamReceiverController::RtpStreamReceiverController() { RtpStreamReceiverController::~RtpStreamReceiverController() = default; std::unique_ptr -RtpStreamReceiverController::CreateReceiver( - uint32_t ssrc, - RtpPacketSinkInterface* sink) { +RtpStreamReceiverController::CreateReceiver(uint32_t ssrc, + RtpPacketSinkInterface* sink) { return rtc::MakeUnique(this, ssrc, sink); } diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index 25b1127675..0027696f20 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -83,8 +83,7 @@ class RtpTransportControllerSend final void OnSentPacket(const rtc::SentPacket& sent_packet) override; void SetSdpBitrateParameters(const BitrateConstraints& constraints) override; - void SetClientBitratePreferences( - const BitrateSettings& preferences) override; + void SetClientBitratePreferences(const BitrateSettings& preferences) override; private: const Clock* const clock_; diff --git a/call/rtx_receive_stream.cc b/call/rtx_receive_stream.cc index 09200791f8..5d5fec19bd 100644 --- a/call/rtx_receive_stream.cc +++ b/call/rtx_receive_stream.cc @@ -63,8 +63,7 @@ void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { media_packet.set_recovered(true); // Skip the RTX header. - rtc::ArrayView rtx_payload = - payload.subview(kRtxHeaderSize); + rtc::ArrayView rtx_payload = payload.subview(kRtxHeaderSize); uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size()); RTC_DCHECK(media_payload != nullptr); diff --git a/call/rtx_receive_stream_unittest.cc b/call/rtx_receive_stream_unittest.cc index 65ab82b0dd..a9cfd53b3c 100644 --- a/call/rtx_receive_stream_unittest.cc +++ b/call/rtx_receive_stream_unittest.cc @@ -36,7 +36,7 @@ constexpr uint8_t kRtxPacket[] = { 0x11, 0x11, 0x11, 0x11, // Timestamp. 0x22, 0x22, 0x22, 0x22, // SSRC. // RTX header. - 0x56, 0x57, // Orig seqno. + 0x56, 0x57, // Orig seqno. // Payload. 0xee, }; @@ -50,7 +50,7 @@ constexpr uint8_t kRtxPacketWithCVO[] = { 0xbe, 0xde, 0x00, 0x01, // Extension header. 0x30, 0x01, 0x00, 0x00, // 90 degree rotation. // RTX header. - 0x56, 0x57, // Orig seqno. + 0x56, 0x57, // Orig seqno. // Payload. 0xee, }; @@ -73,8 +73,8 @@ TEST(RtxReceiveStreamTest, RestoresPacketPayload) { RtpPacketReceived rtx_packet; EXPECT_TRUE(rtx_packet.Parse(rtc::ArrayView(kRtxPacket))); - EXPECT_CALL(media_sink, OnRtpPacket(_)).WillOnce(testing::Invoke( - [](const RtpPacketReceived& packet) { + EXPECT_CALL(media_sink, OnRtpPacket(_)) + .WillOnce(testing::Invoke([](const RtpPacketReceived& packet) { EXPECT_EQ(packet.SequenceNumber(), kMediaSeqno); EXPECT_EQ(packet.Ssrc(), kMediaSSRC); EXPECT_EQ(packet.PayloadType(), kMediaPayloadType); @@ -124,15 +124,15 @@ TEST(RtxReceiveStreamTest, CopiesRtpHeaderExtensions) { RtpHeaderExtensionMap extension_map; extension_map.RegisterByType(3, kRtpExtensionVideoRotation); RtpPacketReceived rtx_packet(&extension_map); - EXPECT_TRUE(rtx_packet.Parse( - rtc::ArrayView(kRtxPacketWithCVO))); + EXPECT_TRUE( + rtx_packet.Parse(rtc::ArrayView(kRtxPacketWithCVO))); VideoRotation rotation = kVideoRotation_0; EXPECT_TRUE(rtx_packet.GetExtension(&rotation)); EXPECT_EQ(kVideoRotation_90, rotation); - EXPECT_CALL(media_sink, OnRtpPacket(_)).WillOnce(testing::Invoke( - [](const RtpPacketReceived& packet) { + EXPECT_CALL(media_sink, OnRtpPacket(_)) + .WillOnce(testing::Invoke([](const RtpPacketReceived& packet) { EXPECT_EQ(packet.SequenceNumber(), kMediaSeqno); EXPECT_EQ(packet.Ssrc(), kMediaSSRC); EXPECT_EQ(packet.PayloadType(), kMediaPayloadType); diff --git a/call/test/mock_audio_send_stream.h b/call/test/mock_audio_send_stream.h index 4eb1166316..489e826d0e 100644 --- a/call/test/mock_audio_send_stream.h +++ b/call/test/mock_audio_send_stream.h @@ -26,14 +26,14 @@ class MockAudioSendStream : public AudioSendStream { MOCK_METHOD0(Start, void()); MOCK_METHOD0(Stop, void()); // GMock doesn't like move-only types, such as std::unique_ptr. - virtual void SendAudioData( - std::unique_ptr audio_frame) { + virtual void SendAudioData(std::unique_ptr audio_frame) { SendAudioDataForMock(audio_frame.get()); } - MOCK_METHOD1(SendAudioDataForMock, - void(webrtc::AudioFrame* audio_frame)); + MOCK_METHOD1(SendAudioDataForMock, void(webrtc::AudioFrame* audio_frame)); MOCK_METHOD4(SendTelephoneEvent, - bool(int payload_type, int payload_frequency, int event, + bool(int payload_type, + int payload_frequency, + int event, int duration_ms)); MOCK_METHOD1(SetMuted, void(bool muted)); MOCK_CONST_METHOD0(GetStats, Stats()); diff --git a/call/test/mock_rtp_transport_controller_send.h b/call/test/mock_rtp_transport_controller_send.h index 7226093b34..e28b42ef26 100644 --- a/call/test/mock_rtp_transport_controller_send.h +++ b/call/test/mock_rtp_transport_controller_send.h @@ -50,8 +50,7 @@ class MockRtpTransportControllerSend MOCK_METHOD1(EnablePeriodicAlrProbing, void(bool)); MOCK_METHOD1(OnSentPacket, void(const rtc::SentPacket&)); MOCK_METHOD1(SetSdpBitrateParameters, void(const BitrateConstraints&)); - MOCK_METHOD1(SetClientBitratePreferences, - void(const BitrateSettings&)); + MOCK_METHOD1(SetClientBitratePreferences, void(const BitrateSettings&)); }; } // namespace webrtc #endif // CALL_TEST_MOCK_RTP_TRANSPORT_CONTROLLER_SEND_H_ diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index a5cd11a837..a6ae8ef3b8 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -16,12 +16,12 @@ #include #include -#include "api/rtp_headers.h" #include "api/call/transport.h" +#include "api/rtp_headers.h" #include "api/rtpparameters.h" #include "api/video/video_content_type.h" -#include "api/video/video_timing.h" #include "api/video/video_sink_interface.h" +#include "api/video/video_timing.h" #include "call/rtp_config.h" #include "common_types.h" // NOLINT(build/include) #include "common_video/include/frame_callback.h" diff --git a/common_audio/audio_converter.cc b/common_audio/audio_converter.cc index 47d2be280e..0f97abb86a 100644 --- a/common_audio/audio_converter.cc +++ b/common_audio/audio_converter.cc @@ -26,12 +26,16 @@ namespace webrtc { class CopyConverter : public AudioConverter { public: - CopyConverter(size_t src_channels, size_t src_frames, size_t dst_channels, + CopyConverter(size_t src_channels, + size_t src_frames, + size_t dst_channels, size_t dst_frames) : AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {} - ~CopyConverter() override {}; + ~CopyConverter() override{}; - void Convert(const float* const* src, size_t src_size, float* const* dst, + void Convert(const float* const* src, + size_t src_size, + float* const* dst, size_t dst_capacity) override { CheckSizes(src_size, dst_capacity); if (src != dst) { @@ -43,12 +47,16 @@ class CopyConverter : public AudioConverter { class UpmixConverter : public AudioConverter { public: - UpmixConverter(size_t src_channels, size_t src_frames, size_t dst_channels, + UpmixConverter(size_t src_channels, + size_t src_frames, + size_t dst_channels, size_t dst_frames) : AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {} - ~UpmixConverter() override {}; + ~UpmixConverter() override{}; - void Convert(const float* const* src, size_t src_size, float* const* dst, + void Convert(const float* const* src, + size_t src_size, + float* const* dst, size_t dst_capacity) override { CheckSizes(src_size, dst_capacity); for (size_t i = 0; i < dst_frames(); ++i) { @@ -61,13 +69,16 @@ class UpmixConverter : public AudioConverter { class DownmixConverter : public AudioConverter { public: - DownmixConverter(size_t src_channels, size_t src_frames, size_t dst_channels, + DownmixConverter(size_t src_channels, + size_t src_frames, + size_t dst_channels, size_t dst_frames) - : AudioConverter(src_channels, src_frames, dst_channels, dst_frames) { - } - ~DownmixConverter() override {}; + : AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {} + ~DownmixConverter() override{}; - void Convert(const float* const* src, size_t src_size, float* const* dst, + void Convert(const float* const* src, + size_t src_size, + float* const* dst, size_t dst_capacity) override { CheckSizes(src_size, dst_capacity); float* dst_mono = dst[0]; @@ -82,7 +93,9 @@ class DownmixConverter : public AudioConverter { class ResampleConverter : public AudioConverter { public: - ResampleConverter(size_t src_channels, size_t src_frames, size_t dst_channels, + ResampleConverter(size_t src_channels, + size_t src_frames, + size_t dst_channels, size_t dst_frames) : AudioConverter(src_channels, src_frames, dst_channels, dst_frames) { resamplers_.reserve(src_channels); @@ -90,9 +103,11 @@ class ResampleConverter : public AudioConverter { resamplers_.push_back(std::unique_ptr( new PushSincResampler(src_frames, dst_frames))); } - ~ResampleConverter() override {}; + ~ResampleConverter() override{}; - void Convert(const float* const* src, size_t src_size, float* const* dst, + void Convert(const float* const* src, + size_t src_size, + float* const* dst, size_t dst_capacity) override { CheckSizes(src_size, dst_capacity); for (size_t i = 0; i < resamplers_.size(); ++i) @@ -108,7 +123,7 @@ class ResampleConverter : public AudioConverter { class CompositionConverter : public AudioConverter { public: explicit CompositionConverter( - std::vector> converters) + std::vector> converters) : converters_(std::move(converters)) { RTC_CHECK_GE(converters_.size(), 2); // We need an intermediate buffer after every converter. @@ -117,19 +132,19 @@ class CompositionConverter : public AudioConverter { std::unique_ptr>(new ChannelBuffer( (*it)->dst_frames(), (*it)->dst_channels()))); } - ~CompositionConverter() override {}; + ~CompositionConverter() override{}; - void Convert(const float* const* src, size_t src_size, float* const* dst, + void Convert(const float* const* src, + size_t src_size, + float* const* dst, size_t dst_capacity) override { converters_.front()->Convert(src, src_size, buffers_.front()->channels(), buffers_.front()->size()); for (size_t i = 2; i < converters_.size(); ++i) { auto& src_buffer = buffers_[i - 2]; auto& dst_buffer = buffers_[i - 1]; - converters_[i]->Convert(src_buffer->channels(), - src_buffer->size(), - dst_buffer->channels(), - dst_buffer->size()); + converters_[i]->Convert(src_buffer->channels(), src_buffer->size(), + dst_buffer->channels(), dst_buffer->size()); } converters_.back()->Convert(buffers_.back()->channels(), buffers_.back()->size(), dst, dst_capacity); @@ -175,8 +190,8 @@ std::unique_ptr AudioConverter::Create(size_t src_channels, sp.reset(new ResampleConverter(src_channels, src_frames, dst_channels, dst_frames)); } else { - sp.reset(new CopyConverter(src_channels, src_frames, dst_channels, - dst_frames)); + sp.reset( + new CopyConverter(src_channels, src_frames, dst_channels, dst_frames)); } return sp; @@ -184,13 +199,12 @@ std::unique_ptr AudioConverter::Create(size_t src_channels, // For CompositionConverter. AudioConverter::AudioConverter() - : src_channels_(0), - src_frames_(0), - dst_channels_(0), - dst_frames_(0) {} + : src_channels_(0), src_frames_(0), dst_channels_(0), dst_frames_(0) {} -AudioConverter::AudioConverter(size_t src_channels, size_t src_frames, - size_t dst_channels, size_t dst_frames) +AudioConverter::AudioConverter(size_t src_channels, + size_t src_frames, + size_t dst_channels, + size_t dst_frames) : src_channels_(src_channels), src_frames_(src_frames), dst_channels_(dst_channels), diff --git a/common_audio/audio_converter.h b/common_audio/audio_converter.h index 3f7b9a852c..769d724e2f 100644 --- a/common_audio/audio_converter.h +++ b/common_audio/audio_converter.h @@ -37,8 +37,10 @@ class AudioConverter { // capacity of |dst_capacity|. Both point to a series of buffers containing // the samples for each channel. The sizes must correspond to the format // passed to Create(). - virtual void Convert(const float* const* src, size_t src_size, - float* const* dst, size_t dst_capacity) = 0; + virtual void Convert(const float* const* src, + size_t src_size, + float* const* dst, + size_t dst_capacity) = 0; size_t src_channels() const { return src_channels_; } size_t src_frames() const { return src_frames_; } @@ -47,7 +49,9 @@ class AudioConverter { protected: AudioConverter(); - AudioConverter(size_t src_channels, size_t src_frames, size_t dst_channels, + AudioConverter(size_t src_channels, + size_t src_frames, + size_t dst_channels, size_t dst_frames); // Helper to RTC_CHECK that inputs are correctly sized. diff --git a/common_audio/audio_converter_unittest.cc b/common_audio/audio_converter_unittest.cc index e9937fd8cc..b99d825c2b 100644 --- a/common_audio/audio_converter_unittest.cc +++ b/common_audio/audio_converter_unittest.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include +#include #include #include @@ -52,8 +52,7 @@ float ComputeSNR(const ChannelBuffer& ref, // Search within one sample of the expected delay. for (size_t delay = std::max(expected_delay, static_cast(1)) - 1; - delay <= std::min(expected_delay + 1, ref.num_frames()); - ++delay) { + delay <= std::min(expected_delay + 1, ref.num_frames()); ++delay) { float mse = 0; float variance = 0; float mean = 0; @@ -92,8 +91,8 @@ void RunAudioConverterTest(size_t src_channels, int dst_sample_rate_hz) { const float kSrcLeft = 0.0002f; const float kSrcRight = 0.0001f; - const float resampling_factor = (1.f * src_sample_rate_hz) / - dst_sample_rate_hz; + const float resampling_factor = + (1.f * src_sample_rate_hz) / dst_sample_rate_hz; const float dst_left = resampling_factor * kSrcLeft; const float dst_right = resampling_factor * kSrcRight; const float dst_mono = (dst_left + dst_right) / 2; @@ -124,13 +123,15 @@ void RunAudioConverterTest(size_t src_channels, ScopedBuffer ref_buffer = CreateBuffer(ref_data, dst_frames); // The sinc resampler has a known delay, which we compute here. - const size_t delay_frames = src_sample_rate_hz == dst_sample_rate_hz ? 0 : - static_cast( - PushSincResampler::AlgorithmicDelaySeconds(src_sample_rate_hz) * - dst_sample_rate_hz); + const size_t delay_frames = + src_sample_rate_hz == dst_sample_rate_hz + ? 0 + : static_cast( + PushSincResampler::AlgorithmicDelaySeconds(src_sample_rate_hz) * + dst_sample_rate_hz); // SNR reported on the same line later. - printf("(%" PRIuS ", %d Hz) -> (%" PRIuS ", %d Hz) ", - src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz); + printf("(%" PRIuS ", %d Hz) -> (%" PRIuS ", %d Hz) ", src_channels, + src_sample_rate_hz, dst_channels, dst_sample_rate_hz); std::unique_ptr converter = AudioConverter::Create( src_channels, src_frames, dst_channels, dst_frames); diff --git a/common_audio/audio_ring_buffer.cc b/common_audio/audio_ring_buffer.cc index e7b5d81ac6..ed4a5dd562 100644 --- a/common_audio/audio_ring_buffer.cc +++ b/common_audio/audio_ring_buffer.cc @@ -28,7 +28,8 @@ AudioRingBuffer::~AudioRingBuffer() { WebRtc_FreeBuffer(buf); } -void AudioRingBuffer::Write(const float* const* data, size_t channels, +void AudioRingBuffer::Write(const float* const* data, + size_t channels, size_t frames) { RTC_DCHECK_EQ(buffers_.size(), channels); for (size_t i = 0; i < channels; ++i) { diff --git a/common_audio/audio_ring_buffer_unittest.cc b/common_audio/audio_ring_buffer_unittest.cc index 2fcf80035f..d411195aa7 100644 --- a/common_audio/audio_ring_buffer_unittest.cc +++ b/common_audio/audio_ring_buffer_unittest.cc @@ -17,8 +17,8 @@ namespace webrtc { -class AudioRingBufferTest : - public ::testing::TestWithParam< ::testing::tuple > { +class AudioRingBufferTest + : public ::testing::TestWithParam< ::testing::tuple > { }; void ReadAndWriteTest(const ChannelBuffer& input, @@ -72,10 +72,8 @@ TEST_P(AudioRingBufferTest, ReadDataMatchesWrittenData) { input.channels()[i][j] = (i + 1) * (j + 1); ChannelBuffer output(kFrames, static_cast(num_channels)); - ReadAndWriteTest(input, - ::testing::get<0>(GetParam()), - ::testing::get<1>(GetParam()), - ::testing::get<2>(GetParam()), + ReadAndWriteTest(input, ::testing::get<0>(GetParam()), + ::testing::get<1>(GetParam()), ::testing::get<2>(GetParam()), &output); // Verify the read data matches the input. @@ -85,7 +83,8 @@ TEST_P(AudioRingBufferTest, ReadDataMatchesWrittenData) { } INSTANTIATE_TEST_CASE_P( - AudioRingBufferTest, AudioRingBufferTest, + AudioRingBufferTest, + AudioRingBufferTest, ::testing::Combine(::testing::Values(10, 20, 42), // num_write_chunk_frames ::testing::Values(1, 10, 17), // num_read_chunk_frames ::testing::Values(100, 256), // buffer_frames diff --git a/common_audio/blocker.cc b/common_audio/blocker.cc index 7d09d21ea8..3dc8ed8040 100644 --- a/common_audio/blocker.cc +++ b/common_audio/blocker.cc @@ -41,8 +41,7 @@ void CopyFrames(const float* const* src, float* const* dst, size_t dst_start_index) { for (size_t i = 0; i < num_channels; ++i) { - memcpy(&dst[i][dst_start_index], - &src[i][src_start_index], + memcpy(&dst[i][dst_start_index], &src[i][src_start_index], num_frames * sizeof(dst[i][dst_start_index])); } } @@ -55,8 +54,7 @@ void MoveFrames(const float* const* src, float* const* dst, size_t dst_start_index) { for (size_t i = 0; i < num_channels; ++i) { - memmove(&dst[i][dst_start_index], - &src[i][src_start_index], + memmove(&dst[i][dst_start_index], &src[i][src_start_index], num_frames * sizeof(dst[i][dst_start_index])); } } @@ -87,9 +85,9 @@ void ApplyWindow(const float* window, size_t gcd(size_t a, size_t b) { size_t tmp; while (b) { - tmp = a; - a = b; - b = tmp % b; + tmp = a; + a = b; + b = tmp % b; } return a; } @@ -184,51 +182,30 @@ void Blocker::ProcessChunk(const float* const* input, block_size_); input_buffer_.MoveReadPositionBackward(block_size_ - shift_amount_); - ApplyWindow(window_.get(), - block_size_, - num_input_channels_, + ApplyWindow(window_.get(), block_size_, num_input_channels_, input_block_.channels()); - callback_->ProcessBlock(input_block_.channels(), - block_size_, - num_input_channels_, - num_output_channels_, + callback_->ProcessBlock(input_block_.channels(), block_size_, + num_input_channels_, num_output_channels_, output_block_.channels()); - ApplyWindow(window_.get(), - block_size_, - num_output_channels_, + ApplyWindow(window_.get(), block_size_, num_output_channels_, output_block_.channels()); - AddFrames(output_buffer_.channels(), - first_frame_in_block, - output_block_.channels(), - 0, - block_size_, - num_output_channels_, - output_buffer_.channels(), - first_frame_in_block); + AddFrames(output_buffer_.channels(), first_frame_in_block, + output_block_.channels(), 0, block_size_, num_output_channels_, + output_buffer_.channels(), first_frame_in_block); first_frame_in_block += shift_amount_; } // Copy output buffer to output - CopyFrames(output_buffer_.channels(), - 0, - chunk_size_, - num_output_channels_, - output, - 0); + CopyFrames(output_buffer_.channels(), 0, chunk_size_, num_output_channels_, + output, 0); // Copy output buffer [chunk_size_, chunk_size_ + initial_delay] // to output buffer [0, initial_delay], zero the rest. - MoveFrames(output_buffer_.channels(), - chunk_size, - initial_delay_, - num_output_channels_, - output_buffer_.channels(), - 0); - ZeroOut(output_buffer_.channels(), - initial_delay_, - chunk_size_, + MoveFrames(output_buffer_.channels(), chunk_size, initial_delay_, + num_output_channels_, output_buffer_.channels(), 0); + ZeroOut(output_buffer_.channels(), initial_delay_, chunk_size_, num_output_channels_); // Calculate new starting frames. diff --git a/common_audio/blocker_unittest.cc b/common_audio/blocker_unittest.cc index 296efab15b..85a24f6847 100644 --- a/common_audio/blocker_unittest.cc +++ b/common_audio/blocker_unittest.cc @@ -71,11 +71,8 @@ class BlockerTest : public ::testing::Test { size_t end = chunk_size - 1; while (end < num_frames) { CopyTo(input_chunk, 0, start, num_input_channels, chunk_size, input); - blocker->ProcessChunk(input_chunk, - chunk_size, - num_input_channels, - num_output_channels, - output_chunk); + blocker->ProcessChunk(input_chunk, chunk_size, num_input_channels, + num_output_channels, output_chunk); CopyTo(output, start, 0, num_output_channels, chunk_size, output_chunk); start += chunk_size; @@ -116,8 +113,7 @@ class BlockerTest : public ::testing::Test { size_t num_frames, const float* const* src) { for (size_t i = 0; i < num_channels; ++i) { - memcpy(&dst[i][start_index_dst], - &src[i][start_index_src], + memcpy(&dst[i][start_index_dst], &src[i][start_index_src], num_frames * sizeof(float)); } } @@ -152,27 +148,15 @@ TEST_F(BlockerTest, TestBlockerMutuallyPrimeChunkandBlockSize) { ChannelBuffer output_chunk_cb(kChunkSize, kNumOutputChannels); PlusThreeBlockerCallback callback; - Blocker blocker(kChunkSize, - kBlockSize, - kNumInputChannels, - kNumOutputChannels, - kWindow, - kShiftAmount, - &callback); + Blocker blocker(kChunkSize, kBlockSize, kNumInputChannels, kNumOutputChannels, + kWindow, kShiftAmount, &callback); - RunTest(&blocker, - kChunkSize, - kNumFrames, - input_cb.channels(), - input_chunk_cb.channels(), - actual_output_cb.channels(), - output_chunk_cb.channels(), - kNumInputChannels, - kNumOutputChannels); + RunTest(&blocker, kChunkSize, kNumFrames, input_cb.channels(), + input_chunk_cb.channels(), actual_output_cb.channels(), + output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels); ValidateSignalEquality(expected_output_cb.channels(), - actual_output_cb.channels(), - kNumOutputChannels, + actual_output_cb.channels(), kNumOutputChannels, kNumFrames); } @@ -205,27 +189,15 @@ TEST_F(BlockerTest, TestBlockerMutuallyPrimeShiftAndBlockSize) { ChannelBuffer output_chunk_cb(kChunkSize, kNumOutputChannels); PlusThreeBlockerCallback callback; - Blocker blocker(kChunkSize, - kBlockSize, - kNumInputChannels, - kNumOutputChannels, - kWindow, - kShiftAmount, - &callback); + Blocker blocker(kChunkSize, kBlockSize, kNumInputChannels, kNumOutputChannels, + kWindow, kShiftAmount, &callback); - RunTest(&blocker, - kChunkSize, - kNumFrames, - input_cb.channels(), - input_chunk_cb.channels(), - actual_output_cb.channels(), - output_chunk_cb.channels(), - kNumInputChannels, - kNumOutputChannels); + RunTest(&blocker, kChunkSize, kNumFrames, input_cb.channels(), + input_chunk_cb.channels(), actual_output_cb.channels(), + output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels); ValidateSignalEquality(expected_output_cb.channels(), - actual_output_cb.channels(), - kNumOutputChannels, + actual_output_cb.channels(), kNumOutputChannels, kNumFrames); } @@ -258,27 +230,15 @@ TEST_F(BlockerTest, TestBlockerNoOverlap) { ChannelBuffer output_chunk_cb(kChunkSize, kNumOutputChannels); PlusThreeBlockerCallback callback; - Blocker blocker(kChunkSize, - kBlockSize, - kNumInputChannels, - kNumOutputChannels, - kWindow, - kShiftAmount, - &callback); + Blocker blocker(kChunkSize, kBlockSize, kNumInputChannels, kNumOutputChannels, + kWindow, kShiftAmount, &callback); - RunTest(&blocker, - kChunkSize, - kNumFrames, - input_cb.channels(), - input_chunk_cb.channels(), - actual_output_cb.channels(), - output_chunk_cb.channels(), - kNumInputChannels, - kNumOutputChannels); + RunTest(&blocker, kChunkSize, kNumFrames, input_cb.channels(), + input_chunk_cb.channels(), actual_output_cb.channels(), + output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels); ValidateSignalEquality(expected_output_cb.channels(), - actual_output_cb.channels(), - kNumOutputChannels, + actual_output_cb.channels(), kNumOutputChannels, kNumFrames); } @@ -286,14 +246,14 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) { const size_t kNumInputChannels = 3; const size_t kNumOutputChannels = 2; const size_t kNumFrames = 1280; - const size_t kChunkSize[] = - {80, 80, 80, 80, 80, 80, 160, 160, 160, 160, 160, 160}; - const size_t kBlockSize[] = - {64, 64, 64, 128, 128, 128, 128, 128, 128, 256, 256, 256}; - const size_t kShiftAmount[] = - {16, 32, 64, 32, 64, 128, 32, 64, 128, 64, 128, 256}; - const size_t kInitialDelay[] = - {48, 48, 48, 112, 112, 112, 96, 96, 96, 224, 224, 224}; + const size_t kChunkSize[] = {80, 80, 80, 80, 80, 80, + 160, 160, 160, 160, 160, 160}; + const size_t kBlockSize[] = {64, 64, 64, 128, 128, 128, + 128, 128, 128, 256, 256, 256}; + const size_t kShiftAmount[] = {16, 32, 64, 32, 64, 128, + 32, 64, 128, 64, 128, 256}; + const size_t kInitialDelay[] = {48, 48, 48, 112, 112, 112, + 96, 96, 96, 224, 224, 224}; float input[kNumInputChannels][kNumFrames]; for (size_t i = 0; i < kNumInputChannels; ++i) { @@ -317,27 +277,15 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) { ChannelBuffer input_chunk_cb(kChunkSize[i], kNumInputChannels); ChannelBuffer output_chunk_cb(kChunkSize[i], kNumOutputChannels); - Blocker blocker(kChunkSize[i], - kBlockSize[i], - kNumInputChannels, - kNumOutputChannels, - window.get(), - kShiftAmount[i], + Blocker blocker(kChunkSize[i], kBlockSize[i], kNumInputChannels, + kNumOutputChannels, window.get(), kShiftAmount[i], &callback); - RunTest(&blocker, - kChunkSize[i], - kNumFrames, - input_cb.channels(), - input_chunk_cb.channels(), - output_cb.channels(), - output_chunk_cb.channels(), - kNumInputChannels, - kNumOutputChannels); + RunTest(&blocker, kChunkSize[i], kNumFrames, input_cb.channels(), + input_chunk_cb.channels(), output_cb.channels(), + output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels); - ValidateInitialDelay(output_cb.channels(), - kNumOutputChannels, - kNumFrames, + ValidateInitialDelay(output_cb.channels(), kNumOutputChannels, kNumFrames, kInitialDelay[i]); } } diff --git a/common_audio/channel_buffer.cc b/common_audio/channel_buffer.cc index df45f6d0f6..38d231e09d 100644 --- a/common_audio/channel_buffer.cc +++ b/common_audio/channel_buffer.cc @@ -68,9 +68,7 @@ void IFChannelBuffer::RefreshI() const { ibuf_.set_num_channels(fbuf_.num_channels()); const float* const* float_channels = fbuf_.channels(); for (size_t i = 0; i < fbuf_.num_channels(); ++i) { - FloatS16ToS16(float_channels[i], - ibuf_.num_frames(), - int_channels[i]); + FloatS16ToS16(float_channels[i], ibuf_.num_frames(), int_channels[i]); } ivalid_ = true; } diff --git a/common_audio/channel_buffer.h b/common_audio/channel_buffer.h index 024868c46c..3f9ba9c0e1 100644 --- a/common_audio/channel_buffer.h +++ b/common_audio/channel_buffer.h @@ -40,9 +40,7 @@ namespace webrtc { template class ChannelBuffer { public: - ChannelBuffer(size_t num_frames, - size_t num_channels, - size_t num_bands = 1) + ChannelBuffer(size_t num_frames, size_t num_channels, size_t num_bands = 1) : data_(new T[num_frames * num_channels]()), channels_(new T*[num_channels * num_bands]), bands_(new T*[num_channels * num_bands]), @@ -119,7 +117,7 @@ class ChannelBuffer { size_t num_frames_per_band() const { return num_frames_per_band_; } size_t num_channels() const { return num_channels_; } size_t num_bands() const { return num_bands_; } - size_t size() const {return num_frames_ * num_allocated_channels_; } + size_t size() const { return num_frames_ * num_allocated_channels_; } void set_num_channels(size_t num_channels) { RTC_DCHECK_LE(num_channels, num_allocated_channels_); diff --git a/common_audio/fft4g.h b/common_audio/fft4g.h index 1f0e29dd5c..1750e27853 100644 --- a/common_audio/fft4g.h +++ b/common_audio/fft4g.h @@ -16,7 +16,7 @@ extern "C" { #endif // Refer to fft4g.c for documentation. -void WebRtc_rdft(size_t n, int isgn, float *a, size_t *ip, float *w); +void WebRtc_rdft(size_t n, int isgn, float* a, size_t* ip, float* w); #if defined(__cplusplus) } diff --git a/common_audio/fir_filter_c.cc b/common_audio/fir_filter_c.cc index 6fe247011b..3418434672 100644 --- a/common_audio/fir_filter_c.cc +++ b/common_audio/fir_filter_c.cc @@ -20,8 +20,7 @@ namespace webrtc { -FIRFilterC::~FIRFilterC() { -} +FIRFilterC::~FIRFilterC() {} FIRFilterC::FIRFilterC(const float* coefficients, size_t coefficients_length) : coefficients_length_(coefficients_length), @@ -52,11 +51,10 @@ void FIRFilterC::Filter(const float* in, size_t length, float* out) { // Update current state. if (length >= state_length_) { - memcpy( - state_.get(), &in[length - state_length_], state_length_ * sizeof(*in)); + memcpy(state_.get(), &in[length - state_length_], + state_length_ * sizeof(*in)); } else { - memmove(state_.get(), - &state_[length], + memmove(state_.get(), &state_[length], (state_length_ - length) * sizeof(state_[0])); memcpy(&state_[state_length_ - length], in, length * sizeof(*in)); } diff --git a/common_audio/fir_filter_c.h b/common_audio/fir_filter_c.h index ffce838a67..d263e1ba60 100644 --- a/common_audio/fir_filter_c.h +++ b/common_audio/fir_filter_c.h @@ -20,8 +20,7 @@ namespace webrtc { class FIRFilterC : public FIRFilter { public: - FIRFilterC(const float* coefficients, - size_t coefficients_length); + FIRFilterC(const float* coefficients, size_t coefficients_length); ~FIRFilterC() override; void Filter(const float* in, size_t length, float* out) override; diff --git a/common_audio/fir_filter_factory.h b/common_audio/fir_filter_factory.h index 2e7ca9b89c..a952541035 100644 --- a/common_audio/fir_filter_factory.h +++ b/common_audio/fir_filter_factory.h @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license diff --git a/common_audio/fir_filter_neon.cc b/common_audio/fir_filter_neon.cc index e27f21b28c..f668841be6 100644 --- a/common_audio/fir_filter_neon.cc +++ b/common_audio/fir_filter_neon.cc @@ -18,8 +18,7 @@ namespace webrtc { -FIRFilterNEON::~FIRFilterNEON() { -} +FIRFilterNEON::~FIRFilterNEON() {} FIRFilterNEON::FIRFilterNEON(const float* coefficients, size_t coefficients_length, @@ -40,8 +39,7 @@ FIRFilterNEON::FIRFilterNEON(const float* coefficients, for (size_t i = 0; i < coefficients_length; ++i) { coefficients_[i + padding] = coefficients[coefficients_length - i - 1]; } - memset(state_.get(), - 0.f, + memset(state_.get(), 0.f, (max_input_length + state_length_) * sizeof(state_[0])); } @@ -60,8 +58,8 @@ void FIRFilterNEON::Filter(const float* in, size_t length, float* out) { float32x4_t m_in; for (size_t j = 0; j < coefficients_length_; j += 4) { - m_in = vld1q_f32(in_ptr + j); - m_sum = vmlaq_f32(m_sum, m_in, vld1q_f32(coef_ptr + j)); + m_in = vld1q_f32(in_ptr + j); + m_sum = vmlaq_f32(m_sum, m_in, vld1q_f32(coef_ptr + j)); } float32x2_t m_half = vadd_f32(vget_high_f32(m_sum), vget_low_f32(m_sum)); diff --git a/common_audio/fir_filter_sse.cc b/common_audio/fir_filter_sse.cc index 0da23fcbb3..ee75fb38ad 100644 --- a/common_audio/fir_filter_sse.cc +++ b/common_audio/fir_filter_sse.cc @@ -19,8 +19,7 @@ namespace webrtc { -FIRFilterSSE2::~FIRFilterSSE2() { -} +FIRFilterSSE2::~FIRFilterSSE2() {} FIRFilterSSE2::FIRFilterSSE2(const float* coefficients, size_t coefficients_length, @@ -41,8 +40,7 @@ FIRFilterSSE2::FIRFilterSSE2(const float* coefficients, for (size_t i = 0; i < coefficients_length; ++i) { coefficients_[i + padding] = coefficients[coefficients_length - i - 1]; } - memset(state_.get(), - 0, + memset(state_.get(), 0, (max_input_length + state_length_) * sizeof(state_[0])); } diff --git a/common_audio/fir_filter_unittest.cc b/common_audio/fir_filter_unittest.cc index 46966217d7..07abf2094f 100644 --- a/common_audio/fir_filter_unittest.cc +++ b/common_audio/fir_filter_unittest.cc @@ -21,20 +21,18 @@ namespace webrtc { namespace { static const float kCoefficients[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f}; -static const size_t kCoefficientsLength = sizeof(kCoefficients) / - sizeof(kCoefficients[0]); +static const size_t kCoefficientsLength = + sizeof(kCoefficients) / sizeof(kCoefficients[0]); -static const float kInput[] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, - 8.f, 9.f, 10.f}; -static const size_t kInputLength = sizeof(kInput) / - sizeof(kInput[0]); +static const float kInput[] = {1.f, 2.f, 3.f, 4.f, 5.f, + 6.f, 7.f, 8.f, 9.f, 10.f}; +static const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); void VerifyOutput(const float* expected_output, const float* output, size_t length) { - EXPECT_EQ(0, memcmp(expected_output, - output, - length * sizeof(expected_output[0]))); + EXPECT_EQ( + 0, memcmp(expected_output, output, length * sizeof(expected_output[0]))); } } // namespace @@ -97,8 +95,8 @@ TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) { EXPECT_FLOAT_EQ(0.2f, output[0]); EXPECT_FLOAT_EQ(0.7f, output[1]); - filter.reset(CreateFirFilter( - kCoefficients, kCoefficientsLength, kCoefficientsLength)); + filter.reset( + CreateFirFilter(kCoefficients, kCoefficientsLength, kCoefficientsLength)); filter->Filter(kInput, kCoefficientsLength, output); EXPECT_FLOAT_EQ(0.2f, output[0]); @@ -149,19 +147,17 @@ TEST(FIRFilterTest, VerifySampleBasedVsBlockBasedFiltering) { filter->Filter(&kInput[i], 1, &output_sample_based[i]); } - EXPECT_EQ(0, memcmp(output_sample_based, - output_block_based, - kInputLength)); + EXPECT_EQ(0, memcmp(output_sample_based, output_block_based, kInputLength)); } TEST(FIRFilterTest, SimplestHighPassFilter) { const float kCoefficients[] = {1.f, -1.f}; - const size_t kCoefficientsLength = sizeof(kCoefficients) / - sizeof(kCoefficients[0]); + const size_t kCoefficientsLength = + sizeof(kCoefficients) / sizeof(kCoefficients[0]); float kConstantInput[] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; - const size_t kConstantInputLength = sizeof(kConstantInput) / - sizeof(kConstantInput[0]); + const size_t kConstantInputLength = + sizeof(kConstantInput) / sizeof(kConstantInput[0]); float output[kConstantInputLength]; std::unique_ptr filter(CreateFirFilter( @@ -175,12 +171,12 @@ TEST(FIRFilterTest, SimplestHighPassFilter) { TEST(FIRFilterTest, SimplestLowPassFilter) { const float kCoefficients[] = {1.f, 1.f}; - const size_t kCoefficientsLength = sizeof(kCoefficients) / - sizeof(kCoefficients[0]); + const size_t kCoefficientsLength = + sizeof(kCoefficients) / sizeof(kCoefficients[0]); float kHighFrequencyInput[] = {-1.f, 1.f, -1.f, 1.f, -1.f, 1.f, -1.f, 1.f}; - const size_t kHighFrequencyInputLength = sizeof(kHighFrequencyInput) / - sizeof(kHighFrequencyInput[0]); + const size_t kHighFrequencyInputLength = + sizeof(kHighFrequencyInput) / sizeof(kHighFrequencyInput[0]); float output[kHighFrequencyInputLength]; std::unique_ptr filter(CreateFirFilter( @@ -195,16 +191,16 @@ TEST(FIRFilterTest, SimplestLowPassFilter) { TEST(FIRFilterTest, SameOutputWhenSwapedCoefficientsAndInput) { float output[kCoefficientsLength]; float output_swaped[kCoefficientsLength]; - std::unique_ptr filter(CreateFirFilter( - kCoefficients, kCoefficientsLength, kCoefficientsLength)); + std::unique_ptr filter( + CreateFirFilter(kCoefficients, kCoefficientsLength, kCoefficientsLength)); // Use kCoefficientsLength for in_length to get same-length outputs. filter->Filter(kInput, kCoefficientsLength, output); - filter.reset(CreateFirFilter( - kInput, kCoefficientsLength, kCoefficientsLength)); + filter.reset( + CreateFirFilter(kInput, kCoefficientsLength, kCoefficientsLength)); filter->Filter(kCoefficients, kCoefficientsLength, output_swaped); - for (size_t i = 0 ; i < kCoefficientsLength; ++i) { + for (size_t i = 0; i < kCoefficientsLength; ++i) { EXPECT_FLOAT_EQ(output[i], output_swaped[i]); } } diff --git a/common_audio/lapped_transform.cc b/common_audio/lapped_transform.cc index 517709f462..72c2ad79f6 100644 --- a/common_audio/lapped_transform.cc +++ b/common_audio/lapped_transform.cc @@ -29,20 +29,17 @@ void LappedTransform::BlockThunk::ProcessBlock(const float* const* input, RTC_CHECK_EQ(parent_->block_length_, num_frames); for (size_t i = 0; i < num_input_channels; ++i) { - memcpy(parent_->real_buf_.Row(i), input[i], - num_frames * sizeof(*input[0])); + memcpy(parent_->real_buf_.Row(i), input[i], num_frames * sizeof(*input[0])); parent_->fft_->Forward(parent_->real_buf_.Row(i), parent_->cplx_pre_.Row(i)); } - size_t block_length = RealFourier::ComplexLength( - RealFourier::FftOrder(num_frames)); + size_t block_length = + RealFourier::ComplexLength(RealFourier::FftOrder(num_frames)); RTC_CHECK_EQ(parent_->cplx_length_, block_length); - parent_->block_processor_->ProcessAudioBlock(parent_->cplx_pre_.Array(), - num_input_channels, - parent_->cplx_length_, - num_output_channels, - parent_->cplx_post_.Array()); + parent_->block_processor_->ProcessAudioBlock( + parent_->cplx_pre_.Array(), num_input_channels, parent_->cplx_length_, + num_output_channels, parent_->cplx_post_.Array()); for (size_t i = 0; i < num_output_channels; ++i) { parent_->fft_->Inverse(parent_->cplx_post_.Row(i), diff --git a/common_audio/lapped_transform.h b/common_audio/lapped_transform.h index c97cd1684c..1ab2a9fee7 100644 --- a/common_audio/lapped_transform.h +++ b/common_audio/lapped_transform.h @@ -35,7 +35,8 @@ class LappedTransform { virtual ~Callback() {} virtual void ProcessAudioBlock(const std::complex* const* in_block, - size_t num_in_channels, size_t frames, + size_t num_in_channels, + size_t frames, size_t num_out_channels, std::complex* const* out_block) = 0; }; @@ -128,4 +129,3 @@ class LappedTransform { } // namespace webrtc #endif // COMMON_AUDIO_LAPPED_TRANSFORM_H_ - diff --git a/common_audio/lapped_transform_unittest.cc b/common_audio/lapped_transform_unittest.cc index d6a312db51..7f3d19f806 100644 --- a/common_audio/lapped_transform_unittest.cc +++ b/common_audio/lapped_transform_unittest.cc @@ -36,9 +36,7 @@ class NoopCallback : public webrtc::LappedTransform::Callback { ++block_num_; } - size_t block_num() { - return block_num_; - } + size_t block_num() { return block_num_; } private: size_t block_num_; @@ -69,9 +67,7 @@ class FftCheckerCallback : public webrtc::LappedTransform::Callback { } } - size_t block_num() { - return block_num_; - } + size_t block_num() { return block_num_; } private: size_t block_num_; @@ -150,8 +146,7 @@ TEST(LappedTransformTest, IdentityProcessor) { trans.ProcessChunk(&in_chunk, &out_chunk); for (size_t i = 0; i < kChunkLength; ++i) { - ASSERT_NEAR(out_chunk[i], - (i < kBlockLength - kShiftAmount) ? 0.0f : 2.0f, + ASSERT_NEAR(out_chunk[i], (i < kBlockLength - kShiftAmount) ? 0.0f : 2.0f, 1e-5f); } @@ -167,8 +162,8 @@ TEST(LappedTransformTest, Callbacks) { float window[kBlockLength]; std::fill(window, &window[kBlockLength], 1.0f); - LappedTransform trans(1, 1, kChunkLength, window, kBlockLength, - kBlockLength, &call); + LappedTransform trans(1, 1, kChunkLength, window, kBlockLength, kBlockLength, + &call); float in_buffer[kChunkLength]; float* in_chunk = in_buffer; float out_buffer[kChunkLength]; diff --git a/common_audio/real_fourier.h b/common_audio/real_fourier.h index d16149b365..a3e4dd16a8 100644 --- a/common_audio/real_fourier.h +++ b/common_audio/real_fourier.h @@ -72,4 +72,3 @@ class RealFourier { } // namespace webrtc #endif // COMMON_AUDIO_REAL_FOURIER_H_ - diff --git a/common_audio/real_fourier_ooura.cc b/common_audio/real_fourier_ooura.cc index ca043e4e13..a3dfbd6811 100644 --- a/common_audio/real_fourier_ooura.cc +++ b/common_audio/real_fourier_ooura.cc @@ -10,8 +10,8 @@ #include "common_audio/real_fourier_ooura.h" -#include #include +#include #include "common_audio/fft4g.h" #include "rtc_base/checks.h" @@ -28,8 +28,8 @@ void Conjugate(complex* array, size_t complex_length) { } size_t ComputeWorkIpSize(size_t fft_length) { - return static_cast(2 + std::ceil(std::sqrt( - static_cast(fft_length)))); + return static_cast( + 2 + std::ceil(std::sqrt(static_cast(fft_length)))); } } // namespace @@ -73,8 +73,8 @@ void RealFourierOoura::Inverse(const complex* src, float* dest) const { // Restore Ooura's conjugate definition. Conjugate(dest_complex, dest_complex_length); // Restore real[n/2] to imag[0]. - dest_complex[0] = complex(dest_complex[0].real(), - src[complex_length_ - 1].real()); + dest_complex[0] = + complex(dest_complex[0].real(), src[complex_length_ - 1].real()); } WebRtc_rdft(length_, -1, dest, work_ip_.get(), work_w_.get()); diff --git a/common_audio/real_fourier_unittest.cc b/common_audio/real_fourier_unittest.cc index d5b6942fc5..132488747a 100644 --- a/common_audio/real_fourier_unittest.cc +++ b/common_audio/real_fourier_unittest.cc @@ -60,8 +60,7 @@ class RealFourierTest : public ::testing::Test { real_buffer_(RealFourier::AllocRealBuffer(4)), cplx_buffer_(RealFourier::AllocCplxBuffer(3)) {} - ~RealFourierTest() { - } + ~RealFourierTest() {} T rf_; const RealFourier::fft_real_scoper real_buffer_; diff --git a/common_audio/resampler/include/push_resampler.h b/common_audio/resampler/include/push_resampler.h index 046415b87e..05b93d1909 100644 --- a/common_audio/resampler/include/push_resampler.h +++ b/common_audio/resampler/include/push_resampler.h @@ -29,7 +29,8 @@ class PushResampler { // Must be called whenever the parameters change. Free to be called at any // time as it is a no-op if parameters have not changed since the last call. - int InitializeIfNeeded(int src_sample_rate_hz, int dst_sample_rate_hz, + int InitializeIfNeeded(int src_sample_rate_hz, + int dst_sample_rate_hz, size_t num_channels); // Returns the total number of samples provided in destination (e.g. 32 kHz, diff --git a/common_audio/resampler/include/resampler.h b/common_audio/resampler/include/resampler.h index fec2c1a7bf..f923b464d8 100644 --- a/common_audio/resampler/include/resampler.h +++ b/common_audio/resampler/include/resampler.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* * A wrapper for resampling a numerous amount of sampling combinations. */ @@ -36,8 +35,11 @@ class Resampler { int ResetIfNeeded(int inFreq, int outFreq, size_t num_channels); // Resample samplesIn to samplesOut. - int Push(const int16_t* samplesIn, size_t lengthIn, int16_t* samplesOut, - size_t maxLen, size_t& outLen); // NOLINT: to avoid changing APIs + int Push(const int16_t* samplesIn, + size_t lengthIn, + int16_t* samplesOut, + size_t maxLen, + size_t& outLen); // NOLINT: to avoid changing APIs private: enum ResamplerMode { diff --git a/common_audio/resampler/push_resampler.cc b/common_audio/resampler/push_resampler.cc index 3930624b2a..cc24c4b3f6 100644 --- a/common_audio/resampler/push_resampler.cc +++ b/common_audio/resampler/push_resampler.cc @@ -25,7 +25,8 @@ namespace { // caused the compiler to generate code that threw off the linker. // TODO(tommi): Re-enable when we've figured out what the problem is. // http://crbug.com/615050 -void CheckValidInitParams(int src_sample_rate_hz, int dst_sample_rate_hz, +void CheckValidInitParams(int src_sample_rate_hz, + int dst_sample_rate_hz, size_t num_channels) { // The below checks are temporarily disabled on WEBRTC_WIN due to problems // with clang debug builds. @@ -57,14 +58,10 @@ void CheckExpectedBufferSizes(size_t src_length, template PushResampler::PushResampler() - : src_sample_rate_hz_(0), - dst_sample_rate_hz_(0), - num_channels_(0) { -} + : src_sample_rate_hz_(0), dst_sample_rate_hz_(0), num_channels_(0) {} template -PushResampler::~PushResampler() { -} +PushResampler::~PushResampler() {} template int PushResampler::InitializeIfNeeded(int src_sample_rate_hz, @@ -92,22 +89,24 @@ int PushResampler::InitializeIfNeeded(int src_sample_rate_hz, static_cast(src_sample_rate_hz / 100); const size_t dst_size_10ms_mono = static_cast(dst_sample_rate_hz / 100); - sinc_resampler_.reset(new PushSincResampler(src_size_10ms_mono, - dst_size_10ms_mono)); + sinc_resampler_.reset( + new PushSincResampler(src_size_10ms_mono, dst_size_10ms_mono)); if (num_channels_ == 2) { src_left_.reset(new T[src_size_10ms_mono]); src_right_.reset(new T[src_size_10ms_mono]); dst_left_.reset(new T[dst_size_10ms_mono]); dst_right_.reset(new T[dst_size_10ms_mono]); - sinc_resampler_right_.reset(new PushSincResampler(src_size_10ms_mono, - dst_size_10ms_mono)); + sinc_resampler_right_.reset( + new PushSincResampler(src_size_10ms_mono, dst_size_10ms_mono)); } return 0; } template -int PushResampler::Resample(const T* src, size_t src_length, T* dst, +int PushResampler::Resample(const T* src, + size_t src_length, + T* dst, size_t dst_capacity) { CheckExpectedBufferSizes(src_length, dst_capacity, num_channels_, src_sample_rate_hz_, dst_sample_rate_hz_); @@ -124,9 +123,8 @@ int PushResampler::Resample(const T* src, size_t src_length, T* dst, T* deinterleaved[] = {src_left_.get(), src_right_.get()}; Deinterleave(src, src_length_mono, num_channels_, deinterleaved); - size_t dst_length_mono = - sinc_resampler_->Resample(src_left_.get(), src_length_mono, - dst_left_.get(), dst_capacity_mono); + size_t dst_length_mono = sinc_resampler_->Resample( + src_left_.get(), src_length_mono, dst_left_.get(), dst_capacity_mono); sinc_resampler_right_->Resample(src_right_.get(), src_length_mono, dst_right_.get(), dst_capacity_mono); diff --git a/common_audio/resampler/push_sinc_resampler.cc b/common_audio/resampler/push_sinc_resampler.cc index 14ab330cdf..3bfead26e7 100644 --- a/common_audio/resampler/push_sinc_resampler.cc +++ b/common_audio/resampler/push_sinc_resampler.cc @@ -28,8 +28,7 @@ PushSincResampler::PushSincResampler(size_t source_frames, first_pass_(true), source_available_(0) {} -PushSincResampler::~PushSincResampler() { -} +PushSincResampler::~PushSincResampler() {} size_t PushSincResampler::Resample(const int16_t* source, size_t source_length, diff --git a/common_audio/resampler/push_sinc_resampler.h b/common_audio/resampler/push_sinc_resampler.h index bdc03a2c00..ad51471294 100644 --- a/common_audio/resampler/push_sinc_resampler.h +++ b/common_audio/resampler/push_sinc_resampler.h @@ -36,8 +36,10 @@ class PushSincResampler : public SincResamplerCallback { // at least as large as |destination_frames|. Returns the number of samples // provided in destination (for convenience, since this will always be equal // to |destination_frames|). - size_t Resample(const int16_t* source, size_t source_frames, - int16_t* destination, size_t destination_capacity); + size_t Resample(const int16_t* source, + size_t source_frames, + int16_t* destination, + size_t destination_capacity); size_t Resample(const float* source, size_t source_frames, float* destination, diff --git a/common_audio/resampler/push_sinc_resampler_unittest.cc b/common_audio/resampler/push_sinc_resampler_unittest.cc index 3be7c0a365..042b5f3959 100644 --- a/common_audio/resampler/push_sinc_resampler_unittest.cc +++ b/common_audio/resampler/push_sinc_resampler_unittest.cc @@ -36,14 +36,13 @@ T DBFS(T x) { } // namespace class PushSincResamplerTest : public ::testing::TestWithParam< - ::testing::tuple> { + ::testing::tuple> { public: PushSincResamplerTest() : input_rate_(::testing::get<0>(GetParam())), output_rate_(::testing::get<1>(GetParam())), rms_error_(::testing::get<2>(GetParam())), - low_freq_error_(::testing::get<3>(GetParam())) { - } + low_freq_error_(::testing::get<3>(GetParam())) {} ~PushSincResamplerTest() override {} @@ -82,8 +81,8 @@ void PushSincResamplerTest::ResampleBenchmarkTest(bool int_format) { source_int[i] = static_cast(floor(32767 * source[i] + 0.5)); } - printf("Benchmarking %d iterations of %d Hz -> %d Hz:\n", - kResampleIterations, input_rate_, output_rate_); + printf("Benchmarking %d iterations of %d Hz -> %d Hz:\n", kResampleIterations, + input_rate_, output_rate_); const double io_ratio = input_rate_ / static_cast(output_rate_); SincResampler sinc_resampler(io_ratio, SincResampler::kDefaultRequestSize, &resampler_source); @@ -101,25 +100,23 @@ void PushSincResamplerTest::ResampleBenchmarkTest(bool int_format) { if (int_format) { for (int i = 0; i < kResampleIterations; ++i) { EXPECT_EQ(output_samples, - resampler.Resample(source_int.get(), - input_samples, - destination_int.get(), - output_samples)); + resampler.Resample(source_int.get(), input_samples, + destination_int.get(), output_samples)); } } else { for (int i = 0; i < kResampleIterations; ++i) { - EXPECT_EQ(output_samples, - resampler.Resample(source.get(), - input_samples, - resampled_destination.get(), - output_samples)); + EXPECT_EQ(output_samples, resampler.Resample(source.get(), input_samples, + resampled_destination.get(), + output_samples)); } } double total_time_us = (rtc::TimeNanos() - start) / rtc::kNumNanosecsPerMicrosec; - printf("PushSincResampler took %.2f us per frame; which is a %.1f%% overhead " - "on SincResampler.\n\n", total_time_us / kResampleIterations, - (total_time_us - total_time_sinc_us) / total_time_sinc_us * 100); + printf( + "PushSincResampler took %.2f us per frame; which is a %.1f%% overhead " + "on SincResampler.\n\n", + total_time_us / kResampleIterations, + (total_time_us - total_time_sinc_us) / total_time_sinc_us * 100); } // Disabled because it takes too long to run routinely. Use for performance @@ -149,8 +146,8 @@ void PushSincResamplerTest::ResampleTest(bool int_format) { const double input_nyquist_freq = 0.5 * input_rate_; // Source for data to be resampled. - SinusoidalLinearChirpSource resampler_source( - input_rate_, input_samples, input_nyquist_freq, 0); + SinusoidalLinearChirpSource resampler_source(input_rate_, input_samples, + input_nyquist_freq, 0); PushSincResampler resampler(input_block_size, output_block_size); @@ -168,8 +165,8 @@ void PushSincResamplerTest::ResampleTest(bool int_format) { // deal with it in the test by delaying the "pure" source to match. It must be // checked before the first call to Resample(), because ChunkSize() will // change afterwards. - const size_t output_delay_samples = output_block_size - - resampler.get_resampler_for_testing()->ChunkSize(); + const size_t output_delay_samples = + output_block_size - resampler.get_resampler_for_testing()->ChunkSize(); // Generate resampled signal. // With the PushSincResampler, we produce the signal block-by-10ms-block @@ -178,21 +175,18 @@ void PushSincResamplerTest::ResampleTest(bool int_format) { if (int_format) { for (size_t i = 0; i < kNumBlocks; ++i) { FloatToS16(&source[i * input_block_size], input_block_size, - source_int.get()); + source_int.get()); EXPECT_EQ(output_block_size, - resampler.Resample(source_int.get(), - input_block_size, - destination_int.get(), - output_block_size)); + resampler.Resample(source_int.get(), input_block_size, + destination_int.get(), output_block_size)); S16ToFloat(destination_int.get(), output_block_size, - &resampled_destination[i * output_block_size]); + &resampled_destination[i * output_block_size]); } } else { for (size_t i = 0; i < kNumBlocks; ++i) { EXPECT_EQ( output_block_size, - resampler.Resample(&source[i * input_block_size], - input_block_size, + resampler.Resample(&source[i * input_block_size], input_block_size, &resampled_destination[i * output_block_size], output_block_size)); } @@ -252,9 +246,13 @@ void PushSincResamplerTest::ResampleTest(bool int_format) { EXPECT_LE(high_freq_max_error, kHighFrequencyMaxError); } -TEST_P(PushSincResamplerTest, ResampleInt) { ResampleTest(true); } +TEST_P(PushSincResamplerTest, ResampleInt) { + ResampleTest(true); +} -TEST_P(PushSincResamplerTest, ResampleFloat) { ResampleTest(false); } +TEST_P(PushSincResamplerTest, ResampleFloat) { + ResampleTest(false); +} // Thresholds chosen arbitrarily based on what each resampling reported during // testing. All thresholds are in dbFS, http://en.wikipedia.org/wiki/DBFS. diff --git a/common_audio/resampler/resampler.cc b/common_audio/resampler/resampler.cc index ea85d827e0..aa3a4bac2a 100644 --- a/common_audio/resampler/resampler.cc +++ b/common_audio/resampler/resampler.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* * A wrapper for resampling a numerous amount of sampling combinations. */ @@ -37,8 +36,7 @@ Resampler::Resampler() my_mode_(kResamplerMode1To1), num_channels_(0), slave_left_(nullptr), - slave_right_(nullptr) { -} + slave_right_(nullptr) {} Resampler::Resampler(int inFreq, int outFreq, size_t num_channels) : Resampler() { @@ -73,9 +71,9 @@ int Resampler::ResetIfNeeded(int inFreq, int outFreq, size_t num_channels) { int tmpInFreq_kHz = inFreq / 1000; int tmpOutFreq_kHz = outFreq / 1000; - if ((tmpInFreq_kHz != my_in_frequency_khz_) - || (tmpOutFreq_kHz != my_out_frequency_khz_) - || (num_channels != num_channels_)) { + if ((tmpInFreq_kHz != my_in_frequency_khz_) || + (tmpOutFreq_kHz != my_out_frequency_khz_) || + (num_channels != num_channels_)) { return Reset(inFreq, outFreq, num_channels); } else { return 0; @@ -191,7 +189,7 @@ int Resampler::Reset(int inFreq, int outFreq, size_t num_channels) { // 2:6 state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); WebRtcSpl_ResetResample16khzTo48khz( - static_cast(state1_)); + static_cast(state1_)); // 6:3 state2_ = malloc(8 * sizeof(int32_t)); memset(state2_, 0, 8 * sizeof(int32_t)); @@ -395,8 +393,11 @@ int Resampler::ComputeResamplerMode(int in_freq_hz, } // Synchronous resampling, all output samples are written to samplesOut -int Resampler::Push(const int16_t * samplesIn, size_t lengthIn, - int16_t* samplesOut, size_t maxLen, size_t& outLen) { +int Resampler::Push(const int16_t* samplesIn, + size_t lengthIn, + int16_t* samplesOut, + size_t maxLen, + size_t& outLen) { if (num_channels_ == 2) { // Split up the signal and call the slave object for each channel int16_t* left = @@ -575,7 +576,7 @@ int Resampler::Push(const int16_t * samplesIn, size_t lengthIn, if ((lengthIn % 160) != 0) { return -1; } - tmp = static_cast (malloc(sizeof(int16_t) * lengthIn * 3)); + tmp = static_cast(malloc(sizeof(int16_t) * lengthIn * 3)); tmp_mem = static_cast(malloc(336 * sizeof(int32_t))); for (size_t i = 0; i < lengthIn; i += 160) { WebRtcSpl_Resample16khzTo48khz( @@ -827,7 +828,7 @@ int Resampler::Push(const int16_t * samplesIn, size_t lengthIn, return -1; } // 3:6 - tmp = static_cast (malloc(sizeof(int16_t) * lengthIn * 2)); + tmp = static_cast(malloc(sizeof(int16_t) * lengthIn * 2)); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, static_cast(state1_)); lengthIn *= 2; @@ -858,8 +859,8 @@ int Resampler::Push(const int16_t * samplesIn, size_t lengthIn, return -1; } tmp_mem = static_cast(malloc(126 * sizeof(int32_t))); - tmp = static_cast( - malloc((lengthIn * 4) / 11 * sizeof(int16_t))); + tmp = + static_cast(malloc((lengthIn * 4) / 11 * sizeof(int16_t))); for (size_t i = 0; i < lengthIn; i += 220) { WebRtcSpl_Resample22khzTo8khz( diff --git a/common_audio/resampler/resampler_unittest.cc b/common_audio/resampler/resampler_unittest.cc index 0300719637..d992d5064b 100644 --- a/common_audio/resampler/resampler_unittest.cc +++ b/common_audio/resampler/resampler_unittest.cc @@ -23,17 +23,10 @@ const size_t kNumChannelsSize = sizeof(kNumChannels) / sizeof(*kNumChannels); // Rates we must support. const int kMaxRate = 96000; -const int kRates[] = { - 8000, - 16000, - 32000, - 44000, - 48000, - kMaxRate -}; +const int kRates[] = {8000, 16000, 32000, 44000, 48000, kMaxRate}; const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); const int kMaxChannels = 2; -const size_t kDataSize = static_cast (kMaxChannels * kMaxRate / 100); +const size_t kDataSize = static_cast(kMaxChannels * kMaxRate / 100); // TODO(andrew): should we be supporting these combinations? bool ValidRates(int in_rate, int out_rate) { @@ -99,7 +92,7 @@ TEST_F(ResamplerTest, Reset) { for (size_t k = 0; k < kNumChannelsSize; ++k) { std::ostringstream ss; ss << "Input rate: " << kRates[i] << ", output rate: " << kRates[j] - << ", channels: " << kNumChannels[k]; + << ", channels: " << kNumChannels[k]; SCOPED_TRACE(ss.str()); if (ValidRates(kRates[i], kRates[j])) EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], kNumChannels[k])); @@ -124,8 +117,8 @@ TEST_F(ResamplerTest, Mono) { size_t in_length = static_cast(kRates[i] / 100); size_t out_length = 0; EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], kChannels)); - EXPECT_EQ(0, rs_.Push(data_in_, in_length, data_out_, kDataSize, - out_length)); + EXPECT_EQ( + 0, rs_.Push(data_in_, in_length, data_out_, kDataSize, out_length)); EXPECT_EQ(static_cast(kRates[j] / 100), out_length); } else { EXPECT_EQ(-1, rs_.Reset(kRates[i], kRates[j], kChannels)); @@ -145,14 +138,12 @@ TEST_F(ResamplerTest, Stereo) { if (ValidRates(kRates[i], kRates[j])) { size_t in_length = static_cast(kChannels * kRates[i] / 100); size_t out_length = 0; - EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], - kChannels)); - EXPECT_EQ(0, rs_.Push(data_in_, in_length, data_out_, kDataSize, - out_length)); + EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], kChannels)); + EXPECT_EQ( + 0, rs_.Push(data_in_, in_length, data_out_, kDataSize, out_length)); EXPECT_EQ(static_cast(kChannels * kRates[j] / 100), out_length); } else { - EXPECT_EQ(-1, rs_.Reset(kRates[i], kRates[j], - kChannels)); + EXPECT_EQ(-1, rs_.Reset(kRates[i], kRates[j], kChannels)); } } } diff --git a/common_audio/resampler/sinc_resampler.cc b/common_audio/resampler/sinc_resampler.cc index 2ea91963e8..c3d1ea466a 100644 --- a/common_audio/resampler/sinc_resampler.cc +++ b/common_audio/resampler/sinc_resampler.cc @@ -217,23 +217,23 @@ void SincResampler::InitializeKernel() { for (size_t i = 0; i < kKernelSize; ++i) { const size_t idx = i + offset_idx * kKernelSize; - const float pre_sinc = static_cast(M_PI * - (static_cast(i) - static_cast(kKernelSize / 2) - - subsample_offset)); + const float pre_sinc = static_cast( + M_PI * (static_cast(i) - static_cast(kKernelSize / 2) - + subsample_offset)); kernel_pre_sinc_storage_[idx] = pre_sinc; // Compute Blackman window, matching the offset of the sinc(). const float x = (i - subsample_offset) / kKernelSize; const float window = static_cast(kA0 - kA1 * cos(2.0 * M_PI * x) + - kA2 * cos(4.0 * M_PI * x)); + kA2 * cos(4.0 * M_PI * x)); kernel_window_storage_[idx] = window; // Compute the sinc with offset, then window the sinc() function and store // at the correct offset. - kernel_storage_[idx] = static_cast(window * - ((pre_sinc == 0) ? - sinc_scale_factor : - (sin(sinc_scale_factor * pre_sinc) / pre_sinc))); + kernel_storage_[idx] = static_cast( + window * ((pre_sinc == 0) + ? sinc_scale_factor + : (sin(sinc_scale_factor * pre_sinc) / pre_sinc))); } } } @@ -255,10 +255,10 @@ void SincResampler::SetRatio(double io_sample_rate_ratio) { const float window = kernel_window_storage_[idx]; const float pre_sinc = kernel_pre_sinc_storage_[idx]; - kernel_storage_[idx] = static_cast(window * - ((pre_sinc == 0) ? - sinc_scale_factor : - (sin(sinc_scale_factor * pre_sinc) / pre_sinc))); + kernel_storage_[idx] = static_cast( + window * ((pre_sinc == 0) + ? sinc_scale_factor + : (sin(sinc_scale_factor * pre_sinc) / pre_sinc))); } } } @@ -312,8 +312,8 @@ void SincResampler::Resample(size_t frames, float* destination) { // Figure out how much to weight each kernel's "convolution". const double kernel_interpolation_factor = virtual_offset_idx - offset_idx; - *destination++ = CONVOLVE_FUNC( - input_ptr, k1, k2, kernel_interpolation_factor); + *destination++ = + CONVOLVE_FUNC(input_ptr, k1, k2, kernel_interpolation_factor); // Advance the virtual index. virtual_source_idx_ += current_io_ratio; @@ -352,7 +352,8 @@ void SincResampler::Flush() { UpdateRegions(false); } -float SincResampler::Convolve_C(const float* input_ptr, const float* k1, +float SincResampler::Convolve_C(const float* input_ptr, + const float* k1, const float* k2, double kernel_interpolation_factor) { float sum1 = 0; @@ -368,7 +369,7 @@ float SincResampler::Convolve_C(const float* input_ptr, const float* k1, // Linearly interpolate the two "convolutions". return static_cast((1.0 - kernel_interpolation_factor) * sum1 + - kernel_interpolation_factor * sum2); + kernel_interpolation_factor * sum2); } } // namespace webrtc diff --git a/common_audio/resampler/sinc_resampler.h b/common_audio/resampler/sinc_resampler.h index deef7f63e4..6306bc9169 100644 --- a/common_audio/resampler/sinc_resampler.h +++ b/common_audio/resampler/sinc_resampler.h @@ -101,14 +101,18 @@ class SincResampler { // Compute convolution of |k1| and |k2| over |input_ptr|, resultant sums are // linearly interpolated using |kernel_interpolation_factor|. On x86 and ARM // the underlying implementation is chosen at run time. - static float Convolve_C(const float* input_ptr, const float* k1, - const float* k2, double kernel_interpolation_factor); + static float Convolve_C(const float* input_ptr, + const float* k1, + const float* k2, + double kernel_interpolation_factor); #if defined(WEBRTC_ARCH_X86_FAMILY) - static float Convolve_SSE(const float* input_ptr, const float* k1, + static float Convolve_SSE(const float* input_ptr, + const float* k1, const float* k2, double kernel_interpolation_factor); #elif defined(WEBRTC_HAS_NEON) - static float Convolve_NEON(const float* input_ptr, const float* k1, + static float Convolve_NEON(const float* input_ptr, + const float* k1, const float* k2, double kernel_interpolation_factor); #endif @@ -145,12 +149,14 @@ class SincResampler { // Data from the source is copied into this buffer for each processing pass. std::unique_ptr input_buffer_; - // Stores the runtime selection of which Convolve function to use. - // TODO(ajm): Move to using a global static which must only be initialized - // once by the user. We're not doing this initially, because we don't have - // e.g. a LazyInstance helper in webrtc. +// Stores the runtime selection of which Convolve function to use. +// TODO(ajm): Move to using a global static which must only be initialized +// once by the user. We're not doing this initially, because we don't have +// e.g. a LazyInstance helper in webrtc. #if defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__) - typedef float (*ConvolveProc)(const float*, const float*, const float*, + typedef float (*ConvolveProc)(const float*, + const float*, + const float*, double); ConvolveProc convolve_proc_; #endif diff --git a/common_audio/resampler/sinc_resampler_neon.cc b/common_audio/resampler/sinc_resampler_neon.cc index 9d77f0d12c..3649324d12 100644 --- a/common_audio/resampler/sinc_resampler_neon.cc +++ b/common_audio/resampler/sinc_resampler_neon.cc @@ -17,7 +17,8 @@ namespace webrtc { -float SincResampler::Convolve_NEON(const float* input_ptr, const float* k1, +float SincResampler::Convolve_NEON(const float* input_ptr, + const float* k1, const float* k2, double kernel_interpolation_factor) { float32x4_t m_input; @@ -25,7 +26,7 @@ float SincResampler::Convolve_NEON(const float* input_ptr, const float* k1, float32x4_t m_sums2 = vmovq_n_f32(0); const float* upper = input_ptr + kKernelSize; - for (; input_ptr < upper; ) { + for (; input_ptr < upper;) { m_input = vld1q_f32(input_ptr); input_ptr += 4; m_sums1 = vmlaq_f32(m_sums1, m_input, vld1q_f32(k1)); diff --git a/common_audio/resampler/sinc_resampler_sse.cc b/common_audio/resampler/sinc_resampler_sse.cc index 711110858f..3906a79752 100644 --- a/common_audio/resampler/sinc_resampler_sse.cc +++ b/common_audio/resampler/sinc_resampler_sse.cc @@ -17,7 +17,8 @@ namespace webrtc { -float SincResampler::Convolve_SSE(const float* input_ptr, const float* k1, +float SincResampler::Convolve_SSE(const float* input_ptr, + const float* k1, const float* k2, double kernel_interpolation_factor) { __m128 m_input; @@ -41,17 +42,18 @@ float SincResampler::Convolve_SSE(const float* input_ptr, const float* k1, } // Linearly interpolate the two "convolutions". - m_sums1 = _mm_mul_ps(m_sums1, _mm_set_ps1( - static_cast(1.0 - kernel_interpolation_factor))); - m_sums2 = _mm_mul_ps(m_sums2, _mm_set_ps1( - static_cast(kernel_interpolation_factor))); + m_sums1 = _mm_mul_ps( + m_sums1, + _mm_set_ps1(static_cast(1.0 - kernel_interpolation_factor))); + m_sums2 = _mm_mul_ps( + m_sums2, _mm_set_ps1(static_cast(kernel_interpolation_factor))); m_sums1 = _mm_add_ps(m_sums1, m_sums2); // Sum components together. float result; m_sums2 = _mm_add_ps(_mm_movehl_ps(m_sums1, m_sums1), m_sums1); - _mm_store_ss(&result, _mm_add_ss(m_sums2, _mm_shuffle_ps( - m_sums2, m_sums2, 1))); + _mm_store_ss(&result, + _mm_add_ss(m_sums2, _mm_shuffle_ps(m_sums2, m_sums2, 1))); return result; } diff --git a/common_audio/resampler/sinc_resampler_unittest.cc b/common_audio/resampler/sinc_resampler_unittest.cc index 87e991d3b6..90bdf31369 100644 --- a/common_audio/resampler/sinc_resampler_unittest.cc +++ b/common_audio/resampler/sinc_resampler_unittest.cc @@ -67,14 +67,14 @@ TEST(SincResamplerTest, ChunkedResample) { std::unique_ptr resampled_destination(new float[max_chunk_size]); // Verify requesting ChunkSize() frames causes a single callback. - EXPECT_CALL(mock_source, Run(_, _)) - .Times(1).WillOnce(ClearBuffer()); + EXPECT_CALL(mock_source, Run(_, _)).Times(1).WillOnce(ClearBuffer()); resampler.Resample(resampler.ChunkSize(), resampled_destination.get()); // Verify requesting kChunks * ChunkSize() frames causes kChunks callbacks. testing::Mock::VerifyAndClear(&mock_source); EXPECT_CALL(mock_source, Run(_, _)) - .Times(kChunks).WillRepeatedly(ClearBuffer()); + .Times(kChunks) + .WillRepeatedly(ClearBuffer()); resampler.Resample(max_chunk_size, resampled_destination.get()); } @@ -87,16 +87,14 @@ TEST(SincResamplerTest, Flush) { new float[resampler.ChunkSize()]); // Fill the resampler with junk data. - EXPECT_CALL(mock_source, Run(_, _)) - .Times(1).WillOnce(FillBuffer()); + EXPECT_CALL(mock_source, Run(_, _)).Times(1).WillOnce(FillBuffer()); resampler.Resample(resampler.ChunkSize() / 2, resampled_destination.get()); ASSERT_NE(resampled_destination[0], 0); // Flush and request more data, which should all be zeros now. resampler.Flush(); testing::Mock::VerifyAndClear(&mock_source); - EXPECT_CALL(mock_source, Run(_, _)) - .Times(1).WillOnce(ClearBuffer()); + EXPECT_CALL(mock_source, Run(_, _)).Times(1).WillOnce(ClearBuffer()); resampler.Resample(resampler.ChunkSize() / 2, resampled_destination.get()); for (size_t i = 0; i < resampler.ChunkSize() / 2; ++i) ASSERT_FLOAT_EQ(resampled_destination[i], 0); @@ -116,7 +114,6 @@ TEST(SincResamplerTest, DISABLED_SetRatioBench) { printf("SetRatio() took %.2fms.\n", total_time_c_us / 1000); } - // Define platform independent function name for Convolve* tests. #if defined(WEBRTC_ARCH_X86_FAMILY) #define CONVOLVE_FUNC Convolve_SSE @@ -232,8 +229,7 @@ TEST(SincResamplerTest, ConvolveBenchmark) { #undef CONVOLVE_FUNC typedef std::tuple SincResamplerTestData; -class SincResamplerTest - : public testing::TestWithParam { +class SincResamplerTest : public testing::TestWithParam { public: SincResamplerTest() : input_rate_(std::get<0>(GetParam())), @@ -263,8 +259,8 @@ TEST_P(SincResamplerTest, Resample) { const double input_nyquist_freq = 0.5 * input_rate_; // Source for data to be resampled. - SinusoidalLinearChirpSource resampler_source( - input_rate_, input_samples, input_nyquist_freq, 0); + SinusoidalLinearChirpSource resampler_source(input_rate_, input_samples, + input_nyquist_freq, 0); const double io_ratio = input_rate_ / static_cast(output_rate_); SincResampler resampler(io_ratio, SincResampler::kDefaultRequestSize, @@ -291,8 +287,8 @@ TEST_P(SincResamplerTest, Resample) { resampler.Resample(output_samples, resampled_destination.get()); // Generate pure signal. - SinusoidalLinearChirpSource pure_source( - output_rate_, output_samples, input_nyquist_freq, 0); + SinusoidalLinearChirpSource pure_source(output_rate_, output_samples, + input_nyquist_freq, 0); pure_source.Run(output_samples, pure_destination.get()); // Range of the Nyquist frequency (0.5 * min(input rate, output_rate)) which @@ -324,8 +320,8 @@ TEST_P(SincResamplerTest, Resample) { double rms_error = sqrt(sum_of_squares / output_samples); - // Convert each error to dbFS. - #define DBFS(x) 20 * log10(x) +// Convert each error to dbFS. +#define DBFS(x) 20 * log10(x) rms_error = DBFS(rms_error); low_freq_max_error = DBFS(low_freq_max_error); high_freq_max_error = DBFS(high_freq_max_error); diff --git a/common_audio/resampler/sinusoidal_linear_chirp_source.cc b/common_audio/resampler/sinusoidal_linear_chirp_source.cc index 134044e778..2afdd1be47 100644 --- a/common_audio/resampler/sinusoidal_linear_chirp_source.cc +++ b/common_audio/resampler/sinusoidal_linear_chirp_source.cc @@ -43,8 +43,7 @@ void SinusoidalLinearChirpSource::Run(size_t frames, float* destination) { } else { // Sinusoidal linear chirp. double t = (current_index_ - delay_samples_) / sample_rate_; - destination[i] = - sin(2 * M_PI * (kMinFrequency * t + (k_ / 2) * t * t)); + destination[i] = sin(2 * M_PI * (kMinFrequency * t + (k_ / 2) * t * t)); } } } @@ -52,7 +51,7 @@ void SinusoidalLinearChirpSource::Run(size_t frames, float* destination) { double SinusoidalLinearChirpSource::Frequency(size_t position) { return kMinFrequency + (position - delay_samples_) * - (max_frequency_ - kMinFrequency) / total_samples_; + (max_frequency_ - kMinFrequency) / total_samples_; } } // namespace webrtc diff --git a/common_audio/resampler/sinusoidal_linear_chirp_source.h b/common_audio/resampler/sinusoidal_linear_chirp_source.h index 7fcbaa0821..e9f3ca34e8 100644 --- a/common_audio/resampler/sinusoidal_linear_chirp_source.h +++ b/common_audio/resampler/sinusoidal_linear_chirp_source.h @@ -26,8 +26,10 @@ class SinusoidalLinearChirpSource : public SincResamplerCallback { public: // |delay_samples| can be used to insert a fractional sample delay into the // source. It will produce zeros until non-negative time is reached. - SinusoidalLinearChirpSource(int sample_rate, size_t samples, - double max_frequency, double delay_samples); + SinusoidalLinearChirpSource(int sample_rate, + size_t samples, + double max_frequency, + double delay_samples); virtual ~SinusoidalLinearChirpSource() {} @@ -36,9 +38,7 @@ class SinusoidalLinearChirpSource : public SincResamplerCallback { double Frequency(size_t position); private: - enum { - kMinFrequency = 5 - }; + enum { kMinFrequency = 5 }; int sample_rate_; size_t total_samples_; diff --git a/common_audio/ring_buffer.h b/common_audio/ring_buffer.h index aa2ac27375..0bbe879980 100644 --- a/common_audio/ring_buffer.h +++ b/common_audio/ring_buffer.h @@ -53,7 +53,8 @@ size_t WebRtc_ReadBuffer(RingBuffer* handle, size_t element_count); // Writes |data| to buffer and returns the number of elements written. -size_t WebRtc_WriteBuffer(RingBuffer* handle, const void* data, +size_t WebRtc_WriteBuffer(RingBuffer* handle, + const void* data, size_t element_count); // Moves the buffer read position and returns the number of elements moved. diff --git a/common_audio/ring_buffer_unittest.cc b/common_audio/ring_buffer_unittest.cc index 4bb1497b17..130e124673 100644 --- a/common_audio/ring_buffer_unittest.cc +++ b/common_audio/ring_buffer_unittest.cc @@ -21,9 +21,7 @@ namespace webrtc { struct FreeBufferDeleter { - inline void operator()(void* ptr) const { - WebRtc_FreeBuffer(ptr); - } + inline void operator()(void* ptr) const { WebRtc_FreeBuffer(ptr); } }; typedef std::unique_ptr scoped_ring_buffer; @@ -31,7 +29,8 @@ static void AssertElementEq(int expected, int actual) { ASSERT_EQ(expected, actual); } -static int SetIncrementingData(int* data, int num_elements, +static int SetIncrementingData(int* data, + int num_elements, int starting_value) { for (int i = 0; i < num_elements; i++) { data[i] = starting_value++; @@ -39,7 +38,8 @@ static int SetIncrementingData(int* data, int num_elements, return starting_value; } -static int CheckIncrementingData(int* data, int num_elements, +static int CheckIncrementingData(int* data, + int num_elements, int starting_value) { for (int i = 0; i < num_elements; i++) { AssertElementEq(starting_value++, data[i]); @@ -70,35 +70,33 @@ static void RandomStressTest(int** data_ptr) { int read_element = 0; for (int j = 0; j < kNumOps; j++) { const bool write = rand() % 2 == 0 ? true : false; // NOLINT - const int num_elements = rand() % buffer_size; // NOLINT + const int num_elements = rand() % buffer_size; // NOLINT if (write) { const int buffer_available = buffer_size - buffer_consumed; ASSERT_EQ(static_cast(buffer_available), WebRtc_available_write(buffer.get())); const int expected_elements = std::min(num_elements, buffer_available); write_element = SetIncrementingData(write_data.get(), expected_elements, - write_element); - ASSERT_EQ(static_cast(expected_elements), - WebRtc_WriteBuffer(buffer.get(), write_data.get(), - num_elements)); - buffer_consumed = std::min(buffer_consumed + expected_elements, - buffer_size); + write_element); + ASSERT_EQ( + static_cast(expected_elements), + WebRtc_WriteBuffer(buffer.get(), write_data.get(), num_elements)); + buffer_consumed = + std::min(buffer_consumed + expected_elements, buffer_size); } else { - const int expected_elements = std::min(num_elements, - buffer_consumed); + const int expected_elements = std::min(num_elements, buffer_consumed); ASSERT_EQ(static_cast(buffer_consumed), WebRtc_available_read(buffer.get())); - ASSERT_EQ(static_cast(expected_elements), - WebRtc_ReadBuffer(buffer.get(), - reinterpret_cast(data_ptr), - read_data.get(), - num_elements)); + ASSERT_EQ( + static_cast(expected_elements), + WebRtc_ReadBuffer(buffer.get(), reinterpret_cast(data_ptr), + read_data.get(), num_elements)); int* check_ptr = read_data.get(); if (data_ptr) { check_ptr = *data_ptr; } - read_element = CheckIncrementingData(check_ptr, expected_elements, - read_element); + read_element = + CheckIncrementingData(check_ptr, expected_elements, read_element); buffer_consumed = std::max(buffer_consumed - expected_elements, 0); } } @@ -127,8 +125,9 @@ TEST(RingBufferTest, PassingNulltoReadBufferForcesMemcpy) { SetIncrementingData(write_data, kDataSize, 0); EXPECT_EQ(kDataSize, WebRtc_WriteBuffer(buffer.get(), write_data, kDataSize)); SetIncrementingData(read_data, kDataSize, kDataSize); - EXPECT_EQ(kDataSize, WebRtc_ReadBuffer(buffer.get(), - reinterpret_cast(&data_ptr), read_data, kDataSize)); + EXPECT_EQ(kDataSize, + WebRtc_ReadBuffer(buffer.get(), reinterpret_cast(&data_ptr), + read_data, kDataSize)); // Copying was not necessary, so |read_data| has not been updated. CheckIncrementingData(data_ptr, kDataSize, 0); CheckIncrementingData(read_data, kDataSize, kDataSize); diff --git a/common_audio/signal_processing/complex_fft_tables.h b/common_audio/signal_processing/complex_fft_tables.h index 6c3fcfdbe0..5171040f5d 100644 --- a/common_audio/signal_processing/complex_fft_tables.h +++ b/common_audio/signal_processing/complex_fft_tables.h @@ -8,141 +8,125 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_ #define COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_ #include "typedefs.h" // NOLINT(build/include) static const int16_t kSinTable1024[] = { - 0, 201, 402, 603, 804, 1005, 1206, 1406, - 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, - 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608, - 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195, - 6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766, - 7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319, - 9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849, - 11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353, - 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827, - 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268, - 15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672, - 16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036, - 18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357, - 19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631, - 20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855, - 22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027, - 23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143, - 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201, - 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198, - 26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132, - 27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001, - 28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802, - 28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534, - 29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195, - 30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783, - 30851, 30918, 30984, 31049, 31113, 31175, 31236, 31297, - 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735, - 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097, - 32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382, - 32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588, - 32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717, - 32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766, - 32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736, - 32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628, - 32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441, - 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176, - 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833, - 31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413, - 31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918, - 30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349, - 30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706, - 29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992, - 28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208, - 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355, - 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437, - 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456, - 25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413, - 24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311, - 23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153, - 22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942, - 20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680, - 19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371, - 18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017, - 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623, - 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, - 14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724, - 12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227, - 11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703, - 9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156, - 7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589, - 6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006, - 4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411, - 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808, - 1607, 1406, 1206, 1005, 804, 603, 402, 201, - 0, -201, -402, -603, -804, -1005, -1206, -1406, - -1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011, - -3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608, - -4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195, - -6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766, - -7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319, - -9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849, - -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353, - -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827, - -14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268, - -15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672, - -16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036, - -18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357, - -19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631, - -20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855, - -22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027, - -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143, - -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201, - -25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198, - -26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132, - -27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001, - -28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802, - -28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534, - -29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195, - -30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783, - -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297, - -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735, - -31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097, - -32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382, - -32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588, - -32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717, - -32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766, - -32767, -32766, -32764, -32761, -32757, -32751, -32744, -32736, - -32727, -32717, -32705, -32692, -32678, -32662, -32646, -32628, - -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441, - -32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176, - -32137, -32097, -32056, -32014, -31970, -31926, -31880, -31833, - -31785, -31735, -31684, -31633, -31580, -31525, -31470, -31413, - -31356, -31297, -31236, -31175, -31113, -31049, -30984, -30918, - -30851, -30783, -30713, -30643, -30571, -30498, -30424, -30349, - -30272, -30195, -30116, -30036, -29955, -29873, -29790, -29706, - -29621, -29534, -29446, -29358, -29268, -29177, -29085, -28992, - -28897, -28802, -28706, -28608, -28510, -28410, -28309, -28208, - -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355, - -27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437, - -26318, -26198, -26077, -25954, -25831, -25707, -25582, -25456, - -25329, -25201, -25072, -24942, -24811, -24679, -24546, -24413, - -24278, -24143, -24006, -23869, -23731, -23592, -23452, -23311, - -23169, -23027, -22883, -22739, -22594, -22448, -22301, -22153, - -22004, -21855, -21705, -21554, -21402, -21249, -21096, -20942, - -20787, -20631, -20474, -20317, -20159, -20000, -19840, -19680, - -19519, -19357, -19194, -19031, -18867, -18702, -18537, -18371, - -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017, - -16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623, - -15446, -15268, -15090, -14911, -14732, -14552, -14372, -14191, - -14009, -13827, -13645, -13462, -13278, -13094, -12909, -12724, - -12539, -12353, -12166, -11980, -11792, -11604, -11416, -11227, - -11038, -10849, -10659, -10469, -10278, -10087, -9895, -9703, - -9511, -9319, -9126, -8932, -8739, -8545, -8351, -8156, - -7961, -7766, -7571, -7375, -7179, -6982, -6786, -6589, - -6392, -6195, -5997, -5799, -5601, -5403, -5205, -5006, - -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411, - -3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808, - -1607, -1406, -1206, -1005, -804, -603, -402, -201 -}; + 0, 201, 402, 603, 804, 1005, 1206, 1406, 1607, + 1808, 2009, 2209, 2410, 2610, 2811, 3011, 3211, 3411, + 3611, 3811, 4011, 4210, 4409, 4608, 4807, 5006, 5205, + 5403, 5601, 5799, 5997, 6195, 6392, 6589, 6786, 6982, + 7179, 7375, 7571, 7766, 7961, 8156, 8351, 8545, 8739, + 8932, 9126, 9319, 9511, 9703, 9895, 10087, 10278, 10469, + 10659, 10849, 11038, 11227, 11416, 11604, 11792, 11980, 12166, + 12353, 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827, + 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268, 15446, + 15623, 15799, 15975, 16150, 16325, 16499, 16672, 16845, 17017, + 17189, 17360, 17530, 17699, 17868, 18036, 18204, 18371, 18537, + 18702, 18867, 19031, 19194, 19357, 19519, 19680, 19840, 20000, + 20159, 20317, 20474, 20631, 20787, 20942, 21096, 21249, 21402, + 21554, 21705, 21855, 22004, 22153, 22301, 22448, 22594, 22739, + 22883, 23027, 23169, 23311, 23452, 23592, 23731, 23869, 24006, + 24143, 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201, + 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198, 26318, + 26437, 26556, 26673, 26789, 26905, 27019, 27132, 27244, 27355, + 27466, 27575, 27683, 27790, 27896, 28001, 28105, 28208, 28309, + 28410, 28510, 28608, 28706, 28802, 28897, 28992, 29085, 29177, + 29268, 29358, 29446, 29534, 29621, 29706, 29790, 29873, 29955, + 30036, 30116, 30195, 30272, 30349, 30424, 30498, 30571, 30643, + 30713, 30783, 30851, 30918, 30984, 31049, 31113, 31175, 31236, + 31297, 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735, + 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097, 32137, + 32176, 32213, 32249, 32284, 32318, 32350, 32382, 32412, 32441, + 32468, 32495, 32520, 32544, 32567, 32588, 32609, 32628, 32646, + 32662, 32678, 32692, 32705, 32717, 32727, 32736, 32744, 32751, + 32757, 32761, 32764, 32766, 32767, 32766, 32764, 32761, 32757, + 32751, 32744, 32736, 32727, 32717, 32705, 32692, 32678, 32662, + 32646, 32628, 32609, 32588, 32567, 32544, 32520, 32495, 32468, + 32441, 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176, + 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833, 31785, + 31735, 31684, 31633, 31580, 31525, 31470, 31413, 31356, 31297, + 31236, 31175, 31113, 31049, 30984, 30918, 30851, 30783, 30713, + 30643, 30571, 30498, 30424, 30349, 30272, 30195, 30116, 30036, + 29955, 29873, 29790, 29706, 29621, 29534, 29446, 29358, 29268, + 29177, 29085, 28992, 28897, 28802, 28706, 28608, 28510, 28410, + 28309, 28208, 28105, 28001, 27896, 27790, 27683, 27575, 27466, + 27355, 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437, + 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456, 25329, + 25201, 25072, 24942, 24811, 24679, 24546, 24413, 24278, 24143, + 24006, 23869, 23731, 23592, 23452, 23311, 23169, 23027, 22883, + 22739, 22594, 22448, 22301, 22153, 22004, 21855, 21705, 21554, + 21402, 21249, 21096, 20942, 20787, 20631, 20474, 20317, 20159, + 20000, 19840, 19680, 19519, 19357, 19194, 19031, 18867, 18702, + 18537, 18371, 18204, 18036, 17868, 17699, 17530, 17360, 17189, + 17017, 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623, + 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, 14009, + 13827, 13645, 13462, 13278, 13094, 12909, 12724, 12539, 12353, + 12166, 11980, 11792, 11604, 11416, 11227, 11038, 10849, 10659, + 10469, 10278, 10087, 9895, 9703, 9511, 9319, 9126, 8932, + 8739, 8545, 8351, 8156, 7961, 7766, 7571, 7375, 7179, + 6982, 6786, 6589, 6392, 6195, 5997, 5799, 5601, 5403, + 5205, 5006, 4807, 4608, 4409, 4210, 4011, 3811, 3611, + 3411, 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808, + 1607, 1406, 1206, 1005, 804, 603, 402, 201, 0, + -201, -402, -603, -804, -1005, -1206, -1406, -1607, -1808, + -2009, -2209, -2410, -2610, -2811, -3011, -3211, -3411, -3611, + -3811, -4011, -4210, -4409, -4608, -4807, -5006, -5205, -5403, + -5601, -5799, -5997, -6195, -6392, -6589, -6786, -6982, -7179, + -7375, -7571, -7766, -7961, -8156, -8351, -8545, -8739, -8932, + -9126, -9319, -9511, -9703, -9895, -10087, -10278, -10469, -10659, + -10849, -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353, + -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827, -14009, + -14191, -14372, -14552, -14732, -14911, -15090, -15268, -15446, -15623, + -15799, -15975, -16150, -16325, -16499, -16672, -16845, -17017, -17189, + -17360, -17530, -17699, -17868, -18036, -18204, -18371, -18537, -18702, + -18867, -19031, -19194, -19357, -19519, -19680, -19840, -20000, -20159, + -20317, -20474, -20631, -20787, -20942, -21096, -21249, -21402, -21554, + -21705, -21855, -22004, -22153, -22301, -22448, -22594, -22739, -22883, + -23027, -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143, + -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201, -25329, + -25456, -25582, -25707, -25831, -25954, -26077, -26198, -26318, -26437, + -26556, -26673, -26789, -26905, -27019, -27132, -27244, -27355, -27466, + -27575, -27683, -27790, -27896, -28001, -28105, -28208, -28309, -28410, + -28510, -28608, -28706, -28802, -28897, -28992, -29085, -29177, -29268, + -29358, -29446, -29534, -29621, -29706, -29790, -29873, -29955, -30036, + -30116, -30195, -30272, -30349, -30424, -30498, -30571, -30643, -30713, + -30783, -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297, + -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735, -31785, + -31833, -31880, -31926, -31970, -32014, -32056, -32097, -32137, -32176, + -32213, -32249, -32284, -32318, -32350, -32382, -32412, -32441, -32468, + -32495, -32520, -32544, -32567, -32588, -32609, -32628, -32646, -32662, + -32678, -32692, -32705, -32717, -32727, -32736, -32744, -32751, -32757, + -32761, -32764, -32766, -32767, -32766, -32764, -32761, -32757, -32751, + -32744, -32736, -32727, -32717, -32705, -32692, -32678, -32662, -32646, + -32628, -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441, + -32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176, -32137, + -32097, -32056, -32014, -31970, -31926, -31880, -31833, -31785, -31735, + -31684, -31633, -31580, -31525, -31470, -31413, -31356, -31297, -31236, + -31175, -31113, -31049, -30984, -30918, -30851, -30783, -30713, -30643, + -30571, -30498, -30424, -30349, -30272, -30195, -30116, -30036, -29955, + -29873, -29790, -29706, -29621, -29534, -29446, -29358, -29268, -29177, + -29085, -28992, -28897, -28802, -28706, -28608, -28510, -28410, -28309, + -28208, -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355, + -27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437, -26318, + -26198, -26077, -25954, -25831, -25707, -25582, -25456, -25329, -25201, + -25072, -24942, -24811, -24679, -24546, -24413, -24278, -24143, -24006, + -23869, -23731, -23592, -23452, -23311, -23169, -23027, -22883, -22739, + -22594, -22448, -22301, -22153, -22004, -21855, -21705, -21554, -21402, + -21249, -21096, -20942, -20787, -20631, -20474, -20317, -20159, -20000, + -19840, -19680, -19519, -19357, -19194, -19031, -18867, -18702, -18537, + -18371, -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017, + -16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623, -15446, + -15268, -15090, -14911, -14732, -14552, -14372, -14191, -14009, -13827, + -13645, -13462, -13278, -13094, -12909, -12724, -12539, -12353, -12166, + -11980, -11792, -11604, -11416, -11227, -11038, -10849, -10659, -10469, + -10278, -10087, -9895, -9703, -9511, -9319, -9126, -8932, -8739, + -8545, -8351, -8156, -7961, -7766, -7571, -7375, -7179, -6982, + -6786, -6589, -6392, -6195, -5997, -5799, -5601, -5403, -5205, + -5006, -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411, + -3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808, -1607, + -1406, -1206, -1005, -804, -603, -402, -201}; #endif // COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_ diff --git a/common_audio/signal_processing/include/real_fft.h b/common_audio/signal_processing/include/real_fft.h index 00d18caeb5..8da243da30 100644 --- a/common_audio/signal_processing/include/real_fft.h +++ b/common_audio/signal_processing/include/real_fft.h @@ -15,7 +15,7 @@ // For ComplexFFT(), the maximum fft order is 10; // WebRTC APM uses orders of only 7 and 8. -enum {kMaxFFTOrder = 10}; +enum { kMaxFFTOrder = 10 }; struct RealFFT; diff --git a/common_audio/signal_processing/include/signal_processing_library.h b/common_audio/signal_processing/include/signal_processing_library.h index 27fea6f837..4d6edbf88e 100644 --- a/common_audio/signal_processing/include/signal_processing_library.h +++ b/common_audio/signal_processing/include/signal_processing_library.h @@ -8,11 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* - * This header file includes all of the fix point signal processing library (SPL) function - * descriptions and declarations. - * For specific function calls, see bottom of file. + * This header file includes all of the fix point signal processing library + * (SPL) function descriptions and declarations. For specific function calls, + * see bottom of file. */ #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SIGNAL_PROCESSING_LIBRARY_H_ @@ -23,63 +22,58 @@ #include "typedefs.h" // NOLINT(build/include) // Macros specific for the fixed point implementation -#define WEBRTC_SPL_WORD16_MAX 32767 -#define WEBRTC_SPL_WORD16_MIN -32768 -#define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff -#define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000 -#define WEBRTC_SPL_MAX_LPC_ORDER 14 -#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value -#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value +#define WEBRTC_SPL_WORD16_MAX 32767 +#define WEBRTC_SPL_WORD16_MIN -32768 +#define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff +#define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000 +#define WEBRTC_SPL_MAX_LPC_ORDER 14 +#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value +#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value // TODO(kma/bjorn): For the next two macros, investigate how to correct the code // for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN. -#define WEBRTC_SPL_ABS_W16(a) \ - (((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a)) -#define WEBRTC_SPL_ABS_W32(a) \ - (((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a)) +#define WEBRTC_SPL_ABS_W16(a) (((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a)) +#define WEBRTC_SPL_ABS_W32(a) (((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a)) -#define WEBRTC_SPL_MUL(a, b) \ - ((int32_t) ((int32_t)(a) * (int32_t)(b))) -#define WEBRTC_SPL_UMUL(a, b) \ - ((uint32_t) ((uint32_t)(a) * (uint32_t)(b))) -#define WEBRTC_SPL_UMUL_32_16(a, b) \ - ((uint32_t) ((uint32_t)(a) * (uint16_t)(b))) -#define WEBRTC_SPL_MUL_16_U16(a, b) \ - ((int32_t)(int16_t)(a) * (uint16_t)(b)) +#define WEBRTC_SPL_MUL(a, b) ((int32_t)((int32_t)(a) * (int32_t)(b))) +#define WEBRTC_SPL_UMUL(a, b) ((uint32_t)((uint32_t)(a) * (uint32_t)(b))) +#define WEBRTC_SPL_UMUL_32_16(a, b) ((uint32_t)((uint32_t)(a) * (uint16_t)(b))) +#define WEBRTC_SPL_MUL_16_U16(a, b) ((int32_t)(int16_t)(a) * (uint16_t)(b)) +// clang-format off +// clang-format would choose some identation +// leading to presubmit error (cpplint.py) #ifndef WEBRTC_ARCH_ARM_V7 // For ARMv7 platforms, these are inline functions in spl_inl_armv7.h #ifndef MIPS32_LE // For MIPS platforms, these are inline functions in spl_inl_mips.h -#define WEBRTC_SPL_MUL_16_16(a, b) \ - ((int32_t) (((int16_t)(a)) * ((int16_t)(b)))) +#define WEBRTC_SPL_MUL_16_16(a, b) ((int32_t)(((int16_t)(a)) * ((int16_t)(b)))) #define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \ - (WEBRTC_SPL_MUL_16_16(a, b >> 16) \ - + ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15)) + (WEBRTC_SPL_MUL_16_16(a, b >> 16) + \ + ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15)) #endif #endif #define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \ - (WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \ - (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10)) + (WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \ + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10)) #define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \ - (WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \ - (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13)) + (WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \ + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13)) #define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 1)) + \ - (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14)) + ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 1)) + \ + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14)) +// clang-format on -#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \ - (WEBRTC_SPL_MUL_16_16(a, b) >> (c)) +#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) (WEBRTC_SPL_MUL_16_16(a, b) >> (c)) #define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \ - ((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) \ - (((int32_t)1) << ((c) - 1)))) >> (c)) + ((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t)(((int32_t)1) << ((c)-1)))) >> (c)) // C + the 32 most significant bits of A * B #define WEBRTC_SPL_SCALEDIFF32(A, B, C) \ - (C + (B >> 16) * A + (((uint32_t)(B & 0x0000FFFF) * A) >> 16)) + (C + (B >> 16) * A + (((uint32_t)(B & 0x0000FFFF) * A) >> 16)) -#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b) +#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b) // Shifting with negative numbers allowed // Positive means left shift @@ -87,12 +81,11 @@ // Shifting with negative numbers not allowed // We cannot do casting here due to signed/unsigned problem -#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c)) +#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c)) -#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c)) +#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c)) -#define WEBRTC_SPL_RAND(a) \ - ((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff)) +#define WEBRTC_SPL_RAND(a) ((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff)) #ifdef __cplusplus extern "C" { @@ -131,13 +124,10 @@ void WebRtcSpl_CopyFromEndW16(const int16_t* in_vector, size_t in_vector_length, size_t samples, int16_t* out_vector); -void WebRtcSpl_ZerosArrayW16(int16_t* vector, - size_t vector_length); -void WebRtcSpl_ZerosArrayW32(int32_t* vector, - size_t vector_length); +void WebRtcSpl_ZerosArrayW16(int16_t* vector, size_t vector_length); +void WebRtcSpl_ZerosArrayW32(int32_t* vector, size_t vector_length); // End: Copy and set operations. - // Minimum and maximum operation functions and their pointers. // Implementation in min_max_operations.c. @@ -297,7 +287,6 @@ size_t WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length); // End: Minimum and maximum operations. - // Vector scaling operations. Implementation in vector_scaling_operations.c. // Description at bottom of file. void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector, @@ -323,9 +312,11 @@ void WebRtcSpl_ScaleVectorWithSat(const int16_t* in_vector, size_t vector_length, int16_t right_shifts); void WebRtcSpl_ScaleAndAddVectors(const int16_t* in_vector1, - int16_t gain1, int right_shifts1, + int16_t gain1, + int right_shifts1, const int16_t* in_vector2, - int16_t gain2, int right_shifts2, + int16_t gain2, + int right_shifts2, int16_t* out_vector, size_t vector_length); @@ -777,7 +768,8 @@ typedef struct { int32_t S_16_8[8]; } WebRtcSpl_State22khzTo8khz; -void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, int16_t* out, +void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, + int16_t* out, WebRtcSpl_State22khzTo8khz* state, int32_t* tmpmem); @@ -790,7 +782,8 @@ typedef struct { int32_t S_11_22[8]; } WebRtcSpl_State8khzTo22khz; -void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, int16_t* out, +void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, + int16_t* out, WebRtcSpl_State8khzTo22khz* state, int32_t* tmpmem); @@ -830,7 +823,8 @@ typedef struct { int32_t S_32_16[8]; } WebRtcSpl_State48khzTo16khz; -void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out, +void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, + int16_t* out, WebRtcSpl_State48khzTo16khz* state, int32_t* tmpmem); @@ -842,7 +836,8 @@ typedef struct { int32_t S_24_48[8]; } WebRtcSpl_State16khzTo48khz; -void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out, +void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, + int16_t* out, WebRtcSpl_State16khzTo48khz* state, int32_t* tmpmem); @@ -855,7 +850,8 @@ typedef struct { int32_t S_16_8[8]; } WebRtcSpl_State48khzTo8khz; -void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out, +void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, + int16_t* out, WebRtcSpl_State48khzTo8khz* state, int32_t* tmpmem); @@ -868,7 +864,8 @@ typedef struct { int32_t S_24_48[8]; } WebRtcSpl_State8khzTo48khz; -void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out, +void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, + int16_t* out, WebRtcSpl_State8khzTo48khz* state, int32_t* tmpmem); @@ -881,11 +878,15 @@ void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state); * ******************************************************************/ -void WebRtcSpl_DownsampleBy2(const int16_t* in, size_t len, - int16_t* out, int32_t* filtState); +void WebRtcSpl_DownsampleBy2(const int16_t* in, + size_t len, + int16_t* out, + int32_t* filtState); -void WebRtcSpl_UpsampleBy2(const int16_t* in, size_t len, - int16_t* out, int32_t* filtState); +void WebRtcSpl_UpsampleBy2(const int16_t* in, + size_t len, + int16_t* out, + int32_t* filtState); /************************************************************ * END OF RESAMPLING FUNCTIONS diff --git a/common_audio/signal_processing/include/spl_inl.h b/common_audio/signal_processing/include/spl_inl.h index ba3a11376b..656a3125bb 100644 --- a/common_audio/signal_processing/include/spl_inl.h +++ b/common_audio/signal_processing/include/spl_inl.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - // This header file includes the inline functions in // the fix point signal processing library. @@ -73,7 +72,7 @@ static __inline int WebRtcSpl_CountLeadingZeros64(uint64_t n) { #if !defined(MIPS_DSP_R1_LE) static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { - int16_t out16 = (int16_t) value32; + int16_t out16 = (int16_t)value32; if (value32 > 32767) out16 = 32767; @@ -112,11 +111,11 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t a, int32_t b) { } static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) { - return WebRtcSpl_SatW32ToW16((int32_t) a + (int32_t) b); + return WebRtcSpl_SatW32ToW16((int32_t)a + (int32_t)b); } static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) { - return WebRtcSpl_SatW32ToW16((int32_t) var1 - (int32_t) var2); + return WebRtcSpl_SatW32ToW16((int32_t)var1 - (int32_t)var2); } #endif // #if !defined(MIPS_DSP_R1_LE) diff --git a/common_audio/signal_processing/include/spl_inl_armv7.h b/common_audio/signal_processing/include/spl_inl_armv7.h index 97179f92f2..930e91e2b3 100644 --- a/common_audio/signal_processing/include/spl_inl_armv7.h +++ b/common_audio/signal_processing/include/spl_inl_armv7.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* This header file includes the inline functions for ARM processors in * the fix point signal processing library. */ @@ -26,35 +25,37 @@ */ static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) { int32_t tmp = 0; - __asm __volatile ("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a)); + __asm __volatile("smulwb %0, %1, %2" : "=r"(tmp) : "r"(b), "r"(a)); return tmp; } static __inline int32_t WEBRTC_SPL_MUL_16_16(int16_t a, int16_t b) { int32_t tmp = 0; - __asm __volatile ("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); + __asm __volatile("smulbb %0, %1, %2" : "=r"(tmp) : "r"(a), "r"(b)); return tmp; } // TODO(kma): add unit test. static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) { int32_t tmp = 0; - __asm __volatile ("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c)); + __asm __volatile("smlabb %0, %1, %2, %3" + : "=r"(tmp) + : "r"(a), "r"(b), "r"(c)); return tmp; } static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) { int32_t s_sum = 0; - __asm __volatile ("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b)); + __asm __volatile("qadd16 %0, %1, %2" : "=r"(s_sum) : "r"(a), "r"(b)); - return (int16_t) s_sum; + return (int16_t)s_sum; } static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) { int32_t l_sum = 0; - __asm __volatile ("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2)); + __asm __volatile("qadd %0, %1, %2" : "=r"(l_sum) : "r"(l_var1), "r"(l_var2)); return l_sum; } @@ -62,7 +63,7 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) { static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) { int32_t l_sub = 0; - __asm __volatile ("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2)); + __asm __volatile("qsub %0, %1, %2" : "=r"(l_sub) : "r"(l_var1), "r"(l_var2)); return l_sub; } @@ -70,7 +71,7 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) { static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) { int32_t s_sub = 0; - __asm __volatile ("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2)); + __asm __volatile("qsub16 %0, %1, %2" : "=r"(s_sub) : "r"(var1), "r"(var2)); return (int16_t)s_sub; } @@ -78,7 +79,7 @@ static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) { static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) { int32_t tmp = 0; - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n)); + __asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(n)); return (int16_t)(32 - tmp); } @@ -92,7 +93,7 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) { a ^= 0xFFFFFFFF; } - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); + __asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a)); return (int16_t)(tmp - 1); } @@ -100,9 +101,10 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) { static __inline int16_t WebRtcSpl_NormU32(uint32_t a) { int tmp = 0; - if (a == 0) return 0; + if (a == 0) + return 0; - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); + __asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a)); return (int16_t)tmp; } @@ -117,7 +119,7 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) { a_32 ^= 0xFFFFFFFF; } - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32)); + __asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a_32)); return (int16_t)(tmp - 17); } @@ -126,7 +128,7 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) { static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { int32_t out = 0; - __asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); + __asm __volatile("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); return (int16_t)out; } diff --git a/common_audio/signal_processing/include/spl_inl_mips.h b/common_audio/signal_processing/include/spl_inl_mips.h index 5819d0f86b..1db95e8254 100644 --- a/common_audio/signal_processing/include/spl_inl_mips.h +++ b/common_audio/signal_processing/include/spl_inl_mips.h @@ -8,69 +8,65 @@ * be found in the AUTHORS file in the root of the source tree. */ - // This header file includes the inline functions in // the fix point signal processing library. #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_MIPS_H_ #define COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_MIPS_H_ -static __inline int32_t WEBRTC_SPL_MUL_16_16(int32_t a, - int32_t b) { +static __inline int32_t WEBRTC_SPL_MUL_16_16(int32_t a, int32_t b) { int32_t value32 = 0; int32_t a1 = 0, b1 = 0; __asm __volatile( #if defined(MIPS32_R2_LE) - "seh %[a1], %[a] \n\t" - "seh %[b1], %[b] \n\t" + "seh %[a1], %[a] \n\t" + "seh %[b1], %[b] \n\t" #else - "sll %[a1], %[a], 16 \n\t" - "sll %[b1], %[b], 16 \n\t" - "sra %[a1], %[a1], 16 \n\t" - "sra %[b1], %[b1], 16 \n\t" + "sll %[a1], %[a], 16 \n\t" + "sll %[b1], %[b], 16 \n\t" + "sra %[a1], %[a1], 16 \n\t" + "sra %[b1], %[b1], 16 \n\t" #endif - "mul %[value32], %[a1], %[b1] \n\t" - : [value32] "=r" (value32), [a1] "=&r" (a1), [b1] "=&r" (b1) - : [a] "r" (a), [b] "r" (b) - : "hi", "lo"); + "mul %[value32], %[a1], %[b1] \n\t" + : [value32] "=r"(value32), [a1] "=&r"(a1), [b1] "=&r"(b1) + : [a] "r"(a), [b] "r"(b) + : "hi", "lo"); return value32; } -static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, - int32_t b) { +static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) { int32_t value32 = 0, b1 = 0, b2 = 0; int32_t a1 = 0; __asm __volatile( #if defined(MIPS32_R2_LE) - "seh %[a1], %[a] \n\t" + "seh %[a1], %[a] \n\t" #else - "sll %[a1], %[a], 16 \n\t" - "sra %[a1], %[a1], 16 \n\t" + "sll %[a1], %[a], 16 \n\t" + "sra %[a1], %[a1], 16 \n\t" #endif - "andi %[b2], %[b], 0xFFFF \n\t" - "sra %[b1], %[b], 16 \n\t" - "sra %[b2], %[b2], 1 \n\t" - "mul %[value32], %[a1], %[b1] \n\t" - "mul %[b2], %[a1], %[b2] \n\t" - "addiu %[b2], %[b2], 0x4000 \n\t" - "sra %[b2], %[b2], 15 \n\t" - "addu %[value32], %[value32], %[b2] \n\t" - : [value32] "=&r" (value32), [b1] "=&r" (b1), [b2] "=&r" (b2), - [a1] "=&r" (a1) - : [a] "r" (a), [b] "r" (b) - : "hi", "lo"); + "andi %[b2], %[b], 0xFFFF \n\t" + "sra %[b1], %[b], 16 \n\t" + "sra %[b2], %[b2], 1 \n\t" + "mul %[value32], %[a1], %[b1] \n\t" + "mul %[b2], %[a1], %[b2] \n\t" + "addiu %[b2], %[b2], 0x4000 \n\t" + "sra %[b2], %[b2], 15 \n\t" + "addu %[value32], %[value32], %[b2] \n\t" + : [value32] "=&r"(value32), [b1] "=&r"(b1), [b2] "=&r"(b2), [a1] "=&r"(a1) + : [a] "r"(a), [b] "r"(b) + : "hi", "lo"); return value32; } #if defined(MIPS_DSP_R1_LE) static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { __asm __volatile( - "shll_s.w %[value32], %[value32], 16 \n\t" - "sra %[value32], %[value32], 16 \n\t" - : [value32] "+r" (value32) - :); + "shll_s.w %[value32], %[value32], 16 \n\t" + "sra %[value32], %[value32], 16 \n\t" + : [value32] "+r"(value32) + :); int16_t out16 = (int16_t)value32; return out16; } @@ -78,10 +74,9 @@ static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) { int32_t value32 = 0; - __asm __volatile( - "addq_s.ph %[value32], %[a], %[b] \n\t" - : [value32] "=r" (value32) - : [a] "r" (a), [b] "r" (b) ); + __asm __volatile("addq_s.ph %[value32], %[a], %[b] \n\t" + : [value32] "=r"(value32) + : [a] "r"(a), [b] "r"(b)); return (int16_t)value32; } @@ -89,9 +84,9 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) { int32_t l_sum; __asm __volatile( - "addq_s.w %[l_sum], %[l_var1], %[l_var2] \n\t" - : [l_sum] "=r" (l_sum) - : [l_var1] "r" (l_var1), [l_var2] "r" (l_var2) ); + "addq_s.w %[l_sum], %[l_var1], %[l_var2] \n\t" + : [l_sum] "=r"(l_sum) + : [l_var1] "r"(l_var1), [l_var2] "r"(l_var2)); return l_sum; } @@ -99,10 +94,9 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) { static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) { int32_t value32; - __asm __volatile( - "subq_s.ph %[value32], %[var1], %[var2] \n\t" - : [value32] "=r" (value32) - : [var1] "r" (var1), [var2] "r" (var2) ); + __asm __volatile("subq_s.ph %[value32], %[var1], %[var2] \n\t" + : [value32] "=r"(value32) + : [var1] "r"(var1), [var2] "r"(var2)); return (int16_t)value32; } @@ -111,9 +105,9 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) { int32_t l_diff; __asm __volatile( - "subq_s.w %[l_diff], %[l_var1], %[l_var2] \n\t" - : [l_diff] "=r" (l_diff) - : [l_var1] "r" (l_var1), [l_var2] "r" (l_var2) ); + "subq_s.w %[l_diff], %[l_var1], %[l_var2] \n\t" + : [l_diff] "=r"(l_diff) + : [l_var1] "r"(l_var1), [l_var2] "r"(l_var2)); return l_diff; } @@ -124,10 +118,10 @@ static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) { int i32 = 32; __asm __volatile( - "clz %[bits], %[n] \n\t" - "subu %[bits], %[i32], %[bits] \n\t" - : [bits] "=&r" (bits) - : [n] "r" (n), [i32] "r" (i32) ); + "clz %[bits], %[n] \n\t" + "subu %[bits], %[i32], %[bits] \n\t" + : [bits] "=&r"(bits) + : [n] "r"(n), [i32] "r"(i32)); return (int16_t)bits; } @@ -136,20 +130,20 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) { int zeros = 0; __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "bnez %[a], 1f \n\t" - " sra %[zeros], %[a], 31 \n\t" - "b 2f \n\t" - " move %[zeros], $zero \n\t" - "1: \n\t" - "xor %[zeros], %[a], %[zeros] \n\t" - "clz %[zeros], %[zeros] \n\t" - "addiu %[zeros], %[zeros], -1 \n\t" - "2: \n\t" - ".set pop \n\t" - : [zeros]"=&r"(zeros) - : [a] "r" (a) ); + ".set push \n\t" + ".set noreorder \n\t" + "bnez %[a], 1f \n\t" + " sra %[zeros], %[a], 31 \n\t" + "b 2f \n\t" + " move %[zeros], $zero \n\t" + "1: \n\t" + "xor %[zeros], %[a], %[zeros] \n\t" + "clz %[zeros], %[zeros] \n\t" + "addiu %[zeros], %[zeros], -1 \n\t" + "2: \n\t" + ".set pop \n\t" + : [zeros] "=&r"(zeros) + : [a] "r"(a)); return (int16_t)zeros; } @@ -157,10 +151,9 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) { static __inline int16_t WebRtcSpl_NormU32(uint32_t a) { int zeros = 0; - __asm __volatile( - "clz %[zeros], %[a] \n\t" - : [zeros] "=r" (zeros) - : [a] "r" (a) ); + __asm __volatile("clz %[zeros], %[a] \n\t" + : [zeros] "=r"(zeros) + : [a] "r"(a)); return (int16_t)(zeros & 0x1f); } @@ -170,43 +163,41 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) { int a0 = a << 16; __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "bnez %[a0], 1f \n\t" - " sra %[zeros], %[a0], 31 \n\t" - "b 2f \n\t" - " move %[zeros], $zero \n\t" - "1: \n\t" - "xor %[zeros], %[a0], %[zeros] \n\t" - "clz %[zeros], %[zeros] \n\t" - "addiu %[zeros], %[zeros], -1 \n\t" - "2: \n\t" - ".set pop \n\t" - : [zeros]"=&r"(zeros) - : [a0] "r" (a0) ); + ".set push \n\t" + ".set noreorder \n\t" + "bnez %[a0], 1f \n\t" + " sra %[zeros], %[a0], 31 \n\t" + "b 2f \n\t" + " move %[zeros], $zero \n\t" + "1: \n\t" + "xor %[zeros], %[a0], %[zeros] \n\t" + "clz %[zeros], %[zeros] \n\t" + "addiu %[zeros], %[zeros], -1 \n\t" + "2: \n\t" + ".set pop \n\t" + : [zeros] "=&r"(zeros) + : [a0] "r"(a0)); return (int16_t)zeros; } -static __inline int32_t WebRtc_MulAccumW16(int16_t a, - int16_t b, - int32_t c) { +static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) { int32_t res = 0, c1 = 0; __asm __volatile( #if defined(MIPS32_R2_LE) - "seh %[a], %[a] \n\t" - "seh %[b], %[b] \n\t" + "seh %[a], %[a] \n\t" + "seh %[b], %[b] \n\t" #else - "sll %[a], %[a], 16 \n\t" - "sll %[b], %[b], 16 \n\t" - "sra %[a], %[a], 16 \n\t" - "sra %[b], %[b], 16 \n\t" + "sll %[a], %[a], 16 \n\t" + "sll %[b], %[b], 16 \n\t" + "sra %[a], %[a], 16 \n\t" + "sra %[b], %[b], 16 \n\t" #endif - "mul %[res], %[a], %[b] \n\t" - "addu %[c1], %[c], %[res] \n\t" - : [c1] "=r" (c1), [res] "=&r" (res) - : [a] "r" (a), [b] "r" (b), [c] "r" (c) - : "hi", "lo"); + "mul %[res], %[a], %[b] \n\t" + "addu %[c1], %[c], %[res] \n\t" + : [c1] "=r"(c1), [res] "=&r"(res) + : [a] "r"(a), [b] "r"(b), [c] "r"(c) + : "hi", "lo"); return (c1); } diff --git a/common_audio/signal_processing/real_fft_unittest.cc b/common_audio/signal_processing/real_fft_unittest.cc index 4f5b5c72b2..2d6b7d1b86 100644 --- a/common_audio/signal_processing/real_fft_unittest.cc +++ b/common_audio/signal_processing/real_fft_unittest.cc @@ -27,17 +27,14 @@ const int kFreqDataLength = (1 << kOrder) + 2; const int kComplexFftDataLength = 2 << kOrder; // Reference data for time signal. const int16_t kRefData[kTimeDataLength] = { - 11739, 6848, -8688, 31980, -30295, 25242, 27085, 19410, - -26299, 15607, -10791, 11778, -23819, 14498, -25772, 10076, - 1173, 6848, -8688, 31980, -30295, 2522, 27085, 19410, - -2629, 5607, -3, 1178, -23819, 1498, -25772, 10076 -}; + 11739, 6848, -8688, 31980, -30295, 25242, 27085, 19410, + -26299, 15607, -10791, 11778, -23819, 14498, -25772, 10076, + 1173, 6848, -8688, 31980, -30295, 2522, 27085, 19410, + -2629, 5607, -3, 1178, -23819, 1498, -25772, 10076}; class RealFFTTest : public ::testing::Test { protected: - RealFFTTest() { - WebRtcSpl_Init(); - } + RealFFTTest() { WebRtcSpl_Init(); } }; TEST_F(RealFFTTest, CreateFailsOnBadInput) { diff --git a/common_audio/signal_processing/resample_by_2_internal.h b/common_audio/signal_processing/resample_by_2_internal.h index b0d19691c4..5483e2ebca 100644 --- a/common_audio/signal_processing/resample_by_2_internal.h +++ b/common_audio/signal_processing/resample_by_2_internal.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* * This header file contains some internal resampling functions. * @@ -23,25 +22,39 @@ * resample_by_2_fast.c * Functions for internal use in the other resample functions ******************************************************************/ -void WebRtcSpl_DownBy2IntToShort(int32_t *in, int32_t len, int16_t *out, - int32_t *state); +void WebRtcSpl_DownBy2IntToShort(int32_t* in, + int32_t len, + int16_t* out, + int32_t* state); -void WebRtcSpl_DownBy2ShortToInt(const int16_t *in, int32_t len, - int32_t *out, int32_t *state); +void WebRtcSpl_DownBy2ShortToInt(const int16_t* in, + int32_t len, + int32_t* out, + int32_t* state); -void WebRtcSpl_UpBy2ShortToInt(const int16_t *in, int32_t len, - int32_t *out, int32_t *state); +void WebRtcSpl_UpBy2ShortToInt(const int16_t* in, + int32_t len, + int32_t* out, + int32_t* state); -void WebRtcSpl_UpBy2IntToInt(const int32_t *in, int32_t len, int32_t *out, - int32_t *state); +void WebRtcSpl_UpBy2IntToInt(const int32_t* in, + int32_t len, + int32_t* out, + int32_t* state); -void WebRtcSpl_UpBy2IntToShort(const int32_t *in, int32_t len, - int16_t *out, int32_t *state); +void WebRtcSpl_UpBy2IntToShort(const int32_t* in, + int32_t len, + int16_t* out, + int32_t* state); -void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, int32_t len, - int32_t* out, int32_t* state); +void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, + int32_t len, + int32_t* out, + int32_t* state); -void WebRtcSpl_LPBy2IntToInt(const int32_t* in, int32_t len, int32_t* out, +void WebRtcSpl_LPBy2IntToInt(const int32_t* in, + int32_t len, + int32_t* out, int32_t* state); #endif // COMMON_AUDIO_SIGNAL_PROCESSING_RESAMPLE_BY_2_INTERNAL_H_ diff --git a/common_audio/signal_processing/signal_processing_unittest.cc b/common_audio/signal_processing/signal_processing_unittest.cc index b9efe01fe7..4ef0c906a0 100644 --- a/common_audio/signal_processing/signal_processing_unittest.cc +++ b/common_audio/signal_processing/signal_processing_unittest.cc @@ -15,111 +15,113 @@ #include "test/gtest.h" static const size_t kVector16Size = 9; -static const int16_t vector16[kVector16Size] = {1, -15511, 4323, 1963, - WEBRTC_SPL_WORD16_MAX, 0, WEBRTC_SPL_WORD16_MIN + 5, -3333, 345}; +static const int16_t vector16[kVector16Size] = {1, + -15511, + 4323, + 1963, + WEBRTC_SPL_WORD16_MAX, + 0, + WEBRTC_SPL_WORD16_MIN + 5, + -3333, + 345}; class SplTest : public testing::Test { protected: - SplTest() { - WebRtcSpl_Init(); - } - virtual ~SplTest() { - } + SplTest() { WebRtcSpl_Init(); } + virtual ~SplTest() {} }; TEST_F(SplTest, MacroTest) { - // Macros with inputs. - int A = 10; - int B = 21; - int a = -3; - int b = WEBRTC_SPL_WORD32_MAX; + // Macros with inputs. + int A = 10; + int B = 21; + int a = -3; + int b = WEBRTC_SPL_WORD32_MAX; - EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B)); - EXPECT_EQ(21, WEBRTC_SPL_MAX(A, B)); + EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B)); + EXPECT_EQ(21, WEBRTC_SPL_MAX(A, B)); - EXPECT_EQ(3, WEBRTC_SPL_ABS_W16(a)); - EXPECT_EQ(3, WEBRTC_SPL_ABS_W32(a)); + EXPECT_EQ(3, WEBRTC_SPL_ABS_W16(a)); + EXPECT_EQ(3, WEBRTC_SPL_ABS_W32(a)); - EXPECT_EQ(-63, WEBRTC_SPL_MUL(a, B)); - EXPECT_EQ(2147483651u, WEBRTC_SPL_UMUL(a, b)); - b = WEBRTC_SPL_WORD16_MAX >> 1; - EXPECT_EQ(4294918147u, WEBRTC_SPL_UMUL_32_16(a, b)); - EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_U16(a, b)); + EXPECT_EQ(-63, WEBRTC_SPL_MUL(a, B)); + EXPECT_EQ(2147483651u, WEBRTC_SPL_UMUL(a, b)); + b = WEBRTC_SPL_WORD16_MAX >> 1; + EXPECT_EQ(4294918147u, WEBRTC_SPL_UMUL_32_16(a, b)); + EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_U16(a, b)); - a = b; - b = -3; + a = b; + b = -3; - EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT16(a, b)); - EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT15(a, b)); - EXPECT_EQ(-3, WEBRTC_SPL_MUL_16_32_RSFT14(a, b)); - EXPECT_EQ(-24, WEBRTC_SPL_MUL_16_32_RSFT11(a, b)); + EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT16(a, b)); + EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT15(a, b)); + EXPECT_EQ(-3, WEBRTC_SPL_MUL_16_32_RSFT14(a, b)); + EXPECT_EQ(-24, WEBRTC_SPL_MUL_16_32_RSFT11(a, b)); - EXPECT_EQ(-12288, WEBRTC_SPL_MUL_16_16_RSFT(a, b, 2)); - EXPECT_EQ(-12287, WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, 2)); + EXPECT_EQ(-12288, WEBRTC_SPL_MUL_16_16_RSFT(a, b, 2)); + EXPECT_EQ(-12287, WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, 2)); - EXPECT_EQ(21, WEBRTC_SPL_SAT(a, A, B)); - EXPECT_EQ(21, WEBRTC_SPL_SAT(a, B, A)); + EXPECT_EQ(21, WEBRTC_SPL_SAT(a, A, B)); + EXPECT_EQ(21, WEBRTC_SPL_SAT(a, B, A)); - // Shifting with negative numbers allowed - int shift_amount = 1; // Workaround compiler warning using variable here. - // Positive means left shift - EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W32(a, shift_amount)); + // Shifting with negative numbers allowed + int shift_amount = 1; // Workaround compiler warning using variable here. + // Positive means left shift + EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W32(a, shift_amount)); - // Shifting with negative numbers not allowed - // We cannot do casting here due to signed/unsigned problem - EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1)); + // Shifting with negative numbers not allowed + // We cannot do casting here due to signed/unsigned problem + EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1)); - EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1)); + EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1)); - EXPECT_EQ(1470, WEBRTC_SPL_RAND(A)); + EXPECT_EQ(1470, WEBRTC_SPL_RAND(A)); - EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_16(a, b)); - EXPECT_EQ(1073676289, WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_WORD16_MAX, - WEBRTC_SPL_WORD16_MAX)); - EXPECT_EQ(1073709055, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MAX, - WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, - WEBRTC_SPL_WORD32_MIN)); + EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_16(a, b)); + EXPECT_EQ(1073676289, + WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MAX)); + EXPECT_EQ(1073709055, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MAX, + WEBRTC_SPL_WORD32_MAX)); + EXPECT_EQ(1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, + WEBRTC_SPL_WORD32_MIN)); #ifdef WEBRTC_ARCH_ARM_V7 - EXPECT_EQ(-1073741824, - WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, - WEBRTC_SPL_WORD32_MAX)); + EXPECT_EQ(-1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, + WEBRTC_SPL_WORD32_MAX)); #else - EXPECT_EQ(-1073741823, - WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, - WEBRTC_SPL_WORD32_MAX)); + EXPECT_EQ(-1073741823, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, + WEBRTC_SPL_WORD32_MAX)); #endif } TEST_F(SplTest, InlineTest) { - int16_t a16 = 121; - int16_t b16 = -17; - int32_t a32 = 111121; - int32_t b32 = -1711; + int16_t a16 = 121; + int16_t b16 = -17; + int32_t a32 = 111121; + int32_t b32 = -1711; - EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32)); + EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32)); - EXPECT_EQ(0, WebRtcSpl_NormW32(0)); - EXPECT_EQ(31, WebRtcSpl_NormW32(-1)); - EXPECT_EQ(0, WebRtcSpl_NormW32(WEBRTC_SPL_WORD32_MIN)); - EXPECT_EQ(14, WebRtcSpl_NormW32(a32)); + EXPECT_EQ(0, WebRtcSpl_NormW32(0)); + EXPECT_EQ(31, WebRtcSpl_NormW32(-1)); + EXPECT_EQ(0, WebRtcSpl_NormW32(WEBRTC_SPL_WORD32_MIN)); + EXPECT_EQ(14, WebRtcSpl_NormW32(a32)); - EXPECT_EQ(0, WebRtcSpl_NormW16(0)); - EXPECT_EQ(15, WebRtcSpl_NormW16(-1)); - EXPECT_EQ(0, WebRtcSpl_NormW16(WEBRTC_SPL_WORD16_MIN)); - EXPECT_EQ(4, WebRtcSpl_NormW16(b32)); - for (int ii = 0; ii < 15; ++ii) { - int16_t value = 1 << ii; - EXPECT_EQ(14 - ii, WebRtcSpl_NormW16(value)); - EXPECT_EQ(15 - ii, WebRtcSpl_NormW16(-value)); - } + EXPECT_EQ(0, WebRtcSpl_NormW16(0)); + EXPECT_EQ(15, WebRtcSpl_NormW16(-1)); + EXPECT_EQ(0, WebRtcSpl_NormW16(WEBRTC_SPL_WORD16_MIN)); + EXPECT_EQ(4, WebRtcSpl_NormW16(b32)); + for (int ii = 0; ii < 15; ++ii) { + int16_t value = 1 << ii; + EXPECT_EQ(14 - ii, WebRtcSpl_NormW16(value)); + EXPECT_EQ(15 - ii, WebRtcSpl_NormW16(-value)); + } - EXPECT_EQ(0, WebRtcSpl_NormU32(0u)); - EXPECT_EQ(0, WebRtcSpl_NormU32(0xffffffff)); - EXPECT_EQ(15, WebRtcSpl_NormU32(static_cast(a32))); + EXPECT_EQ(0, WebRtcSpl_NormU32(0u)); + EXPECT_EQ(0, WebRtcSpl_NormU32(0xffffffff)); + EXPECT_EQ(15, WebRtcSpl_NormU32(static_cast(a32))); - EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16)); - EXPECT_EQ(138, WebRtcSpl_SubSatW16(a16, b16)); + EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16)); + EXPECT_EQ(138, WebRtcSpl_SubSatW16(a16, b16)); } TEST_F(SplTest, AddSubSatW32) { @@ -168,84 +170,83 @@ TEST_F(SplTest, CountLeadingZeros64) { } TEST_F(SplTest, MathOperationsTest) { - int A = 1134567892; - int32_t num = 117; - int32_t den = -5; - uint16_t denU = 5; - EXPECT_EQ(33700, WebRtcSpl_Sqrt(A)); - EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A)); + int A = 1134567892; + int32_t num = 117; + int32_t den = -5; + uint16_t denU = 5; + EXPECT_EQ(33700, WebRtcSpl_Sqrt(A)); + EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A)); - - EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num)); - EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (int16_t)den)); - EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (int16_t)den)); - EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU)); - EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256)); + EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num)); + EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (int16_t)den)); + EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (int16_t)den)); + EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU)); + EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256)); } TEST_F(SplTest, BasicArrayOperationsTest) { - const size_t kVectorSize = 4; - int B[] = {4, 12, 133, 1100}; - int16_t b16[kVectorSize]; - int32_t b32[kVectorSize]; + const size_t kVectorSize = 4; + int B[] = {4, 12, 133, 1100}; + int16_t b16[kVectorSize]; + int32_t b32[kVectorSize]; - int16_t bTmp16[kVectorSize]; - int32_t bTmp32[kVectorSize]; + int16_t bTmp16[kVectorSize]; + int32_t bTmp32[kVectorSize]; - WebRtcSpl_MemSetW16(b16, 3, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(3, b16[kk]); - } - WebRtcSpl_ZerosArrayW16(b16, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(0, b16[kk]); - } - WebRtcSpl_MemSetW32(b32, 3, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(3, b32[kk]); - } - WebRtcSpl_ZerosArrayW32(b32, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(0, b32[kk]); - } - for (size_t kk = 0; kk < kVectorSize; ++kk) { - bTmp16[kk] = (int16_t)kk; - bTmp32[kk] = (int32_t)kk; - } - WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(b16[kk], bTmp16[kk]); - } -// WEBRTC_SPL_MEMCPY_W32(b32, bTmp32, kVectorSize); -// for (int kk = 0; kk < kVectorSize; ++kk) { -// EXPECT_EQ(b32[kk], bTmp32[kk]); -// } - WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16); - for (size_t kk = 0; kk < 2; ++kk) { - EXPECT_EQ(static_cast(kk+2), bTmp16[kk]); - } + WebRtcSpl_MemSetW16(b16, 3, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(3, b16[kk]); + } + WebRtcSpl_ZerosArrayW16(b16, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(0, b16[kk]); + } + WebRtcSpl_MemSetW32(b32, 3, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(3, b32[kk]); + } + WebRtcSpl_ZerosArrayW32(b32, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(0, b32[kk]); + } + for (size_t kk = 0; kk < kVectorSize; ++kk) { + bTmp16[kk] = (int16_t)kk; + bTmp32[kk] = (int32_t)kk; + } + WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(b16[kk], bTmp16[kk]); + } + // WEBRTC_SPL_MEMCPY_W32(b32, bTmp32, kVectorSize); + // for (int kk = 0; kk < kVectorSize; ++kk) { + // EXPECT_EQ(b32[kk], bTmp32[kk]); + // } + WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16); + for (size_t kk = 0; kk < 2; ++kk) { + EXPECT_EQ(static_cast(kk + 2), bTmp16[kk]); + } - for (size_t kk = 0; kk < kVectorSize; ++kk) { - b32[kk] = B[kk]; - b16[kk] = (int16_t)B[kk]; - } - WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]>>1), bTmp16[kk]); - } - WebRtcSpl_VectorBitShiftW16(bTmp16, kVectorSize, b16, 1); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]>>1), bTmp16[kk]); - } - WebRtcSpl_VectorBitShiftW32(bTmp32, kVectorSize, b32, 1); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]>>1), bTmp32[kk]); - } + for (size_t kk = 0; kk < kVectorSize; ++kk) { + b32[kk] = B[kk]; + b16[kk] = (int16_t)B[kk]; + } + WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((B[kk] >> 1), bTmp16[kk]); + } + WebRtcSpl_VectorBitShiftW16(bTmp16, kVectorSize, b16, 1); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((B[kk] >> 1), bTmp16[kk]); + } + WebRtcSpl_VectorBitShiftW32(bTmp32, kVectorSize, b32, 1); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((B[kk] >> 1), bTmp32[kk]); + } - WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(b16[3-kk], bTmp16[kk]); - } + WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(b16[3 - kk], bTmp16[kk]); + } } TEST_F(SplTest, MinMaxOperationsTest) { @@ -253,12 +254,40 @@ TEST_F(SplTest, MinMaxOperationsTest) { // Vectors to test the cases where minimum values have to be caught // outside of the unrolled loops in ARM-Neon. - int16_t vector16[kVectorSize] = {-1, 7485, 0, 3333, - -18283, 0, 12334, -29871, 988, -3333, - 345, -456, 222, 999, 888, 8774, WEBRTC_SPL_WORD16_MIN}; - int32_t vector32[kVectorSize] = {-1, 0, 283211, 3333, - 8712345, 0, -3333, 89345, -374585456, 222, 999, 122345334, - -12389756, -987329871, 888, -2, WEBRTC_SPL_WORD32_MIN}; + int16_t vector16[kVectorSize] = {-1, + 7485, + 0, + 3333, + -18283, + 0, + 12334, + -29871, + 988, + -3333, + 345, + -456, + 222, + 999, + 888, + 8774, + WEBRTC_SPL_WORD16_MIN}; + int32_t vector32[kVectorSize] = {-1, + 0, + 283211, + 3333, + 8712345, + 0, + -3333, + 89345, + -374585456, + 222, + 999, + 122345334, + -12389756, + -987329871, + 888, + -2, + WEBRTC_SPL_WORD32_MIN}; EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, WebRtcSpl_MinValueW16(vector16, kVectorSize)); @@ -312,76 +341,75 @@ TEST_F(SplTest, MinMaxOperationsTest) { } TEST_F(SplTest, VectorOperationsTest) { - const size_t kVectorSize = 4; - int B[] = {4, 12, 133, 1100}; - int16_t a16[kVectorSize]; - int16_t b16[kVectorSize]; - int16_t bTmp16[kVectorSize]; + const size_t kVectorSize = 4; + int B[] = {4, 12, 133, 1100}; + int16_t a16[kVectorSize]; + int16_t b16[kVectorSize]; + int16_t bTmp16[kVectorSize]; - for (size_t kk = 0; kk < kVectorSize; ++kk) { - a16[kk] = B[kk]; - b16[kk] = B[kk]; - } + for (size_t kk = 0; kk < kVectorSize; ++kk) { + a16[kk] = B[kk]; + b16[kk] = B[kk]; + } - WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]*3+7)>>2, bTmp16[kk]); - } - WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, - kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]); - } + WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((B[kk] * 3 + 7) >> 2, bTmp16[kk]); + } + WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((B[kk] * 3 + B[kk] * 2 + 2) >> 2, bTmp16[kk]); + } - WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]); - } + WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(((B[kk] * 3 + B[kk] * 2 + 2) >> 2) + ((b16[kk] * 3 + 7) >> 2), + bTmp16[kk]); + } - WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); - } - WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); - } - WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]); - } + WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((b16[kk] * 13) >> 2, bTmp16[kk]); + } + WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((b16[kk] * 13) >> 2, bTmp16[kk]); + } + WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(((a16[kk] * 13) >> 2) + ((b16[kk] * 7) >> 2), bTmp16[kk]); + } - WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(B[kk] >> 1, bTmp16[kk]); - } - WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], - kVectorSize, 2); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]); - } - WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]); - } + WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(B[kk] >> 1, bTmp16[kk]); + } + WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], kVectorSize, 2); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((a16[kk] * b16[3 - kk]) >> 2, bTmp16[kk]); + } + WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ((a16[kk] * b16[kk]) >> 6, bTmp16[kk]); + } - WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16); - for (size_t kk = 0; kk < kVectorSize - 1; ++kk) { - EXPECT_EQ(32767, bTmp16[kk]); - } - EXPECT_EQ(32749, bTmp16[kVectorSize - 1]); + WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16); + for (size_t kk = 0; kk < kVectorSize - 1; ++kk) { + EXPECT_EQ(32767, bTmp16[kk]); + } + EXPECT_EQ(32749, bTmp16[kVectorSize - 1]); - EXPECT_EQ(0, WebRtcSpl_GetScalingSquare(b16, kVectorSize, 1)); + EXPECT_EQ(0, WebRtcSpl_GetScalingSquare(b16, kVectorSize, 1)); } TEST_F(SplTest, EstimatorsTest) { const size_t kOrder = 2; - const int32_t unstable_filter[] = { 4, 12, 133, 1100 }; - const int32_t stable_filter[] = { 1100, 133, 12, 4 }; - int16_t lpc[kOrder + 2] = { 0 }; - int16_t refl[kOrder + 2] = { 0 }; - int16_t lpc_result[] = { 4096, -497, 15, 0 }; - int16_t refl_result[] = { -3962, 123, 0, 0 }; + const int32_t unstable_filter[] = {4, 12, 133, 1100}; + const int32_t stable_filter[] = {1100, 133, 12, 4}; + int16_t lpc[kOrder + 2] = {0}; + int16_t refl[kOrder + 2] = {0}; + int16_t lpc_result[] = {4096, -497, 15, 0}; + int16_t refl_result[] = {-3962, 123, 0, 0}; EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(unstable_filter, lpc, refl, kOrder)); EXPECT_EQ(1, WebRtcSpl_LevinsonDurbin(stable_filter, lpc, refl, kOrder)); @@ -392,69 +420,61 @@ TEST_F(SplTest, EstimatorsTest) { } TEST_F(SplTest, FilterTest) { - const size_t kVectorSize = 4; - const size_t kFilterOrder = 3; - int16_t A[] = {1, 2, 33, 100}; - int16_t A5[] = {1, 2, 33, 100, -5}; - int16_t B[] = {4, 12, 133, 110}; - int16_t data_in[kVectorSize]; - int16_t data_out[kVectorSize]; - int16_t bTmp16Low[kVectorSize]; - int16_t bState[kVectorSize]; - int16_t bStateLow[kVectorSize]; + const size_t kVectorSize = 4; + const size_t kFilterOrder = 3; + int16_t A[] = {1, 2, 33, 100}; + int16_t A5[] = {1, 2, 33, 100, -5}; + int16_t B[] = {4, 12, 133, 110}; + int16_t data_in[kVectorSize]; + int16_t data_out[kVectorSize]; + int16_t bTmp16Low[kVectorSize]; + int16_t bState[kVectorSize]; + int16_t bStateLow[kVectorSize]; - WebRtcSpl_ZerosArrayW16(bState, kVectorSize); - WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize); + WebRtcSpl_ZerosArrayW16(bState, kVectorSize); + WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - data_in[kk] = A[kk]; - data_out[kk] = 0; - } + for (size_t kk = 0; kk < kVectorSize; ++kk) { + data_in[kk] = A[kk]; + data_out[kk] = 0; + } - // MA filters. - // Note that the input data has |kFilterOrder| states before the actual - // data (one sample). - WebRtcSpl_FilterMAFastQ12(&data_in[kFilterOrder], data_out, B, - kFilterOrder + 1, 1); - EXPECT_EQ(0, data_out[0]); - // AR filters. - // Note that the output data has |kFilterOrder| states before the actual - // data (one sample). - WebRtcSpl_FilterARFastQ12(data_in, &data_out[kFilterOrder], A, - kFilterOrder + 1, 1); - EXPECT_EQ(0, data_out[kFilterOrder]); + // MA filters. + // Note that the input data has |kFilterOrder| states before the actual + // data (one sample). + WebRtcSpl_FilterMAFastQ12(&data_in[kFilterOrder], data_out, B, + kFilterOrder + 1, 1); + EXPECT_EQ(0, data_out[0]); + // AR filters. + // Note that the output data has |kFilterOrder| states before the actual + // data (one sample). + WebRtcSpl_FilterARFastQ12(data_in, &data_out[kFilterOrder], A, + kFilterOrder + 1, 1); + EXPECT_EQ(0, data_out[kFilterOrder]); - EXPECT_EQ(kVectorSize, WebRtcSpl_FilterAR(A5, - 5, - data_in, - kVectorSize, - bState, - kVectorSize, - bStateLow, - kVectorSize, - data_out, - bTmp16Low, - kVectorSize)); + EXPECT_EQ(kVectorSize, WebRtcSpl_FilterAR(A5, 5, data_in, kVectorSize, bState, + kVectorSize, bStateLow, kVectorSize, + data_out, bTmp16Low, kVectorSize)); } TEST_F(SplTest, RandTest) { - const int kVectorSize = 4; - int16_t BU[] = {3653, 12446, 8525, 30691}; - int16_t b16[kVectorSize]; - uint32_t bSeed = 100000; + const int kVectorSize = 4; + int16_t BU[] = {3653, 12446, 8525, 30691}; + int16_t b16[kVectorSize]; + uint32_t bSeed = 100000; - EXPECT_EQ(7086, WebRtcSpl_RandU(&bSeed)); - EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed)); - EXPECT_EQ(-9786, WebRtcSpl_RandN(&bSeed)); - EXPECT_EQ(kVectorSize, WebRtcSpl_RandUArray(b16, kVectorSize, &bSeed)); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(BU[kk], b16[kk]); - } + EXPECT_EQ(7086, WebRtcSpl_RandU(&bSeed)); + EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed)); + EXPECT_EQ(-9786, WebRtcSpl_RandN(&bSeed)); + EXPECT_EQ(kVectorSize, WebRtcSpl_RandUArray(b16, kVectorSize, &bSeed)); + for (int kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(BU[kk], b16[kk]); + } } TEST_F(SplTest, DotProductWithScaleTest) { - EXPECT_EQ(605362796, WebRtcSpl_DotProductWithScale(vector16, - vector16, kVector16Size, 2)); + EXPECT_EQ(605362796, WebRtcSpl_DotProductWithScale(vector16, vector16, + kVector16Size, 2)); } TEST_F(SplTest, CrossCorrelationTest) { @@ -464,8 +484,9 @@ TEST_F(SplTest, CrossCorrelationTest) { const int kStep = 1; const size_t kSeqDimension = 6; - const int16_t kVector16[kVector16Size] = {1, 4323, 1963, - WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MIN + 5, -3333, -876, 8483, 142}; + const int16_t kVector16[kVector16Size] = { + 1, 4323, 1963, WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MIN + 5, -3333, + -876, 8483, 142}; int32_t vector32[kCrossCorrelationDimension] = {0}; WebRtcSpl_CrossCorrelation(vector32, vector16, kVector16, kSeqDimension, @@ -473,12 +494,12 @@ TEST_F(SplTest, CrossCorrelationTest) { // WebRtcSpl_CrossCorrelationC() and WebRtcSpl_CrossCorrelationNeon() // are not bit-exact. - const int32_t kExpected[kCrossCorrelationDimension] = - {-266947903, -15579555, -171282001}; + const int32_t kExpected[kCrossCorrelationDimension] = {-266947903, -15579555, + -171282001}; const int32_t* expected = kExpected; #if !defined(MIPS32_LE) - const int32_t kExpectedNeon[kCrossCorrelationDimension] = - {-266947901, -15579553, -171281999}; + const int32_t kExpectedNeon[kCrossCorrelationDimension] = { + -266947901, -15579553, -171281999}; if (WebRtcSpl_CrossCorrelation != WebRtcSpl_CrossCorrelationC) { expected = kExpectedNeon; } @@ -491,8 +512,9 @@ TEST_F(SplTest, CrossCorrelationTest) { TEST_F(SplTest, AutoCorrelationTest) { int scale = 0; int32_t vector32[kVector16Size]; - const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063, - -85221647, -17104971, 61806945, 6644603, -669329, 43}; + const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063, + -85221647, -17104971, 61806945, + 6644603, -669329, 43}; EXPECT_EQ(kVector16Size, WebRtcSpl_AutoCorrelation(vector16, kVector16Size, @@ -504,63 +526,60 @@ TEST_F(SplTest, AutoCorrelationTest) { } TEST_F(SplTest, SignalProcessingTest) { - const size_t kVectorSize = 4; - int A[] = {1, 2, 33, 100}; - const int16_t kHanning[4] = { 2399, 8192, 13985, 16384 }; - int16_t b16[kVectorSize]; + const size_t kVectorSize = 4; + int A[] = {1, 2, 33, 100}; + const int16_t kHanning[4] = {2399, 8192, 13985, 16384}; + int16_t b16[kVectorSize]; - int16_t bTmp16[kVectorSize]; + int16_t bTmp16[kVectorSize]; - int bScale = 0; + int bScale = 0; - for (size_t kk = 0; kk < kVectorSize; ++kk) { - b16[kk] = A[kk]; - } + for (size_t kk = 0; kk < kVectorSize; ++kk) { + b16[kk] = A[kk]; + } - // TODO(bjornv): Activate the Reflection Coefficient tests when refactoring. -// WebRtcSpl_ReflCoefToLpc(b16, kVectorSize, bTmp16); -//// for (int kk = 0; kk < kVectorSize; ++kk) { -//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]); -//// } -// WebRtcSpl_LpcToReflCoef(bTmp16, kVectorSize, b16); -//// for (int kk = 0; kk < kVectorSize; ++kk) { -//// EXPECT_EQ(a16[kk], b16[kk]); -//// } -// WebRtcSpl_AutoCorrToReflCoef(b32, kVectorSize, bTmp16); -//// for (int kk = 0; kk < kVectorSize; ++kk) { -//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]); -//// } + // TODO(bjornv): Activate the Reflection Coefficient tests when refactoring. + // WebRtcSpl_ReflCoefToLpc(b16, kVectorSize, bTmp16); + //// for (int kk = 0; kk < kVectorSize; ++kk) { + //// EXPECT_EQ(aTmp16[kk], bTmp16[kk]); + //// } + // WebRtcSpl_LpcToReflCoef(bTmp16, kVectorSize, b16); + //// for (int kk = 0; kk < kVectorSize; ++kk) { + //// EXPECT_EQ(a16[kk], b16[kk]); + //// } + // WebRtcSpl_AutoCorrToReflCoef(b32, kVectorSize, bTmp16); + //// for (int kk = 0; kk < kVectorSize; ++kk) { + //// EXPECT_EQ(aTmp16[kk], bTmp16[kk]); + //// } - WebRtcSpl_GetHanningWindow(bTmp16, kVectorSize); - for (size_t kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(kHanning[kk], bTmp16[kk]); - } + WebRtcSpl_GetHanningWindow(bTmp16, kVectorSize); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + EXPECT_EQ(kHanning[kk], bTmp16[kk]); + } - for (size_t kk = 0; kk < kVectorSize; ++kk) { - b16[kk] = A[kk]; - } - EXPECT_EQ(11094 , WebRtcSpl_Energy(b16, kVectorSize, &bScale)); - EXPECT_EQ(0, bScale); + for (size_t kk = 0; kk < kVectorSize; ++kk) { + b16[kk] = A[kk]; + } + EXPECT_EQ(11094, WebRtcSpl_Energy(b16, kVectorSize, &bScale)); + EXPECT_EQ(0, bScale); } TEST_F(SplTest, FFTTest) { - int16_t B[] = {1, 2, 33, 100, - 2, 3, 34, 101, - 3, 4, 35, 102, - 4, 5, 36, 103}; + int16_t B[] = {1, 2, 33, 100, 2, 3, 34, 101, 3, 4, 35, 102, 4, 5, 36, 103}; - EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1)); -// for (int kk = 0; kk < 16; ++kk) { -// EXPECT_EQ(A[kk], B[kk]); -// } - EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1)); -// for (int kk = 0; kk < 16; ++kk) { -// EXPECT_EQ(A[kk], B[kk]); -// } - WebRtcSpl_ComplexBitReverse(B, 3); - for (int kk = 0; kk < 16; ++kk) { -// EXPECT_EQ(A[kk], B[kk]); - } + EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1)); + // for (int kk = 0; kk < 16; ++kk) { + // EXPECT_EQ(A[kk], B[kk]); + // } + EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1)); + // for (int kk = 0; kk < 16; ++kk) { + // EXPECT_EQ(A[kk], B[kk]); + // } + WebRtcSpl_ComplexBitReverse(B, 3); + for (int kk = 0; kk < 16; ++kk) { + // EXPECT_EQ(A[kk], B[kk]); + } } TEST_F(SplTest, Resample48WithSaturationTest) { @@ -570,14 +589,13 @@ TEST_F(SplTest, Resample48WithSaturationTest) { // Saturated input vector of 48 samples. const int32_t kVectorSaturated[3 * kBlockSize + 7] = { - -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, - -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, - -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, - 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, - 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, - 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, - 32767, 32767, 32767, 32767, 32767, 32767, 32767 - }; + -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, + -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, + -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, + 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, + 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, + 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, + 32767, 32767, 32767, 32767, 32767, 32767, 32767}; // All values in |out_vector| should be |kRefValue32kHz|. const int32_t kRefValue32kHz1 = -1077493760; diff --git a/common_audio/sparse_fir_filter.cc b/common_audio/sparse_fir_filter.cc index ed2d79bbe1..0fc032722e 100644 --- a/common_audio/sparse_fir_filter.cc +++ b/common_audio/sparse_fir_filter.cc @@ -34,8 +34,8 @@ void SparseFIRFilter::Filter(const float* in, size_t length, float* out) { for (size_t i = 0; i < length; ++i) { out[i] = 0.f; size_t j; - for (j = 0; i >= j * sparsity_ + offset_ && - j < nonzero_coeffs_.size(); ++j) { + for (j = 0; i >= j * sparsity_ + offset_ && j < nonzero_coeffs_.size(); + ++j) { out[i] += in[i - j * sparsity_ - offset_] * nonzero_coeffs_[j]; } for (; j < nonzero_coeffs_.size(); ++j) { @@ -47,12 +47,10 @@ void SparseFIRFilter::Filter(const float* in, size_t length, float* out) { // Update current state. if (state_.size() > 0u) { if (length >= state_.size()) { - std::memcpy(&state_[0], - &in[length - state_.size()], + std::memcpy(&state_[0], &in[length - state_.size()], state_.size() * sizeof(*in)); } else { - std::memmove(&state_[0], - &state_[length], + std::memmove(&state_[0], &state_[length], (state_.size() - length) * sizeof(state_[0])); std::memcpy(&state_[state_.size() - length], in, length * sizeof(*in)); } diff --git a/common_audio/sparse_fir_filter_unittest.cc b/common_audio/sparse_fir_filter_unittest.cc index 434daaa6d9..b6cd6f9d9b 100644 --- a/common_audio/sparse_fir_filter_unittest.cc +++ b/common_audio/sparse_fir_filter_unittest.cc @@ -21,8 +21,8 @@ namespace webrtc { namespace { static const float kCoeffs[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f}; -static const float kInput[] = - {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f}; +static const float kInput[] = {1.f, 2.f, 3.f, 4.f, 5.f, + 6.f, 7.f, 8.f, 9.f, 10.f}; template void VerifyOutput(const float (&expected_output)[N], const float (&output)[N]) { @@ -50,13 +50,9 @@ TEST(SparseFIRFilterTest, SameOutputForScalarCoefficientAndDifferentSparsity) { const size_t kOffset = 0; float low_sparsity_output[arraysize(kInput)]; float high_sparsity_output[arraysize(kInput)]; - SparseFIRFilter low_sparsity_filter(&kCoeff, - kNumCoeff, - kLowSparsity, + SparseFIRFilter low_sparsity_filter(&kCoeff, kNumCoeff, kLowSparsity, kOffset); - SparseFIRFilter high_sparsity_filter(&kCoeff, - kNumCoeff, - kHighSparsity, + SparseFIRFilter high_sparsity_filter(&kCoeff, kNumCoeff, kHighSparsity, kOffset); low_sparsity_filter.Filter(kInput, arraysize(kInput), low_sparsity_output); high_sparsity_filter.Filter(kInput, arraysize(kInput), high_sparsity_output); @@ -146,15 +142,10 @@ TEST(SparseFIRFilterTest, VerifySampleBasedVsBlockBasedFiltering) { const size_t kSparsity = 3; const size_t kOffset = 1; float output_block_based[arraysize(kInput)]; - SparseFIRFilter filter_block(kCoeffs, - arraysize(kCoeffs), - kSparsity, - kOffset); + SparseFIRFilter filter_block(kCoeffs, arraysize(kCoeffs), kSparsity, kOffset); filter_block.Filter(kInput, arraysize(kInput), output_block_based); float output_sample_based[arraysize(kInput)]; - SparseFIRFilter filter_sample(kCoeffs, - arraysize(kCoeffs), - kSparsity, + SparseFIRFilter filter_sample(kCoeffs, arraysize(kCoeffs), kSparsity, kOffset); for (size_t i = 0; i < arraysize(kInput); ++i) filter_sample.Filter(&kInput[i], 1, &output_sample_based[i]); @@ -165,8 +156,8 @@ TEST(SparseFIRFilterTest, SimpleHighPassFilter) { const size_t kSparsity = 2; const size_t kOffset = 2; const float kHPCoeffs[] = {1.f, -1.f}; - const float kConstantInput[] = - {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; + const float kConstantInput[] = {1.f, 1.f, 1.f, 1.f, 1.f, + 1.f, 1.f, 1.f, 1.f, 1.f}; float output[arraysize(kConstantInput)]; SparseFIRFilter filter(kHPCoeffs, arraysize(kHPCoeffs), kSparsity, kOffset); filter.Filter(kConstantInput, arraysize(kConstantInput), output); @@ -182,8 +173,8 @@ TEST(SparseFIRFilterTest, SimpleLowPassFilter) { const size_t kSparsity = 2; const size_t kOffset = 2; const float kLPCoeffs[] = {1.f, 1.f}; - const float kHighFrequencyInput[] = - {1.f, 1.f, -1.f, -1.f, 1.f, 1.f, -1.f, -1.f, 1.f, 1.f}; + const float kHighFrequencyInput[] = {1.f, 1.f, -1.f, -1.f, 1.f, + 1.f, -1.f, -1.f, 1.f, 1.f}; float output[arraysize(kHighFrequencyInput)]; SparseFIRFilter filter(kLPCoeffs, arraysize(kLPCoeffs), kSparsity, kOffset); filter.Filter(kHighFrequencyInput, arraysize(kHighFrequencyInput), output); @@ -203,9 +194,7 @@ TEST(SparseFIRFilterTest, SameOutputWhenSwappedCoefficientsAndInput) { SparseFIRFilter filter(kCoeffs, arraysize(kCoeffs), kSparsity, kOffset); // Use arraysize(kCoeffs) for in_length to get same-length outputs. filter.Filter(kInput, arraysize(kCoeffs), output); - SparseFIRFilter filter_swapped(kInput, - arraysize(kCoeffs), - kSparsity, + SparseFIRFilter filter_swapped(kInput, arraysize(kCoeffs), kSparsity, kOffset); filter_swapped.Filter(kCoeffs, arraysize(kCoeffs), output_swapped); VerifyOutput(output, output_swapped); @@ -218,9 +207,7 @@ TEST(SparseFIRFilterTest, SameOutputAsFIRFilterWhenSparsityOneAndOffsetZero) { float sparse_output[arraysize(kInput)]; std::unique_ptr filter( CreateFirFilter(kCoeffs, arraysize(kCoeffs), arraysize(kInput))); - SparseFIRFilter sparse_filter(kCoeffs, - arraysize(kCoeffs), - kSparsity, + SparseFIRFilter sparse_filter(kCoeffs, arraysize(kCoeffs), kSparsity, kOffset); filter->Filter(kInput, arraysize(kInput), output); sparse_filter.Filter(kInput, arraysize(kInput), sparse_output); diff --git a/common_audio/vad/include/webrtc_vad.h b/common_audio/vad/include/webrtc_vad.h index 353dbf0861..a6c539cf79 100644 --- a/common_audio/vad/include/webrtc_vad.h +++ b/common_audio/vad/include/webrtc_vad.h @@ -8,9 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* - * This header file includes the VAD API calls. Specific function calls are given below. + * This header file includes the VAD API calls. Specific function calls are + * given below. */ #ifndef COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_ // NOLINT @@ -67,7 +67,9 @@ int WebRtcVad_set_mode(VadInst* handle, int mode); // returns : 1 - (Active Voice), // 0 - (Non-active Voice), // -1 - (Error) -int WebRtcVad_Process(VadInst* handle, int fs, const int16_t* audio_frame, +int WebRtcVad_Process(VadInst* handle, + int fs, + const int16_t* audio_frame, size_t frame_length); // Checks for valid combinations of |rate| and |frame_length|. We support 10, diff --git a/common_audio/vad/vad_core.h b/common_audio/vad/vad_core.h index 6541819f53..0eb8de3d1d 100644 --- a/common_audio/vad/vad_core.h +++ b/common_audio/vad/vad_core.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - /* * This header file includes the descriptions of the core VAD calls. */ @@ -19,37 +18,37 @@ #include "common_audio/signal_processing/include/signal_processing_library.h" #include "typedefs.h" // NOLINT(build/include) -enum { kNumChannels = 6 }; // Number of frequency bands (named channels). +enum { kNumChannels = 6 }; // Number of frequency bands (named channels). enum { kNumGaussians = 2 }; // Number of Gaussians per channel in the GMM. enum { kTableSize = kNumChannels * kNumGaussians }; enum { kMinEnergy = 10 }; // Minimum energy required to trigger audio signal. typedef struct VadInstT_ { - int vad; - int32_t downsampling_filter_states[4]; - WebRtcSpl_State48khzTo8khz state_48_to_8; - int16_t noise_means[kTableSize]; - int16_t speech_means[kTableSize]; - int16_t noise_stds[kTableSize]; - int16_t speech_stds[kTableSize]; - // TODO(bjornv): Change to |frame_count|. - int32_t frame_counter; - int16_t over_hang; // Over Hang - int16_t num_of_speech; - // TODO(bjornv): Change to |age_vector|. - int16_t index_vector[16 * kNumChannels]; - int16_t low_value_vector[16 * kNumChannels]; - // TODO(bjornv): Change to |median|. - int16_t mean_value[kNumChannels]; - int16_t upper_state[5]; - int16_t lower_state[5]; - int16_t hp_filter_state[4]; - int16_t over_hang_max_1[3]; - int16_t over_hang_max_2[3]; - int16_t individual[3]; - int16_t total[3]; + int vad; + int32_t downsampling_filter_states[4]; + WebRtcSpl_State48khzTo8khz state_48_to_8; + int16_t noise_means[kTableSize]; + int16_t speech_means[kTableSize]; + int16_t noise_stds[kTableSize]; + int16_t speech_stds[kTableSize]; + // TODO(bjornv): Change to |frame_count|. + int32_t frame_counter; + int16_t over_hang; // Over Hang + int16_t num_of_speech; + // TODO(bjornv): Change to |age_vector|. + int16_t index_vector[16 * kNumChannels]; + int16_t low_value_vector[16 * kNumChannels]; + // TODO(bjornv): Change to |median|. + int16_t mean_value[kNumChannels]; + int16_t upper_state[5]; + int16_t lower_state[5]; + int16_t hp_filter_state[4]; + int16_t over_hang_max_1[3]; + int16_t over_hang_max_2[3]; + int16_t individual[3]; + int16_t total[3]; - int init_flag; + int init_flag; } VadInstT; // Initializes the core VAD component. The default aggressiveness mode is @@ -100,13 +99,17 @@ int WebRtcVad_set_mode_core(VadInstT* self, int mode); * 0 - No active speech * 1-6 - Active speech */ -int WebRtcVad_CalcVad48khz(VadInstT* inst, const int16_t* speech_frame, +int WebRtcVad_CalcVad48khz(VadInstT* inst, + const int16_t* speech_frame, size_t frame_length); -int WebRtcVad_CalcVad32khz(VadInstT* inst, const int16_t* speech_frame, +int WebRtcVad_CalcVad32khz(VadInstT* inst, + const int16_t* speech_frame, size_t frame_length); -int WebRtcVad_CalcVad16khz(VadInstT* inst, const int16_t* speech_frame, +int WebRtcVad_CalcVad16khz(VadInstT* inst, + const int16_t* speech_frame, size_t frame_length); -int WebRtcVad_CalcVad8khz(VadInstT* inst, const int16_t* speech_frame, +int WebRtcVad_CalcVad8khz(VadInstT* inst, + const int16_t* speech_frame, size_t frame_length); #endif // COMMON_AUDIO_VAD_VAD_CORE_H_ diff --git a/common_audio/vad/vad_filterbank.h b/common_audio/vad/vad_filterbank.h index 620f96a699..60b785bed9 100644 --- a/common_audio/vad/vad_filterbank.h +++ b/common_audio/vad/vad_filterbank.h @@ -38,7 +38,9 @@ // - features [o] : 10 * log10(energy in each frequency band), Q4. // - returns : Total energy of the signal (NOTE! This value is not // exact. It is only used in a comparison.) -int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in, - size_t data_length, int16_t* features); +int16_t WebRtcVad_CalculateFeatures(VadInstT* self, + const int16_t* data_in, + size_t data_length, + int16_t* features); #endif // COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ diff --git a/common_audio/vad/vad_filterbank_unittest.cc b/common_audio/vad/vad_filterbank_unittest.cc index 55b12793da..b80004424b 100644 --- a/common_audio/vad/vad_filterbank_unittest.cc +++ b/common_audio/vad/vad_filterbank_unittest.cc @@ -26,14 +26,12 @@ const int kNumValidFrameLengths = 3; TEST_F(VadTest, vad_filterbank) { VadInstT* self = reinterpret_cast(malloc(sizeof(VadInstT))); - static const int16_t kReference[kNumValidFrameLengths] = { 48, 11, 11 }; + static const int16_t kReference[kNumValidFrameLengths] = {48, 11, 11}; static const int16_t kFeatures[kNumValidFrameLengths * kNumChannels] = { - 1213, 759, 587, 462, 434, 272, - 1479, 1385, 1291, 1200, 1103, 1099, - 1732, 1692, 1681, 1629, 1436, 1436 - }; - static const int16_t kOffsetVector[kNumChannels] = { - 368, 368, 272, 176, 176, 176 }; + 1213, 759, 587, 462, 434, 272, 1479, 1385, 1291, + 1200, 1103, 1099, 1732, 1692, 1681, 1629, 1436, 1436}; + static const int16_t kOffsetVector[kNumChannels] = {368, 368, 272, + 176, 176, 176}; int16_t features[kNumChannels]; // Construct a speech signal that will trigger the VAD in all modes. It is diff --git a/common_audio/vad/vad_sp.h b/common_audio/vad/vad_sp.h index 21fed11b1a..8586ccd590 100644 --- a/common_audio/vad/vad_sp.h +++ b/common_audio/vad/vad_sp.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - // This file includes specific signal processing tools used in vad_core.c. #ifndef COMMON_AUDIO_VAD_VAD_SP_H_ diff --git a/common_audio/vad/vad_sp_unittest.cc b/common_audio/vad/vad_sp_unittest.cc index 7eb6794d21..ebe25cffce 100644 --- a/common_audio/vad/vad_sp_unittest.cc +++ b/common_audio/vad/vad_sp_unittest.cc @@ -25,19 +25,17 @@ namespace test { TEST_F(VadTest, vad_sp) { VadInstT* self = reinterpret_cast(malloc(sizeof(VadInstT))); const size_t kMaxFrameLenSp = 960; // Maximum frame length in this unittest. - int16_t zeros[kMaxFrameLenSp] = { 0 }; - int32_t state[2] = { 0 }; + int16_t zeros[kMaxFrameLenSp] = {0}; + int32_t state[2] = {0}; int16_t data_in[kMaxFrameLenSp]; int16_t data_out[kMaxFrameLenSp]; // We expect the first value to be 1600 as long as |frame_counter| is zero, // which is true for the first iteration. static const int16_t kReferenceMin[32] = { - 1600, 720, 509, 512, 532, 552, 570, 588, - 606, 624, 642, 659, 675, 691, 707, 723, - 1600, 544, 502, 522, 542, 561, 579, 597, - 615, 633, 651, 667, 683, 699, 715, 731 - }; + 1600, 720, 509, 512, 532, 552, 570, 588, 606, 624, 642, + 659, 675, 691, 707, 723, 1600, 544, 502, 522, 542, 561, + 579, 597, 615, 633, 651, 667, 683, 699, 715, 731}; // Construct a speech signal that will trigger the VAD in all modes. It is // known that (i * i) will wrap around, but that doesn't matter in this case. diff --git a/common_audio/vad/vad_unittest.cc b/common_audio/vad/vad_unittest.cc index f79678b8a0..1cef8e9949 100644 --- a/common_audio/vad/vad_unittest.cc +++ b/common_audio/vad/vad_unittest.cc @@ -60,7 +60,7 @@ TEST_F(VadTest, ApiTest) { // combinations. VadInst* handle = WebRtcVad_Create(); - int16_t zeros[kMaxFrameLength] = { 0 }; + int16_t zeros[kMaxFrameLength] = {0}; // Construct a speech signal that will trigger the VAD in all modes. It is // known that (i * i) will wrap around, but that doesn't matter in this case. @@ -87,12 +87,10 @@ TEST_F(VadTest, ApiTest) { // WebRtcVad_set_mode() invalid modes tests. Tries smallest supported value // minus one and largest supported value plus one. - EXPECT_EQ(-1, WebRtcVad_set_mode(handle, - WebRtcSpl_MinValueW32(kModes, - kModesSize) - 1)); - EXPECT_EQ(-1, WebRtcVad_set_mode(handle, - WebRtcSpl_MaxValueW32(kModes, - kModesSize) + 1)); + EXPECT_EQ(-1, WebRtcVad_set_mode( + handle, WebRtcSpl_MinValueW32(kModes, kModesSize) - 1)); + EXPECT_EQ(-1, WebRtcVad_set_mode( + handle, WebRtcSpl_MaxValueW32(kModes, kModesSize) + 1)); // WebRtcVad_Process() tests // nullptr as speech pointer @@ -109,14 +107,10 @@ TEST_F(VadTest, ApiTest) { for (size_t i = 0; i < kRatesSize; i++) { for (size_t j = 0; j < kFrameLengthsSize; j++) { if (ValidRatesAndFrameLengths(kRates[i], kFrameLengths[j])) { - EXPECT_EQ(1, WebRtcVad_Process(handle, - kRates[i], - speech, + EXPECT_EQ(1, WebRtcVad_Process(handle, kRates[i], speech, kFrameLengths[j])); } else { - EXPECT_EQ(-1, WebRtcVad_Process(handle, - kRates[i], - speech, + EXPECT_EQ(-1, WebRtcVad_Process(handle, kRates[i], speech, kFrameLengths[j])); } } @@ -130,22 +124,20 @@ TEST_F(VadTest, ValidRatesFrameLengths) { // This test verifies valid and invalid rate/frame_length combinations. We // loop through some sampling rates and frame lengths from negative values to // values larger than possible. - const int kRates[] = { - -8000, -4000, 0, 4000, 8000, 8001, 15999, 16000, 32000, 48000, 48001, 96000 - }; + const int kRates[] = {-8000, -4000, 0, 4000, 8000, 8001, + 15999, 16000, 32000, 48000, 48001, 96000}; - const size_t kFrameLengths[] = { - 0, 80, 81, 159, 160, 240, 320, 480, 640, 960, 1440, 2000 - }; + const size_t kFrameLengths[] = {0, 80, 81, 159, 160, 240, + 320, 480, 640, 960, 1440, 2000}; for (size_t i = 0; i < arraysize(kRates); i++) { for (size_t j = 0; j < arraysize(kFrameLengths); j++) { if (ValidRatesAndFrameLengths(kRates[i], kFrameLengths[j])) { - EXPECT_EQ(0, WebRtcVad_ValidRateAndFrameLength(kRates[i], - kFrameLengths[j])); + EXPECT_EQ( + 0, WebRtcVad_ValidRateAndFrameLength(kRates[i], kFrameLengths[j])); } else { - EXPECT_EQ(-1, WebRtcVad_ValidRateAndFrameLength(kRates[i], - kFrameLengths[j])); + EXPECT_EQ( + -1, WebRtcVad_ValidRateAndFrameLength(kRates[i], kFrameLengths[j])); } } } diff --git a/common_audio/vad/vad_unittest.h b/common_audio/vad/vad_unittest.h index f982f52eb5..ec4e8766cc 100644 --- a/common_audio/vad/vad_unittest.h +++ b/common_audio/vad/vad_unittest.h @@ -20,17 +20,17 @@ namespace webrtc { namespace test { // Modes we support -const int kModes[] = { 0, 1, 2, 3 }; +const int kModes[] = {0, 1, 2, 3}; const size_t kModesSize = sizeof(kModes) / sizeof(*kModes); // Rates we support. -const int kRates[] = { 8000, 12000, 16000, 24000, 32000, 48000 }; +const int kRates[] = {8000, 12000, 16000, 24000, 32000, 48000}; const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); // Frame lengths we support. const size_t kMaxFrameLength = 1440; -const size_t kFrameLengths[] = { 80, 120, 160, 240, 320, 480, 640, 960, - kMaxFrameLength }; +const size_t kFrameLengths[] = { + 80, 120, 160, 240, 320, 480, 640, 960, kMaxFrameLength}; const size_t kFrameLengthsSize = sizeof(kFrameLengths) / sizeof(*kFrameLengths); } // namespace test diff --git a/common_audio/wav_file.h b/common_audio/wav_file.h index 69c241aad6..cbce59d364 100644 --- a/common_audio/wav_file.h +++ b/common_audio/wav_file.h @@ -60,7 +60,7 @@ class WavWriter final : public WavFile { const int sample_rate_; const size_t num_channels_; size_t num_samples_; // Total number of samples written to file. - FILE* file_handle_; // Output file, owned by this class + FILE* file_handle_; // Output file, owned by this class RTC_DISALLOW_COPY_AND_ASSIGN(WavWriter); }; diff --git a/common_audio/wav_file_unittest.cc b/common_audio/wav_file_unittest.cc index 39e8968e93..d40229a1eb 100644 --- a/common_audio/wav_file_unittest.cc +++ b/common_audio/wav_file_unittest.cc @@ -56,6 +56,8 @@ TEST(WavWriterTest, MAYBE_CPP) { fclose(f); } static const uint8_t kExpectedContents[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 42, 0, 0, 0, // size of whole file - 8: 6 + 44 - 8 'W', 'A', 'V', 'E', @@ -73,6 +75,7 @@ TEST(WavWriterTest, MAYBE_CPP) { 10, 0, // second sample: 10.0 0xff, 0x7f, // third sample: 4e4 (saturated) kMetadata[0], kMetadata[1], + // clang-format on }; static const size_t kContentSize = kWavHeaderSize + kNumSamples * sizeof(int16_t) + sizeof(kMetadata); @@ -112,6 +115,8 @@ TEST(WavWriterTest, C) { EXPECT_EQ(kNumSamples, rtc_WavNumSamples(w)); rtc_WavClose(w); static const uint8_t kExpectedContents[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 44, 0, 0, 0, // size of whole file - 8: 8 + 44 - 8 'W', 'A', 'V', 'E', @@ -129,6 +134,7 @@ TEST(WavWriterTest, C) { 10, 0, // second sample: 10.0 0xff, 0x7f, // third sample: 4e4 (saturated) 0, 0x80, // fourth sample: -1e9 (saturated) + // clang-format on }; static const size_t kContentSize = kWavHeaderSize + kNumSamples * sizeof(int16_t); @@ -209,6 +215,7 @@ TEST(WavWriterTest, MAYBE_CPPFileDescriptor) { } static const uint8_t kExpectedContents[] = { // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 42, 0, 0, 0, // size of whole file - 8: 6 + 44 - 8 'W', 'A', 'V', 'E', diff --git a/common_audio/wav_header.cc b/common_audio/wav_header.cc index a57e917249..d093fa011c 100644 --- a/common_audio/wav_header.cc +++ b/common_audio/wav_header.cc @@ -112,17 +112,23 @@ bool CheckWavParameters(size_t num_channels, } #ifdef WEBRTC_ARCH_LITTLE_ENDIAN -static inline void WriteLE16(uint16_t* f, uint16_t x) { *f = x; } -static inline void WriteLE32(uint32_t* f, uint32_t x) { *f = x; } +static inline void WriteLE16(uint16_t* f, uint16_t x) { + *f = x; +} +static inline void WriteLE32(uint32_t* f, uint32_t x) { + *f = x; +} static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) { - *f = static_cast(a) - | static_cast(b) << 8 - | static_cast(c) << 16 - | static_cast(d) << 24; + *f = static_cast(a) | static_cast(b) << 8 | + static_cast(c) << 16 | static_cast(d) << 24; } -static inline uint16_t ReadLE16(uint16_t x) { return x; } -static inline uint32_t ReadLE32(uint32_t x) { return x; } +static inline uint16_t ReadLE16(uint16_t x) { + return x; +} +static inline uint32_t ReadLE32(uint32_t x) { + return x; +} static inline std::string ReadFourCC(uint32_t x) { return std::string(reinterpret_cast(&x), 4); } @@ -131,11 +137,12 @@ static inline std::string ReadFourCC(uint32_t x) { #endif static inline uint32_t RiffChunkSize(size_t bytes_in_payload) { - return static_cast( - bytes_in_payload + kWavHeaderSize - sizeof(ChunkHeader)); + return static_cast(bytes_in_payload + kWavHeaderSize - + sizeof(ChunkHeader)); } -static inline uint32_t ByteRate(size_t num_channels, int sample_rate, +static inline uint32_t ByteRate(size_t num_channels, + int sample_rate, size_t bytes_per_sample) { return static_cast(num_channels * sample_rate * bytes_per_sample); } @@ -166,8 +173,8 @@ void WriteWavHeader(uint8_t* buf, WriteLE16(&header.fmt.AudioFormat, format); WriteLE16(&header.fmt.NumChannels, static_cast(num_channels)); WriteLE32(&header.fmt.SampleRate, sample_rate); - WriteLE32(&header.fmt.ByteRate, ByteRate(num_channels, sample_rate, - bytes_per_sample)); + WriteLE32(&header.fmt.ByteRate, + ByteRate(num_channels, sample_rate, bytes_per_sample)); WriteLE16(&header.fmt.BlockAlign, BlockAlign(num_channels, bytes_per_sample)); WriteLE16(&header.fmt.BitsPerSample, static_cast(8 * bytes_per_sample)); @@ -239,5 +246,4 @@ bool ReadWavHeader(ReadableWav* readable, *bytes_per_sample, *num_samples); } - } // namespace webrtc diff --git a/common_audio/wav_header.h b/common_audio/wav_header.h index 2295fbe6ad..872d3abce5 100644 --- a/common_audio/wav_header.h +++ b/common_audio/wav_header.h @@ -26,8 +26,8 @@ class ReadableWav { }; enum WavFormat { - kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample - kWavFormatALaw = 6, // 8-bit ITU-T G.711 A-law + kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample + kWavFormatALaw = 6, // 8-bit ITU-T G.711 A-law kWavFormatMuLaw = 7, // 8-bit ITU-T G.711 mu-law }; diff --git a/common_audio/wav_header_unittest.cc b/common_audio/wav_header_unittest.cc index 8b30530ad9..101f3ff389 100644 --- a/common_audio/wav_header_unittest.cc +++ b/common_audio/wav_header_unittest.cc @@ -84,8 +84,8 @@ TEST(WavHeaderTest, CheckWavParameters) { // Too large values. EXPECT_FALSE(CheckWavParameters(1 << 20, 1 << 20, kWavFormatPcm, 1, 0)); - EXPECT_FALSE(CheckWavParameters( - 1, 8000, kWavFormatPcm, 1, std::numeric_limits::max())); + EXPECT_FALSE(CheckWavParameters(1, 8000, kWavFormatPcm, 1, + std::numeric_limits::max())); // Not the same number of samples for each channel. EXPECT_FALSE(CheckWavParameters(3, 8000, kWavFormatPcm, 1, 5)); @@ -104,6 +104,8 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { // *BAD*. { static const uint8_t kBadRiffID[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'i', 'f', 'f', // *BAD* 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', @@ -117,14 +119,16 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { 8, 0, // bits per sample: 1 * 8 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 + // clang-format on }; ReadableWavBuffer r(kBadRiffID, sizeof(kBadRiffID)); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } { static const uint8_t kBadBitsPerSample[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', @@ -138,14 +142,16 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { 1, 0, // bits per sample: *BAD* 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 + // clang-format on }; ReadableWavBuffer r(kBadBitsPerSample, sizeof(kBadBitsPerSample)); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } { static const uint8_t kBadByteRate[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', @@ -159,14 +165,16 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { 8, 0, // bits per sample: 1 * 8 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 + // clang-format on }; ReadableWavBuffer r(kBadByteRate, sizeof(kBadByteRate)); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } { static const uint8_t kBadFmtHeaderSize[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', @@ -181,14 +189,16 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { 0, // extra (though invalid) header byte 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 + // clang-format on }; ReadableWavBuffer r(kBadFmtHeaderSize, sizeof(kBadFmtHeaderSize), false); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } { static const uint8_t kNonZeroExtensionField[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', @@ -203,15 +213,17 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { 1, 0, // non-zero extension field *BAD* 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 + // clang-format on }; ReadableWavBuffer r(kNonZeroExtensionField, sizeof(kNonZeroExtensionField), false); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } { static const uint8_t kMissingDataChunk[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', @@ -223,23 +235,25 @@ TEST(WavHeaderTest, ReadWavHeaderWithErrors) { 0xc9, 0x33, 0x03, 0, // byte rate: 1 * 17 * 12345 17, 0, // block align: NumChannels * BytesPerSample 8, 0, // bits per sample: 1 * 8 + // clang-format on }; ReadableWavBuffer r(kMissingDataChunk, sizeof(kMissingDataChunk)); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } { static const uint8_t kMissingFmtAndDataChunks[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 'W', 'A', 'V', 'E', + // clang-format on }; ReadableWavBuffer r(kMissingFmtAndDataChunks, sizeof(kMissingFmtAndDataChunks)); - EXPECT_FALSE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_FALSE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); } } @@ -250,6 +264,8 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) { memset(buf, 0xa4, sizeof(buf)); WriteWavHeader(buf + 4, 17, 12345, kWavFormatALaw, 1, 123457689); static const uint8_t kExpectedBuf[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0xa4, 0xa4, 0xa4, 0xa4, // untouched bytes before header 'R', 'I', 'F', 'F', 0xbd, 0xd0, 0x5b, 0x07, // size of whole file - 8: 123457689 + 44 - 8 @@ -265,6 +281,7 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) { 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 0xa4, 0xa4, 0xa4, 0xa4, // untouched bytes after header + // clang-format on }; static_assert(sizeof(kExpectedBuf) == kSize, "buffer size"); EXPECT_EQ(0, memcmp(kExpectedBuf, buf, kSize)); @@ -275,9 +292,8 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) { size_t bytes_per_sample = 0; size_t num_samples = 0; ReadableWavBuffer r(buf + 4, sizeof(buf) - 8); - EXPECT_TRUE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_TRUE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); EXPECT_EQ(17u, num_channels); EXPECT_EQ(12345, sample_rate); EXPECT_EQ(kWavFormatALaw, format); @@ -288,6 +304,8 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) { // Try reading an atypical but valid WAV header and make sure it's parsed OK. TEST(WavHeaderTest, ReadAtypicalWavHeader) { static const uint8_t kBuf[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 'R', 'I', 'F', 'F', 0x3d, 0xd1, 0x5b, 0x07, // size of whole file - 8 + an extra 128 bytes of // "metadata": 123457689 + 44 - 8 + 128. (atypical) @@ -303,6 +321,7 @@ TEST(WavHeaderTest, ReadAtypicalWavHeader) { 0, 0, // zero extension size field (atypical) 'd', 'a', 't', 'a', 0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689 + // clang-format on }; size_t num_channels = 0; @@ -311,9 +330,8 @@ TEST(WavHeaderTest, ReadAtypicalWavHeader) { size_t bytes_per_sample = 0; size_t num_samples = 0; ReadableWavBuffer r(kBuf, sizeof(kBuf)); - EXPECT_TRUE( - ReadWavHeader(&r, &num_channels, &sample_rate, &format, - &bytes_per_sample, &num_samples)); + EXPECT_TRUE(ReadWavHeader(&r, &num_channels, &sample_rate, &format, + &bytes_per_sample, &num_samples)); EXPECT_EQ(17u, num_channels); EXPECT_EQ(12345, sample_rate); EXPECT_EQ(kWavFormatALaw, format); diff --git a/common_audio/window_generator.cc b/common_audio/window_generator.cc index 823d2b7387..da5603d9e7 100644 --- a/common_audio/window_generator.cc +++ b/common_audio/window_generator.cc @@ -25,12 +25,11 @@ namespace { complex I0(complex x) { complex y = x / 3.75f; y *= y; - return 1.0f + y * ( - 3.5156229f + y * ( - 3.0899424f + y * ( - 1.2067492f + y * ( - 0.2659732f + y * ( - 0.360768e-1f + y * 0.45813e-2f))))); + return 1.0f + y * (3.5156229f + + y * (3.0899424f + + y * (1.2067492f + + y * (0.2659732f + + y * (0.360768e-1f + y * 0.45813e-2f))))); } } // namespace @@ -41,12 +40,13 @@ void WindowGenerator::Hanning(int length, float* window) { RTC_CHECK_GT(length, 1); RTC_CHECK(window != nullptr); for (int i = 0; i < length; ++i) { - window[i] = 0.5f * (1 - cosf(2 * static_cast(M_PI) * i / - (length - 1))); + window[i] = + 0.5f * (1 - cosf(2 * static_cast(M_PI) * i / (length - 1))); } } -void WindowGenerator::KaiserBesselDerived(float alpha, size_t length, +void WindowGenerator::KaiserBesselDerived(float alpha, + size_t length, float* window) { RTC_CHECK_GT(length, 1U); RTC_CHECK(window != nullptr); @@ -69,4 +69,3 @@ void WindowGenerator::KaiserBesselDerived(float alpha, size_t length, } } // namespace webrtc - diff --git a/common_audio/window_generator.h b/common_audio/window_generator.h index 5fc738eaf0..ad3b4456b9 100644 --- a/common_audio/window_generator.h +++ b/common_audio/window_generator.h @@ -30,4 +30,3 @@ class WindowGenerator { } // namespace webrtc #endif // COMMON_AUDIO_WINDOW_GENERATOR_H_ - diff --git a/common_audio/window_generator_unittest.cc b/common_audio/window_generator_unittest.cc index b2089d471a..cf339327c6 100644 --- a/common_audio/window_generator_unittest.cc +++ b/common_audio/window_generator_unittest.cc @@ -89,4 +89,3 @@ TEST(WindowGeneratorTest, Hanning) { } } // namespace webrtc - diff --git a/common_types.h b/common_types.h index 54d6850f5d..4a76050963 100644 --- a/common_types.h +++ b/common_types.h @@ -296,7 +296,7 @@ struct AudioDecodingCallStats { int decoded_normal; // Number of calls where audio RTP packet decoded. int decoded_plc; // Number of calls resulted in PLC. int decoded_cng; // Number of calls where comfort noise generated due to DTX. - int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG. + int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG. int decoded_muted_output; // Number of calls returning a muted state output. }; diff --git a/common_video/h264/h264_bitstream_parser.cc b/common_video/h264/h264_bitstream_parser.cc index 439beecec2..031fcde924 100644 --- a/common_video/h264/h264_bitstream_parser.cc +++ b/common_video/h264/h264_bitstream_parser.cc @@ -22,7 +22,7 @@ namespace { const int kMaxAbsQpDeltaValue = 51; const int kMinQpValue = 0; const int kMaxQpValue = 51; -} +} // namespace namespace webrtc { @@ -247,8 +247,8 @@ H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu( } } } - if (pps_->entropy_coding_mode_flag && - slice_type != H264::SliceType::kI && slice_type != H264::SliceType::kSi) { + if (pps_->entropy_coding_mode_flag && slice_type != H264::SliceType::kI && + slice_type != H264::SliceType::kSi) { // cabac_init_idc: ue(v) RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp)); } diff --git a/common_video/h264/h264_bitstream_parser_unittest.cc b/common_video/h264/h264_bitstream_parser_unittest.cc index 3bfbdb2704..1509d67753 100644 --- a/common_video/h264/h264_bitstream_parser_unittest.cc +++ b/common_video/h264/h264_bitstream_parser_unittest.cc @@ -28,9 +28,9 @@ uint8_t kH264BitstreamChunk[] = { }; uint8_t kH264BitstreamChunkCabac[] = { - 0x00, 0x00, 0x00, 0x01, 0x27, 0x64, 0x00, 0x0d, 0xac, 0x52, 0x30, 0x50, - 0x7e, 0xc0, 0x5a, 0x81, 0x01, 0x01, 0x18, 0x56, 0xbd, 0xef, 0x80, 0x80, - 0x00, 0x00, 0x00, 0x01, 0x28, 0xfe, 0x09, 0x8b, + 0x00, 0x00, 0x00, 0x01, 0x27, 0x64, 0x00, 0x0d, 0xac, 0x52, 0x30, + 0x50, 0x7e, 0xc0, 0x5a, 0x81, 0x01, 0x01, 0x18, 0x56, 0xbd, 0xef, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x01, 0x28, 0xfe, 0x09, 0x8b, }; // Contains enough of the image slice to contain slice QP. @@ -40,8 +40,8 @@ uint8_t kH264BitstreamNextImageSliceChunk[] = { // Contains enough of the image slice to contain slice QP. uint8_t kH264BitstreamNextImageSliceChunkCabac[] = { - 0x00, 0x00, 0x00, 0x01, 0x21, 0xe1, 0x05, 0x11, 0x3f, 0x9a, 0xae, 0x46, - 0x70, 0xbf, 0xc1, 0x4a, 0x16, 0x8f, 0x51, 0xf4, 0xca, 0xfb, 0xa3, 0x65, + 0x00, 0x00, 0x00, 0x01, 0x21, 0xe1, 0x05, 0x11, 0x3f, 0x9a, 0xae, 0x46, + 0x70, 0xbf, 0xc1, 0x4a, 0x16, 0x8f, 0x51, 0xf4, 0xca, 0xfb, 0xa3, 0x65, }; TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) { diff --git a/common_video/h264/pps_parser.cc b/common_video/h264/pps_parser.cc index 407b15c722..7bc0ff74d0 100644 --- a/common_video/h264/pps_parser.cc +++ b/common_video/h264/pps_parser.cc @@ -25,7 +25,7 @@ namespace { const int kMaxPicInitQpDeltaValue = 25; const int kMinPicInitQpDeltaValue = -26; -} +} // namespace namespace webrtc { diff --git a/common_video/i420_video_frame_unittest.cc b/common_video/i420_video_frame_unittest.cc index 7004d9dab1..4fec8cf388 100644 --- a/common_video/i420_video_frame_unittest.cc +++ b/common_video/i420_video_frame_unittest.cc @@ -24,8 +24,7 @@ namespace webrtc { namespace { rtc::scoped_refptr CreateGradient(int width, int height) { - rtc::scoped_refptr buffer( - I420Buffer::Create(width, height)); + rtc::scoped_refptr buffer(I420Buffer::Create(width, height)); // Initialize with gradient, Y = 128(x/w + y/h), U = 256 x/w, V = 256 y/h for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { @@ -92,13 +91,16 @@ void CheckRotate(int width, EXPECT_EQ(rotated_height, rotated.height()); // Clock-wise order (with 0,0 at top-left) - const struct { int x; int y; } corners[] = { - { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 } - }; + const struct { + int x; + int y; + } corners[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // Corresponding corner colors of the frame produced by CreateGradient. - const struct { int y; int u; int v; } colors[] = { - {0, 0, 0}, { 127, 255, 0}, { 255, 255, 255 }, {127, 0, 255} - }; + const struct { + int y; + int u; + int v; + } colors[] = {{0, 0, 0}, {127, 255, 0}, {255, 255, 255}, {127, 0, 255}}; int corner_offset = static_cast(rotation) / 90; for (int i = 0; i < 4; i++) { @@ -150,12 +152,9 @@ TEST(TestVideoFrame, ShallowCopy) { memset(buffer_u, 8, kSizeU); memset(buffer_v, 4, kSizeV); - VideoFrame frame1( - I420Buffer::Copy(width, height, - buffer_y, stride_y, - buffer_u, stride_u, - buffer_v, stride_v), - kRotation, 0); + VideoFrame frame1(I420Buffer::Copy(width, height, buffer_y, stride_y, + buffer_u, stride_u, buffer_v, stride_v), + kRotation, 0); frame1.set_timestamp(timestamp); frame1.set_ntp_time_ms(ntp_time_ms); frame1.set_timestamp_us(timestamp_us); @@ -204,8 +203,7 @@ TEST(TestVideoFrame, TextureInitialValues) { } TEST(TestI420FrameBuffer, Copy) { - rtc::scoped_refptr buf1( - I420Buffer::Create(20, 10)); + rtc::scoped_refptr buf1(I420Buffer::Create(20, 10)); memset(buf1->MutableDataY(), 1, 200); memset(buf1->MutableDataU(), 2, 50); memset(buf1->MutableDataV(), 3, 50); @@ -217,8 +215,7 @@ TEST(TestI420FrameBuffer, Scale) { rtc::scoped_refptr buf = CreateGradient(200, 100); // Pure scaling, no cropping. - rtc::scoped_refptr scaled_buffer( - I420Buffer::Create(150, 75)); + rtc::scoped_refptr scaled_buffer(I420Buffer::Create(150, 75)); scaled_buffer->ScaleFrom(*buf); CheckCrop(*scaled_buffer, 0.0, 0.0, 1.0, 1.0); @@ -228,8 +225,7 @@ TEST(TestI420FrameBuffer, CropXCenter) { rtc::scoped_refptr buf = CreateGradient(200, 100); // Pure center cropping, no scaling. - rtc::scoped_refptr scaled_buffer( - I420Buffer::Create(100, 100)); + rtc::scoped_refptr scaled_buffer(I420Buffer::Create(100, 100)); scaled_buffer->CropAndScaleFrom(*buf, 50, 0, 100, 100); CheckCrop(*scaled_buffer, 0.25, 0.0, 0.5, 1.0); @@ -239,8 +235,7 @@ TEST(TestI420FrameBuffer, CropXNotCenter) { rtc::scoped_refptr buf = CreateGradient(200, 100); // Non-center cropping, no scaling. - rtc::scoped_refptr scaled_buffer( - I420Buffer::Create(100, 100)); + rtc::scoped_refptr scaled_buffer(I420Buffer::Create(100, 100)); scaled_buffer->CropAndScaleFrom(*buf, 25, 0, 100, 100); CheckCrop(*scaled_buffer, 0.125, 0.0, 0.5, 1.0); @@ -250,8 +245,7 @@ TEST(TestI420FrameBuffer, CropYCenter) { rtc::scoped_refptr buf = CreateGradient(100, 200); // Pure center cropping, no scaling. - rtc::scoped_refptr scaled_buffer( - I420Buffer::Create(100, 100)); + rtc::scoped_refptr scaled_buffer(I420Buffer::Create(100, 100)); scaled_buffer->CropAndScaleFrom(*buf, 0, 50, 100, 100); CheckCrop(*scaled_buffer, 0.0, 0.25, 1.0, 0.5); @@ -261,8 +255,7 @@ TEST(TestI420FrameBuffer, CropYNotCenter) { rtc::scoped_refptr buf = CreateGradient(100, 200); // Non-center cropping, no scaling. - rtc::scoped_refptr scaled_buffer( - I420Buffer::Create(100, 100)); + rtc::scoped_refptr scaled_buffer(I420Buffer::Create(100, 100)); scaled_buffer->CropAndScaleFrom(*buf, 0, 25, 100, 100); CheckCrop(*scaled_buffer, 0.0, 0.125, 1.0, 0.5); @@ -272,8 +265,7 @@ TEST(TestI420FrameBuffer, CropAndScale16x9) { rtc::scoped_refptr buf = CreateGradient(640, 480); // Center crop to 640 x 360 (16/9 aspect), then scale down by 2. - rtc::scoped_refptr scaled_buffer( - I420Buffer::Create(320, 180)); + rtc::scoped_refptr scaled_buffer(I420Buffer::Create(320, 180)); scaled_buffer->CropAndScaleFrom(*buf); CheckCrop(*scaled_buffer, 0.0, 0.125, 1.0, 0.75); @@ -289,7 +281,8 @@ TEST_P(TestI420BufferRotate, Rotates) { CheckRotate(640, 480, GetParam(), *rotated_buffer); } -INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotate, +INSTANTIATE_TEST_CASE_P(Rotate, + TestI420BufferRotate, ::testing::Values(kVideoRotation_0, kVideoRotation_90, kVideoRotation_180, diff --git a/common_video/include/i420_buffer_pool.h b/common_video/include/i420_buffer_pool.h index 1c425bb790..79f7eec23a 100644 --- a/common_video/include/i420_buffer_pool.h +++ b/common_video/include/i420_buffer_pool.h @@ -11,8 +11,8 @@ #ifndef COMMON_VIDEO_INCLUDE_I420_BUFFER_POOL_H_ #define COMMON_VIDEO_INCLUDE_I420_BUFFER_POOL_H_ -#include #include +#include #include "api/video/i420_buffer.h" #include "rtc_base/race_checker.h" diff --git a/common_video/include/video_frame.h b/common_video/include/video_frame.h index 64582932ae..41c391941e 100644 --- a/common_video/include/video_frame.h +++ b/common_video/include/video_frame.h @@ -20,7 +20,7 @@ #include "api/video/video_rotation.h" #include "api/video/video_timing.h" #include "common_types.h" // NOLINT(build/include) -#include "typedefs.h" // NOLINT(build/include) +#include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h index 5b2a3af835..6eff537ba1 100644 --- a/common_video/libyuv/include/webrtc_libyuv.h +++ b/common_video/libyuv/include/webrtc_libyuv.h @@ -20,11 +20,10 @@ #include "api/video/video_frame.h" #include "common_types.h" // NOLINT(build/include) // VideoTypes. -#include "typedefs.h" // NOLINT(build/include) +#include "typedefs.h" // NOLINT(build/include) namespace webrtc { - // This is the max PSNR value our algorithms can return. const double kPerfectPSNR = 48.0f; @@ -93,12 +92,18 @@ double I420SSIM(const I420BufferInterface& ref_buffer, // |tmp_buffer| should be: // (src_width/2) * (src_height/2) * 2 + (dst_width/2) * (dst_height/2) * 2 void NV12Scale(uint8_t* tmp_buffer, - const uint8_t* src_y, int src_stride_y, - const uint8_t* src_uv, int src_stride_uv, - int src_width, int src_height, - uint8_t* dst_y, int dst_stride_y, - uint8_t* dst_uv, int dst_stride_uv, - int dst_width, int dst_height); + const uint8_t* src_y, + int src_stride_y, + const uint8_t* src_uv, + int src_stride_uv, + int src_width, + int src_height, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_uv, + int dst_stride_uv, + int dst_width, + int dst_height); // Helper class for directly converting and scaling NV12 to I420. The Y-plane // will be scaled directly to the I420 destination, which makes this faster @@ -107,13 +112,21 @@ class NV12ToI420Scaler { public: NV12ToI420Scaler(); ~NV12ToI420Scaler(); - void NV12ToI420Scale(const uint8_t* src_y, int src_stride_y, - const uint8_t* src_uv, int src_stride_uv, - int src_width, int src_height, - uint8_t* dst_y, int dst_stride_y, - uint8_t* dst_u, int dst_stride_u, - uint8_t* dst_v, int dst_stride_v, - int dst_width, int dst_height); + void NV12ToI420Scale(const uint8_t* src_y, + int src_stride_y, + const uint8_t* src_uv, + int src_stride_uv, + int src_width, + int src_height, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_u, + int dst_stride_u, + uint8_t* dst_v, + int dst_stride_v, + int dst_width, + int dst_height); + private: std::vector tmp_uv_planes_; }; diff --git a/common_video/libyuv/libyuv_unittest.cc b/common_video/libyuv/libyuv_unittest.cc index ba65544bf0..41d111c7b8 100644 --- a/common_video/libyuv/libyuv_unittest.cc +++ b/common_video/libyuv/libyuv_unittest.cc @@ -57,11 +57,11 @@ TestLibYuv::TestLibYuv() frame_length_(CalcBufferSize(VideoType::kI420, 352, 288)) {} void TestLibYuv::SetUp() { - const std::string input_file_name = webrtc::test::ResourcePath("foreman_cif", - "yuv"); - source_file_ = fopen(input_file_name.c_str(), "rb"); - ASSERT_TRUE(source_file_ != NULL) << "Cannot read file: "<< - input_file_name << "\n"; + const std::string input_file_name = + webrtc::test::ResourcePath("foreman_cif", "yuv"); + source_file_ = fopen(input_file_name.c_str(), "rb"); + ASSERT_TRUE(source_file_ != NULL) + << "Cannot read file: " << input_file_name << "\n"; rtc::scoped_refptr buffer( test::ReadI420Buffer(width_, height_, source_file_)); @@ -83,9 +83,9 @@ TEST_F(TestLibYuv, ConvertSanityTest) { TEST_F(TestLibYuv, ConvertTest) { // Reading YUV frame - testing on the first frame of the foreman sequence int j = 0; - std::string output_file_name = webrtc::test::OutputPath() + - "LibYuvTest_conversion.yuv"; - FILE* output_file = fopen(output_file_name.c_str(), "wb"); + std::string output_file_name = + webrtc::test::OutputPath() + "LibYuvTest_conversion.yuv"; + FILE* output_file = fopen(output_file_name.c_str(), "wb"); ASSERT_TRUE(output_file != NULL); double psnr = 0.0; @@ -249,9 +249,9 @@ TEST_F(TestLibYuv, ConvertTest) { TEST_F(TestLibYuv, ConvertAlignedFrame) { // Reading YUV frame - testing on the first frame of the foreman sequence - std::string output_file_name = webrtc::test::OutputPath() + - "LibYuvTest_conversion.yuv"; - FILE* output_file = fopen(output_file_name.c_str(), "wb"); + std::string output_file_name = + webrtc::test::OutputPath() + "LibYuvTest_conversion.yuv"; + FILE* output_file = fopen(output_file_name.c_str(), "wb"); ASSERT_TRUE(output_file != NULL); double psnr = 0.0; @@ -290,33 +290,24 @@ static uint8_t Average(int a, int b, int c, int d) { } TEST_F(TestLibYuv, NV12Scale2x2to2x2) { - const std::vector src_y = {0, 1, - 2, 3}; + const std::vector src_y = {0, 1, 2, 3}; const std::vector src_uv = {0, 1}; std::vector dst_y(4); std::vector dst_uv(2); uint8_t* tmp_buffer = nullptr; - NV12Scale(tmp_buffer, - src_y.data(), 2, - src_uv.data(), 2, - 2, 2, - dst_y.data(), 2, - dst_uv.data(), 2, - 2, 2); + NV12Scale(tmp_buffer, src_y.data(), 2, src_uv.data(), 2, 2, 2, dst_y.data(), + 2, dst_uv.data(), 2, 2, 2); EXPECT_THAT(dst_y, ::testing::ContainerEq(src_y)); EXPECT_THAT(dst_uv, ::testing::ContainerEq(src_uv)); } TEST_F(TestLibYuv, NV12Scale4x4to2x2) { - const uint8_t src_y[] = { 0, 1, 2, 3, - 4, 5, 6, 7, - 8, 9, 10, 11, - 12, 13, 14, 15}; - const uint8_t src_uv[] = {0, 1, 2, 3, - 4, 5, 6, 7}; + const uint8_t src_y[] = {0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15}; + const uint8_t src_uv[] = {0, 1, 2, 3, 4, 5, 6, 7}; std::vector dst_y(4); std::vector dst_uv(2); @@ -329,13 +320,8 @@ TEST_F(TestLibYuv, NV12Scale4x4to2x2) { dst_chroma_width * dst_chroma_height * 2); tmp_buffer.shrink_to_fit(); - NV12Scale(tmp_buffer.data(), - src_y, 4, - src_uv, 4, - 4, 4, - dst_y.data(), 2, - dst_uv.data(), 2, - 2, 2); + NV12Scale(tmp_buffer.data(), src_y, 4, src_uv, 4, 4, 4, dst_y.data(), 2, + dst_uv.data(), 2, 2, 2); EXPECT_THAT(dst_y, ::testing::ElementsAre( Average(0, 1, 4, 5), Average(2, 3, 6, 7), diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc index 01d93bbaaa..6bdfabd5e9 100644 --- a/common_video/libyuv/webrtc_libyuv.cc +++ b/common_video/libyuv/webrtc_libyuv.cc @@ -75,18 +75,15 @@ int PrintVideoFrame(const I420BufferInterface& frame, FILE* file) { int chroma_width = frame.ChromaWidth(); int chroma_height = frame.ChromaHeight(); - if (PrintPlane(frame.DataY(), width, height, - frame.StrideY(), file) < 0) { + if (PrintPlane(frame.DataY(), width, height, frame.StrideY(), file) < 0) { return -1; } - if (PrintPlane(frame.DataU(), - chroma_width, chroma_height, - frame.StrideU(), file) < 0) { + if (PrintPlane(frame.DataU(), chroma_width, chroma_height, frame.StrideU(), + file) < 0) { return -1; } - if (PrintPlane(frame.DataV(), - chroma_width, chroma_height, - frame.StrideV(), file) < 0) { + if (PrintPlane(frame.DataV(), chroma_width, chroma_height, frame.StrideV(), + file) < 0) { return -1; } return 0; @@ -106,23 +103,18 @@ int ExtractBuffer(const rtc::scoped_refptr& input_frame, int height = input_frame->height(); size_t length = CalcBufferSize(VideoType::kI420, width, height); if (size < length) { - return -1; + return -1; } int chroma_width = input_frame->ChromaWidth(); int chroma_height = input_frame->ChromaHeight(); - libyuv::I420Copy(input_frame->DataY(), - input_frame->StrideY(), - input_frame->DataU(), - input_frame->StrideU(), - input_frame->DataV(), - input_frame->StrideV(), - buffer, width, - buffer + width*height, chroma_width, - buffer + width*height + chroma_width*chroma_height, - chroma_width, - width, height); + libyuv::I420Copy(input_frame->DataY(), input_frame->StrideY(), + input_frame->DataU(), input_frame->StrideU(), + input_frame->DataV(), input_frame->StrideV(), buffer, width, + buffer + width * height, chroma_width, + buffer + width * height + chroma_width * chroma_height, + chroma_width, width, height); return static_cast(length); } @@ -134,24 +126,25 @@ int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) { int ConvertNV12ToRGB565(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height) { + int width, + int height) { int abs_height = (height < 0) ? -height : height; const uint8_t* yplane = src_frame; const uint8_t* uvInterlaced = src_frame + (width * abs_height); - return libyuv::NV12ToRGB565(yplane, width, - uvInterlaced, (width + 1) >> 1, - dst_frame, width, - width, height); + return libyuv::NV12ToRGB565(yplane, width, uvInterlaced, (width + 1) >> 1, + dst_frame, width, width, height); } -int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, int dst_stride) { +int ConvertRGB24ToARGB(const uint8_t* src_frame, + uint8_t* dst_frame, + int width, + int height, + int dst_stride) { if (dst_stride == 0) dst_stride = width; - return libyuv::RGB24ToARGB(src_frame, width, - dst_frame, dst_stride, - width, height); + return libyuv::RGB24ToARGB(src_frame, width, dst_frame, dst_stride, width, + height); } int ConvertVideoType(VideoType video_type) { @@ -371,12 +364,18 @@ double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) { } void NV12Scale(uint8_t* tmp_buffer, - const uint8_t* src_y, int src_stride_y, - const uint8_t* src_uv, int src_stride_uv, - int src_width, int src_height, - uint8_t* dst_y, int dst_stride_y, - uint8_t* dst_uv, int dst_stride_uv, - int dst_width, int dst_height) { + const uint8_t* src_y, + int src_stride_y, + const uint8_t* src_uv, + int src_stride_uv, + int src_width, + int src_height, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_uv, + int dst_stride_uv, + int dst_width, + int dst_height) { const int src_chroma_width = (src_width + 1) / 2; const int src_chroma_height = (src_height + 1) / 2; @@ -400,51 +399,44 @@ void NV12Scale(uint8_t* tmp_buffer, uint8_t* const dst_v = dst_u + dst_chroma_width * dst_chroma_height; // Split source UV plane into separate U and V plane using the temporary data. - libyuv::SplitUVPlane(src_uv, src_stride_uv, - src_u, src_chroma_width, - src_v, src_chroma_width, - src_chroma_width, src_chroma_height); + libyuv::SplitUVPlane(src_uv, src_stride_uv, src_u, src_chroma_width, src_v, + src_chroma_width, src_chroma_width, src_chroma_height); // Scale the planes. - libyuv::I420Scale(src_y, src_stride_y, - src_u, src_chroma_width, - src_v, src_chroma_width, - src_width, src_height, - dst_y, dst_stride_y, - dst_u, dst_chroma_width, - dst_v, dst_chroma_width, - dst_width, dst_height, - libyuv::kFilterBox); + libyuv::I420Scale( + src_y, src_stride_y, src_u, src_chroma_width, src_v, src_chroma_width, + src_width, src_height, dst_y, dst_stride_y, dst_u, dst_chroma_width, + dst_v, dst_chroma_width, dst_width, dst_height, libyuv::kFilterBox); // Merge the UV planes into the destination. - libyuv::MergeUVPlane(dst_u, dst_chroma_width, - dst_v, dst_chroma_width, - dst_uv, dst_stride_uv, - dst_chroma_width, dst_chroma_height); + libyuv::MergeUVPlane(dst_u, dst_chroma_width, dst_v, dst_chroma_width, dst_uv, + dst_stride_uv, dst_chroma_width, dst_chroma_height); } NV12ToI420Scaler::NV12ToI420Scaler() = default; NV12ToI420Scaler::~NV12ToI420Scaler() = default; -void NV12ToI420Scaler::NV12ToI420Scale( - const uint8_t* src_y, int src_stride_y, - const uint8_t* src_uv, int src_stride_uv, - int src_width, int src_height, - uint8_t* dst_y, int dst_stride_y, - uint8_t* dst_u, int dst_stride_u, - uint8_t* dst_v, int dst_stride_v, - int dst_width, int dst_height) { +void NV12ToI420Scaler::NV12ToI420Scale(const uint8_t* src_y, + int src_stride_y, + const uint8_t* src_uv, + int src_stride_uv, + int src_width, + int src_height, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_u, + int dst_stride_u, + uint8_t* dst_v, + int dst_stride_v, + int dst_width, + int dst_height) { if (src_width == dst_width && src_height == dst_height) { // No scaling. tmp_uv_planes_.clear(); tmp_uv_planes_.shrink_to_fit(); - libyuv::NV12ToI420( - src_y, src_stride_y, - src_uv, src_stride_uv, - dst_y, dst_stride_y, - dst_u, dst_stride_u, - dst_v, dst_stride_v, - src_width, src_height); + libyuv::NV12ToI420(src_y, src_stride_y, src_uv, src_stride_uv, dst_y, + dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, + src_width, src_height); return; } @@ -458,21 +450,14 @@ void NV12ToI420Scaler::NV12ToI420Scale( // Split source UV plane into separate U and V plane using the temporary data. uint8_t* const src_u = tmp_uv_planes_.data(); uint8_t* const src_v = tmp_uv_planes_.data() + src_uv_width * src_uv_height; - libyuv::SplitUVPlane(src_uv, src_stride_uv, - src_u, src_uv_width, - src_v, src_uv_width, - src_uv_width, src_uv_height); + libyuv::SplitUVPlane(src_uv, src_stride_uv, src_u, src_uv_width, src_v, + src_uv_width, src_uv_width, src_uv_height); // Scale the planes into the destination. - libyuv::I420Scale(src_y, src_stride_y, - src_u, src_uv_width, - src_v, src_uv_width, - src_width, src_height, - dst_y, dst_stride_y, - dst_u, dst_stride_u, - dst_v, dst_stride_v, - dst_width, dst_height, - libyuv::kFilterBox); + libyuv::I420Scale(src_y, src_stride_y, src_u, src_uv_width, src_v, + src_uv_width, src_width, src_height, dst_y, dst_stride_y, + dst_u, dst_stride_u, dst_v, dst_stride_v, dst_width, + dst_height, libyuv::kFilterBox); } } // namespace webrtc diff --git a/common_video/video_frame.cc b/common_video/video_frame.cc index 518bac0e4d..2e1ec439f3 100644 --- a/common_video/video_frame.cc +++ b/common_video/video_frame.cc @@ -45,7 +45,7 @@ EncodedImage::EncodedImage() : EncodedImage(nullptr, 0, 0) {} EncodedImage::EncodedImage(const EncodedImage&) = default; EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t size) - : _buffer(buffer), _length(length), _size(size) {} + : _buffer(buffer), _length(length), _size(size) {} void EncodedImage::SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms) { diff --git a/common_video/video_frame_buffer.cc b/common_video/video_frame_buffer.cc index 6b772d64b8..eeb77a2bbd 100644 --- a/common_video/video_frame_buffer.cc +++ b/common_video/video_frame_buffer.cc @@ -149,8 +149,7 @@ WrappedI420Buffer::WrappedI420Buffer(int width, y_stride_(y_stride), u_stride_(u_stride), v_stride_(v_stride), - no_longer_used_cb_(no_longer_used) { -} + no_longer_used_cb_(no_longer_used) {} WrappedI420Buffer::~WrappedI420Buffer() { no_longer_used_cb_(); diff --git a/common_video/video_render_frames.cc b/common_video/video_render_frames.cc index 5c732df2cf..4fa9ef7b08 100644 --- a/common_video/video_render_frames.cc +++ b/common_video/video_render_frames.cc @@ -88,8 +88,7 @@ uint32_t VideoRenderFrames::TimeToNextFrameRelease() { return kEventMaxWaitTimeMs; } const int64_t time_to_release = incoming_frames_.front().render_time_ms() - - render_delay_ms_ - - rtc::TimeMillis(); + render_delay_ms_ - rtc::TimeMillis(); return time_to_release < 0 ? 0u : static_cast(time_to_release); } diff --git a/examples/objc/AppRTCMobile/ARDAppClient+Internal.h b/examples/objc/AppRTCMobile/ARDAppClient+Internal.h index 3cf40400f5..8e96b16909 100644 --- a/examples/objc/AppRTCMobile/ARDAppClient+Internal.h +++ b/examples/objc/AppRTCMobile/ARDAppClient+Internal.h @@ -18,8 +18,7 @@ @class RTCPeerConnectionFactory; -@interface ARDAppClient () +@interface ARDAppClient () // All properties should only be mutated from the main queue. @property(nonatomic, strong) id roomServerClient; @@ -43,8 +42,7 @@ @property(nonatomic, strong) NSURL *webSocketRestURL; @property(nonatomic, readonly) BOOL isLoopback; -@property(nonatomic, strong) - RTCMediaConstraints *defaultPeerConnectionConstraints; +@property(nonatomic, strong) RTCMediaConstraints *defaultPeerConnectionConstraints; - (instancetype)initWithRoomServerClient:(id)rsClient signalingChannel:(id)channel diff --git a/examples/objc/AppRTCMobile/ARDAppClient.h b/examples/objc/AppRTCMobile/ARDAppClient.h index e513db19c2..07cd53d167 100644 --- a/examples/objc/AppRTCMobile/ARDAppClient.h +++ b/examples/objc/AppRTCMobile/ARDAppClient.h @@ -32,30 +32,25 @@ typedef NS_ENUM(NSInteger, ARDAppClientState) { // main queue. @protocol ARDAppClientDelegate -- (void)appClient:(ARDAppClient *)client - didChangeState:(ARDAppClientState)state; +- (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state; -- (void)appClient:(ARDAppClient *)client - didChangeConnectionState:(RTCIceConnectionState)state; +- (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state; - (void)appClient:(ARDAppClient *)client didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer; -- (void)appClient:(ARDAppClient *)client - didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack; +- (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack; - (void)appClient:(ARDAppClient *)client didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack; -- (void)appClient:(ARDAppClient *)client - didError:(NSError *)error; +- (void)appClient:(ARDAppClient *)client didError:(NSError *)error; -- (void)appClient:(ARDAppClient *)client - didGetStats:(NSArray *)stats; +- (void)appClient:(ARDAppClient *)client didGetStats:(NSArray *)stats; @optional - (void)appClient:(ARDAppClient *)client -didCreateLocalFileCapturer:(RTCFileVideoCapturer *)fileCapturer; + didCreateLocalFileCapturer:(RTCFileVideoCapturer *)fileCapturer; - (void)appClient:(ARDAppClient *)client didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer; diff --git a/examples/objc/AppRTCMobile/ARDAppEngineClient.h b/examples/objc/AppRTCMobile/ARDAppEngineClient.h index 7514f3645c..db4e2efd7f 100644 --- a/examples/objc/AppRTCMobile/ARDAppEngineClient.h +++ b/examples/objc/AppRTCMobile/ARDAppEngineClient.h @@ -10,5 +10,5 @@ #import "ARDRoomServerClient.h" -@interface ARDAppEngineClient : NSObject +@interface ARDAppEngineClient : NSObject @end diff --git a/examples/objc/AppRTCMobile/ARDJoinResponse+Internal.h b/examples/objc/AppRTCMobile/ARDJoinResponse+Internal.h index b3202999d0..0edf7083c0 100644 --- a/examples/objc/AppRTCMobile/ARDJoinResponse+Internal.h +++ b/examples/objc/AppRTCMobile/ARDJoinResponse+Internal.h @@ -14,10 +14,10 @@ @property(nonatomic, assign) ARDJoinResultType result; @property(nonatomic, assign) BOOL isInitiator; -@property(nonatomic, strong) NSString *roomId; -@property(nonatomic, strong) NSString *clientId; -@property(nonatomic, strong) NSArray *messages; -@property(nonatomic, strong) NSURL *webSocketURL; -@property(nonatomic, strong) NSURL *webSocketRestURL; +@property(nonatomic, strong) NSString* roomId; +@property(nonatomic, strong) NSString* clientId; +@property(nonatomic, strong) NSArray* messages; +@property(nonatomic, strong) NSURL* webSocketURL; +@property(nonatomic, strong) NSURL* webSocketRestURL; @end diff --git a/examples/objc/AppRTCMobile/ARDRoomServerClient.h b/examples/objc/AppRTCMobile/ARDRoomServerClient.h index 70694a8c9f..3a5818d6d6 100644 --- a/examples/objc/AppRTCMobile/ARDRoomServerClient.h +++ b/examples/objc/AppRTCMobile/ARDRoomServerClient.h @@ -18,14 +18,12 @@ - (void)joinRoomWithRoomId:(NSString *)roomId isLoopback:(BOOL)isLoopback - completionHandler:(void (^)(ARDJoinResponse *response, - NSError *error))completionHandler; + completionHandler:(void (^)(ARDJoinResponse *response, NSError *error))completionHandler; - (void)sendMessage:(ARDSignalingMessage *)message forRoomId:(NSString *)roomId clientId:(NSString *)clientId - completionHandler:(void (^)(ARDMessageResponse *response, - NSError *error))completionHandler; + completionHandler:(void (^)(ARDMessageResponse *response, NSError *error))completionHandler; - (void)leaveRoomWithRoomId:(NSString *)roomId clientId:(NSString *)clientId diff --git a/examples/objc/AppRTCMobile/ARDSignalingChannel.h b/examples/objc/AppRTCMobile/ARDSignalingChannel.h index 70ba2ff4c9..396b117b17 100644 --- a/examples/objc/AppRTCMobile/ARDSignalingChannel.h +++ b/examples/objc/AppRTCMobile/ARDSignalingChannel.h @@ -26,11 +26,9 @@ typedef NS_ENUM(NSInteger, ARDSignalingChannelState) { @protocol ARDSignalingChannel; @protocol ARDSignalingChannelDelegate -- (void)channel:(id)channel - didChangeState:(ARDSignalingChannelState)state; +- (void)channel:(id)channel didChangeState:(ARDSignalingChannelState)state; -- (void)channel:(id)channel - didReceiveMessage:(ARDSignalingMessage *)message; +- (void)channel:(id)channel didReceiveMessage:(ARDSignalingMessage *)message; @end @@ -42,11 +40,9 @@ typedef NS_ENUM(NSInteger, ARDSignalingChannelState) { @property(nonatomic, weak) id delegate; // Registers the channel for the given room and client id. -- (void)registerForRoomId:(NSString *)roomId - clientId:(NSString *)clientId; +- (void)registerForRoomId:(NSString *)roomId clientId:(NSString *)clientId; // Sends signaling message over the channel. - (void)sendMessage:(ARDSignalingMessage *)message; @end - diff --git a/examples/objc/AppRTCMobile/ARDSignalingMessage.h b/examples/objc/AppRTCMobile/ARDSignalingMessage.h index e60517282b..93ff4862cf 100644 --- a/examples/objc/AppRTCMobile/ARDSignalingMessage.h +++ b/examples/objc/AppRTCMobile/ARDSignalingMessage.h @@ -42,8 +42,7 @@ typedef enum { @property(nonatomic, readonly) NSArray *candidates; -- (instancetype)initWithRemovedCandidates: - (NSArray *)candidates; +- (instancetype)initWithRemovedCandidates:(NSArray *)candidates; @end diff --git a/examples/objc/AppRTCMobile/ARDTURNClient.h b/examples/objc/AppRTCMobile/ARDTURNClient.h index 75ccffcb8c..0cefaf6c19 100644 --- a/examples/objc/AppRTCMobile/ARDTURNClient.h +++ b/examples/objc/AppRTCMobile/ARDTURNClient.h @@ -15,8 +15,7 @@ @protocol ARDTURNClient // Returns TURN server urls if successful. -- (void)requestServersWithCompletionHandler: - (void (^)(NSArray *turnServers, - NSError *error))completionHandler; +- (void)requestServersWithCompletionHandler:(void (^)(NSArray *turnServers, + NSError *error))completionHandler; @end diff --git a/examples/objc/AppRTCMobile/ARDWebSocketChannel.h b/examples/objc/AppRTCMobile/ARDWebSocketChannel.h index ffb0b724af..81888e6e83 100644 --- a/examples/objc/AppRTCMobile/ARDWebSocketChannel.h +++ b/examples/objc/AppRTCMobile/ARDWebSocketChannel.h @@ -21,8 +21,7 @@ // Registers with the WebSocket server for the given room and client id once // the web socket connection is open. -- (void)registerForRoomId:(NSString *)roomId - clientId:(NSString *)clientId; +- (void)registerForRoomId:(NSString *)roomId clientId:(NSString *)clientId; // Sends message over the WebSocket connection if registered, otherwise POSTs to // the web socket server instead. diff --git a/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h b/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h index d2e5e33b5b..1826555861 100644 --- a/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h +++ b/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h @@ -13,8 +13,7 @@ @interface RTCIceCandidate (JSON) + (RTCIceCandidate *)candidateFromJSONDictionary:(NSDictionary *)dictionary; -+ (NSArray *)candidatesFromJSONDictionary: - (NSDictionary *)dictionary; ++ (NSArray *)candidatesFromJSONDictionary:(NSDictionary *)dictionary; + (NSData *)JSONDataForIceCandidates:(NSArray *)candidates withType:(NSString *)typeValue; - (NSData *)JSONData; diff --git a/examples/objc/AppRTCMobile/RTCMediaConstraints+JSON.h b/examples/objc/AppRTCMobile/RTCMediaConstraints+JSON.h index 74f89a953f..42d7ab0f01 100644 --- a/examples/objc/AppRTCMobile/RTCMediaConstraints+JSON.h +++ b/examples/objc/AppRTCMobile/RTCMediaConstraints+JSON.h @@ -12,8 +12,6 @@ @interface RTCMediaConstraints (JSON) -+ (RTCMediaConstraints *)constraintsFromJSONDictionary: - (NSDictionary *)dictionary; ++ (RTCMediaConstraints *)constraintsFromJSONDictionary:(NSDictionary *)dictionary; @end - diff --git a/examples/objc/AppRTCMobile/RTCSessionDescription+JSON.h b/examples/objc/AppRTCMobile/RTCSessionDescription+JSON.h index cccff9ad74..f5671213a8 100644 --- a/examples/objc/AppRTCMobile/RTCSessionDescription+JSON.h +++ b/examples/objc/AppRTCMobile/RTCSessionDescription+JSON.h @@ -12,8 +12,7 @@ @interface RTCSessionDescription (JSON) -+ (RTCSessionDescription *)descriptionFromJSONDictionary: - (NSDictionary *)dictionary; ++ (RTCSessionDescription *)descriptionFromJSONDictionary:(NSDictionary *)dictionary; - (NSData *)JSONData; @end diff --git a/examples/objc/AppRTCMobile/common/ARDUtilities.h b/examples/objc/AppRTCMobile/common/ARDUtilities.h index 5795ff1cf1..5f0d7dbef7 100644 --- a/examples/objc/AppRTCMobile/common/ARDUtilities.h +++ b/examples/objc/AppRTCMobile/common/ARDUtilities.h @@ -22,17 +22,14 @@ // Issues an asynchronous request that calls back on main queue. + (void)sendAsyncRequest:(NSURLRequest *)request - completionHandler:(void (^)(NSURLResponse *response, - NSData *data, - NSError *error))completionHandler; + completionHandler: + (void (^)(NSURLResponse *response, NSData *data, NSError *error))completionHandler; // Posts data to the specified URL. + (void)sendAsyncPostToURL:(NSURL *)url withData:(NSData *)data - completionHandler:(void (^)(BOOL succeeded, - NSData *data))completionHandler; + completionHandler:(void (^)(BOOL succeeded, NSData *data))completionHandler; @end NSInteger ARDGetCpuUsagePercentage(void); - diff --git a/examples/objc/AppRTCMobile/ios/ARDAppDelegate.h b/examples/objc/AppRTCMobile/ios/ARDAppDelegate.h index 7eafff8ebc..623e859096 100644 --- a/examples/objc/AppRTCMobile/ios/ARDAppDelegate.h +++ b/examples/objc/AppRTCMobile/ios/ARDAppDelegate.h @@ -13,5 +13,5 @@ // The main application class of the AppRTCMobile iOS app demonstrating // interoperability between the Objective C implementation of PeerConnection // and the appr.tc demo webapp. -@interface ARDAppDelegate : NSObject +@interface ARDAppDelegate : NSObject @end diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index b86ba55f31..b7f06aad8a 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -41,8 +41,7 @@ class DummySetSessionDescriptionObserver : public webrtc::SetSessionDescriptionObserver { public: static DummySetSessionDescriptionObserver* Create() { - return - new rtc::RefCountedObject(); + return new rtc::RefCountedObject(); } virtual void OnSuccess() { RTC_LOG(INFO) << __FUNCTION__; } virtual void OnFailure(webrtc::RTCError error) { @@ -52,10 +51,7 @@ class DummySetSessionDescriptionObserver }; Conductor::Conductor(PeerConnectionClient* client, MainWindow* main_wnd) - : peer_id_(-1), - loopback_(false), - client_(client), - main_wnd_(main_wnd) { + : peer_id_(-1), loopback_(false), client_(client), main_wnd_(main_wnd) { client_->RegisterObserver(this); main_wnd->RegisterObserver(this); } @@ -87,15 +83,14 @@ bool Conductor::InitializePeerConnection() { nullptr /* audio_processing */); if (!peer_connection_factory_) { - main_wnd_->MessageBox("Error", - "Failed to initialize PeerConnectionFactory", true); + main_wnd_->MessageBox("Error", "Failed to initialize PeerConnectionFactory", + true); DeletePeerConnection(); return false; } if (!CreatePeerConnection(/*dtls=*/true)) { - main_wnd_->MessageBox("Error", - "CreatePeerConnection failed", true); + main_wnd_->MessageBox("Error", "CreatePeerConnection failed", true); DeletePeerConnection(); } @@ -363,8 +358,8 @@ void Conductor::ConnectToPeer(int peer_id) { RTC_DCHECK(peer_id != -1); if (peer_connection_.get()) { - main_wnd_->MessageBox("Error", - "We only support connecting to one peer at a time", true); + main_wnd_->MessageBox( + "Error", "We only support connecting to one peer at a time", true); return; } diff --git a/examples/peerconnection/client/conductor.h b/examples/peerconnection/client/conductor.h index c24bbac87d..a038743915 100644 --- a/examples/peerconnection/client/conductor.h +++ b/examples/peerconnection/client/conductor.h @@ -30,11 +30,10 @@ namespace cricket { class VideoRenderer; } // namespace cricket -class Conductor - : public webrtc::PeerConnectionObserver, - public webrtc::CreateSessionDescriptionObserver, - public PeerConnectionClientObserver, - public MainWndCallback { +class Conductor : public webrtc::PeerConnectionObserver, + public webrtc::CreateSessionDescriptionObserver, + public PeerConnectionClientObserver, + public MainWndCallback { public: enum CallbackID { MEDIA_CHANNELS_INITIALIZED = 1, diff --git a/examples/peerconnection/client/flagdefs.h b/examples/peerconnection/client/flagdefs.h index cc66c6f34a..564e0e95f9 100644 --- a/examples/peerconnection/client/flagdefs.h +++ b/examples/peerconnection/client/flagdefs.h @@ -20,13 +20,19 @@ extern const uint16_t kDefaultServerPort; // From defaults.[h|cc] // for each platform. DEFINE_bool(help, false, "Prints this message"); -DEFINE_bool(autoconnect, false, "Connect to the server without user " - "intervention."); +DEFINE_bool(autoconnect, + false, + "Connect to the server without user " + "intervention."); DEFINE_string(server, "localhost", "The server to connect to."); -DEFINE_int(port, kDefaultServerPort, +DEFINE_int(port, + kDefaultServerPort, "The port on which the server is listening."); -DEFINE_bool(autocall, false, "Call the first available other client on " - "the server without user intervention. Note: this flag should only be set " - "to true on one of the two clients."); +DEFINE_bool( + autocall, + false, + "Call the first available other client on " + "the server without user intervention. Note: this flag should only be set " + "to true on one of the two clients."); #endif // EXAMPLES_PEERCONNECTION_CLIENT_FLAGDEFS_H_ diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc index 200d487e34..50179c4ba5 100644 --- a/examples/peerconnection/client/linux/main.cc +++ b/examples/peerconnection/client/linux/main.cc @@ -38,15 +38,15 @@ class CustomSocketServer : public rtc::PhysicalSocketServer { // different thread. Alternatively we could look at merging the two loops // by implementing a dispatcher for the socket server and/or use // g_main_context_set_poll_func. - while (gtk_events_pending()) - gtk_main_iteration(); + while (gtk_events_pending()) + gtk_main_iteration(); if (!wnd_->IsWindow() && !conductor_->connection_active() && client_ != NULL && !client_->is_connected()) { message_queue_->Quit(); } - return rtc::PhysicalSocketServer::Wait(0/*cms == -1 ? 1 : cms*/, - process_io); + return rtc::PhysicalSocketServer::Wait(0 /*cms == -1 ? 1 : cms*/, + process_io); } protected: @@ -58,15 +58,15 @@ class CustomSocketServer : public rtc::PhysicalSocketServer { int main(int argc, char* argv[]) { gtk_init(&argc, &argv); - // g_type_init API is deprecated (and does nothing) since glib 2.35.0, see: - // https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html +// g_type_init API is deprecated (and does nothing) since glib 2.35.0, see: +// https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html #if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); + g_type_init(); #endif - // g_thread_init API is deprecated since glib 2.31.0, see release note: - // http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html +// g_thread_init API is deprecated since glib 2.31.0, see release note: +// http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html #if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init(NULL); + g_thread_init(NULL); #endif rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); diff --git a/examples/peerconnection/client/linux/main_wnd.cc b/examples/peerconnection/client/linux/main_wnd.cc index 9b9aed2ebc..52b0d88523 100644 --- a/examples/peerconnection/client/linux/main_wnd.cc +++ b/examples/peerconnection/client/linux/main_wnd.cc @@ -30,7 +30,8 @@ namespace { // GtkMainWnd instance. // -gboolean OnDestroyedCallback(GtkWidget* widget, GdkEvent* event, +gboolean OnDestroyedCallback(GtkWidget* widget, + GdkEvent* event, gpointer data) { reinterpret_cast(data)->OnDestroyed(widget, event); return FALSE; @@ -45,14 +46,17 @@ gboolean SimulateButtonClick(gpointer button) { return false; } -gboolean OnKeyPressCallback(GtkWidget* widget, GdkEventKey* key, +gboolean OnKeyPressCallback(GtkWidget* widget, + GdkEventKey* key, gpointer data) { reinterpret_cast(data)->OnKeyPress(widget, key); return false; } -void OnRowActivatedCallback(GtkTreeView* tree_view, GtkTreePath* path, - GtkTreeViewColumn* column, gpointer data) { +void OnRowActivatedCallback(GtkTreeView* tree_view, + GtkTreePath* path, + GtkTreeViewColumn* column, + gpointer data) { reinterpret_cast(data)->OnRowActivated(tree_view, path, column); } @@ -90,8 +94,8 @@ void InitializeList(GtkWidget* list) { // Adds an entry to a tree view. void AddToList(GtkWidget* list, const gchar* str, int value) { - GtkListStore* store = GTK_LIST_STORE( - gtk_tree_view_get_model(GTK_TREE_VIEW(list))); + GtkListStore* store = + GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))); GtkTreeIter iter; gtk_list_store_append(store, &iter); @@ -131,11 +135,20 @@ gboolean Draw(GtkWidget* widget, cairo_t* cr, gpointer data) { // GtkMainWnd implementation. // -GtkMainWnd::GtkMainWnd(const char* server, int port, bool autoconnect, +GtkMainWnd::GtkMainWnd(const char* server, + int port, + bool autoconnect, bool autocall) - : window_(NULL), draw_area_(NULL), vbox_(NULL), server_edit_(NULL), - port_edit_(NULL), peer_list_(NULL), callback_(NULL), - server_(server), autoconnect_(autoconnect), autocall_(autocall) { + : window_(NULL), + draw_area_(NULL), + vbox_(NULL), + server_edit_(NULL), + port_edit_(NULL), + peer_list_(NULL), + callback_(NULL), + server_(server), + autoconnect_(autoconnect), + autocall_(autocall) { char buffer[10]; sprintfn(buffer, sizeof(buffer), "%i", port); port_ = buffer; @@ -153,12 +166,13 @@ bool GtkMainWnd::IsWindow() { return window_ != NULL && GTK_IS_WINDOW(window_); } -void GtkMainWnd::MessageBox(const char* caption, const char* text, +void GtkMainWnd::MessageBox(const char* caption, + const char* text, bool is_error) { - GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(window_), - GTK_DIALOG_DESTROY_WITH_PARENT, - is_error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO, - GTK_BUTTONS_CLOSE, "%s", text); + GtkWidget* dialog = gtk_message_dialog_new( + GTK_WINDOW(window_), GTK_DIALOG_DESTROY_WITH_PARENT, + is_error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s", + text); gtk_window_set_title(GTK_WINDOW(dialog), caption); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); @@ -174,7 +188,6 @@ MainWindow::UI GtkMainWnd::current_ui() { return STREAMING; } - void GtkMainWnd::StartLocalRenderer(webrtc::VideoTrackInterface* local_video) { local_renderer_.reset(new VideoRenderer(this, local_video)); } @@ -394,7 +407,8 @@ void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) { } } -void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path, +void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, + GtkTreePath* path, GtkTreeViewColumn* column) { RTC_DCHECK(peer_list_ != NULL); GtkTreeIter iter; @@ -402,12 +416,12 @@ void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path, GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { - char* text; - int id = -1; - gtk_tree_model_get(model, &iter, 0, &text, 1, &id, -1); - if (id != -1) - callback_->ConnectToPeer(id); - g_free(text); + char* text; + int id = -1; + gtk_tree_model_get(model, &iter, 0, &text, 1, &id, -1); + if (id != -1) + callback_->ConnectToPeer(id); + g_free(text); } } @@ -519,8 +533,7 @@ void GtkMainWnd::VideoRenderer::SetSize(int width, int height) { gdk_threads_leave(); } -void GtkMainWnd::VideoRenderer::OnFrame( - const webrtc::VideoFrame& video_frame) { +void GtkMainWnd::VideoRenderer::OnFrame(const webrtc::VideoFrame& video_frame) { gdk_threads_enter(); rtc::scoped_refptr buffer( @@ -536,11 +549,10 @@ void GtkMainWnd::VideoRenderer::OnFrame( // This was supposed to be a call to libyuv::I420ToRGBA but it was resulting // in a reddish video output (see https://bugs.webrtc.org/6857) because it // was producing an unexpected byte order (ABGR, byte swapped). - libyuv::I420ToABGR(buffer->DataY(), buffer->StrideY(), - buffer->DataU(), buffer->StrideU(), - buffer->DataV(), buffer->StrideV(), - image_.get(), width_ * 4, - buffer->width(), buffer->height()); + libyuv::I420ToABGR(buffer->DataY(), buffer->StrideY(), buffer->DataU(), + buffer->StrideU(), buffer->DataV(), buffer->StrideV(), + image_.get(), width_ * 4, buffer->width(), + buffer->height()); gdk_threads_leave(); diff --git a/examples/peerconnection/client/linux/main_wnd.h b/examples/peerconnection/client/linux/main_wnd.h index fdeee4ba7b..a2edb74757 100644 --- a/examples/peerconnection/client/linux/main_wnd.h +++ b/examples/peerconnection/client/linux/main_wnd.h @@ -39,8 +39,7 @@ class GtkMainWnd : public MainWindow { virtual void SwitchToConnectUI(); virtual void SwitchToPeerList(const Peers& peers); virtual void SwitchToStreamingUI(); - virtual void MessageBox(const char* caption, const char* text, - bool is_error); + virtual void MessageBox(const char* caption, const char* text, bool is_error); virtual MainWindow::UI current_ui(); virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video); virtual void StopLocalRenderer(); @@ -67,7 +66,8 @@ class GtkMainWnd : public MainWindow { // Callback when the user double clicks a peer in order to initiate a // connection. - void OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path, + void OnRowActivated(GtkTreeView* tree_view, + GtkTreePath* path, GtkTreeViewColumn* column); void OnRedraw(); @@ -86,13 +86,9 @@ class GtkMainWnd : public MainWindow { const uint8_t* image() const { return image_.get(); } - int width() const { - return width_; - } + int width() const { return width_; } - int height() const { - return height_; - } + int height() const { return height_; } protected: void SetSize(int width, int height); @@ -104,9 +100,9 @@ class GtkMainWnd : public MainWindow { }; protected: - GtkWidget* window_; // Our main window. + GtkWidget* window_; // Our main window. GtkWidget* draw_area_; // The drawing surface for rendering video streams. - GtkWidget* vbox_; // Container for the Connect UI. + GtkWidget* vbox_; // Container for the Connect UI. GtkWidget* server_edit_; GtkWidget* port_edit_; GtkWidget* peer_list_; // The list of peers. diff --git a/examples/peerconnection/client/main.cc b/examples/peerconnection/client/main.cc index bcf86f185e..ee70da620f 100644 --- a/examples/peerconnection/client/main.cc +++ b/examples/peerconnection/client/main.cc @@ -17,8 +17,10 @@ #include "rtc_base/win32socketinit.h" #include "rtc_base/win32socketserver.h" -int PASCAL wWinMain(HINSTANCE instance, HINSTANCE prev_instance, - wchar_t* cmd_line, int cmd_show) { +int PASCAL wWinMain(HINSTANCE instance, + HINSTANCE prev_instance, + wchar_t* cmd_line, + int cmd_show) { rtc::EnsureWinsockInit(); rtc::Win32SocketServer w32_ss; rtc::Win32Thread w32_thread(&w32_ss); @@ -26,7 +28,7 @@ int PASCAL wWinMain(HINSTANCE instance, HINSTANCE prev_instance, rtc::WindowsCommandLineArguments win_args; int argc = win_args.argc(); - char **argv = win_args.argv(); + char** argv = win_args.argv(); rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); if (FLAG_help) { @@ -50,7 +52,7 @@ int PASCAL wWinMain(HINSTANCE instance, HINSTANCE prev_instance, rtc::InitializeSSL(); PeerConnectionClient client; rtc::scoped_refptr conductor( - new rtc::RefCountedObject(&client, &wnd)); + new rtc::RefCountedObject(&client, &wnd)); // Main loop. MSG msg; diff --git a/examples/peerconnection/client/main_wnd.cc b/examples/peerconnection/client/main_wnd.cc index 86f84fdbd0..c68d314a74 100644 --- a/examples/peerconnection/client/main_wnd.cc +++ b/examples/peerconnection/client/main_wnd.cc @@ -31,8 +31,10 @@ const char kConnecting[] = "Connecting... "; const char kNoVideoStreams[] = "(no video streams either way)"; const char kNoIncomingStream[] = "(no incoming video)"; -void CalculateWindowSizeForText(HWND wnd, const wchar_t* text, - size_t* width, size_t* height) { +void CalculateWindowSizeForText(HWND wnd, + const wchar_t* text, + size_t* width, + size_t* height) { HDC dc = ::GetDC(wnd); RECT text_rc = {0}; ::DrawText(dc, text, -1, &text_rc, DT_CALCRECT | DT_SINGLELINE); @@ -42,11 +44,9 @@ void CalculateWindowSizeForText(HWND wnd, const wchar_t* text, ::GetWindowRect(wnd, &window); *width = text_rc.right - text_rc.left; - *width += (window.right - window.left) - - (client.right - client.left); + *width += (window.right - window.left) - (client.right - client.left); *height = text_rc.bottom - text_rc.top; - *height += (window.bottom - window.top) - - (client.bottom - client.top); + *height += (window.bottom - window.top) - (client.bottom - client.top); } HFONT GetDefaultFont() { @@ -62,18 +62,30 @@ std::string GetWindowText(HWND wnd) { void AddListBoxItem(HWND listbox, const std::string& str, LPARAM item_data) { LRESULT index = ::SendMessageA(listbox, LB_ADDSTRING, 0, - reinterpret_cast(str.c_str())); + reinterpret_cast(str.c_str())); ::SendMessageA(listbox, LB_SETITEMDATA, index, item_data); } } // namespace -MainWnd::MainWnd(const char* server, int port, bool auto_connect, +MainWnd::MainWnd(const char* server, + int port, + bool auto_connect, bool auto_call) - : ui_(CONNECT_TO_SERVER), wnd_(NULL), edit1_(NULL), edit2_(NULL), - label1_(NULL), label2_(NULL), button_(NULL), listbox_(NULL), - destroyed_(false), callback_(NULL), nested_msg_(NULL), - server_(server), auto_connect_(auto_connect), auto_call_(auto_call) { + : ui_(CONNECT_TO_SERVER), + wnd_(NULL), + edit1_(NULL), + edit2_(NULL), + label1_(NULL), + label2_(NULL), + button_(NULL), + listbox_(NULL), + destroyed_(false), + callback_(NULL), + nested_msg_(NULL), + server_(server), + auto_connect_(auto_connect), + auto_call_(auto_call) { char buffer[10] = {0}; sprintfn(buffer, sizeof(buffer), "%i", port); port_ = buffer; @@ -89,10 +101,11 @@ bool MainWnd::Create() { return false; ui_thread_id_ = ::GetCurrentThreadId(); - wnd_ = ::CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, kClassName, L"WebRTC", - WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, GetModuleHandle(NULL), this); + wnd_ = + ::CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, kClassName, L"WebRTC", + WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), this); ::SendMessage(wnd_, WM_SETFONT, reinterpret_cast(GetDefaultFont()), TRUE); @@ -176,10 +189,10 @@ void MainWnd::SwitchToPeerList(const Peers& peers) { LRESULT count = ::SendMessage(listbox_, LB_GETCOUNT, 0, 0); if (count != LB_ERR) { // Select the last item in the list - LRESULT selection = ::SendMessage(listbox_, LB_SETCURSEL , count - 1, 0); + LRESULT selection = ::SendMessage(listbox_, LB_SETCURSEL, count - 1, 0); if (selection != LB_ERR) - ::PostMessage(wnd_, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(listbox_), - LBN_DBLCLK), + ::PostMessage(wnd_, WM_COMMAND, + MAKEWPARAM(GetDlgCtrlID(listbox_), LBN_DBLCLK), reinterpret_cast(listbox_)); } } @@ -199,7 +212,6 @@ void MainWnd::MessageBox(const char* caption, const char* text, bool is_error) { ::MessageBoxA(handle(), text, caption, flags); } - void MainWnd::StartLocalRenderer(webrtc::VideoTrackInterface* local_video) { local_renderer_.reset(new VideoRenderer(handle(), 1, 1, local_video)); } @@ -218,7 +230,8 @@ void MainWnd::StopRemoteRenderer() { void MainWnd::QueueUIThreadCallback(int msg_id, void* data) { ::PostThreadMessage(ui_thread_id_, UI_THREAD_CALLBACK, - static_cast(msg_id), reinterpret_cast(data)); + static_cast(msg_id), + reinterpret_cast(data)); } void MainWnd::OnPaint() { @@ -244,7 +257,7 @@ void MainWnd::OnPaint() { ::SetStretchBltMode(dc_mem, HALFTONE); // Set the map mode so that the ratio will be maintained for us. - HDC all_dc[] = { ps.hdc, dc_mem }; + HDC all_dc[] = {ps.hdc, dc_mem}; for (int i = 0; i < arraysize(all_dc); ++i) { SetMapMode(all_dc[i], MM_ISOTROPIC); SetWindowExtEx(all_dc[i], width, height, NULL); @@ -254,35 +267,34 @@ void MainWnd::OnPaint() { HBITMAP bmp_mem = ::CreateCompatibleBitmap(ps.hdc, rc.right, rc.bottom); HGDIOBJ bmp_old = ::SelectObject(dc_mem, bmp_mem); - POINT logical_area = { rc.right, rc.bottom }; + POINT logical_area = {rc.right, rc.bottom}; DPtoLP(ps.hdc, &logical_area, 1); HBRUSH brush = ::CreateSolidBrush(RGB(0, 0, 0)); - RECT logical_rect = {0, 0, logical_area.x, logical_area.y }; + RECT logical_rect = {0, 0, logical_area.x, logical_area.y}; ::FillRect(dc_mem, &logical_rect, brush); ::DeleteObject(brush); int x = (logical_area.x / 2) - (width / 2); int y = (logical_area.y / 2) - (height / 2); - StretchDIBits(dc_mem, x, y, width, height, - 0, 0, width, height, image, &bmi, DIB_RGB_COLORS, SRCCOPY); + StretchDIBits(dc_mem, x, y, width, height, 0, 0, width, height, image, + &bmi, DIB_RGB_COLORS, SRCCOPY); if ((rc.right - rc.left) > 200 && (rc.bottom - rc.top) > 200) { const BITMAPINFO& bmi = local_renderer->bmi(); image = local_renderer->image(); int thumb_width = bmi.bmiHeader.biWidth / 4; int thumb_height = abs(bmi.bmiHeader.biHeight) / 4; - StretchDIBits(dc_mem, - logical_area.x - thumb_width - 10, - logical_area.y - thumb_height - 10, - thumb_width, thumb_height, - 0, 0, bmi.bmiHeader.biWidth, -bmi.bmiHeader.biHeight, - image, &bmi, DIB_RGB_COLORS, SRCCOPY); + StretchDIBits(dc_mem, logical_area.x - thumb_width - 10, + logical_area.y - thumb_height - 10, thumb_width, + thumb_height, 0, 0, bmi.bmiHeader.biWidth, + -bmi.bmiHeader.biHeight, image, &bmi, DIB_RGB_COLORS, + SRCCOPY); } - BitBlt(ps.hdc, 0, 0, logical_area.x, logical_area.y, - dc_mem, 0, 0, SRCCOPY); + BitBlt(ps.hdc, 0, 0, logical_area.x, logical_area.y, dc_mem, 0, 0, + SRCCOPY); // Cleanup. ::SelectObject(dc_mem, bmp_old); @@ -305,7 +317,7 @@ void MainWnd::OnPaint() { text += kNoIncomingStream; } ::DrawTextA(ps.hdc, text.c_str(), -1, &rc, - DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DT_SINGLELINE | DT_CENTER | DT_VCENTER); ::SelectObject(ps.hdc, old_font); } } else { @@ -393,8 +405,8 @@ bool MainWnd::OnMessage(UINT msg, WPARAM wp, LPARAM lp, LRESULT* result) { // static LRESULT CALLBACK MainWnd::WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { - MainWnd* me = reinterpret_cast( - ::GetWindowLongPtr(hwnd, GWLP_USERDATA)); + MainWnd* me = + reinterpret_cast(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (!me && WM_CREATE == msg) { CREATESTRUCT* cs = reinterpret_cast(lp); me = reinterpret_cast(cs->lpCreateParams); @@ -433,7 +445,7 @@ bool MainWnd::RegisterWindowClass() { if (wnd_class_) return true; - WNDCLASSEX wcex = { sizeof(WNDCLASSEX) }; + WNDCLASSEX wcex = {sizeof(WNDCLASSEX)}; wcex.style = CS_DBLCLKS; wcex.hInstance = GetModuleHandle(NULL); wcex.hbrBackground = reinterpret_cast(COLOR_WINDOW + 1); @@ -445,17 +457,18 @@ bool MainWnd::RegisterWindowClass() { return wnd_class_ != 0; } -void MainWnd::CreateChildWindow(HWND* wnd, MainWnd::ChildWindowID id, - const wchar_t* class_name, DWORD control_style, +void MainWnd::CreateChildWindow(HWND* wnd, + MainWnd::ChildWindowID id, + const wchar_t* class_name, + DWORD control_style, DWORD ex_style) { if (::IsWindow(*wnd)) return; // Child windows are invisible at first, and shown after being resized. DWORD style = WS_CHILD | control_style; - *wnd = ::CreateWindowEx(ex_style, class_name, L"", style, - 100, 100, 100, 100, wnd_, - reinterpret_cast(id), + *wnd = ::CreateWindowEx(ex_style, class_name, L"", style, 100, 100, 100, 100, + wnd_, reinterpret_cast(id), GetModuleHandle(NULL), NULL); RTC_DCHECK(::IsWindow(*wnd) != FALSE); ::SendMessage(*wnd, WM_SETFONT, reinterpret_cast(GetDefaultFont()), @@ -486,11 +499,9 @@ void MainWnd::LayoutConnectUI(bool show) { size_t width; size_t height; } windows[] = { - { label1_, L"Server" }, - { edit1_, L"XXXyyyYYYgggXXXyyyYYYggg" }, - { label2_, L":" }, - { edit2_, L"XyXyX" }, - { button_, L"Connect" }, + {label1_, L"Server"}, {edit1_, L"XXXyyyYYYgggXXXyyyYYYggg"}, + {label2_, L":"}, {edit2_, L"XyXyX"}, + {button_, L"Connect"}, }; if (show) { @@ -511,8 +522,7 @@ void MainWnd::LayoutConnectUI(bool show) { size_t top = y - (windows[i].height / 2); ::MoveWindow(windows[i].wnd, static_cast(x), static_cast(top), static_cast(windows[i].width), - static_cast(windows[i].height), - TRUE); + static_cast(windows[i].height), TRUE); x += kSeparator + windows[i].width; if (windows[i].text[0] != 'X') ::SetWindowText(windows[i].wnd, windows[i].text); @@ -566,7 +576,9 @@ void MainWnd::HandleTabbing() { // MainWnd::VideoRenderer::VideoRenderer( - HWND wnd, int width, int height, + HWND wnd, + int width, + int height, webrtc::VideoTrackInterface* track_to_render) : wnd_(wnd), rendered_track_(track_to_render) { ::InitializeCriticalSection(&buffer_lock_); @@ -577,8 +589,8 @@ MainWnd::VideoRenderer::VideoRenderer( bmi_.bmiHeader.biCompression = BI_RGB; bmi_.bmiHeader.biWidth = width; bmi_.bmiHeader.biHeight = -height; - bmi_.bmiHeader.biSizeImage = width * height * - (bmi_.bmiHeader.biBitCount >> 3); + bmi_.bmiHeader.biSizeImage = + width * height * (bmi_.bmiHeader.biBitCount >> 3); rendered_track_->AddOrUpdateSink(this, rtc::VideoSinkWants()); } @@ -596,14 +608,12 @@ void MainWnd::VideoRenderer::SetSize(int width, int height) { bmi_.bmiHeader.biWidth = width; bmi_.bmiHeader.biHeight = -height; - bmi_.bmiHeader.biSizeImage = width * height * - (bmi_.bmiHeader.biBitCount >> 3); + bmi_.bmiHeader.biSizeImage = + width * height * (bmi_.bmiHeader.biBitCount >> 3); image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); } -void MainWnd::VideoRenderer::OnFrame( - const webrtc::VideoFrame& video_frame) { - +void MainWnd::VideoRenderer::OnFrame(const webrtc::VideoFrame& video_frame) { { AutoLock lock(this); @@ -616,12 +626,10 @@ void MainWnd::VideoRenderer::OnFrame( SetSize(buffer->width(), buffer->height()); RTC_DCHECK(image_.get() != NULL); - libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), - buffer->DataU(), buffer->StrideU(), - buffer->DataV(), buffer->StrideV(), + libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), buffer->DataU(), + buffer->StrideU(), buffer->DataV(), buffer->StrideV(), image_.get(), - bmi_.bmiHeader.biWidth * - bmi_.bmiHeader.biBitCount / 8, + bmi_.bmiHeader.biWidth * bmi_.bmiHeader.biBitCount / 8, buffer->width(), buffer->height()); } InvalidateRect(wnd_, NULL, TRUE); diff --git a/examples/peerconnection/client/main_wnd.h b/examples/peerconnection/client/main_wnd.h index 8edf81ffb3..57002583ea 100644 --- a/examples/peerconnection/client/main_wnd.h +++ b/examples/peerconnection/client/main_wnd.h @@ -32,6 +32,7 @@ class MainWndCallback { virtual void DisconnectFromCurrentPeer() = 0; virtual void UIThreadCallback(int msg_id, void* data) = 0; virtual void Close() = 0; + protected: virtual ~MainWndCallback() {} }; @@ -50,7 +51,8 @@ class MainWindow { virtual void RegisterObserver(MainWndCallback* callback) = 0; virtual bool IsWindow() = 0; - virtual void MessageBox(const char* caption, const char* text, + virtual void MessageBox(const char* caption, + const char* text, bool is_error) = 0; virtual UI current_ui() = 0; @@ -90,8 +92,7 @@ class MainWnd : public MainWindow { virtual void SwitchToConnectUI(); virtual void SwitchToPeerList(const Peers& peers); virtual void SwitchToStreamingUI(); - virtual void MessageBox(const char* caption, const char* text, - bool is_error); + virtual void MessageBox(const char* caption, const char* text, bool is_error); virtual UI current_ui() { return ui_; } virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video); @@ -105,17 +106,15 @@ class MainWnd : public MainWindow { class VideoRenderer : public rtc::VideoSinkInterface { public: - VideoRenderer(HWND wnd, int width, int height, + VideoRenderer(HWND wnd, + int width, + int height, webrtc::VideoTrackInterface* track_to_render); virtual ~VideoRenderer(); - void Lock() { - ::EnterCriticalSection(&buffer_lock_); - } + void Lock() { ::EnterCriticalSection(&buffer_lock_); } - void Unlock() { - ::LeaveCriticalSection(&buffer_lock_); - } + void Unlock() { ::LeaveCriticalSection(&buffer_lock_); } // VideoSinkInterface implementation void OnFrame(const webrtc::VideoFrame& frame) override; @@ -145,6 +144,7 @@ class MainWnd : public MainWindow { public: explicit AutoLock(T* obj) : obj_(obj) { obj_->Lock(); } ~AutoLock() { obj_->Unlock(); } + protected: T* obj_; }; @@ -168,8 +168,11 @@ class MainWnd : public MainWindow { static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); static bool RegisterWindowClass(); - void CreateChildWindow(HWND* wnd, ChildWindowID id, const wchar_t* class_name, - DWORD control_style, DWORD ex_style); + void CreateChildWindow(HWND* wnd, + ChildWindowID id, + const wchar_t* class_name, + DWORD control_style, + DWORD ex_style); void CreateChildWindows(); void LayoutConnectUI(bool show); diff --git a/examples/peerconnection/client/peer_connection_client.cc b/examples/peerconnection/client/peer_connection_client.cc index 40dfec55fe..bb79d16791 100644 --- a/examples/peerconnection/client/peer_connection_client.cc +++ b/examples/peerconnection/client/peer_connection_client.cc @@ -46,30 +46,23 @@ rtc::AsyncSocket* CreateClientSocket(int family) { } // namespace PeerConnectionClient::PeerConnectionClient() - : callback_(NULL), - resolver_(NULL), - state_(NOT_CONNECTED), - my_id_(-1) { -} + : callback_(NULL), resolver_(NULL), state_(NOT_CONNECTED), my_id_(-1) {} -PeerConnectionClient::~PeerConnectionClient() { -} +PeerConnectionClient::~PeerConnectionClient() {} void PeerConnectionClient::InitSocketSignals() { RTC_DCHECK(control_socket_.get() != NULL); RTC_DCHECK(hanging_get_.get() != NULL); control_socket_->SignalCloseEvent.connect(this, - &PeerConnectionClient::OnClose); - hanging_get_->SignalCloseEvent.connect(this, - &PeerConnectionClient::OnClose); + &PeerConnectionClient::OnClose); + hanging_get_->SignalCloseEvent.connect(this, &PeerConnectionClient::OnClose); control_socket_->SignalConnectEvent.connect(this, - &PeerConnectionClient::OnConnect); - hanging_get_->SignalConnectEvent.connect(this, - &PeerConnectionClient::OnHangingGetConnect); - control_socket_->SignalReadEvent.connect(this, - &PeerConnectionClient::OnRead); - hanging_get_->SignalReadEvent.connect(this, - &PeerConnectionClient::OnHangingGetRead); + &PeerConnectionClient::OnConnect); + hanging_get_->SignalConnectEvent.connect( + this, &PeerConnectionClient::OnHangingGetConnect); + control_socket_->SignalReadEvent.connect(this, &PeerConnectionClient::OnRead); + hanging_get_->SignalReadEvent.connect( + this, &PeerConnectionClient::OnHangingGetRead); } int PeerConnectionClient::id() const { @@ -90,7 +83,8 @@ void PeerConnectionClient::RegisterObserver( callback_ = callback; } -void PeerConnectionClient::Connect(const std::string& server, int port, +void PeerConnectionClient::Connect(const std::string& server, + int port, const std::string& client_name) { RTC_DCHECK(!server.empty()); RTC_DCHECK(!client_name.empty()); @@ -142,8 +136,8 @@ void PeerConnectionClient::DoConnect() { hanging_get_.reset(CreateClientSocket(server_address_.ipaddr().family())); InitSocketSignals(); char buffer[1024]; - sprintfn(buffer, sizeof(buffer), - "GET /sign_in?%s HTTP/1.0\r\n\r\n", client_name_.c_str()); + sprintfn(buffer, sizeof(buffer), "GET /sign_in?%s HTTP/1.0\r\n\r\n", + client_name_.c_str()); onconnect_data_ = buffer; bool ret = ConnectControlSocket(); @@ -165,11 +159,11 @@ bool PeerConnectionClient::SendToPeer(int peer_id, const std::string& message) { char headers[1024]; sprintfn(headers, sizeof(headers), - "POST /message?peer_id=%i&to=%i HTTP/1.0\r\n" - "Content-Length: %i\r\n" - "Content-Type: text/plain\r\n" - "\r\n", - my_id_, peer_id, message.length()); + "POST /message?peer_id=%i&to=%i HTTP/1.0\r\n" + "Content-Length: %i\r\n" + "Content-Type: text/plain\r\n" + "\r\n", + my_id_, peer_id, message.length()); onconnect_data_ = headers; onconnect_data_ += message; return ConnectControlSocket(); @@ -197,7 +191,7 @@ bool PeerConnectionClient::SignOut() { if (my_id_ != -1) { char buffer[1024]; sprintfn(buffer, sizeof(buffer), - "GET /sign_out?peer_id=%i HTTP/1.0\r\n\r\n", my_id_); + "GET /sign_out?peer_id=%i HTTP/1.0\r\n\r\n", my_id_); onconnect_data_ = buffer; return ConnectControlSocket(); } else { @@ -243,8 +237,8 @@ void PeerConnectionClient::OnConnect(rtc::AsyncSocket* socket) { void PeerConnectionClient::OnHangingGetConnect(rtc::AsyncSocket* socket) { char buffer[1024]; - sprintfn(buffer, sizeof(buffer), - "GET /wait?peer_id=%i HTTP/1.0\r\n\r\n", my_id_); + sprintfn(buffer, sizeof(buffer), "GET /wait?peer_id=%i HTTP/1.0\r\n\r\n", + my_id_); int len = static_cast(strlen(buffer)); int sent = socket->Send(buffer, len); RTC_DCHECK(sent == len); @@ -273,7 +267,8 @@ bool PeerConnectionClient::GetHeaderValue(const std::string& data, return false; } -bool PeerConnectionClient::GetHeaderValue(const std::string& data, size_t eoh, +bool PeerConnectionClient::GetHeaderValue(const std::string& data, + size_t eoh, const char* header_pattern, std::string* value) { RTC_DCHECK(value != NULL); @@ -331,8 +326,8 @@ void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) { size_t content_length = 0; if (ReadIntoBuffer(socket, &control_data_, &content_length)) { size_t peer_id = 0, eoh = 0; - bool ok = ParseServerResponse(control_data_, content_length, &peer_id, - &eoh); + bool ok = + ParseServerResponse(control_data_, content_length, &peer_id, &eoh); if (ok) { if (my_id_ == -1) { // First response. Let's store our server assigned ID. @@ -351,7 +346,8 @@ void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) { std::string name; bool connected; if (ParseEntry(control_data_.substr(pos, eol - pos), &name, &id, - &connected) && id != my_id_) { + &connected) && + id != my_id_) { peers_[id] = name; callback_->OnPeerConnected(id, name); } @@ -383,8 +379,8 @@ void PeerConnectionClient::OnHangingGetRead(rtc::AsyncSocket* socket) { size_t content_length = 0; if (ReadIntoBuffer(socket, ¬ification_data_, &content_length)) { size_t peer_id = 0, eoh = 0; - bool ok = ParseServerResponse(notification_data_, content_length, - &peer_id, &eoh); + bool ok = + ParseServerResponse(notification_data_, content_length, &peer_id, &eoh); if (ok) { // Store the position where the body begins. diff --git a/examples/peerconnection/client/peer_connection_client.h b/examples/peerconnection/client/peer_connection_client.h index f5f87ec381..08bbfb0151 100644 --- a/examples/peerconnection/client/peer_connection_client.h +++ b/examples/peerconnection/client/peer_connection_client.h @@ -56,7 +56,8 @@ class PeerConnectionClient : public sigslot::has_slots<>, void RegisterObserver(PeerConnectionClientObserver* callback); - void Connect(const std::string& server, int port, + void Connect(const std::string& server, + int port, const std::string& client_name); bool SendToPeer(int peer_id, const std::string& message); @@ -78,14 +79,19 @@ class PeerConnectionClient : public sigslot::has_slots<>, void OnMessageFromPeer(int peer_id, const std::string& message); // Quick and dirty support for parsing HTTP header values. - bool GetHeaderValue(const std::string& data, size_t eoh, - const char* header_pattern, size_t* value); + bool GetHeaderValue(const std::string& data, + size_t eoh, + const char* header_pattern, + size_t* value); - bool GetHeaderValue(const std::string& data, size_t eoh, - const char* header_pattern, std::string* value); + bool GetHeaderValue(const std::string& data, + size_t eoh, + const char* header_pattern, + std::string* value); // Returns true if the whole response has been read. - bool ReadIntoBuffer(rtc::AsyncSocket* socket, std::string* data, + bool ReadIntoBuffer(rtc::AsyncSocket* socket, + std::string* data, size_t* content_length); void OnRead(rtc::AsyncSocket* socket); @@ -93,13 +99,17 @@ class PeerConnectionClient : public sigslot::has_slots<>, void OnHangingGetRead(rtc::AsyncSocket* socket); // Parses a single line entry in the form ",," - bool ParseEntry(const std::string& entry, std::string* name, int* id, + bool ParseEntry(const std::string& entry, + std::string* name, + int* id, bool* connected); int GetResponseStatus(const std::string& response); - bool ParseServerResponse(const std::string& response, size_t content_length, - size_t* peer_id, size_t* eoh); + bool ParseServerResponse(const std::string& response, + size_t content_length, + size_t* peer_id, + size_t* eoh); void OnClose(rtc::AsyncSocket* socket, int err); diff --git a/examples/peerconnection/server/data_socket.cc b/examples/peerconnection/server/data_socket.cc index 7a924316aa..4369117e1f 100644 --- a/examples/peerconnection/server/data_socket.cc +++ b/examples/peerconnection/server/data_socket.cc @@ -29,7 +29,7 @@ const char DataSocket::kCrossOriginAllowHeaders[] = "Access-Control-Allow-Credentials: true\r\n" "Access-Control-Allow-Methods: POST, GET, OPTIONS\r\n" "Access-Control-Allow-Headers: Content-Type, " - "Content-Length, Connection, Cache-Control\r\n" + "Content-Length, Connection, Cache-Control\r\n" "Access-Control-Expose-Headers: Content-Length, X-Peer-Id\r\n"; #if defined(WIN32) @@ -116,10 +116,11 @@ bool DataSocket::OnDataAvailable(bool* close_socket) { bool DataSocket::Send(const std::string& data) const { return send(socket_, data.data(), static_cast(data.length()), 0) != - SOCKET_ERROR; + SOCKET_ERROR; } -bool DataSocket::Send(const std::string& status, bool connection_close, +bool DataSocket::Send(const std::string& status, + bool connection_close, const std::string& content_type, const std::string& extra_headers, const std::string& data) const { @@ -127,8 +128,9 @@ bool DataSocket::Send(const std::string& status, bool connection_close, assert(!status.empty()); std::string buffer("HTTP/1.1 " + status + "\r\n"); - buffer += "Server: PeerConnectionTestServer/0.1\r\n" - "Cache-Control: no-cache\r\n"; + buffer += + "Server: PeerConnectionTestServer/0.1\r\n" + "Cache-Control: no-cache\r\n"; if (connection_close) buffer += "Connection: close\r\n"; @@ -136,8 +138,8 @@ bool DataSocket::Send(const std::string& status, bool connection_close, if (!content_type.empty()) buffer += "Content-Type: " + content_type + "\r\n"; - buffer += "Content-Length: " + int2str(static_cast(data.size())) + - "\r\n"; + buffer += + "Content-Length: " + int2str(static_cast(data.size())) + "\r\n"; if (!extra_headers.empty()) { buffer += extra_headers; @@ -190,9 +192,7 @@ bool DataSocket::ParseMethodAndPath(const char* begin, size_t len) { size_t method_name_len; RequestMethod id; } supported_methods[] = { - { "GET", 3, GET }, - { "POST", 4, POST }, - { "OPTIONS", 7, OPTIONS }, + {"GET", 3, GET}, {"POST", 4, POST}, {"OPTIONS", 7, OPTIONS}, }; const char* path = NULL; @@ -231,15 +231,15 @@ bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) { static const char kContentLength[] = "Content-Length:"; static const char kContentType[] = "Content-Type:"; if ((headers + ARRAYSIZE(kContentLength)) < end && - strncmp(headers, kContentLength, - ARRAYSIZE(kContentLength) - 1) == 0) { + strncmp(headers, kContentLength, ARRAYSIZE(kContentLength) - 1) == + 0) { headers += ARRAYSIZE(kContentLength) - 1; while (headers[0] == ' ') ++headers; content_length_ = atoi(headers); } else if ((headers + ARRAYSIZE(kContentType)) < end && - strncmp(headers, kContentType, - ARRAYSIZE(kContentType) - 1) == 0) { + strncmp(headers, kContentType, ARRAYSIZE(kContentType) - 1) == + 0) { headers += ARRAYSIZE(kContentType) - 1; while (headers[0] == ' ') ++headers; @@ -267,13 +267,13 @@ bool ListeningSocket::Listen(unsigned short port) { assert(valid()); int enabled = 1; setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, - reinterpret_cast(&enabled), sizeof(enabled)); + reinterpret_cast(&enabled), sizeof(enabled)); struct sockaddr_in addr = {0}; addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons(port); - if (bind(socket_, reinterpret_cast(&addr), - sizeof(addr)) == SOCKET_ERROR) { + if (bind(socket_, reinterpret_cast(&addr), sizeof(addr)) == + SOCKET_ERROR) { printf("bind failed\n"); return false; } diff --git a/examples/peerconnection/server/data_socket.h b/examples/peerconnection/server/data_socket.h index 6bafa830a9..4429bc5a00 100644 --- a/examples/peerconnection/server/data_socket.h +++ b/examples/peerconnection/server/data_socket.h @@ -27,7 +27,7 @@ typedef int NativeSocket; #endif #ifndef INVALID_SOCKET -#define INVALID_SOCKET static_cast(-1) +#define INVALID_SOCKET static_cast(-1) #endif #endif @@ -35,8 +35,8 @@ typedef int NativeSocket; class SocketBase { public: - SocketBase() : socket_(INVALID_SOCKET) { } - explicit SocketBase(NativeSocket socket) : socket_(socket) { } + SocketBase() : socket_(INVALID_SOCKET) {} + explicit SocketBase(NativeSocket socket) : socket_(socket) {} ~SocketBase() { Close(); } NativeSocket socket() const { return socket_; } @@ -60,13 +60,9 @@ class DataSocket : public SocketBase { }; explicit DataSocket(NativeSocket socket) - : SocketBase(socket), - method_(INVALID), - content_length_(0) { - } + : SocketBase(socket), method_(INVALID), content_length_(0) {} - ~DataSocket() { - } + ~DataSocket() {} static const char kCrossOriginAllowHeaders[]; @@ -110,9 +106,11 @@ class DataSocket : public SocketBase { // header terminates with "\r\n". // |data| is the body of the message. It's length will be specified via // a "Content-Length" header. - bool Send(const std::string& status, bool connection_close, + bool Send(const std::string& status, + bool connection_close, const std::string& content_type, - const std::string& extra_headers, const std::string& data) const; + const std::string& extra_headers, + const std::string& data) const; // Clears all held state and prepares the socket for receiving a new request. void Clear(); diff --git a/examples/peerconnection/server/main.cc b/examples/peerconnection/server/main.cc index 1df34bb8c4..eafda60630 100644 --- a/examples/peerconnection/server/main.cc +++ b/examples/peerconnection/server/main.cc @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) { for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) FD_SET((*i)->socket(), &socket_set); - struct timeval timeout = { 10, 0 }; + struct timeval timeout = {10, 0}; if (select(FD_SETSIZE, &socket_set, NULL, NULL, &timeout) == SOCKET_ERROR) { printf("select failed\n"); break; @@ -111,8 +111,7 @@ int main(int argc, char* argv[]) { if (s->PathEquals("/sign_in")) { clients.AddMember(s); } else { - printf("No member found for: %s\n", - s->request_path().c_str()); + printf("No member found for: %s\n", s->request_path().c_str()); s->Send("500 Error", true, "text/plain", "", "Peer most likely gone."); } @@ -127,7 +126,7 @@ int main(int argc, char* argv[]) { s->Send("200 OK", true, "text/plain", "", ""); } else { printf("Couldn't find target for request: %s\n", - s->request_path().c_str()); + s->request_path().c_str()); s->Send("500 Error", true, "text/plain", "", "Peer most likely gone."); } diff --git a/examples/peerconnection/server/peer_channel.cc b/examples/peerconnection/server/peer_channel.cc index 69a0e104f3..6ef08d7b21 100644 --- a/examples/peerconnection/server/peer_channel.cc +++ b/examples/peerconnection/server/peer_channel.cc @@ -37,7 +37,7 @@ using rtc::sprintfn; static const char kPeerIdHeader[] = "Pragma: "; static const char* kRequestPaths[] = { - "/wait", "/sign_out", "/message", + "/wait", "/sign_out", "/message", }; enum RequestPathIndex { @@ -55,8 +55,10 @@ const size_t kMaxNameLength = 512; int ChannelMember::s_member_id_ = 0; ChannelMember::ChannelMember(DataSocket* socket) - : waiting_socket_(NULL), id_(++s_member_id_), - connected_(true), timestamp_(time(NULL)) { + : waiting_socket_(NULL), + id_(++s_member_id_), + connected_(true), + timestamp_(time(NULL)) { assert(socket); assert(socket->method() == DataSocket::GET); assert(socket->PathEquals("/sign_in")); @@ -69,8 +71,7 @@ ChannelMember::ChannelMember(DataSocket* socket) std::replace(name_.begin(), name_.end(), ',', '_'); } -ChannelMember::~ChannelMember() { -} +ChannelMember::~ChannelMember() {} bool ChannelMember::is_wait_request(DataSocket* ds) const { return ds && ds->PathEquals(kRequestPaths[kWait]); @@ -87,8 +88,7 @@ std::string ChannelMember::GetPeerIdHeader() const { bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) { assert(&other != this); - QueueResponse("200 OK", "text/plain", GetPeerIdHeader(), - other.GetEntry()); + QueueResponse("200 OK", "text/plain", GetPeerIdHeader(), other.GetEntry()); return true; } @@ -110,11 +110,9 @@ void ChannelMember::ForwardRequestToPeer(DataSocket* ds, ChannelMember* peer) { std::string extra_headers(GetPeerIdHeader()); if (peer == this) { - ds->Send("200 OK", true, ds->content_type(), extra_headers, - ds->data()); + ds->Send("200 OK", true, ds->content_type(), extra_headers, ds->data()); } else { - printf("Client %s sending to %s\n", - name_.c_str(), peer->name().c_str()); + printf("Client %s sending to %s\n", name_.c_str(), peer->name().c_str()); peer->QueueResponse("200 OK", ds->content_type(), extra_headers, ds->data()); ds->Send("200 OK", true, "text/plain", "", ""); @@ -135,8 +133,8 @@ void ChannelMember::QueueResponse(const std::string& status, if (waiting_socket_) { assert(queue_.size() == 0); assert(waiting_socket_->method() == DataSocket::GET); - bool ok = waiting_socket_->Send(status, true, content_type, extra_headers, - data); + bool ok = + waiting_socket_->Send(status, true, content_type, extra_headers, data); if (!ok) { printf("Failed to deliver data to waiting socket\n"); } @@ -251,7 +249,7 @@ bool PeerChannel::AddMember(DataSocket* ds) { members_.push_back(new_guy); printf("New member added (total=%s): %s\n", - size_t2str(members_.size()).c_str(), new_guy->name().c_str()); + size_t2str(members_.size()).c_str(), new_guy->name().c_str()); // Let the newly connected peer know about other members of the channel. std::string content_type; diff --git a/examples/peerconnection/server/peer_channel.h b/examples/peerconnection/server/peer_channel.h index a9343d9aeb..c3bb1ad10b 100644 --- a/examples/peerconnection/server/peer_channel.h +++ b/examples/peerconnection/server/peer_channel.h @@ -44,8 +44,10 @@ class ChannelMember { void OnClosing(DataSocket* ds); - void QueueResponse(const std::string& status, const std::string& content_type, - const std::string& extra_headers, const std::string& data); + void QueueResponse(const std::string& status, + const std::string& content_type, + const std::string& extra_headers, + const std::string& data); void SetWaitingSocket(DataSocket* ds); @@ -68,12 +70,9 @@ class PeerChannel { public: typedef std::vector Members; - PeerChannel() { - } + PeerChannel() {} - ~PeerChannel() { - DeleteAll(); - } + ~PeerChannel() { DeleteAll(); } const Members& members() const { return members_; } diff --git a/examples/relayserver/relayserver_main.cc b/examples/relayserver/relayserver_main.cc index e3b18f1a92..b98caba044 100644 --- a/examples/relayserver/relayserver_main.cc +++ b/examples/relayserver/relayserver_main.cc @@ -14,7 +14,7 @@ #include "p2p/base/relayserver.h" #include "rtc_base/thread.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { if (argc != 3) { std::cerr << "usage: relayserver internal-address external-address" << std::endl; @@ -33,21 +33,21 @@ int main(int argc, char **argv) { return 1; } - rtc::Thread *pthMain = rtc::Thread::Current(); + rtc::Thread* pthMain = rtc::Thread::Current(); std::unique_ptr int_socket( rtc::AsyncUDPSocket::Create(pthMain->socketserver(), int_addr)); if (!int_socket) { - std::cerr << "Failed to create a UDP socket bound at" - << int_addr.ToString() << std::endl; + std::cerr << "Failed to create a UDP socket bound at" << int_addr.ToString() + << std::endl; return 1; } std::unique_ptr ext_socket( rtc::AsyncUDPSocket::Create(pthMain->socketserver(), ext_addr)); if (!ext_socket) { - std::cerr << "Failed to create a UDP socket bound at" - << ext_addr.ToString() << std::endl; + std::cerr << "Failed to create a UDP socket bound at" << ext_addr.ToString() + << std::endl; return 1; } diff --git a/examples/stunserver/stunserver_main.cc b/examples/stunserver/stunserver_main.cc index 8129e1226d..64d8b419a9 100644 --- a/examples/stunserver/stunserver_main.cc +++ b/examples/stunserver/stunserver_main.cc @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) { return 1; } - rtc::Thread *pthMain = rtc::Thread::Current(); + rtc::Thread* pthMain = rtc::Thread::Current(); rtc::AsyncUDPSocket* server_socket = rtc::AsyncUDPSocket::Create(pthMain->socketserver(), server_addr); diff --git a/examples/turnserver/turnserver_main.cc b/examples/turnserver/turnserver_main.cc index 9bee8518aa..edc0b699b4 100644 --- a/examples/turnserver/turnserver_main.cc +++ b/examples/turnserver/turnserver_main.cc @@ -21,10 +21,9 @@ static const char kSoftware[] = "libjingle TurnServer"; class TurnFileAuth : public cricket::TurnAuthInterface { public: - explicit TurnFileAuth(const std::string& path) : file_(path) { - file_.Load(); - } - virtual bool GetKey(const std::string& username, const std::string& realm, + explicit TurnFileAuth(const std::string& path) : file_(path) { file_.Load(); } + virtual bool GetKey(const std::string& username, + const std::string& realm, std::string* key) { // File is stored as lines of =. // Generate HA1 via "echo -n "::" | md5sum" @@ -37,6 +36,7 @@ class TurnFileAuth : public cricket::TurnAuthInterface { } return ret; } + private: rtc::OptionsFile file_; }; @@ -64,8 +64,8 @@ int main(int argc, char* argv[]) { rtc::AsyncUDPSocket* int_socket = rtc::AsyncUDPSocket::Create(main->socketserver(), int_addr); if (!int_socket) { - std::cerr << "Failed to create a UDP socket bound at" - << int_addr.ToString() << std::endl; + std::cerr << "Failed to create a UDP socket bound at" << int_addr.ToString() + << std::endl; return 1; } diff --git a/logging/rtc_event_log/mock/mock_rtc_event_log.cc b/logging/rtc_event_log/mock/mock_rtc_event_log.cc index 10c2b9677c..240a4f6693 100644 --- a/logging/rtc_event_log/mock/mock_rtc_event_log.cc +++ b/logging/rtc_event_log/mock/mock_rtc_event_log.cc @@ -16,4 +16,3 @@ MockRtcEventLog::MockRtcEventLog() = default; MockRtcEventLog::~MockRtcEventLog() = default; } // namespace webrtc - diff --git a/logging/rtc_event_log/rtc_event_log2rtp_dump.cc b/logging/rtc_event_log/rtc_event_log2rtp_dump.cc index bdb560a0dc..b62759b0d5 100644 --- a/logging/rtc_event_log/rtc_event_log2rtp_dump.cc +++ b/logging/rtc_event_log/rtc_event_log2rtp_dump.cc @@ -84,8 +84,8 @@ int main(int argc, char* argv[]) { " --help for usage.\n" "Example usage:\n" + program_name + " input.rel output.rtp\n"; - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 3) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 3) { std::cout << usage; if (FLAG_help) { rtc::FlagList::Print(nullptr, false); diff --git a/logging/rtc_event_log/rtc_event_log2stats.cc b/logging/rtc_event_log/rtc_event_log2stats.cc index 6b0c4c0222..928c829f49 100644 --- a/logging/rtc_event_log/rtc_event_log2stats.cc +++ b/logging/rtc_event_log/rtc_event_log2stats.cc @@ -189,8 +189,8 @@ int main(int argc, char* argv[]) { " --help for usage.\n" "Example usage:\n" + program_name + " input.rel\n"; - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 2) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 2) { std::cout << usage; if (FLAG_help) { rtc::FlagList::Print(nullptr, false); diff --git a/logging/rtc_event_log/rtc_event_log2text.cc b/logging/rtc_event_log/rtc_event_log2text.cc index 00092a9e3a..17f1207425 100644 --- a/logging/rtc_event_log/rtc_event_log2text.cc +++ b/logging/rtc_event_log/rtc_event_log2text.cc @@ -383,8 +383,8 @@ int main(int argc, char* argv[]) { " --help for usage.\n" "Example usage:\n" + program_name + " input.rel\n"; - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 2) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 2) { std::cout << usage; if (FLAG_help) { rtc::FlagList::Print(nullptr, false); @@ -492,8 +492,8 @@ int main(int argc, char* argv[]) { << parsed_header.extension.transmissionTimeOffset; } if (parsed_header.extension.hasAudioLevel) { - std::cout << "\tAudioLevel=" << - static_cast(parsed_header.extension.audioLevel); + std::cout << "\tAudioLevel=" + << static_cast(parsed_header.extension.audioLevel); } std::cout << std::endl; if (FLAG_print_full_packets) { diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index 030def131d..27bb2b26d6 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -221,10 +221,9 @@ std::pair ParseVarInt(std::istream& stream) { return std::make_pair(varint, false); } -void GetHeaderExtensions( - std::vector* header_extensions, - const RepeatedPtrField& - proto_header_extensions) { +void GetHeaderExtensions(std::vector* header_extensions, + const RepeatedPtrField& + proto_header_extensions) { header_extensions->clear(); for (auto& p : proto_header_extensions) { RTC_CHECK(p.has_name()); diff --git a/logging/rtc_event_log/rtc_event_log_unittest.cc b/logging/rtc_event_log/rtc_event_log_unittest.cc index 486a744be0..21f9cf3765 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -326,7 +326,7 @@ class RtcEventLogSession std::vector outgoing_rtcp_packets; std::vector playout_ssrcs; std::vector bwe_loss_updates; - std::vector > bwe_delay_updates; + std::vector> bwe_delay_updates; std::vector receiver_configs; std::vector sender_configs; std::vector event_types; diff --git a/logging/rtc_event_log/rtc_stream_config.cc b/logging/rtc_event_log/rtc_stream_config.cc index b43c6dd6f3..56c8c813ed 100644 --- a/logging/rtc_event_log/rtc_stream_config.cc +++ b/logging/rtc_event_log/rtc_stream_config.cc @@ -27,9 +27,9 @@ bool StreamConfig::operator==(const StreamConfig& other) const { StreamConfig::Codec::Codec(const std::string& payload_name, int payload_type, int rtx_payload_type) - : payload_name(payload_name), - payload_type(payload_type), - rtx_payload_type(rtx_payload_type) {} + : payload_name(payload_name), + payload_type(payload_type), + rtx_payload_type(rtx_payload_type) {} bool StreamConfig::Codec::operator==(const Codec& other) const { return payload_name == other.payload_name && diff --git a/media/base/adaptedvideotracksource.cc b/media/base/adaptedvideotracksource.cc index 84b39d878f..11952770a4 100644 --- a/media/base/adaptedvideotracksource.cc +++ b/media/base/adaptedvideotracksource.cc @@ -104,8 +104,8 @@ bool AdaptedVideoTrackSource::AdaptFrame(int width, } if (!video_adapter_.AdaptFrameResolution( - width, height, time_us * rtc::kNumNanosecsPerMicrosec, - crop_width, crop_height, out_width, out_height)) { + width, height, time_us * rtc::kNumNanosecsPerMicrosec, crop_width, + crop_height, out_width, out_height)) { broadcaster_.OnDiscardedFrame(); // VideoAdapter dropped the frame. return false; diff --git a/media/base/codec.cc b/media/base/codec.cc index e050c722d2..7c1d67778a 100644 --- a/media/base/codec.cc +++ b/media/base/codec.cc @@ -26,7 +26,7 @@ FeedbackParams::~FeedbackParams() = default; bool FeedbackParam::operator==(const FeedbackParam& other) const { return _stricmp(other.id().c_str(), id().c_str()) == 0 && - _stricmp(other.param().c_str(), param().c_str()) == 0; + _stricmp(other.param().c_str(), param().c_str()) == 0; } bool FeedbackParams::operator==(const FeedbackParams& other) const { @@ -118,7 +118,7 @@ void Codec::SetParam(const std::string& name, const std::string& value) { params[name] = value; } -void Codec::SetParam(const std::string& name, int value) { +void Codec::SetParam(const std::string& name, int value) { params[name] = rtc::ToString(value); } @@ -154,8 +154,7 @@ AudioCodec::AudioCodec(int id, size_t channels) : Codec(id, name, clockrate), bitrate(bitrate), channels(channels) {} -AudioCodec::AudioCodec() : Codec(), bitrate(0), channels(0) { -} +AudioCodec::AudioCodec() : Codec(), bitrate(0), channels(0) {} AudioCodec::AudioCodec(const AudioCodec& c) = default; AudioCodec::AudioCodec(AudioCodec&& c) = default; @@ -177,10 +176,10 @@ bool AudioCodec::Matches(const AudioCodec& codec) const { // Preference is ignored. // TODO(juberti): Treat a zero clockrate as 8000Hz, the RTP default clockrate. return Codec::Matches(codec) && - ((codec.clockrate == 0 /*&& clockrate == 8000*/) || + ((codec.clockrate == 0 /*&& clockrate == 8000*/) || clockrate == codec.clockrate) && - (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) && - ((codec.channels < 2 && channels < 2) || channels == codec.channels); + (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) && + ((codec.channels < 2 && channels < 2) || channels == codec.channels); } std::string AudioCodec::ToString() const { diff --git a/media/base/codec.h b/media/base/codec.h index 7bbb7db850..db133f6e27 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -29,13 +29,9 @@ class FeedbackParam { public: FeedbackParam() = default; FeedbackParam(const std::string& id, const std::string& param) - : id_(id), - param_(param) { - } + : id_(id), param_(param) {} explicit FeedbackParam(const std::string& id) - : id_(id), - param_(kParamValueEmpty) { - } + : id_(id), param_(kParamValueEmpty) {} bool operator==(const FeedbackParam& other) const; @@ -43,7 +39,7 @@ class FeedbackParam { const std::string& param() const { return param_; } private: - std::string id_; // e.g. "nack", "ccm" + std::string id_; // e.g. "nack", "ccm" std::string param_; // e.g. "", "rpsi", "fir" }; @@ -59,6 +55,7 @@ class FeedbackParams { void Intersect(const FeedbackParams& from); const std::vector& params() const { return params_; } + private: bool HasDuplicateEntries() const; @@ -102,9 +99,7 @@ struct Codec { bool operator==(const Codec& c) const; - bool operator!=(const Codec& c) const { - return !(*this == c); - } + bool operator!=(const Codec& c) const { return !(*this == c); } protected: // A Codec can't be created without a subclass. @@ -144,9 +139,7 @@ struct AudioCodec : public Codec { bool operator==(const AudioCodec& c) const; - bool operator!=(const AudioCodec& c) const { - return !(*this == c); - } + bool operator!=(const AudioCodec& c) const { return !(*this == c); } }; struct VideoCodec : public Codec { @@ -175,9 +168,7 @@ struct VideoCodec : public Codec { bool operator==(const VideoCodec& c) const; - bool operator!=(const VideoCodec& c) const { - return !(*this == c); - } + bool operator!=(const VideoCodec& c) const { return !(*this == c); } static VideoCodec CreateRtxCodec(int rtx_payload_type, int associated_payload_type); diff --git a/media/base/device.h b/media/base/device.h index f47293823f..7910c97400 100644 --- a/media/base/device.h +++ b/media/base/device.h @@ -20,12 +20,8 @@ namespace cricket { // Used to represent an audio or video capture or render device. struct Device { Device() {} - Device(const std::string& name, int id) - : name(name), - id(rtc::ToString(id)) { - } - Device(const std::string& name, const std::string& id) - : name(name), id(id) {} + Device(const std::string& name, int id) : name(name), id(rtc::ToString(id)) {} + Device(const std::string& name, const std::string& id) : name(name), id(id) {} std::string name; std::string id; diff --git a/media/base/fakemediaengine.h b/media/base/fakemediaengine.h index 50ef0a3502..34a9b7509b 100644 --- a/media/base/fakemediaengine.h +++ b/media/base/fakemediaengine.h @@ -42,7 +42,8 @@ class FakeVideoEngine; class FakeVoiceEngine; // A common helper class that handles sending and receiving RTP/RTCP packets. -template class RtpHelper : public Base { +template +class RtpHelper : public Base { public: RtpHelper() : sending_(false), @@ -217,9 +218,7 @@ template class RtpHelper : public Base { const RtcpParameters& send_rtcp_parameters() { return send_rtcp_parameters_; } const RtcpParameters& recv_rtcp_parameters() { return recv_rtcp_parameters_; } - bool ready_to_send() const { - return ready_to_send_; - } + bool ready_to_send() const { return ready_to_send_; } int transport_overhead_per_packet() const { return transport_overhead_per_packet_; @@ -270,9 +269,7 @@ template class RtpHelper : public Base { const rtc::PacketTime& packet_time) { rtcp_packets_.push_back(std::string(packet->data(), packet->size())); } - virtual void OnReadyToSend(bool ready) { - ready_to_send_ = ready; - } + virtual void OnReadyToSend(bool ready) { ready_to_send_ = ready; } virtual void OnNetworkRouteChanged(const std::string& transport_name, const rtc::NetworkRoute& network_route) { @@ -311,9 +308,7 @@ class FakeVoiceMediaChannel : public RtpHelper { public: struct DtmfInfo { DtmfInfo(uint32_t ssrc, int event_code, int duration) - : ssrc(ssrc), - event_code(event_code), - duration(duration) {} + : ssrc(ssrc), event_code(event_code), duration(duration) {} uint32_t ssrc; int event_code; int duration; @@ -392,9 +387,7 @@ class FakeVoiceMediaChannel : public RtpHelper { } return false; } - virtual bool InsertDtmf(uint32_t ssrc, - int event_code, - int duration) { + virtual bool InsertDtmf(uint32_t ssrc, int event_code, int duration) { dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration)); return true; } @@ -735,9 +728,7 @@ class FakeDataMediaChannel : public RtpHelper { // and FakeVideoEngine. class FakeBaseEngine { public: - FakeBaseEngine() - : options_changed_(false), - fail_create_channel_(false) {} + FakeBaseEngine() : options_changed_(false), fail_create_channel_(false) {} void set_fail_create_channel(bool fail) { fail_create_channel_ = fail; } RtpCapabilities GetCapabilities() const { return capabilities_; } @@ -875,8 +866,8 @@ class FakeVideoEngine : public FakeBaseEngine { friend class FakeMediaEngine; }; -class FakeMediaEngine : - public CompositeMediaEngine { +class FakeMediaEngine + : public CompositeMediaEngine { public: FakeMediaEngine() : CompositeMediaEngine(std::tuple<>(), diff --git a/media/base/fakenetworkinterface.h b/media/base/fakenetworkinterface.h index 3d98d1f917..98d9c469a5 100644 --- a/media/base/fakenetworkinterface.h +++ b/media/base/fakenetworkinterface.h @@ -37,8 +37,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, conf_(false), sendbuf_size_(-1), recvbuf_size_(-1), - dscp_(rtc::DSCP_NO_CHANGE) { - } + dscp_(rtc::DSCP_NO_CHANGE) {} void SetDestination(MediaChannel* dest) { dest_ = dest; } @@ -125,8 +124,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, rtp_packets_.push_back(*packet); if (conf_) { for (size_t i = 0; i < conf_sent_ssrcs_.size(); ++i) { - if (!SetRtpSsrc(packet->data(), packet->size(), - conf_sent_ssrcs_[i])) { + if (!SetRtpSsrc(packet->data(), packet->size(), conf_sent_ssrcs_[i])) { return false; } PostMessage(ST_RTP, *packet); @@ -148,8 +146,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, return true; } - virtual int SetOption(SocketType type, rtc::Socket::Option opt, - int option) { + virtual int SetOption(SocketType type, rtc::Socket::Option opt, int option) { if (opt == rtc::Socket::OPT_SNDBUF) { sendbuf_size_ = option; } else if (opt == rtc::Socket::OPT_RCVBUF) { @@ -166,15 +163,12 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, virtual void OnMessage(rtc::Message* msg) { rtc::TypedMessageData* msg_data = - static_cast*>( - msg->pdata); + static_cast*>(msg->pdata); if (dest_) { if (msg->message_id == ST_RTP) { - dest_->OnPacketReceived(&msg_data->data(), - rtc::CreatePacketTime(0)); + dest_->OnPacketReceived(&msg_data->data(), rtc::CreatePacketTime(0)); } else { - dest_->OnRtcpReceived(&msg_data->data(), - rtc::CreatePacketTime(0)); + dest_->OnRtcpReceived(&msg_data->data(), rtc::CreatePacketTime(0)); } } delete msg_data; diff --git a/media/base/fakertp.cc b/media/base/fakertp.cc index be1631b73f..fc9a058b87 100644 --- a/media/base/fakertp.cc +++ b/media/base/fakertp.cc @@ -13,9 +13,12 @@ #include "media/base/fakertp.h" #include "rtc_base/gunit.h" -void CompareHeaderExtensions(const char* packet1, size_t packet1_size, - const char* packet2, size_t packet2_size, - const std::vector encrypted_headers, bool expect_equal) { +void CompareHeaderExtensions(const char* packet1, + size_t packet1_size, + const char* packet2, + size_t packet2_size, + const std::vector encrypted_headers, + bool expect_equal) { // Sanity check: packets must be large enough to contain the RTP header and // extensions header. RTC_CHECK_GE(packet1_size, 12 + 4); @@ -36,7 +39,7 @@ void CompareHeaderExtensions(const char* packet1, size_t packet1_size, RTC_CHECK_GE(packet2_size, 12 + 4 + extension_words * 4); while (extension_data1 < extension_end1) { uint8_t id = (*extension_data1 & 0xf0) >> 4; - uint8_t len = (*extension_data1 & 0x0f) +1; + uint8_t len = (*extension_data1 & 0x0f) + 1; extension_data1++; extension_data2++; EXPECT_LE(extension_data1, extension_end1); @@ -48,8 +51,8 @@ void CompareHeaderExtensions(const char* packet1, size_t packet1_size, // The header extension doesn't get encrypted if the id is not in the // list of header extensions to encrypt. if (expect_equal || - std::find(encrypted_headers.begin(), encrypted_headers.end(), id) - == encrypted_headers.end()) { + std::find(encrypted_headers.begin(), encrypted_headers.end(), id) == + encrypted_headers.end()) { EXPECT_EQ(0, memcmp(extension_data1, extension_data2, len)); } else { EXPECT_NE(0, memcmp(extension_data1, extension_data2, len)); diff --git a/media/base/fakertp.h b/media/base/fakertp.h index 6786bab6d9..946f302b00 100644 --- a/media/base/fakertp.h +++ b/media/base/fakertp.h @@ -13,33 +13,28 @@ #ifndef MEDIA_BASE_FAKERTP_H_ #define MEDIA_BASE_FAKERTP_H_ +#include // size_t #include // A typical PCMU RTP packet. // PT=0, SN=1, TS=0, SSRC=1 // all data FF static const unsigned char kPcmuFrame[] = { - 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, }; static const int kHeaderExtensionIDs[] = {1, 4}; @@ -48,93 +43,81 @@ static const int kHeaderExtensionIDs[] = {1, 4}; // PT=0, SN=1, TS=0, SSRC=1 // all data FF static const unsigned char kPcmuFrameWithExtensions[] = { - 0x90, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - // RFC 5285, section 4.2. One-Byte Header. - 0xBE, 0xDE, - // Header extension length 6 * 32 bits. - 0x00, 0x06, - // 8 bytes header id 1. - 0x17, 0x41, 0x42, 0x73, 0xA4, 0x75, 0x26, 0x27, 0x48, - // 3 bytes header id 2. - 0x22, 0x00, 0x00, 0xC8, - // 1 byte header id 3. - 0x30, 0x8E, - // 7 bytes header id 4. - 0x46, 0x55, 0x99, 0x63, 0x86, 0xB3, 0x95, 0xFB, - // 1 byte header padding. - 0x00, - // Payload data. - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x90, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + // RFC 5285, section 4.2. One-Byte Header. + 0xBE, 0xDE, + // Header extension length 6 * 32 bits. + 0x00, 0x06, + // 8 bytes header id 1. + 0x17, 0x41, 0x42, 0x73, 0xA4, 0x75, 0x26, 0x27, 0x48, + // 3 bytes header id 2. + 0x22, 0x00, 0x00, 0xC8, + // 1 byte header id 3. + 0x30, 0x8E, + // 7 bytes header id 4. + 0x46, 0x55, 0x99, 0x63, 0x86, 0xB3, 0x95, 0xFB, + // 1 byte header padding. + 0x00, + // Payload data. + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, }; // A typical Receiver Report RTCP packet. // PT=RR, LN=1, SSRC=1 // send SSRC=2, all other fields 0 static const unsigned char kRtcpReport[] = { - 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // PT = 97, TS = 0, Seq = 1, SSRC = 2 // H264 - NRI = 1, Type = 1, bit stream = FF static const unsigned char kH264Packet[] = { - 0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x21, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x21, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, }; // PT= 101, SN=2, TS=3, SSRC = 4 static const unsigned char kDataPacket[] = { - 0x80, 0x65, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x80, 0x65, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, }; // This expects both packets to be based on kPcmuFrameWithExtensions. // Header extensions with an id in "encrypted_headers" are expected to be // different in the packets unless "expect_equal" is set to "true". -void CompareHeaderExtensions(const char* packet1, size_t packet1_size, - const char* packet2, size_t packet2_size, - const std::vector encrypted_headers, bool expect_equal); +void CompareHeaderExtensions(const char* packet1, + size_t packet1_size, + const char* packet2, + size_t packet2_size, + const std::vector encrypted_headers, + bool expect_equal); #endif // MEDIA_BASE_FAKERTP_H_ diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h index a9b586a052..ea8b1869ba 100644 --- a/media/base/mediachannel.h +++ b/media/base/mediachannel.h @@ -50,7 +50,7 @@ class Timing; namespace webrtc { class AudioSinkInterface; class VideoFrame; -} +} // namespace webrtc namespace cricket { @@ -76,16 +76,16 @@ static std::string ToStringIfSet(const char* key, template static std::string VectorToString(const std::vector& vals) { - std::ostringstream ost; - ost << "["; - for (size_t i = 0; i < vals.size(); ++i) { - if (i > 0) { - ost << ", "; - } - ost << vals[i].ToString(); + std::ostringstream ost; // no-presubmit-check TODO(webrtc:8982) + ost << "["; + for (size_t i = 0; i < vals.size(); ++i) { + if (i > 0) { + ost << ", "; } - ost << "]"; - return ost.str(); + ost << vals[i].ToString(); + } + ost << "]"; + return ost.str(); } // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. @@ -170,7 +170,8 @@ class MediaChannel : public sigslot::has_slots<> { const rtc::PacketOptions& options) = 0; virtual bool SendRtcp(rtc::CopyOnWriteBuffer* packet, const rtc::PacketOptions& options) = 0; - virtual int SetOption(SocketType type, rtc::Socket::Option opt, + virtual int SetOption(SocketType type, + rtc::Socket::Option opt, int option) = 0; virtual ~NetworkInterface() {} }; @@ -240,13 +241,9 @@ class MediaChannel : public sigslot::has_slots<> { // This method sets DSCP |value| on both RTP and RTCP channels. int SetDscp(rtc::DiffServCodePoint value) { int ret; - ret = SetOption(NetworkInterface::ST_RTP, - rtc::Socket::OPT_DSCP, - value); + ret = SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value); if (ret == 0) { - ret = SetOption(NetworkInterface::ST_RTCP, - rtc::Socket::OPT_DSCP, - value); + ret = SetOption(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP, value); } return ret; } @@ -290,9 +287,7 @@ struct SsrcReceiverInfo { struct MediaSenderInfo { MediaSenderInfo(); ~MediaSenderInfo(); - void add_ssrc(const SsrcSenderInfo& stat) { - local_stats.push_back(stat); - } + void add_ssrc(const SsrcSenderInfo& stat) { local_stats.push_back(stat); } // Temporary utility function for call sites that only provide SSRC. // As more info is added into SsrcSenderInfo, this function should go away. void add_ssrc(uint32_t ssrc) { @@ -337,9 +332,7 @@ struct MediaSenderInfo { struct MediaReceiverInfo { MediaReceiverInfo(); ~MediaReceiverInfo(); - void add_ssrc(const SsrcReceiverInfo& stat) { - local_stats.push_back(stat); - } + void add_ssrc(const SsrcReceiverInfo& stat) { local_stats.push_back(stat); } // Temporary utility function for call sites that only provide SSRC. // As more info is added into SsrcSenderInfo, this function should go away. void add_ssrc(uint32_t ssrc) { @@ -655,8 +648,7 @@ struct AudioSendParameters : RtpSendParameters { std::map ToStringMap() const override; }; -struct AudioRecvParameters : RtpParameters { -}; +struct AudioRecvParameters : RtpParameters {}; class VoiceMediaChannel : public MediaChannel { public: @@ -727,8 +719,7 @@ struct VideoSendParameters : RtpSendParameters { // TODO(deadbeef): Rename to VideoReceiverParameters, since they're intended to // encapsulate all the parameters needed for a video RtpReceiver. -struct VideoRecvParameters : RtpParameters { -}; +struct VideoRecvParameters : RtpParameters {}; class VideoMediaChannel : public MediaChannel { public: @@ -836,11 +827,9 @@ struct SendDataParams { enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; -struct DataSendParameters : RtpSendParameters { -}; +struct DataSendParameters : RtpSendParameters {}; -struct DataRecvParameters : RtpParameters { -}; +struct DataRecvParameters : RtpParameters {}; class DataMediaChannel : public MediaChannel { public: @@ -860,14 +849,12 @@ class DataMediaChannel : public MediaChannel { void OnNetworkRouteChanged(const std::string& transport_name, const rtc::NetworkRoute& network_route) override {} - virtual bool SendData( - const SendDataParams& params, - const rtc::CopyOnWriteBuffer& payload, - SendDataResult* result = NULL) = 0; + virtual bool SendData(const SendDataParams& params, + const rtc::CopyOnWriteBuffer& payload, + SendDataResult* result = NULL) = 0; // Signals when data is received (params, data, len) - sigslot::signal3 SignalDataReceived; + sigslot::signal3 + SignalDataReceived; // Signal when the media channel is ready to send the stream. Arguments are: // writable(bool) sigslot::signal1 SignalReadyToSend; diff --git a/media/base/mediaconstants.cc b/media/base/mediaconstants.cc index de21d04a25..522adf3c69 100644 --- a/media/base/mediaconstants.cc +++ b/media/base/mediaconstants.cc @@ -39,12 +39,12 @@ const char kCodecParamAssociatedCodecName[] = "acn"; const char kOpusCodecName[] = "opus"; const char kIsacCodecName[] = "ISAC"; -const char kL16CodecName[] = "L16"; +const char kL16CodecName[] = "L16"; const char kG722CodecName[] = "G722"; const char kIlbcCodecName[] = "ILBC"; const char kPcmuCodecName[] = "PCMU"; const char kPcmaCodecName[] = "PCMA"; -const char kCnCodecName[] = "CN"; +const char kCnCodecName[] = "CN"; const char kDtmfCodecName[] = "telephone-event"; // draft-spittka-payload-rtp-opus-03.txt diff --git a/media/base/mediaengine.h b/media/base/mediaengine.h index b83217413f..57979c2757 100644 --- a/media/base/mediaengine.h +++ b/media/base/mediaengine.h @@ -34,7 +34,7 @@ class AudioDeviceModule; class AudioMixer; class AudioProcessing; class Call; -} +} // namespace webrtc namespace cricket { @@ -85,7 +85,6 @@ class MediaEngineInterface { virtual void StopAecDump() = 0; }; - // CompositeMediaEngine constructs a MediaEngine from separate // voice and video engine classes. template diff --git a/media/base/rtpdataengine.cc b/media/base/rtpdataengine.cc index 6e2155b3b2..fc2b73141e 100644 --- a/media/base/rtpdataengine.cc +++ b/media/base/rtpdataengine.cc @@ -28,9 +28,7 @@ namespace cricket { // We want to avoid IP fragmentation. static const size_t kDataMaxRtpPacketLen = 1200U; // We reserve space after the RTP header for future wiggle room. -static const unsigned char kReservedSpace[] = { - 0x00, 0x00, 0x00, 0x00 -}; +static const unsigned char kReservedSpace[] = {0x00, 0x00, 0x00, 0x00}; // Amount of overhead SRTP may take. We need to leave room in the // buffer for it, otherwise SRTP will fail later. If SRTP ever uses @@ -42,8 +40,7 @@ RtpDataEngine::RtpDataEngine() { DataCodec(kGoogleRtpDataCodecPlType, kGoogleRtpDataCodecName)); } -DataMediaChannel* RtpDataEngine::CreateChannel( - const MediaConfig& config) { +DataMediaChannel* RtpDataEngine::CreateChannel(const MediaConfig& config) { return new RtpDataMediaChannel(config); } @@ -67,18 +64,16 @@ void RtpDataMediaChannel::Construct() { send_limiter_.reset(new rtc::DataRateLimiter(kDataMaxBandwidth / 8, 1.0)); } - RtpDataMediaChannel::~RtpDataMediaChannel() { std::map::const_iterator iter; for (iter = rtp_clock_by_send_ssrc_.begin(); - iter != rtp_clock_by_send_ssrc_.end(); - ++iter) { + iter != rtp_clock_by_send_ssrc_.end(); ++iter) { delete iter->second; } } void RTC_NO_SANITIZE("float-cast-overflow") // bugs.webrtc.org/8204 -RtpClock::Tick(double now, int* seq_num, uint32_t* timestamp) { + RtpClock::Tick(double now, int* seq_num, uint32_t* timestamp) { *seq_num = ++last_seq_num_; *timestamp = timestamp_offset_ + static_cast(now * clockrate_); // UBSan: 5.92374e+10 is outside the range of representable values of type @@ -155,9 +150,9 @@ bool RtpDataMediaChannel::AddSendStream(const StreamParams& stream) { send_streams_.push_back(stream); // TODO(pthatcher): This should be per-stream, not per-ssrc. // And we should probably allow more than one per stream. - rtp_clock_by_send_ssrc_[stream.first_ssrc()] = new RtpClock( - kDataCodecClockrate, - rtc::CreateRandomNonZeroId(), rtc::CreateRandomNonZeroId()); + rtp_clock_by_send_ssrc_[stream.first_ssrc()] = + new RtpClock(kDataCodecClockrate, rtc::CreateRandomNonZeroId(), + rtc::CreateRandomNonZeroId()); RTC_LOG(LS_INFO) << "Added data send stream '" << stream.id << "' with ssrc=" << stream.first_ssrc(); @@ -198,8 +193,8 @@ bool RtpDataMediaChannel::RemoveRecvStream(uint32_t ssrc) { return true; } -void RtpDataMediaChannel::OnPacketReceived( - rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) { +void RtpDataMediaChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet, + const rtc::PacketTime& packet_time) { RtpHeader header; if (!GetRtpHeader(packet->cdata(), packet->size(), &header)) { return; @@ -254,10 +249,9 @@ bool RtpDataMediaChannel::SetMaxSendBandwidth(int bps) { return true; } -bool RtpDataMediaChannel::SendData( - const SendDataParams& params, - const rtc::CopyOnWriteBuffer& payload, - SendDataResult* result) { +bool RtpDataMediaChannel::SendData(const SendDataParams& params, + const rtc::CopyOnWriteBuffer& payload, + SendDataResult* result) { if (result) { // If we return true, we'll set this to SDR_SUCCESS. *result = SDR_ERROR; @@ -310,8 +304,8 @@ bool RtpDataMediaChannel::SendData( RtpHeader header; header.payload_type = found_codec->id; header.ssrc = params.ssrc; - rtp_clock_by_send_ssrc_[header.ssrc]->Tick( - now, &header.seq_num, &header.timestamp); + rtp_clock_by_send_ssrc_[header.ssrc]->Tick(now, &header.seq_num, + &header.timestamp); rtc::CopyOnWriteBuffer packet(kMinRtpPacketLen, packet_len); if (!SetRtpHeader(packet.data(), packet.size(), header)) { diff --git a/media/base/rtpdataengine.h b/media/base/rtpdataengine.h index 52d43253dc..966d0c8151 100644 --- a/media/base/rtpdataengine.h +++ b/media/base/rtpdataengine.h @@ -34,9 +34,7 @@ class RtpDataEngine : public DataEngineInterface { virtual DataMediaChannel* CreateChannel(const MediaConfig& config); - virtual const std::vector& data_codecs() { - return data_codecs_; - } + virtual const std::vector& data_codecs() { return data_codecs_; } private: std::vector data_codecs_; @@ -88,10 +86,9 @@ class RtpDataMediaChannel : public DataMediaChannel { virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) {} virtual void OnReadyToSend(bool ready) {} - virtual bool SendData( - const SendDataParams& params, - const rtc::CopyOnWriteBuffer& payload, - SendDataResult* result); + virtual bool SendData(const SendDataParams& params, + const rtc::CopyOnWriteBuffer& payload, + SendDataResult* result); virtual rtc::DiffServCodePoint PreferredDscp() const; private: diff --git a/media/base/rtpdataengine_unittest.cc b/media/base/rtpdataengine_unittest.cc index a05c3de264..c15c55f5e6 100644 --- a/media/base/rtpdataengine_unittest.cc +++ b/media/base/rtpdataengine_unittest.cc @@ -24,9 +24,9 @@ class FakeDataReceiver : public sigslot::has_slots<> { public: FakeDataReceiver() : has_received_data_(false) {} - void OnDataReceived( - const cricket::ReceiveDataParams& params, - const char* data, size_t len) { + void OnDataReceived(const cricket::ReceiveDataParams& params, + const char* data, + size_t len) { has_received_data_ = true; last_received_data_ = std::string(data, len); last_received_data_len_ = len; @@ -74,34 +74,24 @@ class RtpDataMediaChannelTest : public testing::Test { cricket::RtpDataMediaChannel* channel = static_cast(dme->CreateChannel(config)); channel->SetInterface(iface_.get()); - channel->SignalDataReceived.connect( - receiver_.get(), &FakeDataReceiver::OnDataReceived); + channel->SignalDataReceived.connect(receiver_.get(), + &FakeDataReceiver::OnDataReceived); return channel; } - FakeDataReceiver* receiver() { - return receiver_.get(); - } + FakeDataReceiver* receiver() { return receiver_.get(); } - bool HasReceivedData() { - return receiver_->has_received_data(); - } + bool HasReceivedData() { return receiver_->has_received_data(); } - std::string GetReceivedData() { - return receiver_->last_received_data(); - } + std::string GetReceivedData() { return receiver_->last_received_data(); } - size_t GetReceivedDataLen() { - return receiver_->last_received_data_len(); - } + size_t GetReceivedDataLen() { return receiver_->last_received_data_len(); } cricket::ReceiveDataParams GetReceivedDataParams() { return receiver_->last_received_data_params(); } - bool HasSentData(int count) { - return (iface_->NumRtpPackets() > count); - } + bool HasSentData(int count) { return (iface_->NumRtpPackets() > count); } std::string GetSentData(int index) { // Assume RTP header of length 12 @@ -202,8 +192,7 @@ TEST_F(RtpDataMediaChannelTest, SendData) { unsigned char data[] = "food"; rtc::CopyOnWriteBuffer payload(data, 4); unsigned char padded_data[] = { - 0x00, 0x00, 0x00, 0x00, - 'f', 'o', 'o', 'd', + 0x00, 0x00, 0x00, 0x00, 'f', 'o', 'o', 'd', }; cricket::SendDataResult result; @@ -246,8 +235,7 @@ TEST_F(RtpDataMediaChannelTest, SendData) { EXPECT_EQ(cricket::SDR_SUCCESS, result); ASSERT_TRUE(HasSentData(0)); EXPECT_EQ(sizeof(padded_data), GetSentData(0).length()); - EXPECT_EQ(0, memcmp( - padded_data, GetSentData(0).data(), sizeof(padded_data))); + EXPECT_EQ(0, memcmp(padded_data, GetSentData(0).data(), sizeof(padded_data))); cricket::RtpHeader header0 = GetSentDataHeader(0); EXPECT_NE(0, header0.seq_num); EXPECT_NE(0U, header0.timestamp); @@ -260,8 +248,7 @@ TEST_F(RtpDataMediaChannelTest, SendData) { EXPECT_TRUE(dmc->SendData(params, payload, &result)); ASSERT_TRUE(HasSentData(1)); EXPECT_EQ(sizeof(padded_data), GetSentData(1).length()); - EXPECT_EQ(0, memcmp( - padded_data, GetSentData(1).data(), sizeof(padded_data))); + EXPECT_EQ(0, memcmp(padded_data, GetSentData(1).data(), sizeof(padded_data))); cricket::RtpHeader header1 = GetSentDataHeader(1); EXPECT_EQ(header1.ssrc, 42U); EXPECT_EQ(header1.payload_type, 103); @@ -322,11 +309,9 @@ TEST_F(RtpDataMediaChannelTest, SendDataRate) { TEST_F(RtpDataMediaChannelTest, ReceiveData) { // PT= 103, SN=2, TS=3, SSRC = 4, data = "abcde" - unsigned char data[] = { - 0x80, 0x67, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2A, - 0x00, 0x00, 0x00, 0x00, - 'a', 'b', 'c', 'd', 'e' - }; + unsigned char data[] = {0x80, 0x67, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, + 0x00, 0x00, 'a', 'b', 'c', 'd', 'e'}; rtc::CopyOnWriteBuffer packet(data, sizeof(data)); std::unique_ptr dmc(CreateChannel()); @@ -364,9 +349,7 @@ TEST_F(RtpDataMediaChannelTest, ReceiveData) { } TEST_F(RtpDataMediaChannelTest, InvalidRtpPackets) { - unsigned char data[] = { - 0x80, 0x65, 0x00, 0x02 - }; + unsigned char data[] = {0x80, 0x65, 0x00, 0x02}; rtc::CopyOnWriteBuffer packet(data, sizeof(data)); std::unique_ptr dmc(CreateChannel()); diff --git a/media/base/rtputils.cc b/media/base/rtputils.cc index 96828052f3..ee34cb101e 100644 --- a/media/base/rtputils.cc +++ b/media/base/rtputils.cc @@ -35,9 +35,8 @@ namespace { // Fake auth tag written by the sender when external authentication is enabled. // HMAC in packet will be compared against this value before updating packet // with actual HMAC value. -static const uint8_t kFakeAuthTag[10] = { - 0xba, 0xdd, 0xba, 0xdd, 0xba, 0xdd, 0xba, 0xdd, 0xba, 0xdd -}; +static const uint8_t kFakeAuthTag[10] = {0xba, 0xdd, 0xba, 0xdd, 0xba, + 0xdd, 0xba, 0xdd, 0xba, 0xdd}; void UpdateAbsSendTimeExtensionValue(uint8_t* extension_data, size_t length, @@ -99,10 +98,10 @@ void UpdateRtpAuthTag(uint8_t* rtp, size_t auth_required_length = length - tag_length + kRocLength; uint8_t output[64]; - size_t result = rtc::ComputeHmac( - rtc::DIGEST_SHA_1, &packet_time_params.srtp_auth_key[0], - packet_time_params.srtp_auth_key.size(), rtp, - auth_required_length, output, sizeof(output)); + size_t result = + rtc::ComputeHmac(rtc::DIGEST_SHA_1, &packet_time_params.srtp_auth_key[0], + packet_time_params.srtp_auth_key.size(), rtp, + auth_required_length, output, sizeof(output)); if (result < tag_length) { RTC_NOTREACHED(); @@ -205,18 +204,21 @@ bool GetRtpSsrc(const void* data, size_t len, uint32_t* value) { } bool GetRtpHeaderLen(const void* data, size_t len, size_t* value) { - if (!data || len < kMinRtpPacketLen || !value) return false; + if (!data || len < kMinRtpPacketLen || !value) + return false; const uint8_t* header = static_cast(data); // Get base header size + length of CSRCs (not counting extension yet). size_t header_size = kMinRtpPacketLen + (header[0] & 0xF) * sizeof(uint32_t); - if (len < header_size) return false; + if (len < header_size) + return false; // If there's an extension, read and add in the extension size. if (header[0] & 0x10) { if (len < header_size + sizeof(uint32_t)) return false; header_size += ((rtc::GetBE16(header + header_size + 2) + 1) * sizeof(uint32_t)); - if (len < header_size) return false; + if (len < header_size) + return false; } *value = header_size; return true; @@ -241,11 +243,14 @@ bool GetRtcpType(const void* data, size_t len, int* value) { // to send non-compound packets only to feedback messages. bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value) { // Packet should be at least of 8 bytes, to get SSRC from a RTCP packet. - if (!data || len < kMinRtcpPacketLen + 4 || !value) return false; + if (!data || len < kMinRtcpPacketLen + 4 || !value) + return false; int pl_type; - if (!GetRtcpType(data, len, &pl_type)) return false; + if (!GetRtcpType(data, len, &pl_type)) + return false; // SDES packet parsing is not supported. - if (pl_type == kRtcpTypeSDES) return false; + if (pl_type == kRtcpTypeSDES) + return false; *value = rtc::GetBE32(static_cast(data) + 4); return true; } @@ -256,8 +261,8 @@ bool SetRtpSsrc(void* data, size_t len, uint32_t value) { // Assumes version 2, no padding, no extensions, no csrcs. bool SetRtpHeader(void* data, size_t len, const RtpHeader& header) { - if (!IsValidRtpPayloadType(header.payload_type) || - header.seq_num < 0 || header.seq_num > static_cast(UINT16_MAX)) { + if (!IsValidRtpPayloadType(header.payload_type) || header.seq_num < 0 || + header.seq_num > static_cast(UINT16_MAX)) { return false; } return (SetUint8(data, kRtpFlagsOffset, kRtpVersion << 6) && diff --git a/media/base/rtputils.h b/media/base/rtputils.h index 5258c0be26..0fd9a59816 100644 --- a/media/base/rtputils.h +++ b/media/base/rtputils.h @@ -31,13 +31,13 @@ struct RtpHeader { }; enum RtcpTypes { - kRtcpTypeSR = 200, // Sender report payload type. - kRtcpTypeRR = 201, // Receiver report payload type. - kRtcpTypeSDES = 202, // SDES payload type. - kRtcpTypeBye = 203, // BYE payload type. - kRtcpTypeApp = 204, // APP payload type. - kRtcpTypeRTPFB = 205, // Transport layer Feedback message payload type. - kRtcpTypePSFB = 206, // Payload-specific Feedback message payload type. + kRtcpTypeSR = 200, // Sender report payload type. + kRtcpTypeRR = 201, // Receiver report payload type. + kRtcpTypeSDES = 202, // SDES payload type. + kRtcpTypeBye = 203, // BYE payload type. + kRtcpTypeApp = 204, // APP payload type. + kRtcpTypeRTPFB = 205, // Transport layer Feedback message payload type. + kRtcpTypePSFB = 206, // Payload-specific Feedback message payload type. }; bool GetRtpPayloadType(const void* data, size_t len, int* value); @@ -85,7 +85,6 @@ bool ApplyPacketOptions(uint8_t* data, const rtc::PacketTimeUpdateParams& packet_time_params, uint64_t time_us); - } // namespace cricket #endif // MEDIA_BASE_RTPUTILS_H_ diff --git a/media/base/rtputils_unittest.cc b/media/base/rtputils_unittest.cc index a71eac7a07..08b4d4f4bd 100644 --- a/media/base/rtputils_unittest.cc +++ b/media/base/rtputils_unittest.cc @@ -10,78 +10,68 @@ #include -#include "media/base/rtputils.h" #include "media/base/fakertp.h" +#include "media/base/rtputils.h" #include "rtc_base/asyncpacketsocket.h" #include "rtc_base/gunit.h" namespace cricket { static const uint8_t kRtpPacketWithMarker[] = { - 0x80, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 -}; + 0x80, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; // 3 CSRCs (0x01020304, 0x12345678, 0xAABBCCDD) // Extension (0xBEDE, 0x1122334455667788) static const uint8_t kRtpPacketWithMarkerAndCsrcAndExtension[] = { 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, - 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 -}; -static const uint8_t kInvalidPacket[] = { 0x80, 0x00 }; + 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; +static const uint8_t kInvalidPacket[] = {0x80, 0x00}; static const uint8_t kInvalidPacketWithCsrc[] = { 0x83, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC -}; + 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC}; static const uint8_t kInvalidPacketWithCsrcAndExtension1[] = { - 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, - 0xBE, 0xDE, 0x00 -}; + 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, + 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, 0xBE, 0xDE, 0x00}; static const uint8_t kInvalidPacketWithCsrcAndExtension2[] = { 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, - 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 -}; + 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // PT = 206, FMT = 1, Sender SSRC = 0x1111, Media SSRC = 0x1111 // No FCI information is needed for PLI. static const uint8_t kNonCompoundRtcpPliFeedbackPacket[] = { - 0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11 -}; + 0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11}; // Packet has only mandatory fixed RTCP header // PT = 204, SSRC = 0x1111 -static const uint8_t kNonCompoundRtcpAppPacket[] = { - 0x81, 0xCC, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11 -}; +static const uint8_t kNonCompoundRtcpAppPacket[] = {0x81, 0xCC, 0x00, 0x0C, + 0x00, 0x00, 0x11, 0x11}; // PT = 202, Source count = 0 -static const uint8_t kNonCompoundRtcpSDESPacket[] = { - 0x80, 0xCA, 0x00, 0x00 -}; +static const uint8_t kNonCompoundRtcpSDESPacket[] = {0x80, 0xCA, 0x00, 0x00}; -static uint8_t kFakeTag[4] = { 0xba, 0xdd, 0xba, 0xdd }; +static uint8_t kFakeTag[4] = {0xba, 0xdd, 0xba, 0xdd}; static uint8_t kTestKey[] = "12345678901234567890"; -static uint8_t kTestAstValue[3] = { 0xaa, 0xbb, 0xcc }; +static uint8_t kTestAstValue[3] = {0xaa, 0xbb, 0xcc}; // Valid rtp Message with 2 byte header extension. static uint8_t kRtpMsgWith2ByteExtnHeader[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xBB, 0xCC, 0XDD, // SSRC 0x10, 0x00, 0x00, 0x01, // 2 Byte header extension 0x01, 0x00, 0x00, 0x00 + // clang-format on }; // RTP packet with single byte extension header of length 4 bytes. // Extension id = 3 and length = 3 static uint8_t kRtpMsgWithAbsSendTimeExtension[] = { - 0x90, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xBE, 0xDE, 0x00, 0x02, - 0x22, 0x00, 0x02, 0x1c, - 0x32, 0xaa, 0xbb, 0xcc, + 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBE, 0xDE, 0x00, 0x02, 0x22, 0x00, 0x02, 0x1c, 0x32, 0xaa, 0xbb, 0xcc, }; // Index of AbsSendTimeExtn data in message |kRtpMsgWithAbsSendTimeExtension|. @@ -123,11 +113,10 @@ TEST(RtpUtilsTest, GetRtp) { } TEST(RtpUtilsTest, SetRtpHeader) { - uint8_t packet[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + uint8_t packet[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - RtpHeader header = { 9, 1111, 2222u, 3333u }; + RtpHeader header = {9, 1111, 2222u, 3333u}; EXPECT_TRUE(SetRtpHeader(packet, sizeof(packet), header)); // Bits: 10 0 0 0000 @@ -172,33 +161,31 @@ TEST(RtpUtilsTest, GetRtcp) { uint32_t ssrc; EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpPliFeedbackPacket, - sizeof(kNonCompoundRtcpPliFeedbackPacket), - &ssrc)); + sizeof(kNonCompoundRtcpPliFeedbackPacket), &ssrc)); EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpAppPacket, - sizeof(kNonCompoundRtcpAppPacket), - &ssrc)); + sizeof(kNonCompoundRtcpAppPacket), &ssrc)); EXPECT_FALSE(GetRtcpSsrc(kNonCompoundRtcpSDESPacket, - sizeof(kNonCompoundRtcpSDESPacket), - &ssrc)); + sizeof(kNonCompoundRtcpSDESPacket), &ssrc)); } // Invalid RTP packets. TEST(RtpUtilsTest, InvalidRtpHeader) { // Rtp message with invalid length. const uint8_t kRtpMsgWithInvalidLength[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xBB, 0xCC, 0XDD, // SSRC 0xDD, 0xCC, 0xBB, 0xAA, // Only 1 CSRC, but CC count is 4. + // clang-format on }; EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidLength, sizeof(kRtpMsgWithInvalidLength), nullptr)); // Rtp message with single byte header extension, invalid extension length. const uint8_t kRtpMsgWithInvalidExtnLength[] = { - 0x90, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00 + 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00 }; EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidExtnLength, sizeof(kRtpMsgWithInvalidExtnLength), @@ -232,6 +219,8 @@ TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) { // A valid STUN indication message with a valid RTP header in data attribute // payload field and no extension bit set. uint8_t message_without_extension[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x00, 0x16, 0x00, 0x18, // length of 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -243,6 +232,7 @@ TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) { 0x80, 0x00, 0x00, 0x00, // RTP packet. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // clang-format on }; EXPECT_TRUE(UpdateRtpAbsSendTimeExtension( message_without_extension, sizeof(message_without_extension), 3, 0)); @@ -250,6 +240,8 @@ TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) { // A valid STUN indication message with a valid RTP header and a extension // header. uint8_t message[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x00, 0x16, 0x00, 0x24, // length of 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -261,6 +253,7 @@ TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) { 0x90, 0x00, 0x00, 0x00, // RTP packet. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE, 0x00, 0x02, 0x22, 0xaa, 0xbb, 0xcc, 0x32, 0xaa, 0xbb, 0xcc, + // clang-format on }; EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message, sizeof(message), 3, 0)); } @@ -349,5 +342,4 @@ TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParamsAndAbsSendTime) { sizeof(kExpectedTimestamp))); } - } // namespace cricket diff --git a/media/base/streamparams.cc b/media/base/streamparams.cc index 4c191d5105..154baf6947 100644 --- a/media/base/streamparams.cc +++ b/media/base/streamparams.cc @@ -22,7 +22,7 @@ namespace { void AddStream(std::vector* streams, const StreamParams& stream) { streams->push_back(stream); } -} +} // namespace const char kFecSsrcGroupSemantics[] = "FEC"; const char kFecFrSsrcGroupSemantics[] = "FEC-FR"; @@ -41,18 +41,18 @@ bool GetStream(const StreamParamsVec& streams, MediaStreams::MediaStreams() = default; MediaStreams::~MediaStreams() = default; -bool MediaStreams::GetAudioStream( - const StreamSelector& selector, StreamParams* stream) { +bool MediaStreams::GetAudioStream(const StreamSelector& selector, + StreamParams* stream) { return GetStream(audio_, selector, stream); } -bool MediaStreams::GetVideoStream( - const StreamSelector& selector, StreamParams* stream) { +bool MediaStreams::GetVideoStream(const StreamSelector& selector, + StreamParams* stream) { return GetStream(video_, selector, stream); } -bool MediaStreams::GetDataStream( - const StreamSelector& selector, StreamParams* stream) { +bool MediaStreams::GetDataStream(const StreamSelector& selector, + StreamParams* stream) { return GetStream(data_, selector, stream); } @@ -74,18 +74,15 @@ void MediaStreams::AddDataStream(const StreamParams& stream) { AddStream(&data_, stream); } -bool MediaStreams::RemoveAudioStream( - const StreamSelector& selector) { +bool MediaStreams::RemoveAudioStream(const StreamSelector& selector) { return RemoveStream(&audio_, selector); } -bool MediaStreams::RemoveVideoStream( - const StreamSelector& selector) { +bool MediaStreams::RemoveVideoStream(const StreamSelector& selector) { return RemoveStream(&video_, selector); } -bool MediaStreams::RemoveDataStream( - const StreamSelector& selector) { +bool MediaStreams::RemoveDataStream(const StreamSelector& selector) { return RemoveStream(&data_, selector); } @@ -212,9 +209,8 @@ bool StreamParams::GetSecondarySsrc(const std::string& semantics, uint32_t* secondary_ssrc) const { for (std::vector::const_iterator it = ssrc_groups.begin(); it != ssrc_groups.end(); ++it) { - if (it->has_semantics(semantics) && - it->ssrcs.size() >= 2 && - it->ssrcs[0] == primary_ssrc) { + if (it->has_semantics(semantics) && it->ssrcs.size() >= 2 && + it->ssrcs[0] == primary_ssrc) { *secondary_ssrc = it->ssrcs[1]; return true; } diff --git a/media/base/streamparams.h b/media/base/streamparams.h index 910d46e1df..488b61d040 100644 --- a/media/base/streamparams.h +++ b/media/base/streamparams.h @@ -53,15 +53,13 @@ struct SsrcGroup { bool operator==(const SsrcGroup& other) const { return (semantics == other.semantics && ssrcs == other.ssrcs); } - bool operator!=(const SsrcGroup &other) const { - return !(*this == other); - } + bool operator!=(const SsrcGroup& other) const { return !(*this == other); } bool has_semantics(const std::string& semantics) const; std::string ToString() const; - std::string semantics; // e.g FIX, FEC, SIM. + std::string semantics; // e.g FIX, FEC, SIM. std::vector ssrcs; // SSRCs of this type. }; @@ -88,9 +86,7 @@ struct StreamParams { ssrcs == other.ssrcs && ssrc_groups == other.ssrc_groups && cname == other.cname && stream_ids_ == other.stream_ids_); } - bool operator!=(const StreamParams &other) const { - return !(*this == other); - } + bool operator!=(const StreamParams& other) const { return !(*this == other); } uint32_t first_ssrc() const { if (ssrcs.empty()) { @@ -99,16 +95,12 @@ struct StreamParams { return ssrcs[0]; } - bool has_ssrcs() const { - return !ssrcs.empty(); - } + bool has_ssrcs() const { return !ssrcs.empty(); } bool has_ssrc(uint32_t ssrc) const { return std::find(ssrcs.begin(), ssrcs.end(), ssrc) != ssrcs.end(); } void add_ssrc(uint32_t ssrc) { ssrcs.push_back(ssrc); } - bool has_ssrc_groups() const { - return !ssrc_groups.empty(); - } + bool has_ssrc_groups() const { return !ssrc_groups.empty(); } bool has_ssrc_group(const std::string& semantics) const { return (get_ssrc_group(semantics) != NULL); } @@ -179,7 +171,7 @@ struct StreamParams { // signaled with a=msid lines. std::vector ssrcs; // All SSRCs for this source std::vector ssrc_groups; // e.g. FID, FEC, SIM - std::string cname; // RTCP CNAME + std::string cname; // RTCP CNAME private: bool AddSecondarySsrc(const std::string& semantics, @@ -199,12 +191,8 @@ struct StreamParams { struct StreamSelector { explicit StreamSelector(uint32_t ssrc) : ssrc(ssrc) {} - StreamSelector(const std::string& groupid, - const std::string& streamid) : - ssrc(0), - groupid(groupid), - streamid(streamid) { - } + StreamSelector(const std::string& groupid, const std::string& streamid) + : ssrc(0), groupid(groupid), streamid(streamid) {} explicit StreamSelector(const std::string& streamid) : ssrc(0), streamid(streamid) {} @@ -248,12 +236,9 @@ struct MediaStreams { const std::vector& data() const { return data_; } // Gets a stream, returning true if found. - bool GetAudioStream( - const StreamSelector& selector, StreamParams* stream); - bool GetVideoStream( - const StreamSelector& selector, StreamParams* stream); - bool GetDataStream( - const StreamSelector& selector, StreamParams* stream); + bool GetAudioStream(const StreamSelector& selector, StreamParams* stream); + bool GetVideoStream(const StreamSelector& selector, StreamParams* stream); + bool GetDataStream(const StreamSelector& selector, StreamParams* stream); // Adds a stream. void AddAudioStream(const StreamParams& stream); void AddVideoStream(const StreamParams& stream); @@ -293,8 +278,8 @@ inline bool HasStreamWithNoSsrcs(const StreamParamsVec& streams) { inline const StreamParams* GetStreamBySsrc(const StreamParamsVec& streams, uint32_t ssrc) { - return GetStream(streams, - [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); + return GetStream( + streams, [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); } inline const StreamParams* GetStreamByIds(const StreamParamsVec& streams, @@ -308,16 +293,16 @@ inline const StreamParams* GetStreamByIds(const StreamParamsVec& streams, inline StreamParams* GetStreamByIds(StreamParamsVec& streams, const std::string& groupid, const std::string& id) { - return GetStream(streams, - [&groupid, &id](const StreamParams& sp) { - return sp.groupid == groupid && sp.id == id; - }); + return GetStream(streams, [&groupid, &id](const StreamParams& sp) { + return sp.groupid == groupid && sp.id == id; + }); } inline const StreamParams* GetStream(const StreamParamsVec& streams, const StreamSelector& selector) { - return GetStream(streams, - [&selector](const StreamParams& sp) { return selector.Matches(sp); }); + return GetStream(streams, [&selector](const StreamParams& sp) { + return selector.Matches(sp); + }); } template @@ -332,21 +317,21 @@ bool RemoveStream(StreamParamsVec* streams, Condition condition) { // Removes the stream from streams. Returns true if a stream is // found and removed. inline bool RemoveStream(StreamParamsVec* streams, - const StreamSelector& selector) { - return RemoveStream(streams, - [&selector](const StreamParams& sp) { return selector.Matches(sp); }); + const StreamSelector& selector) { + return RemoveStream(streams, [&selector](const StreamParams& sp) { + return selector.Matches(sp); + }); } inline bool RemoveStreamBySsrc(StreamParamsVec* streams, uint32_t ssrc) { - return RemoveStream(streams, - [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); + return RemoveStream( + streams, [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); } inline bool RemoveStreamByIds(StreamParamsVec* streams, const std::string& groupid, const std::string& id) { - return RemoveStream(streams, - [&groupid, &id](const StreamParams& sp) { - return sp.groupid == groupid && sp.id == id; - }); + return RemoveStream(streams, [&groupid, &id](const StreamParams& sp) { + return sp.groupid == groupid && sp.id == id; + }); } // Checks if |sp| defines parameters for a single primary stream. There may diff --git a/media/base/streamparams_unittest.cc b/media/base/streamparams_unittest.cc index 87ce5d9bd8..c43a955fb6 100644 --- a/media/base/streamparams_unittest.cc +++ b/media/base/streamparams_unittest.cc @@ -32,10 +32,10 @@ static cricket::StreamParams CreateStreamParamsWithSsrcGroup( TEST(SsrcGroup, EqualNotEqual) { cricket::SsrcGroup ssrc_groups[] = { - cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs1)), - cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs2)), - cricket::SsrcGroup("Abc", MAKE_VECTOR(kSsrcs2)), - cricket::SsrcGroup("abc", MAKE_VECTOR(kSsrcs2)), + cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs1)), + cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs2)), + cricket::SsrcGroup("Abc", MAKE_VECTOR(kSsrcs2)), + cricket::SsrcGroup("abc", MAKE_VECTOR(kSsrcs2)), }; for (size_t i = 0; i < arraysize(ssrc_groups); ++i) { @@ -69,7 +69,7 @@ TEST(StreamParams, CreateLegacy) { EXPECT_EQ(ssrc, one_sp.first_ssrc()); EXPECT_TRUE(one_sp.has_ssrcs()); EXPECT_TRUE(one_sp.has_ssrc(ssrc)); - EXPECT_FALSE(one_sp.has_ssrc(ssrc+1)); + EXPECT_FALSE(one_sp.has_ssrc(ssrc + 1)); EXPECT_FALSE(one_sp.has_ssrc_groups()); EXPECT_EQ(0U, one_sp.ssrc_groups.size()); } @@ -149,7 +149,7 @@ TEST(StreamParams, FidFunctions) { std::vector fid_vector; fid_vector.push_back(13); cricket::SsrcGroup invalid_fid_group(cricket::kFidSsrcGroupSemantics, - fid_vector); + fid_vector); cricket::StreamParams sp_invalid; sp_invalid.add_ssrc(13); sp_invalid.ssrc_groups.push_back(invalid_fid_group); @@ -261,10 +261,8 @@ TEST(StreamParams, TestIsOneSsrcStream_SimulcastStream) { } TEST(StreamParams, TestIsOneSsrcStream_SimRtxStream) { - cricket::StreamParams stream = - cricket::CreateSimWithRtxStreamParams("cname", - MAKE_VECTOR(kSsrcs3), - MAKE_VECTOR(kRtxSsrcs3)); + cricket::StreamParams stream = cricket::CreateSimWithRtxStreamParams( + "cname", MAKE_VECTOR(kSsrcs3), MAKE_VECTOR(kRtxSsrcs3)); EXPECT_FALSE(cricket::IsOneSsrcStream(stream)); } @@ -288,19 +286,15 @@ TEST(StreamParams, TestIsSimulcastStream_SimulcastStream) { } TEST(StreamParams, TestIsSimulcastStream_SimRtxStream) { - cricket::StreamParams stream = - cricket::CreateSimWithRtxStreamParams("cname", - MAKE_VECTOR(kSsrcs3), - MAKE_VECTOR(kRtxSsrcs3)); + cricket::StreamParams stream = cricket::CreateSimWithRtxStreamParams( + "cname", MAKE_VECTOR(kSsrcs3), MAKE_VECTOR(kRtxSsrcs3)); EXPECT_TRUE(cricket::IsSimulcastStream(stream)); } TEST(StreamParams, TestIsSimulcastStream_InvalidStreams) { // stream1 has extra non-sim, non-fid ssrc. - cricket::StreamParams stream1 = - cricket::CreateSimWithRtxStreamParams("cname", - MAKE_VECTOR(kSsrcs3), - MAKE_VECTOR(kRtxSsrcs3)); + cricket::StreamParams stream1 = cricket::CreateSimWithRtxStreamParams( + "cname", MAKE_VECTOR(kSsrcs3), MAKE_VECTOR(kRtxSsrcs3)); stream1.add_ssrc(25); EXPECT_FALSE(cricket::IsSimulcastStream(stream1)); diff --git a/media/base/testutils.cc b/media/base/testutils.cc index f92d4013eb..93c2bc98ae 100644 --- a/media/base/testutils.cc +++ b/media/base/testutils.cc @@ -29,7 +29,8 @@ namespace cricket { ///////////////////////////////////////////////////////////////////////// void RawRtpPacket::WriteToByteBuffer(uint32_t in_ssrc, rtc::ByteBufferWriter* buf) const { - if (!buf) return; + if (!buf) + return; buf->WriteUInt8(ver_to_cc); buf->WriteUInt8(m_to_pt); @@ -40,7 +41,8 @@ void RawRtpPacket::WriteToByteBuffer(uint32_t in_ssrc, } bool RawRtpPacket::ReadFromByteBuffer(rtc::ByteBufferReader* buf) { - if (!buf) return false; + if (!buf) + return false; bool ret = true; ret &= buf->ReadUInt8(&ver_to_cc); @@ -56,19 +58,17 @@ bool RawRtpPacket::SameExceptSeqNumTimestampSsrc(const RawRtpPacket& packet, uint16_t seq, uint32_t ts, uint32_t ssc) const { - return sequence_number == seq && - timestamp == ts && - ver_to_cc == packet.ver_to_cc && - m_to_pt == packet.m_to_pt && - ssrc == ssc && - 0 == memcmp(payload, packet.payload, sizeof(payload)); + return sequence_number == seq && timestamp == ts && + ver_to_cc == packet.ver_to_cc && m_to_pt == packet.m_to_pt && + ssrc == ssc && 0 == memcmp(payload, packet.payload, sizeof(payload)); } ///////////////////////////////////////////////////////////////////////// // Implementation of RawRtcpPacket ///////////////////////////////////////////////////////////////////////// -void RawRtcpPacket::WriteToByteBuffer(rtc::ByteBufferWriter *buf) const { - if (!buf) return; +void RawRtcpPacket::WriteToByteBuffer(rtc::ByteBufferWriter* buf) const { + if (!buf) + return; buf->WriteUInt8(ver_to_count); buf->WriteUInt8(type); @@ -77,7 +77,8 @@ void RawRtcpPacket::WriteToByteBuffer(rtc::ByteBufferWriter *buf) const { } bool RawRtcpPacket::ReadFromByteBuffer(rtc::ByteBufferReader* buf) { - if (!buf) return false; + if (!buf) + return false; bool ret = true; ret &= buf->ReadUInt8(&ver_to_count); @@ -88,10 +89,9 @@ bool RawRtcpPacket::ReadFromByteBuffer(rtc::ByteBufferReader* buf) { } bool RawRtcpPacket::EqualsTo(const RawRtcpPacket& packet) const { - return ver_to_count == packet.ver_to_count && - type == packet.type && - length == packet.length && - 0 == memcmp(payload, packet.payload, sizeof(payload)); + return ver_to_count == packet.ver_to_count && type == packet.type && + length == packet.length && + 0 == memcmp(payload, packet.payload, sizeof(payload)); } // Implementation of VideoCaptureListener. @@ -103,7 +103,7 @@ VideoCapturerListener::VideoCapturerListener(VideoCapturer* capturer) frame_height_(0), resolution_changed_(false) { capturer->SignalStateChange.connect(this, - &VideoCapturerListener::OnStateChange); + &VideoCapturerListener::OnStateChange); capturer->AddOrUpdateSink(this, rtc::VideoSinkWants()); } diff --git a/media/base/testutils.h b/media/base/testutils.h index 7db72b07ee..cbdb517d8d 100644 --- a/media/base/testutils.h +++ b/media/base/testutils.h @@ -24,7 +24,7 @@ namespace rtc { class ByteBufferReader; class ByteBufferWriter; class StreamInterface; -} +} // namespace rtc namespace webrtc { class VideoFrame; @@ -37,7 +37,8 @@ namespace cricket { // Returns size of ARGB image. #define ARGB_SIZE(w, h) (w * h * 4) -template inline std::vector MakeVector(const T a[], size_t s) { +template +inline std::vector MakeVector(const T a[], size_t s) { return std::vector(a, a + s); } #define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a)) diff --git a/media/base/turnutils_unittest.cc b/media/base/turnutils_unittest.cc index 4a06d27871..e953c2519c 100644 --- a/media/base/turnutils_unittest.cc +++ b/media/base/turnutils_unittest.cc @@ -50,12 +50,15 @@ TEST(TurnUtilsTest, InvalidTurnSendIndicationMessages) { // Stun Send Indication message with no DATA attribute in message. const uint8_t kTurnSendIndicatinMsgWithNoDataAttribute[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x00, 0x16, 0x00, 0x08, // length of 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id '4', '5', '6', '7', '8', '9', 'a', 'b', 0x00, 0x20, 0x00, 0x04, // Mapped address. 0x00, 0x00, 0x00, 0x00, + // clang-format on }; EXPECT_FALSE( UnwrapTurnPacket(kTurnSendIndicatinMsgWithNoDataAttribute, @@ -72,6 +75,8 @@ TEST(TurnUtilsTest, ValidTurnSendIndicationMessage) { // A valid STUN indication message with a valid RTP header in data attribute // payload field and no extension bit set. const uint8_t kTurnSendIndicationMsgWithoutRtpExtension[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x00, 0x16, 0x00, 0x18, // length of 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -81,11 +86,12 @@ TEST(TurnUtilsTest, ValidTurnSendIndicationMessage) { 0x00, 0x13, 0x00, 0x0C, // Data attribute. 0x80, 0x00, 0x00, 0x00, // RTP packet. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // clang-format on }; - EXPECT_TRUE(UnwrapTurnPacket( - kTurnSendIndicationMsgWithoutRtpExtension, - sizeof(kTurnSendIndicationMsgWithoutRtpExtension), &content_pos, - &content_size)); + EXPECT_TRUE( + UnwrapTurnPacket(kTurnSendIndicationMsgWithoutRtpExtension, + sizeof(kTurnSendIndicationMsgWithoutRtpExtension), + &content_pos, &content_size)); EXPECT_EQ(12U, content_size); EXPECT_EQ(32U, content_pos); } @@ -93,15 +99,18 @@ TEST(TurnUtilsTest, ValidTurnSendIndicationMessage) { // Verify that parsing of valid TURN Channel Messages. TEST(TurnUtilsTest, ValidTurnChannelMessages) { const uint8_t kTurnChannelMsgWithRtpPacket[] = { + // clang-format off + // clang formatting doesn't respect inline comments. 0x40, 0x00, 0x00, 0x0C, 0x80, 0x00, 0x00, 0x00, // RTP packet. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // clang-format on }; size_t content_pos = 0, content_size = 0; - EXPECT_TRUE(UnwrapTurnPacket( - kTurnChannelMsgWithRtpPacket, - sizeof(kTurnChannelMsgWithRtpPacket), &content_pos, &content_size)); + EXPECT_TRUE(UnwrapTurnPacket(kTurnChannelMsgWithRtpPacket, + sizeof(kTurnChannelMsgWithRtpPacket), + &content_pos, &content_size)); EXPECT_EQ(12U, content_size); EXPECT_EQ(4U, content_pos); } diff --git a/media/base/videoadapter.cc b/media/base/videoadapter.cc index ded1cc6a46..c966713848 100644 --- a/media/base/videoadapter.cc +++ b/media/base/videoadapter.cc @@ -194,8 +194,8 @@ bool VideoAdapter::AdaptFrameResolution(int in_width, } // Calculate how the input should be cropped. - if (!requested_format_ || - requested_format_->width == 0 || requested_format_->height == 0) { + if (!requested_format_ || requested_format_->width == 0 || + requested_format_->height == 0) { *cropped_width = in_width; *cropped_height = in_height; } else { @@ -236,8 +236,8 @@ bool VideoAdapter::AdaptFrameResolution(int in_width, if (scale.numerator != scale.denominator) ++frames_scaled_; - if (previous_width_ && (previous_width_ != *out_width || - previous_height_ != *out_height)) { + if (previous_width_ && + (previous_width_ != *out_width || previous_height_ != *out_height)) { ++adaption_changes_; RTC_LOG(LS_INFO) << "Frame size changed: scaled " << frames_scaled_ << " / out " << frames_out_ << " / in " << frames_in_ diff --git a/media/base/videobroadcaster.cc b/media/base/videobroadcaster.cc index 09d69f227e..a16a327b07 100644 --- a/media/base/videobroadcaster.cc +++ b/media/base/videobroadcaster.cc @@ -65,9 +65,9 @@ void VideoBroadcaster::OnFrame(const webrtc::VideoFrame& frame) { continue; } if (sink_pair.wants.black_frames) { - sink_pair.sink->OnFrame(webrtc::VideoFrame( - GetBlackFrameBuffer(frame.width(), frame.height()), frame.rotation(), - frame.timestamp_us())); + sink_pair.sink->OnFrame( + webrtc::VideoFrame(GetBlackFrameBuffer(frame.width(), frame.height()), + frame.rotation(), frame.timestamp_us())); } else { sink_pair.sink->OnFrame(frame); } diff --git a/media/base/videobroadcaster_unittest.cc b/media/base/videobroadcaster_unittest.cc index 0f2057ebe0..a8c3884820 100644 --- a/media/base/videobroadcaster_unittest.cc +++ b/media/base/videobroadcaster_unittest.cc @@ -10,17 +10,16 @@ #include -#include "media/base/videobroadcaster.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame.h" #include "media/base/fakevideorenderer.h" +#include "media/base/videobroadcaster.h" #include "rtc_base/gunit.h" using rtc::VideoBroadcaster; using rtc::VideoSinkWants; using cricket::FakeVideoRenderer; - TEST(VideoBroadcasterTest, frame_wanted) { VideoBroadcaster broadcaster; EXPECT_FALSE(broadcaster.frame_wanted()); diff --git a/media/base/videocapturer.cc b/media/base/videocapturer.cc index f6e05ba5d5..4147da79dd 100644 --- a/media/base/videocapturer.cc +++ b/media/base/videocapturer.cc @@ -319,9 +319,10 @@ int64_t VideoCapturer::GetFormatDistance(const VideoFormat& desired, // Require camera fps to be at least 96% of what is requested, or higher, // if resolution differs. 96% allows for slight variations in fps. e.g. 29.97 if (delta_fps < 0) { - float min_desirable_fps = delta_w ? - VideoFormat::IntervalToFpsFloat(desired.interval) * 28.f / 30.f : - VideoFormat::IntervalToFpsFloat(desired.interval) * 23.f / 30.f; + float min_desirable_fps = + delta_w + ? VideoFormat::IntervalToFpsFloat(desired.interval) * 28.f / 30.f + : VideoFormat::IntervalToFpsFloat(desired.interval) * 23.f / 30.f; delta_fps = -delta_fps; if (supported_fps < min_desirable_fps) { distance |= static_cast(1) << 62; diff --git a/media/base/videocapturer.h b/media/base/videocapturer.h index 0470b4d17c..ee2f5ca0c2 100644 --- a/media/base/videocapturer.h +++ b/media/base/videocapturer.h @@ -38,12 +38,12 @@ namespace cricket { // Current state of the capturer. enum CaptureState { - CS_STOPPED, // The capturer has been stopped or hasn't started yet. - CS_STARTING, // The capturer is in the process of starting. Note, it may - // still fail to start. - CS_RUNNING, // The capturer has been started successfully and is now - // capturing. - CS_FAILED, // The capturer failed to start. + CS_STOPPED, // The capturer has been stopped or hasn't started yet. + CS_STARTING, // The capturer is in the process of starting. Note, it may + // still fail to start. + CS_RUNNING, // The capturer has been started successfully and is now + // capturing. + CS_FAILED, // The capturer failed to start. }; // VideoCapturer is an abstract class that defines the interfaces for video @@ -126,17 +126,13 @@ class VideoCapturer : public sigslot::has_slots<>, // Note that the width and height of the captured frames may differ from the // capture format. For example, the capture format is HD but the captured // frames may be smaller than HD. - const VideoFormat* GetCaptureFormat() const { - return capture_format_.get(); - } + const VideoFormat* GetCaptureFormat() const { return capture_format_.get(); } // Stop the video capturer. virtual void Stop() = 0; // Check if the video capturer is running. virtual bool IsRunning() = 0; - CaptureState capture_state() const { - return capture_state_; - } + CaptureState capture_state() const { return capture_state_; } virtual bool apply_rotation() { return apply_rotation_; } @@ -154,9 +150,7 @@ class VideoCapturer : public sigslot::has_slots<>, void set_enable_camera_list(bool enable_camera_list) { enable_camera_list_ = enable_camera_list; } - bool enable_camera_list() { - return enable_camera_list_; - } + bool enable_camera_list() { return enable_camera_list_; } // Signal all capture state changes that are not a direct result of calling // Start(). @@ -227,9 +221,7 @@ class VideoCapturer : public sigslot::has_slots<>, virtual bool GetPreferredFourccs(std::vector* fourccs) = 0; // mutators to set private attributes - void SetId(const std::string& id) { - id_ = id; - } + void SetId(const std::string& id) { id_ = id; } void SetCaptureFormat(const VideoFormat* format) { capture_format_.reset(format ? new VideoFormat(*format) : NULL); diff --git a/media/base/videocapturer_unittest.cc b/media/base/videocapturer_unittest.cc index e7008c0b91..080f4a08ca 100644 --- a/media/base/videocapturer_unittest.cc +++ b/media/base/videocapturer_unittest.cc @@ -31,9 +31,7 @@ const int kMinHdHeight = 720; } // namespace -class VideoCapturerTest - : public sigslot::has_slots<>, - public testing::Test { +class VideoCapturerTest : public sigslot::has_slots<>, public testing::Test { public: VideoCapturerTest() : capture_state_(cricket::CS_STOPPED), num_state_changes_(0) { @@ -67,11 +65,10 @@ class VideoCapturerTest TEST_F(VideoCapturerTest, CaptureState) { EXPECT_TRUE(capturer_->enable_video_adapter()); - EXPECT_EQ(cricket::CS_RUNNING, capturer_->Start(cricket::VideoFormat( - 640, - 480, - cricket::VideoFormat::FpsToInterval(30), - cricket::FOURCC_I420))); + EXPECT_EQ(cricket::CS_RUNNING, + capturer_->Start(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), + cricket::FOURCC_I420))); EXPECT_TRUE(capturer_->IsRunning()); EXPECT_EQ_WAIT(cricket::CS_RUNNING, capture_state(), kMsCallbackWait); EXPECT_EQ(1, num_state_changes()); @@ -327,9 +324,8 @@ TEST_F(VideoCapturerTest, SinkWantsMaxPixelAndMaxPixelCountStepUp) { } TEST_F(VideoCapturerTest, TestFourccMatch) { - cricket::VideoFormat desired(640, 480, - cricket::VideoFormat::FpsToInterval(30), - cricket::FOURCC_ANY); + cricket::VideoFormat desired( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_ANY); cricket::VideoFormat best; EXPECT_TRUE(capturer_->GetBestCaptureFormat(desired, &best)); EXPECT_EQ(640, best.width); @@ -344,9 +340,8 @@ TEST_F(VideoCapturerTest, TestFourccMatch) { } TEST_F(VideoCapturerTest, TestResolutionMatch) { - cricket::VideoFormat desired(1920, 1080, - cricket::VideoFormat::FpsToInterval(30), - cricket::FOURCC_ANY); + cricket::VideoFormat desired( + 1920, 1080, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_ANY); cricket::VideoFormat best; // Ask for 1920x1080. Get HD 1280x720 which is the highest. EXPECT_TRUE(capturer_->GetBestCaptureFormat(desired, &best)); @@ -390,21 +385,22 @@ TEST_F(VideoCapturerTest, TestResolutionMatch) { TEST_F(VideoCapturerTest, TestHDResolutionMatch) { // Add some HD formats typical of a mediocre HD webcam. std::vector formats; - formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - formats.push_back(cricket::VideoFormat(960, 544, - cricket::VideoFormat::FpsToInterval(24), cricket::FOURCC_I420)); - formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(15), cricket::FOURCC_I420)); + formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + formats.push_back(cricket::VideoFormat( + 960, 544, cricket::VideoFormat::FpsToInterval(24), cricket::FOURCC_I420)); + formats.push_back( + cricket::VideoFormat(1280, 720, cricket::VideoFormat::FpsToInterval(15), + cricket::FOURCC_I420)); formats.push_back(cricket::VideoFormat(2592, 1944, - cricket::VideoFormat::FpsToInterval(7), cricket::FOURCC_I420)); + cricket::VideoFormat::FpsToInterval(7), + cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(formats); - cricket::VideoFormat desired(960, 720, - cricket::VideoFormat::FpsToInterval(30), - cricket::FOURCC_ANY); + cricket::VideoFormat desired( + 960, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_ANY); cricket::VideoFormat best; // Ask for 960x720 30 fps. Get qHD 24 fps EXPECT_TRUE(capturer_->GetBestCaptureFormat(desired, &best)); @@ -484,19 +480,19 @@ TEST_F(VideoCapturerTest, TestHDResolutionMatch) { // Some cameras support 320x240 and 320x640. Verify we choose 320x240. TEST_F(VideoCapturerTest, TestStrangeFormats) { std::vector supported_formats; - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(320, 640, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 640, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); std::vector required_formats; - required_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - required_formats.push_back(cricket::VideoFormat(320, 200, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - required_formats.push_back(cricket::VideoFormat(320, 180, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + required_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + required_formats.push_back(cricket::VideoFormat( + 320, 200, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + required_formats.push_back(cricket::VideoFormat( + 320, 180, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); cricket::VideoFormat best; for (size_t i = 0; i < required_formats.size(); ++i) { EXPECT_TRUE(capturer_->GetBestCaptureFormat(required_formats[i], &best)); @@ -505,10 +501,10 @@ TEST_F(VideoCapturerTest, TestStrangeFormats) { } supported_formats.clear(); - supported_formats.push_back(cricket::VideoFormat(320, 640, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 640, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); for (size_t i = 0; i < required_formats.size(); ++i) { @@ -522,19 +518,19 @@ TEST_F(VideoCapturerTest, TestStrangeFormats) { TEST_F(VideoCapturerTest, TestPoorFpsFormats) { // all formats are low framerate std::vector supported_formats; - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(10), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(7), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(2), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(10), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(7), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 1280, 720, cricket::VideoFormat::FpsToInterval(2), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); std::vector required_formats; - required_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - required_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + required_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + required_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); cricket::VideoFormat best; for (size_t i = 0; i < required_formats.size(); ++i) { EXPECT_TRUE(capturer_->GetBestCaptureFormat(required_formats[i], &best)); @@ -544,12 +540,12 @@ TEST_F(VideoCapturerTest, TestPoorFpsFormats) { // Increase framerate of 320x240. Expect low fps VGA avoided. supported_formats.clear(); - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(7), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(2), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(7), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 1280, 720, cricket::VideoFormat::FpsToInterval(2), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); for (size_t i = 0; i < required_formats.size(); ++i) { @@ -563,12 +559,12 @@ TEST_F(VideoCapturerTest, TestPoorFpsFormats) { // the frame rate properly. TEST_F(VideoCapturerTest, TestSameSizeDifferentFpsFormats) { std::vector supported_formats; - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(10), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(20), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(320, 240, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(10), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(20), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 320, 240, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); std::vector required_formats = supported_formats; @@ -586,23 +582,24 @@ TEST_F(VideoCapturerTest, TestSameSizeDifferentFpsFormats) { TEST_F(VideoCapturerTest, TestFpsFormats) { // We have VGA but low fps. Choose VGA, not HD std::vector supported_formats; - supported_formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(15), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 400, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 360, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back( + cricket::VideoFormat(1280, 720, cricket::VideoFormat::FpsToInterval(30), + cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(15), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 400, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 360, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); std::vector required_formats; - required_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_ANY)); - required_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(20), cricket::FOURCC_ANY)); - required_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(10), cricket::FOURCC_ANY)); + required_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_ANY)); + required_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(20), cricket::FOURCC_ANY)); + required_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(10), cricket::FOURCC_ANY)); cricket::VideoFormat best; // Expect 30 fps to choose 30 fps format. @@ -625,16 +622,17 @@ TEST_F(VideoCapturerTest, TestFpsFormats) { // We have VGA 60 fps and 15 fps. Choose best fps. supported_formats.clear(); - supported_formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_MJPG)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(15), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 400, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 360, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back( + cricket::VideoFormat(1280, 720, cricket::VideoFormat::FpsToInterval(30), + cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_MJPG)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(15), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 400, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 360, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); // Expect 30 fps to choose 60 fps format and will set best fps to 60. @@ -659,12 +657,12 @@ TEST_F(VideoCapturerTest, TestFpsFormats) { TEST_F(VideoCapturerTest, TestRequest16x10_9) { std::vector supported_formats; // We do not support HD, expect 4x3 for 4x3, 16x10, and 16x9 requests. - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 400, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 360, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 400, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 360, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); std::vector required_formats = supported_formats; @@ -678,14 +676,14 @@ TEST_F(VideoCapturerTest, TestRequest16x10_9) { // We do not support 16x9 HD, expect 4x3 for 4x3, 16x10, and 16x9 requests. supported_formats.clear(); - supported_formats.push_back(cricket::VideoFormat(960, 720, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 400, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 360, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 960, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 400, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 360, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); // Expect 4x3, 16x10, and 16x9 requests are respected. @@ -697,14 +695,15 @@ TEST_F(VideoCapturerTest, TestRequest16x10_9) { // We support 16x9HD, Expect 4x3, 16x10, and 16x9 requests are respected. supported_formats.clear(); - supported_formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 480, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 400, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(640, 360, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back( + cricket::VideoFormat(1280, 720, cricket::VideoFormat::FpsToInterval(30), + cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 400, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back(cricket::VideoFormat( + 640, 360, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); // Expect 4x3 for 4x3 and 16x10 requests. @@ -722,7 +721,8 @@ TEST_F(VideoCapturerTest, TestRequest16x10_9) { bool HdFormatInList(const std::vector& formats) { for (std::vector::const_iterator found = - formats.begin(); found != formats.end(); ++found) { + formats.begin(); + found != formats.end(); ++found) { if (found->height >= kMinHdHeight) { return true; } @@ -734,13 +734,11 @@ TEST_F(VideoCapturerTest, Whitelist) { // The definition of HD only applies to the height. Set the HD width to the // smallest legal number to document this fact in this test. const int kMinHdWidth = 1; - cricket::VideoFormat hd_format(kMinHdWidth, - kMinHdHeight, + cricket::VideoFormat hd_format(kMinHdWidth, kMinHdHeight, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); - cricket::VideoFormat vga_format(640, 480, - cricket::VideoFormat::FpsToInterval(30), - cricket::FOURCC_I420); + cricket::VideoFormat vga_format( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); std::vector formats = *capturer_->GetSupportedFormats(); formats.push_back(hd_format); @@ -760,15 +758,16 @@ TEST_F(VideoCapturerTest, Whitelist) { } TEST_F(VideoCapturerTest, BlacklistAllFormats) { - cricket::VideoFormat vga_format(640, 480, - cricket::VideoFormat::FpsToInterval(30), - cricket::FOURCC_I420); + cricket::VideoFormat vga_format( + 640, 480, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); std::vector supported_formats; // Mock a device that only supports HD formats. - supported_formats.push_back(cricket::VideoFormat(1280, 720, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); - supported_formats.push_back(cricket::VideoFormat(1920, 1080, - cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); + supported_formats.push_back( + cricket::VideoFormat(1280, 720, cricket::VideoFormat::FpsToInterval(30), + cricket::FOURCC_I420)); + supported_formats.push_back( + cricket::VideoFormat(1920, 1080, cricket::VideoFormat::FpsToInterval(30), + cricket::FOURCC_I420)); capturer_->ResetSupportedFormats(supported_formats); EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); // Now, enable the list, which would exclude both formats. However, since diff --git a/media/base/videocommon.cc b/media/base/videocommon.cc index 7c81eeb98f..9def96c469 100644 --- a/media/base/videocommon.cc +++ b/media/base/videocommon.cc @@ -24,20 +24,20 @@ struct FourCCAliasEntry { }; static const FourCCAliasEntry kFourCCAliases[] = { - {FOURCC_IYUV, FOURCC_I420}, - {FOURCC_YU16, FOURCC_I422}, - {FOURCC_YU24, FOURCC_I444}, - {FOURCC_YUYV, FOURCC_YUY2}, - {FOURCC_YUVS, FOURCC_YUY2}, - {FOURCC_HDYC, FOURCC_UYVY}, - {FOURCC_2VUY, FOURCC_UYVY}, - {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. - {FOURCC_DMB1, FOURCC_MJPG}, - {FOURCC_BA81, FOURCC_BGGR}, - {FOURCC_RGB3, FOURCC_RAW}, - {FOURCC_BGR3, FOURCC_24BG}, - {FOURCC_CM32, FOURCC_BGRA}, - {FOURCC_CM24, FOURCC_RAW}, + {FOURCC_IYUV, FOURCC_I420}, + {FOURCC_YU16, FOURCC_I422}, + {FOURCC_YU24, FOURCC_I444}, + {FOURCC_YUYV, FOURCC_YUY2}, + {FOURCC_YUVS, FOURCC_YUY2}, + {FOURCC_HDYC, FOURCC_UYVY}, + {FOURCC_2VUY, FOURCC_UYVY}, + {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. + {FOURCC_DMB1, FOURCC_MJPG}, + {FOURCC_BA81, FOURCC_BGGR}, + {FOURCC_RGB3, FOURCC_RAW}, + {FOURCC_BGR3, FOURCC_24BG}, + {FOURCC_CM32, FOURCC_BGRA}, + {FOURCC_CM24, FOURCC_RAW}, }; uint32_t CanonicalFourCC(uint32_t fourcc) { @@ -62,7 +62,7 @@ const int64_t VideoFormat::kMinimumInterval; // Initialized in header. std::string VideoFormat::ToString() const { std::string fourcc_name = GetFourccName(fourcc) + " "; for (std::string::const_iterator i = fourcc_name.begin(); - i < fourcc_name.end(); ++i) { + i < fourcc_name.end(); ++i) { // Test character is printable; Avoid isprint() which asserts on negatives. if (*i < 32 || *i >= 127) { fourcc_name = ""; diff --git a/media/base/videocommon.h b/media/base/videocommon.h index 7415883eca..0ffd989cb6 100644 --- a/media/base/videocommon.h +++ b/media/base/videocommon.h @@ -30,8 +30,7 @@ const uint32_t kDummyVideoSsrc = 0xFFFFFFFF; // Minimum interval is 10k fps. #define FPS_TO_INTERVAL(fps) \ - (fps ? rtc::kNumNanosecsPerSec / fps : \ - rtc::kNumNanosecsPerSec / 10000) + (fps ? rtc::kNumNanosecsPerSec / fps : rtc::kNumNanosecsPerSec / 10000) ////////////////////////////////////////////////////////////////////////////// // Definition of FourCC codes @@ -39,7 +38,7 @@ const uint32_t kDummyVideoSsrc = 0xFFFFFFFF; // Convert four characters to a FourCC code. // Needs to be a macro otherwise the OS X compiler complains when the kFormat* // constants are used in a switch. -#define CRICKET_FOURCC(a, b, c, d) \ +#define CRICKET_FOURCC(a, b, c, d) \ ((static_cast(a)) | (static_cast(b) << 8) | \ (static_cast(c) << 16) | (static_cast(d) << 24)) // Some pages discussing FourCC codes: @@ -73,7 +72,7 @@ enum FourCC { FOURCC_BGRA = CRICKET_FOURCC('B', 'G', 'R', 'A'), FOURCC_ABGR = CRICKET_FOURCC('A', 'B', 'G', 'R'), FOURCC_24BG = CRICKET_FOURCC('2', '4', 'B', 'G'), - FOURCC_RAW = CRICKET_FOURCC('r', 'a', 'w', ' '), + FOURCC_RAW = CRICKET_FOURCC('r', 'a', 'w', ' '), FOURCC_RGBA = CRICKET_FOURCC('R', 'G', 'B', 'A'), FOURCC_RGBP = CRICKET_FOURCC('R', 'G', 'B', 'P'), // bgr565. FOURCC_RGBO = CRICKET_FOURCC('R', 'G', 'B', 'O'), // abgr1555. @@ -144,8 +143,8 @@ inline std::string GetFourccName(uint32_t fourcc) { // VideoFormat with Plain Old Data for global variables. struct VideoFormatPod { - int width; // Number of pixels. - int height; // Number of pixels. + int width; // Number of pixels. + int height; // Number of pixels. int64_t interval; // Nanoseconds. uint32_t fourcc; // Color space. FOURCC_ANY means that any color space is OK. }; @@ -154,9 +153,7 @@ struct VideoFormat : VideoFormatPod { static const int64_t kMinimumInterval = rtc::kNumNanosecsPerSec / 10000; // 10k fps. - VideoFormat() { - Construct(0, 0, 0, 0); - } + VideoFormat() { Construct(0, 0, 0, 0); } VideoFormat(int w, int h, int64_t interval_ns, uint32_t cc) { Construct(w, h, interval_ns, cc); @@ -189,12 +186,12 @@ struct VideoFormat : VideoFormatPod { return 0.f; } return static_cast(rtc::kNumNanosecsPerSec) / - static_cast(interval); + static_cast(interval); } bool operator==(const VideoFormat& format) const { return width == format.width && height == format.height && - interval == format.interval && fourcc == format.fourcc; + interval == format.interval && fourcc == format.fourcc; } bool operator!=(const VideoFormat& format) const { @@ -203,10 +200,10 @@ struct VideoFormat : VideoFormatPod { bool operator<(const VideoFormat& format) const { return (fourcc < format.fourcc) || - (fourcc == format.fourcc && width < format.width) || - (fourcc == format.fourcc && width == format.width && + (fourcc == format.fourcc && width < format.width) || + (fourcc == format.fourcc && width == format.width && height < format.height) || - (fourcc == format.fourcc && width == format.width && + (fourcc == format.fourcc && width == format.width && height == format.height && interval > format.interval); } @@ -219,7 +216,7 @@ struct VideoFormat : VideoFormatPod { // and frame rate. bool IsPixelRateLess(const VideoFormat& format) const { return width * height * framerate() < - format.width * format.height * format.framerate(); + format.width * format.height * format.framerate(); } // Get a string presentation in the form of "fourcc width x height x fps" diff --git a/media/engine/adm_helpers.cc b/media/engine/adm_helpers.cc index 119cc64451..7ec6575413 100644 --- a/media/engine/adm_helpers.cc +++ b/media/engine/adm_helpers.cc @@ -27,7 +27,7 @@ namespace adm_helpers { // the ADM functions, depending on the ID type. #if defined(WEBRTC_WIN) #define AUDIO_DEVICE_ID \ - (AudioDeviceModule::WindowsDeviceType::kDefaultCommunicationDevice) + (AudioDeviceModule::WindowsDeviceType::kDefaultCommunicationDevice) #else #define AUDIO_DEVICE_ID (0u) #endif // defined(WEBRTC_WIN) diff --git a/media/engine/apm_helpers.cc b/media/engine/apm_helpers.cc index cf5dde27dd..ea37cb44f4 100644 --- a/media/engine/apm_helpers.cc +++ b/media/engine/apm_helpers.cc @@ -31,7 +31,8 @@ void Init(AudioProcessing* apm) { GainControl* gc = apm->gain_control(); if (gc->set_analog_level_limits(kMinVolumeLevel, kMaxVolumeLevel) != 0) { RTC_DLOG(LS_ERROR) << "Failed to set analog level limits with minimum: " - << kMinVolumeLevel << " and maximum: " << kMaxVolumeLevel; + << kMinVolumeLevel + << " and maximum: " << kMaxVolumeLevel; } } @@ -44,8 +45,7 @@ AgcConfig GetAgcConfig(AudioProcessing* apm) { return result; } -void SetAgcConfig(AudioProcessing* apm, - const AgcConfig& config) { +void SetAgcConfig(AudioProcessing* apm, const AgcConfig& config) { RTC_DCHECK(apm); GainControl* gc = apm->gain_control(); if (gc->set_target_level_dbfs(config.targetLeveldBOv) != 0) { @@ -62,8 +62,7 @@ void SetAgcConfig(AudioProcessing* apm, } } -void SetAgcStatus(AudioProcessing* apm, - bool enable) { +void SetAgcStatus(AudioProcessing* apm, bool enable) { RTC_DCHECK(apm); #if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID) GainControl::Mode agc_mode = GainControl::kFixedDigital; @@ -82,9 +81,7 @@ void SetAgcStatus(AudioProcessing* apm, RTC_LOG(LS_INFO) << "AGC set to " << enable << " with mode " << agc_mode; } -void SetEcStatus(AudioProcessing* apm, - bool enable, - EcModes mode) { +void SetEcStatus(AudioProcessing* apm, bool enable, EcModes mode) { RTC_DCHECK(apm); RTC_DCHECK(mode == kEcConference || mode == kEcAecm) << "mode: " << mode; EchoCancellation* ec = apm->echo_cancellation(); @@ -99,8 +96,7 @@ void SetEcStatus(AudioProcessing* apm, RTC_LOG(LS_ERROR) << "Failed to enable/disable AEC: " << enable; return; } - if (ec->set_suppression_level(EchoCancellation::kHighSuppression) - != 0) { + if (ec->set_suppression_level(EchoCancellation::kHighSuppression) != 0) { RTC_LOG(LS_ERROR) << "Failed to set high AEC aggressiveness."; return; } diff --git a/media/engine/apm_helpers.h b/media/engine/apm_helpers.h index 42465fcec0..f775d8a473 100644 --- a/media/engine/apm_helpers.h +++ b/media/engine/apm_helpers.h @@ -18,8 +18,8 @@ namespace webrtc { class AudioProcessing; enum EcModes { - kEcConference, // Conferencing default (aggressive AEC). - kEcAecm, // AEC mobile. + kEcConference, // Conferencing default (aggressive AEC). + kEcAecm, // AEC mobile. }; struct AgcConfig { @@ -32,13 +32,9 @@ namespace apm_helpers { void Init(AudioProcessing* apm); AgcConfig GetAgcConfig(AudioProcessing* apm); -void SetAgcConfig(AudioProcessing* apm, - const AgcConfig& config); -void SetAgcStatus(AudioProcessing* apm, - bool enable); -void SetEcStatus(AudioProcessing* apm, - bool enable, - EcModes mode); +void SetAgcConfig(AudioProcessing* apm, const AgcConfig& config); +void SetAgcStatus(AudioProcessing* apm, bool enable); +void SetEcStatus(AudioProcessing* apm, bool enable, EcModes mode); void SetEcMetricsStatus(AudioProcessing* apm, bool enable); void SetAecmMode(AudioProcessing* apm, bool enable_cng); void SetNsStatus(AudioProcessing* apm, bool enable); diff --git a/media/engine/apm_helpers_unittest.cc b/media/engine/apm_helpers_unittest.cc index bad24af83b..47475cc540 100644 --- a/media/engine/apm_helpers_unittest.cc +++ b/media/engine/apm_helpers_unittest.cc @@ -18,7 +18,7 @@ namespace webrtc { namespace { -constexpr AgcConfig kDefaultAgcConfig = { 3, 9, true }; +constexpr AgcConfig kDefaultAgcConfig = {3, 9, true}; struct TestHelper { TestHelper() { @@ -60,8 +60,7 @@ struct TestHelper { TEST(ApmHelpersTest, AgcConfig_DefaultConfiguration) { TestHelper helper; - AgcConfig agc_config = - apm_helpers::GetAgcConfig(helper.apm()); + AgcConfig agc_config = apm_helpers::GetAgcConfig(helper.apm()); EXPECT_EQ(kDefaultAgcConfig.targetLeveldBOv, agc_config.targetLeveldBOv); EXPECT_EQ(kDefaultAgcConfig.digitalCompressionGaindB, @@ -70,19 +69,16 @@ TEST(ApmHelpersTest, AgcConfig_DefaultConfiguration) { } TEST(ApmHelpersTest, AgcConfig_GetAndSet) { - const AgcConfig agc_config = { 11, 17, false }; + const AgcConfig agc_config = {11, 17, false}; TestHelper helper; apm_helpers::SetAgcConfig(helper.apm(), agc_config); - AgcConfig actual_config = - apm_helpers::GetAgcConfig(helper.apm()); + AgcConfig actual_config = apm_helpers::GetAgcConfig(helper.apm()); EXPECT_EQ(agc_config.digitalCompressionGaindB, actual_config.digitalCompressionGaindB); - EXPECT_EQ(agc_config.limiterEnable, - actual_config.limiterEnable); - EXPECT_EQ(agc_config.targetLeveldBOv, - actual_config.targetLeveldBOv); + EXPECT_EQ(agc_config.limiterEnable, actual_config.limiterEnable); + EXPECT_EQ(agc_config.targetLeveldBOv, actual_config.targetLeveldBOv); } TEST(ApmHelpersTest, AgcStatus_DefaultMode) { diff --git a/media/engine/fakewebrtccall.cc b/media/engine/fakewebrtccall.cc index b966234c7c..78a1b63d93 100644 --- a/media/engine/fakewebrtccall.cc +++ b/media/engine/fakewebrtccall.cc @@ -21,17 +21,16 @@ namespace cricket { FakeAudioSendStream::FakeAudioSendStream( - int id, const webrtc::AudioSendStream::Config& config) - : id_(id), config_(config) { -} + int id, + const webrtc::AudioSendStream::Config& config) + : id_(id), config_(config) {} void FakeAudioSendStream::Reconfigure( const webrtc::AudioSendStream::Config& config) { config_ = config; } -const webrtc::AudioSendStream::Config& - FakeAudioSendStream::GetConfig() const { +const webrtc::AudioSendStream::Config& FakeAudioSendStream::GetConfig() const { return config_; } @@ -41,12 +40,13 @@ void FakeAudioSendStream::SetStats( } FakeAudioSendStream::TelephoneEvent - FakeAudioSendStream::GetLatestTelephoneEvent() const { +FakeAudioSendStream::GetLatestTelephoneEvent() const { return latest_telephone_event_; } bool FakeAudioSendStream::SendTelephoneEvent(int payload_type, - int payload_frequency, int event, + int payload_frequency, + int event, int duration_ms) { latest_telephone_event_.payload_type = payload_type; latest_telephone_event_.payload_frequency = payload_frequency; @@ -69,12 +69,12 @@ webrtc::AudioSendStream::Stats FakeAudioSendStream::GetStats( } FakeAudioReceiveStream::FakeAudioReceiveStream( - int id, const webrtc::AudioReceiveStream::Config& config) - : id_(id), config_(config) { -} + int id, + const webrtc::AudioReceiveStream::Config& config) + : id_(id), config_(config) {} -const webrtc::AudioReceiveStream::Config& - FakeAudioReceiveStream::GetConfig() const { +const webrtc::AudioReceiveStream::Config& FakeAudioReceiveStream::GetConfig() + const { return config_; } @@ -189,8 +189,7 @@ int64_t FakeVideoSendStream::GetLastTimestamp() const { void FakeVideoSendStream::OnFrame(const webrtc::VideoFrame& frame) { ++num_swapped_frames_; - if (!last_frame_ || - frame.width() != last_frame_->width() || + if (!last_frame_ || frame.width() != last_frame_->width() || frame.height() != last_frame_->height() || frame.rotation() != last_frame_->rotation()) { video_streams_ = encoder_config_.video_stream_factory->CreateEncoderStreams( @@ -224,8 +223,8 @@ void FakeVideoSendStream::ReconfigureVideoEncoder( } else { width = height = 0; } - video_streams_ = config.video_stream_factory->CreateEncoderStreams( - width, height, config); + video_streams_ = + config.video_stream_factory->CreateEncoderStreams(width, height, config); if (config.encoder_specific_settings != NULL) { const unsigned char num_temporal_layers = static_cast( video_streams_.back().num_temporal_layers.value_or(1)); @@ -457,16 +456,15 @@ webrtc::NetworkState FakeCall::GetNetworkState(webrtc::MediaType media) const { webrtc::AudioSendStream* FakeCall::CreateAudioSendStream( const webrtc::AudioSendStream::Config& config) { - FakeAudioSendStream* fake_stream = new FakeAudioSendStream(next_stream_id_++, - config); + FakeAudioSendStream* fake_stream = + new FakeAudioSendStream(next_stream_id_++, config); audio_send_streams_.push_back(fake_stream); ++num_created_send_streams_; return fake_stream; } void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { - auto it = std::find(audio_send_streams_.begin(), - audio_send_streams_.end(), + auto it = std::find(audio_send_streams_.begin(), audio_send_streams_.end(), static_cast(send_stream)); if (it == audio_send_streams_.end()) { ADD_FAILURE() << "DestroyAudioSendStream called with unknown parameter."; @@ -478,17 +476,17 @@ void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream( const webrtc::AudioReceiveStream::Config& config) { - audio_receive_streams_.push_back(new FakeAudioReceiveStream(next_stream_id_++, - config)); + audio_receive_streams_.push_back( + new FakeAudioReceiveStream(next_stream_id_++, config)); ++num_created_receive_streams_; return audio_receive_streams_.back(); } void FakeCall::DestroyAudioReceiveStream( webrtc::AudioReceiveStream* receive_stream) { - auto it = std::find(audio_receive_streams_.begin(), - audio_receive_streams_.end(), - static_cast(receive_stream)); + auto it = + std::find(audio_receive_streams_.begin(), audio_receive_streams_.end(), + static_cast(receive_stream)); if (it == audio_receive_streams_.end()) { ADD_FAILURE() << "DestroyAudioReceiveStream called with unknown parameter."; } else { @@ -508,8 +506,7 @@ webrtc::VideoSendStream* FakeCall::CreateVideoSendStream( } void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { - auto it = std::find(video_send_streams_.begin(), - video_send_streams_.end(), + auto it = std::find(video_send_streams_.begin(), video_send_streams_.end(), static_cast(send_stream)); if (it == video_send_streams_.end()) { ADD_FAILURE() << "DestroyVideoSendStream called with unknown parameter."; @@ -529,9 +526,9 @@ webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream( void FakeCall::DestroyVideoReceiveStream( webrtc::VideoReceiveStream* receive_stream) { - auto it = std::find(video_receive_streams_.begin(), - video_receive_streams_.end(), - static_cast(receive_stream)); + auto it = + std::find(video_receive_streams_.begin(), video_receive_streams_.end(), + static_cast(receive_stream)); if (it == video_receive_streams_.end()) { ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown parameter."; } else { diff --git a/media/engine/fakewebrtccall.h b/media/engine/fakewebrtccall.h index 00bd079d99..4ee6a8018c 100644 --- a/media/engine/fakewebrtccall.h +++ b/media/engine/fakewebrtccall.h @@ -45,8 +45,8 @@ class FakeAudioSendStream final : public webrtc::AudioSendStream { int duration_ms = 0; }; - explicit FakeAudioSendStream( - int id, const webrtc::AudioSendStream::Config& config); + explicit FakeAudioSendStream(int id, + const webrtc::AudioSendStream::Config& config); int id() const { return id_; } const webrtc::AudioSendStream::Config& GetConfig() const override; @@ -62,7 +62,9 @@ class FakeAudioSendStream final : public webrtc::AudioSendStream { void Stop() override { sending_ = false; } void SendAudioData(std::unique_ptr audio_frame) override { } - bool SendTelephoneEvent(int payload_type, int payload_frequency, int event, + bool SendTelephoneEvent(int payload_type, + int payload_frequency, + int event, int duration_ms) override; void SetMuted(bool muted) override; webrtc::AudioSendStream::Stats GetStats() const override; @@ -80,7 +82,8 @@ class FakeAudioSendStream final : public webrtc::AudioSendStream { class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream { public: explicit FakeAudioReceiveStream( - int id, const webrtc::AudioReceiveStream::Config& config); + int id, + const webrtc::AudioReceiveStream::Config& config); int id() const { return id_; } const webrtc::AudioReceiveStream::Config& GetConfig() const; diff --git a/media/engine/fakewebrtcdeviceinfo.h b/media/engine/fakewebrtcdeviceinfo.h index 51a5b8e50c..7103b4c343 100644 --- a/media/engine/fakewebrtcdeviceinfo.h +++ b/media/engine/fakewebrtcdeviceinfo.h @@ -33,9 +33,10 @@ class FakeWebRtcDeviceInfo : public webrtc::VideoCaptureModule::DeviceInfo { } void AddCapability(const std::string& device_id, const webrtc::VideoCaptureCapability& cap) { - Device* dev = GetDeviceById( - reinterpret_cast(device_id.c_str())); - if (!dev) return; + Device* dev = + GetDeviceById(reinterpret_cast(device_id.c_str())); + if (!dev) + return; dev->caps.push_back(cap); } virtual uint32_t NumberOfDevices() { @@ -49,28 +50,32 @@ class FakeWebRtcDeviceInfo : public webrtc::VideoCaptureModule::DeviceInfo { char* product_id, uint32_t product_id_len) { Device* dev = GetDeviceByIndex(device_num); - if (!dev) return -1; + if (!dev) + return -1; rtc::strcpyn(reinterpret_cast(device_name), device_name_len, - dev->name.c_str()); + dev->name.c_str()); rtc::strcpyn(reinterpret_cast(device_id), device_id_len, - dev->id.c_str()); + dev->id.c_str()); if (product_id) { rtc::strcpyn(reinterpret_cast(product_id), product_id_len, - dev->product.c_str()); + dev->product.c_str()); } return 0; } virtual int32_t NumberOfCapabilities(const char* device_id) { Device* dev = GetDeviceById(device_id); - if (!dev) return -1; + if (!dev) + return -1; return static_cast(dev->caps.size()); } virtual int32_t GetCapability(const char* device_id, const uint32_t device_cap_num, webrtc::VideoCaptureCapability& cap) { Device* dev = GetDeviceById(device_id); - if (!dev) return -1; - if (device_cap_num >= dev->caps.size()) return -1; + if (!dev) + return -1; + if (device_cap_num >= dev->caps.size()) + return -1; cap = dev->caps[device_cap_num]; return 0; } @@ -84,9 +89,11 @@ class FakeWebRtcDeviceInfo : public webrtc::VideoCaptureModule::DeviceInfo { webrtc::VideoCaptureCapability& resulting) { return -1; // not implemented } - virtual int32_t DisplayCaptureSettingsDialogBox( - const char* device_id, const char* dialog_title, - void* parent, uint32_t x, uint32_t y) { + virtual int32_t DisplayCaptureSettingsDialogBox(const char* device_id, + const char* dialog_title, + void* parent, + uint32_t x, + uint32_t y) { return -1; // not implemented } diff --git a/media/engine/fakewebrtcvcmfactory.h b/media/engine/fakewebrtcvcmfactory.h index abd69ea78b..41ec98df8b 100644 --- a/media/engine/fakewebrtcvcmfactory.h +++ b/media/engine/fakewebrtcvcmfactory.h @@ -23,7 +23,8 @@ class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface { public: virtual rtc::scoped_refptr Create( const char* device_id) { - if (!device_info.GetDeviceById(device_id)) return NULL; + if (!device_info.GetDeviceById(device_id)) + return NULL; rtc::scoped_refptr module( new rtc::RefCountedObject()); modules.push_back(module); diff --git a/media/engine/fakewebrtcvideocapturemodule.h b/media/engine/fakewebrtcvideocapturemodule.h index 741b5be785..47f1393c3f 100644 --- a/media/engine/fakewebrtcvideocapturemodule.h +++ b/media/engine/fakewebrtcvideocapturemodule.h @@ -30,7 +30,8 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule { } void DeRegisterCaptureDataCallback() override { callback_ = NULL; } int32_t StartCapture(const webrtc::VideoCaptureCapability& cap) override { - if (running_) return -1; + if (running_) + return -1; cap_ = cap; running_ = true; return 0; @@ -44,7 +45,8 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule { } bool CaptureStarted() override { return running_; } int32_t CaptureSettings(webrtc::VideoCaptureCapability& settings) override { - if (!running_) return -1; + if (!running_) + return -1; settings = cap_; return 0; } @@ -73,9 +75,7 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule { }); } - const webrtc::VideoCaptureCapability& cap() const { - return cap_; - } + const webrtc::VideoCaptureCapability& cap() const { return cap_; } private: rtc::test::TaskQueueForTest task_queue_{"FakeWebRtcVideoCaptureModule"}; diff --git a/media/engine/nullwebrtcvideoengine.h b/media/engine/nullwebrtcvideoengine.h index 0ff997d7ad..9af0f9b130 100644 --- a/media/engine/nullwebrtcvideoengine.h +++ b/media/engine/nullwebrtcvideoengine.h @@ -22,7 +22,6 @@ class Call; } // namespace webrtc - namespace cricket { class VideoMediaChannel; diff --git a/media/engine/payload_type_mapper.cc b/media/engine/payload_type_mapper.cc index 57397d1ae6..5d2fb6757c 100644 --- a/media/engine/payload_type_mapper.cc +++ b/media/engine/payload_type_mapper.cc @@ -30,52 +30,55 @@ PayloadTypeMapper::PayloadTypeMapper() // mapping within the exclusive range. : next_unused_payload_type_(96), max_payload_type_(127), - mappings_({ - // Static payload type assignments according to RFC 3551. - {{"PCMU", 8000, 1}, 0}, - {{"GSM", 8000, 1}, 3}, - {{"G723", 8000, 1}, 4}, - {{"DVI4", 8000, 1}, 5}, - {{"DVI4", 16000, 1}, 6}, - {{"LPC", 8000, 1}, 7}, - {{"PCMA", 8000, 1}, 8}, - {{"G722", 8000, 1}, 9}, - {{"L16", 44100, 2}, 10}, - {{"L16", 44100, 1}, 11}, - {{"QCELP", 8000, 1}, 12}, - {{"CN", 8000, 1}, 13}, - // RFC 4566 is a bit ambiguous on the contents of the "encoding - // parameters" field, which, for audio, encodes the number of - // channels. It is "optional and may be omitted if the number of - // channels is one". Does that necessarily imply that an omitted - // encoding parameter means one channel? Since RFC 3551 doesn't - // specify a value for this parameter for MPA, I've included both 0 - // and 1 here, to increase the chances it will be correctly used if - // someone implements an MPEG audio encoder/decoder. - {{"MPA", 90000, 0}, 14}, - {{"MPA", 90000, 1}, 14}, - {{"G728", 8000, 1}, 15}, - {{"DVI4", 11025, 1}, 16}, - {{"DVI4", 22050, 1}, 17}, - {{"G729", 8000, 1}, 18}, + mappings_( + {// Static payload type assignments according to RFC 3551. + {{"PCMU", 8000, 1}, 0}, + {{"GSM", 8000, 1}, 3}, + {{"G723", 8000, 1}, 4}, + {{"DVI4", 8000, 1}, 5}, + {{"DVI4", 16000, 1}, 6}, + {{"LPC", 8000, 1}, 7}, + {{"PCMA", 8000, 1}, 8}, + {{"G722", 8000, 1}, 9}, + {{"L16", 44100, 2}, 10}, + {{"L16", 44100, 1}, 11}, + {{"QCELP", 8000, 1}, 12}, + {{"CN", 8000, 1}, 13}, + // RFC 4566 is a bit ambiguous on the contents of the "encoding + // parameters" field, which, for audio, encodes the number of + // channels. It is "optional and may be omitted if the number of + // channels is one". Does that necessarily imply that an omitted + // encoding parameter means one channel? Since RFC 3551 doesn't + // specify a value for this parameter for MPA, I've included both 0 + // and 1 here, to increase the chances it will be correctly used if + // someone implements an MPEG audio encoder/decoder. + {{"MPA", 90000, 0}, 14}, + {{"MPA", 90000, 1}, 14}, + {{"G728", 8000, 1}, 15}, + {{"DVI4", 11025, 1}, 16}, + {{"DVI4", 22050, 1}, 17}, + {{"G729", 8000, 1}, 18}, - // Payload type assignments currently used by WebRTC. - // Includes data to reduce collisions (and thus reassignments) - {{kGoogleRtpDataCodecName, 0, 0}, kGoogleRtpDataCodecPlType}, - {{kIlbcCodecName, 8000, 1}, 102}, - {{kIsacCodecName, 16000, 1}, 103}, - {{kIsacCodecName, 32000, 1}, 104}, - {{kCnCodecName, 16000, 1}, 105}, - {{kCnCodecName, 32000, 1}, 106}, - {{kGoogleSctpDataCodecName, 0, 0}, kGoogleSctpDataCodecPlType}, - {{kOpusCodecName, 48000, 2, - {{"minptime", "10"}, {"useinbandfec", "1"}}}, 111}, - // TODO(solenberg): Remove the hard coded 16k,32k,48k DTMF once we - // assign payload types dynamically for send side as well. - {{kDtmfCodecName, 48000, 1}, 110}, - {{kDtmfCodecName, 32000, 1}, 112}, - {{kDtmfCodecName, 16000, 1}, 113}, - {{kDtmfCodecName, 8000, 1}, 126}}) { + // Payload type assignments currently used by WebRTC. + // Includes data to reduce collisions (and thus reassignments) + {{kGoogleRtpDataCodecName, 0, 0}, kGoogleRtpDataCodecPlType}, + {{kIlbcCodecName, 8000, 1}, 102}, + {{kIsacCodecName, 16000, 1}, 103}, + {{kIsacCodecName, 32000, 1}, 104}, + {{kCnCodecName, 16000, 1}, 105}, + {{kCnCodecName, 32000, 1}, 106}, + {{kGoogleSctpDataCodecName, 0, 0}, kGoogleSctpDataCodecPlType}, + {{kOpusCodecName, + 48000, + 2, + {{"minptime", "10"}, {"useinbandfec", "1"}}}, + 111}, + // TODO(solenberg): Remove the hard coded 16k,32k,48k DTMF once we + // assign payload types dynamically for send side as well. + {{kDtmfCodecName, 48000, 1}, 110}, + {{kDtmfCodecName, 32000, 1}, 112}, + {{kDtmfCodecName, 16000, 1}, 113}, + {{kDtmfCodecName, 8000, 1}, 126}}) { // TODO(ossu): Try to keep this as change-proof as possible until we're able // to remove the payload type constants from everywhere in the code. for (const auto& mapping : mappings_) { diff --git a/media/engine/payload_type_mapper_unittest.cc b/media/engine/payload_type_mapper_unittest.cc index 96d56c28d2..979ce61dcc 100644 --- a/media/engine/payload_type_mapper_unittest.cc +++ b/media/engine/payload_type_mapper_unittest.cc @@ -22,42 +22,45 @@ class PayloadTypeMapperTest : public testing::Test { }; TEST_F(PayloadTypeMapperTest, StaticPayloadTypes) { - EXPECT_EQ(0, mapper_.FindMappingFor({"pcmu", 8000, 1})); - EXPECT_EQ(3, mapper_.FindMappingFor({"gsm", 8000, 1})); - EXPECT_EQ(4, mapper_.FindMappingFor({"g723", 8000, 1})); - EXPECT_EQ(5, mapper_.FindMappingFor({"dvi4", 8000, 1})); - EXPECT_EQ(6, mapper_.FindMappingFor({"dvi4", 16000, 1})); - EXPECT_EQ(7, mapper_.FindMappingFor({"lpc", 8000, 1})); - EXPECT_EQ(8, mapper_.FindMappingFor({"pcma", 8000, 1})); - EXPECT_EQ(9, mapper_.FindMappingFor({"g722", 8000, 1})); - EXPECT_EQ(10, mapper_.FindMappingFor({"l16", 44100, 2})); - EXPECT_EQ(11, mapper_.FindMappingFor({"l16", 44100, 1})); - EXPECT_EQ(12, mapper_.FindMappingFor({"qcelp", 8000, 1})); - EXPECT_EQ(13, mapper_.FindMappingFor({"cn", 8000, 1})); - EXPECT_EQ(14, mapper_.FindMappingFor({"mpa", 90000, 0})); - EXPECT_EQ(14, mapper_.FindMappingFor({"mpa", 90000, 1})); - EXPECT_EQ(15, mapper_.FindMappingFor({"g728", 8000, 1})); - EXPECT_EQ(16, mapper_.FindMappingFor({"dvi4", 11025, 1})); - EXPECT_EQ(17, mapper_.FindMappingFor({"dvi4", 22050, 1})); - EXPECT_EQ(18, mapper_.FindMappingFor({"g729", 8000, 1})); + EXPECT_EQ(0, mapper_.FindMappingFor({"pcmu", 8000, 1})); + EXPECT_EQ(3, mapper_.FindMappingFor({"gsm", 8000, 1})); + EXPECT_EQ(4, mapper_.FindMappingFor({"g723", 8000, 1})); + EXPECT_EQ(5, mapper_.FindMappingFor({"dvi4", 8000, 1})); + EXPECT_EQ(6, mapper_.FindMappingFor({"dvi4", 16000, 1})); + EXPECT_EQ(7, mapper_.FindMappingFor({"lpc", 8000, 1})); + EXPECT_EQ(8, mapper_.FindMappingFor({"pcma", 8000, 1})); + EXPECT_EQ(9, mapper_.FindMappingFor({"g722", 8000, 1})); + EXPECT_EQ(10, mapper_.FindMappingFor({"l16", 44100, 2})); + EXPECT_EQ(11, mapper_.FindMappingFor({"l16", 44100, 1})); + EXPECT_EQ(12, mapper_.FindMappingFor({"qcelp", 8000, 1})); + EXPECT_EQ(13, mapper_.FindMappingFor({"cn", 8000, 1})); + EXPECT_EQ(14, mapper_.FindMappingFor({"mpa", 90000, 0})); + EXPECT_EQ(14, mapper_.FindMappingFor({"mpa", 90000, 1})); + EXPECT_EQ(15, mapper_.FindMappingFor({"g728", 8000, 1})); + EXPECT_EQ(16, mapper_.FindMappingFor({"dvi4", 11025, 1})); + EXPECT_EQ(17, mapper_.FindMappingFor({"dvi4", 22050, 1})); + EXPECT_EQ(18, mapper_.FindMappingFor({"g729", 8000, 1})); } TEST_F(PayloadTypeMapperTest, WebRTCPayloadTypes) { // Tests that the payload mapper knows about the audio and data formats we've // been using in WebRTC, with their hard coded values. - auto data_mapping = [this] (const char *name) { + auto data_mapping = [this](const char* name) { return mapper_.FindMappingFor({name, 0, 0}); }; EXPECT_EQ(kGoogleRtpDataCodecPlType, data_mapping(kGoogleRtpDataCodecName)); EXPECT_EQ(kGoogleSctpDataCodecPlType, data_mapping(kGoogleSctpDataCodecName)); - EXPECT_EQ(102, mapper_.FindMappingFor({kIlbcCodecName, 8000, 1})); + EXPECT_EQ(102, mapper_.FindMappingFor({kIlbcCodecName, 8000, 1})); EXPECT_EQ(103, mapper_.FindMappingFor({kIsacCodecName, 16000, 1})); EXPECT_EQ(104, mapper_.FindMappingFor({kIsacCodecName, 32000, 1})); - EXPECT_EQ(105, mapper_.FindMappingFor({kCnCodecName, 16000, 1})); - EXPECT_EQ(106, mapper_.FindMappingFor({kCnCodecName, 32000, 1})); - EXPECT_EQ(111, mapper_.FindMappingFor({kOpusCodecName, 48000, 2, - {{"minptime", "10"}, {"useinbandfec", "1"}}})); + EXPECT_EQ(105, mapper_.FindMappingFor({kCnCodecName, 16000, 1})); + EXPECT_EQ(106, mapper_.FindMappingFor({kCnCodecName, 32000, 1})); + EXPECT_EQ(111, mapper_.FindMappingFor( + {kOpusCodecName, + 48000, + 2, + {{"minptime", "10"}, {"useinbandfec", "1"}}})); // TODO(solenberg): Remove 16k, 32k, 48k DTMF checks once these payload types // are dynamically assigned. EXPECT_EQ(110, mapper_.FindMappingFor({kDtmfCodecName, 48000, 1})); @@ -83,7 +86,7 @@ TEST_F(PayloadTypeMapperTest, ValidDynamicPayloadTypes) { std::set used_payload_types; for (int i = 0; i != 256; ++i) { std::string format_name = "unknown_format_" + std::to_string(i); - webrtc::SdpAudioFormat format(format_name.c_str(), i*100, (i % 2) + 1); + webrtc::SdpAudioFormat format(format_name.c_str(), i * 100, (i % 2) + 1); auto opt_payload_type = mapper_.GetMappingFor(format); bool mapper_is_full = false; @@ -124,7 +127,7 @@ TEST_F(PayloadTypeMapperTest, ToAudioCodec) { EXPECT_TRUE(opt_audio_codec); if (opt_payload_type && opt_audio_codec) { - int payload_type = *opt_payload_type; + int payload_type = *opt_payload_type; const AudioCodec& codec = *opt_audio_codec; EXPECT_EQ(codec.id, payload_type); diff --git a/media/engine/scopedvideodecoder.cc b/media/engine/scopedvideodecoder.cc index 636f3e0287..733132b080 100644 --- a/media/engine/scopedvideodecoder.cc +++ b/media/engine/scopedvideodecoder.cc @@ -65,8 +65,8 @@ int32_t ScopedVideoDecoder::Decode( bool missing_frames, const webrtc::CodecSpecificInfo* codec_specific_info, int64_t render_time_ms) { - return decoder_->Decode(input_image, missing_frames, - codec_specific_info, render_time_ms); + return decoder_->Decode(input_image, missing_frames, codec_specific_info, + render_time_ms); } bool ScopedVideoDecoder::PrefersLateDecoding() const { diff --git a/media/engine/simulcast.cc b/media/engine/simulcast.cc index d55ab9f82a..ffc797117b 100644 --- a/media/engine/simulcast.cc +++ b/media/engine/simulcast.cc @@ -53,14 +53,10 @@ struct SimulcastFormat { // simulcast layers at what bitrates (maximum, target, and minimum). // Important!! Keep this table from high resolution to low resolution. const SimulcastFormat kSimulcastFormats[] = { - {1920, 1080, 3, 5000, 4000, 800}, - {1280, 720, 3, 2500, 2500, 600}, - {960, 540, 3, 900, 900, 450}, - {640, 360, 2, 700, 500, 150}, - {480, 270, 2, 450, 350, 150}, - {320, 180, 1, 200, 150, 30}, - {0, 0, 1, 200, 150, 30} -}; + {1920, 1080, 3, 5000, 4000, 800}, {1280, 720, 3, 2500, 2500, 600}, + {960, 540, 3, 900, 900, 450}, {640, 360, 2, 700, 500, 150}, + {480, 270, 2, 450, 350, 150}, {320, 180, 1, 200, 150, 30}, + {0, 0, 1, 200, 150, 30}}; const int kMaxScreenshareSimulcastLayers = 2; diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc index ab06022f24..7a277950dc 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -12,7 +12,6 @@ #include - #include "api/video/i420_buffer.h" #include "api/video/video_bitrate_allocation.h" #include "api/video_codecs/video_encoder_factory.h" diff --git a/media/engine/webrtcmediaengine.cc b/media/engine/webrtcmediaengine.cc index 7b01c3ffb3..82badc1044 100644 --- a/media/engine/webrtcmediaengine.cc +++ b/media/engine/webrtcmediaengine.cc @@ -175,12 +175,12 @@ std::vector FilterRtpExtensions( // Sort by name, ascending (prioritise encryption), so that we don't reset // extensions if they were specified in a different order (also allows us // to use std::unique below). - std::sort(result.begin(), result.end(), - [](const webrtc::RtpExtension& rhs, - const webrtc::RtpExtension& lhs) { - return rhs.encrypt == lhs.encrypt ? rhs.uri < lhs.uri - : rhs.encrypt > lhs.encrypt; - }); + std::sort( + result.begin(), result.end(), + [](const webrtc::RtpExtension& rhs, const webrtc::RtpExtension& lhs) { + return rhs.encrypt == lhs.encrypt ? rhs.uri < lhs.uri + : rhs.encrypt > lhs.encrypt; + }); // Remove unnecessary extensions (used on send side). if (filter_redundant_extensions) { diff --git a/media/engine/webrtcmediaengine.h b/media/engine/webrtcmediaengine.h index 55f29b71bd..b9927b1a9d 100644 --- a/media/engine/webrtcmediaengine.h +++ b/media/engine/webrtcmediaengine.h @@ -25,11 +25,11 @@ class AudioMixer; class AudioProcessing; class VideoDecoderFactory; class VideoEncoderFactory; -} +} // namespace webrtc namespace cricket { class WebRtcVideoDecoderFactory; class WebRtcVideoEncoderFactory; -} +} // namespace cricket namespace cricket { diff --git a/media/engine/webrtcvideocapturer.cc b/media/engine/webrtcvideocapturer.cc index 5bc3f46093..f8a9f748a8 100644 --- a/media/engine/webrtcvideocapturer.cc +++ b/media/engine/webrtcvideocapturer.cc @@ -23,7 +23,7 @@ #if defined(WEBRTC_WIN) #include "rtc_base/win32.h" // Need this to #include the impl files. -#endif // WEBRTC_WIN +#endif // WEBRTC_WIN #include "system_wrappers/include/field_trial.h" namespace cricket { @@ -326,8 +326,7 @@ bool WebRtcVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { return true; } -void WebRtcVideoCapturer::OnFrame( - const webrtc::VideoFrame& sample) { +void WebRtcVideoCapturer::OnFrame(const webrtc::VideoFrame& sample) { // This can only happen between Start() and Stop(). RTC_DCHECK(start_thread_); diff --git a/media/engine/webrtcvideocapturer_unittest.cc b/media/engine/webrtcvideocapturer_unittest.cc index 8770960c4c..e98f1570e7 100644 --- a/media/engine/webrtcvideocapturer_unittest.cc +++ b/media/engine/webrtcvideocapturer_unittest.cc @@ -81,8 +81,7 @@ TEST_F(WebRtcVideoCapturerTest, TestInitVcm) { TEST_F(WebRtcVideoCapturerTest, TestCapture) { EXPECT_TRUE(capturer_->Init(cricket::Device(kTestDeviceName, kTestDeviceId))); cricket::VideoCapturerListener listener(capturer_.get()); - cricket::VideoFormat format( - capturer_->GetSupportedFormats()->at(0)); + cricket::VideoFormat format(capturer_->GetSupportedFormats()->at(0)); EXPECT_EQ(cricket::CS_STARTING, capturer_->Start(format)); EXPECT_TRUE(capturer_->IsRunning()); ASSERT_TRUE(capturer_->GetCaptureFormat() != NULL); diff --git a/media/engine/webrtcvideocapturerfactory.cc b/media/engine/webrtcvideocapturerfactory.cc index c948101ea8..333df6f165 100644 --- a/media/engine/webrtcvideocapturerfactory.cc +++ b/media/engine/webrtcvideocapturerfactory.cc @@ -19,8 +19,7 @@ namespace cricket { std::unique_ptr WebRtcVideoDeviceCapturerFactory::Create( const Device& device) { #ifdef HAVE_WEBRTC_VIDEO - std::unique_ptr capturer( - new WebRtcVideoCapturer()); + std::unique_ptr capturer(new WebRtcVideoCapturer()); if (!capturer->Init(device)) { return std::unique_ptr(); } diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc index aff2529a1b..7c3ecd1f0c 100644 --- a/media/engine/webrtcvideoengine.cc +++ b/media/engine/webrtcvideoengine.cc @@ -187,7 +187,6 @@ void AddDefaultFeedbackParams(VideoCodec* codec) { codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli)); } - // This function will assign dynamic payload types (in the range [96, 127]) to // the input codecs, and also add ULPFEC, RED, FlexFEC, and associated RTX // codecs for recognized codecs (VP8, VP9, H264, and RED). It will also add @@ -590,8 +589,8 @@ RtpCapabilities WebRtcVideoEngine::GetCapabilities() const { webrtc::RtpExtension(webrtc::RtpExtension::kVideoContentTypeUri, webrtc::RtpExtension::kVideoContentTypeDefaultId)); capabilities.header_extensions.push_back( - webrtc::RtpExtension(webrtc::RtpExtension::kVideoTimingUri, - webrtc::RtpExtension::kVideoTimingDefaultId)); + webrtc::RtpExtension(webrtc::RtpExtension::kVideoTimingUri, + webrtc::RtpExtension::kVideoTimingDefaultId)); // TODO(bugs.webrtc.org/4050): Add MID header extension as capability once MID // demuxing is completed. // capabilities.header_extensions.push_back(webrtc::RtpExtension( @@ -663,10 +662,10 @@ bool WebRtcVideoChannel::NonFlexfecReceiveCodecsHaveChanged( // 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; - }; + 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); @@ -1064,8 +1063,7 @@ bool WebRtcVideoChannel::SetVideoSend( rtc::VideoSourceInterface* source) { TRACE_EVENT0("webrtc", "SetVideoSend"); RTC_DCHECK(ssrc != 0); - RTC_LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc - << ", options: " + RTC_LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", options: " << (options ? options->ToString() : "nullptr") << ", source = " << (source ? "(source)" : "nullptr") << ")"; @@ -1128,9 +1126,8 @@ bool WebRtcVideoChannel::AddSendStream(const StreamParams& sp) { WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( call_, sp, std::move(config), default_send_options_, - video_config_.enable_cpu_adaptation, - bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, - send_params_); + video_config_.enable_cpu_adaptation, bitrate_config_.max_bitrate_bps, + send_codec_, send_rtp_extensions_, send_params_); uint32_t ssrc = sp.first_ssrc(); RTC_DCHECK(ssrc != 0); @@ -1385,7 +1382,7 @@ bool WebRtcVideoChannel::GetStats(VideoMediaInfo* info) { } void WebRtcVideoChannel::FillSenderStats(VideoMediaInfo* video_media_info, - bool log_stats) { + bool log_stats) { rtc::CritScope stream_lock(&stream_crit_); for (std::map::iterator it = send_streams_.begin(); @@ -1396,7 +1393,7 @@ void WebRtcVideoChannel::FillSenderStats(VideoMediaInfo* video_media_info, } void WebRtcVideoChannel::FillReceiverStats(VideoMediaInfo* video_media_info, - bool log_stats) { + bool log_stats) { rtc::CritScope stream_lock(&stream_crit_); for (std::map::iterator it = receive_streams_.begin(); @@ -1429,9 +1426,8 @@ void WebRtcVideoChannel::FillSendAndReceiveCodecStats( } } -void WebRtcVideoChannel::OnPacketReceived( - rtc::CopyOnWriteBuffer* packet, - const rtc::PacketTime& packet_time) { +void WebRtcVideoChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet, + const rtc::PacketTime& packet_time) { const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, packet_time.not_before); const webrtc::PacketReceiver::DeliveryStatus delivery_result = @@ -1487,9 +1483,8 @@ void WebRtcVideoChannel::OnPacketReceived( } } -void WebRtcVideoChannel::OnRtcpReceived( - rtc::CopyOnWriteBuffer* packet, - const rtc::PacketTime& packet_time) { +void WebRtcVideoChannel::OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, + const rtc::PacketTime& packet_time) { const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, packet_time.not_before); // TODO(pbos): Check webrtc::PacketReceiver::DELIVERY_OK once we deliver @@ -1519,16 +1514,14 @@ void WebRtcVideoChannel::OnNetworkRouteChanged( void WebRtcVideoChannel::SetInterface(NetworkInterface* iface) { MediaChannel::SetInterface(iface); // Set the RTP recv/send buffer to a bigger size - MediaChannel::SetOption(NetworkInterface::ST_RTP, - rtc::Socket::OPT_RCVBUF, + MediaChannel::SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_RCVBUF, kVideoRtpBufferSize); // 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, + MediaChannel::SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_SNDBUF, kVideoRtpBufferSize); } @@ -1981,8 +1974,8 @@ void WebRtcVideoChannel::WebRtcVideoSendStream::ReconfigureEncoder() { webrtc::VideoEncoderConfig encoder_config = CreateVideoEncoderConfig(codec_settings.codec); - encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( - codec_settings.codec); + encoder_config.encoder_specific_settings = + ConfigureVideoEncoderSettings(codec_settings.codec); stream_->ReconfigureVideoEncoder(encoder_config.Copy()); @@ -2383,8 +2376,7 @@ void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetRecvParameters( } } -void WebRtcVideoChannel::WebRtcVideoReceiveStream:: - RecreateWebRtcVideoStream() { +void WebRtcVideoChannel::WebRtcVideoReceiveStream::RecreateWebRtcVideoStream() { if (stream_) { MaybeDissociateFlexfecFromVideo(); call_->DestroyVideoReceiveStream(stream_); @@ -2504,8 +2496,8 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::GetVideoReceiverInfo( 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; - info.frames_received = stats.frame_counts.key_frames + - stats.frame_counts.delta_frames; + info.frames_received = + stats.frame_counts.key_frames + stats.frame_counts.delta_frames; info.frames_decoded = stats.frames_decoded; info.frames_rendered = stats.frames_rendered; info.qp_sum = stats.qp_sum; @@ -2624,8 +2616,7 @@ WebRtcVideoChannel::MapCodecs(const std::vector& codecs) { RTC_DCHECK(!video_codecs.empty()); for (std::map::const_iterator it = rtx_mapping.begin(); - it != rtx_mapping.end(); - ++it) { + it != rtx_mapping.end(); ++it) { if (!payload_used[it->first]) { RTC_LOG(LS_ERROR) << "RTX mapped to payload not in codec list."; return std::vector(); diff --git a/media/engine/webrtcvideoengine.h b/media/engine/webrtcvideoengine.h index 041eb6a293..f00ebee4f8 100644 --- a/media/engine/webrtcvideoengine.h +++ b/media/engine/webrtcvideoengine.h @@ -42,7 +42,7 @@ class VideoDecoderFactory; class VideoEncoder; class VideoEncoderFactory; struct MediaConfig; -} +} // namespace webrtc namespace rtc { class Thread; @@ -68,8 +68,7 @@ class UnsignalledSsrcHandler { class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler { public: DefaultUnsignalledSsrcHandler(); - Action OnUnsignalledSsrc(WebRtcVideoChannel* channel, - uint32_t ssrc) override; + Action OnUnsignalledSsrc(WebRtcVideoChannel* channel, uint32_t ssrc) override; rtc::VideoSinkInterface* GetDefaultSink() const; void SetDefaultSink(WebRtcVideoChannel* channel, diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc index 2fc5bec31e..52489797ca 100644 --- a/media/engine/webrtcvideoengine_unittest.cc +++ b/media/engine/webrtcvideoengine_unittest.cc @@ -39,8 +39,8 @@ #include "media/engine/webrtcvideoengine.h" #include "media/engine/webrtcvoiceengine.h" #include "rtc_base/arraysize.h" -#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/gunit.h" +#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/stringutils.h" #include "test/field_trial.h" #include "test/gmock.h" @@ -116,9 +116,8 @@ const int* FindKeyByValue(const std::map& m, int v) { return nullptr; } -bool HasRtxReceiveAssociation( - const webrtc::VideoReceiveStream::Config& config, - int payload_type) { +bool HasRtxReceiveAssociation(const webrtc::VideoReceiveStream::Config& config, + int payload_type) { return FindKeyByValue(config.rtp.rtx_associated_payload_types, payload_type) != nullptr; } @@ -164,16 +163,16 @@ cricket::MediaConfig GetMediaConfig() { } // namespace -#define EXPECT_FRAME_WAIT(c, w, h, t) \ +#define EXPECT_FRAME_WAIT(c, w, h, t) \ EXPECT_EQ_WAIT((c), renderer_.num_rendered_frames(), (t)); \ - EXPECT_EQ((w), renderer_.width()); \ - EXPECT_EQ((h), renderer_.height()); \ + EXPECT_EQ((w), renderer_.width()); \ + EXPECT_EQ((h), renderer_.height()); \ EXPECT_EQ(0, renderer_.errors()); -#define EXPECT_FRAME_ON_RENDERER_WAIT(r, c, w, h, t) \ +#define EXPECT_FRAME_ON_RENDERER_WAIT(r, c, w, h, t) \ EXPECT_EQ_WAIT((c), (r).num_rendered_frames(), (t)); \ - EXPECT_EQ((w), (r).width()); \ - EXPECT_EQ((h), (r).height()); \ + EXPECT_EQ((w), (r).width()); \ + EXPECT_EQ((h), (r).height()); \ EXPECT_EQ(0, (r).errors()); namespace cricket { @@ -642,8 +641,7 @@ TEST_F(WebRtcVideoEngineTest, UsesSimulcastAdapterForVp8Factories) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - EXPECT_TRUE( - channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); + EXPECT_TRUE(channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); EXPECT_TRUE(channel->SetSend(true)); FakeVideoCapturerWithTaskQueue capturer; @@ -718,8 +716,7 @@ TEST_F(WebRtcVideoEngineTest, std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - EXPECT_TRUE( - channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); + EXPECT_TRUE(channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); EXPECT_TRUE(channel->SetSend(true)); // Send a fake frame, or else the media engine will configure the simulcast @@ -1168,8 +1165,7 @@ class WebRtcVideoChannelBaseTest : public testing::Test { cricket::VideoFormat::FpsToInterval(kFramerate), cricket::FOURCC_I420); EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format)); - EXPECT_TRUE( - channel_->SetVideoSend(kSsrc, nullptr, video_capturer_.get())); + EXPECT_TRUE(channel_->SetVideoSend(kSsrc, nullptr, video_capturer_.get())); } virtual cricket::FakeVideoCapturerWithTaskQueue* CreateFakeVideoCapturer() { @@ -1190,11 +1186,11 @@ class WebRtcVideoChannelBaseTest : public testing::Test { // This is required if you want to test unsignalled recv of video rtp packets. void SetUpSecondStreamWithNoRecv() { // SetUp() already added kSsrc make sure duplicate SSRCs cant be added. - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(kSsrc))); + EXPECT_TRUE( + channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); - EXPECT_FALSE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrc))); + EXPECT_FALSE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); EXPECT_TRUE(channel_->AddSendStream( cricket::StreamParams::CreateLegacy(kSsrc + 2))); // We dont add recv for the second stream. @@ -1206,15 +1202,11 @@ class WebRtcVideoChannelBaseTest : public testing::Test { cricket::FOURCC_I420); EXPECT_EQ(cricket::CS_RUNNING, video_capturer_2_->Start(format)); - EXPECT_TRUE(channel_->SetVideoSend(kSsrc + 2, nullptr, - video_capturer_2_.get())); - } - virtual void TearDown() { - channel_.reset(); - } - bool SetDefaultCodec() { - return SetOneCodec(DefaultCodec()); + EXPECT_TRUE( + channel_->SetVideoSend(kSsrc + 2, nullptr, video_capturer_2_.get())); } + virtual void TearDown() { channel_.reset(); } + bool SetDefaultCodec() { return SetOneCodec(DefaultCodec()); } bool SetOneCodec(const cricket::VideoCodec& codec) { cricket::VideoFormat capture_format( @@ -1240,9 +1232,7 @@ class WebRtcVideoChannelBaseTest : public testing::Test { } return success; } - bool SetSend(bool send) { - return channel_->SetSend(send); - } + bool SetSend(bool send) { return channel_->SetSend(send); } bool SendFrame() { if (video_capturer_2_) { video_capturer_2_->CaptureFrame(); @@ -1254,21 +1244,15 @@ class WebRtcVideoChannelBaseTest : public testing::Test { ret &= SendFrame(); return ret; } - int NumRtpBytes() { - return network_interface_.NumRtpBytes(); - } + int NumRtpBytes() { return network_interface_.NumRtpBytes(); } int NumRtpBytes(uint32_t ssrc) { return network_interface_.NumRtpBytes(ssrc); } - int NumRtpPackets() { - return network_interface_.NumRtpPackets(); - } + int NumRtpPackets() { return network_interface_.NumRtpPackets(); } int NumRtpPackets(uint32_t ssrc) { return network_interface_.NumRtpPackets(ssrc); } - int NumSentSsrcs() { - return network_interface_.NumSentSsrcs(); - } + int NumSentSsrcs() { return network_interface_.NumSentSsrcs(); } const rtc::CopyOnWriteBuffer* GetRtpPacket(int index) { return network_interface_.GetRtpPacket(index); } @@ -1290,44 +1274,58 @@ class WebRtcVideoChannelBaseTest : public testing::Test { uint32_t u32 = 0; // Read X and CC fields. - if (!buf.ReadUInt8(&u08)) return false; + if (!buf.ReadUInt8(&u08)) + return false; bool extension = ((u08 & 0x10) != 0); uint8_t cc = (u08 & 0x0F); - if (x) *x = extension; + if (x) + *x = extension; // Read PT field. - if (!buf.ReadUInt8(&u08)) return false; - if (pt) *pt = (u08 & 0x7F); + if (!buf.ReadUInt8(&u08)) + return false; + if (pt) + *pt = (u08 & 0x7F); // Read Sequence Number field. - if (!buf.ReadUInt16(&u16)) return false; - if (seqnum) *seqnum = u16; + if (!buf.ReadUInt16(&u16)) + return false; + if (seqnum) + *seqnum = u16; // Read Timestamp field. - if (!buf.ReadUInt32(&u32)) return false; - if (tstamp) *tstamp = u32; + if (!buf.ReadUInt32(&u32)) + return false; + if (tstamp) + *tstamp = u32; // Read SSRC field. - if (!buf.ReadUInt32(&u32)) return false; - if (ssrc) *ssrc = u32; + if (!buf.ReadUInt32(&u32)) + return false; + if (ssrc) + *ssrc = u32; // Skip CSRCs. for (uint8_t i = 0; i < cc; ++i) { - if (!buf.ReadUInt32(&u32)) return false; + if (!buf.ReadUInt32(&u32)) + return false; } // Skip extension header. if (extension) { // Read Profile-specific extension header ID - if (!buf.ReadUInt16(&u16)) return false; + if (!buf.ReadUInt16(&u16)) + return false; // Read Extension header length - if (!buf.ReadUInt16(&u16)) return false; + if (!buf.ReadUInt16(&u16)) + return false; uint16_t ext_header_len = u16; // Read Extension header for (uint16_t i = 0; i < ext_header_len; ++i) { - if (!buf.ReadUInt32(&u32)) return false; + if (!buf.ReadUInt32(&u32)) + return false; } } @@ -1350,7 +1348,8 @@ class WebRtcVideoChannelBaseTest : public testing::Test { } void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec, - int duration_sec, int fps) { + int duration_sec, + int fps) { EXPECT_TRUE(SetOneCodec(codec)); EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); @@ -1365,7 +1364,6 @@ class WebRtcVideoChannelBaseTest : public testing::Test { EXPECT_EQ(codec.id, GetPayloadType(p.get())); } - cricket::VideoSenderInfo GetSenderStats(size_t i) { cricket::VideoMediaInfo info; EXPECT_TRUE(channel_->GetStats(&info)); @@ -1423,8 +1421,7 @@ class WebRtcVideoChannelBaseTest : public testing::Test { // Test that SetSend works. TEST_F(WebRtcVideoChannelBaseTest, SetSend) { EXPECT_FALSE(channel_->sending()); - EXPECT_TRUE( - channel_->SetVideoSend(kSsrc, nullptr, video_capturer_.get())); + EXPECT_TRUE(channel_->SetVideoSend(kSsrc, nullptr, video_capturer_.get())); EXPECT_TRUE(SetOneCodec(DefaultCodec())); EXPECT_FALSE(channel_->sending()); EXPECT_TRUE(SetSend(true)); @@ -1515,10 +1512,8 @@ TEST_F(WebRtcVideoChannelBaseTest, GetStatsMultipleRecvStreams) { parameters.conference_mode = true; EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(SetSend(true)); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(1))); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(2))); + EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); + EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); EXPECT_TRUE(channel_->SetSink(1, &renderer1)); EXPECT_TRUE(channel_->SetSink(2, &renderer2)); EXPECT_EQ(0, renderer1.num_rendered_frames()); @@ -1550,8 +1545,7 @@ TEST_F(WebRtcVideoChannelBaseTest, GetStatsMultipleRecvStreams) { EXPECT_EQ(1U, GetReceiverStats(i).ssrcs().size()); EXPECT_EQ(i + 1, GetReceiverStats(i).ssrcs()[0]); EXPECT_EQ_WAIT(NumRtpBytes(), GetReceiverStats(i).bytes_rcvd, kTimeout); - EXPECT_EQ_WAIT(NumRtpPackets(), GetReceiverStats(i).packets_rcvd, - kTimeout); + EXPECT_EQ_WAIT(NumRtpPackets(), GetReceiverStats(i).packets_rcvd, kTimeout); EXPECT_EQ_WAIT(kVideoWidth, GetReceiverStats(i).frame_width, kTimeout); EXPECT_EQ_WAIT(kVideoHeight, GetReceiverStats(i).frame_height, kTimeout); } @@ -1566,8 +1560,8 @@ TEST_F(WebRtcVideoChannelBaseTest, GetStatsMultipleSendStreams) { parameters.codecs.push_back(DefaultCodec()); parameters.conference_mode = true; EXPECT_TRUE(channel_->SetSendParameters(parameters)); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(kSsrc))); + EXPECT_TRUE( + channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(SendFrame()); @@ -1584,15 +1578,15 @@ TEST_F(WebRtcVideoChannelBaseTest, GetStatsMultipleSendStreams) { cricket::VideoFormat::FpsToInterval(5), cricket::FOURCC_I420); EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(5678))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(5678))); EXPECT_TRUE(channel_->SetVideoSend(5678, nullptr, capturer.get())); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(5678))); + EXPECT_TRUE( + channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(5678))); EXPECT_TRUE(channel_->SetSink(5678, &renderer2)); EXPECT_TRUE(capturer->CaptureCustomFrame(kTestWidth, kTestHeight)); - EXPECT_FRAME_ON_RENDERER_WAIT( - renderer2, 1, kTestWidth, kTestHeight, kTimeout); + EXPECT_FRAME_ON_RENDERER_WAIT(renderer2, 1, kTestWidth, kTestHeight, + kTimeout); // Get stats, and make sure they are correct for two senders. We wait until // the number of expected packets have been sent to avoid races where we @@ -1658,10 +1652,9 @@ TEST_F(WebRtcVideoChannelBaseTest, SetSendSsrcAfterSetCodecs) { // Remove stream added in Setup. EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); EXPECT_TRUE(SetDefaultCodec()); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(999))); EXPECT_TRUE( - channel_->SetVideoSend(999u, nullptr, video_capturer_.get())); + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(999))); + EXPECT_TRUE(channel_->SetVideoSend(999u, nullptr, video_capturer_.get())); EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(WaitAndSendFrame(0)); EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); @@ -1681,8 +1674,8 @@ TEST_F(WebRtcVideoChannelBaseTest, SetSendSsrcAfterSetCodecs) { // Test that we can set the default video renderer before and after // media is received. TEST_F(WebRtcVideoChannelBaseTest, SetSink) { - uint8_t data1[] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t data1[] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; rtc::CopyOnWriteBuffer packet1(data1, sizeof(data1)); rtc::SetBE32(packet1.data() + 8, kSsrc); @@ -1706,8 +1699,8 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveSendStreams) { EXPECT_GT(NumRtpPackets(), 0); uint32_t ssrc = 0; size_t last_packet = NumRtpPackets() - 1; - std::unique_ptr - p(GetRtpPacket(static_cast(last_packet))); + std::unique_ptr p( + GetRtpPacket(static_cast(last_packet))); ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); EXPECT_EQ(kSsrc, ssrc); @@ -1715,10 +1708,9 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveSendStreams) { EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); int rtp_packets = NumRtpPackets(); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(789u))); EXPECT_TRUE( - channel_->SetVideoSend(789u, nullptr, video_capturer_.get())); + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(789u))); + EXPECT_TRUE(channel_->SetVideoSend(789u, nullptr, video_capturer_.get())); EXPECT_EQ(rtp_packets, NumRtpPackets()); // Wait 30ms to guarantee the engine does not drop the frame. EXPECT_TRUE(WaitAndSendFrame(30)); @@ -1739,10 +1731,8 @@ TEST_F(WebRtcVideoChannelBaseTest, SimulateConference) { parameters.conference_mode = true; EXPECT_TRUE(channel_->SetSendParameters(parameters)); EXPECT_TRUE(SetSend(true)); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(1))); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(2))); + EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); + EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); EXPECT_TRUE(channel_->SetSink(1, &renderer1)); EXPECT_TRUE(channel_->SetSink(2, &renderer2)); EXPECT_EQ(0, renderer1.num_rendered_frames()); @@ -1807,9 +1797,10 @@ TEST_F(WebRtcVideoChannelBaseTest, DISABLED_AddRemoveCapturer) { ++captured_frames; // Wait until frame of right size is captured. EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= captured_frames && - format.width == renderer_.width() && - format.height == renderer_.height() && - !renderer_.black_frame(), kTimeout); + format.width == renderer_.width() && + format.height == renderer_.height() && + !renderer_.black_frame(), + kTimeout); EXPECT_GE(renderer_.num_rendered_frames(), captured_frames); EXPECT_EQ(format.width, renderer_.width()); EXPECT_EQ(format.height, renderer_.height()); @@ -1820,9 +1811,10 @@ TEST_F(WebRtcVideoChannelBaseTest, DISABLED_AddRemoveCapturer) { // The black frame should be the resolution of the previous frame to // prevent expensive encoder reconfigurations. EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= captured_frames && - format.width == renderer_.width() && - format.height == renderer_.height() && - renderer_.black_frame(), kTimeout); + format.width == renderer_.width() && + format.height == renderer_.height() && + renderer_.black_frame(), + kTimeout); EXPECT_GE(renderer_.num_rendered_frames(), captured_frames); EXPECT_EQ(format.width, renderer_.width()); EXPECT_EQ(format.height, renderer_.height()); @@ -1866,8 +1858,8 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveCapturerMultipleSources) { // WebRTC implementation will drop frames if pushed to quickly. Wait the // interval time to avoid that. // Set up the stream associated with the engine. - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(kSsrc))); + EXPECT_TRUE( + channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); cricket::VideoFormat capture_format( kVideoWidth, kVideoHeight, @@ -1875,22 +1867,18 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveCapturerMultipleSources) { // Set up additional stream 1. cricket::FakeVideoRenderer renderer1; EXPECT_FALSE(channel_->SetSink(1, &renderer1)); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(1))); + EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); EXPECT_TRUE(channel_->SetSink(1, &renderer1)); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(1))); + EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); std::unique_ptr capturer1( CreateFakeVideoCapturer()); EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format)); // Set up additional stream 2. cricket::FakeVideoRenderer renderer2; EXPECT_FALSE(channel_->SetSink(2, &renderer2)); - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(2))); + EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); EXPECT_TRUE(channel_->SetSink(2, &renderer2)); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(2))); + EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); std::unique_ptr capturer2( CreateFakeVideoCapturer()); EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format)); @@ -1906,12 +1894,12 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveCapturerMultipleSources) { const int kTestWidth = 160; const int kTestHeight = 120; EXPECT_TRUE(capturer1->CaptureCustomFrame(kTestWidth, kTestHeight)); - EXPECT_FRAME_ON_RENDERER_WAIT( - renderer1, 1, kTestWidth, kTestHeight, kTimeout); + EXPECT_FRAME_ON_RENDERER_WAIT(renderer1, 1, kTestWidth, kTestHeight, + kTimeout); // Capture a frame with additional capturer2, frames should be received EXPECT_TRUE(capturer2->CaptureCustomFrame(kTestWidth, kTestHeight)); - EXPECT_FRAME_ON_RENDERER_WAIT( - renderer2, 1, kTestWidth, kTestHeight, kTimeout); + EXPECT_FRAME_ON_RENDERER_WAIT(renderer2, 1, kTestWidth, kTestHeight, + kTimeout); // Successfully remove the capturer. EXPECT_TRUE(channel_->SetVideoSend(kSsrc, nullptr, nullptr)); // The capturers must be unregistered here as it runs out of it's scope @@ -1927,8 +1915,8 @@ TEST_F(WebRtcVideoChannelBaseTest, RejectEmptyStreamParams) { cricket::StreamParams empty; EXPECT_FALSE(channel_->AddSendStream(empty)); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(789u))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(789u))); } // Test that multiple send streams can be created and deleted properly. @@ -1936,7 +1924,7 @@ TEST_F(WebRtcVideoChannelBaseTest, MultipleSendStreams) { // Remove stream added in Setup. I.e. remove stream corresponding to default // channel. EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); - const unsigned int kSsrcsSize = sizeof(kSsrcs4)/sizeof(kSsrcs4[0]); + const unsigned int kSsrcsSize = sizeof(kSsrcs4) / sizeof(kSsrcs4[0]); for (unsigned int i = 0; i < kSsrcsSize; ++i) { EXPECT_TRUE(channel_->AddSendStream( cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); @@ -2271,7 +2259,7 @@ TEST_F(WebRtcVideoChannelTest, RecvStreamWithSimAndRtx) { EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) << "RTX should be mapped for all decoders/payload types."; EXPECT_TRUE(HasRtxReceiveAssociation(recv_stream->GetConfig(), - GetEngineCodec("red").id)) + GetEngineCodec("red").id)) << "RTX should be mapped for the RED payload type"; EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); @@ -2288,7 +2276,7 @@ TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) { EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) << "RTX should be mapped for all decoders/payload types."; EXPECT_TRUE(HasRtxReceiveAssociation(recv_stream->GetConfig(), - GetEngineCodec("red").id)) + GetEngineCodec("red").id)) << "RTX should be mapped for the RED payload type"; } @@ -2672,8 +2660,8 @@ TEST_F(WebRtcVideoChannelTest, UsesCorrectSettingsForScreencast) { FakeVideoCapturerWithTaskQueue capturer; VideoOptions min_bitrate_options; min_bitrate_options.screencast_min_bitrate_kbps = kScreenshareMinBitrateKbps; - EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, &min_bitrate_options, - &capturer)); + EXPECT_TRUE( + channel_->SetVideoSend(last_ssrc_, &min_bitrate_options, &capturer)); cricket::VideoFormat capture_format_hd = capturer.GetSupportedFormats()->front(); EXPECT_EQ(1280, capture_format_hd.width); @@ -3221,8 +3209,7 @@ TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) { ASSERT_TRUE(channel_->SetSend(true)); cricket::VideoOptions camera_options; camera_options.is_screencast = false; - channel_->SetVideoSend(last_ssrc_, &camera_options, - &capturer); + channel_->SetVideoSend(last_ssrc_, &camera_options, &capturer); ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); @@ -3248,8 +3235,7 @@ TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) { screen_share.Start(screen_share.GetSupportedFormats()->front())); cricket::VideoOptions screenshare_options; screenshare_options.is_screencast = true; - channel_->SetVideoSend(last_ssrc_, &screenshare_options, - &screen_share); + channel_->SetVideoSend(last_ssrc_, &screenshare_options, &screen_share); EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724)); ASSERT_EQ(2, fake_call_->GetNumCreatedSendStreams()); send_stream = fake_call_->GetVideoSendStreams().front(); @@ -3258,8 +3244,7 @@ TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) { EXPECT_EQ(724, send_stream->GetLastHeight()); // Switch back to the normal capturer. Expect the frame to be CPU adapted. - channel_->SetVideoSend(last_ssrc_, &camera_options, - &capturer); + channel_->SetVideoSend(last_ssrc_, &camera_options, &capturer); send_stream = fake_call_->GetVideoSendStreams().front(); // We have a new fake send stream, so it doesn't remember the old sink wants. // In practice, it will be populated from @@ -3481,8 +3466,7 @@ TEST_F(WebRtcVideoChannelTest, SetDefaultSendCodecs) { // when the field trials are not enabled. // TODO(brandtr): Remove or update these tests when FlexFEC _is_ enabled by // default. -TEST_F(WebRtcVideoChannelTest, - FlexfecSendCodecWithoutSsrcNotExposedByDefault) { +TEST_F(WebRtcVideoChannelTest, FlexfecSendCodecWithoutSsrcNotExposedByDefault) { FakeVideoSendStream* stream = AddSendStream(); webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); @@ -3501,8 +3485,7 @@ TEST_F(WebRtcVideoChannelTest, FlexfecSendCodecWithSsrcNotExposedByDefault) { EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty()); } -TEST_F(WebRtcVideoChannelTest, - FlexfecRecvCodecWithoutSsrcNotExposedByDefault) { +TEST_F(WebRtcVideoChannelTest, FlexfecRecvCodecWithoutSsrcNotExposedByDefault) { AddRecvStream(); const std::vector& streams = @@ -3645,8 +3628,7 @@ class WebRtcVideoChannelFlexfecSendRecvTest : public WebRtcVideoChannelTest { } }; -TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, - SetDefaultSendCodecsWithoutSsrc) { +TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetDefaultSendCodecsWithoutSsrc) { FakeVideoSendStream* stream = AddSendStream(); webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); @@ -3962,8 +3944,7 @@ TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithBitratesAndMaxSendBandwidth) { EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); } -TEST_F(WebRtcVideoChannelTest, - SetMaxSendBandwidthShouldPreserveOtherBitrates) { +TEST_F(WebRtcVideoChannelTest, SetMaxSendBandwidthShouldPreserveOtherBitrates) { SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 200000); send_parameters_.max_bandwidth_bps = 300000; @@ -4146,9 +4127,9 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithRtx) { rtx_codec2.SetParam("apt", rtx_codec.id); parameters.codecs.push_back(rtx_codec2); - EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << - "RTX codec with another RTX as associated payload type should be " - "rejected."; + EXPECT_FALSE(channel_->SetRecvParameters(parameters)) + << "RTX codec with another RTX as associated payload type should be " + "rejected."; } TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithChangedRtxPayloadType) { @@ -4623,8 +4604,7 @@ TEST_F(WebRtcVideoChannelTest, info.senders[0].adapt_reason); } -TEST_F(WebRtcVideoChannelTest, - GetStatsTranslatesSendRtcpPacketTypesCorrectly) { +TEST_F(WebRtcVideoChannelTest, GetStatsTranslatesSendRtcpPacketTypesCorrectly) { FakeVideoSendStream* stream = AddSendStream(); webrtc::VideoSendStream::Stats stats; stats.substreams[17].rtcp_packet_type_counts.fir_packets = 2; @@ -4813,7 +4793,7 @@ TEST_F(WebRtcVideoChannelTest, DefaultReceiveStreamReconfiguresToUseRtx) { EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) << "RTX should be mapped for all decoders/payload types."; EXPECT_TRUE(HasRtxReceiveAssociation(recv_stream->GetConfig(), - GetEngineCodec("red").id)) + GetEngineCodec("red").id)) << "RTX should be mapped also for the RED payload type"; EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); } @@ -5066,15 +5046,14 @@ TEST_F(WebRtcVideoChannelTest, ReceiveDifferentUnsignaledSsrc) { cricket::RtpHeader rtpHeader; rtpHeader.payload_type = GetEngineCodec("VP8").id; rtpHeader.seq_num = rtpHeader.timestamp = 0; - rtpHeader.ssrc = kIncomingUnsignalledSsrc+1; + rtpHeader.ssrc = kIncomingUnsignalledSsrc + 1; cricket::SetRtpHeader(data, sizeof(data), rtpHeader); rtc::CopyOnWriteBuffer packet(data, sizeof(data)); rtc::PacketTime packet_time; channel_->OnPacketReceived(&packet, packet_time); // VP8 packet should create default receive stream. ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); - FakeVideoReceiveStream* recv_stream = - fake_call_->GetVideoReceiveStreams()[0]; + FakeVideoReceiveStream* recv_stream = fake_call_->GetVideoReceiveStreams()[0]; EXPECT_EQ(rtpHeader.ssrc, recv_stream->GetConfig().rtp.remote_ssrc); // Verify that the receive stream sinks to a renderer. webrtc::VideoFrame video_frame(CreateBlackFrameBuffer(4, 4), 100, 0, @@ -5084,7 +5063,7 @@ TEST_F(WebRtcVideoChannelTest, ReceiveDifferentUnsignaledSsrc) { // Receive VP9 packet on second SSRC. rtpHeader.payload_type = GetEngineCodec("VP9").id; - rtpHeader.ssrc = kIncomingUnsignalledSsrc+2; + rtpHeader.ssrc = kIncomingUnsignalledSsrc + 2; cricket::SetRtpHeader(data, sizeof(data), rtpHeader); rtc::CopyOnWriteBuffer packet2(data, sizeof(data)); channel_->OnPacketReceived(&packet2, packet_time); @@ -5101,7 +5080,7 @@ TEST_F(WebRtcVideoChannelTest, ReceiveDifferentUnsignaledSsrc) { #if defined(WEBRTC_USE_H264) // Receive H264 packet on third SSRC. rtpHeader.payload_type = 126; - rtpHeader.ssrc = kIncomingUnsignalledSsrc+3; + rtpHeader.ssrc = kIncomingUnsignalledSsrc + 3; cricket::SetRtpHeader(data, sizeof(data), rtpHeader); rtc::CopyOnWriteBuffer packet3(data, sizeof(data)); channel_->OnPacketReceived(&packet3, packet_time); @@ -5760,15 +5739,13 @@ void WebRtcVideoChannelTest::TestReceiverLocalSsrcConfiguration( // local send stream's SSRC. AddSendStream(StreamParams::CreateLegacy(kSecondSenderSsrc)); ASSERT_TRUE(channel_->RemoveSendStream(kSenderSsrc)); - receive_streams = - fake_call_->GetVideoReceiveStreams(); + receive_streams = fake_call_->GetVideoReceiveStreams(); ASSERT_EQ(1u, receive_streams.size()); EXPECT_EQ(kSecondSenderSsrc, receive_streams[0]->GetConfig().rtp.local_ssrc); // Removing the last sender should fall back to default local SSRC. ASSERT_TRUE(channel_->RemoveSendStream(kSecondSenderSsrc)); - receive_streams = - fake_call_->GetVideoReceiveStreams(); + receive_streams = fake_call_->GetVideoReceiveStreams(); ASSERT_EQ(1u, receive_streams.size()); EXPECT_EQ(kExpectedDefaultReceiverSsrc, receive_streams[0]->GetConfig().rtp.local_ssrc); @@ -5826,8 +5803,7 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test { VideoOptions options; if (screenshare) options.is_screencast = screenshare; - EXPECT_TRUE( - channel_->SetVideoSend(ssrcs.front(), &options, &capturer)); + EXPECT_TRUE(channel_->SetVideoSend(ssrcs.front(), &options, &capturer)); // Fetch the latest stream since SetVideoSend() may recreate it if the // screen content setting is changed. FakeVideoSendStream* stream = fake_call_.GetVideoSendStreams().front(); @@ -5929,8 +5905,7 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test { } FakeVideoSendStream* AddSendStream(const StreamParams& sp) { - size_t num_streams = - fake_call_.GetVideoSendStreams().size(); + size_t num_streams = fake_call_.GetVideoSendStreams().size(); EXPECT_TRUE(channel_->AddSendStream(sp)); std::vector streams = fake_call_.GetVideoSendStreams(); @@ -5947,8 +5922,7 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test { } FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { - size_t num_streams = - fake_call_.GetVideoReceiveStreams().size(); + size_t num_streams = fake_call_.GetVideoReceiveStreams().size(); EXPECT_TRUE(channel_->AddRecvStream(sp)); std::vector streams = fake_call_.GetVideoReceiveStreams(); diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc index fd34d08541..8367f028cd 100644 --- a/media/engine/webrtcvoiceengine.cc +++ b/media/engine/webrtcvoiceengine.cc @@ -70,7 +70,7 @@ const int kOpusBitrateFbBps = 32000; // See also http://tools.ietf.org/html/draft-jennings-rtcweb-qos-00 const rtc::DiffServCodePoint kAudioDscpValue = rtc::DSCP_EF; -const int kMinTelephoneEventCode = 0; // RFC4733 (Section 2.3.1) +const int kMinTelephoneEventCode = 0; // RFC4733 (Section 2.3.1) const int kMaxTelephoneEventCode = 255; const int kMinPayloadType = 0; @@ -305,8 +305,8 @@ void WebRtcVoiceEngine::Init() { initialized_ = true; } -rtc::scoped_refptr - WebRtcVoiceEngine::GetAudioState() const { +rtc::scoped_refptr WebRtcVoiceEngine::GetAudioState() + const { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return audio_state_; } @@ -436,8 +436,8 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { << "Disabling EC since built-in EC will be used instead"; } } - webrtc::apm_helpers::SetEcStatus( - apm(), *options.echo_cancellation, ec_mode); + webrtc::apm_helpers::SetEcStatus(apm(), *options.echo_cancellation, + ec_mode); #if !defined(WEBRTC_ANDROID) webrtc::apm_helpers::SetEcMetricsStatus(apm(), *options.echo_cancellation); #endif @@ -524,8 +524,8 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { if (options.typing_detection) { RTC_LOG(LS_INFO) << "Typing detection is enabled? " << *options.typing_detection; - webrtc::apm_helpers::SetTypingDetectionStatus( - apm(), *options.typing_detection); + webrtc::apm_helpers::SetTypingDetectionStatus(apm(), + *options.typing_detection); } webrtc::Config config; @@ -672,14 +672,11 @@ AudioCodecs WebRtcVoiceEngine::CollectCodecs( AudioCodecs out; // Only generate CN payload types for these clockrates: - std::map> generate_cn = {{ 8000, false }, - { 16000, false }, - { 32000, false }}; + std::map> generate_cn = { + {8000, false}, {16000, false}, {32000, false}}; // Only generate telephone-event payload types for these clockrates: - std::map> generate_dtmf = {{ 8000, false }, - { 16000, false }, - { 32000, false }, - { 48000, false }}; + std::map> generate_dtmf = { + {8000, false}, {16000, false}, {32000, false}, {48000, false}}; auto map_format = [&mapper](const webrtc::SdpAudioFormat& format, AudioCodecs* out) { @@ -845,7 +842,9 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream return true; } - bool SendTelephoneEvent(int payload_type, int payload_freq, int event, + bool SendTelephoneEvent(int payload_type, + int payload_freq, + int event, int duration_ms) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(stream_); @@ -916,13 +915,10 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream RTC_CHECK_RUNS_SERIALIZED(&audio_capture_race_checker_); RTC_DCHECK(stream_); std::unique_ptr audio_frame(new webrtc::AudioFrame()); - audio_frame->UpdateFrame(audio_frame->timestamp_, - static_cast(audio_data), - number_of_frames, - sample_rate, - audio_frame->speech_type_, - audio_frame->vad_activity_, - number_of_channels); + audio_frame->UpdateFrame( + audio_frame->timestamp_, static_cast(audio_data), + number_of_frames, sample_rate, audio_frame->speech_type_, + audio_frame->vad_activity_, number_of_channels); stream_->SendAudioData(std::move(audio_frame)); } @@ -1335,9 +1331,8 @@ bool WebRtcVoiceMediaChannel::SetSendParameters( if (!ValidateRtpExtensions(params.extensions)) { return false; } - std::vector filtered_extensions = - FilterRtpExtensions(params.extensions, - webrtc::RtpExtension::IsSupportedForAudio, true); + std::vector filtered_extensions = FilterRtpExtensions( + params.extensions, webrtc::RtpExtension::IsSupportedForAudio, true); if (send_rtp_extensions_ != filtered_extensions) { send_rtp_extensions_.swap(filtered_extensions); for (auto& it : send_streams_) { @@ -1373,9 +1368,8 @@ bool WebRtcVoiceMediaChannel::SetRecvParameters( if (!ValidateRtpExtensions(params.extensions)) { return false; } - std::vector filtered_extensions = - FilterRtpExtensions(params.extensions, - webrtc::RtpExtension::IsSupportedForAudio, false); + std::vector filtered_extensions = FilterRtpExtensions( + params.extensions, webrtc::RtpExtension::IsSupportedForAudio, false); if (recv_rtp_extensions_ != filtered_extensions) { recv_rtp_extensions_.swap(filtered_extensions); for (auto& it : recv_streams_) { @@ -1984,7 +1978,8 @@ bool WebRtcVoiceMediaChannel::CanInsertDtmf() { return dtmf_payload_type_.has_value() && send_; } -bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, int event, +bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, + int event, int duration) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::InsertDtmf"; @@ -1998,8 +1993,7 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, int event, RTC_LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; return false; } - if (event < kMinTelephoneEventCode || - event > kMaxTelephoneEventCode) { + if (event < kMinTelephoneEventCode || event > kMaxTelephoneEventCode) { RTC_LOG(LS_WARNING) << "DTMF event code " << event << " out of range."; return false; } @@ -2009,7 +2003,8 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, int event, } void WebRtcVoiceMediaChannel::OnPacketReceived( - rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) { + rtc::CopyOnWriteBuffer* packet, + const rtc::PacketTime& packet_time) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, @@ -2029,7 +2024,8 @@ void WebRtcVoiceMediaChannel::OnPacketReceived( return; } RTC_DCHECK(std::find(unsignaled_recv_ssrcs_.begin(), - unsignaled_recv_ssrcs_.end(), ssrc) == unsignaled_recv_ssrcs_.end()); + unsignaled_recv_ssrcs_.end(), + ssrc) == unsignaled_recv_ssrcs_.end()); // Add new stream. StreamParams sp = unsignaled_stream_params_; @@ -2040,9 +2036,8 @@ void WebRtcVoiceMediaChannel::OnPacketReceived( return; } unsignaled_recv_ssrcs_.push_back(ssrc); - RTC_HISTOGRAM_COUNTS_LINEAR( - "WebRTC.Audio.NumOfUnsignaledStreams", unsignaled_recv_ssrcs_.size(), 1, - 100, 101); + RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.NumOfUnsignaledStreams", + unsignaled_recv_ssrcs_.size(), 1, 100, 101); // Remove oldest unsignaled stream, if we have too many. if (unsignaled_recv_ssrcs_.size() > kMaxUnsignaledRecvStreams) { @@ -2074,7 +2069,8 @@ void WebRtcVoiceMediaChannel::OnPacketReceived( } void WebRtcVoiceMediaChannel::OnRtcpReceived( - rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) { + rtc::CopyOnWriteBuffer* packet, + const rtc::PacketTime& packet_time) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); // Forward packet to Call as well. @@ -2275,12 +2271,11 @@ std::vector WebRtcVoiceMediaChannel::GetSources( return it->second->GetSources(); } -bool WebRtcVoiceMediaChannel:: - MaybeDeregisterUnsignaledRecvStream(uint32_t ssrc) { +bool WebRtcVoiceMediaChannel::MaybeDeregisterUnsignaledRecvStream( + uint32_t ssrc) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); auto it = std::find(unsignaled_recv_ssrcs_.begin(), - unsignaled_recv_ssrcs_.end(), - ssrc); + unsignaled_recv_ssrcs_.end(), ssrc); if (it != unsignaled_recv_ssrcs_.end()) { unsignaled_recv_ssrcs_.erase(it); return true; diff --git a/media/engine/webrtcvoiceengine.h b/media/engine/webrtcvoiceengine.h index a95ff9f83a..cd0c55c011 100644 --- a/media/engine/webrtcvoiceengine.h +++ b/media/engine/webrtcvoiceengine.h @@ -42,6 +42,7 @@ class WebRtcVoiceMediaChannel; // It uses the WebRtc VoiceEngine library for audio handling. class WebRtcVoiceEngine final { friend class WebRtcVoiceMediaChannel; + public: WebRtcVoiceEngine( webrtc::AudioDeviceModule* adm, diff --git a/media/engine/webrtcvoiceengine_unittest.cc b/media/engine/webrtcvoiceengine_unittest.cc index b03af34661..4e20dfc16a 100644 --- a/media/engine/webrtcvoiceengine_unittest.cc +++ b/media/engine/webrtcvoiceengine_unittest.cc @@ -54,10 +54,16 @@ const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1); const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1); const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); -const cricket::AudioCodec - kTelephoneEventCodec1(106, "telephone-event", 8000, 0, 1); -const cricket::AudioCodec - kTelephoneEventCodec2(107, "telephone-event", 32000, 0, 1); +const cricket::AudioCodec kTelephoneEventCodec1(106, + "telephone-event", + 8000, + 0, + 1); +const cricket::AudioCodec kTelephoneEventCodec2(107, + "telephone-event", + 32000, + 0, + 1); const uint32_t kSsrc0 = 0; const uint32_t kSsrc1 = 1; @@ -65,7 +71,7 @@ const uint32_t kSsrcX = 0x99; const uint32_t kSsrcY = 0x17; const uint32_t kSsrcZ = 0x42; const uint32_t kSsrcW = 0x02; -const uint32_t kSsrcs4[] = { 11, 200, 30, 44 }; +const uint32_t kSsrcs4[] = {11, 200, 30, 44}; constexpr int kRtpHistoryMs = 5000; @@ -87,10 +93,11 @@ void AdmSetupExpectations(webrtc::test::MockAudioDeviceModule* adm) { EXPECT_CALL(*adm, Init()).WillOnce(Return(0)); EXPECT_CALL(*adm, RegisterAudioCallback(_)).WillOnce(Return(0)); #if defined(WEBRTC_WIN) - EXPECT_CALL(*adm, SetPlayoutDevice( - testing::Matcher( - webrtc::AudioDeviceModule::kDefaultCommunicationDevice))) - .WillOnce(Return(0)); + EXPECT_CALL( + *adm, SetPlayoutDevice( + testing::Matcher( + webrtc::AudioDeviceModule::kDefaultCommunicationDevice))) + .WillOnce(Return(0)); #else EXPECT_CALL(*adm, SetPlayoutDevice(0)).WillOnce(Return(0)); #endif // #if defined(WEBRTC_WIN) @@ -98,10 +105,11 @@ void AdmSetupExpectations(webrtc::test::MockAudioDeviceModule* adm) { EXPECT_CALL(*adm, StereoPlayoutIsAvailable(testing::_)).WillOnce(Return(0)); EXPECT_CALL(*adm, SetStereoPlayout(false)).WillOnce(Return(0)); #if defined(WEBRTC_WIN) - EXPECT_CALL(*adm, SetRecordingDevice( - testing::Matcher( - webrtc::AudioDeviceModule::kDefaultCommunicationDevice))) - .WillOnce(Return(0)); + EXPECT_CALL( + *adm, SetRecordingDevice( + testing::Matcher( + webrtc::AudioDeviceModule::kDefaultCommunicationDevice))) + .WillOnce(Return(0)); #else EXPECT_CALL(*adm, SetRecordingDevice(0)).WillOnce(Return(0)); #endif // #if defined(WEBRTC_WIN) @@ -117,7 +125,8 @@ void AdmSetupExpectations(webrtc::test::MockAudioDeviceModule* adm) { EXPECT_CALL(*adm, StopRecording()).WillOnce(Return(0)); EXPECT_CALL(*adm, RegisterAudioCallback(nullptr)).WillOnce(Return(0)); EXPECT_CALL(*adm, Terminate()).WillOnce(Return(0)); - EXPECT_CALL(*adm, Release()).Times(3) + EXPECT_CALL(*adm, Release()) + .Times(3) .WillRepeatedly(Return(rtc::RefCountReleaseStatus::kDroppedLastRef)); } } // namespace @@ -250,9 +259,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { channel_->OnPacketReceived(&packet, rtc::PacketTime()); } - void TearDown() override { - delete channel_; - } + void TearDown() override { delete channel_; } const cricket::FakeAudioSendStream& GetSendStream(uint32_t ssrc) { const auto* send_stream = call_.GetAudioSendStream(ssrc); @@ -291,7 +298,9 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_TRUE(channel_->SetSendParameters(params)); } - void SetAudioSend(uint32_t ssrc, bool enable, cricket::AudioSource* source, + void SetAudioSend(uint32_t ssrc, + bool enable, + cricket::AudioSource* source, const cricket::AudioOptions* options = nullptr) { EXPECT_CALL(*apm_, set_output_will_be_muted(!enable)); ASSERT_TRUE(channel_); @@ -301,14 +310,15 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source)); } - void TestInsertDtmf(uint32_t ssrc, bool caller, + void TestInsertDtmf(uint32_t ssrc, + bool caller, const cricket::AudioCodec& codec) { EXPECT_TRUE(SetupChannel()); if (caller) { // If this is a caller, local description will be applied and add the // send stream. - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcX))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcX))); } // Test we can only InsertDtmf when the other side supports telephone-event. @@ -323,8 +333,8 @@ class WebRtcVoiceEngineTestFake : public testing::Test { if (!caller) { // If this is callee, there's no active send channel yet. EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcX))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcX))); } // Check we fail if the ssrc is invalid. @@ -470,8 +480,8 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_EQ(id, GetSendStreamConfig(kSsrcX).rtp.extensions[0].id); // Ensure extension is set properly on new stream. - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcY))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcY))); EXPECT_NE(call_.GetAudioSendStream(kSsrcX), call_.GetAudioSendStream(kSsrcY)); EXPECT_EQ(1u, GetSendStreamConfig(kSsrcY).rtp.extensions.size()); @@ -991,8 +1001,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { parameters.max_bandwidth_bps = kDesiredBitrate; SetSendParameters(parameters); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcX))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcX))); EXPECT_EQ(kDesiredBitrate, GetCodecBitrate(kSsrcX)); } @@ -1563,8 +1573,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCapsMinAndStartBitrate) { SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); } -TEST_F(WebRtcVoiceEngineTestFake, - SetMaxSendBandwidthForAudioDoesntAffectBwe) { +TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthForAudioDoesntAffectBwe) { SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 200000); send_parameters_.max_bandwidth_bps = 100000; @@ -1583,9 +1592,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); - parameters.codecs[0].AddFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + parameters.codecs[0].AddFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); EXPECT_EQ(0, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); SetSendParameters(parameters); EXPECT_EQ(kRtpHistoryMs, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); @@ -1596,16 +1604,15 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { EXPECT_TRUE(SetupRecvStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); - parameters.codecs[0].AddFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + parameters.codecs[0].AddFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); EXPECT_EQ(0, GetRecvStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); SetSendParameters(parameters); // NACK should be enabled even with no send stream. EXPECT_EQ(kRtpHistoryMs, GetRecvStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcX))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcX))); EXPECT_EQ(kRtpHistoryMs, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); } @@ -1615,9 +1622,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { EXPECT_TRUE(AddRecvStream(kSsrcY)); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); - parameters.codecs[0].AddFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + parameters.codecs[0].AddFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); EXPECT_EQ(0, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); EXPECT_EQ(0, GetRecvStreamConfig(kSsrcY).rtp.nack.rtp_history_ms); SetSendParameters(parameters); @@ -1630,9 +1636,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); - parameters.codecs[0].AddFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + parameters.codecs[0].AddFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); SetSendParameters(parameters); EXPECT_EQ(kRtpHistoryMs, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); @@ -1648,9 +1653,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { EXPECT_TRUE(AddRecvStream(kSsrcY)); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); - parameters.codecs[0].AddFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + parameters.codecs[0].AddFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); SetSendParameters(parameters); EXPECT_EQ(kRtpHistoryMs, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); EXPECT_EQ(kRtpHistoryMs, GetRecvStreamConfig(kSsrcY).rtp.nack.rtp_history_ms); @@ -1668,9 +1672,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kCn16000Codec); - parameters.codecs[0].AddFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty)); + parameters.codecs[0].AddFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); SetSendParameters(parameters); EXPECT_EQ(kRtpHistoryMs, GetSendStreamConfig(kSsrcX).rtp.nack.rtp_history_ms); @@ -1747,7 +1750,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { EXPECT_EQ(32000, spec.target_bitrate_bps); } - parameters.codecs[0].bitrate = 0; // bitrate == default + parameters.codecs[0].bitrate = 0; // bitrate == default SetSendParameters(parameters); { const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; @@ -1755,7 +1758,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { EXPECT_STRCASEEQ("ISAC", spec.format.name.c_str()); EXPECT_EQ(32000, spec.target_bitrate_bps); } - parameters.codecs[0].bitrate = 28000; // bitrate == 28000 + parameters.codecs[0].bitrate = 28000; // bitrate == 28000 SetSendParameters(parameters); { const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; @@ -1764,7 +1767,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { EXPECT_EQ(28000, spec.target_bitrate_bps); } - parameters.codecs[0] = kPcmuCodec; // bitrate == 64000 + parameters.codecs[0] = kPcmuCodec; // bitrate == 64000 SetSendParameters(parameters); { const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; @@ -1773,7 +1776,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { EXPECT_EQ(64000, spec.target_bitrate_bps); } - parameters.codecs[0].bitrate = 0; // bitrate == default + parameters.codecs[0].bitrate = 0; // bitrate == default SetSendParameters(parameters); { const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; @@ -1783,7 +1786,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { } parameters.codecs[0] = kOpusCodec; - parameters.codecs[0].bitrate = 0; // bitrate == default + parameters.codecs[0].bitrate = 0; // bitrate == default SetSendParameters(parameters); { const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; @@ -1910,8 +1913,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { parameters.codecs[2].id = 97; // wideband CN parameters.codecs[4].id = 98; // DTMF SetSendParameters(parameters); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcX))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcX))); const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_EQ(96, send_codec_spec.payload_type); @@ -2104,8 +2107,8 @@ TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { SetSend(true); for (uint32_t ssrc : kSsrcs4) { - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(ssrc))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(ssrc))); SetAudioSend(ssrc, true, &fake_source_); // Verify that we are in a sending state for all the created streams. EXPECT_TRUE(GetSendStream(ssrc).IsSending()); @@ -2127,8 +2130,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { // Create send streams. for (uint32_t ssrc : kSsrcs4) { - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(ssrc))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(ssrc))); } cricket::AudioSendParameters parameters; @@ -2166,8 +2169,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { // Create the send channels and they should be a "not sending" date. for (uint32_t ssrc : kSsrcs4) { - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(ssrc))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(ssrc))); SetAudioSend(ssrc, true, &fake_source_); EXPECT_FALSE(GetSendStream(ssrc).IsSending()); } @@ -2193,8 +2196,8 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { // Create send streams. for (uint32_t ssrc : kSsrcs4) { - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(ssrc))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(ssrc))); } // Create a receive stream to check that none of the send streams end up in @@ -2492,8 +2495,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(AddRecvStream(kSsrcY)); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcX))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcX))); EXPECT_TRUE(call_.GetAudioSendStream(kSsrcX)); EXPECT_EQ(kSsrcX, GetRecvStreamConfig(kSsrcY).rtp.local_ssrc); } @@ -2504,8 +2507,8 @@ TEST_F(WebRtcVoiceEngineTestFake, Recv) { EXPECT_TRUE(AddRecvStream(1)); DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); - EXPECT_TRUE(GetRecvStream(1).VerifyLastPacket(kPcmuFrame, - sizeof(kPcmuFrame))); + EXPECT_TRUE( + GetRecvStream(1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); } // Test that we can properly receive packets on multiple streams. @@ -2568,8 +2571,8 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignaled) { DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE(GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame, - sizeof(kPcmuFrame))); + EXPECT_TRUE( + GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); } // Tests that when we add a stream without SSRCs, but contains a stream_id @@ -2663,8 +2666,8 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignaledAfterSignaled) { rtc::SetBE32(&packet[8], signaled_ssrc); EXPECT_TRUE(AddRecvStream(signaled_ssrc)); DeliverPacket(packet, sizeof(packet)); - EXPECT_TRUE(GetRecvStream(signaled_ssrc).VerifyLastPacket( - packet, sizeof(packet))); + EXPECT_TRUE( + GetRecvStream(signaled_ssrc).VerifyLastPacket(packet, sizeof(packet))); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); // Note that the first unknown SSRC cannot be 0, because we only support @@ -2672,8 +2675,8 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignaledAfterSignaled) { const uint32_t unsignaled_ssrc = 7011; rtc::SetBE32(&packet[8], unsignaled_ssrc); DeliverPacket(packet, sizeof(packet)); - EXPECT_TRUE(GetRecvStream(unsignaled_ssrc).VerifyLastPacket( - packet, sizeof(packet))); + EXPECT_TRUE( + GetRecvStream(unsignaled_ssrc).VerifyLastPacket(packet, sizeof(packet))); EXPECT_EQ(2u, call_.GetAudioReceiveStreams().size()); DeliverPacket(packet, sizeof(packet)); @@ -2694,8 +2697,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamAfterUnsignaled_NoRecreate) { // Spawn unsignaled stream with SSRC=1. DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE(GetRecvStream(1).VerifyLastPacket(kPcmuFrame, - sizeof(kPcmuFrame))); + EXPECT_TRUE( + GetRecvStream(1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); // Verify that the underlying stream object in Call is not recreated when a // stream with SSRC=1 is added. @@ -2713,8 +2716,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamAfterUnsignaled_Recreate) { // Spawn unsignaled stream with SSRC=1. DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE(GetRecvStream(1).VerifyLastPacket(kPcmuFrame, - sizeof(kPcmuFrame))); + EXPECT_TRUE( + GetRecvStream(1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); // Verify that the underlying stream object in Call *is* recreated when a // stream with SSRC=1 is added, and which has changed stream parameters. @@ -2799,12 +2802,15 @@ TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(AddRecvStream(kSsrcY)); - EXPECT_CALL(adm_, - BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); - EXPECT_CALL(adm_, - BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); - EXPECT_CALL(adm_, - BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, BuiltInAECIsAvailable()) + .Times(9) + .WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, BuiltInAGCIsAvailable()) + .Times(4) + .WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, BuiltInNSIsAvailable()) + .Times(2) + .WillRepeatedly(Return(false)); EXPECT_EQ(50u, GetRecvStreamConfig(kSsrcY).jitter_buffer_max_packets); EXPECT_FALSE(GetRecvStreamConfig(kSsrcY).jitter_buffer_fast_accelerate); @@ -2894,14 +2900,18 @@ TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { EXPECT_TRUE(SetupSendStream()); - EXPECT_CALL(adm_, - BuiltInAECIsAvailable()).Times(8).WillRepeatedly(Return(false)); - EXPECT_CALL(adm_, - BuiltInAGCIsAvailable()).Times(8).WillRepeatedly(Return(false)); - EXPECT_CALL(adm_, - BuiltInNSIsAvailable()).Times(8).WillRepeatedly(Return(false)); - EXPECT_CALL(adm_, - RecordingIsInitialized()).Times(2).WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, BuiltInAECIsAvailable()) + .Times(8) + .WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, BuiltInAGCIsAvailable()) + .Times(8) + .WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, BuiltInNSIsAvailable()) + .Times(8) + .WillRepeatedly(Return(false)); + EXPECT_CALL(adm_, RecordingIsInitialized()) + .Times(2) + .WillRepeatedly(Return(false)); EXPECT_CALL(adm_, Recording()).Times(2).WillRepeatedly(Return(false)); EXPECT_CALL(adm_, InitRecording()).Times(2).WillRepeatedly(Return(0)); webrtc::AudioProcessing::Config apm_config; @@ -3136,8 +3146,8 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { EXPECT_TRUE(SetupSendStream()); SetSendParameters(send_parameters_); for (uint32_t ssrc : ssrcs) { - EXPECT_TRUE(channel_->AddRecvStream( - cricket::StreamParams::CreateLegacy(ssrc))); + EXPECT_TRUE( + channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(ssrc))); } EXPECT_EQ(2u, call_.GetAudioReceiveStreams().size()); @@ -3181,11 +3191,9 @@ TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { const uint32_t kAudioSsrc = 1; rtc::CopyOnWriteBuffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); static const unsigned char kRtcp[] = { - 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; rtc::CopyOnWriteBuffer kRtcpPacket(kRtcp, sizeof(kRtcp)); EXPECT_TRUE(SetupSendStream()); @@ -3211,8 +3219,8 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel_SendCreatedFirst) { EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(AddRecvStream(kSsrcY)); EXPECT_EQ(kSsrcX, GetRecvStreamConfig(kSsrcY).rtp.local_ssrc); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcZ))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcZ))); EXPECT_EQ(kSsrcX, GetRecvStreamConfig(kSsrcY).rtp.local_ssrc); EXPECT_TRUE(AddRecvStream(kSsrcW)); EXPECT_EQ(kSsrcX, GetRecvStreamConfig(kSsrcW).rtp.local_ssrc); @@ -3221,13 +3229,13 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel_SendCreatedFirst) { TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel_RecvCreatedFirst) { EXPECT_TRUE(SetupRecvStream()); EXPECT_EQ(0xFA17FA17u, GetRecvStreamConfig(kSsrcX).rtp.local_ssrc); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcY))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcY))); EXPECT_EQ(kSsrcY, GetRecvStreamConfig(kSsrcX).rtp.local_ssrc); EXPECT_TRUE(AddRecvStream(kSsrcZ)); EXPECT_EQ(kSsrcY, GetRecvStreamConfig(kSsrcZ).rtp.local_ssrc); - EXPECT_TRUE(channel_->AddSendStream( - cricket::StreamParams::CreateLegacy(kSsrcW))); + EXPECT_TRUE( + channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcW))); EXPECT_EQ(kSsrcY, GetRecvStreamConfig(kSsrcX).rtp.local_ssrc); EXPECT_EQ(kSsrcY, GetRecvStreamConfig(kSsrcZ).rtp.local_ssrc); } @@ -3437,9 +3445,9 @@ TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { EXPECT_EQ(9, codec.id); } else if (is_codec("telephone-event", 8000)) { EXPECT_EQ(126, codec.id); - // TODO(solenberg): 16k, 32k, 48k DTMF should be dynamically assigned. - // Remove these checks once both send and receive side assigns payload types - // dynamically. + // TODO(solenberg): 16k, 32k, 48k DTMF should be dynamically assigned. + // Remove these checks once both send and receive side assigns payload + // types dynamically. } else if (is_codec("telephone-event", 16000)) { EXPECT_EQ(113, codec.id); } else if (is_codec("telephone-event", 32000)) { @@ -3549,13 +3557,12 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { // Rather than just ASSERTing that there are enough codecs, ensure that we can // check the actual values safely, to provide better test results. - auto get_codec = - [&codecs](size_t index) -> const cricket::AudioCodec& { - static const cricket::AudioCodec missing_codec(0, "", 0, 0, 0); - if (codecs.size() > index) - return codecs[index]; - return missing_codec; - }; + auto get_codec = [&codecs](size_t index) -> const cricket::AudioCodec& { + static const cricket::AudioCodec missing_codec(0, "", 0, 0, 0); + if (codecs.size() > index) + return codecs[index]; + return missing_codec; + }; // Ensure the general codecs are generated first and in order. for (size_t i = 0; i != specs.size(); ++i) { @@ -3567,18 +3574,17 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { // Find the index of a codec, or -1 if not found, so that we can easily check // supplementary codecs are ordered after the general codecs. - auto find_codec = - [&codecs](const webrtc::SdpAudioFormat& format) -> int { - for (size_t i = 0; i != codecs.size(); ++i) { - const cricket::AudioCodec& codec = codecs[i]; - if (STR_CASE_CMP(codec.name.c_str(), format.name.c_str()) == 0 && - codec.clockrate == format.clockrate_hz && - codec.channels == format.num_channels) { - return rtc::checked_cast(i); - } - } - return -1; - }; + auto find_codec = [&codecs](const webrtc::SdpAudioFormat& format) -> int { + for (size_t i = 0; i != codecs.size(); ++i) { + const cricket::AudioCodec& codec = codecs[i]; + if (STR_CASE_CMP(codec.name.c_str(), format.name.c_str()) == 0 && + codec.clockrate == format.clockrate_hz && + codec.channels == format.num_channels) { + return rtc::checked_cast(i); + } + } + return -1; + }; // Ensure all supplementary codecs are generated last. Their internal ordering // is not important. diff --git a/media/sctp/sctptransport.cc b/media/sctp/sctptransport.cc index c459828714..967e315be5 100644 --- a/media/sctp/sctptransport.cc +++ b/media/sctp/sctptransport.cc @@ -16,7 +16,7 @@ enum PreservedErrno { SCTP_EINPROGRESS = EINPROGRESS, SCTP_EWOULDBLOCK = EWOULDBLOCK }; -} +} // namespace #include "media/sctp/sctptransport.h" diff --git a/media/sctp/sctptransport_unittest.cc b/media/sctp/sctptransport_unittest.cc index 86f45531d8..75c2796cf8 100644 --- a/media/sctp/sctptransport_unittest.cc +++ b/media/sctp/sctptransport_unittest.cc @@ -31,7 +31,7 @@ static const int kDefaultTimeout = 10000; // 10 seconds. // Use ports other than the default 5000 for testing. static const int kTransport1Port = 5001; static const int kTransport2Port = 5002; -} +} // namespace namespace cricket { diff --git a/modules/audio_coding/acm2/acm_codec_database.cc b/modules/audio_coding/acm2/acm_codec_database.cc index 4553b52c62..a322c95210 100644 --- a/modules/audio_coding/acm2/acm_codec_database.cc +++ b/modules/audio_coding/acm2/acm_codec_database.cc @@ -42,7 +42,7 @@ bool IsILBCRateValid(int rate, int frame_size_samples) { (rate == 13300)) { return true; } else if (((frame_size_samples == 160) || (frame_size_samples == 320)) && - (rate == 15200)) { + (rate == 15200)) { return true; } else { return false; @@ -62,55 +62,54 @@ bool IsOpusRateValid(int rate) { const CodecInst ACMCodecDB::database_[] = { #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) - {103, "ISAC", 16000, 480, 1, 32000}, -# if (defined(WEBRTC_CODEC_ISAC)) - {104, "ISAC", 32000, 960, 1, 56000}, -# endif + {103, "ISAC", 16000, 480, 1, 32000}, +#if (defined(WEBRTC_CODEC_ISAC)) + {104, "ISAC", 32000, 960, 1, 56000}, #endif - // Mono - {107, "L16", 8000, 80, 1, 128000}, - {108, "L16", 16000, 160, 1, 256000}, - {109, "L16", 32000, 320, 1, 512000}, - // Stereo - {111, "L16", 8000, 80, 2, 128000}, - {112, "L16", 16000, 160, 2, 256000}, - {113, "L16", 32000, 320, 2, 512000}, - // G.711, PCM mu-law and A-law. - // Mono - {0, "PCMU", 8000, 160, 1, 64000}, - {8, "PCMA", 8000, 160, 1, 64000}, - // Stereo - {110, "PCMU", 8000, 160, 2, 64000}, - {118, "PCMA", 8000, 160, 2, 64000}, +#endif + // Mono + {107, "L16", 8000, 80, 1, 128000}, + {108, "L16", 16000, 160, 1, 256000}, + {109, "L16", 32000, 320, 1, 512000}, + // Stereo + {111, "L16", 8000, 80, 2, 128000}, + {112, "L16", 16000, 160, 2, 256000}, + {113, "L16", 32000, 320, 2, 512000}, + // G.711, PCM mu-law and A-law. + // Mono + {0, "PCMU", 8000, 160, 1, 64000}, + {8, "PCMA", 8000, 160, 1, 64000}, + // Stereo + {110, "PCMU", 8000, 160, 2, 64000}, + {118, "PCMA", 8000, 160, 2, 64000}, #ifdef WEBRTC_CODEC_ILBC - {102, "ILBC", 8000, 240, 1, 13300}, + {102, "ILBC", 8000, 240, 1, 13300}, #endif - // Mono - {9, "G722", 16000, 320, 1, 64000}, - // Stereo - {119, "G722", 16000, 320, 2, 64000}, + // Mono + {9, "G722", 16000, 320, 1, 64000}, + // Stereo + {119, "G722", 16000, 320, 2, 64000}, #ifdef WEBRTC_CODEC_OPUS - // Opus internally supports 48, 24, 16, 12, 8 kHz. - // Mono and stereo. - {120, "opus", 48000, 960, 2, 64000}, + // Opus internally supports 48, 24, 16, 12, 8 kHz. + // Mono and stereo. + {120, "opus", 48000, 960, 2, 64000}, #endif - // Comfort noise for four different sampling frequencies. - {13, "CN", 8000, 240, 1, 0}, - {98, "CN", 16000, 480, 1, 0}, - {99, "CN", 32000, 960, 1, 0}, + // Comfort noise for four different sampling frequencies. + {13, "CN", 8000, 240, 1, 0}, + {98, "CN", 16000, 480, 1, 0}, + {99, "CN", 32000, 960, 1, 0}, #ifdef ENABLE_48000_HZ - {100, "CN", 48000, 1440, 1, 0}, + {100, "CN", 48000, 1440, 1, 0}, #endif - {106, "telephone-event", 8000, 240, 1, 0}, - {114, "telephone-event", 16000, 240, 1, 0}, - {115, "telephone-event", 32000, 240, 1, 0}, - {116, "telephone-event", 48000, 240, 1, 0}, + {106, "telephone-event", 8000, 240, 1, 0}, + {114, "telephone-event", 16000, 240, 1, 0}, + {115, "telephone-event", 32000, 240, 1, 0}, + {116, "telephone-event", 48000, 240, 1, 0}, #ifdef WEBRTC_CODEC_RED - {127, "red", 8000, 0, 1, 0}, + {127, "red", 8000, 0, 1, 0}, #endif - // To prevent compile errors due to trailing commas. - {-1, "Null", -1, -1, 0, -1} -}; + // To prevent compile errors due to trailing commas. + {-1, "Null", -1, -1, 0, -1}}; // Create database with all codec settings at compile time. // Each entry needs the following parameters in the given order: @@ -119,9 +118,9 @@ const CodecInst ACMCodecDB::database_[] = { const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = { #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) {2, {480, 960}, 0, 1}, -# if (defined(WEBRTC_CODEC_ISAC)) +#if (defined(WEBRTC_CODEC_ISAC)) {1, {960}, 0, 1}, -# endif +#endif #endif // Mono {4, {80, 160, 240, 320}, 0, 2}, @@ -146,9 +145,9 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = { // Stereo {6, {160, 320, 480, 640, 800, 960}, 0, 2}, #ifdef WEBRTC_CODEC_OPUS - // Opus supports frames shorter than 10ms, - // but it doesn't help us to use them. - // Mono and stereo. +// Opus supports frames shorter than 10ms, +// but it doesn't help us to use them. +// Mono and stereo. #if WEBRTC_OPUS_SUPPORT_120MS_PTIME {5, {480, 960, 1920, 2880, 5760}, 0, 2}, #else @@ -171,16 +170,15 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = { {1, {0}, 0, 1}, #endif // To prevent compile errors due to trailing commas. - {-1, {-1}, -1, 0} -}; + {-1, {-1}, -1, 0}}; // Create a database of all NetEQ decoders at compile time. const NetEqDecoder ACMCodecDB::neteq_decoders_[] = { #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) NetEqDecoder::kDecoderISAC, -# if (defined(WEBRTC_CODEC_ISAC)) +#if (defined(WEBRTC_CODEC_ISAC)) NetEqDecoder::kDecoderISACswb, -# endif +#endif #endif // Mono NetEqDecoder::kDecoderPCM16B, NetEqDecoder::kDecoderPCM16Bwb, @@ -210,10 +208,8 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = { #ifdef ENABLE_48000_HZ NetEqDecoder::kDecoderCNGswb48kHz, #endif - NetEqDecoder::kDecoderAVT, - NetEqDecoder::kDecoderAVT16kHz, - NetEqDecoder::kDecoderAVT32kHz, - NetEqDecoder::kDecoderAVT48kHz, + NetEqDecoder::kDecoderAVT, NetEqDecoder::kDecoderAVT16kHz, + NetEqDecoder::kDecoderAVT32kHz, NetEqDecoder::kDecoderAVT48kHz, #ifdef WEBRTC_CODEC_RED NetEqDecoder::kDecoderRED, #endif @@ -260,8 +256,7 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) { int i; int packet_size_samples; for (i = 0; i < codec_settings_[codec_id].num_packet_sizes; i++) { - packet_size_samples = - codec_settings_[codec_id].packet_sizes_samples[i]; + packet_size_samples = codec_settings_[codec_id].packet_sizes_samples[i]; if (codec_inst.pacsize == packet_size_samples) { packet_size_ok = true; break; @@ -282,11 +277,10 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) { if (STR_CASE_CMP("isac", codec_inst.plname) == 0) { return IsISACRateValid(codec_inst.rate) ? codec_id : kInvalidRate; } else if (STR_CASE_CMP("ilbc", codec_inst.plname) == 0) { - return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize) - ? codec_id : kInvalidRate; + return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize) ? codec_id + : kInvalidRate; } else if (STR_CASE_CMP("opus", codec_inst.plname) == 0) { - return IsOpusRateValid(codec_inst.rate) - ? codec_id : kInvalidRate; + return IsOpusRateValid(codec_inst.rate) ? codec_id : kInvalidRate; } return database_[codec_id].rate == codec_inst.rate ? codec_id : kInvalidRate; @@ -298,8 +292,7 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) { // Does not check other codec settings, such as payload type and packet size. // Returns the id of the codec, or -1 if no match is found. int ACMCodecDB::CodecId(const CodecInst& codec_inst) { - return (CodecId(codec_inst.plname, codec_inst.plfreq, - codec_inst.channels)); + return (CodecId(codec_inst.plname, codec_inst.plfreq, codec_inst.channels)); } int ACMCodecDB::CodecId(const char* payload_name, diff --git a/modules/audio_coding/acm2/acm_codec_database.h b/modules/audio_coding/acm2/acm_codec_database.h index 81cd4be05a..8b7c68a97e 100644 --- a/modules/audio_coding/acm2/acm_codec_database.h +++ b/modules/audio_coding/acm2/acm_codec_database.h @@ -31,7 +31,7 @@ class ACMCodecDB { // build. // kMaxNumPacketSize - Maximum number of allowed packet sizes for one codec. // These might need to be increased if adding a new codec to the database - static const int kMaxNumCodecs = 50; + static const int kMaxNumCodecs = 50; static const int kMaxNumPacketSize = 6; // Codec specific settings diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc index 473b6519ab..6afc161efa 100644 --- a/modules/audio_coding/acm2/acm_receive_test.cc +++ b/modules/audio_coding/acm2/acm_receive_test.cc @@ -156,8 +156,7 @@ void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() { continue; } - if (RemapPltypeAndUseThisCodec(my_codec_param.plname, - my_codec_param.plfreq, + if (RemapPltypeAndUseThisCodec(my_codec_param.plname, my_codec_param.plfreq, my_codec_param.channels, &my_codec_param.pltype)) { ASSERT_EQ(true, @@ -204,8 +203,7 @@ void AcmReceiveTestOldApi::Run() { EXPECT_EQ(0, acm_->IncomingPacket( packet->payload(), - static_cast(packet->payload_length_bytes()), - header)) + static_cast(packet->payload_length_bytes()), header)) << "Failure when inserting packet:" << std::endl << " PT = " << static_cast(header.header.payloadType) << std::endl << " TS = " << header.header.timestamp << std::endl diff --git a/modules/audio_coding/acm2/acm_receive_test.h b/modules/audio_coding/acm2/acm_receive_test.h index c7e7da6e36..83ffcb3a90 100644 --- a/modules/audio_coding/acm2/acm_receive_test.h +++ b/modules/audio_coding/acm2/acm_receive_test.h @@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_ #define MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_ -#include // for size_t +#include // for size_t #include #include diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc index b61099cb98..0a88e70ec9 100644 --- a/modules/audio_coding/acm2/acm_receiver.cc +++ b/modules/audio_coding/acm2/acm_receiver.cc @@ -231,8 +231,8 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id, if (!audio_decoder) { ret_val = neteq_->RegisterPayloadType(neteq_decoder, name, payload_type); } else { - ret_val = neteq_->RegisterExternalDecoder( - audio_decoder, neteq_decoder, name, payload_type); + ret_val = neteq_->RegisterExternalDecoder(audio_decoder, neteq_decoder, + name, payload_type); } if (ret_val != NetEq::kOK) { RTC_LOG(LERROR) << "AcmReceiver::AddCodec " << acm_codec_id @@ -402,10 +402,9 @@ uint32_t AcmReceiver::NowInTimestamp(int decoder_sampling_rate) const { // the least significant bits. (32-6) bits cover 2^(32-6) = 67108864 ms. // We masked 6 most significant bits of 32-bit so there is no overflow in // the conversion from milliseconds to timestamp. - const uint32_t now_in_ms = static_cast( - clock_->TimeInMilliseconds() & 0x03ffffff); - return static_cast( - (decoder_sampling_rate / 1000) * now_in_ms); + const uint32_t now_in_ms = + static_cast(clock_->TimeInMilliseconds() & 0x03ffffff); + return static_cast((decoder_sampling_rate / 1000) * now_in_ms); } void AcmReceiver::GetDecodingCallStatistics( diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc index 78778214a0..350183bf3a 100644 --- a/modules/audio_coding/acm2/acm_receiver_unittest.cc +++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc @@ -30,12 +30,11 @@ namespace acm2 { namespace { bool CodecsEqual(const CodecInst& codec_a, const CodecInst& codec_b) { - if (strcmp(codec_a.plname, codec_b.plname) != 0 || - codec_a.plfreq != codec_b.plfreq || - codec_a.pltype != codec_b.pltype || - codec_b.channels != codec_a.channels) - return false; - return true; + if (strcmp(codec_a.plname, codec_b.plname) != 0 || + codec_a.plfreq != codec_b.plfreq || codec_a.pltype != codec_b.pltype || + codec_b.channels != codec_a.channels) + return false; + return true; } struct CodecIdInst { @@ -115,7 +114,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, } template - void AddSetOfCodecs(const RentACodec::CodecId(&ids)[N]) { + void AddSetOfCodecs(const RentACodec::CodecId (&ids)[N]) { for (auto id : ids) { const auto i = RentACodec::CodecIndexFromId(id); ASSERT_TRUE(i); @@ -186,13 +185,13 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecGetCodec) { CodecInst my_codec; if (n & 0x1) { // Codecs with odd index should match the reference. - EXPECT_EQ(0, receiver_->DecoderByPayloadType(codecs_[n].pltype, - &my_codec)); + EXPECT_EQ(0, + receiver_->DecoderByPayloadType(codecs_[n].pltype, &my_codec)); EXPECT_TRUE(CodecsEqual(codecs_[n], my_codec)); } else { // Codecs with even index are not registered. - EXPECT_EQ(-1, receiver_->DecoderByPayloadType(codecs_[n].pltype, - &my_codec)); + EXPECT_EQ(-1, + receiver_->DecoderByPayloadType(codecs_[n].pltype, &my_codec)); } } } @@ -326,7 +325,8 @@ class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi { // Expect the first output timestamp to be 5*fs/8000 samples before the // first inserted timestamp (because of NetEq's look-ahead). (This value is // defined in Expand::overlap_length_.) - uint32_t expected_output_ts = last_packet_send_timestamp_ - + uint32_t expected_output_ts = + last_packet_send_timestamp_ - rtc::CheckedDivExact(5 * output_sample_rate_hz, 8000); AudioFrame frame; diff --git a/modules/audio_coding/acm2/acm_resampler.cc b/modules/audio_coding/acm2/acm_resampler.cc index b97ced23de..c0b2064453 100644 --- a/modules/audio_coding/acm2/acm_resampler.cc +++ b/modules/audio_coding/acm2/acm_resampler.cc @@ -19,11 +19,9 @@ namespace webrtc { namespace acm2 { -ACMResampler::ACMResampler() { -} +ACMResampler::ACMResampler() {} -ACMResampler::~ACMResampler() { -} +ACMResampler::~ACMResampler() {} int ACMResampler::Resample10Msec(const int16_t* in_audio, int in_freq_hz, diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc index 09a6c80ba7..b1a3e9811d 100644 --- a/modules/audio_coding/acm2/acm_send_test.cc +++ b/modules/audio_coding/acm2/acm_send_test.cc @@ -95,10 +95,9 @@ std::unique_ptr AcmSendTestOldApi::NextPacket() { RTC_CHECK(audio_source_->Read(input_block_size_samples_, input_frame_.mutable_data())); if (input_frame_.num_channels_ > 1) { - InputAudioFile::DuplicateInterleaved(input_frame_.data(), - input_block_size_samples_, - input_frame_.num_channels_, - input_frame_.mutable_data()); + InputAudioFile::DuplicateInterleaved( + input_frame_.data(), input_block_size_samples_, + input_frame_.num_channels_, input_frame_.mutable_data()); } data_to_send_ = false; RTC_CHECK_GE(acm_->Add10MsData(input_frame_), 0); @@ -138,7 +137,7 @@ std::unique_ptr AcmSendTestOldApi::CreatePacket() { packet_memory[0] = 0x80; packet_memory[1] = static_cast(payload_type_); packet_memory[2] = (sequence_number_ >> 8) & 0xFF; - packet_memory[3] = (sequence_number_) & 0xFF; + packet_memory[3] = (sequence_number_)&0xFF; packet_memory[4] = (timestamp_ >> 24) & 0xFF; packet_memory[5] = (timestamp_ >> 16) & 0xFF; packet_memory[6] = (timestamp_ >> 8) & 0xFF; @@ -152,8 +151,7 @@ std::unique_ptr AcmSendTestOldApi::CreatePacket() { ++sequence_number_; // Copy the payload data. - memcpy(packet_memory + kRtpHeaderSize, - &last_payload_vec_[0], + memcpy(packet_memory + kRtpHeaderSize, &last_payload_vec_[0], last_payload_vec_.size()); std::unique_ptr packet( new Packet(packet_memory, allocated_bytes, clock_.TimeInMilliseconds())); diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc index 2d8827c697..7f652a215d 100644 --- a/modules/audio_coding/acm2/audio_coding_module.cc +++ b/modules/audio_coding/acm2/audio_coding_module.cc @@ -323,9 +323,10 @@ int DownMix(const AudioFrame& frame, if (!frame.muted()) { const int16_t* frame_data = frame.data(); for (size_t n = 0; n < frame.samples_per_channel_; ++n) { - out_buff[n] = static_cast( - (static_cast(frame_data[2 * n]) + - static_cast(frame_data[2 * n + 1])) >> 1); + out_buff[n] = + static_cast((static_cast(frame_data[2 * n]) + + static_cast(frame_data[2 * n + 1])) >> + 1); } } else { std::fill(out_buff, out_buff + frame.samples_per_channel_, 0); @@ -472,7 +473,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { if (!HaveValidEncoder("Process")) return -1; - if(!first_frame_) { + if (!first_frame_) { RTC_DCHECK(IsNewerTimestamp(input_data.input_timestamp, last_timestamp_)) << "Time should not move backwards"; } @@ -493,9 +494,10 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { // Clear the buffer before reuse - encoded data will get appended. encode_buffer_.Clear(); encoded_info = encoder_stack_->Encode( - rtp_timestamp, rtc::ArrayView( - input_data.audio, input_data.audio_channel * - input_data.length_per_channel), + rtp_timestamp, + rtc::ArrayView( + input_data.audio, + input_data.audio_channel * input_data.length_per_channel), &encode_buffer_); bitrate_logger_.MaybeLog(encoder_stack_->GetTargetBitrate() / 1000); @@ -767,7 +769,6 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame, expected_in_ts_ = in_frame.timestamp_; } - if (!down_mix && !resample) { // No pre-processing is required. if (expected_in_ts_ == expected_codec_ts_) { @@ -793,8 +794,8 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame, if (down_mix) { // If a resampling is required the output of a down-mix is written into a // local buffer, otherwise, it will be written to the output frame. - int16_t* dest_ptr_audio = resample ? - audio : preprocess_frame_.mutable_data(); + int16_t* dest_ptr_audio = + resample ? audio : preprocess_frame_.mutable_data(); if (DownMix(in_frame, WEBRTC_10MS_PCM_AUDIO, dest_ptr_audio) < 0) return -1; preprocess_frame_.num_channels_ = 1; @@ -912,7 +913,8 @@ int AudioCodingModuleImpl::SetVAD(bool enable_dtx, } // Get VAD/DTX settings. -int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled, +int AudioCodingModuleImpl::VAD(bool* dtx_enabled, + bool* vad_enabled, ACMVADMode* mode) const { rtc::CritScope lock(&acm_crit_sect_); const auto* sp = encoder_factory_->codec_manager.GetStackParams(); @@ -1229,7 +1231,7 @@ int AudioCodingModuleImpl::LeastRequiredDelayMs() const { } void AudioCodingModuleImpl::GetDecodingCallStatistics( - AudioDecodingCallStats* call_stats) const { + AudioDecodingCallStats* call_stats) const { receiver_.GetDecodingCallStatistics(call_stats); } diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc index e16d54a5cf..7592300e10 100644 --- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -425,19 +425,12 @@ class AudioCodingModuleTestWithComfortNoiseOldApi const struct { int ix; FrameType type; - } expectation[] = {{2, kAudioFrameCN}, - {5, kEmptyFrame}, - {8, kEmptyFrame}, - {11, kAudioFrameCN}, - {14, kEmptyFrame}, - {17, kEmptyFrame}, - {20, kAudioFrameCN}, - {23, kEmptyFrame}, - {26, kEmptyFrame}, - {29, kEmptyFrame}, - {32, kAudioFrameCN}, - {35, kEmptyFrame}, - {38, kEmptyFrame}}; + } expectation[] = { + {2, kAudioFrameCN}, {5, kEmptyFrame}, {8, kEmptyFrame}, + {11, kAudioFrameCN}, {14, kEmptyFrame}, {17, kEmptyFrame}, + {20, kAudioFrameCN}, {23, kEmptyFrame}, {26, kEmptyFrame}, + {29, kEmptyFrame}, {32, kAudioFrameCN}, {35, kEmptyFrame}, + {38, kEmptyFrame}}; for (int i = 0; i < kLoops; ++i) { int num_calls_before = packet_cb_.num_calls(); EXPECT_EQ(i / blocks_per_packet, num_calls_before); @@ -686,10 +679,8 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi { last_packet_number_ = num_calls; } ASSERT_GT(last_payload_vec_.size(), 0u); - ASSERT_EQ( - 0, - acm_->IncomingPacket( - &last_payload_vec_[0], last_payload_vec_.size(), rtp_header_)); + ASSERT_EQ(0, acm_->IncomingPacket(&last_payload_vec_[0], + last_payload_vec_.size(), rtp_header_)); } void InsertAudio() override { @@ -819,9 +810,8 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi { // Encode new frame. uint32_t input_timestamp = rtp_header_.header.timestamp; while (info.encoded_bytes == 0) { - info = - isac_encoder_->Encode(input_timestamp, audio_loop_.GetNextBlock(), - &encoded); + info = isac_encoder_->Encode(input_timestamp, + audio_loop_.GetNextBlock(), &encoded); input_timestamp += 160; // 10 ms at 16 kHz. } EXPECT_EQ(rtp_header_.header.timestamp + kPacketSizeSamples, @@ -1094,11 +1084,12 @@ TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutputExternalDecoder) { rtc::scoped_refptr> factory( new rtc::RefCountedObject); - Run(48000, PlatformChecksum("5955e31373828969de7fb308fb58a84e", - "83c0eca235b1a806426ff6ca8655cdf7", - "1126a8c03d1ebc6aa7348b9c541e2082", - "bd44bf97e7899186532f91235cef444d", - "9d092dbc96e7ef6870b78c1056e87315"), + Run(48000, + PlatformChecksum("5955e31373828969de7fb308fb58a84e", + "83c0eca235b1a806426ff6ca8655cdf7", + "1126a8c03d1ebc6aa7348b9c541e2082", + "bd44bf97e7899186532f91235cef444d", + "9d092dbc96e7ef6870b78c1056e87315"), factory, [](AudioCodingModule* acm) { acm->RegisterReceiveCodec(0, {"MockPCMu", 8000, 1}); }); @@ -1154,11 +1145,8 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, int frame_size_rtp_timestamps) { payload_type_ = payload_type; frame_size_rtp_timestamps_ = frame_size_rtp_timestamps; - return send_test_->RegisterCodec(payload_name, - sampling_freq_hz, - channels, - payload_type, - frame_size_samples); + return send_test_->RegisterCodec(payload_name, sampling_freq_hz, channels, + payload_type, frame_size_samples); } bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder, @@ -1257,11 +1245,8 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, int codec_frame_size_samples, int codec_frame_size_rtp_timestamps) { ASSERT_TRUE(SetUpSender()); - ASSERT_TRUE(RegisterSendCodec(codec_name, - codec_sample_rate_hz, - channels, - payload_type, - codec_frame_size_samples, + ASSERT_TRUE(RegisterSendCodec(codec_name, codec_sample_rate_hz, channels, + payload_type, codec_frame_size_samples, codec_frame_size_rtp_timestamps)); } @@ -1342,82 +1327,62 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacSwb30ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); - Run("de4a98e1406f8b798d99cd0704e862e2", - "c1edd36339ce0326cc4550041ad719a0", - 100, - test::AcmReceiveTestOldApi::kMonoOutput); + Run("de4a98e1406f8b798d99cd0704e862e2", "c1edd36339ce0326cc4550041ad719a0", + 100, test::AcmReceiveTestOldApi::kMonoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcm16_16000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 16000, 1, 108, 160, 160)); - Run("ae646d7b68384a1269cc080dd4501916", - "ad786526383178b08d80d6eee06e9bad", - 100, - test::AcmReceiveTestOldApi::kMonoOutput); + Run("ae646d7b68384a1269cc080dd4501916", "ad786526383178b08d80d6eee06e9bad", + 100, test::AcmReceiveTestOldApi::kMonoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcm16_32000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 32000, 1, 109, 320, 320)); - Run("7fe325e8fbaf755e3c5df0b11a4774fb", - "5ef82ea885e922263606c6fdbc49f651", - 100, - test::AcmReceiveTestOldApi::kMonoOutput); + Run("7fe325e8fbaf755e3c5df0b11a4774fb", "5ef82ea885e922263606c6fdbc49f651", + 100, test::AcmReceiveTestOldApi::kMonoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_8000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 2, 111, 80, 80)); - Run("fb263b74e7ac3de915474d77e4744ceb", - "62ce5adb0d4965d0a52ec98ae7f98974", - 100, - test::AcmReceiveTestOldApi::kStereoOutput); + Run("fb263b74e7ac3de915474d77e4744ceb", "62ce5adb0d4965d0a52ec98ae7f98974", + 100, test::AcmReceiveTestOldApi::kStereoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_16000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 16000, 2, 112, 160, 160)); - Run("d09e9239553649d7ac93e19d304281fd", - "41ca8edac4b8c71cd54fd9f25ec14870", - 100, - test::AcmReceiveTestOldApi::kStereoOutput); + Run("d09e9239553649d7ac93e19d304281fd", "41ca8edac4b8c71cd54fd9f25ec14870", + 100, test::AcmReceiveTestOldApi::kStereoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_32000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 32000, 2, 113, 320, 320)); - Run("5f025d4f390982cc26b3d92fe02e3044", - "50e58502fb04421bf5b857dda4c96879", - 100, - test::AcmReceiveTestOldApi::kStereoOutput); + Run("5f025d4f390982cc26b3d92fe02e3044", "50e58502fb04421bf5b857dda4c96879", + 100, test::AcmReceiveTestOldApi::kStereoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcmu_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMU", 8000, 1, 0, 160, 160)); - Run("81a9d4c0bb72e9becc43aef124c981e9", - "8f9b8750bd80fe26b6cbf6659b89f0f9", - 50, - test::AcmReceiveTestOldApi::kMonoOutput); + Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9", + 50, test::AcmReceiveTestOldApi::kMonoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcma_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMA", 8000, 1, 8, 160, 160)); - Run("39611f798969053925a49dc06d08de29", - "6ad745e55aa48981bfc790d0eeef2dd1", - 50, - test::AcmReceiveTestOldApi::kMonoOutput); + Run("39611f798969053925a49dc06d08de29", "6ad745e55aa48981bfc790d0eeef2dd1", + 50, test::AcmReceiveTestOldApi::kMonoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcmu_stereo_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMU", 8000, 2, 110, 160, 160)); - Run("437bec032fdc5cbaa0d5175430af7b18", - "60b6f25e8d1e74cb679cfe756dd9bca5", - 50, - test::AcmReceiveTestOldApi::kStereoOutput); + Run("437bec032fdc5cbaa0d5175430af7b18", "60b6f25e8d1e74cb679cfe756dd9bca5", + 50, test::AcmReceiveTestOldApi::kStereoOutput); } TEST_F(AcmSenderBitExactnessOldApi, Pcma_stereo_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMA", 8000, 2, 118, 160, 160)); - Run("a5c6d83c5b7cedbeff734238220a4b0c", - "92b282c83efd20e7eeef52ba40842cf7", - 50, - test::AcmReceiveTestOldApi::kStereoOutput); + Run("a5c6d83c5b7cedbeff734238220a4b0c", "92b282c83efd20e7eeef52ba40842cf7", + 50, test::AcmReceiveTestOldApi::kStereoOutput); } #if defined(WEBRTC_ANDROID) @@ -1740,11 +1705,11 @@ class AcmChangeBitRateOldApi : public AcmSetBitRateOldApi { if (packet_counter == nr_packets / 2) send_test_->acm()->SetBitRate(target_bitrate_bps); if (packet_counter < nr_packets / 2) - nr_bytes_before += rtc::checked_cast( - next_packet->payload_length_bytes()); + nr_bytes_before += + rtc::checked_cast(next_packet->payload_length_bytes()); else - nr_bytes_after += rtc::checked_cast( - next_packet->payload_length_bytes()); + nr_bytes_after += + rtc::checked_cast(next_packet->payload_length_bytes()); packet_counter++; } // Check that bitrate is 80-120 percent of expected value. @@ -1811,12 +1776,10 @@ TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) { .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate)); EXPECT_CALL(mock_encoder, EncodeImpl(_, _, _)) .Times(AtLeast(1)) - .WillRepeatedly(Invoke(&encoder, - static_cast< - AudioEncoder::EncodedInfo(AudioEncoder::*)( - uint32_t, - rtc::ArrayView, - rtc::Buffer*)>(&AudioEncoderPcmU::Encode))); + .WillRepeatedly(Invoke( + &encoder, static_cast, rtc::Buffer*)>( + &AudioEncoderPcmU::Encode))); EXPECT_CALL(mock_encoder, SetFec(_)) .Times(AtLeast(1)) .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SetFec)); @@ -1866,11 +1829,7 @@ class AcmSwitchingOutputFrequencyOldApi : public ::testing::Test, // this class. test::AudioSinkFork output(this, &output_file); test::AcmReceiveTestToggleOutputFreqOldApi receive_test( - this, - &output, - output_freq_1, - output_freq_2, - toggle_period_ms, + this, &output, output_freq_1, output_freq_2, toggle_period_ms, test::AcmReceiveTestOldApi::kMonoOutput); ASSERT_NO_FATAL_FAILURE(receive_test.RegisterDefaultCodecs()); output_freq_2_ = output_freq_2; diff --git a/modules/audio_coding/acm2/call_statistics_unittest.cc b/modules/audio_coding/acm2/call_statistics_unittest.cc index 77c3863ea8..528708f2fb 100644 --- a/modules/audio_coding/acm2/call_statistics_unittest.cc +++ b/modules/audio_coding/acm2/call_statistics_unittest.cc @@ -52,6 +52,3 @@ TEST(CallStatisticsTest, AllCalls) { } // namespace acm2 } // namespace webrtc - - - diff --git a/modules/audio_coding/acm2/rent_a_codec_unittest.cc b/modules/audio_coding/acm2/rent_a_codec_unittest.cc index ca469e7cdc..fd3329cfb1 100644 --- a/modules/audio_coding/acm2/rent_a_codec_unittest.cc +++ b/modules/audio_coding/acm2/rent_a_codec_unittest.cc @@ -54,8 +54,7 @@ class RentACodecTestF : public ::testing::Test { int expected_send_even_if_empty) { rtc::Buffer out; AudioEncoder::EncodedInfo encoded_info; - encoded_info = - encoder_->Encode(timestamp_, kZeroData, &out); + encoded_info = encoder_->Encode(timestamp_, kZeroData, &out); timestamp_ += kDataLengthSamples; EXPECT_TRUE(encoded_info.redundant.empty()); EXPECT_EQ(expected_out_length, encoded_info.encoded_bytes); @@ -132,9 +131,8 @@ TEST(RentACodecTest, ExternalEncoder) { { ::testing::InSequence s; info.encoded_timestamp = 0; - EXPECT_CALL( - *external_encoder, - EncodeImpl(0, rtc::ArrayView(audio), &encoded)) + EXPECT_CALL(*external_encoder, + EncodeImpl(0, rtc::ArrayView(audio), &encoded)) .WillOnce(Return(info)); EXPECT_CALL(marker, Mark("A")); EXPECT_CALL(marker, Mark("B")); diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc index 2872219197..5948ac3644 100644 --- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc @@ -102,8 +102,7 @@ AudioNetworkAdaptorStates CreateAudioNetworkAdaptor() { config.event_log = states.event_log.get(); // AudioNetworkAdaptorImpl governs the lifetime of controller manager. states.audio_network_adaptor.reset(new AudioNetworkAdaptorImpl( - config, - std::move(controller_manager), std::move(debug_dump_writer))); + config, std::move(controller_manager), std::move(debug_dump_writer))); return states; } diff --git a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc index 98abedeca5..f07735712d 100644 --- a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc @@ -80,9 +80,9 @@ TEST(AnaBitrateControllerTest, ChangeBitrateOnTargetBitrateChanged) { BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0)); constexpr int kTargetBitrateBps = 48000; constexpr size_t kOverheadBytesPerPacket = 64; - constexpr int kBitrateBps = - kTargetBitrateBps - - kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs; + constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 * + 1000 / + kInitialFrameLengthMs; // Frame length unchanged, bitrate changes in accordance with // |metrics.target_audio_bitrate_bps| and |metrics.overhead_bytes_per_packet|. UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); @@ -104,9 +104,9 @@ TEST(AnaBitrateControllerTest, UpdateMultipleNetworkMetricsAtOnce) { BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0)); constexpr int kTargetBitrateBps = 48000; constexpr size_t kOverheadBytesPerPacket = 64; - constexpr int kBitrateBps = - kTargetBitrateBps - - kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs; + constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 * + 1000 / + kInitialFrameLengthMs; Controller::NetworkMetrics network_metrics; network_metrics.target_audio_bitrate_bps = kTargetBitrateBps; network_metrics.overhead_bytes_per_packet = kOverheadBytesPerPacket; @@ -122,9 +122,9 @@ TEST(AnaBitrateControllerTest, TreatUnknownFrameLengthAsFrameLengthUnchanged) { BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0)); constexpr int kTargetBitrateBps = 48000; constexpr size_t kOverheadBytesPerPacket = 64; - constexpr int kBitrateBps = - kTargetBitrateBps - - kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs; + constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 * + 1000 / + kInitialFrameLengthMs; UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); CheckDecision(&controller, absl::nullopt, kBitrateBps); } @@ -138,9 +138,9 @@ TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) { constexpr int kTargetBitrateBps = 48000; constexpr size_t kOverheadBytesPerPacket = 64; - constexpr int kBitrateBps = - kTargetBitrateBps - - kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs; + constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 * + 1000 / + kInitialFrameLengthMs; UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); CheckDecision(&controller, absl::nullopt, kBitrateBps); @@ -162,9 +162,9 @@ TEST(AnaBitrateControllerTest, DecreaseBitrateOnFrameLengthDecreased) { constexpr int kTargetBitrateBps = 48000; constexpr size_t kOverheadBytesPerPacket = 64; - constexpr int kBitrateBps = - kTargetBitrateBps - - kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs; + constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 * + 1000 / + kInitialFrameLengthMs; UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); CheckDecision(&controller, absl::nullopt, kBitrateBps); @@ -213,9 +213,9 @@ TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) { // Next: change frame length. frame_length_ms = 60; - current_bitrate += rtc::checked_cast( - overhead_bytes_per_packet * 8 * 1000 / 20 - - overhead_bytes_per_packet * 8 * 1000 / 60); + current_bitrate += + rtc::checked_cast(overhead_bytes_per_packet * 8 * 1000 / 20 - + overhead_bytes_per_packet * 8 * 1000 / 60); UpdateNetworkMetrics(&controller, overall_bitrate, overhead_bytes_per_packet); CheckDecision(&controller, frame_length_ms, current_bitrate); @@ -227,9 +227,9 @@ TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) { // Next: change frame length. frame_length_ms = 20; - current_bitrate -= rtc::checked_cast( - overhead_bytes_per_packet * 8 * 1000 / 20 - - overhead_bytes_per_packet * 8 * 1000 / 60); + current_bitrate -= + rtc::checked_cast(overhead_bytes_per_packet * 8 * 1000 / 20 - + overhead_bytes_per_packet * 8 * 1000 / 60); UpdateNetworkMetrics(&controller, overall_bitrate, overhead_bytes_per_packet); CheckDecision(&controller, frame_length_ms, current_bitrate); @@ -237,9 +237,9 @@ TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) { overall_bitrate -= 100; current_bitrate -= 100; frame_length_ms = 60; - current_bitrate += rtc::checked_cast( - overhead_bytes_per_packet * 8 * 1000 / 20 - - overhead_bytes_per_packet * 8 * 1000 / 60); + current_bitrate += + rtc::checked_cast(overhead_bytes_per_packet * 8 * 1000 / 20 - + overhead_bytes_per_packet * 8 * 1000 / 60); UpdateNetworkMetrics(&controller, overall_bitrate, overhead_bytes_per_packet); CheckDecision(&controller, frame_length_ms, current_bitrate); diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc index 80255eac69..32f9fcb07b 100644 --- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc +++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc @@ -296,9 +296,9 @@ std::unique_ptr ControllerManagerImpl::Create( } if (scoring_points.size() == 0) { - return std::unique_ptr(new ControllerManagerImpl( - ControllerManagerImpl::Config(0, 0), std::move(controllers), - scoring_points)); + return std::unique_ptr( + new ControllerManagerImpl(ControllerManagerImpl::Config(0, 0), + std::move(controllers), scoring_points)); } else { RTC_CHECK(controller_manager_config.has_min_reordering_time_ms()); RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance()); diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc index 7409721698..7ab72c9437 100644 --- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc +++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc @@ -33,7 +33,7 @@ class NullSmoothingFilter final : public SmoothingFilter { private: absl::optional last_sample_; }; -} +} // namespace FecControllerPlrBased::Config::Config( bool initial_fec_enabled, diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc index 538a3e087d..8e8704ee73 100644 --- a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc @@ -209,11 +209,11 @@ TEST(FecControllerRplrBasedTest, EnableFecForMediumBandwidth) { auto controller = CreateFecControllerRplrBased(false); constexpr float kRecoverablePacketLoss = (kEnablingRecoverablePacketLossAtLowBw + - kEnablingRecoverablePacketLossAtHighBw) / 2.0; - UpdateNetworkMetrics( - controller.get(), - (kEnablingBandwidthHigh + kEnablingBandwidthLow) / 2, - kRecoverablePacketLoss); + kEnablingRecoverablePacketLossAtHighBw) / + 2.0; + UpdateNetworkMetrics(controller.get(), + (kEnablingBandwidthHigh + kEnablingBandwidthLow) / 2, + kRecoverablePacketLoss); CheckDecision(controller.get(), true, kRecoverablePacketLoss); } @@ -274,11 +274,12 @@ TEST(FecControllerRplrBasedTest, DisableFecOnMediumBandwidth) { auto controller = CreateFecControllerRplrBased(true); constexpr float kRecoverablePacketLoss = ((kDisablingRecoverablePacketLossAtLowBw + - kDisablingRecoverablePacketLossAtHighBw) / 2.0f) - kEpsilon; - UpdateNetworkMetrics( - controller.get(), - (kDisablingBandwidthHigh + kDisablingBandwidthLow) / 2, - kRecoverablePacketLoss); + kDisablingRecoverablePacketLossAtHighBw) / + 2.0f) - + kEpsilon; + UpdateNetworkMetrics(controller.get(), + (kDisablingBandwidthHigh + kDisablingBandwidthLow) / 2, + kRecoverablePacketLoss); CheckDecision(controller.get(), false, kRecoverablePacketLoss); } diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc index 6c3cae07bc..40e97cb371 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc @@ -25,7 +25,7 @@ int OverheadRateBps(size_t overhead_bytes_per_packet, int frame_length_ms) { return static_cast(overhead_bytes_per_packet * 8 * 1000 / frame_length_ms); } -} +} // namespace FrameLengthController::Config::Config( const std::vector& encoder_frame_lengths_ms, diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc index 91c07a9484..4cda3401fa 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc @@ -11,8 +11,8 @@ #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" #include -#include #include +#include #include namespace webrtc { @@ -158,9 +158,8 @@ void AudioEncoderCng::Reset() { rtp_timestamps_.clear(); last_frame_active_ = true; vad_->Reset(); - cng_encoder_.reset( - new ComfortNoiseEncoder(SampleRateHz(), sid_frame_interval_ms_, - num_cng_coefficients_)); + cng_encoder_.reset(new ComfortNoiseEncoder( + SampleRateHz(), sid_frame_interval_ms_, num_cng_coefficients_)); } bool AudioEncoderCng::SetFec(bool enable) { @@ -217,11 +216,10 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive( // that value, in which case we don't want to overwrite any value from // an earlier iteration. size_t encoded_bytes_tmp = - cng_encoder_->Encode( - rtc::ArrayView( - &speech_buffer_[i * samples_per_10ms_frame], - samples_per_10ms_frame), - force_sid, encoded); + cng_encoder_->Encode(rtc::ArrayView( + &speech_buffer_[i * samples_per_10ms_frame], + samples_per_10ms_frame), + force_sid, encoded); if (encoded_bytes_tmp > 0) { RTC_CHECK(!output_produced); @@ -238,9 +236,8 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive( return info; } -AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive( - size_t frames_to_encode, - rtc::Buffer* encoded) { +AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(size_t frames_to_encode, + rtc::Buffer* encoded) { const size_t samples_per_10ms_frame = SamplesPer10msFrame(); AudioEncoder::EncodedInfo info; for (size_t i = 0; i < frames_to_encode; ++i) { diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc index c582b44762..a76dcbda29 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc @@ -30,7 +30,7 @@ namespace { static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. static const size_t kMockReturnEncodedBytes = 17; static const int kCngPayloadType = 18; -} +} // namespace class AudioEncoderCngTest : public ::testing::Test { protected: @@ -94,8 +94,7 @@ class AudioEncoderCngTest : public ::testing::Test { InSequence s; AudioEncoder::EncodedInfo info; for (size_t j = 0; j < num_calls - 1; ++j) { - EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) - .WillOnce(Return(info)); + EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)).WillOnce(Return(info)); } info.encoded_bytes = kMockReturnEncodedBytes; EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) @@ -155,12 +154,14 @@ class AudioEncoderCngTest : public ::testing::Test { EXPECT_CALL( *mock_vad_, VoiceActivity(_, expected_first_block_size_ms * sample_rate_hz_ / 1000, - sample_rate_hz_)).WillOnce(Return(Vad::kPassive)); + sample_rate_hz_)) + .WillOnce(Return(Vad::kPassive)); if (expected_second_block_size_ms > 0) { EXPECT_CALL(*mock_vad_, VoiceActivity( _, expected_second_block_size_ms * sample_rate_hz_ / 1000, - sample_rate_hz_)).WillOnce(Return(Vad::kPassive)); + sample_rate_hz_)) + .WillOnce(Return(Vad::kPassive)); } // With this call to Encode(), |mock_vad_| should be called according to the @@ -429,9 +430,7 @@ class AudioEncoderCngDeathTest : public AudioEncoderCngTest { // Override AudioEncoderCngTest::TearDown, since that one expects a call to // the destructor of |mock_vad_|. In this case, that object is already // deleted. - void TearDown() override { - cng_.reset(); - } + void TearDown() override { cng_.reset(); } AudioEncoderCng::Config MakeCngConfig() { // Don't provide a Vad mock object, since it would leak when the test dies. diff --git a/modules/audio_coding/codecs/cng/cng_unittest.cc b/modules/audio_coding/codecs/cng/cng_unittest.cc index 54e5189d30..81688b1f47 100644 --- a/modules/audio_coding/codecs/cng/cng_unittest.cc +++ b/modules/audio_coding/codecs/cng/cng_unittest.cc @@ -29,10 +29,7 @@ enum : size_t { kCNGNumParamsTooHigh = WEBRTC_CNG_MAX_LPC_ORDER + 1 }; -enum { - kNoSid, - kForceSid -}; +enum { kNoSid, kForceSid }; class CngTest : public ::testing::Test { protected: @@ -46,11 +43,11 @@ class CngTest : public ::testing::Test { void CngTest::SetUp() { FILE* input_file; const std::string file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); input_file = fopen(file_name.c_str(), "rb"); ASSERT_TRUE(input_file != NULL); - ASSERT_EQ(640, static_cast(fread(speech_data_, sizeof(int16_t), - 640, input_file))); + ASSERT_EQ(640, static_cast( + fread(speech_data_, sizeof(int16_t), 640, input_file))); fclose(input_file); input_file = NULL; } @@ -74,11 +71,18 @@ void CngTest::TestCngEncode(int sample_rate_hz, int quality) { // Create CNG encoder, init with faulty values, free CNG encoder. TEST_F(CngTest, CngInitFail) { // Call with too few parameters. - EXPECT_DEATH({ ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate, - kCNGNumParamsLow); }, ""); + EXPECT_DEATH( + { + ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate, kCNGNumParamsLow); + }, + ""); // Call with too many parameters. - EXPECT_DEATH({ ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate, - kCNGNumParamsTooHigh); }, ""); + EXPECT_DEATH( + { + ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate, + kCNGNumParamsTooHigh); + }, + ""); } // Encode Cng with too long input vector. @@ -209,13 +213,15 @@ TEST_F(CngTest, CngAutoSid) { // Normal Encode, 100 msec, where no SID data should be generated. for (int i = 0; i < 10; i++) { - EXPECT_EQ(0U, cng_encoder.Encode( - rtc::ArrayView(speech_data_, 160), kNoSid, &sid_data)); + EXPECT_EQ( + 0U, cng_encoder.Encode(rtc::ArrayView(speech_data_, 160), + kNoSid, &sid_data)); } // We have reached 100 msec, and SID data should be generated. - EXPECT_EQ(kCNGNumParamsNormal + 1, cng_encoder.Encode( - rtc::ArrayView(speech_data_, 160), kNoSid, &sid_data)); + EXPECT_EQ(kCNGNumParamsNormal + 1, + cng_encoder.Encode(rtc::ArrayView(speech_data_, 160), + kNoSid, &sid_data)); } // Test automatic SID, with very short interval. @@ -228,13 +234,16 @@ TEST_F(CngTest, CngAutoSidShort) { ComfortNoiseDecoder cng_decoder; // First call will never generate SID, unless forced to. - EXPECT_EQ(0U, cng_encoder.Encode( - rtc::ArrayView(speech_data_, 160), kNoSid, &sid_data)); + EXPECT_EQ(0U, + cng_encoder.Encode(rtc::ArrayView(speech_data_, 160), + kNoSid, &sid_data)); // Normal Encode, 100 msec, SID data should be generated all the time. for (int i = 0; i < 10; i++) { - EXPECT_EQ(kCNGNumParamsNormal + 1, cng_encoder.Encode( - rtc::ArrayView(speech_data_, 160), kNoSid, &sid_data)); + EXPECT_EQ( + kCNGNumParamsNormal + 1, + cng_encoder.Encode(rtc::ArrayView(speech_data_, 160), + kNoSid, &sid_data)); } } diff --git a/modules/audio_coding/codecs/cng/webrtc_cng.cc b/modules/audio_coding/codecs/cng/webrtc_cng.cc index bd17a614bc..a07b093b3c 100644 --- a/modules/audio_coding/codecs/cng/webrtc_cng.cc +++ b/modules/audio_coding/codecs/cng/webrtc_cng.cc @@ -25,28 +25,26 @@ const size_t kCngMaxOutsizeOrder = 640; void WebRtcCng_K2a16(int16_t* k, int useOrder, int16_t* a); const int32_t WebRtcCng_kDbov[94] = { - 1081109975, 858756178, 682134279, 541838517, 430397633, 341876992, - 271562548, 215709799, 171344384, 136103682, 108110997, 85875618, - 68213428, 54183852, 43039763, 34187699, 27156255, 21570980, - 17134438, 13610368, 10811100, 8587562, 6821343, 5418385, - 4303976, 3418770, 2715625, 2157098, 1713444, 1361037, - 1081110, 858756, 682134, 541839, 430398, 341877, - 271563, 215710, 171344, 136104, 108111, 85876, - 68213, 54184, 43040, 34188, 27156, 21571, - 17134, 13610, 10811, 8588, 6821, 5418, - 4304, 3419, 2716, 2157, 1713, 1361, - 1081, 859, 682, 542, 430, 342, - 272, 216, 171, 136, 108, 86, - 68, 54, 43, 34, 27, 22, - 17, 14, 11, 9, 7, 5, - 4, 3, 3, 2, 2, 1, - 1, 1, 1, 1 -}; + 1081109975, 858756178, 682134279, 541838517, 430397633, 341876992, + 271562548, 215709799, 171344384, 136103682, 108110997, 85875618, + 68213428, 54183852, 43039763, 34187699, 27156255, 21570980, + 17134438, 13610368, 10811100, 8587562, 6821343, 5418385, + 4303976, 3418770, 2715625, 2157098, 1713444, 1361037, + 1081110, 858756, 682134, 541839, 430398, 341877, + 271563, 215710, 171344, 136104, 108111, 85876, + 68213, 54184, 43040, 34188, 27156, 21571, + 17134, 13610, 10811, 8588, 6821, 5418, + 4304, 3419, 2716, 2157, 1713, 1361, + 1081, 859, 682, 542, 430, 342, + 272, 216, 171, 136, 108, 86, + 68, 54, 43, 34, 27, 22, + 17, 14, 11, 9, 7, 5, + 4, 3, 3, 2, 2, 1, + 1, 1, 1, 1}; const int16_t WebRtcCng_kCorrWindow[WEBRTC_CNG_MAX_LPC_ORDER] = { - 32702, 32636, 32570, 32505, 32439, 32374, - 32309, 32244, 32179, 32114, 32049, 31985 -}; + 32702, 32636, 32570, 32505, 32439, 32374, + 32309, 32244, 32179, 32114, 32049, 31985}; } // namespace @@ -57,7 +55,7 @@ ComfortNoiseDecoder::ComfortNoiseDecoder() { } void ComfortNoiseDecoder::Reset() { - dec_seed_ = 7777; /* For debugging only. */ + dec_seed_ = 7777; /* For debugging only. */ dec_target_energy_ = 0; dec_used_energy_ = 0; for (auto& c : dec_target_reflCoefs_) @@ -115,11 +113,11 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView out_data, int16_t excitation[kCngMaxOutsizeOrder]; int16_t low[kCngMaxOutsizeOrder]; int16_t lpPoly[WEBRTC_CNG_MAX_LPC_ORDER + 1]; - int16_t ReflBetaStd = 26214; /* 0.8 in q15. */ - int16_t ReflBetaCompStd = 6553; /* 0.2 in q15. */ - int16_t ReflBetaNewP = 19661; /* 0.6 in q15. */ - int16_t ReflBetaCompNewP = 13107; /* 0.4 in q15. */ - int16_t Beta, BetaC; /* These are in Q15. */ + int16_t ReflBetaStd = 26214; /* 0.8 in q15. */ + int16_t ReflBetaCompStd = 6553; /* 0.2 in q15. */ + int16_t ReflBetaNewP = 19661; /* 0.6 in q15. */ + int16_t ReflBetaCompNewP = 13107; /* 0.4 in q15. */ + int16_t Beta, BetaC; /* These are in Q15. */ int32_t targetEnergy; int16_t En; int16_t temp16; @@ -139,30 +137,28 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView out_data, } /* Calculate new scale factor in Q13 */ - dec_used_scale_factor_ = - rtc::checked_cast( - WEBRTC_SPL_MUL_16_16_RSFT(dec_used_scale_factor_, Beta >> 2, 13) + - WEBRTC_SPL_MUL_16_16_RSFT(dec_target_scale_factor_, BetaC >> 2, 13)); + dec_used_scale_factor_ = rtc::checked_cast( + WEBRTC_SPL_MUL_16_16_RSFT(dec_used_scale_factor_, Beta >> 2, 13) + + WEBRTC_SPL_MUL_16_16_RSFT(dec_target_scale_factor_, BetaC >> 2, 13)); - dec_used_energy_ = dec_used_energy_ >> 1; + dec_used_energy_ = dec_used_energy_ >> 1; dec_used_energy_ += dec_target_energy_ >> 1; /* Do the same for the reflection coeffs, albeit in Q15. */ for (size_t i = 0; i < WEBRTC_CNG_MAX_LPC_ORDER; i++) { - dec_used_reflCoefs_[i] = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT( - dec_used_reflCoefs_[i], Beta, 15); - dec_used_reflCoefs_[i] += (int16_t) WEBRTC_SPL_MUL_16_16_RSFT( - dec_target_reflCoefs_[i], BetaC, 15); + dec_used_reflCoefs_[i] = + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_used_reflCoefs_[i], Beta, 15); + dec_used_reflCoefs_[i] += + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_target_reflCoefs_[i], BetaC, 15); } /* Compute the polynomial coefficients. */ WebRtcCng_K2a16(dec_used_reflCoefs_, WEBRTC_CNG_MAX_LPC_ORDER, lpPoly); - targetEnergy = dec_used_energy_; /* Calculate scaling factor based on filter energy. */ - En = 8192; /* 1.0 in Q13. */ + En = 8192; /* 1.0 in Q13. */ for (size_t i = 0; i < (WEBRTC_CNG_MAX_LPC_ORDER); i++) { /* Floating point value for reference. E *= 1.0 - (dec_used_reflCoefs_[i] / 32768.0) * @@ -171,11 +167,11 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView out_data, /* Same in fixed point. */ /* K(i).^2 in Q15. */ - temp16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT( - dec_used_reflCoefs_[i], dec_used_reflCoefs_[i], 15); + temp16 = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_used_reflCoefs_[i], + dec_used_reflCoefs_[i], 15); /* 1 - K(i).^2 in Q15. */ temp16 = 0x7fff - temp16; - En = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(En, temp16, 15); + En = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(En, temp16, 15); } /* float scaling= sqrt(E * dec_target_energy_ / (1 << 24)); */ @@ -183,8 +179,8 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView out_data, /* Calculate sqrt(En * target_energy / excitation energy) */ targetEnergy = WebRtcSpl_Sqrt(dec_used_energy_); - En = (int16_t) WebRtcSpl_Sqrt(En) << 6; - En = (En * 3) >> 1; /* 1.5 estimates sqrt(2). */ + En = (int16_t)WebRtcSpl_Sqrt(En) << 6; + En = (En * 3) >> 1; /* 1.5 estimates sqrt(2). */ dec_used_scale_factor_ = (int16_t)((En * targetEnergy) >> 12); /* Generate excitation. */ @@ -217,7 +213,7 @@ ComfortNoiseEncoder::ComfortNoiseEncoder(int fs, int interval, int quality) enc_Energy_(0), enc_reflCoefs_{0}, enc_corrVector_{0}, - enc_seed_(7777) /* For debugging only. */ { + enc_seed_(7777) /* For debugging only. */ { RTC_CHECK_GT(quality, 0); RTC_CHECK_LE(quality, WEBRTC_CNG_MAX_LPC_ORDER); /* Needed to get the right function pointers in SPLIB. */ @@ -236,7 +232,7 @@ void ComfortNoiseEncoder::Reset(int fs, int interval, int quality) { c = 0; for (auto& c : enc_corrVector_) c = 0; - enc_seed_ = 7777; /* For debugging only. */ + enc_seed_ = 7777; /* For debugging only. */ } size_t ComfortNoiseEncoder::Encode(rtc::ArrayView speech, @@ -312,20 +308,19 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView speech, if (negate) *bptr = -*bptr; - blo = (int32_t) * aptr * (*bptr & 0xffff); - bhi = ((blo >> 16) & 0xffff) - + ((int32_t)(*aptr++) * ((*bptr >> 16) & 0xffff)); + blo = (int32_t)*aptr * (*bptr & 0xffff); + bhi = ((blo >> 16) & 0xffff) + + ((int32_t)(*aptr++) * ((*bptr >> 16) & 0xffff)); blo = (blo & 0xffff) | ((bhi & 0xffff) << 16); - *bptr = (((bhi >> 16) & 0x7fff) << 17) | ((uint32_t) blo >> 15); + *bptr = (((bhi >> 16) & 0x7fff) << 17) | ((uint32_t)blo >> 15); if (negate) *bptr = -*bptr; bptr++; } /* End of bandwidth expansion. */ - stab = WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs, - enc_nrOfCoefs_); + stab = WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs, enc_nrOfCoefs_); if (!stab) { /* Disregard from this frame */ @@ -345,13 +340,12 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView speech, } else { /* Average history with new values. */ for (i = 0; i < enc_nrOfCoefs_; i++) { - enc_reflCoefs_[i] = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT( - enc_reflCoefs_[i], ReflBeta, 15); + enc_reflCoefs_[i] = + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(enc_reflCoefs_[i], ReflBeta, 15); enc_reflCoefs_[i] += - (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(refCs[i], ReflBetaComp, 15); + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(refCs[i], ReflBetaComp, 15); } - enc_Energy_ = - (outEnergy >> 2) + (enc_Energy_ >> 1) + (enc_Energy_ >> 2); + enc_Energy_ = (outEnergy >> 2) + (enc_Energy_ >> 1) + (enc_Energy_ >> 2); } if (enc_Energy_ < 1) { @@ -372,25 +366,25 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView speech, index = 94; const size_t output_coefs = enc_nrOfCoefs_ + 1; - output->AppendData(output_coefs, [&] (rtc::ArrayView output) { - output[0] = (uint8_t)index; + output->AppendData(output_coefs, [&](rtc::ArrayView output) { + output[0] = (uint8_t)index; - /* Quantize coefficients with tweak for WebRtc implementation of - * RFC3389. */ - if (enc_nrOfCoefs_ == WEBRTC_CNG_MAX_LPC_ORDER) { - for (i = 0; i < enc_nrOfCoefs_; i++) { - /* Q15 to Q7 with rounding. */ - output[i + 1] = ((enc_reflCoefs_[i] + 128) >> 8); - } - } else { - for (i = 0; i < enc_nrOfCoefs_; i++) { - /* Q15 to Q7 with rounding. */ - output[i + 1] = (127 + ((enc_reflCoefs_[i] + 128) >> 8)); - } + /* Quantize coefficients with tweak for WebRtc implementation of + * RFC3389. */ + if (enc_nrOfCoefs_ == WEBRTC_CNG_MAX_LPC_ORDER) { + for (i = 0; i < enc_nrOfCoefs_; i++) { + /* Q15 to Q7 with rounding. */ + output[i + 1] = ((enc_reflCoefs_[i] + 128) >> 8); } + } else { + for (i = 0; i < enc_nrOfCoefs_; i++) { + /* Q15 to Q7 with rounding. */ + output[i + 1] = (127 + ((enc_reflCoefs_[i] + 128) >> 8)); + } + } - return output_coefs; - }); + return output_coefs; + }); enc_msSinceSid_ = static_cast((1000 * num_samples) / enc_sampfreq_); diff --git a/modules/audio_coding/codecs/cng/webrtc_cng.h b/modules/audio_coding/codecs/cng/webrtc_cng.h index 5e21b8fd4f..684480a1d3 100644 --- a/modules/audio_coding/codecs/cng/webrtc_cng.h +++ b/modules/audio_coding/codecs/cng/webrtc_cng.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_ #define MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_ @@ -54,8 +53,8 @@ class ComfortNoiseDecoder { int16_t dec_filtstate_[WEBRTC_CNG_MAX_LPC_ORDER + 1]; int16_t dec_filtstateLow_[WEBRTC_CNG_MAX_LPC_ORDER + 1]; uint16_t dec_order_; - int16_t dec_target_scale_factor_; /* Q29 */ - int16_t dec_used_scale_factor_; /* Q29 */ + int16_t dec_target_scale_factor_; /* Q29 */ + int16_t dec_used_scale_factor_; /* Q29 */ }; class ComfortNoiseEncoder { diff --git a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc index a620a3ed7b..25f495f39d 100644 --- a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc +++ b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc @@ -10,8 +10,8 @@ #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" -#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" #include "modules/audio_coding/codecs/g711/g711_interface.h" +#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc index 9fb94fd5c1..c14287ed48 100644 --- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc +++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc @@ -42,8 +42,8 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz) payload_type_(config.payload_type), num_10ms_frames_per_packet_( static_cast(config.frame_size_ms / 10)), - full_frame_samples_( - config.num_channels * config.frame_size_ms * sample_rate_hz / 1000), + full_frame_samples_(config.num_channels * config.frame_size_ms * + sample_rate_hz / 1000), first_timestamp_in_buffer_(0) { RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz"; RTC_CHECK_EQ(config.frame_size_ms % 10, 0) @@ -70,8 +70,8 @@ size_t AudioEncoderPcm::Max10MsFramesInAPacket() const { } int AudioEncoderPcm::GetTargetBitrate() const { - return static_cast( - 8 * BytesPerSample() * SampleRateHz() * NumChannels()); + return static_cast(8 * BytesPerSample() * SampleRateHz() * + NumChannels()); } AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl( @@ -89,13 +89,12 @@ AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl( EncodedInfo info; info.encoded_timestamp = first_timestamp_in_buffer_; info.payload_type = payload_type_; - info.encoded_bytes = - encoded->AppendData(full_frame_samples_ * BytesPerSample(), - [&] (rtc::ArrayView encoded) { - return EncodeCall(&speech_buffer_[0], - full_frame_samples_, - encoded.data()); - }); + info.encoded_bytes = encoded->AppendData( + full_frame_samples_ * BytesPerSample(), + [&](rtc::ArrayView encoded) { + return EncodeCall(&speech_buffer_[0], full_frame_samples_, + encoded.data()); + }); speech_buffer_.clear(); info.encoder_type = GetCodecType(); return info; diff --git a/modules/audio_coding/codecs/g711/g711.h b/modules/audio_coding/codecs/g711/g711.h index 8b1fc81ad1..365f31b470 100644 --- a/modules/audio_coding/codecs/g711/g711.h +++ b/modules/audio_coding/codecs/g711/g711.h @@ -17,7 +17,8 @@ * Modifications for WebRtc, 2011/04/28, by tlegrand: * -Changed to use WebRtc types * -Changed __inline__ to __inline - * -Two changes to make implementation bitexact with ITU-T reference implementation + * -Two changes to make implementation bitexact with ITU-T reference + * implementation */ /*! \page g711_page A-law and mu-law handling @@ -58,10 +59,11 @@ extern "C" { static __inline__ int top_bit(unsigned int bits) { int res; - __asm__ __volatile__(" movl $-1,%%edx;\n" - " bsrl %%eax,%%edx;\n" - : "=d" (res) - : "a" (bits)); + __asm__ __volatile__( + " movl $-1,%%edx;\n" + " bsrl %%eax,%%edx;\n" + : "=d"(res) + : "a"(bits)); return res; } @@ -71,30 +73,33 @@ static __inline__ int top_bit(unsigned int bits) { static __inline__ int bottom_bit(unsigned int bits) { int res; - __asm__ __volatile__(" movl $-1,%%edx;\n" - " bsfl %%eax,%%edx;\n" - : "=d" (res) - : "a" (bits)); + __asm__ __volatile__( + " movl $-1,%%edx;\n" + " bsfl %%eax,%%edx;\n" + : "=d"(res) + : "a"(bits)); return res; } #elif defined(__x86_64__) static __inline__ int top_bit(unsigned int bits) { int res; - __asm__ __volatile__(" movq $-1,%%rdx;\n" - " bsrq %%rax,%%rdx;\n" - : "=d" (res) - : "a" (bits)); + __asm__ __volatile__( + " movq $-1,%%rdx;\n" + " bsrq %%rax,%%rdx;\n" + : "=d"(res) + : "a"(bits)); return res; } static __inline__ int bottom_bit(unsigned int bits) { int res; - __asm__ __volatile__(" movq $-1,%%rdx;\n" - " bsfq %%rax,%%rdx;\n" - : "=d" (res) - : "a" (bits)); + __asm__ __volatile__( + " movq $-1,%%rdx;\n" + " bsfq %%rax,%%rdx;\n" + : "=d"(res) + : "a"(bits)); return res; } #else @@ -166,8 +171,8 @@ static __inline int bottom_bit(unsigned int bits) { * linear sound like peanuts these days, and shouldn't an array lookup be * real fast? No! When the cache sloshes as badly as this one will, a tight * calculation may be better. The messiest part is normally finding the - * segment, but a little inline assembly can fix that on an i386, x86_64 and - * many other modern processors. + * segment, but a little inline assembly can fix that on an i386, x86_64 + * and many other modern processors. */ /* @@ -196,8 +201,9 @@ static __inline int bottom_bit(unsigned int bits) { * John Wiley & Sons, pps 98-111 and 472-476. */ -//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */ -#define ULAW_BIAS 0x84 /* Bias for linear code. */ +//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD +//*/ +#define ULAW_BIAS 0x84 /* Bias for linear code. */ /*! \brief Encode a linear sample to u-law \param linear The sample to encode. @@ -249,7 +255,7 @@ static __inline int16_t ulaw_to_linear(uint8_t ulaw) { * Extract and bias the quantization bits. Then * shift up by the segment number and subtract out the bias. */ - t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4); + t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int)ulaw & 0x70) >> 4); return (int16_t)((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS)); } @@ -317,7 +323,7 @@ static __inline int16_t alaw_to_linear(uint8_t alaw) { alaw ^= ALAW_AMI_MASK; i = ((alaw & 0x0F) << 4); - seg = (((int) alaw & 0x70) >> 4); + seg = (((int)alaw & 0x70) >> 4); if (seg) i = (i + 0x108) << (seg - 1); else diff --git a/modules/audio_coding/codecs/g711/g711_interface.h b/modules/audio_coding/codecs/g711/g711_interface.h index 1f23da62de..f206f30306 100644 --- a/modules/audio_coding/codecs/g711/g711_interface.h +++ b/modules/audio_coding/codecs/g711/g711_interface.h @@ -112,19 +112,19 @@ size_t WebRtcG711_DecodeU(const uint8_t* encoded, int16_t* speechType); /********************************************************************** -* WebRtcG711_Version(...) -* -* This function gives the version string of the G.711 codec. -* -* Input: -* - lenBytes: the size of Allocated space (in Bytes) where -* the version number is written to (in string format). -* -* Output: -* - version: Pointer to a buffer where the version number is -* written to. -* -*/ + * WebRtcG711_Version(...) + * + * This function gives the version string of the G.711 codec. + * + * Input: + * - lenBytes: the size of Allocated space (in Bytes) where + * the version number is written to (in string format). + * + * Output: + * - version: Pointer to a buffer where the version number is + * written to. + * + */ int16_t WebRtcG711_Version(char* version, int16_t lenBytes); diff --git a/modules/audio_coding/codecs/g711/test/testG711.cc b/modules/audio_coding/codecs/g711/test/testG711.cc index 98f3925faa..f3a42f5d79 100644 --- a/modules/audio_coding/codecs/g711/test/testG711.cc +++ b/modules/audio_coding/codecs/g711/test/testG711.cc @@ -69,7 +69,6 @@ int main(int argc, char* argv[]) { printf("outfile : Speech output file\n\n"); printf("outbits : Output bitstream file [optional]\n\n"); exit(0); - } /* Get version and print */ @@ -80,8 +79,8 @@ int main(int argc, char* argv[]) { /* Get frame length */ int framelength_int = atoi(argv[1]); if (framelength_int < 0) { - printf(" G.722: Invalid framelength %d.\n", framelength_int); - exit(1); + printf(" G.722: Invalid framelength %d.\n", framelength_int); + exit(1); } framelength = static_cast(framelength_int); @@ -112,7 +111,7 @@ int main(int argc, char* argv[]) { printf("\nBitfile: %s\n", bitname); } - starttime = clock() / (double) CLOCKS_PER_SEC_G711; /* Runtime statistics */ + starttime = clock() / (double)CLOCKS_PER_SEC_G711; /* Runtime statistics */ /* Initialize encoder and decoder */ framecnt = 0; @@ -155,11 +154,10 @@ int main(int argc, char* argv[]) { } } - runtime = (double)(clock() / (double) CLOCKS_PER_SEC_G711 - starttime); - length_file = ((double) framecnt * (double) framelength / 8000); + runtime = (double)(clock() / (double)CLOCKS_PER_SEC_G711 - starttime); + length_file = ((double)framecnt * (double)framelength / 8000); printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", - runtime, + printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", runtime, (100 * runtime / length_file)); printf("---------------------END----------------------\n"); diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc index ec97ee3321..cb96c3c17e 100644 --- a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc +++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc @@ -123,7 +123,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722Impl::EncodeImpl( const size_t bytes_to_encode = samples_per_channel / 2 * num_channels_; EncodedInfo info; info.encoded_bytes = encoded->AppendData( - bytes_to_encode, [&] (rtc::ArrayView encoded) { + bytes_to_encode, [&](rtc::ArrayView encoded) { // Interleave the encoded bytes of the different channels. Each separate // channel and the interleaved stream encodes two samples per byte, most // significant half first. diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.h b/modules/audio_coding/codecs/g722/audio_encoder_g722.h index 1f4b943f66..3cf143914f 100644 --- a/modules/audio_coding/codecs/g722/audio_encoder_g722.h +++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.h @@ -46,8 +46,8 @@ class AudioEncoderG722Impl final : public AudioEncoder { // The encoder state for one channel. struct EncoderState { G722EncInst* encoder; - std::unique_ptr speech_buffer; // Queued up for encoding. - rtc::Buffer encoded_buffer; // Already encoded. + std::unique_ptr speech_buffer; // Queued up for encoding. + rtc::Buffer encoded_buffer; // Already encoded. EncoderState(); ~EncoderState(); }; diff --git a/modules/audio_coding/codecs/g722/g722_enc_dec.h b/modules/audio_coding/codecs/g722/g722_enc_dec.h index ccda09baf7..24f238d4d5 100644 --- a/modules/audio_coding/codecs/g722/g722_enc_dec.h +++ b/modules/audio_coding/codecs/g722/g722_enc_dec.h @@ -7,7 +7,7 @@ * * Copyright (C) 2005 Steve Underwood * - * Despite my general liking of the GPL, I place my own contributions + * Despite my general liking of the GPL, I place my own contributions * to this code in the public domain for the benefit of all mankind - * even the slimy ones who might try to proprietize my work and use it * to my detriment. @@ -25,7 +25,6 @@ * -Added new defines for minimum and maximum values of short int */ - /*! \file */ #if !defined(_G722_ENC_DEC_H_) @@ -35,12 +34,14 @@ /*! \page g722_page G.722 encoding and decoding \section g722_page_sec_1 What does it do? -The G.722 module is a bit exact implementation of the ITU G.722 specification for all three -specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. +The G.722 module is a bit exact implementation of the ITU G.722 specification +for all three specified bit rates - 64000bps, 56000bps and 48000bps. It passes +the ITU tests. -To allow fast and flexible interworking with narrow band telephony, the encoder and decoder -support an option for the linear audio to be an 8k samples/second stream. In this mode the -codec is considerably faster, and still fully compatible with wideband terminals using G.722. +To allow fast and flexible interworking with narrow band telephony, the encoder +and decoder support an option for the linear audio to be an 8k samples/second +stream. In this mode the codec is considerably faster, and still fully +compatible with wideband terminals using G.722. \section g722_page_sec_2 How does it work? ???. @@ -49,86 +50,78 @@ codec is considerably faster, and still fully compatible with wideband terminals #define WEBRTC_INT16_MAX 32767 #define WEBRTC_INT16_MIN -32768 -enum -{ - G722_SAMPLE_RATE_8000 = 0x0001, - G722_PACKED = 0x0002 -}; +enum { G722_SAMPLE_RATE_8000 = 0x0001, G722_PACKED = 0x0002 }; -typedef struct -{ - /*! TRUE if the operating in the special ITU test mode, with the band split filters - disabled. */ - int itu_test_mode; - /*! TRUE if the G.722 data is packed */ - int packed; - /*! TRUE if encode from 8k samples/second */ - int eight_k; - /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ - int bits_per_sample; +typedef struct { + /*! TRUE if the operating in the special ITU test mode, with the band split + filters disabled. */ + int itu_test_mode; + /*! TRUE if the G.722 data is packed */ + int packed; + /*! TRUE if encode from 8k samples/second */ + int eight_k; + /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ + int bits_per_sample; - /*! Signal history for the QMF */ - int x[24]; + /*! Signal history for the QMF */ + int x[24]; - struct - { - int s; - int sp; - int sz; - int r[3]; - int a[3]; - int ap[3]; - int p[3]; - int d[7]; - int b[7]; - int bp[7]; - int sg[7]; - int nb; - int det; - } band[2]; + struct { + int s; + int sp; + int sz; + int r[3]; + int a[3]; + int ap[3]; + int p[3]; + int d[7]; + int b[7]; + int bp[7]; + int sg[7]; + int nb; + int det; + } band[2]; - unsigned int in_buffer; - int in_bits; - unsigned int out_buffer; - int out_bits; + unsigned int in_buffer; + int in_bits; + unsigned int out_buffer; + int out_bits; } G722EncoderState; -typedef struct -{ - /*! TRUE if the operating in the special ITU test mode, with the band split filters - disabled. */ - int itu_test_mode; - /*! TRUE if the G.722 data is packed */ - int packed; - /*! TRUE if decode to 8k samples/second */ - int eight_k; - /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ - int bits_per_sample; +typedef struct { + /*! TRUE if the operating in the special ITU test mode, with the band split + filters disabled. */ + int itu_test_mode; + /*! TRUE if the G.722 data is packed */ + int packed; + /*! TRUE if decode to 8k samples/second */ + int eight_k; + /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ + int bits_per_sample; - /*! Signal history for the QMF */ - int x[24]; + /*! Signal history for the QMF */ + int x[24]; - struct - { - int s; - int sp; - int sz; - int r[3]; - int a[3]; - int ap[3]; - int p[3]; - int d[7]; - int b[7]; - int bp[7]; - int sg[7]; - int nb; - int det; - } band[2]; - - unsigned int in_buffer; - int in_bits; - unsigned int out_buffer; - int out_bits; + struct { + int s; + int sp; + int sz; + int r[3]; + int a[3]; + int ap[3]; + int p[3]; + int d[7]; + int b[7]; + int bp[7]; + int sg[7]; + int nb; + int det; + } band[2]; + + unsigned int in_buffer; + int in_bits; + unsigned int out_buffer; + int out_bits; } G722DecoderState; #ifdef __cplusplus @@ -138,8 +131,8 @@ extern "C" { G722EncoderState* WebRtc_g722_encode_init(G722EncoderState* s, int rate, int options); -int WebRtc_g722_encode_release(G722EncoderState *s); -size_t WebRtc_g722_encode(G722EncoderState *s, +int WebRtc_g722_encode_release(G722EncoderState* s); +size_t WebRtc_g722_encode(G722EncoderState* s, uint8_t g722_data[], const int16_t amp[], size_t len); @@ -147,8 +140,8 @@ size_t WebRtc_g722_encode(G722EncoderState *s, G722DecoderState* WebRtc_g722_decode_init(G722DecoderState* s, int rate, int options); -int WebRtc_g722_decode_release(G722DecoderState *s); -size_t WebRtc_g722_decode(G722DecoderState *s, +int WebRtc_g722_decode_release(G722DecoderState* s); +size_t WebRtc_g722_decode(G722DecoderState* s, int16_t amp[], const uint8_t g722_data[], size_t len); diff --git a/modules/audio_coding/codecs/g722/g722_interface.h b/modules/audio_coding/codecs/g722/g722_interface.h index d95722314f..3b73f858a0 100644 --- a/modules/audio_coding/codecs/g722/g722_interface.h +++ b/modules/audio_coding/codecs/g722/g722_interface.h @@ -17,21 +17,20 @@ * Solution to support multiple instances */ -typedef struct WebRtcG722EncInst G722EncInst; -typedef struct WebRtcG722DecInst G722DecInst; +typedef struct WebRtcG722EncInst G722EncInst; +typedef struct WebRtcG722DecInst G722DecInst; /* * Comfort noise constants */ -#define G722_WEBRTC_SPEECH 1 -#define G722_WEBRTC_CNG 2 +#define G722_WEBRTC_SPEECH 1 +#define G722_WEBRTC_CNG 2 #ifdef __cplusplus extern "C" { #endif - /**************************************************************************** * WebRtcG722_CreateEncoder(...) * @@ -43,8 +42,7 @@ extern "C" { * Return value : 0 - Ok * -1 - Error */ -int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst); - +int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst); /**************************************************************************** * WebRtcG722_EncoderInit(...) @@ -59,8 +57,7 @@ int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst); * -1 - Error */ -int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst); - +int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst); /**************************************************************************** * WebRtcG722_FreeEncoder(...) @@ -73,9 +70,7 @@ int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst); * Return value : 0 - Ok * -1 - Error */ -int WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst); - - +int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst); /**************************************************************************** * WebRtcG722_Encode(...) @@ -99,7 +94,6 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst, size_t len, uint8_t* encoded); - /**************************************************************************** * WebRtcG722_CreateDecoder(...) * @@ -111,7 +105,7 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst, * Return value : 0 - Ok * -1 - Error */ -int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst); +int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst); /**************************************************************************** * WebRtcG722_DecoderInit(...) @@ -136,8 +130,7 @@ void WebRtcG722_DecoderInit(G722DecInst* inst); * -1 - Error */ -int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst); - +int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst); /**************************************************************************** * WebRtcG722_Decode(...) @@ -159,11 +152,11 @@ int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst); * Return value : Samples in decoded vector */ -size_t WebRtcG722_Decode(G722DecInst *G722dec_inst, +size_t WebRtcG722_Decode(G722DecInst* G722dec_inst, const uint8_t* encoded, size_t len, - int16_t *decoded, - int16_t *speechType); + int16_t* decoded, + int16_t* speechType); /**************************************************************************** * WebRtcG722_Version(...) @@ -171,12 +164,10 @@ size_t WebRtcG722_Decode(G722DecInst *G722dec_inst, * Get a string with the current version of the codec */ -int16_t WebRtcG722_Version(char *versionStr, short len); - +int16_t WebRtcG722_Version(char* versionStr, short len); #ifdef __cplusplus } #endif - #endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */ diff --git a/modules/audio_coding/codecs/g722/test/testG722.cc b/modules/audio_coding/codecs/g722/test/testG722.cc index e0281f2b65..ada56ab90f 100644 --- a/modules/audio_coding/codecs/g722/test/testG722.cc +++ b/modules/audio_coding/codecs/g722/test/testG722.cc @@ -22,137 +22,135 @@ /* Runtime statistics */ #include -#define CLOCKS_PER_SEC_G722 100000 +#define CLOCKS_PER_SEC_G722 100000 // Forward declaration -typedef struct WebRtcG722EncInst G722EncInst; -typedef struct WebRtcG722DecInst G722DecInst; +typedef struct WebRtcG722EncInst G722EncInst; +typedef struct WebRtcG722DecInst G722DecInst; /* function for reading audio data from PCM file */ -bool readframe(int16_t *data, FILE *inp, size_t length) -{ - size_t rlen = fread(data, sizeof(int16_t), length, inp); - if (rlen >= length) - return false; - memset(data + rlen, 0, (length - rlen) * sizeof(int16_t)); - return true; +bool readframe(int16_t* data, FILE* inp, size_t length) { + size_t rlen = fread(data, sizeof(int16_t), length, inp); + if (rlen >= length) + return false; + memset(data + rlen, 0, (length - rlen) * sizeof(int16_t)); + return true; } -int main(int argc, char* argv[]) -{ - char inname[60], outbit[40], outname[40]; - FILE *inp, *outbitp, *outp; +int main(int argc, char* argv[]) { + char inname[60], outbit[40], outname[40]; + FILE *inp, *outbitp, *outp; - int framecnt; - bool endfile; - size_t framelength = 160; - G722EncInst *G722enc_inst; - G722DecInst *G722dec_inst; + int framecnt; + bool endfile; + size_t framelength = 160; + G722EncInst* G722enc_inst; + G722DecInst* G722dec_inst; - /* Runtime statistics */ - double starttime; - double runtime = 0; - double length_file; + /* Runtime statistics */ + double starttime; + double runtime = 0; + double length_file; - size_t stream_len = 0; - int16_t shortdata[960]; - int16_t decoded[960]; - uint8_t streamdata[80 * 6]; - int16_t speechType[1]; + size_t stream_len = 0; + int16_t shortdata[960]; + int16_t decoded[960]; + uint8_t streamdata[80 * 6]; + int16_t speechType[1]; - /* handling wrong input arguments in the command line */ - if (argc!=5) { - printf("\n\nWrong number of arguments or flag values.\n\n"); + /* handling wrong input arguments in the command line */ + if (argc != 5) { + printf("\n\nWrong number of arguments or flag values.\n\n"); - printf("\n"); - printf("Usage:\n\n"); - printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n"); - printf("with:\n"); - printf("framelength : Framelength in samples.\n\n"); - printf("infile : Normal speech input file\n\n"); - printf("outbitfile : Bitstream output file\n\n"); - printf("outspeechfile: Speech output file\n\n"); - exit(0); + printf("\n"); + printf("Usage:\n\n"); + printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n"); + printf("with:\n"); + printf("framelength : Framelength in samples.\n\n"); + printf("infile : Normal speech input file\n\n"); + printf("outbitfile : Bitstream output file\n\n"); + printf("outspeechfile: Speech output file\n\n"); + exit(0); + } + /* Get frame length */ + int framelength_int = atoi(argv[1]); + if (framelength_int < 0) { + printf(" G.722: Invalid framelength %d.\n", framelength_int); + exit(1); + } + framelength = static_cast(framelength_int); + + /* Get Input and Output files */ + sscanf(argv[2], "%s", inname); + sscanf(argv[3], "%s", outbit); + sscanf(argv[4], "%s", outname); + + if ((inp = fopen(inname, "rb")) == NULL) { + printf(" G.722: Cannot read file %s.\n", inname); + exit(1); + } + if ((outbitp = fopen(outbit, "wb")) == NULL) { + printf(" G.722: Cannot write file %s.\n", outbit); + exit(1); + } + if ((outp = fopen(outname, "wb")) == NULL) { + printf(" G.722: Cannot write file %s.\n", outname); + exit(1); + } + printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit, + outname); + + /* Create and init */ + WebRtcG722_CreateEncoder((G722EncInst**)&G722enc_inst); + WebRtcG722_CreateDecoder((G722DecInst**)&G722dec_inst); + WebRtcG722_EncoderInit((G722EncInst*)G722enc_inst); + WebRtcG722_DecoderInit((G722DecInst*)G722dec_inst); + + /* Initialize encoder and decoder */ + framecnt = 0; + endfile = false; + while (!endfile) { + framecnt++; + + /* Read speech block */ + endfile = readframe(shortdata, inp, framelength); + + /* Start clock before call to encoder and decoder */ + starttime = clock() / (double)CLOCKS_PER_SEC_G722; + + /* G.722 encoding + decoding */ + stream_len = WebRtcG722_Encode((G722EncInst*)G722enc_inst, shortdata, + framelength, streamdata); + WebRtcG722_Decode(G722dec_inst, streamdata, stream_len, decoded, + speechType); + + /* Stop clock after call to encoder and decoder */ + runtime += (double)((clock() / (double)CLOCKS_PER_SEC_G722) - starttime); + + /* Write coded bits to file */ + if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) != + stream_len / 2) { + return -1; } - - /* Get frame length */ - int framelength_int = atoi(argv[1]); - if (framelength_int < 0) { - printf(" G.722: Invalid framelength %d.\n", framelength_int); - exit(1); + /* Write coded speech to file */ + if (fwrite(decoded, sizeof(short), framelength, outp) != framelength) { + return -1; } - framelength = static_cast(framelength_int); + } - /* Get Input and Output files */ - sscanf(argv[2], "%s", inname); - sscanf(argv[3], "%s", outbit); - sscanf(argv[4], "%s", outname); + WebRtcG722_FreeEncoder((G722EncInst*)G722enc_inst); + WebRtcG722_FreeDecoder((G722DecInst*)G722dec_inst); - if ((inp = fopen(inname,"rb")) == NULL) { - printf(" G.722: Cannot read file %s.\n", inname); - exit(1); - } - if ((outbitp = fopen(outbit,"wb")) == NULL) { - printf(" G.722: Cannot write file %s.\n", outbit); - exit(1); - } - if ((outp = fopen(outname,"wb")) == NULL) { - printf(" G.722: Cannot write file %s.\n", outname); - exit(1); - } - printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit, outname); + length_file = ((double)framecnt * (double)framelength / 16000); + printf("\n\nLength of speech file: %.1f s\n", length_file); + printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime, + (100 * runtime / length_file)); + printf("---------------------END----------------------\n"); - /* Create and init */ - WebRtcG722_CreateEncoder((G722EncInst **)&G722enc_inst); - WebRtcG722_CreateDecoder((G722DecInst **)&G722dec_inst); - WebRtcG722_EncoderInit((G722EncInst *)G722enc_inst); - WebRtcG722_DecoderInit((G722DecInst *)G722dec_inst); + fclose(inp); + fclose(outbitp); + fclose(outp); - - /* Initialize encoder and decoder */ - framecnt = 0; - endfile = false; - while (!endfile) { - framecnt++; - - /* Read speech block */ - endfile = readframe(shortdata, inp, framelength); - - /* Start clock before call to encoder and decoder */ - starttime = clock()/(double)CLOCKS_PER_SEC_G722; - - /* G.722 encoding + decoding */ - stream_len = WebRtcG722_Encode((G722EncInst *)G722enc_inst, shortdata, framelength, streamdata); - WebRtcG722_Decode(G722dec_inst, streamdata, stream_len, decoded, - speechType); - - /* Stop clock after call to encoder and decoder */ - runtime += (double)((clock()/(double)CLOCKS_PER_SEC_G722)-starttime); - - /* Write coded bits to file */ - if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) != - stream_len / 2) { - return -1; - } - /* Write coded speech to file */ - if (fwrite(decoded, sizeof(short), framelength, outp) != - framelength) { - return -1; - } - } - - WebRtcG722_FreeEncoder((G722EncInst *)G722enc_inst); - WebRtcG722_FreeDecoder((G722DecInst *)G722dec_inst); - - length_file = ((double)framecnt*(double)framelength/16000); - printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file)); - printf("---------------------END----------------------\n"); - - fclose(inp); - fclose(outbitp); - fclose(outp); - - return 0; + return 0; } diff --git a/modules/audio_coding/codecs/ilbc/abs_quant.h b/modules/audio_coding/codecs/ilbc/abs_quant.h index 3a98a6e701..331921cc63 100644 --- a/modules/audio_coding/codecs/ilbc/abs_quant.h +++ b/modules/audio_coding/codecs/ilbc/abs_quant.h @@ -27,13 +27,13 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_AbsQuant( - IlbcEncoder *iLBCenc_inst, + IlbcEncoder* iLBCenc_inst, /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax + iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax and idxVec, uses state_first as input) */ - int16_t *in, /* (i) vector to encode */ - int16_t *weightDenum /* (i) denominator of synthesis filter */ - ); + int16_t* in, /* (i) vector to encode */ + int16_t* weightDenum /* (i) denominator of synthesis filter */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/abs_quant_loop.h b/modules/audio_coding/codecs/ilbc/abs_quant_loop.h index 5116bfd85a..a193a07cda 100644 --- a/modules/audio_coding/codecs/ilbc/abs_quant_loop.h +++ b/modules/audio_coding/codecs/ilbc/abs_quant_loop.h @@ -26,8 +26,10 @@ * (subrutine for WebRtcIlbcfix_StateSearch) *---------------------------------------------------------------*/ -void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN, - int16_t *weightDenumIN, size_t *quantLenIN, - int16_t *idxVecIN); +void WebRtcIlbcfix_AbsQuantLoop(int16_t* syntOutIN, + int16_t* in_weightedIN, + int16_t* weightDenumIN, + size_t* quantLenIN, + int16_t* idxVecIN); #endif diff --git a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc index 08d21f4202..9e58ce03ca 100644 --- a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc +++ b/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc @@ -33,10 +33,10 @@ bool AudioDecoderIlbcImpl::HasDecodePlc() const { } int AudioDecoderIlbcImpl::DecodeInternal(const uint8_t* encoded, - size_t encoded_len, - int sample_rate_hz, - int16_t* decoded, - SpeechType* speech_type) { + size_t encoded_len, + int sample_rate_hz, + int16_t* decoded, + SpeechType* speech_type) { RTC_DCHECK_EQ(sample_rate_hz, 8000); int16_t temp_type = 1; // Default is speech. int ret = WebRtcIlbcfix_Decode(dec_state_, encoded, encoded_len, decoded, @@ -86,10 +86,9 @@ std::vector AudioDecoderIlbcImpl::ParsePayload( } else { size_t byte_offset; uint32_t timestamp_offset; - for (byte_offset = 0, timestamp_offset = 0; - byte_offset < payload.size(); + for (byte_offset = 0, timestamp_offset = 0; byte_offset < payload.size(); byte_offset += bytes_per_frame, - timestamp_offset += timestamps_per_frame) { + timestamp_offset += timestamps_per_frame) { std::unique_ptr frame(new LegacyEncodedAudioFrame( this, rtc::Buffer(payload.data() + byte_offset, bytes_per_frame))); results.emplace_back(timestamp + timestamp_offset, 0, std::move(frame)); diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc index 6ddc078f09..84695e3763 100644 --- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc +++ b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc @@ -89,7 +89,6 @@ AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl( uint32_t rtp_timestamp, rtc::ArrayView audio, rtc::Buffer* encoded) { - // Save timestamp if starting a new packet. if (num_10ms_frames_buffered_ == 0) first_timestamp_in_buffer_ = rtp_timestamp; @@ -107,19 +106,15 @@ AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl( // Encode buffered input. RTC_DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_); num_10ms_frames_buffered_ = 0; - size_t encoded_bytes = - encoded->AppendData( - RequiredOutputSizeBytes(), - [&] (rtc::ArrayView encoded) { - const int r = WebRtcIlbcfix_Encode( - encoder_, - input_buffer_, - kSampleRateHz / 100 * num_10ms_frames_per_packet_, - encoded.data()); - RTC_CHECK_GE(r, 0); + size_t encoded_bytes = encoded->AppendData( + RequiredOutputSizeBytes(), [&](rtc::ArrayView encoded) { + const int r = WebRtcIlbcfix_Encode( + encoder_, input_buffer_, + kSampleRateHz / 100 * num_10ms_frames_per_packet_, encoded.data()); + RTC_CHECK_GE(r, 0); - return static_cast(r); - }); + return static_cast(r); + }); RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes()); @@ -135,20 +130,24 @@ void AudioEncoderIlbcImpl::Reset() { if (encoder_) RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_)); RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_)); - const int encoder_frame_size_ms = frame_size_ms_ > 30 - ? frame_size_ms_ / 2 - : frame_size_ms_; + const int encoder_frame_size_ms = + frame_size_ms_ > 30 ? frame_size_ms_ / 2 : frame_size_ms_; RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms)); num_10ms_frames_buffered_ = 0; } size_t AudioEncoderIlbcImpl::RequiredOutputSizeBytes() const { switch (num_10ms_frames_per_packet_) { - case 2: return 38; - case 3: return 50; - case 4: return 2 * 38; - case 6: return 2 * 50; - default: FATAL(); + case 2: + return 38; + case 3: + return 50; + case 4: + return 2 * 38; + case 6: + return 2 * 50; + default: + FATAL(); } } diff --git a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h b/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h index 581f0d6b90..646e5649b9 100644 --- a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h +++ b/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h @@ -26,16 +26,16 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_AugmentedCbCorr( - int16_t *target, /* (i) Target vector */ - int16_t *buffer, /* (i) Memory buffer */ - int16_t *interpSamples, /* (i) buffer with + int16_t* target, /* (i) Target vector */ + int16_t* buffer, /* (i) Memory buffer */ + int16_t* interpSamples, /* (i) buffer with interpolated samples */ - int32_t *crossDot, /* (o) The cross correlation between - the target and the Augmented - vector */ - size_t low, /* (i) Lag to start from (typically - 20) */ - size_t high, /* (i) Lag to end at (typically 39 */ - int scale); /* (i) Scale factor to use for the crossDot */ + int32_t* crossDot, /* (o) The cross correlation between + the target and the Augmented + vector */ + size_t low, /* (i) Lag to start from (typically + 20) */ + size_t high, /* (i) Lag to end at (typically 39 */ + int scale); /* (i) Scale factor to use for the crossDot */ #endif diff --git a/modules/audio_coding/codecs/ilbc/bw_expand.h b/modules/audio_coding/codecs/ilbc/bw_expand.h index ee9e45a7bc..d25325c7f2 100644 --- a/modules/audio_coding/codecs/ilbc/bw_expand.h +++ b/modules/audio_coding/codecs/ilbc/bw_expand.h @@ -26,11 +26,11 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_BwExpand( - int16_t *out, /* (o) the bandwidth expanded lpc coefficients */ - int16_t *in, /* (i) the lpc coefficients before bandwidth - expansion */ - int16_t *coef, /* (i) the bandwidth expansion factor Q15 */ + int16_t* out, /* (o) the bandwidth expanded lpc coefficients */ + int16_t* in, /* (i) the lpc coefficients before bandwidth + expansion */ + int16_t* coef, /* (i) the bandwidth expansion factor Q15 */ int16_t length /* (i) the length of lpc coefficient vectors */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy.h index e8e2fe979a..894f5d051c 100644 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy.h +++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy.h @@ -21,14 +21,14 @@ void WebRtcIlbcfix_CbMemEnergy( size_t range, - int16_t *CB, /* (i) The CB memory (1:st section) */ - int16_t *filteredCB, /* (i) The filtered CB memory (2:nd section) */ - size_t lMem, /* (i) Length of the CB memory */ - size_t lTarget, /* (i) Length of the target vector */ - int16_t *energyW16, /* (o) Energy in the CB vectors */ - int16_t *energyShifts, /* (o) Shift value of the energy */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size /* (i) Index to where energy values should be stored */ - ); + int16_t* CB, /* (i) The CB memory (1:st section) */ + int16_t* filteredCB, /* (i) The filtered CB memory (2:nd section) */ + size_t lMem, /* (i) Length of the CB memory */ + size_t lTarget, /* (i) Length of the target vector */ + int16_t* energyW16, /* (o) Energy in the CB vectors */ + int16_t* energyShifts, /* (o) Shift value of the energy */ + int scale, /* (i) The scaling of all energy values */ + size_t base_size /* (i) Index to where energy values should be stored */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h index 00eb0179f1..b7b972f911 100644 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h +++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h @@ -20,12 +20,12 @@ #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ void WebRtcIlbcfix_CbMemEnergyAugmentation( - int16_t *interpSamples, /* (i) The interpolated samples */ - int16_t *CBmem, /* (i) The CB memory */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size, /* (i) Index to where energy values should be stored */ - int16_t *energyW16, /* (o) Energy in the CB vectors */ - int16_t *energyShifts /* (o) Shift value of the energy */ - ); + int16_t* interpSamples, /* (i) The interpolated samples */ + int16_t* CBmem, /* (i) The CB memory */ + int scale, /* (i) The scaling of all energy values */ + size_t base_size, /* (i) Index to where energy values should be stored */ + int16_t* energyW16, /* (o) Energy in the CB vectors */ + int16_t* energyShifts /* (o) Shift value of the energy */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h index af8e658a02..5511ef1f3f 100644 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h +++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h @@ -20,14 +20,14 @@ #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ void WebRtcIlbcfix_CbMemEnergyCalc( - int32_t energy, /* (i) input start energy */ - size_t range, /* (i) number of iterations */ - int16_t *ppi, /* (i) input pointer 1 */ - int16_t *ppo, /* (i) input pointer 2 */ - int16_t *energyW16, /* (o) Energy in the CB vectors */ - int16_t *energyShifts, /* (o) Shift value of the energy */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size /* (i) Index to where energy values should be stored */ - ); + int32_t energy, /* (i) input start energy */ + size_t range, /* (i) number of iterations */ + int16_t* ppi, /* (i) input pointer 1 */ + int16_t* ppo, /* (i) input pointer 2 */ + int16_t* energyW16, /* (o) Energy in the CB vectors */ + int16_t* energyShifts, /* (o) Shift value of the energy */ + int scale, /* (i) The scaling of all energy values */ + size_t base_size /* (i) Index to where energy values should be stored */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/cb_search.h b/modules/audio_coding/codecs/ilbc/cb_search.h index c8626c5153..393a2de126 100644 --- a/modules/audio_coding/codecs/ilbc/cb_search.h +++ b/modules/audio_coding/codecs/ilbc/cb_search.h @@ -20,16 +20,16 @@ #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ void WebRtcIlbcfix_CbSearch( - IlbcEncoder *iLBCenc_inst, + IlbcEncoder* iLBCenc_inst, /* (i) the encoder state structure */ - int16_t *index, /* (o) Codebook indices */ - int16_t *gain_index, /* (o) Gain quantization indices */ - int16_t *intarget, /* (i) Target vector for encoding */ - int16_t *decResidual,/* (i) Decoded residual for codebook construction */ - size_t lMem, /* (i) Length of buffer */ - size_t lTarget, /* (i) Length of vector */ - int16_t *weightDenum,/* (i) weighting filter coefficients in Q12 */ - size_t block /* (i) the subblock number */ - ); + int16_t* index, /* (o) Codebook indices */ + int16_t* gain_index, /* (o) Gain quantization indices */ + int16_t* intarget, /* (i) Target vector for encoding */ + int16_t* decResidual, /* (i) Decoded residual for codebook construction */ + size_t lMem, /* (i) Length of buffer */ + size_t lTarget, /* (i) Length of vector */ + int16_t* weightDenum, /* (i) weighting filter coefficients in Q12 */ + size_t block /* (i) the subblock number */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/cb_search_core.h b/modules/audio_coding/codecs/ilbc/cb_search_core.h index 3210668b88..af5a1db5e0 100644 --- a/modules/audio_coding/codecs/ilbc/cb_search_core.h +++ b/modules/audio_coding/codecs/ilbc/cb_search_core.h @@ -22,19 +22,19 @@ #include "modules/audio_coding/codecs/ilbc/defines.h" void WebRtcIlbcfix_CbSearchCore( - int32_t *cDot, /* (i) Cross Correlation */ - size_t range, /* (i) Search range */ - int16_t stage, /* (i) Stage of this search */ - int16_t *inverseEnergy, /* (i) Inversed energy */ - int16_t *inverseEnergyShift, /* (i) Shifts of inversed energy + int32_t* cDot, /* (i) Cross Correlation */ + size_t range, /* (i) Search range */ + int16_t stage, /* (i) Stage of this search */ + int16_t* inverseEnergy, /* (i) Inversed energy */ + int16_t* inverseEnergyShift, /* (i) Shifts of inversed energy with the offset 2*16-29 */ - int32_t *Crit, /* (o) The criteria */ - size_t *bestIndex, /* (o) Index that corresponds to - maximum criteria (in this - vector) */ - int32_t *bestCrit, /* (o) Value of critera for the - chosen index */ - int16_t *bestCritSh); /* (o) The domain of the chosen - criteria */ + int32_t* Crit, /* (o) The criteria */ + size_t* bestIndex, /* (o) Index that corresponds to + maximum criteria (in this + vector) */ + int32_t* bestCrit, /* (o) Value of critera for the + chosen index */ + int16_t* bestCritSh); /* (o) The domain of the chosen + criteria */ #endif diff --git a/modules/audio_coding/codecs/ilbc/cb_update_best_index.h b/modules/audio_coding/codecs/ilbc/cb_update_best_index.h index a4a4cde208..3f57d4845f 100644 --- a/modules/audio_coding/codecs/ilbc/cb_update_best_index.h +++ b/modules/audio_coding/codecs/ilbc/cb_update_best_index.h @@ -22,17 +22,17 @@ #include "modules/audio_coding/codecs/ilbc/defines.h" void WebRtcIlbcfix_CbUpdateBestIndex( - int32_t CritNew, /* (i) New Potentially best Criteria */ - int16_t CritNewSh, /* (i) Shift value of above Criteria */ - size_t IndexNew, /* (i) Index of new Criteria */ - int32_t cDotNew, /* (i) Cross dot of new index */ - int16_t invEnergyNew, /* (i) Inversed energy new index */ - int16_t energyShiftNew, /* (i) Energy shifts of new index */ - int32_t *CritMax, /* (i/o) Maximum Criteria (so far) */ - int16_t *shTotMax, /* (i/o) Shifts of maximum criteria */ - size_t *bestIndex, /* (i/o) Index that corresponds to - maximum criteria */ - int16_t *bestGain); /* (i/o) Gain in Q14 that corresponds - to maximum criteria */ + int32_t CritNew, /* (i) New Potentially best Criteria */ + int16_t CritNewSh, /* (i) Shift value of above Criteria */ + size_t IndexNew, /* (i) Index of new Criteria */ + int32_t cDotNew, /* (i) Cross dot of new index */ + int16_t invEnergyNew, /* (i) Inversed energy new index */ + int16_t energyShiftNew, /* (i) Energy shifts of new index */ + int32_t* CritMax, /* (i/o) Maximum Criteria (so far) */ + int16_t* shTotMax, /* (i/o) Shifts of maximum criteria */ + size_t* bestIndex, /* (i/o) Index that corresponds to + maximum criteria */ + int16_t* bestGain); /* (i/o) Gain in Q14 that corresponds + to maximum criteria */ #endif diff --git a/modules/audio_coding/codecs/ilbc/chebyshev.h b/modules/audio_coding/codecs/ilbc/chebyshev.h index 46eef6b2a6..64b2f49079 100644 --- a/modules/audio_coding/codecs/ilbc/chebyshev.h +++ b/modules/audio_coding/codecs/ilbc/chebyshev.h @@ -30,8 +30,8 @@ int16_t WebRtcIlbcfix_Chebyshev( /* (o) Result of C(x) */ - int16_t x, /* (i) Value to the Chevyshev polynomial */ - int16_t *f /* (i) The coefficients in the polynomial */ - ); + int16_t x, /* (i) Value to the Chevyshev polynomial */ + int16_t* f /* (i) The coefficients in the polynomial */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/comp_corr.h b/modules/audio_coding/codecs/ilbc/comp_corr.h index f54dca27ec..1e6b296eab 100644 --- a/modules/audio_coding/codecs/ilbc/comp_corr.h +++ b/modules/audio_coding/codecs/ilbc/comp_corr.h @@ -26,14 +26,13 @@ * of last subframe at given lag. *---------------------------------------------------------------*/ -void WebRtcIlbcfix_CompCorr( - int32_t *corr, /* (o) cross correlation */ - int32_t *ener, /* (o) energy */ - int16_t *buffer, /* (i) signal buffer */ - size_t lag, /* (i) pitch lag */ - size_t bLen, /* (i) length of buffer */ - size_t sRange, /* (i) correlation search length */ - int16_t scale /* (i) number of rightshifts to use */ +void WebRtcIlbcfix_CompCorr(int32_t* corr, /* (o) cross correlation */ + int32_t* ener, /* (o) energy */ + int16_t* buffer, /* (i) signal buffer */ + size_t lag, /* (i) pitch lag */ + size_t bLen, /* (i) length of buffer */ + size_t sRange, /* (i) correlation search length */ + int16_t scale /* (i) number of rightshifts to use */ ); #endif diff --git a/modules/audio_coding/codecs/ilbc/constants.h b/modules/audio_coding/codecs/ilbc/constants.h index 6864f16da1..3c32c625ef 100644 --- a/modules/audio_coding/codecs/ilbc/constants.h +++ b/modules/audio_coding/codecs/ilbc/constants.h @@ -79,7 +79,8 @@ extern const int16_t WebRtcIlbcfix_kAlpha[]; /* enhancer definitions */ -extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1]; +extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0] + [ENH_FLO_MULT2_PLUS1]; extern const int16_t WebRtcIlbcfix_kEnhWt[]; extern const size_t WebRtcIlbcfix_kEnhPlocs[]; diff --git a/modules/audio_coding/codecs/ilbc/create_augmented_vec.h b/modules/audio_coding/codecs/ilbc/create_augmented_vec.h index ca8b371f5c..28c940006e 100644 --- a/modules/audio_coding/codecs/ilbc/create_augmented_vec.h +++ b/modules/audio_coding/codecs/ilbc/create_augmented_vec.h @@ -27,8 +27,8 @@ *----------------------------------------------------------------*/ void WebRtcIlbcfix_CreateAugmentedVec( - size_t index, /* (i) Index for the augmented vector to be - created */ + size_t index, /* (i) Index for the augmented vector to be + created */ const int16_t* buffer, /* (i) Pointer to the end of the codebook memory that is used for creation of the augmented codebook */ diff --git a/modules/audio_coding/codecs/ilbc/decode.h b/modules/audio_coding/codecs/ilbc/decode.h index ecc968efc5..c5f35f46ad 100644 --- a/modules/audio_coding/codecs/ilbc/decode.h +++ b/modules/audio_coding/codecs/ilbc/decode.h @@ -31,8 +31,8 @@ int WebRtcIlbcfix_DecodeImpl( const uint16_t* bytes, /* (i) encoded signal bits */ IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state structure */ - int16_t mode /* (i) 0: bad packet, PLC, - 1: normal */ + int16_t mode /* (i) 0: bad packet, PLC, + 1: normal */ ) RTC_WARN_UNUSED_RESULT; #endif diff --git a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h b/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h index 416fc362fb..48d43ec2fa 100644 --- a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h +++ b/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h @@ -26,13 +26,13 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_DecoderInterpolateLsp( - int16_t *syntdenum, /* (o) synthesis filter coefficients */ - int16_t *weightdenum, /* (o) weighting denumerator + int16_t* syntdenum, /* (o) synthesis filter coefficients */ + int16_t* weightdenum, /* (o) weighting denumerator coefficients */ - int16_t *lsfdeq, /* (i) dequantized lsf coefficients */ - int16_t length, /* (i) length of lsf coefficient vector */ - IlbcDecoder *iLBCdec_inst + int16_t* lsfdeq, /* (i) dequantized lsf coefficients */ + int16_t length, /* (i) length of lsf coefficient vector */ + IlbcDecoder* iLBCdec_inst /* (i) the decoder state structure */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/defines.h b/modules/audio_coding/codecs/ilbc/defines.h index 6100801bb0..9a4a1966f9 100644 --- a/modules/audio_coding/codecs/ilbc/defines.h +++ b/modules/audio_coding/codecs/ilbc/defines.h @@ -25,103 +25,109 @@ /* general codec settings */ -#define FS 8000 -#define BLOCKL_20MS 160 -#define BLOCKL_30MS 240 -#define BLOCKL_MAX 240 -#define NSUB_20MS 4 -#define NSUB_30MS 6 -#define NSUB_MAX 6 -#define NASUB_20MS 2 -#define NASUB_30MS 4 -#define NASUB_MAX 4 -#define SUBL 40 -#define STATE_LEN 80 -#define STATE_SHORT_LEN_30MS 58 -#define STATE_SHORT_LEN_20MS 57 +#define FS 8000 +#define BLOCKL_20MS 160 +#define BLOCKL_30MS 240 +#define BLOCKL_MAX 240 +#define NSUB_20MS 4 +#define NSUB_30MS 6 +#define NSUB_MAX 6 +#define NASUB_20MS 2 +#define NASUB_30MS 4 +#define NASUB_MAX 4 +#define SUBL 40 +#define STATE_LEN 80 +#define STATE_SHORT_LEN_30MS 58 +#define STATE_SHORT_LEN_20MS 57 /* LPC settings */ -#define LPC_FILTERORDER 10 -#define LPC_LOOKBACK 60 -#define LPC_N_20MS 1 -#define LPC_N_30MS 2 -#define LPC_N_MAX 2 -#define LPC_ASYMDIFF 20 -#define LSF_NSPLIT 3 -#define LSF_NUMBER_OF_STEPS 4 -#define LPC_HALFORDER 5 +#define LPC_FILTERORDER 10 +#define LPC_LOOKBACK 60 +#define LPC_N_20MS 1 +#define LPC_N_30MS 2 +#define LPC_N_MAX 2 +#define LPC_ASYMDIFF 20 +#define LSF_NSPLIT 3 +#define LSF_NUMBER_OF_STEPS 4 +#define LPC_HALFORDER 5 #define COS_GRID_POINTS 60 /* cb settings */ -#define CB_NSTAGES 3 -#define CB_EXPAND 2 -#define CB_MEML 147 -#define CB_FILTERLEN (2*4) -#define CB_HALFFILTERLEN 4 -#define CB_RESRANGE 34 -#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */ -#define CB_MAXGAIN_FIXQ14 21299 +#define CB_NSTAGES 3 +#define CB_EXPAND 2 +#define CB_MEML 147 +#define CB_FILTERLEN (2 * 4) +#define CB_HALFFILTERLEN 4 +#define CB_RESRANGE 34 +#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */ +#define CB_MAXGAIN_FIXQ14 21299 /* enhancer */ -#define ENH_BLOCKL 80 /* block length */ -#define ENH_BLOCKL_HALF (ENH_BLOCKL/2) -#define ENH_HL 3 /* 2*ENH_HL+1 is number blocks - in said second sequence */ -#define ENH_SLOP 2 /* max difference estimated and - correct pitch period */ -#define ENH_PLOCSL 8 /* pitch-estimates and - pitch-locations buffer length */ -#define ENH_OVERHANG 2 -#define ENH_UPS0 4 /* upsampling rate */ -#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */ -#define ENH_FLO_MULT2_PLUS1 7 -#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0) -#define ENH_CORRDIM (2*ENH_SLOP+1) -#define ENH_NBLOCKS (BLOCKL/ENH_BLOCKL) -#define ENH_NBLOCKS_EXTRA 5 -#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */ -#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL -#define ENH_BUFL_FILTEROVERHEAD 3 -#define ENH_A0 819 /* Q14 */ -#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */ -#define ENH_A0DIV2 26843546 /* Q30 */ +#define ENH_BLOCKL 80 /* block length */ +#define ENH_BLOCKL_HALF (ENH_BLOCKL / 2) +#define ENH_HL \ + 3 /* 2*ENH_HL+1 is number blocks \ + in said second \ + sequence */ +#define ENH_SLOP \ + 2 /* max difference estimated and \ + correct pitch period */ +#define ENH_PLOCSL \ + 8 /* pitch-estimates and \ + pitch-locations buffer \ + length */ +#define ENH_OVERHANG 2 +#define ENH_UPS0 4 /* upsampling rate */ +#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */ +#define ENH_FLO_MULT2_PLUS1 7 +#define ENH_VECTL (ENH_BLOCKL + 2 * ENH_FL0) +#define ENH_CORRDIM (2 * ENH_SLOP + 1) +#define ENH_NBLOCKS (BLOCKL / ENH_BLOCKL) +#define ENH_NBLOCKS_EXTRA 5 +#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */ +#define ENH_BUFL (ENH_NBLOCKS_TOT) * ENH_BLOCKL +#define ENH_BUFL_FILTEROVERHEAD 3 +#define ENH_A0 819 /* Q14 */ +#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */ +#define ENH_A0DIV2 26843546 /* Q30 */ /* PLC */ /* Down sampling */ -#define FILTERORDER_DS_PLUS1 7 -#define DELAY_DS 3 -#define FACTOR_DS 2 +#define FILTERORDER_DS_PLUS1 7 +#define DELAY_DS 3 +#define FACTOR_DS 2 /* bit stream defs */ -#define NO_OF_BYTES_20MS 38 -#define NO_OF_BYTES_30MS 50 -#define NO_OF_WORDS_20MS 19 -#define NO_OF_WORDS_30MS 25 -#define STATE_BITS 3 -#define BYTE_LEN 8 -#define ULP_CLASSES 3 +#define NO_OF_BYTES_20MS 38 +#define NO_OF_BYTES_30MS 50 +#define NO_OF_WORDS_20MS 19 +#define NO_OF_WORDS_30MS 25 +#define STATE_BITS 3 +#define BYTE_LEN 8 +#define ULP_CLASSES 3 /* help parameters */ -#define TWO_PI_FIX 25736 /* Q12 */ +#define TWO_PI_FIX 25736 /* Q12 */ /* Constants for codebook search and creation */ -#define ST_MEM_L_TBL 85 -#define MEM_LF_TBL 147 - +#define ST_MEM_L_TBL 85 +#define MEM_LF_TBL 147 /* Struct for the bits */ typedef struct iLBC_bits_t_ { - int16_t lsf[LSF_NSPLIT*LPC_N_MAX]; - int16_t cb_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB index */ - int16_t gain_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB gain */ + int16_t lsf[LSF_NSPLIT * LPC_N_MAX]; + int16_t cb_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values + contains extra CB index */ + int16_t gain_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values + contains extra CB gain */ size_t idxForMax; int16_t state_first; int16_t idxVec[STATE_SHORT_LEN_30MS]; @@ -131,7 +137,6 @@ typedef struct iLBC_bits_t_ { /* type definition encoder instance */ typedef struct IlbcEncoder_ { - /* flag for frame size mode */ int16_t mode; @@ -172,7 +177,6 @@ typedef struct IlbcEncoder_ { /* type definition decoder instance */ typedef struct IlbcDecoder_ { - /* flag for frame size mode */ int16_t mode; @@ -199,13 +203,13 @@ typedef struct IlbcDecoder_ { int16_t prevScale, prevPLI; size_t prevLag; - int16_t prevLpc[LPC_FILTERORDER+1]; - int16_t prevResidual[NSUB_MAX*SUBL]; + int16_t prevLpc[LPC_FILTERORDER + 1]; + int16_t prevResidual[NSUB_MAX * SUBL]; int16_t seed; /* previous synthesis filter parameters */ - int16_t old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; + int16_t old_syntdenum[(LPC_FILTERORDER + 1) * NSUB_MAX]; /* state of output HP filter */ int16_t hpimemx[2]; @@ -213,7 +217,7 @@ typedef struct IlbcDecoder_ { /* enhancer state information */ int use_enhancer; - int16_t enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD]; + int16_t enh_buf[ENH_BUFL + ENH_BUFL_FILTEROVERHEAD]; size_t enh_period[ENH_NBLOCKS_TOT]; } IlbcDecoder; diff --git a/modules/audio_coding/codecs/ilbc/do_plc.h b/modules/audio_coding/codecs/ilbc/do_plc.h index 37af305640..2fbae1de83 100644 --- a/modules/audio_coding/codecs/ilbc/do_plc.h +++ b/modules/audio_coding/codecs/ilbc/do_plc.h @@ -27,15 +27,15 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_DoThePlc( - int16_t *PLCresidual, /* (o) concealed residual */ - int16_t *PLClpc, /* (o) concealed LP parameters */ - int16_t PLI, /* (i) packet loss indicator - 0 - no PL, 1 = PL */ - int16_t *decresidual, /* (i) decoded residual */ - int16_t *lpc, /* (i) decoded LPC (only used for no PL) */ - size_t inlag, /* (i) pitch lag */ - IlbcDecoder *iLBCdec_inst + int16_t* PLCresidual, /* (o) concealed residual */ + int16_t* PLClpc, /* (o) concealed LP parameters */ + int16_t PLI, /* (i) packet loss indicator + 0 - no PL, 1 = PL */ + int16_t* decresidual, /* (i) decoded residual */ + int16_t* lpc, /* (i) decoded LPC (only used for no PL) */ + size_t inlag, /* (i) pitch lag */ + IlbcDecoder* iLBCdec_inst /* (i/o) decoder instance */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/encode.h b/modules/audio_coding/codecs/ilbc/encode.h index 8a3928c5db..db00e2c46e 100644 --- a/modules/audio_coding/codecs/ilbc/encode.h +++ b/modules/audio_coding/codecs/ilbc/encode.h @@ -26,10 +26,10 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_EncodeImpl( - uint16_t *bytes, /* (o) encoded data bits iLBC */ - const int16_t *block, /* (i) speech vector to encode */ - IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder + uint16_t* bytes, /* (o) encoded data bits iLBC */ + const int16_t* block, /* (i) speech vector to encode */ + IlbcEncoder* iLBCenc_inst /* (i/o) the general encoder state */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/energy_inverse.h b/modules/audio_coding/codecs/ilbc/energy_inverse.h index 0404f7d1fd..359a9e2012 100644 --- a/modules/audio_coding/codecs/ilbc/energy_inverse.h +++ b/modules/audio_coding/codecs/ilbc/energy_inverse.h @@ -24,9 +24,10 @@ /* Inverses the in vector in into Q29 domain */ void WebRtcIlbcfix_EnergyInverse( - int16_t *energy, /* (i/o) Energy and inverse - energy (in Q29) */ - size_t noOfEnergies); /* (i) The length of the energy - vector */ + int16_t* + energy, /* (i/o) Energy and inverse + energy (in Q29) */ + size_t noOfEnergies); /* (i) The length of the energy + vector */ #endif diff --git a/modules/audio_coding/codecs/ilbc/enh_upsample.h b/modules/audio_coding/codecs/ilbc/enh_upsample.h index e9a68f4350..b427eca50a 100644 --- a/modules/audio_coding/codecs/ilbc/enh_upsample.h +++ b/modules/audio_coding/codecs/ilbc/enh_upsample.h @@ -26,8 +26,8 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_EnhUpsample( - int32_t *useq1, /* (o) upsampled output sequence */ - int16_t *seq1 /* (i) unupsampled sequence */ - ); + int32_t* useq1, /* (o) upsampled output sequence */ + int16_t* seq1 /* (i) unupsampled sequence */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/enhancer.h b/modules/audio_coding/codecs/ilbc/enhancer.h index 7e20eb11ca..1a6131b91a 100644 --- a/modules/audio_coding/codecs/ilbc/enhancer.h +++ b/modules/audio_coding/codecs/ilbc/enhancer.h @@ -27,13 +27,13 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_Enhancer( - int16_t *odata, /* (o) smoothed block, dimension blockl */ - int16_t *idata, /* (i) data buffer used for enhancing */ - size_t idatal, /* (i) dimension idata */ + int16_t* odata, /* (o) smoothed block, dimension blockl */ + int16_t* idata, /* (i) data buffer used for enhancing */ + size_t idatal, /* (i) dimension idata */ size_t centerStartPos, /* (i) first sample current block within idata */ - size_t *period, /* (i) pitch period array (pitch bward-in time) */ - const size_t *plocs, /* (i) locations where period array values valid */ - size_t periodl /* (i) dimension of period and plocs */ - ); + size_t* period, /* (i) pitch period array (pitch bward-in time) */ + const size_t* plocs, /* (i) locations where period array values valid */ + size_t periodl /* (i) dimension of period and plocs */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.h b/modules/audio_coding/codecs/ilbc/enhancer_interface.h index e305161e43..de4571514f 100644 --- a/modules/audio_coding/codecs/ilbc/enhancer_interface.h +++ b/modules/audio_coding/codecs/ilbc/enhancer_interface.h @@ -26,9 +26,8 @@ *---------------------------------------------------------------*/ size_t // (o) Estimated lag in end of in[] - WebRtcIlbcfix_EnhancerInterface( - int16_t* out, // (o) enhanced signal - const int16_t* in, // (i) unenhanced signal - IlbcDecoder* iLBCdec_inst); // (i) buffers etc +WebRtcIlbcfix_EnhancerInterface(int16_t* out, // (o) enhanced signal + const int16_t* in, // (i) unenhanced signal + IlbcDecoder* iLBCdec_inst); // (i) buffers etc #endif diff --git a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h b/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h index f57e9c406c..c51ac39a43 100644 --- a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h +++ b/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h @@ -28,11 +28,11 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_FilteredCbVecs( - int16_t *cbvectors, /* (o) Codebook vector for the higher section */ - int16_t *CBmem, /* (i) Codebook memory that is filtered to create a - second CB section */ - size_t lMem, /* (i) Length of codebook memory */ - size_t samples /* (i) Number of samples to filter */ - ); + int16_t* cbvectors, /* (o) Codebook vector for the higher section */ + int16_t* CBmem, /* (i) Codebook memory that is filtered to create a + second CB section */ + size_t lMem, /* (i) Length of codebook memory */ + size_t samples /* (i) Number of samples to filter */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/frame_classify.h b/modules/audio_coding/codecs/ilbc/frame_classify.h index 60b3249505..43c6e57a5d 100644 --- a/modules/audio_coding/codecs/ilbc/frame_classify.h +++ b/modules/audio_coding/codecs/ilbc/frame_classify.h @@ -21,9 +21,9 @@ size_t WebRtcIlbcfix_FrameClassify( /* (o) Index to the max-energy sub frame */ - IlbcEncoder *iLBCenc_inst, + IlbcEncoder* iLBCenc_inst, /* (i/o) the encoder state structure */ - int16_t *residualFIX /* (i) lpc residual signal */ - ); + int16_t* residualFIX /* (i) lpc residual signal */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/gain_dequant.h b/modules/audio_coding/codecs/ilbc/gain_dequant.h index 69893727d3..86cc787070 100644 --- a/modules/audio_coding/codecs/ilbc/gain_dequant.h +++ b/modules/audio_coding/codecs/ilbc/gain_dequant.h @@ -30,7 +30,7 @@ int16_t WebRtcIlbcfix_GainDequant( /* (o) quantized gain value (Q14) */ int16_t index, /* (i) quantization index */ int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */ - int16_t stage /* (i) The stage of the search */ - ); + int16_t stage /* (i) The stage of the search */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/gain_quant.h b/modules/audio_coding/codecs/ilbc/gain_quant.h index bc5a936410..51c0bc9a5c 100644 --- a/modules/audio_coding/codecs/ilbc/gain_quant.h +++ b/modules/audio_coding/codecs/ilbc/gain_quant.h @@ -25,11 +25,12 @@ * quantizer for the gain in the gain-shape coding of residual *---------------------------------------------------------------*/ -int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ - int16_t gain, /* (i) gain value Q14 */ - int16_t maxIn, /* (i) maximum of gain value Q14 */ - int16_t stage, /* (i) The stage of the search */ - int16_t *index /* (o) quantization index */ - ); +int16_t +WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ + int16_t gain, /* (i) gain value Q14 */ + int16_t maxIn, /* (i) maximum of gain value Q14 */ + int16_t stage, /* (i) The stage of the search */ + int16_t* index /* (o) quantization index */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/get_lsp_poly.h b/modules/audio_coding/codecs/ilbc/get_lsp_poly.h index 1351b8b3f1..d469409af9 100644 --- a/modules/audio_coding/codecs/ilbc/get_lsp_poly.h +++ b/modules/audio_coding/codecs/ilbc/get_lsp_poly.h @@ -40,8 +40,7 @@ * } *---------------------------------------------------------------*/ -void WebRtcIlbcfix_GetLspPoly( - int16_t *lsp, /* (i) LSP in Q15 */ - int32_t *f); /* (o) polonymial in Q24 */ +void WebRtcIlbcfix_GetLspPoly(int16_t* lsp, /* (i) LSP in Q15 */ + int32_t* f); /* (o) polonymial in Q24 */ #endif diff --git a/modules/audio_coding/codecs/ilbc/get_sync_seq.h b/modules/audio_coding/codecs/ilbc/get_sync_seq.h index 5c729565f6..2281b06726 100644 --- a/modules/audio_coding/codecs/ilbc/get_sync_seq.h +++ b/modules/audio_coding/codecs/ilbc/get_sync_seq.h @@ -26,15 +26,15 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_GetSyncSeq( - int16_t *idata, /* (i) original data */ - size_t idatal, /* (i) dimension of data */ + int16_t* idata, /* (i) original data */ + size_t idatal, /* (i) dimension of data */ size_t centerStartPos, /* (i) where current block starts */ - size_t *period, /* (i) rough-pitch-period array (Q-2) */ - const size_t *plocs, /* (i) where periods of period array are taken (Q-2) */ - size_t periodl, /* (i) dimension period array */ - size_t hl, /* (i) 2*hl+1 is the number of sequences */ - int16_t *surround /* (i/o) The contribution from this sequence - summed with earlier contributions */ - ); + size_t* period, /* (i) rough-pitch-period array (Q-2) */ + const size_t* plocs, /* (i) where periods of period array are taken (Q-2) */ + size_t periodl, /* (i) dimension period array */ + size_t hl, /* (i) 2*hl+1 is the number of sequences */ + int16_t* surround /* (i/o) The contribution from this sequence + summed with earlier contributions */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/hp_input.h b/modules/audio_coding/codecs/ilbc/hp_input.h index f354dd9e2f..ac0d26b6db 100644 --- a/modules/audio_coding/codecs/ilbc/hp_input.h +++ b/modules/audio_coding/codecs/ilbc/hp_input.h @@ -22,13 +22,13 @@ #include "modules/audio_coding/codecs/ilbc/defines.h" void WebRtcIlbcfix_HpInput( - int16_t *signal, /* (i/o) signal vector */ - int16_t *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */ + int16_t* signal, /* (i/o) signal vector */ + int16_t* ba, /* (i) B- and A-coefficients (2:nd order) + {b[0] b[1] b[2] -a[1] -a[2]} + a[0] is assumed to be 1.0 */ + int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1] + yhi[n-2] ylow[n-2] */ + int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */ size_t len); /* (i) Number of samples to filter */ #endif diff --git a/modules/audio_coding/codecs/ilbc/hp_output.h b/modules/audio_coding/codecs/ilbc/hp_output.h index a060a9dc58..88ecdb5ba1 100644 --- a/modules/audio_coding/codecs/ilbc/hp_output.h +++ b/modules/audio_coding/codecs/ilbc/hp_output.h @@ -22,13 +22,13 @@ #include "modules/audio_coding/codecs/ilbc/defines.h" void WebRtcIlbcfix_HpOutput( - int16_t *signal, /* (i/o) signal vector */ - int16_t *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] + int16_t* signal, /* (i/o) signal vector */ + int16_t* ba, /* (i) B- and A-coefficients (2:nd order) + {b[0] b[1] b[2] -a[1] -a[2]} a[0] + is assumed to be 1.0 */ + int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1] yhi[n-2] ylow[n-2] */ - int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */ - size_t len); /* (i) Number of samples to filter */ + int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */ + size_t len); /* (i) Number of samples to filter */ #endif diff --git a/modules/audio_coding/codecs/ilbc/ilbc.h b/modules/audio_coding/codecs/ilbc/ilbc.h index 7836489082..4c12665db7 100644 --- a/modules/audio_coding/codecs/ilbc/ilbc.h +++ b/modules/audio_coding/codecs/ilbc/ilbc.h @@ -40,216 +40,214 @@ typedef struct iLBC_decinst_t_ IlbcDecoderInstance; */ #define ILBC_SPEECH 1 -#define ILBC_CNG 2 +#define ILBC_CNG 2 #ifdef __cplusplus extern "C" { #endif - /**************************************************************************** - * WebRtcIlbcfix_XxxAssign(...) - * - * These functions assigns the encoder/decoder instance to the specified - * memory location - * - * Input: - * - XXX_xxxinst : Pointer to created instance that should be - * assigned - * - ILBCXXX_inst_Addr : Pointer to the desired memory space - * - size : The size that this structure occupies (in Word16) - * - * Return value : 0 - Ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIlbcfix_XxxAssign(...) + * + * These functions assigns the encoder/decoder instance to the specified + * memory location + * + * Input: + * - XXX_xxxinst : Pointer to created instance that should be + * assigned + * - ILBCXXX_inst_Addr : Pointer to the desired memory space + * - size : The size that this structure occupies (in Word16) + * + * Return value : 0 - Ok + * -1 - Error + */ - int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance **iLBC_encinst, - int16_t *ILBCENC_inst_Addr, - int16_t *size); - int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance **iLBC_decinst, - int16_t *ILBCDEC_inst_Addr, - int16_t *size); +int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst, + int16_t* ILBCENC_inst_Addr, + int16_t* size); +int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance** iLBC_decinst, + int16_t* ILBCDEC_inst_Addr, + int16_t* size); +/**************************************************************************** + * WebRtcIlbcfix_XxxAssign(...) + * + * These functions create a instance to the specified structure + * + * Input: + * - XXX_inst : Pointer to created instance that should be created + * + * Return value : 0 - Ok + * -1 - Error + */ - /**************************************************************************** - * WebRtcIlbcfix_XxxAssign(...) - * - * These functions create a instance to the specified structure - * - * Input: - * - XXX_inst : Pointer to created instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ +int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance** iLBC_encinst); +int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance** iLBC_decinst); - int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance **iLBC_encinst); - int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance **iLBC_decinst); +/**************************************************************************** + * WebRtcIlbcfix_XxxFree(...) + * + * These functions frees the dynamic memory of a specified instance + * + * Input: + * - XXX_inst : Pointer to created instance that should be freed + * + * Return value : 0 - Ok + * -1 - Error + */ - /**************************************************************************** - * WebRtcIlbcfix_XxxFree(...) - * - * These functions frees the dynamic memory of a specified instance - * - * Input: - * - XXX_inst : Pointer to created instance that should be freed - * - * Return value : 0 - Ok - * -1 - Error - */ +int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance* iLBC_encinst); +int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance* iLBC_decinst); - int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance *iLBC_encinst); - int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance *iLBC_decinst); +/**************************************************************************** + * WebRtcIlbcfix_EncoderInit(...) + * + * This function initializes a iLBC instance + * + * Input: + * - iLBCenc_inst : iLBC instance, i.e. the user that should receive + * be initialized + * - frameLen : The frame length of the codec 20/30 (ms) + * + * Return value : 0 - Ok + * -1 - Error + */ +int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst, + int16_t frameLen); - /**************************************************************************** - * WebRtcIlbcfix_EncoderInit(...) - * - * This function initializes a iLBC instance - * - * Input: - * - iLBCenc_inst : iLBC instance, i.e. the user that should receive - * be initialized - * - frameLen : The frame length of the codec 20/30 (ms) - * - * Return value : 0 - Ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIlbcfix_Encode(...) + * + * This function encodes one iLBC frame. Input speech length has be a + * multiple of the frame length. + * + * Input: + * - iLBCenc_inst : iLBC instance, i.e. the user that should encode + * a package + * - speechIn : Input speech vector + * - len : Samples in speechIn (160, 240, 320 or 480) + * + * Output: + * - encoded : The encoded data vector + * + * Return value : >0 - Length (in bytes) of coded data + * -1 - Error + */ - int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance *iLBCenc_inst, - int16_t frameLen); +int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, + const int16_t* speechIn, + size_t len, + uint8_t* encoded); - /**************************************************************************** - * WebRtcIlbcfix_Encode(...) - * - * This function encodes one iLBC frame. Input speech length has be a - * multiple of the frame length. - * - * Input: - * - iLBCenc_inst : iLBC instance, i.e. the user that should encode - * a package - * - speechIn : Input speech vector - * - len : Samples in speechIn (160, 240, 320 or 480) - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ +/**************************************************************************** + * WebRtcIlbcfix_DecoderInit(...) + * + * This function initializes a iLBC instance with either 20 or 30 ms frames + * Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's + * not needed to specify the frame length with a variable. + * + * Input: + * - IlbcDecoderInstance : iLBC decoder instance + * - frameLen : The frame length of the codec 20/30 (ms) + * + * Return value : 0 - Ok + * -1 - Error + */ - int WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst, - const int16_t *speechIn, - size_t len, - uint8_t* encoded); +int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst, + int16_t frameLen); +void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst); +void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst); - /**************************************************************************** - * WebRtcIlbcfix_DecoderInit(...) - * - * This function initializes a iLBC instance with either 20 or 30 ms frames - * Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's - * not needed to specify the frame length with a variable. - * - * Input: - * - IlbcDecoderInstance : iLBC decoder instance - * - frameLen : The frame length of the codec 20/30 (ms) - * - * Return value : 0 - Ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIlbcfix_Decode(...) + * + * This function decodes a packet with iLBC frame(s). Output speech length + * will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet). + * + * Input: + * - iLBCdec_inst : iLBC instance, i.e. the user that should decode + * a packet + * - encoded : Encoded iLBC frame(s) + * - len : Bytes in encoded vector + * + * Output: + * - decoded : The decoded vector + * - speechType : 1 normal, 2 CNG + * + * Return value : >0 - Samples in decoded vector + * -1 - Error + */ - int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance *iLBCdec_inst, - int16_t frameLen); - void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst); - void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst); +int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, + const uint8_t* encoded, + size_t len, + int16_t* decoded, + int16_t* speechType); +int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, + const uint8_t* encoded, + size_t len, + int16_t* decoded, + int16_t* speechType); +int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, + const uint8_t* encoded, + size_t len, + int16_t* decoded, + int16_t* speechType); - /**************************************************************************** - * WebRtcIlbcfix_Decode(...) - * - * This function decodes a packet with iLBC frame(s). Output speech length - * will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet). - * - * Input: - * - iLBCdec_inst : iLBC instance, i.e. the user that should decode - * a packet - * - encoded : Encoded iLBC frame(s) - * - len : Bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - speechType : 1 normal, 2 CNG - * - * Return value : >0 - Samples in decoded vector - * -1 - Error - */ +/**************************************************************************** + * WebRtcIlbcfix_DecodePlc(...) + * + * This function conducts PLC for iLBC frame(s). Output speech length + * will be a multiple of 160 or 240 samples. + * + * Input: + * - iLBCdec_inst : iLBC instance, i.e. the user that should perform + * a PLC + * - noOfLostFrames : Number of PLC frames to produce + * + * Output: + * - decoded : The "decoded" vector + * + * Return value : Samples in decoded PLC vector + */ - int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); - int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, +size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst, int16_t* decoded, - int16_t* speechType); - int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); + size_t noOfLostFrames); - /**************************************************************************** - * WebRtcIlbcfix_DecodePlc(...) - * - * This function conducts PLC for iLBC frame(s). Output speech length - * will be a multiple of 160 or 240 samples. - * - * Input: - * - iLBCdec_inst : iLBC instance, i.e. the user that should perform - * a PLC - * - noOfLostFrames : Number of PLC frames to produce - * - * Output: - * - decoded : The "decoded" vector - * - * Return value : Samples in decoded PLC vector - */ +/**************************************************************************** + * WebRtcIlbcfix_NetEqPlc(...) + * + * This function updates the decoder when a packet loss has occured, but it + * does not produce any PLC data. Function can be used if another PLC method + * is used (i.e NetEq). + * + * Input: + * - iLBCdec_inst : iLBC instance that should be updated + * - noOfLostFrames : Number of lost frames + * + * Output: + * - decoded : The "decoded" vector (nothing in this case) + * + * Return value : Samples in decoded PLC vector + */ - size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance *iLBCdec_inst, - int16_t *decoded, - size_t noOfLostFrames); +size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst, + int16_t* decoded, + size_t noOfLostFrames); - /**************************************************************************** - * WebRtcIlbcfix_NetEqPlc(...) - * - * This function updates the decoder when a packet loss has occured, but it - * does not produce any PLC data. Function can be used if another PLC method - * is used (i.e NetEq). - * - * Input: - * - iLBCdec_inst : iLBC instance that should be updated - * - noOfLostFrames : Number of lost frames - * - * Output: - * - decoded : The "decoded" vector (nothing in this case) - * - * Return value : Samples in decoded PLC vector - */ +/**************************************************************************** + * WebRtcIlbcfix_version(...) + * + * This function returns the version number of iLBC + * + * Output: + * - version : Version number of iLBC (maximum 20 char) + */ - size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance *iLBCdec_inst, - int16_t *decoded, - size_t noOfLostFrames); - - /**************************************************************************** - * WebRtcIlbcfix_version(...) - * - * This function returns the version number of iLBC - * - * Output: - * - version : Version number of iLBC (maximum 20 char) - */ - - void WebRtcIlbcfix_version(char *version); +void WebRtcIlbcfix_version(char* version); #ifdef __cplusplus } diff --git a/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc b/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc index b8d3c7c55a..5ec1219b3b 100644 --- a/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc +++ b/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc @@ -71,7 +71,7 @@ class SplitIlbcTest : public ::testing::TestWithParam > { TEST_P(SplitIlbcTest, NumFrames) { AudioDecoderIlbcImpl decoder; const size_t frame_length_samples = frame_length_ms_ * 8; - const auto generate_payload = [] (size_t payload_length_bytes) { + const auto generate_payload = [](size_t payload_length_bytes) { rtc::Buffer payload(payload_length_bytes); // Fill payload with increasing integers {0, 1, 2, ...}. for (size_t i = 0; i < payload.size(); ++i) { @@ -104,7 +104,8 @@ TEST_P(SplitIlbcTest, NumFrames) { // The maximum is defined by the largest payload length that can be uniquely // resolved to a frame size of either 38 bytes (20 ms) or 50 bytes (30 ms). INSTANTIATE_TEST_CASE_P( - IlbcTest, SplitIlbcTest, + IlbcTest, + SplitIlbcTest, ::testing::Values(std::pair(1, 20), // 1 frame, 20 ms. std::pair(2, 20), // 2 frames, 20 ms. std::pair(3, 20), // And so on. diff --git a/modules/audio_coding/codecs/ilbc/index_conv_dec.h b/modules/audio_coding/codecs/ilbc/index_conv_dec.h index 03a721b439..4f08ce04df 100644 --- a/modules/audio_coding/codecs/ilbc/index_conv_dec.h +++ b/modules/audio_coding/codecs/ilbc/index_conv_dec.h @@ -21,8 +21,7 @@ #include "modules/audio_coding/codecs/ilbc/defines.h" -void WebRtcIlbcfix_IndexConvDec( - int16_t *index /* (i/o) Codebook indexes */ +void WebRtcIlbcfix_IndexConvDec(int16_t* index /* (i/o) Codebook indexes */ ); #endif diff --git a/modules/audio_coding/codecs/ilbc/index_conv_enc.h b/modules/audio_coding/codecs/ilbc/index_conv_enc.h index 9938448e86..f89949949c 100644 --- a/modules/audio_coding/codecs/ilbc/index_conv_enc.h +++ b/modules/audio_coding/codecs/ilbc/index_conv_enc.h @@ -25,8 +25,7 @@ * Convert the codebook indexes to make the search easier *---------------------------------------------------------------*/ -void WebRtcIlbcfix_IndexConvEnc( - int16_t *index /* (i/o) Codebook indexes */ +void WebRtcIlbcfix_IndexConvEnc(int16_t* index /* (i/o) Codebook indexes */ ); #endif diff --git a/modules/audio_coding/codecs/ilbc/init_decode.h b/modules/audio_coding/codecs/ilbc/init_decode.h index 49bd61c3ff..fdcf9f0b1a 100644 --- a/modules/audio_coding/codecs/ilbc/init_decode.h +++ b/modules/audio_coding/codecs/ilbc/init_decode.h @@ -25,11 +25,12 @@ * Initiation of decoder instance. *---------------------------------------------------------------*/ -int WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */ - IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */ - int16_t mode, /* (i) frame size mode */ - int use_enhancer /* (i) 1 to use enhancer - 0 to run without enhancer */ - ); +int WebRtcIlbcfix_InitDecode(/* (o) Number of decoded samples */ + IlbcDecoder* + iLBCdec_inst, /* (i/o) Decoder instance */ + int16_t mode, /* (i) frame size mode */ + int use_enhancer /* (i) 1 to use enhancer + 0 to run without enhancer */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/init_encode.h b/modules/audio_coding/codecs/ilbc/init_encode.h index d9b2971ad9..f91a9b0add 100644 --- a/modules/audio_coding/codecs/ilbc/init_encode.h +++ b/modules/audio_coding/codecs/ilbc/init_encode.h @@ -25,9 +25,10 @@ * Initiation of encoder instance. *---------------------------------------------------------------*/ -int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */ - IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */ - int16_t mode /* (i) frame size mode */ - ); +int WebRtcIlbcfix_InitEncode(/* (o) Number of bytes encoded */ + IlbcEncoder* + iLBCenc_inst, /* (i/o) Encoder instance */ + int16_t mode /* (i) frame size mode */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/interpolate.h b/modules/audio_coding/codecs/ilbc/interpolate.h index fc360b4ea2..9f0323649b 100644 --- a/modules/audio_coding/codecs/ilbc/interpolate.h +++ b/modules/audio_coding/codecs/ilbc/interpolate.h @@ -26,10 +26,10 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_Interpolate( - int16_t *out, /* (o) output vector */ - int16_t *in1, /* (i) first input vector */ - int16_t *in2, /* (i) second input vector */ - int16_t coef, /* (i) weight coefficient in Q14 */ + int16_t* out, /* (o) output vector */ + int16_t* in1, /* (i) first input vector */ + int16_t* in2, /* (i) second input vector */ + int16_t coef, /* (i) weight coefficient in Q14 */ int16_t length); /* (i) number of sample is vectors */ #endif diff --git a/modules/audio_coding/codecs/ilbc/interpolate_samples.h b/modules/audio_coding/codecs/ilbc/interpolate_samples.h index f522f937f0..264a101aa4 100644 --- a/modules/audio_coding/codecs/ilbc/interpolate_samples.h +++ b/modules/audio_coding/codecs/ilbc/interpolate_samples.h @@ -26,9 +26,9 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_InterpolateSamples( - int16_t *interpSamples, /* (o) The interpolated samples */ - int16_t *CBmem, /* (i) The CB memory */ - size_t lMem /* (i) Length of the CB memory */ - ); + int16_t* interpSamples, /* (o) The interpolated samples */ + int16_t* CBmem, /* (i) The CB memory */ + size_t lMem /* (i) Length of the CB memory */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/lpc_encode.h b/modules/audio_coding/codecs/ilbc/lpc_encode.h index 7255705310..256fa492bb 100644 --- a/modules/audio_coding/codecs/ilbc/lpc_encode.h +++ b/modules/audio_coding/codecs/ilbc/lpc_encode.h @@ -26,14 +26,14 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_LpcEncode( - int16_t *syntdenum, /* (i/o) synthesis filter coefficients - before/after encoding */ - int16_t *weightdenum, /* (i/o) weighting denumerator coefficients + int16_t* syntdenum, /* (i/o) synthesis filter coefficients before/after encoding */ - int16_t *lsf_index, /* (o) lsf quantization index */ - int16_t *data, /* (i) Speech to do LPC analysis on */ - IlbcEncoder *iLBCenc_inst + int16_t* weightdenum, /* (i/o) weighting denumerator coefficients + before/after encoding */ + int16_t* lsf_index, /* (o) lsf quantization index */ + int16_t* data, /* (i) Speech to do LPC analysis on */ + IlbcEncoder* iLBCenc_inst /* (i/o) the encoder state structure */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_check.h b/modules/audio_coding/codecs/ilbc/lsf_check.h index f92e0cc8db..d367c1d09f 100644 --- a/modules/audio_coding/codecs/ilbc/lsf_check.h +++ b/modules/audio_coding/codecs/ilbc/lsf_check.h @@ -25,9 +25,8 @@ * check for stability of lsf coefficients *---------------------------------------------------------------*/ -int WebRtcIlbcfix_LsfCheck( - int16_t *lsf, /* LSF parameters */ - int dim, /* dimension of LSF */ - int NoAn); /* No of analysis per frame */ +int WebRtcIlbcfix_LsfCheck(int16_t* lsf, /* LSF parameters */ + int dim, /* dimension of LSF */ + int NoAn); /* No of analysis per frame */ #endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h index 4a6c0d5aee..016897a144 100644 --- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h +++ b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h @@ -26,12 +26,12 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_LspInterpolate2PolyDec( - int16_t *a, /* (o) lpc coefficients Q12 */ - int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */ - int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */ + int16_t* a, /* (o) lpc coefficients Q12 */ + int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */ + int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */ int16_t coef, /* (i) weighting coefficient to use between lsf1 and lsf2 Q14 */ - int16_t length /* (i) length of coefficient vectors */ - ); + int16_t length /* (i) length of coefficient vectors */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h index 74863c657f..9cb0dd9f42 100644 --- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h +++ b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h @@ -27,12 +27,12 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_LsfInterpolate2PloyEnc( - int16_t *a, /* (o) lpc coefficients Q12 */ - int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */ - int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */ - int16_t coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ + int16_t* a, /* (o) lpc coefficients Q12 */ + int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */ + int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */ + int16_t coef, /* (i) weighting coefficient to use between + lsf1 and lsf2 Q14 */ int16_t length /* (i) length of coefficient vectors */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h index 80c07988b2..921101ac9e 100644 --- a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h +++ b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h @@ -26,9 +26,9 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_Lsf2Lsp( - int16_t *lsf, /* (i) lsf in Q13 values between 0 and pi */ - int16_t *lsp, /* (o) lsp in Q15 values between -1 and 1 */ + int16_t* lsf, /* (i) lsf in Q13 values between 0 and pi */ + int16_t* lsp, /* (o) lsp in Q15 values between -1 and 1 */ int16_t m /* (i) number of coefficients */ - ); + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_poly.h b/modules/audio_coding/codecs/ilbc/lsf_to_poly.h index 68c4dd06dc..e551836f52 100644 --- a/modules/audio_coding/codecs/ilbc/lsf_to_poly.h +++ b/modules/audio_coding/codecs/ilbc/lsf_to_poly.h @@ -26,8 +26,8 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_Lsf2Poly( - int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */ - int16_t *lsf /* (i) line spectral frequencies in Q13 */ - ); + int16_t* a, /* (o) predictor coefficients (order = 10) in Q12 */ + int16_t* lsf /* (i) line spectral frequencies in Q13 */ + ); #endif diff --git a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h b/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h index 666a99a3bc..358786e752 100644 --- a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h +++ b/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h @@ -26,10 +26,10 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_Lsp2Lsf( - int16_t *lsp, /* (i) lsp vector -1...+1 in Q15 */ - int16_t *lsf, /* (o) Lsf vector 0...Pi in Q13 + int16_t* lsp, /* (i) lsp vector -1...+1 in Q15 */ + int16_t* lsf, /* (o) Lsf vector 0...Pi in Q13 (ordered, so that lsf[i]::NumChannels() const { template size_t AudioEncoderIsacT::Num10MsFramesInNextPacket() const { const int samples_in_next_packet = T::GetNewFrameLen(isac_state_); - return static_cast( - rtc::CheckedDivExact(samples_in_next_packet, - rtc::CheckedDivExact(SampleRateHz(), 100))); + return static_cast(rtc::CheckedDivExact( + samples_in_next_packet, rtc::CheckedDivExact(SampleRateHz(), 100))); } template @@ -123,8 +122,7 @@ AudioEncoder::EncodedInfo AudioEncoderIsacT::EncodeImpl( } size_t encoded_bytes = encoded->AppendData( - kSufficientEncodeBufferSizeBytes, - [&] (rtc::ArrayView encoded) { + kSufficientEncodeBufferSizeBytes, [&](rtc::ArrayView encoded) { int r = T::Encode(isac_state_, audio.data(), encoded.data()); RTC_CHECK_GE(r, 0) << "Encode failed (error code " diff --git a/modules/audio_coding/codecs/isac/fix/include/isacfix.h b/modules/audio_coding/codecs/isac/fix/include/isacfix.h index ef194ca528..626b3c76c3 100644 --- a/modules/audio_coding/codecs/isac/fix/include/isacfix.h +++ b/modules/audio_coding/codecs/isac/fix/include/isacfix.h @@ -16,622 +16,591 @@ #include "modules/audio_coding/codecs/isac/bandwidth_info.h" #include "typedefs.h" // NOLINT(build/include) -typedef struct { - void *dummy; -} ISACFIX_MainStruct; - +typedef struct { void* dummy; } ISACFIX_MainStruct; #if defined(__cplusplus) extern "C" { #endif +/************************************************************************** + * WebRtcIsacfix_AssignSize(...) + * + * Functions used when malloc is not allowed + * Output the number of bytes needed to allocate for iSAC struct. + * + */ - /************************************************************************** - * WebRtcIsacfix_AssignSize(...) - * - * Functions used when malloc is not allowed - * Output the number of bytes needed to allocate for iSAC struct. - * - */ +int16_t WebRtcIsacfix_AssignSize(int* sizeinbytes); - int16_t WebRtcIsacfix_AssignSize(int *sizeinbytes); +/************************************************************************** + * WebRtcIsacfix_Assign(...) + * + * Functions used when malloc is not allowed, it + * places a struct at the given address. + * + * Input: + * - *ISAC_main_inst : a pointer to the coder instance. + * - ISACFIX_inst_Addr : address of the memory where a space is + * for iSAC structure. + * + * Return value : 0 - Ok + * -1 - Error + */ - /************************************************************************** - * WebRtcIsacfix_Assign(...) - * - * Functions used when malloc is not allowed, it - * places a struct at the given address. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - ISACFIX_inst_Addr : address of the memory where a space is - * for iSAC structure. - * - * Return value : 0 - Ok - * -1 - Error - */ +int16_t WebRtcIsacfix_Assign(ISACFIX_MainStruct** inst, + void* ISACFIX_inst_Addr); - int16_t WebRtcIsacfix_Assign(ISACFIX_MainStruct **inst, - void *ISACFIX_inst_Addr); +/**************************************************************************** + * WebRtcIsacfix_Create(...) + * + * This function creates an ISAC instance, which will contain the state + * information for one coding/decoding channel. + * + * Input: + * - *ISAC_main_inst : a pointer to the coder instance. + * + * Return value : 0 - Ok + * -1 - Error + */ - /**************************************************************************** - * WebRtcIsacfix_Create(...) - * - * This function creates an ISAC instance, which will contain the state - * information for one coding/decoding channel. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ +int16_t WebRtcIsacfix_Create(ISACFIX_MainStruct** ISAC_main_inst); - int16_t WebRtcIsacfix_Create(ISACFIX_MainStruct **ISAC_main_inst); +/**************************************************************************** + * WebRtcIsacfix_Free(...) + * + * This function frees the ISAC instance created at the beginning. + * + * Input: + * - ISAC_main_inst : a ISAC instance. + * + * Return value : 0 - Ok + * -1 - Error + */ +int16_t WebRtcIsacfix_Free(ISACFIX_MainStruct* ISAC_main_inst); - /**************************************************************************** - * WebRtcIsacfix_Free(...) - * - * This function frees the ISAC instance created at the beginning. - * - * Input: - * - ISAC_main_inst : a ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIsacfix_EncoderInit(...) + * + * This function initializes an ISAC instance prior to the encoder calls. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - CodingMode : 0 - Bit rate and frame length are automatically + * adjusted to available bandwidth on + * transmission channel. + * 1 - User sets a frame length and a target bit + * rate which is taken as the maximum short-term + * average bit rate. + * + * Return value : 0 - Ok + * -1 - Error + */ - int16_t WebRtcIsacfix_Free(ISACFIX_MainStruct *ISAC_main_inst); +int16_t WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct* ISAC_main_inst, + int16_t CodingMode); +/**************************************************************************** + * WebRtcIsacfix_Encode(...) + * + * This function encodes 10ms frame(s) and inserts it into a package. + * Input speech length has to be 160 samples (10ms). The encoder buffers those + * 10ms frames until it reaches the chosen Framesize (480 or 960 samples + * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - speechIn : input speech vector. + * + * Output: + * - encoded : the encoded data vector + * + * Return value : >0 - Length (in bytes) of coded data + * 0 - The buffer didn't reach the chosen framesize + * so it keeps buffering speech samples. + * -1 - Error + */ - /**************************************************************************** - * WebRtcIsacfix_EncoderInit(...) - * - * This function initializes an ISAC instance prior to the encoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - CodingMode : 0 - Bit rate and frame length are automatically - * adjusted to available bandwidth on - * transmission channel. - * 1 - User sets a frame length and a target bit - * rate which is taken as the maximum short-term - * average bit rate. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct *ISAC_main_inst, - int16_t CodingMode); - - - /**************************************************************************** - * WebRtcIsacfix_Encode(...) - * - * This function encodes 10ms frame(s) and inserts it into a package. - * Input speech length has to be 160 samples (10ms). The encoder buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * -1 - Error - */ - - int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, - const int16_t *speechIn, - uint8_t* encoded); - - - - /**************************************************************************** - * WebRtcIsacfix_EncodeNb(...) - * - * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts - * it into a package. Input speech length has to be 80 samples (10ms). The encoder - * interpolates into wide-band (16 kHz sampling) buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 wide-band samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * -1 - Error - */ +int WebRtcIsacfix_Encode(ISACFIX_MainStruct* ISAC_main_inst, + const int16_t* speechIn, + uint8_t* encoded); +/**************************************************************************** + * WebRtcIsacfix_EncodeNb(...) + * + * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts + * it into a package. Input speech length has to be 80 samples (10ms). The + * encoder interpolates into wide-band (16 kHz sampling) buffers those 10ms + * frames until it reaches the chosen Framesize (480 or 960 wide-band samples + * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. + * + * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - speechIn : input speech vector. + * + * Output: + * - encoded : the encoded data vector + * + * Return value : >0 - Length (in bytes) of coded data + * 0 - The buffer didn't reach the chosen framesize + * so it keeps buffering speech samples. + * -1 - Error + */ #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const int16_t *speechIn, - int16_t *encoded); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED +int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct* ISAC_main_inst, + const int16_t* speechIn, + int16_t* encoded); +#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED +/**************************************************************************** + * WebRtcIsacfix_DecoderInit(...) + * + * This function initializes an ISAC instance prior to the decoder calls. + * + * Input: + * - ISAC_main_inst : ISAC instance. + */ +void WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct* ISAC_main_inst); - /**************************************************************************** - * WebRtcIsacfix_DecoderInit(...) - * - * This function initializes an ISAC instance prior to the decoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - */ +/**************************************************************************** + * WebRtcIsacfix_UpdateBwEstimate1(...) + * + * This function updates the estimate of the bandwidth. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC frame(s). + * - packet_size : size of the packet in bytes. + * - rtp_seq_number : the RTP number of the packet. + * - arr_ts : the arrival time of the packet (from NetEq) + * in samples. + * + * Return value : 0 - Ok + * -1 - Error + */ - void WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct* ISAC_main_inst); +int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct* ISAC_main_inst, + const uint8_t* encoded, + size_t packet_size, + uint16_t rtp_seq_number, + uint32_t arr_ts); - /**************************************************************************** - * WebRtcIsacfix_UpdateBwEstimate1(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet in bytes. - * - rtp_seq_number : the RTP number of the packet. - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIsacfix_UpdateBwEstimate(...) + * + * This function updates the estimate of the bandwidth. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC frame(s). + * - packet_size : size of the packet in bytes. + * - rtp_seq_number : the RTP number of the packet. + * - send_ts : the send time of the packet from RTP header, + * in samples. + * - arr_ts : the arrival time of the packet (from NetEq) + * in samples. + * + * Return value : 0 - Ok + * -1 - Error + */ - int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, - const uint8_t* encoded, - size_t packet_size, - uint16_t rtp_seq_number, - uint32_t arr_ts); +int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct* ISAC_main_inst, + const uint8_t* encoded, + size_t packet_size, + uint16_t rtp_seq_number, + uint32_t send_ts, + uint32_t arr_ts); - /**************************************************************************** - * WebRtcIsacfix_UpdateBwEstimate(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet in bytes. - * - rtp_seq_number : the RTP number of the packet. - * - send_ts : the send time of the packet from RTP header, - * in samples. - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIsacfix_Decode(...) + * + * This function decodes an ISAC frame. Output speech length + * will be a multiple of 480 samples: 480 or 960 samples, + * depending on the framesize (30 or 60 ms). + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC frame(s) + * - len : bytes in encoded vector + * + * Output: + * - decoded : The decoded vector + * + * Return value : >0 - number of samples in decoded vector + * -1 - Error + */ - int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, - const uint8_t* encoded, - size_t packet_size, - uint16_t rtp_seq_number, - uint32_t send_ts, - uint32_t arr_ts); +int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, + const uint8_t* encoded, + size_t len, + int16_t* decoded, + int16_t* speechType); - /**************************************************************************** - * WebRtcIsacfix_Decode(...) - * - * This function decodes an ISAC frame. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the framesize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ +/**************************************************************************** + * WebRtcIsacfix_DecodeNb(...) + * + * This function decodes a ISAC frame in narrow-band (8 kHz sampling). + * Output speech length will be a multiple of 240 samples: 240 or 480 samples, + * depending on the framesize (30 or 60 ms). + * + * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC frame(s) + * - len : bytes in encoded vector + * + * Output: + * - decoded : The decoded vector + * + * Return value : >0 - number of samples in decoded vector + * -1 - Error + */ - int WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst, - const uint8_t* encoded, +#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED +int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst, + const uint16_t* encoded, size_t len, - int16_t *decoded, - int16_t *speechType); + int16_t* decoded, + int16_t* speechType); +#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - - /**************************************************************************** - * WebRtcIsacfix_DecodeNb(...) - * - * This function decodes a ISAC frame in narrow-band (8 kHz sampling). - * Output speech length will be a multiple of 240 samples: 240 or 480 samples, - * depending on the framesize (30 or 60 ms). - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ +/**************************************************************************** + * WebRtcIsacfix_DecodePlcNb(...) + * + * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). + * Output speech length will be "240*noOfLostFrames" samples + * that equevalent of "30*noOfLostFrames" millisecond. + * + * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce + * NOTE! Maximum number is 2 (480 samples = 60ms) + * + * Output: + * - decoded : The decoded vector + * + * Return value : Number of samples in decoded PLC vector + */ #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const uint16_t *encoded, - size_t len, - int16_t *decoded, - int16_t *speechType); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED +size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst, + int16_t* decoded, + size_t noOfLostFrames); +#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED +/**************************************************************************** + * WebRtcIsacfix_DecodePlc(...) + * + * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling). + * Output speech length will be "480*noOfLostFrames" samples + * that is equevalent of "30*noOfLostFrames" millisecond. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - noOfLostFrames : Number of PLC frames (480sample = 30ms) + * to produce + * NOTE! Maximum number is 2 (960 samples = 60ms) + * + * Output: + * - decoded : The decoded vector + * + * Return value : Number of samples in decoded PLC vector + */ - /**************************************************************************** - * WebRtcIsacfix_DecodePlcNb(...) - * - * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). - * Output speech length will be "240*noOfLostFrames" samples - * that equevalent of "30*noOfLostFrames" millisecond. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce - * NOTE! Maximum number is 2 (480 samples = 60ms) - * - * Output: - * - decoded : The decoded vector - * - * Return value : Number of samples in decoded PLC vector - */ +size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct* ISAC_main_inst, + int16_t* decoded, + size_t noOfLostFrames); -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, - int16_t *decoded, - size_t noOfLostFrames); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED +/**************************************************************************** + * WebRtcIsacfix_ReadFrameLen(...) + * + * This function returns the length of the frame represented in the packet. + * + * Input: + * - encoded : Encoded bitstream + * - encoded_len_bytes : Length of the bitstream in bytes. + * + * Output: + * - frameLength : Length of frame in packet (in samples) + * + */ +int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded, + size_t encoded_len_bytes, + size_t* frameLength); +/**************************************************************************** + * WebRtcIsacfix_Control(...) + * + * This function sets the limit on the short-term average bit rate and the + * frame length. Should be used only in Instantaneous mode. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - rate : limit on the short-term average bit rate, + * in bits/second (between 10000 and 32000) + * - framesize : number of milliseconds per frame (30 or 60) + * + * Return value : 0 - ok + * -1 - Error + */ +int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct* ISAC_main_inst, + int16_t rate, + int framesize); - /**************************************************************************** - * WebRtcIsacfix_DecodePlc(...) - * - * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling). - * Output speech length will be "480*noOfLostFrames" samples - * that is equevalent of "30*noOfLostFrames" millisecond. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (480sample = 30ms) - * to produce - * NOTE! Maximum number is 2 (960 samples = 60ms) - * - * Output: - * - decoded : The decoded vector - * - * Return value : Number of samples in decoded PLC vector - */ +void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst, + int bottleneck_bits_per_second); - size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, - int16_t *decoded, - size_t noOfLostFrames ); +/**************************************************************************** + * WebRtcIsacfix_ControlBwe(...) + * + * This function sets the initial values of bottleneck and frame-size if + * iSAC is used in channel-adaptive mode. Through this API, users can + * enforce a frame-size for all values of bottleneck. Then iSAC will not + * automatically change the frame-size. + * + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - rateBPS : initial value of bottleneck in bits/second + * 10000 <= rateBPS <= 32000 is accepted + * - frameSizeMs : number of milliseconds per frame (30 or 60) + * - enforceFrameSize : 1 to enforce the given frame-size through out + * the adaptation process, 0 to let iSAC change + * the frame-size if required. + * + * Return value : 0 - ok + * -1 - Error + */ +int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct* ISAC_main_inst, + int16_t rateBPS, + int frameSizeMs, + int16_t enforceFrameSize); - /**************************************************************************** - * WebRtcIsacfix_ReadFrameLen(...) - * - * This function returns the length of the frame represented in the packet. - * - * Input: - * - encoded : Encoded bitstream - * - encoded_len_bytes : Length of the bitstream in bytes. - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - */ +/**************************************************************************** + * WebRtcIsacfix_version(...) + * + * This function returns the version number. + * + * Output: + * - version : Pointer to character string + * + */ - int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded, - size_t encoded_len_bytes, - size_t* frameLength); +void WebRtcIsacfix_version(char* version); - /**************************************************************************** - * WebRtcIsacfix_Control(...) - * - * This function sets the limit on the short-term average bit rate and the - * frame length. Should be used only in Instantaneous mode. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rate : limit on the short-term average bit rate, - * in bits/second (between 10000 and 32000) - * - framesize : number of milliseconds per frame (30 or 60) - * - * Return value : 0 - ok - * -1 - Error - */ +/**************************************************************************** + * WebRtcIsacfix_GetErrorCode(...) + * + * This function can be used to check the error code of an iSAC instance. When + * a function returns -1 a error code will be set for that instance. The + * function below extract the code of the last error that occured in the + * specified instance. + * + * Input: + * - ISAC_main_inst : ISAC instance + * + * Return value : Error code + */ - int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, - int16_t rate, - int framesize); +int16_t WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct* ISAC_main_inst); - void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst, - int bottleneck_bits_per_second); +/**************************************************************************** + * WebRtcIsacfix_GetUplinkBw(...) + * + * This function return iSAC send bitrate + * + * Input: + * - ISAC_main_inst : iSAC instance + * + * Return value : <0 Error code + * else bitrate + */ - /**************************************************************************** - * WebRtcIsacfix_ControlBwe(...) - * - * This function sets the initial values of bottleneck and frame-size if - * iSAC is used in channel-adaptive mode. Through this API, users can - * enforce a frame-size for all values of bottleneck. Then iSAC will not - * automatically change the frame-size. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rateBPS : initial value of bottleneck in bits/second - * 10000 <= rateBPS <= 32000 is accepted - * - frameSizeMs : number of milliseconds per frame (30 or 60) - * - enforceFrameSize : 1 to enforce the given frame-size through out - * the adaptation process, 0 to let iSAC change - * the frame-size if required. - * - * Return value : 0 - ok - * -1 - Error - */ +int32_t WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct* ISAC_main_inst); - int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, - int16_t rateBPS, - int frameSizeMs, - int16_t enforceFrameSize); +/**************************************************************************** + * WebRtcIsacfix_SetMaxPayloadSize(...) + * + * This function sets a limit for the maximum payload size of iSAC. The same + * value is used both for 30 and 60 msec packets. + * The absolute max will be valid until next time the function is called. + * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate() + * + * Input: + * - ISAC_main_inst : iSAC instance + * - maxPayloadBytes : maximum size of the payload in bytes + * valid values are between 100 and 400 bytes + * + * + * Return value : 0 if sucessful + * -1 if error happens + */ +int16_t WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct* ISAC_main_inst, + int16_t maxPayloadBytes); +/**************************************************************************** + * WebRtcIsacfix_SetMaxRate(...) + * + * This function sets the maximum rate which the codec may not exceed for a + * singel packet. The maximum rate is set in bits per second. + * The codec has an absolute maximum rate of 53400 bits per second (200 bytes + * per 30 msec). + * It is possible to set a maximum rate between 32000 and 53400 bits per second. + * + * The rate limit is valid until next time the function is called. + * + * NOTE! Packet size will never go above the value set if calling + * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes). + * + * Input: + * - ISAC_main_inst : iSAC instance + * - maxRateInBytes : maximum rate in bits per second, + * valid values are 32000 to 53400 bits + * + * Return value : 0 if sucessful + * -1 if error happens + */ - /**************************************************************************** - * WebRtcIsacfix_version(...) - * - * This function returns the version number. - * - * Output: - * - version : Pointer to character string - * - */ +int16_t WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct* ISAC_main_inst, + int32_t maxRate); - void WebRtcIsacfix_version(char *version); +/**************************************************************************** + * WebRtcIsacfix_CreateInternal(...) + * + * This function creates the memory that is used to store data in the encoder + * + * Input: + * - *ISAC_main_inst : a pointer to the coder instance. + * + * Return value : 0 - Ok + * -1 - Error + */ +int16_t WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct* ISAC_main_inst); - /**************************************************************************** - * WebRtcIsacfix_GetErrorCode(...) - * - * This function can be used to check the error code of an iSAC instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occured in the - * specified instance. - * - * Input: - * - ISAC_main_inst : ISAC instance - * - * Return value : Error code - */ +/**************************************************************************** + * WebRtcIsacfix_FreeInternal(...) + * + * This function frees the internal memory for storing encoder data. + * + * Input: + * - ISAC_main_inst : an ISAC instance. + * + * Return value : 0 - Ok + * -1 - Error + */ - int16_t WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct *ISAC_main_inst); +int16_t WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct* ISAC_main_inst); +/**************************************************************************** + * WebRtcIsacfix_GetNewBitStream(...) + * + * This function returns encoded data, with the recieved bwe-index in the + * stream. It should always return a complete packet, i.e. only called once + * even for 60 msec frames + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - bweIndex : index of bandwidth estimate to put in new + * bitstream - scale : factor for rate change (0.4 ~=> half the + * rate, 1 no change). + * + * Output: + * - encoded : the encoded data vector + * + * Return value : >0 - Length (in bytes) of coded data + * -1 - Error + */ - /**************************************************************************** - * WebRtcIsacfix_GetUplinkBw(...) - * - * This function return iSAC send bitrate - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : <0 Error code - * else bitrate - */ +int16_t WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct* ISAC_main_inst, + int16_t bweIndex, + float scale, + uint8_t* encoded); - int32_t WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct *ISAC_main_inst); +/**************************************************************************** + * WebRtcIsacfix_GetDownLinkBwIndex(...) + * + * This function returns index representing the Bandwidth estimate from + * other side to this side. + * + * Input: + * - ISAC_main_inst : iSAC struct + * + * Output: + * - rateIndex : Bandwidth estimate to transmit to other side. + * + */ +int16_t WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst, + int16_t* rateIndex); - /**************************************************************************** - * WebRtcIsacfix_SetMaxPayloadSize(...) - * - * This function sets a limit for the maximum payload size of iSAC. The same - * value is used both for 30 and 60 msec packets. - * The absolute max will be valid until next time the function is called. - * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate() - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxPayloadBytes : maximum size of the payload in bytes - * valid values are between 100 and 400 bytes - * - * - * Return value : 0 if sucessful - * -1 if error happens - */ +/**************************************************************************** + * WebRtcIsacfix_UpdateUplinkBw(...) + * + * This function takes an index representing the Bandwidth estimate from + * this side to other side and updates BWE. + * + * Input: + * - ISAC_main_inst : iSAC struct + * - rateIndex : Bandwidth estimate from other side. + * + */ - int16_t WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct *ISAC_main_inst, - int16_t maxPayloadBytes); +int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst, + int16_t rateIndex); +/**************************************************************************** + * WebRtcIsacfix_ReadBwIndex(...) + * + * This function returns the index of the Bandwidth estimate from the bitstream. + * + * Input: + * - encoded : Encoded bitstream + * - encoded_len_bytes : Length of the bitstream in bytes. + * + * Output: + * - rateIndex : Bandwidth estimate in bitstream + * + */ - /**************************************************************************** - * WebRtcIsacfix_SetMaxRate(...) - * - * This function sets the maximum rate which the codec may not exceed for a - * singel packet. The maximum rate is set in bits per second. - * The codec has an absolute maximum rate of 53400 bits per second (200 bytes - * per 30 msec). - * It is possible to set a maximum rate between 32000 and 53400 bits per second. - * - * The rate limit is valid until next time the function is called. - * - * NOTE! Packet size will never go above the value set if calling - * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxRateInBytes : maximum rate in bits per second, - * valid values are 32000 to 53400 bits - * - * Return value : 0 if sucessful - * -1 if error happens - */ +int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded, + size_t encoded_len_bytes, + int16_t* rateIndex); - int16_t WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct *ISAC_main_inst, - int32_t maxRate); +/**************************************************************************** + * WebRtcIsacfix_GetNewFrameLen(...) + * + * This function return the next frame length (in samples) of iSAC. + * + * Input: + * -ISAC_main_inst : iSAC instance + * + * Return value : frame lenght in samples + */ - /**************************************************************************** - * WebRtcIsacfix_CreateInternal(...) - * - * This function creates the memory that is used to store data in the encoder - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ +int16_t WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct* ISAC_main_inst); - int16_t WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct *ISAC_main_inst); +/* Fills in an IsacBandwidthInfo struct. */ +void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, + IsacBandwidthInfo* bwinfo); - - /**************************************************************************** - * WebRtcIsacfix_FreeInternal(...) - * - * This function frees the internal memory for storing encoder data. - * - * Input: - * - ISAC_main_inst : an ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_GetNewBitStream(...) - * - * This function returns encoded data, with the recieved bwe-index in the - * stream. It should always return a complete packet, i.e. only called once - * even for 60 msec frames - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - bweIndex : index of bandwidth estimate to put in new bitstream - * - scale : factor for rate change (0.4 ~=> half the rate, 1 no change). - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - - int16_t WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct *ISAC_main_inst, - int16_t bweIndex, - float scale, - uint8_t* encoded); - - - /**************************************************************************** - * WebRtcIsacfix_GetDownLinkBwIndex(...) - * - * This function returns index representing the Bandwidth estimate from - * other side to this side. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - rateIndex : Bandwidth estimate to transmit to other side. - * - */ - - int16_t WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst, - int16_t* rateIndex); - - - /**************************************************************************** - * WebRtcIsacfix_UpdateUplinkBw(...) - * - * This function takes an index representing the Bandwidth estimate from - * this side to other side and updates BWE. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - rateIndex : Bandwidth estimate from other side. - * - */ - - int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst, - int16_t rateIndex); - - - /**************************************************************************** - * WebRtcIsacfix_ReadBwIndex(...) - * - * This function returns the index of the Bandwidth estimate from the bitstream. - * - * Input: - * - encoded : Encoded bitstream - * - encoded_len_bytes : Length of the bitstream in bytes. - * - * Output: - * - rateIndex : Bandwidth estimate in bitstream - * - */ - - int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded, - size_t encoded_len_bytes, - int16_t* rateIndex); - - - /**************************************************************************** - * WebRtcIsacfix_GetNewFrameLen(...) - * - * This function return the next frame length (in samples) of iSAC. - * - * Input: - * -ISAC_main_inst : iSAC instance - * - * Return value : frame lenght in samples - */ - - int16_t WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct *ISAC_main_inst); - - /* Fills in an IsacBandwidthInfo struct. */ - void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, - IsacBandwidthInfo* bwinfo); - - /* Uses the values from an IsacBandwidthInfo struct. */ - void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, - const IsacBandwidthInfo* bwinfo); +/* Uses the values from an IsacBandwidthInfo struct. */ +void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, + const IsacBandwidthInfo* bwinfo); #if defined(__cplusplus) } #endif - - #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INCLUDE_ISACFIX_H_ */ diff --git a/modules/audio_coding/codecs/isac/fix/source/arith_routins.h b/modules/audio_coding/codecs/isac/fix/source/arith_routins.h index 25eeecf7fa..cc4ed555cf 100644 --- a/modules/audio_coding/codecs/isac/fix/source/arith_routins.h +++ b/modules/audio_coding/codecs/isac/fix/source/arith_routins.h @@ -35,12 +35,10 @@ * Return value : 0 if ok, * <0 otherwise. */ -int WebRtcIsacfix_EncLogisticMulti2( - Bitstr_enc *streamData, - int16_t *dataQ7, - const uint16_t *env, - const int16_t lenData); - +int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc* streamData, + int16_t* dataQ7, + const uint16_t* env, + const int16_t lenData); /**************************************************************************** * WebRtcIsacfix_EncTerminate(...) @@ -53,8 +51,7 @@ int WebRtcIsacfix_EncLogisticMulti2( * * Return value : number of bytes in the stream */ -int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData); - +int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc* streamData); /**************************************************************************** * WebRtcIsacfix_DecLogisticMulti2(...) @@ -73,12 +70,10 @@ int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData); * Return value : number of bytes in the stream so far * <0 if error detected */ -int WebRtcIsacfix_DecLogisticMulti2( - int16_t *data, - Bitstr_dec *streamData, - const int32_t *env, - const int16_t lenData); - +int WebRtcIsacfix_DecLogisticMulti2(int16_t* data, + Bitstr_dec* streamData, + const int32_t* env, + const int16_t lenData); /**************************************************************************** * WebRtcIsacfix_EncHistMulti(...) @@ -94,12 +89,10 @@ int WebRtcIsacfix_DecLogisticMulti2( * Return value : 0 if ok * <0 if error detected */ -int WebRtcIsacfix_EncHistMulti( - Bitstr_enc *streamData, - const int16_t *data, - const uint16_t *const *cdf, - const int16_t lenData); - +int WebRtcIsacfix_EncHistMulti(Bitstr_enc* streamData, + const int16_t* data, + const uint16_t* const* cdf, + const int16_t lenData); /**************************************************************************** * WebRtcIsacfix_DecHistBisectMulti(...) @@ -121,13 +114,11 @@ int WebRtcIsacfix_EncHistMulti( * Return value : number of bytes in the stream * <0 if error detected */ -int16_t WebRtcIsacfix_DecHistBisectMulti( - int16_t *data, - Bitstr_dec *streamData, - const uint16_t *const *cdf, - const uint16_t *cdfSize, - const int16_t lenData); - +int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t* data, + Bitstr_dec* streamData, + const uint16_t* const* cdf, + const uint16_t* cdfSize, + const int16_t lenData); /**************************************************************************** * WebRtcIsacfix_DecHistOneStepMulti(...) @@ -149,11 +140,10 @@ int16_t WebRtcIsacfix_DecHistBisectMulti( * Return value : number of bytes in original stream * <0 if error detected */ -int16_t WebRtcIsacfix_DecHistOneStepMulti( - int16_t *data, - Bitstr_dec *streamData, - const uint16_t *const *cdf, - const uint16_t *initIndex, - const int16_t lenData); +int16_t WebRtcIsacfix_DecHistOneStepMulti(int16_t* data, + Bitstr_dec* streamData, + const uint16_t* const* cdf, + const uint16_t* initIndex, + const int16_t lenData); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ */ diff --git a/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h b/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h index 67f8d0782e..f8ac1efae7 100644 --- a/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h +++ b/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h @@ -32,8 +32,7 @@ * Return value : 0 */ -int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bwest_str); - +int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr* bwest_str); /**************************************************************************** * WebRtcIsacfix_UpdateUplinkBwImpl(...) @@ -56,16 +55,17 @@ int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bwest_str); * -1 otherwise */ -int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bwest_str, - const uint16_t rtp_number, - const int16_t frameSize, - const uint32_t send_ts, - const uint32_t arr_ts, - const size_t pksize, - const uint16_t Index); +int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr* bwest_str, + const uint16_t rtp_number, + const int16_t frameSize, + const uint32_t send_ts, + const uint32_t arr_ts, + const size_t pksize, + const uint16_t Index); -/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */ -int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bwest_str, +/* Update receiving estimates. Used when we only receive BWE index, no iSAC data + * packet. */ +int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr* bwest_str, const int16_t Index); /**************************************************************************** @@ -80,19 +80,19 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bwest_str, * Return: * bandwith and jitter index (0..23) */ -uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bwest_str); +uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr* bwest_str); /* Returns the bandwidth estimation (in bps) */ -uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bwest_str); +uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str); /* Returns the bandwidth that iSAC should send with in bps */ -int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr *bwest_str); +int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr* bwest_str); /* Returns the max delay (in ms) */ -int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str); +int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str); /* Returns the max delay value from the other side in ms */ -int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr *bwest_str); +int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str); /* Fills in an IsacExternalBandwidthInfo struct. */ void WebRtcIsacfixBw_GetBandwidthInfo(BwEstimatorstr* bwest_str, @@ -106,29 +106,31 @@ void WebRtcIsacfixBw_SetBandwidthInfo(BwEstimatorstr* bwest_str, * update amount of data in bottle neck buffer and burst handling * returns minimum payload size (bytes) */ -uint16_t WebRtcIsacfix_GetMinBytes(RateModel *State, - int16_t StreamSize, /* bytes in bitstream */ - const int16_t FrameLen, /* ms per frame */ - const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */ - const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */ +uint16_t WebRtcIsacfix_GetMinBytes( + RateModel* State, + int16_t StreamSize, /* bytes in bitstream */ + const int16_t FrameLen, /* ms per frame */ + const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */ + const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */ /* * update long-term average bitrate and amount of data in buffer */ -void WebRtcIsacfix_UpdateRateModel(RateModel *State, - int16_t StreamSize, /* bytes in bitstream */ - const int16_t FrameSamples, /* samples per frame */ - const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */ +void WebRtcIsacfix_UpdateRateModel( + RateModel* State, + int16_t StreamSize, /* bytes in bitstream */ + const int16_t FrameSamples, /* samples per frame */ + const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */ - -void WebRtcIsacfix_InitRateModel(RateModel *State); +void WebRtcIsacfix_InitRateModel(RateModel* State); /* Returns the new framelength value (input argument: bottle_neck) */ -int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck, int16_t current_framelength); +int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck, + int16_t current_framelength); /* Returns the new SNR value (input argument: bottle_neck) */ -//returns snr in Q10 +// returns snr in Q10 int16_t WebRtcIsacfix_GetSnr(int16_t bottle_neck, int16_t framesamples); - -#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ */ +#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ \ + */ diff --git a/modules/audio_coding/codecs/isac/fix/source/codec.h b/modules/audio_coding/codecs/isac/fix/source/codec.h index 9876bd6aed..c95b53ff64 100644 --- a/modules/audio_coding/codecs/isac/fix/source/codec.h +++ b/modules/audio_coding/codecs/isac/fix/source/codec.h @@ -38,7 +38,7 @@ int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16, void WebRtcIsacfix_DecodePlcImpl(int16_t* decoded, IsacFixDecoderInstance* ISACdec_obj, - size_t* current_framesample ); + size_t* current_framesample); int WebRtcIsacfix_EncodeImpl(int16_t* in, IsacFixEncoderInstance* ISACenc_obj, @@ -64,7 +64,6 @@ void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct* State); void WebRtcIsacfix_InitPlc(PLCstr* State); - /* transform functions */ void WebRtcIsacfix_InitTransform(void); diff --git a/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h b/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h index ba7bcde0c0..b4251cee1e 100644 --- a/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h +++ b/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h @@ -22,91 +22,79 @@ #include "modules/audio_coding/codecs/isac/fix/source/structs.h" /* decode complex spectrum (return number of bytes in stream) */ -int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, - int16_t *frQ7, - int16_t *fiQ7, +int WebRtcIsacfix_DecodeSpec(Bitstr_dec* streamdata, + int16_t* frQ7, + int16_t* fiQ7, int16_t AvgPitchGain_Q12); /* encode complex spectrum */ -int WebRtcIsacfix_EncodeSpec(const int16_t *fr, - const int16_t *fi, - Bitstr_enc *streamdata, +int WebRtcIsacfix_EncodeSpec(const int16_t* fr, + const int16_t* fi, + Bitstr_enc* streamdata, int16_t AvgPitchGain_Q12); - /* decode & dequantize LPC Coef */ -int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata, - int32_t *LPCCoefQ17, - int32_t *gain_lo_hiQ17, - int16_t *outmodel); +int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec* streamdata, + int32_t* LPCCoefQ17, + int32_t* gain_lo_hiQ17, + int16_t* outmodel); -int WebRtcIsacfix_DecodeLpc(int32_t *gain_lo_hiQ17, - int16_t *LPCCoef_loQ15, - int16_t *LPCCoef_hiQ15, - Bitstr_dec *streamdata, - int16_t *outmodel); +int WebRtcIsacfix_DecodeLpc(int32_t* gain_lo_hiQ17, + int16_t* LPCCoef_loQ15, + int16_t* LPCCoef_hiQ15, + Bitstr_dec* streamdata, + int16_t* outmodel); /* quantize & code LPC Coef */ -int WebRtcIsacfix_EncodeLpc(int32_t *gain_lo_hiQ17, - int16_t *LPCCoef_loQ15, - int16_t *LPCCoef_hiQ15, - int16_t *model, - int32_t *sizeQ11, - Bitstr_enc *streamdata, +int WebRtcIsacfix_EncodeLpc(int32_t* gain_lo_hiQ17, + int16_t* LPCCoef_loQ15, + int16_t* LPCCoef_hiQ15, + int16_t* model, + int32_t* sizeQ11, + Bitstr_enc* streamdata, IsacSaveEncoderData* encData, - transcode_obj *transcodeParam); + transcode_obj* transcodeParam); -int WebRtcIsacfix_EstCodeLpcGain(int32_t *gain_lo_hiQ17, - Bitstr_enc *streamdata, +int WebRtcIsacfix_EstCodeLpcGain(int32_t* gain_lo_hiQ17, + Bitstr_enc* streamdata, IsacSaveEncoderData* encData); /* decode & dequantize RC */ -int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec *streamdata, - int16_t *RCQ15); +int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec* streamdata, int16_t* RCQ15); /* quantize & code RC */ -int WebRtcIsacfix_EncodeRcCoef(int16_t *RCQ15, - Bitstr_enc *streamdata); +int WebRtcIsacfix_EncodeRcCoef(int16_t* RCQ15, Bitstr_enc* streamdata); /* decode & dequantize squared Gain */ -int WebRtcIsacfix_DecodeGain2(Bitstr_dec *streamdata, - int32_t *Gain2); +int WebRtcIsacfix_DecodeGain2(Bitstr_dec* streamdata, int32_t* Gain2); /* quantize & code squared Gain (input is squared gain) */ -int WebRtcIsacfix_EncodeGain2(int32_t *gain2, - Bitstr_enc *streamdata); +int WebRtcIsacfix_EncodeGain2(int32_t* gain2, Bitstr_enc* streamdata); -int WebRtcIsacfix_EncodePitchGain(int16_t *PitchGains_Q12, - Bitstr_enc *streamdata, +int WebRtcIsacfix_EncodePitchGain(int16_t* PitchGains_Q12, + Bitstr_enc* streamdata, IsacSaveEncoderData* encData); -int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagQ7, - int16_t *PitchGain_Q12, - Bitstr_enc *streamdata, +int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagQ7, + int16_t* PitchGain_Q12, + Bitstr_enc* streamdata, IsacSaveEncoderData* encData); -int WebRtcIsacfix_DecodePitchGain(Bitstr_dec *streamdata, - int16_t *PitchGain_Q12); +int WebRtcIsacfix_DecodePitchGain(Bitstr_dec* streamdata, + int16_t* PitchGain_Q12); -int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata, - int16_t *PitchGain_Q12, - int16_t *PitchLagQ7); +int WebRtcIsacfix_DecodePitchLag(Bitstr_dec* streamdata, + int16_t* PitchGain_Q12, + int16_t* PitchLagQ7); -int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata, - size_t *framelength); +int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec* streamdata, size_t* framelength); +int WebRtcIsacfix_EncodeFrameLen(int16_t framelength, Bitstr_enc* streamdata); -int WebRtcIsacfix_EncodeFrameLen(int16_t framelength, - Bitstr_enc *streamdata); +int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec* streamdata, int16_t* BWno); -int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec *streamdata, - int16_t *BWno); +int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t* BWno, Bitstr_enc* streamdata); - -int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t *BWno, - Bitstr_enc *streamdata); - -void WebRtcIsacfix_TranscodeLpcCoef(int32_t *tmpcoeffs_gQ6, - int16_t *index_gQQ); +void WebRtcIsacfix_TranscodeLpcCoef(int32_t* tmpcoeffs_gQ6, int16_t* index_gQQ); // Pointer functions for LPC transforms. diff --git a/modules/audio_coding/codecs/isac/fix/source/fft.h b/modules/audio_coding/codecs/isac/fix/source/fft.h index 61ec515aef..4fe9b96be4 100644 --- a/modules/audio_coding/codecs/isac/fix/source/fft.h +++ b/modules/audio_coding/codecs/isac/fix/source/fft.h @@ -32,8 +32,8 @@ #include "modules/audio_coding/codecs/isac/fix/source/structs.h" -int16_t WebRtcIsacfix_FftRadix16Fastest(int16_t RexQx[], int16_t ImxQx[], int16_t iSign); - - +int16_t WebRtcIsacfix_FftRadix16Fastest(int16_t RexQx[], + int16_t ImxQx[], + int16_t iSign); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FFT_H_ */ diff --git a/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h b/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h index 1c349697dd..8d973471e1 100644 --- a/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h +++ b/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h @@ -42,44 +42,41 @@ void WebRtcIsacfix_HighpassFilterFixDec32MIPS(int16_t* io, #endif typedef void (*AllpassFilter2FixDec16)( - int16_t *data_ch1, // Input and output in channel 1, in Q0 - int16_t *data_ch2, // Input and output in channel 2, in Q0 - const int16_t *factor_ch1, // Scaling factor for channel 1, in Q15 - const int16_t *factor_ch2, // Scaling factor for channel 2, in Q15 + int16_t* data_ch1, // Input and output in channel 1, in Q0 + int16_t* data_ch2, // Input and output in channel 2, in Q0 + const int16_t* factor_ch1, // Scaling factor for channel 1, in Q15 + const int16_t* factor_ch2, // Scaling factor for channel 2, in Q15 const int length, // Length of the data buffers - int32_t *filter_state_ch1, // Filter state for channel 1, in Q16 - int32_t *filter_state_ch2); // Filter state for channel 2, in Q16 + int32_t* filter_state_ch1, // Filter state for channel 1, in Q16 + int32_t* filter_state_ch2); // Filter state for channel 2, in Q16 extern AllpassFilter2FixDec16 WebRtcIsacfix_AllpassFilter2FixDec16; -void WebRtcIsacfix_AllpassFilter2FixDec16C( - int16_t *data_ch1, - int16_t *data_ch2, - const int16_t *factor_ch1, - const int16_t *factor_ch2, - const int length, - int32_t *filter_state_ch1, - int32_t *filter_state_ch2); +void WebRtcIsacfix_AllpassFilter2FixDec16C(int16_t* data_ch1, + int16_t* data_ch2, + const int16_t* factor_ch1, + const int16_t* factor_ch2, + const int length, + int32_t* filter_state_ch1, + int32_t* filter_state_ch2); #if defined(WEBRTC_HAS_NEON) -void WebRtcIsacfix_AllpassFilter2FixDec16Neon( - int16_t *data_ch1, - int16_t *data_ch2, - const int16_t *factor_ch1, - const int16_t *factor_ch2, - const int length, - int32_t *filter_state_ch1, - int32_t *filter_state_ch2); +void WebRtcIsacfix_AllpassFilter2FixDec16Neon(int16_t* data_ch1, + int16_t* data_ch2, + const int16_t* factor_ch1, + const int16_t* factor_ch2, + const int length, + int32_t* filter_state_ch1, + int32_t* filter_state_ch2); #endif #if defined(MIPS_DSP_R1_LE) -void WebRtcIsacfix_AllpassFilter2FixDec16MIPS( - int16_t *data_ch1, - int16_t *data_ch2, - const int16_t *factor_ch1, - const int16_t *factor_ch2, - const int length, - int32_t *filter_state_ch1, - int32_t *filter_state_ch2); +void WebRtcIsacfix_AllpassFilter2FixDec16MIPS(int16_t* data_ch1, + int16_t* data_ch2, + const int16_t* factor_ch1, + const int16_t* factor_ch2, + const int length, + int32_t* filter_state_ch1, + int32_t* filter_state_ch2); #endif #if defined(__cplusplus) || defined(c_plusplus) diff --git a/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc index d17f4a5f9d..0727d58378 100644 --- a/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc +++ b/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc @@ -21,8 +21,8 @@ class FilterBanksTest : public testing::Test { protected: // Pass a function pointer to the Tester function. void RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/5513 - CalculateResidualEnergyTester(AllpassFilter2FixDec16 - AllpassFilter2FixDec16Function) { + CalculateResidualEnergyTester( + AllpassFilter2FixDec16 AllpassFilter2FixDec16Function) { const int kSamples = QLOOKAHEAD; const int kState = 2; int16_t data_ch1[kSamples] = {0}; @@ -31,12 +31,14 @@ class FilterBanksTest : public testing::Test { int32_t state_ch2[kState] = {0}; const int32_t out_state_ch1[kState] = {-809122714, 1645972152}; const int32_t out_state_ch2[kState] = {428019288, 1057309936}; - const int32_t out_data_ch1[kSamples] = {0, 0, 347, 10618, 16718, -7089, - 32767, 16913, 27042, 8377, -22973, -28372, -27603, -14804, 398, -25332, - -11200, 18044, 25223, -6839, 1116, -23984, 32717, 7364}; - const int32_t out_data_ch2[kSamples] = {0, 0, 3010, 22351, 21106, 16969, - -2095, -664, 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339, - -17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504}; + const int32_t out_data_ch1[kSamples] = { + 0, 0, 347, 10618, 16718, -7089, 32767, 16913, + 27042, 8377, -22973, -28372, -27603, -14804, 398, -25332, + -11200, 18044, 25223, -6839, 1116, -23984, 32717, 7364}; + const int32_t out_data_ch2[kSamples] = { + 0, 0, 3010, 22351, 21106, 16969, -2095, -664, + 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339, + -17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504}; int sign = 1; for (int i = 0; i < kSamples; i++) { @@ -46,13 +48,9 @@ class FilterBanksTest : public testing::Test { // UBSan: -1 * -2147483648 cannot be represented in type 'int' }; - AllpassFilter2FixDec16Function(data_ch1, - data_ch2, - WebRtcIsacfix_kUpperApFactorsQ15, - WebRtcIsacfix_kLowerApFactorsQ15, - kSamples, - state_ch1, - state_ch2); + AllpassFilter2FixDec16Function( + data_ch1, data_ch2, WebRtcIsacfix_kUpperApFactorsQ15, + WebRtcIsacfix_kLowerApFactorsQ15, kSamples, state_ch1, state_ch2); for (int i = 0; i < kSamples; i++) { EXPECT_EQ(out_data_ch1[i], data_ch1[i]); @@ -77,13 +75,13 @@ TEST_F(FilterBanksTest, HighpassFilterFixDec32Test) { int16_t in[kSamples]; int32_t state[2] = {12345, 987654}; #ifdef WEBRTC_ARCH_ARM_V7 - int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917, - -1279, -8552, -14494, -7558, -23537, -27258, -30554, -32768, -3432, -32768, - 25215, -27536, 22436}; + int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917, + -1279, -8552, -14494, -7558, -23537, -27258, -30554, + -32768, -3432, -32768, 25215, -27536, 22436}; #else - int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915, - -1280, -8554, -14496, -7561, -23541, -27263, -30560, -32768, -3441, -32768, - 25203, -27550, 22419}; + int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915, + -1280, -8554, -14496, -7561, -23541, -27263, -30560, + -32768, -3441, -32768, 25203, -27550, 22419}; #endif HighpassFilterFixDec32 WebRtcIsacfix_HighpassFilterFixDec32; #if defined(MIPS_DSP_R1_LE) @@ -98,7 +96,7 @@ TEST_F(FilterBanksTest, HighpassFilterFixDec32Test) { } WebRtcIsacfix_HighpassFilterFixDec32(in, kSamples, - WebRtcIsacfix_kHPStCoeffOut1Q30, state); + WebRtcIsacfix_kHPStCoeffOut1Q30, state); for (int i = 0; i < kSamples; i++) { EXPECT_EQ(out[i], in[i]); diff --git a/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc index fa529863c0..2ab8d6aeea 100644 --- a/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc +++ b/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc @@ -23,34 +23,37 @@ class FiltersTest : public testing::Test { int32_t r_buffer[kOrder + 2] = {0}; // Test an overflow case. - const int16_t x_buffer_0[kBuffer] = {0, 0, 3010, 22351, 21106, 16969, -2095, - -664, 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339, -17207, - 32767, 4959, 6177, 32767, 16599, -4747, 20504, 3513, -30980, 32767, - -23839, 13335, 20289, 0, -16969, -2095, -664, 3513, 31981, 32767, - -13839, 23336, 30281}; - const int32_t r_expected_0[kOrder + 2] = {1872498461, -224288754, 203789985, - 483400487, -208272635, 2436500, 137785322, 266600814, -208486262, - 329510080, 137949184, -161738972, -26894267, 237630192}; + const int16_t x_buffer_0[kBuffer] = { + 0, 0, 3010, 22351, 21106, 16969, -2095, -664, + 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339, + -17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504, + 3513, -30980, 32767, -23839, 13335, 20289, 0, -16969, + -2095, -664, 3513, 31981, 32767, -13839, 23336, 30281}; + const int32_t r_expected_0[kOrder + 2] = { + 1872498461, -224288754, 203789985, 483400487, -208272635, + 2436500, 137785322, 266600814, -208486262, 329510080, + 137949184, -161738972, -26894267, 237630192}; - WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_0, - kBuffer, kOrder + 1, &scale); + WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_0, kBuffer, kOrder + 1, + &scale); for (int i = 0; i < kOrder + 2; i++) { EXPECT_EQ(r_expected_0[i], r_buffer[i]); } EXPECT_EQ(3, scale); // Test a no-overflow case. - const int16_t x_buffer_1[kBuffer] = {0, 0, 300, 21, 206, 169, -295, - -664, 3513, -300, 327, -29, 15, 289, -6831, 339, -107, - 37, 59, 6177, 327, 169, -4747, 204, 313, -980, 767, - -9, 135, 289, 0, -6969, -2095, -664, 0, 1, 7, - -39, 236, 281}; - const int32_t r_expected_1[kOrder + 2] = {176253864, 8126617, 1983287, - -26196788, -3487363, -42839676, -24644043, 3469813, 30559879, 31905045, - 5101567, 29328896, -55787438, -13163978}; + const int16_t x_buffer_1[kBuffer] = { + 0, 0, 300, 21, 206, 169, -295, -664, 3513, -300, + 327, -29, 15, 289, -6831, 339, -107, 37, 59, 6177, + 327, 169, -4747, 204, 313, -980, 767, -9, 135, 289, + 0, -6969, -2095, -664, 0, 1, 7, -39, 236, 281}; + const int32_t r_expected_1[kOrder + 2] = { + 176253864, 8126617, 1983287, -26196788, -3487363, + -42839676, -24644043, 3469813, 30559879, 31905045, + 5101567, 29328896, -55787438, -13163978}; - WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_1, - kBuffer, kOrder + 1, &scale); + WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_1, kBuffer, kOrder + 1, + &scale); for (int i = 0; i < kOrder + 2; i++) { EXPECT_EQ(r_expected_1[i], r_buffer[i]); } diff --git a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h index d6d1e8f0c0..40a99e8a77 100644 --- a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h +++ b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h @@ -24,19 +24,19 @@ extern "C" { #include "modules/audio_coding/codecs/isac/fix/source/structs.h" -void WebRtcIsacfix_GetVars(const int16_t *input, - const int16_t *pitchGains_Q12, - uint32_t *oldEnergy, - int16_t *varscale); +void WebRtcIsacfix_GetVars(const int16_t* input, + const int16_t* pitchGains_Q12, + uint32_t* oldEnergy, + int16_t* varscale); -void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0, - int16_t *inHiQ0, - MaskFiltstr_enc *maskdata, +void WebRtcIsacfix_GetLpcCoef(int16_t* inLoQ0, + int16_t* inHiQ0, + MaskFiltstr_enc* maskdata, int16_t snrQ10, - const int16_t *pitchGains_Q12, - int32_t *gain_lo_hiQ17, - int16_t *lo_coeffQ15, - int16_t *hi_coeffQ15); + const int16_t* pitchGains_Q12, + int32_t* gain_lo_hiQ17, + int16_t* lo_coeffQ15, + int16_t* hi_coeffQ15); typedef int32_t (*CalculateResidualEnergy)(int lpc_order, int32_t q_val_corr, diff --git a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc index 1604cc4144..dbcf420179 100644 --- a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc +++ b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc @@ -16,21 +16,21 @@ class LpcMaskingModelTest : public testing::Test { protected: // Pass a function pointer to the Tester function. - void CalculateResidualEnergyTester(CalculateResidualEnergy - CalculateResidualEnergyFunction) { + void CalculateResidualEnergyTester( + CalculateResidualEnergy CalculateResidualEnergyFunction) { const int kIntOrder = 10; const int32_t kInt32QDomain = 5; const int kIntShift = 11; - int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958, - -48, 18745, 498, 9, 23456}; - int32_t corr[kIntOrder + 1] = {11443647, -27495, 0, - 98745, -11443600, 1, 1, 498, 9, 888, 23456}; + int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958, + -48, 18745, 498, 9, 23456}; + int32_t corr[kIntOrder + 1] = {11443647, -27495, 0, 98745, -11443600, 1, + 1, 498, 9, 888, 23456}; int q_shift_residual = 0; int32_t residual_energy = 0; // Test the code path where (residual_energy >= 0x10000). - residual_energy = CalculateResidualEnergyFunction(kIntOrder, - kInt32QDomain, kIntShift, a, corr, &q_shift_residual); + residual_energy = CalculateResidualEnergyFunction( + kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual); EXPECT_EQ(1789023310, residual_energy); EXPECT_EQ(2, q_shift_residual); @@ -40,8 +40,8 @@ class LpcMaskingModelTest : public testing::Test { a[i] = 24575 >> i; corr[i] = i; } - residual_energy = CalculateResidualEnergyFunction(kIntOrder, - kInt32QDomain, kIntShift, a, corr, &q_shift_residual); + residual_energy = CalculateResidualEnergyFunction( + kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual); EXPECT_EQ(1595279092, residual_energy); EXPECT_EQ(26, q_shift_residual); @@ -49,8 +49,8 @@ class LpcMaskingModelTest : public testing::Test { for (int i = 0; i < kIntOrder + 1; i++) { a[i] = 2457 >> i; } - residual_energy = CalculateResidualEnergyFunction(kIntOrder, - kInt32QDomain, kIntShift, a, corr, &q_shift_residual); + residual_energy = CalculateResidualEnergyFunction( + kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual); EXPECT_EQ(2029266944, residual_energy); EXPECT_EQ(33, q_shift_residual); } diff --git a/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h b/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h index 05c53dd94c..c51f2cab74 100644 --- a/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h +++ b/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h @@ -26,10 +26,10 @@ extern const uint16_t WebRtcIsacfix_kSelIndGain[12]; extern const uint16_t WebRtcIsacfix_kSelIndShape[108]; /* cdf array for model indicator */ -extern const uint16_t WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS+1]; +extern const uint16_t WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS + 1]; /* pointer to cdf array for model indicator */ -extern const uint16_t *WebRtcIsacfix_kModelCdfPtr[1]; +extern const uint16_t* WebRtcIsacfix_kModelCdfPtr[1]; /* initial cdf index for decoder of model indicator */ extern const uint16_t WebRtcIsacfix_kModelInitIndex[1]; @@ -70,9 +70,9 @@ extern const uint16_t WebRtcIsacfix_kCdfGain[1212]; extern const uint16_t WebRtcIsacfix_kCdfShape[2059]; /* pointers to cdf tables for quantizer indices */ -extern const uint16_t *WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12]; +extern const uint16_t* WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12]; -extern const uint16_t *WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108]; +extern const uint16_t* WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108]; /* code length for all coefficients using different models */ extern const int16_t WebRtcIsacfix_kCodeLenGainQ11[392]; diff --git a/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h b/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h index 994cce7ce9..4303c82711 100644 --- a/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h +++ b/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h @@ -20,21 +20,22 @@ #include "modules/audio_coding/codecs/isac/fix/source/structs.h" -void WebRtcIsacfix_PitchAnalysis(const int16_t *in, /* PITCH_FRAME_LEN samples */ - int16_t *outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ - PitchAnalysisStruct *State, - int16_t *lagsQ7, - int16_t *PitchGains_Q12); +void WebRtcIsacfix_PitchAnalysis( + const int16_t* in, /* PITCH_FRAME_LEN samples */ + int16_t* outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ + PitchAnalysisStruct* State, + int16_t* lagsQ7, + int16_t* PitchGains_Q12); -void WebRtcIsacfix_InitialPitch(const int16_t *in, - PitchAnalysisStruct *State, - int16_t *qlags); +void WebRtcIsacfix_InitialPitch(const int16_t* in, + PitchAnalysisStruct* State, + int16_t* qlags); -void WebRtcIsacfix_PitchFilter(int16_t *indatFix, - int16_t *outdatQQ, - PitchFiltstr *pfp, - int16_t *lagsQ7, - int16_t *gainsQ12, +void WebRtcIsacfix_PitchFilter(int16_t* indatFix, + int16_t* outdatQQ, + PitchFiltstr* pfp, + int16_t* lagsQ7, + int16_t* gainsQ12, int16_t type); void WebRtcIsacfix_PitchFilterCore(int loopNumber, @@ -48,17 +49,18 @@ void WebRtcIsacfix_PitchFilterCore(int loopNumber, int16_t* outputBuf, int* index2); -void WebRtcIsacfix_PitchFilterGains(const int16_t *indatQ0, - PitchFiltstr *pfp, - int16_t *lagsQ7, - int16_t *gainsQ12); +void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0, + PitchFiltstr* pfp, + int16_t* lagsQ7, + int16_t* gainsQ12); -void WebRtcIsacfix_DecimateAllpass32(const int16_t *in, - int32_t *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */ - int16_t N, /* number of input samples */ - int16_t *out); /* array of size N/2 */ +void WebRtcIsacfix_DecimateAllpass32( + const int16_t* in, + int32_t* state_in, /* array of size: 2*ALLPASSSECTIONS+1 */ + int16_t N, /* number of input samples */ + int16_t* out); /* array of size N/2 */ -int32_t WebRtcIsacfix_Log2Q8( uint32_t x ); +int32_t WebRtcIsacfix_Log2Q8(uint32_t x); void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8); diff --git a/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h b/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h index fe4d2883d4..2b5f54e965 100644 --- a/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h +++ b/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h @@ -11,7 +11,8 @@ /* * pitch_gain_tables.h * - * This file contains tables for the pitch filter side-info in the entropy coder. + * This file contains tables for the pitch filter side-info in the entropy + * coder. * */ @@ -20,7 +21,8 @@ #include "typedefs.h" // NOLINT(build/include) -/********************* Pitch Filter Gain Coefficient Tables ************************/ +/********************* Pitch Filter Gain Coefficient Tables + * ************************/ /* cdf for quantized pitch filter gains */ extern const uint16_t WebRtcIsacfix_kPitchGainCdf[255]; diff --git a/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h b/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h index a8c0c3ae7e..f834eab927 100644 --- a/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h +++ b/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h @@ -11,7 +11,8 @@ /* * pitch_lag_tables.h * - * This file contains tables for the pitch filter side-info in the entropy coder. + * This file contains tables for the pitch filter side-info in the entropy + * coder. * */ @@ -20,7 +21,8 @@ #include "typedefs.h" // NOLINT(build/include) -/********************* Pitch Filter Lag Coefficient Tables ************************/ +/********************* Pitch Filter Lag Coefficient Tables + * ************************/ /* tables for use with small pitch gain */ @@ -30,7 +32,7 @@ extern const uint16_t WebRtcIsacfix_kPitchLagCdf2Lo[20]; extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Lo[2]; extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Lo[10]; -extern const uint16_t *WebRtcIsacfix_kPitchLagPtrLo[4]; +extern const uint16_t* WebRtcIsacfix_kPitchLagPtrLo[4]; /* size of first cdf table */ extern const uint16_t WebRtcIsacfix_kPitchLagSizeLo[1]; @@ -46,8 +48,6 @@ extern const uint16_t WebRtcIsacfix_kInitIndLo[3]; extern const int16_t WebRtcIsacfix_kMeanLag2Lo[19]; extern const int16_t WebRtcIsacfix_kMeanLag4Lo[9]; - - /* tables for use with medium pitch gain */ /* cdfs for quantized pitch lags */ @@ -56,7 +56,7 @@ extern const uint16_t WebRtcIsacfix_kPitchLagCdf2Mid[36]; extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Mid[2]; extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Mid[20]; -extern const uint16_t *WebRtcIsacfix_kPitchLagPtrMid[4]; +extern const uint16_t* WebRtcIsacfix_kPitchLagPtrMid[4]; /* size of first cdf table */ extern const uint16_t WebRtcIsacfix_kPitchLagSizeMid[1]; @@ -72,7 +72,6 @@ extern const uint16_t WebRtcIsacfix_kInitIndMid[3]; extern const int16_t WebRtcIsacfix_kMeanLag2Mid[35]; extern const int16_t WebRtcIsacfix_kMeanLag4Mid[19]; - /* tables for use with large pitch gain */ /* cdfs for quantized pitch lags */ @@ -81,7 +80,7 @@ extern const uint16_t WebRtcIsacfix_kPitchLagCdf2Hi[68]; extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Hi[2]; extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Hi[35]; -extern const uint16_t *WebRtcIsacfix_kPitchLagPtrHi[4]; +extern const uint16_t* WebRtcIsacfix_kPitchLagPtrHi[4]; /* size of first cdf table */ extern const uint16_t WebRtcIsacfix_kPitchLagSizeHi[1]; @@ -97,5 +96,4 @@ extern const uint16_t WebRtcIsacfix_kInitIndHi[3]; extern const int16_t WebRtcIsacfix_kMeanLag2Hi[67]; extern const int16_t WebRtcIsacfix_kMeanLag4Hi[34]; - #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_LAG_TABLES_H_ */ diff --git a/modules/audio_coding/codecs/isac/fix/source/settings.h b/modules/audio_coding/codecs/isac/fix/source/settings.h index 34c0efefd0..03a2d05457 100644 --- a/modules/audio_coding/codecs/isac/fix/source/settings.h +++ b/modules/audio_coding/codecs/isac/fix/source/settings.h @@ -18,84 +18,82 @@ #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ - /* sampling frequency (Hz) */ -#define FS 16000 +#define FS 16000 /* 1.5 times Sampling frequency */ -#define FS_1_HALF (uint32_t) 24000 +#define FS_1_HALF (uint32_t)24000 /* Three times Sampling frequency */ -#define FS3 (uint32_t) 48000 +#define FS3 (uint32_t)48000 /* Eight times Sampling frequency */ -#define FS8 (uint32_t) 128000 +#define FS8 (uint32_t)128000 /* number of samples per frame (either 480 (30ms) or 960 (60ms)) */ -#define INITIAL_FRAMESAMPLES 960 +#define INITIAL_FRAMESAMPLES 960 /* miliseconds */ -#define FRAMESIZE 30 +#define FRAMESIZE 30 /* number of samples per frame processed in the encoder (30ms) */ -#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ -#define FRAMESAMPLES_HALF 240 +#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ +#define FRAMESAMPLES_HALF 240 /* max number of samples per frame (= 60 ms frame) */ -#define MAX_FRAMESAMPLES 960 +#define MAX_FRAMESAMPLES 960 /* number of samples per 10ms frame */ -#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */ +#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */ /* Number of samples per 1 ms */ -#define SAMPLES_PER_MSEC 16 +#define SAMPLES_PER_MSEC 16 /* number of subframes */ -#define SUBFRAMES 6 +#define SUBFRAMES 6 /* length of a subframe */ -#define UPDATE 80 +#define UPDATE 80 /* length of half a subframe (low/high band) */ -#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */ -/* samples of look ahead (in a half-band, so actually half the samples of look ahead @ FS) */ -#define QLOOKAHEAD 24 /* 3 ms */ +#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */ +/* samples of look ahead (in a half-band, so actually half the samples of look + * ahead @ FS) */ +#define QLOOKAHEAD 24 /* 3 ms */ /* order of AR model in spectral entropy coder */ -#define AR_ORDER 6 -#define MAX_ORDER 13 -#define LEVINSON_MAX_ORDER 12 +#define AR_ORDER 6 +#define MAX_ORDER 13 +#define LEVINSON_MAX_ORDER 12 /* window length (masking analysis) */ -#define WINLEN 256 +#define WINLEN 256 /* order of low-band pole filter used to approximate masking curve */ -#define ORDERLO 12 +#define ORDERLO 12 /* order of hi-band pole filter used to approximate masking curve */ -#define ORDERHI 6 - -#define KLT_NUM_AVG_GAIN 0 -#define KLT_NUM_AVG_SHAPE 0 -#define KLT_NUM_MODELS 3 -#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */ - -#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */ -#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */ +#define ORDERHI 6 +#define KLT_NUM_AVG_GAIN 0 +#define KLT_NUM_AVG_SHAPE 0 +#define KLT_NUM_MODELS 3 +#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */ +#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */ +#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */ /* order for post_filter_bank */ -#define POSTQORDER 3 +#define POSTQORDER 3 /* order for pre-filterbank */ -#define QORDER 3 +#define QORDER 3 /* for decimator */ -#define ALLPASSSECTIONS 2 +#define ALLPASSSECTIONS 2 /* The number of composite all-pass filter factors */ -#define NUMBEROFCOMPOSITEAPSECTIONS 4 +#define NUMBEROFCOMPOSITEAPSECTIONS 4 /* The number of all-pass filter factors in an upper or lower channel*/ -#define NUMBEROFCHANNELAPSECTIONS 2 - - - -#define DPMIN_Q10 -10240 /* -10.00 in Q10 */ -#define DPMAX_Q10 10240 /* 10.00 in Q10 */ -#define MINBITS_Q10 10240 /* 10.0 in Q10 */ +#define NUMBEROFCHANNELAPSECTIONS 2 +#define DPMIN_Q10 -10240 /* -10.00 in Q10 */ +#define DPMAX_Q10 10240 /* 10.00 in Q10 */ +#define MINBITS_Q10 10240 /* 10.0 in Q10 */ /* array size for byte stream in number of Word16. */ -#define STREAM_MAXW16 300 /* The old maximum size still needed for the decoding */ -#define STREAM_MAXW16_30MS 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */ -#define STREAM_MAXW16_60MS 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */ +#define STREAM_MAXW16 \ + 300 /* The old maximum size still needed for the decoding */ +#define STREAM_MAXW16_30MS \ + 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */ +#define STREAM_MAXW16_60MS \ + 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */ /* This is used only at the decoder bit-stream struct. * - The encoder and decoder bitstream containers are of different size because * old iSAC limited the encoded bitstream to 600 bytes. But newer versions @@ -110,106 +108,104 @@ /* storage size for bit counts */ //#define BIT_COUNTER_SIZE 30 /* maximum order of any AR model or filter */ -#define MAX_AR_MODEL_ORDER 12 +#define MAX_AR_MODEL_ORDER 12 /* Maximum number of iterations allowed to limit payload size */ -#define MAX_PAYLOAD_LIMIT_ITERATION 1 +#define MAX_PAYLOAD_LIMIT_ITERATION 1 /* Bandwidth estimator */ -#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */ -#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */ -#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */ -#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */ -#define DELAY_CORRECTION_MAX 717 -#define DELAY_CORRECTION_MED 819 -#define Thld_30_60 18000 -#define Thld_60_30 27000 +#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */ +#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */ +#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */ +#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */ +#define DELAY_CORRECTION_MAX 717 +#define DELAY_CORRECTION_MED 819 +#define Thld_30_60 18000 +#define Thld_60_30 27000 -/* assumed header size; we don't know the exact number (header compression may be used) */ -#define HEADER_SIZE 35 /* bytes */ -#define INIT_FRAME_LEN 60 -#define INIT_BN_EST 20000 -#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */ -#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */ +/* assumed header size; we don't know the exact number (header compression may + * be used) */ +#define HEADER_SIZE 35 /* bytes */ +#define INIT_FRAME_LEN 60 +#define INIT_BN_EST 20000 +#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */ +#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */ /* 8738 in Q18 is ~ 1/30 */ -/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT (INIT_FRAME_LEN)) */ -#define INIT_HDR_RATE 4666 +/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT + * (INIT_FRAME_LEN)) */ +#define INIT_HDR_RATE 4666 /* number of packets in a row for a high rate burst */ -#define BURST_LEN 3 +#define BURST_LEN 3 /* ms, max time between two full bursts */ -#define BURST_INTERVAL 800 +#define BURST_INTERVAL 800 /* number of packets in a row for initial high rate burst */ -#define INIT_BURST_LEN 5 +#define INIT_BURST_LEN 5 /* bits/s, rate for the first BURST_LEN packets */ -#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */ - +#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */ /* For pitch analysis */ -#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */ -#define PITCH_MAX_LAG 140 /* 57 Hz */ -#define PITCH_MIN_LAG 20 /* 400 Hz */ -#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */ -#define OFFSET_Q8 768 /* 256 * 3 */ +#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */ +#define PITCH_MAX_LAG 140 /* 57 Hz */ +#define PITCH_MIN_LAG 20 /* 400 Hz */ +#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */ +#define OFFSET_Q8 768 /* 256 * 3 */ -#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */ -#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */ -#define PITCH_CORR_LEN2 60 /* 15 ms */ -#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */ -#define PITCH_SUBFRAMES 4 -#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */ +#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */ +#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */ +#define PITCH_CORR_LEN2 60 /* 15 ms */ +#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */ +#define PITCH_SUBFRAMES 4 +#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */ /* For pitch filter */ -#define PITCH_BUFFSIZE 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */ -#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */ -#define PITCH_FRACS 8 -#define PITCH_FRACORDER 9 -#define PITCH_DAMPORDER 5 - +#define PITCH_BUFFSIZE \ + 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */ +#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */ +#define PITCH_FRACS 8 +#define PITCH_FRACORDER 9 +#define PITCH_DAMPORDER 5 /* Order of high pass filter */ -#define HPORDER 2 - +#define HPORDER 2 /* PLC */ -#define DECAY_RATE 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/ -#define PLC_WAS_USED 1 -#define PLC_NOT_USED 3 -#define RECOVERY_OVERLAP 80 -#define RESAMP_RES 256 -#define RESAMP_RES_BIT 8 - - +#define DECAY_RATE \ + 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/ +#define PLC_WAS_USED 1 +#define PLC_NOT_USED 3 +#define RECOVERY_OVERLAP 80 +#define RESAMP_RES 256 +#define RESAMP_RES_BIT 8 /* Define Error codes */ /* 6000 General */ -#define ISAC_MEMORY_ALLOCATION_FAILED 6010 -#define ISAC_MODE_MISMATCH 6020 -#define ISAC_DISALLOWED_BOTTLENECK 6030 -#define ISAC_DISALLOWED_FRAME_LENGTH 6040 +#define ISAC_MEMORY_ALLOCATION_FAILED 6010 +#define ISAC_MODE_MISMATCH 6020 +#define ISAC_DISALLOWED_BOTTLENECK 6030 +#define ISAC_DISALLOWED_FRAME_LENGTH 6040 /* 6200 Bandwidth estimator */ -#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 +#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 /* 6400 Encoder */ -#define ISAC_ENCODER_NOT_INITIATED 6410 -#define ISAC_DISALLOWED_CODING_MODE 6420 -#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 -#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 -#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 +#define ISAC_ENCODER_NOT_INITIATED 6410 +#define ISAC_DISALLOWED_CODING_MODE 6420 +#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 +#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 +#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 /* 6600 Decoder */ -#define ISAC_DECODER_NOT_INITIATED 6610 -#define ISAC_EMPTY_PACKET 6620 +#define ISAC_DECODER_NOT_INITIATED 6610 +#define ISAC_EMPTY_PACKET 6620 #define ISAC_PACKET_TOO_SHORT 6625 -#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 -#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 -#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 -#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 -#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 -#define ISAC_RANGE_ERROR_DECODE_LPC 6680 -#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 -#define ISAC_LENGTH_MISMATCH 6730 +#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 +#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 +#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 +#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 +#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 +#define ISAC_RANGE_ERROR_DECODE_LPC 6680 +#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 +#define ISAC_LENGTH_MISMATCH 6730 /* 6800 Call setup formats */ -#define ISAC_INCOMPATIBLE_FORMATS 6810 - +#define ISAC_INCOMPATIBLE_FORMATS 6810 #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ */ diff --git a/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h b/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h index 04fddf52fa..4ac5c0bbe3 100644 --- a/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h +++ b/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h @@ -62,15 +62,15 @@ extern const int16_t WebRtcIsacfix_kRc6Levels[11]; /* quantization boundary levels for reflection coefficients */ extern const int16_t WebRtcIsacfix_kRcBound[12]; -/* initial indices for AR reflection coefficient quantizer and cdf table search */ +/* initial indices for AR reflection coefficient quantizer and cdf table search + */ extern const uint16_t WebRtcIsacfix_kRcInitInd[AR_ORDER]; /* pointers to AR cdf tables */ -extern const uint16_t *WebRtcIsacfix_kRcCdfPtr[AR_ORDER]; +extern const uint16_t* WebRtcIsacfix_kRcCdfPtr[AR_ORDER]; /* pointers to AR representation levels tables */ -extern const int16_t *WebRtcIsacfix_kRcLevPtr[AR_ORDER]; - +extern const int16_t* WebRtcIsacfix_kRcLevPtr[AR_ORDER]; /******************** GAIN Coefficient Tables ***********************/ /* cdf for Gain coefficient */ @@ -83,7 +83,7 @@ extern const int32_t WebRtcIsacfix_kGain2Lev[18]; extern const int32_t WebRtcIsacfix_kGain2Bound[19]; /* pointer to Gain cdf table */ -extern const uint16_t *WebRtcIsacfix_kGainPtr[1]; +extern const uint16_t* WebRtcIsacfix_kGainPtr[1]; /* Gain initial index for gain quantizer and cdf table search */ extern const uint16_t WebRtcIsacfix_kGainInitInd[1]; @@ -92,4 +92,5 @@ extern const uint16_t WebRtcIsacfix_kGainInitInd[1]; /* Cosine table */ extern const int16_t WebRtcIsacfix_kCos[6][60]; -#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */ +#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ \ + */ diff --git a/modules/audio_coding/codecs/isac/fix/source/structs.h b/modules/audio_coding/codecs/isac/fix/source/structs.h index 7a14e5c639..352eef0be0 100644 --- a/modules/audio_coding/codecs/isac/fix/source/structs.h +++ b/modules/audio_coding/codecs/isac/fix/source/structs.h @@ -18,7 +18,6 @@ #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ - #include "common_audio/signal_processing/include/signal_processing_library.h" #include "modules/audio_coding/codecs/isac/bandwidth_info.h" #include "modules/audio_coding/codecs/isac/fix/source/settings.h" @@ -26,72 +25,58 @@ /* Bitstream struct for decoder */ typedef struct Bitstreamstruct_dec { - - uint16_t stream[INTERNAL_STREAM_SIZE_W16]; /* Array bytestream to decode */ - uint32_t W_upper; /* Upper boundary of interval W */ - uint32_t streamval; - uint16_t stream_index; /* Index to the current position in bytestream */ - int16_t full; /* 0 - first byte in memory filled, second empty*/ + uint16_t stream[INTERNAL_STREAM_SIZE_W16]; /* Array bytestream to decode */ + uint32_t W_upper; /* Upper boundary of interval W */ + uint32_t streamval; + uint16_t stream_index; /* Index to the current position in bytestream */ + int16_t full; /* 0 - first byte in memory filled, second empty*/ /* 1 - both bytes are empty (we just filled the previous memory */ - size_t stream_size; /* The size of stream in bytes. */ + size_t stream_size; /* The size of stream in bytes. */ } Bitstr_dec; /* Bitstream struct for encoder */ typedef struct Bitstreamstruct_enc { - - uint16_t stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */ - uint32_t W_upper; /* Upper boundary of interval W */ - uint32_t streamval; - uint16_t stream_index; /* Index to the current position in bytestream */ - int16_t full; /* 0 - first byte in memory filled, second empty*/ + uint16_t + stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */ + uint32_t W_upper; /* Upper boundary of interval W */ + uint32_t streamval; + uint16_t stream_index; /* Index to the current position in bytestream */ + int16_t full; /* 0 - first byte in memory filled, second empty*/ /* 1 - both bytes are empty (we just filled the previous memory */ } Bitstr_enc; - typedef struct { - int16_t DataBufferLoQ0[WINLEN]; int16_t DataBufferHiQ0[WINLEN]; - int32_t CorrBufLoQQ[ORDERLO+1]; - int32_t CorrBufHiQQ[ORDERHI+1]; + int32_t CorrBufLoQQ[ORDERLO + 1]; + int32_t CorrBufHiQQ[ORDERHI + 1]; - int16_t CorrBufLoQdom[ORDERLO+1]; - int16_t CorrBufHiQdom[ORDERHI+1]; + int16_t CorrBufLoQdom[ORDERLO + 1]; + int16_t CorrBufHiQdom[ORDERHI + 1]; - int32_t PreStateLoGQ15[ORDERLO+1]; - int32_t PreStateHiGQ15[ORDERHI+1]; + int32_t PreStateLoGQ15[ORDERLO + 1]; + int32_t PreStateHiGQ15[ORDERHI + 1]; uint32_t OldEnergy; } MaskFiltstr_enc; - - typedef struct { - - int16_t PostStateLoGQ0[ORDERLO+1]; - int16_t PostStateHiGQ0[ORDERHI+1]; + int16_t PostStateLoGQ0[ORDERLO + 1]; + int16_t PostStateHiGQ0[ORDERHI + 1]; uint32_t OldEnergy; } MaskFiltstr_dec; - - - - - - - typedef struct { + // state vectors for each of the two analysis filters - //state vectors for each of the two analysis filters - - int32_t INSTAT1_fix[2*(QORDER-1)]; - int32_t INSTAT2_fix[2*(QORDER-1)]; + int32_t INSTAT1_fix[2 * (QORDER - 1)]; + int32_t INSTAT2_fix[2 * (QORDER - 1)]; int16_t INLABUF1_fix[QLOOKAHEAD]; int16_t INLABUF2_fix[QLOOKAHEAD]; @@ -100,12 +85,10 @@ typedef struct { } PreFiltBankstr; - typedef struct { - - //state vectors for each of the two analysis filters - int32_t STATE_0_LOWER_fix[2*POSTQORDER]; - int32_t STATE_0_UPPER_fix[2*POSTQORDER]; + // state vectors for each of the two analysis filters + int32_t STATE_0_LOWER_fix[2 * POSTQORDER]; + int32_t STATE_0_UPPER_fix[2 * POSTQORDER]; /* High pass filter */ @@ -115,8 +98,6 @@ typedef struct { } PostFiltBankstr; typedef struct { - - /* data buffer for pitch filter */ int16_t ubufQQ[PITCH_BUFFSIZE]; @@ -129,42 +110,35 @@ typedef struct { } PitchFiltstr; - - typedef struct { + // for inital estimator + int16_t dec_buffer16[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + PITCH_MAX_LAG / 2 - + PITCH_FRAME_LEN / 2 + 2]; + int32_t decimator_state32[2 * ALLPASSSECTIONS + 1]; + int16_t inbuf[QLOOKAHEAD]; - //for inital estimator - int16_t dec_buffer16[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2]; - int32_t decimator_state32[2*ALLPASSSECTIONS+1]; - int16_t inbuf[QLOOKAHEAD]; - - PitchFiltstr PFstr_wght; - PitchFiltstr PFstr; - + PitchFiltstr PFstr_wght; + PitchFiltstr PFstr; } PitchAnalysisStruct; - typedef struct { /* Parameters used in PLC to avoid re-computation */ /* --- residual signals --- */ - int16_t prevPitchInvIn[FRAMESAMPLES/2]; - int16_t prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90 - int32_t prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90 - + int16_t prevPitchInvIn[FRAMESAMPLES / 2]; + int16_t prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90 + int32_t prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90 int16_t decayCoeffPriodic; /* how much to supress a sample */ int16_t decayCoeffNoise; - int16_t used; /* if PLC is used */ - - - int16_t *lastPitchLP; // [FRAMESAMPLES/2]; saved 240; + int16_t used; /* if PLC is used */ + int16_t* lastPitchLP; // [FRAMESAMPLES/2]; saved 240; /* --- LPC side info --- */ - int16_t lofilt_coefQ15[ ORDERLO ]; - int16_t hifilt_coefQ15[ ORDERHI ]; + int16_t lofilt_coefQ15[ORDERLO]; + int16_t hifilt_coefQ15[ORDERHI]; int32_t gain_lo_hiQ17[2]; /* --- LTP side info --- */ @@ -173,95 +147,101 @@ typedef struct { int16_t lastPitchLag_Q7; /* --- Add-overlap in recovery packet --- */ - int16_t overlapLP[ RECOVERY_OVERLAP ]; // [FRAMESAMPLES/2]; saved 160 + int16_t overlapLP[RECOVERY_OVERLAP]; // [FRAMESAMPLES/2]; saved 160 int16_t pitchCycles; int16_t A; int16_t B; size_t pitchIndex; size_t stretchLag; - int16_t *prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240 + int16_t* prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240 int16_t seed; int16_t std; } PLCstr; - - /* Have instance of struct together with other iSAC structs */ typedef struct { - - int16_t prevFrameSizeMs; /* Previous frame size (in ms) */ - uint16_t prevRtpNumber; /* Previous RTP timestamp from received packet */ + int16_t prevFrameSizeMs; /* Previous frame size (in ms) */ + uint16_t prevRtpNumber; /* Previous RTP timestamp from received packet */ /* (in samples relative beginning) */ - uint32_t prevSendTime; /* Send time for previous packet, from RTP header */ - uint32_t prevArrivalTime; /* Arrival time for previous packet (in ms using timeGetTime()) */ - uint16_t prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in bits/s) */ - uint32_t lastUpdate; /* Time since the last update of the Bottle Neck estimate (in samples) */ - uint32_t lastReduction; /* Time sinse the last reduction (in samples) */ - int32_t countUpdates; /* How many times the estimate was update in the beginning */ + uint32_t prevSendTime; /* Send time for previous packet, from RTP header */ + uint32_t prevArrivalTime; /* Arrival time for previous packet (in ms using + timeGetTime()) */ + uint16_t + prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in + bits/s) */ + uint32_t + lastUpdate; /* Time since the last update of the Bottle Neck estimate (in + samples) */ + uint32_t lastReduction; /* Time sinse the last reduction (in samples) */ + int32_t countUpdates; /* How many times the estimate was update in the + beginning */ - /* The estimated bottle neck rate from there to here (in bits/s) */ - uint32_t recBw; - uint32_t recBwInv; - uint32_t recBwAvg; - uint32_t recBwAvgQ; + /* The estimated bottle neck rate from there to here (in bits/s) */ + uint32_t recBw; + uint32_t recBwInv; + uint32_t recBwAvg; + uint32_t recBwAvgQ; - uint32_t minBwInv; - uint32_t maxBwInv; + uint32_t minBwInv; + uint32_t maxBwInv; - /* The estimated mean absolute jitter value, as seen on this side (in ms) */ - int32_t recJitter; - int32_t recJitterShortTerm; - int32_t recJitterShortTermAbs; - int32_t recMaxDelay; - int32_t recMaxDelayAvgQ; + /* The estimated mean absolute jitter value, as seen on this side (in ms) */ + int32_t recJitter; + int32_t recJitterShortTerm; + int32_t recJitterShortTermAbs; + int32_t recMaxDelay; + int32_t recMaxDelayAvgQ; + int16_t recHeaderRate; /* (assumed) bitrate for headers (bps) */ - int16_t recHeaderRate; /* (assumed) bitrate for headers (bps) */ + uint32_t sendBwAvg; /* The estimated bottle neck rate from here to there (in + bits/s) */ + int32_t + sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on + the other siee (in ms) */ - uint32_t sendBwAvg; /* The estimated bottle neck rate from here to there (in bits/s) */ - int32_t sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on the other siee (in ms) */ - - - int16_t countRecPkts; /* number of packets received since last update */ - int16_t highSpeedRec; /* flag for marking that a high speed network has been detected downstream */ + int16_t countRecPkts; /* number of packets received since last update */ + int16_t highSpeedRec; /* flag for marking that a high speed network has been + detected downstream */ /* number of consecutive pkts sent during which the bwe estimate has - remained at a value greater than the downstream threshold for determining highspeed network */ - int16_t countHighSpeedRec; + remained at a value greater than the downstream threshold for determining + highspeed network */ + int16_t countHighSpeedRec; - /* flag indicating bwe should not adjust down immediately for very late pckts */ - int16_t inWaitPeriod; + /* flag indicating bwe should not adjust down immediately for very late pckts + */ + int16_t inWaitPeriod; /* variable holding the time of the start of a window of time when bwe should not adjust down immediately for very late pckts */ - uint32_t startWaitPeriod; + uint32_t startWaitPeriod; /* number of consecutive pkts sent during which the bwe estimate has - remained at a value greater than the upstream threshold for determining highspeed network */ - int16_t countHighSpeedSent; + remained at a value greater than the upstream threshold for determining + highspeed network */ + int16_t countHighSpeedSent; - /* flag indicated the desired number of packets over threshold rate have been sent and - bwe will assume the connection is over broadband network */ - int16_t highSpeedSend; + /* flag indicated the desired number of packets over threshold rate have been + sent and bwe will assume the connection is over broadband network */ + int16_t highSpeedSend; IsacBandwidthInfo external_bw_info; } BwEstimatorstr; - typedef struct { - /* boolean, flags if previous packet exceeded B.N. */ - int16_t PrevExceed; + int16_t PrevExceed; /* ms */ - int16_t ExceedAgo; + int16_t ExceedAgo; /* packets left to send in current burst */ - int16_t BurstCounter; + int16_t BurstCounter; /* packets */ - int16_t InitCounter; + int16_t InitCounter; /* ms remaining in buffer when next packet will be sent */ - int16_t StillBuffered; + int16_t StillBuffered; } RateModel; @@ -271,112 +251,107 @@ typedef struct { handle 60 ms of data. */ typedef struct { - /* Used to keep track of if it is first or second part of 60 msec packet */ - int startIdx; + int startIdx; /* Frame length in samples */ - int16_t framelength; + int16_t framelength; /* Pitch Gain */ - int16_t pitchGain_index[2]; + int16_t pitchGain_index[2]; /* Pitch Lag */ - int32_t meanGain[2]; - int16_t pitchIndex[PITCH_SUBFRAMES*2]; + int32_t meanGain[2]; + int16_t pitchIndex[PITCH_SUBFRAMES * 2]; /* LPC */ - int32_t LPCcoeffs_g[12*2]; /* KLT_ORDER_GAIN = 12 */ - int16_t LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */ - int16_t LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */ + int32_t LPCcoeffs_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */ + int16_t LPCindex_s[108 * 2]; /* KLT_ORDER_SHAPE = 108 */ + int16_t LPCindex_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */ /* Encode Spec */ - int16_t fre[FRAMESAMPLES]; - int16_t fim[FRAMESAMPLES]; - int16_t AvgPitchGain[2]; + int16_t fre[FRAMESAMPLES]; + int16_t fim[FRAMESAMPLES]; + int16_t AvgPitchGain[2]; /* Used in adaptive mode only */ - int minBytes; + int minBytes; } IsacSaveEncoderData; typedef struct { - - Bitstr_enc bitstr_obj; - MaskFiltstr_enc maskfiltstr_obj; - PreFiltBankstr prefiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; + Bitstr_enc bitstr_obj; + MaskFiltstr_enc maskfiltstr_obj; + PreFiltBankstr prefiltbankstr_obj; + PitchFiltstr pitchfiltstr_obj; PitchAnalysisStruct pitchanalysisstr_obj; - RateModel rate_data_obj; + RateModel rate_data_obj; - int16_t buffer_index; - int16_t current_framesamples; + int16_t buffer_index; + int16_t current_framesamples; - int16_t data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES + int16_t data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES - int16_t frame_nb; - int16_t BottleNeck; - int16_t MaxDelay; - int16_t new_framelength; - int16_t s2nr; - uint16_t MaxBits; + int16_t frame_nb; + int16_t BottleNeck; + int16_t MaxDelay; + int16_t new_framelength; + int16_t s2nr; + uint16_t MaxBits; - int16_t bitstr_seed; + int16_t bitstr_seed; #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - PostFiltBankstr interpolatorstr_obj; + PostFiltBankstr interpolatorstr_obj; #endif - IsacSaveEncoderData *SaveEnc_ptr; - int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec packet */ - int16_t payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec packet */ - int16_t maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60 msec packet */ - int16_t maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */ - int16_t enforceFrameSize; /* If set iSAC will never change packet size */ + IsacSaveEncoderData* SaveEnc_ptr; + int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec + packet */ + int16_t payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec + packet */ + int16_t maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60 + msec packet */ + int16_t maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */ + int16_t enforceFrameSize; /* If set iSAC will never change packet size */ } IsacFixEncoderInstance; - typedef struct { - - Bitstr_dec bitstr_obj; - MaskFiltstr_dec maskfiltstr_obj; - PostFiltBankstr postfiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; - PLCstr plcstr_obj; /* TS; for packet loss concealment */ + Bitstr_dec bitstr_obj; + MaskFiltstr_dec maskfiltstr_obj; + PostFiltBankstr postfiltbankstr_obj; + PitchFiltstr pitchfiltstr_obj; + PLCstr plcstr_obj; /* TS; for packet loss concealment */ #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - PreFiltBankstr decimatorstr_obj; + PreFiltBankstr decimatorstr_obj; #endif } IsacFixDecoderInstance; - - typedef struct { - IsacFixEncoderInstance ISACenc_obj; IsacFixDecoderInstance ISACdec_obj; - BwEstimatorstr bwestimator_obj; - int16_t CodingMode; /* 0 = adaptive; 1 = instantaneous */ - int16_t errorcode; - int16_t initflag; /* 0 = nothing initiated; 1 = encoder or decoder */ + BwEstimatorstr bwestimator_obj; + int16_t CodingMode; /* 0 = adaptive; 1 = instantaneous */ + int16_t errorcode; + int16_t initflag; /* 0 = nothing initiated; 1 = encoder or decoder */ /* not initiated; 2 = all initiated */ } ISACFIX_SubStruct; - typedef struct { - int32_t lpcGains[12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/ + int32_t lpcGains + [12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/ /* */ - uint32_t W_upper; /* Upper boundary of interval W */ - uint32_t streamval; - uint16_t stream_index; /* Index to the current position in bytestream */ - int16_t full; /* 0 - first byte in memory filled, second empty*/ + uint32_t W_upper; /* Upper boundary of interval W */ + uint32_t streamval; + uint16_t stream_index; /* Index to the current position in bytestream */ + int16_t full; /* 0 - first byte in memory filled, second empty*/ /* 1 - both bytes are empty (we just filled the previous memory */ - uint16_t beforeLastWord; - uint16_t lastWord; + uint16_t beforeLastWord; + uint16_t lastWord; } transcode_obj; +// Bitstr_enc myBitStr; -//Bitstr_enc myBitStr; - -#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */ +#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */ diff --git a/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc index 347b0492e9..a058530c25 100644 --- a/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc +++ b/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc @@ -12,147 +12,156 @@ #include "system_wrappers/include/cpu_features_wrapper.h" #include "test/gtest.h" -static const int kSamples = FRAMESAMPLES/2; +static const int kSamples = FRAMESAMPLES / 2; static const int32_t spec2time_out_expected_1[kSamples] = { - -3366470, -2285227, - -3415765, -2310215, -3118030, -2222470, -3030254, -2192091, -3423170, - -2216041, -3305541, -2171936, -3195767, -2095779, -3153304, -2157560, - -3071167, -2032108, -3101190, -1972016, -3103824, -2089118, -3139811, - -1898337, -3102801, -2055082, -3029665, -1854140, -2962586, -1966454, - -3071167, -1894588, -2851743, -1917315, -2848087, -1594932, -2799242, - -1462184, -2845887, -1437599, -2691776, -1329637, -2770659, -1268491, - -2625161, -1578991, -2460299, -1186385, -2365613, -1039354, -2322608, - -958518, -2271749, -789860, -2254538, -850308, -2384436, -850959, -2133734, - -587678, -2093316, -495115, -1973364, -475177, -1801282, -173507, - -1848516, -158015, -1792018, -62648, -1643313, 214746, -1500758, 267077, - -1450193, 560521, -1521579, 675283, -1345408, 857559, -1300822, 1116332, - -1294533, 1241117, -1070027, 1263503, -983816, 1529821, -1019586, - 1910421, -955420, 2073688, -836459, 2401105, -653905, 2690474, -731425, - 2930131, -935234, 3299500, -875978, 3523432, -878906, 3924822, -1081630, - 4561267, -1203023, 5105274, -1510983, 6052762, -2294646, 7021597, - -3108053, 8826736, -4935222, 11678789, -8442713, 18725700, -21526692, - 25420577, 19589811, -28108666, 12634054, -14483066, 6263217, -9979706, - 3665661, -7909736, 2531530, -6434896, 1700772, -5525393, 1479473, - -4894262, 1231760, -4353044, 1032940, -3786590, 941152, -3331614, - 665090, -2851619, 830696, -2762201, 958007, -2483118, 788233, -2184965, - 804825, -1967306, 1007255, -1862474, 920889, -1457506, 755406, -1405841, - 890230, -1302124, 1161599, -701867, 1154163, -1083366, 1204743, -513581, - 1547264, -650636, 1493384, -285543, 1771863, -277906, 1841343, -9078, - 1751863, 230222, 1819578, 207170, 1978972, 398137, 2106468, 552155, - 1997624, 685213, 2129520, 601078, 2238736, 944591, 2441879, 1194178, - 2355280, 986124, 2393328, 1049005, 2417944, 1208368, 2489516, 1352023, - 2572118, 1445283, 2856081, 1532997, 2742279, 1615877, 2915274, 1808036, - 2856871, 1806936, 3241747, 1622461, 2978558, 1841297, 3010378, 1923666, - 3271367, 2126700, 3070935, 1956958, 3107588, 2128405, 3288872, 2114911, - 3315952, 2406651, 3344038, 2370199, 3368980, 2144361, 3305030, 2183803, - 3401450, 2523102, 3405463, 2452475, 3463355, 2421678, 3551968, 2431949, - 3477251, 2148125, 3244489, 2174090}; + -3366470, -2285227, -3415765, -2310215, -3118030, -2222470, -3030254, + -2192091, -3423170, -2216041, -3305541, -2171936, -3195767, -2095779, + -3153304, -2157560, -3071167, -2032108, -3101190, -1972016, -3103824, + -2089118, -3139811, -1898337, -3102801, -2055082, -3029665, -1854140, + -2962586, -1966454, -3071167, -1894588, -2851743, -1917315, -2848087, + -1594932, -2799242, -1462184, -2845887, -1437599, -2691776, -1329637, + -2770659, -1268491, -2625161, -1578991, -2460299, -1186385, -2365613, + -1039354, -2322608, -958518, -2271749, -789860, -2254538, -850308, + -2384436, -850959, -2133734, -587678, -2093316, -495115, -1973364, + -475177, -1801282, -173507, -1848516, -158015, -1792018, -62648, + -1643313, 214746, -1500758, 267077, -1450193, 560521, -1521579, + 675283, -1345408, 857559, -1300822, 1116332, -1294533, 1241117, + -1070027, 1263503, -983816, 1529821, -1019586, 1910421, -955420, + 2073688, -836459, 2401105, -653905, 2690474, -731425, 2930131, + -935234, 3299500, -875978, 3523432, -878906, 3924822, -1081630, + 4561267, -1203023, 5105274, -1510983, 6052762, -2294646, 7021597, + -3108053, 8826736, -4935222, 11678789, -8442713, 18725700, -21526692, + 25420577, 19589811, -28108666, 12634054, -14483066, 6263217, -9979706, + 3665661, -7909736, 2531530, -6434896, 1700772, -5525393, 1479473, + -4894262, 1231760, -4353044, 1032940, -3786590, 941152, -3331614, + 665090, -2851619, 830696, -2762201, 958007, -2483118, 788233, + -2184965, 804825, -1967306, 1007255, -1862474, 920889, -1457506, + 755406, -1405841, 890230, -1302124, 1161599, -701867, 1154163, + -1083366, 1204743, -513581, 1547264, -650636, 1493384, -285543, + 1771863, -277906, 1841343, -9078, 1751863, 230222, 1819578, + 207170, 1978972, 398137, 2106468, 552155, 1997624, 685213, + 2129520, 601078, 2238736, 944591, 2441879, 1194178, 2355280, + 986124, 2393328, 1049005, 2417944, 1208368, 2489516, 1352023, + 2572118, 1445283, 2856081, 1532997, 2742279, 1615877, 2915274, + 1808036, 2856871, 1806936, 3241747, 1622461, 2978558, 1841297, + 3010378, 1923666, 3271367, 2126700, 3070935, 1956958, 3107588, + 2128405, 3288872, 2114911, 3315952, 2406651, 3344038, 2370199, + 3368980, 2144361, 3305030, 2183803, 3401450, 2523102, 3405463, + 2452475, 3463355, 2421678, 3551968, 2431949, 3477251, 2148125, + 3244489, 2174090}; static const int32_t spec2time_out_expected_2[kSamples] = { - 1691694, -2499988, -2035547, - 1060469, 988634, -2044502, -306271, 2041000, 201454, -2289456, 93694, - 2129427, -369152, -1887834, 860796, 2089102, -929424, -1673956, 1395291, - 1785651, -1619673, -1380109, 1963449, 1093311, -2111007, -840456, - 2372786, 578119, -2242702, 89774, 2463304, -132717, -2121480, 643634, - 2277636, -1125999, -1995858, 1543748, 2227861, -1483779, -1495491, - 2102642, 1833876, -1920568, -958378, 2485101, 772261, -2454257, -24942, - 2918714, 136838, -2500453, 816118, 3039735, -746560, -2365815, 1586396, - 2714951, -1511696, -1942334, 2571792, 2182827, -2325335, -1311543, - 3055970, 1367220, -2737182, -110626, 3889222, 631008, -3280879, 853066, - 4122279, -706638, -3334449, 2148311, 3993512, -1846301, -3004894, - 3426779, 3329522, -3165264, -2242423, 4756866, 2557711, -4131280, - -805259, 5702711, 1120592, -4852821, 743664, 6476444, -621186, -5465828, - 2815787, 6768835, -3017442, -5338409, 5658126, 6838454, -5492288, - -4682382, 8874947, 6153814, -8832561, -2649251, 12817398, 4237692, - -13000247, 1190661, 18986363, -115738, -19693978, 9908367, 30660381, - -10632635, -37962068, 47022884, 89744622, -42087632, 40279224, - -88869341, -47542383, 38572364, 10441576, -30339718, -9926740, 19896578, - 28009, -18886612, -1124047, 13232498, -4150304, -12770551, 2637074, - 9051831, -6162211, -8713972, 4557937, 5489716, -6862312, -5532349, - 5415449, 2791310, -6999367, -2790102, 5375806, 546222, -6486452, - -821261, 4994973, -1278840, -5645501, 1060484, 3996285, -2503954, - -4653629, 2220549, 3036977, -3282133, -3318585, 2780636, 1789880, - -4004589, -2041031, 3105373, 574819, -3992722, -971004, 3001703, - -676739, -3841508, 417284, 2897970, -1427018, -3058480, 1189948, - 2210960, -2268992, -2603272, 1949785, 1576172, -2720404, -1891738, - 2309456, 769178, -2975646, -707150, 2424652, -88039, -2966660, -65452, - 2320780, -957557, -2798978, 744640, 1879794, -1672081, -2365319, - 1253309, 1366383, -2204082, -1544367, 1801452, 613828, -2531994, - -983847, 2064842, 118326, -2613790, -203220, 2219635, -730341, -2641861, - 563557, 1765434, -1329916, -2272927, 1037138, 1266725, -1939220, - -1588643, 1754528, 816552, -2376303, -1099167, 1864999, 122477, - -2422762, -400027, 1889228, -579916, -2490353, 287139, 2011318, - -1176657, -2502978, 812896, 1116502, -1940211}; + 1691694, -2499988, -2035547, 1060469, 988634, -2044502, -306271, + 2041000, 201454, -2289456, 93694, 2129427, -369152, -1887834, + 860796, 2089102, -929424, -1673956, 1395291, 1785651, -1619673, + -1380109, 1963449, 1093311, -2111007, -840456, 2372786, 578119, + -2242702, 89774, 2463304, -132717, -2121480, 643634, 2277636, + -1125999, -1995858, 1543748, 2227861, -1483779, -1495491, 2102642, + 1833876, -1920568, -958378, 2485101, 772261, -2454257, -24942, + 2918714, 136838, -2500453, 816118, 3039735, -746560, -2365815, + 1586396, 2714951, -1511696, -1942334, 2571792, 2182827, -2325335, + -1311543, 3055970, 1367220, -2737182, -110626, 3889222, 631008, + -3280879, 853066, 4122279, -706638, -3334449, 2148311, 3993512, + -1846301, -3004894, 3426779, 3329522, -3165264, -2242423, 4756866, + 2557711, -4131280, -805259, 5702711, 1120592, -4852821, 743664, + 6476444, -621186, -5465828, 2815787, 6768835, -3017442, -5338409, + 5658126, 6838454, -5492288, -4682382, 8874947, 6153814, -8832561, + -2649251, 12817398, 4237692, -13000247, 1190661, 18986363, -115738, + -19693978, 9908367, 30660381, -10632635, -37962068, 47022884, 89744622, + -42087632, 40279224, -88869341, -47542383, 38572364, 10441576, -30339718, + -9926740, 19896578, 28009, -18886612, -1124047, 13232498, -4150304, + -12770551, 2637074, 9051831, -6162211, -8713972, 4557937, 5489716, + -6862312, -5532349, 5415449, 2791310, -6999367, -2790102, 5375806, + 546222, -6486452, -821261, 4994973, -1278840, -5645501, 1060484, + 3996285, -2503954, -4653629, 2220549, 3036977, -3282133, -3318585, + 2780636, 1789880, -4004589, -2041031, 3105373, 574819, -3992722, + -971004, 3001703, -676739, -3841508, 417284, 2897970, -1427018, + -3058480, 1189948, 2210960, -2268992, -2603272, 1949785, 1576172, + -2720404, -1891738, 2309456, 769178, -2975646, -707150, 2424652, + -88039, -2966660, -65452, 2320780, -957557, -2798978, 744640, + 1879794, -1672081, -2365319, 1253309, 1366383, -2204082, -1544367, + 1801452, 613828, -2531994, -983847, 2064842, 118326, -2613790, + -203220, 2219635, -730341, -2641861, 563557, 1765434, -1329916, + -2272927, 1037138, 1266725, -1939220, -1588643, 1754528, 816552, + -2376303, -1099167, 1864999, 122477, -2422762, -400027, 1889228, + -579916, -2490353, 287139, 2011318, -1176657, -2502978, 812896, + 1116502, -1940211}; static const int16_t time2spec_out_expected_1[kSamples] = { - 20342, 23889, -10063, -9419, - 3242, 7280, -2012, -5029, 332, 4478, -97, -3244, -891, 3117, 773, -2204, - -1335, 2009, 1236, -1469, -1562, 1277, 1366, -815, -1619, 599, 1449, -177, - -1507, 116, 1294, 263, -1338, -244, 1059, 553, -1045, -549, 829, 826, - -731, -755, 516, 909, -427, -853, 189, 1004, -184, -828, -108, 888, 72, - -700, -280, 717, 342, -611, -534, 601, 534, -374, -646, 399, 567, -171, - -720, 234, 645, -11, -712, -26, 593, 215, -643, -172, 536, 361, -527, - -403, 388, 550, -361, -480, 208, 623, -206, -585, 41, 578, 12, -504, - -182, 583, 218, -437, -339, 499, 263, -354, -450, 347, 456, -193, -524, - 212, 475, -74, -566, 94, 511, 112, -577, -201, 408, 217, -546, -295, 338, - 387, -13, 4, -46, 2, -76, 103, -83, 108, -55, 100, -150, 131, -156, 141, - -171, 179, -190, 128, -227, 172, -214, 215, -189, 265, -244, 322, -335, - 337, -352, 358, -368, 362, -355, 366, -381, 403, -395, 411, -392, 446, - -458, 504, -449, 507, -464, 452, -491, 481, -534, 486, -516, 560, -535, - 525, -537, 559, -554, 570, -616, 591, -585, 627, -509, 588, -584, 547, - -610, 580, -614, 635, -620, 655, -554, 546, -591, 642, -590, 660, -656, - 629, -604, 620, -580, 617, -645, 648, -573, 612, -604, 584, -571, 597, - -562, 627, -550, 560, -606, 529, -584, 568, -503, 532, -463, 512, -440, - 399, -457, 437, -349, 278, -317, 257, -220, 163, -8, -61, 18, -161, 367, - -1306}; + 20342, 23889, -10063, -9419, 3242, 7280, -2012, -5029, 332, 4478, + -97, -3244, -891, 3117, 773, -2204, -1335, 2009, 1236, -1469, + -1562, 1277, 1366, -815, -1619, 599, 1449, -177, -1507, 116, + 1294, 263, -1338, -244, 1059, 553, -1045, -549, 829, 826, + -731, -755, 516, 909, -427, -853, 189, 1004, -184, -828, + -108, 888, 72, -700, -280, 717, 342, -611, -534, 601, + 534, -374, -646, 399, 567, -171, -720, 234, 645, -11, + -712, -26, 593, 215, -643, -172, 536, 361, -527, -403, + 388, 550, -361, -480, 208, 623, -206, -585, 41, 578, + 12, -504, -182, 583, 218, -437, -339, 499, 263, -354, + -450, 347, 456, -193, -524, 212, 475, -74, -566, 94, + 511, 112, -577, -201, 408, 217, -546, -295, 338, 387, + -13, 4, -46, 2, -76, 103, -83, 108, -55, 100, + -150, 131, -156, 141, -171, 179, -190, 128, -227, 172, + -214, 215, -189, 265, -244, 322, -335, 337, -352, 358, + -368, 362, -355, 366, -381, 403, -395, 411, -392, 446, + -458, 504, -449, 507, -464, 452, -491, 481, -534, 486, + -516, 560, -535, 525, -537, 559, -554, 570, -616, 591, + -585, 627, -509, 588, -584, 547, -610, 580, -614, 635, + -620, 655, -554, 546, -591, 642, -590, 660, -656, 629, + -604, 620, -580, 617, -645, 648, -573, 612, -604, 584, + -571, 597, -562, 627, -550, 560, -606, 529, -584, 568, + -503, 532, -463, 512, -440, 399, -457, 437, -349, 278, + -317, 257, -220, 163, -8, -61, 18, -161, 367, -1306}; static const int16_t time2spec_out_expected_2[kSamples] = { - 14283, -11552, -15335, 6626, - 7554, -2150, -6309, 1307, 4523, -4, -3908, -314, 3001, 914, -2715, -1042, - 2094, 1272, -1715, -1399, 1263, 1508, -1021, -1534, 735, 1595, -439, -1447, - 155, 1433, 22, -1325, -268, 1205, 424, -1030, -608, 950, 643, -733, -787, - 661, 861, -502, -888, 331, 852, -144, -849, 19, 833, 99, -826, -154, - 771, 368, -735, -459, 645, 513, -491, -604, 431, 630, -314, -598, 183, - 622, -78, -612, -48, 641, 154, -645, -257, 610, 281, -529, -444, 450, - 441, -327, -506, 274, 476, -232, -570, 117, 554, -86, -531, -21, 572, - 151, -606, -221, 496, 322, -407, -388, 407, 394, -268, -428, 280, 505, - -115, -588, 19, 513, -29, -539, -109, 468, 173, -501, -242, 442, 278, - -478, -680, 656, -659, 656, -669, 602, -688, 612, -667, 612, -642, 627, - -648, 653, -676, 596, -680, 655, -649, 678, -672, 587, -608, 637, -645, - 637, -620, 556, -580, 553, -635, 518, -599, 583, -501, 536, -544, 473, - -552, 583, -511, 541, -532, 563, -486, 461, -453, 486, -388, 424, -416, - 432, -374, 399, -462, 364, -346, 293, -329, 331, -313, 281, -247, 309, - -337, 241, -190, 207, -194, 179, -163, 155, -156, 117, -135, 107, -126, - 29, -22, 81, -8, 17, -61, -10, 8, -37, 80, -44, 72, -88, 65, -89, 130, - -114, 181, -215, 189, -245, 260, -288, 294, -339, 344, -396, 407, -429, - 438, -439, 485, -556, 629, -612, 637, -645, 661, -737, 829, -830, 831, - -1041}; + 14283, -11552, -15335, 6626, 7554, -2150, -6309, 1307, 4523, -4, + -3908, -314, 3001, 914, -2715, -1042, 2094, 1272, -1715, -1399, + 1263, 1508, -1021, -1534, 735, 1595, -439, -1447, 155, 1433, + 22, -1325, -268, 1205, 424, -1030, -608, 950, 643, -733, + -787, 661, 861, -502, -888, 331, 852, -144, -849, 19, + 833, 99, -826, -154, 771, 368, -735, -459, 645, 513, + -491, -604, 431, 630, -314, -598, 183, 622, -78, -612, + -48, 641, 154, -645, -257, 610, 281, -529, -444, 450, + 441, -327, -506, 274, 476, -232, -570, 117, 554, -86, + -531, -21, 572, 151, -606, -221, 496, 322, -407, -388, + 407, 394, -268, -428, 280, 505, -115, -588, 19, 513, + -29, -539, -109, 468, 173, -501, -242, 442, 278, -478, + -680, 656, -659, 656, -669, 602, -688, 612, -667, 612, + -642, 627, -648, 653, -676, 596, -680, 655, -649, 678, + -672, 587, -608, 637, -645, 637, -620, 556, -580, 553, + -635, 518, -599, 583, -501, 536, -544, 473, -552, 583, + -511, 541, -532, 563, -486, 461, -453, 486, -388, 424, + -416, 432, -374, 399, -462, 364, -346, 293, -329, 331, + -313, 281, -247, 309, -337, 241, -190, 207, -194, 179, + -163, 155, -156, 117, -135, 107, -126, 29, -22, 81, + -8, 17, -61, -10, 8, -37, 80, -44, 72, -88, + 65, -89, 130, -114, 181, -215, 189, -245, 260, -288, + 294, -339, 344, -396, 407, -429, 438, -439, 485, -556, + 629, -612, 637, -645, 661, -737, 829, -830, 831, -1041}; class TransformTest : public testing::Test { protected: - TransformTest() { - WebRtcSpl_Init(); - } + TransformTest() { WebRtcSpl_Init(); } - // Pass a function pointer to the Tester function. - void Time2SpecTester(Time2Spec Time2SpecFunction) { - // WebRtcIsacfix_Time2Spec functions hard coded the buffer lengths. It's a - // large buffer but we have to test it here. - int16_t data_in_1[kSamples] = {0}; - int16_t data_in_2[kSamples] = {0}; - int16_t data_out_1[kSamples] = {0}; - int16_t data_out_2[kSamples] = {0}; + // Pass a function pointer to the Tester function. + void Time2SpecTester(Time2Spec Time2SpecFunction) { + // WebRtcIsacfix_Time2Spec functions hard coded the buffer lengths. It's a + // large buffer but we have to test it here. + int16_t data_in_1[kSamples] = {0}; + int16_t data_in_2[kSamples] = {0}; + int16_t data_out_1[kSamples] = {0}; + int16_t data_out_2[kSamples] = {0}; - for(int i = 0; i < kSamples; i++) { - data_in_1[i] = i * i + 1777; - data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17; - } + for (int i = 0; i < kSamples; i++) { + data_in_1[i] = i * i + 1777; + data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17; + } - Time2SpecFunction(data_in_1, data_in_2, data_out_1, data_out_2); + Time2SpecFunction(data_in_1, data_in_2, data_out_1, data_out_2); - for (int i = 0; i < kSamples; i++) { - // We don't require bit-exact for ARM assembly code. - EXPECT_LE(abs(time2spec_out_expected_1[i] - data_out_1[i]), 1); - EXPECT_LE(abs(time2spec_out_expected_2[i] - data_out_2[i]), 1); - } - } + for (int i = 0; i < kSamples; i++) { + // We don't require bit-exact for ARM assembly code. + EXPECT_LE(abs(time2spec_out_expected_1[i] - data_out_1[i]), 1); + EXPECT_LE(abs(time2spec_out_expected_2[i] - data_out_2[i]), 1); + } + } // Pass a function pointer to the Tester function. void Spec2TimeTester(Spec2Time Spec2TimeFunction) { @@ -162,7 +171,7 @@ class TransformTest : public testing::Test { int16_t data_in_2[kSamples] = {0}; int32_t data_out_1[kSamples] = {0}; int32_t data_out_2[kSamples] = {0}; - for(int i = 0; i < kSamples; i++) { + for (int i = 0; i < kSamples; i++) { data_in_1[i] = i * i + 1777; data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17; } @@ -175,7 +184,6 @@ class TransformTest : public testing::Test { EXPECT_LE(abs(spec2time_out_expected_2[i] - data_out_2[i]), 16); } } - }; TEST_F(TransformTest, Time2SpecTest) { diff --git a/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc b/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc index fc779d8185..aeca2e8e31 100644 --- a/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc +++ b/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc @@ -25,19 +25,21 @@ class IsacSpeedTest : public AudioCodecSpeedTest { IsacSpeedTest(); void SetUp() override; void TearDown() override; - float EncodeABlock(int16_t* in_data, uint8_t* bit_stream, - size_t max_bytes, size_t* encoded_bytes) override; - float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes, + float EncodeABlock(int16_t* in_data, + uint8_t* bit_stream, + size_t max_bytes, + size_t* encoded_bytes) override; + float DecodeABlock(const uint8_t* bit_stream, + size_t encoded_bytes, int16_t* out_data) override; - ISACFIX_MainStruct *ISACFIX_main_inst_; + ISACFIX_MainStruct* ISACFIX_main_inst_; }; IsacSpeedTest::IsacSpeedTest() : AudioCodecSpeedTest(kIsacBlockDurationMs, kIsacInputSamplingKhz, kIsacOutputSamplingKhz), - ISACFIX_main_inst_(NULL) { -} + ISACFIX_main_inst_(NULL) {} void IsacSpeedTest::SetUp() { AudioCodecSpeedTest::SetUp(); @@ -60,8 +62,10 @@ void IsacSpeedTest::TearDown() { EXPECT_EQ(0, WebRtcIsacfix_Free(ISACFIX_main_inst_)); } -float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, - size_t max_bytes, size_t* encoded_bytes) { +float IsacSpeedTest::EncodeABlock(int16_t* in_data, + uint8_t* bit_stream, + size_t max_bytes, + size_t* encoded_bytes) { // ISAC takes 10 ms everycall const int subblocks = block_duration_ms_ / 10; const int subblock_length = 10 * input_sampling_khz_; @@ -70,8 +74,8 @@ float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, clock_t clocks = clock(); size_t pointer = 0; for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) { - value = WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer], - bit_stream); + value = + WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer], bit_stream); if (idx == subblocks - 1) EXPECT_GT(value, 0); else @@ -108,7 +112,6 @@ const coding_param param_set[] = { string("pcm"), true)}; -INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest, - ::testing::ValuesIn(param_set)); +INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest, ::testing::ValuesIn(param_set)); } // namespace webrtc diff --git a/modules/audio_coding/codecs/isac/fix/test/kenny.cc b/modules/audio_coding/codecs/isac/fix/test/kenny.cc index 4251627d78..fb64a2b597 100644 --- a/modules/audio_coding/codecs/isac/fix/test/kenny.cc +++ b/modules/audio_coding/codecs/isac/fix/test/kenny.cc @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include #include #include #include -#include #include "modules/audio_coding/codecs/isac/fix/include/isacfix.h" #include "test/gtest.h" @@ -22,14 +22,16 @@ // separate encoder and decoder. /* Defines */ -#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */ -#define MAX_FRAMESAMPLES 960 /* max number of samples per frame (= 60 ms frame) */ -#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */ -#define FS 16000 /* sampling frequency (Hz) */ +#define SEED_FILE \ + "randseed.txt" /* Used when running decoder on garbage data \ + */ +#define MAX_FRAMESAMPLES \ + 960 /* max number of samples per frame (= 60 ms frame) */ +#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */ +#define FS 16000 /* sampling frequency (Hz) */ /* Function for reading audio data from PCM file */ -int readframe(int16_t *data, FILE *inp, int length) { - +int readframe(int16_t* data, FILE* inp, int length) { short k, rlen, status = 0; rlen = fread(data, sizeof(int16_t), length, inp); @@ -45,25 +47,24 @@ int readframe(int16_t *data, FILE *inp, int length) { // Globals needed because gtest does not provide access to argv. // This should be reworked to use flags. static int global_argc; -static char **global_argv; +static char** global_argv; /* Struct for bottleneck model */ typedef struct { - uint32_t send_time; /* samples */ - uint32_t arrival_time; /* samples */ - uint32_t sample_count; /* samples */ + uint32_t send_time; /* samples */ + uint32_t arrival_time; /* samples */ + uint32_t sample_count; /* samples */ uint16_t rtp_number; } BottleNeckModel; -void get_arrival_time(int current_framesamples, /* samples */ - size_t packet_size, /* bytes */ - int bottleneck, /* excluding headers; bits/s */ - BottleNeckModel *BN_data) -{ +void get_arrival_time(int current_framesamples, /* samples */ + size_t packet_size, /* bytes */ + int bottleneck, /* excluding headers; bits/s */ + BottleNeckModel* BN_data) { const int HeaderSize = 35; int HeaderRate; - HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */ + HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */ /* everything in samples */ BN_data->sample_count = BN_data->sample_count + current_framesamples; @@ -80,29 +81,27 @@ void get_arrival_time(int current_framesamples, /* samples */ void get_arrival_time2(int current_framesamples, int current_delay, - BottleNeckModel *BN_data) -{ + BottleNeckModel* BN_data) { if (current_delay == -1) - //dropped packet + // dropped packet { BN_data->arrival_time += current_framesamples; - } - else if (current_delay != -2) - { + } else if (current_delay != -2) { // - BN_data->arrival_time += (current_framesamples + ((FS/1000) * current_delay)); + BN_data->arrival_time += + (current_framesamples + ((FS / 1000) * current_delay)); } - //else - //current packet has same timestamp as previous packet + // else + // current packet has same timestamp as previous packet BN_data->rtp_number++; } TEST(IsacFixTest, Kenny) { int argc = global_argc; - char **argv = global_argv; + char** argv = global_argv; - char inname[100], outname[100], outbitsname[100], bottleneck_file[100]; + char inname[100], outname[100], outbitsname[100], bottleneck_file[100]; FILE *inp, *outp, *f_bn, *outbits; int endfile; @@ -112,7 +111,7 @@ TEST(IsacFixTest, Kenny) { int errtype, h = 0, k, packetLossPercent = 0; int16_t CodingMode; int16_t bottleneck; - int framesize = 30; /* ms */ + int framesize = 30; /* ms */ int cur_framesmpls, err = 0, lostPackets = 0; /* Runtime statistics */ @@ -133,16 +132,16 @@ TEST(IsacFixTest, Kenny) { int32_t payloadRate = 0; int setControlBWE = 0; int readLoss; - FILE *plFile = NULL; + FILE* plFile = NULL; char version_number[20]; char tmpBit[5] = ".bit"; - int totalbits =0; - int totalsmpls =0; + int totalbits = 0; + int totalsmpls = 0; int16_t testNum, testCE; - FILE *fp_gns = NULL; + FILE* fp_gns = NULL; int gns = 0; int cur_delay = 0; char gns_file[100]; @@ -151,20 +150,20 @@ TEST(IsacFixTest, Kenny) { int16_t lostFrame; float scale = (float)0.7; /* only one structure used for ISAC encoder */ - ISACFIX_MainStruct *ISAC_main_inst = NULL; + ISACFIX_MainStruct* ISAC_main_inst = NULL; /* For fault test 10, garbage data */ - FILE *seedfile; - unsigned int random_seed = (unsigned int) time(NULL);//1196764538 + FILE* seedfile; + unsigned int random_seed = (unsigned int)time(NULL); // 1196764538 - BottleNeckModel BN_data; - f_bn = NULL; + BottleNeckModel BN_data; + f_bn = NULL; readLoss = 0; packetLossPercent = 0; /* Handling wrong input arguments in the command line */ - if ((argc<3) || (argc>22)) { + if ((argc < 3) || (argc > 22)) { printf("\n\nWrong number of arguments or flag values.\n\n"); printf("\n"); @@ -182,61 +181,75 @@ TEST(IsacFixTest, Kenny) { printf(" read from a file (e.g. bottleneck.txt)\n\n"); printf("infile :Normal speech input file\n\n"); printf("outfile :Speech output file\n\n"); - printf("[-INITRATE num] :Set a new value for initial rate. Note! Only used" - " in adaptive mode.\n\n"); - printf("[-FL num] :Set (initial) frame length in msec. Valid length" - " are 30 and 60 msec.\n\n"); + printf( + "[-INITRATE num] :Set a new value for initial rate. Note! Only used" + " in adaptive mode.\n\n"); + printf( + "[-FL num] :Set (initial) frame length in msec. Valid length" + " are 30 and 60 msec.\n\n"); printf("[-FIXED_FL] :Frame length to be fixed to initial value.\n\n"); - printf("[-MAX num] :Set the limit for the payload size of iSAC" - " in bytes. \n"); + printf( + "[-MAX num] :Set the limit for the payload size of iSAC" + " in bytes. \n"); printf(" Minimum 100, maximum 400.\n\n"); printf("[-MAXRATE num] :Set the maxrate for iSAC in bits per second. \n"); printf(" Minimum 32000, maximum 53400.\n\n"); printf("[-F num] :if -F option is specified, the test function\n"); - printf(" will run the iSAC API fault scenario specified" - " by the\n"); + printf( + " will run the iSAC API fault scenario specified" + " by the\n"); printf(" supplied number.\n"); printf(" F 1 - Call encoder prior to init encoder call\n"); printf(" F 2 - Call decoder prior to init decoder call\n"); printf(" F 3 - Call decoder prior to encoder call\n"); - printf(" F 4 - Call decoder with a too short coded" - " sequence\n"); - printf(" F 5 - Call decoder with a too long coded" - " sequence\n"); + printf( + " F 4 - Call decoder with a too short coded" + " sequence\n"); + printf( + " F 5 - Call decoder with a too long coded" + " sequence\n"); printf(" F 6 - Call decoder with random bit stream\n"); - printf(" F 7 - Call init encoder/decoder at random" - " during a call\n"); - printf(" F 8 - Call encoder/decoder without having" - " allocated memory for \n"); + printf( + " F 7 - Call init encoder/decoder at random" + " during a call\n"); + printf( + " F 8 - Call encoder/decoder without having" + " allocated memory for \n"); printf(" encoder/decoder instance\n"); printf(" F 9 - Call decodeB without calling decodeA\n"); printf(" F 10 - Call decodeB with garbage data\n"); - printf("[-PL num] :if -PL option is specified 0 encode with narrowband encoder" - " (infile is narrowband)\n"); - printf(" num=2 => decode with narrowband decoder" - " (outfile is narrowband)\n\n"); + printf( + " num=1 => encode with narrowband encoder" + " (infile is narrowband)\n"); + printf( + " num=2 => decode with narrowband decoder" + " (outfile is narrowband)\n\n"); printf("[-CE num] :Test of APIs used by Conference Engine.\n"); - printf(" CE 1 - createInternal, freeInternal," - " getNewBitstream \n"); + printf( + " CE 1 - createInternal, freeInternal," + " getNewBitstream \n"); printf(" CE 2 - transcode, getBWE \n"); printf(" CE 3 - getSendBWE, setSendBWE. \n\n"); - printf("[-RTP_INIT num] :if -RTP_INIT option is specified num will be" - " the initial\n"); + printf( + "[-RTP_INIT num] :if -RTP_INIT option is specified num will be" + " the initial\n"); printf(" value of the rtp sequence number.\n\n"); printf("[--isolated-script-test-perf-output=file]\n"); - printf(" :If this option is specified, perf values will be" - " written to this file in a JSON format.\n\n"); + printf( + " :If this option is specified, perf values will be" + " written to this file in a JSON format.\n\n"); printf("Example usage :\n\n"); printf("%s -I bottleneck.txt speechIn.pcm speechOut.pcm\n\n", argv[0]); exit(1); - } /* Print version number */ @@ -250,7 +263,7 @@ TEST(IsacFixTest, Kenny) { i = 1; /* Instantaneous mode */ - if (!strcmp ("-I", argv[i])) { + if (!strcmp("-I", argv[i])) { printf("\nInstantaneous BottleNeck\n"); CodingMode = 1; i++; @@ -265,7 +278,7 @@ TEST(IsacFixTest, Kenny) { for (; i < argc; i++) { /* Set (initial) bottleneck value */ - if (!strcmp ("-INITRATE", argv[i])) { + if (!strcmp("-INITRATE", argv[i])) { if (i + 1 >= argc) { printf("-INITRATE requires a parameter.\n"); exit(1); @@ -273,8 +286,10 @@ TEST(IsacFixTest, Kenny) { rateBPS = atoi(argv[i + 1]); setControlBWE = 1; if ((rateBPS < 10000) || (rateBPS > 32000)) { - printf("\n%d is not a initial rate. " - "Valid values are in the range 10000 to 32000.\n", rateBPS); + printf( + "\n%d is not a initial rate. " + "Valid values are in the range 10000 to 32000.\n", + rateBPS); exit(1); } printf("\nNew initial rate: %d\n", rateBPS); @@ -282,15 +297,17 @@ TEST(IsacFixTest, Kenny) { } /* Set (initial) framelength */ - if (!strcmp ("-FL", argv[i])) { + if (!strcmp("-FL", argv[i])) { if (i + 1 >= argc) { printf("-FL requires a parameter.\n"); exit(1); } framesize = atoi(argv[i + 1]); if ((framesize != 30) && (framesize != 60)) { - printf("\n%d is not a valid frame length. " - "Valid length are 30 and 60 msec.\n", framesize); + printf( + "\n%d is not a valid frame length. " + "Valid length are 30 and 60 msec.\n", + framesize); exit(1); } printf("\nFrame Length: %d\n", framesize); @@ -298,13 +315,13 @@ TEST(IsacFixTest, Kenny) { } /* Fixed frame length */ - if (!strcmp ("-FIXED_FL", argv[i])) { + if (!strcmp("-FIXED_FL", argv[i])) { fixedFL = 1; setControlBWE = 1; } /* Set maximum allowed payload size in bytes */ - if (!strcmp ("-MAX", argv[i])) { + if (!strcmp("-MAX", argv[i])) { if (i + 1 >= argc) { printf("-MAX requires a parameter.\n"); exit(1); @@ -315,7 +332,7 @@ TEST(IsacFixTest, Kenny) { } /* Set maximum rate in bytes */ - if (!strcmp ("-MAXRATE", argv[i])) { + if (!strcmp("-MAXRATE", argv[i])) { if (i + 1 >= argc) { printf("-MAXRATE requires a parameter.\n"); exit(1); @@ -326,7 +343,7 @@ TEST(IsacFixTest, Kenny) { } /* Test of fault scenarious */ - if (!strcmp ("-F", argv[i])) { + if (!strcmp("-F", argv[i])) { if (i + 1 >= argc) { printf("-F requires a parameter."); exit(1); @@ -334,59 +351,63 @@ TEST(IsacFixTest, Kenny) { testNum = atoi(argv[i + 1]); printf("\nFault test: %d\n", testNum); if (testNum < 1 || testNum > 10) { - printf("\n%d is not a valid Fault Scenario number." - " Valid Fault Scenarios are numbered 1-10.\n", testNum); + printf( + "\n%d is not a valid Fault Scenario number." + " Valid Fault Scenarios are numbered 1-10.\n", + testNum); exit(1); } i++; } /* Packet loss test */ - if (!strcmp ("-PL", argv[i])) { + if (!strcmp("-PL", argv[i])) { if (i + 1 >= argc) { printf("-PL requires a parameter.\n"); exit(1); } - if( isdigit( *argv[i+1] ) ) { - packetLossPercent = atoi( argv[i+1] ); - if( (packetLossPercent < 0) | (packetLossPercent > 100) ) { - printf( "\nInvalid packet loss perentage \n" ); - exit( 1 ); + if (isdigit(*argv[i + 1])) { + packetLossPercent = atoi(argv[i + 1]); + if ((packetLossPercent < 0) | (packetLossPercent > 100)) { + printf("\nInvalid packet loss perentage \n"); + exit(1); } - if( packetLossPercent > 0 ) { - printf( "\nSimulating %d %% of independent packet loss\n", - packetLossPercent ); + if (packetLossPercent > 0) { + printf("\nSimulating %d %% of independent packet loss\n", + packetLossPercent); } else { - printf( "\nNo Packet Loss Is Simulated \n" ); + printf("\nNo Packet Loss Is Simulated \n"); } readLoss = 0; } else { readLoss = 1; - plFile = fopen( argv[i+1], "rb" ); - if( plFile == NULL ) { - FAIL() << "Couldn't open the frameloss file: " << argv[i+1]; + plFile = fopen(argv[i + 1], "rb"); + if (plFile == NULL) { + FAIL() << "Couldn't open the frameloss file: " << argv[i + 1]; } - printf( "\nSimulating packet loss through the given " - "channel file: %s\n", argv[i+1] ); + printf( + "\nSimulating packet loss through the given " + "channel file: %s\n", + argv[i + 1]); } i++; } /* Random packetlosses */ - if (!strcmp ("-rnd", argv[i])) { - srand(time(NULL) ); - printf( "\n Random pattern in lossed packets \n" ); + if (!strcmp("-rnd", argv[i])) { + srand(time(NULL)); + printf("\n Random pattern in lossed packets \n"); } /* Use gns file */ - if (!strcmp ("-G", argv[i])) { + if (!strcmp("-G", argv[i])) { if (i + 1 >= argc) { printf("-G requires a parameter.\n"); exit(1); } sscanf(argv[i + 1], "%s", gns_file); fp_gns = fopen(gns_file, "rb"); - if (fp_gns == NULL) { + if (fp_gns == NULL) { FAIL() << "Cannot read file " << gns_file << "."; } gns = 1; @@ -394,7 +415,7 @@ TEST(IsacFixTest, Kenny) { } /* Run Narrowband interfaces (either encoder or decoder) */ - if (!strcmp ("-NB", argv[i])) { + if (!strcmp("-NB", argv[i])) { if (i + 1 >= argc) { printf("-NB requires a parameter.\n"); exit(1); @@ -404,25 +425,27 @@ TEST(IsacFixTest, Kenny) { } /* Run Conference Engine APIs */ - if (!strcmp ("-CE", argv[i])) { + if (!strcmp("-CE", argv[i])) { if (i + 1 >= argc) { printf("-CE requires a parameter.\n"); exit(1); } testCE = atoi(argv[i + 1]); - if (testCE==1 || testCE==2) { + if (testCE == 1 || testCE == 2) { i++; - scale = (float)atof( argv[i+1] ); + scale = (float)atof(argv[i + 1]); } else if (testCE < 1 || testCE > 3) { - printf("\n%d is not a valid CE-test number, valid Fault " - "Scenarios are numbered 1-3\n", testCE); + printf( + "\n%d is not a valid CE-test number, valid Fault " + "Scenarios are numbered 1-3\n", + testCE); exit(1); } i++; } /* Set initial RTP number */ - if (!strcmp ("-RTP_INIT", argv[i])) { + if (!strcmp("-RTP_INIT", argv[i])) { if (i + 1 >= argc) { printf("-RTP_INIT requires a parameter.\n"); exit(1); @@ -442,16 +465,16 @@ TEST(IsacFixTest, Kenny) { /* Get Bottleneck value */ /* Gns files and bottleneck should not and can not be used simultaneously */ - bottleneck = atoi(argv[CodingMode+1]); + bottleneck = atoi(argv[CodingMode + 1]); if (bottleneck == 0 && gns == 0) { - sscanf(argv[CodingMode+1], "%s", bottleneck_file); + sscanf(argv[CodingMode + 1], "%s", bottleneck_file); f_bn = fopen(bottleneck_file, "rb"); - if (f_bn == NULL) { + if (f_bn == NULL) { printf("No value provided for BottleNeck\n"); FAIL() << "Cannot read file " << bottleneck_file; } else { int aux_var; - printf("reading bottleneck rates from file %s\n\n",bottleneck_file); + printf("reading bottleneck rates from file %s\n\n", bottleneck_file); if (fscanf(f_bn, "%d", &aux_var) == EOF) { /* Set pointer to beginning of file */ fseek(f_bn, 0L, SEEK_SET); @@ -481,18 +504,18 @@ TEST(IsacFixTest, Kenny) { outbitsname[h] = outname[h]; h++; } - for (k=0; k<5; k++) { + for (k = 0; k < 5; k++) { outbitsname[h] = tmpBit[k]; h++; } - if ((inp = fopen(inname,"rb")) == NULL) { + if ((inp = fopen(inname, "rb")) == NULL) { FAIL() << " iSAC: Cannot read file " << inname; } - if ((outp = fopen(outname,"wb")) == NULL) { + if ((outp = fopen(outname, "wb")) == NULL) { FAIL() << " iSAC: Cannot write file " << outname; } - if ((outbits = fopen(outbitsname,"wb")) == NULL) { + if ((outbits = fopen(outbitsname, "wb")) == NULL) { FAIL() << " iSAC: Cannot write file " << outbitsname; } printf("\nInput:%s\nOutput:%s\n\n", inname, outname); @@ -502,30 +525,28 @@ TEST(IsacFixTest, Kenny) { /* Test to run decoder with garbage data */ srand(random_seed); - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { + if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) { printf("Error: Could not open file %s\n", SEED_FILE); - } - else { + } else { fprintf(seedfile, "%u\n", random_seed); fclose(seedfile); } } /* Runtime statistics */ - starttime = clock()/(double)CLOCKS_PER_SEC; + starttime = clock() / (double)CLOCKS_PER_SEC; /* Initialize the ISAC and BN structs */ - if (testNum != 8) - { - if(1){ - err =WebRtcIsacfix_Create(&ISAC_main_inst); - }else{ + if (testNum != 8) { + if (1) { + err = WebRtcIsacfix_Create(&ISAC_main_inst); + } else { /* Test the Assign functions */ int sss; - void *ppp; - err =WebRtcIsacfix_AssignSize(&sss); - ppp=malloc(sss); - err =WebRtcIsacfix_Assign(&ISAC_main_inst,ppp); + void* ppp; + err = WebRtcIsacfix_AssignSize(&sss); + ppp = malloc(sss); + err = WebRtcIsacfix_Assign(&ISAC_main_inst, ppp); } /* Error check */ if (err < 0) { @@ -541,13 +562,13 @@ TEST(IsacFixTest, Kenny) { } /* Init of bandwidth data */ - BN_data.send_time = 0; - BN_data.arrival_time = 0; - BN_data.sample_count = 0; - BN_data.rtp_number = 0; + BN_data.send_time = 0; + BN_data.arrival_time = 0; + BN_data.sample_count = 0; + BN_data.rtp_number = 0; /* Initialize encoder and decoder */ - framecnt= 0; + framecnt = 0; endfile = 0; if (testNum != 1) { WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode); @@ -560,10 +581,10 @@ TEST(IsacFixTest, Kenny) { err = WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize); if (err < 0) { /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\n\n Error in control: %d.\n\n", errtype); } - } else if(setControlBWE == 1) { + } else if (setControlBWE == 1) { err = WebRtcIsacfix_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL); } @@ -571,7 +592,7 @@ TEST(IsacFixTest, Kenny) { err = WebRtcIsacfix_SetMaxPayloadSize(ISAC_main_inst, payloadSize); if (err < 0) { /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); FAIL() << "Error in SetMaxPayloadSize: " << errtype; } } @@ -579,35 +600,32 @@ TEST(IsacFixTest, Kenny) { err = WebRtcIsacfix_SetMaxRate(ISAC_main_inst, payloadRate); if (err < 0) { /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); FAIL() << "Error in SetMaxRateInBytes: " << errtype; } } *speechType = 1; - while (endfile == 0) { - - if(testNum == 7 && (rand()%2 == 0)) { + if (testNum == 7 && (rand() % 2 == 0)) { err = WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode); /* Error check */ if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\n\n Error in encoderinit: %d.\n\n", errtype); } WebRtcIsacfix_DecoderInit(ISAC_main_inst); } - cur_framesmpls = 0; while (1) { /* Read 10 ms speech block */ if (nbTest != 1) { endfile = readframe(shortdata, inp, FRAMESAMPLES_10ms); } else { - endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms/2)); + endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms / 2)); } if (testNum == 7) { @@ -620,22 +638,18 @@ TEST(IsacFixTest, Kenny) { short bwe; /* Encode */ - stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst, - shortdata, + stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst, shortdata, (uint8_t*)streamdata); /* If packet is ready, and CE testing, call the different API functions from the internal API. */ - if (stream_len_int>0) { + if (stream_len_int > 0) { if (testCE == 1) { err = WebRtcIsacfix_ReadBwIndex( reinterpret_cast(streamdata), - static_cast(stream_len_int), - &bwe); + static_cast(stream_len_int), &bwe); stream_len_int = WebRtcIsacfix_GetNewBitStream( - ISAC_main_inst, - bwe, - scale, + ISAC_main_inst, bwe, scale, reinterpret_cast(streamdata)); } else if (testCE == 2) { /* transcode function not supported */ @@ -646,37 +660,33 @@ TEST(IsacFixTest, Kenny) { err = WebRtcIsacfix_GetDownLinkBwIndex(ISAC_main_inst, &bwe); /* Error Check */ if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\nError in getSendBWE: %d.\n", errtype); } err = WebRtcIsacfix_UpdateUplinkBw(ISAC_main_inst, bwe); /* Error Check */ if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\nError in setBWE: %d.\n", errtype); } - } } } else { #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - stream_len_int = WebRtcIsacfix_EncodeNb(ISAC_main_inst, - shortdata, - streamdata); + stream_len_int = + WebRtcIsacfix_EncodeNb(ISAC_main_inst, shortdata, streamdata); #else stream_len_int = -1; #endif } - } - else - { + } else { break; } if (stream_len_int < 0 || err < 0) { /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\nError in encoder: %d.\n", errtype); } else { stream_len = static_cast(stream_len_int); @@ -705,7 +715,8 @@ TEST(IsacFixTest, Kenny) { } /* exit encoder loop if the encoder returned a bitstream */ - if (stream_len != 0) break; + if (stream_len != 0) + break; } /* make coded sequence to short be inreasing */ @@ -722,7 +733,7 @@ TEST(IsacFixTest, Kenny) { if (testNum == 6) { srand(time(NULL)); - for (i = 0; i < static_cast(stream_len); i++ ) { + for (i = 0; i < static_cast(stream_len); i++) { streamdata[i] = rand(); } } @@ -740,8 +751,7 @@ TEST(IsacFixTest, Kenny) { /* simulate packet handling through NetEq and the modem */ if (!(testNum == 3 && framecnt == 0)) { if (gns == 0) { - get_arrival_time(cur_framesmpls, stream_len, bottleneck, - &BN_data); + get_arrival_time(cur_framesmpls, stream_len, bottleneck, &BN_data); } else { get_arrival_time2(cur_framesmpls, cur_delay, &BN_data); } @@ -749,44 +759,38 @@ TEST(IsacFixTest, Kenny) { /* packet not dropped */ if (cur_delay != -1) { - /* Error test number 10, garbage data */ if (testNum == 10) { - for ( i = 0; i < static_cast(stream_len); i++) { - streamdata[i] = (short) (streamdata[i] + (short) rand()); + for (i = 0; i < static_cast(stream_len); i++) { + streamdata[i] = (short)(streamdata[i] + (short)rand()); } } if (testNum != 9) { err = WebRtcIsacfix_UpdateBwEstimate( - ISAC_main_inst, - reinterpret_cast(streamdata), - stream_len, - BN_data.rtp_number, - BN_data.send_time, + ISAC_main_inst, reinterpret_cast(streamdata), + stream_len, BN_data.rtp_number, BN_data.send_time, BN_data.arrival_time); if (err < 0) { /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\nError in decoder: %d.\n", errtype); } } - if( readLoss == 1 ) { - if( fread( &lostFrame, sizeof(int16_t), 1, plFile ) != 1 ) { - rewind( plFile ); + if (readLoss == 1) { + if (fread(&lostFrame, sizeof(int16_t), 1, plFile) != 1) { + rewind(plFile); } lostFrame = !lostFrame; } else { - lostFrame = (rand()%100 < packetLossPercent); + lostFrame = (rand() % 100 < packetLossPercent); } - - /* iSAC decoding */ - if( lostFrame && framecnt > 0) { - if (nbTest !=2) { + if (lostFrame && framecnt > 0) { + if (nbTest != 2) { declen = static_cast( WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize)); } else { @@ -799,32 +803,29 @@ TEST(IsacFixTest, Kenny) { } lostPackets++; } else { - if (nbTest !=2 ) { + if (nbTest != 2) { size_t FL; /* Call getFramelen, only used here for function test */ err = WebRtcIsacfix_ReadFrameLen( reinterpret_cast(streamdata), stream_len, &FL); declen = WebRtcIsacfix_Decode( - ISAC_main_inst, - reinterpret_cast(streamdata), - stream_len, - decoded, - speechType); + ISAC_main_inst, reinterpret_cast(streamdata), + stream_len, decoded, speechType); /* Error check */ if (err < 0 || declen < 0 || FL != static_cast(declen)) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf( "\nError %d in ReadFrameLen (%s), Decode (%s), with FL %zu and " "declen %d.\n", errtype, err < 0 ? "yes" : "no", declen < 0 ? "yes" : "no", FL, declen); } - prevFrameSize = static_cast(declen/480); + prevFrameSize = static_cast(declen / 480); } else { #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - declen = WebRtcIsacfix_DecodeNb( ISAC_main_inst, streamdata, - stream_len, decoded, speechType ); + declen = WebRtcIsacfix_DecodeNb(ISAC_main_inst, streamdata, + stream_len, decoded, speechType); #else declen = -1; #endif @@ -834,13 +835,12 @@ TEST(IsacFixTest, Kenny) { if (declen <= 0) { /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); + errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst); printf("\nError in decoder: %d.\n", errtype); } /* Write decoded speech frame to file */ - if (fwrite(decoded, sizeof(int16_t), - declen, outp) != (size_t)declen) { + if (fwrite(decoded, sizeof(int16_t), declen, outp) != (size_t)declen) { FAIL(); } // fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/ @@ -855,30 +855,28 @@ TEST(IsacFixTest, Kenny) { /* Error test number 10, garbage data */ if (testNum == 10) { - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - printf( "Error: Could not open file %s\n", SEED_FILE); - } - else { + if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) { + printf("Error: Could not open file %s\n", SEED_FILE); + } else { fprintf(seedfile, "ok\n\n"); fclose(seedfile); } } } printf("\nLost Frames %d ~ %4.1f%%\n", lostPackets, - (double)lostPackets/(double)framecnt*100.0 ); + (double)lostPackets / (double)framecnt * 100.0); printf("\n\ntotal bits = %d bits", totalbits); printf("\nmeasured average bitrate = %0.3f kbits/s", - (double)totalbits *(FS/1000) / totalsmpls); + (double)totalbits * (FS / 1000) / totalsmpls); printf("\n"); /* Runtime statistics */ - - runtime = (double)(((double)clock()/(double)CLOCKS_PER_SEC)-starttime); - length_file = ((double)framecnt*(double)declen/FS); + runtime = (double)(((double)clock() / (double)CLOCKS_PER_SEC) - starttime); + length_file = ((double)framecnt * (double)declen / FS); printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", - runtime, (100*runtime/length_file)); + printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", runtime, + (100 * runtime / length_file)); printf("\n\n_______________________________________________\n"); // Record the results with Perf test tools. @@ -893,7 +891,7 @@ TEST(IsacFixTest, Kenny) { fclose(outp); fclose(outbits); - if ( testCE == 1) { + if (testCE == 1) { WebRtcIsacfix_FreeInternal(ISAC_main_inst); } WebRtcIsacfix_Free(ISAC_main_inst); diff --git a/modules/audio_coding/codecs/isac/main/include/isac.h b/modules/audio_coding/codecs/isac/main/include/isac.h index e1ee818059..1d7e07538e 100644 --- a/modules/audio_coding/codecs/isac/main/include/isac.h +++ b/modules/audio_coding/codecs/isac/main/include/isac.h @@ -16,709 +16,647 @@ #include "modules/audio_coding/codecs/isac/bandwidth_info.h" #include "typedefs.h" // NOLINT(build/include) -typedef struct WebRtcISACStruct ISACStruct; +typedef struct WebRtcISACStruct ISACStruct; #if defined(__cplusplus) extern "C" { #endif - /****************************************************************************** - * WebRtcIsac_AssignSize(...) - * - * This function returns the size of the ISAC instance, so that the instance - * can be created outside iSAC. - * - * Input: - * - samplingRate : sampling rate of the input/output audio. - * - * Output: - * - sizeinbytes : number of bytes needed to allocate for the - * instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsac_AssignSize( - int* sizeinbytes); - - - /****************************************************************************** - * WebRtcIsac_Assign(...) - * - * This function assignes the memory already created to the ISAC instance. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - samplingRate : sampling rate of the input/output audio. - * - ISAC_inst_Addr : the already allocated memory, where we put the - * iSAC structure. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsac_Assign( - ISACStruct** ISAC_main_inst, - void* ISAC_inst_Addr); - - - /****************************************************************************** - * WebRtcIsac_Create(...) - * - * This function creates an ISAC instance, which will contain the state - * information for one coding/decoding channel. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsac_Create( - ISACStruct** ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_Free(...) - * - * This function frees the ISAC instance created at the beginning. - * - * Input: - * - ISAC_main_inst : an ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsac_Free( - ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_EncoderInit(...) - * - * This function initializes an ISAC instance prior to the encoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - CodingMode : 0 -> Bit rate and frame length are - * automatically adjusted to available bandwidth - * on transmission channel, just valid if codec - * is created to work in wideband mode. - * 1 -> User sets a frame length and a target bit - * rate which is taken as the maximum - * short-term average bit rate. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsac_EncoderInit( - ISACStruct* ISAC_main_inst, - int16_t CodingMode); - - - /****************************************************************************** - * WebRtcIsac_Encode(...) - * - * This function encodes 10ms audio blocks and inserts it into a package. - * Input speech length has 160 samples if operating at 16 kHz sampling - * rate, or 320 if operating at 32 kHz sampling rate. The encoder buffers the - * input audio until the whole frame is buffered then proceeds with encoding. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : 0 - The buffer didn't reach the chosen - * frame-size so it keeps buffering speech - * samples. - * : -1 - Error - */ - - int WebRtcIsac_Encode( - ISACStruct* ISAC_main_inst, - const int16_t* speechIn, - uint8_t* encoded); - - - /****************************************************************************** - * WebRtcIsac_DecoderInit(...) - * - * This function initializes an ISAC instance prior to the decoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - */ - - void WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst); - - /****************************************************************************** - * WebRtcIsac_UpdateBwEstimate(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - send_ts : the RTP send timestamp, given in samples - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ - - int16_t WebRtcIsac_UpdateBwEstimate( - ISACStruct* ISAC_main_inst, - const uint8_t* encoded, - size_t packet_size, - uint16_t rtp_seq_number, - uint32_t send_ts, - uint32_t arr_ts); - - - /****************************************************************************** - * WebRtcIsac_Decode(...) - * - * This function decodes an ISAC frame. At 16 kHz sampling rate, the length - * of the output audio could be either 480 or 960 samples, equivalent to - * 30 or 60 ms respectively. At 32 kHz sampling rate, the length of the - * output audio is 960 samples, which is 30 ms. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - len : bytes in encoded vector. - * - * Output: - * - decoded : The decoded vector. - * - * Return value : >0 - number of samples in decoded vector. - * -1 - Error. - */ - - int WebRtcIsac_Decode( - ISACStruct* ISAC_main_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); - - - /****************************************************************************** - * WebRtcIsac_DecodePlc(...) - * - * This function conducts PLC for ISAC frame(s). Output speech length - * will be a multiple of frames, i.e. multiples of 30 ms audio. Therefore, - * the output is multiple of 480 samples if operating at 16 kHz and multiple - * of 960 if operating at 32 kHz. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames to produce. - * - * Output: - * - decoded : The decoded vector. - * - * Return value : Number of samples in decoded PLC vector - */ - - size_t WebRtcIsac_DecodePlc( - ISACStruct* ISAC_main_inst, - int16_t* decoded, - size_t noOfLostFrames); - - - /****************************************************************************** - * WebRtcIsac_Control(...) - * - * This function sets the limit on the short-term average bit-rate and the - * frame length. Should be used only in Instantaneous mode. At 16 kHz sampling - * rate, an average bit-rate between 10000 to 32000 bps is valid and a - * frame-size of 30 or 60 ms is acceptable. At 32 kHz, an average bit-rate - * between 10000 to 56000 is acceptable, and the valid frame-size is 30 ms. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rate : limit on the short-term average bit rate, - * in bits/second. - * - framesize : frame-size in millisecond. - * - * Return value : 0 - ok - * -1 - Error - */ - - int16_t WebRtcIsac_Control( - ISACStruct* ISAC_main_inst, - int32_t rate, - int framesize); - - void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst, - int bottleneck_bits_per_second); - - /****************************************************************************** - * WebRtcIsac_ControlBwe(...) - * - * This function sets the initial values of bottleneck and frame-size if - * iSAC is used in channel-adaptive mode. Therefore, this API is not - * applicable if the codec is created to operate in super-wideband mode. - * - * Through this API, users can enforce a frame-size for all values of - * bottleneck. Then iSAC will not automatically change the frame-size. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rateBPS : initial value of bottleneck in bits/second - * 10000 <= rateBPS <= 56000 is accepted - * For default bottleneck set rateBPS = 0 - * - frameSizeMs : number of milliseconds per frame (30 or 60) - * - enforceFrameSize : 1 to enforce the given frame-size through - * out the adaptation process, 0 to let iSAC - * change the frame-size if required. - * - * Return value : 0 - ok - * -1 - Error - */ - - int16_t WebRtcIsac_ControlBwe( - ISACStruct* ISAC_main_inst, - int32_t rateBPS, - int frameSizeMs, - int16_t enforceFrameSize); - - - /****************************************************************************** - * WebRtcIsac_ReadFrameLen(...) - * - * This function returns the length of the frame represented in the packet. - * - * Input: - * - encoded : Encoded bit-stream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - */ - - int16_t WebRtcIsac_ReadFrameLen( - ISACStruct* ISAC_main_inst, - const uint8_t* encoded, - int16_t* frameLength); - - - /****************************************************************************** - * WebRtcIsac_version(...) - * - * This function returns the version number. - * - * Output: - * - version : Pointer to character string - * - */ - - void WebRtcIsac_version( - char *version); - - - /****************************************************************************** - * WebRtcIsac_GetErrorCode(...) - * - * This function can be used to check the error code of an iSAC instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occurred in the - * specified instance. - * - * Input: - * - ISAC_main_inst : ISAC instance - * - * Return value : Error code - */ - - int16_t WebRtcIsac_GetErrorCode( - ISACStruct* ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsac_GetUplinkBw(...) - * - * This function outputs the target bottleneck of the codec. In - * channel-adaptive mode, the target bottleneck is specified through in-band - * signalling retreived by bandwidth estimator. - * In channel-independent, also called instantaneous mode, the target - * bottleneck is provided to the encoder by calling xxx_control(...). If - * xxx_control is never called the default values is returned. The default - * value for bottleneck at 16 kHz encoder sampling rate is 32000 bits/sec, - * and it is 56000 bits/sec for 32 kHz sampling rate. - * Note that the output is the iSAC internal operating bottleneck which might - * differ slightly from the one provided through xxx_control(). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Output: - * - *bottleneck : bottleneck in bits/sec - * - * Return value : -1 if error happens - * 0 bit-rates computed correctly. - */ - - int16_t WebRtcIsac_GetUplinkBw( - ISACStruct* ISAC_main_inst, - int32_t* bottleneck); - - - /****************************************************************************** - * WebRtcIsac_SetMaxPayloadSize(...) - * - * This function sets a limit for the maximum payload size of iSAC. The same - * value is used both for 30 and 60 ms packets. If the encoder sampling rate - * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the - * encoder sampling rate is 32 kHz the maximum payload size is between 120 - * and 600 bytes. - * - * If an out of range limit is used, the function returns -1, but the closest - * valid value will be applied. - * - * --------------- - * IMPORTANT NOTES - * --------------- - * The size of a packet is limited to the minimum of 'max-payload-size' and - * 'max-rate.' For instance, let's assume the max-payload-size is set to - * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps - * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms - * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, - * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to - * 170 bytes, i.e. min(170, 300). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxPayloadBytes : maximum size of the payload in bytes - * valid values are between 120 and 400 bytes - * if encoder sampling rate is 16 kHz. For - * 32 kHz encoder sampling rate valid values - * are between 120 and 600 bytes. - * - * Return value : 0 if successful - * -1 if error happens - */ - - int16_t WebRtcIsac_SetMaxPayloadSize( - ISACStruct* ISAC_main_inst, - int16_t maxPayloadBytes); - - - /****************************************************************************** - * WebRtcIsac_SetMaxRate(...) - * - * This function sets the maximum rate which the codec may not exceed for - * any signal packet. The maximum rate is defined and payload-size per - * frame-size in bits per second. - * - * The codec has a maximum rate of 53400 bits per second (200 bytes per 30 - * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms) - * if the encoder sampling rate is 32 kHz. - * - * It is possible to set a maximum rate between 32000 and 53400 bits/sec - * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode. - * - * If an out of range limit is used, the function returns -1, but the closest - * valid value will be applied. - * - * --------------- - * IMPORTANT NOTES - * --------------- - * The size of a packet is limited to the minimum of 'max-payload-size' and - * 'max-rate.' For instance, let's assume the max-payload-size is set to - * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps - * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms - * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, - * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to - * 170 bytes, min(170, 300). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxRate : maximum rate in bits per second, - * valid values are 32000 to 53400 bits/sec in - * wideband mode, and 32000 to 160000 bits/sec in - * super-wideband mode. - * - * Return value : 0 if successful - * -1 if error happens - */ - - int16_t WebRtcIsac_SetMaxRate( - ISACStruct* ISAC_main_inst, - int32_t maxRate); - - - /****************************************************************************** - * WebRtcIsac_DecSampRate() - * Return the sampling rate of the decoded audio. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : sampling frequency in Hertz. - * - */ - - uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_EncSampRate() - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : sampling rate in Hertz. - * - */ - - uint16_t WebRtcIsac_EncSampRate(ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_SetDecSampRate() - * Set the sampling rate of the decoder. Initialization of the decoder WILL - * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz - * which is set when the instance is created. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - sampRate : sampling rate in Hertz. - * - * Return value : 0 if successful - * -1 if failed. - */ - - int16_t WebRtcIsac_SetDecSampRate(ISACStruct* ISAC_main_inst, - uint16_t samp_rate_hz); - - - /****************************************************************************** - * WebRtcIsac_SetEncSampRate() - * Set the sampling rate of the encoder. Initialization of the encoder WILL - * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz - * which is set when the instance is created. The encoding-mode and the - * bottleneck remain unchanged by this call, however, the maximum rate and - * maximum payload-size will reset to their default value. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - sampRate : sampling rate in Hertz. - * - * Return value : 0 if successful - * -1 if failed. - */ - - int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst, - uint16_t sample_rate_hz); - - - - /****************************************************************************** - * WebRtcIsac_GetNewBitStream(...) - * - * This function returns encoded data, with the recieved bwe-index in the - * stream. If the rate is set to a value less than bottleneck of codec - * the new bistream will be re-encoded with the given target rate. - * It should always return a complete packet, i.e. only called once - * even for 60 msec frames. - * - * NOTE 1! This function does not write in the ISACStruct, it is not allowed. - * NOTE 2! Currently not implemented for SWB mode. - * NOTE 3! Rates larger than the bottleneck of the codec will be limited - * to the current bottleneck. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - bweIndex : Index of bandwidth estimate to put in new - * bitstream - * - rate : target rate of the transcoder is bits/sec. - * Valid values are the accepted rate in iSAC, - * i.e. 10000 to 56000. - * - isRCU : if the new bit-stream is an RCU stream. - * Note that the rate parameter always indicates - * the target rate of the main payload, regardless - * of 'isRCU' value. - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error or called in SWB mode - * NOTE! No error code is written to - * the struct since it is only allowed to read - * the struct. - */ - int16_t WebRtcIsac_GetNewBitStream( - ISACStruct* ISAC_main_inst, - int16_t bweIndex, - int16_t jitterInfo, - int32_t rate, - uint8_t* encoded, - int16_t isRCU); - - - - /**************************************************************************** - * WebRtcIsac_GetDownLinkBwIndex(...) - * - * This function returns index representing the Bandwidth estimate from - * other side to this side. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - bweIndex : Bandwidth estimate to transmit to other side. - * - */ - - int16_t WebRtcIsac_GetDownLinkBwIndex( - ISACStruct* ISAC_main_inst, - int16_t* bweIndex, - int16_t* jitterInfo); - - - /**************************************************************************** - * WebRtcIsac_UpdateUplinkBw(...) - * - * This function takes an index representing the Bandwidth estimate from - * this side to other side and updates BWE. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - bweIndex : Bandwidth estimate from other side. - * - */ - - int16_t WebRtcIsac_UpdateUplinkBw( - ISACStruct* ISAC_main_inst, - int16_t bweIndex); - - - /**************************************************************************** - * WebRtcIsac_ReadBwIndex(...) - * - * This function returns the index of the Bandwidth estimate from the bitstream. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - bweIndex : Bandwidth estimate in bitstream - * - */ - - int16_t WebRtcIsac_ReadBwIndex( - const uint8_t* encoded, - int16_t* bweIndex); - - - - /******************************************************************************* - * WebRtcIsac_GetNewFrameLen(...) - * - * returns the frame lenght (in samples) of the next packet. In the case of channel-adaptive - * mode, iSAC decides on its frame lenght based on the estimated bottleneck - * this allows a user to prepare for the next packet (at the encoder) - * - * The primary usage is in CE to make the iSAC works in channel-adaptive mode - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Return Value : frame lenght in samples - * - */ - - int16_t WebRtcIsac_GetNewFrameLen( - ISACStruct* ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsac_GetRedPayload(...) - * - * Populates "encoded" with the redundant payload of the recently encoded - * frame. This function has to be called once that WebRtcIsac_Encode(...) - * returns a positive value. Regardless of the frame-size this function will - * be called only once after encoding is completed. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - encoded : the encoded data vector - * - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : -1 - Error - * - * - */ - int16_t WebRtcIsac_GetRedPayload( - ISACStruct* ISAC_main_inst, - uint8_t* encoded); - - - /**************************************************************************** - * WebRtcIsac_DecodeRcu(...) - * - * This function decodes a redundant (RCU) iSAC frame. Function is called in - * NetEq with a stored RCU payload i case of packet loss. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the framesize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC RCU frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - int WebRtcIsac_DecodeRcu( - ISACStruct* ISAC_main_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); - - /* Fills in an IsacBandwidthInfo struct. |inst| should be a decoder. */ - void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst, IsacBandwidthInfo* bwinfo); - - /* Uses the values from an IsacBandwidthInfo struct. |inst| should be an - encoder. */ - void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst, - const IsacBandwidthInfo* bwinfo); - - /* If |inst| is a decoder but not an encoder: tell it what sample rate the - encoder is using, for bandwidth estimation purposes. */ - void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, int sample_rate_hz); +/****************************************************************************** + * WebRtcIsac_AssignSize(...) + * + * This function returns the size of the ISAC instance, so that the instance + * can be created outside iSAC. + * + * Input: + * - samplingRate : sampling rate of the input/output audio. + * + * Output: + * - sizeinbytes : number of bytes needed to allocate for the + * instance. + * + * Return value : 0 - Ok + * -1 - Error + */ + +int16_t WebRtcIsac_AssignSize(int* sizeinbytes); + +/****************************************************************************** + * WebRtcIsac_Assign(...) + * + * This function assignes the memory already created to the ISAC instance. + * + * Input: + * - *ISAC_main_inst : a pointer to the coder instance. + * - samplingRate : sampling rate of the input/output audio. + * - ISAC_inst_Addr : the already allocated memory, where we put the + * iSAC structure. + * + * Return value : 0 - Ok + * -1 - Error + */ + +int16_t WebRtcIsac_Assign(ISACStruct** ISAC_main_inst, void* ISAC_inst_Addr); + +/****************************************************************************** + * WebRtcIsac_Create(...) + * + * This function creates an ISAC instance, which will contain the state + * information for one coding/decoding channel. + * + * Input: + * - *ISAC_main_inst : a pointer to the coder instance. + * + * Return value : 0 - Ok + * -1 - Error + */ + +int16_t WebRtcIsac_Create(ISACStruct** ISAC_main_inst); + +/****************************************************************************** + * WebRtcIsac_Free(...) + * + * This function frees the ISAC instance created at the beginning. + * + * Input: + * - ISAC_main_inst : an ISAC instance. + * + * Return value : 0 - Ok + * -1 - Error + */ + +int16_t WebRtcIsac_Free(ISACStruct* ISAC_main_inst); + +/****************************************************************************** + * WebRtcIsac_EncoderInit(...) + * + * This function initializes an ISAC instance prior to the encoder calls. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - CodingMode : 0 -> Bit rate and frame length are + * automatically adjusted to available bandwidth + * on transmission channel, just valid if codec + * is created to work in wideband mode. + * 1 -> User sets a frame length and a target bit + * rate which is taken as the maximum + * short-term average bit rate. + * + * Return value : 0 - Ok + * -1 - Error + */ + +int16_t WebRtcIsac_EncoderInit(ISACStruct* ISAC_main_inst, int16_t CodingMode); + +/****************************************************************************** + * WebRtcIsac_Encode(...) + * + * This function encodes 10ms audio blocks and inserts it into a package. + * Input speech length has 160 samples if operating at 16 kHz sampling + * rate, or 320 if operating at 32 kHz sampling rate. The encoder buffers the + * input audio until the whole frame is buffered then proceeds with encoding. + * + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - speechIn : input speech vector. + * + * Output: + * - encoded : the encoded data vector + * + * Return value: + * : >0 - Length (in bytes) of coded data + * : 0 - The buffer didn't reach the chosen + * frame-size so it keeps buffering speech + * samples. + * : -1 - Error + */ + +int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst, + const int16_t* speechIn, + uint8_t* encoded); + +/****************************************************************************** + * WebRtcIsac_DecoderInit(...) + * + * This function initializes an ISAC instance prior to the decoder calls. + * + * Input: + * - ISAC_main_inst : ISAC instance. + */ + +void WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst); + +/****************************************************************************** + * WebRtcIsac_UpdateBwEstimate(...) + * + * This function updates the estimate of the bandwidth. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC frame(s). + * - packet_size : size of the packet. + * - rtp_seq_number : the RTP number of the packet. + * - send_ts : the RTP send timestamp, given in samples + * - arr_ts : the arrival time of the packet (from NetEq) + * in samples. + * + * Return value : 0 - Ok + * -1 - Error + */ + +int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst, + const uint8_t* encoded, + size_t packet_size, + uint16_t rtp_seq_number, + uint32_t send_ts, + uint32_t arr_ts); + +/****************************************************************************** + * WebRtcIsac_Decode(...) + * + * This function decodes an ISAC frame. At 16 kHz sampling rate, the length + * of the output audio could be either 480 or 960 samples, equivalent to + * 30 or 60 ms respectively. At 32 kHz sampling rate, the length of the + * output audio is 960 samples, which is 30 ms. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC frame(s). + * - len : bytes in encoded vector. + * + * Output: + * - decoded : The decoded vector. + * + * Return value : >0 - number of samples in decoded vector. + * -1 - Error. + */ + +int WebRtcIsac_Decode(ISACStruct* ISAC_main_inst, + const uint8_t* encoded, + size_t len, + int16_t* decoded, + int16_t* speechType); + +/****************************************************************************** + * WebRtcIsac_DecodePlc(...) + * + * This function conducts PLC for ISAC frame(s). Output speech length + * will be a multiple of frames, i.e. multiples of 30 ms audio. Therefore, + * the output is multiple of 480 samples if operating at 16 kHz and multiple + * of 960 if operating at 32 kHz. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - noOfLostFrames : Number of PLC frames to produce. + * + * Output: + * - decoded : The decoded vector. + * + * Return value : Number of samples in decoded PLC vector + */ + +size_t WebRtcIsac_DecodePlc(ISACStruct* ISAC_main_inst, + int16_t* decoded, + size_t noOfLostFrames); + +/****************************************************************************** + * WebRtcIsac_Control(...) + * + * This function sets the limit on the short-term average bit-rate and the + * frame length. Should be used only in Instantaneous mode. At 16 kHz sampling + * rate, an average bit-rate between 10000 to 32000 bps is valid and a + * frame-size of 30 or 60 ms is acceptable. At 32 kHz, an average bit-rate + * between 10000 to 56000 is acceptable, and the valid frame-size is 30 ms. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - rate : limit on the short-term average bit rate, + * in bits/second. + * - framesize : frame-size in millisecond. + * + * Return value : 0 - ok + * -1 - Error + */ + +int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst, + int32_t rate, + int framesize); + +void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst, + int bottleneck_bits_per_second); + +/****************************************************************************** + * WebRtcIsac_ControlBwe(...) + * + * This function sets the initial values of bottleneck and frame-size if + * iSAC is used in channel-adaptive mode. Therefore, this API is not + * applicable if the codec is created to operate in super-wideband mode. + * + * Through this API, users can enforce a frame-size for all values of + * bottleneck. Then iSAC will not automatically change the frame-size. + * + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - rateBPS : initial value of bottleneck in bits/second + * 10000 <= rateBPS <= 56000 is accepted + * For default bottleneck set rateBPS = 0 + * - frameSizeMs : number of milliseconds per frame (30 or 60) + * - enforceFrameSize : 1 to enforce the given frame-size through + * out the adaptation process, 0 to let iSAC + * change the frame-size if required. + * + * Return value : 0 - ok + * -1 - Error + */ + +int16_t WebRtcIsac_ControlBwe(ISACStruct* ISAC_main_inst, + int32_t rateBPS, + int frameSizeMs, + int16_t enforceFrameSize); + +/****************************************************************************** + * WebRtcIsac_ReadFrameLen(...) + * + * This function returns the length of the frame represented in the packet. + * + * Input: + * - encoded : Encoded bit-stream + * + * Output: + * - frameLength : Length of frame in packet (in samples) + * + */ + +int16_t WebRtcIsac_ReadFrameLen(ISACStruct* ISAC_main_inst, + const uint8_t* encoded, + int16_t* frameLength); + +/****************************************************************************** + * WebRtcIsac_version(...) + * + * This function returns the version number. + * + * Output: + * - version : Pointer to character string + * + */ + +void WebRtcIsac_version(char* version); + +/****************************************************************************** + * WebRtcIsac_GetErrorCode(...) + * + * This function can be used to check the error code of an iSAC instance. When + * a function returns -1 a error code will be set for that instance. The + * function below extract the code of the last error that occurred in the + * specified instance. + * + * Input: + * - ISAC_main_inst : ISAC instance + * + * Return value : Error code + */ + +int16_t WebRtcIsac_GetErrorCode(ISACStruct* ISAC_main_inst); + +/**************************************************************************** + * WebRtcIsac_GetUplinkBw(...) + * + * This function outputs the target bottleneck of the codec. In + * channel-adaptive mode, the target bottleneck is specified through in-band + * signalling retreived by bandwidth estimator. + * In channel-independent, also called instantaneous mode, the target + * bottleneck is provided to the encoder by calling xxx_control(...). If + * xxx_control is never called the default values is returned. The default + * value for bottleneck at 16 kHz encoder sampling rate is 32000 bits/sec, + * and it is 56000 bits/sec for 32 kHz sampling rate. + * Note that the output is the iSAC internal operating bottleneck which might + * differ slightly from the one provided through xxx_control(). + * + * Input: + * - ISAC_main_inst : iSAC instance + * + * Output: + * - *bottleneck : bottleneck in bits/sec + * + * Return value : -1 if error happens + * 0 bit-rates computed correctly. + */ + +int16_t WebRtcIsac_GetUplinkBw(ISACStruct* ISAC_main_inst, int32_t* bottleneck); + +/****************************************************************************** + * WebRtcIsac_SetMaxPayloadSize(...) + * + * This function sets a limit for the maximum payload size of iSAC. The same + * value is used both for 30 and 60 ms packets. If the encoder sampling rate + * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the + * encoder sampling rate is 32 kHz the maximum payload size is between 120 + * and 600 bytes. + * + * If an out of range limit is used, the function returns -1, but the closest + * valid value will be applied. + * + * --------------- + * IMPORTANT NOTES + * --------------- + * The size of a packet is limited to the minimum of 'max-payload-size' and + * 'max-rate.' For instance, let's assume the max-payload-size is set to + * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps + * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms + * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, + * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to + * 170 bytes, i.e. min(170, 300). + * + * Input: + * - ISAC_main_inst : iSAC instance + * - maxPayloadBytes : maximum size of the payload in bytes + * valid values are between 120 and 400 bytes + * if encoder sampling rate is 16 kHz. For + * 32 kHz encoder sampling rate valid values + * are between 120 and 600 bytes. + * + * Return value : 0 if successful + * -1 if error happens + */ + +int16_t WebRtcIsac_SetMaxPayloadSize(ISACStruct* ISAC_main_inst, + int16_t maxPayloadBytes); + +/****************************************************************************** + * WebRtcIsac_SetMaxRate(...) + * + * This function sets the maximum rate which the codec may not exceed for + * any signal packet. The maximum rate is defined and payload-size per + * frame-size in bits per second. + * + * The codec has a maximum rate of 53400 bits per second (200 bytes per 30 + * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms) + * if the encoder sampling rate is 32 kHz. + * + * It is possible to set a maximum rate between 32000 and 53400 bits/sec + * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode. + * + * If an out of range limit is used, the function returns -1, but the closest + * valid value will be applied. + * + * --------------- + * IMPORTANT NOTES + * --------------- + * The size of a packet is limited to the minimum of 'max-payload-size' and + * 'max-rate.' For instance, let's assume the max-payload-size is set to + * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps + * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms + * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, + * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to + * 170 bytes, min(170, 300). + * + * Input: + * - ISAC_main_inst : iSAC instance + * - maxRate : maximum rate in bits per second, + * valid values are 32000 to 53400 bits/sec in + * wideband mode, and 32000 to 160000 bits/sec in + * super-wideband mode. + * + * Return value : 0 if successful + * -1 if error happens + */ + +int16_t WebRtcIsac_SetMaxRate(ISACStruct* ISAC_main_inst, int32_t maxRate); + +/****************************************************************************** + * WebRtcIsac_DecSampRate() + * Return the sampling rate of the decoded audio. + * + * Input: + * - ISAC_main_inst : iSAC instance + * + * Return value : sampling frequency in Hertz. + * + */ + +uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst); + +/****************************************************************************** + * WebRtcIsac_EncSampRate() + * + * Input: + * - ISAC_main_inst : iSAC instance + * + * Return value : sampling rate in Hertz. + * + */ + +uint16_t WebRtcIsac_EncSampRate(ISACStruct* ISAC_main_inst); + +/****************************************************************************** + * WebRtcIsac_SetDecSampRate() + * Set the sampling rate of the decoder. Initialization of the decoder WILL + * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz + * which is set when the instance is created. + * + * Input: + * - ISAC_main_inst : iSAC instance + * - sampRate : sampling rate in Hertz. + * + * Return value : 0 if successful + * -1 if failed. + */ + +int16_t WebRtcIsac_SetDecSampRate(ISACStruct* ISAC_main_inst, + uint16_t samp_rate_hz); + +/****************************************************************************** + * WebRtcIsac_SetEncSampRate() + * Set the sampling rate of the encoder. Initialization of the encoder WILL + * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz + * which is set when the instance is created. The encoding-mode and the + * bottleneck remain unchanged by this call, however, the maximum rate and + * maximum payload-size will reset to their default value. + * + * Input: + * - ISAC_main_inst : iSAC instance + * - sampRate : sampling rate in Hertz. + * + * Return value : 0 if successful + * -1 if failed. + */ + +int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst, + uint16_t sample_rate_hz); + +/****************************************************************************** + * WebRtcIsac_GetNewBitStream(...) + * + * This function returns encoded data, with the recieved bwe-index in the + * stream. If the rate is set to a value less than bottleneck of codec + * the new bistream will be re-encoded with the given target rate. + * It should always return a complete packet, i.e. only called once + * even for 60 msec frames. + * + * NOTE 1! This function does not write in the ISACStruct, it is not allowed. + * NOTE 2! Currently not implemented for SWB mode. + * NOTE 3! Rates larger than the bottleneck of the codec will be limited + * to the current bottleneck. + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - bweIndex : Index of bandwidth estimate to put in new + * bitstream + * - rate : target rate of the transcoder is bits/sec. + * Valid values are the accepted rate in iSAC, + * i.e. 10000 to 56000. + * - isRCU : if the new bit-stream is an RCU + * stream. Note that the rate parameter always indicates the target rate of the + * main payload, regardless of 'isRCU' value. + * + * Output: + * - encoded : The encoded data vector + * + * Return value : >0 - Length (in bytes) of coded data + * -1 - Error or called in SWB mode + * NOTE! No error code is written to + * the struct since it is only allowed to read + * the struct. + */ +int16_t WebRtcIsac_GetNewBitStream(ISACStruct* ISAC_main_inst, + int16_t bweIndex, + int16_t jitterInfo, + int32_t rate, + uint8_t* encoded, + int16_t isRCU); + +/**************************************************************************** + * WebRtcIsac_GetDownLinkBwIndex(...) + * + * This function returns index representing the Bandwidth estimate from + * other side to this side. + * + * Input: + * - ISAC_main_inst : iSAC struct + * + * Output: + * - bweIndex : Bandwidth estimate to transmit to other side. + * + */ + +int16_t WebRtcIsac_GetDownLinkBwIndex(ISACStruct* ISAC_main_inst, + int16_t* bweIndex, + int16_t* jitterInfo); + +/**************************************************************************** + * WebRtcIsac_UpdateUplinkBw(...) + * + * This function takes an index representing the Bandwidth estimate from + * this side to other side and updates BWE. + * + * Input: + * - ISAC_main_inst : iSAC struct + * - bweIndex : Bandwidth estimate from other side. + * + */ + +int16_t WebRtcIsac_UpdateUplinkBw(ISACStruct* ISAC_main_inst, int16_t bweIndex); + +/**************************************************************************** + * WebRtcIsac_ReadBwIndex(...) + * + * This function returns the index of the Bandwidth estimate from the bitstream. + * + * Input: + * - encoded : Encoded bitstream + * + * Output: + * - frameLength : Length of frame in packet (in samples) + * - bweIndex : Bandwidth estimate in bitstream + * + */ + +int16_t WebRtcIsac_ReadBwIndex(const uint8_t* encoded, int16_t* bweIndex); + +/******************************************************************************* + * WebRtcIsac_GetNewFrameLen(...) + * + * returns the frame lenght (in samples) of the next packet. In the case of + * channel-adaptive mode, iSAC decides on its frame lenght based on the + * estimated bottleneck this allows a user to prepare for the next packet (at + * the encoder) + * + * The primary usage is in CE to make the iSAC works in channel-adaptive mode + * + * Input: + * - ISAC_main_inst : iSAC struct + * + * Return Value : frame lenght in samples + * + */ + +int16_t WebRtcIsac_GetNewFrameLen(ISACStruct* ISAC_main_inst); + +/**************************************************************************** + * WebRtcIsac_GetRedPayload(...) + * + * Populates "encoded" with the redundant payload of the recently encoded + * frame. This function has to be called once that WebRtcIsac_Encode(...) + * returns a positive value. Regardless of the frame-size this function will + * be called only once after encoding is completed. + * + * Input: + * - ISAC_main_inst : iSAC struct + * + * Output: + * - encoded : the encoded data vector + * + * + * Return value: + * : >0 - Length (in bytes) of coded data + * : -1 - Error + * + * + */ +int16_t WebRtcIsac_GetRedPayload(ISACStruct* ISAC_main_inst, uint8_t* encoded); + +/**************************************************************************** + * WebRtcIsac_DecodeRcu(...) + * + * This function decodes a redundant (RCU) iSAC frame. Function is called in + * NetEq with a stored RCU payload i case of packet loss. Output speech length + * will be a multiple of 480 samples: 480 or 960 samples, + * depending on the framesize (30 or 60 ms). + * + * Input: + * - ISAC_main_inst : ISAC instance. + * - encoded : encoded ISAC RCU frame(s) + * - len : bytes in encoded vector + * + * Output: + * - decoded : The decoded vector + * + * Return value : >0 - number of samples in decoded vector + * -1 - Error + */ +int WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst, + const uint8_t* encoded, + size_t len, + int16_t* decoded, + int16_t* speechType); + +/* Fills in an IsacBandwidthInfo struct. |inst| should be a decoder. */ +void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst, IsacBandwidthInfo* bwinfo); + +/* Uses the values from an IsacBandwidthInfo struct. |inst| should be an + encoder. */ +void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst, + const IsacBandwidthInfo* bwinfo); + +/* If |inst| is a decoder but not an encoder: tell it what sample rate the + encoder is using, for bandwidth estimation purposes. */ +void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, int sample_rate_hz); #if defined(__cplusplus) } #endif - - #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_ISAC_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/arith_routines.h b/modules/audio_coding/codecs/isac/main/source/arith_routines.h index d001c68b82..6e7ea1da5e 100644 --- a/modules/audio_coding/codecs/isac/main/source/arith_routines.h +++ b/modules/audio_coding/codecs/isac/main/source/arith_routines.h @@ -21,42 +21,47 @@ #include "modules/audio_coding/codecs/isac/main/source/structs.h" int WebRtcIsac_EncLogisticMulti2( - Bitstr *streamdata, /* in-/output struct containing bitstream */ - int16_t *dataQ7, /* input: data vector */ - const uint16_t *env, /* input: side info vector defining the width of the pdf */ - const int N, /* input: data vector length */ + Bitstr* streamdata, /* in-/output struct containing bitstream */ + int16_t* dataQ7, /* input: data vector */ + const uint16_t* + env, /* input: side info vector defining the width of the pdf */ + const int N, /* input: data vector length */ const int16_t isSWB12kHz); /* if the codec is working in 12kHz bandwidth */ /* returns the number of bytes in the stream */ -int WebRtcIsac_EncTerminate(Bitstr *streamdata); /* in-/output struct containing bitstream */ +int WebRtcIsac_EncTerminate( + Bitstr* streamdata); /* in-/output struct containing bitstream */ /* returns the number of bytes in the stream so far */ int WebRtcIsac_DecLogisticMulti2( - int16_t *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const uint16_t *env, /* input: side info vector defining the width of the pdf */ - const int16_t *dither, /* input: dither vector */ - const int N, /* input: data vector length */ + int16_t* data, /* output: data vector */ + Bitstr* streamdata, /* in-/output struct containing bitstream */ + const uint16_t* + env, /* input: side info vector defining the width of the pdf */ + const int16_t* dither, /* input: dither vector */ + const int N, /* input: data vector length */ const int16_t isSWB12kHz); /* if the codec is working in 12kHz bandwidth */ void WebRtcIsac_EncHistMulti( - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const int *data, /* input: data vector */ - const uint16_t *const *cdf, /* input: array of cdf arrays */ + Bitstr* streamdata, /* in-/output struct containing bitstream */ + const int* data, /* input: data vector */ + const uint16_t* const* cdf, /* input: array of cdf arrays */ const int N); /* input: data vector length */ int WebRtcIsac_DecHistBisectMulti( - int *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const uint16_t *const *cdf, /* input: array of cdf arrays */ - const uint16_t *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */ - const int N); /* input: data vector length */ + int* data, /* output: data vector */ + Bitstr* streamdata, /* in-/output struct containing bitstream */ + const uint16_t* const* cdf, /* input: array of cdf arrays */ + const uint16_t* + cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */ + const int N); /* input: data vector length */ int WebRtcIsac_DecHistOneStepMulti( - int *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const uint16_t *const *cdf, /* input: array of cdf arrays */ - const uint16_t *init_index,/* input: vector of initial cdf table search entries */ - const int N); /* input: data vector length */ + int* data, /* output: data vector */ + Bitstr* streamdata, /* in-/output struct containing bitstream */ + const uint16_t* const* cdf, /* input: array of cdf arrays */ + const uint16_t* + init_index, /* input: vector of initial cdf table search entries */ + const int N); /* input: data vector length */ #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc b/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc index 333ab52c00..87ae0e0bcb 100644 --- a/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc +++ b/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc @@ -29,7 +29,11 @@ void TestGoodConfig(const AudioEncoderIsacFloatImpl::Config& config) { // Wrap subroutine calls that test things in this, so that the error messages // will be accompanied by stack traces that make it possible to tell which // subroutine invocation caused the failure. -#define S(x) do { SCOPED_TRACE(#x); x; } while (0) +#define S(x) \ + do { \ + SCOPED_TRACE(#x); \ + x; \ + } while (0) } // namespace diff --git a/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h b/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h index fbeb8493d4..d80ff73bf5 100644 --- a/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h +++ b/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h @@ -24,162 +24,151 @@ #include "modules/audio_coding/codecs/isac/main/source/settings.h" #include "modules/audio_coding/codecs/isac/main/source/structs.h" -#define MIN_ISAC_BW 10000 -#define MIN_ISAC_BW_LB 10000 -#define MIN_ISAC_BW_UB 25000 +#define MIN_ISAC_BW 10000 +#define MIN_ISAC_BW_LB 10000 +#define MIN_ISAC_BW_UB 25000 -#define MAX_ISAC_BW 56000 -#define MAX_ISAC_BW_UB 32000 -#define MAX_ISAC_BW_LB 32000 +#define MAX_ISAC_BW 56000 +#define MAX_ISAC_BW_UB 32000 +#define MAX_ISAC_BW_LB 32000 -#define MIN_ISAC_MD 5 -#define MAX_ISAC_MD 25 +#define MIN_ISAC_MD 5 +#define MAX_ISAC_MD 25 // assumed header size, in bytes; we don't know the exact number // (header compression may be used) -#define HEADER_SIZE 35 +#define HEADER_SIZE 35 // Initial Frame-Size, in ms, for Wideband & Super-Wideband Mode -#define INIT_FRAME_LEN_WB 60 +#define INIT_FRAME_LEN_WB 60 #define INIT_FRAME_LEN_SWB 30 // Initial Bottleneck Estimate, in bits/sec, for // Wideband & Super-wideband mode -#define INIT_BN_EST_WB 20e3f -#define INIT_BN_EST_SWB 56e3f +#define INIT_BN_EST_WB 20e3f +#define INIT_BN_EST_SWB 56e3f // Initial Header rate (header rate depends on frame-size), // in bits/sec, for Wideband & Super-Wideband mode. -#define INIT_HDR_RATE_WB \ +#define INIT_HDR_RATE_WB \ ((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_WB) -#define INIT_HDR_RATE_SWB \ +#define INIT_HDR_RATE_SWB \ ((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_SWB) // number of packets in a row for a high rate burst -#define BURST_LEN 3 +#define BURST_LEN 3 // ms, max time between two full bursts -#define BURST_INTERVAL 500 +#define BURST_INTERVAL 500 // number of packets in a row for initial high rate burst -#define INIT_BURST_LEN 5 +#define INIT_BURST_LEN 5 // bits/s, rate for the first BURST_LEN packets -#define INIT_RATE_WB INIT_BN_EST_WB -#define INIT_RATE_SWB INIT_BN_EST_SWB - +#define INIT_RATE_WB INIT_BN_EST_WB +#define INIT_RATE_SWB INIT_BN_EST_SWB #if defined(__cplusplus) extern "C" { #endif - /* This function initializes the struct */ - /* to be called before using the struct for anything else */ - /* returns 0 if everything went fine, -1 otherwise */ - int32_t WebRtcIsac_InitBandwidthEstimator( - BwEstimatorstr* bwest_str, - enum IsacSamplingRate encoderSampRate, - enum IsacSamplingRate decoderSampRate); +/* This function initializes the struct */ +/* to be called before using the struct for anything else */ +/* returns 0 if everything went fine, -1 otherwise */ +int32_t WebRtcIsac_InitBandwidthEstimator( + BwEstimatorstr* bwest_str, + enum IsacSamplingRate encoderSampRate, + enum IsacSamplingRate decoderSampRate); - /* This function updates the receiving estimate */ - /* Parameters: */ - /* rtp_number - value from RTP packet, from NetEq */ - /* frame length - length of signal frame in ms, from iSAC decoder */ - /* send_ts - value in RTP header giving send time in samples */ - /* arr_ts - value given by timeGetTime() time of arrival in samples of packet from NetEq */ - /* pksize - size of packet in bytes, from NetEq */ - /* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */ - /* returns 0 if everything went fine, -1 otherwise */ - int16_t WebRtcIsac_UpdateBandwidthEstimator( - BwEstimatorstr* bwest_str, - const uint16_t rtp_number, - const int32_t frame_length, - const uint32_t send_ts, - const uint32_t arr_ts, - const size_t pksize); +/* This function updates the receiving estimate */ +/* Parameters: */ +/* rtp_number - value from RTP packet, from NetEq */ +/* frame length - length of signal frame in ms, from iSAC decoder */ +/* send_ts - value in RTP header giving send time in samples */ +/* arr_ts - value given by timeGetTime() time of arrival in samples of + * packet from NetEq */ +/* pksize - size of packet in bytes, from NetEq */ +/* Index - integer (range 0...23) indicating bottle neck & jitter as + * estimated by other side */ +/* returns 0 if everything went fine, -1 otherwise */ +int16_t WebRtcIsac_UpdateBandwidthEstimator(BwEstimatorstr* bwest_str, + const uint16_t rtp_number, + const int32_t frame_length, + const uint32_t send_ts, + const uint32_t arr_ts, + const size_t pksize); - /* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */ - int16_t WebRtcIsac_UpdateUplinkBwImpl( - BwEstimatorstr* bwest_str, - int16_t Index, - enum IsacSamplingRate encoderSamplingFreq); +/* Update receiving estimates. Used when we only receive BWE index, no iSAC data + * packet. */ +int16_t WebRtcIsac_UpdateUplinkBwImpl( + BwEstimatorstr* bwest_str, + int16_t Index, + enum IsacSamplingRate encoderSamplingFreq); - /* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the sending iSAC payload */ - void WebRtcIsac_GetDownlinkBwJitIndexImpl( - BwEstimatorstr* bwest_str, - int16_t* bottleneckIndex, - int16_t* jitterInfo, - enum IsacSamplingRate decoderSamplingFreq); +/* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the + * sending iSAC payload */ +void WebRtcIsac_GetDownlinkBwJitIndexImpl( + BwEstimatorstr* bwest_str, + int16_t* bottleneckIndex, + int16_t* jitterInfo, + enum IsacSamplingRate decoderSamplingFreq); - /* Returns the bandwidth estimation (in bps) */ - int32_t WebRtcIsac_GetDownlinkBandwidth( - const BwEstimatorstr *bwest_str); +/* Returns the bandwidth estimation (in bps) */ +int32_t WebRtcIsac_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str); - /* Returns the max delay (in ms) */ - int32_t WebRtcIsac_GetDownlinkMaxDelay( - const BwEstimatorstr *bwest_str); +/* Returns the max delay (in ms) */ +int32_t WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str); - /* Returns the bandwidth that iSAC should send with in bps */ - int32_t WebRtcIsac_GetUplinkBandwidth(const BwEstimatorstr* bwest_str); +/* Returns the bandwidth that iSAC should send with in bps */ +int32_t WebRtcIsac_GetUplinkBandwidth(const BwEstimatorstr* bwest_str); - /* Returns the max delay value from the other side in ms */ - int32_t WebRtcIsac_GetUplinkMaxDelay( - const BwEstimatorstr *bwest_str); +/* Returns the max delay value from the other side in ms */ +int32_t WebRtcIsac_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str); - /* Fills in an IsacExternalBandwidthInfo struct. */ - void WebRtcIsacBw_GetBandwidthInfo( - BwEstimatorstr* bwest_str, - enum IsacSamplingRate decoder_sample_rate_hz, - IsacBandwidthInfo* bwinfo); +/* Fills in an IsacExternalBandwidthInfo struct. */ +void WebRtcIsacBw_GetBandwidthInfo(BwEstimatorstr* bwest_str, + enum IsacSamplingRate decoder_sample_rate_hz, + IsacBandwidthInfo* bwinfo); - /* Uses the values from an IsacExternalBandwidthInfo struct. */ - void WebRtcIsacBw_SetBandwidthInfo(BwEstimatorstr* bwest_str, - const IsacBandwidthInfo* bwinfo); +/* Uses the values from an IsacExternalBandwidthInfo struct. */ +void WebRtcIsacBw_SetBandwidthInfo(BwEstimatorstr* bwest_str, + const IsacBandwidthInfo* bwinfo); - /* - * update amount of data in bottle neck buffer and burst handling - * returns minimum payload size (bytes) - */ - int WebRtcIsac_GetMinBytes( - RateModel* State, - int StreamSize, /* bytes in bitstream */ - const int FrameLen, /* ms per frame */ - const double BottleNeck, /* bottle neck rate; excl headers (bps) */ - const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */ - enum ISACBandwidth bandwidth - /*,int16_t frequentLargePackets*/); +/* + * update amount of data in bottle neck buffer and burst handling + * returns minimum payload size (bytes) + */ +int WebRtcIsac_GetMinBytes( + RateModel* State, + int StreamSize, /* bytes in bitstream */ + const int FrameLen, /* ms per frame */ + const double BottleNeck, /* bottle neck rate; excl headers (bps) */ + const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */ + enum ISACBandwidth bandwidth + /*,int16_t frequentLargePackets*/); - /* - * update long-term average bitrate and amount of data in buffer - */ - void WebRtcIsac_UpdateRateModel( - RateModel* State, - int StreamSize, /* bytes in bitstream */ - const int FrameSamples, /* samples per frame */ - const double BottleNeck); /* bottle neck rate; excl headers (bps) */ +/* + * update long-term average bitrate and amount of data in buffer + */ +void WebRtcIsac_UpdateRateModel( + RateModel* State, + int StreamSize, /* bytes in bitstream */ + const int FrameSamples, /* samples per frame */ + const double BottleNeck); /* bottle neck rate; excl headers (bps) */ +void WebRtcIsac_InitRateModel(RateModel* State); - void WebRtcIsac_InitRateModel( - RateModel *State); +/* Returns the new framelength value (input argument: bottle_neck) */ +int WebRtcIsac_GetNewFrameLength(double bottle_neck, int current_framelength); - /* Returns the new framelength value (input argument: bottle_neck) */ - int WebRtcIsac_GetNewFrameLength( - double bottle_neck, - int current_framelength); +/* Returns the new SNR value (input argument: bottle_neck) */ +double WebRtcIsac_GetSnr(double bottle_neck, int new_framelength); - /* Returns the new SNR value (input argument: bottle_neck) */ - double WebRtcIsac_GetSnr( - double bottle_neck, - int new_framelength); - - - int16_t WebRtcIsac_UpdateUplinkJitter( - BwEstimatorstr* bwest_str, - int32_t index); +int16_t WebRtcIsac_UpdateUplinkJitter(BwEstimatorstr* bwest_str, int32_t index); #if defined(__cplusplus) } #endif - -#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ */ +#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ \ + */ diff --git a/modules/audio_coding/codecs/isac/main/source/codec.h b/modules/audio_coding/codecs/isac/main/source/codec.h index 96118ad089..c3867047c5 100644 --- a/modules/audio_coding/codecs/isac/main/source/codec.h +++ b/modules/audio_coding/codecs/isac/main/source/codec.h @@ -25,10 +25,12 @@ void WebRtcIsac_ResetBitstream(Bitstr* bit_stream); -int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str, Bitstr* streamdata, +int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str, + Bitstr* streamdata, size_t packet_size, uint16_t rtp_seq_number, - uint32_t send_ts, uint32_t arr_ts, + uint32_t send_ts, + uint32_t arr_ts, enum IsacSamplingRate encoderSampRate, enum IsacSamplingRate decoderSampRate); @@ -38,7 +40,8 @@ int WebRtcIsac_DecodeLb(const TransformTables* transform_tables, int16_t* current_framesamples, int16_t isRCUPayload); -int WebRtcIsac_DecodeRcuLb(float* signal_out, ISACLBDecStruct* ISACdec_obj, +int WebRtcIsac_DecodeRcuLb(float* signal_out, + ISACLBDecStruct* ISACdec_obj, int16_t* current_framesamples); int WebRtcIsac_EncodeLb(const TransformTables* transform_tables, @@ -48,15 +51,20 @@ int WebRtcIsac_EncodeLb(const TransformTables* transform_tables, int16_t bottleneckIndex); int WebRtcIsac_EncodeStoredDataLb(const IsacSaveEncoderData* ISACSavedEnc_obj, - Bitstr* ISACBitStr_obj, int BWnumber, + Bitstr* ISACBitStr_obj, + int BWnumber, float scale); int WebRtcIsac_EncodeStoredDataUb( - const ISACUBSaveEncDataStruct* ISACSavedEnc_obj, Bitstr* bitStream, - int32_t jitterInfo, float scale, enum ISACBandwidth bandwidth); + const ISACUBSaveEncDataStruct* ISACSavedEnc_obj, + Bitstr* bitStream, + int32_t jitterInfo, + float scale, + enum ISACBandwidth bandwidth); int16_t WebRtcIsac_GetRedPayloadUb( - const ISACUBSaveEncDataStruct* ISACSavedEncObj, Bitstr* bitStreamObj, + const ISACUBSaveEncDataStruct* ISACSavedEncObj, + Bitstr* bitStreamObj, enum ISACBandwidth bandwidth); /****************************************************************************** @@ -82,7 +90,6 @@ int16_t WebRtcIsac_RateAllocation(int32_t inRateBitPerSec, double* rateUBBitPerSec, enum ISACBandwidth* bandwidthKHz); - /****************************************************************************** * WebRtcIsac_DecodeUb16() * @@ -169,7 +176,6 @@ void WebRtcIsac_InitMasking(MaskFiltstr* maskdata); void WebRtcIsac_InitPostFilterbank(PostFiltBankstr* postfiltdata); - /**************************** transform functions ****************************/ void WebRtcIsac_InitTransform(TransformTables* tables); @@ -190,18 +196,25 @@ void WebRtcIsac_Spec2time(const TransformTables* tables, /***************************** filterbank functions **************************/ -void WebRtcIsac_FilterAndCombineFloat(float* InLP, float* InHP, float* Out, +void WebRtcIsac_FilterAndCombineFloat(float* InLP, + float* InHP, + float* Out, PostFiltBankstr* postfiltdata); - /************************* normalized lattice filters ************************/ -void WebRtcIsac_NormLatticeFilterMa(int orderCoef, float* stateF, float* stateG, - float* lat_in, double* filtcoeflo, +void WebRtcIsac_NormLatticeFilterMa(int orderCoef, + float* stateF, + float* stateG, + float* lat_in, + double* filtcoeflo, double* lat_out); -void WebRtcIsac_NormLatticeFilterAr(int orderCoef, float* stateF, float* stateG, - double* lat_in, double* lo_filt_coef, +void WebRtcIsac_NormLatticeFilterAr(int orderCoef, + float* stateF, + float* stateG, + double* lat_in, + double* lo_filt_coef, float* lat_out); void WebRtcIsac_Dir2Lat(double* a, int orderCoef, float* sth, float* cth); diff --git a/modules/audio_coding/codecs/isac/main/source/crc.h b/modules/audio_coding/codecs/isac/main/source/crc.h index b3197a1a7d..19adbdaa0b 100644 --- a/modules/audio_coding/codecs/isac/main/source/crc.h +++ b/modules/audio_coding/codecs/isac/main/source/crc.h @@ -36,11 +36,6 @@ * -1 - Error */ -int WebRtcIsac_GetCrc( - const int16_t* encoded, - int no_of_word8s, - uint32_t* crc); - - +int WebRtcIsac_GetCrc(const int16_t* encoded, int no_of_word8s, uint32_t* crc); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h b/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h index 2fa1c715b3..b8d918b9ed 100644 --- a/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h +++ b/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h @@ -39,9 +39,7 @@ * * */ -int16_t WebRtcIsac_RemoveLarMean( - double* lar, - int16_t bandwidth); +int16_t WebRtcIsac_RemoveLarMean(double* lar, int16_t bandwidth); /****************************************************************************** * WebRtcIsac_DecorrelateIntraVec() @@ -59,11 +57,9 @@ int16_t WebRtcIsac_RemoveLarMean( * Output: * -out : decorrelated LAR vectors. */ -int16_t WebRtcIsac_DecorrelateIntraVec( - const double* inLAR, - double* out, - int16_t bandwidth); - +int16_t WebRtcIsac_DecorrelateIntraVec(const double* inLAR, + double* out, + int16_t bandwidth); /****************************************************************************** * WebRtcIsac_DecorrelateInterVec() @@ -82,11 +78,9 @@ int16_t WebRtcIsac_DecorrelateIntraVec( * Output: * -out : decorrelated LAR vectors. */ -int16_t WebRtcIsac_DecorrelateInterVec( - const double* data, - double* out, - int16_t bandwidth); - +int16_t WebRtcIsac_DecorrelateInterVec(const double* data, + double* out, + int16_t bandwidth); /****************************************************************************** * WebRtcIsac_QuantizeUncorrLar() @@ -102,11 +96,7 @@ int16_t WebRtcIsac_DecorrelateInterVec( * -data : quantized version of the input. * -idx : pointer to quantization indices. */ -double WebRtcIsac_QuantizeUncorrLar( - double* data, - int* idx, - int16_t bandwidth); - +double WebRtcIsac_QuantizeUncorrLar(double* data, int* idx, int16_t bandwidth); /****************************************************************************** * WebRtcIsac_CorrelateIntraVec() @@ -121,11 +111,9 @@ double WebRtcIsac_QuantizeUncorrLar( * Output: * -out : correlated parametrs. */ -int16_t WebRtcIsac_CorrelateIntraVec( - const double* data, - double* out, - int16_t bandwidth); - +int16_t WebRtcIsac_CorrelateIntraVec(const double* data, + double* out, + int16_t bandwidth); /****************************************************************************** * WebRtcIsac_CorrelateInterVec() @@ -140,17 +128,15 @@ int16_t WebRtcIsac_CorrelateIntraVec( * Output: * -out : correlated parametrs. */ -int16_t WebRtcIsac_CorrelateInterVec( - const double* data, - double* out, - int16_t bandwidth); - +int16_t WebRtcIsac_CorrelateInterVec(const double* data, + double* out, + int16_t bandwidth); /****************************************************************************** * WebRtcIsac_AddLarMean() * * This is the inverse of WebRtcIsac_RemoveLarMean() - * + * * Input: * -data : pointer to mean-removed LAR:s. * -bandwidth : indicates if the given LAR vectors belong @@ -159,10 +145,7 @@ int16_t WebRtcIsac_CorrelateInterVec( * Output: * -data : pointer to LARs. */ -int16_t WebRtcIsac_AddLarMean( - double* data, - int16_t bandwidth); - +int16_t WebRtcIsac_AddLarMean(double* data, int16_t bandwidth); /****************************************************************************** * WebRtcIsac_DequantizeLpcParam() @@ -177,11 +160,9 @@ int16_t WebRtcIsac_AddLarMean( * Output: * -out : pointer to quantized values. */ -int16_t WebRtcIsac_DequantizeLpcParam( - const int* idx, - double* out, - int16_t bandwidth); - +int16_t WebRtcIsac_DequantizeLpcParam(const int* idx, + double* out, + int16_t bandwidth); /****************************************************************************** * WebRtcIsac_ToLogDomainRemoveMean() @@ -194,9 +175,7 @@ int16_t WebRtcIsac_DequantizeLpcParam( * Output: * -lpcGain : mean-removed in log domain. */ -int16_t WebRtcIsac_ToLogDomainRemoveMean( - double* lpGains); - +int16_t WebRtcIsac_ToLogDomainRemoveMean(double* lpGains); /****************************************************************************** * WebRtcIsac_DecorrelateLPGain() @@ -210,16 +189,13 @@ int16_t WebRtcIsac_ToLogDomainRemoveMean( * Output: * -out : decorrelated parameters. */ -int16_t WebRtcIsac_DecorrelateLPGain( - const double* data, - double* out); - +int16_t WebRtcIsac_DecorrelateLPGain(const double* data, double* out); /****************************************************************************** * WebRtcIsac_QuantizeLpcGain() * * Quantize the decorrelated log-domain gains. - * + * * Input: * -lpcGain : uncorrelated LPC gains. * @@ -227,10 +203,7 @@ int16_t WebRtcIsac_DecorrelateLPGain( * -idx : quantization indices * -lpcGain : quantized value of the inpt. */ -double WebRtcIsac_QuantizeLpcGain( - double* lpGains, - int* idx); - +double WebRtcIsac_QuantizeLpcGain(double* lpGains, int* idx); /****************************************************************************** * WebRtcIsac_DequantizeLpcGain() @@ -243,10 +216,7 @@ double WebRtcIsac_QuantizeLpcGain( * Output: * -lpcGains : quantized values of the given parametes. */ -int16_t WebRtcIsac_DequantizeLpcGain( - const int* idx, - double* lpGains); - +int16_t WebRtcIsac_DequantizeLpcGain(const int* idx, double* lpGains); /****************************************************************************** * WebRtcIsac_CorrelateLpcGain() @@ -259,10 +229,7 @@ int16_t WebRtcIsac_DequantizeLpcGain( * Output: * -out : correlated parameters. */ -int16_t WebRtcIsac_CorrelateLpcGain( - const double* data, - double* out); - +int16_t WebRtcIsac_CorrelateLpcGain(const double* data, double* out); /****************************************************************************** * WebRtcIsac_AddMeanToLinearDomain() @@ -275,8 +242,6 @@ int16_t WebRtcIsac_CorrelateLpcGain( * Output: * -lpcGain : LPC gain in normal domain. */ -int16_t WebRtcIsac_AddMeanToLinearDomain( - double* lpcGains); - +int16_t WebRtcIsac_AddMeanToLinearDomain(double* lpcGains); #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_ diff --git a/modules/audio_coding/codecs/isac/main/source/entropy_coding.h b/modules/audio_coding/codecs/isac/main/source/entropy_coding.h index 7224ad07f7..6c2b8d3cc1 100644 --- a/modules/audio_coding/codecs/isac/main/source/entropy_coding.h +++ b/modules/audio_coding/codecs/isac/main/source/entropy_coding.h @@ -46,8 +46,11 @@ * Return value : < 0 if an error occures * 0 if succeeded. */ -int WebRtcIsac_DecodeSpec(Bitstr* streamdata, int16_t AvgPitchGain_Q12, - enum ISACBand band, double* fr, double* fi); +int WebRtcIsac_DecodeSpec(Bitstr* streamdata, + int16_t AvgPitchGain_Q12, + enum ISACBand band, + double* fr, + double* fi); /****************************************************************************** * WebRtcIsac_EncodeSpec() @@ -72,24 +75,31 @@ int WebRtcIsac_DecodeSpec(Bitstr* streamdata, int16_t AvgPitchGain_Q12, * Return value : < 0 if an error occures * 0 if succeeded. */ -int WebRtcIsac_EncodeSpec(const int16_t* fr, const int16_t* fi, - int16_t AvgPitchGain_Q12, enum ISACBand band, +int WebRtcIsac_EncodeSpec(const int16_t* fr, + const int16_t* fi, + int16_t AvgPitchGain_Q12, + enum ISACBand band, Bitstr* streamdata); /* decode & dequantize LPC Coef */ int WebRtcIsac_DecodeLpcCoef(Bitstr* streamdata, double* LPCCoef); -int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata, double* lpcVecs, +int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata, + double* lpcVecs, double* percepFilterGains, int16_t bandwidth); -int WebRtcIsac_DecodeLpc(Bitstr* streamdata, double* LPCCoef_lo, +int WebRtcIsac_DecodeLpc(Bitstr* streamdata, + double* LPCCoef_lo, double* LPCCoef_hi); /* quantize & code LPC Coef */ -void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo, double* LPCCoef_hi, - Bitstr* streamdata, IsacSaveEncoderData* encData); +void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo, + double* LPCCoef_hi, + Bitstr* streamdata, + IsacSaveEncoderData* encData); -void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi, +void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, + double* LPCCoef_hi, Bitstr* streamdata, IsacSaveEncoderData* encData); @@ -126,7 +136,8 @@ void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi, * Return value : 0 if encoding is successful, * <0 if failed to encode. */ -int16_t WebRtcIsac_EncodeLpcUB(double* lpcCoeff, Bitstr* streamdata, +int16_t WebRtcIsac_EncodeLpcUB(double* lpcCoeff, + Bitstr* streamdata, double* interpolLPCCoeff, int16_t bandwidth, ISACUBSaveEncDataStruct* encData); @@ -184,9 +195,9 @@ void WebRtcIsac_EncodePitchLag(double* PitchLags, Bitstr* streamdata, IsacSaveEncoderData* encData); -int WebRtcIsac_DecodePitchGain(Bitstr* streamdata, - int16_t* PitchGain_Q12); -int WebRtcIsac_DecodePitchLag(Bitstr* streamdata, int16_t* PitchGain_Q12, +int WebRtcIsac_DecodePitchGain(Bitstr* streamdata, int16_t* PitchGain_Q12); +int WebRtcIsac_DecodePitchLag(Bitstr* streamdata, + int16_t* PitchGain_Q12, double* PitchLag); int WebRtcIsac_DecodeFrameLen(Bitstr* streamdata, int16_t* framelength); @@ -200,10 +211,10 @@ void WebRtcIsac_Poly2Rc(double* a, int N, double* RC); /* Step-up */ void WebRtcIsac_Rc2Poly(double* RC, int N, double* a); -void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi, +void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, + double* LPCCoef_hi, int* index_g); - /****************************************************************************** * WebRtcIsac_EncodeLpcGainUb() * Encode LPC gains of sub-Frames. @@ -220,10 +231,10 @@ void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi, * - lpcGainIndex : quantization indices for lpc gains, these will * be stored to be used for FEC. */ -void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata, +void WebRtcIsac_EncodeLpcGainUb(double* lpGains, + Bitstr* streamdata, int* lpcGainIndex); - /****************************************************************************** * WebRtcIsac_EncodeLpcGainUb() * Store LPC gains of sub-Frames in 'streamdata'. @@ -239,7 +250,6 @@ void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata, */ void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata); - /****************************************************************************** * WebRtcIsac_DecodeLpcGainUb() * Decode the LPC gain of sub-frames. @@ -257,7 +267,6 @@ void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata); */ int16_t WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata); - /****************************************************************************** * WebRtcIsac_EncodeBandwidth() * Encode if the bandwidth of encoded audio is 0-12 kHz or 0-16 kHz. @@ -277,7 +286,6 @@ int16_t WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata); int16_t WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth, Bitstr* streamData); - /****************************************************************************** * WebRtcIsac_DecodeBandwidth() * Decode the bandwidth of the encoded audio, i.e. if the bandwidth is 0-12 kHz @@ -298,7 +306,6 @@ int16_t WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth, int16_t WebRtcIsac_DecodeBandwidth(Bitstr* streamData, enum ISACBandwidth* bandwidth); - /****************************************************************************** * WebRtcIsac_EncodeJitterInfo() * Decode the jitter information. @@ -316,9 +323,7 @@ int16_t WebRtcIsac_DecodeBandwidth(Bitstr* streamData, * Return value : 0 if succeeded. * <0 if failed. */ -int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex, - Bitstr* streamData); - +int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex, Bitstr* streamData); /****************************************************************************** * WebRtcIsac_DecodeJitterInfo() @@ -337,7 +342,6 @@ int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex, * Return value : 0 if succeeded. * <0 if failed. */ -int16_t WebRtcIsac_DecodeJitterInfo(Bitstr* streamData, - int32_t* jitterInfo); +int16_t WebRtcIsac_DecodeJitterInfo(Bitstr* streamData, int32_t* jitterInfo); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENTROPY_CODING_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/fft.h b/modules/audio_coding/codecs/isac/main/source/fft.h index 975015370b..34e5f94542 100644 --- a/modules/audio_coding/codecs/isac/main/source/fft.h +++ b/modules/audio_coding/codecs/isac/main/source/fft.h @@ -34,10 +34,12 @@ /* double precision routine */ - -int WebRtcIsac_Fftns (unsigned int ndim, const int dims[], double Re[], double Im[], - int isign, double scaling, FFTstr *fftstate); - - +int WebRtcIsac_Fftns(unsigned int ndim, + const int dims[], + double Re[], + double Im[], + int isign, + double scaling, + FFTstr* fftstate); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc b/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc index 727f0f61e0..3ec28cca74 100644 --- a/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc +++ b/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc @@ -35,15 +35,13 @@ class IsacTest : public ::testing::Test { uint8_t bitstream_small_[7]; // Simulate sync packets. }; -IsacTest::IsacTest() - : isac_codec_(NULL) { -} +IsacTest::IsacTest() : isac_codec_(NULL) {} void IsacTest::SetUp() { // Read some samples from a speech file, to be used in the encode test. FILE* input_file; const std::string file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); input_file = fopen(file_name.c_str(), "rb"); ASSERT_TRUE(input_file != NULL); ASSERT_EQ(kIsacNumberOfSamples, @@ -69,7 +67,8 @@ TEST_F(IsacTest, IsacFreeFail) { TEST_F(IsacTest, IsacCreateFree) { EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_)); EXPECT_TRUE(isac_codec_ != NULL); - EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));} + EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_)); +} TEST_F(IsacTest, IsacUpdateBWE) { // Create encoder memory. @@ -86,17 +85,17 @@ TEST_F(IsacTest, IsacUpdateBWE) { 12345, 56789)); // Encode 60 ms of data (needed to create a first packet). - encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); + encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); EXPECT_EQ(0, encoded_bytes); - encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); + encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); EXPECT_EQ(0, encoded_bytes); - encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); + encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); EXPECT_EQ(0, encoded_bytes); - encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); + encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); EXPECT_EQ(0, encoded_bytes); - encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); + encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); EXPECT_EQ(0, encoded_bytes); - encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); + encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_); EXPECT_GT(encoded_bytes, 0); // Call to update bandwidth estimator with real data. diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h b/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h index 30f9153984..5503e2d49b 100644 --- a/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h +++ b/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h @@ -21,24 +21,26 @@ #include "modules/audio_coding/codecs/isac/main/source/settings.h" #include "modules/audio_coding/codecs/isac/main/source/structs.h" -void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata, - double signal_noise_ratio, const int16_t *pitchGains_Q12, - double *lo_coeff, double *hi_coeff); +void WebRtcIsac_GetLpcCoefLb(double* inLo, + double* inHi, + MaskFiltstr* maskdata, + double signal_noise_ratio, + const int16_t* pitchGains_Q12, + double* lo_coeff, + double* hi_coeff); -void WebRtcIsac_GetLpcGain( - double signal_noise_ratio, - const double* filtCoeffVecs, - int numVecs, - double* gain, - double corrLo[][UB_LPC_ORDER + 1], - const double* varscale); +void WebRtcIsac_GetLpcGain(double signal_noise_ratio, + const double* filtCoeffVecs, + int numVecs, + double* gain, + double corrLo[][UB_LPC_ORDER + 1], + const double* varscale); -void WebRtcIsac_GetLpcCoefUb( - double* inSignal, - MaskFiltstr* maskdata, - double* lpCoeff, - double corr[][UB_LPC_ORDER + 1], - double* varscale, - int16_t bandwidth); +void WebRtcIsac_GetLpcCoefUb(double* inSignal, + MaskFiltstr* maskdata, + double* lpCoeff, + double corr[][UB_LPC_ORDER + 1], + double* varscale, + int16_t bandwidth); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYIS_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h index 7a5abfd26e..84913ddfe8 100644 --- a/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h @@ -46,4 +46,4 @@ extern const uint16_t* WebRtcIsac_kLpcGainCdfMat[SUBFRAMES]; extern const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES]; -#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ +#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h index 7bae0960a7..e21e15a422 100644 --- a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h @@ -26,22 +26,22 @@ extern const double WebRtcIsac_kMeanLarUb12[UB_LPC_ORDER]; extern const double WebRtcIsac_kMeanLpcGain; -extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER]; +extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER] + [UB_LPC_ORDER]; -extern const double WebRtcIsac_kInterVecDecorrMatUb12 -[UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME]; +extern const double WebRtcIsac_kInterVecDecorrMatUb12[UB_LPC_VEC_PER_FRAME] + [UB_LPC_VEC_PER_FRAME]; extern const double WebRtcIsac_kLpcShapeQStepSizeUb12; -extern const double WebRtcIsac_kLpcShapeLeftRecPointUb12 -[UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME]; +extern const double + WebRtcIsac_kLpcShapeLeftRecPointUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; +extern const int16_t + WebRtcIsac_kLpcShapeNumRecPointUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; -extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; - -extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; +extern const uint16_t + WebRtcIsac_kLpcShapeEntropySearchUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; extern const uint16_t WebRtcIsac_kLpcShapeCdfVec0Ub12[14]; @@ -59,7 +59,7 @@ extern const uint16_t WebRtcIsac_kLpcShapeCdfVec6Ub12[33]; extern const uint16_t WebRtcIsac_kLpcShapeCdfVec7Ub12[49]; -extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; +extern const uint16_t* + WebRtcIsac_kLpcShapeCdfMatUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; -#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ +#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h index d828b833a9..4d5403d8d4 100644 --- a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h @@ -24,10 +24,11 @@ extern const double WebRtcIsac_kMeanLarUb16[UB_LPC_ORDER]; -extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER][UB_LPC_ORDER]; +extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER] + [UB_LPC_ORDER]; -extern const double WebRtcIsac_kInterVecDecorrMatUb16 -[UB16_LPC_VEC_PER_FRAME][UB16_LPC_VEC_PER_FRAME]; +extern const double WebRtcIsac_kInterVecDecorrMatUb16[UB16_LPC_VEC_PER_FRAME] + [UB16_LPC_VEC_PER_FRAME]; extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub16[14]; @@ -61,18 +62,19 @@ extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub165[34]; extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub166[71]; -extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; +extern const uint16_t* + WebRtcIsac_kLpcShapeCdfMatUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; -extern const double WebRtcIsac_kLpcShapeLeftRecPointUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; +extern const double + WebRtcIsac_kLpcShapeLeftRecPointUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; -extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; +extern const int16_t + WebRtcIsac_kLpcShapeNumRecPointUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; -extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; +extern const uint16_t + WebRtcIsac_kLpcShapeEntropySearchUb16[UB_LPC_ORDER * + UB16_LPC_VEC_PER_FRAME]; extern const double WebRtcIsac_kLpcShapeQStepSizeUb16; -#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_ +#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_ diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_tables.h index 2b02557032..2d92dfaaa5 100644 --- a/modules/audio_coding/codecs/isac/main/source/lpc_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/lpc_tables.h @@ -22,27 +22,27 @@ #include "modules/audio_coding/codecs/isac/main/source/settings.h" -#define KLT_STEPSIZE 1.00000000 -#define KLT_NUM_AVG_GAIN 0 -#define KLT_NUM_AVG_SHAPE 0 -#define KLT_NUM_MODELS 3 -#define LPC_GAIN_SCALE 4.000f -#define LPC_LOBAND_SCALE 2.100f -#define LPC_LOBAND_ORDER ORDERLO -#define LPC_HIBAND_SCALE 0.450f -#define LPC_HIBAND_ORDER ORDERHI -#define LPC_GAIN_ORDER 2 +#define KLT_STEPSIZE 1.00000000 +#define KLT_NUM_AVG_GAIN 0 +#define KLT_NUM_AVG_SHAPE 0 +#define KLT_NUM_MODELS 3 +#define LPC_GAIN_SCALE 4.000f +#define LPC_LOBAND_SCALE 2.100f +#define LPC_LOBAND_ORDER ORDERLO +#define LPC_HIBAND_SCALE 0.450f +#define LPC_HIBAND_ORDER ORDERHI +#define LPC_GAIN_ORDER 2 -#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER) +#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER) -#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES) -#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES) +#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES) +#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES) /* cdf array for model indicator */ -extern const uint16_t WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS+1]; +extern const uint16_t WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS + 1]; /* pointer to cdf array for model indicator */ -extern const uint16_t *WebRtcIsac_kQKltModelCdfPtr[1]; +extern const uint16_t* WebRtcIsac_kQKltModelCdfPtr[1]; /* initial cdf index for decoder of model indicator */ extern const uint16_t WebRtcIsac_kQKltModelInitIndex[1]; @@ -78,9 +78,9 @@ extern const uint16_t WebRtcIsac_kQKltCdfGain[404]; extern const uint16_t WebRtcIsac_kQKltCdfShape[686]; /* pointers to cdf tables for quantizer indices */ -extern const uint16_t *WebRtcIsac_kQKltCdfPtrGain[12]; +extern const uint16_t* WebRtcIsac_kQKltCdfPtrGain[12]; -extern const uint16_t *WebRtcIsac_kQKltCdfPtrShape[108]; +extern const uint16_t* WebRtcIsac_kQKltCdfPtrShape[108]; /* left KLT transforms */ extern const double WebRtcIsac_kKltT1Gain[4]; diff --git a/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h b/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h index 597dc21d1c..f72236d4ae 100644 --- a/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h +++ b/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ @@ -24,11 +23,12 @@ static __inline long int WebRtcIsac_lrint(double x_dbl) { __asm { fld x_dbl fistp x_int - }; + } + ; return x_int; } -#else // Do a slow but correct implementation of lrint +#else // Do a slow but correct implementation of lrint static __inline long int WebRtcIsac_lrint(double x_dbl) { long int x_int; diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h b/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h index c03ce6296f..4ab78c20ad 100644 --- a/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h +++ b/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h @@ -22,10 +22,11 @@ #include "modules/audio_coding/codecs/isac/main/source/structs.h" -void WebRtcIsac_PitchAnalysis(const double *in, /* PITCH_FRAME_LEN samples */ - double *out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ - PitchAnalysisStruct *State, - double *lags, - double *gains); +void WebRtcIsac_PitchAnalysis( + const double* in, /* PITCH_FRAME_LEN samples */ + double* out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ + PitchAnalysisStruct* State, + double* lags, + double* gains); #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h b/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h index fe506ee284..891bcef1ea 100644 --- a/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h @@ -11,7 +11,8 @@ /* * pitch_gain_tables.h * - * This file contains tables for the pitch filter side-info in the entropy coder. + * This file contains tables for the pitch filter side-info in the entropy + * coder. * */ @@ -20,8 +21,10 @@ #include "typedefs.h" // NOLINT(build/include) -/* header file for coding tables for the pitch filter side-info in the entropy coder */ -/********************* Pitch Filter Gain Coefficient Tables ************************/ +/* header file for coding tables for the pitch filter side-info in the entropy + * coder */ +/********************* Pitch Filter Gain Coefficient Tables + * ************************/ /* cdf for quantized pitch filter gains */ extern const uint16_t WebRtcIsac_kQPitchGainCdf[255]; diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h b/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h index 6a57c87264..b662ab5419 100644 --- a/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h @@ -11,7 +11,8 @@ /* * pitch_lag_tables.h * - * This file contains tables for the pitch filter side-info in the entropy coder. + * This file contains tables for the pitch filter side-info in the entropy + * coder. * */ @@ -19,8 +20,10 @@ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_LAG_TABLES_H_ #include "typedefs.h" // NOLINT(build/include) -/* header file for coding tables for the pitch filter side-info in the entropy coder */ -/********************* Pitch Filter Lag Coefficient Tables ************************/ +/* header file for coding tables for the pitch filter side-info in the entropy + * coder */ +/********************* Pitch Filter Lag Coefficient Tables + * ************************/ /* tables for use with small pitch gain */ @@ -30,7 +33,7 @@ extern const uint16_t WebRtcIsac_kQPitchLagCdf2Lo[20]; extern const uint16_t WebRtcIsac_kQPitchLagCdf3Lo[2]; extern const uint16_t WebRtcIsac_kQPitchLagCdf4Lo[10]; -extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrLo[4]; +extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrLo[4]; /* size of first cdf table */ extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeLo[1]; @@ -49,7 +52,6 @@ extern const double WebRtcIsac_kQMeanLag4Lo[9]; extern const double WebRtcIsac_kQPitchLagStepsizeLo; - /* tables for use with medium pitch gain */ /* cdfs for quantized pitch lags */ @@ -58,7 +60,7 @@ extern const uint16_t WebRtcIsac_kQPitchLagCdf2Mid[36]; extern const uint16_t WebRtcIsac_kQPitchLagCdf3Mid[2]; extern const uint16_t WebRtcIsac_kQPitchLagCdf4Mid[20]; -extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrMid[4]; +extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrMid[4]; /* size of first cdf table */ extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeMid[1]; @@ -77,7 +79,6 @@ extern const double WebRtcIsac_kQMeanLag4Mid[19]; extern const double WebRtcIsac_kQPitchLagStepsizeMid; - /* tables for use with large pitch gain */ /* cdfs for quantized pitch lags */ @@ -86,7 +87,7 @@ extern const uint16_t WebRtcIsac_kQPitchLagCdf2Hi[68]; extern const uint16_t WebRtcIsac_kQPitchLagCdf3Hi[2]; extern const uint16_t WebRtcIsac_kQPitchLagCdf4Hi[35]; -extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrHi[4]; +extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrHi[4]; /* size of first cdf table */ extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeHi[1]; diff --git a/modules/audio_coding/codecs/isac/main/source/settings.h b/modules/audio_coding/codecs/isac/main/source/settings.h index c08d72ffe3..14a5be812c 100644 --- a/modules/audio_coding/codecs/isac/main/source/settings.h +++ b/modules/audio_coding/codecs/isac/main/source/settings.h @@ -19,187 +19,181 @@ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ /* sampling frequency (Hz) */ -#define FS 16000 +#define FS 16000 /* number of samples per frame (either 320 (20ms), 480 (30ms) or 960 (60ms)) */ -#define INITIAL_FRAMESAMPLES 960 - +#define INITIAL_FRAMESAMPLES 960 #define MAXFFTSIZE 2048 #define NFACTOR 11 - - /* do not modify the following; this will have to be modified if we * have a 20ms framesize option */ /**********************************************************************/ /* miliseconds */ -#define FRAMESIZE 30 +#define FRAMESIZE 30 /* number of samples per frame processed in the encoder, 480 */ -#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ -#define FRAMESAMPLES_HALF 240 -#define FRAMESAMPLES_QUARTER 120 +#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ +#define FRAMESAMPLES_HALF 240 +#define FRAMESAMPLES_QUARTER 120 /**********************************************************************/ - - /* max number of samples per frame (= 60 ms frame) */ -#define MAX_FRAMESAMPLES 960 -#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2) +#define MAX_FRAMESAMPLES 960 +#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2) /* number of samples per 10ms frame */ -#define FRAMESAMPLES_10ms ((10*FS)/1000) -#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2) +#define FRAMESAMPLES_10ms ((10 * FS) / 1000) +#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2) /* number of samples in 30 ms frame */ -#define FRAMESAMPLES_30ms 480 +#define FRAMESAMPLES_30ms 480 /* number of subframes */ -#define SUBFRAMES 6 +#define SUBFRAMES 6 /* length of a subframe */ -#define UPDATE 80 +#define UPDATE 80 /* length of half a subframe (low/high band) */ -#define HALF_SUBFRAMELEN (UPDATE/2) +#define HALF_SUBFRAMELEN (UPDATE / 2) /* samples of look ahead (in a half-band, so actually * half the samples of look ahead @ FS) */ -#define QLOOKAHEAD 24 /* 3 ms */ +#define QLOOKAHEAD 24 /* 3 ms */ /* order of AR model in spectral entropy coder */ -#define AR_ORDER 6 +#define AR_ORDER 6 /* order of LP model in spectral entropy coder */ -#define LP_ORDER 0 +#define LP_ORDER 0 /* window length (masking analysis) */ -#define WINLEN 256 +#define WINLEN 256 /* order of low-band pole filter used to approximate masking curve */ -#define ORDERLO 12 +#define ORDERLO 12 /* order of hi-band pole filter used to approximate masking curve */ -#define ORDERHI 6 - -#define UB_LPC_ORDER 4 -#define UB_LPC_VEC_PER_FRAME 2 -#define UB16_LPC_VEC_PER_FRAME 4 -#define UB_ACTIVE_SUBFRAMES 2 -#define UB_MAX_LPC_ORDER 6 -#define UB_INTERPOL_SEGMENTS 1 -#define UB16_INTERPOL_SEGMENTS 3 -#define LB_TOTAL_DELAY_SAMPLES 48 -enum ISACBandwidth {isac8kHz = 8, isac12kHz = 12, isac16kHz = 16}; -enum ISACBand {kIsacLowerBand = 0, kIsacUpperBand12 = 1, kIsacUpperBand16 = 2}; -enum IsacSamplingRate {kIsacWideband = 16, kIsacSuperWideband = 32}; -#define UB_LPC_GAIN_DIM SUBFRAMES -#define FB_STATE_SIZE_WORD32 6 +#define ORDERHI 6 +#define UB_LPC_ORDER 4 +#define UB_LPC_VEC_PER_FRAME 2 +#define UB16_LPC_VEC_PER_FRAME 4 +#define UB_ACTIVE_SUBFRAMES 2 +#define UB_MAX_LPC_ORDER 6 +#define UB_INTERPOL_SEGMENTS 1 +#define UB16_INTERPOL_SEGMENTS 3 +#define LB_TOTAL_DELAY_SAMPLES 48 +enum ISACBandwidth { isac8kHz = 8, isac12kHz = 12, isac16kHz = 16 }; +enum ISACBand { + kIsacLowerBand = 0, + kIsacUpperBand12 = 1, + kIsacUpperBand16 = 2 +}; +enum IsacSamplingRate { kIsacWideband = 16, kIsacSuperWideband = 32 }; +#define UB_LPC_GAIN_DIM SUBFRAMES +#define FB_STATE_SIZE_WORD32 6 /* order for post_filter_bank */ -#define POSTQORDER 3 +#define POSTQORDER 3 /* order for pre-filterbank */ -#define QORDER 3 +#define QORDER 3 /* another order */ -#define QORDER_ALL (POSTQORDER+QORDER-1) +#define QORDER_ALL (POSTQORDER + QORDER - 1) /* for decimator */ -#define ALLPASSSECTIONS 2 - +#define ALLPASSSECTIONS 2 /* array size for byte stream in number of bytes. */ /* The old maximum size still needed for the decoding */ -#define STREAM_SIZE_MAX 600 -#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */ -#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */ +#define STREAM_SIZE_MAX 600 +#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */ +#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */ /* storage size for bit counts */ -#define BIT_COUNTER_SIZE 30 +#define BIT_COUNTER_SIZE 30 /* maximum order of any AR model or filter */ -#define MAX_AR_MODEL_ORDER 12//50 - +#define MAX_AR_MODEL_ORDER 12 // 50 /* For pitch analysis */ -#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */ -#define PITCH_MAX_LAG 140 /* 57 Hz */ -#define PITCH_MIN_LAG 20 /* 400 Hz */ -#define PITCH_MAX_GAIN 0.45 -#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */ -#define PITCH_MAX_GAIN_Q12 1843 -#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) -#define PITCH_CORR_LEN2 60 /* 15 ms */ -#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN/4) -#define PITCH_BW 11 /* half the band width of correlation surface */ -#define PITCH_SUBFRAMES 4 -#define PITCH_GRAN_PER_SUBFRAME 5 -#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN/PITCH_SUBFRAMES) -#define PITCH_UPDATE (PITCH_SUBFRAME_LEN/PITCH_GRAN_PER_SUBFRAME) +#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */ +#define PITCH_MAX_LAG 140 /* 57 Hz */ +#define PITCH_MIN_LAG 20 /* 400 Hz */ +#define PITCH_MAX_GAIN 0.45 +#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */ +#define PITCH_MAX_GAIN_Q12 1843 +#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG / 2 - PITCH_MIN_LAG / 2 + 5) +#define PITCH_CORR_LEN2 60 /* 15 ms */ +#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN / 4) +#define PITCH_BW 11 /* half the band width of correlation surface */ +#define PITCH_SUBFRAMES 4 +#define PITCH_GRAN_PER_SUBFRAME 5 +#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN / PITCH_SUBFRAMES) +#define PITCH_UPDATE (PITCH_SUBFRAME_LEN / PITCH_GRAN_PER_SUBFRAME) /* maximum number of peaks to be examined in correlation surface */ -#define PITCH_MAX_NUM_PEAKS 10 -#define PITCH_PEAK_DECAY 0.85 +#define PITCH_MAX_NUM_PEAKS 10 +#define PITCH_PEAK_DECAY 0.85 /* For weighting filter */ -#define PITCH_WLPCORDER 6 -#define PITCH_WLPCWINLEN PITCH_FRAME_LEN -#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */ -#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN +#define PITCH_WLPCORDER 6 +#define PITCH_WLPCWINLEN PITCH_FRAME_LEN +#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */ +#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN /* For pitch filter */ /* Extra 50 for fraction and LP filters */ -#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50) -#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN+PITCH_BUFFSIZE) +#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50) +#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN + PITCH_BUFFSIZE) /* Max rel. step for interpolation */ -#define PITCH_UPSTEP 1.5 +#define PITCH_UPSTEP 1.5 /* Max rel. step for interpolation */ -#define PITCH_DOWNSTEP 0.67 -#define PITCH_FRACS 8 -#define PITCH_FRACORDER 9 -#define PITCH_DAMPORDER 5 -#define PITCH_FILTDELAY 1.5f +#define PITCH_DOWNSTEP 0.67 +#define PITCH_FRACS 8 +#define PITCH_FRACORDER 9 +#define PITCH_DAMPORDER 5 +#define PITCH_FILTDELAY 1.5f /* stepsize for quantization of the pitch Gain */ -#define PITCH_GAIN_STEPSIZE 0.125 - - +#define PITCH_GAIN_STEPSIZE 0.125 /* Order of high pass filter */ -#define HPORDER 2 +#define HPORDER 2 /* some mathematical constants */ /* log2(exp) */ -#define LOG2EXP 1.44269504088896 -#define PI 3.14159265358979 +#define LOG2EXP 1.44269504088896 +#define PI 3.14159265358979 /* Maximum number of iterations allowed to limit payload size */ -#define MAX_PAYLOAD_LIMIT_ITERATION 5 +#define MAX_PAYLOAD_LIMIT_ITERATION 5 /* Redundant Coding */ -#define RCU_BOTTLENECK_BPS 16000 -#define RCU_TRANSCODING_SCALE 0.40f -#define RCU_TRANSCODING_SCALE_INVERSE 2.5f +#define RCU_BOTTLENECK_BPS 16000 +#define RCU_TRANSCODING_SCALE 0.40f +#define RCU_TRANSCODING_SCALE_INVERSE 2.5f -#define RCU_TRANSCODING_SCALE_UB 0.50f -#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f +#define RCU_TRANSCODING_SCALE_UB 0.50f +#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f /* Define Error codes */ /* 6000 General */ -#define ISAC_MEMORY_ALLOCATION_FAILED 6010 -#define ISAC_MODE_MISMATCH 6020 -#define ISAC_DISALLOWED_BOTTLENECK 6030 -#define ISAC_DISALLOWED_FRAME_LENGTH 6040 -#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050 +#define ISAC_MEMORY_ALLOCATION_FAILED 6010 +#define ISAC_MODE_MISMATCH 6020 +#define ISAC_DISALLOWED_BOTTLENECK 6030 +#define ISAC_DISALLOWED_FRAME_LENGTH 6040 +#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050 /* 6200 Bandwidth estimator */ -#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 +#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 /* 6400 Encoder */ -#define ISAC_ENCODER_NOT_INITIATED 6410 -#define ISAC_DISALLOWED_CODING_MODE 6420 -#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 -#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 -#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 -#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460 +#define ISAC_ENCODER_NOT_INITIATED 6410 +#define ISAC_DISALLOWED_CODING_MODE 6420 +#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 +#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 +#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 +#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460 /* 6600 Decoder */ -#define ISAC_DECODER_NOT_INITIATED 6610 -#define ISAC_EMPTY_PACKET 6620 -#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 -#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 -#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 -#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 -#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 -#define ISAC_RANGE_ERROR_DECODE_LPC 6680 -#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 -#define ISAC_LENGTH_MISMATCH 6730 -#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740 -#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750 -#define ISAC_DISALLOWED_LPC_MODEL 6760 +#define ISAC_DECODER_NOT_INITIATED 6610 +#define ISAC_EMPTY_PACKET 6620 +#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 +#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 +#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 +#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 +#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 +#define ISAC_RANGE_ERROR_DECODE_LPC 6680 +#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 +#define ISAC_LENGTH_MISMATCH 6730 +#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740 +#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750 +#define ISAC_DISALLOWED_LPC_MODEL 6760 /* 6800 Call setup formats */ -#define ISAC_INCOMPATIBLE_FORMATS 6810 +#define ISAC_INCOMPATIBLE_FORMATS 6810 #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ */ diff --git a/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h b/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h index 1e656eb2bd..d272be0dc3 100644 --- a/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h +++ b/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h @@ -11,7 +11,7 @@ /* * spectrum_ar_model_tables.h * - * This file contains definitions of tables with AR coefficients, + * This file contains definitions of tables with AR coefficients, * Gain coefficients and cosine tables. * */ @@ -45,15 +45,15 @@ extern const uint16_t WebRtcIsac_kQArRc6Cdf[NUM_AR_RC_QUANT_BAUNDARY]; /* quantization boundary levels for reflection coefficients */ extern const int16_t WebRtcIsac_kQArBoundaryLevels[NUM_AR_RC_QUANT_BAUNDARY]; -/* initial indices for AR reflection coefficient quantizer and cdf table search */ +/* initial indices for AR reflection coefficient quantizer and cdf table search + */ extern const uint16_t WebRtcIsac_kQArRcInitIndex[AR_ORDER]; /* pointers to AR cdf tables */ -extern const uint16_t *WebRtcIsac_kQArRcCdfPtr[AR_ORDER]; +extern const uint16_t* WebRtcIsac_kQArRcCdfPtr[AR_ORDER]; /* pointers to AR representation levels tables */ -extern const int16_t *WebRtcIsac_kQArRcLevelsPtr[AR_ORDER]; - +extern const int16_t* WebRtcIsac_kQArRcLevelsPtr[AR_ORDER]; /******************** GAIN Coefficient Tables ***********************/ /* cdf for Gain coefficient */ @@ -66,7 +66,7 @@ extern const int32_t WebRtcIsac_kQGain2Levels[18]; extern const int32_t WebRtcIsac_kQGain2BoundaryLevels[19]; /* pointer to Gain cdf table */ -extern const uint16_t *WebRtcIsac_kQGainCdf_ptr[1]; +extern const uint16_t* WebRtcIsac_kQGainCdf_ptr[1]; /* Gain initial index for gain quantizer and cdf table search */ extern const uint16_t WebRtcIsac_kQGainInitIndex[1]; @@ -75,4 +75,5 @@ extern const uint16_t WebRtcIsac_kQGainInitIndex[1]; /* Cosine table */ extern const int16_t WebRtcIsac_kCos[6][60]; -#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */ +#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ \ + */ diff --git a/modules/audio_coding/codecs/isac/main/source/structs.h b/modules/audio_coding/codecs/isac/main/source/structs.h index 8197d553db..f8ac9c7c9d 100644 --- a/modules/audio_coding/codecs/isac/main/source/structs.h +++ b/modules/audio_coding/codecs/isac/main/source/structs.h @@ -23,178 +23,166 @@ #include "typedefs.h" // NOLINT(build/include) typedef struct Bitstreamstruct { - - uint8_t stream[STREAM_SIZE_MAX]; - uint32_t W_upper; - uint32_t streamval; - uint32_t stream_index; + uint8_t stream[STREAM_SIZE_MAX]; + uint32_t W_upper; + uint32_t streamval; + uint32_t stream_index; } Bitstr; typedef struct { + double DataBufferLo[WINLEN]; + double DataBufferHi[WINLEN]; - double DataBufferLo[WINLEN]; - double DataBufferHi[WINLEN]; + double CorrBufLo[ORDERLO + 1]; + double CorrBufHi[ORDERHI + 1]; - double CorrBufLo[ORDERLO+1]; - double CorrBufHi[ORDERHI+1]; + float PreStateLoF[ORDERLO + 1]; + float PreStateLoG[ORDERLO + 1]; + float PreStateHiF[ORDERHI + 1]; + float PreStateHiG[ORDERHI + 1]; + float PostStateLoF[ORDERLO + 1]; + float PostStateLoG[ORDERLO + 1]; + float PostStateHiF[ORDERHI + 1]; + float PostStateHiG[ORDERHI + 1]; - float PreStateLoF[ORDERLO+1]; - float PreStateLoG[ORDERLO+1]; - float PreStateHiF[ORDERHI+1]; - float PreStateHiG[ORDERHI+1]; - float PostStateLoF[ORDERLO+1]; - float PostStateLoG[ORDERLO+1]; - float PostStateHiF[ORDERHI+1]; - float PostStateHiG[ORDERHI+1]; - - double OldEnergy; + double OldEnergy; } MaskFiltstr; - typedef struct { + // state vectors for each of the two analysis filters + double INSTAT1[2 * (QORDER - 1)]; + double INSTAT2[2 * (QORDER - 1)]; + double INSTATLA1[2 * (QORDER - 1)]; + double INSTATLA2[2 * (QORDER - 1)]; + double INLABUF1[QLOOKAHEAD]; + double INLABUF2[QLOOKAHEAD]; - //state vectors for each of the two analysis filters - double INSTAT1[2*(QORDER-1)]; - double INSTAT2[2*(QORDER-1)]; - double INSTATLA1[2*(QORDER-1)]; - double INSTATLA2[2*(QORDER-1)]; - double INLABUF1[QLOOKAHEAD]; - double INLABUF2[QLOOKAHEAD]; - - float INSTAT1_float[2*(QORDER-1)]; - float INSTAT2_float[2*(QORDER-1)]; - float INSTATLA1_float[2*(QORDER-1)]; - float INSTATLA2_float[2*(QORDER-1)]; - float INLABUF1_float[QLOOKAHEAD]; - float INLABUF2_float[QLOOKAHEAD]; + float INSTAT1_float[2 * (QORDER - 1)]; + float INSTAT2_float[2 * (QORDER - 1)]; + float INSTATLA1_float[2 * (QORDER - 1)]; + float INSTATLA2_float[2 * (QORDER - 1)]; + float INLABUF1_float[QLOOKAHEAD]; + float INLABUF2_float[QLOOKAHEAD]; /* High pass filter */ - double HPstates[HPORDER]; - float HPstates_float[HPORDER]; + double HPstates[HPORDER]; + float HPstates_float[HPORDER]; } PreFiltBankstr; - typedef struct { - - //state vectors for each of the two analysis filters - double STATE_0_LOWER[2*POSTQORDER]; - double STATE_0_UPPER[2*POSTQORDER]; + // state vectors for each of the two analysis filters + double STATE_0_LOWER[2 * POSTQORDER]; + double STATE_0_UPPER[2 * POSTQORDER]; /* High pass filter */ - double HPstates1[HPORDER]; - double HPstates2[HPORDER]; + double HPstates1[HPORDER]; + double HPstates2[HPORDER]; - float STATE_0_LOWER_float[2*POSTQORDER]; - float STATE_0_UPPER_float[2*POSTQORDER]; + float STATE_0_LOWER_float[2 * POSTQORDER]; + float STATE_0_UPPER_float[2 * POSTQORDER]; - float HPstates1_float[HPORDER]; - float HPstates2_float[HPORDER]; + float HPstates1_float[HPORDER]; + float HPstates2_float[HPORDER]; } PostFiltBankstr; typedef struct { + // data buffer for pitch filter + double ubuf[PITCH_BUFFSIZE]; - //data buffer for pitch filter - double ubuf[PITCH_BUFFSIZE]; + // low pass state vector + double ystate[PITCH_DAMPORDER]; - //low pass state vector - double ystate[PITCH_DAMPORDER]; - - //old lag and gain - double oldlagp[1]; - double oldgainp[1]; + // old lag and gain + double oldlagp[1]; + double oldgainp[1]; } PitchFiltstr; typedef struct { + // data buffer + double buffer[PITCH_WLPCBUFLEN]; - //data buffer - double buffer[PITCH_WLPCBUFLEN]; + // state vectors + double istate[PITCH_WLPCORDER]; + double weostate[PITCH_WLPCORDER]; + double whostate[PITCH_WLPCORDER]; - //state vectors - double istate[PITCH_WLPCORDER]; - double weostate[PITCH_WLPCORDER]; - double whostate[PITCH_WLPCORDER]; - - //LPC window -> should be a global array because constant - double window[PITCH_WLPCWINLEN]; + // LPC window -> should be a global array because constant + double window[PITCH_WLPCWINLEN]; } WeightFiltstr; typedef struct { + // for inital estimator + double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + PITCH_MAX_LAG / 2 - + PITCH_FRAME_LEN / 2 + 2]; + double decimator_state[2 * ALLPASSSECTIONS + 1]; + double hp_state[2]; - //for inital estimator - double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + - PITCH_MAX_LAG/2 - PITCH_FRAME_LEN/2+2]; - double decimator_state[2*ALLPASSSECTIONS+1]; - double hp_state[2]; + double whitened_buf[QLOOKAHEAD]; - double whitened_buf[QLOOKAHEAD]; + double inbuf[QLOOKAHEAD]; - double inbuf[QLOOKAHEAD]; - - PitchFiltstr PFstr_wght; - PitchFiltstr PFstr; + PitchFiltstr PFstr_wght; + PitchFiltstr PFstr; WeightFiltstr Wghtstr; } PitchAnalysisStruct; - - /* Have instance of struct together with other iSAC structs */ typedef struct { - /* Previous frame length (in ms) */ - int32_t prev_frame_length; + int32_t prev_frame_length; /* Previous RTP timestamp from received packet (in samples relative beginning) */ - int32_t prev_rec_rtp_number; + int32_t prev_rec_rtp_number; /* Send timestamp for previous packet (in ms using timeGetTime()) */ - uint32_t prev_rec_send_ts; + uint32_t prev_rec_send_ts; /* Arrival time for previous packet (in ms using timeGetTime()) */ - uint32_t prev_rec_arr_ts; + uint32_t prev_rec_arr_ts; /* rate of previous packet, derived from RTP timestamps (in bits/s) */ - float prev_rec_rtp_rate; + float prev_rec_rtp_rate; /* Time sinse the last update of the BN estimate (in ms) */ - uint32_t last_update_ts; + uint32_t last_update_ts; /* Time sinse the last reduction (in ms) */ - uint32_t last_reduction_ts; + uint32_t last_reduction_ts; /* How many times the estimate was update in the beginning */ - int32_t count_tot_updates_rec; + int32_t count_tot_updates_rec; /* The estimated bottle neck rate from there to here (in bits/s) */ - int32_t rec_bw; - float rec_bw_inv; - float rec_bw_avg; - float rec_bw_avg_Q; + int32_t rec_bw; + float rec_bw_inv; + float rec_bw_avg; + float rec_bw_avg_Q; /* The estimated mean absolute jitter value, as seen on this side (in ms) */ - float rec_jitter; - float rec_jitter_short_term; - float rec_jitter_short_term_abs; - float rec_max_delay; - float rec_max_delay_avg_Q; + float rec_jitter; + float rec_jitter_short_term; + float rec_jitter_short_term_abs; + float rec_max_delay; + float rec_max_delay_avg_Q; /* (assumed) bitrate for headers (bps) */ - float rec_header_rate; + float rec_header_rate; /* The estimated bottle neck rate from here to there (in bits/s) */ - float send_bw_avg; + float send_bw_avg; /* The estimated mean absolute jitter value, as seen on the other siee (in ms) */ - float send_max_delay_avg; + float send_max_delay_avg; // number of packets received since last update int num_pkts_rec; @@ -217,35 +205,31 @@ typedef struct { int change_to_WB; - uint32_t senderTimestamp; - uint32_t receiverTimestamp; - //enum IsacSamplingRate incomingStreamSampFreq; - uint16_t numConsecLatePkts; - float consecLatency; - int16_t inWaitLatePkts; + uint32_t senderTimestamp; + uint32_t receiverTimestamp; + // enum IsacSamplingRate incomingStreamSampFreq; + uint16_t numConsecLatePkts; + float consecLatency; + int16_t inWaitLatePkts; IsacBandwidthInfo external_bw_info; } BwEstimatorstr; - typedef struct { - /* boolean, flags if previous packet exceeded B.N. */ - int PrevExceed; + int PrevExceed; /* ms */ - int ExceedAgo; + int ExceedAgo; /* packets left to send in current burst */ - int BurstCounter; + int BurstCounter; /* packets */ - int InitCounter; + int InitCounter; /* ms remaining in buffer when next packet will be sent */ double StillBuffered; } RateModel; - typedef struct { - unsigned int SpaceAlloced; unsigned int MaxPermAlloced; double Tmp0[MAXFFTSIZE]; @@ -253,36 +237,34 @@ typedef struct { double Tmp2[MAXFFTSIZE]; double Tmp3[MAXFFTSIZE]; int Perm[MAXFFTSIZE]; - int factor [NFACTOR]; + int factor[NFACTOR]; } FFTstr; - /* The following strutc is used to store data from encoding, to make it fast and easy to construct a new bitstream with a different Bandwidth estimate. All values (except framelength and minBytes) is double size to handle 60 ms of data. */ typedef struct { - /* Used to keep track of if it is first or second part of 60 msec packet */ - int startIdx; + int startIdx; /* Frame length in samples */ int16_t framelength; /* Pitch Gain */ - int pitchGain_index[2]; + int pitchGain_index[2]; /* Pitch Lag */ - double meanGain[2]; - int pitchIndex[PITCH_SUBFRAMES*2]; + double meanGain[2]; + int pitchIndex[PITCH_SUBFRAMES * 2]; /* LPC */ - int LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */ - int LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */ - double LPCcoeffs_lo[(ORDERLO+1)*SUBFRAMES*2]; - double LPCcoeffs_hi[(ORDERHI+1)*SUBFRAMES*2]; + int LPCindex_s[108 * 2]; /* KLT_ORDER_SHAPE = 108 */ + int LPCindex_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */ + double LPCcoeffs_lo[(ORDERLO + 1) * SUBFRAMES * 2]; + double LPCcoeffs_hi[(ORDERHI + 1) * SUBFRAMES * 2]; /* Encode Spec */ int16_t fre[FRAMESAMPLES]; @@ -290,59 +272,54 @@ typedef struct { int16_t AvgPitchGain[2]; /* Used in adaptive mode only */ - int minBytes; + int minBytes; } IsacSaveEncoderData; - typedef struct { + int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; + double lpcGain[SUBFRAMES << 1]; + int lpcGainIndex[SUBFRAMES << 1]; - int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - double lpcGain[SUBFRAMES<<1]; - int lpcGainIndex[SUBFRAMES<<1]; - - Bitstr bitStreamObj; + Bitstr bitStreamObj; int16_t realFFT[FRAMESAMPLES_HALF]; int16_t imagFFT[FRAMESAMPLES_HALF]; } ISACUBSaveEncDataStruct; - - typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; - PreFiltBankstr prefiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; + Bitstr bitstr_obj; + MaskFiltstr maskfiltstr_obj; + PreFiltBankstr prefiltbankstr_obj; + PitchFiltstr pitchfiltstr_obj; PitchAnalysisStruct pitchanalysisstr_obj; - FFTstr fftstr_obj; + FFTstr fftstr_obj; IsacSaveEncoderData SaveEnc_obj; - int buffer_index; - int16_t current_framesamples; + int buffer_index; + int16_t current_framesamples; - float data_buffer_float[FRAMESAMPLES_30ms]; + float data_buffer_float[FRAMESAMPLES_30ms]; - int frame_nb; - double bottleneck; - int16_t new_framelength; - double s2nr; + int frame_nb; + double bottleneck; + int16_t new_framelength; + double s2nr; /* Maximum allowed number of bits for a 30 msec packet */ - int16_t payloadLimitBytes30; + int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec packet */ - int16_t payloadLimitBytes60; + int16_t payloadLimitBytes60; /* Maximum allowed number of bits for both 30 and 60 msec packet */ - int16_t maxPayloadBytes; + int16_t maxPayloadBytes; /* Maximum allowed rate in bytes per 30 msec packet */ - int16_t maxRateInBytes; + int16_t maxRateInBytes; /*--- If set to 1 iSAC will not addapt the frame-size, if used in channel-adaptive mode. The initial value will be used for all rates. ---*/ - int16_t enforceFrameSize; + int16_t enforceFrameSize; /*----- This records the BWE index the encoder injected into the bit-stream. @@ -351,64 +328,53 @@ typedef struct { a recursive procedure (WebRtcIsac_GetDownlinkBwJitIndexImpl) and has to be called only once per each encode. -----*/ - int16_t lastBWIdx; + int16_t lastBWIdx; } ISACLBEncStruct; typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; - PreFiltBankstr prefiltbankstr_obj; - FFTstr fftstr_obj; + Bitstr bitstr_obj; + MaskFiltstr maskfiltstr_obj; + PreFiltBankstr prefiltbankstr_obj; + FFTstr fftstr_obj; ISACUBSaveEncDataStruct SaveEnc_obj; - int buffer_index; - float data_buffer_float[MAX_FRAMESAMPLES + - LB_TOTAL_DELAY_SAMPLES]; - double bottleneck; + int buffer_index; + float data_buffer_float[MAX_FRAMESAMPLES + LB_TOTAL_DELAY_SAMPLES]; + double bottleneck; /* Maximum allowed number of bits for a 30 msec packet */ - //int16_t payloadLimitBytes30; + // int16_t payloadLimitBytes30; /* Maximum allowed number of bits for both 30 and 60 msec packet */ - //int16_t maxPayloadBytes; - int16_t maxPayloadSizeBytes; + // int16_t maxPayloadBytes; + int16_t maxPayloadSizeBytes; - double lastLPCVec[UB_LPC_ORDER]; - int16_t numBytesUsed; - int16_t lastJitterInfo; + double lastLPCVec[UB_LPC_ORDER]; + int16_t numBytesUsed; + int16_t lastJitterInfo; } ISACUBEncStruct; - - typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; + Bitstr bitstr_obj; + MaskFiltstr maskfiltstr_obj; PostFiltBankstr postfiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; - FFTstr fftstr_obj; + PitchFiltstr pitchfiltstr_obj; + FFTstr fftstr_obj; } ISACLBDecStruct; typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; + Bitstr bitstr_obj; + MaskFiltstr maskfiltstr_obj; PostFiltBankstr postfiltbankstr_obj; - FFTstr fftstr_obj; + FFTstr fftstr_obj; } ISACUBDecStruct; - - typedef struct { - ISACLBEncStruct ISACencLB_obj; ISACLBDecStruct ISACdecLB_obj; } ISACLBStruct; - typedef struct { - ISACUBEncStruct ISACencUB_obj; ISACUBDecStruct ISACdecUB_obj; } ISACUBStruct; @@ -420,14 +386,14 @@ typedef struct { */ typedef struct { /* 6 lower-band & 6 upper-band */ - double loFiltGain[SUBFRAMES]; - double hiFiltGain[SUBFRAMES]; + double loFiltGain[SUBFRAMES]; + double hiFiltGain[SUBFRAMES]; /* Upper boundary of interval W */ uint32_t W_upper; uint32_t streamval; /* Index to the current position in bytestream */ uint32_t stream_index; - uint8_t stream[3]; + uint8_t stream[3]; } transcode_obj; typedef struct { @@ -443,46 +409,46 @@ typedef struct { typedef struct { // lower-band codec instance - ISACLBStruct instLB; + ISACLBStruct instLB; // upper-band codec instance - ISACUBStruct instUB; + ISACUBStruct instUB; // Bandwidth Estimator and model for the rate. - BwEstimatorstr bwestimator_obj; - RateModel rate_data_obj; - double MaxDelay; + BwEstimatorstr bwestimator_obj; + RateModel rate_data_obj; + double MaxDelay; /* 0 = adaptive; 1 = instantaneous */ - int16_t codingMode; + int16_t codingMode; // overall bottleneck of the codec - int32_t bottleneck; + int32_t bottleneck; // QMF Filter state - int32_t analysisFBState1[FB_STATE_SIZE_WORD32]; - int32_t analysisFBState2[FB_STATE_SIZE_WORD32]; - int32_t synthesisFBState1[FB_STATE_SIZE_WORD32]; - int32_t synthesisFBState2[FB_STATE_SIZE_WORD32]; + int32_t analysisFBState1[FB_STATE_SIZE_WORD32]; + int32_t analysisFBState2[FB_STATE_SIZE_WORD32]; + int32_t synthesisFBState1[FB_STATE_SIZE_WORD32]; + int32_t synthesisFBState2[FB_STATE_SIZE_WORD32]; // Error Code - int16_t errorCode; + int16_t errorCode; // bandwidth of the encoded audio 8, 12 or 16 kHz - enum ISACBandwidth bandwidthKHz; + enum ISACBandwidth bandwidthKHz; // Sampling rate of audio, encoder and decode, 8 or 16 kHz enum IsacSamplingRate encoderSamplingRateKHz; enum IsacSamplingRate decoderSamplingRateKHz; // Flag to keep track of initializations, lower & upper-band // encoder and decoder. - int16_t initFlag; + int16_t initFlag; // Flag to to indicate signal bandwidth switch - int16_t resetFlag_8kHz; + int16_t resetFlag_8kHz; // Maximum allowed rate, measured in Bytes per 30 ms. - int16_t maxRateBytesPer30Ms; + int16_t maxRateBytesPer30Ms; // Maximum allowed payload-size, measured in Bytes. - int16_t maxPayloadSizeBytes; + int16_t maxPayloadSizeBytes; /* The expected sampling rate of the input signal. Valid values are 16000 * and 32000. This is not the operation sampling rate of the codec. */ uint16_t in_sample_rate_hz; diff --git a/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc b/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc index cedcb9d3f4..35a8832462 100644 --- a/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc +++ b/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc @@ -11,11 +11,11 @@ // ReleaseTest-API.cpp : Defines the entry point for the console application. // +#include #include #include #include #include -#include #include /* include API */ @@ -24,10 +24,13 @@ #include "rtc_base/format_macros.h" /* Defines */ -#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */ -#define MAX_FRAMESAMPLES 960 /* max number of samples per frame - (= 60 ms frame & 16 kHz) or - (= 30 ms frame & 32 kHz) */ +#define SEED_FILE \ + "randseed.txt" /* Used when running decoder on garbage data \ + */ +#define MAX_FRAMESAMPLES \ + 960 /* max number of samples per frame \ + (= 60 ms frame & 16 kHz) or \ + (= 30 ms frame & 32 kHz) */ #define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */ #define SWBFRAMESAMPLES_10ms 320 //#define FS 16000 /* sampling frequency (Hz) */ @@ -42,7 +45,7 @@ using namespace std; int main(int argc, char* argv[]) { char inname[100], outname[100], bottleneck_file[100], vadfile[100]; - FILE* inp, *outp, * f_bn = NULL, * vadp = NULL, *bandwidthp; + FILE *inp, *outp, *f_bn = NULL, *vadp = NULL, *bandwidthp; int framecnt, endfile; size_t i; @@ -230,8 +233,10 @@ int main(int argc, char* argv[]) { rateBPS = atoi(argv[i + 1]); setControlBWE = 1; if ((rateBPS < 10000) || (rateBPS > 32000)) { - printf("\n%d is not a initial rate. Valid values are in the range " - "10000 to 32000.\n", rateBPS); + printf( + "\n%d is not a initial rate. Valid values are in the range " + "10000 to 32000.\n", + rateBPS); exit(0); } printf("New initial rate: %d\n", rateBPS); @@ -242,8 +247,10 @@ int main(int argc, char* argv[]) { if (!strcmp("-FL", argv[i])) { framesize = atoi(argv[i + 1]); if ((framesize != 30) && (framesize != 60)) { - printf("\n%d is not a valid frame length. Valid length are 30 and 60 " - "msec.\n", framesize); + printf( + "\n%d is not a valid frame length. Valid length are 30 and 60 " + "msec.\n", + framesize); exit(0); } setControlBWE = 1; @@ -277,8 +284,10 @@ int main(int argc, char* argv[]) { testNum = atoi(argv[i + 1]); printf("Fault test: %d\n", testNum); if (testNum < 1 || testNum > 10) { - printf("\n%d is not a valid Fault Scenario number. Valid Fault " - "Scenarios are numbered 1-10.\n", testNum); + printf( + "\n%d is not a valid Fault Scenario number. Valid Fault " + "Scenarios are numbered 1-10.\n", + testNum); exit(0); } i++; @@ -336,8 +345,10 @@ int main(int argc, char* argv[]) { sscanf(argv[i], "%s", bottleneck_file); f_bn = fopen(bottleneck_file, "rb"); if (f_bn == NULL) { - printf("Error No value provided for BottleNeck and cannot read file " - "%s.\n", bottleneck_file); + printf( + "Error No value provided for BottleNeck and cannot read file " + "%s.\n", + bottleneck_file); exit(0); } else { printf("reading bottleneck rates from file %s\n\n", bottleneck_file); @@ -637,8 +648,8 @@ int main(int argc, char* argv[]) { } if (fwrite(streamDataTransCoding, sizeof(uint8_t), - streamLenTransCoding, transcodingBitstream) != - streamLenTransCoding) { + streamLenTransCoding, + transcodingBitstream) != streamLenTransCoding) { return -1; } @@ -718,8 +729,7 @@ int main(int argc, char* argv[]) { fprintf(stderr, "Error in RED trans-coding\n"); exit(0); } - streamLenTransCoding = - static_cast(streamLenTransCoding_int); + streamLenTransCoding = static_cast(streamLenTransCoding_int); } } diff --git a/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc b/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc index 23de079ad0..59a3ade5dd 100644 --- a/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc +++ b/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc @@ -18,16 +18,14 @@ #include "modules/audio_coding/codecs/isac/main/include/isac.h" #include "modules/audio_coding/codecs/isac/main/util/utility.h" -#define MAX_FILE_NAME 500 +#define MAX_FILE_NAME 500 #define MAX_NUM_CLIENTS 2 - #define NUM_CLIENTS 2 using namespace std; -int main(int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { char fileNameWB[MAX_FILE_NAME]; char fileNameSWB[MAX_FILE_NAME]; @@ -68,21 +66,18 @@ int main(int argc, char* argv[]) printf(" iSAC-swb version %s\n", versionNumber); printf("____________________________________________\n"); - - fileNameWB[0] = '\0'; + fileNameWB[0] = '\0'; fileNameSWB[0] = '\0'; char myFlag[20]; strcpy(myFlag, "-wb"); // READ THE WIDEBAND AND SUPER-WIDEBAND FILE NAMES - if(readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0) - { + if (readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0) { printf("No wideband file is specified"); } strcpy(myFlag, "-swb"); - if(readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0) - { + if (readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0) { printf("No super-wideband file is specified"); } @@ -97,16 +92,15 @@ int main(int argc, char* argv[]) strcpy(myFlag, "-I"); short codingMode = readSwitch(argc, argv, myFlag); - for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) - { + for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) { codecInstance[clientCntr] = NULL; printf("\n"); printf("Client %d\n", clientCntr + 1); printf("---------\n"); - printf("Starting %s", - (encoderSampRate[clientCntr] == 16000) - ? "wideband":"super-wideband"); + printf("Starting %s", (encoderSampRate[clientCntr] == 16000) + ? "wideband" + : "super-wideband"); // Open output File Name OPEN_FILE_WB(outFile[clientCntr], outFileName[clientCntr]); @@ -114,30 +108,27 @@ int main(int argc, char* argv[]) samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10; - if(codingMode == 1) - { - bottleneck[clientCntr] = (clientCntr)? bnSWB:bnWB; - } - else - { - bottleneck[clientCntr] = (clientCntr)? minBn:maxBn; + if (codingMode == 1) { + bottleneck[clientCntr] = (clientCntr) ? bnSWB : bnWB; + } else { + bottleneck[clientCntr] = (clientCntr) ? minBn : maxBn; } printf("Bottleneck....................... %0.3f kbits/sec \n", bottleneck[clientCntr] / 1000.0); // coding-mode - printf("Encoding Mode.................... %s\n", - (codingMode == 1)? "Channel-Independent (Instantaneous)":"Adaptive"); + printf( + "Encoding Mode.................... %s\n", + (codingMode == 1) ? "Channel-Independent (Instantaneous)" : "Adaptive"); lenEncodedInBytes[clientCntr] = 0; lenAudioIn10ms[clientCntr] = 0; lenEncodedInBytesTmp[clientCntr] = 0; lenAudioIn10msTmp[clientCntr] = 0; - packetData[clientCntr] = (BottleNeckModel*)new(BottleNeckModel); - if(packetData[clientCntr] == NULL) - { + packetData[clientCntr] = (BottleNeckModel*)new (BottleNeckModel); + if (packetData[clientCntr] == NULL) { printf("Could not allocate memory for packetData \n"); return -1; } @@ -145,24 +136,22 @@ int main(int argc, char* argv[]) memset(resamplerState[clientCntr], 0, sizeof(int32_t) * 8); } - for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) - { + for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) { // Create - if(WebRtcIsac_Create(&codecInstance[clientCntr])) - { + if (WebRtcIsac_Create(&codecInstance[clientCntr])) { printf("Could not creat client %d\n", clientCntr + 1); return -1; } - WebRtcIsac_SetEncSampRate(codecInstance[clientCntr], encoderSampRate[clientCntr]); + WebRtcIsac_SetEncSampRate(codecInstance[clientCntr], + encoderSampRate[clientCntr]); - WebRtcIsac_SetDecSampRate(codecInstance[clientCntr], - encoderSampRate[clientCntr + (1 - ((clientCntr & 1)<<1))]); + WebRtcIsac_SetDecSampRate( + codecInstance[clientCntr], + encoderSampRate[clientCntr + (1 - ((clientCntr & 1) << 1))]); // Initialize Encoder - if(WebRtcIsac_EncoderInit(codecInstance[clientCntr], - codingMode) < 0) - { + if (WebRtcIsac_EncoderInit(codecInstance[clientCntr], codingMode) < 0) { printf("Could not initialize client, %d\n", clientCntr + 1); return -1; } @@ -170,12 +159,10 @@ int main(int argc, char* argv[]) WebRtcIsac_DecoderInit(codecInstance[clientCntr]); // setup Rate if in Instantaneous mode - if(codingMode != 0) - { + if (codingMode != 0) { // ONLY Clients who are not in Adaptive mode - if(WebRtcIsac_Control(codecInstance[clientCntr], - bottleneck[clientCntr], 30) < 0) - { + if (WebRtcIsac_Control(codecInstance[clientCntr], bottleneck[clientCntr], + 30) < 0) { printf("Could not setup bottleneck and frame-size for client %d\n", clientCntr + 1); return -1; @@ -183,7 +170,6 @@ int main(int argc, char* argv[]) } } - size_t streamLen; short numSamplesRead; size_t lenDecodedAudio; @@ -192,7 +178,7 @@ int main(int argc, char* argv[]) printf("\n"); short num10ms[MAX_NUM_CLIENTS]; - memset(num10ms, 0, sizeof(short)*MAX_NUM_CLIENTS); + memset(num10ms, 0, sizeof(short) * MAX_NUM_CLIENTS); FILE* arrivalTimeFile1 = fopen("arrivalTime1.dat", "wb"); FILE* arrivalTimeFile2 = fopen("arrivalTime2.dat", "wb"); short numPrint[MAX_NUM_CLIENTS]; @@ -205,61 +191,60 @@ int main(int argc, char* argv[]) short audioBuff60ms[60 * 32]; short resampledAudio60ms[60 * 32]; - unsigned short bitStream[600+600]; + unsigned short bitStream[600 + 600]; short speechType[1]; short numSampFreqChanged = 0; - while(numSampFreqChanged < 10) - { - for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) - { + while (numSampFreqChanged < 10) { + for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) { // Encoding/decoding for this pair of clients, if there is // audio for any of them - //if(audioLeft[clientCntr] || audioLeft[clientCntr + 1]) + // if(audioLeft[clientCntr] || audioLeft[clientCntr + 1]) //{ - //for(pairCntr = 0; pairCntr < 2; pairCntr++) + // for(pairCntr = 0; pairCntr < 2; pairCntr++) //{ - senderIdx = clientCntr; // + pairCntr; - receiverIdx = 1 - clientCntr;// + (1 - pairCntr); + senderIdx = clientCntr; // + pairCntr; + receiverIdx = 1 - clientCntr; // + (1 - pairCntr); - //if(num10ms[senderIdx] > 6) + // if(num10ms[senderIdx] > 6) //{ // printf("Too many frames read for client %d", // senderIdx + 1); // return -1; //} - numSamplesRead = (short)fread(audioBuff10ms, sizeof(short), - samplesIn10ms[senderIdx], inFile[senderIdx]); - if(numSamplesRead != samplesIn10ms[senderIdx]) - { + numSamplesRead = + (short)fread(audioBuff10ms, sizeof(short), samplesIn10ms[senderIdx], + inFile[senderIdx]); + if (numSamplesRead != samplesIn10ms[senderIdx]) { // file finished switch encoder sampling frequency. - printf("Changing Encoder Sampling frequency in client %d to ", senderIdx+1); + printf("Changing Encoder Sampling frequency in client %d to ", + senderIdx + 1); fclose(inFile[senderIdx]); numSampFreqChanged++; - if(encoderSampRate[senderIdx] == 16000) - { + if (encoderSampRate[senderIdx] == 16000) { printf("super-wideband.\n"); OPEN_FILE_RB(inFile[senderIdx], fileNameSWB); encoderSampRate[senderIdx] = 32000; - } - else - { + } else { printf("wideband.\n"); OPEN_FILE_RB(inFile[senderIdx], fileNameWB); encoderSampRate[senderIdx] = 16000; } - WebRtcIsac_SetEncSampRate(codecInstance[senderIdx], encoderSampRate[senderIdx]); - WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx], encoderSampRate[senderIdx]); + WebRtcIsac_SetEncSampRate(codecInstance[senderIdx], + encoderSampRate[senderIdx]); + WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx], + encoderSampRate[senderIdx]); samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10; - numSamplesRead = (short)fread(audioBuff10ms, sizeof(short), - samplesIn10ms[senderIdx], inFile[senderIdx]); - if(numSamplesRead != samplesIn10ms[senderIdx]) - { + numSamplesRead = + (short)fread(audioBuff10ms, sizeof(short), samplesIn10ms[senderIdx], + inFile[senderIdx]); + if (numSamplesRead != samplesIn10ms[senderIdx]) { printf(" File %s for client %d has not enough audio\n", - (encoderSampRate[senderIdx]==16000)? "wideband":"super-wideband", + (encoderSampRate[senderIdx] == 16000) ? "wideband" + : "super-wideband", senderIdx + 1); return -1; } @@ -267,39 +252,34 @@ int main(int argc, char* argv[]) num10ms[senderIdx]++; // sanity check - //if(num10ms[senderIdx] > 6) + // if(num10ms[senderIdx] > 6) //{ - // printf("Client %d has got more than 60 ms audio and encoded no packet.\n", + // printf("Client %d has got more than 60 ms audio and encoded no + // packet.\n", // senderIdx); // return -1; //} // Encode - int streamLen_int = WebRtcIsac_Encode(codecInstance[senderIdx], - audioBuff10ms, - (uint8_t*)bitStream); + audioBuff10ms, (uint8_t*)bitStream); int16_t ggg; if (streamLen_int > 0) { if ((WebRtcIsac_ReadFrameLen( codecInstance[receiverIdx], - reinterpret_cast(bitStream), - &ggg)) < 0) + reinterpret_cast(bitStream), &ggg)) < 0) printf("ERROR\n"); } // Sanity check - if(streamLen_int < 0) - { + if (streamLen_int < 0) { printf(" Encoder error in client %d \n", senderIdx + 1); return -1; } streamLen = static_cast(streamLen_int); - - if(streamLen > 0) - { + if (streamLen > 0) { // Packet generated; model sending through a channel, do bandwidth // estimation at the receiver and decode. lenEncodedInBytes[senderIdx] += streamLen; @@ -308,32 +288,30 @@ int main(int argc, char* argv[]) lenAudioIn10msTmp[senderIdx] += (unsigned int)num10ms[senderIdx]; // Print after ~5 sec. - if(lenAudioIn10msTmp[senderIdx] >= 100) - { + if (lenAudioIn10msTmp[senderIdx] >= 100) { numPrint[senderIdx]++; - printf(" %d, %6.3f => %6.3f ", senderIdx+1, + printf(" %d, %6.3f => %6.3f ", senderIdx + 1, bottleneck[senderIdx] / 1000.0, lenEncodedInBytesTmp[senderIdx] * 0.8 / - lenAudioIn10msTmp[senderIdx]); + lenAudioIn10msTmp[senderIdx]); - if(codingMode == 0) - { + if (codingMode == 0) { int32_t bn; WebRtcIsac_GetUplinkBw(codecInstance[senderIdx], &bn); printf("[%d] ", bn); } - //int16_t rateIndexLB; - //int16_t rateIndexUB; - //WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx], + // int16_t rateIndexLB; + // int16_t rateIndexUB; + // WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx], // &rateIndexLB, &rateIndexUB); - //printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB); + // printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB); cout << flush; lenEncodedInBytesTmp[senderIdx] = 0; - lenAudioIn10msTmp[senderIdx] = 0; - //if(senderIdx == (NUM_CLIENTS - 1)) + lenAudioIn10msTmp[senderIdx] = 0; + // if(senderIdx == (NUM_CLIENTS - 1)) //{ - printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. /1000); + printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. / 1000); //} // After ~20 sec change the bottleneck. @@ -385,23 +363,20 @@ int main(int argc, char* argv[]) // model a channel of given bottleneck, to get the receive timestamp get_arrival_time(num10ms[senderIdx] * samplesIn10ms[senderIdx], - streamLen, bottleneck[senderIdx], packetData[senderIdx], - encoderSampRate[senderIdx]*1000, encoderSampRate[senderIdx]*1000); + streamLen, bottleneck[senderIdx], + packetData[senderIdx], + encoderSampRate[senderIdx] * 1000, + encoderSampRate[senderIdx] * 1000); // Write the arrival time. - if(senderIdx == 0) - { + if (senderIdx == 0) { if (fwrite(&(packetData[senderIdx]->arrival_time), - sizeof(unsigned int), - 1, arrivalTimeFile1) != 1) { + sizeof(unsigned int), 1, arrivalTimeFile1) != 1) { return -1; } - } - else - { + } else { if (fwrite(&(packetData[senderIdx]->arrival_time), - sizeof(unsigned int), - 1, arrivalTimeFile2) != 1) { + sizeof(unsigned int), 1, arrivalTimeFile2) != 1) { return -1; } } @@ -409,8 +384,7 @@ int main(int argc, char* argv[]) // BWE if (WebRtcIsac_UpdateBwEstimate( codecInstance[receiverIdx], - reinterpret_cast(bitStream), - streamLen, + reinterpret_cast(bitStream), streamLen, packetData[senderIdx]->rtp_number, packetData[senderIdx]->sample_count, packetData[senderIdx]->arrival_time) < 0) { @@ -419,34 +393,27 @@ int main(int argc, char* argv[]) } /**/ // Decode - int lenDecodedAudio_int = WebRtcIsac_Decode( - codecInstance[receiverIdx], - reinterpret_cast(bitStream), - streamLen, - audioBuff60ms, - speechType); - if(lenDecodedAudio_int < 0) - { + int lenDecodedAudio_int = + WebRtcIsac_Decode(codecInstance[receiverIdx], + reinterpret_cast(bitStream), + streamLen, audioBuff60ms, speechType); + if (lenDecodedAudio_int < 0) { printf(" Decoder error in client %d \n", receiverIdx + 1); return -1; } lenDecodedAudio = static_cast(lenDecodedAudio_int); - if(encoderSampRate[senderIdx] == 16000) - { - WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms, + if (encoderSampRate[senderIdx] == 16000) { + WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, + resampledAudio60ms, resamplerState[receiverIdx]); if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, - outFile[receiverIdx]) != - lenDecodedAudio << 1) { + outFile[receiverIdx]) != lenDecodedAudio << 1) { return -1; } - } - else - { + } else { if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, - outFile[receiverIdx]) != - lenDecodedAudio) { + outFile[receiverIdx]) != lenDecodedAudio) { return -1; } } diff --git a/modules/audio_coding/codecs/isac/main/util/utility.h b/modules/audio_coding/codecs/isac/main/util/utility.h index b5882a57fb..1acc54251b 100644 --- a/modules/audio_coding/codecs/isac/main/util/utility.h +++ b/modules/audio_coding/codecs/isac/main/util/utility.h @@ -11,134 +11,98 @@ #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_UTIL_UTILITY_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_UTIL_UTILITY_H_ -#include #include +#include #if defined(__cplusplus) extern "C" { #endif -#define OPEN_FILE_WB(filePtr, fullPath) \ - do \ - { \ - if(fullPath != NULL) \ - { \ - filePtr = fopen(fullPath, "wb"); \ - if(filePtr == NULL) \ - { \ - printf("could not open %s to write to.", fullPath); \ - return -1; \ - } \ - } \ - else \ - { \ - filePtr = NULL; \ - } \ - }while(0) +#define OPEN_FILE_WB(filePtr, fullPath) \ + do { \ + if (fullPath != NULL) { \ + filePtr = fopen(fullPath, "wb"); \ + if (filePtr == NULL) { \ + printf("could not open %s to write to.", fullPath); \ + return -1; \ + } \ + } else { \ + filePtr = NULL; \ + } \ + } while (0) -#define OPEN_FILE_AB(filePtr, fullPath) \ - do \ - { \ - if(fullPath != NULL) \ - { \ - filePtr = fopen(fullPath, "ab"); \ - if(filePtr == NULL) \ - { \ - printf("could not open %s to write to.", fullPath); \ - return -1; \ - } \ - } \ - else \ - { \ - filePtr = NULL; \ - } \ - }while(0) +#define OPEN_FILE_AB(filePtr, fullPath) \ + do { \ + if (fullPath != NULL) { \ + filePtr = fopen(fullPath, "ab"); \ + if (filePtr == NULL) { \ + printf("could not open %s to write to.", fullPath); \ + return -1; \ + } \ + } else { \ + filePtr = NULL; \ + } \ + } while (0) -#define OPEN_FILE_RB(filePtr, fullPath) \ - do \ - { \ - if(fullPath != NULL) \ - { \ - filePtr = fopen(fullPath, "rb"); \ - if(filePtr == NULL) \ - { \ - printf("could not open %s to read from.", fullPath); \ - return -1; \ - } \ - } \ - else \ - { \ - filePtr = NULL; \ - } \ - }while(0) +#define OPEN_FILE_RB(filePtr, fullPath) \ + do { \ + if (fullPath != NULL) { \ + filePtr = fopen(fullPath, "rb"); \ + if (filePtr == NULL) { \ + printf("could not open %s to read from.", fullPath); \ + return -1; \ + } \ + } else { \ + filePtr = NULL; \ + } \ + } while (0) -#define WRITE_FILE_D(bufferPtr, len, filePtr) \ - do \ - { \ - if(filePtr != NULL) \ - { \ - double dummy[1000]; \ - int cntr; \ - for(cntr = 0; cntr < (len); cntr++) \ - { \ - dummy[cntr] = (double)bufferPtr[cntr]; \ - } \ - fwrite(dummy, sizeof(double), len, filePtr); \ - fflush(filePtr); \ - } \ - } while(0) +#define WRITE_FILE_D(bufferPtr, len, filePtr) \ + do { \ + if (filePtr != NULL) { \ + double dummy[1000]; \ + int cntr; \ + for (cntr = 0; cntr < (len); cntr++) { \ + dummy[cntr] = (double)bufferPtr[cntr]; \ + } \ + fwrite(dummy, sizeof(double), len, filePtr); \ + fflush(filePtr); \ + } \ + } while (0) - typedef struct { - unsigned int whenPackGeneratedMs; - unsigned int whenPrevPackLeftMs; - unsigned int sendTimeMs ; /* milisecond */ - unsigned int arrival_time; /* samples */ - unsigned int sample_count; /* samples, also used as "send time stamp" */ - unsigned int rtp_number; - } BottleNeckModel; +typedef struct { + unsigned int whenPackGeneratedMs; + unsigned int whenPrevPackLeftMs; + unsigned int sendTimeMs; /* milisecond */ + unsigned int arrival_time; /* samples */ + unsigned int sample_count; /* samples, also used as "send time stamp" */ + unsigned int rtp_number; +} BottleNeckModel; - void get_arrival_time( - int current_framesamples, /* samples */ - size_t packet_size, /* bytes */ - int bottleneck, /* excluding headers; bits/s */ - BottleNeckModel* BN_data, - short senderSampFreqHz, - short receiverSampFreqHz); +void get_arrival_time(int current_framesamples, /* samples */ + size_t packet_size, /* bytes */ + int bottleneck, /* excluding headers; bits/s */ + BottleNeckModel* BN_data, + short senderSampFreqHz, + short receiverSampFreqHz); - /* function for reading audio data from PCM file */ - int readframe( - short* data, - FILE* inp, - int length); +/* function for reading audio data from PCM file */ +int readframe(short* data, FILE* inp, int length); - short readSwitch( - int argc, - char* argv[], - char* strID); +short readSwitch(int argc, char* argv[], char* strID); - double readParamDouble( - int argc, - char* argv[], - char* strID, - double defaultVal); +double readParamDouble(int argc, char* argv[], char* strID, double defaultVal); - int readParamInt( - int argc, - char* argv[], - char* strID, - int defaultVal); +int readParamInt(int argc, char* argv[], char* strID, int defaultVal); - int readParamString( - int argc, - char* argv[], - char* strID, - char* stringParam, - int maxSize); +int readParamString(int argc, + char* argv[], + char* strID, + char* stringParam, + int maxSize); #if defined(__cplusplus) } #endif - - #endif diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc index 6d322a8282..0bf3b19a3b 100644 --- a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc +++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc @@ -68,10 +68,9 @@ std::vector LegacyEncodedAudioFrame::SplitBySamples( split_size_bytes * timestamps_per_ms / bytes_per_ms); size_t byte_offset; uint32_t timestamp_offset; - for (byte_offset = 0, timestamp_offset = 0; - byte_offset < payload.size(); + for (byte_offset = 0, timestamp_offset = 0; byte_offset < payload.size(); byte_offset += split_size_bytes, - timestamp_offset += timestamps_per_chunk) { + timestamp_offset += timestamps_per_chunk) { split_size_bytes = std::min(split_size_bytes, payload.size() - byte_offset); rtc::Buffer new_payload(payload.data() + byte_offset, split_size_bytes); diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc index e2dd4454e1..9079bcd1dd 100644 --- a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc +++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc @@ -97,20 +97,15 @@ TEST_P(SplitBySamplesTest, PayloadSizes) { // 40 ms -> 20 + 20 ms // 50 ms -> 25 + 25 ms // 60 ms -> 30 + 30 ms - ExpectedSplit expected_splits[] = { - {10, 1, {10}}, - {20, 1, {20}}, - {30, 1, {30}}, - {40, 2, {20, 20}}, - {50, 2, {25, 25}}, - {60, 2, {30, 30}} - }; + ExpectedSplit expected_splits[] = {{10, 1, {10}}, {20, 1, {20}}, + {30, 1, {30}}, {40, 2, {20, 20}}, + {50, 2, {25, 25}}, {60, 2, {30, 30}}}; for (const auto& expected_split : expected_splits) { // The payload values are set to steadily increase (modulo 256), so that the // resulting frames can be checked and we can be reasonably certain no // sample was missed or repeated. - const auto generate_payload = [] (size_t num_bytes) { + const auto generate_payload = [](size_t num_bytes) { rtc::Buffer payload(num_bytes); uint8_t value = 0; // Allow wrap-around of value in counter below. diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index fc6d544da2..05d3b72bc4 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -613,20 +613,17 @@ AudioEncoder::EncodedInfo AudioEncoderOpusImpl::EncodeImpl( const size_t max_encoded_bytes = SufficientOutputBufferSize(); EncodedInfo info; - info.encoded_bytes = - encoded->AppendData( - max_encoded_bytes, [&] (rtc::ArrayView encoded) { - int status = WebRtcOpus_Encode( - inst_, &input_buffer_[0], - rtc::CheckedDivExact(input_buffer_.size(), - config_.num_channels), - rtc::saturated_cast(max_encoded_bytes), - encoded.data()); + info.encoded_bytes = encoded->AppendData( + max_encoded_bytes, [&](rtc::ArrayView encoded) { + int status = WebRtcOpus_Encode( + inst_, &input_buffer_[0], + rtc::CheckedDivExact(input_buffer_.size(), config_.num_channels), + rtc::saturated_cast(max_encoded_bytes), encoded.data()); - RTC_CHECK_GE(status, 0); // Fails only if fed invalid data. + RTC_CHECK_GE(status, 0); // Fails only if fed invalid data. - return static_cast(status); - }); + return static_cast(status); + }); input_buffer_.clear(); bool dtx_frame = (info.encoded_bytes <= 2); diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc index c4d37da5cf..dde20900da 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc @@ -753,8 +753,8 @@ TEST(AudioEncoderOpusTest, SetMaxPlaybackRateNb) { EXPECT_EQ(8000, config.max_playback_rate_hz); EXPECT_EQ(12000, config.bitrate_bps); - config = CreateConfigWithParameters({{"maxplaybackrate", "8000"}, - {"stereo", "1"}}); + config = CreateConfigWithParameters( + {{"maxplaybackrate", "8000"}, {"stereo", "1"}}); EXPECT_EQ(8000, config.max_playback_rate_hz); EXPECT_EQ(24000, config.bitrate_bps); } @@ -765,8 +765,8 @@ TEST(AudioEncoderOpusTest, SetMaxPlaybackRateMb) { EXPECT_EQ(8001, config.max_playback_rate_hz); EXPECT_EQ(20000, config.bitrate_bps); - config = CreateConfigWithParameters({{"maxplaybackrate", "8001"}, - {"stereo", "1"}}); + config = CreateConfigWithParameters( + {{"maxplaybackrate", "8001"}, {"stereo", "1"}}); EXPECT_EQ(8001, config.max_playback_rate_hz); EXPECT_EQ(40000, config.bitrate_bps); } @@ -777,8 +777,8 @@ TEST(AudioEncoderOpusTest, SetMaxPlaybackRateWb) { EXPECT_EQ(12001, config.max_playback_rate_hz); EXPECT_EQ(20000, config.bitrate_bps); - config = CreateConfigWithParameters({{"maxplaybackrate", "12001"}, - {"stereo", "1"}}); + config = CreateConfigWithParameters( + {{"maxplaybackrate", "12001"}, {"stereo", "1"}}); EXPECT_EQ(12001, config.max_playback_rate_hz); EXPECT_EQ(40000, config.bitrate_bps); } @@ -789,8 +789,8 @@ TEST(AudioEncoderOpusTest, SetMaxPlaybackRateSwb) { EXPECT_EQ(16001, config.max_playback_rate_hz); EXPECT_EQ(32000, config.bitrate_bps); - config = CreateConfigWithParameters({{"maxplaybackrate", "16001"}, - {"stereo", "1"}}); + config = CreateConfigWithParameters( + {{"maxplaybackrate", "16001"}, {"stereo", "1"}}); EXPECT_EQ(16001, config.max_playback_rate_hz); EXPECT_EQ(64000, config.bitrate_bps); } @@ -801,8 +801,8 @@ TEST(AudioEncoderOpusTest, SetMaxPlaybackRateFb) { EXPECT_EQ(24001, config.max_playback_rate_hz); EXPECT_EQ(32000, config.bitrate_bps); - config = CreateConfigWithParameters({{"maxplaybackrate", "24001"}, - {"stereo", "1"}}); + config = CreateConfigWithParameters( + {{"maxplaybackrate", "24001"}, {"stereo", "1"}}); EXPECT_EQ(24001, config.max_playback_rate_hz); EXPECT_EQ(64000, config.bitrate_bps); } diff --git a/modules/audio_coding/codecs/opus/opus_fec_test.cc b/modules/audio_coding/codecs/opus/opus_fec_test.cc index 4e0a17ecc1..f1983ae9c4 100644 --- a/modules/audio_coding/codecs/opus/opus_fec_test.cc +++ b/modules/audio_coding/codecs/opus/opus_fec_test.cc @@ -83,8 +83,8 @@ void OpusFecTest::SetUp() { rewind(fp); // Allocate memory to contain the whole file. - in_data_.reset(new int16_t[loop_length_samples_ + - block_length_sample_ * channels_]); + in_data_.reset( + new int16_t[loop_length_samples_ + block_length_sample_ * channels_]); // Copy the file into the buffer. ASSERT_EQ(fread(&in_data_[0], sizeof(int16_t), loop_length_samples_, fp), @@ -130,14 +130,12 @@ OpusFecTest::OpusFecTest() max_bytes_(0), encoded_bytes_(0), opus_encoder_(NULL), - opus_decoder_(NULL) { -} + opus_decoder_(NULL) {} void OpusFecTest::EncodeABlock() { - int value = WebRtcOpus_Encode(opus_encoder_, - &in_data_[data_pointer_], - block_length_sample_, - max_bytes_, &bit_stream_[0]); + int value = + WebRtcOpus_Encode(opus_encoder_, &in_data_[data_pointer_], + block_length_sample_, max_bytes_, &bit_stream_[0]); EXPECT_GT(value, 0); encoded_bytes_ = static_cast(value); @@ -151,9 +149,9 @@ void OpusFecTest::DecodeABlock(bool lost_previous, bool lost_current) { // Decode previous frame. if (!lost_current && WebRtcOpus_PacketHasFec(&bit_stream_[0], encoded_bytes_) == 1) { - value_1 = WebRtcOpus_DecodeFec(opus_decoder_, &bit_stream_[0], - encoded_bytes_, &out_data_[0], - &audio_type); + value_1 = + WebRtcOpus_DecodeFec(opus_decoder_, &bit_stream_[0], encoded_bytes_, + &out_data_[0], &audio_type); } else { value_1 = WebRtcOpus_DecodePlc(opus_decoder_, &out_data_[0], 1); } @@ -173,16 +171,14 @@ TEST_P(OpusFecTest, RandomPacketLossTest) { int time_now_ms, fec_frames; int actual_packet_loss_rate; bool lost_current, lost_previous; - mode mode_set[3] = {{true, 0}, - {false, 0}, - {true, 50}}; + mode mode_set[3] = {{true, 0}, {false, 0}, {true, 50}}; lost_current = false; for (int i = 0; i < 3; i++) { if (mode_set[i].fec) { EXPECT_EQ(0, WebRtcOpus_EnableFec(opus_encoder_)); - EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, - mode_set[i].target_packet_loss_rate)); + EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate( + opus_encoder_, mode_set[i].target_packet_loss_rate)); printf("FEC is ON, target at packet loss rate %d percent.\n", mode_set[i].target_packet_loss_rate); } else { @@ -218,7 +214,7 @@ TEST_P(OpusFecTest, RandomPacketLossTest) { // |data_pointer_| is incremented and wrapped across // |loop_length_samples_|. data_pointer_ = (data_pointer_ + block_length_sample_ * channels_) % - loop_length_samples_; + loop_length_samples_; } if (mode_set[i].fec) { printf("%.2f percent frames has FEC.\n", @@ -242,7 +238,6 @@ const coding_param param_set[] = { string("pcm"))}; // 64 kbps, stereo -INSTANTIATE_TEST_CASE_P(AllTest, OpusFecTest, - ::testing::ValuesIn(param_set)); +INSTANTIATE_TEST_CASE_P(AllTest, OpusFecTest, ::testing::ValuesIn(param_set)); } // namespace webrtc diff --git a/modules/audio_coding/codecs/opus/opus_inst.h b/modules/audio_coding/codecs/opus/opus_inst.h index 066fa2267f..2473a5c753 100644 --- a/modules/audio_coding/codecs/opus/opus_inst.h +++ b/modules/audio_coding/codecs/opus/opus_inst.h @@ -32,5 +32,4 @@ struct WebRtcOpusDecInst { int in_dtx_mode; }; - #endif // MODULES_AUDIO_CODING_CODECS_OPUS_OPUS_INST_H_ diff --git a/modules/audio_coding/codecs/opus/opus_interface.h b/modules/audio_coding/codecs/opus/opus_interface.h index 4b8e892344..0b1c64d62f 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.h +++ b/modules/audio_coding/codecs/opus/opus_interface.h @@ -318,8 +318,10 @@ void WebRtcOpus_DecoderInit(OpusDecInst* inst); * Return value : >0 - Samples per channel in decoded vector * -1 - Error */ -int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded, - size_t encoded_bytes, int16_t* decoded, +int WebRtcOpus_Decode(OpusDecInst* inst, + const uint8_t* encoded, + size_t encoded_bytes, + int16_t* decoded, int16_t* audio_type); /**************************************************************************** @@ -336,7 +338,8 @@ int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded, * Return value : >0 - number of samples in decoded PLC vector * -1 - Error */ -int WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded, +int WebRtcOpus_DecodePlc(OpusDecInst* inst, + int16_t* decoded, int number_of_lost_frames); /**************************************************************************** @@ -357,8 +360,10 @@ int WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded, * 0 - No FEC data in the packet * -1 - Error */ -int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded, - size_t encoded_bytes, int16_t* decoded, +int WebRtcOpus_DecodeFec(OpusDecInst* inst, + const uint8_t* encoded, + size_t encoded_bytes, + int16_t* decoded, int16_t* audio_type); /**************************************************************************** diff --git a/modules/audio_coding/codecs/opus/opus_speed_test.cc b/modules/audio_coding/codecs/opus/opus_speed_test.cc index ca46aa1b16..03b59ed32e 100644 --- a/modules/audio_coding/codecs/opus/opus_speed_test.cc +++ b/modules/audio_coding/codecs/opus/opus_speed_test.cc @@ -23,9 +23,12 @@ class OpusSpeedTest : public AudioCodecSpeedTest { OpusSpeedTest(); void SetUp() override; void TearDown() override; - float EncodeABlock(int16_t* in_data, uint8_t* bit_stream, - size_t max_bytes, size_t* encoded_bytes) override; - float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes, + float EncodeABlock(int16_t* in_data, + uint8_t* bit_stream, + size_t max_bytes, + size_t* encoded_bytes) override; + float DecodeABlock(const uint8_t* bit_stream, + size_t encoded_bytes, int16_t* out_data) override; WebRtcOpusEncInst* opus_encoder_; WebRtcOpusDecInst* opus_decoder_; @@ -36,8 +39,7 @@ OpusSpeedTest::OpusSpeedTest() kOpusSamplingKhz, kOpusSamplingKhz), opus_encoder_(NULL), - opus_decoder_(NULL) { -} + opus_decoder_(NULL) {} void OpusSpeedTest::SetUp() { AudioCodecSpeedTest::SetUp(); @@ -57,12 +59,13 @@ void OpusSpeedTest::TearDown() { EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); } -float OpusSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, - size_t max_bytes, size_t* encoded_bytes) { +float OpusSpeedTest::EncodeABlock(int16_t* in_data, + uint8_t* bit_stream, + size_t max_bytes, + size_t* encoded_bytes) { clock_t clocks = clock(); - int value = WebRtcOpus_Encode(opus_encoder_, in_data, - input_length_sample_, max_bytes, - bit_stream); + int value = WebRtcOpus_Encode(opus_encoder_, in_data, input_length_sample_, + max_bytes, bit_stream); clocks = clock() - clocks; EXPECT_GT(value, 0); *encoded_bytes = static_cast(value); @@ -70,7 +73,8 @@ float OpusSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, } float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream, - size_t encoded_bytes, int16_t* out_data) { + size_t encoded_bytes, + int16_t* out_data) { int value; int16_t audio_type; clock_t clocks = clock(); @@ -84,13 +88,13 @@ float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream, /* Test audio length in second. */ constexpr size_t kDurationSec = 400; -#define ADD_TEST(complexity) \ -TEST_P(OpusSpeedTest, OpusSetComplexityTest##complexity) { \ - /* Set complexity. */ \ - printf("Setting complexity to %d ...\n", complexity); \ - EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, complexity)); \ - EncodeDecode(kDurationSec); \ -} +#define ADD_TEST(complexity) \ + TEST_P(OpusSpeedTest, OpusSetComplexityTest##complexity) { \ + /* Set complexity. */ \ + printf("Setting complexity to %d ...\n", complexity); \ + EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, complexity)); \ + EncodeDecode(kDurationSec); \ + } ADD_TEST(10); ADD_TEST(9); @@ -136,7 +140,6 @@ const coding_param param_set[] = { string("pcm"), true)}; -INSTANTIATE_TEST_CASE_P(AllTest, OpusSpeedTest, - ::testing::ValuesIn(param_set)); +INSTANTIATE_TEST_CASE_P(AllTest, OpusSpeedTest, ::testing::ValuesIn(param_set)); } // namespace webrtc diff --git a/modules/audio_coding/codecs/opus/opus_unittest.cc b/modules/audio_coding/codecs/opus/opus_unittest.cc index 12a15853c9..034f8cd203 100644 --- a/modules/audio_coding/codecs/opus/opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_unittest.cc @@ -58,9 +58,12 @@ class OpusTest : public TestWithParam<::testing::tuple> { int16_t* audio_type); void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, - opus_int32 expect, int32_t set); + opus_int32 expect, + int32_t set); - void CheckAudioBounded(const int16_t* audio, size_t samples, size_t channels, + void CheckAudioBounded(const int16_t* audio, + size_t samples, + size_t channels, uint16_t bound) const; WebRtcOpusEncInst* opus_encoder_; @@ -78,15 +81,15 @@ OpusTest::OpusTest() opus_decoder_(NULL), encoded_bytes_(0), channels_(static_cast(::testing::get<0>(GetParam()))), - application_(::testing::get<1>(GetParam())) { -} + application_(::testing::get<1>(GetParam())) {} -void OpusTest::PrepareSpeechData(size_t channel, int block_length_ms, +void OpusTest::PrepareSpeechData(size_t channel, + int block_length_ms, int loop_length_ms) { - const std::string file_name = - webrtc::test::ResourcePath((channel == 1) ? - "audio_coding/testfile32kHz" : - "audio_coding/teststereo32kHz", "pcm"); + const std::string file_name = webrtc::test::ResourcePath( + (channel == 1) ? "audio_coding/testfile32kHz" + : "audio_coding/teststereo32kHz", + "pcm"); if (loop_length_ms < block_length_ms) { loop_length_ms = block_length_ms; } @@ -100,13 +103,14 @@ void OpusTest::SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, int32_t set) { opus_int32 bandwidth; EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, set)); - opus_encoder_ctl(opus_encoder_->encoder, - OPUS_GET_MAX_BANDWIDTH(&bandwidth)); + opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_MAX_BANDWIDTH(&bandwidth)); EXPECT_EQ(expect, bandwidth); } -void OpusTest::CheckAudioBounded(const int16_t* audio, size_t samples, - size_t channels, uint16_t bound) const { +void OpusTest::CheckAudioBounded(const int16_t* audio, + size_t samples, + size_t channels, + uint16_t bound) const { for (size_t i = 0; i < samples; ++i) { for (size_t c = 0; c < channels; ++c) { ASSERT_GE(audio[i * channels + c], -bound); @@ -120,16 +124,15 @@ int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, WebRtcOpusDecInst* decoder, int16_t* output_audio, int16_t* audio_type) { - int encoded_bytes_int = WebRtcOpus_Encode( - encoder, input_audio.data(), - rtc::CheckedDivExact(input_audio.size(), channels_), - kMaxBytes, bitstream_); + int encoded_bytes_int = + WebRtcOpus_Encode(encoder, input_audio.data(), + rtc::CheckedDivExact(input_audio.size(), channels_), + kMaxBytes, bitstream_); EXPECT_GE(encoded_bytes_int, 0); encoded_bytes_ = static_cast(encoded_bytes_int); int est_len = WebRtcOpus_DurationEst(decoder, bitstream_, encoded_bytes_); - int act_len = WebRtcOpus_Decode(decoder, bitstream_, - encoded_bytes_, output_audio, - audio_type); + int act_len = WebRtcOpus_Decode(decoder, bitstream_, encoded_bytes_, + output_audio, audio_type); EXPECT_EQ(est_len, act_len); return act_len; } @@ -141,30 +144,28 @@ void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) { const size_t samples = kOpusRateKhz * block_length_ms; // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); // Set bitrate. - EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, - channels_ == 1 ? 32000 : 64000)); + EXPECT_EQ( + 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000)); // Set input audio as silence. std::vector silence(samples * channels_, 0); // Setting DTX. - EXPECT_EQ(0, dtx ? WebRtcOpus_EnableDtx(opus_encoder_) : - WebRtcOpus_DisableDtx(opus_encoder_)); + EXPECT_EQ(0, dtx ? WebRtcOpus_EnableDtx(opus_encoder_) + : WebRtcOpus_DisableDtx(opus_encoder_)); int16_t audio_type; int16_t* output_data_decode = new int16_t[samples * channels_]; for (int i = 0; i < 100; ++i) { - EXPECT_EQ(samples, - static_cast(EncodeDecode( - opus_encoder_, speech_data_.GetNextBlock(), opus_decoder_, - output_data_decode, &audio_type))); + EXPECT_EQ(samples, static_cast(EncodeDecode( + opus_encoder_, speech_data_.GetNextBlock(), + opus_decoder_, output_data_decode, &audio_type))); // If not DTX, it should never enter DTX mode. If DTX, we do not care since // whether it enters DTX depends on the signal type. if (!dtx) { @@ -178,10 +179,9 @@ void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) { // We input some silent segments. In DTX mode, the encoder will stop sending. // However, DTX may happen after a while. for (int i = 0; i < 30; ++i) { - EXPECT_EQ(samples, - static_cast(EncodeDecode( - opus_encoder_, silence, opus_decoder_, output_data_decode, - &audio_type))); + EXPECT_EQ(samples, static_cast( + EncodeDecode(opus_encoder_, silence, opus_decoder_, + output_data_decode, &audio_type))); if (!dtx) { EXPECT_GT(encoded_bytes_, 1U); EXPECT_EQ(0, opus_encoder_->in_dtx_mode); @@ -227,10 +227,9 @@ void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) { int i = 0; for (; i < max_dtx_frames; ++i) { time += block_length_ms; - EXPECT_EQ(samples, - static_cast(EncodeDecode( - opus_encoder_, silence, opus_decoder_, output_data_decode, - &audio_type))); + EXPECT_EQ(samples, static_cast( + EncodeDecode(opus_encoder_, silence, opus_decoder_, + output_data_decode, &audio_type))); if (dtx) { if (encoded_bytes_ > 1) break; @@ -263,10 +262,9 @@ void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) { // Enters DTX again immediately. time += block_length_ms; - EXPECT_EQ(samples, - static_cast(EncodeDecode( - opus_encoder_, silence, opus_decoder_, output_data_decode, - &audio_type))); + EXPECT_EQ(samples, static_cast( + EncodeDecode(opus_encoder_, silence, opus_decoder_, + output_data_decode, &audio_type))); if (dtx) { EXPECT_EQ(1U, encoded_bytes_); // Send 1 byte. EXPECT_EQ(1, opus_encoder_->in_dtx_mode); @@ -287,10 +285,9 @@ void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) { silence[0] = 10000; if (dtx) { // Verify that encoder/decoder can jump out from DTX mode. - EXPECT_EQ(samples, - static_cast(EncodeDecode( - opus_encoder_, silence, opus_decoder_, output_data_decode, - &audio_type))); + EXPECT_EQ(samples, static_cast( + EncodeDecode(opus_encoder_, silence, opus_decoder_, + output_data_decode, &audio_type))); EXPECT_GT(encoded_bytes_, 1U); EXPECT_EQ(0, opus_encoder_->in_dtx_mode); EXPECT_EQ(0, opus_decoder_->in_dtx_mode); @@ -375,9 +372,8 @@ TEST(OpusTest, OpusFreeFail) { // Test normal Create and Free. TEST_P(OpusTest, OpusCreateFree) { - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); EXPECT_TRUE(opus_encoder_ != NULL); EXPECT_TRUE(opus_decoder_ != NULL); @@ -390,23 +386,20 @@ TEST_P(OpusTest, OpusEncodeDecode) { PrepareSpeechData(channels_, 20, 20); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); - EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, - channels_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); + EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); // Set bitrate. - EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, - channels_ == 1 ? 32000 : 64000)); + EXPECT_EQ( + 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000)); // Check number of channels for decoder. EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_)); // Check application mode. opus_int32 app; - opus_encoder_ctl(opus_encoder_->encoder, - OPUS_GET_APPLICATION(&app)); + opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_APPLICATION(&app)); EXPECT_EQ(application_ == 0 ? OPUS_APPLICATION_VOIP : OPUS_APPLICATION_AUDIO, app); @@ -429,9 +422,8 @@ TEST_P(OpusTest, OpusSetBitRate) { EXPECT_EQ(-1, WebRtcOpus_SetBitRate(opus_encoder_, 60000)); // Create encoder memory, try with different bitrates. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 30000)); EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 60000)); EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 300000)); @@ -446,9 +438,8 @@ TEST_P(OpusTest, OpusSetComplexity) { EXPECT_EQ(-1, WebRtcOpus_SetComplexity(opus_encoder_, 9)); // Create encoder memory, try with different complexities. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 0)); EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 10)); @@ -524,9 +515,8 @@ TEST_P(OpusTest, OpusDecodeInit) { PrepareSpeechData(channels_, 20, 20); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); // Encode & decode. @@ -540,9 +530,9 @@ TEST_P(OpusTest, OpusDecodeInit) { WebRtcOpus_DecoderInit(opus_decoder_); EXPECT_EQ(kOpus20msFrameSamples, - static_cast(WebRtcOpus_Decode( - opus_decoder_, bitstream_, encoded_bytes_, output_data_decode, - &audio_type))); + static_cast( + WebRtcOpus_Decode(opus_decoder_, bitstream_, encoded_bytes_, + output_data_decode, &audio_type))); // Free memory. delete[] output_data_decode; @@ -556,9 +546,8 @@ TEST_P(OpusTest, OpusEnableDisableFec) { EXPECT_EQ(-1, WebRtcOpus_DisableFec(opus_encoder_)); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_EnableFec(opus_encoder_)); EXPECT_EQ(0, WebRtcOpus_DisableFec(opus_encoder_)); @@ -573,30 +562,25 @@ TEST_P(OpusTest, OpusEnableDisableDtx) { EXPECT_EQ(-1, WebRtcOpus_DisableDtx(opus_encoder_)); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); opus_int32 dtx; // DTX is off by default. - opus_encoder_ctl(opus_encoder_->encoder, - OPUS_GET_DTX(&dtx)); + opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_DTX(&dtx)); EXPECT_EQ(0, dtx); // Test to enable DTX. EXPECT_EQ(0, WebRtcOpus_EnableDtx(opus_encoder_)); - opus_encoder_ctl(opus_encoder_->encoder, - OPUS_GET_DTX(&dtx)); + opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_DTX(&dtx)); EXPECT_EQ(1, dtx); // Test to disable DTX. EXPECT_EQ(0, WebRtcOpus_DisableDtx(opus_encoder_)); - opus_encoder_ctl(opus_encoder_->encoder, - OPUS_GET_DTX(&dtx)); + opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_DTX(&dtx)); EXPECT_EQ(0, dtx); - // Free memory. EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); } @@ -630,9 +614,8 @@ TEST_P(OpusTest, OpusSetPacketLossRate) { EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, -1)); @@ -647,9 +630,8 @@ TEST_P(OpusTest, OpusSetMaxPlaybackRate) { EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, 20000)); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 48000); SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 24001); @@ -671,14 +653,13 @@ TEST_P(OpusTest, OpusDecodePlc) { PrepareSpeechData(channels_, 20, 20); // Create encoder memory. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); // Set bitrate. - EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, - channels_== 1 ? 32000 : 64000)); + EXPECT_EQ( + 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000)); // Check number of channels for decoder. EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_)); @@ -693,9 +674,8 @@ TEST_P(OpusTest, OpusDecodePlc) { // Call decoder PLC. int16_t* plc_buffer = new int16_t[kOpus20msFrameSamples * channels_]; - EXPECT_EQ(kOpus20msFrameSamples, - static_cast(WebRtcOpus_DecodePlc( - opus_decoder_, plc_buffer, 1))); + EXPECT_EQ(kOpus20msFrameSamples, static_cast(WebRtcOpus_DecodePlc( + opus_decoder_, plc_buffer, 1))); // Free memory. delete[] plc_buffer; @@ -709,34 +689,33 @@ TEST_P(OpusTest, OpusDurationEstimation) { PrepareSpeechData(channels_, 20, 20); // Create. - EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); + EXPECT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); // 10 ms. We use only first 10 ms of a 20 ms block. auto speech_block = speech_data_.GetNextBlock(); int encoded_bytes_int = WebRtcOpus_Encode( opus_encoder_, speech_block.data(), - rtc::CheckedDivExact(speech_block.size(), 2 * channels_), - kMaxBytes, bitstream_); + rtc::CheckedDivExact(speech_block.size(), 2 * channels_), kMaxBytes, + bitstream_); EXPECT_GE(encoded_bytes_int, 0); - EXPECT_EQ(kOpus10msFrameSamples, - static_cast(WebRtcOpus_DurationEst( - opus_decoder_, bitstream_, - static_cast(encoded_bytes_int)))); + EXPECT_EQ( + kOpus10msFrameSamples, + static_cast(WebRtcOpus_DurationEst( + opus_decoder_, bitstream_, static_cast(encoded_bytes_int)))); // 20 ms speech_block = speech_data_.GetNextBlock(); - encoded_bytes_int = WebRtcOpus_Encode( - opus_encoder_, speech_block.data(), - rtc::CheckedDivExact(speech_block.size(), channels_), - kMaxBytes, bitstream_); + encoded_bytes_int = + WebRtcOpus_Encode(opus_encoder_, speech_block.data(), + rtc::CheckedDivExact(speech_block.size(), channels_), + kMaxBytes, bitstream_); EXPECT_GE(encoded_bytes_int, 0); - EXPECT_EQ(kOpus20msFrameSamples, - static_cast(WebRtcOpus_DurationEst( - opus_decoder_, bitstream_, - static_cast(encoded_bytes_int)))); + EXPECT_EQ( + kOpus20msFrameSamples, + static_cast(WebRtcOpus_DurationEst( + opus_decoder_, bitstream_, static_cast(encoded_bytes_int)))); // Free memory. EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); @@ -749,15 +728,13 @@ TEST_P(OpusTest, OpusDecodeRepacketized) { PrepareSpeechData(channels_, 20, 20 * kPackets); // Create encoder memory. - ASSERT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, - channels_, - application_)); - ASSERT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, - channels_)); + ASSERT_EQ(0, + WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_)); + ASSERT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); // Set bitrate. - EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, - channels_ == 1 ? 32000 : 64000)); + EXPECT_EQ( + 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000)); // Check number of channels for decoder. EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_)); @@ -776,9 +753,9 @@ TEST_P(OpusTest, OpusDecodeRepacketized) { WebRtcOpus_Encode(opus_encoder_, speech_block.data(), rtc::CheckedDivExact(speech_block.size(), channels_), kMaxBytes, bitstream_); - if (opus_repacketizer_cat( - rp, bitstream_, - rtc::checked_cast(encoded_bytes_)) == OPUS_OK) { + if (opus_repacketizer_cat(rp, bitstream_, + rtc::checked_cast(encoded_bytes_)) == + OPUS_OK) { ++num_packets; if (num_packets == kPackets) { break; @@ -798,9 +775,9 @@ TEST_P(OpusTest, OpusDecodeRepacketized) { opus_decoder_, bitstream_, encoded_bytes_))); EXPECT_EQ(kOpus20msFrameSamples * kPackets, - static_cast(WebRtcOpus_Decode( - opus_decoder_, bitstream_, encoded_bytes_, - output_data_decode.get(), &audio_type))); + static_cast( + WebRtcOpus_Decode(opus_decoder_, bitstream_, encoded_bytes_, + output_data_decode.get(), &audio_type))); // Free memory. opus_repacketizer_destroy(rp); @@ -812,5 +789,4 @@ INSTANTIATE_TEST_CASE_P(VariousMode, OpusTest, Combine(Values(1, 2), Values(0, 1))); - } // namespace webrtc diff --git a/modules/audio_coding/codecs/pcm16b/pcm16b.h b/modules/audio_coding/codecs/pcm16b/pcm16b.h index 041701a4b5..9a3bfe90fa 100644 --- a/modules/audio_coding/codecs/pcm16b/pcm16b.h +++ b/modules/audio_coding/codecs/pcm16b/pcm16b.h @@ -38,9 +38,7 @@ extern "C" { * Always equal to twice the len input parameter. */ -size_t WebRtcPcm16b_Encode(const int16_t* speech, - size_t len, - uint8_t* encoded); +size_t WebRtcPcm16b_Encode(const int16_t* speech, size_t len, uint8_t* encoded); /**************************************************************************** * WebRtcPcm16b_Decode(...) @@ -57,9 +55,7 @@ size_t WebRtcPcm16b_Encode(const int16_t* speech, * Returned value : Samples in speech */ -size_t WebRtcPcm16b_Decode(const uint8_t* encoded, - size_t len, - int16_t* speech); +size_t WebRtcPcm16b_Decode(const uint8_t* encoded, size_t len, int16_t* speech); #ifdef __cplusplus } diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc index cd62069901..2601f26e44 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -58,10 +58,8 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl( uint32_t rtp_timestamp, rtc::ArrayView audio, rtc::Buffer* encoded) { - const size_t primary_offset = encoded->size(); - EncodedInfo info = - speech_encoder_->Encode(rtp_timestamp, audio, encoded); + EncodedInfo info = speech_encoder_->Encode(rtp_timestamp, audio, encoded); RTC_CHECK(info.redundant.empty()) << "Cannot use nested redundant encoders."; RTC_DCHECK_EQ(encoded->size() - primary_offset, info.encoded_bytes); diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc index 890ac22f06..0f5a811bad 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc @@ -48,9 +48,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { .WillRepeatedly(Return(sample_rate_hz_)); } - void TearDown() override { - red_.reset(); - } + void TearDown() override { red_.reset(); } void Encode() { ASSERT_TRUE(red_.get() != NULL); @@ -73,8 +71,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { const int red_payload_type_; }; -TEST_F(AudioEncoderCopyRedTest, CreateAndDestroy) { -} +TEST_F(AudioEncoderCopyRedTest, CreateAndDestroy) {} TEST_F(AudioEncoderCopyRedTest, CheckSampleRatePropagation) { EXPECT_CALL(*mock_encoder_, SampleRateHz()).WillOnce(Return(17)); diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc index d3749c142e..c539152212 100644 --- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc +++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc @@ -34,8 +34,7 @@ AudioCodecSpeedTest::AudioCodecSpeedTest(int block_duration_ms, encoded_bytes_(0), encoding_time_ms_(0.0), decoding_time_ms_(0.0), - out_file_(NULL) { -} + out_file_(NULL) {} void AudioCodecSpeedTest::SetUp() { channels_ = get<0>(GetParam()); @@ -52,8 +51,8 @@ void AudioCodecSpeedTest::SetUp() { rewind(fp); // Allocate memory to contain the whole file. - in_data_.reset(new int16_t[loop_length_samples_ + - input_length_sample_ * channels_]); + in_data_.reset( + new int16_t[loop_length_samples_ + input_length_sample_ * channels_]); data_pointer_ = 0; @@ -111,11 +110,11 @@ void AudioCodecSpeedTest::EncodeDecode(size_t audio_duration_sec) { time_ms = DecodeABlock(&bit_stream_[0], encoded_bytes_, &out_data_[0]); decoding_time_ms_ += time_ms; if (save_out_data_) { - fwrite(&out_data_[0], sizeof(int16_t), - output_length_sample_ * channels_, out_file_); + fwrite(&out_data_[0], sizeof(int16_t), output_length_sample_ * channels_, + out_file_); } data_pointer_ = (data_pointer_ + input_length_sample_ * channels_) % - loop_length_samples_; + loop_length_samples_; time_now_ms += block_duration_ms_; } diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.h b/modules/audio_coding/codecs/tools/audio_codec_speed_test.h index 9e616e789b..0214a7d90f 100644 --- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.h +++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.h @@ -36,15 +36,18 @@ class AudioCodecSpeedTest : public testing::TestWithParam { // 2. save the bit stream to |bit_stream| of |max_bytes| bytes in size, // 3. assign |encoded_bytes| with the length of the bit stream (in bytes), // 4. return the cost of time (in millisecond) spent on actual encoding. - virtual float EncodeABlock(int16_t* in_data, uint8_t* bit_stream, - size_t max_bytes, size_t* encoded_bytes) = 0; + virtual float EncodeABlock(int16_t* in_data, + uint8_t* bit_stream, + size_t max_bytes, + size_t* encoded_bytes) = 0; // DecodeABlock(...) does the following: // 1. decodes the bit stream in |bit_stream| with a length of |encoded_bytes| // (in bytes), // 2. save the decoded audio in |out_data|, // 3. return the cost of time (in millisecond) spent on actual decoding. - virtual float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes, + virtual float DecodeABlock(const uint8_t* bit_stream, + size_t encoded_bytes, int16_t* out_data) = 0; // Encoding and decode an audio of |audio_duration| (in seconds) and diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h index dfbe45978f..a5ad4ffac8 100644 --- a/modules/audio_coding/include/audio_coding_module.h +++ b/modules/audio_coding/include/audio_coding_module.h @@ -127,8 +127,10 @@ class AudioCodingModule { // -1 if no codec matches the given parameters. // 0 if succeeded. // - static int Codec(const char* payload_name, CodecInst* codec, - int sampling_freq_hz, size_t channels); + static int Codec(const char* payload_name, + CodecInst* codec, + int sampling_freq_hz, + size_t channels); /////////////////////////////////////////////////////////////////////////// // int32_t Codec() @@ -146,7 +148,8 @@ class AudioCodingModule { // if the codec is found, the index of the codec in the list, // -1 if the codec is not found. // - static int Codec(const char* payload_name, int sampling_freq_hz, + static int Codec(const char* payload_name, + int sampling_freq_hz, size_t channels); /////////////////////////////////////////////////////////////////////////// @@ -398,8 +401,8 @@ class AudioCodingModule { // 0 if succeeded. // virtual int32_t SetVAD(const bool enable_dtx = true, - const bool enable_vad = false, - const ACMVADMode vad_mode = VADNormal) = 0; + const bool enable_vad = false, + const ACMVADMode vad_mode = VADNormal) = 0; /////////////////////////////////////////////////////////////////////////// // int32_t VAD() @@ -416,8 +419,9 @@ class AudioCodingModule { // -1 if fails to retrieve the setting of DTX/VAD, // 0 if succeeded. // - virtual int32_t VAD(bool* dtx_enabled, bool* vad_enabled, - ACMVADMode* vad_mode) const = 0; + virtual int32_t VAD(bool* dtx_enabled, + bool* vad_enabled, + ACMVADMode* vad_mode) const = 0; /////////////////////////////////////////////////////////////////////////// // int32_t RegisterVADCallback() @@ -527,8 +531,7 @@ class AudioCodingModule { // -1 if fails to unregister. // 0 if the given codec is successfully unregistered. // - virtual int UnregisterReceiveCodec( - uint8_t payload_type) = 0; + virtual int UnregisterReceiveCodec(uint8_t payload_type) = 0; /////////////////////////////////////////////////////////////////////////// // int32_t ReceiveCodec() diff --git a/modules/audio_coding/include/audio_coding_module_typedefs.h b/modules/audio_coding/include/audio_coding_module_typedefs.h index 85a6bf932f..e8f80dc481 100644 --- a/modules/audio_coding/include/audio_coding_module_typedefs.h +++ b/modules/audio_coding/include/audio_coding_module_typedefs.h @@ -41,8 +41,8 @@ enum ACMVADMode { // kAudio : optimized for non-voice signals like music. // enum OpusApplicationMode { - kVoip = 0, - kAudio = 1, + kVoip = 0, + kAudio = 1, }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/accelerate.h b/modules/audio_coding/neteq/accelerate.h index bf4f0f7266..6d5b11515a 100644 --- a/modules/audio_coding/neteq/accelerate.h +++ b/modules/audio_coding/neteq/accelerate.h @@ -29,10 +29,10 @@ class BackgroundNoise; // Accelerate are implemented. class Accelerate : public TimeStretch { public: - Accelerate(int sample_rate_hz, size_t num_channels, + Accelerate(int sample_rate_hz, + size_t num_channels, const BackgroundNoise& background_noise) - : TimeStretch(sample_rate_hz, num_channels, background_noise) { - } + : TimeStretch(sample_rate_hz, num_channels, background_noise) {} // This method performs the actual Accelerate operation. The samples are // read from |input|, of length |input_length| elements, and are written to diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc index e8f7a4a4af..54ede6f4e3 100644 --- a/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -114,7 +114,7 @@ class AudioDecoderTest : public ::testing::Test { decoder_ = NULL; } - virtual void InitEncoder() { } + virtual void InitEncoder() {} // TODO(henrik.lundin) Change return type to size_t once most/all overriding // implementations are gone. @@ -136,12 +136,13 @@ class AudioDecoderTest : public ::testing::Test { samples_per_10ms, channels_, interleaved_input.get()); - encoded_info = audio_encoder_->Encode( - 0, rtc::ArrayView(interleaved_input.get(), - audio_encoder_->NumChannels() * - audio_encoder_->SampleRateHz() / - 100), - output); + encoded_info = + audio_encoder_->Encode(0, + rtc::ArrayView( + interleaved_input.get(), + audio_encoder_->NumChannels() * + audio_encoder_->SampleRateHz() / 100), + output); } EXPECT_EQ(payload_type_, encoded_info.payload_type); return static_cast(encoded_info.encoded_bytes); @@ -152,11 +153,14 @@ class AudioDecoderTest : public ::testing::Test { // with |mse|. The encoded stream should contain |expected_bytes|. For stereo // audio, the absolute difference between the two channels is compared vs // |channel_diff_tolerance|. - void EncodeDecodeTest(size_t expected_bytes, int tolerance, double mse, - int delay = 0, int channel_diff_tolerance = 0) { + void EncodeDecodeTest(size_t expected_bytes, + int tolerance, + double mse, + int delay = 0, + int channel_diff_tolerance = 0) { ASSERT_GE(tolerance, 0) << "Test must define a tolerance >= 0"; - ASSERT_GE(channel_diff_tolerance, 0) << - "Test must define a channel_diff_tolerance >= 0"; + ASSERT_GE(channel_diff_tolerance, 0) + << "Test must define a channel_diff_tolerance >= 0"; size_t processed_samples = 0u; rtc::Buffer encoded; size_t encoded_bytes = 0u; @@ -168,10 +172,10 @@ class AudioDecoderTest : public ::testing::Test { input.resize(input.size() + frame_size_, 0); // Read from input file. ASSERT_GE(input.size() - processed_samples, frame_size_); - ASSERT_TRUE(input_audio_.Read( - frame_size_, codec_input_rate_hz_, &input[processed_samples])); - size_t enc_len = EncodeFrame( - &input[processed_samples], frame_size_, &encoded); + ASSERT_TRUE(input_audio_.Read(frame_size_, codec_input_rate_hz_, + &input[processed_samples])); + size_t enc_len = + EncodeFrame(&input[processed_samples], frame_size_, &encoded); // Make sure that frame_size_ * channels_ samples are allocated and free. decoded.resize((processed_samples + frame_size_) * channels_, 0); AudioDecoder::SpeechType speech_type; @@ -189,11 +193,11 @@ class AudioDecoderTest : public ::testing::Test { if (expected_bytes) { EXPECT_EQ(expected_bytes, encoded_bytes); } - CompareInputOutput( - input, decoded, processed_samples, channels_, tolerance, delay); + CompareInputOutput(input, decoded, processed_samples, channels_, tolerance, + delay); if (channels_ == 2) - CompareTwoChannels( - decoded, processed_samples, channels_, channel_diff_tolerance); + CompareTwoChannels(decoded, processed_samples, channels_, + channel_diff_tolerance); EXPECT_LE( MseInputOutput(input, decoded, processed_samples, channels_, delay), mse); @@ -242,10 +246,9 @@ class AudioDecoderTest : public ::testing::Test { AudioDecoder::SpeechType speech_type; decoder_->Reset(); std::unique_ptr output(new int16_t[frame_size_ * channels_]); - size_t dec_len = decoder_->Decode(encoded.data(), enc_len, - codec_input_rate_hz_, - frame_size_ * channels_ * sizeof(int16_t), - output.get(), &speech_type); + size_t dec_len = decoder_->Decode( + encoded.data(), enc_len, codec_input_rate_hz_, + frame_size_ * channels_ * sizeof(int16_t), output.get(), &speech_type); EXPECT_EQ(frame_size_ * channels_, dec_len); // Call DecodePlc and verify that we get one frame of data. // (Overwrite the output from the above Decode call, but that does not @@ -332,10 +335,9 @@ class AudioDecoderIlbcTest : public AudioDecoderTest { AudioDecoder::SpeechType speech_type; decoder_->Reset(); std::unique_ptr output(new int16_t[frame_size_ * channels_]); - size_t dec_len = decoder_->Decode(encoded.data(), enc_len, - codec_input_rate_hz_, - frame_size_ * channels_ * sizeof(int16_t), - output.get(), &speech_type); + size_t dec_len = decoder_->Decode( + encoded.data(), enc_len, codec_input_rate_hz_, + frame_size_ * channels_ * sizeof(int16_t), output.get(), &speech_type); EXPECT_EQ(frame_size_, dec_len); // Simply call DecodePlc and verify that we get 0 as return value. EXPECT_EQ(0U, decoder_->DecodePlc(1, output.get())); diff --git a/modules/audio_coding/neteq/audio_multi_vector.cc b/modules/audio_coding/neteq/audio_multi_vector.cc index c3e623fdde..fee37cb8bb 100644 --- a/modules/audio_coding/neteq/audio_multi_vector.cc +++ b/modules/audio_coding/neteq/audio_multi_vector.cc @@ -21,7 +21,8 @@ namespace webrtc { AudioMultiVector::AudioMultiVector(size_t N) { assert(N > 0); - if (N < 1) N = 1; + if (N < 1) + N = 1; for (size_t n = 0; n < N; ++n) { channels_.push_back(new AudioVector); } @@ -30,7 +31,8 @@ AudioMultiVector::AudioMultiVector(size_t N) { AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) { assert(N > 0); - if (N < 1) N = 1; + if (N < 1) + N = 1; for (size_t n = 0; n < N; ++n) { channels_.push_back(new AudioVector(initial_size)); } @@ -86,7 +88,7 @@ void AudioMultiVector::PushBackInterleaved(const int16_t* append_this, } channels_[channel]->PushBack(temp_array, length_per_channel); } - delete [] temp_array; + delete[] temp_array; } void AudioMultiVector::PushBack(const AudioMultiVector& append_this) { diff --git a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc index f05aee026c..7272dc287a 100644 --- a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc +++ b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc @@ -37,9 +37,7 @@ class AudioMultiVectorTest : public ::testing::TestWithParam { array_interleaved_ = new int16_t[num_channels_ * array_length()]; } - ~AudioMultiVectorTest() { - delete [] array_interleaved_; - } + ~AudioMultiVectorTest() { delete[] array_interleaved_; } virtual void SetUp() { // Populate test arrays. @@ -58,9 +56,7 @@ class AudioMultiVectorTest : public ::testing::TestWithParam { } } - size_t array_length() const { - return sizeof(array_) / sizeof(array_[0]); - } + size_t array_length() const { return sizeof(array_) / sizeof(array_[0]); } const size_t num_channels_; size_t interleaved_length_; @@ -168,8 +164,9 @@ TEST_P(AudioMultiVectorTest, PushBackFromIndex) { ASSERT_EQ(2u, vec2.Size()); for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t i = 0; i < 2; ++i) { - EXPECT_EQ(array_interleaved_[channel + num_channels_ * - (array_length() - 2 + i)], vec2[channel][i]); + EXPECT_EQ(array_interleaved_[channel + + num_channels_ * (array_length() - 2 + i)], + vec2[channel][i]); } } } @@ -206,7 +203,7 @@ TEST_P(AudioMultiVectorTest, ReadInterleaved) { EXPECT_EQ(0, memcmp(array_interleaved_, output, read_samples * sizeof(int16_t))); - delete [] output; + delete[] output; } // Test the PopFront method. diff --git a/modules/audio_coding/neteq/audio_vector.cc b/modules/audio_coding/neteq/audio_vector.cc index 93cd1fb31c..0486416320 100644 --- a/modules/audio_coding/neteq/audio_vector.cc +++ b/modules/audio_coding/neteq/audio_vector.cc @@ -20,8 +20,7 @@ namespace webrtc { -AudioVector::AudioVector() - : AudioVector(kDefaultInitialSize) { +AudioVector::AudioVector() : AudioVector(kDefaultInitialSize) { Clear(); } @@ -47,16 +46,15 @@ void AudioVector::CopyTo(AudioVector* copy_to) const { copy_to->end_index_ = Size(); } -void AudioVector::CopyTo( - size_t length, size_t position, int16_t* copy_to) const { +void AudioVector::CopyTo(size_t length, + size_t position, + int16_t* copy_to) const { if (length == 0) return; length = std::min(length, Size() - position); const size_t copy_index = (begin_index_ + position) % capacity_; - const size_t first_chunk_length = - std::min(length, capacity_ - copy_index); - memcpy(copy_to, &array_[copy_index], - first_chunk_length * sizeof(int16_t)); + const size_t first_chunk_length = std::min(length, capacity_ - copy_index); + memcpy(copy_to, &array_[copy_index], first_chunk_length * sizeof(int16_t)); const size_t remaining_length = length - first_chunk_length; if (remaining_length > 0) { memcpy(©_to[first_chunk_length], array_.get(), @@ -102,8 +100,9 @@ void AudioVector::PushBack(const AudioVector& append_this) { PushBack(append_this, append_this.Size(), 0); } -void AudioVector::PushBack( - const AudioVector& append_this, size_t length, size_t position) { +void AudioVector::PushBack(const AudioVector& append_this, + size_t length, + size_t position) { RTC_DCHECK_LE(position, append_this.Size()); RTC_DCHECK_LE(length, append_this.Size() - position); @@ -116,8 +115,8 @@ void AudioVector::PushBack( const size_t start_index = (append_this.begin_index_ + position) % append_this.capacity_; - const size_t first_chunk_length = std::min( - length, append_this.capacity_ - start_index); + const size_t first_chunk_length = + std::min(length, append_this.capacity_ - start_index); PushBack(&append_this.array_[start_index], first_chunk_length); const size_t remaining_length = length - first_chunk_length; @@ -179,8 +178,7 @@ void AudioVector::InsertAt(const int16_t* insert_this, } } -void AudioVector::InsertZerosAt(size_t length, - size_t position) { +void AudioVector::InsertZerosAt(size_t length, size_t position) { if (length == 0) return; // Cap the insert position at the current array length. @@ -265,7 +263,8 @@ void AudioVector::CrossFade(const AudioVector& append_this, alpha -= alpha_step; array_[(position + i) % capacity_] = (alpha * array_[(position + i) % capacity_] + - (16384 - alpha) * append_this[i] + 8192) >> 14; + (16384 - alpha) * append_this[i] + 8192) >> + 14; } assert(alpha >= 0); // Verify that the slope was correct. // Append what is left of |append_this|. @@ -319,8 +318,8 @@ void AudioVector::InsertByPushBack(const int16_t* insert_this, } void AudioVector::InsertByPushFront(const int16_t* insert_this, - size_t length, - size_t position) { + size_t length, + size_t position) { std::unique_ptr temp_array(nullptr); if (position > 0) { // TODO(minyue): see if it is possible to avoid copying to a buffer. @@ -335,8 +334,7 @@ void AudioVector::InsertByPushFront(const int16_t* insert_this, PushFront(temp_array.get(), position); } -void AudioVector::InsertZerosByPushBack(size_t length, - size_t position) { +void AudioVector::InsertZerosByPushBack(size_t length, size_t position) { const size_t move_chunk_length = Size() - position; std::unique_ptr temp_array(nullptr); if (move_chunk_length > 0) { @@ -359,8 +357,7 @@ void AudioVector::InsertZerosByPushBack(size_t length, PushBack(temp_array.get(), move_chunk_length); } -void AudioVector::InsertZerosByPushFront(size_t length, - size_t position) { +void AudioVector::InsertZerosByPushFront(size_t length, size_t position) { std::unique_ptr temp_array(nullptr); if (position > 0) { temp_array.reset(new int16_t[position]); diff --git a/modules/audio_coding/neteq/audio_vector.h b/modules/audio_coding/neteq/audio_vector.h index 754a9fdbe6..65939ce366 100644 --- a/modules/audio_coding/neteq/audio_vector.h +++ b/modules/audio_coding/neteq/audio_vector.h @@ -75,7 +75,8 @@ class AudioVector { // them at |position|. The length of the AudioVector is increased by |length|. // |position| = 0 means that the new values are prepended to the vector. // |position| = Size() means that the new values are appended to the vector. - virtual void InsertAt(const int16_t* insert_this, size_t length, + virtual void InsertAt(const int16_t* insert_this, + size_t length, size_t position); // Like InsertAt, but inserts |length| zero elements at |position|. @@ -140,10 +141,12 @@ class AudioVector { void Reserve(size_t n); - void InsertByPushBack(const int16_t* insert_this, size_t length, + void InsertByPushBack(const int16_t* insert_this, + size_t length, size_t position); - void InsertByPushFront(const int16_t* insert_this, size_t length, + void InsertByPushFront(const int16_t* insert_this, + size_t length, size_t position); void InsertZerosByPushBack(size_t length, size_t position); diff --git a/modules/audio_coding/neteq/audio_vector_unittest.cc b/modules/audio_coding/neteq/audio_vector_unittest.cc index 1b54abca5c..e70178c6c9 100644 --- a/modules/audio_coding/neteq/audio_vector_unittest.cc +++ b/modules/audio_coding/neteq/audio_vector_unittest.cc @@ -30,9 +30,7 @@ class AudioVectorTest : public ::testing::Test { } } - size_t array_length() const { - return sizeof(array_) / sizeof(array_[0]); - } + size_t array_length() const { return sizeof(array_) / sizeof(array_[0]); } int16_t array_[10]; }; @@ -283,8 +281,8 @@ TEST_F(AudioVectorTest, InsertBeyondEnd) { for (int i = 0; i < kNewLength; ++i) { new_array[i] = 100 + i; } - int insert_position = rtc::checked_cast( - array_length() + 10); // Too large. + int insert_position = + rtc::checked_cast(array_length() + 10); // Too large. vec.InsertAt(new_array, kNewLength, insert_position); // Verify that the vector looks as follows: // {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }. @@ -375,7 +373,7 @@ TEST_F(AudioVectorTest, CrossFade) { EXPECT_EQ(0, vec1[i]); } // Check mixing zone. - for (size_t i = 0 ; i < kFadeLength; ++i) { + for (size_t i = 0; i < kFadeLength; ++i) { EXPECT_NEAR((i + 1) * 100 / (kFadeLength + 1), vec1[kLength - kFadeLength + i], 1); } diff --git a/modules/audio_coding/neteq/background_noise.cc b/modules/audio_coding/neteq/background_noise.cc index 50ffa86a9a..08c278e14a 100644 --- a/modules/audio_coding/neteq/background_noise.cc +++ b/modules/audio_coding/neteq/background_noise.cc @@ -58,11 +58,11 @@ void BackgroundNoise::Update(const AudioMultiVector& input, int16_t temp_signal_array[kVecLen + kMaxLpcOrder] = {0}; int16_t* temp_signal = &temp_signal_array[kMaxLpcOrder]; input[channel_ix].CopyTo(kVecLen, input.Size() - kVecLen, temp_signal); - int32_t sample_energy = CalculateAutoCorrelation(temp_signal, kVecLen, - auto_correlation); + int32_t sample_energy = + CalculateAutoCorrelation(temp_signal, kVecLen, auto_correlation); if ((!vad.running() && - sample_energy < parameters.energy_update_threshold) || + sample_energy < parameters.energy_update_threshold) || (vad.running() && !vad.active_speech())) { // Generate LPC coefficients. if (auto_correlation[0] > 0) { @@ -91,10 +91,8 @@ void BackgroundNoise::Update(const AudioMultiVector& input, WebRtcSpl_FilterMAFastQ12(temp_signal + kVecLen - kResidualLength, fiter_output, lpc_coefficients, kMaxLpcOrder + 1, kResidualLength); - int32_t residual_energy = WebRtcSpl_DotProductWithScale(fiter_output, - fiter_output, - kResidualLength, - 0); + int32_t residual_energy = WebRtcSpl_DotProductWithScale( + fiter_output, fiter_output, kResidualLength, 0); // Check spectral flatness. // Comparing the residual variance with the input signal variance tells @@ -146,7 +144,8 @@ const int16_t* BackgroundNoise::FilterState(size_t channel) const { return channel_parameters_[channel].filter_state; } -void BackgroundNoise::SetFilterState(size_t channel, const int16_t* input, +void BackgroundNoise::SetFilterState(size_t channel, + const int16_t* input, size_t length) { assert(channel < num_channels_); length = std::min(length, kMaxLpcOrder); @@ -164,7 +163,9 @@ int16_t BackgroundNoise::ScaleShift(size_t channel) const { } int32_t BackgroundNoise::CalculateAutoCorrelation( - const int16_t* signal, size_t length, int32_t* auto_correlation) const { + const int16_t* signal, + size_t length, + int32_t* auto_correlation) const { static const int kCorrelationStep = -1; const int correlation_scale = CrossCorrelationWithAutoShift(signal, signal, length, kMaxLpcOrder + 1, @@ -185,15 +186,16 @@ void BackgroundNoise::IncrementEnergyThreshold(size_t channel, assert(channel < num_channels_); ChannelParameters& parameters = channel_parameters_[channel]; int32_t temp_energy = - (kThresholdIncrement * parameters.low_energy_update_threshold) >> 16; - temp_energy += kThresholdIncrement * - (parameters.energy_update_threshold & 0xFF); - temp_energy += (kThresholdIncrement * - ((parameters.energy_update_threshold>>8) & 0xFF)) << 8; + (kThresholdIncrement * parameters.low_energy_update_threshold) >> 16; + temp_energy += + kThresholdIncrement * (parameters.energy_update_threshold & 0xFF); + temp_energy += + (kThresholdIncrement * ((parameters.energy_update_threshold >> 8) & 0xFF)) + << 8; parameters.low_energy_update_threshold += temp_energy; - parameters.energy_update_threshold += kThresholdIncrement * - (parameters.energy_update_threshold>>16); + parameters.energy_update_threshold += + kThresholdIncrement * (parameters.energy_update_threshold >> 16); parameters.energy_update_threshold += parameters.low_energy_update_threshold >> 16; parameters.low_energy_update_threshold = @@ -201,8 +203,7 @@ void BackgroundNoise::IncrementEnergyThreshold(size_t channel, // Update maximum energy. // Decrease by a factor 1/1024 each time. - parameters.max_energy = parameters.max_energy - - (parameters.max_energy >> 10); + parameters.max_energy = parameters.max_energy - (parameters.max_energy >> 10); if (sample_energy > parameters.max_energy) { parameters.max_energy = sample_energy; } @@ -223,9 +224,8 @@ void BackgroundNoise::SaveParameters(size_t channel, assert(channel < num_channels_); ChannelParameters& parameters = channel_parameters_[channel]; memcpy(parameters.filter, lpc_coefficients, - (kMaxLpcOrder+1) * sizeof(int16_t)); - memcpy(parameters.filter_state, filter_state, - kMaxLpcOrder * sizeof(int16_t)); + (kMaxLpcOrder + 1) * sizeof(int16_t)); + memcpy(parameters.filter_state, filter_state, kMaxLpcOrder * sizeof(int16_t)); // Save energy level and update energy threshold levels. // Never get under 1.0 in average sample energy. parameters.energy = std::max(sample_energy, 1); diff --git a/modules/audio_coding/neteq/background_noise.h b/modules/audio_coding/neteq/background_noise.h index a6f139573f..26d42b50db 100644 --- a/modules/audio_coding/neteq/background_noise.h +++ b/modules/audio_coding/neteq/background_noise.h @@ -38,8 +38,7 @@ class BackgroundNoise { // Updates the parameter estimates based on the signal currently in the // |sync_buffer|, and on the latest decision in |vad| if it is running. - void Update(const AudioMultiVector& sync_buffer, - const PostDecodeVad& vad); + void Update(const AudioMultiVector& sync_buffer, const PostDecodeVad& vad); // Returns |energy_| for |channel|. int32_t Energy(size_t channel) const; @@ -78,9 +77,7 @@ class BackgroundNoise { struct ChannelParameters { // Constructor. - ChannelParameters() { - Reset(); - } + ChannelParameters() { Reset(); } void Reset() { energy = 2500; diff --git a/modules/audio_coding/neteq/buffer_level_filter.cc b/modules/audio_coding/neteq/buffer_level_filter.cc index 6005de6989..4d015b6827 100644 --- a/modules/audio_coding/neteq/buffer_level_filter.cc +++ b/modules/audio_coding/neteq/buffer_level_filter.cc @@ -31,7 +31,8 @@ void BufferLevelFilter::Update(size_t buffer_size_packets, // (1 - |level_factor_|) * |buffer_size_packets| // |level_factor_| and |filtered_current_level_| are in Q8. // |buffer_size_packets| is in Q0. - filtered_current_level_ = ((level_factor_ * filtered_current_level_) >> 8) + + filtered_current_level_ = + ((level_factor_ * filtered_current_level_) >> 8) + ((256 - level_factor_) * static_cast(buffer_size_packets)); // Account for time-scale operations (accelerate and pre-emptive expand). diff --git a/modules/audio_coding/neteq/buffer_level_filter.h b/modules/audio_coding/neteq/buffer_level_filter.h index 7a48c72b74..c8d27dcd1f 100644 --- a/modules/audio_coding/neteq/buffer_level_filter.h +++ b/modules/audio_coding/neteq/buffer_level_filter.h @@ -28,7 +28,8 @@ class BufferLevelFilter { // corresponding number of packets, and is subtracted from the filtered // value (thus bypassing the filter operation). |packet_len_samples| is the // number of audio samples carried in each incoming packet. - virtual void Update(size_t buffer_size_packets, int time_stretched_samples, + virtual void Update(size_t buffer_size_packets, + int time_stretched_samples, size_t packet_len_samples); // Set the current target buffer level (obtained from diff --git a/modules/audio_coding/neteq/buffer_level_filter_unittest.cc b/modules/audio_coding/neteq/buffer_level_filter_unittest.cc index 72c8727429..b6dcd2a98a 100644 --- a/modules/audio_coding/neteq/buffer_level_filter_unittest.cc +++ b/modules/audio_coding/neteq/buffer_level_filter_unittest.cc @@ -39,8 +39,7 @@ TEST(BufferLevelFilter, ConvergenceTest) { } // Expect the filtered value to be (theoretically) // (1 - (251/256) ^ |times|) * |value|. - double expected_value_double = - (1 - pow(251.0 / 256.0, times)) * value; + double expected_value_double = (1 - pow(251.0 / 256.0, times)) * value; int expected_value = static_cast(expected_value_double); // filtered_current_level() returns the value in Q8. // The actual value may differ slightly from the expected value due to @@ -94,7 +93,6 @@ TEST(BufferLevelFilter, FilterFactor) { EXPECT_EQ(expected_value, filter.filtered_current_level() >> 8); } - TEST(BufferLevelFilter, TimeStretchedSamples) { BufferLevelFilter filter; filter.SetTargetBufferLevel(1); // Makes filter coefficient 251/256. diff --git a/modules/audio_coding/neteq/comfort_noise.cc b/modules/audio_coding/neteq/comfort_noise.cc index 5e0a87526e..b341acd5a5 100644 --- a/modules/audio_coding/neteq/comfort_noise.cc +++ b/modules/audio_coding/neteq/comfort_noise.cc @@ -35,10 +35,9 @@ int ComfortNoise::UpdateParameters(const Packet& packet) { return kOK; } -int ComfortNoise::Generate(size_t requested_length, - AudioMultiVector* output) { +int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) { // TODO(hlundin): Change to an enumerator and skip assert. - assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || + assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || fs_hz_ == 48000); // Not adapted for multi-channel yet. if (output->Channels() != 1) { @@ -63,8 +62,7 @@ int ComfortNoise::Generate(size_t requested_length, std::unique_ptr temp(new int16_t[number_of_samples]); if (!cng_decoder->Generate( - rtc::ArrayView(temp.get(), number_of_samples), - new_period)) { + rtc::ArrayView(temp.get(), number_of_samples), new_period)) { // Error returned. output->Zeros(requested_length); RTC_LOG(LS_ERROR) @@ -75,9 +73,9 @@ int ComfortNoise::Generate(size_t requested_length, if (first_call_) { // Set tapering window parameters. Values are in Q15. - int16_t muting_window; // Mixing factor for overlap data. - int16_t muting_window_increment; // Mixing factor increment (negative). - int16_t unmuting_window; // Mixing factor for comfort noise. + int16_t muting_window; // Mixing factor for overlap data. + int16_t muting_window_increment; // Mixing factor increment (negative). + int16_t unmuting_window; // Mixing factor for comfort noise. int16_t unmuting_window_increment; // Mixing factor increment. if (fs_hz_ == 8000) { muting_window = DspHelper::kMuteFactorStart8kHz; @@ -109,7 +107,8 @@ int ComfortNoise::Generate(size_t requested_length, // channel. (*sync_buffer_)[0][start_ix + i] = (((*sync_buffer_)[0][start_ix + i] * muting_window) + - ((*output)[0][i] * unmuting_window) + 16384) >> 15; + ((*output)[0][i] * unmuting_window) + 16384) >> + 15; muting_window += muting_window_increment; unmuting_window += unmuting_window_increment; } diff --git a/modules/audio_coding/neteq/comfort_noise.h b/modules/audio_coding/neteq/comfort_noise.h index 18800ad644..c8cc64a5ff 100644 --- a/modules/audio_coding/neteq/comfort_noise.h +++ b/modules/audio_coding/neteq/comfort_noise.h @@ -32,14 +32,14 @@ class ComfortNoise { kMultiChannelNotSupported }; - ComfortNoise(int fs_hz, DecoderDatabase* decoder_database, + ComfortNoise(int fs_hz, + DecoderDatabase* decoder_database, SyncBuffer* sync_buffer) : fs_hz_(fs_hz), first_call_(true), overlap_length_(5 * fs_hz_ / 8000), decoder_database_(decoder_database), - sync_buffer_(sync_buffer) { - } + sync_buffer_(sync_buffer) {} // Resets the state. Should be called before each new comfort noise period. void Reset(); diff --git a/modules/audio_coding/neteq/cross_correlation.cc b/modules/audio_coding/neteq/cross_correlation.cc index da9c913249..2a03d4af26 100644 --- a/modules/audio_coding/neteq/cross_correlation.cc +++ b/modules/audio_coding/neteq/cross_correlation.cc @@ -48,8 +48,9 @@ int CrossCorrelationWithAutoShift(const int16_t* sequence_1, // There are some corner cases that 2) is not satisfied, e.g., // max_1 = 17, max_2 = 30848, sequence_1_length = 4095, in such case, // optimal scaling is 0, while the following calculation results in 1. - const int32_t factor = (max_1 * max_2) / (std::numeric_limits::max() - / static_cast(sequence_1_length)); + const int32_t factor = + (max_1 * max_2) / (std::numeric_limits::max() / + static_cast(sequence_1_length)); const int scaling = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor); WebRtcSpl_CrossCorrelation(cross_correlation, sequence_1, sequence_2, diff --git a/modules/audio_coding/neteq/decision_logic.cc b/modules/audio_coding/neteq/decision_logic.cc index 279a9e6bee..cc58f04781 100644 --- a/modules/audio_coding/neteq/decision_logic.cc +++ b/modules/audio_coding/neteq/decision_logic.cc @@ -95,7 +95,7 @@ void DecisionLogic::SoftReset() { void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) { // TODO(hlundin): Change to an enumerator and skip assert. - assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000); + assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000); fs_mult_ = fs_hz / 8000; output_size_samples_ = output_size_samples; } @@ -122,11 +122,11 @@ Operations DecisionLogic::GetDecision(const SyncBuffer& sync_buffer, const size_t cur_size_samples = samples_left + packet_buffer_.NumSamplesInBuffer(decoder_frame_length); - prev_time_scale_ = prev_time_scale_ && - (prev_mode == kModeAccelerateSuccess || - prev_mode == kModeAccelerateLowEnergy || - prev_mode == kModePreemptiveExpandSuccess || - prev_mode == kModePreemptiveExpandLowEnergy); + prev_time_scale_ = + prev_time_scale_ && (prev_mode == kModeAccelerateSuccess || + prev_mode == kModeAccelerateLowEnergy || + prev_mode == kModePreemptiveExpandSuccess || + prev_mode == kModePreemptiveExpandLowEnergy); FilterBufferLevel(cur_size_samples, prev_mode); diff --git a/modules/audio_coding/neteq/decision_logic.h b/modules/audio_coding/neteq/decision_logic.h index 9d88c4d355..d23aa744c3 100644 --- a/modules/audio_coding/neteq/decision_logic.h +++ b/modules/audio_coding/neteq/decision_logic.h @@ -97,9 +97,7 @@ class DecisionLogic { virtual void ExpandDecision(Operations operation); // Adds |value| to |sample_memory_|. - void AddSampleMemory(int32_t value) { - sample_memory_ += value; - } + void AddSampleMemory(int32_t value) { sample_memory_ += value; } // Accessors and mutators. void set_sample_memory(int32_t value) { sample_memory_ = value; } @@ -115,11 +113,7 @@ class DecisionLogic { // The value 5 sets maximum time-stretch rate to about 100 ms/s. static const int kMinTimescaleInterval = 5; - enum CngState { - kCngOff, - kCngRfc3389On, - kCngInternalOn - }; + enum CngState { kCngOff, kCngRfc3389On, kCngInternalOn }; // Returns the operation that should be done next. |sync_buffer| and |expand| // are provided for reference. |decoder_frame_length| is the number of samples diff --git a/modules/audio_coding/neteq/decision_logic_fax.cc b/modules/audio_coding/neteq/decision_logic_fax.cc index 22d36ce9cc..0f904bb531 100644 --- a/modules/audio_coding/neteq/decision_logic_fax.cc +++ b/modules/audio_coding/neteq/decision_logic_fax.cc @@ -39,8 +39,8 @@ Operations DecisionLogicFax::GetDecisionSpecialized( decoder_database_->IsComfortNoise(next_packet->payload_type); } if (is_cng_packet) { - if (static_cast((generated_noise_samples + target_timestamp) - - available_timestamp) >= 0) { + if (static_cast((generated_noise_samples + target_timestamp) - + available_timestamp) >= 0) { // Time to play this packet now. return kRfc3389Cng; } else { @@ -72,8 +72,8 @@ Operations DecisionLogicFax::GetDecisionSpecialized( } else if (target_timestamp == available_timestamp) { return kNormal; } else { - if (static_cast((generated_noise_samples + target_timestamp) - - available_timestamp) >= 0) { + if (static_cast((generated_noise_samples + target_timestamp) - + available_timestamp) >= 0) { return kNormal; } else { // If currently playing comfort noise, continue with that. Do not @@ -100,5 +100,4 @@ Operations DecisionLogicFax::GetDecisionSpecialized( } } - } // namespace webrtc diff --git a/modules/audio_coding/neteq/decision_logic_normal.cc b/modules/audio_coding/neteq/decision_logic_normal.cc index c163999f58..a683b8c201 100644 --- a/modules/audio_coding/neteq/decision_logic_normal.cc +++ b/modules/audio_coding/neteq/decision_logic_normal.cc @@ -79,8 +79,8 @@ Operations DecisionLogicNormal::GetDecisionSpecialized( // Note that the MuteFactor is in Q14, so a value of 16384 corresponds to 1. if (postpone_decoding_after_expand_ && prev_mode == kModeExpand && !packet_buffer_.ContainsDtxOrCngPacket(decoder_database_) && - cur_size_samples < static_cast(delay_manager_->TargetLevel() * - packet_length_samples_) >> 8 && + cur_size_samples(delay_manager_->TargetLevel() * + packet_length_samples_)>> 8 && expand.MuteFactor(0) < 16384 / 2) { return kExpand; } @@ -92,10 +92,9 @@ Operations DecisionLogicNormal::GetDecisionSpecialized( return ExpectedPacketAvailable(prev_mode, play_dtmf); } else if (!PacketBuffer::IsObsoleteTimestamp( available_timestamp, target_timestamp, five_seconds_samples)) { - return FuturePacketAvailable(sync_buffer, expand, decoder_frame_length, - prev_mode, target_timestamp, - available_timestamp, play_dtmf, - generated_noise_samples); + return FuturePacketAvailable( + sync_buffer, expand, decoder_frame_length, prev_mode, target_timestamp, + available_timestamp, play_dtmf, generated_noise_samples); } else { // This implies that available_timestamp < target_timestamp, which can // happen when a new stream or codec is received. Signal for a reset. @@ -183,10 +182,8 @@ Operations DecisionLogicNormal::FuturePacketAvailable( // Check if we should continue with an ongoing expand because the new packet // is too far into the future. uint32_t timestamp_leap = available_timestamp - target_timestamp; - if ((prev_mode == kModeExpand) && - !ReinitAfterExpands(timestamp_leap) && - !MaxWaitForPacket() && - PacketTooEarly(timestamp_leap) && + if ((prev_mode == kModeExpand) && !ReinitAfterExpands(timestamp_leap) && + !MaxWaitForPacket() && PacketTooEarly(timestamp_leap) && UnderTargetLevel()) { if (play_dtmf) { // Still have DTMF to play, so do not do expand. @@ -199,12 +196,11 @@ Operations DecisionLogicNormal::FuturePacketAvailable( const size_t samples_left = sync_buffer.FutureLength() - expand.overlap_length(); - const size_t cur_size_samples = samples_left + - packet_buffer_.NumPacketsInBuffer() * decoder_frame_length; + const size_t cur_size_samples = + samples_left + packet_buffer_.NumPacketsInBuffer() * decoder_frame_length; // If previous was comfort noise, then no merge is needed. - if (prev_mode == kModeRfc3389Cng || - prev_mode == kModeCodecInternalCng) { + if (prev_mode == kModeRfc3389Cng || prev_mode == kModeCodecInternalCng) { // Keep the same delay as before the CNG, but make sure that the number of // samples in buffer is no higher than 4 times the optimal level. (Note that // TargetLevel() is in Q8.) @@ -212,7 +208,7 @@ Operations DecisionLogicNormal::FuturePacketAvailable( available_timestamp || cur_size_samples > ((delay_manager_->TargetLevel() * packet_length_samples_) >> 8) * - 4) { + 4) { // Time to play this new packet. return kNormal; } else { @@ -237,17 +233,17 @@ Operations DecisionLogicNormal::FuturePacketAvailable( bool DecisionLogicNormal::UnderTargetLevel() const { return buffer_level_filter_->filtered_current_level() <= - delay_manager_->TargetLevel(); + delay_manager_->TargetLevel(); } bool DecisionLogicNormal::ReinitAfterExpands(uint32_t timestamp_leap) const { return timestamp_leap >= - static_cast(output_size_samples_ * kReinitAfterExpands); + static_cast(output_size_samples_ * kReinitAfterExpands); } bool DecisionLogicNormal::PacketTooEarly(uint32_t timestamp_leap) const { return timestamp_leap > - static_cast(output_size_samples_ * num_consecutive_expands_); + static_cast(output_size_samples_ * num_consecutive_expands_); } bool DecisionLogicNormal::MaxWaitForPacket() const { diff --git a/modules/audio_coding/neteq/decision_logic_normal.h b/modules/audio_coding/neteq/decision_logic_normal.h index a718f99495..ed2ea39b98 100644 --- a/modules/audio_coding/neteq/decision_logic_normal.h +++ b/modules/audio_coding/neteq/decision_logic_normal.h @@ -58,15 +58,14 @@ class DecisionLogicNormal : public DecisionLogic { // Returns the operation to do given that the expected packet is not // available, but a packet further into the future is at hand. - virtual Operations FuturePacketAvailable( - const SyncBuffer& sync_buffer, - const Expand& expand, - size_t decoder_frame_length, - Modes prev_mode, - uint32_t target_timestamp, - uint32_t available_timestamp, - bool play_dtmf, - size_t generated_noise_samples); + virtual Operations FuturePacketAvailable(const SyncBuffer& sync_buffer, + const Expand& expand, + size_t decoder_frame_length, + Modes prev_mode, + uint32_t target_timestamp, + uint32_t available_timestamp, + bool play_dtmf, + size_t generated_noise_samples); // Returns the operation to do given that the expected packet is available. virtual Operations ExpectedPacketAvailable(Modes prev_mode, bool play_dtmf); diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc index 72c0376f5d..1fd8c03ca2 100644 --- a/modules/audio_coding/neteq/decoder_database.cc +++ b/modules/audio_coding/neteq/decoder_database.cc @@ -134,9 +134,13 @@ DecoderDatabase::DecoderInfo::SubtypeFromFormat(const SdpAudioFormat& format) { return Subtype::kNormal; } -bool DecoderDatabase::Empty() const { return decoders_.empty(); } +bool DecoderDatabase::Empty() const { + return decoders_.empty(); +} -int DecoderDatabase::Size() const { return static_cast(decoders_.size()); } +int DecoderDatabase::Size() const { + return static_cast(decoders_.size()); +} void DecoderDatabase::Reset() { decoders_.clear(); @@ -276,7 +280,7 @@ const DecoderDatabase::DecoderInfo* DecoderDatabase::GetDecoderInfo( int DecoderDatabase::SetActiveDecoder(uint8_t rtp_payload_type, bool* new_decoder) { // Check that |rtp_payload_type| exists in the database. - const DecoderInfo *info = GetDecoderInfo(rtp_payload_type); + const DecoderInfo* info = GetDecoderInfo(rtp_payload_type); if (!info) { // Decoder not found. return kDecoderNotFound; @@ -289,7 +293,7 @@ int DecoderDatabase::SetActiveDecoder(uint8_t rtp_payload_type, *new_decoder = true; } else if (active_decoder_type_ != rtp_payload_type) { // Moving from one active decoder to another. Delete the first one. - const DecoderInfo *old_info = GetDecoderInfo(active_decoder_type_); + const DecoderInfo* old_info = GetDecoderInfo(active_decoder_type_); RTC_DCHECK(old_info); old_info->DropDecoder(); *new_decoder = true; @@ -308,7 +312,7 @@ AudioDecoder* DecoderDatabase::GetActiveDecoder() const { int DecoderDatabase::SetActiveCngDecoder(uint8_t rtp_payload_type) { // Check that |rtp_payload_type| exists in the database. - const DecoderInfo *info = GetDecoderInfo(rtp_payload_type); + const DecoderInfo* info = GetDecoderInfo(rtp_payload_type); if (!info) { // Decoder not found. return kDecoderNotFound; @@ -335,7 +339,7 @@ ComfortNoiseDecoder* DecoderDatabase::GetActiveCngDecoder() const { } AudioDecoder* DecoderDatabase::GetDecoder(uint8_t rtp_payload_type) const { - const DecoderInfo *info = GetDecoderInfo(rtp_payload_type); + const DecoderInfo* info = GetDecoderInfo(rtp_payload_type); return info ? info->GetDecoder() : nullptr; } @@ -350,17 +354,17 @@ bool DecoderDatabase::IsType(uint8_t rtp_payload_type, } bool DecoderDatabase::IsComfortNoise(uint8_t rtp_payload_type) const { - const DecoderInfo *info = GetDecoderInfo(rtp_payload_type); + const DecoderInfo* info = GetDecoderInfo(rtp_payload_type); return info && info->IsComfortNoise(); } bool DecoderDatabase::IsDtmf(uint8_t rtp_payload_type) const { - const DecoderInfo *info = GetDecoderInfo(rtp_payload_type); + const DecoderInfo* info = GetDecoderInfo(rtp_payload_type); return info && info->IsDtmf(); } bool DecoderDatabase::IsRed(uint8_t rtp_payload_type) const { - const DecoderInfo *info = GetDecoderInfo(rtp_payload_type); + const DecoderInfo* info = GetDecoderInfo(rtp_payload_type); return info && info->IsRed(); } diff --git a/modules/audio_coding/neteq/decoder_database.h b/modules/audio_coding/neteq/decoder_database.h index 6b388dd6e8..107d2f31ff 100644 --- a/modules/audio_coding/neteq/decoder_database.h +++ b/modules/audio_coding/neteq/decoder_database.h @@ -88,14 +88,10 @@ class DecoderDatabase { } // Returns true if the decoder's format is DTMF. - bool IsDtmf() const { - return subtype_ == Subtype::kDtmf; - } + bool IsDtmf() const { return subtype_ == Subtype::kDtmf; } // Returns true if the decoder's format is RED. - bool IsRed() const { - return subtype_ == Subtype::kRed; - } + bool IsRed() const { return subtype_ == Subtype::kRed; } // Returns true if the decoder's format is named |name|. bool IsType(const char* name) const; @@ -125,12 +121,7 @@ class DecoderDatabase { }; const absl::optional cng_decoder_; - enum class Subtype : int8_t { - kNormal, - kComfortNoise, - kDtmf, - kRed - }; + enum class Subtype : int8_t { kNormal, kComfortNoise, kDtmf, kRed }; static Subtype SubtypeFromFormat(const SdpAudioFormat& format); diff --git a/modules/audio_coding/neteq/decoder_database_unittest.cc b/modules/audio_coding/neteq/decoder_database_unittest.cc index afd10ae564..10043e0bba 100644 --- a/modules/audio_coding/neteq/decoder_database_unittest.cc +++ b/modules/audio_coding/neteq/decoder_database_unittest.cc @@ -110,7 +110,7 @@ TEST(DecoderDatabase, GetDecoderInfo) { EXPECT_EQ(kCodecName, info->get_name()); EXPECT_EQ(decoder, db.GetDecoder(kPayloadType)); info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. - EXPECT_TRUE(info == NULL); // Should not be found. + EXPECT_TRUE(info == NULL); // Should not be found. } TEST(DecoderDatabase, GetDecoder) { @@ -292,7 +292,6 @@ TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) { // Try to set non-existing codecs as active. EXPECT_EQ(DecoderDatabase::kDecoderNotFound, db.SetActiveDecoder(17, &changed)); - EXPECT_EQ(DecoderDatabase::kDecoderNotFound, - db.SetActiveCngDecoder(17)); + EXPECT_EQ(DecoderDatabase::kDecoderNotFound, db.SetActiveCngDecoder(17)); } } // namespace webrtc diff --git a/modules/audio_coding/neteq/delay_manager.cc b/modules/audio_coding/neteq/delay_manager.cc index b70131d9ed..a945cdcad8 100644 --- a/modules/audio_coding/neteq/delay_manager.cc +++ b/modules/audio_coding/neteq/delay_manager.cc @@ -155,8 +155,9 @@ void DelayManager::UpdateCumulativeSums(int packet_len_ms, (packet_iat_stopwatch_->ElapsedMs() << 8) / packet_len_ms; // Calculate cumulative sum IAT with sequence number compensation. The sum // is zero if there is no clock-drift. - iat_cumulative_sum_ += (iat_packets_q8 - - (static_cast(sequence_number - last_seq_no_) << 8)); + iat_cumulative_sum_ += + (iat_packets_q8 - + (static_cast(sequence_number - last_seq_no_) << 8)); // Subtract drift term. iat_cumulative_sum_ -= kCumulativeSumDrift; // Ensure not negative. @@ -189,8 +190,8 @@ void DelayManager::UpdateHistogram(size_t iat_packets) { assert(iat_packets < iat_vector_.size()); int vector_sum = 0; // Sum up the vector elements as they are processed. // Multiply each element in |iat_vector_| with |iat_factor_|. - for (IATVector::iterator it = iat_vector_.begin(); - it != iat_vector_.end(); ++it) { + for (IATVector::iterator it = iat_vector_.begin(); it != iat_vector_.end(); + ++it) { *it = (static_cast(*it) * iat_factor_) >> 15; vector_sum += *it; } @@ -236,7 +237,7 @@ void DelayManager::LimitTargetLevel() { least_required_delay_ms_ = (target_level_ * packet_len_ms_) >> 8; if (packet_len_ms_ > 0 && minimum_delay_ms_ > 0) { - int minimum_delay_packet_q8 = (minimum_delay_ms_ << 8) / packet_len_ms_; + int minimum_delay_packet_q8 = (minimum_delay_ms_ << 8) / packet_len_ms_; target_level_ = std::max(target_level_, minimum_delay_packet_q8); } @@ -269,8 +270,8 @@ int DelayManager::CalculateTargetLevel(int iat_packets) { // (in Q30) by definition, and since the solution is often a low value for // |iat_index|, it is more efficient to start with |sum| = 1 and subtract // elements from the start of the histogram. - size_t index = 0; // Start from the beginning of |iat_vector_|. - int sum = 1 << 30; // Assign to 1 in Q30. + size_t index = 0; // Start from the beginning of |iat_vector_|. + int sum = 1 << 30; // Assign to 1 in Q30. sum -= iat_vector_[index]; // Ensure that target level is >= 1. do { @@ -313,13 +314,12 @@ int DelayManager::SetPacketAudioLength(int length_ms) { return 0; } - void DelayManager::Reset() { packet_len_ms_ = 0; // Packet size unknown. streaming_mode_ = false; peak_detector_.Reset(); ResetHistogram(); // Resets target levels too. - iat_factor_ = 0; // Adapt the histogram faster for the first few packets. + iat_factor_ = 0; // Adapt the histogram faster for the first few packets. packet_iat_stopwatch_ = tick_timer_->GetNewStopwatch(); max_iat_stopwatch_ = tick_timer_->GetNewStopwatch(); iat_cumulative_sum_ = 0; @@ -471,8 +471,12 @@ int DelayManager::least_required_delay_ms() const { return least_required_delay_ms_; } -int DelayManager::base_target_level() const { return base_target_level_; } -void DelayManager::set_streaming_mode(bool value) { streaming_mode_ = value; } +int DelayManager::base_target_level() const { + return base_target_level_; +} +void DelayManager::set_streaming_mode(bool value) { + streaming_mode_ = value; +} int DelayManager::last_pack_cng_or_dtmf() const { return last_pack_cng_or_dtmf_; } diff --git a/modules/audio_coding/neteq/delay_manager.h b/modules/audio_coding/neteq/delay_manager.h index 0d082c8788..08004eaccb 100644 --- a/modules/audio_coding/neteq/delay_manager.h +++ b/modules/audio_coding/neteq/delay_manager.h @@ -117,9 +117,9 @@ class DelayManager { virtual void set_last_pack_cng_or_dtmf(int value); private: - static const int kLimitProbability = 53687091; // 1/20 in Q30. + static const int kLimitProbability = 53687091; // 1/20 in Q30. static const int kLimitProbabilityStreaming = 536871; // 1/2000 in Q30. - static const int kMaxStreamingPeakPeriodMs = 600000; // 10 minutes in ms. + static const int kMaxStreamingPeakPeriodMs = 600000; // 10 minutes in ms. static const int kCumulativeSumDrift = 2; // Drift term for cumulative sum // |iat_cumulative_sum_|. // Steady-state forgetting factor for |iat_vector_|, 0.9993 in Q15. @@ -146,28 +146,29 @@ class DelayManager { bool first_packet_received_; const size_t max_packets_in_buffer_; // Capacity of the packet buffer. - IATVector iat_vector_; // Histogram of inter-arrival times. + IATVector iat_vector_; // Histogram of inter-arrival times. int iat_factor_; // Forgetting factor for updating the IAT histogram (Q15). const TickTimer* tick_timer_; // Time elapsed since last packet. std::unique_ptr packet_iat_stopwatch_; - int base_target_level_; // Currently preferred buffer level before peak - // detection and streaming mode (Q0). + int base_target_level_; // Currently preferred buffer level before peak + // detection and streaming mode (Q0). // TODO(turajs) change the comment according to the implementation of // minimum-delay. - int target_level_; // Currently preferred buffer level in (fractions) - // of packets (Q8), before adding any extra delay. + int target_level_; // Currently preferred buffer level in (fractions) + // of packets (Q8), before adding any extra delay. int packet_len_ms_; // Length of audio in each incoming packet [ms]. bool streaming_mode_; - uint16_t last_seq_no_; // Sequence number for last received packet. - uint32_t last_timestamp_; // Timestamp for the last received packet. - int minimum_delay_ms_; // Externally set minimum delay. + uint16_t last_seq_no_; // Sequence number for last received packet. + uint32_t last_timestamp_; // Timestamp for the last received packet. + int minimum_delay_ms_; // Externally set minimum delay. int least_required_delay_ms_; // Smallest preferred buffer level (same unit - // as |target_level_|), before applying - // |minimum_delay_ms_| and/or |maximum_delay_ms_|. - int maximum_delay_ms_; // Externally set maximum allowed delay. - int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times. - int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|. + // as |target_level_|), before applying + // |minimum_delay_ms_| and/or + // |maximum_delay_ms_|. + int maximum_delay_ms_; // Externally set maximum allowed delay. + int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times. + int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|. // Time elapsed since maximum was observed. std::unique_ptr max_iat_stopwatch_; DelayPeakDetector& peak_detector_; diff --git a/modules/audio_coding/neteq/delay_manager_unittest.cc b/modules/audio_coding/neteq/delay_manager_unittest.cc index 953bc6b400..f9c5680017 100644 --- a/modules/audio_coding/neteq/delay_manager_unittest.cc +++ b/modules/audio_coding/neteq/delay_manager_unittest.cc @@ -49,8 +49,7 @@ DelayManagerTest::DelayManagerTest() : dm_(NULL), detector_(&tick_timer_), seq_no_(0x1234), ts_(0x12345678) {} void DelayManagerTest::SetUp() { - EXPECT_CALL(detector_, Reset()) - .Times(1); + EXPECT_CALL(detector_, Reset()).Times(1); dm_ = new DelayManager(kMaxNumberOfPackets, &detector_, &tick_timer_); } @@ -94,8 +93,7 @@ TEST_F(DelayManagerTest, VectorInitialization) { TEST_F(DelayManagerTest, SetPacketAudioLength) { const int kLengthMs = 30; // Expect DelayManager to pass on the new length to the detector object. - EXPECT_CALL(detector_, SetPacketAudioLength(kLengthMs)) - .Times(1); + EXPECT_CALL(detector_, SetPacketAudioLength(kLengthMs)).Times(1); EXPECT_EQ(0, dm_->SetPacketAudioLength(kLengthMs)); EXPECT_EQ(-1, dm_->SetPacketAudioLength(-1)); // Illegal parameter value. } @@ -121,8 +119,7 @@ TEST_F(DelayManagerTest, UpdateNormal) { // Expect detector update method to be called once with inter-arrival time // equal to 1 packet, and (base) target level equal to 1 as well. // Return false to indicate no peaks found. - EXPECT_CALL(detector_, Update(1, 1)) - .WillOnce(Return(false)); + EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(false)); InsertNextPacket(); EXPECT_EQ(1 << 8, dm_->TargetLevel()); // In Q8. EXPECT_EQ(1, dm_->base_target_level()); @@ -145,8 +142,7 @@ TEST_F(DelayManagerTest, UpdateLongInterArrivalTime) { // Expect detector update method to be called once with inter-arrival time // equal to 1 packet, and (base) target level equal to 1 as well. // Return false to indicate no peaks found. - EXPECT_CALL(detector_, Update(2, 2)) - .WillOnce(Return(false)); + EXPECT_CALL(detector_, Update(2, 2)).WillOnce(Return(false)); InsertNextPacket(); EXPECT_EQ(2 << 8, dm_->TargetLevel()); // In Q8. EXPECT_EQ(2, dm_->base_target_level()); @@ -169,10 +165,8 @@ TEST_F(DelayManagerTest, UpdatePeakFound) { // Expect detector update method to be called once with inter-arrival time // equal to 1 packet, and (base) target level equal to 1 as well. // Return true to indicate that peaks are found. Let the peak height be 5. - EXPECT_CALL(detector_, Update(1, 1)) - .WillOnce(Return(true)); - EXPECT_CALL(detector_, MaxPeakHeight()) - .WillOnce(Return(5)); + EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(true)); + EXPECT_CALL(detector_, MaxPeakHeight()).WillOnce(Return(5)); InsertNextPacket(); EXPECT_EQ(5 << 8, dm_->TargetLevel()); EXPECT_EQ(1, dm_->base_target_level()); // Base target level is w/o peaks. @@ -193,8 +187,7 @@ TEST_F(DelayManagerTest, TargetDelay) { // Expect detector update method to be called once with inter-arrival time // equal to 1 packet, and (base) target level equal to 1 as well. // Return false to indicate no peaks found. - EXPECT_CALL(detector_, Update(1, 1)) - .WillOnce(Return(false)); + EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(false)); InsertNextPacket(); const int kExpectedTarget = 1; EXPECT_EQ(kExpectedTarget << 8, dm_->TargetLevel()); // In Q8. diff --git a/modules/audio_coding/neteq/delay_peak_detector_unittest.cc b/modules/audio_coding/neteq/delay_peak_detector_unittest.cc index 058ba66362..fd4dded608 100644 --- a/modules/audio_coding/neteq/delay_peak_detector_unittest.cc +++ b/modules/audio_coding/neteq/delay_peak_detector_unittest.cc @@ -65,8 +65,8 @@ TEST(DelayPeakDetector, TriggerPeakMode) { int next = 1; // Start with the second packet to get a proper IAT. while (next < kNumPackets) { while (next < kNumPackets && arrival_times_ms[next] <= time) { - int iat_packets = (arrival_times_ms[next] - arrival_times_ms[next - 1]) / - kPacketSizeMs; + int iat_packets = + (arrival_times_ms[next] - arrival_times_ms[next - 1]) / kPacketSizeMs; const int kTargetBufferLevel = 1; // Define peaks to be iat > 2. if (time < peak_mode_start_ms || time > peak_mode_end_ms) { EXPECT_FALSE(detector.Update(iat_packets, kTargetBufferLevel)); @@ -112,8 +112,8 @@ TEST(DelayPeakDetector, DoNotTriggerPeakMode) { int next = 1; // Start with the second packet to get a proper IAT. while (next < kNumPackets) { while (next < kNumPackets && arrival_times_ms[next] <= time) { - int iat_packets = (arrival_times_ms[next] - arrival_times_ms[next - 1]) / - kPacketSizeMs; + int iat_packets = + (arrival_times_ms[next] - arrival_times_ms[next - 1]) / kPacketSizeMs; const int kTargetBufferLevel = 2; // Define peaks to be iat > 4. EXPECT_FALSE(detector.Update(iat_packets, kTargetBufferLevel)); ++next; diff --git a/modules/audio_coding/neteq/dsp_helper.cc b/modules/audio_coding/neteq/dsp_helper.cc index 2a1d81ba0d..05b0f70bcf 100644 --- a/modules/audio_coding/neteq/dsp_helper.cc +++ b/modules/audio_coding/neteq/dsp_helper.cc @@ -21,41 +21,29 @@ namespace webrtc { // Table of constants used in method DspHelper::ParabolicFit(). const int16_t DspHelper::kParabolaCoefficients[17][3] = { - { 120, 32, 64 }, - { 140, 44, 75 }, - { 150, 50, 80 }, - { 160, 57, 85 }, - { 180, 72, 96 }, - { 200, 89, 107 }, - { 210, 98, 112 }, - { 220, 108, 117 }, - { 240, 128, 128 }, - { 260, 150, 139 }, - { 270, 162, 144 }, - { 280, 174, 149 }, - { 300, 200, 160 }, - { 320, 228, 171 }, - { 330, 242, 176 }, - { 340, 257, 181 }, - { 360, 288, 192 } }; + {120, 32, 64}, {140, 44, 75}, {150, 50, 80}, {160, 57, 85}, + {180, 72, 96}, {200, 89, 107}, {210, 98, 112}, {220, 108, 117}, + {240, 128, 128}, {260, 150, 139}, {270, 162, 144}, {280, 174, 149}, + {300, 200, 160}, {320, 228, 171}, {330, 242, 176}, {340, 257, 181}, + {360, 288, 192}}; // Filter coefficients used when downsampling from the indicated sample rates // (8, 16, 32, 48 kHz) to 4 kHz. Coefficients are in Q12. The corresponding Q0 // values are provided in the comments before each array. // Q0 values: {0.3, 0.4, 0.3}. -const int16_t DspHelper::kDownsample8kHzTbl[3] = { 1229, 1638, 1229 }; +const int16_t DspHelper::kDownsample8kHzTbl[3] = {1229, 1638, 1229}; // Q0 values: {0.15, 0.2, 0.3, 0.2, 0.15}. -const int16_t DspHelper::kDownsample16kHzTbl[5] = { 614, 819, 1229, 819, 614 }; +const int16_t DspHelper::kDownsample16kHzTbl[5] = {614, 819, 1229, 819, 614}; // Q0 values: {0.1425, 0.1251, 0.1525, 0.1628, 0.1525, 0.1251, 0.1425}. -const int16_t DspHelper::kDownsample32kHzTbl[7] = { - 584, 512, 625, 667, 625, 512, 584 }; +const int16_t DspHelper::kDownsample32kHzTbl[7] = {584, 512, 625, 667, + 625, 512, 584}; // Q0 values: {0.2487, 0.0952, 0.1042, 0.1074, 0.1042, 0.0952, 0.2487}. -const int16_t DspHelper::kDownsample48kHzTbl[7] = { - 1019, 390, 427, 440, 427, 390, 1019 }; +const int16_t DspHelper::kDownsample48kHzTbl[7] = {1019, 390, 427, 440, + 427, 390, 1019}; int DspHelper::RampSignal(const int16_t* input, size_t length, @@ -115,9 +103,12 @@ int DspHelper::RampSignal(AudioMultiVector* signal, return end_factor; } -void DspHelper::PeakDetection(int16_t* data, size_t data_length, - size_t num_peaks, int fs_mult, - size_t* peak_index, int16_t* peak_value) { +void DspHelper::PeakDetection(int16_t* data, + size_t data_length, + size_t num_peaks, + int fs_mult, + size_t* peak_index, + int16_t* peak_value) { size_t min_index = 0; size_t max_index = 0; @@ -163,8 +154,10 @@ void DspHelper::PeakDetection(int16_t* data, size_t data_length, } } -void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult, - size_t* peak_index, int16_t* peak_value) { +void DspHelper::ParabolicFit(int16_t* signal_points, + int fs_mult, + size_t* peak_index, + int16_t* peak_value) { uint16_t fit_index[13]; if (fs_mult == 1) { fit_index[0] = 0; @@ -204,23 +197,26 @@ void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult, // num = -3 * signal_points[0] + 4 * signal_points[1] - signal_points[2]; // den = signal_points[0] - 2 * signal_points[1] + signal_points[2]; - int32_t num = (signal_points[0] * -3) + (signal_points[1] * 4) - - signal_points[2]; + int32_t num = + (signal_points[0] * -3) + (signal_points[1] * 4) - signal_points[2]; int32_t den = signal_points[0] + (signal_points[1] * -2) + signal_points[2]; int32_t temp = num * 120; int flag = 1; - int16_t stp = kParabolaCoefficients[fit_index[fs_mult]][0] - - kParabolaCoefficients[fit_index[fs_mult - 1]][0]; - int16_t strt = (kParabolaCoefficients[fit_index[fs_mult]][0] - + kParabolaCoefficients[fit_index[fs_mult - 1]][0]) / 2; + int16_t stp = kParabolaCoefficients[fit_index[fs_mult]][0] - + kParabolaCoefficients[fit_index[fs_mult - 1]][0]; + int16_t strt = (kParabolaCoefficients[fit_index[fs_mult]][0] + + kParabolaCoefficients[fit_index[fs_mult - 1]][0]) / + 2; int16_t lmt; if (temp < -den * strt) { lmt = strt - stp; while (flag) { if ((flag == fs_mult) || (temp > -den * lmt)) { - *peak_value = (den * kParabolaCoefficients[fit_index[fs_mult - flag]][1] - + num * kParabolaCoefficients[fit_index[fs_mult - flag]][2] - + signal_points[0] * 256) / 256; + *peak_value = + (den * kParabolaCoefficients[fit_index[fs_mult - flag]][1] + + num * kParabolaCoefficients[fit_index[fs_mult - flag]][2] + + signal_points[0] * 256) / + 256; *peak_index = *peak_index * 2 * fs_mult - flag; flag = 0; } else { @@ -233,9 +229,9 @@ void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult, while (flag) { if ((flag == fs_mult) || (temp < -den * lmt)) { int32_t temp_term_1 = - den * kParabolaCoefficients[fit_index[fs_mult+flag]][1]; + den * kParabolaCoefficients[fit_index[fs_mult + flag]][1]; int32_t temp_term_2 = - num * kParabolaCoefficients[fit_index[fs_mult+flag]][2]; + num * kParabolaCoefficients[fit_index[fs_mult + flag]][2]; int32_t temp_term_3 = signal_points[0] * 256; *peak_value = (temp_term_1 + temp_term_2 + temp_term_3) / 256; *peak_index = *peak_index * 2 * fs_mult + flag; @@ -251,8 +247,10 @@ void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult, } } -size_t DspHelper::MinDistortion(const int16_t* signal, size_t min_lag, - size_t max_lag, size_t length, +size_t DspHelper::MinDistortion(const int16_t* signal, + size_t min_lag, + size_t max_lag, + size_t length, int32_t* distortion_value) { size_t best_index = 0; int32_t min_distortion = WEBRTC_SPL_WORD32_MAX; @@ -273,9 +271,12 @@ size_t DspHelper::MinDistortion(const int16_t* signal, size_t min_lag, return best_index; } -void DspHelper::CrossFade(const int16_t* input1, const int16_t* input2, - size_t length, int16_t* mix_factor, - int16_t factor_decrement, int16_t* output) { +void DspHelper::CrossFade(const int16_t* input1, + const int16_t* input2, + size_t length, + int16_t* mix_factor, + int16_t factor_decrement, + int16_t* output) { int16_t factor = *mix_factor; int16_t complement_factor = 16384 - factor; for (size_t i = 0; i < length; i++) { @@ -287,8 +288,10 @@ void DspHelper::CrossFade(const int16_t* input1, const int16_t* input2, *mix_factor = factor; } -void DspHelper::UnmuteSignal(const int16_t* input, size_t length, - int16_t* factor, int increment, +void DspHelper::UnmuteSignal(const int16_t* input, + size_t length, + int16_t* factor, + int increment, int16_t* output) { uint16_t factor_16b = *factor; int32_t factor_32b = (static_cast(factor_16b) << 6) + 32; @@ -308,17 +311,20 @@ void DspHelper::MuteSignal(int16_t* signal, int mute_slope, size_t length) { } } -int DspHelper::DownsampleTo4kHz(const int16_t* input, size_t input_length, - size_t output_length, int input_rate_hz, - bool compensate_delay, int16_t* output) { +int DspHelper::DownsampleTo4kHz(const int16_t* input, + size_t input_length, + size_t output_length, + int input_rate_hz, + bool compensate_delay, + int16_t* output) { // Set filter parameters depending on input frequency. // NOTE: The phase delay values are wrong compared to the true phase delay // of the filters. However, the error is preserved (through the +1 term) for // consistency. const int16_t* filter_coefficients; // Filter coefficients. - size_t filter_length; // Number of coefficients. - size_t filter_delay; // Phase delay in samples. - int16_t factor; // Conversion rate (inFsHz / 8000). + size_t filter_length; // Number of coefficients. + size_t filter_delay; // Phase delay in samples. + int16_t factor; // Conversion rate (inFsHz / 8000). switch (input_rate_hz) { case 8000: { filter_length = 3; diff --git a/modules/audio_coding/neteq/dsp_helper.h b/modules/audio_coding/neteq/dsp_helper.h index 7ceb66f57a..8940acd969 100644 --- a/modules/audio_coding/neteq/dsp_helper.h +++ b/modules/audio_coding/neteq/dsp_helper.h @@ -85,9 +85,12 @@ class DspHelper { // locations and values are written to the arrays |peak_index| and // |peak_value|, respectively. Both arrays must hold at least |num_peaks| // elements. - static void PeakDetection(int16_t* data, size_t data_length, - size_t num_peaks, int fs_mult, - size_t* peak_index, int16_t* peak_value); + static void PeakDetection(int16_t* data, + size_t data_length, + size_t num_peaks, + int fs_mult, + size_t* peak_index, + int16_t* peak_value); // Estimates the height and location of a maximum. The three values in the // array |signal_points| are used as basis for a parabolic fit, which is then @@ -95,30 +98,40 @@ class DspHelper { // assumed to be from a 4 kHz signal, while the maximum, written to // |peak_index| and |peak_value| is given in the full sample rate, as // indicated by the sample rate multiplier |fs_mult|. - static void ParabolicFit(int16_t* signal_points, int fs_mult, - size_t* peak_index, int16_t* peak_value); + static void ParabolicFit(int16_t* signal_points, + int fs_mult, + size_t* peak_index, + int16_t* peak_value); // Calculates the sum-abs-diff for |signal| when compared to a displaced // version of itself. Returns the displacement lag that results in the minimum // distortion. The resulting distortion is written to |distortion_value|. // The values of |min_lag| and |max_lag| are boundaries for the search. - static size_t MinDistortion(const int16_t* signal, size_t min_lag, - size_t max_lag, size_t length, - int32_t* distortion_value); + static size_t MinDistortion(const int16_t* signal, + size_t min_lag, + size_t max_lag, + size_t length, + int32_t* distortion_value); // Mixes |length| samples from |input1| and |input2| together and writes the // result to |output|. The gain for |input1| starts at |mix_factor| (Q14) and // is decreased by |factor_decrement| (Q14) for each sample. The gain for // |input2| is the complement 16384 - mix_factor. - static void CrossFade(const int16_t* input1, const int16_t* input2, - size_t length, int16_t* mix_factor, - int16_t factor_decrement, int16_t* output); + static void CrossFade(const int16_t* input1, + const int16_t* input2, + size_t length, + int16_t* mix_factor, + int16_t factor_decrement, + int16_t* output); // Scales |input| with an increasing gain. Applies |factor| (Q14) to the first // sample and increases the gain by |increment| (Q20) for each sample. The // result is written to |output|. |length| samples are processed. - static void UnmuteSignal(const int16_t* input, size_t length, int16_t* factor, - int increment, int16_t* output); + static void UnmuteSignal(const int16_t* input, + size_t length, + int16_t* factor, + int increment, + int16_t* output); // Starts at unity gain and gradually fades out |signal|. For each sample, // the gain is reduced by |mute_slope| (Q14). |length| samples are processed. @@ -129,9 +142,12 @@ class DspHelper { // samples to |output|. Compensates for the phase delay of the downsampling // filters if |compensate_delay| is true. Returns -1 if the input is too short // to produce |output_length| samples, otherwise 0. - static int DownsampleTo4kHz(const int16_t* input, size_t input_length, - size_t output_length, int input_rate_hz, - bool compensate_delay, int16_t* output); + static int DownsampleTo4kHz(const int16_t* input, + size_t input_length, + size_t output_length, + int input_rate_hz, + bool compensate_delay, + int16_t* output); private: // Table of constants used in method DspHelper::ParabolicFit(). diff --git a/modules/audio_coding/neteq/dsp_helper_unittest.cc b/modules/audio_coding/neteq/dsp_helper_unittest.cc index 98ae2a2c2d..9d5da5d4ef 100644 --- a/modules/audio_coding/neteq/dsp_helper_unittest.cc +++ b/modules/audio_coding/neteq/dsp_helper_unittest.cc @@ -30,8 +30,8 @@ TEST(DspHelper, RampSignalArray) { int increment = (16384 << 6) / kLen; // Test first method. - int stop_factor = DspHelper::RampSignal(input, kLen, start_factor, increment, - output); + int stop_factor = + DspHelper::RampSignal(input, kLen, start_factor, increment, output); EXPECT_EQ(16383, stop_factor); // Almost reach 1 in Q14. for (int i = 0; i < kLen; ++i) { EXPECT_EQ(1000 * i / kLen, output[i]); @@ -63,8 +63,8 @@ TEST(DspHelper, RampSignalAudioMultiVector) { // Q20, while the factor is in Q14, hence the shift by 6. int increment = (16384 << 6) / kLen; - int stop_factor = DspHelper::RampSignal(&input, start_index, kLen, - start_factor, increment); + int stop_factor = + DspHelper::RampSignal(&input, start_index, kLen, start_factor, increment); EXPECT_EQ(16383, stop_factor); // Almost reach 1 in Q14. // Verify that the first |kLen| samples are left untouched. int i; diff --git a/modules/audio_coding/neteq/dtmf_buffer.cc b/modules/audio_coding/neteq/dtmf_buffer.cc index 370de42bbe..656cff9606 100644 --- a/modules/audio_coding/neteq/dtmf_buffer.cc +++ b/modules/audio_coding/neteq/dtmf_buffer.cc @@ -98,9 +98,8 @@ int DtmfBuffer::ParseEvent(uint32_t rtp_timestamp, // already in the buffer. If so, the new event is simply merged with the // existing one. int DtmfBuffer::InsertEvent(const DtmfEvent& event) { - if (event.event_no < 0 || event.event_no > 15 || - event.volume < 0 || event.volume > 63 || - event.duration <= 0 || event.duration > 65535) { + if (event.event_no < 0 || event.event_no > 15 || event.volume < 0 || + event.volume > 63 || event.duration <= 0 || event.duration > 65535) { RTC_LOG(LS_WARNING) << "InsertEvent invalid parameters"; return kInvalidEventParameters; } @@ -142,8 +141,8 @@ bool DtmfBuffer::GetEvent(uint32_t current_timestamp, DtmfEvent* event) { #endif } } - if (current_timestamp >= it->timestamp - && current_timestamp <= event_end) { // TODO(hlundin): Change to <. + if (current_timestamp >= it->timestamp && + current_timestamp <= event_end) { // TODO(hlundin): Change to <. // Found a matching event. if (event) { event->event_no = it->event_no; @@ -153,16 +152,15 @@ bool DtmfBuffer::GetEvent(uint32_t current_timestamp, DtmfEvent* event) { event->timestamp = it->timestamp; } #ifdef LEGACY_BITEXACT - if (it->end_bit && - current_timestamp + frame_len_samples_ >= event_end) { + if (it->end_bit && current_timestamp + frame_len_samples_ >= event_end) { // We are done playing this. Erase the event. buffer_.erase(it); } #endif return true; } else if (current_timestamp > event_end) { // TODO(hlundin): Change to >=. - // Erase old event. Operation returns a valid pointer to the next element - // in the list. +// Erase old event. Operation returns a valid pointer to the next element +// in the list. #ifdef LEGACY_BITEXACT if (!next_available) { if (event) { @@ -196,10 +194,7 @@ bool DtmfBuffer::Empty() const { } int DtmfBuffer::SetSampleRate(int fs_hz) { - if (fs_hz != 8000 && - fs_hz != 16000 && - fs_hz != 32000 && - fs_hz != 48000) { + if (fs_hz != 8000 && fs_hz != 16000 && fs_hz != 32000 && fs_hz != 48000) { return kInvalidSampleRate; } max_extrapolation_samples_ = 7 * fs_hz / 100; diff --git a/modules/audio_coding/neteq/dtmf_buffer.h b/modules/audio_coding/neteq/dtmf_buffer.h index 87a56554d5..1035e87c8f 100644 --- a/modules/audio_coding/neteq/dtmf_buffer.h +++ b/modules/audio_coding/neteq/dtmf_buffer.h @@ -28,19 +28,9 @@ struct DtmfEvent { // Constructors DtmfEvent() - : timestamp(0), - event_no(0), - volume(0), - duration(0), - end_bit(false) { - } + : timestamp(0), event_no(0), volume(0), duration(0), end_bit(false) {} DtmfEvent(uint32_t ts, int ev, int vol, int dur, bool end) - : timestamp(ts), - event_no(ev), - volume(vol), - duration(dur), - end_bit(end) { - } + : timestamp(ts), event_no(ev), volume(vol), duration(dur), end_bit(end) {} }; // This is the buffer holding DTMF events while waiting for them to be played. diff --git a/modules/audio_coding/neteq/dtmf_buffer_unittest.cc b/modules/audio_coding/neteq/dtmf_buffer_unittest.cc index 7bcf1e0f4e..607a5ec6fa 100644 --- a/modules/audio_coding/neteq/dtmf_buffer_unittest.cc +++ b/modules/audio_coding/neteq/dtmf_buffer_unittest.cc @@ -31,11 +31,11 @@ static int sample_rate_hz = 8000; static uint32_t MakeDtmfPayload(int event, bool end, int volume, int duration) { uint32_t payload = 0; -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | event |E|R| volume | duration | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // 0 1 2 3 + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // | event |E|R| volume | duration | + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ payload |= (event & 0x00FF) << 24; payload |= (end ? 0x00800000 : 0x00000000); payload |= (volume & 0x003F) << 16; @@ -44,13 +44,10 @@ static uint32_t MakeDtmfPayload(int event, bool end, int volume, int duration) { return payload; } -static bool EqualEvents(const DtmfEvent& a, - const DtmfEvent& b) { - return (a.duration == b.duration - && a.end_bit == b.end_bit - && a.event_no == b.event_no - && a.timestamp == b.timestamp - && a.volume == b.volume); +static bool EqualEvents(const DtmfEvent& a, const DtmfEvent& b) { + return (a.duration == b.duration && a.end_bit == b.end_bit && + a.event_no == b.event_no && a.timestamp == b.timestamp && + a.volume == b.volume); } TEST(DtmfBuffer, CreateAndDestroy) { @@ -68,9 +65,8 @@ TEST(DtmfBuffer, ParseEvent) { uint32_t payload = MakeDtmfPayload(event_no, end_bit, volume, duration); uint8_t* payload_ptr = reinterpret_cast(&payload); DtmfEvent event; - EXPECT_EQ(DtmfBuffer::kOK, - DtmfBuffer::ParseEvent(timestamp, payload_ptr, sizeof(payload), - &event)); + EXPECT_EQ(DtmfBuffer::kOK, DtmfBuffer::ParseEvent(timestamp, payload_ptr, + sizeof(payload), &event)); EXPECT_EQ(duration, event.duration); EXPECT_EQ(end_bit, event.end_bit); EXPECT_EQ(event_no, event.event_no); @@ -107,7 +103,7 @@ TEST(DtmfBuffer, SimpleInsertAndGet) { EXPECT_TRUE(EqualEvents(event, out_event)); EXPECT_EQ(1u, buffer.Length()); EXPECT_FALSE(buffer.Empty()); - // Give a "current" timestamp after the event has ended. +// Give a "current" timestamp after the event has ended. #ifdef LEGACY_BITEXACT EXPECT_TRUE(buffer.GetEvent(timestamp + duration + 10, &out_event)); #endif @@ -171,17 +167,17 @@ TEST(DtmfBuffer, OverlappingEvents) { // Expect to get the long event. EXPECT_TRUE(buffer.GetEvent(timestamp, &out_event)); EXPECT_TRUE(EqualEvents(long_event, out_event)); - // Expect no more events. +// Expect no more events. #ifdef LEGACY_BITEXACT - EXPECT_TRUE(buffer.GetEvent(timestamp + long_event.duration + 10, - &out_event)); + EXPECT_TRUE( + buffer.GetEvent(timestamp + long_event.duration + 10, &out_event)); EXPECT_TRUE(EqualEvents(long_event, out_event)); - EXPECT_TRUE(buffer.GetEvent(timestamp + long_event.duration + 10, - &out_event)); + EXPECT_TRUE( + buffer.GetEvent(timestamp + long_event.duration + 10, &out_event)); EXPECT_TRUE(EqualEvents(short_event, out_event)); #else - EXPECT_FALSE(buffer.GetEvent(timestamp + long_event.duration + 10, - &out_event)); + EXPECT_FALSE( + buffer.GetEvent(timestamp + long_event.duration + 10, &out_event)); #endif EXPECT_TRUE(buffer.Empty()); } diff --git a/modules/audio_coding/neteq/dtmf_tone_generator.cc b/modules/audio_coding/neteq/dtmf_tone_generator.cc index b848c600d0..6fdb95aaca 100644 --- a/modules/audio_coding/neteq/dtmf_tone_generator.cc +++ b/modules/audio_coding/neteq/dtmf_tone_generator.cc @@ -39,72 +39,69 @@ namespace webrtc { // sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0 through 15. // Values are in Q14. const int DtmfToneGenerator::kCoeff1[4][16] = { - { 24219, 27980, 27980, 27980, 26956, 26956, 26956, 25701, 25701, 25701, - 24219, 24219, 27980, 26956, 25701, 24219 }, - { 30556, 31548, 31548, 31548, 31281, 31281, 31281, 30951, 30951, 30951, - 30556, 30556, 31548, 31281, 30951, 30556 }, - { 32210, 32462, 32462, 32462, 32394, 32394, 32394, 32311, 32311, 32311, - 32210, 32210, 32462, 32394, 32311, 32210 }, - { 32520, 32632, 32632, 32632, 32602, 32602, 32602, 32564, 32564, 32564, - 32520, 32520, 32632, 32602, 32564, 32520 } }; + {24219, 27980, 27980, 27980, 26956, 26956, 26956, 25701, 25701, 25701, + 24219, 24219, 27980, 26956, 25701, 24219}, + {30556, 31548, 31548, 31548, 31281, 31281, 31281, 30951, 30951, 30951, + 30556, 30556, 31548, 31281, 30951, 30556}, + {32210, 32462, 32462, 32462, 32394, 32394, 32394, 32311, 32311, 32311, + 32210, 32210, 32462, 32394, 32311, 32210}, + {32520, 32632, 32632, 32632, 32602, 32602, 32602, 32564, 32564, 32564, + 32520, 32520, 32632, 32602, 32564, 32520}}; // The filter coefficient a = 2*cos(2*pi*f/fs) for the high frequency tone, for // sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0 through 15. // Values are in Q14. const int DtmfToneGenerator::kCoeff2[4][16] = { - { 16325, 19073, 16325, 13085, 19073, 16325, 13085, 19073, 16325, 13085, - 19073, 13085, 9315, 9315, 9315, 9315}, - { 28361, 29144, 28361, 27409, 29144, 28361, 27409, 29144, 28361, 27409, - 29144, 27409, 26258, 26258, 26258, 26258}, - { 31647, 31849, 31647, 31400, 31849, 31647, 31400, 31849, 31647, 31400, - 31849, 31400, 31098, 31098, 31098, 31098}, - { 32268, 32359, 32268, 32157, 32359, 32268, 32157, 32359, 32268, 32157, - 32359, 32157, 32022, 32022, 32022, 32022} }; + {16325, 19073, 16325, 13085, 19073, 16325, 13085, 19073, 16325, 13085, + 19073, 13085, 9315, 9315, 9315, 9315}, + {28361, 29144, 28361, 27409, 29144, 28361, 27409, 29144, 28361, 27409, + 29144, 27409, 26258, 26258, 26258, 26258}, + {31647, 31849, 31647, 31400, 31849, 31647, 31400, 31849, 31647, 31400, + 31849, 31400, 31098, 31098, 31098, 31098}, + {32268, 32359, 32268, 32157, 32359, 32268, 32157, 32359, 32268, 32157, + 32359, 32157, 32022, 32022, 32022, 32022}}; // The initialization value x[-2] = sin(2*pi*f/fs) for the low frequency tone, // for sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0-15. // Values are in Q14. const int DtmfToneGenerator::kInitValue1[4][16] = { - { 11036, 8528, 8528, 8528, 9315, 9315, 9315, 10163, 10163, 10163, 11036, - 11036, 8528, 9315, 10163, 11036}, - { 5918, 4429, 4429, 4429, 4879, 4879, 4879, 5380, 5380, 5380, 5918, 5918, - 4429, 4879, 5380, 5918}, - { 3010, 2235, 2235, 2235, 2468, 2468, 2468, 2728, 2728, 2728, 3010, 3010, - 2235, 2468, 2728, 3010}, - { 2013, 1493, 1493, 1493, 1649, 1649, 1649, 1823, 1823, 1823, 2013, 2013, - 1493, 1649, 1823, 2013 } }; + {11036, 8528, 8528, 8528, 9315, 9315, 9315, 10163, 10163, 10163, 11036, + 11036, 8528, 9315, 10163, 11036}, + {5918, 4429, 4429, 4429, 4879, 4879, 4879, 5380, 5380, 5380, 5918, 5918, + 4429, 4879, 5380, 5918}, + {3010, 2235, 2235, 2235, 2468, 2468, 2468, 2728, 2728, 2728, 3010, 3010, + 2235, 2468, 2728, 3010}, + {2013, 1493, 1493, 1493, 1649, 1649, 1649, 1823, 1823, 1823, 2013, 2013, + 1493, 1649, 1823, 2013}}; // The initialization value x[-2] = sin(2*pi*f/fs) for the high frequency tone, // for sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0-15. // Values are in Q14. const int DtmfToneGenerator::kInitValue2[4][16] = { - { 14206, 13323, 14206, 15021, 13323, 14206, 15021, 13323, 14206, 15021, - 13323, 15021, 15708, 15708, 15708, 15708}, - { 8207, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8979, - 9801, 9801, 9801, 9801}, - { 4249, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4685, - 5164, 5164, 5164, 5164}, - { 2851, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 3148, - 3476, 3476, 3476, 3476} }; + {14206, 13323, 14206, 15021, 13323, 14206, 15021, 13323, 14206, 15021, + 13323, 15021, 15708, 15708, 15708, 15708}, + {8207, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8979, + 9801, 9801, 9801, 9801}, + {4249, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4685, + 5164, 5164, 5164, 5164}, + {2851, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 3148, + 3476, 3476, 3476, 3476}}; // Amplitude multipliers for volume values 0 through 63, corresponding to // 0 dBm0 through -63 dBm0. Values are in Q14. // for a in range(0, 64): // print round(16141.0 * 10**(-float(a)/20)) const int DtmfToneGenerator::kAmplitude[64] = { - 16141, 14386, 12821, 11427, 10184, 9077, 8090, 7210, 6426, 5727, 5104, 4549, - 4054, 3614, 3221, 2870, 2558, 2280, 2032, 1811, 1614, 1439, 1282, 1143, - 1018, 908, 809, 721, 643, 573, 510, 455, 405, 361, 322, 287, 256, 228, 203, - 181, 161, 144, 128, 114, 102, 91, 81, 72, 64, 57, 51, 45, 41, 36, 32, 29, - 26, 23, 20, 18, 16, 14, 13, 11 }; + 16141, 14386, 12821, 11427, 10184, 9077, 8090, 7210, 6426, 5727, 5104, + 4549, 4054, 3614, 3221, 2870, 2558, 2280, 2032, 1811, 1614, 1439, + 1282, 1143, 1018, 908, 809, 721, 643, 573, 510, 455, 405, + 361, 322, 287, 256, 228, 203, 181, 161, 144, 128, 114, + 102, 91, 81, 72, 64, 57, 51, 45, 41, 36, 32, + 29, 26, 23, 20, 18, 16, 14, 13, 11}; // Constructor. DtmfToneGenerator::DtmfToneGenerator() - : initialized_(false), - coeff1_(0), - coeff2_(0), - amplitude_(0) { -} + : initialized_(false), coeff1_(0), coeff2_(0), amplitude_(0) {} // Initialize the DTMF generator with sample rate fs Hz (8000, 16000, 32000, // 48000), event (0-15) and attenuation (0-36 dB). @@ -170,8 +167,7 @@ void DtmfToneGenerator::Reset() { } // Generate num_samples of DTMF signal and write to |output|. -int DtmfToneGenerator::Generate(size_t num_samples, - AudioMultiVector* output) { +int DtmfToneGenerator::Generate(size_t num_samples, AudioMultiVector* output) { if (!initialized_) { return kNotInitialized; } @@ -183,10 +179,10 @@ int DtmfToneGenerator::Generate(size_t num_samples, output->AssertSize(num_samples); for (size_t i = 0; i < num_samples; ++i) { // Use recursion formula y[n] = a * y[n - 1] - y[n - 2]. - int16_t temp_val_low = ((coeff1_ * sample_history1_[1] + 8192) >> 14) - - sample_history1_[0]; - int16_t temp_val_high = ((coeff2_ * sample_history2_[1] + 8192) >> 14) - - sample_history2_[0]; + int16_t temp_val_low = + ((coeff1_ * sample_history1_[1] + 8192) >> 14) - sample_history1_[0]; + int16_t temp_val_high = + ((coeff2_ * sample_history2_[1] + 8192) >> 14) - sample_history2_[0]; // Update recursion memory. sample_history1_[0] = sample_history1_[1]; diff --git a/modules/audio_coding/neteq/dtmf_tone_generator.h b/modules/audio_coding/neteq/dtmf_tone_generator.h index faad6a25b1..b91d221a52 100644 --- a/modules/audio_coding/neteq/dtmf_tone_generator.h +++ b/modules/audio_coding/neteq/dtmf_tone_generator.h @@ -37,7 +37,7 @@ class DtmfToneGenerator { static const int kCoeff2[4][16]; // 2nd oscillator model coefficient table. static const int kInitValue1[4][16]; // Initialization for 1st oscillator. static const int kInitValue2[4][16]; // Initialization for 2nd oscillator. - static const int kAmplitude[64]; // Amplitude for 0 through -63 dBm0. + static const int kAmplitude[64]; // Amplitude for 0 through -63 dBm0. static const int16_t kAmpMultiplier = 23171; // 3 dB attenuation (in Q15). bool initialized_; // True if generator is initialized properly. diff --git a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc index 8c22fe5542..11a0ac6a6b 100644 --- a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc +++ b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc @@ -84,8 +84,7 @@ class DtmfToneGeneratorTest : public ::testing::Test { // Verify that the attenuation is correct. for (int channel = 0; channel < channels; ++channel) { EXPECT_NEAR(attenuation_factor * ref_signal[channel][n], - signal[channel][n], - 2); + signal[channel][n], 2); } } diff --git a/modules/audio_coding/neteq/expand.cc b/modules/audio_coding/neteq/expand.cc index 73e8d07e0d..5f671ada6b 100644 --- a/modules/audio_coding/neteq/expand.cc +++ b/modules/audio_coding/neteq/expand.cc @@ -14,7 +14,7 @@ #include // memset #include // min, max -#include // numeric_limits +#include // numeric_limits #include "common_audio/signal_processing/include/signal_processing_library.h" #include "modules/audio_coding/neteq/background_noise.h" @@ -94,7 +94,6 @@ int Expand::Process(AudioMultiVector* output) { GenerateRandomVector(2, rand_length, random_vector); } - // Generate signal. UpdateLagIndex(); @@ -103,8 +102,8 @@ int Expand::Process(AudioMultiVector* output) { size_t expansion_vector_length = max_lag_ + overlap_length_; size_t current_lag = expand_lags_[current_lag_index_]; // Copy lag+overlap data. - size_t expansion_vector_position = expansion_vector_length - current_lag - - overlap_length_; + size_t expansion_vector_position = + expansion_vector_length - current_lag - overlap_length_; size_t temp_length = current_lag + overlap_length_; for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) { ChannelParameters& parameters = channel_parameters_[channel_ix]; @@ -175,8 +174,10 @@ int Expand::Process(AudioMultiVector* output) { // Do overlap add between new vector and overlap. (*sync_buffer_)[channel_ix][start_ix + i] = (((*sync_buffer_)[channel_ix][start_ix + i] * muting_window) + - (((parameters.mute_factor * voiced_vector_storage[i]) >> 14) * - unmuting_window) + 16384) >> 15; + (((parameters.mute_factor * voiced_vector_storage[i]) >> 14) * + unmuting_window) + + 16384) >> + 15; muting_window += muting_window_increment; unmuting_window += unmuting_window_increment; } @@ -188,10 +189,10 @@ int Expand::Process(AudioMultiVector* output) { // parameters.expand_vector0 and parameters.expand_vector1 no longer // match with expand_lags_, causing invalid reads and writes. Is it a good // idea to enable this again, and solve the vector size problem? -// max_lag_ = fs_mult * 120; -// expand_lags_[0] = fs_mult * 120; -// expand_lags_[1] = fs_mult * 120; -// expand_lags_[2] = fs_mult * 120; + // max_lag_ = fs_mult * 120; + // expand_lags_[0] = fs_mult * 120; + // expand_lags_[1] = fs_mult * 120; + // expand_lags_[2] = fs_mult * 120; } // Unvoiced part. @@ -204,8 +205,7 @@ int Expand::Process(AudioMultiVector* output) { } WebRtcSpl_AffineTransformVector(scaled_random_vector, random_vector, parameters.ar_gain, add_constant, - parameters.ar_gain_scale, - current_lag); + parameters.ar_gain_scale, current_lag); WebRtcSpl_FilterARFastQ12(scaled_random_vector, unvoiced_vector, parameters.ar_filter, kUnvoicedLpcOrder + 1, current_lag); @@ -230,8 +230,9 @@ int Expand::Process(AudioMultiVector* output) { // Create combined signal by shifting in more and more of unvoiced part. temp_shift = 8 - temp_shift; // = getbits(mix_factor_increment). - size_t temp_length = (parameters.current_voice_mix_factor - - parameters.voice_mix_factor) >> temp_shift; + size_t temp_length = + (parameters.current_voice_mix_factor - parameters.voice_mix_factor) >> + temp_shift; temp_length = std::min(temp_length, current_lag); DspHelper::CrossFade(voiced_vector, unvoiced_vector, temp_length, ¶meters.current_voice_mix_factor, @@ -266,9 +267,8 @@ int Expand::Process(AudioMultiVector* output) { // Mute segment according to slope value. if ((consecutive_expands_ != 0) || !parameters.onset) { // Mute to the previous level, then continue with the muting. - WebRtcSpl_AffineTransformVector(temp_data, temp_data, - parameters.mute_factor, 8192, - 14, current_lag); + WebRtcSpl_AffineTransformVector( + temp_data, temp_data, parameters.mute_factor, 8192, 14, current_lag); if (!stop_muting_) { DspHelper::MuteSignal(temp_data, parameters.mute_slope, current_lag); @@ -276,8 +276,8 @@ int Expand::Process(AudioMultiVector* output) { // Shift by 6 to go from Q20 to Q14. // TODO(hlundin): Adding 8192 before shifting 6 steps seems wrong. // Legacy. - int16_t gain = static_cast(16384 - - (((current_lag * parameters.mute_slope) + 8192) >> 6)); + int16_t gain = static_cast( + 16384 - (((current_lag * parameters.mute_slope) + 8192) >> 6)); gain = ((gain * parameters.mute_factor) + 8192) >> 14; // Guard against getting stuck with very small (but sometimes audible) @@ -291,12 +291,9 @@ int Expand::Process(AudioMultiVector* output) { } // Background noise part. - GenerateBackgroundNoise(random_vector, - channel_ix, - channel_parameters_[channel_ix].mute_slope, - TooManyExpands(), - current_lag, - unvoiced_array_memory); + GenerateBackgroundNoise( + random_vector, channel_ix, channel_parameters_[channel_ix].mute_slope, + TooManyExpands(), current_lag, unvoiced_array_memory); // Add background noise to the combined voiced-unvoiced signal. for (size_t i = 0; i < current_lag; i++) { @@ -311,8 +308,9 @@ int Expand::Process(AudioMultiVector* output) { } // Increase call number and cap it. - consecutive_expands_ = consecutive_expands_ >= kMaxConsecutiveExpands ? - kMaxConsecutiveExpands : consecutive_expands_ + 1; + consecutive_expands_ = consecutive_expands_ >= kMaxConsecutiveExpands + ? kMaxConsecutiveExpands + : consecutive_expands_ + 1; expand_duration_samples_ += output->Size(); // Clamp the duration counter at 2 seconds. expand_duration_samples_ = std::min(expand_duration_samples_, @@ -329,7 +327,7 @@ void Expand::SetParametersForNormalAfterExpand() { } void Expand::SetParametersForMergeAfterExpand() { - current_lag_index_ = -1; /* out of the 3 possible ones */ + current_lag_index_ = -1; /* out of the 3 possible ones */ lag_index_direction_ = 1; /* make sure we get the "optimal" lag */ stop_muting_ = true; } @@ -357,7 +355,7 @@ void Expand::InitializeForAnExpandPeriod() { consecutive_expands_ = 0; for (size_t ix = 0; ix < num_channels_; ++ix) { channel_parameters_[ix].current_voice_mix_factor = 16384; // 1.0 in Q14. - channel_parameters_[ix].mute_factor = 16384; // 1.0 in Q14. + channel_parameters_[ix].mute_factor = 16384; // 1.0 in Q14. // Start with 0 gain for background noise. background_noise_->SetMuteFactor(ix, 0); } @@ -420,10 +418,10 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Calculate distortion around the |kNumCorrelationCandidates| best lags. int distortion_scale = 0; for (size_t i = 0; i < kNumCorrelationCandidates; i++) { - size_t min_index = std::max(fs_mult_20, - best_correlation_index[i] - fs_mult_4); - size_t max_index = std::min(fs_mult_120 - 1, - best_correlation_index[i] + fs_mult_4); + size_t min_index = + std::max(fs_mult_20, best_correlation_index[i] - fs_mult_4); + size_t max_index = + std::min(fs_mult_120 - 1, best_correlation_index[i] + fs_mult_4); best_distortion_index[i] = DspHelper::MinDistortion( &(audio_history[signal_length - fs_mult_dist_len]), min_index, max_index, fs_mult_dist_len, &best_distortion_w32[i]); @@ -459,23 +457,23 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Calculate the exact best correlation in the range between // |correlation_lag| and |distortion_lag|. - correlation_length = - std::max(std::min(distortion_lag + 10, fs_mult_120), - static_cast(60 * fs_mult)); + correlation_length = std::max(std::min(distortion_lag + 10, fs_mult_120), + static_cast(60 * fs_mult)); size_t start_index = std::min(distortion_lag, correlation_lag); size_t correlation_lags = static_cast( - WEBRTC_SPL_ABS_W16((distortion_lag-correlation_lag)) + 1); + WEBRTC_SPL_ABS_W16((distortion_lag - correlation_lag)) + 1); assert(correlation_lags <= static_cast(99 * fs_mult + 1)); for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) { ChannelParameters& parameters = channel_parameters_[channel_ix]; // Calculate suitable scaling. int16_t signal_max = WebRtcSpl_MaxAbsValueW16( - &audio_history[signal_length - correlation_length - start_index - - correlation_lags], - correlation_length + start_index + correlation_lags - 1); - int correlation_scale = (31 - WebRtcSpl_NormW32(signal_max * signal_max)) + + &audio_history[signal_length - correlation_length - start_index - + correlation_lags], + correlation_length + start_index + correlation_lags - 1); + int correlation_scale = + (31 - WebRtcSpl_NormW32(signal_max * signal_max)) + (31 - WebRtcSpl_NormW32(static_cast(correlation_length))) - 31; correlation_scale = std::max(0, correlation_scale); @@ -520,8 +518,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Calculate max_correlation / sqrt(energy1 * energy2) in Q14. int cc_shift = 14 - (energy1_scale + energy2_scale) / 2; max_correlation = WEBRTC_SPL_SHIFT_W32(max_correlation, cc_shift); - corr_coefficient = WebRtcSpl_DivW32W16(max_correlation, - sqrt_energy_product); + corr_coefficient = + WebRtcSpl_DivW32W16(max_correlation, sqrt_energy_product); // Cap at 1.0 in Q14. corr_coefficient = std::min(16384, corr_coefficient); } else { @@ -547,9 +545,9 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { int32_t scaled_energy2 = std::max(16 - WebRtcSpl_NormW32(energy2), 0); int32_t scaled_energy1 = scaled_energy2 - 13; // Calculate scaled_energy1 / scaled_energy2 in Q13. - int32_t energy_ratio = WebRtcSpl_DivW32W16( - WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1), - static_cast(energy2 >> scaled_energy2)); + int32_t energy_ratio = + WebRtcSpl_DivW32W16(WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1), + static_cast(energy2 >> scaled_energy2)); // Calculate sqrt ratio in Q13 (sqrt of en1/en2 in Q26). amplitude_ratio = static_cast(WebRtcSpl_SqrtFloor(energy_ratio << 13)); @@ -558,16 +556,13 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { parameters.expand_vector0.PushBack(vector1, expansion_length); parameters.expand_vector1.Clear(); if (parameters.expand_vector1.Size() < expansion_length) { - parameters.expand_vector1.Extend( - expansion_length - parameters.expand_vector1.Size()); + parameters.expand_vector1.Extend(expansion_length - + parameters.expand_vector1.Size()); } std::unique_ptr temp_1(new int16_t[expansion_length]); - WebRtcSpl_AffineTransformVector(temp_1.get(), - const_cast(vector2), - amplitude_ratio, - 4096, - 13, - expansion_length); + WebRtcSpl_AffineTransformVector( + temp_1.get(), const_cast(vector2), amplitude_ratio, 4096, + 13, expansion_length); parameters.expand_vector1.OverwriteAt(temp_1.get(), expansion_length, 0); } else { // Energy change constraint not fulfilled. Only use last vector. @@ -606,11 +601,11 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Calculate the LPC and the gain of the filters. // Calculate kUnvoicedLpcOrder + 1 lags of the auto-correlation function. - size_t temp_index = signal_length - fs_mult_lpc_analysis_len - - kUnvoicedLpcOrder; + size_t temp_index = + signal_length - fs_mult_lpc_analysis_len - kUnvoicedLpcOrder; // Copy signal to temporary vector to be able to pad with leading zeros. - int16_t* temp_signal = new int16_t[fs_mult_lpc_analysis_len - + kUnvoicedLpcOrder]; + int16_t* temp_signal = + new int16_t[fs_mult_lpc_analysis_len + kUnvoicedLpcOrder]; memset(temp_signal, 0, sizeof(int16_t) * (fs_mult_lpc_analysis_len + kUnvoicedLpcOrder)); memcpy(&temp_signal[kUnvoicedLpcOrder], @@ -619,16 +614,15 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { CrossCorrelationWithAutoShift( &temp_signal[kUnvoicedLpcOrder], &temp_signal[kUnvoicedLpcOrder], fs_mult_lpc_analysis_len, kUnvoicedLpcOrder + 1, -1, auto_correlation); - delete [] temp_signal; + delete[] temp_signal; // Verify that variance is positive. if (auto_correlation[0] > 0) { // Estimate AR filter parameters using Levinson-Durbin algorithm; // kUnvoicedLpcOrder + 1 filter coefficients. - int16_t stability = WebRtcSpl_LevinsonDurbin(auto_correlation, - parameters.ar_filter, - reflection_coeff, - kUnvoicedLpcOrder); + int16_t stability = + WebRtcSpl_LevinsonDurbin(auto_correlation, parameters.ar_filter, + reflection_coeff, kUnvoicedLpcOrder); // Keep filter parameters only if filter is stable. if (stability != 1) { @@ -671,10 +665,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { &(audio_history[signal_length - 128 - kUnvoicedLpcOrder]), sizeof(int16_t) * kUnvoicedLpcOrder); WebRtcSpl_FilterMAFastQ12(&audio_history[signal_length - 128], - unvoiced_vector, - parameters.ar_filter, - kUnvoicedLpcOrder + 1, - 128); + unvoiced_vector, parameters.ar_filter, + kUnvoicedLpcOrder + 1, 128); const int unvoiced_max_abs = [&] { const int16_t max_abs = WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128); // Since WebRtcSpl_MaxAbsValueW16 returns 2^15 - 1 when the input contains @@ -689,10 +681,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { int unvoiced_prescale = std::max(0, 2 * WebRtcSpl_GetSizeInBits(unvoiced_max_abs) - 24); - int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(unvoiced_vector, - unvoiced_vector, - 128, - unvoiced_prescale); + int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale( + unvoiced_vector, unvoiced_vector, 128, unvoiced_prescale); // Normalize |unvoiced_energy| to 28 or 29 bits to preserve sqrt() accuracy. int16_t unvoiced_scale = WebRtcSpl_NormW32(unvoiced_energy) - 3; @@ -703,8 +693,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { unvoiced_energy = WEBRTC_SPL_SHIFT_W32(unvoiced_energy, unvoiced_scale); int16_t unvoiced_gain = static_cast(WebRtcSpl_SqrtFloor(unvoiced_energy)); - parameters.ar_gain_scale = 13 - + (unvoiced_scale + 7 - unvoiced_prescale) / 2; + parameters.ar_gain_scale = + 13 + (unvoiced_scale + 7 - unvoiced_prescale) / 2; parameters.ar_gain = unvoiced_gain; // Calculate voice_mix_factor from corr_coefficient. @@ -717,17 +707,17 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { int16_t x1, x2, x3; // |corr_coefficient| is in Q14. x1 = static_cast(corr_coefficient); - x2 = (x1 * x1) >> 14; // Shift 14 to keep result in Q14. + x2 = (x1 * x1) >> 14; // Shift 14 to keep result in Q14. x3 = (x1 * x2) >> 14; - static const int kCoefficients[4] = { -5179, 19931, -16422, 5776 }; + static const int kCoefficients[4] = {-5179, 19931, -16422, 5776}; int32_t temp_sum = kCoefficients[0] * 16384; temp_sum += kCoefficients[1] * x1; temp_sum += kCoefficients[2] * x2; temp_sum += kCoefficients[3] * x3; parameters.voice_mix_factor = static_cast(std::min(temp_sum / 4096, 16384)); - parameters.voice_mix_factor = std::max(parameters.voice_mix_factor, - static_cast(0)); + parameters.voice_mix_factor = + std::max(parameters.voice_mix_factor, static_cast(0)); } else { parameters.voice_mix_factor = 0; } @@ -816,8 +806,8 @@ void Expand::Correlation(const int16_t* input, static const size_t kNumCorrelationLags = 54; static const size_t kCorrelationLength = 60; // Downsample to 4 kHz sample rate. - static const size_t kDownsampledLength = kCorrelationStartLag - + kNumCorrelationLags + kCorrelationLength; + static const size_t kDownsampledLength = + kCorrelationStartLag + kNumCorrelationLags + kCorrelationLength; int16_t downsampled_input[kDownsampledLength]; static const size_t kFilterDelay = 0; WebRtcSpl_DownsampleFast( @@ -827,8 +817,8 @@ void Expand::Correlation(const int16_t* input, downsampling_factor, kFilterDelay); // Normalize |downsampled_input| to using all 16 bits. - int16_t max_value = WebRtcSpl_MaxAbsValueW16(downsampled_input, - kDownsampledLength); + int16_t max_value = + WebRtcSpl_MaxAbsValueW16(downsampled_input, kDownsampledLength); int16_t norm_shift = 16 - WebRtcSpl_NormW32(max_value); WebRtcSpl_VectorBitShiftW16(downsampled_input, kDownsampledLength, downsampled_input, norm_shift); @@ -836,13 +826,13 @@ void Expand::Correlation(const int16_t* input, int32_t correlation[kNumCorrelationLags]; CrossCorrelationWithAutoShift( &downsampled_input[kDownsampledLength - kCorrelationLength], - &downsampled_input[kDownsampledLength - kCorrelationLength - - kCorrelationStartLag], + &downsampled_input[kDownsampledLength - kCorrelationLength - + kCorrelationStartLag], kCorrelationLength, kNumCorrelationLags, -1, correlation); // Normalize and move data from 32-bit to 16-bit vector. - int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation, - kNumCorrelationLags); + int32_t max_correlation = + WebRtcSpl_MaxAbsValueW32(correlation, kNumCorrelationLags); int16_t norm_shift2 = static_cast( std::max(18 - WebRtcSpl_NormW32(max_correlation), 0)); WebRtcSpl_VectorBitShiftW32ToW16(output, kNumCorrelationLags, correlation, @@ -894,19 +884,15 @@ void Expand::GenerateBackgroundNoise(int16_t* random_vector, // Scale random vector to correct energy level. WebRtcSpl_AffineTransformVector( - scaled_random_vector, random_vector, - background_noise_->Scale(channel), dc_offset, - background_noise_->ScaleShift(channel), - num_noise_samples); + scaled_random_vector, random_vector, background_noise_->Scale(channel), + dc_offset, background_noise_->ScaleShift(channel), num_noise_samples); WebRtcSpl_FilterARFastQ12(scaled_random_vector, noise_samples, background_noise_->Filter(channel), - kNoiseLpcOrder + 1, - num_noise_samples); + kNoiseLpcOrder + 1, num_noise_samples); background_noise_->SetFilterState( - channel, - &(noise_samples[num_noise_samples - kNoiseLpcOrder]), + channel, &(noise_samples[num_noise_samples - kNoiseLpcOrder]), kNoiseLpcOrder); // Unmute the background noise. diff --git a/modules/audio_coding/neteq/expand.h b/modules/audio_coding/neteq/expand.h index 4060bd78bc..2fd4faec96 100644 --- a/modules/audio_coding/neteq/expand.h +++ b/modules/audio_coding/neteq/expand.h @@ -114,7 +114,7 @@ class Expand { int16_t ar_filter_state[kUnvoicedLpcOrder]; int16_t ar_gain; int16_t ar_gain_scale; - int16_t voice_mix_factor; /* Q14 */ + int16_t voice_mix_factor; /* Q14 */ int16_t current_voice_mix_factor; /* Q14 */ AudioVector expand_vector0; AudioVector expand_vector1; diff --git a/modules/audio_coding/neteq/include/neteq.h b/modules/audio_coding/neteq/include/neteq.h index 6288aeb1c5..273979b333 100644 --- a/modules/audio_coding/neteq/include/neteq.h +++ b/modules/audio_coding/neteq/include/neteq.h @@ -33,25 +33,25 @@ class AudioFrame; class AudioDecoderFactory; struct NetEqNetworkStatistics { - uint16_t current_buffer_size_ms; // Current jitter buffer size in ms. + uint16_t current_buffer_size_ms; // Current jitter buffer size in ms. uint16_t preferred_buffer_size_ms; // Target buffer size in ms. - uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky - // jitter; 0 otherwise. - uint16_t packet_loss_rate; // Loss rate (network + late) in Q14. - uint16_t expand_rate; // Fraction (of original stream) of synthesized - // audio inserted through expansion (in Q14). + uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky + // jitter; 0 otherwise. + uint16_t packet_loss_rate; // Loss rate (network + late) in Q14. + uint16_t expand_rate; // Fraction (of original stream) of synthesized + // audio inserted through expansion (in Q14). uint16_t speech_expand_rate; // Fraction (of original stream) of synthesized // speech inserted through expansion (in Q14). - uint16_t preemptive_rate; // Fraction of data inserted through pre-emptive - // expansion (in Q14). - uint16_t accelerate_rate; // Fraction of data removed through acceleration - // (in Q14). - uint16_t secondary_decoded_rate; // Fraction of data coming from FEC/RED - // decoding (in Q14). + uint16_t preemptive_rate; // Fraction of data inserted through pre-emptive + // expansion (in Q14). + uint16_t accelerate_rate; // Fraction of data removed through acceleration + // (in Q14). + uint16_t secondary_decoded_rate; // Fraction of data coming from FEC/RED + // decoding (in Q14). uint16_t secondary_discarded_rate; // Fraction of discarded FEC/RED data (in // Q14). - int32_t clockdrift_ppm; // Average clock-drift in parts-per-million - // (positive or negative). + int32_t clockdrift_ppm; // Average clock-drift in parts-per-million + // (positive or negative). size_t added_zero_samples; // Number of zero samples added in "off" mode. // Statistics for packet waiting times, i.e., the time between a packet // arrives until it is decoded. @@ -104,11 +104,7 @@ class NetEq { absl::optional codec_pair_id; }; - enum ReturnCodes { - kOK = 0, - kFail = -1, - kNotImplemented = -2 - }; + enum ReturnCodes { kOK = 0, kFail = -1, kNotImplemented = -2 }; // Creates a new NetEq object, with parameters set in |config|. The |config| // object will only have to be valid for the duration of the call to this diff --git a/modules/audio_coding/neteq/merge.cc b/modules/audio_coding/neteq/merge.cc index fb0bb0df10..3c9ad19d05 100644 --- a/modules/audio_coding/neteq/merge.cc +++ b/modules/audio_coding/neteq/merge.cc @@ -43,10 +43,11 @@ Merge::Merge(int fs_hz, Merge::~Merge() = default; -size_t Merge::Process(int16_t* input, size_t input_length, +size_t Merge::Process(int16_t* input, + size_t input_length, AudioMultiVector* output) { // TODO(hlundin): Change to an enumerator and skip assert. - assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || + assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || fs_hz_ == 48000); assert(fs_hz_ <= kMaxSampleRate); // Should not be possible. @@ -68,8 +69,8 @@ size_t Merge::Process(int16_t* input, size_t input_length, new int16_t[input_length_per_channel]); std::unique_ptr expanded_channel(new int16_t[expanded_length]); for (size_t channel = 0; channel < num_channels_; ++channel) { - input_vector[channel].CopyTo( - input_length_per_channel, 0, input_channel.get()); + input_vector[channel].CopyTo(input_length_per_channel, 0, + input_channel.get()); expanded_[channel].CopyTo(expanded_length, 0, expanded_channel.get()); const int16_t new_mute_factor = std::min( @@ -93,11 +94,11 @@ size_t Merge::Process(int16_t* input, size_t input_length, // Mute the new decoded data if needed (and unmute it linearly). // This is the overlapping part of expanded_signal. - size_t interpolation_length = std::min( - kMaxCorrelationLength * fs_mult_, - expanded_length - best_correlation_index); - interpolation_length = std::min(interpolation_length, - input_length_per_channel); + size_t interpolation_length = + std::min(kMaxCorrelationLength * fs_mult_, + expanded_length - best_correlation_index); + interpolation_length = + std::min(interpolation_length, input_length_per_channel); RTC_DCHECK_LE(new_mute_factor, 16384); int16_t mute_factor = @@ -203,30 +204,28 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) { return required_length; } -int16_t Merge::SignalScaling(const int16_t* input, size_t input_length, +int16_t Merge::SignalScaling(const int16_t* input, + size_t input_length, const int16_t* expanded_signal) const { // Adjust muting factor if new vector is more or less of the BGN energy. const auto mod_input_length = rtc::SafeMin( 64 * rtc::dchecked_cast(fs_mult_), input_length); const int16_t expanded_max = WebRtcSpl_MaxAbsValueW16(expanded_signal, mod_input_length); - int32_t factor = (expanded_max * expanded_max) / - (std::numeric_limits::max() / - static_cast(mod_input_length)); + int32_t factor = + (expanded_max * expanded_max) / (std::numeric_limits::max() / + static_cast(mod_input_length)); const int expanded_shift = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor); - int32_t energy_expanded = WebRtcSpl_DotProductWithScale(expanded_signal, - expanded_signal, - mod_input_length, - expanded_shift); + int32_t energy_expanded = WebRtcSpl_DotProductWithScale( + expanded_signal, expanded_signal, mod_input_length, expanded_shift); // Calculate energy of input signal. const int16_t input_max = WebRtcSpl_MaxAbsValueW16(input, mod_input_length); factor = (input_max * input_max) / (std::numeric_limits::max() / - static_cast(mod_input_length)); + static_cast(mod_input_length)); const int input_shift = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor); - int32_t energy_input = WebRtcSpl_DotProductWithScale(input, input, - mod_input_length, - input_shift); + int32_t energy_input = WebRtcSpl_DotProductWithScale( + input, input, mod_input_length, input_shift); // Align to the same Q-domain. if (input_shift > expanded_shift) { @@ -257,8 +256,10 @@ int16_t Merge::SignalScaling(const int16_t* input, size_t input_length, // TODO(hlundin): There are some parameter values in this method that seem // strange. Compare with Expand::Correlation. -void Merge::Downsample(const int16_t* input, size_t input_length, - const int16_t* expanded_signal, size_t expanded_length) { +void Merge::Downsample(const int16_t* input, + size_t input_length, + const int16_t* expanded_signal, + size_t expanded_length) { const int16_t* filter_coefficients; size_t num_coefficients; int decimation_factor = fs_hz_ / 4000; @@ -278,11 +279,10 @@ void Merge::Downsample(const int16_t* input, size_t input_length, num_coefficients = 7; } size_t signal_offset = num_coefficients - 1; - WebRtcSpl_DownsampleFast(&expanded_signal[signal_offset], - expanded_length - signal_offset, - expanded_downsampled_, kExpandDownsampLength, - filter_coefficients, num_coefficients, - decimation_factor, kCompensateDelay); + WebRtcSpl_DownsampleFast( + &expanded_signal[signal_offset], expanded_length - signal_offset, + expanded_downsampled_, kExpandDownsampLength, filter_coefficients, + num_coefficients, decimation_factor, kCompensateDelay); if (input_length <= length_limit) { // Not quite long enough, so we have to cheat a bit. // If the input is really short, we'll just use the input length as is, and @@ -301,15 +301,15 @@ void Merge::Downsample(const int16_t* input, size_t input_length, memset(&input_downsampled_[downsamp_temp_len], 0, sizeof(int16_t) * (kInputDownsampLength - downsamp_temp_len)); } else { - WebRtcSpl_DownsampleFast(&input[signal_offset], - input_length - signal_offset, input_downsampled_, - kInputDownsampLength, filter_coefficients, - num_coefficients, decimation_factor, - kCompensateDelay); + WebRtcSpl_DownsampleFast( + &input[signal_offset], input_length - signal_offset, input_downsampled_, + kInputDownsampLength, filter_coefficients, num_coefficients, + decimation_factor, kCompensateDelay); } } -size_t Merge::CorrelateAndPeakSearch(size_t start_position, size_t input_length, +size_t Merge::CorrelateAndPeakSearch(size_t start_position, + size_t input_length, size_t expand_period) const { // Calculate correlation without any normalization. const size_t max_corr_length = kMaxCorrelationLength; @@ -328,8 +328,8 @@ size_t Merge::CorrelateAndPeakSearch(size_t start_position, size_t input_length, new int16_t[correlation_buffer_size]); memset(correlation16.get(), 0, correlation_buffer_size * sizeof(int16_t)); int16_t* correlation_ptr = &correlation16[pad_length]; - int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation, - stop_position_downsamp); + int32_t max_correlation = + WebRtcSpl_MaxAbsValueW32(correlation, stop_position_downsamp); int norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation)); WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp, correlation, norm_shift); @@ -366,7 +366,7 @@ size_t Merge::CorrelateAndPeakSearch(size_t start_position, size_t input_length, while (((best_correlation_index + input_length) < (timestamps_per_call_ + expand_->overlap_length())) || ((best_correlation_index + input_length) < start_position)) { - assert(false); // Should never happen. + assert(false); // Should never happen. best_correlation_index += expand_period; // Jump one lag ahead. } return best_correlation_index; @@ -376,5 +376,4 @@ size_t Merge::RequiredFutureSamples() { return fs_hz_ / 100 * num_channels_; // 10 ms. } - } // namespace webrtc diff --git a/modules/audio_coding/neteq/merge.h b/modules/audio_coding/neteq/merge.h index 6da0b4f071..017e824edf 100644 --- a/modules/audio_coding/neteq/merge.h +++ b/modules/audio_coding/neteq/merge.h @@ -44,7 +44,8 @@ class Merge { // (interleaved). The result is written to |output|. The number of channels // allocated in |output| defines the number of channels that will be used when // de-interleaving |input|. - virtual size_t Process(int16_t* input, size_t input_length, + virtual size_t Process(int16_t* input, + size_t input_length, AudioMultiVector* output); virtual size_t RequiredFutureSamples(); @@ -68,19 +69,23 @@ class Merge { // Analyzes |input| and |expanded_signal| and returns muting factor (Q14) to // be used on the new data. - int16_t SignalScaling(const int16_t* input, size_t input_length, + int16_t SignalScaling(const int16_t* input, + size_t input_length, const int16_t* expanded_signal) const; // Downsamples |input| (|input_length| samples) and |expanded_signal| to // 4 kHz sample rate. The downsampled signals are written to // |input_downsampled_| and |expanded_downsampled_|, respectively. - void Downsample(const int16_t* input, size_t input_length, - const int16_t* expanded_signal, size_t expanded_length); + void Downsample(const int16_t* input, + size_t input_length, + const int16_t* expanded_signal, + size_t expanded_length); // Calculates cross-correlation between |input_downsampled_| and // |expanded_downsampled_|, and finds the correlation maximum. The maximizing // lag is returned. - size_t CorrelateAndPeakSearch(size_t start_position, size_t input_length, + size_t CorrelateAndPeakSearch(size_t start_position, + size_t input_length, size_t expand_period) const; const int fs_mult_; // fs_hz_ / 8000. diff --git a/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h b/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h index f662fb6ec0..bf9fd59c9a 100644 --- a/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h +++ b/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h @@ -20,17 +20,14 @@ namespace webrtc { class MockBufferLevelFilter : public BufferLevelFilter { public: virtual ~MockBufferLevelFilter() { Die(); } - MOCK_METHOD0(Die, - void()); - MOCK_METHOD0(Reset, - void()); + MOCK_METHOD0(Die, void()); + MOCK_METHOD0(Reset, void()); MOCK_METHOD3(Update, - void(size_t buffer_size_packets, int time_stretched_samples, - size_t packet_len_samples)); - MOCK_METHOD1(SetTargetBufferLevel, - void(int target_buffer_level)); - MOCK_CONST_METHOD0(filtered_current_level, - int()); + void(size_t buffer_size_packets, + int time_stretched_samples, + size_t packet_len_samples)); + MOCK_METHOD1(SetTargetBufferLevel, void(int target_buffer_level)); + MOCK_CONST_METHOD0(filtered_current_level, int()); }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_decoder_database.h b/modules/audio_coding/neteq/mock/mock_decoder_database.h index 3d57edd95c..b1d815141e 100644 --- a/modules/audio_coding/neteq/mock/mock_decoder_database.h +++ b/modules/audio_coding/neteq/mock/mock_decoder_database.h @@ -26,15 +26,13 @@ class MockDecoderDatabase : public DecoderDatabase { : DecoderDatabase(factory, absl::nullopt) {} virtual ~MockDecoderDatabase() { Die(); } MOCK_METHOD0(Die, void()); - MOCK_CONST_METHOD0(Empty, - bool()); - MOCK_CONST_METHOD0(Size, - int()); - MOCK_METHOD0(Reset, - void()); + MOCK_CONST_METHOD0(Empty, bool()); + MOCK_CONST_METHOD0(Size, int()); + MOCK_METHOD0(Reset, void()); MOCK_METHOD3(RegisterPayload, - int(uint8_t rtp_payload_type, NetEqDecoder codec_type, - const std::string& name)); + int(uint8_t rtp_payload_type, + NetEqDecoder codec_type, + const std::string& name)); MOCK_METHOD2(RegisterPayload, int(int rtp_payload_type, const SdpAudioFormat& audio_format)); MOCK_METHOD4(InsertExternal, @@ -42,19 +40,15 @@ class MockDecoderDatabase : public DecoderDatabase { NetEqDecoder codec_type, const std::string& codec_name, AudioDecoder* decoder)); - MOCK_METHOD1(Remove, - int(uint8_t rtp_payload_type)); + MOCK_METHOD1(Remove, int(uint8_t rtp_payload_type)); MOCK_METHOD0(RemoveAll, void()); MOCK_CONST_METHOD1(GetDecoderInfo, - const DecoderInfo*(uint8_t rtp_payload_type)); + const DecoderInfo*(uint8_t rtp_payload_type)); MOCK_METHOD2(SetActiveDecoder, - int(uint8_t rtp_payload_type, bool* new_decoder)); - MOCK_CONST_METHOD0(GetActiveDecoder, - AudioDecoder*()); - MOCK_METHOD1(SetActiveCngDecoder, - int(uint8_t rtp_payload_type)); - MOCK_CONST_METHOD0(GetActiveCngDecoder, - ComfortNoiseDecoder*()); + int(uint8_t rtp_payload_type, bool* new_decoder)); + MOCK_CONST_METHOD0(GetActiveDecoder, AudioDecoder*()); + MOCK_METHOD1(SetActiveCngDecoder, int(uint8_t rtp_payload_type)); + MOCK_CONST_METHOD0(GetActiveCngDecoder, ComfortNoiseDecoder*()); }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_delay_manager.h b/modules/audio_coding/neteq/mock/mock_delay_manager.h index 61f209d5c4..9b2ed498d9 100644 --- a/modules/audio_coding/neteq/mock/mock_delay_manager.h +++ b/modules/audio_coding/neteq/mock/mock_delay_manager.h @@ -25,37 +25,25 @@ class MockDelayManager : public DelayManager { : DelayManager(max_packets_in_buffer, peak_detector, tick_timer) {} virtual ~MockDelayManager() { Die(); } MOCK_METHOD0(Die, void()); - MOCK_CONST_METHOD0(iat_vector, - const IATVector&()); + MOCK_CONST_METHOD0(iat_vector, const IATVector&()); MOCK_METHOD3(Update, - int(uint16_t sequence_number, uint32_t timestamp, int sample_rate_hz)); - MOCK_METHOD1(CalculateTargetLevel, - int(int iat_packets)); - MOCK_METHOD1(SetPacketAudioLength, - int(int length_ms)); - MOCK_METHOD0(Reset, - void()); - MOCK_CONST_METHOD0(PeakFound, - bool()); - MOCK_METHOD1(UpdateCounters, - void(int elapsed_time_ms)); - MOCK_METHOD0(ResetPacketIatCount, - void()); - MOCK_CONST_METHOD2(BufferLimits, - void(int* lower_limit, int* higher_limit)); - MOCK_CONST_METHOD0(TargetLevel, - int()); + int(uint16_t sequence_number, + uint32_t timestamp, + int sample_rate_hz)); + MOCK_METHOD1(CalculateTargetLevel, int(int iat_packets)); + MOCK_METHOD1(SetPacketAudioLength, int(int length_ms)); + MOCK_METHOD0(Reset, void()); + MOCK_CONST_METHOD0(PeakFound, bool()); + MOCK_METHOD1(UpdateCounters, void(int elapsed_time_ms)); + MOCK_METHOD0(ResetPacketIatCount, void()); + MOCK_CONST_METHOD2(BufferLimits, void(int* lower_limit, int* higher_limit)); + MOCK_CONST_METHOD0(TargetLevel, int()); MOCK_METHOD0(RegisterEmptyPacket, void()); - MOCK_METHOD1(set_extra_delay_ms, - void(int16_t delay)); - MOCK_CONST_METHOD0(base_target_level, - int()); - MOCK_METHOD1(set_streaming_mode, - void(bool value)); - MOCK_CONST_METHOD0(last_pack_cng_or_dtmf, - int()); - MOCK_METHOD1(set_last_pack_cng_or_dtmf, - void(int value)); + MOCK_METHOD1(set_extra_delay_ms, void(int16_t delay)); + MOCK_CONST_METHOD0(base_target_level, int()); + MOCK_METHOD1(set_streaming_mode, void(bool value)); + MOCK_CONST_METHOD0(last_pack_cng_or_dtmf, int()); + MOCK_METHOD1(set_last_pack_cng_or_dtmf, void(int value)); }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h b/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h index 153a4d716a..11b571f86c 100644 --- a/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h +++ b/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h @@ -22,16 +22,11 @@ class MockDtmfBuffer : public DtmfBuffer { MockDtmfBuffer(int fs) : DtmfBuffer(fs) {} virtual ~MockDtmfBuffer() { Die(); } MOCK_METHOD0(Die, void()); - MOCK_METHOD0(Flush, - void()); - MOCK_METHOD1(InsertEvent, - int(const DtmfEvent& event)); - MOCK_METHOD2(GetEvent, - bool(uint32_t current_timestamp, DtmfEvent* event)); - MOCK_CONST_METHOD0(Length, - size_t()); - MOCK_CONST_METHOD0(Empty, - bool()); + MOCK_METHOD0(Flush, void()); + MOCK_METHOD1(InsertEvent, int(const DtmfEvent& event)); + MOCK_METHOD2(GetEvent, bool(uint32_t current_timestamp, DtmfEvent* event)); + MOCK_CONST_METHOD0(Length, size_t()); + MOCK_CONST_METHOD0(Empty, bool()); }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h b/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h index 2cb5980891..be4b7b5f61 100644 --- a/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h +++ b/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h @@ -21,14 +21,10 @@ class MockDtmfToneGenerator : public DtmfToneGenerator { public: virtual ~MockDtmfToneGenerator() { Die(); } MOCK_METHOD0(Die, void()); - MOCK_METHOD3(Init, - int(int fs, int event, int attenuation)); - MOCK_METHOD0(Reset, - void()); - MOCK_METHOD2(Generate, - int(size_t num_samples, AudioMultiVector* output)); - MOCK_CONST_METHOD0(initialized, - bool()); + MOCK_METHOD3(Init, int(int fs, int event, int attenuation)); + MOCK_METHOD0(Reset, void()); + MOCK_METHOD2(Generate, int(size_t num_samples, AudioMultiVector* output)); + MOCK_CONST_METHOD0(initialized, bool()); }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_expand.h b/modules/audio_coding/neteq/mock/mock_expand.h index 05fdaec750..aed01646f5 100644 --- a/modules/audio_coding/neteq/mock/mock_expand.h +++ b/modules/audio_coding/neteq/mock/mock_expand.h @@ -33,16 +33,11 @@ class MockExpand : public Expand { num_channels) {} virtual ~MockExpand() { Die(); } MOCK_METHOD0(Die, void()); - MOCK_METHOD0(Reset, - void()); - MOCK_METHOD1(Process, - int(AudioMultiVector* output)); - MOCK_METHOD0(SetParametersForNormalAfterExpand, - void()); - MOCK_METHOD0(SetParametersForMergeAfterExpand, - void()); - MOCK_CONST_METHOD0(overlap_length, - size_t()); + MOCK_METHOD0(Reset, void()); + MOCK_METHOD1(Process, int(AudioMultiVector* output)); + MOCK_METHOD0(SetParametersForNormalAfterExpand, void()); + MOCK_METHOD0(SetParametersForMergeAfterExpand, void()); + MOCK_CONST_METHOD0(overlap_length, size_t()); }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h b/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h index b3152405b5..5aed6a9d72 100644 --- a/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h +++ b/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h @@ -75,17 +75,16 @@ class MockExternalPcm16B : public AudioDecoder { int sample_rate_hz, int16_t* decoded, SpeechType* speech_type)); - MOCK_CONST_METHOD0(HasDecodePlc, - bool()); - MOCK_METHOD2(DecodePlc, - size_t(size_t num_frames, int16_t* decoded)); + MOCK_CONST_METHOD0(HasDecodePlc, bool()); + MOCK_METHOD2(DecodePlc, size_t(size_t num_frames, int16_t* decoded)); MOCK_METHOD0(Reset, void()); MOCK_METHOD5(IncomingPacket, - int(const uint8_t* payload, size_t payload_len, - uint16_t rtp_sequence_number, uint32_t rtp_timestamp, - uint32_t arrival_timestamp)); - MOCK_METHOD0(ErrorCode, - int()); + int(const uint8_t* payload, + size_t payload_len, + uint16_t rtp_sequence_number, + uint32_t rtp_timestamp, + uint32_t arrival_timestamp)); + MOCK_METHOD0(ErrorCode, int()); int SampleRateHz() const /* override */ { return real_.SampleRateHz(); } size_t Channels() const /* override */ { return real_.Channels(); } diff --git a/modules/audio_coding/neteq/nack_tracker.h b/modules/audio_coding/neteq/nack_tracker.h index 66383ce088..1936a944cc 100644 --- a/modules/audio_coding/neteq/nack_tracker.h +++ b/modules/audio_coding/neteq/nack_tracker.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_ #define MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_ -#include #include +#include #include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/include/module_common_types.h" diff --git a/modules/audio_coding/neteq/neteq.cc b/modules/audio_coding/neteq/neteq.cc index db1258903a..55af23e99a 100644 --- a/modules/audio_coding/neteq/neteq.cc +++ b/modules/audio_coding/neteq/neteq.cc @@ -27,14 +27,12 @@ NetEq::Config& NetEq::Config::operator=(Config&&) = default; std::string NetEq::Config::ToString() const { char buf[1024]; rtc::SimpleStringBuilder ss(buf); - ss << "sample_rate_hz=" << sample_rate_hz - << ", enable_post_decode_vad=" + ss << "sample_rate_hz=" << sample_rate_hz << ", enable_post_decode_vad=" << (enable_post_decode_vad ? "true" : "false") << ", max_packets_in_buffer=" << max_packets_in_buffer - << ", playout_mode=" << playout_mode - << ", enable_fast_accelerate=" - << (enable_fast_accelerate ? " true": "false") - << ", enable_muted_state=" << (enable_muted_state ? " true": "false"); + << ", playout_mode=" << playout_mode << ", enable_fast_accelerate=" + << (enable_fast_accelerate ? " true" : "false") + << ", enable_muted_state=" << (enable_muted_state ? " true" : "false"); return ss.str(); } diff --git a/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc index 03f5aa3cc0..5c350bb47a 100644 --- a/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc +++ b/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc @@ -55,8 +55,8 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { } virtual ~NetEqExternalDecoderUnitTest() { - delete [] input_; - delete [] encoded_; + delete[] input_; + delete[] encoded_; // ~NetEqExternalDecoderTest() will delete |external_decoder_|, so expecting // Die() to be called. EXPECT_CALL(*external_decoder_, Die()).Times(1); @@ -75,8 +75,8 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { if (!input_file_->Read(frame_size_samples_, input_)) { return -1; } - payload_size_bytes_ = WebRtcPcm16b_Encode(input_, frame_size_samples_, - encoded_); + payload_size_bytes_ = + WebRtcPcm16b_Encode(input_, frame_size_samples_, encoded_); int next_send_time = rtp_generator_->GetRtpHeader( kPayloadType, frame_size_samples_, &rtp_header_); @@ -111,9 +111,10 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { uint32_t time_now = 0; for (int k = 0; k < num_loops; ++k) { while (time_now >= next_arrival_time) { - InsertPacket(rtp_header_, rtc::ArrayView( - encoded_, payload_size_bytes_), - next_arrival_time); + InsertPacket( + rtp_header_, + rtc::ArrayView(encoded_, payload_size_bytes_), + next_arrival_time); // Get next input packet. do { next_send_time = GetNewPacket(); @@ -148,6 +149,7 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { } int samples_per_ms() const { return samples_per_ms_; } + private: std::unique_ptr external_decoder_; int samples_per_ms_; @@ -337,11 +339,9 @@ TEST_F(LargeTimestampJumpTest, JumpLongerThanHalfRange) { static_cast(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF, "jump should be larger than half range"); // Replace the default RTP generator with one that jumps in timestamp. - ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), - kStartSeqeunceNumber, - kStartTimestamp, - kJumpFromTimestamp, - kJumpToTimestamp)); + ResetRtpGenerator(new test::TimestampJumpRtpGenerator( + samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp, + kJumpFromTimestamp, kJumpToTimestamp)); RunTest(130); // Run 130 laps @ 10 ms each in the test loop. EXPECT_EQ(kRecovered, test_state_); @@ -361,11 +361,9 @@ TEST_F(LargeTimestampJumpTest, JumpLongerThanHalfRangeAndWrap) { static_cast(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF, "jump should be larger than half range"); // Replace the default RTP generator with one that jumps in timestamp. - ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), - kStartSeqeunceNumber, - kStartTimestamp, - kJumpFromTimestamp, - kJumpToTimestamp)); + ResetRtpGenerator(new test::TimestampJumpRtpGenerator( + samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp, + kJumpFromTimestamp, kJumpToTimestamp)); RunTest(130); // Run 130 laps @ 10 ms each in the test loop. EXPECT_EQ(kRecovered, test_state_); @@ -420,11 +418,9 @@ TEST_F(ShortTimestampJumpTest, JumpShorterThanHalfRange) { static_cast(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF, "jump should be smaller than half range"); // Replace the default RTP generator with one that jumps in timestamp. - ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), - kStartSeqeunceNumber, - kStartTimestamp, - kJumpFromTimestamp, - kJumpToTimestamp)); + ResetRtpGenerator(new test::TimestampJumpRtpGenerator( + samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp, + kJumpFromTimestamp, kJumpToTimestamp)); RunTest(130); // Run 130 laps @ 10 ms each in the test loop. EXPECT_EQ(kRecovered, test_state_); @@ -444,11 +440,9 @@ TEST_F(ShortTimestampJumpTest, JumpShorterThanHalfRangeAndWrap) { static_cast(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF, "jump should be smaller than half range"); // Replace the default RTP generator with one that jumps in timestamp. - ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), - kStartSeqeunceNumber, - kStartTimestamp, - kJumpFromTimestamp, - kJumpToTimestamp)); + ResetRtpGenerator(new test::TimestampJumpRtpGenerator( + samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp, + kJumpFromTimestamp, kJumpToTimestamp)); RunTest(130); // Run 130 laps @ 10 ms each in the test loop. EXPECT_EQ(kRecovered, test_state_); diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc index 40eae1b8de..afc15bf248 100644 --- a/modules/audio_coding/neteq/neteq_impl.cc +++ b/modules/audio_coding/neteq/neteq_impl.cc @@ -681,8 +681,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, decoder->IncomingPacket(packet_list.front().payload.data(), packet_list.front().payload.size(), packet_list.front().sequence_number, - packet_list.front().timestamp, - receive_timestamp); + packet_list.front().timestamp, receive_timestamp); } PacketList parsed_packet_list; @@ -703,7 +702,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, const auto sequence_number = packet.sequence_number; const auto payload_type = packet.payload_type; const Packet::Priority original_priority = packet.priority; - auto packet_from_result = [&] (AudioDecoder::ParseResult& result) { + auto packet_from_result = [&](AudioDecoder::ParseResult& result) { Packet new_packet; new_packet.sequence_number = sequence_number; new_packet.payload_type = payload_type; @@ -788,8 +787,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, assert(decoder_info); if (decoder_info->SampleRateHz() != fs_hz_ || channels != algorithm_buffer_->Channels()) { - SetSampleRateAndChannels(decoder_info->SampleRateHz(), - channels); + SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels); } if (nack_enabled_) { RTC_DCHECK(nack_); @@ -866,8 +864,8 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) { return 0; } - int return_value = GetDecision(&operation, &packet_list, &dtmf_event, - &play_dtmf); + int return_value = + GetDecision(&operation, &packet_list, &dtmf_event, &play_dtmf); if (return_value != 0) { last_mode_ = kModeError; return return_value; @@ -876,12 +874,11 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) { AudioDecoder::SpeechType speech_type; int length = 0; const size_t start_num_packets = packet_list.size(); - int decode_return_value = Decode(&packet_list, &operation, - &length, &speech_type); + int decode_return_value = + Decode(&packet_list, &operation, &length, &speech_type); assert(vad_.get()); - bool sid_frame_available = - (operation == kRfc3389Cng && !packet_list.empty()); + bool sid_frame_available = (operation == kRfc3389Cng && !packet_list.empty()); vad_->Update(decoded_buffer_.get(), static_cast(length), speech_type, sid_frame_available, fs_hz_); @@ -1033,8 +1030,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) { // Update the background noise parameters if last operation wrote data // straight from the decoder to the |sync_buffer_|. That is, none of the // operations that modify the signal can be followed by a parameter update. - if ((last_mode_ == kModeNormal) || - (last_mode_ == kModeAccelerateFail) || + if ((last_mode_ == kModeNormal) || (last_mode_ == kModeAccelerateFail) || (last_mode_ == kModePreemptiveExpandFail) || (last_mode_ == kModeRfc3389Cng) || (last_mode_ == kModeCodecInternalCng)) { @@ -1051,7 +1047,8 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) { // If last operation was not expand, calculate the |playout_timestamp_| from // the |sync_buffer_|. However, do not update the |playout_timestamp_| if it // would be moved "backwards". - uint32_t temp_timestamp = sync_buffer_->end_timestamp() - + uint32_t temp_timestamp = + sync_buffer_->end_timestamp() - static_cast(sync_buffer_->FutureLength()); if (static_cast(temp_timestamp - playout_timestamp_) > 0) { playout_timestamp_ = temp_timestamp; @@ -1070,13 +1067,13 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) { : timestamp_scaler_->ToExternal(playout_timestamp_) - static_cast(audio_frame->samples_per_channel_); - if (!(last_mode_ == kModeRfc3389Cng || - last_mode_ == kModeCodecInternalCng || - last_mode_ == kModeExpand)) { + if (!(last_mode_ == kModeRfc3389Cng || last_mode_ == kModeCodecInternalCng || + last_mode_ == kModeExpand)) { generated_noise_stopwatch_.reset(); } - if (decode_return_value) return decode_return_value; + if (decode_return_value) + return decode_return_value; return return_value; } @@ -1100,11 +1097,10 @@ int NetEqImpl::GetDecision(Operations* operation, RTC_DCHECK(!generated_noise_stopwatch_ || generated_noise_stopwatch_->ElapsedTicks() >= 1); uint64_t generated_noise_samples = - generated_noise_stopwatch_ - ? (generated_noise_stopwatch_->ElapsedTicks() - 1) * - output_size_samples_ + - decision_logic_->noise_fast_forward() - : 0; + generated_noise_stopwatch_ ? (generated_noise_stopwatch_->ElapsedTicks() - + 1) * output_size_samples_ + + decision_logic_->noise_fast_forward() + : 0; if (decision_logic_->CngRfc3389On() || last_mode_ == kModeRfc3389Cng) { // Because of timestamp peculiarities, we have to "manually" disallow using @@ -1127,7 +1123,7 @@ int NetEqImpl::GetDecision(Operations* operation, assert(expand_.get()); const int samples_left = static_cast(sync_buffer_->FutureLength() - - expand_->overlap_length()); + expand_->overlap_length()); if (last_mode_ == kModeAccelerateSuccess || last_mode_ == kModeAccelerateLowEnergy || last_mode_ == kModePreemptiveExpandSuccess || @@ -1139,9 +1135,8 @@ int NetEqImpl::GetDecision(Operations* operation, // Check if it is time to play a DTMF event. if (dtmf_buffer_->GetEvent( - static_cast( - end_timestamp + generated_noise_samples), - dtmf_event)) { + static_cast(end_timestamp + generated_noise_samples), + dtmf_event)) { *play_dtmf = true; } @@ -1243,12 +1238,12 @@ int NetEqImpl::GetDecision(Operations* operation, decision_logic_->set_prev_time_scale(true); return 0; } else if (samples_left >= static_cast(samples_10_ms) && - decoder_frame_length_ >= samples_30_ms) { + decoder_frame_length_ >= samples_30_ms) { // Avoid decoding more data as it might overflow the playout buffer. *operation = kNormal; return 0; } else if (samples_left < static_cast(samples_20_ms) && - decoder_frame_length_ < samples_30_ms) { + decoder_frame_length_ < samples_30_ms) { // Build up decoded data by decoding at least 20 ms of audio data. Do // not perform accelerate yet, but wait until we only need to do one // decoding. @@ -1267,7 +1262,7 @@ int NetEqImpl::GetDecision(Operations* operation, // audio data. if ((samples_left >= static_cast(samples_30_ms)) || (samples_left >= static_cast(samples_10_ms) && - decoder_frame_length_ >= samples_30_ms)) { + decoder_frame_length_ >= samples_30_ms)) { // Already have enough data, so we do not need to extract any more. // Or, avoid decoding more data as it might overflow the playout buffer. // Still try preemptive expand, though. @@ -1339,7 +1334,8 @@ int NetEqImpl::GetDecision(Operations* operation, return 0; } -int NetEqImpl::Decode(PacketList* packet_list, Operations* operation, +int NetEqImpl::Decode(PacketList* packet_list, + Operations* operation, int* decoded_length, AudioDecoder::SpeechType* speech_type) { *speech_type = AudioDecoder::kSpeech; @@ -1364,8 +1360,8 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation, decoder_database_->SetActiveDecoder(payload_type, &decoder_changed); if (decoder_changed) { // We have a new decoder. Re-init some values. - const DecoderDatabase::DecoderInfo* decoder_info = decoder_database_ - ->GetDecoderInfo(payload_type); + const DecoderDatabase::DecoderInfo* decoder_info = + decoder_database_->GetDecoderInfo(payload_type); assert(decoder_info); if (!decoder_info) { RTC_LOG(LS_WARNING) @@ -1411,8 +1407,8 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation, RTC_DCHECK(packet_list->empty()); return_value = DecodeCng(decoder, decoded_length, speech_type); } else { - return_value = DecodeLoop(packet_list, *operation, decoder, - decoded_length, speech_type); + return_value = DecodeLoop(packet_list, *operation, decoder, decoded_length, + speech_type); } if (*decoded_length < 0) { @@ -1446,7 +1442,8 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation, return return_value; } -int NetEqImpl::DecodeCng(AudioDecoder* decoder, int* decoded_length, +int NetEqImpl::DecodeCng(AudioDecoder* decoder, + int* decoded_length, AudioDecoder::SpeechType* speech_type) { if (!decoder) { // This happens when active decoder is not defined. @@ -1456,9 +1453,9 @@ int NetEqImpl::DecodeCng(AudioDecoder* decoder, int* decoded_length, while (*decoded_length < rtc::dchecked_cast(output_size_samples_)) { const int length = decoder->Decode( - nullptr, 0, fs_hz_, - (decoded_buffer_length_ - *decoded_length) * sizeof(int16_t), - &decoded_buffer_[*decoded_length], speech_type); + nullptr, 0, fs_hz_, + (decoded_buffer_length_ - *decoded_length) * sizeof(int16_t), + &decoded_buffer_[*decoded_length], speech_type); if (length > 0) { *decoded_length += length; } else { @@ -1476,15 +1473,16 @@ int NetEqImpl::DecodeCng(AudioDecoder* decoder, int* decoded_length, return 0; } -int NetEqImpl::DecodeLoop(PacketList* packet_list, const Operations& operation, - AudioDecoder* decoder, int* decoded_length, +int NetEqImpl::DecodeLoop(PacketList* packet_list, + const Operations& operation, + AudioDecoder* decoder, + int* decoded_length, AudioDecoder::SpeechType* speech_type) { RTC_DCHECK(last_decoded_timestamps_.empty()); // Do decoding. - while ( - !packet_list->empty() && - !decoder_database_->IsComfortNoise(packet_list->front().payload_type)) { + while (!packet_list->empty() && !decoder_database_->IsComfortNoise( + packet_list->front().payload_type)) { assert(decoder); // At this point, we must have a decoder object. // The number of channels in the |sync_buffer_| should be the same as the // number decoder channels. @@ -1526,15 +1524,16 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list, const Operations& operation, // If the list is not empty at this point, either a decoding error terminated // the while-loop, or list must hold exactly one CNG packet. - assert( - packet_list->empty() || *decoded_length < 0 || - (packet_list->size() == 1 && - decoder_database_->IsComfortNoise(packet_list->front().payload_type))); + assert(packet_list->empty() || *decoded_length < 0 || + (packet_list->size() == 1 && decoder_database_->IsComfortNoise( + packet_list->front().payload_type))); return 0; } -void NetEqImpl::DoNormal(const int16_t* decoded_buffer, size_t decoded_length, - AudioDecoder::SpeechType speech_type, bool play_dtmf) { +void NetEqImpl::DoNormal(const int16_t* decoded_buffer, + size_t decoded_length, + AudioDecoder::SpeechType speech_type, + bool play_dtmf) { assert(normal_.get()); normal_->Process(decoded_buffer, decoded_length, last_mode_, algorithm_buffer_.get()); @@ -1543,9 +1542,8 @@ void NetEqImpl::DoNormal(const int16_t* decoded_buffer, size_t decoded_length, } // If last packet was decoded as an inband CNG, set mode to CNG instead. - if ((speech_type == AudioDecoder::kComfortNoise) - || ((last_mode_ == kModeCodecInternalCng) - && (decoded_length == 0))) { + if ((speech_type == AudioDecoder::kComfortNoise) || + ((last_mode_ == kModeCodecInternalCng) && (decoded_length == 0))) { // TODO(hlundin): Remove second part of || statement above. last_mode_ = kModeCodecInternalCng; } @@ -1555,11 +1553,13 @@ void NetEqImpl::DoNormal(const int16_t* decoded_buffer, size_t decoded_length, } } -void NetEqImpl::DoMerge(int16_t* decoded_buffer, size_t decoded_length, - AudioDecoder::SpeechType speech_type, bool play_dtmf) { +void NetEqImpl::DoMerge(int16_t* decoded_buffer, + size_t decoded_length, + AudioDecoder::SpeechType speech_type, + bool play_dtmf) { assert(merge_.get()); - size_t new_length = merge_->Process(decoded_buffer, decoded_length, - algorithm_buffer_.get()); + size_t new_length = + merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get()); // Correction can be negative. int expand_length_correction = rtc::dchecked_cast(new_length) - @@ -1587,7 +1587,7 @@ void NetEqImpl::DoMerge(int16_t* decoded_buffer, size_t decoded_length, int NetEqImpl::DoExpand(bool play_dtmf) { while ((sync_buffer_->FutureLength() - expand_->overlap_length()) < - output_size_samples_) { + output_size_samples_) { algorithm_buffer_->Clear(); int return_value = expand_->Process(algorithm_buffer_.get()); size_t length = algorithm_buffer_->Size(); @@ -1635,11 +1635,10 @@ int NetEqImpl::DoAccelerate(int16_t* decoded_buffer, size_t decoded_length_per_channel = decoded_length / num_channels; if (decoded_length_per_channel < required_samples) { // Must move data from the |sync_buffer_| in order to get 30 ms. - borrowed_samples_per_channel = static_cast(required_samples - - decoded_length_per_channel); + borrowed_samples_per_channel = + static_cast(required_samples - decoded_length_per_channel); memmove(&decoded_buffer[borrowed_samples_per_channel * num_channels], - decoded_buffer, - sizeof(int16_t) * decoded_length); + decoded_buffer, sizeof(int16_t) * decoded_length); sync_buffer_->ReadInterleavedFromEnd(borrowed_samples_per_channel, decoded_buffer); decoded_length = required_samples * num_channels; @@ -1672,17 +1671,16 @@ int NetEqImpl::DoAccelerate(int16_t* decoded_buffer, if (length < borrowed_samples_per_channel) { // This destroys the beginning of the buffer, but will not cause any // problems. - sync_buffer_->ReplaceAtIndex(*algorithm_buffer_, - sync_buffer_->Size() - - borrowed_samples_per_channel); + sync_buffer_->ReplaceAtIndex( + *algorithm_buffer_, + sync_buffer_->Size() - borrowed_samples_per_channel); sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length); algorithm_buffer_->PopFront(length); assert(algorithm_buffer_->Empty()); } else { - sync_buffer_->ReplaceAtIndex(*algorithm_buffer_, - borrowed_samples_per_channel, - sync_buffer_->Size() - - borrowed_samples_per_channel); + sync_buffer_->ReplaceAtIndex( + *algorithm_buffer_, borrowed_samples_per_channel, + sync_buffer_->Size() - borrowed_samples_per_channel); algorithm_buffer_->PopFront(borrowed_samples_per_channel); } } @@ -1714,11 +1712,11 @@ int NetEqImpl::DoPreemptiveExpand(int16_t* decoded_buffer, required_samples - decoded_length_per_channel; // Calculate how many of these were already played out. old_borrowed_samples_per_channel = - (borrowed_samples_per_channel > sync_buffer_->FutureLength()) ? - (borrowed_samples_per_channel - sync_buffer_->FutureLength()) : 0; + (borrowed_samples_per_channel > sync_buffer_->FutureLength()) + ? (borrowed_samples_per_channel - sync_buffer_->FutureLength()) + : 0; memmove(&decoded_buffer[borrowed_samples_per_channel * num_channels], - decoded_buffer, - sizeof(int16_t) * decoded_length); + decoded_buffer, sizeof(int16_t) * decoded_length); sync_buffer_->ReadInterleavedFromEnd(borrowed_samples_per_channel, decoded_buffer); decoded_length = required_samples * num_channels; @@ -1726,8 +1724,7 @@ int NetEqImpl::DoPreemptiveExpand(int16_t* decoded_buffer, size_t samples_added; PreemptiveExpand::ReturnCodes return_code = preemptive_expand_->Process( - decoded_buffer, decoded_length, - old_borrowed_samples_per_channel, + decoded_buffer, decoded_length, old_borrowed_samples_per_channel, algorithm_buffer_.get(), &samples_added); stats_.PreemptiveExpandedSamples(samples_added); switch (return_code) { @@ -1780,8 +1777,8 @@ int NetEqImpl::DoRfc3389Cng(PacketList* packet_list, bool play_dtmf) { return -comfort_noise_->internal_error_code(); } } - int cn_return = comfort_noise_->Generate(output_size_samples_, - algorithm_buffer_.get()); + int cn_return = + comfort_noise_->Generate(output_size_samples_, algorithm_buffer_.get()); expand_->Reset(); last_mode_ = kModeRfc3389Cng; if (!play_dtmf) { @@ -1909,16 +1906,17 @@ void NetEqImpl::DoAlternativePlc(bool increase_timestamp) { expand_->Reset(); } -int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event, size_t num_channels, +int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event, + size_t num_channels, int16_t* output) const { size_t out_index = 0; size_t overdub_length = output_size_samples_; // Default value. if (sync_buffer_->dtmf_index() > sync_buffer_->next_index()) { // Special operation for transition from "DTMF only" to "DTMF overdub". - out_index = std::min( - sync_buffer_->dtmf_index() - sync_buffer_->next_index(), - output_size_samples_); + out_index = + std::min(sync_buffer_->dtmf_index() - sync_buffer_->next_index(), + output_size_samples_); overdub_length = output_size_samples_ - out_index; } @@ -1929,8 +1927,8 @@ int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event, size_t num_channels, dtmf_event.volume); } if (dtmf_return_value == 0) { - dtmf_return_value = dtmf_tone_generator_->Generate(overdub_length, - &dtmf_output); + dtmf_return_value = + dtmf_tone_generator_->Generate(overdub_length, &dtmf_output); assert(overdub_length == dtmf_output.Size()); } dtmf_output.ReadInterleaved(overdub_length, &output[out_index]); @@ -2051,7 +2049,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) { RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " " << channels; // TODO(hlundin): Change to an enumerator and skip assert. - assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000); + assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000); assert(channels > 0); fs_hz_ = fs_hz; @@ -2085,7 +2083,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) { // Move index so that we create a small set of future samples (all 0). sync_buffer_->set_next_index(sync_buffer_->next_index() - - expand_->overlap_length()); + expand_->overlap_length()); normal_.reset(new Normal(fs_hz, decoder_database_.get(), *background_noise_, expand_.get())); @@ -2095,8 +2093,8 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) { fs_hz, channels, *background_noise_, expand_->overlap_length())); // Delete ComfortNoise object and create a new one. - comfort_noise_.reset(new ComfortNoise(fs_hz, decoder_database_.get(), - sync_buffer_.get())); + comfort_noise_.reset( + new ComfortNoise(fs_hz, decoder_database_.get(), sync_buffer_.get())); // Verify that |decoded_buffer_| is long enough. if (decoded_buffer_length_ < kMaxFrameSize * channels) { diff --git a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc index 585fd8f48b..57fc682f73 100644 --- a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc +++ b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc @@ -86,8 +86,8 @@ class MockAudioDecoder final : public AudioDecoder { return kPacketDuration; } - bool PacketHasFec( - const uint8_t* encoded, size_t encoded_len) const /* override */ { + bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const + /* override */ { ADD_FAILURE() << "Since going through ParsePayload, PacketHasFec should " "never get called."; return fec_enabled_; @@ -123,40 +123,40 @@ class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { static const int kPayloadSizeByte = 30; static const int kFrameSizeMs = 20; -enum logic { - kIgnore, - kEqual, - kSmallerThan, - kLargerThan, -}; + enum logic { + kIgnore, + kEqual, + kSmallerThan, + kLargerThan, + }; -struct NetEqNetworkStatsCheck { - logic current_buffer_size_ms; - logic preferred_buffer_size_ms; - logic jitter_peaks_found; - logic packet_loss_rate; - logic expand_rate; - logic speech_expand_rate; - logic preemptive_rate; - logic accelerate_rate; - logic secondary_decoded_rate; - logic secondary_discarded_rate; - logic clockdrift_ppm; - logic added_zero_samples; - NetEqNetworkStatistics stats_ref; -}; + struct NetEqNetworkStatsCheck { + logic current_buffer_size_ms; + logic preferred_buffer_size_ms; + logic jitter_peaks_found; + logic packet_loss_rate; + logic expand_rate; + logic speech_expand_rate; + logic preemptive_rate; + logic accelerate_rate; + logic secondary_decoded_rate; + logic secondary_discarded_rate; + logic clockdrift_ppm; + logic added_zero_samples; + NetEqNetworkStatistics stats_ref; + }; -NetEqNetworkStatsTest(NetEqDecoder codec, - int sample_rate_hz, - MockAudioDecoder* decoder) - : NetEqExternalDecoderTest(codec, sample_rate_hz, decoder), - external_decoder_(decoder), - samples_per_ms_(sample_rate_hz / 1000), - frame_size_samples_(kFrameSizeMs * samples_per_ms_), - rtp_generator_(new test::RtpGenerator(samples_per_ms_)), - last_lost_time_(0), - packet_loss_interval_(0xffffffff) { - Init(); + NetEqNetworkStatsTest(NetEqDecoder codec, + int sample_rate_hz, + MockAudioDecoder* decoder) + : NetEqExternalDecoderTest(codec, sample_rate_hz, decoder), + external_decoder_(decoder), + samples_per_ms_(sample_rate_hz / 1000), + frame_size_samples_(kFrameSizeMs * samples_per_ms_), + rtp_generator_(new test::RtpGenerator(samples_per_ms_)), + last_lost_time_(0), + packet_loss_interval_(0xffffffff) { + Init(); } bool Lost(uint32_t send_time) { @@ -168,8 +168,9 @@ NetEqNetworkStatsTest(NetEqDecoder codec, } void SetPacketLossRate(double loss_rate) { - packet_loss_interval_ = (loss_rate >= 1e-3 ? - static_cast(kFrameSizeMs) / loss_rate : 0xffffffff); + packet_loss_interval_ = + (loss_rate >= 1e-3 ? static_cast(kFrameSizeMs) / loss_rate + : 0xffffffff); } // |stats_ref| @@ -181,19 +182,19 @@ NetEqNetworkStatsTest(NetEqDecoder codec, NetEqNetworkStatistics stats; neteq()->NetworkStatistics(&stats); -#define CHECK_NETEQ_NETWORK_STATS(x)\ - switch (expects.x) {\ - case kEqual:\ - EXPECT_EQ(stats.x, expects.stats_ref.x);\ - break;\ - case kSmallerThan:\ - EXPECT_LT(stats.x, expects.stats_ref.x);\ - break;\ - case kLargerThan:\ - EXPECT_GT(stats.x, expects.stats_ref.x);\ - break;\ - default:\ - break;\ +#define CHECK_NETEQ_NETWORK_STATS(x) \ + switch (expects.x) { \ + case kEqual: \ + EXPECT_EQ(stats.x, expects.stats_ref.x); \ + break; \ + case kSmallerThan: \ + EXPECT_LT(stats.x, expects.stats_ref.x); \ + break; \ + case kLargerThan: \ + EXPECT_GT(stats.x, expects.stats_ref.x); \ + break; \ + default: \ + break; \ } CHECK_NETEQ_NETWORK_STATS(current_buffer_size_ms); @@ -220,15 +221,13 @@ NetEqNetworkStatsTest(NetEqDecoder codec, uint32_t next_send_time; // Initiate |last_lost_time_|. - time_now = next_send_time = last_lost_time_ = - rtp_generator_->GetRtpHeader(kPayloadType, frame_size_samples_, - &rtp_header_); + time_now = next_send_time = last_lost_time_ = rtp_generator_->GetRtpHeader( + kPayloadType, frame_size_samples_, &rtp_header_); for (int k = 0; k < num_loops; ++k) { // Delay by one frame such that the FEC can come in. while (time_now + kFrameSizeMs >= next_send_time) { - next_send_time = rtp_generator_->GetRtpHeader(kPayloadType, - frame_size_samples_, - &rtp_header_); + next_send_time = rtp_generator_->GetRtpHeader( + kPayloadType, frame_size_samples_, &rtp_header_); if (!Lost(next_send_time)) { static const uint8_t payload[kPayloadSizeByte] = {0}; InsertPacket(rtp_header_, payload, next_send_time); @@ -243,21 +242,19 @@ NetEqNetworkStatsTest(NetEqDecoder codec, void DecodeFecTest() { external_decoder_->set_fec_enabled(false); - NetEqNetworkStatsCheck expects = { - kIgnore, // current_buffer_size_ms - kIgnore, // preferred_buffer_size_ms - kIgnore, // jitter_peaks_found - kEqual, // packet_loss_rate - kEqual, // expand_rate - kEqual, // voice_expand_rate - kIgnore, // preemptive_rate - kEqual, // accelerate_rate - kEqual, // decoded_fec_rate - kEqual, // discarded_fec_rate - kIgnore, // clockdrift_ppm - kEqual, // added_zero_samples - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - }; + NetEqNetworkStatsCheck expects = {kIgnore, // current_buffer_size_ms + kIgnore, // preferred_buffer_size_ms + kIgnore, // jitter_peaks_found + kEqual, // packet_loss_rate + kEqual, // expand_rate + kEqual, // voice_expand_rate + kIgnore, // preemptive_rate + kEqual, // accelerate_rate + kEqual, // decoded_fec_rate + kEqual, // discarded_fec_rate + kIgnore, // clockdrift_ppm + kEqual, // added_zero_samples + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; RunTest(50, expects); // Next we introduce packet losses. @@ -277,21 +274,19 @@ NetEqNetworkStatsTest(NetEqDecoder codec, } void NoiseExpansionTest() { - NetEqNetworkStatsCheck expects = { - kIgnore, // current_buffer_size_ms - kIgnore, // preferred_buffer_size_ms - kIgnore, // jitter_peaks_found - kEqual, // packet_loss_rate - kEqual, // expand_rate - kEqual, // speech_expand_rate - kIgnore, // preemptive_rate - kEqual, // accelerate_rate - kEqual, // decoded_fec_rate - kEqual, // discard_fec_rate - kIgnore, // clockdrift_ppm - kEqual, // added_zero_samples - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - }; + NetEqNetworkStatsCheck expects = {kIgnore, // current_buffer_size_ms + kIgnore, // preferred_buffer_size_ms + kIgnore, // jitter_peaks_found + kEqual, // packet_loss_rate + kEqual, // expand_rate + kEqual, // speech_expand_rate + kIgnore, // preemptive_rate + kEqual, // accelerate_rate + kEqual, // decoded_fec_rate + kEqual, // discard_fec_rate + kIgnore, // clockdrift_ppm + kEqual, // added_zero_samples + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; RunTest(50, expects); SetPacketLossRate(1); diff --git a/modules/audio_coding/neteq/neteq_stereo_unittest.cc b/modules/audio_coding/neteq/neteq_stereo_unittest.cc index 49facdd1ec..ef4c235e6e 100644 --- a/modules/audio_coding/neteq/neteq_stereo_unittest.cc +++ b/modules/audio_coding/neteq/neteq_stereo_unittest.cc @@ -11,9 +11,9 @@ // Test to verify correct stereo and multi-channel operation. #include +#include #include #include -#include #include "api/audio/audio_frame.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" @@ -72,17 +72,17 @@ class NetEqStereoTest : public ::testing::TestWithParam { input_ = new int16_t[frame_size_samples_]; encoded_ = new uint8_t[2 * frame_size_samples_]; input_multi_channel_ = new int16_t[frame_size_samples_ * num_channels_]; - encoded_multi_channel_ = new uint8_t[frame_size_samples_ * 2 * - num_channels_]; + encoded_multi_channel_ = + new uint8_t[frame_size_samples_ * 2 * num_channels_]; } ~NetEqStereoTest() { delete neteq_mono_; delete neteq_; - delete [] input_; - delete [] encoded_; - delete [] input_multi_channel_; - delete [] encoded_multi_channel_; + delete[] input_; + delete[] encoded_; + delete[] input_multi_channel_; + delete[] encoded_multi_channel_; } virtual void SetUp() { @@ -142,17 +142,15 @@ class NetEqStereoTest : public ::testing::TestWithParam { if (!input_file_->Read(frame_size_samples_, input_)) { return -1; } - payload_size_bytes_ = WebRtcPcm16b_Encode(input_, frame_size_samples_, - encoded_); + payload_size_bytes_ = + WebRtcPcm16b_Encode(input_, frame_size_samples_, encoded_); if (frame_size_samples_ * 2 != payload_size_bytes_) { return -1; } - int next_send_time = rtp_generator_mono_.GetRtpHeader(kPayloadTypeMono, - frame_size_samples_, - &rtp_header_mono_); - test::InputAudioFile::DuplicateInterleaved(input_, frame_size_samples_, - num_channels_, - input_multi_channel_); + int next_send_time = rtp_generator_mono_.GetRtpHeader( + kPayloadTypeMono, frame_size_samples_, &rtp_header_mono_); + test::InputAudioFile::DuplicateInterleaved( + input_, frame_size_samples_, num_channels_, input_multi_channel_); multi_payload_size_bytes_ = WebRtcPcm16b_Encode( input_multi_channel_, frame_size_samples_ * num_channels_, encoded_multi_channel_); @@ -267,8 +265,7 @@ class NetEqStereoTest : public ::testing::TestWithParam { class NetEqStereoTestNoJitter : public NetEqStereoTest { protected: - NetEqStereoTestNoJitter() - : NetEqStereoTest() { + NetEqStereoTestNoJitter() : NetEqStereoTest() { // Start the sender 100 ms before the receiver to pre-fill the buffer. // This is to avoid doing preemptive expand early in the test. // TODO(hlundin): Mock the decision making instead to control the modes. @@ -282,17 +279,15 @@ TEST_P(NetEqStereoTestNoJitter, RunTest) { class NetEqStereoTestPositiveDrift : public NetEqStereoTest { protected: - NetEqStereoTestPositiveDrift() - : NetEqStereoTest(), - drift_factor(0.9) { + NetEqStereoTestPositiveDrift() : NetEqStereoTest(), drift_factor(0.9) { // Start the sender 100 ms before the receiver to pre-fill the buffer. // This is to avoid doing preemptive expand early in the test. // TODO(hlundin): Mock the decision making instead to control the modes. last_arrival_time_ = -100; } virtual int GetArrivalTime(int send_time) { - int arrival_time = last_arrival_time_ + - drift_factor * (send_time - last_send_time_); + int arrival_time = + last_arrival_time_ + drift_factor * (send_time - last_send_time_); last_send_time_ = send_time; last_arrival_time_ = arrival_time; return arrival_time; @@ -307,8 +302,7 @@ TEST_P(NetEqStereoTestPositiveDrift, RunTest) { class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { protected: - NetEqStereoTestNegativeDrift() - : NetEqStereoTestPositiveDrift() { + NetEqStereoTestNegativeDrift() : NetEqStereoTestPositiveDrift() { drift_factor = 1.1; last_arrival_time_ = 0; } @@ -322,10 +316,7 @@ class NetEqStereoTestDelays : public NetEqStereoTest { protected: static const int kDelayInterval = 10; static const int kDelay = 1000; - NetEqStereoTestDelays() - : NetEqStereoTest(), - frame_index_(0) { - } + NetEqStereoTestDelays() : NetEqStereoTest(), frame_index_(0) {} virtual int GetArrivalTime(int send_time) { // Deliver immediately, unless we have a back-log. @@ -349,22 +340,16 @@ TEST_P(NetEqStereoTestDelays, RunTest) { class NetEqStereoTestLosses : public NetEqStereoTest { protected: static const int kLossInterval = 10; - NetEqStereoTestLosses() - : NetEqStereoTest(), - frame_index_(0) { - } + NetEqStereoTestLosses() : NetEqStereoTest(), frame_index_(0) {} - virtual bool Lost() { - return (++frame_index_) % kLossInterval == 0; - } + virtual bool Lost() { return (++frame_index_) % kLossInterval == 0; } // TODO(hlundin): NetEq is not giving bitexact results for these cases. virtual void VerifyOutput(size_t num_samples) { for (size_t i = 0; i < num_samples; ++i) { const int16_t* output_data = output_.data(); const int16_t* output_multi_channel_data = output_multi_channel_.data(); - auto first_channel_sample = - output_multi_channel_data[i * num_channels_]; + auto first_channel_sample = output_multi_channel_data[i * num_channels_]; for (size_t j = 0; j < num_channels_; ++j) { const int kErrorMargin = 200; EXPECT_NEAR(output_data[i], @@ -384,7 +369,6 @@ TEST_P(NetEqStereoTestLosses, RunTest) { RunTest(100); } - // Creates a list of parameter sets. std::list GetTestParameters() { std::list l; @@ -412,9 +396,9 @@ std::list GetTestParameters() { // Pretty-printing the test parameters in case of an error. void PrintTo(const TestParameters& p, ::std::ostream* os) { - *os << "{frame_size = " << p.frame_size << - ", num_channels = " << p.num_channels << - ", sample_rate = " << p.sample_rate << "}"; + *os << "{frame_size = " << p.frame_size + << ", num_channels = " << p.num_channels + << ", sample_rate = " << p.sample_rate << "}"; } // Instantiate the tests. Each test is instantiated using the function above, diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc index 6239985bae..4ed7a6b088 100644 --- a/modules/audio_coding/neteq/neteq_unittest.cc +++ b/modules/audio_coding/neteq/neteq_unittest.cc @@ -61,17 +61,17 @@ const std::string& PlatformChecksum(const std::string& checksum_general, const std::string& checksum_win_32, const std::string& checksum_win_64) { #if defined(WEBRTC_ANDROID) - #ifdef WEBRTC_ARCH_64_BITS - return checksum_android_64; - #else - return checksum_android_32; - #endif // WEBRTC_ARCH_64_BITS +#ifdef WEBRTC_ARCH_64_BITS + return checksum_android_64; +#else + return checksum_android_32; +#endif // WEBRTC_ARCH_64_BITS #elif defined(WEBRTC_WIN) - #ifdef WEBRTC_ARCH_64_BITS - return checksum_win_64; - #else - return checksum_win_32; - #endif // WEBRTC_ARCH_64_BITS +#ifdef WEBRTC_ARCH_64_BITS + return checksum_win_64; +#else + return checksum_win_32; +#endif // WEBRTC_ARCH_64_BITS #else return checksum_general; #endif // WEBRTC_WIN @@ -107,7 +107,8 @@ void Convert(const webrtc::RtcpStatistics& stats_raw, stats->set_jitter(stats_raw.jitter); } -void AddMessage(FILE* file, rtc::MessageDigest* digest, +void AddMessage(FILE* file, + rtc::MessageDigest* digest, const std::string& message) { int32_t size = message.length(); if (file) @@ -164,7 +165,8 @@ class ResultSink { explicit ResultSink(const std::string& output_file); ~ResultSink(); - template void AddResult(const T* test_results, size_t length); + template + void AddResult(const T* test_results, size_t length); void AddResult(const NetEqNetworkStatistics& stats); void AddResult(const RtcpStatistics& stats); @@ -190,7 +192,7 @@ ResultSink::~ResultSink() { fclose(output_fp_); } -template +template void ResultSink::AddResult(const T* test_results, size_t length) { if (output_fp_) { ASSERT_EQ(length, fwrite(test_results, sizeof(T), length, output_fp_)); @@ -247,7 +249,7 @@ class NetEqDecodingTest : public ::testing::Test { virtual void SetUp(); virtual void TearDown(); void SelectDecoders(NetEqDecoder* used_codec); - void OpenInputFile(const std::string &rtp_file); + void OpenInputFile(const std::string& rtp_file); void Process(); void DecodeAndCompare(const std::string& rtp_file, @@ -265,9 +267,11 @@ class NetEqDecodingTest : public ::testing::Test { uint8_t* payload, size_t* payload_len); - void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp, + void WrapTest(uint16_t start_seq_no, + uint32_t start_timestamp, const std::set& drop_seq_numbers, - bool expect_seq_no_wrap, bool expect_timestamp_wrap); + bool expect_seq_no_wrap, + bool expect_timestamp_wrap); void LongCngWithClockDrift(double drift_factor, double network_freeze_ms, @@ -316,7 +320,7 @@ void NetEqDecodingTest::TearDown() { delete neteq_; } -void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) { +void NetEqDecodingTest::OpenInputFile(const std::string& rtp_file) { rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); } @@ -384,8 +388,8 @@ void NetEqDecodingTest::DecodeAndCompare( ss << "Lap number " << i++ << " in DecodeAndCompare while loop"; SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. ASSERT_NO_FATAL_FAILURE(Process()); - ASSERT_NO_FATAL_FAILURE(output.AddResult( - out_frame_.data(), out_frame_.samples_per_channel_)); + ASSERT_NO_FATAL_FAILURE( + output.AddResult(out_frame_.data(), out_frame_.samples_per_channel_)); // Query the network statistics API once per second if (sim_clock_ % 1000 == 0) { @@ -447,7 +451,7 @@ void NetEqDecodingTest::PopulateCng(int frame_index, rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. rtp_info->payloadType = 98; // WB CNG. rtp_info->markerBit = 0; - payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. + payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. *payload_len = 1; // Only noise level, no spectral parameters. } @@ -462,36 +466,29 @@ TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { const std::string input_rtp_file = webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); - const std::string output_checksum = PlatformChecksum( - "0c6dc227f781c81a229970f8fceda1a012498cba", - "15c4a2202877a414515e218bdb7992f0ad53e5af", - "not used", - "0c6dc227f781c81a229970f8fceda1a012498cba", - "25fc4c863caa499aa447a5b8d059f5452cbcc500"); + const std::string output_checksum = + PlatformChecksum("0c6dc227f781c81a229970f8fceda1a012498cba", + "15c4a2202877a414515e218bdb7992f0ad53e5af", "not used", + "0c6dc227f781c81a229970f8fceda1a012498cba", + "25fc4c863caa499aa447a5b8d059f5452cbcc500"); const std::string network_stats_checksum = PlatformChecksum("4b2370f5c794741d2a46be5c7935c66ef3fb53e9", - "e339cb2adf5ab3dfc21cb7205d670a34751e8336", - "not used", + "e339cb2adf5ab3dfc21cb7205d670a34751e8336", "not used", "4b2370f5c794741d2a46be5c7935c66ef3fb53e9", "4b2370f5c794741d2a46be5c7935c66ef3fb53e9"); - const std::string rtcp_stats_checksum = PlatformChecksum( - "b8880bf9fed2487efbddcb8d94b9937a29ae521d", - "f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4", - "not used", - "b8880bf9fed2487efbddcb8d94b9937a29ae521d", - "b8880bf9fed2487efbddcb8d94b9937a29ae521d"); + const std::string rtcp_stats_checksum = + PlatformChecksum("b8880bf9fed2487efbddcb8d94b9937a29ae521d", + "f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4", "not used", + "b8880bf9fed2487efbddcb8d94b9937a29ae521d", + "b8880bf9fed2487efbddcb8d94b9937a29ae521d"); - DecodeAndCompare(input_rtp_file, - output_checksum, - network_stats_checksum, - rtcp_stats_checksum, - FLAG_gen_ref); + DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, + rtcp_stats_checksum, FLAG_gen_ref); } -#if !defined(WEBRTC_IOS) && \ - defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ +#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ defined(WEBRTC_CODEC_OPUS) #define MAYBE_TestOpusBitExactness TestOpusBitExactness #else @@ -501,12 +498,12 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { const std::string input_rtp_file = webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp"); - const std::string output_checksum = PlatformChecksum( - "14a63b3c7b925c82296be4bafc71bec85f2915c2", - "b7b7ed802b0e18ee416973bf3b9ae98599b0181d", - "5876e52dda90d5ca433c3726555b907b97c86374", - "14a63b3c7b925c82296be4bafc71bec85f2915c2", - "14a63b3c7b925c82296be4bafc71bec85f2915c2"); + const std::string output_checksum = + PlatformChecksum("14a63b3c7b925c82296be4bafc71bec85f2915c2", + "b7b7ed802b0e18ee416973bf3b9ae98599b0181d", + "5876e52dda90d5ca433c3726555b907b97c86374", + "14a63b3c7b925c82296be4bafc71bec85f2915c2", + "14a63b3c7b925c82296be4bafc71bec85f2915c2"); const std::string network_stats_checksum = PlatformChecksum("adb3272498e436d1c019cbfd71610e9510c54497", @@ -515,22 +512,18 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { "adb3272498e436d1c019cbfd71610e9510c54497", "adb3272498e436d1c019cbfd71610e9510c54497"); - const std::string rtcp_stats_checksum = PlatformChecksum( - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0"); + const std::string rtcp_stats_checksum = + PlatformChecksum("e37c797e3de6a64dda88c9ade7a013d022a2e1e0", + "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", + "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", + "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", + "e37c797e3de6a64dda88c9ade7a013d022a2e1e0"); - DecodeAndCompare(input_rtp_file, - output_checksum, - network_stats_checksum, - rtcp_stats_checksum, - FLAG_gen_ref); + DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, + rtcp_stats_checksum, FLAG_gen_ref); } -#if !defined(WEBRTC_IOS) && \ - defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ +#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ defined(WEBRTC_CODEC_OPUS) #define MAYBE_TestOpusDtxBitExactness TestOpusDtxBitExactness #else @@ -805,10 +798,8 @@ TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDrift) { const bool kGetAudioDuringFreezeRecovery = false; const int kDelayToleranceMs = 20; const int kMaxTimeToSpeechMs = 100; - LongCngWithClockDrift(kDriftFactor, - kNetworkFreezeTimeMs, - kGetAudioDuringFreezeRecovery, - kDelayToleranceMs, + LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, + kGetAudioDuringFreezeRecovery, kDelayToleranceMs, kMaxTimeToSpeechMs); } @@ -819,10 +810,8 @@ TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDrift) { const bool kGetAudioDuringFreezeRecovery = false; const int kDelayToleranceMs = 20; const int kMaxTimeToSpeechMs = 100; - LongCngWithClockDrift(kDriftFactor, - kNetworkFreezeTimeMs, - kGetAudioDuringFreezeRecovery, - kDelayToleranceMs, + LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, + kGetAudioDuringFreezeRecovery, kDelayToleranceMs, kMaxTimeToSpeechMs); } @@ -833,10 +822,8 @@ TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDriftNetworkFreeze) { const bool kGetAudioDuringFreezeRecovery = false; const int kDelayToleranceMs = 50; const int kMaxTimeToSpeechMs = 200; - LongCngWithClockDrift(kDriftFactor, - kNetworkFreezeTimeMs, - kGetAudioDuringFreezeRecovery, - kDelayToleranceMs, + LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, + kGetAudioDuringFreezeRecovery, kDelayToleranceMs, kMaxTimeToSpeechMs); } @@ -847,10 +834,8 @@ TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreeze) { const bool kGetAudioDuringFreezeRecovery = false; const int kDelayToleranceMs = 20; const int kMaxTimeToSpeechMs = 100; - LongCngWithClockDrift(kDriftFactor, - kNetworkFreezeTimeMs, - kGetAudioDuringFreezeRecovery, - kDelayToleranceMs, + LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, + kGetAudioDuringFreezeRecovery, kDelayToleranceMs, kMaxTimeToSpeechMs); } @@ -861,10 +846,8 @@ TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreezeExtraPull) { const bool kGetAudioDuringFreezeRecovery = true; const int kDelayToleranceMs = 20; const int kMaxTimeToSpeechMs = 100; - LongCngWithClockDrift(kDriftFactor, - kNetworkFreezeTimeMs, - kGetAudioDuringFreezeRecovery, - kDelayToleranceMs, + LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, + kGetAudioDuringFreezeRecovery, kDelayToleranceMs, kMaxTimeToSpeechMs); } @@ -874,10 +857,8 @@ TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { const bool kGetAudioDuringFreezeRecovery = false; const int kDelayToleranceMs = 10; const int kMaxTimeToSpeechMs = 50; - LongCngWithClockDrift(kDriftFactor, - kNetworkFreezeTimeMs, - kGetAudioDuringFreezeRecovery, - kDelayToleranceMs, + LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, + kGetAudioDuringFreezeRecovery, kDelayToleranceMs, kMaxTimeToSpeechMs); } @@ -1002,11 +983,11 @@ class NetEqBgnTest : public NetEqDecodingTest { ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); // Next packet. - rtp_info.timestamp += rtc::checked_cast( - expected_samples_per_channel); + rtp_info.timestamp += + rtc::checked_cast(expected_samples_per_channel); rtp_info.sequenceNumber++; - receive_timestamp += rtc::checked_cast( - expected_samples_per_channel); + receive_timestamp += + rtc::checked_cast(expected_samples_per_channel); } output.Reset(); @@ -1099,8 +1080,8 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, if (packets_inserted > 4) { // Expect preferred and actual buffer size to be no more than 2 frames. EXPECT_LE(network_stats.preferred_buffer_size_ms, kFrameSizeMs * 2); - EXPECT_LE(network_stats.current_buffer_size_ms, kFrameSizeMs * 2 + - algorithmic_delay_ms_); + EXPECT_LE(network_stats.current_buffer_size_ms, + kFrameSizeMs * 2 + algorithmic_delay_ms_); } last_seq_no = seq_no; last_timestamp = timestamp; @@ -1166,8 +1147,8 @@ void NetEqDecodingTest::DuplicateCng() { const int kSamples = kFrameSizeMs * kSampleRateKhz; const size_t kPayloadBytes = kSamples * 2; - const int algorithmic_delay_samples = std::max( - algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); + const int algorithmic_delay_samples = + std::max(algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); // Insert three speech packets. Three are needed to get the frame length // correct. uint8_t payload[kPayloadBytes] = {0}; @@ -1239,7 +1220,9 @@ void NetEqDecodingTest::DuplicateCng() { *playout_timestamp); } -TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { DuplicateCng(); } +TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { + DuplicateCng(); +} TEST_F(NetEqDecodingTest, CngFirst) { uint16_t seq_no = 0; @@ -1493,25 +1476,25 @@ namespace { return ::testing::AssertionFailure() << "timestamp_ diff (" << a.timestamp_ << " != " << b.timestamp_ << ")"; if (a.sample_rate_hz_ != b.sample_rate_hz_) - return ::testing::AssertionFailure() << "sample_rate_hz_ diff (" - << a.sample_rate_hz_ - << " != " << b.sample_rate_hz_ << ")"; + return ::testing::AssertionFailure() + << "sample_rate_hz_ diff (" << a.sample_rate_hz_ + << " != " << b.sample_rate_hz_ << ")"; if (a.samples_per_channel_ != b.samples_per_channel_) return ::testing::AssertionFailure() << "samples_per_channel_ diff (" << a.samples_per_channel_ << " != " << b.samples_per_channel_ << ")"; if (a.num_channels_ != b.num_channels_) - return ::testing::AssertionFailure() << "num_channels_ diff (" - << a.num_channels_ - << " != " << b.num_channels_ << ")"; + return ::testing::AssertionFailure() + << "num_channels_ diff (" << a.num_channels_ + << " != " << b.num_channels_ << ")"; if (a.speech_type_ != b.speech_type_) - return ::testing::AssertionFailure() << "speech_type_ diff (" - << a.speech_type_ - << " != " << b.speech_type_ << ")"; + return ::testing::AssertionFailure() + << "speech_type_ diff (" << a.speech_type_ + << " != " << b.speech_type_ << ")"; if (a.vad_activity_ != b.vad_activity_) - return ::testing::AssertionFailure() << "vad_activity_ diff (" - << a.vad_activity_ - << " != " << b.vad_activity_ << ")"; + return ::testing::AssertionFailure() + << "vad_activity_ diff (" << a.vad_activity_ + << " != " << b.vad_activity_ << ")"; return ::testing::AssertionSuccess(); } @@ -1520,9 +1503,9 @@ namespace { ::testing::AssertionResult res = AudioFramesEqualExceptData(a, b); if (!res) return res; - if (memcmp( - a.data(), b.data(), - a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) != 0) { + if (memcmp(a.data(), b.data(), + a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) != + 0) { return ::testing::AssertionFailure() << "data_ diff"; } return ::testing::AssertionSuccess(); diff --git a/modules/audio_coding/neteq/normal.cc b/modules/audio_coding/neteq/normal.cc index f10158c0e1..83f7616d8e 100644 --- a/modules/audio_coding/neteq/normal.cc +++ b/modules/audio_coding/neteq/normal.cc @@ -76,8 +76,7 @@ int Normal::Process(const int16_t* input, // Adjust muting factor if needed (to BGN level). size_t energy_length = std::min(static_cast(fs_mult * 64), length_per_channel); - int scaling = 6 + fs_shift - - WebRtcSpl_NormW32(decoded_max * decoded_max); + int scaling = 6 + fs_shift - WebRtcSpl_NormW32(decoded_max * decoded_max); scaling = std::max(scaling, 0); // |scaling| should always be >= 0. int32_t energy = WebRtcSpl_DotProductWithScale(signal.get(), signal.get(), energy_length, scaling); @@ -90,8 +89,7 @@ int Normal::Process(const int16_t* input, } int local_mute_factor = 16384; // 1.0 in Q14. - if ((energy != 0) && - (energy > background_noise_.Energy(channel_ix))) { + if ((energy != 0) && (energy > background_noise_.Energy(channel_ix))) { // Normalize new frame energy to 15 bits. scaling = WebRtcSpl_NormW32(energy) - 16; // We want background_noise_.energy() / energy in Q14. diff --git a/modules/audio_coding/neteq/normal.h b/modules/audio_coding/neteq/normal.h index 14323eab04..41bd30a85f 100644 --- a/modules/audio_coding/neteq/normal.h +++ b/modules/audio_coding/neteq/normal.h @@ -54,7 +54,8 @@ class Normal { // |output| defines the number of channels that will be used when // de-interleaving |input|. |last_mode| contains the mode used in the previous // GetAudio call (i.e., not the current one). - int Process(const int16_t* input, size_t length, + int Process(const int16_t* input, + size_t length, Modes last_mode, AudioMultiVector* output); diff --git a/modules/audio_coding/neteq/normal_unittest.cc b/modules/audio_coding/neteq/normal_unittest.cc index ab99d9a47a..106762afbb 100644 --- a/modules/audio_coding/neteq/normal_unittest.cc +++ b/modules/audio_coding/neteq/normal_unittest.cc @@ -39,7 +39,7 @@ int ExpandProcess120ms(AudioMultiVector* output) { return 0; } -} // namespace +} // namespace TEST(Normal, CreateAndDestroy) { MockDecoderDatabase db; @@ -84,10 +84,7 @@ TEST(Normal, AvoidDivideByZero) { // and using this as a denominator would lead to problems. int input_size_samples = 63; EXPECT_EQ(input_size_samples, - normal.Process(input, - input_size_samples, - kModeExpand, - &output)); + normal.Process(input, input_size_samples, kModeExpand, &output)); EXPECT_CALL(db, Die()); // Called when |db| goes out of scope. EXPECT_CALL(expand, Die()); // Called when |expand| goes out of scope. @@ -139,10 +136,7 @@ TEST(Normal, LastModeExpand120msPacket) { EXPECT_CALL(expand, Process(_)).WillOnce(Invoke(ExpandProcess120ms)); EXPECT_CALL(expand, Reset()); EXPECT_EQ(static_cast(kPacketsizeBytes), - normal.Process(input, - kPacketsizeBytes, - kModeExpand, - &output)); + normal.Process(input, kPacketsizeBytes, kModeExpand, &output)); EXPECT_EQ(kPacketsizeBytes, output.Size()); diff --git a/modules/audio_coding/neteq/packet_buffer.cc b/modules/audio_coding/neteq/packet_buffer.cc index f7b622d0b4..c04534eaa6 100644 --- a/modules/audio_coding/neteq/packet_buffer.cc +++ b/modules/audio_coding/neteq/packet_buffer.cc @@ -29,11 +29,8 @@ namespace { class NewTimestampIsLarger { public: explicit NewTimestampIsLarger(const Packet& new_packet) - : new_packet_(new_packet) { - } - bool operator()(const Packet& packet) { - return (new_packet_ >= packet); - } + : new_packet_(new_packet) {} + bool operator()(const Packet& packet) { return (new_packet_ >= packet); } private: const Packet& new_packet_; @@ -102,8 +99,7 @@ int PacketBuffer::InsertPacket(Packet&& packet, StatisticsCalculator* stats) { // should be inserted. The list is searched from the back, since the most // likely case is that the new packet should be near the end of the list. PacketList::reverse_iterator rit = std::find_if( - buffer_.rbegin(), buffer_.rend(), - NewTimestampIsLarger(packet)); + buffer_.rbegin(), buffer_.rend(), NewTimestampIsLarger(packet)); // The new packet is to be inserted to the right of |rit|. If it has the same // timestamp as |rit|, which has a higher priority, do not insert the new diff --git a/modules/audio_coding/neteq/post_decode_vad.cc b/modules/audio_coding/neteq/post_decode_vad.cc index a09d18ffd8..9999d6764b 100644 --- a/modules/audio_coding/neteq/post_decode_vad.cc +++ b/modules/audio_coding/neteq/post_decode_vad.cc @@ -45,7 +45,8 @@ void PostDecodeVad::Init() { } } -void PostDecodeVad::Update(int16_t* signal, size_t length, +void PostDecodeVad::Update(int16_t* signal, + size_t length, AudioDecoder::SpeechType speech_type, bool sid_frame, int fs_hz) { @@ -72,13 +73,13 @@ void PostDecodeVad::Update(int16_t* signal, size_t length, active_speech_ = false; // Loop through frame sizes 30, 20, and 10 ms. for (int vad_frame_size_ms = 30; vad_frame_size_ms >= 10; - vad_frame_size_ms -= 10) { + vad_frame_size_ms -= 10) { size_t vad_frame_size_samples = static_cast(vad_frame_size_ms * fs_hz / 1000); while (length - vad_sample_index >= vad_frame_size_samples) { - int vad_return = WebRtcVad_Process( - vad_instance_, fs_hz, &signal[vad_sample_index], - vad_frame_size_samples); + int vad_return = + WebRtcVad_Process(vad_instance_, fs_hz, &signal[vad_sample_index], + vad_frame_size_samples); active_speech_ |= (vad_return == 1); vad_sample_index += vad_frame_size_samples; } diff --git a/modules/audio_coding/neteq/post_decode_vad.h b/modules/audio_coding/neteq/post_decode_vad.h index 7b67bbe9b8..dac95f02f8 100644 --- a/modules/audio_coding/neteq/post_decode_vad.h +++ b/modules/audio_coding/neteq/post_decode_vad.h @@ -30,8 +30,7 @@ class PostDecodeVad { running_(false), active_speech_(true), sid_interval_counter_(0), - vad_instance_(NULL) { - } + vad_instance_(NULL) {} virtual ~PostDecodeVad(); @@ -46,8 +45,11 @@ class PostDecodeVad { // Updates post-decode VAD with the audio data in |signal| having |length| // samples. The data is of type |speech_type|, at the sample rate |fs_hz|. - void Update(int16_t* signal, size_t length, - AudioDecoder::SpeechType speech_type, bool sid_frame, int fs_hz); + void Update(int16_t* signal, + size_t length, + AudioDecoder::SpeechType speech_type, + bool sid_frame, + int fs_hz); // Accessors. bool enabled() const { return enabled_; } diff --git a/modules/audio_coding/neteq/preemptive_expand.cc b/modules/audio_coding/neteq/preemptive_expand.cc index bc753895b1..4702078d67 100644 --- a/modules/audio_coding/neteq/preemptive_expand.cc +++ b/modules/audio_coding/neteq/preemptive_expand.cc @@ -50,8 +50,7 @@ void PreemptiveExpand::SetParametersForPassiveSpeech(size_t len, // but we must ensure that best_correlation is not larger than the length of // the new data. // but we must ensure that best_correlation is not larger than the new data. - *peak_index = std::min(*peak_index, - len - old_data_length_per_channel_); + *peak_index = std::min(*peak_index, len - old_data_length_per_channel_); } PreemptiveExpand::ReturnCodes PreemptiveExpand::CheckCriteriaAndStretch( @@ -68,13 +67,13 @@ PreemptiveExpand::ReturnCodes PreemptiveExpand::CheckCriteriaAndStretch( // Check for strong correlation (>0.9 in Q14) and at least 15 ms new data, // or passive speech. if (((best_correlation > kCorrelationThreshold) && - (old_data_length_per_channel_ <= fs_mult_120)) || + (old_data_length_per_channel_ <= fs_mult_120)) || !active_speech) { // Do accelerate operation by overlap add. // Set length of the first part, not to be modified. - size_t unmodified_length = std::max(old_data_length_per_channel_, - fs_mult_120); + size_t unmodified_length = + std::max(old_data_length_per_channel_, fs_mult_120); // Copy first part, including cross-fade region. output->PushBackInterleaved( input, (unmodified_length + peak_index) * num_channels_); @@ -107,8 +106,8 @@ PreemptiveExpand* PreemptiveExpandFactory::Create( size_t num_channels, const BackgroundNoise& background_noise, size_t overlap_samples) const { - return new PreemptiveExpand( - sample_rate_hz, num_channels, background_noise, overlap_samples); + return new PreemptiveExpand(sample_rate_hz, num_channels, background_noise, + overlap_samples); } } // namespace webrtc diff --git a/modules/audio_coding/neteq/preemptive_expand.h b/modules/audio_coding/neteq/preemptive_expand.h index 303501db12..197d3f1974 100644 --- a/modules/audio_coding/neteq/preemptive_expand.h +++ b/modules/audio_coding/neteq/preemptive_expand.h @@ -35,15 +35,14 @@ class PreemptiveExpand : public TimeStretch { size_t overlap_samples) : TimeStretch(sample_rate_hz, num_channels, background_noise), old_data_length_per_channel_(0), - overlap_samples_(overlap_samples) { - } + overlap_samples_(overlap_samples) {} // This method performs the actual PreemptiveExpand operation. The samples are // read from |input|, of length |input_length| elements, and are written to // |output|. The number of samples added through time-stretching is // is provided in the output |length_change_samples|. The method returns // the outcome of the operation as an enumerator value. - ReturnCodes Process(const int16_t *pw16_decoded, + ReturnCodes Process(const int16_t* pw16_decoded, size_t len, size_t old_data_len, AudioMultiVector* output, @@ -77,11 +76,10 @@ struct PreemptiveExpandFactory { PreemptiveExpandFactory() {} virtual ~PreemptiveExpandFactory() {} - virtual PreemptiveExpand* Create( - int sample_rate_hz, - size_t num_channels, - const BackgroundNoise& background_noise, - size_t overlap_samples) const; + virtual PreemptiveExpand* Create(int sample_rate_hz, + size_t num_channels, + const BackgroundNoise& background_noise, + size_t overlap_samples) const; }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/random_vector.cc b/modules/audio_coding/neteq/random_vector.cc index c2df8cf80a..ada175831c 100644 --- a/modules/audio_coding/neteq/random_vector.cc +++ b/modules/audio_coding/neteq/random_vector.cc @@ -13,29 +13,35 @@ namespace webrtc { const int16_t RandomVector::kRandomTable[RandomVector::kRandomTableSize] = { - 2680, 5532, 441, 5520, 16170, -5146, -1024, -8733, 3115, 9598, -10380, - -4959, -1280, -21716, 7133, -1522, 13458, -3902, 2789, -675, 3441, 5016, - -13599, -4003, -2739, 3922, -7209, 13352, -11617, -7241, 12905, -2314, 5426, - 10121, -9702, 11207, -13542, 1373, 816, -5934, -12504, 4798, 1811, 4112, - -613, 201, -10367, -2960, -2419, 3442, 4299, -6116, -6092, 1552, -1650, - -480, -1237, 18720, -11858, -8303, -8212, 865, -2890, -16968, 12052, -5845, - -5912, 9777, -5665, -6294, 5426, -4737, -6335, 1652, 761, 3832, 641, -8552, - -9084, -5753, 8146, 12156, -4915, 15086, -1231, -1869, 11749, -9319, -6403, - 11407, 6232, -1683, 24340, -11166, 4017, -10448, 3153, -2936, 6212, 2891, - -866, -404, -4807, -2324, -1917, -2388, -6470, -3895, -10300, 5323, -5403, - 2205, 4640, 7022, -21186, -6244, -882, -10031, -3395, -12885, 7155, -5339, - 5079, -2645, -9515, 6622, 14651, 15852, 359, 122, 8246, -3502, -6696, -3679, - -13535, -1409, -704, -7403, -4007, 1798, 279, -420, -12796, -14219, 1141, - 3359, 11434, 7049, -6684, -7473, 14283, -4115, -9123, -8969, 4152, 4117, - 13792, 5742, 16168, 8661, -1609, -6095, 1881, 14380, -5588, 6758, -6425, - -22969, -7269, 7031, 1119, -1611, -5850, -11281, 3559, -8952, -10146, -4667, - -16251, -1538, 2062, -1012, -13073, 227, -3142, -5265, 20, 5770, -7559, - 4740, -4819, 992, -8208, -7130, -4652, 6725, 7369, -1036, 13144, -1588, - -5304, -2344, -449, -5705, -8894, 5205, -17904, -11188, -1022, 4852, 10101, - -5255, -4200, -752, 7941, -1543, 5959, 14719, 13346, 17045, -15605, -1678, - -1600, -9230, 68, 23348, 1172, 7750, 11212, -18227, 9956, 4161, 883, 3947, - 4341, 1014, -4889, -2603, 1246, -5630, -3596, -870, -1298, 2784, -3317, - -6612, -20541, 4166, 4181, -8625, 3562, 12890, 4761, 3205, -12259, -8579 }; + 2680, 5532, 441, 5520, 16170, -5146, -1024, -8733, 3115, + 9598, -10380, -4959, -1280, -21716, 7133, -1522, 13458, -3902, + 2789, -675, 3441, 5016, -13599, -4003, -2739, 3922, -7209, + 13352, -11617, -7241, 12905, -2314, 5426, 10121, -9702, 11207, + -13542, 1373, 816, -5934, -12504, 4798, 1811, 4112, -613, + 201, -10367, -2960, -2419, 3442, 4299, -6116, -6092, 1552, + -1650, -480, -1237, 18720, -11858, -8303, -8212, 865, -2890, + -16968, 12052, -5845, -5912, 9777, -5665, -6294, 5426, -4737, + -6335, 1652, 761, 3832, 641, -8552, -9084, -5753, 8146, + 12156, -4915, 15086, -1231, -1869, 11749, -9319, -6403, 11407, + 6232, -1683, 24340, -11166, 4017, -10448, 3153, -2936, 6212, + 2891, -866, -404, -4807, -2324, -1917, -2388, -6470, -3895, + -10300, 5323, -5403, 2205, 4640, 7022, -21186, -6244, -882, + -10031, -3395, -12885, 7155, -5339, 5079, -2645, -9515, 6622, + 14651, 15852, 359, 122, 8246, -3502, -6696, -3679, -13535, + -1409, -704, -7403, -4007, 1798, 279, -420, -12796, -14219, + 1141, 3359, 11434, 7049, -6684, -7473, 14283, -4115, -9123, + -8969, 4152, 4117, 13792, 5742, 16168, 8661, -1609, -6095, + 1881, 14380, -5588, 6758, -6425, -22969, -7269, 7031, 1119, + -1611, -5850, -11281, 3559, -8952, -10146, -4667, -16251, -1538, + 2062, -1012, -13073, 227, -3142, -5265, 20, 5770, -7559, + 4740, -4819, 992, -8208, -7130, -4652, 6725, 7369, -1036, + 13144, -1588, -5304, -2344, -449, -5705, -8894, 5205, -17904, + -11188, -1022, 4852, 10101, -5255, -4200, -752, 7941, -1543, + 5959, 14719, 13346, 17045, -15605, -1678, -1600, -9230, 68, + 23348, 1172, 7750, 11212, -18227, 9956, 4161, 883, 3947, + 4341, 1014, -4889, -2603, 1246, -5630, -3596, -870, -1298, + 2784, -3317, -6612, -20541, 4166, 4181, -8625, 3562, 12890, + 4761, 3205, -12259, -8579}; void RandomVector::Reset() { seed_ = 777; @@ -51,7 +57,7 @@ void RandomVector::Generate(size_t length, int16_t* output) { } void RandomVector::IncreaseSeedIncrement(int16_t increase_by) { - seed_increment_+= increase_by; + seed_increment_ += increase_by; seed_increment_ &= kRandomTableSize - 1; } } // namespace webrtc diff --git a/modules/audio_coding/neteq/random_vector.h b/modules/audio_coding/neteq/random_vector.h index 18adbe095c..2c6e06cade 100644 --- a/modules/audio_coding/neteq/random_vector.h +++ b/modules/audio_coding/neteq/random_vector.h @@ -24,10 +24,7 @@ class RandomVector { static const size_t kRandomTableSize = 256; static const int16_t kRandomTable[kRandomTableSize]; - RandomVector() - : seed_(777), - seed_increment_(1) { - } + RandomVector() : seed_(777), seed_increment_(1) {} void Reset(); diff --git a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc index c3d9f33b80..73cd66cac1 100644 --- a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc +++ b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc @@ -100,8 +100,8 @@ Packet CreateRedPayload(size_t num_payloads, // Not the last block; set F = 1. *payload_ptr |= 0x80; ++payload_ptr; - int this_offset = rtc::checked_cast( - (num_payloads - i - 1) * timestamp_offset); + int this_offset = + rtc::checked_cast((num_payloads - i - 1) * timestamp_offset); *payload_ptr = this_offset >> 6; ++payload_ptr; assert(kPayloadLength <= 1023); // Max length described by 10 bits. diff --git a/modules/audio_coding/neteq/rtcp.h b/modules/audio_coding/neteq/rtcp.h index ce2035b219..45bb058462 100644 --- a/modules/audio_coding/neteq/rtcp.h +++ b/modules/audio_coding/neteq/rtcp.h @@ -22,9 +22,7 @@ struct RTPHeader; class Rtcp { public: - Rtcp() { - Init(0); - } + Rtcp() { Init(0); } ~Rtcp() {} @@ -39,17 +37,17 @@ class Rtcp { void GetStatistics(bool no_reset, RtcpStatistics* stats); private: - uint16_t cycles_; // The number of wrap-arounds for the sequence number. - uint16_t max_seq_no_; // The maximum sequence number received. Starts over - // from 0 after wrap-around. + uint16_t cycles_; // The number of wrap-arounds for the sequence number. + uint16_t max_seq_no_; // The maximum sequence number received. Starts over + // from 0 after wrap-around. uint16_t base_seq_no_; // The sequence number of the first received packet. uint32_t received_packets_; // The number of packets that have been received. uint32_t received_packets_prior_; // Number of packets received when last // report was generated. uint32_t expected_prior_; // Expected number of packets, at the time of the // last report. - int64_t jitter_; // Current jitter value in Q4. - int32_t transit_; // Clock difference for previous packet. + int64_t jitter_; // Current jitter value in Q4. + int32_t transit_; // Clock difference for previous packet. RTC_DISALLOW_COPY_AND_ASSIGN(Rtcp); }; diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc index c698790b8a..3d5744cb29 100644 --- a/modules/audio_coding/neteq/statistics_calculator.cc +++ b/modules/audio_coding/neteq/statistics_calculator.cc @@ -42,8 +42,7 @@ StatisticsCalculator::PeriodicUmaLogger::PeriodicUmaLogger( : uma_name_(uma_name), report_interval_ms_(report_interval_ms), max_value_(max_value), - timer_(0) { -} + timer_(0) {} StatisticsCalculator::PeriodicUmaLogger::~PeriodicUmaLogger() = default; @@ -66,8 +65,7 @@ StatisticsCalculator::PeriodicUmaCount::PeriodicUmaCount( const std::string& uma_name, int report_interval_ms, int max_value) - : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) { -} + : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {} StatisticsCalculator::PeriodicUmaCount::~PeriodicUmaCount() { // Log the count for the current (incomplete) interval. @@ -90,8 +88,7 @@ StatisticsCalculator::PeriodicUmaAverage::PeriodicUmaAverage( const std::string& uma_name, int report_interval_ms, int max_value) - : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) { -} + : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {} StatisticsCalculator::PeriodicUmaAverage::~PeriodicUmaAverage() { // Log the average for the current (incomplete) interval. @@ -266,11 +263,10 @@ void StatisticsCalculator::StoreWaitingTime(int waiting_time_ms) { waiting_times_.push_back(waiting_time_ms); } -void StatisticsCalculator::GetNetworkStatistics( - int fs_hz, - size_t num_samples_in_buffers, - size_t samples_per_packet, - NetEqNetworkStatistics *stats) { +void StatisticsCalculator::GetNetworkStatistics(int fs_hz, + size_t num_samples_in_buffers, + size_t samples_per_packet, + NetEqNetworkStatistics* stats) { RTC_DCHECK_GT(fs_hz, 0); RTC_DCHECK(stats); @@ -291,20 +287,18 @@ void StatisticsCalculator::GetNetworkStatistics( CalculateQ14Ratio(expanded_speech_samples_ + expanded_noise_samples_, timestamps_since_last_report_); - stats->speech_expand_rate = - CalculateQ14Ratio(expanded_speech_samples_, - timestamps_since_last_report_); + stats->speech_expand_rate = CalculateQ14Ratio(expanded_speech_samples_, + timestamps_since_last_report_); - stats->secondary_decoded_rate = - CalculateQ14Ratio(secondary_decoded_samples_, - timestamps_since_last_report_); + stats->secondary_decoded_rate = CalculateQ14Ratio( + secondary_decoded_samples_, timestamps_since_last_report_); const size_t discarded_secondary_samples = discarded_secondary_packets_ * samples_per_packet; - stats->secondary_discarded_rate = CalculateQ14Ratio( - discarded_secondary_samples, - static_cast(discarded_secondary_samples + - secondary_decoded_samples_)); + stats->secondary_discarded_rate = + CalculateQ14Ratio(discarded_secondary_samples, + static_cast(discarded_secondary_samples + + secondary_decoded_samples_)); if (waiting_times_.size() == 0) { stats->mean_waiting_time_ms = -1; diff --git a/modules/audio_coding/neteq/statistics_calculator.h b/modules/audio_coding/neteq/statistics_calculator.h index a06ddfba62..42fd4c93e5 100644 --- a/modules/audio_coding/neteq/statistics_calculator.h +++ b/modules/audio_coding/neteq/statistics_calculator.h @@ -98,7 +98,7 @@ class StatisticsCalculator { void GetNetworkStatistics(int fs_hz, size_t num_samples_in_buffers, size_t samples_per_packet, - NetEqNetworkStatistics *stats); + NetEqNetworkStatistics* stats); // Populates |preferred_buffer_size_ms|, |jitter_peaks_found| and // |clockdrift_ppm| in |stats|. This is a convenience method, and does not diff --git a/modules/audio_coding/neteq/sync_buffer.cc b/modules/audio_coding/neteq/sync_buffer.cc index 28d7649fdb..82ca16fe60 100644 --- a/modules/audio_coding/neteq/sync_buffer.cc +++ b/modules/audio_coding/neteq/sync_buffer.cc @@ -27,7 +27,7 @@ void SyncBuffer::PushBack(const AudioMultiVector& append_this) { next_index_ -= samples_added; } else { // This means that we are pushing out future data that was never used. -// assert(false); + // assert(false); // TODO(hlundin): This assert must be disabled to support 60 ms frames. // This should not happen even for 60 ms frames, but it does. Investigate // why. @@ -75,9 +75,8 @@ void SyncBuffer::GetNextAudioInterleaved(size_t requested_len, RTC_DCHECK(output); const size_t samples_to_read = std::min(FutureLength(), requested_len); output->ResetWithoutMuting(); - const size_t tot_samples_read = - ReadInterleavedFromIndex(next_index_, samples_to_read, - output->mutable_data()); + const size_t tot_samples_read = ReadInterleavedFromIndex( + next_index_, samples_to_read, output->mutable_data()); const size_t samples_read_per_channel = tot_samples_read / Channels(); next_index_ += samples_read_per_channel; output->num_channels_ = Channels(); diff --git a/modules/audio_coding/neteq/sync_buffer.h b/modules/audio_coding/neteq/sync_buffer.h index d880356163..8a35326c7a 100644 --- a/modules/audio_coding/neteq/sync_buffer.h +++ b/modules/audio_coding/neteq/sync_buffer.h @@ -92,7 +92,7 @@ class SyncBuffer : public AudioMultiVector { private: size_t next_index_; uint32_t end_timestamp_; // The timestamp of the last sample in the buffer. - size_t dtmf_index_; // Index to the first non-DTMF sample in the buffer. + size_t dtmf_index_; // Index to the first non-DTMF sample in the buffer. RTC_DISALLOW_COPY_AND_ASSIGN(SyncBuffer); }; diff --git a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc index bca401a5d2..ad61235cf2 100644 --- a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc @@ -52,7 +52,8 @@ class NetEqIlbcQualityTest : public NetEqQualityTest { int EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) override { + rtc::Buffer* payload, + size_t max_bytes) override { const size_t kFrameSizeSamples = 80; // Samples per 10 ms. size_t encoded_samples = 0; uint32_t dummy_timestamp = 0; diff --git a/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc b/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc index d88f789f02..94984b87e6 100644 --- a/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc @@ -30,8 +30,11 @@ class NetEqIsacQualityTest : public NetEqQualityTest { NetEqIsacQualityTest(); void SetUp() override; void TearDown() override; - int EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) override; + int EncodeBlock(int16_t* in_data, + size_t block_size_samples, + rtc::Buffer* payload, + size_t max_bytes) override; + private: ISACFIX_MainStruct* isac_encoder_; int bit_rate_kbps_; @@ -44,10 +47,10 @@ NetEqIsacQualityTest::NetEqIsacQualityTest() NetEqDecoder::kDecoderISAC), isac_encoder_(NULL), bit_rate_kbps_(FLAG_bit_rate_kbps) { - // Flag validation - RTC_CHECK(FLAG_bit_rate_kbps >= 10 && FLAG_bit_rate_kbps <= 32) - << "Invalid bit rate, should be between 10 and 32 kbps."; - } + // Flag validation + RTC_CHECK(FLAG_bit_rate_kbps >= 10 && FLAG_bit_rate_kbps <= 32) + << "Invalid bit rate, should be between 10 and 32 kbps."; +} void NetEqIsacQualityTest::SetUp() { ASSERT_EQ(1u, channels_) << "iSAC supports only mono audio."; @@ -69,7 +72,8 @@ void NetEqIsacQualityTest::TearDown() { int NetEqIsacQualityTest::EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) { + rtc::Buffer* payload, + size_t max_bytes) { // ISAC takes 10 ms for every call. const int subblocks = kIsacBlockDurationMs / 10; const int subblock_length = 10 * kIsacInputSamplingKhz; @@ -80,11 +84,11 @@ int NetEqIsacQualityTest::EncodeBlock(int16_t* in_data, // The Isac encoder does not perform encoding (and returns 0) until it // receives a sequence of sub-blocks that amount to the frame duration. EXPECT_EQ(0, value); - payload->AppendData(max_bytes, [&] (rtc::ArrayView payload) { - value = WebRtcIsacfix_Encode(isac_encoder_, &in_data[pointer], - payload.data()); - return (value >= 0) ? static_cast(value) : 0; - }); + payload->AppendData(max_bytes, [&](rtc::ArrayView payload) { + value = WebRtcIsacfix_Encode(isac_encoder_, &in_data[pointer], + payload.data()); + return (value >= 0) ? static_cast(value) : 0; + }); } EXPECT_GT(value, 0); return value; diff --git a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc index c2542b6937..6861e4c55a 100644 --- a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/codecs/opus/opus_inst.h" +#include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/neteq/tools/neteq_quality_test.h" #include "rtc_base/flags.h" @@ -24,8 +24,10 @@ static const int kOpusSamplingKhz = 48; DEFINE_int(bit_rate_kbps, 32, "Target bit rate (kbps)."); -DEFINE_int(complexity, 10, "Complexity: 0 ~ 10 -- defined as in Opus" - "specification."); +DEFINE_int(complexity, + 10, + "Complexity: 0 ~ 10 -- defined as in Opus" + "specification."); DEFINE_int(maxplaybackrate, 48000, "Maximum playback rate (Hz)."); @@ -46,8 +48,11 @@ class NetEqOpusQualityTest : public NetEqQualityTest { NetEqOpusQualityTest(); void SetUp() override; void TearDown() override; - int EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) override; + int EncodeBlock(int16_t* in_data, + size_t block_size_samples, + rtc::Buffer* payload, + size_t max_bytes) override; + private: WebRtcOpusEncInst* opus_encoder_; OpusRepacketizer* repacketizer_; @@ -120,8 +125,7 @@ void NetEqOpusQualityTest::SetUp() { } EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, complexity_)); EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, maxplaybackrate_)); - EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, - target_loss_rate_)); + EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, target_loss_rate_)); NetEqQualityTest::SetUp(); } @@ -134,26 +138,25 @@ void NetEqOpusQualityTest::TearDown() { int NetEqOpusQualityTest::EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) { + rtc::Buffer* payload, + size_t max_bytes) { EXPECT_EQ(block_size_samples, sub_block_size_samples_ * sub_packets_); int16_t* pointer = in_data; int value; opus_repacketizer_init(repacketizer_); for (int idx = 0; idx < sub_packets_; idx++) { - payload->AppendData(max_bytes, [&] (rtc::ArrayView payload) { - value = WebRtcOpus_Encode(opus_encoder_, - pointer, sub_block_size_samples_, - max_bytes, payload.data()); + payload->AppendData(max_bytes, [&](rtc::ArrayView payload) { + value = WebRtcOpus_Encode(opus_encoder_, pointer, sub_block_size_samples_, + max_bytes, payload.data()); - Log() << "Encoded a frame with Opus mode " - << (value == 0 ? 0 : payload[0] >> 3) - << std::endl; + Log() << "Encoded a frame with Opus mode " + << (value == 0 ? 0 : payload[0] >> 3) << std::endl; - return (value >= 0) ? static_cast(value) : 0; - }); + return (value >= 0) ? static_cast(value) : 0; + }); - if (OPUS_OK != opus_repacketizer_cat(repacketizer_, - payload->data(), value)) { + if (OPUS_OK != + opus_repacketizer_cat(repacketizer_, payload->data(), value)) { opus_repacketizer_init(repacketizer_); // If the repacketization fails, we discard this frame. return 0; diff --git a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc index bc3c1682e4..54ff849739 100644 --- a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc @@ -52,7 +52,8 @@ class NetEqPcmuQualityTest : public NetEqQualityTest { int EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) override { + rtc::Buffer* payload, + size_t max_bytes) override { const size_t kFrameSizeSamples = 80; // Samples per 10 ms. size_t encoded_samples = 0; uint32_t dummy_timestamp = 0; diff --git a/modules/audio_coding/neteq/test/neteq_performance_unittest.cc b/modules/audio_coding/neteq/test/neteq_performance_unittest.cc index 0510af8004..6b1c223c40 100644 --- a/modules/audio_coding/neteq/test/neteq_performance_unittest.cc +++ b/modules/audio_coding/neteq/test/neteq_performance_unittest.cc @@ -9,10 +9,10 @@ */ #include "modules/audio_coding/neteq/tools/neteq_performance_test.h" +#include "system_wrappers/include/field_trial.h" #include "test/gtest.h" #include "test/testsupport/perf_test.h" #include "typedefs.h" // NOLINT(build/include) -#include "system_wrappers/include/field_trial.h" // Runs a test with 10% packet losses and 10% clock drift, to exercise // both loss concealment and time-stretching code. @@ -27,8 +27,8 @@ TEST(NetEqPerformanceTest, Run) { : kSimulationTimeMs, kLossPeriod, kDriftFactor); ASSERT_GT(runtime, 0); - webrtc::test::PrintResult( - "neteq_performance", "", "10_pl_10_drift", runtime, "ms", true); + webrtc::test::PrintResult("neteq_performance", "", "10_pl_10_drift", runtime, + "ms", true); } // Runs a test with neither packet losses nor clock drift, to put @@ -37,7 +37,7 @@ TEST(NetEqPerformanceTest, Run) { TEST(NetEqPerformanceTest, RunClean) { const int kSimulationTimeMs = 10000000; const int kQuickSimulationTimeMs = 100000; - const int kLossPeriod = 0; // No losses. + const int kLossPeriod = 0; // No losses. const double kDriftFactor = 0.0; // No clock drift. int64_t runtime = webrtc::test::NetEqPerformanceTest::Run( webrtc::field_trial::IsEnabled("WebRTC-QuickPerfTest") @@ -45,6 +45,6 @@ TEST(NetEqPerformanceTest, RunClean) { : kSimulationTimeMs, kLossPeriod, kDriftFactor); ASSERT_GT(runtime, 0); - webrtc::test::PrintResult( - "neteq_performance", "", "0_pl_0_drift", runtime, "ms", true); + webrtc::test::PrintResult("neteq_performance", "", "0_pl_0_drift", runtime, + "ms", true); } diff --git a/modules/audio_coding/neteq/test/neteq_speed_test.cc b/modules/audio_coding/neteq/test/neteq_speed_test.cc index ad123fe926..76b6878c13 100644 --- a/modules/audio_coding/neteq/test/neteq_speed_test.cc +++ b/modules/audio_coding/neteq/test/neteq_speed_test.cc @@ -19,23 +19,24 @@ // Define command line flags. DEFINE_int(runtime_ms, 10000, "Simulated runtime in ms."); -DEFINE_int(lossrate, 10, - "Packet lossrate; drop every N packets."); -DEFINE_float(drift, 0.1f, - "Clockdrift factor."); +DEFINE_int(lossrate, 10, "Packet lossrate; drop every N packets."); +DEFINE_float(drift, 0.1f, "Clockdrift factor."); DEFINE_bool(help, false, "Print this message."); int main(int argc, char* argv[]) { std::string program_name = argv[0]; - std::string usage = "Tool for measuring the speed of NetEq.\n" - "Usage: " + program_name + " [options]\n\n" + std::string usage = + "Tool for measuring the speed of NetEq.\n" + "Usage: " + + program_name + + " [options]\n\n" " --runtime_ms=N runtime in ms; default is 10000 ms\n" " --lossrate=N drop every N packets; default is 10\n" " --drift=F clockdrift factor between 0.0 and 1.0; " "default is 0.1\n"; webrtc::test::SetExecutablePath(argv[0]); - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 1) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 1) { printf("%s", usage.c_str()); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); @@ -47,9 +48,8 @@ int main(int argc, char* argv[]) { RTC_CHECK_GE(FLAG_lossrate, 0); RTC_CHECK(FLAG_drift >= 0.0 && FLAG_drift < 1.0); - int64_t result = - webrtc::test::NetEqPerformanceTest::Run(FLAG_runtime_ms, FLAG_lossrate, - FLAG_drift); + int64_t result = webrtc::test::NetEqPerformanceTest::Run( + FLAG_runtime_ms, FLAG_lossrate, FLAG_drift); if (result <= 0) { std::cout << "There was an error" << std::endl; return -1; diff --git a/modules/audio_coding/neteq/time_stretch.cc b/modules/audio_coding/neteq/time_stretch.cc index 8a1bfa2835..560d9be56d 100644 --- a/modules/audio_coding/neteq/time_stretch.cc +++ b/modules/audio_coding/neteq/time_stretch.cc @@ -80,7 +80,7 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input, // Calculate scaling to ensure that |peak_index| samples can be square-summed // without overflowing. int scaling = 31 - WebRtcSpl_NormW32(max_input_value_ * max_input_value_) - - WebRtcSpl_NormW32(static_cast(peak_index)); + WebRtcSpl_NormW32(static_cast(peak_index)); scaling = std::max(0, scaling); // |vec1| starts at 15 ms minus one pitch period. @@ -99,8 +99,8 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input, WebRtcSpl_DotProductWithScale(vec1, vec2, peak_index, scaling); // Check if the signal seems to be active speech or not (simple VAD). - bool active_speech = SpeechDetection(vec1_energy, vec2_energy, peak_index, - scaling); + bool active_speech = + SpeechDetection(vec1_energy, vec2_energy, peak_index, scaling); int16_t best_correlation; if (!active_speech) { @@ -126,8 +126,8 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input, static_cast(vec2_energy >> energy2_scale); // Calculate square-root of energy product. - int16_t sqrt_energy_prod = WebRtcSpl_SqrtFloor(vec1_energy_int16 * - vec2_energy_int16); + int16_t sqrt_energy_prod = + WebRtcSpl_SqrtFloor(vec1_energy_int16 * vec2_energy_int16); // Calculate cross_corr / sqrt(en1*en2) in Q14. int temp_scale = 14 - (energy1_scale + energy2_scale) / 2; @@ -138,7 +138,6 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input, best_correlation = std::min(static_cast(16384), best_correlation); } - // Check accelerate criteria and stretch the signal. ReturnCodes return_value = CheckCriteriaAndStretch(input, input_len, peak_index, best_correlation, @@ -172,8 +171,10 @@ void TimeStretch::AutoCorrelation() { auto_corr, scaling); } -bool TimeStretch::SpeechDetection(int32_t vec1_energy, int32_t vec2_energy, - size_t peak_index, int scaling) const { +bool TimeStretch::SpeechDetection(int32_t vec1_energy, + int32_t vec2_energy, + size_t peak_index, + int scaling) const { // Check if the signal seems to be active speech or not (simple VAD). // If (vec1_energy + vec2_energy) / (2 * peak_index) <= // 8 * background_noise_energy, then we say that the signal contains no diff --git a/modules/audio_coding/neteq/time_stretch.h b/modules/audio_coding/neteq/time_stretch.h index ace10cd055..606d1d0ecf 100644 --- a/modules/audio_coding/neteq/time_stretch.h +++ b/modules/audio_coding/neteq/time_stretch.h @@ -35,7 +35,8 @@ class TimeStretch { kError = -1 }; - TimeStretch(int sample_rate_hz, size_t num_channels, + TimeStretch(int sample_rate_hz, + size_t num_channels, const BackgroundNoise& background_noise) : sample_rate_hz_(sample_rate_hz), fs_mult_(sample_rate_hz / 8000), @@ -43,10 +44,8 @@ class TimeStretch { master_channel_(0), // First channel is master. background_noise_(background_noise), max_input_value_(0) { - assert(sample_rate_hz_ == 8000 || - sample_rate_hz_ == 16000 || - sample_rate_hz_ == 32000 || - sample_rate_hz_ == 48000); + assert(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 || + sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000); assert(num_channels_ > 0); assert(master_channel_ < num_channels_); memset(auto_correlation_, 0, sizeof(auto_correlation_)); @@ -106,8 +105,10 @@ class TimeStretch { void AutoCorrelation(); // Performs a simple voice-activity detection based on the input parameters. - bool SpeechDetection(int32_t vec1_energy, int32_t vec2_energy, - size_t peak_index, int scaling) const; + bool SpeechDetection(int32_t vec1_energy, + int32_t vec2_energy, + size_t peak_index, + int scaling) const; RTC_DISALLOW_COPY_AND_ASSIGN(TimeStretch); }; diff --git a/modules/audio_coding/neteq/time_stretch_unittest.cc b/modules/audio_coding/neteq/time_stretch_unittest.cc index 8d0f4d4a64..c96c7d4ec2 100644 --- a/modules/audio_coding/neteq/time_stretch_unittest.cc +++ b/modules/audio_coding/neteq/time_stretch_unittest.cc @@ -34,8 +34,8 @@ TEST(TimeStretch, CreateAndDestroy) { const int kOverlapSamples = 5 * kSampleRate / 8000; BackgroundNoise bgn(kNumChannels); Accelerate accelerate(kSampleRate, kNumChannels, bgn); - PreemptiveExpand preemptive_expand( - kSampleRate, kNumChannels, bgn, kOverlapSamples); + PreemptiveExpand preemptive_expand(kSampleRate, kNumChannels, bgn, + kOverlapSamples); } TEST(TimeStretch, CreateUsingFactory) { diff --git a/modules/audio_coding/neteq/timestamp_scaler.cc b/modules/audio_coding/neteq/timestamp_scaler.cc index d7aa9fe868..07d945edce 100644 --- a/modules/audio_coding/neteq/timestamp_scaler.cc +++ b/modules/audio_coding/neteq/timestamp_scaler.cc @@ -70,7 +70,6 @@ uint32_t TimestampScaler::ToInternal(uint32_t external_timestamp, } } - uint32_t TimestampScaler::ToExternal(uint32_t internal_timestamp) const { if (!first_packet_received_ || (numerator_ == denominator_)) { // Not initialized, or scale factor is 1. diff --git a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc index eeaf772b4e..1f1445af05 100644 --- a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc +++ b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "modules/audio_coding/neteq/timestamp_scaler.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "modules/audio_coding/neteq/mock/mock_decoder_database.h" #include "modules/audio_coding/neteq/packet.h" -#include "modules/audio_coding/neteq/timestamp_scaler.h" #include "test/gmock.h" #include "test/gtest.h" @@ -60,7 +60,7 @@ TEST(TimestampScaler, TestNoScalingLargeStep) { // |external_timestamp| will be a large positive value. start_timestamp = start_timestamp - 5 * kStep; for (uint32_t timestamp = start_timestamp; timestamp != 5 * kStep; - timestamp += kStep) { + timestamp += kStep) { // Scale to internal timestamp. EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); // Scale back. diff --git a/modules/audio_coding/neteq/tools/audio_loop.cc b/modules/audio_coding/neteq/tools/audio_loop.cc index b5ad8817fe..972921b51a 100644 --- a/modules/audio_coding/neteq/tools/audio_loop.cc +++ b/modules/audio_coding/neteq/tools/audio_loop.cc @@ -21,16 +21,18 @@ bool AudioLoop::Init(const std::string file_name, size_t max_loop_length_samples, size_t block_length_samples) { FILE* fp = fopen(file_name.c_str(), "rb"); - if (!fp) return false; + if (!fp) + return false; - audio_array_.reset(new int16_t[max_loop_length_samples + - block_length_samples]); - size_t samples_read = fread(audio_array_.get(), sizeof(int16_t), - max_loop_length_samples, fp); + audio_array_.reset( + new int16_t[max_loop_length_samples + block_length_samples]); + size_t samples_read = + fread(audio_array_.get(), sizeof(int16_t), max_loop_length_samples, fp); fclose(fp); // Block length must be shorter than the loop length. - if (block_length_samples > samples_read) return false; + if (block_length_samples > samples_read) + return false; // Add an extra block length of samples to the end of the array, starting // over again from the beginning of the array. This is done to simplify @@ -54,6 +56,5 @@ rtc::ArrayView AudioLoop::GetNextBlock() { return rtc::ArrayView(output_ptr, block_length_samples_); } - } // namespace test } // namespace webrtc diff --git a/modules/audio_coding/neteq/tools/audio_loop.h b/modules/audio_coding/neteq/tools/audio_loop.h index abb1a36378..876c2d772c 100644 --- a/modules/audio_coding/neteq/tools/audio_loop.h +++ b/modules/audio_coding/neteq/tools/audio_loop.h @@ -26,10 +26,7 @@ namespace test { class AudioLoop { public: AudioLoop() - : next_index_(0), - loop_length_samples_(0), - block_length_samples_(0) { - } + : next_index_(0), loop_length_samples_(0), block_length_samples_(0) {} virtual ~AudioLoop() {} @@ -38,7 +35,8 @@ class AudioLoop { // greater. Otherwise, the loop length is the same as the file length. // The audio will be delivered in blocks of |block_length_samples|. // Returns false if the initialization failed, otherwise true. - bool Init(const std::string file_name, size_t max_loop_length_samples, + bool Init(const std::string file_name, + size_t max_loop_length_samples, size_t block_length_samples); // Returns a (pointer,size) pair for the next block of audio. The size is diff --git a/modules/audio_coding/neteq/tools/audio_sink.h b/modules/audio_coding/neteq/tools/audio_sink.h index 18ac6fcd9f..05e6fe8e7c 100644 --- a/modules/audio_coding/neteq/tools/audio_sink.h +++ b/modules/audio_coding/neteq/tools/audio_sink.h @@ -32,9 +32,8 @@ class AudioSink { // Writes |audio_frame| to the AudioSink. Returns true if successful, // otherwise false. bool WriteAudioFrame(const AudioFrame& audio_frame) { - return WriteArray( - audio_frame.data(), - audio_frame.samples_per_channel_ * audio_frame.num_channels_); + return WriteArray(audio_frame.data(), audio_frame.samples_per_channel_ * + audio_frame.num_channels_); } private: diff --git a/modules/audio_coding/neteq/tools/input_audio_file.cc b/modules/audio_coding/neteq/tools/input_audio_file.cc index 330a874ea9..6d11064724 100644 --- a/modules/audio_coding/neteq/tools/input_audio_file.cc +++ b/modules/audio_coding/neteq/tools/input_audio_file.cc @@ -20,7 +20,9 @@ InputAudioFile::InputAudioFile(const std::string file_name, bool loop_at_end) fp_ = fopen(file_name.c_str(), "rb"); } -InputAudioFile::~InputAudioFile() { fclose(fp_); } +InputAudioFile::~InputAudioFile() { + fclose(fp_); +} bool InputAudioFile::Read(size_t samples, int16_t* destination) { if (!fp_) { @@ -73,7 +75,8 @@ bool InputAudioFile::Seek(int samples) { return true; } -void InputAudioFile::DuplicateInterleaved(const int16_t* source, size_t samples, +void InputAudioFile::DuplicateInterleaved(const int16_t* source, + size_t samples, size_t channels, int16_t* destination) { // Start from the end of |source| and |destination|, and work towards the diff --git a/modules/audio_coding/neteq/tools/input_audio_file.h b/modules/audio_coding/neteq/tools/input_audio_file.h index 6bfa369b38..db5a9440eb 100644 --- a/modules/audio_coding/neteq/tools/input_audio_file.h +++ b/modules/audio_coding/neteq/tools/input_audio_file.h @@ -45,8 +45,10 @@ class InputAudioFile { // channels are identical. The output |destination| must have the capacity to // hold samples * channels elements. Note that |source| and |destination| can // be the same array (i.e., point to the same address). - static void DuplicateInterleaved(const int16_t* source, size_t samples, - size_t channels, int16_t* destination); + static void DuplicateInterleaved(const int16_t* source, + size_t samples, + size_t channels, + int16_t* destination); private: FILE* fp_; diff --git a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc index 2c23e5c90b..3bd218b8b8 100644 --- a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include "modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" #include "api/audio/audio_frame.h" @@ -32,9 +31,8 @@ NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec, } void NetEqExternalDecoderTest::Init() { - ASSERT_EQ(NetEq::kOK, - neteq_->RegisterExternalDecoder(decoder_, codec_, name_, - kPayloadType)); + ASSERT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder(decoder_, codec_, name_, + kPayloadType)); } void NetEqExternalDecoderTest::InsertPacket( diff --git a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h index b8670a3f68..78f0085e03 100644 --- a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h +++ b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h @@ -31,7 +31,7 @@ class NetEqExternalDecoderTest { int sample_rate_hz, AudioDecoder* decoder); - virtual ~NetEqExternalDecoderTest() { } + virtual ~NetEqExternalDecoderTest() {} // In Init(), we register the external decoder. void Init(); diff --git a/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/modules/audio_coding/neteq/tools/neteq_performance_test.cc index 80aa809132..e0dfebf206 100644 --- a/modules/audio_coding/neteq/tools/neteq_performance_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_performance_test.cc @@ -95,9 +95,8 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, } // Get next packet. - packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType, - kInputBlockSizeSamples, - &rtp_header); + packet_input_time_ms = rtp_gen.GetRtpHeader( + kPayloadType, kInputBlockSizeSamples, &rtp_header); input_samples = audio_loop.GetNextBlock(); if (input_samples.empty()) return -1; diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc index 82fa90e602..faca8959d4 100644 --- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc @@ -47,7 +47,9 @@ static bool ValidateFilename(const std::string& value, bool write) { return true; } -DEFINE_string(in_filename, DefaultInFilename().c_str(), +DEFINE_string( + in_filename, + DefaultInFilename().c_str(), "Filename for input audio (specify sample rate with --input_sample_rate, " "and channels with --channels)."); @@ -55,8 +57,9 @@ DEFINE_int(input_sample_rate, 16000, "Sample rate of input file in Hz."); DEFINE_int(channels, 1, "Number of channels in input audio."); -DEFINE_string(out_filename, DefaultOutFilename().c_str(), - "Name of output audio file."); +DEFINE_string(out_filename, + DefaultOutFilename().c_str(), + "Name of output audio file."); DEFINE_int(runtime_ms, 10000, "Simulated runtime (milliseconds)."); @@ -67,8 +70,9 @@ DEFINE_int(random_loss_mode, "Random loss mode: 0--no loss, 1--uniform loss, 2--Gilbert Elliot " "loss, 3--fixed loss."); -DEFINE_int(burst_length, 30, - "Burst length in milliseconds, only valid for Gilbert Elliot loss."); +DEFINE_int(burst_length, + 30, + "Burst length in milliseconds, only valid for Gilbert Elliot loss."); DEFINE_float(drift_factor, 0.0, "Time drift factor."); @@ -85,21 +89,22 @@ DEFINE_string(loss_events, // to achieve the target packet loss rate |loss_rate|, when a packet is not // lost only if all |units| drawings within the duration of the packet result in // no-loss. -static double ProbTrans00Solver(int units, double loss_rate, +static double ProbTrans00Solver(int units, + double loss_rate, double prob_trans_10) { if (units == 1) return prob_trans_10 / (1.0f - loss_rate) - prob_trans_10; -// 0 == prob_trans_00 ^ (units - 1) + (1 - loss_rate) / prob_trans_10 * -// prob_trans_00 - (1 - loss_rate) * (1 + 1 / prob_trans_10). -// There is a unique solution between 0.0 and 1.0, due to the monotonicity and -// an opposite sign at 0.0 and 1.0. -// For simplicity, we reformulate the equation as -// f(x) = x ^ (units - 1) + a x + b. -// Its derivative is -// f'(x) = (units - 1) x ^ (units - 2) + a. -// The derivative is strictly greater than 0 when x is between 0 and 1. -// We use Newton's method to solve the equation, iteration is -// x(k+1) = x(k) - f(x) / f'(x); + // 0 == prob_trans_00 ^ (units - 1) + (1 - loss_rate) / prob_trans_10 * + // prob_trans_00 - (1 - loss_rate) * (1 + 1 / prob_trans_10). + // There is a unique solution between 0.0 and 1.0, due to the monotonicity and + // an opposite sign at 0.0 and 1.0. + // For simplicity, we reformulate the equation as + // f(x) = x ^ (units - 1) + a x + b. + // Its derivative is + // f'(x) = (units - 1) x ^ (units - 2) + a. + // The derivative is strictly greater than 0 when x is between 0 and 1. + // We use Newton's method to solve the equation, iteration is + // x(k+1) = x(k) - f(x) / f'(x); const double kPrecision = 0.001f; const int kIterations = 100; const double a = (1.0f - loss_rate) / prob_trans_10; @@ -117,7 +122,7 @@ static double ProbTrans00Solver(int units, double loss_rate, x = 0.0f; } f = pow(x, units - 1) + a * x + b; - iter ++; + iter++; } return x; } @@ -210,9 +215,7 @@ bool NoLoss::Lost(int now_ms) { return false; } -UniformLoss::UniformLoss(double loss_rate) - : loss_rate_(loss_rate) { -} +UniformLoss::UniformLoss(double loss_rate) : loss_rate_(loss_rate) {} bool UniformLoss::Lost(int now_ms) { int drop_this = rand(); @@ -223,8 +226,7 @@ GilbertElliotLoss::GilbertElliotLoss(double prob_trans_11, double prob_trans_01) : prob_trans_11_(prob_trans_11), prob_trans_01_(prob_trans_01), lost_last_(false), - uniform_loss_model_(new UniformLoss(0)) { -} + uniform_loss_model_(new UniformLoss(0)) {} GilbertElliotLoss::~GilbertElliotLoss() {} @@ -277,8 +279,8 @@ void NetEqQualityTest::SetUp() { // a full packet duration is drawn with a loss, |unit_loss_rate| fulfills // (1 - unit_loss_rate) ^ (block_duration_ms_ / kPacketLossTimeUnitMs) == // 1 - packet_loss_rate. - double unit_loss_rate = (1.0f - pow(1.0f - 0.01f * packet_loss_rate_, - 1.0f / units)); + double unit_loss_rate = + (1.0f - pow(1.0f - 0.01f * packet_loss_rate_, 1.0f / units)); loss_model_.reset(new UniformLoss(unit_loss_rate)); break; } @@ -304,8 +306,8 @@ void NetEqQualityTest::SetUp() { double loss_rate = 0.01f * packet_loss_rate_; double prob_trans_10 = 1.0f * kPacketLossTimeUnitMs / FLAG_burst_length; double prob_trans_00 = ProbTrans00Solver(units, loss_rate, prob_trans_10); - loss_model_.reset(new GilbertElliotLoss(1.0f - prob_trans_10, - 1.0f - prob_trans_00)); + loss_model_.reset( + new GilbertElliotLoss(1.0f - prob_trans_10, 1.0f - prob_trans_00)); break; } case kFixedLoss: { @@ -347,7 +349,7 @@ bool NetEqQualityTest::PacketLost() { // The loop is to make sure that codecs with different block lengths share the // same packet loss profile. bool lost = false; - for (int idx = 0; idx < cycles; idx ++) { + for (int idx = 0; idx < cycles; idx++) { if (loss_model_->Lost(decoded_time_ms_)) { // The packet will be lost if any of the drawings indicates a loss, but // the loop has to go on to make sure that codecs with different block @@ -359,14 +361,10 @@ bool NetEqQualityTest::PacketLost() { } int NetEqQualityTest::Transmit() { - int packet_input_time_ms = - rtp_generator_->GetRtpHeader(kPayloadType, in_size_samples_, - &rtp_header_); - Log() << "Packet of size " - << payload_size_bytes_ - << " bytes, for frame at " - << packet_input_time_ms - << " ms "; + int packet_input_time_ms = rtp_generator_->GetRtpHeader( + kPayloadType, in_size_samples_, &rtp_header_); + Log() << "Packet of size " << payload_size_bytes_ << " bytes, for frame at " + << packet_input_time_ms << " ms "; if (payload_size_bytes_ > 0) { if (!PacketLost()) { int ret = neteq_->InsertPacket( @@ -411,9 +409,8 @@ void NetEqQualityTest::Simulate() { decoded_time_ms_) { ASSERT_TRUE(in_file_->Read(in_size_samples_ * channels_, &in_data_[0])); payload_.Clear(); - payload_size_bytes_ = EncodeBlock(&in_data_[0], - in_size_samples_, &payload_, - max_payload_bytes_); + payload_size_bytes_ = EncodeBlock(&in_data_[0], in_size_samples_, + &payload_, max_payload_bytes_); total_payload_size_bytes_ += payload_size_bytes_; decodable_time_ms_ = Transmit() + block_duration_ms_; } @@ -423,8 +420,7 @@ void NetEqQualityTest::Simulate() { } } Log() << "Average bit rate was " - << 8.0f * total_payload_size_bytes_ / FLAG_runtime_ms - << " kbps" + << 8.0f * total_payload_size_bytes_ / FLAG_runtime_ms << " kbps" << std::endl; } diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.h b/modules/audio_coding/neteq/tools/neteq_quality_test.h index 2b82b0aec8..b19460cfe9 100644 --- a/modules/audio_coding/neteq/tools/neteq_quality_test.h +++ b/modules/audio_coding/neteq/tools/neteq_quality_test.h @@ -36,7 +36,7 @@ enum LossModes { class LossModel { public: - virtual ~LossModel() {}; + virtual ~LossModel(){}; virtual bool Lost(int now_ms) = 0; }; @@ -110,8 +110,10 @@ class NetEqQualityTest : public ::testing::Test { // |block_size_samples| (samples per channel), // 2. save the bit stream to |payload| of |max_bytes| bytes in size, // 3. returns the length of the payload (in bytes), - virtual int EncodeBlock(int16_t* in_data, size_t block_size_samples, - rtc::Buffer* payload, size_t max_bytes) = 0; + virtual int EncodeBlock(int16_t* in_data, + size_t block_size_samples, + rtc::Buffer* payload, + size_t max_bytes) = 0; // PacketLost(...) determines weather a packet sent at an indicated time gets // lost or not. diff --git a/modules/audio_coding/neteq/tools/neteq_replacement_input.h b/modules/audio_coding/neteq/tools/neteq_replacement_input.h index 111300129d..9ce9b9dc63 100644 --- a/modules/audio_coding/neteq/tools/neteq_replacement_input.h +++ b/modules/audio_coding/neteq/tools/neteq_replacement_input.h @@ -42,7 +42,7 @@ class NetEqReplacementInput : public NetEqInput { const uint8_t replacement_payload_type_; const std::set comfort_noise_types_; const std::set forbidden_types_; - std::unique_ptr packet_; // The next packet to deliver. + std::unique_ptr packet_; // The next packet to deliver. uint32_t last_frame_size_timestamps_ = 960; // Initial guess: 20 ms @ 48 kHz. }; diff --git a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc index d69b1a7938..673c8fd817 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc +++ b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc @@ -10,20 +10,20 @@ #include #include -#include #include // For ULONG_MAX returned by strtoul. -#include #include #include // For strtoul. +#include +#include #include #include "modules/audio_coding/neteq/include/neteq.h" #include "modules/audio_coding/neteq/tools/fake_decode_from_file.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" -#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" #include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h" #include "modules/audio_coding/neteq/tools/neteq_replacement_input.h" +#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" #include "modules/audio_coding/neteq/tools/output_audio_file.h" #include "modules/audio_coding/neteq/tools/output_wav_file.h" @@ -71,7 +71,7 @@ bool ValidatePayloadType(int value) { bool ValidateSsrcValue(const std::string& str) { uint32_t dummy_ssrc; - if (ParseSsrc(str, &dummy_ssrc)) // Value is ok. + if (ParseSsrc(str, &dummy_ssrc)) // Value is ok. return true; printf("Invalid SSRC: %s\n", str.c_str()); return false; @@ -106,10 +106,15 @@ DEFINE_int(cn_nb, 13, "RTP payload type for comfort noise (8 kHz)"); DEFINE_int(cn_wb, 98, "RTP payload type for comfort noise (16 kHz)"); DEFINE_int(cn_swb32, 99, "RTP payload type for comfort noise (32 kHz)"); DEFINE_int(cn_swb48, 100, "RTP payload type for comfort noise (48 kHz)"); -DEFINE_bool(codec_map, false, "Prints the mapping between RTP payload type and " - "codec"); -DEFINE_string(replacement_audio_file, "", - "A PCM file that will be used to populate ""dummy"" RTP packets"); +DEFINE_bool(codec_map, + false, + "Prints the mapping between RTP payload type and " + "codec"); +DEFINE_string(replacement_audio_file, + "", + "A PCM file that will be used to populate " + "dummy" + " RTP packets"); DEFINE_string(ssrc, "", "Only use packets with this SSRC (decimal or hex, the latter " @@ -240,8 +245,8 @@ class SsrcSwitchDetector : public NetEqPostInsertPacket { NetEq* neteq) override { if (last_ssrc_ && packet.header.ssrc != *last_ssrc_) { std::cout << "Changing streams from 0x" << std::hex << *last_ssrc_ - << " to 0x" << std::hex << packet.header.ssrc - << std::dec << " (payload type " + << " to 0x" << std::hex << packet.header.ssrc << std::dec + << " (payload type " << static_cast(packet.header.payloadType) << ")" << std::endl; } @@ -258,10 +263,13 @@ class SsrcSwitchDetector : public NetEqPostInsertPacket { int RunTest(int argc, char* argv[]) { std::string program_name = argv[0]; - std::string usage = "Tool for decoding an RTP dump file using NetEq.\n" - "Run " + program_name + " --help for usage.\n" - "Example usage:\n" + program_name + - " input.rtp output.{pcm, wav}\n"; + std::string usage = + "Tool for decoding an RTP dump file using NetEq.\n" + "Run " + + program_name + + " --help for usage.\n" + "Example usage:\n" + + program_name + " input.rtp output.{pcm, wav}\n"; if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) { return 1; } @@ -406,10 +414,8 @@ int RunTest(int argc, char* argv[]) { {FLAG_g722, std::make_pair(NetEqDecoder::kDecoderG722, "g722")}, {FLAG_avt, std::make_pair(NetEqDecoder::kDecoderAVT, "avt")}, {FLAG_avt_16, std::make_pair(NetEqDecoder::kDecoderAVT16kHz, "avt-16")}, - {FLAG_avt_32, - std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")}, - {FLAG_avt_48, - std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")}, + {FLAG_avt_32, std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")}, + {FLAG_avt_48, std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")}, {FLAG_red, std::make_pair(NetEqDecoder::kDecoderRED, "red")}, {FLAG_cn_nb, std::make_pair(NetEqDecoder::kDecoderCNGnb, "cng-nb")}, {FLAG_cn_wb, std::make_pair(NetEqDecoder::kDecoderCNGwb, "cng-wb")}, @@ -440,9 +446,8 @@ int RunTest(int argc, char* argv[]) { std::set cn_types = std_set_int32_to_uint8( {FLAG_cn_nb, FLAG_cn_wb, FLAG_cn_swb32, FLAG_cn_swb48}); - std::set forbidden_types = - std_set_int32_to_uint8({FLAG_g722, FLAG_red, FLAG_avt, - FLAG_avt_16, FLAG_avt_32, FLAG_avt_48}); + std::set forbidden_types = std_set_int32_to_uint8( + {FLAG_g722, FLAG_red, FLAG_avt, FLAG_avt_16, FLAG_avt_32, FLAG_avt_48}); input.reset(new NetEqReplacementInput(std::move(input), replacement_pt, cn_types, forbidden_types)); diff --git a/modules/audio_coding/neteq/tools/neteq_stats_getter.cc b/modules/audio_coding/neteq/tools/neteq_stats_getter.cc index 6474e21ca7..58c9ae4acb 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_getter.cc +++ b/modules/audio_coding/neteq/tools/neteq_stats_getter.cc @@ -26,8 +26,7 @@ std::string NetEqStatsGetter::ConcealmentEvent::ToString() const { rtc::SimpleStringBuilder ss(ss_buf); ss << "ConcealmentEvent duration_ms:" << duration_ms << " event_number:" << concealment_event_number - << " time_from_previous_event_end_ms:" - << time_from_previous_event_end_ms; + << " time_from_previous_event_end_ms:" << time_from_previous_event_end_ms; return ss.str(); } @@ -115,12 +114,10 @@ NetEqStatsGetter::Stats NetEqStatsGetter::AverageStats() const { a.added_zero_samples += b.added_zero_samples; a.mean_waiting_time_ms += b.mean_waiting_time_ms; a.median_waiting_time_ms += b.median_waiting_time_ms; - a.min_waiting_time_ms = - std::min(a.min_waiting_time_ms, - static_cast(b.min_waiting_time_ms)); - a.max_waiting_time_ms = - std::max(a.max_waiting_time_ms, - static_cast(b.max_waiting_time_ms)); + a.min_waiting_time_ms = std::min( + a.min_waiting_time_ms, static_cast(b.min_waiting_time_ms)); + a.max_waiting_time_ms = std::max( + a.max_waiting_time_ms, static_cast(b.max_waiting_time_ms)); return a; }); diff --git a/modules/audio_coding/neteq/tools/neteq_stats_getter.h b/modules/audio_coding/neteq/tools/neteq_stats_getter.h index dbb396a249..975393c316 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_getter.h +++ b/modules/audio_coding/neteq/tools/neteq_stats_getter.h @@ -69,9 +69,7 @@ class NetEqStatsGetter : public NetEqGetAudioCallback { double AverageSpeechExpandRate() const; - NetEqDelayAnalyzer* delay_analyzer() const { - return delay_analyzer_.get(); - } + NetEqDelayAnalyzer* delay_analyzer() const { return delay_analyzer_.get(); } const std::vector& concealment_events() const { // Do not account for the last concealment event to avoid potential end diff --git a/modules/audio_coding/neteq/tools/packet.cc b/modules/audio_coding/neteq/tools/packet.cc index 9505a2953c..b1a9b64193 100644 --- a/modules/audio_coding/neteq/tools/packet.cc +++ b/modules/audio_coding/neteq/tools/packet.cc @@ -158,11 +158,10 @@ void Packet::CopyToHeader(RTPHeader* destination) const { destination->paddingLength = header_.paddingLength; destination->headerLength = header_.headerLength; destination->payload_type_frequency = header_.payload_type_frequency; - memcpy(&destination->arrOfCSRCs, - &header_.arrOfCSRCs, + memcpy(&destination->arrOfCSRCs, &header_.arrOfCSRCs, sizeof(header_.arrOfCSRCs)); - memcpy( - &destination->extension, &header_.extension, sizeof(header_.extension)); + memcpy(&destination->extension, &header_.extension, + sizeof(header_.extension)); } } // namespace test diff --git a/modules/audio_coding/neteq/tools/packet.h b/modules/audio_coding/neteq/tools/packet.h index 94d45c5b2d..2c9a26f31e 100644 --- a/modules/audio_coding/neteq/tools/packet.h +++ b/modules/audio_coding/neteq/tools/packet.h @@ -15,7 +15,7 @@ #include #include "api/rtp_headers.h" // NOLINT(build/include) -#include "common_types.h" // NOLINT(build/include) +#include "common_types.h" // NOLINT(build/include) #include "rtc_base/constructormagic.h" #include "typedefs.h" // NOLINT(build/include) diff --git a/modules/audio_coding/neteq/tools/packet_unittest.cc b/modules/audio_coding/neteq/tools/packet_unittest.cc index ce6a3b9697..7f3d6630c3 100644 --- a/modules/audio_coding/neteq/tools/packet_unittest.cc +++ b/modules/audio_coding/neteq/tools/packet_unittest.cc @@ -28,7 +28,7 @@ void MakeRtpHeader(int payload_type, rtp_data[0] = 0x80; rtp_data[1] = static_cast(payload_type); rtp_data[2] = (seq_number >> 8) & 0xFF; - rtp_data[3] = (seq_number) & 0xFF; + rtp_data[3] = (seq_number)&0xFF; rtp_data[4] = timestamp >> 24; rtp_data[5] = (timestamp >> 16) & 0xFF; rtp_data[6] = (timestamp >> 8) & 0xFF; @@ -47,8 +47,8 @@ TEST(TestPacket, RegularPacket) { const uint16_t kSequenceNumber = 4711; const uint32_t kTimestamp = 47114711; const uint32_t kSsrc = 0x12345678; - MakeRtpHeader( - kPayloadType, kSequenceNumber, kTimestamp, kSsrc, packet_memory); + MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc, + packet_memory); const double kPacketTime = 1.0; // Hand over ownership of |packet_memory| to |packet|. Packet packet(packet_memory, kPacketLengthBytes, kPacketTime); @@ -75,13 +75,11 @@ TEST(TestPacket, DummyPacket) { const uint16_t kSequenceNumber = 4711; const uint32_t kTimestamp = 47114711; const uint32_t kSsrc = 0x12345678; - MakeRtpHeader( - kPayloadType, kSequenceNumber, kTimestamp, kSsrc, packet_memory); + MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc, + packet_memory); const double kPacketTime = 1.0; // Hand over ownership of |packet_memory| to |packet|. - Packet packet(packet_memory, - kPacketLengthBytes, - kVirtualPacketLengthBytes, + Packet packet(packet_memory, kPacketLengthBytes, kVirtualPacketLengthBytes, kPacketTime); ASSERT_TRUE(packet.valid_header()); EXPECT_EQ(kPayloadType, packet.header().payloadType); @@ -140,8 +138,8 @@ TEST(TestPacket, RED) { const uint16_t kSequenceNumber = 4711; const uint32_t kTimestamp = 47114711; const uint32_t kSsrc = 0x12345678; - MakeRtpHeader( - kRedPayloadType, kSequenceNumber, kTimestamp, kSsrc, packet_memory); + MakeRtpHeader(kRedPayloadType, kSequenceNumber, kTimestamp, kSsrc, + packet_memory); // Create four RED headers. // Payload types are just the same as the block index the offset is 100 times // the block index. @@ -154,8 +152,8 @@ TEST(TestPacket, RED) { uint32_t timestamp_offset = 100 * i; int block_length = 10 * i; bool last_block = (i == kRedBlocks - 1) ? true : false; - payload_ptr += MakeRedHeader( - payload_type, timestamp_offset, block_length, last_block, payload_ptr); + payload_ptr += MakeRedHeader(payload_type, timestamp_offset, block_length, + last_block, payload_ptr); } const double kPacketTime = 1.0; // Hand over ownership of |packet_memory| to |packet|. @@ -178,8 +176,7 @@ TEST(TestPacket, RED) { EXPECT_EQ(kRedBlocks, static_cast(red_headers.size())); int block_index = 0; for (std::list::reverse_iterator it = red_headers.rbegin(); - it != red_headers.rend(); - ++it) { + it != red_headers.rend(); ++it) { // Reading list from the back, since the extraction puts the main payload // (which is the last one on wire) first. RTPHeader* red_block = *it; diff --git a/modules/audio_coding/neteq/tools/rtp_analyze.cc b/modules/audio_coding/neteq/tools/rtp_analyze.cc index 12721ccc96..f9390381cd 100644 --- a/modules/audio_coding/neteq/tools/rtp_analyze.cc +++ b/modules/audio_coding/neteq/tools/rtp_analyze.cc @@ -20,10 +20,14 @@ // Define command line flags. DEFINE_int(red, 117, "RTP payload type for RED"); -DEFINE_int(audio_level, -1, "Extension ID for audio level (RFC 6464); " - "-1 not to print audio level"); -DEFINE_int(abs_send_time, -1, "Extension ID for absolute sender time; " - "-1 not to print absolute send time"); +DEFINE_int(audio_level, + -1, + "Extension ID for audio level (RFC 6464); " + "-1 not to print audio level"); +DEFINE_int(abs_send_time, + -1, + "Extension ID for absolute sender time; " + "-1 not to print absolute send time"); DEFINE_bool(help, false, "Print this message"); int main(int argc, char* argv[]) { @@ -37,8 +41,8 @@ int main(int argc, char* argv[]) { program_name + " input.rtp output.txt\n\n" + "Output is sent to stdout if no output file is given. " + "Note that this tool can read files with or without payloads.\n"; - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || (argc != 2 && argc != 3)) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + (argc != 2 && argc != 3)) { printf("%s", usage.c_str()); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); @@ -47,10 +51,11 @@ int main(int argc, char* argv[]) { return 1; } - RTC_CHECK(FLAG_red >= 0 && FLAG_red <= 127); // Payload type - RTC_CHECK(FLAG_audio_level == -1 || // Default - (FLAG_audio_level > 0 && FLAG_audio_level <= 255)); // Extension ID - RTC_CHECK(FLAG_abs_send_time == -1 || // Default + RTC_CHECK(FLAG_red >= 0 && FLAG_red <= 127); // Payload type + RTC_CHECK(FLAG_audio_level == -1 || // Default + (FLAG_audio_level > 0 && FLAG_audio_level <= 255)); // Extension ID + RTC_CHECK( + FLAG_abs_send_time == -1 || // Default (FLAG_abs_send_time > 0 && FLAG_abs_send_time <= 255)); // Extension ID printf("Input file: %s\n", argv[1]); @@ -104,19 +109,14 @@ int main(int argc, char* argv[]) { } // Write packet data to file. Use virtual_packet_length_bytes so that the // correct packet sizes are printed also for RTP header-only dumps. - fprintf(out_file, - "%5u %10u %10u %5i %5i %2i %#08X", - packet->header().sequenceNumber, - packet->header().timestamp, + fprintf(out_file, "%5u %10u %10u %5i %5i %2i %#08X", + packet->header().sequenceNumber, packet->header().timestamp, static_cast(packet->time_ms()), static_cast(packet->virtual_packet_length_bytes()), - packet->header().payloadType, - packet->header().markerBit, + packet->header().payloadType, packet->header().markerBit, packet->header().ssrc); if (print_audio_level && packet->header().extension.hasAudioLevel) { - fprintf(out_file, - " %5u (%1i)", - packet->header().extension.audioLevel, + fprintf(out_file, " %5u (%1i)", packet->header().extension.audioLevel, packet->header().extension.voiceActivity); } if (print_abs_send_time && packet->header().extension.hasAbsoluteSendTime) { @@ -156,11 +156,8 @@ int main(int argc, char* argv[]) { while (!red_headers.empty()) { webrtc::RTPHeader* red = red_headers.front(); assert(red); - fprintf(out_file, - "* %5u %10u %10u %5i\n", - red->sequenceNumber, - red->timestamp, - static_cast(packet->time_ms()), + fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber, + red->timestamp, static_cast(packet->time_ms()), red->payloadType); red_headers.pop_front(); delete red; diff --git a/modules/audio_coding/neteq/tools/rtp_encode.cc b/modules/audio_coding/neteq/tools/rtp_encode.cc index 66e7a285ad..1984e3f3d3 100644 --- a/modules/audio_coding/neteq/tools/rtp_encode.cc +++ b/modules/audio_coding/neteq/tools/rtp_encode.cc @@ -247,11 +247,16 @@ AudioEncoderCng::Config GetCngConfig(int sample_rate_hz) { AudioEncoderCng::Config cng_config; const auto default_payload_type = [&] { switch (sample_rate_hz) { - case 8000: return 13; - case 16000: return 98; - case 32000: return 99; - case 48000: return 100; - default: RTC_NOTREACHED(); + case 8000: + return 13; + case 16000: + return 98; + case 32000: + return 99; + case 48000: + return 100; + default: + RTC_NOTREACHED(); } return 0; }; diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.cc b/modules/audio_coding/neteq/tools/rtp_file_source.cc index 0945667407..806bba7a9f 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.cc +++ b/modules/audio_coding/neteq/tools/rtp_file_source.cc @@ -44,8 +44,7 @@ bool RtpFileSource::ValidPcap(const std::string& file_name) { return !!temp_file; } -RtpFileSource::~RtpFileSource() { -} +RtpFileSource::~RtpFileSource() {} bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id) { @@ -82,8 +81,7 @@ std::unique_ptr RtpFileSource::NextPacket() { } RtpFileSource::RtpFileSource() - : PacketSource(), - parser_(RtpHeaderParser::Create()) {} + : PacketSource(), parser_(RtpHeaderParser::Create()) {} bool RtpFileSource::OpenFile(const std::string& file_name) { rtp_reader_.reset(RtpFileReader::Create(RtpFileReader::kRtpDump, file_name)); diff --git a/modules/audio_coding/neteq/tools/rtp_generator.cc b/modules/audio_coding/neteq/tools/rtp_generator.cc index cedd7aeb9e..ab7acdce39 100644 --- a/modules/audio_coding/neteq/tools/rtp_generator.cc +++ b/modules/audio_coding/neteq/tools/rtp_generator.cc @@ -32,8 +32,8 @@ uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type, uint32_t this_send_time = next_send_time_ms_; assert(samples_per_ms_ > 0); - next_send_time_ms_ += ((1.0 + drift_factor_) * payload_length_samples) / - samples_per_ms_; + next_send_time_ms_ += + ((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_; return this_send_time; } @@ -46,8 +46,8 @@ void RtpGenerator::set_drift_factor(double factor) { uint32_t TimestampJumpRtpGenerator::GetRtpHeader(uint8_t payload_type, size_t payload_length_samples, RTPHeader* rtp_header) { - uint32_t ret = RtpGenerator::GetRtpHeader( - payload_type, payload_length_samples, rtp_header); + uint32_t ret = RtpGenerator::GetRtpHeader(payload_type, + payload_length_samples, rtp_header); if (timestamp_ - static_cast(payload_length_samples) <= jump_from_timestamp_ && timestamp_ > jump_from_timestamp_) { diff --git a/modules/audio_coding/neteq/tools/rtp_generator.h b/modules/audio_coding/neteq/tools/rtp_generator.h index 3b3cca939e..04fdbddb9e 100644 --- a/modules/audio_coding/neteq/tools/rtp_generator.h +++ b/modules/audio_coding/neteq/tools/rtp_generator.h @@ -32,8 +32,7 @@ class RtpGenerator { next_send_time_ms_(start_send_time_ms), ssrc_(ssrc), samples_per_ms_(samples_per_ms), - drift_factor_(0.0) { - } + drift_factor_(0.0) {} virtual ~RtpGenerator() {} diff --git a/modules/audio_coding/test/Channel.cc b/modules/audio_coding/test/Channel.cc index 7d5e6e291f..8fdb677f32 100644 --- a/modules/audio_coding/test/Channel.cc +++ b/modules/audio_coding/test/Channel.cc @@ -30,11 +30,15 @@ int32_t Channel::SendData(FrameType frameType, rtpInfo.header.markerBit = false; rtpInfo.header.ssrc = 0; - rtpInfo.header.sequenceNumber = (external_sequence_number_ < 0) ? - _seqNo++ : static_cast(external_sequence_number_); + rtpInfo.header.sequenceNumber = + (external_sequence_number_ < 0) + ? _seqNo++ + : static_cast(external_sequence_number_); rtpInfo.header.payloadType = payloadType; - rtpInfo.header.timestamp = (external_send_timestamp_ < 0) ? timeStamp : - static_cast(external_send_timestamp_); + rtpInfo.header.timestamp = + (external_send_timestamp_ < 0) + ? timeStamp + : static_cast(external_send_timestamp_); if (frameType == kAudioFrameCN) { rtpInfo.type.Audio.isCNG = true; @@ -57,7 +61,7 @@ int32_t Channel::SendData(FrameType frameType, // only 0x80 if we have multiple blocks _payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1]; size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) + - fragmentation->fragmentationLength[1]; + fragmentation->fragmentationLength[1]; _payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF); _payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF); _payloadData[3] = uint8_t(REDheader & 0x000000FF); @@ -96,7 +100,7 @@ int32_t Channel::SendData(FrameType frameType, _channelCritSect.Enter(); if (_saveBitStream) { - //fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile); + // fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile); } if (!_isStereo) { @@ -128,8 +132,8 @@ int32_t Channel::SendData(FrameType frameType, // TODO(turajs): rewite this method. void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { int n; - if ((rtpInfo.header.payloadType != _lastPayloadType) - && (_lastPayloadType != -1)) { + if ((rtpInfo.header.payloadType != _lastPayloadType) && + (_lastPayloadType != -1)) { // payload-type is changed. // we have to terminate the calculations on the previous payload type // we ignore the last packet in that payload type just to make things @@ -156,14 +160,15 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { if (!newPayload) { if (!currentPayloadStr->newPacket) { if (!_useLastFrameSize) { - _lastFrameSizeSample = (uint32_t) ((uint32_t) rtpInfo.header.timestamp - - (uint32_t) currentPayloadStr->lastTimestamp); + _lastFrameSizeSample = + (uint32_t)((uint32_t)rtpInfo.header.timestamp - + (uint32_t)currentPayloadStr->lastTimestamp); } assert(_lastFrameSizeSample > 0); int k = 0; for (; k < MAX_NUM_FRAMESIZES; ++k) { if ((currentPayloadStr->frameSizeStats[k].frameSizeSample == - _lastFrameSizeSample) || + _lastFrameSizeSample) || (currentPayloadStr->frameSizeStats[k].frameSizeSample == 0)) { break; } @@ -174,9 +179,9 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { _lastPayloadType, _lastFrameSizeSample); return; } - ACMTestFrameSizeStats* currentFrameSizeStats = &(currentPayloadStr - ->frameSizeStats[k]); - currentFrameSizeStats->frameSizeSample = (int16_t) _lastFrameSizeSample; + ACMTestFrameSizeStats* currentFrameSizeStats = + &(currentPayloadStr->frameSizeStats[k]); + currentFrameSizeStats->frameSizeSample = (int16_t)_lastFrameSizeSample; // increment the number of encoded samples. currentFrameSizeStats->totalEncodedSamples += _lastFrameSizeSample; @@ -185,15 +190,15 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { // increment the total number of bytes (this is based on // the previous payload we don't know the frame-size of // the current payload. - currentFrameSizeStats->totalPayloadLenByte += currentPayloadStr - ->lastPayloadLenByte; + currentFrameSizeStats->totalPayloadLenByte += + currentPayloadStr->lastPayloadLenByte; // store the maximum payload-size (this is based on // the previous payload we don't know the frame-size of // the current payload. - if (currentFrameSizeStats->maxPayloadLen - < currentPayloadStr->lastPayloadLenByte) { - currentFrameSizeStats->maxPayloadLen = currentPayloadStr - ->lastPayloadLenByte; + if (currentFrameSizeStats->maxPayloadLen < + currentPayloadStr->lastPayloadLenByte) { + currentFrameSizeStats->maxPayloadLen = + currentPayloadStr->lastPayloadLenByte; } // store the current values for the next time currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp; @@ -203,8 +208,8 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { currentPayloadStr->lastPayloadLenByte = payloadSize; currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp; currentPayloadStr->payloadType = rtpInfo.header.payloadType; - memset(currentPayloadStr->frameSizeStats, 0, MAX_NUM_FRAMESIZES * - sizeof(ACMTestFrameSizeStats)); + memset(currentPayloadStr->frameSizeStats, 0, + MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats)); } } else { n = 0; @@ -216,8 +221,8 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { _payloadStats[n].lastPayloadLenByte = payloadSize; _payloadStats[n].lastTimestamp = rtpInfo.header.timestamp; _payloadStats[n].payloadType = rtpInfo.header.payloadType; - memset(_payloadStats[n].frameSizeStats, 0, MAX_NUM_FRAMESIZES * - sizeof(ACMTestFrameSizeStats)); + memset(_payloadStats[n].frameSizeStats, 0, + MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats)); } } @@ -262,8 +267,7 @@ Channel::Channel(int16_t chID) } } -Channel::~Channel() { -} +Channel::~Channel() {} void Channel::RegisterReceiverACM(AudioCodingModule* acm) { _receiverACM = acm; @@ -311,13 +315,13 @@ int16_t Channel::Stats(CodecInst& codecInst, _channelCritSect.Leave(); return 0; } - payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats - .frameSizeStats[n].totalEncodedSamples / (double) codecInst.plfreq; + payloadStats.frameSizeStats[n].usageLenSec = + (double)payloadStats.frameSizeStats[n].totalEncodedSamples / + (double)codecInst.plfreq; payloadStats.frameSizeStats[n].rateBitPerSec = - payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 - / payloadStats.frameSizeStats[n].usageLenSec; - + payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 / + payloadStats.frameSizeStats[n].usageLenSec; } _channelCritSect.Leave(); return 0; @@ -353,14 +357,14 @@ void Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte) { if (_payloadStats[k].payloadType == -1) { break; } - payloadType[k] = (uint8_t) _payloadStats[k].payloadType; + payloadType[k] = (uint8_t)_payloadStats[k].payloadType; payloadLenByte[k] = 0; for (n = 0; n < MAX_NUM_FRAMESIZES; n++) { if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) { break; } - payloadLenByte[k] += (uint16_t) _payloadStats[k].frameSizeStats[n] - .totalPayloadLenByte; + payloadLenByte[k] += + (uint16_t)_payloadStats[k].frameSizeStats[n].totalPayloadLenByte; } } @@ -387,18 +391,15 @@ void Channel::PrintStats(CodecInst& codecInst) { payloadStats.frameSizeStats[k].rateBitPerSec); printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n", payloadStats.frameSizeStats[k].maxPayloadLen); - printf( - "Maximum Instantaneous Rate.... %.0f bits/sec\n", - ((double) payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 - * (double) codecInst.plfreq) - / (double) payloadStats.frameSizeStats[k].frameSizeSample); + printf("Maximum Instantaneous Rate.... %.0f bits/sec\n", + ((double)payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 * + (double)codecInst.plfreq) / + (double)payloadStats.frameSizeStats[k].frameSizeSample); printf("Number of Packets............. %u\n", - (unsigned int) payloadStats.frameSizeStats[k].numPackets); + (unsigned int)payloadStats.frameSizeStats[k].numPackets); printf("Duration...................... %0.3f sec\n\n", payloadStats.frameSizeStats[k].usageLenSec); - } - } uint32_t Channel::LastInTimestamp() { @@ -413,7 +414,7 @@ double Channel::BitRate() { double rate; uint64_t currTime = rtc::TimeMillis(); _channelCritSect.Enter(); - rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime); + rate = ((double)_totalBytes * 8.0) / (double)(currTime - _beginTime); _channelCritSect.Leave(); return rate; } diff --git a/modules/audio_coding/test/Channel.h b/modules/audio_coding/test/Channel.h index e01e33e43b..e5f5b546fd 100644 --- a/modules/audio_coding/test/Channel.h +++ b/modules/audio_coding/test/Channel.h @@ -20,8 +20,8 @@ namespace webrtc { -#define MAX_NUM_PAYLOADS 50 -#define MAX_NUM_FRAMESIZES 6 +#define MAX_NUM_PAYLOADS 50 +#define MAX_NUM_FRAMESIZES 6 // TODO(turajs): Write constructor for this structure. struct ACMTestFrameSizeStats { @@ -45,7 +45,6 @@ struct ACMTestPayloadStats { class Channel : public AudioPacketizationCallback { public: - Channel(int16_t chID = -1); ~Channel() override; @@ -56,7 +55,7 @@ class Channel : public AudioPacketizationCallback { size_t payloadSize, const RTPFragmentationHeader* fragmentation) override; - void RegisterReceiverACM(AudioCodingModule *acm); + void RegisterReceiverACM(AudioCodingModule* acm); void ResetStats(); @@ -68,9 +67,7 @@ class Channel : public AudioPacketizationCallback { void PrintStats(CodecInst& codecInst); - void SetIsStereo(bool isStereo) { - _isStereo = isStereo; - } + void SetIsStereo(bool isStereo) { _isStereo = isStereo; } uint32_t LastInTimestamp(); diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc index 0bf4de5394..4e16dc8989 100644 --- a/modules/audio_coding/test/EncodeDecodeTest.cc +++ b/modules/audio_coding/test/EncodeDecodeTest.cc @@ -10,10 +10,10 @@ #include "modules/audio_coding/test/EncodeDecodeTest.h" -#include -#include #include #include +#include +#include // no-presubmit-check TODO(webrtc:8982) #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "common_types.h" // NOLINT(build/include) diff --git a/modules/audio_coding/test/PCMFile.cc b/modules/audio_coding/test/PCMFile.cc index 2b2f1f08c8..659f9688c7 100644 --- a/modules/audio_coding/test/PCMFile.cc +++ b/modules/audio_coding/test/PCMFile.cc @@ -30,8 +30,8 @@ PCMFile::PCMFile() rewinded_(false), read_stereo_(false), save_stereo_(false) { - timestamp_ = (((uint32_t) rand() & 0x0000FFFF) << 16) | - ((uint32_t) rand() & 0x0000FFFF); + timestamp_ = + (((uint32_t)rand() & 0x0000FFFF) << 16) | ((uint32_t)rand() & 0x0000FFFF); } PCMFile::PCMFile(uint32_t timestamp) @@ -52,7 +52,8 @@ PCMFile::~PCMFile() { } } -int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len, +int16_t PCMFile::ChooseFile(std::string* file_name, + int16_t max_len, uint16_t* frequency_hz) { char tmp_name[MAX_FILE_NAME_LENGTH_BYTE]; @@ -61,8 +62,8 @@ int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len, int16_t n = 0; // Removing trailing spaces. - while ((isspace(tmp_name[n]) || iscntrl(tmp_name[n])) && (tmp_name[n] != 0) - && (n < MAX_FILE_NAME_LENGTH_BYTE)) { + while ((isspace(tmp_name[n]) || iscntrl(tmp_name[n])) && (tmp_name[n] != 0) && + (n < MAX_FILE_NAME_LENGTH_BYTE)) { n++; } if (n > 0) { @@ -80,7 +81,7 @@ int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len, tmp_name[n + 1] = '\0'; } - int16_t len = (int16_t) strlen(tmp_name); + int16_t len = (int16_t)strlen(tmp_name); if (len > max_len) { return -1; } @@ -91,15 +92,17 @@ int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len, printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequency_hz); EXPECT_TRUE(fgets(tmp_name, 10, stdin) != NULL); - uint16_t tmp_frequency = (uint16_t) atoi(tmp_name); + uint16_t tmp_frequency = (uint16_t)atoi(tmp_name); if (tmp_frequency > 0) { *frequency_hz = tmp_frequency; } return 0; } -void PCMFile::Open(const std::string& file_name, uint16_t frequency, - const char* mode, bool auto_rewind) { +void PCMFile::Open(const std::string& file_name, + uint16_t frequency, + const char* mode, + bool auto_rewind) { if ((pcm_file_ = fopen(file_name.c_str(), mode)) == NULL) { printf("Cannot open file %s.\n", file_name.c_str()); ADD_FAILURE() << "Unable to read file"; @@ -125,9 +128,9 @@ int32_t PCMFile::Read10MsData(AudioFrame& audio_frame) { channels = 2; } - int32_t payload_size = (int32_t) fread(audio_frame.mutable_data(), - sizeof(uint16_t), - samples_10ms_ * channels, pcm_file_); + int32_t payload_size = + (int32_t)fread(audio_frame.mutable_data(), sizeof(uint16_t), + samples_10ms_ * channels, pcm_file_); if (payload_size < samples_10ms_ * channels) { int16_t* frame_data = audio_frame.mutable_data(); for (int k = payload_size; k < samples_10ms_ * channels; k++) { diff --git a/modules/audio_coding/test/PCMFile.h b/modules/audio_coding/test/PCMFile.h index 05b9828c2f..dc7a4fc45e 100644 --- a/modules/audio_coding/test/PCMFile.h +++ b/modules/audio_coding/test/PCMFile.h @@ -28,26 +28,27 @@ class PCMFile { PCMFile(uint32_t timestamp); ~PCMFile(); - void Open(const std::string& filename, uint16_t frequency, const char* mode, + void Open(const std::string& filename, + uint16_t frequency, + const char* mode, bool auto_rewind = false); int32_t Read10MsData(AudioFrame& audio_frame); - void Write10MsData(const int16_t *playout_buffer, size_t length_smpls); + void Write10MsData(const int16_t* playout_buffer, size_t length_smpls); void Write10MsData(const AudioFrame& audio_frame); uint16_t PayloadLength10Ms() const; int32_t SamplingFrequency() const; void Close(); - bool EndOfFile() const { - return end_of_file_; - } + bool EndOfFile() const { return end_of_file_; } // Moves forward the specified number of 10 ms blocks. If a limit has been set // with SetNum10MsBlocksToRead, fast-forwarding does not count towards this // limit. void FastForward(int num_10ms_blocks); void Rewind(); - static int16_t ChooseFile(std::string* file_name, int16_t max_len, + static int16_t ChooseFile(std::string* file_name, + int16_t max_len, uint16_t* frequency_hz); bool Rewinded(); void SaveStereo(bool is_stereo = true); diff --git a/modules/audio_coding/test/PacketLossTest.cc b/modules/audio_coding/test/PacketLossTest.cc index d5fbfd1207..c5cb3963b3 100644 --- a/modules/audio_coding/test/PacketLossTest.cc +++ b/modules/audio_coding/test/PacketLossTest.cc @@ -23,11 +23,10 @@ ReceiverWithPacketLoss::ReceiverWithPacketLoss() burst_length_(1), packet_counter_(0), lost_packet_counter_(0), - burst_lost_counter_(burst_length_) { -} + burst_lost_counter_(burst_length_) {} -void ReceiverWithPacketLoss::Setup(AudioCodingModule *acm, - RTPStream *rtpStream, +void ReceiverWithPacketLoss::Setup(AudioCodingModule* acm, + RTPStream* rtpStream, std::string out_file_name, int channels, int loss_rate, @@ -84,13 +83,14 @@ bool ReceiverWithPacketLoss::PacketLost() { return false; } -SenderWithFEC::SenderWithFEC() - : expected_loss_rate_(0) { -} +SenderWithFEC::SenderWithFEC() : expected_loss_rate_(0) {} -void SenderWithFEC::Setup(AudioCodingModule *acm, RTPStream *rtpStream, - std::string in_file_name, int sample_rate, - int channels, int expected_loss_rate) { +void SenderWithFEC::Setup(AudioCodingModule* acm, + RTPStream* rtpStream, + std::string in_file_name, + int sample_rate, + int channels, + int expected_loss_rate) { Sender::Setup(acm, rtpStream, in_file_name, sample_rate, channels); EXPECT_TRUE(SetFEC(true)); EXPECT_TRUE(SetPacketLossRate(expected_loss_rate)); @@ -111,18 +111,19 @@ bool SenderWithFEC::SetPacketLossRate(int expected_loss_rate) { return false; } -PacketLossTest::PacketLossTest(int channels, int expected_loss_rate, - int actual_loss_rate, int burst_length) +PacketLossTest::PacketLossTest(int channels, + int expected_loss_rate, + int actual_loss_rate, + int burst_length) : channels_(channels), - in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" : - "audio_coding/teststereo32kHz"), + in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" + : "audio_coding/teststereo32kHz"), sample_rate_hz_(32000), sender_(new SenderWithFEC), receiver_(new ReceiverWithPacketLoss), expected_loss_rate_(expected_loss_rate), actual_loss_rate_(actual_loss_rate), - burst_length_(burst_length) { -} + burst_length_(burst_length) {} void PacketLossTest::Perform() { #ifndef WEBRTC_CODEC_OPUS diff --git a/modules/audio_coding/test/PacketLossTest.h b/modules/audio_coding/test/PacketLossTest.h index 7eab442b59..f6f92db1ad 100644 --- a/modules/audio_coding/test/PacketLossTest.h +++ b/modules/audio_coding/test/PacketLossTest.h @@ -20,8 +20,11 @@ namespace webrtc { class ReceiverWithPacketLoss : public Receiver { public: ReceiverWithPacketLoss(); - void Setup(AudioCodingModule *acm, RTPStream *rtpStream, - std::string out_file_name, int channels, int loss_rate, + void Setup(AudioCodingModule* acm, + RTPStream* rtpStream, + std::string out_file_name, + int channels, + int loss_rate, int burst_length); bool IncomingPacket() override; @@ -37,20 +40,27 @@ class ReceiverWithPacketLoss : public Receiver { class SenderWithFEC : public Sender { public: SenderWithFEC(); - void Setup(AudioCodingModule *acm, RTPStream *rtpStream, - std::string in_file_name, int sample_rate, int channels, + void Setup(AudioCodingModule* acm, + RTPStream* rtpStream, + std::string in_file_name, + int sample_rate, + int channels, int expected_loss_rate); bool SetPacketLossRate(int expected_loss_rate); bool SetFEC(bool enable_fec); + protected: int expected_loss_rate_; }; class PacketLossTest : public ACMTest { public: - PacketLossTest(int channels, int expected_loss_rate_, int actual_loss_rate, + PacketLossTest(int channels, + int expected_loss_rate_, + int actual_loss_rate, int burst_length); void Perform(); + protected: int channels_; std::string in_file_name_; diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc index 8cc5bd9f99..a1329e77bc 100644 --- a/modules/audio_coding/test/RTPFile.cc +++ b/modules/audio_coding/test/RTPFile.cc @@ -14,9 +14,9 @@ #include #ifdef WIN32 -# include +#include #else -# include +#include #endif #include "modules/include/module_common_types.h" @@ -29,18 +29,22 @@ namespace webrtc { void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader) { rtpInfo->header.payloadType = rtpHeader[1]; - rtpInfo->header.sequenceNumber = (static_cast(rtpHeader[2]) << 8) | - rtpHeader[3]; + rtpInfo->header.sequenceNumber = + (static_cast(rtpHeader[2]) << 8) | rtpHeader[3]; rtpInfo->header.timestamp = (static_cast(rtpHeader[4]) << 24) | - (static_cast(rtpHeader[5]) << 16) | - (static_cast(rtpHeader[6]) << 8) | rtpHeader[7]; + (static_cast(rtpHeader[5]) << 16) | + (static_cast(rtpHeader[6]) << 8) | + rtpHeader[7]; rtpInfo->header.ssrc = (static_cast(rtpHeader[8]) << 24) | - (static_cast(rtpHeader[9]) << 16) | - (static_cast(rtpHeader[10]) << 8) | rtpHeader[11]; + (static_cast(rtpHeader[9]) << 16) | + (static_cast(rtpHeader[10]) << 8) | + rtpHeader[11]; } -void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, - int16_t seqNo, uint32_t timeStamp, +void RTPStream::MakeRTPheader(uint8_t* rtpHeader, + uint8_t payloadType, + int16_t seqNo, + uint32_t timeStamp, uint32_t ssrc) { rtpHeader[0] = 0x80; rtpHeader[1] = payloadType; @@ -56,8 +60,11 @@ void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, rtpHeader[11] = ssrc & 0xFF; } -RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo, - const uint8_t* payloadData, size_t payloadSize, +RTPPacket::RTPPacket(uint8_t payloadType, + uint32_t timeStamp, + int16_t seqNo, + const uint8_t* payloadData, + size_t payloadSize, uint32_t frequency) : payloadType(payloadType), timeStamp(timeStamp), @@ -82,20 +89,25 @@ RTPBuffer::~RTPBuffer() { delete _queueRWLock; } -void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp, - const int16_t seqNo, const uint8_t* payloadData, - const size_t payloadSize, uint32_t frequency) { - RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData, +void RTPBuffer::Write(const uint8_t payloadType, + const uint32_t timeStamp, + const int16_t seqNo, + const uint8_t* payloadData, + const size_t payloadSize, + uint32_t frequency) { + RTPPacket* packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData, payloadSize, frequency); _queueRWLock->AcquireLockExclusive(); _rtpQueue.push(packet); _queueRWLock->ReleaseLockExclusive(); } -size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - size_t payloadSize, uint32_t* offset) { +size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, + uint8_t* payloadData, + size_t payloadSize, + uint32_t* offset) { _queueRWLock->AcquireLockShared(); - RTPPacket *packet = _rtpQueue.front(); + RTPPacket* packet = _rtpQueue.front(); _rtpQueue.pop(); _queueRWLock->ReleaseLockShared(); rtpInfo->header.markerBit = 1; @@ -120,7 +132,7 @@ bool RTPBuffer::EndOfFile() const { return eof; } -void RTPFile::Open(const char *filename, const char *mode) { +void RTPFile::Open(const char* filename, const char* mode) { if ((_rtpFile = fopen(filename, mode)) == NULL) { printf("Cannot write file %s.\n", filename); ADD_FAILURE() << "Unable to write file"; @@ -165,9 +177,12 @@ void RTPFile::ReadHeader() { padding = ntohs(padding); } -void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp, - const int16_t seqNo, const uint8_t* payloadData, - const size_t payloadSize, uint32_t frequency) { +void RTPFile::Write(const uint8_t payloadType, + const uint32_t timeStamp, + const int16_t seqNo, + const uint8_t* payloadData, + const size_t payloadSize, + uint32_t frequency) { /* write RTP packet to file */ uint8_t rtpHeader[12]; MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0); @@ -185,8 +200,10 @@ void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp, EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile)); } -size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - size_t payloadSize, uint32_t* offset) { +size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, + uint8_t* payloadData, + size_t payloadSize, + uint32_t* offset) { uint16_t lengthBytes; uint16_t plen; uint8_t rtpHeader[12]; diff --git a/modules/audio_coding/test/RTPFile.h b/modules/audio_coding/test/RTPFile.h index b9afe2f1c4..73e97dd526 100644 --- a/modules/audio_coding/test/RTPFile.h +++ b/modules/audio_coding/test/RTPFile.h @@ -22,30 +22,40 @@ namespace webrtc { class RTPStream { public: - virtual ~RTPStream() { - } + virtual ~RTPStream() {} - virtual void Write(const uint8_t payloadType, const uint32_t timeStamp, - const int16_t seqNo, const uint8_t* payloadData, - const size_t payloadSize, uint32_t frequency) = 0; + virtual void Write(const uint8_t payloadType, + const uint32_t timeStamp, + const int16_t seqNo, + const uint8_t* payloadData, + const size_t payloadSize, + uint32_t frequency) = 0; // Returns the packet's payload size. Zero should be treated as an // end-of-stream (in the case that EndOfFile() is true) or an error. - virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - size_t payloadSize, uint32_t* offset) = 0; + virtual size_t Read(WebRtcRTPHeader* rtpInfo, + uint8_t* payloadData, + size_t payloadSize, + uint32_t* offset) = 0; virtual bool EndOfFile() const = 0; protected: - void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, int16_t seqNo, - uint32_t timeStamp, uint32_t ssrc); + void MakeRTPheader(uint8_t* rtpHeader, + uint8_t payloadType, + int16_t seqNo, + uint32_t timeStamp, + uint32_t ssrc); void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader); }; class RTPPacket { public: - RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo, - const uint8_t* payloadData, size_t payloadSize, + RTPPacket(uint8_t payloadType, + uint32_t timeStamp, + int16_t seqNo, + const uint8_t* payloadData, + size_t payloadSize, uint32_t frequency); ~RTPPacket(); @@ -80,20 +90,16 @@ class RTPBuffer : public RTPStream { private: RWLockWrapper* _queueRWLock; - std::queue _rtpQueue; + std::queue _rtpQueue; }; class RTPFile : public RTPStream { public: - ~RTPFile() { - } + ~RTPFile() {} - RTPFile() - : _rtpFile(NULL), - _rtpEOF(false) { - } + RTPFile() : _rtpFile(NULL), _rtpEOF(false) {} - void Open(const char *outFilename, const char *mode); + void Open(const char* outFilename, const char* mode); void Close(); diff --git a/modules/audio_coding/test/TestAllCodecs.cc b/modules/audio_coding/test/TestAllCodecs.cc index f8debe9ec1..df9c731742 100644 --- a/modules/audio_coding/test/TestAllCodecs.cc +++ b/modules/audio_coding/test/TestAllCodecs.cc @@ -46,19 +46,19 @@ TestPack::TestPack() timestamp_diff_(0), last_in_timestamp_(0), total_bytes_(0), - payload_size_(0) { -} + payload_size_(0) {} -TestPack::~TestPack() { -} +TestPack::~TestPack() {} void TestPack::RegisterReceiverACM(AudioCodingModule* acm) { receiver_acm_ = acm; return; } -int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, - uint32_t timestamp, const uint8_t* payload_data, +int32_t TestPack::SendData(FrameType frame_type, + uint8_t payload_type, + uint32_t timestamp, + const uint8_t* payload_data, size_t payload_size, const RTPFragmentationHeader* fragmentation) { WebRtcRTPHeader rtp_info; @@ -125,8 +125,8 @@ TestAllCodecs::~TestAllCodecs() { } void TestAllCodecs::Perform() { - const std::string file_name = webrtc::test::ResourcePath( - "audio_coding/testfile32kHz", "pcm"); + const std::string file_name = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); infile_a_.Open(file_name, 32000, "rb"); if (test_mode_ == 0) { @@ -306,17 +306,17 @@ void TestAllCodecs::Perform() { char codec_opus[] = "OPUS"; RegisterSendCodec('A', codec_opus, 48000, 6000, 480, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, kVariableSize); + RegisterSendCodec('A', codec_opus, 48000, 20000, 480 * 2, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, kVariableSize); + RegisterSendCodec('A', codec_opus, 48000, 32000, 480 * 4, kVariableSize); Run(channel_a_to_b_); RegisterSendCodec('A', codec_opus, 48000, 48000, 480, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, kVariableSize); + RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 4, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, kVariableSize); + RegisterSendCodec('A', codec_opus, 48000, 96000, 480 * 6, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, kVariableSize); + RegisterSendCodec('A', codec_opus, 48000, 500000, 480 * 2, kVariableSize); Run(channel_a_to_b_); outfile_b_.Close(); #endif @@ -351,9 +351,12 @@ void TestAllCodecs::Perform() { // used when registering, can be an internal header // set to kVariableSize if the codec is a variable // rate codec -void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, - int32_t sampling_freq_hz, int rate, - int packet_size, size_t extra_byte) { +void TestAllCodecs::RegisterSendCodec(char side, + char* codec_name, + int32_t sampling_freq_hz, + int rate, + int packet_size, + size_t extra_byte) { if (test_mode_ != 0) { // Print out codec and settings. printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name, @@ -377,9 +380,11 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, // packet. If variable rate codec (extra_byte == -1), set to -1. if (extra_byte != kVariableSize) { // Add 0.875 to always round up to a whole byte - packet_size_bytes_ = static_cast( - static_cast(packet_size * rate) / - static_cast(sampling_freq_hz * 8) + 0.875) + extra_byte; + packet_size_bytes_ = + static_cast(static_cast(packet_size * rate) / + static_cast(sampling_freq_hz * 8) + + 0.875) + + extra_byte; } else { // Packets will have a variable size. packet_size_bytes_ = kVariableSize; @@ -396,9 +401,7 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, my_acm = acm_b_.get(); break; } - default: { - break; - } + default: { break; } } ASSERT_TRUE(my_acm != NULL); diff --git a/modules/audio_coding/test/TestAllCodecs.h b/modules/audio_coding/test/TestAllCodecs.h index e0285e95e0..36269a9d9e 100644 --- a/modules/audio_coding/test/TestAllCodecs.h +++ b/modules/audio_coding/test/TestAllCodecs.h @@ -60,8 +60,12 @@ class TestAllCodecs : public ACMTest { // codec name, and a sampling frequency matching is not required. // This is useful for codecs which support several sampling frequency. // Note! Only mono mode is tested in this test. - void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz, - int rate, int packet_size, size_t extra_byte); + void RegisterSendCodec(char side, + char* codec_name, + int32_t sampling_freq_hz, + int rate, + int packet_size, + size_t extra_byte); void Run(TestPack* channel); void OpenOutFile(int test_number); diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h index 98aa0080ec..1d9dead0bc 100644 --- a/modules/audio_coding/test/TestRedFec.h +++ b/modules/audio_coding/test/TestRedFec.h @@ -26,11 +26,13 @@ class TestRedFec : public ACMTest { ~TestRedFec(); void Perform(); + private: // The default value of '-1' indicates that the registration is based only on // codec name and a sampling frequency matching is not required. This is // useful for codecs which support several sampling frequency. - int16_t RegisterSendCodec(char side, const char* codecName, + int16_t RegisterSendCodec(char side, + const char* codecName, int32_t sampFreqHz = -1); void Run(); void OpenOutFile(int16_t testNumber); diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc index 2002068d66..2704d3d892 100644 --- a/modules/audio_coding/test/TestStereo.cc +++ b/modules/audio_coding/test/TestStereo.cc @@ -34,11 +34,9 @@ TestPackStereo::TestPackStereo() total_bytes_(0), payload_size_(0), codec_mode_(kNotSet), - lost_packet_(false) { -} + lost_packet_(false) {} -TestPackStereo::~TestPackStereo() { -} +TestPackStereo::~TestPackStereo() {} void TestPackStereo::RegisterReceiverACM(AudioCodingModule* acm) { receiver_acm_ = acm; @@ -72,8 +70,8 @@ int32_t TestPackStereo::SendData(const FrameType frame_type, rtp_info.type.Audio.isCNG = true; rtp_info.type.Audio.channel = static_cast(kMono); } - status = receiver_acm_->IncomingPacket(payload_data, payload_size, - rtp_info); + status = + receiver_acm_->IncomingPacket(payload_data, payload_size, rtp_info); if (frame_type != kAudioFrameCN) { payload_size_ = static_cast(payload_size); @@ -152,10 +150,10 @@ void TestStereo::Perform() { ACMVADMode vad_mode; // Open both mono and stereo test files in 32 kHz. - const std::string file_name_stereo = webrtc::test::ResourcePath( - "audio_coding/teststereo32kHz", "pcm"); - const std::string file_name_mono = webrtc::test::ResourcePath( - "audio_coding/testfile32kHz", "pcm"); + const std::string file_name_stereo = + webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"); + const std::string file_name_mono = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); frequency_hz = 32000; in_file_stereo_ = new PCMFile(); in_file_mono_ = new PCMFile(); @@ -230,22 +228,22 @@ void TestStereo::Perform() { OpenOutFile(test_cntr_); char codec_g722[] = "G722"; RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_g722, 16000, 64000, 320, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_g722, 16000, 64000, 480, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_g722, 16000, 64000, 640, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_g722, 16000, 64000, 800, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_g722, 16000, 64000, 960, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); @@ -259,16 +257,16 @@ void TestStereo::Perform() { OpenOutFile(test_cntr_); char codec_l16[] = "L16"; RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels, - l16_8khz_pltype_); + l16_8khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 8000, 128000, 160, codec_channels, - l16_8khz_pltype_); + l16_8khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 8000, 128000, 240, codec_channels, - l16_8khz_pltype_); + l16_8khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 8000, 128000, 320, codec_channels, - l16_8khz_pltype_); + l16_8khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); @@ -280,16 +278,16 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels, - l16_16khz_pltype_); + l16_16khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 16000, 256000, 320, codec_channels, - l16_16khz_pltype_); + l16_16khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 16000, 256000, 480, codec_channels, - l16_16khz_pltype_); + l16_16khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 16000, 256000, 640, codec_channels, - l16_16khz_pltype_); + l16_16khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); @@ -301,10 +299,10 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels, - l16_32khz_pltype_); + l16_32khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_l16, 32000, 512000, 640, codec_channels, - l16_32khz_pltype_); + l16_32khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); #ifdef PCMA_AND_PCMU @@ -392,26 +390,26 @@ void TestStereo::Perform() { char codec_opus[] = "opus"; // Run Opus with 10 ms frame size. RegisterSendCodec('A', codec_opus, 48000, 64000, 480, codec_channels, - opus_pltype_); + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); // Run Opus with 20 ms frame size. - RegisterSendCodec('A', codec_opus, 48000, 64000, 480*2, codec_channels, - opus_pltype_); + RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 2, codec_channels, + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); // Run Opus with 40 ms frame size. - RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, codec_channels, - opus_pltype_); + RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 4, codec_channels, + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); // Run Opus with 60 ms frame size. - RegisterSendCodec('A', codec_opus, 48000, 64000, 480*6, codec_channels, - opus_pltype_); + RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 6, codec_channels, + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); // Run Opus with 20 ms frame size and different bitrates. RegisterSendCodec('A', codec_opus, 48000, 40000, 960, codec_channels, - opus_pltype_); + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); RegisterSendCodec('A', codec_opus, 48000, 510000, 960, codec_channels, - opus_pltype_); + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); #endif @@ -430,7 +428,7 @@ void TestStereo::Perform() { channel_a2b_->set_codec_mode(kStereo); OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, - g722_pltype_); + g722_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); @@ -443,7 +441,7 @@ void TestStereo::Perform() { channel_a2b_->set_codec_mode(kStereo); OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels, - l16_8khz_pltype_); + l16_8khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); if (test_mode_ != 0) { @@ -454,7 +452,7 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels, - l16_16khz_pltype_); + l16_16khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); if (test_mode_ != 0) { @@ -465,7 +463,7 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels, - l16_32khz_pltype_); + l16_32khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); #ifdef PCMA_AND_PCMU @@ -497,7 +495,7 @@ void TestStereo::Perform() { channel_a2b_->set_codec_mode(kStereo); OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_opus, 48000, 64000, 960, codec_channels, - opus_pltype_); + opus_pltype_); Run(channel_a2b_, audio_channels, codec_channels); // Encode in mono, decode in stereo mode. @@ -522,7 +520,7 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, - g722_pltype_); + g722_pltype_); // Make sure it is possible to set VAD/CNG, now that we are sending mono // again. @@ -542,7 +540,7 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels, - l16_8khz_pltype_); + l16_8khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); if (test_mode_ != 0) { @@ -553,7 +551,7 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels, - l16_16khz_pltype_); + l16_16khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); if (test_mode_ != 0) { @@ -564,7 +562,7 @@ void TestStereo::Perform() { test_cntr_++; OpenOutFile(test_cntr_); RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels, - l16_32khz_pltype_); + l16_32khz_pltype_); Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); #ifdef PCMA_AND_PCMU @@ -593,7 +591,7 @@ void TestStereo::Perform() { OpenOutFile(test_cntr_); // Encode and decode in mono. RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels, - opus_pltype_); + opus_pltype_); CodecInst opus_codec_param; for (uint8_t n = 0; n < num_encoders; n++) { EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param)); @@ -620,8 +618,10 @@ void TestStereo::Perform() { OpenOutFile(test_cntr_); if (test_mode_ != 0) { // Print out codec and settings - printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" - " Decode: mono\n", test_cntr_); + printf( + "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" + " Decode: mono\n", + test_cntr_); } Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); @@ -630,8 +630,10 @@ void TestStereo::Perform() { OpenOutFile(test_cntr_); if (test_mode_ != 0) { // Print out codec and settings - printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" - " Decode: stereo\n", test_cntr_); + printf( + "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" + " Decode: stereo\n", + test_cntr_); } opus_codec_param.channels = 2; EXPECT_EQ(true, @@ -644,8 +646,10 @@ void TestStereo::Perform() { OpenOutFile(test_cntr_); if (test_mode_ != 0) { // Print out codec and settings - printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" - " Decode: mono\n", test_cntr_); + printf( + "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" + " Decode: mono\n", + test_cntr_); } opus_codec_param.channels = 1; EXPECT_EQ(true, @@ -665,9 +669,10 @@ void TestStereo::Perform() { #ifdef WEBRTC_CODEC_OPUS printf(" Opus\n"); #endif - printf("\nTo complete the test, listen to the %d number of output " - "files.\n", - test_cntr_); + printf( + "\nTo complete the test, listen to the %d number of output " + "files.\n", + test_cntr_); } // Delete the file pointers. @@ -684,9 +689,12 @@ void TestStereo::Perform() { // pack_size - packet size in samples // channels - number of channels; 1 for mono, 2 for stereo // payload_type - payload type for the codec -void TestStereo::RegisterSendCodec(char side, char* codec_name, - int32_t sampling_freq_hz, int rate, - int pack_size, int channels, +void TestStereo::RegisterSendCodec(char side, + char* codec_name, + int32_t sampling_freq_hz, + int rate, + int pack_size, + int channels, int payload_type) { if (test_mode_ != 0) { // Print out codec and settings @@ -722,7 +730,8 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name, CodecInst my_codec_param; // Get all codec parameters before registering EXPECT_GT(AudioCodingModule::Codec(codec_name, &my_codec_param, - sampling_freq_hz, channels), -1); + sampling_freq_hz, channels), + -1); my_codec_param.rate = rate; my_codec_param.pacsize = pack_size; EXPECT_EQ(0, my_acm->RegisterSendCodec(my_codec_param)); @@ -730,7 +739,9 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name, send_codec_name_ = codec_name; } -void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels, +void TestStereo::Run(TestPackStereo* channel, + int in_channels, + int out_channels, int percent_loss) { AudioFrame audio_frame; @@ -785,8 +796,8 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels, variable_packets++; } else { // For fixed rate codecs, check that packet size is correct. - if ((rec_size != pack_size_bytes_ * out_channels) - && (pack_size_bytes_ < 65535)) { + if ((rec_size != pack_size_bytes_ * out_channels) && + (pack_size_bytes_ < 65535)) { error_count++; } } @@ -831,7 +842,7 @@ void TestStereo::OpenOutFile(int16_t test_number) { std::string file_name; std::stringstream file_stream; file_stream << webrtc::test::OutputPath() << "teststereo_out_" << test_number - << ".pcm"; + << ".pcm"; file_name = file_stream.str(); out_file_.Open(file_name, 32000, "wb"); } diff --git a/modules/audio_coding/test/TestStereo.h b/modules/audio_coding/test/TestStereo.h index a454f25639..6fd7d6ff07 100644 --- a/modules/audio_coding/test/TestStereo.h +++ b/modules/audio_coding/test/TestStereo.h @@ -23,11 +23,7 @@ namespace webrtc { -enum StereoMonoMode { - kNotSet, - kMono, - kStereo -}; +enum StereoMonoMode { kNotSet, kMono, kStereo }; class TestPackStereo : public AudioPacketizationCallback { public: @@ -72,11 +68,17 @@ class TestStereo : public ACMTest { // The default value of '-1' indicates that the registration is based only on // codec name and a sampling frequncy matching is not required. This is useful // for codecs which support several sampling frequency. - void RegisterSendCodec(char side, char* codec_name, int32_t samp_freq_hz, - int rate, int pack_size, int channels, + void RegisterSendCodec(char side, + char* codec_name, + int32_t samp_freq_hz, + int rate, + int pack_size, + int channels, int payload_type); - void Run(TestPackStereo* channel, int in_channels, int out_channels, + void Run(TestPackStereo* channel, + int in_channels, + int out_channels, int percent_loss = 0); void OpenOutFile(int16_t test_number); void DisplaySendReceiveCodec(); diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc index 586563895b..d211a6ba87 100644 --- a/modules/audio_coding/test/TestVADDTX.cc +++ b/modules/audio_coding/test/TestVADDTX.cc @@ -84,8 +84,11 @@ void TestVadDtx::RegisterCodec(CodecInst codec_param) { // Encoding a file and see if the numbers that various packets occur follow // the expectation. -void TestVadDtx::Run(std::string in_filename, int frequency, int channels, - std::string out_filename, bool append, +void TestVadDtx::Run(std::string in_filename, + int frequency, + int channels, + std::string out_filename, + bool append, const int* expects) { monitor_->ResetStatistics(); @@ -146,13 +149,10 @@ void TestVadDtx::Run(std::string in_filename, int frequency, int channels, // Following is the implementation of TestWebRtcVadDtx. TestWebRtcVadDtx::TestWebRtcVadDtx() - : vad_enabled_(false), - dtx_enabled_(false), - output_file_num_(0) { -} + : vad_enabled_(false), dtx_enabled_(false), output_file_num_(0) {} void TestWebRtcVadDtx::Perform() { - // Go through various test cases. +// Go through various test cases. #ifdef WEBRTC_CODEC_ISAC // Register iSAC WB as send codec RegisterCodec(kIsacWb); @@ -206,15 +206,14 @@ void TestWebRtcVadDtx::Test(bool new_outfile) { output_file_num_++; } std::stringstream out_filename; - out_filename << webrtc::test::OutputPath() - << "testWebRtcVadDtx_outFile_" - << output_file_num_ - << ".pcm"; - Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), - 32000, 1, out_filename.str(), !new_outfile, expects); + out_filename << webrtc::test::OutputPath() << "testWebRtcVadDtx_outFile_" + << output_file_num_ << ".pcm"; + Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, + out_filename.str(), !new_outfile, expects); } -void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad, +void TestWebRtcVadDtx::SetVAD(bool enable_dtx, + bool enable_vad, ACMVADMode vad_mode) { ACMVADMode mode; EXPECT_EQ(0, acm_send_->SetVAD(enable_dtx, enable_vad, vad_mode)); @@ -227,10 +226,10 @@ void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad, enable_dtx = enable_vad = false; } - EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected. + EXPECT_EQ(dtx_enabled_, enable_dtx); // DTX should be set as expected. if (dtx_enabled_) { - EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD. + EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD. } else { // Using no DTX should not affect setting of VAD. EXPECT_EQ(enable_vad, vad_enabled_); @@ -250,19 +249,19 @@ void TestOpusDtx::Perform() { int expects[] = {0, 1, 0, 0, 0}; // Register Opus as send codec - std::string out_filename = webrtc::test::OutputPath() + - "testOpusDtx_outFile_mono.pcm"; + std::string out_filename = + webrtc::test::OutputPath() + "testOpusDtx_outFile_mono.pcm"; RegisterCodec(kOpus); EXPECT_EQ(0, acm_send_->DisableOpusDtx()); - Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), - 32000, 1, out_filename, false, expects); + Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, + out_filename, false, expects); EXPECT_EQ(0, acm_send_->EnableOpusDtx()); expects[kEmptyFrame] = 1; expects[kAudioFrameCN] = 1; - Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), - 32000, 1, out_filename, true, expects); + Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, + out_filename, true, expects); // Register stereo Opus as send codec out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_stereo.pcm"; @@ -270,15 +269,15 @@ void TestOpusDtx::Perform() { EXPECT_EQ(0, acm_send_->DisableOpusDtx()); expects[kEmptyFrame] = 0; expects[kAudioFrameCN] = 0; - Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), - 32000, 2, out_filename, false, expects); + Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000, + 2, out_filename, false, expects); EXPECT_EQ(0, acm_send_->EnableOpusDtx()); expects[kEmptyFrame] = 1; expects[kAudioFrameCN] = 1; - Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), - 32000, 2, out_filename, true, expects); + Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000, + 2, out_filename, true, expects); #endif } diff --git a/modules/audio_coding/test/TestVADDTX.h b/modules/audio_coding/test/TestVADDTX.h index 8cd4444f3d..e3840f795a 100644 --- a/modules/audio_coding/test/TestVADDTX.h +++ b/modules/audio_coding/test/TestVADDTX.h @@ -28,6 +28,7 @@ class ActivityMonitor : public ACMVADCallback { void PrintStatistics(); void ResetStatistics(); void GetStatistics(uint32_t* stats); + private: // 0 - kEmptyFrame // 1 - kAudioFrameSpeech @@ -37,7 +38,6 @@ class ActivityMonitor : public ACMVADCallback { uint32_t counter_[5]; }; - // TestVadDtx is to verify that VAD/DTX perform as they should. It runs through // an audio file and check if the occurrence of various packet types follows // expectation. TestVadDtx needs its derived class to implement the Perform() @@ -65,8 +65,12 @@ class TestVadDtx : public ACMTest { // 2 - kAudioFrameCN // 3 - kVideoFrameKey (not used by audio) // 4 - kVideoFrameDelta (not used by audio) - void Run(std::string in_filename, int frequency, int channels, - std::string out_filename, bool append, const int* expects); + void Run(std::string in_filename, + int frequency, + int channels, + std::string out_filename, + bool append, + const int* expects); std::unique_ptr acm_send_; std::unique_ptr acm_receive_; diff --git a/modules/audio_coding/test/Tester.cc b/modules/audio_coding/test/Tester.cc index 1124222308..8ce50a413b 100644 --- a/modules/audio_coding/test/Tester.cc +++ b/modules/audio_coding/test/Tester.cc @@ -115,7 +115,7 @@ TEST(AudioCodingModuleTest, TestPacketLossBurst) { #if defined(WEBRTC_IOS) TEST(AudioCodingModuleTest, DISABLED_TestPacketLossStereo) { #else - TEST(AudioCodingModuleTest, TestPacketLossStereo) { +TEST(AudioCodingModuleTest, TestPacketLossStereo) { #endif webrtc::PacketLossTest(2, 10, 10, 1).Perform(); } @@ -128,3 +128,11 @@ TEST(AudioCodingModuleTest, TestPacketLossStereoBurst) { #endif webrtc::PacketLossTest(2, 10, 10, 2).Perform(); } + +// The full API test is too long to run automatically on bots, but can be used +// for offline testing. User interaction is needed. +#ifdef ACM_TEST_FULL_API +TEST(AudioCodingModuleTest, TestAPI) { + webrtc::APITest().Perform(); +} +#endif diff --git a/modules/audio_coding/test/TwoWayCommunication.cc b/modules/audio_coding/test/TwoWayCommunication.cc index 1ed5a72e46..5a78c11981 100644 --- a/modules/audio_coding/test/TwoWayCommunication.cc +++ b/modules/audio_coding/test/TwoWayCommunication.cc @@ -60,8 +60,7 @@ TwoWayCommunication::~TwoWayCommunication() { _outFileRefB.Close(); } -void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A, - uint8_t* codecID_B) { +void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B) { std::unique_ptr tmpACM(AudioCodingModule::Create( AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))); uint8_t noCodec = tmpACM->NumberOfCodecs(); @@ -75,11 +74,11 @@ void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A, printf("\nChoose a send codec for side A [0]: "); char myStr[15] = ""; EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); - *codecID_A = (uint8_t) atoi(myStr); + *codecID_A = (uint8_t)atoi(myStr); printf("\nChoose a send codec for side B [0]: "); EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); - *codecID_B = (uint8_t) atoi(myStr); + *codecID_B = (uint8_t)atoi(myStr); printf("\n"); } @@ -118,8 +117,8 @@ void TwoWayCommunication::SetUp() { uint16_t frequencyHz; //--- Input A - std::string in_file_name = webrtc::test::ResourcePath( - "audio_coding/testfile32kHz", "pcm"); + std::string in_file_name = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); frequencyHz = 32000; printf("Enter input file at side A [%s]: ", in_file_name.c_str()); PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz); @@ -134,8 +133,8 @@ void TwoWayCommunication::SetUp() { _outFileRefA.Open(ref_file_name, frequencyHz, "wb"); //--- Input B - in_file_name = webrtc::test::ResourcePath("audio_coding/testfile32kHz", - "pcm"); + in_file_name = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); frequencyHz = 32000; printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str()); PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz); @@ -200,8 +199,8 @@ void TwoWayCommunication::SetUpAutotest() { uint16_t frequencyHz; //--- Input A and B - std::string in_file_name = webrtc::test::ResourcePath( - "audio_coding/testfile32kHz", "pcm"); + std::string in_file_name = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); frequencyHz = 16000; _inFileA.Open(in_file_name, frequencyHz, "rb"); _inFileB.Open(in_file_name, frequencyHz, "rb"); @@ -210,16 +209,16 @@ void TwoWayCommunication::SetUpAutotest() { std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm"; frequencyHz = 16000; _outFileA.Open(output_file_a, frequencyHz, "wb"); - std::string output_ref_file_a = webrtc::test::OutputPath() - + "ref_outAutotestA.pcm"; + std::string output_ref_file_a = + webrtc::test::OutputPath() + "ref_outAutotestA.pcm"; _outFileRefA.Open(output_ref_file_a, frequencyHz, "wb"); //--- Output B std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm"; frequencyHz = 16000; _outFileB.Open(output_file_b, frequencyHz, "wb"); - std::string output_ref_file_b = webrtc::test::OutputPath() - + "ref_outAutotestB.pcm"; + std::string output_ref_file_b = + webrtc::test::OutputPath() + "ref_outAutotestB.pcm"; _outFileRefB.Open(output_ref_file_b, frequencyHz, "wb"); //--- Set A-to-B channel diff --git a/modules/audio_coding/test/TwoWayCommunication.h b/modules/audio_coding/test/TwoWayCommunication.h index fb23275a9a..f0becaec35 100644 --- a/modules/audio_coding/test/TwoWayCommunication.h +++ b/modules/audio_coding/test/TwoWayCommunication.h @@ -27,6 +27,7 @@ class TwoWayCommunication : public ACMTest { ~TwoWayCommunication(); void Perform(); + private: void ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B); void SetUp(); diff --git a/modules/audio_coding/test/delay_test.cc b/modules/audio_coding/test/delay_test.cc index 532a8eb14e..3c20a54c47 100644 --- a/modules/audio_coding/test/delay_test.cc +++ b/modules/audio_coding/test/delay_test.cc @@ -83,26 +83,25 @@ class DelayTest { void Initialize() { test_cntr_ = 0; - std::string file_name = webrtc::test::ResourcePath( - "audio_coding/testfile32kHz", "pcm"); + std::string file_name = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); if (strlen(FLAG_input_file) > 0) file_name = FLAG_input_file; in_file_a_.Open(file_name, 32000, "rb"); - ASSERT_EQ(0, acm_a_->InitializeReceiver()) << - "Couldn't initialize receiver.\n"; - ASSERT_EQ(0, acm_b_->InitializeReceiver()) << - "Couldn't initialize receiver.\n"; + ASSERT_EQ(0, acm_a_->InitializeReceiver()) + << "Couldn't initialize receiver.\n"; + ASSERT_EQ(0, acm_b_->InitializeReceiver()) + << "Couldn't initialize receiver.\n"; if (FLAG_delay > 0) { - ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay)) << - "Failed to set minimum delay.\n"; + ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay)) + << "Failed to set minimum delay.\n"; } int num_encoders = acm_a_->NumberOfCodecs(); CodecInst my_codec_param; for (int n = 0; n < num_encoders; n++) { - EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) << - "Failed to get codec."; + EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) << "Failed to get codec."; if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0) my_codec_param.channels = 1; else if (my_codec_param.channels > 1) @@ -118,12 +117,14 @@ class DelayTest { } // Create and connect the channel - ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)) << - "Couldn't register Transport callback.\n"; + ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)) + << "Couldn't register Transport callback.\n"; channel_a2b_->RegisterReceiverACM(acm_b_.get()); } - void Perform(const TestSettings* config, size_t num_tests, int duration_sec, + void Perform(const TestSettings* config, + size_t num_tests, + int duration_sec, const char* output_prefix) { for (size_t n = 0; n < num_tests; ++n) { ApplyConfig(config[n]); @@ -134,14 +135,15 @@ class DelayTest { private: void ApplyConfig(const TestSettings& config) { printf("====================================\n"); - printf("Test %d \n" - "Codec: %s, %d kHz, %d channel(s)\n" - "ACM: DTX %s, FEC %s\n" - "Channel: %s\n", - ++test_cntr_, config.codec.name, config.codec.sample_rate_hz, - config.codec.num_channels, config.acm.dtx ? "on" : "off", - config.acm.fec ? "on" : "off", - config.packet_loss ? "with packet-loss" : "no packet-loss"); + printf( + "Test %d \n" + "Codec: %s, %d kHz, %d channel(s)\n" + "ACM: DTX %s, FEC %s\n" + "Channel: %s\n", + ++test_cntr_, config.codec.name, config.codec.sample_rate_hz, + config.codec.num_channels, config.acm.dtx ? "on" : "off", + config.acm.fec ? "on" : "off", + config.packet_loss ? "with packet-loss" : "no packet-loss"); SendCodec(config.codec); ConfigAcm(config.acm); ConfigChannel(config.packet_loss); @@ -149,20 +151,20 @@ class DelayTest { void SendCodec(const CodecSettings& config) { CodecInst my_codec_param; - ASSERT_EQ(0, AudioCodingModule::Codec( - config.name, &my_codec_param, config.sample_rate_hz, - config.num_channels)) << "Specified codec is not supported.\n"; + ASSERT_EQ( + 0, AudioCodingModule::Codec(config.name, &my_codec_param, + config.sample_rate_hz, config.num_channels)) + << "Specified codec is not supported.\n"; encoding_sample_rate_hz_ = my_codec_param.plfreq; - ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param)) << - "Failed to register send-codec.\n"; + ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param)) + << "Failed to register send-codec.\n"; } void ConfigAcm(const AcmSettings& config) { - ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr)) << - "Failed to set VAD.\n"; - ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) << - "Failed to set RED.\n"; + ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr)) + << "Failed to set VAD.\n"; + ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) << "Failed to set RED.\n"; } void ConfigChannel(bool packet_loss) { @@ -172,7 +174,8 @@ class DelayTest { void OpenOutFile(const char* output_id) { std::stringstream file_stream; file_stream << "delay_test_" << FLAG_codec << "_" << FLAG_sample_rate_hz - << "Hz" << "_" << FLAG_delay << "ms.pcm"; + << "Hz" + << "_" << FLAG_delay << "ms.pcm"; std::cout << "Output file: " << file_stream.str() << std::endl << std::endl; std::string file_name = webrtc::test::OutputPath() + file_stream.str(); out_file_b_.Open(file_name.c_str(), 32000, "wb"); @@ -197,14 +200,15 @@ class DelayTest { if ((num_frames & 0x3F) == 0x3F) { NetworkStatistics statistics; acm_b_->GetNetworkStatistics(&statistics); - fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d" + fprintf(stdout, + "delay: min=%3d max=%3d mean=%3d median=%3d" " ts-based average = %6.3f, " "curr buff-lev = %4u opt buff-lev = %4u \n", statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs, statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs, average_delay, statistics.currentBufferSize, statistics.preferredBufferSize); - fflush (stdout); + fflush(stdout); } in_file_a_.Read10MsData(audio_frame); @@ -256,10 +260,8 @@ int main(int argc, char* argv[]) { webrtc::TestSettings test_setting; strcpy(test_setting.codec.name, FLAG_codec); - if (FLAG_sample_rate_hz != 8000 && - FLAG_sample_rate_hz != 16000 && - FLAG_sample_rate_hz != 32000 && - FLAG_sample_rate_hz != 48000) { + if (FLAG_sample_rate_hz != 8000 && FLAG_sample_rate_hz != 16000 && + FLAG_sample_rate_hz != 32000 && FLAG_sample_rate_hz != 48000) { std::cout << "Invalid sampling rate.\n"; return 1; } diff --git a/modules/audio_coding/test/iSACTest.cc b/modules/audio_coding/test/iSACTest.cc index a847132741..e9fd867e03 100644 --- a/modules/audio_coding/test/iSACTest.cc +++ b/modules/audio_coding/test/iSACTest.cc @@ -41,11 +41,11 @@ void SetISACConfigDefault(ACMTestISACConfig& isacConfig) { return; } -int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm, +int16_t SetISAConfig(ACMTestISACConfig& isacConfig, + AudioCodingModule* acm, int testMode) { - - if ((isacConfig.currentRateBitPerSec != 0) - || (isacConfig.currentFrameSizeMsec != 0)) { + if ((isacConfig.currentRateBitPerSec != 0) || + (isacConfig.currentFrameSizeMsec != 0)) { auto sendCodec = acm->SendCodec(); EXPECT_TRUE(sendCodec); if (isacConfig.currentRateBitPerSec < 0) { @@ -57,8 +57,8 @@ int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm, sendCodec->rate = isacConfig.currentRateBitPerSec; } if (isacConfig.currentFrameSizeMsec != 0) { - sendCodec->pacsize = isacConfig.currentFrameSizeMsec - * (sendCodec->plfreq / 1000); + sendCodec->pacsize = + isacConfig.currentFrameSizeMsec * (sendCodec->plfreq / 1000); } EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec)); } @@ -81,15 +81,15 @@ void ISACTest::Setup() { CodecInst codecParam; for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs(); - codecCntr++) { + codecCntr++) { EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam)); - if (!STR_CASE_CMP(codecParam.plname, "ISAC") - && codecParam.plfreq == 16000) { + if (!STR_CASE_CMP(codecParam.plname, "ISAC") && + codecParam.plfreq == 16000) { memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst)); _idISAC16kHz = codecCntr; } - if (!STR_CASE_CMP(codecParam.plname, "ISAC") - && codecParam.plfreq == 32000) { + if (!STR_CASE_CMP(codecParam.plname, "ISAC") && + codecParam.plfreq == 32000) { memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst)); _idISAC32kHz = codecCntr; } @@ -115,8 +115,8 @@ void ISACTest::Setup() { EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get())); _channel_B2A->RegisterReceiverACM(_acmA.get()); - file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz", - "pcm"); + file_name_swb_ = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz)); EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz)); @@ -213,7 +213,8 @@ void ISACTest::Run10ms() { _outFileB.Write10MsData(audioFrame); } -void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig, +void ISACTest::EncodeDecode(int testNr, + ACMTestISACConfig& wbISACConfig, ACMTestISACConfig& swbISACConfig) { // Files in Side A and B _inFileA.Open(file_name_swb_, 32000, "rb", true); @@ -241,8 +242,8 @@ void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig, SetISAConfig(wbISACConfig, _acmB.get(), _testMode); bool adaptiveMode = false; - if ((swbISACConfig.currentRateBitPerSec == -1) - || (wbISACConfig.currentRateBitPerSec == -1)) { + if ((swbISACConfig.currentRateBitPerSec == -1) || + (wbISACConfig.currentRateBitPerSec == -1)) { adaptiveMode = true; } _myTimer.Reset(); diff --git a/modules/audio_coding/test/iSACTest.h b/modules/audio_coding/test/iSACTest.h index d0e7d5954f..22c85b4aa4 100644 --- a/modules/audio_coding/test/iSACTest.h +++ b/modules/audio_coding/test/iSACTest.h @@ -23,7 +23,7 @@ #include "modules/audio_coding/test/utility.h" #define MAX_FILE_NAME_LENGTH_BYTE 500 -#define NO_OF_CLIENTS 15 +#define NO_OF_CLIENTS 15 namespace webrtc { @@ -42,12 +42,14 @@ class ISACTest : public ACMTest { ~ISACTest(); void Perform(); + private: void Setup(); void Run10ms(); - void EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig, + void EncodeDecode(int testNr, + ACMTestISACConfig& wbISACConfig, ACMTestISACConfig& swbISACConfig); void SwitchingSamplingRate(int testNr, int maxSampRateChange); diff --git a/modules/audio_coding/test/opus_test.cc b/modules/audio_coding/test/opus_test.cc index d3afd6bb0d..40b51475bf 100644 --- a/modules/audio_coding/test/opus_test.cc +++ b/modules/audio_coding/test/opus_test.cc @@ -211,8 +211,11 @@ void OpusTest::Perform() { #endif } -void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate, - size_t frame_length, int percent_loss) { +void OpusTest::Run(TestPackStereo* channel, + size_t channels, + int bitrate, + size_t frame_length, + int percent_loss) { AudioFrame audio_frame; int32_t out_freq_hz_b = out_file_.SamplingFrequency(); const size_t kBufferSizeSamples = 480 * 12 * 2; // 120 ms stereo audio. @@ -237,8 +240,8 @@ void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate, // default. const int kOpusComplexity5 = 5; EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_mono_encoder_, kOpusComplexity5)); - EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_stereo_encoder_, - kOpusComplexity5)); + EXPECT_EQ(0, + WebRtcOpus_SetComplexity(opus_stereo_encoder_, kOpusComplexity5)); #endif // Fast-forward 1 second (100 blocks) since the files start with silence. @@ -263,19 +266,16 @@ void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate, } // If input audio is sampled at 32 kHz, resampling to 48 kHz is required. - EXPECT_EQ(480, - resampler_.Resample10Msec(audio_frame.data(), - audio_frame.sample_rate_hz_, - 48000, - channels, - kBufferSizeSamples - written_samples, - &audio[written_samples])); + EXPECT_EQ(480, resampler_.Resample10Msec( + audio_frame.data(), audio_frame.sample_rate_hz_, 48000, + channels, kBufferSizeSamples - written_samples, + &audio[written_samples])); written_samples += 480 * channels; // Sometimes we need to loop over the audio vector to produce the right // number of packets. - size_t loop_encode = (written_samples - read_samples) / - (channels * frame_length); + size_t loop_encode = + (written_samples - read_samples) / (channels * frame_length); if (loop_encode > 0) { const size_t kMaxBytes = 1000; // Maximum number of bytes for one packet. @@ -319,9 +319,9 @@ void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate, opus_stereo_decoder_, bitstream, bitstream_len_byte, &out_audio[decoded_samples * channels], &audio_type); } else { - decoded_samples += WebRtcOpus_DecodePlc( - opus_stereo_decoder_, &out_audio[decoded_samples * channels], - 1); + decoded_samples += + WebRtcOpus_DecodePlc(opus_stereo_decoder_, + &out_audio[decoded_samples * channels], 1); } } @@ -377,14 +377,14 @@ void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate, void OpusTest::OpenOutFile(int test_number) { std::string file_name; std::stringstream file_stream; - file_stream << webrtc::test::OutputPath() << "opustest_out_" - << test_number << ".pcm"; + file_stream << webrtc::test::OutputPath() << "opustest_out_" << test_number + << ".pcm"; file_name = file_stream.str(); out_file_.Open(file_name, 48000, "wb"); file_stream.str(""); file_name = file_stream.str(); file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" - << test_number << ".pcm"; + << test_number << ".pcm"; file_name = file_stream.str(); out_file_standalone_.Open(file_name, 48000, "wb"); } diff --git a/modules/audio_coding/test/opus_test.h b/modules/audio_coding/test/opus_test.h index 3e9d9a7187..1356f27231 100644 --- a/modules/audio_coding/test/opus_test.h +++ b/modules/audio_coding/test/opus_test.h @@ -15,8 +15,8 @@ #include -#include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/acm2/acm_resampler.h" +#include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/test/ACMTest.h" #include "modules/audio_coding/test/Channel.h" #include "modules/audio_coding/test/PCMFile.h" diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc index 89bf34f43b..7579d62fe5 100644 --- a/modules/audio_coding/test/target_delay_unittest.cc +++ b/modules/audio_coding/test/target_delay_unittest.cc @@ -73,8 +73,8 @@ class TargetDelayTest : public ::testing::Test { void WithTargetDelayBufferNotChanging() { // A target delay that is one packet larger than jitter. - const int kTargetDelayMs = (kInterarrivalJitterPacket + 1) * - kNum10msPerFrame * 10; + const int kTargetDelayMs = + (kInterarrivalJitterPacket + 1) * kNum10msPerFrame * 10; ASSERT_EQ(0, SetMinimumDelay(kTargetDelayMs)); for (int n = 0; n < 30; ++n) // Run enough iterations to fill the buffer. Run(true); @@ -91,8 +91,8 @@ class TargetDelayTest : public ::testing::Test { int clean_optimal_delay = GetCurrentOptimalDelayMs(); // A relatively large delay. - const int kTargetDelayMs = (kInterarrivalJitterPacket + 10) * - kNum10msPerFrame * 10; + const int kTargetDelayMs = + (kInterarrivalJitterPacket + 10) * kNum10msPerFrame * 10; ASSERT_EQ(0, SetMinimumDelay(kTargetDelayMs)); for (int n = 0; n < 300; ++n) // Run enough iterations to fill the buffer. Run(true); @@ -146,8 +146,8 @@ class TargetDelayTest : public ::testing::Test { void Push() { rtp_info_.header.timestamp += kFrameSizeSamples; rtp_info_.header.sequenceNumber++; - ASSERT_EQ(0, acm_->IncomingPacket(payload_, kFrameSizeSamples * 2, - rtp_info_)); + ASSERT_EQ(0, + acm_->IncomingPacket(payload_, kFrameSizeSamples * 2, rtp_info_)); } // Pull audio equivalent to the amount of audio in one RTP packet. @@ -195,9 +195,7 @@ class TargetDelayTest : public ::testing::Test { return stats.preferredBufferSize; } - int RequiredDelay() { - return acm_->LeastRequiredDelayMs(); - } + int RequiredDelay() { return acm_->LeastRequiredDelayMs(); } std::unique_ptr acm_; WebRtcRTPHeader rtp_info_; diff --git a/modules/audio_coding/test/utility.cc b/modules/audio_coding/test/utility.cc index 3c64620d3f..83c25b537e 100644 --- a/modules/audio_coding/test/utility.cc +++ b/modules/audio_coding/test/utility.cc @@ -23,11 +23,7 @@ namespace webrtc { -ACMTestTimer::ACMTestTimer() - : _msec(0), - _sec(0), - _min(0), - _hour(0) { +ACMTestTimer::ACMTestTimer() : _msec(0), _sec(0), _min(0), _hour(0) { return; } @@ -68,12 +64,14 @@ void ACMTestTimer::Tick1sec() { void ACMTestTimer::CurrentTimeHMS(char* currTime) { sprintf(currTime, "%4lu:%02u:%06.3f", _hour, _min, - (double) _sec + (double) _msec / 1000.); + (double)_sec + (double)_msec / 1000.); return; } -void ACMTestTimer::CurrentTime(unsigned long& h, unsigned char& m, - unsigned char& s, unsigned short& ms) { +void ACMTestTimer::CurrentTime(unsigned long& h, + unsigned char& m, + unsigned char& s, + unsigned short& ms) { h = _hour; m = _min; s = _sec; @@ -101,9 +99,8 @@ void ACMTestTimer::Adjust() { } int16_t ChooseCodec(CodecInst& codecInst) { - PrintCodecs(); - //AudioCodingModule* tmpACM = AudioCodingModule::Create(0); + // AudioCodingModule* tmpACM = AudioCodingModule::Create(0); uint8_t noCodec = AudioCodingModule::NumberOfCodecs(); int8_t codecID; bool outOfRange = false; @@ -118,7 +115,7 @@ int16_t ChooseCodec(CodecInst& codecInst) { } } while (outOfRange); - CHECK_ERROR(AudioCodingModule::Codec((uint8_t )codecID, &codecInst)); + CHECK_ERROR(AudioCodingModule::Codec((uint8_t)codecID, &codecInst)); return 0; } @@ -132,7 +129,6 @@ void PrintCodecs() { printf("%2d- %-18s %5d %6d\n", codecCntr, codecInst.plname, codecInst.plfreq, codecInst.rate); } - } namespace test { @@ -192,7 +188,7 @@ void CircularBuffer::Update(const double newVal) { if (_calcVar) { // to calculate variance we have to update // the sum of squares - _sumSqr += (double) (newVal - oldVal) * (double) (newVal + oldVal); + _sumSqr += (double)(newVal - oldVal) * (double)(newVal + oldVal); } } @@ -236,17 +232,15 @@ int16_t CircularBuffer::ArithMean(double& mean) { assert(_buffLen > 0); if (_buffIsFull) { - - mean = _sum / (double) _buffLen; + mean = _sum / (double)_buffLen; return 0; } else { if (_idx > 0) { - mean = _sum / (double) _idx; + mean = _sum / (double)_idx; return 0; } else { return -1; } - } } @@ -254,11 +248,11 @@ int16_t CircularBuffer::Variance(double& var) { assert(_buffLen > 0); if (_buffIsFull) { - var = _sumSqr / (double) _buffLen; + var = _sumSqr / (double)_buffLen; return 0; } else { if (_idx > 0) { - var = _sumSqr / (double) _idx; + var = _sumSqr / (double)_idx; return 0; } else { return -1; @@ -269,9 +263,9 @@ int16_t CircularBuffer::Variance(double& var) { } // namespace test bool FixedPayloadTypeCodec(const char* payloadName) { - char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = { "PCMU", - "PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA", "G722", "QCELP", "CN", - "MPA", "G728", "G729" }; + char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = { + "PCMU", "PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA", + "G722", "QCELP", "CN", "MPA", "G728", "G729"}; for (int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++) { if (!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n])) { diff --git a/modules/audio_coding/test/utility.h b/modules/audio_coding/test/utility.h index 07cbe7170d..6f17df5bdf 100644 --- a/modules/audio_coding/test/utility.h +++ b/modules/audio_coding/test/utility.h @@ -17,48 +17,48 @@ namespace webrtc { //----------------------------- -#define CHECK_ERROR(f) \ - do { \ - EXPECT_GE(f, 0) << "Error Calling API"; \ - } while(0) +#define CHECK_ERROR(f) \ + do { \ + EXPECT_GE(f, 0) << "Error Calling API"; \ + } while (0) //----------------------------- -#define CHECK_PROTECTED(f) \ - do { \ - if (f >= 0) { \ - ADD_FAILURE() << "Error Calling API"; \ - } else { \ - printf("An expected error is caught.\n"); \ - } \ - } while(0) +#define CHECK_PROTECTED(f) \ + do { \ + if (f >= 0) { \ + ADD_FAILURE() << "Error Calling API"; \ + } else { \ + printf("An expected error is caught.\n"); \ + } \ + } while (0) //---------------------------- -#define CHECK_ERROR_MT(f) \ - do { \ - if (f < 0) { \ - fprintf(stderr, "Error Calling API in file %s at line %d \n", \ - __FILE__, __LINE__); \ - } \ - } while(0) +#define CHECK_ERROR_MT(f) \ + do { \ + if (f < 0) { \ + fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \ + __LINE__); \ + } \ + } while (0) //---------------------------- -#define CHECK_PROTECTED_MT(f) \ - do { \ - if (f >= 0) { \ - fprintf(stderr, "Error Calling API in file %s at line %d \n", \ - __FILE__, __LINE__); \ - } else { \ - printf("An expected error is caught.\n"); \ - } \ - } while(0) +#define CHECK_PROTECTED_MT(f) \ + do { \ + if (f >= 0) { \ + fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \ + __LINE__); \ + } else { \ + printf("An expected error is caught.\n"); \ + } \ + } while (0) -#define DELETE_POINTER(p) \ - do { \ - if (p != NULL) { \ - delete p; \ - p = NULL; \ - } \ - } while(0) +#define DELETE_POINTER(p) \ + do { \ + if (p != NULL) { \ + delete p; \ + p = NULL; \ + } \ + } while (0) class ACMTestTimer { public: @@ -71,7 +71,9 @@ class ACMTestTimer { void Tick100ms(); void Tick1sec(); void CurrentTimeHMS(char* currTime); - void CurrentTime(unsigned long& h, unsigned char& m, unsigned char& s, + void CurrentTime(unsigned long& h, + unsigned char& m, + unsigned char& s, unsigned short& ms); private: diff --git a/modules/audio_device/android/audio_device_unittest.cc b/modules/audio_device/android/audio_device_unittest.cc index c297aaa636..06ae706632 100644 --- a/modules/audio_device/android/audio_device_unittest.cc +++ b/modules/audio_device/android/audio_device_unittest.cc @@ -92,6 +92,7 @@ class AudioStreamInterface { public: virtual void Write(const void* source, size_t num_frames) = 0; virtual void Read(void* destination, size_t num_frames) = 0; + protected: virtual ~AudioStreamInterface() {} }; @@ -100,11 +101,10 @@ class AudioStreamInterface { // construction. class FileAudioStream : public AudioStreamInterface { public: - FileAudioStream( - size_t num_callbacks, const std::string& file_name, int sample_rate) - : file_size_in_bytes_(0), - sample_rate_(sample_rate), - file_pos_(0) { + FileAudioStream(size_t num_callbacks, + const std::string& file_name, + int sample_rate) + : file_size_in_bytes_(0), sample_rate_(sample_rate), file_pos_(0) { file_size_in_bytes_ = test::GetFileSize(file_name); sample_rate_ = sample_rate; EXPECT_GE(file_size_in_callbacks(), num_callbacks) @@ -114,8 +114,8 @@ class FileAudioStream : public AudioStreamInterface { file_.reset(new int16_t[num_16bit_samples]); FILE* audio_file = fopen(file_name.c_str(), "rb"); EXPECT_NE(audio_file, nullptr); - size_t num_samples_read = fread( - file_.get(), sizeof(int16_t), num_16bit_samples, audio_file); + size_t num_samples_read = + fread(file_.get(), sizeof(int16_t), num_16bit_samples, audio_file); EXPECT_EQ(num_samples_read, num_16bit_samples); fclose(audio_file); } @@ -126,15 +126,14 @@ class FileAudioStream : public AudioStreamInterface { // Read samples from file stored in memory (at construction) and copy // |num_frames| (<=> 10ms) to the |destination| byte buffer. void Read(void* destination, size_t num_frames) override { - memcpy(destination, - static_cast (&file_[file_pos_]), + memcpy(destination, static_cast(&file_[file_pos_]), num_frames * sizeof(int16_t)); file_pos_ += num_frames; } int file_size_in_seconds() const { - return static_cast( - file_size_in_bytes_ / (kBytesPerSample * sample_rate_)); + return static_cast(file_size_in_bytes_ / + (kBytesPerSample * sample_rate_)); } size_t file_size_in_callbacks() const { return file_size_in_seconds() * kNumCallbacksPerSecond; @@ -167,9 +166,7 @@ class FifoAudioStream : public AudioStreamInterface { EXPECT_NE(fifo_.get(), nullptr); } - ~FifoAudioStream() { - Flush(); - } + ~FifoAudioStream() { Flush(); } // Allocate new memory, copy |num_frames| samples from |source| into memory // and add pointer to the memory location to end of the list. @@ -181,9 +178,7 @@ class FifoAudioStream : public AudioStreamInterface { return; } int16_t* memory = new int16_t[frames_per_buffer_]; - memcpy(static_cast (&memory[0]), - source, - bytes_per_buffer_); + memcpy(static_cast(&memory[0]), source, bytes_per_buffer_); rtc::CritScope lock(&lock_); fifo_->push_back(memory); const size_t size = fifo_->size(); @@ -206,24 +201,20 @@ class FifoAudioStream : public AudioStreamInterface { } else { int16_t* memory = fifo_->front(); fifo_->pop_front(); - memcpy(destination, - static_cast (&memory[0]), - bytes_per_buffer_); + memcpy(destination, static_cast(&memory[0]), bytes_per_buffer_); delete memory; } } - size_t size() const { - return fifo_->size(); - } + size_t size() const { return fifo_->size(); } - size_t largest_size() const { - return largest_size_; - } + size_t largest_size() const { return largest_size_; } size_t average_size() const { - return (total_written_elements_ == 0) ? 0.0 : 0.5 + static_cast ( - total_written_elements_) / (write_count_ - kNumIgnoreFirstCallbacks); + return (total_written_elements_ == 0) + ? 0.0 + : 0.5 + static_cast(total_written_elements_) / + (write_count_ - kNumIgnoreFirstCallbacks); } private: @@ -255,8 +246,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface { bytes_per_buffer_(frames_per_buffer_ * sizeof(int16_t)), play_count_(0), rec_count_(0), - pulse_time_(0) { - } + pulse_time_(0) {} // Insert periodic impulses in first two samples of |destination|. void Read(void* destination, size_t num_frames) override { @@ -272,7 +262,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface { } PRINT("."); const int16_t impulse = std::numeric_limits::max(); - int16_t* ptr16 = static_cast (destination); + int16_t* ptr16 = static_cast(destination); for (size_t i = 0; i < 2; ++i) { ptr16[i] = impulse; } @@ -289,19 +279,18 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface { // been transmitted (sets |pulse_time_| to value larger than zero). return; } - const int16_t* ptr16 = static_cast (source); + const int16_t* ptr16 = static_cast(source); std::vector vec(ptr16, ptr16 + num_frames); // Find max value in the audio buffer. int max = *std::max_element(vec.begin(), vec.end()); // Find index (element position in vector) of the max element. - int index_of_max = std::distance(vec.begin(), - std::find(vec.begin(), vec.end(), - max)); + int index_of_max = + std::distance(vec.begin(), std::find(vec.begin(), vec.end(), max)); if (max > kImpulseThreshold) { PRINTD("(%d,%d)", max, index_of_max); int64_t now_time = rtc::TimeMillis(); - int extra_delay = IndexToMilliseconds(static_cast (index_of_max)); - PRINTD("[%d]", static_cast (now_time - pulse_time_)); + int extra_delay = IndexToMilliseconds(static_cast(index_of_max)); + PRINTD("[%d]", static_cast(now_time - pulse_time_)); PRINTD("[%d]", extra_delay); // Total latency is the difference between transmit time and detection // tome plus the extra delay within the buffer in which we detected the @@ -315,9 +304,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface { } } - size_t num_latency_values() const { - return latencies_.size(); - } + size_t num_latency_values() const { return latencies_.size(); } int min_latency() const { if (latencies_.empty()) @@ -334,9 +321,9 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface { int average_latency() const { if (latencies_.empty()) return 0; - return 0.5 + static_cast ( - std::accumulate(latencies_.begin(), latencies_.end(), 0)) / - latencies_.size(); + return 0.5 + static_cast( + std::accumulate(latencies_.begin(), latencies_.end(), 0)) / + latencies_.size(); } void PrintResults() const { @@ -345,8 +332,8 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface { PRINT("%d ", *it); } PRINT("\n"); - PRINT("%s[min, max, avg]=[%d, %d, %d] ms\n", kTag, - min_latency(), max_latency(), average_latency()); + PRINT("%s[min, max, avg]=[%d, %d, %d] ms\n", kTag, min_latency(), + max_latency(), average_latency()); } int IndexToMilliseconds(double index) const { @@ -473,8 +460,7 @@ class MockAudioTransportAndroid : public test::MockAudioTransport { // AudioDeviceTest test fixture. class AudioDeviceTest : public ::testing::Test { protected: - AudioDeviceTest() - : test_is_done_(EventWrapper::Create()) { + AudioDeviceTest() : test_is_done_(EventWrapper::Create()) { // One-time initialization of JVM and application context. Ensures that we // can do calls between C++ and Java. Initializes both Java and OpenSL ES // implementations. @@ -487,22 +473,12 @@ class AudioDeviceTest : public ::testing::Test { record_parameters_ = audio_manager()->GetRecordAudioParameters(); build_info_.reset(new BuildInfo()); } - virtual ~AudioDeviceTest() { - EXPECT_EQ(0, audio_device_->Terminate()); - } + virtual ~AudioDeviceTest() { EXPECT_EQ(0, audio_device_->Terminate()); } - int playout_sample_rate() const { - return playout_parameters_.sample_rate(); - } - int record_sample_rate() const { - return record_parameters_.sample_rate(); - } - size_t playout_channels() const { - return playout_parameters_.channels(); - } - size_t record_channels() const { - return record_parameters_.channels(); - } + int playout_sample_rate() const { return playout_parameters_.sample_rate(); } + int record_sample_rate() const { return record_parameters_.sample_rate(); } + size_t playout_channels() const { return playout_parameters_.channels(); } + size_t record_channels() const { return record_parameters_.channels(); } size_t playout_frames_per_10ms_buffer() const { return playout_parameters_.frames_per_10ms_buffer(); } @@ -527,8 +503,8 @@ class AudioDeviceTest : public ::testing::Test { } AudioManager* GetAudioManager(AudioDeviceModule* adm) const { - return static_cast(adm)-> - GetAndroidAudioManagerForTest(); + return static_cast(adm) + ->GetAndroidAudioManagerForTest(); } AudioDeviceBuffer* audio_device_buffer() const { @@ -546,9 +522,7 @@ class AudioDeviceTest : public ::testing::Test { std::string GetFileName(int sample_rate) { EXPECT_TRUE(sample_rate == 48000 || sample_rate == 44100); char fname[64]; - snprintf(fname, - sizeof(fname), - "audio_device/audio_short%d", + snprintf(fname, sizeof(fname), "audio_device/audio_short%d", sample_rate / 1000); std::string file_name(webrtc::test::ResourcePath(fname, "pcm")); EXPECT_TRUE(test::FileExists(file_name)); @@ -705,16 +679,16 @@ TEST_F(AudioDeviceTest, VerifyDefaultAudioLayer) { TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForCombinedJavaOpenSLCombo) { AudioDeviceModule::AudioLayer expected_layer = AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio; - AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer( - expected_layer); + AudioDeviceModule::AudioLayer active_layer = + TestActiveAudioLayer(expected_layer); EXPECT_EQ(expected_layer, active_layer); } TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForJavaInBothDirections) { AudioDeviceModule::AudioLayer expected_layer = AudioDeviceModule::kAndroidJavaAudio; - AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer( - expected_layer); + AudioDeviceModule::AudioLayer active_layer = + TestActiveAudioLayer(expected_layer); EXPECT_EQ(expected_layer, active_layer); } @@ -774,7 +748,7 @@ TEST_F(AudioDeviceTest, UsesCorrectDelayEstimateForHighLatencyOutputPath) { TEST_F(AudioDeviceTest, UsesCorrectDelayEstimateForLowLatencyOutputPath) { EXPECT_EQ(kLowLatencyModeDelayEstimateInMilliseconds, TestDelayOnAudioLayer( - AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio)); + AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio)); } // Ensure that the ADM internal audio device buffer is configured to use the @@ -790,7 +764,6 @@ TEST_F(AudioDeviceTest, VerifyAudioDeviceBufferParameters) { audio_device_buffer()->RecordingChannels()); } - TEST_F(AudioDeviceTest, InitTerminate) { // Initialization is part of the test fixture. EXPECT_TRUE(audio_device()->Initialized()); @@ -896,11 +869,8 @@ TEST_F(AudioDeviceTest, StartPlayoutVerifyCallbacks) { MockAudioTransportAndroid mock(kPlayout); mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks); EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(), - kBytesPerSample, - playout_channels(), - playout_sample_rate(), - NotNull(), - _, _, _)) + kBytesPerSample, playout_channels(), + playout_sample_rate(), NotNull(), _, _, _)) .Times(AtLeast(kNumCallbacks)); EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock)); StartPlayout(); @@ -927,18 +897,14 @@ TEST_F(AudioDeviceTest, StartRecordingVerifyCallbacks) { StopRecording(); } - // Start playout and recording (full-duplex audio) and verify that audio is // active in both directions. TEST_F(AudioDeviceTest, StartPlayoutAndRecordingVerifyCallbacks) { MockAudioTransportAndroid mock(kPlayout | kRecording); - mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks); + mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks); EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(), - kBytesPerSample, - playout_channels(), - playout_sample_rate(), - NotNull(), - _, _, _)) + kBytesPerSample, playout_channels(), + playout_sample_rate(), NotNull(), _, _, _)) .Times(AtLeast(kNumCallbacks)); EXPECT_CALL( mock, RecordedDataIsAvailable(NotNull(), record_frames_per_10ms_buffer(), @@ -964,8 +930,7 @@ TEST_F(AudioDeviceTest, RunPlayoutWithFileAsSource) { std::string file_name = GetFileName(playout_sample_rate()); std::unique_ptr file_audio_stream( new FileAudioStream(num_callbacks, file_name, playout_sample_rate())); - mock.HandleCallbacks(test_is_done_.get(), - file_audio_stream.get(), + mock.HandleCallbacks(test_is_done_.get(), file_audio_stream.get(), num_callbacks); // SetMaxPlayoutVolume(); EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock)); @@ -999,15 +964,14 @@ TEST_F(AudioDeviceTest, DISABLED_RunPlayoutAndRecordingInFullDuplex) { NiceMock mock(kPlayout | kRecording); std::unique_ptr fifo_audio_stream( new FifoAudioStream(playout_frames_per_10ms_buffer())); - mock.HandleCallbacks(test_is_done_.get(), - fifo_audio_stream.get(), + mock.HandleCallbacks(test_is_done_.get(), fifo_audio_stream.get(), kFullDuplexTimeInSec * kNumCallbacksPerSecond); SetMaxPlayoutVolume(); EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock)); StartRecording(); StartPlayout(); - test_is_done_->Wait(std::max(kTestTimeOutInMilliseconds, - 1000 * kFullDuplexTimeInSec)); + test_is_done_->Wait( + std::max(kTestTimeOutInMilliseconds, 1000 * kFullDuplexTimeInSec)); StopPlayout(); StopRecording(); @@ -1033,16 +997,15 @@ TEST_F(AudioDeviceTest, DISABLED_MeasureLoopbackLatency) { NiceMock mock(kPlayout | kRecording); std::unique_ptr latency_audio_stream( new LatencyMeasuringAudioStream(playout_frames_per_10ms_buffer())); - mock.HandleCallbacks(test_is_done_.get(), - latency_audio_stream.get(), + mock.HandleCallbacks(test_is_done_.get(), latency_audio_stream.get(), kMeasureLatencyTimeInSec * kNumCallbacksPerSecond); EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock)); SetMaxPlayoutVolume(); DisableBuiltInAECIfAvailable(); StartRecording(); StartPlayout(); - test_is_done_->Wait(std::max(kTestTimeOutInMilliseconds, - 1000 * kMeasureLatencyTimeInSec)); + test_is_done_->Wait( + std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec)); StopPlayout(); StopRecording(); // Verify that the correct number of transmitted impulses are detected. diff --git a/modules/audio_device/android/audio_manager.h b/modules/audio_device/android/audio_manager.h index 3de991c14b..d2d0eb623b 100644 --- a/modules/audio_device/android/audio_manager.h +++ b/modules/audio_device/android/audio_manager.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ #define MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ -#include #include +#include #include diff --git a/modules/audio_device/android/audio_manager_unittest.cc b/modules/audio_device/android/audio_manager_unittest.cc index 00314ebfeb..ed713cbede 100644 --- a/modules/audio_device/android/audio_manager_unittest.cc +++ b/modules/audio_device/android/audio_manager_unittest.cc @@ -73,8 +73,7 @@ class AudioManagerTest : public ::testing::Test { AudioParameters record_parameters_; }; -TEST_F(AudioManagerTest, ConstructDestruct) { -} +TEST_F(AudioManagerTest, ConstructDestruct) {} // It should not be possible to create an OpenSL engine object if Java based // audio is requested in both directions. @@ -187,8 +186,8 @@ TEST_F(AudioManagerTest, ShowDeviceInfo) { BuildInfo build_info; PRINT("%smodel: %s\n", kTag, build_info.GetDeviceModel().c_str()); PRINT("%sbrand: %s\n", kTag, build_info.GetBrand().c_str()); - PRINT("%smanufacturer: %s\n", - kTag, build_info.GetDeviceManufacturer().c_str()); + PRINT("%smanufacturer: %s\n", kTag, + build_info.GetDeviceManufacturer().c_str()); } // Add Android build information to the test for logging purposes. @@ -238,4 +237,3 @@ TEST_F(AudioManagerTest, AudioParametersWithNonDefaultConstruction) { } } // namespace webrtc - diff --git a/modules/audio_device/android/audio_record_jni.cc b/modules/audio_device/android/audio_record_jni.cc index 02d74486e0..97ba6c668c 100644 --- a/modules/audio_device/android/audio_record_jni.cc +++ b/modules/audio_device/android/audio_record_jni.cc @@ -140,7 +140,7 @@ int32_t AudioRecordJni::InitRecording() { RTC_DCHECK(!recording_); ScopedHistogramTimer timer("WebRTC.Audio.InitRecordingDurationMs"); int frames_per_buffer = j_audio_record_->InitRecording( - audio_parameters_.sample_rate(), audio_parameters_.channels()); + audio_parameters_.sample_rate(), audio_parameters_.channels()); if (frames_per_buffer < 0) { direct_buffer_address_ = nullptr; RTC_LOG(LS_ERROR) << "InitRecording failed"; @@ -246,7 +246,7 @@ void AudioRecordJni::OnCacheDirectBufferAddress(JNIEnv* env, RTC_DCHECK(!direct_buffer_address_); direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer); jlong capacity = env->GetDirectBufferCapacity(byte_buffer); - RTC_LOG(INFO) << "direct buffer capacity: " << capacity; + RTC_LOG(INFO) << "direct buffer capacity: " << capacity; direct_buffer_capacity_in_bytes_ = static_cast(capacity); } diff --git a/modules/audio_device/android/audio_record_jni.h b/modules/audio_device/android/audio_record_jni.h index f508280ad0..a700a51b2b 100644 --- a/modules/audio_device/android/audio_record_jni.h +++ b/modules/audio_device/android/audio_record_jni.h @@ -48,7 +48,7 @@ class AudioRecordJni { class JavaAudioRecord { public: JavaAudioRecord(NativeRegistration* native_registration, - std::unique_ptr audio_track); + std::unique_ptr audio_track); ~JavaAudioRecord(); int InitRecording(int sample_rate, size_t channels); @@ -91,8 +91,10 @@ class AudioRecordJni { // is also stored in |direct_buffer_capacity_in_bytes_|. // This method will be called by the WebRtcAudioRecord constructor, i.e., // on the same thread that this object is created on. - static void JNICALL CacheDirectBufferAddress( - JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioRecord); + static void JNICALL CacheDirectBufferAddress(JNIEnv* env, + jobject obj, + jobject byte_buffer, + jlong nativeAudioRecord); void OnCacheDirectBufferAddress(JNIEnv* env, jobject byte_buffer); // Called periodically by the Java based WebRtcAudioRecord object when @@ -101,8 +103,10 @@ class AudioRecordJni { // now time to send these to the consumer. // This method is called on a high-priority thread from Java. The name of // the thread is 'AudioRecordThread'. - static void JNICALL DataIsRecorded( - JNIEnv* env, jobject obj, jint length, jlong nativeAudioRecord); + static void JNICALL DataIsRecorded(JNIEnv* env, + jobject obj, + jint length, + jlong nativeAudioRecord); void OnDataIsRecorded(int length); // Stores thread ID in constructor. diff --git a/modules/audio_device/android/audio_track_jni.cc b/modules/audio_device/android/audio_track_jni.cc index f8f254a883..b0e5ddf5f6 100644 --- a/modules/audio_device/android/audio_track_jni.cc +++ b/modules/audio_device/android/audio_track_jni.cc @@ -221,11 +221,11 @@ void AudioTrackJni::OnCacheDirectBufferAddress(JNIEnv* env, RTC_DCHECK(!direct_buffer_address_); direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer); jlong capacity = env->GetDirectBufferCapacity(byte_buffer); - RTC_LOG(INFO) << "direct buffer capacity: " << capacity; + RTC_LOG(INFO) << "direct buffer capacity: " << capacity; direct_buffer_capacity_in_bytes_ = static_cast(capacity); const size_t bytes_per_frame = audio_parameters_.channels() * sizeof(int16_t); frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / bytes_per_frame; - RTC_LOG(INFO) << "frames_per_buffer: " << frames_per_buffer_; + RTC_LOG(INFO) << "frames_per_buffer: " << frames_per_buffer_; } JNI_FUNCTION_ALIGN diff --git a/modules/audio_device/android/audio_track_jni.h b/modules/audio_device/android/audio_track_jni.h index fd9c61e1ff..469aa82bbd 100644 --- a/modules/audio_device/android/audio_track_jni.h +++ b/modules/audio_device/android/audio_track_jni.h @@ -90,8 +90,10 @@ class AudioTrackJni { // |byte_buffer| in |direct_buffer_address_|. The size of the buffer // is also stored in |direct_buffer_capacity_in_bytes_|. // Called on the same thread as the creating thread. - static void JNICALL CacheDirectBufferAddress( - JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack); + static void JNICALL CacheDirectBufferAddress(JNIEnv* env, + jobject obj, + jobject byte_buffer, + jlong nativeAudioTrack); void OnCacheDirectBufferAddress(JNIEnv* env, jobject byte_buffer); // Called periodically by the Java based WebRtcAudioTrack object when @@ -99,8 +101,10 @@ class AudioTrackJni { // be written to the memory area |direct_buffer_address_| for playout. // This method is called on a high-priority thread from Java. The name of // the thread is 'AudioTrackThread'. - static void JNICALL GetPlayoutData( - JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack); + static void JNICALL GetPlayoutData(JNIEnv* env, + jobject obj, + jint length, + jlong nativeAudioTrack); void OnGetPlayoutData(size_t length); // Stores thread ID in constructor. diff --git a/modules/audio_device/android/build_info.cc b/modules/audio_device/android/build_info.cc index 9eab4b33ef..916be8244e 100644 --- a/modules/audio_device/android/build_info.cc +++ b/modules/audio_device/android/build_info.cc @@ -21,8 +21,8 @@ BuildInfo::BuildInfo() std::string BuildInfo::GetStringFromJava(const char* name) { jmethodID id = j_build_info_.GetStaticMethodId(name, "()Ljava/lang/String;"); - jstring j_string = static_cast( - j_build_info_.CallStaticObjectMethod(id)); + jstring j_string = + static_cast(j_build_info_.CallStaticObjectMethod(id)); return j_environment_->JavaToStdString(j_string); } diff --git a/modules/audio_device/android/opensles_common.h b/modules/audio_device/android/opensles_common.h index 90988eef5a..438c522072 100644 --- a/modules/audio_device/android/opensles_common.h +++ b/modules/audio_device/android/opensles_common.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ #define MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ -#include #include +#include #include "rtc_base/checks.h" diff --git a/modules/audio_device/audio_device_buffer.cc b/modules/audio_device/audio_device_buffer.cc index 3bbc7147ff..d872da5fc9 100644 --- a/modules/audio_device/audio_device_buffer.cc +++ b/modules/audio_device/audio_device_buffer.cc @@ -244,8 +244,7 @@ void AudioDeviceBuffer::NativeAudioRecordingInterrupted() { recording_thread_checker_.DetachFromThread(); } -void AudioDeviceBuffer::SetVQEData(int play_delay_ms, - int rec_delay_ms) { +void AudioDeviceBuffer::SetVQEData(int play_delay_ms, int rec_delay_ms) { RTC_DCHECK_RUN_ON(&recording_thread_checker_); play_delay_ms_ = play_delay_ms; rec_delay_ms_ = rec_delay_ms; diff --git a/modules/audio_device/audio_device_config.h b/modules/audio_device/audio_device_config.h index fd12c8bedd..fa51747b67 100644 --- a/modules/audio_device/audio_device_config.h +++ b/modules/audio_device/audio_device_config.h @@ -28,4 +28,3 @@ enum { GET_MIC_VOLUME_INTERVAL_MS = 1000 }; #endif #endif // AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H_ - diff --git a/modules/audio_device/audio_device_generic.h b/modules/audio_device/audio_device_generic.h index e7abcb37ff..be9c072c41 100644 --- a/modules/audio_device/audio_device_generic.h +++ b/modules/audio_device/audio_device_generic.h @@ -122,8 +122,8 @@ class AudioDeviceGeneric { virtual int32_t EnableBuiltInAGC(bool enable); virtual int32_t EnableBuiltInNS(bool enable); - // iOS only. - // TODO(henrika): add Android support. +// iOS only. +// TODO(henrika): add Android support. #if defined(WEBRTC_IOS) virtual int GetPlayoutAudioParameters(AudioParameters* params) const; virtual int GetRecordAudioParameters(AudioParameters* params) const; diff --git a/modules/audio_device/dummy/audio_device_dummy.cc b/modules/audio_device/dummy/audio_device_dummy.cc index b7b61a72ab..b8fd837038 100644 --- a/modules/audio_device/dummy/audio_device_dummy.cc +++ b/modules/audio_device/dummy/audio_device_dummy.cc @@ -21,13 +21,21 @@ AudioDeviceGeneric::InitStatus AudioDeviceDummy::Init() { return InitStatus::OK; } -int32_t AudioDeviceDummy::Terminate() { return 0; } +int32_t AudioDeviceDummy::Terminate() { + return 0; +} -bool AudioDeviceDummy::Initialized() const { return true; } +bool AudioDeviceDummy::Initialized() const { + return true; +} -int16_t AudioDeviceDummy::PlayoutDevices() { return -1; } +int16_t AudioDeviceDummy::PlayoutDevices() { + return -1; +} -int16_t AudioDeviceDummy::RecordingDevices() { return -1; } +int16_t AudioDeviceDummy::RecordingDevices() { + return -1; +} int32_t AudioDeviceDummy::PlayoutDeviceName(uint16_t index, char name[kAdmMaxDeviceNameSize], @@ -41,59 +49,99 @@ int32_t AudioDeviceDummy::RecordingDeviceName(uint16_t index, return -1; } -int32_t AudioDeviceDummy::SetPlayoutDevice(uint16_t index) { return -1; } +int32_t AudioDeviceDummy::SetPlayoutDevice(uint16_t index) { + return -1; +} int32_t AudioDeviceDummy::SetPlayoutDevice( AudioDeviceModule::WindowsDeviceType device) { return -1; } -int32_t AudioDeviceDummy::SetRecordingDevice(uint16_t index) { return -1; } +int32_t AudioDeviceDummy::SetRecordingDevice(uint16_t index) { + return -1; +} int32_t AudioDeviceDummy::SetRecordingDevice( AudioDeviceModule::WindowsDeviceType device) { return -1; } -int32_t AudioDeviceDummy::PlayoutIsAvailable(bool& available) { return -1; } +int32_t AudioDeviceDummy::PlayoutIsAvailable(bool& available) { + return -1; +} -int32_t AudioDeviceDummy::InitPlayout() { return -1; } +int32_t AudioDeviceDummy::InitPlayout() { + return -1; +} -bool AudioDeviceDummy::PlayoutIsInitialized() const { return false; } +bool AudioDeviceDummy::PlayoutIsInitialized() const { + return false; +} -int32_t AudioDeviceDummy::RecordingIsAvailable(bool& available) { return -1; } +int32_t AudioDeviceDummy::RecordingIsAvailable(bool& available) { + return -1; +} -int32_t AudioDeviceDummy::InitRecording() { return -1; } +int32_t AudioDeviceDummy::InitRecording() { + return -1; +} -bool AudioDeviceDummy::RecordingIsInitialized() const { return false; } +bool AudioDeviceDummy::RecordingIsInitialized() const { + return false; +} -int32_t AudioDeviceDummy::StartPlayout() { return -1; } +int32_t AudioDeviceDummy::StartPlayout() { + return -1; +} -int32_t AudioDeviceDummy::StopPlayout() { return 0; } +int32_t AudioDeviceDummy::StopPlayout() { + return 0; +} -bool AudioDeviceDummy::Playing() const { return false; } +bool AudioDeviceDummy::Playing() const { + return false; +} -int32_t AudioDeviceDummy::StartRecording() { return -1; } +int32_t AudioDeviceDummy::StartRecording() { + return -1; +} -int32_t AudioDeviceDummy::StopRecording() { return 0; } +int32_t AudioDeviceDummy::StopRecording() { + return 0; +} -bool AudioDeviceDummy::Recording() const { return false; } +bool AudioDeviceDummy::Recording() const { + return false; +} -int32_t AudioDeviceDummy::InitSpeaker() { return -1; } +int32_t AudioDeviceDummy::InitSpeaker() { + return -1; +} -bool AudioDeviceDummy::SpeakerIsInitialized() const { return false; } +bool AudioDeviceDummy::SpeakerIsInitialized() const { + return false; +} -int32_t AudioDeviceDummy::InitMicrophone() { return -1; } +int32_t AudioDeviceDummy::InitMicrophone() { + return -1; +} -bool AudioDeviceDummy::MicrophoneIsInitialized() const { return false; } +bool AudioDeviceDummy::MicrophoneIsInitialized() const { + return false; +} int32_t AudioDeviceDummy::SpeakerVolumeIsAvailable(bool& available) { return -1; } -int32_t AudioDeviceDummy::SetSpeakerVolume(uint32_t volume) { return -1; } +int32_t AudioDeviceDummy::SetSpeakerVolume(uint32_t volume) { + return -1; +} -int32_t AudioDeviceDummy::SpeakerVolume(uint32_t& volume) const { return -1; } +int32_t AudioDeviceDummy::SpeakerVolume(uint32_t& volume) const { + return -1; +} int32_t AudioDeviceDummy::MaxSpeakerVolume(uint32_t& maxVolume) const { return -1; @@ -107,7 +155,9 @@ int32_t AudioDeviceDummy::MicrophoneVolumeIsAvailable(bool& available) { return -1; } -int32_t AudioDeviceDummy::SetMicrophoneVolume(uint32_t volume) { return -1; } +int32_t AudioDeviceDummy::SetMicrophoneVolume(uint32_t volume) { + return -1; +} int32_t AudioDeviceDummy::MicrophoneVolume(uint32_t& volume) const { return -1; @@ -121,36 +171,56 @@ int32_t AudioDeviceDummy::MinMicrophoneVolume(uint32_t& minVolume) const { return -1; } -int32_t AudioDeviceDummy::SpeakerMuteIsAvailable(bool& available) { return -1; } +int32_t AudioDeviceDummy::SpeakerMuteIsAvailable(bool& available) { + return -1; +} -int32_t AudioDeviceDummy::SetSpeakerMute(bool enable) { return -1; } +int32_t AudioDeviceDummy::SetSpeakerMute(bool enable) { + return -1; +} -int32_t AudioDeviceDummy::SpeakerMute(bool& enabled) const { return -1; } +int32_t AudioDeviceDummy::SpeakerMute(bool& enabled) const { + return -1; +} int32_t AudioDeviceDummy::MicrophoneMuteIsAvailable(bool& available) { return -1; } -int32_t AudioDeviceDummy::SetMicrophoneMute(bool enable) { return -1; } +int32_t AudioDeviceDummy::SetMicrophoneMute(bool enable) { + return -1; +} -int32_t AudioDeviceDummy::MicrophoneMute(bool& enabled) const { return -1; } +int32_t AudioDeviceDummy::MicrophoneMute(bool& enabled) const { + return -1; +} int32_t AudioDeviceDummy::StereoPlayoutIsAvailable(bool& available) { return -1; } -int32_t AudioDeviceDummy::SetStereoPlayout(bool enable) { return -1; } +int32_t AudioDeviceDummy::SetStereoPlayout(bool enable) { + return -1; +} -int32_t AudioDeviceDummy::StereoPlayout(bool& enabled) const { return -1; } +int32_t AudioDeviceDummy::StereoPlayout(bool& enabled) const { + return -1; +} int32_t AudioDeviceDummy::StereoRecordingIsAvailable(bool& available) { return -1; } -int32_t AudioDeviceDummy::SetStereoRecording(bool enable) { return -1; } +int32_t AudioDeviceDummy::SetStereoRecording(bool enable) { + return -1; +} -int32_t AudioDeviceDummy::StereoRecording(bool& enabled) const { return -1; } +int32_t AudioDeviceDummy::StereoRecording(bool& enabled) const { + return -1; +} -int32_t AudioDeviceDummy::PlayoutDelay(uint16_t& delayMS) const { return -1; } +int32_t AudioDeviceDummy::PlayoutDelay(uint16_t& delayMS) const { + return -1; +} void AudioDeviceDummy::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {} } // namespace webrtc diff --git a/modules/audio_device/dummy/file_audio_device.h b/modules/audio_device/dummy/file_audio_device.h index 8eea38c71f..f07690e7e0 100644 --- a/modules/audio_device/dummy/file_audio_device.h +++ b/modules/audio_device/dummy/file_audio_device.h @@ -38,8 +38,7 @@ class FileAudioDevice : public AudioDeviceGeneric { // The input file should be a readable 48k stereo raw file, and the output // file should point to a writable location. The output format will also be // 48k stereo raw audio. - FileAudioDevice(const char* inputFilename, - const char* outputFilename); + FileAudioDevice(const char* inputFilename, const char* outputFilename); virtual ~FileAudioDevice(); // Retrieve the currently utilized audio layer @@ -138,7 +137,7 @@ class FileAudioDevice : public AudioDeviceGeneric { int32_t _record_index; AudioDeviceBuffer* _ptrAudioBuffer; int8_t* _recordingBuffer; // In bytes. - int8_t* _playoutBuffer; // In bytes. + int8_t* _playoutBuffer; // In bytes. uint32_t _recordingFramesLeft; uint32_t _playoutFramesLeft; rtc::CriticalSection _critSect; diff --git a/modules/audio_device/include/audio_device.h b/modules/audio_device/include/audio_device.h index 8b7a5cc44e..a861319374 100644 --- a/modules/audio_device/include/audio_device.h +++ b/modules/audio_device/include/audio_device.h @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license @@ -12,8 +12,8 @@ #define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_ #include "modules/audio_device/include/audio_device_defines.h" -#include "rtc_base/scoped_ref_ptr.h" #include "rtc_base/refcount.h" +#include "rtc_base/scoped_ref_ptr.h" namespace webrtc { @@ -21,10 +21,7 @@ class AudioDeviceModule : public rtc::RefCountInterface { public: // Deprecated. // TODO(henrika): to be removed. - enum ErrorCode { - kAdmErrNone = 0, - kAdmErrArgument = 1 - }; + enum ErrorCode { kAdmErrNone = 0, kAdmErrArgument = 1 }; enum AudioLayer { kPlatformDefaultAudio = 0, @@ -46,11 +43,7 @@ class AudioDeviceModule : public rtc::RefCountInterface { }; // TODO(bugs.webrtc.org/7306): deprecated. - enum ChannelType { - kChannelLeft = 0, - kChannelRight = 1, - kChannelBoth = 2 - }; + enum ChannelType { kChannelLeft = 0, kChannelRight = 1, kChannelBoth = 2 }; public: // Creates an ADM. diff --git a/modules/audio_device/include/mock_audio_device.h b/modules/audio_device/include/mock_audio_device.h index 7984e0b5bd..105442b807 100644 --- a/modules/audio_device/include/mock_audio_device.h +++ b/modules/audio_device/include/mock_audio_device.h @@ -33,12 +33,14 @@ class MockAudioDeviceModule : public AudioDeviceModule { MOCK_CONST_METHOD0(Initialized, bool()); MOCK_METHOD0(PlayoutDevices, int16_t()); MOCK_METHOD0(RecordingDevices, int16_t()); - MOCK_METHOD3(PlayoutDeviceName, int32_t(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize])); - MOCK_METHOD3(RecordingDeviceName, int32_t(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize])); + MOCK_METHOD3(PlayoutDeviceName, + int32_t(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize])); + MOCK_METHOD3(RecordingDeviceName, + int32_t(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize])); MOCK_METHOD1(SetPlayoutDevice, int32_t(uint16_t index)); MOCK_METHOD1(SetPlayoutDevice, int32_t(WindowsDeviceType device)); MOCK_METHOD1(SetRecordingDevice, int32_t(uint16_t index)); diff --git a/modules/audio_device/ios/audio_device_ios.h b/modules/audio_device/ios/audio_device_ios.h index b1d40537af..eeebbf382f 100644 --- a/modules/audio_device/ios/audio_device_ios.h +++ b/modules/audio_device/ios/audio_device_ios.h @@ -13,7 +13,6 @@ #include -#include "sdk/objc/Framework/Headers/WebRTC/RTCMacros.h" #include "modules/audio_device/audio_device_generic.h" #include "modules/audio_device/ios/audio_session_observer.h" #include "modules/audio_device/ios/voice_processing_audio_unit.h" @@ -22,6 +21,7 @@ #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/thread_checker.h" +#include "sdk/objc/Framework/Headers/WebRTC/RTCMacros.h" RTC_FWD_DECL_OBJC_CLASS(RTCAudioSessionDelegateAdapter); @@ -154,7 +154,7 @@ class AudioDeviceIOS : public AudioDeviceGeneric, AudioBufferList* io_data) override; // Handles messages from posts. - void OnMessage(rtc::Message *msg) override; + void OnMessage(rtc::Message* msg) override; private: // Called by the relevant AudioSessionObserver methods on |thread_|. diff --git a/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h b/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h index 7a0f9d2594..f024bfb00f 100644 --- a/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h +++ b/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h @@ -24,7 +24,6 @@ class AudioSessionObserver; /** |observer| is a raw pointer and should be kept alive * for this object's lifetime. */ -- (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer NS_DESIGNATED_INITIALIZER; @end diff --git a/modules/audio_device/linux/alsasymboltable_linux.cc b/modules/audio_device/linux/alsasymboltable_linux.cc index d605dbaac7..5dfb91d6f4 100644 --- a/modules/audio_device/linux/alsasymboltable_linux.cc +++ b/modules/audio_device/linux/alsasymboltable_linux.cc @@ -31,8 +31,7 @@ namespace webrtc { namespace adm_linux_alsa { LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(AlsaSymbolTable, "libasound.so.2") -#define X(sym) \ - LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(AlsaSymbolTable, sym) +#define X(sym) LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(AlsaSymbolTable, sym) ALSA_SYMBOLS_LIST #undef X LATE_BINDING_SYMBOL_TABLE_DEFINE_END(AlsaSymbolTable) diff --git a/modules/audio_device/linux/alsasymboltable_linux.h b/modules/audio_device/linux/alsasymboltable_linux.h index 9c1f954522..c9970b02bc 100644 --- a/modules/audio_device/linux/alsasymboltable_linux.h +++ b/modules/audio_device/linux/alsasymboltable_linux.h @@ -36,109 +36,108 @@ namespace adm_linux_alsa { // The ALSA symbols we need, as an X-Macro list. // This list must contain precisely every libasound function that is used in // alsasoundsystem.cc. -#define ALSA_SYMBOLS_LIST \ - X(snd_device_name_free_hint) \ - X(snd_device_name_get_hint) \ - X(snd_device_name_hint) \ - X(snd_pcm_avail_update) \ - X(snd_pcm_close) \ - X(snd_pcm_delay) \ - X(snd_pcm_drop) \ - X(snd_pcm_open) \ - X(snd_pcm_prepare) \ - X(snd_pcm_readi) \ - X(snd_pcm_recover) \ - X(snd_pcm_resume) \ - X(snd_pcm_reset) \ - X(snd_pcm_state) \ - X(snd_pcm_set_params) \ - X(snd_pcm_get_params) \ - X(snd_pcm_start) \ - X(snd_pcm_stream) \ - X(snd_pcm_frames_to_bytes) \ - X(snd_pcm_bytes_to_frames) \ - X(snd_pcm_wait) \ - X(snd_pcm_writei) \ - X(snd_pcm_info_get_class) \ - X(snd_pcm_info_get_subdevices_avail) \ - X(snd_pcm_info_get_subdevice_name) \ - X(snd_pcm_info_set_subdevice) \ - X(snd_pcm_info_get_id) \ - X(snd_pcm_info_set_device) \ - X(snd_pcm_info_set_stream) \ - X(snd_pcm_info_get_name) \ - X(snd_pcm_info_get_subdevices_count) \ - X(snd_pcm_info_sizeof) \ - X(snd_pcm_hw_params) \ - X(snd_pcm_hw_params_malloc) \ - X(snd_pcm_hw_params_free) \ - X(snd_pcm_hw_params_any) \ - X(snd_pcm_hw_params_set_access) \ - X(snd_pcm_hw_params_set_format) \ - X(snd_pcm_hw_params_set_channels) \ - X(snd_pcm_hw_params_set_rate_near) \ - X(snd_pcm_hw_params_set_buffer_size_near) \ - X(snd_card_next) \ - X(snd_card_get_name) \ - X(snd_config_update) \ - X(snd_config_copy) \ - X(snd_config_get_id) \ - X(snd_ctl_open) \ - X(snd_ctl_close) \ - X(snd_ctl_card_info) \ - X(snd_ctl_card_info_sizeof) \ - X(snd_ctl_card_info_get_id) \ - X(snd_ctl_card_info_get_name) \ - X(snd_ctl_pcm_next_device) \ - X(snd_ctl_pcm_info) \ - X(snd_mixer_load) \ - X(snd_mixer_free) \ - X(snd_mixer_detach) \ - X(snd_mixer_close) \ - X(snd_mixer_open) \ - X(snd_mixer_attach) \ - X(snd_mixer_first_elem) \ - X(snd_mixer_elem_next) \ - X(snd_mixer_selem_get_name) \ - X(snd_mixer_selem_is_active) \ - X(snd_mixer_selem_register) \ - X(snd_mixer_selem_set_playback_volume_all) \ - X(snd_mixer_selem_get_playback_volume) \ - X(snd_mixer_selem_has_playback_volume) \ +#define ALSA_SYMBOLS_LIST \ + X(snd_device_name_free_hint) \ + X(snd_device_name_get_hint) \ + X(snd_device_name_hint) \ + X(snd_pcm_avail_update) \ + X(snd_pcm_close) \ + X(snd_pcm_delay) \ + X(snd_pcm_drop) \ + X(snd_pcm_open) \ + X(snd_pcm_prepare) \ + X(snd_pcm_readi) \ + X(snd_pcm_recover) \ + X(snd_pcm_resume) \ + X(snd_pcm_reset) \ + X(snd_pcm_state) \ + X(snd_pcm_set_params) \ + X(snd_pcm_get_params) \ + X(snd_pcm_start) \ + X(snd_pcm_stream) \ + X(snd_pcm_frames_to_bytes) \ + X(snd_pcm_bytes_to_frames) \ + X(snd_pcm_wait) \ + X(snd_pcm_writei) \ + X(snd_pcm_info_get_class) \ + X(snd_pcm_info_get_subdevices_avail) \ + X(snd_pcm_info_get_subdevice_name) \ + X(snd_pcm_info_set_subdevice) \ + X(snd_pcm_info_get_id) \ + X(snd_pcm_info_set_device) \ + X(snd_pcm_info_set_stream) \ + X(snd_pcm_info_get_name) \ + X(snd_pcm_info_get_subdevices_count) \ + X(snd_pcm_info_sizeof) \ + X(snd_pcm_hw_params) \ + X(snd_pcm_hw_params_malloc) \ + X(snd_pcm_hw_params_free) \ + X(snd_pcm_hw_params_any) \ + X(snd_pcm_hw_params_set_access) \ + X(snd_pcm_hw_params_set_format) \ + X(snd_pcm_hw_params_set_channels) \ + X(snd_pcm_hw_params_set_rate_near) \ + X(snd_pcm_hw_params_set_buffer_size_near) \ + X(snd_card_next) \ + X(snd_card_get_name) \ + X(snd_config_update) \ + X(snd_config_copy) \ + X(snd_config_get_id) \ + X(snd_ctl_open) \ + X(snd_ctl_close) \ + X(snd_ctl_card_info) \ + X(snd_ctl_card_info_sizeof) \ + X(snd_ctl_card_info_get_id) \ + X(snd_ctl_card_info_get_name) \ + X(snd_ctl_pcm_next_device) \ + X(snd_ctl_pcm_info) \ + X(snd_mixer_load) \ + X(snd_mixer_free) \ + X(snd_mixer_detach) \ + X(snd_mixer_close) \ + X(snd_mixer_open) \ + X(snd_mixer_attach) \ + X(snd_mixer_first_elem) \ + X(snd_mixer_elem_next) \ + X(snd_mixer_selem_get_name) \ + X(snd_mixer_selem_is_active) \ + X(snd_mixer_selem_register) \ + X(snd_mixer_selem_set_playback_volume_all) \ + X(snd_mixer_selem_get_playback_volume) \ + X(snd_mixer_selem_has_playback_volume) \ X(snd_mixer_selem_get_playback_volume_range) \ - X(snd_mixer_selem_has_playback_switch) \ - X(snd_mixer_selem_get_playback_switch) \ - X(snd_mixer_selem_set_playback_switch_all) \ - X(snd_mixer_selem_has_capture_switch) \ - X(snd_mixer_selem_get_capture_switch) \ - X(snd_mixer_selem_set_capture_switch_all) \ - X(snd_mixer_selem_has_capture_volume) \ - X(snd_mixer_selem_set_capture_volume_all) \ - X(snd_mixer_selem_get_capture_volume) \ - X(snd_mixer_selem_get_capture_volume_range) \ - X(snd_dlopen) \ - X(snd_dlclose) \ - X(snd_config) \ - X(snd_config_search) \ - X(snd_config_get_string) \ - X(snd_config_search_definition) \ - X(snd_config_get_type) \ - X(snd_config_delete) \ - X(snd_config_iterator_entry) \ - X(snd_config_iterator_first) \ - X(snd_config_iterator_next) \ - X(snd_config_iterator_end) \ - X(snd_config_delete_compound_members) \ - X(snd_config_get_integer) \ - X(snd_config_get_bool) \ - X(snd_dlsym) \ - X(snd_strerror) \ - X(snd_lib_error) \ + X(snd_mixer_selem_has_playback_switch) \ + X(snd_mixer_selem_get_playback_switch) \ + X(snd_mixer_selem_set_playback_switch_all) \ + X(snd_mixer_selem_has_capture_switch) \ + X(snd_mixer_selem_get_capture_switch) \ + X(snd_mixer_selem_set_capture_switch_all) \ + X(snd_mixer_selem_has_capture_volume) \ + X(snd_mixer_selem_set_capture_volume_all) \ + X(snd_mixer_selem_get_capture_volume) \ + X(snd_mixer_selem_get_capture_volume_range) \ + X(snd_dlopen) \ + X(snd_dlclose) \ + X(snd_config) \ + X(snd_config_search) \ + X(snd_config_get_string) \ + X(snd_config_search_definition) \ + X(snd_config_get_type) \ + X(snd_config_delete) \ + X(snd_config_iterator_entry) \ + X(snd_config_iterator_first) \ + X(snd_config_iterator_next) \ + X(snd_config_iterator_end) \ + X(snd_config_delete_compound_members) \ + X(snd_config_get_integer) \ + X(snd_config_get_bool) \ + X(snd_dlsym) \ + X(snd_strerror) \ + X(snd_lib_error) \ X(snd_lib_error_set_handler) LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(AlsaSymbolTable) -#define X(sym) \ - LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(AlsaSymbolTable, sym) +#define X(sym) LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(AlsaSymbolTable, sym) ALSA_SYMBOLS_LIST #undef X LATE_BINDING_SYMBOL_TABLE_DECLARE_END(AlsaSymbolTable) diff --git a/modules/audio_device/linux/audio_device_alsa_linux.h b/modules/audio_device/linux/audio_device_alsa_linux.h index 60e5743fa9..f8961453b5 100644 --- a/modules/audio_device/linux/audio_device_alsa_linux.h +++ b/modules/audio_device/linux/audio_device_alsa_linux.h @@ -25,178 +25,175 @@ #include #include - -namespace webrtc -{ +namespace webrtc { class EventWrapper; -class AudioDeviceLinuxALSA : public AudioDeviceGeneric -{ -public: - AudioDeviceLinuxALSA(); - virtual ~AudioDeviceLinuxALSA(); +class AudioDeviceLinuxALSA : public AudioDeviceGeneric { + public: + AudioDeviceLinuxALSA(); + virtual ~AudioDeviceLinuxALSA(); - // Retrieve the currently utilized audio layer - int32_t ActiveAudioLayer( - AudioDeviceModule::AudioLayer& audioLayer) const override; + // Retrieve the currently utilized audio layer + int32_t ActiveAudioLayer( + AudioDeviceModule::AudioLayer& audioLayer) const override; - // Main initializaton and termination - InitStatus Init() override; - int32_t Terminate() override; - bool Initialized() const override; + // Main initializaton and termination + InitStatus Init() override; + int32_t Terminate() override; + bool Initialized() const override; - // Device enumeration - int16_t PlayoutDevices() override; - int16_t RecordingDevices() override; - int32_t PlayoutDeviceName(uint16_t index, + // Device enumeration + int16_t PlayoutDevices() override; + int16_t RecordingDevices() override; + int32_t PlayoutDeviceName(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]) override; + int32_t RecordingDeviceName(uint16_t index, char name[kAdmMaxDeviceNameSize], char guid[kAdmMaxGuidSize]) override; - int32_t RecordingDeviceName(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]) override; - // Device selection - int32_t SetPlayoutDevice(uint16_t index) override; - int32_t SetPlayoutDevice( - AudioDeviceModule::WindowsDeviceType device) override; - int32_t SetRecordingDevice(uint16_t index) override; - int32_t SetRecordingDevice( - AudioDeviceModule::WindowsDeviceType device) override; + // Device selection + int32_t SetPlayoutDevice(uint16_t index) override; + int32_t SetPlayoutDevice( + AudioDeviceModule::WindowsDeviceType device) override; + int32_t SetRecordingDevice(uint16_t index) override; + int32_t SetRecordingDevice( + AudioDeviceModule::WindowsDeviceType device) override; - // Audio transport initialization - int32_t PlayoutIsAvailable(bool& available) override; - int32_t InitPlayout() override; - bool PlayoutIsInitialized() const override; - int32_t RecordingIsAvailable(bool& available) override; - int32_t InitRecording() override; - bool RecordingIsInitialized() const override; + // Audio transport initialization + int32_t PlayoutIsAvailable(bool& available) override; + int32_t InitPlayout() override; + bool PlayoutIsInitialized() const override; + int32_t RecordingIsAvailable(bool& available) override; + int32_t InitRecording() override; + bool RecordingIsInitialized() const override; - // Audio transport control - int32_t StartPlayout() override; - int32_t StopPlayout() override; - bool Playing() const override; - int32_t StartRecording() override; - int32_t StopRecording() override; - bool Recording() const override; + // Audio transport control + int32_t StartPlayout() override; + int32_t StopPlayout() override; + bool Playing() const override; + int32_t StartRecording() override; + int32_t StopRecording() override; + bool Recording() const override; - // Audio mixer initialization - int32_t InitSpeaker() override; - bool SpeakerIsInitialized() const override; - int32_t InitMicrophone() override; - bool MicrophoneIsInitialized() const override; + // Audio mixer initialization + int32_t InitSpeaker() override; + bool SpeakerIsInitialized() const override; + int32_t InitMicrophone() override; + bool MicrophoneIsInitialized() const override; - // Speaker volume controls - int32_t SpeakerVolumeIsAvailable(bool& available) override; - int32_t SetSpeakerVolume(uint32_t volume) override; - int32_t SpeakerVolume(uint32_t& volume) const override; - int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override; - int32_t MinSpeakerVolume(uint32_t& minVolume) const override; + // Speaker volume controls + int32_t SpeakerVolumeIsAvailable(bool& available) override; + int32_t SetSpeakerVolume(uint32_t volume) override; + int32_t SpeakerVolume(uint32_t& volume) const override; + int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override; + int32_t MinSpeakerVolume(uint32_t& minVolume) const override; - // Microphone volume controls - int32_t MicrophoneVolumeIsAvailable(bool& available) override; - int32_t SetMicrophoneVolume(uint32_t volume) override; - int32_t MicrophoneVolume(uint32_t& volume) const override; - int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override; - int32_t MinMicrophoneVolume(uint32_t& minVolume) const override; + // Microphone volume controls + int32_t MicrophoneVolumeIsAvailable(bool& available) override; + int32_t SetMicrophoneVolume(uint32_t volume) override; + int32_t MicrophoneVolume(uint32_t& volume) const override; + int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override; + int32_t MinMicrophoneVolume(uint32_t& minVolume) const override; - // Speaker mute control - int32_t SpeakerMuteIsAvailable(bool& available) override; - int32_t SetSpeakerMute(bool enable) override; - int32_t SpeakerMute(bool& enabled) const override; + // Speaker mute control + int32_t SpeakerMuteIsAvailable(bool& available) override; + int32_t SetSpeakerMute(bool enable) override; + int32_t SpeakerMute(bool& enabled) const override; - // Microphone mute control - int32_t MicrophoneMuteIsAvailable(bool& available) override; - int32_t SetMicrophoneMute(bool enable) override; - int32_t MicrophoneMute(bool& enabled) const override; + // Microphone mute control + int32_t MicrophoneMuteIsAvailable(bool& available) override; + int32_t SetMicrophoneMute(bool enable) override; + int32_t MicrophoneMute(bool& enabled) const override; - // Stereo support - int32_t StereoPlayoutIsAvailable(bool& available) override; - int32_t SetStereoPlayout(bool enable) override; - int32_t StereoPlayout(bool& enabled) const override; - int32_t StereoRecordingIsAvailable(bool& available) override; - int32_t SetStereoRecording(bool enable) override; - int32_t StereoRecording(bool& enabled) const override; + // Stereo support + int32_t StereoPlayoutIsAvailable(bool& available) override; + int32_t SetStereoPlayout(bool enable) override; + int32_t StereoPlayout(bool& enabled) const override; + int32_t StereoRecordingIsAvailable(bool& available) override; + int32_t SetStereoRecording(bool enable) override; + int32_t StereoRecording(bool& enabled) const override; - // Delay information and control - int32_t PlayoutDelay(uint16_t& delayMS) const override; + // Delay information and control + int32_t PlayoutDelay(uint16_t& delayMS) const override; - void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override; + void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override; -private: - int32_t GetDevicesInfo(const int32_t function, - const bool playback, - const int32_t enumDeviceNo = 0, - char* enumDeviceName = NULL, - const int32_t ednLen = 0) const; - int32_t ErrorRecovery(int32_t error, snd_pcm_t* deviceHandle); + private: + int32_t GetDevicesInfo(const int32_t function, + const bool playback, + const int32_t enumDeviceNo = 0, + char* enumDeviceName = NULL, + const int32_t ednLen = 0) const; + int32_t ErrorRecovery(int32_t error, snd_pcm_t* deviceHandle); - bool KeyPressed() const; + bool KeyPressed() const; - void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); }; - void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); }; + void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); }; + void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); }; - inline int32_t InputSanityCheckAfterUnlockedPeriod() const; - inline int32_t OutputSanityCheckAfterUnlockedPeriod() const; + inline int32_t InputSanityCheckAfterUnlockedPeriod() const; + inline int32_t OutputSanityCheckAfterUnlockedPeriod() const; - static bool RecThreadFunc(void*); - static bool PlayThreadFunc(void*); - bool RecThreadProcess(); - bool PlayThreadProcess(); + static bool RecThreadFunc(void*); + static bool PlayThreadFunc(void*); + bool RecThreadProcess(); + bool PlayThreadProcess(); - AudioDeviceBuffer* _ptrAudioBuffer; + AudioDeviceBuffer* _ptrAudioBuffer; - rtc::CriticalSection _critSect; + rtc::CriticalSection _critSect; - // TODO(pbos): Make plain members and start/stop instead of resetting these - // pointers. A thread can be reused. - std::unique_ptr _ptrThreadRec; - std::unique_ptr _ptrThreadPlay; + // TODO(pbos): Make plain members and start/stop instead of resetting these + // pointers. A thread can be reused. + std::unique_ptr _ptrThreadRec; + std::unique_ptr _ptrThreadPlay; - AudioMixerManagerLinuxALSA _mixerManager; + AudioMixerManagerLinuxALSA _mixerManager; - uint16_t _inputDeviceIndex; - uint16_t _outputDeviceIndex; - bool _inputDeviceIsSpecified; - bool _outputDeviceIsSpecified; + uint16_t _inputDeviceIndex; + uint16_t _outputDeviceIndex; + bool _inputDeviceIsSpecified; + bool _outputDeviceIsSpecified; - snd_pcm_t* _handleRecord; - snd_pcm_t* _handlePlayout; + snd_pcm_t* _handleRecord; + snd_pcm_t* _handlePlayout; - snd_pcm_uframes_t _recordingBuffersizeInFrame; - snd_pcm_uframes_t _recordingPeriodSizeInFrame; - snd_pcm_uframes_t _playoutBufferSizeInFrame; - snd_pcm_uframes_t _playoutPeriodSizeInFrame; + snd_pcm_uframes_t _recordingBuffersizeInFrame; + snd_pcm_uframes_t _recordingPeriodSizeInFrame; + snd_pcm_uframes_t _playoutBufferSizeInFrame; + snd_pcm_uframes_t _playoutPeriodSizeInFrame; - ssize_t _recordingBufferSizeIn10MS; - ssize_t _playoutBufferSizeIn10MS; - uint32_t _recordingFramesIn10MS; - uint32_t _playoutFramesIn10MS; + ssize_t _recordingBufferSizeIn10MS; + ssize_t _playoutBufferSizeIn10MS; + uint32_t _recordingFramesIn10MS; + uint32_t _playoutFramesIn10MS; - uint32_t _recordingFreq; - uint32_t _playoutFreq; - uint8_t _recChannels; - uint8_t _playChannels; + uint32_t _recordingFreq; + uint32_t _playoutFreq; + uint8_t _recChannels; + uint8_t _playChannels; - int8_t* _recordingBuffer; // in byte - int8_t* _playoutBuffer; // in byte - uint32_t _recordingFramesLeft; - uint32_t _playoutFramesLeft; + int8_t* _recordingBuffer; // in byte + int8_t* _playoutBuffer; // in byte + uint32_t _recordingFramesLeft; + uint32_t _playoutFramesLeft; - bool _initialized; - bool _recording; - bool _playing; - bool _recIsInitialized; - bool _playIsInitialized; + bool _initialized; + bool _recording; + bool _playing; + bool _recIsInitialized; + bool _playIsInitialized; - snd_pcm_sframes_t _recordingDelay; - snd_pcm_sframes_t _playoutDelay; + snd_pcm_sframes_t _recordingDelay; + snd_pcm_sframes_t _playoutDelay; - char _oldKeyState[32]; + char _oldKeyState[32]; #if defined(WEBRTC_USE_X11) - Display* _XDisplay; + Display* _XDisplay; #endif }; -} +} // namespace webrtc #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_ALSA_LINUX_H_ diff --git a/modules/audio_device/linux/audio_device_pulse_linux.cc b/modules/audio_device/linux/audio_device_pulse_linux.cc index 33eeee929b..7dda66f79b 100644 --- a/modules/audio_device/linux/audio_device_pulse_linux.cc +++ b/modules/audio_device/linux/audio_device_pulse_linux.cc @@ -1951,8 +1951,7 @@ int32_t AudioDeviceLinuxPulse::ReadRecordedData(const void* bufferData, int32_t AudioDeviceLinuxPulse::ProcessRecordedData(int8_t* bufferData, uint32_t bufferSizeInSamples, uint32_t recDelay) - RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect) { - + RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect) { _ptrAudioBuffer->SetRecordedBuffer(bufferData, bufferSizeInSamples); // TODO(andrew): this is a temporary hack, to avoid non-causal far- and diff --git a/modules/audio_device/linux/audio_device_pulse_linux.h b/modules/audio_device/linux/audio_device_pulse_linux.h index 9aadfbe0df..d16c13f6f8 100644 --- a/modules/audio_device/linux/audio_device_pulse_linux.h +++ b/modules/audio_device/linux/audio_device_pulse_linux.h @@ -85,253 +85,252 @@ const uint32_t WEBRTC_PA_MSECS_PER_SEC = 1000; // Init _configuredLatencyRec/Play to this value to disable latency requirements const int32_t WEBRTC_PA_NO_LATENCY_REQUIREMENTS = -1; -// Set this const to 1 to account for peeked and used data in latency calculation +// Set this const to 1 to account for peeked and used data in latency +// calculation const uint32_t WEBRTC_PA_CAPTURE_BUFFER_LATENCY_ADJUSTMENT = 0; -namespace webrtc -{ +namespace webrtc { class EventWrapper; -class AudioDeviceLinuxPulse: public AudioDeviceGeneric -{ -public: - AudioDeviceLinuxPulse(); - virtual ~AudioDeviceLinuxPulse(); +class AudioDeviceLinuxPulse : public AudioDeviceGeneric { + public: + AudioDeviceLinuxPulse(); + virtual ~AudioDeviceLinuxPulse(); - // Retrieve the currently utilized audio layer - int32_t ActiveAudioLayer( - AudioDeviceModule::AudioLayer& audioLayer) const override; + // Retrieve the currently utilized audio layer + int32_t ActiveAudioLayer( + AudioDeviceModule::AudioLayer& audioLayer) const override; - // Main initializaton and termination - InitStatus Init() override; - int32_t Terminate() override; - bool Initialized() const override; + // Main initializaton and termination + InitStatus Init() override; + int32_t Terminate() override; + bool Initialized() const override; - // Device enumeration - int16_t PlayoutDevices() override; - int16_t RecordingDevices() override; - int32_t PlayoutDeviceName(uint16_t index, + // Device enumeration + int16_t PlayoutDevices() override; + int16_t RecordingDevices() override; + int32_t PlayoutDeviceName(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]) override; + int32_t RecordingDeviceName(uint16_t index, char name[kAdmMaxDeviceNameSize], char guid[kAdmMaxGuidSize]) override; - int32_t RecordingDeviceName(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]) override; - // Device selection - int32_t SetPlayoutDevice(uint16_t index) override; - int32_t SetPlayoutDevice( - AudioDeviceModule::WindowsDeviceType device) override; - int32_t SetRecordingDevice(uint16_t index) override; - int32_t SetRecordingDevice( - AudioDeviceModule::WindowsDeviceType device) override; + // Device selection + int32_t SetPlayoutDevice(uint16_t index) override; + int32_t SetPlayoutDevice( + AudioDeviceModule::WindowsDeviceType device) override; + int32_t SetRecordingDevice(uint16_t index) override; + int32_t SetRecordingDevice( + AudioDeviceModule::WindowsDeviceType device) override; - // Audio transport initialization - int32_t PlayoutIsAvailable(bool& available) override; - int32_t InitPlayout() override; - bool PlayoutIsInitialized() const override; - int32_t RecordingIsAvailable(bool& available) override; - int32_t InitRecording() override; - bool RecordingIsInitialized() const override; + // Audio transport initialization + int32_t PlayoutIsAvailable(bool& available) override; + int32_t InitPlayout() override; + bool PlayoutIsInitialized() const override; + int32_t RecordingIsAvailable(bool& available) override; + int32_t InitRecording() override; + bool RecordingIsInitialized() const override; - // Audio transport control - int32_t StartPlayout() override; - int32_t StopPlayout() override; - bool Playing() const override; - int32_t StartRecording() override; - int32_t StopRecording() override; - bool Recording() const override; + // Audio transport control + int32_t StartPlayout() override; + int32_t StopPlayout() override; + bool Playing() const override; + int32_t StartRecording() override; + int32_t StopRecording() override; + bool Recording() const override; - // Audio mixer initialization - int32_t InitSpeaker() override; - bool SpeakerIsInitialized() const override; - int32_t InitMicrophone() override; - bool MicrophoneIsInitialized() const override; + // Audio mixer initialization + int32_t InitSpeaker() override; + bool SpeakerIsInitialized() const override; + int32_t InitMicrophone() override; + bool MicrophoneIsInitialized() const override; - // Speaker volume controls - int32_t SpeakerVolumeIsAvailable(bool& available) override; - int32_t SetSpeakerVolume(uint32_t volume) override; - int32_t SpeakerVolume(uint32_t& volume) const override; - int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override; - int32_t MinSpeakerVolume(uint32_t& minVolume) const override; + // Speaker volume controls + int32_t SpeakerVolumeIsAvailable(bool& available) override; + int32_t SetSpeakerVolume(uint32_t volume) override; + int32_t SpeakerVolume(uint32_t& volume) const override; + int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override; + int32_t MinSpeakerVolume(uint32_t& minVolume) const override; - // Microphone volume controls - int32_t MicrophoneVolumeIsAvailable(bool& available) override; - int32_t SetMicrophoneVolume(uint32_t volume) override; - int32_t MicrophoneVolume(uint32_t& volume) const override; - int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override; - int32_t MinMicrophoneVolume(uint32_t& minVolume) const override; + // Microphone volume controls + int32_t MicrophoneVolumeIsAvailable(bool& available) override; + int32_t SetMicrophoneVolume(uint32_t volume) override; + int32_t MicrophoneVolume(uint32_t& volume) const override; + int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override; + int32_t MinMicrophoneVolume(uint32_t& minVolume) const override; - // Speaker mute control - int32_t SpeakerMuteIsAvailable(bool& available) override; - int32_t SetSpeakerMute(bool enable) override; - int32_t SpeakerMute(bool& enabled) const override; + // Speaker mute control + int32_t SpeakerMuteIsAvailable(bool& available) override; + int32_t SetSpeakerMute(bool enable) override; + int32_t SpeakerMute(bool& enabled) const override; - // Microphone mute control - int32_t MicrophoneMuteIsAvailable(bool& available) override; - int32_t SetMicrophoneMute(bool enable) override; - int32_t MicrophoneMute(bool& enabled) const override; + // Microphone mute control + int32_t MicrophoneMuteIsAvailable(bool& available) override; + int32_t SetMicrophoneMute(bool enable) override; + int32_t MicrophoneMute(bool& enabled) const override; - // Stereo support - int32_t StereoPlayoutIsAvailable(bool& available) override; - int32_t SetStereoPlayout(bool enable) override; - int32_t StereoPlayout(bool& enabled) const override; - int32_t StereoRecordingIsAvailable(bool& available) override; - int32_t SetStereoRecording(bool enable) override; - int32_t StereoRecording(bool& enabled) const override; + // Stereo support + int32_t StereoPlayoutIsAvailable(bool& available) override; + int32_t SetStereoPlayout(bool enable) override; + int32_t StereoPlayout(bool& enabled) const override; + int32_t StereoRecordingIsAvailable(bool& available) override; + int32_t SetStereoRecording(bool enable) override; + int32_t StereoRecording(bool& enabled) const override; - // Delay information and control - int32_t PlayoutDelay(uint16_t& delayMS) const override; + // Delay information and control + int32_t PlayoutDelay(uint16_t& delayMS) const override; - void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override; + void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override; -private: - void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); } - void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); } - void WaitForOperationCompletion(pa_operation* paOperation) const; - void WaitForSuccess(pa_operation* paOperation) const; + private: + void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); } + void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); } + void WaitForOperationCompletion(pa_operation* paOperation) const; + void WaitForSuccess(pa_operation* paOperation) const; - bool KeyPressed() const; + bool KeyPressed() const; - static void PaContextStateCallback(pa_context* c, void* pThis); - static void PaSinkInfoCallback(pa_context* c, - const pa_sink_info* i, - int eol, - void* pThis); - static void PaSourceInfoCallback(pa_context* c, - const pa_source_info* i, - int eol, - void* pThis); - static void PaServerInfoCallback(pa_context* c, - const pa_server_info* i, - void* pThis); - static void PaStreamStateCallback(pa_stream* p, void* pThis); - void PaContextStateCallbackHandler(pa_context* c); - void PaSinkInfoCallbackHandler(const pa_sink_info* i, int eol); - void PaSourceInfoCallbackHandler(const pa_source_info* i, int eol); - void PaServerInfoCallbackHandler(const pa_server_info* i); - void PaStreamStateCallbackHandler(pa_stream* p); - - void EnableWriteCallback(); - void DisableWriteCallback(); - static void PaStreamWriteCallback(pa_stream* unused, - size_t buffer_space, + static void PaContextStateCallback(pa_context* c, void* pThis); + static void PaSinkInfoCallback(pa_context* c, + const pa_sink_info* i, + int eol, + void* pThis); + static void PaSourceInfoCallback(pa_context* c, + const pa_source_info* i, + int eol, void* pThis); - void PaStreamWriteCallbackHandler(size_t buffer_space); - static void PaStreamUnderflowCallback(pa_stream* unused, void* pThis); - void PaStreamUnderflowCallbackHandler(); - void EnableReadCallback(); - void DisableReadCallback(); - static void PaStreamReadCallback(pa_stream* unused1, - size_t unused2, - void* pThis); - void PaStreamReadCallbackHandler(); - static void PaStreamOverflowCallback(pa_stream* unused, void* pThis); - void PaStreamOverflowCallbackHandler(); - int32_t LatencyUsecs(pa_stream* stream); - int32_t ReadRecordedData(const void* bufferData, size_t bufferSize); - int32_t ProcessRecordedData(int8_t* bufferData, - uint32_t bufferSizeInSamples, - uint32_t recDelay); + static void PaServerInfoCallback(pa_context* c, + const pa_server_info* i, + void* pThis); + static void PaStreamStateCallback(pa_stream* p, void* pThis); + void PaContextStateCallbackHandler(pa_context* c); + void PaSinkInfoCallbackHandler(const pa_sink_info* i, int eol); + void PaSourceInfoCallbackHandler(const pa_source_info* i, int eol); + void PaServerInfoCallbackHandler(const pa_server_info* i); + void PaStreamStateCallbackHandler(pa_stream* p); - int32_t CheckPulseAudioVersion(); - int32_t InitSamplingFrequency(); - int32_t GetDefaultDeviceInfo(bool recDevice, char* name, uint16_t& index); - int32_t InitPulseAudio(); - int32_t TerminatePulseAudio(); + void EnableWriteCallback(); + void DisableWriteCallback(); + static void PaStreamWriteCallback(pa_stream* unused, + size_t buffer_space, + void* pThis); + void PaStreamWriteCallbackHandler(size_t buffer_space); + static void PaStreamUnderflowCallback(pa_stream* unused, void* pThis); + void PaStreamUnderflowCallbackHandler(); + void EnableReadCallback(); + void DisableReadCallback(); + static void PaStreamReadCallback(pa_stream* unused1, + size_t unused2, + void* pThis); + void PaStreamReadCallbackHandler(); + static void PaStreamOverflowCallback(pa_stream* unused, void* pThis); + void PaStreamOverflowCallbackHandler(); + int32_t LatencyUsecs(pa_stream* stream); + int32_t ReadRecordedData(const void* bufferData, size_t bufferSize); + int32_t ProcessRecordedData(int8_t* bufferData, + uint32_t bufferSizeInSamples, + uint32_t recDelay); - void PaLock(); - void PaUnLock(); + int32_t CheckPulseAudioVersion(); + int32_t InitSamplingFrequency(); + int32_t GetDefaultDeviceInfo(bool recDevice, char* name, uint16_t& index); + int32_t InitPulseAudio(); + int32_t TerminatePulseAudio(); - static bool RecThreadFunc(void*); - static bool PlayThreadFunc(void*); - bool RecThreadProcess(); - bool PlayThreadProcess(); + void PaLock(); + void PaUnLock(); - AudioDeviceBuffer* _ptrAudioBuffer; + static bool RecThreadFunc(void*); + static bool PlayThreadFunc(void*); + bool RecThreadProcess(); + bool PlayThreadProcess(); - rtc::CriticalSection _critSect; - EventWrapper& _timeEventRec; - EventWrapper& _timeEventPlay; - EventWrapper& _recStartEvent; - EventWrapper& _playStartEvent; + AudioDeviceBuffer* _ptrAudioBuffer; - // TODO(pbos): Remove unique_ptr and use directly without resetting. - std::unique_ptr _ptrThreadPlay; - std::unique_ptr _ptrThreadRec; + rtc::CriticalSection _critSect; + EventWrapper& _timeEventRec; + EventWrapper& _timeEventPlay; + EventWrapper& _recStartEvent; + EventWrapper& _playStartEvent; - AudioMixerManagerLinuxPulse _mixerManager; + // TODO(pbos): Remove unique_ptr and use directly without resetting. + std::unique_ptr _ptrThreadPlay; + std::unique_ptr _ptrThreadRec; - uint16_t _inputDeviceIndex; - uint16_t _outputDeviceIndex; - bool _inputDeviceIsSpecified; - bool _outputDeviceIsSpecified; + AudioMixerManagerLinuxPulse _mixerManager; - int sample_rate_hz_; - uint8_t _recChannels; - uint8_t _playChannels; + uint16_t _inputDeviceIndex; + uint16_t _outputDeviceIndex; + bool _inputDeviceIsSpecified; + bool _outputDeviceIsSpecified; - // Stores thread ID in constructor. - // We can then use ThreadChecker::CalledOnValidThread() to ensure that - // other methods are called from the same thread. - // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()). - rtc::ThreadChecker thread_checker_; + int sample_rate_hz_; + uint8_t _recChannels; + uint8_t _playChannels; - bool _initialized; - bool _recording; - bool _playing; - bool _recIsInitialized; - bool _playIsInitialized; - bool _startRec; - bool _stopRec; - bool _startPlay; - bool _stopPlay; - bool update_speaker_volume_at_startup_; + // Stores thread ID in constructor. + // We can then use ThreadChecker::CalledOnValidThread() to ensure that + // other methods are called from the same thread. + // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()). + rtc::ThreadChecker thread_checker_; - uint32_t _sndCardPlayDelay; - uint32_t _sndCardRecDelay; + bool _initialized; + bool _recording; + bool _playing; + bool _recIsInitialized; + bool _playIsInitialized; + bool _startRec; + bool _stopRec; + bool _startPlay; + bool _stopPlay; + bool update_speaker_volume_at_startup_; - int32_t _writeErrors; + uint32_t _sndCardPlayDelay; + uint32_t _sndCardRecDelay; - uint16_t _deviceIndex; - int16_t _numPlayDevices; - int16_t _numRecDevices; - char* _playDeviceName; - char* _recDeviceName; - char* _playDisplayDeviceName; - char* _recDisplayDeviceName; - char _paServerVersion[32]; + int32_t _writeErrors; - int8_t* _playBuffer; - size_t _playbackBufferSize; - size_t _playbackBufferUnused; - size_t _tempBufferSpace; - int8_t* _recBuffer; - size_t _recordBufferSize; - size_t _recordBufferUsed; - const void* _tempSampleData; - size_t _tempSampleDataSize; - int32_t _configuredLatencyPlay; - int32_t _configuredLatencyRec; + uint16_t _deviceIndex; + int16_t _numPlayDevices; + int16_t _numRecDevices; + char* _playDeviceName; + char* _recDeviceName; + char* _playDisplayDeviceName; + char* _recDisplayDeviceName; + char _paServerVersion[32]; - // PulseAudio - uint16_t _paDeviceIndex; - bool _paStateChanged; + int8_t* _playBuffer; + size_t _playbackBufferSize; + size_t _playbackBufferUnused; + size_t _tempBufferSpace; + int8_t* _recBuffer; + size_t _recordBufferSize; + size_t _recordBufferUsed; + const void* _tempSampleData; + size_t _tempSampleDataSize; + int32_t _configuredLatencyPlay; + int32_t _configuredLatencyRec; - pa_threaded_mainloop* _paMainloop; - pa_mainloop_api* _paMainloopApi; - pa_context* _paContext; + // PulseAudio + uint16_t _paDeviceIndex; + bool _paStateChanged; - pa_stream* _recStream; - pa_stream* _playStream; - uint32_t _recStreamFlags; - uint32_t _playStreamFlags; - pa_buffer_attr _playBufferAttr; - pa_buffer_attr _recBufferAttr; + pa_threaded_mainloop* _paMainloop; + pa_mainloop_api* _paMainloopApi; + pa_context* _paContext; - char _oldKeyState[32]; - Display* _XDisplay; + pa_stream* _recStream; + pa_stream* _playStream; + uint32_t _recStreamFlags; + uint32_t _playStreamFlags; + pa_buffer_attr _playBufferAttr; + pa_buffer_attr _recBufferAttr; + + char _oldKeyState[32]; + Display* _XDisplay; }; -} +} // namespace webrtc #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_PULSE_LINUX_H_ diff --git a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h index 61de607cf7..0f31322bc3 100644 --- a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h +++ b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h @@ -18,55 +18,53 @@ #include -namespace webrtc -{ +namespace webrtc { -class AudioMixerManagerLinuxALSA -{ -public: - int32_t OpenSpeaker(char* deviceName); - int32_t OpenMicrophone(char* deviceName); - int32_t SetSpeakerVolume(uint32_t volume); - int32_t SpeakerVolume(uint32_t& volume) const; - int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; - int32_t MinSpeakerVolume(uint32_t& minVolume) const; - int32_t SpeakerVolumeIsAvailable(bool& available); - int32_t SpeakerMuteIsAvailable(bool& available); - int32_t SetSpeakerMute(bool enable); - int32_t SpeakerMute(bool& enabled) const; - int32_t MicrophoneMuteIsAvailable(bool& available); - int32_t SetMicrophoneMute(bool enable); - int32_t MicrophoneMute(bool& enabled) const; - int32_t MicrophoneVolumeIsAvailable(bool& available); - int32_t SetMicrophoneVolume(uint32_t volume); - int32_t MicrophoneVolume(uint32_t& volume) const; - int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; - int32_t MinMicrophoneVolume(uint32_t& minVolume) const; - int32_t Close(); - int32_t CloseSpeaker(); - int32_t CloseMicrophone(); - bool SpeakerIsInitialized() const; - bool MicrophoneIsInitialized() const; +class AudioMixerManagerLinuxALSA { + public: + int32_t OpenSpeaker(char* deviceName); + int32_t OpenMicrophone(char* deviceName); + int32_t SetSpeakerVolume(uint32_t volume); + int32_t SpeakerVolume(uint32_t& volume) const; + int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; + int32_t MinSpeakerVolume(uint32_t& minVolume) const; + int32_t SpeakerVolumeIsAvailable(bool& available); + int32_t SpeakerMuteIsAvailable(bool& available); + int32_t SetSpeakerMute(bool enable); + int32_t SpeakerMute(bool& enabled) const; + int32_t MicrophoneMuteIsAvailable(bool& available); + int32_t SetMicrophoneMute(bool enable); + int32_t MicrophoneMute(bool& enabled) const; + int32_t MicrophoneVolumeIsAvailable(bool& available); + int32_t SetMicrophoneVolume(uint32_t volume); + int32_t MicrophoneVolume(uint32_t& volume) const; + int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; + int32_t MinMicrophoneVolume(uint32_t& minVolume) const; + int32_t Close(); + int32_t CloseSpeaker(); + int32_t CloseMicrophone(); + bool SpeakerIsInitialized() const; + bool MicrophoneIsInitialized() const; -public: - AudioMixerManagerLinuxALSA(); - ~AudioMixerManagerLinuxALSA(); + public: + AudioMixerManagerLinuxALSA(); + ~AudioMixerManagerLinuxALSA(); -private: - int32_t LoadMicMixerElement() const; - int32_t LoadSpeakerMixerElement() const; - void GetControlName(char *controlName, char* deviceName) const; + private: + int32_t LoadMicMixerElement() const; + int32_t LoadSpeakerMixerElement() const; + void GetControlName(char* controlName, char* deviceName) const; -private: - rtc::CriticalSection _critSect; - mutable snd_mixer_t* _outputMixerHandle; - char _outputMixerStr[kAdmMaxDeviceNameSize]; - mutable snd_mixer_t* _inputMixerHandle; - char _inputMixerStr[kAdmMaxDeviceNameSize]; - mutable snd_mixer_elem_t* _outputMixerElement; - mutable snd_mixer_elem_t* _inputMixerElement; + private: + rtc::CriticalSection _critSect; + mutable snd_mixer_t* _outputMixerHandle; + char _outputMixerStr[kAdmMaxDeviceNameSize]; + mutable snd_mixer_t* _inputMixerHandle; + char _inputMixerStr[kAdmMaxDeviceNameSize]; + mutable snd_mixer_elem_t* _outputMixerElement; + mutable snd_mixer_elem_t* _inputMixerElement; }; -} +} // namespace webrtc #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_MIXER_MANAGER_ALSA_LINUX_H_ diff --git a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h index 7846ccbcc0..1917b96096 100644 --- a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h +++ b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h @@ -20,94 +20,98 @@ #include #ifndef UINT32_MAX -#define UINT32_MAX ((uint32_t)-1) +#define UINT32_MAX ((uint32_t)-1) #endif -namespace webrtc -{ +namespace webrtc { -class AudioMixerManagerLinuxPulse -{ -public: - int32_t SetPlayStream(pa_stream* playStream); - int32_t SetRecStream(pa_stream* recStream); - int32_t OpenSpeaker(uint16_t deviceIndex); - int32_t OpenMicrophone(uint16_t deviceIndex); - int32_t SetSpeakerVolume(uint32_t volume); - int32_t SpeakerVolume(uint32_t& volume) const; - int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; - int32_t MinSpeakerVolume(uint32_t& minVolume) const; - int32_t SpeakerVolumeIsAvailable(bool& available); - int32_t SpeakerMuteIsAvailable(bool& available); - int32_t SetSpeakerMute(bool enable); - int32_t StereoPlayoutIsAvailable(bool& available); - int32_t StereoRecordingIsAvailable(bool& available); - int32_t SpeakerMute(bool& enabled) const; - int32_t MicrophoneMuteIsAvailable(bool& available); - int32_t SetMicrophoneMute(bool enable); - int32_t MicrophoneMute(bool& enabled) const; - int32_t MicrophoneVolumeIsAvailable(bool& available); - int32_t SetMicrophoneVolume(uint32_t volume); - int32_t MicrophoneVolume(uint32_t& volume) const; - int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; - int32_t MinMicrophoneVolume(uint32_t& minVolume) const; - int32_t SetPulseAudioObjects(pa_threaded_mainloop* mainloop, - pa_context* context); - int32_t Close(); - int32_t CloseSpeaker(); - int32_t CloseMicrophone(); - bool SpeakerIsInitialized() const; - bool MicrophoneIsInitialized() const; +class AudioMixerManagerLinuxPulse { + public: + int32_t SetPlayStream(pa_stream* playStream); + int32_t SetRecStream(pa_stream* recStream); + int32_t OpenSpeaker(uint16_t deviceIndex); + int32_t OpenMicrophone(uint16_t deviceIndex); + int32_t SetSpeakerVolume(uint32_t volume); + int32_t SpeakerVolume(uint32_t& volume) const; + int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; + int32_t MinSpeakerVolume(uint32_t& minVolume) const; + int32_t SpeakerVolumeIsAvailable(bool& available); + int32_t SpeakerMuteIsAvailable(bool& available); + int32_t SetSpeakerMute(bool enable); + int32_t StereoPlayoutIsAvailable(bool& available); + int32_t StereoRecordingIsAvailable(bool& available); + int32_t SpeakerMute(bool& enabled) const; + int32_t MicrophoneMuteIsAvailable(bool& available); + int32_t SetMicrophoneMute(bool enable); + int32_t MicrophoneMute(bool& enabled) const; + int32_t MicrophoneVolumeIsAvailable(bool& available); + int32_t SetMicrophoneVolume(uint32_t volume); + int32_t MicrophoneVolume(uint32_t& volume) const; + int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; + int32_t MinMicrophoneVolume(uint32_t& minVolume) const; + int32_t SetPulseAudioObjects(pa_threaded_mainloop* mainloop, + pa_context* context); + int32_t Close(); + int32_t CloseSpeaker(); + int32_t CloseMicrophone(); + bool SpeakerIsInitialized() const; + bool MicrophoneIsInitialized() const; -public: - AudioMixerManagerLinuxPulse(); - ~AudioMixerManagerLinuxPulse(); + public: + AudioMixerManagerLinuxPulse(); + ~AudioMixerManagerLinuxPulse(); -private: - static void PaSinkInfoCallback(pa_context *c, const pa_sink_info *i, - int eol, void *pThis); - static void PaSinkInputInfoCallback(pa_context *c, - const pa_sink_input_info *i, int eol, - void *pThis); - static void PaSourceInfoCallback(pa_context *c, const pa_source_info *i, - int eol, void *pThis); - static void - PaSetVolumeCallback(pa_context* /*c*/, int success, void* /*pThis*/); - void PaSinkInfoCallbackHandler(const pa_sink_info *i, int eol); - void PaSinkInputInfoCallbackHandler(const pa_sink_input_info *i, int eol); - void PaSourceInfoCallbackHandler(const pa_source_info *i, int eol); + private: + static void PaSinkInfoCallback(pa_context* c, + const pa_sink_info* i, + int eol, + void* pThis); + static void PaSinkInputInfoCallback(pa_context* c, + const pa_sink_input_info* i, + int eol, + void* pThis); + static void PaSourceInfoCallback(pa_context* c, + const pa_source_info* i, + int eol, + void* pThis); + static void PaSetVolumeCallback(pa_context* /*c*/, + int success, + void* /*pThis*/); + void PaSinkInfoCallbackHandler(const pa_sink_info* i, int eol); + void PaSinkInputInfoCallbackHandler(const pa_sink_input_info* i, int eol); + void PaSourceInfoCallbackHandler(const pa_source_info* i, int eol); - void WaitForOperationCompletion(pa_operation* paOperation) const; + void WaitForOperationCompletion(pa_operation* paOperation) const; - bool GetSinkInputInfo() const; - bool GetSinkInfoByIndex(int device_index)const ; - bool GetSourceInfoByIndex(int device_index) const; + bool GetSinkInputInfo() const; + bool GetSinkInfoByIndex(int device_index) const; + bool GetSourceInfoByIndex(int device_index) const; -private: - int16_t _paOutputDeviceIndex; - int16_t _paInputDeviceIndex; + private: + int16_t _paOutputDeviceIndex; + int16_t _paInputDeviceIndex; - pa_stream* _paPlayStream; - pa_stream* _paRecStream; + pa_stream* _paPlayStream; + pa_stream* _paRecStream; - pa_threaded_mainloop* _paMainloop; - pa_context* _paContext; + pa_threaded_mainloop* _paMainloop; + pa_context* _paContext; - mutable uint32_t _paVolume; - mutable uint32_t _paMute; - mutable uint32_t _paVolSteps; - bool _paSpeakerMute; - mutable uint32_t _paSpeakerVolume; - mutable uint8_t _paChannels; - bool _paObjectsSet; + mutable uint32_t _paVolume; + mutable uint32_t _paMute; + mutable uint32_t _paVolSteps; + bool _paSpeakerMute; + mutable uint32_t _paSpeakerVolume; + mutable uint8_t _paChannels; + bool _paObjectsSet; - // Stores thread ID in constructor. - // We can then use ThreadChecker::CalledOnValidThread() to ensure that - // other methods are called from the same thread. - // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()). - rtc::ThreadChecker thread_checker_; + // Stores thread ID in constructor. + // We can then use ThreadChecker::CalledOnValidThread() to ensure that + // other methods are called from the same thread. + // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()). + rtc::ThreadChecker thread_checker_; }; -} +} // namespace webrtc #endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_MIXER_MANAGER_PULSE_LINUX_H_ diff --git a/modules/audio_device/linux/latebindingsymboltable_linux.h b/modules/audio_device/linux/latebindingsymboltable_linux.h index b834f5c76e..1e28c223cf 100644 --- a/modules/audio_device/linux/latebindingsymboltable_linux.h +++ b/modules/audio_device/linux/latebindingsymboltable_linux.h @@ -26,7 +26,7 @@ namespace webrtc { namespace adm_linux { #ifdef WEBRTC_LINUX -typedef void *DllHandle; +typedef void* DllHandle; const DllHandle kInvalidDllHandle = NULL; #else @@ -40,37 +40,30 @@ void InternalUnloadDll(DllHandle handle); bool InternalLoadSymbols(DllHandle handle, int num_symbols, - const char *const symbol_names[], - void *symbols[]); + const char* const symbol_names[], + void* symbols[]); template + const char* const kSymbolNames[]> class LateBindingSymbolTable { public: LateBindingSymbolTable() - : handle_(kInvalidDllHandle), - undefined_symbols_(false) { + : handle_(kInvalidDllHandle), undefined_symbols_(false) { memset(symbols_, 0, sizeof(symbols_)); } - ~LateBindingSymbolTable() { - Unload(); - } + ~LateBindingSymbolTable() { Unload(); } - static int NumSymbols() { - return SYMBOL_TABLE_SIZE; - } + static int NumSymbols() { return SYMBOL_TABLE_SIZE; } // We do not use this, but we offer it for theoretical convenience. - static const char *GetSymbolName(int index) { + static const char* GetSymbolName(int index) { assert(index < NumSymbols()); return kSymbolNames[index]; } - bool IsLoaded() const { - return handle_ != kInvalidDllHandle; - } + bool IsLoaded() const { return handle_ != kInvalidDllHandle; } // Loads the DLL and the symbol table. Returns true iff the DLL and symbol // table loaded successfully. @@ -106,7 +99,7 @@ class LateBindingSymbolTable { // Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below // instead of this. - void *GetSymbol(int index) const { + void* GetSymbol(int index) const { assert(IsLoaded()); assert(index < NumSymbols()); return symbols_[index]; @@ -115,15 +108,13 @@ class LateBindingSymbolTable { private: DllHandle handle_; bool undefined_symbols_; - void *symbols_[SYMBOL_TABLE_SIZE]; + void* symbols_[SYMBOL_TABLE_SIZE]; RTC_DISALLOW_COPY_AND_ASSIGN(LateBindingSymbolTable); }; // This macro must be invoked in a header to declare a symbol table class. -#define LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(ClassName) \ -enum { - +#define LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(ClassName) enum { // This macro must be invoked in the header declaration once for each symbol // (recommended to use an X-Macro to avoid duplication). // This macro defines an enum with names built from the symbols, which @@ -150,26 +141,24 @@ enum { // This macro must be invoked in a .cc file to define a previously-declared // symbol table class. #define LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(ClassName, dllName) \ -const char ClassName##_kDllName[] = dllName; \ -const char *const ClassName##_kSymbolNames[ClassName##_SYMBOL_TABLE_SIZE] = { - + const char ClassName##_kDllName[] = dllName; \ + const char* const ClassName##_kSymbolNames[ClassName##_SYMBOL_TABLE_SIZE] = { // This macro must be invoked in the .cc definition once for each symbol // (recommended to use an X-Macro to avoid duplication). // This would have to use the mangled name if we were to ever support C++ // symbols. -#define LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(ClassName, sym) \ - #sym, +#define LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(ClassName, sym) #sym, #define LATE_BINDING_SYMBOL_TABLE_DEFINE_END(ClassName) \ -}; + } \ + ; // Index of a given symbol in the given symbol table class. -#define LATESYM_INDEXOF(ClassName, sym) \ - (ClassName##_SYMBOL_TABLE_INDEX_##sym) +#define LATESYM_INDEXOF(ClassName, sym) (ClassName##_SYMBOL_TABLE_INDEX_##sym) // Returns a reference to the given late-binded symbol, with the correct type. #define LATESYM_GET(ClassName, inst, sym) \ - (*reinterpret_cast( \ + (*reinterpret_cast( \ (inst)->GetSymbol(LATESYM_INDEXOF(ClassName, sym)))) } // namespace adm_linux diff --git a/modules/audio_device/linux/pulseaudiosymboltable_linux.cc b/modules/audio_device/linux/pulseaudiosymboltable_linux.cc index 3d012fe619..e0759e6ca3 100644 --- a/modules/audio_device/linux/pulseaudiosymboltable_linux.cc +++ b/modules/audio_device/linux/pulseaudiosymboltable_linux.cc @@ -32,7 +32,7 @@ namespace adm_linux_pulse { LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(PulseAudioSymbolTable, "libpulse.so.0") #define X(sym) \ - LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(PulseAudioSymbolTable, sym) + LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(PulseAudioSymbolTable, sym) PULSE_AUDIO_SYMBOLS_LIST #undef X LATE_BINDING_SYMBOL_TABLE_DEFINE_END(PulseAudioSymbolTable) diff --git a/modules/audio_device/linux/pulseaudiosymboltable_linux.h b/modules/audio_device/linux/pulseaudiosymboltable_linux.h index d21446ce8a..2f6a9510d8 100644 --- a/modules/audio_device/linux/pulseaudiosymboltable_linux.h +++ b/modules/audio_device/linux/pulseaudiosymboltable_linux.h @@ -36,66 +36,66 @@ namespace adm_linux_pulse { // The PulseAudio symbols we need, as an X-Macro list. // This list must contain precisely every libpulse function that is used in // the ADM LINUX PULSE Device and Mixer classes -#define PULSE_AUDIO_SYMBOLS_LIST \ - X(pa_bytes_per_second) \ - X(pa_context_connect) \ - X(pa_context_disconnect) \ - X(pa_context_errno) \ - X(pa_context_get_protocol_version) \ - X(pa_context_get_server_info) \ - X(pa_context_get_sink_info_list) \ - X(pa_context_get_sink_info_by_index) \ - X(pa_context_get_sink_info_by_name) \ - X(pa_context_get_sink_input_info) \ - X(pa_context_get_source_info_by_index) \ - X(pa_context_get_source_info_by_name) \ - X(pa_context_get_source_info_list) \ - X(pa_context_get_state) \ - X(pa_context_new) \ - X(pa_context_set_sink_input_volume) \ - X(pa_context_set_sink_input_mute) \ +#define PULSE_AUDIO_SYMBOLS_LIST \ + X(pa_bytes_per_second) \ + X(pa_context_connect) \ + X(pa_context_disconnect) \ + X(pa_context_errno) \ + X(pa_context_get_protocol_version) \ + X(pa_context_get_server_info) \ + X(pa_context_get_sink_info_list) \ + X(pa_context_get_sink_info_by_index) \ + X(pa_context_get_sink_info_by_name) \ + X(pa_context_get_sink_input_info) \ + X(pa_context_get_source_info_by_index) \ + X(pa_context_get_source_info_by_name) \ + X(pa_context_get_source_info_list) \ + X(pa_context_get_state) \ + X(pa_context_new) \ + X(pa_context_set_sink_input_volume) \ + X(pa_context_set_sink_input_mute) \ X(pa_context_set_source_volume_by_index) \ - X(pa_context_set_source_mute_by_index) \ - X(pa_context_set_state_callback) \ - X(pa_context_unref) \ - X(pa_cvolume_set) \ - X(pa_operation_get_state) \ - X(pa_operation_unref) \ - X(pa_stream_connect_playback) \ - X(pa_stream_connect_record) \ - X(pa_stream_disconnect) \ - X(pa_stream_drop) \ - X(pa_stream_get_device_index) \ - X(pa_stream_get_index) \ - X(pa_stream_get_latency) \ - X(pa_stream_get_sample_spec) \ - X(pa_stream_get_state) \ - X(pa_stream_new) \ - X(pa_stream_peek) \ - X(pa_stream_readable_size) \ - X(pa_stream_set_buffer_attr) \ - X(pa_stream_set_overflow_callback) \ - X(pa_stream_set_read_callback) \ - X(pa_stream_set_state_callback) \ - X(pa_stream_set_underflow_callback) \ - X(pa_stream_set_write_callback) \ - X(pa_stream_unref) \ - X(pa_stream_writable_size) \ - X(pa_stream_write) \ - X(pa_strerror) \ - X(pa_threaded_mainloop_free) \ - X(pa_threaded_mainloop_get_api) \ - X(pa_threaded_mainloop_lock) \ - X(pa_threaded_mainloop_new) \ - X(pa_threaded_mainloop_signal) \ - X(pa_threaded_mainloop_start) \ - X(pa_threaded_mainloop_stop) \ - X(pa_threaded_mainloop_unlock) \ + X(pa_context_set_source_mute_by_index) \ + X(pa_context_set_state_callback) \ + X(pa_context_unref) \ + X(pa_cvolume_set) \ + X(pa_operation_get_state) \ + X(pa_operation_unref) \ + X(pa_stream_connect_playback) \ + X(pa_stream_connect_record) \ + X(pa_stream_disconnect) \ + X(pa_stream_drop) \ + X(pa_stream_get_device_index) \ + X(pa_stream_get_index) \ + X(pa_stream_get_latency) \ + X(pa_stream_get_sample_spec) \ + X(pa_stream_get_state) \ + X(pa_stream_new) \ + X(pa_stream_peek) \ + X(pa_stream_readable_size) \ + X(pa_stream_set_buffer_attr) \ + X(pa_stream_set_overflow_callback) \ + X(pa_stream_set_read_callback) \ + X(pa_stream_set_state_callback) \ + X(pa_stream_set_underflow_callback) \ + X(pa_stream_set_write_callback) \ + X(pa_stream_unref) \ + X(pa_stream_writable_size) \ + X(pa_stream_write) \ + X(pa_strerror) \ + X(pa_threaded_mainloop_free) \ + X(pa_threaded_mainloop_get_api) \ + X(pa_threaded_mainloop_lock) \ + X(pa_threaded_mainloop_new) \ + X(pa_threaded_mainloop_signal) \ + X(pa_threaded_mainloop_start) \ + X(pa_threaded_mainloop_stop) \ + X(pa_threaded_mainloop_unlock) \ X(pa_threaded_mainloop_wait) LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(PulseAudioSymbolTable) #define X(sym) \ - LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(PulseAudioSymbolTable, sym) + LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(PulseAudioSymbolTable, sym) PULSE_AUDIO_SYMBOLS_LIST #undef X LATE_BINDING_SYMBOL_TABLE_DECLARE_END(PulseAudioSymbolTable) diff --git a/modules/audio_device/mac/portaudio/pa_memorybarrier.h b/modules/audio_device/mac/portaudio/pa_memorybarrier.h index f689622201..19b5055f4b 100644 --- a/modules/audio_device/mac/portaudio/pa_memorybarrier.h +++ b/modules/audio_device/mac/portaudio/pa_memorybarrier.h @@ -30,13 +30,13 @@ */ /* - * The text above constitutes the entire PortAudio license; however, + * The text above constitutes the entire PortAudio license; however, * the PortAudio community also makes the following non-binding requests: * * Any person wishing to distribute modifications to the Software is * requested to send the modifications to the original developer so that - * they can be incorporated into the canonical version. It is also - * requested that these non-binding requests be included along with the + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the * license above. */ @@ -47,10 +47,10 @@ /**************** * Some memory barrier primitives based on the system. - * right now only OS X, FreeBSD, and Linux are supported. In addition to providing - * memory barriers, these functions should ensure that data cached in registers - * is written out to cache where it can be snooped by other CPUs. (ie, the volatile - * keyword should not be required) + * right now only OS X, FreeBSD, and Linux are supported. In addition to + *providing memory barriers, these functions should ensure that data cached in + *registers is written out to cache where it can be snooped by other CPUs. (ie, + *the volatile keyword should not be required) * * the primitives that must be defined are: * @@ -61,67 +61,67 @@ ****************/ #if defined(__APPLE__) -# include - /* Here are the memory barrier functions. Mac OS X only provides - full memory barriers, so the three types of barriers are the same, - however, these barriers are superior to compiler-based ones. */ -# define PaUtil_FullMemoryBarrier() OSMemoryBarrier() -# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier() -# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier() +#include +/* Here are the memory barrier functions. Mac OS X only provides + full memory barriers, so the three types of barriers are the same, + however, these barriers are superior to compiler-based ones. */ +#define PaUtil_FullMemoryBarrier() OSMemoryBarrier() +#define PaUtil_ReadMemoryBarrier() OSMemoryBarrier() +#define PaUtil_WriteMemoryBarrier() OSMemoryBarrier() #elif defined(__GNUC__) - /* GCC >= 4.1 has built-in intrinsics. We'll use those */ -# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) -# define PaUtil_FullMemoryBarrier() __sync_synchronize() -# define PaUtil_ReadMemoryBarrier() __sync_synchronize() -# define PaUtil_WriteMemoryBarrier() __sync_synchronize() - /* as a fallback, GCC understands volatile asm and "memory" to mean it - * should not reorder memory read/writes */ - /* Note that it is not clear that any compiler actually defines __PPC__, - * it can probably removed safely. */ -# elif defined( __ppc__ ) || defined( __powerpc__) || defined( __PPC__ ) -# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory") -# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory") -# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory") -# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || \ - defined( __i686__ ) || defined( __x86_64__ ) -# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory") -# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory") -# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory") -# else -# ifdef ALLOW_SMP_DANGERS -# warning Memory barriers not defined on this system or system unknown -# warning For SMP safety, you should fix this. -# define PaUtil_FullMemoryBarrier() -# define PaUtil_ReadMemoryBarrier() -# define PaUtil_WriteMemoryBarrier() -# else -# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed. -# endif -# endif -#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE) -# include -# pragma intrinsic(_ReadWriteBarrier) -# pragma intrinsic(_ReadBarrier) -# pragma intrinsic(_WriteBarrier) -# define PaUtil_FullMemoryBarrier() _ReadWriteBarrier() -# define PaUtil_ReadMemoryBarrier() _ReadBarrier() -# define PaUtil_WriteMemoryBarrier() _WriteBarrier() -#elif defined(_WIN32_WCE) -# define PaUtil_FullMemoryBarrier() -# define PaUtil_ReadMemoryBarrier() -# define PaUtil_WriteMemoryBarrier() -#elif defined(_MSC_VER) || defined(__BORLANDC__) -# define PaUtil_FullMemoryBarrier() _asm { lock add [esp], 0 } -# define PaUtil_ReadMemoryBarrier() _asm { lock add [esp], 0 } -# define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0 } +/* GCC >= 4.1 has built-in intrinsics. We'll use those */ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) +#define PaUtil_FullMemoryBarrier() __sync_synchronize() +#define PaUtil_ReadMemoryBarrier() __sync_synchronize() +#define PaUtil_WriteMemoryBarrier() __sync_synchronize() +/* as a fallback, GCC understands volatile asm and "memory" to mean it + * should not reorder memory read/writes */ +/* Note that it is not clear that any compiler actually defines __PPC__, + * it can probably removed safely. */ +#elif defined(__ppc__) || defined(__powerpc__) || defined(__PPC__) +#define PaUtil_FullMemoryBarrier() asm volatile("sync" ::: "memory") +#define PaUtil_ReadMemoryBarrier() asm volatile("sync" ::: "memory") +#define PaUtil_WriteMemoryBarrier() asm volatile("sync" ::: "memory") +#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \ + defined(__i686__) || defined(__x86_64__) +#define PaUtil_FullMemoryBarrier() asm volatile("mfence" ::: "memory") +#define PaUtil_ReadMemoryBarrier() asm volatile("lfence" ::: "memory") +#define PaUtil_WriteMemoryBarrier() asm volatile("sfence" ::: "memory") #else -# ifdef ALLOW_SMP_DANGERS -# warning Memory barriers not defined on this system or system unknown -# warning For SMP safety, you should fix this. -# define PaUtil_FullMemoryBarrier() -# define PaUtil_ReadMemoryBarrier() -# define PaUtil_WriteMemoryBarrier() -# else -# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed. -# endif +#ifdef ALLOW_SMP_DANGERS +#warning Memory barriers not defined on this system or system unknown +#warning For SMP safety, you should fix this. +#define PaUtil_FullMemoryBarrier() +#define PaUtil_ReadMemoryBarrier() +#define PaUtil_WriteMemoryBarrier() +#else +# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed. +#endif +#endif +#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE) +#include +#pragma intrinsic(_ReadWriteBarrier) +#pragma intrinsic(_ReadBarrier) +#pragma intrinsic(_WriteBarrier) +#define PaUtil_FullMemoryBarrier() _ReadWriteBarrier() +#define PaUtil_ReadMemoryBarrier() _ReadBarrier() +#define PaUtil_WriteMemoryBarrier() _WriteBarrier() +#elif defined(_WIN32_WCE) +#define PaUtil_FullMemoryBarrier() +#define PaUtil_ReadMemoryBarrier() +#define PaUtil_WriteMemoryBarrier() +#elif defined(_MSC_VER) || defined(__BORLANDC__) +#define PaUtil_FullMemoryBarrier() _asm { lock add [esp], 0} +#define PaUtil_ReadMemoryBarrier() _asm { lock add [esp], 0} +#define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0} +#else +#ifdef ALLOW_SMP_DANGERS +#warning Memory barriers not defined on this system or system unknown +#warning For SMP safety, you should fix this. +#define PaUtil_FullMemoryBarrier() +#define PaUtil_ReadMemoryBarrier() +#define PaUtil_WriteMemoryBarrier() +#else +# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed. +#endif #endif diff --git a/modules/audio_device/mac/portaudio/pa_ringbuffer.h b/modules/audio_device/mac/portaudio/pa_ringbuffer.h index 210a65e4d8..a88a82f864 100644 --- a/modules/audio_device/mac/portaudio/pa_ringbuffer.h +++ b/modules/audio_device/mac/portaudio/pa_ringbuffer.h @@ -8,7 +8,7 @@ * Author: Phil Burk, http://www.softsynth.com * modified for SMP safety on OS X by Bjorn Roche. * also allowed for const where possible. - * modified for multiple-byte-sized data elements by Sven Fischer + * modified for multiple-byte-sized data elements by Sven Fischer * * Note that this is safe only for a single-thread reader * and a single-thread writer. @@ -38,13 +38,13 @@ */ /* - * The text above constitutes the entire PortAudio license; however, + * The text above constitutes the entire PortAudio license; however, * the PortAudio community also makes the following non-binding requests: * * Any person wishing to distribute modifications to the Software is * requested to send the modifications to the original developer so that - * they can be incorporated into the canonical version. It is also - * requested that these non-binding requests be included along with the + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the * license above. */ @@ -58,11 +58,11 @@ a single reader and a single writer (ie. one thread or callback writes to the ring buffer, another thread or callback reads from it). - The PaUtilRingBuffer structure manages a ring buffer containing N - elements, where N must be a power of two. An element may be any size + The PaUtilRingBuffer structure manages a ring buffer containing N + elements, where N must be a power of two. An element may be any size (specified in bytes). - The memory area used to store the buffer elements must be allocated by + The memory area used to store the buffer elements must be allocated by the client prior to calling PaUtil_InitializeRingBuffer() and must outlive the use of the ring buffer. */ @@ -70,7 +70,7 @@ #if defined(__APPLE__) #include typedef int32_t PaRingBufferSize; -#elif defined( __GNUC__ ) +#elif defined(__GNUC__) typedef long PaRingBufferSize; #elif (_MSC_VER >= 1400) typedef long PaRingBufferSize; @@ -80,23 +80,24 @@ typedef long PaRingBufferSize; typedef long PaRingBufferSize; #endif - - #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /* __cplusplus */ -typedef struct PaUtilRingBuffer -{ - PaRingBufferSize bufferSize; /**< Number of elements in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */ - PaRingBufferSize writeIndex; /**< Index of next writable element. Set by PaUtil_AdvanceRingBufferWriteIndex. */ - PaRingBufferSize readIndex; /**< Index of next readable element. Set by PaUtil_AdvanceRingBufferReadIndex. */ - PaRingBufferSize bigMask; /**< Used for wrapping indices with extra bit to distinguish full/empty. */ - PaRingBufferSize smallMask; /**< Used for fitting indices to buffer. */ - PaRingBufferSize elementSizeBytes; /**< Number of bytes per element. */ - char *buffer; /**< Pointer to the buffer containing the actual data. */ -}PaUtilRingBuffer; +typedef struct PaUtilRingBuffer { + PaRingBufferSize + bufferSize; /**< Number of elements in FIFO. Power of 2. Set by + PaUtil_InitRingBuffer. */ + PaRingBufferSize writeIndex; /**< Index of next writable element. Set by + PaUtil_AdvanceRingBufferWriteIndex. */ + PaRingBufferSize readIndex; /**< Index of next readable element. Set by + PaUtil_AdvanceRingBufferReadIndex. */ + PaRingBufferSize bigMask; /**< Used for wrapping indices with extra bit to + distinguish full/empty. */ + PaRingBufferSize smallMask; /**< Used for fitting indices to buffer. */ + PaRingBufferSize elementSizeBytes; /**< Number of bytes per element. */ + char* buffer; /**< Pointer to the buffer containing the actual data. */ +} PaUtilRingBuffer; /** Initialize Ring Buffer. @@ -111,13 +112,16 @@ typedef struct PaUtilRingBuffer @return -1 if elementCount is not a power of 2, otherwise 0. */ -PaRingBufferSize PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, PaRingBufferSize elementSizeBytes, PaRingBufferSize elementCount, void *dataPtr ); +PaRingBufferSize PaUtil_InitializeRingBuffer(PaUtilRingBuffer* rbuf, + PaRingBufferSize elementSizeBytes, + PaRingBufferSize elementCount, + void* dataPtr); /** Clear buffer. Should only be called when buffer is NOT being read. @param rbuf The ring buffer. */ -void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf ); +void PaUtil_FlushRingBuffer(PaUtilRingBuffer* rbuf); /** Retrieve the number of elements available in the ring buffer for writing. @@ -125,7 +129,7 @@ void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf ); @return The number of elements available for writing. */ -PaRingBufferSize PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf ); +PaRingBufferSize PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer* rbuf); /** Retrieve the number of elements available in the ring buffer for reading. @@ -133,7 +137,7 @@ PaRingBufferSize PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf ); @return The number of elements available for reading. */ -PaRingBufferSize PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf ); +PaRingBufferSize PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer* rbuf); /** Write data to the ring buffer. @@ -145,7 +149,9 @@ PaRingBufferSize PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf ); @return The number of elements written. */ -PaRingBufferSize PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, PaRingBufferSize elementCount ); +PaRingBufferSize PaUtil_WriteRingBuffer(PaUtilRingBuffer* rbuf, + const void* data, + PaRingBufferSize elementCount); /** Read data from the ring buffer. @@ -157,7 +163,9 @@ PaRingBufferSize PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *dat @return The number of elements read. */ -PaRingBufferSize PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, PaRingBufferSize elementCount ); +PaRingBufferSize PaUtil_ReadRingBuffer(PaUtilRingBuffer* rbuf, + void* data, + PaRingBufferSize elementCount); /** Get address of region(s) to which we can write data. @@ -179,9 +187,12 @@ PaRingBufferSize PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, PaRi @return The room available to be written or elementCount, whichever is smaller. */ -PaRingBufferSize PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount, - void **dataPtr1, PaRingBufferSize *sizePtr1, - void **dataPtr2, PaRingBufferSize *sizePtr2 ); +PaRingBufferSize PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer* rbuf, + PaRingBufferSize elementCount, + void** dataPtr1, + PaRingBufferSize* sizePtr1, + void** dataPtr2, + PaRingBufferSize* sizePtr2); /** Advance the write index to the next location to be written. @@ -191,7 +202,9 @@ PaRingBufferSize PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, PaRin @return The new position. */ -PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount ); +PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex( + PaUtilRingBuffer* rbuf, + PaRingBufferSize elementCount); /** Get address of region(s) from which we can write data. @@ -213,9 +226,12 @@ PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, PaR @return The number of elements available for reading. */ -PaRingBufferSize PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount, - void **dataPtr1, PaRingBufferSize *sizePtr1, - void **dataPtr2, PaRingBufferSize *sizePtr2 ); +PaRingBufferSize PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer* rbuf, + PaRingBufferSize elementCount, + void** dataPtr1, + PaRingBufferSize* sizePtr1, + void** dataPtr2, + PaRingBufferSize* sizePtr2); /** Advance the read index to the next location to be read. @@ -225,7 +241,9 @@ PaRingBufferSize PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, PaRing @return The new position. */ -PaRingBufferSize PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount ); +PaRingBufferSize PaUtil_AdvanceRingBufferReadIndex( + PaUtilRingBuffer* rbuf, + PaRingBufferSize elementCount); #ifdef __cplusplus } diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc index 731d4614e8..7df2cd03d2 100644 --- a/modules/audio_device/win/audio_device_core_win.cc +++ b/modules/audio_device/win/audio_device_core_win.cc @@ -28,9 +28,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -1959,8 +1959,7 @@ int32_t AudioDeviceWindowsCore::InitPlayout() { RTC_LOG(LS_VERBOSE) << "cbSize : " << Wfx.cbSize; RTC_LOG(LS_VERBOSE) << "Additional settings:"; RTC_LOG(LS_VERBOSE) << "_playAudioFrameSize: " << _playAudioFrameSize; - RTC_LOG(LS_VERBOSE) << "_playBlockSize : " - << _playBlockSize; + RTC_LOG(LS_VERBOSE) << "_playBlockSize : " << _playBlockSize; RTC_LOG(LS_VERBOSE) << "_playChannels : " << _playChannels; } diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h index 1a0123ec40..4984bd954b 100644 --- a/modules/audio_device/win/audio_device_core_win.h +++ b/modules/audio_device/win/audio_device_core_win.h @@ -17,24 +17,24 @@ #include "modules/audio_device/audio_device_generic.h" -#include // CLSID_CWMAudioAEC - // (must be before audioclient.h) -#include // WASAPI +#include // CLSID_CWMAudioAEC + // (must be before audioclient.h) +#include // WASAPI #include -#include // MMDevice -#include // Avrt +#include // Avrt #include -#include // IMediaObject +#include // IMediaObject +#include // MMDevice #include "rtc_base/criticalsection.h" #include "rtc_base/scoped_ref_ptr.h" // Use Multimedia Class Scheduler Service (MMCSS) to boost the thread priority -#pragma comment( lib, "avrt.lib" ) +#pragma comment(lib, "avrt.lib") // AVRT function pointers -typedef BOOL (WINAPI *PAvRevertMmThreadCharacteristics)(HANDLE); -typedef HANDLE (WINAPI *PAvSetMmThreadCharacteristicsA)(LPCSTR, LPDWORD); -typedef BOOL (WINAPI *PAvSetMmThreadPriority)(HANDLE, AVRT_PRIORITY); +typedef BOOL(WINAPI* PAvRevertMmThreadCharacteristics)(HANDLE); +typedef HANDLE(WINAPI* PAvSetMmThreadCharacteristicsA)(LPCSTR, LPDWORD); +typedef BOOL(WINAPI* PAvSetMmThreadPriority)(HANDLE, AVRT_PRIORITY); namespace webrtc { @@ -53,9 +53,7 @@ class ScopedCOMInitializer { enum SelectMTA { kMTA }; // Constructor for STA initialization. - ScopedCOMInitializer() { - Initialize(COINIT_APARTMENTTHREADED); - } + ScopedCOMInitializer() { Initialize(COINIT_APARTMENTTHREADED); } // Constructor for MTA initialization. explicit ScopedCOMInitializer(SelectMTA mta) { @@ -70,9 +68,7 @@ class ScopedCOMInitializer { bool succeeded() const { return SUCCEEDED(hr_); } private: - void Initialize(COINIT init) { - hr_ = CoInitializeEx(NULL, init); - } + void Initialize(COINIT init) { hr_ = CoInitializeEx(NULL, init); } HRESULT hr_; @@ -80,238 +76,246 @@ class ScopedCOMInitializer { void operator=(const ScopedCOMInitializer&); }; +class AudioDeviceWindowsCore : public AudioDeviceGeneric { + public: + AudioDeviceWindowsCore(); + ~AudioDeviceWindowsCore(); -class AudioDeviceWindowsCore : public AudioDeviceGeneric -{ -public: - AudioDeviceWindowsCore(); - ~AudioDeviceWindowsCore(); + static bool CoreAudioIsSupported(); - static bool CoreAudioIsSupported(); + // Retrieve the currently utilized audio layer + virtual int32_t ActiveAudioLayer( + AudioDeviceModule::AudioLayer& audioLayer) const; - // Retrieve the currently utilized audio layer - virtual int32_t ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const; + // Main initializaton and termination + virtual InitStatus Init(); + virtual int32_t Terminate(); + virtual bool Initialized() const; - // Main initializaton and termination - virtual InitStatus Init(); - virtual int32_t Terminate(); - virtual bool Initialized() const; + // Device enumeration + virtual int16_t PlayoutDevices(); + virtual int16_t RecordingDevices(); + virtual int32_t PlayoutDeviceName(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]); + virtual int32_t RecordingDeviceName(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]); - // Device enumeration - virtual int16_t PlayoutDevices(); - virtual int16_t RecordingDevices(); - virtual int32_t PlayoutDeviceName( - uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]); - virtual int32_t RecordingDeviceName( - uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]); + // Device selection + virtual int32_t SetPlayoutDevice(uint16_t index); + virtual int32_t SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device); + virtual int32_t SetRecordingDevice(uint16_t index); + virtual int32_t SetRecordingDevice( + AudioDeviceModule::WindowsDeviceType device); - // Device selection - virtual int32_t SetPlayoutDevice(uint16_t index); - virtual int32_t SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device); - virtual int32_t SetRecordingDevice(uint16_t index); - virtual int32_t SetRecordingDevice(AudioDeviceModule::WindowsDeviceType device); + // Audio transport initialization + virtual int32_t PlayoutIsAvailable(bool& available); + virtual int32_t InitPlayout(); + virtual bool PlayoutIsInitialized() const; + virtual int32_t RecordingIsAvailable(bool& available); + virtual int32_t InitRecording(); + virtual bool RecordingIsInitialized() const; - // Audio transport initialization - virtual int32_t PlayoutIsAvailable(bool& available); - virtual int32_t InitPlayout(); - virtual bool PlayoutIsInitialized() const; - virtual int32_t RecordingIsAvailable(bool& available); - virtual int32_t InitRecording(); - virtual bool RecordingIsInitialized() const; + // Audio transport control + virtual int32_t StartPlayout(); + virtual int32_t StopPlayout(); + virtual bool Playing() const; + virtual int32_t StartRecording(); + virtual int32_t StopRecording(); + virtual bool Recording() const; - // Audio transport control - virtual int32_t StartPlayout(); - virtual int32_t StopPlayout(); - virtual bool Playing() const; - virtual int32_t StartRecording(); - virtual int32_t StopRecording(); - virtual bool Recording() const; + // Audio mixer initialization + virtual int32_t InitSpeaker(); + virtual bool SpeakerIsInitialized() const; + virtual int32_t InitMicrophone(); + virtual bool MicrophoneIsInitialized() const; - // Audio mixer initialization - virtual int32_t InitSpeaker(); - virtual bool SpeakerIsInitialized() const; - virtual int32_t InitMicrophone(); - virtual bool MicrophoneIsInitialized() const; + // Speaker volume controls + virtual int32_t SpeakerVolumeIsAvailable(bool& available); + virtual int32_t SetSpeakerVolume(uint32_t volume); + virtual int32_t SpeakerVolume(uint32_t& volume) const; + virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; + virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const; - // Speaker volume controls - virtual int32_t SpeakerVolumeIsAvailable(bool& available); - virtual int32_t SetSpeakerVolume(uint32_t volume); - virtual int32_t SpeakerVolume(uint32_t& volume) const; - virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const; - virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const; + // Microphone volume controls + virtual int32_t MicrophoneVolumeIsAvailable(bool& available); + virtual int32_t SetMicrophoneVolume(uint32_t volume); + virtual int32_t MicrophoneVolume(uint32_t& volume) const; + virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; + virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const; - // Microphone volume controls - virtual int32_t MicrophoneVolumeIsAvailable(bool& available); - virtual int32_t SetMicrophoneVolume(uint32_t volume); - virtual int32_t MicrophoneVolume(uint32_t& volume) const; - virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const; - virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const; + // Speaker mute control + virtual int32_t SpeakerMuteIsAvailable(bool& available); + virtual int32_t SetSpeakerMute(bool enable); + virtual int32_t SpeakerMute(bool& enabled) const; - // Speaker mute control - virtual int32_t SpeakerMuteIsAvailable(bool& available); - virtual int32_t SetSpeakerMute(bool enable); - virtual int32_t SpeakerMute(bool& enabled) const; + // Microphone mute control + virtual int32_t MicrophoneMuteIsAvailable(bool& available); + virtual int32_t SetMicrophoneMute(bool enable); + virtual int32_t MicrophoneMute(bool& enabled) const; - // Microphone mute control - virtual int32_t MicrophoneMuteIsAvailable(bool& available); - virtual int32_t SetMicrophoneMute(bool enable); - virtual int32_t MicrophoneMute(bool& enabled) const; + // Stereo support + virtual int32_t StereoPlayoutIsAvailable(bool& available); + virtual int32_t SetStereoPlayout(bool enable); + virtual int32_t StereoPlayout(bool& enabled) const; + virtual int32_t StereoRecordingIsAvailable(bool& available); + virtual int32_t SetStereoRecording(bool enable); + virtual int32_t StereoRecording(bool& enabled) const; - // Stereo support - virtual int32_t StereoPlayoutIsAvailable(bool& available); - virtual int32_t SetStereoPlayout(bool enable); - virtual int32_t StereoPlayout(bool& enabled) const; - virtual int32_t StereoRecordingIsAvailable(bool& available); - virtual int32_t SetStereoRecording(bool enable); - virtual int32_t StereoRecording(bool& enabled) const; + // Delay information and control + virtual int32_t PlayoutDelay(uint16_t& delayMS) const; - // Delay information and control - virtual int32_t PlayoutDelay(uint16_t& delayMS) const; + virtual bool BuiltInAECIsAvailable() const; - virtual bool BuiltInAECIsAvailable() const; + virtual int32_t EnableBuiltInAEC(bool enable); - virtual int32_t EnableBuiltInAEC(bool enable); + public: + virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer); -public: - virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer); + private: + bool KeyPressed() const; -private: - bool KeyPressed() const; + private: // avrt function pointers + PAvRevertMmThreadCharacteristics _PAvRevertMmThreadCharacteristics; + PAvSetMmThreadCharacteristicsA _PAvSetMmThreadCharacteristicsA; + PAvSetMmThreadPriority _PAvSetMmThreadPriority; + HMODULE _avrtLibrary; + bool _winSupportAvrt; -private: // avrt function pointers - PAvRevertMmThreadCharacteristics _PAvRevertMmThreadCharacteristics; - PAvSetMmThreadCharacteristicsA _PAvSetMmThreadCharacteristicsA; - PAvSetMmThreadPriority _PAvSetMmThreadPriority; - HMODULE _avrtLibrary; - bool _winSupportAvrt; + private: // thread functions + DWORD InitCaptureThreadPriority(); + void RevertCaptureThreadPriority(); + static DWORD WINAPI WSAPICaptureThread(LPVOID context); + DWORD DoCaptureThread(); -private: // thread functions - DWORD InitCaptureThreadPriority(); - void RevertCaptureThreadPriority(); - static DWORD WINAPI WSAPICaptureThread(LPVOID context); - DWORD DoCaptureThread(); + static DWORD WINAPI WSAPICaptureThreadPollDMO(LPVOID context); + DWORD DoCaptureThreadPollDMO(); - static DWORD WINAPI WSAPICaptureThreadPollDMO(LPVOID context); - DWORD DoCaptureThreadPollDMO(); + static DWORD WINAPI WSAPIRenderThread(LPVOID context); + DWORD DoRenderThread(); - static DWORD WINAPI WSAPIRenderThread(LPVOID context); - DWORD DoRenderThread(); + void _Lock(); + void _UnLock(); - void _Lock(); - void _UnLock(); + int SetDMOProperties(); - int SetDMOProperties(); + int SetBoolProperty(IPropertyStore* ptrPS, + REFPROPERTYKEY key, + VARIANT_BOOL value); - int SetBoolProperty(IPropertyStore* ptrPS, - REFPROPERTYKEY key, - VARIANT_BOOL value); + int SetVtI4Property(IPropertyStore* ptrPS, REFPROPERTYKEY key, LONG value); - int SetVtI4Property(IPropertyStore* ptrPS, - REFPROPERTYKEY key, - LONG value); + int32_t _EnumerateEndpointDevicesAll(EDataFlow dataFlow) const; + void _TraceCOMError(HRESULT hr) const; - int32_t _EnumerateEndpointDevicesAll(EDataFlow dataFlow) const; - void _TraceCOMError(HRESULT hr) const; + int32_t _RefreshDeviceList(EDataFlow dir); + int16_t _DeviceListCount(EDataFlow dir); + int32_t _GetDefaultDeviceName(EDataFlow dir, + ERole role, + LPWSTR szBuffer, + int bufferLen); + int32_t _GetListDeviceName(EDataFlow dir, + int index, + LPWSTR szBuffer, + int bufferLen); + int32_t _GetDeviceName(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen); + int32_t _GetListDeviceID(EDataFlow dir, + int index, + LPWSTR szBuffer, + int bufferLen); + int32_t _GetDefaultDeviceID(EDataFlow dir, + ERole role, + LPWSTR szBuffer, + int bufferLen); + int32_t _GetDefaultDeviceIndex(EDataFlow dir, ERole role, int* index); + int32_t _GetDeviceID(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen); + int32_t _GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice); + int32_t _GetListDevice(EDataFlow dir, int index, IMMDevice** ppDevice); - int32_t _RefreshDeviceList(EDataFlow dir); - int16_t _DeviceListCount(EDataFlow dir); - int32_t _GetDefaultDeviceName(EDataFlow dir, ERole role, LPWSTR szBuffer, int bufferLen); - int32_t _GetListDeviceName(EDataFlow dir, int index, LPWSTR szBuffer, int bufferLen); - int32_t _GetDeviceName(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen); - int32_t _GetListDeviceID(EDataFlow dir, int index, LPWSTR szBuffer, int bufferLen); - int32_t _GetDefaultDeviceID(EDataFlow dir, ERole role, LPWSTR szBuffer, int bufferLen); - int32_t _GetDefaultDeviceIndex(EDataFlow dir, ERole role, int* index); - int32_t _GetDeviceID(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen); - int32_t _GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice); - int32_t _GetListDevice(EDataFlow dir, int index, IMMDevice** ppDevice); + // Converts from wide-char to UTF-8 if UNICODE is defined. + // Does nothing if UNICODE is undefined. + char* WideToUTF8(const TCHAR* src) const; - // Converts from wide-char to UTF-8 if UNICODE is defined. - // Does nothing if UNICODE is undefined. - char* WideToUTF8(const TCHAR* src) const; + int32_t InitRecordingDMO(); - int32_t InitRecordingDMO(); + ScopedCOMInitializer _comInit; + AudioDeviceBuffer* _ptrAudioBuffer; + rtc::CriticalSection _critSect; + rtc::CriticalSection _volumeMutex; - ScopedCOMInitializer _comInit; - AudioDeviceBuffer* _ptrAudioBuffer; - rtc::CriticalSection _critSect; - rtc::CriticalSection _volumeMutex; + IMMDeviceEnumerator* _ptrEnumerator; + IMMDeviceCollection* _ptrRenderCollection; + IMMDeviceCollection* _ptrCaptureCollection; + IMMDevice* _ptrDeviceOut; + IMMDevice* _ptrDeviceIn; - IMMDeviceEnumerator* _ptrEnumerator; - IMMDeviceCollection* _ptrRenderCollection; - IMMDeviceCollection* _ptrCaptureCollection; - IMMDevice* _ptrDeviceOut; - IMMDevice* _ptrDeviceIn; + IAudioClient* _ptrClientOut; + IAudioClient* _ptrClientIn; + IAudioRenderClient* _ptrRenderClient; + IAudioCaptureClient* _ptrCaptureClient; + IAudioEndpointVolume* _ptrCaptureVolume; + ISimpleAudioVolume* _ptrRenderSimpleVolume; - IAudioClient* _ptrClientOut; - IAudioClient* _ptrClientIn; - IAudioRenderClient* _ptrRenderClient; - IAudioCaptureClient* _ptrCaptureClient; - IAudioEndpointVolume* _ptrCaptureVolume; - ISimpleAudioVolume* _ptrRenderSimpleVolume; + // DirectX Media Object (DMO) for the built-in AEC. + rtc::scoped_refptr _dmo; + rtc::scoped_refptr _mediaBuffer; + bool _builtInAecEnabled; - // DirectX Media Object (DMO) for the built-in AEC. - rtc::scoped_refptr _dmo; - rtc::scoped_refptr _mediaBuffer; - bool _builtInAecEnabled; + HANDLE _hRenderSamplesReadyEvent; + HANDLE _hPlayThread; + HANDLE _hRenderStartedEvent; + HANDLE _hShutdownRenderEvent; - HANDLE _hRenderSamplesReadyEvent; - HANDLE _hPlayThread; - HANDLE _hRenderStartedEvent; - HANDLE _hShutdownRenderEvent; + HANDLE _hCaptureSamplesReadyEvent; + HANDLE _hRecThread; + HANDLE _hCaptureStartedEvent; + HANDLE _hShutdownCaptureEvent; - HANDLE _hCaptureSamplesReadyEvent; - HANDLE _hRecThread; - HANDLE _hCaptureStartedEvent; - HANDLE _hShutdownCaptureEvent; + HANDLE _hMmTask; - HANDLE _hMmTask; + UINT _playAudioFrameSize; + uint32_t _playSampleRate; + uint32_t _devicePlaySampleRate; + uint32_t _playBlockSize; + uint32_t _devicePlayBlockSize; + uint32_t _playChannels; + uint32_t _sndCardPlayDelay; + UINT64 _writtenSamples; - UINT _playAudioFrameSize; - uint32_t _playSampleRate; - uint32_t _devicePlaySampleRate; - uint32_t _playBlockSize; - uint32_t _devicePlayBlockSize; - uint32_t _playChannels; - uint32_t _sndCardPlayDelay; - UINT64 _writtenSamples; + UINT _recAudioFrameSize; + uint32_t _recSampleRate; + uint32_t _recBlockSize; + uint32_t _recChannels; + UINT64 _readSamples; + uint32_t _sndCardRecDelay; - UINT _recAudioFrameSize; - uint32_t _recSampleRate; - uint32_t _recBlockSize; - uint32_t _recChannels; - UINT64 _readSamples; - uint32_t _sndCardRecDelay; + uint16_t _recChannelsPrioList[3]; + uint16_t _playChannelsPrioList[2]; - uint16_t _recChannelsPrioList[3]; - uint16_t _playChannelsPrioList[2]; + LARGE_INTEGER _perfCounterFreq; + double _perfCounterFactor; - LARGE_INTEGER _perfCounterFreq; - double _perfCounterFactor; + private: + bool _initialized; + bool _recording; + bool _playing; + bool _recIsInitialized; + bool _playIsInitialized; + bool _speakerIsInitialized; + bool _microphoneIsInitialized; -private: - bool _initialized; - bool _recording; - bool _playing; - bool _recIsInitialized; - bool _playIsInitialized; - bool _speakerIsInitialized; - bool _microphoneIsInitialized; + bool _usingInputDeviceIndex; + bool _usingOutputDeviceIndex; + AudioDeviceModule::WindowsDeviceType _inputDevice; + AudioDeviceModule::WindowsDeviceType _outputDevice; + uint16_t _inputDeviceIndex; + uint16_t _outputDeviceIndex; - bool _usingInputDeviceIndex; - bool _usingOutputDeviceIndex; - AudioDeviceModule::WindowsDeviceType _inputDevice; - AudioDeviceModule::WindowsDeviceType _outputDevice; - uint16_t _inputDeviceIndex; - uint16_t _outputDeviceIndex; - - mutable char _str[512]; + mutable char _str[512]; }; -#endif // #if (_MSC_VER >= 1400) +#endif // #if (_MSC_VER >= 1400) } // namespace webrtc diff --git a/modules/audio_mixer/audio_frame_manipulator_unittest.cc b/modules/audio_mixer/audio_frame_manipulator_unittest.cc index 36148212ea..28154a53c6 100644 --- a/modules/audio_mixer/audio_frame_manipulator_unittest.cc +++ b/modules/audio_mixer/audio_frame_manipulator_unittest.cc @@ -23,8 +23,8 @@ void FillFrameWithConstants(size_t samples_per_channel, frame->num_channels_ = number_of_channels; frame->samples_per_channel_ = samples_per_channel; int16_t* frame_data = frame->mutable_data(); - std::fill(frame_data, - frame_data + samples_per_channel * number_of_channels, value); + std::fill(frame_data, frame_data + samples_per_channel * number_of_channels, + value); } } // namespace diff --git a/modules/audio_mixer/audio_mixer_impl_unittest.cc b/modules/audio_mixer/audio_mixer_impl_unittest.cc index b9e1e73b3f..57e4526c92 100644 --- a/modules/audio_mixer/audio_mixer_impl_unittest.cc +++ b/modules/audio_mixer/audio_mixer_impl_unittest.cc @@ -188,11 +188,11 @@ TEST(AudioMixer, LargestEnergyVadActiveMixed) { if (i == kAudioSources - 1 || i < kAudioSources - 1 - AudioMixerImpl::kMaximumAmountOfMixedAudioSources) { - EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i - << " wrong."; + EXPECT_FALSE(is_mixed) + << "Mixing status of AudioSource #" << i << " wrong."; } else { - EXPECT_TRUE(is_mixed) << "Mixing status of AudioSource #" << i - << " wrong."; + EXPECT_TRUE(is_mixed) + << "Mixing status of AudioSource #" << i << " wrong."; } } } @@ -221,9 +221,8 @@ TEST(AudioMixer, FrameNotModifiedForSingleParticipant) { &audio_frame); } - EXPECT_EQ( - 0, - memcmp(participant.fake_frame()->data(), audio_frame.data(), n_samples)); + EXPECT_EQ(0, memcmp(participant.fake_frame()->data(), audio_frame.data(), + n_samples)); } TEST(AudioMixer, SourceAtNativeRateShouldNeverResample) { diff --git a/modules/audio_processing/aec/aec_core.cc b/modules/audio_processing/aec/aec_core.cc index 43949292b3..95ed595c97 100644 --- a/modules/audio_processing/aec/aec_core.cc +++ b/modules/audio_processing/aec/aec_core.cc @@ -14,11 +14,11 @@ #include "modules/audio_processing/aec/aec_core.h" -#include #include #include // size_t #include #include +#include #include "rtc_base/checks.h" extern "C" { @@ -178,9 +178,7 @@ __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) { // window, of which the length is 1 unit longer than indicated. Remove "+1" when // the code is refactored. PowerLevel::PowerLevel() - : framelevel(kSubCountLen + 1), - averagelevel(kCountLen + 1) { -} + : framelevel(kSubCountLen + 1), averagelevel(kCountLen + 1) {} BlockBuffer::BlockBuffer() { buffer_ = WebRtc_CreateBuffer(kBufferSizeBlocks, sizeof(float) * PART_LEN); @@ -238,10 +236,7 @@ size_t BlockBuffer::AvaliableSpace() { } DivergentFilterFraction::DivergentFilterFraction() - : count_(0), - occurrence_(0), - fraction_(-1.0) { -} + : count_(0), occurrence_(0), fraction_(-1.0) {} void DivergentFilterFraction::Reset() { Clear(); @@ -254,19 +249,18 @@ void DivergentFilterFraction::AddObservation(const PowerLevel& nearlevel, const float near_level = nearlevel.framelevel.GetLatestMean(); const float level_increase = linoutlevel.framelevel.GetLatestMean() - near_level; - const bool output_signal_active = nlpoutlevel.framelevel.GetLatestMean() > - 40.0 * nlpoutlevel.minlevel; + const bool output_signal_active = + nlpoutlevel.framelevel.GetLatestMean() > 40.0 * nlpoutlevel.minlevel; // Level increase should be, in principle, negative, when the filter // does not diverge. Here we allow some margin (0.01 * near end level) and // numerical error (1.0). We count divergence only when the AEC output // signal is active. - if (output_signal_active && - level_increase > std::max(0.01 * near_level, 1.0)) + if (output_signal_active && level_increase > std::max(0.01 * near_level, 1.0)) occurrence_++; ++count_; if (count_ == kDivergentFilterFractionAggregationWindowSize) { fraction_ = static_cast(occurrence_) / - kDivergentFilterFractionAggregationWindowSize; + kDivergentFilterFractionAggregationWindowSize; Clear(); } } @@ -416,9 +410,9 @@ static void Suppress(const float hNl[PART_LEN1], float efw[2][PART_LEN1]) { } } -static int PartitionDelay(int num_partitions, - float h_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1]) { +static int PartitionDelay( + int num_partitions, + float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1]) { // Measures the energy in each filter partition and returns the partition with // highest energy. // TODO(bjornv): Spread computational cost by computing one partition per @@ -445,7 +439,8 @@ static int PartitionDelay(int num_partitions, } // Update metric with 10 * log10(numerator / denominator). -static void UpdateLogRatioMetric(Stats* metric, float numerator, +static void UpdateLogRatioMetric(Stats* metric, + float numerator, float denominator) { RTC_DCHECK(metric); RTC_CHECK(numerator >= 0); @@ -736,9 +731,8 @@ static void UpdateMetrics(AecCore* aec) { } if (aec->linoutlevel.framelevel.EndOfBlock()) { - aec->divergent_filter_fraction.AddObservation(aec->nearlevel, - aec->linoutlevel, - aec->nlpoutlevel); + aec->divergent_filter_fraction.AddObservation( + aec->nearlevel, aec->linoutlevel, aec->nlpoutlevel); } if (aec->farlevel.averagelevel.EndOfBlock()) { @@ -755,7 +749,6 @@ static void UpdateMetrics(AecCore* aec) { if ((aec->stateCounter > (0.5f * kCountLen * kSubCountLen)) && (aec->farlevel.framelevel.EndOfBlock()) && (far_average_level > (actThreshold * aec->farlevel.minlevel))) { - // ERL: error return loss. const float near_average_level = aec->nearlevel.averagelevel.GetLatestMean(); @@ -815,9 +808,9 @@ static void UpdateDelayMetrics(AecCore* self) { for (i = 0; i < kHistorySizeBlocks; i++) { l1_norm += abs(i - median) * self->delay_histogram[i]; } - self->delay_std = - static_cast((l1_norm + self->num_delay_values / 2) / - self->num_delay_values) * kMsPerBlock; + self->delay_std = static_cast((l1_norm + self->num_delay_values / 2) / + self->num_delay_values) * + kMsPerBlock; // Determine fraction of delays that are out of bounds, that is, either // negative (anti-causal system) or larger than the AEC filter length. @@ -949,11 +942,11 @@ static int SignalBasedDelayCorrection(AecCore* self) { return delay_correction; } -static void RegressorPower(int num_partitions, - int latest_added_partition, - float x_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float x_pow[PART_LEN1]) { +static void RegressorPower( + int num_partitions, + int latest_added_partition, + float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float x_pow[PART_LEN1]) { RTC_DCHECK_LT(latest_added_partition, num_partitions); memset(x_pow, 0, PART_LEN1 * sizeof(x_pow[0])); @@ -976,21 +969,20 @@ static void RegressorPower(int num_partitions, } } -static void EchoSubtraction(const OouraFft& ooura_fft, - int num_partitions, - int extended_filter_enabled, - int* extreme_filter_divergence, - float filter_step_size, - float error_threshold, - float* x_fft, - int* x_fft_buf_block_pos, - float x_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float* const y, - float x_pow[PART_LEN1], - float h_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float echo_subtractor_output[PART_LEN]) { +static void EchoSubtraction( + const OouraFft& ooura_fft, + int num_partitions, + int extended_filter_enabled, + int* extreme_filter_divergence, + float filter_step_size, + float error_threshold, + float* x_fft, + int* x_fft_buf_block_pos, + float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float* const y, + float x_pow[PART_LEN1], + float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float echo_subtractor_output[PART_LEN]) { float s_fft[2][PART_LEN1]; float e_extended[PART_LEN2]; float s_extended[PART_LEN2]; @@ -1118,10 +1110,10 @@ static void FormSuppressionGain(AecCore* aec, // preferred. memcpy(hNlPref, &hNl[minPrefBand], sizeof(float) * prefBandSize); qsort(hNlPref, prefBandSize, sizeof(float), CmpFloat); - hNlFb = hNlPref[static_cast(floor(prefBandQuant * - (prefBandSize - 1)))]; - hNlFbLow = hNlPref[static_cast(floor(prefBandQuantLow * - (prefBandSize - 1)))]; + hNlFb = + hNlPref[static_cast(floor(prefBandQuant * (prefBandSize - 1)))]; + hNlFbLow = hNlPref[static_cast( + floor(prefBandQuantLow * (prefBandSize - 1)))]; } } @@ -1142,10 +1134,10 @@ static void FormSuppressionGain(AecCore* aec, if (aec->hNlMinCtr == 2) { aec->hNlNewMin = 0; aec->hNlMinCtr = 0; - aec->overDrive = - WEBRTC_SPL_MAX(kTargetSupp[aec->nlp_mode] / - static_cast(log(aec->hNlFbMin + 1e-10f) + 1e-10f), - min_overdrive[aec->nlp_mode]); + aec->overDrive = WEBRTC_SPL_MAX( + kTargetSupp[aec->nlp_mode] / + static_cast(log(aec->hNlFbMin + 1e-10f) + 1e-10f), + min_overdrive[aec->nlp_mode]); } // Smooth the overdrive. @@ -1773,20 +1765,18 @@ void BufferNearendFrame( float nearend_buffer[NUM_HIGH_BANDS_MAX + 1] [PART_LEN - (FRAME_LEN - PART_LEN)]) { for (size_t i = 0; i < num_bands; ++i) { - memcpy( - &nearend_buffer[i][0], - &nearend_frame[i] - [nearend_start_index + FRAME_LEN - num_samples_to_buffer], - num_samples_to_buffer * sizeof(float)); + memcpy(&nearend_buffer[i][0], + &nearend_frame[i][nearend_start_index + FRAME_LEN - + num_samples_to_buffer], + num_samples_to_buffer * sizeof(float)); } } -void BufferOutputBlock(size_t num_bands, - const float output_block[NUM_HIGH_BANDS_MAX + 1] - [PART_LEN], - size_t* output_buffer_size, - float output_buffer[NUM_HIGH_BANDS_MAX + 1] - [2 * PART_LEN]) { +void BufferOutputBlock( + size_t num_bands, + const float output_block[NUM_HIGH_BANDS_MAX + 1][PART_LEN], + size_t* output_buffer_size, + float output_buffer[NUM_HIGH_BANDS_MAX + 1][2 * PART_LEN]) { for (size_t i = 0; i < num_bands; ++i) { memcpy(&output_buffer[i][*output_buffer_size], &output_block[i][0], PART_LEN * sizeof(float)); diff --git a/modules/audio_processing/aec/aec_core_mips.cc b/modules/audio_processing/aec/aec_core_mips.cc index ebe6349e93..bf89cfaf93 100644 --- a/modules/audio_processing/aec/aec_core_mips.cc +++ b/modules/audio_processing/aec/aec_core_mips.cc @@ -51,95 +51,94 @@ void WebRtcAec_FilterFar_mips( int len = PART_LEN1 >> 1; __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "1: \n\t" - "lwc1 %[f0], 0(%[aRe]) \n\t" - "lwc1 %[f1], 0(%[bRe]) \n\t" - "lwc1 %[f2], 0(%[bIm]) \n\t" - "lwc1 %[f3], 0(%[aIm]) \n\t" - "lwc1 %[f4], 4(%[aRe]) \n\t" - "lwc1 %[f5], 4(%[bRe]) \n\t" - "lwc1 %[f6], 4(%[bIm]) \n\t" - "mul.s %[f8], %[f0], %[f1] \n\t" - "mul.s %[f0], %[f0], %[f2] \n\t" - "mul.s %[f9], %[f4], %[f5] \n\t" - "mul.s %[f4], %[f4], %[f6] \n\t" - "lwc1 %[f7], 4(%[aIm]) \n\t" + ".set push \n\t" + ".set noreorder \n\t" + "1: \n\t" + "lwc1 %[f0], 0(%[aRe]) \n\t" + "lwc1 %[f1], 0(%[bRe]) \n\t" + "lwc1 %[f2], 0(%[bIm]) \n\t" + "lwc1 %[f3], 0(%[aIm]) \n\t" + "lwc1 %[f4], 4(%[aRe]) \n\t" + "lwc1 %[f5], 4(%[bRe]) \n\t" + "lwc1 %[f6], 4(%[bIm]) \n\t" + "mul.s %[f8], %[f0], %[f1] \n\t" + "mul.s %[f0], %[f0], %[f2] \n\t" + "mul.s %[f9], %[f4], %[f5] \n\t" + "mul.s %[f4], %[f4], %[f6] \n\t" + "lwc1 %[f7], 4(%[aIm]) \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f12], %[f2], %[f3] \n\t" - "mul.s %[f1], %[f3], %[f1] \n\t" - "mul.s %[f11], %[f6], %[f7] \n\t" - "addiu %[aRe], %[aRe], 8 \n\t" - "addiu %[aIm], %[aIm], 8 \n\t" - "addiu %[len], %[len], -1 \n\t" - "sub.s %[f8], %[f8], %[f12] \n\t" - "mul.s %[f12], %[f7], %[f5] \n\t" - "lwc1 %[f2], 0(%[yf0]) \n\t" - "add.s %[f1], %[f0], %[f1] \n\t" - "lwc1 %[f3], 0(%[yf1]) \n\t" - "sub.s %[f9], %[f9], %[f11] \n\t" - "lwc1 %[f6], 4(%[yf0]) \n\t" - "add.s %[f4], %[f4], %[f12] \n\t" -#else // #if !defined(MIPS32_R2_LE) - "addiu %[aRe], %[aRe], 8 \n\t" - "addiu %[aIm], %[aIm], 8 \n\t" - "addiu %[len], %[len], -1 \n\t" - "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t" - "lwc1 %[f2], 0(%[yf0]) \n\t" - "madd.s %[f1], %[f0], %[f3], %[f1] \n\t" - "lwc1 %[f3], 0(%[yf1]) \n\t" - "nmsub.s %[f9], %[f9], %[f6], %[f7] \n\t" - "lwc1 %[f6], 4(%[yf0]) \n\t" - "madd.s %[f4], %[f4], %[f7], %[f5] \n\t" + "mul.s %[f12], %[f2], %[f3] \n\t" + "mul.s %[f1], %[f3], %[f1] \n\t" + "mul.s %[f11], %[f6], %[f7] \n\t" + "addiu %[aRe], %[aRe], 8 \n\t" + "addiu %[aIm], %[aIm], 8 \n\t" + "addiu %[len], %[len], -1 \n\t" + "sub.s %[f8], %[f8], %[f12] \n\t" + "mul.s %[f12], %[f7], %[f5] \n\t" + "lwc1 %[f2], 0(%[yf0]) \n\t" + "add.s %[f1], %[f0], %[f1] \n\t" + "lwc1 %[f3], 0(%[yf1]) \n\t" + "sub.s %[f9], %[f9], %[f11] \n\t" + "lwc1 %[f6], 4(%[yf0]) \n\t" + "add.s %[f4], %[f4], %[f12] \n\t" +#else // #if !defined(MIPS32_R2_LE) + "addiu %[aRe], %[aRe], 8 \n\t" + "addiu %[aIm], %[aIm], 8 \n\t" + "addiu %[len], %[len], -1 \n\t" + "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t" + "lwc1 %[f2], 0(%[yf0]) \n\t" + "madd.s %[f1], %[f0], %[f3], %[f1] \n\t" + "lwc1 %[f3], 0(%[yf1]) \n\t" + "nmsub.s %[f9], %[f9], %[f6], %[f7] \n\t" + "lwc1 %[f6], 4(%[yf0]) \n\t" + "madd.s %[f4], %[f4], %[f7], %[f5] \n\t" #endif // #if !defined(MIPS32_R2_LE) - "lwc1 %[f5], 4(%[yf1]) \n\t" - "add.s %[f2], %[f2], %[f8] \n\t" - "addiu %[bRe], %[bRe], 8 \n\t" - "addiu %[bIm], %[bIm], 8 \n\t" - "add.s %[f3], %[f3], %[f1] \n\t" - "add.s %[f6], %[f6], %[f9] \n\t" - "add.s %[f5], %[f5], %[f4] \n\t" - "swc1 %[f2], 0(%[yf0]) \n\t" - "swc1 %[f3], 0(%[yf1]) \n\t" - "swc1 %[f6], 4(%[yf0]) \n\t" - "swc1 %[f5], 4(%[yf1]) \n\t" - "addiu %[yf0], %[yf0], 8 \n\t" - "bgtz %[len], 1b \n\t" - " addiu %[yf1], %[yf1], 8 \n\t" - "lwc1 %[f0], 0(%[aRe]) \n\t" - "lwc1 %[f1], 0(%[bRe]) \n\t" - "lwc1 %[f2], 0(%[bIm]) \n\t" - "lwc1 %[f3], 0(%[aIm]) \n\t" - "mul.s %[f8], %[f0], %[f1] \n\t" - "mul.s %[f0], %[f0], %[f2] \n\t" + "lwc1 %[f5], 4(%[yf1]) \n\t" + "add.s %[f2], %[f2], %[f8] \n\t" + "addiu %[bRe], %[bRe], 8 \n\t" + "addiu %[bIm], %[bIm], 8 \n\t" + "add.s %[f3], %[f3], %[f1] \n\t" + "add.s %[f6], %[f6], %[f9] \n\t" + "add.s %[f5], %[f5], %[f4] \n\t" + "swc1 %[f2], 0(%[yf0]) \n\t" + "swc1 %[f3], 0(%[yf1]) \n\t" + "swc1 %[f6], 4(%[yf0]) \n\t" + "swc1 %[f5], 4(%[yf1]) \n\t" + "addiu %[yf0], %[yf0], 8 \n\t" + "bgtz %[len], 1b \n\t" + " addiu %[yf1], %[yf1], 8 \n\t" + "lwc1 %[f0], 0(%[aRe]) \n\t" + "lwc1 %[f1], 0(%[bRe]) \n\t" + "lwc1 %[f2], 0(%[bIm]) \n\t" + "lwc1 %[f3], 0(%[aIm]) \n\t" + "mul.s %[f8], %[f0], %[f1] \n\t" + "mul.s %[f0], %[f0], %[f2] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f12], %[f2], %[f3] \n\t" - "mul.s %[f1], %[f3], %[f1] \n\t" - "sub.s %[f8], %[f8], %[f12] \n\t" - "lwc1 %[f2], 0(%[yf0]) \n\t" - "add.s %[f1], %[f0], %[f1] \n\t" - "lwc1 %[f3], 0(%[yf1]) \n\t" -#else // #if !defined(MIPS32_R2_LE) - "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t" - "lwc1 %[f2], 0(%[yf0]) \n\t" - "madd.s %[f1], %[f0], %[f3], %[f1] \n\t" - "lwc1 %[f3], 0(%[yf1]) \n\t" + "mul.s %[f12], %[f2], %[f3] \n\t" + "mul.s %[f1], %[f3], %[f1] \n\t" + "sub.s %[f8], %[f8], %[f12] \n\t" + "lwc1 %[f2], 0(%[yf0]) \n\t" + "add.s %[f1], %[f0], %[f1] \n\t" + "lwc1 %[f3], 0(%[yf1]) \n\t" +#else // #if !defined(MIPS32_R2_LE) + "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t" + "lwc1 %[f2], 0(%[yf0]) \n\t" + "madd.s %[f1], %[f0], %[f3], %[f1] \n\t" + "lwc1 %[f3], 0(%[yf1]) \n\t" #endif // #if !defined(MIPS32_R2_LE) - "add.s %[f2], %[f2], %[f8] \n\t" - "add.s %[f3], %[f3], %[f1] \n\t" - "swc1 %[f2], 0(%[yf0]) \n\t" - "swc1 %[f3], 0(%[yf1]) \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), - [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5), - [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8), - [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), - [f12] "=&f" (f12), [f13] "=&f" (f13), [aRe] "+r" (aRe), - [aIm] "+r" (aIm), [bRe] "+r" (bRe), [bIm] "+r" (bIm), - [yf0] "+r" (yf0), [yf1] "+r" (yf1), [len] "+r" (len) - : - : "memory"); + "add.s %[f2], %[f2], %[f8] \n\t" + "add.s %[f3], %[f3], %[f1] \n\t" + "swc1 %[f2], 0(%[yf0]) \n\t" + "swc1 %[f3], 0(%[yf1]) \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), + [f12] "=&f"(f12), [f13] "=&f"(f13), [aRe] "+r"(aRe), [aIm] "+r"(aIm), + [bRe] "+r"(bRe), [bIm] "+r"(bIm), [yf0] "+r"(yf0), [yf1] "+r"(yf1), + [len] "+r"(len) + : + : "memory"); } } @@ -171,73 +170,71 @@ void WebRtcAec_FilterAdaptation_mips( int len = PART_LEN >> 1; __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[fft_tmp], %[fft], 0 \n\t" - "1: \n\t" - "lwc1 %[f0], 0(%[aRe]) \n\t" - "lwc1 %[f1], 0(%[bRe]) \n\t" - "lwc1 %[f2], 0(%[bIm]) \n\t" - "lwc1 %[f4], 4(%[aRe]) \n\t" - "lwc1 %[f5], 4(%[bRe]) \n\t" - "lwc1 %[f6], 4(%[bIm]) \n\t" - "addiu %[aRe], %[aRe], 8 \n\t" - "addiu %[bRe], %[bRe], 8 \n\t" - "mul.s %[f8], %[f0], %[f1] \n\t" - "mul.s %[f0], %[f0], %[f2] \n\t" - "lwc1 %[f3], 0(%[aIm]) \n\t" - "mul.s %[f9], %[f4], %[f5] \n\t" - "lwc1 %[f7], 4(%[aIm]) \n\t" - "mul.s %[f4], %[f4], %[f6] \n\t" + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[fft_tmp], %[fft], 0 \n\t" + "1: \n\t" + "lwc1 %[f0], 0(%[aRe]) \n\t" + "lwc1 %[f1], 0(%[bRe]) \n\t" + "lwc1 %[f2], 0(%[bIm]) \n\t" + "lwc1 %[f4], 4(%[aRe]) \n\t" + "lwc1 %[f5], 4(%[bRe]) \n\t" + "lwc1 %[f6], 4(%[bIm]) \n\t" + "addiu %[aRe], %[aRe], 8 \n\t" + "addiu %[bRe], %[bRe], 8 \n\t" + "mul.s %[f8], %[f0], %[f1] \n\t" + "mul.s %[f0], %[f0], %[f2] \n\t" + "lwc1 %[f3], 0(%[aIm]) \n\t" + "mul.s %[f9], %[f4], %[f5] \n\t" + "lwc1 %[f7], 4(%[aIm]) \n\t" + "mul.s %[f4], %[f4], %[f6] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f10], %[f3], %[f2] \n\t" - "mul.s %[f1], %[f3], %[f1] \n\t" - "mul.s %[f11], %[f7], %[f6] \n\t" - "mul.s %[f5], %[f7], %[f5] \n\t" - "addiu %[aIm], %[aIm], 8 \n\t" - "addiu %[bIm], %[bIm], 8 \n\t" - "addiu %[len], %[len], -1 \n\t" - "add.s %[f8], %[f8], %[f10] \n\t" - "sub.s %[f1], %[f0], %[f1] \n\t" - "add.s %[f9], %[f9], %[f11] \n\t" - "sub.s %[f5], %[f4], %[f5] \n\t" -#else // #if !defined(MIPS32_R2_LE) - "addiu %[aIm], %[aIm], 8 \n\t" - "addiu %[bIm], %[bIm], 8 \n\t" - "addiu %[len], %[len], -1 \n\t" - "madd.s %[f8], %[f8], %[f3], %[f2] \n\t" - "nmsub.s %[f1], %[f0], %[f3], %[f1] \n\t" - "madd.s %[f9], %[f9], %[f7], %[f6] \n\t" - "nmsub.s %[f5], %[f4], %[f7], %[f5] \n\t" + "mul.s %[f10], %[f3], %[f2] \n\t" + "mul.s %[f1], %[f3], %[f1] \n\t" + "mul.s %[f11], %[f7], %[f6] \n\t" + "mul.s %[f5], %[f7], %[f5] \n\t" + "addiu %[aIm], %[aIm], 8 \n\t" + "addiu %[bIm], %[bIm], 8 \n\t" + "addiu %[len], %[len], -1 \n\t" + "add.s %[f8], %[f8], %[f10] \n\t" + "sub.s %[f1], %[f0], %[f1] \n\t" + "add.s %[f9], %[f9], %[f11] \n\t" + "sub.s %[f5], %[f4], %[f5] \n\t" +#else // #if !defined(MIPS32_R2_LE) + "addiu %[aIm], %[aIm], 8 \n\t" + "addiu %[bIm], %[bIm], 8 \n\t" + "addiu %[len], %[len], -1 \n\t" + "madd.s %[f8], %[f8], %[f3], %[f2] \n\t" + "nmsub.s %[f1], %[f0], %[f3], %[f1] \n\t" + "madd.s %[f9], %[f9], %[f7], %[f6] \n\t" + "nmsub.s %[f5], %[f4], %[f7], %[f5] \n\t" #endif // #if !defined(MIPS32_R2_LE) - "swc1 %[f8], 0(%[fft_tmp]) \n\t" - "swc1 %[f1], 4(%[fft_tmp]) \n\t" - "swc1 %[f9], 8(%[fft_tmp]) \n\t" - "swc1 %[f5], 12(%[fft_tmp]) \n\t" - "bgtz %[len], 1b \n\t" - " addiu %[fft_tmp], %[fft_tmp], 16 \n\t" - "lwc1 %[f0], 0(%[aRe]) \n\t" - "lwc1 %[f1], 0(%[bRe]) \n\t" - "lwc1 %[f2], 0(%[bIm]) \n\t" - "lwc1 %[f3], 0(%[aIm]) \n\t" - "mul.s %[f8], %[f0], %[f1] \n\t" + "swc1 %[f8], 0(%[fft_tmp]) \n\t" + "swc1 %[f1], 4(%[fft_tmp]) \n\t" + "swc1 %[f9], 8(%[fft_tmp]) \n\t" + "swc1 %[f5], 12(%[fft_tmp]) \n\t" + "bgtz %[len], 1b \n\t" + " addiu %[fft_tmp], %[fft_tmp], 16 \n\t" + "lwc1 %[f0], 0(%[aRe]) \n\t" + "lwc1 %[f1], 0(%[bRe]) \n\t" + "lwc1 %[f2], 0(%[bIm]) \n\t" + "lwc1 %[f3], 0(%[aIm]) \n\t" + "mul.s %[f8], %[f0], %[f1] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f10], %[f3], %[f2] \n\t" - "add.s %[f8], %[f8], %[f10] \n\t" -#else // #if !defined(MIPS32_R2_LE) - "madd.s %[f8], %[f8], %[f3], %[f2] \n\t" + "mul.s %[f10], %[f3], %[f2] \n\t" + "add.s %[f8], %[f8], %[f10] \n\t" +#else // #if !defined(MIPS32_R2_LE) + "madd.s %[f8], %[f8], %[f3], %[f2] \n\t" #endif // #if !defined(MIPS32_R2_LE) - "swc1 %[f8], 4(%[fft]) \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), - [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5), - [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8), - [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), - [f12] "=&f" (f12), [aRe] "+r" (aRe), [aIm] "+r" (aIm), - [bRe] "+r" (bRe), [bIm] "+r" (bIm), [fft_tmp] "=&r" (fft_tmp), - [len] "+r" (len) - : [fft] "r" (fft) - : "memory"); + "swc1 %[f8], 4(%[fft]) \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), + [f12] "=&f"(f12), [aRe] "+r"(aRe), [aIm] "+r"(aIm), [bRe] "+r"(bRe), + [bIm] "+r"(bIm), [fft_tmp] "=&r"(fft_tmp), [len] "+r"(len) + : [fft] "r"(fft) + : "memory"); ooura_fft.InverseFft(fft); memset(fft + PART_LEN, 0, sizeof(float) * PART_LEN); @@ -246,102 +243,101 @@ void WebRtcAec_FilterAdaptation_mips( { float scale = 2.0f / PART_LEN2; __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[fft_tmp], %[fft], 0 \n\t" - "addiu %[len], $zero, 8 \n\t" - "1: \n\t" - "addiu %[len], %[len], -1 \n\t" - "lwc1 %[f0], 0(%[fft_tmp]) \n\t" - "lwc1 %[f1], 4(%[fft_tmp]) \n\t" - "lwc1 %[f2], 8(%[fft_tmp]) \n\t" - "lwc1 %[f3], 12(%[fft_tmp]) \n\t" - "mul.s %[f0], %[f0], %[scale] \n\t" - "mul.s %[f1], %[f1], %[scale] \n\t" - "mul.s %[f2], %[f2], %[scale] \n\t" - "mul.s %[f3], %[f3], %[scale] \n\t" - "lwc1 %[f4], 16(%[fft_tmp]) \n\t" - "lwc1 %[f5], 20(%[fft_tmp]) \n\t" - "lwc1 %[f6], 24(%[fft_tmp]) \n\t" - "lwc1 %[f7], 28(%[fft_tmp]) \n\t" - "mul.s %[f4], %[f4], %[scale] \n\t" - "mul.s %[f5], %[f5], %[scale] \n\t" - "mul.s %[f6], %[f6], %[scale] \n\t" - "mul.s %[f7], %[f7], %[scale] \n\t" - "swc1 %[f0], 0(%[fft_tmp]) \n\t" - "swc1 %[f1], 4(%[fft_tmp]) \n\t" - "swc1 %[f2], 8(%[fft_tmp]) \n\t" - "swc1 %[f3], 12(%[fft_tmp]) \n\t" - "swc1 %[f4], 16(%[fft_tmp]) \n\t" - "swc1 %[f5], 20(%[fft_tmp]) \n\t" - "swc1 %[f6], 24(%[fft_tmp]) \n\t" - "swc1 %[f7], 28(%[fft_tmp]) \n\t" - "bgtz %[len], 1b \n\t" - " addiu %[fft_tmp], %[fft_tmp], 32 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), - [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5), - [f6] "=&f" (f6), [f7] "=&f" (f7), [len] "=&r" (len), - [fft_tmp] "=&r" (fft_tmp) - : [scale] "f" (scale), [fft] "r" (fft) - : "memory"); + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[fft_tmp], %[fft], 0 \n\t" + "addiu %[len], $zero, 8 \n\t" + "1: \n\t" + "addiu %[len], %[len], -1 \n\t" + "lwc1 %[f0], 0(%[fft_tmp]) \n\t" + "lwc1 %[f1], 4(%[fft_tmp]) \n\t" + "lwc1 %[f2], 8(%[fft_tmp]) \n\t" + "lwc1 %[f3], 12(%[fft_tmp]) \n\t" + "mul.s %[f0], %[f0], %[scale] \n\t" + "mul.s %[f1], %[f1], %[scale] \n\t" + "mul.s %[f2], %[f2], %[scale] \n\t" + "mul.s %[f3], %[f3], %[scale] \n\t" + "lwc1 %[f4], 16(%[fft_tmp]) \n\t" + "lwc1 %[f5], 20(%[fft_tmp]) \n\t" + "lwc1 %[f6], 24(%[fft_tmp]) \n\t" + "lwc1 %[f7], 28(%[fft_tmp]) \n\t" + "mul.s %[f4], %[f4], %[scale] \n\t" + "mul.s %[f5], %[f5], %[scale] \n\t" + "mul.s %[f6], %[f6], %[scale] \n\t" + "mul.s %[f7], %[f7], %[scale] \n\t" + "swc1 %[f0], 0(%[fft_tmp]) \n\t" + "swc1 %[f1], 4(%[fft_tmp]) \n\t" + "swc1 %[f2], 8(%[fft_tmp]) \n\t" + "swc1 %[f3], 12(%[fft_tmp]) \n\t" + "swc1 %[f4], 16(%[fft_tmp]) \n\t" + "swc1 %[f5], 20(%[fft_tmp]) \n\t" + "swc1 %[f6], 24(%[fft_tmp]) \n\t" + "swc1 %[f7], 28(%[fft_tmp]) \n\t" + "bgtz %[len], 1b \n\t" + " addiu %[fft_tmp], %[fft_tmp], 32 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [len] "=&r"(len), [fft_tmp] "=&r"(fft_tmp) + : [scale] "f"(scale), [fft] "r"(fft) + : "memory"); } ooura_fft.Fft(fft); aRe = h_fft_buf[0] + pos; aIm = h_fft_buf[1] + pos; __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[fft_tmp], %[fft], 0 \n\t" - "addiu %[len], $zero, 31 \n\t" - "lwc1 %[f0], 0(%[aRe]) \n\t" - "lwc1 %[f1], 0(%[fft_tmp]) \n\t" - "lwc1 %[f2], 256(%[aRe]) \n\t" - "lwc1 %[f3], 4(%[fft_tmp]) \n\t" - "lwc1 %[f4], 4(%[aRe]) \n\t" - "lwc1 %[f5], 8(%[fft_tmp]) \n\t" - "lwc1 %[f6], 4(%[aIm]) \n\t" - "lwc1 %[f7], 12(%[fft_tmp]) \n\t" - "add.s %[f0], %[f0], %[f1] \n\t" - "add.s %[f2], %[f2], %[f3] \n\t" - "add.s %[f4], %[f4], %[f5] \n\t" - "add.s %[f6], %[f6], %[f7] \n\t" - "addiu %[fft_tmp], %[fft_tmp], 16 \n\t" - "swc1 %[f0], 0(%[aRe]) \n\t" - "swc1 %[f2], 256(%[aRe]) \n\t" - "swc1 %[f4], 4(%[aRe]) \n\t" - "addiu %[aRe], %[aRe], 8 \n\t" - "swc1 %[f6], 4(%[aIm]) \n\t" - "addiu %[aIm], %[aIm], 8 \n\t" - "1: \n\t" - "lwc1 %[f0], 0(%[aRe]) \n\t" - "lwc1 %[f1], 0(%[fft_tmp]) \n\t" - "lwc1 %[f2], 0(%[aIm]) \n\t" - "lwc1 %[f3], 4(%[fft_tmp]) \n\t" - "lwc1 %[f4], 4(%[aRe]) \n\t" - "lwc1 %[f5], 8(%[fft_tmp]) \n\t" - "lwc1 %[f6], 4(%[aIm]) \n\t" - "lwc1 %[f7], 12(%[fft_tmp]) \n\t" - "add.s %[f0], %[f0], %[f1] \n\t" - "add.s %[f2], %[f2], %[f3] \n\t" - "add.s %[f4], %[f4], %[f5] \n\t" - "add.s %[f6], %[f6], %[f7] \n\t" - "addiu %[len], %[len], -1 \n\t" - "addiu %[fft_tmp], %[fft_tmp], 16 \n\t" - "swc1 %[f0], 0(%[aRe]) \n\t" - "swc1 %[f2], 0(%[aIm]) \n\t" - "swc1 %[f4], 4(%[aRe]) \n\t" - "addiu %[aRe], %[aRe], 8 \n\t" - "swc1 %[f6], 4(%[aIm]) \n\t" - "bgtz %[len], 1b \n\t" - " addiu %[aIm], %[aIm], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), - [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5), - [f6] "=&f" (f6), [f7] "=&f" (f7), [len] "=&r" (len), - [fft_tmp] "=&r" (fft_tmp), [aRe] "+r" (aRe), [aIm] "+r" (aIm) - : [fft] "r" (fft) - : "memory"); + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[fft_tmp], %[fft], 0 \n\t" + "addiu %[len], $zero, 31 \n\t" + "lwc1 %[f0], 0(%[aRe]) \n\t" + "lwc1 %[f1], 0(%[fft_tmp]) \n\t" + "lwc1 %[f2], 256(%[aRe]) \n\t" + "lwc1 %[f3], 4(%[fft_tmp]) \n\t" + "lwc1 %[f4], 4(%[aRe]) \n\t" + "lwc1 %[f5], 8(%[fft_tmp]) \n\t" + "lwc1 %[f6], 4(%[aIm]) \n\t" + "lwc1 %[f7], 12(%[fft_tmp]) \n\t" + "add.s %[f0], %[f0], %[f1] \n\t" + "add.s %[f2], %[f2], %[f3] \n\t" + "add.s %[f4], %[f4], %[f5] \n\t" + "add.s %[f6], %[f6], %[f7] \n\t" + "addiu %[fft_tmp], %[fft_tmp], 16 \n\t" + "swc1 %[f0], 0(%[aRe]) \n\t" + "swc1 %[f2], 256(%[aRe]) \n\t" + "swc1 %[f4], 4(%[aRe]) \n\t" + "addiu %[aRe], %[aRe], 8 \n\t" + "swc1 %[f6], 4(%[aIm]) \n\t" + "addiu %[aIm], %[aIm], 8 \n\t" + "1: \n\t" + "lwc1 %[f0], 0(%[aRe]) \n\t" + "lwc1 %[f1], 0(%[fft_tmp]) \n\t" + "lwc1 %[f2], 0(%[aIm]) \n\t" + "lwc1 %[f3], 4(%[fft_tmp]) \n\t" + "lwc1 %[f4], 4(%[aRe]) \n\t" + "lwc1 %[f5], 8(%[fft_tmp]) \n\t" + "lwc1 %[f6], 4(%[aIm]) \n\t" + "lwc1 %[f7], 12(%[fft_tmp]) \n\t" + "add.s %[f0], %[f0], %[f1] \n\t" + "add.s %[f2], %[f2], %[f3] \n\t" + "add.s %[f4], %[f4], %[f5] \n\t" + "add.s %[f6], %[f6], %[f7] \n\t" + "addiu %[len], %[len], -1 \n\t" + "addiu %[fft_tmp], %[fft_tmp], 16 \n\t" + "swc1 %[f0], 0(%[aRe]) \n\t" + "swc1 %[f2], 0(%[aIm]) \n\t" + "swc1 %[f4], 4(%[aRe]) \n\t" + "addiu %[aRe], %[aRe], 8 \n\t" + "swc1 %[f6], 4(%[aIm]) \n\t" + "bgtz %[len], 1b \n\t" + " addiu %[aIm], %[aIm], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [len] "=&r"(len), [fft_tmp] "=&r"(fft_tmp), [aRe] "+r"(aRe), + [aIm] "+r"(aIm) + : [fft] "r"(fft) + : "memory"); } } @@ -359,28 +355,28 @@ void WebRtcAec_Overdrive_mips(float overdrive_scaling, for (int i = 0; i < PART_LEN1; ++i) { // Weight subbands __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "lwc1 %[temp1], 0(%[p_hNl]) \n\t" - "lwc1 %[temp2], 0(%[p_wC]) \n\t" - "c.lt.s %[hNlFb], %[temp1] \n\t" - "bc1f 1f \n\t" - " mul.s %[temp3], %[temp2], %[hNlFb] \n\t" - "sub.s %[temp4], %[one], %[temp2] \n\t" + ".set push \n\t" + ".set noreorder \n\t" + "lwc1 %[temp1], 0(%[p_hNl]) \n\t" + "lwc1 %[temp2], 0(%[p_wC]) \n\t" + "c.lt.s %[hNlFb], %[temp1] \n\t" + "bc1f 1f \n\t" + " mul.s %[temp3], %[temp2], %[hNlFb] \n\t" + "sub.s %[temp4], %[one], %[temp2] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[temp1], %[temp1], %[temp4] \n\t" - "add.s %[temp1], %[temp3], %[temp1] \n\t" -#else // #if !defined(MIPS32_R2_LE) - "madd.s %[temp1], %[temp3], %[temp1], %[temp4] \n\t" + "mul.s %[temp1], %[temp1], %[temp4] \n\t" + "add.s %[temp1], %[temp3], %[temp1] \n\t" +#else // #if !defined(MIPS32_R2_LE) + "madd.s %[temp1], %[temp3], %[temp1], %[temp4] \n\t" #endif // #if !defined(MIPS32_R2_LE) - "swc1 %[temp1], 0(%[p_hNl]) \n\t" - "1: \n\t" - "addiu %[p_wC], %[p_wC], 4 \n\t" - ".set pop \n\t" - : [temp1] "=&f" (temp1), [temp2] "=&f" (temp2), [temp3] "=&f" (temp3), - [temp4] "=&f" (temp4), [p_wC] "+r" (p_WebRtcAec_wC) - : [hNlFb] "f" (hNlFb), [one] "f" (one), [p_hNl] "r" (p_hNl) - : "memory"); + "swc1 %[temp1], 0(%[p_hNl]) \n\t" + "1: \n\t" + "addiu %[p_wC], %[p_wC], 4 \n\t" + ".set pop \n\t" + : [temp1] "=&f"(temp1), [temp2] "=&f"(temp2), [temp3] "=&f"(temp3), + [temp4] "=&f"(temp4), [p_wC] "+r"(p_WebRtcAec_wC) + : [hNlFb] "f"(hNlFb), [one] "f"(one), [p_hNl] "r"(p_hNl) + : "memory"); hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]); } @@ -399,22 +395,22 @@ void WebRtcAec_Suppress_mips(const float hNl[PART_LEN1], for (int i = 0; i < PART_LEN1; ++i) { __asm __volatile( - "lwc1 %[temp1], 0(%[p_hNl]) \n\t" - "lwc1 %[temp3], 0(%[p_efw1]) \n\t" - "lwc1 %[temp2], 0(%[p_efw0]) \n\t" - "addiu %[p_hNl], %[p_hNl], 4 \n\t" - "mul.s %[temp3], %[temp3], %[temp1] \n\t" - "mul.s %[temp2], %[temp2], %[temp1] \n\t" - "addiu %[p_efw0], %[p_efw0], 4 \n\t" - "addiu %[p_efw1], %[p_efw1], 4 \n\t" - "neg.s %[temp4], %[temp3] \n\t" - "swc1 %[temp2], -4(%[p_efw0]) \n\t" - "swc1 %[temp4], -4(%[p_efw1]) \n\t" - : [temp1] "=&f" (temp1), [temp2] "=&f" (temp2), [temp3] "=&f" (temp3), - [temp4] "=&f" (temp4), [p_efw0] "+r" (p_efw0), [p_efw1] "+r" (p_efw1), - [p_hNl] "+r" (p_hNl) - : - : "memory"); + "lwc1 %[temp1], 0(%[p_hNl]) \n\t" + "lwc1 %[temp3], 0(%[p_efw1]) \n\t" + "lwc1 %[temp2], 0(%[p_efw0]) \n\t" + "addiu %[p_hNl], %[p_hNl], 4 \n\t" + "mul.s %[temp3], %[temp3], %[temp1] \n\t" + "mul.s %[temp2], %[temp2], %[temp1] \n\t" + "addiu %[p_efw0], %[p_efw0], 4 \n\t" + "addiu %[p_efw1], %[p_efw1], 4 \n\t" + "neg.s %[temp4], %[temp3] \n\t" + "swc1 %[temp2], -4(%[p_efw0]) \n\t" + "swc1 %[temp4], -4(%[p_efw1]) \n\t" + : [temp1] "=&f"(temp1), [temp2] "=&f"(temp2), [temp3] "=&f"(temp3), + [temp4] "=&f"(temp4), [p_efw0] "+r"(p_efw0), [p_efw1] "+r"(p_efw1), + [p_hNl] "+r"(p_hNl) + : + : "memory"); } } @@ -433,51 +429,50 @@ void WebRtcAec_ScaleErrorSignal_mips(float mu, #endif __asm __volatile( - ".set push \n\t" - ".set noreorder \n\t" - "1: \n\t" - "lwc1 %[f0], 0(%[x_pow]) \n\t" - "lwc1 %[f1], 0(%[ef0]) \n\t" - "lwc1 %[f2], 0(%[ef1]) \n\t" - "add.s %[f0], %[f0], %[fac1] \n\t" - "div.s %[f1], %[f1], %[f0] \n\t" - "div.s %[f2], %[f2], %[f0] \n\t" - "mul.s %[f0], %[f1], %[f1] \n\t" + ".set push \n\t" + ".set noreorder \n\t" + "1: \n\t" + "lwc1 %[f0], 0(%[x_pow]) \n\t" + "lwc1 %[f1], 0(%[ef0]) \n\t" + "lwc1 %[f2], 0(%[ef1]) \n\t" + "add.s %[f0], %[f0], %[fac1] \n\t" + "div.s %[f1], %[f1], %[f0] \n\t" + "div.s %[f2], %[f2], %[f0] \n\t" + "mul.s %[f0], %[f1], %[f1] \n\t" #if defined(MIPS32_R2_LE) - "madd.s %[f0], %[f0], %[f2], %[f2] \n\t" + "madd.s %[f0], %[f0], %[f2], %[f2] \n\t" #else - "mul.s %[f3], %[f2], %[f2] \n\t" - "add.s %[f0], %[f0], %[f3] \n\t" + "mul.s %[f3], %[f2], %[f2] \n\t" + "add.s %[f0], %[f0], %[f3] \n\t" #endif - "c.le.s %[f0], %[err_th2] \n\t" - "nop \n\t" - "bc1t 2f \n\t" - " nop \n\t" - "sqrt.s %[f0], %[f0] \n\t" - "add.s %[f0], %[f0], %[fac1] \n\t" - "div.s %[f0], %[err_th], %[f0] \n\t" - "mul.s %[f1], %[f1], %[f0] \n\t" - "mul.s %[f2], %[f2], %[f0] \n\t" - "2: \n\t" - "mul.s %[f1], %[f1], %[mu] \n\t" - "mul.s %[f2], %[f2], %[mu] \n\t" - "swc1 %[f1], 0(%[ef0]) \n\t" - "swc1 %[f2], 0(%[ef1]) \n\t" - "addiu %[len], %[len], -1 \n\t" - "addiu %[x_pow], %[x_pow], 4 \n\t" - "addiu %[ef0], %[ef0], 4 \n\t" - "bgtz %[len], 1b \n\t" - " addiu %[ef1], %[ef1], 4 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), + "c.le.s %[f0], %[err_th2] \n\t" + "nop \n\t" + "bc1t 2f \n\t" + " nop \n\t" + "sqrt.s %[f0], %[f0] \n\t" + "add.s %[f0], %[f0], %[fac1] \n\t" + "div.s %[f0], %[err_th], %[f0] \n\t" + "mul.s %[f1], %[f1], %[f0] \n\t" + "mul.s %[f2], %[f2], %[f0] \n\t" + "2: \n\t" + "mul.s %[f1], %[f1], %[mu] \n\t" + "mul.s %[f2], %[f2], %[mu] \n\t" + "swc1 %[f1], 0(%[ef0]) \n\t" + "swc1 %[f2], 0(%[ef1]) \n\t" + "addiu %[len], %[len], -1 \n\t" + "addiu %[x_pow], %[x_pow], 4 \n\t" + "addiu %[ef0], %[ef0], 4 \n\t" + "bgtz %[len], 1b \n\t" + " addiu %[ef1], %[ef1], 4 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), #if !defined(MIPS32_R2_LE) - [f3] "=&f" (f3), + [f3] "=&f"(f3), #endif - [x_pow] "+r" (x_pow), [ef0] "+r" (ef0), [ef1] "+r" (ef1), - [len] "+r" (len) - : [fac1] "f" (fac1), [err_th2] "f" (err_th2), [mu] "f" (mu), - [err_th] "f" (error_threshold) - : "memory"); + [x_pow] "+r"(x_pow), [ef0] "+r"(ef0), [ef1] "+r"(ef1), [len] "+r"(len) + : [fac1] "f"(fac1), [err_th2] "f"(err_th2), [mu] "f"(mu), + [err_th] "f"(error_threshold) + : "memory"); } void WebRtcAec_InitAec_mips(void) { diff --git a/modules/audio_processing/aec/aec_core_neon.cc b/modules/audio_processing/aec/aec_core_neon.cc index 1fbf56b8b6..072bd17dfe 100644 --- a/modules/audio_processing/aec/aec_core_neon.cc +++ b/modules/audio_processing/aec/aec_core_neon.cc @@ -38,13 +38,12 @@ __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) { return aRe * bIm + aIm * bRe; } -static void FilterFarNEON(int num_partitions, - int x_fft_buf_block_pos, - float x_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float h_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float y_fft[2][PART_LEN1]) { +static void FilterFarNEON( + int num_partitions, + int x_fft_buf_block_pos, + float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float y_fft[2][PART_LEN1]) { int i; for (i = 0; i < num_partitions; i++) { int j; diff --git a/modules/audio_processing/aec/aec_core_sse2.cc b/modules/audio_processing/aec/aec_core_sse2.cc index 0532662bed..ede04ddfc3 100644 --- a/modules/audio_processing/aec/aec_core_sse2.cc +++ b/modules/audio_processing/aec/aec_core_sse2.cc @@ -33,13 +33,12 @@ __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) { return aRe * bIm + aIm * bRe; } -static void FilterFarSSE2(int num_partitions, - int x_fft_buf_block_pos, - float x_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float h_fft_buf[2] - [kExtendedNumPartitions * PART_LEN1], - float y_fft[2][PART_LEN1]) { +static void FilterFarSSE2( + int num_partitions, + int x_fft_buf_block_pos, + float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], + float y_fft[2][PART_LEN1]) { int i; for (i = 0; i < num_partitions; i++) { int j; @@ -257,10 +256,10 @@ static __m128 mm_pow_ps(__m128 a, __m128 b) { _mm_and_ps(a, *(reinterpret_cast(float_exponent_mask))); const __m128 n_1 = _mm_castsi128_ps(_mm_srli_epi32( _mm_castps_si128(two_n), shift_exponent_into_top_mantissa)); - const __m128 n_0 = - _mm_or_ps(n_1, *(reinterpret_cast(eight_biased_exponent))); - const __m128 n = - _mm_sub_ps(n_0, *(reinterpret_cast(implicit_leading_one))); + const __m128 n_0 = _mm_or_ps( + n_1, *(reinterpret_cast(eight_biased_exponent))); + const __m128 n = _mm_sub_ps( + n_0, *(reinterpret_cast(implicit_leading_one))); // Compute y. static const ALIGN16_BEG int mantissa_mask[4] ALIGN16_END = { @@ -269,9 +268,9 @@ static __m128 mm_pow_ps(__m128 a, __m128 b) { 0x3F800000, 0x3F800000, 0x3F800000, 0x3F800000}; const __m128 mantissa = _mm_and_ps(a, *(reinterpret_cast(mantissa_mask))); - const __m128 y = - _mm_or_ps(mantissa, - *(reinterpret_cast(zero_biased_exponent_is_one))); + const __m128 y = _mm_or_ps( + mantissa, + *(reinterpret_cast(zero_biased_exponent_is_one))); // Approximate log2(y) ~= (y - 1) * pol5(y). // pol5(y) = C5 * y^5 + C4 * y^4 + C3 * y^3 + C2 * y^2 + C1 * y + C0 @@ -303,9 +302,8 @@ static __m128 mm_pow_ps(__m128 a, __m128 b) { const __m128 pol5_y_8 = _mm_mul_ps(pol5_y_7, y); const __m128 pol5_y = _mm_add_ps(pol5_y_8, *(reinterpret_cast(C0))); - const __m128 y_minus_one = - _mm_sub_ps(y, - *(reinterpret_cast(zero_biased_exponent_is_one))); + const __m128 y_minus_one = _mm_sub_ps( + y, *(reinterpret_cast(zero_biased_exponent_is_one))); const __m128 log2_y = _mm_mul_ps(y_minus_one, pol5_y); // Combine parts. diff --git a/modules/audio_processing/aec/echo_cancellation.cc b/modules/audio_processing/aec/echo_cancellation.cc index 163306883b..c8382ec1d6 100644 --- a/modules/audio_processing/aec/echo_cancellation.cc +++ b/modules/audio_processing/aec/echo_cancellation.cc @@ -291,7 +291,7 @@ int32_t WebRtcAec_BufferFarend(void* aecInst, aecpc->farend_started = 1; WebRtcAec_SetSystemDelay(aecpc->aec, WebRtcAec_system_delay(aecpc->aec) + - static_cast(newNrOfSamples)); + static_cast(newNrOfSamples)); // Write the time-domain data to |far_pre_buf|. WebRtc_WriteBuffer(aecpc->far_pre_buf, farend_ptr, newNrOfSamples); @@ -302,8 +302,8 @@ int32_t WebRtcAec_BufferFarend(void* aecInst, { float* ptmp = NULL; float tmp[PART_LEN2]; - WebRtc_ReadBuffer(aecpc->far_pre_buf, - reinterpret_cast(&ptmp), tmp, PART_LEN2); + WebRtc_ReadBuffer(aecpc->far_pre_buf, reinterpret_cast(&ptmp), + tmp, PART_LEN2); WebRtcAec_BufferFarendBlock(aecpc->aec, &ptmp[PART_LEN]); } @@ -545,9 +545,9 @@ static int ProcessNormal(Aec* aecInst, const float minSkewEst = -0.5f; const float maxSkewEst = 1.0f; - reported_delay_ms = - reported_delay_ms > kMaxTrustedDelayMs ? kMaxTrustedDelayMs : - reported_delay_ms; + reported_delay_ms = reported_delay_ms > kMaxTrustedDelayMs + ? kMaxTrustedDelayMs + : reported_delay_ms; // TODO(andrew): we need to investigate if this +10 is really wanted. reported_delay_ms += 10; aecInst->msInSndCardBuf = reported_delay_ms; @@ -642,9 +642,8 @@ static int ProcessNormal(Aec* aecInst, // for too long). When the far-end buffer is filled with // approximately the same amount of data as reported by the system // we end the startup phase. - int overhead_elements = - WebRtcAec_system_delay(aecInst->aec) / PART_LEN - - aecInst->bufSizeStart; + int overhead_elements = WebRtcAec_system_delay(aecInst->aec) / PART_LEN - + aecInst->bufSizeStart; if (overhead_elements == 0) { // Enable the AEC aecInst->startup_phase = 0; @@ -780,10 +779,8 @@ static void EstBufDelayNormal(Aec* aecInst) { // We use -1 to signal an initialized state in the "extended" implementation; // compensate for that. aecInst->filtDelay = aecInst->filtDelay < 0 ? 0 : aecInst->filtDelay; - aecInst->filtDelay = - WEBRTC_SPL_MAX(0, static_cast(0.8 * - aecInst->filtDelay + - 0.2 * current_delay)); + aecInst->filtDelay = WEBRTC_SPL_MAX( + 0, static_cast(0.8 * aecInst->filtDelay + 0.2 * current_delay)); delay_difference = aecInst->filtDelay - aecInst->knownDelay; if (delay_difference > 224) { @@ -809,8 +806,8 @@ static void EstBufDelayNormal(Aec* aecInst) { } static void EstBufDelayExtended(Aec* aecInst) { - int reported_delay = aecInst->msInSndCardBuf * sampMsNb * - aecInst->rate_factor; + int reported_delay = + aecInst->msInSndCardBuf * sampMsNb * aecInst->rate_factor; int current_delay = reported_delay - WebRtcAec_system_delay(aecInst->aec); int delay_difference = 0; @@ -839,8 +836,8 @@ static void EstBufDelayExtended(Aec* aecInst) { aecInst->filtDelay = WEBRTC_SPL_MAX(0, 0.5 * current_delay); } else { aecInst->filtDelay = WEBRTC_SPL_MAX( - 0, static_cast(0.95 * aecInst->filtDelay + 0.05 * - current_delay)); + 0, + static_cast(0.95 * aecInst->filtDelay + 0.05 * current_delay)); } delay_difference = aecInst->filtDelay - aecInst->knownDelay; diff --git a/modules/audio_processing/aec/system_delay_unittest.cc b/modules/audio_processing/aec/system_delay_unittest.cc index fc57af8b87..e7e79fe723 100644 --- a/modules/audio_processing/aec/system_delay_unittest.cc +++ b/modules/audio_processing/aec/system_delay_unittest.cc @@ -104,14 +104,8 @@ void SystemDelayTest::Init(int sample_rate_hz) { void SystemDelayTest::RenderAndCapture(int device_buffer_ms) { EXPECT_EQ(0, WebRtcAec_BufferFarend(handle_, far_, samples_per_frame_)); - EXPECT_EQ(0, - WebRtcAec_Process(handle_, - &near_ptr_, - 1, - &out_ptr_, - samples_per_frame_, - device_buffer_ms, - 0)); + EXPECT_EQ(0, WebRtcAec_Process(handle_, &near_ptr_, 1, &out_ptr_, + samples_per_frame_, device_buffer_ms, 0)); } size_t SystemDelayTest::BufferFillUp() { @@ -157,16 +151,15 @@ void SystemDelayTest::RunStableStartup() { EXPECT_GT(kStableConvergenceMs, process_time_ms); } // Verify that the buffer has been flushed. - EXPECT_GE(static_cast(buffer_size), - WebRtcAec_system_delay(self_->aec)); + EXPECT_GE(static_cast(buffer_size), WebRtcAec_system_delay(self_->aec)); } - int SystemDelayTest::MapBufferSizeToSamples(int size_in_ms, - bool extended_filter) { +int SystemDelayTest::MapBufferSizeToSamples(int size_in_ms, + bool extended_filter) { // If extended_filter is disabled we add an extra 10 ms for the unprocessed // frame. That is simply how the algorithm is constructed. - return static_cast( - (size_in_ms + (extended_filter ? 0 : 10)) * samples_per_frame_ / 10); + return static_cast((size_in_ms + (extended_filter ? 0 : 10)) * + samples_per_frame_ / 10); } // The tests should meet basic requirements and not be adjusted to what is @@ -241,9 +234,9 @@ TEST_F(SystemDelayTest, CorrectDelayAfterStableStartup) { static_cast(kDeviceBufMs * samples_per_frame_ / 10); EXPECT_GE(average_reported_delay, WebRtcAec_system_delay(self_->aec)); int lower_bound = WebRtcAec_extended_filter_enabled(self_->aec) - ? (average_reported_delay / 2 - - rtc::checked_cast(samples_per_frame_)) - : average_reported_delay * 3 / 4; + ? (average_reported_delay / 2 - + rtc::checked_cast(samples_per_frame_)) + : average_reported_delay * 3 / 4; EXPECT_LE(lower_bound, WebRtcAec_system_delay(self_->aec)); } } @@ -322,14 +315,8 @@ TEST_F(SystemDelayTest, CorrectDelayAfterStableBufferBuildUp) { // can make that assumption since we have a separate stability test. int process_time_ms = 0; for (; process_time_ms < kStableConvergenceMs; process_time_ms += 10) { - EXPECT_EQ(0, - WebRtcAec_Process(handle_, - &near_ptr_, - 1, - &out_ptr_, - samples_per_frame_, - kDeviceBufMs, - 0)); + EXPECT_EQ(0, WebRtcAec_Process(handle_, &near_ptr_, 1, &out_ptr_, + samples_per_frame_, kDeviceBufMs, 0)); } // Verify that a buffer size has been established. EXPECT_EQ(0, self_->checkBuffSize); @@ -414,8 +401,8 @@ TEST_F(SystemDelayTest, CorrectDelayDuringDrift) { for (int j = 0; j < 1000; j++) { // Drift = -1 ms per 100 ms of data. int device_buf_ms = kDeviceBufMs - (j / 10) + jump; - int device_buf = MapBufferSizeToSamples(device_buf_ms, - extended_filter == 1); + int device_buf = + MapBufferSizeToSamples(device_buf_ms, extended_filter == 1); if (device_buf_ms < 30) { // Add 10 ms data, taking affect next frame. @@ -452,8 +439,8 @@ TEST_F(SystemDelayTest, ShouldRecoverAfterGlitch) { for (size_t i = 0; i < kNumSampleRates; i++) { Init(kSampleRateHz[i]); RunStableStartup(); - int device_buf = MapBufferSizeToSamples(kDeviceBufMs, - extended_filter == 1); + int device_buf = + MapBufferSizeToSamples(kDeviceBufMs, extended_filter == 1); // Glitch state. for (int j = 0; j < 20; j++) { EXPECT_EQ(0, @@ -513,8 +500,8 @@ TEST_F(SystemDelayTest, UnaffectedWhenSpuriousDeviceBufferValues) { for (size_t i = 0; i < kNumSampleRates; i++) { Init(kSampleRateHz[i]); RunStableStartup(); - int device_buf = MapBufferSizeToSamples(kDeviceBufMs, - extended_filter == 1); + int device_buf = + MapBufferSizeToSamples(kDeviceBufMs, extended_filter == 1); // Normal state. We are currently not in a non-causal state. bool non_causal = false; @@ -566,8 +553,8 @@ TEST_F(SystemDelayTest, CorrectImpactWhenTogglingDeviceBufferValues) { for (size_t i = 0; i < kNumSampleRates; i++) { Init(kSampleRateHz[i]); RunStableStartup(); - const int device_buf = MapBufferSizeToSamples(kDeviceBufMs, - extended_filter == 1); + const int device_buf = + MapBufferSizeToSamples(kDeviceBufMs, extended_filter == 1); // Normal state. We are currently not in a non-causal state. bool non_causal = false; diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc index b075ff52fc..15717d1796 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc @@ -357,9 +357,8 @@ TEST(AdaptiveFirFilter, FilterAndAdapt) { RandomizeSampleVector(&random_generator, n); static constexpr float kNoiseScaling = 1.f / 100.f; - std::transform( - y.begin(), y.end(), n.begin(), y.begin(), - [](float a, float b) { return a + b * kNoiseScaling; }); + std::transform(y.begin(), y.end(), n.begin(), y.begin(), + [](float a, float b) { return a + b * kNoiseScaling; }); x_hp_filter.Process(x[0]); y_hp_filter.Process(y); diff --git a/modules/audio_processing/aec3/aec3_common.cc b/modules/audio_processing/aec3/aec3_common.cc index 7becce49f1..8e130551e9 100644 --- a/modules/audio_processing/aec3/aec3_common.cc +++ b/modules/audio_processing/aec3/aec3_common.cc @@ -10,8 +10,8 @@ #include "modules/audio_processing/aec3/aec3_common.h" -#include "typedefs.h" // NOLINT(build/include) #include "system_wrappers/include/cpu_features_wrapper.h" +#include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index b32ae3c3e5..20b0580fc9 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -387,7 +387,7 @@ void AecState::UpdateReverb(const std::vector& impulse_response) { } x = {in}; float out = x.a; out *= 1.1920929e-7f; // 1/2^23 - out -= 126.942695f; // Remove bias. + out -= 126.942695f; // Remove bias. return out; }; RTC_DCHECK_GT(matching_data.size(), start_index + i); diff --git a/modules/audio_processing/aec3/block_processor_metrics_unittest.cc b/modules/audio_processing/aec3/block_processor_metrics_unittest.cc index 7ce8573efa..73f76895a6 100644 --- a/modules/audio_processing/aec3/block_processor_metrics_unittest.cc +++ b/modules/audio_processing/aec3/block_processor_metrics_unittest.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block_processor_metrics.h" +#include "modules/audio_processing/aec3/aec3_common.h" #include "test/gtest.h" diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc index 841cdfa764..0e237a5786 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc @@ -104,9 +104,9 @@ TEST(EchoPathDelayEstimator, DelayEstimation) { } else { ADD_FAILURE(); } + } } } -} // Verifies that the delay estimator does not produce delay estimates for render // signals of low level. diff --git a/modules/audio_processing/aec3/echo_remover.cc b/modules/audio_processing/aec3/echo_remover.cc index e264d30844..deae3a3986 100644 --- a/modules/audio_processing/aec3/echo_remover.cc +++ b/modules/audio_processing/aec3/echo_remover.cc @@ -243,8 +243,6 @@ void EchoRemoverImpl::ProcessCapture( // Estimate the comfort noise. cng_.Compute(aec_state_, Y2, &comfort_noise, &high_band_comfort_noise); - - // Compute and apply the suppression gain. suppression_gain_.GetGain(E2, R2, cng_.NoiseSpectrum(), E, X, Y, render_signal_analyzer_, aec_state_, x, diff --git a/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc b/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc index fbd30d179b..fb9f151b42 100644 --- a/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc +++ b/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc @@ -12,8 +12,8 @@ #include -#include "modules/audio_processing/aec3/aec_state.h" #include "modules/audio_processing/aec3/aec3_fft.h" +#include "modules/audio_processing/aec3/aec_state.h" #include "test/gtest.h" namespace webrtc { @@ -78,23 +78,19 @@ TEST(TransformDbMetricForReporting, DbFsScaling) { // Verifies that the TransformDbMetricForReporting method is able to properly // limit the output. TEST(TransformDbMetricForReporting, Limits) { - EXPECT_EQ( - 0, - aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f, 0.001f)); - EXPECT_EQ( - 10, - aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f, 100.f)); + EXPECT_EQ(0, aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f, + 0.001f)); + EXPECT_EQ(10, aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f, + 100.f)); } // Verifies that the TransformDbMetricForReporting method is able to properly // negate output. TEST(TransformDbMetricForReporting, Negate) { - EXPECT_EQ( - 10, - aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, 1.f, 0.1f)); - EXPECT_EQ( - -10, - aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, 1.f, 10.f)); + EXPECT_EQ(10, aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, 1.f, + 0.1f)); + EXPECT_EQ(-10, aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, + 1.f, 10.f)); } // Verify the Update functionality of DbMetric. diff --git a/modules/audio_processing/aec3/erle_estimator.cc b/modules/audio_processing/aec3/erle_estimator.cc index 1f0429a715..ab6c1c7278 100644 --- a/modules/audio_processing/aec3/erle_estimator.cc +++ b/modules/audio_processing/aec3/erle_estimator.cc @@ -132,8 +132,8 @@ void ErleEstimator::Update(rtc::ArrayView render_spectrum, } --hold_counter_time_domain_; erle_time_domain_ = (hold_counter_time_domain_ > 0) - ? erle_time_domain_ - : std::max(min_erle_, 0.97f * erle_time_domain_); + ? erle_time_domain_ + : std::max(min_erle_, 0.97f * erle_time_domain_); } } // namespace webrtc diff --git a/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc b/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc index f398b84fb7..ed30799490 100644 --- a/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc +++ b/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc @@ -241,34 +241,34 @@ TEST(MainFilterUpdateGain, GainCausesFilterToConverge) { // Verifies that the magnitude of the gain on average decreases for a // persistently exciting signal. TEST(MainFilterUpdateGain, DecreasingGain) { - std::vector blocks_with_echo_path_changes; - std::vector blocks_with_saturation; + std::vector blocks_with_echo_path_changes; + std::vector blocks_with_saturation; - std::array e; - std::array y; - FftData G_a; - FftData G_b; - FftData G_c; - std::array G_a_power; - std::array G_b_power; - std::array G_c_power; + std::array e; + std::array y; + FftData G_a; + FftData G_b; + FftData G_c; + std::array G_a_power; + std::array G_b_power; + std::array G_c_power; - RunFilterUpdateTest(100, 65, 12, blocks_with_echo_path_changes, - blocks_with_saturation, false, &e, &y, &G_a); - RunFilterUpdateTest(300, 65, 12, blocks_with_echo_path_changes, - blocks_with_saturation, false, &e, &y, &G_b); - RunFilterUpdateTest(600, 65, 12, blocks_with_echo_path_changes, - blocks_with_saturation, false, &e, &y, &G_c); + RunFilterUpdateTest(100, 65, 12, blocks_with_echo_path_changes, + blocks_with_saturation, false, &e, &y, &G_a); + RunFilterUpdateTest(300, 65, 12, blocks_with_echo_path_changes, + blocks_with_saturation, false, &e, &y, &G_b); + RunFilterUpdateTest(600, 65, 12, blocks_with_echo_path_changes, + blocks_with_saturation, false, &e, &y, &G_c); - G_a.Spectrum(Aec3Optimization::kNone, G_a_power); - G_b.Spectrum(Aec3Optimization::kNone, G_b_power); - G_c.Spectrum(Aec3Optimization::kNone, G_c_power); + G_a.Spectrum(Aec3Optimization::kNone, G_a_power); + G_b.Spectrum(Aec3Optimization::kNone, G_b_power); + G_c.Spectrum(Aec3Optimization::kNone, G_c_power); - EXPECT_GT(std::accumulate(G_a_power.begin(), G_a_power.end(), 0.), - std::accumulate(G_b_power.begin(), G_b_power.end(), 0.)); + EXPECT_GT(std::accumulate(G_a_power.begin(), G_a_power.end(), 0.), + std::accumulate(G_b_power.begin(), G_b_power.end(), 0.)); - EXPECT_GT(std::accumulate(G_b_power.begin(), G_b_power.end(), 0.), - std::accumulate(G_c_power.begin(), G_c_power.end(), 0.)); + EXPECT_GT(std::accumulate(G_b_power.begin(), G_b_power.end(), 0.), + std::accumulate(G_c_power.begin(), G_c_power.end(), 0.)); } // Verifies that the gain is zero when there is saturation and that the internal diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc index 97c7f5b857..cea5f13ce7 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc @@ -6,7 +6,7 @@ * 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. - */ + */ #include "modules/audio_processing/aec3/matched_filter_lag_aggregator.h" diff --git a/modules/audio_processing/aec3/matched_filter_unittest.cc b/modules/audio_processing/aec3/matched_filter_unittest.cc index c3c3a0db86..fd878ff98d 100644 --- a/modules/audio_processing/aec3/matched_filter_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_unittest.cc @@ -6,7 +6,7 @@ * 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. - */ + */ #include "modules/audio_processing/aec3/matched_filter.h" diff --git a/modules/audio_processing/aec3/render_buffer.h b/modules/audio_processing/aec3/render_buffer.h index 9419b30aa9..34e7edf37a 100644 --- a/modules/audio_processing/aec3/render_buffer.h +++ b/modules/audio_processing/aec3/render_buffer.h @@ -82,7 +82,6 @@ class RenderBuffer { return headroom; } - // Returns a reference to the spectrum buffer. const VectorBuffer& GetSpectrumBuffer() const { return *spectrum_buffer_; } diff --git a/modules/audio_processing/aec3/residual_echo_estimator.cc b/modules/audio_processing/aec3/residual_echo_estimator.cc index 85a15e1a50..ea787a4b82 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator.cc +++ b/modules/audio_processing/aec3/residual_echo_estimator.cc @@ -216,7 +216,6 @@ void ResidualEchoEstimator::NonLinearEstimate( const std::array& X2, const std::array& Y2, std::array* R2) { - // Compute preliminary residual echo. std::transform(X2.begin(), X2.end(), R2->begin(), [echo_path_gain](float a) { return a * echo_path_gain * echo_path_gain; diff --git a/modules/audio_processing/aec3/stationarity_estimator.cc b/modules/audio_processing/aec3/stationarity_estimator.cc index d4e32f56ab..be04002ed4 100644 --- a/modules/audio_processing/aec3/stationarity_estimator.cc +++ b/modules/audio_processing/aec3/stationarity_estimator.cc @@ -86,7 +86,6 @@ void StationarityEstimator::UpdateStationarityFlags( } UpdateHangover(); SmoothStationaryPerFreq(); - } bool StationarityEstimator::EstimateBandStationarity( diff --git a/modules/audio_processing/aec3/subtractor.h b/modules/audio_processing/aec3/subtractor.h index 38fc3c631e..33fdde5809 100644 --- a/modules/audio_processing/aec3/subtractor.h +++ b/modules/audio_processing/aec3/subtractor.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ #define MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ -#include #include +#include #include #include "modules/audio_processing/aec3/adaptive_fir_filter.h" diff --git a/modules/audio_processing/aec3/suppression_gain_unittest.cc b/modules/audio_processing/aec3/suppression_gain_unittest.cc index 7e5ee9fdb4..4670178ee2 100644 --- a/modules/audio_processing/aec3/suppression_gain_unittest.cc +++ b/modules/audio_processing/aec3/suppression_gain_unittest.cc @@ -144,7 +144,6 @@ TEST(SuppressionGain, BasicGainComputation) { } std::for_each(g.begin(), g.end(), [](float a) { EXPECT_NEAR(0.f, a, 0.001); }); - } } // namespace aec3 diff --git a/modules/audio_processing/aec_dump/mock_aec_dump.cc b/modules/audio_processing/aec_dump/mock_aec_dump.cc index aa89e45fe8..fe35d81db9 100644 --- a/modules/audio_processing/aec_dump/mock_aec_dump.cc +++ b/modules/audio_processing/aec_dump/mock_aec_dump.cc @@ -15,5 +15,5 @@ namespace test { MockAecDump::MockAecDump() = default; MockAecDump::~MockAecDump() = default; -} -} +} // namespace test +} // namespace webrtc diff --git a/modules/audio_processing/aecm/aecm_core.cc b/modules/audio_processing/aecm/aecm_core.cc index 3d9facab4a..21a2ba110a 100644 --- a/modules/audio_processing/aecm/aecm_core.cc +++ b/modules/audio_processing/aecm/aecm_core.cc @@ -28,126 +28,97 @@ extern "C" { #include "typedefs.h" // NOLINT(build/include) #ifdef AEC_DEBUG -FILE *dfile; -FILE *testfile; +FILE* dfile; +FILE* testfile; #endif const int16_t WebRtcAecm_kCosTable[] = { - 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, - 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, - 7791, 7745, 7697, 7647, 7595, 7540, 7483, 7424, 7362, - 7299, 7233, 7164, 7094, 7021, 6947, 6870, 6791, 6710, - 6627, 6542, 6455, 6366, 6275, 6182, 6087, 5991, 5892, - 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930, - 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, - 3719, 3591, 3462, 3331, 3200, 3068, 2935, 2801, 2667, - 2531, 2395, 2258, 2120, 1981, 1842, 1703, 1563, 1422, - 1281, 1140, 998, 856, 713, 571, 428, 285, 142, - 0, -142, -285, -428, -571, -713, -856, -998, -1140, - -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395, - -2531, -2667, -2801, -2935, -3068, -3200, -3331, -3462, -3591, - -3719, -3845, -3971, -4095, -4219, -4341, -4461, -4580, -4698, - -4815, -4930, -5043, -5155, -5265, -5374, -5481, -5586, -5690, - -5792, -5892, -5991, -6087, -6182, -6275, -6366, -6455, -6542, - -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, -7233, - -7299, -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, - -7791, -7834, -7874, -7912, -7948, -7982, -8012, -8041, -8067, - -8091, -8112, -8130, -8147, -8160, -8172, -8180, -8187, -8190, - -8191, -8190, -8187, -8180, -8172, -8160, -8147, -8130, -8112, - -8091, -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834, - -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362, - -7299, -7233, -7164, -7094, -7021, -6947, -6870, -6791, -6710, - -6627, -6542, -6455, -6366, -6275, -6182, -6087, -5991, -5892, - -5792, -5690, -5586, -5481, -5374, -5265, -5155, -5043, -4930, - -4815, -4698, -4580, -4461, -4341, -4219, -4096, -3971, -3845, - -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, -2667, - -2531, -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, - -1281, -1140, -998, -856, -713, -571, -428, -285, -142, - 0, 142, 285, 428, 571, 713, 856, 998, 1140, - 1281, 1422, 1563, 1703, 1842, 1981, 2120, 2258, 2395, - 2531, 2667, 2801, 2935, 3068, 3200, 3331, 3462, 3591, - 3719, 3845, 3971, 4095, 4219, 4341, 4461, 4580, 4698, - 4815, 4930, 5043, 5155, 5265, 5374, 5481, 5586, 5690, - 5792, 5892, 5991, 6087, 6182, 6275, 6366, 6455, 6542, - 6627, 6710, 6791, 6870, 6947, 7021, 7094, 7164, 7233, - 7299, 7362, 7424, 7483, 7540, 7595, 7647, 7697, 7745, - 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, 8067, - 8091, 8112, 8130, 8147, 8160, 8172, 8180, 8187, 8190 -}; + 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, 8091, 8067, + 8041, 8012, 7982, 7948, 7912, 7874, 7834, 7791, 7745, 7697, 7647, + 7595, 7540, 7483, 7424, 7362, 7299, 7233, 7164, 7094, 7021, 6947, + 6870, 6791, 6710, 6627, 6542, 6455, 6366, 6275, 6182, 6087, 5991, + 5892, 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930, 4815, + 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, 3719, 3591, 3462, + 3331, 3200, 3068, 2935, 2801, 2667, 2531, 2395, 2258, 2120, 1981, + 1842, 1703, 1563, 1422, 1281, 1140, 998, 856, 713, 571, 428, + 285, 142, 0, -142, -285, -428, -571, -713, -856, -998, -1140, + -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395, -2531, -2667, + -2801, -2935, -3068, -3200, -3331, -3462, -3591, -3719, -3845, -3971, -4095, + -4219, -4341, -4461, -4580, -4698, -4815, -4930, -5043, -5155, -5265, -5374, + -5481, -5586, -5690, -5792, -5892, -5991, -6087, -6182, -6275, -6366, -6455, + -6542, -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, -7233, -7299, + -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, -7791, -7834, -7874, + -7912, -7948, -7982, -8012, -8041, -8067, -8091, -8112, -8130, -8147, -8160, + -8172, -8180, -8187, -8190, -8191, -8190, -8187, -8180, -8172, -8160, -8147, + -8130, -8112, -8091, -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834, + -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362, -7299, -7233, + -7164, -7094, -7021, -6947, -6870, -6791, -6710, -6627, -6542, -6455, -6366, + -6275, -6182, -6087, -5991, -5892, -5792, -5690, -5586, -5481, -5374, -5265, + -5155, -5043, -4930, -4815, -4698, -4580, -4461, -4341, -4219, -4096, -3971, + -3845, -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, -2667, -2531, + -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, -1281, -1140, -998, + -856, -713, -571, -428, -285, -142, 0, 142, 285, 428, 571, + 713, 856, 998, 1140, 1281, 1422, 1563, 1703, 1842, 1981, 2120, + 2258, 2395, 2531, 2667, 2801, 2935, 3068, 3200, 3331, 3462, 3591, + 3719, 3845, 3971, 4095, 4219, 4341, 4461, 4580, 4698, 4815, 4930, + 5043, 5155, 5265, 5374, 5481, 5586, 5690, 5792, 5892, 5991, 6087, + 6182, 6275, 6366, 6455, 6542, 6627, 6710, 6791, 6870, 6947, 7021, + 7094, 7164, 7233, 7299, 7362, 7424, 7483, 7540, 7595, 7647, 7697, + 7745, 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, 8067, 8091, + 8112, 8130, 8147, 8160, 8172, 8180, 8187, 8190}; const int16_t WebRtcAecm_kSinTable[] = { - 0, 142, 285, 428, 571, 713, 856, 998, - 1140, 1281, 1422, 1563, 1703, 1842, 1981, 2120, - 2258, 2395, 2531, 2667, 2801, 2935, 3068, 3200, - 3331, 3462, 3591, 3719, 3845, 3971, 4095, 4219, - 4341, 4461, 4580, 4698, 4815, 4930, 5043, 5155, - 5265, 5374, 5481, 5586, 5690, 5792, 5892, 5991, - 6087, 6182, 6275, 6366, 6455, 6542, 6627, 6710, - 6791, 6870, 6947, 7021, 7094, 7164, 7233, 7299, - 7362, 7424, 7483, 7540, 7595, 7647, 7697, 7745, - 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, - 8067, 8091, 8112, 8130, 8147, 8160, 8172, 8180, - 8187, 8190, 8191, 8190, 8187, 8180, 8172, 8160, - 8147, 8130, 8112, 8091, 8067, 8041, 8012, 7982, - 7948, 7912, 7874, 7834, 7791, 7745, 7697, 7647, - 7595, 7540, 7483, 7424, 7362, 7299, 7233, 7164, - 7094, 7021, 6947, 6870, 6791, 6710, 6627, 6542, - 6455, 6366, 6275, 6182, 6087, 5991, 5892, 5792, - 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930, - 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, - 3845, 3719, 3591, 3462, 3331, 3200, 3068, 2935, - 2801, 2667, 2531, 2395, 2258, 2120, 1981, 1842, - 1703, 1563, 1422, 1281, 1140, 998, 856, 713, - 571, 428, 285, 142, 0, -142, -285, -428, - -571, -713, -856, -998, -1140, -1281, -1422, -1563, - -1703, -1842, -1981, -2120, -2258, -2395, -2531, -2667, - -2801, -2935, -3068, -3200, -3331, -3462, -3591, -3719, - -3845, -3971, -4095, -4219, -4341, -4461, -4580, -4698, - -4815, -4930, -5043, -5155, -5265, -5374, -5481, -5586, - -5690, -5792, -5892, -5991, -6087, -6182, -6275, -6366, - -6455, -6542, -6627, -6710, -6791, -6870, -6947, -7021, - -7094, -7164, -7233, -7299, -7362, -7424, -7483, -7540, - -7595, -7647, -7697, -7745, -7791, -7834, -7874, -7912, - -7948, -7982, -8012, -8041, -8067, -8091, -8112, -8130, - -8147, -8160, -8172, -8180, -8187, -8190, -8191, -8190, - -8187, -8180, -8172, -8160, -8147, -8130, -8112, -8091, - -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834, - -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, - -7362, -7299, -7233, -7164, -7094, -7021, -6947, -6870, - -6791, -6710, -6627, -6542, -6455, -6366, -6275, -6182, - -6087, -5991, -5892, -5792, -5690, -5586, -5481, -5374, - -5265, -5155, -5043, -4930, -4815, -4698, -4580, -4461, - -4341, -4219, -4096, -3971, -3845, -3719, -3591, -3462, - -3331, -3200, -3068, -2935, -2801, -2667, -2531, -2395, - -2258, -2120, -1981, -1842, -1703, -1563, -1422, -1281, - -1140, -998, -856, -713, -571, -428, -285, -142 -}; + 0, 142, 285, 428, 571, 713, 856, 998, 1140, 1281, 1422, + 1563, 1703, 1842, 1981, 2120, 2258, 2395, 2531, 2667, 2801, 2935, + 3068, 3200, 3331, 3462, 3591, 3719, 3845, 3971, 4095, 4219, 4341, + 4461, 4580, 4698, 4815, 4930, 5043, 5155, 5265, 5374, 5481, 5586, + 5690, 5792, 5892, 5991, 6087, 6182, 6275, 6366, 6455, 6542, 6627, + 6710, 6791, 6870, 6947, 7021, 7094, 7164, 7233, 7299, 7362, 7424, + 7483, 7540, 7595, 7647, 7697, 7745, 7791, 7834, 7874, 7912, 7948, + 7982, 8012, 8041, 8067, 8091, 8112, 8130, 8147, 8160, 8172, 8180, + 8187, 8190, 8191, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, + 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, 7791, 7745, + 7697, 7647, 7595, 7540, 7483, 7424, 7362, 7299, 7233, 7164, 7094, + 7021, 6947, 6870, 6791, 6710, 6627, 6542, 6455, 6366, 6275, 6182, + 6087, 5991, 5892, 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, + 4930, 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, 3719, + 3591, 3462, 3331, 3200, 3068, 2935, 2801, 2667, 2531, 2395, 2258, + 2120, 1981, 1842, 1703, 1563, 1422, 1281, 1140, 998, 856, 713, + 571, 428, 285, 142, 0, -142, -285, -428, -571, -713, -856, + -998, -1140, -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395, + -2531, -2667, -2801, -2935, -3068, -3200, -3331, -3462, -3591, -3719, -3845, + -3971, -4095, -4219, -4341, -4461, -4580, -4698, -4815, -4930, -5043, -5155, + -5265, -5374, -5481, -5586, -5690, -5792, -5892, -5991, -6087, -6182, -6275, + -6366, -6455, -6542, -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, + -7233, -7299, -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, -7791, + -7834, -7874, -7912, -7948, -7982, -8012, -8041, -8067, -8091, -8112, -8130, + -8147, -8160, -8172, -8180, -8187, -8190, -8191, -8190, -8187, -8180, -8172, + -8160, -8147, -8130, -8112, -8091, -8067, -8041, -8012, -7982, -7948, -7912, + -7874, -7834, -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362, + -7299, -7233, -7164, -7094, -7021, -6947, -6870, -6791, -6710, -6627, -6542, + -6455, -6366, -6275, -6182, -6087, -5991, -5892, -5792, -5690, -5586, -5481, + -5374, -5265, -5155, -5043, -4930, -4815, -4698, -4580, -4461, -4341, -4219, + -4096, -3971, -3845, -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, + -2667, -2531, -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, -1281, + -1140, -998, -856, -713, -571, -428, -285, -142}; // Initialization table for echo channel in 8 kHz static const int16_t kChannelStored8kHz[PART_LEN1] = { - 2040, 1815, 1590, 1498, 1405, 1395, 1385, 1418, - 1451, 1506, 1562, 1644, 1726, 1804, 1882, 1918, - 1953, 1982, 2010, 2025, 2040, 2034, 2027, 2021, - 2014, 1997, 1980, 1925, 1869, 1800, 1732, 1683, - 1635, 1604, 1572, 1545, 1517, 1481, 1444, 1405, - 1367, 1331, 1294, 1270, 1245, 1239, 1233, 1247, - 1260, 1282, 1303, 1338, 1373, 1407, 1441, 1470, - 1499, 1524, 1549, 1565, 1582, 1601, 1621, 1649, - 1676 -}; + 2040, 1815, 1590, 1498, 1405, 1395, 1385, 1418, 1451, 1506, 1562, + 1644, 1726, 1804, 1882, 1918, 1953, 1982, 2010, 2025, 2040, 2034, + 2027, 2021, 2014, 1997, 1980, 1925, 1869, 1800, 1732, 1683, 1635, + 1604, 1572, 1545, 1517, 1481, 1444, 1405, 1367, 1331, 1294, 1270, + 1245, 1239, 1233, 1247, 1260, 1282, 1303, 1338, 1373, 1407, 1441, + 1470, 1499, 1524, 1549, 1565, 1582, 1601, 1621, 1649, 1676}; // Initialization table for echo channel in 16 kHz static const int16_t kChannelStored16kHz[PART_LEN1] = { - 2040, 1590, 1405, 1385, 1451, 1562, 1726, 1882, - 1953, 2010, 2040, 2027, 2014, 1980, 1869, 1732, - 1635, 1572, 1517, 1444, 1367, 1294, 1245, 1233, - 1260, 1303, 1373, 1441, 1499, 1549, 1582, 1621, - 1676, 1741, 1802, 1861, 1921, 1983, 2040, 2102, - 2170, 2265, 2375, 2515, 2651, 2781, 2922, 3075, - 3253, 3471, 3738, 3976, 4151, 4258, 4308, 4288, - 4270, 4253, 4237, 4179, 4086, 3947, 3757, 3484, - 3153 -}; + 2040, 1590, 1405, 1385, 1451, 1562, 1726, 1882, 1953, 2010, 2040, + 2027, 2014, 1980, 1869, 1732, 1635, 1572, 1517, 1444, 1367, 1294, + 1245, 1233, 1260, 1303, 1373, 1441, 1499, 1549, 1582, 1621, 1676, + 1741, 1802, 1861, 1921, 1983, 2040, 2102, 2170, 2265, 2375, 2515, + 2651, 2781, 2922, 3075, 3253, 3471, 3738, 3976, 4151, 4258, 4308, + 4288, 4270, 4253, 4237, 4179, 4086, 3947, 3757, 3484, 3153}; // Moves the pointer to the next entry and inserts |far_spectrum| and // corresponding Q-domain in its buffer. @@ -168,8 +139,7 @@ void WebRtcAecm_UpdateFarHistory(AecmCore* self, // Update Q-domain buffer self->far_q_domains[self->far_history_pos] = far_q; // Update far end spectrum buffer - memcpy(&(self->far_history[self->far_history_pos * PART_LEN1]), - far_spectrum, + memcpy(&(self->far_history[self->far_history_pos * PART_LEN1]), far_spectrum, sizeof(uint16_t) * PART_LEN1); } @@ -213,95 +183,90 @@ StoreAdaptiveChannel WebRtcAecm_StoreAdaptiveChannel; ResetAdaptiveChannel WebRtcAecm_ResetAdaptiveChannel; AecmCore* WebRtcAecm_CreateCore() { - AecmCore* aecm = static_cast(malloc(sizeof(AecmCore))); + AecmCore* aecm = static_cast(malloc(sizeof(AecmCore))); - aecm->farFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, - sizeof(int16_t)); - if (!aecm->farFrameBuf) - { - WebRtcAecm_FreeCore(aecm); - return NULL; - } + aecm->farFrameBuf = + WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); + if (!aecm->farFrameBuf) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } - aecm->nearNoisyFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, - sizeof(int16_t)); - if (!aecm->nearNoisyFrameBuf) - { - WebRtcAecm_FreeCore(aecm); - return NULL; - } + aecm->nearNoisyFrameBuf = + WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); + if (!aecm->nearNoisyFrameBuf) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } - aecm->nearCleanFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, - sizeof(int16_t)); - if (!aecm->nearCleanFrameBuf) - { - WebRtcAecm_FreeCore(aecm); - return NULL; - } + aecm->nearCleanFrameBuf = + WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); + if (!aecm->nearCleanFrameBuf) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } - aecm->outFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, - sizeof(int16_t)); - if (!aecm->outFrameBuf) - { - WebRtcAecm_FreeCore(aecm); - return NULL; - } + aecm->outFrameBuf = + WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); + if (!aecm->outFrameBuf) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } - aecm->delay_estimator_farend = WebRtc_CreateDelayEstimatorFarend(PART_LEN1, - MAX_DELAY); - if (aecm->delay_estimator_farend == NULL) { - WebRtcAecm_FreeCore(aecm); - return NULL; - } - aecm->delay_estimator = - WebRtc_CreateDelayEstimator(aecm->delay_estimator_farend, 0); - if (aecm->delay_estimator == NULL) { - WebRtcAecm_FreeCore(aecm); - return NULL; - } - // TODO(bjornv): Explicitly disable robust delay validation until no - // performance regression has been established. Then remove the line. - WebRtc_enable_robust_validation(aecm->delay_estimator, 0); + aecm->delay_estimator_farend = + WebRtc_CreateDelayEstimatorFarend(PART_LEN1, MAX_DELAY); + if (aecm->delay_estimator_farend == NULL) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } + aecm->delay_estimator = + WebRtc_CreateDelayEstimator(aecm->delay_estimator_farend, 0); + if (aecm->delay_estimator == NULL) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } + // TODO(bjornv): Explicitly disable robust delay validation until no + // performance regression has been established. Then remove the line. + WebRtc_enable_robust_validation(aecm->delay_estimator, 0); - aecm->real_fft = WebRtcSpl_CreateRealFFT(PART_LEN_SHIFT); - if (aecm->real_fft == NULL) { - WebRtcAecm_FreeCore(aecm); - return NULL; - } + aecm->real_fft = WebRtcSpl_CreateRealFFT(PART_LEN_SHIFT); + if (aecm->real_fft == NULL) { + WebRtcAecm_FreeCore(aecm); + return NULL; + } - // Init some aecm pointers. 16 and 32 byte alignment is only necessary - // for Neon code currently. - aecm->xBuf = (int16_t*) (((uintptr_t)aecm->xBuf_buf + 31) & ~ 31); - aecm->dBufClean = (int16_t*) (((uintptr_t)aecm->dBufClean_buf + 31) & ~ 31); - aecm->dBufNoisy = (int16_t*) (((uintptr_t)aecm->dBufNoisy_buf + 31) & ~ 31); - aecm->outBuf = (int16_t*) (((uintptr_t)aecm->outBuf_buf + 15) & ~ 15); - aecm->channelStored = (int16_t*) (((uintptr_t) - aecm->channelStored_buf + 15) & ~ 15); - aecm->channelAdapt16 = (int16_t*) (((uintptr_t) - aecm->channelAdapt16_buf + 15) & ~ 15); - aecm->channelAdapt32 = (int32_t*) (((uintptr_t) - aecm->channelAdapt32_buf + 31) & ~ 31); + // Init some aecm pointers. 16 and 32 byte alignment is only necessary + // for Neon code currently. + aecm->xBuf = (int16_t*)(((uintptr_t)aecm->xBuf_buf + 31) & ~31); + aecm->dBufClean = (int16_t*)(((uintptr_t)aecm->dBufClean_buf + 31) & ~31); + aecm->dBufNoisy = (int16_t*)(((uintptr_t)aecm->dBufNoisy_buf + 31) & ~31); + aecm->outBuf = (int16_t*)(((uintptr_t)aecm->outBuf_buf + 15) & ~15); + aecm->channelStored = + (int16_t*)(((uintptr_t)aecm->channelStored_buf + 15) & ~15); + aecm->channelAdapt16 = + (int16_t*)(((uintptr_t)aecm->channelAdapt16_buf + 15) & ~15); + aecm->channelAdapt32 = + (int32_t*)(((uintptr_t)aecm->channelAdapt32_buf + 31) & ~31); - return aecm; + return aecm; } void WebRtcAecm_InitEchoPathCore(AecmCore* aecm, const int16_t* echo_path) { - int i = 0; + int i = 0; - // Reset the stored channel - memcpy(aecm->channelStored, echo_path, sizeof(int16_t) * PART_LEN1); - // Reset the adapted channels - memcpy(aecm->channelAdapt16, echo_path, sizeof(int16_t) * PART_LEN1); - for (i = 0; i < PART_LEN1; i++) - { - aecm->channelAdapt32[i] = (int32_t)aecm->channelAdapt16[i] << 16; - } + // Reset the stored channel + memcpy(aecm->channelStored, echo_path, sizeof(int16_t) * PART_LEN1); + // Reset the adapted channels + memcpy(aecm->channelAdapt16, echo_path, sizeof(int16_t) * PART_LEN1); + for (i = 0; i < PART_LEN1; i++) { + aecm->channelAdapt32[i] = (int32_t)aecm->channelAdapt16[i] << 16; + } - // Reset channel storing variables - aecm->mseAdaptOld = 1000; - aecm->mseStoredOld = 1000; - aecm->mseThreshold = WEBRTC_SPL_WORD32_MAX; - aecm->mseChannelCount = 0; + // Reset channel storing variables + aecm->mseAdaptOld = 1000; + aecm->mseStoredOld = 1000; + aecm->mseThreshold = WEBRTC_SPL_WORD32_MAX; + aecm->mseChannelCount = 0; } static void CalcLinearEnergiesC(AecmCore* aecm, @@ -310,65 +275,61 @@ static void CalcLinearEnergiesC(AecmCore* aecm, uint32_t* far_energy, uint32_t* echo_energy_adapt, uint32_t* echo_energy_stored) { - int i; + int i; - // Get energy for the delayed far end signal and estimated - // echo using both stored and adapted channels. - for (i = 0; i < PART_LEN1; i++) - { - echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], - far_spectrum[i]); - (*far_energy) += (uint32_t)(far_spectrum[i]); - *echo_energy_adapt += aecm->channelAdapt16[i] * far_spectrum[i]; - (*echo_energy_stored) += (uint32_t)echo_est[i]; - } + // Get energy for the delayed far end signal and estimated + // echo using both stored and adapted channels. + for (i = 0; i < PART_LEN1; i++) { + echo_est[i] = + WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]); + (*far_energy) += (uint32_t)(far_spectrum[i]); + *echo_energy_adapt += aecm->channelAdapt16[i] * far_spectrum[i]; + (*echo_energy_stored) += (uint32_t)echo_est[i]; + } } static void StoreAdaptiveChannelC(AecmCore* aecm, const uint16_t* far_spectrum, int32_t* echo_est) { - int i; + int i; - // During startup we store the channel every block. - memcpy(aecm->channelStored, aecm->channelAdapt16, sizeof(int16_t) * PART_LEN1); - // Recalculate echo estimate - for (i = 0; i < PART_LEN; i += 4) - { - echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], - far_spectrum[i]); - echo_est[i + 1] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 1], - far_spectrum[i + 1]); - echo_est[i + 2] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 2], - far_spectrum[i + 2]); - echo_est[i + 3] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 3], - far_spectrum[i + 3]); - } - echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], - far_spectrum[i]); + // During startup we store the channel every block. + memcpy(aecm->channelStored, aecm->channelAdapt16, + sizeof(int16_t) * PART_LEN1); + // Recalculate echo estimate + for (i = 0; i < PART_LEN; i += 4) { + echo_est[i] = + WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]); + echo_est[i + 1] = + WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 1], far_spectrum[i + 1]); + echo_est[i + 2] = + WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 2], far_spectrum[i + 2]); + echo_est[i + 3] = + WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 3], far_spectrum[i + 3]); + } + echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]); } static void ResetAdaptiveChannelC(AecmCore* aecm) { - int i; + int i; - // The stored channel has a significantly lower MSE than the adaptive one for - // two consecutive calculations. Reset the adaptive channel. - memcpy(aecm->channelAdapt16, aecm->channelStored, - sizeof(int16_t) * PART_LEN1); - // Restore the W32 channel - for (i = 0; i < PART_LEN; i += 4) - { - aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16; - aecm->channelAdapt32[i + 1] = (int32_t)aecm->channelStored[i + 1] << 16; - aecm->channelAdapt32[i + 2] = (int32_t)aecm->channelStored[i + 2] << 16; - aecm->channelAdapt32[i + 3] = (int32_t)aecm->channelStored[i + 3] << 16; - } + // The stored channel has a significantly lower MSE than the adaptive one for + // two consecutive calculations. Reset the adaptive channel. + memcpy(aecm->channelAdapt16, aecm->channelStored, + sizeof(int16_t) * PART_LEN1); + // Restore the W32 channel + for (i = 0; i < PART_LEN; i += 4) { aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16; + aecm->channelAdapt32[i + 1] = (int32_t)aecm->channelStored[i + 1] << 16; + aecm->channelAdapt32[i + 2] = (int32_t)aecm->channelStored[i + 2] << 16; + aecm->channelAdapt32[i + 3] = (int32_t)aecm->channelStored[i + 3] << 16; + } + aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16; } // Initialize function pointers for ARM Neon platform. #if defined(WEBRTC_HAS_NEON) -static void WebRtcAecm_InitNeon(void) -{ +static void WebRtcAecm_InitNeon(void) { WebRtcAecm_StoreAdaptiveChannel = WebRtcAecm_StoreAdaptiveChannelNeon; WebRtcAecm_ResetAdaptiveChannel = WebRtcAecm_ResetAdaptiveChannelNeon; WebRtcAecm_CalcLinearEnergies = WebRtcAecm_CalcLinearEnergiesNeon; @@ -377,8 +338,7 @@ static void WebRtcAecm_InitNeon(void) // Initialize function pointers for MIPS platform. #if defined(MIPS32_LE) -static void WebRtcAecm_InitMips(void) -{ +static void WebRtcAecm_InitMips(void) { #if defined(MIPS_DSP_R1_LE) WebRtcAecm_StoreAdaptiveChannel = WebRtcAecm_StoreAdaptiveChannel_mips; WebRtcAecm_ResetAdaptiveChannel = WebRtcAecm_ResetAdaptiveChannel_mips; @@ -389,8 +349,8 @@ static void WebRtcAecm_InitMips(void) // WebRtcAecm_InitCore(...) // -// This function initializes the AECM instant created with WebRtcAecm_CreateCore(...) -// Input: +// This function initializes the AECM instant created with +// WebRtcAecm_CreateCore(...) Input: // - aecm : Pointer to the Echo Suppression instance // - samplingFreq : Sampling Frequency // @@ -401,152 +361,147 @@ static void WebRtcAecm_InitMips(void) // -1 - Error // int WebRtcAecm_InitCore(AecmCore* const aecm, int samplingFreq) { - int i = 0; - int32_t tmp32 = PART_LEN1 * PART_LEN1; - int16_t tmp16 = PART_LEN1; + int i = 0; + int32_t tmp32 = PART_LEN1 * PART_LEN1; + int16_t tmp16 = PART_LEN1; - if (samplingFreq != 8000 && samplingFreq != 16000) - { - samplingFreq = 8000; - return -1; - } - // sanity check of sampling frequency - aecm->mult = (int16_t)samplingFreq / 8000; + if (samplingFreq != 8000 && samplingFreq != 16000) { + samplingFreq = 8000; + return -1; + } + // sanity check of sampling frequency + aecm->mult = (int16_t)samplingFreq / 8000; - aecm->farBufWritePos = 0; - aecm->farBufReadPos = 0; - aecm->knownDelay = 0; - aecm->lastKnownDelay = 0; + aecm->farBufWritePos = 0; + aecm->farBufReadPos = 0; + aecm->knownDelay = 0; + aecm->lastKnownDelay = 0; - WebRtc_InitBuffer(aecm->farFrameBuf); - WebRtc_InitBuffer(aecm->nearNoisyFrameBuf); - WebRtc_InitBuffer(aecm->nearCleanFrameBuf); - WebRtc_InitBuffer(aecm->outFrameBuf); + WebRtc_InitBuffer(aecm->farFrameBuf); + WebRtc_InitBuffer(aecm->nearNoisyFrameBuf); + WebRtc_InitBuffer(aecm->nearCleanFrameBuf); + WebRtc_InitBuffer(aecm->outFrameBuf); - memset(aecm->xBuf_buf, 0, sizeof(aecm->xBuf_buf)); - memset(aecm->dBufClean_buf, 0, sizeof(aecm->dBufClean_buf)); - memset(aecm->dBufNoisy_buf, 0, sizeof(aecm->dBufNoisy_buf)); - memset(aecm->outBuf_buf, 0, sizeof(aecm->outBuf_buf)); + memset(aecm->xBuf_buf, 0, sizeof(aecm->xBuf_buf)); + memset(aecm->dBufClean_buf, 0, sizeof(aecm->dBufClean_buf)); + memset(aecm->dBufNoisy_buf, 0, sizeof(aecm->dBufNoisy_buf)); + memset(aecm->outBuf_buf, 0, sizeof(aecm->outBuf_buf)); - aecm->seed = 666; - aecm->totCount = 0; + aecm->seed = 666; + aecm->totCount = 0; - if (WebRtc_InitDelayEstimatorFarend(aecm->delay_estimator_farend) != 0) { - return -1; - } - if (WebRtc_InitDelayEstimator(aecm->delay_estimator) != 0) { - return -1; - } - // Set far end histories to zero - memset(aecm->far_history, 0, sizeof(uint16_t) * PART_LEN1 * MAX_DELAY); - memset(aecm->far_q_domains, 0, sizeof(int) * MAX_DELAY); - aecm->far_history_pos = MAX_DELAY; + if (WebRtc_InitDelayEstimatorFarend(aecm->delay_estimator_farend) != 0) { + return -1; + } + if (WebRtc_InitDelayEstimator(aecm->delay_estimator) != 0) { + return -1; + } + // Set far end histories to zero + memset(aecm->far_history, 0, sizeof(uint16_t) * PART_LEN1 * MAX_DELAY); + memset(aecm->far_q_domains, 0, sizeof(int) * MAX_DELAY); + aecm->far_history_pos = MAX_DELAY; - aecm->nlpFlag = 1; - aecm->fixedDelay = -1; + aecm->nlpFlag = 1; + aecm->fixedDelay = -1; - aecm->dfaCleanQDomain = 0; - aecm->dfaCleanQDomainOld = 0; - aecm->dfaNoisyQDomain = 0; - aecm->dfaNoisyQDomainOld = 0; + aecm->dfaCleanQDomain = 0; + aecm->dfaCleanQDomainOld = 0; + aecm->dfaNoisyQDomain = 0; + aecm->dfaNoisyQDomainOld = 0; - memset(aecm->nearLogEnergy, 0, sizeof(aecm->nearLogEnergy)); - aecm->farLogEnergy = 0; - memset(aecm->echoAdaptLogEnergy, 0, sizeof(aecm->echoAdaptLogEnergy)); - memset(aecm->echoStoredLogEnergy, 0, sizeof(aecm->echoStoredLogEnergy)); + memset(aecm->nearLogEnergy, 0, sizeof(aecm->nearLogEnergy)); + aecm->farLogEnergy = 0; + memset(aecm->echoAdaptLogEnergy, 0, sizeof(aecm->echoAdaptLogEnergy)); + memset(aecm->echoStoredLogEnergy, 0, sizeof(aecm->echoStoredLogEnergy)); - // Initialize the echo channels with a stored shape. - if (samplingFreq == 8000) - { - WebRtcAecm_InitEchoPathCore(aecm, kChannelStored8kHz); - } - else - { - WebRtcAecm_InitEchoPathCore(aecm, kChannelStored16kHz); - } + // Initialize the echo channels with a stored shape. + if (samplingFreq == 8000) { + WebRtcAecm_InitEchoPathCore(aecm, kChannelStored8kHz); + } else { + WebRtcAecm_InitEchoPathCore(aecm, kChannelStored16kHz); + } - memset(aecm->echoFilt, 0, sizeof(aecm->echoFilt)); - memset(aecm->nearFilt, 0, sizeof(aecm->nearFilt)); - aecm->noiseEstCtr = 0; + memset(aecm->echoFilt, 0, sizeof(aecm->echoFilt)); + memset(aecm->nearFilt, 0, sizeof(aecm->nearFilt)); + aecm->noiseEstCtr = 0; - aecm->cngMode = AecmTrue; + aecm->cngMode = AecmTrue; - memset(aecm->noiseEstTooLowCtr, 0, sizeof(aecm->noiseEstTooLowCtr)); - memset(aecm->noiseEstTooHighCtr, 0, sizeof(aecm->noiseEstTooHighCtr)); - // Shape the initial noise level to an approximate pink noise. - for (i = 0; i < (PART_LEN1 >> 1) - 1; i++) - { - aecm->noiseEst[i] = (tmp32 << 8); - tmp16--; - tmp32 -= (int32_t)((tmp16 << 1) + 1); - } - for (; i < PART_LEN1; i++) - { - aecm->noiseEst[i] = (tmp32 << 8); - } + memset(aecm->noiseEstTooLowCtr, 0, sizeof(aecm->noiseEstTooLowCtr)); + memset(aecm->noiseEstTooHighCtr, 0, sizeof(aecm->noiseEstTooHighCtr)); + // Shape the initial noise level to an approximate pink noise. + for (i = 0; i < (PART_LEN1 >> 1) - 1; i++) { + aecm->noiseEst[i] = (tmp32 << 8); + tmp16--; + tmp32 -= (int32_t)((tmp16 << 1) + 1); + } + for (; i < PART_LEN1; i++) { + aecm->noiseEst[i] = (tmp32 << 8); + } - aecm->farEnergyMin = WEBRTC_SPL_WORD16_MAX; - aecm->farEnergyMax = WEBRTC_SPL_WORD16_MIN; - aecm->farEnergyMaxMin = 0; - aecm->farEnergyVAD = FAR_ENERGY_MIN; // This prevents false speech detection at the - // beginning. - aecm->farEnergyMSE = 0; - aecm->currentVADValue = 0; - aecm->vadUpdateCount = 0; - aecm->firstVAD = 1; + aecm->farEnergyMin = WEBRTC_SPL_WORD16_MAX; + aecm->farEnergyMax = WEBRTC_SPL_WORD16_MIN; + aecm->farEnergyMaxMin = 0; + aecm->farEnergyVAD = + FAR_ENERGY_MIN; // This prevents false speech detection at the + // beginning. + aecm->farEnergyMSE = 0; + aecm->currentVADValue = 0; + aecm->vadUpdateCount = 0; + aecm->firstVAD = 1; - aecm->startupState = 0; - aecm->supGain = SUPGAIN_DEFAULT; - aecm->supGainOld = SUPGAIN_DEFAULT; + aecm->startupState = 0; + aecm->supGain = SUPGAIN_DEFAULT; + aecm->supGainOld = SUPGAIN_DEFAULT; - aecm->supGainErrParamA = SUPGAIN_ERROR_PARAM_A; - aecm->supGainErrParamD = SUPGAIN_ERROR_PARAM_D; - aecm->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B; - aecm->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D; + aecm->supGainErrParamA = SUPGAIN_ERROR_PARAM_A; + aecm->supGainErrParamD = SUPGAIN_ERROR_PARAM_D; + aecm->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B; + aecm->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D; - // Assert a preprocessor definition at compile-time. It's an assumption - // used in assembly code, so check the assembly files before any change. - static_assert(PART_LEN % 16 == 0, "PART_LEN is not a multiple of 16"); + // Assert a preprocessor definition at compile-time. It's an assumption + // used in assembly code, so check the assembly files before any change. + static_assert(PART_LEN % 16 == 0, "PART_LEN is not a multiple of 16"); - // Initialize function pointers. - WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC; - WebRtcAecm_StoreAdaptiveChannel = StoreAdaptiveChannelC; - WebRtcAecm_ResetAdaptiveChannel = ResetAdaptiveChannelC; + // Initialize function pointers. + WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC; + WebRtcAecm_StoreAdaptiveChannel = StoreAdaptiveChannelC; + WebRtcAecm_ResetAdaptiveChannel = ResetAdaptiveChannelC; #if defined(WEBRTC_HAS_NEON) - WebRtcAecm_InitNeon(); + WebRtcAecm_InitNeon(); #endif #if defined(MIPS32_LE) - WebRtcAecm_InitMips(); + WebRtcAecm_InitMips(); #endif - return 0; + return 0; } // TODO(bjornv): This function is currently not used. Add support for these // parameters from a higher level int WebRtcAecm_Control(AecmCore* aecm, int delay, int nlpFlag) { - aecm->nlpFlag = nlpFlag; - aecm->fixedDelay = delay; + aecm->nlpFlag = nlpFlag; + aecm->fixedDelay = delay; - return 0; + return 0; } void WebRtcAecm_FreeCore(AecmCore* aecm) { - if (aecm == NULL) { - return; - } + if (aecm == NULL) { + return; + } - WebRtc_FreeBuffer(aecm->farFrameBuf); - WebRtc_FreeBuffer(aecm->nearNoisyFrameBuf); - WebRtc_FreeBuffer(aecm->nearCleanFrameBuf); - WebRtc_FreeBuffer(aecm->outFrameBuf); + WebRtc_FreeBuffer(aecm->farFrameBuf); + WebRtc_FreeBuffer(aecm->nearNoisyFrameBuf); + WebRtc_FreeBuffer(aecm->nearCleanFrameBuf); + WebRtc_FreeBuffer(aecm->outFrameBuf); - WebRtc_FreeDelayEstimator(aecm->delay_estimator); - WebRtc_FreeDelayEstimatorFarend(aecm->delay_estimator_farend); - WebRtcSpl_FreeRealFFT(aecm->real_fft); + WebRtc_FreeDelayEstimator(aecm->delay_estimator); + WebRtc_FreeDelayEstimatorFarend(aecm->delay_estimator_farend); + WebRtcSpl_FreeRealFFT(aecm->real_fft); - free(aecm); + free(aecm); } int WebRtcAecm_ProcessFrame(AecmCore* aecm, @@ -554,89 +509,72 @@ int WebRtcAecm_ProcessFrame(AecmCore* aecm, const int16_t* nearendNoisy, const int16_t* nearendClean, int16_t* out) { - int16_t outBlock_buf[PART_LEN + 8]; // Align buffer to 8-byte boundary. - int16_t* outBlock = (int16_t*) (((uintptr_t) outBlock_buf + 15) & ~ 15); + int16_t outBlock_buf[PART_LEN + 8]; // Align buffer to 8-byte boundary. + int16_t* outBlock = (int16_t*)(((uintptr_t)outBlock_buf + 15) & ~15); - int16_t farFrame[FRAME_LEN]; - const int16_t* out_ptr = NULL; - int size = 0; + int16_t farFrame[FRAME_LEN]; + const int16_t* out_ptr = NULL; + int size = 0; - // Buffer the current frame. - // Fetch an older one corresponding to the delay. - WebRtcAecm_BufferFarFrame(aecm, farend, FRAME_LEN); - WebRtcAecm_FetchFarFrame(aecm, farFrame, FRAME_LEN, aecm->knownDelay); + // Buffer the current frame. + // Fetch an older one corresponding to the delay. + WebRtcAecm_BufferFarFrame(aecm, farend, FRAME_LEN); + WebRtcAecm_FetchFarFrame(aecm, farFrame, FRAME_LEN, aecm->knownDelay); - // Buffer the synchronized far and near frames, - // to pass the smaller blocks individually. - WebRtc_WriteBuffer(aecm->farFrameBuf, farFrame, FRAME_LEN); - WebRtc_WriteBuffer(aecm->nearNoisyFrameBuf, nearendNoisy, FRAME_LEN); - if (nearendClean != NULL) - { - WebRtc_WriteBuffer(aecm->nearCleanFrameBuf, nearendClean, FRAME_LEN); + // Buffer the synchronized far and near frames, + // to pass the smaller blocks individually. + WebRtc_WriteBuffer(aecm->farFrameBuf, farFrame, FRAME_LEN); + WebRtc_WriteBuffer(aecm->nearNoisyFrameBuf, nearendNoisy, FRAME_LEN); + if (nearendClean != NULL) { + WebRtc_WriteBuffer(aecm->nearCleanFrameBuf, nearendClean, FRAME_LEN); + } + + // Process as many blocks as possible. + while (WebRtc_available_read(aecm->farFrameBuf) >= PART_LEN) { + int16_t far_block[PART_LEN]; + const int16_t* far_block_ptr = NULL; + int16_t near_noisy_block[PART_LEN]; + const int16_t* near_noisy_block_ptr = NULL; + + WebRtc_ReadBuffer(aecm->farFrameBuf, (void**)&far_block_ptr, far_block, + PART_LEN); + WebRtc_ReadBuffer(aecm->nearNoisyFrameBuf, (void**)&near_noisy_block_ptr, + near_noisy_block, PART_LEN); + if (nearendClean != NULL) { + int16_t near_clean_block[PART_LEN]; + const int16_t* near_clean_block_ptr = NULL; + + WebRtc_ReadBuffer(aecm->nearCleanFrameBuf, (void**)&near_clean_block_ptr, + near_clean_block, PART_LEN); + if (WebRtcAecm_ProcessBlock(aecm, far_block_ptr, near_noisy_block_ptr, + near_clean_block_ptr, outBlock) == -1) { + return -1; + } + } else { + if (WebRtcAecm_ProcessBlock(aecm, far_block_ptr, near_noisy_block_ptr, + NULL, outBlock) == -1) { + return -1; + } } - // Process as many blocks as possible. - while (WebRtc_available_read(aecm->farFrameBuf) >= PART_LEN) - { - int16_t far_block[PART_LEN]; - const int16_t* far_block_ptr = NULL; - int16_t near_noisy_block[PART_LEN]; - const int16_t* near_noisy_block_ptr = NULL; + WebRtc_WriteBuffer(aecm->outFrameBuf, outBlock, PART_LEN); + } - WebRtc_ReadBuffer(aecm->farFrameBuf, (void**) &far_block_ptr, far_block, - PART_LEN); - WebRtc_ReadBuffer(aecm->nearNoisyFrameBuf, - (void**) &near_noisy_block_ptr, - near_noisy_block, - PART_LEN); - if (nearendClean != NULL) - { - int16_t near_clean_block[PART_LEN]; - const int16_t* near_clean_block_ptr = NULL; + // Stuff the out buffer if we have less than a frame to output. + // This should only happen for the first frame. + size = (int)WebRtc_available_read(aecm->outFrameBuf); + if (size < FRAME_LEN) { + WebRtc_MoveReadPtr(aecm->outFrameBuf, size - FRAME_LEN); + } - WebRtc_ReadBuffer(aecm->nearCleanFrameBuf, - (void**) &near_clean_block_ptr, - near_clean_block, - PART_LEN); - if (WebRtcAecm_ProcessBlock(aecm, - far_block_ptr, - near_noisy_block_ptr, - near_clean_block_ptr, - outBlock) == -1) - { - return -1; - } - } else - { - if (WebRtcAecm_ProcessBlock(aecm, - far_block_ptr, - near_noisy_block_ptr, - NULL, - outBlock) == -1) - { - return -1; - } - } + // Obtain an output frame. + WebRtc_ReadBuffer(aecm->outFrameBuf, (void**)&out_ptr, out, FRAME_LEN); + if (out_ptr != out) { + // ReadBuffer() hasn't copied to |out| in this case. + memcpy(out, out_ptr, FRAME_LEN * sizeof(int16_t)); + } - WebRtc_WriteBuffer(aecm->outFrameBuf, outBlock, PART_LEN); - } - - // Stuff the out buffer if we have less than a frame to output. - // This should only happen for the first frame. - size = (int) WebRtc_available_read(aecm->outFrameBuf); - if (size < FRAME_LEN) - { - WebRtc_MoveReadPtr(aecm->outFrameBuf, size - FRAME_LEN); - } - - // Obtain an output frame. - WebRtc_ReadBuffer(aecm->outFrameBuf, (void**) &out_ptr, out, FRAME_LEN); - if (out_ptr != out) { - // ReadBuffer() hasn't copied to |out| in this case. - memcpy(out, out_ptr, FRAME_LEN * sizeof(int16_t)); - } - - return 0; + return 0; } // WebRtcAecm_AsymFilt(...) @@ -653,26 +591,23 @@ int WebRtcAecm_ProcessFrame(AecmCore* aecm, // // Return: - Filtered value. // -int16_t WebRtcAecm_AsymFilt(const int16_t filtOld, const int16_t inVal, +int16_t WebRtcAecm_AsymFilt(const int16_t filtOld, + const int16_t inVal, const int16_t stepSizePos, - const int16_t stepSizeNeg) -{ - int16_t retVal; + const int16_t stepSizeNeg) { + int16_t retVal; - if ((filtOld == WEBRTC_SPL_WORD16_MAX) | (filtOld == WEBRTC_SPL_WORD16_MIN)) - { - return inVal; - } - retVal = filtOld; - if (filtOld > inVal) - { - retVal -= (filtOld - inVal) >> stepSizeNeg; - } else - { - retVal += (inVal - filtOld) >> stepSizePos; - } + if ((filtOld == WEBRTC_SPL_WORD16_MAX) | (filtOld == WEBRTC_SPL_WORD16_MIN)) { + return inVal; + } + retVal = filtOld; + if (filtOld > inVal) { + retVal -= (filtOld - inVal) >> stepSizeNeg; + } else { + retVal += (inVal - filtOld) >> stepSizePos; + } - return retVal; + return retVal; } // ExtractFractionPart(a, zeros) @@ -700,8 +635,9 @@ static int16_t LogOfEnergyInQ8(uint32_t energy, int q_domain) { // WebRtcAecm_CalcEnergies(...) // -// This function calculates the log of energies for nearend, farend and estimated -// echoes. There is also an update of energy decision levels, i.e. internal VAD. +// This function calculates the log of energies for nearend, farend and +// estimated echoes. There is also an update of energy decision levels, i.e. +// internal VAD. // // // @param aecm [i/o] Handle of the AECM instance. @@ -716,123 +652,112 @@ void WebRtcAecm_CalcEnergies(AecmCore* aecm, const int16_t far_q, const uint32_t nearEner, int32_t* echoEst) { - // Local variables - uint32_t tmpAdapt = 0; - uint32_t tmpStored = 0; - uint32_t tmpFar = 0; + // Local variables + uint32_t tmpAdapt = 0; + uint32_t tmpStored = 0; + uint32_t tmpFar = 0; - int i; + int i; - int16_t tmp16; - int16_t increase_max_shifts = 4; - int16_t decrease_max_shifts = 11; - int16_t increase_min_shifts = 11; - int16_t decrease_min_shifts = 3; + int16_t tmp16; + int16_t increase_max_shifts = 4; + int16_t decrease_max_shifts = 11; + int16_t increase_min_shifts = 11; + int16_t decrease_min_shifts = 3; - // Get log of near end energy and store in buffer + // Get log of near end energy and store in buffer - // Shift buffer - memmove(aecm->nearLogEnergy + 1, aecm->nearLogEnergy, - sizeof(int16_t) * (MAX_BUF_LEN - 1)); + // Shift buffer + memmove(aecm->nearLogEnergy + 1, aecm->nearLogEnergy, + sizeof(int16_t) * (MAX_BUF_LEN - 1)); - // Logarithm of integrated magnitude spectrum (nearEner) - aecm->nearLogEnergy[0] = LogOfEnergyInQ8(nearEner, aecm->dfaNoisyQDomain); + // Logarithm of integrated magnitude spectrum (nearEner) + aecm->nearLogEnergy[0] = LogOfEnergyInQ8(nearEner, aecm->dfaNoisyQDomain); - WebRtcAecm_CalcLinearEnergies(aecm, far_spectrum, echoEst, &tmpFar, &tmpAdapt, &tmpStored); + WebRtcAecm_CalcLinearEnergies(aecm, far_spectrum, echoEst, &tmpFar, &tmpAdapt, + &tmpStored); - // Shift buffers - memmove(aecm->echoAdaptLogEnergy + 1, aecm->echoAdaptLogEnergy, - sizeof(int16_t) * (MAX_BUF_LEN - 1)); - memmove(aecm->echoStoredLogEnergy + 1, aecm->echoStoredLogEnergy, - sizeof(int16_t) * (MAX_BUF_LEN - 1)); + // Shift buffers + memmove(aecm->echoAdaptLogEnergy + 1, aecm->echoAdaptLogEnergy, + sizeof(int16_t) * (MAX_BUF_LEN - 1)); + memmove(aecm->echoStoredLogEnergy + 1, aecm->echoStoredLogEnergy, + sizeof(int16_t) * (MAX_BUF_LEN - 1)); - // Logarithm of delayed far end energy - aecm->farLogEnergy = LogOfEnergyInQ8(tmpFar, far_q); + // Logarithm of delayed far end energy + aecm->farLogEnergy = LogOfEnergyInQ8(tmpFar, far_q); - // Logarithm of estimated echo energy through adapted channel - aecm->echoAdaptLogEnergy[0] = LogOfEnergyInQ8(tmpAdapt, - RESOLUTION_CHANNEL16 + far_q); + // Logarithm of estimated echo energy through adapted channel + aecm->echoAdaptLogEnergy[0] = + LogOfEnergyInQ8(tmpAdapt, RESOLUTION_CHANNEL16 + far_q); - // Logarithm of estimated echo energy through stored channel - aecm->echoStoredLogEnergy[0] = - LogOfEnergyInQ8(tmpStored, RESOLUTION_CHANNEL16 + far_q); + // Logarithm of estimated echo energy through stored channel + aecm->echoStoredLogEnergy[0] = + LogOfEnergyInQ8(tmpStored, RESOLUTION_CHANNEL16 + far_q); - // Update farend energy levels (min, max, vad, mse) - if (aecm->farLogEnergy > FAR_ENERGY_MIN) - { - if (aecm->startupState == 0) - { - increase_max_shifts = 2; - decrease_min_shifts = 2; - increase_min_shifts = 8; - } - - aecm->farEnergyMin = WebRtcAecm_AsymFilt(aecm->farEnergyMin, aecm->farLogEnergy, - increase_min_shifts, decrease_min_shifts); - aecm->farEnergyMax = WebRtcAecm_AsymFilt(aecm->farEnergyMax, aecm->farLogEnergy, - increase_max_shifts, decrease_max_shifts); - aecm->farEnergyMaxMin = (aecm->farEnergyMax - aecm->farEnergyMin); - - // Dynamic VAD region size - tmp16 = 2560 - aecm->farEnergyMin; - if (tmp16 > 0) - { - tmp16 = (int16_t)((tmp16 * FAR_ENERGY_VAD_REGION) >> 9); - } else - { - tmp16 = 0; - } - tmp16 += FAR_ENERGY_VAD_REGION; - - if ((aecm->startupState == 0) | (aecm->vadUpdateCount > 1024)) - { - // In startup phase or VAD update halted - aecm->farEnergyVAD = aecm->farEnergyMin + tmp16; - } else - { - if (aecm->farEnergyVAD > aecm->farLogEnergy) - { - aecm->farEnergyVAD += - (aecm->farLogEnergy + tmp16 - aecm->farEnergyVAD) >> 6; - aecm->vadUpdateCount = 0; - } else - { - aecm->vadUpdateCount++; - } - } - // Put MSE threshold higher than VAD - aecm->farEnergyMSE = aecm->farEnergyVAD + (1 << 8); + // Update farend energy levels (min, max, vad, mse) + if (aecm->farLogEnergy > FAR_ENERGY_MIN) { + if (aecm->startupState == 0) { + increase_max_shifts = 2; + decrease_min_shifts = 2; + increase_min_shifts = 8; } - // Update VAD variables - if (aecm->farLogEnergy > aecm->farEnergyVAD) - { - if ((aecm->startupState == 0) | (aecm->farEnergyMaxMin > FAR_ENERGY_DIFF)) - { - // We are in startup or have significant dynamics in input speech level - aecm->currentVADValue = 1; - } - } else - { - aecm->currentVADValue = 0; + aecm->farEnergyMin = + WebRtcAecm_AsymFilt(aecm->farEnergyMin, aecm->farLogEnergy, + increase_min_shifts, decrease_min_shifts); + aecm->farEnergyMax = + WebRtcAecm_AsymFilt(aecm->farEnergyMax, aecm->farLogEnergy, + increase_max_shifts, decrease_max_shifts); + aecm->farEnergyMaxMin = (aecm->farEnergyMax - aecm->farEnergyMin); + + // Dynamic VAD region size + tmp16 = 2560 - aecm->farEnergyMin; + if (tmp16 > 0) { + tmp16 = (int16_t)((tmp16 * FAR_ENERGY_VAD_REGION) >> 9); + } else { + tmp16 = 0; } - if ((aecm->currentVADValue) && (aecm->firstVAD)) - { - aecm->firstVAD = 0; - if (aecm->echoAdaptLogEnergy[0] > aecm->nearLogEnergy[0]) - { - // The estimated echo has higher energy than the near end signal. - // This means that the initialization was too aggressive. Scale - // down by a factor 8 - for (i = 0; i < PART_LEN1; i++) - { - aecm->channelAdapt16[i] >>= 3; - } - // Compensate the adapted echo energy level accordingly. - aecm->echoAdaptLogEnergy[0] -= (3 << 8); - aecm->firstVAD = 1; - } + tmp16 += FAR_ENERGY_VAD_REGION; + + if ((aecm->startupState == 0) | (aecm->vadUpdateCount > 1024)) { + // In startup phase or VAD update halted + aecm->farEnergyVAD = aecm->farEnergyMin + tmp16; + } else { + if (aecm->farEnergyVAD > aecm->farLogEnergy) { + aecm->farEnergyVAD += + (aecm->farLogEnergy + tmp16 - aecm->farEnergyVAD) >> 6; + aecm->vadUpdateCount = 0; + } else { + aecm->vadUpdateCount++; + } } + // Put MSE threshold higher than VAD + aecm->farEnergyMSE = aecm->farEnergyVAD + (1 << 8); + } + + // Update VAD variables + if (aecm->farLogEnergy > aecm->farEnergyVAD) { + if ((aecm->startupState == 0) | (aecm->farEnergyMaxMin > FAR_ENERGY_DIFF)) { + // We are in startup or have significant dynamics in input speech level + aecm->currentVADValue = 1; + } + } else { + aecm->currentVADValue = 0; + } + if ((aecm->currentVADValue) && (aecm->firstVAD)) { + aecm->firstVAD = 0; + if (aecm->echoAdaptLogEnergy[0] > aecm->nearLogEnergy[0]) { + // The estimated echo has higher energy than the near end signal. + // This means that the initialization was too aggressive. Scale + // down by a factor 8 + for (i = 0; i < PART_LEN1; i++) { + aecm->channelAdapt16[i] >>= 3; + } + // Compensate the adapted echo energy level accordingly. + aecm->echoAdaptLogEnergy[0] -= (3 << 8); + aecm->firstVAD = 1; + } + } } // WebRtcAecm_CalcStepSize(...) @@ -841,52 +766,50 @@ void WebRtcAecm_CalcEnergies(AecmCore* aecm, // // // @param aecm [in] Handle of the AECM instance. -// @param mu [out] (Return value) Stepsize in log2(), i.e. number of shifts. +// @param mu [out] (Return value) Stepsize in log2(), i.e. number of +// shifts. // // int16_t WebRtcAecm_CalcStepSize(AecmCore* const aecm) { - int32_t tmp32; - int16_t tmp16; - int16_t mu = MU_MAX; + int32_t tmp32; + int16_t tmp16; + int16_t mu = MU_MAX; - // Here we calculate the step size mu used in the - // following NLMS based Channel estimation algorithm - if (!aecm->currentVADValue) - { - // Far end energy level too low, no channel update - mu = 0; - } else if (aecm->startupState > 0) - { - if (aecm->farEnergyMin >= aecm->farEnergyMax) - { - mu = MU_MIN; - } else - { - tmp16 = (aecm->farLogEnergy - aecm->farEnergyMin); - tmp32 = tmp16 * MU_DIFF; - tmp32 = WebRtcSpl_DivW32W16(tmp32, aecm->farEnergyMaxMin); - mu = MU_MIN - 1 - (int16_t)(tmp32); - // The -1 is an alternative to rounding. This way we get a larger - // stepsize, so we in some sense compensate for truncation in NLMS - } - if (mu < MU_MAX) - { - mu = MU_MAX; // Equivalent with maximum step size of 2^-MU_MAX - } + // Here we calculate the step size mu used in the + // following NLMS based Channel estimation algorithm + if (!aecm->currentVADValue) { + // Far end energy level too low, no channel update + mu = 0; + } else if (aecm->startupState > 0) { + if (aecm->farEnergyMin >= aecm->farEnergyMax) { + mu = MU_MIN; + } else { + tmp16 = (aecm->farLogEnergy - aecm->farEnergyMin); + tmp32 = tmp16 * MU_DIFF; + tmp32 = WebRtcSpl_DivW32W16(tmp32, aecm->farEnergyMaxMin); + mu = MU_MIN - 1 - (int16_t)(tmp32); + // The -1 is an alternative to rounding. This way we get a larger + // stepsize, so we in some sense compensate for truncation in NLMS } + if (mu < MU_MAX) { + mu = MU_MAX; // Equivalent with maximum step size of 2^-MU_MAX + } + } - return mu; + return mu; } // WebRtcAecm_UpdateChannel(...) // -// This function performs channel estimation. NLMS and decision on channel storage. +// This function performs channel estimation. NLMS and decision on channel +// storage. // // // @param aecm [i/o] Handle of the AECM instance. // @param far_spectrum [in] Absolute value of the farend signal in Q(far_q) // @param far_q [in] Q-domain of the farend signal -// @param dfa [in] Absolute value of the nearend signal (Q[aecm->dfaQDomain]) +// @param dfa [in] Absolute value of the nearend signal +// (Q[aecm->dfaQDomain]) // @param mu [in] NLMS step size. // @param echoEst [i/o] Estimated echo in Q(far_q+RESOLUTION_CHANNEL16). // @@ -896,343 +819,301 @@ void WebRtcAecm_UpdateChannel(AecmCore* aecm, const uint16_t* const dfa, const int16_t mu, int32_t* echoEst) { - uint32_t tmpU32no1, tmpU32no2; - int32_t tmp32no1, tmp32no2; - int32_t mseStored; - int32_t mseAdapt; + uint32_t tmpU32no1, tmpU32no2; + int32_t tmp32no1, tmp32no2; + int32_t mseStored; + int32_t mseAdapt; - int i; + int i; - int16_t zerosFar, zerosNum, zerosCh, zerosDfa; - int16_t shiftChFar, shiftNum, shift2ResChan; - int16_t tmp16no1; - int16_t xfaQ, dfaQ; + int16_t zerosFar, zerosNum, zerosCh, zerosDfa; + int16_t shiftChFar, shiftNum, shift2ResChan; + int16_t tmp16no1; + int16_t xfaQ, dfaQ; - // This is the channel estimation algorithm. It is base on NLMS but has a variable step - // length, which was calculated above. - if (mu) - { - for (i = 0; i < PART_LEN1; i++) - { - // Determine norm of channel and farend to make sure we don't get overflow in - // multiplication - zerosCh = WebRtcSpl_NormU32(aecm->channelAdapt32[i]); - zerosFar = WebRtcSpl_NormU32((uint32_t)far_spectrum[i]); - if (zerosCh + zerosFar > 31) - { - // Multiplication is safe - tmpU32no1 = WEBRTC_SPL_UMUL_32_16(aecm->channelAdapt32[i], - far_spectrum[i]); - shiftChFar = 0; - } else - { - // We need to shift down before multiplication - shiftChFar = 32 - zerosCh - zerosFar; - // If zerosCh == zerosFar == 0, shiftChFar is 32. A - // right shift of 32 is undefined. To avoid that, we - // do this check. - tmpU32no1 = rtc::dchecked_cast( - shiftChFar >= 32 - ? 0 - : aecm->channelAdapt32[i] >> shiftChFar) * - far_spectrum[i]; - } - // Determine Q-domain of numerator - zerosNum = WebRtcSpl_NormU32(tmpU32no1); - if (dfa[i]) - { - zerosDfa = WebRtcSpl_NormU32((uint32_t)dfa[i]); - } else - { - zerosDfa = 32; - } - tmp16no1 = zerosDfa - 2 + aecm->dfaNoisyQDomain - - RESOLUTION_CHANNEL32 - far_q + shiftChFar; - if (zerosNum > tmp16no1 + 1) - { - xfaQ = tmp16no1; - dfaQ = zerosDfa - 2; - } else - { - xfaQ = zerosNum - 2; - dfaQ = RESOLUTION_CHANNEL32 + far_q - aecm->dfaNoisyQDomain - - shiftChFar + xfaQ; - } - // Add in the same Q-domain - tmpU32no1 = WEBRTC_SPL_SHIFT_W32(tmpU32no1, xfaQ); - tmpU32no2 = WEBRTC_SPL_SHIFT_W32((uint32_t)dfa[i], dfaQ); - tmp32no1 = (int32_t)tmpU32no2 - (int32_t)tmpU32no1; - zerosNum = WebRtcSpl_NormW32(tmp32no1); - if ((tmp32no1) && (far_spectrum[i] > (CHANNEL_VAD << far_q))) - { - // - // Update is needed - // - // This is what we would like to compute - // - // tmp32no1 = dfa[i] - (aecm->channelAdapt[i] * far_spectrum[i]) - // tmp32norm = (i + 1) - // aecm->channelAdapt[i] += (2^mu) * tmp32no1 - // / (tmp32norm * far_spectrum[i]) - // + // This is the channel estimation algorithm. It is base on NLMS but has a + // variable step length, which was calculated above. + if (mu) { + for (i = 0; i < PART_LEN1; i++) { + // Determine norm of channel and farend to make sure we don't get overflow + // in multiplication + zerosCh = WebRtcSpl_NormU32(aecm->channelAdapt32[i]); + zerosFar = WebRtcSpl_NormU32((uint32_t)far_spectrum[i]); + if (zerosCh + zerosFar > 31) { + // Multiplication is safe + tmpU32no1 = + WEBRTC_SPL_UMUL_32_16(aecm->channelAdapt32[i], far_spectrum[i]); + shiftChFar = 0; + } else { + // We need to shift down before multiplication + shiftChFar = 32 - zerosCh - zerosFar; + // If zerosCh == zerosFar == 0, shiftChFar is 32. A + // right shift of 32 is undefined. To avoid that, we + // do this check. + tmpU32no1 = + rtc::dchecked_cast( + shiftChFar >= 32 ? 0 : aecm->channelAdapt32[i] >> shiftChFar) * + far_spectrum[i]; + } + // Determine Q-domain of numerator + zerosNum = WebRtcSpl_NormU32(tmpU32no1); + if (dfa[i]) { + zerosDfa = WebRtcSpl_NormU32((uint32_t)dfa[i]); + } else { + zerosDfa = 32; + } + tmp16no1 = zerosDfa - 2 + aecm->dfaNoisyQDomain - RESOLUTION_CHANNEL32 - + far_q + shiftChFar; + if (zerosNum > tmp16no1 + 1) { + xfaQ = tmp16no1; + dfaQ = zerosDfa - 2; + } else { + xfaQ = zerosNum - 2; + dfaQ = RESOLUTION_CHANNEL32 + far_q - aecm->dfaNoisyQDomain - + shiftChFar + xfaQ; + } + // Add in the same Q-domain + tmpU32no1 = WEBRTC_SPL_SHIFT_W32(tmpU32no1, xfaQ); + tmpU32no2 = WEBRTC_SPL_SHIFT_W32((uint32_t)dfa[i], dfaQ); + tmp32no1 = (int32_t)tmpU32no2 - (int32_t)tmpU32no1; + zerosNum = WebRtcSpl_NormW32(tmp32no1); + if ((tmp32no1) && (far_spectrum[i] > (CHANNEL_VAD << far_q))) { + // + // Update is needed + // + // This is what we would like to compute + // + // tmp32no1 = dfa[i] - (aecm->channelAdapt[i] * far_spectrum[i]) + // tmp32norm = (i + 1) + // aecm->channelAdapt[i] += (2^mu) * tmp32no1 + // / (tmp32norm * far_spectrum[i]) + // - // Make sure we don't get overflow in multiplication. - if (zerosNum + zerosFar > 31) - { - if (tmp32no1 > 0) - { - tmp32no2 = (int32_t)WEBRTC_SPL_UMUL_32_16(tmp32no1, - far_spectrum[i]); - } else - { - tmp32no2 = -(int32_t)WEBRTC_SPL_UMUL_32_16(-tmp32no1, - far_spectrum[i]); - } - shiftNum = 0; - } else - { - shiftNum = 32 - (zerosNum + zerosFar); - if (tmp32no1 > 0) - { - tmp32no2 = (tmp32no1 >> shiftNum) * far_spectrum[i]; - } else - { - tmp32no2 = -((-tmp32no1 >> shiftNum) * far_spectrum[i]); - } - } - // Normalize with respect to frequency bin - tmp32no2 = WebRtcSpl_DivW32W16(tmp32no2, i + 1); - // Make sure we are in the right Q-domain - shift2ResChan = shiftNum + shiftChFar - xfaQ - mu - ((30 - zerosFar) << 1); - if (WebRtcSpl_NormW32(tmp32no2) < shift2ResChan) - { - tmp32no2 = WEBRTC_SPL_WORD32_MAX; - } else - { - tmp32no2 = WEBRTC_SPL_SHIFT_W32(tmp32no2, shift2ResChan); - } - aecm->channelAdapt32[i] = - WebRtcSpl_AddSatW32(aecm->channelAdapt32[i], tmp32no2); - if (aecm->channelAdapt32[i] < 0) - { - // We can never have negative channel gain - aecm->channelAdapt32[i] = 0; - } - aecm->channelAdapt16[i] = - (int16_t)(aecm->channelAdapt32[i] >> 16); - } + // Make sure we don't get overflow in multiplication. + if (zerosNum + zerosFar > 31) { + if (tmp32no1 > 0) { + tmp32no2 = + (int32_t)WEBRTC_SPL_UMUL_32_16(tmp32no1, far_spectrum[i]); + } else { + tmp32no2 = + -(int32_t)WEBRTC_SPL_UMUL_32_16(-tmp32no1, far_spectrum[i]); + } + shiftNum = 0; + } else { + shiftNum = 32 - (zerosNum + zerosFar); + if (tmp32no1 > 0) { + tmp32no2 = (tmp32no1 >> shiftNum) * far_spectrum[i]; + } else { + tmp32no2 = -((-tmp32no1 >> shiftNum) * far_spectrum[i]); + } } + // Normalize with respect to frequency bin + tmp32no2 = WebRtcSpl_DivW32W16(tmp32no2, i + 1); + // Make sure we are in the right Q-domain + shift2ResChan = + shiftNum + shiftChFar - xfaQ - mu - ((30 - zerosFar) << 1); + if (WebRtcSpl_NormW32(tmp32no2) < shift2ResChan) { + tmp32no2 = WEBRTC_SPL_WORD32_MAX; + } else { + tmp32no2 = WEBRTC_SPL_SHIFT_W32(tmp32no2, shift2ResChan); + } + aecm->channelAdapt32[i] = + WebRtcSpl_AddSatW32(aecm->channelAdapt32[i], tmp32no2); + if (aecm->channelAdapt32[i] < 0) { + // We can never have negative channel gain + aecm->channelAdapt32[i] = 0; + } + aecm->channelAdapt16[i] = (int16_t)(aecm->channelAdapt32[i] >> 16); + } } - // END: Adaptive channel update + } + // END: Adaptive channel update - // Determine if we should store or restore the channel - if ((aecm->startupState == 0) & (aecm->currentVADValue)) - { - // During startup we store the channel every block, - // and we recalculate echo estimate + // Determine if we should store or restore the channel + if ((aecm->startupState == 0) & (aecm->currentVADValue)) { + // During startup we store the channel every block, + // and we recalculate echo estimate + WebRtcAecm_StoreAdaptiveChannel(aecm, far_spectrum, echoEst); + } else { + if (aecm->farLogEnergy < aecm->farEnergyMSE) { + aecm->mseChannelCount = 0; + } else { + aecm->mseChannelCount++; + } + // Enough data for validation. Store channel if we can. + if (aecm->mseChannelCount >= (MIN_MSE_COUNT + 10)) { + // We have enough data. + // Calculate MSE of "Adapt" and "Stored" versions. + // It is actually not MSE, but average absolute error. + mseStored = 0; + mseAdapt = 0; + for (i = 0; i < MIN_MSE_COUNT; i++) { + tmp32no1 = ((int32_t)aecm->echoStoredLogEnergy[i] - + (int32_t)aecm->nearLogEnergy[i]); + tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1); + mseStored += tmp32no2; + + tmp32no1 = ((int32_t)aecm->echoAdaptLogEnergy[i] - + (int32_t)aecm->nearLogEnergy[i]); + tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1); + mseAdapt += tmp32no2; + } + if (((mseStored << MSE_RESOLUTION) < (MIN_MSE_DIFF * mseAdapt)) & + ((aecm->mseStoredOld << MSE_RESOLUTION) < + (MIN_MSE_DIFF * aecm->mseAdaptOld))) { + // The stored channel has a significantly lower MSE than the adaptive + // one for two consecutive calculations. Reset the adaptive channel. + WebRtcAecm_ResetAdaptiveChannel(aecm); + } else if (((MIN_MSE_DIFF * mseStored) > (mseAdapt << MSE_RESOLUTION)) & + (mseAdapt < aecm->mseThreshold) & + (aecm->mseAdaptOld < aecm->mseThreshold)) { + // The adaptive channel has a significantly lower MSE than the stored + // one. The MSE for the adaptive channel has also been low for two + // consecutive calculations. Store the adaptive channel. WebRtcAecm_StoreAdaptiveChannel(aecm, far_spectrum, echoEst); - } else - { - if (aecm->farLogEnergy < aecm->farEnergyMSE) - { - aecm->mseChannelCount = 0; - } else - { - aecm->mseChannelCount++; + + // Update threshold + if (aecm->mseThreshold == WEBRTC_SPL_WORD32_MAX) { + aecm->mseThreshold = (mseAdapt + aecm->mseAdaptOld); + } else { + int scaled_threshold = aecm->mseThreshold * 5 / 8; + aecm->mseThreshold += ((mseAdapt - scaled_threshold) * 205) >> 8; } - // Enough data for validation. Store channel if we can. - if (aecm->mseChannelCount >= (MIN_MSE_COUNT + 10)) - { - // We have enough data. - // Calculate MSE of "Adapt" and "Stored" versions. - // It is actually not MSE, but average absolute error. - mseStored = 0; - mseAdapt = 0; - for (i = 0; i < MIN_MSE_COUNT; i++) - { - tmp32no1 = ((int32_t)aecm->echoStoredLogEnergy[i] - - (int32_t)aecm->nearLogEnergy[i]); - tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1); - mseStored += tmp32no2; + } - tmp32no1 = ((int32_t)aecm->echoAdaptLogEnergy[i] - - (int32_t)aecm->nearLogEnergy[i]); - tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1); - mseAdapt += tmp32no2; - } - if (((mseStored << MSE_RESOLUTION) < (MIN_MSE_DIFF * mseAdapt)) - & ((aecm->mseStoredOld << MSE_RESOLUTION) < (MIN_MSE_DIFF - * aecm->mseAdaptOld))) - { - // The stored channel has a significantly lower MSE than the adaptive one for - // two consecutive calculations. Reset the adaptive channel. - WebRtcAecm_ResetAdaptiveChannel(aecm); - } else if (((MIN_MSE_DIFF * mseStored) > (mseAdapt << MSE_RESOLUTION)) & (mseAdapt - < aecm->mseThreshold) & (aecm->mseAdaptOld < aecm->mseThreshold)) - { - // The adaptive channel has a significantly lower MSE than the stored one. - // The MSE for the adaptive channel has also been low for two consecutive - // calculations. Store the adaptive channel. - WebRtcAecm_StoreAdaptiveChannel(aecm, far_spectrum, echoEst); + // Reset counter + aecm->mseChannelCount = 0; - // Update threshold - if (aecm->mseThreshold == WEBRTC_SPL_WORD32_MAX) - { - aecm->mseThreshold = (mseAdapt + aecm->mseAdaptOld); - } else - { - int scaled_threshold = aecm->mseThreshold * 5 / 8; - aecm->mseThreshold += - ((mseAdapt - scaled_threshold) * 205) >> 8; - } - - } - - // Reset counter - aecm->mseChannelCount = 0; - - // Store the MSE values. - aecm->mseStoredOld = mseStored; - aecm->mseAdaptOld = mseAdapt; - } + // Store the MSE values. + aecm->mseStoredOld = mseStored; + aecm->mseAdaptOld = mseAdapt; } - // END: Determine if we should store or reset channel estimate. + } + // END: Determine if we should store or reset channel estimate. } // CalcSuppressionGain(...) // -// This function calculates the suppression gain that is used in the Wiener filter. +// This function calculates the suppression gain that is used in the Wiener +// filter. // // // @param aecm [i/n] Handle of the AECM instance. -// @param supGain [out] (Return value) Suppression gain with which to scale the noise +// @param supGain [out] (Return value) Suppression gain with which to scale +// the noise // level (Q14). // // int16_t WebRtcAecm_CalcSuppressionGain(AecmCore* const aecm) { - int32_t tmp32no1; + int32_t tmp32no1; - int16_t supGain = SUPGAIN_DEFAULT; - int16_t tmp16no1; - int16_t dE = 0; + int16_t supGain = SUPGAIN_DEFAULT; + int16_t tmp16no1; + int16_t dE = 0; - // Determine suppression gain used in the Wiener filter. The gain is based on a mix of far - // end energy and echo estimation error. - // Adjust for the far end signal level. A low signal level indicates no far end signal, - // hence we set the suppression gain to 0 - if (!aecm->currentVADValue) - { - supGain = 0; - } else - { - // Adjust for possible double talk. If we have large variations in estimation error we - // likely have double talk (or poor channel). - tmp16no1 = (aecm->nearLogEnergy[0] - aecm->echoStoredLogEnergy[0] - ENERGY_DEV_OFFSET); - dE = WEBRTC_SPL_ABS_W16(tmp16no1); + // Determine suppression gain used in the Wiener filter. The gain is based on + // a mix of far end energy and echo estimation error. Adjust for the far end + // signal level. A low signal level indicates no far end signal, hence we set + // the suppression gain to 0 + if (!aecm->currentVADValue) { + supGain = 0; + } else { + // Adjust for possible double talk. If we have large variations in + // estimation error we likely have double talk (or poor channel). + tmp16no1 = (aecm->nearLogEnergy[0] - aecm->echoStoredLogEnergy[0] - + ENERGY_DEV_OFFSET); + dE = WEBRTC_SPL_ABS_W16(tmp16no1); - if (dE < ENERGY_DEV_TOL) - { - // Likely no double talk. The better estimation, the more we can suppress signal. - // Update counters - if (dE < SUPGAIN_EPC_DT) - { - tmp32no1 = aecm->supGainErrParamDiffAB * dE; - tmp32no1 += (SUPGAIN_EPC_DT >> 1); - tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(tmp32no1, SUPGAIN_EPC_DT); - supGain = aecm->supGainErrParamA - tmp16no1; - } else - { - tmp32no1 = aecm->supGainErrParamDiffBD * (ENERGY_DEV_TOL - dE); - tmp32no1 += ((ENERGY_DEV_TOL - SUPGAIN_EPC_DT) >> 1); - tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(tmp32no1, (ENERGY_DEV_TOL - - SUPGAIN_EPC_DT)); - supGain = aecm->supGainErrParamD + tmp16no1; - } - } else - { - // Likely in double talk. Use default value - supGain = aecm->supGainErrParamD; - } + if (dE < ENERGY_DEV_TOL) { + // Likely no double talk. The better estimation, the more we can suppress + // signal. Update counters + if (dE < SUPGAIN_EPC_DT) { + tmp32no1 = aecm->supGainErrParamDiffAB * dE; + tmp32no1 += (SUPGAIN_EPC_DT >> 1); + tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(tmp32no1, SUPGAIN_EPC_DT); + supGain = aecm->supGainErrParamA - tmp16no1; + } else { + tmp32no1 = aecm->supGainErrParamDiffBD * (ENERGY_DEV_TOL - dE); + tmp32no1 += ((ENERGY_DEV_TOL - SUPGAIN_EPC_DT) >> 1); + tmp16no1 = (int16_t)WebRtcSpl_DivW32W16( + tmp32no1, (ENERGY_DEV_TOL - SUPGAIN_EPC_DT)); + supGain = aecm->supGainErrParamD + tmp16no1; + } + } else { + // Likely in double talk. Use default value + supGain = aecm->supGainErrParamD; } + } - if (supGain > aecm->supGainOld) - { - tmp16no1 = supGain; - } else - { - tmp16no1 = aecm->supGainOld; - } - aecm->supGainOld = supGain; - if (tmp16no1 < aecm->supGain) - { - aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4); - } else - { - aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4); - } + if (supGain > aecm->supGainOld) { + tmp16no1 = supGain; + } else { + tmp16no1 = aecm->supGainOld; + } + aecm->supGainOld = supGain; + if (tmp16no1 < aecm->supGain) { + aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4); + } else { + aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4); + } - // END: Update suppression gain + // END: Update suppression gain - return aecm->supGain; + return aecm->supGain; } void WebRtcAecm_BufferFarFrame(AecmCore* const aecm, const int16_t* const farend, const int farLen) { - int writeLen = farLen, writePos = 0; - - // Check if the write position must be wrapped - while (aecm->farBufWritePos + writeLen > FAR_BUF_LEN) - { - // Write to remaining buffer space before wrapping - writeLen = FAR_BUF_LEN - aecm->farBufWritePos; - memcpy(aecm->farBuf + aecm->farBufWritePos, farend + writePos, - sizeof(int16_t) * writeLen); - aecm->farBufWritePos = 0; - writePos = writeLen; - writeLen = farLen - writeLen; - } + int writeLen = farLen, writePos = 0; + // Check if the write position must be wrapped + while (aecm->farBufWritePos + writeLen > FAR_BUF_LEN) { + // Write to remaining buffer space before wrapping + writeLen = FAR_BUF_LEN - aecm->farBufWritePos; memcpy(aecm->farBuf + aecm->farBufWritePos, farend + writePos, sizeof(int16_t) * writeLen); - aecm->farBufWritePos += writeLen; + aecm->farBufWritePos = 0; + writePos = writeLen; + writeLen = farLen - writeLen; + } + + memcpy(aecm->farBuf + aecm->farBufWritePos, farend + writePos, + sizeof(int16_t) * writeLen); + aecm->farBufWritePos += writeLen; } void WebRtcAecm_FetchFarFrame(AecmCore* const aecm, int16_t* const farend, const int farLen, const int knownDelay) { - int readLen = farLen; - int readPos = 0; - int delayChange = knownDelay - aecm->lastKnownDelay; + int readLen = farLen; + int readPos = 0; + int delayChange = knownDelay - aecm->lastKnownDelay; - aecm->farBufReadPos -= delayChange; + aecm->farBufReadPos -= delayChange; - // Check if delay forces a read position wrap - while (aecm->farBufReadPos < 0) - { - aecm->farBufReadPos += FAR_BUF_LEN; - } - while (aecm->farBufReadPos > FAR_BUF_LEN - 1) - { - aecm->farBufReadPos -= FAR_BUF_LEN; - } + // Check if delay forces a read position wrap + while (aecm->farBufReadPos < 0) { + aecm->farBufReadPos += FAR_BUF_LEN; + } + while (aecm->farBufReadPos > FAR_BUF_LEN - 1) { + aecm->farBufReadPos -= FAR_BUF_LEN; + } - aecm->lastKnownDelay = knownDelay; + aecm->lastKnownDelay = knownDelay; - // Check if read position must be wrapped - while (aecm->farBufReadPos + readLen > FAR_BUF_LEN) - { - - // Read from remaining buffer space before wrapping - readLen = FAR_BUF_LEN - aecm->farBufReadPos; - memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, - sizeof(int16_t) * readLen); - aecm->farBufReadPos = 0; - readPos = readLen; - readLen = farLen - readLen; - } + // Check if read position must be wrapped + while (aecm->farBufReadPos + readLen > FAR_BUF_LEN) { + // Read from remaining buffer space before wrapping + readLen = FAR_BUF_LEN - aecm->farBufReadPos; memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, sizeof(int16_t) * readLen); - aecm->farBufReadPos += readLen; + aecm->farBufReadPos = 0; + readPos = readLen; + readLen = farLen - readLen; + } + memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, + sizeof(int16_t) * readLen); + aecm->farBufReadPos += readLen; } diff --git a/modules/audio_processing/aecm/aecm_core.h b/modules/audio_processing/aecm/aecm_core.h index feb997e9fa..3da3bca8b8 100644 --- a/modules/audio_processing/aecm/aecm_core.h +++ b/modules/audio_processing/aecm/aecm_core.h @@ -29,109 +29,109 @@ extern "C" { #endif typedef struct { - int16_t real; - int16_t imag; + int16_t real; + int16_t imag; } ComplexInt16; typedef struct { - int farBufWritePos; - int farBufReadPos; - int knownDelay; - int lastKnownDelay; - int firstVAD; // Parameter to control poorly initialized channels + int farBufWritePos; + int farBufReadPos; + int knownDelay; + int lastKnownDelay; + int firstVAD; // Parameter to control poorly initialized channels - RingBuffer* farFrameBuf; - RingBuffer* nearNoisyFrameBuf; - RingBuffer* nearCleanFrameBuf; - RingBuffer* outFrameBuf; + RingBuffer* farFrameBuf; + RingBuffer* nearNoisyFrameBuf; + RingBuffer* nearCleanFrameBuf; + RingBuffer* outFrameBuf; - int16_t farBuf[FAR_BUF_LEN]; + int16_t farBuf[FAR_BUF_LEN]; - int16_t mult; - uint32_t seed; + int16_t mult; + uint32_t seed; - // Delay estimation variables - void* delay_estimator_farend; - void* delay_estimator; - uint16_t currentDelay; - // Far end history variables - // TODO(bjornv): Replace |far_history| with ring_buffer. - uint16_t far_history[PART_LEN1 * MAX_DELAY]; - int far_history_pos; - int far_q_domains[MAX_DELAY]; + // Delay estimation variables + void* delay_estimator_farend; + void* delay_estimator; + uint16_t currentDelay; + // Far end history variables + // TODO(bjornv): Replace |far_history| with ring_buffer. + uint16_t far_history[PART_LEN1 * MAX_DELAY]; + int far_history_pos; + int far_q_domains[MAX_DELAY]; - int16_t nlpFlag; - int16_t fixedDelay; + int16_t nlpFlag; + int16_t fixedDelay; - uint32_t totCount; + uint32_t totCount; - int16_t dfaCleanQDomain; - int16_t dfaCleanQDomainOld; - int16_t dfaNoisyQDomain; - int16_t dfaNoisyQDomainOld; + int16_t dfaCleanQDomain; + int16_t dfaCleanQDomainOld; + int16_t dfaNoisyQDomain; + int16_t dfaNoisyQDomainOld; - int16_t nearLogEnergy[MAX_BUF_LEN]; - int16_t farLogEnergy; - int16_t echoAdaptLogEnergy[MAX_BUF_LEN]; - int16_t echoStoredLogEnergy[MAX_BUF_LEN]; + int16_t nearLogEnergy[MAX_BUF_LEN]; + int16_t farLogEnergy; + int16_t echoAdaptLogEnergy[MAX_BUF_LEN]; + int16_t echoStoredLogEnergy[MAX_BUF_LEN]; - // The extra 16 or 32 bytes in the following buffers are for alignment based - // Neon code. - // It's designed this way since the current GCC compiler can't align a - // buffer in 16 or 32 byte boundaries properly. - int16_t channelStored_buf[PART_LEN1 + 8]; - int16_t channelAdapt16_buf[PART_LEN1 + 8]; - int32_t channelAdapt32_buf[PART_LEN1 + 8]; - int16_t xBuf_buf[PART_LEN2 + 16]; // farend - int16_t dBufClean_buf[PART_LEN2 + 16]; // nearend - int16_t dBufNoisy_buf[PART_LEN2 + 16]; // nearend - int16_t outBuf_buf[PART_LEN + 8]; + // The extra 16 or 32 bytes in the following buffers are for alignment based + // Neon code. + // It's designed this way since the current GCC compiler can't align a + // buffer in 16 or 32 byte boundaries properly. + int16_t channelStored_buf[PART_LEN1 + 8]; + int16_t channelAdapt16_buf[PART_LEN1 + 8]; + int32_t channelAdapt32_buf[PART_LEN1 + 8]; + int16_t xBuf_buf[PART_LEN2 + 16]; // farend + int16_t dBufClean_buf[PART_LEN2 + 16]; // nearend + int16_t dBufNoisy_buf[PART_LEN2 + 16]; // nearend + int16_t outBuf_buf[PART_LEN + 8]; - // Pointers to the above buffers - int16_t *channelStored; - int16_t *channelAdapt16; - int32_t *channelAdapt32; - int16_t *xBuf; - int16_t *dBufClean; - int16_t *dBufNoisy; - int16_t *outBuf; + // Pointers to the above buffers + int16_t* channelStored; + int16_t* channelAdapt16; + int32_t* channelAdapt32; + int16_t* xBuf; + int16_t* dBufClean; + int16_t* dBufNoisy; + int16_t* outBuf; - int32_t echoFilt[PART_LEN1]; - int16_t nearFilt[PART_LEN1]; - int32_t noiseEst[PART_LEN1]; - int noiseEstTooLowCtr[PART_LEN1]; - int noiseEstTooHighCtr[PART_LEN1]; - int16_t noiseEstCtr; - int16_t cngMode; + int32_t echoFilt[PART_LEN1]; + int16_t nearFilt[PART_LEN1]; + int32_t noiseEst[PART_LEN1]; + int noiseEstTooLowCtr[PART_LEN1]; + int noiseEstTooHighCtr[PART_LEN1]; + int16_t noiseEstCtr; + int16_t cngMode; - int32_t mseAdaptOld; - int32_t mseStoredOld; - int32_t mseThreshold; + int32_t mseAdaptOld; + int32_t mseStoredOld; + int32_t mseThreshold; - int16_t farEnergyMin; - int16_t farEnergyMax; - int16_t farEnergyMaxMin; - int16_t farEnergyVAD; - int16_t farEnergyMSE; - int currentVADValue; - int16_t vadUpdateCount; + int16_t farEnergyMin; + int16_t farEnergyMax; + int16_t farEnergyMaxMin; + int16_t farEnergyVAD; + int16_t farEnergyMSE; + int currentVADValue; + int16_t vadUpdateCount; - int16_t startupState; - int16_t mseChannelCount; - int16_t supGain; - int16_t supGainOld; + int16_t startupState; + int16_t mseChannelCount; + int16_t supGain; + int16_t supGainOld; - int16_t supGainErrParamA; - int16_t supGainErrParamD; - int16_t supGainErrParamDiffAB; - int16_t supGainErrParamDiffBD; + int16_t supGainErrParamA; + int16_t supGainErrParamD; + int16_t supGainErrParamDiffAB; + int16_t supGainErrParamDiffBD; - struct RealFFT* real_fft; + struct RealFFT* real_fft; #ifdef AEC_DEBUG - FILE *farFile; - FILE *nearFile; - FILE *outFile; + FILE* farFile; + FILE* nearFile; + FILE* outFile; #endif } AecmCore; diff --git a/modules/audio_processing/aecm/aecm_core_c.cc b/modules/audio_processing/aecm/aecm_core_c.cc index effe04851c..b640f1a6e1 100644 --- a/modules/audio_processing/aecm/aecm_core_c.cc +++ b/modules/audio_processing/aecm/aecm_core_c.cc @@ -30,28 +30,25 @@ extern "C" { // Square root of Hanning window in Q14. static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { - 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, - 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224, - 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040, - 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, - 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, - 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079, - 15231, 15373, 15506, 15631, 15746, 15851, 15947, 16034, - 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384 -}; + 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, 3562, 3951, + 4337, 4720, 5101, 5478, 5853, 6224, 6591, 6954, 7313, 7668, 8019, + 8364, 8705, 9040, 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, + 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, 13773, 13985, 14189, + 14384, 14571, 14749, 14918, 15079, 15231, 15373, 15506, 15631, 15746, 15851, + 15947, 16034, 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384}; #ifdef AECM_WITH_ABS_APPROX -//Q15 alpha = 0.99439986968132 const Factor for magnitude approximation +// Q15 alpha = 0.99439986968132 const Factor for magnitude approximation static const uint16_t kAlpha1 = 32584; -//Q15 beta = 0.12967166976970 const Factor for magnitude approximation +// Q15 beta = 0.12967166976970 const Factor for magnitude approximation static const uint16_t kBeta1 = 4249; -//Q15 alpha = 0.94234827210087 const Factor for magnitude approximation +// Q15 alpha = 0.94234827210087 const Factor for magnitude approximation static const uint16_t kAlpha2 = 30879; -//Q15 beta = 0.33787806009150 const Factor for magnitude approximation +// Q15 beta = 0.33787806009150 const Factor for magnitude approximation static const uint16_t kBeta2 = 11072; -//Q15 alpha = 0.82247698684306 const Factor for magnitude approximation +// Q15 alpha = 0.82247698684306 const Factor for magnitude approximation static const uint16_t kAlpha3 = 26951; -//Q15 beta = 0.57762063060713 const Factor for magnitude approximation +// Q15 beta = 0.57762063060713 const Factor for magnitude approximation static const uint16_t kBeta3 = 18927; #endif @@ -77,8 +74,8 @@ static void WindowAndFFT(AecmCore* aecm, int16_t scaled_time_signal = time_signal[i] * (1 << time_signal_scaling); fft[i] = (int16_t)((scaled_time_signal * WebRtcAecm_kSqrtHanning[i]) >> 14); scaled_time_signal = time_signal[i + PART_LEN] * (1 << time_signal_scaling); - fft[PART_LEN + i] = (int16_t)(( - scaled_time_signal * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14); + fft[PART_LEN + i] = (int16_t)( + (scaled_time_signal * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14); } // Do forward FFT, then take only the first PART_LEN complex samples, @@ -115,32 +112,27 @@ static void InverseFFTAndWindow(AecmCore* aecm, outCFFT = WebRtcSpl_RealInverseFFT(aecm->real_fft, fft, ifft_out); for (i = 0; i < PART_LEN; i++) { ifft_out[i] = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( - ifft_out[i], WebRtcAecm_kSqrtHanning[i], 14); + ifft_out[i], WebRtcAecm_kSqrtHanning[i], 14); tmp32no1 = WEBRTC_SPL_SHIFT_W32((int32_t)ifft_out[i], - outCFFT - aecm->dfaCleanQDomain); + outCFFT - aecm->dfaCleanQDomain); output[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, tmp32no1 + aecm->outBuf[i], WEBRTC_SPL_WORD16_MIN); - tmp32no1 = (ifft_out[PART_LEN + i] * - WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14; - tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, - outCFFT - aecm->dfaCleanQDomain); - aecm->outBuf[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, - tmp32no1, - WEBRTC_SPL_WORD16_MIN); + tmp32no1 = + (ifft_out[PART_LEN + i] * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14; + tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, outCFFT - aecm->dfaCleanQDomain); + aecm->outBuf[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, tmp32no1, + WEBRTC_SPL_WORD16_MIN); } // Copy the current block to the old position // (aecm->outBuf is shifted elsewhere) memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN); - memcpy(aecm->dBufNoisy, - aecm->dBufNoisy + PART_LEN, + memcpy(aecm->dBufNoisy, aecm->dBufNoisy + PART_LEN, sizeof(int16_t) * PART_LEN); - if (nearendClean != NULL) - { - memcpy(aecm->dBufClean, - aecm->dBufClean + PART_LEN, + if (nearendClean != NULL) { + memcpy(aecm->dBufClean, aecm->dBufClean + PART_LEN, sizeof(int16_t) * PART_LEN); } } @@ -171,7 +163,7 @@ static int TimeToFrequencyDomain(AecmCore* aecm, // In fft_buf, +16 for 32-byte alignment. int16_t fft_buf[PART_LEN4 + 16]; - int16_t *fft = (int16_t *) (((uintptr_t) fft_buf + 31) & ~31); + int16_t* fft = (int16_t*)(((uintptr_t)fft_buf + 31) & ~31); int16_t tmp16no1; #ifndef WEBRTC_ARCH_ARM_V7 @@ -196,54 +188,43 @@ static int TimeToFrequencyDomain(AecmCore* aecm, freq_signal[0].imag = 0; freq_signal[PART_LEN].imag = 0; freq_signal_abs[0] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[0].real); - freq_signal_abs[PART_LEN] = (uint16_t)WEBRTC_SPL_ABS_W16( - freq_signal[PART_LEN].real); - (*freq_signal_sum_abs) = (uint32_t)(freq_signal_abs[0]) + - (uint32_t)(freq_signal_abs[PART_LEN]); + freq_signal_abs[PART_LEN] = + (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[PART_LEN].real); + (*freq_signal_sum_abs) = + (uint32_t)(freq_signal_abs[0]) + (uint32_t)(freq_signal_abs[PART_LEN]); - for (i = 1; i < PART_LEN; i++) - { - if (freq_signal[i].real == 0) - { + for (i = 1; i < PART_LEN; i++) { + if (freq_signal[i].real == 0) { freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].imag); - } - else if (freq_signal[i].imag == 0) - { + } else if (freq_signal[i].imag == 0) { freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].real); - } - else - { - // Approximation for magnitude of complex fft output - // magn = sqrt(real^2 + imag^2) - // magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|) - // - // The parameters alpha and beta are stored in Q15 + } else { +// Approximation for magnitude of complex fft output +// magn = sqrt(real^2 + imag^2) +// magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|) +// +// The parameters alpha and beta are stored in Q15 #ifdef AECM_WITH_ABS_APPROX tmp16no1 = WEBRTC_SPL_ABS_W16(freq_signal[i].real); tmp16no2 = WEBRTC_SPL_ABS_W16(freq_signal[i].imag); - if(tmp16no1 > tmp16no2) - { + if (tmp16no1 > tmp16no2) { max_value = tmp16no1; min_value = tmp16no2; - } else - { + } else { max_value = tmp16no2; min_value = tmp16no1; } // Magnitude in Q(-6) - if ((max_value >> 2) > min_value) - { + if ((max_value >> 2) > min_value) { alpha = kAlpha1; beta = kBeta1; - } else if ((max_value >> 1) > min_value) - { + } else if ((max_value >> 1) > min_value) { alpha = kAlpha2; beta = kBeta2; - } else - { + } else { alpha = kAlpha3; beta = kBeta3; } @@ -253,24 +234,21 @@ static int TimeToFrequencyDomain(AecmCore* aecm, #else #ifdef WEBRTC_ARCH_ARM_V7 __asm __volatile( - "smulbb %[tmp32no1], %[real], %[real]\n\t" - "smlabb %[tmp32no2], %[imag], %[imag], %[tmp32no1]\n\t" - :[tmp32no1]"+&r"(tmp32no1), - [tmp32no2]"=r"(tmp32no2) - :[real]"r"(freq_signal[i].real), - [imag]"r"(freq_signal[i].imag) - ); + "smulbb %[tmp32no1], %[real], %[real]\n\t" + "smlabb %[tmp32no2], %[imag], %[imag], %[tmp32no1]\n\t" + : [tmp32no1] "+&r"(tmp32no1), [tmp32no2] "=r"(tmp32no2) + : [real] "r"(freq_signal[i].real), [imag] "r"(freq_signal[i].imag)); #else tmp16no1 = WEBRTC_SPL_ABS_W16(freq_signal[i].real); tmp16no2 = WEBRTC_SPL_ABS_W16(freq_signal[i].imag); tmp32no1 = tmp16no1 * tmp16no1; tmp32no2 = tmp16no2 * tmp16no2; tmp32no2 = WebRtcSpl_AddSatW32(tmp32no1, tmp32no2); -#endif // WEBRTC_ARCH_ARM_V7 +#endif // WEBRTC_ARCH_ARM_V7 tmp32no1 = WebRtcSpl_SqrtFloor(tmp32no2); freq_signal_abs[i] = (uint16_t)tmp32no1; -#endif // AECM_WITH_ABS_APPROX +#endif // AECM_WITH_ABS_APPROX } (*freq_signal_sum_abs) += (uint32_t)freq_signal_abs[i]; } @@ -279,11 +257,11 @@ static int TimeToFrequencyDomain(AecmCore* aecm, } int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200 -WebRtcAecm_ProcessBlock(AecmCore* aecm, - const int16_t* farend, - const int16_t* nearendNoisy, - const int16_t* nearendClean, - int16_t* output) { + WebRtcAecm_ProcessBlock(AecmCore* aecm, + const int16_t* farend, + const int16_t* nearendNoisy, + const int16_t* nearendClean, + int16_t* output) { int i; uint32_t xfaSum; @@ -302,13 +280,13 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, // 32 byte aligned buffers (with +8 or +16). // TODO(kma): define fft with ComplexInt16. - int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe. + int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe. int32_t echoEst32_buf[PART_LEN1 + 8]; int32_t dfw_buf[PART_LEN2 + 8]; int32_t efw_buf[PART_LEN2 + 8]; - int16_t* fft = (int16_t*) (((uintptr_t) fft_buf + 31) & ~ 31); - int32_t* echoEst32 = (int32_t*) (((uintptr_t) echoEst32_buf + 31) & ~ 31); + int16_t* fft = (int16_t*)(((uintptr_t)fft_buf + 31) & ~31); + int32_t* echoEst32 = (int32_t*)(((uintptr_t)echoEst32_buf + 31) & ~31); ComplexInt16* dfw = (ComplexInt16*)(((uintptr_t)dfw_buf + 31) & ~31); ComplexInt16* efw = (ComplexInt16*)(((uintptr_t)efw_buf + 31) & ~31); @@ -334,53 +312,37 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, // (1) another CONV_LEN blocks // (2) the rest - if (aecm->startupState < 2) - { - aecm->startupState = (aecm->totCount >= CONV_LEN) + - (aecm->totCount >= CONV_LEN2); + if (aecm->startupState < 2) { + aecm->startupState = + (aecm->totCount >= CONV_LEN) + (aecm->totCount >= CONV_LEN2); } // END: Determine startup state // Buffer near and far end signals memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN); memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN); - if (nearendClean != NULL) - { - memcpy(aecm->dBufClean + PART_LEN, - nearendClean, + if (nearendClean != NULL) { + memcpy(aecm->dBufClean + PART_LEN, nearendClean, sizeof(int16_t) * PART_LEN); } // Transform far end signal from time domain to frequency domain. - far_q = TimeToFrequencyDomain(aecm, - aecm->xBuf, - dfw, - xfa, - &xfaSum); + far_q = TimeToFrequencyDomain(aecm, aecm->xBuf, dfw, xfa, &xfaSum); // Transform noisy near end signal from time domain to frequency domain. - zerosDBufNoisy = TimeToFrequencyDomain(aecm, - aecm->dBufNoisy, - dfw, - dfaNoisy, - &dfaNoisySum); + zerosDBufNoisy = + TimeToFrequencyDomain(aecm, aecm->dBufNoisy, dfw, dfaNoisy, &dfaNoisySum); aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain; aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy; - - if (nearendClean == NULL) - { + if (nearendClean == NULL) { ptrDfaClean = dfaNoisy; aecm->dfaCleanQDomainOld = aecm->dfaNoisyQDomainOld; aecm->dfaCleanQDomain = aecm->dfaNoisyQDomain; dfaCleanSum = dfaNoisySum; - } else - { + } else { // Transform clean near end signal from time domain to frequency domain. - zerosDBufClean = TimeToFrequencyDomain(aecm, - aecm->dBufClean, - dfw, - dfaClean, + zerosDBufClean = TimeToFrequencyDomain(aecm, aecm->dBufClean, dfw, dfaClean, &dfaCleanSum); aecm->dfaCleanQDomainOld = aecm->dfaCleanQDomain; aecm->dfaCleanQDomain = (int16_t)zerosDBufClean; @@ -389,46 +351,34 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, // Get the delay // Save far-end history and estimate delay WebRtcAecm_UpdateFarHistory(aecm, xfa, far_q); - if (WebRtc_AddFarSpectrumFix(aecm->delay_estimator_farend, - xfa, - PART_LEN1, + if (WebRtc_AddFarSpectrumFix(aecm->delay_estimator_farend, xfa, PART_LEN1, far_q) == -1) { return -1; } - delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator, - dfaNoisy, - PART_LEN1, - zerosDBufNoisy); - if (delay == -1) - { + delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator, dfaNoisy, + PART_LEN1, zerosDBufNoisy); + if (delay == -1) { return -1; - } - else if (delay == -2) - { + } else if (delay == -2) { // If the delay is unknown, we assume zero. // NOTE: this will have to be adjusted if we ever add lookahead. delay = 0; } - if (aecm->fixedDelay >= 0) - { + if (aecm->fixedDelay >= 0) { // Use fixed delay delay = aecm->fixedDelay; } // Get aligned far end spectrum far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay); - zerosXBuf = (int16_t) far_q; - if (far_spectrum_ptr == NULL) - { + zerosXBuf = (int16_t)far_q; + if (far_spectrum_ptr == NULL) { return -1; } // Calculate log(energy) and update energy threshold levels - WebRtcAecm_CalcEnergies(aecm, - far_spectrum_ptr, - zerosXBuf, - dfaNoisySum, + WebRtcAecm_CalcEnergies(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisySum, echoEst32); // Calculate stepsize @@ -440,18 +390,12 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, // This is the channel estimation algorithm. // It is base on NLMS but has a variable step length, // which was calculated above. - WebRtcAecm_UpdateChannel(aecm, - far_spectrum_ptr, - zerosXBuf, - dfaNoisy, - mu, + WebRtcAecm_UpdateChannel(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisy, mu, echoEst32); supGain = WebRtcAecm_CalcSuppressionGain(aecm); - // Calculate Wiener filter hnl[] - for (i = 0; i < PART_LEN1; i++) - { + for (i = 0; i < PART_LEN1; i++) { // Far end signal through channel estimate in Q8 // How much can we shift right to preserve resolution tmp32no1 = echoEst32[i] - aecm->echoFilt[i]; @@ -460,28 +404,24 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, zeros32 = WebRtcSpl_NormW32(aecm->echoFilt[i]) + 1; zeros16 = WebRtcSpl_NormW16(supGain) + 1; - if (zeros32 + zeros16 > 16) - { + if (zeros32 + zeros16 > 16) { // Multiplication is safe // Result in // Q(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN+ // aecm->xfaQDomainBuf[diff]) - echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], - (uint16_t)supGain); + echoEst32Gained = + WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], (uint16_t)supGain); resolutionDiff = 14 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN; resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf); - } else - { + } else { tmp16no1 = 17 - zeros32 - zeros16; - resolutionDiff = 14 + tmp16no1 - RESOLUTION_CHANNEL16 - - RESOLUTION_SUPGAIN; + resolutionDiff = + 14 + tmp16no1 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN; resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf); - if (zeros32 > tmp16no1) - { + if (zeros32 > tmp16no1) { echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], supGain >> tmp16no1); - } else - { + } else { // Result in Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN-16) echoEst32Gained = (aecm->echoFilt[i] >> tmp16no1) * supGain; } @@ -513,125 +453,100 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, } // Wiener filter coefficients, resulting hnl in Q14 - if (echoEst32Gained == 0) - { + if (echoEst32Gained == 0) { hnl[i] = ONE_Q14; - } else if (aecm->nearFilt[i] == 0) - { + } else if (aecm->nearFilt[i] == 0) { hnl[i] = 0; - } else - { + } else { // Multiply the suppression gain // Rounding echoEst32Gained += (uint32_t)(aecm->nearFilt[i] >> 1); - tmpU32 = WebRtcSpl_DivU32U16(echoEst32Gained, - (uint16_t)aecm->nearFilt[i]); + tmpU32 = + WebRtcSpl_DivU32U16(echoEst32Gained, (uint16_t)aecm->nearFilt[i]); // Current resolution is // Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN- max(0,17-zeros16- zeros32)) // Make sure we are in Q14 tmp32no1 = (int32_t)WEBRTC_SPL_SHIFT_W32(tmpU32, resolutionDiff); - if (tmp32no1 > ONE_Q14) - { + if (tmp32no1 > ONE_Q14) { hnl[i] = 0; - } else if (tmp32no1 < 0) - { + } else if (tmp32no1 < 0) { hnl[i] = ONE_Q14; - } else - { + } else { // 1-echoEst/dfa hnl[i] = ONE_Q14 - (int16_t)tmp32no1; - if (hnl[i] < 0) - { + if (hnl[i] < 0) { hnl[i] = 0; } } } - if (hnl[i]) - { + if (hnl[i]) { numPosCoef++; } } // Only in wideband. Prevent the gain in upper band from being larger than // in lower band. - if (aecm->mult == 2) - { + if (aecm->mult == 2) { // TODO(bjornv): Investigate if the scaling of hnl[i] below can cause // speech distortion in double-talk. - for (i = 0; i < PART_LEN1; i++) - { + for (i = 0; i < PART_LEN1; i++) { hnl[i] = (int16_t)((hnl[i] * hnl[i]) >> 14); } - for (i = kMinPrefBand; i <= kMaxPrefBand; i++) - { + for (i = kMinPrefBand; i <= kMaxPrefBand; i++) { avgHnl32 += (int32_t)hnl[i]; } RTC_DCHECK_GT(kMaxPrefBand - kMinPrefBand + 1, 0); avgHnl32 /= (kMaxPrefBand - kMinPrefBand + 1); - for (i = kMaxPrefBand; i < PART_LEN1; i++) - { - if (hnl[i] > (int16_t)avgHnl32) - { + for (i = kMaxPrefBand; i < PART_LEN1; i++) { + if (hnl[i] > (int16_t)avgHnl32) { hnl[i] = (int16_t)avgHnl32; } } } // Calculate NLP gain, result is in Q14 - if (aecm->nlpFlag) - { - for (i = 0; i < PART_LEN1; i++) - { + if (aecm->nlpFlag) { + for (i = 0; i < PART_LEN1; i++) { // Truncate values close to zero and one. - if (hnl[i] > NLP_COMP_HIGH) - { + if (hnl[i] > NLP_COMP_HIGH) { hnl[i] = ONE_Q14; - } else if (hnl[i] < NLP_COMP_LOW) - { + } else if (hnl[i] < NLP_COMP_LOW) { hnl[i] = 0; } // Remove outliers - if (numPosCoef < 3) - { + if (numPosCoef < 3) { nlpGain = 0; - } else - { + } else { nlpGain = ONE_Q14; } // NLP - if ((hnl[i] == ONE_Q14) && (nlpGain == ONE_Q14)) - { + if ((hnl[i] == ONE_Q14) && (nlpGain == ONE_Q14)) { hnl[i] = ONE_Q14; - } else - { + } else { hnl[i] = (int16_t)((hnl[i] * nlpGain) >> 14); } // multiply with Wiener coefficients - efw[i].real = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, - hnl[i], 14)); - efw[i].imag = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, - hnl[i], 14)); + efw[i].real = (int16_t)( + WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, hnl[i], 14)); + efw[i].imag = (int16_t)( + WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, hnl[i], 14)); } - } - else - { + } else { // multiply with Wiener coefficients - for (i = 0; i < PART_LEN1; i++) - { - efw[i].real = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, - hnl[i], 14)); - efw[i].imag = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, - hnl[i], 14)); + for (i = 0; i < PART_LEN1; i++) { + efw[i].real = (int16_t)( + WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, hnl[i], 14)); + efw[i].imag = (int16_t)( + WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, hnl[i], 14)); } } - if (aecm->cngMode == AecmTrue) - { + if (aecm->cngMode == AecmTrue) { ComfortNoise(aecm, ptrDfaClean, efw, hnl); } @@ -660,83 +575,66 @@ static void ComfortNoise(AecmCore* aecm, RTC_DCHECK_GE(shiftFromNearToNoise, 0); RTC_DCHECK_LT(shiftFromNearToNoise, 16); - if (aecm->noiseEstCtr < 100) - { + if (aecm->noiseEstCtr < 100) { // Track the minimum more quickly initially. aecm->noiseEstCtr++; minTrackShift = 6; - } else - { + } else { minTrackShift = 9; } // Estimate noise power. - for (i = 0; i < PART_LEN1; i++) - { + for (i = 0; i < PART_LEN1; i++) { // Shift to the noise domain. tmp32 = (int32_t)dfa[i]; outLShift32 = tmp32 << shiftFromNearToNoise; - if (outLShift32 < aecm->noiseEst[i]) - { + if (outLShift32 < aecm->noiseEst[i]) { // Reset "too low" counter aecm->noiseEstTooLowCtr[i] = 0; // Track the minimum. - if (aecm->noiseEst[i] < (1 << minTrackShift)) - { + if (aecm->noiseEst[i] < (1 << minTrackShift)) { // For small values, decrease noiseEst[i] every // |kNoiseEstIncCount| block. The regular approach below can not // go further down due to truncation. aecm->noiseEstTooHighCtr[i]++; - if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) - { + if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) { aecm->noiseEst[i]--; - aecm->noiseEstTooHighCtr[i] = 0; // Reset the counter + aecm->noiseEstTooHighCtr[i] = 0; // Reset the counter } + } else { + aecm->noiseEst[i] -= + ((aecm->noiseEst[i] - outLShift32) >> minTrackShift); } - else - { - aecm->noiseEst[i] -= ((aecm->noiseEst[i] - outLShift32) - >> minTrackShift); - } - } else - { + } else { // Reset "too high" counter aecm->noiseEstTooHighCtr[i] = 0; // Ramp slowly upwards until we hit the minimum again. - if ((aecm->noiseEst[i] >> 19) > 0) - { + if ((aecm->noiseEst[i] >> 19) > 0) { // Avoid overflow. // Multiplication with 2049 will cause wrap around. Scale // down first and then multiply aecm->noiseEst[i] >>= 11; aecm->noiseEst[i] *= 2049; - } - else if ((aecm->noiseEst[i] >> 11) > 0) - { + } else if ((aecm->noiseEst[i] >> 11) > 0) { // Large enough for relative increase aecm->noiseEst[i] *= 2049; aecm->noiseEst[i] >>= 11; - } - else - { + } else { // Make incremental increases based on size every // |kNoiseEstIncCount| block aecm->noiseEstTooLowCtr[i]++; - if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) - { + if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) { aecm->noiseEst[i] += (aecm->noiseEst[i] >> 9) + 1; - aecm->noiseEstTooLowCtr[i] = 0; // Reset counter + aecm->noiseEstTooLowCtr[i] = 0; // Reset counter } } } } - for (i = 0; i < PART_LEN1; i++) - { + for (i = 0; i < PART_LEN1; i++) { tmp32 = aecm->noiseEst[i] >> shiftFromNearToNoise; - if (tmp32 > 32767) - { + if (tmp32 > 32767) { tmp32 = 32767; aecm->noiseEst[i] = tmp32 << shiftFromNearToNoise; } @@ -750,23 +648,21 @@ static void ComfortNoise(AecmCore* aecm, WebRtcSpl_RandUArray(randW16, PART_LEN, &aecm->seed); // Generate noise according to estimated energy. - uReal[0] = 0; // Reject LF noise. + uReal[0] = 0; // Reject LF noise. uImag[0] = 0; - for (i = 1; i < PART_LEN1; i++) - { + for (i = 1; i < PART_LEN1; i++) { // Get a random index for the cos and sin tables over [0 359]. tmp16 = (int16_t)((359 * randW16[i - 1]) >> 15); // Tables are in Q13. - uReal[i] = (int16_t)((noiseRShift16[i] * WebRtcAecm_kCosTable[tmp16]) >> - 13); - uImag[i] = (int16_t)((-noiseRShift16[i] * WebRtcAecm_kSinTable[tmp16]) >> - 13); + uReal[i] = + (int16_t)((noiseRShift16[i] * WebRtcAecm_kCosTable[tmp16]) >> 13); + uImag[i] = + (int16_t)((-noiseRShift16[i] * WebRtcAecm_kSinTable[tmp16]) >> 13); } uImag[PART_LEN] = 0; - for (i = 0; i < PART_LEN1; i++) - { + for (i = 0; i < PART_LEN1; i++) { out[i].real = WebRtcSpl_AddSatW16(out[i].real, uReal[i]); out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]); } diff --git a/modules/audio_processing/aecm/aecm_core_mips.cc b/modules/audio_processing/aecm/aecm_core_mips.cc index 58e5ec5e35..11e4095ef5 100644 --- a/modules/audio_processing/aecm/aecm_core_mips.cc +++ b/modules/audio_processing/aecm/aecm_core_mips.cc @@ -16,56 +16,37 @@ #include "rtc_base/numerics/safe_conversions.h" static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { - 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, - 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224, - 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040, - 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, - 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, - 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079, - 15231, 15373, 15506, 15631, 15746, 15851, 15947, 16034, - 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384 -}; + 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, 3562, 3951, + 4337, 4720, 5101, 5478, 5853, 6224, 6591, 6954, 7313, 7668, 8019, + 8364, 8705, 9040, 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, + 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, 13773, 13985, 14189, + 14384, 14571, 14749, 14918, 15079, 15231, 15373, 15506, 15631, 15746, 15851, + 15947, 16034, 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384}; static const int16_t kNoiseEstQDomain = 15; static const int16_t kNoiseEstIncCount = 5; static int16_t coefTable[] = { - 0, 4, 256, 260, 128, 132, 384, 388, - 64, 68, 320, 324, 192, 196, 448, 452, - 32, 36, 288, 292, 160, 164, 416, 420, - 96, 100, 352, 356, 224, 228, 480, 484, - 16, 20, 272, 276, 144, 148, 400, 404, - 80, 84, 336, 340, 208, 212, 464, 468, - 48, 52, 304, 308, 176, 180, 432, 436, - 112, 116, 368, 372, 240, 244, 496, 500, - 8, 12, 264, 268, 136, 140, 392, 396, - 72, 76, 328, 332, 200, 204, 456, 460, - 40, 44, 296, 300, 168, 172, 424, 428, - 104, 108, 360, 364, 232, 236, 488, 492, - 24, 28, 280, 284, 152, 156, 408, 412, - 88, 92, 344, 348, 216, 220, 472, 476, - 56, 60, 312, 316, 184, 188, 440, 444, - 120, 124, 376, 380, 248, 252, 504, 508 -}; + 0, 4, 256, 260, 128, 132, 384, 388, 64, 68, 320, 324, 192, 196, 448, + 452, 32, 36, 288, 292, 160, 164, 416, 420, 96, 100, 352, 356, 224, 228, + 480, 484, 16, 20, 272, 276, 144, 148, 400, 404, 80, 84, 336, 340, 208, + 212, 464, 468, 48, 52, 304, 308, 176, 180, 432, 436, 112, 116, 368, 372, + 240, 244, 496, 500, 8, 12, 264, 268, 136, 140, 392, 396, 72, 76, 328, + 332, 200, 204, 456, 460, 40, 44, 296, 300, 168, 172, 424, 428, 104, 108, + 360, 364, 232, 236, 488, 492, 24, 28, 280, 284, 152, 156, 408, 412, 88, + 92, 344, 348, 216, 220, 472, 476, 56, 60, 312, 316, 184, 188, 440, 444, + 120, 124, 376, 380, 248, 252, 504, 508}; static int16_t coefTable_ifft[] = { - 0, 512, 256, 508, 128, 252, 384, 380, - 64, 124, 320, 444, 192, 188, 448, 316, - 32, 60, 288, 476, 160, 220, 416, 348, - 96, 92, 352, 412, 224, 156, 480, 284, - 16, 28, 272, 492, 144, 236, 400, 364, - 80, 108, 336, 428, 208, 172, 464, 300, - 48, 44, 304, 460, 176, 204, 432, 332, - 112, 76, 368, 396, 240, 140, 496, 268, - 8, 12, 264, 500, 136, 244, 392, 372, - 72, 116, 328, 436, 200, 180, 456, 308, - 40, 52, 296, 468, 168, 212, 424, 340, - 104, 84, 360, 404, 232, 148, 488, 276, - 24, 20, 280, 484, 152, 228, 408, 356, - 88, 100, 344, 420, 216, 164, 472, 292, - 56, 36, 312, 452, 184, 196, 440, 324, - 120, 68, 376, 388, 248, 132, 504, 260 -}; + 0, 512, 256, 508, 128, 252, 384, 380, 64, 124, 320, 444, 192, 188, 448, + 316, 32, 60, 288, 476, 160, 220, 416, 348, 96, 92, 352, 412, 224, 156, + 480, 284, 16, 28, 272, 492, 144, 236, 400, 364, 80, 108, 336, 428, 208, + 172, 464, 300, 48, 44, 304, 460, 176, 204, 432, 332, 112, 76, 368, 396, + 240, 140, 496, 268, 8, 12, 264, 500, 136, 244, 392, 372, 72, 116, 328, + 436, 200, 180, 456, 308, 40, 52, 296, 468, 168, 212, 424, 340, 104, 84, + 360, 404, 232, 148, 488, 276, 24, 20, 280, 484, 152, 228, 408, 356, 88, + 100, 344, 420, 216, 164, 472, 292, 56, 36, 312, 452, 184, 196, 440, 324, + 120, 68, 376, 388, 248, 132, 504, 260}; static void ComfortNoise(AecmCore* aecm, const uint16_t* dfa, @@ -81,122 +62,152 @@ static void WindowAndFFT(AecmCore* aecm, int32_t tmp1, tmp2, tmp3, tmp4; int16_t* pfrfi; ComplexInt16* pfreq_signal; - int16_t f_coef, s_coef; + int16_t f_coef, s_coef; int32_t load_ptr, store_ptr1, store_ptr2, shift, shift1; int32_t hann, hann1, coefs; memset(fft, 0, sizeof(int16_t) * PART_LEN4); // FFT of signal - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[shift], %[time_signal_scaling], -14 \n\t" - "addiu %[i], $zero, 64 \n\t" - "addiu %[load_ptr], %[time_signal], 0 \n\t" - "addiu %[hann], %[hanning], 0 \n\t" - "addiu %[hann1], %[hanning], 128 \n\t" - "addiu %[coefs], %[coefTable], 0 \n\t" - "bltz %[shift], 2f \n\t" - " negu %[shift1], %[shift] \n\t" - "1: \n\t" - "lh %[tmp1], 0(%[load_ptr]) \n\t" - "lh %[tmp2], 0(%[hann]) \n\t" - "lh %[tmp3], 128(%[load_ptr]) \n\t" - "lh %[tmp4], 0(%[hann1]) \n\t" - "addiu %[i], %[i], -1 \n\t" - "mul %[tmp1], %[tmp1], %[tmp2] \n\t" - "mul %[tmp3], %[tmp3], %[tmp4] \n\t" - "lh %[f_coef], 0(%[coefs]) \n\t" - "lh %[s_coef], 2(%[coefs]) \n\t" - "addiu %[load_ptr], %[load_ptr], 2 \n\t" - "addiu %[hann], %[hann], 2 \n\t" - "addiu %[hann1], %[hann1], -2 \n\t" - "addu %[store_ptr1], %[fft], %[f_coef] \n\t" - "addu %[store_ptr2], %[fft], %[s_coef] \n\t" - "sllv %[tmp1], %[tmp1], %[shift] \n\t" - "sllv %[tmp3], %[tmp3], %[shift] \n\t" - "sh %[tmp1], 0(%[store_ptr1]) \n\t" - "sh %[tmp3], 0(%[store_ptr2]) \n\t" - "bgtz %[i], 1b \n\t" - " addiu %[coefs], %[coefs], 4 \n\t" - "b 3f \n\t" - " nop \n\t" - "2: \n\t" - "lh %[tmp1], 0(%[load_ptr]) \n\t" - "lh %[tmp2], 0(%[hann]) \n\t" - "lh %[tmp3], 128(%[load_ptr]) \n\t" - "lh %[tmp4], 0(%[hann1]) \n\t" - "addiu %[i], %[i], -1 \n\t" - "mul %[tmp1], %[tmp1], %[tmp2] \n\t" - "mul %[tmp3], %[tmp3], %[tmp4] \n\t" - "lh %[f_coef], 0(%[coefs]) \n\t" - "lh %[s_coef], 2(%[coefs]) \n\t" - "addiu %[load_ptr], %[load_ptr], 2 \n\t" - "addiu %[hann], %[hann], 2 \n\t" - "addiu %[hann1], %[hann1], -2 \n\t" - "addu %[store_ptr1], %[fft], %[f_coef] \n\t" - "addu %[store_ptr2], %[fft], %[s_coef] \n\t" - "srav %[tmp1], %[tmp1], %[shift1] \n\t" - "srav %[tmp3], %[tmp3], %[shift1] \n\t" - "sh %[tmp1], 0(%[store_ptr1]) \n\t" - "sh %[tmp3], 0(%[store_ptr2]) \n\t" - "bgtz %[i], 2b \n\t" - " addiu %[coefs], %[coefs], 4 \n\t" - "3: \n\t" - ".set pop \n\t" - : [load_ptr] "=&r" (load_ptr), [shift] "=&r" (shift), [hann] "=&r" (hann), - [hann1] "=&r" (hann1), [shift1] "=&r" (shift1), [coefs] "=&r" (coefs), - [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [tmp3] "=&r" (tmp3), - [tmp4] "=&r" (tmp4), [i] "=&r" (i), [f_coef] "=&r" (f_coef), - [s_coef] "=&r" (s_coef), [store_ptr1] "=&r" (store_ptr1), - [store_ptr2] "=&r" (store_ptr2) - : [time_signal] "r" (time_signal), [coefTable] "r" (coefTable), - [time_signal_scaling] "r" (time_signal_scaling), - [hanning] "r" (WebRtcAecm_kSqrtHanning), [fft] "r" (fft) - : "memory", "hi", "lo" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[shift], %[time_signal_scaling], -14 \n\t" + "addiu %[i], $zero, 64 \n\t" + "addiu %[load_ptr], %[time_signal], 0 \n\t" + "addiu %[hann], %[hanning], 0 \n\t" + "addiu %[hann1], %[hanning], 128 \n\t" + "addiu %[coefs], %[coefTable], 0 \n\t" + "bltz %[shift], 2f \n\t" + " negu %[shift1], %[shift] \n\t" + "1: " + "\n\t" + "lh %[tmp1], 0(%[load_ptr]) \n\t" + "lh %[tmp2], 0(%[hann]) \n\t" + "lh %[tmp3], 128(%[load_ptr]) \n\t" + "lh %[tmp4], 0(%[hann1]) \n\t" + "addiu %[i], %[i], -1 \n\t" + "mul %[tmp1], %[tmp1], %[tmp2] \n\t" + "mul %[tmp3], %[tmp3], %[tmp4] \n\t" + "lh %[f_coef], 0(%[coefs]) \n\t" + "lh %[s_coef], 2(%[coefs]) \n\t" + "addiu %[load_ptr], %[load_ptr], 2 \n\t" + "addiu %[hann], %[hann], 2 \n\t" + "addiu %[hann1], %[hann1], -2 \n\t" + "addu %[store_ptr1], %[fft], %[f_coef] \n\t" + "addu %[store_ptr2], %[fft], %[s_coef] \n\t" + "sllv %[tmp1], %[tmp1], %[shift] \n\t" + "sllv %[tmp3], %[tmp3], %[shift] \n\t" + "sh %[tmp1], 0(%[store_ptr1]) \n\t" + "sh %[tmp3], 0(%[store_ptr2]) \n\t" + "bgtz %[i], 1b \n\t" + " addiu %[coefs], %[coefs], 4 \n\t" + "b 3f \n\t" + " nop \n\t" + "2: " + "\n\t" + "lh %[tmp1], 0(%[load_ptr]) \n\t" + "lh %[tmp2], 0(%[hann]) \n\t" + "lh %[tmp3], 128(%[load_ptr]) \n\t" + "lh %[tmp4], 0(%[hann1]) \n\t" + "addiu %[i], %[i], -1 \n\t" + "mul %[tmp1], %[tmp1], %[tmp2] \n\t" + "mul %[tmp3], %[tmp3], %[tmp4] \n\t" + "lh %[f_coef], 0(%[coefs]) \n\t" + "lh %[s_coef], 2(%[coefs]) \n\t" + "addiu %[load_ptr], %[load_ptr], 2 \n\t" + "addiu %[hann], %[hann], 2 \n\t" + "addiu %[hann1], %[hann1], -2 \n\t" + "addu %[store_ptr1], %[fft], %[f_coef] \n\t" + "addu %[store_ptr2], %[fft], %[s_coef] \n\t" + "srav %[tmp1], %[tmp1], %[shift1] \n\t" + "srav %[tmp3], %[tmp3], %[shift1] \n\t" + "sh %[tmp1], 0(%[store_ptr1]) \n\t" + "sh %[tmp3], 0(%[store_ptr2]) \n\t" + "bgtz %[i], 2b \n\t" + " addiu %[coefs], %[coefs], 4 \n\t" + "3: " + "\n\t" + ".set pop \n\t" + : [load_ptr] "=&r"(load_ptr), [shift] "=&r"(shift), [hann] "=&r"(hann), + [hann1] "=&r"(hann1), [shift1] "=&r"(shift1), [coefs] "=&r"(coefs), + [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3), + [tmp4] "=&r"(tmp4), [i] "=&r"(i), [f_coef] "=&r"(f_coef), + [s_coef] "=&r"(s_coef), [store_ptr1] "=&r"(store_ptr1), + [store_ptr2] "=&r"(store_ptr2) + : [time_signal] "r"(time_signal), [coefTable] "r"(coefTable), + [time_signal_scaling] "r"(time_signal_scaling), + [hanning] "r"(WebRtcAecm_kSqrtHanning), [fft] "r"(fft) + : "memory", "hi", "lo"); WebRtcSpl_ComplexFFT(fft, PART_LEN_SHIFT, 1); pfrfi = fft; pfreq_signal = freq_signal; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[j], $zero, 128 \n\t" - "1: \n\t" - "lh %[tmp1], 0(%[pfrfi]) \n\t" - "lh %[tmp2], 2(%[pfrfi]) \n\t" - "lh %[tmp3], 4(%[pfrfi]) \n\t" - "lh %[tmp4], 6(%[pfrfi]) \n\t" - "subu %[tmp2], $zero, %[tmp2] \n\t" - "sh %[tmp1], 0(%[pfreq_signal]) \n\t" - "sh %[tmp2], 2(%[pfreq_signal]) \n\t" - "subu %[tmp4], $zero, %[tmp4] \n\t" - "sh %[tmp3], 4(%[pfreq_signal]) \n\t" - "sh %[tmp4], 6(%[pfreq_signal]) \n\t" - "lh %[tmp1], 8(%[pfrfi]) \n\t" - "lh %[tmp2], 10(%[pfrfi]) \n\t" - "lh %[tmp3], 12(%[pfrfi]) \n\t" - "lh %[tmp4], 14(%[pfrfi]) \n\t" - "addiu %[j], %[j], -8 \n\t" - "subu %[tmp2], $zero, %[tmp2] \n\t" - "sh %[tmp1], 8(%[pfreq_signal]) \n\t" - "sh %[tmp2], 10(%[pfreq_signal]) \n\t" - "subu %[tmp4], $zero, %[tmp4] \n\t" - "sh %[tmp3], 12(%[pfreq_signal]) \n\t" - "sh %[tmp4], 14(%[pfreq_signal]) \n\t" - "addiu %[pfreq_signal], %[pfreq_signal], 16 \n\t" - "bgtz %[j], 1b \n\t" - " addiu %[pfrfi], %[pfrfi], 16 \n\t" - ".set pop \n\t" - : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [tmp3] "=&r" (tmp3), - [j] "=&r" (j), [pfrfi] "+r" (pfrfi), [pfreq_signal] "+r" (pfreq_signal), - [tmp4] "=&r" (tmp4) - : - : "memory" - ); + __asm __volatile( + ".set push " + "\n\t" + ".set noreorder " + "\n\t" + "addiu %[j], $zero, 128 " + "\n\t" + "1: " + "\n\t" + "lh %[tmp1], 0(%[pfrfi]) " + "\n\t" + "lh %[tmp2], 2(%[pfrfi]) " + "\n\t" + "lh %[tmp3], 4(%[pfrfi]) " + "\n\t" + "lh %[tmp4], 6(%[pfrfi]) " + "\n\t" + "subu %[tmp2], $zero, %[tmp2] " + "\n\t" + "sh %[tmp1], 0(%[pfreq_signal]) " + "\n\t" + "sh %[tmp2], 2(%[pfreq_signal]) " + "\n\t" + "subu %[tmp4], $zero, %[tmp4] " + "\n\t" + "sh %[tmp3], 4(%[pfreq_signal]) " + "\n\t" + "sh %[tmp4], 6(%[pfreq_signal]) " + "\n\t" + "lh %[tmp1], 8(%[pfrfi]) " + "\n\t" + "lh %[tmp2], 10(%[pfrfi]) " + "\n\t" + "lh %[tmp3], 12(%[pfrfi]) " + "\n\t" + "lh %[tmp4], 14(%[pfrfi]) " + "\n\t" + "addiu %[j], %[j], -8 " + "\n\t" + "subu %[tmp2], $zero, %[tmp2] " + "\n\t" + "sh %[tmp1], 8(%[pfreq_signal]) " + "\n\t" + "sh %[tmp2], 10(%[pfreq_signal]) " + "\n\t" + "subu %[tmp4], $zero, %[tmp4] " + "\n\t" + "sh %[tmp3], 12(%[pfreq_signal]) " + "\n\t" + "sh %[tmp4], 14(%[pfreq_signal]) " + "\n\t" + "addiu %[pfreq_signal], %[pfreq_signal], 16 " + "\n\t" + "bgtz %[j], 1b " + "\n\t" + " addiu %[pfrfi], %[pfrfi], 16 " + "\n\t" + ".set pop " + "\n\t" + : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3), + [j] "=&r"(j), [pfrfi] "+r"(pfrfi), [pfreq_signal] "+r"(pfreq_signal), + [tmp4] "=&r"(tmp4) + : + : "memory"); } static void InverseFFTAndWindow(AecmCore* aecm, @@ -216,67 +227,118 @@ static void InverseFFTAndWindow(AecmCore* aecm, const int16_t* pp_kSqrtHanning = &WebRtcAecm_kSqrtHanning[PART_LEN]; int16_t* output1 = output; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[i], $zero, 64 \n\t" - "1: \n\t" - "lh %[tmp1], 0(%[pcoefTable_ifft]) \n\t" - "lh %[tmp2], 2(%[pcoefTable_ifft]) \n\t" - "lh %[tmp_re], 0(%[pefw]) \n\t" - "lh %[tmp_im], 2(%[pefw]) \n\t" - "addu %[pfft], %[fft], %[tmp2] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "addu %[pfft], %[fft], %[tmp1] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "subu %[tmp_im], $zero, %[tmp_im] \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "lh %[tmp1], 4(%[pcoefTable_ifft]) \n\t" - "lh %[tmp2], 6(%[pcoefTable_ifft]) \n\t" - "lh %[tmp_re], 4(%[pefw]) \n\t" - "lh %[tmp_im], 6(%[pefw]) \n\t" - "addu %[pfft], %[fft], %[tmp2] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "addu %[pfft], %[fft], %[tmp1] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "subu %[tmp_im], $zero, %[tmp_im] \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "lh %[tmp1], 8(%[pcoefTable_ifft]) \n\t" - "lh %[tmp2], 10(%[pcoefTable_ifft]) \n\t" - "lh %[tmp_re], 8(%[pefw]) \n\t" - "lh %[tmp_im], 10(%[pefw]) \n\t" - "addu %[pfft], %[fft], %[tmp2] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "addu %[pfft], %[fft], %[tmp1] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "subu %[tmp_im], $zero, %[tmp_im] \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "lh %[tmp1], 12(%[pcoefTable_ifft]) \n\t" - "lh %[tmp2], 14(%[pcoefTable_ifft]) \n\t" - "lh %[tmp_re], 12(%[pefw]) \n\t" - "lh %[tmp_im], 14(%[pefw]) \n\t" - "addu %[pfft], %[fft], %[tmp2] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "addu %[pfft], %[fft], %[tmp1] \n\t" - "sh %[tmp_re], 0(%[pfft]) \n\t" - "subu %[tmp_im], $zero, %[tmp_im] \n\t" - "sh %[tmp_im], 2(%[pfft]) \n\t" - "addiu %[pcoefTable_ifft], %[pcoefTable_ifft], 16 \n\t" - "addiu %[i], %[i], -4 \n\t" - "bgtz %[i], 1b \n\t" - " addiu %[pefw], %[pefw], 16 \n\t" - ".set pop \n\t" - : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [pfft] "+r" (pfft), - [i] "=&r" (i), [tmp_re] "=&r" (tmp_re), [tmp_im] "=&r" (tmp_im), - [pefw] "+r" (pefw), [pcoefTable_ifft] "+r" (pcoefTable_ifft), - [fft] "+r" (fft) - : - : "memory" - ); + __asm __volatile( + ".set push " + "\n\t" + ".set noreorder " + "\n\t" + "addiu %[i], $zero, 64 " + "\n\t" + "1: " + "\n\t" + "lh %[tmp1], 0(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp2], 2(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp_re], 0(%[pefw]) " + "\n\t" + "lh %[tmp_im], 2(%[pefw]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp2] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp1] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "subu %[tmp_im], $zero, %[tmp_im] " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "lh %[tmp1], 4(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp2], 6(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp_re], 4(%[pefw]) " + "\n\t" + "lh %[tmp_im], 6(%[pefw]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp2] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp1] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "subu %[tmp_im], $zero, %[tmp_im] " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "lh %[tmp1], 8(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp2], 10(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp_re], 8(%[pefw]) " + "\n\t" + "lh %[tmp_im], 10(%[pefw]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp2] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp1] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "subu %[tmp_im], $zero, %[tmp_im] " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "lh %[tmp1], 12(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp2], 14(%[pcoefTable_ifft]) " + "\n\t" + "lh %[tmp_re], 12(%[pefw]) " + "\n\t" + "lh %[tmp_im], 14(%[pefw]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp2] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "addu %[pfft], %[fft], %[tmp1] " + "\n\t" + "sh %[tmp_re], 0(%[pfft]) " + "\n\t" + "subu %[tmp_im], $zero, %[tmp_im] " + "\n\t" + "sh %[tmp_im], 2(%[pfft]) " + "\n\t" + "addiu %[pcoefTable_ifft], %[pcoefTable_ifft], 16 " + "\n\t" + "addiu %[i], %[i], -4 " + "\n\t" + "bgtz %[i], 1b " + "\n\t" + " addiu %[pefw], %[pefw], 16 " + "\n\t" + ".set pop " + "\n\t" + : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [pfft] "+r"(pfft), [i] "=&r"(i), + [tmp_re] "=&r"(tmp_re), [tmp_im] "=&r"(tmp_im), [pefw] "+r"(pefw), + [pcoefTable_ifft] "+r"(pcoefTable_ifft), [fft] "+r"(fft) + : + : "memory"); fft[2] = efw[PART_LEN].real; fft[3] = -efw[PART_LEN].imag; @@ -284,150 +346,235 @@ static void InverseFFTAndWindow(AecmCore* aecm, outCFFT = WebRtcSpl_ComplexIFFT(fft, PART_LEN_SHIFT, 1); pfft = fft; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[i], $zero, 128 \n\t" - "1: \n\t" - "lh %[tmp1], 0(%[ppfft]) \n\t" - "lh %[tmp2], 4(%[ppfft]) \n\t" - "lh %[tmp3], 8(%[ppfft]) \n\t" - "lh %[tmp4], 12(%[ppfft]) \n\t" - "addiu %[i], %[i], -4 \n\t" - "sh %[tmp1], 0(%[pfft]) \n\t" - "sh %[tmp2], 2(%[pfft]) \n\t" - "sh %[tmp3], 4(%[pfft]) \n\t" - "sh %[tmp4], 6(%[pfft]) \n\t" - "addiu %[ppfft], %[ppfft], 16 \n\t" - "bgtz %[i], 1b \n\t" - " addiu %[pfft], %[pfft], 8 \n\t" - ".set pop \n\t" - : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [pfft] "+r" (pfft), - [i] "=&r" (i), [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4), - [ppfft] "+r" (ppfft) - : - : "memory" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[i], $zero, 128 \n\t" + "1: \n\t" + "lh %[tmp1], 0(%[ppfft]) \n\t" + "lh %[tmp2], 4(%[ppfft]) \n\t" + "lh %[tmp3], 8(%[ppfft]) \n\t" + "lh %[tmp4], 12(%[ppfft]) \n\t" + "addiu %[i], %[i], -4 \n\t" + "sh %[tmp1], 0(%[pfft]) \n\t" + "sh %[tmp2], 2(%[pfft]) \n\t" + "sh %[tmp3], 4(%[pfft]) \n\t" + "sh %[tmp4], 6(%[pfft]) \n\t" + "addiu %[ppfft], %[ppfft], 16 \n\t" + "bgtz %[i], 1b \n\t" + " addiu %[pfft], %[pfft], 8 \n\t" + ".set pop \n\t" + : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [pfft] "+r"(pfft), [i] "=&r"(i), + [tmp3] "=&r"(tmp3), [tmp4] "=&r"(tmp4), [ppfft] "+r"(ppfft) + : + : "memory"); pfft = fft; out_aecm = (int32_t)(outCFFT - aecm->dfaCleanQDomain); - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[i], $zero, 64 \n\t" - "11: \n\t" - "lh %[tmp1], 0(%[pfft]) \n\t" - "lh %[tmp2], 0(%[p_kSqrtHanning]) \n\t" - "addiu %[i], %[i], -2 \n\t" - "mul %[tmp1], %[tmp1], %[tmp2] \n\t" - "lh %[tmp3], 2(%[pfft]) \n\t" - "lh %[tmp4], 2(%[p_kSqrtHanning]) \n\t" - "mul %[tmp3], %[tmp3], %[tmp4] \n\t" - "addiu %[tmp1], %[tmp1], 8192 \n\t" - "sra %[tmp1], %[tmp1], 14 \n\t" - "addiu %[tmp3], %[tmp3], 8192 \n\t" - "sra %[tmp3], %[tmp3], 14 \n\t" - "bgez %[out_aecm], 1f \n\t" - " negu %[tmp2], %[out_aecm] \n\t" - "srav %[tmp1], %[tmp1], %[tmp2] \n\t" - "b 2f \n\t" - " srav %[tmp3], %[tmp3], %[tmp2] \n\t" - "1: \n\t" - "sllv %[tmp1], %[tmp1], %[out_aecm] \n\t" - "sllv %[tmp3], %[tmp3], %[out_aecm] \n\t" - "2: \n\t" - "lh %[tmp4], 0(%[paecm_buf]) \n\t" - "lh %[tmp2], 2(%[paecm_buf]) \n\t" - "addu %[tmp3], %[tmp3], %[tmp2] \n\t" - "addu %[tmp1], %[tmp1], %[tmp4] \n\t" + __asm __volatile( + ".set push " + "\n\t" + ".set noreorder " + "\n\t" + "addiu %[i], $zero, 64 " + "\n\t" + "11: " + "\n\t" + "lh %[tmp1], 0(%[pfft]) " + "\n\t" + "lh %[tmp2], 0(%[p_kSqrtHanning]) " + "\n\t" + "addiu %[i], %[i], -2 " + "\n\t" + "mul %[tmp1], %[tmp1], %[tmp2] " + "\n\t" + "lh %[tmp3], 2(%[pfft]) " + "\n\t" + "lh %[tmp4], 2(%[p_kSqrtHanning]) " + "\n\t" + "mul %[tmp3], %[tmp3], %[tmp4] " + "\n\t" + "addiu %[tmp1], %[tmp1], 8192 " + "\n\t" + "sra %[tmp1], %[tmp1], 14 " + "\n\t" + "addiu %[tmp3], %[tmp3], 8192 " + "\n\t" + "sra %[tmp3], %[tmp3], 14 " + "\n\t" + "bgez %[out_aecm], 1f " + "\n\t" + " negu %[tmp2], %[out_aecm] " + "\n\t" + "srav %[tmp1], %[tmp1], %[tmp2] " + "\n\t" + "b 2f " + "\n\t" + " srav %[tmp3], %[tmp3], %[tmp2] " + "\n\t" + "1: " + "\n\t" + "sllv %[tmp1], %[tmp1], %[out_aecm] " + "\n\t" + "sllv %[tmp3], %[tmp3], %[out_aecm] " + "\n\t" + "2: " + "\n\t" + "lh %[tmp4], 0(%[paecm_buf]) " + "\n\t" + "lh %[tmp2], 2(%[paecm_buf]) " + "\n\t" + "addu %[tmp3], %[tmp3], %[tmp2] " + "\n\t" + "addu %[tmp1], %[tmp1], %[tmp4] " + "\n\t" #if defined(MIPS_DSP_R1_LE) - "shll_s.w %[tmp1], %[tmp1], 16 \n\t" - "sra %[tmp1], %[tmp1], 16 \n\t" - "shll_s.w %[tmp3], %[tmp3], 16 \n\t" - "sra %[tmp3], %[tmp3], 16 \n\t" -#else // #if defined(MIPS_DSP_R1_LE) - "sra %[tmp4], %[tmp1], 31 \n\t" - "sra %[tmp2], %[tmp1], 15 \n\t" - "beq %[tmp4], %[tmp2], 3f \n\t" - " ori %[tmp2], $zero, 0x7fff \n\t" - "xor %[tmp1], %[tmp2], %[tmp4] \n\t" - "3: \n\t" - "sra %[tmp2], %[tmp3], 31 \n\t" - "sra %[tmp4], %[tmp3], 15 \n\t" - "beq %[tmp2], %[tmp4], 4f \n\t" - " ori %[tmp4], $zero, 0x7fff \n\t" - "xor %[tmp3], %[tmp4], %[tmp2] \n\t" - "4: \n\t" + "shll_s.w %[tmp1], %[tmp1], 16 " + "\n\t" + "sra %[tmp1], %[tmp1], 16 " + "\n\t" + "shll_s.w %[tmp3], %[tmp3], 16 " + "\n\t" + "sra %[tmp3], %[tmp3], 16 " + "\n\t" +#else // #if defined(MIPS_DSP_R1_LE) + "sra %[tmp4], %[tmp1], 31 " + "\n\t" + "sra %[tmp2], %[tmp1], 15 " + "\n\t" + "beq %[tmp4], %[tmp2], 3f " + "\n\t" + " ori %[tmp2], $zero, 0x7fff " + "\n\t" + "xor %[tmp1], %[tmp2], %[tmp4] " + "\n\t" + "3: " + "\n\t" + "sra %[tmp2], %[tmp3], 31 " + "\n\t" + "sra %[tmp4], %[tmp3], 15 " + "\n\t" + "beq %[tmp2], %[tmp4], 4f " + "\n\t" + " ori %[tmp4], $zero, 0x7fff " + "\n\t" + "xor %[tmp3], %[tmp4], %[tmp2] " + "\n\t" + "4: " + "\n\t" #endif // #if defined(MIPS_DSP_R1_LE) - "sh %[tmp1], 0(%[pfft]) \n\t" - "sh %[tmp1], 0(%[output1]) \n\t" - "sh %[tmp3], 2(%[pfft]) \n\t" - "sh %[tmp3], 2(%[output1]) \n\t" - "lh %[tmp1], 128(%[pfft]) \n\t" - "lh %[tmp2], 0(%[pp_kSqrtHanning]) \n\t" - "mul %[tmp1], %[tmp1], %[tmp2] \n\t" - "lh %[tmp3], 130(%[pfft]) \n\t" - "lh %[tmp4], -2(%[pp_kSqrtHanning]) \n\t" - "mul %[tmp3], %[tmp3], %[tmp4] \n\t" - "sra %[tmp1], %[tmp1], 14 \n\t" - "sra %[tmp3], %[tmp3], 14 \n\t" - "bgez %[out_aecm], 5f \n\t" - " negu %[tmp2], %[out_aecm] \n\t" - "srav %[tmp3], %[tmp3], %[tmp2] \n\t" - "b 6f \n\t" - " srav %[tmp1], %[tmp1], %[tmp2] \n\t" - "5: \n\t" - "sllv %[tmp1], %[tmp1], %[out_aecm] \n\t" - "sllv %[tmp3], %[tmp3], %[out_aecm] \n\t" - "6: \n\t" + "sh %[tmp1], 0(%[pfft]) " + "\n\t" + "sh %[tmp1], 0(%[output1]) " + "\n\t" + "sh %[tmp3], 2(%[pfft]) " + "\n\t" + "sh %[tmp3], 2(%[output1]) " + "\n\t" + "lh %[tmp1], 128(%[pfft]) " + "\n\t" + "lh %[tmp2], 0(%[pp_kSqrtHanning]) " + "\n\t" + "mul %[tmp1], %[tmp1], %[tmp2] " + "\n\t" + "lh %[tmp3], 130(%[pfft]) " + "\n\t" + "lh %[tmp4], -2(%[pp_kSqrtHanning]) " + "\n\t" + "mul %[tmp3], %[tmp3], %[tmp4] " + "\n\t" + "sra %[tmp1], %[tmp1], 14 " + "\n\t" + "sra %[tmp3], %[tmp3], 14 " + "\n\t" + "bgez %[out_aecm], 5f " + "\n\t" + " negu %[tmp2], %[out_aecm] " + "\n\t" + "srav %[tmp3], %[tmp3], %[tmp2] " + "\n\t" + "b 6f " + "\n\t" + " srav %[tmp1], %[tmp1], %[tmp2] " + "\n\t" + "5: " + "\n\t" + "sllv %[tmp1], %[tmp1], %[out_aecm] " + "\n\t" + "sllv %[tmp3], %[tmp3], %[out_aecm] " + "\n\t" + "6: " + "\n\t" #if defined(MIPS_DSP_R1_LE) - "shll_s.w %[tmp1], %[tmp1], 16 \n\t" - "sra %[tmp1], %[tmp1], 16 \n\t" - "shll_s.w %[tmp3], %[tmp3], 16 \n\t" - "sra %[tmp3], %[tmp3], 16 \n\t" -#else // #if defined(MIPS_DSP_R1_LE) - "sra %[tmp4], %[tmp1], 31 \n\t" - "sra %[tmp2], %[tmp1], 15 \n\t" - "beq %[tmp4], %[tmp2], 7f \n\t" - " ori %[tmp2], $zero, 0x7fff \n\t" - "xor %[tmp1], %[tmp2], %[tmp4] \n\t" - "7: \n\t" - "sra %[tmp2], %[tmp3], 31 \n\t" - "sra %[tmp4], %[tmp3], 15 \n\t" - "beq %[tmp2], %[tmp4], 8f \n\t" - " ori %[tmp4], $zero, 0x7fff \n\t" - "xor %[tmp3], %[tmp4], %[tmp2] \n\t" - "8: \n\t" + "shll_s.w %[tmp1], %[tmp1], 16 " + "\n\t" + "sra %[tmp1], %[tmp1], 16 " + "\n\t" + "shll_s.w %[tmp3], %[tmp3], 16 " + "\n\t" + "sra %[tmp3], %[tmp3], 16 " + "\n\t" +#else // #if defined(MIPS_DSP_R1_LE) + "sra %[tmp4], %[tmp1], 31 " + "\n\t" + "sra %[tmp2], %[tmp1], 15 " + "\n\t" + "beq %[tmp4], %[tmp2], 7f " + "\n\t" + " ori %[tmp2], $zero, 0x7fff " + "\n\t" + "xor %[tmp1], %[tmp2], %[tmp4] " + "\n\t" + "7: " + "\n\t" + "sra %[tmp2], %[tmp3], 31 " + "\n\t" + "sra %[tmp4], %[tmp3], 15 " + "\n\t" + "beq %[tmp2], %[tmp4], 8f " + "\n\t" + " ori %[tmp4], $zero, 0x7fff " + "\n\t" + "xor %[tmp3], %[tmp4], %[tmp2] " + "\n\t" + "8: " + "\n\t" #endif // #if defined(MIPS_DSP_R1_LE) - "sh %[tmp1], 0(%[paecm_buf]) \n\t" - "sh %[tmp3], 2(%[paecm_buf]) \n\t" - "addiu %[output1], %[output1], 4 \n\t" - "addiu %[paecm_buf], %[paecm_buf], 4 \n\t" - "addiu %[pfft], %[pfft], 4 \n\t" - "addiu %[p_kSqrtHanning], %[p_kSqrtHanning], 4 \n\t" - "bgtz %[i], 11b \n\t" - " addiu %[pp_kSqrtHanning], %[pp_kSqrtHanning], -4 \n\t" - ".set pop \n\t" - : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [pfft] "+r" (pfft), - [output1] "+r" (output1), [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4), - [paecm_buf] "+r" (paecm_buf), [i] "=&r" (i), - [pp_kSqrtHanning] "+r" (pp_kSqrtHanning), - [p_kSqrtHanning] "+r" (p_kSqrtHanning) - : [out_aecm] "r" (out_aecm), - [WebRtcAecm_kSqrtHanning] "r" (WebRtcAecm_kSqrtHanning) - : "hi", "lo","memory" - ); + "sh %[tmp1], 0(%[paecm_buf]) " + "\n\t" + "sh %[tmp3], 2(%[paecm_buf]) " + "\n\t" + "addiu %[output1], %[output1], 4 " + "\n\t" + "addiu %[paecm_buf], %[paecm_buf], 4 " + "\n\t" + "addiu %[pfft], %[pfft], 4 " + "\n\t" + "addiu %[p_kSqrtHanning], %[p_kSqrtHanning], 4 " + "\n\t" + "bgtz %[i], 11b " + "\n\t" + " addiu %[pp_kSqrtHanning], %[pp_kSqrtHanning], -4 " + "\n\t" + ".set pop " + "\n\t" + : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [pfft] "+r"(pfft), + [output1] "+r"(output1), [tmp3] "=&r"(tmp3), [tmp4] "=&r"(tmp4), + [paecm_buf] "+r"(paecm_buf), [i] "=&r"(i), + [pp_kSqrtHanning] "+r"(pp_kSqrtHanning), + [p_kSqrtHanning] "+r"(p_kSqrtHanning) + : [out_aecm] "r"(out_aecm), + [WebRtcAecm_kSqrtHanning] "r"(WebRtcAecm_kSqrtHanning) + : "hi", "lo", "memory"); // Copy the current block to the old position // (aecm->outBuf is shifted elsewhere) memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN); - memcpy(aecm->dBufNoisy, - aecm->dBufNoisy + PART_LEN, + memcpy(aecm->dBufNoisy, aecm->dBufNoisy + PART_LEN, sizeof(int16_t) * PART_LEN); if (nearendClean != NULL) { - memcpy(aecm->dBufClean, - aecm->dBufClean + PART_LEN, + memcpy(aecm->dBufClean, aecm->dBufClean + PART_LEN, sizeof(int16_t) * PART_LEN); } } @@ -451,62 +598,61 @@ void WebRtcAecm_CalcLinearEnergies_mips(AecmCore* aecm, // Get energy for the delayed far end signal and estimated // echo using both stored and adapted channels. - for (i = 0; i < PART_LEN; i+= 4) { - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "lh %[stored0], 0(%[ch_stored_p]) \n\t" - "lhu %[adept0], 0(%[ch_adapt_p]) \n\t" - "lhu %[spectrum0], 0(%[spectrum_p]) \n\t" - "lh %[stored1], 2(%[ch_stored_p]) \n\t" - "lhu %[adept1], 2(%[ch_adapt_p]) \n\t" - "lhu %[spectrum1], 2(%[spectrum_p]) \n\t" - "mul %[echo0], %[stored0], %[spectrum0] \n\t" - "mul %[temp0], %[adept0], %[spectrum0] \n\t" - "mul %[echo1], %[stored1], %[spectrum1] \n\t" - "mul %[temp1], %[adept1], %[spectrum1] \n\t" - "addu %[par1], %[par1], %[spectrum0] \n\t" - "addu %[par1], %[par1], %[spectrum1] \n\t" - "addiu %[echo_p], %[echo_p], 16 \n\t" - "addu %[par3], %[par3], %[echo0] \n\t" - "addu %[par2], %[par2], %[temp0] \n\t" - "addu %[par3], %[par3], %[echo1] \n\t" - "addu %[par2], %[par2], %[temp1] \n\t" - "usw %[echo0], -16(%[echo_p]) \n\t" - "usw %[echo1], -12(%[echo_p]) \n\t" - "lh %[stored0], 4(%[ch_stored_p]) \n\t" - "lhu %[adept0], 4(%[ch_adapt_p]) \n\t" - "lhu %[spectrum0], 4(%[spectrum_p]) \n\t" - "lh %[stored1], 6(%[ch_stored_p]) \n\t" - "lhu %[adept1], 6(%[ch_adapt_p]) \n\t" - "lhu %[spectrum1], 6(%[spectrum_p]) \n\t" - "mul %[echo0], %[stored0], %[spectrum0] \n\t" - "mul %[temp0], %[adept0], %[spectrum0] \n\t" - "mul %[echo1], %[stored1], %[spectrum1] \n\t" - "mul %[temp1], %[adept1], %[spectrum1] \n\t" - "addu %[par1], %[par1], %[spectrum0] \n\t" - "addu %[par1], %[par1], %[spectrum1] \n\t" - "addiu %[ch_stored_p], %[ch_stored_p], 8 \n\t" - "addiu %[ch_adapt_p], %[ch_adapt_p], 8 \n\t" - "addiu %[spectrum_p], %[spectrum_p], 8 \n\t" - "addu %[par3], %[par3], %[echo0] \n\t" - "addu %[par2], %[par2], %[temp0] \n\t" - "addu %[par3], %[par3], %[echo1] \n\t" - "addu %[par2], %[par2], %[temp1] \n\t" - "usw %[echo0], -8(%[echo_p]) \n\t" - "usw %[echo1], -4(%[echo_p]) \n\t" - ".set pop \n\t" - : [temp0] "=&r" (temp0), [stored0] "=&r" (stored0), - [adept0] "=&r" (adept0), [spectrum0] "=&r" (spectrum0), - [echo0] "=&r" (echo0), [echo_p] "+r" (echo_p), [par3] "+r" (par3), - [par1] "+r" (par1), [par2] "+r" (par2), [stored1] "=&r" (stored1), - [adept1] "=&r" (adept1), [echo1] "=&r" (echo1), - [spectrum1] "=&r" (spectrum1), [temp1] "=&r" (temp1), - [ch_stored_p] "+r" (ch_stored_p), [ch_adapt_p] "+r" (ch_adapt_p), - [spectrum_p] "+r" (spectrum_p) - : - : "hi", "lo", "memory" - ); + for (i = 0; i < PART_LEN; i += 4) { + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "lh %[stored0], 0(%[ch_stored_p]) \n\t" + "lhu %[adept0], 0(%[ch_adapt_p]) \n\t" + "lhu %[spectrum0], 0(%[spectrum_p]) \n\t" + "lh %[stored1], 2(%[ch_stored_p]) \n\t" + "lhu %[adept1], 2(%[ch_adapt_p]) \n\t" + "lhu %[spectrum1], 2(%[spectrum_p]) \n\t" + "mul %[echo0], %[stored0], %[spectrum0] \n\t" + "mul %[temp0], %[adept0], %[spectrum0] \n\t" + "mul %[echo1], %[stored1], %[spectrum1] \n\t" + "mul %[temp1], %[adept1], %[spectrum1] \n\t" + "addu %[par1], %[par1], %[spectrum0] \n\t" + "addu %[par1], %[par1], %[spectrum1] \n\t" + "addiu %[echo_p], %[echo_p], 16 \n\t" + "addu %[par3], %[par3], %[echo0] \n\t" + "addu %[par2], %[par2], %[temp0] \n\t" + "addu %[par3], %[par3], %[echo1] \n\t" + "addu %[par2], %[par2], %[temp1] \n\t" + "usw %[echo0], -16(%[echo_p]) \n\t" + "usw %[echo1], -12(%[echo_p]) \n\t" + "lh %[stored0], 4(%[ch_stored_p]) \n\t" + "lhu %[adept0], 4(%[ch_adapt_p]) \n\t" + "lhu %[spectrum0], 4(%[spectrum_p]) \n\t" + "lh %[stored1], 6(%[ch_stored_p]) \n\t" + "lhu %[adept1], 6(%[ch_adapt_p]) \n\t" + "lhu %[spectrum1], 6(%[spectrum_p]) \n\t" + "mul %[echo0], %[stored0], %[spectrum0] \n\t" + "mul %[temp0], %[adept0], %[spectrum0] \n\t" + "mul %[echo1], %[stored1], %[spectrum1] \n\t" + "mul %[temp1], %[adept1], %[spectrum1] \n\t" + "addu %[par1], %[par1], %[spectrum0] \n\t" + "addu %[par1], %[par1], %[spectrum1] \n\t" + "addiu %[ch_stored_p], %[ch_stored_p], 8 \n\t" + "addiu %[ch_adapt_p], %[ch_adapt_p], 8 \n\t" + "addiu %[spectrum_p], %[spectrum_p], 8 \n\t" + "addu %[par3], %[par3], %[echo0] \n\t" + "addu %[par2], %[par2], %[temp0] \n\t" + "addu %[par3], %[par3], %[echo1] \n\t" + "addu %[par2], %[par2], %[temp1] \n\t" + "usw %[echo0], -8(%[echo_p]) \n\t" + "usw %[echo1], -4(%[echo_p]) \n\t" + ".set pop \n\t" + : [temp0] "=&r"(temp0), [stored0] "=&r"(stored0), + [adept0] "=&r"(adept0), [spectrum0] "=&r"(spectrum0), + [echo0] "=&r"(echo0), [echo_p] "+r"(echo_p), [par3] "+r"(par3), + [par1] "+r"(par1), [par2] "+r"(par2), [stored1] "=&r"(stored1), + [adept1] "=&r"(adept1), [echo1] "=&r"(echo1), + [spectrum1] "=&r"(spectrum1), [temp1] "=&r"(temp1), + [ch_stored_p] "+r"(ch_stored_p), [ch_adapt_p] "+r"(ch_adapt_p), + [spectrum_p] "+r"(spectrum_p) + : + : "hi", "lo", "memory"); } echo_est[PART_LEN] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[PART_LEN], @@ -537,35 +683,33 @@ void WebRtcAecm_StoreAdaptiveChannel_mips(AecmCore* aecm, sizeof(int16_t) * PART_LEN1); // Recalculate echo estimate for (i = 0; i < PART_LEN; i += 4) { - __asm __volatile ( - "ulw %[temp0], 0(%[temp8]) \n\t" - "ulw %[temp2], 0(%[temp1]) \n\t" - "ulw %[temp4], 4(%[temp8]) \n\t" - "ulw %[temp5], 4(%[temp1]) \n\t" - "muleq_s.w.phl %[temp3], %[temp2], %[temp0] \n\t" - "muleq_s.w.phr %[temp0], %[temp2], %[temp0] \n\t" - "muleq_s.w.phl %[temp6], %[temp5], %[temp4] \n\t" - "muleq_s.w.phr %[temp4], %[temp5], %[temp4] \n\t" - "addiu %[temp7], %[temp7], 16 \n\t" - "addiu %[temp1], %[temp1], 8 \n\t" - "addiu %[temp8], %[temp8], 8 \n\t" - "sra %[temp3], %[temp3], 1 \n\t" - "sra %[temp0], %[temp0], 1 \n\t" - "sra %[temp6], %[temp6], 1 \n\t" - "sra %[temp4], %[temp4], 1 \n\t" - "usw %[temp3], -12(%[temp7]) \n\t" - "usw %[temp0], -16(%[temp7]) \n\t" - "usw %[temp6], -4(%[temp7]) \n\t" - "usw %[temp4], -8(%[temp7]) \n\t" - : [temp0] "=&r" (temp0), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3), - [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [temp6] "=&r" (temp6), - [temp1] "+r" (temp1), [temp8] "+r" (temp8), [temp7] "+r" (temp7) - : - : "hi", "lo", "memory" - ); + __asm __volatile( + "ulw %[temp0], 0(%[temp8]) \n\t" + "ulw %[temp2], 0(%[temp1]) \n\t" + "ulw %[temp4], 4(%[temp8]) \n\t" + "ulw %[temp5], 4(%[temp1]) \n\t" + "muleq_s.w.phl %[temp3], %[temp2], %[temp0] \n\t" + "muleq_s.w.phr %[temp0], %[temp2], %[temp0] \n\t" + "muleq_s.w.phl %[temp6], %[temp5], %[temp4] \n\t" + "muleq_s.w.phr %[temp4], %[temp5], %[temp4] \n\t" + "addiu %[temp7], %[temp7], 16 \n\t" + "addiu %[temp1], %[temp1], 8 \n\t" + "addiu %[temp8], %[temp8], 8 \n\t" + "sra %[temp3], %[temp3], 1 \n\t" + "sra %[temp0], %[temp0], 1 \n\t" + "sra %[temp6], %[temp6], 1 \n\t" + "sra %[temp4], %[temp4], 1 \n\t" + "usw %[temp3], -12(%[temp7]) \n\t" + "usw %[temp0], -16(%[temp7]) \n\t" + "usw %[temp6], -4(%[temp7]) \n\t" + "usw %[temp4], -8(%[temp7]) \n\t" + : [temp0] "=&r"(temp0), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3), + [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [temp6] "=&r"(temp6), + [temp1] "+r"(temp1), [temp8] "+r"(temp8), [temp7] "+r"(temp7) + : + : "hi", "lo", "memory"); } - echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], - far_spectrum[i]); + echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]); } void WebRtcAecm_ResetAdaptiveChannel_mips(AecmCore* aecm) { @@ -579,31 +723,28 @@ void WebRtcAecm_ResetAdaptiveChannel_mips(AecmCore* aecm) { // The stored channel has a significantly lower MSE than the adaptive one for // two consecutive calculations. Reset the adaptive channel. - memcpy(aecm->channelAdapt16, - aecm->channelStored, + memcpy(aecm->channelAdapt16, aecm->channelStored, sizeof(int16_t) * PART_LEN1); // Restore the W32 channel for (i = 0; i < PART_LEN; i += 4) { - __asm __volatile ( - "ulw %[temp1], 0(%[temp0]) \n\t" - "ulw %[temp4], 4(%[temp0]) \n\t" - "preceq.w.phl %[temp2], %[temp1] \n\t" - "preceq.w.phr %[temp1], %[temp1] \n\t" - "preceq.w.phl %[temp5], %[temp4] \n\t" - "preceq.w.phr %[temp4], %[temp4] \n\t" - "addiu %[temp0], %[temp0], 8 \n\t" - "usw %[temp2], 4(%[temp3]) \n\t" - "usw %[temp1], 0(%[temp3]) \n\t" - "usw %[temp5], 12(%[temp3]) \n\t" - "usw %[temp4], 8(%[temp3]) \n\t" - "addiu %[temp3], %[temp3], 16 \n\t" - : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), - [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), - [temp3] "+r" (temp3), [temp0] "+r" (temp0) - : - : "memory" - ); + __asm __volatile( + "ulw %[temp1], 0(%[temp0]) \n\t" + "ulw %[temp4], 4(%[temp0]) \n\t" + "preceq.w.phl %[temp2], %[temp1] \n\t" + "preceq.w.phr %[temp1], %[temp1] \n\t" + "preceq.w.phl %[temp5], %[temp4] \n\t" + "preceq.w.phr %[temp4], %[temp4] \n\t" + "addiu %[temp0], %[temp0], 8 \n\t" + "usw %[temp2], 4(%[temp3]) \n\t" + "usw %[temp1], 0(%[temp3]) \n\t" + "usw %[temp5], 12(%[temp3]) \n\t" + "usw %[temp4], 8(%[temp3]) \n\t" + "addiu %[temp3], %[temp3], 16 \n\t" + : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp4] "=&r"(temp4), + [temp5] "=&r"(temp5), [temp3] "+r"(temp3), [temp0] "+r"(temp0) + : + : "memory"); } aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16; @@ -633,7 +774,7 @@ static int TimeToFrequencyDomain(AecmCore* aecm, // In fft_buf, +16 for 32-byte alignment. int16_t fft_buf[PART_LEN4 + 16]; - int16_t *fft = (int16_t *) (((uintptr_t) fft_buf + 31) & ~31); + int16_t* fft = (int16_t*)(((uintptr_t)fft_buf + 31) & ~31); int16_t tmp16no1; #if !defined(MIPS_DSP_R2_LE) @@ -662,25 +803,18 @@ static int TimeToFrequencyDomain(AecmCore* aecm, freq_signal[PART_LEN].imag = 0; freq_signal[PART_LEN].real = fft[PART_LEN2]; freq_signal_abs[0] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[0].real); - freq_signal_abs[PART_LEN] = (uint16_t)WEBRTC_SPL_ABS_W16( - freq_signal[PART_LEN].real); - (*freq_signal_sum_abs) = (uint32_t)(freq_signal_abs[0]) + - (uint32_t)(freq_signal_abs[PART_LEN]); + freq_signal_abs[PART_LEN] = + (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[PART_LEN].real); + (*freq_signal_sum_abs) = + (uint32_t)(freq_signal_abs[0]) + (uint32_t)(freq_signal_abs[PART_LEN]); #if !defined(MIPS_DSP_R2_LE) for (i = 1; i < PART_LEN; i++) { - if (freq_signal[i].real == 0) - { - freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16( - freq_signal[i].imag); - } - else if (freq_signal[i].imag == 0) - { - freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16( - freq_signal[i].real); - } - else - { + if (freq_signal[i].real == 0) { + freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].imag); + } else if (freq_signal[i].imag == 0) { + freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].real); + } else { // Approximation for magnitude of complex fft output // magn = sqrt(real^2 + imag^2) // magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|) @@ -697,32 +831,30 @@ static int TimeToFrequencyDomain(AecmCore* aecm, } (*freq_signal_sum_abs) += (uint32_t)freq_signal_abs[i]; } -#else // #if !defined(MIPS_DSP_R2_LE) - freqs = (uint32_t)(freq_signal_abs[0]) + - (uint32_t)(freq_signal_abs[PART_LEN]); +#else // #if !defined(MIPS_DSP_R2_LE) + freqs = + (uint32_t)(freq_signal_abs[0]) + (uint32_t)(freq_signal_abs[PART_LEN]); freqp = &(freq_signal[1].real); - __asm __volatile ( - "lw %[freqt0], 0(%[freqp]) \n\t" - "lw %[freqt1], 4(%[freqp]) \n\t" - "lw %[freqt2], 8(%[freqp]) \n\t" - "mult $ac0, $zero, $zero \n\t" - "mult $ac1, $zero, $zero \n\t" - "mult $ac2, $zero, $zero \n\t" - "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t" - "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t" - "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t" - "addiu %[freqp], %[freqp], 12 \n\t" - "extr.w %[tmp32no20], $ac0, 1 \n\t" - "extr.w %[tmp32no21], $ac1, 1 \n\t" - "extr.w %[tmp32no22], $ac2, 1 \n\t" - : [freqt0] "=&r" (freqt0), [freqt1] "=&r" (freqt1), - [freqt2] "=&r" (freqt2), [freqp] "+r" (freqp), - [tmp32no20] "=r" (tmp32no20), [tmp32no21] "=r" (tmp32no21), - [tmp32no22] "=r" (tmp32no22) - : - : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo" - ); + __asm __volatile( + "lw %[freqt0], 0(%[freqp]) \n\t" + "lw %[freqt1], 4(%[freqp]) \n\t" + "lw %[freqt2], 8(%[freqp]) \n\t" + "mult $ac0, $zero, $zero \n\t" + "mult $ac1, $zero, $zero \n\t" + "mult $ac2, $zero, $zero \n\t" + "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t" + "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t" + "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t" + "addiu %[freqp], %[freqp], 12 \n\t" + "extr.w %[tmp32no20], $ac0, 1 \n\t" + "extr.w %[tmp32no21], $ac1, 1 \n\t" + "extr.w %[tmp32no22], $ac2, 1 \n\t" + : [freqt0] "=&r"(freqt0), [freqt1] "=&r"(freqt1), [freqt2] "=&r"(freqt2), + [freqp] "+r"(freqp), [tmp32no20] "=r"(tmp32no20), + [tmp32no21] "=r"(tmp32no21), [tmp32no22] "=r"(tmp32no22) + : + : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo"); tmp32no10 = WebRtcSpl_SqrtFloor(tmp32no20); tmp32no11 = WebRtcSpl_SqrtFloor(tmp32no21); @@ -734,57 +866,54 @@ static int TimeToFrequencyDomain(AecmCore* aecm, freqs += (uint32_t)tmp32no11; freqs += (uint32_t)tmp32no12; freqabsp = &(freq_signal_abs[4]); - for (i = 4; i < PART_LEN; i+=4) - { - __asm __volatile ( - "ulw %[freqt0], 0(%[freqp]) \n\t" - "ulw %[freqt1], 4(%[freqp]) \n\t" - "ulw %[freqt2], 8(%[freqp]) \n\t" - "ulw %[freqt3], 12(%[freqp]) \n\t" - "mult $ac0, $zero, $zero \n\t" - "mult $ac1, $zero, $zero \n\t" - "mult $ac2, $zero, $zero \n\t" - "mult $ac3, $zero, $zero \n\t" - "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t" - "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t" - "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t" - "dpaq_s.w.ph $ac3, %[freqt3], %[freqt3] \n\t" - "addiu %[freqp], %[freqp], 16 \n\t" - "addiu %[freqabsp], %[freqabsp], 8 \n\t" - "extr.w %[tmp32no20], $ac0, 1 \n\t" - "extr.w %[tmp32no21], $ac1, 1 \n\t" - "extr.w %[tmp32no22], $ac2, 1 \n\t" - "extr.w %[tmp32no23], $ac3, 1 \n\t" - : [freqt0] "=&r" (freqt0), [freqt1] "=&r" (freqt1), - [freqt2] "=&r" (freqt2), [freqt3] "=&r" (freqt3), - [tmp32no20] "=r" (tmp32no20), [tmp32no21] "=r" (tmp32no21), - [tmp32no22] "=r" (tmp32no22), [tmp32no23] "=r" (tmp32no23), - [freqabsp] "+r" (freqabsp), [freqp] "+r" (freqp) - : - : "memory", "hi", "lo", "$ac1hi", "$ac1lo", - "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo" - ); + for (i = 4; i < PART_LEN; i += 4) { + __asm __volatile( + "ulw %[freqt0], 0(%[freqp]) \n\t" + "ulw %[freqt1], 4(%[freqp]) \n\t" + "ulw %[freqt2], 8(%[freqp]) \n\t" + "ulw %[freqt3], 12(%[freqp]) \n\t" + "mult $ac0, $zero, $zero \n\t" + "mult $ac1, $zero, $zero \n\t" + "mult $ac2, $zero, $zero \n\t" + "mult $ac3, $zero, $zero \n\t" + "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t" + "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t" + "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t" + "dpaq_s.w.ph $ac3, %[freqt3], %[freqt3] \n\t" + "addiu %[freqp], %[freqp], 16 \n\t" + "addiu %[freqabsp], %[freqabsp], 8 \n\t" + "extr.w %[tmp32no20], $ac0, 1 \n\t" + "extr.w %[tmp32no21], $ac1, 1 \n\t" + "extr.w %[tmp32no22], $ac2, 1 \n\t" + "extr.w %[tmp32no23], $ac3, 1 \n\t" + : [freqt0] "=&r"(freqt0), [freqt1] "=&r"(freqt1), + [freqt2] "=&r"(freqt2), [freqt3] "=&r"(freqt3), + [tmp32no20] "=r"(tmp32no20), [tmp32no21] "=r"(tmp32no21), + [tmp32no22] "=r"(tmp32no22), [tmp32no23] "=r"(tmp32no23), + [freqabsp] "+r"(freqabsp), [freqp] "+r"(freqp) + : + : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo", + "$ac3hi", "$ac3lo"); tmp32no10 = WebRtcSpl_SqrtFloor(tmp32no20); tmp32no11 = WebRtcSpl_SqrtFloor(tmp32no21); tmp32no12 = WebRtcSpl_SqrtFloor(tmp32no22); tmp32no13 = WebRtcSpl_SqrtFloor(tmp32no23); - __asm __volatile ( - "sh %[tmp32no10], -8(%[freqabsp]) \n\t" - "sh %[tmp32no11], -6(%[freqabsp]) \n\t" - "sh %[tmp32no12], -4(%[freqabsp]) \n\t" - "sh %[tmp32no13], -2(%[freqabsp]) \n\t" - "addu %[freqs], %[freqs], %[tmp32no10] \n\t" - "addu %[freqs], %[freqs], %[tmp32no11] \n\t" - "addu %[freqs], %[freqs], %[tmp32no12] \n\t" - "addu %[freqs], %[freqs], %[tmp32no13] \n\t" - : [freqs] "+r" (freqs) - : [tmp32no10] "r" (tmp32no10), [tmp32no11] "r" (tmp32no11), - [tmp32no12] "r" (tmp32no12), [tmp32no13] "r" (tmp32no13), - [freqabsp] "r" (freqabsp) - : "memory" - ); + __asm __volatile( + "sh %[tmp32no10], -8(%[freqabsp]) \n\t" + "sh %[tmp32no11], -6(%[freqabsp]) \n\t" + "sh %[tmp32no12], -4(%[freqabsp]) \n\t" + "sh %[tmp32no13], -2(%[freqabsp]) \n\t" + "addu %[freqs], %[freqs], %[tmp32no10] \n\t" + "addu %[freqs], %[freqs], %[tmp32no11] \n\t" + "addu %[freqs], %[freqs], %[tmp32no12] \n\t" + "addu %[freqs], %[freqs], %[tmp32no13] \n\t" + : [freqs] "+r"(freqs) + : [tmp32no10] "r"(tmp32no10), [tmp32no11] "r"(tmp32no11), + [tmp32no12] "r"(tmp32no12), [tmp32no13] "r"(tmp32no13), + [freqabsp] "r"(freqabsp) + : "memory"); } (*freq_signal_sum_abs) = freqs; @@ -813,13 +942,13 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, const uint16_t* far_spectrum_ptr = NULL; // 32 byte aligned buffers (with +8 or +16). - int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe. + int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe. int32_t echoEst32_buf[PART_LEN1 + 8]; int32_t dfw_buf[PART_LEN2 + 8]; int32_t efw_buf[PART_LEN2 + 8]; - int16_t* fft = (int16_t*)(((uint32_t)fft_buf + 31) & ~ 31); - int32_t* echoEst32 = (int32_t*)(((uint32_t)echoEst32_buf + 31) & ~ 31); + int16_t* fft = (int16_t*)(((uint32_t)fft_buf + 31) & ~31); + int32_t* echoEst32 = (int32_t*)(((uint32_t)echoEst32_buf + 31) & ~31); ComplexInt16* dfw = (ComplexInt16*)(((uint32_t)dfw_buf + 31) & ~31); ComplexInt16* efw = (ComplexInt16*)(((uint32_t)efw_buf + 31) & ~31); @@ -856,35 +985,25 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, // (2) the rest if (aecm->startupState < 2) { - aecm->startupState = (aecm->totCount >= CONV_LEN) + - (aecm->totCount >= CONV_LEN2); + aecm->startupState = + (aecm->totCount >= CONV_LEN) + (aecm->totCount >= CONV_LEN2); } // END: Determine startup state // Buffer near and far end signals memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN); - memcpy(aecm->dBufNoisy + PART_LEN, - nearendNoisy, - sizeof(int16_t) * PART_LEN); + memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN); if (nearendClean != NULL) { - memcpy(aecm->dBufClean + PART_LEN, - nearendClean, + memcpy(aecm->dBufClean + PART_LEN, nearendClean, sizeof(int16_t) * PART_LEN); } // Transform far end signal from time domain to frequency domain. - far_q = TimeToFrequencyDomain(aecm, - aecm->xBuf, - dfw, - xfa, - &xfaSum); + far_q = TimeToFrequencyDomain(aecm, aecm->xBuf, dfw, xfa, &xfaSum); // Transform noisy near end signal from time domain to frequency domain. - zerosDBufNoisy = TimeToFrequencyDomain(aecm, - aecm->dBufNoisy, - dfw, - dfaNoisy, - &dfaNoisySum); + zerosDBufNoisy = + TimeToFrequencyDomain(aecm, aecm->dBufNoisy, dfw, dfaNoisy, &dfaNoisySum); aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain; aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy; @@ -895,10 +1014,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, dfaCleanSum = dfaNoisySum; } else { // Transform clean near end signal from time domain to frequency domain. - zerosDBufClean = TimeToFrequencyDomain(aecm, - aecm->dBufClean, - dfw, - dfaClean, + zerosDBufClean = TimeToFrequencyDomain(aecm, aecm->dBufClean, dfw, dfaClean, &dfaCleanSum); aecm->dfaCleanQDomainOld = aecm->dfaCleanQDomain; aecm->dfaCleanQDomain = (int16_t)zerosDBufClean; @@ -912,14 +1028,11 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, far_q) == -1) { return -1; } - delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator, - dfaNoisy, - PART_LEN1, - zerosDBufNoisy); + delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator, dfaNoisy, + PART_LEN1, zerosDBufNoisy); if (delay == -1) { return -1; - } - else if (delay == -2) { + } else if (delay == -2) { // If the delay is unknown, we assume zero. // NOTE: this will have to be adjusted if we ever add lookahead. delay = 0; @@ -932,17 +1045,14 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, // Get aligned far end spectrum far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay); - zerosXBuf = (int16_t) far_q; + zerosXBuf = (int16_t)far_q; if (far_spectrum_ptr == NULL) { return -1; } // Calculate log(energy) and update energy threshold levels - WebRtcAecm_CalcEnergies(aecm, - far_spectrum_ptr, - zerosXBuf, - dfaNoisySum, + WebRtcAecm_CalcEnergies(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisySum, echoEst32); // Calculate stepsize mu = WebRtcAecm_CalcStepSize(aecm); @@ -953,11 +1063,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, // This is the channel estimation algorithm. // It is base on NLMS but has a variable step length, // which was calculated above. - WebRtcAecm_UpdateChannel(aecm, - far_spectrum_ptr, - zerosXBuf, - dfaNoisy, - mu, + WebRtcAecm_UpdateChannel(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisy, mu, echoEst32); supGain = WebRtcAecm_CalcSuppressionGain(aecm); @@ -976,19 +1082,18 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, // Multiplication is safe // Result in // Q(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN+aecm->xfaQDomainBuf[diff]) - echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], - (uint16_t)supGain); + echoEst32Gained = + WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], (uint16_t)supGain); resolutionDiff = 14 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN; resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf); } else { tmp16no1 = 17 - zeros32 - zeros16; - resolutionDiff = 14 + tmp16no1 - RESOLUTION_CHANNEL16 - - RESOLUTION_SUPGAIN; + resolutionDiff = + 14 + tmp16no1 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN; resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf); if (zeros32 > tmp16no1) { - echoEst32Gained = WEBRTC_SPL_UMUL_32_16( - (uint32_t)aecm->echoFilt[i], - supGain >> tmp16no1); + echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], + supGain >> tmp16no1); } else { // Result in Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN-16) echoEst32Gained = (aecm->echoFilt[i] >> tmp16no1) * supGain; @@ -1004,8 +1109,8 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, tmp16no2 = ptrDfaClean[i] >> -qDomainDiff; } else { tmp16no1 = dfa_clean_q_domain_diff < 0 - ? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff - : aecm->nearFilt[i] << dfa_clean_q_domain_diff; + ? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff + : aecm->nearFilt[i] << dfa_clean_q_domain_diff; qDomainDiff = 0; tmp16no2 = ptrDfaClean[i]; } @@ -1017,8 +1122,8 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, if ((tmp16no2) & (-qDomainDiff > zeros16)) { aecm->nearFilt[i] = WEBRTC_SPL_WORD16_MAX; } else { - aecm->nearFilt[i] = qDomainDiff < 0 ? tmp16no2 << -qDomainDiff - : tmp16no2 >> qDomainDiff; + aecm->nearFilt[i] = + qDomainDiff < 0 ? tmp16no2 << -qDomainDiff : tmp16no2 >> qDomainDiff; } // Wiener filter coefficients, resulting hnl in Q14 @@ -1031,8 +1136,8 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, // Multiply the suppression gain // Rounding echoEst32Gained += (uint32_t)(aecm->nearFilt[i] >> 1); - tmpU32 = WebRtcSpl_DivU32U16(echoEst32Gained, - (uint16_t)aecm->nearFilt[i]); + tmpU32 = + WebRtcSpl_DivU32U16(echoEst32Gained, (uint16_t)aecm->nearFilt[i]); // Current resolution is // Q-(RESOLUTION_CHANNEL + RESOLUTION_SUPGAIN @@ -1062,58 +1167,56 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, // TODO(bjornv): Investigate if the scaling of hnl[i] below can cause // speech distortion in double-talk. for (i = 0; i < (PART_LEN1 >> 3); i++) { - __asm __volatile ( - "lh %[temp1], 0(%[ptr1]) \n\t" - "lh %[temp2], 2(%[ptr1]) \n\t" - "lh %[temp3], 4(%[ptr1]) \n\t" - "lh %[temp4], 6(%[ptr1]) \n\t" - "lh %[temp5], 8(%[ptr1]) \n\t" - "lh %[temp6], 10(%[ptr1]) \n\t" - "lh %[temp7], 12(%[ptr1]) \n\t" - "lh %[temp8], 14(%[ptr1]) \n\t" - "mul %[temp1], %[temp1], %[temp1] \n\t" - "mul %[temp2], %[temp2], %[temp2] \n\t" - "mul %[temp3], %[temp3], %[temp3] \n\t" - "mul %[temp4], %[temp4], %[temp4] \n\t" - "mul %[temp5], %[temp5], %[temp5] \n\t" - "mul %[temp6], %[temp6], %[temp6] \n\t" - "mul %[temp7], %[temp7], %[temp7] \n\t" - "mul %[temp8], %[temp8], %[temp8] \n\t" - "sra %[temp1], %[temp1], 14 \n\t" - "sra %[temp2], %[temp2], 14 \n\t" - "sra %[temp3], %[temp3], 14 \n\t" - "sra %[temp4], %[temp4], 14 \n\t" - "sra %[temp5], %[temp5], 14 \n\t" - "sra %[temp6], %[temp6], 14 \n\t" - "sra %[temp7], %[temp7], 14 \n\t" - "sra %[temp8], %[temp8], 14 \n\t" - "sh %[temp1], 0(%[ptr1]) \n\t" - "sh %[temp2], 2(%[ptr1]) \n\t" - "sh %[temp3], 4(%[ptr1]) \n\t" - "sh %[temp4], 6(%[ptr1]) \n\t" - "sh %[temp5], 8(%[ptr1]) \n\t" - "sh %[temp6], 10(%[ptr1]) \n\t" - "sh %[temp7], 12(%[ptr1]) \n\t" - "sh %[temp8], 14(%[ptr1]) \n\t" - "addiu %[ptr1], %[ptr1], 16 \n\t" - : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3), - [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [temp6] "=&r" (temp6), - [temp7] "=&r" (temp7), [temp8] "=&r" (temp8), [ptr1] "+r" (ptr1) - : - : "memory", "hi", "lo" - ); + __asm __volatile( + "lh %[temp1], 0(%[ptr1]) \n\t" + "lh %[temp2], 2(%[ptr1]) \n\t" + "lh %[temp3], 4(%[ptr1]) \n\t" + "lh %[temp4], 6(%[ptr1]) \n\t" + "lh %[temp5], 8(%[ptr1]) \n\t" + "lh %[temp6], 10(%[ptr1]) \n\t" + "lh %[temp7], 12(%[ptr1]) \n\t" + "lh %[temp8], 14(%[ptr1]) \n\t" + "mul %[temp1], %[temp1], %[temp1] \n\t" + "mul %[temp2], %[temp2], %[temp2] \n\t" + "mul %[temp3], %[temp3], %[temp3] \n\t" + "mul %[temp4], %[temp4], %[temp4] \n\t" + "mul %[temp5], %[temp5], %[temp5] \n\t" + "mul %[temp6], %[temp6], %[temp6] \n\t" + "mul %[temp7], %[temp7], %[temp7] \n\t" + "mul %[temp8], %[temp8], %[temp8] \n\t" + "sra %[temp1], %[temp1], 14 \n\t" + "sra %[temp2], %[temp2], 14 \n\t" + "sra %[temp3], %[temp3], 14 \n\t" + "sra %[temp4], %[temp4], 14 \n\t" + "sra %[temp5], %[temp5], 14 \n\t" + "sra %[temp6], %[temp6], 14 \n\t" + "sra %[temp7], %[temp7], 14 \n\t" + "sra %[temp8], %[temp8], 14 \n\t" + "sh %[temp1], 0(%[ptr1]) \n\t" + "sh %[temp2], 2(%[ptr1]) \n\t" + "sh %[temp3], 4(%[ptr1]) \n\t" + "sh %[temp4], 6(%[ptr1]) \n\t" + "sh %[temp5], 8(%[ptr1]) \n\t" + "sh %[temp6], 10(%[ptr1]) \n\t" + "sh %[temp7], 12(%[ptr1]) \n\t" + "sh %[temp8], 14(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3), + [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [temp6] "=&r"(temp6), + [temp7] "=&r"(temp7), [temp8] "=&r"(temp8), [ptr1] "+r"(ptr1) + : + : "memory", "hi", "lo"); } - for(i = 0; i < (PART_LEN1 & 7); i++) { - __asm __volatile ( - "lh %[temp1], 0(%[ptr1]) \n\t" - "mul %[temp1], %[temp1], %[temp1] \n\t" - "sra %[temp1], %[temp1], 14 \n\t" - "sh %[temp1], 0(%[ptr1]) \n\t" - "addiu %[ptr1], %[ptr1], 2 \n\t" - : [temp1] "=&r" (temp1), [ptr1] "+r" (ptr1) - : - : "memory", "hi", "lo" - ); + for (i = 0; i < (PART_LEN1 & 7); i++) { + __asm __volatile( + "lh %[temp1], 0(%[ptr1]) \n\t" + "mul %[temp1], %[temp1], %[temp1] \n\t" + "sra %[temp1], %[temp1], 14 \n\t" + "sh %[temp1], 0(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 2 \n\t" + : [temp1] "=&r"(temp1), [ptr1] "+r"(ptr1) + : + : "memory", "hi", "lo"); } for (i = kMinPrefBand; i <= kMaxPrefBand; i++) { @@ -1141,102 +1244,95 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm, } else { for (i = 0; i < PART_LEN1; i++) { #if defined(MIPS_DSP_R1_LE) - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "lh %[temp1], 0(%[ptr]) \n\t" - "lh %[temp2], 0(%[dr_ptr]) \n\t" - "slti %[temp4], %[temp1], 0x4001 \n\t" - "beqz %[temp4], 3f \n\t" - " lh %[temp3], 2(%[dr_ptr]) \n\t" - "slti %[temp5], %[temp1], 3277 \n\t" - "bnez %[temp5], 2f \n\t" - " addiu %[dr_ptr], %[dr_ptr], 4 \n\t" - "mul %[temp2], %[temp2], %[temp1] \n\t" - "mul %[temp3], %[temp3], %[temp1] \n\t" - "shra_r.w %[temp2], %[temp2], 14 \n\t" - "shra_r.w %[temp3], %[temp3], 14 \n\t" - "b 4f \n\t" - " nop \n\t" - "2: \n\t" - "addu %[temp1], $zero, $zero \n\t" - "addu %[temp2], $zero, $zero \n\t" - "addu %[temp3], $zero, $zero \n\t" - "b 1f \n\t" - " nop \n\t" - "3: \n\t" - "addiu %[temp1], $0, 0x4000 \n\t" - "1: \n\t" - "sh %[temp1], 0(%[ptr]) \n\t" - "4: \n\t" - "sh %[temp2], 0(%[er_ptr]) \n\t" - "sh %[temp3], 2(%[er_ptr]) \n\t" - "addiu %[ptr], %[ptr], 2 \n\t" - "addiu %[er_ptr], %[er_ptr], 4 \n\t" - ".set pop \n\t" - : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3), - [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [ptr] "+r" (ptr), - [er_ptr] "+r" (er_ptr), [dr_ptr] "+r" (dr_ptr) - : - : "memory", "hi", "lo" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "lh %[temp1], 0(%[ptr]) \n\t" + "lh %[temp2], 0(%[dr_ptr]) \n\t" + "slti %[temp4], %[temp1], 0x4001 \n\t" + "beqz %[temp4], 3f \n\t" + " lh %[temp3], 2(%[dr_ptr]) \n\t" + "slti %[temp5], %[temp1], 3277 \n\t" + "bnez %[temp5], 2f \n\t" + " addiu %[dr_ptr], %[dr_ptr], 4 \n\t" + "mul %[temp2], %[temp2], %[temp1] \n\t" + "mul %[temp3], %[temp3], %[temp1] \n\t" + "shra_r.w %[temp2], %[temp2], 14 \n\t" + "shra_r.w %[temp3], %[temp3], 14 \n\t" + "b 4f \n\t" + " nop \n\t" + "2: \n\t" + "addu %[temp1], $zero, $zero \n\t" + "addu %[temp2], $zero, $zero \n\t" + "addu %[temp3], $zero, $zero \n\t" + "b 1f \n\t" + " nop \n\t" + "3: \n\t" + "addiu %[temp1], $0, 0x4000 \n\t" + "1: \n\t" + "sh %[temp1], 0(%[ptr]) \n\t" + "4: \n\t" + "sh %[temp2], 0(%[er_ptr]) \n\t" + "sh %[temp3], 2(%[er_ptr]) \n\t" + "addiu %[ptr], %[ptr], 2 \n\t" + "addiu %[er_ptr], %[er_ptr], 4 \n\t" + ".set pop \n\t" + : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3), + [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [ptr] "+r"(ptr), + [er_ptr] "+r"(er_ptr), [dr_ptr] "+r"(dr_ptr) + : + : "memory", "hi", "lo"); #else - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "lh %[temp1], 0(%[ptr]) \n\t" - "lh %[temp2], 0(%[dr_ptr]) \n\t" - "slti %[temp4], %[temp1], 0x4001 \n\t" - "beqz %[temp4], 3f \n\t" - " lh %[temp3], 2(%[dr_ptr]) \n\t" - "slti %[temp5], %[temp1], 3277 \n\t" - "bnez %[temp5], 2f \n\t" - " addiu %[dr_ptr], %[dr_ptr], 4 \n\t" - "mul %[temp2], %[temp2], %[temp1] \n\t" - "mul %[temp3], %[temp3], %[temp1] \n\t" - "addiu %[temp2], %[temp2], 0x2000 \n\t" - "addiu %[temp3], %[temp3], 0x2000 \n\t" - "sra %[temp2], %[temp2], 14 \n\t" - "sra %[temp3], %[temp3], 14 \n\t" - "b 4f \n\t" - " nop \n\t" - "2: \n\t" - "addu %[temp1], $zero, $zero \n\t" - "addu %[temp2], $zero, $zero \n\t" - "addu %[temp3], $zero, $zero \n\t" - "b 1f \n\t" - " nop \n\t" - "3: \n\t" - "addiu %[temp1], $0, 0x4000 \n\t" - "1: \n\t" - "sh %[temp1], 0(%[ptr]) \n\t" - "4: \n\t" - "sh %[temp2], 0(%[er_ptr]) \n\t" - "sh %[temp3], 2(%[er_ptr]) \n\t" - "addiu %[ptr], %[ptr], 2 \n\t" - "addiu %[er_ptr], %[er_ptr], 4 \n\t" - ".set pop \n\t" - : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3), - [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [ptr] "+r" (ptr), - [er_ptr] "+r" (er_ptr), [dr_ptr] "+r" (dr_ptr) - : - : "memory", "hi", "lo" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "lh %[temp1], 0(%[ptr]) \n\t" + "lh %[temp2], 0(%[dr_ptr]) \n\t" + "slti %[temp4], %[temp1], 0x4001 \n\t" + "beqz %[temp4], 3f \n\t" + " lh %[temp3], 2(%[dr_ptr]) \n\t" + "slti %[temp5], %[temp1], 3277 \n\t" + "bnez %[temp5], 2f \n\t" + " addiu %[dr_ptr], %[dr_ptr], 4 \n\t" + "mul %[temp2], %[temp2], %[temp1] \n\t" + "mul %[temp3], %[temp3], %[temp1] \n\t" + "addiu %[temp2], %[temp2], 0x2000 \n\t" + "addiu %[temp3], %[temp3], 0x2000 \n\t" + "sra %[temp2], %[temp2], 14 \n\t" + "sra %[temp3], %[temp3], 14 \n\t" + "b 4f \n\t" + " nop \n\t" + "2: \n\t" + "addu %[temp1], $zero, $zero \n\t" + "addu %[temp2], $zero, $zero \n\t" + "addu %[temp3], $zero, $zero \n\t" + "b 1f \n\t" + " nop \n\t" + "3: \n\t" + "addiu %[temp1], $0, 0x4000 \n\t" + "1: \n\t" + "sh %[temp1], 0(%[ptr]) \n\t" + "4: \n\t" + "sh %[temp2], 0(%[er_ptr]) \n\t" + "sh %[temp3], 2(%[er_ptr]) \n\t" + "addiu %[ptr], %[ptr], 2 \n\t" + "addiu %[er_ptr], %[er_ptr], 4 \n\t" + ".set pop \n\t" + : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3), + [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [ptr] "+r"(ptr), + [er_ptr] "+r"(er_ptr), [dr_ptr] "+r"(dr_ptr) + : + : "memory", "hi", "lo"); #endif } } - } - else { + } else { // multiply with Wiener coefficients for (i = 0; i < PART_LEN1; i++) { - efw[i].real = (int16_t) - (WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, - hnl[i], - 14)); - efw[i].imag = (int16_t) - (WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, - hnl[i], - 14)); + efw[i].real = (int16_t)( + WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, hnl[i], 14)); + efw[i].imag = (int16_t)( + WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, hnl[i], 14)); } } @@ -1284,26 +1380,25 @@ static void ComfortNoise(AecmCore* aecm, // Generate a uniform random array on [0 2^15-1]. WebRtcSpl_RandUArray(randW16, PART_LEN, &aecm->seed); int16_t* randW16p = (int16_t*)randW16; -#if defined (MIPS_DSP_R1_LE) +#if defined(MIPS_DSP_R1_LE) int16_t* kCosTablep = (int16_t*)WebRtcAecm_kCosTable; int16_t* kSinTablep = (int16_t*)WebRtcAecm_kSinTable; -#endif // #if defined(MIPS_DSP_R1_LE) +#endif // #if defined(MIPS_DSP_R1_LE) tmp1 = (int32_t*)aecm->noiseEst + 1; dfap = (int16_t*)dfa + 1; lambdap = (int16_t*)lambda + 1; // Estimate noise power. - for (i = 1; i < PART_LEN1; i+=2) { - // Shift to the noise domain. - __asm __volatile ( - "lh %[tmp32], 0(%[dfap]) \n\t" - "lw %[tnoise], 0(%[tmp1]) \n\t" - "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t" - : [tmp32] "=&r" (tmp32), [outLShift32] "=r" (outLShift32), - [tnoise] "=&r" (tnoise) - : [tmp1] "r" (tmp1), [dfap] "r" (dfap), - [shiftFromNearToNoise] "r" (shiftFromNearToNoise) - : "memory" - ); + for (i = 1; i < PART_LEN1; i += 2) { + // Shift to the noise domain. + __asm __volatile( + "lh %[tmp32], 0(%[dfap]) \n\t" + "lw %[tnoise], 0(%[tmp1]) \n\t" + "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t" + : [tmp32] "=&r"(tmp32), [outLShift32] "=r"(outLShift32), + [tnoise] "=&r"(tnoise) + : [tmp1] "r"(tmp1), [dfap] "r"(dfap), + [shiftFromNearToNoise] "r"(shiftFromNearToNoise) + : "memory"); if (outLShift32 < tnoise) { // Reset "too low" counter @@ -1319,13 +1414,13 @@ static void ComfortNoise(AecmCore* aecm, aecm->noiseEstTooHighCtr[i] = 0; // Reset the counter } } else { - __asm __volatile ( - "subu %[tmp32], %[tnoise], %[outLShift32] \n\t" - "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t" - "subu %[tnoise], %[tnoise], %[tmp32] \n\t" - : [tmp32] "=&r" (tmp32), [tnoise] "+r" (tnoise) - : [outLShift32] "r" (outLShift32), [minTrackShift] "r" (minTrackShift) - ); + __asm __volatile( + "subu %[tmp32], %[tnoise], %[outLShift32] \n\t" + "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t" + "subu %[tnoise], %[tnoise], %[tmp32] \n\t" + : [tmp32] "=&r"(tmp32), [tnoise] "+r"(tnoise) + : + [outLShift32] "r"(outLShift32), [minTrackShift] "r"(minTrackShift)); } } else { // Reset "too high" counter @@ -1334,53 +1429,49 @@ static void ComfortNoise(AecmCore* aecm, if ((tnoise >> 19) <= 0) { if ((tnoise >> 11) > 0) { // Large enough for relative increase - __asm __volatile ( - "mul %[tnoise], %[tnoise], %[c2049] \n\t" - "sra %[tnoise], %[tnoise], 11 \n\t" - : [tnoise] "+r" (tnoise) - : [c2049] "r" (c2049) - : "hi", "lo" - ); + __asm __volatile( + "mul %[tnoise], %[tnoise], %[c2049] \n\t" + "sra %[tnoise], %[tnoise], 11 \n\t" + : [tnoise] "+r"(tnoise) + : [c2049] "r"(c2049) + : "hi", "lo"); } else { // Make incremental increases based on size every // |kNoiseEstIncCount| block aecm->noiseEstTooLowCtr[i]++; if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) { - __asm __volatile ( - "sra %[tmp32], %[tnoise], 9 \n\t" - "addi %[tnoise], %[tnoise], 1 \n\t" - "addu %[tnoise], %[tnoise], %[tmp32] \n\t" - : [tnoise] "+r" (tnoise), [tmp32] "=&r" (tmp32) - : - ); - aecm->noiseEstTooLowCtr[i] = 0; // Reset counter + __asm __volatile( + "sra %[tmp32], %[tnoise], 9 \n\t" + "addi %[tnoise], %[tnoise], 1 \n\t" + "addu %[tnoise], %[tnoise], %[tmp32] \n\t" + : [tnoise] "+r"(tnoise), [tmp32] "=&r"(tmp32) + :); + aecm->noiseEstTooLowCtr[i] = 0; // Reset counter } } } else { // Avoid overflow. // Multiplication with 2049 will cause wrap around. Scale // down first and then multiply - __asm __volatile ( - "sra %[tnoise], %[tnoise], 11 \n\t" - "mul %[tnoise], %[tnoise], %[c2049] \n\t" - : [tnoise] "+r" (tnoise) - : [c2049] "r" (c2049) - : "hi", "lo" - ); + __asm __volatile( + "sra %[tnoise], %[tnoise], 11 \n\t" + "mul %[tnoise], %[tnoise], %[c2049] \n\t" + : [tnoise] "+r"(tnoise) + : [c2049] "r"(c2049) + : "hi", "lo"); } } // Shift to the noise domain. - __asm __volatile ( - "lh %[tmp32], 2(%[dfap]) \n\t" - "lw %[tnoise1], 4(%[tmp1]) \n\t" - "addiu %[dfap], %[dfap], 4 \n\t" - "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t" - : [tmp32] "=&r" (tmp32), [dfap] "+r" (dfap), - [outLShift32] "=r" (outLShift32), [tnoise1] "=&r" (tnoise1) - : [tmp1] "r" (tmp1), [shiftFromNearToNoise] "r" (shiftFromNearToNoise) - : "memory" - ); + __asm __volatile( + "lh %[tmp32], 2(%[dfap]) \n\t" + "lw %[tnoise1], 4(%[tmp1]) \n\t" + "addiu %[dfap], %[dfap], 4 \n\t" + "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t" + : [tmp32] "=&r"(tmp32), [dfap] "+r"(dfap), + [outLShift32] "=r"(outLShift32), [tnoise1] "=&r"(tnoise1) + : [tmp1] "r"(tmp1), [shiftFromNearToNoise] "r"(shiftFromNearToNoise) + : "memory"); if (outLShift32 < tnoise1) { // Reset "too low" counter @@ -1393,16 +1484,16 @@ static void ComfortNoise(AecmCore* aecm, aecm->noiseEstTooHighCtr[i + 1]++; if (aecm->noiseEstTooHighCtr[i + 1] >= kNoiseEstIncCount) { tnoise1--; - aecm->noiseEstTooHighCtr[i + 1] = 0; // Reset the counter + aecm->noiseEstTooHighCtr[i + 1] = 0; // Reset the counter } } else { - __asm __volatile ( - "subu %[tmp32], %[tnoise1], %[outLShift32] \n\t" - "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t" - "subu %[tnoise1], %[tnoise1], %[tmp32] \n\t" - : [tmp32] "=&r" (tmp32), [tnoise1] "+r" (tnoise1) - : [outLShift32] "r" (outLShift32), [minTrackShift] "r" (minTrackShift) - ); + __asm __volatile( + "subu %[tmp32], %[tnoise1], %[outLShift32] \n\t" + "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t" + "subu %[tnoise1], %[tnoise1], %[tmp32] \n\t" + : [tmp32] "=&r"(tmp32), [tnoise1] "+r"(tnoise1) + : + [outLShift32] "r"(outLShift32), [minTrackShift] "r"(minTrackShift)); } } else { // Reset "too high" counter @@ -1411,59 +1502,55 @@ static void ComfortNoise(AecmCore* aecm, if ((tnoise1 >> 19) <= 0) { if ((tnoise1 >> 11) > 0) { // Large enough for relative increase - __asm __volatile ( - "mul %[tnoise1], %[tnoise1], %[c2049] \n\t" - "sra %[tnoise1], %[tnoise1], 11 \n\t" - : [tnoise1] "+r" (tnoise1) - : [c2049] "r" (c2049) - : "hi", "lo" - ); + __asm __volatile( + "mul %[tnoise1], %[tnoise1], %[c2049] \n\t" + "sra %[tnoise1], %[tnoise1], 11 \n\t" + : [tnoise1] "+r"(tnoise1) + : [c2049] "r"(c2049) + : "hi", "lo"); } else { // Make incremental increases based on size every // |kNoiseEstIncCount| block aecm->noiseEstTooLowCtr[i + 1]++; if (aecm->noiseEstTooLowCtr[i + 1] >= kNoiseEstIncCount) { - __asm __volatile ( - "sra %[tmp32], %[tnoise1], 9 \n\t" - "addi %[tnoise1], %[tnoise1], 1 \n\t" - "addu %[tnoise1], %[tnoise1], %[tmp32] \n\t" - : [tnoise1] "+r" (tnoise1), [tmp32] "=&r" (tmp32) - : - ); - aecm->noiseEstTooLowCtr[i + 1] = 0; // Reset counter + __asm __volatile( + "sra %[tmp32], %[tnoise1], 9 \n\t" + "addi %[tnoise1], %[tnoise1], 1 \n\t" + "addu %[tnoise1], %[tnoise1], %[tmp32] \n\t" + : [tnoise1] "+r"(tnoise1), [tmp32] "=&r"(tmp32) + :); + aecm->noiseEstTooLowCtr[i + 1] = 0; // Reset counter } } } else { // Avoid overflow. // Multiplication with 2049 will cause wrap around. Scale // down first and then multiply - __asm __volatile ( - "sra %[tnoise1], %[tnoise1], 11 \n\t" - "mul %[tnoise1], %[tnoise1], %[c2049] \n\t" - : [tnoise1] "+r" (tnoise1) - : [c2049] "r" (c2049) - : "hi", "lo" - ); + __asm __volatile( + "sra %[tnoise1], %[tnoise1], 11 \n\t" + "mul %[tnoise1], %[tnoise1], %[c2049] \n\t" + : [tnoise1] "+r"(tnoise1) + : [c2049] "r"(c2049) + : "hi", "lo"); } } - __asm __volatile ( - "lh %[tmp16], 0(%[lambdap]) \n\t" - "lh %[tmp161], 2(%[lambdap]) \n\t" - "sw %[tnoise], 0(%[tmp1]) \n\t" - "sw %[tnoise1], 4(%[tmp1]) \n\t" - "subu %[tmp16], %[c114], %[tmp16] \n\t" - "subu %[tmp161], %[c114], %[tmp161] \n\t" - "srav %[tmp32], %[tnoise], %[shiftFromNearToNoise] \n\t" - "srav %[tmp321], %[tnoise1], %[shiftFromNearToNoise] \n\t" - "addiu %[lambdap], %[lambdap], 4 \n\t" - "addiu %[tmp1], %[tmp1], 8 \n\t" - : [tmp16] "=&r" (tmp16), [tmp161] "=&r" (tmp161), [tmp1] "+r" (tmp1), - [tmp32] "=&r" (tmp32), [tmp321] "=&r" (tmp321), [lambdap] "+r" (lambdap) - : [tnoise] "r" (tnoise), [tnoise1] "r" (tnoise1), [c114] "r" (c114), - [shiftFromNearToNoise] "r" (shiftFromNearToNoise) - : "memory" - ); + __asm __volatile( + "lh %[tmp16], 0(%[lambdap]) \n\t" + "lh %[tmp161], 2(%[lambdap]) \n\t" + "sw %[tnoise], 0(%[tmp1]) \n\t" + "sw %[tnoise1], 4(%[tmp1]) \n\t" + "subu %[tmp16], %[c114], %[tmp16] \n\t" + "subu %[tmp161], %[c114], %[tmp161] \n\t" + "srav %[tmp32], %[tnoise], %[shiftFromNearToNoise] \n\t" + "srav %[tmp321], %[tnoise1], %[shiftFromNearToNoise] \n\t" + "addiu %[lambdap], %[lambdap], 4 \n\t" + "addiu %[tmp1], %[tmp1], 8 \n\t" + : [tmp16] "=&r"(tmp16), [tmp161] "=&r"(tmp161), [tmp1] "+r"(tmp1), + [tmp32] "=&r"(tmp32), [tmp321] "=&r"(tmp321), [lambdap] "+r"(lambdap) + : [tnoise] "r"(tnoise), [tnoise1] "r"(tnoise1), [c114] "r"(c114), + [shiftFromNearToNoise] "r"(shiftFromNearToNoise) + : "memory"); if (tmp32 > 32767) { tmp32 = 32767; @@ -1471,33 +1558,31 @@ static void ComfortNoise(AecmCore* aecm, } if (tmp321 > 32767) { tmp321 = 32767; - aecm->noiseEst[i+1] = tmp321 << shiftFromNearToNoise; + aecm->noiseEst[i + 1] = tmp321 << shiftFromNearToNoise; } - __asm __volatile ( - "mul %[tmp32], %[tmp32], %[tmp16] \n\t" - "mul %[tmp321], %[tmp321], %[tmp161] \n\t" - "sra %[nrsh1], %[tmp32], 14 \n\t" - "sra %[nrsh2], %[tmp321], 14 \n\t" - : [nrsh1] "=&r" (nrsh1), [nrsh2] "=r" (nrsh2) - : [tmp16] "r" (tmp16), [tmp161] "r" (tmp161), [tmp32] "r" (tmp32), - [tmp321] "r" (tmp321) - : "memory", "hi", "lo" - ); + __asm __volatile( + "mul %[tmp32], %[tmp32], %[tmp16] \n\t" + "mul %[tmp321], %[tmp321], %[tmp161] \n\t" + "sra %[nrsh1], %[tmp32], 14 \n\t" + "sra %[nrsh2], %[tmp321], 14 \n\t" + : [nrsh1] "=&r"(nrsh1), [nrsh2] "=r"(nrsh2) + : [tmp16] "r"(tmp16), [tmp161] "r"(tmp161), [tmp32] "r"(tmp32), + [tmp321] "r"(tmp321) + : "memory", "hi", "lo"); - __asm __volatile ( - "lh %[tmp32], 0(%[randW16p]) \n\t" - "lh %[tmp321], 2(%[randW16p]) \n\t" - "addiu %[randW16p], %[randW16p], 4 \n\t" - "mul %[tmp32], %[tmp32], %[c359] \n\t" - "mul %[tmp321], %[tmp321], %[c359] \n\t" - "sra %[tmp16], %[tmp32], 15 \n\t" - "sra %[tmp161], %[tmp321], 15 \n\t" - : [randW16p] "+r" (randW16p), [tmp32] "=&r" (tmp32), - [tmp16] "=r" (tmp16), [tmp161] "=r" (tmp161), [tmp321] "=&r" (tmp321) - : [c359] "r" (c359) - : "memory", "hi", "lo" - ); + __asm __volatile( + "lh %[tmp32], 0(%[randW16p]) \n\t" + "lh %[tmp321], 2(%[randW16p]) \n\t" + "addiu %[randW16p], %[randW16p], 4 \n\t" + "mul %[tmp32], %[tmp32], %[c359] \n\t" + "mul %[tmp321], %[tmp321], %[c359] \n\t" + "sra %[tmp16], %[tmp32], 15 \n\t" + "sra %[tmp161], %[tmp321], 15 \n\t" + : [randW16p] "+r"(randW16p), [tmp32] "=&r"(tmp32), [tmp16] "=r"(tmp16), + [tmp161] "=r"(tmp161), [tmp321] "=&r"(tmp321) + : [c359] "r"(c359) + : "memory", "hi", "lo"); #if !defined(MIPS_DSP_R1_LE) tmp32 = WebRtcAecm_kCosTable[tmp16]; @@ -1505,36 +1590,34 @@ static void ComfortNoise(AecmCore* aecm, tmp322 = WebRtcAecm_kCosTable[tmp161]; tmp323 = WebRtcAecm_kSinTable[tmp161]; #else - __asm __volatile ( - "sll %[tmp16], %[tmp16], 1 \n\t" - "sll %[tmp161], %[tmp161], 1 \n\t" - "lhx %[tmp32], %[tmp16](%[kCosTablep]) \n\t" - "lhx %[tmp321], %[tmp16](%[kSinTablep]) \n\t" - "lhx %[tmp322], %[tmp161](%[kCosTablep]) \n\t" - "lhx %[tmp323], %[tmp161](%[kSinTablep]) \n\t" - : [tmp32] "=&r" (tmp32), [tmp321] "=&r" (tmp321), - [tmp322] "=&r" (tmp322), [tmp323] "=&r" (tmp323) - : [kCosTablep] "r" (kCosTablep), [tmp16] "r" (tmp16), - [tmp161] "r" (tmp161), [kSinTablep] "r" (kSinTablep) - : "memory" - ); + __asm __volatile( + "sll %[tmp16], %[tmp16], 1 \n\t" + "sll %[tmp161], %[tmp161], 1 \n\t" + "lhx %[tmp32], %[tmp16](%[kCosTablep]) \n\t" + "lhx %[tmp321], %[tmp16](%[kSinTablep]) \n\t" + "lhx %[tmp322], %[tmp161](%[kCosTablep]) \n\t" + "lhx %[tmp323], %[tmp161](%[kSinTablep]) \n\t" + : [tmp32] "=&r"(tmp32), [tmp321] "=&r"(tmp321), [tmp322] "=&r"(tmp322), + [tmp323] "=&r"(tmp323) + : [kCosTablep] "r"(kCosTablep), [tmp16] "r"(tmp16), + [tmp161] "r"(tmp161), [kSinTablep] "r"(kSinTablep) + : "memory"); #endif - __asm __volatile ( - "mul %[tmp32], %[tmp32], %[nrsh1] \n\t" - "negu %[tmp162], %[nrsh1] \n\t" - "mul %[tmp322], %[tmp322], %[nrsh2] \n\t" - "negu %[tmp163], %[nrsh2] \n\t" - "sra %[tmp32], %[tmp32], 13 \n\t" - "mul %[tmp321], %[tmp321], %[tmp162] \n\t" - "sra %[tmp322], %[tmp322], 13 \n\t" - "mul %[tmp323], %[tmp323], %[tmp163] \n\t" - "sra %[tmp321], %[tmp321], 13 \n\t" - "sra %[tmp323], %[tmp323], 13 \n\t" - : [tmp32] "+r" (tmp32), [tmp321] "+r" (tmp321), [tmp162] "=&r" (tmp162), - [tmp322] "+r" (tmp322), [tmp323] "+r" (tmp323), [tmp163] "=&r" (tmp163) - : [nrsh1] "r" (nrsh1), [nrsh2] "r" (nrsh2) - : "hi", "lo" - ); + __asm __volatile( + "mul %[tmp32], %[tmp32], %[nrsh1] \n\t" + "negu %[tmp162], %[nrsh1] \n\t" + "mul %[tmp322], %[tmp322], %[nrsh2] \n\t" + "negu %[tmp163], %[nrsh2] \n\t" + "sra %[tmp32], %[tmp32], 13 \n\t" + "mul %[tmp321], %[tmp321], %[tmp162] \n\t" + "sra %[tmp322], %[tmp322], 13 \n\t" + "mul %[tmp323], %[tmp323], %[tmp163] \n\t" + "sra %[tmp321], %[tmp321], 13 \n\t" + "sra %[tmp323], %[tmp323], 13 \n\t" + : [tmp32] "+r"(tmp32), [tmp321] "+r"(tmp321), [tmp162] "=&r"(tmp162), + [tmp322] "+r"(tmp322), [tmp323] "+r"(tmp323), [tmp163] "=&r"(tmp163) + : [nrsh1] "r"(nrsh1), [nrsh2] "r"(nrsh2) + : "hi", "lo"); // Tables are in Q13. uReal[i] = (int16_t)tmp32; uImag[i] = (int16_t)tmp321; diff --git a/modules/audio_processing/aecm/aecm_core_neon.cc b/modules/audio_processing/aecm/aecm_core_neon.cc index ca7211f738..a2153a21a7 100644 --- a/modules/audio_processing/aecm/aecm_core_neon.cc +++ b/modules/audio_processing/aecm/aecm_core_neon.cc @@ -77,12 +77,12 @@ void WebRtcAecm_CalcLinearEnergiesNeon(AecmCore* aecm, echo_stored_v = vaddq_u32(echo_est_v_low, echo_stored_v); echo_stored_v = vaddq_u32(echo_est_v_high, echo_stored_v); - echo_adapt_v = vmlal_u16(echo_adapt_v, - vreinterpret_u16_s16(vget_low_s16(adapt_v)), - vget_low_u16(spectrum_v)); - echo_adapt_v = vmlal_u16(echo_adapt_v, - vreinterpret_u16_s16(vget_high_s16(adapt_v)), - vget_high_u16(spectrum_v)); + echo_adapt_v = + vmlal_u16(echo_adapt_v, vreinterpret_u16_s16(vget_low_s16(adapt_v)), + vget_low_u16(spectrum_v)); + echo_adapt_v = + vmlal_u16(echo_adapt_v, vreinterpret_u16_s16(vget_high_s16(adapt_v)), + vget_high_u16(spectrum_v)); start_stored_p += 8; start_adapt_p += 8; diff --git a/modules/audio_processing/aecm/aecm_defines.h b/modules/audio_processing/aecm/aecm_defines.h index ae2d2bc03a..5805549e2c 100644 --- a/modules/audio_processing/aecm/aecm_defines.h +++ b/modules/audio_processing/aecm/aecm_defines.h @@ -11,77 +11,77 @@ #ifndef MODULES_AUDIO_PROCESSING_AECM_AECM_DEFINES_H_ #define MODULES_AUDIO_PROCESSING_AECM_AECM_DEFINES_H_ -#define AECM_DYNAMIC_Q /* Turn on/off dynamic Q-domain. */ +#define AECM_DYNAMIC_Q /* Turn on/off dynamic Q-domain. */ /* Algorithm parameters */ -#define FRAME_LEN 80 /* Total frame length, 10 ms. */ +#define FRAME_LEN 80 /* Total frame length, 10 ms. */ -#define PART_LEN 64 /* Length of partition. */ -#define PART_LEN_SHIFT 7 /* Length of (PART_LEN * 2) in base 2. */ +#define PART_LEN 64 /* Length of partition. */ +#define PART_LEN_SHIFT 7 /* Length of (PART_LEN * 2) in base 2. */ -#define PART_LEN1 (PART_LEN + 1) /* Unique fft coefficients. */ -#define PART_LEN2 (PART_LEN << 1) /* Length of partition * 2. */ -#define PART_LEN4 (PART_LEN << 2) /* Length of partition * 4. */ -#define FAR_BUF_LEN PART_LEN4 /* Length of buffers. */ -#define MAX_DELAY 100 +#define PART_LEN1 (PART_LEN + 1) /* Unique fft coefficients. */ +#define PART_LEN2 (PART_LEN << 1) /* Length of partition * 2. */ +#define PART_LEN4 (PART_LEN << 2) /* Length of partition * 4. */ +#define FAR_BUF_LEN PART_LEN4 /* Length of buffers. */ +#define MAX_DELAY 100 /* Counter parameters */ -#define CONV_LEN 512 /* Convergence length used at startup. */ -#define CONV_LEN2 (CONV_LEN << 1) /* Used at startup. */ +#define CONV_LEN 512 /* Convergence length used at startup. */ +#define CONV_LEN2 (CONV_LEN << 1) /* Used at startup. */ /* Energy parameters */ -#define MAX_BUF_LEN 64 /* History length of energy signals. */ -#define FAR_ENERGY_MIN 1025 /* Lowest Far energy level: At least 2 */ - /* in energy. */ -#define FAR_ENERGY_DIFF 929 /* Allowed difference between max */ - /* and min. */ -#define ENERGY_DEV_OFFSET 0 /* The energy error offset in Q8. */ -#define ENERGY_DEV_TOL 400 /* The energy estimation tolerance (Q8). */ -#define FAR_ENERGY_VAD_REGION 230 /* Far VAD tolerance region. */ +#define MAX_BUF_LEN 64 /* History length of energy signals. */ +#define FAR_ENERGY_MIN 1025 /* Lowest Far energy level: At least 2 */ + /* in energy. */ +#define FAR_ENERGY_DIFF 929 /* Allowed difference between max */ + /* and min. */ +#define ENERGY_DEV_OFFSET 0 /* The energy error offset in Q8. */ +#define ENERGY_DEV_TOL 400 /* The energy estimation tolerance (Q8). */ +#define FAR_ENERGY_VAD_REGION 230 /* Far VAD tolerance region. */ /* Stepsize parameters */ -#define MU_MIN 10 /* Min stepsize 2^-MU_MIN (far end energy */ - /* dependent). */ -#define MU_MAX 1 /* Max stepsize 2^-MU_MAX (far end energy */ - /* dependent). */ -#define MU_DIFF 9 /* MU_MIN - MU_MAX */ +#define MU_MIN 10 /* Min stepsize 2^-MU_MIN (far end energy */ + /* dependent). */ +#define MU_MAX 1 /* Max stepsize 2^-MU_MAX (far end energy */ + /* dependent). */ +#define MU_DIFF 9 /* MU_MIN - MU_MAX */ /* Channel parameters */ -#define MIN_MSE_COUNT 20 /* Min number of consecutive blocks with enough */ - /* far end energy to compare channel estimates. */ -#define MIN_MSE_DIFF 29 /* The ratio between adapted and stored channel to */ - /* accept a new storage (0.8 in Q-MSE_RESOLUTION). */ -#define MSE_RESOLUTION 5 /* MSE parameter resolution. */ -#define RESOLUTION_CHANNEL16 12 /* W16 Channel in Q-RESOLUTION_CHANNEL16. */ -#define RESOLUTION_CHANNEL32 28 /* W32 Channel in Q-RESOLUTION_CHANNEL. */ -#define CHANNEL_VAD 16 /* Minimum energy in frequency band */ - /* to update channel. */ +#define MIN_MSE_COUNT 20 /* Min number of consecutive blocks with enough */ + /* far end energy to compare channel estimates. */ +#define MIN_MSE_DIFF 29 /* The ratio between adapted and stored channel to */ + /* accept a new storage (0.8 in Q-MSE_RESOLUTION). */ +#define MSE_RESOLUTION 5 /* MSE parameter resolution. */ +#define RESOLUTION_CHANNEL16 12 /* W16 Channel in Q-RESOLUTION_CHANNEL16. */ +#define RESOLUTION_CHANNEL32 28 /* W32 Channel in Q-RESOLUTION_CHANNEL. */ +#define CHANNEL_VAD 16 /* Minimum energy in frequency band */ + /* to update channel. */ /* Suppression gain parameters: SUPGAIN parameters in Q-(RESOLUTION_SUPGAIN). */ -#define RESOLUTION_SUPGAIN 8 /* Channel in Q-(RESOLUTION_SUPGAIN). */ -#define SUPGAIN_DEFAULT (1 << RESOLUTION_SUPGAIN) /* Default. */ -#define SUPGAIN_ERROR_PARAM_A 3072 /* Estimation error parameter */ - /* (Maximum gain) (8 in Q8). */ -#define SUPGAIN_ERROR_PARAM_B 1536 /* Estimation error parameter */ - /* (Gain before going down). */ -#define SUPGAIN_ERROR_PARAM_D SUPGAIN_DEFAULT /* Estimation error parameter */ - /* (Should be the same as Default) (1 in Q8). */ -#define SUPGAIN_EPC_DT 200 /* SUPGAIN_ERROR_PARAM_C * ENERGY_DEV_TOL */ +#define RESOLUTION_SUPGAIN 8 /* Channel in Q-(RESOLUTION_SUPGAIN). */ +#define SUPGAIN_DEFAULT (1 << RESOLUTION_SUPGAIN) /* Default. */ +#define SUPGAIN_ERROR_PARAM_A 3072 /* Estimation error parameter */ + /* (Maximum gain) (8 in Q8). */ +#define SUPGAIN_ERROR_PARAM_B 1536 /* Estimation error parameter */ + /* (Gain before going down). */ +#define SUPGAIN_ERROR_PARAM_D SUPGAIN_DEFAULT /* Estimation error parameter */ +/* (Should be the same as Default) (1 in Q8). */ +#define SUPGAIN_EPC_DT 200 /* SUPGAIN_ERROR_PARAM_C * ENERGY_DEV_TOL */ /* Defines for "check delay estimation" */ -#define CORR_WIDTH 31 /* Number of samples to correlate over. */ -#define CORR_MAX 16 /* Maximum correlation offset. */ -#define CORR_MAX_BUF 63 -#define CORR_DEV 4 -#define CORR_MAX_LEVEL 20 -#define CORR_MAX_LOW 4 -#define CORR_BUF_LEN (CORR_MAX << 1) + 1 +#define CORR_WIDTH 31 /* Number of samples to correlate over. */ +#define CORR_MAX 16 /* Maximum correlation offset. */ +#define CORR_MAX_BUF 63 +#define CORR_DEV 4 +#define CORR_MAX_LEVEL 20 +#define CORR_MAX_LOW 4 +#define CORR_BUF_LEN (CORR_MAX << 1) + 1 /* Note that CORR_WIDTH + 2*CORR_MAX <= MAX_BUF_LEN. */ -#define ONE_Q14 (1 << 14) +#define ONE_Q14 (1 << 14) /* NLP defines */ -#define NLP_COMP_LOW 3277 /* 0.2 in Q14 */ -#define NLP_COMP_HIGH ONE_Q14 /* 1 in Q14 */ +#define NLP_COMP_LOW 3277 /* 0.2 in Q14 */ +#define NLP_COMP_HIGH ONE_Q14 /* 1 in Q14 */ #endif diff --git a/modules/audio_processing/aecm/echo_control_mobile.cc b/modules/audio_processing/aecm/echo_control_mobile.cc index 36e227166f..c947563b28 100644 --- a/modules/audio_processing/aecm/echo_control_mobile.cc +++ b/modules/audio_processing/aecm/echo_control_mobile.cc @@ -21,56 +21,56 @@ extern "C" { } #include "modules/audio_processing/aecm/aecm_core.h" -#define BUF_SIZE_FRAMES 50 // buffer size (frames) +#define BUF_SIZE_FRAMES 50 // buffer size (frames) // Maximum length of resampled signal. Must be an integer multiple of frames // (ceil(1/(1 + MIN_SKEW)*2) + 1)*FRAME_LEN // The factor of 2 handles wb, and the + 1 is as a safety margin #define MAX_RESAMP_LEN (5 * FRAME_LEN) -static const size_t kBufSizeSamp = BUF_SIZE_FRAMES * FRAME_LEN; // buffer size (samples) -static const int kSampMsNb = 8; // samples per ms in nb +static const size_t kBufSizeSamp = + BUF_SIZE_FRAMES * FRAME_LEN; // buffer size (samples) +static const int kSampMsNb = 8; // samples per ms in nb // Target suppression levels for nlp modes // log{0.001, 0.00001, 0.00000001} static const int kInitCheck = 42; -typedef struct -{ - int sampFreq; - int scSampFreq; - short bufSizeStart; - int knownDelay; +typedef struct { + int sampFreq; + int scSampFreq; + short bufSizeStart; + int knownDelay; - // Stores the last frame added to the farend buffer - short farendOld[2][FRAME_LEN]; - short initFlag; // indicates if AEC has been initialized + // Stores the last frame added to the farend buffer + short farendOld[2][FRAME_LEN]; + short initFlag; // indicates if AEC has been initialized - // Variables used for averaging far end buffer size - short counter; - short sum; - short firstVal; - short checkBufSizeCtr; + // Variables used for averaging far end buffer size + short counter; + short sum; + short firstVal; + short checkBufSizeCtr; - // Variables used for delay shifts - short msInSndCardBuf; - short filtDelay; - int timeForDelayChange; - int ECstartup; - int checkBuffSize; - int delayChange; - short lastDelayDiff; + // Variables used for delay shifts + short msInSndCardBuf; + short filtDelay; + int timeForDelayChange; + int ECstartup; + int checkBuffSize; + int delayChange; + short lastDelayDiff; - int16_t echoMode; + int16_t echoMode; #ifdef AEC_DEBUG - FILE *bufFile; - FILE *delayFile; - FILE *preCompFile; - FILE *postCompFile; -#endif // AEC_DEBUG - // Structures - RingBuffer *farendBuf; + FILE* bufFile; + FILE* delayFile; + FILE* preCompFile; + FILE* postCompFile; +#endif // AEC_DEBUG + // Structures + RingBuffer* farendBuf; - AecmCore* aecmCore; + AecmCore* aecmCore; } AecMobile; // Estimates delay to set the position of the farend buffer read pointer @@ -81,123 +81,117 @@ static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf); static int WebRtcAecm_DelayComp(AecMobile* aecm); void* WebRtcAecm_Create() { - AecMobile* aecm = static_cast(malloc(sizeof(AecMobile))); + AecMobile* aecm = static_cast(malloc(sizeof(AecMobile))); - WebRtcSpl_Init(); + WebRtcSpl_Init(); - aecm->aecmCore = WebRtcAecm_CreateCore(); - if (!aecm->aecmCore) { - WebRtcAecm_Free(aecm); - return NULL; - } + aecm->aecmCore = WebRtcAecm_CreateCore(); + if (!aecm->aecmCore) { + WebRtcAecm_Free(aecm); + return NULL; + } - aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp, - sizeof(int16_t)); - if (!aecm->farendBuf) - { - WebRtcAecm_Free(aecm); - return NULL; - } + aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp, sizeof(int16_t)); + if (!aecm->farendBuf) { + WebRtcAecm_Free(aecm); + return NULL; + } - aecm->initFlag = 0; + aecm->initFlag = 0; #ifdef AEC_DEBUG - aecm->aecmCore->farFile = fopen("aecFar.pcm","wb"); - aecm->aecmCore->nearFile = fopen("aecNear.pcm","wb"); - aecm->aecmCore->outFile = fopen("aecOut.pcm","wb"); - //aecm->aecmCore->outLpFile = fopen("aecOutLp.pcm","wb"); + aecm->aecmCore->farFile = fopen("aecFar.pcm", "wb"); + aecm->aecmCore->nearFile = fopen("aecNear.pcm", "wb"); + aecm->aecmCore->outFile = fopen("aecOut.pcm", "wb"); + // aecm->aecmCore->outLpFile = fopen("aecOutLp.pcm","wb"); - aecm->bufFile = fopen("aecBuf.dat", "wb"); - aecm->delayFile = fopen("aecDelay.dat", "wb"); - aecm->preCompFile = fopen("preComp.pcm", "wb"); - aecm->postCompFile = fopen("postComp.pcm", "wb"); -#endif // AEC_DEBUG - return aecm; + aecm->bufFile = fopen("aecBuf.dat", "wb"); + aecm->delayFile = fopen("aecDelay.dat", "wb"); + aecm->preCompFile = fopen("preComp.pcm", "wb"); + aecm->postCompFile = fopen("postComp.pcm", "wb"); +#endif // AEC_DEBUG + return aecm; } void WebRtcAecm_Free(void* aecmInst) { AecMobile* aecm = static_cast(aecmInst); - if (aecm == NULL) { - return; - } + if (aecm == NULL) { + return; + } #ifdef AEC_DEBUG - fclose(aecm->aecmCore->farFile); - fclose(aecm->aecmCore->nearFile); - fclose(aecm->aecmCore->outFile); - //fclose(aecm->aecmCore->outLpFile); + fclose(aecm->aecmCore->farFile); + fclose(aecm->aecmCore->nearFile); + fclose(aecm->aecmCore->outFile); + // fclose(aecm->aecmCore->outLpFile); - fclose(aecm->bufFile); - fclose(aecm->delayFile); - fclose(aecm->preCompFile); - fclose(aecm->postCompFile); -#endif // AEC_DEBUG - WebRtcAecm_FreeCore(aecm->aecmCore); - WebRtc_FreeBuffer(aecm->farendBuf); - free(aecm); + fclose(aecm->bufFile); + fclose(aecm->delayFile); + fclose(aecm->preCompFile); + fclose(aecm->postCompFile); +#endif // AEC_DEBUG + WebRtcAecm_FreeCore(aecm->aecmCore); + WebRtc_FreeBuffer(aecm->farendBuf); + free(aecm); } -int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq) -{ - AecMobile* aecm = static_cast(aecmInst); - AecmConfig aecConfig; +int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq) { + AecMobile* aecm = static_cast(aecmInst); + AecmConfig aecConfig; - if (aecm == NULL) - { - return -1; - } + if (aecm == NULL) { + return -1; + } - if (sampFreq != 8000 && sampFreq != 16000) - { - return AECM_BAD_PARAMETER_ERROR; - } - aecm->sampFreq = sampFreq; + if (sampFreq != 8000 && sampFreq != 16000) { + return AECM_BAD_PARAMETER_ERROR; + } + aecm->sampFreq = sampFreq; - // Initialize AECM core - if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) - { - return AECM_UNSPECIFIED_ERROR; - } + // Initialize AECM core + if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) { + return AECM_UNSPECIFIED_ERROR; + } - // Initialize farend buffer - WebRtc_InitBuffer(aecm->farendBuf); + // Initialize farend buffer + WebRtc_InitBuffer(aecm->farendBuf); - aecm->initFlag = kInitCheck; // indicates that initialization has been done + aecm->initFlag = kInitCheck; // indicates that initialization has been done - aecm->delayChange = 1; + aecm->delayChange = 1; - aecm->sum = 0; - aecm->counter = 0; - aecm->checkBuffSize = 1; - aecm->firstVal = 0; + aecm->sum = 0; + aecm->counter = 0; + aecm->checkBuffSize = 1; + aecm->firstVal = 0; - aecm->ECstartup = 1; - aecm->bufSizeStart = 0; - aecm->checkBufSizeCtr = 0; - aecm->filtDelay = 0; - aecm->timeForDelayChange = 0; - aecm->knownDelay = 0; - aecm->lastDelayDiff = 0; + aecm->ECstartup = 1; + aecm->bufSizeStart = 0; + aecm->checkBufSizeCtr = 0; + aecm->filtDelay = 0; + aecm->timeForDelayChange = 0; + aecm->knownDelay = 0; + aecm->lastDelayDiff = 0; - memset(&aecm->farendOld, 0, sizeof(aecm->farendOld)); + memset(&aecm->farendOld, 0, sizeof(aecm->farendOld)); - // Default settings. - aecConfig.cngMode = AecmTrue; - aecConfig.echoMode = 3; + // Default settings. + aecConfig.cngMode = AecmTrue; + aecConfig.echoMode = 3; - if (WebRtcAecm_set_config(aecm, aecConfig) == -1) - { - return AECM_UNSPECIFIED_ERROR; - } + if (WebRtcAecm_set_config(aecm, aecConfig) == -1) { + return AECM_UNSPECIFIED_ERROR; + } - return 0; + return 0; } // Returns any error that is caused when buffering the // farend signal. -int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend, - size_t nrOfSamples) { +int32_t WebRtcAecm_GetBufferFarendError(void* aecmInst, + const int16_t* farend, + size_t nrOfSamples) { AecMobile* aecm = static_cast(aecmInst); if (aecm == NULL) @@ -215,8 +209,8 @@ int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend, return 0; } - -int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, +int32_t WebRtcAecm_BufferFarend(void* aecmInst, + const int16_t* farend, size_t nrOfSamples) { AecMobile* aecm = static_cast(aecmInst); @@ -227,8 +221,7 @@ int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, return err; // TODO(unknown): Is this really a good idea? - if (!aecm->ECstartup) - { + if (!aecm->ECstartup) { WebRtcAecm_DelayComp(aecm); } @@ -237,412 +230,363 @@ int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, return 0; } -int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, - const int16_t *nearendClean, int16_t *out, - size_t nrOfSamples, int16_t msInSndCardBuf) -{ - AecMobile* aecm = static_cast(aecmInst); - int32_t retVal = 0; - size_t i; - short nmbrOfFilledBuffers; - size_t nBlocks10ms; - size_t nFrames; +int32_t WebRtcAecm_Process(void* aecmInst, + const int16_t* nearendNoisy, + const int16_t* nearendClean, + int16_t* out, + size_t nrOfSamples, + int16_t msInSndCardBuf) { + AecMobile* aecm = static_cast(aecmInst); + int32_t retVal = 0; + size_t i; + short nmbrOfFilledBuffers; + size_t nBlocks10ms; + size_t nFrames; #ifdef AEC_DEBUG - short msInAECBuf; + short msInAECBuf; #endif - if (aecm == NULL) - { + if (aecm == NULL) { + return -1; + } + + if (nearendNoisy == NULL) { + return AECM_NULL_POINTER_ERROR; + } + + if (out == NULL) { + return AECM_NULL_POINTER_ERROR; + } + + if (aecm->initFlag != kInitCheck) { + return AECM_UNINITIALIZED_ERROR; + } + + if (nrOfSamples != 80 && nrOfSamples != 160) { + return AECM_BAD_PARAMETER_ERROR; + } + + if (msInSndCardBuf < 0) { + msInSndCardBuf = 0; + retVal = AECM_BAD_PARAMETER_WARNING; + } else if (msInSndCardBuf > 500) { + msInSndCardBuf = 500; + retVal = AECM_BAD_PARAMETER_WARNING; + } + msInSndCardBuf += 10; + aecm->msInSndCardBuf = msInSndCardBuf; + + nFrames = nrOfSamples / FRAME_LEN; + nBlocks10ms = nFrames / aecm->aecmCore->mult; + + if (aecm->ECstartup) { + if (nearendClean == NULL) { + if (out != nearendNoisy) { + memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples); + } + } else if (out != nearendClean) { + memcpy(out, nearendClean, sizeof(short) * nrOfSamples); + } + + nmbrOfFilledBuffers = + (short)WebRtc_available_read(aecm->farendBuf) / FRAME_LEN; + // The AECM is in the start up mode + // AECM is disabled until the soundcard buffer and farend buffers are OK + + // Mechanism to ensure that the soundcard buffer is reasonably stable. + if (aecm->checkBuffSize) { + aecm->checkBufSizeCtr++; + // Before we fill up the far end buffer we require the amount of data on + // the sound card to be stable (+/-8 ms) compared to the first value. This + // comparison is made during the following 4 consecutive frames. If it + // seems to be stable then we start to fill up the far end buffer. + + if (aecm->counter == 0) { + aecm->firstVal = aecm->msInSndCardBuf; + aecm->sum = 0; + } + + if (abs(aecm->firstVal - aecm->msInSndCardBuf) < + WEBRTC_SPL_MAX(0.2 * aecm->msInSndCardBuf, kSampMsNb)) { + aecm->sum += aecm->msInSndCardBuf; + aecm->counter++; + } else { + aecm->counter = 0; + } + + if (aecm->counter * nBlocks10ms >= 6) { + // The farend buffer size is determined in blocks of 80 samples + // Use 75% of the average value of the soundcard buffer + aecm->bufSizeStart = WEBRTC_SPL_MIN( + (3 * aecm->sum * aecm->aecmCore->mult) / (aecm->counter * 40), + BUF_SIZE_FRAMES); + // buffersize has now been determined + aecm->checkBuffSize = 0; + } + + if (aecm->checkBufSizeCtr * nBlocks10ms > 50) { + // for really bad sound cards, don't disable echocanceller for more than + // 0.5 sec + aecm->bufSizeStart = WEBRTC_SPL_MIN( + (3 * aecm->msInSndCardBuf * aecm->aecmCore->mult) / 40, + BUF_SIZE_FRAMES); + aecm->checkBuffSize = 0; + } + } + + // if checkBuffSize changed in the if-statement above + if (!aecm->checkBuffSize) { + // soundcard buffer is now reasonably stable + // When the far end buffer is filled with approximately the same amount of + // data as the amount on the sound card we end the start up phase and + // start to cancel echoes. + + if (nmbrOfFilledBuffers == aecm->bufSizeStart) { + aecm->ECstartup = 0; // Enable the AECM + } else if (nmbrOfFilledBuffers > aecm->bufSizeStart) { + WebRtc_MoveReadPtr(aecm->farendBuf, + (int)WebRtc_available_read(aecm->farendBuf) - + (int)aecm->bufSizeStart * FRAME_LEN); + aecm->ECstartup = 0; + } + } + + } else { + // AECM is enabled + + // Note only 1 block supported for nb and 2 blocks for wb + for (i = 0; i < nFrames; i++) { + int16_t farend[FRAME_LEN]; + const int16_t* farend_ptr = NULL; + + nmbrOfFilledBuffers = + (short)WebRtc_available_read(aecm->farendBuf) / FRAME_LEN; + + // Check that there is data in the far end buffer + if (nmbrOfFilledBuffers > 0) { + // Get the next 80 samples from the farend buffer + WebRtc_ReadBuffer(aecm->farendBuf, (void**)&farend_ptr, farend, + FRAME_LEN); + + // Always store the last frame for use when we run out of data + memcpy(&(aecm->farendOld[i][0]), farend_ptr, FRAME_LEN * sizeof(short)); + } else { + // We have no data so we use the last played frame + memcpy(farend, &(aecm->farendOld[i][0]), FRAME_LEN * sizeof(short)); + farend_ptr = farend; + } + + // Call buffer delay estimator when all data is extracted, + // i,e. i = 0 for NB and i = 1 for WB + if ((i == 0 && aecm->sampFreq == 8000) || + (i == 1 && aecm->sampFreq == 16000)) { + WebRtcAecm_EstBufDelay(aecm, aecm->msInSndCardBuf); + } + + // Call the AECM + /*WebRtcAecm_ProcessFrame(aecm->aecmCore, farend, &nearend[FRAME_LEN * i], + &out[FRAME_LEN * i], aecm->knownDelay);*/ + if (WebRtcAecm_ProcessFrame( + aecm->aecmCore, farend_ptr, &nearendNoisy[FRAME_LEN * i], + (nearendClean ? &nearendClean[FRAME_LEN * i] : NULL), + &out[FRAME_LEN * i]) == -1) return -1; } - - if (nearendNoisy == NULL) - { - return AECM_NULL_POINTER_ERROR; - } - - if (out == NULL) - { - return AECM_NULL_POINTER_ERROR; - } - - if (aecm->initFlag != kInitCheck) - { - return AECM_UNINITIALIZED_ERROR; - } - - if (nrOfSamples != 80 && nrOfSamples != 160) - { - return AECM_BAD_PARAMETER_ERROR; - } - - if (msInSndCardBuf < 0) - { - msInSndCardBuf = 0; - retVal = AECM_BAD_PARAMETER_WARNING; - } else if (msInSndCardBuf > 500) - { - msInSndCardBuf = 500; - retVal = AECM_BAD_PARAMETER_WARNING; - } - msInSndCardBuf += 10; - aecm->msInSndCardBuf = msInSndCardBuf; - - nFrames = nrOfSamples / FRAME_LEN; - nBlocks10ms = nFrames / aecm->aecmCore->mult; - - if (aecm->ECstartup) - { - if (nearendClean == NULL) - { - if (out != nearendNoisy) - { - memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples); - } - } else if (out != nearendClean) - { - memcpy(out, nearendClean, sizeof(short) * nrOfSamples); - } - - nmbrOfFilledBuffers = - (short) WebRtc_available_read(aecm->farendBuf) / FRAME_LEN; - // The AECM is in the start up mode - // AECM is disabled until the soundcard buffer and farend buffers are OK - - // Mechanism to ensure that the soundcard buffer is reasonably stable. - if (aecm->checkBuffSize) - { - aecm->checkBufSizeCtr++; - // Before we fill up the far end buffer we require the amount of data on the - // sound card to be stable (+/-8 ms) compared to the first value. This - // comparison is made during the following 4 consecutive frames. If it seems - // to be stable then we start to fill up the far end buffer. - - if (aecm->counter == 0) - { - aecm->firstVal = aecm->msInSndCardBuf; - aecm->sum = 0; - } - - if (abs(aecm->firstVal - aecm->msInSndCardBuf) - < WEBRTC_SPL_MAX(0.2 * aecm->msInSndCardBuf, kSampMsNb)) - { - aecm->sum += aecm->msInSndCardBuf; - aecm->counter++; - } else - { - aecm->counter = 0; - } - - if (aecm->counter * nBlocks10ms >= 6) - { - // The farend buffer size is determined in blocks of 80 samples - // Use 75% of the average value of the soundcard buffer - aecm->bufSizeStart - = WEBRTC_SPL_MIN((3 * aecm->sum - * aecm->aecmCore->mult) / (aecm->counter * 40), BUF_SIZE_FRAMES); - // buffersize has now been determined - aecm->checkBuffSize = 0; - } - - if (aecm->checkBufSizeCtr * nBlocks10ms > 50) - { - // for really bad sound cards, don't disable echocanceller for more than 0.5 sec - aecm->bufSizeStart = WEBRTC_SPL_MIN((3 * aecm->msInSndCardBuf - * aecm->aecmCore->mult) / 40, BUF_SIZE_FRAMES); - aecm->checkBuffSize = 0; - } - } - - // if checkBuffSize changed in the if-statement above - if (!aecm->checkBuffSize) - { - // soundcard buffer is now reasonably stable - // When the far end buffer is filled with approximately the same amount of - // data as the amount on the sound card we end the start up phase and start - // to cancel echoes. - - if (nmbrOfFilledBuffers == aecm->bufSizeStart) - { - aecm->ECstartup = 0; // Enable the AECM - } else if (nmbrOfFilledBuffers > aecm->bufSizeStart) - { - WebRtc_MoveReadPtr(aecm->farendBuf, - (int) WebRtc_available_read(aecm->farendBuf) - - (int) aecm->bufSizeStart * FRAME_LEN); - aecm->ECstartup = 0; - } - } - - } else - { - // AECM is enabled - - // Note only 1 block supported for nb and 2 blocks for wb - for (i = 0; i < nFrames; i++) - { - int16_t farend[FRAME_LEN]; - const int16_t* farend_ptr = NULL; - - nmbrOfFilledBuffers = - (short) WebRtc_available_read(aecm->farendBuf) / FRAME_LEN; - - // Check that there is data in the far end buffer - if (nmbrOfFilledBuffers > 0) - { - // Get the next 80 samples from the farend buffer - WebRtc_ReadBuffer(aecm->farendBuf, (void**) &farend_ptr, farend, - FRAME_LEN); - - // Always store the last frame for use when we run out of data - memcpy(&(aecm->farendOld[i][0]), farend_ptr, - FRAME_LEN * sizeof(short)); - } else - { - // We have no data so we use the last played frame - memcpy(farend, &(aecm->farendOld[i][0]), FRAME_LEN * sizeof(short)); - farend_ptr = farend; - } - - // Call buffer delay estimator when all data is extracted, - // i,e. i = 0 for NB and i = 1 for WB - if ((i == 0 && aecm->sampFreq == 8000) || (i == 1 && aecm->sampFreq == 16000)) - { - WebRtcAecm_EstBufDelay(aecm, aecm->msInSndCardBuf); - } - - // Call the AECM - /*WebRtcAecm_ProcessFrame(aecm->aecmCore, farend, &nearend[FRAME_LEN * i], - &out[FRAME_LEN * i], aecm->knownDelay);*/ - if (WebRtcAecm_ProcessFrame(aecm->aecmCore, - farend_ptr, - &nearendNoisy[FRAME_LEN * i], - (nearendClean - ? &nearendClean[FRAME_LEN * i] - : NULL), - &out[FRAME_LEN * i]) == -1) - return -1; - } - } + } #ifdef AEC_DEBUG - msInAECBuf = (short) WebRtc_available_read(aecm->farendBuf) / - (kSampMsNb * aecm->aecmCore->mult); - fwrite(&msInAECBuf, 2, 1, aecm->bufFile); - fwrite(&(aecm->knownDelay), sizeof(aecm->knownDelay), 1, aecm->delayFile); + msInAECBuf = (short)WebRtc_available_read(aecm->farendBuf) / + (kSampMsNb * aecm->aecmCore->mult); + fwrite(&msInAECBuf, 2, 1, aecm->bufFile); + fwrite(&(aecm->knownDelay), sizeof(aecm->knownDelay), 1, aecm->delayFile); #endif - return retVal; + return retVal; } -int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config) -{ - AecMobile* aecm = static_cast(aecmInst); +int32_t WebRtcAecm_set_config(void* aecmInst, AecmConfig config) { + AecMobile* aecm = static_cast(aecmInst); - if (aecm == NULL) - { - return -1; - } + if (aecm == NULL) { + return -1; + } - if (aecm->initFlag != kInitCheck) - { - return AECM_UNINITIALIZED_ERROR; - } + if (aecm->initFlag != kInitCheck) { + return AECM_UNINITIALIZED_ERROR; + } - if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) - { - return AECM_BAD_PARAMETER_ERROR; - } - aecm->aecmCore->cngMode = config.cngMode; + if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) { + return AECM_BAD_PARAMETER_ERROR; + } + aecm->aecmCore->cngMode = config.cngMode; - if (config.echoMode < 0 || config.echoMode > 4) - { - return AECM_BAD_PARAMETER_ERROR; - } - aecm->echoMode = config.echoMode; + if (config.echoMode < 0 || config.echoMode > 4) { + return AECM_BAD_PARAMETER_ERROR; + } + aecm->echoMode = config.echoMode; - if (aecm->echoMode == 0) - { - aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 3; - aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 3; - aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 3; - aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 3; - aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 3) - - (SUPGAIN_ERROR_PARAM_B >> 3); - aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B >> 3) - - (SUPGAIN_ERROR_PARAM_D >> 3); - } else if (aecm->echoMode == 1) - { - aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 2; - aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 2; - aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 2; - aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 2; - aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 2) - - (SUPGAIN_ERROR_PARAM_B >> 2); - aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B >> 2) - - (SUPGAIN_ERROR_PARAM_D >> 2); - } else if (aecm->echoMode == 2) - { - aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 1; - aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 1; - aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 1; - aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 1; - aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 1) - - (SUPGAIN_ERROR_PARAM_B >> 1); - aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B >> 1) - - (SUPGAIN_ERROR_PARAM_D >> 1); - } else if (aecm->echoMode == 3) - { - aecm->aecmCore->supGain = SUPGAIN_DEFAULT; - aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT; - aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A; - aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D; - aecm->aecmCore->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B; - aecm->aecmCore->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D; - } else if (aecm->echoMode == 4) - { - aecm->aecmCore->supGain = SUPGAIN_DEFAULT << 1; - aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT << 1; - aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A << 1; - aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D << 1; - aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A << 1) - - (SUPGAIN_ERROR_PARAM_B << 1); - aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B << 1) - - (SUPGAIN_ERROR_PARAM_D << 1); - } + if (aecm->echoMode == 0) { + aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 3; + aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 3; + aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 3; + aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 3; + aecm->aecmCore->supGainErrParamDiffAB = + (SUPGAIN_ERROR_PARAM_A >> 3) - (SUPGAIN_ERROR_PARAM_B >> 3); + aecm->aecmCore->supGainErrParamDiffBD = + (SUPGAIN_ERROR_PARAM_B >> 3) - (SUPGAIN_ERROR_PARAM_D >> 3); + } else if (aecm->echoMode == 1) { + aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 2; + aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 2; + aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 2; + aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 2; + aecm->aecmCore->supGainErrParamDiffAB = + (SUPGAIN_ERROR_PARAM_A >> 2) - (SUPGAIN_ERROR_PARAM_B >> 2); + aecm->aecmCore->supGainErrParamDiffBD = + (SUPGAIN_ERROR_PARAM_B >> 2) - (SUPGAIN_ERROR_PARAM_D >> 2); + } else if (aecm->echoMode == 2) { + aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 1; + aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 1; + aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 1; + aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 1; + aecm->aecmCore->supGainErrParamDiffAB = + (SUPGAIN_ERROR_PARAM_A >> 1) - (SUPGAIN_ERROR_PARAM_B >> 1); + aecm->aecmCore->supGainErrParamDiffBD = + (SUPGAIN_ERROR_PARAM_B >> 1) - (SUPGAIN_ERROR_PARAM_D >> 1); + } else if (aecm->echoMode == 3) { + aecm->aecmCore->supGain = SUPGAIN_DEFAULT; + aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT; + aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A; + aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D; + aecm->aecmCore->supGainErrParamDiffAB = + SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B; + aecm->aecmCore->supGainErrParamDiffBD = + SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D; + } else if (aecm->echoMode == 4) { + aecm->aecmCore->supGain = SUPGAIN_DEFAULT << 1; + aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT << 1; + aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A << 1; + aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D << 1; + aecm->aecmCore->supGainErrParamDiffAB = + (SUPGAIN_ERROR_PARAM_A << 1) - (SUPGAIN_ERROR_PARAM_B << 1); + aecm->aecmCore->supGainErrParamDiffBD = + (SUPGAIN_ERROR_PARAM_B << 1) - (SUPGAIN_ERROR_PARAM_D << 1); + } - return 0; + return 0; } int32_t WebRtcAecm_InitEchoPath(void* aecmInst, const void* echo_path, - size_t size_bytes) -{ - AecMobile* aecm = static_cast(aecmInst); - const int16_t* echo_path_ptr = static_cast(echo_path); + size_t size_bytes) { + AecMobile* aecm = static_cast(aecmInst); + const int16_t* echo_path_ptr = static_cast(echo_path); - if (aecmInst == NULL) { - return -1; - } - if (echo_path == NULL) { - return AECM_NULL_POINTER_ERROR; - } - if (size_bytes != WebRtcAecm_echo_path_size_bytes()) - { - // Input channel size does not match the size of AECM - return AECM_BAD_PARAMETER_ERROR; - } - if (aecm->initFlag != kInitCheck) - { - return AECM_UNINITIALIZED_ERROR; - } + if (aecmInst == NULL) { + return -1; + } + if (echo_path == NULL) { + return AECM_NULL_POINTER_ERROR; + } + if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { + // Input channel size does not match the size of AECM + return AECM_BAD_PARAMETER_ERROR; + } + if (aecm->initFlag != kInitCheck) { + return AECM_UNINITIALIZED_ERROR; + } - WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr); + WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr); - return 0; + return 0; } int32_t WebRtcAecm_GetEchoPath(void* aecmInst, void* echo_path, - size_t size_bytes) -{ - AecMobile* aecm = static_cast(aecmInst); - int16_t* echo_path_ptr = static_cast(echo_path); + size_t size_bytes) { + AecMobile* aecm = static_cast(aecmInst); + int16_t* echo_path_ptr = static_cast(echo_path); - if (aecmInst == NULL) { - return -1; - } - if (echo_path == NULL) { - return AECM_NULL_POINTER_ERROR; - } - if (size_bytes != WebRtcAecm_echo_path_size_bytes()) - { - // Input channel size does not match the size of AECM - return AECM_BAD_PARAMETER_ERROR; - } - if (aecm->initFlag != kInitCheck) - { - return AECM_UNINITIALIZED_ERROR; - } + if (aecmInst == NULL) { + return -1; + } + if (echo_path == NULL) { + return AECM_NULL_POINTER_ERROR; + } + if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { + // Input channel size does not match the size of AECM + return AECM_BAD_PARAMETER_ERROR; + } + if (aecm->initFlag != kInitCheck) { + return AECM_UNINITIALIZED_ERROR; + } - memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes); - return 0; + memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes); + return 0; } -size_t WebRtcAecm_echo_path_size_bytes() -{ - return (PART_LEN1 * sizeof(int16_t)); +size_t WebRtcAecm_echo_path_size_bytes() { + return (PART_LEN1 * sizeof(int16_t)); } - static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf) { - short delayNew, nSampSndCard; - short nSampFar = (short) WebRtc_available_read(aecm->farendBuf); - short diff; + short delayNew, nSampSndCard; + short nSampFar = (short)WebRtc_available_read(aecm->farendBuf); + short diff; - nSampSndCard = msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult; + nSampSndCard = msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult; - delayNew = nSampSndCard - nSampFar; + delayNew = nSampSndCard - nSampFar; - if (delayNew < FRAME_LEN) - { - WebRtc_MoveReadPtr(aecm->farendBuf, FRAME_LEN); - delayNew += FRAME_LEN; + if (delayNew < FRAME_LEN) { + WebRtc_MoveReadPtr(aecm->farendBuf, FRAME_LEN); + delayNew += FRAME_LEN; + } + + aecm->filtDelay = + WEBRTC_SPL_MAX(0, (8 * aecm->filtDelay + 2 * delayNew) / 10); + + diff = aecm->filtDelay - aecm->knownDelay; + if (diff > 224) { + if (aecm->lastDelayDiff < 96) { + aecm->timeForDelayChange = 0; + } else { + aecm->timeForDelayChange++; } - - aecm->filtDelay = WEBRTC_SPL_MAX(0, (8 * aecm->filtDelay + 2 * delayNew) / 10); - - diff = aecm->filtDelay - aecm->knownDelay; - if (diff > 224) - { - if (aecm->lastDelayDiff < 96) - { - aecm->timeForDelayChange = 0; - } else - { - aecm->timeForDelayChange++; - } - } else if (diff < 96 && aecm->knownDelay > 0) - { - if (aecm->lastDelayDiff > 224) - { - aecm->timeForDelayChange = 0; - } else - { - aecm->timeForDelayChange++; - } - } else - { - aecm->timeForDelayChange = 0; + } else if (diff < 96 && aecm->knownDelay > 0) { + if (aecm->lastDelayDiff > 224) { + aecm->timeForDelayChange = 0; + } else { + aecm->timeForDelayChange++; } - aecm->lastDelayDiff = diff; + } else { + aecm->timeForDelayChange = 0; + } + aecm->lastDelayDiff = diff; - if (aecm->timeForDelayChange > 25) - { - aecm->knownDelay = WEBRTC_SPL_MAX((int)aecm->filtDelay - 160, 0); - } - return 0; + if (aecm->timeForDelayChange > 25) { + aecm->knownDelay = WEBRTC_SPL_MAX((int)aecm->filtDelay - 160, 0); + } + return 0; } static int WebRtcAecm_DelayComp(AecMobile* aecm) { - int nSampFar = (int) WebRtc_available_read(aecm->farendBuf); - int nSampSndCard, delayNew, nSampAdd; - const int maxStuffSamp = 10 * FRAME_LEN; + int nSampFar = (int)WebRtc_available_read(aecm->farendBuf); + int nSampSndCard, delayNew, nSampAdd; + const int maxStuffSamp = 10 * FRAME_LEN; - nSampSndCard = aecm->msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult; - delayNew = nSampSndCard - nSampFar; + nSampSndCard = aecm->msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult; + delayNew = nSampSndCard - nSampFar; - if (delayNew > FAR_BUF_LEN - FRAME_LEN * aecm->aecmCore->mult) - { - // The difference of the buffer sizes is larger than the maximum - // allowed known delay. Compensate by stuffing the buffer. - nSampAdd = (int)(WEBRTC_SPL_MAX(((nSampSndCard >> 1) - nSampFar), - FRAME_LEN)); - nSampAdd = WEBRTC_SPL_MIN(nSampAdd, maxStuffSamp); + if (delayNew > FAR_BUF_LEN - FRAME_LEN * aecm->aecmCore->mult) { + // The difference of the buffer sizes is larger than the maximum + // allowed known delay. Compensate by stuffing the buffer. + nSampAdd = + (int)(WEBRTC_SPL_MAX(((nSampSndCard >> 1) - nSampFar), FRAME_LEN)); + nSampAdd = WEBRTC_SPL_MIN(nSampAdd, maxStuffSamp); - WebRtc_MoveReadPtr(aecm->farendBuf, -nSampAdd); - aecm->delayChange = 1; // the delay needs to be updated - } + WebRtc_MoveReadPtr(aecm->farendBuf, -nSampAdd); + aecm->delayChange = 1; // the delay needs to be updated + } - return 0; + return 0; } diff --git a/modules/audio_processing/aecm/echo_control_mobile.h b/modules/audio_processing/aecm/echo_control_mobile.h index e0091c3e57..576cf196fa 100644 --- a/modules/audio_processing/aecm/echo_control_mobile.h +++ b/modules/audio_processing/aecm/echo_control_mobile.h @@ -15,24 +15,21 @@ #include "typedefs.h" // NOLINT(build/include) -enum { - AecmFalse = 0, - AecmTrue -}; +enum { AecmFalse = 0, AecmTrue }; // Errors -#define AECM_UNSPECIFIED_ERROR 12000 -#define AECM_UNSUPPORTED_FUNCTION_ERROR 12001 -#define AECM_UNINITIALIZED_ERROR 12002 -#define AECM_NULL_POINTER_ERROR 12003 -#define AECM_BAD_PARAMETER_ERROR 12004 +#define AECM_UNSPECIFIED_ERROR 12000 +#define AECM_UNSUPPORTED_FUNCTION_ERROR 12001 +#define AECM_UNINITIALIZED_ERROR 12002 +#define AECM_NULL_POINTER_ERROR 12003 +#define AECM_BAD_PARAMETER_ERROR 12004 // Warnings -#define AECM_BAD_PARAMETER_WARNING 12100 +#define AECM_BAD_PARAMETER_WARNING 12100 typedef struct { - int16_t cngMode; // AECM_FALSE, AECM_TRUE (default) - int16_t echoMode; // 0, 1, 2, 3 (default), 4 + int16_t cngMode; // AECM_FALSE, AECM_TRUE (default) + int16_t echoMode; // 0, 1, 2, 3 (default), 4 } AecmConfig; #ifdef __cplusplus @@ -202,7 +199,6 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst, */ size_t WebRtcAecm_echo_path_size_bytes(); - #ifdef __cplusplus } #endif diff --git a/modules/audio_processing/agc/agc_manager_direct.cc b/modules/audio_processing/agc/agc_manager_direct.cc index 2d6ee81521..9714b4c95e 100644 --- a/modules/audio_processing/agc/agc_manager_direct.cc +++ b/modules/audio_processing/agc/agc_manager_direct.cc @@ -69,12 +69,12 @@ int LevelFromGainError(int gain_error, int level) { int new_level = level; if (gain_error > 0) { while (kGainMap[new_level] - kGainMap[level] < gain_error && - new_level < kMaxMicLevel) { + new_level < kMaxMicLevel) { ++new_level; } } else { while (kGainMap[new_level] - kGainMap[level] > gain_error && - new_level > kMinMicLevel) { + new_level > kMinMicLevel) { --new_level; } } @@ -88,26 +88,21 @@ int LevelFromGainError(int gain_error, int level) { class DebugFile { #ifdef WEBRTC_AGC_DEBUG_DUMP public: - explicit DebugFile(const char* filename) - : file_(fopen(filename, "wb")) { + explicit DebugFile(const char* filename) : file_(fopen(filename, "wb")) { RTC_DCHECK(file_); } - ~DebugFile() { - fclose(file_); - } + ~DebugFile() { fclose(file_); } void Write(const int16_t* data, size_t length_samples) { fwrite(data, 1, length_samples * sizeof(int16_t), file_); } + private: FILE* file_; #else public: - explicit DebugFile(const char* filename) { - } - ~DebugFile() { - } - void Write(const int16_t* data, size_t length_samples) { - } + explicit DebugFile(const char* filename) {} + ~DebugFile() {} + void Write(const int16_t* data, size_t length_samples) {} #endif // WEBRTC_AGC_DEBUG_DUMP }; @@ -272,7 +267,8 @@ void AgcManagerDirect::SetLevel(int new_level) { if (voe_level > level_ + kLevelQuantizationSlack || voe_level < level_ - kLevelQuantizationSlack) { RTC_DLOG(LS_INFO) << "[agc] Mic volume was manually adjusted. Updating " - "stored level from " << level_ << " to " << voe_level; + "stored level from " + << level_ << " to " << voe_level; level_ = voe_level; // Always allow the user to increase the volume. if (level_ > max_level_) { @@ -383,15 +379,15 @@ void AgcManagerDirect::UpdateGain() { // target and the newly received target. This serves to soften perceptible // intra-talkspurt adjustments, at the cost of some adaptation speed. if ((raw_compression == max_compression_gain_ && - target_compression_ == max_compression_gain_ - 1) || + target_compression_ == max_compression_gain_ - 1) || (raw_compression == kMinCompressionGain && - target_compression_ == kMinCompressionGain + 1)) { + target_compression_ == kMinCompressionGain + 1)) { // Special case to allow the target to reach the endpoints of the // compression range. The deemphasis would otherwise halt it at 1 dB shy. target_compression_ = raw_compression; } else { - target_compression_ = (raw_compression - target_compression_) / 2 - + target_compression_; + target_compression_ = + (raw_compression - target_compression_) / 2 + target_compression_; } // Residual error will be handled by adjusting the volume slider. Use the diff --git a/modules/audio_processing/agc/gain_map_internal.h b/modules/audio_processing/agc/gain_map_internal.h index f09c748b59..63d9b510ca 100644 --- a/modules/audio_processing/agc/gain_map_internal.h +++ b/modules/audio_processing/agc/gain_map_internal.h @@ -14,262 +14,23 @@ static const int kGainMapSize = 256; // Uses parameters: si = 2, sf = 0.25, D = 8/256 static const int kGainMap[kGainMapSize] = { - -56, - -54, - -52, - -50, - -48, - -47, - -45, - -43, - -42, - -40, - -38, - -37, - -35, - -34, - -33, - -31, - -30, - -29, - -27, - -26, - -25, - -24, - -23, - -22, - -20, - -19, - -18, - -17, - -16, - -15, - -14, - -14, - -13, - -12, - -11, - -10, - -9, - -8, - -8, - -7, - -6, - -5, - -5, - -4, - -3, - -2, - -2, - -1, - 0, - 0, - 1, - 1, - 2, - 3, - 3, - 4, - 4, - 5, - 5, - 6, - 6, - 7, - 7, - 8, - 8, - 9, - 9, - 10, - 10, - 11, - 11, - 12, - 12, - 13, - 13, - 13, - 14, - 14, - 15, - 15, - 15, - 16, - 16, - 17, - 17, - 17, - 18, - 18, - 18, - 19, - 19, - 19, - 20, - 20, - 21, - 21, - 21, - 22, - 22, - 22, - 23, - 23, - 23, - 24, - 24, - 24, - 24, - 25, - 25, - 25, - 26, - 26, - 26, - 27, - 27, - 27, - 28, - 28, - 28, - 28, - 29, - 29, - 29, - 30, - 30, - 30, - 30, - 31, - 31, - 31, - 32, - 32, - 32, - 32, - 33, - 33, - 33, - 33, - 34, - 34, - 34, - 35, - 35, - 35, - 35, - 36, - 36, - 36, - 36, - 37, - 37, - 37, - 38, - 38, - 38, - 38, - 39, - 39, - 39, - 39, - 40, - 40, - 40, - 40, - 41, - 41, - 41, - 41, - 42, - 42, - 42, - 42, - 43, - 43, - 43, - 44, - 44, - 44, - 44, - 45, - 45, - 45, - 45, - 46, - 46, - 46, - 46, - 47, - 47, - 47, - 47, - 48, - 48, - 48, - 48, - 49, - 49, - 49, - 49, - 50, - 50, - 50, - 50, - 51, - 51, - 51, - 51, - 52, - 52, - 52, - 52, - 53, - 53, - 53, - 53, - 54, - 54, - 54, - 54, - 55, - 55, - 55, - 55, - 56, - 56, - 56, - 56, - 57, - 57, - 57, - 57, - 58, - 58, - 58, - 58, - 59, - 59, - 59, - 59, - 60, - 60, - 60, - 60, - 61, - 61, - 61, - 61, - 62, - 62, - 62, - 62, - 63, - 63, - 63, - 63, - 64 -}; + -56, -54, -52, -50, -48, -47, -45, -43, -42, -40, -38, -37, -35, -34, -33, + -31, -30, -29, -27, -26, -25, -24, -23, -22, -20, -19, -18, -17, -16, -15, + -14, -14, -13, -12, -11, -10, -9, -8, -8, -7, -6, -5, -5, -4, -3, + -2, -2, -1, 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, + 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, + 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 18, 19, + 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, + 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, + 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, + 33, 33, 33, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, + 37, 37, 38, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 41, + 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, + 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 48, 48, + 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, + 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, + 56, 56, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 59, 60, + 60, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63, + 64}; #endif // MODULES_AUDIO_PROCESSING_AGC_GAIN_MAP_INTERNAL_H_ diff --git a/modules/audio_processing/agc/mock_agc.h b/modules/audio_processing/agc/mock_agc.h index cf2a859d61..ff1e9fda32 100644 --- a/modules/audio_processing/agc/mock_agc.h +++ b/modules/audio_processing/agc/mock_agc.h @@ -20,8 +20,8 @@ namespace webrtc { class MockAgc : public Agc { public: MOCK_METHOD2(AnalyzePreproc, float(const int16_t* audio, size_t length)); - MOCK_METHOD3(Process, void(const int16_t* audio, size_t length, - int sample_rate_hz)); + MOCK_METHOD3(Process, + void(const int16_t* audio, size_t length, int sample_rate_hz)); MOCK_METHOD1(GetRmsErrorDb, bool(int* error)); MOCK_METHOD0(Reset, void()); MOCK_METHOD1(set_target_level_dbfs, int(int level)); diff --git a/modules/audio_processing/agc2/agc2_common.h b/modules/audio_processing/agc2/agc2_common.h index a0919c848a..3ed88a36b8 100644 --- a/modules/audio_processing/agc2/agc2_common.h +++ b/modules/audio_processing/agc2/agc2_common.h @@ -15,7 +15,6 @@ #include - namespace webrtc { constexpr float kMinFloatS16Value = -32768.f; diff --git a/modules/audio_processing/agc2/gain_applier_unittest.cc b/modules/audio_processing/agc2/gain_applier_unittest.cc index bbf3a85d6c..3296345e62 100644 --- a/modules/audio_processing/agc2/gain_applier_unittest.cc +++ b/modules/audio_processing/agc2/gain_applier_unittest.cc @@ -72,8 +72,7 @@ TEST(AutomaticGainController2GainApplier, RampingIsDone) { float last_signal_level = initial_signal_level; for (const auto sample : fake_audio.float_frame_view().channel(channel)) { const float current_change = fabs(last_signal_level - sample); - max_signal_change = - std::max(max_signal_change, current_change); + max_signal_change = std::max(max_signal_change, current_change); last_signal_level = sample; } const float total_gain_change = diff --git a/modules/audio_processing/audio_buffer.cc b/modules/audio_processing/audio_buffer.cc index 16f11742e3..f163f5a07d 100644 --- a/modules/audio_processing/audio_buffer.cc +++ b/modules/audio_processing/audio_buffer.cc @@ -49,20 +49,20 @@ AudioBuffer::AudioBuffer(size_t input_num_frames, size_t process_num_frames, size_t num_process_channels, size_t output_num_frames) - : input_num_frames_(input_num_frames), - num_input_channels_(num_input_channels), - proc_num_frames_(process_num_frames), - num_proc_channels_(num_process_channels), - output_num_frames_(output_num_frames), - num_channels_(num_process_channels), - num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)), - num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)), - mixed_low_pass_valid_(false), - reference_copied_(false), - activity_(AudioFrame::kVadUnknown), - keyboard_data_(NULL), - data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)), - output_buffer_(new IFChannelBuffer(output_num_frames_, num_channels_)) { + : input_num_frames_(input_num_frames), + num_input_channels_(num_input_channels), + proc_num_frames_(process_num_frames), + num_proc_channels_(num_process_channels), + output_num_frames_(output_num_frames), + num_channels_(num_process_channels), + num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)), + num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)), + mixed_low_pass_valid_(false), + reference_copied_(false), + activity_(AudioFrame::kVadUnknown), + keyboard_data_(NULL), + data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)), + output_buffer_(new IFChannelBuffer(output_num_frames_, num_channels_)) { RTC_DCHECK_GT(input_num_frames_, 0); RTC_DCHECK_GT(proc_num_frames_, 0); RTC_DCHECK_GT(output_num_frames_, 0); @@ -73,8 +73,8 @@ AudioBuffer::AudioBuffer(size_t input_num_frames, if (input_num_frames_ != proc_num_frames_ || output_num_frames_ != proc_num_frames_) { // Create an intermediate buffer for resampling. - process_buffer_.reset(new ChannelBuffer(proc_num_frames_, - num_proc_channels_)); + process_buffer_.reset( + new ChannelBuffer(proc_num_frames_, num_proc_channels_)); if (input_num_frames_ != proc_num_frames_) { for (size_t i = 0; i < num_proc_channels_; ++i) { @@ -92,12 +92,10 @@ AudioBuffer::AudioBuffer(size_t input_num_frames, } if (num_bands_ > 1) { - split_data_.reset(new IFChannelBuffer(proc_num_frames_, - num_proc_channels_, - num_bands_)); - splitting_filter_.reset(new SplittingFilter(num_proc_channels_, - num_bands_, - proc_num_frames_)); + split_data_.reset( + new IFChannelBuffer(proc_num_frames_, num_proc_channels_, num_bands_)); + splitting_filter_.reset( + new SplittingFilter(num_proc_channels_, num_bands_, proc_num_frames_)); } } @@ -132,8 +130,7 @@ void AudioBuffer::CopyFrom(const float* const* data, // Resample. if (input_num_frames_ != proc_num_frames_) { for (size_t i = 0; i < num_proc_channels_; ++i) { - input_resamplers_[i]->Resample(data_ptr[i], - input_num_frames_, + input_resamplers_[i]->Resample(data_ptr[i], input_num_frames_, process_buffer_->channels()[i], proc_num_frames_); } @@ -142,8 +139,7 @@ void AudioBuffer::CopyFrom(const float* const* data, // Convert to the S16 range. for (size_t i = 0; i < num_proc_channels_; ++i) { - FloatToFloatS16(data_ptr[i], - proc_num_frames_, + FloatToFloatS16(data_ptr[i], proc_num_frames_, data_->fbuf()->channels()[i]); } } @@ -161,17 +157,14 @@ void AudioBuffer::CopyTo(const StreamConfig& stream_config, data_ptr = process_buffer_->channels(); } for (size_t i = 0; i < num_channels_; ++i) { - FloatS16ToFloat(data_->fbuf()->channels()[i], - proc_num_frames_, + FloatS16ToFloat(data_->fbuf()->channels()[i], proc_num_frames_, data_ptr[i]); } // Resample. if (output_num_frames_ != proc_num_frames_) { for (size_t i = 0; i < num_channels_; ++i) { - output_resamplers_[i]->Resample(data_ptr[i], - proc_num_frames_, - data[i], + output_resamplers_[i]->Resample(data_ptr[i], proc_num_frames_, data[i], output_num_frames_); } } @@ -204,16 +197,14 @@ int16_t* const* AudioBuffer::channels() { } const int16_t* const* AudioBuffer::split_bands_const(size_t channel) const { - return split_data_.get() ? - split_data_->ibuf_const()->bands(channel) : - data_->ibuf_const()->bands(channel); + return split_data_.get() ? split_data_->ibuf_const()->bands(channel) + : data_->ibuf_const()->bands(channel); } int16_t* const* AudioBuffer::split_bands(size_t channel) { mixed_low_pass_valid_ = false; - return split_data_.get() ? - split_data_->ibuf()->bands(channel) : - data_->ibuf()->bands(channel); + return split_data_.get() ? split_data_->ibuf()->bands(channel) + : data_->ibuf()->bands(channel); } const int16_t* const* AudioBuffer::split_channels_const(Band band) const { @@ -261,16 +252,14 @@ float* const* AudioBuffer::channels_f() { } const float* const* AudioBuffer::split_bands_const_f(size_t channel) const { - return split_data_.get() ? - split_data_->fbuf_const()->bands(channel) : - data_->fbuf_const()->bands(channel); + return split_data_.get() ? split_data_->fbuf_const()->bands(channel) + : data_->fbuf_const()->bands(channel); } float* const* AudioBuffer::split_bands_f(size_t channel) { mixed_low_pass_valid_ = false; - return split_data_.get() ? - split_data_->fbuf()->bands(channel) : - data_->fbuf()->bands(channel); + return split_data_.get() ? split_data_->fbuf()->bands(channel) + : data_->fbuf()->bands(channel); } const float* const* AudioBuffer::split_channels_const_f(Band band) const { @@ -401,19 +390,16 @@ void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) { num_input_channels_, deinterleaved[0]); } else { RTC_DCHECK_EQ(num_proc_channels_, num_input_channels_); - Deinterleave(frame->data(), - input_num_frames_, - num_proc_channels_, + Deinterleave(frame->data(), input_num_frames_, num_proc_channels_, deinterleaved); } // Resample. if (input_num_frames_ != proc_num_frames_) { for (size_t i = 0; i < num_proc_channels_; ++i) { - input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i], - input_num_frames_, - data_->fbuf()->channels()[i], - proc_num_frames_); + input_resamplers_[i]->Resample( + input_buffer_->fbuf_const()->channels()[i], input_num_frames_, + data_->fbuf()->channels()[i], proc_num_frames_); } } } @@ -453,8 +439,7 @@ void AudioBuffer::CopyLowPassToReference() { if (!low_pass_reference_channels_.get() || low_pass_reference_channels_->num_channels() != num_channels_) { low_pass_reference_channels_.reset( - new ChannelBuffer(num_split_frames_, - num_proc_channels_)); + new ChannelBuffer(num_split_frames_, num_proc_channels_)); } for (size_t i = 0; i < num_proc_channels_; i++) { memcpy(low_pass_reference_channels_->channels()[i], diff --git a/modules/audio_processing/audio_buffer.h b/modules/audio_processing/audio_buffer.h index 508f96f651..3d7c4a88f0 100644 --- a/modules/audio_processing/audio_buffer.h +++ b/modules/audio_processing/audio_buffer.h @@ -25,11 +25,7 @@ namespace webrtc { class PushSincResampler; class IFChannelBuffer; -enum Band { - kBand0To8kHz = 0, - kBand8To16kHz = 1, - kBand16To24kHz = 2 -}; +enum Band { kBand0To8kHz = 0, kBand8To16kHz = 1, kBand16To24kHz = 2 }; class AudioBuffer { public: @@ -152,11 +148,11 @@ class AudioBuffer { std::unique_ptr data_; std::unique_ptr split_data_; std::unique_ptr splitting_filter_; - std::unique_ptr > mixed_low_pass_channels_; - std::unique_ptr > low_pass_reference_channels_; + std::unique_ptr> mixed_low_pass_channels_; + std::unique_ptr> low_pass_reference_channels_; std::unique_ptr input_buffer_; std::unique_ptr output_buffer_; - std::unique_ptr > process_buffer_; + std::unique_ptr> process_buffer_; std::vector> input_resamplers_; std::vector> output_resamplers_; }; diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc index 39f8b8b4c6..b770fef18a 100644 --- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc @@ -146,8 +146,7 @@ struct TestConfig { // Create test config for the first processing API function set. test_configs.push_back(test_config); - test_config.render_api_function = - RenderApiImpl::AnalyzeReverseStreamImpl; + test_config.render_api_function = RenderApiImpl::AnalyzeReverseStreamImpl; test_config.capture_api_function = CaptureApiImpl::ProcessStreamImpl3; test_configs.push_back(test_config); } @@ -482,8 +481,7 @@ void PopulateAudioFrame(AudioFrame* frame, for (size_t k = 0; k < frame->samples_per_channel_; k++) { // Store random 16 bit number between -(amplitude+1) and // amplitude. - frame_data[k * ch] = - rand_gen->RandInt(2 * amplitude + 1) - amplitude - 1; + frame_data[k * ch] = rand_gen->RandInt(2 * amplitude + 1) - amplitude - 1; } } } diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc index 2ea01591a7..3ac5e71291 100644 --- a/modules/audio_processing/audio_processing_impl_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_unittest.cc @@ -72,15 +72,13 @@ TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) { // New sample rate. (Only impacts ProcessStream). SetFrameSampleRate(&frame, 32000); - EXPECT_CALL(mock, InitializeLocked()) - .Times(1); + EXPECT_CALL(mock, InitializeLocked()).Times(1); EXPECT_NOERR(mock.ProcessStream(&frame)); // New number of channels. // TODO(peah): Investigate why this causes 2 inits. frame.num_channels_ = 2; - EXPECT_CALL(mock, InitializeLocked()) - .Times(2); + EXPECT_CALL(mock, InitializeLocked()).Times(2); EXPECT_NOERR(mock.ProcessStream(&frame)); // ProcessStream sets num_channels_ == num_output_channels. frame.num_channels_ = 2; diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc index 2e985cef8f..56615cb532 100644 --- a/modules/audio_processing/audio_processing_performance_unittest.cc +++ b/modules/audio_processing/audio_processing_performance_unittest.cc @@ -160,13 +160,9 @@ struct SimulationConfig { // Handler for the frame counters. class FrameCounters { public: - void IncreaseRenderCounter() { - rtc::AtomicOps::Increment(&render_count_); - } + void IncreaseRenderCounter() { rtc::AtomicOps::Increment(&render_count_); } - void IncreaseCaptureCounter() { - rtc::AtomicOps::Increment(&capture_count_); - } + void IncreaseCaptureCounter() { rtc::AtomicOps::Increment(&capture_count_); } int CaptureMinusRenderCounters() const { // The return value will be approximate, but that's good enough since @@ -196,9 +192,7 @@ class FrameCounters { // Class that represents a flag that can only be raised. class LockedFlag { public: - bool get_flag() const { - return rtc::AtomicOps::AcquireLoad(&flag_); - } + bool get_flag() const { return rtc::AtomicOps::AcquireLoad(&flag_); } void set_flag() { if (!get_flag()) // read-only operation to avoid affecting the cache-line. @@ -248,9 +242,8 @@ class TimedThreadApiProcessor { "_" + std::to_string(simulation_config_->sample_rate_hz) + "Hz"; webrtc::test::PrintResultMeanAndError( - "apm_timing", sample_rate_name, processor_name, - GetDurationAverage(), GetDurationStandardDeviation(), - "us", false); + "apm_timing", sample_rate_name, processor_name, GetDurationAverage(), + GetDurationStandardDeviation(), "us", false); if (kPrintAllDurations) { webrtc::test::PrintResultList("apm_call_durations", sample_rate_name, diff --git a/modules/audio_processing/beamformer/array_util.h b/modules/audio_processing/beamformer/array_util.h index 8e69f81f7e..9bdbecbcd8 100644 --- a/modules/audio_processing/beamformer/array_util.h +++ b/modules/audio_processing/beamformer/array_util.h @@ -24,7 +24,7 @@ namespace webrtc { // y: the depth dimension, with positive forward from the camera's // perspective. // z: the vertical dimension, with positive upwards. -template +template struct CartesianPoint { CartesianPoint() { c[0] = 0; @@ -74,7 +74,7 @@ absl::optional GetArrayNormalIfExists( // The resulting Point will be in the xy-plane. Point AzimuthToPoint(float azimuth); -template +template float Distance(CartesianPoint a, CartesianPoint b) { return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + (a.y() - b.y()) * (a.y() - b.y()) + diff --git a/modules/audio_processing/beamformer/complex_matrix_unittest.cc b/modules/audio_processing/beamformer/complex_matrix_unittest.cc index e11dfd2b5c..f9c7ea5fe5 100644 --- a/modules/audio_processing/beamformer/complex_matrix_unittest.cc +++ b/modules/audio_processing/beamformer/complex_matrix_unittest.cc @@ -61,10 +61,10 @@ TEST(ComplexMatrixTest, TestConjugateTranspose) { {complex(3.3f, -3.3f), complex(7.7f, -7.7f)}, {complex(4.4f, -4.4f), complex(8.8f, -8.8f)}}; - ComplexMatrix initial_mat( - *kValuesInitial, kNumInitialRows, kNumInitialCols); - ComplexMatrix expected_result( - *kValuesExpected, kNumResultRows, kNumResultCols); + ComplexMatrix initial_mat(*kValuesInitial, kNumInitialRows, + kNumInitialCols); + ComplexMatrix expected_result(*kValuesExpected, kNumResultRows, + kNumResultCols); ComplexMatrix actual_result(kNumResultRows, kNumResultCols); actual_result.ConjugateTranspose(initial_mat); diff --git a/modules/audio_processing/beamformer/covariance_matrix_generator.cc b/modules/audio_processing/beamformer/covariance_matrix_generator.cc index df36d5974f..afc6ddd3a1 100644 --- a/modules/audio_processing/beamformer/covariance_matrix_generator.cc +++ b/modules/audio_processing/beamformer/covariance_matrix_generator.cc @@ -73,13 +73,8 @@ void CovarianceMatrixGenerator::AngledCovarianceMatrix( ComplexMatrix interf_cov_vector(1, geometry.size()); ComplexMatrix interf_cov_vector_transposed(geometry.size(), 1); - PhaseAlignmentMasks(frequency_bin, - fft_size, - sample_rate, - sound_speed, - geometry, - angle, - &interf_cov_vector); + PhaseAlignmentMasks(frequency_bin, fft_size, sample_rate, sound_speed, + geometry, angle, &interf_cov_vector); interf_cov_vector.Scale(1.f / Norm(interf_cov_vector)); interf_cov_vector_transposed.Transpose(interf_cov_vector); interf_cov_vector.PointwiseConjugate(); diff --git a/modules/audio_processing/beamformer/covariance_matrix_generator.h b/modules/audio_processing/beamformer/covariance_matrix_generator.h index 6a5841f631..d26ed2fc0b 100644 --- a/modules/audio_processing/beamformer/covariance_matrix_generator.h +++ b/modules/audio_processing/beamformer/covariance_matrix_generator.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_BEAMFORMER_COVARIANCE_MATRIX_GENERATOR_H_ #define MODULES_AUDIO_PROCESSING_BEAMFORMER_COVARIANCE_MATRIX_GENERATOR_H_ -#include "modules/audio_processing/beamformer/complex_matrix.h" #include "modules/audio_processing/beamformer/array_util.h" +#include "modules/audio_processing/beamformer/complex_matrix.h" namespace webrtc { diff --git a/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc b/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc index a6518e5d95..4f77744cc2 100644 --- a/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc +++ b/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc @@ -32,8 +32,7 @@ TEST(CovarianceMatrixGeneratorTest, TestUniformCovarianceMatrix2Mics) { geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f)); } ComplexMatrix actual_covariance_matrix(kNumberMics, kNumberMics); - CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, - geometry, + CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, geometry, &actual_covariance_matrix); complex* const* actual_els = actual_covariance_matrix.elements(); @@ -60,8 +59,7 @@ TEST(CovarianceMatrixGeneratorTest, TestUniformCovarianceMatrix3Mics) { geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f)); } ComplexMatrix actual_covariance_matrix(kNumberMics, kNumberMics); - CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, - geometry, + CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, geometry, &actual_covariance_matrix); complex* const* actual_els = actual_covariance_matrix.elements(); @@ -97,8 +95,7 @@ TEST(CovarianceMatrixGeneratorTest, TestUniformCovarianceMatrix3DArray) { geometry.push_back(Point(-0.025f, 0.15f, -0.075f)); geometry.push_back(Point(-0.025f, -0.05f, 0.225f)); ComplexMatrix actual_covariance_matrix(kNumberMics, kNumberMics); - CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, - geometry, + CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, geometry, &actual_covariance_matrix); complex* const* actual_els = actual_covariance_matrix.elements(); @@ -154,14 +151,9 @@ TEST(CovarianceMatrixGeneratorTest, TestAngledCovarianceMatrix2Mics) { geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f)); } ComplexMatrix actual_covariance_matrix(kNumberMics, kNumberMics); - CovarianceMatrixGenerator::AngledCovarianceMatrix(kSpeedOfSound, - kAngle, - kFrequencyBin, - kFftSize, - kNumberFrequencyBins, - kSampleRate, - geometry, - &actual_covariance_matrix); + CovarianceMatrixGenerator::AngledCovarianceMatrix( + kSpeedOfSound, kAngle, kFrequencyBin, kFftSize, kNumberFrequencyBins, + kSampleRate, geometry, &actual_covariance_matrix); complex* const* actual_els = actual_covariance_matrix.elements(); @@ -192,14 +184,9 @@ TEST(CovarianceMatrixGeneratorTest, TestAngledCovarianceMatrix3Mics) { geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f)); } ComplexMatrix actual_covariance_matrix(kNumberMics, kNumberMics); - CovarianceMatrixGenerator::AngledCovarianceMatrix(kSpeedOfSound, - kAngle, - kFrequencyBin, - kFftSize, - kNumberFrequencyBins, - kSampleRate, - geometry, - &actual_covariance_matrix); + CovarianceMatrixGenerator::AngledCovarianceMatrix( + kSpeedOfSound, kAngle, kFrequencyBin, kFftSize, kNumberFrequencyBins, + kSampleRate, geometry, &actual_covariance_matrix); complex* const* actual_els = actual_covariance_matrix.elements(); diff --git a/modules/audio_processing/beamformer/matrix.h b/modules/audio_processing/beamformer/matrix.h index bf94c25df0..3d1a709d52 100644 --- a/modules/audio_processing/beamformer/matrix.h +++ b/modules/audio_processing/beamformer/matrix.h @@ -33,7 +33,7 @@ template std::complex sqrt_wrapper(std::complex x) { return sqrt(x); } -} // namespace +} // namespace namespace webrtc { diff --git a/modules/audio_processing/beamformer/matrix_test_helpers.h b/modules/audio_processing/beamformer/matrix_test_helpers.h index 62b47082e3..e7b2f09d58 100644 --- a/modules/audio_processing/beamformer/matrix_test_helpers.h +++ b/modules/audio_processing/beamformer/matrix_test_helpers.h @@ -66,11 +66,9 @@ class MatrixTestHelpers { for (size_t i = 0; i < expected.num_rows(); ++i) { for (size_t j = 0; j < expected.num_columns(); ++j) { EXPECT_NEAR(expected_elements[i][j].real(), - actual_elements[i][j].real(), - kTolerance); + actual_elements[i][j].real(), kTolerance); EXPECT_NEAR(expected_elements[i][j].imag(), - actual_elements[i][j].imag(), - kTolerance); + actual_elements[i][j].imag(), kTolerance); } } } @@ -87,11 +85,9 @@ class MatrixTestHelpers { for (size_t i = 0; i < expected.num_rows(); ++i) { for (size_t j = 0; j < expected.num_columns(); ++j) { EXPECT_NEAR(expected_elements[i][j].real(), - actual_elements[i][j].real(), - tolerance); + actual_elements[i][j].real(), tolerance); EXPECT_NEAR(expected_elements[i][j].imag(), - actual_elements[i][j].imag(), - tolerance); + actual_elements[i][j].imag(), tolerance); } } } diff --git a/modules/audio_processing/beamformer/matrix_unittest.cc b/modules/audio_processing/beamformer/matrix_unittest.cc index 4badfd07ed..4dcf91b4a0 100644 --- a/modules/audio_processing/beamformer/matrix_unittest.cc +++ b/modules/audio_processing/beamformer/matrix_unittest.cc @@ -74,8 +74,8 @@ TEST(MatrixTest, TestTranspose) { {1.1f, 5.5f}, {2.2f, 6.6f}, {3.3f, 7.7f}, {4.4f, 8.8f}}; Matrix initial_mat(*kValuesInitial, kNumInitialRows, kNumInitialCols); - Matrix expected_result( - *kValuesExpected, kNumResultRows, kNumResultCols); + Matrix expected_result(*kValuesExpected, kNumResultRows, + kNumResultCols); Matrix actual_result(kNumResultRows, kNumResultCols); actual_result.Transpose(initial_mat); @@ -300,10 +300,10 @@ TEST(MatrixTest, TestComplexOperations) { Matrix > lh_mat(*kValuesLeft, kNumRows, kNumCols); Matrix > rh_mat(*kValuesRight, kNumRows, kNumCols); - Matrix > expected_result_add( - *kValuesExpectedAdd, kNumRows, kNumCols); - Matrix > expected_result_multiply( - *kValuesExpectedMultiply, kNumRows, kNumCols); + Matrix > expected_result_add(*kValuesExpectedAdd, kNumRows, + kNumCols); + Matrix > expected_result_multiply(*kValuesExpectedMultiply, + kNumRows, kNumCols); Matrix > expected_result_pointwise_divide( *kValuesExpectedPointwiseDivide, kNumRows, kNumCols); Matrix > actual_result_add; diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer.cc b/modules/audio_processing/beamformer/nonlinear_beamformer.cc index 12f6d2f465..89dc44c8b8 100644 --- a/modules/audio_processing/beamformer/nonlinear_beamformer.cc +++ b/modules/audio_processing/beamformer/nonlinear_beamformer.cc @@ -234,13 +234,9 @@ void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) { hold_target_blocks_ = kHoldTargetSeconds * 2 * sample_rate_hz / kFftSize; interference_blocks_count_ = hold_target_blocks_; - process_transform_.reset(new LappedTransform(num_input_channels_, - 0u, - chunk_length_, - window_, - kFftSize, - kFftSize / 2, - this)); + process_transform_.reset(new LappedTransform(num_input_channels_, 0u, + chunk_length_, window_, kFftSize, + kFftSize / 2, this)); postfilter_transform_.reset(new PostFilterTransform( num_postfilter_channels_, chunk_length_, window_, kFftSize)); const float wave_number_step = @@ -267,10 +263,10 @@ void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) { // low_mean_end_bin_ high_mean_end_bin_ // void NonlinearBeamformer::InitLowFrequencyCorrectionRanges() { - low_mean_start_bin_ = Round(static_cast(kLowMeanStartHz) * - kFftSize / sample_rate_hz_); - low_mean_end_bin_ = Round(static_cast(kLowMeanEndHz) * - kFftSize / sample_rate_hz_); + low_mean_start_bin_ = + Round(static_cast(kLowMeanStartHz) * kFftSize / sample_rate_hz_); + low_mean_end_bin_ = + Round(static_cast(kLowMeanEndHz) * kFftSize / sample_rate_hz_); RTC_DCHECK_GT(low_mean_start_bin_, 0U); RTC_DCHECK_LT(low_mean_start_bin_, low_mean_end_bin_); @@ -280,10 +276,10 @@ void NonlinearBeamformer::InitHighFrequencyCorrectionRanges() { const float kAliasingFreqHz = kSpeedOfSoundMeterSeconds / (min_mic_spacing_ * (1.f + std::abs(std::cos(target_angle_radians_)))); - const float kHighMeanStartHz = std::min(0.5f * kAliasingFreqHz, - sample_rate_hz_ / 2.f); - const float kHighMeanEndHz = std::min(0.75f * kAliasingFreqHz, - sample_rate_hz_ / 2.f); + const float kHighMeanStartHz = + std::min(0.5f * kAliasingFreqHz, sample_rate_hz_ / 2.f); + const float kHighMeanEndHz = + std::min(0.75f * kAliasingFreqHz, sample_rate_hz_ / 2.f); high_mean_start_bin_ = Round(kHighMeanStartHz * kFftSize / sample_rate_hz_); high_mean_end_bin_ = Round(kHighMeanEndHz * kFftSize / sample_rate_hz_); @@ -366,14 +362,8 @@ void NonlinearBeamformer::InitInterfCovMats() { new ComplexMatrixF(num_input_channels_, num_input_channels_))); ComplexMatrixF angled_cov_mat(num_input_channels_, num_input_channels_); CovarianceMatrixGenerator::AngledCovarianceMatrix( - kSpeedOfSoundMeterSeconds, - interf_angles_radians_[j], - i, - kFftSize, - kNumFreqBins, - sample_rate_hz_, - array_geometry_, - &angled_cov_mat); + kSpeedOfSoundMeterSeconds, interf_angles_radians_[j], i, kFftSize, + kNumFreqBins, sample_rate_hz_, array_geometry_, &angled_cov_mat); // Normalize matrices before averaging them. complex_f normalization_factor = angled_cov_mat.elements()[0][0]; angled_cov_mat.Scale(1.f / normalization_factor); @@ -442,7 +432,9 @@ bool NonlinearBeamformer::IsInBeam(const SphericalPointf& spherical_point) { kHalfBeamWidthRadians; } -bool NonlinearBeamformer::is_target_present() { return is_target_present_; } +bool NonlinearBeamformer::is_target_present() { + return is_target_present_; +} void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input, size_t num_input_channels, @@ -473,15 +465,11 @@ void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input, rmw *= rmw; float rmw_r = rmw.real(); - new_mask_[i] = CalculatePostfilterMask(*interf_cov_mats_[i][0], - rpsiws_[i][0], - ratio_rxiw_rxim, - rmw_r); + new_mask_[i] = CalculatePostfilterMask( + *interf_cov_mats_[i][0], rpsiws_[i][0], ratio_rxiw_rxim, rmw_r); for (size_t j = 1; j < interf_angles_radians_.size(); ++j) { - float tmp_mask = CalculatePostfilterMask(*interf_cov_mats_[i][j], - rpsiws_[i][j], - ratio_rxiw_rxim, - rmw_r); + float tmp_mask = CalculatePostfilterMask( + *interf_cov_mats_[i][j], rpsiws_[i][j], ratio_rxiw_rxim, rmw_r); if (tmp_mask < new_mask_[i]) { new_mask_[i] = tmp_mask; } @@ -577,8 +565,8 @@ void NonlinearBeamformer::ApplyHighFrequencyCorrection() { // Compute mean over the given range of time_smooth_mask_, [first, last). float NonlinearBeamformer::MaskRangeMean(size_t first, size_t last) { RTC_DCHECK_GT(last, first); - const float sum = std::accumulate(time_smooth_mask_ + first, - time_smooth_mask_ + last, 0.f); + const float sum = + std::accumulate(time_smooth_mask_ + first, time_smooth_mask_ + last, 0.f); return sum / (last - first); } diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer.h b/modules/audio_processing/beamformer/nonlinear_beamformer.h index 9ae28edc1f..b58165f0ad 100644 --- a/modules/audio_processing/beamformer/nonlinear_beamformer.h +++ b/modules/audio_processing/beamformer/nonlinear_beamformer.h @@ -21,8 +21,8 @@ #include #include -#include "common_audio/lapped_transform.h" #include "common_audio/channel_buffer.h" +#include "common_audio/lapped_transform.h" #include "modules/audio_processing/beamformer/array_util.h" #include "modules/audio_processing/beamformer/complex_matrix.h" diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc b/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc index 7db5b9f38f..10f5cc022e 100644 --- a/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc +++ b/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc @@ -20,10 +20,11 @@ DEFINE_string(i, "", "The name of the input file to read from."); DEFINE_string(o, "out.wav", "Name of the output file to write to."); -DEFINE_string(mic_positions, "", - "Space delimited cartesian coordinates of microphones in meters. " - "The coordinates of each point are contiguous. " - "For a two element array: \"x1 y1 z1 x2 y2 z2\""); +DEFINE_string(mic_positions, + "", + "Space delimited cartesian coordinates of microphones in meters. " + "The coordinates of each point are contiguous. " + "For a two element array: \"x1 y1 z1 x2 y2 z2\""); DEFINE_bool(help, false, "Prints this message."); namespace webrtc { @@ -63,8 +64,8 @@ std::vector ParseArrayGeometry(const std::string& mic_positions, } // namespace int main(int argc, char* argv[]) { - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 1) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 1) { printf("%s", kUsage); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); @@ -84,8 +85,8 @@ int main(int argc, char* argv[]) { NonlinearBeamformer bf(array_geometry, array_geometry.size()); bf.Initialize(kChunkSizeMs, in_file.sample_rate()); - printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", - FLAG_i, in_file.num_channels(), in_file.sample_rate()); + printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", FLAG_i, + in_file.num_channels(), in_file.sample_rate()); printf("Output file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", FLAG_o, out_file.num_channels(), out_file.sample_rate()); @@ -94,17 +95,17 @@ int main(int argc, char* argv[]) { in_file.num_channels()); std::vector interleaved(buf.size()); - while (in_file.ReadSamples(interleaved.size(), - &interleaved[0]) == interleaved.size()) { + while (in_file.ReadSamples(interleaved.size(), &interleaved[0]) == + interleaved.size()) { FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]); - Deinterleave(&interleaved[0], buf.num_frames(), - buf.num_channels(), buf.channels()); + Deinterleave(&interleaved[0], buf.num_frames(), buf.num_channels(), + buf.channels()); bf.AnalyzeChunk(buf); bf.PostFilter(&buf); - Interleave(buf.channels(), buf.num_frames(), - buf.num_channels(), &interleaved[0]); + Interleave(buf.channels(), buf.num_frames(), buf.num_channels(), + &interleaved[0]); FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]); out_file.WriteSamples(&interleaved[0], interleaved.size()); } diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc b/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc index 78b2f0a68e..7d81b88af7 100644 --- a/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc +++ b/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc @@ -260,8 +260,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection1, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo16kHz_ArrayGeometry1_TargetDirection1) { +TEST(BeamformerBitExactnessTest, Stereo16kHz_ArrayGeometry1_TargetDirection1) { const float kOutputReference[] = {-0.000077f, -0.000147f, -0.000138f, -0.000077f, -0.000147f, -0.000138f}; @@ -269,8 +268,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection1, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo32kHz_ArrayGeometry1_TargetDirection1) { +TEST(BeamformerBitExactnessTest, Stereo32kHz_ArrayGeometry1_TargetDirection1) { const float kOutputReference[] = {-0.000061f, -0.000061f, -0.000061f, -0.000061f, -0.000061f, -0.000061f}; @@ -278,8 +276,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection1, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo48kHz_ArrayGeometry1_TargetDirection1) { +TEST(BeamformerBitExactnessTest, Stereo48kHz_ArrayGeometry1_TargetDirection1) { const float kOutputReference[] = {0.000450f, 0.000436f, 0.000433f, 0.000450f, 0.000436f, 0.000433f}; @@ -298,8 +295,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo16kHz_ArrayGeometry1_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo16kHz_ArrayGeometry1_TargetDirection2) { const float kOutputReference[] = {0.000221f, -0.000249f, 0.000140f, 0.000221f, -0.000249f, 0.000140f}; @@ -307,8 +303,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo32kHz_ArrayGeometry1_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo32kHz_ArrayGeometry1_TargetDirection2) { const float kOutputReference[] = {0.000763f, -0.000336f, 0.000549f, 0.000763f, -0.000336f, 0.000549f}; @@ -316,8 +311,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo48kHz_ArrayGeometry1_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo48kHz_ArrayGeometry1_TargetDirection2) { const float kOutputReference[] = {-0.000004f, -0.000494f, 0.000255f, -0.000004f, -0.000494f, 0.000255f}; @@ -325,8 +319,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo8kHz_ArrayGeometry2_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo8kHz_ArrayGeometry2_TargetDirection2) { const float kOutputReference[] = {-0.000914f, 0.002170f, -0.002382f, -0.000914f, 0.002170f, -0.002382f}; @@ -334,8 +327,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo16kHz_ArrayGeometry2_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo16kHz_ArrayGeometry2_TargetDirection2) { const float kOutputReference[] = {0.000179f, -0.000179f, 0.000081f, 0.000179f, -0.000179f, 0.000081f}; @@ -343,8 +335,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo32kHz_ArrayGeometry2_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo32kHz_ArrayGeometry2_TargetDirection2) { const float kOutputReference[] = {0.000549f, -0.000214f, 0.000366f, 0.000549f, -0.000214f, 0.000366f}; @@ -352,8 +343,7 @@ TEST(BeamformerBitExactnessTest, TargetDirection2, kOutputReference); } -TEST(BeamformerBitExactnessTest, - Stereo48kHz_ArrayGeometry2_TargetDirection2) { +TEST(BeamformerBitExactnessTest, Stereo48kHz_ArrayGeometry2_TargetDirection2) { const float kOutputReference[] = {0.000019f, -0.000310f, 0.000182f, 0.000019f, -0.000310f, 0.000182f}; diff --git a/modules/audio_processing/config_unittest.cc b/modules/audio_processing/config_unittest.cc index 8776ee3391..19e9ab37d2 100644 --- a/modules/audio_processing/config_unittest.cc +++ b/modules/audio_processing/config_unittest.cc @@ -19,11 +19,9 @@ struct MyExperiment { static const int kDefaultFactor; static const int kDefaultOffset; - MyExperiment() - : factor(kDefaultFactor), offset(kDefaultOffset) {} + MyExperiment() : factor(kDefaultFactor), offset(kDefaultOffset) {} - MyExperiment(int factor, int offset) - : factor(factor), offset(offset) {} + MyExperiment(int factor, int offset) : factor(factor), offset(offset) {} int factor; int offset; @@ -61,17 +59,13 @@ struct Algo1_CostFunction { ConfigOptionID::kAlgo1CostFunctionForTest; Algo1_CostFunction() {} - virtual int cost(int x) const { - return x; - } + virtual int cost(int x) const { return x; } virtual ~Algo1_CostFunction() {} }; struct SqrCost : Algo1_CostFunction { - virtual int cost(int x) const { - return x*x; - } + virtual int cost(int x) const { return x * x; } }; TEST(Config, SupportsPolymorphism) { diff --git a/modules/audio_processing/echo_cancellation_impl.cc b/modules/audio_processing/echo_cancellation_impl.cc index 99f676c562..15cd0db751 100644 --- a/modules/audio_processing/echo_cancellation_impl.cc +++ b/modules/audio_processing/echo_cancellation_impl.cc @@ -147,7 +147,6 @@ void EchoCancellationImpl::ProcessRenderAudio( } } - int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio, int stream_delay_ms) { rtc::CritScope cs_capture(crit_capture_); @@ -376,7 +375,8 @@ int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { return GetDelayMetrics(median, std, &fraction_poor_delays); } -int EchoCancellationImpl::GetDelayMetrics(int* median, int* std, +int EchoCancellationImpl::GetDelayMetrics(int* median, + int* std, float* fraction_poor_delays) { rtc::CritScope cs(crit_capture_); if (median == NULL) { @@ -445,8 +445,7 @@ int EchoCancellationImpl::GetSystemDelayInSamples() const { rtc::CritScope cs(crit_capture_); RTC_DCHECK(enabled_); // Report the delay for the first AEC component. - return WebRtcAec_system_delay( - WebRtcAec_aec_core(cancellers_[0]->state())); + return WebRtcAec_system_delay(WebRtcAec_aec_core(cancellers_[0]->state())); } void EchoCancellationImpl::PackRenderAudioBuffer( diff --git a/modules/audio_processing/echo_control_mobile_impl.cc b/modules/audio_processing/echo_control_mobile_impl.cc index 0ff1bce2c4..841364f941 100644 --- a/modules/audio_processing/echo_control_mobile_impl.cc +++ b/modules/audio_processing/echo_control_mobile_impl.cc @@ -120,10 +120,10 @@ EchoControlMobileImpl::EchoControlMobileImpl(rtc::CriticalSection* crit_render, } EchoControlMobileImpl::~EchoControlMobileImpl() { - if (external_echo_path_ != NULL) { - delete [] external_echo_path_; - external_echo_path_ = NULL; - } + if (external_echo_path_ != NULL) { + delete[] external_echo_path_; + external_echo_path_ = NULL; + } } void EchoControlMobileImpl::ProcessRenderAudio( @@ -218,8 +218,7 @@ int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio, ++handle_index; } for (size_t band = 1u; band < audio->num_bands(); ++band) { - memset(audio->split_bands(capture)[band], - 0, + memset(audio->split_bands(capture)[band], 0, audio->num_frames_per_band() * sizeof(audio->split_bands(capture)[band][0])); } @@ -269,8 +268,7 @@ int EchoControlMobileImpl::set_routing_mode(RoutingMode mode) { return Configure(); } -EchoControlMobile::RoutingMode EchoControlMobileImpl::routing_mode() - const { +EchoControlMobile::RoutingMode EchoControlMobileImpl::routing_mode() const { rtc::CritScope cs(crit_capture_); return routing_mode_; } diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc index 8be261c071..685a27ff66 100644 --- a/modules/audio_processing/gain_control_impl.cc +++ b/modules/audio_processing/gain_control_impl.cc @@ -67,9 +67,7 @@ class GainControlImpl::GainController { set_capture_level(capture_level); } - void set_capture_level(int capture_level) { - capture_level_ = capture_level; - } + void set_capture_level(int capture_level) { capture_level_ = capture_level; } int get_capture_level() { RTC_DCHECK(capture_level_); @@ -259,7 +257,7 @@ int GainControlImpl::stream_analog_level() { data_dumper_->DumpRaw("gain_control_stream_analog_level", 1, &analog_capture_level_); // TODO(ajm): enable this assertion? - //RTC_DCHECK_EQ(kAdaptiveAnalog, mode_); + // RTC_DCHECK_EQ(kAdaptiveAnalog, mode_); return analog_capture_level_; } @@ -303,8 +301,7 @@ GainControl::Mode GainControlImpl::mode() const { return mode_; } -int GainControlImpl::set_analog_level_limits(int minimum, - int maximum) { +int GainControlImpl::set_analog_level_limits(int minimum, int maximum) { if (minimum < 0) { return AudioProcessing::kBadParameterError; } @@ -419,11 +416,10 @@ int GainControlImpl::Configure() { WebRtcAgcConfig config; // TODO(ajm): Flip the sign here (since AGC expects a positive value) if we // change the interface. - //RTC_DCHECK_LE(target_level_dbfs_, 0); - //config.targetLevelDbfs = static_cast(-target_level_dbfs_); + // RTC_DCHECK_LE(target_level_dbfs_, 0); + // config.targetLevelDbfs = static_cast(-target_level_dbfs_); config.targetLevelDbfs = static_cast(target_level_dbfs_); - config.compressionGaindB = - static_cast(compression_gain_db_); + config.compressionGaindB = static_cast(compression_gain_db_); config.limiterEnable = limiter_enabled_; int error = AudioProcessing::kNoError; diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index d5bdeeaecc..38a97ca3dc 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -18,7 +18,7 @@ #include #include // size_t -#include // FILE +#include // FILE #include #include @@ -743,8 +743,8 @@ class StreamConfig { private: static size_t calculate_frames(int sample_rate_hz) { - return static_cast( - AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000); + return static_cast(AudioProcessing::kChunkSizeMs * sample_rate_hz / + 1000); } int sample_rate_hz_; @@ -893,7 +893,8 @@ class EchoCancellation { // Deprecated. Use GetStatistics on the AudioProcessing interface instead. virtual int GetDelayMetrics(int* median, int* std) = 0; // Deprecated. Use GetStatistics on the AudioProcessing interface instead. - virtual int GetDelayMetrics(int* median, int* std, + virtual int GetDelayMetrics(int* median, + int* std, float* fraction_poor_delays) = 0; // Returns a pointer to the low level AEC component. In case of multiple @@ -1037,8 +1038,7 @@ class GainControl { // Sets the |minimum| and |maximum| analog levels of the audio capture device. // Must be set if and only if an analog mode is used. Limited to [0, 65535]. - virtual int set_analog_level_limits(int minimum, - int maximum) = 0; + virtual int set_analog_level_limits(int minimum, int maximum) = 0; virtual int analog_level_minimum() const = 0; virtual int analog_level_maximum() const = 0; @@ -1097,12 +1097,7 @@ class NoiseSuppression { // Determines the aggressiveness of the suppression. Increasing the level // will reduce the noise level at the expense of a higher speech distortion. - enum Level { - kLow, - kModerate, - kHigh, - kVeryHigh - }; + enum Level { kLow, kModerate, kHigh, kVeryHigh }; virtual int set_level(Level level) = 0; virtual Level level() const = 0; diff --git a/modules/audio_processing/include/config.h b/modules/audio_processing/include/config.h index 4e318c9868..9232b2e0a8 100644 --- a/modules/audio_processing/include/config.h +++ b/modules/audio_processing/include/config.h @@ -64,11 +64,13 @@ class Config { // Returned references are owned by this. // // Requires std::is_default_constructible - template const T& Get() const; + template + const T& Get() const; // Set the option, deleting any previous instance of the same. // This instance gets ownership of the newly set value. - template void Set(T* value); + template + void Set(T* value); Config(); ~Config(); @@ -78,16 +80,14 @@ class Config { virtual ~BaseOption() {} }; - template + template struct Option : BaseOption { - explicit Option(T* v): value(v) {} - ~Option() { - delete value; - } + explicit Option(T* v) : value(v) {} + ~Option() { delete value; } T* value; }; - template + template static ConfigOptionID identifier() { return T::identifier; } @@ -95,7 +95,7 @@ class Config { // Used to instantiate a default constructed object that doesn't needs to be // owned. This allows Get to be implemented without requiring explicitly // locks. - template + template static const T& default_value() { static const T* const def = new T(); return *def; @@ -109,7 +109,7 @@ class Config { void operator=(const Config&); }; -template +template const T& Config::Get() const { OptionMap::const_iterator it = options_.find(identifier()); if (it != options_.end()) { @@ -121,7 +121,7 @@ const T& Config::Get() const { return default_value(); } -template +template void Config::Set(T* value) { BaseOption*& it = options_[identifier()]; delete it; diff --git a/modules/audio_processing/include/mock_audio_processing.h b/modules/audio_processing/include/mock_audio_processing.h index b3253e9380..9ceee106c0 100644 --- a/modules/audio_processing/include/mock_audio_processing.h +++ b/modules/audio_processing/include/mock_audio_processing.h @@ -40,8 +40,8 @@ class MockEchoCancellation : public EchoCancellation { MOCK_METHOD1(enable_delay_logging, int(bool enable)); MOCK_CONST_METHOD0(is_delay_logging_enabled, bool()); MOCK_METHOD2(GetDelayMetrics, int(int* median, int* std)); - MOCK_METHOD3(GetDelayMetrics, int(int* median, int* std, - float* fraction_poor_delays)); + MOCK_METHOD3(GetDelayMetrics, + int(int* median, int* std, float* fraction_poor_delays)); MOCK_CONST_METHOD0(aec_core, struct AecCore*()); }; @@ -148,18 +148,18 @@ class MockAudioProcessing : public testing::NiceMock { high_pass_filter_(new testing::NiceMock()), level_estimator_(new testing::NiceMock()), noise_suppression_(new testing::NiceMock()), - voice_detection_(new testing::NiceMock()) { - } + voice_detection_(new testing::NiceMock()) {} virtual ~MockAudioProcessing() {} MOCK_METHOD0(Initialize, int()); - MOCK_METHOD6(Initialize, int(int capture_input_sample_rate_hz, - int capture_output_sample_rate_hz, - int render_sample_rate_hz, - ChannelLayout capture_input_layout, - ChannelLayout capture_output_layout, - ChannelLayout render_input_layout)); + MOCK_METHOD6(Initialize, + int(int capture_input_sample_rate_hz, + int capture_output_sample_rate_hz, + int render_sample_rate_hz, + ChannelLayout capture_input_layout, + ChannelLayout capture_output_layout, + ChannelLayout render_input_layout)); MOCK_METHOD1(Initialize, int(const ProcessingConfig& processing_config)); MOCK_METHOD1(ApplyConfig, void(const Config& config)); MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config)); @@ -172,26 +172,30 @@ class MockAudioProcessing : public testing::NiceMock { MOCK_METHOD1(set_output_will_be_muted, void(bool muted)); MOCK_METHOD1(SetRuntimeSetting, void(RuntimeSetting setting)); MOCK_METHOD1(ProcessStream, int(AudioFrame* frame)); - MOCK_METHOD7(ProcessStream, int(const float* const* src, - size_t samples_per_channel, - int input_sample_rate_hz, - ChannelLayout input_layout, - int output_sample_rate_hz, - ChannelLayout output_layout, - float* const* dest)); - MOCK_METHOD4(ProcessStream, int(const float* const* src, - const StreamConfig& input_config, - const StreamConfig& output_config, - float* const* dest)); + MOCK_METHOD7(ProcessStream, + int(const float* const* src, + size_t samples_per_channel, + int input_sample_rate_hz, + ChannelLayout input_layout, + int output_sample_rate_hz, + ChannelLayout output_layout, + float* const* dest)); + MOCK_METHOD4(ProcessStream, + int(const float* const* src, + const StreamConfig& input_config, + const StreamConfig& output_config, + float* const* dest)); MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame)); - MOCK_METHOD4(AnalyzeReverseStream, int(const float* const* data, - size_t samples_per_channel, - int sample_rate_hz, - ChannelLayout layout)); - MOCK_METHOD4(ProcessReverseStream, int(const float* const* src, - const StreamConfig& input_config, - const StreamConfig& output_config, - float* const* dest)); + MOCK_METHOD4(AnalyzeReverseStream, + int(const float* const* data, + size_t samples_per_channel, + int sample_rate_hz, + ChannelLayout layout)); + MOCK_METHOD4(ProcessReverseStream, + int(const float* const* src, + const StreamConfig& input_config, + const StreamConfig& output_config, + float* const* dest)); MOCK_METHOD1(set_stream_delay_ms, int(int delay)); MOCK_CONST_METHOD0(stream_delay_ms, int()); MOCK_CONST_METHOD0(was_stream_delay_set, bool()); @@ -215,9 +219,7 @@ class MockAudioProcessing : public testing::NiceMock { virtual MockEchoControlMobile* echo_control_mobile() const { return echo_control_mobile_.get(); } - virtual MockGainControl* gain_control() const { - return gain_control_.get(); - } + virtual MockGainControl* gain_control() const { return gain_control_.get(); } virtual MockHighPassFilter* high_pass_filter() const { return high_pass_filter_.get(); } diff --git a/modules/audio_processing/intelligibility/intelligibility_enhancer.cc b/modules/audio_processing/intelligibility/intelligibility_enhancer.cc index 0e696d9fff..0f7b118ea1 100644 --- a/modules/audio_processing/intelligibility/intelligibility_enhancer.cc +++ b/modules/audio_processing/intelligibility/intelligibility_enhancer.cc @@ -31,16 +31,16 @@ const int kWindowSizeMs = 16; const int kChunkSizeMs = 10; // Size provided by APM. const float kClipFreqKhz = 0.2f; const float kKbdAlpha = 1.5f; -const float kLambdaBot = -1.f; // Extreme values in bisection -const float kLambdaTop = -1e-5f; // search for lamda. +const float kLambdaBot = -1.f; // Extreme values in bisection +const float kLambdaTop = -1e-5f; // search for lamda. const float kVoiceProbabilityThreshold = 0.5f; // Number of chunks after voice activity which is still considered speech. const size_t kSpeechOffsetDelay = 10; -const float kDecayRate = 0.995f; // Power estimation decay rate. +const float kDecayRate = 0.995f; // Power estimation decay rate. const float kMaxRelativeGainChange = 0.005f; const float kRho = 0.0004f; // Default production and interpretation SNR. const float kPowerNormalizationFactor = 1.f / (1 << 30); -const float kMaxActiveSNR = 128.f; // 21dB +const float kMaxActiveSNR = 128.f; // 21dB const float kMinInactiveSNR = 32.f; // 15dB const size_t kGainUpdatePeriod = 10u; @@ -133,8 +133,8 @@ IntelligibilityEnhancer::~IntelligibilityEnhancer() { } } -void IntelligibilityEnhancer::SetCaptureNoiseEstimate( - std::vector noise, float gain) { +void IntelligibilityEnhancer::SetCaptureNoiseEstimate(std::vector noise, + float gain) { RTC_DCHECK_EQ(noise.size(), num_noise_bins_); for (auto& bin : noise) { bin *= gain; @@ -176,10 +176,9 @@ void IntelligibilityEnhancer::ProcessAudioBlock( MapToErbBands(noise_power_estimator_.power().data(), capture_filter_bank_, filtered_noise_pow_.data()); SolveForGainsGivenLambda(kLambdaTop, start_freq_, gains_eq_.data()); - const float power_target = std::accumulate( - filtered_clear_pow_.data(), - filtered_clear_pow_.data() + bank_size_, - 0.f); + const float power_target = + std::accumulate(filtered_clear_pow_.data(), + filtered_clear_pow_.data() + bank_size_, 0.f); const float power_top = DotProduct(gains_eq_.data(), filtered_clear_pow_.data(), bank_size_); SolveForGainsGivenLambda(kLambdaBot, start_freq_, gains_eq_.data()); @@ -199,12 +198,11 @@ void IntelligibilityEnhancer::ProcessAudioBlock( void IntelligibilityEnhancer::SnrBasedEffectActivation() { const float* clear_psd = clear_power_estimator_.power().data(); const float* noise_psd = noise_power_estimator_.power().data(); - const float clear_power = - std::accumulate(clear_psd, clear_psd + freqs_, 0.f); - const float noise_power = - std::accumulate(noise_psd, noise_psd + freqs_, 0.f); - snr_ = kDecayRate * snr_ + (1.f - kDecayRate) * clear_power / - (noise_power + std::numeric_limits::epsilon()); + const float clear_power = std::accumulate(clear_psd, clear_psd + freqs_, 0.f); + const float noise_power = std::accumulate(noise_psd, noise_psd + freqs_, 0.f); + snr_ = kDecayRate * snr_ + + (1.f - kDecayRate) * clear_power / + (noise_power + std::numeric_limits::epsilon()); if (is_active_) { if (snr_ > kMaxActiveSNR) { RTC_LOG(LS_INFO) << "Intelligibility Enhancer was deactivated at chunk " diff --git a/modules/audio_processing/intelligibility/intelligibility_enhancer.h b/modules/audio_processing/intelligibility/intelligibility_enhancer.h index 3e0e269c58..35130921bb 100644 --- a/modules/audio_processing/intelligibility/intelligibility_enhancer.h +++ b/modules/audio_processing/intelligibility/intelligibility_enhancer.h @@ -93,7 +93,7 @@ class IntelligibilityEnhancer : public LappedTransform::Callback { static const size_t kMaxNumNoiseEstimatesToBuffer = 5; - const size_t freqs_; // Num frequencies in frequency domain. + const size_t freqs_; // Num frequencies in frequency domain. const size_t num_noise_bins_; const size_t chunk_length_; // Chunk size in samples. const size_t bank_size_; // Num ERB filters. diff --git a/modules/audio_processing/intelligibility/intelligibility_utils.cc b/modules/audio_processing/intelligibility/intelligibility_utils.cc index b6917f4407..b606d95132 100644 --- a/modules/audio_processing/intelligibility/intelligibility_utils.cc +++ b/modules/audio_processing/intelligibility/intelligibility_utils.cc @@ -37,11 +37,11 @@ float UpdateFactor(float target, float current, float limit) { } // namespace -template +template PowerEstimator::PowerEstimator(size_t num_freqs, float decay) : power_(num_freqs, 0.f), decay_(decay) {} -template +template void PowerEstimator::Step(const T* data) { for (size_t i = 0; i < power_.size(); ++i) { power_[i] = decay_ * power_[i] + diff --git a/modules/audio_processing/low_cut_filter_unittest.cc b/modules/audio_processing/low_cut_filter_unittest.cc index d98d665d37..d7b3cb963d 100644 --- a/modules/audio_processing/low_cut_filter_unittest.cc +++ b/modules/audio_processing/low_cut_filter_unittest.cc @@ -51,12 +51,10 @@ void RunBitexactnessTest(int sample_rate, (stream_config.num_frames() * stream_config.num_channels()); for (size_t frame_no = 0; frame_no < num_frames_to_process; ++frame_no) { std::vector frame_input( - input.begin() + - stream_config.num_frames() * stream_config.num_channels() * - frame_no, - input.begin() + - stream_config.num_frames() * stream_config.num_channels() * - (frame_no + 1)); + input.begin() + stream_config.num_frames() * + stream_config.num_channels() * frame_no, + input.begin() + stream_config.num_frames() * + stream_config.num_channels() * (frame_no + 1)); output = ProcessOneFrame(frame_input, stream_config, &low_cut_filter); } diff --git a/modules/audio_processing/noise_suppression_impl.cc b/modules/audio_processing/noise_suppression_impl.cc index 8dd713f4e5..15d404323c 100644 --- a/modules/audio_processing/noise_suppression_impl.cc +++ b/modules/audio_processing/noise_suppression_impl.cc @@ -37,10 +37,9 @@ class NoiseSuppressionImpl::Suppressor { int error = NS_INIT(state_, sample_rate_hz); RTC_DCHECK_EQ(0, error); } - ~Suppressor() { - NS_FREE(state_); - } + ~Suppressor() { NS_FREE(state_); } NsState* state() { return state_; } + private: NsState* state_ = nullptr; RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Suppressor); @@ -96,15 +95,11 @@ void NoiseSuppressionImpl::ProcessCaptureAudio(AudioBuffer* audio) { RTC_DCHECK_EQ(suppressors_.size(), audio->num_channels()); for (size_t i = 0; i < suppressors_.size(); i++) { #if defined(WEBRTC_NS_FLOAT) - WebRtcNs_Process(suppressors_[i]->state(), - audio->split_bands_const_f(i), - audio->num_bands(), - audio->split_bands_f(i)); + WebRtcNs_Process(suppressors_[i]->state(), audio->split_bands_const_f(i), + audio->num_bands(), audio->split_bands_f(i)); #elif defined(WEBRTC_NS_FIXED) - WebRtcNsx_Process(suppressors_[i]->state(), - audio->split_bands_const(i), - audio->num_bands(), - audio->split_bands(i)); + WebRtcNsx_Process(suppressors_[i]->state(), audio->split_bands_const(i), + audio->num_bands(), audio->split_bands(i)); #endif } } @@ -190,8 +185,8 @@ std::vector NoiseSuppressionImpl::NoiseEstimate() { noise_estimate.assign(WebRtcNsx_num_freq(), 0.f); for (auto& suppressor : suppressors_) { int q_noise; - const uint32_t* noise = WebRtcNsx_noise_estimate(suppressor->state(), - &q_noise); + const uint32_t* noise = + WebRtcNsx_noise_estimate(suppressor->state(), &q_noise); const float kNormalizationFactor = 1.f / ((1 << q_noise) * suppressors_.size()); for (size_t i = 0; i < noise_estimate.size(); ++i) { diff --git a/modules/audio_processing/noise_suppression_unittest.cc b/modules/audio_processing/noise_suppression_unittest.cc index 0b734fdd3f..b2074859b0 100644 --- a/modules/audio_processing/noise_suppression_unittest.cc +++ b/modules/audio_processing/noise_suppression_unittest.cc @@ -97,18 +97,18 @@ void RunBitexactnessTest(int sample_rate_hz, TEST(NoiseSuppresionBitExactnessTest, Mono8kHzLow) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {1432.341431f, 3321.919922f, 7677.521973f}; + const float kNoiseEstimateReference[] = {1432.341431f, 3321.919922f, + 7677.521973f}; const float kOutputReference[] = {0.003510f, 0.004517f, 0.004669f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {1432.341431f, 3321.919922f, 7677.521973f}; + const float kNoiseEstimateReference[] = {1432.341431f, 3321.919922f, + 7677.521973f}; const float kOutputReference[] = {0.003510f, 0.004517f, 0.004669f}; #else const float kSpeechProbabilityReference = 0.73421317f; - const float kNoiseEstimateReference[] = - {1175.266113f, 3289.305908f, 7532.991211f}; + const float kNoiseEstimateReference[] = {1175.266113f, 3289.305908f, + 7532.991211f}; const float kOutputReference[] = {0.003263f, 0.004402f, 0.004537f}; #endif @@ -120,18 +120,18 @@ TEST(NoiseSuppresionBitExactnessTest, Mono8kHzLow) { TEST(NoiseSuppresionBitExactnessTest, Mono16kHzLow) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2534.461914f, 6277.638672f, 14367.499023f}; + const float kNoiseEstimateReference[] = {2534.461914f, 6277.638672f, + 14367.499023f}; const float kOutputReference[] = {0.003449f, 0.004334f, 0.004303f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2534.461914f, 6277.638672f, 14367.499023f}; + const float kNoiseEstimateReference[] = {2534.461914f, 6277.638672f, + 14367.499023f}; const float kOutputReference[] = {0.003449f, 0.004334f, 0.004303f}; #else const float kSpeechProbabilityReference = 0.71672988f; - const float kNoiseEstimateReference[] = - {2151.313965f, 6509.765137f, 15658.848633f}; + const float kNoiseEstimateReference[] = {2151.313965f, 6509.765137f, + 15658.848633f}; const float kOutputReference[] = {0.003574f, 0.004494f, 0.004499f}; #endif @@ -143,18 +143,18 @@ TEST(NoiseSuppresionBitExactnessTest, Mono16kHzLow) { TEST(NoiseSuppresionBitExactnessTest, Mono32kHzLow) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2540.059082f, 6317.822754f, 14440.845703f}; + const float kNoiseEstimateReference[] = {2540.059082f, 6317.822754f, + 14440.845703f}; const float kOutputReference[] = {0.001679f, 0.002411f, 0.002594f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2540.059082f, 6317.822754f, 14440.845703f}; + const float kNoiseEstimateReference[] = {2540.059082f, 6317.822754f, + 14440.845703f}; const float kOutputReference[] = {0.001679f, 0.002411f, 0.002594f}; #else const float kSpeechProbabilityReference = 0.67999554f; - const float kNoiseEstimateReference[] = - {2149.780518f, 7076.936035f, 14939.945312f}; + const float kNoiseEstimateReference[] = {2149.780518f, 7076.936035f, + 14939.945312f}; const float kOutputReference[] = {0.001221f, 0.001984f, 0.002228f}; #endif @@ -166,18 +166,18 @@ TEST(NoiseSuppresionBitExactnessTest, Mono32kHzLow) { TEST(NoiseSuppresionBitExactnessTest, Mono48kHzLow) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2564.605713f, 6213.656250f, 13372.284180f}; + const float kNoiseEstimateReference[] = {2564.605713f, 6213.656250f, + 13372.284180f}; const float kOutputReference[] = {-0.013185f, -0.012769f, -0.012023f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2564.605713f, 6213.656250f, 13372.284180f}; + const float kNoiseEstimateReference[] = {2564.605713f, 6213.656250f, + 13372.284180f}; const float kOutputReference[] = {-0.013185f, -0.012769f, -0.012023f}; #else const float kSpeechProbabilityReference = 0.70645678f; - const float kNoiseEstimateReference[] = - {2168.783203f, 6902.895508f, 13190.677734f}; + const float kNoiseEstimateReference[] = {2168.783203f, 6902.895508f, + 13190.677734f}; const float kOutputReference[] = {-0.013062f, -0.012657f, -0.011934f}; #endif @@ -189,20 +189,20 @@ TEST(NoiseSuppresionBitExactnessTest, Mono48kHzLow) { TEST(NoiseSuppresionBitExactnessTest, Stereo16kHzLow) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {9992.127930f, 12689.569336f, 11589.296875f}; + const float kNoiseEstimateReference[] = {9992.127930f, 12689.569336f, + 11589.296875f}; const float kOutputReference[] = {-0.011108f, -0.007904f, -0.012390f, -0.002441f, 0.000855f, -0.003204f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {10321.353516f, 12133.852539f, 10923.060547f}; + const float kNoiseEstimateReference[] = {10321.353516f, 12133.852539f, + 10923.060547f}; const float kOutputReference[] = {-0.011108f, -0.007904f, -0.012390f, -0.002472f, 0.000916f, -0.003235f}; #else const float kSpeechProbabilityReference = 0.67230678f; - const float kNoiseEstimateReference[] = - {9771.250000f, 11329.377930f, 10503.052734f}; + const float kNoiseEstimateReference[] = {9771.250000f, 11329.377930f, + 10503.052734f}; const float kOutputReference[] = {-0.011459f, -0.008110f, -0.012728f, -0.002399f, 0.001018f, -0.003189f}; #endif @@ -215,18 +215,18 @@ TEST(NoiseSuppresionBitExactnessTest, Stereo16kHzLow) { TEST(NoiseSuppresionBitExactnessTest, Mono16kHzModerate) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2057.085938f, 7601.055176f, 19666.187500f}; + const float kNoiseEstimateReference[] = {2057.085938f, 7601.055176f, + 19666.187500f}; const float kOutputReference[] = {0.004669f, 0.005524f, 0.005432f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2244.497803f, 6864.164062f, 16726.523438f}; + const float kNoiseEstimateReference[] = {2244.497803f, 6864.164062f, + 16726.523438f}; const float kOutputReference[] = {0.004669f, 0.005615f, 0.005585f}; #else const float kSpeechProbabilityReference = 0.70897013f; - const float kNoiseEstimateReference[] = - {2171.490723f, 6553.567871f, 15626.562500f}; + const float kNoiseEstimateReference[] = {2171.490723f, 6553.567871f, + 15626.562500f}; const float kOutputReference[] = {0.004513f, 0.005590f, 0.005614f}; #endif @@ -238,18 +238,18 @@ TEST(NoiseSuppresionBitExactnessTest, Mono16kHzModerate) { TEST(NoiseSuppresionBitExactnessTest, Mono16kHzHigh) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2095.148193f, 7698.553711f, 19689.533203f}; + const float kNoiseEstimateReference[] = {2095.148193f, 7698.553711f, + 19689.533203f}; const float kOutputReference[] = {0.004639f, 0.005402f, 0.005310f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2282.515625f, 6984.408203f, 16920.960938f}; + const float kNoiseEstimateReference[] = {2282.515625f, 6984.408203f, + 16920.960938f}; const float kOutputReference[] = {0.004547f, 0.005432f, 0.005402f}; #else const float kSpeechProbabilityReference = 0.70106733f; - const float kNoiseEstimateReference[] = - {2224.968506f, 6712.025879f, 15785.087891f}; + const float kNoiseEstimateReference[] = {2224.968506f, 6712.025879f, + 15785.087891f}; const float kOutputReference[] = {0.004394f, 0.005406f, 0.005416f}; #endif @@ -261,18 +261,18 @@ TEST(NoiseSuppresionBitExactnessTest, Mono16kHzHigh) { TEST(NoiseSuppresionBitExactnessTest, Mono16kHzVeryHigh) { #if defined(WEBRTC_ARCH_ARM64) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2677.733398f, 6186.987305f, 14365.744141f}; + const float kNoiseEstimateReference[] = {2677.733398f, 6186.987305f, + 14365.744141f}; const float kOutputReference[] = {0.004273f, 0.005127f, 0.005188f}; #elif defined(WEBRTC_ARCH_ARM) const float kSpeechProbabilityReference = -4.0f; - const float kNoiseEstimateReference[] = - {2677.733398f, 6186.987305f, 14365.744141f}; + const float kNoiseEstimateReference[] = {2677.733398f, 6186.987305f, + 14365.744141f}; const float kOutputReference[] = {0.004273f, 0.005127f, 0.005188f}; #else const float kSpeechProbabilityReference = 0.70281971f; - const float kNoiseEstimateReference[] = - {2254.347900f, 6723.699707f, 15771.625977f}; + const float kNoiseEstimateReference[] = {2254.347900f, 6723.699707f, + 15771.625977f}; const float kOutputReference[] = {0.004321f, 0.005247f, 0.005263f}; #endif diff --git a/modules/audio_processing/ns/defines.h b/modules/audio_processing/ns/defines.h index 66b45a9565..d6abfea7e7 100644 --- a/modules/audio_processing/ns/defines.h +++ b/modules/audio_processing/ns/defines.h @@ -11,39 +11,45 @@ #ifndef MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ #define MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ -#define BLOCKL_MAX 160 // max processing block length: 160 -#define ANAL_BLOCKL_MAX 256 // max analysis block length: 256 -#define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1 -#define NUM_HIGH_BANDS_MAX 2 // max number of high bands: 2 +#define BLOCKL_MAX 160 // max processing block length: 160 +#define ANAL_BLOCKL_MAX 256 // max analysis block length: 256 +#define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1 +#define NUM_HIGH_BANDS_MAX 2 // max number of high bands: 2 -#define QUANTILE (float)0.25 +#define QUANTILE (float)0.25 -#define SIMULT 3 -#define END_STARTUP_LONG 200 -#define END_STARTUP_SHORT 50 -#define FACTOR (float)40.0 -#define WIDTH (float)0.01 +#define SIMULT 3 +#define END_STARTUP_LONG 200 +#define END_STARTUP_SHORT 50 +#define FACTOR (float)40.0 +#define WIDTH (float)0.01 // Length of fft work arrays. -#define IP_LENGTH (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2)) +#define IP_LENGTH \ + (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2)) #define W_LENGTH (ANAL_BLOCKL_MAX >> 1) -//PARAMETERS FOR NEW METHOD -#define DD_PR_SNR (float)0.98 // DD update of prior SNR -#define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90) -#define SPECT_FL_TAVG (float)0.30 // tavg parameter for spectral flatness measure -#define SPECT_DIFF_TAVG (float)0.30 // tavg parameter for spectral difference measure -#define PRIOR_UPDATE (float)0.10 // update parameter of prior model -#define NOISE_UPDATE (float)0.90 // update parameter for noise -#define SPEECH_UPDATE (float)0.99 // update parameter when likely speech -#define WIDTH_PR_MAP (float)4.0 // width parameter in sigmoid map for prior model -#define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature -#define SF_FEATURE_THR (float)0.5 // default threshold for Spectral Flatness feature -#define SD_FEATURE_THR (float)0.5 // default threshold for Spectral Difference feature -#define PROB_RANGE (float)0.20 // probability threshold for noise state in - // speech/noise likelihood -#define HIST_PAR_EST 1000 // histogram size for estimation of parameters -#define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate +// PARAMETERS FOR NEW METHOD +#define DD_PR_SNR (float)0.98 // DD update of prior SNR +#define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90) +#define SPECT_FL_TAVG \ + (float)0.30 // tavg parameter for spectral flatness measure +#define SPECT_DIFF_TAVG \ + (float)0.30 // tavg parameter for spectral difference measure +#define PRIOR_UPDATE (float)0.10 // update parameter of prior model +#define NOISE_UPDATE (float)0.90 // update parameter for noise +#define SPEECH_UPDATE (float)0.99 // update parameter when likely speech +#define WIDTH_PR_MAP \ + (float)4.0 // width parameter in sigmoid map for prior model +#define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature +#define SF_FEATURE_THR \ + (float)0.5 // default threshold for Spectral Flatness feature +#define SD_FEATURE_THR \ + (float)0.5 // default threshold for Spectral Difference feature +#define PROB_RANGE (float)0.20 // probability threshold for noise state in + // speech/noise likelihood +#define HIST_PAR_EST 1000 // histogram size for estimation of parameters +#define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate // -#define B_LIM (float)0.5 // threshold in final energy gain factor calculation -#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ +#define B_LIM (float)0.5 // threshold in final energy gain factor calculation +#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ diff --git a/modules/audio_processing/ns/noise_suppression.h b/modules/audio_processing/ns/noise_suppression.h index fa5da70189..fd6aa961c1 100644 --- a/modules/audio_processing/ns/noise_suppression.h +++ b/modules/audio_processing/ns/noise_suppression.h @@ -93,9 +93,9 @@ void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe); * - outframe : Pointer to output frame for each band */ void WebRtcNs_Process(NsHandle* NS_inst, - const float* const* spframe, - size_t num_bands, - float* const* outframe); + const float* const* spframe, + size_t num_bands, + float* const* outframe); /* Returns the internally used prior speech probability of the current frame. * There is a frequency bin based one as well, with which this should not be diff --git a/modules/audio_processing/ns/ns_core.h b/modules/audio_processing/ns/ns_core.h index 990d363223..e90b8ce39b 100644 --- a/modules/audio_processing/ns/ns_core.h +++ b/modules/audio_processing/ns/ns_core.h @@ -78,26 +78,26 @@ typedef struct NoiseSuppressionC_ { float wfft[W_LENGTH]; // Parameters for new method: some not needed, will reduce/cleanup later. - int32_t blockInd; // Frame index counter. + int32_t blockInd; // Frame index counter. int modelUpdatePars[4]; // Parameters for updating or estimating. // Thresholds/weights for prior model. - float priorModelPars[7]; // Parameters for prior model. - float noise[HALF_ANAL_BLOCKL]; // Noise spectrum from current frame. + float priorModelPars[7]; // Parameters for prior model. + float noise[HALF_ANAL_BLOCKL]; // Noise spectrum from current frame. float noisePrev[HALF_ANAL_BLOCKL]; // Noise spectrum from previous frame. // Magnitude spectrum of previous analyze frame. float magnPrevAnalyze[HALF_ANAL_BLOCKL]; // Magnitude spectrum of previous process frame. float magnPrevProcess[HALF_ANAL_BLOCKL]; float logLrtTimeAvg[HALF_ANAL_BLOCKL]; // Log LRT factor with time-smoothing. - float priorSpeechProb; // Prior speech/noise probability. + float priorSpeechProb; // Prior speech/noise probability. float featureData[7]; // Conservative noise spectrum estimate. float magnAvgPause[HALF_ANAL_BLOCKL]; float signalEnergy; // Energy of |magn|. float sumMagn; - float whiteNoiseLevel; // Initial noise estimate. + float whiteNoiseLevel; // Initial noise estimate. float initMagnEst[HALF_ANAL_BLOCKL]; // Initial magnitude spectrum estimate. - float pinkNoiseNumerator; // Pink noise parameter: numerator. + float pinkNoiseNumerator; // Pink noise parameter: numerator. float pinkNoiseExp; // Pink noise parameter: power of frequencies. float parametricNoise[HALF_ANAL_BLOCKL]; // Parameters for feature extraction. diff --git a/modules/audio_processing/ns/nsx_core.h b/modules/audio_processing/ns/nsx_core.h index c8097f7946..479e90c83e 100644 --- a/modules/audio_processing/ns/nsx_core.h +++ b/modules/audio_processing/ns/nsx_core.h @@ -20,98 +20,97 @@ #include "typedefs.h" // NOLINT(build/include) typedef struct NoiseSuppressionFixedC_ { - uint32_t fs; + uint32_t fs; - const int16_t* window; - int16_t analysisBuffer[ANAL_BLOCKL_MAX]; - int16_t synthesisBuffer[ANAL_BLOCKL_MAX]; - uint16_t noiseSupFilter[HALF_ANAL_BLOCKL]; - uint16_t overdrive; /* Q8 */ - uint16_t denoiseBound; /* Q14 */ - const int16_t* factor2Table; - int16_t noiseEstLogQuantile[SIMULT* HALF_ANAL_BLOCKL]; - int16_t noiseEstDensity[SIMULT* HALF_ANAL_BLOCKL]; - int16_t noiseEstCounter[SIMULT]; - int16_t noiseEstQuantile[HALF_ANAL_BLOCKL]; + const int16_t* window; + int16_t analysisBuffer[ANAL_BLOCKL_MAX]; + int16_t synthesisBuffer[ANAL_BLOCKL_MAX]; + uint16_t noiseSupFilter[HALF_ANAL_BLOCKL]; + uint16_t overdrive; /* Q8 */ + uint16_t denoiseBound; /* Q14 */ + const int16_t* factor2Table; + int16_t noiseEstLogQuantile[SIMULT * HALF_ANAL_BLOCKL]; + int16_t noiseEstDensity[SIMULT * HALF_ANAL_BLOCKL]; + int16_t noiseEstCounter[SIMULT]; + int16_t noiseEstQuantile[HALF_ANAL_BLOCKL]; - size_t anaLen; - size_t anaLen2; - size_t magnLen; - int aggrMode; - int stages; - int initFlag; - int gainMap; + size_t anaLen; + size_t anaLen2; + size_t magnLen; + int aggrMode; + int stages; + int initFlag; + int gainMap; - int32_t maxLrt; - int32_t minLrt; + int32_t maxLrt; + int32_t minLrt; // Log LRT factor with time-smoothing in Q8. - int32_t logLrtTimeAvgW32[HALF_ANAL_BLOCKL]; - int32_t featureLogLrt; - int32_t thresholdLogLrt; - int16_t weightLogLrt; + int32_t logLrtTimeAvgW32[HALF_ANAL_BLOCKL]; + int32_t featureLogLrt; + int32_t thresholdLogLrt; + int16_t weightLogLrt; - uint32_t featureSpecDiff; - uint32_t thresholdSpecDiff; - int16_t weightSpecDiff; + uint32_t featureSpecDiff; + uint32_t thresholdSpecDiff; + int16_t weightSpecDiff; - uint32_t featureSpecFlat; - uint32_t thresholdSpecFlat; - int16_t weightSpecFlat; + uint32_t featureSpecFlat; + uint32_t thresholdSpecFlat; + int16_t weightSpecFlat; // Conservative estimate of noise spectrum. - int32_t avgMagnPause[HALF_ANAL_BLOCKL]; - uint32_t magnEnergy; - uint32_t sumMagn; - uint32_t curAvgMagnEnergy; - uint32_t timeAvgMagnEnergy; - uint32_t timeAvgMagnEnergyTmp; + int32_t avgMagnPause[HALF_ANAL_BLOCKL]; + uint32_t magnEnergy; + uint32_t sumMagn; + uint32_t curAvgMagnEnergy; + uint32_t timeAvgMagnEnergy; + uint32_t timeAvgMagnEnergyTmp; - uint32_t whiteNoiseLevel; // Initial noise estimate. + uint32_t whiteNoiseLevel; // Initial noise estimate. // Initial magnitude spectrum estimate. - uint32_t initMagnEst[HALF_ANAL_BLOCKL]; + uint32_t initMagnEst[HALF_ANAL_BLOCKL]; // Pink noise parameters: - int32_t pinkNoiseNumerator; // Numerator. - int32_t pinkNoiseExp; // Power of freq. - int minNorm; // Smallest normalization factor. - int zeroInputSignal; // Zero input signal flag. + int32_t pinkNoiseNumerator; // Numerator. + int32_t pinkNoiseExp; // Power of freq. + int minNorm; // Smallest normalization factor. + int zeroInputSignal; // Zero input signal flag. // Noise spectrum from previous frame. - uint32_t prevNoiseU32[HALF_ANAL_BLOCKL]; + uint32_t prevNoiseU32[HALF_ANAL_BLOCKL]; // Magnitude spectrum from previous frame. - uint16_t prevMagnU16[HALF_ANAL_BLOCKL]; + uint16_t prevMagnU16[HALF_ANAL_BLOCKL]; // Prior speech/noise probability in Q14. - int16_t priorNonSpeechProb; + int16_t priorNonSpeechProb; - int blockIndex; // Frame index counter. + int blockIndex; // Frame index counter. // Parameter for updating or estimating thresholds/weights for prior model. - int modelUpdate; - int cntThresUpdate; + int modelUpdate; + int cntThresUpdate; // Histograms for parameter estimation. - int16_t histLrt[HIST_PAR_EST]; - int16_t histSpecFlat[HIST_PAR_EST]; - int16_t histSpecDiff[HIST_PAR_EST]; + int16_t histLrt[HIST_PAR_EST]; + int16_t histSpecFlat[HIST_PAR_EST]; + int16_t histSpecDiff[HIST_PAR_EST]; // Quantities for high band estimate. - int16_t dataBufHBFX[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX]; + int16_t dataBufHBFX[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX]; - int qNoise; - int prevQNoise; - int prevQMagn; - size_t blockLen10ms; + int qNoise; + int prevQNoise; + int prevQMagn; + size_t blockLen10ms; - int16_t real[ANAL_BLOCKL_MAX]; - int16_t imag[ANAL_BLOCKL_MAX]; - int32_t energyIn; - int scaleEnergyIn; - int normData; + int16_t real[ANAL_BLOCKL_MAX]; + int16_t imag[ANAL_BLOCKL_MAX]; + int32_t energyIn; + int scaleEnergyIn; + int normData; struct RealFFT* real_fft; } NoiseSuppressionFixedC; #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /**************************************************************************** diff --git a/modules/audio_processing/ns/nsx_defines.h b/modules/audio_processing/ns/nsx_defines.h index 12869b3cf5..dc14dbc793 100644 --- a/modules/audio_processing/ns/nsx_defines.h +++ b/modules/audio_processing/ns/nsx_defines.h @@ -11,54 +11,64 @@ #ifndef MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ #define MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ -#define ANAL_BLOCKL_MAX 256 /* Max analysis block length */ -#define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */ -#define NUM_HIGH_BANDS_MAX 2 /* Max number of high bands */ -#define SIMULT 3 -#define END_STARTUP_LONG 200 -#define END_STARTUP_SHORT 50 -#define FACTOR_Q16 2621440 /* 40 in Q16 */ -#define FACTOR_Q7 5120 /* 40 in Q7 */ -#define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */ -#define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */ +#define ANAL_BLOCKL_MAX 256 /* Max analysis block length */ +#define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */ +#define NUM_HIGH_BANDS_MAX 2 /* Max number of high bands */ +#define SIMULT 3 +#define END_STARTUP_LONG 200 +#define END_STARTUP_SHORT 50 +#define FACTOR_Q16 2621440 /* 40 in Q16 */ +#define FACTOR_Q7 5120 /* 40 in Q7 */ +#define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */ +#define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */ /* PARAMETERS FOR NEW METHOD */ -#define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */ +#define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */ #define ONE_MINUS_DD_PR_SNR_Q11 41 /* DD update of prior SNR */ -#define SPECT_FLAT_TAVG_Q14 4915 /* (0.30) tavg parameter for spectral flatness measure */ -#define SPECT_DIFF_TAVG_Q8 77 /* (0.30) tavg parameter for spectral flatness measure */ -#define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */ -#define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */ +#define SPECT_FLAT_TAVG_Q14 \ + 4915 /* (0.30) tavg parameter for spectral flatness measure */ +#define SPECT_DIFF_TAVG_Q8 \ + 77 /* (0.30) tavg parameter for spectral flatness measure */ +#define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */ +#define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */ /* Probability threshold for noise state in speech/noise likelihood. */ #define ONE_MINUS_PROB_RANGE_Q8 205 /* 205 ~= Q8(0.8) */ -#define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */ +#define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */ /* FEATURE EXTRACTION CONFIG */ /* Bin size of histogram */ -#define BIN_SIZE_LRT 10 -/* Scale parameters: multiply dominant peaks of the histograms by scale factor to obtain. */ +#define BIN_SIZE_LRT 10 +/* Scale parameters: multiply dominant peaks of the histograms by scale factor + * to obtain. */ /* Thresholds for prior model */ -#define FACTOR_1_LRT_DIFF 6 /* For LRT and spectral difference (5 times bigger) */ -/* For spectral_flatness: used when noise is flatter than speech (10 times bigger). */ -#define FACTOR_2_FLAT_Q10 922 +#define FACTOR_1_LRT_DIFF \ + 6 /* For LRT and spectral difference (5 times bigger) */ +/* For spectral_flatness: used when noise is flatter than speech (10 times + * bigger). */ +#define FACTOR_2_FLAT_Q10 922 /* Peak limit for spectral flatness (varies between 0 and 1) */ -#define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */ -/* Limit on spacing of two highest peaks in histogram: spacing determined by bin size. */ -#define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */ +#define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */ +/* Limit on spacing of two highest peaks in histogram: spacing determined by bin + * size. */ +#define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */ /* Limit on relevance of second peak */ -#define LIM_PEAK_WEIGHT_FLAT_DIFF 2 -#define THRES_FLUCT_LRT 10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */ +#define LIM_PEAK_WEIGHT_FLAT_DIFF 2 +#define THRES_FLUCT_LRT \ + 10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */ /* Limit on the max and min values for the feature thresholds */ -#define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */ -#define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */ -#define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */ -#define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */ +#define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */ +#define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */ +#define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */ +#define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */ /* Criteria of weight of histogram peak to accept/reject feature */ -#define THRES_WEIGHT_FLAT_DIFF 154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */ +#define THRES_WEIGHT_FLAT_DIFF \ + 154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */ -#define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */ -#define ONE_MINUS_GAMMA_PAUSE_Q8 13 /* ~= Q8(0.05) Update for conservative noise estimate */ -#define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 3 /* ~= Q8(0.01) Update for transition and noise region */ +#define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */ +#define ONE_MINUS_GAMMA_PAUSE_Q8 \ + 13 /* ~= Q8(0.05) Update for conservative noise estimate */ +#define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 \ + 3 /* ~= Q8(0.01) Update for transition and noise region */ #endif /* MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ */ diff --git a/modules/audio_processing/ns/windows_private.h b/modules/audio_processing/ns/windows_private.h index 2ffd693d8d..17792ecdfe 100644 --- a/modules/audio_processing/ns/windows_private.h +++ b/modules/audio_processing/ns/windows_private.h @@ -13,562 +13,660 @@ // Hanning window for 4ms 16kHz static const float kHanning64w128[128] = { - 0.00000000000000f, 0.02454122852291f, 0.04906767432742f, - 0.07356456359967f, 0.09801714032956f, 0.12241067519922f, - 0.14673047445536f, 0.17096188876030f, 0.19509032201613f, - 0.21910124015687f, 0.24298017990326f, 0.26671275747490f, - 0.29028467725446f, 0.31368174039889f, 0.33688985339222f, - 0.35989503653499f, 0.38268343236509f, 0.40524131400499f, - 0.42755509343028f, 0.44961132965461f, 0.47139673682600f, - 0.49289819222978f, 0.51410274419322f, 0.53499761988710f, - 0.55557023301960f, 0.57580819141785f, 0.59569930449243f, - 0.61523159058063f, 0.63439328416365f, 0.65317284295378f, - 0.67155895484702f, 0.68954054473707f, 0.70710678118655f, - 0.72424708295147f, 0.74095112535496f, 0.75720884650648f, - 0.77301045336274f, 0.78834642762661f, 0.80320753148064f, - 0.81758481315158f, 0.83146961230255f, 0.84485356524971f, - 0.85772861000027f, 0.87008699110871f, 0.88192126434835f, - 0.89322430119552f, 0.90398929312344f, 0.91420975570353f, - 0.92387953251129f, 0.93299279883474f, 0.94154406518302f, - 0.94952818059304f, 0.95694033573221f, 0.96377606579544f, - 0.97003125319454f, 0.97570213003853f, 0.98078528040323f, - 0.98527764238894f, 0.98917650996478f, 0.99247953459871f, - 0.99518472667220f, 0.99729045667869f, 0.99879545620517f, - 0.99969881869620f, 1.00000000000000f, - 0.99969881869620f, 0.99879545620517f, 0.99729045667869f, - 0.99518472667220f, 0.99247953459871f, 0.98917650996478f, - 0.98527764238894f, 0.98078528040323f, 0.97570213003853f, - 0.97003125319454f, 0.96377606579544f, 0.95694033573221f, - 0.94952818059304f, 0.94154406518302f, 0.93299279883474f, - 0.92387953251129f, 0.91420975570353f, 0.90398929312344f, - 0.89322430119552f, 0.88192126434835f, 0.87008699110871f, - 0.85772861000027f, 0.84485356524971f, 0.83146961230255f, - 0.81758481315158f, 0.80320753148064f, 0.78834642762661f, - 0.77301045336274f, 0.75720884650648f, 0.74095112535496f, - 0.72424708295147f, 0.70710678118655f, 0.68954054473707f, - 0.67155895484702f, 0.65317284295378f, 0.63439328416365f, - 0.61523159058063f, 0.59569930449243f, 0.57580819141785f, - 0.55557023301960f, 0.53499761988710f, 0.51410274419322f, - 0.49289819222978f, 0.47139673682600f, 0.44961132965461f, - 0.42755509343028f, 0.40524131400499f, 0.38268343236509f, - 0.35989503653499f, 0.33688985339222f, 0.31368174039889f, - 0.29028467725446f, 0.26671275747490f, 0.24298017990326f, - 0.21910124015687f, 0.19509032201613f, 0.17096188876030f, - 0.14673047445536f, 0.12241067519922f, 0.09801714032956f, - 0.07356456359967f, 0.04906767432742f, 0.02454122852291f -}; - - + 0.00000000000000f, 0.02454122852291f, 0.04906767432742f, 0.07356456359967f, + 0.09801714032956f, 0.12241067519922f, 0.14673047445536f, 0.17096188876030f, + 0.19509032201613f, 0.21910124015687f, 0.24298017990326f, 0.26671275747490f, + 0.29028467725446f, 0.31368174039889f, 0.33688985339222f, 0.35989503653499f, + 0.38268343236509f, 0.40524131400499f, 0.42755509343028f, 0.44961132965461f, + 0.47139673682600f, 0.49289819222978f, 0.51410274419322f, 0.53499761988710f, + 0.55557023301960f, 0.57580819141785f, 0.59569930449243f, 0.61523159058063f, + 0.63439328416365f, 0.65317284295378f, 0.67155895484702f, 0.68954054473707f, + 0.70710678118655f, 0.72424708295147f, 0.74095112535496f, 0.75720884650648f, + 0.77301045336274f, 0.78834642762661f, 0.80320753148064f, 0.81758481315158f, + 0.83146961230255f, 0.84485356524971f, 0.85772861000027f, 0.87008699110871f, + 0.88192126434835f, 0.89322430119552f, 0.90398929312344f, 0.91420975570353f, + 0.92387953251129f, 0.93299279883474f, 0.94154406518302f, 0.94952818059304f, + 0.95694033573221f, 0.96377606579544f, 0.97003125319454f, 0.97570213003853f, + 0.98078528040323f, 0.98527764238894f, 0.98917650996478f, 0.99247953459871f, + 0.99518472667220f, 0.99729045667869f, 0.99879545620517f, 0.99969881869620f, + 1.00000000000000f, 0.99969881869620f, 0.99879545620517f, 0.99729045667869f, + 0.99518472667220f, 0.99247953459871f, 0.98917650996478f, 0.98527764238894f, + 0.98078528040323f, 0.97570213003853f, 0.97003125319454f, 0.96377606579544f, + 0.95694033573221f, 0.94952818059304f, 0.94154406518302f, 0.93299279883474f, + 0.92387953251129f, 0.91420975570353f, 0.90398929312344f, 0.89322430119552f, + 0.88192126434835f, 0.87008699110871f, 0.85772861000027f, 0.84485356524971f, + 0.83146961230255f, 0.81758481315158f, 0.80320753148064f, 0.78834642762661f, + 0.77301045336274f, 0.75720884650648f, 0.74095112535496f, 0.72424708295147f, + 0.70710678118655f, 0.68954054473707f, 0.67155895484702f, 0.65317284295378f, + 0.63439328416365f, 0.61523159058063f, 0.59569930449243f, 0.57580819141785f, + 0.55557023301960f, 0.53499761988710f, 0.51410274419322f, 0.49289819222978f, + 0.47139673682600f, 0.44961132965461f, 0.42755509343028f, 0.40524131400499f, + 0.38268343236509f, 0.35989503653499f, 0.33688985339222f, 0.31368174039889f, + 0.29028467725446f, 0.26671275747490f, 0.24298017990326f, 0.21910124015687f, + 0.19509032201613f, 0.17096188876030f, 0.14673047445536f, 0.12241067519922f, + 0.09801714032956f, 0.07356456359967f, 0.04906767432742f, 0.02454122852291f}; // hybrib Hanning & flat window static const float kBlocks80w128[128] = { - (float)0.00000000, (float)0.03271908, (float)0.06540313, (float)0.09801714, (float)0.13052619, - (float)0.16289547, (float)0.19509032, (float)0.22707626, (float)0.25881905, (float)0.29028468, - (float)0.32143947, (float)0.35225005, (float)0.38268343, (float)0.41270703, (float)0.44228869, - (float)0.47139674, (float)0.50000000, (float)0.52806785, (float)0.55557023, (float)0.58247770, - (float)0.60876143, (float)0.63439328, (float)0.65934582, (float)0.68359230, (float)0.70710678, - (float)0.72986407, (float)0.75183981, (float)0.77301045, (float)0.79335334, (float)0.81284668, - (float)0.83146961, (float)0.84920218, (float)0.86602540, (float)0.88192126, (float)0.89687274, - (float)0.91086382, (float)0.92387953, (float)0.93590593, (float)0.94693013, (float)0.95694034, - (float)0.96592583, (float)0.97387698, (float)0.98078528, (float)0.98664333, (float)0.99144486, - (float)0.99518473, (float)0.99785892, (float)0.99946459, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)0.99946459, (float)0.99785892, (float)0.99518473, (float)0.99144486, - (float)0.98664333, (float)0.98078528, (float)0.97387698, (float)0.96592583, (float)0.95694034, - (float)0.94693013, (float)0.93590593, (float)0.92387953, (float)0.91086382, (float)0.89687274, - (float)0.88192126, (float)0.86602540, (float)0.84920218, (float)0.83146961, (float)0.81284668, - (float)0.79335334, (float)0.77301045, (float)0.75183981, (float)0.72986407, (float)0.70710678, - (float)0.68359230, (float)0.65934582, (float)0.63439328, (float)0.60876143, (float)0.58247770, - (float)0.55557023, (float)0.52806785, (float)0.50000000, (float)0.47139674, (float)0.44228869, - (float)0.41270703, (float)0.38268343, (float)0.35225005, (float)0.32143947, (float)0.29028468, - (float)0.25881905, (float)0.22707626, (float)0.19509032, (float)0.16289547, (float)0.13052619, - (float)0.09801714, (float)0.06540313, (float)0.03271908 -}; + (float)0.00000000, (float)0.03271908, (float)0.06540313, (float)0.09801714, + (float)0.13052619, (float)0.16289547, (float)0.19509032, (float)0.22707626, + (float)0.25881905, (float)0.29028468, (float)0.32143947, (float)0.35225005, + (float)0.38268343, (float)0.41270703, (float)0.44228869, (float)0.47139674, + (float)0.50000000, (float)0.52806785, (float)0.55557023, (float)0.58247770, + (float)0.60876143, (float)0.63439328, (float)0.65934582, (float)0.68359230, + (float)0.70710678, (float)0.72986407, (float)0.75183981, (float)0.77301045, + (float)0.79335334, (float)0.81284668, (float)0.83146961, (float)0.84920218, + (float)0.86602540, (float)0.88192126, (float)0.89687274, (float)0.91086382, + (float)0.92387953, (float)0.93590593, (float)0.94693013, (float)0.95694034, + (float)0.96592583, (float)0.97387698, (float)0.98078528, (float)0.98664333, + (float)0.99144486, (float)0.99518473, (float)0.99785892, (float)0.99946459, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)0.99946459, (float)0.99785892, (float)0.99518473, + (float)0.99144486, (float)0.98664333, (float)0.98078528, (float)0.97387698, + (float)0.96592583, (float)0.95694034, (float)0.94693013, (float)0.93590593, + (float)0.92387953, (float)0.91086382, (float)0.89687274, (float)0.88192126, + (float)0.86602540, (float)0.84920218, (float)0.83146961, (float)0.81284668, + (float)0.79335334, (float)0.77301045, (float)0.75183981, (float)0.72986407, + (float)0.70710678, (float)0.68359230, (float)0.65934582, (float)0.63439328, + (float)0.60876143, (float)0.58247770, (float)0.55557023, (float)0.52806785, + (float)0.50000000, (float)0.47139674, (float)0.44228869, (float)0.41270703, + (float)0.38268343, (float)0.35225005, (float)0.32143947, (float)0.29028468, + (float)0.25881905, (float)0.22707626, (float)0.19509032, (float)0.16289547, + (float)0.13052619, (float)0.09801714, (float)0.06540313, (float)0.03271908}; // hybrib Hanning & flat window static const float kBlocks160w256[256] = { - (float)0.00000000, (float)0.01636173, (float)0.03271908, (float)0.04906767, (float)0.06540313, - (float)0.08172107, (float)0.09801714, (float)0.11428696, (float)0.13052619, (float)0.14673047, - (float)0.16289547, (float)0.17901686, (float)0.19509032, (float)0.21111155, (float)0.22707626, - (float)0.24298018, (float)0.25881905, (float)0.27458862, (float)0.29028468, (float)0.30590302, - (float)0.32143947, (float)0.33688985, (float)0.35225005, (float)0.36751594, (float)0.38268343, - (float)0.39774847, (float)0.41270703, (float)0.42755509, (float)0.44228869, (float)0.45690388, - (float)0.47139674, (float)0.48576339, (float)0.50000000, (float)0.51410274, (float)0.52806785, - (float)0.54189158, (float)0.55557023, (float)0.56910015, (float)0.58247770, (float)0.59569930, - (float)0.60876143, (float)0.62166057, (float)0.63439328, (float)0.64695615, (float)0.65934582, - (float)0.67155895, (float)0.68359230, (float)0.69544264, (float)0.70710678, (float)0.71858162, - (float)0.72986407, (float)0.74095113, (float)0.75183981, (float)0.76252720, (float)0.77301045, - (float)0.78328675, (float)0.79335334, (float)0.80320753, (float)0.81284668, (float)0.82226822, - (float)0.83146961, (float)0.84044840, (float)0.84920218, (float)0.85772861, (float)0.86602540, - (float)0.87409034, (float)0.88192126, (float)0.88951608, (float)0.89687274, (float)0.90398929, - (float)0.91086382, (float)0.91749450, (float)0.92387953, (float)0.93001722, (float)0.93590593, - (float)0.94154407, (float)0.94693013, (float)0.95206268, (float)0.95694034, (float)0.96156180, - (float)0.96592583, (float)0.97003125, (float)0.97387698, (float)0.97746197, (float)0.98078528, - (float)0.98384601, (float)0.98664333, (float)0.98917651, (float)0.99144486, (float)0.99344778, - (float)0.99518473, (float)0.99665524, (float)0.99785892, (float)0.99879546, (float)0.99946459, - (float)0.99986614, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)0.99986614, (float)0.99946459, (float)0.99879546, (float)0.99785892, - (float)0.99665524, (float)0.99518473, (float)0.99344778, (float)0.99144486, (float)0.98917651, - (float)0.98664333, (float)0.98384601, (float)0.98078528, (float)0.97746197, (float)0.97387698, - (float)0.97003125, (float)0.96592583, (float)0.96156180, (float)0.95694034, (float)0.95206268, - (float)0.94693013, (float)0.94154407, (float)0.93590593, (float)0.93001722, (float)0.92387953, - (float)0.91749450, (float)0.91086382, (float)0.90398929, (float)0.89687274, (float)0.88951608, - (float)0.88192126, (float)0.87409034, (float)0.86602540, (float)0.85772861, (float)0.84920218, - (float)0.84044840, (float)0.83146961, (float)0.82226822, (float)0.81284668, (float)0.80320753, - (float)0.79335334, (float)0.78328675, (float)0.77301045, (float)0.76252720, (float)0.75183981, - (float)0.74095113, (float)0.72986407, (float)0.71858162, (float)0.70710678, (float)0.69544264, - (float)0.68359230, (float)0.67155895, (float)0.65934582, (float)0.64695615, (float)0.63439328, - (float)0.62166057, (float)0.60876143, (float)0.59569930, (float)0.58247770, (float)0.56910015, - (float)0.55557023, (float)0.54189158, (float)0.52806785, (float)0.51410274, (float)0.50000000, - (float)0.48576339, (float)0.47139674, (float)0.45690388, (float)0.44228869, (float)0.42755509, - (float)0.41270703, (float)0.39774847, (float)0.38268343, (float)0.36751594, (float)0.35225005, - (float)0.33688985, (float)0.32143947, (float)0.30590302, (float)0.29028468, (float)0.27458862, - (float)0.25881905, (float)0.24298018, (float)0.22707626, (float)0.21111155, (float)0.19509032, - (float)0.17901686, (float)0.16289547, (float)0.14673047, (float)0.13052619, (float)0.11428696, - (float)0.09801714, (float)0.08172107, (float)0.06540313, (float)0.04906767, (float)0.03271908, - (float)0.01636173 -}; + (float)0.00000000, (float)0.01636173, (float)0.03271908, (float)0.04906767, + (float)0.06540313, (float)0.08172107, (float)0.09801714, (float)0.11428696, + (float)0.13052619, (float)0.14673047, (float)0.16289547, (float)0.17901686, + (float)0.19509032, (float)0.21111155, (float)0.22707626, (float)0.24298018, + (float)0.25881905, (float)0.27458862, (float)0.29028468, (float)0.30590302, + (float)0.32143947, (float)0.33688985, (float)0.35225005, (float)0.36751594, + (float)0.38268343, (float)0.39774847, (float)0.41270703, (float)0.42755509, + (float)0.44228869, (float)0.45690388, (float)0.47139674, (float)0.48576339, + (float)0.50000000, (float)0.51410274, (float)0.52806785, (float)0.54189158, + (float)0.55557023, (float)0.56910015, (float)0.58247770, (float)0.59569930, + (float)0.60876143, (float)0.62166057, (float)0.63439328, (float)0.64695615, + (float)0.65934582, (float)0.67155895, (float)0.68359230, (float)0.69544264, + (float)0.70710678, (float)0.71858162, (float)0.72986407, (float)0.74095113, + (float)0.75183981, (float)0.76252720, (float)0.77301045, (float)0.78328675, + (float)0.79335334, (float)0.80320753, (float)0.81284668, (float)0.82226822, + (float)0.83146961, (float)0.84044840, (float)0.84920218, (float)0.85772861, + (float)0.86602540, (float)0.87409034, (float)0.88192126, (float)0.88951608, + (float)0.89687274, (float)0.90398929, (float)0.91086382, (float)0.91749450, + (float)0.92387953, (float)0.93001722, (float)0.93590593, (float)0.94154407, + (float)0.94693013, (float)0.95206268, (float)0.95694034, (float)0.96156180, + (float)0.96592583, (float)0.97003125, (float)0.97387698, (float)0.97746197, + (float)0.98078528, (float)0.98384601, (float)0.98664333, (float)0.98917651, + (float)0.99144486, (float)0.99344778, (float)0.99518473, (float)0.99665524, + (float)0.99785892, (float)0.99879546, (float)0.99946459, (float)0.99986614, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)0.99986614, (float)0.99946459, (float)0.99879546, + (float)0.99785892, (float)0.99665524, (float)0.99518473, (float)0.99344778, + (float)0.99144486, (float)0.98917651, (float)0.98664333, (float)0.98384601, + (float)0.98078528, (float)0.97746197, (float)0.97387698, (float)0.97003125, + (float)0.96592583, (float)0.96156180, (float)0.95694034, (float)0.95206268, + (float)0.94693013, (float)0.94154407, (float)0.93590593, (float)0.93001722, + (float)0.92387953, (float)0.91749450, (float)0.91086382, (float)0.90398929, + (float)0.89687274, (float)0.88951608, (float)0.88192126, (float)0.87409034, + (float)0.86602540, (float)0.85772861, (float)0.84920218, (float)0.84044840, + (float)0.83146961, (float)0.82226822, (float)0.81284668, (float)0.80320753, + (float)0.79335334, (float)0.78328675, (float)0.77301045, (float)0.76252720, + (float)0.75183981, (float)0.74095113, (float)0.72986407, (float)0.71858162, + (float)0.70710678, (float)0.69544264, (float)0.68359230, (float)0.67155895, + (float)0.65934582, (float)0.64695615, (float)0.63439328, (float)0.62166057, + (float)0.60876143, (float)0.59569930, (float)0.58247770, (float)0.56910015, + (float)0.55557023, (float)0.54189158, (float)0.52806785, (float)0.51410274, + (float)0.50000000, (float)0.48576339, (float)0.47139674, (float)0.45690388, + (float)0.44228869, (float)0.42755509, (float)0.41270703, (float)0.39774847, + (float)0.38268343, (float)0.36751594, (float)0.35225005, (float)0.33688985, + (float)0.32143947, (float)0.30590302, (float)0.29028468, (float)0.27458862, + (float)0.25881905, (float)0.24298018, (float)0.22707626, (float)0.21111155, + (float)0.19509032, (float)0.17901686, (float)0.16289547, (float)0.14673047, + (float)0.13052619, (float)0.11428696, (float)0.09801714, (float)0.08172107, + (float)0.06540313, (float)0.04906767, (float)0.03271908, (float)0.01636173}; // hybrib Hanning & flat window: for 20ms static const float kBlocks320w512[512] = { - (float)0.00000000, (float)0.00818114, (float)0.01636173, (float)0.02454123, (float)0.03271908, - (float)0.04089475, (float)0.04906767, (float)0.05723732, (float)0.06540313, (float)0.07356456, - (float)0.08172107, (float)0.08987211, (float)0.09801714, (float)0.10615561, (float)0.11428696, - (float)0.12241068, (float)0.13052619, (float)0.13863297, (float)0.14673047, (float)0.15481816, - (float)0.16289547, (float)0.17096189, (float)0.17901686, (float)0.18705985, (float)0.19509032, - (float)0.20310773, (float)0.21111155, (float)0.21910124, (float)0.22707626, (float)0.23503609, - (float)0.24298018, (float)0.25090801, (float)0.25881905, (float)0.26671276, (float)0.27458862, - (float)0.28244610, (float)0.29028468, (float)0.29810383, (float)0.30590302, (float)0.31368174, - (float)0.32143947, (float)0.32917568, (float)0.33688985, (float)0.34458148, (float)0.35225005, - (float)0.35989504, (float)0.36751594, (float)0.37511224, (float)0.38268343, (float)0.39022901, - (float)0.39774847, (float)0.40524131, (float)0.41270703, (float)0.42014512, (float)0.42755509, - (float)0.43493645, (float)0.44228869, (float)0.44961133, (float)0.45690388, (float)0.46416584, - (float)0.47139674, (float)0.47859608, (float)0.48576339, (float)0.49289819, (float)0.50000000, - (float)0.50706834, (float)0.51410274, (float)0.52110274, (float)0.52806785, (float)0.53499762, - (float)0.54189158, (float)0.54874927, (float)0.55557023, (float)0.56235401, (float)0.56910015, - (float)0.57580819, (float)0.58247770, (float)0.58910822, (float)0.59569930, (float)0.60225052, - (float)0.60876143, (float)0.61523159, (float)0.62166057, (float)0.62804795, (float)0.63439328, - (float)0.64069616, (float)0.64695615, (float)0.65317284, (float)0.65934582, (float)0.66547466, - (float)0.67155895, (float)0.67759830, (float)0.68359230, (float)0.68954054, (float)0.69544264, - (float)0.70129818, (float)0.70710678, (float)0.71286806, (float)0.71858162, (float)0.72424708, - (float)0.72986407, (float)0.73543221, (float)0.74095113, (float)0.74642045, (float)0.75183981, - (float)0.75720885, (float)0.76252720, (float)0.76779452, (float)0.77301045, (float)0.77817464, - (float)0.78328675, (float)0.78834643, (float)0.79335334, (float)0.79830715, (float)0.80320753, - (float)0.80805415, (float)0.81284668, (float)0.81758481, (float)0.82226822, (float)0.82689659, - (float)0.83146961, (float)0.83598698, (float)0.84044840, (float)0.84485357, (float)0.84920218, - (float)0.85349396, (float)0.85772861, (float)0.86190585, (float)0.86602540, (float)0.87008699, - (float)0.87409034, (float)0.87803519, (float)0.88192126, (float)0.88574831, (float)0.88951608, - (float)0.89322430, (float)0.89687274, (float)0.90046115, (float)0.90398929, (float)0.90745693, - (float)0.91086382, (float)0.91420976, (float)0.91749450, (float)0.92071783, (float)0.92387953, - (float)0.92697940, (float)0.93001722, (float)0.93299280, (float)0.93590593, (float)0.93875641, - (float)0.94154407, (float)0.94426870, (float)0.94693013, (float)0.94952818, (float)0.95206268, - (float)0.95453345, (float)0.95694034, (float)0.95928317, (float)0.96156180, (float)0.96377607, - (float)0.96592583, (float)0.96801094, (float)0.97003125, (float)0.97198664, (float)0.97387698, - (float)0.97570213, (float)0.97746197, (float)0.97915640, (float)0.98078528, (float)0.98234852, - (float)0.98384601, (float)0.98527764, (float)0.98664333, (float)0.98794298, (float)0.98917651, - (float)0.99034383, (float)0.99144486, (float)0.99247953, (float)0.99344778, (float)0.99434953, - (float)0.99518473, (float)0.99595331, (float)0.99665524, (float)0.99729046, (float)0.99785892, - (float)0.99836060, (float)0.99879546, (float)0.99916346, (float)0.99946459, (float)0.99969882, - (float)0.99986614, (float)0.99996653, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, - (float)1.00000000, (float)0.99996653, (float)0.99986614, (float)0.99969882, (float)0.99946459, - (float)0.99916346, (float)0.99879546, (float)0.99836060, (float)0.99785892, (float)0.99729046, - (float)0.99665524, (float)0.99595331, (float)0.99518473, (float)0.99434953, (float)0.99344778, - (float)0.99247953, (float)0.99144486, (float)0.99034383, (float)0.98917651, (float)0.98794298, - (float)0.98664333, (float)0.98527764, (float)0.98384601, (float)0.98234852, (float)0.98078528, - (float)0.97915640, (float)0.97746197, (float)0.97570213, (float)0.97387698, (float)0.97198664, - (float)0.97003125, (float)0.96801094, (float)0.96592583, (float)0.96377607, (float)0.96156180, - (float)0.95928317, (float)0.95694034, (float)0.95453345, (float)0.95206268, (float)0.94952818, - (float)0.94693013, (float)0.94426870, (float)0.94154407, (float)0.93875641, (float)0.93590593, - (float)0.93299280, (float)0.93001722, (float)0.92697940, (float)0.92387953, (float)0.92071783, - (float)0.91749450, (float)0.91420976, (float)0.91086382, (float)0.90745693, (float)0.90398929, - (float)0.90046115, (float)0.89687274, (float)0.89322430, (float)0.88951608, (float)0.88574831, - (float)0.88192126, (float)0.87803519, (float)0.87409034, (float)0.87008699, (float)0.86602540, - (float)0.86190585, (float)0.85772861, (float)0.85349396, (float)0.84920218, (float)0.84485357, - (float)0.84044840, (float)0.83598698, (float)0.83146961, (float)0.82689659, (float)0.82226822, - (float)0.81758481, (float)0.81284668, (float)0.80805415, (float)0.80320753, (float)0.79830715, - (float)0.79335334, (float)0.78834643, (float)0.78328675, (float)0.77817464, (float)0.77301045, - (float)0.76779452, (float)0.76252720, (float)0.75720885, (float)0.75183981, (float)0.74642045, - (float)0.74095113, (float)0.73543221, (float)0.72986407, (float)0.72424708, (float)0.71858162, - (float)0.71286806, (float)0.70710678, (float)0.70129818, (float)0.69544264, (float)0.68954054, - (float)0.68359230, (float)0.67759830, (float)0.67155895, (float)0.66547466, (float)0.65934582, - (float)0.65317284, (float)0.64695615, (float)0.64069616, (float)0.63439328, (float)0.62804795, - (float)0.62166057, (float)0.61523159, (float)0.60876143, (float)0.60225052, (float)0.59569930, - (float)0.58910822, (float)0.58247770, (float)0.57580819, (float)0.56910015, (float)0.56235401, - (float)0.55557023, (float)0.54874927, (float)0.54189158, (float)0.53499762, (float)0.52806785, - (float)0.52110274, (float)0.51410274, (float)0.50706834, (float)0.50000000, (float)0.49289819, - (float)0.48576339, (float)0.47859608, (float)0.47139674, (float)0.46416584, (float)0.45690388, - (float)0.44961133, (float)0.44228869, (float)0.43493645, (float)0.42755509, (float)0.42014512, - (float)0.41270703, (float)0.40524131, (float)0.39774847, (float)0.39022901, (float)0.38268343, - (float)0.37511224, (float)0.36751594, (float)0.35989504, (float)0.35225005, (float)0.34458148, - (float)0.33688985, (float)0.32917568, (float)0.32143947, (float)0.31368174, (float)0.30590302, - (float)0.29810383, (float)0.29028468, (float)0.28244610, (float)0.27458862, (float)0.26671276, - (float)0.25881905, (float)0.25090801, (float)0.24298018, (float)0.23503609, (float)0.22707626, - (float)0.21910124, (float)0.21111155, (float)0.20310773, (float)0.19509032, (float)0.18705985, - (float)0.17901686, (float)0.17096189, (float)0.16289547, (float)0.15481816, (float)0.14673047, - (float)0.13863297, (float)0.13052619, (float)0.12241068, (float)0.11428696, (float)0.10615561, - (float)0.09801714, (float)0.08987211, (float)0.08172107, (float)0.07356456, (float)0.06540313, - (float)0.05723732, (float)0.04906767, (float)0.04089475, (float)0.03271908, (float)0.02454123, - (float)0.01636173, (float)0.00818114 -}; - + (float)0.00000000, (float)0.00818114, (float)0.01636173, (float)0.02454123, + (float)0.03271908, (float)0.04089475, (float)0.04906767, (float)0.05723732, + (float)0.06540313, (float)0.07356456, (float)0.08172107, (float)0.08987211, + (float)0.09801714, (float)0.10615561, (float)0.11428696, (float)0.12241068, + (float)0.13052619, (float)0.13863297, (float)0.14673047, (float)0.15481816, + (float)0.16289547, (float)0.17096189, (float)0.17901686, (float)0.18705985, + (float)0.19509032, (float)0.20310773, (float)0.21111155, (float)0.21910124, + (float)0.22707626, (float)0.23503609, (float)0.24298018, (float)0.25090801, + (float)0.25881905, (float)0.26671276, (float)0.27458862, (float)0.28244610, + (float)0.29028468, (float)0.29810383, (float)0.30590302, (float)0.31368174, + (float)0.32143947, (float)0.32917568, (float)0.33688985, (float)0.34458148, + (float)0.35225005, (float)0.35989504, (float)0.36751594, (float)0.37511224, + (float)0.38268343, (float)0.39022901, (float)0.39774847, (float)0.40524131, + (float)0.41270703, (float)0.42014512, (float)0.42755509, (float)0.43493645, + (float)0.44228869, (float)0.44961133, (float)0.45690388, (float)0.46416584, + (float)0.47139674, (float)0.47859608, (float)0.48576339, (float)0.49289819, + (float)0.50000000, (float)0.50706834, (float)0.51410274, (float)0.52110274, + (float)0.52806785, (float)0.53499762, (float)0.54189158, (float)0.54874927, + (float)0.55557023, (float)0.56235401, (float)0.56910015, (float)0.57580819, + (float)0.58247770, (float)0.58910822, (float)0.59569930, (float)0.60225052, + (float)0.60876143, (float)0.61523159, (float)0.62166057, (float)0.62804795, + (float)0.63439328, (float)0.64069616, (float)0.64695615, (float)0.65317284, + (float)0.65934582, (float)0.66547466, (float)0.67155895, (float)0.67759830, + (float)0.68359230, (float)0.68954054, (float)0.69544264, (float)0.70129818, + (float)0.70710678, (float)0.71286806, (float)0.71858162, (float)0.72424708, + (float)0.72986407, (float)0.73543221, (float)0.74095113, (float)0.74642045, + (float)0.75183981, (float)0.75720885, (float)0.76252720, (float)0.76779452, + (float)0.77301045, (float)0.77817464, (float)0.78328675, (float)0.78834643, + (float)0.79335334, (float)0.79830715, (float)0.80320753, (float)0.80805415, + (float)0.81284668, (float)0.81758481, (float)0.82226822, (float)0.82689659, + (float)0.83146961, (float)0.83598698, (float)0.84044840, (float)0.84485357, + (float)0.84920218, (float)0.85349396, (float)0.85772861, (float)0.86190585, + (float)0.86602540, (float)0.87008699, (float)0.87409034, (float)0.87803519, + (float)0.88192126, (float)0.88574831, (float)0.88951608, (float)0.89322430, + (float)0.89687274, (float)0.90046115, (float)0.90398929, (float)0.90745693, + (float)0.91086382, (float)0.91420976, (float)0.91749450, (float)0.92071783, + (float)0.92387953, (float)0.92697940, (float)0.93001722, (float)0.93299280, + (float)0.93590593, (float)0.93875641, (float)0.94154407, (float)0.94426870, + (float)0.94693013, (float)0.94952818, (float)0.95206268, (float)0.95453345, + (float)0.95694034, (float)0.95928317, (float)0.96156180, (float)0.96377607, + (float)0.96592583, (float)0.96801094, (float)0.97003125, (float)0.97198664, + (float)0.97387698, (float)0.97570213, (float)0.97746197, (float)0.97915640, + (float)0.98078528, (float)0.98234852, (float)0.98384601, (float)0.98527764, + (float)0.98664333, (float)0.98794298, (float)0.98917651, (float)0.99034383, + (float)0.99144486, (float)0.99247953, (float)0.99344778, (float)0.99434953, + (float)0.99518473, (float)0.99595331, (float)0.99665524, (float)0.99729046, + (float)0.99785892, (float)0.99836060, (float)0.99879546, (float)0.99916346, + (float)0.99946459, (float)0.99969882, (float)0.99986614, (float)0.99996653, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, + (float)1.00000000, (float)0.99996653, (float)0.99986614, (float)0.99969882, + (float)0.99946459, (float)0.99916346, (float)0.99879546, (float)0.99836060, + (float)0.99785892, (float)0.99729046, (float)0.99665524, (float)0.99595331, + (float)0.99518473, (float)0.99434953, (float)0.99344778, (float)0.99247953, + (float)0.99144486, (float)0.99034383, (float)0.98917651, (float)0.98794298, + (float)0.98664333, (float)0.98527764, (float)0.98384601, (float)0.98234852, + (float)0.98078528, (float)0.97915640, (float)0.97746197, (float)0.97570213, + (float)0.97387698, (float)0.97198664, (float)0.97003125, (float)0.96801094, + (float)0.96592583, (float)0.96377607, (float)0.96156180, (float)0.95928317, + (float)0.95694034, (float)0.95453345, (float)0.95206268, (float)0.94952818, + (float)0.94693013, (float)0.94426870, (float)0.94154407, (float)0.93875641, + (float)0.93590593, (float)0.93299280, (float)0.93001722, (float)0.92697940, + (float)0.92387953, (float)0.92071783, (float)0.91749450, (float)0.91420976, + (float)0.91086382, (float)0.90745693, (float)0.90398929, (float)0.90046115, + (float)0.89687274, (float)0.89322430, (float)0.88951608, (float)0.88574831, + (float)0.88192126, (float)0.87803519, (float)0.87409034, (float)0.87008699, + (float)0.86602540, (float)0.86190585, (float)0.85772861, (float)0.85349396, + (float)0.84920218, (float)0.84485357, (float)0.84044840, (float)0.83598698, + (float)0.83146961, (float)0.82689659, (float)0.82226822, (float)0.81758481, + (float)0.81284668, (float)0.80805415, (float)0.80320753, (float)0.79830715, + (float)0.79335334, (float)0.78834643, (float)0.78328675, (float)0.77817464, + (float)0.77301045, (float)0.76779452, (float)0.76252720, (float)0.75720885, + (float)0.75183981, (float)0.74642045, (float)0.74095113, (float)0.73543221, + (float)0.72986407, (float)0.72424708, (float)0.71858162, (float)0.71286806, + (float)0.70710678, (float)0.70129818, (float)0.69544264, (float)0.68954054, + (float)0.68359230, (float)0.67759830, (float)0.67155895, (float)0.66547466, + (float)0.65934582, (float)0.65317284, (float)0.64695615, (float)0.64069616, + (float)0.63439328, (float)0.62804795, (float)0.62166057, (float)0.61523159, + (float)0.60876143, (float)0.60225052, (float)0.59569930, (float)0.58910822, + (float)0.58247770, (float)0.57580819, (float)0.56910015, (float)0.56235401, + (float)0.55557023, (float)0.54874927, (float)0.54189158, (float)0.53499762, + (float)0.52806785, (float)0.52110274, (float)0.51410274, (float)0.50706834, + (float)0.50000000, (float)0.49289819, (float)0.48576339, (float)0.47859608, + (float)0.47139674, (float)0.46416584, (float)0.45690388, (float)0.44961133, + (float)0.44228869, (float)0.43493645, (float)0.42755509, (float)0.42014512, + (float)0.41270703, (float)0.40524131, (float)0.39774847, (float)0.39022901, + (float)0.38268343, (float)0.37511224, (float)0.36751594, (float)0.35989504, + (float)0.35225005, (float)0.34458148, (float)0.33688985, (float)0.32917568, + (float)0.32143947, (float)0.31368174, (float)0.30590302, (float)0.29810383, + (float)0.29028468, (float)0.28244610, (float)0.27458862, (float)0.26671276, + (float)0.25881905, (float)0.25090801, (float)0.24298018, (float)0.23503609, + (float)0.22707626, (float)0.21910124, (float)0.21111155, (float)0.20310773, + (float)0.19509032, (float)0.18705985, (float)0.17901686, (float)0.17096189, + (float)0.16289547, (float)0.15481816, (float)0.14673047, (float)0.13863297, + (float)0.13052619, (float)0.12241068, (float)0.11428696, (float)0.10615561, + (float)0.09801714, (float)0.08987211, (float)0.08172107, (float)0.07356456, + (float)0.06540313, (float)0.05723732, (float)0.04906767, (float)0.04089475, + (float)0.03271908, (float)0.02454123, (float)0.01636173, (float)0.00818114}; // Hanning window: for 15ms at 16kHz with symmetric zeros static const float kBlocks240w512[512] = { - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00654494, (float)0.01308960, (float)0.01963369, - (float)0.02617695, (float)0.03271908, (float)0.03925982, (float)0.04579887, (float)0.05233596, - (float)0.05887080, (float)0.06540313, (float)0.07193266, (float)0.07845910, (float)0.08498218, - (float)0.09150162, (float)0.09801714, (float)0.10452846, (float)0.11103531, (float)0.11753740, - (float)0.12403446, (float)0.13052620, (float)0.13701233, (float)0.14349262, (float)0.14996676, - (float)0.15643448, (float)0.16289547, (float)0.16934951, (float)0.17579629, (float)0.18223552, - (float)0.18866697, (float)0.19509032, (float)0.20150533, (float)0.20791170, (float)0.21430916, - (float)0.22069745, (float)0.22707628, (float)0.23344538, (float)0.23980446, (float)0.24615330, - (float)0.25249159, (float)0.25881904, (float)0.26513544, (float)0.27144045, (float)0.27773386, - (float)0.28401536, (float)0.29028466, (float)0.29654160, (float)0.30278578, (float)0.30901700, - (float)0.31523499, (float)0.32143945, (float)0.32763019, (float)0.33380687, (float)0.33996925, - (float)0.34611708, (float)0.35225007, (float)0.35836795, (float)0.36447051, (float)0.37055743, - (float)0.37662852, (float)0.38268346, (float)0.38872197, (float)0.39474389, (float)0.40074885, - (float)0.40673664, (float)0.41270703, (float)0.41865975, (float)0.42459452, (float)0.43051112, - (float)0.43640924, (float)0.44228873, (float)0.44814920, (float)0.45399052, (float)0.45981237, - (float)0.46561453, (float)0.47139674, (float)0.47715878, (float)0.48290035, (float)0.48862126, - (float)0.49432120, (float)0.50000000, (float)0.50565743, (float)0.51129311, (float)0.51690692, - (float)0.52249855, (float)0.52806789, (float)0.53361452, (float)0.53913832, (float)0.54463905, - (float)0.55011642, (float)0.55557024, (float)0.56100029, (float)0.56640625, (float)0.57178795, - (float)0.57714522, (float)0.58247769, (float)0.58778524, (float)0.59306765, (float)0.59832460, - (float)0.60355598, (float)0.60876143, (float)0.61394083, (float)0.61909395, (float)0.62422055, - (float)0.62932038, (float)0.63439333, (float)0.63943899, (float)0.64445734, (float)0.64944810, - (float)0.65441096, (float)0.65934587, (float)0.66425246, (float)0.66913062, (float)0.67398012, - (float)0.67880076, (float)0.68359232, (float)0.68835455, (float)0.69308740, (float)0.69779050, - (float)0.70246369, (float)0.70710677, (float)0.71171963, (float)0.71630198, (float)0.72085363, - (float)0.72537440, (float)0.72986406, (float)0.73432255, (float)0.73874950, (float)0.74314487, - (float)0.74750835, (float)0.75183982, (float)0.75613910, (float)0.76040596, (float)0.76464027, - (float)0.76884186, (float)0.77301043, (float)0.77714598, (float)0.78124821, (float)0.78531694, - (float)0.78935206, (float)0.79335338, (float)0.79732066, (float)0.80125386, (float)0.80515265, - (float)0.80901700, (float)0.81284672, (float)0.81664157, (float)0.82040149, (float)0.82412618, - (float)0.82781565, (float)0.83146966, (float)0.83508795, (float)0.83867061, (float)0.84221727, - (float)0.84572780, (float)0.84920216, (float)0.85264021, (float)0.85604161, (float)0.85940641, - (float)0.86273444, (float)0.86602545, (float)0.86927933, (float)0.87249607, (float)0.87567532, - (float)0.87881714, (float)0.88192129, (float)0.88498765, (float)0.88801610, (float)0.89100653, - (float)0.89395881, (float)0.89687276, (float)0.89974827, (float)0.90258533, (float)0.90538365, - (float)0.90814316, (float)0.91086388, (float)0.91354549, (float)0.91618794, (float)0.91879123, - (float)0.92135513, (float)0.92387950, (float)0.92636442, (float)0.92880958, (float)0.93121493, - (float)0.93358046, (float)0.93590593, (float)0.93819135, (float)0.94043654, (float)0.94264150, - (float)0.94480604, (float)0.94693011, (float)0.94901365, (float)0.95105654, (float)0.95305866, - (float)0.95501995, (float)0.95694035, (float)0.95881975, (float)0.96065807, (float)0.96245527, - (float)0.96421117, (float)0.96592581, (float)0.96759909, (float)0.96923089, (float)0.97082120, - (float)0.97236991, (float)0.97387701, (float)0.97534233, (float)0.97676587, (float)0.97814763, - (float)0.97948742, (float)0.98078531, (float)0.98204112, (float)0.98325491, (float)0.98442656, - (float)0.98555607, (float)0.98664331, (float)0.98768836, (float)0.98869103, (float)0.98965138, - (float)0.99056935, (float)0.99144489, (float)0.99227792, (float)0.99306846, (float)0.99381649, - (float)0.99452192, (float)0.99518472, (float)0.99580491, (float)0.99638247, (float)0.99691731, - (float)0.99740952, (float)0.99785894, (float)0.99826562, (float)0.99862951, (float)0.99895066, - (float)0.99922901, (float)0.99946457, (float)0.99965733, (float)0.99980724, (float)0.99991435, - (float)0.99997860, (float)1.00000000, (float)0.99997860, (float)0.99991435, (float)0.99980724, - (float)0.99965733, (float)0.99946457, (float)0.99922901, (float)0.99895066, (float)0.99862951, - (float)0.99826562, (float)0.99785894, (float)0.99740946, (float)0.99691731, (float)0.99638247, - (float)0.99580491, (float)0.99518472, (float)0.99452192, (float)0.99381644, (float)0.99306846, - (float)0.99227792, (float)0.99144489, (float)0.99056935, (float)0.98965138, (float)0.98869103, - (float)0.98768836, (float)0.98664331, (float)0.98555607, (float)0.98442656, (float)0.98325491, - (float)0.98204112, (float)0.98078525, (float)0.97948742, (float)0.97814757, (float)0.97676587, - (float)0.97534227, (float)0.97387695, (float)0.97236991, (float)0.97082120, (float)0.96923089, - (float)0.96759909, (float)0.96592581, (float)0.96421117, (float)0.96245521, (float)0.96065807, - (float)0.95881969, (float)0.95694029, (float)0.95501995, (float)0.95305860, (float)0.95105648, - (float)0.94901365, (float)0.94693011, (float)0.94480604, (float)0.94264150, (float)0.94043654, - (float)0.93819129, (float)0.93590593, (float)0.93358046, (float)0.93121493, (float)0.92880952, - (float)0.92636436, (float)0.92387950, (float)0.92135507, (float)0.91879123, (float)0.91618794, - (float)0.91354543, (float)0.91086382, (float)0.90814310, (float)0.90538365, (float)0.90258527, - (float)0.89974827, (float)0.89687276, (float)0.89395875, (float)0.89100647, (float)0.88801610, - (float)0.88498759, (float)0.88192123, (float)0.87881714, (float)0.87567532, (float)0.87249595, - (float)0.86927933, (float)0.86602539, (float)0.86273432, (float)0.85940641, (float)0.85604161, - (float)0.85264009, (float)0.84920216, (float)0.84572780, (float)0.84221715, (float)0.83867055, - (float)0.83508795, (float)0.83146954, (float)0.82781565, (float)0.82412612, (float)0.82040137, - (float)0.81664157, (float)0.81284660, (float)0.80901700, (float)0.80515265, (float)0.80125374, - (float)0.79732066, (float)0.79335332, (float)0.78935200, (float)0.78531694, (float)0.78124815, - (float)0.77714586, (float)0.77301049, (float)0.76884180, (float)0.76464021, (float)0.76040596, - (float)0.75613904, (float)0.75183970, (float)0.74750835, (float)0.74314481, (float)0.73874938, - (float)0.73432249, (float)0.72986400, (float)0.72537428, (float)0.72085363, (float)0.71630186, - (float)0.71171951, (float)0.70710677, (float)0.70246363, (float)0.69779032, (float)0.69308734, - (float)0.68835449, (float)0.68359220, (float)0.67880070, (float)0.67398006, (float)0.66913044, - (float)0.66425240, (float)0.65934575, (float)0.65441096, (float)0.64944804, (float)0.64445722, - (float)0.63943905, (float)0.63439327, (float)0.62932026, (float)0.62422055, (float)0.61909389, - (float)0.61394072, (float)0.60876143, (float)0.60355592, (float)0.59832448, (float)0.59306765, - (float)0.58778518, (float)0.58247757, (float)0.57714522, (float)0.57178789, (float)0.56640613, - (float)0.56100023, (float)0.55557019, (float)0.55011630, (float)0.54463905, (float)0.53913826, - (float)0.53361434, (float)0.52806783, (float)0.52249849, (float)0.51690674, (float)0.51129305, - (float)0.50565726, (float)0.50000006, (float)0.49432117, (float)0.48862115, (float)0.48290038, - (float)0.47715873, (float)0.47139663, (float)0.46561456, (float)0.45981231, (float)0.45399037, - (float)0.44814920, (float)0.44228864, (float)0.43640912, (float)0.43051112, (float)0.42459446, - (float)0.41865960, (float)0.41270703, (float)0.40673658, (float)0.40074870, (float)0.39474386, - (float)0.38872188, (float)0.38268328, (float)0.37662849, (float)0.37055734, (float)0.36447033, - (float)0.35836792, (float)0.35224995, (float)0.34611690, (float)0.33996922, (float)0.33380675, - (float)0.32763001, (float)0.32143945, (float)0.31523487, (float)0.30901679, (float)0.30278572, - (float)0.29654145, (float)0.29028472, (float)0.28401530, (float)0.27773371, (float)0.27144048, - (float)0.26513538, (float)0.25881892, (float)0.25249159, (float)0.24615324, (float)0.23980433, - (float)0.23344538, (float)0.22707619, (float)0.22069728, (float)0.21430916, (float)0.20791161, - (float)0.20150517, (float)0.19509031, (float)0.18866688, (float)0.18223536, (float)0.17579627, - (float)0.16934940, (float)0.16289529, (float)0.15643445, (float)0.14996666, (float)0.14349243, - (float)0.13701232, (float)0.13052608, (float)0.12403426, (float)0.11753736, (float)0.11103519, - (float)0.10452849, (float)0.09801710, (float)0.09150149, (float)0.08498220, (float)0.07845904, - (float)0.07193252, (float)0.06540315, (float)0.05887074, (float)0.05233581, (float)0.04579888, - (float)0.03925974, (float)0.03271893, (float)0.02617695, (float)0.01963361, (float)0.01308943, - (float)0.00654493, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000 -}; - + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00654494, (float)0.01308960, (float)0.01963369, + (float)0.02617695, (float)0.03271908, (float)0.03925982, (float)0.04579887, + (float)0.05233596, (float)0.05887080, (float)0.06540313, (float)0.07193266, + (float)0.07845910, (float)0.08498218, (float)0.09150162, (float)0.09801714, + (float)0.10452846, (float)0.11103531, (float)0.11753740, (float)0.12403446, + (float)0.13052620, (float)0.13701233, (float)0.14349262, (float)0.14996676, + (float)0.15643448, (float)0.16289547, (float)0.16934951, (float)0.17579629, + (float)0.18223552, (float)0.18866697, (float)0.19509032, (float)0.20150533, + (float)0.20791170, (float)0.21430916, (float)0.22069745, (float)0.22707628, + (float)0.23344538, (float)0.23980446, (float)0.24615330, (float)0.25249159, + (float)0.25881904, (float)0.26513544, (float)0.27144045, (float)0.27773386, + (float)0.28401536, (float)0.29028466, (float)0.29654160, (float)0.30278578, + (float)0.30901700, (float)0.31523499, (float)0.32143945, (float)0.32763019, + (float)0.33380687, (float)0.33996925, (float)0.34611708, (float)0.35225007, + (float)0.35836795, (float)0.36447051, (float)0.37055743, (float)0.37662852, + (float)0.38268346, (float)0.38872197, (float)0.39474389, (float)0.40074885, + (float)0.40673664, (float)0.41270703, (float)0.41865975, (float)0.42459452, + (float)0.43051112, (float)0.43640924, (float)0.44228873, (float)0.44814920, + (float)0.45399052, (float)0.45981237, (float)0.46561453, (float)0.47139674, + (float)0.47715878, (float)0.48290035, (float)0.48862126, (float)0.49432120, + (float)0.50000000, (float)0.50565743, (float)0.51129311, (float)0.51690692, + (float)0.52249855, (float)0.52806789, (float)0.53361452, (float)0.53913832, + (float)0.54463905, (float)0.55011642, (float)0.55557024, (float)0.56100029, + (float)0.56640625, (float)0.57178795, (float)0.57714522, (float)0.58247769, + (float)0.58778524, (float)0.59306765, (float)0.59832460, (float)0.60355598, + (float)0.60876143, (float)0.61394083, (float)0.61909395, (float)0.62422055, + (float)0.62932038, (float)0.63439333, (float)0.63943899, (float)0.64445734, + (float)0.64944810, (float)0.65441096, (float)0.65934587, (float)0.66425246, + (float)0.66913062, (float)0.67398012, (float)0.67880076, (float)0.68359232, + (float)0.68835455, (float)0.69308740, (float)0.69779050, (float)0.70246369, + (float)0.70710677, (float)0.71171963, (float)0.71630198, (float)0.72085363, + (float)0.72537440, (float)0.72986406, (float)0.73432255, (float)0.73874950, + (float)0.74314487, (float)0.74750835, (float)0.75183982, (float)0.75613910, + (float)0.76040596, (float)0.76464027, (float)0.76884186, (float)0.77301043, + (float)0.77714598, (float)0.78124821, (float)0.78531694, (float)0.78935206, + (float)0.79335338, (float)0.79732066, (float)0.80125386, (float)0.80515265, + (float)0.80901700, (float)0.81284672, (float)0.81664157, (float)0.82040149, + (float)0.82412618, (float)0.82781565, (float)0.83146966, (float)0.83508795, + (float)0.83867061, (float)0.84221727, (float)0.84572780, (float)0.84920216, + (float)0.85264021, (float)0.85604161, (float)0.85940641, (float)0.86273444, + (float)0.86602545, (float)0.86927933, (float)0.87249607, (float)0.87567532, + (float)0.87881714, (float)0.88192129, (float)0.88498765, (float)0.88801610, + (float)0.89100653, (float)0.89395881, (float)0.89687276, (float)0.89974827, + (float)0.90258533, (float)0.90538365, (float)0.90814316, (float)0.91086388, + (float)0.91354549, (float)0.91618794, (float)0.91879123, (float)0.92135513, + (float)0.92387950, (float)0.92636442, (float)0.92880958, (float)0.93121493, + (float)0.93358046, (float)0.93590593, (float)0.93819135, (float)0.94043654, + (float)0.94264150, (float)0.94480604, (float)0.94693011, (float)0.94901365, + (float)0.95105654, (float)0.95305866, (float)0.95501995, (float)0.95694035, + (float)0.95881975, (float)0.96065807, (float)0.96245527, (float)0.96421117, + (float)0.96592581, (float)0.96759909, (float)0.96923089, (float)0.97082120, + (float)0.97236991, (float)0.97387701, (float)0.97534233, (float)0.97676587, + (float)0.97814763, (float)0.97948742, (float)0.98078531, (float)0.98204112, + (float)0.98325491, (float)0.98442656, (float)0.98555607, (float)0.98664331, + (float)0.98768836, (float)0.98869103, (float)0.98965138, (float)0.99056935, + (float)0.99144489, (float)0.99227792, (float)0.99306846, (float)0.99381649, + (float)0.99452192, (float)0.99518472, (float)0.99580491, (float)0.99638247, + (float)0.99691731, (float)0.99740952, (float)0.99785894, (float)0.99826562, + (float)0.99862951, (float)0.99895066, (float)0.99922901, (float)0.99946457, + (float)0.99965733, (float)0.99980724, (float)0.99991435, (float)0.99997860, + (float)1.00000000, (float)0.99997860, (float)0.99991435, (float)0.99980724, + (float)0.99965733, (float)0.99946457, (float)0.99922901, (float)0.99895066, + (float)0.99862951, (float)0.99826562, (float)0.99785894, (float)0.99740946, + (float)0.99691731, (float)0.99638247, (float)0.99580491, (float)0.99518472, + (float)0.99452192, (float)0.99381644, (float)0.99306846, (float)0.99227792, + (float)0.99144489, (float)0.99056935, (float)0.98965138, (float)0.98869103, + (float)0.98768836, (float)0.98664331, (float)0.98555607, (float)0.98442656, + (float)0.98325491, (float)0.98204112, (float)0.98078525, (float)0.97948742, + (float)0.97814757, (float)0.97676587, (float)0.97534227, (float)0.97387695, + (float)0.97236991, (float)0.97082120, (float)0.96923089, (float)0.96759909, + (float)0.96592581, (float)0.96421117, (float)0.96245521, (float)0.96065807, + (float)0.95881969, (float)0.95694029, (float)0.95501995, (float)0.95305860, + (float)0.95105648, (float)0.94901365, (float)0.94693011, (float)0.94480604, + (float)0.94264150, (float)0.94043654, (float)0.93819129, (float)0.93590593, + (float)0.93358046, (float)0.93121493, (float)0.92880952, (float)0.92636436, + (float)0.92387950, (float)0.92135507, (float)0.91879123, (float)0.91618794, + (float)0.91354543, (float)0.91086382, (float)0.90814310, (float)0.90538365, + (float)0.90258527, (float)0.89974827, (float)0.89687276, (float)0.89395875, + (float)0.89100647, (float)0.88801610, (float)0.88498759, (float)0.88192123, + (float)0.87881714, (float)0.87567532, (float)0.87249595, (float)0.86927933, + (float)0.86602539, (float)0.86273432, (float)0.85940641, (float)0.85604161, + (float)0.85264009, (float)0.84920216, (float)0.84572780, (float)0.84221715, + (float)0.83867055, (float)0.83508795, (float)0.83146954, (float)0.82781565, + (float)0.82412612, (float)0.82040137, (float)0.81664157, (float)0.81284660, + (float)0.80901700, (float)0.80515265, (float)0.80125374, (float)0.79732066, + (float)0.79335332, (float)0.78935200, (float)0.78531694, (float)0.78124815, + (float)0.77714586, (float)0.77301049, (float)0.76884180, (float)0.76464021, + (float)0.76040596, (float)0.75613904, (float)0.75183970, (float)0.74750835, + (float)0.74314481, (float)0.73874938, (float)0.73432249, (float)0.72986400, + (float)0.72537428, (float)0.72085363, (float)0.71630186, (float)0.71171951, + (float)0.70710677, (float)0.70246363, (float)0.69779032, (float)0.69308734, + (float)0.68835449, (float)0.68359220, (float)0.67880070, (float)0.67398006, + (float)0.66913044, (float)0.66425240, (float)0.65934575, (float)0.65441096, + (float)0.64944804, (float)0.64445722, (float)0.63943905, (float)0.63439327, + (float)0.62932026, (float)0.62422055, (float)0.61909389, (float)0.61394072, + (float)0.60876143, (float)0.60355592, (float)0.59832448, (float)0.59306765, + (float)0.58778518, (float)0.58247757, (float)0.57714522, (float)0.57178789, + (float)0.56640613, (float)0.56100023, (float)0.55557019, (float)0.55011630, + (float)0.54463905, (float)0.53913826, (float)0.53361434, (float)0.52806783, + (float)0.52249849, (float)0.51690674, (float)0.51129305, (float)0.50565726, + (float)0.50000006, (float)0.49432117, (float)0.48862115, (float)0.48290038, + (float)0.47715873, (float)0.47139663, (float)0.46561456, (float)0.45981231, + (float)0.45399037, (float)0.44814920, (float)0.44228864, (float)0.43640912, + (float)0.43051112, (float)0.42459446, (float)0.41865960, (float)0.41270703, + (float)0.40673658, (float)0.40074870, (float)0.39474386, (float)0.38872188, + (float)0.38268328, (float)0.37662849, (float)0.37055734, (float)0.36447033, + (float)0.35836792, (float)0.35224995, (float)0.34611690, (float)0.33996922, + (float)0.33380675, (float)0.32763001, (float)0.32143945, (float)0.31523487, + (float)0.30901679, (float)0.30278572, (float)0.29654145, (float)0.29028472, + (float)0.28401530, (float)0.27773371, (float)0.27144048, (float)0.26513538, + (float)0.25881892, (float)0.25249159, (float)0.24615324, (float)0.23980433, + (float)0.23344538, (float)0.22707619, (float)0.22069728, (float)0.21430916, + (float)0.20791161, (float)0.20150517, (float)0.19509031, (float)0.18866688, + (float)0.18223536, (float)0.17579627, (float)0.16934940, (float)0.16289529, + (float)0.15643445, (float)0.14996666, (float)0.14349243, (float)0.13701232, + (float)0.13052608, (float)0.12403426, (float)0.11753736, (float)0.11103519, + (float)0.10452849, (float)0.09801710, (float)0.09150149, (float)0.08498220, + (float)0.07845904, (float)0.07193252, (float)0.06540315, (float)0.05887074, + (float)0.05233581, (float)0.04579888, (float)0.03925974, (float)0.03271893, + (float)0.02617695, (float)0.01963361, (float)0.01308943, (float)0.00654493, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000}; // Hanning window: for 30ms with 1024 fft with symmetric zeros at 16kHz static const float kBlocks480w1024[1024] = { - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00327249, (float)0.00654494, - (float)0.00981732, (float)0.01308960, (float)0.01636173, (float)0.01963369, (float)0.02290544, - (float)0.02617695, (float)0.02944817, (float)0.03271908, (float)0.03598964, (float)0.03925982, - (float)0.04252957, (float)0.04579887, (float)0.04906768, (float)0.05233596, (float)0.05560368, - (float)0.05887080, (float)0.06213730, (float)0.06540313, (float)0.06866825, (float)0.07193266, - (float)0.07519628, (float)0.07845910, (float)0.08172107, (float)0.08498218, (float)0.08824237, - (float)0.09150162, (float)0.09475989, (float)0.09801714, (float)0.10127335, (float)0.10452846, - (float)0.10778246, (float)0.11103531, (float)0.11428697, (float)0.11753740, (float)0.12078657, - (float)0.12403446, (float)0.12728101, (float)0.13052620, (float)0.13376999, (float)0.13701233, - (float)0.14025325, (float)0.14349262, (float)0.14673047, (float)0.14996676, (float)0.15320145, - (float)0.15643448, (float)0.15966582, (float)0.16289547, (float)0.16612339, (float)0.16934951, - (float)0.17257382, (float)0.17579629, (float)0.17901687, (float)0.18223552, (float)0.18545224, - (float)0.18866697, (float)0.19187967, (float)0.19509032, (float)0.19829889, (float)0.20150533, - (float)0.20470962, (float)0.20791170, (float)0.21111156, (float)0.21430916, (float)0.21750447, - (float)0.22069745, (float)0.22388805, (float)0.22707628, (float)0.23026206, (float)0.23344538, - (float)0.23662618, (float)0.23980446, (float)0.24298020, (float)0.24615330, (float)0.24932377, - (float)0.25249159, (float)0.25565669, (float)0.25881904, (float)0.26197866, (float)0.26513544, - (float)0.26828939, (float)0.27144045, (float)0.27458861, (float)0.27773386, (float)0.28087610, - (float)0.28401536, (float)0.28715158, (float)0.29028466, (float)0.29341471, (float)0.29654160, - (float)0.29966527, (float)0.30278578, (float)0.30590302, (float)0.30901700, (float)0.31212768, - (float)0.31523499, (float)0.31833893, (float)0.32143945, (float)0.32453656, (float)0.32763019, - (float)0.33072028, (float)0.33380687, (float)0.33688986, (float)0.33996925, (float)0.34304500, - (float)0.34611708, (float)0.34918544, (float)0.35225007, (float)0.35531089, (float)0.35836795, - (float)0.36142117, (float)0.36447051, (float)0.36751595, (float)0.37055743, (float)0.37359497, - (float)0.37662852, (float)0.37965801, (float)0.38268346, (float)0.38570479, (float)0.38872197, - (float)0.39173502, (float)0.39474389, (float)0.39774847, (float)0.40074885, (float)0.40374491, - (float)0.40673664, (float)0.40972406, (float)0.41270703, (float)0.41568562, (float)0.41865975, - (float)0.42162940, (float)0.42459452, (float)0.42755508, (float)0.43051112, (float)0.43346250, - (float)0.43640924, (float)0.43935132, (float)0.44228873, (float)0.44522133, (float)0.44814920, - (float)0.45107228, (float)0.45399052, (float)0.45690390, (float)0.45981237, (float)0.46271592, - (float)0.46561453, (float)0.46850815, (float)0.47139674, (float)0.47428030, (float)0.47715878, - (float)0.48003215, (float)0.48290035, (float)0.48576337, (float)0.48862126, (float)0.49147385, - (float)0.49432120, (float)0.49716330, (float)0.50000000, (float)0.50283140, (float)0.50565743, - (float)0.50847799, (float)0.51129311, (float)0.51410276, (float)0.51690692, (float)0.51970553, - (float)0.52249855, (float)0.52528602, (float)0.52806789, (float)0.53084403, (float)0.53361452, - (float)0.53637928, (float)0.53913832, (float)0.54189163, (float)0.54463905, (float)0.54738063, - (float)0.55011642, (float)0.55284631, (float)0.55557024, (float)0.55828828, (float)0.56100029, - (float)0.56370628, (float)0.56640625, (float)0.56910014, (float)0.57178795, (float)0.57446963, - (float)0.57714522, (float)0.57981455, (float)0.58247769, (float)0.58513463, (float)0.58778524, - (float)0.59042960, (float)0.59306765, (float)0.59569931, (float)0.59832460, (float)0.60094351, - (float)0.60355598, (float)0.60616195, (float)0.60876143, (float)0.61135441, (float)0.61394083, - (float)0.61652070, (float)0.61909395, (float)0.62166059, (float)0.62422055, (float)0.62677383, - (float)0.62932038, (float)0.63186020, (float)0.63439333, (float)0.63691956, (float)0.63943899, - (float)0.64195162, (float)0.64445734, (float)0.64695615, (float)0.64944810, (float)0.65193301, - (float)0.65441096, (float)0.65688187, (float)0.65934587, (float)0.66180271, (float)0.66425246, - (float)0.66669512, (float)0.66913062, (float)0.67155898, (float)0.67398012, (float)0.67639405, - (float)0.67880076, (float)0.68120021, (float)0.68359232, (float)0.68597710, (float)0.68835455, - (float)0.69072467, (float)0.69308740, (float)0.69544262, (float)0.69779050, (float)0.70013082, - (float)0.70246369, (float)0.70478904, (float)0.70710677, (float)0.70941699, (float)0.71171963, - (float)0.71401459, (float)0.71630198, (float)0.71858168, (float)0.72085363, (float)0.72311789, - (float)0.72537440, (float)0.72762316, (float)0.72986406, (float)0.73209721, (float)0.73432255, - (float)0.73653996, (float)0.73874950, (float)0.74095118, (float)0.74314487, (float)0.74533057, - (float)0.74750835, (float)0.74967808, (float)0.75183982, (float)0.75399351, (float)0.75613910, - (float)0.75827658, (float)0.76040596, (float)0.76252723, (float)0.76464027, (float)0.76674515, - (float)0.76884186, (float)0.77093029, (float)0.77301043, (float)0.77508241, (float)0.77714598, - (float)0.77920127, (float)0.78124821, (float)0.78328675, (float)0.78531694, (float)0.78733873, - (float)0.78935206, (float)0.79135692, (float)0.79335338, (float)0.79534125, (float)0.79732066, - (float)0.79929149, (float)0.80125386, (float)0.80320752, (float)0.80515265, (float)0.80708915, - (float)0.80901700, (float)0.81093621, (float)0.81284672, (float)0.81474853, (float)0.81664157, - (float)0.81852591, (float)0.82040149, (float)0.82226825, (float)0.82412618, (float)0.82597536, - (float)0.82781565, (float)0.82964706, (float)0.83146966, (float)0.83328325, (float)0.83508795, - (float)0.83688378, (float)0.83867061, (float)0.84044838, (float)0.84221727, (float)0.84397703, - (float)0.84572780, (float)0.84746957, (float)0.84920216, (float)0.85092574, (float)0.85264021, - (float)0.85434544, (float)0.85604161, (float)0.85772866, (float)0.85940641, (float)0.86107504, - (float)0.86273444, (float)0.86438453, (float)0.86602545, (float)0.86765707, (float)0.86927933, - (float)0.87089235, (float)0.87249607, (float)0.87409031, (float)0.87567532, (float)0.87725097, - (float)0.87881714, (float)0.88037390, (float)0.88192129, (float)0.88345921, (float)0.88498765, - (float)0.88650668, (float)0.88801610, (float)0.88951612, (float)0.89100653, (float)0.89248741, - (float)0.89395881, (float)0.89542055, (float)0.89687276, (float)0.89831537, (float)0.89974827, - (float)0.90117162, (float)0.90258533, (float)0.90398932, (float)0.90538365, (float)0.90676826, - (float)0.90814316, (float)0.90950841, (float)0.91086388, (float)0.91220951, (float)0.91354549, - (float)0.91487163, (float)0.91618794, (float)0.91749454, (float)0.91879123, (float)0.92007810, - (float)0.92135513, (float)0.92262226, (float)0.92387950, (float)0.92512691, (float)0.92636442, - (float)0.92759192, (float)0.92880958, (float)0.93001723, (float)0.93121493, (float)0.93240267, - (float)0.93358046, (float)0.93474817, (float)0.93590593, (float)0.93705362, (float)0.93819135, - (float)0.93931901, (float)0.94043654, (float)0.94154406, (float)0.94264150, (float)0.94372880, - (float)0.94480604, (float)0.94587320, (float)0.94693011, (float)0.94797695, (float)0.94901365, - (float)0.95004016, (float)0.95105654, (float)0.95206273, (float)0.95305866, (float)0.95404440, - (float)0.95501995, (float)0.95598525, (float)0.95694035, (float)0.95788521, (float)0.95881975, - (float)0.95974404, (float)0.96065807, (float)0.96156180, (float)0.96245527, (float)0.96333838, - (float)0.96421117, (float)0.96507370, (float)0.96592581, (float)0.96676767, (float)0.96759909, - (float)0.96842021, (float)0.96923089, (float)0.97003126, (float)0.97082120, (float)0.97160077, - (float)0.97236991, (float)0.97312868, (float)0.97387701, (float)0.97461486, (float)0.97534233, - (float)0.97605932, (float)0.97676587, (float)0.97746199, (float)0.97814763, (float)0.97882277, - (float)0.97948742, (float)0.98014158, (float)0.98078531, (float)0.98141843, (float)0.98204112, - (float)0.98265332, (float)0.98325491, (float)0.98384601, (float)0.98442656, (float)0.98499662, - (float)0.98555607, (float)0.98610497, (float)0.98664331, (float)0.98717111, (float)0.98768836, - (float)0.98819500, (float)0.98869103, (float)0.98917651, (float)0.98965138, (float)0.99011570, - (float)0.99056935, (float)0.99101239, (float)0.99144489, (float)0.99186671, (float)0.99227792, - (float)0.99267852, (float)0.99306846, (float)0.99344778, (float)0.99381649, (float)0.99417448, - (float)0.99452192, (float)0.99485862, (float)0.99518472, (float)0.99550015, (float)0.99580491, - (float)0.99609905, (float)0.99638247, (float)0.99665523, (float)0.99691731, (float)0.99716878, - (float)0.99740952, (float)0.99763954, (float)0.99785894, (float)0.99806762, (float)0.99826562, - (float)0.99845290, (float)0.99862951, (float)0.99879545, (float)0.99895066, (float)0.99909520, - (float)0.99922901, (float)0.99935216, (float)0.99946457, (float)0.99956632, (float)0.99965733, - (float)0.99973762, (float)0.99980724, (float)0.99986613, (float)0.99991435, (float)0.99995178, - (float)0.99997860, (float)0.99999464, (float)1.00000000, (float)0.99999464, (float)0.99997860, - (float)0.99995178, (float)0.99991435, (float)0.99986613, (float)0.99980724, (float)0.99973762, - (float)0.99965733, (float)0.99956632, (float)0.99946457, (float)0.99935216, (float)0.99922901, - (float)0.99909520, (float)0.99895066, (float)0.99879545, (float)0.99862951, (float)0.99845290, - (float)0.99826562, (float)0.99806762, (float)0.99785894, (float)0.99763954, (float)0.99740946, - (float)0.99716872, (float)0.99691731, (float)0.99665523, (float)0.99638247, (float)0.99609905, - (float)0.99580491, (float)0.99550015, (float)0.99518472, (float)0.99485862, (float)0.99452192, - (float)0.99417448, (float)0.99381644, (float)0.99344778, (float)0.99306846, (float)0.99267852, - (float)0.99227792, (float)0.99186671, (float)0.99144489, (float)0.99101239, (float)0.99056935, - (float)0.99011564, (float)0.98965138, (float)0.98917651, (float)0.98869103, (float)0.98819494, - (float)0.98768836, (float)0.98717111, (float)0.98664331, (float)0.98610497, (float)0.98555607, - (float)0.98499656, (float)0.98442656, (float)0.98384601, (float)0.98325491, (float)0.98265326, - (float)0.98204112, (float)0.98141843, (float)0.98078525, (float)0.98014158, (float)0.97948742, - (float)0.97882277, (float)0.97814757, (float)0.97746193, (float)0.97676587, (float)0.97605932, - (float)0.97534227, (float)0.97461486, (float)0.97387695, (float)0.97312862, (float)0.97236991, - (float)0.97160077, (float)0.97082120, (float)0.97003126, (float)0.96923089, (float)0.96842015, - (float)0.96759909, (float)0.96676761, (float)0.96592581, (float)0.96507365, (float)0.96421117, - (float)0.96333838, (float)0.96245521, (float)0.96156180, (float)0.96065807, (float)0.95974404, - (float)0.95881969, (float)0.95788515, (float)0.95694029, (float)0.95598525, (float)0.95501995, - (float)0.95404440, (float)0.95305860, (float)0.95206267, (float)0.95105648, (float)0.95004016, - (float)0.94901365, (float)0.94797695, (float)0.94693011, (float)0.94587314, (float)0.94480604, - (float)0.94372880, (float)0.94264150, (float)0.94154406, (float)0.94043654, (float)0.93931895, - (float)0.93819129, (float)0.93705362, (float)0.93590593, (float)0.93474817, (float)0.93358046, - (float)0.93240267, (float)0.93121493, (float)0.93001723, (float)0.92880952, (float)0.92759192, - (float)0.92636436, (float)0.92512691, (float)0.92387950, (float)0.92262226, (float)0.92135507, - (float)0.92007804, (float)0.91879123, (float)0.91749448, (float)0.91618794, (float)0.91487157, - (float)0.91354543, (float)0.91220951, (float)0.91086382, (float)0.90950835, (float)0.90814310, - (float)0.90676820, (float)0.90538365, (float)0.90398932, (float)0.90258527, (float)0.90117157, - (float)0.89974827, (float)0.89831525, (float)0.89687276, (float)0.89542055, (float)0.89395875, - (float)0.89248741, (float)0.89100647, (float)0.88951600, (float)0.88801610, (float)0.88650662, - (float)0.88498759, (float)0.88345915, (float)0.88192123, (float)0.88037384, (float)0.87881714, - (float)0.87725091, (float)0.87567532, (float)0.87409031, (float)0.87249595, (float)0.87089223, - (float)0.86927933, (float)0.86765701, (float)0.86602539, (float)0.86438447, (float)0.86273432, - (float)0.86107504, (float)0.85940641, (float)0.85772860, (float)0.85604161, (float)0.85434544, - (float)0.85264009, (float)0.85092574, (float)0.84920216, (float)0.84746951, (float)0.84572780, - (float)0.84397697, (float)0.84221715, (float)0.84044844, (float)0.83867055, (float)0.83688372, - (float)0.83508795, (float)0.83328319, (float)0.83146954, (float)0.82964706, (float)0.82781565, - (float)0.82597530, (float)0.82412612, (float)0.82226813, (float)0.82040137, (float)0.81852591, - (float)0.81664157, (float)0.81474847, (float)0.81284660, (float)0.81093609, (float)0.80901700, - (float)0.80708915, (float)0.80515265, (float)0.80320752, (float)0.80125374, (float)0.79929143, - (float)0.79732066, (float)0.79534125, (float)0.79335332, (float)0.79135686, (float)0.78935200, - (float)0.78733861, (float)0.78531694, (float)0.78328675, (float)0.78124815, (float)0.77920121, - (float)0.77714586, (float)0.77508223, (float)0.77301049, (float)0.77093029, (float)0.76884180, - (float)0.76674509, (float)0.76464021, (float)0.76252711, (float)0.76040596, (float)0.75827658, - (float)0.75613904, (float)0.75399339, (float)0.75183970, (float)0.74967796, (float)0.74750835, - (float)0.74533057, (float)0.74314481, (float)0.74095106, (float)0.73874938, (float)0.73653996, - (float)0.73432249, (float)0.73209721, (float)0.72986400, (float)0.72762305, (float)0.72537428, - (float)0.72311789, (float)0.72085363, (float)0.71858162, (float)0.71630186, (float)0.71401453, - (float)0.71171951, (float)0.70941705, (float)0.70710677, (float)0.70478898, (float)0.70246363, - (float)0.70013070, (float)0.69779032, (float)0.69544268, (float)0.69308734, (float)0.69072461, - (float)0.68835449, (float)0.68597704, (float)0.68359220, (float)0.68120021, (float)0.67880070, - (float)0.67639399, (float)0.67398006, (float)0.67155886, (float)0.66913044, (float)0.66669512, - (float)0.66425240, (float)0.66180259, (float)0.65934575, (float)0.65688181, (float)0.65441096, - (float)0.65193301, (float)0.64944804, (float)0.64695609, (float)0.64445722, (float)0.64195150, - (float)0.63943905, (float)0.63691956, (float)0.63439327, (float)0.63186014, (float)0.62932026, - (float)0.62677372, (float)0.62422055, (float)0.62166059, (float)0.61909389, (float)0.61652064, - (float)0.61394072, (float)0.61135429, (float)0.60876143, (float)0.60616189, (float)0.60355592, - (float)0.60094339, (float)0.59832448, (float)0.59569913, (float)0.59306765, (float)0.59042960, - (float)0.58778518, (float)0.58513451, (float)0.58247757, (float)0.57981461, (float)0.57714522, - (float)0.57446963, (float)0.57178789, (float)0.56910002, (float)0.56640613, (float)0.56370628, - (float)0.56100023, (float)0.55828822, (float)0.55557019, (float)0.55284619, (float)0.55011630, - (float)0.54738069, (float)0.54463905, (float)0.54189152, (float)0.53913826, (float)0.53637916, - (float)0.53361434, (float)0.53084403, (float)0.52806783, (float)0.52528596, (float)0.52249849, - (float)0.51970541, (float)0.51690674, (float)0.51410276, (float)0.51129305, (float)0.50847787, - (float)0.50565726, (float)0.50283122, (float)0.50000006, (float)0.49716327, (float)0.49432117, - (float)0.49147379, (float)0.48862115, (float)0.48576325, (float)0.48290038, (float)0.48003212, - (float)0.47715873, (float)0.47428021, (float)0.47139663, (float)0.46850798, (float)0.46561456, - (float)0.46271589, (float)0.45981231, (float)0.45690379, (float)0.45399037, (float)0.45107210, - (float)0.44814920, (float)0.44522130, (float)0.44228864, (float)0.43935123, (float)0.43640912, - (float)0.43346232, (float)0.43051112, (float)0.42755505, (float)0.42459446, (float)0.42162928, - (float)0.41865960, (float)0.41568545, (float)0.41270703, (float)0.40972400, (float)0.40673658, - (float)0.40374479, (float)0.40074870, (float)0.39774850, (float)0.39474386, (float)0.39173496, - (float)0.38872188, (float)0.38570464, (float)0.38268328, (float)0.37965804, (float)0.37662849, - (float)0.37359491, (float)0.37055734, (float)0.36751580, (float)0.36447033, (float)0.36142117, - (float)0.35836792, (float)0.35531086, (float)0.35224995, (float)0.34918529, (float)0.34611690, - (float)0.34304500, (float)0.33996922, (float)0.33688980, (float)0.33380675, (float)0.33072016, - (float)0.32763001, (float)0.32453656, (float)0.32143945, (float)0.31833887, (float)0.31523487, - (float)0.31212750, (float)0.30901679, (float)0.30590302, (float)0.30278572, (float)0.29966521, - (float)0.29654145, (float)0.29341453, (float)0.29028472, (float)0.28715155, (float)0.28401530, - (float)0.28087601, (float)0.27773371, (float)0.27458847, (float)0.27144048, (float)0.26828936, - (float)0.26513538, (float)0.26197854, (float)0.25881892, (float)0.25565651, (float)0.25249159, - (float)0.24932374, (float)0.24615324, (float)0.24298008, (float)0.23980433, (float)0.23662600, - (float)0.23344538, (float)0.23026201, (float)0.22707619, (float)0.22388794, (float)0.22069728, - (float)0.21750426, (float)0.21430916, (float)0.21111152, (float)0.20791161, (float)0.20470949, - (float)0.20150517, (float)0.19829892, (float)0.19509031, (float)0.19187963, (float)0.18866688, - (float)0.18545210, (float)0.18223536, (float)0.17901689, (float)0.17579627, (float)0.17257376, - (float)0.16934940, (float)0.16612324, (float)0.16289529, (float)0.15966584, (float)0.15643445, - (float)0.15320137, (float)0.14996666, (float)0.14673033, (float)0.14349243, (float)0.14025325, - (float)0.13701232, (float)0.13376991, (float)0.13052608, (float)0.12728085, (float)0.12403426, - (float)0.12078657, (float)0.11753736, (float)0.11428688, (float)0.11103519, (float)0.10778230, - (float)0.10452849, (float)0.10127334, (float)0.09801710, (float)0.09475980, (float)0.09150149, - (float)0.08824220, (float)0.08498220, (float)0.08172106, (float)0.07845904, (float)0.07519618, - (float)0.07193252, (float)0.06866808, (float)0.06540315, (float)0.06213728, (float)0.05887074, - (float)0.05560357, (float)0.05233581, (float)0.04906749, (float)0.04579888, (float)0.04252954, - (float)0.03925974, (float)0.03598953, (float)0.03271893, (float)0.02944798, (float)0.02617695, - (float)0.02290541, (float)0.01963361, (float)0.01636161, (float)0.01308943, (float)0.00981712, - (float)0.00654493, (float)0.00327244, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, - (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000 -}; + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00327249, (float)0.00654494, (float)0.00981732, + (float)0.01308960, (float)0.01636173, (float)0.01963369, (float)0.02290544, + (float)0.02617695, (float)0.02944817, (float)0.03271908, (float)0.03598964, + (float)0.03925982, (float)0.04252957, (float)0.04579887, (float)0.04906768, + (float)0.05233596, (float)0.05560368, (float)0.05887080, (float)0.06213730, + (float)0.06540313, (float)0.06866825, (float)0.07193266, (float)0.07519628, + (float)0.07845910, (float)0.08172107, (float)0.08498218, (float)0.08824237, + (float)0.09150162, (float)0.09475989, (float)0.09801714, (float)0.10127335, + (float)0.10452846, (float)0.10778246, (float)0.11103531, (float)0.11428697, + (float)0.11753740, (float)0.12078657, (float)0.12403446, (float)0.12728101, + (float)0.13052620, (float)0.13376999, (float)0.13701233, (float)0.14025325, + (float)0.14349262, (float)0.14673047, (float)0.14996676, (float)0.15320145, + (float)0.15643448, (float)0.15966582, (float)0.16289547, (float)0.16612339, + (float)0.16934951, (float)0.17257382, (float)0.17579629, (float)0.17901687, + (float)0.18223552, (float)0.18545224, (float)0.18866697, (float)0.19187967, + (float)0.19509032, (float)0.19829889, (float)0.20150533, (float)0.20470962, + (float)0.20791170, (float)0.21111156, (float)0.21430916, (float)0.21750447, + (float)0.22069745, (float)0.22388805, (float)0.22707628, (float)0.23026206, + (float)0.23344538, (float)0.23662618, (float)0.23980446, (float)0.24298020, + (float)0.24615330, (float)0.24932377, (float)0.25249159, (float)0.25565669, + (float)0.25881904, (float)0.26197866, (float)0.26513544, (float)0.26828939, + (float)0.27144045, (float)0.27458861, (float)0.27773386, (float)0.28087610, + (float)0.28401536, (float)0.28715158, (float)0.29028466, (float)0.29341471, + (float)0.29654160, (float)0.29966527, (float)0.30278578, (float)0.30590302, + (float)0.30901700, (float)0.31212768, (float)0.31523499, (float)0.31833893, + (float)0.32143945, (float)0.32453656, (float)0.32763019, (float)0.33072028, + (float)0.33380687, (float)0.33688986, (float)0.33996925, (float)0.34304500, + (float)0.34611708, (float)0.34918544, (float)0.35225007, (float)0.35531089, + (float)0.35836795, (float)0.36142117, (float)0.36447051, (float)0.36751595, + (float)0.37055743, (float)0.37359497, (float)0.37662852, (float)0.37965801, + (float)0.38268346, (float)0.38570479, (float)0.38872197, (float)0.39173502, + (float)0.39474389, (float)0.39774847, (float)0.40074885, (float)0.40374491, + (float)0.40673664, (float)0.40972406, (float)0.41270703, (float)0.41568562, + (float)0.41865975, (float)0.42162940, (float)0.42459452, (float)0.42755508, + (float)0.43051112, (float)0.43346250, (float)0.43640924, (float)0.43935132, + (float)0.44228873, (float)0.44522133, (float)0.44814920, (float)0.45107228, + (float)0.45399052, (float)0.45690390, (float)0.45981237, (float)0.46271592, + (float)0.46561453, (float)0.46850815, (float)0.47139674, (float)0.47428030, + (float)0.47715878, (float)0.48003215, (float)0.48290035, (float)0.48576337, + (float)0.48862126, (float)0.49147385, (float)0.49432120, (float)0.49716330, + (float)0.50000000, (float)0.50283140, (float)0.50565743, (float)0.50847799, + (float)0.51129311, (float)0.51410276, (float)0.51690692, (float)0.51970553, + (float)0.52249855, (float)0.52528602, (float)0.52806789, (float)0.53084403, + (float)0.53361452, (float)0.53637928, (float)0.53913832, (float)0.54189163, + (float)0.54463905, (float)0.54738063, (float)0.55011642, (float)0.55284631, + (float)0.55557024, (float)0.55828828, (float)0.56100029, (float)0.56370628, + (float)0.56640625, (float)0.56910014, (float)0.57178795, (float)0.57446963, + (float)0.57714522, (float)0.57981455, (float)0.58247769, (float)0.58513463, + (float)0.58778524, (float)0.59042960, (float)0.59306765, (float)0.59569931, + (float)0.59832460, (float)0.60094351, (float)0.60355598, (float)0.60616195, + (float)0.60876143, (float)0.61135441, (float)0.61394083, (float)0.61652070, + (float)0.61909395, (float)0.62166059, (float)0.62422055, (float)0.62677383, + (float)0.62932038, (float)0.63186020, (float)0.63439333, (float)0.63691956, + (float)0.63943899, (float)0.64195162, (float)0.64445734, (float)0.64695615, + (float)0.64944810, (float)0.65193301, (float)0.65441096, (float)0.65688187, + (float)0.65934587, (float)0.66180271, (float)0.66425246, (float)0.66669512, + (float)0.66913062, (float)0.67155898, (float)0.67398012, (float)0.67639405, + (float)0.67880076, (float)0.68120021, (float)0.68359232, (float)0.68597710, + (float)0.68835455, (float)0.69072467, (float)0.69308740, (float)0.69544262, + (float)0.69779050, (float)0.70013082, (float)0.70246369, (float)0.70478904, + (float)0.70710677, (float)0.70941699, (float)0.71171963, (float)0.71401459, + (float)0.71630198, (float)0.71858168, (float)0.72085363, (float)0.72311789, + (float)0.72537440, (float)0.72762316, (float)0.72986406, (float)0.73209721, + (float)0.73432255, (float)0.73653996, (float)0.73874950, (float)0.74095118, + (float)0.74314487, (float)0.74533057, (float)0.74750835, (float)0.74967808, + (float)0.75183982, (float)0.75399351, (float)0.75613910, (float)0.75827658, + (float)0.76040596, (float)0.76252723, (float)0.76464027, (float)0.76674515, + (float)0.76884186, (float)0.77093029, (float)0.77301043, (float)0.77508241, + (float)0.77714598, (float)0.77920127, (float)0.78124821, (float)0.78328675, + (float)0.78531694, (float)0.78733873, (float)0.78935206, (float)0.79135692, + (float)0.79335338, (float)0.79534125, (float)0.79732066, (float)0.79929149, + (float)0.80125386, (float)0.80320752, (float)0.80515265, (float)0.80708915, + (float)0.80901700, (float)0.81093621, (float)0.81284672, (float)0.81474853, + (float)0.81664157, (float)0.81852591, (float)0.82040149, (float)0.82226825, + (float)0.82412618, (float)0.82597536, (float)0.82781565, (float)0.82964706, + (float)0.83146966, (float)0.83328325, (float)0.83508795, (float)0.83688378, + (float)0.83867061, (float)0.84044838, (float)0.84221727, (float)0.84397703, + (float)0.84572780, (float)0.84746957, (float)0.84920216, (float)0.85092574, + (float)0.85264021, (float)0.85434544, (float)0.85604161, (float)0.85772866, + (float)0.85940641, (float)0.86107504, (float)0.86273444, (float)0.86438453, + (float)0.86602545, (float)0.86765707, (float)0.86927933, (float)0.87089235, + (float)0.87249607, (float)0.87409031, (float)0.87567532, (float)0.87725097, + (float)0.87881714, (float)0.88037390, (float)0.88192129, (float)0.88345921, + (float)0.88498765, (float)0.88650668, (float)0.88801610, (float)0.88951612, + (float)0.89100653, (float)0.89248741, (float)0.89395881, (float)0.89542055, + (float)0.89687276, (float)0.89831537, (float)0.89974827, (float)0.90117162, + (float)0.90258533, (float)0.90398932, (float)0.90538365, (float)0.90676826, + (float)0.90814316, (float)0.90950841, (float)0.91086388, (float)0.91220951, + (float)0.91354549, (float)0.91487163, (float)0.91618794, (float)0.91749454, + (float)0.91879123, (float)0.92007810, (float)0.92135513, (float)0.92262226, + (float)0.92387950, (float)0.92512691, (float)0.92636442, (float)0.92759192, + (float)0.92880958, (float)0.93001723, (float)0.93121493, (float)0.93240267, + (float)0.93358046, (float)0.93474817, (float)0.93590593, (float)0.93705362, + (float)0.93819135, (float)0.93931901, (float)0.94043654, (float)0.94154406, + (float)0.94264150, (float)0.94372880, (float)0.94480604, (float)0.94587320, + (float)0.94693011, (float)0.94797695, (float)0.94901365, (float)0.95004016, + (float)0.95105654, (float)0.95206273, (float)0.95305866, (float)0.95404440, + (float)0.95501995, (float)0.95598525, (float)0.95694035, (float)0.95788521, + (float)0.95881975, (float)0.95974404, (float)0.96065807, (float)0.96156180, + (float)0.96245527, (float)0.96333838, (float)0.96421117, (float)0.96507370, + (float)0.96592581, (float)0.96676767, (float)0.96759909, (float)0.96842021, + (float)0.96923089, (float)0.97003126, (float)0.97082120, (float)0.97160077, + (float)0.97236991, (float)0.97312868, (float)0.97387701, (float)0.97461486, + (float)0.97534233, (float)0.97605932, (float)0.97676587, (float)0.97746199, + (float)0.97814763, (float)0.97882277, (float)0.97948742, (float)0.98014158, + (float)0.98078531, (float)0.98141843, (float)0.98204112, (float)0.98265332, + (float)0.98325491, (float)0.98384601, (float)0.98442656, (float)0.98499662, + (float)0.98555607, (float)0.98610497, (float)0.98664331, (float)0.98717111, + (float)0.98768836, (float)0.98819500, (float)0.98869103, (float)0.98917651, + (float)0.98965138, (float)0.99011570, (float)0.99056935, (float)0.99101239, + (float)0.99144489, (float)0.99186671, (float)0.99227792, (float)0.99267852, + (float)0.99306846, (float)0.99344778, (float)0.99381649, (float)0.99417448, + (float)0.99452192, (float)0.99485862, (float)0.99518472, (float)0.99550015, + (float)0.99580491, (float)0.99609905, (float)0.99638247, (float)0.99665523, + (float)0.99691731, (float)0.99716878, (float)0.99740952, (float)0.99763954, + (float)0.99785894, (float)0.99806762, (float)0.99826562, (float)0.99845290, + (float)0.99862951, (float)0.99879545, (float)0.99895066, (float)0.99909520, + (float)0.99922901, (float)0.99935216, (float)0.99946457, (float)0.99956632, + (float)0.99965733, (float)0.99973762, (float)0.99980724, (float)0.99986613, + (float)0.99991435, (float)0.99995178, (float)0.99997860, (float)0.99999464, + (float)1.00000000, (float)0.99999464, (float)0.99997860, (float)0.99995178, + (float)0.99991435, (float)0.99986613, (float)0.99980724, (float)0.99973762, + (float)0.99965733, (float)0.99956632, (float)0.99946457, (float)0.99935216, + (float)0.99922901, (float)0.99909520, (float)0.99895066, (float)0.99879545, + (float)0.99862951, (float)0.99845290, (float)0.99826562, (float)0.99806762, + (float)0.99785894, (float)0.99763954, (float)0.99740946, (float)0.99716872, + (float)0.99691731, (float)0.99665523, (float)0.99638247, (float)0.99609905, + (float)0.99580491, (float)0.99550015, (float)0.99518472, (float)0.99485862, + (float)0.99452192, (float)0.99417448, (float)0.99381644, (float)0.99344778, + (float)0.99306846, (float)0.99267852, (float)0.99227792, (float)0.99186671, + (float)0.99144489, (float)0.99101239, (float)0.99056935, (float)0.99011564, + (float)0.98965138, (float)0.98917651, (float)0.98869103, (float)0.98819494, + (float)0.98768836, (float)0.98717111, (float)0.98664331, (float)0.98610497, + (float)0.98555607, (float)0.98499656, (float)0.98442656, (float)0.98384601, + (float)0.98325491, (float)0.98265326, (float)0.98204112, (float)0.98141843, + (float)0.98078525, (float)0.98014158, (float)0.97948742, (float)0.97882277, + (float)0.97814757, (float)0.97746193, (float)0.97676587, (float)0.97605932, + (float)0.97534227, (float)0.97461486, (float)0.97387695, (float)0.97312862, + (float)0.97236991, (float)0.97160077, (float)0.97082120, (float)0.97003126, + (float)0.96923089, (float)0.96842015, (float)0.96759909, (float)0.96676761, + (float)0.96592581, (float)0.96507365, (float)0.96421117, (float)0.96333838, + (float)0.96245521, (float)0.96156180, (float)0.96065807, (float)0.95974404, + (float)0.95881969, (float)0.95788515, (float)0.95694029, (float)0.95598525, + (float)0.95501995, (float)0.95404440, (float)0.95305860, (float)0.95206267, + (float)0.95105648, (float)0.95004016, (float)0.94901365, (float)0.94797695, + (float)0.94693011, (float)0.94587314, (float)0.94480604, (float)0.94372880, + (float)0.94264150, (float)0.94154406, (float)0.94043654, (float)0.93931895, + (float)0.93819129, (float)0.93705362, (float)0.93590593, (float)0.93474817, + (float)0.93358046, (float)0.93240267, (float)0.93121493, (float)0.93001723, + (float)0.92880952, (float)0.92759192, (float)0.92636436, (float)0.92512691, + (float)0.92387950, (float)0.92262226, (float)0.92135507, (float)0.92007804, + (float)0.91879123, (float)0.91749448, (float)0.91618794, (float)0.91487157, + (float)0.91354543, (float)0.91220951, (float)0.91086382, (float)0.90950835, + (float)0.90814310, (float)0.90676820, (float)0.90538365, (float)0.90398932, + (float)0.90258527, (float)0.90117157, (float)0.89974827, (float)0.89831525, + (float)0.89687276, (float)0.89542055, (float)0.89395875, (float)0.89248741, + (float)0.89100647, (float)0.88951600, (float)0.88801610, (float)0.88650662, + (float)0.88498759, (float)0.88345915, (float)0.88192123, (float)0.88037384, + (float)0.87881714, (float)0.87725091, (float)0.87567532, (float)0.87409031, + (float)0.87249595, (float)0.87089223, (float)0.86927933, (float)0.86765701, + (float)0.86602539, (float)0.86438447, (float)0.86273432, (float)0.86107504, + (float)0.85940641, (float)0.85772860, (float)0.85604161, (float)0.85434544, + (float)0.85264009, (float)0.85092574, (float)0.84920216, (float)0.84746951, + (float)0.84572780, (float)0.84397697, (float)0.84221715, (float)0.84044844, + (float)0.83867055, (float)0.83688372, (float)0.83508795, (float)0.83328319, + (float)0.83146954, (float)0.82964706, (float)0.82781565, (float)0.82597530, + (float)0.82412612, (float)0.82226813, (float)0.82040137, (float)0.81852591, + (float)0.81664157, (float)0.81474847, (float)0.81284660, (float)0.81093609, + (float)0.80901700, (float)0.80708915, (float)0.80515265, (float)0.80320752, + (float)0.80125374, (float)0.79929143, (float)0.79732066, (float)0.79534125, + (float)0.79335332, (float)0.79135686, (float)0.78935200, (float)0.78733861, + (float)0.78531694, (float)0.78328675, (float)0.78124815, (float)0.77920121, + (float)0.77714586, (float)0.77508223, (float)0.77301049, (float)0.77093029, + (float)0.76884180, (float)0.76674509, (float)0.76464021, (float)0.76252711, + (float)0.76040596, (float)0.75827658, (float)0.75613904, (float)0.75399339, + (float)0.75183970, (float)0.74967796, (float)0.74750835, (float)0.74533057, + (float)0.74314481, (float)0.74095106, (float)0.73874938, (float)0.73653996, + (float)0.73432249, (float)0.73209721, (float)0.72986400, (float)0.72762305, + (float)0.72537428, (float)0.72311789, (float)0.72085363, (float)0.71858162, + (float)0.71630186, (float)0.71401453, (float)0.71171951, (float)0.70941705, + (float)0.70710677, (float)0.70478898, (float)0.70246363, (float)0.70013070, + (float)0.69779032, (float)0.69544268, (float)0.69308734, (float)0.69072461, + (float)0.68835449, (float)0.68597704, (float)0.68359220, (float)0.68120021, + (float)0.67880070, (float)0.67639399, (float)0.67398006, (float)0.67155886, + (float)0.66913044, (float)0.66669512, (float)0.66425240, (float)0.66180259, + (float)0.65934575, (float)0.65688181, (float)0.65441096, (float)0.65193301, + (float)0.64944804, (float)0.64695609, (float)0.64445722, (float)0.64195150, + (float)0.63943905, (float)0.63691956, (float)0.63439327, (float)0.63186014, + (float)0.62932026, (float)0.62677372, (float)0.62422055, (float)0.62166059, + (float)0.61909389, (float)0.61652064, (float)0.61394072, (float)0.61135429, + (float)0.60876143, (float)0.60616189, (float)0.60355592, (float)0.60094339, + (float)0.59832448, (float)0.59569913, (float)0.59306765, (float)0.59042960, + (float)0.58778518, (float)0.58513451, (float)0.58247757, (float)0.57981461, + (float)0.57714522, (float)0.57446963, (float)0.57178789, (float)0.56910002, + (float)0.56640613, (float)0.56370628, (float)0.56100023, (float)0.55828822, + (float)0.55557019, (float)0.55284619, (float)0.55011630, (float)0.54738069, + (float)0.54463905, (float)0.54189152, (float)0.53913826, (float)0.53637916, + (float)0.53361434, (float)0.53084403, (float)0.52806783, (float)0.52528596, + (float)0.52249849, (float)0.51970541, (float)0.51690674, (float)0.51410276, + (float)0.51129305, (float)0.50847787, (float)0.50565726, (float)0.50283122, + (float)0.50000006, (float)0.49716327, (float)0.49432117, (float)0.49147379, + (float)0.48862115, (float)0.48576325, (float)0.48290038, (float)0.48003212, + (float)0.47715873, (float)0.47428021, (float)0.47139663, (float)0.46850798, + (float)0.46561456, (float)0.46271589, (float)0.45981231, (float)0.45690379, + (float)0.45399037, (float)0.45107210, (float)0.44814920, (float)0.44522130, + (float)0.44228864, (float)0.43935123, (float)0.43640912, (float)0.43346232, + (float)0.43051112, (float)0.42755505, (float)0.42459446, (float)0.42162928, + (float)0.41865960, (float)0.41568545, (float)0.41270703, (float)0.40972400, + (float)0.40673658, (float)0.40374479, (float)0.40074870, (float)0.39774850, + (float)0.39474386, (float)0.39173496, (float)0.38872188, (float)0.38570464, + (float)0.38268328, (float)0.37965804, (float)0.37662849, (float)0.37359491, + (float)0.37055734, (float)0.36751580, (float)0.36447033, (float)0.36142117, + (float)0.35836792, (float)0.35531086, (float)0.35224995, (float)0.34918529, + (float)0.34611690, (float)0.34304500, (float)0.33996922, (float)0.33688980, + (float)0.33380675, (float)0.33072016, (float)0.32763001, (float)0.32453656, + (float)0.32143945, (float)0.31833887, (float)0.31523487, (float)0.31212750, + (float)0.30901679, (float)0.30590302, (float)0.30278572, (float)0.29966521, + (float)0.29654145, (float)0.29341453, (float)0.29028472, (float)0.28715155, + (float)0.28401530, (float)0.28087601, (float)0.27773371, (float)0.27458847, + (float)0.27144048, (float)0.26828936, (float)0.26513538, (float)0.26197854, + (float)0.25881892, (float)0.25565651, (float)0.25249159, (float)0.24932374, + (float)0.24615324, (float)0.24298008, (float)0.23980433, (float)0.23662600, + (float)0.23344538, (float)0.23026201, (float)0.22707619, (float)0.22388794, + (float)0.22069728, (float)0.21750426, (float)0.21430916, (float)0.21111152, + (float)0.20791161, (float)0.20470949, (float)0.20150517, (float)0.19829892, + (float)0.19509031, (float)0.19187963, (float)0.18866688, (float)0.18545210, + (float)0.18223536, (float)0.17901689, (float)0.17579627, (float)0.17257376, + (float)0.16934940, (float)0.16612324, (float)0.16289529, (float)0.15966584, + (float)0.15643445, (float)0.15320137, (float)0.14996666, (float)0.14673033, + (float)0.14349243, (float)0.14025325, (float)0.13701232, (float)0.13376991, + (float)0.13052608, (float)0.12728085, (float)0.12403426, (float)0.12078657, + (float)0.11753736, (float)0.11428688, (float)0.11103519, (float)0.10778230, + (float)0.10452849, (float)0.10127334, (float)0.09801710, (float)0.09475980, + (float)0.09150149, (float)0.08824220, (float)0.08498220, (float)0.08172106, + (float)0.07845904, (float)0.07519618, (float)0.07193252, (float)0.06866808, + (float)0.06540315, (float)0.06213728, (float)0.05887074, (float)0.05560357, + (float)0.05233581, (float)0.04906749, (float)0.04579888, (float)0.04252954, + (float)0.03925974, (float)0.03598953, (float)0.03271893, (float)0.02944798, + (float)0.02617695, (float)0.02290541, (float)0.01963361, (float)0.01636161, + (float)0.01308943, (float)0.00981712, (float)0.00654493, (float)0.00327244, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, + (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000}; #endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_WINDOWS_PRIVATE_H_ diff --git a/modules/audio_processing/residual_echo_detector.cc b/modules/audio_processing/residual_echo_detector.cc index aec545aa41..e80501358e 100644 --- a/modules/audio_processing/residual_echo_detector.cc +++ b/modules/audio_processing/residual_echo_detector.cc @@ -141,19 +141,20 @@ void ResidualEchoDetector::AnalyzeCaptureAudio( read_index -= kLookbackFrames; } RTC_DCHECK_LT(read_index, render_power_.size()); - RTC_LOG_F(LS_ERROR) - << "Echo detector internal state: {" - "Echo likelihood: " << echo_likelihood_ - << ", Best Delay: " << best_delay - << ", Covariance: " << covariances_[best_delay].covariance() - << ", Last capture power: " << capture_power - << ", Capture mean: " << capture_mean - << ", Capture_standard deviation: " << capture_std_deviation - << ", Last render power: " << render_power_[read_index] - << ", Render mean: " << render_power_mean_[read_index] - << ", Render standard deviation: " - << render_power_std_dev_[read_index] - << ", Reliability: " << reliability_ << "}"; + RTC_LOG_F(LS_ERROR) << "Echo detector internal state: {" + "Echo likelihood: " + << echo_likelihood_ << ", Best Delay: " << best_delay + << ", Covariance: " + << covariances_[best_delay].covariance() + << ", Last capture power: " << capture_power + << ", Capture mean: " << capture_mean + << ", Capture_standard deviation: " + << capture_std_deviation << ", Last render power: " + << render_power_[read_index] + << ", Render mean: " << render_power_mean_[read_index] + << ", Render standard deviation: " + << render_power_std_dev_[read_index] + << ", Reliability: " << reliability_ << "}"; log_counter_++; } } diff --git a/modules/audio_processing/rms_level.h b/modules/audio_processing/rms_level.h index ae124b7299..ae45a45baa 100644 --- a/modules/audio_processing/rms_level.h +++ b/modules/audio_processing/rms_level.h @@ -72,4 +72,3 @@ class RmsLevel { } // namespace webrtc #endif // MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ - diff --git a/modules/audio_processing/splitting_filter.cc b/modules/audio_processing/splitting_filter.cc index e2b8f82c36..122bc9cc7f 100644 --- a/modules/audio_processing/splitting_filter.cc +++ b/modules/audio_processing/splitting_filter.cc @@ -63,8 +63,7 @@ void SplittingFilter::TwoBandsAnalysis(const IFChannelBuffer* data, IFChannelBuffer* bands) { RTC_DCHECK_EQ(two_bands_states_.size(), data->num_channels()); for (size_t i = 0; i < two_bands_states_.size(); ++i) { - WebRtcSpl_AnalysisQMF(data->ibuf_const()->channels()[i], - data->num_frames(), + WebRtcSpl_AnalysisQMF(data->ibuf_const()->channels()[i], data->num_frames(), bands->ibuf()->channels(0)[i], bands->ibuf()->channels(1)[i], two_bands_states_[i].analysis_state1, @@ -76,12 +75,11 @@ void SplittingFilter::TwoBandsSynthesis(const IFChannelBuffer* bands, IFChannelBuffer* data) { RTC_DCHECK_LE(data->num_channels(), two_bands_states_.size()); for (size_t i = 0; i < data->num_channels(); ++i) { - WebRtcSpl_SynthesisQMF(bands->ibuf_const()->channels(0)[i], - bands->ibuf_const()->channels(1)[i], - bands->num_frames_per_band(), - data->ibuf()->channels()[i], - two_bands_states_[i].synthesis_state1, - two_bands_states_[i].synthesis_state2); + WebRtcSpl_SynthesisQMF( + bands->ibuf_const()->channels(0)[i], + bands->ibuf_const()->channels(1)[i], bands->num_frames_per_band(), + data->ibuf()->channels()[i], two_bands_states_[i].synthesis_state1, + two_bands_states_[i].synthesis_state2); } } diff --git a/modules/audio_processing/splitting_filter_unittest.cc b/modules/audio_processing/splitting_filter_unittest.cc index 3e0dbb9b9c..1caee64a7d 100644 --- a/modules/audio_processing/splitting_filter_unittest.cc +++ b/modules/audio_processing/splitting_filter_unittest.cc @@ -39,8 +39,7 @@ TEST(SplittingFilterTest, SplitsIntoThreeBandsAndReconstructs) { static const int kFrequenciesHz[kNumBands] = {1000, 12000, 18000}; static const float kAmplitude = 8192.f; static const size_t kChunks = 8; - SplittingFilter splitting_filter(kChannels, - kNumBands, + SplittingFilter splitting_filter(kChannels, kNumBands, kSamplesPer48kHzChannel); IFChannelBuffer in_data(kSamplesPer48kHzChannel, kChannels, kNumBands); IFChannelBuffer bands(kSamplesPer48kHzChannel, kChannels, kNumBands); @@ -48,8 +47,7 @@ TEST(SplittingFilterTest, SplitsIntoThreeBandsAndReconstructs) { for (size_t i = 0; i < kChunks; ++i) { // Input signal generation. bool is_present[kNumBands]; - memset(in_data.fbuf()->channels()[0], - 0, + memset(in_data.fbuf()->channels()[0], 0, kSamplesPer48kHzChannel * sizeof(in_data.fbuf()->channels()[0][0])); for (size_t j = 0; j < kNumBands; ++j) { is_present[j] = i & (static_cast(1) << j); @@ -57,7 +55,7 @@ TEST(SplittingFilterTest, SplitsIntoThreeBandsAndReconstructs) { for (size_t k = 0; k < kSamplesPer48kHzChannel; ++k) { in_data.fbuf()->channels()[0][k] += amplitude * sin(2.f * M_PI * kFrequenciesHz[j] * - (i * kSamplesPer48kHzChannel + k) / kSampleRateHz); + (i * kSamplesPer48kHzChannel + k) / kSampleRateHz); } } // Three band splitting filter. diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index 6a3f31632f..ebf20e35e1 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -128,9 +128,7 @@ DEFINE_int(aecm_routing_mode, DEFINE_int(aecm_comfort_noise, kParameterNotSpecifiedValue, "Activate (1) or deactivate(0) the AECM comfort noise"); -DEFINE_int(agc_mode, - kParameterNotSpecifiedValue, - "Specify the AGC mode (0-2)"); +DEFINE_int(agc_mode, kParameterNotSpecifiedValue, "Specify the AGC mode (0-2)"); DEFINE_int(agc_target_level, kParameterNotSpecifiedValue, "Specify the AGC target level (0-31)"); @@ -147,9 +145,7 @@ DEFINE_float(pre_amplifier_gain_factor, DEFINE_int(vad_likelihood, kParameterNotSpecifiedValue, "Specify the VAD likelihood (0-3)"); -DEFINE_int(ns_level, - kParameterNotSpecifiedValue, - "Specify the NS level (0-3)"); +DEFINE_int(ns_level, kParameterNotSpecifiedValue, "Specify the NS level (0-3)"); DEFINE_int(stream_delay, kParameterNotSpecifiedValue, "Specify the stream delay in ms to use"); @@ -454,8 +450,8 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) { int AudioprocFloatImpl(std::unique_ptr ap_builder, int argc, char* argv[]) { - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 1) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 1) { printf("%s", kUsageDescription); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); diff --git a/modules/audio_processing/test/conversational_speech/generator.cc b/modules/audio_processing/test/conversational_speech/generator.cc index ee3f81a9a2..f6a0b4655f 100644 --- a/modules/audio_processing/test/conversational_speech/generator.cc +++ b/modules/audio_processing/test/conversational_speech/generator.cc @@ -40,8 +40,8 @@ DEFINE_bool(help, false, "Prints this message"); } // namespace int main(int argc, char* argv[]) { - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 1) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 1) { printf("%s", kUsageDescription); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); @@ -60,23 +60,23 @@ int main(int argc, char* argv[]) { conversational_speech::LoadTiming(config.timing_filepath()); // Parse timing and audio tracks. - auto wavreader_factory = rtc::MakeUnique< - conversational_speech::WavReaderFactory>(); + auto wavreader_factory = + rtc::MakeUnique(); conversational_speech::MultiEndCall multiend_call( timing, config.audiotracks_path(), std::move(wavreader_factory)); // Generate output audio tracks. - auto generated_audiotrack_pairs = conversational_speech::Simulate( - multiend_call, config.output_path()); + auto generated_audiotrack_pairs = + conversational_speech::Simulate(multiend_call, config.output_path()); // Show paths to created audio tracks. std::cout << "Output files:" << std::endl; for (const auto& output_paths_entry : *generated_audiotrack_pairs) { std::cout << " speaker: " << output_paths_entry.first << std::endl; std::cout << " near end: " << output_paths_entry.second.near_end - << std::endl; + << std::endl; std::cout << " far end: " << output_paths_entry.second.far_end - << std::endl; + << std::endl; } return 0; diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader.cc b/modules/audio_processing/test/conversational_speech/mock_wavreader.cc index 103483d83e..58d68e68b2 100644 --- a/modules/audio_processing/test/conversational_speech/mock_wavreader.cc +++ b/modules/audio_processing/test/conversational_speech/mock_wavreader.cc @@ -16,10 +16,12 @@ namespace conversational_speech { using testing::Return; -MockWavReader::MockWavReader( - int sample_rate, size_t num_channels, size_t num_samples) - : sample_rate_(sample_rate), num_channels_(num_channels), - num_samples_(num_samples) { +MockWavReader::MockWavReader(int sample_rate, + size_t num_channels, + size_t num_samples) + : sample_rate_(sample_rate), + num_channels_(num_channels), + num_samples_(num_samples) { ON_CALL(*this, SampleRate()).WillByDefault(Return(sample_rate_)); ON_CALL(*this, NumChannels()).WillByDefault(Return(num_channels_)); ON_CALL(*this, NumSamples()).WillByDefault(Return(num_samples_)); diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc index 76f5c80718..eb8e3bed3c 100644 --- a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc +++ b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc @@ -25,10 +25,9 @@ using testing::Invoke; MockWavReaderFactory::MockWavReaderFactory( const Params& default_params, const std::map& params) - : default_params_(default_params), - audiotrack_names_params_(params) { - ON_CALL(*this, Create(_)).WillByDefault(Invoke( - this, &MockWavReaderFactory::CreateMock)); + : default_params_(default_params), audiotrack_names_params_(params) { + ON_CALL(*this, Create(_)) + .WillByDefault(Invoke(this, &MockWavReaderFactory::CreateMock)); } MockWavReaderFactory::MockWavReaderFactory(const Params& default_params) @@ -41,16 +40,15 @@ std::unique_ptr MockWavReaderFactory::CreateMock( const std::string& filepath) { // Search the parameters corresponding to filepath. const rtc::Pathname audiotrack_file_path(filepath); - const auto it = audiotrack_names_params_.find( - audiotrack_file_path.filename()); + const auto it = + audiotrack_names_params_.find(audiotrack_file_path.filename()); // If not found, use default parameters. if (it == audiotrack_names_params_.end()) { RTC_LOG(LS_VERBOSE) << "using default parameters for " << filepath; - return std::unique_ptr( - new MockWavReader(default_params_.sample_rate, - default_params_.num_channels, - default_params_.num_samples)); + return std::unique_ptr(new MockWavReader( + default_params_.sample_rate, default_params_.num_channels, + default_params_.num_samples)); } // Found, use the audiotrack-specific parameters. @@ -58,10 +56,8 @@ std::unique_ptr MockWavReaderFactory::CreateMock( RTC_LOG(LS_VERBOSE) << "sample_rate " << it->second.sample_rate; RTC_LOG(LS_VERBOSE) << "num_channels " << it->second.num_channels; RTC_LOG(LS_VERBOSE) << "num_samples " << it->second.num_samples; - return std::unique_ptr( - new MockWavReader(it->second.sample_rate, - it->second.num_channels, - it->second.num_samples)); + return std::unique_ptr(new MockWavReader( + it->second.sample_rate, it->second.num_channels, it->second.num_samples)); } } // namespace conversational_speech diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h index 4c055cf3ae..e84f5f35cc 100644 --- a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h +++ b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h @@ -25,7 +25,7 @@ namespace conversational_speech { class MockWavReaderFactory : public WavReaderAbstractFactory { public: - struct Params{ + struct Params { int sample_rate; size_t num_channels; size_t num_samples; @@ -36,8 +36,8 @@ class MockWavReaderFactory : public WavReaderAbstractFactory { explicit MockWavReaderFactory(const Params& default_params); ~MockWavReaderFactory(); - MOCK_CONST_METHOD1(Create, std::unique_ptr( - const std::string&)); + MOCK_CONST_METHOD1(Create, + std::unique_ptr(const std::string&)); private: // Creates a MockWavReader instance using the parameters in diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.cc b/modules/audio_processing/test/conversational_speech/multiend_call.cc index f5411bd97f..d633d90e9c 100644 --- a/modules/audio_processing/test/conversational_speech/multiend_call.cc +++ b/modules/audio_processing/test/conversational_speech/multiend_call.cc @@ -21,11 +21,13 @@ namespace test { namespace conversational_speech { MultiEndCall::MultiEndCall( - rtc::ArrayView timing, const std::string& audiotracks_path, + rtc::ArrayView timing, + const std::string& audiotracks_path, std::unique_ptr wavreader_abstract_factory) - : timing_(timing), audiotracks_path_(audiotracks_path), - wavreader_abstract_factory_(std::move(wavreader_abstract_factory)), - valid_(false) { + : timing_(timing), + audiotracks_path_(audiotracks_path), + wavreader_abstract_factory_(std::move(wavreader_abstract_factory)), + valid_(false) { FindSpeakerNames(); if (CreateAudioTrackReaders()) valid_ = CheckTiming(); @@ -49,8 +51,8 @@ bool MultiEndCall::CreateAudioTrackReaders() { continue; // Instance Pathname to retrieve the full path to the audiotrack file. - const rtc::Pathname audiotrack_file_path( - audiotracks_path_, turn.audiotrack_file_name); + const rtc::Pathname audiotrack_file_path(audiotracks_path_, + turn.audiotrack_file_name); // Map the audiotrack file name to a new instance of WavReaderInterface. std::unique_ptr wavreader = @@ -69,8 +71,8 @@ bool MultiEndCall::CreateAudioTrackReaders() { return false; } - audiotrack_readers_.emplace( - turn.audiotrack_file_name, std::move(wavreader)); + audiotrack_readers_.emplace(turn.audiotrack_file_name, + std::move(wavreader)); } return true; @@ -101,10 +103,9 @@ bool MultiEndCall::CheckTiming() { // detect self cross-talk). std::map> speaking_turn_indices; for (const std::string& speaker_name : speaker_names_) { - speaking_turn_indices.emplace( - std::piecewise_construct, - std::forward_as_tuple(speaker_name), - std::forward_as_tuple()); + speaking_turn_indices.emplace(std::piecewise_construct, + std::forward_as_tuple(speaker_name), + std::forward_as_tuple()); } // Parse turns. @@ -115,8 +116,8 @@ bool MultiEndCall::CheckTiming() { << "Audio track reader not created"; // Begin and end timestamps for the current turn. - int offset_samples = millisecond_to_samples( - turn.offset, it->second->SampleRate()); + int offset_samples = + millisecond_to_samples(turn.offset, it->second->SampleRate()); std::size_t begin_timestamp = last_turn.end + offset_samples; std::size_t end_timestamp = begin_timestamp + it->second->NumSamples(); RTC_LOG(LS_INFO) << "turn #" << turn_index << " " << begin_timestamp << "-" @@ -124,16 +125,16 @@ bool MultiEndCall::CheckTiming() { // The order is invalid if the offset is negative and its absolute value is // larger then the duration of the previous turn. - if (offset_samples < 0 && -offset_samples > static_cast( - last_turn.end - last_turn.begin)) { + if (offset_samples < 0 && + -offset_samples > static_cast(last_turn.end - last_turn.begin)) { RTC_LOG(LS_ERROR) << "invalid order"; return false; } // Cross-talk with 3 or more speakers occurs when the beginning of the // current interval falls in the last two turns. - if (turn_index > 1 && in_interval(begin_timestamp, last_turn) - && in_interval(begin_timestamp, second_last_turn)) { + if (turn_index > 1 && in_interval(begin_timestamp, last_turn) && + in_interval(begin_timestamp, second_last_turn)) { RTC_LOG(LS_ERROR) << "cross-talk with 3+ speakers"; return false; } @@ -164,8 +165,9 @@ bool MultiEndCall::CheckTiming() { std::vector speaking_turns_for_name; std::copy_if(speaking_turns_.begin(), speaking_turns_.end(), std::back_inserter(speaking_turns_for_name), - [&speaker_name](const SpeakingTurn& st){ - return st.speaker_name == speaker_name; }); + [&speaker_name](const SpeakingTurn& st) { + return st.speaker_name == speaker_name; + }); // Check for overlap between adjacent elements. // This is a sufficient condition for self cross-talk since the intervals @@ -173,7 +175,8 @@ bool MultiEndCall::CheckTiming() { auto overlap = std::adjacent_find( speaking_turns_for_name.begin(), speaking_turns_for_name.end(), [](const SpeakingTurn& a, const SpeakingTurn& b) { - return a.end > b.begin; }); + return a.end > b.begin; + }); if (overlap != speaking_turns_for_name.end()) { RTC_LOG(LS_ERROR) << "Self cross-talk detected"; diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.h b/modules/audio_processing/test/conversational_speech/multiend_call.h index d91058f654..a4eff382bd 100644 --- a/modules/audio_processing/test/conversational_speech/multiend_call.h +++ b/modules/audio_processing/test/conversational_speech/multiend_call.h @@ -51,18 +51,22 @@ class MultiEndCall { }; MultiEndCall( - rtc::ArrayView timing, const std::string& audiotracks_path, + rtc::ArrayView timing, + const std::string& audiotracks_path, std::unique_ptr wavreader_abstract_factory); ~MultiEndCall(); const std::set& speaker_names() const { return speaker_names_; } const std::map>& - audiotrack_readers() const { return audiotrack_readers_; } + audiotrack_readers() const { + return audiotrack_readers_; + } bool valid() const { return valid_; } int sample_rate() const { return sample_rate_hz_; } size_t total_duration_samples() const { return total_duration_samples_; } const std::vector& speaking_turns() const { - return speaking_turns_; } + return speaking_turns_; + } private: // Finds unique speaker names. diff --git a/modules/audio_processing/test/conversational_speech/simulator.cc b/modules/audio_processing/test/conversational_speech/simulator.cc index 437a973bdc..946aee1a99 100644 --- a/modules/audio_processing/test/conversational_speech/simulator.cc +++ b/modules/audio_processing/test/conversational_speech/simulator.cc @@ -38,28 +38,27 @@ using conversational_speech::WavReaderInterface; // Combines output path and speaker names to define the output file paths for // the near-end and far=end audio tracks. std::unique_ptr> - InitSpeakerOutputFilePaths(const std::set& speaker_names, - const std::string& output_path) { +InitSpeakerOutputFilePaths(const std::set& speaker_names, + const std::string& output_path) { // Create map. - auto speaker_output_file_paths_map = rtc::MakeUnique< - std::map>(); + auto speaker_output_file_paths_map = + rtc::MakeUnique>(); // Add near-end and far-end output paths into the map. for (const auto& speaker_name : speaker_names) { - const rtc::Pathname near_end_path( - output_path, "s_" + speaker_name + "-near_end.wav"); + const rtc::Pathname near_end_path(output_path, + "s_" + speaker_name + "-near_end.wav"); RTC_LOG(LS_VERBOSE) << "The near-end audio track will be created in " << near_end_path.pathname() << "."; - const rtc::Pathname far_end_path( - output_path, "s_" + speaker_name + "-far_end.wav"); + const rtc::Pathname far_end_path(output_path, + "s_" + speaker_name + "-far_end.wav"); RTC_LOG(LS_VERBOSE) << "The far-end audio track will be created in " << far_end_path.pathname() << "."; // Add to map. speaker_output_file_paths_map->emplace( - std::piecewise_construct, - std::forward_as_tuple(speaker_name), + std::piecewise_construct, std::forward_as_tuple(speaker_name), std::forward_as_tuple(near_end_path.pathname(), far_end_path.pathname())); } @@ -71,16 +70,13 @@ std::unique_ptr> // output track of a speaker. class SpeakerWavWriters { public: - SpeakerWavWriters( - const SpeakerOutputFilePaths& output_file_paths, int sample_rate) - : near_end_wav_writer_(output_file_paths.near_end, sample_rate, 1u), - far_end_wav_writer_(output_file_paths.far_end, sample_rate, 1u) {} - WavWriter* near_end_wav_writer() { - return &near_end_wav_writer_; - } - WavWriter* far_end_wav_writer() { - return &far_end_wav_writer_; - } + SpeakerWavWriters(const SpeakerOutputFilePaths& output_file_paths, + int sample_rate) + : near_end_wav_writer_(output_file_paths.near_end, sample_rate, 1u), + far_end_wav_writer_(output_file_paths.far_end, sample_rate, 1u) {} + WavWriter* near_end_wav_writer() { return &near_end_wav_writer_; } + WavWriter* far_end_wav_writer() { return &far_end_wav_writer_; } + private: WavWriter near_end_wav_writer_; WavWriter far_end_wav_writer_; @@ -89,18 +85,18 @@ class SpeakerWavWriters { // Initializes one WavWriter instance for each speaker and both the near-end and // far-end output tracks. std::unique_ptr> - InitSpeakersWavWriters(const std::map& - speaker_output_file_paths, int sample_rate) { +InitSpeakersWavWriters(const std::map& + speaker_output_file_paths, + int sample_rate) { // Create map. - auto speaker_wav_writers_map = rtc::MakeUnique< - std::map>(); + auto speaker_wav_writers_map = + rtc::MakeUnique>(); // Add SpeakerWavWriters instance into the map. for (auto it = speaker_output_file_paths.begin(); - it != speaker_output_file_paths.end(); ++it) { + it != speaker_output_file_paths.end(); ++it) { speaker_wav_writers_map->emplace( - std::piecewise_construct, - std::forward_as_tuple(it->first), + std::piecewise_construct, std::forward_as_tuple(it->first), std::forward_as_tuple(it->second, sample_rate)); } @@ -112,17 +108,16 @@ std::unique_ptr>> PreloadAudioTracks( const std::map>& audiotrack_readers) { // Create map. - auto audiotracks_map = rtc::MakeUnique< - std::map>>(); + auto audiotracks_map = + rtc::MakeUnique>>(); // Add audio track vectors. for (auto it = audiotrack_readers.begin(); it != audiotrack_readers.end(); - ++it) { + ++it) { // Add map entry. - audiotracks_map->emplace( - std::piecewise_construct, - std::forward_as_tuple(it->first), - std::forward_as_tuple(it->second->NumSamples())); + audiotracks_map->emplace(std::piecewise_construct, + std::forward_as_tuple(it->first), + std::forward_as_tuple(it->second->NumSamples())); // Read samples. it->second->ReadInt16Samples(audiotracks_map->at(it->first)); @@ -136,7 +131,8 @@ std::unique_ptr>> PreloadAudioTracks( // adds zeros as left padding. The padding corresponds to intervals during which // a speaker is not active. void PadLeftWriteChunk(rtc::ArrayView source_samples, - size_t interval_begin, WavWriter* wav_writer) { + size_t interval_begin, + WavWriter* wav_writer) { // Add left padding. RTC_CHECK(wav_writer); RTC_CHECK_GE(interval_begin, wav_writer->num_samples()); @@ -179,11 +175,12 @@ void ScaleSignal(rtc::ArrayView source_samples, namespace conversational_speech { std::unique_ptr> Simulate( - const MultiEndCall& multiend_call, const std::string& output_path) { + const MultiEndCall& multiend_call, + const std::string& output_path) { // Set output file paths and initialize wav writers. const auto& speaker_names = multiend_call.speaker_names(); - auto speaker_output_file_paths = InitSpeakerOutputFilePaths( - speaker_names, output_path); + auto speaker_output_file_paths = + InitSpeakerOutputFilePaths(speaker_names, output_path); auto speakers_wav_writers = InitSpeakersWavWriters( *speaker_output_file_paths, multiend_call.sample_rate()); diff --git a/modules/audio_processing/test/conversational_speech/simulator.h b/modules/audio_processing/test/conversational_speech/simulator.h index 671c3b9c73..743db420f5 100644 --- a/modules/audio_processing/test/conversational_speech/simulator.h +++ b/modules/audio_processing/test/conversational_speech/simulator.h @@ -26,16 +26,16 @@ namespace conversational_speech { struct SpeakerOutputFilePaths { SpeakerOutputFilePaths(const std::string& new_near_end, const std::string& new_far_end) - : near_end(new_near_end), - far_end(new_far_end) {} + : near_end(new_near_end), far_end(new_far_end) {} // Paths to the near-end and far-end audio track files. const std::string near_end; const std::string far_end; }; // Generates the near-end and far-end audio track pairs for each speaker. -std::unique_ptr> - Simulate(const MultiEndCall& multiend_call, const std::string& output_path); +std::unique_ptr> Simulate( + const MultiEndCall& multiend_call, + const std::string& output_path); } // namespace conversational_speech } // namespace test diff --git a/modules/audio_processing/test/conversational_speech/timing.cc b/modules/audio_processing/test/conversational_speech/timing.cc index 2e96d2b783..6c19f32807 100644 --- a/modules/audio_processing/test/conversational_speech/timing.cc +++ b/modules/audio_processing/test/conversational_speech/timing.cc @@ -19,7 +19,7 @@ namespace webrtc { namespace test { namespace conversational_speech { -bool Turn::operator==(const Turn &b) const { +bool Turn::operator==(const Turn& b) const { return b.speaker_name == speaker_name && b.audiotrack_file_name == audiotrack_file_name && b.offset == offset && b.gain == gain; diff --git a/modules/audio_processing/test/conversational_speech/timing.h b/modules/audio_processing/test/conversational_speech/timing.h index 07a26e14c7..812f3d55cc 100644 --- a/modules/audio_processing/test/conversational_speech/timing.h +++ b/modules/audio_processing/test/conversational_speech/timing.h @@ -20,7 +20,7 @@ namespace webrtc { namespace test { namespace conversational_speech { -struct Turn{ +struct Turn { Turn(std::string new_speaker_name, std::string new_audiotrack_file_name, int new_offset, @@ -29,7 +29,7 @@ struct Turn{ audiotrack_file_name(new_audiotrack_file_name), offset(new_offset), gain(gain) {} - bool operator==(const Turn &b) const; + bool operator==(const Turn& b) const; std::string speaker_name; std::string audiotrack_file_name; int offset; diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc index 8342d3fed8..1a5cf8f2e2 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc +++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc @@ -37,17 +37,11 @@ class WavReaderAdaptor final : public WavReaderInterface { return wav_reader_.ReadSamples(samples.size(), samples.begin()); } - int SampleRate() const override { - return wav_reader_.sample_rate(); - } + int SampleRate() const override { return wav_reader_.sample_rate(); } - size_t NumChannels() const override { - return wav_reader_.num_channels(); - } + size_t NumChannels() const override { return wav_reader_.num_channels(); } - size_t NumSamples() const override { - return wav_reader_.num_samples(); - } + size_t NumSamples() const override { return wav_reader_.num_samples(); } private: WavReader wav_reader_; diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.h b/modules/audio_processing/test/conversational_speech/wavreader_factory.h index e168d0d71f..2f86bf5ae0 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_factory.h +++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.h @@ -25,8 +25,8 @@ class WavReaderFactory : public WavReaderAbstractFactory { public: WavReaderFactory(); ~WavReaderFactory() override; - std::unique_ptr Create(const std::string& filepath) const - override; + std::unique_ptr Create( + const std::string& filepath) const override; }; } // namespace conversational_speech diff --git a/modules/audio_processing/test/debug_dump_replayer.cc b/modules/audio_processing/test/debug_dump_replayer.cc index bc95cfd749..a06c76e32a 100644 --- a/modules/audio_processing/test/debug_dump_replayer.cc +++ b/modules/audio_processing/test/debug_dump_replayer.cc @@ -23,8 +23,8 @@ void MaybeResetBuffer(std::unique_ptr>* buffer, auto& buffer_ref = *buffer; if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() || buffer_ref->num_channels() != config.num_channels()) { - buffer_ref.reset(new ChannelBuffer(config.num_frames(), - config.num_channels())); + buffer_ref.reset( + new ChannelBuffer(config.num_frames(), config.num_channels())); } } diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc index d90d14fa8f..4e2943395e 100644 --- a/modules/audio_processing/test/debug_dump_test.cc +++ b/modules/audio_processing/test/debug_dump_test.cc @@ -33,8 +33,8 @@ void MaybeResetBuffer(std::unique_ptr>* buffer, auto& buffer_ref = *buffer; if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() || buffer_ref->num_channels() != config.num_channels()) { - buffer_ref.reset(new ChannelBuffer(config.num_frames(), - config.num_channels())); + buffer_ref.reset( + new ChannelBuffer(config.num_frames(), config.num_channels())); } } @@ -87,7 +87,8 @@ class DebugDumpGenerator { AudioProcessing* apm() const { return apm_.get(); } private: - static void ReadAndDeinterleave(ResampleInputAudioFile* audio, int channels, + static void ReadAndDeinterleave(ResampleInputAudioFile* audio, + int channels, const StreamConfig& config, float* const* buffer); @@ -227,11 +228,10 @@ void DebugDumpGenerator::Process(size_t num_blocks) { apm_->ProcessStream(input_->channels(), input_config_, output_config_, output_->channels())); - RTC_CHECK_EQ(AudioProcessing::kNoError, - apm_->ProcessReverseStream(reverse_->channels(), - reverse_config_, - reverse_config_, - reverse_->channels())); + RTC_CHECK_EQ( + AudioProcessing::kNoError, + apm_->ProcessReverseStream(reverse_->channels(), reverse_config_, + reverse_config_, reverse_->channels())); } } @@ -288,9 +288,9 @@ void DebugDumpTest::VerifyDebugDump(const std::string& in_filename) { ASSERT_EQ(output_config.num_frames() * sizeof(float), msg->output_channel(0).size()); for (int i = 0; i < msg->output_channel_size(); ++i) { - ASSERT_EQ(0, memcmp(output->channels()[i], - msg->output_channel(i).data(), - msg->output_channel(i).size())); + ASSERT_EQ(0, + memcmp(output->channels()[i], msg->output_channel(i).data(), + msg->output_channel(i).size())); } } } diff --git a/modules/audio_processing/test/fake_recording_device.h b/modules/audio_processing/test/fake_recording_device.h index 0d93b7a249..13f94a7e22 100644 --- a/modules/audio_processing/test/fake_recording_device.h +++ b/modules/audio_processing/test/fake_recording_device.h @@ -15,8 +15,8 @@ #include #include -#include "api/audio/audio_frame.h" #include "api/array_view.h" +#include "api/audio/audio_frame.h" #include "common_audio/channel_buffer.h" #include "rtc_base/checks.h" diff --git a/modules/audio_processing/test/protobuf_utils.cc b/modules/audio_processing/test/protobuf_utils.cc index 3b623b915c..6ecc97eca3 100644 --- a/modules/audio_processing/test/protobuf_utils.cc +++ b/modules/audio_processing/test/protobuf_utils.cc @@ -14,8 +14,8 @@ namespace webrtc { size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr* bytes) { - // The "wire format" for the size is little-endian. Assume we're running on - // a little-endian machine. +// The "wire format" for the size is little-endian. Assume we're running on +// a little-endian machine. #ifndef WEBRTC_ARCH_LITTLE_ENDIAN #error "Need to convert messsage from little-endian." #endif diff --git a/modules/audio_processing/test/test_utils.cc b/modules/audio_processing/test/test_utils.cc index 846ce2b647..937775e64b 100644 --- a/modules/audio_processing/test/test_utils.cc +++ b/modules/audio_processing/test/test_utils.cc @@ -91,9 +91,9 @@ void WriteFloatData(const float* const* data, } // TODO(aluebs): Use ScaleToInt16Range() from audio_util for (size_t i = 0; i < length; ++i) { - buffer[i] = buffer[i] > 0 ? - buffer[i] * std::numeric_limits::max() : - -buffer[i] * std::numeric_limits::min(); + buffer[i] = buffer[i] > 0 + ? buffer[i] * std::numeric_limits::max() + : -buffer[i] * std::numeric_limits::min(); } if (wav_file) { wav_file->WriteSamples(buffer.get(), length); @@ -113,11 +113,10 @@ size_t SamplesFromRate(int rate) { return static_cast(AudioProcessing::kChunkSizeMs * rate / 1000); } -void SetFrameSampleRate(AudioFrame* frame, - int sample_rate_hz) { +void SetFrameSampleRate(AudioFrame* frame, int sample_rate_hz) { frame->sample_rate_hz_ = sample_rate_hz; - frame->samples_per_channel_ = AudioProcessing::kChunkSizeMs * - sample_rate_hz / 1000; + frame->samples_per_channel_ = + AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000; } AudioProcessing::ChannelLayout LayoutFromChannels(size_t num_channels) { diff --git a/modules/audio_processing/test/test_utils.h b/modules/audio_processing/test/test_utils.h index 43f907a358..6e4154ad6d 100644 --- a/modules/audio_processing/test/test_utils.h +++ b/modules/audio_processing/test/test_utils.h @@ -91,8 +91,7 @@ FILE* OpenFile(const std::string& filename, const char* mode); size_t SamplesFromRate(int rate); -void SetFrameSampleRate(AudioFrame* frame, - int sample_rate_hz); +void SetFrameSampleRate(AudioFrame* frame, int sample_rate_hz); template void SetContainerFormat(int sample_rate_hz, @@ -130,14 +129,14 @@ float ComputeSNR(const T* ref, const T* test, size_t length, float* variance) { // Returns a vector parsed from whitespace delimited values in to_parse, // or an empty vector if the string could not be parsed. -template +template std::vector ParseList(const std::string& to_parse) { std::vector values; std::istringstream str(to_parse); std::copy( - std::istream_iterator(str), - std::istream_iterator(), + std::istream_iterator(str), // no-presubmit-check TODO(webrtc:8982) + std::istream_iterator(), // no-presubmit-check TODO(webrtc:8982) std::back_inserter(values)); return values; diff --git a/modules/audio_processing/three_band_filter_bank.cc b/modules/audio_processing/three_band_filter_bank.cc index f5a319bc54..dbbfc283c5 100644 --- a/modules/audio_processing/three_band_filter_bank.cc +++ b/modules/audio_processing/three_band_filter_bank.cc @@ -68,19 +68,19 @@ const size_t kNumCoeffs = 4; // A Kaiser window is used because of its flexibility and the alpha is set to // 3.5, since that sets a stop band attenuation of 40dB ensuring a fast // transition. -const float kLowpassCoeffs[kNumBands * kSparsity][kNumCoeffs] = - {{-0.00047749f, -0.00496888f, +0.16547118f, +0.00425496f}, - {-0.00173287f, -0.01585778f, +0.14989004f, +0.00994113f}, - {-0.00304815f, -0.02536082f, +0.12154542f, +0.01157993f}, - {-0.00383509f, -0.02982767f, +0.08543175f, +0.00983212f}, - {-0.00346946f, -0.02587886f, +0.04760441f, +0.00607594f}, - {-0.00154717f, -0.01136076f, +0.01387458f, +0.00186353f}, - {+0.00186353f, +0.01387458f, -0.01136076f, -0.00154717f}, - {+0.00607594f, +0.04760441f, -0.02587886f, -0.00346946f}, - {+0.00983212f, +0.08543175f, -0.02982767f, -0.00383509f}, - {+0.01157993f, +0.12154542f, -0.02536082f, -0.00304815f}, - {+0.00994113f, +0.14989004f, -0.01585778f, -0.00173287f}, - {+0.00425496f, +0.16547118f, -0.00496888f, -0.00047749f}}; +const float kLowpassCoeffs[kNumBands * kSparsity][kNumCoeffs] = { + {-0.00047749f, -0.00496888f, +0.16547118f, +0.00425496f}, + {-0.00173287f, -0.01585778f, +0.14989004f, +0.00994113f}, + {-0.00304815f, -0.02536082f, +0.12154542f, +0.01157993f}, + {-0.00383509f, -0.02982767f, +0.08543175f, +0.00983212f}, + {-0.00346946f, -0.02587886f, +0.04760441f, +0.00607594f}, + {-0.00154717f, -0.01136076f, +0.01387458f, +0.00186353f}, + {+0.00186353f, +0.01387458f, -0.01136076f, -0.00154717f}, + {+0.00607594f, +0.04760441f, -0.02587886f, -0.00346946f}, + {+0.00983212f, +0.08543175f, -0.02982767f, -0.00383509f}, + {+0.01157993f, +0.12154542f, -0.02536082f, -0.00304815f}, + {+0.00994113f, +0.14989004f, -0.01585778f, -0.00173287f}, + {+0.00425496f, +0.16547118f, -0.00496888f, -0.00047749f}}; // Downsamples |in| into |out|, taking one every |kNumbands| starting from // |offset|. |split_length| is the |out| length. |in| has to be at least @@ -150,8 +150,7 @@ void ThreeBandFilterBank::Analysis(const float* in, Downsample(in, in_buffer_.size(), kNumBands - i - 1, &in_buffer_[0]); for (size_t j = 0; j < kSparsity; ++j) { const size_t offset = i + j * kNumBands; - analysis_filters_[offset]->Filter(&in_buffer_[0], - in_buffer_.size(), + analysis_filters_[offset]->Filter(&in_buffer_[0], in_buffer_.size(), &out_buffer_[0]); DownModulate(&out_buffer_[0], out_buffer_.size(), offset, out); } @@ -173,15 +172,13 @@ void ThreeBandFilterBank::Synthesis(const float* const* in, for (size_t j = 0; j < kSparsity; ++j) { const size_t offset = i + j * kNumBands; UpModulate(in, in_buffer_.size(), offset, &in_buffer_[0]); - synthesis_filters_[offset]->Filter(&in_buffer_[0], - in_buffer_.size(), + synthesis_filters_[offset]->Filter(&in_buffer_[0], in_buffer_.size(), &out_buffer_[0]); Upsample(&out_buffer_[0], out_buffer_.size(), i, out); } } } - // Modulates |in| by |dct_modulation_| and accumulates it in each of the // |kNumBands| bands of |out|. |offset| is the index in the period of the // cosines used for modulation. |split_length| is the length of |in| and each diff --git a/modules/audio_processing/transient/click_annotate.cc b/modules/audio_processing/transient/click_annotate.cc index 1f01d01942..ce646b51be 100644 --- a/modules/audio_processing/transient/click_annotate.cc +++ b/modules/audio_processing/transient/click_annotate.cc @@ -73,9 +73,7 @@ int main(int argc, char* argv[]) { // Read first buffer from the PCM test file. size_t file_samples_read = ReadInt16FromFileToFloatBuffer( - pcm_file.get(), - audio_buffer_length, - audio_buffer.get()); + pcm_file.get(), audio_buffer_length, audio_buffer.get()); for (int time = 0; file_samples_read > 0; time += chunk_size_ms) { // Pad the rest of the buffer with zeros. for (size_t i = file_samples_read; i < audio_buffer_length; ++i) { @@ -92,14 +90,12 @@ int main(int argc, char* argv[]) { send_times.push_back(value); // Read next buffer from the PCM test file. - file_samples_read = ReadInt16FromFileToFloatBuffer(pcm_file.get(), - audio_buffer_length, - audio_buffer.get()); + file_samples_read = ReadInt16FromFileToFloatBuffer( + pcm_file.get(), audio_buffer_length, audio_buffer.get()); } - size_t floats_written = WriteFloatBufferToFile(dat_file.get(), - send_times.size(), - &send_times[0]); + size_t floats_written = + WriteFloatBufferToFile(dat_file.get(), send_times.size(), &send_times[0]); if (floats_written == 0) { printf("\nThe send times could not be written to DAT file\n\n"); diff --git a/modules/audio_processing/transient/common.h b/modules/audio_processing/transient/common.h index 69546fc57b..63c9a7b315 100644 --- a/modules/audio_processing/transient/common.h +++ b/modules/audio_processing/transient/common.h @@ -22,6 +22,6 @@ enum { kSampleRate48kHz = 48000 }; -} // namespace ts -} // namespace webrtc +} // namespace ts +} // namespace webrtc #endif // MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_ diff --git a/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h b/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h index 4de24e0fcb..92233bfd74 100644 --- a/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h +++ b/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h @@ -19,44 +19,25 @@ namespace webrtc { const int kDaubechies8CoefficientsLength = 16; -const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength] - = { - -5.44158422430816093862e-02f, - 3.12871590914465924627e-01f, - -6.75630736298012846142e-01f, - 5.85354683654869090148e-01f, - 1.58291052560238926228e-02f, - -2.84015542962428091389e-01f, - -4.72484573997972536787e-04f, - 1.28747426620186011803e-01f, - 1.73693010020221083600e-02f, - -4.40882539310647192377e-02f, - -1.39810279170155156436e-02f, - 8.74609404701565465445e-03f, - 4.87035299301066034600e-03f, - -3.91740372995977108837e-04f, - -6.75449405998556772109e-04f, - -1.17476784002281916305e-04f -}; +const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength] = { + -5.44158422430816093862e-02f, 3.12871590914465924627e-01f, + -6.75630736298012846142e-01f, 5.85354683654869090148e-01f, + 1.58291052560238926228e-02f, -2.84015542962428091389e-01f, + -4.72484573997972536787e-04f, 1.28747426620186011803e-01f, + 1.73693010020221083600e-02f, -4.40882539310647192377e-02f, + -1.39810279170155156436e-02f, 8.74609404701565465445e-03f, + 4.87035299301066034600e-03f, -3.91740372995977108837e-04f, + -6.75449405998556772109e-04f, -1.17476784002281916305e-04f}; const float kDaubechies8LowPassCoefficients[kDaubechies8CoefficientsLength] = { - -1.17476784002281916305e-04f, - 6.75449405998556772109e-04f, - -3.91740372995977108837e-04f, - -4.87035299301066034600e-03f, - 8.74609404701565465445e-03f, - 1.39810279170155156436e-02f, - -4.40882539310647192377e-02f, - -1.73693010020221083600e-02f, - 1.28747426620186011803e-01f, - 4.72484573997972536787e-04f, - -2.84015542962428091389e-01f, - -1.58291052560238926228e-02f, - 5.85354683654869090148e-01f, - 6.75630736298012846142e-01f, - 3.12871590914465924627e-01f, - 5.44158422430816093862e-02f -}; + -1.17476784002281916305e-04f, 6.75449405998556772109e-04f, + -3.91740372995977108837e-04f, -4.87035299301066034600e-03f, + 8.74609404701565465445e-03f, 1.39810279170155156436e-02f, + -4.40882539310647192377e-02f, -1.73693010020221083600e-02f, + 1.28747426620186011803e-01f, 4.72484573997972536787e-04f, + -2.84015542962428091389e-01f, -1.58291052560238926228e-02f, + 5.85354683654869090148e-01f, 6.75630736298012846142e-01f, + 3.12871590914465924627e-01f, 5.44158422430816093862e-02f}; } // namespace webrtc diff --git a/modules/audio_processing/transient/dyadic_decimator.h b/modules/audio_processing/transient/dyadic_decimator.h index 104f95d3af..e5b19613e5 100644 --- a/modules/audio_processing/transient/dyadic_decimator.h +++ b/modules/audio_processing/transient/dyadic_decimator.h @@ -44,7 +44,7 @@ inline size_t GetOutLengthToDyadicDecimate(size_t in_length, // GetOutLengthToDyadicDecimate(). // Must be previously allocated. // Returns the number of output samples, -1 on error. -template +template static size_t DyadicDecimate(const T* in, size_t in_length, bool odd_sequence, diff --git a/modules/audio_processing/transient/dyadic_decimator_unittest.cc b/modules/audio_processing/transient/dyadic_decimator_unittest.cc index c407f47ffb..3e65a7b9bf 100644 --- a/modules/audio_processing/transient/dyadic_decimator_unittest.cc +++ b/modules/audio_processing/transient/dyadic_decimator_unittest.cc @@ -19,7 +19,7 @@ static const size_t kOddBufferLength = 5; static const size_t kOutBufferLength = 3; int16_t const test_buffer_even_len[] = {0, 1, 2, 3, 4, 5}; -int16_t const test_buffer_odd_len[] = {0, 1, 2, 3, 4}; +int16_t const test_buffer_odd_len[] = {0, 1, 2, 3, 4}; int16_t test_buffer_out[kOutBufferLength]; TEST(DyadicDecimatorTest, GetOutLengthToDyadicDecimate) { @@ -29,30 +29,23 @@ TEST(DyadicDecimatorTest, GetOutLengthToDyadicDecimate) { EXPECT_EQ(2u, GetOutLengthToDyadicDecimate(5, true)); } - TEST(DyadicDecimatorTest, DyadicDecimateErrorValues) { size_t out_samples = 0; - out_samples = DyadicDecimate(static_cast(NULL), - kEvenBufferLength, + out_samples = DyadicDecimate(static_cast(NULL), kEvenBufferLength, false, // Even sequence. - test_buffer_out, - kOutBufferLength); + test_buffer_out, kOutBufferLength); EXPECT_EQ(0u, out_samples); - out_samples = DyadicDecimate(test_buffer_even_len, - kEvenBufferLength, + out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength, false, // Even sequence. - static_cast(NULL), - kOutBufferLength); + static_cast(NULL), kOutBufferLength); EXPECT_EQ(0u, out_samples); // Less than required |out_length|. - out_samples = DyadicDecimate(test_buffer_even_len, - kEvenBufferLength, + out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength, false, // Even sequence. - test_buffer_out, - 2); + test_buffer_out, 2); EXPECT_EQ(0u, out_samples); } @@ -60,11 +53,9 @@ TEST(DyadicDecimatorTest, DyadicDecimateEvenLengthEvenSequence) { size_t expected_out_samples = GetOutLengthToDyadicDecimate(kEvenBufferLength, false); - size_t out_samples = DyadicDecimate(test_buffer_even_len, - kEvenBufferLength, + size_t out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength, false, // Even sequence. - test_buffer_out, - kOutBufferLength); + test_buffer_out, kOutBufferLength); EXPECT_EQ(expected_out_samples, out_samples); @@ -77,11 +68,9 @@ TEST(DyadicDecimatorTest, DyadicDecimateEvenLengthOddSequence) { size_t expected_out_samples = GetOutLengthToDyadicDecimate(kEvenBufferLength, true); - size_t out_samples = DyadicDecimate(test_buffer_even_len, - kEvenBufferLength, + size_t out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength, true, // Odd sequence. - test_buffer_out, - kOutBufferLength); + test_buffer_out, kOutBufferLength); EXPECT_EQ(expected_out_samples, out_samples); @@ -94,11 +83,9 @@ TEST(DyadicDecimatorTest, DyadicDecimateOddLengthEvenSequence) { size_t expected_out_samples = GetOutLengthToDyadicDecimate(kOddBufferLength, false); - size_t out_samples = DyadicDecimate(test_buffer_odd_len, - kOddBufferLength, + size_t out_samples = DyadicDecimate(test_buffer_odd_len, kOddBufferLength, false, // Even sequence. - test_buffer_out, - kOutBufferLength); + test_buffer_out, kOutBufferLength); EXPECT_EQ(expected_out_samples, out_samples); @@ -111,11 +98,9 @@ TEST(DyadicDecimatorTest, DyadicDecimateOddLengthOddSequence) { size_t expected_out_samples = GetOutLengthToDyadicDecimate(kOddBufferLength, true); - size_t out_samples = DyadicDecimate(test_buffer_odd_len, - kOddBufferLength, + size_t out_samples = DyadicDecimate(test_buffer_odd_len, kOddBufferLength, true, // Odd sequence. - test_buffer_out, - kOutBufferLength); + test_buffer_out, kOutBufferLength); EXPECT_EQ(expected_out_samples, out_samples); diff --git a/modules/audio_processing/transient/file_utils_unittest.cc b/modules/audio_processing/transient/file_utils_unittest.cc index d9880f9b85..05f83411d2 100644 --- a/modules/audio_processing/transient/file_utils_unittest.cc +++ b/modules/audio_processing/transient/file_utils_unittest.cc @@ -11,8 +11,8 @@ #include "modules/audio_processing/transient/file_utils.h" #include -#include #include +#include #include #include "rtc_base/system/file_wrapper.h" @@ -26,18 +26,18 @@ static const uint8_t kPiBytesf[4] = {0xDB, 0x0F, 0x49, 0x40}; static const uint8_t kEBytesf[4] = {0x54, 0xF8, 0x2D, 0x40}; static const uint8_t kAvogadroBytesf[4] = {0x2F, 0x0C, 0xFF, 0x66}; -static const uint8_t kPiBytes[8] = - {0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40}; -static const uint8_t kEBytes[8] = - {0x69, 0x57, 0x14, 0x8B, 0x0A, 0xBF, 0x05, 0x40}; -static const uint8_t kAvogadroBytes[8] = - {0xF4, 0xBC, 0xA8, 0xDF, 0x85, 0xE1, 0xDF, 0x44}; +static const uint8_t kPiBytes[8] = {0x18, 0x2D, 0x44, 0x54, + 0xFB, 0x21, 0x09, 0x40}; +static const uint8_t kEBytes[8] = {0x69, 0x57, 0x14, 0x8B, + 0x0A, 0xBF, 0x05, 0x40}; +static const uint8_t kAvogadroBytes[8] = {0xF4, 0xBC, 0xA8, 0xDF, + 0x85, 0xE1, 0xDF, 0x44}; static const double kPi = 3.14159265358979323846; static const double kE = 2.71828182845904523536; static const double kAvogadro = 602214100000000000000000.0; -class TransientFileUtilsTest: public ::testing::Test { +class TransientFileUtilsTest : public ::testing::Test { protected: TransientFileUtilsTest() : kTestFileName( @@ -47,12 +47,10 @@ class TransientFileUtilsTest: public ::testing::Test { test::ResourcePath("audio_processing/transient/float-utils", "dat")) {} - ~TransientFileUtilsTest() override { - CleanupTempFiles(); - } + ~TransientFileUtilsTest() override { CleanupTempFiles(); } std::string CreateTempFilename(const std::string& dir, - const std::string& prefix) { + const std::string& prefix) { std::string filename = test::TempFilename(dir, prefix); temp_filenames_.push_back(filename); return filename; @@ -170,9 +168,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) { const size_t kBufferLength = 12; std::unique_ptr buffer(new int16_t[kBufferLength]); - EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), - kBufferLength, - buffer.get())); + EXPECT_EQ(kBufferLength, + ReadInt16BufferFromFile(file.get(), kBufferLength, buffer.get())); EXPECT_EQ(22377, buffer[4]); EXPECT_EQ(16389, buffer[7]); EXPECT_EQ(17631, buffer[kBufferLength - 1]); @@ -184,9 +181,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) { // int16s read. const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; buffer.reset(new int16_t[kBufferLenghtLargerThanFile]); - EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), - kBufferLenghtLargerThanFile, - buffer.get())); + EXPECT_EQ(kBufferLength, + ReadInt16BufferFromFile(file.get(), kBufferLenghtLargerThanFile, + buffer.get())); EXPECT_EQ(11544, buffer[0]); EXPECT_EQ(22377, buffer[4]); EXPECT_EQ(16389, buffer[7]); @@ -211,9 +208,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) { const size_t kBufferLength = 12; std::unique_ptr buffer(new float[kBufferLength]); - EXPECT_EQ(kBufferLength, ReadInt16FromFileToFloatBuffer(file.get(), - kBufferLength, - buffer.get())); + EXPECT_EQ(kBufferLength, ReadInt16FromFileToFloatBuffer( + file.get(), kBufferLength, buffer.get())); EXPECT_DOUBLE_EQ(11544, buffer[0]); EXPECT_DOUBLE_EQ(22377, buffer[4]); @@ -228,9 +224,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) { const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; buffer.reset(new float[kBufferLenghtLargerThanFile]); EXPECT_EQ(kBufferLength, - ReadInt16FromFileToFloatBuffer(file.get(), - kBufferLenghtLargerThanFile, - buffer.get())); + ReadInt16FromFileToFloatBuffer( + file.get(), kBufferLenghtLargerThanFile, buffer.get())); EXPECT_DOUBLE_EQ(11544, buffer[0]); EXPECT_DOUBLE_EQ(22377, buffer[4]); EXPECT_DOUBLE_EQ(16389, buffer[7]); @@ -255,9 +250,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) { const size_t kBufferLength = 12; std::unique_ptr buffer(new double[kBufferLength]); - EXPECT_EQ(kBufferLength, ReadInt16FromFileToDoubleBuffer(file.get(), - kBufferLength, - buffer.get())); + EXPECT_EQ(kBufferLength, ReadInt16FromFileToDoubleBuffer( + file.get(), kBufferLength, buffer.get())); EXPECT_DOUBLE_EQ(11544, buffer[0]); EXPECT_DOUBLE_EQ(22377, buffer[4]); EXPECT_DOUBLE_EQ(16389, buffer[7]); @@ -271,9 +265,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) { const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; buffer.reset(new double[kBufferLenghtLargerThanFile]); EXPECT_EQ(kBufferLength, - ReadInt16FromFileToDoubleBuffer(file.get(), - kBufferLenghtLargerThanFile, - buffer.get())); + ReadInt16FromFileToDoubleBuffer( + file.get(), kBufferLenghtLargerThanFile, buffer.get())); EXPECT_DOUBLE_EQ(11544, buffer[0]); EXPECT_DOUBLE_EQ(22377, buffer[4]); EXPECT_DOUBLE_EQ(16389, buffer[7]); @@ -297,9 +290,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) { const size_t kBufferLength = 3; std::unique_ptr buffer(new float[kBufferLength]); - EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), - kBufferLength, - buffer.get())); + EXPECT_EQ(kBufferLength, + ReadFloatBufferFromFile(file.get(), kBufferLength, buffer.get())); EXPECT_FLOAT_EQ(kPi, buffer[0]); EXPECT_FLOAT_EQ(kE, buffer[1]); EXPECT_FLOAT_EQ(kAvogadro, buffer[2]); @@ -311,9 +303,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) { // doubles read. const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; buffer.reset(new float[kBufferLenghtLargerThanFile]); - EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), - kBufferLenghtLargerThanFile, - buffer.get())); + EXPECT_EQ(kBufferLength, + ReadFloatBufferFromFile(file.get(), kBufferLenghtLargerThanFile, + buffer.get())); EXPECT_FLOAT_EQ(kPi, buffer[0]); EXPECT_FLOAT_EQ(kE, buffer[1]); EXPECT_FLOAT_EQ(kAvogadro, buffer[2]); @@ -336,9 +328,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) { const size_t kBufferLength = 3; std::unique_ptr buffer(new double[kBufferLength]); - EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), - kBufferLength, - buffer.get())); + EXPECT_EQ(kBufferLength, + ReadDoubleBufferFromFile(file.get(), kBufferLength, buffer.get())); EXPECT_DOUBLE_EQ(kPi, buffer[0]); EXPECT_DOUBLE_EQ(kE, buffer[1]); EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]); @@ -350,9 +341,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) { // doubles read. const size_t kBufferLenghtLargerThanFile = kBufferLength * 2; buffer.reset(new double[kBufferLenghtLargerThanFile]); - EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), - kBufferLenghtLargerThanFile, - buffer.get())); + EXPECT_EQ(kBufferLength, + ReadDoubleBufferFromFile(file.get(), kBufferLenghtLargerThanFile, + buffer.get())); EXPECT_DOUBLE_EQ(kPi, buffer[0]); EXPECT_DOUBLE_EQ(kE, buffer[1]); EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]); @@ -366,8 +357,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) { TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) { std::unique_ptr file(FileWrapper::Create()); - std::string kOutFileName = CreateTempFilename(test::OutputPath(), - "utils_test"); + std::string kOutFileName = + CreateTempFilename(test::OutputPath(), "utils_test"); file->OpenFile(kOutFileName.c_str(), false); // Write mode. ASSERT_TRUE(file->is_open()) << "File could not be opened:\n" @@ -381,8 +372,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) { written_buffer[1] = 2; written_buffer[2] = 3; - EXPECT_EQ(kBufferLength, WriteInt16BufferToFile(file.get(), - kBufferLength, + EXPECT_EQ(kBufferLength, WriteInt16BufferToFile(file.get(), kBufferLength, written_buffer.get())); file->CloseFile(); @@ -391,11 +381,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) { ASSERT_TRUE(file->is_open()) << "File could not be opened:\n" << kOutFileName.c_str(); - EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), - kBufferLength, + EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), kBufferLength, read_buffer.get())); - EXPECT_EQ(0, memcmp(written_buffer.get(), - read_buffer.get(), + EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(), kBufferLength * sizeof(written_buffer[0]))); } @@ -407,8 +395,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) { TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) { std::unique_ptr file(FileWrapper::Create()); - std::string kOutFileName = CreateTempFilename(test::OutputPath(), - "utils_test"); + std::string kOutFileName = + CreateTempFilename(test::OutputPath(), "utils_test"); file->OpenFile(kOutFileName.c_str(), false); // Write mode. ASSERT_TRUE(file->is_open()) << "File could not be opened:\n" @@ -422,8 +410,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) { written_buffer[1] = static_cast(kE); written_buffer[2] = static_cast(kAvogadro); - EXPECT_EQ(kBufferLength, WriteFloatBufferToFile(file.get(), - kBufferLength, + EXPECT_EQ(kBufferLength, WriteFloatBufferToFile(file.get(), kBufferLength, written_buffer.get())); file->CloseFile(); @@ -432,11 +419,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) { ASSERT_TRUE(file->is_open()) << "File could not be opened:\n" << kOutFileName.c_str(); - EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), - kBufferLength, + EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), kBufferLength, read_buffer.get())); - EXPECT_EQ(0, memcmp(written_buffer.get(), - read_buffer.get(), + EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(), kBufferLength * sizeof(written_buffer[0]))); } @@ -448,8 +433,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) { TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) { std::unique_ptr file(FileWrapper::Create()); - std::string kOutFileName = CreateTempFilename(test::OutputPath(), - "utils_test"); + std::string kOutFileName = + CreateTempFilename(test::OutputPath(), "utils_test"); file->OpenFile(kOutFileName.c_str(), false); // Write mode. ASSERT_TRUE(file->is_open()) << "File could not be opened:\n" @@ -463,8 +448,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) { written_buffer[1] = kE; written_buffer[2] = kAvogadro; - EXPECT_EQ(kBufferLength, WriteDoubleBufferToFile(file.get(), - kBufferLength, + EXPECT_EQ(kBufferLength, WriteDoubleBufferToFile(file.get(), kBufferLength, written_buffer.get())); file->CloseFile(); @@ -473,11 +457,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) { ASSERT_TRUE(file->is_open()) << "File could not be opened:\n" << kOutFileName.c_str(); - EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), - kBufferLength, + EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), kBufferLength, read_buffer.get())); - EXPECT_EQ(0, memcmp(written_buffer.get(), - read_buffer.get(), + EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(), kBufferLength * sizeof(written_buffer[0]))); } @@ -501,9 +483,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ExpectedErrorReturnValues) { // Tests with file not opened. EXPECT_EQ(0u, ReadInt16BufferFromFile(file.get(), 1, int16_buffer.get())); - EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(file.get(), - 1, - double_buffer.get())); + EXPECT_EQ( + 0u, ReadInt16FromFileToDoubleBuffer(file.get(), 1, double_buffer.get())); EXPECT_EQ(0u, ReadDoubleBufferFromFile(file.get(), 1, double_buffer.get())); EXPECT_EQ(0u, WriteInt16BufferToFile(file.get(), 1, int16_buffer.get())); EXPECT_EQ(0u, WriteDoubleBufferToFile(file.get(), 1, double_buffer.get())); @@ -518,9 +499,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_ExpectedErrorReturnValues) { EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(NULL, 1, double_buffer.get())); EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(file.get(), 1, NULL)); - EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(file.get(), - 0, - double_buffer.get())); + EXPECT_EQ( + 0u, ReadInt16FromFileToDoubleBuffer(file.get(), 0, double_buffer.get())); EXPECT_EQ(0u, ReadDoubleBufferFromFile(NULL, 1, double_buffer.get())); EXPECT_EQ(0u, ReadDoubleBufferFromFile(file.get(), 1, NULL)); @@ -536,4 +516,3 @@ TEST_F(TransientFileUtilsTest, MAYBE_ExpectedErrorReturnValues) { } } // namespace webrtc - diff --git a/modules/audio_processing/transient/moving_moments.cc b/modules/audio_processing/transient/moving_moments.cc index 46b16b82bc..4be4d6adcd 100644 --- a/modules/audio_processing/transient/moving_moments.cc +++ b/modules/audio_processing/transient/moving_moments.cc @@ -18,10 +18,7 @@ namespace webrtc { MovingMoments::MovingMoments(size_t length) - : length_(length), - queue_(), - sum_(0.0), - sum_of_squares_(0.0) { + : length_(length), queue_(), sum_(0.0), sum_of_squares_(0.0) { RTC_DCHECK_GT(length, 0); for (size_t i = 0; i < length; ++i) { queue_.push(0.0); @@ -30,8 +27,10 @@ MovingMoments::MovingMoments(size_t length) MovingMoments::~MovingMoments() {} -void MovingMoments::CalculateMoments(const float* in, size_t in_length, - float* first, float* second) { +void MovingMoments::CalculateMoments(const float* in, + size_t in_length, + float* first, + float* second) { RTC_DCHECK(in); RTC_DCHECK_GT(in_length, 0); RTC_DCHECK(first); diff --git a/modules/audio_processing/transient/moving_moments.h b/modules/audio_processing/transient/moving_moments.h index f1b3e38cc0..6dc05204da 100644 --- a/modules/audio_processing/transient/moving_moments.h +++ b/modules/audio_processing/transient/moving_moments.h @@ -33,8 +33,10 @@ class MovingMoments { // Calculates the new values using |in|. Results will be in the out buffers. // |first| and |second| must be allocated with at least |in_length|. - void CalculateMoments(const float* in, size_t in_length, - float* first, float* second); + void CalculateMoments(const float* in, + size_t in_length, + float* first, + float* second); private: size_t length_; @@ -48,5 +50,4 @@ class MovingMoments { } // namespace webrtc - #endif // MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_ diff --git a/modules/audio_processing/transient/moving_moments_unittest.cc b/modules/audio_processing/transient/moving_moments_unittest.cc index 057bc454e0..b0e613e7ab 100644 --- a/modules/audio_processing/transient/moving_moments_unittest.cc +++ b/modules/audio_processing/transient/moving_moments_unittest.cc @@ -26,7 +26,8 @@ class MovingMomentsTest : public ::testing::Test { virtual void SetUp(); // Calls CalculateMoments and verifies that it produces the expected // outputs. - void CalculateMomentsAndVerify(const float* input, size_t input_length, + void CalculateMomentsAndVerify(const float* input, + size_t input_length, const float* expected_mean, const float* expected_mean_squares); @@ -42,14 +43,13 @@ void MovingMomentsTest::SetUp() { } void MovingMomentsTest::CalculateMomentsAndVerify( - const float* input, size_t input_length, + const float* input, + size_t input_length, const float* expected_mean, const float* expected_mean_squares) { ASSERT_LE(input_length, kMaxOutputLength); - moving_moments_->CalculateMoments(input, - input_length, - output_mean_, + moving_moments_->CalculateMoments(input, input_length, output_mean_, output_mean_squares_); for (size_t i = 1; i < input_length; ++i) { @@ -73,10 +73,10 @@ TEST_F(MovingMomentsTest, CorrectMomentsOfAConstantBuffer) { const float kInput[] = {5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f}; const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); - const float expected_mean[kInputLength] = - {1.f, 2.f, 3.f, 4.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f}; - const float expected_mean_squares[kInputLength] = - {5.f, 10.f, 15.f, 20.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f}; + const float expected_mean[kInputLength] = {1.f, 2.f, 3.f, 4.f, 5.f, + 5.f, 5.f, 5.f, 5.f, 5.f}; + const float expected_mean_squares[kInputLength] = { + 5.f, 10.f, 15.f, 20.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f}; CalculateMomentsAndVerify(kInput, kInputLength, expected_mean, expected_mean_squares); @@ -86,24 +86,23 @@ TEST_F(MovingMomentsTest, CorrectMomentsOfAnIncreasingBuffer) { const float kInput[] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f}; const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); - const float expected_mean[kInputLength] = - {0.2f, 0.6f, 1.2f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}; - const float expected_mean_squares[kInputLength] = - {0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f}; + const float expected_mean[kInputLength] = {0.2f, 0.6f, 1.2f, 2.f, 3.f, + 4.f, 5.f, 6.f, 7.f}; + const float expected_mean_squares[kInputLength] = { + 0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f}; CalculateMomentsAndVerify(kInput, kInputLength, expected_mean, expected_mean_squares); } TEST_F(MovingMomentsTest, CorrectMomentsOfADecreasingBuffer) { - const float kInput[] = - {-1.f, -2.f, -3.f, -4.f, -5.f, -6.f, -7.f, -8.f, -9.f}; + const float kInput[] = {-1.f, -2.f, -3.f, -4.f, -5.f, -6.f, -7.f, -8.f, -9.f}; const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); - const float expected_mean[kInputLength] = - {-0.2f, -0.6f, -1.2f, -2.f, -3.f, -4.f, -5.f, -6.f, -7.f}; - const float expected_mean_squares[kInputLength] = - {0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f}; + const float expected_mean[kInputLength] = {-0.2f, -0.6f, -1.2f, -2.f, -3.f, + -4.f, -5.f, -6.f, -7.f}; + const float expected_mean_squares[kInputLength] = { + 0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f}; CalculateMomentsAndVerify(kInput, kInputLength, expected_mean, expected_mean_squares); @@ -112,76 +111,78 @@ TEST_F(MovingMomentsTest, CorrectMomentsOfADecreasingBuffer) { TEST_F(MovingMomentsTest, CorrectMomentsOfAZeroMeanSequence) { const size_t kMovingMomentsBufferLength = 4; moving_moments_.reset(new MovingMoments(kMovingMomentsBufferLength)); - const float kInput[] = - {1.f, -1.f, 1.f, -1.f, 1.f, -1.f, 1.f, -1.f, 1.f, -1.f}; + const float kInput[] = {1.f, -1.f, 1.f, -1.f, 1.f, + -1.f, 1.f, -1.f, 1.f, -1.f}; const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); - const float expected_mean[kInputLength] = - {0.25f, 0.f, 0.25f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; - const float expected_mean_squares[kInputLength] = - {0.25f, 0.5f, 0.75f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; + const float expected_mean[kInputLength] = {0.25f, 0.f, 0.25f, 0.f, 0.f, + 0.f, 0.f, 0.f, 0.f, 0.f}; + const float expected_mean_squares[kInputLength] = { + 0.25f, 0.5f, 0.75f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; CalculateMomentsAndVerify(kInput, kInputLength, expected_mean, expected_mean_squares); } TEST_F(MovingMomentsTest, CorrectMomentsOfAnArbitraryBuffer) { - const float kInput[] = - {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, 0.13f, 0.17f, 0.19f, 0.23f}; + const float kInput[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, + 0.13f, 0.17f, 0.19f, 0.23f}; const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); - const float expected_mean[kInputLength] = - {0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f}; - const float expected_mean_squares[kInputLength] = - {0.008f, 0.026f, 0.076f, 0.174f, 0.1764f, 0.1718f, 0.1596f, 0.1168f, - 0.0294f}; + const float expected_mean[kInputLength] = { + 0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f}; + const float expected_mean_squares[kInputLength] = {0.008f, 0.026f, 0.076f, + 0.174f, 0.1764f, 0.1718f, + 0.1596f, 0.1168f, 0.0294f}; CalculateMomentsAndVerify(kInput, kInputLength, expected_mean, expected_mean_squares); } TEST_F(MovingMomentsTest, MutipleCalculateMomentsCalls) { - const float kInputFirstCall[] = - {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, 0.13f, 0.17f, 0.19f, 0.23f}; - const size_t kInputFirstCallLength = sizeof(kInputFirstCall) / - sizeof(kInputFirstCall[0]); + const float kInputFirstCall[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, + 0.13f, 0.17f, 0.19f, 0.23f}; + const size_t kInputFirstCallLength = + sizeof(kInputFirstCall) / sizeof(kInputFirstCall[0]); const float kInputSecondCall[] = {0.29f, 0.31f}; - const size_t kInputSecondCallLength = sizeof(kInputSecondCall) / - sizeof(kInputSecondCall[0]); + const size_t kInputSecondCallLength = + sizeof(kInputSecondCall) / sizeof(kInputSecondCall[0]); const float kInputThirdCall[] = {0.37f, 0.41f, 0.43f, 0.47f}; - const size_t kInputThirdCallLength = sizeof(kInputThirdCall) / - sizeof(kInputThirdCall[0]); + const size_t kInputThirdCallLength = + sizeof(kInputThirdCall) / sizeof(kInputThirdCall[0]); - const float expected_mean_first_call[kInputFirstCallLength] = - {0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f}; - const float expected_mean_squares_first_call[kInputFirstCallLength] = - {0.008f, 0.026f, 0.076f, 0.174f, 0.1764f, 0.1718f, 0.1596f, 0.1168f, - 0.0294f}; + const float expected_mean_first_call[kInputFirstCallLength] = { + 0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f}; + const float expected_mean_squares_first_call[kInputFirstCallLength] = { + 0.008f, 0.026f, 0.076f, 0.174f, 0.1764f, + 0.1718f, 0.1596f, 0.1168f, 0.0294f}; - const float expected_mean_second_call[kInputSecondCallLength] = - {0.202f, 0.238f}; - const float expected_mean_squares_second_call[kInputSecondCallLength] = - {0.0438f, 0.0596f}; + const float expected_mean_second_call[kInputSecondCallLength] = {0.202f, + 0.238f}; + const float expected_mean_squares_second_call[kInputSecondCallLength] = { + 0.0438f, 0.0596f}; - const float expected_mean_third_call[kInputThirdCallLength] = - {0.278f, 0.322f, 0.362f, 0.398f}; - const float expected_mean_squares_third_call[kInputThirdCallLength] = - {0.0812f, 0.1076f, 0.134f, 0.1614f}; + const float expected_mean_third_call[kInputThirdCallLength] = { + 0.278f, 0.322f, 0.362f, 0.398f}; + const float expected_mean_squares_third_call[kInputThirdCallLength] = { + 0.0812f, 0.1076f, 0.134f, 0.1614f}; CalculateMomentsAndVerify(kInputFirstCall, kInputFirstCallLength, - expected_mean_first_call, expected_mean_squares_first_call); + expected_mean_first_call, + expected_mean_squares_first_call); CalculateMomentsAndVerify(kInputSecondCall, kInputSecondCallLength, - expected_mean_second_call, expected_mean_squares_second_call); + expected_mean_second_call, + expected_mean_squares_second_call); CalculateMomentsAndVerify(kInputThirdCall, kInputThirdCallLength, - expected_mean_third_call, expected_mean_squares_third_call); + expected_mean_third_call, + expected_mean_squares_third_call); } -TEST_F(MovingMomentsTest, - VerifySampleBasedVsBlockBasedCalculation) { - const float kInput[] = - {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, 0.13f, 0.17f, 0.19f, 0.23f}; +TEST_F(MovingMomentsTest, VerifySampleBasedVsBlockBasedCalculation) { + const float kInput[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, + 0.13f, 0.17f, 0.19f, 0.23f}; const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]); float output_mean_block_based[kInputLength]; @@ -190,17 +191,16 @@ TEST_F(MovingMomentsTest, float output_mean_sample_based; float output_mean_squares_sample_based; - moving_moments_->CalculateMoments( - kInput, kInputLength, output_mean_block_based, - output_mean_squares_block_based); + moving_moments_->CalculateMoments(kInput, kInputLength, + output_mean_block_based, + output_mean_squares_block_based); moving_moments_.reset(new MovingMoments(kMovingMomentsBufferLength)); for (size_t i = 0; i < kInputLength; ++i) { - moving_moments_->CalculateMoments( - &kInput[i], 1, &output_mean_sample_based, - &output_mean_squares_sample_based); + moving_moments_->CalculateMoments(&kInput[i], 1, &output_mean_sample_based, + &output_mean_squares_sample_based); EXPECT_FLOAT_EQ(output_mean_block_based[i], output_mean_sample_based); EXPECT_FLOAT_EQ(output_mean_squares_block_based[i], - output_mean_squares_sample_based); + output_mean_squares_sample_based); } } diff --git a/modules/audio_processing/transient/transient_detector.cc b/modules/audio_processing/transient/transient_detector.cc index 1bb6f9f10a..c3bf282b0e 100644 --- a/modules/audio_processing/transient/transient_detector.cc +++ b/modules/audio_processing/transient/transient_detector.cc @@ -51,8 +51,7 @@ TransientDetector::TransientDetector(int sample_rate_hz) wpd_tree_.reset(new WPDTree(samples_per_chunk_, kDaubechies8HighPassCoefficients, kDaubechies8LowPassCoefficients, - kDaubechies8CoefficientsLength, - kLevels)); + kDaubechies8CoefficientsLength, kLevels)); for (size_t i = 0; i < kLeaves; ++i) { moving_moments_[i].reset( new MovingMoments(samples_per_transient / kLeaves)); @@ -86,8 +85,7 @@ float TransientDetector::Detect(const float* data, for (size_t i = 0; i < kLeaves; ++i) { WPDNode* leaf = wpd_tree_->NodeAt(kLevels, i); - moving_moments_[i]->CalculateMoments(leaf->data(), - tree_leaves_data_length_, + moving_moments_[i]->CalculateMoments(leaf->data(), tree_leaves_data_length_, first_moments_.get(), second_moments_.get()); @@ -127,8 +125,9 @@ float TransientDetector::Detect(const float* data, const float kVerticalScaling = 0.5f; const float kVerticalShift = 1.f; - result = (cos(result * horizontal_scaling + kHorizontalShift) - + kVerticalShift) * kVerticalScaling; + result = + (cos(result * horizontal_scaling + kHorizontalShift) + kVerticalShift) * + kVerticalScaling; result *= result; } diff --git a/modules/audio_processing/transient/transient_detector_unittest.cc b/modules/audio_processing/transient/transient_detector_unittest.cc index 8f6095415d..69a669ff80 100644 --- a/modules/audio_processing/transient/transient_detector_unittest.cc +++ b/modules/audio_processing/transient/transient_detector_unittest.cc @@ -23,8 +23,7 @@ namespace webrtc { -static const int kSampleRatesHz[] = {ts::kSampleRate8kHz, - ts::kSampleRate16kHz, +static const int kSampleRatesHz[] = {ts::kSampleRate8kHz, ts::kSampleRate16kHz, ts::kSampleRate32kHz, ts::kSampleRate48kHz}; static const size_t kNumberOfSampleRates = @@ -57,7 +56,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) { bool file_opened = detect_file->is_open(); ASSERT_TRUE(file_opened) << "File could not be opened.\n" - << detect_file_name.str().c_str(); + << detect_file_name.str().c_str(); // Prepare audio file. std::stringstream audio_file_name; @@ -80,8 +79,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) { size_t frames_read = 0; - while (ReadInt16FromFileToFloatBuffer(audio_file.get(), - buffer_length, + while (ReadInt16FromFileToFloatBuffer(audio_file.get(), buffer_length, buffer.get()) == buffer_length) { ++frames_read; @@ -92,8 +90,8 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) { << "Detect test file is malformed.\n"; // Compare results with data from the matlab test file. - EXPECT_NEAR(file_value, detector_value, kTolerance) << "Frame: " - << frames_read; + EXPECT_NEAR(file_value, detector_value, kTolerance) + << "Frame: " << frames_read; } detect_file->CloseFile(); diff --git a/modules/audio_processing/transient/transient_suppression_test.cc b/modules/audio_processing/transient/transient_suppression_test.cc index 8512e0128a..00e198916f 100644 --- a/modules/audio_processing/transient/transient_suppression_test.cc +++ b/modules/audio_processing/transient/transient_suppression_test.cc @@ -10,8 +10,8 @@ #include "modules/audio_processing/transient/transient_suppressor.h" -#include #include +#include #include #include @@ -36,9 +36,7 @@ DEFINE_int(chunk_size_ms, 10, "Time between each chunk of samples in milliseconds."); -DEFINE_int(sample_rate_hz, - 16000, - "Sampling frequency of the signal in Hertz."); +DEFINE_int(sample_rate_hz, 16000, "Sampling frequency of the signal in Hertz."); DEFINE_int(detection_rate_hz, 0, "Sampling frequency of the detection signal in Hertz."); @@ -79,9 +77,7 @@ bool ReadBuffers(FILE* in_file, tmpbuf.reset(new int16_t[num_channels * audio_buffer_size]); read_ptr = tmpbuf.get(); } - if (fread(read_ptr, - sizeof(*read_ptr), - num_channels * audio_buffer_size, + if (fread(read_ptr, sizeof(*read_ptr), num_channels * audio_buffer_size, in_file) != num_channels * audio_buffer_size) { return false; } @@ -104,8 +100,8 @@ bool ReadBuffers(FILE* in_file, } if (reference_file) { std::unique_ptr ibuf(new int16_t[audio_buffer_size]); - if (fread(ibuf.get(), sizeof(ibuf[0]), audio_buffer_size, reference_file) - != audio_buffer_size) + if (fread(ibuf.get(), sizeof(ibuf[0]), audio_buffer_size, reference_file) != + audio_buffer_size) return false; S16ToFloat(ibuf.get(), audio_buffer_size, reference_buffer); } @@ -163,8 +159,8 @@ void void_main() { Agc agc; TransientSuppressor suppressor; - suppressor.Initialize( - FLAG_sample_rate_hz, detection_rate_hz, FLAG_num_channels); + suppressor.Initialize(FLAG_sample_rate_hz, detection_rate_hz, + FLAG_num_channels); const size_t audio_buffer_size = FLAG_chunk_size_ms * FLAG_sample_rate_hz / 1000; @@ -184,38 +180,27 @@ void void_main() { if (reference_file) reference_buffer.reset(new float[audio_buffer_size]); - while (ReadBuffers(in_file, - audio_buffer_size, - FLAG_num_channels, - audio_buffer_i.get(), - detection_file, - detection_buffer_size, - detection_buffer.get(), - reference_file, - reference_buffer.get())) { - agc.Process(audio_buffer_i.get(), - static_cast(audio_buffer_size), + while (ReadBuffers(in_file, audio_buffer_size, FLAG_num_channels, + audio_buffer_i.get(), detection_file, + detection_buffer_size, detection_buffer.get(), + reference_file, reference_buffer.get())) { + agc.Process(audio_buffer_i.get(), static_cast(audio_buffer_size), FLAG_sample_rate_hz); for (size_t i = 0; i < FLAG_num_channels * audio_buffer_size; ++i) { audio_buffer_f[i] = audio_buffer_i[i]; } - ASSERT_EQ(0, - suppressor.Suppress(audio_buffer_f.get(), - audio_buffer_size, - FLAG_num_channels, - detection_buffer.get(), - detection_buffer_size, - reference_buffer.get(), - audio_buffer_size, - agc.voice_probability(), - true)) + ASSERT_EQ(0, suppressor.Suppress(audio_buffer_f.get(), audio_buffer_size, + FLAG_num_channels, detection_buffer.get(), + detection_buffer_size, + reference_buffer.get(), audio_buffer_size, + agc.voice_probability(), true)) << "The transient suppressor could not suppress the frame"; // Write result to out file. - WritePCM( - out_file, audio_buffer_size, FLAG_num_channels, audio_buffer_f.get()); + WritePCM(out_file, audio_buffer_size, FLAG_num_channels, + audio_buffer_f.get()); } fclose(in_file); @@ -231,8 +216,8 @@ void void_main() { } // namespace webrtc int main(int argc, char* argv[]) { - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc != 1) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc != 1) { printf("%s", webrtc::kUsage); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); diff --git a/modules/audio_processing/transient/transient_suppressor.cc b/modules/audio_processing/transient/transient_suppressor.cc index 9bbd7d9500..28eb666c47 100644 --- a/modules/audio_processing/transient/transient_suppressor.cc +++ b/modules/audio_processing/transient/transient_suppressor.cc @@ -60,8 +60,7 @@ TransientSuppressor::TransientSuppressor() use_hard_restoration_(false), chunks_since_voice_change_(0), seed_(182), - using_reference_(false) { -} + using_reference_(false) {} TransientSuppressor::~TransientSuppressor() {} @@ -110,17 +109,14 @@ int TransientSuppressor::Initialize(int sample_rate_hz, RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin); num_channels_ = num_channels; in_buffer_.reset(new float[analysis_length_ * num_channels_]); - memset(in_buffer_.get(), - 0, + memset(in_buffer_.get(), 0, analysis_length_ * num_channels_ * sizeof(in_buffer_[0])); detection_length_ = detection_rate_hz * ts::kChunkSizeMs / 1000; detection_buffer_.reset(new float[detection_length_]); - memset(detection_buffer_.get(), - 0, + memset(detection_buffer_.get(), 0, detection_length_ * sizeof(detection_buffer_[0])); out_buffer_.reset(new float[analysis_length_ * num_channels_]); - memset(out_buffer_.get(), - 0, + memset(out_buffer_.get(), 0, analysis_length_ * num_channels_ * sizeof(out_buffer_[0])); // ip[0] must be zero to trigger initialization using rdft(). size_t ip_length = 2 + sqrtf(analysis_length_); @@ -129,14 +125,12 @@ int TransientSuppressor::Initialize(int sample_rate_hz, wfft_.reset(new float[complex_analysis_length_ - 1]); memset(wfft_.get(), 0, (complex_analysis_length_ - 1) * sizeof(wfft_[0])); spectral_mean_.reset(new float[complex_analysis_length_ * num_channels_]); - memset(spectral_mean_.get(), - 0, + memset(spectral_mean_.get(), 0, complex_analysis_length_ * num_channels_ * sizeof(spectral_mean_[0])); fft_buffer_.reset(new float[analysis_length_ + 2]); memset(fft_buffer_.get(), 0, (analysis_length_ + 2) * sizeof(fft_buffer_[0])); magnitudes_.reset(new float[complex_analysis_length_]); - memset(magnitudes_.get(), - 0, + memset(magnitudes_.get(), 0, complex_analysis_length_ * sizeof(magnitudes_[0])); mean_factor_.reset(new float[complex_analysis_length_]); @@ -190,8 +184,8 @@ int TransientSuppressor::Suppress(float* data, detection_data = &in_buffer_[buffer_delay_]; } - float detector_result = detector_->Detect( - detection_data, detection_length, reference_data, reference_length); + float detector_result = detector_->Detect(detection_data, detection_length, + reference_data, reference_length); if (detector_result < 0) { return -1; } @@ -247,8 +241,8 @@ void TransientSuppressor::Suppress(float* in_ptr, fft_buffer_[1] = 0.f; for (size_t i = 0; i < complex_analysis_length_; ++i) { - magnitudes_[i] = ComplexMagnitude(fft_buffer_[i * 2], - fft_buffer_[i * 2 + 1]); + magnitudes_[i] = + ComplexMagnitude(fft_buffer_[i * 2], fft_buffer_[i * 2 + 1]); } // Restore audio if necessary. if (suppression_enabled_) { @@ -269,11 +263,7 @@ void TransientSuppressor::Suppress(float* in_ptr, // Put R[n/2] back in fft_buffer_[1]. fft_buffer_[1] = fft_buffer_[analysis_length_]; - WebRtc_rdft(analysis_length_, - -1, - fft_buffer_.get(), - ip_.get(), - wfft_.get()); + WebRtc_rdft(analysis_length_, -1, fft_buffer_.get(), ip_.get(), wfft_.get()); const float fft_scaling = 2.f / analysis_length_; for (size_t i = 0; i < analysis_length_; ++i) { @@ -301,8 +291,7 @@ void TransientSuppressor::UpdateKeypress(bool key_pressed) { keypress_counter_ = 0; } - if (detection_enabled_ && - ++chunks_since_keypress_ > kChunksUntilNotTyping) { + if (detection_enabled_ && ++chunks_since_keypress_ > kChunksUntilNotTyping) { if (suppression_enabled_) { RTC_LOG(LS_INFO) << "[ts] Transient suppression is now disabled."; } @@ -337,26 +326,22 @@ void TransientSuppressor::UpdateRestoration(float voice_probability) { // |detection_enabled_| is updated by UpdateKeypress(). void TransientSuppressor::UpdateBuffers(float* data) { // TODO(aluebs): Change to ring buffer. - memmove(in_buffer_.get(), - &in_buffer_[data_length_], + memmove(in_buffer_.get(), &in_buffer_[data_length_], (buffer_delay_ + (num_channels_ - 1) * analysis_length_) * sizeof(in_buffer_[0])); // Copy new chunk to buffer. for (int i = 0; i < num_channels_; ++i) { memcpy(&in_buffer_[buffer_delay_ + i * analysis_length_], - &data[i * data_length_], - data_length_ * sizeof(*data)); + &data[i * data_length_], data_length_ * sizeof(*data)); } if (detection_enabled_) { // Shift previous chunk in out buffer. - memmove(out_buffer_.get(), - &out_buffer_[data_length_], + memmove(out_buffer_.get(), &out_buffer_[data_length_], (buffer_delay_ + (num_channels_ - 1) * analysis_length_) * sizeof(out_buffer_[0])); // Initialize new chunk in out buffer. for (int i = 0; i < num_channels_; ++i) { - memset(&out_buffer_[buffer_delay_ + i * analysis_length_], - 0, + memset(&out_buffer_[buffer_delay_ + i * analysis_length_], 0, data_length_ * sizeof(out_buffer_[0])); } } @@ -375,7 +360,7 @@ void TransientSuppressor::HardRestoration(float* spectral_mean) { if (magnitudes_[i] > spectral_mean[i] && magnitudes_[i] > 0) { // RandU() generates values on [0, int16::max()] const float phase = 2 * ts::kPi * WebRtcSpl_RandU(&seed_) / - std::numeric_limits::max(); + std::numeric_limits::max(); const float scaled_mean = detector_result * spectral_mean[i]; fft_buffer_[i * 2] = (1 - detector_result) * fft_buffer_[i * 2] + diff --git a/modules/audio_processing/transient/wpd_node.cc b/modules/audio_processing/transient/wpd_node.cc index 20d6a9013e..2e0ee7e5b7 100644 --- a/modules/audio_processing/transient/wpd_node.cc +++ b/modules/audio_processing/transient/wpd_node.cc @@ -23,13 +23,12 @@ namespace webrtc { WPDNode::WPDNode(size_t length, const float* coefficients, size_t coefficients_length) - : // The data buffer has parent data length to be able to contain and filter - // it. + : // The data buffer has parent data length to be able to contain and + // filter it. data_(new float[2 * length + 1]), length_(length), - filter_(CreateFirFilter(coefficients, - coefficients_length, - 2 * length + 1)) { + filter_( + CreateFirFilter(coefficients, coefficients_length, 2 * length + 1)) { RTC_DCHECK_GT(length, 0); RTC_DCHECK(coefficients); RTC_DCHECK_GT(coefficients_length, 0); @@ -48,8 +47,8 @@ int WPDNode::Update(const float* parent_data, size_t parent_data_length) { // Decimate data. const bool kOddSequence = true; - size_t output_samples = DyadicDecimate( - data_.get(), parent_data_length, kOddSequence, data_.get(), length_); + size_t output_samples = DyadicDecimate(data_.get(), parent_data_length, + kOddSequence, data_.get(), length_); if (output_samples != length_) { return -1; } diff --git a/modules/audio_processing/transient/wpd_node_unittest.cc b/modules/audio_processing/transient/wpd_node_unittest.cc index 1929361055..5f9238255c 100644 --- a/modules/audio_processing/transient/wpd_node_unittest.cc +++ b/modules/audio_processing/transient/wpd_node_unittest.cc @@ -20,18 +20,17 @@ static const size_t kDataLength = 5; static const float kTolerance = 0.0001f; static const size_t kParentDataLength = kDataLength * 2; -static const float kParentData[kParentDataLength] = - {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f}; +static const float kParentData[kParentDataLength] = {1.f, 2.f, 3.f, 4.f, 5.f, + 6.f, 7.f, 8.f, 9.f, 10.f}; static const float kCoefficients[] = {0.2f, -0.3f, 0.5f, -0.7f, 0.11f}; -static const size_t kCoefficientsLength = sizeof(kCoefficients) / - sizeof(kCoefficients[0]); +static const size_t kCoefficientsLength = + sizeof(kCoefficients) / sizeof(kCoefficients[0]); TEST(WPDNodeTest, Accessors) { WPDNode node(kDataLength, kCoefficients, kCoefficientsLength); EXPECT_EQ(0, node.set_data(kParentData, kDataLength)); - EXPECT_EQ(0, memcmp(node.data(), - kParentData, + EXPECT_EQ(0, memcmp(node.data(), kParentData, kDataLength * sizeof(node.data()[0]))); } diff --git a/modules/audio_processing/transient/wpd_tree.cc b/modules/audio_processing/transient/wpd_tree.cc index a01b816daf..72f4d76891 100644 --- a/modules/audio_processing/transient/wpd_tree.cc +++ b/modules/audio_processing/transient/wpd_tree.cc @@ -19,8 +19,10 @@ namespace webrtc { -WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients, - const float* low_pass_coefficients, size_t coefficients_length, +WPDTree::WPDTree(size_t data_length, + const float* high_pass_coefficients, + const float* low_pass_coefficients, + size_t coefficients_length, int levels) : data_length_(data_length), levels_(levels), @@ -98,8 +100,8 @@ int WPDTree::Update(const float* data, size_t data_length) { index_left_child = index * 2; index_right_child = index_left_child + 1; - update_result = nodes_[index_left_child]->Update( - nodes_[index]->data(), nodes_[index]->length()); + update_result = nodes_[index_left_child]->Update(nodes_[index]->data(), + nodes_[index]->length()); if (update_result != 0) { return -1; } diff --git a/modules/audio_processing/transient/wpd_tree.h b/modules/audio_processing/transient/wpd_tree.h index 53fc06b294..707a89d44a 100644 --- a/modules/audio_processing/transient/wpd_tree.h +++ b/modules/audio_processing/transient/wpd_tree.h @@ -47,9 +47,7 @@ class WPDTree { ~WPDTree(); // Returns the number of nodes at any given level. - static int NumberOfNodesAtLevel(int level) { - return 1 << level; - } + static int NumberOfNodesAtLevel(int level) { return 1 << level; } // Returns a pointer to the node at the given level and index(of that level). // Level goes from 0 to levels(). diff --git a/modules/audio_processing/transient/wpd_tree_unittest.cc b/modules/audio_processing/transient/wpd_tree_unittest.cc index 02c7f51db5..88f073963b 100644 --- a/modules/audio_processing/transient/wpd_tree_unittest.cc +++ b/modules/audio_processing/transient/wpd_tree_unittest.cc @@ -30,13 +30,10 @@ TEST(WPDTreeTest, Construction) { float test_buffer[kTestBufferSize]; memset(test_buffer, 0.f, kTestBufferSize * sizeof(*test_buffer)); float test_coefficients[] = {1.f, 2.f, 3.f, 4.f, 5.f}; - const size_t kTestCoefficientsLength = sizeof(test_coefficients) / - sizeof(test_coefficients[0]); - WPDTree tree(kTestBufferSize, - test_coefficients, - test_coefficients, - kTestCoefficientsLength, - kLevels); + const size_t kTestCoefficientsLength = + sizeof(test_coefficients) / sizeof(test_coefficients[0]); + WPDTree tree(kTestBufferSize, test_coefficients, test_coefficients, + kTestCoefficientsLength, kLevels); ASSERT_EQ(kExpectedNumberOfNodes, tree.num_nodes()); // Checks for NodeAt(level, index). int nodes_at_level = 0; @@ -79,10 +76,8 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) { const int kLeaves = 1 << kLevels; const size_t kLeavesSamples = kTestBufferSize >> kLevels; // Create tree with Discrete Meyer Wavelet Coefficients. - WPDTree tree(kTestBufferSize, - kDaubechies8HighPassCoefficients, - kDaubechies8LowPassCoefficients, - kDaubechies8CoefficientsLength, + WPDTree tree(kTestBufferSize, kDaubechies8HighPassCoefficients, + kDaubechies8LowPassCoefficients, kDaubechies8CoefficientsLength, kLevels); // Allocate and open all matlab and out files. std::unique_ptr matlab_files_data[kLeaves]; @@ -134,9 +129,8 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) { size_t frames_read = 0; // Read first buffer from the PCM test file. - size_t file_samples_read = ReadInt16FromFileToFloatBuffer(test_file.get(), - kTestBufferSize, - test_buffer); + size_t file_samples_read = ReadInt16FromFileToFloatBuffer( + test_file.get(), kTestBufferSize, test_buffer); while (file_samples_read > 0 && frames_read < kMaxFramesToTest) { ++frames_read; @@ -152,10 +146,8 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) { // Compare results with data from the matlab test files. for (int i = 0; i < kLeaves; ++i) { // Compare data values - size_t matlab_samples_read = - ReadDoubleBufferFromFile(matlab_files_data[i].get(), - kLeavesSamples, - matlab_buffer); + size_t matlab_samples_read = ReadDoubleBufferFromFile( + matlab_files_data[i].get(), kLeavesSamples, matlab_buffer); ASSERT_EQ(kLeavesSamples, matlab_samples_read) << "Matlab test files are malformed.\n" @@ -170,15 +162,13 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) { } // Write results to out files. - WriteFloatBufferToFile(out_files_data[i].get(), - kLeavesSamples, + WriteFloatBufferToFile(out_files_data[i].get(), kLeavesSamples, node_data); } // Read next buffer from the PCM test file. - file_samples_read = ReadInt16FromFileToFloatBuffer(test_file.get(), - kTestBufferSize, - test_buffer); + file_samples_read = ReadInt16FromFileToFloatBuffer( + test_file.get(), kTestBufferSize, test_buffer); } // Close all matlab and out files. diff --git a/modules/audio_processing/typing_detection.cc b/modules/audio_processing/typing_detection.cc index 6e18124aad..e725b264ee 100644 --- a/modules/audio_processing/typing_detection.cc +++ b/modules/audio_processing/typing_detection.cc @@ -24,8 +24,7 @@ TypingDetection::TypingDetection() reporting_threshold_(300), penalty_decay_(1), type_event_delay_(2), - report_detection_update_period_(1) { -} + report_detection_update_period_(1) {} TypingDetection::~TypingDetection() {} @@ -41,8 +40,7 @@ bool TypingDetection::Process(bool key_pressed, bool vad_activity) { else ++time_since_last_typing_; - if (time_since_last_typing_ < type_event_delay_ && - vad_activity && + if (time_since_last_typing_ < type_event_delay_ && vad_activity && time_active_ < time_window_) { penalty_counter_ += cost_per_typing_; if (penalty_counter_ > reporting_threshold_) @@ -73,15 +71,20 @@ void TypingDetection::SetParameters(int time_window, int penalty_decay, int type_event_delay, int report_detection_update_period) { - if (time_window) time_window_ = time_window; + if (time_window) + time_window_ = time_window; - if (cost_per_typing) cost_per_typing_ = cost_per_typing; + if (cost_per_typing) + cost_per_typing_ = cost_per_typing; - if (reporting_threshold) reporting_threshold_ = reporting_threshold; + if (reporting_threshold) + reporting_threshold_ = reporting_threshold; - if (penalty_decay) penalty_decay_ = penalty_decay; + if (penalty_decay) + penalty_decay_ = penalty_decay; - if (type_event_delay) type_event_delay_ = type_event_delay; + if (type_event_delay) + type_event_delay_ = type_event_delay; if (report_detection_update_period) report_detection_update_period_ = report_detection_update_period; diff --git a/modules/audio_processing/utility/block_mean_calculator.cc b/modules/audio_processing/utility/block_mean_calculator.cc index 3d766929c6..82c1c0face 100644 --- a/modules/audio_processing/utility/block_mean_calculator.cc +++ b/modules/audio_processing/utility/block_mean_calculator.cc @@ -15,10 +15,7 @@ namespace webrtc { BlockMeanCalculator::BlockMeanCalculator(size_t block_length) - : block_length_(block_length), - count_(0), - sum_(0.0), - mean_(0.0) { + : block_length_(block_length), count_(0), sum_(0.0), mean_(0.0) { RTC_DCHECK(block_length_ != 0); } diff --git a/modules/audio_processing/utility/delay_estimator.cc b/modules/audio_processing/utility/delay_estimator.cc index 871b541651..a15b91406c 100644 --- a/modules/audio_processing/utility/delay_estimator.cc +++ b/modules/audio_processing/utility/delay_estimator.cc @@ -21,9 +21,9 @@ static const int kShiftsAtZero = 13; // Right shifts at zero binary spectrum. static const int kShiftsLinearSlope = 3; -static const int32_t kProbabilityOffset = 1024; // 2 in Q9. +static const int32_t kProbabilityOffset = 1024; // 2 in Q9. static const int32_t kProbabilityLowerLimit = 8704; // 17 in Q9. -static const int32_t kProbabilityMinSpread = 2816; // 5.5 in Q9. +static const int32_t kProbabilityMinSpread = 2816; // 5.5 in Q9. // Robust validation settings static const float kHistogramMax = 3000.f; @@ -39,13 +39,13 @@ static const float kMinFractionWhenPossiblyNonCausal = 0.25f; // Counts and returns number of bits of a 32-bit word. static int BitCount(uint32_t u32) { - uint32_t tmp = u32 - ((u32 >> 1) & 033333333333) - - ((u32 >> 2) & 011111111111); + uint32_t tmp = + u32 - ((u32 >> 1) & 033333333333) - ((u32 >> 2) & 011111111111); tmp = ((tmp + (tmp >> 3)) & 030707070707); tmp = (tmp + (tmp >> 6)); tmp = (tmp + (tmp >> 12) + (tmp >> 24)) & 077; - return ((int) tmp); + return ((int)tmp); } // Compares the |binary_vector| with all rows of the |binary_matrix| and counts @@ -69,7 +69,7 @@ static void BitCountComparison(uint32_t binary_vector, // Compare |binary_vector| with all rows of the |binary_matrix| for (; n < matrix_size; n++) { - bit_counts[n] = (int32_t) BitCount(binary_vector ^ binary_matrix[n]); + bit_counts[n] = (int32_t)BitCount(binary_vector ^ binary_matrix[n]); } } @@ -96,8 +96,9 @@ static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self, int32_t valley_level_q14) { const float valley_depth = valley_depth_q14 * kQ14Scaling; float decrease_in_last_set = valley_depth; - const int max_hits_for_slow_change = (candidate_delay < self->last_delay) ? - kMaxHitsWhenPossiblyNonCausal : kMaxHitsWhenPossiblyCausal; + const int max_hits_for_slow_change = (candidate_delay < self->last_delay) + ? kMaxHitsWhenPossiblyNonCausal + : kMaxHitsWhenPossiblyCausal; int i = 0; RTC_DCHECK_EQ(self->history_size, self->farend->history_size); @@ -127,18 +128,20 @@ static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self, // |candidate_delay| is a "potential" candidate and we start decreasing // these histogram bins more rapidly with |valley_depth|. if (self->candidate_hits < max_hits_for_slow_change) { - decrease_in_last_set = (self->mean_bit_counts[self->compare_delay] - - valley_level_q14) * kQ14Scaling; + decrease_in_last_set = + (self->mean_bit_counts[self->compare_delay] - valley_level_q14) * + kQ14Scaling; } // 4. All other bins are decreased with |valley_depth|. // TODO(bjornv): Investigate how to make this loop more efficient. Split up // the loop? Remove parts that doesn't add too much. for (i = 0; i < self->history_size; ++i) { int is_in_last_set = (i >= self->last_delay - 2) && - (i <= self->last_delay + 1) && (i != candidate_delay); - int is_in_candidate_set = (i >= candidate_delay - 2) && - (i <= candidate_delay + 1); - self->histogram[i] -= decrease_in_last_set * is_in_last_set + + (i <= self->last_delay + 1) && (i != candidate_delay); + int is_in_candidate_set = + (i >= candidate_delay - 2) && (i <= candidate_delay + 1); + self->histogram[i] -= + decrease_in_last_set * is_in_last_set + valley_depth * (!is_in_last_set && !is_in_candidate_set); // 5. No histogram bin can go below 0. if (self->histogram[i] < 0) { @@ -196,16 +199,18 @@ static int HistogramBasedValidation(const BinaryDelayEstimator* self, // into tables? if (delay_difference > self->allowed_offset) { fraction = 1.f - kFractionSlope * (delay_difference - self->allowed_offset); - fraction = (fraction > kMinFractionWhenPossiblyCausal ? fraction : - kMinFractionWhenPossiblyCausal); + fraction = (fraction > kMinFractionWhenPossiblyCausal + ? fraction + : kMinFractionWhenPossiblyCausal); } else if (delay_difference < 0) { - fraction = kMinFractionWhenPossiblyNonCausal - - kFractionSlope * delay_difference; + fraction = + kMinFractionWhenPossiblyNonCausal - kFractionSlope * delay_difference; fraction = (fraction > 1.f ? 1.f : fraction); } histogram_threshold *= fraction; - histogram_threshold = (histogram_threshold > kMinHistogramThreshold ? - histogram_threshold : kMinHistogramThreshold); + histogram_threshold = + (histogram_threshold > kMinHistogramThreshold ? histogram_threshold + : kMinHistogramThreshold); is_histogram_valid = (self->histogram[candidate_delay] >= histogram_threshold) && @@ -243,8 +248,8 @@ static int RobustValidation(const BinaryDelayEstimator* self, // i) Before we actually have a valid estimate (|last_delay| == -2), we say // a candidate is valid if either algorithm states so // (|is_instantaneous_valid| OR |is_histogram_valid|). - is_robust = (self->last_delay < 0) && - (is_instantaneous_valid || is_histogram_valid); + is_robust = + (self->last_delay < 0) && (is_instantaneous_valid || is_histogram_valid); // ii) Otherwise, we need both algorithms to be certain // (|is_instantaneous_valid| AND |is_histogram_valid|) is_robust |= is_instantaneous_valid && is_histogram_valid; @@ -252,13 +257,12 @@ static int RobustValidation(const BinaryDelayEstimator* self, // the instantaneous one if |is_histogram_valid| = 1 and the histogram // is significantly strong. is_robust |= is_histogram_valid && - (self->histogram[candidate_delay] > self->last_delay_histogram); + (self->histogram[candidate_delay] > self->last_delay_histogram); return is_robust; } void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) { - if (self == NULL) { return; } @@ -302,20 +306,17 @@ int WebRtc_AllocateFarendBufferMemory(BinaryDelayEstimatorFarend* self, self->binary_far_history = static_cast( realloc(self->binary_far_history, history_size * sizeof(*self->binary_far_history))); - self->far_bit_counts = static_cast( - realloc(self->far_bit_counts, - history_size * sizeof(*self->far_bit_counts))); + self->far_bit_counts = static_cast(realloc( + self->far_bit_counts, history_size * sizeof(*self->far_bit_counts))); if ((self->binary_far_history == NULL) || (self->far_bit_counts == NULL)) { history_size = 0; } // Fill with zeros if we have expanded the buffers. if (history_size > self->history_size) { int size_diff = history_size - self->history_size; - memset(&self->binary_far_history[self->history_size], - 0, + memset(&self->binary_far_history[self->history_size], 0, sizeof(*self->binary_far_history) * size_diff); - memset(&self->far_bit_counts[self->history_size], - 0, + memset(&self->far_bit_counts[self->history_size], 0, sizeof(*self->far_bit_counts) * size_diff); } self->history_size = history_size; @@ -330,7 +331,8 @@ void WebRtc_InitBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) { } void WebRtc_SoftResetBinaryDelayEstimatorFarend( - BinaryDelayEstimatorFarend* self, int delay_shift) { + BinaryDelayEstimatorFarend* self, + int delay_shift) { int abs_shift = abs(delay_shift); int shift_size = 0; int dest_index = 0; @@ -355,8 +357,7 @@ void WebRtc_SoftResetBinaryDelayEstimatorFarend( sizeof(*self->binary_far_history) * shift_size); memset(&self->binary_far_history[padding_index], 0, sizeof(*self->binary_far_history) * abs_shift); - memmove(&self->far_bit_counts[dest_index], - &self->far_bit_counts[src_index], + memmove(&self->far_bit_counts[dest_index], &self->far_bit_counts[src_index], sizeof(*self->far_bit_counts) * shift_size); memset(&self->far_bit_counts[padding_index], 0, sizeof(*self->far_bit_counts) * abs_shift); @@ -378,7 +379,6 @@ void WebRtc_AddBinaryFarSpectrum(BinaryDelayEstimatorFarend* handle, } void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) { - if (self == NULL) { return; } @@ -403,7 +403,8 @@ void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) { } BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator( - BinaryDelayEstimatorFarend* farend, int max_lookahead) { + BinaryDelayEstimatorFarend* farend, + int max_lookahead) { BinaryDelayEstimator* self = NULL; if ((farend != NULL) && (max_lookahead >= 0)) { @@ -457,22 +458,18 @@ int WebRtc_AllocateHistoryBufferMemory(BinaryDelayEstimator* self, self->histogram = static_cast( realloc(self->histogram, (history_size + 1) * sizeof(*self->histogram))); - if ((self->mean_bit_counts == NULL) || - (self->bit_counts == NULL) || + if ((self->mean_bit_counts == NULL) || (self->bit_counts == NULL) || (self->histogram == NULL)) { history_size = 0; } // Fill with zeros if we have expanded the buffers. if (history_size > self->history_size) { int size_diff = history_size - self->history_size; - memset(&self->mean_bit_counts[self->history_size], - 0, + memset(&self->mean_bit_counts[self->history_size], 0, sizeof(*self->mean_bit_counts) * size_diff); - memset(&self->bit_counts[self->history_size], - 0, + memset(&self->bit_counts[self->history_size], 0, sizeof(*self->bit_counts) * size_diff); - memset(&self->histogram[self->history_size], - 0, + memset(&self->histogram[self->history_size], 0, sizeof(*self->histogram) * size_diff); } self->history_size = history_size; @@ -485,15 +482,14 @@ void WebRtc_InitBinaryDelayEstimator(BinaryDelayEstimator* self) { RTC_DCHECK(self); memset(self->bit_counts, 0, sizeof(int32_t) * self->history_size); - memset(self->binary_near_history, - 0, + memset(self->binary_near_history, 0, sizeof(uint32_t) * self->near_history_size); for (i = 0; i <= self->history_size; ++i) { self->mean_bit_counts[i] = (20 << 9); // 20 in Q9. self->histogram[i] = 0.f; } - self->minimum_probability = kMaxBitCountsQ9; // 32 in Q9. - self->last_delay_probability = (int) kMaxBitCountsQ9; // 32 in Q9. + self->minimum_probability = kMaxBitCountsQ9; // 32 in Q9. + self->last_delay_probability = (int)kMaxBitCountsQ9; // 32 in Q9. // Default return value if we're unable to estimate. -1 is used for errors. self->last_delay = -2; @@ -617,8 +613,8 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self, // and deeper than the best estimate so far // (|value_best_candidate| < |last_delay_probability|) valid_candidate = ((valley_depth > kProbabilityOffset) && - ((value_best_candidate < self->minimum_probability) || - (value_best_candidate < self->last_delay_probability))); + ((value_best_candidate < self->minimum_probability) || + (value_best_candidate < self->last_delay_probability))); // Check for nonstationary farend signal. const bool non_stationary_farend = @@ -637,7 +633,6 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self, int is_histogram_valid = HistogramBasedValidation(self, candidate_delay); valid_candidate = RobustValidation(self, candidate_delay, valid_candidate, is_histogram_valid); - } // Only update the delay estimate when the farend is nonstationary and when @@ -645,8 +640,9 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self, if (non_stationary_farend && valid_candidate) { if (candidate_delay != self->last_delay) { self->last_delay_histogram = - (self->histogram[candidate_delay] > kLastHistogramMax ? - kLastHistogramMax : self->histogram[candidate_delay]); + (self->histogram[candidate_delay] > kLastHistogramMax + ? kLastHistogramMax + : self->histogram[candidate_delay]); // Adjust the histogram if we made a change to |last_delay|, though it was // not the most likely one according to the histogram. if (self->histogram[candidate_delay] < @@ -679,8 +675,8 @@ float WebRtc_binary_last_delay_quality(BinaryDelayEstimator* self) { } else { // Note that |last_delay_probability| states how deep the minimum of the // cost function is, so it is rather an error probability. - quality = (float) (kMaxBitCountsQ9 - self->last_delay_probability) / - kMaxBitCountsQ9; + quality = (float)(kMaxBitCountsQ9 - self->last_delay_probability) / + kMaxBitCountsQ9; if (quality < 0) { quality = 0; } diff --git a/modules/audio_processing/utility/delay_estimator.h b/modules/audio_processing/utility/delay_estimator.h index cce6113a53..11483ec6b5 100644 --- a/modules/audio_processing/utility/delay_estimator.h +++ b/modules/audio_processing/utility/delay_estimator.h @@ -117,7 +117,8 @@ void WebRtc_InitBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self); // - delay_shift : The amount of blocks to shift history buffers. // void WebRtc_SoftResetBinaryDelayEstimatorFarend( - BinaryDelayEstimatorFarend* self, int delay_shift); + BinaryDelayEstimatorFarend* self, + int delay_shift); // Adds the binary far-end spectrum to the internal far-end history buffer. This // spectrum is used as reference when calculating the delay using @@ -153,7 +154,8 @@ void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self); // See WebRtc_CreateDelayEstimator(..) in delay_estimator_wrapper.c for detailed // description. BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator( - BinaryDelayEstimatorFarend* farend, int max_lookahead); + BinaryDelayEstimatorFarend* farend, + int max_lookahead); // Re-allocates |history_size| dependent buffers. The far-end buffers will be // updated at the same time if needed. diff --git a/modules/audio_processing/utility/delay_estimator_unittest.cc b/modules/audio_processing/utility/delay_estimator_unittest.cc index 36700e5706..3e4e050504 100644 --- a/modules/audio_processing/utility/delay_estimator_unittest.cc +++ b/modules/audio_processing/utility/delay_estimator_unittest.cc @@ -27,7 +27,7 @@ enum { kSequenceLength = 400 }; const int kDifferentHistorySize = 3; const int kDifferentLookahead = 1; -const int kEnable[] = { 0, 1 }; +const int kEnable[] = {0, 1}; const size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable); class DelayEstimatorTest : public ::testing::Test { @@ -41,9 +41,13 @@ class DelayEstimatorTest : public ::testing::Test { void VerifyDelay(BinaryDelayEstimator* binary_handle, int offset, int delay); void RunBinarySpectra(BinaryDelayEstimator* binary1, BinaryDelayEstimator* binary2, - int near_offset, int lookahead_offset, int far_offset); - void RunBinarySpectraTest(int near_offset, int lookahead_offset, - int ref_robust_validation, int robust_validation); + int near_offset, + int lookahead_offset, + int far_offset); + void RunBinarySpectraTest(int near_offset, + int lookahead_offset, + int ref_robust_validation, + int robust_validation); void* handle_; DelayEstimator* self_; @@ -83,8 +87,8 @@ DelayEstimatorTest::DelayEstimatorTest() } void DelayEstimatorTest::SetUp() { - farend_handle_ = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, - kHistorySize); + farend_handle_ = + WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, kHistorySize); ASSERT_TRUE(farend_handle_ != NULL); farend_self_ = reinterpret_cast(farend_handle_); handle_ = WebRtc_CreateDelayEstimator(farend_handle_, kLookahead); @@ -131,7 +135,8 @@ void DelayEstimatorTest::InitBinary() { } void DelayEstimatorTest::VerifyDelay(BinaryDelayEstimator* binary_handle, - int offset, int delay) { + int offset, + int delay) { // Verify that we WebRtc_binary_last_delay() returns correct delay. EXPECT_EQ(delay, WebRtc_binary_last_delay(binary_handle)); @@ -147,8 +152,8 @@ void DelayEstimatorTest::RunBinarySpectra(BinaryDelayEstimator* binary1, int near_offset, int lookahead_offset, int far_offset) { - int different_validations = binary1->robust_validation_enabled ^ - binary2->robust_validation_enabled; + int different_validations = + binary1->robust_validation_enabled ^ binary2->robust_validation_enabled; WebRtc_InitBinaryDelayEstimatorFarend(binary_farend_); WebRtc_InitBinaryDelayEstimator(binary1); WebRtc_InitBinaryDelayEstimator(binary2); @@ -160,9 +165,8 @@ void DelayEstimatorTest::RunBinarySpectra(BinaryDelayEstimator* binary1, WebRtc_AddBinaryFarSpectrum(binary_farend_, binary_spectrum_[i + far_offset]); int delay_1 = WebRtc_ProcessBinarySpectrum(binary1, binary_spectrum_[i]); - int delay_2 = - WebRtc_ProcessBinarySpectrum(binary2, - binary_spectrum_[i - near_offset]); + int delay_2 = WebRtc_ProcessBinarySpectrum( + binary2, binary_spectrum_[i - near_offset]); VerifyDelay(binary1, far_offset + kLookahead, delay_1); VerifyDelay(binary2, @@ -177,7 +181,7 @@ void DelayEstimatorTest::RunBinarySpectra(BinaryDelayEstimator* binary1, // all the time, unless one of them has robust validation turned on. In // that case the robust validation leaves the initial state faster. if ((near_offset == 0) && (lookahead_offset == 0)) { - if (!different_validations) { + if (!different_validations) { EXPECT_EQ(delay_1, delay_2); } else { if (binary1->robust_validation_enabled) { @@ -199,9 +203,8 @@ void DelayEstimatorTest::RunBinarySpectraTest(int near_offset, int lookahead_offset, int ref_robust_validation, int robust_validation) { - BinaryDelayEstimator* binary2 = - WebRtc_CreateBinaryDelayEstimator(binary_farend_, - kLookahead + lookahead_offset); + BinaryDelayEstimator* binary2 = WebRtc_CreateBinaryDelayEstimator( + binary_farend_, kLookahead + lookahead_offset); // Verify the delay for both causal and non-causal systems. For causal systems // the delay is equivalent with a positive |offset| of the far-end sequence. // For non-causal systems the delay is equivalent with a negative |offset| of @@ -209,8 +212,7 @@ void DelayEstimatorTest::RunBinarySpectraTest(int near_offset, binary_->robust_validation_enabled = ref_robust_validation; binary2->robust_validation_enabled = robust_validation; for (int offset = -kLookahead; - offset < kMaxDelay - lookahead_offset - near_offset; - offset++) { + offset < kMaxDelay - lookahead_offset - near_offset; offset++) { RunBinarySpectra(binary_, binary2, near_offset, lookahead_offset, offset); } WebRtc_FreeBinaryDelayEstimator(binary2); @@ -248,8 +250,8 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 3) Incorrect spectrum size. EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(NULL, far_f_, spectrum_size_)); // Use |farend_handle_| which is properly created at SetUp(). - EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, - spectrum_size_)); + EXPECT_EQ(-1, + WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, spectrum_size_)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, spectrum_size_ + 1)); @@ -259,8 +261,8 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 3) Incorrect spectrum size. // 4) Too high precision in far-end spectrum (Q-domain > 15). EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(NULL, far_u16_, spectrum_size_, 0)); - EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, NULL, spectrum_size_, - 0)); + EXPECT_EQ(-1, + WebRtc_AddFarSpectrumFix(farend_handle_, NULL, spectrum_size_, 0)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, spectrum_size_ + 1, 0)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, @@ -313,16 +315,15 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 3) Incorrect spectrum size. // 4) Non matching history sizes if multiple delay estimators using the same // far-end reference. - EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, - spectrum_size_)); + EXPECT_EQ(-1, + WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, spectrum_size_)); // Use |handle_| which is properly created at SetUp(). - EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, NULL, - spectrum_size_)); + EXPECT_EQ(-1, + WebRtc_DelayEstimatorProcessFloat(handle_, NULL, spectrum_size_)); EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, spectrum_size_ + 1)); // |tmp_handle| is already in a non-matching state. - EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle, - near_f_, + EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle, near_f_, spectrum_size_)); // WebRtc_DelayEstimatorProcessFix() should return -1 if we have: @@ -332,19 +333,17 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 4) Too high precision in near-end spectrum (Q-domain > 15). // 5) Non matching history sizes if multiple delay estimators using the same // far-end reference. - EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(NULL, near_u16_, spectrum_size_, - 0)); - EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, NULL, spectrum_size_, - 0)); + EXPECT_EQ( + -1, WebRtc_DelayEstimatorProcessFix(NULL, near_u16_, spectrum_size_, 0)); + EXPECT_EQ(-1, + WebRtc_DelayEstimatorProcessFix(handle_, NULL, spectrum_size_, 0)); EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, spectrum_size_ + 1, 0)); EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, spectrum_size_, 16)); // |tmp_handle| is already in a non-matching state. - EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle, - near_u16_, - spectrum_size_, - 0)); + EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle, near_u16_, + spectrum_size_, 0)); WebRtc_FreeDelayEstimator(tmp_handle); // WebRtc_last_delay() should return -1 if we have a NULL pointer as |handle|. @@ -382,8 +381,8 @@ TEST_F(DelayEstimatorTest, InitializedSpectrumAfterProcess) { // In this test we verify that the mean spectra are initialized after first // time we call WebRtc_AddFarSpectrum() and Process() respectively. The test // also verifies the state is not left for zero spectra. - const float kZerosFloat[kSpectrumSize] = { 0.0 }; - const uint16_t kZerosU16[kSpectrumSize] = { 0 }; + const float kZerosFloat[kSpectrumSize] = {0.0}; + const uint16_t kZerosU16[kSpectrumSize] = {0}; // For floating point operations, process one frame and verify initialization // flag. @@ -391,14 +390,14 @@ TEST_F(DelayEstimatorTest, InitializedSpectrumAfterProcess) { EXPECT_EQ(0, WebRtc_AddFarSpectrumFloat(farend_handle_, kZerosFloat, spectrum_size_)); EXPECT_EQ(0, farend_self_->far_spectrum_initialized); - EXPECT_EQ(0, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, - spectrum_size_)); + EXPECT_EQ(0, + WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, spectrum_size_)); EXPECT_EQ(1, farend_self_->far_spectrum_initialized); EXPECT_EQ(-2, WebRtc_DelayEstimatorProcessFloat(handle_, kZerosFloat, spectrum_size_)); EXPECT_EQ(0, self_->near_spectrum_initialized); - EXPECT_EQ(-2, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, - spectrum_size_)); + EXPECT_EQ( + -2, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, spectrum_size_)); EXPECT_EQ(1, self_->near_spectrum_initialized); // For fixed point operations, process one frame and verify initialization @@ -407,8 +406,8 @@ TEST_F(DelayEstimatorTest, InitializedSpectrumAfterProcess) { EXPECT_EQ(0, WebRtc_AddFarSpectrumFix(farend_handle_, kZerosU16, spectrum_size_, 0)); EXPECT_EQ(0, farend_self_->far_spectrum_initialized); - EXPECT_EQ(0, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, - spectrum_size_, 0)); + EXPECT_EQ( + 0, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, spectrum_size_, 0)); EXPECT_EQ(1, farend_self_->far_spectrum_initialized); EXPECT_EQ(-2, WebRtc_DelayEstimatorProcessFix(handle_, kZerosU16, spectrum_size_, 0)); @@ -429,10 +428,10 @@ TEST_F(DelayEstimatorTest, CorrectLastDelay) { // Floating point operations. Init(); for (int i = 0; i < 200; i++) { - EXPECT_EQ(0, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, - spectrum_size_)); - last_delay = WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, - spectrum_size_); + EXPECT_EQ( + 0, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, spectrum_size_)); + last_delay = + WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, spectrum_size_); if (last_delay != -2) { EXPECT_EQ(last_delay, WebRtc_last_delay(handle_)); if (!WebRtc_is_robust_validation_enabled(handle_)) { @@ -451,8 +450,8 @@ TEST_F(DelayEstimatorTest, CorrectLastDelay) { for (int i = 0; i < 200; i++) { EXPECT_EQ(0, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, spectrum_size_, 0)); - last_delay = WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, - spectrum_size_, 0); + last_delay = + WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, spectrum_size_, 0); if (last_delay != -2) { EXPECT_EQ(last_delay, WebRtc_last_delay(handle_)); if (!WebRtc_is_robust_validation_enabled(handle_)) { @@ -577,8 +576,8 @@ TEST_F(DelayEstimatorTest, AllowedOffsetNoImpactWhenRobustValidationDisabled) { } TEST_F(DelayEstimatorTest, VerifyLookaheadAtCreate) { - void* farend_handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, - kMaxDelay); + void* farend_handle = + WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, kMaxDelay); ASSERT_TRUE(farend_handle != NULL); void* handle = WebRtc_CreateDelayEstimator(farend_handle, kLookahead); ASSERT_TRUE(handle != NULL); diff --git a/modules/audio_processing/utility/delay_estimator_wrapper.cc b/modules/audio_processing/utility/delay_estimator_wrapper.cc index f907c80a35..27c2a3a1a2 100644 --- a/modules/audio_processing/utility/delay_estimator_wrapper.cc +++ b/modules/audio_processing/utility/delay_estimator_wrapper.cc @@ -72,7 +72,7 @@ static uint32_t BinarySpectrumFix(const uint16_t* spectrum, for (i = kBandFirst; i <= kBandLast; i++) { if (spectrum[i] > 0) { // Convert input spectrum from Q(|q_domain|) to Q15. - int32_t spectrum_q15 = ((int32_t) spectrum[i]) << (15 - q_domain); + int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain); threshold_spectrum[i].int32_ = (spectrum_q15 >> 1); *threshold_initialized = 1; } @@ -80,7 +80,7 @@ static uint32_t BinarySpectrumFix(const uint16_t* spectrum, } for (i = kBandFirst; i <= kBandLast; i++) { // Convert input spectrum from Q(|q_domain|) to Q15. - int32_t spectrum_q15 = ((int32_t) spectrum[i]) << (15 - q_domain); + int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain); // Update the |threshold_spectrum|. WebRtc_MeanEstimatorFix(spectrum_q15, 6, &(threshold_spectrum[i].int32_)); // Convert |spectrum| at current frequency bin to a binary value. @@ -123,7 +123,7 @@ static uint32_t BinarySpectrumFloat(const float* spectrum, } void WebRtc_FreeDelayEstimatorFarend(void* handle) { - DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle; + DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; if (handle == NULL) { return; @@ -158,8 +158,8 @@ void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) { memory_fail |= (self->binary_farend == NULL); // Allocate memory for spectrum buffers. - self->mean_far_spectrum = - static_cast(malloc(spectrum_size * sizeof(SpectrumType))); + self->mean_far_spectrum = static_cast( + malloc(spectrum_size * sizeof(SpectrumType))); memory_fail |= (self->mean_far_spectrum == NULL); self->spectrum_size = spectrum_size; @@ -174,7 +174,7 @@ void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) { } int WebRtc_InitDelayEstimatorFarend(void* handle) { - DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle; + DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; if (self == NULL) { return -1; @@ -193,7 +193,7 @@ int WebRtc_InitDelayEstimatorFarend(void* handle) { } void WebRtc_SoftResetDelayEstimatorFarend(void* handle, int delay_shift) { - DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle; + DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; RTC_DCHECK(self); WebRtc_SoftResetBinaryDelayEstimatorFarend(self->binary_farend, delay_shift); } @@ -202,7 +202,7 @@ int WebRtc_AddFarSpectrumFix(void* handle, const uint16_t* far_spectrum, int spectrum_size, int far_q) { - DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle; + DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; uint32_t binary_spectrum = 0; if (self == NULL) { @@ -232,7 +232,7 @@ int WebRtc_AddFarSpectrumFix(void* handle, int WebRtc_AddFarSpectrumFloat(void* handle, const float* far_spectrum, int spectrum_size) { - DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle; + DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; uint32_t binary_spectrum = 0; if (self == NULL) { @@ -256,7 +256,7 @@ int WebRtc_AddFarSpectrumFloat(void* handle, } void WebRtc_FreeDelayEstimator(void* handle) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; if (handle == NULL) { return; @@ -273,7 +273,7 @@ void WebRtc_FreeDelayEstimator(void* handle) { void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) { DelayEstimator* self = NULL; - DelayEstimatorFarend* farend = (DelayEstimatorFarend*) farend_handle; + DelayEstimatorFarend* farend = (DelayEstimatorFarend*)farend_handle; if (farend_handle != NULL) { self = static_cast(malloc(sizeof(DelayEstimator))); @@ -304,7 +304,7 @@ void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) { } int WebRtc_InitDelayEstimator(void* handle) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; if (self == NULL) { return -1; @@ -323,7 +323,7 @@ int WebRtc_InitDelayEstimator(void* handle) { } int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; RTC_DCHECK(self); return WebRtc_SoftResetBinaryDelayEstimator(self->binary_handle, delay_shift); } @@ -352,7 +352,7 @@ int WebRtc_history_size(const void* handle) { } int WebRtc_set_lookahead(void* handle, int lookahead) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; RTC_DCHECK(self); RTC_DCHECK(self->binary_handle); if ((lookahead > self->binary_handle->near_history_size - 1) || @@ -364,14 +364,14 @@ int WebRtc_set_lookahead(void* handle, int lookahead) { } int WebRtc_lookahead(void* handle) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; RTC_DCHECK(self); RTC_DCHECK(self->binary_handle); return self->binary_handle->lookahead; } int WebRtc_set_allowed_offset(void* handle, int allowed_offset) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; if ((self == NULL) || (allowed_offset < 0)) { return -1; @@ -381,7 +381,7 @@ int WebRtc_set_allowed_offset(void* handle, int allowed_offset) { } int WebRtc_get_allowed_offset(const void* handle) { - const DelayEstimator* self = (const DelayEstimator*) handle; + const DelayEstimator* self = (const DelayEstimator*)handle; if (self == NULL) { return -1; @@ -390,7 +390,7 @@ int WebRtc_get_allowed_offset(const void* handle) { } int WebRtc_enable_robust_validation(void* handle, int enable) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; if (self == NULL) { return -1; @@ -404,7 +404,7 @@ int WebRtc_enable_robust_validation(void* handle, int enable) { } int WebRtc_is_robust_validation_enabled(const void* handle) { - const DelayEstimator* self = (const DelayEstimator*) handle; + const DelayEstimator* self = (const DelayEstimator*)handle; if (self == NULL) { return -1; @@ -416,7 +416,7 @@ int WebRtc_DelayEstimatorProcessFix(void* handle, const uint16_t* near_spectrum, int spectrum_size, int near_q) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; uint32_t binary_spectrum = 0; if (self == NULL) { @@ -436,10 +436,9 @@ int WebRtc_DelayEstimatorProcessFix(void* handle, } // Get binary spectra. - binary_spectrum = BinarySpectrumFix(near_spectrum, - self->mean_near_spectrum, - near_q, - &(self->near_spectrum_initialized)); + binary_spectrum = + BinarySpectrumFix(near_spectrum, self->mean_near_spectrum, near_q, + &(self->near_spectrum_initialized)); return WebRtc_ProcessBinarySpectrum(self->binary_handle, binary_spectrum); } @@ -447,7 +446,7 @@ int WebRtc_DelayEstimatorProcessFix(void* handle, int WebRtc_DelayEstimatorProcessFloat(void* handle, const float* near_spectrum, int spectrum_size) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; uint32_t binary_spectrum = 0; if (self == NULL) { @@ -470,7 +469,7 @@ int WebRtc_DelayEstimatorProcessFloat(void* handle, } int WebRtc_last_delay(void* handle) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; if (self == NULL) { return -1; @@ -480,7 +479,7 @@ int WebRtc_last_delay(void* handle) { } float WebRtc_last_delay_quality(void* handle) { - DelayEstimator* self = (DelayEstimator*) handle; + DelayEstimator* self = (DelayEstimator*)handle; RTC_DCHECK(self); return WebRtc_binary_last_delay_quality(self->binary_handle); } diff --git a/modules/audio_processing/utility/ooura_fft.cc b/modules/audio_processing/utility/ooura_fft.cc index d753a813a6..2add4eb26b 100644 --- a/modules/audio_processing/utility/ooura_fft.cc +++ b/modules/audio_processing/utility/ooura_fft.cc @@ -313,7 +313,6 @@ static void rftbsub_128_C(float* a) { } #endif - } // namespace OouraFft::OouraFft() { diff --git a/modules/audio_processing/utility/ooura_fft_mips.cc b/modules/audio_processing/utility/ooura_fft_mips.cc index 569e1d7e82..c782ee7386 100644 --- a/modules/audio_processing/utility/ooura_fft_mips.cc +++ b/modules/audio_processing/utility/ooura_fft_mips.cc @@ -279,533 +279,600 @@ void cft1st_128_mips(float* a) { const float* first = rdft_wk3ri_first; const float* second = rdft_wk3ri_second; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - // first 8 - "lwc1 %[f0], 0(%[a]) \n\t" - "lwc1 %[f1], 4(%[a]) \n\t" - "lwc1 %[f2], 8(%[a]) \n\t" - "lwc1 %[f3], 12(%[a]) \n\t" - "lwc1 %[f4], 16(%[a]) \n\t" - "lwc1 %[f5], 20(%[a]) \n\t" - "lwc1 %[f6], 24(%[a]) \n\t" - "lwc1 %[f7], 28(%[a]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "add.s %[f7], %[f8], %[f2] \n\t" - "sub.s %[f8], %[f8], %[f2] \n\t" - "sub.s %[f2], %[f1], %[f4] \n\t" - "add.s %[f1], %[f1], %[f4] \n\t" - "add.s %[f4], %[f6], %[f3] \n\t" - "sub.s %[f6], %[f6], %[f3] \n\t" - "sub.s %[f3], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "swc1 %[f7], 0(%[a]) \n\t" - "swc1 %[f8], 16(%[a]) \n\t" - "swc1 %[f2], 28(%[a]) \n\t" - "swc1 %[f1], 12(%[a]) \n\t" - "swc1 %[f4], 4(%[a]) \n\t" - "swc1 %[f6], 20(%[a]) \n\t" - "swc1 %[f3], 8(%[a]) \n\t" - "swc1 %[f0], 24(%[a]) \n\t" - // second 8 - "lwc1 %[f0], 32(%[a]) \n\t" - "lwc1 %[f1], 36(%[a]) \n\t" - "lwc1 %[f2], 40(%[a]) \n\t" - "lwc1 %[f3], 44(%[a]) \n\t" - "lwc1 %[f4], 48(%[a]) \n\t" - "lwc1 %[f5], 52(%[a]) \n\t" - "lwc1 %[f6], 56(%[a]) \n\t" - "lwc1 %[f7], 60(%[a]) \n\t" - "add.s %[f8], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "add.s %[f7], %[f4], %[f1] \n\t" - "sub.s %[f4], %[f4], %[f1] \n\t" - "add.s %[f1], %[f3], %[f8] \n\t" - "sub.s %[f3], %[f3], %[f8] \n\t" - "sub.s %[f8], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "add.s %[f5], %[f6], %[f2] \n\t" - "sub.s %[f6], %[f2], %[f6] \n\t" - "lwc1 %[f9], 8(%[rdft_w]) \n\t" - "sub.s %[f2], %[f8], %[f7] \n\t" - "add.s %[f8], %[f8], %[f7] \n\t" - "sub.s %[f7], %[f4], %[f0] \n\t" - "add.s %[f4], %[f4], %[f0] \n\t" - // prepare for loop - "addiu %[a_ptr], %[a], 64 \n\t" - "addiu %[p1_rdft], %[rdft_w], 8 \n\t" - "addiu %[p2_rdft], %[rdft_w], 16 \n\t" - "addiu %[count], $zero, 7 \n\t" - // finish second 8 - "mul.s %[f2], %[f9], %[f2] \n\t" - "mul.s %[f8], %[f9], %[f8] \n\t" - "mul.s %[f7], %[f9], %[f7] \n\t" - "mul.s %[f4], %[f9], %[f4] \n\t" - "swc1 %[f1], 32(%[a]) \n\t" - "swc1 %[f3], 52(%[a]) \n\t" - "swc1 %[f5], 36(%[a]) \n\t" - "swc1 %[f6], 48(%[a]) \n\t" - "swc1 %[f2], 40(%[a]) \n\t" - "swc1 %[f8], 44(%[a]) \n\t" - "swc1 %[f7], 56(%[a]) \n\t" - "swc1 %[f4], 60(%[a]) \n\t" - // loop - "1: \n\t" - "lwc1 %[f0], 0(%[a_ptr]) \n\t" - "lwc1 %[f1], 4(%[a_ptr]) \n\t" - "lwc1 %[f2], 8(%[a_ptr]) \n\t" - "lwc1 %[f3], 12(%[a_ptr]) \n\t" - "lwc1 %[f4], 16(%[a_ptr]) \n\t" - "lwc1 %[f5], 20(%[a_ptr]) \n\t" - "lwc1 %[f6], 24(%[a_ptr]) \n\t" - "lwc1 %[f7], 28(%[a_ptr]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "lwc1 %[f10], 4(%[p1_rdft]) \n\t" - "lwc1 %[f11], 0(%[p2_rdft]) \n\t" - "lwc1 %[f12], 4(%[p2_rdft]) \n\t" - "lwc1 %[f13], 8(%[first]) \n\t" - "lwc1 %[f14], 12(%[first]) \n\t" - "add.s %[f7], %[f8], %[f2] \n\t" - "sub.s %[f8], %[f8], %[f2] \n\t" - "add.s %[f2], %[f6], %[f3] \n\t" - "sub.s %[f6], %[f6], %[f3] \n\t" - "add.s %[f3], %[f0], %[f5] \n\t" - "sub.s %[f0], %[f0], %[f5] \n\t" - "add.s %[f5], %[f1], %[f4] \n\t" - "sub.s %[f1], %[f1], %[f4] \n\t" - "swc1 %[f7], 0(%[a_ptr]) \n\t" - "swc1 %[f2], 4(%[a_ptr]) \n\t" - "mul.s %[f4], %[f9], %[f8] \n\t" + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + // first 8 + "lwc1 %[f0], 0(%[a]) \n\t" + "lwc1 %[f1], 4(%[a]) \n\t" + "lwc1 %[f2], 8(%[a]) \n\t" + "lwc1 %[f3], 12(%[a]) \n\t" + "lwc1 %[f4], 16(%[a]) \n\t" + "lwc1 %[f5], 20(%[a]) \n\t" + "lwc1 %[f6], 24(%[a]) \n\t" + "lwc1 %[f7], 28(%[a]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "add.s %[f7], %[f8], %[f2] \n\t" + "sub.s %[f8], %[f8], %[f2] \n\t" + "sub.s %[f2], %[f1], %[f4] \n\t" + "add.s %[f1], %[f1], %[f4] \n\t" + "add.s %[f4], %[f6], %[f3] \n\t" + "sub.s %[f6], %[f6], %[f3] \n\t" + "sub.s %[f3], %[f0], %[f5] \n\t" + "add.s %[f0], %[f0], %[f5] \n\t" + "swc1 %[f7], 0(%[a]) \n\t" + "swc1 %[f8], 16(%[a]) \n\t" + "swc1 %[f2], 28(%[a]) \n\t" + "swc1 %[f1], 12(%[a]) \n\t" + "swc1 %[f4], 4(%[a]) \n\t" + "swc1 %[f6], 20(%[a]) \n\t" + "swc1 %[f3], 8(%[a]) \n\t" + "swc1 %[f0], 24(%[a]) \n\t" + // second 8 + "lwc1 %[f0], 32(%[a]) \n\t" + "lwc1 %[f1], 36(%[a]) \n\t" + "lwc1 %[f2], 40(%[a]) \n\t" + "lwc1 %[f3], 44(%[a]) \n\t" + "lwc1 %[f4], 48(%[a]) \n\t" + "lwc1 %[f5], 52(%[a]) \n\t" + "lwc1 %[f6], 56(%[a]) \n\t" + "lwc1 %[f7], 60(%[a]) \n\t" + "add.s %[f8], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "add.s %[f7], %[f4], %[f1] \n\t" + "sub.s %[f4], %[f4], %[f1] \n\t" + "add.s %[f1], %[f3], %[f8] \n\t" + "sub.s %[f3], %[f3], %[f8] \n\t" + "sub.s %[f8], %[f0], %[f5] \n\t" + "add.s %[f0], %[f0], %[f5] \n\t" + "add.s %[f5], %[f6], %[f2] \n\t" + "sub.s %[f6], %[f2], %[f6] \n\t" + "lwc1 %[f9], 8(%[rdft_w]) \n\t" + "sub.s %[f2], %[f8], %[f7] \n\t" + "add.s %[f8], %[f8], %[f7] \n\t" + "sub.s %[f7], %[f4], %[f0] \n\t" + "add.s %[f4], %[f4], %[f0] \n\t" + // prepare for loop + "addiu %[a_ptr], %[a], 64 \n\t" + "addiu %[p1_rdft], %[rdft_w], 8 \n\t" + "addiu %[p2_rdft], %[rdft_w], 16 \n\t" + "addiu %[count], $zero, 7 \n\t" + // finish second 8 + "mul.s %[f2], %[f9], %[f2] \n\t" + "mul.s %[f8], %[f9], %[f8] \n\t" + "mul.s %[f7], %[f9], %[f7] \n\t" + "mul.s %[f4], %[f9], %[f4] \n\t" + "swc1 %[f1], 32(%[a]) \n\t" + "swc1 %[f3], 52(%[a]) \n\t" + "swc1 %[f5], 36(%[a]) \n\t" + "swc1 %[f6], 48(%[a]) \n\t" + "swc1 %[f2], 40(%[a]) \n\t" + "swc1 %[f8], 44(%[a]) \n\t" + "swc1 %[f7], 56(%[a]) \n\t" + "swc1 %[f4], 60(%[a]) \n\t" + // loop + "1: \n\t" + "lwc1 %[f0], 0(%[a_ptr]) \n\t" + "lwc1 %[f1], 4(%[a_ptr]) \n\t" + "lwc1 %[f2], 8(%[a_ptr]) \n\t" + "lwc1 %[f3], 12(%[a_ptr]) \n\t" + "lwc1 %[f4], 16(%[a_ptr]) \n\t" + "lwc1 %[f5], 20(%[a_ptr]) \n\t" + "lwc1 %[f6], 24(%[a_ptr]) \n\t" + "lwc1 %[f7], 28(%[a_ptr]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "lwc1 %[f10], 4(%[p1_rdft]) \n\t" + "lwc1 %[f11], 0(%[p2_rdft]) \n\t" + "lwc1 %[f12], 4(%[p2_rdft]) \n\t" + "lwc1 %[f13], 8(%[first]) \n\t" + "lwc1 %[f14], 12(%[first]) \n\t" + "add.s %[f7], %[f8], %[f2] \n\t" + "sub.s %[f8], %[f8], %[f2] \n\t" + "add.s %[f2], %[f6], %[f3] \n\t" + "sub.s %[f6], %[f6], %[f3] \n\t" + "add.s %[f3], %[f0], %[f5] \n\t" + "sub.s %[f0], %[f0], %[f5] \n\t" + "add.s %[f5], %[f1], %[f4] \n\t" + "sub.s %[f1], %[f1], %[f4] \n\t" + "swc1 %[f7], 0(%[a_ptr]) \n\t" + "swc1 %[f2], 4(%[a_ptr]) \n\t" + "mul.s %[f4], %[f9], %[f8] \n\t" #if defined(MIPS32_R2_LE) - "mul.s %[f8], %[f10], %[f8] \n\t" - "mul.s %[f7], %[f11], %[f0] \n\t" - "mul.s %[f0], %[f12], %[f0] \n\t" - "mul.s %[f2], %[f13], %[f3] \n\t" - "mul.s %[f3], %[f14], %[f3] \n\t" - "nmsub.s %[f4], %[f4], %[f10], %[f6] \n\t" - "madd.s %[f8], %[f8], %[f9], %[f6] \n\t" - "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t" - "madd.s %[f0], %[f0], %[f11], %[f5] \n\t" - "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t" - "madd.s %[f3], %[f3], %[f13], %[f1] \n\t" + "mul.s %[f8], %[f10], %[f8] \n\t" + "mul.s %[f7], %[f11], %[f0] \n\t" + "mul.s %[f0], %[f12], %[f0] \n\t" + "mul.s %[f2], %[f13], %[f3] \n\t" + "mul.s %[f3], %[f14], %[f3] \n\t" + "nmsub.s %[f4], %[f4], %[f10], %[f6] \n\t" + "madd.s %[f8], %[f8], %[f9], %[f6] \n\t" + "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t" + "madd.s %[f0], %[f0], %[f11], %[f5] \n\t" + "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t" + "madd.s %[f3], %[f3], %[f13], %[f1] \n\t" #else - "mul.s %[f7], %[f10], %[f6] \n\t" - "mul.s %[f6], %[f9], %[f6] \n\t" - "mul.s %[f8], %[f10], %[f8] \n\t" - "mul.s %[f2], %[f11], %[f0] \n\t" - "mul.s %[f11], %[f11], %[f5] \n\t" - "mul.s %[f5], %[f12], %[f5] \n\t" - "mul.s %[f0], %[f12], %[f0] \n\t" - "mul.s %[f12], %[f13], %[f3] \n\t" - "mul.s %[f13], %[f13], %[f1] \n\t" - "mul.s %[f1], %[f14], %[f1] \n\t" - "mul.s %[f3], %[f14], %[f3] \n\t" - "sub.s %[f4], %[f4], %[f7] \n\t" - "add.s %[f8], %[f6], %[f8] \n\t" - "sub.s %[f7], %[f2], %[f5] \n\t" - "add.s %[f0], %[f11], %[f0] \n\t" - "sub.s %[f2], %[f12], %[f1] \n\t" - "add.s %[f3], %[f13], %[f3] \n\t" + "mul.s %[f7], %[f10], %[f6] \n\t" + "mul.s %[f6], %[f9], %[f6] \n\t" + "mul.s %[f8], %[f10], %[f8] \n\t" + "mul.s %[f2], %[f11], %[f0] \n\t" + "mul.s %[f11], %[f11], %[f5] \n\t" + "mul.s %[f5], %[f12], %[f5] \n\t" + "mul.s %[f0], %[f12], %[f0] \n\t" + "mul.s %[f12], %[f13], %[f3] \n\t" + "mul.s %[f13], %[f13], %[f1] \n\t" + "mul.s %[f1], %[f14], %[f1] \n\t" + "mul.s %[f3], %[f14], %[f3] \n\t" + "sub.s %[f4], %[f4], %[f7] \n\t" + "add.s %[f8], %[f6], %[f8] \n\t" + "sub.s %[f7], %[f2], %[f5] \n\t" + "add.s %[f0], %[f11], %[f0] \n\t" + "sub.s %[f2], %[f12], %[f1] \n\t" + "add.s %[f3], %[f13], %[f3] \n\t" #endif - "swc1 %[f4], 16(%[a_ptr]) \n\t" - "swc1 %[f8], 20(%[a_ptr]) \n\t" - "swc1 %[f7], 8(%[a_ptr]) \n\t" - "swc1 %[f0], 12(%[a_ptr]) \n\t" - "swc1 %[f2], 24(%[a_ptr]) \n\t" - "swc1 %[f3], 28(%[a_ptr]) \n\t" - "lwc1 %[f0], 32(%[a_ptr]) \n\t" - "lwc1 %[f1], 36(%[a_ptr]) \n\t" - "lwc1 %[f2], 40(%[a_ptr]) \n\t" - "lwc1 %[f3], 44(%[a_ptr]) \n\t" - "lwc1 %[f4], 48(%[a_ptr]) \n\t" - "lwc1 %[f5], 52(%[a_ptr]) \n\t" - "lwc1 %[f6], 56(%[a_ptr]) \n\t" - "lwc1 %[f7], 60(%[a_ptr]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "lwc1 %[f11], 8(%[p2_rdft]) \n\t" - "lwc1 %[f12], 12(%[p2_rdft]) \n\t" - "lwc1 %[f13], 8(%[second]) \n\t" - "lwc1 %[f14], 12(%[second]) \n\t" - "add.s %[f7], %[f8], %[f2] \n\t" - "sub.s %[f8], %[f2], %[f8] \n\t" - "add.s %[f2], %[f6], %[f3] \n\t" - "sub.s %[f6], %[f3], %[f6] \n\t" - "add.s %[f3], %[f0], %[f5] \n\t" - "sub.s %[f0], %[f0], %[f5] \n\t" - "add.s %[f5], %[f1], %[f4] \n\t" - "sub.s %[f1], %[f1], %[f4] \n\t" - "swc1 %[f7], 32(%[a_ptr]) \n\t" - "swc1 %[f2], 36(%[a_ptr]) \n\t" - "mul.s %[f4], %[f10], %[f8] \n\t" + "swc1 %[f4], 16(%[a_ptr]) \n\t" + "swc1 %[f8], 20(%[a_ptr]) \n\t" + "swc1 %[f7], 8(%[a_ptr]) \n\t" + "swc1 %[f0], 12(%[a_ptr]) \n\t" + "swc1 %[f2], 24(%[a_ptr]) \n\t" + "swc1 %[f3], 28(%[a_ptr]) \n\t" + "lwc1 %[f0], 32(%[a_ptr]) \n\t" + "lwc1 %[f1], 36(%[a_ptr]) \n\t" + "lwc1 %[f2], 40(%[a_ptr]) \n\t" + "lwc1 %[f3], 44(%[a_ptr]) \n\t" + "lwc1 %[f4], 48(%[a_ptr]) \n\t" + "lwc1 %[f5], 52(%[a_ptr]) \n\t" + "lwc1 %[f6], 56(%[a_ptr]) \n\t" + "lwc1 %[f7], 60(%[a_ptr]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "lwc1 %[f11], 8(%[p2_rdft]) \n\t" + "lwc1 %[f12], 12(%[p2_rdft]) \n\t" + "lwc1 %[f13], 8(%[second]) \n\t" + "lwc1 %[f14], 12(%[second]) \n\t" + "add.s %[f7], %[f8], %[f2] \n\t" + "sub.s %[f8], %[f2], %[f8] \n\t" + "add.s %[f2], %[f6], %[f3] \n\t" + "sub.s %[f6], %[f3], %[f6] \n\t" + "add.s %[f3], %[f0], %[f5] \n\t" + "sub.s %[f0], %[f0], %[f5] \n\t" + "add.s %[f5], %[f1], %[f4] \n\t" + "sub.s %[f1], %[f1], %[f4] \n\t" + "swc1 %[f7], 32(%[a_ptr]) \n\t" + "swc1 %[f2], 36(%[a_ptr]) \n\t" + "mul.s %[f4], %[f10], %[f8] \n\t" #if defined(MIPS32_R2_LE) - "mul.s %[f10], %[f10], %[f6] \n\t" - "mul.s %[f7], %[f11], %[f0] \n\t" - "mul.s %[f11], %[f11], %[f5] \n\t" - "mul.s %[f2], %[f13], %[f3] \n\t" - "mul.s %[f13], %[f13], %[f1] \n\t" - "madd.s %[f4], %[f4], %[f9], %[f6] \n\t" - "nmsub.s %[f10], %[f10], %[f9], %[f8] \n\t" - "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t" - "madd.s %[f11], %[f11], %[f12], %[f0] \n\t" - "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t" - "madd.s %[f13], %[f13], %[f14], %[f3] \n\t" + "mul.s %[f10], %[f10], %[f6] \n\t" + "mul.s %[f7], %[f11], %[f0] \n\t" + "mul.s %[f11], %[f11], %[f5] \n\t" + "mul.s %[f2], %[f13], %[f3] \n\t" + "mul.s %[f13], %[f13], %[f1] \n\t" + "madd.s %[f4], %[f4], %[f9], %[f6] \n\t" + "nmsub.s %[f10], %[f10], %[f9], %[f8] \n\t" + "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t" + "madd.s %[f11], %[f11], %[f12], %[f0] \n\t" + "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t" + "madd.s %[f13], %[f13], %[f14], %[f3] \n\t" #else - "mul.s %[f2], %[f9], %[f6] \n\t" - "mul.s %[f10], %[f10], %[f6] \n\t" - "mul.s %[f9], %[f9], %[f8] \n\t" - "mul.s %[f7], %[f11], %[f0] \n\t" - "mul.s %[f8], %[f12], %[f5] \n\t" - "mul.s %[f11], %[f11], %[f5] \n\t" - "mul.s %[f12], %[f12], %[f0] \n\t" - "mul.s %[f5], %[f13], %[f3] \n\t" - "mul.s %[f0], %[f14], %[f1] \n\t" - "mul.s %[f13], %[f13], %[f1] \n\t" - "mul.s %[f14], %[f14], %[f3] \n\t" - "add.s %[f4], %[f4], %[f2] \n\t" - "sub.s %[f10], %[f10], %[f9] \n\t" - "sub.s %[f7], %[f7], %[f8] \n\t" - "add.s %[f11], %[f11], %[f12] \n\t" - "sub.s %[f2], %[f5], %[f0] \n\t" - "add.s %[f13], %[f13], %[f14] \n\t" + "mul.s %[f2], %[f9], %[f6] \n\t" + "mul.s %[f10], %[f10], %[f6] \n\t" + "mul.s %[f9], %[f9], %[f8] \n\t" + "mul.s %[f7], %[f11], %[f0] \n\t" + "mul.s %[f8], %[f12], %[f5] \n\t" + "mul.s %[f11], %[f11], %[f5] \n\t" + "mul.s %[f12], %[f12], %[f0] \n\t" + "mul.s %[f5], %[f13], %[f3] \n\t" + "mul.s %[f0], %[f14], %[f1] \n\t" + "mul.s %[f13], %[f13], %[f1] \n\t" + "mul.s %[f14], %[f14], %[f3] \n\t" + "add.s %[f4], %[f4], %[f2] \n\t" + "sub.s %[f10], %[f10], %[f9] \n\t" + "sub.s %[f7], %[f7], %[f8] \n\t" + "add.s %[f11], %[f11], %[f12] \n\t" + "sub.s %[f2], %[f5], %[f0] \n\t" + "add.s %[f13], %[f13], %[f14] \n\t" #endif - "swc1 %[f4], 48(%[a_ptr]) \n\t" - "swc1 %[f10], 52(%[a_ptr]) \n\t" - "swc1 %[f7], 40(%[a_ptr]) \n\t" - "swc1 %[f11], 44(%[a_ptr]) \n\t" - "swc1 %[f2], 56(%[a_ptr]) \n\t" - "swc1 %[f13], 60(%[a_ptr]) \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f9], 8(%[p1_rdft]) \n\t" - "addiu %[a_ptr], %[a_ptr], 64 \n\t" - "addiu %[p1_rdft], %[p1_rdft], 8 \n\t" - "addiu %[p2_rdft], %[p2_rdft], 16 \n\t" - "addiu %[first], %[first], 8 \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[second], %[second], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), - [f12] "=&f" (f12), [f13] "=&f" (f13), [f14] "=&f" (f14), - [a_ptr] "=&r" (a_ptr), [p1_rdft] "=&r" (p1_rdft), [first] "+r" (first), - [p2_rdft] "=&r" (p2_rdft), [count] "=&r" (count), [second] "+r" (second) - : [a] "r" (a), [rdft_w] "r" (rdft_w) - : "memory" - ); + "swc1 %[f4], 48(%[a_ptr]) \n\t" + "swc1 %[f10], 52(%[a_ptr]) \n\t" + "swc1 %[f7], 40(%[a_ptr]) \n\t" + "swc1 %[f11], 44(%[a_ptr]) \n\t" + "swc1 %[f2], 56(%[a_ptr]) \n\t" + "swc1 %[f13], 60(%[a_ptr]) \n\t" + "addiu %[count], %[count], -1 \n\t" + "lwc1 %[f9], 8(%[p1_rdft]) \n\t" + "addiu %[a_ptr], %[a_ptr], 64 \n\t" + "addiu %[p1_rdft], %[p1_rdft], 8 \n\t" + "addiu %[p2_rdft], %[p2_rdft], 16 \n\t" + "addiu %[first], %[first], 8 \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[second], %[second], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), + [f12] "=&f"(f12), [f13] "=&f"(f13), [f14] "=&f"(f14), + [a_ptr] "=&r"(a_ptr), [p1_rdft] "=&r"(p1_rdft), [first] "+r"(first), + [p2_rdft] "=&r"(p2_rdft), [count] "=&r"(count), [second] "+r"(second) + : [a] "r"(a), [rdft_w] "r"(rdft_w) + : "memory"); } void cftmdl_128_mips(float* a) { float f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14; int tmp_a, count; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[tmp_a], %[a], 0 \n\t" - "addiu %[count], $zero, 4 \n\t" - "1: \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f0], 0(%[tmp_a]) \n\t" - "lwc1 %[f2], 32(%[tmp_a]) \n\t" - "lwc1 %[f4], 64(%[tmp_a]) \n\t" - "lwc1 %[f6], 96(%[tmp_a]) \n\t" - "lwc1 %[f1], 4(%[tmp_a]) \n\t" - "lwc1 %[f3], 36(%[tmp_a]) \n\t" - "lwc1 %[f5], 68(%[tmp_a]) \n\t" - "lwc1 %[f7], 100(%[tmp_a]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "add.s %[f7], %[f8], %[f2] \n\t" - "sub.s %[f8], %[f8], %[f2] \n\t" - "add.s %[f2], %[f1], %[f4] \n\t" - "sub.s %[f1], %[f1], %[f4] \n\t" - "add.s %[f4], %[f6], %[f3] \n\t" - "sub.s %[f6], %[f6], %[f3] \n\t" - "sub.s %[f3], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "swc1 %[f7], 0(%[tmp_a]) \n\t" - "swc1 %[f8], 64(%[tmp_a]) \n\t" - "swc1 %[f2], 36(%[tmp_a]) \n\t" - "swc1 %[f1], 100(%[tmp_a]) \n\t" - "swc1 %[f4], 4(%[tmp_a]) \n\t" - "swc1 %[f6], 68(%[tmp_a]) \n\t" - "swc1 %[f3], 32(%[tmp_a]) \n\t" - "swc1 %[f0], 96(%[tmp_a]) \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[tmp_a], %[tmp_a], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count) - : [a] "r" (a) - : "memory" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[tmp_a], %[a], 0 \n\t" + "addiu %[count], $zero, 4 \n\t" + "1: \n\t" + "addiu %[count], %[count], -1 \n\t" + "lwc1 %[f0], 0(%[tmp_a]) \n\t" + "lwc1 %[f2], 32(%[tmp_a]) \n\t" + "lwc1 %[f4], 64(%[tmp_a]) \n\t" + "lwc1 %[f6], 96(%[tmp_a]) \n\t" + "lwc1 %[f1], 4(%[tmp_a]) \n\t" + "lwc1 %[f3], 36(%[tmp_a]) \n\t" + "lwc1 %[f5], 68(%[tmp_a]) \n\t" + "lwc1 %[f7], 100(%[tmp_a]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "add.s %[f7], %[f8], %[f2] \n\t" + "sub.s %[f8], %[f8], %[f2] \n\t" + "add.s %[f2], %[f1], %[f4] \n\t" + "sub.s %[f1], %[f1], %[f4] \n\t" + "add.s %[f4], %[f6], %[f3] \n\t" + "sub.s %[f6], %[f6], %[f3] \n\t" + "sub.s %[f3], %[f0], %[f5] \n\t" + "add.s %[f0], %[f0], %[f5] \n\t" + "swc1 %[f7], 0(%[tmp_a]) \n\t" + "swc1 %[f8], 64(%[tmp_a]) \n\t" + "swc1 %[f2], 36(%[tmp_a]) \n\t" + "swc1 %[f1], 100(%[tmp_a]) \n\t" + "swc1 %[f4], 4(%[tmp_a]) \n\t" + "swc1 %[f6], 68(%[tmp_a]) \n\t" + "swc1 %[f3], 32(%[tmp_a]) \n\t" + "swc1 %[f0], 96(%[tmp_a]) \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[tmp_a], %[tmp_a], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count) + : [a] "r"(a) + : "memory"); f9 = rdft_w[2]; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[tmp_a], %[a], 128 \n\t" - "addiu %[count], $zero, 4 \n\t" - "1: \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f0], 0(%[tmp_a]) \n\t" - "lwc1 %[f2], 32(%[tmp_a]) \n\t" - "lwc1 %[f5], 68(%[tmp_a]) \n\t" - "lwc1 %[f7], 100(%[tmp_a]) \n\t" - "lwc1 %[f1], 4(%[tmp_a]) \n\t" - "lwc1 %[f3], 36(%[tmp_a]) \n\t" - "lwc1 %[f4], 64(%[tmp_a]) \n\t" - "lwc1 %[f6], 96(%[tmp_a]) \n\t" - "sub.s %[f8], %[f0], %[f2] \n\t" - "add.s %[f0], %[f0], %[f2] \n\t" - "sub.s %[f2], %[f5], %[f7] \n\t" - "add.s %[f5], %[f5], %[f7] \n\t" - "sub.s %[f7], %[f1], %[f3] \n\t" - "add.s %[f1], %[f1], %[f3] \n\t" - "sub.s %[f3], %[f4], %[f6] \n\t" - "add.s %[f4], %[f4], %[f6] \n\t" - "sub.s %[f6], %[f8], %[f2] \n\t" - "add.s %[f8], %[f8], %[f2] \n\t" - "add.s %[f2], %[f5], %[f1] \n\t" - "sub.s %[f5], %[f5], %[f1] \n\t" - "add.s %[f1], %[f3], %[f7] \n\t" - "sub.s %[f3], %[f3], %[f7] \n\t" - "add.s %[f7], %[f0], %[f4] \n\t" - "sub.s %[f0], %[f0], %[f4] \n\t" - "sub.s %[f4], %[f6], %[f1] \n\t" - "add.s %[f6], %[f6], %[f1] \n\t" - "sub.s %[f1], %[f3], %[f8] \n\t" - "add.s %[f3], %[f3], %[f8] \n\t" - "mul.s %[f4], %[f4], %[f9] \n\t" - "mul.s %[f6], %[f6], %[f9] \n\t" - "mul.s %[f1], %[f1], %[f9] \n\t" - "mul.s %[f3], %[f3], %[f9] \n\t" - "swc1 %[f7], 0(%[tmp_a]) \n\t" - "swc1 %[f2], 4(%[tmp_a]) \n\t" - "swc1 %[f5], 64(%[tmp_a]) \n\t" - "swc1 %[f0], 68(%[tmp_a]) \n\t" - "swc1 %[f4], 32(%[tmp_a]) \n\t" - "swc1 %[f6], 36(%[tmp_a]) \n\t" - "swc1 %[f1], 96(%[tmp_a]) \n\t" - "swc1 %[f3], 100(%[tmp_a]) \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[tmp_a], %[tmp_a], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count) - : [a] "r" (a), [f9] "f" (f9) - : "memory" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[tmp_a], %[a], 128 \n\t" + "addiu %[count], $zero, 4 \n\t" + "1: \n\t" + "addiu %[count], %[count], -1 \n\t" + "lwc1 %[f0], 0(%[tmp_a]) \n\t" + "lwc1 %[f2], 32(%[tmp_a]) \n\t" + "lwc1 %[f5], 68(%[tmp_a]) \n\t" + "lwc1 %[f7], 100(%[tmp_a]) \n\t" + "lwc1 %[f1], 4(%[tmp_a]) \n\t" + "lwc1 %[f3], 36(%[tmp_a]) \n\t" + "lwc1 %[f4], 64(%[tmp_a]) \n\t" + "lwc1 %[f6], 96(%[tmp_a]) \n\t" + "sub.s %[f8], %[f0], %[f2] \n\t" + "add.s %[f0], %[f0], %[f2] \n\t" + "sub.s %[f2], %[f5], %[f7] \n\t" + "add.s %[f5], %[f5], %[f7] \n\t" + "sub.s %[f7], %[f1], %[f3] \n\t" + "add.s %[f1], %[f1], %[f3] \n\t" + "sub.s %[f3], %[f4], %[f6] \n\t" + "add.s %[f4], %[f4], %[f6] \n\t" + "sub.s %[f6], %[f8], %[f2] \n\t" + "add.s %[f8], %[f8], %[f2] \n\t" + "add.s %[f2], %[f5], %[f1] \n\t" + "sub.s %[f5], %[f5], %[f1] \n\t" + "add.s %[f1], %[f3], %[f7] \n\t" + "sub.s %[f3], %[f3], %[f7] \n\t" + "add.s %[f7], %[f0], %[f4] \n\t" + "sub.s %[f0], %[f0], %[f4] \n\t" + "sub.s %[f4], %[f6], %[f1] \n\t" + "add.s %[f6], %[f6], %[f1] \n\t" + "sub.s %[f1], %[f3], %[f8] \n\t" + "add.s %[f3], %[f3], %[f8] \n\t" + "mul.s %[f4], %[f4], %[f9] \n\t" + "mul.s %[f6], %[f6], %[f9] \n\t" + "mul.s %[f1], %[f1], %[f9] \n\t" + "mul.s %[f3], %[f3], %[f9] \n\t" + "swc1 %[f7], 0(%[tmp_a]) \n\t" + "swc1 %[f2], 4(%[tmp_a]) \n\t" + "swc1 %[f5], 64(%[tmp_a]) \n\t" + "swc1 %[f0], 68(%[tmp_a]) \n\t" + "swc1 %[f4], 32(%[tmp_a]) \n\t" + "swc1 %[f6], 36(%[tmp_a]) \n\t" + "swc1 %[f1], 96(%[tmp_a]) \n\t" + "swc1 %[f3], 100(%[tmp_a]) \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[tmp_a], %[tmp_a], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count) + : [a] "r"(a), [f9] "f"(f9) + : "memory"); f10 = rdft_w[3]; f11 = rdft_w[4]; f12 = rdft_w[5]; f13 = rdft_wk3ri_first[2]; f14 = rdft_wk3ri_first[3]; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[tmp_a], %[a], 256 \n\t" - "addiu %[count], $zero, 4 \n\t" - "1: \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f0], 0(%[tmp_a]) \n\t" - "lwc1 %[f2], 32(%[tmp_a]) \n\t" - "lwc1 %[f4], 64(%[tmp_a]) \n\t" - "lwc1 %[f6], 96(%[tmp_a]) \n\t" - "lwc1 %[f1], 4(%[tmp_a]) \n\t" - "lwc1 %[f3], 36(%[tmp_a]) \n\t" - "lwc1 %[f5], 68(%[tmp_a]) \n\t" - "lwc1 %[f7], 100(%[tmp_a]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "sub.s %[f7], %[f8], %[f2] \n\t" - "add.s %[f8], %[f8], %[f2] \n\t" - "add.s %[f2], %[f1], %[f4] \n\t" - "sub.s %[f1], %[f1], %[f4] \n\t" - "sub.s %[f4], %[f6], %[f3] \n\t" - "add.s %[f6], %[f6], %[f3] \n\t" - "sub.s %[f3], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "swc1 %[f8], 0(%[tmp_a]) \n\t" - "swc1 %[f6], 4(%[tmp_a]) \n\t" - "mul.s %[f5], %[f9], %[f7] \n\t" + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[tmp_a], %[a], 256 \n\t" + "addiu %[count], $zero, 4 \n\t" + "1: \n\t" + "addiu %[count], %[count], -1 \n\t" + "lwc1 %[f0], 0(%[tmp_a]) \n\t" + "lwc1 %[f2], 32(%[tmp_a]) \n\t" + "lwc1 %[f4], 64(%[tmp_a]) \n\t" + "lwc1 %[f6], 96(%[tmp_a]) \n\t" + "lwc1 %[f1], 4(%[tmp_a]) \n\t" + "lwc1 %[f3], 36(%[tmp_a]) \n\t" + "lwc1 %[f5], 68(%[tmp_a]) \n\t" + "lwc1 %[f7], 100(%[tmp_a]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "sub.s %[f7], %[f8], %[f2] \n\t" + "add.s %[f8], %[f8], %[f2] \n\t" + "add.s %[f2], %[f1], %[f4] \n\t" + "sub.s %[f1], %[f1], %[f4] \n\t" + "sub.s %[f4], %[f6], %[f3] \n\t" + "add.s %[f6], %[f6], %[f3] \n\t" + "sub.s %[f3], %[f0], %[f5] \n\t" + "add.s %[f0], %[f0], %[f5] \n\t" + "swc1 %[f8], 0(%[tmp_a]) \n\t" + "swc1 %[f6], 4(%[tmp_a]) \n\t" + "mul.s %[f5], %[f9], %[f7] \n\t" #if defined(MIPS32_R2_LE) - "mul.s %[f7], %[f10], %[f7] \n\t" - "mul.s %[f8], %[f11], %[f3] \n\t" - "mul.s %[f3], %[f12], %[f3] \n\t" - "mul.s %[f6], %[f13], %[f0] \n\t" - "mul.s %[f0], %[f14], %[f0] \n\t" - "nmsub.s %[f5], %[f5], %[f10], %[f4] \n\t" - "madd.s %[f7], %[f7], %[f9], %[f4] \n\t" - "nmsub.s %[f8], %[f8], %[f12], %[f2] \n\t" - "madd.s %[f3], %[f3], %[f11], %[f2] \n\t" - "nmsub.s %[f6], %[f6], %[f14], %[f1] \n\t" - "madd.s %[f0], %[f0], %[f13], %[f1] \n\t" - "swc1 %[f5], 64(%[tmp_a]) \n\t" - "swc1 %[f7], 68(%[tmp_a]) \n\t" + "mul.s %[f7], %[f10], %[f7] \n\t" + "mul.s %[f8], %[f11], %[f3] \n\t" + "mul.s %[f3], %[f12], %[f3] \n\t" + "mul.s %[f6], %[f13], %[f0] \n\t" + "mul.s %[f0], %[f14], %[f0] \n\t" + "nmsub.s %[f5], %[f5], %[f10], %[f4] \n\t" + "madd.s %[f7], %[f7], %[f9], %[f4] \n\t" + "nmsub.s %[f8], %[f8], %[f12], %[f2] \n\t" + "madd.s %[f3], %[f3], %[f11], %[f2] \n\t" + "nmsub.s %[f6], %[f6], %[f14], %[f1] \n\t" + "madd.s %[f0], %[f0], %[f13], %[f1] \n\t" + "swc1 %[f5], 64(%[tmp_a]) \n\t" + "swc1 %[f7], 68(%[tmp_a]) \n\t" #else - "mul.s %[f8], %[f10], %[f4] \n\t" - "mul.s %[f4], %[f9], %[f4] \n\t" - "mul.s %[f7], %[f10], %[f7] \n\t" - "mul.s %[f6], %[f11], %[f3] \n\t" - "mul.s %[f3], %[f12], %[f3] \n\t" - "sub.s %[f5], %[f5], %[f8] \n\t" - "mul.s %[f8], %[f12], %[f2] \n\t" - "mul.s %[f2], %[f11], %[f2] \n\t" - "add.s %[f7], %[f4], %[f7] \n\t" - "mul.s %[f4], %[f13], %[f0] \n\t" - "mul.s %[f0], %[f14], %[f0] \n\t" - "sub.s %[f8], %[f6], %[f8] \n\t" - "mul.s %[f6], %[f14], %[f1] \n\t" - "mul.s %[f1], %[f13], %[f1] \n\t" - "add.s %[f3], %[f2], %[f3] \n\t" - "swc1 %[f5], 64(%[tmp_a]) \n\t" - "swc1 %[f7], 68(%[tmp_a]) \n\t" - "sub.s %[f6], %[f4], %[f6] \n\t" - "add.s %[f0], %[f1], %[f0] \n\t" + "mul.s %[f8], %[f10], %[f4] \n\t" + "mul.s %[f4], %[f9], %[f4] \n\t" + "mul.s %[f7], %[f10], %[f7] \n\t" + "mul.s %[f6], %[f11], %[f3] \n\t" + "mul.s %[f3], %[f12], %[f3] \n\t" + "sub.s %[f5], %[f5], %[f8] \n\t" + "mul.s %[f8], %[f12], %[f2] \n\t" + "mul.s %[f2], %[f11], %[f2] \n\t" + "add.s %[f7], %[f4], %[f7] \n\t" + "mul.s %[f4], %[f13], %[f0] \n\t" + "mul.s %[f0], %[f14], %[f0] \n\t" + "sub.s %[f8], %[f6], %[f8] \n\t" + "mul.s %[f6], %[f14], %[f1] \n\t" + "mul.s %[f1], %[f13], %[f1] \n\t" + "add.s %[f3], %[f2], %[f3] \n\t" + "swc1 %[f5], 64(%[tmp_a]) \n\t" + "swc1 %[f7], 68(%[tmp_a]) \n\t" + "sub.s %[f6], %[f4], %[f6] \n\t" + "add.s %[f0], %[f1], %[f0] \n\t" #endif - "swc1 %[f8], 32(%[tmp_a]) \n\t" - "swc1 %[f3], 36(%[tmp_a]) \n\t" - "swc1 %[f6], 96(%[tmp_a]) \n\t" - "swc1 %[f0], 100(%[tmp_a]) \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[tmp_a], %[tmp_a], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count) - : [a] "r" (a), [f9] "f" (f9), [f10] "f" (f10), [f11] "f" (f11), - [f12] "f" (f12), [f13] "f" (f13), [f14] "f" (f14) - : "memory" - ); + "swc1 %[f8], 32(%[tmp_a]) \n\t" + "swc1 %[f3], 36(%[tmp_a]) \n\t" + "swc1 %[f6], 96(%[tmp_a]) \n\t" + "swc1 %[f0], 100(%[tmp_a]) \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[tmp_a], %[tmp_a], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count) + : [a] "r"(a), [f9] "f"(f9), [f10] "f"(f10), [f11] "f"(f11), + [f12] "f"(f12), [f13] "f"(f13), [f14] "f"(f14) + : "memory"); f11 = rdft_w[6]; f12 = rdft_w[7]; f13 = rdft_wk3ri_second[2]; f14 = rdft_wk3ri_second[3]; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[tmp_a], %[a], 384 \n\t" - "addiu %[count], $zero, 4 \n\t" - "1: \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f0], 0(%[tmp_a]) \n\t" - "lwc1 %[f1], 4(%[tmp_a]) \n\t" - "lwc1 %[f2], 32(%[tmp_a]) \n\t" - "lwc1 %[f3], 36(%[tmp_a]) \n\t" - "lwc1 %[f4], 64(%[tmp_a]) \n\t" - "lwc1 %[f5], 68(%[tmp_a]) \n\t" - "lwc1 %[f6], 96(%[tmp_a]) \n\t" - "lwc1 %[f7], 100(%[tmp_a]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "sub.s %[f7], %[f2], %[f8] \n\t" - "add.s %[f2], %[f2], %[f8] \n\t" - "add.s %[f8], %[f1], %[f4] \n\t" - "sub.s %[f1], %[f1], %[f4] \n\t" - "sub.s %[f4], %[f3], %[f6] \n\t" - "add.s %[f3], %[f3], %[f6] \n\t" - "sub.s %[f6], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "swc1 %[f2], 0(%[tmp_a]) \n\t" - "swc1 %[f3], 4(%[tmp_a]) \n\t" - "mul.s %[f5], %[f10], %[f7] \n\t" + __asm __volatile( + ".set push " + "\n\t" + ".set noreorder " + "\n\t" + "addiu %[tmp_a], %[a], 384 " + "\n\t" + "addiu %[count], $zero, 4 " + "\n\t" + "1: " + "\n\t" + "addiu %[count], %[count], -1 " + "\n\t" + "lwc1 %[f0], 0(%[tmp_a]) " + "\n\t" + "lwc1 %[f1], 4(%[tmp_a]) " + "\n\t" + "lwc1 %[f2], 32(%[tmp_a]) " + "\n\t" + "lwc1 %[f3], 36(%[tmp_a]) " + "\n\t" + "lwc1 %[f4], 64(%[tmp_a]) " + "\n\t" + "lwc1 %[f5], 68(%[tmp_a]) " + "\n\t" + "lwc1 %[f6], 96(%[tmp_a]) " + "\n\t" + "lwc1 %[f7], 100(%[tmp_a]) " + "\n\t" + "add.s %[f8], %[f0], %[f2] " + "\n\t" + "sub.s %[f0], %[f0], %[f2] " + "\n\t" + "add.s %[f2], %[f4], %[f6] " + "\n\t" + "sub.s %[f4], %[f4], %[f6] " + "\n\t" + "add.s %[f6], %[f1], %[f3] " + "\n\t" + "sub.s %[f1], %[f1], %[f3] " + "\n\t" + "add.s %[f3], %[f5], %[f7] " + "\n\t" + "sub.s %[f5], %[f5], %[f7] " + "\n\t" + "sub.s %[f7], %[f2], %[f8] " + "\n\t" + "add.s %[f2], %[f2], %[f8] " + "\n\t" + "add.s %[f8], %[f1], %[f4] " + "\n\t" + "sub.s %[f1], %[f1], %[f4] " + "\n\t" + "sub.s %[f4], %[f3], %[f6] " + "\n\t" + "add.s %[f3], %[f3], %[f6] " + "\n\t" + "sub.s %[f6], %[f0], %[f5] " + "\n\t" + "add.s %[f0], %[f0], %[f5] " + "\n\t" + "swc1 %[f2], 0(%[tmp_a]) " + "\n\t" + "swc1 %[f3], 4(%[tmp_a]) " + "\n\t" + "mul.s %[f5], %[f10], %[f7] " + "\n\t" #if defined(MIPS32_R2_LE) - "mul.s %[f7], %[f9], %[f7] \n\t" - "mul.s %[f2], %[f12], %[f8] \n\t" - "mul.s %[f8], %[f11], %[f8] \n\t" - "mul.s %[f3], %[f14], %[f1] \n\t" - "mul.s %[f1], %[f13], %[f1] \n\t" - "madd.s %[f5], %[f5], %[f9], %[f4] \n\t" - "msub.s %[f7], %[f7], %[f10], %[f4] \n\t" - "msub.s %[f2], %[f2], %[f11], %[f6] \n\t" - "madd.s %[f8], %[f8], %[f12], %[f6] \n\t" - "msub.s %[f3], %[f3], %[f13], %[f0] \n\t" - "madd.s %[f1], %[f1], %[f14], %[f0] \n\t" - "swc1 %[f5], 64(%[tmp_a]) \n\t" - "swc1 %[f7], 68(%[tmp_a]) \n\t" + "mul.s %[f7], %[f9], %[f7] " + "\n\t" + "mul.s %[f2], %[f12], %[f8] " + "\n\t" + "mul.s %[f8], %[f11], %[f8] " + "\n\t" + "mul.s %[f3], %[f14], %[f1] " + "\n\t" + "mul.s %[f1], %[f13], %[f1] " + "\n\t" + "madd.s %[f5], %[f5], %[f9], %[f4] " + "\n\t" + "msub.s %[f7], %[f7], %[f10], %[f4] " + "\n\t" + "msub.s %[f2], %[f2], %[f11], %[f6] " + "\n\t" + "madd.s %[f8], %[f8], %[f12], %[f6] " + "\n\t" + "msub.s %[f3], %[f3], %[f13], %[f0] " + "\n\t" + "madd.s %[f1], %[f1], %[f14], %[f0] " + "\n\t" + "swc1 %[f5], 64(%[tmp_a]) " + "\n\t" + "swc1 %[f7], 68(%[tmp_a]) " + "\n\t" #else - "mul.s %[f2], %[f9], %[f4] \n\t" - "mul.s %[f4], %[f10], %[f4] \n\t" - "mul.s %[f7], %[f9], %[f7] \n\t" - "mul.s %[f3], %[f11], %[f6] \n\t" - "mul.s %[f6], %[f12], %[f6] \n\t" - "add.s %[f5], %[f5], %[f2] \n\t" - "sub.s %[f7], %[f4], %[f7] \n\t" - "mul.s %[f2], %[f12], %[f8] \n\t" - "mul.s %[f8], %[f11], %[f8] \n\t" - "mul.s %[f4], %[f14], %[f1] \n\t" - "mul.s %[f1], %[f13], %[f1] \n\t" - "sub.s %[f2], %[f3], %[f2] \n\t" - "mul.s %[f3], %[f13], %[f0] \n\t" - "mul.s %[f0], %[f14], %[f0] \n\t" - "add.s %[f8], %[f8], %[f6] \n\t" - "swc1 %[f5], 64(%[tmp_a]) \n\t" - "swc1 %[f7], 68(%[tmp_a]) \n\t" - "sub.s %[f3], %[f3], %[f4] \n\t" - "add.s %[f1], %[f1], %[f0] \n\t" + "mul.s %[f2], %[f9], %[f4] " + "\n\t" + "mul.s %[f4], %[f10], %[f4] " + "\n\t" + "mul.s %[f7], %[f9], %[f7] " + "\n\t" + "mul.s %[f3], %[f11], %[f6] " + "\n\t" + "mul.s %[f6], %[f12], %[f6] " + "\n\t" + "add.s %[f5], %[f5], %[f2] " + "\n\t" + "sub.s %[f7], %[f4], %[f7] " + "\n\t" + "mul.s %[f2], %[f12], %[f8] " + "\n\t" + "mul.s %[f8], %[f11], %[f8] " + "\n\t" + "mul.s %[f4], %[f14], %[f1] " + "\n\t" + "mul.s %[f1], %[f13], %[f1] " + "\n\t" + "sub.s %[f2], %[f3], %[f2] " + "\n\t" + "mul.s %[f3], %[f13], %[f0] " + "\n\t" + "mul.s %[f0], %[f14], %[f0] " + "\n\t" + "add.s %[f8], %[f8], %[f6] " + "\n\t" + "swc1 %[f5], 64(%[tmp_a]) " + "\n\t" + "swc1 %[f7], 68(%[tmp_a]) " + "\n\t" + "sub.s %[f3], %[f3], %[f4] " + "\n\t" + "add.s %[f1], %[f1], %[f0] " + "\n\t" #endif - "swc1 %[f2], 32(%[tmp_a]) \n\t" - "swc1 %[f8], 36(%[tmp_a]) \n\t" - "swc1 %[f3], 96(%[tmp_a]) \n\t" - "swc1 %[f1], 100(%[tmp_a]) \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[tmp_a], %[tmp_a], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count) - : [a] "r" (a), [f9] "f" (f9), [f10] "f" (f10), [f11] "f" (f11), - [f12] "f" (f12), [f13] "f" (f13), [f14] "f" (f14) - : "memory" - ); + "swc1 %[f2], 32(%[tmp_a]) " + "\n\t" + "swc1 %[f8], 36(%[tmp_a]) " + "\n\t" + "swc1 %[f3], 96(%[tmp_a]) " + "\n\t" + "swc1 %[f1], 100(%[tmp_a]) " + "\n\t" + "bgtz %[count], 1b " + "\n\t" + " addiu %[tmp_a], %[tmp_a], 8 " + "\n\t" + ".set pop " + "\n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count) + : [a] "r"(a), [f9] "f"(f9), [f10] "f"(f10), [f11] "f"(f11), + [f12] "f"(f12), [f13] "f"(f13), [f14] "f"(f14) + : "memory"); } void cftfsub_128_mips(float* a) { @@ -815,55 +882,53 @@ void cftfsub_128_mips(float* a) { cft1st_128_mips(a); cftmdl_128_mips(a); - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[tmp_a], %[a], 0 \n\t" - "addiu %[count], $zero, 16 \n\t" - "1: \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f0], 0(%[tmp_a]) \n\t" - "lwc1 %[f2], 128(%[tmp_a]) \n\t" - "lwc1 %[f4], 256(%[tmp_a]) \n\t" - "lwc1 %[f6], 384(%[tmp_a]) \n\t" - "lwc1 %[f1], 4(%[tmp_a]) \n\t" - "lwc1 %[f3], 132(%[tmp_a]) \n\t" - "lwc1 %[f5], 260(%[tmp_a]) \n\t" - "lwc1 %[f7], 388(%[tmp_a]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f1], %[f3] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "add.s %[f7], %[f8], %[f2] \n\t" - "sub.s %[f8], %[f8], %[f2] \n\t" - "add.s %[f2], %[f1], %[f4] \n\t" - "sub.s %[f1], %[f1], %[f4] \n\t" - "add.s %[f4], %[f6], %[f3] \n\t" - "sub.s %[f6], %[f6], %[f3] \n\t" - "sub.s %[f3], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "swc1 %[f7], 0(%[tmp_a]) \n\t" - "swc1 %[f8], 256(%[tmp_a]) \n\t" - "swc1 %[f2], 132(%[tmp_a]) \n\t" - "swc1 %[f1], 388(%[tmp_a]) \n\t" - "swc1 %[f4], 4(%[tmp_a]) \n\t" - "swc1 %[f6], 260(%[tmp_a]) \n\t" - "swc1 %[f3], 128(%[tmp_a]) \n\t" - "swc1 %[f0], 384(%[tmp_a]) \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[tmp_a], %[tmp_a], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), - [count] "=&r" (count) - : [a] "r" (a) - : "memory" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[tmp_a], %[a], 0 \n\t" + "addiu %[count], $zero, 16 \n\t" + "1: \n\t" + "addiu %[count], %[count], -1 \n\t" + "lwc1 %[f0], 0(%[tmp_a]) \n\t" + "lwc1 %[f2], 128(%[tmp_a]) \n\t" + "lwc1 %[f4], 256(%[tmp_a]) \n\t" + "lwc1 %[f6], 384(%[tmp_a]) \n\t" + "lwc1 %[f1], 4(%[tmp_a]) \n\t" + "lwc1 %[f3], 132(%[tmp_a]) \n\t" + "lwc1 %[f5], 260(%[tmp_a]) \n\t" + "lwc1 %[f7], 388(%[tmp_a]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f1], %[f3] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "add.s %[f7], %[f8], %[f2] \n\t" + "sub.s %[f8], %[f8], %[f2] \n\t" + "add.s %[f2], %[f1], %[f4] \n\t" + "sub.s %[f1], %[f1], %[f4] \n\t" + "add.s %[f4], %[f6], %[f3] \n\t" + "sub.s %[f6], %[f6], %[f3] \n\t" + "sub.s %[f3], %[f0], %[f5] \n\t" + "add.s %[f0], %[f0], %[f5] \n\t" + "swc1 %[f7], 0(%[tmp_a]) \n\t" + "swc1 %[f8], 256(%[tmp_a]) \n\t" + "swc1 %[f2], 132(%[tmp_a]) \n\t" + "swc1 %[f1], 388(%[tmp_a]) \n\t" + "swc1 %[f4], 4(%[tmp_a]) \n\t" + "swc1 %[f6], 260(%[tmp_a]) \n\t" + "swc1 %[f3], 128(%[tmp_a]) \n\t" + "swc1 %[f0], 384(%[tmp_a]) \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[tmp_a], %[tmp_a], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count) + : [a] "r"(a) + : "memory"); } void cftbsub_128_mips(float* a) { @@ -873,55 +938,54 @@ void cftbsub_128_mips(float* a) { cft1st_128_mips(a); cftmdl_128_mips(a); - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "addiu %[tmp_a], %[a], 0 \n\t" - "addiu %[count], $zero, 16 \n\t" - "1: \n\t" - "addiu %[count], %[count], -1 \n\t" - "lwc1 %[f0], 0(%[tmp_a]) \n\t" - "lwc1 %[f2], 128(%[tmp_a]) \n\t" - "lwc1 %[f4], 256(%[tmp_a]) \n\t" - "lwc1 %[f6], 384(%[tmp_a]) \n\t" - "lwc1 %[f1], 4(%[tmp_a]) \n\t" - "lwc1 %[f3], 132(%[tmp_a]) \n\t" - "lwc1 %[f5], 260(%[tmp_a]) \n\t" - "lwc1 %[f7], 388(%[tmp_a]) \n\t" - "add.s %[f8], %[f0], %[f2] \n\t" - "sub.s %[f0], %[f0], %[f2] \n\t" - "add.s %[f2], %[f4], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "add.s %[f6], %[f1], %[f3] \n\t" - "sub.s %[f1], %[f3], %[f1] \n\t" - "add.s %[f3], %[f5], %[f7] \n\t" - "sub.s %[f5], %[f5], %[f7] \n\t" - "add.s %[f7], %[f8], %[f2] \n\t" - "sub.s %[f8], %[f8], %[f2] \n\t" - "sub.s %[f2], %[f1], %[f4] \n\t" - "add.s %[f1], %[f1], %[f4] \n\t" - "add.s %[f4], %[f3], %[f6] \n\t" - "sub.s %[f6], %[f3], %[f6] \n\t" - "sub.s %[f3], %[f0], %[f5] \n\t" - "add.s %[f0], %[f0], %[f5] \n\t" - "neg.s %[f4], %[f4] \n\t" - "swc1 %[f7], 0(%[tmp_a]) \n\t" - "swc1 %[f8], 256(%[tmp_a]) \n\t" - "swc1 %[f2], 132(%[tmp_a]) \n\t" - "swc1 %[f1], 388(%[tmp_a]) \n\t" - "swc1 %[f6], 260(%[tmp_a]) \n\t" - "swc1 %[f3], 128(%[tmp_a]) \n\t" - "swc1 %[f0], 384(%[tmp_a]) \n\t" - "swc1 %[f4], 4(%[tmp_a]) \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[tmp_a], %[tmp_a], 8 \n\t" - ".set pop \n\t" - : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), - [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), - [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count) - : [a] "r" (a) - : "memory" - ); + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[tmp_a], %[a], 0 \n\t" + "addiu %[count], $zero, 16 \n\t" + "1: \n\t" + "addiu %[count], %[count], -1 \n\t" + "lwc1 %[f0], 0(%[tmp_a]) \n\t" + "lwc1 %[f2], 128(%[tmp_a]) \n\t" + "lwc1 %[f4], 256(%[tmp_a]) \n\t" + "lwc1 %[f6], 384(%[tmp_a]) \n\t" + "lwc1 %[f1], 4(%[tmp_a]) \n\t" + "lwc1 %[f3], 132(%[tmp_a]) \n\t" + "lwc1 %[f5], 260(%[tmp_a]) \n\t" + "lwc1 %[f7], 388(%[tmp_a]) \n\t" + "add.s %[f8], %[f0], %[f2] \n\t" + "sub.s %[f0], %[f0], %[f2] \n\t" + "add.s %[f2], %[f4], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "add.s %[f6], %[f1], %[f3] \n\t" + "sub.s %[f1], %[f3], %[f1] \n\t" + "add.s %[f3], %[f5], %[f7] \n\t" + "sub.s %[f5], %[f5], %[f7] \n\t" + "add.s %[f7], %[f8], %[f2] \n\t" + "sub.s %[f8], %[f8], %[f2] \n\t" + "sub.s %[f2], %[f1], %[f4] \n\t" + "add.s %[f1], %[f1], %[f4] \n\t" + "add.s %[f4], %[f3], %[f6] \n\t" + "sub.s %[f6], %[f3], %[f6] \n\t" + "sub.s %[f3], %[f0], %[f5] \n\t" + "add.s %[f0], %[f0], %[f5] \n\t" + "neg.s %[f4], %[f4] \n\t" + "swc1 %[f7], 0(%[tmp_a]) \n\t" + "swc1 %[f8], 256(%[tmp_a]) \n\t" + "swc1 %[f2], 132(%[tmp_a]) \n\t" + "swc1 %[f1], 388(%[tmp_a]) \n\t" + "swc1 %[f6], 260(%[tmp_a]) \n\t" + "swc1 %[f3], 128(%[tmp_a]) \n\t" + "swc1 %[f0], 384(%[tmp_a]) \n\t" + "swc1 %[f4], 4(%[tmp_a]) \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[tmp_a], %[tmp_a], 8 \n\t" + ".set pop \n\t" + : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), + [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), + [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count) + : [a] "r"(a) + : "memory"); } void rftfsub_128_mips(float* a) { @@ -931,254 +995,252 @@ void rftfsub_128_mips(float* a) { float* a2 = &a[126]; const float* c1 = &c[1]; const float* c2 = &c[31]; - float f1, f2, f3 ,f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; + float f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; int count; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "lwc1 %[f6], 0(%[c2]) \n\t" - "lwc1 %[f1], 0(%[a1]) \n\t" - "lwc1 %[f2], 0(%[a2]) \n\t" - "lwc1 %[f3], 4(%[a1]) \n\t" - "lwc1 %[f4], 4(%[a2]) \n\t" - "lwc1 %[f5], 0(%[c1]) \n\t" - "sub.s %[f6], %[f0], %[f6] \n\t" - "sub.s %[f7], %[f1], %[f2] \n\t" - "add.s %[f8], %[f3], %[f4] \n\t" - "addiu %[count], $zero, 15 \n\t" - "mul.s %[f9], %[f6], %[f7] \n\t" - "mul.s %[f6], %[f6], %[f8] \n\t" + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "lwc1 %[f6], 0(%[c2]) \n\t" + "lwc1 %[f1], 0(%[a1]) \n\t" + "lwc1 %[f2], 0(%[a2]) \n\t" + "lwc1 %[f3], 4(%[a1]) \n\t" + "lwc1 %[f4], 4(%[a2]) \n\t" + "lwc1 %[f5], 0(%[c1]) \n\t" + "sub.s %[f6], %[f0], %[f6] \n\t" + "sub.s %[f7], %[f1], %[f2] \n\t" + "add.s %[f8], %[f3], %[f4] \n\t" + "addiu %[count], $zero, 15 \n\t" + "mul.s %[f9], %[f6], %[f7] \n\t" + "mul.s %[f6], %[f6], %[f8] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f8], %[f5], %[f8] \n\t" - "mul.s %[f5], %[f5], %[f7] \n\t" - "sub.s %[f9], %[f9], %[f8] \n\t" - "add.s %[f6], %[f6], %[f5] \n\t" + "mul.s %[f8], %[f5], %[f8] \n\t" + "mul.s %[f5], %[f5], %[f7] \n\t" + "sub.s %[f9], %[f9], %[f8] \n\t" + "add.s %[f6], %[f6], %[f5] \n\t" #else - "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t" - "madd.s %[f6], %[f6], %[f5], %[f7] \n\t" + "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t" + "madd.s %[f6], %[f6], %[f5], %[f7] \n\t" #endif - "sub.s %[f1], %[f1], %[f9] \n\t" - "add.s %[f2], %[f2], %[f9] \n\t" - "sub.s %[f3], %[f3], %[f6] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "swc1 %[f1], 0(%[a1]) \n\t" - "swc1 %[f2], 0(%[a2]) \n\t" - "swc1 %[f3], 4(%[a1]) \n\t" - "swc1 %[f4], 4(%[a2]) \n\t" - "addiu %[a1], %[a1], 8 \n\t" - "addiu %[a2], %[a2], -8 \n\t" - "addiu %[c1], %[c1], 4 \n\t" - "addiu %[c2], %[c2], -4 \n\t" - "1: \n\t" - "lwc1 %[f6], 0(%[c2]) \n\t" - "lwc1 %[f1], 0(%[a1]) \n\t" - "lwc1 %[f2], 0(%[a2]) \n\t" - "lwc1 %[f3], 4(%[a1]) \n\t" - "lwc1 %[f4], 4(%[a2]) \n\t" - "lwc1 %[f5], 0(%[c1]) \n\t" - "sub.s %[f6], %[f0], %[f6] \n\t" - "sub.s %[f7], %[f1], %[f2] \n\t" - "add.s %[f8], %[f3], %[f4] \n\t" - "lwc1 %[f10], -4(%[c2]) \n\t" - "lwc1 %[f11], 8(%[a1]) \n\t" - "lwc1 %[f12], -8(%[a2]) \n\t" - "mul.s %[f9], %[f6], %[f7] \n\t" - "mul.s %[f6], %[f6], %[f8] \n\t" + "sub.s %[f1], %[f1], %[f9] \n\t" + "add.s %[f2], %[f2], %[f9] \n\t" + "sub.s %[f3], %[f3], %[f6] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "swc1 %[f1], 0(%[a1]) \n\t" + "swc1 %[f2], 0(%[a2]) \n\t" + "swc1 %[f3], 4(%[a1]) \n\t" + "swc1 %[f4], 4(%[a2]) \n\t" + "addiu %[a1], %[a1], 8 \n\t" + "addiu %[a2], %[a2], -8 \n\t" + "addiu %[c1], %[c1], 4 \n\t" + "addiu %[c2], %[c2], -4 \n\t" + "1: \n\t" + "lwc1 %[f6], 0(%[c2]) \n\t" + "lwc1 %[f1], 0(%[a1]) \n\t" + "lwc1 %[f2], 0(%[a2]) \n\t" + "lwc1 %[f3], 4(%[a1]) \n\t" + "lwc1 %[f4], 4(%[a2]) \n\t" + "lwc1 %[f5], 0(%[c1]) \n\t" + "sub.s %[f6], %[f0], %[f6] \n\t" + "sub.s %[f7], %[f1], %[f2] \n\t" + "add.s %[f8], %[f3], %[f4] \n\t" + "lwc1 %[f10], -4(%[c2]) \n\t" + "lwc1 %[f11], 8(%[a1]) \n\t" + "lwc1 %[f12], -8(%[a2]) \n\t" + "mul.s %[f9], %[f6], %[f7] \n\t" + "mul.s %[f6], %[f6], %[f8] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f8], %[f5], %[f8] \n\t" - "mul.s %[f5], %[f5], %[f7] \n\t" - "lwc1 %[f13], 12(%[a1]) \n\t" - "lwc1 %[f14], -4(%[a2]) \n\t" - "lwc1 %[f15], 4(%[c1]) \n\t" - "sub.s %[f9], %[f9], %[f8] \n\t" - "add.s %[f6], %[f6], %[f5] \n\t" + "mul.s %[f8], %[f5], %[f8] \n\t" + "mul.s %[f5], %[f5], %[f7] \n\t" + "lwc1 %[f13], 12(%[a1]) \n\t" + "lwc1 %[f14], -4(%[a2]) \n\t" + "lwc1 %[f15], 4(%[c1]) \n\t" + "sub.s %[f9], %[f9], %[f8] \n\t" + "add.s %[f6], %[f6], %[f5] \n\t" #else - "lwc1 %[f13], 12(%[a1]) \n\t" - "lwc1 %[f14], -4(%[a2]) \n\t" - "lwc1 %[f15], 4(%[c1]) \n\t" - "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t" - "madd.s %[f6], %[f6], %[f5], %[f7] \n\t" + "lwc1 %[f13], 12(%[a1]) \n\t" + "lwc1 %[f14], -4(%[a2]) \n\t" + "lwc1 %[f15], 4(%[c1]) \n\t" + "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t" + "madd.s %[f6], %[f6], %[f5], %[f7] \n\t" #endif - "sub.s %[f10], %[f0], %[f10] \n\t" - "sub.s %[f5], %[f11], %[f12] \n\t" - "add.s %[f7], %[f13], %[f14] \n\t" - "sub.s %[f1], %[f1], %[f9] \n\t" - "add.s %[f2], %[f2], %[f9] \n\t" - "sub.s %[f3], %[f3], %[f6] \n\t" - "mul.s %[f8], %[f10], %[f5] \n\t" - "mul.s %[f10], %[f10], %[f7] \n\t" + "sub.s %[f10], %[f0], %[f10] \n\t" + "sub.s %[f5], %[f11], %[f12] \n\t" + "add.s %[f7], %[f13], %[f14] \n\t" + "sub.s %[f1], %[f1], %[f9] \n\t" + "add.s %[f2], %[f2], %[f9] \n\t" + "sub.s %[f3], %[f3], %[f6] \n\t" + "mul.s %[f8], %[f10], %[f5] \n\t" + "mul.s %[f10], %[f10], %[f7] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f9], %[f15], %[f7] \n\t" - "mul.s %[f15], %[f15], %[f5] \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "swc1 %[f1], 0(%[a1]) \n\t" - "swc1 %[f2], 0(%[a2]) \n\t" - "sub.s %[f8], %[f8], %[f9] \n\t" - "add.s %[f10], %[f10], %[f15] \n\t" + "mul.s %[f9], %[f15], %[f7] \n\t" + "mul.s %[f15], %[f15], %[f5] \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "swc1 %[f1], 0(%[a1]) \n\t" + "swc1 %[f2], 0(%[a2]) \n\t" + "sub.s %[f8], %[f8], %[f9] \n\t" + "add.s %[f10], %[f10], %[f15] \n\t" #else - "swc1 %[f1], 0(%[a1]) \n\t" - "swc1 %[f2], 0(%[a2]) \n\t" - "sub.s %[f4], %[f4], %[f6] \n\t" - "nmsub.s %[f8], %[f8], %[f15], %[f7] \n\t" - "madd.s %[f10], %[f10], %[f15], %[f5] \n\t" + "swc1 %[f1], 0(%[a1]) \n\t" + "swc1 %[f2], 0(%[a2]) \n\t" + "sub.s %[f4], %[f4], %[f6] \n\t" + "nmsub.s %[f8], %[f8], %[f15], %[f7] \n\t" + "madd.s %[f10], %[f10], %[f15], %[f5] \n\t" #endif - "swc1 %[f3], 4(%[a1]) \n\t" - "swc1 %[f4], 4(%[a2]) \n\t" - "sub.s %[f11], %[f11], %[f8] \n\t" - "add.s %[f12], %[f12], %[f8] \n\t" - "sub.s %[f13], %[f13], %[f10] \n\t" - "sub.s %[f14], %[f14], %[f10] \n\t" - "addiu %[c2], %[c2], -8 \n\t" - "addiu %[c1], %[c1], 8 \n\t" - "swc1 %[f11], 8(%[a1]) \n\t" - "swc1 %[f12], -8(%[a2]) \n\t" - "swc1 %[f13], 12(%[a1]) \n\t" - "swc1 %[f14], -4(%[a2]) \n\t" - "addiu %[a1], %[a1], 16 \n\t" - "addiu %[count], %[count], -1 \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[a2], %[a2], -16 \n\t" - ".set pop \n\t" - : [a1] "+r" (a1), [a2] "+r" (a2), [c1] "+r" (c1), [c2] "+r" (c2), - [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), [f4] "=&f" (f4), - [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8), - [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), [f12] "=&f" (f12), - [f13] "=&f" (f13), [f14] "=&f" (f14), [f15] "=&f" (f15), - [count] "=&r" (count) - : [f0] "f" (f0) - : "memory" - ); + "swc1 %[f3], 4(%[a1]) \n\t" + "swc1 %[f4], 4(%[a2]) \n\t" + "sub.s %[f11], %[f11], %[f8] \n\t" + "add.s %[f12], %[f12], %[f8] \n\t" + "sub.s %[f13], %[f13], %[f10] \n\t" + "sub.s %[f14], %[f14], %[f10] \n\t" + "addiu %[c2], %[c2], -8 \n\t" + "addiu %[c1], %[c1], 8 \n\t" + "swc1 %[f11], 8(%[a1]) \n\t" + "swc1 %[f12], -8(%[a2]) \n\t" + "swc1 %[f13], 12(%[a1]) \n\t" + "swc1 %[f14], -4(%[a2]) \n\t" + "addiu %[a1], %[a1], 16 \n\t" + "addiu %[count], %[count], -1 \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[a2], %[a2], -16 \n\t" + ".set pop \n\t" + : [a1] "+r"(a1), [a2] "+r"(a2), [c1] "+r"(c1), [c2] "+r"(c2), + [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), [f4] "=&f"(f4), + [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), [f8] "=&f"(f8), + [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), [f12] "=&f"(f12), + [f13] "=&f"(f13), [f14] "=&f"(f14), [f15] "=&f"(f15), + [count] "=&r"(count) + : [f0] "f"(f0) + : "memory"); } void rftbsub_128_mips(float* a) { - const float *c = rdft_w + 32; + const float* c = rdft_w + 32; const float f0 = 0.5f; float* a1 = &a[2]; float* a2 = &a[126]; const float* c1 = &c[1]; const float* c2 = &c[31]; - float f1, f2, f3 ,f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; + float f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; int count; a[1] = -a[1]; a[65] = -a[65]; - __asm __volatile ( - ".set push \n\t" - ".set noreorder \n\t" - "lwc1 %[f6], 0(%[c2]) \n\t" - "lwc1 %[f1], 0(%[a1]) \n\t" - "lwc1 %[f2], 0(%[a2]) \n\t" - "lwc1 %[f3], 4(%[a1]) \n\t" - "lwc1 %[f4], 4(%[a2]) \n\t" - "lwc1 %[f5], 0(%[c1]) \n\t" - "sub.s %[f6], %[f0], %[f6] \n\t" - "sub.s %[f7], %[f1], %[f2] \n\t" - "add.s %[f8], %[f3], %[f4] \n\t" - "addiu %[count], $zero, 15 \n\t" - "mul.s %[f9], %[f6], %[f7] \n\t" - "mul.s %[f6], %[f6], %[f8] \n\t" + __asm __volatile( + ".set push \n\t" + ".set noreorder \n\t" + "lwc1 %[f6], 0(%[c2]) \n\t" + "lwc1 %[f1], 0(%[a1]) \n\t" + "lwc1 %[f2], 0(%[a2]) \n\t" + "lwc1 %[f3], 4(%[a1]) \n\t" + "lwc1 %[f4], 4(%[a2]) \n\t" + "lwc1 %[f5], 0(%[c1]) \n\t" + "sub.s %[f6], %[f0], %[f6] \n\t" + "sub.s %[f7], %[f1], %[f2] \n\t" + "add.s %[f8], %[f3], %[f4] \n\t" + "addiu %[count], $zero, 15 \n\t" + "mul.s %[f9], %[f6], %[f7] \n\t" + "mul.s %[f6], %[f6], %[f8] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f8], %[f5], %[f8] \n\t" - "mul.s %[f5], %[f5], %[f7] \n\t" - "add.s %[f9], %[f9], %[f8] \n\t" - "sub.s %[f6], %[f6], %[f5] \n\t" + "mul.s %[f8], %[f5], %[f8] \n\t" + "mul.s %[f5], %[f5], %[f7] \n\t" + "add.s %[f9], %[f9], %[f8] \n\t" + "sub.s %[f6], %[f6], %[f5] \n\t" #else - "madd.s %[f9], %[f9], %[f5], %[f8] \n\t" - "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t" + "madd.s %[f9], %[f9], %[f5], %[f8] \n\t" + "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t" #endif - "sub.s %[f1], %[f1], %[f9] \n\t" - "add.s %[f2], %[f2], %[f9] \n\t" - "sub.s %[f3], %[f6], %[f3] \n\t" - "sub.s %[f4], %[f6], %[f4] \n\t" - "swc1 %[f1], 0(%[a1]) \n\t" - "swc1 %[f2], 0(%[a2]) \n\t" - "swc1 %[f3], 4(%[a1]) \n\t" - "swc1 %[f4], 4(%[a2]) \n\t" - "addiu %[a1], %[a1], 8 \n\t" - "addiu %[a2], %[a2], -8 \n\t" - "addiu %[c1], %[c1], 4 \n\t" - "addiu %[c2], %[c2], -4 \n\t" - "1: \n\t" - "lwc1 %[f6], 0(%[c2]) \n\t" - "lwc1 %[f1], 0(%[a1]) \n\t" - "lwc1 %[f2], 0(%[a2]) \n\t" - "lwc1 %[f3], 4(%[a1]) \n\t" - "lwc1 %[f4], 4(%[a2]) \n\t" - "lwc1 %[f5], 0(%[c1]) \n\t" - "sub.s %[f6], %[f0], %[f6] \n\t" - "sub.s %[f7], %[f1], %[f2] \n\t" - "add.s %[f8], %[f3], %[f4] \n\t" - "lwc1 %[f10], -4(%[c2]) \n\t" - "lwc1 %[f11], 8(%[a1]) \n\t" - "lwc1 %[f12], -8(%[a2]) \n\t" - "mul.s %[f9], %[f6], %[f7] \n\t" - "mul.s %[f6], %[f6], %[f8] \n\t" + "sub.s %[f1], %[f1], %[f9] \n\t" + "add.s %[f2], %[f2], %[f9] \n\t" + "sub.s %[f3], %[f6], %[f3] \n\t" + "sub.s %[f4], %[f6], %[f4] \n\t" + "swc1 %[f1], 0(%[a1]) \n\t" + "swc1 %[f2], 0(%[a2]) \n\t" + "swc1 %[f3], 4(%[a1]) \n\t" + "swc1 %[f4], 4(%[a2]) \n\t" + "addiu %[a1], %[a1], 8 \n\t" + "addiu %[a2], %[a2], -8 \n\t" + "addiu %[c1], %[c1], 4 \n\t" + "addiu %[c2], %[c2], -4 \n\t" + "1: \n\t" + "lwc1 %[f6], 0(%[c2]) \n\t" + "lwc1 %[f1], 0(%[a1]) \n\t" + "lwc1 %[f2], 0(%[a2]) \n\t" + "lwc1 %[f3], 4(%[a1]) \n\t" + "lwc1 %[f4], 4(%[a2]) \n\t" + "lwc1 %[f5], 0(%[c1]) \n\t" + "sub.s %[f6], %[f0], %[f6] \n\t" + "sub.s %[f7], %[f1], %[f2] \n\t" + "add.s %[f8], %[f3], %[f4] \n\t" + "lwc1 %[f10], -4(%[c2]) \n\t" + "lwc1 %[f11], 8(%[a1]) \n\t" + "lwc1 %[f12], -8(%[a2]) \n\t" + "mul.s %[f9], %[f6], %[f7] \n\t" + "mul.s %[f6], %[f6], %[f8] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f8], %[f5], %[f8] \n\t" - "mul.s %[f5], %[f5], %[f7] \n\t" - "lwc1 %[f13], 12(%[a1]) \n\t" - "lwc1 %[f14], -4(%[a2]) \n\t" - "lwc1 %[f15], 4(%[c1]) \n\t" - "add.s %[f9], %[f9], %[f8] \n\t" - "sub.s %[f6], %[f6], %[f5] \n\t" + "mul.s %[f8], %[f5], %[f8] \n\t" + "mul.s %[f5], %[f5], %[f7] \n\t" + "lwc1 %[f13], 12(%[a1]) \n\t" + "lwc1 %[f14], -4(%[a2]) \n\t" + "lwc1 %[f15], 4(%[c1]) \n\t" + "add.s %[f9], %[f9], %[f8] \n\t" + "sub.s %[f6], %[f6], %[f5] \n\t" #else - "lwc1 %[f13], 12(%[a1]) \n\t" - "lwc1 %[f14], -4(%[a2]) \n\t" - "lwc1 %[f15], 4(%[c1]) \n\t" - "madd.s %[f9], %[f9], %[f5], %[f8] \n\t" - "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t" + "lwc1 %[f13], 12(%[a1]) \n\t" + "lwc1 %[f14], -4(%[a2]) \n\t" + "lwc1 %[f15], 4(%[c1]) \n\t" + "madd.s %[f9], %[f9], %[f5], %[f8] \n\t" + "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t" #endif - "sub.s %[f10], %[f0], %[f10] \n\t" - "sub.s %[f5], %[f11], %[f12] \n\t" - "add.s %[f7], %[f13], %[f14] \n\t" - "sub.s %[f1], %[f1], %[f9] \n\t" - "add.s %[f2], %[f2], %[f9] \n\t" - "sub.s %[f3], %[f6], %[f3] \n\t" - "mul.s %[f8], %[f10], %[f5] \n\t" - "mul.s %[f10], %[f10], %[f7] \n\t" + "sub.s %[f10], %[f0], %[f10] \n\t" + "sub.s %[f5], %[f11], %[f12] \n\t" + "add.s %[f7], %[f13], %[f14] \n\t" + "sub.s %[f1], %[f1], %[f9] \n\t" + "add.s %[f2], %[f2], %[f9] \n\t" + "sub.s %[f3], %[f6], %[f3] \n\t" + "mul.s %[f8], %[f10], %[f5] \n\t" + "mul.s %[f10], %[f10], %[f7] \n\t" #if !defined(MIPS32_R2_LE) - "mul.s %[f9], %[f15], %[f7] \n\t" - "mul.s %[f15], %[f15], %[f5] \n\t" - "sub.s %[f4], %[f6], %[f4] \n\t" - "swc1 %[f1], 0(%[a1]) \n\t" - "swc1 %[f2], 0(%[a2]) \n\t" - "add.s %[f8], %[f8], %[f9] \n\t" - "sub.s %[f10], %[f10], %[f15] \n\t" + "mul.s %[f9], %[f15], %[f7] \n\t" + "mul.s %[f15], %[f15], %[f5] \n\t" + "sub.s %[f4], %[f6], %[f4] \n\t" + "swc1 %[f1], 0(%[a1]) \n\t" + "swc1 %[f2], 0(%[a2]) \n\t" + "add.s %[f8], %[f8], %[f9] \n\t" + "sub.s %[f10], %[f10], %[f15] \n\t" #else - "swc1 %[f1], 0(%[a1]) \n\t" - "swc1 %[f2], 0(%[a2]) \n\t" - "sub.s %[f4], %[f6], %[f4] \n\t" - "madd.s %[f8], %[f8], %[f15], %[f7] \n\t" - "nmsub.s %[f10], %[f10], %[f15], %[f5] \n\t" + "swc1 %[f1], 0(%[a1]) \n\t" + "swc1 %[f2], 0(%[a2]) \n\t" + "sub.s %[f4], %[f6], %[f4] \n\t" + "madd.s %[f8], %[f8], %[f15], %[f7] \n\t" + "nmsub.s %[f10], %[f10], %[f15], %[f5] \n\t" #endif - "swc1 %[f3], 4(%[a1]) \n\t" - "swc1 %[f4], 4(%[a2]) \n\t" - "sub.s %[f11], %[f11], %[f8] \n\t" - "add.s %[f12], %[f12], %[f8] \n\t" - "sub.s %[f13], %[f10], %[f13] \n\t" - "sub.s %[f14], %[f10], %[f14] \n\t" - "addiu %[c2], %[c2], -8 \n\t" - "addiu %[c1], %[c1], 8 \n\t" - "swc1 %[f11], 8(%[a1]) \n\t" - "swc1 %[f12], -8(%[a2]) \n\t" - "swc1 %[f13], 12(%[a1]) \n\t" - "swc1 %[f14], -4(%[a2]) \n\t" - "addiu %[a1], %[a1], 16 \n\t" - "addiu %[count], %[count], -1 \n\t" - "bgtz %[count], 1b \n\t" - " addiu %[a2], %[a2], -16 \n\t" - ".set pop \n\t" - : [a1] "+r" (a1), [a2] "+r" (a2), [c1] "+r" (c1), [c2] "+r" (c2), - [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), [f4] "=&f" (f4), - [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8), - [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), [f12] "=&f" (f12), - [f13] "=&f" (f13), [f14] "=&f" (f14), [f15] "=&f" (f15), - [count] "=&r" (count) - : [f0] "f" (f0) - : "memory" - ); + "swc1 %[f3], 4(%[a1]) \n\t" + "swc1 %[f4], 4(%[a2]) \n\t" + "sub.s %[f11], %[f11], %[f8] \n\t" + "add.s %[f12], %[f12], %[f8] \n\t" + "sub.s %[f13], %[f10], %[f13] \n\t" + "sub.s %[f14], %[f10], %[f14] \n\t" + "addiu %[c2], %[c2], -8 \n\t" + "addiu %[c1], %[c1], 8 \n\t" + "swc1 %[f11], 8(%[a1]) \n\t" + "swc1 %[f12], -8(%[a2]) \n\t" + "swc1 %[f13], 12(%[a1]) \n\t" + "swc1 %[f14], -4(%[a2]) \n\t" + "addiu %[a1], %[a1], 16 \n\t" + "addiu %[count], %[count], -1 \n\t" + "bgtz %[count], 1b \n\t" + " addiu %[a2], %[a2], -16 \n\t" + ".set pop \n\t" + : [a1] "+r"(a1), [a2] "+r"(a2), [c1] "+r"(c1), [c2] "+r"(c2), + [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), [f4] "=&f"(f4), + [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), [f8] "=&f"(f8), + [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), [f12] "=&f"(f12), + [f13] "=&f"(f13), [f14] "=&f"(f14), [f15] "=&f"(f15), + [count] "=&r"(count) + : [f0] "f"(f0) + : "memory"); } #endif diff --git a/modules/audio_processing/vad/gmm_unittest.cc b/modules/audio_processing/vad/gmm_unittest.cc index dfc8855a14..d895afab7b 100644 --- a/modules/audio_processing/vad/gmm_unittest.cc +++ b/modules/audio_processing/vad/gmm_unittest.cc @@ -37,10 +37,10 @@ TEST(GmmTest, EvaluateGmm) { voice_gmm.covar_inverse = &kVoiceGmmCovarInverse[0][0][0]; // Test vectors. These are the mean of the GMM means. - const double kXVoice[kVoiceGmmDim] = { - -1.35893162459863, 602.862491970368, 178.022069191324}; - const double kXNoise[kNoiseGmmDim] = { - -2.33443722724409, 2827.97828765184, 141.114178166812}; + const double kXVoice[kVoiceGmmDim] = {-1.35893162459863, 602.862491970368, + 178.022069191324}; + const double kXNoise[kNoiseGmmDim] = {-2.33443722724409, 2827.97828765184, + 141.114178166812}; // Expected pdf values. These values are computed in MATLAB using EvalGmm.m const double kPdfNoise = 1.88904409403101e-07; diff --git a/modules/audio_processing/vad/noise_gmm_tables.h b/modules/audio_processing/vad/noise_gmm_tables.h index c07dadebd5..15562776e9 100644 --- a/modules/audio_processing/vad/noise_gmm_tables.h +++ b/modules/audio_processing/vad/noise_gmm_tables.h @@ -70,16 +70,8 @@ static const double kNoiseGmmMean[kNoiseGmmNumMixtures][kNoiseGmmDim] = { {-2.30193040814533e+00, 1.43953696546439e+03, 7.04085275122649e+01}}; static const double kNoiseGmmWeights[kNoiseGmmNumMixtures] = { - -1.09422832086193e+01, - -1.10847897513425e+01, - -1.36767587732187e+01, - -1.79789356118641e+01, - -1.42830169160894e+01, - -1.56500228061379e+01, - -1.83124990950113e+01, - -1.69979436177477e+01, - -1.12329424387828e+01, - -1.41311785780639e+01, - -1.47171861448585e+01, - -1.35963362781839e+01}; + -1.09422832086193e+01, -1.10847897513425e+01, -1.36767587732187e+01, + -1.79789356118641e+01, -1.42830169160894e+01, -1.56500228061379e+01, + -1.83124990950113e+01, -1.69979436177477e+01, -1.12329424387828e+01, + -1.41311785780639e+01, -1.47171861448585e+01, -1.35963362781839e+01}; #endif // MODULES_AUDIO_PROCESSING_VAD_NOISE_GMM_TABLES_H_ diff --git a/modules/audio_processing/vad/pitch_based_vad.cc b/modules/audio_processing/vad/pitch_based_vad.cc index 240ec63f29..025ef2059d 100644 --- a/modules/audio_processing/vad/pitch_based_vad.cc +++ b/modules/audio_processing/vad/pitch_based_vad.cc @@ -13,9 +13,9 @@ #include #include -#include "modules/audio_processing/vad/vad_circular_buffer.h" #include "modules/audio_processing/vad/common.h" #include "modules/audio_processing/vad/noise_gmm_tables.h" +#include "modules/audio_processing/vad/vad_circular_buffer.h" #include "modules/audio_processing/vad/voice_gmm_tables.h" namespace webrtc { @@ -58,8 +58,7 @@ PitchBasedVad::PitchBasedVad() voice_gmm_.covar_inverse = &kVoiceGmmCovarInverse[0][0][0]; } -PitchBasedVad::~PitchBasedVad() { -} +PitchBasedVad::~PitchBasedVad() {} int PitchBasedVad::VoicingProbability(const AudioFeatures& features, double* p_combined) { diff --git a/modules/audio_processing/vad/pitch_internal_unittest.cc b/modules/audio_processing/vad/pitch_internal_unittest.cc index c1fde10008..19c2e1a271 100644 --- a/modules/audio_processing/vad/pitch_internal_unittest.cc +++ b/modules/audio_processing/vad/pitch_internal_unittest.cc @@ -26,12 +26,12 @@ TEST(PitchInternalTest, test) { double lags[] = {90, 111, 122, 50}; // Expected outputs - double expected_log_pitch_gain[] = { - -0.541212549898316, -1.45672279045507, -0.80471895621705}; + double expected_log_pitch_gain[] = {-0.541212549898316, -1.45672279045507, + -0.80471895621705}; double expected_log_old_gain = log(gains[kNumInputParameters - 1]); - double expected_pitch_lag_hz[] = { - 92.3076923076923, 70.9010339734121, 93.0232558139535}; + double expected_pitch_lag_hz[] = {92.3076923076923, 70.9010339734121, + 93.0232558139535}; double expected_old_lag = lags[kNumInputParameters - 1]; double log_pitch_gain[kNumOutputParameters]; diff --git a/modules/audio_processing/vad/pole_zero_filter.cc b/modules/audio_processing/vad/pole_zero_filter.cc index fa56a3c15e..b9967d7aea 100644 --- a/modules/audio_processing/vad/pole_zero_filter.cc +++ b/modules/audio_processing/vad/pole_zero_filter.cc @@ -53,7 +53,8 @@ PoleZeroFilter::PoleZeroFilter(const float* numerator_coefficients, } template -static float FilterArPast(const T* past, size_t order, +static float FilterArPast(const T* past, + size_t order, const float* coefficients) { float sum = 0.0f; size_t past_index = order - 1; diff --git a/modules/audio_processing/vad/standalone_vad.cc b/modules/audio_processing/vad/standalone_vad.cc index 2640892cc2..813d375f9a 100644 --- a/modules/audio_processing/vad/standalone_vad.cc +++ b/modules/audio_processing/vad/standalone_vad.cc @@ -21,8 +21,7 @@ namespace webrtc { static const int kDefaultStandaloneVadMode = 3; StandaloneVad::StandaloneVad(VadInst* vad) - : vad_(vad), buffer_(), index_(0), mode_(kDefaultStandaloneVadMode) { -} + : vad_(vad), buffer_(), index_(0), mode_(kDefaultStandaloneVadMode) {} StandaloneVad::~StandaloneVad() { WebRtcVad_Free(vad_); diff --git a/modules/audio_processing/vad/standalone_vad.h b/modules/audio_processing/vad/standalone_vad.h index b85de0a75a..3f6eb7fde9 100644 --- a/modules/audio_processing/vad/standalone_vad.h +++ b/modules/audio_processing/vad/standalone_vad.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_ #define MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_ -#include "modules/audio_processing/vad/common.h" #include "common_audio/vad/include/webrtc_vad.h" +#include "modules/audio_processing/vad/common.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/modules/audio_processing/vad/vad_audio_proc.cc b/modules/audio_processing/vad/vad_audio_proc.cc index 459cda6974..e9007c61b2 100644 --- a/modules/audio_processing/vad/vad_audio_proc.cc +++ b/modules/audio_processing/vad/vad_audio_proc.cc @@ -67,8 +67,7 @@ VadAudioProc::VadAudioProc() WebRtcIsac_InitPitchAnalysis(pitch_analysis_handle_.get()); } -VadAudioProc::~VadAudioProc() { -} +VadAudioProc::~VadAudioProc() {} void VadAudioProc::ResetBuffer() { memcpy(audio_buffer_, &audio_buffer_[kNumSamplesToProcess], diff --git a/modules/audio_processing/vad/vad_audio_proc_internal.h b/modules/audio_processing/vad/vad_audio_proc_internal.h index ab1e63651f..915524f474 100644 --- a/modules/audio_processing/vad/vad_audio_proc_internal.h +++ b/modules/audio_processing/vad/vad_audio_proc_internal.h @@ -14,23 +14,10 @@ namespace webrtc { // These values should match MATLAB counterparts for unit-tests to pass. -static const double kCorrWeight[] = {1.000000, - 0.985000, - 0.970225, - 0.955672, - 0.941337, - 0.927217, - 0.913308, - 0.899609, - 0.886115, - 0.872823, - 0.859730, - 0.846834, - 0.834132, - 0.821620, - 0.809296, - 0.797156, - 0.785199}; +static const double kCorrWeight[] = { + 1.000000, 0.985000, 0.970225, 0.955672, 0.941337, 0.927217, + 0.913308, 0.899609, 0.886115, 0.872823, 0.859730, 0.846834, + 0.834132, 0.821620, 0.809296, 0.797156, 0.785199}; static const double kLpcAnalWin[] = { 0.00000000, 0.01314436, 0.02628645, 0.03942400, 0.05255473, 0.06567639, @@ -75,11 +62,9 @@ static const double kLpcAnalWin[] = { 0.06567639, 0.05255473, 0.03942400, 0.02628645, 0.01314436, 0.00000000}; static const size_t kFilterOrder = 2; -static const float kCoeffNumerator[kFilterOrder + 1] = {0.974827f, - -1.949650f, +static const float kCoeffNumerator[kFilterOrder + 1] = {0.974827f, -1.949650f, 0.974827f}; -static const float kCoeffDenominator[kFilterOrder + 1] = {1.0f, - -1.971999f, +static const float kCoeffDenominator[kFilterOrder + 1] = {1.0f, -1.971999f, 0.972457f}; static_assert(kFilterOrder + 1 == diff --git a/modules/audio_processing/vad/vad_circular_buffer.cc b/modules/audio_processing/vad/vad_circular_buffer.cc index 3c4d5ad0e0..31f14d7f64 100644 --- a/modules/audio_processing/vad/vad_circular_buffer.cc +++ b/modules/audio_processing/vad/vad_circular_buffer.cc @@ -19,11 +19,9 @@ VadCircularBuffer::VadCircularBuffer(int buffer_size) is_full_(false), index_(0), buffer_size_(buffer_size), - sum_(0) { -} + sum_(0) {} -VadCircularBuffer::~VadCircularBuffer() { -} +VadCircularBuffer::~VadCircularBuffer() {} void VadCircularBuffer::Reset() { is_full_ = false; diff --git a/modules/audio_processing/vad/voice_activity_detector.cc b/modules/audio_processing/vad/voice_activity_detector.cc index 66a704f6be..f0d34c668e 100644 --- a/modules/audio_processing/vad/voice_activity_detector.cc +++ b/modules/audio_processing/vad/voice_activity_detector.cc @@ -27,8 +27,7 @@ const double kLowProbability = 0.01; VoiceActivityDetector::VoiceActivityDetector() : last_voice_probability_(kDefaultVoiceValue), - standalone_vad_(StandaloneVad::Create()) { -} + standalone_vad_(StandaloneVad::Create()) {} VoiceActivityDetector::~VoiceActivityDetector() = default; diff --git a/modules/audio_processing/vad/voice_activity_detector.h b/modules/audio_processing/vad/voice_activity_detector.h index 0079cb2184..e424ac1a28 100644 --- a/modules/audio_processing/vad/voice_activity_detector.h +++ b/modules/audio_processing/vad/voice_activity_detector.h @@ -15,10 +15,10 @@ #include #include "common_audio/resampler/include/resampler.h" -#include "modules/audio_processing/vad/vad_audio_proc.h" #include "modules/audio_processing/vad/common.h" #include "modules/audio_processing/vad/pitch_based_vad.h" #include "modules/audio_processing/vad/standalone_vad.h" +#include "modules/audio_processing/vad/vad_audio_proc.h" namespace webrtc { diff --git a/modules/audio_processing/vad/voice_gmm_tables.h b/modules/audio_processing/vad/voice_gmm_tables.h index 29cc7d6cb2..ef4ad7e21e 100644 --- a/modules/audio_processing/vad/voice_gmm_tables.h +++ b/modules/audio_processing/vad/voice_gmm_tables.h @@ -70,16 +70,8 @@ static const double kVoiceGmmMean[kVoiceGmmNumMixtures][kVoiceGmmDim] = { {-7.29187507662854e-01, 5.22717685022855e+02, 1.16377942283991e+02}}; static const double kVoiceGmmWeights[kVoiceGmmNumMixtures] = { - -1.39789694361035e+01, - -1.19527720202104e+01, - -1.32396317929055e+01, - -1.09436815209238e+01, - -1.13440027478149e+01, - -1.12200721834504e+01, - -1.02537324043693e+01, - -1.60789861938302e+01, - -1.03394494048344e+01, - -1.83207938586818e+01, - -1.31186044948288e+01, - -9.52479998673554e+00}; + -1.39789694361035e+01, -1.19527720202104e+01, -1.32396317929055e+01, + -1.09436815209238e+01, -1.13440027478149e+01, -1.12200721834504e+01, + -1.02537324043693e+01, -1.60789861938302e+01, -1.03394494048344e+01, + -1.83207938586818e+01, -1.31186044948288e+01, -9.52479998673554e+00}; #endif // MODULES_AUDIO_PROCESSING_VAD_VOICE_GMM_TABLES_H_ diff --git a/modules/audio_processing/voice_detection_impl.cc b/modules/audio_processing/voice_detection_impl.cc index 5ee0c7b9c2..9280be1ef9 100644 --- a/modules/audio_processing/voice_detection_impl.cc +++ b/modules/audio_processing/voice_detection_impl.cc @@ -23,10 +23,9 @@ class VoiceDetectionImpl::Vad { int error = WebRtcVad_Init(state_); RTC_DCHECK_EQ(0, error); } - ~Vad() { - WebRtcVad_Free(state_); - } + ~Vad() { WebRtcVad_Free(state_); } VadInst* state() { return state_; } + private: VadInst* state_ = nullptr; RTC_DISALLOW_COPY_AND_ASSIGN(Vad); @@ -65,9 +64,9 @@ void VoiceDetectionImpl::ProcessCaptureAudio(AudioBuffer* audio) { RTC_DCHECK_GE(160, audio->num_frames_per_band()); // TODO(ajm): concatenate data in frame buffer here. - int vad_ret = WebRtcVad_Process(vad_->state(), sample_rate_hz_, - audio->mixed_low_pass_data(), - frame_size_samples_); + int vad_ret = + WebRtcVad_Process(vad_->state(), sample_rate_hz_, + audio->mixed_low_pass_data(), frame_size_samples_); if (vad_ret == 0) { stream_has_voice_ = false; audio->set_activity(AudioFrame::kVadPassive); @@ -103,7 +102,7 @@ int VoiceDetectionImpl::set_stream_has_voice(bool has_voice) { bool VoiceDetectionImpl::stream_has_voice() const { rtc::CritScope cs(crit_); // TODO(ajm): enable this assertion? - //RTC_DCHECK(using_external_vad_ || is_component_enabled()); + // RTC_DCHECK(using_external_vad_ || is_component_enabled()); return stream_has_voice_; } @@ -142,7 +141,7 @@ VoiceDetection::Likelihood VoiceDetectionImpl::likelihood() const { int VoiceDetectionImpl::set_frame_size_ms(int size) { rtc::CritScope cs(crit_); - RTC_DCHECK_EQ(10, size); // TODO(ajm): remove when supported. + RTC_DCHECK_EQ(10, size); // TODO(ajm): remove when supported. frame_size_ms_ = size; Initialize(sample_rate_hz_); return AudioProcessing::kNoError; diff --git a/modules/bitrate_controller/bitrate_controller_impl.cc b/modules/bitrate_controller/bitrate_controller_impl.cc index 5b9b9ad462..38f97fb7e2 100644 --- a/modules/bitrate_controller/bitrate_controller_impl.cc +++ b/modules/bitrate_controller/bitrate_controller_impl.cc @@ -25,8 +25,7 @@ class BitrateControllerImpl::RtcpBandwidthObserverImpl : public RtcpBandwidthObserver { public: explicit RtcpBandwidthObserverImpl(BitrateControllerImpl* owner) - : owner_(owner) { - } + : owner_(owner) {} ~RtcpBandwidthObserverImpl() override = default; // Received RTCP REMB or TMMBR. void OnReceivedEstimatedBitrate(uint32_t bitrate) override { @@ -102,8 +101,7 @@ void BitrateControllerImpl::SetBitrates(int start_bitrate_bps, int max_bitrate_bps) { { rtc::CritScope cs(&critsect_); - bandwidth_estimation_.SetBitrates(start_bitrate_bps, - min_bitrate_bps, + bandwidth_estimation_.SetBitrates(start_bitrate_bps, min_bitrate_bps, max_bitrate_bps); } MaybeTriggerOnNetworkChanged(); diff --git a/modules/bitrate_controller/bitrate_controller_impl.h b/modules/bitrate_controller/bitrate_controller_impl.h index 6a678082e9..e315c5f9fd 100644 --- a/modules/bitrate_controller/bitrate_controller_impl.h +++ b/modules/bitrate_controller/bitrate_controller_impl.h @@ -54,7 +54,6 @@ class BitrateControllerImpl : public BitrateController { int min_bitrate_bps, int max_bitrate_bps) override; - void SetReservedBitrate(uint32_t reserved_bitrate_bps) override; // Returns true if the parameters have changed since the last call. diff --git a/modules/bitrate_controller/bitrate_controller_unittest.cc b/modules/bitrate_controller/bitrate_controller_unittest.cc index 8bd7800ee7..ce930d10d4 100644 --- a/modules/bitrate_controller/bitrate_controller_unittest.cc +++ b/modules/bitrate_controller/bitrate_controller_unittest.cc @@ -26,28 +26,29 @@ using webrtc::BitrateObserver; using webrtc::PacedSender; using webrtc::RtcpBandwidthObserver; -uint8_t WeightedLoss(int num_packets1, uint8_t fraction_loss1, - int num_packets2, uint8_t fraction_loss2) { - int weighted_sum = num_packets1 * fraction_loss1 + - num_packets2 * fraction_loss2; +uint8_t WeightedLoss(int num_packets1, + uint8_t fraction_loss1, + int num_packets2, + uint8_t fraction_loss2) { + int weighted_sum = + num_packets1 * fraction_loss1 + num_packets2 * fraction_loss2; int total_num_packets = num_packets1 + num_packets2; return (weighted_sum + total_num_packets / 2) / total_num_packets; } webrtc::RTCPReportBlock CreateReportBlock( - uint32_t remote_ssrc, uint32_t source_ssrc, - uint8_t fraction_lost, uint32_t extended_high_sequence_number) { + uint32_t remote_ssrc, + uint32_t source_ssrc, + uint8_t fraction_lost, + uint32_t extended_high_sequence_number) { return webrtc::RTCPReportBlock(remote_ssrc, source_ssrc, fraction_lost, 0, extended_high_sequence_number, 0, 0, 0); } -class TestBitrateObserver: public BitrateObserver { +class TestBitrateObserver : public BitrateObserver { public: TestBitrateObserver() - : last_bitrate_(0), - last_fraction_loss_(0), - last_rtt_(0) { - } + : last_bitrate_(0), last_fraction_loss_(0), last_rtt_(0) {} virtual void OnNetworkChanged(uint32_t bitrate, uint8_t fraction_loss, @@ -76,8 +77,7 @@ class BitrateControllerTest : public ::testing::Test { bandwidth_observer_ = controller_.get(); } - virtual void TearDown() { - } + virtual void TearDown() {} const int kMinBitrateBps = 100000; const int kStartBitrateBps = 200000; @@ -197,8 +197,8 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { RtcpBandwidthObserver* second_bandwidth_observer = controller_.get(); report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 21)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 100, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100, + time_ms); // Test start bitrate. EXPECT_EQ(200000, bitrate_observer_.last_bitrate_); @@ -212,8 +212,8 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { time_ms += 500; report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 21)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 100, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100, + time_ms); EXPECT_EQ(217000, bitrate_observer_.last_bitrate_); EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); EXPECT_EQ(100, bitrate_observer_.last_rtt_); @@ -221,8 +221,8 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { // Extra report should not change estimate. report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 31)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 100, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100, + time_ms); EXPECT_EQ(217000, bitrate_observer_.last_bitrate_); time_ms += 500; @@ -232,34 +232,34 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { // Second report should not change estimate. report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 41)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 100, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100, + time_ms); EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); time_ms += 1000; // Reports from only one bandwidth observer is ok. report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 61)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 50, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50, + time_ms); EXPECT_EQ(255189, bitrate_observer_.last_bitrate_); time_ms += 1000; report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 81)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 50, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50, + time_ms); EXPECT_EQ(276604, bitrate_observer_.last_bitrate_); time_ms += 1000; report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 121)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 50, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50, + time_ms); EXPECT_EQ(299732, bitrate_observer_.last_bitrate_); time_ms += 1000; // Reach max cap. report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 141)}; - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 50, time_ms); + second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50, + time_ms); EXPECT_EQ(300000, bitrate_observer_.last_bitrate_); // Test that a low REMB trigger immediately. diff --git a/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/modules/bitrate_controller/send_side_bandwidth_estimation.cc index 323c210a54..d304516007 100644 --- a/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -193,8 +193,8 @@ void SendSideBandwidthEstimation::CurrentEstimate(int* bitrate, *rtt = last_round_trip_time_ms_; } -void SendSideBandwidthEstimation::UpdateReceiverEstimate( - int64_t now_ms, uint32_t bandwidth) { +void SendSideBandwidthEstimation::UpdateReceiverEstimate(int64_t now_ms, + uint32_t bandwidth) { bwe_incoming_ = bandwidth; CapBitrateToThresholds(now_ms, current_bitrate_bps_); } diff --git a/modules/bitrate_controller/send_side_bandwidth_estimation.h b/modules/bitrate_controller/send_side_bandwidth_estimation.h index d09184c0bf..54b571e96e 100644 --- a/modules/bitrate_controller/send_side_bandwidth_estimation.h +++ b/modules/bitrate_controller/send_side_bandwidth_estimation.h @@ -54,9 +54,7 @@ class SendSideBandwidthEstimation { // Call when we receive a RTCP message with a ReceiveBlock. void UpdateRtt(int64_t rtt, int64_t now_ms); - void SetBitrates(int send_bitrate, - int min_bitrate, - int max_bitrate); + void SetBitrates(int send_bitrate, int min_bitrate, int max_bitrate); void SetSendBitrate(int bitrate); void SetMinMaxBitrate(int min_bitrate, int max_bitrate); int GetMinBitrate() const; diff --git a/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc index 567d81f610..8d5b08bd04 100644 --- a/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc +++ b/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc @@ -164,5 +164,4 @@ TEST(SendSideBweTest, SettingSendBitrateOverridesDelayBasedEstimate) { EXPECT_EQ(bitrate_bps, kForcedHighBitrate); } - } // namespace webrtc diff --git a/modules/congestion_controller/bbr/bbr_network_controller.cc b/modules/congestion_controller/bbr/bbr_network_controller.cc index a8de48a9d3..89fab5d0fd 100644 --- a/modules/congestion_controller/bbr/bbr_network_controller.cc +++ b/modules/congestion_controller/bbr/bbr_network_controller.cc @@ -430,7 +430,7 @@ NetworkControlUpdate BbrNetworkController::OnTransportPacketsFeedback( } else { bytes_acked_since_queue_drained_ += data_acked; } - } + } } // Handle logic specific to PROBE_BW mode. diff --git a/modules/congestion_controller/include/receive_side_congestion_controller.h b/modules/congestion_controller/include/receive_side_congestion_controller.h index a4b593ae88..ef3c8b16eb 100644 --- a/modules/congestion_controller/include/receive_side_congestion_controller.h +++ b/modules/congestion_controller/include/receive_side_congestion_controller.h @@ -30,9 +30,8 @@ class RemoteBitrateObserver; class ReceiveSideCongestionController : public CallStatsObserver, public Module { public: - ReceiveSideCongestionController( - const Clock* clock, - PacketRouter* packet_router); + ReceiveSideCongestionController(const Clock* clock, + PacketRouter* packet_router); virtual ~ReceiveSideCongestionController() {} diff --git a/modules/congestion_controller/probe_controller.cc b/modules/congestion_controller/probe_controller.cc index 56fc8ad376..674fa4231f 100644 --- a/modules/congestion_controller/probe_controller.cc +++ b/modules/congestion_controller/probe_controller.cc @@ -81,7 +81,7 @@ void ProbeController::SetBitrates(int64_t min_bitrate_bps, int64_t max_bitrate_bps) { rtc::CritScope cs(&critsect_); - if (start_bitrate_bps > 0) { + if (start_bitrate_bps > 0) { start_bitrate_bps_ = start_bitrate_bps; estimated_bitrate_bps_ = start_bitrate_bps; } else if (start_bitrate_bps_ == 0) { diff --git a/modules/congestion_controller/probe_controller_unittest.cc b/modules/congestion_controller/probe_controller_unittest.cc index 6e47e017fe..14f53b73b8 100644 --- a/modules/congestion_controller/probe_controller_unittest.cc +++ b/modules/congestion_controller/probe_controller_unittest.cc @@ -249,7 +249,7 @@ TEST_F(LegacyProbeControllerTest, PeriodicProbingAfterReset) { // Make sure we use |kStartBitrateBps| as the estimated bitrate // until SetEstimatedBitrate is called with an updated estimate. clock_.AdvanceTimeMilliseconds(10000); - EXPECT_CALL(local_pacer, CreateProbeCluster(kStartBitrateBps*2)); + EXPECT_CALL(local_pacer, CreateProbeCluster(kStartBitrateBps * 2)); probe_controller_->Process(); } diff --git a/modules/congestion_controller/send_side_congestion_controller.cc b/modules/congestion_controller/send_side_congestion_controller.cc index 8df5ed0191..480b7418c0 100644 --- a/modules/congestion_controller/send_side_congestion_controller.cc +++ b/modules/congestion_controller/send_side_congestion_controller.cc @@ -97,10 +97,10 @@ void SortPacketFeedbackVector( } bool IsPacerPushbackExperimentEnabled() { - return webrtc::field_trial::IsEnabled(kPacerPushbackExperiment) || ( - !webrtc::field_trial::IsDisabled(kPacerPushbackExperiment) && - webrtc::runtime_enabled_features::IsFeatureEnabled( - webrtc::runtime_enabled_features::kDualStreamModeFeatureName)); + return webrtc::field_trial::IsEnabled(kPacerPushbackExperiment) || + (!webrtc::field_trial::IsDisabled(kPacerPushbackExperiment) && + webrtc::runtime_enabled_features::IsFeatureEnabled( + webrtc::runtime_enabled_features::kDualStreamModeFeatureName)); } } // namespace diff --git a/modules/congestion_controller/transport_feedback_adapter_unittest.cc b/modules/congestion_controller/transport_feedback_adapter_unittest.cc index 00e60bb9a6..39aa72e816 100644 --- a/modules/congestion_controller/transport_feedback_adapter_unittest.cc +++ b/modules/congestion_controller/transport_feedback_adapter_unittest.cc @@ -34,7 +34,7 @@ const PacedPacketInfo kPacingInfo1(1, 8, 4000); const PacedPacketInfo kPacingInfo2(2, 14, 7000); const PacedPacketInfo kPacingInfo3(3, 20, 10000); const PacedPacketInfo kPacingInfo4(4, 22, 10000); -} +} // namespace namespace test { @@ -85,8 +85,7 @@ TEST_F(LegacyTransportFeedbackAdapterTest, ObserverSanity) { const std::vector packets = { PacketFeedback(100, 200, 0, 1000, kPacingInfo0), PacketFeedback(110, 210, 1, 2000, kPacingInfo0), - PacketFeedback(120, 220, 2, 3000, kPacingInfo0) - }; + PacketFeedback(120, 220, 2, 3000, kPacingInfo0)}; rtcp::TransportFeedback feedback; feedback.SetBase(packets[0].sequence_number, @@ -171,8 +170,7 @@ TEST_F(LegacyTransportFeedbackAdapterTest, FeedbackVectorReportsUnreceived) { PacketFeedback(130, 230, 3, 1500, kPacingInfo0), PacketFeedback(140, 240, 4, 1500, kPacingInfo0), PacketFeedback(150, 250, 5, 1500, kPacingInfo0), - PacketFeedback(160, 260, 6, 1500, kPacingInfo0) - }; + PacketFeedback(160, 260, 6, 1500, kPacingInfo0)}; for (const PacketFeedback& packet : sent_packets) OnSentPacket(packet); @@ -180,8 +178,7 @@ TEST_F(LegacyTransportFeedbackAdapterTest, FeedbackVectorReportsUnreceived) { // Note: Important to include the last packet, as only unreceived packets in // between received packets can be inferred. std::vector received_packets = { - sent_packets[0], sent_packets[2], sent_packets[6] - }; + sent_packets[0], sent_packets[2], sent_packets[6]}; rtcp::TransportFeedback feedback; feedback.SetBase(received_packets[0].sequence_number, diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc index 722f5dc53a..6bf8d512a8 100644 --- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc +++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc @@ -22,8 +22,7 @@ namespace webrtc { BlankDetectorDesktopCapturerWrapper::BlankDetectorDesktopCapturerWrapper( std::unique_ptr capturer, RgbaColor blank_pixel) - : capturer_(std::move(capturer)), - blank_pixel_(blank_pixel) { + : capturer_(std::move(capturer)), blank_pixel_(blank_pixel) { RTC_DCHECK(capturer_); } diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc index f9cfee026f..d4ec0082f5 100644 --- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc +++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc @@ -49,7 +49,7 @@ class BlankDetectorDesktopCapturerWrapperTest }; BlankDetectorDesktopCapturerWrapperTest:: -BlankDetectorDesktopCapturerWrapperTest() { + BlankDetectorDesktopCapturerWrapperTest() { frame_generator_.size()->set(frame_width_, frame_height_); frame_generator_.set_desktop_frame_painter(&painter_); std::unique_ptr capturer(new FakeDesktopCapturer()); @@ -63,7 +63,7 @@ BlankDetectorDesktopCapturerWrapperTest() { } BlankDetectorDesktopCapturerWrapperTest:: -~BlankDetectorDesktopCapturerWrapperTest() = default; + ~BlankDetectorDesktopCapturerWrapperTest() = default; void BlankDetectorDesktopCapturerWrapperTest::OnCaptureResult( DesktopCapturer::Result result, diff --git a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc index b15ce2b0fd..5e0d264cc2 100644 --- a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc +++ b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc @@ -20,13 +20,12 @@ namespace webrtc { CaptureResultDesktopCapturerWrapper::CaptureResultDesktopCapturerWrapper( std::unique_ptr base_capturer, ResultObserver* observer) - : DesktopCapturerWrapper(std::move(base_capturer)), - observer_(observer) { + : DesktopCapturerWrapper(std::move(base_capturer)), observer_(observer) { RTC_DCHECK(observer_); } -CaptureResultDesktopCapturerWrapper:: -~CaptureResultDesktopCapturerWrapper() = default; +CaptureResultDesktopCapturerWrapper::~CaptureResultDesktopCapturerWrapper() = + default; void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) { if ((callback_ == nullptr) != (callback == nullptr)) { diff --git a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h index 3f97bc5fc4..ffce296164 100644 --- a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h +++ b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h @@ -21,9 +21,8 @@ namespace webrtc { // A DesktopCapturerWrapper implementation to capture the result of // |base_capturer|. Derived classes are expected to provide a ResultObserver // implementation to observe the DesktopFrame returned by |base_capturer_|. -class CaptureResultDesktopCapturerWrapper - : public DesktopCapturerWrapper, - public DesktopCapturer::Callback { +class CaptureResultDesktopCapturerWrapper : public DesktopCapturerWrapper, + public DesktopCapturer::Callback { public: using Callback = DesktopCapturer::Callback; diff --git a/modules/desktop_capture/cropped_desktop_frame.h b/modules/desktop_capture/cropped_desktop_frame.h index f6cac6c7a2..59dced4017 100644 --- a/modules/desktop_capture/cropped_desktop_frame.h +++ b/modules/desktop_capture/cropped_desktop_frame.h @@ -27,4 +27,3 @@ std::unique_ptr CreateCroppedDesktopFrame( } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_CROPPED_DESKTOP_FRAME_H_ - diff --git a/modules/desktop_capture/cropped_desktop_frame_unittest.cc b/modules/desktop_capture/cropped_desktop_frame_unittest.cc index d15f207dea..fbd488fc99 100644 --- a/modules/desktop_capture/cropped_desktop_frame_unittest.cc +++ b/modules/desktop_capture/cropped_desktop_frame_unittest.cc @@ -32,15 +32,16 @@ TEST(CroppedDesktopFrameTest, DoNotCreateWrapperIfSizeIsNotChanged) { } TEST(CroppedDesktopFrameTest, ReturnNullptrIfSizeIsNotSufficient) { - ASSERT_EQ(nullptr, CreateCroppedDesktopFrame( - CreateTestFrame(), DesktopRect::MakeWH(11, 10))); + ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(CreateTestFrame(), + DesktopRect::MakeWH(11, 10))); } TEST(CroppedDesktopFrameTest, ReturnNullIfCropRegionIsOutOfBounds) { std::unique_ptr frame = CreateTestFrame(); frame->set_top_left(DesktopVector(100, 200)); - ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(std::move(frame), - DesktopRect::MakeLTRB(101, 203, 109, 218))); + ASSERT_EQ(nullptr, + CreateCroppedDesktopFrame( + std::move(frame), DesktopRect::MakeLTRB(101, 203, 109, 218))); } TEST(CroppedDesktopFrameTest, CropASubArea) { @@ -56,7 +57,7 @@ TEST(CroppedDesktopFrameTest, SetTopLeft) { std::unique_ptr frame = CreateTestFrame(); frame->set_top_left(DesktopVector(100, 200)); frame = CreateCroppedDesktopFrame(std::move(frame), - DesktopRect::MakeLTRB(1, 3, 9, 18)); + DesktopRect::MakeLTRB(1, 3, 9, 18)); ASSERT_EQ(frame->size().width(), 8); ASSERT_EQ(frame->size().height(), 15); ASSERT_EQ(frame->top_left().x(), 101); diff --git a/modules/desktop_capture/cropping_window_capturer.h b/modules/desktop_capture/cropping_window_capturer.h index 9fbfddaa81..c889801da3 100644 --- a/modules/desktop_capture/cropping_window_capturer.h +++ b/modules/desktop_capture/cropping_window_capturer.h @@ -13,8 +13,8 @@ #include -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" +#include "modules/desktop_capture/desktop_capturer.h" namespace webrtc { @@ -76,4 +76,3 @@ class CroppingWindowCapturer : public DesktopCapturer, } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_CROPPING_WINDOW_CAPTURER_H_ - diff --git a/modules/desktop_capture/cropping_window_capturer_win.cc b/modules/desktop_capture/cropping_window_capturer_win.cc index b08f4411a5..ae270a6717 100644 --- a/modules/desktop_capture/cropping_window_capturer_win.cc +++ b/modules/desktop_capture/cropping_window_capturer_win.cc @@ -147,8 +147,7 @@ BOOL CALLBACK TopWindowVerifier(HWND hwnd, LPARAM param) { class CroppingWindowCapturerWin : public CroppingWindowCapturer { public: - CroppingWindowCapturerWin( - const DesktopCaptureOptions& options) + CroppingWindowCapturerWin(const DesktopCaptureOptions& options) : CroppingWindowCapturer(options) {} private: @@ -216,8 +215,8 @@ bool CroppingWindowCapturerWin::ShouldUseScreenCapturer() { if (region_type == SIMPLEREGION) { // The |region_rect| returned from GetRgnBox() is always in window // coordinate. - region_rect.Translate( - window_region_rect_.left(), window_region_rect_.top()); + region_rect.Translate(window_region_rect_.left(), + window_region_rect_.top()); // MSDN: The window region determines the area *within* the window where the // system permits drawing. // https://msdn.microsoft.com/en-us/library/windows/desktop/dd144950(v=vs.85).aspx. diff --git a/modules/desktop_capture/desktop_and_cursor_composer.cc b/modules/desktop_capture/desktop_and_cursor_composer.cc index cad53f1adb..7656ba3c3d 100644 --- a/modules/desktop_capture/desktop_and_cursor_composer.cc +++ b/modules/desktop_capture/desktop_and_cursor_composer.cc @@ -28,8 +28,10 @@ namespace { // Helper function that blends one image into another. Source image must be // pre-multiplied with the alpha channel. Destination is assumed to be opaque. -void AlphaBlend(uint8_t* dest, int dest_stride, - const uint8_t* src, int src_stride, +void AlphaBlend(uint8_t* dest, + int dest_stride, + const uint8_t* src, + int src_stride, const DesktopSize& size) { for (int y = 0; y < size.height(); ++y) { for (int x = 0; x < size.width(); ++x) { @@ -111,8 +113,7 @@ DesktopFrameWithCursor::DesktopFrameWithCursor( cursor.image()->data() + origin_shift.y() * cursor.image()->stride() + origin_shift.x() * DesktopFrame::kBytesPerPixel, - cursor.image()->stride(), - target_rect.size()); + cursor.image()->stride(), target_rect.size()); } DesktopFrameWithCursor::~DesktopFrameWithCursor() { diff --git a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc index 9c3ab7bc81..c94a3cdd3b 100644 --- a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc +++ b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc @@ -11,8 +11,8 @@ #include #include "modules/desktop_capture/desktop_and_cursor_composer.h" -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/mouse_cursor.h" #include "modules/desktop_capture/shared_desktop_frame.h" @@ -30,9 +30,15 @@ const int kCursorHeight = 10; const int kTestCursorSize = 3; const uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = { - { 0xffffffff, 0x99990000, 0xaa222222, }, - { 0x88008800, 0xaa0000aa, 0xaa333333, }, - { 0x00000000, 0xaa0000aa, 0xaa333333, }, + { + 0xffffffff, 0x99990000, 0xaa222222, + }, + { + 0x88008800, 0xaa0000aa, 0xaa333333, + }, + { + 0x00000000, 0xaa0000aa, 0xaa333333, + }, }; uint32_t GetFakeFramePixelValue(const DesktopVector& p) { @@ -197,19 +203,11 @@ TEST_F(DesktopAndCursorComposerTest, CursorShouldBeIgnoredIfNoFrameCaptured) { int hotspot_x, hotspot_y; bool inside; } tests[] = { - {0, 0, 0, 0, true}, - {50, 50, 0, 0, true}, - {100, 50, 0, 0, true}, - {50, 100, 0, 0, true}, - {100, 100, 0, 0, true}, - {0, 0, 2, 5, true}, - {1, 1, 2, 5, true}, - {50, 50, 2, 5, true}, - {100, 100, 2, 5, true}, - {0, 0, 5, 2, true}, - {50, 50, 5, 2, true}, - {100, 100, 5, 2, true}, - {0, 0, 0, 0, false}, + {0, 0, 0, 0, true}, {50, 50, 0, 0, true}, {100, 50, 0, 0, true}, + {50, 100, 0, 0, true}, {100, 100, 0, 0, true}, {0, 0, 2, 5, true}, + {1, 1, 2, 5, true}, {50, 50, 2, 5, true}, {100, 100, 2, 5, true}, + {0, 0, 5, 2, true}, {50, 50, 5, 2, true}, {100, 100, 5, 2, true}, + {0, 0, 0, 0, false}, }; for (size_t i = 0; i < arraysize(tests); i++) { @@ -245,19 +243,9 @@ TEST_F(DesktopAndCursorComposerTest, int x; int y; } tests[] = { - { 0, 0 }, - { 50, 50 }, - { 50, 150 }, - { 100, 150 }, - { 50, 200 }, - { 99, 200 }, - { 100, 199 }, - { 200, 300 }, - { 200, 299 }, - { 199, 300 }, - { -1, -1 }, - { -10000, -10000 }, - { 10000, 10000 }, + {0, 0}, {50, 50}, {50, 150}, {100, 150}, {50, 200}, + {99, 200}, {100, 199}, {200, 300}, {200, 299}, {199, 300}, + {-1, -1}, {-10000, -10000}, {10000, 10000}, }; for (size_t i = 0; i < arraysize(tests); i++) { SCOPED_TRACE(i); @@ -281,12 +269,7 @@ TEST_F(DesktopAndCursorComposerTest, IsOccludedShouldBeConsidered) { int x; int y; } tests[] = { - { 100, 200 }, - { 101, 200 }, - { 100, 201 }, - { 101, 201 }, - { 150, 250 }, - { 199, 299 }, + {100, 200}, {101, 200}, {100, 201}, {101, 201}, {150, 250}, {199, 299}, }; fake_screen_->set_is_occluded(true); for (size_t i = 0; i < arraysize(tests); i++) { @@ -311,12 +294,7 @@ TEST_F(DesktopAndCursorComposerTest, CursorIncluded) { int x; int y; } tests[] = { - { 100, 200 }, - { 101, 200 }, - { 100, 201 }, - { 101, 201 }, - { 150, 250 }, - { 199, 299 }, + {100, 200}, {101, 200}, {100, 201}, {101, 201}, {150, 250}, {199, 299}, }; for (size_t i = 0; i < arraysize(tests); i++) { SCOPED_TRACE(i); diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h index a945d27264..60aa05c3fd 100644 --- a/modules/desktop_capture/desktop_capture_options.h +++ b/modules/desktop_capture/desktop_capture_options.h @@ -108,9 +108,7 @@ class DesktopCaptureOptions { } // Allowing directx based capturer or not, this capturer works on windows 7 // with platform update / windows 8 or upper. - bool allow_directx_capturer() const { - return allow_directx_capturer_; - } + bool allow_directx_capturer() const { return allow_directx_capturer_; } void set_allow_directx_capturer(bool enabled) { allow_directx_capturer_ = enabled; } diff --git a/modules/desktop_capture/desktop_capture_types.h b/modules/desktop_capture/desktop_capture_types.h index 5d6ab8a48c..f0a2bafa1f 100644 --- a/modules/desktop_capture/desktop_capture_types.h +++ b/modules/desktop_capture/desktop_capture_types.h @@ -41,17 +41,14 @@ const ScreenId kInvalidScreenId = -2; // An integer to attach to each DesktopFrame to differentiate the generator of // the frame. namespace DesktopCapturerId { - constexpr uint32_t CreateFourCC(char a, char b, char c, char d) { - return ((static_cast(a)) | - (static_cast(b) << 8) | - (static_cast(c) << 16) | - (static_cast(d) << 24)); - } +constexpr uint32_t CreateFourCC(char a, char b, char c, char d) { + return ((static_cast(a)) | (static_cast(b) << 8) | + (static_cast(c) << 16) | (static_cast(d) << 24)); +} - constexpr uint32_t kUnknown = 0; - constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' '); - constexpr uint32_t kScreenCapturerWinDirectx = - CreateFourCC('D', 'X', 'G', 'I'); +constexpr uint32_t kUnknown = 0; +constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' '); +constexpr uint32_t kScreenCapturerWinDirectx = CreateFourCC('D', 'X', 'G', 'I'); } // namespace DesktopCapturerId } // namespace webrtc diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h index 335427af23..47196cfe49 100644 --- a/modules/desktop_capture/desktop_capturer.h +++ b/modules/desktop_capture/desktop_capturer.h @@ -19,8 +19,8 @@ #include #include -#include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/desktop_capture_types.h" +#include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/shared_memory.h" namespace webrtc { @@ -152,4 +152,3 @@ class DesktopCapturer { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ - diff --git a/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc b/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc index 0a08088095..4721a14155 100644 --- a/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc +++ b/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc @@ -122,8 +122,8 @@ void ExecuteDifferWrapperCase(BlackWhiteDesktopFramePainter* frame_painter, OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_)) .Times(1) .WillOnce(testing::Invoke([&updated_region, check_result, exactly_match]( - DesktopCapturer::Result result, - std::unique_ptr* frame) { + DesktopCapturer::Result result, + std::unique_ptr* frame) { ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS); if (check_result) { if (exactly_match) { diff --git a/modules/desktop_capture/desktop_frame.cc b/modules/desktop_capture/desktop_frame.cc index 67f20090ef..1d315e2fff 100644 --- a/modules/desktop_capture/desktop_frame.cc +++ b/modules/desktop_capture/desktop_frame.cc @@ -36,7 +36,8 @@ DesktopFrame::DesktopFrame(DesktopSize size, DesktopFrame::~DesktopFrame() = default; -void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, int src_stride, +void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, + int src_stride, const DesktopRect& dest_rect) { RTC_CHECK(DesktopRect::MakeSize(size()).ContainsRect(dest_rect)); @@ -51,11 +52,12 @@ void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, int src_stride, void DesktopFrame::CopyPixelsFrom(const DesktopFrame& src_frame, const DesktopVector& src_pos, const DesktopRect& dest_rect) { - RTC_CHECK(DesktopRect::MakeSize(src_frame.size()).ContainsRect( - DesktopRect::MakeOriginSize(src_pos, dest_rect.size()))); + RTC_CHECK(DesktopRect::MakeSize(src_frame.size()) + .ContainsRect( + DesktopRect::MakeOriginSize(src_pos, dest_rect.size()))); - CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), - src_frame.stride(), dest_rect); + CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), src_frame.stride(), + dest_rect); } DesktopRect DesktopFrame::rect() const { @@ -94,7 +96,8 @@ void DesktopFrame::MoveFrameInfoFrom(DesktopFrame* other) { } BasicDesktopFrame::BasicDesktopFrame(DesktopSize size) - : DesktopFrame(size, kBytesPerPixel * size.width(), + : DesktopFrame(size, + kBytesPerPixel * size.width(), new uint8_t[kBytesPerPixel * size.width() * size.height()], nullptr) {} @@ -142,9 +145,7 @@ SharedMemoryDesktopFrame::SharedMemoryDesktopFrame( DesktopSize size, int stride, std::unique_ptr shared_memory) - : SharedMemoryDesktopFrame(size, - stride, - shared_memory.release()) {} + : SharedMemoryDesktopFrame(size, stride, shared_memory.release()) {} SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() { delete shared_memory_; diff --git a/modules/desktop_capture/desktop_frame.h b/modules/desktop_capture/desktop_frame.h index 421d4b4480..2a3b71e8a3 100644 --- a/modules/desktop_capture/desktop_frame.h +++ b/modules/desktop_capture/desktop_frame.h @@ -90,9 +90,7 @@ class DesktopFrame { // Not all DesktopCapturer implementations set this field; it's set to // kUnknown by default. uint32_t capturer_id() const { return capturer_id_; } - void set_capturer_id(uint32_t capturer_id) { - capturer_id_ = capturer_id; - } + void set_capturer_id(uint32_t capturer_id) { capturer_id_ = capturer_id; } // Copies various information from |other|. Anything initialized in // constructor are not copied. @@ -193,4 +191,3 @@ class SharedMemoryDesktopFrame : public DesktopFrame { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ - diff --git a/modules/desktop_capture/desktop_frame_rotation.cc b/modules/desktop_capture/desktop_frame_rotation.cc index 7cf0348e4c..d7ea48cf3d 100644 --- a/modules/desktop_capture/desktop_frame_rotation.cc +++ b/modules/desktop_capture/desktop_frame_rotation.cc @@ -12,8 +12,8 @@ #include -#include "third_party/libyuv/include/libyuv/rotate_argb.h" #include "rtc_base/checks.h" +#include "third_party/libyuv/include/libyuv/rotate_argb.h" namespace webrtc { @@ -109,10 +109,10 @@ void RotateDesktopFrame(const DesktopFrame& source, } int result = libyuv::ARGBRotate( - source.GetFrameDataAtPos(source_rect.top_left()), source.stride(), - target->GetFrameDataAtPos(target_rect.top_left()), target->stride(), - source_rect.width(), source_rect.height(), - ToLibyuvRotationMode(rotation)); + source.GetFrameDataAtPos(source_rect.top_left()), source.stride(), + target->GetFrameDataAtPos(target_rect.top_left()), target->stride(), + source_rect.width(), source_rect.height(), + ToLibyuvRotationMode(rotation)); RTC_DCHECK_EQ(result, 0); } diff --git a/modules/desktop_capture/desktop_frame_rotation_unittest.cc b/modules/desktop_capture/desktop_frame_rotation_unittest.cc index e31f47207a..acd6db184e 100644 --- a/modules/desktop_capture/desktop_frame_rotation_unittest.cc +++ b/modules/desktop_capture/desktop_frame_rotation_unittest.cc @@ -39,8 +39,8 @@ ArrayDesktopFrame::~ArrayDesktopFrame() = default; TEST(DesktopFrameRotationTest, CopyRect3x4) { // A DesktopFrame of 4-pixel width by 3-pixel height. static uint32_t frame_pixels[] = { - 0, 1, 2, 3, // - 4, 5, 6, 7, // + 0, 1, 2, 3, // + 4, 5, 6, 7, // 8, 9, 10, 11, // }; ArrayDesktopFrame frame(DesktopSize(4, 3), frame_pixels); @@ -55,8 +55,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) { // After Rotating clock-wise 90 degree { static uint32_t expected_pixels[] = { - 8, 4, 0, // - 9, 5, 1, // + 8, 4, 0, // + 9, 5, 1, // 10, 6, 2, // 11, 7, 3, // }; @@ -72,8 +72,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) { { static uint32_t expected_pixels[] = { 11, 10, 9, 8, // - 7, 6, 5, 4, // - 3, 2, 1, 0, // + 7, 6, 5, 4, // + 3, 2, 1, 0, // }; ArrayDesktopFrame expected(DesktopSize(4, 3), expected_pixels); @@ -88,8 +88,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) { static uint32_t expected_pixels[] = { 3, 7, 11, // 2, 6, 10, // - 1, 5, 9, // - 0, 4, 8, // + 1, 5, 9, // + 0, 4, 8, // }; ArrayDesktopFrame expected(DesktopSize(3, 4), expected_pixels); @@ -103,8 +103,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) { TEST(DesktopFrameRotationTest, CopyRect3x5) { // A DesktopFrame of 5-pixel width by 3-pixel height. static uint32_t frame_pixels[] = { - 0, 1, 2, 3, 4, // - 5, 6, 7, 8, 9, // + 0, 1, 2, 3, 4, // + 5, 6, 7, 8, 9, // 10, 11, 12, 13, 14, // }; ArrayDesktopFrame frame(DesktopSize(5, 3), frame_pixels); @@ -135,10 +135,10 @@ TEST(DesktopFrameRotationTest, CopyRect3x5) { // After Rotating clock-wise 180 degree { - static uint32_t expected_pixels[] { + static uint32_t expected_pixels[]{ 14, 13, 12, 11, 10, // - 9, 8, 7, 6, 5, // - 4, 3, 2, 1, 0, // + 9, 8, 7, 6, 5, // + 4, 3, 2, 1, 0, // }; ArrayDesktopFrame expected(DesktopSize(5, 3), expected_pixels); @@ -169,8 +169,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x5) { TEST(DesktopFrameRotationTest, PartialCopyRect3x5) { // A DesktopFrame of 5-pixel width by 3-pixel height. static uint32_t frame_pixels[] = { - 0, 1, 2, 3, 4, // - 5, 6, 7, 8, 9, // + 0, 1, 2, 3, 4, // + 5, 6, 7, 8, 9, // 10, 11, 12, 13, 14, // }; ArrayDesktopFrame frame(DesktopSize(5, 3), frame_pixels); @@ -225,11 +225,11 @@ TEST(DesktopFrameRotationTest, PartialCopyRect3x5) { { static uint32_t expected_pixels[] = { - 0, 0, 0, // + 0, 0, 0, // 11, 6, 0, // 12, 7, 0, // 13, 8, 0, // - 0, 0, 0, // + 0, 0, 0, // }; ArrayDesktopFrame expected(DesktopSize(3, 5), expected_pixels); @@ -259,8 +259,8 @@ TEST(DesktopFrameRotationTest, PartialCopyRect3x5) { { static uint32_t expected_pixels[] = { 0, 13, 12, 11, 0, // - 0, 8, 7, 6, 0, // - 0, 0, 0, 0, 0, // + 0, 8, 7, 6, 0, // + 0, 0, 0, 0, 0, // }; ArrayDesktopFrame expected(DesktopSize(5, 3), expected_pixels); @@ -310,20 +310,20 @@ TEST(DesktopFrameRotationTest, PartialCopyRect3x5) { TEST(DesktopFrameRotationTest, WithOffset) { // A DesktopFrame of 4-pixel width by 3-pixel height. static uint32_t frame_pixels[] = { - 0, 1, 2, 3, // - 4, 5, 6, 7, // + 0, 1, 2, 3, // + 4, 5, 6, 7, // 8, 9, 10, 11, // }; ArrayDesktopFrame frame(DesktopSize(4, 3), frame_pixels); { static uint32_t expected_pixels[] = { - 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 1, 2, 3, 0, 0, 0, // - 0, 4, 5, 6, 7, 0, 0, 0, // - 0, 8, 9, 10, 11, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, 0, 0, // + 0, 0, 1, 2, 3, 0, 0, 0, // + 0, 4, 5, 6, 7, 0, 0, 0, // + 0, 8, 9, 10, 11, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, 0, 0, // }; ArrayDesktopFrame expected(DesktopSize(8, 6), expected_pixels); @@ -339,12 +339,12 @@ TEST(DesktopFrameRotationTest, WithOffset) { { static uint32_t expected_pixels[] = { - 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 11, 10, 9, 8, 0, 0, 0, // - 0, 7, 6, 5, 4, 0, 0, 0, // - 0, 3, 2, 1, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, 0, 0, // + 0, 11, 10, 9, 8, 0, 0, 0, // + 0, 7, 6, 5, 4, 0, 0, 0, // + 0, 3, 2, 1, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, 0, 0, // }; ArrayDesktopFrame expected(DesktopSize(8, 6), expected_pixels); @@ -360,14 +360,14 @@ TEST(DesktopFrameRotationTest, WithOffset) { { static uint32_t expected_pixels[] = { - 0, 0, 0, 0, 0, 0, // - 0, 8, 4, 0, 0, 0, // - 0, 9, 5, 1, 0, 0, // - 0, 10, 6, 2, 0, 0, // - 0, 11, 7, 3, 0, 0, // - 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, // + 0, 8, 4, 0, 0, 0, // + 0, 9, 5, 1, 0, 0, // + 0, 10, 6, 2, 0, 0, // + 0, 11, 7, 3, 0, 0, // + 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, // }; ArrayDesktopFrame expected(DesktopSize(6, 8), expected_pixels); @@ -383,14 +383,14 @@ TEST(DesktopFrameRotationTest, WithOffset) { { static uint32_t expected_pixels[] = { - 0, 0, 0, 0, 0, 0, // - 0, 3, 7, 11, 0, 0, // - 0, 2, 6, 10, 0, 0, // - 0, 1, 5, 9, 0, 0, // - 0, 0, 4, 8, 0, 0, // - 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, // + 0, 3, 7, 11, 0, 0, // + 0, 2, 6, 10, 0, 0, // + 0, 1, 5, 9, 0, 0, // + 0, 0, 4, 8, 0, 0, // + 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, // + 0, 0, 0, 0, 0, 0, // }; ArrayDesktopFrame expected(DesktopSize(6, 8), expected_pixels); diff --git a/modules/desktop_capture/desktop_frame_win.cc b/modules/desktop_capture/desktop_frame_win.cc index fbc1200dd7..58ebac91d5 100644 --- a/modules/desktop_capture/desktop_frame_win.cc +++ b/modules/desktop_capture/desktop_frame_win.cc @@ -53,8 +53,8 @@ std::unique_ptr DesktopFrameWin::Create( section_handle = shared_memory->handle(); } void* data = nullptr; - HBITMAP bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data, - section_handle, 0); + HBITMAP bitmap = + CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data, section_handle, 0); if (!bitmap) { RTC_LOG(LS_WARNING) << "Failed to allocate new window frame " << GetLastError(); diff --git a/modules/desktop_capture/desktop_frame_win.h b/modules/desktop_capture/desktop_frame_win.h index 9ae1dc4d95..5cad867b14 100644 --- a/modules/desktop_capture/desktop_frame_win.h +++ b/modules/desktop_capture/desktop_frame_win.h @@ -48,4 +48,3 @@ class DesktopFrameWin : public DesktopFrame { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_WIN_H_ - diff --git a/modules/desktop_capture/desktop_geometry.cc b/modules/desktop_capture/desktop_geometry.cc index 8c1b23a006..8220e5f593 100644 --- a/modules/desktop_capture/desktop_geometry.cc +++ b/modules/desktop_capture/desktop_geometry.cc @@ -15,8 +15,8 @@ namespace webrtc { bool DesktopRect::Contains(const DesktopVector& point) const { - return point.x() >= left() && point.x() < right() && - point.y() >= top() && point.y() < bottom(); + return point.x() >= left() && point.x() < right() && point.y() >= top() && + point.y() < bottom(); } bool DesktopRect::ContainsRect(const DesktopRect& rect) const { @@ -76,4 +76,3 @@ void DesktopRect::Scale(double horizontal, double vertical) { } } // namespace webrtc - diff --git a/modules/desktop_capture/desktop_geometry.h b/modules/desktop_capture/desktop_geometry.h index c1ee1a539e..e01b435d6b 100644 --- a/modules/desktop_capture/desktop_geometry.h +++ b/modules/desktop_capture/desktop_geometry.h @@ -51,9 +51,7 @@ class DesktopVector { class DesktopSize { public: DesktopSize() : width_(0), height_(0) {} - DesktopSize(int32_t width, int32_t height) - : width_(width), height_(height) { - } + DesktopSize(int32_t width, int32_t height) : width_(width), height_(height) {} int32_t width() const { return width_; } int32_t height() const { return height_; } @@ -83,12 +81,16 @@ class DesktopRect { static DesktopRect MakeWH(int32_t width, int32_t height) { return DesktopRect(0, 0, width, height); } - static DesktopRect MakeXYWH(int32_t x, int32_t y, - int32_t width, int32_t height) { + static DesktopRect MakeXYWH(int32_t x, + int32_t y, + int32_t width, + int32_t height) { return DesktopRect(x, y, x + width, y + height); } - static DesktopRect MakeLTRB(int32_t left, int32_t top, - int32_t right, int32_t bottom) { + static DesktopRect MakeLTRB(int32_t left, + int32_t top, + int32_t right, + int32_t bottom) { return DesktopRect(left, top, right, bottom); } static DesktopRect MakeOriginSize(const DesktopVector& origin, @@ -115,7 +117,7 @@ class DesktopRect { bool equals(const DesktopRect& other) const { return left_ == other.left_ && top_ == other.top_ && - right_ == other.right_ && bottom_ == other.bottom_; + right_ == other.right_ && bottom_ == other.bottom_; } // Returns true if |point| lies within the rectangle boundaries. @@ -151,8 +153,7 @@ class DesktopRect { private: DesktopRect(int32_t left, int32_t top, int32_t right, int32_t bottom) - : left_(left), top_(top), right_(right), bottom_(bottom) { - } + : left_(left), top_(top), right_(right), bottom_(bottom) {} int32_t left_; int32_t top_; @@ -163,4 +164,3 @@ class DesktopRect { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_GEOMETRY_H_ - diff --git a/modules/desktop_capture/desktop_region.cc b/modules/desktop_capture/desktop_region.cc index fb310d43e5..472f815587 100644 --- a/modules/desktop_capture/desktop_region.cc +++ b/modules/desktop_capture/desktop_region.cc @@ -17,15 +17,13 @@ namespace webrtc { DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right) - : left(left), right(right) { -} + : left(left), right(right) {} DesktopRegion::Row::Row(const Row&) = default; DesktopRegion::Row::Row(Row&&) = default; DesktopRegion::Row::Row(int32_t top, int32_t bottom) - : top(top), bottom(bottom) { -} + : top(top), bottom(bottom) {} DesktopRegion::Row::~Row() {} @@ -63,8 +61,7 @@ bool DesktopRegion::Equals(const DesktopRegion& region) const { Rows::const_iterator it1 = rows_.begin(); Rows::const_iterator it2 = region.rows_.begin(); while (it1 != rows_.end()) { - if (it2 == region.rows_.end() || - it1->first != it2->first || + if (it2 == region.rows_.end() || it1->first != it2->first || it1->second->top != it2->second->top || it1->second->bottom != it2->second->bottom || it1->second->spans != it2->second->spans) { @@ -100,14 +97,13 @@ void DesktopRegion::AddRect(const DesktopRect& rect) { // necessary. Rows::iterator row = rows_.upper_bound(top); while (top < rect.bottom()) { - if (row == rows_.end() || top < row->second->top) { + if (row == rows_.end() || top < row->second->top) { // If |top| is above the top of the current |row| then add a new row above // the current one. int32_t bottom = rect.bottom(); if (row != rows_.end() && row->second->top < bottom) bottom = row->second->top; - row = rows_.insert( - row, Rows::value_type(bottom, new Row(top, bottom))); + row = rows_.insert(row, Rows::value_type(bottom, new Row(top, bottom))); } else if (top > row->second->top) { // If the |top| falls in the middle of the |row| then split |row| into // two, at |top|, and leave |row| referring to the lower of the two, @@ -421,9 +417,8 @@ void DesktopRegion::AddSpanToRow(Row* row, int left, int right) { } // Find the first span that ends at or after |left|. - RowSpanSet::iterator start = - std::lower_bound(row->spans.begin(), row->spans.end(), left, - CompareSpanRight); + RowSpanSet::iterator start = std::lower_bound( + row->spans.begin(), row->spans.end(), left, CompareSpanRight); assert(start < row->spans.end()); // Find the first span that starts after |right|. @@ -462,9 +457,8 @@ void DesktopRegion::AddSpanToRow(Row* row, int left, int right) { bool DesktopRegion::IsSpanInRow(const Row& row, const RowSpan& span) { // Find the first span that starts at or after |span.left| and then check if // it's the same span. - RowSpanSet::const_iterator it = - std::lower_bound(row.spans.begin(), row.spans.end(), span.left, - CompareSpanLeft); + RowSpanSet::const_iterator it = std::lower_bound( + row.spans.begin(), row.spans.end(), span.left, CompareSpanLeft); return it != row.spans.end() && *it == span; } diff --git a/modules/desktop_capture/desktop_region.h b/modules/desktop_capture/desktop_region.h index 93f78a4c0c..305f877e9e 100644 --- a/modules/desktop_capture/desktop_region.h +++ b/modules/desktop_capture/desktop_region.h @@ -166,4 +166,3 @@ class DesktopRegion { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_REGION_H_ - diff --git a/modules/desktop_capture/desktop_region_unittest.cc b/modules/desktop_capture/desktop_region_unittest.cc index 0e94c9dee8..65fc42fd5d 100644 --- a/modules/desktop_capture/desktop_region_unittest.cc +++ b/modules/desktop_capture/desktop_region_unittest.cc @@ -23,7 +23,8 @@ int RadmonInt(int max) { } void CompareRegion(const DesktopRegion& region, - const DesktopRect rects[], int rects_size) { + const DesktopRect rects[], + int rects_size) { DesktopRegion::Iterator it(region); for (int i = 0; i < rects_size; ++i) { SCOPED_TRACE(i); @@ -31,8 +32,8 @@ void CompareRegion(const DesktopRegion& region, EXPECT_TRUE(it.rect().equals(rects[i])) << it.rect().left() << "-" << it.rect().right() << "." << it.rect().top() << "-" << it.rect().bottom() << " " - << rects[i].left() << "-" << rects[i].right() << "." - << rects[i].top() << "-" << rects[i].bottom(); + << rects[i].left() << "-" << rects[i].right() << "." << rects[i].top() + << "-" << rects[i].bottom(); it.Advance(); } EXPECT_TRUE(it.IsAtEnd()); @@ -68,22 +69,27 @@ TEST(DesktopRegionTest, NonOverlappingRects) { int count; DesktopRect rects[4]; } cases[] = { - { 1, { DesktopRect::MakeXYWH(10, 10, 10, 10) } }, - { 2, { DesktopRect::MakeXYWH(10, 10, 10, 10), - DesktopRect::MakeXYWH(30, 10, 10, 15) } }, - { 2, { DesktopRect::MakeXYWH(10, 10, 10, 10), - DesktopRect::MakeXYWH(10, 30, 10, 5) } }, - { 3, { DesktopRect::MakeXYWH(10, 10, 10, 9), - DesktopRect::MakeXYWH(30, 10, 15, 10), - DesktopRect::MakeXYWH(10, 30, 8, 10) } }, - { 4, { DesktopRect::MakeXYWH(0, 0, 30, 10), - DesktopRect::MakeXYWH(40, 0, 10, 30), - DesktopRect::MakeXYWH(0, 20, 10, 30), - DesktopRect::MakeXYWH(20, 40, 30, 10) } }, - { 4, { DesktopRect::MakeXYWH(0, 0, 10, 100), - DesktopRect::MakeXYWH(20, 10, 30, 10), - DesktopRect::MakeXYWH(20, 30, 30, 10), - DesktopRect::MakeXYWH(20, 50, 30, 10) } }, + {1, {DesktopRect::MakeXYWH(10, 10, 10, 10)}}, + {2, + {DesktopRect::MakeXYWH(10, 10, 10, 10), + DesktopRect::MakeXYWH(30, 10, 10, 15)}}, + {2, + {DesktopRect::MakeXYWH(10, 10, 10, 10), + DesktopRect::MakeXYWH(10, 30, 10, 5)}}, + {3, + {DesktopRect::MakeXYWH(10, 10, 10, 9), + DesktopRect::MakeXYWH(30, 10, 15, 10), + DesktopRect::MakeXYWH(10, 30, 8, 10)}}, + {4, + {DesktopRect::MakeXYWH(0, 0, 30, 10), + DesktopRect::MakeXYWH(40, 0, 10, 30), + DesktopRect::MakeXYWH(0, 20, 10, 30), + DesktopRect::MakeXYWH(20, 40, 30, 10)}}, + {4, + {DesktopRect::MakeXYWH(0, 0, 10, 100), + DesktopRect::MakeXYWH(20, 10, 30, 10), + DesktopRect::MakeXYWH(20, 30, 30, 10), + DesktopRect::MakeXYWH(20, 50, 30, 10)}}, }; for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) { @@ -114,81 +120,97 @@ TEST(DesktopRegionTest, TwoRects) { int expected_count; DesktopRect expected_rects[3]; } cases[] = { - // Touching rectangles that merge into one. - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(0, 100, 100, 200), - 1, { DesktopRect::MakeLTRB(0, 100, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(100, 0, 200, 100), - 1, { DesktopRect::MakeLTRB(100, 0, 200, 200) } }, + // Touching rectangles that merge into one. + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(0, 100, 100, 200), + 1, + {DesktopRect::MakeLTRB(0, 100, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(100, 0, 200, 100), + 1, + {DesktopRect::MakeLTRB(100, 0, 200, 200)}}, - // Rectangles touching on the vertical edge. - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(0, 150, 100, 250), - 3, { DesktopRect::MakeLTRB(100, 100, 200, 150), - DesktopRect::MakeLTRB(0, 150, 200, 200), - DesktopRect::MakeLTRB(0, 200, 100, 250) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(0, 50, 100, 150), - 3, { DesktopRect::MakeLTRB(0, 50, 100, 100), - DesktopRect::MakeLTRB(0, 100, 200, 150), - DesktopRect::MakeLTRB(100, 150, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(0, 120, 100, 180), - 3, { DesktopRect::MakeLTRB(100, 100, 200, 120), - DesktopRect::MakeLTRB(0, 120, 200, 180), - DesktopRect::MakeLTRB(100, 180, 200, 200) } }, + // Rectangles touching on the vertical edge. + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(0, 150, 100, 250), + 3, + {DesktopRect::MakeLTRB(100, 100, 200, 150), + DesktopRect::MakeLTRB(0, 150, 200, 200), + DesktopRect::MakeLTRB(0, 200, 100, 250)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(0, 50, 100, 150), + 3, + {DesktopRect::MakeLTRB(0, 50, 100, 100), + DesktopRect::MakeLTRB(0, 100, 200, 150), + DesktopRect::MakeLTRB(100, 150, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(0, 120, 100, 180), + 3, + {DesktopRect::MakeLTRB(100, 100, 200, 120), + DesktopRect::MakeLTRB(0, 120, 200, 180), + DesktopRect::MakeLTRB(100, 180, 200, 200)}}, - // Rectangles touching on the horizontal edge. - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(150, 0, 250, 100), - 2, { DesktopRect::MakeLTRB(150, 0, 250, 100), - DesktopRect::MakeLTRB(100, 100, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(50, 0, 150, 100), - 2, { DesktopRect::MakeLTRB(50, 0, 150, 100), - DesktopRect::MakeLTRB(100, 100, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(120, 0, 180, 100), - 2, { DesktopRect::MakeLTRB(120, 0, 180, 100), - DesktopRect::MakeLTRB(100, 100, 200, 200) } }, + // Rectangles touching on the horizontal edge. + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(150, 0, 250, 100), + 2, + {DesktopRect::MakeLTRB(150, 0, 250, 100), + DesktopRect::MakeLTRB(100, 100, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(50, 0, 150, 100), + 2, + {DesktopRect::MakeLTRB(50, 0, 150, 100), + DesktopRect::MakeLTRB(100, 100, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(120, 0, 180, 100), + 2, + {DesktopRect::MakeLTRB(120, 0, 180, 100), + DesktopRect::MakeLTRB(100, 100, 200, 200)}}, - // Overlapping rectangles. - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(50, 50, 150, 150), - 3, { DesktopRect::MakeLTRB(50, 50, 150, 100), - DesktopRect::MakeLTRB(50, 100, 200, 150), - DesktopRect::MakeLTRB(100, 150, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(150, 50, 250, 150), - 3, { DesktopRect::MakeLTRB(150, 50, 250, 100), - DesktopRect::MakeLTRB(100, 100, 250, 150), - DesktopRect::MakeLTRB(100, 150, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(0, 120, 150, 180), - 3, { DesktopRect::MakeLTRB(100, 100, 200, 120), - DesktopRect::MakeLTRB(0, 120, 200, 180), - DesktopRect::MakeLTRB(100, 180, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(120, 0, 180, 150), - 2, { DesktopRect::MakeLTRB(120, 0, 180, 100), - DesktopRect::MakeLTRB(100, 100, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 0, 200, 300), - DesktopRect::MakeLTRB(0, 100, 300, 200), - 3, { DesktopRect::MakeLTRB(100, 0, 200, 100), - DesktopRect::MakeLTRB(0, 100, 300, 200), - DesktopRect::MakeLTRB(100, 200, 200, 300)} }, + // Overlapping rectangles. + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(50, 50, 150, 150), + 3, + {DesktopRect::MakeLTRB(50, 50, 150, 100), + DesktopRect::MakeLTRB(50, 100, 200, 150), + DesktopRect::MakeLTRB(100, 150, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(150, 50, 250, 150), + 3, + {DesktopRect::MakeLTRB(150, 50, 250, 100), + DesktopRect::MakeLTRB(100, 100, 250, 150), + DesktopRect::MakeLTRB(100, 150, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(0, 120, 150, 180), + 3, + {DesktopRect::MakeLTRB(100, 100, 200, 120), + DesktopRect::MakeLTRB(0, 120, 200, 180), + DesktopRect::MakeLTRB(100, 180, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(120, 0, 180, 150), + 2, + {DesktopRect::MakeLTRB(120, 0, 180, 100), + DesktopRect::MakeLTRB(100, 100, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 0, 200, 300), + DesktopRect::MakeLTRB(0, 100, 300, 200), + 3, + {DesktopRect::MakeLTRB(100, 0, 200, 100), + DesktopRect::MakeLTRB(0, 100, 300, 200), + DesktopRect::MakeLTRB(100, 200, 200, 300)}}, - // One rectangle enclosing another. - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(150, 150, 180, 180), - 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(100, 100, 180, 180), - 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } }, - { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(150, 150, 200, 200), - 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } }, + // One rectangle enclosing another. + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(150, 150, 180, 180), + 1, + {DesktopRect::MakeLTRB(100, 100, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(100, 100, 180, 180), + 1, + {DesktopRect::MakeLTRB(100, 100, 200, 200)}}, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(150, 150, 200, 200), + 1, + {DesktopRect::MakeLTRB(100, 100, 200, 200)}}, }; for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) { @@ -219,7 +241,9 @@ TEST(DesktopRegionTest, SameRow) { const int kLastRectSizes[] = {3, 27}; DesktopRegion base_region; - bool base_map[kMapWidth] = { false, }; + bool base_map[kMapWidth] = { + false, + }; base_region.AddRect(DesktopRect::MakeXYWH(5, 0, 5, 1)); std::fill_n(base_map + 5, 5, true); @@ -239,13 +263,15 @@ TEST(DesktopRegionTest, SameRow) { SCOPED_TRACE(x); DesktopRegion r = base_region; - r.AddRect(DesktopRect::MakeXYWH(x, 0, last_rect_size, 1)); + r.AddRect(DesktopRect::MakeXYWH(x, 0, last_rect_size, 1)); bool expected_map[kMapWidth]; std::copy(base_map, base_map + kMapWidth, expected_map); std::fill_n(expected_map + x, last_rect_size, true); - bool map[kMapWidth] = { false, }; + bool map[kMapWidth] = { + false, + }; int pos = -1; for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) { @@ -266,32 +292,42 @@ TEST(DesktopRegionTest, ComplexRegions) { int expected_count; DesktopRect expected_rects[6]; } cases[] = { - { 3, { DesktopRect::MakeLTRB(100, 100, 200, 200), + {3, + { + DesktopRect::MakeLTRB(100, 100, 200, 200), DesktopRect::MakeLTRB(0, 100, 100, 200), - DesktopRect::MakeLTRB(310, 110, 320, 120), }, - 2, { DesktopRect::MakeLTRB(0, 100, 200, 200), - DesktopRect::MakeLTRB(310, 110, 320, 120) } }, - { 3, { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(50, 50, 150, 150), - DesktopRect::MakeLTRB(300, 125, 350, 175) }, - 4, { DesktopRect::MakeLTRB(50, 50, 150, 100), - DesktopRect::MakeLTRB(50, 100, 200, 150), - DesktopRect::MakeLTRB(300, 125, 350, 175), - DesktopRect::MakeLTRB(100, 150, 200, 200) } }, - { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30), - DesktopRect::MakeLTRB(10, 10, 40, 40), - DesktopRect::MakeLTRB(20, 20, 50, 50), - DesktopRect::MakeLTRB(50, 0, 65, 15) }, - 6, { DesktopRect::MakeLTRB(0, 0, 30, 10), - DesktopRect::MakeLTRB(50, 0, 65, 15), - DesktopRect::MakeLTRB(0, 10, 40, 20), - DesktopRect::MakeLTRB(0, 20, 50, 30), - DesktopRect::MakeLTRB(10, 30, 50, 40), - DesktopRect::MakeLTRB(20, 40, 50, 50) } }, - { 3, { DesktopRect::MakeLTRB(10, 10, 40, 20), - DesktopRect::MakeLTRB(10, 30, 40, 40), - DesktopRect::MakeLTRB(10, 20, 40, 30) }, - 1, { DesktopRect::MakeLTRB(10, 10, 40, 40) } }, + DesktopRect::MakeLTRB(310, 110, 320, 120), + }, + 2, + {DesktopRect::MakeLTRB(0, 100, 200, 200), + DesktopRect::MakeLTRB(310, 110, 320, 120)}}, + {3, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(50, 50, 150, 150), + DesktopRect::MakeLTRB(300, 125, 350, 175)}, + 4, + {DesktopRect::MakeLTRB(50, 50, 150, 100), + DesktopRect::MakeLTRB(50, 100, 200, 150), + DesktopRect::MakeLTRB(300, 125, 350, 175), + DesktopRect::MakeLTRB(100, 150, 200, 200)}}, + {4, + {DesktopRect::MakeLTRB(0, 0, 30, 30), + DesktopRect::MakeLTRB(10, 10, 40, 40), + DesktopRect::MakeLTRB(20, 20, 50, 50), + DesktopRect::MakeLTRB(50, 0, 65, 15)}, + 6, + {DesktopRect::MakeLTRB(0, 0, 30, 10), + DesktopRect::MakeLTRB(50, 0, 65, 15), + DesktopRect::MakeLTRB(0, 10, 40, 20), + DesktopRect::MakeLTRB(0, 20, 50, 30), + DesktopRect::MakeLTRB(10, 30, 50, 40), + DesktopRect::MakeLTRB(20, 40, 50, 50)}}, + {3, + {DesktopRect::MakeLTRB(10, 10, 40, 20), + DesktopRect::MakeLTRB(10, 30, 40, 40), + DesktopRect::MakeLTRB(10, 20, 40, 30)}, + 1, + {DesktopRect::MakeLTRB(10, 10, 40, 40)}}, }; for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) { @@ -316,44 +352,62 @@ TEST(DesktopRegionTest, Equals) { DesktopRect rects[4]; int id; } regions[] = { - // Same region with one of the rectangles 1 pixel wider/taller. - { 2, { DesktopRect::MakeLTRB(0, 100, 200, 200), - DesktopRect::MakeLTRB(310, 110, 320, 120) }, 0 }, - { 2, { DesktopRect::MakeLTRB(0, 100, 201, 200), - DesktopRect::MakeLTRB(310, 110, 320, 120) }, 1 }, - { 2, { DesktopRect::MakeLTRB(0, 100, 200, 201), - DesktopRect::MakeLTRB(310, 110, 320, 120) }, 2 }, + // Same region with one of the rectangles 1 pixel wider/taller. + {2, + {DesktopRect::MakeLTRB(0, 100, 200, 200), + DesktopRect::MakeLTRB(310, 110, 320, 120)}, + 0}, + {2, + {DesktopRect::MakeLTRB(0, 100, 201, 200), + DesktopRect::MakeLTRB(310, 110, 320, 120)}, + 1}, + {2, + {DesktopRect::MakeLTRB(0, 100, 200, 201), + DesktopRect::MakeLTRB(310, 110, 320, 120)}, + 2}, - // Same region with one of the rectangles shifted horizontally and - // vertically. - { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30), - DesktopRect::MakeLTRB(10, 10, 40, 40), - DesktopRect::MakeLTRB(20, 20, 50, 50), - DesktopRect::MakeLTRB(50, 0, 65, 15) }, 3 }, - { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30), - DesktopRect::MakeLTRB(10, 10, 40, 40), - DesktopRect::MakeLTRB(20, 20, 50, 50), - DesktopRect::MakeLTRB(50, 1, 65, 16) }, 4 }, - { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30), - DesktopRect::MakeLTRB(10, 10, 40, 40), - DesktopRect::MakeLTRB(20, 20, 50, 50), - DesktopRect::MakeLTRB(51, 0, 66, 15) }, 5 }, + // Same region with one of the rectangles shifted horizontally and + // vertically. + {4, + {DesktopRect::MakeLTRB(0, 0, 30, 30), + DesktopRect::MakeLTRB(10, 10, 40, 40), + DesktopRect::MakeLTRB(20, 20, 50, 50), + DesktopRect::MakeLTRB(50, 0, 65, 15)}, + 3}, + {4, + {DesktopRect::MakeLTRB(0, 0, 30, 30), + DesktopRect::MakeLTRB(10, 10, 40, 40), + DesktopRect::MakeLTRB(20, 20, 50, 50), + DesktopRect::MakeLTRB(50, 1, 65, 16)}, + 4}, + {4, + {DesktopRect::MakeLTRB(0, 0, 30, 30), + DesktopRect::MakeLTRB(10, 10, 40, 40), + DesktopRect::MakeLTRB(20, 20, 50, 50), + DesktopRect::MakeLTRB(51, 0, 66, 15)}, + 5}, - // Same region defined by a different set of rectangles - one of the - // rectangle is split horizontally into two. - { 3, { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(50, 50, 150, 150), - DesktopRect::MakeLTRB(300, 125, 350, 175) }, 6 }, - { 4, { DesktopRect::MakeLTRB(100, 100, 200, 200), - DesktopRect::MakeLTRB(50, 50, 100, 150), - DesktopRect::MakeLTRB(100, 50, 150, 150), - DesktopRect::MakeLTRB(300, 125, 350, 175) }, 6 }, + // Same region defined by a different set of rectangles - one of the + // rectangle is split horizontally into two. + {3, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(50, 50, 150, 150), + DesktopRect::MakeLTRB(300, 125, 350, 175)}, + 6}, + {4, + {DesktopRect::MakeLTRB(100, 100, 200, 200), + DesktopRect::MakeLTRB(50, 50, 100, 150), + DesktopRect::MakeLTRB(100, 50, 150, 150), + DesktopRect::MakeLTRB(300, 125, 350, 175)}, + 6}, - // Rectangle region defined by a set of rectangles that merge into one. - { 3, { DesktopRect::MakeLTRB(10, 10, 40, 20), - DesktopRect::MakeLTRB(10, 30, 40, 40), - DesktopRect::MakeLTRB(10, 20, 40, 30) }, 7 }, - { 1, { DesktopRect::MakeLTRB(10, 10, 40, 40) }, 7 }, + // Rectangle region defined by a set of rectangles that merge into one. + {3, + {DesktopRect::MakeLTRB(10, 10, 40, 20), + DesktopRect::MakeLTRB(10, 30, 40, 40), + DesktopRect::MakeLTRB(10, 20, 40, 30)}, + 7}, + {1, {DesktopRect::MakeLTRB(10, 10, 40, 40)}, 7}, }; int kTotalRegions = sizeof(regions) / sizeof(Region); @@ -379,15 +433,18 @@ TEST(DesktopRegionTest, Translate) { int expected_count; DesktopRect expected_rects[5]; } cases[] = { - { 3, { DesktopRect::MakeLTRB(0, 0, 30, 30), - DesktopRect::MakeLTRB(10, 10, 40, 40), - DesktopRect::MakeLTRB(20, 20, 50, 50) }, - 3, 5, - 5, { DesktopRect::MakeLTRB(3, 5, 33, 15), - DesktopRect::MakeLTRB(3, 15, 43, 25), - DesktopRect::MakeLTRB(3, 25, 53, 35), - DesktopRect::MakeLTRB(13, 35, 53, 45), - DesktopRect::MakeLTRB(23, 45, 53, 55) } }, + {3, + {DesktopRect::MakeLTRB(0, 0, 30, 30), + DesktopRect::MakeLTRB(10, 10, 40, 40), + DesktopRect::MakeLTRB(20, 20, 50, 50)}, + 3, + 5, + 5, + {DesktopRect::MakeLTRB(3, 5, 33, 15), + DesktopRect::MakeLTRB(3, 15, 43, 25), + DesktopRect::MakeLTRB(3, 25, 53, 35), + DesktopRect::MakeLTRB(13, 35, 53, 45), + DesktopRect::MakeLTRB(23, 45, 53, 55)}}, }; for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) { @@ -408,27 +465,42 @@ TEST(DesktopRegionTest, Intersect) { int expected_count; DesktopRect expected_rects[5]; } cases[] = { - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(50, 50, 150, 150) }, - 1, { DesktopRect::MakeLTRB(50, 50, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(50, 50, 150, 150)}, + 1, + {DesktopRect::MakeLTRB(50, 50, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(100, 0, 200, 300) }, - 1, { DesktopRect::MakeLTRB(0, 100, 300, 200) }, - 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } }, + {1, + {DesktopRect::MakeLTRB(100, 0, 200, 300)}, + 1, + {DesktopRect::MakeLTRB(0, 100, 300, 200)}, + 1, + {DesktopRect::MakeLTRB(100, 100, 200, 200)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 2, { DesktopRect::MakeLTRB(50, 10, 150, 30), - DesktopRect::MakeLTRB(50, 30, 160, 50) }, - 1, { DesktopRect::MakeLTRB(50, 10, 100, 50) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 2, + {DesktopRect::MakeLTRB(50, 10, 150, 30), + DesktopRect::MakeLTRB(50, 30, 160, 50)}, + 1, + {DesktopRect::MakeLTRB(50, 10, 100, 50)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 2, { DesktopRect::MakeLTRB(50, 10, 150, 30), - DesktopRect::MakeLTRB(50, 30, 90, 50) }, - 2, { DesktopRect::MakeLTRB(50, 10, 100, 30), - DesktopRect::MakeLTRB(50, 30, 90, 50) } }, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(100, 50, 200, 200) }, - 0, {} }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 2, + {DesktopRect::MakeLTRB(50, 10, 150, 30), + DesktopRect::MakeLTRB(50, 30, 90, 50)}, + 2, + {DesktopRect::MakeLTRB(50, 10, 100, 30), + DesktopRect::MakeLTRB(50, 30, 90, 50)}}, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(100, 50, 200, 200)}, + 0, + {}}, }; for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) { @@ -453,81 +525,123 @@ TEST(DesktopRegionTest, Subtract) { int expected_count; DesktopRect expected_rects[5]; } cases[] = { - // Subtract one rect from another. - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(50, 50, 150, 150) }, - 2, { DesktopRect::MakeLTRB(0, 0, 100, 50), - DesktopRect::MakeLTRB(0, 50, 50, 100) } }, + // Subtract one rect from another. + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(50, 50, 150, 150)}, + 2, + {DesktopRect::MakeLTRB(0, 0, 100, 50), + DesktopRect::MakeLTRB(0, 50, 50, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(-50, -50, 50, 50) }, - 2, { DesktopRect::MakeLTRB(50, 0, 100, 50), - DesktopRect::MakeLTRB(0, 50, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(-50, -50, 50, 50)}, + 2, + {DesktopRect::MakeLTRB(50, 0, 100, 50), + DesktopRect::MakeLTRB(0, 50, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(-50, 50, 50, 150) }, - 2, { DesktopRect::MakeLTRB(0, 0, 100, 50), - DesktopRect::MakeLTRB(50, 50, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(-50, 50, 50, 150)}, + 2, + {DesktopRect::MakeLTRB(0, 0, 100, 50), + DesktopRect::MakeLTRB(50, 50, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(50, 50, 150, 70) }, - 3, { DesktopRect::MakeLTRB(0, 0, 100, 50), - DesktopRect::MakeLTRB(0, 50, 50, 70), - DesktopRect::MakeLTRB(0, 70, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(50, 50, 150, 70)}, + 3, + {DesktopRect::MakeLTRB(0, 0, 100, 50), + DesktopRect::MakeLTRB(0, 50, 50, 70), + DesktopRect::MakeLTRB(0, 70, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(50, 50, 70, 70) }, - 4, { DesktopRect::MakeLTRB(0, 0, 100, 50), - DesktopRect::MakeLTRB(0, 50, 50, 70), - DesktopRect::MakeLTRB(70, 50, 100, 70), - DesktopRect::MakeLTRB(0, 70, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(50, 50, 70, 70)}, + 4, + {DesktopRect::MakeLTRB(0, 0, 100, 50), + DesktopRect::MakeLTRB(0, 50, 50, 70), + DesktopRect::MakeLTRB(70, 50, 100, 70), + DesktopRect::MakeLTRB(0, 70, 100, 100)}}, - // Empty result. - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 0, {} }, + // Empty result. + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 0, + {}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(-10, -10, 110, 110) }, - 0, {} }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(-10, -10, 110, 110)}, + 0, + {}}, - { 2, { DesktopRect::MakeLTRB(0, 0, 100, 100), - DesktopRect::MakeLTRB(50, 50, 150, 150) }, - 2, { DesktopRect::MakeLTRB(0, 0, 100, 100), - DesktopRect::MakeLTRB(50, 50, 150, 150) }, - 0, {} }, + {2, + {DesktopRect::MakeLTRB(0, 0, 100, 100), + DesktopRect::MakeLTRB(50, 50, 150, 150)}, + 2, + {DesktopRect::MakeLTRB(0, 0, 100, 100), + DesktopRect::MakeLTRB(50, 50, 150, 150)}, + 0, + {}}, - // One rect out of disjoint set. - { 3, { DesktopRect::MakeLTRB(0, 0, 10, 10), - DesktopRect::MakeLTRB(20, 20, 30, 30), - DesktopRect::MakeLTRB(40, 0, 50, 10) }, - 1, { DesktopRect::MakeLTRB(20, 20, 30, 30) }, - 2, { DesktopRect::MakeLTRB(0, 0, 10, 10), - DesktopRect::MakeLTRB(40, 0, 50, 10) } }, + // One rect out of disjoint set. + {3, + {DesktopRect::MakeLTRB(0, 0, 10, 10), + DesktopRect::MakeLTRB(20, 20, 30, 30), + DesktopRect::MakeLTRB(40, 0, 50, 10)}, + 1, + {DesktopRect::MakeLTRB(20, 20, 30, 30)}, + 2, + {DesktopRect::MakeLTRB(0, 0, 10, 10), + DesktopRect::MakeLTRB(40, 0, 50, 10)}}, - // Row merging. - { 3, { DesktopRect::MakeLTRB(0, 0, 100, 50), - DesktopRect::MakeLTRB(0, 50, 150, 70), - DesktopRect::MakeLTRB(0, 70, 100, 100) }, - 1, { DesktopRect::MakeLTRB(100, 50, 150, 70) }, - 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } }, + // Row merging. + {3, + {DesktopRect::MakeLTRB(0, 0, 100, 50), + DesktopRect::MakeLTRB(0, 50, 150, 70), + DesktopRect::MakeLTRB(0, 70, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(100, 50, 150, 70)}, + 1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}}, - // No-op subtraction. - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(100, 0, 200, 100) }, - 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } }, + // No-op subtraction. + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(100, 0, 200, 100)}, + 1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(-100, 0, 0, 100) }, - 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(-100, 0, 0, 100)}, + 1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(0, 100, 0, 200) }, - 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(0, 100, 0, 200)}, + 1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}}, - { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) }, - 1, { DesktopRect::MakeLTRB(0, -100, 100, 0) }, - 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } }, + {1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}, + 1, + {DesktopRect::MakeLTRB(0, -100, 100, 0)}, + 1, + {DesktopRect::MakeLTRB(0, 0, 100, 100)}}, }; for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) { @@ -552,19 +666,21 @@ TEST(DesktopRegionTest, SubtractRectOnSameRow) { struct SpanSet { int count; struct Range { - int start; - int end; + int start; + int end; } spans[3]; } span_sets[] = { - {1, { {0, 3} } }, - {1, { {0, 5} } }, - {1, { {0, 7} } }, - {1, { {0, 12} } }, - {2, { {0, 3}, {4, 5}, {6, 16} } }, + {1, {{0, 3}}}, + {1, {{0, 5}}}, + {1, {{0, 7}}}, + {1, {{0, 12}}}, + {2, {{0, 3}, {4, 5}, {6, 16}}}, }; DesktopRegion base_region; - bool base_map[kMapWidth] = { false, }; + bool base_map[kMapWidth] = { + false, + }; base_region.AddRect(DesktopRect::MakeXYWH(5, 0, 5, 1)); std::fill_n(base_map + 5, 5, true); @@ -599,7 +715,9 @@ TEST(DesktopRegionTest, SubtractRectOnSameRow) { } r.Subtract(region2); - bool map[kMapWidth] = { false, }; + bool map[kMapWidth] = { + false, + }; int pos = -1; for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) { @@ -623,19 +741,21 @@ TEST(DesktopRegionTest, SubtractRectOnSameCol) { struct SpanSet { int count; struct Range { - int start; - int end; + int start; + int end; } spans[3]; } span_sets[] = { - {1, { {0, 3} } }, - {1, { {0, 5} } }, - {1, { {0, 7} } }, - {1, { {0, 12} } }, - {2, { {0, 3}, {4, 5}, {6, 16} } }, + {1, {{0, 3}}}, + {1, {{0, 5}}}, + {1, {{0, 7}}}, + {1, {{0, 12}}}, + {2, {{0, 3}, {4, 5}, {6, 16}}}, }; DesktopRegion base_region; - bool base_map[kMapHeight] = { false, }; + bool base_map[kMapHeight] = { + false, + }; base_region.AddRect(DesktopRect::MakeXYWH(0, 5, 1, 5)); std::fill_n(base_map + 5, 5, true); @@ -670,7 +790,9 @@ TEST(DesktopRegionTest, SubtractRectOnSameCol) { } r.Subtract(region2); - bool map[kMapHeight] = { false, }; + bool map[kMapHeight] = { + false, + }; int pos = -1; for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) { @@ -686,19 +808,18 @@ TEST(DesktopRegionTest, SubtractRectOnSameCol) { } } - TEST(DesktopRegionTest, DISABLED_Performance) { for (int c = 0; c < 1000; ++c) { DesktopRegion r; for (int i = 0; i < 10; ++i) { - r.AddRect(DesktopRect::MakeXYWH( - RadmonInt(1000), RadmonInt(1000), 200, 200)); + r.AddRect( + DesktopRect::MakeXYWH(RadmonInt(1000), RadmonInt(1000), 200, 200)); } for (int i = 0; i < 1000; ++i) { - r.AddRect(DesktopRect::MakeXYWH( - RadmonInt(1000), RadmonInt(1000), - 5 + RadmonInt(10) * 5, 5 + RadmonInt(10) * 5)); + r.AddRect(DesktopRect::MakeXYWH(RadmonInt(1000), RadmonInt(1000), + 5 + RadmonInt(10) * 5, + 5 + RadmonInt(10) * 5)); } // Iterate over the rectangles. diff --git a/modules/desktop_capture/differ_block.cc b/modules/desktop_capture/differ_block.cc index 3315247238..e15211d7d2 100644 --- a/modules/desktop_capture/differ_block.cc +++ b/modules/desktop_capture/differ_block.cc @@ -12,9 +12,9 @@ #include -#include "typedefs.h" // NOLINT(build/include) #include "modules/desktop_capture/differ_vector_sse2.h" #include "system_wrappers/include/cpu_features_wrapper.h" +#include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/modules/desktop_capture/differ_block.h b/modules/desktop_capture/differ_block.h index 7bf9a7b1db..2019ae03f0 100644 --- a/modules/desktop_capture/differ_block.h +++ b/modules/desktop_capture/differ_block.h @@ -35,9 +35,7 @@ bool BlockDifference(const uint8_t* image1, // Low level function to compare 2 blocks of pixels of size // (kBlockSize, kBlockSize). Returns whether the blocks differ. -bool BlockDifference(const uint8_t* image1, - const uint8_t* image2, - int stride); +bool BlockDifference(const uint8_t* image1, const uint8_t* image2, int stride); } // namespace webrtc diff --git a/modules/desktop_capture/differ_block_unittest.cc b/modules/desktop_capture/differ_block_unittest.cc index 3f08632aaa..ac8b3a1765 100644 --- a/modules/desktop_capture/differ_block_unittest.cc +++ b/modules/desktop_capture/differ_block_unittest.cc @@ -27,9 +27,9 @@ static void GenerateData(uint8_t* data, int size) { static const int kSizeOfBlock = kBlockSize * kBlockSize * kBytesPerPixel; uint8_t block_buffer[kSizeOfBlock * 2 + 16]; -void PrepareBuffers(uint8_t* &block1, uint8_t* &block2) { - block1 = reinterpret_cast - ((reinterpret_cast(&block_buffer[0]) + 15) & ~15); +void PrepareBuffers(uint8_t*& block1, uint8_t*& block2) { + block1 = reinterpret_cast( + (reinterpret_cast(&block_buffer[0]) + 15) & ~15); GenerateData(block1, kSizeOfBlock); block2 = block1 + kSizeOfBlock; memcpy(block2, block1, kSizeOfBlock); @@ -51,7 +51,7 @@ TEST(BlockDifferenceTestLast, BlockDifference) { uint8_t* block1; uint8_t* block2; PrepareBuffers(block1, block2); - block2[kSizeOfBlock-2] += 1; + block2[kSizeOfBlock - 2] += 1; for (int i = 0; i < kTimesToRun; ++i) { int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); @@ -63,7 +63,7 @@ TEST(BlockDifferenceTestMid, BlockDifference) { uint8_t* block1; uint8_t* block2; PrepareBuffers(block1, block2); - block2[kSizeOfBlock/2+1] += 1; + block2[kSizeOfBlock / 2 + 1] += 1; for (int i = 0; i < kTimesToRun; ++i) { int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); diff --git a/modules/desktop_capture/differ_vector_sse2.cc b/modules/desktop_capture/differ_vector_sse2.cc index 9b552e0f61..1c8b602d71 100644 --- a/modules/desktop_capture/differ_vector_sse2.cc +++ b/modules/desktop_capture/differ_vector_sse2.cc @@ -13,8 +13,8 @@ #if defined(_MSC_VER) #include #else -#include #include +#include #endif namespace webrtc { diff --git a/modules/desktop_capture/fake_desktop_capturer.h b/modules/desktop_capture/fake_desktop_capturer.h index cb1cfe1ba6..82c053cbe0 100644 --- a/modules/desktop_capture/fake_desktop_capturer.h +++ b/modules/desktop_capture/fake_desktop_capturer.h @@ -13,8 +13,8 @@ #include -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_types.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_frame_generator.h" #include "modules/desktop_capture/shared_memory.h" diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc index b261a03028..2dd8ce1f5e 100644 --- a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc +++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc @@ -51,16 +51,16 @@ SharedMemoryFactoryProxy::SharedMemoryFactoryProxy( } // static -std::unique_ptr -SharedMemoryFactoryProxy::Create(SharedMemoryFactory* factory) { +std::unique_ptr SharedMemoryFactoryProxy::Create( + SharedMemoryFactory* factory) { return std::unique_ptr( new SharedMemoryFactoryProxy(factory)); } SharedMemoryFactoryProxy::~SharedMemoryFactoryProxy() = default; -std::unique_ptr -SharedMemoryFactoryProxy::CreateSharedMemory(size_t size) { +std::unique_ptr SharedMemoryFactoryProxy::CreateSharedMemory( + size_t size) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); return factory_->CreateSharedMemory(size); } diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper.h b/modules/desktop_capture/fallback_desktop_capturer_wrapper.h index a6f2ceb100..97affbe461 100644 --- a/modules/desktop_capture/fallback_desktop_capturer_wrapper.h +++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper.h @@ -13,8 +13,8 @@ #include -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_types.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/shared_memory.h" diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc b/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc index ca11162dc4..f2d6071598 100644 --- a/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc +++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc @@ -180,8 +180,8 @@ TEST_F(FallbackDesktopCapturerWrapperTest, BothFailed) { } TEST_F(FallbackDesktopCapturerWrapperTest, WithSharedMemory) { - wrapper_->SetSharedMemoryFactory(std::unique_ptr( - new FakeSharedMemoryFactory())); + wrapper_->SetSharedMemoryFactory( + std::unique_ptr(new FakeSharedMemoryFactory())); wrapper_->CaptureFrame(); main_capturer_->set_result(DesktopCapturer::Result::ERROR_TEMPORARY); wrapper_->CaptureFrame(); diff --git a/modules/desktop_capture/mac/desktop_configuration.h b/modules/desktop_capture/mac/desktop_configuration.h index 736d623685..2bee9af2cb 100644 --- a/modules/desktop_capture/mac/desktop_configuration.h +++ b/modules/desktop_capture/mac/desktop_configuration.h @@ -14,8 +14,8 @@ #include #include -#include "typedefs.h" // NOLINT(build/include) #include "modules/desktop_capture/desktop_geometry.h" +#include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/modules/desktop_capture/mac/desktop_configuration_monitor.cc b/modules/desktop_capture/mac/desktop_configuration_monitor.cc index e8378c38d9..d4364bedc2 100644 --- a/modules/desktop_capture/mac/desktop_configuration_monitor.cc +++ b/modules/desktop_capture/mac/desktop_configuration_monitor.cc @@ -43,7 +43,7 @@ DesktopConfigurationMonitor::~DesktopConfigurationMonitor() { void DesktopConfigurationMonitor::Lock() { if (!display_configuration_capture_event_->Wait( - kDisplayConfigurationEventTimeoutMs)) { + kDisplayConfigurationEventTimeoutMs)) { RTC_LOG_F(LS_ERROR) << "Event wait timed out."; abort(); } @@ -57,7 +57,7 @@ void DesktopConfigurationMonitor::Unlock() { void DesktopConfigurationMonitor::DisplaysReconfiguredCallback( CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, - void *user_parameter) { + void* user_parameter) { DesktopConfigurationMonitor* monitor = reinterpret_cast(user_parameter); monitor->DisplaysReconfigured(display, flags); diff --git a/modules/desktop_capture/mac/desktop_configuration_monitor.h b/modules/desktop_capture/mac/desktop_configuration_monitor.h index 746fbb271d..5215e5496a 100644 --- a/modules/desktop_capture/mac/desktop_configuration_monitor.h +++ b/modules/desktop_capture/mac/desktop_configuration_monitor.h @@ -45,7 +45,7 @@ class DesktopConfigurationMonitor : public rtc::RefCountedBase { private: static void DisplaysReconfiguredCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, - void *user_parameter); + void* user_parameter); void DisplaysReconfigured(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags); diff --git a/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc b/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc index a9f334fb7e..0cda46c93f 100644 --- a/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc +++ b/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc @@ -27,7 +27,7 @@ const int64_t kUpdateIntervalMs = 500; std::string GetWindowTitle(CGWindowID id) { CFArrayRef window_id_array = - CFArrayCreate(NULL, reinterpret_cast(&id), 1, NULL); + CFArrayCreate(NULL, reinterpret_cast(&id), 1, NULL); CFArrayRef window_array = CGWindowListCreateDescriptionFromArray(window_id_array); std::string title; @@ -35,7 +35,7 @@ std::string GetWindowTitle(CGWindowID id) { if (window_array && CFArrayGetCount(window_array)) { CFDictionaryRef window = reinterpret_cast( CFArrayGetValueAtIndex(window_array, 0)); - CFStringRef title_ref = reinterpret_cast( + CFStringRef title_ref = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowName)); if (title_ref) @@ -49,7 +49,7 @@ std::string GetWindowTitle(CGWindowID id) { int GetWindowOwnerPid(CGWindowID id) { CFArrayRef window_id_array = - CFArrayCreate(NULL, reinterpret_cast(&id), 1, NULL); + CFArrayCreate(NULL, reinterpret_cast(&id), 1, NULL); CFArrayRef window_array = CGWindowListCreateDescriptionFromArray(window_id_array); int pid = 0; @@ -57,7 +57,7 @@ int GetWindowOwnerPid(CGWindowID id) { if (window_array && CFArrayGetCount(window_array)) { CFDictionaryRef window = reinterpret_cast( CFArrayGetValueAtIndex(window_array, 0)); - CFNumberRef pid_ref = reinterpret_cast( + CFNumberRef pid_ref = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowOwnerPID)); if (pid_ref) @@ -97,7 +97,7 @@ CGWindowID FindFullScreenWindowWithSamePidAndTitle(CGWindowID id) { CFDictionaryGetValue(window, kCGWindowName)); CFNumberRef window_id_ref = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowNumber)); - CFNumberRef window_pid_ref = reinterpret_cast( + CFNumberRef window_pid_ref = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowOwnerPID)); if (!window_title_ref || !window_id_ref || !window_pid_ref) @@ -170,8 +170,8 @@ CGWindowID FullScreenChromeWindowDetector::FindFullScreenWindow( void FullScreenChromeWindowDetector::UpdateWindowListIfNeeded( CGWindowID original_window) { if (IsChromeWindow(original_window) && - (rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec - > kUpdateIntervalMs) { + (rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec > + kUpdateIntervalMs) { previous_window_list_.clear(); previous_window_list_.swap(current_window_list_); diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc index d30eb4be03..7f89cde1ce 100644 --- a/modules/desktop_capture/mac/window_list_utils.cc +++ b/modules/desktop_capture/mac/window_list_utils.cc @@ -19,9 +19,9 @@ #include "rtc_base/checks.h" #include "rtc_base/macutils.h" -static_assert( - static_cast(kCGNullWindowID) == webrtc::kNullWindowId, - "kNullWindowId needs to equal to kCGNullWindowID."); +static_assert(static_cast(kCGNullWindowID) == + webrtc::kNullWindowId, + "kNullWindowId needs to equal to kCGNullWindowID."); namespace webrtc { @@ -69,8 +69,8 @@ bool GetWindowList(rtc::FunctionView on_window, // Only get on screen, non-desktop windows. // According to - // https://developer.apple.com/documentation/coregraphics/cgwindowlistoption/1454105-optiononscreenonly , - // when kCGWindowListOptionOnScreenOnly is used, the order of windows are in + // https://developer.apple.com/documentation/coregraphics/cgwindowlistoption/1454105-optiononscreenonly + // , when kCGWindowListOptionOnScreenOnly is used, the order of windows are in // decreasing z-order. CFArrayRef window_array = CGWindowListCopyWindowInfo( kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, @@ -143,7 +143,7 @@ bool GetWindowList(DesktopCapturer::SourceList* windows, WindowId id = GetWindowId(window); std::string title = GetWindowTitle(window); if (id != kNullWindowId && !title.empty()) { - windows->push_back(DesktopCapturer::Source{ id, title }); + windows->push_back(DesktopCapturer::Source{id, title}); } return true; }, @@ -151,9 +151,8 @@ bool GetWindowList(DesktopCapturer::SourceList* windows, } // Returns true if the window is occupying a full screen. -bool IsWindowFullScreen( - const MacDesktopConfiguration& desktop_config, - CFDictionaryRef window) { +bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config, + CFDictionaryRef window) { bool fullscreen = false; CFDictionaryRef bounds_ref = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowBounds)); @@ -164,10 +163,9 @@ bool IsWindowFullScreen( for (MacDisplayConfigurations::const_iterator it = desktop_config.displays.begin(); it != desktop_config.displays.end(); it++) { - if (it->bounds.equals(DesktopRect::MakeXYWH(bounds.origin.x, - bounds.origin.y, - bounds.size.width, - bounds.size.height))) { + if (it->bounds.equals( + DesktopRect::MakeXYWH(bounds.origin.x, bounds.origin.y, + bounds.size.width, bounds.size.height))) { fullscreen = true; break; } @@ -185,10 +183,9 @@ bool IsWindowOnScreen(CFDictionaryRef window) { bool IsWindowOnScreen(CGWindowID id) { bool on_screen; - if (GetWindowRef(id, - [&on_screen](CFDictionaryRef window) { - on_screen = IsWindowOnScreen(window); - })) { + if (GetWindowRef(id, [&on_screen](CFDictionaryRef window) { + on_screen = IsWindowOnScreen(window); + })) { return on_screen; } return false; @@ -265,18 +262,16 @@ DesktopRect GetWindowBounds(CFDictionaryRef window) { return DesktopRect(); } - return DesktopRect::MakeXYWH(gc_window_rect.origin.x, - gc_window_rect.origin.y, + return DesktopRect::MakeXYWH(gc_window_rect.origin.x, gc_window_rect.origin.y, gc_window_rect.size.width, gc_window_rect.size.height); } DesktopRect GetWindowBounds(CGWindowID id) { DesktopRect result; - if (GetWindowRef(id, - [&result](CFDictionaryRef window) { - result = GetWindowBounds(window); - })) { + if (GetWindowRef(id, [&result](CFDictionaryRef window) { + result = GetWindowBounds(window); + })) { return result; } return DesktopRect(); diff --git a/modules/desktop_capture/mouse_cursor.cc b/modules/desktop_capture/mouse_cursor.cc index bb9f32707b..3b61e10a8b 100644 --- a/modules/desktop_capture/mouse_cursor.cc +++ b/modules/desktop_capture/mouse_cursor.cc @@ -19,8 +19,7 @@ namespace webrtc { MouseCursor::MouseCursor() {} MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot) - : image_(image), - hotspot_(hotspot) { + : image_(image), hotspot_(hotspot) { assert(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width()); assert(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height()); } diff --git a/modules/desktop_capture/mouse_cursor.h b/modules/desktop_capture/mouse_cursor.h index daf6c9695e..31fe836232 100644 --- a/modules/desktop_capture/mouse_cursor.h +++ b/modules/desktop_capture/mouse_cursor.h @@ -34,7 +34,7 @@ class MouseCursor { void set_image(DesktopFrame* image) { image_.reset(image); } const DesktopFrame* image() const { return image_.get(); } - void set_hotspot(const DesktopVector& hotspot ) { hotspot_ = hotspot; } + void set_hotspot(const DesktopVector& hotspot) { hotspot_ = hotspot; } const DesktopVector& hotspot() const { return hotspot_; } private: diff --git a/modules/desktop_capture/mouse_cursor_monitor.h b/modules/desktop_capture/mouse_cursor_monitor.h index e969d8eb31..a589c59b8d 100644 --- a/modules/desktop_capture/mouse_cursor_monitor.h +++ b/modules/desktop_capture/mouse_cursor_monitor.h @@ -110,4 +110,3 @@ class MouseCursorMonitor { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_H_ - diff --git a/modules/desktop_capture/mouse_cursor_monitor_unittest.cc b/modules/desktop_capture/mouse_cursor_monitor_unittest.cc index 812873fa61..ea7ba60616 100644 --- a/modules/desktop_capture/mouse_cursor_monitor_unittest.cc +++ b/modules/desktop_capture/mouse_cursor_monitor_unittest.cc @@ -10,11 +10,11 @@ #include -#include "modules/desktop_capture/mouse_cursor_monitor.h" -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/mouse_cursor.h" +#include "modules/desktop_capture/mouse_cursor_monitor.h" #include "test/gtest.h" namespace webrtc { @@ -22,9 +22,7 @@ namespace webrtc { class MouseCursorMonitorTest : public testing::Test, public MouseCursorMonitor::Callback { public: - MouseCursorMonitorTest() - : position_received_(false) { - } + MouseCursorMonitorTest() : position_received_(false) {} // MouseCursorMonitor::Callback interface void OnMouseCursor(MouseCursor* cursor_image) override { diff --git a/modules/desktop_capture/mouse_cursor_monitor_win.cc b/modules/desktop_capture/mouse_cursor_monitor_win.cc index 0c0a7b7759..bc03b95868 100644 --- a/modules/desktop_capture/mouse_cursor_monitor_win.cc +++ b/modules/desktop_capture/mouse_cursor_monitor_win.cc @@ -31,8 +31,7 @@ namespace { bool IsSameCursorShape(const CURSORINFO& left, const CURSORINFO& right) { // If the cursors are not showing, we do not care the hCursor handle. return left.flags == right.flags && - (left.flags != CURSOR_SHOWING || - left.hCursor == right.hCursor); + (left.flags != CURSOR_SHOWING || left.hCursor == right.hCursor); } } // namespace @@ -152,8 +151,9 @@ void MouseCursorMonitorWin::Capture() { } else { if (inside) { HWND windowUnderCursor = WindowFromPoint(cursor_info.ptScreenPos); - inside = windowUnderCursor ? - (window_ == GetAncestor(windowUnderCursor, GA_ROOT)) : false; + inside = windowUnderCursor + ? (window_ == GetAncestor(windowUnderCursor, GA_ROOT)) + : false; } position = position.subtract(cropped_rect.top_left()); } @@ -171,11 +171,10 @@ void MouseCursorMonitorWin::Capture() { DesktopRect MouseCursorMonitorWin::GetScreenRect() { assert(screen_ != kInvalidScreenId); if (screen_ == kFullDesktopScreenId) { - return DesktopRect::MakeXYWH( - GetSystemMetrics(SM_XVIRTUALSCREEN), - GetSystemMetrics(SM_YVIRTUALSCREEN), - GetSystemMetrics(SM_CXVIRTUALSCREEN), - GetSystemMetrics(SM_CYVIRTUALSCREEN)); + return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN), + GetSystemMetrics(SM_YVIRTUALSCREEN), + GetSystemMetrics(SM_CXVIRTUALSCREEN), + GetSystemMetrics(SM_CYVIRTUALSCREEN)); } DISPLAY_DEVICE device; device.cb = sizeof(device); @@ -186,19 +185,19 @@ DesktopRect MouseCursorMonitorWin::GetScreenRect() { DEVMODE device_mode; device_mode.dmSize = sizeof(device_mode); device_mode.dmDriverExtra = 0; - result = EnumDisplaySettingsEx( - device.DeviceName, ENUM_CURRENT_SETTINGS, &device_mode, 0); + result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS, + &device_mode, 0); if (!result) return DesktopRect(); - return DesktopRect::MakeXYWH(device_mode.dmPosition.x, - device_mode.dmPosition.y, - device_mode.dmPelsWidth, - device_mode.dmPelsHeight); + return DesktopRect::MakeXYWH( + device_mode.dmPosition.x, device_mode.dmPosition.y, + device_mode.dmPelsWidth, device_mode.dmPelsHeight); } MouseCursorMonitor* MouseCursorMonitor::CreateForWindow( - const DesktopCaptureOptions& options, WindowId window) { + const DesktopCaptureOptions& options, + WindowId window) { return new MouseCursorMonitorWin(reinterpret_cast(window)); } diff --git a/modules/desktop_capture/mouse_cursor_monitor_x11.cc b/modules/desktop_capture/mouse_cursor_monitor_x11.cc index 039f9c37b8..41749bd284 100644 --- a/modules/desktop_capture/mouse_cursor_monitor_x11.cc +++ b/modules/desktop_capture/mouse_cursor_monitor_x11.cc @@ -12,9 +12,9 @@ #include "modules/desktop_capture/mouse_cursor_monitor.h" -#include #include #include +#include #include "modules/desktop_capture/desktop_capture_options.h" #include "modules/desktop_capture/desktop_capture_types.h" @@ -35,7 +35,7 @@ Window GetTopLevelWindow(Display* display, Window window) { while (true) { // If the window is in WithdrawnState then look at all of its children. ::Window root, parent; - ::Window *children; + ::Window* children; unsigned int num_children; if (!XQueryTree(display, window, &root, &parent, &children, &num_children)) { @@ -104,12 +104,9 @@ MouseCursorMonitorX11::MouseCursorMonitorX11( std::unique_ptr default_cursor( new BasicDesktopFrame(DesktopSize(kSize, kSize))); const uint8_t pixels[kSize * kSize] = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t* ptr = default_cursor->data(); for (int y = 0; y < kSize; ++y) { for (int x = 0; x < kSize; ++x) { @@ -228,11 +225,11 @@ void MouseCursorMonitorX11::CaptureCursor() { XErrorTrap error_trap(display()); img = XFixesGetCursorImage(display()); if (!img || error_trap.GetLastErrorAndDisable() != 0) - return; - } + return; + } - std::unique_ptr image( - new BasicDesktopFrame(DesktopSize(img->width, img->height))); + std::unique_ptr image( + new BasicDesktopFrame(DesktopSize(img->width, img->height))); // Xlib stores 32-bit data in longs, even if longs are 64-bits long. unsigned long* src = img->pixels; @@ -252,7 +249,8 @@ void MouseCursorMonitorX11::CaptureCursor() { // static MouseCursorMonitor* MouseCursorMonitor::CreateForWindow( - const DesktopCaptureOptions& options, WindowId window) { + const DesktopCaptureOptions& options, + WindowId window) { if (!options.x_display()) return NULL; window = GetTopLevelWindow(options.x_display()->display(), window); diff --git a/modules/desktop_capture/screen_capture_frame_queue.h b/modules/desktop_capture/screen_capture_frame_queue.h index a9a1643058..a5bb595150 100644 --- a/modules/desktop_capture/screen_capture_frame_queue.h +++ b/modules/desktop_capture/screen_capture_frame_queue.h @@ -16,10 +16,9 @@ #include "rtc_base/constructormagic.h" // TODO(zijiehe): These headers are not used in this file, but to avoid build // break in remoting/host. We should add headers in each individual files. -#include "modules/desktop_capture/desktop_frame.h" // Remove +#include "modules/desktop_capture/desktop_frame.h" // Remove #include "modules/desktop_capture/shared_desktop_frame.h" // Remove - namespace webrtc { // Represents a queue of reusable video frames. Provides access to the 'current' @@ -43,9 +42,7 @@ class ScreenCaptureFrameQueue { // Moves to the next frame in the queue, moving the 'current' frame to become // the 'previous' one. - void MoveToNextFrame() { - current_ = (current_ + 1) % kQueueLength; - } + void MoveToNextFrame() { current_ = (current_ + 1) % kQueueLength; } // Replaces the current frame with a new one allocated by the caller. The // existing frame (if any) is destroyed. Takes ownership of |frame|. @@ -62,9 +59,7 @@ class ScreenCaptureFrameQueue { current_ = 0; } - FrameType* current_frame() const { - return frames_[current_].get(); - } + FrameType* current_frame() const { return frames_[current_].get(); } FrameType* previous_frame() const { return frames_[(current_ + kQueueLength - 1) % kQueueLength].get(); diff --git a/modules/desktop_capture/screen_capturer_helper.cc b/modules/desktop_capture/screen_capturer_helper.cc index 4e4635eaed..2e4fef86be 100644 --- a/modules/desktop_capture/screen_capturer_helper.cc +++ b/modules/desktop_capture/screen_capturer_helper.cc @@ -16,12 +16,9 @@ namespace webrtc { ScreenCapturerHelper::ScreenCapturerHelper() - : invalid_region_lock_(RWLockWrapper::CreateRWLock()), - log_grid_size_(0) { -} + : invalid_region_lock_(RWLockWrapper::CreateRWLock()), log_grid_size_(0) {} -ScreenCapturerHelper::~ScreenCapturerHelper() { -} +ScreenCapturerHelper::~ScreenCapturerHelper() {} void ScreenCapturerHelper::ClearInvalidRegion() { WriteLockScoped scoped_invalid_region_lock(*invalid_region_lock_); @@ -39,8 +36,7 @@ void ScreenCapturerHelper::InvalidateScreen(const DesktopSize& size) { invalid_region_.AddRect(DesktopRect::MakeSize(size)); } -void ScreenCapturerHelper::TakeInvalidRegion( - DesktopRegion* invalid_region) { +void ScreenCapturerHelper::TakeInvalidRegion(DesktopRegion* invalid_region) { invalid_region->Clear(); { @@ -65,8 +61,7 @@ const DesktopSize& ScreenCapturerHelper::size_most_recent() const { return size_most_recent_; } -void ScreenCapturerHelper::set_size_most_recent( - const DesktopSize& size) { +void ScreenCapturerHelper::set_size_most_recent(const DesktopSize& size) { size_most_recent_ = size; } diff --git a/modules/desktop_capture/screen_capturer_helper_unittest.cc b/modules/desktop_capture/screen_capturer_helper_unittest.cc index f2944abf67..1ce4959e76 100644 --- a/modules/desktop_capture/screen_capturer_helper_unittest.cc +++ b/modules/desktop_capture/screen_capturer_helper_unittest.cc @@ -55,8 +55,7 @@ TEST_F(ScreenCapturerHelperTest, InvalidateScreen) { TEST_F(ScreenCapturerHelperTest, SizeMostRecent) { EXPECT_TRUE(capturer_helper_.size_most_recent().is_empty()); capturer_helper_.set_size_most_recent(DesktopSize(12, 34)); - EXPECT_TRUE( - DesktopSize(12, 34).equals(capturer_helper_.size_most_recent())); + EXPECT_TRUE(DesktopSize(12, 34).equals(capturer_helper_.size_most_recent())); } TEST_F(ScreenCapturerHelperTest, SetLogGridSize) { @@ -103,7 +102,8 @@ TEST_F(ScreenCapturerHelperTest, SetLogGridSize) { EXPECT_TRUE(DesktopRegion(DesktopRect::MakeXYWH(7, 7, 1, 1)).Equals(region)); } -void TestExpandRegionToGrid(const DesktopRegion& region, int log_grid_size, +void TestExpandRegionToGrid(const DesktopRegion& region, + int log_grid_size, const DesktopRegion& expanded_region_expected) { DesktopRegion expanded_region1; ScreenCapturerHelper::ExpandToGrid(region, log_grid_size, &expanded_region1); @@ -115,9 +115,15 @@ void TestExpandRegionToGrid(const DesktopRegion& region, int log_grid_size, EXPECT_TRUE(expanded_region1.Equals(expanded_region2)); } -void TestExpandRectToGrid(int l, int t, int r, int b, int log_grid_size, - int lExpanded, int tExpanded, - int rExpanded, int bExpanded) { +void TestExpandRectToGrid(int l, + int t, + int r, + int b, + int log_grid_size, + int lExpanded, + int tExpanded, + int rExpanded, + int bExpanded) { TestExpandRegionToGrid(DesktopRegion(DesktopRect::MakeLTRB(l, t, r, b)), log_grid_size, DesktopRegion(DesktopRect::MakeLTRB( @@ -131,23 +137,23 @@ TEST_F(ScreenCapturerHelperTest, ExpandToGrid) { int x = i * kGridSize; for (int j = -2; j <= 2; j++) { int y = j * kGridSize; - TestExpandRectToGrid(x + 0, y + 0, x + 1, y + 1, kLogGridSize, - x + 0, y + 0, x + kGridSize, y + kGridSize); + TestExpandRectToGrid(x + 0, y + 0, x + 1, y + 1, kLogGridSize, x + 0, + y + 0, x + kGridSize, y + kGridSize); TestExpandRectToGrid(x + 0, y + kGridSize - 1, x + 1, y + kGridSize, - kLogGridSize, - x + 0, y + 0, x + kGridSize, y + kGridSize); - TestExpandRectToGrid(x + kGridSize - 1, y + kGridSize - 1, - x + kGridSize, y + kGridSize, kLogGridSize, - x + 0, y + 0, x + kGridSize, y + kGridSize); - TestExpandRectToGrid(x + kGridSize - 1, y + 0, - x + kGridSize, y + 1, kLogGridSize, - x + 0, y + 0, x + kGridSize, y + kGridSize); + kLogGridSize, x + 0, y + 0, x + kGridSize, + y + kGridSize); + TestExpandRectToGrid(x + kGridSize - 1, y + kGridSize - 1, x + kGridSize, + y + kGridSize, kLogGridSize, x + 0, y + 0, + x + kGridSize, y + kGridSize); + TestExpandRectToGrid(x + kGridSize - 1, y + 0, x + kGridSize, y + 1, + kLogGridSize, x + 0, y + 0, x + kGridSize, + y + kGridSize); TestExpandRectToGrid(x - 1, y + 0, x + 1, y + 1, kLogGridSize, x - kGridSize, y + 0, x + kGridSize, y + kGridSize); TestExpandRectToGrid(x - 1, y - 1, x + 1, y + 0, kLogGridSize, x - kGridSize, y - kGridSize, x + kGridSize, y); - TestExpandRectToGrid(x + 0, y - 1, x + 1, y + 1, kLogGridSize, - x, y - kGridSize, x + kGridSize, y + kGridSize); + TestExpandRectToGrid(x + 0, y - 1, x + 1, y + 1, kLogGridSize, x, + y - kGridSize, x + kGridSize, y + kGridSize); TestExpandRectToGrid(x - 1, y - 1, x + 0, y + 1, kLogGridSize, x - kGridSize, y - kGridSize, x, y + kGridSize); @@ -164,18 +170,18 @@ TEST_F(ScreenCapturerHelperTest, ExpandToGrid) { } if (q != 1) { region.AddRect(DesktopRect::MakeXYWH(x, y - 1, 1, 1)); - expanded_region_expected.AddRect(DesktopRect::MakeXYWH( - x, y - kGridSize, kGridSize, kGridSize)); + expanded_region_expected.AddRect( + DesktopRect::MakeXYWH(x, y - kGridSize, kGridSize, kGridSize)); } if (q != 2) { region.AddRect(DesktopRect::MakeXYWH(x - 1, y, 1, 1)); - expanded_region_expected.AddRect(DesktopRect::MakeXYWH( - x - kGridSize, y, kGridSize, kGridSize)); + expanded_region_expected.AddRect( + DesktopRect::MakeXYWH(x - kGridSize, y, kGridSize, kGridSize)); } if (q != 3) { region.AddRect(DesktopRect::MakeXYWH(x, y, 1, 1)); - expanded_region_expected.AddRect(DesktopRect::MakeXYWH( - x, y, kGridSize, kGridSize)); + expanded_region_expected.AddRect( + DesktopRect::MakeXYWH(x, y, kGridSize, kGridSize)); } TestExpandRegionToGrid(region, kLogGridSize, expanded_region_expected); diff --git a/modules/desktop_capture/screen_capturer_integration_test.cc b/modules/desktop_capture/screen_capturer_integration_test.cc index 0104a56074..fdcf67bf0a 100644 --- a/modules/desktop_capture/screen_capturer_integration_test.cc +++ b/modules/desktop_capture/screen_capturer_integration_test.cc @@ -89,8 +89,8 @@ class ScreenCapturerIntegrationTest : public testing::Test { void TestCaptureUpdatedRegion( std::initializer_list capturers) { RTC_DCHECK(capturers.size() > 0); - // A large enough area for the tests, which should be able to be fulfilled - // by most systems. +// A large enough area for the tests, which should be able to be fulfilled +// by most systems. #if defined(WEBRTC_WIN) // On Windows, an interesting warning window may pop up randomly. The root // cause is still under investigation, so reduce the test area to work @@ -212,8 +212,8 @@ class ScreenCapturerIntegrationTest : public testing::Test { return; } - if (ArePixelsColoredBy( - *frame, rect, color, drawer->MayDrawIncompleteShapes())) { + if (ArePixelsColoredBy(*frame, rect, color, + drawer->MayDrawIncompleteShapes())) { capturers[j] = nullptr; succeeded_capturers++; } @@ -222,17 +222,15 @@ class ScreenCapturerIntegrationTest : public testing::Test { // been resolved. else if (i == wait_capture_round - 1) { std::string result; - rtc::Base64::EncodeFromArray(frame->data(), - frame->size().height() * frame->stride(), - &result); + rtc::Base64::EncodeFromArray( + frame->data(), frame->size().height() * frame->stride(), &result); std::cout << frame->size().width() << " x " << frame->size().height() << std::endl; // Split the entire string (can be over 4M) into several lines to // avoid browser from sticking. static const size_t kLineLength = 32768; const char* result_end = result.c_str() + result.length(); - for (const char* it = result.c_str(); - it < result_end; + for (const char* it = result.c_str(); it < result_end; it += kLineLength) { const size_t max_length = result_end - it; std::cout << std::string(it, std::min(kLineLength, max_length)) diff --git a/modules/desktop_capture/screen_capturer_mac_unittest.cc b/modules/desktop_capture/screen_capturer_mac_unittest.cc index 00d2d02a29..812f230a06 100644 --- a/modules/desktop_capture/screen_capturer_mac_unittest.cc +++ b/modules/desktop_capture/screen_capturer_mac_unittest.cc @@ -13,8 +13,8 @@ #include #include -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/desktop_geometry.h" #include "modules/desktop_capture/desktop_region.h" diff --git a/modules/desktop_capture/screen_capturer_unittest.cc b/modules/desktop_capture/screen_capturer_unittest.cc index 9ed4f4cb98..0264867aa4 100644 --- a/modules/desktop_capture/screen_capturer_unittest.cc +++ b/modules/desktop_capture/screen_capturer_unittest.cc @@ -73,12 +73,9 @@ class ScreenCapturerTest : public testing::Test { class FakeSharedMemory : public SharedMemory { public: FakeSharedMemory(char* buffer, size_t size) - : SharedMemory(buffer, size, 0, kTestSharedMemoryId), - buffer_(buffer) { - } - virtual ~FakeSharedMemory() { - delete[] buffer_; - } + : SharedMemory(buffer, size, 0, kTestSharedMemoryId), buffer_(buffer) {} + virtual ~FakeSharedMemory() { delete[] buffer_; } + private: char* buffer_; RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemory); diff --git a/modules/desktop_capture/screen_capturer_win.cc b/modules/desktop_capture/screen_capturer_win.cc index ecdc48e5b4..be6d8a5275 100644 --- a/modules/desktop_capture/screen_capturer_win.cc +++ b/modules/desktop_capture/screen_capturer_win.cc @@ -12,8 +12,8 @@ #include #include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h" -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h" #include "modules/desktop_capture/rgba_color.h" #include "modules/desktop_capture/win/screen_capturer_win_directx.h" @@ -25,8 +25,7 @@ namespace webrtc { namespace { std::unique_ptr CreateScreenCapturerWinDirectx() { - std::unique_ptr capturer( - new ScreenCapturerWinDirectx()); + std::unique_ptr capturer(new ScreenCapturerWinDirectx()); capturer.reset(new BlankDetectorDesktopCapturerWrapper( std::move(capturer), RgbaColor(0, 0, 0, 0))); return capturer; diff --git a/modules/desktop_capture/screen_capturer_x11.cc b/modules/desktop_capture/screen_capturer_x11.cc index 5b099caa3d..e95fccc208 100644 --- a/modules/desktop_capture/screen_capturer_x11.cc +++ b/modules/desktop_capture/screen_capturer_x11.cc @@ -14,10 +14,10 @@ #include #include -#include -#include #include #include +#include +#include #include "modules/desktop_capture/desktop_capture_options.h" #include "modules/desktop_capture/desktop_capturer.h" @@ -128,8 +128,8 @@ ScreenCapturerLinux::ScreenCapturerLinux() { ScreenCapturerLinux::~ScreenCapturerLinux() { options_.x_display()->RemoveEventHandler(ConfigureNotify, this); if (use_damage_) { - options_.x_display()->RemoveEventHandler( - damage_event_base_ + XDamageNotify, this); + options_.x_display()->RemoveEventHandler(damage_event_base_ + XDamageNotify, + this); } DeinitXlib(); } @@ -197,8 +197,8 @@ void ScreenCapturerLinux::InitXDamage() { // properly. // Request notifications every time the screen becomes damaged. - damage_handle_ = XDamageCreate(display(), root_window_, - XDamageReportNonEmpty); + damage_handle_ = + XDamageCreate(display(), root_window_, XDamageReportNonEmpty); if (!damage_handle_) { RTC_LOG(LS_ERROR) << "Unable to initialize XDamage."; return; @@ -212,8 +212,8 @@ void ScreenCapturerLinux::InitXDamage() { return; } - options_.x_display()->AddEventHandler( - damage_event_base_ + XDamageNotify, this); + options_.x_display()->AddEventHandler(damage_event_base_ + XDamageNotify, + this); use_damage_ = true; RTC_LOG(LS_INFO) << "Using XDamage extension."; @@ -240,10 +240,10 @@ void ScreenCapturerLinux::CaptureFrame() { // reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still // in a good shape. if (!x_server_pixel_buffer_.is_initialized()) { - // We failed to initialize pixel buffer. - RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized."; - callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr); - return; + // We failed to initialize pixel buffer. + RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized."; + callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr); + return; } // If the current frame is from an older generation then allocate a new one. @@ -336,8 +336,8 @@ std::unique_ptr ScreenCapturerLinux::CaptureScreen() { updated_region->IntersectWith( DesktopRect::MakeSize(x_server_pixel_buffer_.window_size())); - for (DesktopRegion::Iterator it(*updated_region); - !it.IsAtEnd(); it.Advance()) { + for (DesktopRegion::Iterator it(*updated_region); !it.IsAtEnd(); + it.Advance()) { if (!x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get())) return nullptr; } @@ -379,8 +379,8 @@ void ScreenCapturerLinux::SynchronizeFrame() { DesktopFrame* current = queue_.current_frame(); DesktopFrame* last = queue_.previous_frame(); RTC_DCHECK(current != last); - for (DesktopRegion::Iterator it(last_invalid_region_); - !it.IsAtEnd(); it.Advance()) { + for (DesktopRegion::Iterator it(last_invalid_region_); !it.IsAtEnd(); + it.Advance()) { current->CopyPixelsFrom(*last, it.rect().top_left(), it.rect()); } } diff --git a/modules/desktop_capture/screen_drawer.h b/modules/desktop_capture/screen_drawer.h index 89dfd66ddd..0f4ee25fca 100644 --- a/modules/desktop_capture/screen_drawer.h +++ b/modules/desktop_capture/screen_drawer.h @@ -15,9 +15,9 @@ #include -#include "modules/desktop_capture/rgba_color.h" #include "modules/desktop_capture/desktop_capture_types.h" #include "modules/desktop_capture/desktop_geometry.h" +#include "modules/desktop_capture/rgba_color.h" namespace webrtc { diff --git a/modules/desktop_capture/screen_drawer_linux.cc b/modules/desktop_capture/screen_drawer_linux.cc index cbd8ba8612..cbd19a9944 100644 --- a/modules/desktop_capture/screen_drawer_linux.cc +++ b/modules/desktop_capture/screen_drawer_linux.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include +#include #include diff --git a/modules/desktop_capture/screen_drawer_unittest.cc b/modules/desktop_capture/screen_drawer_unittest.cc index 349edbc58b..71429c5fc3 100644 --- a/modules/desktop_capture/screen_drawer_unittest.cc +++ b/modules/desktop_capture/screen_drawer_unittest.cc @@ -10,15 +10,15 @@ #include "modules/desktop_capture/screen_drawer.h" -#include #include +#include #include "rtc_base/checks.h" #include "rtc_base/function_view.h" #include "rtc_base/logging.h" -#include "rtc_base/random.h" #include "rtc_base/platform_thread.h" #include "rtc_base/ptr_util.h" +#include "rtc_base/random.h" #include "rtc_base/timeutils.h" #include "system_wrappers/include/sleep.h" #include "test/gtest.h" @@ -45,9 +45,7 @@ void TestScreenDrawerLock( Task(std::atomic* created, const std::atomic& ready, rtc::FunctionView()> ctor) - : created_(created), - ready_(ready), - ctor_(ctor) {} + : created_(created), ready_(ready), ctor_(ctor) {} ~Task() = default; @@ -85,7 +83,8 @@ void TestScreenDrawerLock( // Wait for the first lock in Task::RunTask() to be created. // TODO(zijiehe): Find a better solution to wait for the creation of the first - // lock. See https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc + // lock. See + // https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc while (!created.load()) { SleepMs(1); } @@ -152,9 +151,7 @@ TEST(ScreenDrawerTest, TwoScreenDrawerLocks) { return rtc::MakeUnique(semaphore_name); }); #elif defined(WEBRTC_WIN) - TestScreenDrawerLock([]() { - return ScreenDrawerLock::Create(); - }); + TestScreenDrawerLock([]() { return ScreenDrawerLock::Create(); }); #endif } diff --git a/modules/desktop_capture/shared_memory.cc b/modules/desktop_capture/shared_memory.cc index fcbdd54e28..b4ff78b2a0 100644 --- a/modules/desktop_capture/shared_memory.cc +++ b/modules/desktop_capture/shared_memory.cc @@ -19,10 +19,6 @@ const SharedMemory::Handle SharedMemory::kInvalidHandle = -1; #endif SharedMemory::SharedMemory(void* data, size_t size, Handle handle, int id) - : data_(data), - size_(size), - handle_(handle), - id_(id) { -} + : data_(data), size_(size), handle_(handle), id_(id) {} } // namespace webrtc diff --git a/modules/desktop_capture/shared_memory.h b/modules/desktop_capture/shared_memory.h index dc72b29b40..3bafa0b41e 100644 --- a/modules/desktop_capture/shared_memory.h +++ b/modules/desktop_capture/shared_memory.h @@ -80,4 +80,3 @@ class SharedMemoryFactory { } // namespace webrtc #endif // MODULES_DESKTOP_CAPTURE_SHARED_MEMORY_H_ - diff --git a/modules/desktop_capture/test_utils.cc b/modules/desktop_capture/test_utils.cc index 0a4749afdb..81473eec42 100644 --- a/modules/desktop_capture/test_utils.cc +++ b/modules/desktop_capture/test_utils.cc @@ -34,8 +34,7 @@ bool DesktopFrameDataEquals(const DesktopFrame& left, const uint8_t* left_array = left.data(); const uint8_t* right_array = right.data(); for (int i = 0; i < left.size().height(); i++) { - if (memcmp(left_array, - right_array, + if (memcmp(left_array, right_array, DesktopFrame::kBytesPerPixel * left.size().width()) != 0) { return false; } diff --git a/modules/desktop_capture/win/cursor.cc b/modules/desktop_capture/win/cursor.cc index 38dc02b883..dfce5fbde7 100644 --- a/modules/desktop_capture/win/cursor.cc +++ b/modules/desktop_capture/win/cursor.cc @@ -26,19 +26,15 @@ namespace { #if defined(WEBRTC_ARCH_LITTLE_ENDIAN) -#define RGBA(r, g, b, a) \ - ((((a) << 24) & 0xff000000) | \ - (((b) << 16) & 0xff0000) | \ - (((g) << 8) & 0xff00) | \ - ((r) & 0xff)) +#define RGBA(r, g, b, a) \ + ((((a) << 24) & 0xff000000) | (((b) << 16) & 0xff0000) | \ + (((g) << 8) & 0xff00) | ((r)&0xff)) #else // !defined(WEBRTC_ARCH_LITTLE_ENDIAN) -#define RGBA(r, g, b, a) \ - ((((r) << 24) & 0xff000000) | \ - (((g) << 16) & 0xff0000) | \ - (((b) << 8) & 0xff00) | \ - ((a) & 0xff)) +#define RGBA(r, g, b, a) \ + ((((r) << 24) & 0xff000000) | (((g) << 16) & 0xff0000) | \ + (((b) << 8) & 0xff00) | ((a)&0xff)) #endif // !defined(WEBRTC_ARCH_LITTLE_ENDIAN) @@ -149,13 +145,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) { bmi.bV5AlphaMask = 0xff000000; bmi.bV5CSType = LCS_WINDOWS_COLOR_SPACE; bmi.bV5Intent = LCS_GM_BUSINESS; - if (!GetDIBits(dc, - scoped_mask, - 0, - height, - mask_data.get(), - reinterpret_cast(&bmi), - DIB_RGB_COLORS)) { + if (!GetDIBits(dc, scoped_mask, 0, height, mask_data.get(), + reinterpret_cast(&bmi), DIB_RGB_COLORS)) { RTC_LOG_F(LS_ERROR) << "Unable to get bitmap bits. Error = " << GetLastError(); return NULL; @@ -169,13 +160,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) { if (is_color) { image.reset(new BasicDesktopFrame(DesktopSize(width, height))); // Get the pixels from the color bitmap. - if (!GetDIBits(dc, - scoped_color, - 0, - height, - image->data(), - reinterpret_cast(&bmi), - DIB_RGB_COLORS)) { + if (!GetDIBits(dc, scoped_color, 0, height, image->data(), + reinterpret_cast(&bmi), DIB_RGB_COLORS)) { RTC_LOG_F(LS_ERROR) << "Unable to get bitmap bits. Error = " << GetLastError(); return NULL; @@ -194,8 +180,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) { image.reset(new BasicDesktopFrame(DesktopSize(width, height))); // The XOR mask becomes the color bitmap. - memcpy( - image->data(), mask_plane + (width * height), image->stride() * height); + memcpy(image->data(), mask_plane + (width * height), + image->stride() * height); } // Reconstruct transparency from the mask if the color image does not has @@ -232,8 +218,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) { } } if (add_outline) { - AddCursorOutline( - width, height, reinterpret_cast(image->data())); + AddCursorOutline(width, height, + reinterpret_cast(image->data())); } } @@ -241,8 +227,7 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) { // images. AlphaMul(reinterpret_cast(image->data()), width, height); - return new MouseCursor( - image.release(), DesktopVector(hotspot_x, hotspot_y)); + return new MouseCursor(image.release(), DesktopVector(hotspot_x, hotspot_y)); } } // namespace webrtc diff --git a/modules/desktop_capture/win/cursor_unittest.cc b/modules/desktop_capture/win/cursor_unittest.cc index 368a3da587..ff7b6bf311 100644 --- a/modules/desktop_capture/win/cursor_unittest.cc +++ b/modules/desktop_capture/win/cursor_unittest.cc @@ -74,17 +74,17 @@ bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) { } // namespace TEST(MouseCursorTest, MatchCursors) { - EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP, - IDD_CURSOR1_32BPP)); + EXPECT_TRUE( + ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP, IDD_CURSOR1_32BPP)); - EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_8BPP, - IDD_CURSOR1_32BPP)); + EXPECT_TRUE( + ConvertToMouseShapeAndCompare(IDD_CURSOR1_8BPP, IDD_CURSOR1_32BPP)); - EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR2_1BPP, - IDD_CURSOR2_32BPP)); + EXPECT_TRUE( + ConvertToMouseShapeAndCompare(IDD_CURSOR2_1BPP, IDD_CURSOR2_32BPP)); - EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR3_4BPP, - IDD_CURSOR3_32BPP)); + EXPECT_TRUE( + ConvertToMouseShapeAndCompare(IDD_CURSOR3_4BPP, IDD_CURSOR3_32BPP)); } } // namespace webrtc diff --git a/modules/desktop_capture/win/cursor_unittest_resources.h b/modules/desktop_capture/win/cursor_unittest_resources.h index 043103dc47..f583554d68 100644 --- a/modules/desktop_capture/win/cursor_unittest_resources.h +++ b/modules/desktop_capture/win/cursor_unittest_resources.h @@ -11,14 +11,14 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_ #define MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_ -#define IDD_CURSOR1_24BPP 101 -#define IDD_CURSOR1_32BPP 102 -#define IDD_CURSOR1_8BPP 103 +#define IDD_CURSOR1_24BPP 101 +#define IDD_CURSOR1_32BPP 102 +#define IDD_CURSOR1_8BPP 103 -#define IDD_CURSOR2_1BPP 104 -#define IDD_CURSOR2_32BPP 105 +#define IDD_CURSOR2_1BPP 104 +#define IDD_CURSOR2_32BPP 105 -#define IDD_CURSOR3_4BPP 106 -#define IDD_CURSOR3_32BPP 107 +#define IDD_CURSOR3_4BPP 106 +#define IDD_CURSOR3_32BPP 107 #endif // MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_ diff --git a/modules/desktop_capture/win/d3d_device.cc b/modules/desktop_capture/win/d3d_device.cc index c2b78c12cc..b220b138a5 100644 --- a/modules/desktop_capture/win/d3d_device.cc +++ b/modules/desktop_capture/win/d3d_device.cc @@ -69,8 +69,9 @@ bool D3dDevice::Initialize(const ComPtr& adapter) { // static std::vector D3dDevice::EnumDevices() { ComPtr factory; - _com_error error = CreateDXGIFactory1(__uuidof(IDXGIFactory1), - reinterpret_cast(factory.GetAddressOf())); + _com_error error = + CreateDXGIFactory1(__uuidof(IDXGIFactory1), + reinterpret_cast(factory.GetAddressOf())); if (error.Error() != S_OK || !factory) { RTC_LOG(LS_WARNING) << "Cannot create IDXGIFactory1."; return std::vector(); diff --git a/modules/desktop_capture/win/d3d_device.h b/modules/desktop_capture/win/d3d_device.h index 8f545d367c..b40279cd44 100644 --- a/modules/desktop_capture/win/d3d_device.h +++ b/modules/desktop_capture/win/d3d_device.h @@ -11,10 +11,10 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_ #define MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_ -#include -#include #include #include +#include +#include #include diff --git a/modules/desktop_capture/win/desktop.cc b/modules/desktop_capture/win/desktop.cc index 34842b3c79..459b6fe3be 100644 --- a/modules/desktop_capture/win/desktop.cc +++ b/modules/desktop_capture/win/desktop.cc @@ -16,8 +16,7 @@ namespace webrtc { -Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) { -} +Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {} Desktop::~Desktop() { if (own_ && desktop_ != NULL) { @@ -72,10 +71,10 @@ bool Desktop::SetThreadDesktop() const { } Desktop* Desktop::GetDesktop(const WCHAR* desktop_name) { - ACCESS_MASK desired_access = - DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | - DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS | - DESKTOP_SWITCHDESKTOP | GENERIC_WRITE; + ACCESS_MASK desired_access = DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | + DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL | + DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS | + DESKTOP_SWITCHDESKTOP | GENERIC_WRITE; HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access); if (desktop == NULL) { RTC_LOG(LS_ERROR) << "Failed to open the desktop '" << desktop_name diff --git a/modules/desktop_capture/win/dxgi_adapter_duplicator.cc b/modules/desktop_capture/win/dxgi_adapter_duplicator.cc index c4cd982d27..81354fbead 100644 --- a/modules/desktop_capture/win/dxgi_adapter_duplicator.cc +++ b/modules/desktop_capture/win/dxgi_adapter_duplicator.cc @@ -10,8 +10,8 @@ #include "modules/desktop_capture/win/dxgi_adapter_duplicator.h" -#include #include +#include #include diff --git a/modules/desktop_capture/win/dxgi_context.cc b/modules/desktop_capture/win/dxgi_context.cc index 6b4649e26c..6a679cb91f 100644 --- a/modules/desktop_capture/win/dxgi_context.cc +++ b/modules/desktop_capture/win/dxgi_context.cc @@ -14,8 +14,8 @@ namespace webrtc { DxgiAdapterContext::DxgiAdapterContext() = default; -DxgiAdapterContext::DxgiAdapterContext( - const DxgiAdapterContext& context) = default; +DxgiAdapterContext::DxgiAdapterContext(const DxgiAdapterContext& context) = + default; DxgiAdapterContext::~DxgiAdapterContext() = default; DxgiFrameContext::DxgiFrameContext() = default; diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc index 2da12a676a..2029811b2a 100644 --- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc +++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc @@ -67,8 +67,7 @@ bool DxgiDuplicatorController::IsCurrentSessionSupported() { return session_id != 0; } -DxgiDuplicatorController::DxgiDuplicatorController() - : refcount_(0) {} +DxgiDuplicatorController::DxgiDuplicatorController() : refcount_(0) {} void DxgiDuplicatorController::AddRef() { int refcount = (++refcount_); @@ -104,13 +103,14 @@ bool DxgiDuplicatorController::RetrieveD3dInfo(D3dInfo* info) { return result; } -DxgiDuplicatorController::Result -DxgiDuplicatorController::Duplicate(DxgiFrame* frame) { +DxgiDuplicatorController::Result DxgiDuplicatorController::Duplicate( + DxgiFrame* frame) { return DoDuplicate(frame, -1); } -DxgiDuplicatorController::Result -DxgiDuplicatorController::DuplicateMonitor(DxgiFrame* frame, int monitor_id) { +DxgiDuplicatorController::Result DxgiDuplicatorController::DuplicateMonitor( + DxgiFrame* frame, + int monitor_id) { RTC_DCHECK_GE(monitor_id, 0); return DoDuplicate(frame, monitor_id); } @@ -141,8 +141,9 @@ bool DxgiDuplicatorController::GetDeviceNames( return false; } -DxgiDuplicatorController::Result -DxgiDuplicatorController::DoDuplicate(DxgiFrame* frame, int monitor_id) { +DxgiDuplicatorController::Result DxgiDuplicatorController::DoDuplicate( + DxgiFrame* frame, + int monitor_id) { RTC_DCHECK(frame); rtc::CritScope lock(&lock_); @@ -443,8 +444,8 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, // |fallback_frame|. shared_frame = target; } else { - fallback_frame = SharedDesktopFrame::Wrap(std::unique_ptr( - new BasicDesktopFrame(desktop_size()))); + fallback_frame = SharedDesktopFrame::Wrap( + std::unique_ptr(new BasicDesktopFrame(desktop_size()))); shared_frame = fallback_frame.get(); } @@ -454,8 +455,7 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, if (GetNumFramesCaptured() > 0) { // Sleep |ms_per_frame| before capturing next frame to ensure the screen // has been updated by the video adapter. - webrtc::SleepMs( - ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms)); + webrtc::SleepMs(ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms)); } last_frame_start_ms = rtc::TimeMillis(); if (!DoDuplicateAll(context, shared_frame)) { diff --git a/modules/desktop_capture/win/dxgi_frame.cc b/modules/desktop_capture/win/dxgi_frame.cc index b51fcca73c..85d708c82c 100644 --- a/modules/desktop_capture/win/dxgi_frame.cc +++ b/modules/desktop_capture/win/dxgi_frame.cc @@ -21,8 +21,7 @@ namespace webrtc { -DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) - : factory_(factory) {} +DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) : factory_(factory) {} DxgiFrame::~DxgiFrame() = default; diff --git a/modules/desktop_capture/win/dxgi_frame.h b/modules/desktop_capture/win/dxgi_frame.h index 49f2320c31..c87f42e01e 100644 --- a/modules/desktop_capture/win/dxgi_frame.h +++ b/modules/desktop_capture/win/dxgi_frame.h @@ -14,8 +14,8 @@ #include #include -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_types.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_geometry.h" #include "modules/desktop_capture/resolution_tracker.h" #include "modules/desktop_capture/shared_desktop_frame.h" diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.cc b/modules/desktop_capture/win/dxgi_output_duplicator.cc index 4675b0748a..f1f6f42066 100644 --- a/modules/desktop_capture/win/dxgi_output_duplicator.cc +++ b/modules/desktop_capture/win/dxgi_output_duplicator.cc @@ -12,10 +12,10 @@ #include -#include #include #include #include +#include #include @@ -177,9 +177,7 @@ bool DxgiOutputDuplicator::Duplicate(Context* context, // context here. The |updated_region| always starts from (0, 0). DesktopRegion updated_region; updated_region.Swap(&context->updated_region); - if (error.Error() == S_OK && - frame_info.AccumulatedFrames > 0 && - resource) { + if (error.Error() == S_OK && frame_info.AccumulatedFrames > 0 && resource) { DetectUpdatedRegion(frame_info, &context->updated_region); SpreadContextChange(context); if (!texture_->CopyFrom(frame_info, resource.Get())) { @@ -195,8 +193,8 @@ bool DxgiOutputDuplicator::Duplicate(Context* context, it.Advance()) { // The |updated_region| returned by Windows is rotated, but the |source| // frame is not. So we need to rotate it reversely. - const DesktopRect source_rect = RotateRect( - it.rect(), desktop_size(), ReverseRotation(rotation_)); + const DesktopRect source_rect = + RotateRect(it.rect(), desktop_size(), ReverseRotation(rotation_)); RotateDesktopFrame(source, source_rect, rotation_, offset, target); } } else { diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.h b/modules/desktop_capture/win/dxgi_output_duplicator.h index 3f10533a22..d2a019d35b 100644 --- a/modules/desktop_capture/win/dxgi_output_duplicator.h +++ b/modules/desktop_capture/win/dxgi_output_duplicator.h @@ -11,10 +11,10 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_ #define MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_ -#include -#include #include #include +#include +#include #include #include diff --git a/modules/desktop_capture/win/dxgi_texture.cc b/modules/desktop_capture/win/dxgi_texture.cc index 8f1d034a06..c8081fb69e 100644 --- a/modules/desktop_capture/win/dxgi_texture.cc +++ b/modules/desktop_capture/win/dxgi_texture.cc @@ -10,9 +10,9 @@ #include "modules/desktop_capture/win/dxgi_texture.h" +#include #include #include -#include #include "modules/desktop_capture/desktop_region.h" #include "rtc_base/checks.h" diff --git a/modules/desktop_capture/win/dxgi_texture_mapping.cc b/modules/desktop_capture/win/dxgi_texture_mapping.cc index dfe8259dd0..01bcabafc7 100644 --- a/modules/desktop_capture/win/dxgi_texture_mapping.cc +++ b/modules/desktop_capture/win/dxgi_texture_mapping.cc @@ -10,9 +10,9 @@ #include "modules/desktop_capture/win/dxgi_texture_mapping.h" -#include #include #include +#include #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/modules/desktop_capture/win/dxgi_texture_staging.cc b/modules/desktop_capture/win/dxgi_texture_staging.cc index e3e915726e..f2b3583320 100644 --- a/modules/desktop_capture/win/dxgi_texture_staging.cc +++ b/modules/desktop_capture/win/dxgi_texture_staging.cc @@ -10,10 +10,10 @@ #include "modules/desktop_capture/win/dxgi_texture_staging.h" -#include -#include #include #include +#include +#include #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -45,8 +45,8 @@ bool DxgiTextureStaging::InitializeStage(ID3D11Texture2D* texture) { AssertStageAndSurfaceAreSameObject(); D3D11_TEXTURE2D_DESC current_desc; stage_->GetDesc(¤t_desc); - const bool recreate_needed = ( - memcmp(&desc, ¤t_desc, sizeof(D3D11_TEXTURE2D_DESC)) != 0); + const bool recreate_needed = + (memcmp(&desc, ¤t_desc, sizeof(D3D11_TEXTURE2D_DESC)) != 0); RTC_HISTOGRAM_BOOLEAN("WebRTC.DesktopCapture.StagingTextureRecreate", recreate_needed); if (!recreate_needed) { diff --git a/modules/desktop_capture/win/dxgi_texture_staging.h b/modules/desktop_capture/win/dxgi_texture_staging.h index 65d56baed2..998b79f8a4 100644 --- a/modules/desktop_capture/win/dxgi_texture_staging.h +++ b/modules/desktop_capture/win/dxgi_texture_staging.h @@ -11,9 +11,9 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_STAGING_H_ #define MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_STAGING_H_ -#include #include #include +#include #include "modules/desktop_capture/desktop_geometry.h" #include "modules/desktop_capture/desktop_region.h" diff --git a/modules/desktop_capture/win/scoped_gdi_object.h b/modules/desktop_capture/win/scoped_gdi_object.h index 60a8b5ca8e..cc6299c541 100644 --- a/modules/desktop_capture/win/scoped_gdi_object.h +++ b/modules/desktop_capture/win/scoped_gdi_object.h @@ -20,19 +20,15 @@ namespace webrtc { namespace win { // Scoper for GDI objects. -template +template class ScopedGDIObject { public: ScopedGDIObject() : handle_(NULL) {} explicit ScopedGDIObject(T object) : handle_(object) {} - ~ScopedGDIObject() { - Traits::Close(handle_); - } + ~ScopedGDIObject() { Traits::Close(handle_); } - T Get() { - return handle_; - } + T Get() { return handle_; } void Set(T object) { if (handle_ && object != handle_) diff --git a/modules/desktop_capture/win/scoped_thread_desktop.cc b/modules/desktop_capture/win/scoped_thread_desktop.cc index bbc00efbbb..22e8e7bc8f 100644 --- a/modules/desktop_capture/win/scoped_thread_desktop.cc +++ b/modules/desktop_capture/win/scoped_thread_desktop.cc @@ -15,8 +15,7 @@ namespace webrtc { ScopedThreadDesktop::ScopedThreadDesktop() - : initial_(Desktop::GetThreadDesktop()) { -} + : initial_(Desktop::GetThreadDesktop()) {} ScopedThreadDesktop::~ScopedThreadDesktop() { Revert(); diff --git a/modules/desktop_capture/win/screen_capture_utils.cc b/modules/desktop_capture/win/screen_capture_utils.cc index 948adc8d45..e294497e55 100644 --- a/modules/desktop_capture/win/screen_capture_utils.cc +++ b/modules/desktop_capture/win/screen_capture_utils.cc @@ -95,15 +95,14 @@ DesktopRect GetScreenRect(DesktopCapturer::SourceId screen, DEVMODE device_mode; device_mode.dmSize = sizeof(device_mode); device_mode.dmDriverExtra = 0; - result = EnumDisplaySettingsEx( - device.DeviceName, ENUM_CURRENT_SETTINGS, &device_mode, 0); + result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS, + &device_mode, 0); if (!result) return DesktopRect(); - return DesktopRect::MakeXYWH(device_mode.dmPosition.x, - device_mode.dmPosition.y, - device_mode.dmPelsWidth, - device_mode.dmPelsHeight); + return DesktopRect::MakeXYWH( + device_mode.dmPosition.x, device_mode.dmPosition.y, + device_mode.dmPelsWidth, device_mode.dmPelsHeight); } } // namespace webrtc diff --git a/modules/desktop_capture/win/screen_capture_utils.h b/modules/desktop_capture/win/screen_capture_utils.h index 2e7d1fff16..f494dd2176 100644 --- a/modules/desktop_capture/win/screen_capture_utils.h +++ b/modules/desktop_capture/win/screen_capture_utils.h @@ -11,8 +11,8 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_ #define MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_ -#include #include +#include #include "modules/desktop_capture/desktop_capturer.h" diff --git a/modules/desktop_capture/win/screen_capture_utils_unittest.cc b/modules/desktop_capture/win/screen_capture_utils_unittest.cc index b9dbf3d05b..a71c4f7610 100644 --- a/modules/desktop_capture/win/screen_capture_utils_unittest.cc +++ b/modules/desktop_capture/win/screen_capture_utils_unittest.cc @@ -10,8 +10,8 @@ #include "modules/desktop_capture/win/screen_capture_utils.h" -#include #include +#include #include "modules/desktop_capture/desktop_capturer.h" #include "test/gtest.h" diff --git a/modules/desktop_capture/win/screen_capturer_win_directx.cc b/modules/desktop_capture/win/screen_capturer_win_directx.cc index 807acc6bfd..0432bfbab4 100644 --- a/modules/desktop_capture/win/screen_capturer_win_directx.cc +++ b/modules/desktop_capture/win/screen_capturer_win_directx.cc @@ -65,14 +65,13 @@ bool ScreenCapturerWinDirectx::GetScreenListFromDeviceNames( } for (const auto& device_name : device_names) { - const auto it = std::find( - gdi_names.begin(), gdi_names.end(), device_name); + const auto it = std::find(gdi_names.begin(), gdi_names.end(), device_name); if (it == gdi_names.end()) { // devices_names[i] has not been found in gdi_names, so use max_screen_id. max_screen_id++; - screens->push_back({ max_screen_id }); + screens->push_back({max_screen_id}); } else { - screens->push_back({ gdi_screens[it - gdi_names.begin()] }); + screens->push_back({gdi_screens[it - gdi_names.begin()]}); } } @@ -132,8 +131,8 @@ void ScreenCapturerWinDirectx::CaptureFrame() { if (current_screen_id_ == kFullDesktopScreenId) { result = controller_->Duplicate(frames_.current_frame()); } else { - result = controller_->DuplicateMonitor( - frames_.current_frame(), current_screen_id_); + result = controller_->DuplicateMonitor(frames_.current_frame(), + current_screen_id_); } using DuplicateResult = DxgiDuplicatorController::Result; @@ -170,9 +169,8 @@ void ScreenCapturerWinDirectx::CaptureFrame() { case DuplicateResult::SUCCEEDED: { std::unique_ptr frame = frames_.current_frame()->frame()->Share(); - frame->set_capture_time_ms( - (rtc::TimeNanos() - capture_start_time_nanos) / - rtc::kNumNanosecsPerMillisec); + frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / + rtc::kNumNanosecsPerMillisec); frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinDirectx); callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); break; diff --git a/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc b/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc index d07a6482ee..5874cb820e 100644 --- a/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc +++ b/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc @@ -10,8 +10,8 @@ #include "modules/desktop_capture/win/screen_capturer_win_directx.h" -#include #include +#include #include "modules/desktop_capture/desktop_capturer.h" #include "test/gtest.h" @@ -22,9 +22,7 @@ namespace webrtc { // devices in its output, since the device name is missing. TEST(ScreenCaptureUtilsTest, GetScreenListFromDeviceNamesAndGetIndex) { const std::vector device_names = { - "\\\\.\\DISPLAY0", - "\\\\.\\DISPLAY1", - "\\\\.\\DISPLAY2", + "\\\\.\\DISPLAY0", "\\\\.\\DISPLAY1", "\\\\.\\DISPLAY2", }; DesktopCapturer::SourceList screens; ASSERT_TRUE(ScreenCapturerWinDirectx::GetScreenListFromDeviceNames( @@ -32,8 +30,8 @@ TEST(ScreenCaptureUtilsTest, GetScreenListFromDeviceNamesAndGetIndex) { ASSERT_EQ(device_names.size(), screens.size()); for (size_t i = 0; i < screens.size(); i++) { - ASSERT_EQ(ScreenCapturerWinDirectx::GetIndexFromScreenId( - screens[i].id, device_names), + ASSERT_EQ(ScreenCapturerWinDirectx::GetIndexFromScreenId(screens[i].id, + device_names), static_cast(i)); } } diff --git a/modules/desktop_capture/win/screen_capturer_win_gdi.cc b/modules/desktop_capture/win/screen_capturer_win_gdi.cc index 25aa0d110b..03f8340bbc 100644 --- a/modules/desktop_capture/win/screen_capturer_win_gdi.cc +++ b/modules/desktop_capture/win/screen_capturer_win_gdi.cc @@ -88,14 +88,12 @@ void ScreenCapturerWinGdi::CaptureFrame() { // Emit the current frame. std::unique_ptr frame = queue_.current_frame()->Share(); - frame->set_dpi(DesktopVector( - GetDeviceCaps(desktop_dc_, LOGPIXELSX), - GetDeviceCaps(desktop_dc_, LOGPIXELSY))); + frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), + GetDeviceCaps(desktop_dc_, LOGPIXELSY))); frame->mutable_updated_region()->SetRect( DesktopRect::MakeSize(frame->size())); - frame->set_capture_time_ms( - (rtc::TimeNanos() - capture_start_time_nanos) / - rtc::kNumNanosecsPerMillisec); + frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / + rtc::kNumNanosecsPerMillisec); frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinGdi); callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); } @@ -216,8 +214,8 @@ bool ScreenCapturerWinGdi::CaptureImage() { } bool result = (BitBlt(memory_dc_, 0, 0, screen_rect.width(), - screen_rect.height(), desktop_dc_, screen_rect.left(), screen_rect.top(), - SRCCOPY | CAPTUREBLT) != FALSE); + screen_rect.height(), desktop_dc_, screen_rect.left(), + screen_rect.top(), SRCCOPY | CAPTUREBLT) != FALSE); if (!result) { RTC_LOG_GLE(LS_WARNING) << "BitBlt failed"; } diff --git a/modules/desktop_capture/win/screen_capturer_win_gdi.h b/modules/desktop_capture/win/screen_capturer_win_gdi.h index 2e30d59e0b..be4794efd8 100644 --- a/modules/desktop_capture/win/screen_capturer_win_gdi.h +++ b/modules/desktop_capture/win/screen_capturer_win_gdi.h @@ -44,7 +44,7 @@ class ScreenCapturerWinGdi : public DesktopCapturer { bool SelectSource(SourceId id) override; private: - typedef HRESULT (WINAPI * DwmEnableCompositionFunc)(UINT); + typedef HRESULT(WINAPI* DwmEnableCompositionFunc)(UINT); // Make sure that the device contexts match the screen configuration. void PrepareCaptureResources(); diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.cc b/modules/desktop_capture/win/screen_capturer_win_magnifier.cc index d52b028814..c7b07d15b8 100644 --- a/modules/desktop_capture/win/screen_capturer_win_magnifier.cc +++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.cc @@ -136,8 +136,8 @@ bool ScreenCapturerWinMagnifier::SelectSource(SourceId id) { void ScreenCapturerWinMagnifier::SetExcludedWindow(WindowId excluded_window) { excluded_window_ = (HWND)excluded_window; if (excluded_window_ && magnifier_initialized_) { - set_window_filter_list_func_( - magnifier_window_, MW_FILTERMODE_EXCLUDE, 1, &excluded_window_); + set_window_filter_list_func_(magnifier_window_, MW_FILTERMODE_EXCLUDE, 1, + &excluded_window_); } } @@ -186,8 +186,7 @@ BOOL ScreenCapturerWinMagnifier::OnMagImageScalingCallback( RECT clipped, HRGN dirty) { ScreenCapturerWinMagnifier* owner = - reinterpret_cast( - TlsGetValue(GetTlsIndex())); + reinterpret_cast(TlsGetValue(GetTlsIndex())); TlsSetValue(GetTlsIndex(), nullptr); owner->OnCaptured(srcdata, srcheader); @@ -243,10 +242,10 @@ bool ScreenCapturerWinMagnifier::InitializeMagnifier() { } HMODULE hInstance = nullptr; - result = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(&DefWindowProc), - &hInstance); + result = + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + reinterpret_cast(&DefWindowProc), &hInstance); if (!result) { mag_uninitialize_func_(); RTC_LOG_F(LS_WARNING) << "Failed to initialize ScreenCapturerWinMagnifier: " @@ -346,8 +345,7 @@ void ScreenCapturerWinMagnifier::OnCaptured(void* data, // Copy the data into the frame. current_frame->CopyPixelsFrom( - reinterpret_cast(data), - header.stride, + reinterpret_cast(data), header.stride, DesktopRect::MakeXYWH(0, 0, header.width, header.height)); magnifier_capture_succeeded_ = true; diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.h b/modules/desktop_capture/win/screen_capturer_win_magnifier.h index d994b1e059..28f29bce15 100644 --- a/modules/desktop_capture/win/screen_capturer_win_magnifier.h +++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.h @@ -13,9 +13,9 @@ #include -#include #include #include +#include #include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/screen_capture_frame_queue.h" diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc index 219024813a..4c5489fa71 100644 --- a/modules/desktop_capture/win/window_capture_utils.cc +++ b/modules/desktop_capture/win/window_capture_utils.cc @@ -25,8 +25,7 @@ bool GetWindowRect(HWND window, DesktopRect* result) { if (!::GetWindowRect(window, &rect)) { return false; } - *result = DesktopRect::MakeLTRB( - rect.left, rect.top, rect.right, rect.bottom); + *result = DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom); return true; } @@ -97,22 +96,22 @@ bool GetWindowContentRect(HWND window, DesktopRect* result) { } int GetWindowRegionTypeWithBoundary(HWND window, DesktopRect* result) { - win::ScopedGDIObject> - scoped_hrgn(CreateRectRgn(0, 0, 0, 0)); + win::ScopedGDIObject> scoped_hrgn( + CreateRectRgn(0, 0, 0, 0)); const int region_type = GetWindowRgn(window, scoped_hrgn.Get()); if (region_type == SIMPLEREGION) { RECT rect; GetRgnBox(scoped_hrgn.Get(), &rect); - *result = DesktopRect::MakeLTRB( - rect.left, rect.top, rect.right, rect.bottom); + *result = + DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom); } return region_type; } bool GetDcSize(HDC hdc, DesktopSize* size) { - win::ScopedGDIObject> - scoped_hgdi(GetCurrentObject(hdc, OBJ_BITMAP)); + win::ScopedGDIObject> scoped_hgdi( + GetCurrentObject(hdc, OBJ_BITMAP)); BITMAP bitmap; memset(&bitmap, 0, sizeof(BITMAP)); if (GetObject(scoped_hgdi.Get(), sizeof(BITMAP), &bitmap) == 0) { diff --git a/modules/desktop_capture/win/window_capture_utils.h b/modules/desktop_capture/win/window_capture_utils.h index eb4f945dcd..024c7eb860 100644 --- a/modules/desktop_capture/win/window_capture_utils.h +++ b/modules/desktop_capture/win/window_capture_utils.h @@ -59,7 +59,7 @@ bool GetDcSize(HDC hdc, DesktopSize* size); // function returns false if native APIs fail. bool IsWindowMaximized(HWND window, bool* result); -typedef HRESULT (WINAPI *DwmIsCompositionEnabledFunc)(BOOL* enabled); +typedef HRESULT(WINAPI* DwmIsCompositionEnabledFunc)(BOOL* enabled); class WindowCaptureHelperWin { public: WindowCaptureHelperWin(); diff --git a/modules/desktop_capture/window_capturer_unittest.cc b/modules/desktop_capture/window_capturer_unittest.cc index 0c31fb7823..ac51d15c7a 100644 --- a/modules/desktop_capture/window_capturer_unittest.cc +++ b/modules/desktop_capture/window_capturer_unittest.cc @@ -10,8 +10,8 @@ #include -#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" +#include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_frame.h" #include "modules/desktop_capture/desktop_region.h" #include "test/gtest.h" diff --git a/modules/desktop_capture/window_capturer_win.cc b/modules/desktop_capture/window_capturer_win.cc index 1b59af6891..f345a5e2e4 100644 --- a/modules/desktop_capture/window_capturer_win.cc +++ b/modules/desktop_capture/window_capturer_win.cc @@ -104,8 +104,8 @@ bool GetWindowDrawableRect(HWND window, } if (is_maximized) { - return GetCroppedWindowRect( - window, drawable_rect, /* original_rect */ nullptr); + return GetCroppedWindowRect(window, drawable_rect, + /* original_rect */ nullptr); } *drawable_rect = *original_rect; return true; @@ -198,8 +198,8 @@ bool WindowCapturerWin::FocusOnSelectedSource() { bool WindowCapturerWin::IsOccluded(const DesktopVector& pos) { DesktopVector sys_pos = pos.add(GetFullscreenRect().top_left()); - return reinterpret_cast(window_finder_.GetWindowUnderPoint(sys_pos)) - != window_; + return reinterpret_cast(window_finder_.GetWindowUnderPoint(sys_pos)) != + window_; } void WindowCapturerWin::Start(Callback* callback) { @@ -317,10 +317,8 @@ void WindowCapturerWin::CaptureFrame() { // Aero is enabled or PrintWindow() failed, use BitBlt. if (!result) { result = BitBlt(mem_dc, 0, 0, frame->size().width(), frame->size().height(), - window_dc, - cropped_rect.left() - original_rect.left(), - cropped_rect.top() - original_rect.top(), - SRCCOPY); + window_dc, cropped_rect.left() - original_rect.left(), + cropped_rect.top() - original_rect.top(), SRCCOPY); } SelectObject(mem_dc, previous_object); diff --git a/modules/desktop_capture/window_capturer_x11.cc b/modules/desktop_capture/window_capturer_x11.cc index 5536b6a2d9..c4ca3ae5e8 100644 --- a/modules/desktop_capture/window_capturer_x11.cc +++ b/modules/desktop_capture/window_capturer_x11.cc @@ -10,9 +10,9 @@ #include +#include #include #include -#include #include @@ -93,15 +93,14 @@ WindowCapturerLinux::~WindowCapturerLinux() { } bool WindowCapturerLinux::GetSourceList(SourceList* sources) { - return GetWindowList(&atom_cache_, - [this, sources](::Window window) { - Source w; - w.id = window; - if (this->GetWindowTitle(window, &w.title)) { - sources->push_back(w); - } - return true; - }); + return GetWindowList(&atom_cache_, [this, sources](::Window window) { + Source w; + w.id = window; + if (this->GetWindowTitle(window, &w.title)) { + sources->push_back(w); + } + return true; + }); } bool WindowCapturerLinux::SelectSource(SourceId id) { @@ -134,8 +133,8 @@ bool WindowCapturerLinux::FocusOnSelectedSource() { ::Window parent; ::Window root; // Find the root window to pass event to. - int status = XQueryTree( - display(), selected_window_, &root, &parent, &children, &num_children); + int status = XQueryTree(display(), selected_window_, &root, &parent, + &children, &num_children); if (status == 0) { RTC_LOG(LS_ERROR) << "Failed to query for the root window."; return false; @@ -164,11 +163,8 @@ bool WindowCapturerLinux::FocusOnSelectedSource() { memset(xev.xclient.data.l, 0, sizeof(xev.xclient.data.l)); - XSendEvent(display(), - root, - False, - SubstructureRedirectMask | SubstructureNotifyMask, - &xev); + XSendEvent(display(), root, False, + SubstructureRedirectMask | SubstructureNotifyMask, &xev); } XFlush(display()); return true; @@ -229,7 +225,7 @@ void WindowCapturerLinux::CaptureFrame() { bool WindowCapturerLinux::IsOccluded(const DesktopVector& pos) { return window_finder_.GetWindowUnderPoint(pos) != - static_cast(selected_window_); + static_cast(selected_window_); } bool WindowCapturerLinux::HandleXEvent(const XEvent& event) { @@ -237,7 +233,7 @@ bool WindowCapturerLinux::HandleXEvent(const XEvent& event) { XConfigureEvent xce = event.xconfigure; if (xce.window == selected_window_) { if (!DesktopRectFromXAttributes(xce).equals( - x_server_pixel_buffer_.window_rect())) { + x_server_pixel_buffer_.window_rect())) { if (!x_server_pixel_buffer_.Init(display(), selected_window_)) { RTC_LOG(LS_ERROR) << "Failed to initialize pixel buffer after resizing."; @@ -260,8 +256,8 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) { if (status && window_name.value && window_name.nitems) { int cnt; char** list = nullptr; - status = Xutf8TextPropertyToTextList(display(), &window_name, &list, - &cnt); + status = + Xutf8TextPropertyToTextList(display(), &window_name, &list, &cnt); if (status >= Success && cnt && *list) { if (cnt > 1) { RTC_LOG(LS_INFO) << "Window has " << cnt diff --git a/modules/desktop_capture/window_finder_unittest.cc b/modules/desktop_capture/window_finder_unittest.cc index ccbc46956a..70f0d864c9 100644 --- a/modules/desktop_capture/window_finder_unittest.cc +++ b/modules/desktop_capture/window_finder_unittest.cc @@ -28,8 +28,8 @@ #if defined(WEBRTC_WIN) #include -#include "modules/desktop_capture/window_finder_win.h" #include "modules/desktop_capture/win/window_capture_utils.h" +#include "modules/desktop_capture/window_finder_win.h" #endif namespace webrtc { @@ -64,8 +64,8 @@ TEST(WindowFinderTest, FindConsoleWindow) { MoveWindow(console_window, 0, 0, kMaxSize, kMaxSize, true); // Brings console window to top. - SetWindowPos( - console_window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(console_window, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE); BringWindowToTop(console_window); WindowFinderWin finder; @@ -154,14 +154,14 @@ TEST(WindowFinderTest, ShouldReturnNullWindowIfSpotIsOutOfScreen) { return; } - ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint( - DesktopVector(INT16_MAX, INT16_MAX))); - ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint( - DesktopVector(INT16_MAX, INT16_MIN))); - ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint( - DesktopVector(INT16_MIN, INT16_MAX))); - ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint( - DesktopVector(INT16_MIN, INT16_MIN))); + ASSERT_EQ(kNullWindowId, + finder->GetWindowUnderPoint(DesktopVector(INT16_MAX, INT16_MAX))); + ASSERT_EQ(kNullWindowId, + finder->GetWindowUnderPoint(DesktopVector(INT16_MAX, INT16_MIN))); + ASSERT_EQ(kNullWindowId, + finder->GetWindowUnderPoint(DesktopVector(INT16_MIN, INT16_MAX))); + ASSERT_EQ(kNullWindowId, + finder->GetWindowUnderPoint(DesktopVector(INT16_MIN, INT16_MIN))); } } // namespace diff --git a/modules/desktop_capture/window_finder_win.cc b/modules/desktop_capture/window_finder_win.cc index 9f87106a30..7c31dea21d 100644 --- a/modules/desktop_capture/window_finder_win.cc +++ b/modules/desktop_capture/window_finder_win.cc @@ -20,7 +20,7 @@ WindowFinderWin::WindowFinderWin() = default; WindowFinderWin::~WindowFinderWin() = default; WindowId WindowFinderWin::GetWindowUnderPoint(DesktopVector point) { - HWND window = WindowFromPoint(POINT { point.x(), point.y() }); + HWND window = WindowFromPoint(POINT{point.x(), point.y()}); if (!window) { return kNullWindowId; } diff --git a/modules/desktop_capture/window_finder_x11.cc b/modules/desktop_capture/window_finder_x11.cc index 3096217e5b..192f929d16 100644 --- a/modules/desktop_capture/window_finder_x11.cc +++ b/modules/desktop_capture/window_finder_x11.cc @@ -16,8 +16,7 @@ namespace webrtc { -WindowFinderX11::WindowFinderX11(XAtomCache* cache) - : cache_(cache) { +WindowFinderX11::WindowFinderX11(XAtomCache* cache) : cache_(cache) { RTC_DCHECK(cache_); } @@ -25,16 +24,15 @@ WindowFinderX11::~WindowFinderX11() = default; WindowId WindowFinderX11::GetWindowUnderPoint(DesktopVector point) { WindowId id = kNullWindowId; - GetWindowList(cache_, - [&id, this, point](::Window window) { - DesktopRect rect; - if (GetWindowRect(this->cache_->display(), window, &rect) && - rect.Contains(point)) { - id = window; - return false; - } - return true; - }); + GetWindowList(cache_, [&id, this, point](::Window window) { + DesktopRect rect; + if (GetWindowRect(this->cache_->display(), window, &rect) && + rect.Contains(point)) { + id = window; + return false; + } + return true; + }); return id; } diff --git a/modules/desktop_capture/x11/shared_x_display.cc b/modules/desktop_capture/x11/shared_x_display.cc index ff2cba5b4a..db6a64b81d 100644 --- a/modules/desktop_capture/x11/shared_x_display.cc +++ b/modules/desktop_capture/x11/shared_x_display.cc @@ -19,8 +19,7 @@ namespace webrtc { -SharedXDisplay::SharedXDisplay(Display* display) - : display_(display) { +SharedXDisplay::SharedXDisplay(Display* display) : display_(display) { RTC_DCHECK(display_); } diff --git a/modules/desktop_capture/x11/window_list_utils.cc b/modules/desktop_capture/x11/window_list_utils.cc index 65c7edffbe..fe070d8878 100644 --- a/modules/desktop_capture/x11/window_list_utils.cc +++ b/modules/desktop_capture/x11/window_list_utils.cc @@ -10,10 +10,10 @@ #include "modules/desktop_capture/x11/window_list_utils.h" -#include -#include #include +#include #include +#include #include @@ -49,10 +49,9 @@ class XWindowProperty { Atom actual_type; int actual_format; unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty - int status = XGetWindowProperty(display, window, property, 0L, ~0L, False, - AnyPropertyType, &actual_type, - &actual_format, &size_, - &bytes_after, &data_); + int status = XGetWindowProperty( + display, window, property, 0L, ~0L, False, AnyPropertyType, + &actual_type, &actual_format, &size_, &bytes_after, &data_); if (status != Success) { data_ = nullptr; return; @@ -78,9 +77,7 @@ class XWindowProperty { const PropertyType* data() const { return reinterpret_cast(data_); } - PropertyType* data() { - return reinterpret_cast(data_); - } + PropertyType* data() { return reinterpret_cast(data_); } private: bool is_valid_ = false; @@ -106,7 +103,7 @@ class XWindowProperty { RTC_DCHECK_EQ(state, WithdrawnState); // If the window is in WithdrawnState then look at all of its children. ::Window root, parent; - ::Window *children; + ::Window* children; unsigned int num_children; if (!XQueryTree(cache->display(), window, &root, &parent, &children, &num_children)) { @@ -137,14 +134,12 @@ bool IsDesktopElement(XAtomCache* cache, ::Window window) { // says this hint *should* be present on all windows, and we use the existence // of _NET_WM_WINDOW_TYPE_NORMAL in the property to indicate a window is not // a desktop element (that is, only "normal" windows should be shareable). - XWindowProperty window_type( - cache->display(), window, cache->WindowType()); + XWindowProperty window_type(cache->display(), window, + cache->WindowType()); if (window_type.is_valid() && window_type.size() > 0) { uint32_t* end = window_type.data() + window_type.size(); - bool is_normal = (end != std::find( - window_type.data(), - end, - cache->WindowTypeNormal())); + bool is_normal = + (end != std::find(window_type.data(), end, cache->WindowTypeNormal())); return !is_normal; } @@ -166,8 +161,8 @@ bool IsDesktopElement(XAtomCache* cache, ::Window window) { int32_t GetWindowState(XAtomCache* cache, ::Window window) { // Get WM_STATE property of the window. - XWindowProperty window_state( - cache->display(), window, cache->WmState()); + XWindowProperty window_state(cache->display(), window, + cache->WmState()); // WM_STATE is considered to be set to WithdrawnState when it missing. return window_state.is_valid() ? *window_state.data() : WithdrawnState; @@ -188,11 +183,7 @@ bool GetWindowList(XAtomCache* cache, unsigned int num_children; { XErrorTrap error_trap(display); - if (XQueryTree(display, - root_window, - &root_window, - &parent, - &children, + if (XQueryTree(display, root_window, &root_window, &parent, &children, &num_children) == 0 || error_trap.GetLastErrorAndDisable() != 0) { failed_screens++; @@ -242,14 +233,8 @@ bool GetWindowRect(::Display* display, { XErrorTrap error_trap(display); ::Window child; - if (!XTranslateCoordinates(display, - window, - attributes->root, - -rect->left(), - -rect->top(), - &offset_x, - &offset_y, - &child) || + if (!XTranslateCoordinates(display, window, attributes->root, -rect->left(), + -rect->top(), &offset_x, &offset_y, &child) || error_trap.GetLastErrorAndDisable() != 0) { return false; } diff --git a/modules/desktop_capture/x11/window_list_utils.h b/modules/desktop_capture/x11/window_list_utils.h index 92571b2ca6..72d2a70d21 100644 --- a/modules/desktop_capture/x11/window_list_utils.h +++ b/modules/desktop_capture/x11/window_list_utils.h @@ -45,9 +45,7 @@ bool GetWindowRect(::Display* display, // Creates a DesktopRect from |attributes|. template DesktopRect DesktopRectFromXAttributes(const T& attributes) { - return DesktopRect::MakeXYWH(attributes.x, - attributes.y, - attributes.width, + return DesktopRect::MakeXYWH(attributes.x, attributes.y, attributes.width, attributes.height); } diff --git a/modules/desktop_capture/x11/x_atom_cache.h b/modules/desktop_capture/x11/x_atom_cache.h index d77d2fb524..5246c2bb5c 100644 --- a/modules/desktop_capture/x11/x_atom_cache.h +++ b/modules/desktop_capture/x11/x_atom_cache.h @@ -11,8 +11,8 @@ #ifndef MODULES_DESKTOP_CAPTURE_X11_X_ATOM_CACHE_H_ #define MODULES_DESKTOP_CAPTURE_X11_X_ATOM_CACHE_H_ -#include #include +#include namespace webrtc { diff --git a/modules/desktop_capture/x11/x_error_trap.cc b/modules/desktop_capture/x11/x_error_trap.cc index a0dbac6c46..6559c3dbe9 100644 --- a/modules/desktop_capture/x11/x_error_trap.cc +++ b/modules/desktop_capture/x11/x_error_trap.cc @@ -37,11 +37,10 @@ int XServerErrorHandler(Display* display, XErrorEvent* error_event) { } // namespace XErrorTrap::XErrorTrap(Display* display) - : original_error_handler_(NULL), - enabled_(true) { + : original_error_handler_(NULL), enabled_(true) { #if defined(TOOLKIT_GTK) gdk_error_trap_push(); -#else // !defined(TOOLKIT_GTK) +#else // !defined(TOOLKIT_GTK) assert(!g_xserver_error_trap_enabled); original_error_handler_ = XSetErrorHandler(&XServerErrorHandler); g_xserver_error_trap_enabled = true; @@ -53,7 +52,7 @@ int XErrorTrap::GetLastErrorAndDisable() { enabled_ = false; #if defined(TOOLKIT_GTK) return gdk_error_trap_push(); -#else // !defined(TOOLKIT_GTK) +#else // !defined(TOOLKIT_GTK) assert(g_xserver_error_trap_enabled); XSetErrorHandler(original_error_handler_); g_xserver_error_trap_enabled = false; diff --git a/modules/desktop_capture/x11/x_server_pixel_buffer.cc b/modules/desktop_capture/x11/x_server_pixel_buffer.cc index ab1b95add4..e327d3fc7d 100644 --- a/modules/desktop_capture/x11/x_server_pixel_buffer.cc +++ b/modules/desktop_capture/x11/x_server_pixel_buffer.cc @@ -52,10 +52,8 @@ uint32_t MaskToShift(uint32_t mask) { // Returns true if |image| is in RGB format. bool IsXImageRGBFormat(XImage* image) { - return image->bits_per_pixel == 32 && - image->red_mask == 0xff0000 && - image->green_mask == 0xff00 && - image->blue_mask == 0xff; + return image->bits_per_pixel == 32 && image->red_mask == 0xff0000 && + image->green_mask == 0xff00 && image->blue_mask == 0xff; } // We expose two forms of blitting to handle variations in the pixel format. @@ -255,11 +253,9 @@ bool XServerPixelBuffer::InitPixmaps(int depth) { { XErrorTrap error_trap(display_); - shm_pixmap_ = XShmCreatePixmap(display_, window_, - shm_segment_info_->shmaddr, - shm_segment_info_, - window_rect_.width(), - window_rect_.height(), depth); + shm_pixmap_ = XShmCreatePixmap( + display_, window_, shm_segment_info_->shmaddr, shm_segment_info_, + window_rect_.width(), window_rect_.height(), depth); XSync(display_, False); if (error_trap.GetLastErrorAndDisable() != 0) { // |shm_pixmap_| is not not valid because the request was not processed @@ -275,8 +271,7 @@ bool XServerPixelBuffer::InitPixmaps(int depth) { shm_gc_values.subwindow_mode = IncludeInferiors; shm_gc_values.graphics_exposures = False; shm_gc_ = XCreateGC(display_, window_, - GCSubwindowMode | GCGraphicsExposures, - &shm_gc_values); + GCSubwindowMode | GCGraphicsExposures, &shm_gc_values); XSync(display_, False); if (error_trap.GetLastErrorAndDisable() != 0) { XFreePixmap(display_, shm_pixmap_); @@ -321,9 +316,9 @@ bool XServerPixelBuffer::CaptureRect(const DesktopRect& rect, if (shm_segment_info_ && (shm_pixmap_ || xshm_get_image_succeeded_)) { if (shm_pixmap_) { - XCopyArea(display_, window_, shm_pixmap_, shm_gc_, - rect.left(), rect.top(), rect.width(), rect.height(), - rect.left(), rect.top()); + XCopyArea(display_, window_, shm_pixmap_, shm_gc_, rect.left(), + rect.top(), rect.width(), rect.height(), rect.left(), + rect.top()); XSync(display_, False); } diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h index 65bb20777a..08b36d1015 100644 --- a/modules/include/module_common_types.h +++ b/modules/include/module_common_types.h @@ -185,8 +185,7 @@ class RTPFragmentationHeader { memset(fragmentationOffset + oldVectorSize, 0, sizeof(size_t) * (size16 - oldVectorSize)); // copy old values - memcpy(fragmentationOffset, oldOffsets, - sizeof(size_t) * oldVectorSize); + memcpy(fragmentationOffset, oldOffsets, sizeof(size_t) * oldVectorSize); delete[] oldOffsets; } // length @@ -195,8 +194,7 @@ class RTPFragmentationHeader { fragmentationLength = new size_t[size16]; memset(fragmentationLength + oldVectorSize, 0, sizeof(size_t) * (size16 - oldVectorSize)); - memcpy(fragmentationLength, oldLengths, - sizeof(size_t) * oldVectorSize); + memcpy(fragmentationLength, oldLengths, sizeof(size_t) * oldVectorSize); delete[] oldLengths; } // time diff diff --git a/modules/include/module_common_types_public.h b/modules/include/module_common_types_public.h index 2fbb49ae9c..f1ae3de462 100644 --- a/modules/include/module_common_types_public.h +++ b/modules/include/module_common_types_public.h @@ -68,9 +68,7 @@ class Unwrapper { } // Only update the internal state to the specified last (unwrapped) value. - void UpdateLast(int64_t last_value) { - last_value_ = last_value; - } + void UpdateLast(int64_t last_value) { last_value_ = last_value; } // Unwrap the value and update the internal state. int64_t Unwrap(U value) { diff --git a/modules/module_common_types_unittest.cc b/modules/module_common_types_unittest.cc index 3045c0dc6a..8289bea17f 100644 --- a/modules/module_common_types_unittest.cc +++ b/modules/module_common_types_unittest.cc @@ -112,7 +112,6 @@ TEST(LatestTimestamp, Wrap) { EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0xFFFF0000, 0x0000FFFF)); } - TEST(SequenceNumberUnwrapper, Limits) { SequenceNumberUnwrapper unwrapper; diff --git a/modules/pacing/alr_detector.cc b/modules/pacing/alr_detector.cc index 17fae297d5..1d16a71e67 100644 --- a/modules/pacing/alr_detector.cc +++ b/modules/pacing/alr_detector.cc @@ -11,8 +11,8 @@ #include "modules/pacing/alr_detector.h" #include -#include #include +#include #include "logging/rtc_event_log/events/rtc_event_alr_state.h" #include "logging/rtc_event_log/rtc_event_log.h" diff --git a/modules/pacing/bitrate_prober.cc b/modules/pacing/bitrate_prober.cc index 7f60207f3e..345855bd9c 100644 --- a/modules/pacing/bitrate_prober.cc +++ b/modules/pacing/bitrate_prober.cc @@ -124,9 +124,9 @@ int BitrateProber::TimeUntilNextProbe(int64_t now_ms) { if (next_probe_time_ms_ >= 0) { time_until_probe_ms = next_probe_time_ms_ - now_ms; if (time_until_probe_ms < -kMaxProbeDelayMs) { - RTC_LOG(LS_WARNING)<<"Probe delay too high"<< - " (next_ms:"< #include #include -#include #include +#include #include "modules/include/module_common_types.h" #include "modules/pacing/alr_detector.h" @@ -194,9 +194,9 @@ void PacedSender::InsertPacket(RtpPacketSender::Priority priority, if (capture_time_ms < 0) capture_time_ms = now_ms; - packets_->Push(PacketQueueInterface::Packet(priority, ssrc, sequence_number, - capture_time_ms, now_ms, bytes, - retransmission, packet_counter_++)); + packets_->Push(PacketQueueInterface::Packet( + priority, ssrc, sequence_number, capture_time_ms, now_ms, bytes, + retransmission, packet_counter_++)); } void PacedSender::SetAccountForAudioPackets(bool account_for_audio) { diff --git a/modules/pacing/paced_sender_unittest.cc b/modules/pacing/paced_sender_unittest.cc index fa55e216bc..fb79ebcbaf 100644 --- a/modules/pacing/paced_sender_unittest.cc +++ b/modules/pacing/paced_sender_unittest.cc @@ -411,20 +411,12 @@ TEST_F(PacedSenderTest, CanQueuePacketsWithSameSequenceNumberOnDifferentSsrcs) { uint32_t ssrc = 12345; uint16_t sequence_number = 1234; - SendAndExpectPacket(PacedSender::kNormalPriority, - ssrc, - sequence_number, - clock_.TimeInMilliseconds(), - 250, - false); + SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number, + clock_.TimeInMilliseconds(), 250, false); // Expect packet on second ssrc to be queued and sent as well. - SendAndExpectPacket(PacedSender::kNormalPriority, - ssrc + 1, - sequence_number, - clock_.TimeInMilliseconds(), - 250, - false); + SendAndExpectPacket(PacedSender::kNormalPriority, ssrc + 1, sequence_number, + clock_.TimeInMilliseconds(), 250, false); clock_.AdvanceTimeMilliseconds(1000); send_bucket_->Process(); @@ -504,12 +496,8 @@ TEST_F(PacedSenderTest, VerifyPaddingUpToBitrate) { int64_t start_time = clock_.TimeInMilliseconds(); while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) { - SendAndExpectPacket(PacedSender::kNormalPriority, - ssrc, - sequence_number++, - capture_time_ms, - 250, - false); + SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, + capture_time_ms, 250, false); EXPECT_CALL(callback_, TimeToSendPadding(250, _)) .Times(1) .WillOnce(Return(250)); @@ -1050,12 +1038,8 @@ TEST_F(PacedSenderTest, QueueTimeGrowsOverTime) { EXPECT_EQ(0, send_bucket_->QueueInMs()); send_bucket_->SetPacingRates(30000 * kPaceMultiplier, 0); - SendAndExpectPacket(PacedSender::kNormalPriority, - ssrc, - sequence_number, - clock_.TimeInMilliseconds(), - 1200, - false); + SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number, + clock_.TimeInMilliseconds(), 1200, false); clock_.AdvanceTimeMilliseconds(500); EXPECT_EQ(500, send_bucket_->QueueInMs()); diff --git a/modules/pacing/packet_router_unittest.cc b/modules/pacing/packet_router_unittest.cc index 34b533bbe4..3da134a804 100644 --- a/modules/pacing/packet_router_unittest.cc +++ b/modules/pacing/packet_router_unittest.cc @@ -234,11 +234,10 @@ TEST(PacketRouterTest, TimeToSendPadding) { EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes, _)).Times(0); EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false)); EXPECT_CALL(rtp_2, TimeToSendPadding(_, _)).Times(0); - EXPECT_EQ(0u, - packet_router.TimeToSendPadding( - requested_padding_bytes, - PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, - kProbeMinBytes))); + EXPECT_EQ(0u, packet_router.TimeToSendPadding( + requested_padding_bytes, + PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, + kProbeMinBytes))); // Only one module has BWE extensions. EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); @@ -262,11 +261,10 @@ TEST(PacketRouterTest, TimeToSendPadding) { EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true)); EXPECT_CALL(rtp_2, HasBweExtensions()).Times(1).WillOnce(Return(true)); EXPECT_CALL(rtp_2, TimeToSendPadding(requested_padding_bytes, _)).Times(1); - EXPECT_EQ(0u, - packet_router.TimeToSendPadding( - requested_padding_bytes, - PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, - kProbeMinBytes))); + EXPECT_EQ(0u, packet_router.TimeToSendPadding( + requested_padding_bytes, + PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, + kProbeMinBytes))); packet_router.RemoveSendRtpModule(&rtp_2); } @@ -360,14 +358,14 @@ TEST(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) { // Verify that TimeToSendPacket does not end up in a receiver. EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _, _)).Times(0); EXPECT_TRUE(packet_router.TimeToSendPacket( - kSsrc, 1, 1, false, PacedPacketInfo(PacedPacketInfo::kNotAProbe, - kProbeMinBytes, kProbeMinBytes))); + kSsrc, 1, 1, false, + PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, + kProbeMinBytes))); // Verify that TimeToSendPadding does not end up in a receiver. EXPECT_CALL(rtp, TimeToSendPadding(_, _)).Times(0); - EXPECT_EQ(0u, - packet_router.TimeToSendPadding( - 200, PacedPacketInfo(PacedPacketInfo::kNotAProbe, - kProbeMinBytes, kProbeMinBytes))); + EXPECT_EQ(0u, packet_router.TimeToSendPadding( + 200, PacedPacketInfo(PacedPacketInfo::kNotAProbe, + kProbeMinBytes, kProbeMinBytes))); packet_router.RemoveSendRtpModule(&rtp); } diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 949cc6af1a..8be5e49834 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -114,7 +114,7 @@ bool AimdRateControl::TimeToReduceFurther(int64_t time_now, if (ValidEstimate()) { // TODO(terelius/holmer): Investigate consequences of increasing // the threshold to 0.95 * LatestEstimate(). - const uint32_t threshold = static_cast (0.5 * LatestEstimate()); + const uint32_t threshold = static_cast(0.5 * LatestEstimate()); return incoming_bitrate_bps < threshold; } return false; @@ -206,8 +206,8 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f; // Calculate the max bit rate std dev given the normalized // variance and the current incoming bit rate. - const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ * - avg_max_bitrate_kbps_); + const float std_max_bit_rate = + sqrt(var_max_bitrate_kbps_ * avg_max_bitrate_kbps_); switch (rate_control_state_) { case kRcHold: break; @@ -295,15 +295,17 @@ uint32_t AimdRateControl::ClampBitrate(uint32_t new_bitrate_bps, } uint32_t AimdRateControl::MultiplicativeRateIncrease( - int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const { + int64_t now_ms, + int64_t last_ms, + uint32_t current_bitrate_bps) const { double alpha = 1.08; if (last_ms > -1) { auto time_since_last_update_ms = rtc::SafeMin(now_ms - last_ms, 1000); - alpha = pow(alpha, time_since_last_update_ms / 1000.0); + alpha = pow(alpha, time_since_last_update_ms / 1000.0); } - uint32_t multiplicative_increase_bps = std::max( - current_bitrate_bps * (alpha - 1.0), 1000.0); + uint32_t multiplicative_increase_bps = + std::max(current_bitrate_bps * (alpha - 1.0), 1000.0); return multiplicative_increase_bps; } @@ -318,13 +320,14 @@ void AimdRateControl::UpdateMaxBitRateEstimate(float incoming_bitrate_kbps) { if (avg_max_bitrate_kbps_ == -1.0f) { avg_max_bitrate_kbps_ = incoming_bitrate_kbps; } else { - avg_max_bitrate_kbps_ = (1 - alpha) * avg_max_bitrate_kbps_ + - alpha * incoming_bitrate_kbps; + avg_max_bitrate_kbps_ = + (1 - alpha) * avg_max_bitrate_kbps_ + alpha * incoming_bitrate_kbps; } // Estimate the max bit rate variance and normalize the variance // with the average max bit rate. const float norm = std::max(avg_max_bitrate_kbps_, 1.0f); - var_max_bitrate_kbps_ = (1 - alpha) * var_max_bitrate_kbps_ + + var_max_bitrate_kbps_ = + (1 - alpha) * var_max_bitrate_kbps_ + alpha * (avg_max_bitrate_kbps_ - incoming_bitrate_kbps) * (avg_max_bitrate_kbps_ - incoming_bitrate_kbps) / norm; // 0.4 ~= 14 kbit/s at 500 kbit/s diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.h b/modules/remote_bitrate_estimator/aimd_rate_control.h index c62ad7d60a..4de15d04b9 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -64,7 +64,8 @@ class AimdRateControl { // large compared to the bitrate actually being received by the other end. uint32_t ClampBitrate(uint32_t new_bitrate_bps, uint32_t incoming_bitrate_bps) const; - uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms, + uint32_t MultiplicativeRateIncrease(int64_t now_ms, + int64_t last_ms, uint32_t current_bitrate_bps) const; uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms) const; void UpdateChangePeriod(int64_t now_ms); diff --git a/modules/remote_bitrate_estimator/bwe_simulations.cc b/modules/remote_bitrate_estimator/bwe_simulations.cc index 87106f173a..de6d2d9927 100644 --- a/modules/remote_bitrate_estimator/bwe_simulations.cc +++ b/modules/remote_bitrate_estimator/bwe_simulations.cc @@ -551,4 +551,3 @@ TEST_P(BweSimulation, GoogCcComparisonChoke) { } // namespace bwe } // namespace testing } // namespace webrtc - diff --git a/modules/remote_bitrate_estimator/inter_arrival.cc b/modules/remote_bitrate_estimator/inter_arrival.cc index ef3ca8b624..b779e41797 100644 --- a/modules/remote_bitrate_estimator/inter_arrival.cc +++ b/modules/remote_bitrate_estimator/inter_arrival.cc @@ -51,8 +51,8 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp, } else if (NewTimestampGroup(arrival_time_ms, timestamp)) { // First packet of a later frame, the previous frame sample is ready. if (prev_timestamp_group_.complete_time_ms >= 0) { - *timestamp_delta = current_timestamp_group_.timestamp - - prev_timestamp_group_.timestamp; + *timestamp_delta = + current_timestamp_group_.timestamp - prev_timestamp_group_.timestamp; *arrival_time_delta_ms = current_timestamp_group_.complete_time_ms - prev_timestamp_group_.complete_time_ms; // Check system time differences to see if we have an unproportional jump @@ -86,7 +86,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp, } assert(*arrival_time_delta_ms >= 0); *packet_size_delta = static_cast(current_timestamp_group_.size) - - static_cast(prev_timestamp_group_.size); + static_cast(prev_timestamp_group_.size); calculated_deltas = true; } prev_timestamp_group_ = current_timestamp_group_; @@ -95,8 +95,8 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp, current_timestamp_group_.timestamp = timestamp; current_timestamp_group_.size = 0; } else { - current_timestamp_group_.timestamp = LatestTimestamp( - current_timestamp_group_.timestamp, timestamp); + current_timestamp_group_.timestamp = + LatestTimestamp(current_timestamp_group_.timestamp, timestamp); } // Accumulate the frame size. current_timestamp_group_.size += packet_size; @@ -113,8 +113,8 @@ bool InterArrival::PacketInOrder(uint32_t timestamp) { // Assume that a diff which is bigger than half the timestamp interval // (32 bits) must be due to reordering. This code is almost identical to // that in IsNewerTimestamp() in module_common_types.h. - uint32_t timestamp_diff = timestamp - - current_timestamp_group_.first_timestamp; + uint32_t timestamp_diff = + timestamp - current_timestamp_group_.first_timestamp; return timestamp_diff < 0x80000000; } } @@ -128,8 +128,8 @@ bool InterArrival::NewTimestampGroup(int64_t arrival_time_ms, } else if (BelongsToBurst(arrival_time_ms, timestamp)) { return false; } else { - uint32_t timestamp_diff = timestamp - - current_timestamp_group_.first_timestamp; + uint32_t timestamp_diff = + timestamp - current_timestamp_group_.first_timestamp; return timestamp_diff > kTimestampGroupLengthTicks; } } @@ -140,15 +140,15 @@ bool InterArrival::BelongsToBurst(int64_t arrival_time_ms, return false; } assert(current_timestamp_group_.complete_time_ms >= 0); - int64_t arrival_time_delta_ms = arrival_time_ms - - current_timestamp_group_.complete_time_ms; + int64_t arrival_time_delta_ms = + arrival_time_ms - current_timestamp_group_.complete_time_ms; uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp; int64_t ts_delta_ms = timestamp_to_ms_coeff_ * timestamp_diff + 0.5; if (ts_delta_ms == 0) return true; int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms; return propagation_delta_ms < 0 && - arrival_time_delta_ms <= kBurstDeltaThresholdMs; + arrival_time_delta_ms <= kBurstDeltaThresholdMs; } void InterArrival::Reset() { diff --git a/modules/remote_bitrate_estimator/inter_arrival.h b/modules/remote_bitrate_estimator/inter_arrival.h index f6ab280d34..e9aaf9b2aa 100644 --- a/modules/remote_bitrate_estimator/inter_arrival.h +++ b/modules/remote_bitrate_estimator/inter_arrival.h @@ -54,14 +54,9 @@ class InterArrival { private: struct TimestampGroup { TimestampGroup() - : size(0), - first_timestamp(0), - timestamp(0), - complete_time_ms(-1) {} + : size(0), first_timestamp(0), timestamp(0), complete_time_ms(-1) {} - bool IsFirstPacket() const { - return complete_time_ms == -1; - } + bool IsFirstPacket() const { return complete_time_ms == -1; } size_t size; uint32_t first_timestamp; diff --git a/modules/remote_bitrate_estimator/inter_arrival_unittest.cc b/modules/remote_bitrate_estimator/inter_arrival_unittest.cc index cd038c42ac..545b19600d 100644 --- a/modules/remote_bitrate_estimator/inter_arrival_unittest.cc +++ b/modules/remote_bitrate_estimator/inter_arrival_unittest.cc @@ -36,18 +36,15 @@ class InterArrivalTest : public ::testing::Test { inter_arrival_.reset( new InterArrival(kTimestampGroupLengthUs / 1000, 1.0, true)); inter_arrival_rtp_.reset(new InterArrival( - MakeRtpTimestamp(kTimestampGroupLengthUs), - kRtpTimestampToMs, - true)); + MakeRtpTimestamp(kTimestampGroupLengthUs), kRtpTimestampToMs, true)); inter_arrival_ast_.reset(new InterArrival( - MakeAbsSendTime(kTimestampGroupLengthUs), - kAstToMs, - true)); + MakeAbsSendTime(kTimestampGroupLengthUs), kAstToMs, true)); } // Test that neither inter_arrival instance complete the timestamp group from // the given data. - void ExpectFalse(int64_t timestamp_us, int64_t arrival_time_ms, + void ExpectFalse(int64_t timestamp_us, + int64_t arrival_time_ms, size_t packet_size) { InternalExpectFalse(inter_arrival_rtp_.get(), MakeRtpTimestamp(timestamp_us), arrival_time_ms, @@ -60,8 +57,10 @@ class InterArrivalTest : public ::testing::Test { // the given data and that all returned deltas are as expected (except // timestamp delta, which is rounded from us to different ranges and must // match within an interval, given in |timestamp_near]. - void ExpectTrue(int64_t timestamp_us, int64_t arrival_time_ms, - size_t packet_size, int64_t expected_timestamp_delta_us, + void ExpectTrue(int64_t timestamp_us, + int64_t arrival_time_ms, + size_t packet_size, + int64_t expected_timestamp_delta_us, int64_t expected_arrival_time_delta_ms, int expected_packet_size_delta, uint32_t timestamp_near) { @@ -77,7 +76,8 @@ class InterArrivalTest : public ::testing::Test { expected_packet_size_delta, timestamp_near << 8); } - void WrapTestHelper(int64_t wrap_start_us, uint32_t timestamp_near, + void WrapTestHelper(int64_t wrap_start_us, + uint32_t timestamp_near, bool unorderly_within_group) { // Step through the range of a 32 bit int, 1/4 at a time to not cause // packets close to wraparound to be judged as out of order. @@ -92,21 +92,21 @@ class InterArrivalTest : public ::testing::Test { // G3 arrival_time += kBurstThresholdMs + 1; - ExpectTrue(wrap_start_us / 2, arrival_time, 1, - wrap_start_us / 4, 6, 0, // Delta G2-G1 + ExpectTrue(wrap_start_us / 2, arrival_time, 1, wrap_start_us / 4, 6, + 0, // Delta G2-G1 0); // G4 arrival_time += kBurstThresholdMs + 1; int64_t g4_arrival_time = arrival_time; ExpectTrue(wrap_start_us / 2 + wrap_start_us / 4, arrival_time, 1, - wrap_start_us / 4, 6, 0, // Delta G3-G2 + wrap_start_us / 4, 6, 0, // Delta G3-G2 timestamp_near); // G5 arrival_time += kBurstThresholdMs + 1; - ExpectTrue(wrap_start_us, arrival_time, 2, - wrap_start_us / 4, 6, 0, // Delta G4-G3 + ExpectTrue(wrap_start_us, arrival_time, 2, wrap_start_us / 4, 6, + 0, // Delta G4-G3 timestamp_near); for (int i = 0; i < 10; ++i) { // Slowly step across the wrap point. @@ -141,12 +141,10 @@ class InterArrivalTest : public ::testing::Test { // G7 arrival_time += kBurstThresholdMs + 1; - ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs, - arrival_time, 100, + ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs, arrival_time, 100, // Delta G6-G5 kTriggerNewGroupUs - 9 * kMinStep, - g6_arrival_time - g5_arrival_time, - 10 - (2 + 10), + g6_arrival_time - g5_arrival_time, 10 - (2 + 10), timestamp_near); } @@ -158,13 +156,16 @@ class InterArrivalTest : public ::testing::Test { } static uint32_t MakeAbsSendTime(int64_t us) { - uint32_t absolute_send_time = static_cast( - ((static_cast(us) << 18) + 500000) / 1000000) & 0x00FFFFFFul; + uint32_t absolute_send_time = + static_cast(((static_cast(us) << 18) + 500000) / + 1000000) & + 0x00FFFFFFul; return absolute_send_time << 8; } static void InternalExpectFalse(InterArrival* inter_arrival, - uint32_t timestamp, int64_t arrival_time_ms, + uint32_t timestamp, + int64_t arrival_time_ms, size_t packet_size) { uint32_t dummy_timestamp = 101; int64_t dummy_arrival_time_ms = 303; @@ -179,7 +180,8 @@ class InterArrivalTest : public ::testing::Test { } static void InternalExpectTrue(InterArrival* inter_arrival, - uint32_t timestamp, int64_t arrival_time_ms, + uint32_t timestamp, + int64_t arrival_time_ms, size_t packet_size, uint32_t expected_timestamp_delta, int64_t expected_arrival_time_delta_ms, @@ -222,8 +224,7 @@ TEST_F(InterArrivalTest, FirstGroup) { arrival_time += kBurstThresholdMs + 1; ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1, // Delta G2-G1 - kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, - 0); + kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, 0); } TEST_F(InterArrivalTest, SecondGroup) { @@ -242,16 +243,14 @@ TEST_F(InterArrivalTest, SecondGroup) { int64_t g3_arrival_time = arrival_time; ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1, // Delta G2-G1 - kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, - 0); + kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, 0); // G4 // First packet of 4th group yields deltas between group 2 and 3. arrival_time += kBurstThresholdMs + 1; ExpectTrue(3 * kTriggerNewGroupUs, arrival_time, 2, // Delta G3-G2 - kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1, - 0); + kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1, 0); } TEST_F(InterArrivalTest, AccumulatedGroup) { @@ -275,9 +274,9 @@ TEST_F(InterArrivalTest, AccumulatedGroup) { // G3 arrival_time = 500; - ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100, - g2_timestamp, g2_arrival_time - g1_arrival_time, - (2 + 10) - 1, // Delta G2-G1 + ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100, g2_timestamp, + g2_arrival_time - g1_arrival_time, + (2 + 10) - 1, // Delta G2-G1 0); } @@ -311,8 +310,7 @@ TEST_F(InterArrivalTest, OutOfOrderPacket) { ExpectTrue(timestamp, arrival_time, 100, // Delta G2-G1 g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time, - (2 + 10) - 1, - 0); + (2 + 10) - 1, 0); } TEST_F(InterArrivalTest, OutOfOrderWithinGroup) { @@ -347,10 +345,8 @@ TEST_F(InterArrivalTest, OutOfOrderWithinGroup) { // G3 timestamp = 2 * kTriggerNewGroupUs; arrival_time = 500; - ExpectTrue(timestamp, arrival_time, 100, - g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time, - (2 + 10) - 1, - 0); + ExpectTrue(timestamp, arrival_time, 100, g2_timestamp - g1_timestamp, + g2_arrival_time - g1_arrival_time, (2 + 10) - 1, 0); } TEST_F(InterArrivalTest, TwoBursts) { @@ -373,13 +369,12 @@ TEST_F(InterArrivalTest, TwoBursts) { // G3 timestamp += 30000; arrival_time += kBurstThresholdMs + 1; - ExpectTrue(timestamp, arrival_time, 100, - g2_timestamp, g2_arrival_time - g1_arrival_time, + ExpectTrue(timestamp, arrival_time, 100, g2_timestamp, + g2_arrival_time - g1_arrival_time, 10 - 1, // Delta G2-G1 0); } - TEST_F(InterArrivalTest, NoBursts) { // G1 ExpectFalse(0, 17, 1); diff --git a/modules/remote_bitrate_estimator/overuse_detector.cc b/modules/remote_bitrate_estimator/overuse_detector.cc index 421c1dbc5a..776ca42a56 100644 --- a/modules/remote_bitrate_estimator/overuse_detector.cc +++ b/modules/remote_bitrate_estimator/overuse_detector.cc @@ -11,8 +11,8 @@ #include "modules/remote_bitrate_estimator/overuse_detector.h" #include -#include #include +#include #include #include @@ -142,8 +142,7 @@ void OveruseDetector::UpdateThreshold(double modified_offset, int64_t now_ms) { const double k = fabs(modified_offset) < threshold_ ? k_down_ : k_up_; const int64_t kMaxTimeDeltaMs = 100; int64_t time_delta_ms = std::min(now_ms - last_update_ms_, kMaxTimeDeltaMs); - threshold_ += - k * (fabs(modified_offset) - threshold_) * time_delta_ms; + threshold_ += k * (fabs(modified_offset) - threshold_) * time_delta_ms; threshold_ = rtc::SafeClamp(threshold_, 6.f, 600.f); last_update_ms_ = now_ms; } diff --git a/modules/remote_bitrate_estimator/overuse_detector_unittest.cc b/modules/remote_bitrate_estimator/overuse_detector_unittest.cc index 2b50d70b65..366902c268 100644 --- a/modules/remote_bitrate_estimator/overuse_detector_unittest.cc +++ b/modules/remote_bitrate_estimator/overuse_detector_unittest.cc @@ -41,11 +41,11 @@ class OveruseDetectorTest : public ::testing::Test { random_(123456789) {} protected: - void SetUp() override { - overuse_detector_.reset(new OveruseDetector()); - } + void SetUp() override { overuse_detector_.reset(new OveruseDetector()); } - int Run100000Samples(int packets_per_frame, size_t packet_size, int mean_ms, + int Run100000Samples(int packets_per_frame, + size_t packet_size, + int mean_ms, int standard_deviation_ms) { int unique_overuse = 0; int last_overuse = -1; @@ -69,8 +69,11 @@ class OveruseDetectorTest : public ::testing::Test { return unique_overuse; } - int RunUntilOveruse(int packets_per_frame, size_t packet_size, int mean_ms, - int standard_deviation_ms, int drift_per_frame_ms) { + int RunUntilOveruse(int packets_per_frame, + size_t packet_size, + int mean_ms, + int standard_deviation_ms, + int drift_per_frame_ms) { // Simulate a higher send pace, that is too high. for (int i = 0; i < 1000; ++i) { for (int j = 0; j < packets_per_frame; ++j) { @@ -89,7 +92,8 @@ class OveruseDetectorTest : public ::testing::Test { return -1; } - void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms, + void UpdateDetector(uint32_t rtp_timestamp, + int64_t receive_time_ms, size_t packet_size) { uint32_t timestamp_delta; int64_t time_delta; @@ -189,8 +193,9 @@ TEST_F(OveruseDetectorTest, SimpleOveruse2000Kbit30fps) { frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(7, frames_until_overuse); } @@ -204,8 +209,9 @@ TEST_F(OveruseDetectorTest, SimpleOveruse100kbit10fps) { frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(7, frames_until_overuse); } @@ -328,8 +334,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance30Kbit3fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(20, frames_until_overuse); } @@ -342,8 +349,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(4, frames_until_overuse); } @@ -356,8 +364,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(44, frames_until_overuse); } @@ -370,8 +379,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(4, frames_until_overuse); } @@ -390,8 +400,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit5fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(20, frames_until_overuse); } @@ -410,8 +421,9 @@ TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit5fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(44, frames_until_overuse); } @@ -430,8 +442,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit10fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(20, frames_until_overuse); } @@ -450,8 +463,9 @@ TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit10fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(44, frames_until_overuse); } @@ -470,8 +484,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance300Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(19, frames_until_overuse); } @@ -484,8 +499,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(5, frames_until_overuse); } @@ -498,8 +514,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(44, frames_until_overuse); } @@ -512,8 +529,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(10, frames_until_overuse); } @@ -532,8 +550,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance1000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(19, frames_until_overuse); } @@ -546,8 +565,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(5, frames_until_overuse); } @@ -560,8 +580,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(44, frames_until_overuse); } @@ -574,8 +595,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(10, frames_until_overuse); } @@ -594,8 +616,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance2000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(19, frames_until_overuse); } @@ -608,8 +631,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(5, frames_until_overuse); } @@ -622,8 +646,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(44, frames_until_overuse); } @@ -636,8 +661,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) { int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); EXPECT_EQ(0, unique_overuse); - int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, - frame_duration_ms, sigma_ms, drift_per_frame_ms); + int frames_until_overuse = + RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, + sigma_ms, drift_per_frame_ms); EXPECT_EQ(10, frames_until_overuse); } @@ -648,9 +674,7 @@ class OveruseDetectorExperimentTest : public OveruseDetectorTest { "WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {} protected: - void SetUp() override { - overuse_detector_.reset(new OveruseDetector()); - } + void SetUp() override { overuse_detector_.reset(new OveruseDetector()); } test::ScopedFieldTrials override_field_trials_; }; diff --git a/modules/remote_bitrate_estimator/overuse_estimator.cc b/modules/remote_bitrate_estimator/overuse_estimator.cc index 3d8ab2ad60..09de5c6e7c 100644 --- a/modules/remote_bitrate_estimator/overuse_estimator.cc +++ b/modules/remote_bitrate_estimator/overuse_estimator.cc @@ -73,12 +73,12 @@ void OveruseEstimator::Update(int64_t t_delta, } const double h[2] = {fs_delta, 1.0}; - const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1], - E_[1][0]*h[0] + E_[1][1]*h[1]}; + const double Eh[2] = {E_[0][0] * h[0] + E_[0][1] * h[1], + E_[1][0] * h[0] + E_[1][1] * h[1]}; BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_); - const double residual = t_ts_delta - slope_*h[0] - offset_; + const double residual = t_ts_delta - slope_ * h[0] - offset_; const bool in_stable_state = (current_hypothesis == BandwidthUsage::kBwNormal); @@ -92,13 +92,12 @@ void OveruseEstimator::Update(int64_t t_delta, min_frame_period, in_stable_state); } - const double denom = var_noise_ + h[0]*Eh[0] + h[1]*Eh[1]; + const double denom = var_noise_ + h[0] * Eh[0] + h[1] * Eh[1]; - const double K[2] = {Eh[0] / denom, - Eh[1] / denom}; + const double K[2] = {Eh[0] / denom, Eh[1] / denom}; - const double IKh[2][2] = {{1.0 - K[0]*h[0], -K[0]*h[1]}, - {-K[1]*h[0], 1.0 - K[1]*h[1]}}; + const double IKh[2][2] = {{1.0 - K[0] * h[0], -K[0] * h[1]}, + {-K[1] * h[0], 1.0 - K[1] * h[1]}}; const double e00 = E_[0][0]; const double e01 = E_[0][1]; @@ -109,7 +108,8 @@ void OveruseEstimator::Update(int64_t t_delta, E_[1][1] = e01 * IKh[1][0] + E_[1][1] * IKh[1][1]; // The covariance matrix must be positive semi-definite. - bool positive_semi_definite = E_[0][0] + E_[1][1] >= 0 && + bool positive_semi_definite = + E_[0][0] + E_[1][1] >= 0 && E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0; assert(positive_semi_definite); if (!positive_semi_definite) { @@ -150,16 +150,15 @@ void OveruseEstimator::UpdateNoiseEstimate(double residual, // of the network. |alpha| is tuned for 30 frames per second, but is scaled // according to |ts_delta|. double alpha = 0.01; - if (num_of_deltas_ > 10*30) { + if (num_of_deltas_ > 10 * 30) { alpha = 0.002; } // Only update the noise estimate if we're not over-using. |beta| is a // function of alpha and the time delta since the previous update. const double beta = pow(1 - alpha, ts_delta * 30.0 / 1000.0); - avg_noise_ = beta * avg_noise_ - + (1 - beta) * residual; - var_noise_ = beta * var_noise_ - + (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual); + avg_noise_ = beta * avg_noise_ + (1 - beta) * residual; + var_noise_ = beta * var_noise_ + + (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual); if (var_noise_ < 1) { var_noise_ = 1; } diff --git a/modules/remote_bitrate_estimator/overuse_estimator.h b/modules/remote_bitrate_estimator/overuse_estimator.h index 61a7150a92..4c924938aa 100644 --- a/modules/remote_bitrate_estimator/overuse_estimator.h +++ b/modules/remote_bitrate_estimator/overuse_estimator.h @@ -34,20 +34,14 @@ class OveruseEstimator { int64_t now_ms); // Returns the estimated noise/jitter variance in ms^2. - double var_noise() const { - return var_noise_; - } + double var_noise() const { return var_noise_; } // Returns the estimated inter-arrival time delta offset in ms. - double offset() const { - return offset_; - } + double offset() const { return offset_; } // Returns the number of deltas which the current over-use estimator state is // based on. - unsigned int num_of_deltas() const { - return num_of_deltas_; - } + unsigned int num_of_deltas() const { return num_of_deltas_; } private: double UpdateMinFramePeriod(double ts_delta); diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc index b061cbde51..045674d003 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc @@ -35,15 +35,15 @@ enum { kExpectedNumberOfProbes = 3 }; -static const double kTimestampToMs = 1000.0 / - static_cast(1 << kInterArrivalShift); +static const double kTimestampToMs = + 1000.0 / static_cast(1 << kInterArrivalShift); -template +template std::vector Keys(const std::map& map) { std::vector keys; keys.reserve(map.size()); for (typename std::map::const_iterator it = map.begin(); - it != map.end(); ++it) { + it != map.end(); ++it) { keys.push_back(it->first); } return keys; @@ -61,39 +61,38 @@ uint32_t ConvertMsTo24Bits(int64_t time_ms) { bool RemoteBitrateEstimatorAbsSendTime::IsWithinClusterBounds( int send_delta_ms, const Cluster& cluster_aggregate) { - if (cluster_aggregate.count == 0) - return true; - float cluster_mean = cluster_aggregate.send_mean_ms / - static_cast(cluster_aggregate.count); - return fabs(static_cast(send_delta_ms) - cluster_mean) < 2.5f; - } + if (cluster_aggregate.count == 0) + return true; + float cluster_mean = cluster_aggregate.send_mean_ms / + static_cast(cluster_aggregate.count); + return fabs(static_cast(send_delta_ms) - cluster_mean) < 2.5f; +} - void RemoteBitrateEstimatorAbsSendTime::AddCluster( - std::list* clusters, - Cluster* cluster) { - cluster->send_mean_ms /= static_cast(cluster->count); - cluster->recv_mean_ms /= static_cast(cluster->count); - cluster->mean_size /= cluster->count; - clusters->push_back(*cluster); - } +void RemoteBitrateEstimatorAbsSendTime::AddCluster(std::list* clusters, + Cluster* cluster) { + cluster->send_mean_ms /= static_cast(cluster->count); + cluster->recv_mean_ms /= static_cast(cluster->count); + cluster->mean_size /= cluster->count; + clusters->push_back(*cluster); +} - RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime( - RemoteBitrateObserver* observer, - const Clock* clock) - : clock_(clock), - observer_(observer), - inter_arrival_(), - estimator_(), - detector_(), - incoming_bitrate_(kBitrateWindowMs, 8000), - incoming_bitrate_initialized_(false), - total_probes_received_(0), - first_packet_time_ms_(-1), - last_update_ms_(-1), - uma_recorded_(false) { - RTC_DCHECK(clock_); - RTC_DCHECK(observer_); - RTC_LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating."; +RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime( + RemoteBitrateObserver* observer, + const Clock* clock) + : clock_(clock), + observer_(observer), + inter_arrival_(), + estimator_(), + detector_(), + incoming_bitrate_(kBitrateWindowMs, 8000), + incoming_bitrate_initialized_(false), + total_probes_received_(0), + first_packet_time_ms_(-1), + last_update_ms_(-1), + uma_recorded_(false) { + RTC_DCHECK(clock_); + RTC_DCHECK(observer_); + RTC_LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating."; } void RemoteBitrateEstimatorAbsSendTime::ComputeClusters( @@ -102,8 +101,7 @@ void RemoteBitrateEstimatorAbsSendTime::ComputeClusters( int64_t prev_send_time = -1; int64_t prev_recv_time = -1; for (std::list::const_iterator it = probes_.begin(); - it != probes_.end(); - ++it) { + it != probes_.end(); ++it) { if (prev_send_time >= 0) { int send_delta_ms = it->send_time_ms - prev_send_time; int recv_delta_ms = it->recv_time_ms - prev_recv_time; @@ -111,8 +109,7 @@ void RemoteBitrateEstimatorAbsSendTime::ComputeClusters( ++current.num_above_min_delta; } if (!IsWithinClusterBounds(send_delta_ms, current)) { - if (current.count >= kMinClusterSize && - current.send_mean_ms > 0.0f && + if (current.count >= kMinClusterSize && current.send_mean_ms > 0.0f && current.recv_mean_ms > 0.0f) { AddCluster(clusters, ¤t); } @@ -126,8 +123,7 @@ void RemoteBitrateEstimatorAbsSendTime::ComputeClusters( prev_send_time = it->send_time_ms; prev_recv_time = it->recv_time_ms; } - if (current.count >= kMinClusterSize && - current.send_mean_ms > 0.0f && + if (current.count >= kMinClusterSize && current.send_mean_ms > 0.0f && current.recv_mean_ms > 0.0f) { AddCluster(clusters, ¤t); } @@ -139,8 +135,7 @@ RemoteBitrateEstimatorAbsSendTime::FindBestProbe( int highest_probe_bitrate_bps = 0; std::list::const_iterator best_it = clusters.end(); for (std::list::const_iterator it = clusters.begin(); - it != clusters.end(); - ++it) { + it != clusters.end(); ++it) { if (it->send_mean_ms == 0 || it->recv_mean_ms == 0) continue; if (it->num_above_min_delta > it->count / 2 && diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc index ccfb64645b..bf7f594051 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc @@ -14,14 +14,15 @@ namespace webrtc { -class RemoteBitrateEstimatorAbsSendTimeTest : - public RemoteBitrateEstimatorTest { +class RemoteBitrateEstimatorAbsSendTimeTest + : public RemoteBitrateEstimatorTest { public: RemoteBitrateEstimatorAbsSendTimeTest() {} virtual void SetUp() { bitrate_estimator_.reset(new RemoteBitrateEstimatorAbsSendTime( bitrate_observer_.get(), &clock_)); } + protected: RTC_DISALLOW_COPY_AND_ASSIGN(RemoteBitrateEstimatorAbsSendTimeTest); }; diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc index 612a51e4ee..8188215b29 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc @@ -76,8 +76,8 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket( uma_recorded_ = true; } uint32_t ssrc = header.ssrc; - uint32_t rtp_timestamp = header.timestamp + - header.extension.transmissionTimeOffset; + uint32_t rtp_timestamp = + header.timestamp + header.extension.transmissionTimeOffset; int64_t now_ms = clock_->TimeInMilliseconds(); rtc::CritScope cs(&crit_sect_); SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc); @@ -152,7 +152,7 @@ int64_t RemoteBitrateEstimatorSingleStream::TimeUntilNextProcess() { rtc::CritScope cs_(&crit_sect_); RTC_DCHECK_GT(process_interval_ms_, 0); return last_process_time_ + process_interval_ms_ - - clock_->TimeInMilliseconds(); + clock_->TimeInMilliseconds(); } void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) { @@ -184,10 +184,9 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) { } AimdRateControl* remote_rate = GetRemoteRate(); - double mean_noise_var = sum_var_noise / - static_cast(overuse_detectors_.size()); - const RateControlInput input(bw_state, - incoming_bitrate_.Rate(now_ms), + double mean_noise_var = + sum_var_noise / static_cast(overuse_detectors_.size()); + const RateControlInput input(bw_state, incoming_bitrate_.Rate(now_ms), mean_noise_var); uint32_t target_bitrate = remote_rate->Update(&input, now_ms); if (remote_rate->ValidEstimate()) { @@ -237,7 +236,7 @@ void RemoteBitrateEstimatorSingleStream::GetSsrcs( ssrcs->resize(overuse_detectors_.size()); int i = 0; for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin(); - it != overuse_detectors_.end(); ++it, ++i) { + it != overuse_detectors_.end(); ++it, ++i) { (*ssrcs)[i] = it->first; } } diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc index c4bb76bb23..120db13c7f 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc @@ -14,14 +14,14 @@ namespace webrtc { -class RemoteBitrateEstimatorSingleTest : - public RemoteBitrateEstimatorTest { +class RemoteBitrateEstimatorSingleTest : public RemoteBitrateEstimatorTest { public: RemoteBitrateEstimatorSingleTest() {} virtual void SetUp() { bitrate_estimator_.reset(new RemoteBitrateEstimatorSingleStream( bitrate_observer_.get(), &clock_)); } + protected: RTC_DISALLOW_COPY_AND_ASSIGN(RemoteBitrateEstimatorSingleTest); }; diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc index 0b3ff439d8..5e117942c1 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc @@ -69,8 +69,10 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, PacketList* packets) { RtpPacket* packet = new RtpPacket; packet->send_time = time_now_us + kSendSideOffsetUs; packet->size = packet_size; - packet->rtp_timestamp = rtp_timestamp_offset_ + static_cast( - ((frequency_ / 1000) * packet->send_time + 500) / 1000); + packet->rtp_timestamp = + rtp_timestamp_offset_ + + static_cast(((frequency_ / 1000) * packet->send_time + 500) / + 1000); packet->ssrc = ssrc_; packets->push_back(packet); } @@ -90,11 +92,12 @@ RtpStream::RtcpPacket* RtpStream::Rtcp(int64_t time_now_us) { } RtcpPacket* rtcp = new RtcpPacket; int64_t send_time_us = time_now_us + kSendSideOffsetUs; - rtcp->timestamp = rtp_timestamp_offset_ + static_cast( - ((frequency_ / 1000) * send_time_us + 500) / 1000); + rtcp->timestamp = + rtp_timestamp_offset_ + + static_cast(((frequency_ / 1000) * send_time_us + 500) / 1000); rtcp->ntp_secs = send_time_us / 1000000; - rtcp->ntp_frac = static_cast((send_time_us % 1000000) * - kNtpFracPerMs); + rtcp->ntp_frac = + static_cast((send_time_us % 1000000) * kNtpFracPerMs); rtcp->ssrc = ssrc_; next_rtcp_time_ = time_now_us + kRtcpIntervalUs; return rtcp; @@ -119,12 +122,10 @@ bool RtpStream::Compare(const std::pair& left, } StreamGenerator::StreamGenerator(int capacity, int64_t time_now) - : capacity_(capacity), - prev_arrival_time_us_(time_now) {} + : capacity_(capacity), prev_arrival_time_us_(time_now) {} StreamGenerator::~StreamGenerator() { - for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); - ++it) { + for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) { delete it->second; } streams_.clear(); @@ -153,8 +154,9 @@ void StreamGenerator::SetBitrateBps(int bitrate_bps) { int total_bitrate_after = 0; for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) { bitrate_before += it->second->bitrate_bps(); - int64_t bitrate_after = (bitrate_before * bitrate_bps + - total_bitrate_before / 2) / total_bitrate_before; + int64_t bitrate_after = + (bitrate_before * bitrate_bps + total_bitrate_before / 2) / + total_bitrate_before; it->second->set_bitrate_bps(bitrate_after - total_bitrate_after); total_bitrate_after += it->second->bitrate_bps(); } @@ -174,17 +176,18 @@ int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets, assert(packets != NULL); assert(packets->empty()); assert(capacity_ > 0); - StreamMap::iterator it = std::min_element(streams_.begin(), streams_.end(), - RtpStream::Compare); + StreamMap::iterator it = + std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare); (*it).second->GenerateFrame(time_now_us, packets); int i = 0; for (RtpStream::PacketList::iterator packet_it = packets->begin(); - packet_it != packets->end(); ++packet_it) { + packet_it != packets->end(); ++packet_it) { int capacity_bpus = capacity_ / 1000; int64_t required_network_time_us = (8 * 1000 * (*packet_it)->size + capacity_bpus / 2) / capacity_bpus; - prev_arrival_time_us_ = std::max(time_now_us + required_network_time_us, - prev_arrival_time_us_ + required_network_time_us); + prev_arrival_time_us_ = + std::max(time_now_us + required_network_time_us, + prev_arrival_time_us_ + required_network_time_us); (*packet_it)->arrival_time = prev_arrival_time_us_; ++i; } @@ -196,21 +199,21 @@ int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets, RemoteBitrateEstimatorTest::RemoteBitrateEstimatorTest() : clock_(100000000), bitrate_observer_(new testing::TestBitrateObserver), - stream_generator_(new testing::StreamGenerator( - 1e6, // Capacity. - clock_.TimeInMicroseconds())), + stream_generator_( + new testing::StreamGenerator(1e6, // Capacity. + clock_.TimeInMicroseconds())), arrival_time_offset_ms_(0) {} RemoteBitrateEstimatorTest::~RemoteBitrateEstimatorTest() {} void RemoteBitrateEstimatorTest::AddDefaultStream() { - stream_generator_->AddStream(new testing::RtpStream( - 30, // Frames per second. - 3e5, // Bitrate. - 1, // SSRC. - 90000, // RTP frequency. - 0xFFFFF000, // Timestamp offset. - 0)); // RTCP receive time. + stream_generator_->AddStream( + new testing::RtpStream(30, // Frames per second. + 3e5, // Bitrate. + 1, // SSRC. + 90000, // RTP frequency. + 0xFFFFF000, // Timestamp offset. + 0)); // RTCP receive time. } uint32_t RemoteBitrateEstimatorTest::AbsSendTime(int64_t t, int64_t denom) { @@ -250,8 +253,8 @@ bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(uint32_t ssrc, RTC_DCHECK_GT(bitrate_bps, 0); stream_generator_->SetBitrateBps(bitrate_bps); testing::RtpStream::PacketList packets; - int64_t next_time_us = stream_generator_->GenerateFrame( - &packets, clock_.TimeInMicroseconds()); + int64_t next_time_us = + stream_generator_->GenerateFrame(&packets, clock_.TimeInMicroseconds()); bool overuse = false; while (!packets.empty()) { testing::RtpStream::RtpPacket* packet = packets.front(); @@ -339,8 +342,8 @@ void RemoteBitrateEstimatorTest::InitialBehaviorTestHelper( absolute_send_time); clock_.AdvanceTimeMilliseconds(1000 / kFramerate); timestamp += 90 * kFrameIntervalMs; - absolute_send_time = AddAbsSendTime(absolute_send_time, - kFrameIntervalAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime); } bitrate_estimator_->Process(); EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); @@ -377,19 +380,18 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper( absolute_send_time); clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); timestamp += 90 * kFrameIntervalMs; - absolute_send_time = AddAbsSendTime(absolute_send_time, - kFrameIntervalAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime); } bitrate_estimator_->Process(); EXPECT_TRUE(bitrate_observer_->updated()); - EXPECT_NEAR(expected_bitrate_bps, - bitrate_observer_->latest_bitrate(), + EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(), kAcceptedBitrateErrorBps); for (int i = 0; i < 10; ++i) { clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); timestamp += 2 * 90 * kFrameIntervalMs; - absolute_send_time = AddAbsSendTime(absolute_send_time, - 2 * kFrameIntervalAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, 2 * kFrameIntervalAbsSendTime); IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp, absolute_send_time); IncomingPacket( @@ -400,8 +402,7 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper( } bitrate_estimator_->Process(); EXPECT_TRUE(bitrate_observer_->updated()); - EXPECT_NEAR(expected_bitrate_bps, - bitrate_observer_->latest_bitrate(), + EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(), kAcceptedBitrateErrorBps); } @@ -472,7 +473,8 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper( ASSERT_EQ(bitrate_sum, kStartBitrate); } if (wrap_time_stamp) { - stream_generator_->set_rtp_timestamp_offset(kDefaultSsrc, + stream_generator_->set_rtp_timestamp_offset( + kDefaultSsrc, std::numeric_limits::max() - steady_state_time * 90000); } @@ -538,8 +540,8 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() { bitrate_estimator_->Process(); clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); timestamp += 90 * kFrameIntervalMs; - absolute_send_time = AddAbsSendTime(absolute_send_time, - kFrameIntervalAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime); } EXPECT_TRUE(bitrate_observer_->updated()); EXPECT_GE(bitrate_observer_->latest_bitrate(), 400000u); @@ -558,8 +560,8 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() { absolute_send_time); clock_.AdvanceTimeMilliseconds(kFrameIntervalMs / kTimestampGroupLength); timestamp += 1; - absolute_send_time = AddAbsSendTime(absolute_send_time, - kSingleRtpTickAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, kSingleRtpTickAbsSendTime); } // Increase time until next batch to simulate over-use. clock_.AdvanceTimeMilliseconds(10); @@ -575,8 +577,7 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() { EXPECT_LT(bitrate_observer_->latest_bitrate(), 400000u); } -void RemoteBitrateEstimatorTest::TestWrappingHelper( - int silence_time_s) { +void RemoteBitrateEstimatorTest::TestWrappingHelper(int silence_time_s) { const int kFramerate = 100; const int kFrameIntervalMs = 1000 / kFramerate; const uint32_t kFrameIntervalAbsSendTime = AbsSendTime(1, kFramerate); @@ -588,8 +589,8 @@ void RemoteBitrateEstimatorTest::TestWrappingHelper( absolute_send_time); timestamp += kFrameIntervalMs; clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); - absolute_send_time = AddAbsSendTime(absolute_send_time, - kFrameIntervalAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime); bitrate_estimator_->Process(); } uint32_t bitrate_before = 0; @@ -597,16 +598,16 @@ void RemoteBitrateEstimatorTest::TestWrappingHelper( bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_before); clock_.AdvanceTimeMilliseconds(silence_time_s * 1000); - absolute_send_time = AddAbsSendTime(absolute_send_time, - AbsSendTime(silence_time_s, 1)); + absolute_send_time = + AddAbsSendTime(absolute_send_time, AbsSendTime(silence_time_s, 1)); bitrate_estimator_->Process(); for (size_t i = 0; i < 21; ++i) { IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp, absolute_send_time); timestamp += kFrameIntervalMs; clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); - absolute_send_time = AddAbsSendTime(absolute_send_time, - kFrameIntervalAbsSendTime); + absolute_send_time = + AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime); bitrate_estimator_->Process(); } uint32_t bitrate_after = 0; diff --git a/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/modules/remote_bitrate_estimator/remote_estimator_proxy.cc index 1e42266f7d..8cde28d027 100644 --- a/modules/remote_bitrate_estimator/remote_estimator_proxy.cc +++ b/modules/remote_bitrate_estimator/remote_estimator_proxy.cc @@ -10,8 +10,8 @@ #include "modules/remote_bitrate_estimator/remote_estimator_proxy.h" -#include #include +#include #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "rtc_base/checks.h" diff --git a/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc b/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc index 4197fcc727..6c1fc8cd93 100644 --- a/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc +++ b/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/pacing/packet_router.h" #include "modules/remote_bitrate_estimator/remote_estimator_proxy.h" +#include "modules/pacing/packet_router.h" #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "system_wrappers/include/clock.h" #include "test/gmock.h" diff --git a/modules/remote_bitrate_estimator/test/bwe.cc b/modules/remote_bitrate_estimator/test/bwe.cc index 656cb5b4cf..536743fd34 100644 --- a/modules/remote_bitrate_estimator/test/bwe.cc +++ b/modules/remote_bitrate_estimator/test/bwe.cc @@ -34,15 +34,13 @@ BweReceiver::BweReceiver(int flow_id) : flow_id_(flow_id), received_packets_(kSetCapacity), rate_counter_(), - loss_account_() { -} + loss_account_() {} BweReceiver::BweReceiver(int flow_id, int64_t window_size_ms) : flow_id_(flow_id), received_packets_(kSetCapacity), rate_counter_(window_size_ms), - loss_account_() { -} + loss_account_() {} void BweReceiver::ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) { diff --git a/modules/remote_bitrate_estimator/test/bwe_test.cc b/modules/remote_bitrate_estimator/test/bwe_test.cc index 71088ff56e..737847c291 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test.cc @@ -34,8 +34,7 @@ namespace testing { namespace bwe { PacketProcessorRunner::PacketProcessorRunner(PacketProcessor* processor) - : processor_(processor) { -} + : processor_(processor) {} PacketProcessorRunner::~PacketProcessorRunner() { for (Packet* packet : queue_) @@ -97,8 +96,7 @@ void PacketProcessorRunner::QueuePackets(Packets* batch, } // Plot link capacity by default. -BweTest::BweTest() : BweTest(true) { -} +BweTest::BweTest() : BweTest(true) {} BweTest::BweTest(bool plot_capacity) : run_time_ms_(0), @@ -117,9 +115,8 @@ BweTest::~BweTest() { void BweTest::SetUp() { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - std::string test_name = - std::string(test_info->test_case_name()) + "_" + - std::string(test_info->name()); + std::string test_name = std::string(test_info->test_case_name()) + "_" + + std::string(test_info->name()); BWE_TEST_LOGGING_GLOBAL_CONTEXT(test_name); BWE_TEST_LOGGING_GLOBAL_ENABLE(false); } @@ -769,8 +766,8 @@ void BweTest::RunLongTcpFairness(BandwidthEstimatorType bwe_type) { // max_delay_ms = 1000; std::string title("5.6_Long_TCP_Fairness"); - std::string flow_name = std::string() + - bwe_names[bwe_type] + 'x' + bwe_names[kTcpEstimator]; + std::string flow_name = + std::string() + bwe_names[bwe_type] + 'x' + bwe_names[kTcpEstimator]; RunFairnessTest(bwe_type, kNumRmcatFlows, kNumTcpFlows, kRunTimeS, kCapacityKbps, max_delay_ms, rtt_ms, kMaxJitterMs, kOffSetsMs, diff --git a/modules/remote_bitrate_estimator/test/bwe_test.h b/modules/remote_bitrate_estimator/test/bwe_test.h index 43156e7fc7..24d5f107a8 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test.h +++ b/modules/remote_bitrate_estimator/test/bwe_test.h @@ -133,8 +133,7 @@ class BweTest { Link uplink_; private: - void FindPacketsToProcess(const FlowIds& flow_ids, Packets* in, - Packets* out); + void FindPacketsToProcess(const FlowIds& flow_ids, Packets* in, Packets* out); void GiveFeedbackToAffectedSenders(PacketReceiver* receiver); int64_t run_time_ms_; diff --git a/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc b/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc index 7b12f067cf..d273e211e8 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc @@ -42,8 +42,7 @@ class BaseLineFileVerify : public BaseLineFileInterface { // the baseline file is missing. This is the default when verifying files, but // not when updating (i.e. we always write it out if missing). BaseLineFileVerify(const std::string& filepath, bool allow_missing_file) - : reader_(), - fail_to_read_response_(false) { + : reader_(), fail_to_read_response_(false) { std::unique_ptr reader; reader.reset(ResourceFileReader::Create(filepath, "bin")); if (!reader.get()) { @@ -72,7 +71,7 @@ class BaseLineFileVerify : public BaseLineFileInterface { reader_->Read(&read_bps) && read_bps == estimate_bps) { } else { printf("ERROR: Baseline differs starting at: %d ms (%d vs %d)!\n", - static_cast(time_ms), estimate_bps, read_bps); + static_cast(time_ms), estimate_bps, read_bps); reader_.reset(NULL); } } @@ -101,9 +100,7 @@ class BaseLineFileUpdate : public BaseLineFileInterface { public: BaseLineFileUpdate(const std::string& filepath, BaseLineFileInterface* verifier) - : verifier_(verifier), - output_content_(), - filepath_(filepath) { + : verifier_(verifier), output_content_(), filepath_(filepath) { output_content_.push_back(kMagicMarker); output_content_.push_back(kFileVersion1); } @@ -126,13 +123,13 @@ class BaseLineFileUpdate : public BaseLineFileInterface { writer.reset(OutputFileWriter::Create(filepath_, "bin")); if (!writer.get()) { printf("WARNING: Cannot create output file: %s.bin\n", - filepath_.c_str()); + filepath_.c_str()); return false; } printf("NOTE: Writing baseline file for BWE test: %s.bin\n", filepath_.c_str()); for (std::vector::iterator it = output_content_.begin(); - it != output_content_.end(); ++it) { + it != output_content_.end(); ++it) { writer->Write(*it); } return true; @@ -150,7 +147,8 @@ class BaseLineFileUpdate : public BaseLineFileInterface { }; BaseLineFileInterface* BaseLineFileInterface::Create( - const std::string& filename, bool write_output_file) { + const std::string& filename, + bool write_output_file) { std::string filepath = filename; std::replace(filepath.begin(), filepath.end(), '/', '_'); filepath = std::string(kResourceSubDir) + "/" + filepath; diff --git a/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc b/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc index ffd410ef37..afea787b1a 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc @@ -80,8 +80,8 @@ bool OutputFileWriter::Write(uint32_t value) { OutputFileWriter* OutputFileWriter::Create(const std::string& filename, const std::string& extension) { - std::string filepath = webrtc::test::OutputPath() + filename + "." + - extension; + std::string filepath = + webrtc::test::OutputPath() + filename + "." + extension; FILE* file = fopen(filepath.c_str(), "wb"); if (file == NULL) { BWE_TEST_LOGGING_CONTEXT("OutputFileWriter"); diff --git a/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/modules/remote_bitrate_estimator/test/bwe_test_framework.cc index 2a6614fc0f..8b36cd746d 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_framework.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test_framework.cc @@ -39,9 +39,7 @@ class DelayCapHelper { return (max_delay_us_ == 0 || max_delay_us_ >= packet_delay_us); } - const Stats& delay_stats() const { - return delay_stats_; - } + const Stats& delay_stats() const { return delay_stats_; } private: int64_t max_delay_us_; @@ -50,7 +48,7 @@ class DelayCapHelper { RTC_DISALLOW_COPY_AND_ASSIGN(DelayCapHelper); }; -const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids) { +const FlowIds CreateFlowIds(const int* flow_ids_array, size_t num_flow_ids) { FlowIds flow_ids(&flow_ids_array[0], flow_ids_array + num_flow_ids); return flow_ids; } @@ -109,8 +107,7 @@ Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size) sender_timestamp_us_(send_time_us), payload_size_(payload_size) {} -Packet::~Packet() { -} +Packet::~Packet() {} bool Packet::operator<(const Packet& rhs) const { return send_time_us_ < rhs.send_time_us_; @@ -138,8 +135,7 @@ MediaPacket::MediaPacket(int flow_id, int64_t send_time_us, size_t payload_size, const RTPHeader& header) - : Packet(flow_id, send_time_us, payload_size), header_(header) { -} + : Packet(flow_id, send_time_us, payload_size), header_(header) {} MediaPacket::MediaPacket(int64_t send_time_us, uint16_t sequence_number) : Packet(0, send_time_us, 0) { @@ -149,8 +145,9 @@ MediaPacket::MediaPacket(int64_t send_time_us, uint16_t sequence_number) void MediaPacket::SetAbsSendTimeMs(int64_t abs_send_time_ms) { header_.extension.hasAbsoluteSendTime = true; - header_.extension.absoluteSendTime = ((static_cast(abs_send_time_ms * - (1 << 18)) + 500) / 1000) & 0x00fffffful; + header_.extension.absoluteSendTime = + ((static_cast(abs_send_time_ms * (1 << 18)) + 500) / 1000) & + 0x00fffffful; } BbrBweFeedback::BbrBweFeedback( @@ -168,8 +165,7 @@ RembFeedback::RembFeedback(int flow_id, RTCPReportBlock report_block) : FeedbackPacket(flow_id, send_time_us, last_send_time_ms), estimated_bps_(estimated_bps), - report_block_(report_block) { -} + report_block_(report_block) {} SendSideBweFeedback::SendSideBweFeedback( int flow_id, @@ -272,7 +268,6 @@ RateCounterFilter::~RateCounterFilter() { LogStats(); } - void RateCounterFilter::LogStats() { BWE_TEST_LOGGING_CONTEXT("RateCounterFilter"); packets_per_second_stats_.Log("pps"); @@ -315,15 +310,13 @@ void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { LossFilter::LossFilter(PacketProcessorListener* listener, int flow_id) : PacketProcessor(listener, flow_id, kRegular), random_(0x12345678), - loss_fraction_(0.0f) { -} + loss_fraction_(0.0f) {} LossFilter::LossFilter(PacketProcessorListener* listener, const FlowIds& flow_ids) : PacketProcessor(listener, flow_ids, kRegular), random_(0x12345678), - loss_fraction_(0.0f) { -} + loss_fraction_(0.0f) {} void LossFilter::SetLoss(float loss_percent) { BWE_TEST_LOGGING_ENABLE(false); @@ -335,7 +328,7 @@ void LossFilter::SetLoss(float loss_percent) { void LossFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { assert(in_out); - for (PacketsIt it = in_out->begin(); it != in_out->end(); ) { + for (PacketsIt it = in_out->begin(); it != in_out->end();) { if (random_.Rand() < loss_fraction_) { delete *it; it = in_out->erase(it); @@ -350,15 +343,13 @@ const int64_t kDefaultOneWayDelayUs = 0; DelayFilter::DelayFilter(PacketProcessorListener* listener, int flow_id) : PacketProcessor(listener, flow_id, kRegular), one_way_delay_us_(kDefaultOneWayDelayUs), - last_send_time_us_(0) { -} + last_send_time_us_(0) {} DelayFilter::DelayFilter(PacketProcessorListener* listener, const FlowIds& flow_ids) : PacketProcessor(listener, flow_ids, kRegular), one_way_delay_us_(kDefaultOneWayDelayUs), - last_send_time_us_(0) { -} + last_send_time_us_(0) {} void DelayFilter::SetOneWayDelayMs(int64_t one_way_delay_ms) { BWE_TEST_LOGGING_ENABLE(false); @@ -381,8 +372,7 @@ JitterFilter::JitterFilter(PacketProcessorListener* listener, int flow_id) random_(0x89674523), stddev_jitter_us_(0), last_send_time_us_(0), - reordering_(false) { -} + reordering_(false) {} JitterFilter::JitterFilter(PacketProcessorListener* listener, const FlowIds& flow_ids) @@ -390,8 +380,7 @@ JitterFilter::JitterFilter(PacketProcessorListener* listener, random_(0x89674523), stddev_jitter_us_(0), last_send_time_us_(0), - reordering_(false) { -} + reordering_(false) {} const int kN = 3; // Truncated N sigma gaussian. @@ -410,7 +399,7 @@ inline int64_t TruncatedNSigmaGaussian(Random* const random, const int64_t gaussian_random = random->Gaussian(mean, std_dev); return rtc::SafeClamp(gaussian_random, -kN * std_dev, kN * std_dev); } -} +} // namespace void JitterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { assert(in_out); @@ -448,15 +437,13 @@ int64_t JitterFilter::MeanUs() { ReorderFilter::ReorderFilter(PacketProcessorListener* listener, int flow_id) : PacketProcessor(listener, flow_id, kRegular), random_(0x27452389), - reorder_fraction_(0.0f) { -} + reorder_fraction_(0.0f) {} ReorderFilter::ReorderFilter(PacketProcessorListener* listener, const FlowIds& flow_ids) : PacketProcessor(listener, flow_ids, kRegular), random_(0x27452389), - reorder_fraction_(0.0f) { -} + reorder_fraction_(0.0f) {} void ReorderFilter::SetReorder(float reorder_percent) { BWE_TEST_LOGGING_ENABLE(false); @@ -490,16 +477,14 @@ ChokeFilter::ChokeFilter(PacketProcessorListener* listener, int flow_id) : PacketProcessor(listener, flow_id, kRegular), capacity_kbps_(kDefaultKbps), last_send_time_us_(0), - delay_cap_helper_(new DelayCapHelper()) { -} + delay_cap_helper_(new DelayCapHelper()) {} ChokeFilter::ChokeFilter(PacketProcessorListener* listener, const FlowIds& flow_ids) : PacketProcessor(listener, flow_ids, kRegular), capacity_kbps_(kDefaultKbps), last_send_time_us_(0), - delay_cap_helper_(new DelayCapHelper()) { -} + delay_cap_helper_(new DelayCapHelper()) {} ChokeFilter::~ChokeFilter() {} @@ -515,7 +500,7 @@ uint32_t ChokeFilter::capacity_kbps() { void ChokeFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { assert(in_out); - for (PacketsIt it = in_out->begin(); it != in_out->end(); ) { + for (PacketsIt it = in_out->begin(); it != in_out->end();) { int64_t earliest_send_time_us = std::max(last_send_time_us_, (*it)->send_time_us()); int64_t new_send_time_us = @@ -556,8 +541,7 @@ TraceBasedDeliveryFilter::TraceBasedDeliveryFilter( name_(""), delay_cap_helper_(new DelayCapHelper()), packets_per_second_stats_(), - kbps_stats_() { -} + kbps_stats_() {} TraceBasedDeliveryFilter::TraceBasedDeliveryFilter( PacketProcessorListener* listener, @@ -571,8 +555,7 @@ TraceBasedDeliveryFilter::TraceBasedDeliveryFilter( name_(""), delay_cap_helper_(new DelayCapHelper()), packets_per_second_stats_(), - kbps_stats_() { -} + kbps_stats_() {} TraceBasedDeliveryFilter::TraceBasedDeliveryFilter( PacketProcessorListener* listener, @@ -587,11 +570,9 @@ TraceBasedDeliveryFilter::TraceBasedDeliveryFilter( name_(name), delay_cap_helper_(new DelayCapHelper()), packets_per_second_stats_(), - kbps_stats_() { -} + kbps_stats_() {} -TraceBasedDeliveryFilter::~TraceBasedDeliveryFilter() { -} +TraceBasedDeliveryFilter::~TraceBasedDeliveryFilter() {} bool TraceBasedDeliveryFilter::Init(const std::string& filename) { FILE* trace_file = fopen(filename.c_str(), "r"); @@ -769,8 +750,7 @@ AdaptiveVideoSource::AdaptiveVideoSource(int flow_id, uint32_t kbps, uint32_t ssrc, int64_t first_frame_offset_ms) - : VideoSource(flow_id, fps, kbps, ssrc, first_frame_offset_ms) { -} + : VideoSource(flow_id, fps, kbps, ssrc, first_frame_offset_ms) {} void AdaptiveVideoSource::SetBitrateBps(int bitrate_bps) { bits_per_second_ = bitrate_bps; @@ -787,8 +767,7 @@ PeriodicKeyFrameSource::PeriodicKeyFrameSource(int flow_id, key_frame_interval_(key_frame_interval), frame_counter_(0), compensation_bytes_(0), - compensation_per_frame_(0) { -} + compensation_per_frame_(0) {} uint32_t PeriodicKeyFrameSource::NextFrameSize() { uint32_t payload_size = frame_size_bytes_; diff --git a/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/modules/remote_bitrate_estimator/test/bwe_test_framework.h index 983a79a093..bfb4935678 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_framework.h +++ b/modules/remote_bitrate_estimator/test/bwe_test_framework.h @@ -75,7 +75,7 @@ class RateCounter { }; typedef std::set FlowIds; -const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids); +const FlowIds CreateFlowIds(const int* flow_ids_array, size_t num_flow_ids); const FlowIds CreateFlowIdRange(int initial_value, int last_value); template @@ -85,7 +85,8 @@ bool DereferencingComparator(const T* const& a, const T* const& b) { return *a < *b; } -template class Stats { +template +class Stats { public: Stats() : data_(), @@ -95,12 +96,9 @@ template class Stats { mean_(0), variance_(0), min_(0), - max_(0) { - } + max_(0) {} - void Push(T data_point) { - data_.push_back(data_point); - } + void Push(T data_point) { data_.push_back(data_point); } T GetMean() { if (last_mean_count_ != data_.size()) { @@ -125,9 +123,7 @@ template class Stats { } return variance_; } - T GetStdDev() { - return sqrt(static_cast(GetVariance())); - } + T GetStdDev() { return sqrt(static_cast(GetVariance())); } T GetMin() { RefreshMinMax(); return min_; @@ -139,14 +135,14 @@ template class Stats { std::string AsString() { std::stringstream ss; - ss << (GetMean() >= 0 ? GetMean() : -1) << ", " << - (GetStdDev() >= 0 ? GetStdDev() : -1); + ss << (GetMean() >= 0 ? GetMean() : -1) << ", " + << (GetStdDev() >= 0 ? GetStdDev() : -1); return ss.str(); } void Log(const std::string& units) { - BWE_TEST_LOGGING_LOG5("", "%f %s\t+/-%f\t[%f,%f]", - GetMean(), units.c_str(), GetStdDev(), GetMin(), GetMax()); + BWE_TEST_LOGGING_LOG5("", "%f %s\t+/-%f\t[%f,%f]", GetMean(), units.c_str(), + GetStdDev(), GetMin(), GetMax()); } private: diff --git a/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc b/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc index 2562732a1b..3e41ac1952 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc @@ -153,8 +153,10 @@ class BweTestFramework_RateCounterFilterTest : public ::testing::Test { virtual ~BweTestFramework_RateCounterFilterTest() {} protected: - void TestRateCounter(int64_t run_for_ms, uint32_t payload_bits, - uint32_t expected_pps, uint32_t expected_bps) { + void TestRateCounter(int64_t run_for_ms, + uint32_t payload_bits, + uint32_t expected_pps, + uint32_t expected_bps) { Packets packets; RTPHeader header; // "Send" a packet every 10 ms. @@ -280,7 +282,8 @@ class BweTestFramework_DelayFilterTest : public ::testing::Test { } protected: - void TestDelayFilter(int64_t run_for_ms, uint32_t in_packets, + void TestDelayFilter(int64_t run_for_ms, + uint32_t in_packets, uint32_t out_packets) { Packets packets; for (uint32_t i = 0; i < in_packets; ++i) { @@ -301,7 +304,7 @@ class BweTestFramework_DelayFilterTest : public ::testing::Test { void TestDelayFilter(int64_t delay_ms) { filter_.SetOneWayDelayMs(delay_ms); - TestDelayFilter(1, 0, 0); // No input should yield no output + TestDelayFilter(1, 0, 0); // No input should yield no output // Single packet TestDelayFilter(0, 1, 1); @@ -357,8 +360,8 @@ TEST_F(BweTestFramework_DelayFilterTest, Delay0) { TestDelayFilter(1, 10, 10); // Expect no delay (delay time is zero) TestDelayFilter(1, 0, 0); // Check no packets are still in buffer filter_.SetOneWayDelayMs(0); - TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero) - TestDelayFilter(1, 0, 0); // Check no packets are still in buffer + TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero) + TestDelayFilter(1, 0, 0); // Check no packets are still in buffer } TEST_F(BweTestFramework_DelayFilterTest, Delay1) { @@ -580,11 +583,7 @@ TEST(BweTestFramework_ReorderFilterTest, Reorder100) { class BweTestFramework_ChokeFilterTest : public ::testing::Test { public: BweTestFramework_ChokeFilterTest() - : now_ms_(0), - sequence_number_(0), - output_packets_(), - send_times_us_() { - } + : now_ms_(0), sequence_number_(0), output_packets_(), send_times_us_() {} virtual ~BweTestFramework_ChokeFilterTest() { for (auto* packet : output_packets_) delete packet; diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.cc b/modules/remote_bitrate_estimator/test/bwe_test_logging.cc index 68f3cb052e..571ed50c0e 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_logging.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test_logging.cc @@ -41,12 +41,14 @@ Logging::Context::Context(uint32_t name, int64_t timestamp_ms, bool enabled) { Logging::GetInstance()->PushState(ToString(name), timestamp_ms, enabled); } -Logging::Context::Context(const std::string& name, int64_t timestamp_ms, +Logging::Context::Context(const std::string& name, + int64_t timestamp_ms, bool enabled) { Logging::GetInstance()->PushState(name, timestamp_ms, enabled); } -Logging::Context::Context(const char* name, int64_t timestamp_ms, +Logging::Context::Context(const char* name, + int64_t timestamp_ms, bool enabled) { Logging::GetInstance()->PushState(name, timestamp_ms, enabled); } @@ -204,20 +206,16 @@ void Logging::PlotLabel(int figure, } } -Logging::Logging() - : thread_map_() { -} +Logging::Logging() : thread_map_() {} Logging::~Logging() = default; Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {} -Logging::State::State(const std::string& tag, int64_t timestamp_ms, +Logging::State::State(const std::string& tag, + int64_t timestamp_ms, bool enabled) - : tag(tag), - timestamp_ms(timestamp_ms), - enabled(enabled) { -} + : tag(tag), timestamp_ms(timestamp_ms), enabled(enabled) {} void Logging::State::MergePrevious(const State& previous) { if (tag.empty()) { @@ -229,7 +227,8 @@ void Logging::State::MergePrevious(const State& previous) { enabled = previous.enabled && enabled; } -void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms, +void Logging::PushState(const std::string& append_to_tag, + int64_t timestamp_ms, bool enabled) { rtc::CritScope cs(&crit_sect_); State new_state(append_to_tag, timestamp_ms, enabled); diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.h b/modules/remote_bitrate_estimator/test/bwe_test_logging.h index 0f84249150..20a29cc793 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_logging.h +++ b/modules/remote_bitrate_estimator/test/bwe_test_logging.h @@ -132,57 +132,56 @@ #include "rtc_base/constructormagic.h" #include "rtc_base/criticalsection.h" -#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \ - do { \ - webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \ - } while (0) +#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \ + do { \ + webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \ + } while (0) -#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \ - do { \ - webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \ - } while (0) +#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \ + do { \ + webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \ + } while (0) -#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx ## line +#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx##line #define __BWE_TEST_LOGGING_CONTEXT_DECLARE(ctx, line, name, time, enabled) \ - webrtc::testing::bwe::Logging::Context \ - __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line)(name, time, enabled) + webrtc::testing::bwe::Logging::Context __BWE_TEST_LOGGING_CONTEXT_NAME( \ + ctx, line)(name, time, enabled) #define BWE_TEST_LOGGING_CONTEXT(name) \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true) -#define BWE_TEST_LOGGING_ENABLE(enabled) \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \ - static_cast(enabled)) -#define BWE_TEST_LOGGING_TIME(time) \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \ - static_cast(time), true) + __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true) +#define BWE_TEST_LOGGING_ENABLE(enabled) \ + __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \ + static_cast(enabled)) +#define BWE_TEST_LOGGING_TIME(time) \ + __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \ + static_cast(time), true) -#define BWE_TEST_LOGGING_LOG1(name, format, _1) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \ - } while (0) -#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \ - } while (0) -#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \ - } while (0) -#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ - _4); \ - } while (0) -#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ - do {\ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ - _4, _5); \ - } while (0) +#define BWE_TEST_LOGGING_LOG1(name, format, _1) \ + do { \ + BWE_TEST_LOGGING_CONTEXT(name); \ + webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \ + } while (0) +#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \ + do { \ + BWE_TEST_LOGGING_CONTEXT(name); \ + webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \ + } while (0) +#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \ + do { \ + BWE_TEST_LOGGING_CONTEXT(name); \ + webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \ + } while (0) +#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \ + do { \ + BWE_TEST_LOGGING_CONTEXT(name); \ + webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4); \ + } while (0) +#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ + do { \ + BWE_TEST_LOGGING_CONTEXT(name); \ + webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4, \ + _5); \ + } while (0) #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \ do { \ @@ -266,6 +265,7 @@ class Logging { Context(const std::string& name, int64_t timestamp_ms, bool enabled); Context(const char* name, int64_t timestamp_ms, bool enabled); ~Context(); + private: RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Context); }; @@ -281,7 +281,8 @@ class Logging { // Note: Implicit |this| argument counts as the first argument. __attribute__((__format__(__printf__, 2, 3))) #endif - void Log(const char format[], ...); + void + Log(const char format[], ...); void Plot(int figure, const std::string& name, double value); void Plot(int figure, const std::string& name, @@ -340,7 +341,8 @@ class Logging { Logging(); ~Logging(); - void PushState(const std::string& append_to_tag, int64_t timestamp_ms, + void PushState(const std::string& append_to_tag, + int64_t timestamp_ms, bool enabled); void PopState(); diff --git a/modules/remote_bitrate_estimator/test/estimators/bbr.h b/modules/remote_bitrate_estimator/test/estimators/bbr.h index 1d16ac515c..ee45dbfee0 100644 --- a/modules/remote_bitrate_estimator/test/estimators/bbr.h +++ b/modules/remote_bitrate_estimator/test/estimators/bbr.h @@ -230,6 +230,7 @@ class BbrBweReceiver : public BweReceiver { void ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) override; FeedbackPacket* GetFeedback(int64_t now_ms) override; + private: SimulatedClock clock_; std::vector packet_feedbacks_; diff --git a/modules/remote_bitrate_estimator/test/estimators/nada.cc b/modules/remote_bitrate_estimator/test/estimators/nada.cc index d3d0baea0e..e74397e72e 100644 --- a/modules/remote_bitrate_estimator/test/estimators/nada.cc +++ b/modules/remote_bitrate_estimator/test/estimators/nada.cc @@ -46,11 +46,9 @@ NadaBweReceiver::NadaBweReceiver(int flow_id) last_congestion_signal_ms_(0), last_delays_index_(0), exp_smoothed_delay_ms_(-1), - est_queuing_delay_signal_ms_(0) { -} + est_queuing_delay_signal_ms_(0) {} -NadaBweReceiver::~NadaBweReceiver() { -} +NadaBweReceiver::~NadaBweReceiver() {} void NadaBweReceiver::ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) { @@ -162,8 +160,7 @@ NadaBweSender::NadaBweSender(int kbps, BitrateObserver* observer, Clock* clock) : BweSender(kbps), // Referred as "Reference Rate" = R_n., clock_(clock), observer_(observer), - original_operating_mode_(true) { -} + original_operating_mode_(true) {} NadaBweSender::NadaBweSender(BitrateObserver* observer, Clock* clock) : BweSender(kMinNadaBitrateKbps), // Referred as "Reference Rate" = R_n. @@ -171,8 +168,7 @@ NadaBweSender::NadaBweSender(BitrateObserver* observer, Clock* clock) observer_(observer), original_operating_mode_(true) {} -NadaBweSender::~NadaBweSender() { -} +NadaBweSender::~NadaBweSender() {} int NadaBweSender::GetFeedbackIntervalMs() const { return 100; @@ -243,8 +239,7 @@ int64_t NadaBweSender::TimeUntilNextProcess() { return 100; } -void NadaBweSender::Process() { -} +void NadaBweSender::Process() {} void NadaBweSender::AcceleratedRampUp(const NadaFeedback& fb) { const int kMaxRampUpQueuingDelayMs = 50; // Referred as T_th. diff --git a/modules/remote_bitrate_estimator/test/estimators/nada.h b/modules/remote_bitrate_estimator/test/estimators/nada.h index f00a6d3690..c9b7cd683f 100644 --- a/modules/remote_bitrate_estimator/test/estimators/nada.h +++ b/modules/remote_bitrate_estimator/test/estimators/nada.h @@ -7,7 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. * -*/ + */ // Implementation of Network-Assisted Dynamic Adaptation's (NADA's) proposal // Version according to Draft Document (mentioned in references) diff --git a/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc b/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc index eac9e9349a..2b48528a10 100644 --- a/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc +++ b/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc @@ -426,8 +426,8 @@ TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) { // Raw delays are = [50 250 450 650 850 1050 1250 1450] ms. // Baseline delay will be 50 ms. // Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms. - const int64_t kMedianFilteredDelaysMs[] = { - 0, 100, 200, 300, 400, 600, 800, 1000}; + const int64_t kMedianFilteredDelaysMs[] = {0, 100, 200, 300, + 400, 600, 800, 1000}; const int kNumPackets = arraysize(kMedianFilteredDelaysMs); const float kAlpha = 0.1f; // Used for exponential smoothing. diff --git a/modules/remote_bitrate_estimator/test/estimators/remb.cc b/modules/remote_bitrate_estimator/test/estimators/remb.cc index ae9638923a..51b38ac763 100644 --- a/modules/remote_bitrate_estimator/test/estimators/remb.cc +++ b/modules/remote_bitrate_estimator/test/estimators/remb.cc @@ -37,8 +37,7 @@ RembBweSender::RembBweSender(int kbps, BitrateObserver* observer, Clock* clock) 1000 * kMaxBitrateKbps); } -RembBweSender::~RembBweSender() { -} +RembBweSender::~RembBweSender() {} void RembBweSender::GiveFeedback(const FeedbackPacket& feedback) { const RembFeedback& remb_feedback = @@ -80,8 +79,7 @@ RembReceiver::RembReceiver(int flow_id, bool plot) estimator_->SetMinBitrate(kRemoteBitrateEstimatorMinBitrateBps); } -RembReceiver::~RembReceiver() { -} +RembReceiver::~RembReceiver() {} void RembReceiver::ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) { diff --git a/modules/remote_bitrate_estimator/test/estimators/send_side.cc b/modules/remote_bitrate_estimator/test/estimators/send_side.cc index 6e03eee942..563c33550e 100644 --- a/modules/remote_bitrate_estimator/test/estimators/send_side.cc +++ b/modules/remote_bitrate_estimator/test/estimators/send_side.cc @@ -143,11 +143,9 @@ void SendSideBweSender::Process() { } SendSideBweReceiver::SendSideBweReceiver(int flow_id) - : BweReceiver(flow_id), last_feedback_ms_(0) { -} + : BweReceiver(flow_id), last_feedback_ms_(0) {} -SendSideBweReceiver::~SendSideBweReceiver() { -} +SendSideBweReceiver::~SendSideBweReceiver() {} void SendSideBweReceiver::ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) { diff --git a/modules/remote_bitrate_estimator/test/estimators/tcp.cc b/modules/remote_bitrate_estimator/test/estimators/tcp.cc index 5899837985..759c2f62a7 100644 --- a/modules/remote_bitrate_estimator/test/estimators/tcp.cc +++ b/modules/remote_bitrate_estimator/test/estimators/tcp.cc @@ -22,13 +22,9 @@ namespace testing { namespace bwe { TcpBweReceiver::TcpBweReceiver(int flow_id) - : BweReceiver(flow_id), - last_feedback_ms_(0), - latest_owd_ms_(0) { -} + : BweReceiver(flow_id), last_feedback_ms_(0), latest_owd_ms_(0) {} -TcpBweReceiver::~TcpBweReceiver() { -} +TcpBweReceiver::~TcpBweReceiver() {} void TcpBweReceiver::ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) { diff --git a/modules/remote_bitrate_estimator/test/metric_recorder.cc b/modules/remote_bitrate_estimator/test/metric_recorder.cc index 612ad4ab46..b33afb25c4 100644 --- a/modules/remote_bitrate_estimator/test/metric_recorder.cc +++ b/modules/remote_bitrate_estimator/test/metric_recorder.cc @@ -27,13 +27,12 @@ template double NormLp(T sum, size_t size, double p) { return pow(sum / size, 1.0 / p); } -} +} // namespace const double kP = 1.0; // Used for Norm Lp. LinkShare::LinkShare(ChokeFilter* choke_filter) - : choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) { -} + : choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) {} void LinkShare::PauseFlow(int flow_id) { running_flows_.erase(flow_id); @@ -288,10 +287,10 @@ void MetricRecorder::PlotThroughputHistogram( average_bitrate_kbps + pos_error + extra_error, "estimate_error", optimal_bitrate_per_flow_kbps, optimum_title, flow_id_); - BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Channel utilization : ", - "%lf %%", - 100.0 * static_cast(average_bitrate_kbps) / - optimal_bitrate_per_flow_kbps); + BWE_TEST_LOGGING_LOG1( + "RESULTS >>> " + bwe_name + " Channel utilization : ", "%lf %%", + 100.0 * static_cast(average_bitrate_kbps) / + optimal_bitrate_per_flow_kbps); RTC_UNUSED(pos_error); RTC_UNUSED(neg_error); diff --git a/modules/remote_bitrate_estimator/test/packet.h b/modules/remote_bitrate_estimator/test/packet.h index 0a0e0ca7b5..3050e54ba6 100644 --- a/modules/remote_bitrate_estimator/test/packet.h +++ b/modules/remote_bitrate_estimator/test/packet.h @@ -17,8 +17,8 @@ #include #include "common_types.h" // NOLINT(build/include) -#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" namespace webrtc { namespace testing { diff --git a/modules/remote_bitrate_estimator/test/packet_receiver.cc b/modules/remote_bitrate_estimator/test/packet_receiver.cc index f4a42ed182..d68ea9a37b 100644 --- a/modules/remote_bitrate_estimator/test/packet_receiver.cc +++ b/modules/remote_bitrate_estimator/test/packet_receiver.cc @@ -68,11 +68,9 @@ PacketReceiver::PacketReceiver(PacketProcessorListener* listener, bwe_type, plot_delay, plot_bwe, - nullptr) { -} + nullptr) {} -PacketReceiver::~PacketReceiver() { -} +PacketReceiver::~PacketReceiver() {} void PacketReceiver::RunFor(int64_t time_ms, Packets* in_out) { Packets feedback; diff --git a/modules/remote_bitrate_estimator/test/packet_sender.cc b/modules/remote_bitrate_estimator/test/packet_sender.cc index d45f363491..fbd69560e4 100644 --- a/modules/remote_bitrate_estimator/test/packet_sender.cc +++ b/modules/remote_bitrate_estimator/test/packet_sender.cc @@ -86,8 +86,7 @@ VideoSender::VideoSender(PacketProcessorListener* listener, modules_.push_back(bwe_.get()); } -VideoSender::~VideoSender() { -} +VideoSender::~VideoSender() {} void VideoSender::Pause() { previous_sending_bitrate_ = TargetBitrateKbps(); @@ -338,8 +337,7 @@ const int kPacketSizeBytes = 1200; TcpSender::TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms) - : TcpSender(listener, flow_id, offset_ms, kNoLimit) { -} + : TcpSender(listener, flow_id, offset_ms, kNoLimit) {} TcpSender::TcpSender(PacketProcessorListener* listener, int flow_id, @@ -358,8 +356,7 @@ TcpSender::TcpSender(PacketProcessorListener* listener, send_limit_bytes_(send_limit_bytes), last_generated_packets_ms_(0), num_recent_sent_packets_(0), - bitrate_kbps_(0) { -} + bitrate_kbps_(0) {} void TcpSender::RunFor(int64_t time_ms, Packets* in_out) { if (clock_.TimeInMilliseconds() + time_ms < offset_ms_) { @@ -477,8 +474,8 @@ Packets TcpSender::GeneratePackets(size_t num_packets) { generated.push_back( new MediaPacket(*flow_ids().begin(), 1000 * clock_.TimeInMilliseconds(), kPacketSizeBytes, next_sequence_number_++)); - generated.back()->set_sender_timestamp_us( - 1000 * clock_.TimeInMilliseconds()); + generated.back()->set_sender_timestamp_us(1000 * + clock_.TimeInMilliseconds()); total_sent_bytes_ += kPacketSizeBytes; } diff --git a/modules/remote_bitrate_estimator/test/packet_sender.h b/modules/remote_bitrate_estimator/test/packet_sender.h index 81a466bca4..718b5b76f8 100644 --- a/modules/remote_bitrate_estimator/test/packet_sender.h +++ b/modules/remote_bitrate_estimator/test/packet_sender.h @@ -11,8 +11,8 @@ #ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ #define MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ -#include #include +#include #include #include #include diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp.cc b/modules/remote_bitrate_estimator/tools/bwe_rtp.cc index 2fcb4241e3..47e3cfa761 100644 --- a/modules/remote_bitrate_estimator/tools/bwe_rtp.cc +++ b/modules/remote_bitrate_estimator/tools/bwe_rtp.cc @@ -128,13 +128,13 @@ bool ParseArgsAndSetupEstimator(int argc, new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock); *estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator"; break; - } + } case webrtc::kRtpExtensionTransmissionTimeOffset: { *estimator = new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock); - *estimator_used = "RemoteBitrateEstimator"; - break; - } + *estimator_used = "RemoteBitrateEstimator"; + break; + } default: assert(false); } diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp.h b/modules/remote_bitrate_estimator/tools/bwe_rtp.h index 9a4723b795..57484fd95d 100644 --- a/modules/remote_bitrate_estimator/tools/bwe_rtp.h +++ b/modules/remote_bitrate_estimator/tools/bwe_rtp.h @@ -21,16 +21,15 @@ class RtpHeaderParser; namespace test { class RtpFileReader; } -} +} // namespace webrtc -bool ParseArgsAndSetupEstimator( - int argc, - char** argv, - webrtc::Clock* clock, - webrtc::RemoteBitrateObserver* observer, - webrtc::test::RtpFileReader** rtp_reader, - webrtc::RtpHeaderParser** parser, - webrtc::RemoteBitrateEstimator** estimator, - std::string* estimator_used); +bool ParseArgsAndSetupEstimator(int argc, + char** argv, + webrtc::Clock* clock, + webrtc::RemoteBitrateObserver* observer, + webrtc::test::RtpFileReader** rtp_reader, + webrtc::RtpHeaderParser** parser, + webrtc::RemoteBitrateEstimator** estimator, + std::string* estimator_used); #endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_ diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc index 887921b6ae..0594a33500 100644 --- a/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc +++ b/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc @@ -104,10 +104,8 @@ int main(int argc, char* argv[]) { printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter, clock.TimeInMilliseconds()); printf("Estimator used: %s\n", estimator_used.c_str()); - printf("Packets with absolute send time: %d\n", - abs_send_time_count); - printf("Packets with timestamp offset: %d\n", - ts_offset_count); + printf("Packets with absolute send time: %d\n", abs_send_time_count); + printf("Packets with timestamp offset: %d\n", ts_offset_count); printf("Packets with no extension: %d\n", packet_counter - ts_offset_count - abs_send_time_count); return 0; diff --git a/modules/remote_bitrate_estimator/tools/rtp_to_text.cc b/modules/remote_bitrate_estimator/tools/rtp_to_text.cc index 54f027a069..9e82da4714 100644 --- a/modules/remote_bitrate_estimator/tools/rtp_to_text.cc +++ b/modules/remote_bitrate_estimator/tools/rtp_to_text.cc @@ -29,7 +29,8 @@ int main(int argc, char* argv[]) { bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0); std::unique_ptr rtp_reader(reader); std::unique_ptr rtp_parser(parser); - fprintf(stdout, "seqnum timestamp ts_offset abs_sendtime recvtime " + fprintf(stdout, + "seqnum timestamp ts_offset abs_sendtime recvtime " "markerbit ssrc size original_size\n"); int packet_counter = 0; int non_zero_abs_send_time = 0; @@ -47,24 +48,19 @@ int main(int argc, char* argv[]) { ss << static_cast(packet.time_ms) * 1000000; fprintf(stdout, "%s\n", ss.str().c_str()); } else { - fprintf(stdout, - "%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n", - header.sequenceNumber, - header.timestamp, + fprintf(stdout, "%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n", + header.sequenceNumber, header.timestamp, header.extension.transmissionTimeOffset, - header.extension.absoluteSendTime, - packet.time_ms, - header.markerBit, - header.ssrc, - packet.length, + header.extension.absoluteSendTime, packet.time_ms, + header.markerBit, header.ssrc, packet.length, packet.original_length); } ++packet_counter; } fprintf(stderr, "Parsed %d packets\n", packet_counter); fprintf(stderr, "Packets with non-zero absolute send time: %d\n", - non_zero_abs_send_time); + non_zero_abs_send_time); fprintf(stderr, "Packets with non-zero timestamp offset: %d\n", - non_zero_ts_offsets); + non_zero_ts_offsets); return 0; } diff --git a/modules/rtp_rtcp/include/receive_statistics.h b/modules/rtp_rtcp/include/receive_statistics.h index acf8317b59..0adc79bcd0 100644 --- a/modules/rtp_rtcp/include/receive_statistics.h +++ b/modules/rtp_rtcp/include/receive_statistics.h @@ -16,8 +16,8 @@ #include "modules/include/module.h" #include "modules/include/module_common_types.h" -#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h index e3d95b20ca..5195e8ab7e 100644 --- a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h +++ b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h @@ -33,7 +33,9 @@ class RemoteNtpTimeEstimator { // Updates the estimator with round trip time |rtt|, NTP seconds |ntp_secs|, // NTP fraction |ntp_frac| and RTP timestamp |rtcp_timestamp|. - bool UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, + bool UpdateRtcpTimestamp(int64_t rtt, + uint32_t ntp_secs, + uint32_t ntp_frac, uint32_t rtp_timestamp); // Estimates the NTP timestamp in local timebase from |rtp_timestamp|. diff --git a/modules/rtp_rtcp/include/rtp_payload_registry.h b/modules/rtp_rtcp/include/rtp_payload_registry.h index c80f475c44..be296da957 100644 --- a/modules/rtp_rtcp/include/rtp_payload_registry.h +++ b/modules/rtp_rtcp/include/rtp_payload_registry.h @@ -68,8 +68,8 @@ class RTPPayloadRegistry { std::map payload_type_map_; int8_t last_received_payload_type_; - // As a first step in splitting this class up in separate cases for audio and - // video, DCHECK that no instance is used for both audio and video. +// As a first step in splitting this class up in separate cases for audio and +// video, DCHECK that no instance is used for both audio and video. #if RTC_DCHECK_IS_ON bool used_for_audio_ RTC_GUARDED_BY(crit_sect_) = false; bool used_for_video_ RTC_GUARDED_BY(crit_sect_) = false; diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h index 2cd3c5465d..d3515f6fa6 100644 --- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h +++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h @@ -22,8 +22,8 @@ #include "system_wrappers/include/clock.h" #include "typedefs.h" // NOLINT(build/include) -#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination -#define IP_PACKET_SIZE 1500 // we assume ethernet +#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination +#define IP_PACKET_SIZE 1500 // we assume ethernet #define MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS 10 namespace webrtc { @@ -97,15 +97,9 @@ class PayloadUnion { enum RTPAliveType { kRtpDead = 0, kRtpNoRtp = 1, kRtpAlive = 2 }; -enum ProtectionType { - kUnprotectedPacket, - kProtectedPacket -}; +enum ProtectionType { kUnprotectedPacket, kProtectedPacket }; -enum StorageType { - kDontRetransmit, - kAllowRetransmission -}; +enum StorageType { kDontRetransmit, kAllowRetransmission }; enum RTPExtensionType { kRtpExtensionNone, @@ -166,10 +160,10 @@ enum RetransmissionMode : uint8_t { }; enum RtxMode { - kRtxOff = 0x0, - kRtxRetransmitted = 0x1, // Only send retransmissions over RTX. - kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads - // instead of padding. + kRtxOff = 0x0, + kRtxRetransmitted = 0x1, // Only send retransmissions over RTX. + kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads + // instead of padding. }; const size_t kRtxHeaderSize = 2; diff --git a/modules/rtp_rtcp/source/byte_io.h b/modules/rtp_rtcp/source/byte_io.h index e482452b9f..f9d973b0fe 100644 --- a/modules/rtp_rtcp/source/byte_io.h +++ b/modules/rtp_rtcp/source/byte_io.h @@ -11,7 +11,6 @@ #ifndef MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ #define MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ - // This file contains classes for reading and writing integer types from/to // byte array representations. Signed/unsigned, partial (whole byte) sizes, // and big/little endian byte order is all supported. @@ -35,7 +34,6 @@ // These classes are implemented as recursive templetizations, inteded to make // it easy for the compiler to completely inline the reading/writing. - #include #include "typedefs.h" // NOLINT(build/include) @@ -129,8 +127,8 @@ class ByteReader { // two's complement for is used. static T ReinterpretAsSigned(U unsigned_val) { // An unsigned value with only the highest order bit set (ex 0x80). - const U kUnsignedHighestBitMask = - static_cast(1) << ((sizeof(U) * 8) - 1); + const U kUnsignedHighestBitMask = static_cast(1) + << ((sizeof(U) * 8) - 1); // A signed value with only the highest bit set. Since this is two's // complement form, we can use the min value from std::numeric_limits. const T kSignedHighestBitMask = std::numeric_limits::min(); @@ -353,20 +351,16 @@ class ByteReader { public: static T ReadBigEndian(const uint8_t* data) { static_assert(sizeof(T) >= 8, kSizeErrorMsg); - return - (Get(data, 0) << 56) | (Get(data, 1) << 48) | - (Get(data, 2) << 40) | (Get(data, 3) << 32) | - (Get(data, 4) << 24) | (Get(data, 5) << 16) | - (Get(data, 6) << 8) | Get(data, 7); + return (Get(data, 0) << 56) | (Get(data, 1) << 48) | (Get(data, 2) << 40) | + (Get(data, 3) << 32) | (Get(data, 4) << 24) | (Get(data, 5) << 16) | + (Get(data, 6) << 8) | Get(data, 7); } static T ReadLittleEndian(const uint8_t* data) { static_assert(sizeof(T) >= 8, kSizeErrorMsg); - return - Get(data, 0) | (Get(data, 1) << 8) | - (Get(data, 2) << 16) | (Get(data, 3) << 24) | - (Get(data, 4) << 32) | (Get(data, 5) << 40) | - (Get(data, 6) << 48) | (Get(data, 7) << 56); + return Get(data, 0) | (Get(data, 1) << 8) | (Get(data, 2) << 16) | + (Get(data, 3) << 24) | (Get(data, 4) << 32) | (Get(data, 5) << 40) | + (Get(data, 6) << 48) | (Get(data, 7) << 56); } private: diff --git a/modules/rtp_rtcp/source/byte_io_unittest.cc b/modules/rtp_rtcp/source/byte_io_unittest.cc index 3ddb7617bf..20b66362fc 100644 --- a/modules/rtp_rtcp/source/byte_io_unittest.cc +++ b/modules/rtp_rtcp/source/byte_io_unittest.cc @@ -127,10 +127,10 @@ class ByteIoTest : public ::testing::Test { }; TEST_F(ByteIoTest, Test16UBitBigEndian) { - TestRead::ReadBigEndian, - sizeof(uint16_t)>(true); - TestWrite::WriteBigEndian, - sizeof(uint16_t)>(true); + TestRead::ReadBigEndian, sizeof(uint16_t)>( + true); + TestWrite::WriteBigEndian, sizeof(uint16_t)>( + true); } TEST_F(ByteIoTest, Test24UBitBigEndian) { @@ -139,24 +139,23 @@ TEST_F(ByteIoTest, Test24UBitBigEndian) { } TEST_F(ByteIoTest, Test32UBitBigEndian) { - TestRead::ReadBigEndian, - sizeof(uint32_t)>(true); - TestWrite::WriteBigEndian, - sizeof(uint32_t)>(true); + TestRead::ReadBigEndian, sizeof(uint32_t)>( + true); + TestWrite::WriteBigEndian, sizeof(uint32_t)>( + true); } TEST_F(ByteIoTest, Test64UBitBigEndian) { - TestRead::ReadBigEndian, - sizeof(uint64_t)>(true); - TestWrite::WriteBigEndian, - sizeof(uint64_t)>(true); + TestRead::ReadBigEndian, sizeof(uint64_t)>( + true); + TestWrite::WriteBigEndian, sizeof(uint64_t)>( + true); } TEST_F(ByteIoTest, Test16SBitBigEndian) { - TestRead::ReadBigEndian, - sizeof(int16_t)>(true); - TestWrite::WriteBigEndian, - sizeof(int16_t)>(true); + TestRead::ReadBigEndian, sizeof(int16_t)>(true); + TestWrite::WriteBigEndian, sizeof(int16_t)>( + true); } TEST_F(ByteIoTest, Test24SBitBigEndian) { @@ -165,24 +164,22 @@ TEST_F(ByteIoTest, Test24SBitBigEndian) { } TEST_F(ByteIoTest, Test32SBitBigEndian) { - TestRead::ReadBigEndian, - sizeof(int32_t)>(true); - TestWrite::WriteBigEndian, - sizeof(int32_t)>(true); + TestRead::ReadBigEndian, sizeof(int32_t)>(true); + TestWrite::WriteBigEndian, sizeof(int32_t)>( + true); } TEST_F(ByteIoTest, Test64SBitBigEndian) { - TestRead::ReadBigEndian, - sizeof(int64_t)>(true); - TestWrite::WriteBigEndian, - sizeof(int64_t)>(true); + TestRead::ReadBigEndian, sizeof(int64_t)>(true); + TestWrite::WriteBigEndian, sizeof(int64_t)>( + true); } TEST_F(ByteIoTest, Test16UBitLittleEndian) { - TestRead::ReadLittleEndian, - sizeof(uint16_t)>(false); + TestRead::ReadLittleEndian, sizeof(uint16_t)>( + false); TestWrite::WriteLittleEndian, - sizeof(uint16_t)>(false); + sizeof(uint16_t)>(false); } TEST_F(ByteIoTest, Test24UBitLittleEndian) { @@ -191,24 +188,24 @@ TEST_F(ByteIoTest, Test24UBitLittleEndian) { } TEST_F(ByteIoTest, Test32UBitLittleEndian) { - TestRead::ReadLittleEndian, - sizeof(uint32_t)>(false); + TestRead::ReadLittleEndian, sizeof(uint32_t)>( + false); TestWrite::WriteLittleEndian, - sizeof(uint32_t)>(false); + sizeof(uint32_t)>(false); } TEST_F(ByteIoTest, Test64UBitLittleEndian) { - TestRead::ReadLittleEndian, - sizeof(uint64_t)>(false); + TestRead::ReadLittleEndian, sizeof(uint64_t)>( + false); TestWrite::WriteLittleEndian, - sizeof(uint64_t)>(false); + sizeof(uint64_t)>(false); } TEST_F(ByteIoTest, Test16SBitLittleEndian) { - TestRead::ReadLittleEndian, - sizeof(int16_t)>(false); - TestWrite::WriteLittleEndian, - sizeof(int16_t)>(false); + TestRead::ReadLittleEndian, sizeof(int16_t)>( + false); + TestWrite::WriteLittleEndian, sizeof(int16_t)>( + false); } TEST_F(ByteIoTest, Test24SBitLittleEndian) { @@ -217,17 +214,17 @@ TEST_F(ByteIoTest, Test24SBitLittleEndian) { } TEST_F(ByteIoTest, Test32SBitLittleEndian) { - TestRead::ReadLittleEndian, - sizeof(int32_t)>(false); - TestWrite::WriteLittleEndian, - sizeof(int32_t)>(false); + TestRead::ReadLittleEndian, sizeof(int32_t)>( + false); + TestWrite::WriteLittleEndian, sizeof(int32_t)>( + false); } TEST_F(ByteIoTest, Test64SBitLittleEndian) { - TestRead::ReadLittleEndian, - sizeof(int64_t)>(false); - TestWrite::WriteLittleEndian, - sizeof(int64_t)>(false); + TestRead::ReadLittleEndian, sizeof(int64_t)>( + false); + TestWrite::WriteLittleEndian, sizeof(int64_t)>( + false); } // Sets up a fixed byte array and converts N bytes from the array into a diff --git a/modules/rtp_rtcp/source/fec_private_tables_bursty.cc b/modules/rtp_rtcp/source/fec_private_tables_bursty.cc index 49a590bf47..9dbc012368 100644 --- a/modules/rtp_rtcp/source/fec_private_tables_bursty.cc +++ b/modules/rtp_rtcp/source/fec_private_tables_bursty.cc @@ -10,7 +10,6 @@ #include "modules/rtp_rtcp/source/fec_private_tables_bursty.h" - namespace { // clang-format off #define kMaskBursty1_1 \ diff --git a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc index 4c2a48d222..ddc2805209 100644 --- a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc @@ -281,11 +281,11 @@ TEST(FlexfecSenderTest, MaxPacketOverheadWithExtensions) { SimulatedClock clock(kInitialSimulatedClockTime); const size_t kExtensionHeaderLength = 1; const size_t kRtpOneByteHeaderLength = 4; - const size_t kExtensionsTotalSize = Word32Align( - kRtpOneByteHeaderLength + - kExtensionHeaderLength + AbsoluteSendTime::kValueSizeBytes + - kExtensionHeaderLength + TransmissionOffset::kValueSizeBytes + - kExtensionHeaderLength + TransportSequenceNumber::kValueSizeBytes); + const size_t kExtensionsTotalSize = + Word32Align(kRtpOneByteHeaderLength + kExtensionHeaderLength + + AbsoluteSendTime::kValueSizeBytes + kExtensionHeaderLength + + TransmissionOffset::kValueSizeBytes + kExtensionHeaderLength + + TransportSequenceNumber::kValueSizeBytes); FlexfecSender sender(kFlexfecPayloadType, kFlexfecSsrc, kMediaSsrc, kNoMid, kRtpHeaderExtensions, RTPSender::FecExtensionSizes(), nullptr /* rtp_state */, &clock); diff --git a/modules/rtp_rtcp/source/forward_error_correction.cc b/modules/rtp_rtcp/source/forward_error_correction.cc index 30689e38ae..b743110b2d 100644 --- a/modules/rtp_rtcp/source/forward_error_correction.cc +++ b/modules/rtp_rtcp/source/forward_error_correction.cc @@ -52,7 +52,7 @@ int32_t ForwardErrorCorrection::Packet::Release() { // the std::unique_ptr's are not covariant w.r.t. the types that // they are pointing to. template -bool ForwardErrorCorrection::SortablePacket::LessThan::operator() ( +bool ForwardErrorCorrection::SortablePacket::LessThan::operator()( const S& first, const T& second) { RTC_DCHECK_EQ(first->ssrc, second->ssrc); diff --git a/modules/rtp_rtcp/source/forward_error_correction.h b/modules/rtp_rtcp/source/forward_error_correction.h index 1f06b296e9..819f6bcec5 100644 --- a/modules/rtp_rtcp/source/forward_error_correction.h +++ b/modules/rtp_rtcp/source/forward_error_correction.h @@ -67,7 +67,7 @@ class ForwardErrorCorrection { // packets belonging to the same SSRC. struct LessThan { template - bool operator() (const S& first, const T& second); + bool operator()(const S& first, const T& second); }; uint32_t ssrc; @@ -83,8 +83,8 @@ class ForwardErrorCorrection { ReceivedPacket(); ~ReceivedPacket(); - bool is_fec; // Set to true if this is an FEC packet and false - // otherwise. + bool is_fec; // Set to true if this is an FEC packet and false + // otherwise. rtc::scoped_refptr pkt; // Pointer to the packet storage. }; diff --git a/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/modules/rtp_rtcp/source/nack_rtx_unittest.cc index 77750247c7..53ff5d5f2f 100644 --- a/modules/rtp_rtcp/source/nack_rtx_unittest.cc +++ b/modules/rtp_rtcp/source/nack_rtx_unittest.cc @@ -1,12 +1,12 @@ /* -* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. -* -* 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. -*/ + * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. + * + * 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. + */ #include #include @@ -62,9 +62,7 @@ class RtxLoopBackTransport : public webrtc::Transport { count_rtx_ssrc_(0), module_(NULL) {} - void SetSendModule(RtpRtcp* rtpRtcpModule) { - module_ = rtpRtcpModule; - } + void SetSendModule(RtpRtcp* rtpRtcpModule) { module_ = rtpRtcpModule; } void DropEveryNthPacket(int n) { packet_loss_ = n; } @@ -120,9 +118,7 @@ class RtpRtcpRtxNackTest : public ::testing::Test { RtpRtcpRtxNackTest() : rtp_rtcp_module_(nullptr), transport_(kTestRtxSsrc), - rtx_stream_(&media_stream_, - rtx_associated_payload_types_, - kTestSsrc), + rtx_stream_(&media_stream_, rtx_associated_payload_types_, kTestSsrc), payload_data_length(sizeof(payload_data)), fake_clock(123456), retransmission_rate_limiter_(&fake_clock, kMaxRttMs) {} @@ -227,8 +223,8 @@ class RtpRtcpRtxNackTest : public ::testing::Test { std::unique_ptr receive_statistics_; RtpRtcp* rtp_rtcp_module_; RtxLoopBackTransport transport_; - const std::map rtx_associated_payload_types_ = - {{kRtxPayloadType, kPayloadType}}; + const std::map rtx_associated_payload_types_ = { + {kRtxPayloadType, kPayloadType}}; VerifyingMediaStream media_stream_; RtxReceiveStream rtx_stream_; uint8_t payload_data[65000]; diff --git a/modules/rtp_rtcp/source/packet_loss_stats.cc b/modules/rtp_rtcp/source/packet_loss_stats.cc index 35184db3db..076348d2da 100644 --- a/modules/rtp_rtcp/source/packet_loss_stats.cc +++ b/modules/rtp_rtcp/source/packet_loss_stats.cc @@ -23,24 +23,24 @@ namespace webrtc { PacketLossStats::PacketLossStats() : single_loss_historic_count_(0), multiple_loss_historic_event_count_(0), - multiple_loss_historic_packet_count_(0) { -} + multiple_loss_historic_packet_count_(0) {} PacketLossStats::~PacketLossStats() = default; void PacketLossStats::AddLostPacket(uint16_t sequence_number) { // Detect sequence number wrap around. if (!lost_packets_buffer_.empty() && - static_cast(*(lost_packets_buffer_.rbegin())) - sequence_number - > 0x8000) { + static_cast(*(lost_packets_buffer_.rbegin())) - sequence_number > + 0x8000) { // The buffer contains large numbers and this is a small number. lost_packets_wrapped_buffer_.insert(sequence_number); } else { lost_packets_buffer_.insert(sequence_number); } - if (lost_packets_wrapped_buffer_.size() + lost_packets_buffer_.size() - > kBufferSize || (!lost_packets_wrapped_buffer_.empty() && - *(lost_packets_wrapped_buffer_.rbegin()) > 0x4000)) { + if (lost_packets_wrapped_buffer_.size() + lost_packets_buffer_.size() > + kBufferSize || + (!lost_packets_wrapped_buffer_.empty() && + *(lost_packets_wrapped_buffer_.rbegin()) > 0x4000)) { PruneBuffer(); } } diff --git a/modules/rtp_rtcp/source/receive_statistics_impl.cc b/modules/rtp_rtcp/source/receive_statistics_impl.cc index bb2833f610..888fa929e7 100644 --- a/modules/rtp_rtcp/source/receive_statistics_impl.cc +++ b/modules/rtp_rtcp/source/receive_statistics_impl.cc @@ -121,7 +121,7 @@ void StreamStatisticianImpl::UpdateJitter(const RTPHeader& header, uint32_t last_receive_time_rtp = NtpToRtp(last_receive_time_ntp_, header.payload_type_frequency); int32_t time_diff_samples = (receive_time_rtp - last_receive_time_rtp) - - (header.timestamp - last_received_timestamp_); + (header.timestamp - last_received_timestamp_); time_diff_samples = std::abs(time_diff_samples); @@ -219,9 +219,9 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() { // Number of received RTP packets since last report, counts all packets but // not re-transmissions. - uint32_t rec_since_last = - (receive_counters_.transmitted.packets - - receive_counters_.retransmitted.packets) - last_report_inorder_packets_; + uint32_t rec_since_last = (receive_counters_.transmitted.packets - + receive_counters_.retransmitted.packets) - + last_report_inorder_packets_; // With NACK we don't know the expected retransmissions during the last // second. We know how many "old" packets we have received. We just count @@ -243,8 +243,7 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() { uint8_t local_fraction_lost = 0; if (exp_since_last) { // Scale 0 to 255, where 255 is 100% loss. - local_fraction_lost = - static_cast(255 * missing / exp_since_last); + local_fraction_lost = static_cast(255 * missing / exp_since_last); } stats.fraction_lost = local_fraction_lost; @@ -261,9 +260,8 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() { last_reported_statistics_ = stats; // Only for report blocks in RTCP SR and RR. - last_report_inorder_packets_ = - receive_counters_.transmitted.packets - - receive_counters_.retransmitted.packets; + last_report_inorder_packets_ = receive_counters_.transmitted.packets - + receive_counters_.retransmitted.packets; last_report_old_packets_ = receive_counters_.retransmitted.packets; last_report_seq_max_ = received_seq_max_; BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "cumulative_loss_pkts", @@ -276,8 +274,8 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() { return stats; } -void StreamStatisticianImpl::GetDataCounters( - size_t* bytes_received, uint32_t* packets_received) const { +void StreamStatisticianImpl::GetDataCounters(size_t* bytes_received, + uint32_t* packets_received) const { rtc::CritScope cs(&stream_lock_); if (bytes_received) { *bytes_received = receive_counters_.transmitted.payload_bytes + @@ -309,8 +307,7 @@ bool StreamStatisticianImpl::IsRetransmitOfOldPacket( uint32_t frequency_khz = header.payload_type_frequency / 1000; assert(frequency_khz > 0); - int64_t time_diff_ms = clock_->TimeInMilliseconds() - - last_receive_time_ms_; + int64_t time_diff_ms = clock_->TimeInMilliseconds() - last_receive_time_ms_; // Diff in time stamp since last received in order. uint32_t timestamp_diff = header.timestamp - last_received_timestamp_; @@ -347,8 +344,8 @@ bool StreamStatisticianImpl::InOrderPacketInternal( return true; } else { // If we have a restart of the remote side this packet is still in order. - return !IsNewerSequenceNumber(sequence_number, received_seq_max_ - - max_reordering_threshold_); + return !IsNewerSequenceNumber( + sequence_number, received_seq_max_ - max_reordering_threshold_); } } diff --git a/modules/rtp_rtcp/source/receive_statistics_unittest.cc b/modules/rtp_rtcp/source/receive_statistics_unittest.cc index c586b3dc4d..29fc88daac 100644 --- a/modules/rtp_rtcp/source/receive_statistics_unittest.cc +++ b/modules/rtp_rtcp/source/receive_statistics_unittest.cc @@ -39,9 +39,8 @@ RTPHeader CreateRtpHeader(uint32_t ssrc) { class ReceiveStatisticsTest : public ::testing::Test { public: - ReceiveStatisticsTest() : - clock_(0), - receive_statistics_(ReceiveStatistics::Create(&clock_)) { + ReceiveStatisticsTest() + : clock_(0), receive_statistics_(ReceiveStatistics::Create(&clock_)) { header1_ = CreateRtpHeader(kSsrc1); header2_ = CreateRtpHeader(kSsrc2); } @@ -74,8 +73,7 @@ TEST_F(ReceiveStatisticsTest, TwoIncomingSsrcs) { EXPECT_EQ(200u, bytes_received); EXPECT_EQ(2u, packets_received); - statistician = - receive_statistics_->GetStatistician(kSsrc2); + statistician = receive_statistics_->GetStatistician(kSsrc2); ASSERT_TRUE(statistician != NULL); EXPECT_GT(statistician->BitrateReceived(), 0u); statistician->GetDataCounters(&bytes_received, &packets_received); @@ -236,8 +234,8 @@ TEST_F(ReceiveStatisticsTest, RtcpCallbacks) { // Call GetStatistics, simulating a timed rtcp sender thread. RtcpStatistics statistics; - receive_statistics_->GetStatistician(kSsrc1) - ->GetStatistics(&statistics, true); + receive_statistics_->GetStatistician(kSsrc1)->GetStatistics(&statistics, + true); EXPECT_EQ(1u, callback.num_calls_); EXPECT_EQ(callback.ssrc_, kSsrc1); @@ -272,8 +270,8 @@ TEST_F(ReceiveStatisticsTest, RtcpCallbacks) { receive_statistics_->IncomingPacket(header1_, kPacketSize1, false); ++header1_.sequenceNumber; - receive_statistics_->GetStatistician(kSsrc1) - ->GetStatistics(&statistics, true); + receive_statistics_->GetStatistician(kSsrc1)->GetStatistics(&statistics, + true); // Should not have been called after deregister. EXPECT_EQ(1u, callback.num_calls_); @@ -324,8 +322,8 @@ TEST_F(ReceiveStatisticsTest, RtpCallbacks) { // One packet of size kPacketSize1. header1_.headerLength = kHeaderLength; - receive_statistics_->IncomingPacket( - header1_, kPacketSize1 + kHeaderLength, false); + receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength, + false); StreamDataCounters expected; expected.transmitted.payload_bytes = kPacketSize1; expected.transmitted.header_bytes = kHeaderLength; @@ -368,8 +366,8 @@ TEST_F(ReceiveStatisticsTest, RtpCallbacks) { ++header1_.sequenceNumber; clock_.AdvanceTimeMilliseconds(5); // One FEC packet. - receive_statistics_->IncomingPacket( - header1_, kPacketSize1 + kHeaderLength, false); + receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength, + false); receive_statistics_->FecPacketReceived(header1_, kPacketSize1 + kHeaderLength); expected.transmitted.payload_bytes = kPacketSize1 * 4; @@ -385,8 +383,8 @@ TEST_F(ReceiveStatisticsTest, RtpCallbacks) { // New stats, but callback should not be called. ++header1_.sequenceNumber; clock_.AdvanceTimeMilliseconds(5); - receive_statistics_->IncomingPacket( - header1_, kPacketSize1 + kHeaderLength, true); + receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength, + true); callback.Matches(5, kSsrc1, expected); } @@ -402,8 +400,8 @@ TEST_F(ReceiveStatisticsTest, RtpCallbacksFecFirst) { kPacketSize1 + kHeaderLength); EXPECT_EQ(0u, callback.num_calls_); - receive_statistics_->IncomingPacket( - header1_, kPacketSize1 + kHeaderLength, false); + receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength, + false); StreamDataCounters expected; expected.transmitted.payload_bytes = kPacketSize1; expected.transmitted.header_bytes = kHeaderLength; diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc index e752369f73..5254cd57bb 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc @@ -1,12 +1,12 @@ /* -* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. -* -* 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. -*/ + * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. + * + * 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. + */ #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" #include "common_types.h" // NOLINT(build/include) @@ -63,8 +63,11 @@ class RemoteNtpTimeEstimatorTest : public ::testing::Test { ReceiveRtcpSr(kTestRtt, rtcp_timestamp, ntp.seconds(), ntp.fractions()); } - void UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, - uint32_t rtp_timestamp, bool expected_result) { + void UpdateRtcpTimestamp(int64_t rtt, + uint32_t ntp_secs, + uint32_t ntp_frac, + uint32_t rtp_timestamp, + bool expected_result) { EXPECT_EQ(expected_result, estimator_->UpdateRtcpTimestamp( rtt, ntp_secs, ntp_frac, rtp_timestamp)); } diff --git a/modules/rtp_rtcp/source/rtcp_nack_stats.cc b/modules/rtp_rtcp/source/rtcp_nack_stats.cc index 8700b045b9..24b708502e 100644 --- a/modules/rtp_rtcp/source/rtcp_nack_stats.cc +++ b/modules/rtp_rtcp/source/rtcp_nack_stats.cc @@ -15,14 +15,12 @@ namespace webrtc { RtcpNackStats::RtcpNackStats() - : max_sequence_number_(0), - requests_(0), - unique_requests_(0) {} + : max_sequence_number_(0), requests_(0), unique_requests_(0) {} void RtcpNackStats::ReportRequest(uint16_t sequence_number) { if (requests_ == 0 || IsNewerSequenceNumber(sequence_number, max_sequence_number_)) { - max_sequence_number_ = sequence_number; + max_sequence_number_ = sequence_number; ++unique_requests_; } ++requests_; diff --git a/modules/rtp_rtcp/source/rtcp_nack_stats.h b/modules/rtp_rtcp/source/rtcp_nack_stats.h index d9e2622abc..9da4351a59 100644 --- a/modules/rtp_rtcp/source/rtcp_nack_stats.h +++ b/modules/rtp_rtcp/source/rtcp_nack_stats.h @@ -1,12 +1,12 @@ /* -* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. -* -* 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. -*/ + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. + * + * 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. + */ #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_NACK_STATS_H_ #define MODULES_RTP_RTCP_SOURCE_RTCP_NACK_STATS_H_ diff --git a/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc b/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc index 5b4def5476..1c3017375d 100644 --- a/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc @@ -61,4 +61,3 @@ TEST(RtcpNackStatsTest, RequestsWithWrap) { } } // namespace webrtc - diff --git a/modules/rtp_rtcp/source/rtcp_packet.cc b/modules/rtp_rtcp/source/rtcp_packet.cc index ecce5ef34c..194b992ef8 100644 --- a/modules/rtp_rtcp/source/rtcp_packet.cc +++ b/modules/rtp_rtcp/source/rtcp_packet.cc @@ -75,8 +75,8 @@ void RtcpPacket::CreateHeader( RTC_DCHECK_LE(count_or_format, 0x1f); constexpr uint8_t kVersionBits = 2 << 6; constexpr uint8_t kNoPaddingBit = 0 << 5; - buffer[*pos + 0] = kVersionBits | kNoPaddingBit | - static_cast(count_or_format); + buffer[*pos + 0] = + kVersionBits | kNoPaddingBit | static_cast(count_or_format); buffer[*pos + 1] = packet_type; buffer[*pos + 2] = (length >> 8) & 0xff; buffer[*pos + 3] = length & 0xff; diff --git a/modules/rtp_rtcp/source/rtcp_packet/app.cc b/modules/rtp_rtcp/source/rtcp_packet/app.cc index 10d2a771fe..4e21bc93e4 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/app.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/app.cc @@ -64,9 +64,9 @@ void App::SetSubType(uint8_t subtype) { void App::SetData(const uint8_t* data, size_t data_length) { RTC_DCHECK(data); RTC_DCHECK_EQ(data_length % 4, 0) << "Data must be 32 bits aligned."; - RTC_DCHECK_LE(data_length, kMaxDataSize) << "App data size " << data_length - << " exceed maximum of " - << kMaxDataSize << " bytes."; + RTC_DCHECK_LE(data_length, kMaxDataSize) + << "App data size " << data_length << " exceed maximum of " + << kMaxDataSize << " bytes."; data_.SetData(data, data_length); } diff --git a/modules/rtp_rtcp/source/rtcp_packet/common_header.h b/modules/rtp_rtcp/source/rtcp_packet/common_header.h index d91956e2e3..5416406091 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/common_header.h +++ b/modules/rtp_rtcp/source/rtcp_packet/common_header.h @@ -21,7 +21,7 @@ class CommonHeader { CommonHeader() {} CommonHeader(const CommonHeader&) = default; - CommonHeader& operator =(const CommonHeader&) = default; + CommonHeader& operator=(const CommonHeader&) = default; bool Parse(const uint8_t* buffer, size_t size_bytes); diff --git a/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc index a284642451..e8b4c52c68 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc @@ -42,9 +42,8 @@ TEST(RtcpCommonHeaderTest, Version) { } TEST(RtcpCommonHeaderTest, PacketSize) { - uint8_t buffer[] = {0x80, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00}; + uint8_t buffer[] = {0x80, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CommonHeader header; EXPECT_FALSE(header.Parse(buffer, sizeof(buffer) - 1)); EXPECT_TRUE(header.Parse(buffer, sizeof(buffer))); @@ -55,9 +54,8 @@ TEST(RtcpCommonHeaderTest, PacketSize) { TEST(RtcpCommonHeaderTest, PaddingAndPayloadSize) { // Set v = 2, p = 1, but leave fmt, pt as 0. - uint8_t buffer[] = {0xa0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00}; + uint8_t buffer[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CommonHeader header; // Padding bit set, but no byte for padding (can't specify padding length). EXPECT_FALSE(header.Parse(buffer, 4)); diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc index 1e72d4a84d..c37f77e812 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc @@ -39,16 +39,13 @@ bool operator==(const RTCPVoIPMetric& metric1, const RTCPVoIPMetric& metric2) { metric1.endSystemDelay == metric2.endSystemDelay && metric1.signalLevel == metric2.signalLevel && metric1.noiseLevel == metric2.noiseLevel && - metric1.RERL == metric2.RERL && - metric1.Gmin == metric2.Gmin && + metric1.RERL == metric2.RERL && metric1.Gmin == metric2.Gmin && metric1.Rfactor == metric2.Rfactor && metric1.extRfactor == metric2.extRfactor && - metric1.MOSLQ == metric2.MOSLQ && - metric1.MOSCQ == metric2.MOSCQ && + metric1.MOSLQ == metric2.MOSLQ && metric1.MOSCQ == metric2.MOSCQ && metric1.RXconfig == metric2.RXconfig && metric1.JBnominal == metric2.JBnominal && - metric1.JBmax == metric2.JBmax && - metric1.JBabsMax == metric2.JBabsMax; + metric1.JBmax == metric2.JBmax && metric1.JBabsMax == metric2.JBabsMax; } namespace rtcp { @@ -57,8 +54,7 @@ bool operator==(const Rrtr& rrtr1, const Rrtr& rrtr2) { } bool operator==(const ReceiveTimeInfo& time1, const ReceiveTimeInfo& time2) { - return time1.ssrc == time2.ssrc && - time1.last_rr == time2.last_rr && + return time1.ssrc == time2.ssrc && time1.last_rr == time2.last_rr && time1.delay_since_last_rr == time2.delay_since_last_rr; } @@ -113,26 +109,26 @@ Rrtr RtcpPacketExtendedReportsTest::Rand() { template <> RTCPVoIPMetric RtcpPacketExtendedReportsTest::Rand() { RTCPVoIPMetric metric; - metric.lossRate = Rand(); - metric.discardRate = Rand(); - metric.burstDensity = Rand(); - metric.gapDensity = Rand(); - metric.burstDuration = Rand(); - metric.gapDuration = Rand(); + metric.lossRate = Rand(); + metric.discardRate = Rand(); + metric.burstDensity = Rand(); + metric.gapDensity = Rand(); + metric.burstDuration = Rand(); + metric.gapDuration = Rand(); metric.roundTripDelay = Rand(); metric.endSystemDelay = Rand(); - metric.signalLevel = Rand(); - metric.noiseLevel = Rand(); - metric.RERL = Rand(); - metric.Gmin = Rand(); - metric.Rfactor = Rand(); - metric.extRfactor = Rand(); - metric.MOSLQ = Rand(); - metric.MOSCQ = Rand(); - metric.RXconfig = Rand(); - metric.JBnominal = Rand(); - metric.JBmax = Rand(); - metric.JBabsMax = Rand(); + metric.signalLevel = Rand(); + metric.noiseLevel = Rand(); + metric.RERL = Rand(); + metric.Gmin = Rand(); + metric.Rfactor = Rand(); + metric.extRfactor = Rand(); + metric.MOSLQ = Rand(); + metric.MOSCQ = Rand(); + metric.RXconfig = Rand(); + metric.JBnominal = Rand(); + metric.JBmax = Rand(); + metric.JBabsMax = Rand(); return metric; } diff --git a/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc index 2800fbc79e..d9eb465fd9 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc @@ -29,11 +29,9 @@ constexpr uint32_t kSenderSsrc = 0x12345678; constexpr uint32_t kRemoteSsrc = 0x23456789; constexpr uint8_t kSeqNr = 13; // Manually created Fir packet matching constants above. -constexpr uint8_t kPacket[] = {0x84, 206, 0x00, 0x04, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, - 0x23, 0x45, 0x67, 0x89, - 0x0d, 0x00, 0x00, 0x00}; +constexpr uint8_t kPacket[] = {0x84, 206, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, + 0x67, 0x89, 0x0d, 0x00, 0x00, 0x00}; } // namespace TEST(RtcpPacketFirTest, Parse) { @@ -77,20 +75,16 @@ TEST(RtcpPacketFirTest, TwoFciEntries) { } TEST(RtcpPacketFirTest, ParseFailsOnZeroFciEntries) { - constexpr uint8_t kPacketWithoutFci[] = {0x84, 206, 0x00, 0x02, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00}; + constexpr uint8_t kPacketWithoutFci[] = {0x84, 206, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x00, 0x00, 0x00, 0x00}; Fir parsed; EXPECT_FALSE(test::ParseSinglePacket(kPacketWithoutFci, &parsed)); } TEST(RtcpPacketFirTest, ParseFailsOnFractionalFciEntries) { - constexpr uint8_t kPacketWithOneAndHalfFci[] = {0x84, 206, 0x00, 0x05, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, - 0x23, 0x45, 0x67, 0x89, - 0x0d, 0x00, 0x00, 0x00, - 'h', 'a', 'l', 'f'}; + constexpr uint8_t kPacketWithOneAndHalfFci[] = { + 0x84, 206, 0x00, 0x05, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x45, 0x67, 0x89, 0x0d, 0x00, 0x00, 0x00, 'h', 'a', 'l', 'f'}; Fir parsed; EXPECT_FALSE(test::ParseSinglePacket(kPacketWithOneAndHalfFci, &parsed)); diff --git a/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc index e6cf7bef4a..67e614dd3c 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc @@ -23,9 +23,8 @@ namespace { const uint32_t kSenderSsrc = 0x12345678; const uint32_t kRemoteSsrc = 0x23456789; // Manually created Pli packet matching constants above. -const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, - 0x12, 0x34, 0x56, 0x78, - 0x23, 0x45, 0x67, 0x89}; +const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; } // namespace TEST(RtcpPacketPliTest, Parse) { @@ -45,7 +44,7 @@ TEST(RtcpPacketPliTest, Create) { rtc::Buffer packet = pli.Build(); EXPECT_THAT(make_tuple(packet.data(), packet.size()), - ElementsAreArray(kPacket)); + ElementsAreArray(kPacket)); } TEST(RtcpPacketPliTest, ParseFailsOnTooSmallPacket) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc index e80736900d..f10f93ea20 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc @@ -23,9 +23,8 @@ namespace { const uint32_t kSenderSsrc = 0x12345678; const uint32_t kRemoteSsrc = 0x23456789; // Manually created packet matching constants above. -const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, - 0x12, 0x34, 0x56, 0x78, - 0x23, 0x45, 0x67, 0x89}; +const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; } // namespace TEST(RtcpPacketRapidResyncRequestTest, Parse) { @@ -56,9 +55,8 @@ TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnTooSmallPacket) { } TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnTooLargePacket) { - const uint8_t kTooLargePacket[] = {0x85, 205, 0x00, 0x03, - 0x12, 0x34, 0x56, 0x78, - 0x32, 0x21, 0x65, 0x87, + const uint8_t kTooLargePacket[] = {0x85, 205, 0x00, 0x03, 0x12, 0x34, + 0x56, 0x78, 0x32, 0x21, 0x65, 0x87, 0x23, 0x45, 0x67, 0x89}; RapidResyncRequest parsed; EXPECT_FALSE(test::ParseSinglePacket(kTooLargePacket, &parsed)); diff --git a/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc index 7bd79b311c..56622ea81a 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc @@ -19,9 +19,8 @@ namespace { const uint32_t kNtpSec = 0x12345678; const uint32_t kNtpFrac = 0x23456789; -const uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, - 0x12, 0x34, 0x56, 0x78, - 0x23, 0x45, 0x67, 0x89}; +const uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; const size_t kBlockSizeBytes = sizeof(kBlock); static_assert( kBlockSizeBytes == Rrtr::kLength, diff --git a/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc index 7896f2d0bc..b903a4e383 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc @@ -97,11 +97,10 @@ TEST(RtcpPacketSdesTest, CreateAndParseCnameItemWithEmptyString) { TEST(RtcpPacketSdesTest, ParseSkipsNonCNameField) { const uint8_t kName[] = "abc"; const uint8_t kCname[] = "de"; - const uint8_t kValidPacket[] = {0x81, 202, 0x00, 0x04, - 0x12, 0x34, 0x56, 0x78, - kNameTag, 3, kName[0], kName[1], kName[2], - kCnameTag, 2, kCname[0], kCname[1], - kTerminatorTag, kPadding, kPadding}; + const uint8_t kValidPacket[] = { + 0x81, 202, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, kNameTag, 3, kName[0], kName[1], kName[2], kCnameTag, + 2, kCname[0], kCname[1], kTerminatorTag, kPadding, kPadding}; // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kValidPacket) % 4); ASSERT_EQ(kValidPacket[3] + 1u, sizeof(kValidPacket) / 4); @@ -118,13 +117,14 @@ TEST(RtcpPacketSdesTest, ParseSkipsChunksWithoutCName) { const uint8_t kName[] = "ab"; const uint8_t kEmail[] = "de"; const uint8_t kCname[] = "def"; - const uint8_t kPacket[] = {0x82, 202, 0x00, 0x07, - 0x12, 0x34, 0x56, 0x78, // 1st chunk. - kNameTag, 3, kName[0], kName[1], kName[2], - kEmailTag, 2, kEmail[0], kEmail[1], - kTerminatorTag, kPadding, kPadding, - 0x23, 0x45, 0x67, 0x89, // 2nd chunk. - kCnameTag, 3, kCname[0], kCname[1], kCname[2], + const uint8_t kPacket[] = { + 0x82, 202, 0x00, 0x07, 0x12, + 0x34, 0x56, 0x78, // 1st chunk. + kNameTag, 3, kName[0], kName[1], kName[2], + kEmailTag, 2, kEmail[0], kEmail[1], kTerminatorTag, + kPadding, kPadding, 0x23, 0x45, 0x67, + 0x89, // 2nd chunk. + kCnameTag, 3, kCname[0], kCname[1], kCname[2], kTerminatorTag, kPadding, kPadding}; // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kPacket) % 4); @@ -141,10 +141,9 @@ TEST(RtcpPacketSdesTest, ParseFailsWithoutChunkItemTerminator) { const uint8_t kName[] = "abc"; const uint8_t kCname[] = "d"; // No place for next chunk item. - const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03, - 0x12, 0x34, 0x56, 0x78, - kNameTag, 3, kName[0], kName[1], kName[2], - kCnameTag, 1, kCname[0]}; + const uint8_t kInvalidPacket[] = { + 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78, + kNameTag, 3, kName[0], kName[1], kName[2], kCnameTag, 1, kCname[0]}; // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4); ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4); @@ -157,11 +156,9 @@ TEST(RtcpPacketSdesTest, ParseFailsWithDamagedChunkItem) { const uint8_t kName[] = "ab"; const uint8_t kCname[] = "d"; // Next chunk item has non-terminator type, but not the size. - const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03, - 0x12, 0x34, 0x56, 0x78, - kNameTag, 2, kName[0], kName[1], - kCnameTag, 1, kCname[0], - kEmailTag}; + const uint8_t kInvalidPacket[] = { + 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78, + kNameTag, 2, kName[0], kName[1], kCnameTag, 1, kCname[0], kEmailTag}; // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4); ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4); @@ -174,10 +171,9 @@ TEST(RtcpPacketSdesTest, ParseFailsWithTooLongChunkItem) { const uint8_t kName[] = "abc"; const uint8_t kCname[] = "d"; // Last chunk item has length that goes beyond the buffer end. - const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03, - 0x12, 0x34, 0x56, 0x78, - kNameTag, 3, kName[0], kName[1], kName[2], - kCnameTag, 2, kCname[0]}; + const uint8_t kInvalidPacket[] = { + 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78, + kNameTag, 3, kName[0], kName[1], kName[2], kCnameTag, 2, kCname[0]}; // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4); ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4); @@ -189,11 +185,10 @@ TEST(RtcpPacketSdesTest, ParseFailsWithTooLongChunkItem) { TEST(RtcpPacketSdesTest, ParseFailsWithTwoCNames) { const uint8_t kCname1[] = "a"; const uint8_t kCname2[] = "de"; - const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03, - 0x12, 0x34, 0x56, 0x78, - kCnameTag, 1, kCname1[0], - kCnameTag, 2, kCname2[0], kCname2[1], - kTerminatorTag}; + const uint8_t kInvalidPacket[] = { + 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, + 0x78, kCnameTag, 1, kCname1[0], kCnameTag, 2, kCname2[0], + kCname2[1], kTerminatorTag}; // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4); ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4); @@ -206,12 +201,11 @@ TEST(RtcpPacketSdesTest, ParseFailsWithTooLittleSpaceForNextChunk) { const uint8_t kCname[] = "a"; const uint8_t kEmail[] = "de"; // Two chunks are promised in the header, but no place for the second chunk. - const uint8_t kInvalidPacket[] = {0x82, 202, 0x00, 0x04, - 0x12, 0x34, 0x56, 0x78, // 1st chunk. - kCnameTag, 1, kCname[0], - kEmailTag, 2, kEmail[0], kEmail[1], - kTerminatorTag, - 0x23, 0x45, 0x67, 0x89}; // 2nd chunk. + const uint8_t kInvalidPacket[] = { + 0x82, 202, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, // 1st chunk. + kCnameTag, 1, kCname[0], kEmailTag, 2, kEmail[0], kEmail[1], + kTerminatorTag, 0x23, 0x45, 0x67, 0x89}; // 2nd chunk. // Sanity checks packet was assembled correctly. ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4); ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4); diff --git a/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc index 30edc7ecdb..a0c6e725f0 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc @@ -29,13 +29,10 @@ const NtpTime kNtp(0x11121418, 0x22242628); const uint32_t kRtpTimestamp = 0x33343536; const uint32_t kPacketCount = 0x44454647; const uint32_t kOctetCount = 0x55565758; -const uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, - 0x12, 0x34, 0x56, 0x78, - 0x11, 0x12, 0x14, 0x18, - 0x22, 0x24, 0x26, 0x28, - 0x33, 0x34, 0x35, 0x36, - 0x44, 0x45, 0x46, 0x47, - 0x55, 0x56, 0x57, 0x58}; +const uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, 0x12, 0x34, 0x56, + 0x78, 0x11, 0x12, 0x14, 0x18, 0x22, 0x24, + 0x26, 0x28, 0x33, 0x34, 0x35, 0x36, 0x44, + 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58}; } // namespace TEST(RtcpPacketSenderReportTest, CreateWithoutReportBlocks) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc index 5a85d8a7bb..e5d2e0bdd6 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc @@ -26,11 +26,9 @@ const uint32_t kSenderSsrc = 0x12345678; const uint32_t kRemoteSsrc = 0x23456789; const uint32_t kBitrateBps = 312000; const uint16_t kOverhead = 0x1fe; -const uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, - 0x23, 0x45, 0x67, 0x89, - 0x0a, 0x61, 0x61, 0xfe}; +const uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, + 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe}; } // namespace TEST(RtcpPacketTmmbnTest, Create) { @@ -97,9 +95,8 @@ TEST(RtcpPacketTmmbnTest, ParseFailsOnTooSmallPacket) { } TEST(RtcpPacketTmmbnTest, ParseFailsOnUnAlignedPacket) { - const uint8_t kUnalignedPacket[] = {0x84, 205, 0x00, 0x03, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, + const uint8_t kUnalignedPacket[] = {0x84, 205, 0x00, 0x03, 0x12, 0x34, + 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, 0x67, 0x89}; Tmmbn tmmbn; diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc index d3fe72ac72..63fa9116ff 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc @@ -26,11 +26,9 @@ const uint32_t kSenderSsrc = 0x12345678; const uint32_t kRemoteSsrc = 0x23456789; const uint32_t kBitrateBps = 312000; const uint16_t kOverhead = 0x1fe; -const uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, - 0x23, 0x45, 0x67, 0x89, - 0x0a, 0x61, 0x61, 0xfe}; +const uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, + 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe}; } // namespace TEST(RtcpPacketTmmbrTest, Create) { @@ -74,21 +72,17 @@ TEST(RtcpPacketTmmbrTest, CreateAndParseWithTwoEntries) { } TEST(RtcpPacketTmmbrTest, ParseFailsWithoutItems) { - const uint8_t kZeroItemsPacket[] = {0x83, 205, 0x00, 0x02, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00}; + const uint8_t kZeroItemsPacket[] = {0x83, 205, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x00, 0x00, 0x00, 0x00}; Tmmbr tmmbr; EXPECT_FALSE(test::ParseSinglePacket(kZeroItemsPacket, &tmmbr)); } TEST(RtcpPacketTmmbrTest, ParseFailsOnUnAlignedPacket) { - const uint8_t kUnalignedPacket[] = {0x83, 205, 0x00, 0x05, - 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, - 0x23, 0x45, 0x67, 0x89, - 0x0a, 0x61, 0x61, 0xfe, - 0x34, 0x56, 0x78, 0x9a}; + const uint8_t kUnalignedPacket[] = { + 0x83, 205, 0x00, 0x05, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x45, 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe, 0x34, 0x56, 0x78, 0x9a}; Tmmbr tmmbr; EXPECT_FALSE(test::ParseSinglePacket(kUnalignedPacket, &tmmbr)); diff --git a/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc index 310246adc9..04965256bd 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc @@ -79,8 +79,8 @@ class FeedbackTester { ASSERT_TRUE(feedback_->IsConsistent()); serialized_ = feedback_->Build(); VerifyInternal(); - feedback_ = TransportFeedback::ParseFrom(serialized_.data(), - serialized_.size()); + feedback_ = + TransportFeedback::ParseFrom(serialized_.data(), serialized_.size()); ASSERT_TRUE(feedback_->IsConsistent()); ASSERT_NE(nullptr, feedback_.get()); VerifyInternal(); @@ -209,10 +209,7 @@ TEST(RtcpPacketTest, TransportFeedback_TwoBitVectorFull) { TEST(RtcpPacketTest, TransportFeedback_LargeAndNegativeDeltas) { const uint16_t kReceived[] = {1, 2, 6, 7, 8}; const int64_t kReceiveTimes[] = { - 2000, - 1000, - 4000, - 3000, + 2000, 1000, 4000, 3000, 3000 + TransportFeedback::kDeltaScaleFactor * (1 << 8)}; const size_t kLength = sizeof(kReceived) / sizeof(uint16_t); const size_t kExpectedSizeBytes = diff --git a/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc index a2fbcc5f75..598b8c6c6c 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc @@ -17,11 +17,10 @@ namespace rtcp { namespace { const uint32_t kRemoteSsrc = 0x23456789; -const uint8_t kBlock[] = {0x07, 0x00, 0x00, 0x08, 0x23, 0x45, 0x67, 0x89, - 0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x22, 0x23, - 0x33, 0x34, 0x44, 0x45, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x00, 0x55, 0x56, - 0x66, 0x67, 0x77, 0x78}; +const uint8_t kBlock[] = {0x07, 0x00, 0x00, 0x08, 0x23, 0x45, 0x67, 0x89, 0x01, + 0x02, 0x03, 0x04, 0x11, 0x12, 0x22, 0x23, 0x33, 0x34, + 0x44, 0x45, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x00, 0x55, 0x56, 0x66, 0x67, 0x77, 0x78}; const size_t kBlockSizeBytes = sizeof(kBlock); static_assert( kBlockSizeBytes == VoipMetric::kLength, diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc index af164ccf0c..491bd45ee9 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -820,8 +820,7 @@ void RTCPReceiver::HandleTmmbr(const CommonHeader& rtcp_block, TmmbrInformation* tmmbr_info = FindOrCreateTmmbrInfo(tmmbr.sender_ssrc()); auto* entry = &tmmbr_info->tmmbr[sender_ssrc]; - entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc, - request.bitrate_bps(), + entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc, request.bitrate_bps(), request.packet_overhead()); entry->last_updated_ms = clock_->TimeInMilliseconds(); diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index a6fd593531..41d4725665 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -1235,8 +1235,8 @@ TEST_F(RtcpReceiverTest, HandlesInvalidTransportFeedback) { // Modify the TransportFeedback packet so that it is invalid. const size_t kStatusCountOffset = 14; - ByteWriter::WriteBigEndian( - &built_packet.data()[kStatusCountOffset], 42); + ByteWriter::WriteBigEndian(&built_packet.data()[kStatusCountOffset], + 42); // Stress no transport feedback is expected. EXPECT_CALL(transport_feedback_observer_, OnTransportFeedback(_)).Times(0); diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc index c7c38bfceb..974f19f5ee 100644 --- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc @@ -42,8 +42,7 @@ class RtcpPacketTypeCounterObserverImpl : public RtcpPacketTypeCounterObserver { RtcpPacketTypeCounter counter_; }; -class TestTransport : public Transport, - public RtpData { +class TestTransport : public Transport, public RtpData { public: TestTransport() {} @@ -69,7 +68,7 @@ static const uint32_t kSenderSsrc = 0x11111111; static const uint32_t kRemoteSsrc = 0x22222222; static const uint32_t kStartRtpTimestamp = 0x34567; static const uint32_t kRtpTimestamp = 0x45678; -} +} // namespace class RtcpSenderTest : public ::testing::Test { protected: @@ -309,8 +308,9 @@ TEST_F(RtcpSenderTest, SendEmptyApp) { TEST_F(RtcpSenderTest, SetInvalidApplicationSpecificData) { const uint8_t kData[] = {'t', 'e', 's', 't', 'd', 'a', 't'}; const uint16_t kInvalidDataLength = sizeof(kData) / sizeof(kData[0]); - EXPECT_EQ(-1, rtcp_sender_->SetApplicationSpecificData( - 0, 0, kData, kInvalidDataLength)); // Should by multiple of 4. + EXPECT_EQ(-1, + rtcp_sender_->SetApplicationSpecificData( + 0, 0, kData, kInvalidDataLength)); // Should by multiple of 4. } TEST_F(RtcpSenderTest, SendFir) { @@ -630,23 +630,24 @@ TEST_F(RtcpSenderTest, SendCompoundPliRemb) { TEST_F(RtcpSenderTest, ByeMustBeLast) { MockTransport mock_transport; EXPECT_CALL(mock_transport, SendRtcp(_, _)) - .WillOnce(Invoke([](const uint8_t* data, size_t len) { - const uint8_t* next_packet = data; - const uint8_t* const packet_end = data + len; - rtcp::CommonHeader packet; - while (next_packet < packet_end) { - EXPECT_TRUE(packet.Parse(next_packet, packet_end - next_packet)); - next_packet = packet.NextPacket(); - if (packet.type() == rtcp::Bye::kPacketType) // Main test expectation. - EXPECT_EQ(0, packet_end - next_packet) - << "Bye packet should be last in a compound RTCP packet."; - if (next_packet == packet_end) // Validate test was set correctly. - EXPECT_EQ(packet.type(), rtcp::Bye::kPacketType) - << "Last packet in this test expected to be Bye."; - } + .WillOnce(Invoke([](const uint8_t* data, size_t len) { + const uint8_t* next_packet = data; + const uint8_t* const packet_end = data + len; + rtcp::CommonHeader packet; + while (next_packet < packet_end) { + EXPECT_TRUE(packet.Parse(next_packet, packet_end - next_packet)); + next_packet = packet.NextPacket(); + if (packet.type() == + rtcp::Bye::kPacketType) // Main test expectation. + EXPECT_EQ(0, packet_end - next_packet) + << "Bye packet should be last in a compound RTCP packet."; + if (next_packet == packet_end) // Validate test was set correctly. + EXPECT_EQ(packet.type(), rtcp::Bye::kPacketType) + << "Last packet in this test expected to be Bye."; + } - return true; - })); + return true; + })); // Re-configure rtcp_sender_ with mock_transport_ rtcp_sender_.reset(new RTCPSender(false, &clock_, receive_statistics_.get(), diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 1fe50005cc..c2ec58a3fa 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -246,7 +246,6 @@ TEST(RtcpTransceiverImplTest, SendsNoRtcpWhenNetworkStateIsDown) { config.outgoing_transport = &mock_transport; RtcpTransceiverImpl rtcp_transceiver(config); - EXPECT_CALL(mock_transport, SendRtcp(_, _)).Times(0); const uint8_t raw[] = {1, 2, 3, 4}; diff --git a/modules/rtp_rtcp/source/rtp_fec_unittest.cc b/modules/rtp_rtcp/source/rtp_fec_unittest.cc index ba18fc61d4..cbad0aed4a 100644 --- a/modules/rtp_rtcp/source/rtp_fec_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_fec_unittest.cc @@ -155,19 +155,19 @@ bool RtpFecTest::IsRecoveryComplete() { // All recovered packets must be identical to the corresponding // original packets. - auto cmp = []( - const std::unique_ptr& media_packet, - const std::unique_ptr& - recovered_packet) { - if (media_packet->length != recovered_packet->pkt->length) { - return false; - } - if (memcmp(media_packet->data, recovered_packet->pkt->data, - media_packet->length) != 0) { - return false; - } - return true; - }; + auto cmp = + [](const std::unique_ptr& media_packet, + const std::unique_ptr& + recovered_packet) { + if (media_packet->length != recovered_packet->pkt->length) { + return false; + } + if (memcmp(media_packet->data, recovered_packet->pkt->data, + media_packet->length) != 0) { + return false; + } + return true; + }; return std::equal(media_packets_.cbegin(), media_packets_.cend(), recovered_packets_.cbegin(), cmp); } @@ -286,8 +286,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNoLoss) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // No packets lost, expect complete recovery. @@ -318,8 +317,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // One packet lost, one FEC packet, expect complete recovery. @@ -334,8 +332,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // 2 packets lost, one FEC packet, cannot get complete recovery. @@ -398,8 +395,7 @@ TYPED_TEST(RtpFecTest, NoFecRecoveryWithOldFecPacket) { this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Expect that no decoding is done to get missing packet (seq#0) of third @@ -441,8 +437,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameRecovery) { true); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Expect 3 media packets in recovered list, and complete recovery. @@ -493,8 +488,7 @@ TEST_F(RtpFecTestUlpfecOnly, FecRecoveryWithSeqNumGapOneFrameRecovery) { true); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // The two FEC packets are received and should allow for complete recovery, @@ -552,8 +546,7 @@ TEST_F(RtpFecTestFlexfecOnly, FecRecoveryWithSeqNumGapOneFrameNoRecovery) { true); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // The two FEC packets are received and should allow for complete recovery, @@ -598,8 +591,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithMediaOutOfOrder) { std::swap(*it0, *it1); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Expect 3 media packets in recovered list, and complete recovery. @@ -638,8 +630,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) { this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Expect 3 media packets in recovered list, and complete recovery. @@ -687,8 +678,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery. @@ -705,8 +695,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Cannot get complete recovery for this loss configuration with random mask. @@ -753,8 +742,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Expect complete recovery for consecutive packet loss <= 50%. @@ -771,8 +759,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Expect complete recovery for consecutive packet loss <= 50%. @@ -789,8 +776,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Cannot get complete recovery for this loss configuration. @@ -820,8 +806,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // No packets lost, expect complete recovery. @@ -852,8 +837,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // One packet lost, one FEC packet, expect complete recovery. @@ -868,8 +852,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // 2 packets lost, one FEC packet, cannot get complete recovery. @@ -914,8 +897,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery. @@ -933,8 +915,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Cannot get complete recovery for this loss configuration. @@ -970,8 +951,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // One packet lost, one FEC packet, expect complete recovery. @@ -985,8 +965,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Unprotected packet lost. Recovery not possible. @@ -1001,8 +980,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // 2 protected packets lost, one FEC packet, cannot get complete recovery. @@ -1041,8 +1019,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // One packet lost, one FEC packet, expect complete recovery. @@ -1056,8 +1033,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Unprotected packet lost. Recovery not possible. @@ -1076,8 +1052,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // 5 protected packets lost, one FEC packet, cannot get complete recovery. @@ -1116,8 +1091,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // One packet lost, one FEC packet, expect complete recovery. @@ -1131,8 +1105,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // Unprotected packet lost. Recovery not possible. @@ -1151,8 +1124,7 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); for (const auto& received_packet : this->received_packets_) { - this->fec_.DecodeFec(*received_packet, - &this->recovered_packets_); + this->fec_.DecodeFec(*received_packet, &this->recovered_packets_); } // 5 protected packets lost, one FEC packet, cannot get complete recovery. diff --git a/modules/rtp_rtcp/source/rtp_format_h264.cc b/modules/rtp_rtcp/source/rtp_format_h264.cc index 633f0ae8d0..9c91611dbd 100644 --- a/modules/rtp_rtcp/source/rtp_format_h264.cc +++ b/modules/rtp_rtcp/source/rtp_format_h264.cc @@ -92,8 +92,7 @@ RtpPacketizerH264::RtpPacketizerH264(size_t max_payload_len, RTC_CHECK_GT(max_payload_len, last_packet_reduction_len); } -RtpPacketizerH264::~RtpPacketizerH264() { -} +RtpPacketizerH264::~RtpPacketizerH264() {} RtpPacketizerH264::Fragment::~Fragment() = default; @@ -582,8 +581,8 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu( uint32_t pps_id; uint32_t sps_id; if (PpsParser::ParsePpsIds(&payload_data[start_offset], - end_offset - start_offset, &pps_id, - &sps_id)) { + end_offset - start_offset, &pps_id, + &sps_id)) { nalu.pps_id = pps_id; nalu.sps_id = sps_id; } else { diff --git a/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc b/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc index cbf9996030..0eaf7a5e12 100644 --- a/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc @@ -493,7 +493,7 @@ const uint8_t kRewrittenSps[] = {kSps, 0x00, 0x00, 0x03, 0x03, 0xF4, 0x05, 0x03, 0xC7, 0xE0, 0x1B, 0x41, 0x10, 0x8D, 0x00}; const uint8_t kIdrOne[] = {kIdr, 0xFF, 0x00, 0x00, 0x04}; const uint8_t kIdrTwo[] = {kIdr, 0xFF, 0x00, 0x11}; -} +} // namespace class RtpPacketizerH264TestSpsRewriting : public ::testing::Test { public: @@ -665,7 +665,7 @@ TEST_F(RtpDepacketizerH264Test, TestStapAKey) { TEST_F(RtpDepacketizerH264Test, TestStapANaluSpsWithResolution) { uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24. - // Length (2 bytes), nal header, payload. + // Length (2 bytes), nal header, payload. 0x00, 0x19, kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25, 0x80, @@ -796,9 +796,9 @@ TEST_F(RtpDepacketizerH264Test, DepacketizeWithDoubleRewriting) { TEST_F(RtpDepacketizerH264Test, TestStapADelta) { uint8_t packet[16] = {kStapA, // F=0, NRI=0, Type=24. - // Length, nal header, payload. - 0, 0x02, kSlice, 0xFF, 0, 0x03, kSlice, 0xFF, - 0x00, 0, 0x04, kSlice, 0xFF, 0x00, 0x11}; + // Length, nal header, payload. + 0, 0x02, kSlice, 0xFF, 0, 0x03, kSlice, 0xFF, 0x00, 0, + 0x04, kSlice, 0xFF, 0x00, 0x11}; RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); @@ -904,7 +904,7 @@ TEST_F(RtpDepacketizerH264Test, TestTruncatedSingleStapANalu) { } TEST_F(RtpDepacketizerH264Test, TestStapAPacketWithTruncatedNalUnits) { - const uint8_t kPayload[] = { 0x58, 0xCB, 0xED, 0xDF}; + const uint8_t kPayload[] = {0x58, 0xCB, 0xED, 0xDF}; RtpDepacketizer::ParsedPayload payload; EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); } @@ -923,7 +923,7 @@ TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) { TEST_F(RtpDepacketizerH264Test, TestSeiPacket) { const uint8_t kPayload[] = { - kSei, // F=0, NRI=0, Type=6. + kSei, // F=0, NRI=0, Type=6. 0x03, 0x03, 0x03, 0x03 // Payload. }; RtpDepacketizer::ParsedPayload payload; diff --git a/modules/rtp_rtcp/source/rtp_format_video_generic.cc b/modules/rtp_rtcp/source/rtp_format_video_generic.cc index 14e4880c67..8be5b4a87c 100644 --- a/modules/rtp_rtcp/source/rtp_format_video_generic.cc +++ b/modules/rtp_rtcp/source/rtp_format_video_generic.cc @@ -30,8 +30,7 @@ RtpPacketizerGeneric::RtpPacketizerGeneric(FrameType frame_type, num_packets_left_(0), num_larger_packets_(0) {} -RtpPacketizerGeneric::~RtpPacketizerGeneric() { -} +RtpPacketizerGeneric::~RtpPacketizerGeneric() {} size_t RtpPacketizerGeneric::SetPayloadData( const uint8_t* payload_data, diff --git a/modules/rtp_rtcp/source/rtp_format_vp8.cc b/modules/rtp_rtcp/source/rtp_format_vp8.cc index 85ab7c1ed4..0f559e8a8e 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp8.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp8.cc @@ -109,9 +109,8 @@ int ParseVP8Extension(RTPVideoHeaderVP8* vp8, } if (has_tid || has_key_idx) { - if (ParseVP8TIDAndKeyIdx( - vp8, &data, &data_length, &parsed_bytes, has_tid, has_key_idx) != - 0) { + if (ParseVP8TIDAndKeyIdx(vp8, &data, &data_length, &parsed_bytes, has_tid, + has_key_idx) != 0) { return -1; } } @@ -171,8 +170,7 @@ RtpPacketizerVp8::RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, RTC_DCHECK(ValidateHeader(hdr_info)); } -RtpPacketizerVp8::~RtpPacketizerVp8() { -} +RtpPacketizerVp8::~RtpPacketizerVp8() {} size_t RtpPacketizerVp8::SetPayloadData( const uint8_t* payload_data, @@ -252,8 +250,8 @@ void RtpPacketizerVp8::GeneratePacketsSplitPayloadBalanced(size_t payload_len, if (num_packets_left == 2 && current_packet_bytes == remaining_data) { --current_packet_bytes; } - QueuePacket(payload_len - remaining_data, - current_packet_bytes, remaining_data == payload_len); + QueuePacket(payload_len - remaining_data, current_packet_bytes, + remaining_data == payload_len); remaining_data -= current_packet_bytes; --num_packets_left; } @@ -302,8 +300,7 @@ int RtpPacketizerVp8::WriteHeaderAndPayload(const InfoStruct& packet_info, return -1; memcpy(&buffer[vp8_fixed_payload_descriptor_bytes_ + extension_length], - &payload_data_[packet_info.payload_start_pos], - packet_info.size); + &payload_data_[packet_info.payload_start_pos], packet_info.size); // Return total length of written data. return packet_info.size + vp8_fixed_payload_descriptor_bytes_ + @@ -318,20 +315,20 @@ int RtpPacketizerVp8::WriteExtensionFields(uint8_t* buffer, *x_field = 0; extension_length = 1; // One octet for the X field. if (PictureIdPresent()) { - if (WritePictureIDFields( - x_field, buffer, buffer_length, &extension_length) < 0) { + if (WritePictureIDFields(x_field, buffer, buffer_length, + &extension_length) < 0) { return -1; } } if (TL0PicIdxFieldPresent()) { - if (WriteTl0PicIdxFields( - x_field, buffer, buffer_length, &extension_length) < 0) { + if (WriteTl0PicIdxFields(x_field, buffer, buffer_length, + &extension_length) < 0) { return -1; } } if (TIDFieldPresent() || KeyIdxFieldPresent()) { - if (WriteTIDAndKeyIdxFields( - x_field, buffer, buffer_length, &extension_length) < 0) { + if (WriteTIDAndKeyIdxFields(x_field, buffer, buffer_length, + &extension_length) < 0) { return -1; } } @@ -516,8 +513,7 @@ bool RtpDepacketizerVp8::Parse(ParsedPayload* parsed_payload, if (extension) { const int parsed_bytes = ParseVP8Extension(&parsed_payload->type.Video.codecHeader.VP8, - payload_data, - payload_data_length); + payload_data, payload_data_length); if (parsed_bytes < 0) return false; payload_data += parsed_bytes; diff --git a/modules/rtp_rtcp/source/rtp_format_vp8.h b/modules/rtp_rtcp/source/rtp_format_vp8.h index 7697480169..3f0d7e5532 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp8.h +++ b/modules/rtp_rtcp/source/rtp_format_vp8.h @@ -82,13 +82,10 @@ class RtpPacketizerVp8 : public RtpPacketizer { // Splits given part of payload to packets with a given capacity. The last // packet should be reduced by last_packet_reduction_len_. - void GeneratePacketsSplitPayloadBalanced(size_t payload_len, - size_t capacity); + void GeneratePacketsSplitPayloadBalanced(size_t payload_len, size_t capacity); // Insert packet into packet queue. - void QueuePacket(size_t start_pos, - size_t packet_size, - bool first_packet); + void QueuePacket(size_t start_pos, size_t packet_size, bool first_packet); // Write the payload header and copy the payload to the buffer. // The info in packet_info determines which part of the payload is written diff --git a/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc b/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc index 62d7c3c3bf..8dc7ba0a4c 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include "modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h" #include "test/gtest.h" @@ -32,12 +31,13 @@ RtpFormatVp8TestHelper::RtpFormatVp8TestHelper(const RTPVideoHeaderVP8* hdr) RtpFormatVp8TestHelper::~RtpFormatVp8TestHelper() { delete fragmentation_; - delete [] payload_data_; + delete[] payload_data_; } bool RtpFormatVp8TestHelper::Init(const size_t* partition_sizes, size_t num_partitions) { - if (inited_) return false; + if (inited_) + return false; fragmentation_ = new RTPFragmentationHeader; fragmentation_->VerifyAndAllocateFragmentationHeader(num_partitions); payload_size_ = 0; @@ -95,7 +95,7 @@ void RtpFormatVp8TestHelper::GetAllPacketsAndCheck( // First octet tests. #define EXPECT_BIT_EQ(x, n, a) EXPECT_EQ((((x) >> (n)) & 0x1), a) -#define EXPECT_RSV_ZERO(x) EXPECT_EQ(((x) & 0xE0), 0) +#define EXPECT_RSV_ZERO(x) EXPECT_EQ(((x)&0xE0), 0) #define EXPECT_BIT_X_EQ(x, a) EXPECT_BIT_EQ(x, 7, a) @@ -103,7 +103,7 @@ void RtpFormatVp8TestHelper::GetAllPacketsAndCheck( #define EXPECT_BIT_S_EQ(x, a) EXPECT_BIT_EQ(x, 4, a) -#define EXPECT_PART_ID_EQ(x, a) EXPECT_EQ(((x) & 0x0F), a) +#define EXPECT_PART_ID_EQ(x, a) EXPECT_EQ(((x)&0x0F), a) // Extension fields tests #define EXPECT_BIT_I_EQ(x, a) EXPECT_BIT_EQ(x, 7, a) @@ -114,11 +114,11 @@ void RtpFormatVp8TestHelper::GetAllPacketsAndCheck( #define EXPECT_BIT_K_EQ(x, a) EXPECT_BIT_EQ(x, 4, a) -#define EXPECT_TID_EQ(x, a) EXPECT_EQ((((x) & 0xC0) >> 6), a) +#define EXPECT_TID_EQ(x, a) EXPECT_EQ((((x)&0xC0) >> 6), a) #define EXPECT_BIT_Y_EQ(x, a) EXPECT_BIT_EQ(x, 5, a) -#define EXPECT_KEYIDX_EQ(x, a) EXPECT_EQ(((x) & 0x1F), a) +#define EXPECT_KEYIDX_EQ(x, a) EXPECT_EQ(((x)&0x1F), a) void RtpFormatVp8TestHelper::CheckHeader(bool frag_start) { payload_start_ = 1; @@ -127,8 +127,7 @@ void RtpFormatVp8TestHelper::CheckHeader(bool frag_start) { if (hdr_info_->pictureId != kNoPictureId || hdr_info_->temporalIdx != kNoTemporalIdx || - hdr_info_->tl0PicIdx != kNoTl0PicIdx || - hdr_info_->keyIdx != kNoKeyIdx) { + hdr_info_->tl0PicIdx != kNoTl0PicIdx || hdr_info_->keyIdx != kNoKeyIdx) { EXPECT_BIT_X_EQ(buffer[0], 1); ++payload_start_; CheckPictureID(); diff --git a/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc b/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc index 322600060a..cff14ed9dd 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc @@ -123,11 +123,8 @@ TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) { ASSERT_EQ(num_packets, kExpectedNum); helper_->set_sloppy_partitioning(true); - helper_->GetAllPacketsAndCheck(&packetizer, - kExpectedSizes, - kExpectedPart, - kExpectedFragStart, - kExpectedNum); + helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, + kExpectedFragStart, kExpectedNum); } TEST_F(RtpPacketizerVp8Test, TestEqualSizeWithLastPacketReduction) { @@ -184,11 +181,8 @@ TEST_F(RtpPacketizerVp8Test, TestNonReferenceBit) { ASSERT_EQ(num_packets, kExpectedNum); helper_->set_sloppy_partitioning(true); - helper_->GetAllPacketsAndCheck(&packetizer, - kExpectedSizes, - kExpectedPart, - kExpectedFragStart, - kExpectedNum); + helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, + kExpectedFragStart, kExpectedNum); } // Verify Tl0PicIdx and TID fields, and layerSync bit. @@ -216,11 +210,8 @@ TEST_F(RtpPacketizerVp8Test, TestTl0PicIdxAndTID) { CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); ASSERT_EQ(num_packets, kExpectedNum); - helper_->GetAllPacketsAndCheck(&packetizer, - kExpectedSizes, - kExpectedPart, - kExpectedFragStart, - kExpectedNum); + helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, + kExpectedFragStart, kExpectedNum); } // Verify KeyIdx field. @@ -246,11 +237,8 @@ TEST_F(RtpPacketizerVp8Test, TestKeyIdx) { CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); ASSERT_EQ(num_packets, kExpectedNum); - helper_->GetAllPacketsAndCheck(&packetizer, - kExpectedSizes, - kExpectedPart, - kExpectedFragStart, - kExpectedNum); + helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, + kExpectedFragStart, kExpectedNum); } // Verify TID field and KeyIdx field in combination. @@ -277,11 +265,8 @@ TEST_F(RtpPacketizerVp8Test, TestTIDAndKeyIdx) { CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); ASSERT_EQ(num_packets, kExpectedNum); - helper_->GetAllPacketsAndCheck(&packetizer, - kExpectedSizes, - kExpectedPart, - kExpectedFragStart, - kExpectedNum); + helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, + kExpectedFragStart, kExpectedNum); } class RtpDepacketizerVp8Test : public ::testing::Test { @@ -310,14 +295,14 @@ TEST_F(RtpDepacketizerVp8Test, BasicHeader) { RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength); + ExpectPacket(&payload, packet + kHeaderLength, + sizeof(packet) - kHeaderLength); EXPECT_EQ(kVideoFrameDelta, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 0, 1, 4); - VerifyExtensions( - &payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx, kNoKeyIdx); + VerifyExtensions(&payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx, + kNoKeyIdx); } TEST_F(RtpDepacketizerVp8Test, PictureID) { @@ -331,13 +316,13 @@ TEST_F(RtpDepacketizerVp8Test, PictureID) { RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength1, sizeof(packet) - kHeaderLength1); + ExpectPacket(&payload, packet + kHeaderLength1, + sizeof(packet) - kHeaderLength1); EXPECT_EQ(kVideoFrameDelta, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 1, 0, 0); - VerifyExtensions( - &payload.type, kPictureId, kNoTl0PicIdx, kNoTemporalIdx, kNoKeyIdx); + VerifyExtensions(&payload.type, kPictureId, kNoTl0PicIdx, kNoTemporalIdx, + kNoKeyIdx); // Re-use packet, but change to long PictureID. packet[2] = 0x80 | kPictureId; @@ -345,14 +330,11 @@ TEST_F(RtpDepacketizerVp8Test, PictureID) { payload = RtpDepacketizer::ParsedPayload(); ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength2, sizeof(packet) - kHeaderLength2); + ExpectPacket(&payload, packet + kHeaderLength2, + sizeof(packet) - kHeaderLength2); VerifyBasicHeader(&payload.type, 1, 0, 0); - VerifyExtensions(&payload.type, - (kPictureId << 8) + kPictureId, - kNoTl0PicIdx, - kNoTemporalIdx, - kNoKeyIdx); + VerifyExtensions(&payload.type, (kPictureId << 8) + kPictureId, kNoTl0PicIdx, + kNoTemporalIdx, kNoKeyIdx); } TEST_F(RtpDepacketizerVp8Test, Tl0PicIdx) { @@ -365,13 +347,13 @@ TEST_F(RtpDepacketizerVp8Test, Tl0PicIdx) { RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength); + ExpectPacket(&payload, packet + kHeaderLength, + sizeof(packet) - kHeaderLength); EXPECT_EQ(kVideoFrameKey, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 0, 1, 0); - VerifyExtensions( - &payload.type, kNoPictureId, kTl0PicIdx, kNoTemporalIdx, kNoKeyIdx); + VerifyExtensions(&payload.type, kNoPictureId, kTl0PicIdx, kNoTemporalIdx, + kNoKeyIdx); } TEST_F(RtpDepacketizerVp8Test, TIDAndLayerSync) { @@ -383,8 +365,8 @@ TEST_F(RtpDepacketizerVp8Test, TIDAndLayerSync) { RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength); + ExpectPacket(&payload, packet + kHeaderLength, + sizeof(packet) - kHeaderLength); EXPECT_EQ(kVideoFrameDelta, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 0, 0, 8); @@ -402,13 +384,13 @@ TEST_F(RtpDepacketizerVp8Test, KeyIdx) { RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength); + ExpectPacket(&payload, packet + kHeaderLength, + sizeof(packet) - kHeaderLength); EXPECT_EQ(kVideoFrameDelta, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 0, 0, 8); - VerifyExtensions( - &payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx, kKeyIdx); + VerifyExtensions(&payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx, + kKeyIdx); } TEST_F(RtpDepacketizerVp8Test, MultipleExtensions) { @@ -423,8 +405,8 @@ TEST_F(RtpDepacketizerVp8Test, MultipleExtensions) { RtpDepacketizer::ParsedPayload payload; ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); - ExpectPacket( - &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength); + ExpectPacket(&payload, packet + kHeaderLength, + sizeof(packet) - kHeaderLength); EXPECT_EQ(kVideoFrameDelta, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 0, 0, 8); @@ -467,10 +449,8 @@ TEST_F(RtpDepacketizerVp8Test, TestWithPacketizer) { EXPECT_EQ(kVideoFrameKey, payload.frame_type); EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec); VerifyBasicHeader(&payload.type, 1, 1, 0); - VerifyExtensions(&payload.type, - input_header.pictureId, - input_header.tl0PicIdx, - input_header.temporalIdx, + VerifyExtensions(&payload.type, input_header.pictureId, + input_header.tl0PicIdx, input_header.temporalIdx, input_header.keyIdx); EXPECT_EQ(payload.type.Video.codecHeader.VP8.layerSync, input_header.layerSync); diff --git a/modules/rtp_rtcp/source/rtp_format_vp9.cc b/modules/rtp_rtcp/source/rtp_format_vp9.cc index b354fb179b..cae7911661 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp9.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp9.cc @@ -73,8 +73,7 @@ bool PictureIdPresent(const RTPVideoHeaderVP9& hdr) { // +-+-+-+-+-+-+-+-+ // size_t LayerInfoLength(const RTPVideoHeaderVP9& hdr) { - if (hdr.temporal_idx == kNoTemporalIdx && - hdr.spatial_idx == kNoSpatialIdx) { + if (hdr.temporal_idx == kNoTemporalIdx && hdr.spatial_idx == kNoSpatialIdx) { return 0; } return hdr.flexible_mode ? 1 : 2; @@ -127,12 +126,12 @@ size_t SsDataLength(const RTPVideoHeaderVP9& hdr) { RTC_DCHECK_GT(hdr.num_spatial_layers, 0U); RTC_DCHECK_LE(hdr.num_spatial_layers, kMaxVp9NumberOfSpatialLayers); RTC_DCHECK_LE(hdr.gof.num_frames_in_gof, kMaxVp9FramesInGof); - size_t length = 1; // V + size_t length = 1; // V if (hdr.spatial_layer_resolution_present) { - length += 4 * hdr.num_spatial_layers; // Y + length += 4 * hdr.num_spatial_layers; // Y } if (hdr.gof.num_frames_in_gof > 0) { - ++length; // G + ++length; // G } // N_G length += hdr.gof.num_frames_in_gof; // T, U, R @@ -194,7 +193,8 @@ bool WriteLayerInfoCommon(const RTPVideoHeaderVP9& vp9, RETURN_FALSE_ON_ERROR(writer->WriteBits(TemporalIdxField(vp9, 0), 3)); RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.temporal_up_switch ? 1 : 0, 1)); RETURN_FALSE_ON_ERROR(writer->WriteBits(SpatialIdxField(vp9, 0), 3)); - RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.inter_layer_predicted ? 1: 0, 1)); + RETURN_FALSE_ON_ERROR( + writer->WriteBits(vp9.inter_layer_predicted ? 1 : 0, 1)); return true; } @@ -232,8 +232,8 @@ bool WriteLayerInfo(const RTPVideoHeaderVP9& vp9, // bool WriteRefIndices(const RTPVideoHeaderVP9& vp9, rtc::BitBufferWriter* writer) { - if (!PictureIdPresent(vp9) || - vp9.num_ref_pics == 0 || vp9.num_ref_pics > kMaxVp9RefPics) { + if (!PictureIdPresent(vp9) || vp9.num_ref_pics == 0 || + vp9.num_ref_pics > kMaxVp9RefPics) { return false; } for (uint8_t i = 0; i < vp9.num_ref_pics; ++i) { @@ -469,8 +469,7 @@ RtpPacketizerVp9::RtpPacketizerVp9(const RTPVideoHeaderVP9& hdr, payload_size_(0), last_packet_reduction_len_(last_packet_reduction_len) {} -RtpPacketizerVp9::~RtpPacketizerVp9() { -} +RtpPacketizerVp9::~RtpPacketizerVp9() {} std::string RtpPacketizerVp9::ToString() { return "RtpPacketizerVp9"; @@ -634,8 +633,8 @@ bool RtpPacketizerVp9::WriteHeaderAndPayload(const PacketInfo& packet_info, return false; // Copy payload data. - memcpy(&buffer[header_length], - &payload_[packet_info.payload_start_pos], packet_info.size); + memcpy(&buffer[header_length], &payload_[packet_info.payload_start_pos], + packet_info.size); packet->SetPayloadSize(header_length + packet_info.size); return true; diff --git a/modules/rtp_rtcp/source/rtp_format_vp9.h b/modules/rtp_rtcp/source/rtp_format_vp9.h index 0171977710..90178643eb 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp9.h +++ b/modules/rtp_rtcp/source/rtp_format_vp9.h @@ -87,7 +87,6 @@ class RtpPacketizerVp9 : public RtpPacketizer { RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); }; - class RtpDepacketizerVp9 : public RtpDepacketizer { public: ~RtpDepacketizerVp9() override = default; diff --git a/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc b/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc index 2fe415a8c1..e798302668 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc @@ -225,7 +225,7 @@ TEST_F(RtpPacketizerVp9Test, TestOneBytePictureId) { const size_t kFrameSize = 30; const size_t kPacketSize = 12; - expected_.picture_id = kMaxOneBytePictureId; // 2 byte payload descriptor + expected_.picture_id = kMaxOneBytePictureId; // 2 byte payload descriptor expected_.max_picture_id = kMaxOneBytePictureId; Init(kFrameSize, kPacketSize); @@ -584,8 +584,7 @@ TEST_F(RtpPacketizerVp9Test, TestNonRefForInterLayerPred) { class RtpDepacketizerVp9Test : public ::testing::Test { protected: - RtpDepacketizerVp9Test() - : depacketizer_(new RtpDepacketizerVp9()) {} + RtpDepacketizerVp9Test() : depacketizer_(new RtpDepacketizerVp9()) {} void SetUp() override { expected_.InitRTPVideoHeaderVP9(); } @@ -705,8 +704,8 @@ TEST_F(RtpDepacketizerVp9Test, ParseRefIdx) { TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithNoPictureId) { const uint8_t kPdiff = 3; uint8_t packet[13] = {0}; - packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 Z:0 - packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0 + packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 Z:0 + packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0 RtpDepacketizer::ParsedPayload parsed; EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); diff --git a/modules/rtp_rtcp/source/rtp_payload_registry.cc b/modules/rtp_rtcp/source/rtp_payload_registry.cc index c48cd6c14f..f69940a037 100644 --- a/modules/rtp_rtcp/source/rtp_payload_registry.cc +++ b/modules/rtp_rtcp/source/rtp_payload_registry.cc @@ -30,8 +30,8 @@ bool PayloadIsCompatible(const RtpUtility::Payload& payload, bool PayloadIsCompatible(const RtpUtility::Payload& payload, const VideoCodec& video_codec) { if (!payload.typeSpecific.is_video() || - _stricmp(payload.name, - CodecTypeToPayloadString(video_codec.codecType)) != 0) + _stricmp(payload.name, CodecTypeToPayloadString(video_codec.codecType)) != + 0) return false; // For H264, profiles must match as well. if (video_codec.codecType == kVideoCodecH264) { @@ -72,15 +72,15 @@ bool IsPayloadTypeValid(int8_t payload_type) { // Sanity check. switch (payload_type) { // Reserved payload types to avoid RTCP conflicts when marker bit is set. - case 64: // 192 Full INTRA-frame request. - case 72: // 200 Sender report. - case 73: // 201 Receiver report. - case 74: // 202 Source description. - case 75: // 203 Goodbye. - case 76: // 204 Application-defined. - case 77: // 205 Transport layer FB message. - case 78: // 206 Payload-specific FB message. - case 79: // 207 Extended report. + case 64: // 192 Full INTRA-frame request. + case 72: // 200 Sender report. + case 73: // 201 Receiver report. + case 74: // 202 Source description. + case 75: // 203 Goodbye. + case 76: // 204 Application-defined. + case 77: // 205 Transport layer FB message. + case 78: // 206 Payload-specific FB message. + case 79: // 207 Extended report. RTC_LOG(LS_ERROR) << "Can't register invalid receiver payload type: " << payload_type; return false; @@ -91,8 +91,7 @@ bool IsPayloadTypeValid(int8_t payload_type) { } // namespace -RTPPayloadRegistry::RTPPayloadRegistry() - : last_received_payload_type_(-1) {} +RTPPayloadRegistry::RTPPayloadRegistry() : last_received_payload_type_(-1) {} RTPPayloadRegistry::~RTPPayloadRegistry() = default; @@ -215,8 +214,7 @@ void RTPPayloadRegistry::DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( } } -int RTPPayloadRegistry::GetPayloadTypeFrequency( - uint8_t payload_type) const { +int RTPPayloadRegistry::GetPayloadTypeFrequency(uint8_t payload_type) const { const auto payload = PayloadTypeToPayload(payload_type); if (!payload) { return -1; diff --git a/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/modules/rtp_rtcp/source/rtp_receiver_audio.cc index 06695191b3..3db5ef5c9d 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_audio.cc +++ b/modules/rtp_rtcp/source/rtp_receiver_audio.cc @@ -11,7 +11,7 @@ #include "modules/rtp_rtcp/source/rtp_receiver_audio.h" #include // assert -#include // pow() +#include // pow() #include // memcpy() #include "common_types.h" // NOLINT(build/include) @@ -53,8 +53,7 @@ bool RTPReceiverAudio::TelephoneEventForwardToDecoder() const { return telephone_event_forward_to_decoder_; } -bool RTPReceiverAudio::TelephoneEventPayloadType( - int8_t payload_type) const { +bool RTPReceiverAudio::TelephoneEventPayloadType(int8_t payload_type) const { rtc::CritScope lock(&crit_sect_); return telephone_event_payload_type_ == payload_type; } @@ -139,8 +138,7 @@ int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, num_energy_ = rtp_header->type.Audio.numEnergy; if (rtp_header->type.Audio.numEnergy > 0 && rtp_header->type.Audio.numEnergy <= kRtpCsrcSize) { - memcpy(current_remote_energy_, - rtp_header->type.Audio.arrOfEnergy, + memcpy(current_remote_energy_, rtp_header->type.Audio.arrOfEnergy, rtp_header->type.Audio.numEnergy); } @@ -154,7 +152,6 @@ int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, RTPAliveType RTPReceiverAudio::ProcessDeadOrAlive( uint16_t last_payload_length) const { - // Our CNG is 9 bytes; if it's a likely CNG the receiver needs to check // kRtpNoRtp against NetEq speech_type kOutputPLCtoCNG. if (last_payload_length < 10) { // our CNG is 9 bytes @@ -264,8 +261,7 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific( // don't forward event to decoder return 0; } - std::set::iterator first = - telephone_event_reported_.begin(); + std::set::iterator first = telephone_event_reported_.begin(); if (first != telephone_event_reported_.end() && *first > 15) { // don't forward non DTMF events return 0; diff --git a/modules/rtp_rtcp/source/rtp_receiver_impl.cc b/modules/rtp_rtcp/source/rtp_receiver_impl.cc index fb2cc6660e..a0d201ae8b 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_impl.cc +++ b/modules/rtp_rtcp/source/rtp_receiver_impl.cc @@ -89,7 +89,6 @@ RtpReceiverImpl::RtpReceiverImpl(Clock* clock, current_remote_csrc_(), last_received_timestamp_(0), last_received_frame_time_ms_(-1) { - memset(current_remote_csrc_, 0, sizeof(current_remote_csrc_)); } @@ -122,8 +121,7 @@ int32_t RtpReceiverImpl::RegisterReceivePayload(const VideoCodec& video_codec) { return rtp_payload_registry_->RegisterReceivePayload(video_codec); } -int32_t RtpReceiverImpl::DeRegisterReceivePayload( - const int8_t payload_type) { +int32_t RtpReceiverImpl::DeRegisterReceivePayload(const int8_t payload_type) { rtc::CritScope lock(&critical_section_rtp_receiver_); return rtp_payload_registry_->DeRegisterReceivePayload(payload_type); } @@ -140,13 +138,12 @@ int32_t RtpReceiverImpl::CSRCs(uint32_t array_of_csrcs[kRtpCsrcSize]) const { assert(num_csrcs_ <= kRtpCsrcSize); if (num_csrcs_ > 0) { - memcpy(array_of_csrcs, current_remote_csrc_, sizeof(uint32_t)*num_csrcs_); + memcpy(array_of_csrcs, current_remote_csrc_, sizeof(uint32_t) * num_csrcs_); } return num_csrcs_; } -int32_t RtpReceiverImpl::Energy( - uint8_t array_of_energy[kRtpCsrcSize]) const { +int32_t RtpReceiverImpl::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const { return rtp_media_receiver_->Energy(array_of_energy); } @@ -157,8 +154,7 @@ bool RtpReceiverImpl::IncomingRtpPacket(const RTPHeader& rtp_header, // Trigger our callbacks. CheckSSRCChanged(rtp_header); - if (CheckPayloadChanged(rtp_header, - &payload_specific) == -1) { + if (CheckPayloadChanged(rtp_header, &payload_specific) == -1) { if (payload_length == 0) { // OK, keep-alive packet. return true; @@ -282,9 +278,8 @@ int32_t RtpReceiverImpl::CheckPayloadChanged(const RTPHeader& rtp_header, if (payload_type != last_received_payload_type) { bool should_discard_changes = false; - rtp_media_receiver_->CheckPayloadChanged( - payload_type, specific_payload, - &should_discard_changes); + rtp_media_receiver_->CheckPayloadChanged(payload_type, specific_payload, + &should_discard_changes); if (should_discard_changes) { return 0; @@ -314,8 +309,7 @@ void RtpReceiverImpl::CheckCSRC(const WebRtcRTPHeader& rtp_header) { rtc::CritScope lock(&critical_section_rtp_receiver_); // Copy new. - memcpy(current_remote_csrc_, - rtp_header.header.arrOfCSRCs, + memcpy(current_remote_csrc_, rtp_header.header.arrOfCSRCs, num_csrcs * sizeof(uint32_t)); num_csrcs_ = num_csrcs; diff --git a/modules/rtp_rtcp/source/rtp_receiver_video.cc b/modules/rtp_rtcp/source/rtp_receiver_video.cc index ee6cc27be4..d93ee76dd2 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_video.cc +++ b/modules/rtp_rtcp/source/rtp_receiver_video.cc @@ -32,11 +32,9 @@ RTPReceiverStrategy* RTPReceiverStrategy::CreateVideoStrategy( } RTPReceiverVideo::RTPReceiverVideo(RtpData* data_callback) - : RTPReceiverStrategy(data_callback) { -} + : RTPReceiverStrategy(data_callback) {} -RTPReceiverVideo::~RTPReceiverVideo() { -} +RTPReceiverVideo::~RTPReceiverVideo() {} int32_t RTPReceiverVideo::OnNewPayloadTypeCreated( int payload_type, diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 289ef539ce..fe8dbf385c 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -64,8 +64,7 @@ RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) { } else { // No clock implementation provided, use default clock. RtpRtcp::Configuration configuration_copy; - memcpy(&configuration_copy, &configuration, - sizeof(RtpRtcp::Configuration)); + memcpy(&configuration_copy, &configuration, sizeof(RtpRtcp::Configuration)); configuration_copy.clock = Clock::GetRealTimeClock(); return new ModuleRtpRtcpImpl(configuration_copy); } @@ -221,10 +220,10 @@ void ModuleRtpRtcpImpl::Process() { } else { // Report rtt from receiver. if (process_rtt) { - int64_t rtt_ms; - if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) { - rtt_stats_->OnRttUpdate(rtt_ms); - } + int64_t rtt_ms; + if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) { + rtt_stats_->OnRttUpdate(rtt_ms); + } } } @@ -277,8 +276,7 @@ void ModuleRtpRtcpImpl::IncomingRtcpPacket(const uint8_t* rtcp_packet, rtcp_receiver_.IncomingPacket(rtcp_packet, length); } -int32_t ModuleRtpRtcpImpl::RegisterSendPayload( - const CodecInst& voice_codec) { +int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const CodecInst& voice_codec) { return rtp_sender_->RegisterPayload( voice_codec.plname, voice_codec.pltype, voice_codec.plfreq, voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate); @@ -365,16 +363,15 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() { StreamDataCounters rtp_stats; StreamDataCounters rtx_stats; rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); - state.packets_sent = rtp_stats.transmitted.packets + - rtx_stats.transmitted.packets; + state.packets_sent = + rtp_stats.transmitted.packets + rtx_stats.transmitted.packets; state.media_bytes_sent = rtp_stats.transmitted.payload_bytes + rtx_stats.transmitted.payload_bytes; state.send_bitrate = rtp_sender_->BitrateSent(); } state.module = this; - LastReceivedNTP(&state.last_rr_ntp_secs, - &state.last_rr_ntp_frac, + LastReceivedNTP(&state.last_rr_ntp_secs, &state.last_rr_ntp_frac, &state.remote_sr); state.last_xr_rtis = rtcp_receiver_.ConsumeReceivedXrReferenceTimeInfo(); @@ -432,7 +429,7 @@ bool ModuleRtpRtcpImpl::SendOutgoingData( rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); // Make sure an RTCP report isn't queued behind a key frame. if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { - rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); + rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); } int64_t expected_retransmission_time_ms = rtt_ms(); if (expected_retransmission_time_ms == 0) { @@ -456,7 +453,7 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, bool retransmission, const PacedPacketInfo& pacing_info) { return rtp_sender_->TimeToSendPacket(ssrc, sequence_number, capture_time_ms, - retransmission, pacing_info); + retransmission, pacing_info); } size_t ModuleRtpRtcpImpl::TimeToSendPadding( @@ -501,22 +498,18 @@ int32_t ModuleRtpRtcpImpl::RemoveMixedCNAME(const uint32_t ssrc) { return rtcp_sender_.RemoveMixedCNAME(ssrc); } -int32_t ModuleRtpRtcpImpl::RemoteCNAME( - const uint32_t remote_ssrc, - char c_name[RTCP_CNAME_SIZE]) const { +int32_t ModuleRtpRtcpImpl::RemoteCNAME(const uint32_t remote_ssrc, + char c_name[RTCP_CNAME_SIZE]) const { return rtcp_receiver_.CNAME(remote_ssrc, c_name); } -int32_t ModuleRtpRtcpImpl::RemoteNTP( - uint32_t* received_ntpsecs, - uint32_t* received_ntpfrac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp) const { - return rtcp_receiver_.NTP(received_ntpsecs, - received_ntpfrac, - rtcp_arrival_time_secs, - rtcp_arrival_time_frac, +int32_t ModuleRtpRtcpImpl::RemoteNTP(uint32_t* received_ntpsecs, + uint32_t* received_ntpfrac, + uint32_t* rtcp_arrival_time_secs, + uint32_t* rtcp_arrival_time_frac, + uint32_t* rtcp_timestamp) const { + return rtcp_receiver_.NTP(received_ntpsecs, received_ntpfrac, + rtcp_arrival_time_secs, rtcp_arrival_time_frac, rtcp_timestamp) ? 0 : -1; @@ -554,13 +547,13 @@ int32_t ModuleRtpRtcpImpl::SetRTCPApplicationSpecificData( const uint32_t name, const uint8_t* data, const uint16_t length) { - return rtcp_sender_.SetApplicationSpecificData(sub_type, name, data, length); + return rtcp_sender_.SetApplicationSpecificData(sub_type, name, data, length); } // (XR) VOIP metric. int32_t ModuleRtpRtcpImpl::SetRTCPVoIPMetrics( - const RTCPVoIPMetric* voip_metric) { - return rtcp_sender_.SetRTCPVoIPMetrics(voip_metric); + const RTCPVoIPMetric* voip_metric) { + return rtcp_sender_.SetRTCPVoIPMetrics(voip_metric); } void ModuleRtpRtcpImpl::SetRtcpXrRrtrStatus(bool enable) { @@ -573,9 +566,8 @@ bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const { } // TODO(asapersson): Replace this method with the one below. -int32_t ModuleRtpRtcpImpl::DataCountersRTP( - size_t* bytes_sent, - uint32_t* packets_sent) const { +int32_t ModuleRtpRtcpImpl::DataCountersRTP(size_t* bytes_sent, + uint32_t* packets_sent) const { StreamDataCounters rtp_stats; StreamDataCounters rtx_stats; rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); @@ -589,8 +581,8 @@ int32_t ModuleRtpRtcpImpl::DataCountersRTP( rtx_stats.transmitted.header_bytes; } if (packets_sent) { - *packets_sent = rtp_stats.transmitted.packets + - rtx_stats.transmitted.packets; + *packets_sent = + rtp_stats.transmitted.packets + rtx_stats.transmitted.packets; } return 0; } @@ -605,7 +597,8 @@ void ModuleRtpRtcpImpl::GetRtpPacketLossStats( bool outgoing, uint32_t ssrc, struct RtpPacketLossStats* loss_stats) const { - if (!loss_stats) return; + if (!loss_stats) + return; const PacketLossStats* stats_source = NULL; if (outgoing) { if (SSRC() == ssrc) { @@ -617,8 +610,7 @@ void ModuleRtpRtcpImpl::GetRtpPacketLossStats( } } if (stats_source) { - loss_stats->single_packet_loss_count = - stats_source->GetSingleLossCount(); + loss_stats->single_packet_loss_count = stats_source->GetSingleLossCount(); loss_stats->multiple_packet_loss_event_count = stats_source->GetMultipleLossEventCount(); loss_stats->multiple_packet_loss_packet_count = @@ -776,15 +768,13 @@ bool ModuleRtpRtcpImpl::SendFeedbackPacket( } // Send a TelephoneEvent tone using RFC 2833 (4733). -int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband( - const uint8_t key, - const uint16_t time_ms, - const uint8_t level) { +int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband(const uint8_t key, + const uint16_t time_ms, + const uint8_t level) { return rtp_sender_->SendTelephoneEvent(key, time_ms, level); } -int32_t ModuleRtpRtcpImpl::SetAudioLevel( - const uint8_t level_d_bov) { +int32_t ModuleRtpRtcpImpl::SetAudioLevel(const uint8_t level_d_bov) { return rtp_sender_->SetAudioLevel(level_d_bov); } @@ -843,8 +833,7 @@ void ModuleRtpRtcpImpl::OnReceivedNack( for (uint16_t nack_sequence_number : nack_sequence_numbers) { send_loss_stats_.AddLostPacket(nack_sequence_number); } - if (!rtp_sender_->StorePackets() || - nack_sequence_numbers.size() == 0) { + if (!rtp_sender_->StorePackets() || nack_sequence_numbers.size() == 0) { return; } // Use RTT from RtcpRttStats class if provided. @@ -869,11 +858,8 @@ bool ModuleRtpRtcpImpl::LastReceivedNTP( uint32_t ntp_secs = 0; uint32_t ntp_frac = 0; - if (!rtcp_receiver_.NTP(&ntp_secs, - &ntp_frac, - rtcp_arrival_time_secs, - rtcp_arrival_time_frac, - NULL)) { + if (!rtcp_receiver_.NTP(&ntp_secs, &ntp_frac, rtcp_arrival_time_secs, + rtcp_arrival_time_frac, NULL)) { return false; } *remote_sr = @@ -922,7 +908,7 @@ void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( } StreamDataCountersCallback* - ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { +ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { return rtp_sender_->GetRtpStatisticsCallback(); } diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc index c92e7445cd..0c9e885fc5 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -49,8 +49,7 @@ class RtcpRttStatsTestImpl : public RtcpRttStats { int64_t rtt_ms_; }; -class SendTransport : public Transport, - public RtpData { +class SendTransport : public Transport, public RtpData { public: SendTransport() : receiver_(nullptr), @@ -61,9 +60,7 @@ class SendTransport : public Transport, keepalive_payload_type_(0), num_keepalive_sent_(0) {} - void SetRtpRtcpModule(ModuleRtpRtcpImpl* receiver) { - receiver_ = receiver; - } + void SetRtpRtcpModule(ModuleRtpRtcpImpl* receiver) { receiver_ = receiver; } void SimulateNetworkDelay(int64_t delay_ms, SimulatedClock* clock) { clock_ = clock; delay_ms_ = delay_ms; @@ -156,9 +153,7 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver { // Received RTCP stats for (own) local SSRC. return counter_map_[impl_->SSRC()]; } - int RtpSent() { - return transport_.rtp_packets_sent_; - } + int RtpSent() { return transport_.rtp_packets_sent_; } uint16_t LastRtpSequenceNumber() { return transport_.last_rtp_header_.sequenceNumber; } @@ -250,8 +245,8 @@ class RtpRtcpImplTest : public ::testing::Test { const uint8_t payload[100] = {0}; EXPECT_EQ(true, module->impl_->SendOutgoingData( - kVideoFrameKey, codec_.plType, 0, 0, payload, - sizeof(payload), nullptr, &rtp_video_header, nullptr)); + kVideoFrameKey, codec_.plType, 0, 0, payload, + sizeof(payload), nullptr, &rtp_video_header, nullptr)); } void IncomingRtcpNack(const RtpRtcpModule* module, uint16_t sequence_number) { @@ -348,16 +343,16 @@ TEST_F(RtpRtcpImplTest, Rtt) { int64_t avg_rtt; int64_t min_rtt; int64_t max_rtt; - EXPECT_EQ(0, - sender_.impl_->RTT(kReceiverSsrc, &rtt, &avg_rtt, &min_rtt, &max_rtt)); + EXPECT_EQ( + 0, sender_.impl_->RTT(kReceiverSsrc, &rtt, &avg_rtt, &min_rtt, &max_rtt)); EXPECT_NEAR(2 * kOneWayNetworkDelayMs, rtt, 1); EXPECT_NEAR(2 * kOneWayNetworkDelayMs, avg_rtt, 1); EXPECT_NEAR(2 * kOneWayNetworkDelayMs, min_rtt, 1); EXPECT_NEAR(2 * kOneWayNetworkDelayMs, max_rtt, 1); // No RTT from other ssrc. - EXPECT_EQ(-1, - sender_.impl_->RTT(kReceiverSsrc+1, &rtt, &avg_rtt, &min_rtt, &max_rtt)); + EXPECT_EQ(-1, sender_.impl_->RTT(kReceiverSsrc + 1, &rtt, &avg_rtt, &min_rtt, + &max_rtt)); // Verify RTT from rtt_stats config. EXPECT_EQ(0, sender_.rtt_stats_.LastProcessedRtt()); @@ -464,8 +459,8 @@ TEST_F(RtpRtcpImplTest, AddStreamDataCounters) { rtp.transmitted.header_bytes = 2; rtp.transmitted.padding_bytes = 3; EXPECT_EQ(rtp.transmitted.TotalBytes(), rtp.transmitted.payload_bytes + - rtp.transmitted.header_bytes + - rtp.transmitted.padding_bytes); + rtp.transmitted.header_bytes + + rtp.transmitted.padding_bytes); StreamDataCounters rtp2; rtp2.first_packet_time_ms = -1; diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index 8e0a4e8906..42cdcf8bd6 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -79,10 +79,14 @@ const char* FrameTypeToString(FrameType frame_type) { switch (frame_type) { case kEmptyFrame: return "empty"; - case kAudioFrameSpeech: return "audio_speech"; - case kAudioFrameCN: return "audio_cn"; - case kVideoFrameKey: return "video_key"; - case kVideoFrameDelta: return "video_delta"; + case kAudioFrameSpeech: + return "audio_speech"; + case kAudioFrameCN: + return "audio_cn"; + case kVideoFrameKey: + return "video_key"; + case kVideoFrameDelta: + return "video_delta"; } return ""; } @@ -260,8 +264,8 @@ int32_t RTPSender::RegisterPayload( RTC_DCHECK(payload); // Check if it's the same as we already have. - if (RtpUtility::StringCompare( - payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1)) { + if (RtpUtility::StringCompare(payload->name, payload_name, + RTP_PAYLOAD_NAME_SIZE - 1)) { if (audio_configured_ && payload->typeSpecific.is_audio()) { auto& p = payload->typeSpecific.audio_payload(); if (rtc::SafeEq(p.format.clockrate_hz, frequency) && @@ -439,8 +443,8 @@ bool RTPSender::SendOutgoingData(FrameType frame_type, result = audio_->SendAudio(frame_type, payload_type, rtp_timestamp, payload_data, payload_size); } else { - TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, - "Send", "type", FrameTypeToString(frame_type)); + TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, "Send", "type", + FrameTypeToString(frame_type)); if (frame_type == kEmptyFrame) return true; @@ -983,9 +987,9 @@ void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) { rtc::CritScope cs(&statistics_crit_); // TODO(holmer): Compute this iteratively instead. send_delays_[now_ms] = now_ms - capture_time_ms; - send_delays_.erase(send_delays_.begin(), - send_delays_.lower_bound(now_ms - - kSendSideDelayWindowMs)); + send_delays_.erase( + send_delays_.begin(), + send_delays_.lower_bound(now_ms - kSendSideDelayWindowMs)); int num_delays = 0; for (auto it = send_delays_.upper_bound(now_ms - kSendSideDelayWindowMs); it != send_delays_.end(); ++it) { diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc index 4ca16880c2..bf86a39339 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -26,8 +26,7 @@ namespace webrtc { RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtp_sender) - : clock_(clock), - rtp_sender_(rtp_sender) {} + : clock_(clock), rtp_sender_(rtp_sender) {} RTPSenderAudio::~RTPSenderAudio() {} @@ -190,7 +189,8 @@ bool RTPSenderAudio::SendAudio(FrameType frame_type, dtmf_duration_samples -= 0xffff; dtmf_length_samples_ -= 0xffff; - return SendTelephoneEventPacket(ended, dtmf_timestamp_, + return SendTelephoneEventPacket( + ended, dtmf_timestamp_, static_cast(dtmf_duration_samples), false); } else { if (!SendTelephoneEventPacket(ended, dtmf_timestamp_, diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index aa27263fcd..86b0aa3818 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -390,9 +390,8 @@ TEST_P(RtpSenderTest, AssignSequenceNumberAllowsPaddingOnAudio) { const size_t kMinPaddingSize = 50; EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _)) .WillOnce(testing::Return(true)); - EXPECT_EQ( - kMinPaddingSize, - rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, PacedPacketInfo())); + EXPECT_EQ(kMinPaddingSize, rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, + PacedPacketInfo())); } TEST_P(RtpSenderTestWithoutPacer, AssignSequenceNumberSetPaddingTimestamps) { @@ -941,21 +940,22 @@ TEST_P(RtpSenderTest, SendRedundantPayloads) { PacketOptions options; EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _)) - .WillOnce(testing::DoAll(testing::SaveArg<2>(&options), - testing::Return(true))); + .WillOnce( + testing::DoAll(testing::SaveArg<2>(&options), testing::Return(true))); EXPECT_EQ(kPayloadSizes[0], rtp_sender_->TimeToSendPadding(500, PacedPacketInfo())); EXPECT_TRUE(options.is_retransmit); - EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] + - rtp_header_len + kRtxHeaderSize, + EXPECT_CALL(transport, SendRtp(_, + kPayloadSizes[kNumPayloadSizes - 1] + + rtp_header_len + kRtxHeaderSize, _)) .WillOnce(testing::Return(true)); options.is_retransmit = false; EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) - .WillOnce(testing::DoAll(testing::SaveArg<2>(&options), - testing::Return(true))); + .WillOnce( + testing::DoAll(testing::SaveArg<2>(&options), testing::Return(true))); EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize, rtp_sender_->TimeToSendPadding(999, PacedPacketInfo())); EXPECT_FALSE(options.is_retransmit); diff --git a/modules/rtp_rtcp/source/rtp_utility.cc b/modules/rtp_rtcp/source/rtp_utility.cc index 1d44b3c8ab..e050da60f8 100644 --- a/modules/rtp_rtcp/source/rtp_utility.cc +++ b/modules/rtp_rtcp/source/rtp_utility.cc @@ -33,8 +33,7 @@ enum { * Misc utility routines */ -bool StringCompare(const char* str1, const char* str2, - const uint32_t length) { +bool StringCompare(const char* str1, const char* str2, const uint32_t length) { return _strnicmp(str1, str2, length) == 0; } @@ -48,11 +47,9 @@ size_t Word32Align(size_t size) { RtpHeaderParser::RtpHeaderParser(const uint8_t* rtpData, const size_t rtpDataLength) : _ptrRTPDataBegin(rtpData), - _ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) { -} + _ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) {} -RtpHeaderParser::~RtpHeaderParser() { -} +RtpHeaderParser::~RtpHeaderParser() {} bool RtpHeaderParser::RTCP() const { // 72 to 76 is reserved for RTP @@ -60,21 +57,21 @@ bool RtpHeaderParser::RTCP() const { // for RTCP 200 SR == marker bit + 72 // for RTCP 204 APP == marker bit + 76 /* - * RTCP - * - * FIR full INTRA-frame request 192 [RFC2032] supported - * NACK negative acknowledgement 193 [RFC2032] - * IJ Extended inter-arrival jitter report 195 [RFC-ietf-avt-rtp-toff - * set-07.txt] http://tools.ietf.org/html/draft-ietf-avt-rtp-toffset-07 - * SR sender report 200 [RFC3551] supported - * RR receiver report 201 [RFC3551] supported - * SDES source description 202 [RFC3551] supported - * BYE goodbye 203 [RFC3551] supported - * APP application-defined 204 [RFC3551] ignored - * RTPFB Transport layer FB message 205 [RFC4585] supported - * PSFB Payload-specific FB message 206 [RFC4585] supported - * XR extended report 207 [RFC3611] supported - */ + * RTCP + * + * FIR full INTRA-frame request 192 [RFC2032] supported + * NACK negative acknowledgement 193 [RFC2032] + * IJ Extended inter-arrival jitter report 195 [RFC-ietf-avt-rtp-toff + * set-07.txt] http://tools.ietf.org/html/draft-ietf-avt-rtp-toffset-07 + * SR sender report 200 [RFC3551] supported + * RR receiver report 201 [RFC3551] supported + * SDES source description 202 [RFC3551] supported + * BYE goodbye 203 [RFC3551] supported + * APP application-defined 204 [RFC3551] ignored + * RTPFB Transport layer FB message 205 [RFC4585] supported + * PSFB Payload-specific FB message 206 [RFC4585] supported + * XR extended report 207 [RFC3611] supported + */ /* 205 RFC 5104 * FMT 1 NACK supported @@ -84,15 +81,15 @@ bool RtpHeaderParser::RTCP() const { */ /* 206 RFC 5104 - * FMT 1: Picture Loss Indication (PLI) supported - * FMT 2: Slice Lost Indication (SLI) - * FMT 3: Reference Picture Selection Indication (RPSI) - * FMT 4: Full Intra Request (FIR) Command supported - * FMT 5: Temporal-Spatial Trade-off Request (TSTR) - * FMT 6: Temporal-Spatial Trade-off Notification (TSTN) - * FMT 7: Video Back Channel Message (VBCM) - * FMT 15: Application layer FB message - */ + * FMT 1: Picture Loss Indication (PLI) supported + * FMT 2: Slice Lost Indication (SLI) + * FMT 3: Reference Picture Selection Indication (RPSI) + * FMT 4: Full Intra Request (FIR) Command supported + * FMT 5: Temporal-Spatial Trade-off Request (TSTR) + * FMT 6: Temporal-Spatial Trade-off Notification (TSTN) + * FMT 7: Video Back Channel Message (VBCM) + * FMT 15: Application layer FB message + */ const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin; if (length < kRtcpMinHeaderLength) { @@ -147,8 +144,8 @@ bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const { uint32_t SSRC = ByteReader::ReadBigEndian(ptr); ptr += 4; - header->payloadType = PT; - header->ssrc = SSRC; + header->payloadType = PT; + header->ssrc = SSRC; header->headerLength = 4 + (len << 2); return true; @@ -163,18 +160,18 @@ bool RtpHeaderParser::Parse( } // Version - const uint8_t V = _ptrRTPDataBegin[0] >> 6; + const uint8_t V = _ptrRTPDataBegin[0] >> 6; // Padding - const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true; + const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true; // eXtension - const bool X = ((_ptrRTPDataBegin[0] & 0x10) == 0) ? false : true; + const bool X = ((_ptrRTPDataBegin[0] & 0x10) == 0) ? false : true; const uint8_t CC = _ptrRTPDataBegin[0] & 0x0f; - const bool M = ((_ptrRTPDataBegin[1] & 0x80) == 0) ? false : true; + const bool M = ((_ptrRTPDataBegin[1] & 0x80) == 0) ? false : true; const uint8_t PT = _ptrRTPDataBegin[1] & 0x7f; - const uint16_t sequenceNumber = (_ptrRTPDataBegin[2] << 8) + - _ptrRTPDataBegin[3]; + const uint16_t sequenceNumber = + (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3]; const uint8_t* ptr = &_ptrRTPDataBegin[4]; @@ -194,13 +191,13 @@ bool RtpHeaderParser::Parse( return false; } - header->markerBit = M; - header->payloadType = PT; + header->markerBit = M; + header->payloadType = PT; header->sequenceNumber = sequenceNumber; - header->timestamp = RTPTimestamp; - header->ssrc = SSRC; - header->numCSRCs = CC; - header->paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0; + header->timestamp = RTPTimestamp; + header->ssrc = SSRC; + header->numCSRCs = CC; + header->paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0; for (uint8_t i = 0; i < CC; ++i) { uint32_t CSRC = ByteReader::ReadBigEndian(ptr); @@ -208,7 +205,7 @@ bool RtpHeaderParser::Parse( header->arrOfCSRCs[i] = CSRC; } - header->headerLength = 12 + CSRCocts; + header->headerLength = 12 + CSRCocts; // If in effect, MAY be omitted for those packets for which the offset // is zero. @@ -270,10 +267,8 @@ bool RtpHeaderParser::Parse( static constexpr uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; if (definedByProfile == kRtpOneByteHeaderExtensionId) { const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen; - ParseOneByteExtensionHeader(header, - ptrExtensionMap, - ptrRTPDataExtensionEnd, - ptr); + ParseOneByteExtensionHeader(header, ptrExtensionMap, + ptrRTPDataExtensionEnd, ptr); } header->headerLength += XLen; } diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc b/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc index cb3e28bd46..3afd61228f 100644 --- a/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc +++ b/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc @@ -233,7 +233,7 @@ int32_t UlpfecReceiverImpl::ProcessReceivedFec() { // not modifying the vector we are currently iterating over (packets are added // in AddReceivedRedPacket). std::vector> - received_packets; + received_packets; received_packets.swap(received_packets_); for (const auto& received_packet : received_packets) { @@ -260,8 +260,7 @@ int32_t UlpfecReceiverImpl::ProcessReceivedFec() { // header, OnRecoveredPacket will recurse back here. recovered_packet->returned = true; crit_sect_.Leave(); - recovered_packet_callback_->OnRecoveredPacket(packet->data, - packet->length); + recovered_packet_callback_->OnRecoveredPacket(packet->data, packet->length); crit_sect_.Enter(); } diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc index c3bd5a7304..e050f807d0 100644 --- a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc @@ -15,8 +15,8 @@ #include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "modules/rtp_rtcp/include/ulpfec_receiver.h" -#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" +#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/fec_test_helper.h" #include "modules/rtp_rtcp/source/forward_error_correction.h" @@ -351,8 +351,7 @@ TEST_F(UlpfecReceiverTest, PacketNotDroppedTooEarly) { EncodeFec(media_packets_batch1, kNumFecPacketsBatch1, &fec_packets); BuildAndAddRedMediaPacket(augmented_media_packets_batch1.front()); - EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)) - .Times(1); + EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1); EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); delayed_fec = fec_packets.front(); @@ -367,15 +366,13 @@ TEST_F(UlpfecReceiverTest, PacketNotDroppedTooEarly) { for (auto it = augmented_media_packets_batch2.begin(); it != augmented_media_packets_batch2.end(); ++it) { BuildAndAddRedMediaPacket(*it); - EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)) - .Times(1); + EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1); EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); } // Add the delayed FEC packet. One packet should be reconstructed. BuildAndAddRedFecPacket(delayed_fec); - EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)) - .Times(1); + EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1); EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); } @@ -393,8 +390,7 @@ TEST_F(UlpfecReceiverTest, PacketDroppedWhenTooOld) { EncodeFec(media_packets_batch1, kNumFecPacketsBatch1, &fec_packets); BuildAndAddRedMediaPacket(augmented_media_packets_batch1.front()); - EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)) - .Times(1); + EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1); EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); delayed_fec = fec_packets.front(); @@ -409,8 +405,7 @@ TEST_F(UlpfecReceiverTest, PacketDroppedWhenTooOld) { for (auto it = augmented_media_packets_batch2.begin(); it != augmented_media_packets_batch2.end(); ++it) { BuildAndAddRedMediaPacket(*it); - EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)) - .Times(1); + EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1); EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); } @@ -451,8 +446,7 @@ TEST_F(UlpfecReceiverTest, OldFecPacketDropped) { // and should have been dropped. Only the media packet we inserted will be // returned. BuildAndAddRedMediaPacket(augmented_media_packets.front()); - EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)) - .Times(1); + EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1); EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); } diff --git a/modules/rtp_rtcp/test/testAPI/test_api_audio.cc b/modules/rtp_rtcp/test/testAPI/test_api_audio.cc index a6ccc90a68..d64440f79d 100644 --- a/modules/rtp_rtcp/test/testAPI/test_api_audio.cc +++ b/modules/rtp_rtcp/test/testAPI/test_api_audio.cc @@ -25,7 +25,7 @@ namespace webrtc { namespace { const uint32_t kTestRate = 64000u; -const uint8_t kTestPayload[] = { 't', 'e', 's', 't' }; +const uint8_t kTestPayload[] = {'t', 'e', 's', 't'}; const uint8_t kPcmuPayloadType = 96; const uint8_t kDtmfPayloadType = 97; diff --git a/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc b/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc index e1b333fe09..44b1ff5264 100644 --- a/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc +++ b/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc @@ -28,11 +28,8 @@ namespace { class RtcpCallback : public RtcpIntraFrameObserver { public: - void SetModule(RtpRtcp* module) { - _rtpRtcpModule = module; - } - virtual void OnRTCPPacketTimeout(const int32_t id) { - } + void SetModule(RtpRtcp* module) { _rtpRtcpModule = module; } + virtual void OnRTCPPacketTimeout(const int32_t id) {} virtual void OnLipSyncUpdate(const int32_t id, const int32_t audioVideoOffset) {} void OnReceivedIntraFrameRequest(uint32_t ssrc) override {} diff --git a/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/modules/rtp_rtcp/test/testAPI/test_api_video.cc index 6d6f31bee2..91d1bfdd68 100644 --- a/modules/rtp_rtcp/test/testAPI/test_api_video.cc +++ b/modules/rtp_rtcp/test/testAPI/test_api_video.cc @@ -27,7 +27,6 @@ namespace { const unsigned char kPayloadType = 100; - }; namespace webrtc { @@ -75,13 +74,13 @@ class RtpRtcpVideoTest : public ::testing::Test { payload_data_length_ = sizeof(video_frame_); for (size_t n = 0; n < payload_data_length_; n++) { - video_frame_[n] = n%10; + video_frame_[n] = n % 10; } } size_t BuildRTPheader(uint8_t* dataBuffer, - uint32_t timestamp, - uint32_t sequence_number) { + uint32_t timestamp, + uint32_t sequence_number) { dataBuffer[0] = static_cast(0x80); // version 2 dataBuffer[1] = static_cast(kPayloadType); ByteWriter::WriteBigEndian(dataBuffer + 2, sequence_number); @@ -105,8 +104,7 @@ class RtpRtcpVideoTest : public ::testing::Test { // Correct seq num, timestamp and payload type. size_t header_length = BuildRTPheader(buffer, timestamp, sequence_number); buffer[0] |= 0x20; // Set padding bit. - int32_t* data = - reinterpret_cast(&(buffer[header_length])); + int32_t* data = reinterpret_cast(&(buffer[header_length])); // Fill data buffer with random data. for (size_t j = 0; j < (padding_bytes_in_packet >> 2); j++) { @@ -134,7 +132,7 @@ class RtpRtcpVideoTest : public ::testing::Test { uint32_t test_ssrc_; uint32_t test_timestamp_; uint16_t test_sequence_number_; - uint8_t video_frame_[65000]; + uint8_t video_frame_[65000]; size_t payload_data_length_; SimulatedClock fake_clock; RateLimiter retransmission_rate_limiter_; @@ -158,8 +156,8 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) { EXPECT_EQ(0, rtp_payload_registry_.RegisterReceivePayload(codec)); for (int frame_idx = 0; frame_idx < 10; ++frame_idx) { for (int packet_idx = 0; packet_idx < 5; ++packet_idx) { - size_t packet_size = PaddingPacket(padding_packet, timestamp, seq_num, - kPadSize); + size_t packet_size = + PaddingPacket(padding_packet, timestamp, seq_num, kPadSize); ++seq_num; RTPHeader header; std::unique_ptr parser(RtpHeaderParser::Create()); diff --git a/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h b/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h index ccf9752ee9..0bc2f56917 100644 --- a/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h +++ b/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h @@ -23,169 +23,35 @@ const int kNumberCodes = kMaxMediaPacketsTest * (kMaxMediaPacketsTest + 1) / 2; // loss expected for each code size up to: // (kMaxMediaPacketsTest, kMaxMediaPacketsTest). const float kMaxResidualLossRandomMask[kNumberCodes] = { - 0.009463f, - 0.022436f, - 0.007376f, - 0.033895f, - 0.012423f, - 0.004644f, - 0.043438f, - 0.019937f, - 0.008820f, - 0.003438f, - 0.051282f, - 0.025795f, - 0.012872f, - 0.006458f, - 0.003195f, - 0.057728f, - 0.032146f, - 0.016708f, - 0.009242f, - 0.005054f, - 0.003078f, - 0.063050f, - 0.037261f, - 0.021767f, - 0.012447f, - 0.007099f, - 0.003826f, - 0.002504f, - 0.067476f, - 0.042348f, - 0.026169f, - 0.015695f, - 0.009478f, - 0.005887f, - 0.003568f, - 0.001689f, - 0.071187f, - 0.046575f, - 0.031697f, - 0.019797f, - 0.012433f, - 0.007027f, - 0.004845f, - 0.002777f, - 0.001753f, - 0.074326f, - 0.050628f, - 0.034978f, - 0.021955f, - 0.014821f, - 0.009462f, - 0.006393f, - 0.004181f, - 0.003105f, - 0.001231f, - 0.077008f, - 0.054226f, - 0.038407f, - 0.026251f, - 0.018634f, - 0.011568f, - 0.008130f, - 0.004957f, - 0.003334f, - 0.002069f, - 0.001304f, - 0.079318f, - 0.057180f, - 0.041268f, - 0.028842f, - 0.020033f, - 0.014061f, - 0.009636f, - 0.006411f, - 0.004583f, - 0.002817f, - 0.001770f, - 0.001258f -}; + 0.009463f, 0.022436f, 0.007376f, 0.033895f, 0.012423f, 0.004644f, 0.043438f, + 0.019937f, 0.008820f, 0.003438f, 0.051282f, 0.025795f, 0.012872f, 0.006458f, + 0.003195f, 0.057728f, 0.032146f, 0.016708f, 0.009242f, 0.005054f, 0.003078f, + 0.063050f, 0.037261f, 0.021767f, 0.012447f, 0.007099f, 0.003826f, 0.002504f, + 0.067476f, 0.042348f, 0.026169f, 0.015695f, 0.009478f, 0.005887f, 0.003568f, + 0.001689f, 0.071187f, 0.046575f, 0.031697f, 0.019797f, 0.012433f, 0.007027f, + 0.004845f, 0.002777f, 0.001753f, 0.074326f, 0.050628f, 0.034978f, 0.021955f, + 0.014821f, 0.009462f, 0.006393f, 0.004181f, 0.003105f, 0.001231f, 0.077008f, + 0.054226f, 0.038407f, 0.026251f, 0.018634f, 0.011568f, 0.008130f, 0.004957f, + 0.003334f, 0.002069f, 0.001304f, 0.079318f, 0.057180f, 0.041268f, 0.028842f, + 0.020033f, 0.014061f, 0.009636f, 0.006411f, 0.004583f, 0.002817f, 0.001770f, + 0.001258f}; // For the bursty mask type: reference level for the maximum average residual // loss expected for each code size up to: // (kMaxMediaPacketsTestf, kMaxMediaPacketsTest). const float kMaxResidualLossBurstyMask[kNumberCodes] = { - 0.033236f, - 0.053344f, - 0.026616f, - 0.064129f, - 0.036589f, - 0.021892f, - 0.071055f, - 0.043890f, - 0.028009f, - 0.018524f, - 0.075968f, - 0.049828f, - 0.033288f, - 0.022791f, - 0.016088f, - 0.079672f, - 0.054586f, - 0.037872f, - 0.026679f, - 0.019326f, - 0.014293f, - 0.082582f, - 0.058719f, - 0.042045f, - 0.030504f, - 0.022391f, - 0.016894f, - 0.012946f, - 0.084935f, - 0.062169f, - 0.045620f, - 0.033713f, - 0.025570f, - 0.019439f, - 0.015121f, - 0.011920f, - 0.086881f, - 0.065267f, - 0.048721f, - 0.037613f, - 0.028278f, - 0.022152f, - 0.017314f, - 0.013791f, - 0.011130f, - 0.088516f, - 0.067911f, - 0.051709f, - 0.040819f, - 0.030777f, - 0.024547f, - 0.019689f, - 0.015877f, - 0.012773f, - 0.010516f, - 0.089909f, - 0.070332f, - 0.054402f, - 0.043210f, - 0.034096f, - 0.026625f, - 0.021823f, - 0.017648f, - 0.014649f, - 0.011982f, - 0.010035f, - 0.091109f, - 0.072428f, - 0.056775f, - 0.045418f, - 0.036679f, - 0.028599f, - 0.023693f, - 0.019966f, - 0.016603f, - 0.013690f, - 0.011359f, - 0.009657f -}; + 0.033236f, 0.053344f, 0.026616f, 0.064129f, 0.036589f, 0.021892f, 0.071055f, + 0.043890f, 0.028009f, 0.018524f, 0.075968f, 0.049828f, 0.033288f, 0.022791f, + 0.016088f, 0.079672f, 0.054586f, 0.037872f, 0.026679f, 0.019326f, 0.014293f, + 0.082582f, 0.058719f, 0.042045f, 0.030504f, 0.022391f, 0.016894f, 0.012946f, + 0.084935f, 0.062169f, 0.045620f, 0.033713f, 0.025570f, 0.019439f, 0.015121f, + 0.011920f, 0.086881f, 0.065267f, 0.048721f, 0.037613f, 0.028278f, 0.022152f, + 0.017314f, 0.013791f, 0.011130f, 0.088516f, 0.067911f, 0.051709f, 0.040819f, + 0.030777f, 0.024547f, 0.019689f, 0.015877f, 0.012773f, 0.010516f, 0.089909f, + 0.070332f, 0.054402f, 0.043210f, 0.034096f, 0.026625f, 0.021823f, 0.017648f, + 0.014649f, 0.011982f, 0.010035f, 0.091109f, 0.072428f, 0.056775f, 0.045418f, + 0.036679f, 0.028599f, 0.023693f, 0.019966f, 0.016603f, 0.013690f, 0.011359f, + 0.009657f}; } // namespace webrtc #endif // MODULES_RTP_RTCP_TEST_TESTFEC_AVERAGE_RESIDUAL_LOSS_XOR_CODES_H_ diff --git a/modules/rtp_rtcp/test/testFec/test_fec.cc b/modules/rtp_rtcp/test/testFec/test_fec.cc index fd50b46773..7c65d3dca8 100644 --- a/modules/rtp_rtcp/test/testFec/test_fec.cc +++ b/modules/rtp_rtcp/test/testFec/test_fec.cc @@ -252,8 +252,8 @@ void RunTest(bool use_flexfec) { const uint32_t kMinPacketSize = 12; const uint32_t kMaxPacketSize = static_cast( IP_PACKET_SIZE - 12 - 28 - fec->MaxPacketOverhead()); - media_packet->length = random.Rand(kMinPacketSize, - kMaxPacketSize); + media_packet->length = + random.Rand(kMinPacketSize, kMaxPacketSize); // Generate random values for the first 2 bytes. media_packet->data[0] = random.Rand(); @@ -456,8 +456,8 @@ void RunTest(bool use_flexfec) { } // loop over num_imp_packets } // loop over FecPackets } // loop over num_media_packets - } // loop over loss rates - } // loop over mask types + } // loop over loss rates + } // loop over mask types // Have DecodeFec clear the recovered packet list. fec->ResetState(&recovered_packet_list); diff --git a/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc b/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc index 292e9fe566..f6d2dea242 100644 --- a/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc +++ b/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc @@ -41,7 +41,7 @@ * (1) Random loss: Bernoulli process, characterized by the average loss rate. * (2) Bursty loss: Markov chain (Gilbert-Elliot model), characterized by two * parameters: average loss rate and average burst length. -*/ + */ #include @@ -71,9 +71,9 @@ const int kNumStatesDistribution = 2 * kMaxMediaPacketsTest * kMaxGapSize + 1; // The code type. enum CodeType { - xor_random_code, // XOR with random mask type. - xor_bursty_code, // XOR with bursty mask type. - rs_code // Reed_solomon. + xor_random_code, // XOR with random mask type. + xor_bursty_code, // XOR with bursty mask type. + rs_code // Reed_solomon. }; // The code size parameters. @@ -89,10 +89,7 @@ struct CodeSizeParams { }; // The type of loss models. -enum LossModelType { - kRandomLossModel, - kBurstyLossModel -}; +enum LossModelType { kRandomLossModel, kBurstyLossModel }; struct LossModel { LossModelType loss_type; @@ -101,19 +98,19 @@ struct LossModel { }; // Average loss rates. -const float kAverageLossRate[] = { 0.025f, 0.05f, 0.1f, 0.25f }; +const float kAverageLossRate[] = {0.025f, 0.05f, 0.1f, 0.25f}; // Average burst lengths. The case of |kAverageBurstLength = 1.0| refers to // the random model. Note that for the random (Bernoulli) model, the average // burst length is determined by the average loss rate, i.e., // AverageBurstLength = 1 / (1 - AverageLossRate) for random model. -const float kAverageBurstLength[] = { 1.0f, 2.0f, 4.0f }; +const float kAverageBurstLength[] = {1.0f, 2.0f, 4.0f}; // Total number of loss models: For each burst length case, there are // a number of models corresponding to the loss rates. -const int kNumLossModels = (sizeof(kAverageBurstLength) / - sizeof(*kAverageBurstLength)) * (sizeof(kAverageLossRate) / - sizeof(*kAverageLossRate)); +const int kNumLossModels = + (sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength)) * + (sizeof(kAverageLossRate) / sizeof(*kAverageLossRate)); // Thresholds on the average loss rate of the packet loss model, below which // certain properties of the codes are expected. @@ -123,8 +120,8 @@ float loss_rate_lower_threshold = 0.025f; // Set of thresholds on the expected average recovery rate, for each code type. // These are global thresholds for now; in future version we may condition them // on the code length/size and protection level. -const float kRecoveryRateXorRandom[3] = { 0.94f, 0.50f, 0.19f }; -const float kRecoveryRateXorBursty[3] = { 0.90f, 0.54f, 0.22f }; +const float kRecoveryRateXorRandom[3] = {0.94f, 0.50f, 0.19f}; +const float kRecoveryRateXorBursty[3] = {0.90f, 0.54f, 0.22f}; // Metrics for a given FEC code; each code is defined by the code type // (RS, XOR-random/bursty), and the code size parameters (k,m), where @@ -150,7 +147,7 @@ MetricsFecCode kMetricsReedSolomon[kNumberCodes]; class FecPacketMaskMetricsTest : public ::testing::Test { protected: - FecPacketMaskMetricsTest() { } + FecPacketMaskMetricsTest() {} int max_num_codes_; LossModel loss_model_[kNumLossModels]; @@ -251,10 +248,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test { int tot_num_packets) { // Loop over the loss models. for (int k = 0; k < kNumLossModels; k++) { - double loss_rate = static_cast( - loss_model_[k].average_loss_rate); - double burst_length = static_cast( - loss_model_[k].average_burst_length); + double loss_rate = static_cast(loss_model_[k].average_loss_rate); + double burst_length = + static_cast(loss_model_[k].average_burst_length); double result = 1.0; if (loss_model_[k].loss_type == kRandomLossModel) { for (int i = 0; i < tot_num_packets; i++) { @@ -279,7 +275,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test { // Use stationary probability for first state/packet. if (state[0] == 0) { // Received result = (1.0 - loss_rate); - } else { // Lost + } else { // Lost result = loss_rate; } @@ -287,13 +283,13 @@ class FecPacketMaskMetricsTest : public ::testing::Test { for (int i = 1; i < tot_num_packets; i++) { // Current state is received if (state[i] == 0) { - if (state[i-1] == 0) { - result *= prob00; // Previous received, current received. - } else { - result *= prob10; // Previous lost, current received. - } + if (state[i - 1] == 0) { + result *= prob00; // Previous received, current received. + } else { + result *= prob10; // Previous lost, current received. + } } else { // Current state is lost - if (state[i-1] == 0) { + if (state[i - 1] == 0) { result *= prob01; // Previous received, current lost. } else { result *= prob11; // Previous lost, current lost. @@ -333,13 +329,12 @@ class FecPacketMaskMetricsTest : public ::testing::Test { for (int loss = 1; loss <= num_fec_packets; loss++) { int index = gap_number * (2 * kMaxMediaPacketsTest) + loss; residual_loss_gap += metrics.residual_loss_per_loss_gap[index]; - tot_num_configs += - code_params_[code_index].configuration_density[index]; + tot_num_configs += code_params_[code_index].configuration_density[index]; } // Normalize, to compare across code sizes. if (tot_num_configs > 0) { - residual_loss_gap = residual_loss_gap / - static_cast(tot_num_configs); + residual_loss_gap = + residual_loss_gap / static_cast(tot_num_configs); } return residual_loss_gap; } @@ -354,7 +349,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test { metrics->recovery_rate_per_loss[loss] = 0.0; int tot_num_configs = 0; double arl = 0.0; - for (int gap = 0; gap < kMaxGapSize; gap ++) { + for (int gap = 0; gap < kMaxGapSize; gap++) { int index = gap * (2 * kMaxMediaPacketsTest) + loss; arl += metrics->residual_loss_per_loss_gap[index]; tot_num_configs += @@ -366,7 +361,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } // Recovery rate for a given loss |loss| is 1 minus the scaled |arl|, // where the scale factor is relative to code size/parameters. - double scaled_loss = static_cast(loss * num_media_packets) / + double scaled_loss = + static_cast(loss * num_media_packets) / static_cast(num_media_packets + num_fec_packets); metrics->recovery_rate_per_loss[loss] = 1.0 - arl / scaled_loss; } @@ -384,10 +380,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test { // Compute the metrics for an FEC code, given by the code type |code_type| // (XOR-random/ bursty or RS), and by the code index |code_index| // (which containes the code size parameters/protection length). - void ComputeMetricsForCode(CodeType code_type, - int code_index) { + void ComputeMetricsForCode(CodeType code_type, int code_index) { std::unique_ptr prob_weight(new double[kNumLossModels]); - memset(prob_weight.get() , 0, sizeof(double) * kNumLossModels); + memset(prob_weight.get(), 0, sizeof(double) * kNumLossModels); MetricsFecCode metrics_code; SetMetricsZero(&metrics_code); @@ -395,7 +390,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test { int num_fec_packets = code_params_[code_index].num_fec_packets; int tot_num_packets = num_media_packets + num_fec_packets; std::unique_ptr state(new uint8_t[tot_num_packets]); - memset(state.get() , 0, tot_num_packets); + memset(state.get(), 0, tot_num_packets); int num_loss_configurations = static_cast(pow(2.0f, tot_num_packets)); // Loop over all loss configurations for the symbol sequence of length @@ -426,9 +421,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test { if (bit_value == 1) { state[j] = 1; // Lost state. num_packets_lost++; - if (j < num_media_packets) { - num_media_packets_lost++; - } + if (j < num_media_packets) { + num_media_packets_lost++; + } } } // Done with loop over total number of packets. assert(num_media_packets_lost <= num_media_packets); @@ -440,9 +435,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test { // Compute the number of recovered packets. int num_recovered_packets = 0; if (code_type == xor_random_code || code_type == xor_bursty_code) { - num_recovered_packets = RecoveredMediaPackets(num_media_packets, - num_fec_packets, - state.get()); + num_recovered_packets = RecoveredMediaPackets( + num_media_packets, num_fec_packets, state.get()); } else { // For the RS code, we can either completely recover all the packets // if the loss is less than or equal to the number of FEC packets, @@ -455,18 +449,17 @@ class FecPacketMaskMetricsTest : public ::testing::Test { assert(num_recovered_packets <= num_media_packets); // Compute the residual loss. We only care about recovering media/source // packets, so residual loss is based on lost/recovered media packets. - residual_loss = static_cast(num_media_packets_lost - - num_recovered_packets); + residual_loss = + static_cast(num_media_packets_lost - num_recovered_packets); // Compute the probability weights for this configuration. - ComputeProbabilityWeight(prob_weight.get(), - state.get(), + ComputeProbabilityWeight(prob_weight.get(), state.get(), tot_num_packets); // Update the average and variance of the residual loss. for (int k = 0; k < kNumLossModels; k++) { - metrics_code.average_residual_loss[k] += residual_loss * - prob_weight[k]; - metrics_code.variance_residual_loss[k] += residual_loss * + metrics_code.average_residual_loss[k] += residual_loss * prob_weight[k]; + metrics_code.variance_residual_loss[k] += + residual_loss * residual_loss * prob_weight[k]; } } // Done with processing for num_media_packets_lost >= 1. // Update the distribution statistics. @@ -494,12 +487,12 @@ class FecPacketMaskMetricsTest : public ::testing::Test { metrics_code.average_residual_loss[k] / static_cast(tot_num_packets); metrics_code.variance_residual_loss[k] = - metrics_code.variance_residual_loss[k] / - static_cast(num_media_packets * num_media_packets); + metrics_code.variance_residual_loss[k] / + static_cast(num_media_packets * num_media_packets); metrics_code.variance_residual_loss[k] = metrics_code.variance_residual_loss[k] - (metrics_code.average_residual_loss[k] * - metrics_code.average_residual_loss[k]); + metrics_code.average_residual_loss[k]); assert(metrics_code.variance_residual_loss[k] >= 0.0); assert(metrics_code.average_residual_loss[k] > 0.0); metrics_code.variance_residual_loss[k] = @@ -508,10 +501,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } // Compute marginal distribution as a function of loss parameter. - ComputeRecoveryRatePerLoss(&metrics_code, - num_media_packets, - num_fec_packets, - code_index); + ComputeRecoveryRatePerLoss(&metrics_code, num_media_packets, + num_fec_packets, code_index); if (code_type == rs_code) { CopyMetrics(&kMetricsReedSolomon[code_index], metrics_code); } else if (code_type == xor_random_code) { @@ -523,24 +514,25 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } } - void WriteOutMetricsAllFecCodes() { + void WriteOutMetricsAllFecCodes() { std::string filename = test::OutputPath() + "data_metrics_all_codes"; FILE* fp = fopen(filename.c_str(), "wb"); // Loop through codes up to |kMaxMediaPacketsTest|. int code_index = 0; for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; - num_media_packets++) { + num_media_packets++) { for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; - num_fec_packets++) { + num_fec_packets++) { fprintf(fp, "FOR CODE: (%d, %d) \n", num_media_packets, num_fec_packets); for (int k = 0; k < kNumLossModels; k++) { float loss_rate = loss_model_[k].average_loss_rate; float burst_length = loss_model_[k].average_burst_length; - fprintf(fp, "Loss rate = %.2f, Burst length = %.2f: %.4f %.4f %.4f" + fprintf( + fp, + "Loss rate = %.2f, Burst length = %.2f: %.4f %.4f %.4f" " **** %.4f %.4f %.4f \n", - loss_rate, - burst_length, + loss_rate, burst_length, 100 * kMetricsReedSolomon[code_index].average_residual_loss[k], 100 * kMetricsXorRandom[code_index].average_residual_loss[k], 100 * kMetricsXorBursty[code_index].average_residual_loss[k], @@ -548,40 +540,27 @@ class FecPacketMaskMetricsTest : public ::testing::Test { kMetricsXorRandom[code_index].variance_residual_loss[k], kMetricsXorBursty[code_index].variance_residual_loss[k]); } - for (int gap = 0; gap < kGapSizeOutput; gap ++) { - double rs_residual_loss = ComputeResidualLossPerGap( - kMetricsReedSolomon[code_index], - gap, - num_fec_packets, - code_index); + for (int gap = 0; gap < kGapSizeOutput; gap++) { + double rs_residual_loss = + ComputeResidualLossPerGap(kMetricsReedSolomon[code_index], gap, + num_fec_packets, code_index); double xor_random_residual_loss = ComputeResidualLossPerGap( - kMetricsXorRandom[code_index], - gap, - num_fec_packets, - code_index); + kMetricsXorRandom[code_index], gap, num_fec_packets, code_index); double xor_bursty_residual_loss = ComputeResidualLossPerGap( - kMetricsXorBursty[code_index], - gap, - num_fec_packets, - code_index); - fprintf(fp, "Residual loss as a function of gap " - "%d: %.4f %.4f %.4f \n", - gap, - rs_residual_loss, - xor_random_residual_loss, - xor_bursty_residual_loss); + kMetricsXorBursty[code_index], gap, num_fec_packets, code_index); + fprintf(fp, + "Residual loss as a function of gap " + "%d: %.4f %.4f %.4f \n", + gap, rs_residual_loss, xor_random_residual_loss, + xor_bursty_residual_loss); } fprintf(fp, "Recovery rate as a function of loss number \n"); for (int loss = 1; loss <= num_media_packets + num_fec_packets; - loss ++) { - fprintf(fp, "For loss number %d: %.4f %.4f %.4f \n", - loss, - kMetricsReedSolomon[code_index]. - recovery_rate_per_loss[loss], - kMetricsXorRandom[code_index]. - recovery_rate_per_loss[loss], - kMetricsXorBursty[code_index]. - recovery_rate_per_loss[loss]); + loss++) { + fprintf(fp, "For loss number %d: %.4f %.4f %.4f \n", loss, + kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss], + kMetricsXorRandom[code_index].recovery_rate_per_loss[loss], + kMetricsXorBursty[code_index].recovery_rate_per_loss[loss]); } fprintf(fp, "******************\n"); fprintf(fp, "\n"); @@ -592,10 +571,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } void SetLossModels() { - int num_loss_rates = sizeof(kAverageLossRate) / - sizeof(*kAverageLossRate); - int num_burst_lengths = sizeof(kAverageBurstLength) / - sizeof(*kAverageBurstLength); + int num_loss_rates = sizeof(kAverageLossRate) / sizeof(*kAverageLossRate); + int num_burst_lengths = + sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength); int num_loss_models = 0; for (int k = 0; k < num_burst_lengths; k++) { for (int k2 = 0; k2 < num_loss_rates; k2++) { @@ -617,9 +595,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test { void SetCodeParams() { int code_index = 0; for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; - num_media_packets++) { + num_media_packets++) { for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; - num_fec_packets++) { + num_fec_packets++) { code_params_[code_index].num_media_packets = num_media_packets; code_params_[code_index].num_fec_packets = num_fec_packets; code_params_[code_index].protection_level = @@ -646,8 +624,10 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } } if (row_degree == 0) { - printf("Invalid mask: FEC packet has empty mask (does not protect " - "anything) %d %d %d \n", i, num_media_packets, num_fec_packets); + printf( + "Invalid mask: FEC packet has empty mask (does not protect " + "anything) %d %d %d \n", + i, num_media_packets, num_fec_packets); return -1; } } @@ -660,8 +640,10 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } } if (column_degree == 0) { - printf("Invalid mask: Media packet has no protection at all %d %d %d " - "\n", j, num_media_packets, num_fec_packets); + printf( + "Invalid mask: Media packet has no protection at all %d %d %d " + "\n", + j, num_media_packets, num_fec_packets); return -1; } } @@ -696,8 +678,10 @@ class FecPacketMaskMetricsTest : public ::testing::Test { } } if (degree == num_fec_packets) { - printf("Invalid mask: Two media packets are have full degree " - "%d %d %d %d \n", j, j2, num_media_packets, num_fec_packets); + printf( + "Invalid mask: Two media packets are have full degree " + "%d %d %d %d \n", + j, j2, num_media_packets, num_fec_packets); return -1; } } @@ -738,7 +722,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test { static_cast(internal::PacketMaskSize(num_media_packets)); internal::PacketMaskTable mask_table(fec_mask_type, num_media_packets); for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; - num_fec_packets++) { + num_fec_packets++) { memset(packet_mask.get(), 0, num_media_packets * mask_bytes_fec_packet); rtc::ArrayView mask = mask_table.LookUp(num_media_packets, num_fec_packets); @@ -751,8 +735,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test { return -1; } // Compute the metrics for this code/mask. - ComputeMetricsForCode(code_type, - code_index); + ComputeMetricsForCode(code_type, code_index); code_index++; } } @@ -763,12 +746,11 @@ class FecPacketMaskMetricsTest : public ::testing::Test { void ProcessRS(CodeType code_type) { int code_index = 0; for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; - num_media_packets++) { + num_media_packets++) { for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; - num_fec_packets++) { + num_fec_packets++) { // Compute the metrics for this code type. - ComputeMetricsForCode(code_type, - code_index); + ComputeMetricsForCode(code_type, code_index); code_index++; } } @@ -801,10 +783,9 @@ TEST_F(FecPacketMaskMetricsTest, FecXorMaxResidualLoss) { SetCodeParams(); ComputeMetricsAllCodes(); WriteOutMetricsAllFecCodes(); - int num_loss_rates = sizeof(kAverageLossRate) / - sizeof(*kAverageLossRate); - int num_burst_lengths = sizeof(kAverageBurstLength) / - sizeof(*kAverageBurstLength); + int num_loss_rates = sizeof(kAverageLossRate) / sizeof(*kAverageLossRate); + int num_burst_lengths = + sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength); for (int code_index = 0; code_index < max_num_codes_; code_index++) { double sum_residual_loss_random_mask_random_loss = 0.0; double sum_residual_loss_bursty_mask_bursty_loss = 0.0; @@ -822,7 +803,7 @@ TEST_F(FecPacketMaskMetricsTest, FecXorMaxResidualLoss) { sum_residual_loss_random_mask_random_loss / num_loss_rates; float average_residual_loss_bursty_mask_bursty_loss = sum_residual_loss_bursty_mask_bursty_loss / - (num_loss_rates * (num_burst_lengths - 1)); + (num_loss_rates * (num_burst_lengths - 1)); const float ref_random_mask = kMaxResidualLossRandomMask[code_index]; const float ref_bursty_mask = kMaxResidualLossBurstyMask[code_index]; EXPECT_LE(average_residual_loss_random_mask_random_loss, ref_random_mask); @@ -844,16 +825,16 @@ TEST_F(FecPacketMaskMetricsTest, FecXorVsRS) { float loss_rate = loss_model_[k].average_loss_rate; float protection_level = code_params_[code_index].protection_level; // Under these conditions we expect XOR to not be better than RS. - if (loss_model_[k].loss_type == kRandomLossModel && - loss_rate <= protection_level) { + if (loss_model_[k].loss_type == kRandomLossModel && + loss_rate <= protection_level) { EXPECT_GE(kMetricsXorRandom[code_index].average_residual_loss[k], kMetricsReedSolomon[code_index].average_residual_loss[k]); EXPECT_GE(kMetricsXorBursty[code_index].average_residual_loss[k], kMetricsReedSolomon[code_index].average_residual_loss[k]); - } - // TODO(marpan): There are some cases (for high loss rates and/or - // burst loss models) where XOR is better than RS. Is there some pattern - // we can identify and enforce as a constraint? + } + // TODO(marpan): There are some cases (for high loss rates and/or + // burst loss models) where XOR is better than RS. Is there some pattern + // we can identify and enforce as a constraint? } } } @@ -868,25 +849,24 @@ TEST_F(FecPacketMaskMetricsTest, FecTrendXorVsRsLossRate) { // TODO(marpan): Examine this further to see if the condition can be strictly // satisfied (i.e., scale = 1.0) for all codes with different/better masks. double scale = 0.90; - int num_loss_rates = sizeof(kAverageLossRate) / - sizeof(*kAverageLossRate); - int num_burst_lengths = sizeof(kAverageBurstLength) / - sizeof(*kAverageBurstLength); + int num_loss_rates = sizeof(kAverageLossRate) / sizeof(*kAverageLossRate); + int num_burst_lengths = + sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength); for (int code_index = 0; code_index < max_num_codes_; code_index++) { for (int i = 0; i < num_burst_lengths; i++) { for (int j = 0; j < num_loss_rates - 1; j++) { int k = num_loss_rates * i + j; // For XOR random. if (kMetricsXorRandom[code_index].average_residual_loss[k] > - kMetricsReedSolomon[code_index].average_residual_loss[k]) { + kMetricsReedSolomon[code_index].average_residual_loss[k]) { double diff_rs_xor_random_loss1 = (kMetricsXorRandom[code_index].average_residual_loss[k] - kMetricsReedSolomon[code_index].average_residual_loss[k]) / - kMetricsXorRandom[code_index].average_residual_loss[k]; + kMetricsXorRandom[code_index].average_residual_loss[k]; double diff_rs_xor_random_loss2 = - (kMetricsXorRandom[code_index].average_residual_loss[k+1] - - kMetricsReedSolomon[code_index].average_residual_loss[k+1]) / - kMetricsXorRandom[code_index].average_residual_loss[k+1]; + (kMetricsXorRandom[code_index].average_residual_loss[k + 1] - + kMetricsReedSolomon[code_index].average_residual_loss[k + 1]) / + kMetricsXorRandom[code_index].average_residual_loss[k + 1]; EXPECT_GE(diff_rs_xor_random_loss1, scale * diff_rs_xor_random_loss2); } // TODO(marpan): Investigate the cases for the bursty mask where @@ -909,11 +889,11 @@ TEST_F(FecPacketMaskMetricsTest, FecBehaviorViaProtectionLevelAndLength) { for (int code_index1 = 0; code_index1 < max_num_codes_; code_index1++) { float protection_level1 = code_params_[code_index1].protection_level; int length1 = code_params_[code_index1].num_media_packets + - code_params_[code_index1].num_fec_packets; + code_params_[code_index1].num_fec_packets; for (int code_index2 = 0; code_index2 < max_num_codes_; code_index2++) { float protection_level2 = code_params_[code_index2].protection_level; int length2 = code_params_[code_index2].num_media_packets + - code_params_[code_index2].num_fec_packets; + code_params_[code_index2].num_fec_packets; // Codes with higher protection are more efficient, conditioned on the // length of the code (higher protection but shorter length codes are // generally not more efficient). For two codes with equal protection, @@ -959,11 +939,9 @@ TEST_F(FecPacketMaskMetricsTest, FecVarianceBehaviorXorVsRs) { double scale = 0.95; for (int code_index = 0; code_index < max_num_codes_; code_index++) { for (int k = 0; k < kNumLossModels; k++) { - EXPECT_LE(scale * - kMetricsXorRandom[code_index].variance_residual_loss[k], + EXPECT_LE(scale * kMetricsXorRandom[code_index].variance_residual_loss[k], kMetricsReedSolomon[code_index].variance_residual_loss[k]); - EXPECT_LE(scale * - kMetricsXorBursty[code_index].variance_residual_loss[k], + EXPECT_LE(scale * kMetricsXorBursty[code_index].variance_residual_loss[k], kMetricsReedSolomon[code_index].variance_residual_loss[k]); } } @@ -979,8 +957,8 @@ TEST_F(FecPacketMaskMetricsTest, FecXorBurstyPerfectRecoveryConsecutiveLoss) { int num_fec_packets = code_params_[code_index].num_fec_packets; for (int loss = 1; loss <= num_fec_packets; loss++) { int index = loss; // |gap| is zero. - EXPECT_EQ(kMetricsXorBursty[code_index]. - residual_loss_per_loss_gap[index], 0.0); + EXPECT_EQ(kMetricsXorBursty[code_index].residual_loss_per_loss_gap[index], + 0.0); } } } @@ -1036,42 +1014,46 @@ TEST_F(FecPacketMaskMetricsTest, FecRecoveryRateUnderLossConditions) { // Perfect recovery (|recovery_rate_per_loss| == 1) is expected for // |loss_number| = 1, for all codes. int loss_number = 1; - EXPECT_EQ(kMetricsReedSolomon[code_index]. - recovery_rate_per_loss[loss_number], 1.0); - EXPECT_EQ(kMetricsXorRandom[code_index]. - recovery_rate_per_loss[loss_number], 1.0); - EXPECT_EQ(kMetricsXorBursty[code_index]. - recovery_rate_per_loss[loss_number], 1.0); + EXPECT_EQ( + kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number], + 1.0); + EXPECT_EQ(kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number], + 1.0); + EXPECT_EQ(kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number], + 1.0); // For |loss_number| = |num_fec_packets| / 2, we expect the following: // Perfect recovery for RS, and recovery for XOR above the threshold. loss_number = num_fec_packets / 2 > 0 ? num_fec_packets / 2 : 1; - EXPECT_EQ(kMetricsReedSolomon[code_index]. - recovery_rate_per_loss[loss_number], 1.0); - EXPECT_GE(kMetricsXorRandom[code_index]. - recovery_rate_per_loss[loss_number], kRecoveryRateXorRandom[0]); - EXPECT_GE(kMetricsXorBursty[code_index]. - recovery_rate_per_loss[loss_number], kRecoveryRateXorBursty[0]); + EXPECT_EQ( + kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number], + 1.0); + EXPECT_GE(kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number], + kRecoveryRateXorRandom[0]); + EXPECT_GE(kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number], + kRecoveryRateXorBursty[0]); // For |loss_number| = |num_fec_packets|, we expect the following: // Perfect recovery for RS, and recovery for XOR above the threshold. loss_number = num_fec_packets; - EXPECT_EQ(kMetricsReedSolomon[code_index]. - recovery_rate_per_loss[loss_number], 1.0); - EXPECT_GE(kMetricsXorRandom[code_index]. - recovery_rate_per_loss[loss_number], kRecoveryRateXorRandom[1]); - EXPECT_GE(kMetricsXorBursty[code_index]. - recovery_rate_per_loss[loss_number], kRecoveryRateXorBursty[1]); + EXPECT_EQ( + kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number], + 1.0); + EXPECT_GE(kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number], + kRecoveryRateXorRandom[1]); + EXPECT_GE(kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number], + kRecoveryRateXorBursty[1]); // For |loss_number| = |num_fec_packets| + 1, we expect the following: // Zero recovery for RS, but non-zero recovery for XOR. if (num_fec_packets > 1 && num_media_packets > 2) { - loss_number = num_fec_packets + 1; - EXPECT_EQ(kMetricsReedSolomon[code_index]. - recovery_rate_per_loss[loss_number], 0.0); - EXPECT_GE(kMetricsXorRandom[code_index]. - recovery_rate_per_loss[loss_number], - kRecoveryRateXorRandom[2]); - EXPECT_GE(kMetricsXorBursty[code_index]. - recovery_rate_per_loss[loss_number], - kRecoveryRateXorBursty[2]); + loss_number = num_fec_packets + 1; + EXPECT_EQ( + kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number], + 0.0); + EXPECT_GE( + kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number], + kRecoveryRateXorRandom[2]); + EXPECT_GE( + kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number], + kRecoveryRateXorBursty[2]); } } } diff --git a/modules/utility/include/helpers_android.h b/modules/utility/include/helpers_android.h index 808b347ee7..b7bb0b2fa8 100644 --- a/modules/utility/include/helpers_android.h +++ b/modules/utility/include/helpers_android.h @@ -42,11 +42,15 @@ jlong PointerTojlong(void* ptr); // JNIEnv-helper methods that wraps the API which uses the JNI interface // pointer (JNIEnv*). It allows us to RTC_CHECK success and that no Java // exception is thrown while calling the method. -jmethodID GetMethodID( - JNIEnv* jni, jclass c, const char* name, const char* signature); +jmethodID GetMethodID(JNIEnv* jni, + jclass c, + const char* name, + const char* signature); -jmethodID GetStaticMethodID( - JNIEnv* jni, jclass c, const char* name, const char* signature); +jmethodID GetStaticMethodID(JNIEnv* jni, + jclass c, + const char* name, + const char* signature); jclass FindClass(JNIEnv* jni, const char* name); diff --git a/modules/utility/include/jvm_android.h b/modules/utility/include/jvm_android.h index f899263f76..eb18cc27f3 100644 --- a/modules/utility/include/jvm_android.h +++ b/modules/utility/include/jvm_android.h @@ -78,8 +78,9 @@ class NativeRegistration : public JavaClass { NativeRegistration(JNIEnv* jni, jclass clazz); ~NativeRegistration(); - std::unique_ptr NewObject( - const char* name, const char* signature, ...); + std::unique_ptr NewObject(const char* name, + const char* signature, + ...); private: JNIEnv* const jni_; @@ -99,7 +100,9 @@ class JNIEnvironment { // |loaded_classes| array defined in jvm_android.cc. // This method must be called on the construction thread. std::unique_ptr RegisterNatives( - const char* name, const JNINativeMethod *methods, int num_methods); + const char* name, + const JNINativeMethod* methods, + int num_methods); // Converts from Java string to std::string. // This method must be called on the construction thread. diff --git a/modules/utility/include/process_thread.h b/modules/utility/include/process_thread.h index 28e1191085..4ab40b219a 100644 --- a/modules/utility/include/process_thread.h +++ b/modules/utility/include/process_thread.h @@ -74,4 +74,4 @@ class ProcessThread { } // namespace webrtc -#endif // MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ +#endif // MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ diff --git a/modules/utility/source/helpers_android.cc b/modules/utility/source/helpers_android.cc index 5e760b4c03..0206d15274 100644 --- a/modules/utility/source/helpers_android.cc +++ b/modules/utility/source/helpers_android.cc @@ -47,8 +47,10 @@ jlong PointerTojlong(void* ptr) { return ret; } -jmethodID GetMethodID ( - JNIEnv* jni, jclass c, const char* name, const char* signature) { +jmethodID GetMethodID(JNIEnv* jni, + jclass c, + const char* name, + const char* signature) { jmethodID m = jni->GetMethodID(c, name, signature); CHECK_EXCEPTION(jni) << "Error during GetMethodID: " << name << ", " << signature; @@ -56,8 +58,10 @@ jmethodID GetMethodID ( return m; } -jmethodID GetStaticMethodID ( - JNIEnv* jni, jclass c, const char* name, const char* signature) { +jmethodID GetStaticMethodID(JNIEnv* jni, + jclass c, + const char* name, + const char* signature) { jmethodID m = jni->GetStaticMethodID(c, name, signature); CHECK_EXCEPTION(jni) << "Error during GetStaticMethodID: " << name << ", " << signature; @@ -107,6 +111,8 @@ AttachThreadScoped::~AttachThreadScoped() { } } -JNIEnv* AttachThreadScoped::env() { return env_; } +JNIEnv* AttachThreadScoped::env() { + return env_; +} } // namespace webrtc diff --git a/modules/utility/source/jvm_android.cc b/modules/utility/source/jvm_android.cc index d43ec65958..2d48c2d7be 100644 --- a/modules/utility/source/jvm_android.cc +++ b/modules/utility/source/jvm_android.cc @@ -27,10 +27,10 @@ struct { const char* name; jclass clazz; } loaded_classes[] = { - {"org/webrtc/voiceengine/BuildInfo", nullptr}, - {"org/webrtc/voiceengine/WebRtcAudioManager", nullptr}, - {"org/webrtc/voiceengine/WebRtcAudioRecord", nullptr}, - {"org/webrtc/voiceengine/WebRtcAudioTrack", nullptr}, + {"org/webrtc/voiceengine/BuildInfo", nullptr}, + {"org/webrtc/voiceengine/WebRtcAudioManager", nullptr}, + {"org/webrtc/voiceengine/WebRtcAudioRecord", nullptr}, + {"org/webrtc/voiceengine/WebRtcAudioTrack", nullptr}, }; // Android's FindClass() is trickier than usual because the app-specific @@ -68,8 +68,7 @@ jclass LookUpClass(const char* name) { } // AttachCurrentThreadIfNeeded implementation. -AttachCurrentThreadIfNeeded::AttachCurrentThreadIfNeeded() - : attached_(false) { +AttachCurrentThreadIfNeeded::AttachCurrentThreadIfNeeded() : attached_(false) { RTC_LOG(INFO) << "AttachCurrentThreadIfNeeded::ctor"; JavaVM* jvm = JVM::GetInstance()->jvm(); RTC_CHECK(jvm); @@ -141,27 +140,26 @@ NativeRegistration::~NativeRegistration() { CHECK_EXCEPTION(jni_) << "Error during UnregisterNatives"; } -std::unique_ptr NativeRegistration::NewObject( - const char* name, const char* signature, ...) { +std::unique_ptr NativeRegistration::NewObject(const char* name, + const char* signature, + ...) { RTC_LOG(INFO) << "NativeRegistration::NewObject"; va_list args; va_start(args, signature); - jobject obj = jni_->NewObjectV(j_class_, - GetMethodID(jni_, j_class_, name, signature), - args); + jobject obj = jni_->NewObjectV( + j_class_, GetMethodID(jni_, j_class_, name, signature), args); CHECK_EXCEPTION(jni_) << "Error during NewObjectV"; va_end(args); return std::unique_ptr(new GlobalRef(jni_, obj)); } // JavaClass implementation. -jmethodID JavaClass::GetMethodId( - const char* name, const char* signature) { +jmethodID JavaClass::GetMethodId(const char* name, const char* signature) { return GetMethodID(jni_, j_class_, name, signature); } -jmethodID JavaClass::GetStaticMethodId( - const char* name, const char* signature) { +jmethodID JavaClass::GetStaticMethodId(const char* name, + const char* signature) { return GetStaticMethodID(jni_, j_class_, name, signature); } @@ -192,7 +190,9 @@ JNIEnvironment::~JNIEnvironment() { } std::unique_ptr JNIEnvironment::RegisterNatives( - const char* name, const JNINativeMethod *methods, int num_methods) { + const char* name, + const JNINativeMethod* methods, + int num_methods) { RTC_LOG(INFO) << "JNIEnvironment::RegisterNatives: " << name; RTC_DCHECK(thread_checker_.CalledOnValidThread()); jclass clazz = LookUpClass(name); diff --git a/modules/utility/source/process_thread_impl.cc b/modules/utility/source/process_thread_impl.cc index 014624e48c..97272da2bf 100644 --- a/modules/utility/source/process_thread_impl.cc +++ b/modules/utility/source/process_thread_impl.cc @@ -32,13 +32,12 @@ int64_t GetNextCallbackTime(Module* module, int64_t time_now) { } return time_now + interval; } -} +} // namespace ProcessThread::~ProcessThread() {} // static -std::unique_ptr ProcessThread::Create( - const char* thread_name) { +std::unique_ptr ProcessThread::Create(const char* thread_name) { return std::unique_ptr(new ProcessThreadImpl(thread_name)); } @@ -76,7 +75,7 @@ void ProcessThreadImpl::Start() { void ProcessThreadImpl::Stop() { RTC_DCHECK(thread_checker_.CalledOnValidThread()); - if(!thread_.get()) + if (!thread_.get()) return; { @@ -155,9 +154,8 @@ void ProcessThreadImpl::DeRegisterModule(Module* module) { { rtc::CritScope lock(&lock_); - modules_.remove_if([&module](const ModuleCallback& m) { - return m.module == module; - }); + modules_.remove_if( + [&module](const ModuleCallback& m) { return m.module == module; }); } // Notify the module that it's been detached. diff --git a/modules/utility/source/process_thread_impl.h b/modules/utility/source/process_thread_impl.h index 9856fba576..fcc668f3cd 100644 --- a/modules/utility/source/process_thread_impl.h +++ b/modules/utility/source/process_thread_impl.h @@ -85,4 +85,4 @@ class ProcessThreadImpl : public ProcessThread { } // namespace webrtc -#endif // MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_ +#endif // MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_ diff --git a/modules/utility/source/process_thread_impl_unittest.cc b/modules/utility/source/process_thread_impl_unittest.cc index d27896410e..d5926b26c3 100644 --- a/modules/utility/source/process_thread_impl_unittest.cc +++ b/modules/utility/source/process_thread_impl_unittest.cc @@ -137,9 +137,8 @@ TEST(ProcessThreadImpl, Deregister) { .WillOnce(Return(0)) .WillRepeatedly(Return(1)); EXPECT_CALL(module, Process()) - .WillOnce(DoAll(SetEvent(event.get()), - Increment(&process_count), - Return())) + .WillOnce( + DoAll(SetEvent(event.get()), Increment(&process_count), Return())) .WillRepeatedly(DoAll(Increment(&process_count), Return())); thread.RegisterModule(&module, RTC_FROM_HERE); @@ -174,13 +173,11 @@ void ProcessCallAfterAFewMs(int64_t milliseconds) { int64_t start_time = 0; int64_t called_time = 0; EXPECT_CALL(module, TimeUntilNextProcess()) - .WillOnce(DoAll(SetTimestamp(&start_time), - Return(milliseconds))) + .WillOnce(DoAll(SetTimestamp(&start_time), Return(milliseconds))) .WillRepeatedly(Return(milliseconds)); EXPECT_CALL(module, Process()) - .WillOnce(DoAll(SetTimestamp(&called_time), - SetEvent(event.get()), - Return())) + .WillOnce( + DoAll(SetTimestamp(&called_time), SetEvent(event.get()), Return())) .WillRepeatedly(Return()); EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1); @@ -238,11 +235,9 @@ TEST(ProcessThreadImpl, DISABLED_Process50Times) { MockModule module; int callback_count = 0; // Ask for a callback after 20ms. - EXPECT_CALL(module, TimeUntilNextProcess()) - .WillRepeatedly(Return(20)); + EXPECT_CALL(module, TimeUntilNextProcess()).WillRepeatedly(Return(20)); EXPECT_CALL(module, Process()) - .WillRepeatedly(DoAll(Increment(&callback_count), - Return())); + .WillRepeatedly(DoAll(Increment(&callback_count), Return())); EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1); thread.RegisterModule(&module, RTC_FROM_HERE); @@ -281,8 +276,7 @@ TEST(ProcessThreadImpl, WakeUp) { // The second time TimeUntilNextProcess is then called, is after Process // has been called and we don't expect any more calls. EXPECT_CALL(module, TimeUntilNextProcess()) - .WillOnce(DoAll(SetTimestamp(&start_time), - SetEvent(started.get()), + .WillOnce(DoAll(SetTimestamp(&start_time), SetEvent(started.get()), Return(1000))) .WillOnce(Return(1000)); EXPECT_CALL(module, Process()) diff --git a/modules/video_capture/device_info_impl.h b/modules/video_capture/device_info_impl.h index 7e23f043fd..f6e197007b 100644 --- a/modules/video_capture/device_info_impl.h +++ b/modules/video_capture/device_info_impl.h @@ -16,45 +16,42 @@ #include "modules/video_capture/video_capture.h" #include "rtc_base/synchronization/rw_lock_wrapper.h" -namespace webrtc -{ -namespace videocapturemodule -{ -class DeviceInfoImpl: public VideoCaptureModule::DeviceInfo -{ -public: - DeviceInfoImpl(); - virtual ~DeviceInfoImpl(void); - virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8); - virtual int32_t GetCapability( - const char* deviceUniqueIdUTF8, - const uint32_t deviceCapabilityNumber, - VideoCaptureCapability& capability); +namespace webrtc { +namespace videocapturemodule { +class DeviceInfoImpl : public VideoCaptureModule::DeviceInfo { + public: + DeviceInfoImpl(); + virtual ~DeviceInfoImpl(void); + virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8); + virtual int32_t GetCapability(const char* deviceUniqueIdUTF8, + const uint32_t deviceCapabilityNumber, + VideoCaptureCapability& capability); - virtual int32_t GetBestMatchedCapability( - const char* deviceUniqueIdUTF8, - const VideoCaptureCapability& requested, - VideoCaptureCapability& resulting); - virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, - VideoRotation& orientation); + virtual int32_t GetBestMatchedCapability( + const char* deviceUniqueIdUTF8, + const VideoCaptureCapability& requested, + VideoCaptureCapability& resulting); + virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, + VideoRotation& orientation); -protected: - /* Initialize this object*/ + protected: + /* Initialize this object*/ - virtual int32_t Init()=0; - /* - * Fills the member variable _captureCapabilities with capabilities for the given device name. - */ - virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8)=0; + virtual int32_t Init() = 0; + /* + * Fills the member variable _captureCapabilities with capabilities for the + * given device name. + */ + virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) = 0; -protected: - // Data members - typedef std::vector VideoCaptureCapabilities; - VideoCaptureCapabilities _captureCapabilities; - RWLockWrapper& _apiLock; - char* _lastUsedDeviceName; - uint32_t _lastUsedDeviceNameLength; + protected: + // Data members + typedef std::vector VideoCaptureCapabilities; + VideoCaptureCapabilities _captureCapabilities; + RWLockWrapper& _apiLock; + char* _lastUsedDeviceName; + uint32_t _lastUsedDeviceNameLength; }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_ diff --git a/modules/video_capture/external/device_info_external.cc b/modules/video_capture/external/device_info_external.cc index 4951dc8927..cd660e2e0b 100644 --- a/modules/video_capture/external/device_info_external.cc +++ b/modules/video_capture/external/device_info_external.cc @@ -25,19 +25,21 @@ class ExternalDeviceInfo : public DeviceInfoImpl { const char* /*dialogTitleUTF8*/, void* /*parentWindow*/, uint32_t /*positionX*/, - uint32_t /*positionY*/) { return -1; } - virtual int32_t GetDeviceName( - uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8=0, - uint32_t productUniqueIdUTF8Length=0) { + uint32_t /*positionY*/) { return -1; } - virtual int32_t CreateCapabilityMap( - const char* deviceUniqueIdUTF8) { return 0; } + virtual int32_t GetDeviceName(uint32_t deviceNumber, + char* deviceNameUTF8, + uint32_t deviceNameLength, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8 = 0, + uint32_t productUniqueIdUTF8Length = 0) { + return -1; + } + virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) { + return 0; + } virtual int32_t Init() { return 0; } }; diff --git a/modules/video_capture/linux/device_info_linux.h b/modules/video_capture/linux/device_info_linux.h index 86eb61efa1..fc7b4d8d03 100644 --- a/modules/video_capture/linux/device_info_linux.h +++ b/modules/video_capture/linux/device_info_linux.h @@ -14,40 +14,39 @@ #include "modules/video_capture/device_info_impl.h" #include "modules/video_capture/video_capture_impl.h" -namespace webrtc -{ -namespace videocapturemodule -{ -class DeviceInfoLinux: public DeviceInfoImpl -{ -public: - DeviceInfoLinux(); - virtual ~DeviceInfoLinux(); - virtual uint32_t NumberOfDevices(); - virtual int32_t GetDeviceName( - uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8=0, - uint32_t productUniqueIdUTF8Length=0); - /* - * Fills the membervariable _captureCapabilities with capabilites for the given device name. - */ - virtual int32_t CreateCapabilityMap (const char* deviceUniqueIdUTF8); - virtual int32_t DisplayCaptureSettingsDialogBox( - const char* /*deviceUniqueIdUTF8*/, - const char* /*dialogTitleUTF8*/, - void* /*parentWindow*/, - uint32_t /*positionX*/, - uint32_t /*positionY*/) { return -1;} - int32_t FillCapabilities(int fd); - int32_t Init(); -private: +namespace webrtc { +namespace videocapturemodule { +class DeviceInfoLinux : public DeviceInfoImpl { + public: + DeviceInfoLinux(); + virtual ~DeviceInfoLinux(); + virtual uint32_t NumberOfDevices(); + virtual int32_t GetDeviceName(uint32_t deviceNumber, + char* deviceNameUTF8, + uint32_t deviceNameLength, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8 = 0, + uint32_t productUniqueIdUTF8Length = 0); + /* + * Fills the membervariable _captureCapabilities with capabilites for the + * given device name. + */ + virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8); + virtual int32_t DisplayCaptureSettingsDialogBox( + const char* /*deviceUniqueIdUTF8*/, + const char* /*dialogTitleUTF8*/, + void* /*parentWindow*/, + uint32_t /*positionX*/, + uint32_t /*positionY*/) { + return -1; + } + int32_t FillCapabilities(int fd); + int32_t Init(); - bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8); + private: + bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8); }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_ diff --git a/modules/video_capture/linux/video_capture_linux.h b/modules/video_capture/linux/video_capture_linux.h index c0649a5170..88455f9b9b 100644 --- a/modules/video_capture/linux/video_capture_linux.h +++ b/modules/video_capture/linux/video_capture_linux.h @@ -18,50 +18,46 @@ #include "rtc_base/criticalsection.h" #include "rtc_base/platform_thread.h" -namespace webrtc -{ -namespace videocapturemodule -{ -class VideoCaptureModuleV4L2: public VideoCaptureImpl -{ -public: - VideoCaptureModuleV4L2(); - virtual ~VideoCaptureModuleV4L2(); - virtual int32_t Init(const char* deviceUniqueId); - virtual int32_t StartCapture(const VideoCaptureCapability& capability); - virtual int32_t StopCapture(); - virtual bool CaptureStarted(); - virtual int32_t CaptureSettings(VideoCaptureCapability& settings); +namespace webrtc { +namespace videocapturemodule { +class VideoCaptureModuleV4L2 : public VideoCaptureImpl { + public: + VideoCaptureModuleV4L2(); + virtual ~VideoCaptureModuleV4L2(); + virtual int32_t Init(const char* deviceUniqueId); + virtual int32_t StartCapture(const VideoCaptureCapability& capability); + virtual int32_t StopCapture(); + virtual bool CaptureStarted(); + virtual int32_t CaptureSettings(VideoCaptureCapability& settings); -private: - enum {kNoOfV4L2Bufffers=4}; + private: + enum { kNoOfV4L2Bufffers = 4 }; - static bool CaptureThread(void*); - bool CaptureProcess(); - bool AllocateVideoBuffers(); - bool DeAllocateVideoBuffers(); + static bool CaptureThread(void*); + bool CaptureProcess(); + bool AllocateVideoBuffers(); + bool DeAllocateVideoBuffers(); - // TODO(pbos): Stop using unique_ptr and resetting the thread. - std::unique_ptr _captureThread; - rtc::CriticalSection _captureCritSect; + // TODO(pbos): Stop using unique_ptr and resetting the thread. + std::unique_ptr _captureThread; + rtc::CriticalSection _captureCritSect; - int32_t _deviceId; - int32_t _deviceFd; + int32_t _deviceId; + int32_t _deviceFd; - int32_t _buffersAllocatedByDevice; - int32_t _currentWidth; - int32_t _currentHeight; - int32_t _currentFrameRate; - bool _captureStarted; - VideoType _captureVideoType; - struct Buffer - { - void *start; - size_t length; - }; - Buffer *_pool; + int32_t _buffersAllocatedByDevice; + int32_t _currentWidth; + int32_t _currentHeight; + int32_t _currentFrameRate; + bool _captureStarted; + VideoType _captureVideoType; + struct Buffer { + void* start; + size_t length; + }; + Buffer* _pool; }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc index 1c6d06480d..aed299c012 100644 --- a/modules/video_capture/test/video_capture_unittest.cc +++ b/modules/video_capture/test/video_capture_unittest.cc @@ -32,25 +32,24 @@ using webrtc::VideoCaptureCapability; using webrtc::VideoCaptureFactory; using webrtc::VideoCaptureModule; - -#define WAIT_(ex, timeout, res) \ - do { \ - res = (ex); \ - int64_t start = rtc::TimeMillis(); \ +#define WAIT_(ex, timeout, res) \ + do { \ + res = (ex); \ + int64_t start = rtc::TimeMillis(); \ while (!res && rtc::TimeMillis() < start + timeout) { \ - SleepMs(5); \ - res = (ex); \ - } \ + SleepMs(5); \ + res = (ex); \ + } \ } while (0) #define EXPECT_TRUE_WAIT(ex, timeout) \ - do { \ - bool res; \ - WAIT_(ex, timeout, res); \ - if (!res) EXPECT_TRUE(ex); \ + do { \ + bool res; \ + WAIT_(ex, timeout, res); \ + if (!res) \ + EXPECT_TRUE(ex); \ } while (0) - static const int kTimeOut = 5000; static const int kTestHeight = 288; static const int kTestWidth = 352; @@ -59,8 +58,8 @@ static const int kTestFramerate = 30; class TestVideoCaptureCallback : public rtc::VideoSinkInterface { public: - TestVideoCaptureCallback() : - last_render_time_ms_(0), + TestVideoCaptureCallback() + : last_render_time_ms_(0), incoming_frames_(0), timing_warnings_(0), rotate_frame_(webrtc::kVideoRotation_0) {} @@ -85,16 +84,15 @@ class TestVideoCaptureCallback EXPECT_EQ(rotate_frame_, videoFrame.rotation()); #endif // RenderTimstamp should be the time now. - EXPECT_TRUE( - videoFrame.render_time_ms() >= rtc::TimeMillis()-30 && - videoFrame.render_time_ms() <= rtc::TimeMillis()); + EXPECT_TRUE(videoFrame.render_time_ms() >= rtc::TimeMillis() - 30 && + videoFrame.render_time_ms() <= rtc::TimeMillis()); if ((videoFrame.render_time_ms() > - last_render_time_ms_ + (1000 * 1.1) / capability_.maxFPS && - last_render_time_ms_ > 0) || + last_render_time_ms_ + (1000 * 1.1) / capability_.maxFPS && + last_render_time_ms_ > 0) || (videoFrame.render_time_ms() < - last_render_time_ms_ + (1000 * 0.9) / capability_.maxFPS && - last_render_time_ms_ > 0)) { + last_render_time_ms_ + (1000 * 0.9) / capability_.maxFPS && + last_render_time_ms_ > 0)) { timing_warnings_++; } @@ -105,7 +103,7 @@ class TestVideoCaptureCallback void SetExpectedCapability(VideoCaptureCapability capability) { rtc::CritScope cs(&capture_cs_); - capability_= capability; + capability_ = capability; incoming_frames_ = 0; last_render_time_ms_ = 0; } @@ -161,8 +159,8 @@ class VideoCaptureTest : public testing::Test { char device_name[256]; char unique_name[256]; - EXPECT_EQ(0, device_info_->GetDeviceName( - device, device_name, 256, unique_name, 256)); + EXPECT_EQ(0, device_info_->GetDeviceName(device, device_name, 256, + unique_name, 256)); rtc::scoped_refptr module( VideoCaptureFactory::Create(unique_name)); @@ -251,8 +249,8 @@ TEST_F(VideoCaptureTest, MAYBE_Capabilities) { OpenVideoCaptureDevice(0, &capture_observer)); ASSERT_TRUE(module.get() != NULL); - int number_of_capabilities = device_info_->NumberOfCapabilities( - module->CurrentDeviceName()); + int number_of_capabilities = + device_info_->NumberOfCapabilities(module->CurrentDeviceName()); EXPECT_GT(number_of_capabilities, 0); // Key is x, value is vector of maxFPS values at that // resolution. @@ -293,8 +291,7 @@ TEST_F(VideoCaptureTest, MAYBE_Capabilities) { EXPECT_GT(frame_rates_by_resolution.size(), 1U); for (FrameRatesByResolution::const_iterator it = frame_rates_by_resolution.begin(); - it != frame_rates_by_resolution.end(); - ++it) { + it != frame_rates_by_resolution.end(); ++it) { EXPECT_GT(it->second.size(), 1U) << it->first; } #endif // WEBRTC_ANDROID @@ -328,7 +325,6 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) { OpenVideoCaptureDevice(1, &capture_observer2)); ASSERT_TRUE(module1.get() != NULL); - VideoCaptureCapability capability2; #ifndef WEBRTC_MAC device_info_->GetCapability(module2->CurrentDeviceName(), 0, capability2); @@ -378,8 +374,7 @@ class VideoCaptureExternalTest : public testing::Test { capture_module_->RegisterCaptureDataCallback(&capture_callback_); } - void TearDown() { - } + void TearDown() {} webrtc::VideoCaptureExternal* capture_input_interface_; rtc::scoped_refptr capture_module_; @@ -393,8 +388,9 @@ TEST_F(VideoCaptureExternalTest, TestExternalCapture) { webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); std::unique_ptr test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_)); } @@ -404,18 +400,22 @@ TEST_F(VideoCaptureExternalTest, Rotation) { webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); std::unique_ptr test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90)); capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), - length, capture_callback_.capability(), 0)); + EXPECT_EQ(0, + capture_input_interface_->IncomingFrame( + test_buffer.get(), length, capture_callback_.capability(), 0)); } diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h index fb3a461e00..0231f28ef7 100644 --- a/modules/video_capture/video_capture.h +++ b/modules/video_capture/video_capture.h @@ -18,7 +18,7 @@ namespace webrtc { -class VideoCaptureModule: public rtc::RefCountInterface { +class VideoCaptureModule : public rtc::RefCountInterface { public: // Interface for receiving information about available camera devices. class DeviceInfo { @@ -32,25 +32,21 @@ class VideoCaptureModule: public rtc::RefCountInterface { // Otherwise same as deviceNameUTF8. // productUniqueIdUTF8 - Unique product id if it exist. // Null terminated otherwise. - virtual int32_t GetDeviceName( - uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8 = 0, - uint32_t productUniqueIdUTF8Length = 0) = 0; - + virtual int32_t GetDeviceName(uint32_t deviceNumber, + char* deviceNameUTF8, + uint32_t deviceNameLength, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8 = 0, + uint32_t productUniqueIdUTF8Length = 0) = 0; // Returns the number of capabilities this device. - virtual int32_t NumberOfCapabilities( - const char* deviceUniqueIdUTF8) = 0; + virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0; // Gets the capabilities of the named device. - virtual int32_t GetCapability( - const char* deviceUniqueIdUTF8, - const uint32_t deviceCapabilityNumber, - VideoCaptureCapability& capability) = 0; + virtual int32_t GetCapability(const char* deviceUniqueIdUTF8, + const uint32_t deviceCapabilityNumber, + VideoCaptureCapability& capability) = 0; // Gets clockwise angle the captured frames should be rotated in order // to be displayed correctly on a normally rotated display. @@ -65,7 +61,7 @@ class VideoCaptureModule: public rtc::RefCountInterface { const VideoCaptureCapability& requested, VideoCaptureCapability& resulting) = 0; - // Display OS /capture device specific settings dialog + // Display OS /capture device specific settings dialog virtual int32_t DisplayCaptureSettingsDialogBox( const char* deviceUniqueIdUTF8, const char* dialogTitleUTF8, @@ -78,14 +74,13 @@ class VideoCaptureModule: public rtc::RefCountInterface { // Register capture data callback virtual void RegisterCaptureDataCallback( - rtc::VideoSinkInterface *dataCallback) = 0; + rtc::VideoSinkInterface* dataCallback) = 0; // Remove capture data callback virtual void DeRegisterCaptureDataCallback() = 0; // Start capture device - virtual int32_t StartCapture( - const VideoCaptureCapability& capability) = 0; + virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0; virtual int32_t StopCapture() = 0; @@ -113,8 +108,8 @@ class VideoCaptureModule: public rtc::RefCountInterface { // Return whether the rotation is applied or left pending. virtual bool GetApplyRotation() = 0; -protected: - virtual ~VideoCaptureModule() {}; + protected: + virtual ~VideoCaptureModule(){}; }; } // namespace webrtc diff --git a/modules/video_capture/video_capture_config.h b/modules/video_capture/video_capture_config.h index 4cfff6ee71..f285b9eeb1 100644 --- a/modules/video_capture/video_capture_config.h +++ b/modules/video_capture/video_capture_config.h @@ -11,23 +11,23 @@ #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_ #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_ -namespace webrtc -{ -namespace videocapturemodule -{ -enum {kDefaultWidth = 640}; // Start width -enum {kDefaultHeight = 480}; // Start heigt -enum {kDefaultFrameRate = 30}; // Start frame rate +namespace webrtc { +namespace videocapturemodule { +enum { kDefaultWidth = 640 }; // Start width +enum { kDefaultHeight = 480 }; // Start heigt +enum { kDefaultFrameRate = 30 }; // Start frame rate -enum {kMaxFrameRate =60}; // Max allowed frame rate of the start image +enum { kMaxFrameRate = 60 }; // Max allowed frame rate of the start image -enum {kDefaultCaptureDelay = 120}; -enum {kMaxCaptureDelay = 270}; // Max capture delay allowed in the precompiled capture delay values. +enum { kDefaultCaptureDelay = 120 }; +enum { + kMaxCaptureDelay = 270 +}; // Max capture delay allowed in the precompiled capture delay values. -enum {kFrameRateCallbackInterval = 1000}; -enum {kFrameRateCountHistorySize = 90}; -enum {kFrameRateHistoryWindowMs = 2000}; +enum { kFrameRateCallbackInterval = 1000 }; +enum { kFrameRateCountHistorySize = 90 }; +enum { kFrameRateHistoryWindowMs = 2000 }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_ diff --git a/modules/video_capture/video_capture_defines.h b/modules/video_capture/video_capture_defines.h index ec5bf24e4c..350025fa7f 100644 --- a/modules/video_capture/video_capture_defines.h +++ b/modules/video_capture/video_capture_defines.h @@ -15,63 +15,59 @@ #include "modules/include/module_common_types.h" #include "typedefs.h" // NOLINT(build/include) -namespace webrtc -{ +namespace webrtc { -enum {kVideoCaptureUniqueNameLength =1024}; //Max unique capture device name lenght -enum {kVideoCaptureDeviceNameLength =256}; //Max capture device name lenght -enum {kVideoCaptureProductIdLength =128}; //Max product id length +enum { + kVideoCaptureUniqueNameLength = 1024 +}; // Max unique capture device name lenght +enum { kVideoCaptureDeviceNameLength = 256 }; // Max capture device name lenght +enum { kVideoCaptureProductIdLength = 128 }; // Max product id length -struct VideoCaptureCapability -{ - int32_t width; - int32_t height; - int32_t maxFPS; - VideoType videoType; - bool interlaced; +struct VideoCaptureCapability { + int32_t width; + int32_t height; + int32_t maxFPS; + VideoType videoType; + bool interlaced; - VideoCaptureCapability() - { - width = 0; - height = 0; - maxFPS = 0; - videoType = VideoType::kUnknown; - interlaced = false; - } - ; - bool operator!=(const VideoCaptureCapability &other) const - { - if (width != other.width) - return true; - if (height != other.height) - return true; - if (maxFPS != other.maxFPS) - return true; - if (videoType != other.videoType) - return true; - if (interlaced != other.interlaced) - return true; - return false; - } - bool operator==(const VideoCaptureCapability &other) const - { - return !operator!=(other); - } + VideoCaptureCapability() { + width = 0; + height = 0; + maxFPS = 0; + videoType = VideoType::kUnknown; + interlaced = false; + }; + bool operator!=(const VideoCaptureCapability& other) const { + if (width != other.width) + return true; + if (height != other.height) + return true; + if (maxFPS != other.maxFPS) + return true; + if (videoType != other.videoType) + return true; + if (interlaced != other.interlaced) + return true; + return false; + } + bool operator==(const VideoCaptureCapability& other) const { + return !operator!=(other); + } }; /* External Capture interface. Returned by Create and implemented by the capture module. */ -class VideoCaptureExternal -{ -public: - // |capture_time| must be specified in the NTP time format in milliseconds. - virtual int32_t IncomingFrame(uint8_t* videoFrame, - size_t videoFrameLength, - const VideoCaptureCapability& frameInfo, - int64_t captureTime = 0) = 0; -protected: - ~VideoCaptureExternal() {} +class VideoCaptureExternal { + public: + // |capture_time| must be specified in the NTP time format in milliseconds. + virtual int32_t IncomingFrame(uint8_t* videoFrame, + size_t videoFrameLength, + const VideoCaptureCapability& frameInfo, + int64_t captureTime = 0) = 0; + + protected: + ~VideoCaptureExternal() {} }; } // namespace webrtc diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h index d252597643..7826427f39 100644 --- a/modules/video_capture/video_capture_impl.h +++ b/modules/video_capture/video_capture_impl.h @@ -22,98 +22,97 @@ #include "rtc_base/criticalsection.h" #include "rtc_base/scoped_ref_ptr.h" -namespace webrtc -{ +namespace webrtc { namespace videocapturemodule { // Class definitions -class VideoCaptureImpl: public VideoCaptureModule, public VideoCaptureExternal -{ -public: +class VideoCaptureImpl : public VideoCaptureModule, + public VideoCaptureExternal { + public: + /* + * Create a video capture module object + * + * id - unique identifier of this video capture module object + * deviceUniqueIdUTF8 - name of the device. Available names can be found by + * using GetDeviceName + */ + static rtc::scoped_refptr Create( + const char* deviceUniqueIdUTF8); - /* - * Create a video capture module object - * - * id - unique identifier of this video capture module object - * deviceUniqueIdUTF8 - name of the device. Available names can be found by using GetDeviceName - */ - static rtc::scoped_refptr Create( - const char* deviceUniqueIdUTF8); + /* + * Create a video capture module object used for external capture. + * + * id - unique identifier of this video capture module object + * externalCapture - [out] interface to call when a new frame is captured. + */ + static rtc::scoped_refptr Create( + VideoCaptureExternal*& externalCapture); - /* - * Create a video capture module object used for external capture. - * - * id - unique identifier of this video capture module object - * externalCapture - [out] interface to call when a new frame is captured. - */ - static rtc::scoped_refptr Create( - VideoCaptureExternal*& externalCapture); + static DeviceInfo* CreateDeviceInfo(); - static DeviceInfo* CreateDeviceInfo(); + // Helpers for converting between (integral) degrees and + // VideoRotation values. Return 0 on success. + static int32_t RotationFromDegrees(int degrees, VideoRotation* rotation); + static int32_t RotationInDegrees(VideoRotation rotation, int* degrees); - // Helpers for converting between (integral) degrees and - // VideoRotation values. Return 0 on success. - static int32_t RotationFromDegrees(int degrees, VideoRotation* rotation); - static int32_t RotationInDegrees(VideoRotation rotation, int* degrees); + // Call backs + void RegisterCaptureDataCallback( + rtc::VideoSinkInterface* dataCallback) override; + void DeRegisterCaptureDataCallback() override; - //Call backs - void RegisterCaptureDataCallback( - rtc::VideoSinkInterface* dataCallback) override; - void DeRegisterCaptureDataCallback() override; + int32_t SetCaptureRotation(VideoRotation rotation) override; + bool SetApplyRotation(bool enable) override; + bool GetApplyRotation() override { return apply_rotation_; } - int32_t SetCaptureRotation(VideoRotation rotation) override; - bool SetApplyRotation(bool enable) override; - bool GetApplyRotation() override { - return apply_rotation_; - } + const char* CurrentDeviceName() const override; - const char* CurrentDeviceName() const override; + // Implement VideoCaptureExternal + // |capture_time| must be specified in NTP time format in milliseconds. + int32_t IncomingFrame(uint8_t* videoFrame, + size_t videoFrameLength, + const VideoCaptureCapability& frameInfo, + int64_t captureTime = 0) override; - // Implement VideoCaptureExternal - // |capture_time| must be specified in NTP time format in milliseconds. - int32_t IncomingFrame(uint8_t* videoFrame, - size_t videoFrameLength, - const VideoCaptureCapability& frameInfo, - int64_t captureTime = 0) override; + // Platform dependent + int32_t StartCapture(const VideoCaptureCapability& capability) override { + _requestedCapability = capability; + return -1; + } + int32_t StopCapture() override { return -1; } + bool CaptureStarted() override { return false; } + int32_t CaptureSettings(VideoCaptureCapability& /*settings*/) override { + return -1; + } - // Platform dependent - int32_t StartCapture(const VideoCaptureCapability& capability) override - { - _requestedCapability = capability; - return -1; - } - int32_t StopCapture() override { return -1; } - bool CaptureStarted() override {return false; } - int32_t CaptureSettings(VideoCaptureCapability& /*settings*/) override - { return -1; } + protected: + VideoCaptureImpl(); + virtual ~VideoCaptureImpl(); + int32_t DeliverCapturedFrame(VideoFrame& captureFrame); -protected: - VideoCaptureImpl(); - virtual ~VideoCaptureImpl(); - int32_t DeliverCapturedFrame(VideoFrame& captureFrame); + char* _deviceUniqueId; // current Device unique name; + rtc::CriticalSection _apiCs; + VideoCaptureCapability _requestedCapability; // Should be set by platform + // dependent code in + // StartCapture. + private: + void UpdateFrameCount(); + uint32_t CalculateFrameRate(int64_t now_ns); - char* _deviceUniqueId; // current Device unique name; - rtc::CriticalSection _apiCs; - VideoCaptureCapability _requestedCapability; // Should be set by platform dependent code in StartCapture. -private: - void UpdateFrameCount(); - uint32_t CalculateFrameRate(int64_t now_ns); + // last time the module process function was called. + int64_t _lastProcessTimeNanos; + // last time the frame rate callback function was called. + int64_t _lastFrameRateCallbackTimeNanos; - // last time the module process function was called. - int64_t _lastProcessTimeNanos; - // last time the frame rate callback function was called. - int64_t _lastFrameRateCallbackTimeNanos; + rtc::VideoSinkInterface* _dataCallBack; - rtc::VideoSinkInterface* _dataCallBack; + int64_t _lastProcessFrameTimeNanos; + // timestamp for local captured frames + int64_t _incomingFrameTimesNanos[kFrameRateCountHistorySize]; + VideoRotation _rotateFrame; // Set if the frame should be rotated by the + // capture module. - int64_t _lastProcessFrameTimeNanos; - // timestamp for local captured frames - int64_t _incomingFrameTimesNanos[kFrameRateCountHistorySize]; - VideoRotation _rotateFrame; // Set if the frame should be rotated by the - // capture module. - - // Indicate whether rotation should be applied before delivered externally. - bool apply_rotation_; + // Indicate whether rotation should be applied before delivered externally. + bool apply_rotation_; }; } // namespace videocapturemodule } // namespace webrtc diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h index 69991b2d9c..68988557c7 100644 --- a/modules/video_capture/windows/device_info_ds.h +++ b/modules/video_capture/windows/device_info_ds.h @@ -16,91 +16,84 @@ #include -namespace webrtc -{ -namespace videocapturemodule -{ -struct VideoCaptureCapabilityWindows: public VideoCaptureCapability -{ - uint32_t directShowCapabilityIndex; - bool supportFrameRateControl; - VideoCaptureCapabilityWindows() - { - directShowCapabilityIndex = 0; - supportFrameRateControl = false; - } +namespace webrtc { +namespace videocapturemodule { +struct VideoCaptureCapabilityWindows : public VideoCaptureCapability { + uint32_t directShowCapabilityIndex; + bool supportFrameRateControl; + VideoCaptureCapabilityWindows() { + directShowCapabilityIndex = 0; + supportFrameRateControl = false; + } }; -class DeviceInfoDS: public DeviceInfoImpl -{ -public: - // Factory function. - static DeviceInfoDS* Create(); +class DeviceInfoDS : public DeviceInfoImpl { + public: + // Factory function. + static DeviceInfoDS* Create(); - DeviceInfoDS(); - virtual ~DeviceInfoDS(); + DeviceInfoDS(); + virtual ~DeviceInfoDS(); - int32_t Init(); - virtual uint32_t NumberOfDevices(); + int32_t Init(); + virtual uint32_t NumberOfDevices(); - /* - * Returns the available capture devices. - */ - virtual int32_t - GetDeviceName(uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, - uint32_t productUniqueIdUTF8Length); + /* + * Returns the available capture devices. + */ + virtual int32_t GetDeviceName(uint32_t deviceNumber, + char* deviceNameUTF8, + uint32_t deviceNameLength, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8, + uint32_t productUniqueIdUTF8Length); - /* - * Display OS /capture device specific settings dialog - */ - virtual int32_t - DisplayCaptureSettingsDialogBox( - const char* deviceUniqueIdUTF8, - const char* dialogTitleUTF8, - void* parentWindow, - uint32_t positionX, - uint32_t positionY); + /* + * Display OS /capture device specific settings dialog + */ + virtual int32_t DisplayCaptureSettingsDialogBox( + const char* deviceUniqueIdUTF8, + const char* dialogTitleUTF8, + void* parentWindow, + uint32_t positionX, + uint32_t positionY); - // Windows specific + // Windows specific - /* Gets a capture device filter - The user of this API is responsible for releasing the filter when it not needed. - */ - IBaseFilter * GetDeviceFilter(const char* deviceUniqueIdUTF8, - char* productUniqueIdUTF8 = NULL, - uint32_t productUniqueIdUTF8Length = 0); + /* Gets a capture device filter + The user of this API is responsible for releasing the filter when it not + needed. + */ + IBaseFilter* GetDeviceFilter(const char* deviceUniqueIdUTF8, + char* productUniqueIdUTF8 = NULL, + uint32_t productUniqueIdUTF8Length = 0); - int32_t - GetWindowsCapability(const int32_t capabilityIndex, - VideoCaptureCapabilityWindows& windowsCapability); + int32_t GetWindowsCapability( + const int32_t capabilityIndex, + VideoCaptureCapabilityWindows& windowsCapability); - static void GetProductId(const char* devicePath, - char* productUniqueIdUTF8, - uint32_t productUniqueIdUTF8Length); + static void GetProductId(const char* devicePath, + char* productUniqueIdUTF8, + uint32_t productUniqueIdUTF8Length); -protected: - int32_t GetDeviceInfo(uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, - uint32_t productUniqueIdUTF8Length); + protected: + int32_t GetDeviceInfo(uint32_t deviceNumber, + char* deviceNameUTF8, + uint32_t deviceNameLength, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8, + uint32_t productUniqueIdUTF8Length); - virtual int32_t - CreateCapabilityMap(const char* deviceUniqueIdUTF8); + virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8); -private: - ICreateDevEnum* _dsDevEnum; - IEnumMoniker* _dsMonikerDevEnum; - bool _CoUninitializeIsRequired; - std::vector _captureCapabilitiesWindows; + private: + ICreateDevEnum* _dsDevEnum; + IEnumMoniker* _dsMonikerDevEnum; + bool _CoUninitializeIsRequired; + std::vector _captureCapabilitiesWindows; }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_ diff --git a/modules/video_capture/windows/device_info_mf.cc b/modules/video_capture/windows/device_info_mf.cc index 3bdd7553a5..4002f25ac0 100644 --- a/modules/video_capture/windows/device_info_mf.cc +++ b/modules/video_capture/windows/device_info_mf.cc @@ -13,11 +13,9 @@ namespace webrtc { namespace videocapturemodule { -DeviceInfoMF::DeviceInfoMF() { -} +DeviceInfoMF::DeviceInfoMF() {} -DeviceInfoMF::~DeviceInfoMF() { -} +DeviceInfoMF::~DeviceInfoMF() {} int32_t DeviceInfoMF::Init() { return -1; @@ -27,14 +25,13 @@ uint32_t DeviceInfoMF::NumberOfDevices() { return 0; } -int32_t DeviceInfoMF::GetDeviceName( - uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, - uint32_t productUniqueIdUTF8Length) { +int32_t DeviceInfoMF::GetDeviceName(uint32_t deviceNumber, + char* deviceNameUTF8, + uint32_t deviceNameLength, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8, + uint32_t productUniqueIdUTF8Length) { return -1; } diff --git a/modules/video_capture/windows/device_info_mf.h b/modules/video_capture/windows/device_info_mf.h index 027f7c4401..984d20674a 100644 --- a/modules/video_capture/windows/device_info_mf.h +++ b/modules/video_capture/windows/device_info_mf.h @@ -25,7 +25,8 @@ class DeviceInfoMF : public DeviceInfoImpl { int32_t Init(); virtual uint32_t NumberOfDevices(); - virtual int32_t GetDeviceName(uint32_t deviceNumber, char* deviceNameUTF8, + virtual int32_t GetDeviceName(uint32_t deviceNumber, + char* deviceNameUTF8, uint32_t deviceNameLength, char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Length, @@ -33,8 +34,11 @@ class DeviceInfoMF : public DeviceInfoImpl { uint32_t productUniqueIdUTF8Length); virtual int32_t DisplayCaptureSettingsDialogBox( - const char* deviceUniqueIdUTF8, const char* dialogTitleUTF8, - void* parentWindow, uint32_t positionX, uint32_t positionY); + const char* deviceUniqueIdUTF8, + const char* dialogTitleUTF8, + void* parentWindow, + uint32_t positionX, + uint32_t positionY); }; } // namespace videocapturemodule diff --git a/modules/video_capture/windows/help_functions_ds.cc b/modules/video_capture/windows/help_functions_ds.cc index 12deab0128..ab85da9488 100644 --- a/modules/video_capture/windows/help_functions_ds.cc +++ b/modules/video_capture/windows/help_functions_ds.cc @@ -16,104 +16,90 @@ #include -namespace webrtc -{ -namespace videocapturemodule -{ +namespace webrtc { +namespace videocapturemodule { // This returns minimum :), which will give max frame rate... -LONGLONG GetMaxOfFrameArray(LONGLONG *maxFps, long size) -{ - LONGLONG maxFPS = maxFps[0]; - for (int i = 0; i < size; i++) - { - if (maxFPS > maxFps[i]) - maxFPS = maxFps[i]; - } - return maxFPS; +LONGLONG GetMaxOfFrameArray(LONGLONG* maxFps, long size) { + LONGLONG maxFPS = maxFps[0]; + for (int i = 0; i < size; i++) { + if (maxFPS > maxFps[i]) + maxFPS = maxFps[i]; + } + return maxFPS; } -IPin* GetInputPin(IBaseFilter* filter) -{ - HRESULT hr; - IPin* pin = NULL; - IEnumPins* pPinEnum = NULL; - filter->EnumPins(&pPinEnum); - if (pPinEnum == NULL) - { - return NULL; - } - - // get first unconnected pin - hr = pPinEnum->Reset(); // set to first pin - - while (S_OK == pPinEnum->Next(1, &pin, NULL)) - { - PIN_DIRECTION pPinDir; - pin->QueryDirection(&pPinDir); - if (PINDIR_INPUT == pPinDir) // This is an input pin - { - IPin* tempPin = NULL; - if (S_OK != pin->ConnectedTo(&tempPin)) // The pint is not connected - { - pPinEnum->Release(); - return pin; - } - } - pin->Release(); - } - pPinEnum->Release(); +IPin* GetInputPin(IBaseFilter* filter) { + HRESULT hr; + IPin* pin = NULL; + IEnumPins* pPinEnum = NULL; + filter->EnumPins(&pPinEnum); + if (pPinEnum == NULL) { return NULL; + } + + // get first unconnected pin + hr = pPinEnum->Reset(); // set to first pin + + while (S_OK == pPinEnum->Next(1, &pin, NULL)) { + PIN_DIRECTION pPinDir; + pin->QueryDirection(&pPinDir); + if (PINDIR_INPUT == pPinDir) // This is an input pin + { + IPin* tempPin = NULL; + if (S_OK != pin->ConnectedTo(&tempPin)) // The pint is not connected + { + pPinEnum->Release(); + return pin; + } + } + pin->Release(); + } + pPinEnum->Release(); + return NULL; } -IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category) -{ - HRESULT hr; - IPin* pin = NULL; - IEnumPins* pPinEnum = NULL; - filter->EnumPins(&pPinEnum); - if (pPinEnum == NULL) - { - return NULL; - } - // get first unconnected pin - hr = pPinEnum->Reset(); // set to first pin - while (S_OK == pPinEnum->Next(1, &pin, NULL)) - { - PIN_DIRECTION pPinDir; - pin->QueryDirection(&pPinDir); - if (PINDIR_OUTPUT == pPinDir) // This is an output pin - { - if (Category == GUID_NULL || PinMatchesCategory(pin, Category)) - { - pPinEnum->Release(); - return pin; - } - } - pin->Release(); - pin = NULL; - } - pPinEnum->Release(); +IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category) { + HRESULT hr; + IPin* pin = NULL; + IEnumPins* pPinEnum = NULL; + filter->EnumPins(&pPinEnum); + if (pPinEnum == NULL) { return NULL; + } + // get first unconnected pin + hr = pPinEnum->Reset(); // set to first pin + while (S_OK == pPinEnum->Next(1, &pin, NULL)) { + PIN_DIRECTION pPinDir; + pin->QueryDirection(&pPinDir); + if (PINDIR_OUTPUT == pPinDir) // This is an output pin + { + if (Category == GUID_NULL || PinMatchesCategory(pin, Category)) { + pPinEnum->Release(); + return pin; + } + } + pin->Release(); + pin = NULL; + } + pPinEnum->Release(); + return NULL; } -BOOL PinMatchesCategory(IPin *pPin, REFGUID Category) -{ - BOOL bFound = FALSE; - IKsPropertySet *pKs = NULL; - HRESULT hr = pPin->QueryInterface(IID_PPV_ARGS(&pKs)); - if (SUCCEEDED(hr)) - { - GUID PinCategory; - DWORD cbReturned; - hr = pKs->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0, &PinCategory, - sizeof(GUID), &cbReturned); - if (SUCCEEDED(hr) && (cbReturned == sizeof(GUID))) - { - bFound = (PinCategory == Category); - } - pKs->Release(); +BOOL PinMatchesCategory(IPin* pPin, REFGUID Category) { + BOOL bFound = FALSE; + IKsPropertySet* pKs = NULL; + HRESULT hr = pPin->QueryInterface(IID_PPV_ARGS(&pKs)); + if (SUCCEEDED(hr)) { + GUID PinCategory; + DWORD cbReturned; + hr = pKs->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0, + &PinCategory, sizeof(GUID), &cbReturned); + if (SUCCEEDED(hr) && (cbReturned == sizeof(GUID))) { + bFound = (PinCategory == Category); } - return bFound; + pKs->Release(); + } + return bFound; } } // namespace videocapturemodule } // namespace webrtc diff --git a/modules/video_capture/windows/help_functions_ds.h b/modules/video_capture/windows/help_functions_ds.h index 990f4183cc..e77efd1237 100644 --- a/modules/video_capture/windows/help_functions_ds.h +++ b/modules/video_capture/windows/help_functions_ds.h @@ -13,23 +13,45 @@ #include -DEFINE_GUID(MEDIASUBTYPE_I420, 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, - 0xAA, 0x00, 0x38, 0x9B, 0x71); -DEFINE_GUID(MEDIASUBTYPE_HDYC, 0x43594448, 0x0000, 0x0010, 0x80, 0x00, 0x00, - 0xAA, 0x00, 0x38, 0x9B, 0x71); +DEFINE_GUID(MEDIASUBTYPE_I420, + 0x30323449, + 0x0000, + 0x0010, + 0x80, + 0x00, + 0x00, + 0xAA, + 0x00, + 0x38, + 0x9B, + 0x71); +DEFINE_GUID(MEDIASUBTYPE_HDYC, + 0x43594448, + 0x0000, + 0x0010, + 0x80, + 0x00, + 0x00, + 0xAA, + 0x00, + 0x38, + 0x9B, + 0x71); -#define RELEASE_AND_CLEAR(p) if (p) { (p) -> Release () ; (p) = NULL ; } +#define RELEASE_AND_CLEAR(p) \ + if (p) { \ + (p)->Release(); \ + (p) = NULL; \ + } -namespace webrtc -{ -namespace videocapturemodule -{ -LONGLONG GetMaxOfFrameArray(LONGLONG *maxFps, long size); +namespace webrtc { +namespace videocapturemodule { +LONGLONG GetMaxOfFrameArray(LONGLONG* maxFps, long size); IPin* GetInputPin(IBaseFilter* filter); IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category); -BOOL PinMatchesCategory(IPin *pPin, REFGUID Category); +BOOL PinMatchesCategory(IPin* pPin, REFGUID Category); } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_HELP_FUNCTIONS_DS_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_HELP_FUNCTIONS_DS_H_ diff --git a/modules/video_capture/windows/sink_filter_ds.h b/modules/video_capture/windows/sink_filter_ds.h index 4f620f4b49..a73022db46 100644 --- a/modules/video_capture/windows/sink_filter_ds.h +++ b/modules/video_capture/windows/sink_filter_ds.h @@ -11,85 +11,82 @@ #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_ #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_ -#include // Include base DS filter header files +#include // Include base DS filter header files #include "modules/video_capture/video_capture_defines.h" -namespace webrtc -{ -namespace videocapturemodule -{ -//forward declaration +namespace webrtc { +namespace videocapturemodule { +// forward declaration class CaptureSinkFilter; /** * input pin for camera input * */ -class CaptureInputPin: public CBaseInputPin -{ -public: - VideoCaptureCapability _requestedCapability; - VideoCaptureCapability _resultingCapability; - HANDLE _threadHandle; +class CaptureInputPin : public CBaseInputPin { + public: + VideoCaptureCapability _requestedCapability; + VideoCaptureCapability _resultingCapability; + HANDLE _threadHandle; - CaptureInputPin(IN TCHAR* szName, - IN CaptureSinkFilter* pFilter, - IN CCritSec * pLock, - OUT HRESULT * pHr, - IN LPCWSTR pszName); - virtual ~CaptureInputPin(); + CaptureInputPin(IN TCHAR* szName, + IN CaptureSinkFilter* pFilter, + IN CCritSec* pLock, + OUT HRESULT* pHr, + IN LPCWSTR pszName); + virtual ~CaptureInputPin(); - HRESULT GetMediaType (IN int iPos, OUT CMediaType * pmt); - HRESULT CheckMediaType (IN const CMediaType * pmt); - STDMETHODIMP Receive (IN IMediaSample *); - HRESULT SetMatchingMediaType(const VideoCaptureCapability& capability); + HRESULT GetMediaType(IN int iPos, OUT CMediaType* pmt); + HRESULT CheckMediaType(IN const CMediaType* pmt); + STDMETHODIMP Receive(IN IMediaSample*); + HRESULT SetMatchingMediaType(const VideoCaptureCapability& capability); }; -class CaptureSinkFilter: public CBaseFilter -{ +class CaptureSinkFilter : public CBaseFilter { + public: + CaptureSinkFilter(const IN TCHAR* tszName, + IN LPUNKNOWN punk, + OUT HRESULT* phr, + VideoCaptureExternal& captureObserver); + virtual ~CaptureSinkFilter(); -public: - CaptureSinkFilter(const IN TCHAR * tszName, - IN LPUNKNOWN punk, - OUT HRESULT * phr, - VideoCaptureExternal& captureObserver); - virtual ~CaptureSinkFilter(); + // -------------------------------------------------------------------- + // class methods - // -------------------------------------------------------------------- - // class methods + void ProcessCapturedFrame(unsigned char* pBuffer, + size_t length, + const VideoCaptureCapability& frameInfo); + // explicit receiver lock aquisition and release + void LockReceive() { m_crtRecv.Lock(); } + void UnlockReceive() { m_crtRecv.Unlock(); } + // explicit filter lock aquisition and release + void LockFilter() { m_crtFilter.Lock(); } + void UnlockFilter() { m_crtFilter.Unlock(); } + void SetFilterGraph(IGraphBuilder* graph); // Used if EVR - void ProcessCapturedFrame(unsigned char* pBuffer, size_t length, - const VideoCaptureCapability& frameInfo); - // explicit receiver lock aquisition and release - void LockReceive() { m_crtRecv.Lock();} - void UnlockReceive() {m_crtRecv.Unlock();} - // explicit filter lock aquisition and release - void LockFilter() {m_crtFilter.Lock();} - void UnlockFilter() { m_crtFilter.Unlock(); } - void SetFilterGraph(IGraphBuilder* graph); // Used if EVR + // -------------------------------------------------------------------- + // COM interfaces + DECLARE_IUNKNOWN; + STDMETHODIMP SetMatchingMediaType(const VideoCaptureCapability& capability); - // -------------------------------------------------------------------- - // COM interfaces -DECLARE_IUNKNOWN ; - STDMETHODIMP SetMatchingMediaType(const VideoCaptureCapability& capability); + // -------------------------------------------------------------------- + // CBaseFilter methods + int GetPinCount(); + CBasePin* GetPin(IN int Index); + STDMETHODIMP Pause(); + STDMETHODIMP Stop(); + STDMETHODIMP GetClassID(OUT CLSID* pCLSID); + // -------------------------------------------------------------------- + // class factory calls this + static CUnknown* CreateInstance(IN LPUNKNOWN punk, OUT HRESULT* phr); - // -------------------------------------------------------------------- - // CBaseFilter methods - int GetPinCount (); - CBasePin * GetPin ( IN int Index); - STDMETHODIMP Pause (); - STDMETHODIMP Stop (); - STDMETHODIMP GetClassID ( OUT CLSID * pCLSID); - // -------------------------------------------------------------------- - // class factory calls this - static CUnknown * CreateInstance (IN LPUNKNOWN punk, OUT HRESULT * phr); -private: - CCritSec m_crtFilter; // filter lock - CCritSec m_crtRecv; // receiver lock; always acquire before filter lock - CaptureInputPin * m_pInput; - VideoCaptureExternal& _captureObserver; + private: + CCritSec m_crtFilter; // filter lock + CCritSec m_crtRecv; // receiver lock; always acquire before filter lock + CaptureInputPin* m_pInput; + VideoCaptureExternal& _captureObserver; }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_ diff --git a/modules/video_capture/windows/video_capture_ds.h b/modules/video_capture/windows/video_capture_ds.h index 86fa5892b1..db3d34a084 100644 --- a/modules/video_capture/windows/video_capture_ds.h +++ b/modules/video_capture/windows/video_capture_ds.h @@ -17,63 +17,57 @@ #define CAPTURE_FILTER_NAME L"VideoCaptureFilter" #define SINK_FILTER_NAME L"SinkFilter" -namespace webrtc -{ -namespace videocapturemodule -{ +namespace webrtc { +namespace videocapturemodule { // Forward declaraion class CaptureSinkFilter; -class VideoCaptureDS: public VideoCaptureImpl -{ -public: - VideoCaptureDS(); +class VideoCaptureDS : public VideoCaptureImpl { + public: + VideoCaptureDS(); - virtual int32_t Init(const char* deviceUniqueIdUTF8); + virtual int32_t Init(const char* deviceUniqueIdUTF8); - /************************************************************************* - * - * Start/Stop - * - *************************************************************************/ - virtual int32_t - StartCapture(const VideoCaptureCapability& capability); - virtual int32_t StopCapture(); + /************************************************************************* + * + * Start/Stop + * + *************************************************************************/ + virtual int32_t StartCapture(const VideoCaptureCapability& capability); + virtual int32_t StopCapture(); - /************************************************************************** - * - * Properties of the set device - * - **************************************************************************/ + /************************************************************************** + * + * Properties of the set device + * + **************************************************************************/ - virtual bool CaptureStarted(); - virtual int32_t CaptureSettings(VideoCaptureCapability& settings); + virtual bool CaptureStarted(); + virtual int32_t CaptureSettings(VideoCaptureCapability& settings); -protected: - virtual ~VideoCaptureDS(); + protected: + virtual ~VideoCaptureDS(); - // Help functions + // Help functions - int32_t - SetCameraOutput(const VideoCaptureCapability& requestedCapability); - int32_t DisconnectGraph(); - HRESULT ConnectDVCamera(); + int32_t SetCameraOutput(const VideoCaptureCapability& requestedCapability); + int32_t DisconnectGraph(); + HRESULT ConnectDVCamera(); - DeviceInfoDS _dsInfo; + DeviceInfoDS _dsInfo; - IBaseFilter* _captureFilter; - IGraphBuilder* _graphBuilder; - IMediaControl* _mediaControl; - CaptureSinkFilter* _sinkFilter; - IPin* _inputSendPin; - IPin* _outputCapturePin; - - // Microsoft DV interface (external DV cameras) - IBaseFilter* _dvFilter; - IPin* _inputDvPin; - IPin* _outputDvPin; + IBaseFilter* _captureFilter; + IGraphBuilder* _graphBuilder; + IMediaControl* _mediaControl; + CaptureSinkFilter* _sinkFilter; + IPin* _inputSendPin; + IPin* _outputCapturePin; + // Microsoft DV interface (external DV cameras) + IBaseFilter* _dvFilter; + IPin* _inputDvPin; + IPin* _outputDvPin; }; } // namespace videocapturemodule } // namespace webrtc -#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_VIDEO_CAPTURE_DS_H_ +#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_VIDEO_CAPTURE_DS_H_ diff --git a/modules/video_capture/windows/video_capture_mf.cc b/modules/video_capture/windows/video_capture_mf.cc index 086b7083d9..4c72ee96a3 100644 --- a/modules/video_capture/windows/video_capture_mf.cc +++ b/modules/video_capture/windows/video_capture_mf.cc @@ -20,8 +20,7 @@ int32_t VideoCaptureMF::Init(const char* device_id) { return 0; } -int32_t VideoCaptureMF::StartCapture( - const VideoCaptureCapability& capability) { +int32_t VideoCaptureMF::StartCapture(const VideoCaptureCapability& capability) { return -1; } @@ -33,8 +32,7 @@ bool VideoCaptureMF::CaptureStarted() { return false; } -int32_t VideoCaptureMF::CaptureSettings( - VideoCaptureCapability& settings) { +int32_t VideoCaptureMF::CaptureSettings(VideoCaptureCapability& settings) { return -1; } diff --git a/modules/video_capture/windows/video_capture_mf.h b/modules/video_capture/windows/video_capture_mf.h index 896be4e260..ed9c382f1e 100644 --- a/modules/video_capture/windows/video_capture_mf.h +++ b/modules/video_capture/windows/video_capture_mf.h @@ -30,8 +30,7 @@ class VideoCaptureMF : public VideoCaptureImpl { virtual int32_t StartCapture(const VideoCaptureCapability& capability); virtual int32_t StopCapture(); virtual bool CaptureStarted(); - virtual int32_t CaptureSettings( - VideoCaptureCapability& settings); // NOLINT + virtual int32_t CaptureSettings(VideoCaptureCapability& settings); // NOLINT protected: virtual ~VideoCaptureMF(); diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.h b/modules/video_coding/codecs/h264/h264_decoder_impl.h index 1172f145d6..a709177946 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.h +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.h @@ -58,8 +58,9 @@ class H264DecoderImpl : public H264Decoder { // Called by FFmpeg when it needs a frame buffer to store decoded frames in. // The |VideoFrame| returned by FFmpeg at |Decode| originate from here. Their // buffers are reference counted and freed by FFmpeg using |AVFreeBuffer2|. - static int AVGetBuffer2( - AVCodecContext* context, AVFrame* av_frame, int flags); + static int AVGetBuffer2(AVCodecContext* context, + AVFrame* av_frame, + int flags); // Called by FFmpeg when it is done with a video frame, see |AVGetBuffer2|. static void AVFreeBuffer2(void* opaque, uint8_t* data); diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc index 67c5abcaf1..eee954d176 100644 --- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc @@ -45,17 +45,17 @@ enum H264EncoderImplEvent { int NumberOfThreads(int width, int height, int number_of_cores) { // TODO(hbos): In Chromium, multiple threads do not work with sandbox on Mac, // see crbug.com/583348. Until further investigated, only use one thread. -// if (width * height >= 1920 * 1080 && number_of_cores > 8) { -// return 8; // 8 threads for 1080p on high perf machines. -// } else if (width * height > 1280 * 960 && number_of_cores >= 6) { -// return 3; // 3 threads for 1080p. -// } else if (width * height > 640 * 480 && number_of_cores >= 3) { -// return 2; // 2 threads for qHD/HD. -// } else { -// return 1; // 1 thread for VGA or less. -// } -// TODO(sprang): Also check sSliceArgument.uiSliceNum om GetEncoderPrams(), -// before enabling multithreading here. + // if (width * height >= 1920 * 1080 && number_of_cores > 8) { + // return 8; // 8 threads for 1080p on high perf machines. + // } else if (width * height > 1280 * 960 && number_of_cores >= 6) { + // return 3; // 3 threads for 1080p. + // } else if (width * height > 640 * 480 && number_of_cores >= 3) { + // return 2; // 2 threads for qHD/HD. + // } else { + // return 1; // 1 thread for VGA or less. + // } + // TODO(sprang): Also check sSliceArgument.uiSliceNum om GetEncoderPrams(), + // before enabling multithreading here. return 1; } @@ -139,10 +139,10 @@ static void RtpFragmentize(EncodedImage* encoded_image, // Because the sum of all layer lengths, |required_size|, fits in a // |size_t|, we know that any indices in-between will not overflow. RTC_DCHECK_GE(layerInfo.pNalLengthInByte[nal], 4); - RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+0], start_code[0]); - RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+1], start_code[1]); - RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+2], start_code[2]); - RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+3], start_code[3]); + RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 0], start_code[0]); + RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 1], start_code[1]); + RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 2], start_code[2]); + RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 3], start_code[3]); frag_header->fragmentationOffset[frag] = encoded_image->_length + layer_len + sizeof(start_code); frag_header->fragmentationLength[frag] = @@ -150,8 +150,7 @@ static void RtpFragmentize(EncodedImage* encoded_image, layer_len += layerInfo.pNalLengthInByte[nal]; } // Copy the entire layer's data (including start codes). - memcpy(encoded_image->_buffer + encoded_image->_length, - layerInfo.pBsBuf, + memcpy(encoded_image->_buffer + encoded_image->_length, layerInfo.pBsBuf, layer_len); encoded_image->_length += layer_len; } @@ -190,8 +189,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, int32_t number_of_cores, size_t max_payload_size) { ReportInit(); - if (!codec_settings || - codec_settings->codecType != kVideoCodecH264) { + if (!codec_settings || codec_settings->codecType != kVideoCodecH264) { ReportError(); return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } @@ -222,8 +220,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, RTC_DCHECK(openh264_encoder_); if (kOpenH264EncoderDetailedLogging) { int trace_level = WELS_LOG_DETAIL; - openh264_encoder_->SetOption(ENCODER_OPTION_TRACE_LEVEL, - &trace_level); + openh264_encoder_->SetOption(ENCODER_OPTION_TRACE_LEVEL, &trace_level); } // else WELS_LOG_DEFAULT is used by default. @@ -255,8 +252,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, } // TODO(pbos): Base init params on these values before submitting. int video_format = EVideoFormatType::videoFormatI420; - openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, - &video_format); + openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, &video_format); // Initialize encoded image. Default buffer size: size of unencoded data. encoded_image_._size = CalcBufferSize(VideoType::kI420, codec_settings->width, @@ -300,8 +296,7 @@ int32_t H264EncoderImpl::SetRateAllocation( memset(&target_bitrate, 0, sizeof(SBitrateInfo)); target_bitrate.iLayer = SPATIAL_LAYER_ALL, target_bitrate.iBitrate = target_bps_; - openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE, - &target_bitrate); + openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE, &target_bitrate); openh264_encoder_->SetOption(ENCODER_OPTION_FRAME_RATE, &max_frame_rate_); return WEBRTC_VIDEO_CODEC_OK; } @@ -485,8 +480,7 @@ void H264EncoderImpl::ReportInit() { if (has_reported_init_) return; RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event", - kH264EncoderEventInit, - kH264EncoderEventMax); + kH264EncoderEventInit, kH264EncoderEventMax); has_reported_init_ = true; } @@ -494,13 +488,12 @@ void H264EncoderImpl::ReportError() { if (has_reported_error_) return; RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event", - kH264EncoderEventError, - kH264EncoderEventMax); + kH264EncoderEventError, kH264EncoderEventMax); has_reported_error_ = true; } -int32_t H264EncoderImpl::SetChannelParameters( - uint32_t packet_loss, int64_t rtt) { +int32_t H264EncoderImpl::SetChannelParameters(uint32_t packet_loss, + int64_t rtt) { return WEBRTC_VIDEO_CODEC_OK; } diff --git a/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc b/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc index de4352f79e..dcf99f1c84 100644 --- a/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc +++ b/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc @@ -126,8 +126,8 @@ int32_t MultiplexDecoderAdapter::Decode( int32_t rv = 0; for (size_t i = 0; i < image.image_components.size(); i++) { rv = decoders_[image.image_components[i].component_index]->Decode( - image.image_components[i].encoded_image, missing_frames, - nullptr, render_time_ms); + image.image_components[i].encoded_image, missing_frames, nullptr, + render_time_ms); if (rv != WEBRTC_VIDEO_CODEC_OK) return rv; } diff --git a/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc b/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc index fbefd60903..be5c2cca25 100644 --- a/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc +++ b/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc @@ -128,9 +128,8 @@ TEST_F(TestMultiplexAdapter, EncodeDecodeI420Frame) { ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info)); EXPECT_EQ(kVideoCodecMultiplex, codec_specific_info.codecType); - EXPECT_EQ( - WEBRTC_VIDEO_CODEC_OK, - decoder_->Decode(encoded_frame, false, &codec_specific_info, -1)); + EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, + decoder_->Decode(encoded_frame, false, &codec_specific_info, -1)); std::unique_ptr decoded_frame; absl::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc index 5ac6986830..394ee14c4e 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc @@ -308,9 +308,9 @@ bool VideoCodecTestFixtureImpl::Config::IsAsyncCodec() const { // TODO(kthelgason): Move this out of the test fixture impl and // make available as a shared utility class. -void VideoCodecTestFixtureImpl::H264KeyframeChecker:: - CheckEncodedFrame(webrtc::VideoCodecType codec, - const EncodedImage& encoded_frame) const { +void VideoCodecTestFixtureImpl::H264KeyframeChecker::CheckEncodedFrame( + webrtc::VideoCodecType codec, + const EncodedImage& encoded_frame) const { EXPECT_EQ(kVideoCodecH264, codec); bool contains_sps = false; bool contains_pps = false; @@ -390,8 +390,7 @@ VideoCodecTestFixtureImpl::VideoCodecTestFixtureImpl( decoder_factory_(std::move(decoder_factory)), config_(config) {} -VideoCodecTestFixtureImpl:: - ~VideoCodecTestFixtureImpl() = default; +VideoCodecTestFixtureImpl::~VideoCodecTestFixtureImpl() = default; // Processes all frames in the clip and verifies the result. void VideoCodecTestFixtureImpl::RunTest( diff --git a/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc b/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc index fc49c92b7b..f8580fc9dc 100644 --- a/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc +++ b/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc @@ -70,8 +70,8 @@ TEST(VideoCodecTestMediaCodec, ForemanCif500kbpsVp8) { TEST(VideoCodecTestMediaCodec, ForemanCif500kbpsH264CBP) { auto config = CreateConfig(); - const auto frame_checker = rtc::MakeUnique< - VideoCodecTestFixtureImpl::H264KeyframeChecker>(); + const auto frame_checker = + rtc::MakeUnique(); config.encoded_frame_checker = frame_checker.get(); config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false, 352, 288); @@ -95,8 +95,8 @@ TEST(VideoCodecTestMediaCodec, ForemanCif500kbpsH264CBP) { // HW encoders that support CHP. TEST(VideoCodecTestMediaCodec, DISABLED_ForemanCif500kbpsH264CHP) { auto config = CreateConfig(); - const auto frame_checker = rtc::MakeUnique< - VideoCodecTestFixtureImpl::H264KeyframeChecker>(); + const auto frame_checker = + rtc::MakeUnique(); config.h264_codec_settings.profile = H264::kProfileConstrainedHigh; config.encoded_frame_checker = frame_checker.get(); diff --git a/modules/video_coding/codecs/test/videocodec_test_openh264.cc b/modules/video_coding/codecs/test/videocodec_test_openh264.cc index c8a6ba209c..a0743d1485 100644 --- a/modules/video_coding/codecs/test/videocodec_test_openh264.cc +++ b/modules/video_coding/codecs/test/videocodec_test_openh264.cc @@ -39,8 +39,8 @@ VideoCodecTestFixture::Config CreateConfig() { } // namespace TEST(VideoCodecTestOpenH264, ConstantHighBitrate) { - auto frame_checker = rtc::MakeUnique< - VideoCodecTestFixtureImpl::H264KeyframeChecker>(); + auto frame_checker = + rtc::MakeUnique(); auto config = CreateConfig(); config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, true, false, kCifWidth, kCifHeight); @@ -60,8 +60,8 @@ TEST(VideoCodecTestOpenH264, ConstantHighBitrate) { // H264: Enable SingleNalUnit packetization mode. Encoder should split // large frames into multiple slices and limit length of NAL units. TEST(VideoCodecTestOpenH264, SingleNalUnit) { - auto frame_checker = rtc::MakeUnique< - VideoCodecTestFixtureImpl::H264KeyframeChecker>(); + auto frame_checker = + rtc::MakeUnique(); auto config = CreateConfig(); config.h264_codec_settings.packetization_mode = H264PacketizationMode::SingleNalUnit; diff --git a/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc b/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc index c91f3401f8..a5667bcb63 100644 --- a/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc +++ b/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc @@ -37,8 +37,8 @@ std::unique_ptr CreateTestFixtureWithConfig( VideoCodecTestFixture::Config config) { auto decoder_factory = CreateObjCDecoderFactory(); auto encoder_factory = CreateObjCEncoderFactory(); - return CreateVideoCodecTestFixture( - config, std::move(decoder_factory), std::move(encoder_factory)); + return CreateVideoCodecTestFixture(config, std::move(decoder_factory), + std::move(encoder_factory)); } } // namespace @@ -53,8 +53,8 @@ std::unique_ptr CreateTestFixtureWithConfig( // TODO(kthelgason): Use RC Thresholds when the internal bitrateAdjuster is no // longer in use. MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CBP) { - const auto frame_checker = rtc::MakeUnique< - VideoCodecTestFixtureImpl::H264KeyframeChecker>(); + const auto frame_checker = + rtc::MakeUnique(); auto config = CreateConfig(); config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false, 352, 288); @@ -69,8 +69,8 @@ MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CBP) { } MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CHP) { - const auto frame_checker = rtc::MakeUnique< - VideoCodecTestFixtureImpl::H264KeyframeChecker>(); + const auto frame_checker = + rtc::MakeUnique(); auto config = CreateConfig(); config.h264_codec_settings.profile = H264::kProfileConstrainedHigh; config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false, diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc index bd2c9921bf..9df5544878 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include #include diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index 0f8bc756fa..522c98971f 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include #include #include diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.cc b/modules/video_coding/codecs/vp8/screenshare_layers.cc index cd2449052b..f7f1019820 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers.cc @@ -37,8 +37,7 @@ constexpr int ScreenshareLayers::kMaxNumTemporalLayers; // been exceeded. This prevents needless keyframe requests. const int ScreenshareLayers::kMaxFrameIntervalMs = 2750; -ScreenshareLayers::ScreenshareLayers(int num_temporal_layers, - Clock* clock) +ScreenshareLayers::ScreenshareLayers(int num_temporal_layers, Clock* clock) : clock_(clock), number_of_temporal_layers_( std::min(kMaxNumTemporalLayers, num_temporal_layers)), diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.h b/modules/video_coding/codecs/vp8/screenshare_layers.h index c1b5fa79a7..5185b45d8f 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.h +++ b/modules/video_coding/codecs/vp8/screenshare_layers.h @@ -28,8 +28,7 @@ class ScreenshareLayers : public TemporalLayers { static const double kAcceptableTargetOvershoot; static const int kMaxFrameIntervalMs; - ScreenshareLayers(int num_temporal_layers, - Clock* clock); + ScreenshareLayers(int num_temporal_layers, Clock* clock); virtual ~ScreenshareLayers(); // Returns the recommended VP8 encode flags needed. May refresh the decoder diff --git a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc index 6eea837454..f8cfe88b07 100644 --- a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc +++ b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc @@ -12,8 +12,8 @@ #include #include -#include #include +#include #include "modules/video_coding/codecs/vp8/include/vp8_common_types.h" #include "rtc_base/checks.h" diff --git a/modules/video_coding/codecs/vp9/include/vp9_globals.h b/modules/video_coding/codecs/vp9/include/vp9_globals.h index 3ee9952c36..aa532a6876 100644 --- a/modules/video_coding/codecs/vp9/include/vp9_globals.h +++ b/modules/video_coding/codecs/vp9/include/vp9_globals.h @@ -181,12 +181,12 @@ struct RTPVideoHeaderVP9 { bool beginning_of_frame; // True if this packet is the first in a VP9 layer // frame. bool end_of_frame; // True if this packet is the last in a VP9 layer frame. - bool ss_data_available; // True if SS data is available in this payload - // descriptor. + bool ss_data_available; // True if SS data is available in this payload + // descriptor. bool non_ref_for_inter_layer_pred; // True for frame which is not used as // reference for inter-layer prediction. - int16_t picture_id; // PictureID index, 15 bits; - // kNoPictureId if PictureID does not exist. + int16_t picture_id; // PictureID index, 15 bits; + // kNoPictureId if PictureID does not exist. int16_t max_picture_id; // Maximum picture ID index; either 0x7F or 0x7FFF; int16_t tl0_pic_idx; // TL0PIC_IDX, 8 bits; // kNoTl0PicIdx means no value provided. diff --git a/modules/video_coding/codecs/vp9/svc_config.cc b/modules/video_coding/codecs/vp9/svc_config.cc index c4ec288ccd..22902fecea 100644 --- a/modules/video_coding/codecs/vp9/svc_config.cc +++ b/modules/video_coding/codecs/vp9/svc_config.cc @@ -85,7 +85,7 @@ std::vector ConfigureSvcNormalVideo(size_t input_width, spatial_layer.minBitrate = std::max(static_cast(min_bitrate), kMinVp9SvcBitrateKbps); spatial_layer.maxBitrate = - static_cast((1.6 * num_pixels + 50 * 1000) / 1000); + static_cast((1.6 * num_pixels + 50 * 1000) / 1000); spatial_layer.targetBitrate = (spatial_layer.minBitrate + spatial_layer.maxBitrate) / 2; spatial_layers.push_back(spatial_layer); diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc index 7a1e2aba3b..24f86aae98 100644 --- a/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -15,10 +15,10 @@ #include #include -#include "vpx/vpx_encoder.h" -#include "vpx/vpx_decoder.h" #include "vpx/vp8cx.h" #include "vpx/vp8dx.h" +#include "vpx/vpx_decoder.h" +#include "vpx/vpx_encoder.h" #include "common_video/include/video_frame_buffer.h" #include "common_video/libyuv/include/webrtc_libyuv.h" @@ -164,9 +164,8 @@ bool VP9EncoderImpl::SetSvcRates( RTC_LOG(LS_ERROR) << "Scaling factors not specified!"; return false; } - rate_ratio[i] = - static_cast(svc_params_.scaling_factor_num[i]) / - svc_params_.scaling_factor_den[i]; + rate_ratio[i] = static_cast(svc_params_.scaling_factor_num[i]) / + svc_params_.scaling_factor_den[i]; total += rate_ratio[i]; } @@ -409,7 +408,7 @@ int VP9EncoderImpl::NumberOfThreads(int width, } else if (width * height >= 640 * 360 && number_of_cores > 2) { return 2; } else { - // Use 2 threads for low res on ARM. +// Use 2 threads for low res on ARM. #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \ defined(WEBRTC_ANDROID) if (width * height >= 320 * 180 && number_of_cores > 2) { @@ -531,7 +530,7 @@ int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) { vpx_codec_control(encoder_, VP9E_SET_ROW_MT, 1); #if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \ - !defined(ANDROID) + !defined(ANDROID) // Do not enable the denoiser on ARM since optimization is pending. // Denoiser is on by default on other platforms. vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY, @@ -716,11 +715,9 @@ void VP9EncoderImpl::PopulateCodecSpecific(CodecSpecificInfo* codec_specific, if (vp9_info->ss_data_available) { vp9_info->spatial_layer_resolution_present = true; for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) { - vp9_info->width[i] = codec_.width * - svc_params_.scaling_factor_num[i] / + vp9_info->width[i] = codec_.width * svc_params_.scaling_factor_num[i] / svc_params_.scaling_factor_den[i]; - vp9_info->height[i] = codec_.height * - svc_params_.scaling_factor_num[i] / + vp9_info->height[i] = codec_.height * svc_params_.scaling_factor_num[i] / svc_params_.scaling_factor_den[i]; } if (!vp9_info->flexible_mode) { diff --git a/modules/video_coding/encoded_frame.h b/modules/video_coding/encoded_frame.h index 80f0dcc86b..17c61d7544 100644 --- a/modules/video_coding/encoded_frame.h +++ b/modules/video_coding/encoded_frame.h @@ -29,19 +29,19 @@ class VCMEncodedFrame : protected EncodedImage { ~VCMEncodedFrame(); /** - * Delete VideoFrame and resets members to zero - */ + * Delete VideoFrame and resets members to zero + */ void Free(); /** - * Set render time in milliseconds - */ + * Set render time in milliseconds + */ void SetRenderTime(const int64_t renderTimeMs) { _renderTimeMs = renderTimeMs; } /** - * Set the encoded frame size - */ + * Set the encoded frame size + */ void SetEncodedSize(uint32_t width, uint32_t height) { _encodedWidth = width; _encodedHeight = height; @@ -52,34 +52,34 @@ class VCMEncodedFrame : protected EncodedImage { } /** - * Get the encoded image - */ + * Get the encoded image + */ const webrtc::EncodedImage& EncodedImage() const { return static_cast(*this); } /** - * Get pointer to frame buffer - */ + * Get pointer to frame buffer + */ const uint8_t* Buffer() const { return _buffer; } /** - * Get frame length - */ + * Get frame length + */ size_t Length() const { return _length; } /** - * Get frame timestamp (90kHz) - */ + * Get frame timestamp (90kHz) + */ uint32_t TimeStamp() const { return _timeStamp; } /** - * Get render time in milliseconds - */ + * Get render time in milliseconds + */ int64_t RenderTimeMs() const { return _renderTimeMs; } /** - * Get frame type - */ + * Get frame type + */ webrtc::FrameType FrameType() const { return _frameType; } /** - * Get frame rotation - */ + * Get frame rotation + */ VideoRotation rotation() const { return rotation_; } /** * Get video content type @@ -94,30 +94,30 @@ class VCMEncodedFrame : protected EncodedImage { */ bool Complete() const { return _completeFrame; } /** - * True if there's a frame missing before this frame - */ + * True if there's a frame missing before this frame + */ bool MissingFrame() const { return _missingFrame; } /** - * Payload type of the encoded payload - */ + * Payload type of the encoded payload + */ uint8_t PayloadType() const { return _payloadType; } /** - * Get codec specific info. - * The returned pointer is only valid as long as the VCMEncodedFrame - * is valid. Also, VCMEncodedFrame owns the pointer and will delete - * the object. - */ + * Get codec specific info. + * The returned pointer is only valid as long as the VCMEncodedFrame + * is valid. Also, VCMEncodedFrame owns the pointer and will delete + * the object. + */ const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } protected: /** - * Verifies that current allocated buffer size is larger than or equal to the - * input size. - * If the current buffer size is smaller, a new allocation is made and the old - * buffer data - * is copied to the new buffer. - * Buffer size is updated to minimumSize. - */ + * Verifies that current allocated buffer size is larger than or equal to the + * input size. + * If the current buffer size is smaller, a new allocation is made and the old + * buffer data + * is copied to the new buffer. + * Buffer size is updated to minimumSize. + */ void VerifyAndAllocate(size_t minimumSize); void Reset(); diff --git a/modules/video_coding/frame_buffer.h b/modules/video_coding/frame_buffer.h index 2fc2d212be..66f338a4cf 100644 --- a/modules/video_coding/frame_buffer.h +++ b/modules/video_coding/frame_buffer.h @@ -14,8 +14,8 @@ #include #include "modules/include/module_common_types.h" -#include "modules/video_coding/include/video_coding.h" #include "modules/video_coding/encoded_frame.h" +#include "modules/video_coding/include/video_coding.h" #include "modules/video_coding/jitter_buffer_common.h" #include "modules/video_coding/session_info.h" #include "typedefs.h" // NOLINT(build/include) @@ -71,7 +71,6 @@ class VCMFrameBuffer : public VCMEncodedFrame { webrtc::FrameType FrameType() const; - private: void SetState(VCMFrameBufferStateEnum state); // Set state of frame diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index 580bfc9bc0..01500e7f89 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -32,8 +32,7 @@ VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing, _clock->CurrentNtpInMilliseconds() - _clock->TimeInMilliseconds(); } -VCMDecodedFrameCallback::~VCMDecodedFrameCallback() { -} +VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {} void VCMDecodedFrameCallback::SetUserReceiveCallback( VCMReceiveCallback* receiveCallback) { @@ -141,8 +140,8 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, _timing->SetTimingFrameInfo(timing_frame_info); } - decodedImage.set_timestamp_us( - frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); + decodedImage.set_timestamp_us(frameInfo->renderTimeMs * + rtc::kNumMicrosecsPerMillisec); decodedImage.set_rotation(frameInfo->rotation); _receiveCallback->FrameToRender(decodedImage, qp, frameInfo->content_type); } @@ -211,39 +210,39 @@ int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, } int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) { - TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", - frame.EncodedImage()._timeStamp); - _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; - _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); - _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); - _frameInfos[_nextFrameInfoIdx].timing = frame.video_timing(); - // Set correctly only for key frames. Thus, use latest key frame - // content type. If the corresponding key frame was lost, decode will fail - // and content type will be ignored. - if (frame.FrameType() == kVideoFrameKey) { - _frameInfos[_nextFrameInfoIdx].content_type = frame.contentType(); - _last_keyframe_content_type = frame.contentType(); - } else { - _frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type; - } - _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); + TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", + frame.EncodedImage()._timeStamp); + _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; + _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); + _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); + _frameInfos[_nextFrameInfoIdx].timing = frame.video_timing(); + // Set correctly only for key frames. Thus, use latest key frame + // content type. If the corresponding key frame was lost, decode will fail + // and content type will be ignored. + if (frame.FrameType() == kVideoFrameKey) { + _frameInfos[_nextFrameInfoIdx].content_type = frame.contentType(); + _last_keyframe_content_type = frame.contentType(); + } else { + _frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type; + } + _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); - _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; - int32_t ret = decoder_->Decode(frame.EncodedImage(), frame.MissingFrame(), - frame.CodecSpecific(), frame.RenderTimeMs()); + _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; + int32_t ret = decoder_->Decode(frame.EncodedImage(), frame.MissingFrame(), + frame.CodecSpecific(), frame.RenderTimeMs()); - _callback->OnDecoderImplementationName(decoder_->ImplementationName()); - if (ret < WEBRTC_VIDEO_CODEC_OK) { - RTC_LOG(LS_WARNING) << "Failed to decode frame with timestamp " - << frame.TimeStamp() << ", error code: " << ret; - _callback->Pop(frame.TimeStamp()); - return ret; - } else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || - ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) { - // No output - _callback->Pop(frame.TimeStamp()); - } + _callback->OnDecoderImplementationName(decoder_->ImplementationName()); + if (ret < WEBRTC_VIDEO_CODEC_OK) { + RTC_LOG(LS_WARNING) << "Failed to decode frame with timestamp " + << frame.TimeStamp() << ", error code: " << ret; + _callback->Pop(frame.TimeStamp()); return ret; + } else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || + ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) { + // No output + _callback->Pop(frame.TimeStamp()); + } + return ret; } int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback( diff --git a/modules/video_coding/generic_decoder.h b/modules/video_coding/generic_decoder.h index 8137b2069f..17d2897d63 100644 --- a/modules/video_coding/generic_decoder.h +++ b/modules/video_coding/generic_decoder.h @@ -81,20 +81,20 @@ class VCMGenericDecoder { ~VCMGenericDecoder(); /** - * Initialize the decoder with the information from the VideoCodec - */ + * Initialize the decoder with the information from the VideoCodec + */ int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores); /** - * Decode to a raw I420 frame, - * - * inputVideoBuffer reference to encoded video frame - */ + * Decode to a raw I420 frame, + * + * inputVideoBuffer reference to encoded video frame + */ int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs); /** - * Set decode callback. Deregistering while decoding is illegal. - */ + * Set decode callback. Deregistering while decoding is illegal. + */ int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); bool External() const; diff --git a/modules/video_coding/generic_encoder.cc b/modules/video_coding/generic_encoder.cc index 202cc8625d..7eb35e78da 100644 --- a/modules/video_coding/generic_encoder.cc +++ b/modules/video_coding/generic_encoder.cc @@ -1,12 +1,12 @@ /* -* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -* -* 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. -*/ + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * 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. + */ #include "modules/video_coding/generic_encoder.h" @@ -70,8 +70,8 @@ int32_t VCMGenericEncoder::InitEncode(const VideoCodec* settings, if (encoder_->InitEncode(settings, number_of_cores, max_payload_size) != 0) { RTC_LOG(LS_ERROR) << "Failed to initialize the encoder associated with " "codec type: " - << CodecTypeToPayloadString(settings->codecType) - << " (" << settings->codecType <<")"; + << CodecTypeToPayloadString(settings->codecType) << " (" + << settings->codecType << ")"; return -1; } vcm_encoded_frame_callback_->Reset(); @@ -151,9 +151,9 @@ int32_t VCMGenericEncoder::RequestFrame( // VideoSendStreamTest.VideoSendStreamStopSetEncoderRateToZero, set // internal_source to true and use FakeEncoder. And the latter will // happily encode this 1x1 frame and pass it on down the pipeline. - return encoder_->Encode(VideoFrame(I420Buffer::Create(1, 1), - kVideoRotation_0, 0), - NULL, &frame_types); + return encoder_->Encode( + VideoFrame(I420Buffer::Create(1, 1), kVideoRotation_0, 0), NULL, + &frame_types); return 0; } diff --git a/modules/video_coding/h264_sps_pps_tracker_unittest.cc b/modules/video_coding/h264_sps_pps_tracker_unittest.cc index f88992f28b..0ad85ac057 100644 --- a/modules/video_coding/h264_sps_pps_tracker_unittest.cc +++ b/modules/video_coding/h264_sps_pps_tracker_unittest.cc @@ -12,9 +12,9 @@ #include +#include "common_video/h264/h264_common.h" #include "modules/video_coding/packet.h" #include "test/gtest.h" -#include "common_video/h264/h264_common.h" namespace webrtc { namespace video_coding { diff --git a/modules/video_coding/include/video_codec_interface.h b/modules/video_coding/include/video_codec_interface.h index d61a926fee..1b5e155e47 100644 --- a/modules/video_coding/include/video_codec_interface.h +++ b/modules/video_coding/include/video_codec_interface.h @@ -37,8 +37,8 @@ struct CodecSpecificInfoVP8 { struct CodecSpecificInfoVP9 { bool first_frame_in_picture; // First frame, increment picture_id. - bool inter_pic_predicted; // This layer frame is dependent on previously - // coded frame(s). + bool inter_pic_predicted; // This layer frame is dependent on previously + // coded frame(s). bool flexible_mode; bool ss_data_available; bool non_ref_for_inter_layer_pred; diff --git a/modules/video_coding/include/video_coding.h b/modules/video_coding/include/video_coding.h index 61ce66a912..e5c30ebf2d 100644 --- a/modules/video_coding/include/video_coding.h +++ b/modules/video_coding/include/video_coding.h @@ -72,8 +72,8 @@ class VideoCodingModule : public Module { static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory); /* - * Sender - */ + * Sender + */ // Registers a codec to be used for encoding. Calling this // API multiple times overwrites any previously registered codecs. @@ -182,8 +182,8 @@ class VideoCodingModule : public Module { virtual int32_t EnableFrameDropper(bool enable) = 0; /* - * Receiver - */ + * Receiver + */ // Register possible receive codecs, can be called multiple times for // different codecs. diff --git a/modules/video_coding/jitter_buffer.cc b/modules/video_coding/jitter_buffer.cc index 6e688fd2b2..5f45ece595 100644 --- a/modules/video_coding/jitter_buffer.cc +++ b/modules/video_coding/jitter_buffer.cc @@ -761,9 +761,8 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet, } else { incomplete_frames_.InsertFrame(frame); // If NACKs are enabled, keyframes are triggered by |GetNackList|. - if (nack_mode_ == kNoNack && - NonContinuousOrIncompleteDuration() > - 90 * kMaxDiscontinuousFramesTime) { + if (nack_mode_ == kNoNack && NonContinuousOrIncompleteDuration() > + 90 * kMaxDiscontinuousFramesTime) { return kFlushIndicator; } } @@ -777,9 +776,8 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet, } else { incomplete_frames_.InsertFrame(frame); // If NACKs are enabled, keyframes are triggered by |GetNackList|. - if (nack_mode_ == kNoNack && - NonContinuousOrIncompleteDuration() > - 90 * kMaxDiscontinuousFramesTime) { + if (nack_mode_ == kNoNack && NonContinuousOrIncompleteDuration() > + 90 * kMaxDiscontinuousFramesTime) { return kFlushIndicator; } } diff --git a/modules/video_coding/jitter_buffer_unittest.cc b/modules/video_coding/jitter_buffer_unittest.cc index a1447c060b..71c17ea6c8 100644 --- a/modules/video_coding/jitter_buffer_unittest.cc +++ b/modules/video_coding/jitter_buffer_unittest.cc @@ -214,8 +214,7 @@ class TestBasicJitterBuffer : public ::testing::TestWithParam, clock_.reset(new SimulatedClock(0)); jitter_buffer_.reset(new VCMJitterBuffer( clock_.get(), - std::unique_ptr(event_factory_.CreateEvent()), - this, + std::unique_ptr(event_factory_.CreateEvent()), this, this)); jitter_buffer_->Start(); seq_num_ = 1234; @@ -333,8 +332,8 @@ class TestRunningJitterBuffer : public ::testing::TestWithParam, oldest_packet_to_nack_ = 250; jitter_buffer_ = new VCMJitterBuffer( clock_.get(), - std::unique_ptr(event_factory_.CreateEvent()), - this, this); + std::unique_ptr(event_factory_.CreateEvent()), this, + this); stream_generator_ = new StreamGenerator(0, clock_->TimeInMilliseconds()); jitter_buffer_->Start(); jitter_buffer_->SetNackSettings(max_nack_list_size_, oldest_packet_to_nack_, diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc index 41db158cca..5e754f1088 100644 --- a/modules/video_coding/jitter_estimator.cc +++ b/modules/video_coding/jitter_estimator.cc @@ -139,10 +139,10 @@ void VCMJitterEstimator::UpdateEstimate(int64_t frameDelayMS, // Update the variance anyway since we want to capture cases where we only // get // key frames. - _varFrameSize = VCM_MAX(_phi * _varFrameSize + - (1 - _phi) * (frameSizeBytes - avgFrameSize) * - (frameSizeBytes - avgFrameSize), - 1.0); + _varFrameSize = VCM_MAX( + _phi * _varFrameSize + (1 - _phi) * (frameSizeBytes - avgFrameSize) * + (frameSizeBytes - avgFrameSize), + 1.0); } // Update max frameSize estimate diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc index e3083b0504..aea35b04dd 100644 --- a/modules/video_coding/media_opt_util.cc +++ b/modules/video_coding/media_opt_util.cc @@ -19,8 +19,8 @@ #include "modules/include/module_common_types.h" #include "modules/video_coding/codecs/vp8/include/vp8_common_types.h" -#include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/fec_rate_table.h" +#include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/nack_fec_tables.h" namespace webrtc { @@ -285,9 +285,8 @@ bool VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) { // Average number of packets per frame (source and fec): const uint8_t avgTotPackets = static_cast( std::min(static_cast(std::numeric_limits::max()), - 1.5f + - static_cast(bitRatePerFrame) * 1000.0f / - static_cast(8.0 * _maxPayloadSize))); + 1.5f + static_cast(bitRatePerFrame) * 1000.0f / + static_cast(8.0 * _maxPayloadSize))); // FEC rate parameters: for P and I frame uint8_t codeRateDelta = 0; diff --git a/modules/video_coding/media_optimization.cc b/modules/video_coding/media_optimization.cc index ea70f3f47c..5433edbab7 100644 --- a/modules/video_coding/media_optimization.cc +++ b/modules/video_coding/media_optimization.cc @@ -30,8 +30,7 @@ MediaOptimization::MediaOptimization(Clock* clock) memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); } -MediaOptimization::~MediaOptimization(void) { -} +MediaOptimization::~MediaOptimization(void) {} void MediaOptimization::Reset() { rtc::CritScope lock(&crit_sect_); diff --git a/modules/video_coding/nack_module.h b/modules/video_coding/nack_module.h index 5640ea89b8..fc2f2a7977 100644 --- a/modules/video_coding/nack_module.h +++ b/modules/video_coding/nack_module.h @@ -12,8 +12,8 @@ #define MODULES_VIDEO_CODING_NACK_MODULE_H_ #include -#include #include +#include #include "modules/include/module.h" #include "modules/include/module_common_types.h" diff --git a/modules/video_coding/rtp_frame_reference_finder.cc b/modules/video_coding/rtp_frame_reference_finder.cc index 9401243245..396935cdbb 100644 --- a/modules/video_coding/rtp_frame_reference_finder.cc +++ b/modules/video_coding/rtp_frame_reference_finder.cc @@ -572,7 +572,7 @@ void RtpFrameReferenceFinder::FrameReceivedVp9(uint16_t picture_id, last_picture_id = Add(last_picture_id, 1); while (last_picture_id != picture_id) { - gof_idx = (gof_idx + 1) % gof_size; + gof_idx = (gof_idx + 1) % gof_size; RTC_CHECK(gof_idx < kMaxVp9FramesInGof); size_t temporal_idx = info->gof->temporal_idx[gof_idx]; diff --git a/modules/video_coding/rtp_frame_reference_finder.h b/modules/video_coding/rtp_frame_reference_finder.h index 00e638dd75..d7d1c1260c 100644 --- a/modules/video_coding/rtp_frame_reference_finder.h +++ b/modules/video_coding/rtp_frame_reference_finder.h @@ -12,9 +12,9 @@ #define MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_ #include +#include #include #include -#include #include #include diff --git a/modules/video_coding/test/test_util.h b/modules/video_coding/test/test_util.h index 404e49ebcf..a38fc58b12 100644 --- a/modules/video_coding/test/test_util.h +++ b/modules/video_coding/test/test_util.h @@ -18,6 +18,7 @@ class NullEventFactory : public webrtc::EventFactory { virtual ~NullEventFactory() {} webrtc::EventWrapper* CreateEvent() override { return new NullEvent; } + private: // Private class to avoid more dependencies on it in tests. class NullEvent : public webrtc::EventWrapper { diff --git a/modules/video_coding/utility/ivf_file_writer.cc b/modules/video_coding/utility/ivf_file_writer.cc index 4b2cf3dda5..d9342f6852 100644 --- a/modules/video_coding/utility/ivf_file_writer.cc +++ b/modules/video_coding/utility/ivf_file_writer.cc @@ -122,8 +122,7 @@ bool IvfFileWriter::InitFromFirstFrame(const EncodedImage& encoded_image, if (!WriteHeader()) return false; - const char* codec_name = - CodecTypeToPayloadString(codec_type_); + const char* codec_name = CodecTypeToPayloadString(codec_type_); RTC_LOG(LS_WARNING) << "Created IVF file for codec data of type " << codec_name << " at resolution " << width_ << " x " << height_ << ", using " diff --git a/modules/video_coding/utility/quality_scaler_unittest.cc b/modules/video_coding/utility/quality_scaler_unittest.cc index 58a381c5ac..b17062df5c 100644 --- a/modules/video_coding/utility/quality_scaler_unittest.cc +++ b/modules/video_coding/utility/quality_scaler_unittest.cc @@ -28,16 +28,16 @@ static const int kMinFramesNeededToScale = 60; // From quality_scaler.cc. static const size_t kDefaultTimeoutMs = 150; } // namespace -#define DO_SYNC(q, block) do { \ - rtc::Event event(false, false); \ - q->PostTask([this, &event] { \ - block; \ - event.Set(); \ - }); \ - RTC_CHECK(event.Wait(1000)); \ +#define DO_SYNC(q, block) \ + do { \ + rtc::Event event(false, false); \ + q->PostTask([this, &event] { \ + block; \ + event.Set(); \ + }); \ + RTC_CHECK(event.Wait(1000)); \ } while (0) - class MockAdaptationObserver : public AdaptationObserverInterface { public: MockAdaptationObserver() : event(false, false) {} @@ -87,7 +87,7 @@ class QualityScalerTest : public ::testing::Test, } ~QualityScalerTest() { - DO_SYNC(q_, {qs_.reset(nullptr);}); + DO_SYNC(q_, { qs_.reset(nullptr); }); } void TriggerScale(ScaleDirection scale_direction) { diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc index f8c83d3625..345fdcb943 100644 --- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc +++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc @@ -75,8 +75,8 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam { if (layer_bitrate == 0) { EXPECT_FALSE(actual.IsSpatialLayerUsed(i)); } - EXPECT_EQ(expected[i] * 1000U, layer_bitrate) << "Mismatch at index " - << i; + EXPECT_EQ(expected[i] * 1000U, layer_bitrate) + << "Mismatch at index " << i; sum += layer_bitrate; } EXPECT_EQ(sum, actual.get_sum_bps()); diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc index 8be04cd08d..7ef6cfe24a 100644 --- a/modules/video_coding/video_codec_initializer.cc +++ b/modules/video_coding/video_codec_initializer.cc @@ -33,8 +33,7 @@ bool VideoCodecInitializer::SetupCodec( if (config.codec_type == kVideoCodecMultiplex) { VideoEncoderConfig associated_config = config.Copy(); associated_config.codec_type = kVideoCodecVP9; - if (!SetupCodec(associated_config, streams, codec, - bitrate_allocator)) { + if (!SetupCodec(associated_config, streams, codec, bitrate_allocator)) { RTC_LOG(LS_ERROR) << "Failed to create stereo encoder configuration."; return false; } @@ -42,8 +41,7 @@ bool VideoCodecInitializer::SetupCodec( return true; } - *codec = - VideoEncoderConfigToVideoCodec(config, streams); + *codec = VideoEncoderConfigToVideoCodec(config, streams); *bitrate_allocator = CreateBitrateAllocator(*codec); return true; diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc index 104b149c00..4edf31ab01 100644 --- a/modules/video_coding/video_codec_initializer_unittest.cc +++ b/modules/video_coding/video_codec_initializer_unittest.cc @@ -76,8 +76,7 @@ class VideoCodecInitializerTest : public ::testing::Test { codec_out_ = VideoCodec(); bitrate_allocator_out_.reset(); temporal_layers_.clear(); - if (!VideoCodecInitializer::SetupCodec(config_, streams_, - &codec_out_, + if (!VideoCodecInitializer::SetupCodec(config_, streams_, &codec_out_, &bitrate_allocator_out_)) { return false; } diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc index a0a3a7f409..1127b0f340 100644 --- a/modules/video_coding/video_coding_impl.cc +++ b/modules/video_coding/video_coding_impl.cc @@ -100,9 +100,7 @@ class VideoCodingModuleImpl : public VideoCodingModule { return receiver_time; } - void Process() override { - receiver_.Process(); - } + void Process() override { receiver_.Process(); } int32_t RegisterSendCodec(const VideoCodec* sendCodec, uint32_t numberOfCores, @@ -125,8 +123,7 @@ class VideoCodingModuleImpl : public VideoCodingModule { int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder, uint8_t /* payloadType */, bool internalSource) override { - sender_.RegisterExternalEncoder(externalEncoder, - internalSource); + sender_.RegisterExternalEncoder(externalEncoder, internalSource); return 0; } diff --git a/modules/video_coding/video_coding_impl.h b/modules/video_coding/video_coding_impl.h index 4f96ad92f0..0f3903fd74 100644 --- a/modules/video_coding/video_coding_impl.h +++ b/modules/video_coding/video_coding_impl.h @@ -63,8 +63,7 @@ class VideoSender { public: typedef VideoCodingModule::SenderNackMode SenderNackMode; - VideoSender(Clock* clock, - EncodedImageCallback* post_encode_callback); + VideoSender(Clock* clock, EncodedImageCallback* post_encode_callback); ~VideoSender(); diff --git a/modules/video_coding/video_receiver.cc b/modules/video_coding/video_receiver.cc index 25b2908f0e..2ab69870a3 100644 --- a/modules/video_coding/video_receiver.cc +++ b/modules/video_coding/video_receiver.cc @@ -156,8 +156,7 @@ int32_t VideoReceiver::SetVideoProtection(VCMVideoProtection videoProtection, case kProtectionNackFEC: { RTC_DCHECK(enable); - _receiver.SetNackMode(kNack, - media_optimization::kLowRttNackMs, + _receiver.SetNackMode(kNack, media_optimization::kLowRttNackMs, media_optimization::kMaxRttDelayThreshold); _receiver.SetDecodeErrorMode(kNoErrors); break; diff --git a/modules/video_coding/video_receiver_unittest.cc b/modules/video_coding/video_receiver_unittest.cc index feca48ea59..2855f7a565 100644 --- a/modules/video_coding/video_receiver_unittest.cc +++ b/modules/video_coding/video_receiver_unittest.cc @@ -76,7 +76,7 @@ class TestVideoReceiver : public ::testing::Test { EXPECT_EQ(0, receiver_->IncomingPacket(payload, length, *header)); ++header->header.sequenceNumber; EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0); - receiver_->Process();; + receiver_->Process(); EXPECT_CALL(decoder_, Decode(_, _, _, _)).Times(1); EXPECT_EQ(0, receiver_->Decode(100)); } diff --git a/modules/video_coding/video_sender.cc b/modules/video_coding/video_sender.cc index ec24a97d1e..f10822d72b 100644 --- a/modules/video_coding/video_sender.cc +++ b/modules/video_coding/video_sender.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include // std::max #include "common_types.h" // NOLINT(build/include) @@ -137,8 +136,7 @@ void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, } return; } - _codecDataBase.RegisterExternalEncoder(externalEncoder, - internalSource); + _codecDataBase.RegisterExternalEncoder(externalEncoder, internalSource); } EncoderParameters VideoSender::UpdateEncoderParameters( @@ -291,8 +289,7 @@ int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame, RTC_LOG(LS_ERROR) << "Frame conversion failed, dropping frame."; return VCM_PARAMETER_ERROR; } - converted_frame = VideoFrame(converted_buffer, - converted_frame.timestamp(), + converted_frame = VideoFrame(converted_buffer, converted_frame.timestamp(), converted_frame.render_time_ms(), converted_frame.rotation()); } diff --git a/modules/video_coding/video_sender_unittest.cc b/modules/video_coding/video_sender_unittest.cc index 877eb99635..7321a08464 100644 --- a/modules/video_coding/video_sender_unittest.cc +++ b/modules/video_coding/video_sender_unittest.cc @@ -19,8 +19,8 @@ #include "modules/video_coding/include/mock/mock_vcm_callbacks.h" #include "modules/video_coding/include/mock/mock_video_codec_interface.h" #include "modules/video_coding/include/video_coding.h" -#include "modules/video_coding/video_coding_impl.h" #include "modules/video_coding/utility/default_video_bitrate_allocator.h" +#include "modules/video_coding/video_coding_impl.h" #include "system_wrappers/include/clock.h" #include "test/frame_generator.h" #include "test/gtest.h" @@ -228,17 +228,16 @@ class TestVideoSenderWithMockEncoder : public TestVideoSender { ExpectEncodeWithFrameTypes(stream, false); } - void ExpectInitialKeyFrames() { - ExpectEncodeWithFrameTypes(-1, true); - } + void ExpectInitialKeyFrames() { ExpectEncodeWithFrameTypes(-1, true); } void ExpectEncodeWithFrameTypes(int intra_request_stream, bool first_frame) { if (intra_request_stream == -1) { // No intra request expected, keyframes on first frame. FrameType frame_type = first_frame ? kVideoFrameKey : kVideoFrameDelta; - EXPECT_CALL(encoder_, - Encode(_, _, Pointee(ElementsAre(frame_type, frame_type, - frame_type)))) + EXPECT_CALL( + encoder_, + Encode(_, _, + Pointee(ElementsAre(frame_type, frame_type, frame_type)))) .Times(1) .WillRepeatedly(Return(0)); return; @@ -248,9 +247,10 @@ class TestVideoSenderWithMockEncoder : public TestVideoSender { ASSERT_LT(intra_request_stream, kNumberOfStreams); std::vector frame_types(kNumberOfStreams, kVideoFrameDelta); frame_types[intra_request_stream] = kVideoFrameKey; - EXPECT_CALL(encoder_, - Encode(_, _, Pointee(ElementsAreArray(&frame_types[0], - frame_types.size())))) + EXPECT_CALL( + encoder_, + Encode(_, _, + Pointee(ElementsAreArray(&frame_types[0], frame_types.size())))) .Times(1) .WillRepeatedly(Return(0)); } diff --git a/modules/video_processing/test/denoiser_test.cc b/modules/video_processing/test/denoiser_test.cc index 601ae0ed4a..327b16ed40 100644 --- a/modules/video_processing/test/denoiser_test.cc +++ b/modules/video_processing/test/denoiser_test.cc @@ -14,8 +14,8 @@ #include "common_video/include/i420_buffer_pool.h" #include "modules/video_processing/video_denoiser.h" -#include "test/gtest.h" #include "test/frame_utils.h" +#include "test/gtest.h" #include "test/testsupport/fileutils.h" namespace webrtc { diff --git a/modules/video_processing/util/denoiser_filter_sse2.cc b/modules/video_processing/util/denoiser_filter_sse2.cc index 83b7e54feb..49d2548854 100644 --- a/modules/video_processing/util/denoiser_filter_sse2.cc +++ b/modules/video_processing/util/denoiser_filter_sse2.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include "modules/video_processing/util/denoiser_filter_sse2.h" +#include namespace webrtc { diff --git a/modules/video_processing/util/skin_detection.cc b/modules/video_processing/util/skin_detection.cc index 8eaa2c5a9c..c711a90385 100644 --- a/modules/video_processing/util/skin_detection.cc +++ b/modules/video_processing/util/skin_detection.cc @@ -16,11 +16,14 @@ namespace webrtc { // Fixed-point skin color model parameters. -static const int skin_mean[5][2] = { - {7463, 9614}, {6400, 10240}, {7040, 10240}, {8320, 9280}, {6800, 9614}}; +static const int skin_mean[5][2] = {{7463, 9614}, + {6400, 10240}, + {7040, 10240}, + {8320, 9280}, + {6800, 9614}}; static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157}; // q16 -static const int skin_threshold[6] = {1570636, 1400000, 800000, 800000, 800000, - 800000}; // q18 +static const int skin_threshold[6] = {1570636, 1400000, 800000, + 800000, 800000, 800000}; // q18 // Thresholds on luminance. static const int y_low = 40; @@ -39,10 +42,9 @@ static int EvaluateSkinColorDifference(int cb, int cr, int idx) { const int cb_diff_q2 = (cb_diff_q12 + (1 << 9)) >> 10; const int cbcr_diff_q2 = (cbcr_diff_q12 + (1 << 9)) >> 10; const int cr_diff_q2 = (cr_diff_q12 + (1 << 9)) >> 10; - const int skin_diff = skin_inv_cov[0] * cb_diff_q2 + - skin_inv_cov[1] * cbcr_diff_q2 + - skin_inv_cov[2] * cbcr_diff_q2 + - skin_inv_cov[3] * cr_diff_q2; + const int skin_diff = + skin_inv_cov[0] * cb_diff_q2 + skin_inv_cov[1] * cbcr_diff_q2 + + skin_inv_cov[2] * cbcr_diff_q2 + skin_inv_cov[3] * cr_diff_q2; return skin_diff; } diff --git a/modules/video_processing/util/skin_detection.h b/modules/video_processing/util/skin_detection.h old mode 100755 new mode 100644 diff --git a/modules/video_processing/video_denoiser.cc b/modules/video_processing/video_denoiser.cc index a87f2496c8..cf262f0126 100644 --- a/modules/video_processing/video_denoiser.cc +++ b/modules/video_processing/video_denoiser.cc @@ -31,10 +31,14 @@ static void ShowRect(const std::unique_ptr& filter, const std::unique_ptr& moving_edge_red, const std::unique_ptr& x_density, const std::unique_ptr& y_density, - const uint8_t* u_src, int stride_u_src, - const uint8_t* v_src, int stride_v_src, - uint8_t* u_dst, int stride_u_dst, - uint8_t* v_dst, int stride_v_dst, + const uint8_t* u_src, + int stride_u_src, + const uint8_t* v_src, + int stride_v_src, + uint8_t* u_dst, + int stride_u_dst, + uint8_t* v_dst, + int stride_v_dst, int mb_rows_, int mb_cols_) { for (int mb_row = 0; mb_row < mb_rows_; ++mb_row) { @@ -323,20 +327,17 @@ rtc::scoped_refptr VideoDenoiser::DenoiseFrame( CopyLumaOnMargin(y_src, stride_y_src, y_dst, stride_y_dst); // Copy u/v planes. - libyuv::CopyPlane(frame->DataU(), frame->StrideU(), - dst->MutableDataU(), dst->StrideU(), - (width_ + 1) >> 1, (height_ + 1) >> 1); - libyuv::CopyPlane(frame->DataV(), frame->StrideV(), - dst->MutableDataV(), dst->StrideV(), - (width_ + 1) >> 1, (height_ + 1) >> 1); + libyuv::CopyPlane(frame->DataU(), frame->StrideU(), dst->MutableDataU(), + dst->StrideU(), (width_ + 1) >> 1, (height_ + 1) >> 1); + libyuv::CopyPlane(frame->DataV(), frame->StrideV(), dst->MutableDataV(), + dst->StrideV(), (width_ + 1) >> 1, (height_ + 1) >> 1); #if DISPLAY || DISPLAYNEON // Show rectangular region ShowRect(filter_, moving_edge_, moving_object_, x_density_, y_density_, frame->DataU(), frame->StrideU(), frame->DataV(), frame->StrideV(), - dst->MutableDataU(), dst->StrideU(), - dst->MutableDataV(), dst->StrideV(), - mb_rows_, mb_cols_); + dst->MutableDataU(), dst->StrideU(), dst->MutableDataV(), + dst->StrideV(), mb_rows_, mb_cols_); #endif prev_buffer_ = dst; return dst; diff --git a/ortc/ortcfactory_integrationtest.cc b/ortc/ortcfactory_integrationtest.cc index 5a61680bec..016aacc0ee 100644 --- a/ortc/ortcfactory_integrationtest.cc +++ b/ortc/ortcfactory_integrationtest.cc @@ -227,8 +227,7 @@ class OrtcFactoryIntegrationTest : public testing::Test { new rtc::RefCountedObject( false /* remote */)); return rtc::scoped_refptr( - ortc_factory->CreateVideoTrack( - id, fake_video_track_sources_.back())); + ortc_factory->CreateVideoTrack(id, fake_video_track_sources_.back())); } // Helper function used to test two way RTP senders and receivers with basic @@ -325,15 +324,15 @@ class OrtcFactoryIntegrationTest : public testing::Test { fake_audio_capture_module2_->frames_received() > kDefaultNumFrames && fake_video_renderer2.num_rendered_frames() > kDefaultNumFrames, - kDefaultTimeout) << "Audio capture module 1 received " - << fake_audio_capture_module1_->frames_received() - << " frames, Video renderer 1 rendered " - << fake_video_renderer1.num_rendered_frames() - << " frames, Audio capture module 2 received " - << fake_audio_capture_module2_->frames_received() - << " frames, Video renderer 2 rendered " - << fake_video_renderer2.num_rendered_frames() - << " frames."; + kDefaultTimeout) + << "Audio capture module 1 received " + << fake_audio_capture_module1_->frames_received() + << " frames, Video renderer 1 rendered " + << fake_video_renderer1.num_rendered_frames() + << " frames, Audio capture module 2 received " + << fake_audio_capture_module2_->frames_received() + << " frames, Video renderer 2 rendered " + << fake_video_renderer2.num_rendered_frames() << " frames."; } else { WAIT(false, kReceivingDuration); rendered_video_frames1_ = fake_video_renderer1.num_rendered_frames(); diff --git a/ortc/rtptransportcontrolleradapter.cc b/ortc/rtptransportcontrolleradapter.cc index 5d5bf5ed7b..009b3addfc 100644 --- a/ortc/rtptransportcontrolleradapter.cc +++ b/ortc/rtptransportcontrolleradapter.cc @@ -127,8 +127,7 @@ RtpTransportControllerAdapter::~RtpTransportControllerAdapter() { } // Call must be destroyed on the worker thread. worker_thread_->Invoke( - RTC_FROM_HERE, - rtc::Bind(&RtpTransportControllerAdapter::Close_w, this)); + RTC_FROM_HERE, rtc::Bind(&RtpTransportControllerAdapter::Close_w, this)); } RTCErrorOr> @@ -636,8 +635,7 @@ RtpTransportControllerAdapter::RtpTransportControllerAdapter( remote_video_description_.AddCodec(dummy_video); worker_thread_->Invoke( - RTC_FROM_HERE, - rtc::Bind(&RtpTransportControllerAdapter::Init_w, this)); + RTC_FROM_HERE, rtc::Bind(&RtpTransportControllerAdapter::Init_w, this)); } // TODO(nisse): Duplicates corresponding method in PeerConnection (used diff --git a/p2p/base/asyncstuntcpsocket.cc b/p2p/base/asyncstuntcpsocket.cc index ef9d3c5f13..8bb796fd1d 100644 --- a/p2p/base/asyncstuntcpsocket.cc +++ b/p2p/base/asyncstuntcpsocket.cc @@ -39,16 +39,16 @@ AsyncStunTCPSocket* AsyncStunTCPSocket::Create( rtc::AsyncSocket* socket, const rtc::SocketAddress& bind_address, const rtc::SocketAddress& remote_address) { - return new AsyncStunTCPSocket(AsyncTCPSocketBase::ConnectSocket( - socket, bind_address, remote_address), false); + return new AsyncStunTCPSocket( + AsyncTCPSocketBase::ConnectSocket(socket, bind_address, remote_address), + false); } -AsyncStunTCPSocket::AsyncStunTCPSocket( - rtc::AsyncSocket* socket, bool listen) - : rtc::AsyncTCPSocketBase(socket, listen, kBufSize) { -} +AsyncStunTCPSocket::AsyncStunTCPSocket(rtc::AsyncSocket* socket, bool listen) + : rtc::AsyncTCPSocketBase(socket, listen, kBufSize) {} -int AsyncStunTCPSocket::Send(const void *pv, size_t cb, +int AsyncStunTCPSocket::Send(const void* pv, + size_t cb, const rtc::PacketOptions& options) { if (cb > kBufSize || cb < kPacketLenSize + kPacketLenOffset) { SetError(EMSGSIZE); @@ -121,12 +121,12 @@ void AsyncStunTCPSocket::ProcessInput(char* data, size_t* len) { } } -void AsyncStunTCPSocket::HandleIncomingConnection( - rtc::AsyncSocket* socket) { +void AsyncStunTCPSocket::HandleIncomingConnection(rtc::AsyncSocket* socket) { SignalNewConnection(this, new AsyncStunTCPSocket(socket, false)); } -size_t AsyncStunTCPSocket::GetExpectedLength(const void* data, size_t len, +size_t AsyncStunTCPSocket::GetExpectedLength(const void* data, + size_t len, int* pad_bytes) { *pad_bytes = 0; PacketLength pkt_len = diff --git a/p2p/base/asyncstuntcpsocket.h b/p2p/base/asyncstuntcpsocket.h index 15ca911b71..a299e61145 100644 --- a/p2p/base/asyncstuntcpsocket.h +++ b/p2p/base/asyncstuntcpsocket.h @@ -22,10 +22,9 @@ class AsyncStunTCPSocket : public rtc::AsyncTCPSocketBase { // Binds and connects |socket| and creates AsyncTCPSocket for // it. Takes ownership of |socket|. Returns NULL if bind() or // connect() fail (|socket| is destroyed in that case). - static AsyncStunTCPSocket* Create( - rtc::AsyncSocket* socket, - const rtc::SocketAddress& bind_address, - const rtc::SocketAddress& remote_address); + static AsyncStunTCPSocket* Create(rtc::AsyncSocket* socket, + const rtc::SocketAddress& bind_address, + const rtc::SocketAddress& remote_address); AsyncStunTCPSocket(rtc::AsyncSocket* socket, bool listen); @@ -39,8 +38,7 @@ class AsyncStunTCPSocket : public rtc::AsyncTCPSocketBase { // This method returns the message hdr + length written in the header. // This method also returns the number of padding bytes needed/added to the // turn message. |pad_bytes| should be used only when |is_turn| is true. - size_t GetExpectedLength(const void* data, size_t len, - int* pad_bytes); + size_t GetExpectedLength(const void* data, size_t len, int* pad_bytes); RTC_DISALLOW_COPY_AND_ASSIGN(AsyncStunTCPSocket); }; diff --git a/p2p/base/asyncstuntcpsocket_unittest.cc b/p2p/base/asyncstuntcpsocket_unittest.cc index c0f7fc0994..de9541941f 100644 --- a/p2p/base/asyncstuntcpsocket_unittest.cc +++ b/p2p/base/asyncstuntcpsocket_unittest.cc @@ -20,49 +20,34 @@ namespace cricket { static unsigned char kStunMessageWithZeroLength[] = { - 0x00, 0x01, 0x00, 0x00, // length of 0 (last 2 bytes) - 0x21, 0x12, 0xA4, 0x42, - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'a', 'b', + 0x00, 0x01, 0x00, 0x00, // length of 0 (last 2 bytes) + 0x21, 0x12, 0xA4, 0x42, '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', 'a', 'b', }; - static unsigned char kTurnChannelDataMessageWithZeroLength[] = { - 0x40, 0x00, 0x00, 0x00, // length of 0 (last 2 bytes) + 0x40, 0x00, 0x00, 0x00, // length of 0 (last 2 bytes) }; static unsigned char kTurnChannelDataMessage[] = { - 0x40, 0x00, 0x00, 0x10, - 0x21, 0x12, 0xA4, 0x42, - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'a', 'b', + 0x40, 0x00, 0x00, 0x10, 0x21, 0x12, 0xA4, 0x42, '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', }; static unsigned char kStunMessageWithInvalidLength[] = { - 0x00, 0x01, 0x00, 0x10, - 0x21, 0x12, 0xA4, 0x42, - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'a', 'b', + 0x00, 0x01, 0x00, 0x10, 0x21, 0x12, 0xA4, 0x42, '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', }; static unsigned char kTurnChannelDataMessageWithInvalidLength[] = { - 0x80, 0x00, 0x00, 0x20, - 0x21, 0x12, 0xA4, 0x42, - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'a', 'b', + 0x80, 0x00, 0x00, 0x20, 0x21, 0x12, 0xA4, 0x42, '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', }; static unsigned char kTurnChannelDataMessageWithOddLength[] = { - 0x40, 0x00, 0x00, 0x05, - 0x21, 0x12, 0xA4, 0x42, - '0', + 0x40, 0x00, 0x00, 0x05, 0x21, 0x12, 0xA4, 0x42, '0', }; - static const rtc::SocketAddress kClientAddr("11.11.11.11", 0); static const rtc::SocketAddress kServerAddr("22.22.22.22", 0); @@ -72,20 +57,18 @@ class AsyncStunTCPSocketTest : public testing::Test, AsyncStunTCPSocketTest() : vss_(new rtc::VirtualSocketServer()), thread_(vss_.get()) {} - virtual void SetUp() { - CreateSockets(); - } + virtual void SetUp() { CreateSockets(); } void CreateSockets() { - rtc::AsyncSocket* server = vss_->CreateAsyncSocket( - kServerAddr.family(), SOCK_STREAM); + rtc::AsyncSocket* server = + vss_->CreateAsyncSocket(kServerAddr.family(), SOCK_STREAM); server->Bind(kServerAddr); recv_socket_.reset(new AsyncStunTCPSocket(server, true)); recv_socket_->SignalNewConnection.connect( this, &AsyncStunTCPSocketTest::OnNewConnection); - rtc::AsyncSocket* client = vss_->CreateAsyncSocket( - kClientAddr.family(), SOCK_STREAM); + rtc::AsyncSocket* client = + vss_->CreateAsyncSocket(kClientAddr.family(), SOCK_STREAM); send_socket_.reset(AsyncStunTCPSocket::Create( client, kClientAddr, recv_socket_->GetLocalAddress())); send_socket_->SignalSentPacket.connect( @@ -94,8 +77,10 @@ class AsyncStunTCPSocketTest : public testing::Test, vss_->ProcessMessagesUntilIdle(); } - void OnReadPacket(rtc::AsyncPacketSocket* socket, const char* data, - size_t len, const rtc::SocketAddress& remote_addr, + void OnReadPacket(rtc::AsyncPacketSocket* socket, + const char* data, + size_t len, + const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time) { recv_packets_.push_back(std::string(data, len)); } @@ -108,14 +93,14 @@ class AsyncStunTCPSocketTest : public testing::Test, void OnNewConnection(rtc::AsyncPacketSocket* server, rtc::AsyncPacketSocket* new_socket) { listen_socket_.reset(new_socket); - new_socket->SignalReadPacket.connect( - this, &AsyncStunTCPSocketTest::OnReadPacket); + new_socket->SignalReadPacket.connect(this, + &AsyncStunTCPSocketTest::OnReadPacket); } bool Send(const void* data, size_t len) { rtc::PacketOptions options; - size_t ret = send_socket_->Send( - reinterpret_cast(data), len, options); + size_t ret = + send_socket_->Send(reinterpret_cast(data), len, options); vss_->ProcessMessagesUntilIdle(); return (ret == len); } @@ -123,7 +108,7 @@ class AsyncStunTCPSocketTest : public testing::Test, bool CheckData(const void* data, int len) { bool ret = false; if (recv_packets_.size()) { - std::string packet = recv_packets_.front(); + std::string packet = recv_packets_.front(); recv_packets_.pop_front(); ret = (memcmp(data, packet.c_str(), len) == 0); } @@ -141,8 +126,8 @@ class AsyncStunTCPSocketTest : public testing::Test, // Testing a stun packet sent/recv properly. TEST_F(AsyncStunTCPSocketTest, TestSingleStunPacket) { - EXPECT_TRUE(Send(kStunMessageWithZeroLength, - sizeof(kStunMessageWithZeroLength))); + EXPECT_TRUE( + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength))); EXPECT_EQ(1u, recv_packets_.size()); EXPECT_TRUE(CheckData(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength))); @@ -150,14 +135,14 @@ TEST_F(AsyncStunTCPSocketTest, TestSingleStunPacket) { // Verify sending multiple packets. TEST_F(AsyncStunTCPSocketTest, TestMultipleStunPackets) { - EXPECT_TRUE(Send(kStunMessageWithZeroLength, - sizeof(kStunMessageWithZeroLength))); - EXPECT_TRUE(Send(kStunMessageWithZeroLength, - sizeof(kStunMessageWithZeroLength))); - EXPECT_TRUE(Send(kStunMessageWithZeroLength, - sizeof(kStunMessageWithZeroLength))); - EXPECT_TRUE(Send(kStunMessageWithZeroLength, - sizeof(kStunMessageWithZeroLength))); + EXPECT_TRUE( + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength))); + EXPECT_TRUE( + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength))); + EXPECT_TRUE( + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength))); + EXPECT_TRUE( + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength))); EXPECT_EQ(4u, recv_packets_.size()); } @@ -172,11 +157,10 @@ TEST_F(AsyncStunTCPSocketTest, TestTurnChannelDataWithZeroLength) { // Verifying TURN channel data message. TEST_F(AsyncStunTCPSocketTest, TestTurnChannelData) { - EXPECT_TRUE(Send(kTurnChannelDataMessage, - sizeof(kTurnChannelDataMessage))); + EXPECT_TRUE(Send(kTurnChannelDataMessage, sizeof(kTurnChannelDataMessage))); EXPECT_EQ(1u, recv_packets_.size()); - EXPECT_TRUE(CheckData(kTurnChannelDataMessage, - sizeof(kTurnChannelDataMessage))); + EXPECT_TRUE( + CheckData(kTurnChannelDataMessage, sizeof(kTurnChannelDataMessage))); } // Verifying TURN channel messages which needs padding handled properly. @@ -210,18 +194,18 @@ TEST_F(AsyncStunTCPSocketTest, TestStunInvalidLength) { // Verifying TURN channel data message with invalid length. TEST_F(AsyncStunTCPSocketTest, TestTurnChannelDataWithInvalidLength) { EXPECT_FALSE(Send(kTurnChannelDataMessageWithInvalidLength, - sizeof(kTurnChannelDataMessageWithInvalidLength))); + sizeof(kTurnChannelDataMessageWithInvalidLength))); // Modify the length to larger value. kTurnChannelDataMessageWithInvalidLength[2] = 0xFF; kTurnChannelDataMessageWithInvalidLength[3] = 0xF0; EXPECT_FALSE(Send(kTurnChannelDataMessageWithInvalidLength, - sizeof(kTurnChannelDataMessageWithInvalidLength))); + sizeof(kTurnChannelDataMessageWithInvalidLength))); // Modify the length to smaller value. kTurnChannelDataMessageWithInvalidLength[2] = 0x00; kTurnChannelDataMessageWithInvalidLength[3] = 0x00; EXPECT_FALSE(Send(kTurnChannelDataMessageWithInvalidLength, - sizeof(kTurnChannelDataMessageWithInvalidLength))); + sizeof(kTurnChannelDataMessageWithInvalidLength))); } // Verifying a small buffer handled (dropped) properly. This will be diff --git a/p2p/base/basicpacketsocketfactory.cc b/p2p/base/basicpacketsocketfactory.cc index 31761c6c83..b7eb8ed1c6 100644 --- a/p2p/base/basicpacketsocketfactory.cc +++ b/p2p/base/basicpacketsocketfactory.cc @@ -27,23 +27,16 @@ namespace rtc { BasicPacketSocketFactory::BasicPacketSocketFactory() - : thread_(Thread::Current()), - socket_factory_(NULL) { -} + : thread_(Thread::Current()), socket_factory_(NULL) {} BasicPacketSocketFactory::BasicPacketSocketFactory(Thread* thread) - : thread_(thread), - socket_factory_(NULL) { -} + : thread_(thread), socket_factory_(NULL) {} BasicPacketSocketFactory::BasicPacketSocketFactory( SocketFactory* socket_factory) - : thread_(NULL), - socket_factory_(socket_factory) { -} + : thread_(NULL), socket_factory_(socket_factory) {} -BasicPacketSocketFactory::~BasicPacketSocketFactory() { -} +BasicPacketSocketFactory::~BasicPacketSocketFactory() {} AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket( const SocketAddress& address, diff --git a/p2p/base/dtlstransport.cc b/p2p/base/dtlstransport.cc index 1bb1a6af2b..2a528a3db9 100644 --- a/p2p/base/dtlstransport.cc +++ b/p2p/base/dtlstransport.cc @@ -170,8 +170,7 @@ bool DtlsTransport::SetLocalCertificate( if (dtls_active_) { if (certificate == local_certificate_) { // This may happen during renegotiation. - RTC_LOG(LS_INFO) << ToString() - << ": Ignoring identical DTLS identity"; + RTC_LOG(LS_INFO) << ToString() << ": Ignoring identical DTLS identity"; return true; } else { RTC_LOG(LS_ERROR) << ToString() @@ -260,8 +259,7 @@ bool DtlsTransport::SetRemoteFingerprint(const std::string& digest_alg, // SetRemoteFingerprint shouldn't even be called though. if (digest_alg.empty()) { RTC_DCHECK(!digest_len); - RTC_LOG(LS_INFO) << ToString() - << ": Other side didn't support DTLS."; + RTC_LOG(LS_INFO) << ToString() << ": Other side didn't support DTLS."; dtls_active_ = false; return true; } @@ -343,8 +341,7 @@ bool DtlsTransport::SetupDtls() { dtls_.reset(rtc::SSLStreamAdapter::Create(downward)); if (!dtls_) { - RTC_LOG(LS_ERROR) << ToString() - << ": Failed to create DTLS adapter."; + RTC_LOG(LS_ERROR) << ToString() << ": Failed to create DTLS adapter."; delete downward; return false; } @@ -371,13 +368,11 @@ bool DtlsTransport::SetupDtls() { // Set up DTLS-SRTP, if it's been enabled. if (!srtp_ciphers_.empty()) { if (!dtls_->SetDtlsSrtpCryptoSuites(srtp_ciphers_)) { - RTC_LOG(LS_ERROR) << ToString() - << ": Couldn't set DTLS-SRTP ciphers."; + RTC_LOG(LS_ERROR) << ToString() << ": Couldn't set DTLS-SRTP ciphers."; return false; } } else { - RTC_LOG(LS_INFO) << ToString() - << ": Not using DTLS-SRTP."; + RTC_LOG(LS_INFO) << ToString() << ": Not using DTLS-SRTP."; } RTC_LOG(LS_INFO) << ToString() << ": DTLS setup complete."; @@ -496,10 +491,9 @@ void DtlsTransport::ConnectToIceTransport() { void DtlsTransport::OnWritableState(rtc::PacketTransportInternal* transport) { RTC_DCHECK(rtc::Thread::Current() == network_thread_); RTC_DCHECK(transport == ice_transport_); - RTC_LOG(LS_VERBOSE) - << ToString() - << ": ice_transport writable state changed to " - << ice_transport_->writable(); + RTC_LOG(LS_VERBOSE) << ToString() + << ": ice_transport writable state changed to " + << ice_transport_->writable(); if (!dtls_active_) { // Not doing DTLS. @@ -590,8 +584,7 @@ void DtlsTransport::OnReadPacket(rtc::PacketTransportInternal* transport, // Is this potentially a DTLS packet? if (IsDtlsPacket(data, size)) { if (!HandleDtlsPacket(data, size)) { - RTC_LOG(LS_ERROR) << ToString() - << ": Failed to handle DTLS packet."; + RTC_LOG(LS_ERROR) << ToString() << ": Failed to handle DTLS packet."; return; } } else { @@ -605,8 +598,8 @@ void DtlsTransport::OnReadPacket(rtc::PacketTransportInternal* transport, // And it had better be a SRTP packet. if (!IsRtpPacket(data, size)) { - RTC_LOG(LS_ERROR) << ToString() - << ": Received unexpected non-DTLS packet."; + RTC_LOG(LS_ERROR) + << ToString() << ": Received unexpected non-DTLS packet."; return; } @@ -642,8 +635,7 @@ void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { RTC_DCHECK(dtls == dtls_.get()); if (sig & rtc::SE_OPEN) { // This is the first time. - RTC_LOG(LS_INFO) << ToString() - << ": DTLS handshake complete."; + RTC_LOG(LS_INFO) << ToString() << ": DTLS handshake complete."; if (dtls_->GetState() == rtc::SS_OPEN) { // The check for OPEN shouldn't be necessary but let's make // sure we don't accidentally frob the state if it's closed. @@ -664,8 +656,7 @@ void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0); } else if (ret == rtc::SR_EOS) { // Remote peer shut down the association with no error. - RTC_LOG(LS_INFO) << ToString() - << ": DTLS transport closed"; + RTC_LOG(LS_INFO) << ToString() << ": DTLS transport closed"; set_writable(false); set_dtls_state(DTLS_TRANSPORT_CLOSED); } else if (ret == rtc::SR_ERROR) { @@ -681,12 +672,10 @@ void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself. set_writable(false); if (!err) { - RTC_LOG(LS_INFO) << ToString() - << ": DTLS transport closed"; + RTC_LOG(LS_INFO) << ToString() << ": DTLS transport closed"; set_dtls_state(DTLS_TRANSPORT_CLOSED); } else { - RTC_LOG(LS_INFO) << ToString() - << ": DTLS transport error, code=" << err; + RTC_LOG(LS_INFO) << ToString() << ": DTLS transport error, code=" << err; set_dtls_state(DTLS_TRANSPORT_FAILED); } } @@ -709,13 +698,11 @@ void DtlsTransport::MaybeStartDtls() { // ignore write errors, thus any errors must be because of // configuration and therefore are our fault. RTC_NOTREACHED() << "StartSSL failed."; - RTC_LOG(LS_ERROR) << ToString() - << ": Couldn't start DTLS handshake"; + RTC_LOG(LS_ERROR) << ToString() << ": Couldn't start DTLS handshake"; set_dtls_state(DTLS_TRANSPORT_FAILED); return; } - RTC_LOG(LS_INFO) << ToString() - << ": DtlsTransport: Started DTLS handshake"; + RTC_LOG(LS_INFO) << ToString() << ": DtlsTransport: Started DTLS handshake"; set_dtls_state(DTLS_TRANSPORT_CONNECTING); // Now that the handshake has started, we can process a cached ClientHello // (if one exists). @@ -725,8 +712,7 @@ void DtlsTransport::MaybeStartDtls() { << ": Handling cached DTLS ClientHello packet."; if (!HandleDtlsPacket(cached_client_hello_.data(), cached_client_hello_.size())) { - RTC_LOG(LS_ERROR) << ToString() - << ": Failed to handle DTLS packet."; + RTC_LOG(LS_ERROR) << ToString() << ": Failed to handle DTLS packet."; } } else { RTC_LOG(LS_WARNING) << ToString() @@ -773,8 +759,7 @@ void DtlsTransport::set_writable(bool writable) { if (writable_ == writable) { return; } - RTC_LOG(LS_VERBOSE) << ToString() - << ": set_writable to: " << writable; + RTC_LOG(LS_VERBOSE) << ToString() << ": set_writable to: " << writable; writable_ = writable; if (writable_) { SignalReadyToSend(this); @@ -786,9 +771,8 @@ void DtlsTransport::set_dtls_state(DtlsTransportState state) { if (dtls_state_ == state) { return; } - RTC_LOG(LS_VERBOSE) << ToString() - << ": set_dtls_state from:" << dtls_state_ << " to " - << state; + RTC_LOG(LS_VERBOSE) << ToString() << ": set_dtls_state from:" << dtls_state_ + << " to " << state; dtls_state_ = state; SignalDtlsState(this, state); } @@ -805,8 +789,7 @@ void DtlsTransport::ConfigureHandshakeTimeout() { // extreme values. int initial_timeout = std::max(kMinHandshakeTimeout, std::min(kMaxHandshakeTimeout, 2 * (*rtt))); - RTC_LOG(LS_INFO) << ToString() - << ": configuring DTLS handshake timeout " + RTC_LOG(LS_INFO) << ToString() << ": configuring DTLS handshake timeout " << initial_timeout << " based on ICE RTT " << *rtt; dtls_->SetInitialRetransmissionTimeout(initial_timeout); diff --git a/p2p/base/fakedtlstransport.h b/p2p/base/fakedtlstransport.h index 5907f070ad..2422ec9060 100644 --- a/p2p/base/fakedtlstransport.h +++ b/p2p/base/fakedtlstransport.h @@ -171,9 +171,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { *crypto_suite = crypto_suite_; return true; } - void SetSrtpCryptoSuite(int crypto_suite) { - crypto_suite_ = crypto_suite; - } + void SetSrtpCryptoSuite(int crypto_suite) { crypto_suite_ = crypto_suite; } bool GetSslCipherSuite(int* cipher_suite) override { return false; } rtc::scoped_refptr GetLocalCertificate() const override { return local_cert_; diff --git a/p2p/base/p2ptransportchannel.h b/p2p/base/p2ptransportchannel.h index 421bf8f8f2..bd1e001a1b 100644 --- a/p2p/base/p2ptransportchannel.h +++ b/p2p/base/p2ptransportchannel.h @@ -260,10 +260,10 @@ class P2PTransportChannel : public IceTransportInternal { void AddAllocatorSession(std::unique_ptr session); void AddConnection(Connection* connection); - void OnPortReady(PortAllocatorSession *session, PortInterface* port); + void OnPortReady(PortAllocatorSession* session, PortInterface* port); void OnPortsPruned(PortAllocatorSession* session, const std::vector& ports); - void OnCandidatesReady(PortAllocatorSession *session, + void OnCandidatesReady(PortAllocatorSession* session, const std::vector& candidates); void OnCandidatesRemoved(PortAllocatorSession* session, const std::vector& candidates); @@ -284,11 +284,13 @@ class P2PTransportChannel : public IceTransportInternal { void OnRoleConflict(PortInterface* port); void OnConnectionStateChange(Connection* connection); - void OnReadPacket(Connection *connection, const char *data, size_t len, + void OnReadPacket(Connection* connection, + const char* data, + size_t len, const rtc::PacketTime& packet_time); void OnSentPacket(const rtc::SentPacket& sent_packet); void OnReadyToSend(Connection* connection); - void OnConnectionDestroyed(Connection *connection); + void OnConnectionDestroyed(Connection* connection); void OnNominated(Connection* conn); @@ -376,7 +378,7 @@ class P2PTransportChannel : public IceTransportInternal { // |pinged_connections_| and |unpinged_connections_| has the same // connections as |connections_|. These 2 sets maintain whether a // connection should be pinged next or not. - std::vector connections_; + std::vector connections_; std::set pinged_connections_; std::set unpinged_connections_; diff --git a/p2p/base/p2ptransportchannel_unittest.cc b/p2p/base/p2ptransportchannel_unittest.cc index 39dfaa3507..89018ab3be 100644 --- a/p2p/base/p2ptransportchannel_unittest.cc +++ b/p2p/base/p2ptransportchannel_unittest.cc @@ -53,8 +53,8 @@ static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | cricket::PORTALLOCATOR_DISABLE_TCP; static const int LOW_RTT = 20; // Addresses on the public internet. -static const SocketAddress kPublicAddrs[2] = - { SocketAddress("11.11.11.11", 0), SocketAddress("22.22.22.22", 0) }; +static const SocketAddress kPublicAddrs[2] = {SocketAddress("11.11.11.11", 0), + SocketAddress("22.22.22.22", 0)}; // IPv6 Addresses on the public internet. static const SocketAddress kIPv6PublicAddrs[2] = { SocketAddress("2400:4030:1:2c00:be30:abcd:efab:cdef", 0), @@ -66,23 +66,23 @@ static const SocketAddress kIPv6AlternateAddrs[2] = { SocketAddress("2401:4030:1:2c00:be30:abcd:efab:cdef", 0), SocketAddress("2601:0:1000:1b03:2e41:38ff:fea6:f2a4", 0)}; // Addresses for HTTP proxy servers. -static const SocketAddress kHttpsProxyAddrs[2] = - { SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443) }; +static const SocketAddress kHttpsProxyAddrs[2] = { + SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443)}; // Addresses for SOCKS proxy servers. -static const SocketAddress kSocksProxyAddrs[2] = - { SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080) }; +static const SocketAddress kSocksProxyAddrs[2] = { + SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080)}; // Internal addresses for NAT boxes. -static const SocketAddress kNatAddrs[2] = - { SocketAddress("192.168.1.1", 0), SocketAddress("192.168.2.1", 0) }; +static const SocketAddress kNatAddrs[2] = {SocketAddress("192.168.1.1", 0), + SocketAddress("192.168.2.1", 0)}; // Private addresses inside the NAT private networks. -static const SocketAddress kPrivateAddrs[2] = - { SocketAddress("192.168.1.11", 0), SocketAddress("192.168.2.22", 0) }; +static const SocketAddress kPrivateAddrs[2] = { + SocketAddress("192.168.1.11", 0), SocketAddress("192.168.2.22", 0)}; // For cascaded NATs, the internal addresses of the inner NAT boxes. -static const SocketAddress kCascadedNatAddrs[2] = - { SocketAddress("192.168.10.1", 0), SocketAddress("192.168.20.1", 0) }; +static const SocketAddress kCascadedNatAddrs[2] = { + SocketAddress("192.168.10.1", 0), SocketAddress("192.168.20.1", 0)}; // For cascaded NATs, private addresses inside the inner private networks. -static const SocketAddress kCascadedPrivateAddrs[2] = - { SocketAddress("192.168.10.11", 0), SocketAddress("192.168.20.22", 0) }; +static const SocketAddress kCascadedPrivateAddrs[2] = { + SocketAddress("192.168.10.11", 0), SocketAddress("192.168.20.22", 0)}; // The address of the public STUN server. static const SocketAddress kStunAddr("99.99.99.1", cricket::STUN_SERVER_PORT); // The addresses for the public turn server. @@ -219,18 +219,18 @@ class P2PTransportChannelTestBase : public testing::Test, protected: enum Config { - OPEN, // Open to the Internet - NAT_FULL_CONE, // NAT, no filtering - NAT_ADDR_RESTRICTED, // NAT, must send to an addr to recv - NAT_PORT_RESTRICTED, // NAT, must send to an addr+port to recv - NAT_SYMMETRIC, // NAT, endpoint-dependent bindings - NAT_DOUBLE_CONE, // Double NAT, both cone - NAT_SYMMETRIC_THEN_CONE, // Double NAT, symmetric outer, cone inner - BLOCK_UDP, // Firewall, UDP in/out blocked - BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked - BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443 - PROXY_HTTPS, // All traffic through HTTPS proxy - PROXY_SOCKS, // All traffic through SOCKS proxy + OPEN, // Open to the Internet + NAT_FULL_CONE, // NAT, no filtering + NAT_ADDR_RESTRICTED, // NAT, must send to an addr to recv + NAT_PORT_RESTRICTED, // NAT, must send to an addr+port to recv + NAT_SYMMETRIC, // NAT, endpoint-dependent bindings + NAT_DOUBLE_CONE, // Double NAT, both cone + NAT_SYMMETRIC_THEN_CONE, // Double NAT, symmetric outer, cone inner + BLOCK_UDP, // Firewall, UDP in/out blocked + BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked + BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443 + PROXY_HTTPS, // All traffic through HTTPS proxy + PROXY_SOCKS, // All traffic through SOCKS proxy NUM_CONFIGS }; @@ -260,7 +260,7 @@ class P2PTransportChannelTestBase : public testing::Test, bool CheckData(const char* data, int len) { bool ret = false; if (!ch_packets_.empty()) { - std::string packet = ch_packets_.front(); + std::string packet = ch_packets_.front(); ret = (packet == std::string(data, len)); ch_packets_.pop_front(); } @@ -458,8 +458,8 @@ class P2PTransportChannelTestBase : public testing::Test, void SetProxy(int endpoint, rtc::ProxyType type) { rtc::ProxyInfo info; info.type = type; - info.address = (type == rtc::PROXY_HTTPS) ? - kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; + info.address = (type == rtc::PROXY_HTTPS) ? kHttpsProxyAddrs[endpoint] + : kSocksProxyAddrs[endpoint]; GetAllocator(endpoint)->set_proxy("unittest/1.0", info); } void SetAllocatorFlags(int endpoint, int flags) { @@ -563,8 +563,8 @@ class P2PTransportChannelTestBase : public testing::Test, if (connect_time < expected.connect_wait) { RTC_LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; } else { - RTC_LOG(LS_INFO) << "Connect time: TIMEOUT (" - << expected.connect_wait << " ms)"; + RTC_LOG(LS_INFO) << "Connect time: TIMEOUT (" << expected.connect_wait + << " ms)"; } // Allow a few turns of the crank for the selected connections to emerge. @@ -588,8 +588,8 @@ class P2PTransportChannelTestBase : public testing::Test, if (converge_time < converge_wait) { RTC_LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; } else { - RTC_LOG(LS_INFO) << "Converge time: TIMEOUT (" - << converge_wait << " ms)"; + RTC_LOG(LS_INFO) << "Converge time: TIMEOUT (" << converge_wait + << " ms)"; } } // Try sending some data to other end. @@ -873,9 +873,7 @@ class P2PTransportChannelTestBase : public testing::Test, remote_ice_parameter_source_ = source; } - void set_force_relay(bool relay) { - force_relay_ = relay; - } + void set_force_relay(bool relay) { force_relay_ = relay; } void ConnectSignalNominated(Connection* conn) { conn->SignalNominated.connect(this, @@ -1018,20 +1016,22 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase { case NAT_SYMMETRIC: AddAddress(endpoint, kPrivateAddrs[endpoint]); // Add a single NAT of the desired type - nat()->AddTranslator(kPublicAddrs[endpoint], kNatAddrs[endpoint], - static_cast(config - NAT_FULL_CONE))-> - AddClient(kPrivateAddrs[endpoint]); + nat() + ->AddTranslator(kPublicAddrs[endpoint], kNatAddrs[endpoint], + static_cast(config - NAT_FULL_CONE)) + ->AddClient(kPrivateAddrs[endpoint]); break; case NAT_DOUBLE_CONE: case NAT_SYMMETRIC_THEN_CONE: AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); // Add a two cascaded NATs of the desired types - nat()->AddTranslator(kPublicAddrs[endpoint], kNatAddrs[endpoint], - (config == NAT_DOUBLE_CONE) ? - rtc::NAT_OPEN_CONE : rtc::NAT_SYMMETRIC)-> - AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], - rtc::NAT_OPEN_CONE)-> - AddClient(kCascadedPrivateAddrs[endpoint]); + nat() + ->AddTranslator(kPublicAddrs[endpoint], kNatAddrs[endpoint], + (config == NAT_DOUBLE_CONE) ? rtc::NAT_OPEN_CONE + : rtc::NAT_SYMMETRIC) + ->AddTranslator(kPrivateAddrs[endpoint], + kCascadedNatAddrs[endpoint], rtc::NAT_OPEN_CONE) + ->AddClient(kCascadedPrivateAddrs[endpoint]); break; case BLOCK_UDP: case BLOCK_UDP_AND_INCOMING_TCP: @@ -1040,8 +1040,7 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase { case PROXY_SOCKS: AddAddress(endpoint, kPublicAddrs[endpoint]); // Block all UDP - fw()->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, - kPublicAddrs[endpoint]); + fw()->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kPublicAddrs[endpoint]); if (config == BLOCK_UDP_AND_INCOMING_TCP) { // Block TCP inbound to the endpoint fw()->AddRule(false, rtc::FP_TCP, SocketAddress(), @@ -1103,19 +1102,43 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase { // TODO(?): Rearrange rows/columns from best to worst. const P2PTransportChannelTest::Result* P2PTransportChannelTest::kMatrix[NUM_CONFIGS][NUM_CONFIGS] = { -// OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH PRXS -/*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS, NULL, LTPT}, -/*CO*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LTRT}, -/*AD*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LTRT}, -/*PO*/ {SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS, NULL, LTRT}, -/*SY*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, -/*2C*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LTRT}, -/*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, -/*!U*/ {LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS, NULL, LTRT}, -/*!T*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LTRT}, -/*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LSRS}, -/*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, -/*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LTRT}, + // OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH + // PRXS + /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS, + NULL, LTPT}, + /*CO*/ + {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, + LTRT}, + /*AD*/ + {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, + LTRT}, + /*PO*/ + {SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS, NULL, + LTRT}, + /*SY*/ + {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, + LTRT}, + /*2C*/ + {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, + LTRT}, + /*SC*/ + {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, + LTRT}, + /*!U*/ + {LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS, NULL, + LTRT}, + /*!T*/ + {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, + LTRT}, + /*HT*/ + {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, + LSRS}, + /*PR*/ + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL}, + /*PR*/ + {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, + LTRT}, }; // The actual tests that exercise all the various configurations. @@ -1325,9 +1348,10 @@ TEST_F(P2PTransportChannelTest, // Adding address in ep1 will trigger continual gathering. AddAddress(0, kAlternateAddrs[0]); EXPECT_EQ_SIMULATED_WAIT( - 1, GetMetricsObserver(0)->GetEnumCounter( - webrtc::kEnumCounterIceRegathering, - static_cast(IceRegatheringReason::NETWORK_CHANGE)), + 1, + GetMetricsObserver(0)->GetEnumCounter( + webrtc::kEnumCounterIceRegathering, + static_cast(IceRegatheringReason::NETWORK_CHANGE)), kDefaultTimeout, clock); ep2_ch1()->SetIceParameters(kIceParams[3]); @@ -1386,8 +1410,8 @@ TEST_F(P2PTransportChannelTest, TestIceRegatherOnAllNetworksContinual) { // ep1 gathers continually but ep2 does not. const int kRegatherInterval = 2000; IceConfig config1 = CreateIceConfig(1000, GATHER_CONTINUALLY); - config1.regather_all_networks_interval_range.emplace( - kRegatherInterval, kRegatherInterval); + config1.regather_all_networks_interval_range.emplace(kRegatherInterval, + kRegatherInterval); IceConfig config2; CreateChannels(config1, config2); @@ -1421,7 +1445,7 @@ class P2PTransportRegatherAllNetworksTest : public P2PTransportChannelTest { void TestWithRoles(IceRole p1_role, IceRole p2_role) { rtc::ScopedFakeClock clock; ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, - kDefaultPortAllocatorFlags); + kDefaultPortAllocatorFlags); set_force_relay(true); const int kRegatherInterval = 2000; @@ -1429,8 +1453,8 @@ class P2PTransportRegatherAllNetworksTest : public P2PTransportChannelTest { // Set up peer 1 to auto regather every 2s. IceConfig config1 = CreateIceConfig(1000, GATHER_CONTINUALLY); - config1.regather_all_networks_interval_range.emplace( - kRegatherInterval, kRegatherInterval); + config1.regather_all_networks_interval_range.emplace(kRegatherInterval, + kRegatherInterval); IceConfig config2 = CreateIceConfig(1000, GATHER_CONTINUALLY); // Set peer roles. @@ -1440,11 +1464,10 @@ class P2PTransportRegatherAllNetworksTest : public P2PTransportChannelTest { CreateChannels(config1, config2); // Wait for initial connection to be made. - EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && - ep1_ch1()->writable() && - ep2_ch1()->receiving() && - ep2_ch1()->writable(), - kMediumTimeout, clock); + EXPECT_TRUE_SIMULATED_WAIT( + ep1_ch1()->receiving() && ep1_ch1()->writable() && + ep2_ch1()->receiving() && ep2_ch1()->writable(), + kMediumTimeout, clock); const Connection* initial_selected = ep1_ch1()->selected_connection(); @@ -1453,9 +1476,10 @@ class P2PTransportRegatherAllNetworksTest : public P2PTransportChannelTest { const int kWaitRegather = kRegatherInterval * kNumRegathers + kRegatherInterval / 2; SIMULATED_WAIT(false, kWaitRegather, clock); - EXPECT_EQ(kNumRegathers, GetMetricsObserver(0)->GetEnumCounter( - webrtc::kEnumCounterIceRegathering, - static_cast(IceRegatheringReason::OCCASIONAL_REFRESH))); + EXPECT_EQ(kNumRegathers, + GetMetricsObserver(0)->GetEnumCounter( + webrtc::kEnumCounterIceRegathering, + static_cast(IceRegatheringReason::OCCASIONAL_REFRESH))); const Connection* new_selected = ep1_ch1()->selected_connection(); @@ -1814,26 +1838,16 @@ TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { AddAddress(1, kPublicAddrs[1]); CreateChannels(); - EXPECT_EQ(rtc::DSCP_NO_CHANGE, - GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); - EXPECT_EQ(rtc::DSCP_NO_CHANGE, - GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); - GetEndpoint(0)->cd1_.ch_->SetOption( - rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); - GetEndpoint(1)->cd1_.ch_->SetOption( - rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); - EXPECT_EQ(rtc::DSCP_CS6, - GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); - EXPECT_EQ(rtc::DSCP_CS6, - GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); - GetEndpoint(0)->cd1_.ch_->SetOption( - rtc::Socket::OPT_DSCP, rtc::DSCP_AF41); - GetEndpoint(1)->cd1_.ch_->SetOption( - rtc::Socket::OPT_DSCP, rtc::DSCP_AF41); - EXPECT_EQ(rtc::DSCP_AF41, - GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); - EXPECT_EQ(rtc::DSCP_AF41, - GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); + EXPECT_EQ(rtc::DSCP_NO_CHANGE, GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); + EXPECT_EQ(rtc::DSCP_NO_CHANGE, GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); + GetEndpoint(0)->cd1_.ch_->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); + GetEndpoint(1)->cd1_.ch_->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); + EXPECT_EQ(rtc::DSCP_CS6, GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); + EXPECT_EQ(rtc::DSCP_CS6, GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); + GetEndpoint(0)->cd1_.ch_->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_AF41); + GetEndpoint(1)->cd1_.ch_->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_AF41); + EXPECT_EQ(rtc::DSCP_AF41, GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); + EXPECT_EQ(rtc::DSCP_AF41, GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); } // Verify IPv6 connection is preferred over IPv4. @@ -2240,15 +2254,16 @@ class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { RTC_CHECK_GE(nat_type, NAT_FULL_CONE); RTC_CHECK_LE(nat_type, NAT_SYMMETRIC); - rtc::NATSocketServer::Translator* outer_nat = - nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], - static_cast(nat_type - NAT_FULL_CONE)); + rtc::NATSocketServer::Translator* outer_nat = nat()->AddTranslator( + kPublicAddrs[0], kNatAddrs[0], + static_cast(nat_type - NAT_FULL_CONE)); ConfigureEndpoint(outer_nat, 0, config1); ConfigureEndpoint(outer_nat, 1, config2); set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); } void ConfigureEndpoint(rtc::NATSocketServer::Translator* nat, - int endpoint, Config config) { + int endpoint, + Config config) { RTC_CHECK(config <= NAT_SYMMETRIC); if (config == OPEN) { AddAddress(endpoint, kPrivateAddrs[endpoint]); @@ -2256,8 +2271,8 @@ class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { } else { AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], - static_cast(config - NAT_FULL_CONE))->AddClient( - kCascadedPrivateAddrs[endpoint]); + static_cast(config - NAT_FULL_CONE)) + ->AddClient(kCascadedPrivateAddrs[endpoint]); } } }; @@ -2420,7 +2435,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) { ep2_ch1()->selected_connection()->receiving(), kMediumTimeout, clock); EXPECT_TRUE( - LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); + LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); EXPECT_TRUE( RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); @@ -2982,10 +2997,10 @@ TEST_F(P2PTransportChannelMultihomedTest, ep2_ch1()->receiving() && ep2_ch1()->writable(), kMediumTimeout, clock); - EXPECT_TRUE( - ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && - LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && - RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); + EXPECT_TRUE(ep1_ch1()->selected_connection() && + ep2_ch1()->selected_connection() && + LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && + RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); // Add the new address first and then remove the other one. RTC_LOG(LS_INFO) << "Draining..."; diff --git a/p2p/base/packetsocketfactory.h b/p2p/base/packetsocketfactory.h index e5df8fd2d1..4667bb1fd7 100644 --- a/p2p/base/packetsocketfactory.h +++ b/p2p/base/packetsocketfactory.h @@ -50,7 +50,7 @@ class PacketSocketFactory { OPT_SSLTCP = OPT_TLS_FAKE, }; - PacketSocketFactory() { } + PacketSocketFactory() {} virtual ~PacketSocketFactory() = default; virtual AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, diff --git a/p2p/base/port.cc b/p2p/base/port.cc index 5007a04701..fd4764dd2f 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -133,7 +133,7 @@ rtc::PacketInfoProtocolType ConvertProtocolTypeToPacketInfoProtocolType( // We will restrict RTT estimates (when used for determining state) to be // within a reasonable range. -const int MINIMUM_RTT = 100; // 0.1 seconds +const int MINIMUM_RTT = 100; // 0.1 seconds const int MAXIMUM_RTT = 60000; // 60 seconds // When we don't have any RTT data, we have to pick something reasonable. We @@ -316,8 +316,8 @@ void Port::Construct() { thread_->PostDelayed(RTC_FROM_HERE, timeout_delay_, this, MSG_DESTROY_IF_DEAD); - RTC_LOG(LS_INFO) << ToString() - << ": Port created with network cost " << network_cost_; + RTC_LOG(LS_INFO) << ToString() << ": Port created with network cost " + << network_cost_; } Port::~Port() { @@ -455,9 +455,10 @@ void Port::AddOrReplaceConnection(Connection* conn) { SignalConnectionCreated(this, conn); } -void Port::OnReadPacket( - const char* data, size_t size, const rtc::SocketAddress& addr, - ProtocolType proto) { +void Port::OnReadPacket(const char* data, + size_t size, + const rtc::SocketAddress& addr, + ProtocolType proto) { // If the user has enabled port packets, just hand this over. if (enable_port_packets_) { SignalReadPacket(this, data, size, addr); @@ -641,7 +642,7 @@ bool Port::ParseStunUsername(const StunMessage* stun_msg, local_ufrag->clear(); remote_ufrag->clear(); const StunByteStringAttribute* username_attr = - stun_msg->GetByteString(STUN_ATTR_USERNAME); + stun_msg->GetByteString(STUN_ATTR_USERNAME); if (username_attr == NULL) return false; @@ -657,9 +658,9 @@ bool Port::ParseStunUsername(const StunMessage* stun_msg, return true; } -bool Port::MaybeIceRoleConflict( - const rtc::SocketAddress& addr, IceMessage* stun_msg, - const std::string& remote_ufrag) { +bool Port::MaybeIceRoleConflict(const rtc::SocketAddress& addr, + IceMessage* stun_msg, + const std::string& remote_ufrag) { // Validate ICE_CONTROLLING or ICE_CONTROLLED attributes. bool ret = true; IceRole remote_ice_role = ICEROLE_UNKNOWN; @@ -694,8 +695,8 @@ bool Port::MaybeIceRoleConflict( SignalRoleConflict(this); } else { // Send Role Conflict (487) error response. - SendBindingErrorResponse(stun_msg, addr, - STUN_ERROR_ROLE_CONFLICT, STUN_ERROR_REASON_ROLE_CONFLICT); + SendBindingErrorResponse(stun_msg, addr, STUN_ERROR_ROLE_CONFLICT, + STUN_ERROR_REASON_ROLE_CONFLICT); ret = false; } } @@ -706,8 +707,8 @@ bool Port::MaybeIceRoleConflict( SignalRoleConflict(this); } else { // Send Role Conflict (487) error response. - SendBindingErrorResponse(stun_msg, addr, - STUN_ERROR_ROLE_CONFLICT, STUN_ERROR_REASON_ROLE_CONFLICT); + SendBindingErrorResponse(stun_msg, addr, STUN_ERROR_ROLE_CONFLICT, + STUN_ERROR_REASON_ROLE_CONFLICT); ret = false; } } @@ -793,10 +794,9 @@ void Port::SendBindingResponse(StunMessage* request, // Log at LS_INFO if we send a stun ping response on an unwritable // connection. Connection* conn = GetConnection(addr); - rtc::LoggingSeverity sev = (conn && !conn->writable()) ? - rtc::LS_INFO : rtc::LS_VERBOSE; - RTC_LOG_V(sev) << ToString() - << ": Sent STUN ping response, to=" + rtc::LoggingSeverity sev = + (conn && !conn->writable()) ? rtc::LS_INFO : rtc::LS_VERBOSE; + RTC_LOG_V(sev) << ToString() << ": Sent STUN ping response, to=" << addr.ToSensitiveString() << ", id=" << rtc::hex_encode(response.transaction_id()); @@ -808,7 +808,8 @@ void Port::SendBindingResponse(StunMessage* request, void Port::SendBindingErrorResponse(StunMessage* request, const rtc::SocketAddress& addr, - int error_code, const std::string& reason) { + int error_code, + const std::string& reason) { RTC_DCHECK(request->type() == STUN_BINDING_REQUEST); // Fill in the response message. @@ -854,7 +855,7 @@ void Port::Prune() { thread_->Post(RTC_FROM_HERE, this, MSG_DESTROY_IF_DEAD); } -void Port::OnMessage(rtc::Message *pmsg) { +void Port::OnMessage(rtc::Message* pmsg) { RTC_DCHECK(pmsg->message_id == MSG_DESTROY_IF_DEAD); bool dead = (state_ == State::INIT || state_ == State::PRUNED) && @@ -946,9 +947,7 @@ void Port::CopyPortInformationToPacketInfo(rtc::PacketInfo* info) const { class ConnectionRequest : public StunRequest { public: explicit ConnectionRequest(Connection* connection) - : StunRequest(new IceMessage()), - connection_(connection) { - } + : StunRequest(new IceMessage()), connection_(connection) {} void Prepare(StunMessage* request) override { request->SetType(STUN_BINDING_REQUEST); @@ -1022,9 +1021,7 @@ class ConnectionRequest : public StunRequest { connection_->OnConnectionRequestErrorResponse(this, response); } - void OnTimeout() override { - connection_->OnConnectionRequestTimeout(this); - } + void OnTimeout() override { connection_->OnConnectionRequestTimeout(this); } void OnSent() override { connection_->OnConnectionRequestSent(this); @@ -1033,9 +1030,7 @@ class ConnectionRequest : public StunRequest { timeout_ = true; } - int resend_delay() override { - return CONNECTION_RESPONSE_TIMEOUT; - } + int resend_delay() override { return CONNECTION_RESPONSE_TIMEOUT; } private: Connection* connection_; @@ -1077,8 +1072,7 @@ Connection::Connection(Port* port, RTC_LOG(LS_INFO) << ToString() << ": Connection created"; } -Connection::~Connection() { -} +Connection::~Connection() {} const Candidate& Connection::local_candidate() const { RTC_DCHECK(local_candidate_index_ < port_->Candidates().size()); @@ -1118,9 +1112,8 @@ void Connection::set_write_state(WriteState value) { WriteState old_value = write_state_; write_state_ = value; if (value != old_value) { - RTC_LOG(LS_VERBOSE) << ToString() - << ": set_write_state from: " << old_value << " to " - << value; + RTC_LOG(LS_VERBOSE) << ToString() << ": set_write_state from: " << old_value + << " to " << value; SignalStateChange(this); } } @@ -1144,8 +1137,7 @@ void Connection::UpdateReceiving(int64_t now) { if (receiving_ == receiving) { return; } - RTC_LOG(LS_VERBOSE) << ToString() << ": set_receiving to " - << receiving; + RTC_LOG(LS_VERBOSE) << ToString() << ": set_receiving to " << receiving; receiving_ = receiving; receiving_unchanged_since_ = now; SignalStateChange(this); @@ -1163,8 +1155,7 @@ void Connection::set_connected(bool value) { bool old_value = connected_; connected_ = value; if (value != old_value) { - RTC_LOG(LS_VERBOSE) << ToString() - << ": Change connected_ to " << value; + RTC_LOG(LS_VERBOSE) << ToString() << ": Change connected_ to " << value; SignalStateChange(this); } } @@ -1185,13 +1176,14 @@ int Connection::receiving_timeout() const { return receiving_timeout_.value_or(WEAK_CONNECTION_RECEIVE_TIMEOUT); } -void Connection::OnSendStunPacket(const void* data, size_t size, +void Connection::OnSendStunPacket(const void* data, + size_t size, StunRequest* req) { rtc::PacketOptions options(port_->DefaultDscpValue()); options.info_signaled_after_sent.packet_type = rtc::PacketType::kIceConnectivityCheck; - auto err = port_->SendTo( - data, size, remote_candidate_.address(), options, false); + auto err = + port_->SendTo(data, size, remote_candidate_.address(), options, false); if (err < 0) { RTC_LOG(LS_WARNING) << ToString() << ": Failed to send STUN ping " @@ -1200,8 +1192,9 @@ void Connection::OnSendStunPacket(const void* data, size_t size, } } -void Connection::OnReadPacket( - const char* data, size_t size, const rtc::PacketTime& packet_time) { +void Connection::OnReadPacket(const char* data, + size_t size, + const rtc::PacketTime& packet_time) { std::unique_ptr msg; std::string remote_ufrag; const rtc::SocketAddress& addr(remote_candidate_.address()); @@ -1231,8 +1224,7 @@ void Connection::OnReadPacket( rtc::LoggingSeverity sev = (!writable() ? rtc::LS_INFO : rtc::LS_VERBOSE); switch (msg->type()) { case STUN_BINDING_REQUEST: - RTC_LOG_V(sev) << ToString() - << ": Received STUN ping, id=" + RTC_LOG_V(sev) << ToString() << ": Received STUN ping, id=" << rtc::hex_encode(msg->transaction_id()); if (remote_ufrag == remote_candidate_.username()) { @@ -1255,8 +1247,8 @@ void Connection::OnReadPacket( // id's match. case STUN_BINDING_RESPONSE: case STUN_BINDING_ERROR_RESPONSE: - if (msg->ValidateMessageIntegrity( - data, size, remote_candidate().password())) { + if (msg->ValidateMessageIntegrity(data, size, + remote_candidate().password())) { requests_.CheckResponse(msg.get()); } // Otherwise silently discard the response message. @@ -1358,8 +1350,7 @@ void Connection::Destroy() { // with the networking thread on which this message is posted). Also affects // tests, with a workaround in // AutoSocketServerThread::~AutoSocketServerThread. - RTC_LOG(LS_VERBOSE) << ToString() - << ": Connection destroyed"; + RTC_LOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; port_->thread()->Post(RTC_FROM_HERE, this, MSG_DELETE); LogCandidatePairConfig(webrtc::IceCandidatePairConfigType::kDestroyed); } @@ -1421,8 +1412,8 @@ void Connection::UpdateState(int64_t now) { TooLongWithoutResponse(pings_since_last_response_, unwritable_timeout(), now)) { uint32_t max_pings = unwritable_min_checks(); - RTC_LOG(LS_INFO) << ToString() << ": Unwritable after " - << max_pings << " ping failures and " + RTC_LOG(LS_INFO) << ToString() << ": Unwritable after " << max_pings + << " ping failures and " << now - pings_since_last_response_[0].sent_time << " ms without a response," " ms since last received ping=" @@ -1434,8 +1425,7 @@ void Connection::UpdateState(int64_t now) { if ((write_state_ == STATE_WRITE_UNRELIABLE || write_state_ == STATE_WRITE_INIT) && TooLongWithoutResponse(pings_since_last_response_, - CONNECTION_WRITE_TIMEOUT, - now)) { + CONNECTION_WRITE_TIMEOUT, now)) { RTC_LOG(LS_INFO) << ToString() << ": Timed out after " << now - pings_since_last_response_[0].sent_time << " ms without a response, rtt=" << rtt; @@ -1461,8 +1451,7 @@ void Connection::Ping(int64_t now) { } pings_since_last_response_.push_back(SentPing(req->id(), now, nomination)); packet_loss_estimator_.ExpectResponse(req->id(), now); - RTC_LOG(LS_VERBOSE) << ToString() - << ": Sending STUN ping, id=" + RTC_LOG(LS_VERBOSE) << ToString() << ": Sending STUN ping, id=" << rtc::hex_encode(req->id()) << ", nomination=" << nomination_; requests_.Send(req); @@ -1552,24 +1541,24 @@ uint32_t Connection::ComputeNetworkCost() const { std::string Connection::ToString() const { const char CONNECT_STATE_ABBREV[2] = { - '-', // not connected (false) - 'C', // connected (true) + '-', // not connected (false) + 'C', // connected (true) }; const char RECEIVE_STATE_ABBREV[2] = { - '-', // not receiving (false) - 'R', // receiving (true) + '-', // not receiving (false) + 'R', // receiving (true) }; const char WRITE_STATE_ABBREV[4] = { - 'W', // STATE_WRITABLE - 'w', // STATE_WRITE_UNRELIABLE - '-', // STATE_WRITE_INIT - 'x', // STATE_WRITE_TIMEOUT + 'W', // STATE_WRITABLE + 'w', // STATE_WRITE_UNRELIABLE + '-', // STATE_WRITE_INIT + 'x', // STATE_WRITE_TIMEOUT }; const std::string ICESTATE[4] = { - "W", // STATE_WAITING - "I", // STATE_INPROGRESS - "S", // STATE_SUCCEEDED - "F" // STATE_FAILED + "W", // STATE_WAITING + "I", // STATE_INPROGRESS + "S", // STATE_SUCCEEDED + "F" // STATE_FAILED }; const std::string SELECTED_STATE_ABBREV[2] = { "-", // candidate pair not selected (false) @@ -1651,8 +1640,7 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request, if (RTC_LOG_CHECK_LEVEL_V(sev)) { std::string pings; PrintPingsSinceLastResponse(&pings, 5); - RTC_LOG_V(sev) << ToString() - << ": Received STUN ping response, id=" + RTC_LOG_V(sev) << ToString() << ": Received STUN ping response, id=" << rtc::hex_encode(request->id()) << ", code=0" // Makes logging easier to parse. ", rtt=" @@ -1673,8 +1661,7 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request, void Connection::OnConnectionRequestErrorResponse(ConnectionRequest* request, StunMessage* response) { int error_code = response->GetErrorCodeValue(); - RTC_LOG(LS_WARNING) << ToString() - << ": Received STUN error response id=" + RTC_LOG(LS_WARNING) << ToString() << ": Received STUN error response id=" << rtc::hex_encode(request->id()) << " code=" << error_code << " rtt=" << request->Elapsed(); @@ -1752,7 +1739,7 @@ void Connection::MaybeUpdatePeerReflexiveCandidate( } } -void Connection::OnMessage(rtc::Message *pmsg) { +void Connection::OnMessage(rtc::Message* pmsg) { RTC_DCHECK(pmsg->message_id == MSG_DELETE); RTC_LOG(LS_INFO) << "Connection deleted with number of pings sent: " << num_pings_sent_; @@ -1762,7 +1749,7 @@ void Connection::OnMessage(rtc::Message *pmsg) { int64_t Connection::last_received() const { return std::max(last_data_received_, - std::max(last_ping_received_, last_ping_response_received_)); + std::max(last_ping_received_, last_ping_response_received_)); } ConnectionInfo Connection::stats() { @@ -1851,8 +1838,7 @@ void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request, new_local_candidate.set_network_cost(local_candidate().network_cost()); // Change the local candidate of this Connection to the new prflx candidate. - RTC_LOG(LS_INFO) << ToString() - << ": Updating local candidate type to prflx."; + RTC_LOG(LS_INFO) << ToString() << ": Updating local candidate type to prflx."; local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); // SignalStateChange to force a re-sort in P2PTransportChannel as this @@ -1878,11 +1864,12 @@ ProxyConnection::ProxyConnection(Port* port, const Candidate& remote_candidate) : Connection(port, index, remote_candidate) {} -int ProxyConnection::Send(const void* data, size_t size, +int ProxyConnection::Send(const void* data, + size_t size, const rtc::PacketOptions& options) { stats_.sent_total_packets++; - int sent = port_->SendTo(data, size, remote_candidate_.address(), - options, true); + int sent = + port_->SendTo(data, size, remote_candidate_.address(), options, true); if (sent <= 0) { RTC_DCHECK(sent < 0); error_ = port_->GetError(); diff --git a/p2p/base/port.h b/p2p/base/port.h index c3e2c14fe8..09cbdef508 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -57,8 +57,8 @@ extern const char TCPTYPE_PASSIVE_STR[]; extern const char TCPTYPE_SIMOPEN_STR[]; enum RelayType { - RELAY_GTURN, // Legacy google relay service. - RELAY_TURN // Standard (TURN) relay service. + RELAY_GTURN, // Legacy google relay service. + RELAY_TURN // Standard (TURN) relay service. }; enum IcePriorityValue { @@ -179,7 +179,8 @@ typedef std::set ServerAddresses; // Represents a local communication mechanism that can be used to create // connections to similar mechanisms of the other client. Subclasses of this // one add support for specific mechanisms like local UDP ports. -class Port : public PortInterface, public rtc::MessageHandler, +class Port : public PortInterface, + public rtc::MessageHandler, public sigslot::has_slots<> { public: // INIT: The state when a port is just created. @@ -320,8 +321,7 @@ class Port : public PortInterface, public rtc::MessageHandler, int error_code, const std::string& reason) override; - void set_proxy(const std::string& user_agent, - const rtc::ProxyInfo& proxy) { + void set_proxy(const std::string& user_agent, const rtc::ProxyInfo& proxy) { user_agent_ = user_agent; proxy_ = proxy; } @@ -413,7 +413,8 @@ class Port : public PortInterface, public rtc::MessageHandler, // Called when a packet is received from an unknown address that is not // currently a connection. If this is an authenticated STUN binding request, // then we will signal the client. - void OnReadPacket(const char* data, size_t size, + void OnReadPacket(const char* data, + size_t size, const rtc::SocketAddress& addr, ProtocolType proto); @@ -521,10 +522,10 @@ class Connection : public CandidatePairInterface, uint64_t priority() const; enum WriteState { - STATE_WRITABLE = 0, // we have received ping responses recently - STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures - STATE_WRITE_INIT = 2, // we have yet to receive a ping response - STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures + STATE_WRITABLE = 0, // we have received ping responses recently + STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures + STATE_WRITE_INIT = 2, // we have yet to receive a ping response + STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures }; WriteState write_state() const { return write_state_; } @@ -535,9 +536,7 @@ class Connection : public CandidatePairInterface, // be false for TCP connections. bool connected() const { return connected_; } bool weak() const { return !(writable() && receiving() && connected()); } - bool active() const { - return write_state_ != STATE_WRITE_TIMEOUT; - } + bool active() const { return write_state_ != STATE_WRITE_TIMEOUT; } // A connection is dead if it can be safely deleted. bool dead(int64_t now) const; @@ -567,7 +566,8 @@ class Connection : public CandidatePairInterface, // The connection can send and receive packets asynchronously. This matches // the interface of AsyncPacketSocket, which may use UDP or TCP under the // covers. - virtual int Send(const void* data, size_t size, + virtual int Send(const void* data, + size_t size, const rtc::PacketOptions& options) = 0; // Error if Send() returns < 0 @@ -579,7 +579,8 @@ class Connection : public CandidatePairInterface, sigslot::signal1 SignalReadyToSend; // Called when a packet is received on this connection. - void OnReadPacket(const char* data, size_t size, + void OnReadPacket(const char* data, + size_t size, const rtc::PacketTime& packet_time); // Called when the socket is currently able to send. @@ -613,9 +614,7 @@ class Connection : public CandidatePairInterface, // Public for unit tests. uint32_t acked_nomination() const { return acked_nomination_; } - void set_remote_ice_mode(IceMode mode) { - remote_ice_mode_ = mode; - } + void set_remote_ice_mode(IceMode mode) { remote_ice_mode_ = mode; } int receiving_timeout() const; void set_receiving_timeout(absl::optional receiving_timeout_ms) { @@ -670,7 +669,7 @@ class Connection : public CandidatePairInterface, void PrintPingsSinceLastResponse(std::string* pings, size_t max); bool reported() const { return reported_; } - void set_reported(bool reported) { reported_ = reported;} + void set_reported(bool reported) { reported_ = reported; } // The following two methods are only used for logging in ToString above, and // this flag is set true by P2PTransportChannel for its selected candidate // pair. diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 55887055ec..423db3e87f 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -184,9 +184,11 @@ class TestPort : public Port { conn->set_use_candidate_attr(true); return conn; } - virtual int SendTo( - const void* data, size_t size, const rtc::SocketAddress& addr, - const rtc::PacketOptions& options, bool payload) { + virtual int SendTo(const void* data, + size_t size, + const rtc::SocketAddress& addr, + const rtc::PacketOptions& options, + bool payload) { if (!payload) { IceMessage* msg = new IceMessage; Buffer* buf = new Buffer(static_cast(data), size); @@ -201,15 +203,9 @@ class TestPort : public Port { } return static_cast(size); } - virtual int SetOption(rtc::Socket::Option opt, int value) { - return 0; - } - virtual int GetOption(rtc::Socket::Option opt, int* value) { - return -1; - } - virtual int GetError() { - return 0; - } + virtual int SetOption(rtc::Socket::Option opt, int value) { return 0; } + virtual int GetOption(rtc::Socket::Option opt, int* value) { return -1; } + virtual int GetError() { return 0; } void Reset() { last_stun_buf_.reset(); last_stun_msg_.reset(); @@ -228,21 +224,22 @@ class TestPort : public Port { int type_preference_ = 0; }; -static void SendPingAndReceiveResponse( - Connection* lconn, TestPort* lport, Connection* rconn, TestPort* rport, - rtc::ScopedFakeClock* clock, int64_t ms) { +static void SendPingAndReceiveResponse(Connection* lconn, + TestPort* lport, + Connection* rconn, + TestPort* rport, + rtc::ScopedFakeClock* clock, + int64_t ms) { lconn->Ping(rtc::TimeMillis()); ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout); ASSERT_TRUE(lport->last_stun_buf()); rconn->OnReadPacket(lport->last_stun_buf()->data(), - lport->last_stun_buf()->size(), - rtc::PacketTime()); + lport->last_stun_buf()->size(), rtc::PacketTime()); clock->AdvanceTime(webrtc::TimeDelta::ms(ms)); ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout); ASSERT_TRUE(rport->last_stun_buf()); lconn->OnReadPacket(rport->last_stun_buf()->data(), - rport->last_stun_buf()->size(), - rtc::PacketTime()); + rport->last_stun_buf()->size(), rtc::PacketTime()); } class TestChannel : public sigslot::has_slots<> { @@ -272,8 +269,8 @@ class TestChannel : public sigslot::has_slots<> { (ice_mode_ == ICEMODE_FULL) ? ICEMODE_LITE : ICEMODE_FULL; conn_->set_remote_ice_mode(remote_ice_mode); conn_->set_use_candidate_attr(remote_ice_mode == ICEMODE_FULL); - conn_->SignalStateChange.connect( - this, &TestChannel::OnConnectionStateChange); + conn_->SignalStateChange.connect(this, + &TestChannel::OnConnectionStateChange); conn_->SignalDestroyed.connect(this, &TestChannel::OnDestroyed); conn_->SignalReadyToSend.connect(this, &TestChannel::OnConnectionReadyToSend); @@ -294,9 +291,7 @@ class TestChannel : public sigslot::has_slots<> { port_->SendBindingResponse(remote_request_.get(), remote_address_); remote_request_.reset(); } - void Ping() { - Ping(0); - } + void Ping() { Ping(0); } void Ping(int64_t now) { conn_->Ping(now); } void Stop() { if (conn_) { @@ -304,21 +299,19 @@ class TestChannel : public sigslot::has_slots<> { } } - void OnPortComplete(Port* port) { - complete_count_++; - } - void SetIceMode(IceMode ice_mode) { - ice_mode_ = ice_mode; - } + void OnPortComplete(Port* port) { complete_count_++; } + void SetIceMode(IceMode ice_mode) { ice_mode_ = ice_mode; } int SendData(const char* data, size_t len) { rtc::PacketOptions options; return conn_->Send(data, len, options); } - void OnUnknownAddress(PortInterface* port, const SocketAddress& addr, + void OnUnknownAddress(PortInterface* port, + const SocketAddress& addr, ProtocolType proto, - IceMessage* msg, const std::string& rf, + IceMessage* msg, + const std::string& rf, bool /*port_muxed*/) { ASSERT_EQ(port_.get(), port); if (!remote_address_.IsNil()) { @@ -360,9 +353,7 @@ class TestChannel : public sigslot::has_slots<> { void set_connection_ready_to_send(bool ready) { connection_ready_to_send_ = ready; } - bool connection_ready_to_send() const { - return connection_ready_to_send_; - } + bool connection_ready_to_send() const { return connection_ready_to_send_; } private: // ReadyToSend will only issue after a Connection recovers from ENOTCONN @@ -405,8 +396,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { username_(rtc::CreateRandomString(ICE_UFRAG_LENGTH)), password_(rtc::CreateRandomString(ICE_PWD_LENGTH)), role_conflict_(false), - ports_destroyed_(0) { - } + ports_destroyed_(0) {} protected: void TestLocalToLocal() { @@ -423,8 +413,8 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { Port* port2 = CreateStunPort(kLocalAddr2, &nat_socket_factory2_); port2->SetIceRole(cricket::ICEROLE_CONTROLLED); TestConnectivity("udp", port1, StunName(ntype), port2, - ntype == NAT_OPEN_CONE, true, - ntype != NAT_SYMMETRIC, true); + ntype == NAT_OPEN_CONE, true, ntype != NAT_SYMMETRIC, + true); } void TestLocalToRelay(RelayType rtype, ProtocolType proto) { Port* port1 = CreateUdpPort(kLocalAddr1); @@ -440,8 +430,8 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { port1->SetIceRole(cricket::ICEROLE_CONTROLLING); Port* port2 = CreateUdpPort(kLocalAddr2); port2->SetIceRole(cricket::ICEROLE_CONTROLLED); - TestConnectivity(StunName(ntype), port1, "udp", port2, - true, ntype != NAT_SYMMETRIC, true, true); + TestConnectivity(StunName(ntype), port1, "udp", port2, true, + ntype != NAT_SYMMETRIC, true, true); } void TestStunToStun(NATType ntype1, NATType ntype2) { nat_server1_.reset(CreateNatServer(kNatAddr1, ntype1)); @@ -451,8 +441,8 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { Port* port2 = CreateStunPort(kLocalAddr2, &nat_socket_factory2_); port2->SetIceRole(cricket::ICEROLE_CONTROLLED); TestConnectivity(StunName(ntype1), port1, StunName(ntype2), port2, - ntype2 == NAT_OPEN_CONE, - ntype1 != NAT_SYMMETRIC, ntype2 != NAT_SYMMETRIC, + ntype2 == NAT_OPEN_CONE, ntype1 != NAT_SYMMETRIC, + ntype2 != NAT_SYMMETRIC, ntype1 + ntype2 < (NAT_PORT_RESTRICTED + NAT_SYMMETRIC)); } void TestStunToRelay(NATType ntype, RelayType rtype, ProtocolType proto) { @@ -508,7 +498,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { return CreateTcpPort(addr, &socket_factory_); } TCPPort* CreateTcpPort(const SocketAddress& addr, - PacketSocketFactory* socket_factory) { + PacketSocketFactory* socket_factory) { return TCPPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0, username_, password_, true); } @@ -520,8 +510,10 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { password_, stun_servers, std::string(), absl::nullopt); } - Port* CreateRelayPort(const SocketAddress& addr, RelayType rtype, - ProtocolType int_proto, ProtocolType ext_proto) { + Port* CreateRelayPort(const SocketAddress& addr, + RelayType rtype, + ProtocolType int_proto, + ProtocolType ext_proto) { if (rtype == RELAY_TURN) { return CreateTurnPort(addr, &socket_factory_, int_proto, ext_proto); } else { @@ -530,7 +522,8 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { } TurnPort* CreateTurnPort(const SocketAddress& addr, PacketSocketFactory* socket_factory, - ProtocolType int_proto, ProtocolType ext_proto) { + ProtocolType int_proto, + ProtocolType ext_proto) { SocketAddress server_addr = int_proto == PROTO_TCP ? kTurnTcpIntAddr : kTurnUdpIntAddr; return CreateTurnPort(addr, socket_factory, int_proto, ext_proto, @@ -538,7 +531,8 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { } TurnPort* CreateTurnPort(const SocketAddress& addr, PacketSocketFactory* socket_factory, - ProtocolType int_proto, ProtocolType ext_proto, + ProtocolType int_proto, + ProtocolType ext_proto, const rtc::SocketAddress& server_addr) { return TurnPort::Create( &main_, socket_factory, MakeNetwork(addr), 0, 0, username_, password_, @@ -547,10 +541,11 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { nullptr, nullptr); } RelayPort* CreateGturnPort(const SocketAddress& addr, - ProtocolType int_proto, ProtocolType ext_proto) { + ProtocolType int_proto, + ProtocolType ext_proto) { RelayPort* port = CreateGturnPort(addr); - SocketAddress addrs[] = - { kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr }; + SocketAddress addrs[] = {kRelayUdpIntAddr, kRelayTcpIntAddr, + kRelaySslTcpIntAddr}; port->AddServerAddress(ProtocolAddress(addrs[int_proto], int_proto)); return port; } @@ -564,7 +559,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { // other side can connect to this port using a non-UDP protocol. } rtc::NATServer* CreateNatServer(const SocketAddress& addr, - rtc::NATType type) { + rtc::NATType type) { return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); } static const char* StunName(NATType type) { @@ -616,10 +611,14 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { void ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2); // This does all the work and then deletes |port1| and |port2|. - void TestConnectivity(const char* name1, Port* port1, - const char* name2, Port* port2, - bool accept, bool same_addr1, - bool same_addr2, bool possible); + void TestConnectivity(const char* name1, + Port* port1, + const char* name2, + Port* port2, + bool accept, + bool same_addr1, + bool same_addr2, + bool possible); // This connects the provided channels which have already started. |ch1| // should have its Connection created (either through CreateConnection() or @@ -734,8 +733,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { // Verify that we could still connect channels. ConnectStartedChannels(&ch1, &ch2); - EXPECT_TRUE_WAIT(ch1.connection_ready_to_send(), - kTcpReconnectTimeout); + EXPECT_TRUE_WAIT(ch1.connection_ready_to_send(), kTcpReconnectTimeout); // Channel2 is the passive one so a new connection is created during // reconnect. This new connection should never have issued ENOTCONN // hence the connection_ready_to_send() should be false. @@ -796,9 +794,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { return port; } - void OnRoleConflict(PortInterface* port) { - role_conflict_ = true; - } + void OnRoleConflict(PortInterface* port) { role_conflict_ = true; } bool role_conflict() const { return role_conflict_; } void ConnectToSignalDestroyed(PortInterface* port) { @@ -837,10 +833,14 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { int ports_destroyed_; }; -void PortTest::TestConnectivity(const char* name1, Port* port1, - const char* name2, Port* port2, - bool accept, bool same_addr1, - bool same_addr2, bool possible) { +void PortTest::TestConnectivity(const char* name1, + Port* port1, + const char* name2, + Port* port2, + bool accept, + bool same_addr1, + bool same_addr2, + bool possible) { rtc::ScopedFakeClock clock; RTC_LOG(LS_INFO) << "Test: " << name1 << " to " << name2 << ": "; port1->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); @@ -874,7 +874,8 @@ void PortTest::TestConnectivity(const char* name1, Port* port1, // Ensure the ping came from the same address used for src. // This is the case unless the source NAT was symmetric. - if (same_addr1) EXPECT_EQ(ch2.remote_address(), GetAddress(port1)); + if (same_addr1) + EXPECT_EQ(ch2.remote_address(), GetAddress(port1)); EXPECT_TRUE(same_addr2); // Send a ping from dst to src. @@ -980,9 +981,8 @@ class FakePacketSocketFactory : public rtc::PacketSocketFactory { FakePacketSocketFactory() : next_udp_socket_(NULL), next_server_tcp_socket_(NULL), - next_client_tcp_socket_(NULL) { - } - ~FakePacketSocketFactory() override { } + next_client_tcp_socket_(NULL) {} + ~FakePacketSocketFactory() override {} AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, uint16_t min_port, @@ -1025,9 +1025,7 @@ class FakePacketSocketFactory : public rtc::PacketSocketFactory { void set_next_client_tcp_socket(AsyncPacketSocket* next_client_tcp_socket) { next_client_tcp_socket_ = next_client_tcp_socket; } - rtc::AsyncResolverInterface* CreateAsyncResolver() override { - return NULL; - } + rtc::AsyncResolverInterface* CreateAsyncResolver() override { return NULL; } private: AsyncPacketSocket* next_udp_socket_; @@ -1039,33 +1037,30 @@ class FakeAsyncPacketSocket : public AsyncPacketSocket { public: // Returns current local address. Address may be set to NULL if the // socket is not bound yet (GetState() returns STATE_BINDING). - virtual SocketAddress GetLocalAddress() const { - return SocketAddress(); - } + virtual SocketAddress GetLocalAddress() const { return SocketAddress(); } // Returns remote address. Returns zeroes if this is not a client TCP socket. - virtual SocketAddress GetRemoteAddress() const { - return SocketAddress(); - } + virtual SocketAddress GetRemoteAddress() const { return SocketAddress(); } // Send a packet. - virtual int Send(const void *pv, size_t cb, + virtual int Send(const void* pv, + size_t cb, const rtc::PacketOptions& options) { return static_cast(cb); } - virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr, + virtual int SendTo(const void* pv, + size_t cb, + const SocketAddress& addr, const rtc::PacketOptions& options) { return static_cast(cb); } - virtual int Close() { - return 0; - } + virtual int Close() { return 0; } virtual State GetState() const { return state_; } virtual int GetOption(Socket::Option opt, int* value) { return 0; } virtual int SetOption(Socket::Option opt, int value) { return 0; } virtual int GetError() const { return 0; } - virtual void SetError(int error) { } + virtual void SetError(int error) {} void set_state(State state) { state_ = state; } @@ -1355,8 +1350,8 @@ TEST_F(PortTest, TestConnectionDead) { conn->ReceivedPing(); int64_t after_last_receiving = rtc::TimeMillis(); // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT - conn->UpdateState( - before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); + conn->UpdateState(before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - + 1); rtc::Thread::Current()->ProcessMessages(100); EXPECT_TRUE(ch1.conn() != nullptr); conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); @@ -1388,16 +1383,15 @@ TEST_F(PortTest, TestLoopbackCall) { lport->SetIceTiebreaker(kTiebreaker1); lport->PrepareAddress(); ASSERT_FALSE(lport->Candidates().empty()); - Connection* conn = lport->CreateConnection(lport->Candidates()[0], - Port::ORIGIN_MESSAGE); + Connection* conn = + lport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); conn->Ping(0); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); IceMessage* msg = lport->last_stun_msg(); EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); conn->OnReadPacket(lport->last_stun_buf()->data(), - lport->last_stun_buf()->size(), - rtc::PacketTime()); + lport->last_stun_buf()->size(), rtc::PacketTime()); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); msg = lport->last_stun_msg(); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); @@ -1407,8 +1401,8 @@ TEST_F(PortTest, TestLoopbackCall) { lport->Reset(); lport->AddCandidateAddress(kLocalAddr2); // Creating a different connection as |conn| is receiving. - Connection* conn1 = lport->CreateConnection(lport->Candidates()[1], - Port::ORIGIN_MESSAGE); + Connection* conn1 = + lport->CreateConnection(lport->Candidates()[1], Port::ORIGIN_MESSAGE); conn1->Ping(0); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); @@ -1416,8 +1410,8 @@ TEST_F(PortTest, TestLoopbackCall) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); std::unique_ptr modified_req( CreateStunMessage(STUN_BINDING_REQUEST)); - const StunByteStringAttribute* username_attr = msg->GetByteString( - STUN_ATTR_USERNAME); + const StunByteStringAttribute* username_attr = + msg->GetByteString(STUN_ATTR_USERNAME); modified_req->AddAttribute(rtc::MakeUnique( STUN_ATTR_USERNAME, username_attr->GetString())); // To make sure we receive error response, adding tiebreaker less than @@ -1455,10 +1449,10 @@ TEST_F(PortTest, TestIceRoleConflict) { rport->PrepareAddress(); ASSERT_FALSE(lport->Candidates().empty()); ASSERT_FALSE(rport->Candidates().empty()); - Connection* lconn = lport->CreateConnection(rport->Candidates()[0], - Port::ORIGIN_MESSAGE); - Connection* rconn = rport->CreateConnection(lport->Candidates()[0], - Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* rconn = + rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); rconn->Ping(0); ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, kDefaultTimeout); @@ -1466,8 +1460,7 @@ TEST_F(PortTest, TestIceRoleConflict) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); // Send rport binding request to lport. lconn->OnReadPacket(rport->last_stun_buf()->data(), - rport->last_stun_buf()->size(), - rtc::PacketTime()); + rport->last_stun_buf()->size(), rtc::PacketTime()); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); @@ -1478,8 +1471,7 @@ TEST_F(PortTest, TestTcpNoDelay) { TCPPort* port1 = CreateTcpPort(kLocalAddr1); port1->SetIceRole(cricket::ICEROLE_CONTROLLING); int option_value = -1; - int success = port1->GetOption(rtc::Socket::OPT_NODELAY, - &option_value); + int success = port1->GetOption(rtc::Socket::OPT_NODELAY, &option_value); ASSERT_EQ(0, success); // GetOption() should complete successfully w/ 0 ASSERT_EQ(1, option_value); delete port1; @@ -1520,10 +1512,9 @@ TEST_F(PortTest, TestDelayedBindingTcp) { void PortTest::TestCrossFamilyPorts(int type) { FakePacketSocketFactory factory; std::unique_ptr ports[4]; - SocketAddress addresses[4] = {SocketAddress("192.168.1.3", 0), - SocketAddress("192.168.1.4", 0), - SocketAddress("2001:db8::1", 0), - SocketAddress("2001:db8::2", 0)}; + SocketAddress addresses[4] = { + SocketAddress("192.168.1.3", 0), SocketAddress("192.168.1.4", 0), + SocketAddress("2001:db8::1", 0), SocketAddress("2001:db8::2", 0)}; for (int i = 0; i < 4; i++) { FakeAsyncPacketSocket* socket = new FakeAsyncPacketSocket(); if (type == SOCK_DGRAM) { @@ -1576,8 +1567,7 @@ TEST_F(PortTest, TestSkipCrossFamilyUdp) { } void PortTest::ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2) { - Connection* c = p1->CreateConnection(GetCandidate(p2), - Port::ORIGIN_MESSAGE); + Connection* c = p1->CreateConnection(GetCandidate(p2), Port::ORIGIN_MESSAGE); if (can_connect) { EXPECT_FALSE(NULL == c); EXPECT_EQ(1U, p1->connections().size()); @@ -1590,10 +1580,9 @@ void PortTest::ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2) { TEST_F(PortTest, TestUdpV6CrossTypePorts) { FakePacketSocketFactory factory; std::unique_ptr ports[4]; - SocketAddress addresses[4] = {SocketAddress("2001:db8::1", 0), - SocketAddress("fe80::1", 0), - SocketAddress("fe80::2", 0), - SocketAddress("::1", 0)}; + SocketAddress addresses[4] = { + SocketAddress("2001:db8::1", 0), SocketAddress("fe80::1", 0), + SocketAddress("fe80::2", 0), SocketAddress("::1", 0)}; for (int i = 0; i < 4; i++) { FakeAsyncPacketSocket* socket = new FakeAsyncPacketSocket(); factory.set_next_udp_socket(socket); @@ -1623,33 +1612,28 @@ TEST_F(PortTest, TestUdpV6CrossTypePorts) { TEST_F(PortTest, TestDefaultDscpValue) { int dscp; std::unique_ptr udpport(CreateUdpPort(kLocalAddr1)); - EXPECT_EQ(0, udpport->SetOption(rtc::Socket::OPT_DSCP, - rtc::DSCP_CS6)); + EXPECT_EQ(0, udpport->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS6)); EXPECT_EQ(0, udpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); std::unique_ptr tcpport(CreateTcpPort(kLocalAddr1)); - EXPECT_EQ(0, tcpport->SetOption(rtc::Socket::OPT_DSCP, - rtc::DSCP_AF31)); + EXPECT_EQ(0, tcpport->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_AF31)); EXPECT_EQ(0, tcpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_AF31, dscp); std::unique_ptr stunport( CreateStunPort(kLocalAddr1, nat_socket_factory1())); - EXPECT_EQ(0, stunport->SetOption(rtc::Socket::OPT_DSCP, - rtc::DSCP_AF41)); + EXPECT_EQ(0, stunport->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_AF41)); EXPECT_EQ(0, stunport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_AF41, dscp); std::unique_ptr turnport1( CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); // Socket is created in PrepareAddress. turnport1->PrepareAddress(); - EXPECT_EQ(0, turnport1->SetOption(rtc::Socket::OPT_DSCP, - rtc::DSCP_CS7)); + EXPECT_EQ(0, turnport1->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS7)); EXPECT_EQ(0, turnport1->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_CS7, dscp); // This will verify correct value returned without the socket. std::unique_ptr turnport2( CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); - EXPECT_EQ(0, turnport2->SetOption(rtc::Socket::OPT_DSCP, - rtc::DSCP_CS6)); + EXPECT_EQ(0, turnport2->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS6)); EXPECT_EQ(0, turnport2->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_CS6, dscp); } @@ -1669,10 +1653,10 @@ TEST_F(PortTest, TestSendStunMessage) { lport->PrepareAddress(); rport->PrepareAddress(); ASSERT_FALSE(rport->Candidates().empty()); - Connection* lconn = lport->CreateConnection( - rport->Candidates()[0], Port::ORIGIN_MESSAGE); - Connection* rconn = rport->CreateConnection( - lport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* rconn = + rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); lconn->Ping(0); // Check that it's a proper BINDING-REQUEST. @@ -1724,8 +1708,8 @@ TEST_F(PortTest, TestSendStunMessage) { EXPECT_EQ(1U, rconn->stats().sent_ping_responses); EXPECT_FALSE(msg->IsLegacy()); - const StunAddressAttribute* addr_attr = msg->GetAddress( - STUN_ATTR_XOR_MAPPED_ADDRESS); + const StunAddressAttribute* addr_attr = + msg->GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); ASSERT_TRUE(addr_attr != NULL); EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress()); EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); @@ -1748,10 +1732,9 @@ TEST_F(PortTest, TestSendStunMessage) { // Respond with a BINDING-ERROR-RESPONSE. This wouldn't happen in real life, // but we can do it here. - rport->SendBindingErrorResponse(request.get(), - lport->Candidates()[0].address(), - STUN_ERROR_SERVER_ERROR, - STUN_ERROR_REASON_SERVER_ERROR); + rport->SendBindingErrorResponse( + request.get(), lport->Candidates()[0].address(), STUN_ERROR_SERVER_ERROR, + STUN_ERROR_REASON_SERVER_ERROR); msg = rport->last_stun_msg(); ASSERT_TRUE(msg != NULL); EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); @@ -1834,10 +1817,10 @@ TEST_F(PortTest, TestNomination) { rport->PrepareAddress(); ASSERT_FALSE(lport->Candidates().empty()); ASSERT_FALSE(rport->Candidates().empty()); - Connection* lconn = lport->CreateConnection(rport->Candidates()[0], - Port::ORIGIN_MESSAGE); - Connection* rconn = rport->CreateConnection(lport->Candidates()[0], - Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* rconn = + rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); // |lconn| is controlling, |rconn| is controlled. uint32_t nomination = 1234; @@ -1854,8 +1837,7 @@ TEST_F(PortTest, TestNomination) { ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout); ASSERT_TRUE(lport->last_stun_buf()); rconn->OnReadPacket(lport->last_stun_buf()->data(), - lport->last_stun_buf()->size(), - rtc::PacketTime()); + lport->last_stun_buf()->size(), rtc::PacketTime()); EXPECT_EQ(nomination, rconn->remote_nomination()); EXPECT_FALSE(lconn->nominated()); EXPECT_TRUE(rconn->nominated()); @@ -1867,8 +1849,7 @@ TEST_F(PortTest, TestNomination) { ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout); ASSERT_TRUE(rport->last_stun_buf()); lconn->OnReadPacket(rport->last_stun_buf()->data(), - rport->last_stun_buf()->size(), - rtc::PacketTime()); + rport->last_stun_buf()->size(), rtc::PacketTime()); EXPECT_EQ(nomination, lconn->acked_nomination()); EXPECT_TRUE(lconn->nominated()); EXPECT_TRUE(rconn->nominated()); @@ -1892,28 +1873,28 @@ TEST_F(PortTest, TestRoundTripTime) { rport->PrepareAddress(); ASSERT_FALSE(lport->Candidates().empty()); ASSERT_FALSE(rport->Candidates().empty()); - Connection* lconn = lport->CreateConnection(rport->Candidates()[0], - Port::ORIGIN_MESSAGE); - Connection* rconn = rport->CreateConnection(lport->Candidates()[0], - Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* rconn = + rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); EXPECT_EQ(0u, lconn->stats().total_round_trip_time_ms); EXPECT_FALSE(lconn->stats().current_round_trip_time_ms); - SendPingAndReceiveResponse( - lconn, lport.get(), rconn, rport.get(), &clock, 10); + SendPingAndReceiveResponse(lconn, lport.get(), rconn, rport.get(), &clock, + 10); EXPECT_EQ(10u, lconn->stats().total_round_trip_time_ms); ASSERT_TRUE(lconn->stats().current_round_trip_time_ms); EXPECT_EQ(10u, *lconn->stats().current_round_trip_time_ms); - SendPingAndReceiveResponse( - lconn, lport.get(), rconn, rport.get(), &clock, 20); + SendPingAndReceiveResponse(lconn, lport.get(), rconn, rport.get(), &clock, + 20); EXPECT_EQ(30u, lconn->stats().total_round_trip_time_ms); ASSERT_TRUE(lconn->stats().current_round_trip_time_ms); EXPECT_EQ(20u, *lconn->stats().current_round_trip_time_ms); - SendPingAndReceiveResponse( - lconn, lport.get(), rconn, rport.get(), &clock, 30); + SendPingAndReceiveResponse(lconn, lport.get(), rconn, rport.get(), &clock, + 30); EXPECT_EQ(60u, lconn->stats().total_round_trip_time_ms); ASSERT_TRUE(lconn->stats().current_round_trip_time_ms); EXPECT_EQ(30u, *lconn->stats().current_round_trip_time_ms); @@ -1933,16 +1914,16 @@ TEST_F(PortTest, TestUseCandidateAttribute) { lport->PrepareAddress(); rport->PrepareAddress(); ASSERT_FALSE(rport->Candidates().empty()); - Connection* lconn = lport->CreateConnection( - rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); lconn->Ping(0); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); IceMessage* msg = lport->last_stun_msg(); const StunUInt64Attribute* ice_controlling_attr = msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); ASSERT_TRUE(ice_controlling_attr != NULL); - const StunByteStringAttribute* use_candidate_attr = msg->GetByteString( - STUN_ATTR_USE_CANDIDATE); + const StunByteStringAttribute* use_candidate_attr = + msg->GetByteString(STUN_ATTR_USE_CANDIDATE); ASSERT_TRUE(use_candidate_attr != NULL); } @@ -2065,8 +2046,8 @@ TEST_F(PortTest, TestHandleStunMessage) { // BINDING-REQUEST from local to remote with valid ICE username, // MESSAGE-INTEGRITY, and FINGERPRINT. - in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, - "rfrag:lfrag")); + in_msg.reset( + CreateStunMessageWithUsername(STUN_BINDING_REQUEST, "rfrag:lfrag")); in_msg->AddMessageIntegrity("rpass"); in_msg->AddFingerprint(); WriteStunMessage(in_msg.get(), buf.get()); @@ -2101,7 +2082,7 @@ TEST_F(PortTest, TestHandleStunMessage) { ASSERT_TRUE(out_msg->GetErrorCode() != NULL); EXPECT_EQ(STUN_ERROR_SERVER_ERROR, out_msg->GetErrorCode()->code()); EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), - out_msg->GetErrorCode()->reason()); + out_msg->GetErrorCode()->reason()); } // Tests handling of ICE binding requests with missing or incorrect usernames. @@ -2147,8 +2128,8 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); // BINDING-REQUEST with reversed username. - in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, - "lfrag:rfrag")); + in_msg.reset( + CreateStunMessageWithUsername(STUN_BINDING_REQUEST, "lfrag:rfrag")); in_msg->AddMessageIntegrity("rpass"); in_msg->AddFingerprint(); WriteStunMessage(in_msg.get(), buf.get()); @@ -2159,8 +2140,8 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); // BINDING-REQUEST with garbage username. - in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, - "abcd:efgh")); + in_msg.reset( + CreateStunMessageWithUsername(STUN_BINDING_REQUEST, "abcd:efgh")); in_msg->AddMessageIntegrity("rpass"); in_msg->AddFingerprint(); WriteStunMessage(in_msg.get(), buf.get()); @@ -2183,8 +2164,8 @@ TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { // BINDING-REQUEST from local to remote with valid ICE username and // FINGERPRINT, but no MESSAGE-INTEGRITY. - in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, - "rfrag:lfrag")); + in_msg.reset( + CreateStunMessageWithUsername(STUN_BINDING_REQUEST, "rfrag:lfrag")); in_msg->AddFingerprint(); WriteStunMessage(in_msg.get(), buf.get()); EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, @@ -2195,8 +2176,8 @@ TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { // BINDING-REQUEST from local to remote with valid ICE username and // FINGERPRINT, but invalid MESSAGE-INTEGRITY. - in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, - "rfrag:lfrag")); + in_msg.reset( + CreateStunMessageWithUsername(STUN_BINDING_REQUEST, "rfrag:lfrag")); in_msg->AddMessageIntegrity("invalid"); in_msg->AddFingerprint(); WriteStunMessage(in_msg.get(), buf.get()); @@ -2223,8 +2204,8 @@ TEST_F(PortTest, TestHandleStunMessageBadFingerprint) { // BINDING-REQUEST from local to remote with valid ICE username and // MESSAGE-INTEGRITY, but no FINGERPRINT; GetStunMessage should fail. - in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, - "rfrag:lfrag")); + in_msg.reset( + CreateStunMessageWithUsername(STUN_BINDING_REQUEST, "rfrag:lfrag")); in_msg->AddMessageIntegrity("rpass"); WriteStunMessage(in_msg.get(), buf.get()); EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, @@ -2312,10 +2293,10 @@ TEST_F(PortTest, TestHandleStunBindingIndication) { ASSERT_FALSE(lport->Candidates().empty()); ASSERT_FALSE(rport->Candidates().empty()); - Connection* lconn = lport->CreateConnection(rport->Candidates()[0], - Port::ORIGIN_MESSAGE); - Connection* rconn = rport->CreateConnection(lport->Candidates()[0], - Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* rconn = + rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); rconn->Ping(0); ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, kDefaultTimeout); @@ -2323,8 +2304,7 @@ TEST_F(PortTest, TestHandleStunBindingIndication) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); // Send rport binding request to lport. lconn->OnReadPacket(rport->last_stun_buf()->data(), - rport->last_stun_buf()->size(), - rtc::PacketTime()); + rport->last_stun_buf()->size(), rtc::PacketTime()); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); int64_t last_ping_received1 = lconn->last_ping_received(); @@ -2377,11 +2357,9 @@ TEST_F(PortTest, TestComputeCandidatePriority) { TEST_F(PortTest, TestFoundation) { std::unique_ptr testport( CreateTestPort(kLocalAddr1, "name", "pass")); - testport->AddCandidateAddress(kLocalAddr1, kLocalAddr1, - LOCAL_PORT_TYPE, + testport->AddCandidateAddress(kLocalAddr1, kLocalAddr1, LOCAL_PORT_TYPE, cricket::ICE_TYPE_PREFERENCE_HOST, false); - testport->AddCandidateAddress(kLocalAddr2, kLocalAddr1, - STUN_PORT_TYPE, + testport->AddCandidateAddress(kLocalAddr2, kLocalAddr1, STUN_PORT_TYPE, cricket::ICE_TYPE_PREFERENCE_SRFLX, true); EXPECT_NE(testport->Candidates()[0].foundation(), testport->Candidates()[1].foundation()); @@ -2446,8 +2424,8 @@ TEST_F(PortTest, TestCandidateFoundation) { // Running a second turn server, to get different base IP address. SocketAddress kTurnUdpIntAddr2("99.99.98.4", STUN_SERVER_PORT); SocketAddress kTurnUdpExtAddr2("99.99.98.5", 0); - TestTurnServer turn_server2( - rtc::Thread::Current(), kTurnUdpIntAddr2, kTurnUdpExtAddr2); + TestTurnServer turn_server2(rtc::Thread::Current(), kTurnUdpIntAddr2, + kTurnUdpExtAddr2); std::unique_ptr turnport3( CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP, kTurnUdpIntAddr2)); @@ -2485,8 +2463,7 @@ TEST_F(PortTest, TestCandidateRelatedAddress) { stunport->PrepareAddress(); ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kDefaultTimeout); // Check STUN candidate address. - EXPECT_EQ(stunport->Candidates()[0].address().ipaddr(), - kNatAddr1.ipaddr()); + EXPECT_EQ(stunport->Candidates()[0].address().ipaddr(), kNatAddr1.ipaddr()); // Check STUN candidate related address. EXPECT_EQ(stunport->Candidates()[0].related_address(), stunport->GetLocalAddress()); @@ -2499,8 +2476,7 @@ TEST_F(PortTest, TestCandidateRelatedAddress) { relayport->PrepareAddress(); ASSERT_EQ_WAIT(1U, relayport->Candidates().size(), kDefaultTimeout); // For Gturn related address is set to "0.0.0.0:0" - EXPECT_EQ(rtc::SocketAddress(), - relayport->Candidates()[0].related_address()); + EXPECT_EQ(rtc::SocketAddress(), relayport->Candidates()[0].related_address()); // Verifying the related address for TURN candidate. // For TURN related address must be equal to the mapped address. std::unique_ptr turnport( @@ -2542,8 +2518,8 @@ TEST_F(PortTest, TestConnectionPriority) { // pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) lport->SetIceRole(cricket::ICEROLE_CONTROLLING); rport->SetIceRole(cricket::ICEROLE_CONTROLLED); - Connection* lconn = lport->CreateConnection( - rport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* lconn = + lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); #if defined(WEBRTC_WIN) EXPECT_EQ(0x2001EE9FC003D0BU, lconn->priority()); #else @@ -2552,8 +2528,8 @@ TEST_F(PortTest, TestConnectionPriority) { lport->SetIceRole(cricket::ICEROLE_CONTROLLED); rport->SetIceRole(cricket::ICEROLE_CONTROLLING); - Connection* rconn = rport->CreateConnection( - lport->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* rconn = + rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE); #if defined(WEBRTC_WIN) EXPECT_EQ(0x2001EE9FC003D0AU, rconn->priority()); #else @@ -2730,9 +2706,9 @@ TEST_F(PortTest, TestTimeoutForNeverWritable) { // In this test |ch1| behaves like FULL mode client and we have created // port which responds to the ping message just like LITE client. TEST_F(PortTest, TestIceLiteConnectivity) { - TestPort* ice_full_port = CreateTestPort( - kLocalAddr1, "lfrag", "lpass", - cricket::ICEROLE_CONTROLLING, kTiebreaker1); + TestPort* ice_full_port = + CreateTestPort(kLocalAddr1, "lfrag", "lpass", + cricket::ICEROLE_CONTROLLING, kTiebreaker1); std::unique_ptr ice_lite_port( CreateTestPort(kLocalAddr2, "rfrag", "rpass", cricket::ICEROLE_CONTROLLED, @@ -2766,11 +2742,11 @@ TEST_F(PortTest, TestIceLiteConnectivity) { // NOTE: Ideally we should't create connection at this stage from lite // port, as it should be done only after receiving ping with USE_CANDIDATE. // But we need a connection to send a response message. - ice_lite_port->CreateConnection( - ice_full_port->Candidates()[0], cricket::Port::ORIGIN_MESSAGE); + ice_lite_port->CreateConnection(ice_full_port->Candidates()[0], + cricket::Port::ORIGIN_MESSAGE); std::unique_ptr request(CopyStunMessage(msg)); - ice_lite_port->SendBindingResponse( - request.get(), ice_full_port->Candidates()[0].address()); + ice_lite_port->SendBindingResponse(request.get(), + ice_full_port->Candidates()[0].address()); // Feeding the respone message from litemode to the full mode connection. ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->data(), diff --git a/p2p/base/portallocator.h b/p2p/base/portallocator.h index 4d128b0b91..dcf6c6b3c3 100644 --- a/p2p/base/portallocator.h +++ b/p2p/base/portallocator.h @@ -28,7 +28,7 @@ namespace webrtc { class MetricsObserverInterface; class TurnCustomizer; -} +} // namespace webrtc namespace cricket { @@ -269,8 +269,8 @@ class PortAllocatorSession : public sigslot::has_slots<> { // ready(pairable). sigslot::signal2&> SignalPortsPruned; - sigslot::signal2&> SignalCandidatesReady; + sigslot::signal2&> + SignalCandidatesReady; // Candidates should be signaled to be removed when the port that generated // the candidates is removed. sigslot::signal2&> diff --git a/p2p/base/portinterface.h b/p2p/base/portinterface.h index 7df4543e6e..60fa4444b3 100644 --- a/p2p/base/portinterface.h +++ b/p2p/base/portinterface.h @@ -23,7 +23,7 @@ namespace rtc { class Network; struct PacketOptions; -} +} // namespace rtc namespace cricket { class Connection; @@ -68,13 +68,12 @@ class PortInterface { virtual void PrepareAddress() = 0; // Returns the connection to the given address or NULL if none exists. - virtual Connection* GetConnection( - const rtc::SocketAddress& remote_addr) = 0; + virtual Connection* GetConnection(const rtc::SocketAddress& remote_addr) = 0; // Creates a new connection to the given address. enum CandidateOrigin { ORIGIN_THIS_PORT, ORIGIN_OTHER_PORT, ORIGIN_MESSAGE }; - virtual Connection* CreateConnection( - const Candidate& remote_candidate, CandidateOrigin origin) = 0; + virtual Connection* CreateConnection(const Candidate& remote_candidate, + CandidateOrigin origin) = 0; // Functions on the underlying socket(s). virtual int SetOption(rtc::Socket::Option opt, int value) = 0; @@ -87,25 +86,32 @@ class PortInterface { // Sends the given packet to the given address, provided that the address is // that of a connection or an address that has sent to us already. - virtual int SendTo(const void* data, size_t size, + virtual int SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, - const rtc::PacketOptions& options, bool payload) = 0; + const rtc::PacketOptions& options, + bool payload) = 0; // Indicates that we received a successful STUN binding request from an // address that doesn't correspond to any current connection. To turn this // into a real connection, call CreateConnection. - sigslot::signal6 SignalUnknownAddress; + sigslot::signal6 + SignalUnknownAddress; // Sends a response message (normal or error) to the given request. One of // these methods should be called as a response to SignalUnknownAddress. // NOTE: You MUST call CreateConnection BEFORE SendBindingResponse. virtual void SendBindingResponse(StunMessage* request, const rtc::SocketAddress& addr) = 0; - virtual void SendBindingErrorResponse( - StunMessage* request, const rtc::SocketAddress& addr, - int error_code, const std::string& reason) = 0; + virtual void SendBindingErrorResponse(StunMessage* request, + const rtc::SocketAddress& addr, + int error_code, + const std::string& reason) = 0; // Signaled when this port decides to delete itself because it no longer has // any usefulness. @@ -119,8 +125,9 @@ class PortInterface { // through their respective connection and instead delivers every packet // through this port. virtual void EnablePortPackets() = 0; - sigslot::signal4 SignalReadPacket; + sigslot:: + signal4 + SignalReadPacket; // Emitted each time a packet is sent on this port. sigslot::signal1 SignalSentPacket; diff --git a/p2p/base/pseudotcp.h b/p2p/base/pseudotcp.h index 0a8507aa54..c363ef64b7 100644 --- a/p2p/base/pseudotcp.h +++ b/p2p/base/pseudotcp.h @@ -34,7 +34,8 @@ class IPseudoTcpNotify { // Write the packet onto the network enum WriteResult { WR_SUCCESS, WR_TOO_LARGE, WR_FAIL }; virtual WriteResult TcpWritePacket(PseudoTcp* tcp, - const char* buffer, size_t len) = 0; + const char* buffer, + size_t len) = 0; protected: virtual ~IPseudoTcpNotify() {} @@ -58,7 +59,11 @@ class PseudoTcp { int GetError(); enum TcpState { - TCP_LISTEN, TCP_SYN_SENT, TCP_SYN_RECEIVED, TCP_ESTABLISHED, TCP_CLOSED + TCP_LISTEN, + TCP_SYN_SENT, + TCP_SYN_RECEIVED, + TCP_ESTABLISHED, + TCP_CLOSED }; TcpState State() const { return m_state; } @@ -71,7 +76,7 @@ class PseudoTcp { // Call this whenever a packet arrives. // Returns true if the packet was processed successfully. - bool NotifyPacket(const char * buffer, size_t len); + bool NotifyPacket(const char* buffer, size_t len); // Call this to determine the next time NotifyClock should be called. // Returns false if the socket is ready to be destroyed. @@ -84,10 +89,10 @@ class PseudoTcp { // Setting options for OPT_RCVBUF or OPT_SNDBUF after Connect() is called // will result in an assertion. enum Option { - OPT_NODELAY, // Whether to enable Nagle's algorithm (0 == off) - OPT_ACKDELAY, // The Delayed ACK timeout (0 == off). - OPT_RCVBUF, // Set the receive buffer size, in bytes. - OPT_SNDBUF, // Set the send buffer size, in bytes. + OPT_NODELAY, // Whether to enable Nagle's algorithm (0 == off) + OPT_ACKDELAY, // The Delayed ACK timeout (0 == off). + OPT_RCVBUF, // Set the receive buffer size, in bytes. + OPT_SNDBUF, // Set the send buffer size, in bytes. }; void GetOption(Option opt, int* value); void SetOption(Option opt, int value); @@ -113,7 +118,7 @@ class PseudoTcp { uint32_t conv, seq, ack; uint8_t flags; uint16_t wnd; - const char * data; + const char* data; uint32_t len; uint32_t tsval, tsecr; }; diff --git a/p2p/base/relayport.cc b/p2p/base/relayport.cc index 373882fd68..7413f3b6e2 100644 --- a/p2p/base/relayport.cc +++ b/p2p/base/relayport.cc @@ -18,11 +18,11 @@ namespace cricket { static const int kMessageConnectTimeout = 1; -static const int kKeepAliveDelay = 10 * 60 * 1000; -static const int kRetryTimeout = 50 * 1000; // ICE says 50 secs +static const int kKeepAliveDelay = 10 * 60 * 1000; +static const int kRetryTimeout = 50 * 1000; // ICE says 50 secs // How long to wait for a socket to connect to remote host in milliseconds // before trying another connection. -static const int kSoftConnectTimeoutMs = 3 * 1000; +static const int kSoftConnectTimeoutMs = 3 * 1000; // Handles a connection to one address/port/protocol combination for a // particular RelayEntry. @@ -34,17 +34,11 @@ class RelayConnection : public sigslot::has_slots<> { ~RelayConnection() override; rtc::AsyncPacketSocket* socket() const { return socket_; } - const ProtocolAddress* protocol_address() { - return protocol_address_; - } + const ProtocolAddress* protocol_address() { return protocol_address_; } - rtc::SocketAddress GetAddress() const { - return protocol_address_->address; - } + rtc::SocketAddress GetAddress() const { return protocol_address_->address; } - ProtocolType GetProtocol() const { - return protocol_address_->proto; - } + ProtocolType GetProtocol() const { return protocol_address_->proto; } int SetSocketOption(rtc::Socket::Option opt, int value); @@ -67,15 +61,14 @@ class RelayConnection : public sigslot::has_slots<> { private: rtc::AsyncPacketSocket* socket_; const ProtocolAddress* protocol_address_; - StunRequestManager *request_manager_; + StunRequestManager* request_manager_; }; // Manages a number of connections to the relayserver, one for each // available protocol. We aim to use each connection for only a // specific destination address so that we can avoid wrapping every // packet in a STUN send / data indication. -class RelayEntry : public rtc::MessageHandler, - public sigslot::has_slots<> { +class RelayEntry : public rtc::MessageHandler, public sigslot::has_slots<> { public: RelayEntry(RelayPort* port, const rtc::SocketAddress& ext_addr); ~RelayEntry() override; @@ -107,7 +100,8 @@ class RelayEntry : public rtc::MessageHandler, // Sends a packet to the given destination address using the socket of this // entry. This will wrap the packet in STUN if necessary. - int SendTo(const void* data, size_t size, + int SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, const rtc::PacketOptions& options); @@ -140,11 +134,11 @@ class RelayEntry : public rtc::MessageHandler, void OnSocketClose(rtc::AsyncPacketSocket* socket, int error); // Called when a packet is received on this socket. - void OnReadPacket( - rtc::AsyncPacketSocket* socket, - const char* data, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time); + void OnReadPacket(rtc::AsyncPacketSocket* socket, + const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time); void OnSentPacket(rtc::AsyncPacketSocket* socket, const rtc::SentPacket& sent_packet); @@ -154,7 +148,8 @@ class RelayEntry : public rtc::MessageHandler, // Sends the given data on the socket to the server with no wrapping. This // returns the number of bytes written or -1 if an error occurred. - int SendPacket(const void* data, size_t size, + int SendPacket(const void* data, + size_t size, const rtc::PacketOptions& options); }; @@ -196,8 +191,7 @@ RelayPort::RelayPort(rtc::Thread* thread, password), ready_(false), error_(0) { - entries_.push_back( - new RelayEntry(this, rtc::SocketAddress())); + entries_.push_back(new RelayEntry(this, rtc::SocketAddress())); // TODO(?): set local preference value for TCP based candidates. } @@ -210,9 +204,8 @@ RelayPort::~RelayPort() { void RelayPort::AddServerAddress(const ProtocolAddress& addr) { // Since HTTP proxies usually only allow 443, // let's up the priority on PROTO_SSLTCP - if (addr.proto == PROTO_SSLTCP && - (proxy().type == rtc::PROXY_HTTPS || - proxy().type == rtc::PROXY_UNKNOWN)) { + if (addr.proto == PROTO_SSLTCP && (proxy().type == rtc::PROXY_HTTPS || + proxy().type == rtc::PROXY_UNKNOWN)) { server_addr_.push_front(addr); } else { server_addr_.push_back(addr); @@ -235,8 +228,7 @@ void RelayPort::AddExternalAddress(const ProtocolAddress& addr) { void RelayPort::SetReady() { if (!ready_) { std::vector::iterator iter; - for (iter = external_addr_.begin(); - iter != external_addr_.end(); ++iter) { + for (iter = external_addr_.begin(); iter != external_addr_.end(); ++iter) { std::string proto_name = ProtoToString(iter->proto); // In case of Gturn, related address is set to null socket address. // This is due to as mapped address stun attribute is used for allocated @@ -250,7 +242,7 @@ void RelayPort::SetReady() { } } -const ProtocolAddress * RelayPort::ServerAddress(size_t index) const { +const ProtocolAddress* RelayPort::ServerAddress(size_t index) const { if (index < server_addr_.size()) return &server_addr_[index]; return NULL; @@ -260,8 +252,7 @@ bool RelayPort::HasMagicCookie(const char* data, size_t size) { if (size < 24 + sizeof(TURN_MAGIC_COOKIE_VALUE)) { return false; } else { - return memcmp(data + 24, - TURN_MAGIC_COOKIE_VALUE, + return memcmp(data + 24, TURN_MAGIC_COOKIE_VALUE, sizeof(TURN_MAGIC_COOKIE_VALUE)) == 0; } } @@ -300,12 +291,13 @@ Connection* RelayPort::CreateConnection(const Candidate& address, } } - Connection * conn = new ProxyConnection(this, index, address); + Connection* conn = new ProxyConnection(this, index, address); AddOrReplaceConnection(conn); return conn; } -int RelayPort::SendTo(const void* data, size_t size, +int RelayPort::SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, const rtc::PacketOptions& options, bool payload) { @@ -400,11 +392,11 @@ ProtocolType RelayPort::GetProtocol() const { return PROTO_UDP; } -void RelayPort::OnReadPacket( - const char* data, size_t size, - const rtc::SocketAddress& remote_addr, - ProtocolType proto, - const rtc::PacketTime& packet_time) { +void RelayPort::OnReadPacket(const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, + ProtocolType proto, + const rtc::PacketTime& packet_time) { if (Connection* conn = GetConnection(remote_addr)) { conn->OnReadPacket(data, size, packet_time); } else { @@ -415,8 +407,7 @@ void RelayPort::OnReadPacket( RelayConnection::RelayConnection(const ProtocolAddress* protocol_address, rtc::AsyncPacketSocket* socket, rtc::Thread* thread) - : socket_(socket), - protocol_address_(protocol_address) { + : socket_(socket), protocol_address_(protocol_address) { request_manager_ = new StunRequestManager(thread); request_manager_->SignalSendPacket.connect(this, &RelayConnection::OnSendPacket); @@ -427,8 +418,7 @@ RelayConnection::~RelayConnection() { delete socket_; } -int RelayConnection::SetSocketOption(rtc::Socket::Option opt, - int value) { +int RelayConnection::SetSocketOption(rtc::Socket::Option opt, int value) { if (socket_) { return socket_->SetOption(opt, value); } @@ -439,7 +429,8 @@ bool RelayConnection::CheckResponse(StunMessage* msg) { return request_manager_->CheckResponse(msg); } -void RelayConnection::OnSendPacket(const void* data, size_t size, +void RelayConnection::OnSendPacket(const void* data, + size_t size, StunRequest* req) { // TODO(mallinath) Find a way to get DSCP value from Port. rtc::PacketOptions options; // Default dscp set to NO_CHANGE. @@ -452,7 +443,8 @@ void RelayConnection::OnSendPacket(const void* data, size_t size, } } -int RelayConnection::Send(const void* pv, size_t cb, +int RelayConnection::Send(const void* pv, + size_t cb, const rtc::PacketOptions& options) { return socket_->SendTo(pv, cb, GetAddress(), options); } @@ -461,12 +453,13 @@ void RelayConnection::SendAllocateRequest(RelayEntry* entry, int delay) { request_manager_->SendDelayed(new AllocateRequest(entry, this), delay); } -RelayEntry::RelayEntry(RelayPort* port, - const rtc::SocketAddress& ext_addr) - : port_(port), ext_addr_(ext_addr), - server_index_(0), connected_(false), locked_(false), - current_connection_(NULL) { -} +RelayEntry::RelayEntry(RelayPort* port, const rtc::SocketAddress& ext_addr) + : port_(port), + ext_addr_(ext_addr), + server_index_(0), + connected_(false), + locked_(false), + current_connection_(NULL) {} RelayEntry::~RelayEntry() { // Remove all RelayConnections and dispose sockets. @@ -567,7 +560,8 @@ void RelayEntry::OnConnect(const rtc::SocketAddress& mapped_addr, port_->SetReady(); } -int RelayEntry::SendTo(const void* data, size_t size, +int RelayEntry::SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, const rtc::PacketOptions& options) { // If this connection is locked to the address given, then we can send the @@ -635,8 +629,7 @@ int RelayEntry::SetSocketOption(rtc::Socket::Option opt, int value) { return socket_error; } -void RelayEntry::HandleConnectFailure( - rtc::AsyncPacketSocket* socket) { +void RelayEntry::HandleConnectFailure(rtc::AsyncPacketSocket* socket) { // Make sure it's the current connection that has failed, it might // be an old socked that has not yet been disposed. if (!socket || @@ -650,7 +643,7 @@ void RelayEntry::HandleConnectFailure( } } -void RelayEntry::OnMessage(rtc::Message *pmsg) { +void RelayEntry::OnMessage(rtc::Message* pmsg) { RTC_DCHECK(pmsg->message_id == kMessageConnectTimeout); if (current_connection_) { const ProtocolAddress* ra = current_connection_->protocol_address(); @@ -679,17 +672,16 @@ void RelayEntry::OnSocketConnect(rtc::AsyncPacketSocket* socket) { } } -void RelayEntry::OnSocketClose(rtc::AsyncPacketSocket* socket, - int error) { +void RelayEntry::OnSocketClose(rtc::AsyncPacketSocket* socket, int error) { RTC_LOG_ERR_EX(LERROR, error) << "Relay connection failed: socket closed"; HandleConnectFailure(socket); } -void RelayEntry::OnReadPacket( - rtc::AsyncPacketSocket* socket, - const char* data, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time) { +void RelayEntry::OnReadPacket(rtc::AsyncPacketSocket* socket, + const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time) { // RTC_DCHECK(remote_addr == port_->server_addr()); // TODO(?): are we worried about this? @@ -723,7 +715,7 @@ void RelayEntry::OnReadPacket( return; } else if (msg.type() == STUN_SEND_RESPONSE) { if (const StunUInt32Attribute* options_attr = - msg.GetUInt32(STUN_ATTR_OPTIONS)) { + msg.GetUInt32(STUN_ATTR_OPTIONS)) { if (options_attr->value() & 0x1) { locked_ = true; } @@ -770,7 +762,8 @@ void RelayEntry::OnReadyToSend(rtc::AsyncPacketSocket* socket) { } } -int RelayEntry::SendPacket(const void* data, size_t size, +int RelayEntry::SendPacket(const void* data, + size_t size, const rtc::PacketOptions& options) { int sent = 0; if (current_connection_) { @@ -781,11 +774,8 @@ int RelayEntry::SendPacket(const void* data, size_t size, return sent; } -AllocateRequest::AllocateRequest(RelayEntry* entry, - RelayConnection* connection) - : StunRequest(new RelayMessage()), - entry_(entry), - connection_(connection) { +AllocateRequest::AllocateRequest(RelayEntry* entry, RelayConnection* connection) + : StunRequest(new RelayMessage()), entry_(entry), connection_(connection) { start_time_ = rtc::TimeMillis(); } @@ -793,9 +783,8 @@ void AllocateRequest::Prepare(StunMessage* request) { request->SetType(STUN_ALLOCATE_REQUEST); auto username_attr = StunAttribute::CreateByteString(STUN_ATTR_USERNAME); - username_attr->CopyBytes( - entry_->port()->username_fragment().c_str(), - entry_->port()->username_fragment().size()); + username_attr->CopyBytes(entry_->port()->username_fragment().c_str(), + entry_->port()->username_fragment().size()); request->AddAttribute(std::move(username_attr)); } @@ -809,10 +798,9 @@ int AllocateRequest::resend_delay() { if (count_ == 0) { return 0; } - return 100 * std::max(1 << (count_-1), 2); + return 100 * std::max(1 << (count_ - 1), 2); } - void AllocateRequest::OnResponse(StunMessage* response) { const StunAddressAttribute* addr_attr = response->GetAddress(STUN_ATTR_MAPPED_ADDRESS); diff --git a/p2p/base/relayport.h b/p2p/base/relayport.h index 3e1416df77..48a939e0cf 100644 --- a/p2p/base/relayport.h +++ b/p2p/base/relayport.h @@ -62,7 +62,7 @@ class RelayPort : public Port { bool SupportsProtocol(const std::string& protocol) const override; ProtocolType GetProtocol() const override; - const ProtocolAddress * ServerAddress(size_t index) const; + const ProtocolAddress* ServerAddress(size_t index) const; bool IsReady() { return ready_; } // Used for testing. @@ -88,7 +88,8 @@ class RelayPort : public Port { bool payload) override; // Dispatches the given packet to the port or connection as appropriate. - void OnReadPacket(const char* data, size_t size, + void OnReadPacket(const char* data, + size_t size, const rtc::SocketAddress& remote_addr, ProtocolType proto, const rtc::PacketTime& packet_time); diff --git a/p2p/base/relayport_unittest.cc b/p2p/base/relayport_unittest.cc index fc12ffc402..e6e922fdaf 100644 --- a/p2p/base/relayport_unittest.cc +++ b/p2p/base/relayport_unittest.cc @@ -41,8 +41,7 @@ static const int kMaxTimeoutMs = 5000; // RelayPort and created sockets by listening for signals such as, // SignalConnectFailure, SignalConnectTimeout, SignalSocketClosed and // SignalReadPacket. -class RelayPortTest : public testing::Test, - public sigslot::has_slots<> { +class RelayPortTest : public testing::Test, public sigslot::has_slots<> { public: RelayPortTest() : virtual_socket_server_(new rtc::VirtualSocketServer()), @@ -63,7 +62,8 @@ class RelayPortTest : public testing::Test, } void OnReadPacket(rtc::AsyncPacketSocket* socket, - const char* data, size_t size, + const char* data, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time) { received_packet_count_[socket]++; @@ -80,17 +80,15 @@ class RelayPortTest : public testing::Test, protected: virtual void SetUp() { // The relay server needs an external socket to work properly. - rtc::AsyncUDPSocket* ext_socket = - CreateAsyncUdpSocket(kRelayExtAddr); + rtc::AsyncUDPSocket* ext_socket = CreateAsyncUdpSocket(kRelayExtAddr); relay_server_->AddExternalSocket(ext_socket); // Listen for failures. - relay_port_->SignalConnectFailure. - connect(this, &RelayPortTest::OnConnectFailure); + relay_port_->SignalConnectFailure.connect(this, + &RelayPortTest::OnConnectFailure); // Listen for soft timeouts. - relay_port_->SignalSoftTimeout. - connect(this, &RelayPortTest::OnSoftTimeout); + relay_port_->SignalSoftTimeout.connect(this, &RelayPortTest::OnSoftTimeout); } // Udp has the highest 'goodness' value of the three different @@ -177,8 +175,7 @@ class RelayPortTest : public testing::Test, cricket::ProtocolAddress(kRelayTcpAddr, cricket::PROTO_TCP); // Create a ssl server socket for the RelayServer. - rtc::AsyncSocket* ssl_server_socket = - CreateServerSocket(kRelaySslAddr); + rtc::AsyncSocket* ssl_server_socket = CreateServerSocket(kRelaySslAddr); relay_server_->AddInternalServerSocket(ssl_server_socket, cricket::PROTO_SSLTCP); diff --git a/p2p/base/relayserver.cc b/p2p/base/relayserver.cc index 9bb53ad45a..8e17a79db8 100644 --- a/p2p/base/relayserver.cc +++ b/p2p/base/relayserver.cc @@ -33,7 +33,9 @@ const int MAX_LIFETIME = 15 * 60 * 1000; const uint32_t USERNAME_LENGTH = 16; // Calls SendTo on the given socket and logs any bad results. -void Send(rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, +void Send(rtc::AsyncPacketSocket* socket, + const char* bytes, + size_t size, const rtc::SocketAddress& addr) { rtc::PacketOptions options; int result = socket->SendTo(bytes, size, addr, options); @@ -55,9 +57,12 @@ void SendStun(const StunMessage& msg, } // Constructs a STUN error response and sends it on the given socket. -void SendStunError(const StunMessage& msg, rtc::AsyncPacketSocket* socket, - const rtc::SocketAddress& remote_addr, int error_code, - const char* error_desc, const std::string& magic_cookie) { +void SendStunError(const StunMessage& msg, + rtc::AsyncPacketSocket* socket, + const rtc::SocketAddress& remote_addr, + int error_code, + const char* error_desc, + const std::string& magic_cookie) { RelayMessage err_msg; err_msg.SetType(GetStunErrorResponseType(msg.type())); err_msg.SetTransactionID(msg.transaction_id()); @@ -82,8 +87,7 @@ void SendStunError(const StunMessage& msg, rtc::AsyncPacketSocket* socket, } RelayServer::RelayServer(rtc::Thread* thread) - : thread_(thread), random_(rtc::SystemTimeNanos()), log_bindings_(true) { -} + : thread_(thread), random_(rtc::SystemTimeNanos()), log_bindings_(true) {} RelayServer::~RelayServer() { // Deleting the binding will cause it to be removed from the map. @@ -143,8 +147,7 @@ void RelayServer::AddInternalServerSocket(rtc::AsyncSocket* socket, socket->SignalReadEvent.connect(this, &RelayServer::OnReadEvent); } -void RelayServer::RemoveInternalServerSocket( - rtc::AsyncSocket* socket) { +void RelayServer::RemoveInternalServerSocket(rtc::AsyncSocket* socket) { ServerSocketMap::iterator iter = server_sockets_.find(socket); RTC_DCHECK(iter != server_sockets_.end()); server_sockets_.erase(iter); @@ -182,11 +185,11 @@ void RelayServer::OnReadEvent(rtc::AsyncSocket* socket) { AcceptConnection(socket); } -void RelayServer::OnInternalPacket( - rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time) { - +void RelayServer::OnInternalPacket(rtc::AsyncPacketSocket* socket, + const char* bytes, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time) { // Get the address of the connection we just received on. rtc::SocketAddressPair ap(remote_addr, socket->GetLocalAddress()); RTC_DCHECK(!ap.destination().IsNil()); @@ -227,11 +230,11 @@ void RelayServer::OnInternalPacket( } } -void RelayServer::OnExternalPacket( - rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time) { - +void RelayServer::OnExternalPacket(rtc::AsyncPacketSocket* socket, + const char* bytes, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time) { // Get the address of the connection we just received on. rtc::SocketAddressPair ap(remote_addr, socket->GetLocalAddress()); RTC_DCHECK(!ap.destination().IsNil()); @@ -296,11 +299,12 @@ void RelayServer::OnExternalPacket( int_conn->Send(bytes, size, ext_conn->addr_pair().source()); } -bool RelayServer::HandleStun( - const char* bytes, size_t size, const rtc::SocketAddress& remote_addr, - rtc::AsyncPacketSocket* socket, std::string* username, - StunMessage* msg) { - +bool RelayServer::HandleStun(const char* bytes, + size_t size, + const rtc::SocketAddress& remote_addr, + rtc::AsyncPacketSocket* socket, + std::string* username, + StunMessage* msg) { // Parse this into a stun message. Eat the message if this fails. rtc::ByteBufferReader buf(bytes, size); if (!msg->Read(&buf)) { @@ -324,10 +328,10 @@ bool RelayServer::HandleStun( return true; } -void RelayServer::HandleStunAllocate( - const char* bytes, size_t size, const rtc::SocketAddressPair& ap, - rtc::AsyncPacketSocket* socket) { - +void RelayServer::HandleStunAllocate(const char* bytes, + size_t size, + const rtc::SocketAddressPair& ap, + rtc::AsyncPacketSocket* socket) { // Make sure this is a valid STUN request. RelayMessage request; std::string username; @@ -336,11 +340,7 @@ void RelayServer::HandleStunAllocate( // Make sure this is a an allocate request. if (request.type() != STUN_ALLOCATE_REQUEST) { - SendStunError(request, - socket, - ap.source(), - 600, - "Operation Not Supported", + SendStunError(request, socket, ap.source(), 600, "Operation Not Supported", ""); return; } @@ -386,9 +386,9 @@ void RelayServer::HandleStunAllocate( HandleStunAllocate(int_conn, request); } -void RelayServer::HandleStun( - RelayServerConnection* int_conn, const char* bytes, size_t size) { - +void RelayServer::HandleStun(RelayServerConnection* int_conn, + const char* bytes, + size_t size) { // Make sure this is a valid STUN request. RelayMessage request; std::string username; @@ -413,9 +413,8 @@ void RelayServer::HandleStun( int_conn->SendStunError(request, 600, "Operation Not Supported"); } -void RelayServer::HandleStunAllocate( - RelayServerConnection* int_conn, const StunMessage& request) { - +void RelayServer::HandleStunAllocate(RelayServerConnection* int_conn, + const StunMessage& request) { // Create a response message that includes an address with which external // clients can communicate. @@ -430,10 +429,9 @@ void RelayServer::HandleStunAllocate( response.AddAttribute(std::move(magic_cookie_attr)); RTC_DCHECK_GT(external_sockets_.size(), 0); - size_t index = random_.Rand(rtc::dchecked_cast( - external_sockets_.size() - 1)); - rtc::SocketAddress ext_addr = - external_sockets_[index]->GetLocalAddress(); + size_t index = + random_.Rand(rtc::dchecked_cast(external_sockets_.size() - 1)); + rtc::SocketAddress ext_addr = external_sockets_[index]->GetLocalAddress(); auto addr_attr = StunAttribute::CreateAddress(STUN_ATTR_MAPPED_ADDRESS); addr_attr->SetIP(ext_addr.ipaddr()); @@ -452,9 +450,8 @@ void RelayServer::HandleStunAllocate( int_conn->SendStun(response); } -void RelayServer::HandleStunSend( - RelayServerConnection* int_conn, const StunMessage& request) { - +void RelayServer::HandleStunSend(RelayServerConnection* int_conn, + const StunMessage& request) { const StunAddressAttribute* addr_attr = request.GetAddress(STUN_ATTR_DESTINATION_ADDRESS); if (!addr_attr) { @@ -533,14 +530,13 @@ void RelayServer::RemoveBinding(RelayServerBinding* binding) { } } -void RelayServer::OnMessage(rtc::Message *pmsg) { +void RelayServer::OnMessage(rtc::Message* pmsg) { static const uint32_t kMessageAcceptConnection = 1; RTC_DCHECK(pmsg->message_id == kMessageAcceptConnection); rtc::MessageData* data = pmsg->pdata; rtc::AsyncSocket* socket = - static_cast *> - (data)->data(); + static_cast*>(data)->data(); AcceptConnection(socket); delete data; } @@ -554,8 +550,7 @@ void RelayServer::OnTimeout(RelayServerBinding* binding) { void RelayServer::AcceptConnection(rtc::AsyncSocket* server_socket) { // Check if someone is trying to connect to us. rtc::SocketAddress accept_addr; - rtc::AsyncSocket* accepted_socket = - server_socket->Accept(&accept_addr); + rtc::AsyncSocket* accepted_socket = server_socket->Accept(&accept_addr); if (accepted_socket != NULL) { // We had someone trying to connect, now check which protocol to // use and create a packet socket. @@ -573,9 +568,10 @@ void RelayServer::AcceptConnection(rtc::AsyncSocket* server_socket) { } RelayServerConnection::RelayServerConnection( - RelayServerBinding* binding, const rtc::SocketAddressPair& addrs, + RelayServerBinding* binding, + const rtc::SocketAddressPair& addrs, rtc::AsyncPacketSocket* socket) - : binding_(binding), addr_pair_(addrs), socket_(socket), locked_(false) { + : binding_(binding), addr_pair_(addrs), socket_(socket), locked_(false) { // The creation of a new connection constitutes a use of the binding. binding_->NoteUsed(); } @@ -592,8 +588,9 @@ void RelayServerConnection::Send(const char* data, size_t size) { cricket::Send(socket_, data, size, addr_pair_.source()); } -void RelayServerConnection::Send( - const char* data, size_t size, const rtc::SocketAddress& from_addr) { +void RelayServerConnection::Send(const char* data, + size_t size, + const rtc::SocketAddress& from_addr) { // If the from address is known to the client, we don't need to send it. if (locked() && (from_addr == default_dest_)) { Send(data, size); @@ -631,14 +628,14 @@ void RelayServerConnection::SendStun(const StunMessage& msg) { cricket::SendStun(msg, socket_, addr_pair_.source()); } -void RelayServerConnection::SendStunError( - const StunMessage& request, int error_code, const char* error_desc) { +void RelayServerConnection::SendStunError(const StunMessage& request, + int error_code, + const char* error_desc) { // An error does not indicate use. If no legitimate use off the binding // occurs, we want it to be cleaned up even if errors are still occuring. - cricket::SendStunError( - request, socket_, addr_pair_.source(), error_code, error_desc, - binding_->magic_cookie()); + cricket::SendStunError(request, socket_, addr_pair_.source(), error_code, + error_desc, binding_->magic_cookie()); } void RelayServerConnection::Lock() { @@ -661,9 +658,8 @@ RelayServerBinding::RelayServerBinding(RelayServer* server, password_(password), lifetime_(lifetime) { // For now, every connection uses the standard magic cookie value. - magic_cookie_.append( - reinterpret_cast(TURN_MAGIC_COOKIE_VALUE), - sizeof(TURN_MAGIC_COOKIE_VALUE)); + magic_cookie_.append(reinterpret_cast(TURN_MAGIC_COOKIE_VALUE), + sizeof(TURN_MAGIC_COOKIE_VALUE)); // Initialize the last-used time to now. NoteUsed(); @@ -709,7 +705,6 @@ bool RelayServerBinding::HasMagicCookie(const char* bytes, size_t size) const { RelayServerConnection* RelayServerBinding::GetInternalConnection( const rtc::SocketAddress& ext_addr) { - // Look for an internal connection that is locked to this address. for (size_t i = 0; i < internal_connections_.size(); ++i) { if (internal_connections_[i]->locked() && @@ -731,7 +726,7 @@ RelayServerConnection* RelayServerBinding::GetExternalConnection( return 0; } -void RelayServerBinding::OnMessage(rtc::Message *pmsg) { +void RelayServerBinding::OnMessage(rtc::Message* pmsg) { if (pmsg->message_id == MSG_LIFETIME_TIMER) { RTC_DCHECK(!pmsg->pdata); diff --git a/p2p/base/relayserver.h b/p2p/base/relayserver.h index 54ef1cb07e..c7661204f8 100644 --- a/p2p/base/relayserver.h +++ b/p2p/base/relayserver.h @@ -30,8 +30,7 @@ class RelayServerConnection; // Relays traffic between connections to the server that are "bound" together. // All connections created with the same username/password are bound together. -class RelayServer : public rtc::MessageHandler, - public sigslot::has_slots<> { +class RelayServer : public rtc::MessageHandler, public sigslot::has_slots<> { public: // Creates a server, which will use this thread to post messages to itself. explicit RelayServer(rtc::Thread* thread); @@ -70,11 +69,10 @@ class RelayServer : public rtc::MessageHandler, private: typedef std::vector SocketList; - typedef std::map ServerSocketMap; + typedef std::map ServerSocketMap; typedef std::map BindingMap; - typedef std::map ConnectionMap; + typedef std::map + ConnectionMap; rtc::Thread* thread_; webrtc::Random random_; @@ -88,25 +86,31 @@ class RelayServer : public rtc::MessageHandler, // Called when a packet is received by the server on one of its sockets. void OnInternalPacket(rtc::AsyncPacketSocket* socket, - const char* bytes, size_t size, + const char* bytes, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time); void OnExternalPacket(rtc::AsyncPacketSocket* socket, - const char* bytes, size_t size, + const char* bytes, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time); void OnReadEvent(rtc::AsyncSocket* socket); // Processes the relevant STUN request types from the client. - bool HandleStun(const char* bytes, size_t size, + bool HandleStun(const char* bytes, + size_t size, const rtc::SocketAddress& remote_addr, rtc::AsyncPacketSocket* socket, - std::string* username, StunMessage* msg); - void HandleStunAllocate(const char* bytes, size_t size, + std::string* username, + StunMessage* msg); + void HandleStunAllocate(const char* bytes, + size_t size, const rtc::SocketAddressPair& ap, rtc::AsyncPacketSocket* socket); - void HandleStun(RelayServerConnection* int_conn, const char* bytes, + void HandleStun(RelayServerConnection* int_conn, + const char* bytes, size_t size); void HandleStunAllocate(RelayServerConnection* int_conn, const StunMessage& msg); @@ -149,8 +153,7 @@ class RelayServerConnection { // Sends a packet to the connected client. If an address is provided, then // we make sure the internal client receives it, wrapping if necessary. void Send(const char* data, size_t size); - void Send(const char* data, size_t size, - const rtc::SocketAddress& ext_addr); + void Send(const char* data, size_t size, const rtc::SocketAddress& ext_addr); // Sends a STUN message to the connected client with no wrapping. void SendStun(const StunMessage& msg); diff --git a/p2p/base/relayserver_unittest.cc b/p2p/base/relayserver_unittest.cc index 8024016669..36b51f11d9 100644 --- a/p2p/base/relayserver_unittest.cc +++ b/p2p/base/relayserver_unittest.cc @@ -95,30 +95,20 @@ class RelayServerTest : public testing::Test { void SendRaw2(const char* data, int len) { return Send(client2_.get(), data, len, server_ext_addr); } - void Send(rtc::TestClient* client, const char* data, - int len, const SocketAddress& addr) { + void Send(rtc::TestClient* client, + const char* data, + int len, + const SocketAddress& addr) { client->SendTo(data, len, addr); } - bool Receive1Fails() { - return client1_.get()->CheckNoPacket(); - } - bool Receive2Fails() { - return client2_.get()->CheckNoPacket(); - } + bool Receive1Fails() { return client1_.get()->CheckNoPacket(); } + bool Receive2Fails() { return client2_.get()->CheckNoPacket(); } - StunMessage* Receive1() { - return Receive(client1_.get()); - } - StunMessage* Receive2() { - return Receive(client2_.get()); - } - std::string ReceiveRaw1() { - return ReceiveRaw(client1_.get()); - } - std::string ReceiveRaw2() { - return ReceiveRaw(client2_.get()); - } + StunMessage* Receive1() { return Receive(client1_.get()); } + StunMessage* Receive2() { return Receive(client2_.get()); } + std::string ReceiveRaw1() { return ReceiveRaw(client1_.get()); } + std::string ReceiveRaw2() { return ReceiveRaw(client2_.get()); } StunMessage* Receive(rtc::TestClient* client) { StunMessage* msg = NULL; std::unique_ptr packet = @@ -144,8 +134,7 @@ class RelayServerTest : public testing::Test { static StunMessage* CreateStunMessage(int type) { StunMessage* msg = new RelayMessage(); msg->SetType(type); - msg->SetTransactionID( - rtc::CreateRandomString(kStunTransactionIdLength)); + msg->SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); return msg; } static void AddMagicCookieAttr(StunMessage* msg) { @@ -275,8 +264,7 @@ TEST_F(RelayServerTest, TestReallocate) { EXPECT_EQ(server_ext_addr.port(), mapped_addr->port()); EXPECT_EQ(server_ext_addr.ipaddr(), mapped_addr->ipaddr()); - const StunUInt32Attribute* lifetime_attr = - res->GetUInt32(STUN_ATTR_LIFETIME); + const StunUInt32Attribute* lifetime_attr = res->GetUInt32(STUN_ATTR_LIFETIME); ASSERT_TRUE(lifetime_attr != NULL); EXPECT_EQ(LIFETIME, lifetime_attr->value()); } @@ -296,8 +284,7 @@ TEST_F(RelayServerTest, TestRemoteBind) { ASSERT_TRUE(res); EXPECT_EQ(STUN_DATA_INDICATION, res->type()); - const StunByteStringAttribute* recv_data = - res->GetByteString(STUN_ATTR_DATA); + const StunByteStringAttribute* recv_data = res->GetByteString(STUN_ATTR_DATA); ASSERT_TRUE(recv_data != NULL); rtc::ByteBufferReader buf(recv_data->bytes(), recv_data->length()); diff --git a/p2p/base/stun.cc b/p2p/base/stun.cc index 2bedde07a2..38990f9b90 100644 --- a/p2p/base/stun.cc +++ b/p2p/base/stun.cc @@ -12,6 +12,7 @@ #include +#include #include #include @@ -40,7 +41,7 @@ const char STUN_ERROR_REASON_UNSUPPORTED_PROTOCOL[] = "Unsupported Protocol"; const char STUN_ERROR_REASON_ROLE_CONFLICT[] = "Role Conflict"; const char STUN_ERROR_REASON_SERVER_ERROR[] = "Server Error"; -const char TURN_MAGIC_COOKIE_VALUE[] = { '\x72', '\xC6', '\x4B', '\xC6' }; +const char TURN_MAGIC_COOKIE_VALUE[] = {'\x72', '\xC6', '\x4B', '\xC6'}; const char EMPTY_TRANSACTION_ID[] = "0000000000000000"; const uint32_t STUN_FINGERPRINT_XOR_VALUE = 0x5354554E; @@ -72,9 +73,8 @@ bool StunMessage::SetTransactionID(const std::string& str) { } static bool DesignatedExpertRange(int attr_type) { - return - (attr_type >= 0x4000 && attr_type <= 0x7FFF) || - (attr_type >= 0xC000 && attr_type <= 0xFFFF); + return (attr_type >= 0x4000 && attr_type <= 0x7FFF) || + (attr_type >= 0xC000 && attr_type <= 0xFFFF); } void StunMessage::AddAttribute(std::unique_ptr attr) { @@ -98,8 +98,8 @@ void StunMessage::AddAttribute(std::unique_ptr attr) { std::unique_ptr StunMessage::RemoveAttribute(int type) { std::unique_ptr attribute; for (auto it = attrs_.rbegin(); it != attrs_.rend(); ++it) { - if ((* it)->type() == type) { - attribute = std::move(* it); + if ((*it)->type() == type) { + attribute = std::move(*it); attrs_.erase(std::next(it).base()); break; } @@ -161,7 +161,8 @@ const StunUInt16ListAttribute* StunMessage::GetUnknownAttributes() const { // Verifies a STUN message has a valid MESSAGE-INTEGRITY attribute, using the // procedure outlined in RFC 5389, section 15.4. -bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, +bool StunMessage::ValidateMessageIntegrity(const char* data, + size_t size, const std::string& password) { // Verifying the size of the message. if ((size % 4) != 0 || size < kStunHeaderSize) { @@ -212,8 +213,8 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, if (size > mi_pos + kStunAttributeHeaderSize + kStunMessageIntegritySize) { // Stun message has other attributes after message integrity. // Adjust the length parameter in stun message to calculate HMAC. - size_t extra_offset = size - - (mi_pos + kStunAttributeHeaderSize + kStunMessageIntegritySize); + size_t extra_offset = + size - (mi_pos + kStunAttributeHeaderSize + kStunMessageIntegritySize); size_t new_adjusted_len = size - extra_offset - kStunHeaderSize; // Writing new length of the STUN message @ Message Length in temp buffer. @@ -226,17 +227,15 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, } char hmac[kStunMessageIntegritySize]; - size_t ret = rtc::ComputeHmac(rtc::DIGEST_SHA_1, - password.c_str(), password.size(), - temp_data.get(), mi_pos, - hmac, sizeof(hmac)); + size_t ret = + rtc::ComputeHmac(rtc::DIGEST_SHA_1, password.c_str(), password.size(), + temp_data.get(), mi_pos, hmac, sizeof(hmac)); RTC_DCHECK(ret == sizeof(hmac)); if (ret != sizeof(hmac)) return false; // Comparing the calculated HMAC with the one present in the message. - return memcmp(data + current_pos + kStunAttributeHeaderSize, - hmac, + return memcmp(data + current_pos + kStunAttributeHeaderSize, hmac, sizeof(hmac)) == 0; } @@ -244,8 +243,7 @@ bool StunMessage::AddMessageIntegrity(const std::string& password) { return AddMessageIntegrity(password.c_str(), password.size()); } -bool StunMessage::AddMessageIntegrity(const char* key, - size_t keylen) { +bool StunMessage::AddMessageIntegrity(const char* key, size_t keylen) { // Add the attribute with a dummy value. Since this is a known attribute, it // can't fail. auto msg_integrity_attr_ptr = rtc::MakeUnique( @@ -261,10 +259,8 @@ bool StunMessage::AddMessageIntegrity(const char* key, int msg_len_for_hmac = static_cast( buf.Length() - kStunAttributeHeaderSize - msg_integrity_attr->length()); char hmac[kStunMessageIntegritySize]; - size_t ret = rtc::ComputeHmac(rtc::DIGEST_SHA_1, - key, keylen, - buf.Data(), msg_len_for_hmac, - hmac, sizeof(hmac)); + size_t ret = rtc::ComputeHmac(rtc::DIGEST_SHA_1, key, keylen, buf.Data(), + msg_len_for_hmac, hmac, sizeof(hmac)); RTC_DCHECK(ret == sizeof(hmac)); if (ret != sizeof(hmac)) { RTC_LOG(LS_ERROR) << "HMAC computation failed. Message-Integrity " @@ -304,7 +300,7 @@ bool StunMessage::ValidateFingerprint(const char* data, size_t size) { uint32_t fingerprint = rtc::GetBE32(fingerprint_attr_data + kStunAttributeHeaderSize); return ((fingerprint ^ STUN_FINGERPRINT_XOR_VALUE) == - rtc::ComputeCrc32(data, size - fingerprint_attr_size)); + rtc::ComputeCrc32(data, size - fingerprint_attr_size)); } bool StunMessage::AddFingerprint() { @@ -421,20 +417,34 @@ void StunMessage::SetStunMagicCookie(uint32_t val) { StunAttributeValueType StunMessage::GetAttributeValueType(int type) const { switch (type) { - case STUN_ATTR_MAPPED_ADDRESS: return STUN_VALUE_ADDRESS; - case STUN_ATTR_USERNAME: return STUN_VALUE_BYTE_STRING; - case STUN_ATTR_MESSAGE_INTEGRITY: return STUN_VALUE_BYTE_STRING; - case STUN_ATTR_ERROR_CODE: return STUN_VALUE_ERROR_CODE; - case STUN_ATTR_UNKNOWN_ATTRIBUTES: return STUN_VALUE_UINT16_LIST; - case STUN_ATTR_REALM: return STUN_VALUE_BYTE_STRING; - case STUN_ATTR_NONCE: return STUN_VALUE_BYTE_STRING; - case STUN_ATTR_XOR_MAPPED_ADDRESS: return STUN_VALUE_XOR_ADDRESS; - case STUN_ATTR_SOFTWARE: return STUN_VALUE_BYTE_STRING; - case STUN_ATTR_ALTERNATE_SERVER: return STUN_VALUE_ADDRESS; - case STUN_ATTR_FINGERPRINT: return STUN_VALUE_UINT32; - case STUN_ATTR_ORIGIN: return STUN_VALUE_BYTE_STRING; - case STUN_ATTR_RETRANSMIT_COUNT: return STUN_VALUE_UINT32; - default: return STUN_VALUE_UNKNOWN; + case STUN_ATTR_MAPPED_ADDRESS: + return STUN_VALUE_ADDRESS; + case STUN_ATTR_USERNAME: + return STUN_VALUE_BYTE_STRING; + case STUN_ATTR_MESSAGE_INTEGRITY: + return STUN_VALUE_BYTE_STRING; + case STUN_ATTR_ERROR_CODE: + return STUN_VALUE_ERROR_CODE; + case STUN_ATTR_UNKNOWN_ATTRIBUTES: + return STUN_VALUE_UINT16_LIST; + case STUN_ATTR_REALM: + return STUN_VALUE_BYTE_STRING; + case STUN_ATTR_NONCE: + return STUN_VALUE_BYTE_STRING; + case STUN_ATTR_XOR_MAPPED_ADDRESS: + return STUN_VALUE_XOR_ADDRESS; + case STUN_ATTR_SOFTWARE: + return STUN_VALUE_BYTE_STRING; + case STUN_ATTR_ALTERNATE_SERVER: + return STUN_VALUE_ADDRESS; + case STUN_ATTR_FINGERPRINT: + return STUN_VALUE_UINT32; + case STUN_ATTR_ORIGIN: + return STUN_VALUE_BYTE_STRING; + case STUN_ATTR_RETRANSMIT_COUNT: + return STUN_VALUE_UINT32; + default: + return STUN_VALUE_UNKNOWN; } } @@ -463,14 +473,13 @@ const StunAttribute* StunMessage::GetAttribute(int type) const { bool StunMessage::IsValidTransactionId(const std::string& transaction_id) { return transaction_id.size() == kStunTransactionIdLength || - transaction_id.size() == kStunLegacyTransactionIdLength; + transaction_id.size() == kStunLegacyTransactionIdLength; } // StunAttribute StunAttribute::StunAttribute(uint16_t type, uint16_t length) - : type_(type), length_(length) { -} + : type_(type), length_(length) {} void StunAttribute::ConsumePadding(ByteBufferReader* buf) const { int remainder = length_ % 4; @@ -554,8 +563,7 @@ StunAddressAttribute::StunAddressAttribute(uint16_t type, } StunAddressAttribute::StunAddressAttribute(uint16_t type, uint16_t length) - : StunAttribute(type, length) { -} + : StunAttribute(type, length) {} StunAttributeValueType StunAddressAttribute::value_type() const { return STUN_VALUE_ADDRESS; @@ -625,14 +633,12 @@ bool StunAddressAttribute::Write(ByteBufferWriter* buf) const { StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type, const rtc::SocketAddress& addr) - : StunAddressAttribute(type, addr), owner_(NULL) { -} + : StunAddressAttribute(type, addr), owner_(NULL) {} StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type, uint16_t length, StunMessage* owner) - : StunAddressAttribute(type, length), owner_(owner) { -} + : StunAddressAttribute(type, length), owner_(owner) {} StunAttributeValueType StunXorAddressAttribute::value_type() const { return STUN_VALUE_XOR_ADDRESS; @@ -716,12 +722,10 @@ bool StunXorAddressAttribute::Write(ByteBufferWriter* buf) const { } StunUInt32Attribute::StunUInt32Attribute(uint16_t type, uint32_t value) - : StunAttribute(type, SIZE), bits_(value) { -} + : StunAttribute(type, SIZE), bits_(value) {} StunUInt32Attribute::StunUInt32Attribute(uint16_t type) - : StunAttribute(type, SIZE), bits_(0) { -} + : StunAttribute(type, SIZE), bits_(0) {} StunAttributeValueType StunUInt32Attribute::value_type() const { return STUN_VALUE_UINT32; @@ -750,12 +754,10 @@ bool StunUInt32Attribute::Write(ByteBufferWriter* buf) const { } StunUInt64Attribute::StunUInt64Attribute(uint16_t type, uint64_t value) - : StunAttribute(type, SIZE), bits_(value) { -} + : StunAttribute(type, SIZE), bits_(value) {} StunUInt64Attribute::StunUInt64Attribute(uint16_t type) - : StunAttribute(type, SIZE), bits_(0) { -} + : StunAttribute(type, SIZE), bits_(0) {} StunAttributeValueType StunUInt64Attribute::value_type() const { return STUN_VALUE_UINT64; @@ -773,8 +775,7 @@ bool StunUInt64Attribute::Write(ByteBufferWriter* buf) const { } StunByteStringAttribute::StunByteStringAttribute(uint16_t type) - : StunAttribute(type, 0), bytes_(NULL) { -} + : StunAttribute(type, 0), bytes_(NULL) {} StunByteStringAttribute::StunByteStringAttribute(uint16_t type, const std::string& str) @@ -790,11 +791,10 @@ StunByteStringAttribute::StunByteStringAttribute(uint16_t type, } StunByteStringAttribute::StunByteStringAttribute(uint16_t type, uint16_t length) - : StunAttribute(type, length), bytes_(NULL) { -} + : StunAttribute(type, length), bytes_(NULL) {} StunByteStringAttribute::~StunByteStringAttribute() { - delete [] bytes_; + delete[] bytes_; } StunAttributeValueType StunByteStringAttribute::value_type() const { @@ -840,7 +840,7 @@ bool StunByteStringAttribute::Write(ByteBufferWriter* buf) const { } void StunByteStringAttribute::SetBytes(char* bytes, size_t length) { - delete [] bytes_; + delete[] bytes_; bytes_ = bytes; SetLength(static_cast(length)); } @@ -856,11 +856,9 @@ StunErrorCodeAttribute::StunErrorCodeAttribute(uint16_t type, } StunErrorCodeAttribute::StunErrorCodeAttribute(uint16_t type, uint16_t length) - : StunAttribute(type, length), class_(0), number_(0) { -} + : StunAttribute(type, length), class_(0), number_(0) {} -StunErrorCodeAttribute::~StunErrorCodeAttribute() { -} +StunErrorCodeAttribute::~StunErrorCodeAttribute() {} StunAttributeValueType StunErrorCodeAttribute::value_type() const { return STUN_VALUE_ERROR_CODE; @@ -1000,9 +998,8 @@ bool ComputeStunCredentialHash(const std::string& username, input += password; char digest[rtc::MessageDigest::kMaxSize]; - size_t size = rtc::ComputeDigest( - rtc::DIGEST_MD5, input.c_str(), input.size(), - digest, sizeof(digest)); + size_t size = rtc::ComputeDigest(rtc::DIGEST_MD5, input.c_str(), input.size(), + digest, sizeof(digest)); if (size == 0) { return false; } @@ -1019,11 +1016,9 @@ std::unique_ptr CopyStunAttribute( tmp_buffer_ptr = &tmpBuffer; } - std::unique_ptr copy( - StunAttribute::Create(attribute.value_type(), - attribute.type(), - static_cast(attribute.length()), - nullptr)); + std::unique_ptr copy(StunAttribute::Create( + attribute.value_type(), attribute.type(), + static_cast(attribute.length()), nullptr)); if (!copy) { return nullptr; diff --git a/p2p/base/stun.h b/p2p/base/stun.h index 02b7b786bc..dfb56e0c0e 100644 --- a/p2p/base/stun.h +++ b/p2p/base/stun.h @@ -25,10 +25,10 @@ namespace cricket { // These are the types of STUN messages defined in RFC 5389. enum StunMessageType { - STUN_BINDING_REQUEST = 0x0001, - STUN_BINDING_INDICATION = 0x0011, - STUN_BINDING_RESPONSE = 0x0101, - STUN_BINDING_ERROR_RESPONSE = 0x0111, + STUN_BINDING_REQUEST = 0x0001, + STUN_BINDING_INDICATION = 0x0011, + STUN_BINDING_RESPONSE = 0x0101, + STUN_BINDING_ERROR_RESPONSE = 0x0111, }; // These are all known STUN attributes, defined in RFC 5389 and elsewhere. @@ -37,19 +37,19 @@ enum StunMessageType { // RETRANSMIT_COUNT is the number of outstanding pings without a response at // the time the packet is generated. enum StunAttributeType { - STUN_ATTR_MAPPED_ADDRESS = 0x0001, // Address - STUN_ATTR_USERNAME = 0x0006, // ByteString - STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, // ByteString, 20 bytes - STUN_ATTR_ERROR_CODE = 0x0009, // ErrorCode - STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a, // UInt16List - STUN_ATTR_REALM = 0x0014, // ByteString - STUN_ATTR_NONCE = 0x0015, // ByteString - STUN_ATTR_XOR_MAPPED_ADDRESS = 0x0020, // XorAddress - STUN_ATTR_SOFTWARE = 0x8022, // ByteString - STUN_ATTR_ALTERNATE_SERVER = 0x8023, // Address - STUN_ATTR_FINGERPRINT = 0x8028, // UInt32 - STUN_ATTR_ORIGIN = 0x802F, // ByteString - STUN_ATTR_RETRANSMIT_COUNT = 0xFF00 // UInt32 + STUN_ATTR_MAPPED_ADDRESS = 0x0001, // Address + STUN_ATTR_USERNAME = 0x0006, // ByteString + STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, // ByteString, 20 bytes + STUN_ATTR_ERROR_CODE = 0x0009, // ErrorCode + STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a, // UInt16List + STUN_ATTR_REALM = 0x0014, // ByteString + STUN_ATTR_NONCE = 0x0015, // ByteString + STUN_ATTR_XOR_MAPPED_ADDRESS = 0x0020, // XorAddress + STUN_ATTR_SOFTWARE = 0x8022, // ByteString + STUN_ATTR_ALTERNATE_SERVER = 0x8023, // Address + STUN_ATTR_FINGERPRINT = 0x8028, // UInt32 + STUN_ATTR_ORIGIN = 0x802F, // ByteString + STUN_ATTR_RETRANSMIT_COUNT = 0xFF00 // UInt32 }; // These are the types of the values associated with the attributes above. @@ -57,34 +57,34 @@ enum StunAttributeType { // attributes. Note that these values are for our own use, and not defined in // RFC 5389. enum StunAttributeValueType { - STUN_VALUE_UNKNOWN = 0, - STUN_VALUE_ADDRESS = 1, - STUN_VALUE_XOR_ADDRESS = 2, - STUN_VALUE_UINT32 = 3, - STUN_VALUE_UINT64 = 4, - STUN_VALUE_BYTE_STRING = 5, - STUN_VALUE_ERROR_CODE = 6, - STUN_VALUE_UINT16_LIST = 7 + STUN_VALUE_UNKNOWN = 0, + STUN_VALUE_ADDRESS = 1, + STUN_VALUE_XOR_ADDRESS = 2, + STUN_VALUE_UINT32 = 3, + STUN_VALUE_UINT64 = 4, + STUN_VALUE_BYTE_STRING = 5, + STUN_VALUE_ERROR_CODE = 6, + STUN_VALUE_UINT16_LIST = 7 }; // These are the types of STUN addresses defined in RFC 5389. enum StunAddressFamily { // NB: UNDEF is not part of the STUN spec. - STUN_ADDRESS_UNDEF = 0, - STUN_ADDRESS_IPV4 = 1, - STUN_ADDRESS_IPV6 = 2 + STUN_ADDRESS_UNDEF = 0, + STUN_ADDRESS_IPV4 = 1, + STUN_ADDRESS_IPV6 = 2 }; // These are the types of STUN error codes defined in RFC 5389. enum StunErrorCode { - STUN_ERROR_TRY_ALTERNATE = 300, - STUN_ERROR_BAD_REQUEST = 400, - STUN_ERROR_UNAUTHORIZED = 401, - STUN_ERROR_UNKNOWN_ATTRIBUTE = 420, - STUN_ERROR_STALE_CREDENTIALS = 430, // GICE only - STUN_ERROR_STALE_NONCE = 438, - STUN_ERROR_SERVER_ERROR = 500, - STUN_ERROR_GLOBAL_FAILURE = 600 + STUN_ERROR_TRY_ALTERNATE = 300, + STUN_ERROR_BAD_REQUEST = 400, + STUN_ERROR_UNAUTHORIZED = 401, + STUN_ERROR_UNKNOWN_ATTRIBUTE = 420, + STUN_ERROR_STALE_CREDENTIALS = 430, // GICE only + STUN_ERROR_STALE_NONCE = 438, + STUN_ERROR_SERVER_ERROR = 500, + STUN_ERROR_GLOBAL_FAILURE = 600 }; // Strings for the error codes above. @@ -170,7 +170,8 @@ class StunMessage { // Validates that a raw STUN message has a correct MESSAGE-INTEGRITY value. // This can't currently be done on a StunMessage, since it is affected by // padding data (which we discard when reading a StunMessage). - static bool ValidateMessageIntegrity(const char* data, size_t size, + static bool ValidateMessageIntegrity(const char* data, + size_t size, const std::string& password); // Adds a MESSAGE-INTEGRITY attribute that is valid for the current message. bool AddMessageIntegrity(const std::string& password); @@ -216,8 +217,7 @@ class StunMessage { // Base class for all STUN/TURN attributes. class StunAttribute { public: - virtual ~StunAttribute() { - } + virtual ~StunAttribute() {} int type() const { return type_; } size_t length() const { return length_; } @@ -482,7 +482,9 @@ bool IsStunErrorResponseType(int msg_type); // Computes the STUN long-term credential hash. bool ComputeStunCredentialHash(const std::string& username, - const std::string& realm, const std::string& password, std::string* hash); + const std::string& realm, + const std::string& password, + std::string* hash); // Make a copy af |attribute| and return a new StunAttribute. // This is useful if you don't care about what kind of attribute you @@ -507,22 +509,22 @@ enum RelayMessageType { // STUN_ALLOCATE_REQUEST = 0x0003, // STUN_ALLOCATE_RESPONSE = 0x0103, // STUN_ALLOCATE_ERROR_RESPONSE = 0x0113, - STUN_SEND_REQUEST = 0x0004, - STUN_SEND_RESPONSE = 0x0104, - STUN_SEND_ERROR_RESPONSE = 0x0114, - STUN_DATA_INDICATION = 0x0115, + STUN_SEND_REQUEST = 0x0004, + STUN_SEND_RESPONSE = 0x0104, + STUN_SEND_ERROR_RESPONSE = 0x0114, + STUN_DATA_INDICATION = 0x0115, }; // "GTURN"-specific STUN attributes. // TODO(?): Rename these attributes to GTURN_ to avoid conflicts. enum RelayAttributeType { - STUN_ATTR_LIFETIME = 0x000d, // UInt32 - STUN_ATTR_MAGIC_COOKIE = 0x000f, // ByteString, 4 bytes - STUN_ATTR_BANDWIDTH = 0x0010, // UInt32 - STUN_ATTR_DESTINATION_ADDRESS = 0x0011, // Address - STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, // Address - STUN_ATTR_DATA = 0x0013, // ByteString - STUN_ATTR_OPTIONS = 0x8001, // UInt32 + STUN_ATTR_LIFETIME = 0x000d, // UInt32 + STUN_ATTR_MAGIC_COOKIE = 0x000f, // ByteString, 4 bytes + STUN_ATTR_BANDWIDTH = 0x0010, // UInt32 + STUN_ATTR_DESTINATION_ADDRESS = 0x0011, // Address + STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, // Address + STUN_ATTR_DATA = 0x0013, // ByteString + STUN_ATTR_OPTIONS = 0x8001, // UInt32 }; // A "GTURN" STUN message. @@ -534,33 +536,33 @@ class RelayMessage : public StunMessage { // Defined in TURN RFC 5766. enum TurnMessageType { - STUN_ALLOCATE_REQUEST = 0x0003, - STUN_ALLOCATE_RESPONSE = 0x0103, - STUN_ALLOCATE_ERROR_RESPONSE = 0x0113, - TURN_REFRESH_REQUEST = 0x0004, - TURN_REFRESH_RESPONSE = 0x0104, - TURN_REFRESH_ERROR_RESPONSE = 0x0114, - TURN_SEND_INDICATION = 0x0016, - TURN_DATA_INDICATION = 0x0017, - TURN_CREATE_PERMISSION_REQUEST = 0x0008, - TURN_CREATE_PERMISSION_RESPONSE = 0x0108, + STUN_ALLOCATE_REQUEST = 0x0003, + STUN_ALLOCATE_RESPONSE = 0x0103, + STUN_ALLOCATE_ERROR_RESPONSE = 0x0113, + TURN_REFRESH_REQUEST = 0x0004, + TURN_REFRESH_RESPONSE = 0x0104, + TURN_REFRESH_ERROR_RESPONSE = 0x0114, + TURN_SEND_INDICATION = 0x0016, + TURN_DATA_INDICATION = 0x0017, + TURN_CREATE_PERMISSION_REQUEST = 0x0008, + TURN_CREATE_PERMISSION_RESPONSE = 0x0108, TURN_CREATE_PERMISSION_ERROR_RESPONSE = 0x0118, - TURN_CHANNEL_BIND_REQUEST = 0x0009, - TURN_CHANNEL_BIND_RESPONSE = 0x0109, - TURN_CHANNEL_BIND_ERROR_RESPONSE = 0x0119, + TURN_CHANNEL_BIND_REQUEST = 0x0009, + TURN_CHANNEL_BIND_RESPONSE = 0x0109, + TURN_CHANNEL_BIND_ERROR_RESPONSE = 0x0119, }; enum TurnAttributeType { - STUN_ATTR_CHANNEL_NUMBER = 0x000C, // UInt32 - STUN_ATTR_TURN_LIFETIME = 0x000d, // UInt32 - STUN_ATTR_XOR_PEER_ADDRESS = 0x0012, // XorAddress + STUN_ATTR_CHANNEL_NUMBER = 0x000C, // UInt32 + STUN_ATTR_TURN_LIFETIME = 0x000d, // UInt32 + STUN_ATTR_XOR_PEER_ADDRESS = 0x0012, // XorAddress // TODO(mallinath) - Uncomment after RelayAttributes are renamed. // STUN_ATTR_DATA = 0x0013, // ByteString - STUN_ATTR_XOR_RELAYED_ADDRESS = 0x0016, // XorAddress - STUN_ATTR_EVEN_PORT = 0x0018, // ByteString, 1 byte. - STUN_ATTR_REQUESTED_TRANSPORT = 0x0019, // UInt32 - STUN_ATTR_DONT_FRAGMENT = 0x001A, // No content, Length = 0 - STUN_ATTR_RESERVATION_TOKEN = 0x0022, // ByteString, 8 bytes. + STUN_ATTR_XOR_RELAYED_ADDRESS = 0x0016, // XorAddress + STUN_ATTR_EVEN_PORT = 0x0018, // ByteString, 1 byte. + STUN_ATTR_REQUESTED_TRANSPORT = 0x0019, // UInt32 + STUN_ATTR_DONT_FRAGMENT = 0x001A, // No content, Length = 0 + STUN_ATTR_RESERVATION_TOKEN = 0x0022, // ByteString, 8 bytes. // TODO(mallinath) - Rename STUN_ATTR_TURN_LIFETIME to STUN_ATTR_LIFETIME and // STUN_ATTR_TURN_DATA to STUN_ATTR_DATA. Also rename RelayMessage attributes // by appending G to attribute name. @@ -568,10 +570,10 @@ enum TurnAttributeType { // RFC 5766-defined errors. enum TurnErrorType { - STUN_ERROR_FORBIDDEN = 403, - STUN_ERROR_ALLOCATION_MISMATCH = 437, - STUN_ERROR_WRONG_CREDENTIALS = 441, - STUN_ERROR_UNSUPPORTED_PROTOCOL = 442 + STUN_ERROR_FORBIDDEN = 403, + STUN_ERROR_ALLOCATION_MISMATCH = 437, + STUN_ERROR_WRONG_CREDENTIALS = 441, + STUN_ERROR_UNSUPPORTED_PROTOCOL = 442 }; extern const char STUN_ERROR_REASON_FORBIDDEN[]; extern const char STUN_ERROR_REASON_ALLOCATION_MISMATCH[]; @@ -597,7 +599,7 @@ enum IceAttributeType { // RFC 5245-defined errors. enum IceErrorCode { - STUN_ERROR_ROLE_CONFLICT = 487, + STUN_ERROR_ROLE_CONFLICT = 487, }; extern const char STUN_ERROR_REASON_ROLE_CONFLICT[]; diff --git a/p2p/base/stun_unittest.cc b/p2p/base/stun_unittest.cc index 5c805dc770..65b976e5a5 100644 --- a/p2p/base/stun_unittest.cc +++ b/p2p/base/stun_unittest.cc @@ -24,14 +24,16 @@ namespace cricket { class StunTest : public ::testing::Test { protected: - void CheckStunHeader(const StunMessage& msg, StunMessageType expected_type, + void CheckStunHeader(const StunMessage& msg, + StunMessageType expected_type, size_t expected_length) { ASSERT_EQ(expected_type, msg.type()); ASSERT_EQ(expected_length, msg.length()); } void CheckStunTransactionID(const StunMessage& msg, - const unsigned char* expectedID, size_t length) { + const unsigned char* expectedID, + size_t length) { ASSERT_EQ(length, msg.transaction_id().size()); ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy()); ASSERT_EQ(length == kStunTransactionIdLength, !msg.IsLegacy()); @@ -73,11 +75,13 @@ class StunTest : public ::testing::Test { } }; - // Sample STUN packets with various attributes // Gathered by wiresharking pjproject's pjnath test programs // pjproject available at www.pjsip.org +// clang-format off +// clang formatting doesn't respect inline comments. + static const unsigned char kStunMessageWithIPv6MappedAddress[] = { 0x00, 0x01, 0x00, 0x18, // message header 0x21, 0x12, 0xa4, 0x42, // transaction id @@ -267,6 +271,7 @@ static const unsigned char kRtcpPacket[] = { 0x00, 0x03, 0x73, 0x50, }; + // RFC5769 Test Vectors // Software name (request): "STUN test client" (without quotes) // Software name (response): "test vector" (without quotes) @@ -472,31 +477,31 @@ static const unsigned char kCalculatedHmac2[] = { 0x43, 0x14, 0x10, 0x28 // } }; +// clang-format on + // A transaction ID without the 'magic cookie' portion // pjnat's test programs use this transaction ID a lot. -const unsigned char kTestTransactionId1[] = { 0x029, 0x01f, 0x0cd, 0x07c, - 0x0ba, 0x058, 0x0ab, 0x0d7, - 0x0f2, 0x041, 0x001, 0x000 }; +const unsigned char kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c, + 0x0ba, 0x058, 0x0ab, 0x0d7, + 0x0f2, 0x041, 0x001, 0x000}; // They use this one sometimes too. -const unsigned char kTestTransactionId2[] = { 0x0e3, 0x0a9, 0x046, 0x0e1, - 0x07c, 0x000, 0x0c2, 0x062, - 0x054, 0x008, 0x001, 0x000 }; +const unsigned char kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1, + 0x07c, 0x000, 0x0c2, 0x062, + 0x054, 0x008, 0x001, 0x000}; -const in6_addr kIPv6TestAddress1 = { { { 0x24, 0x01, 0xfa, 0x00, - 0x00, 0x04, 0x10, 0x00, - 0xbe, 0x30, 0x5b, 0xff, - 0xfe, 0xe5, 0x00, 0xc3 } } }; -const in6_addr kIPv6TestAddress2 = { { { 0x24, 0x01, 0xfa, 0x00, - 0x00, 0x04, 0x10, 0x12, - 0x06, 0x0c, 0xce, 0xff, - 0xfe, 0x1f, 0x61, 0xa4 } } }; +const in6_addr kIPv6TestAddress1 = { + {{0x24, 0x01, 0xfa, 0x00, 0x00, 0x04, 0x10, 0x00, 0xbe, 0x30, 0x5b, 0xff, + 0xfe, 0xe5, 0x00, 0xc3}}}; +const in6_addr kIPv6TestAddress2 = { + {{0x24, 0x01, 0xfa, 0x00, 0x00, 0x04, 0x10, 0x12, 0x06, 0x0c, 0xce, 0xff, + 0xfe, 0x1f, 0x61, 0xa4}}}; #ifdef WEBRTC_POSIX -const in_addr kIPv4TestAddress1 = { 0xe64417ac }; +const in_addr kIPv4TestAddress1 = {0xe64417ac}; #elif defined WEBRTC_WIN // Windows in_addr has a union with a uchar[] array first. -const in_addr kIPv4TestAddress1 = { { { 0x0ac, 0x017, 0x044, 0x0e6 } } }; +const in_addr kIPv4TestAddress1 = {{{0x0ac, 0x017, 0x044, 0x0e6}}}; #endif const char kTestUserName1[] = "abcdefgh"; const char kTestUserName2[] = "abc"; @@ -516,9 +521,9 @@ const int kTestMessagePort4 = 40444; // Test that the GetStun*Type and IsStun*Type methods work as expected. TEST_F(StunTest, MessageTypes) { EXPECT_EQ(STUN_BINDING_RESPONSE, - GetStunSuccessResponseType(STUN_BINDING_REQUEST)); + GetStunSuccessResponseType(STUN_BINDING_REQUEST)); EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, - GetStunErrorResponseType(STUN_BINDING_REQUEST)); + GetStunErrorResponseType(STUN_BINDING_REQUEST)); EXPECT_EQ(-1, GetStunSuccessResponseType(STUN_BINDING_INDICATION)); EXPECT_EQ(-1, GetStunSuccessResponseType(STUN_BINDING_RESPONSE)); EXPECT_EQ(-1, GetStunSuccessResponseType(STUN_BINDING_ERROR_RESPONSE)); @@ -526,10 +531,8 @@ TEST_F(StunTest, MessageTypes) { EXPECT_EQ(-1, GetStunErrorResponseType(STUN_BINDING_RESPONSE)); EXPECT_EQ(-1, GetStunErrorResponseType(STUN_BINDING_ERROR_RESPONSE)); - int types[] = { - STUN_BINDING_REQUEST, STUN_BINDING_INDICATION, - STUN_BINDING_RESPONSE, STUN_BINDING_ERROR_RESPONSE - }; + int types[] = {STUN_BINDING_REQUEST, STUN_BINDING_INDICATION, + STUN_BINDING_RESPONSE, STUN_BINDING_ERROR_RESPONSE}; for (size_t i = 0; i < arraysize(types); ++i) { EXPECT_EQ(i == 0U, IsStunRequestType(types[i])); EXPECT_EQ(i == 1U, IsStunIndicationType(types[i])); @@ -547,8 +550,8 @@ TEST_F(StunTest, ReadMessageWithIPv4AddressAttribute) { const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_MAPPED_ADDRESS); rtc::IPAddress test_address(kIPv4TestAddress1); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, - kTestMessagePort4, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, kTestMessagePort4, + test_address); } TEST_F(StunTest, ReadMessageWithIPv4XorAddressAttribute) { @@ -561,8 +564,8 @@ TEST_F(StunTest, ReadMessageWithIPv4XorAddressAttribute) { const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); rtc::IPAddress test_address(kIPv4TestAddress1); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, - kTestMessagePort3, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, kTestMessagePort3, + test_address); } TEST_F(StunTest, ReadMessageWithIPv6AddressAttribute) { @@ -574,8 +577,8 @@ TEST_F(StunTest, ReadMessageWithIPv6AddressAttribute) { rtc::IPAddress test_address(kIPv6TestAddress1); const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_MAPPED_ADDRESS); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, - kTestMessagePort2, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, kTestMessagePort2, + test_address); } TEST_F(StunTest, ReadMessageWithInvalidAddressAttribute) { @@ -587,8 +590,8 @@ TEST_F(StunTest, ReadMessageWithInvalidAddressAttribute) { rtc::IPAddress test_address(kIPv6TestAddress1); const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_MAPPED_ADDRESS); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, - kTestMessagePort2, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, kTestMessagePort2, + test_address); } TEST_F(StunTest, ReadMessageWithIPv6XorAddressAttribute) { @@ -602,8 +605,8 @@ TEST_F(StunTest, ReadMessageWithIPv6XorAddressAttribute) { const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, - kTestMessagePort1, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, kTestMessagePort1, + test_address); } // Read the RFC5389 fields from the RFC5769 sample STUN request. @@ -628,8 +631,7 @@ TEST_F(StunTest, ReadRfc5769RequestMessage) { ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); // Fingerprint checked in a later test, but double-check the value here. - const StunUInt32Attribute* fingerprint = - msg.GetUInt32(STUN_ATTR_FINGERPRINT); + const StunUInt32Attribute* fingerprint = msg.GetUInt32(STUN_ATTR_FINGERPRINT); ASSERT_TRUE(fingerprint != NULL); EXPECT_EQ(0xe57a3bcf, fingerprint->value()); } @@ -693,13 +695,11 @@ TEST_F(StunTest, ReadRfc5769RequestMessageLongTermAuth) { ASSERT_TRUE(username != NULL); EXPECT_EQ(kRfc5769SampleMsgWithAuthUsername, username->GetString()); - const StunByteStringAttribute* nonce = - msg.GetByteString(STUN_ATTR_NONCE); + const StunByteStringAttribute* nonce = msg.GetByteString(STUN_ATTR_NONCE); ASSERT_TRUE(nonce != NULL); EXPECT_EQ(kRfc5769SampleMsgWithAuthNonce, nonce->GetString()); - const StunByteStringAttribute* realm = - msg.GetByteString(STUN_ATTR_REALM); + const StunByteStringAttribute* realm = msg.GetByteString(STUN_ATTR_REALM); ASSERT_TRUE(realm != NULL); EXPECT_EQ(kRfc5769SampleMsgWithAuthRealm, realm->GetString()); @@ -714,7 +714,7 @@ TEST_F(StunTest, ReadRfc5769RequestMessageLongTermAuth) { TEST_F(StunTest, ReadLegacyMessage) { unsigned char rfc3489_packet[sizeof(kStunMessageWithIPv4MappedAddress)]; memcpy(rfc3489_packet, kStunMessageWithIPv4MappedAddress, - sizeof(kStunMessageWithIPv4MappedAddress)); + sizeof(kStunMessageWithIPv4MappedAddress)); // Overwrite the magic cookie here. memcpy(&rfc3489_packet[4], "ABCD", 4); @@ -725,8 +725,8 @@ TEST_F(StunTest, ReadLegacyMessage) { const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_MAPPED_ADDRESS); rtc::IPAddress test_address(kIPv4TestAddress1); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, - kTestMessagePort4, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, kTestMessagePort4, + test_address); } TEST_F(StunTest, SetIPv6XorAddressAttributeOwner) { @@ -741,8 +741,8 @@ TEST_F(StunTest, SetIPv6XorAddressAttributeOwner) { const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, - kTestMessagePort1, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV6, kTestMessagePort1, + test_address); // Owner with a different transaction ID. msg2.SetTransactionID("ABCDABCDABCD"); @@ -789,8 +789,8 @@ TEST_F(StunTest, SetIPv4XorAddressAttributeOwner) { const StunAddressAttribute* addr = msg.GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, - kTestMessagePort3, test_address); + CheckStunAddressAttribute(addr, STUN_ADDRESS_IPV4, kTestMessagePort3, + test_address); // Owner with a different transaction ID. msg2.SetTransactionID("ABCDABCDABCD"); @@ -994,8 +994,8 @@ TEST_F(StunTest, ReadByteStringAttribute) { TEST_F(StunTest, ReadPaddedByteStringAttribute) { StunMessage msg; - size_t size = ReadStunMessage(&msg, - kStunMessageWithPaddedByteStringAttribute); + size_t size = + ReadStunMessage(&msg, kStunMessageWithPaddedByteStringAttribute); ASSERT_NE(0U, size); CheckStunHeader(msg, STUN_BINDING_REQUEST, size); CheckStunTransactionID(msg, kTestTransactionId2, kStunTransactionIdLength); @@ -1056,8 +1056,7 @@ TEST_F(StunTest, ReadMessageWithOriginAttribute) { StunMessage msg; size_t size = ReadStunMessage(&msg, kStunMessageWithOriginAttribute); CheckStunHeader(msg, STUN_BINDING_REQUEST, size); - const StunByteStringAttribute* origin = - msg.GetByteString(STUN_ATTR_ORIGIN); + const StunByteStringAttribute* origin = msg.GetByteString(STUN_ATTR_ORIGIN); ASSERT_TRUE(origin != NULL); EXPECT_EQ(kTestOrigin, origin->GetString()); } @@ -1154,56 +1153,47 @@ TEST_F(StunTest, ValidateMessageIntegrity) { // Try the messages from RFC 5769. EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleRequest), - sizeof(kRfc5769SampleRequest), - kRfc5769SampleMsgPassword)); + sizeof(kRfc5769SampleRequest), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleRequest), - sizeof(kRfc5769SampleRequest), - "InvalidPassword")); + sizeof(kRfc5769SampleRequest), "InvalidPassword")); EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleResponse), - sizeof(kRfc5769SampleResponse), - kRfc5769SampleMsgPassword)); + sizeof(kRfc5769SampleResponse), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleResponse), - sizeof(kRfc5769SampleResponse), - "InvalidPassword")); + sizeof(kRfc5769SampleResponse), "InvalidPassword")); EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleResponseIPv6), - sizeof(kRfc5769SampleResponseIPv6), - kRfc5769SampleMsgPassword)); + sizeof(kRfc5769SampleResponseIPv6), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleResponseIPv6), - sizeof(kRfc5769SampleResponseIPv6), - "InvalidPassword")); + sizeof(kRfc5769SampleResponseIPv6), "InvalidPassword")); // We first need to compute the key for the long-term authentication HMAC. std::string key; ComputeStunCredentialHash(kRfc5769SampleMsgWithAuthUsername, - kRfc5769SampleMsgWithAuthRealm, kRfc5769SampleMsgWithAuthPassword, &key); + kRfc5769SampleMsgWithAuthRealm, + kRfc5769SampleMsgWithAuthPassword, &key); EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleRequestLongTermAuth), sizeof(kRfc5769SampleRequestLongTermAuth), key)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kRfc5769SampleRequestLongTermAuth), - sizeof(kRfc5769SampleRequestLongTermAuth), - "InvalidPassword")); + sizeof(kRfc5769SampleRequestLongTermAuth), "InvalidPassword")); // Try some edge cases. EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kStunMessageWithZeroLength), - sizeof(kStunMessageWithZeroLength), - kRfc5769SampleMsgPassword)); + sizeof(kStunMessageWithZeroLength), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kStunMessageWithExcessLength), - sizeof(kStunMessageWithExcessLength), - kRfc5769SampleMsgPassword)); + sizeof(kStunMessageWithExcessLength), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kStunMessageWithSmallLength), - sizeof(kStunMessageWithSmallLength), - kRfc5769SampleMsgPassword)); + sizeof(kStunMessageWithSmallLength), kRfc5769SampleMsgPassword)); // Again, but with the lengths matching what is claimed in the headers. EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( @@ -1222,8 +1212,7 @@ TEST_F(StunTest, ValidateMessageIntegrity) { // Check that a too-short HMAC doesn't cause buffer overflow. EXPECT_FALSE(StunMessage::ValidateMessageIntegrity( reinterpret_cast(kStunMessageWithBadHmacAtEnd), - sizeof(kStunMessageWithBadHmacAtEnd), - kRfc5769SampleMsgPassword)); + sizeof(kStunMessageWithBadHmacAtEnd), kRfc5769SampleMsgPassword)); // Test that munging a single bit anywhere in the message causes the // message-integrity check to fail, unless it is after the M-I attribute. @@ -1233,8 +1222,9 @@ TEST_F(StunTest, ValidateMessageIntegrity) { buf[i] ^= 0x01; if (i > 0) buf[i - 1] ^= 0x01; - EXPECT_EQ(i >= sizeof(buf) - 8, StunMessage::ValidateMessageIntegrity( - buf, sizeof(buf), kRfc5769SampleMsgPassword)); + EXPECT_EQ(i >= sizeof(buf) - 8, + StunMessage::ValidateMessageIntegrity(buf, sizeof(buf), + kRfc5769SampleMsgPassword)); } } @@ -1251,14 +1241,14 @@ TEST_F(StunTest, AddMessageIntegrity) { const StunByteStringAttribute* mi_attr = msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); EXPECT_EQ(20U, mi_attr->length()); - EXPECT_EQ(0, memcmp( - mi_attr->bytes(), kCalculatedHmac1, sizeof(kCalculatedHmac1))); + EXPECT_EQ( + 0, memcmp(mi_attr->bytes(), kCalculatedHmac1, sizeof(kCalculatedHmac1))); rtc::ByteBufferWriter buf1; EXPECT_TRUE(msg.Write(&buf1)); EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( - reinterpret_cast(buf1.Data()), buf1.Length(), - kRfc5769SampleMsgPassword)); + reinterpret_cast(buf1.Data()), buf1.Length(), + kRfc5769SampleMsgPassword)); IceMessage msg2; rtc::ByteBufferReader buf2( @@ -1275,8 +1265,8 @@ TEST_F(StunTest, AddMessageIntegrity) { rtc::ByteBufferWriter buf3; EXPECT_TRUE(msg2.Write(&buf3)); EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( - reinterpret_cast(buf3.Data()), buf3.Length(), - kRfc5769SampleMsgPassword)); + reinterpret_cast(buf3.Data()), buf3.Length(), + kRfc5769SampleMsgPassword)); } // Check our STUN message validation code against the RFC5769 test messages. @@ -1331,6 +1321,8 @@ TEST_F(StunTest, AddFingerprint) { } // Sample "GTURN" relay message. +// clang-format off +// clang formatting doesn't respect inline comments. static const unsigned char kRelayMessage[] = { 0x00, 0x01, 0x00, 88, // message header 0x21, 0x12, 0xA4, 0x42, // magic cookie @@ -1360,6 +1352,7 @@ static const unsigned char kRelayMessage[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 0 // DATA must be padded per rfc5766. }; +// clang-format on // Test that we can read the GTURN-specific fields. TEST_F(StunTest, ReadRelayMessage) { @@ -1412,10 +1405,8 @@ TEST_F(StunTest, ReadRelayMessage) { bytes = msg.GetByteString(STUN_ATTR_MAGIC_COOKIE); ASSERT_TRUE(bytes != NULL); EXPECT_EQ(4U, bytes->length()); - EXPECT_EQ(0, - memcmp(bytes->bytes(), - TURN_MAGIC_COOKIE_VALUE, - sizeof(TURN_MAGIC_COOKIE_VALUE))); + EXPECT_EQ(0, memcmp(bytes->bytes(), TURN_MAGIC_COOKIE_VALUE, + sizeof(TURN_MAGIC_COOKIE_VALUE))); bytes2 = StunAttribute::CreateByteString(STUN_ATTR_MAGIC_COOKIE); bytes2->CopyBytes(reinterpret_cast(TURN_MAGIC_COOKIE_VALUE), @@ -1541,10 +1532,10 @@ TEST_F(StunTest, RemoveAttribute) { // Test CopyStunAttribute TEST_F(StunTest, CopyAttribute) { rtc::ByteBufferWriter buf; - rtc::ByteBufferWriter* buffer_ptrs[] = { &buf, nullptr }; + rtc::ByteBufferWriter* buffer_ptrs[] = {&buf, nullptr}; // Test both with and without supplied ByteBufferWriter. for (auto buffer_ptr : buffer_ptrs) { - { // Test StunByteStringAttribute. + { // Test StunByteStringAttribute. auto attr = StunAttribute::CreateByteString(STUN_ATTR_USERNAME); attr->CopyBytes("kes", sizeof("kes")); @@ -1554,13 +1545,13 @@ TEST_F(StunTest, CopyAttribute) { static_cast(copy.get())->bytes()); } - { // Test StunAddressAttribute. + { // Test StunAddressAttribute. rtc::IPAddress test_ip(kIPv6TestAddress2); auto addr = StunAttribute::CreateAddress(STUN_ATTR_MAPPED_ADDRESS); rtc::SocketAddress test_addr(test_ip, kTestMessagePort2); addr->SetAddress(test_addr); - CheckStunAddressAttribute(addr.get(), - STUN_ADDRESS_IPV6, kTestMessagePort2, test_ip); + CheckStunAddressAttribute(addr.get(), STUN_ADDRESS_IPV6, + kTestMessagePort2, test_ip); auto copy = CopyStunAttribute(*addr.get(), buffer_ptr); ASSERT_EQ(copy->value_type(), STUN_VALUE_ADDRESS); diff --git a/p2p/base/stunport.cc b/p2p/base/stunport.cc index 1705d1d68f..9574314c76 100644 --- a/p2p/base/stunport.cc +++ b/p2p/base/stunport.cc @@ -25,7 +25,7 @@ namespace cricket { // TODO(?): Move these to a common place (used in relayport too) -const int RETRY_TIMEOUT = 50 * 1000; // 50 seconds +const int RETRY_TIMEOUT = 50 * 1000; // 50 seconds // Handles a binding request sent to the STUN server. class StunBindingRequest : public StunRequest { @@ -68,9 +68,9 @@ class StunBindingRequest : public StunRequest { RTC_LOG(LS_ERROR) << "Missing binding response error code."; } else { RTC_LOG(LS_ERROR) << "Binding error response:" - " class=" << attr->eclass() - << " number=" << attr->number() << " reason=" - << attr->reason(); + " class=" + << attr->eclass() << " number=" << attr->number() + << " reason=" << attr->reason(); } port_->OnStunBindingOrResolveRequestFailed(server_addr_); @@ -104,13 +104,12 @@ class StunBindingRequest : public StunRequest { int64_t start_time_; }; -UDPPort::AddressResolver::AddressResolver( - rtc::PacketSocketFactory* factory) +UDPPort::AddressResolver::AddressResolver(rtc::PacketSocketFactory* factory) : socket_factory_(factory) {} UDPPort::AddressResolver::~AddressResolver() { - for (ResolverMap::iterator it = resolvers_.begin(); - it != resolvers_.end(); ++it) { + for (ResolverMap::iterator it = resolvers_.begin(); it != resolvers_.end(); + ++it) { // TODO(guoweis): Change to asynchronous DNS resolution to prevent the hang // when passing true to the Destroy() which is a safer way to avoid the code // unloaded before the thread exits. Please see webrtc bug 5139. @@ -118,16 +117,14 @@ UDPPort::AddressResolver::~AddressResolver() { } } -void UDPPort::AddressResolver::Resolve( - const rtc::SocketAddress& address) { +void UDPPort::AddressResolver::Resolve(const rtc::SocketAddress& address) { if (resolvers_.find(address) != resolvers_.end()) return; rtc::AsyncResolverInterface* resolver = socket_factory_->CreateAsyncResolver(); - resolvers_.insert( - std::pair( - address, resolver)); + resolvers_.insert(std::pair( + address, resolver)); resolver->SignalDone.connect(this, &UDPPort::AddressResolver::OnResolveResult); @@ -148,8 +145,8 @@ bool UDPPort::AddressResolver::GetResolvedAddress( void UDPPort::AddressResolver::OnResolveResult( rtc::AsyncResolverInterface* resolver) { - for (ResolverMap::iterator it = resolvers_.begin(); - it != resolvers_.end(); ++it) { + for (ResolverMap::iterator it = resolvers_.begin(); it != resolvers_.end(); + ++it) { if (it->second == resolver) { SignalDone(it->first, resolver->GetError()); return; @@ -208,8 +205,7 @@ bool UDPPort::Init() { socket_ = socket_factory()->CreateUdpSocket( rtc::SocketAddress(Network()->GetBestIP(), 0), min_port(), max_port()); if (!socket_) { - RTC_LOG(LS_WARNING) << ToString() - << ": UDP socket creation failed"; + RTC_LOG(LS_WARNING) << ToString() << ": UDP socket creation failed"; return false; } socket_->SignalReadPacket.connect(this, &UDPPort::OnReadPacket); @@ -264,7 +260,8 @@ Connection* UDPPort::CreateConnection(const Candidate& address, return conn; } -int UDPPort::SendTo(const void* data, size_t size, +int UDPPort::SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, const rtc::PacketOptions& options, bool payload) { @@ -273,8 +270,8 @@ int UDPPort::SendTo(const void* data, size_t size, int sent = socket_->SendTo(data, size, addr, modified_options); if (sent < 0) { error_ = socket_->GetError(); - RTC_LOG(LS_ERROR) << ToString() << ": UDP send of " - << size << " bytes failed with error " << error_; + RTC_LOG(LS_ERROR) << ToString() << ": UDP send of " << size + << " bytes failed with error " << error_; } return sent; } @@ -389,14 +386,12 @@ void UDPPort::ResolveStunAddress(const rtc::SocketAddress& stun_addr) { resolver_->SignalDone.connect(this, &UDPPort::OnResolveResult); } - RTC_LOG(LS_INFO) << ToString() - << ": Starting STUN host lookup for " + RTC_LOG(LS_INFO) << ToString() << ": Starting STUN host lookup for " << stun_addr.ToSensitiveString(); resolver_->Resolve(stun_addr); } -void UDPPort::OnResolveResult(const rtc::SocketAddress& input, - int error) { +void UDPPort::OnResolveResult(const rtc::SocketAddress& input, int error) { RTC_DCHECK(resolver_.get() != NULL); rtc::SocketAddress resolved; @@ -475,8 +470,8 @@ void UDPPort::OnStunBindingRequestSucceeded( rtc::SocketAddress related_address = socket_->GetLocalAddress(); // If we can't stamp the related address correctly, empty it to avoid leak. if (!MaybeSetDefaultLocalAddress(&related_address)) { - related_address = rtc::EmptySocketAddressWithFamily( - related_address.family()); + related_address = + rtc::EmptySocketAddressWithFamily(related_address.family()); } std::ostringstream url; @@ -492,7 +487,7 @@ void UDPPort::OnStunBindingRequestSucceeded( void UDPPort::OnStunBindingOrResolveRequestFailed( const rtc::SocketAddress& stun_server_addr) { if (bind_request_failed_servers_.find(stun_server_addr) != - bind_request_failed_servers_.end()) { + bind_request_failed_servers_.end()) { return; } bind_request_failed_servers_.insert(stun_server_addr); @@ -504,7 +499,8 @@ void UDPPort::MaybeSetPortCompleteOrError() { return; // Do not set port ready if we are still waiting for bind responses. - const size_t servers_done_bind_request = bind_request_failed_servers_.size() + + const size_t servers_done_bind_request = + bind_request_failed_servers_.size() + bind_request_succeeded_servers_.size(); if (server_addresses_.size() != servers_done_bind_request) { return; @@ -515,8 +511,7 @@ void UDPPort::MaybeSetPortCompleteOrError() { // The port is "completed" if there is no stun server provided, or the bind // request succeeded for any stun server, or the socket is shared. - if (server_addresses_.empty() || - bind_request_succeeded_servers_.size() > 0 || + if (server_addresses_.empty() || bind_request_succeeded_servers_.size() > 0 || SharedSocket()) { SignalPortComplete(this); } else { diff --git a/p2p/base/stunport_unittest.cc b/p2p/base/stunport_unittest.cc index c7ced3a33e..2c18bd8d8f 100644 --- a/p2p/base/stunport_unittest.cc +++ b/p2p/base/stunport_unittest.cc @@ -104,21 +104,21 @@ class StunPortTestBase : public testing::Test, public sigslot::has_slots<> { stun_port_->SignalPortError.connect(this, &StunPortTestBase::OnPortError); } - void PrepareAddress() { - stun_port_->PrepareAddress(); - } + void PrepareAddress() { stun_port_->PrepareAddress(); } - void OnReadPacket(rtc::AsyncPacketSocket* socket, const char* data, - size_t size, const rtc::SocketAddress& remote_addr, + void OnReadPacket(rtc::AsyncPacketSocket* socket, + const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time) { - stun_port_->HandleIncomingPacket( - socket, data, size, remote_addr, rtc::PacketTime()); + stun_port_->HandleIncomingPacket(socket, data, size, remote_addr, + rtc::PacketTime()); } void SendData(const char* data, size_t len) { - stun_port_->HandleIncomingPacket( - socket_.get(), data, len, rtc::SocketAddress("22.22.22.22", 0), - rtc::PacketTime()); + stun_port_->HandleIncomingPacket(socket_.get(), data, len, + rtc::SocketAddress("22.22.22.22", 0), + rtc::PacketTime()); } protected: @@ -136,20 +136,14 @@ class StunPortTestBase : public testing::Test, public sigslot::has_slots<> { done_ = true; error_ = true; } - void SetKeepaliveDelay(int delay) { - stun_keepalive_delay_ = delay; - } + void SetKeepaliveDelay(int delay) { stun_keepalive_delay_ = delay; } void SetKeepaliveLifetime(int lifetime) { stun_keepalive_lifetime_ = lifetime; } - cricket::TestStunServer* stun_server_1() { - return stun_server_1_.get(); - } - cricket::TestStunServer* stun_server_2() { - return stun_server_2_.get(); - } + cricket::TestStunServer* stun_server_1() { return stun_server_1_.get(); } + cricket::TestStunServer* stun_server_2() { return stun_server_2_.get(); } private: std::unique_ptr ss_; diff --git a/p2p/base/stunrequest.cc b/p2p/base/stunrequest.cc index 851bd70b89..a639ee3862 100644 --- a/p2p/base/stunrequest.cc +++ b/p2p/base/stunrequest.cc @@ -41,13 +41,11 @@ const int STUN_MAX_RETRANSMISSIONS = 8; // Total sends: 9 // work well. const int STUN_MAX_RTO = 8000; // milliseconds, or 5 doublings -StunRequestManager::StunRequestManager(rtc::Thread* thread) - : thread_(thread) { -} +StunRequestManager::StunRequestManager(rtc::Thread* thread) : thread_(thread) {} StunRequestManager::~StunRequestManager() { while (requests_.begin() != requests_.end()) { - StunRequest *request = requests_.begin()->second; + StunRequest* request = requests_.begin()->second; requests_.erase(requests_.begin()); delete request; } @@ -167,17 +165,17 @@ bool StunRequestManager::CheckResponse(const char* data, size_t size) { } StunRequest::StunRequest() - : count_(0), timeout_(false), manager_(0), - msg_(new StunMessage()), tstamp_(0) { - msg_->SetTransactionID( - rtc::CreateRandomString(kStunTransactionIdLength)); + : count_(0), + timeout_(false), + manager_(0), + msg_(new StunMessage()), + tstamp_(0) { + msg_->SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); } StunRequest::StunRequest(StunMessage* request) - : count_(0), timeout_(false), manager_(0), - msg_(request), tstamp_(0) { - msg_->SetTransactionID( - rtc::CreateRandomString(kStunTransactionIdLength)); + : count_(0), timeout_(false), manager_(0), msg_(request), tstamp_(0) { + msg_->SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); } StunRequest::~StunRequest() { @@ -217,7 +215,6 @@ int StunRequest::Elapsed() const { return static_cast(rtc::TimeMillis() - tstamp_); } - void StunRequest::set_manager(StunRequestManager* manager) { RTC_DCHECK(!manager_); manager_ = manager; diff --git a/p2p/base/stunrequest_unittest.cc b/p2p/base/stunrequest_unittest.cc index f777b85f85..07b40d6850 100644 --- a/p2p/base/stunrequest_unittest.cc +++ b/p2p/base/stunrequest_unittest.cc @@ -20,13 +20,15 @@ namespace cricket { -class StunRequestTest : public testing::Test, - public sigslot::has_slots<> { +class StunRequestTest : public testing::Test, public sigslot::has_slots<> { public: StunRequestTest() : manager_(rtc::Thread::Current()), - request_count_(0), response_(NULL), - success_(false), failure_(false), timeout_(false) { + request_count_(0), + response_(NULL), + success_(false), + failure_(false), + timeout_(false) { manager_.SignalSendPacket.connect(this, &StunRequestTest::OnSendPacket); } @@ -42,9 +44,7 @@ class StunRequestTest : public testing::Test, response_ = res; failure_ = true; } - void OnTimeout() { - timeout_ = true; - } + void OnTimeout() { timeout_ = true; } protected: static StunMessage* CreateStunMessage(StunMessageType type, @@ -76,16 +76,13 @@ class StunRequestThunker : public StunRequest { StunRequestThunker(StunMessage* msg, StunRequestTest* test) : StunRequest(msg), test_(test) {} explicit StunRequestThunker(StunRequestTest* test) : test_(test) {} + private: - virtual void OnResponse(StunMessage* res) { - test_->OnResponse(res); - } + virtual void OnResponse(StunMessage* res) { test_->OnResponse(res); } virtual void OnErrorResponse(StunMessage* res) { test_->OnErrorResponse(res); } - virtual void OnTimeout() { - test_->OnTimeout(); - } + virtual void OnTimeout() { test_->OnTimeout(); } virtual void Prepare(StunMessage* request) { request->SetType(STUN_BINDING_REQUEST); diff --git a/p2p/base/stunserver.cc b/p2p/base/stunserver.cc index a9f0e99cd1..00eacf17bc 100644 --- a/p2p/base/stunserver.cc +++ b/p2p/base/stunserver.cc @@ -25,10 +25,11 @@ StunServer::~StunServer() { socket_->SignalReadPacket.disconnect(this); } -void StunServer::OnPacket( - rtc::AsyncPacketSocket* socket, const char* buf, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time) { +void StunServer::OnPacket(rtc::AsyncPacketSocket* socket, + const char* buf, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time) { // Parse the STUN message; eat any messages that fail to parse. rtc::ByteBufferReader bbuf(buf, size); StunMessage msg; @@ -50,16 +51,17 @@ void StunServer::OnPacket( } } -void StunServer::OnBindingRequest( - StunMessage* msg, const rtc::SocketAddress& remote_addr) { +void StunServer::OnBindingRequest(StunMessage* msg, + const rtc::SocketAddress& remote_addr) { StunMessage response; GetStunBindReqponse(msg, remote_addr, &response); SendResponse(response, remote_addr); } -void StunServer::SendErrorResponse( - const StunMessage& msg, const rtc::SocketAddress& addr, - int error_code, const char* error_desc) { +void StunServer::SendErrorResponse(const StunMessage& msg, + const rtc::SocketAddress& addr, + int error_code, + const char* error_desc) { StunMessage err_msg; err_msg.SetType(GetStunErrorResponseType(msg.type())); err_msg.SetTransactionID(msg.transaction_id()); @@ -72,8 +74,8 @@ void StunServer::SendErrorResponse( SendResponse(err_msg, addr); } -void StunServer::SendResponse( - const StunMessage& msg, const rtc::SocketAddress& addr) { +void StunServer::SendResponse(const StunMessage& msg, + const rtc::SocketAddress& addr) { rtc::ByteBufferWriter buf; msg.Write(&buf); rtc::PacketOptions options; diff --git a/p2p/base/stunserver.h b/p2p/base/stunserver.h index 7489ce9416..9016d06c20 100644 --- a/p2p/base/stunserver.h +++ b/p2p/base/stunserver.h @@ -29,29 +29,27 @@ class StunServer : public sigslot::has_slots<> { protected: // Slot for AsyncSocket.PacketRead: - void OnPacket( - rtc::AsyncPacketSocket* socket, const char* buf, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time); + void OnPacket(rtc::AsyncPacketSocket* socket, + const char* buf, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time); // Handlers for the different types of STUN/TURN requests: virtual void OnBindingRequest(StunMessage* msg, - const rtc::SocketAddress& addr); - void OnAllocateRequest(StunMessage* msg, - const rtc::SocketAddress& addr); - void OnSharedSecretRequest(StunMessage* msg, - const rtc::SocketAddress& addr); - void OnSendRequest(StunMessage* msg, - const rtc::SocketAddress& addr); + const rtc::SocketAddress& addr); + void OnAllocateRequest(StunMessage* msg, const rtc::SocketAddress& addr); + void OnSharedSecretRequest(StunMessage* msg, const rtc::SocketAddress& addr); + void OnSendRequest(StunMessage* msg, const rtc::SocketAddress& addr); // Sends an error response to the given message back to the user. - void SendErrorResponse( - const StunMessage& msg, const rtc::SocketAddress& addr, - int error_code, const char* error_desc); + void SendErrorResponse(const StunMessage& msg, + const rtc::SocketAddress& addr, + int error_code, + const char* error_desc); // Sends the given message to the appropriate destination. - void SendResponse(const StunMessage& msg, - const rtc::SocketAddress& addr); + void SendResponse(const StunMessage& msg, const rtc::SocketAddress& addr); // A helper method to compose a STUN binding response. void GetStunBindReqponse(StunMessage* request, diff --git a/p2p/base/stunserver_unittest.cc b/p2p/base/stunserver_unittest.cc index 6b44360043..f9c7ad7887 100644 --- a/p2p/base/stunserver_unittest.cc +++ b/p2p/base/stunserver_unittest.cc @@ -30,8 +30,8 @@ class StunServerTest : public testing::Test { public: StunServerTest() : ss_(new rtc::VirtualSocketServer()), network_(ss_.get()) {} virtual void SetUp() { - server_.reset(new StunServer( - rtc::AsyncUDPSocket::Create(ss_.get(), server_addr))); + server_.reset( + new StunServer(rtc::AsyncUDPSocket::Create(ss_.get(), server_addr))); client_.reset(new rtc::TestClient( WrapUnique(rtc::AsyncUDPSocket::Create(ss_.get(), client_addr)))); @@ -45,9 +45,7 @@ class StunServerTest : public testing::Test { void Send(const char* buf, int len) { client_->SendTo(buf, len, server_addr); } - bool ReceiveFails() { - return(client_->CheckNoPacket()); - } + bool ReceiveFails() { return (client_->CheckNoPacket()); } StunMessage* Receive() { StunMessage* msg = NULL; std::unique_ptr packet = @@ -100,9 +98,10 @@ TEST_F(StunServerTest, TestGood) { #endif // if !defined(THREAD_SANITIZER) TEST_F(StunServerTest, TestBad) { - const char* bad = "this is a completely nonsensical message whose only " - "purpose is to make the parser go 'ack'. it doesn't " - "look anything like a normal stun message"; + const char* bad = + "this is a completely nonsensical message whose only " + "purpose is to make the parser go 'ack'. it doesn't " + "look anything like a normal stun message"; Send(bad, static_cast(strlen(bad))); ASSERT_TRUE(ReceiveFails()); diff --git a/p2p/base/tcpport.cc b/p2p/base/tcpport.cc index 7017952806..d070f6ecee 100644 --- a/p2p/base/tcpport.cc +++ b/p2p/base/tcpport.cc @@ -140,8 +140,7 @@ Connection* TCPPort::CreateConnection(const Candidate& address, } TCPConnection* conn = NULL; - if (rtc::AsyncPacketSocket* socket = - GetIncoming(address.address(), true)) { + if (rtc::AsyncPacketSocket* socket = GetIncoming(address.address(), true)) { // Incoming connection; we already created a socket and connected signals, // so we need to hand off the "read packet" responsibility to // TCPConnection. @@ -191,11 +190,12 @@ void TCPPort::PrepareAddress() { } } -int TCPPort::SendTo(const void* data, size_t size, +int TCPPort::SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, const rtc::PacketOptions& options, bool payload) { - rtc::AsyncPacketSocket * socket = NULL; + rtc::AsyncPacketSocket* socket = NULL; TCPConnection* conn = static_cast(GetConnection(addr)); // For Connection, this is the code path used by Ping() to establish @@ -224,8 +224,8 @@ int TCPPort::SendTo(const void* data, size_t size, // Error from this code path for a Connection (instead of from a bare // socket) will not trigger reconnecting. In theory, this shouldn't matter // as OnClose should always be called and set connected to false. - RTC_LOG(LS_ERROR) << ToString() << ": TCP send of " - << size << " bytes failed with error " << error_; + RTC_LOG(LS_ERROR) << ToString() << ": TCP send of " << size + << " bytes failed with error " << error_; } return sent; } @@ -269,8 +269,7 @@ void TCPPort::OnNewConnection(rtc::AsyncPacketSocket* socket, incoming.socket->SignalReadyToSend.connect(this, &TCPPort::OnReadyToSend); incoming.socket->SignalSentPacket.connect(this, &TCPPort::OnSentPacket); - RTC_LOG(LS_VERBOSE) << ToString() - << ": Accepted connection from " + RTC_LOG(LS_VERBOSE) << ToString() << ": Accepted connection from " << incoming.addr.ToSensitiveString(); incoming_.push_back(incoming); } @@ -289,8 +288,8 @@ void TCPPort::TryCreateServerSocket() { socket_->SignalAddressReady.connect(this, &TCPPort::OnAddressReady); } -rtc::AsyncPacketSocket* TCPPort::GetIncoming( - const rtc::SocketAddress& addr, bool remove) { +rtc::AsyncPacketSocket* TCPPort::GetIncoming(const rtc::SocketAddress& addr, + bool remove) { rtc::AsyncPacketSocket* socket = NULL; for (std::list::iterator it = incoming_.begin(); it != incoming_.end(); ++it) { @@ -305,7 +304,8 @@ rtc::AsyncPacketSocket* TCPPort::GetIncoming( } void TCPPort::OnReadPacket(rtc::AsyncPacketSocket* socket, - const char* data, size_t size, + const char* data, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time) { Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); @@ -360,10 +360,10 @@ TCPConnection::TCPConnection(TCPPort* port, } } -TCPConnection::~TCPConnection() { -} +TCPConnection::~TCPConnection() {} -int TCPConnection::Send(const void* data, size_t size, +int TCPConnection::Send(const void* data, + size_t size, const rtc::PacketOptions& options) { if (!socket_) { error_ = ENOTCONN; @@ -442,8 +442,7 @@ void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) { [socket_address](const rtc::InterfaceAddress& addr) { return socket_address.ipaddr() == addr; }) != desired_addresses.end()) { - RTC_LOG(LS_VERBOSE) << ToString() - << ": Connection established to " + RTC_LOG(LS_VERBOSE) << ToString() << ": Connection established to " << socket->GetRemoteAddress().ToSensitiveString(); } else { if (socket->GetLocalAddress().IsLoopbackIP()) { @@ -477,8 +476,7 @@ void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) { void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { RTC_DCHECK(socket == socket_.get()); - RTC_LOG(LS_INFO) << ToString() - << ": Connection closed with error " << error; + RTC_LOG(LS_INFO) << ToString() << ": Connection closed with error " << error; // Guard against the condition where IPC socket will call OnClose for every // packet it can't send. @@ -533,10 +531,11 @@ void TCPConnection::MaybeReconnect() { error_ = EPIPE; } -void TCPConnection::OnReadPacket( - rtc::AsyncPacketSocket* socket, const char* data, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time) { +void TCPConnection::OnReadPacket(rtc::AsyncPacketSocket* socket, + const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time) { RTC_DCHECK(socket == socket_.get()); Connection::OnReadPacket(data, size, packet_time); } @@ -557,8 +556,7 @@ void TCPConnection::CreateOutgoingTcpSocket() { remote_candidate().address(), port()->proxy(), port()->user_agent(), opts)); if (socket_) { - RTC_LOG(LS_VERBOSE) << ToString() - << ": Connecting from " + RTC_LOG(LS_VERBOSE) << ToString() << ": Connecting from " << socket_->GetLocalAddress().ToSensitiveString() << " to " << remote_candidate().address().ToSensitiveString(); @@ -566,8 +564,7 @@ void TCPConnection::CreateOutgoingTcpSocket() { connection_pending_ = true; ConnectSocketSignals(socket_.get()); } else { - RTC_LOG(LS_WARNING) << ToString() - << ": Failed to create connection to " + RTC_LOG(LS_WARNING) << ToString() << ": Failed to create connection to " << remote_candidate().address().ToSensitiveString(); } } diff --git a/p2p/base/tcpport.h b/p2p/base/tcpport.h index d20a8de1df..fa5c958c21 100644 --- a/p2p/base/tcpport.h +++ b/p2p/base/tcpport.h @@ -83,12 +83,13 @@ class TCPPort : public Port { void TryCreateServerSocket(); - rtc::AsyncPacketSocket* GetIncoming( - const rtc::SocketAddress& addr, bool remove = false); + rtc::AsyncPacketSocket* GetIncoming(const rtc::SocketAddress& addr, + bool remove = false); // Receives packet signal from the local TCP Socket. void OnReadPacket(rtc::AsyncPacketSocket* socket, - const char* data, size_t size, + const char* data, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time); @@ -113,7 +114,8 @@ class TCPPort : public Port { class TCPConnection : public Connection { public: // Connection is outgoing unless socket is specified - TCPConnection(TCPPort* port, const Candidate& candidate, + TCPConnection(TCPPort* port, + const Candidate& candidate, rtc::AsyncPacketSocket* socket = 0); ~TCPConnection() override; @@ -154,7 +156,8 @@ class TCPConnection : public Connection { void OnConnect(rtc::AsyncPacketSocket* socket); void OnClose(rtc::AsyncPacketSocket* socket, int error); void OnReadPacket(rtc::AsyncPacketSocket* socket, - const char* data, size_t size, + const char* data, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time); void OnReadyToSend(rtc::AsyncPacketSocket* socket); diff --git a/p2p/base/tcpport_unittest.cc b/p2p/base/tcpport_unittest.cc index 6d3fe32fe3..ef302f9026 100644 --- a/p2p/base/tcpport_unittest.cc +++ b/p2p/base/tcpport_unittest.cc @@ -54,8 +54,7 @@ class TCPPortTest : public testing::Test, public sigslot::has_slots<> { main_(ss_.get()), socket_factory_(rtc::Thread::Current()), username_(rtc::CreateRandomString(ICE_UFRAG_LENGTH)), - password_(rtc::CreateRandomString(ICE_PWD_LENGTH)) { - } + password_(rtc::CreateRandomString(ICE_PWD_LENGTH)) {} rtc::Network* MakeNetwork(const SocketAddress& addr) { networks_.emplace_back("unittest", "unittest", addr.ipaddr(), 32); diff --git a/p2p/base/testrelayserver.h b/p2p/base/testrelayserver.h index 0d360cf248..550bbeeb8f 100644 --- a/p2p/base/testrelayserver.h +++ b/p2p/base/testrelayserver.h @@ -32,19 +32,17 @@ class TestRelayServer : public sigslot::has_slots<> { const rtc::SocketAddress& ssl_int_addr, const rtc::SocketAddress& ssl_ext_addr) : server_(thread) { - server_.AddInternalSocket(rtc::AsyncUDPSocket::Create( - thread->socketserver(), udp_int_addr)); - server_.AddExternalSocket(rtc::AsyncUDPSocket::Create( - thread->socketserver(), udp_ext_addr)); + server_.AddInternalSocket( + rtc::AsyncUDPSocket::Create(thread->socketserver(), udp_int_addr)); + server_.AddExternalSocket( + rtc::AsyncUDPSocket::Create(thread->socketserver(), udp_ext_addr)); tcp_int_socket_.reset(CreateListenSocket(thread, tcp_int_addr)); tcp_ext_socket_.reset(CreateListenSocket(thread, tcp_ext_addr)); ssl_int_socket_.reset(CreateListenSocket(thread, ssl_int_addr)); ssl_ext_socket_.reset(CreateListenSocket(thread, ssl_ext_addr)); } - int GetConnectionCount() const { - return server_.GetConnectionCount(); - } + int GetConnectionCount() const { return server_.GetConnectionCount(); } rtc::SocketAddressPair GetConnection(int connection) const { return server_.GetConnection(connection); } @@ -54,7 +52,7 @@ class TestRelayServer : public sigslot::has_slots<> { private: rtc::AsyncSocket* CreateListenSocket(rtc::Thread* thread, - const rtc::SocketAddress& addr) { + const rtc::SocketAddress& addr) { rtc::AsyncSocket* socket = thread->socketserver()->CreateAsyncSocket(addr.family(), SOCK_STREAM); socket->Bind(addr); @@ -63,22 +61,22 @@ class TestRelayServer : public sigslot::has_slots<> { return socket; } void OnAccept(rtc::AsyncSocket* socket) { - bool external = (socket == tcp_ext_socket_.get() || - socket == ssl_ext_socket_.get()); - bool ssl = (socket == ssl_int_socket_.get() || - socket == ssl_ext_socket_.get()); + bool external = + (socket == tcp_ext_socket_.get() || socket == ssl_ext_socket_.get()); + bool ssl = + (socket == ssl_int_socket_.get() || socket == ssl_ext_socket_.get()); rtc::AsyncSocket* raw_socket = socket->Accept(NULL); if (raw_socket) { rtc::AsyncTCPSocket* packet_socket = new rtc::AsyncTCPSocket( - (!ssl) ? raw_socket : - new rtc::AsyncSSLServerSocket(raw_socket), false); + (!ssl) ? raw_socket : new rtc::AsyncSSLServerSocket(raw_socket), + false); if (!external) { packet_socket->SignalClose.connect(this, - &TestRelayServer::OnInternalClose); + &TestRelayServer::OnInternalClose); server_.AddInternalSocket(packet_socket); } else { packet_socket->SignalClose.connect(this, - &TestRelayServer::OnExternalClose); + &TestRelayServer::OnExternalClose); server_.AddExternalSocket(packet_socket); } } diff --git a/p2p/base/testturncustomizer.h b/p2p/base/testturncustomizer.h index d05569657c..265b53683a 100644 --- a/p2p/base/testturncustomizer.h +++ b/p2p/base/testturncustomizer.h @@ -24,12 +24,11 @@ class TestTurnCustomizer : public webrtc::TurnCustomizer { enum TestTurnAttributeExtensions { // Test only attribute - STUN_ATTR_COUNTER = 0xFF02 // Number + STUN_ATTR_COUNTER = 0xFF02 // Number }; - void MaybeModifyOutgoingStunMessage( - cricket::PortInterface* port, - cricket::StunMessage* message) override { + void MaybeModifyOutgoingStunMessage(cricket::PortInterface* port, + cricket::StunMessage* message) override { modify_cnt_++; ASSERT_NE(0, message->type()); diff --git a/p2p/base/testturnserver.h b/p2p/base/testturnserver.h index d130560ff2..734ca4d972 100644 --- a/p2p/base/testturnserver.h +++ b/p2p/base/testturnserver.h @@ -32,8 +32,7 @@ class TestTurnRedirector : public TurnRedirectInterface { public: explicit TestTurnRedirector(const std::vector& addresses) : alternate_server_addresses_(addresses), - iter_(alternate_server_addresses_.begin()) { - } + iter_(alternate_server_addresses_.begin()) {} virtual bool ShouldRedirect(const rtc::SocketAddress&, rtc::SocketAddress* out) { @@ -128,7 +127,7 @@ class TestTurnServer : public TurnAuthInterface { RTC_DCHECK(thread_checker_.CalledOnValidThread()); const TurnServer::AllocationMap& map = server_.allocations(); for (TurnServer::AllocationMap::const_iterator it = map.begin(); - it != map.end(); ++it) { + it != map.end(); ++it) { if (src == it->first.src()) { return it->second.get(); } @@ -139,7 +138,8 @@ class TestTurnServer : public TurnAuthInterface { private: // For this test server, succeed if the password is the same as the username. // Obviously, do not use this in a production environment. - virtual bool GetKey(const std::string& username, const std::string& realm, + virtual bool GetKey(const std::string& username, + const std::string& realm, std::string* key) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); return ComputeStunCredentialHash(username, realm, username, key); diff --git a/p2p/base/transportdescription.cc b/p2p/base/transportdescription.cc index 9cbf383d5d..ad29a1199e 100644 --- a/p2p/base/transportdescription.cc +++ b/p2p/base/transportdescription.cc @@ -18,11 +18,8 @@ namespace cricket { bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role) { const char* const roles[] = { - CONNECTIONROLE_ACTIVE_STR, - CONNECTIONROLE_PASSIVE_STR, - CONNECTIONROLE_ACTPASS_STR, - CONNECTIONROLE_HOLDCONN_STR - }; + CONNECTIONROLE_ACTIVE_STR, CONNECTIONROLE_PASSIVE_STR, + CONNECTIONROLE_ACTPASS_STR, CONNECTIONROLE_HOLDCONN_STR}; for (size_t i = 0; i < arraysize(roles); ++i) { if (_stricmp(roles[i], role_str.c_str()) == 0) { diff --git a/p2p/base/transportdescription.h b/p2p/base/transportdescription.h index 664b7d3a23..3bffdf971a 100644 --- a/p2p/base/transportdescription.h +++ b/p2p/base/transportdescription.h @@ -30,18 +30,10 @@ namespace cricket { // or unsupported crypto. // TODO(deadbeef): Remove this or rename it to something more appropriate, like // SdesPolicy. -enum SecurePolicy { - SEC_DISABLED, - SEC_ENABLED, - SEC_REQUIRED -}; +enum SecurePolicy { SEC_DISABLED, SEC_ENABLED, SEC_REQUIRED }; // Whether our side of the call is driving the negotiation, or the other side. -enum IceRole { - ICEROLE_CONTROLLING = 0, - ICEROLE_CONTROLLED, - ICEROLE_UNKNOWN -}; +enum IceRole { ICEROLE_CONTROLLING = 0, ICEROLE_CONTROLLED, ICEROLE_UNKNOWN }; // ICE RFC 5245 implementation type. enum IceMode { @@ -123,8 +115,7 @@ struct TransportDescription { HasOption(ICE_OPTION_RENOMINATION)); } - static rtc::SSLFingerprint* CopyFingerprint( - const rtc::SSLFingerprint* from) { + static rtc::SSLFingerprint* CopyFingerprint(const rtc::SSLFingerprint* from) { if (!from) return NULL; diff --git a/p2p/base/transportdescriptionfactory.cc b/p2p/base/transportdescriptionfactory.cc index 5924a9379d..618726e841 100644 --- a/p2p/base/transportdescriptionfactory.cc +++ b/p2p/base/transportdescriptionfactory.cc @@ -21,8 +21,7 @@ namespace cricket { TransportDescriptionFactory::TransportDescriptionFactory() - : secure_(SEC_DISABLED) { -} + : secure_(SEC_DISABLED) {} TransportDescriptionFactory::~TransportDescriptionFactory() = default; @@ -89,8 +88,9 @@ TransportDescription* TransportDescriptionFactory::CreateAnswer( if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { // Fail if we can't create the fingerprint. // Setting DTLS role to active. - ConnectionRole role = (options.prefer_passive_role) ? - CONNECTIONROLE_PASSIVE : CONNECTIONROLE_ACTIVE; + ConnectionRole role = (options.prefer_passive_role) + ? CONNECTIONROLE_PASSIVE + : CONNECTIONROLE_ACTIVE; if (!SetSecurityInfo(desc.get(), role)) { return NULL; @@ -106,8 +106,8 @@ TransportDescription* TransportDescriptionFactory::CreateAnswer( return desc.release(); } -bool TransportDescriptionFactory::SetSecurityInfo( - TransportDescription* desc, ConnectionRole role) const { +bool TransportDescriptionFactory::SetSecurityInfo(TransportDescription* desc, + ConnectionRole role) const { if (!certificate_) { RTC_LOG(LS_ERROR) << "Cannot create identity digest with no certificate"; return false; diff --git a/p2p/base/transportdescriptionfactory.h b/p2p/base/transportdescriptionfactory.h index f8b031a683..937c5fa1fe 100644 --- a/p2p/base/transportdescriptionfactory.h +++ b/p2p/base/transportdescriptionfactory.h @@ -52,7 +52,8 @@ class TransportDescriptionFactory { } // Creates a transport description suitable for use in an offer. - TransportDescription* CreateOffer(const TransportOptions& options, + TransportDescription* CreateOffer( + const TransportOptions& options, const TransportDescription* current_description) const; // Create a transport description that is a response to an offer. // diff --git a/p2p/base/transportdescriptionfactory_unittest.cc b/p2p/base/transportdescriptionfactory_unittest.cc index df01871067..a7c34b56a0 100644 --- a/p2p/base/transportdescriptionfactory_unittest.cc +++ b/p2p/base/transportdescriptionfactory_unittest.cc @@ -32,8 +32,10 @@ class TransportDescriptionFactoryTest : public testing::Test { new rtc::FakeSSLIdentity("User2")))) {} void CheckDesc(const TransportDescription* desc, - const std::string& opt, const std::string& ice_ufrag, - const std::string& ice_pwd, const std::string& dtls_alg) { + const std::string& opt, + const std::string& ice_ufrag, + const std::string& ice_pwd, + const std::string& dtls_alg) { ASSERT_TRUE(desc != NULL); EXPECT_EQ(!opt.empty(), desc->HasOption(opt)); if (ice_ufrag.empty() && ice_pwd.empty()) { @@ -160,8 +162,8 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtls) { f1_.set_secure(cricket::SEC_ENABLED); f1_.set_certificate(cert1_); std::string digest_alg; - ASSERT_TRUE(cert1_->ssl_certificate().GetSignatureDigestAlgorithm( - &digest_alg)); + ASSERT_TRUE( + cert1_->ssl_certificate().GetSignatureDigestAlgorithm(&digest_alg)); std::unique_ptr desc( f1_.CreateOffer(TransportOptions(), NULL)); CheckDesc(desc.get(), "", "", "", digest_alg); @@ -185,15 +187,14 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsReofferDtls) { f1_.set_secure(cricket::SEC_ENABLED); f1_.set_certificate(cert1_); std::string digest_alg; - ASSERT_TRUE(cert1_->ssl_certificate().GetSignatureDigestAlgorithm( - &digest_alg)); + ASSERT_TRUE( + cert1_->ssl_certificate().GetSignatureDigestAlgorithm(&digest_alg)); std::unique_ptr old_desc( f1_.CreateOffer(TransportOptions(), NULL)); ASSERT_TRUE(old_desc.get() != NULL); std::unique_ptr desc( f1_.CreateOffer(TransportOptions(), old_desc.get())); - CheckDesc(desc.get(), "", - old_desc->ice_ufrag, old_desc->ice_pwd, digest_alg); + CheckDesc(desc.get(), "", old_desc->ice_ufrag, old_desc->ice_pwd, digest_alg); } TEST_F(TransportDescriptionFactoryTest, TestAnswerDefault) { @@ -218,8 +219,7 @@ TEST_F(TransportDescriptionFactoryTest, TestReanswer) { std::unique_ptr desc( f2_.CreateAnswer(offer.get(), TransportOptions(), true, old_desc.get())); ASSERT_TRUE(desc.get() != NULL); - CheckDesc(desc.get(), "", - old_desc->ice_ufrag, old_desc->ice_pwd, ""); + CheckDesc(desc.get(), "", old_desc->ice_ufrag, old_desc->ice_pwd, ""); } // Test that we handle answering an offer with DTLS with no DTLS. @@ -261,8 +261,8 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToDtls) { // f2_ produces the answer that is being checked in this test, so the // answer must contain fingerprint lines with cert2_'s digest algorithm. std::string digest_alg2; - ASSERT_TRUE(cert2_->ssl_certificate().GetSignatureDigestAlgorithm( - &digest_alg2)); + ASSERT_TRUE( + cert2_->ssl_certificate().GetSignatureDigestAlgorithm(&digest_alg2)); std::unique_ptr offer( f1_.CreateOffer(TransportOptions(), NULL)); diff --git a/p2p/base/transportinfo.h b/p2p/base/transportinfo.h index 3502423c12..627c0f781f 100644 --- a/p2p/base/transportinfo.h +++ b/p2p/base/transportinfo.h @@ -29,8 +29,7 @@ struct TransportInfo { TransportInfo(const std::string& content_name, const TransportDescription& description) - : content_name(content_name), - description(description) {} + : content_name(content_name), description(description) {} std::string content_name; TransportDescription description; diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc index 2dd67bc9ae..cb7cfa84e3 100644 --- a/p2p/base/turnport.cc +++ b/p2p/base/turnport.cc @@ -96,7 +96,8 @@ class TurnRefreshRequest : public StunRequest { class TurnCreatePermissionRequest : public StunRequest, public sigslot::has_slots<> { public: - TurnCreatePermissionRequest(TurnPort* port, TurnEntry* entry, + TurnCreatePermissionRequest(TurnPort* port, + TurnEntry* entry, const rtc::SocketAddress& ext_addr); void Prepare(StunMessage* request) override; void OnSent() override; @@ -112,10 +113,11 @@ class TurnCreatePermissionRequest : public StunRequest, rtc::SocketAddress ext_addr_; }; -class TurnChannelBindRequest : public StunRequest, - public sigslot::has_slots<> { +class TurnChannelBindRequest : public StunRequest, public sigslot::has_slots<> { public: - TurnChannelBindRequest(TurnPort* port, TurnEntry* entry, int channel_id, + TurnChannelBindRequest(TurnPort* port, + TurnEntry* entry, + int channel_id, const rtc::SocketAddress& ext_addr); void Prepare(StunMessage* request) override; void OnSent() override; @@ -137,8 +139,7 @@ class TurnChannelBindRequest : public StunRequest, class TurnEntry : public sigslot::has_slots<> { public: enum BindState { STATE_UNBOUND, STATE_BINDING, STATE_BOUND }; - TurnEntry(TurnPort* port, int channel_id, - const rtc::SocketAddress& ext_addr); + TurnEntry(TurnPort* port, int channel_id, const rtc::SocketAddress& ext_addr); TurnPort* port() { return port_; } @@ -164,7 +165,9 @@ class TurnEntry : public sigslot::has_slots<> { void SendChannelBindRequest(int delay); // Sends a packet to the given destination address. // This will wrap the packet in STUN if necessary. - int Send(const void* data, size_t size, bool payload, + int Send(const void* data, + size_t size, + bool payload, const rtc::PacketOptions& options); void OnCreatePermissionSuccess(); @@ -302,8 +305,7 @@ std::vector TurnPort::GetTlsEllipticCurves() const { } void TurnPort::PrepareAddress() { - if (credentials_.username.empty() || - credentials_.password.empty()) { + if (credentials_.username.empty() || credentials_.password.empty()) { RTC_LOG(LS_ERROR) << "Allocation can't be started without setting the" " TURN server credentials for the user."; OnAllocateError(); @@ -330,8 +332,7 @@ void TurnPort::PrepareAddress() { // Insert the current address to prevent redirection pingpong. attempted_server_addresses_.insert(server_address_.address); - RTC_LOG(LS_INFO) << ToString() - << ": Trying to connect to TURN server via " + RTC_LOG(LS_INFO) << ToString() << ": Trying to connect to TURN server via " << ProtoToString(server_address_.proto) << " @ " << server_address_.address.ToSensitiveString(); if (!CreateTurnClientSocket()) { @@ -481,8 +482,7 @@ void TurnPort::OnSocketClose(rtc::AsyncPacketSocket* socket, int error) { void TurnPort::OnAllocateMismatch() { if (allocate_mismatch_retries_ >= MAX_ALLOCATE_MISMATCH_RETRIES) { - RTC_LOG(LS_WARNING) << ToString() - << ": Giving up on the port after " + RTC_LOG(LS_WARNING) << ToString() << ": Giving up on the port after " << allocate_mismatch_retries_ << " retries for STUN_ERROR_ALLOCATION_MISMATCH"; OnAllocateError(); @@ -576,7 +576,8 @@ int TurnPort::GetError() { return error_; } -int TurnPort::SendTo(const void* data, size_t size, +int TurnPort::SendTo(const void* data, + size_t size, const rtc::SocketAddress& addr, const rtc::PacketOptions& options, bool payload) { @@ -612,7 +613,8 @@ bool TurnPort::CanHandleIncomingPacketsFrom( } bool TurnPort::HandleIncomingPacket(rtc::AsyncPacketSocket* socket, - const char* data, size_t size, + const char* data, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time) { if (socket != socket_) { @@ -733,8 +735,7 @@ bool TurnPort::SetAlternateServer(const rtc::SocketAddress& address) { return false; } - RTC_LOG(LS_INFO) << ToString() - << ": Redirecting from TURN server [" + RTC_LOG(LS_INFO) << ToString() << ": Redirecting from TURN server [" << server_address_.address.ToSensitiveString() << "] to TURN server [" << address.ToSensitiveString() << "]"; @@ -749,8 +750,7 @@ void TurnPort::ResolveTurnAddress(const rtc::SocketAddress& address) { if (resolver_) return; - RTC_LOG(LS_INFO) << ToString() - << ": Starting TURN host lookup for " + RTC_LOG(LS_INFO) << ToString() << ": Starting TURN host lookup for " << address.ToSensitiveString(); resolver_ = socket_factory()->CreateAsyncResolver(); resolver_->SignalDone.connect(this, &TurnPort::OnResolveResult); @@ -777,8 +777,7 @@ void TurnPort::OnResolveResult(rtc::AsyncResolverInterface* resolver) { if (resolver_->GetError() != 0 || !resolver_->GetResolvedAddress(Network()->GetBestIP().family(), &resolved_address)) { - RTC_LOG(LS_WARNING) << ToString() - << ": TURN host lookup received error " + RTC_LOG(LS_WARNING) << ToString() << ": TURN host lookup received error " << resolver_->GetError(); error_ = resolver_->GetError(); OnAllocateError(); @@ -786,21 +785,20 @@ void TurnPort::OnResolveResult(rtc::AsyncResolverInterface* resolver) { } // Signal needs both resolved and unresolved address. After signal is sent // we can copy resolved address back into |server_address_|. - SignalResolvedServerAddress(this, server_address_.address, - resolved_address); + SignalResolvedServerAddress(this, server_address_.address, resolved_address); server_address_.address = resolved_address; PrepareAddress(); } -void TurnPort::OnSendStunPacket(const void* data, size_t size, +void TurnPort::OnSendStunPacket(const void* data, + size_t size, StunRequest* request) { RTC_DCHECK(connected()); rtc::PacketOptions options(DefaultDscpValue()); options.info_signaled_after_sent.packet_type = rtc::PacketType::kTurnMessage; CopyPortInformationToPacketInfo(&options.info_signaled_after_sent); if (Send(data, size, options) < 0) { - RTC_LOG(LS_ERROR) << ToString() - << ": Failed to send TURN message, error: " + RTC_LOG(LS_ERROR) << ToString() << ": Failed to send TURN message, error: " << socket_->GetError(); } } @@ -922,7 +920,8 @@ void TurnPort::OnAllocateRequestTimeout() { OnAllocateError(); } -void TurnPort::HandleDataIndication(const char* data, size_t size, +void TurnPort::HandleDataIndication(const char* data, + size_t size, const rtc::PacketTime& packet_time) { // Read in the message, and process according to RFC5766, Section 10.4. rtc::ByteBufferReader buf(data, size); @@ -943,8 +942,7 @@ void TurnPort::HandleDataIndication(const char* data, size_t size, return; } - const StunByteStringAttribute* data_attr = - msg.GetByteString(STUN_ATTR_DATA); + const StunByteStringAttribute* data_attr = msg.GetByteString(STUN_ATTR_DATA); if (!data_attr) { RTC_LOG(LS_WARNING) << ToString() << ": Missing STUN_ATTR_DATA attribute in " @@ -962,11 +960,12 @@ void TurnPort::HandleDataIndication(const char* data, size_t size, << ext_addr.ToSensitiveString(); } - DispatchPacket(data_attr->bytes(), data_attr->length(), ext_addr, - PROTO_UDP, packet_time); + DispatchPacket(data_attr->bytes(), data_attr->length(), ext_addr, PROTO_UDP, + packet_time); } -void TurnPort::HandleChannelData(int channel_id, const char* data, +void TurnPort::HandleChannelData(int channel_id, + const char* data, size_t size, const rtc::PacketTime& packet_time) { // Read the message, and process according to RFC5766, Section 11.6. @@ -1007,9 +1006,11 @@ void TurnPort::HandleChannelData(int channel_id, const char* data, PROTO_UDP, packet_time); } -void TurnPort::DispatchPacket(const char* data, size_t size, - const rtc::SocketAddress& remote_addr, - ProtocolType proto, const rtc::PacketTime& packet_time) { +void TurnPort::DispatchPacket(const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, + ProtocolType proto, + const rtc::PacketTime& packet_time) { if (Connection* conn = GetConnection(remote_addr)) { conn->OnReadPacket(data, size, packet_time); } else { @@ -1046,8 +1047,7 @@ bool TurnPort::ScheduleRefresh(uint32_t lifetime) { } SendRequest(new TurnRefreshRequest(this), delay); - RTC_LOG(LS_INFO) << ToString() << ": Scheduled refresh in " - << delay << "ms."; + RTC_LOG(LS_INFO) << ToString() << ": Scheduled refresh in " << delay << "ms."; return true; } @@ -1068,7 +1068,8 @@ void TurnPort::AddRequestAuthInfo(StunMessage* msg) { RTC_DCHECK(success); } -int TurnPort::Send(const void* data, size_t len, +int TurnPort::Send(const void* data, + size_t len, const rtc::PacketOptions& options) { return socket_->SendTo(data, len, server_address_.address, options); } @@ -1250,8 +1251,9 @@ void TurnPort::TurnCustomizerMaybeModifyOutgoingStunMessage( turn_customizer_->MaybeModifyOutgoingStunMessage(this, message); } -bool TurnPort::TurnCustomizerAllowChannelData( - const void* data, size_t size, bool payload) { +bool TurnPort::TurnCustomizerAllowChannelData(const void* data, + size_t size, + bool payload) { if (turn_customizer_ == nullptr) { return true; } @@ -1260,9 +1262,7 @@ bool TurnPort::TurnCustomizerAllowChannelData( } TurnAllocateRequest::TurnAllocateRequest(TurnPort* port) - : StunRequest(new TurnMessage()), - port_(port) { -} + : StunRequest(new TurnMessage()), port_(port) {} void TurnAllocateRequest::Prepare(StunMessage* request) { // Create the request as indicated in RFC 5766, Section 6.1. @@ -1278,8 +1278,7 @@ void TurnAllocateRequest::Prepare(StunMessage* request) { } void TurnAllocateRequest::OnSent() { - RTC_LOG(LS_INFO) << port_->ToString() - << ": TURN allocate request sent, id=" + RTC_LOG(LS_INFO) << port_->ToString() << ": TURN allocate request sent, id=" << rtc::hex_encode(id()); StunRequest::OnSent(); } @@ -1337,7 +1336,7 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { << ", rtt=" << Elapsed(); switch (error_code) { - case STUN_ERROR_UNAUTHORIZED: // Unauthrorized. + case STUN_ERROR_UNAUTHORIZED: // Unauthrorized. OnAuthChallenge(response, error_code); break; case STUN_ERROR_TRY_ALTERNATE: @@ -1359,9 +1358,8 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { } void TurnAllocateRequest::OnTimeout() { - RTC_LOG(LS_WARNING) << port_->ToString() - << ": TURN allocate request " << rtc::hex_encode(id()) - << " timeout"; + RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN allocate request " + << rtc::hex_encode(id()) << " timeout"; port_->OnAllocateRequestTimeout(); } @@ -1447,10 +1445,7 @@ void TurnAllocateRequest::OnTryAlternate(StunMessage* response, int code) { } TurnRefreshRequest::TurnRefreshRequest(TurnPort* port) - : StunRequest(new TurnMessage()), - port_(port), - lifetime_(-1) { -} + : StunRequest(new TurnMessage()), port_(port), lifetime_(-1) {} void TurnRefreshRequest::Prepare(StunMessage* request) { // Create the request as indicated in RFC 5766, Section 7.1. @@ -1466,8 +1461,7 @@ void TurnRefreshRequest::Prepare(StunMessage* request) { } void TurnRefreshRequest::OnSent() { - RTC_LOG(LS_INFO) << port_->ToString() - << ": TURN refresh request sent, id=" + RTC_LOG(LS_INFO) << port_->ToString() << ": TURN refresh request sent, id=" << rtc::hex_encode(id()); StunRequest::OnSent(); } @@ -1522,13 +1516,14 @@ void TurnRefreshRequest::OnErrorResponse(StunMessage* response) { } void TurnRefreshRequest::OnTimeout() { - RTC_LOG(LS_WARNING) << port_->ToString() - << ": TURN refresh timeout " << rtc::hex_encode(id()); + RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN refresh timeout " + << rtc::hex_encode(id()); port_->OnRefreshError(); } TurnCreatePermissionRequest::TurnCreatePermissionRequest( - TurnPort* port, TurnEntry* entry, + TurnPort* port, + TurnEntry* entry, const rtc::SocketAddress& ext_addr) : StunRequest(new TurnMessage()), port_(port), @@ -1593,15 +1588,17 @@ void TurnCreatePermissionRequest::OnEntryDestroyed(TurnEntry* entry) { } TurnChannelBindRequest::TurnChannelBindRequest( - TurnPort* port, TurnEntry* entry, - int channel_id, const rtc::SocketAddress& ext_addr) + TurnPort* port, + TurnEntry* entry, + int channel_id, + const rtc::SocketAddress& ext_addr) : StunRequest(new TurnMessage()), port_(port), entry_(entry), channel_id_(channel_id), ext_addr_(ext_addr) { - entry_->SignalDestroyed.connect( - this, &TurnChannelBindRequest::OnEntryDestroyed); + entry_->SignalDestroyed.connect(this, + &TurnChannelBindRequest::OnEntryDestroyed); } void TurnChannelBindRequest::Prepare(StunMessage* request) { @@ -1638,8 +1635,8 @@ void TurnChannelBindRequest::OnResponse(StunMessage* response) { // permission from expiring. int delay = TURN_PERMISSION_TIMEOUT - 60000; entry_->SendChannelBindRequest(delay); - RTC_LOG(LS_INFO) << port_->ToString() - << ": Scheduled channel bind in " << delay << "ms."; + RTC_LOG(LS_INFO) << port_->ToString() << ": Scheduled channel bind in " + << delay << "ms."; } } @@ -1655,8 +1652,7 @@ void TurnChannelBindRequest::OnErrorResponse(StunMessage* response) { } void TurnChannelBindRequest::OnTimeout() { - RTC_LOG(LS_WARNING) << port_->ToString() - << ": TURN channel bind timeout " + RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN channel bind timeout " << rtc::hex_encode(id()); if (entry_) { entry_->OnChannelBindTimeout(); @@ -1668,7 +1664,8 @@ void TurnChannelBindRequest::OnEntryDestroyed(TurnEntry* entry) { entry_ = NULL; } -TurnEntry::TurnEntry(TurnPort* port, int channel_id, +TurnEntry::TurnEntry(TurnPort* port, + int channel_id, const rtc::SocketAddress& ext_addr) : port_(port), channel_id_(channel_id), @@ -1684,11 +1681,13 @@ void TurnEntry::SendCreatePermissionRequest(int delay) { } void TurnEntry::SendChannelBindRequest(int delay) { - port_->SendRequest(new TurnChannelBindRequest( - port_, this, channel_id_, ext_addr_), delay); + port_->SendRequest( + new TurnChannelBindRequest(port_, this, channel_id_, ext_addr_), delay); } -int TurnEntry::Send(const void* data, size_t size, bool payload, +int TurnEntry::Send(const void* data, + size_t size, + bool payload, const rtc::PacketOptions& options) { rtc::ByteBufferWriter buf; if (state_ != STATE_BOUND || @@ -1697,8 +1696,7 @@ int TurnEntry::Send(const void* data, size_t size, bool payload, // The turn_customizer_ can also make us use Send Indication. TurnMessage msg; msg.SetType(TURN_SEND_INDICATION); - msg.SetTransactionID( - rtc::CreateRandomString(kStunTransactionIdLength)); + msg.SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); msg.AddAttribute(rtc::MakeUnique( STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); msg.AddAttribute( @@ -1727,8 +1725,7 @@ int TurnEntry::Send(const void* data, size_t size, bool payload, } void TurnEntry::OnCreatePermissionSuccess() { - RTC_LOG(LS_INFO) << port_->ToString() - << ": Create permission for " + RTC_LOG(LS_INFO) << port_->ToString() << ": Create permission for " << ext_addr_.ToSensitiveString() << " succeeded"; port_->SignalCreatePermissionResult(port_, ext_addr_, TURN_SUCCESS_RESULT_CODE); @@ -1768,8 +1765,7 @@ void TurnEntry::OnCreatePermissionTimeout() { } void TurnEntry::OnChannelBindSuccess() { - RTC_LOG(LS_INFO) << port_->ToString() - << ": Successful channel bind for " + RTC_LOG(LS_INFO) << port_->ToString() << ": Successful channel bind for " << ext_addr_.ToSensitiveString(); RTC_DCHECK(state_ == STATE_BINDING || state_ == STATE_BOUND); state_ = STATE_BOUND; diff --git a/p2p/base/turnport_unittest.cc b/p2p/base/turnport_unittest.cc index 68654f4192..5917a7fa37 100644 --- a/p2p/base/turnport_unittest.cc +++ b/p2p/base/turnport_unittest.cc @@ -44,10 +44,10 @@ using rtc::SocketAddress; static const SocketAddress kLocalAddr1("11.11.11.11", 0); static const SocketAddress kLocalAddr2("22.22.22.22", 0); -static const SocketAddress kLocalIPv6Addr( - "2401:fa00:4:1000:be30:5bff:fee5:c3", 0); -static const SocketAddress kLocalIPv6Addr2( - "2401:fa00:4:2000:be30:5bff:fee5:d4", 0); +static const SocketAddress kLocalIPv6Addr("2401:fa00:4:1000:be30:5bff:fee5:c3", + 0); +static const SocketAddress kLocalIPv6Addr2("2401:fa00:4:2000:be30:5bff:fee5:d4", + 0); static const SocketAddress kTurnUdpIntAddr("99.99.99.3", cricket::TURN_SERVER_PORT); static const SocketAddress kTurnTcpIntAddr("99.99.99.4", @@ -61,7 +61,8 @@ static const SocketAddress kTurnIPv6IntAddr( "2400:4030:2:2c00:be30:abcd:efab:cdef", cricket::TURN_SERVER_PORT); static const SocketAddress kTurnUdpIPv6IntAddr( - "2400:4030:1:2c00:be30:abcd:efab:cdef", cricket::TURN_SERVER_PORT); + "2400:4030:1:2c00:be30:abcd:efab:cdef", + cricket::TURN_SERVER_PORT); static const char kCandidateFoundation[] = "foundation"; static const char kIceUfrag1[] = "TESTICEUFRAG0001"; @@ -81,22 +82,22 @@ static constexpr unsigned int kConnectionDestructionDelay = 1; // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=5191 static constexpr unsigned int kResolverTimeout = 10000; -static const cricket::ProtocolAddress kTurnUdpProtoAddr( - kTurnUdpIntAddr, cricket::PROTO_UDP); -static const cricket::ProtocolAddress kTurnTcpProtoAddr( - kTurnTcpIntAddr, cricket::PROTO_TCP); +static const cricket::ProtocolAddress kTurnUdpProtoAddr(kTurnUdpIntAddr, + cricket::PROTO_UDP); +static const cricket::ProtocolAddress kTurnTcpProtoAddr(kTurnTcpIntAddr, + cricket::PROTO_TCP); static const cricket::ProtocolAddress kTurnTlsProtoAddr(kTurnTcpIntAddr, cricket::PROTO_TLS); -static const cricket::ProtocolAddress kTurnUdpIPv6ProtoAddr( - kTurnUdpIPv6IntAddr, cricket::PROTO_UDP); +static const cricket::ProtocolAddress kTurnUdpIPv6ProtoAddr(kTurnUdpIPv6IntAddr, + cricket::PROTO_UDP); static const unsigned int MSG_TESTFINISH = 0; #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) static int GetFDCount() { - struct dirent *dp; + struct dirent* dp; int fd_count = 0; - DIR *dir = opendir("/proc/self/fd/"); + DIR* dir = opendir("/proc/self/fd/"); while ((dp = readdir(dir)) != NULL) { if (dp->d_name[0] == '.') continue; @@ -170,12 +171,8 @@ class TurnPortTest : public testing::Test, test_finish_ = true; } - void OnTurnPortComplete(Port* port) { - turn_ready_ = true; - } - void OnTurnPortError(Port* port) { - turn_error_ = true; - } + void OnTurnPortComplete(Port* port) { turn_ready_ = true; } + void OnTurnPortError(Port* port) { turn_error_ = true; } void OnTurnUnknownAddress(PortInterface* port, const SocketAddress& addr, ProtocolType proto, @@ -194,30 +191,29 @@ class TurnPortTest : public testing::Test, void OnTurnRefreshResult(TurnPort* port, int code) { turn_refresh_success_ = (code == 0); } - void OnTurnReadPacket(Connection* conn, const char* data, size_t size, + void OnTurnReadPacket(Connection* conn, + const char* data, + size_t size, const rtc::PacketTime& packet_time) { turn_packets_.push_back(rtc::Buffer(data, size)); } - void OnUdpPortComplete(Port* port) { - udp_ready_ = true; - } - void OnUdpReadPacket(Connection* conn, const char* data, size_t size, + void OnUdpPortComplete(Port* port) { udp_ready_ = true; } + void OnUdpReadPacket(Connection* conn, + const char* data, + size_t size, const rtc::PacketTime& packet_time) { udp_packets_.push_back(rtc::Buffer(data, size)); } void OnSocketReadPacket(rtc::AsyncPacketSocket* socket, - const char* data, size_t size, + const char* data, + size_t size, const rtc::SocketAddress& remote_addr, const rtc::PacketTime& packet_time) { turn_port_->HandleIncomingPacket(socket, data, size, remote_addr, packet_time); } - void OnTurnPortClosed(TurnPort* port) { - turn_port_closed_ = true; - } - void OnTurnPortDestroyed(PortInterface* port) { - turn_port_destroyed_ = true; - } + void OnTurnPortClosed(TurnPort* port) { turn_port_closed_ = true; } + void OnTurnPortDestroyed(PortInterface* port) { turn_port_destroyed_ = true; } rtc::AsyncSocket* CreateServerSocket(const SocketAddress addr) { rtc::AsyncSocket* socket = ss_->CreateAsyncSocket(AF_INET, SOCK_STREAM); @@ -300,15 +296,15 @@ class TurnPortTest : public testing::Test, socket_.reset(socket_factory_.CreateUdpSocket( rtc::SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0)); ASSERT_TRUE(socket_ != NULL); - socket_->SignalReadPacket.connect( - this, &TurnPortTest::OnSocketReadPacket); + socket_->SignalReadPacket.connect(this, + &TurnPortTest::OnSocketReadPacket); } RelayCredentials credentials(username, password); - turn_port_.reset(TurnPort::Create( - &main_, &socket_factory_, MakeNetwork(kLocalAddr1), socket_.get(), - kIceUfrag1, kIcePwd1, server_address, credentials, 0, std::string(), - nullptr)); + turn_port_.reset(TurnPort::Create(&main_, &socket_factory_, + MakeNetwork(kLocalAddr1), socket_.get(), + kIceUfrag1, kIcePwd1, server_address, + credentials, 0, std::string(), nullptr)); // This TURN port will be the controlling. turn_port_->SetIceRole(ICEROLE_CONTROLLING); ConnectSignals(); @@ -316,19 +312,18 @@ class TurnPortTest : public testing::Test, void ConnectSignals() { turn_port_->SignalPortComplete.connect(this, - &TurnPortTest::OnTurnPortComplete); - turn_port_->SignalPortError.connect(this, - &TurnPortTest::OnTurnPortError); - turn_port_->SignalUnknownAddress.connect(this, - &TurnPortTest::OnTurnUnknownAddress); - turn_port_->SignalCreatePermissionResult.connect(this, - &TurnPortTest::OnTurnCreatePermissionResult); + &TurnPortTest::OnTurnPortComplete); + turn_port_->SignalPortError.connect(this, &TurnPortTest::OnTurnPortError); + turn_port_->SignalUnknownAddress.connect( + this, &TurnPortTest::OnTurnUnknownAddress); + turn_port_->SignalCreatePermissionResult.connect( + this, &TurnPortTest::OnTurnCreatePermissionResult); turn_port_->SignalTurnRefreshResult.connect( this, &TurnPortTest::OnTurnRefreshResult); - turn_port_->SignalTurnPortClosed.connect( - this, &TurnPortTest::OnTurnPortClosed); - turn_port_->SignalDestroyed.connect( - this, &TurnPortTest::OnTurnPortDestroyed); + turn_port_->SignalTurnPortClosed.connect(this, + &TurnPortTest::OnTurnPortClosed); + turn_port_->SignalDestroyed.connect(this, + &TurnPortTest::OnTurnPortDestroyed); } void CreateUdpPort() { CreateUdpPort(kLocalAddr2); } @@ -339,8 +334,8 @@ class TurnPortTest : public testing::Test, kIcePwd2, std::string(), false, absl::nullopt)); // UDP port will be controlled. udp_port_->SetIceRole(ICEROLE_CONTROLLED); - udp_port_->SignalPortComplete.connect( - this, &TurnPortTest::OnUdpPortComplete); + udp_port_->SignalPortComplete.connect(this, + &TurnPortTest::OnUdpPortComplete); } void PrepareTurnAndUdpPorts(ProtocolType protocol_type) { @@ -568,8 +563,8 @@ class TurnPortTest : public testing::Test, // Send ping from UDP to TURN. ASSERT_GE(turn_port_->Candidates().size(), 1U); - Connection* conn1 = udp_port_->CreateConnection( - turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* conn1 = udp_port_->CreateConnection(turn_port_->Candidates()[0], + Port::ORIGIN_MESSAGE); ASSERT_TRUE(conn1 != NULL); conn1->Ping(0); SIMULATED_WAIT(!turn_unknown_address_, kSimulatedRtt * 2, fake_clock_); @@ -578,8 +573,8 @@ class TurnPortTest : public testing::Test, EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state()); // Send ping from TURN to UDP. - Connection* conn2 = turn_port_->CreateConnection( - udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0], + Port::ORIGIN_MESSAGE); ASSERT_TRUE(conn2 != NULL); ASSERT_TRUE_SIMULATED_WAIT(turn_create_permission_success_, kSimulatedRtt, fake_clock_); @@ -643,10 +638,10 @@ class TurnPortTest : public testing::Test, PrepareTurnAndUdpPorts(protocol_type); // Create connections and send pings. - Connection* conn1 = turn_port_->CreateConnection( - udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - Connection* conn2 = udp_port_->CreateConnection( - turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], + Port::ORIGIN_MESSAGE); + Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], + Port::ORIGIN_MESSAGE); ASSERT_TRUE(conn1 != NULL); ASSERT_TRUE(conn2 != NULL); conn1->SignalReadPacket.connect(static_cast(this), @@ -663,7 +658,7 @@ class TurnPortTest : public testing::Test, // Send some data. size_t num_packets = 256; for (size_t i = 0; i < num_packets; ++i) { - unsigned char buf[256] = { 0 }; + unsigned char buf[256] = {0}; for (size_t j = 0; j < i + 1; ++j) { buf[j] = 0xFF - static_cast(j); } @@ -696,10 +691,10 @@ class TurnPortTest : public testing::Test, PrepareTurnAndUdpPorts(protocol_type); // Create connections and send pings. - Connection* conn1 = turn_port_->CreateConnection( - udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - Connection* conn2 = udp_port_->CreateConnection( - turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); + Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], + Port::ORIGIN_MESSAGE); + Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], + Port::ORIGIN_MESSAGE); ASSERT_TRUE(conn1 != NULL); ASSERT_TRUE(conn2 != NULL); conn1->SignalReadPacket.connect(static_cast(this), @@ -714,7 +709,7 @@ class TurnPortTest : public testing::Test, kSimulatedRtt * 2, fake_clock_); // Send some data from Udp to TurnPort. - unsigned char buf[256] = { 0 }; + unsigned char buf[256] = {0}; conn2->Send(buf, sizeof(buf), options); // Now release the TurnPort allocation. @@ -796,7 +791,7 @@ TEST_F(TurnPortTest, TestReconstructedServerUrlForTls) { // Do a normal TURN allocation. TEST_F(TurnPortTest, TestTurnAllocate) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024)); + EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10 * 1024)); turn_port_->PrepareAddress(); EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_); ASSERT_EQ(1U, turn_port_->Candidates().size()); @@ -809,7 +804,7 @@ TEST_F(TurnPortTest, TestTurnAllocate) { TEST_F(TurnPortTest, TestTurnTcpAllocate) { turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024)); + EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10 * 1024)); turn_port_->PrepareAddress(); EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 3, fake_clock_); ASSERT_EQ(1U, turn_port_->Candidates().size()); @@ -1561,11 +1556,11 @@ TEST_F(TurnPortTest, TestResolverShutdown) { } #endif -class MessageObserver : public StunMessageObserver{ +class MessageObserver : public StunMessageObserver { public: - MessageObserver(unsigned int *message_counter, + MessageObserver(unsigned int* message_counter, unsigned int* channel_data_counter, - unsigned int *attr_counter) + unsigned int* attr_counter) : message_counter_(message_counter), channel_data_counter_(channel_data_counter), attr_counter_(attr_counter) {} @@ -1575,8 +1570,8 @@ class MessageObserver : public StunMessageObserver{ (*message_counter_)++; } // Implementation defined attributes are returned as ByteString - const StunByteStringAttribute* attr = msg->GetByteString( - TestTurnCustomizer::STUN_ATTR_COUNTER); + const StunByteStringAttribute* attr = + msg->GetByteString(TestTurnCustomizer::STUN_ATTR_COUNTER); if (attr != nullptr && attr_counter_ != nullptr) { rtc::ByteBufferReader buf(attr->bytes(), attr->length()); unsigned int val = ~0u; @@ -1609,8 +1604,7 @@ TEST_F(TurnPortTest, TestTurnCustomizerCount) { unsigned int observer_attr_counter = 0; TestTurnCustomizer* customizer = new TestTurnCustomizer(); std::unique_ptr validator(new MessageObserver( - &observer_message_counter, - &observer_channel_data_counter, + &observer_message_counter, &observer_channel_data_counter, &observer_attr_counter)); turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); @@ -1640,8 +1634,7 @@ TEST_F(TurnPortTest, TestTurnCustomizerDisallowChannelData) { unsigned int observer_attr_counter = 0; TestTurnCustomizer* customizer = new TestTurnCustomizer(); std::unique_ptr validator(new MessageObserver( - &observer_message_counter, - &observer_channel_data_counter, + &observer_message_counter, &observer_channel_data_counter, &observer_attr_counter)); customizer->allow_channel_data_ = false; turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); @@ -1670,8 +1663,7 @@ TEST_F(TurnPortTest, TestTurnCustomizerAddAttribute) { unsigned int observer_attr_counter = 0; TestTurnCustomizer* customizer = new TestTurnCustomizer(); std::unique_ptr validator(new MessageObserver( - &observer_message_counter, - &observer_channel_data_counter, + &observer_message_counter, &observer_channel_data_counter, &observer_attr_counter)); customizer->allow_channel_data_ = false; customizer->add_counter_ = true; diff --git a/p2p/base/udptransport.h b/p2p/base/udptransport.h index 541910e793..06a795f2e1 100644 --- a/p2p/base/udptransport.h +++ b/p2p/base/udptransport.h @@ -25,7 +25,7 @@ class AsyncPacketSocket; struct PacketTime; struct SentPacket; class SocketAddress; -} +} // namespace rtc namespace cricket { diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc index 6a0c02ba87..14cf1ae43e 100644 --- a/p2p/client/basicportallocator.cc +++ b/p2p/client/basicportallocator.cc @@ -129,13 +129,12 @@ BasicPortAllocator::BasicPortAllocator( RTC_DCHECK(relay_port_factory_ != nullptr); RTC_DCHECK(network_manager_ != nullptr); RTC_DCHECK(socket_factory_ != nullptr); - SetConfiguration(ServerAddresses(), std::vector(), - 0, false, customizer); + SetConfiguration(ServerAddresses(), std::vector(), 0, + false, customizer); Construct(); } -BasicPortAllocator::BasicPortAllocator( - rtc::NetworkManager* network_manager) +BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager) : network_manager_(network_manager), socket_factory_(nullptr) { InitRelayPortFactory(nullptr); RTC_DCHECK(relay_port_factory_ != nullptr); @@ -143,10 +142,9 @@ BasicPortAllocator::BasicPortAllocator( Construct(); } -BasicPortAllocator::BasicPortAllocator( - rtc::NetworkManager* network_manager, - rtc::PacketSocketFactory* socket_factory, - const ServerAddresses& stun_servers) +BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager, + rtc::PacketSocketFactory* socket_factory, + const ServerAddresses& stun_servers) : network_manager_(network_manager), socket_factory_(socket_factory) { InitRelayPortFactory(nullptr); RTC_DCHECK(relay_port_factory_ != nullptr); @@ -224,8 +222,10 @@ void BasicPortAllocator::SetNetworkIgnoreMask(int network_ignore_mask) { } PortAllocatorSession* BasicPortAllocator::CreateSessionInternal( - const std::string& content_name, int component, - const std::string& ice_ufrag, const std::string& ice_pwd) { + const std::string& content_name, + int component, + const std::string& ice_ufrag, + const std::string& ice_pwd) { CheckRunOnValidThreadAndInitialized(); PortAllocatorSession* session = new BasicPortAllocatorSession( this, content_name, component, ice_ufrag, ice_pwd); @@ -545,30 +545,30 @@ bool BasicPortAllocatorSession::CandidatesAllocationDone() const { [](const PortData& port) { return port.inprogress(); }); } -void BasicPortAllocatorSession::OnMessage(rtc::Message *message) { +void BasicPortAllocatorSession::OnMessage(rtc::Message* message) { switch (message->message_id) { - case MSG_CONFIG_START: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - GetPortConfigurations(); - break; - case MSG_CONFIG_READY: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - OnConfigReady(static_cast(message->pdata)); - break; - case MSG_ALLOCATE: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - OnAllocate(); - break; - case MSG_SEQUENCEOBJECTS_CREATED: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - OnAllocationSequenceObjectsCreated(); - break; - case MSG_CONFIG_STOP: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - OnConfigStop(); - break; - default: - RTC_NOTREACHED(); + case MSG_CONFIG_START: + RTC_DCHECK(rtc::Thread::Current() == network_thread_); + GetPortConfigurations(); + break; + case MSG_CONFIG_READY: + RTC_DCHECK(rtc::Thread::Current() == network_thread_); + OnConfigReady(static_cast(message->pdata)); + break; + case MSG_ALLOCATE: + RTC_DCHECK(rtc::Thread::Current() == network_thread_); + OnAllocate(); + break; + case MSG_SEQUENCEOBJECTS_CREATED: + RTC_DCHECK(rtc::Thread::Current() == network_thread_); + OnAllocationSequenceObjectsCreated(); + break; + case MSG_CONFIG_STOP: + RTC_DCHECK(rtc::Thread::Current() == network_thread_); + OnConfigStop(); + break; + default: + RTC_NOTREACHED(); } } @@ -580,9 +580,8 @@ void BasicPortAllocatorSession::UpdateIceParametersInternal() { } void BasicPortAllocatorSession::GetPortConfigurations() { - PortConfiguration* config = new PortConfiguration(allocator_->stun_servers(), - username(), - password()); + PortConfiguration* config = + new PortConfiguration(allocator_->stun_servers(), username(), password()); for (const RelayServerConfig& turn_server : allocator_->turn_servers()) { config->AddRelay(turn_server); @@ -610,8 +609,8 @@ void BasicPortAllocatorSession::OnConfigStop() { // mark those as error. Since session doesn't need any new candidates // at this stage of the allocation, it's safe to discard any new candidates. bool send_signal = false; - for (std::vector::iterator it = ports_.begin(); - it != ports_.end(); ++it) { + for (std::vector::iterator it = ports_.begin(); it != ports_.end(); + ++it) { if (it->inprogress()) { // Updating port state to error, which didn't finish allocating candidates // yet. @@ -836,14 +835,14 @@ void BasicPortAllocatorSession::DisableEquivalentPhases( PortConfiguration* config, uint32_t* flags) { for (uint32_t i = 0; i < sequences_.size() && - (*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES; + (*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES; ++i) { sequences_[i]->DisableEquivalentPhases(network, config, flags); } } void BasicPortAllocatorSession::AddAllocatedPort(Port* port, - AllocationSequence * seq, + AllocationSequence* seq, bool prepare_address) { if (!port) return; @@ -863,13 +862,11 @@ void BasicPortAllocatorSession::AddAllocatedPort(Port* port, port->SignalCandidateReady.connect( this, &BasicPortAllocatorSession::OnCandidateReady); port->SignalPortComplete.connect(this, - &BasicPortAllocatorSession::OnPortComplete); + &BasicPortAllocatorSession::OnPortComplete); port->SignalDestroyed.connect(this, - &BasicPortAllocatorSession::OnPortDestroyed); - port->SignalPortError.connect( - this, &BasicPortAllocatorSession::OnPortError); - RTC_LOG(LS_INFO) << port->ToString() - << ": Added port to allocator"; + &BasicPortAllocatorSession::OnPortDestroyed); + port->SignalPortError.connect(this, &BasicPortAllocatorSession::OnPortError); + RTC_LOG(LS_INFO) << port->ToString() << ": Added port to allocator"; if (prepare_address) port->PrepareAddress(); @@ -881,8 +878,8 @@ void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() { MaybeSignalCandidatesAllocationDone(); } -void BasicPortAllocatorSession::OnCandidateReady( - Port* port, const Candidate& c) { +void BasicPortAllocatorSession::OnCandidateReady(Port* port, + const Candidate& c) { RTC_DCHECK(rtc::Thread::Current() == network_thread_); PortData* data = FindPort(port); RTC_DCHECK(data != NULL); @@ -1091,15 +1088,13 @@ void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() { } } -void BasicPortAllocatorSession::OnPortDestroyed( - PortInterface* port) { +void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) { RTC_DCHECK(rtc::Thread::Current() == network_thread_); for (std::vector::iterator iter = ports_.begin(); iter != ports_.end(); ++iter) { if (port == iter->port()) { ports_.erase(iter); - RTC_LOG(LS_INFO) << port->ToString() - << ": Removed port from allocator (" + RTC_LOG(LS_INFO) << port->ToString() << ": Removed port from allocator (" << static_cast(ports_.size()) << " remaining)"; return; } @@ -1109,8 +1104,8 @@ void BasicPortAllocatorSession::OnPortDestroyed( BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort( Port* port) { - for (std::vector::iterator it = ports_.begin(); - it != ports_.end(); ++it) { + for (std::vector::iterator it = ports_.begin(); it != ports_.end(); + ++it) { if (it->port() == port) { return &*it; } @@ -1170,8 +1165,7 @@ AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session, flags_(flags), udp_socket_(), udp_port_(NULL), - phase_(0) { -} + phase_(0) {} void AllocationSequence::Init() { if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { @@ -1179,8 +1173,8 @@ void AllocationSequence::Init() { rtc::SocketAddress(network_->GetBestIP(), 0), session_->allocator()->min_port(), session_->allocator()->max_port())); if (udp_socket_) { - udp_socket_->SignalReadPacket.connect( - this, &AllocationSequence::OnReadPacket); + udp_socket_->SignalReadPacket.connect(this, + &AllocationSequence::OnReadPacket); } // Continuing if |udp_socket_| is NULL, as local TCP and RelayPort using TCP // are next available options to setup a communication channel. @@ -1204,7 +1198,8 @@ AllocationSequence::~AllocationSequence() { } void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, - PortConfiguration* config, uint32_t* flags) { + PortConfiguration* config, + uint32_t* flags) { if (network_failed_) { // If the network of this allocation sequence has ever become failed, // it won't be equivalent to the new network. @@ -1457,8 +1452,7 @@ void AllocationSequence::CreateGturnPort(const RelayServerConfig& config) { // Add the addresses of this protocol. PortList::const_iterator relay_port; - for (relay_port = config.ports.begin(); - relay_port != config.ports.end(); + for (relay_port = config.ports.begin(); relay_port != config.ports.end(); ++relay_port) { port->AddServerAddress(*relay_port); port->AddExternalAddress(*relay_port); @@ -1470,8 +1464,8 @@ void AllocationSequence::CreateGturnPort(const RelayServerConfig& config) { void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { PortList::const_iterator relay_port; - for (relay_port = config.ports.begin(); - relay_port != config.ports.end(); ++relay_port) { + for (relay_port = config.ports.begin(); relay_port != config.ports.end(); + ++relay_port) { // Skip UDP connections to relay servers if it's disallowed. if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP_RELAY) && relay_port->proto == PROTO_UDP) { @@ -1485,7 +1479,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { if (server_ip_family != AF_UNSPEC && server_ip_family != local_ip_family) { RTC_LOG(LS_INFO) << "Server and local address families are not compatible. " - "Server address: " << relay_port->address.ipaddr().ToString() + "Server address: " + << relay_port->address.ipaddr().ToString() << " Local address: " << network_->GetBestIP().ToString(); continue; } @@ -1512,9 +1507,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { args, udp_socket_.get()); if (!port) { - RTC_LOG(LS_WARNING) - << "Failed to create relay port with " - << args.server_address->address.ToString(); + RTC_LOG(LS_WARNING) << "Failed to create relay port with " + << args.server_address->address.ToString(); continue; } @@ -1524,14 +1518,12 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); } else { port = session_->allocator()->relay_port_factory()->Create( - args, - session_->allocator()->min_port(), + args, session_->allocator()->min_port(), session_->allocator()->max_port()); if (!port) { - RTC_LOG(LS_WARNING) - << "Failed to create relay port with " - << args.server_address->address.ToString(); + RTC_LOG(LS_WARNING) << "Failed to create relay port with " + << args.server_address->address.ToString(); continue; } } @@ -1540,10 +1532,11 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { } } -void AllocationSequence::OnReadPacket( - rtc::AsyncPacketSocket* socket, const char* data, size_t size, - const rtc::SocketAddress& remote_addr, - const rtc::PacketTime& packet_time) { +void AllocationSequence::OnReadPacket(rtc::AsyncPacketSocket* socket, + const char* data, + size_t size, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time) { RTC_DCHECK(socket == udp_socket_.get()); bool turn_port_found = false; @@ -1594,10 +1587,9 @@ void AllocationSequence::OnPortDestroyed(PortInterface* port) { } // PortConfiguration -PortConfiguration::PortConfiguration( - const rtc::SocketAddress& stun_address, - const std::string& username, - const std::string& password) +PortConfiguration::PortConfiguration(const rtc::SocketAddress& stun_address, + const std::string& username, + const std::string& password) : stun_address(stun_address), username(username), password(password) { if (!stun_address.IsNil()) stun_servers.insert(stun_address); @@ -1606,9 +1598,7 @@ PortConfiguration::PortConfiguration( PortConfiguration::PortConfiguration(const ServerAddresses& stun_servers, const std::string& username, const std::string& password) - : stun_servers(stun_servers), - username(username), - password(password) { + : stun_servers(stun_servers), username(username), password(password) { if (!stun_servers.empty()) stun_address = *(stun_servers.begin()); } @@ -1634,12 +1624,11 @@ void PortConfiguration::AddRelay(const RelayServerConfig& config) { relays.push_back(config); } -bool PortConfiguration::SupportsProtocol( - const RelayServerConfig& relay, ProtocolType type) const { +bool PortConfiguration::SupportsProtocol(const RelayServerConfig& relay, + ProtocolType type) const { PortList::const_iterator relay_port; - for (relay_port = relay.ports.begin(); - relay_port != relay.ports.end(); - ++relay_port) { + for (relay_port = relay.ports.begin(); relay_port != relay.ports.end(); + ++relay_port) { if (relay_port->proto == type) return true; } @@ -1649,15 +1638,15 @@ bool PortConfiguration::SupportsProtocol( bool PortConfiguration::SupportsProtocol(RelayType turn_type, ProtocolType type) const { for (size_t i = 0; i < relays.size(); ++i) { - if (relays[i].type == turn_type && - SupportsProtocol(relays[i], type)) + if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) return true; } return false; } ServerAddresses PortConfiguration::GetRelayServerAddresses( - RelayType turn_type, ProtocolType type) const { + RelayType turn_type, + ProtocolType type) const { ServerAddresses servers; for (size_t i = 0; i < relays.size(); ++i) { if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { diff --git a/p2p/client/basicportallocator.h b/p2p/client/basicportallocator.h index 0925ea3655..07bf2f99b8 100644 --- a/p2p/client/basicportallocator.h +++ b/p2p/client/basicportallocator.h @@ -17,8 +17,8 @@ #include "api/turncustomizer.h" #include "p2p/base/portallocator.h" -#include "p2p/client/turnportfactory.h" #include "p2p/client/relayportfactoryinterface.h" +#include "p2p/client/turnportfactory.h" #include "rtc_base/checks.h" #include "rtc_base/messagequeue.h" #include "rtc_base/network.h" @@ -186,9 +186,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession, } has_pairable_candidate_ = has_pairable_candidate; } - void set_complete() { - state_ = STATE_COMPLETE; - } + void set_complete() { state_ = STATE_COMPLETE; } void set_error() { RTC_DCHECK(state_ == STATE_INPROGRESS); state_ = STATE_ERROR; @@ -218,7 +216,8 @@ class BasicPortAllocatorSession : public PortAllocatorSession, void DisableEquivalentPhases(rtc::Network* network, PortConfiguration* config, uint32_t* flags); - void AddAllocatedPort(Port* port, AllocationSequence* seq, + void AddAllocatedPort(Port* port, + AllocationSequence* seq, bool prepare_address); void OnCandidateReady(Port* port, const Candidate& c); void OnPortComplete(Port* port); @@ -308,8 +307,8 @@ struct PortConfiguration : public rtc::MessageData { bool SupportsProtocol(RelayType turn_type, ProtocolType type) const; // Helper method returns the server addresses for the matching RelayType and // Protocol type. - ServerAddresses GetRelayServerAddresses( - RelayType turn_type, ProtocolType type) const; + ServerAddresses GetRelayServerAddresses(RelayType turn_type, + ProtocolType type) const; }; class UDPPort; diff --git a/p2p/client/basicportallocator_unittest.cc b/p2p/client/basicportallocator_unittest.cc index b3d4f25b59..42699a9c89 100644 --- a/p2p/client/basicportallocator_unittest.cc +++ b/p2p/client/basicportallocator_unittest.cc @@ -1339,9 +1339,8 @@ TEST_F(BasicPortAllocatorTest, // a NAT, there is no local candidate. However, this specified default route // (kClientAddr) which was discovered when sending STUN requests, will become // the srflx addresses. -TEST_F( - BasicPortAllocatorTest, - TestDisableAdapterEnumerationWithoutNatLocalhostCandDisabledDiffRoute) { +TEST_F(BasicPortAllocatorTest, + TestDisableAdapterEnumerationWithoutNatLocalhostCandDisabledDiffRoute) { ResetWithStunServerNoNat(kStunAddr); AddInterfaceAsDefaultRoute(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); diff --git a/p2p/client/relayportfactoryinterface.h b/p2p/client/relayportfactoryinterface.h index 5890bcd9bd..2afe6512fe 100644 --- a/p2p/client/relayportfactoryinterface.h +++ b/p2p/client/relayportfactoryinterface.h @@ -56,15 +56,13 @@ class RelayPortFactoryInterface { // This variant is used for UDP connection to the relay server // using a already existing shared socket. - virtual std::unique_ptr Create( - const CreateRelayPortArgs& args, - rtc::AsyncPacketSocket* udp_socket) = 0; + virtual std::unique_ptr Create(const CreateRelayPortArgs& args, + rtc::AsyncPacketSocket* udp_socket) = 0; // This variant is used for the other cases. - virtual std::unique_ptr Create( - const CreateRelayPortArgs& args, - int min_port, - int max_port) = 0; + virtual std::unique_ptr Create(const CreateRelayPortArgs& args, + int min_port, + int max_port) = 0; }; } // namespace cricket diff --git a/p2p/client/turnportfactory.cc b/p2p/client/turnportfactory.cc index fc4f9d31e8..6404134c4a 100644 --- a/p2p/client/turnportfactory.cc +++ b/p2p/client/turnportfactory.cc @@ -16,33 +16,23 @@ namespace cricket { -TurnPortFactory::~TurnPortFactory() { -} +TurnPortFactory::~TurnPortFactory() {} std::unique_ptr TurnPortFactory::Create( const CreateRelayPortArgs& args, rtc::AsyncPacketSocket* udp_socket) { - TurnPort* port = TurnPort::Create( - args.network_thread, - args.socket_factory, - args.network, - udp_socket, - args.username, - args.password, - *args.server_address, - args.config->credentials, - args.config->priority, - args.origin, + args.network_thread, args.socket_factory, args.network, udp_socket, + args.username, args.password, *args.server_address, + args.config->credentials, args.config->priority, args.origin, args.turn_customizer); port->SetTlsCertPolicy(args.config->tls_cert_policy); return std::unique_ptr(port); } -std::unique_ptr TurnPortFactory::Create( - const CreateRelayPortArgs& args, - int min_port, - int max_port) { +std::unique_ptr TurnPortFactory::Create(const CreateRelayPortArgs& args, + int min_port, + int max_port) { TurnPort* port = TurnPort::Create( args.network_thread, args.socket_factory, args.network, min_port, max_port, args.username, args.password, *args.server_address, diff --git a/p2p/client/turnportfactory.h b/p2p/client/turnportfactory.h index d5c510b83f..3e45a6acb0 100644 --- a/p2p/client/turnportfactory.h +++ b/p2p/client/turnportfactory.h @@ -22,14 +22,12 @@ class TurnPortFactory : public RelayPortFactoryInterface { public: ~TurnPortFactory() override; - std::unique_ptr Create( - const CreateRelayPortArgs& args, - rtc::AsyncPacketSocket* udp_socket) override; + std::unique_ptr Create(const CreateRelayPortArgs& args, + rtc::AsyncPacketSocket* udp_socket) override; - std::unique_ptr Create( - const CreateRelayPortArgs& args, - int min_port, - int max_port) override; + std::unique_ptr Create(const CreateRelayPortArgs& args, + int min_port, + int max_port) override; }; } // namespace cricket diff --git a/p2p/stunprober/stunprober.cc b/p2p/stunprober/stunprober.cc index 2a02cd02f1..51506b670d 100644 --- a/p2p/stunprober/stunprober.cc +++ b/p2p/stunprober/stunprober.cc @@ -258,8 +258,7 @@ StunProber::StunProber(rtc::PacketSocketFactory* socket_factory, : interval_ms_(0), socket_factory_(socket_factory), thread_(thread), - networks_(networks) { -} + networks_(networks) {} StunProber::~StunProber() { for (auto* req : requesters_) { diff --git a/pc/bundlefilter.cc b/pc/bundlefilter.cc index 7791da6274..201d2bf95c 100644 --- a/pc/bundlefilter.cc +++ b/pc/bundlefilter.cc @@ -15,11 +15,9 @@ namespace cricket { -BundleFilter::BundleFilter() { -} +BundleFilter::BundleFilter() {} -BundleFilter::~BundleFilter() { -} +BundleFilter::~BundleFilter() {} bool BundleFilter::DemuxPacket(const uint8_t* data, size_t len) { // For RTP packets, we check whether the payload type can be found. diff --git a/pc/bundlefilter_unittest.cc b/pc/bundlefilter_unittest.cc index 2b1af5c3a3..e7cadbfbac 100644 --- a/pc/bundlefilter_unittest.cc +++ b/pc/bundlefilter_unittest.cc @@ -19,29 +19,30 @@ static const int kPayloadType3 = 0x33; // SSRC = 0x1111, Payload type = 0x11 static const unsigned char kRtpPacketPt1Ssrc1[] = { - 0x80, kPayloadType1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, - 0x11, + 0x80, kPayloadType1, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, }; // SSRC = 0x2222, Payload type = 0x22 static const unsigned char kRtpPacketPt2Ssrc2[] = { - 0x80, 0x80 + kPayloadType2, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x80 + kPayloadType2, + 0x00, 0x01, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, 0x22, 0x22, }; // SSRC = 0x2222, Payload type = 0x33 static const unsigned char kRtpPacketPt3Ssrc2[] = { - 0x80, kPayloadType3, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, - 0x22, + 0x80, kPayloadType3, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, }; // An SCTP packet. static const unsigned char kSctpPacket[] = { - 0x00, 0x01, 0x00, 0x01, - 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, }; TEST(BundleFilterTest, RtpPacketTest) { diff --git a/pc/channel.cc b/pc/channel.cc index 041412582c..8ee2ba5996 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -325,7 +325,8 @@ bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet, return SendPacket(true, packet, options); } -int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, +int BaseChannel::SetOption(SocketType type, + rtc::Socket::Option opt, int value) { return network_thread_->Invoke( RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); @@ -608,8 +609,8 @@ bool BaseChannel::UpdateLocalStreams_w(const std::vector& streams, if (it->has_ssrcs() && !GetStreamBySsrc(streams, it->first_ssrc())) { if (!media_channel()->RemoveSendStream(it->first_ssrc())) { std::ostringstream desc; - desc << "Failed to remove send stream with ssrc " - << it->first_ssrc() << "."; + desc << "Failed to remove send stream with ssrc " << it->first_ssrc() + << "."; SafeSetError(desc.str(), error_desc); ret = false; } @@ -649,8 +650,8 @@ bool BaseChannel::UpdateRemoteStreams_w( RTC_LOG(LS_INFO) << "Remove remote ssrc: " << it->first_ssrc(); } else { std::ostringstream desc; - desc << "Failed to remove remote stream with ssrc " - << it->first_ssrc() << "."; + desc << "Failed to remove remote stream with ssrc " << it->first_ssrc() + << "."; SafeSetError(desc.str(), error_desc); ret = false; } @@ -659,7 +660,7 @@ bool BaseChannel::UpdateRemoteStreams_w( demuxer_criteria_.ssrcs.clear(); // Check for new streams. for (StreamParamsVec::const_iterator it = streams.begin(); - it != streams.end(); ++it) { + it != streams.end(); ++it) { // We allow a StreamParams with an empty list of SSRCs, in which case the // MediaChannel will cache the parameters and use them for any unsignaled // stream received later. @@ -689,17 +690,17 @@ RtpHeaderExtensions BaseChannel::GetFilteredRtpHeaderExtensions( if (crypto_options_.enable_encrypted_rtp_header_extensions) { RtpHeaderExtensions filtered; auto pred = [](const webrtc::RtpExtension& extension) { - return !extension.encrypt; + return !extension.encrypt; }; std::copy_if(extensions.begin(), extensions.end(), - std::back_inserter(filtered), pred); + std::back_inserter(filtered), pred); return filtered; } return webrtc::RtpExtension::FilterDuplicateNonEncrypted(extensions); } -void BaseChannel::OnMessage(rtc::Message *pmsg) { +void BaseChannel::OnMessage(rtc::Message* pmsg) { TRACE_EVENT0("webrtc", "BaseChannel::OnMessage"); switch (pmsg->message_id) { case MSG_SEND_RTP_PACKET: @@ -863,7 +864,7 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content, AudioSendParameters send_params = last_send_params_; RtpSendParametersFromMediaDescription(audio, rtp_header_extensions, - &send_params); + &send_params); send_params.mid = content_name(); bool parameters_applied = media_channel()->SetSendParameters(send_params); @@ -998,7 +999,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, VideoSendParameters send_params = last_send_params_; RtpSendParametersFromMediaDescription(video, rtp_header_extensions, - &send_params); + &send_params); if (video->conference_mode()) { send_params.conference_mode = true; } @@ -1162,7 +1163,7 @@ bool RtpDataChannel::SetRemoteContent_w(const MediaContentDescription* content, RTC_LOG(LS_INFO) << "Setting remote data description"; DataSendParameters send_params = last_send_params_; RtpSendParametersFromMediaDescription(data, rtp_header_extensions, - &send_params); + &send_params); if (!media_channel()->SetSendParameters(send_params)) { SafeSetError("Failed to set remote data description send parameters.", error_desc); @@ -1175,8 +1176,7 @@ bool RtpDataChannel::SetRemoteContent_w(const MediaContentDescription* content, // description too (without a local description, we won't be able to // recv them anyway). if (!UpdateRemoteStreams_w(data->streams(), type, error_desc)) { - SafeSetError("Failed to set remote data description streams.", - error_desc); + SafeSetError("Failed to set remote data description streams.", error_desc); return false; } @@ -1232,8 +1232,7 @@ void RtpDataChannel::OnMessage(rtc::Message* pmsg) { void RtpDataChannel::OnDataReceived(const ReceiveDataParams& params, const char* data, size_t len) { - DataReceivedMessageData* msg = new DataReceivedMessageData( - params, data, len); + DataReceivedMessageData* msg = new DataReceivedMessageData(params, data, len); signaling_thread()->Post(RTC_FROM_HERE, this, MSG_DATARECEIVED, msg); } diff --git a/pc/channel.h b/pc/channel.h index 9532ee4a81..6dd2709f5c 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -166,8 +166,7 @@ class BaseChannel : public rtc::MessageHandler, void OnTransportReadyToSend(bool ready); // Only public for unit tests. Otherwise, consider protected. - int SetOption(SocketType type, rtc::Socket::Option o, int val) - override; + int SetOption(SocketType type, rtc::Socket::Option o, int val) override; int SetOption_n(SocketType type, rtc::Socket::Option o, int val); virtual cricket::MediaType media_type() = 0; @@ -443,9 +442,7 @@ class RtpDataChannel : public BaseChannel { SendDataResult* result); // Should be called on the signaling thread only. - bool ready_to_send_data() const { - return ready_to_send_data_; - } + bool ready_to_send_data() const { return ready_to_send_data_; } sigslot::signal2 SignalDataReceived; @@ -466,11 +463,7 @@ class RtpDataChannel : public BaseChannel { SendDataMessageData(const SendDataParams& params, const rtc::CopyOnWriteBuffer* payload, SendDataResult* result) - : params(params), - payload(payload), - result(result), - succeeded(false) { - } + : params(params), payload(payload), result(result), succeeded(false) {} const SendDataParams& params; const rtc::CopyOnWriteBuffer* payload; @@ -482,11 +475,10 @@ class RtpDataChannel : public BaseChannel { // We copy the data because the data will become invalid after we // handle DataMediaChannel::SignalDataReceived but before we fire // SignalDataReceived. - DataReceivedMessageData( - const ReceiveDataParams& params, const char* data, size_t len) - : params(params), - payload(data, len) { - } + DataReceivedMessageData(const ReceiveDataParams& params, + const char* data, + size_t len) + : params(params), payload(data, len) {} const ReceiveDataParams params; const rtc::CopyOnWriteBuffer payload; }; @@ -506,8 +498,9 @@ class RtpDataChannel : public BaseChannel { void UpdateMediaSendRecvState_w() override; void OnMessage(rtc::Message* pmsg) override; - void OnDataReceived( - const ReceiveDataParams& params, const char* data, size_t len); + void OnDataReceived(const ReceiveDataParams& params, + const char* data, + size_t len); void OnDataChannelReadyToSend(bool writable); bool ready_to_send_data_ = false; diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index 0d8fdc3ed4..f8548264c0 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -88,7 +88,7 @@ class DataTraits : public Traits {}; // Base class for Voice/Video/RtpDataChannel tests -template +template class ChannelTest : public testing::Test, public sigslot::has_slots<> { public: enum Flags { @@ -221,10 +221,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { this, &ChannelTest::OnRtcpMuxFullyActive1); channel2_->SignalRtcpMuxFullyActive.connect( this, &ChannelTest::OnRtcpMuxFullyActive2); - CreateContent(flags1, kPcmuCodec, kH264Codec, - &local_media_content1_); - CreateContent(flags2, kPcmuCodec, kH264Codec, - &local_media_content2_); + CreateContent(flags1, kPcmuCodec, kH264Codec, &local_media_content1_); + CreateContent(flags2, kPcmuCodec, kH264Codec, &local_media_content2_); CopyContent(local_media_content1_, &remote_media_content1_); CopyContent(local_media_content2_, &remote_media_content2_); @@ -402,9 +400,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { bool AddStream1(int id) { return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); } - bool RemoveStream1(int id) { - return channel1_->RemoveRecvStream(id); - } + bool RemoveStream1(int id) { return channel1_->RemoveRecvStream(id); } void SendRtp1() { media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), @@ -484,18 +480,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { return data; } - bool CheckNoRtp1() { - return media_channel1_->CheckNoRtp(); - } - bool CheckNoRtp2() { - return media_channel2_->CheckNoRtp(); - } - bool CheckNoRtcp1() { - return media_channel1_->CheckNoRtcp(); - } - bool CheckNoRtcp2() { - return media_channel2_->CheckNoRtcp(); - } + bool CheckNoRtp1() { return media_channel1_->CheckNoRtp(); } + bool CheckNoRtp2() { return media_channel2_->CheckNoRtp(); } + bool CheckNoRtcp1() { return media_channel1_->CheckNoRtcp(); } + bool CheckNoRtcp2() { return media_channel2_->CheckNoRtcp(); } void CreateContent(int flags, const cricket::AudioCodec& audio_codec, @@ -585,8 +573,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { EXPECT_EQ(0U, media_channel1_->codecs().size()); EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, NULL)); ASSERT_EQ(1U, media_channel1_->codecs().size()); - EXPECT_TRUE(CodecMatches(content.codecs()[0], - media_channel1_->codecs()[0])); + EXPECT_TRUE( + CodecMatches(content.codecs()[0], media_channel1_->codecs()[0])); } // Test that SetLocalContent and SetRemoteContent properly deals @@ -599,8 +587,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { EXPECT_EQ(0U, media_channel1_->codecs().size()); EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, NULL)); ASSERT_EQ(1U, media_channel1_->codecs().size()); - EXPECT_TRUE(CodecMatches(content.codecs()[0], - media_channel1_->codecs()[0])); + EXPECT_TRUE( + CodecMatches(content.codecs()[0], media_channel1_->codecs()[0])); } // Test that SetLocalContent and SetRemoteContent properly set RTCP @@ -1020,42 +1008,42 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Test that we can send and receive early media when a provisional answer is // sent and received. The test uses SRTP, RTCP mux and SSRC mux. void SendEarlyMediaUsingRtcpMuxSrtp() { - int sequence_number1_1 = 0, sequence_number2_2 = 0; + int sequence_number1_1 = 0, sequence_number2_2 = 0; - CreateChannels(SSRC_MUX | RTCP_MUX | DTLS, SSRC_MUX | RTCP_MUX | DTLS); - EXPECT_TRUE(SendOffer()); - EXPECT_TRUE(SendProvisionalAnswer()); - EXPECT_TRUE(channel1_->srtp_active()); - EXPECT_TRUE(channel2_->srtp_active()); - EXPECT_EQ(nullptr, channel1_->rtcp_packet_transport()); - EXPECT_EQ(nullptr, channel2_->rtcp_packet_transport()); - WaitForThreads(); // Wait for 'sending' flag go through network thread. - SendCustomRtcp1(kSsrc1); - SendCustomRtp1(kSsrc1, ++sequence_number1_1); - WaitForThreads(); - EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); - EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); + CreateChannels(SSRC_MUX | RTCP_MUX | DTLS, SSRC_MUX | RTCP_MUX | DTLS); + EXPECT_TRUE(SendOffer()); + EXPECT_TRUE(SendProvisionalAnswer()); + EXPECT_TRUE(channel1_->srtp_active()); + EXPECT_TRUE(channel2_->srtp_active()); + EXPECT_EQ(nullptr, channel1_->rtcp_packet_transport()); + EXPECT_EQ(nullptr, channel2_->rtcp_packet_transport()); + WaitForThreads(); // Wait for 'sending' flag go through network thread. + SendCustomRtcp1(kSsrc1); + SendCustomRtp1(kSsrc1, ++sequence_number1_1); + WaitForThreads(); + EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); + EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); - // Send packets from callee and verify that it is received. - SendCustomRtcp2(kSsrc2); - SendCustomRtp2(kSsrc2, ++sequence_number2_2); - WaitForThreads(); - EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); - EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); + // Send packets from callee and verify that it is received. + SendCustomRtcp2(kSsrc2); + SendCustomRtp2(kSsrc2, ++sequence_number2_2); + WaitForThreads(); + EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); + EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); - // Complete call setup and ensure everything is still OK. - EXPECT_TRUE(SendFinalAnswer()); - EXPECT_TRUE(channel1_->srtp_active()); - EXPECT_TRUE(channel2_->srtp_active()); - SendCustomRtcp1(kSsrc1); - SendCustomRtp1(kSsrc1, ++sequence_number1_1); - SendCustomRtcp2(kSsrc2); - SendCustomRtp2(kSsrc2, ++sequence_number2_2); - WaitForThreads(); - EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); - EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); - EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); - EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); + // Complete call setup and ensure everything is still OK. + EXPECT_TRUE(SendFinalAnswer()); + EXPECT_TRUE(channel1_->srtp_active()); + EXPECT_TRUE(channel2_->srtp_active()); + SendCustomRtcp1(kSsrc1); + SendCustomRtp1(kSsrc1, ++sequence_number1_1); + SendCustomRtcp2(kSsrc2); + SendCustomRtp2(kSsrc2, ++sequence_number2_2); + WaitForThreads(); + EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); + EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); + EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); + EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); } // Test that we properly send RTP without SRTP from a thread. @@ -1151,8 +1139,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { EXPECT_TRUE(CheckNoRtp2()); } - void SendBundleToBundle( - const int* pl_types, int len, bool rtcp_mux, bool secure) { + void SendBundleToBundle(const int* pl_types, + int len, + bool rtcp_mux, + bool secure) { ASSERT_EQ(2, len); int sequence_number1_1 = 0, sequence_number2_2 = 0; // Only pl_type1 was added to the bundle filter for both |channel1_| @@ -1473,7 +1463,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { cricket::CandidatePairInterface* last_selected_candidate_pair_; }; -template<> +template <> void ChannelTest::CreateContent( int flags, const cricket::AudioCodec& audio_codec, @@ -1483,18 +1473,18 @@ void ChannelTest::CreateContent( audio->set_rtcp_mux((flags & RTCP_MUX) != 0); } -template<> +template <> void ChannelTest::CopyContent( const cricket::AudioContentDescription& source, cricket::AudioContentDescription* audio) { *audio = source; } -template<> +template <> bool ChannelTest::CodecMatches(const cricket::AudioCodec& c1, const cricket::AudioCodec& c2) { return c1.name == c2.name && c1.clockrate == c2.clockrate && - c1.bitrate == c2.bitrate && c1.channels == c2.channels; + c1.bitrate == c2.bitrate && c1.channels == c2.channels; } template <> @@ -1520,21 +1510,23 @@ class VoiceChannelDoubleThreadTest : public ChannelTest { }; class VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest - : public ChannelTest { + : public ChannelTest { public: typedef ChannelTest Base; VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest() - : Base(true, kPcmuFrameWithExtensions, kRtcpReport, - NetworkIsWorker::Yes) {} + : Base(true, + kPcmuFrameWithExtensions, + kRtcpReport, + NetworkIsWorker::Yes) {} }; class VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest - : public ChannelTest { + : public ChannelTest { public: typedef ChannelTest Base; VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest() - : Base(true, kPcmuFrameWithExtensions, kRtcpReport, - NetworkIsWorker::No) {} + : Base(true, kPcmuFrameWithExtensions, kRtcpReport, NetworkIsWorker::No) { + } }; // override to add NULL parameter @@ -1555,12 +1547,12 @@ std::unique_ptr ChannelTest::CreateChannel( } // override to add 0 parameter -template<> +template <> bool ChannelTest::AddStream1(int id) { return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); } -template<> +template <> void ChannelTest::CreateContent( int flags, const cricket::AudioCodec& audio_codec, @@ -1570,14 +1562,14 @@ void ChannelTest::CreateContent( video->set_rtcp_mux((flags & RTCP_MUX) != 0); } -template<> +template <> void ChannelTest::CopyContent( const cricket::VideoContentDescription& source, cricket::VideoContentDescription* video) { *video = source; } -template<> +template <> bool ChannelTest::CodecMatches(const cricket::VideoCodec& c1, const cricket::VideoCodec& c2) { return c1.name == c2.name; @@ -1683,7 +1675,6 @@ TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) { Base::SendRtpToRtpOnThread(); } - TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) { Base::SendWithWritabilityLoss(); } @@ -2365,14 +2356,11 @@ TEST_F(RtpDataChannelDoubleThreadTest, TestSendData) { cricket::SendDataParams params; params.ssrc = 42; - unsigned char data[] = { - 'f', 'o', 'o' - }; + unsigned char data[] = {'f', 'o', 'o'}; rtc::CopyOnWriteBuffer payload(data, 3); cricket::SendDataResult result; ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); - EXPECT_EQ(params.ssrc, - media_channel1_->last_sent_data_params().ssrc); + EXPECT_EQ(params.ssrc, media_channel1_->last_sent_data_params().ssrc); EXPECT_EQ("foo", media_channel1_->last_sent_data()); } diff --git a/pc/channelmanager.cc b/pc/channelmanager.cc index e32f56a397..ac97ea817c 100644 --- a/pc/channelmanager.cc +++ b/pc/channelmanager.cc @@ -194,7 +194,6 @@ VoiceChannel* ChannelManager::CreateVoiceChannel( return voice_channel_ptr; } - void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) { TRACE_EVENT0("webrtc", "ChannelManager::DestroyVoiceChannel"); if (!voice_channel) { @@ -261,8 +260,6 @@ VideoChannel* ChannelManager::CreateVideoChannel( return video_channel_ptr; } - - void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) { TRACE_EVENT0("webrtc", "ChannelManager::DestroyVideoChannel"); if (!video_channel) { diff --git a/pc/datachannel.cc b/pc/datachannel.cc index b7a717c34e..6971ca8f66 100644 --- a/pc/datachannel.cc +++ b/pc/datachannel.cc @@ -122,10 +122,9 @@ rtc::scoped_refptr DataChannel::Create( return channel; } -DataChannel::DataChannel( - DataChannelProviderInterface* provider, - cricket::DataChannelType dct, - const std::string& label) +DataChannel::DataChannel(DataChannelProviderInterface* provider, + cricket::DataChannelType dct, + const std::string& label) : label_(label), observer_(nullptr), state_(kConnecting), @@ -141,14 +140,11 @@ DataChannel::DataChannel( receive_ssrc_set_(false), writable_(false), send_ssrc_(0), - receive_ssrc_(0) { -} + receive_ssrc_(0) {} bool DataChannel::Init(const InternalDataChannelInit& config) { if (data_channel_type_ == cricket::DCT_RTP) { - if (config.reliable || - config.id != -1 || - config.maxRetransmits != -1 || + if (config.reliable || config.id != -1 || config.maxRetransmits != -1 || config.maxRetransmitTime != -1) { RTC_LOG(LS_ERROR) << "Failed to initialize the RTP data channel due to " "invalid DataChannelInit."; @@ -156,8 +152,7 @@ bool DataChannel::Init(const InternalDataChannelInit& config) { } handshake_state_ = kHandshakeReady; } else if (data_channel_type_ == cricket::DCT_SCTP) { - if (config.id < -1 || - config.maxRetransmits < -1 || + if (config.id < -1 || config.maxRetransmits < -1 || config.maxRetransmitTime < -1) { RTC_LOG(LS_ERROR) << "Failed to initialize the SCTP data channel due to " "invalid DataChannelInit."; @@ -171,15 +166,15 @@ bool DataChannel::Init(const InternalDataChannelInit& config) { config_ = config; switch (config_.open_handshake_role) { - case webrtc::InternalDataChannelInit::kNone: // pre-negotiated - handshake_state_ = kHandshakeReady; - break; - case webrtc::InternalDataChannelInit::kOpener: - handshake_state_ = kHandshakeShouldSendOpen; - break; - case webrtc::InternalDataChannelInit::kAcker: - handshake_state_ = kHandshakeShouldSendAck; - break; + case webrtc::InternalDataChannelInit::kNone: // pre-negotiated + handshake_state_ = kHandshakeReady; + break; + case webrtc::InternalDataChannelInit::kOpener: + handshake_state_ = kHandshakeShouldSendOpen; + break; + case webrtc::InternalDataChannelInit::kAcker: + handshake_state_ = kHandshakeShouldSendAck; + break; } // Try to connect to the transport in case the transport channel already @@ -214,8 +209,7 @@ bool DataChannel::reliable() const { if (data_channel_type_ == cricket::DCT_RTP) { return false; } else { - return config_.maxRetransmits == -1 && - config_.maxRetransmitTime == -1; + return config_.maxRetransmits == -1 && config_.maxRetransmitTime == -1; } } @@ -476,9 +470,8 @@ void DataChannel::UpdateState() { WriteDataChannelOpenAckMessage(&payload); SendControlMessage(payload); } - if (writable_ && - (handshake_state_ == kHandshakeReady || - handshake_state_ == kHandshakeWaitingForAck)) { + if (writable_ && (handshake_state_ == kHandshakeReady || + handshake_state_ == kHandshakeWaitingForAck)) { SetState(kOpen); // If we have received buffers before the channel got writable. // Deliver them now. diff --git a/pc/datachannel.h b/pc/datachannel.h index bd7ea1a3d9..449165729d 100644 --- a/pc/datachannel.h +++ b/pc/datachannel.h @@ -53,11 +53,7 @@ class DataChannelProviderInterface { }; struct InternalDataChannelInit : public DataChannelInit { - enum OpenHandshakeRole { - kOpener, - kAcker, - kNone - }; + enum OpenHandshakeRole { kOpener, kAcker, kNone }; // The default role is kOpener because the default |negotiated| is false. InternalDataChannelInit() : open_handshake_role(kOpener) {} explicit InternalDataChannelInit(const DataChannelInit& base) @@ -223,9 +219,7 @@ class DataChannel : public DataChannelInterface, PacketQueue(); ~PacketQueue(); - size_t byte_count() const { - return byte_count_; - } + size_t byte_count() const { return byte_count_; } bool Empty() const; @@ -301,25 +295,25 @@ class DataChannel : public DataChannelInterface, // Define proxy for DataChannelInterface. BEGIN_SIGNALING_PROXY_MAP(DataChannel) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*) - PROXY_METHOD0(void, UnregisterObserver) - PROXY_CONSTMETHOD0(std::string, label) - PROXY_CONSTMETHOD0(bool, reliable) - PROXY_CONSTMETHOD0(bool, ordered) - PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime) - PROXY_CONSTMETHOD0(uint16_t, maxRetransmits) - PROXY_CONSTMETHOD0(std::string, protocol) - PROXY_CONSTMETHOD0(bool, negotiated) - PROXY_CONSTMETHOD0(int, id) - PROXY_CONSTMETHOD0(DataState, state) - PROXY_CONSTMETHOD0(uint32_t, messages_sent) - PROXY_CONSTMETHOD0(uint64_t, bytes_sent) - PROXY_CONSTMETHOD0(uint32_t, messages_received) - PROXY_CONSTMETHOD0(uint64_t, bytes_received) - PROXY_CONSTMETHOD0(uint64_t, buffered_amount) - PROXY_METHOD0(void, Close) - PROXY_METHOD1(bool, Send, const DataBuffer&) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*) +PROXY_METHOD0(void, UnregisterObserver) +PROXY_CONSTMETHOD0(std::string, label) +PROXY_CONSTMETHOD0(bool, reliable) +PROXY_CONSTMETHOD0(bool, ordered) +PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime) +PROXY_CONSTMETHOD0(uint16_t, maxRetransmits) +PROXY_CONSTMETHOD0(std::string, protocol) +PROXY_CONSTMETHOD0(bool, negotiated) +PROXY_CONSTMETHOD0(int, id) +PROXY_CONSTMETHOD0(DataState, state) +PROXY_CONSTMETHOD0(uint32_t, messages_sent) +PROXY_CONSTMETHOD0(uint64_t, bytes_sent) +PROXY_CONSTMETHOD0(uint32_t, messages_received) +PROXY_CONSTMETHOD0(uint64_t, bytes_received) +PROXY_CONSTMETHOD0(uint64_t, buffered_amount) +PROXY_METHOD0(void, Close) +PROXY_METHOD1(bool, Send, const DataBuffer&) END_PROXY_MAP() } // namespace webrtc diff --git a/pc/datachannel_unittest.cc b/pc/datachannel_unittest.cc index 4a713cb97b..4c044cf629 100644 --- a/pc/datachannel_unittest.cc +++ b/pc/datachannel_unittest.cc @@ -28,33 +28,23 @@ class FakeDataChannelObserver : public webrtc::DataChannelObserver { on_state_change_count_(0), on_buffered_amount_change_count_(0) {} - void OnStateChange() { - ++on_state_change_count_; - } + void OnStateChange() { ++on_state_change_count_; } void OnBufferedAmountChange(uint64_t previous_amount) { ++on_buffered_amount_change_count_; } - void OnMessage(const webrtc::DataBuffer& buffer) { - ++messages_received_; - } + void OnMessage(const webrtc::DataBuffer& buffer) { ++messages_received_; } - size_t messages_received() const { - return messages_received_; - } + size_t messages_received() const { return messages_received_; } - void ResetOnStateChangeCount() { - on_state_change_count_ = 0; - } + void ResetOnStateChangeCount() { on_state_change_count_ = 0; } void ResetOnBufferedAmountChangeCount() { on_buffered_amount_change_count_ = 0; } - size_t on_state_change_count() const { - return on_state_change_count_; - } + size_t on_state_change_count() const { return on_state_change_count_; } size_t on_buffered_amount_change_count() const { return on_buffered_amount_change_count_; @@ -103,13 +93,9 @@ class StateSignalsListener : public sigslot::has_slots<> { int opened_count() const { return opened_count_; } int closed_count() const { return closed_count_; } - void OnSignalOpened(DataChannel* data_channel) { - ++opened_count_; - } + void OnSignalOpened(DataChannel* data_channel) { ++opened_count_; } - void OnSignalClosed(DataChannel* data_channel) { - ++closed_count_; - } + void OnSignalClosed(DataChannel* data_channel) { ++closed_count_; } private: int opened_count_ = 0; @@ -234,12 +220,10 @@ TEST_F(SctpDataChannelTest, VerifyMessagesAndBytesSent) { AddObserver(); SetChannelReady(); std::vector buffers({ - webrtc::DataBuffer("message 1"), - webrtc::DataBuffer("msg 2"), - webrtc::DataBuffer("message three"), - webrtc::DataBuffer("quadra message"), - webrtc::DataBuffer("fifthmsg"), - webrtc::DataBuffer("message of the beast"), + webrtc::DataBuffer("message 1"), webrtc::DataBuffer("msg 2"), + webrtc::DataBuffer("message three"), webrtc::DataBuffer("quadra message"), + webrtc::DataBuffer("fifthmsg"), + webrtc::DataBuffer("message of the beast"), }); // Default values. @@ -306,8 +290,7 @@ TEST_F(SctpDataChannelTest, LateCreatedChannelTransitionToOpen) { rtc::scoped_refptr dc = DataChannel::Create(provider_.get(), cricket::DCT_SCTP, "test1", init); EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, dc->state()); - EXPECT_TRUE_WAIT(webrtc::DataChannelInterface::kOpen == dc->state(), - 1000); + EXPECT_TRUE_WAIT(webrtc::DataChannelInterface::kOpen == dc->state(), 1000); } // Tests that an unordered DataChannel sends data as ordered until the OPEN_ACK @@ -459,12 +442,10 @@ TEST_F(SctpDataChannelTest, NoMsgSentIfNegotiatedAndNotFromOpenMsg) { TEST_F(SctpDataChannelTest, VerifyMessagesAndBytesReceived) { AddObserver(); std::vector buffers({ - webrtc::DataBuffer("message 1"), - webrtc::DataBuffer("msg 2"), - webrtc::DataBuffer("message three"), - webrtc::DataBuffer("quadra message"), - webrtc::DataBuffer("fifthmsg"), - webrtc::DataBuffer("message of the beast"), + webrtc::DataBuffer("message 1"), webrtc::DataBuffer("msg 2"), + webrtc::DataBuffer("message three"), webrtc::DataBuffer("quadra message"), + webrtc::DataBuffer("fifthmsg"), + webrtc::DataBuffer("message of the beast"), }); webrtc_data_channel_->SetSctpSid(1); @@ -584,13 +565,11 @@ TEST_F(SctpDataChannelTest, ClosedWhenReceivedBufferFull) { TEST_F(SctpDataChannelTest, SendEmptyData) { webrtc_data_channel_->SetSctpSid(1); SetChannelReady(); - EXPECT_EQ(webrtc::DataChannelInterface::kOpen, - webrtc_data_channel_->state()); + EXPECT_EQ(webrtc::DataChannelInterface::kOpen, webrtc_data_channel_->state()); webrtc::DataBuffer buffer(""); EXPECT_TRUE(webrtc_data_channel_->Send(buffer)); - EXPECT_EQ(webrtc::DataChannelInterface::kOpen, - webrtc_data_channel_->state()); + EXPECT_EQ(webrtc::DataChannelInterface::kOpen, webrtc_data_channel_->state()); } // Tests that a channel can be closed without being opened or assigned an sid. diff --git a/pc/dtmfsender.cc b/pc/dtmfsender.cc index 1fde7bf236..64876ee80f 100644 --- a/pc/dtmfsender.cc +++ b/pc/dtmfsender.cc @@ -69,8 +69,7 @@ rtc::scoped_refptr DtmfSender::Create( return nullptr; } rtc::scoped_refptr dtmf_sender( - new rtc::RefCountedObject(track, signaling_thread, - provider)); + new rtc::RefCountedObject(track, signaling_thread, provider)); return dtmf_sender; } @@ -113,19 +112,19 @@ bool DtmfSender::CanInsertDtmf() { return provider_->CanInsertDtmf(); } -bool DtmfSender::InsertDtmf(const std::string& tones, int duration, +bool DtmfSender::InsertDtmf(const std::string& tones, + int duration, int inter_tone_gap) { RTC_DCHECK(signaling_thread_->IsCurrent()); - if (duration > kDtmfMaxDurationMs || - duration < kDtmfMinDurationMs || + if (duration > kDtmfMaxDurationMs || duration < kDtmfMinDurationMs || inter_tone_gap < kDtmfMinGapMs) { RTC_LOG(LS_ERROR) << "InsertDtmf is called with invalid duration or tones gap. " "The duration cannot be more than " << kDtmfMaxDurationMs << "ms or less than " << kDtmfMinDurationMs - << "ms. The gap between tones must be at least " - << kDtmfMinGapMs << "ms."; + << "ms. The gap between tones must be at least " << kDtmfMinGapMs + << "ms."; return false; } diff --git a/pc/dtmfsender.h b/pc/dtmfsender.h index ff7f0ac049..f72778bac1 100644 --- a/pc/dtmfsender.h +++ b/pc/dtmfsender.h @@ -49,17 +49,15 @@ class DtmfProviderInterface { virtual ~DtmfProviderInterface() {} }; -class DtmfSender - : public DtmfSenderInterface, - public sigslot::has_slots<>, - public rtc::MessageHandler { +class DtmfSender : public DtmfSenderInterface, + public sigslot::has_slots<>, + public rtc::MessageHandler { public: // |track| is only there for backwards compatibility, since there's a track // accessor method. - static rtc::scoped_refptr Create( - AudioTrackInterface* track, - rtc::Thread* signaling_thread, - DtmfProviderInterface* provider); + static rtc::scoped_refptr Create(AudioTrackInterface* track, + rtc::Thread* signaling_thread, + DtmfProviderInterface* provider); // Implements DtmfSenderInterface. void RegisterObserver(DtmfSenderObserverInterface* observer) override; @@ -105,15 +103,15 @@ class DtmfSender // Define proxy for DtmfSenderInterface. BEGIN_SIGNALING_PROXY_MAP(DtmfSender) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD1(void, RegisterObserver, DtmfSenderObserverInterface*) - PROXY_METHOD0(void, UnregisterObserver) - PROXY_METHOD0(bool, CanInsertDtmf) - PROXY_METHOD3(bool, InsertDtmf, const std::string&, int, int) - PROXY_CONSTMETHOD0(const AudioTrackInterface*, track) - PROXY_CONSTMETHOD0(std::string, tones) - PROXY_CONSTMETHOD0(int, duration) - PROXY_CONSTMETHOD0(int, inter_tone_gap) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_METHOD1(void, RegisterObserver, DtmfSenderObserverInterface*) +PROXY_METHOD0(void, UnregisterObserver) +PROXY_METHOD0(bool, CanInsertDtmf) +PROXY_METHOD3(bool, InsertDtmf, const std::string&, int, int) +PROXY_CONSTMETHOD0(const AudioTrackInterface*, track) +PROXY_CONSTMETHOD0(std::string, tones) +PROXY_CONSTMETHOD0(int, duration) +PROXY_CONSTMETHOD0(int, inter_tone_gap) END_PROXY_MAP() // Get DTMF code from the DTMF event character. diff --git a/pc/dtmfsender_unittest.cc b/pc/dtmfsender_unittest.cc index 48f2bee259..c901763911 100644 --- a/pc/dtmfsender_unittest.cc +++ b/pc/dtmfsender_unittest.cc @@ -15,7 +15,6 @@ #include #include - #include "pc/audiotrack.h" #include "rtc_base/fakeclock.h" #include "rtc_base/gunit.h" @@ -46,12 +45,8 @@ class FakeDtmfObserver : public DtmfSenderObserverInterface { } // getters - const std::vector& tones() const { - return tones_; - } - bool completed() const { - return completed_; - } + const std::vector& tones() const { return tones_; } + bool completed() const { return completed_; } private: std::vector tones_; @@ -62,9 +57,7 @@ class FakeDtmfProvider : public DtmfProviderInterface { public: struct DtmfInfo { DtmfInfo(int code, int duration, int gap) - : code(code), - duration(duration), - gap(gap) {} + : code(code), duration(duration), gap(gap) {} int code; int duration; int gap; @@ -72,9 +65,7 @@ class FakeDtmfProvider : public DtmfProviderInterface { FakeDtmfProvider() : last_insert_dtmf_call_(0) {} - ~FakeDtmfProvider() { - SignalDestroyed(); - } + ~FakeDtmfProvider() { SignalDestroyed(); } // Implements DtmfProviderInterface. bool CanInsertDtmf() override { return can_insert_; } @@ -118,8 +109,7 @@ class DtmfSenderTest : public testing::Test { observer_(new rtc::RefCountedObject()), provider_(new FakeDtmfProvider()) { provider_->SetCanInsertDtmf(true); - dtmf_ = DtmfSender::Create(track_, rtc::Thread::Current(), - provider_.get()); + dtmf_ = DtmfSender::Create(track_, rtc::Thread::Current(), provider_.get()); dtmf_->RegisterObserver(observer_.get()); } @@ -131,7 +121,8 @@ class DtmfSenderTest : public testing::Test { // Constructs a list of DtmfInfo from |tones|, |duration| and // |inter_tone_gap|. - void GetDtmfInfoFromString(const std::string& tones, int duration, + void GetDtmfInfoFromString(const std::string& tones, + int duration, int inter_tone_gap, std::vector* dtmfs) { // Init extra_delay as -inter_tone_gap - duration to ensure the first @@ -146,16 +137,17 @@ class DtmfSenderTest : public testing::Test { if (tone == ',') { extra_delay = 2000; // 2 seconds } else { - dtmfs->push_back(FakeDtmfProvider::DtmfInfo(code, duration, - duration + inter_tone_gap + extra_delay)); + dtmfs->push_back(FakeDtmfProvider::DtmfInfo( + code, duration, duration + inter_tone_gap + extra_delay)); extra_delay = 0; } } } void VerifyExpectedState(AudioTrackInterface* track, - const std::string& tones, - int duration, int inter_tone_gap) { + const std::string& tones, + int duration, + int inter_tone_gap) { EXPECT_EQ(track, dtmf_->track()); EXPECT_EQ(tones, dtmf_->tones()); EXPECT_EQ(duration, dtmf_->duration()); @@ -163,7 +155,8 @@ class DtmfSenderTest : public testing::Test { } // Verify the provider got all the expected calls. - void VerifyOnProvider(const std::string& tones, int duration, + void VerifyOnProvider(const std::string& tones, + int duration, int inter_tone_gap) { std::vector dtmf_queue_ref; GetDtmfInfoFromString(tones, duration, inter_tone_gap, &dtmf_queue_ref); diff --git a/pc/externalhmac.cc b/pc/externalhmac.cc index 8e730e9f4c..d4383f1f4c 100644 --- a/pc/externalhmac.cc +++ b/pc/externalhmac.cc @@ -20,28 +20,25 @@ // Begin test case 0 */ static const uint8_t kExternalHmacTestCase0Key[20] = { - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b -}; + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}; static const uint8_t kExternalHmacTestCase0Data[8] = { - 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 // "Hi There" + 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 // "Hi There" }; -static const uint8_t kExternalHmacFakeTag[10] = { - 0xba, 0xdd, 0xba, 0xdd, 0xba, 0xdd, 0xba, 0xdd, 0xba, 0xdd -}; +static const uint8_t kExternalHmacFakeTag[10] = {0xba, 0xdd, 0xba, 0xdd, 0xba, + 0xdd, 0xba, 0xdd, 0xba, 0xdd}; static const srtp_auth_test_case_t kExternalHmacTestCase0 = { - 20, // Octets in key - const_cast(kExternalHmacTestCase0Key), // Key - 8, // Octets in data - const_cast(kExternalHmacTestCase0Data), // Data - 10, // Octets in tag - const_cast(kExternalHmacFakeTag), // Tag - NULL // Pointer to next - // testcase + 20, // Octets in key + const_cast(kExternalHmacTestCase0Key), // Key + 8, // Octets in data + const_cast(kExternalHmacTestCase0Data), // Data + 10, // Octets in tag + const_cast(kExternalHmacFakeTag), // Tag + NULL // Pointer to next + // testcase }; static const char kExternalHmacDescription[] = @@ -49,17 +46,16 @@ static const char kExternalHmacDescription[] = // srtp_auth_type_t external_hmac is the hmac metaobject -static const srtp_auth_type_t external_hmac = { - external_hmac_alloc, - external_hmac_dealloc, - external_hmac_init, - external_hmac_compute, - external_hmac_update, - external_hmac_start, - const_cast(kExternalHmacDescription), - const_cast(&kExternalHmacTestCase0), - EXTERNAL_HMAC_SHA1 -}; +static const srtp_auth_type_t external_hmac = { + external_hmac_alloc, + external_hmac_dealloc, + external_hmac_init, + external_hmac_compute, + external_hmac_update, + external_hmac_start, + const_cast(kExternalHmacDescription), + const_cast(&kExternalHmacTestCase0), + EXTERNAL_HMAC_SHA1}; srtp_err_status_t external_hmac_alloc(srtp_auth_t** a, int key_len, diff --git a/pc/jsepicecandidate.cc b/pc/jsepicecandidate.cc index 48feb89a69..48a1d0894b 100644 --- a/pc/jsepicecandidate.cc +++ b/pc/jsepicecandidate.cc @@ -31,20 +31,16 @@ IceCandidateInterface* CreateIceCandidate(const std::string& sdp_mid, JsepIceCandidate::JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index) - : sdp_mid_(sdp_mid), - sdp_mline_index_(sdp_mline_index) { -} + : sdp_mid_(sdp_mid), sdp_mline_index_(sdp_mline_index) {} JsepIceCandidate::JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index, const cricket::Candidate& candidate) : sdp_mid_(sdp_mid), sdp_mline_index_(sdp_mline_index), - candidate_(candidate) { -} + candidate_(candidate) {} -JsepIceCandidate::~JsepIceCandidate() { -} +JsepIceCandidate::~JsepIceCandidate() {} bool JsepIceCandidate::Initialize(const std::string& sdp, SdpParseError* err) { return SdpDeserializeCandidate(sdp, this, err); @@ -68,7 +64,7 @@ bool JsepCandidateCollection::HasCandidate( const IceCandidateInterface* candidate) const { bool ret = false; for (std::vector::const_iterator it = candidates_.begin(); - it != candidates_.end(); ++it) { + it != candidates_.end(); ++it) { if ((*it)->sdp_mid() == candidate->sdp_mid() && (*it)->sdp_mline_index() == candidate->sdp_mline_index() && (*it)->candidate().IsEquivalent(candidate->candidate())) { diff --git a/pc/jsepsessiondescription_unittest.cc b/pc/jsepsessiondescription_unittest.cc index fbcfcb7161..614b23d2ba 100644 --- a/pc/jsepsessiondescription_unittest.cc +++ b/pc/jsepsessiondescription_unittest.cc @@ -81,13 +81,11 @@ class JsepSessionDescriptionTest : public testing::Test { cricket::Candidate candidate(cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", address, 1, "", "", "local", 0, "1"); candidate_ = candidate; - const std::string session_id = - rtc::ToString(rtc::CreateRandomId64()); - const std::string session_version = - rtc::ToString(rtc::CreateRandomId()); + const std::string session_id = rtc::ToString(rtc::CreateRandomId64()); + const std::string session_version = rtc::ToString(rtc::CreateRandomId()); jsep_desc_ = rtc::MakeUnique(SdpType::kOffer); ASSERT_TRUE(jsep_desc_->Initialize(CreateCricketSessionDescription(), - session_id, session_version)); + session_id, session_version)); } std::string Serialize(const SessionDescriptionInterface* desc) { diff --git a/pc/localaudiosource.cc b/pc/localaudiosource.cc index b2fdd4dcae..b8dbfaab1c 100644 --- a/pc/localaudiosource.cc +++ b/pc/localaudiosource.cc @@ -26,8 +26,7 @@ rtc::scoped_refptr LocalAudioSource::Create( return source; } -void LocalAudioSource::Initialize( - const cricket::AudioOptions* audio_options) { +void LocalAudioSource::Initialize(const cricket::AudioOptions* audio_options) { if (!audio_options) return; diff --git a/pc/mediasession.cc b/pc/mediasession.cc index 92a6106fc8..79aa975d96 100644 --- a/pc/mediasession.cc +++ b/pc/mediasession.cc @@ -120,12 +120,13 @@ static bool IsMediaContentOfType(const ContentInfo* content, return content->media_description()->type() == media_type; } -static bool CreateCryptoParams(int tag, const std::string& cipher, - CryptoParams *out) { +static bool CreateCryptoParams(int tag, + const std::string& cipher, + CryptoParams* out) { int key_len; int salt_len; - if (!rtc::GetSrtpKeyAndSaltLengths( - rtc::SrtpCryptoSuiteFromName(cipher), &key_len, &salt_len)) { + if (!rtc::GetSrtpKeyAndSaltLengths(rtc::SrtpCryptoSuiteFromName(cipher), + &key_len, &salt_len)) { return false; } @@ -146,7 +147,7 @@ static bool CreateCryptoParams(int tag, const std::string& cipher, } static bool AddCryptoParams(const std::string& cipher_suite, - CryptoParamsVec *out) { + CryptoParamsVec* out) { int size = static_cast(out->size()); out->resize(size + 1); @@ -254,12 +255,12 @@ void GetSupportedDataSdesCryptoSuiteNames( static bool SelectCrypto(const MediaContentDescription* offer, bool bundle, const rtc::CryptoOptions& crypto_options, - CryptoParams *crypto) { + CryptoParams* crypto) { bool audio = offer->type() == MEDIA_TYPE_AUDIO; const CryptoParamsVec& cryptos = offer->cryptos(); - for (CryptoParamsVec::const_iterator i = cryptos.begin(); - i != cryptos.end(); ++i) { + for (CryptoParamsVec::const_iterator i = cryptos.begin(); i != cryptos.end(); + ++i) { if ((crypto_options.enable_gcm_crypto_suites && rtc::IsGcmCryptoSuiteName(i->cipher_suite)) || rtc::CS_AES_CM_128_HMAC_SHA1_80 == i->cipher_suite || @@ -325,8 +326,7 @@ class UsedIds { UsedIds(int min_allowed_id, int max_allowed_id) : min_allowed_id_(min_allowed_id), max_allowed_id_(max_allowed_id), - next_id_(max_allowed_id) { - } + next_id_(max_allowed_id) {} // Loops through all Id in |ids| and changes its id if it is // already in use by another IdStruct. Call this methods with all Id @@ -334,8 +334,8 @@ class UsedIds { // Note that typename Id must be a type of IdStruct. template void FindAndSetIdUsed(std::vector* ids) { - for (typename std::vector::iterator it = ids->begin(); - it != ids->end(); ++it) { + for (typename std::vector::iterator it = ids->begin(); it != ids->end(); + ++it) { FindAndSetIdUsed(&*it); } } @@ -372,13 +372,9 @@ class UsedIds { return next_id_; } - bool IsIdUsed(int new_id) { - return id_set_.find(new_id) != id_set_.end(); - } + bool IsIdUsed(int new_id) { return id_set_.find(new_id) != id_set_.end(); } - void SetIdUsed(int new_id) { - id_set_.insert(new_id); - } + void SetIdUsed(int new_id) { id_set_.insert(new_id); } const int min_allowed_id_; const int max_allowed_id_; @@ -391,9 +387,7 @@ class UsedIds { class UsedPayloadTypes : public UsedIds { public: UsedPayloadTypes() - : UsedIds(kDynamicPayloadTypeMin, kDynamicPayloadTypeMax) { - } - + : UsedIds(kDynamicPayloadTypeMin, kDynamicPayloadTypeMax) {} private: static const int kDynamicPayloadTypeMin = 96; @@ -428,7 +422,6 @@ static bool AddStreamParams( const bool include_rtx_streams = ContainsRtxCodec(content_description->codecs()); - const bool include_flexfec_stream = ContainsFlexfecCodec(content_description->codecs()); @@ -519,8 +512,7 @@ static bool UpdateTransportInfoForBundle(const ContentGroup& bundle_group, selected_transport_info->description.ice_pwd; ConnectionRole selected_connection_role = selected_transport_info->description.connection_role; - for (TransportInfos::iterator it = - sdesc->transport_infos().begin(); + for (TransportInfos::iterator it = sdesc->transport_infos().begin(); it != sdesc->transport_infos().end(); ++it) { if (bundle_group.HasContentName(it->content_name) && it->content_name != selected_content_name) { @@ -931,11 +923,12 @@ static bool FindByUri(const RtpHeaderExtensions& extensions, static bool FindByUriWithEncryptionPreference( const RtpHeaderExtensions& extensions, - const webrtc::RtpExtension& ext_to_match, bool encryption_preference, + const webrtc::RtpExtension& ext_to_match, + bool encryption_preference, webrtc::RtpExtension* found_extension) { const webrtc::RtpExtension* unencrypted_extension = nullptr; for (RtpHeaderExtensions::const_iterator it = extensions.begin(); - it != extensions.end(); ++it) { + it != extensions.end(); ++it) { // We assume that all URIs are given in a canonical format. if (it->uri == ext_to_match.uri) { if (!encryption_preference || it->encrypt) { @@ -1008,7 +1001,8 @@ static void AddEncryptedVersionsOfHdrExts(RtpHeaderExtensions* extensions, if (extension.encrypt || !webrtc::RtpExtension::IsEncryptionSupported(extension.uri) || (FindByUriWithEncryptionPreference(*extensions, extension, true, - &existing) && existing.encrypt)) { + &existing) && + existing.encrypt)) { continue; } @@ -1023,7 +1017,7 @@ static void AddEncryptedVersionsOfHdrExts(RtpHeaderExtensions* extensions, } } extensions->insert(extensions->end(), encrypted_extensions.begin(), - encrypted_extensions.end()); + encrypted_extensions.end()); } static void NegotiateRtpHeaderExtensions( @@ -1032,11 +1026,12 @@ static void NegotiateRtpHeaderExtensions( bool enable_encrypted_rtp_header_extensions, RtpHeaderExtensions* negotiated_extenstions) { RtpHeaderExtensions::const_iterator ours; - for (ours = local_extensions.begin(); - ours != local_extensions.end(); ++ours) { + for (ours = local_extensions.begin(); ours != local_extensions.end(); + ++ours) { webrtc::RtpExtension theirs; - if (FindByUriWithEncryptionPreference(offered_extensions, *ours, - enable_encrypted_rtp_header_extensions, &theirs)) { + if (FindByUriWithEncryptionPreference( + offered_extensions, *ours, enable_encrypted_rtp_header_extensions, + &theirs)) { // We respond with their RTP header extension id. negotiated_extenstions->push_back(theirs); } @@ -1079,10 +1074,9 @@ static bool CreateMediaContentAnswer( answer->AddCodecs(negotiated_codecs); answer->set_protocol(offer->protocol()); RtpHeaderExtensions negotiated_rtp_extensions; - NegotiateRtpHeaderExtensions(local_rtp_extenstions, - offer->rtp_header_extensions(), - enable_encrypted_rtp_header_extensions, - &negotiated_rtp_extensions); + NegotiateRtpHeaderExtensions( + local_rtp_extenstions, offer->rtp_header_extensions(), + enable_encrypted_rtp_header_extensions, &negotiated_rtp_extensions); answer->set_rtp_header_extensions(negotiated_rtp_extensions); answer->set_rtcp_mux(session_options.rtcp_mux_enabled && offer->rtcp_mux()); @@ -1260,7 +1254,8 @@ const AudioCodecs& MediaSessionDescriptionFactory::audio_recv_codecs() const { } void MediaSessionDescriptionFactory::set_audio_codecs( - const AudioCodecs& send_codecs, const AudioCodecs& recv_codecs) { + const AudioCodecs& send_codecs, + const AudioCodecs& recv_codecs) { audio_send_codecs_ = send_codecs; audio_recv_codecs_ = recv_codecs; ComputeAudioCodecsIntersectionAndUnion(); @@ -1771,18 +1766,19 @@ void MediaSessionDescriptionFactory::GetRtpHdrExtsToOffer( } bool MediaSessionDescriptionFactory::AddTransportOffer( - const std::string& content_name, - const TransportOptions& transport_options, - const SessionDescription* current_desc, - SessionDescription* offer_desc) const { + const std::string& content_name, + const TransportOptions& transport_options, + const SessionDescription* current_desc, + SessionDescription* offer_desc) const { if (!transport_desc_factory_) - return false; + return false; const TransportDescription* current_tdesc = GetTransportDescription(content_name, current_desc); std::unique_ptr new_tdesc( transport_desc_factory_->CreateOffer(transport_options, current_tdesc)); - bool ret = (new_tdesc.get() != NULL && - offer_desc->AddTransportInfo(TransportInfo(content_name, *new_tdesc))); + bool ret = + (new_tdesc.get() != NULL && + offer_desc->AddTransportInfo(TransportInfo(content_name, *new_tdesc))); if (!ret) { RTC_LOG(LS_ERROR) << "Failed to AddTransportOffer, content name=" << content_name; @@ -1811,8 +1807,8 @@ bool MediaSessionDescriptionFactory::AddTransportAnswer( const std::string& content_name, const TransportDescription& transport_desc, SessionDescription* answer_desc) const { - if (!answer_desc->AddTransportInfo(TransportInfo(content_name, - transport_desc))) { + if (!answer_desc->AddTransportInfo( + TransportInfo(content_name, transport_desc))) { RTC_LOG(LS_ERROR) << "Failed to AddTransportAnswer, content name=" << content_name; return false; @@ -2006,8 +2002,8 @@ bool MediaSessionDescriptionFactory::AddDataContentForOffer( // TODO(deadbeef): Offer kMediaProtocolUdpDtlsSctp (or TcpDtlsSctp), once // it's safe to do so. Older versions of webrtc would reject these // protocols; see https://bugs.chromium.org/p/webrtc/issues/detail?id=7706. - data->set_protocol( - secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); + data->set_protocol(secure_transport ? kMediaProtocolDtlsSctp + : kMediaProtocolSctp); } else { GetSupportedDataSdesCryptoSuiteNames(session_options.crypto_options, &crypto_suites); @@ -2385,7 +2381,8 @@ const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc) { } const MediaContentDescription* GetFirstMediaContentDescription( - const SessionDescription* sdesc, MediaType media_type) { + const SessionDescription* sdesc, + MediaType media_type) { const ContentInfo* content = GetFirstMediaContent(sdesc, media_type); return (content ? content->media_description() : nullptr); } diff --git a/pc/mediasession.h b/pc/mediasession.h index 997a4692d3..b40974039b 100644 --- a/pc/mediasession.h +++ b/pc/mediasession.h @@ -183,11 +183,10 @@ class MediaSessionDescriptionFactory { const SessionDescription* current_description, RtpHeaderExtensions* audio_extensions, RtpHeaderExtensions* video_extensions) const; - bool AddTransportOffer( - const std::string& content_name, - const TransportOptions& transport_options, - const SessionDescription* current_desc, - SessionDescription* offer) const; + bool AddTransportOffer(const std::string& content_name, + const TransportOptions& transport_options, + const SessionDescription* current_desc, + SessionDescription* offer) const; TransportDescription* CreateTransportAnswer( const std::string& content_name, @@ -196,10 +195,9 @@ class MediaSessionDescriptionFactory { const SessionDescription* current_desc, bool require_transport_attributes) const; - bool AddTransportAnswer( - const std::string& content_name, - const TransportDescription& transport_desc, - SessionDescription* answer_desc) const; + bool AddTransportAnswer(const std::string& content_name, + const TransportDescription& transport_desc, + SessionDescription* answer_desc) const; // Helpers for adding media contents to the SessionDescription. Returns true // it succeeds or the media content is not needed, or false if there is any diff --git a/pc/mediasession_unittest.cc b/pc/mediasession_unittest.cc index acc18506f1..269ad78a70 100644 --- a/pc/mediasession_unittest.cc +++ b/pc/mediasession_unittest.cc @@ -26,9 +26,9 @@ #include "rtc_base/messagedigest.h" #include "rtc_base/ssladapter.h" -#define ASSERT_CRYPTO(cd, s, cs) \ - ASSERT_EQ(s, cd->cryptos().size()); \ - ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) +#define ASSERT_CRYPTO(cd, s, cs) \ + ASSERT_EQ(s, cd->cryptos().size()); \ + ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) typedef std::vector Candidates; @@ -423,18 +423,14 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { std::unique_ptr desc; if (has_current_desc) { current_desc.reset(new SessionDescription()); - EXPECT_TRUE(current_desc->AddTransportInfo( - TransportInfo("audio", - TransportDescription(current_audio_ufrag, - current_audio_pwd)))); - EXPECT_TRUE(current_desc->AddTransportInfo( - TransportInfo("video", - TransportDescription(current_video_ufrag, - current_video_pwd)))); - EXPECT_TRUE(current_desc->AddTransportInfo( - TransportInfo("data", - TransportDescription(current_data_ufrag, - current_data_pwd)))); + EXPECT_TRUE(current_desc->AddTransportInfo(TransportInfo( + "audio", + TransportDescription(current_audio_ufrag, current_audio_pwd)))); + EXPECT_TRUE(current_desc->AddTransportInfo(TransportInfo( + "video", + TransportDescription(current_video_ufrag, current_video_pwd)))); + EXPECT_TRUE(current_desc->AddTransportInfo(TransportInfo( + "data", TransportDescription(current_data_ufrag, current_data_pwd)))); } if (offer) { desc.reset(f1_.CreateOffer(options, current_desc.get())); @@ -471,8 +467,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { if (options.bundle_enabled) { EXPECT_EQ(ti_audio->description.ice_ufrag, ti_video->description.ice_ufrag); - EXPECT_EQ(ti_audio->description.ice_pwd, - ti_video->description.ice_pwd); + EXPECT_EQ(ti_audio->description.ice_pwd, ti_video->description.ice_pwd); } else { if (has_current_desc) { EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); @@ -498,8 +493,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { if (options.bundle_enabled) { EXPECT_EQ(ti_audio->description.ice_ufrag, ti_data->description.ice_ufrag); - EXPECT_EQ(ti_audio->description.ice_pwd, - ti_data->description.ice_pwd); + EXPECT_EQ(ti_audio->description.ice_pwd, ti_data->description.ice_pwd); } else { if (has_current_desc) { EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); @@ -560,7 +554,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { bool found = false; for (size_t i = 0; i < ref_audio_media_desc->cryptos().size(); ++i) { if (ref_audio_media_desc->cryptos()[i].Matches( - audio_media_desc->cryptos()[0])) { + audio_media_desc->cryptos()[0])) { found = true; break; } @@ -647,8 +641,8 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { } EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); - EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached - EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux + EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached + EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux if (gcm_offer && gcm_answer) { ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuiteGcm); } else { @@ -818,8 +812,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached. EXPECT_EQ(cricket::kDataMaxBandwidth, - dcd->bandwidth()); // default bandwidth (auto) - EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on + dcd->bandwidth()); // default bandwidth (auto) + EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on ASSERT_CRYPTO(dcd, 1U, kDefaultSrtpCryptoSuite); EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); } @@ -872,8 +866,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, const AudioContentDescription* acd = ac->media_description()->as_audio(); const VideoContentDescription* vcd = vc->media_description()->as_video(); - EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. - EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. + EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. + EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. } // Creates an audio+video sendonly offer. @@ -1004,8 +998,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { ASSERT_CRYPTO(acd, 1U, kDefaultSrtpCryptoSuite); EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); - EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached - EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux + EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached + EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuite); EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); } @@ -1299,124 +1293,112 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { std::unique_ptr answer( f2_.CreateAnswer(offer.get(), opts, NULL)); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), - GetFirstAudioContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), - GetFirstVideoContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), - GetFirstAudioContentDescription( - answer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), - GetFirstVideoContentDescription( - answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtension1), + GetFirstAudioContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtension1), + GetFirstVideoContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionAnswer), + GetFirstAudioContentDescription(answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionAnswer), + GetFirstVideoContentDescription(answer.get())->rtp_header_extensions()); } TEST_F(MediaSessionDescriptionFactoryTest, - TestOfferAnswerWithEncryptedRtpExtensionsBoth) { + TestOfferAnswerWithEncryptedRtpExtensionsBoth) { MediaSessionOptions opts; AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts); f1_.set_enable_encrypted_rtp_header_extensions(true); f2_.set_enable_encrypted_rtp_header_extensions(true); - f1_.set_audio_rtp_header_extensions( - MAKE_VECTOR(kAudioRtpExtension1)); - f1_.set_video_rtp_header_extensions( - MAKE_VECTOR(kVideoRtpExtension1)); - f2_.set_audio_rtp_header_extensions( - MAKE_VECTOR(kAudioRtpExtension2)); - f2_.set_video_rtp_header_extensions( - MAKE_VECTOR(kVideoRtpExtension2)); + f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); + f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); + f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); + f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); std::unique_ptr offer(f1_.CreateOffer(opts, NULL)); ASSERT_TRUE(offer.get() != NULL); std::unique_ptr answer( f2_.CreateAnswer(offer.get(), opts, NULL)); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncrypted1), - GetFirstAudioContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncrypted1), - GetFirstVideoContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncryptedAnswer), - GetFirstAudioContentDescription( - answer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer), - GetFirstVideoContentDescription( - answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionEncrypted1), + GetFirstAudioContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionEncrypted1), + GetFirstVideoContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionEncryptedAnswer), + GetFirstAudioContentDescription(answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer), + GetFirstVideoContentDescription(answer.get())->rtp_header_extensions()); } TEST_F(MediaSessionDescriptionFactoryTest, - TestOfferAnswerWithEncryptedRtpExtensionsOffer) { + TestOfferAnswerWithEncryptedRtpExtensionsOffer) { MediaSessionOptions opts; AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts); f1_.set_enable_encrypted_rtp_header_extensions(true); - f1_.set_audio_rtp_header_extensions( - MAKE_VECTOR(kAudioRtpExtension1)); - f1_.set_video_rtp_header_extensions( - MAKE_VECTOR(kVideoRtpExtension1)); - f2_.set_audio_rtp_header_extensions( - MAKE_VECTOR(kAudioRtpExtension2)); - f2_.set_video_rtp_header_extensions( - MAKE_VECTOR(kVideoRtpExtension2)); + f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); + f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); + f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); + f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); std::unique_ptr offer(f1_.CreateOffer(opts, NULL)); ASSERT_TRUE(offer.get() != NULL); std::unique_ptr answer( f2_.CreateAnswer(offer.get(), opts, NULL)); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncrypted1), - GetFirstAudioContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncrypted1), - GetFirstVideoContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), - GetFirstAudioContentDescription( - answer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), - GetFirstVideoContentDescription( - answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionEncrypted1), + GetFirstAudioContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionEncrypted1), + GetFirstVideoContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionAnswer), + GetFirstAudioContentDescription(answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionAnswer), + GetFirstVideoContentDescription(answer.get())->rtp_header_extensions()); } TEST_F(MediaSessionDescriptionFactoryTest, - TestOfferAnswerWithEncryptedRtpExtensionsAnswer) { + TestOfferAnswerWithEncryptedRtpExtensionsAnswer) { MediaSessionOptions opts; AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts); f2_.set_enable_encrypted_rtp_header_extensions(true); - f1_.set_audio_rtp_header_extensions( - MAKE_VECTOR(kAudioRtpExtension1)); - f1_.set_video_rtp_header_extensions( - MAKE_VECTOR(kVideoRtpExtension1)); - f2_.set_audio_rtp_header_extensions( - MAKE_VECTOR(kAudioRtpExtension2)); - f2_.set_video_rtp_header_extensions( - MAKE_VECTOR(kVideoRtpExtension2)); + f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); + f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); + f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); + f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); std::unique_ptr offer(f1_.CreateOffer(opts, NULL)); ASSERT_TRUE(offer.get() != NULL); std::unique_ptr answer( f2_.CreateAnswer(offer.get(), opts, NULL)); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), - GetFirstAudioContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), - GetFirstVideoContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), - GetFirstAudioContentDescription( - answer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), - GetFirstVideoContentDescription( - answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtension1), + GetFirstAudioContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtension1), + GetFirstVideoContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionAnswer), + GetFirstAudioContentDescription(answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionAnswer), + GetFirstVideoContentDescription(answer.get())->rtp_header_extensions()); } // Create an audio, video, data answer without legacy StreamParams. @@ -1638,7 +1620,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { const StreamParamsVec& audio_streams = acd->streams(); ASSERT_EQ(2U, audio_streams.size()); - EXPECT_EQ(audio_streams[0].cname , audio_streams[1].cname); + EXPECT_EQ(audio_streams[0].cname, audio_streams[1].cname); EXPECT_EQ(kAudioTrack1, audio_streams[0].id); ASSERT_EQ(1U, audio_streams[0].ssrcs.size()); EXPECT_NE(0U, audio_streams[0].ssrcs[0]); @@ -1667,7 +1649,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { const StreamParamsVec& data_streams = dcd->streams(); ASSERT_EQ(2U, data_streams.size()); - EXPECT_EQ(data_streams[0].cname , data_streams[1].cname); + EXPECT_EQ(data_streams[0].cname, data_streams[1].cname); EXPECT_EQ(kDataTrack1, data_streams[0].id); ASSERT_EQ(1U, data_streams[0].ssrcs.size()); EXPECT_NE(0U, data_streams[0].ssrcs[0]); @@ -1676,8 +1658,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { EXPECT_NE(0U, data_streams[1].ssrcs[0]); EXPECT_EQ(cricket::kDataMaxBandwidth, - dcd->bandwidth()); // default bandwidth (auto) - EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on + dcd->bandwidth()); // default bandwidth (auto) + EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on ASSERT_CRYPTO(dcd, 1U, kDefaultSrtpCryptoSuite); // Update the offer. Add a new video track that is not synched to the @@ -1835,7 +1817,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { const StreamParamsVec& audio_streams = acd->streams(); ASSERT_EQ(2U, audio_streams.size()); - EXPECT_TRUE(audio_streams[0].cname == audio_streams[1].cname); + EXPECT_TRUE(audio_streams[0].cname == audio_streams[1].cname); EXPECT_EQ(kAudioTrack1, audio_streams[0].id); ASSERT_EQ(1U, audio_streams[0].ssrcs.size()); EXPECT_NE(0U, audio_streams[0].ssrcs[0]); @@ -1861,7 +1843,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { const StreamParamsVec& data_streams = dcd->streams(); ASSERT_EQ(2U, data_streams.size()); - EXPECT_TRUE(data_streams[0].cname == data_streams[1].cname); + EXPECT_TRUE(data_streams[0].cname == data_streams[1].cname); EXPECT_EQ(kDataTrack1, data_streams[0].id); ASSERT_EQ(1U, data_streams[0].ssrcs.size()); EXPECT_NE(0U, data_streams[0].ssrcs[0]); @@ -1870,8 +1852,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { EXPECT_NE(0U, data_streams[1].ssrcs[0]); EXPECT_EQ(cricket::kDataMaxBandwidth, - dcd->bandwidth()); // default bandwidth (auto) - EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on + dcd->bandwidth()); // default bandwidth (auto) + EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on // Update the answer. Add a new video track that is not synched to the // other tracks and remove 1 audio track. @@ -1912,7 +1894,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { const StreamParamsVec& updated_audio_streams = updated_acd->streams(); ASSERT_EQ(1U, updated_audio_streams.size()); - EXPECT_TRUE(audio_streams[0] == updated_audio_streams[0]); + EXPECT_TRUE(audio_streams[0] == updated_audio_streams[0]); const StreamParamsVec& updated_video_streams = updated_vcd->streams(); ASSERT_EQ(2U, updated_video_streams.size()); @@ -1955,17 +1937,14 @@ TEST_F(MediaSessionDescriptionFactoryTest, // TODO(wu): |updated_offer| should not include the codec // (i.e. |kAudioCodecs2[0]|) the other side doesn't support. const AudioCodec kUpdatedAudioCodecOffer[] = { - kAudioCodecsAnswer[0], - kAudioCodecsAnswer[1], - kAudioCodecs2[0], + kAudioCodecsAnswer[0], kAudioCodecsAnswer[1], kAudioCodecs2[0], }; // The expected video codecs are the common video codecs from the first // offer/answer exchange plus the video codecs only |f2_| offer, sorted in // preference order. const VideoCodec kUpdatedVideoCodecOffer[] = { - kVideoCodecsAnswer[0], - kVideoCodecs2[1], + kVideoCodecsAnswer[0], kVideoCodecs2[1], }; const AudioContentDescription* updated_acd = @@ -2128,7 +2107,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ASSERT_EQ("H264", updated_vcd->codecs()[0].name); ASSERT_EQ(std::string(cricket::kRtxCodecName), updated_vcd->codecs()[1].name); - int new_h264_pl_type = updated_vcd->codecs()[0].id; + int new_h264_pl_type = updated_vcd->codecs()[0].id; EXPECT_NE(used_pl_type, new_h264_pl_type); VideoCodec rtx = updated_vcd->codecs()[1]; int pt_referenced_by_rtx = rtc::FromString( @@ -2460,12 +2439,12 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr answer( f2_.CreateAnswer(offer.get(), opts, NULL)); - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), - GetFirstAudioContentDescription( - answer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), - GetFirstVideoContentDescription( - answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtensionAnswer), + GetFirstAudioContentDescription(answer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kVideoRtpExtensionAnswer), + GetFirstVideoContentDescription(answer.get())->rtp_header_extensions()); std::unique_ptr updated_offer( f2_.CreateOffer(opts, answer.get())); @@ -2516,23 +2495,23 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { kVideoRtpExtension3[0], kAudioRtpExtension3[1], }; - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), - GetFirstAudioContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), - GetFirstVideoContentDescription( - offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtension3), + GetFirstAudioContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kExpectedVideoRtpExtension), + GetFirstVideoContentDescription(offer.get())->rtp_header_extensions()); // Nothing should change when creating a new offer std::unique_ptr updated_offer( f1_.CreateOffer(opts, offer.get())); EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), - GetFirstAudioContentDescription( - updated_offer.get())->rtp_header_extensions()); + GetFirstAudioContentDescription(updated_offer.get()) + ->rtp_header_extensions()); EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), - GetFirstVideoContentDescription( - updated_offer.get())->rtp_header_extensions()); + GetFirstVideoContentDescription(updated_offer.get()) + ->rtp_header_extensions()); } // Same as "RtpExtensionIdReused" above for encrypted RTP extensions. @@ -2558,23 +2537,23 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) { kAudioRtpExtension3ForEncryptionOffer[2], }; - EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer), - GetFirstAudioContentDescription( - offer.get())->rtp_header_extensions()); - EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), - GetFirstVideoContentDescription( - offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer), + GetFirstAudioContentDescription(offer.get())->rtp_header_extensions()); + EXPECT_EQ( + MAKE_VECTOR(kExpectedVideoRtpExtension), + GetFirstVideoContentDescription(offer.get())->rtp_header_extensions()); // Nothing should change when creating a new offer std::unique_ptr updated_offer( f1_.CreateOffer(opts, offer.get())); EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer), - GetFirstAudioContentDescription( - updated_offer.get())->rtp_header_extensions()); + GetFirstAudioContentDescription(updated_offer.get()) + ->rtp_header_extensions()); EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), - GetFirstVideoContentDescription( - updated_offer.get())->rtp_header_extensions()); + GetFirstVideoContentDescription(updated_offer.get()) + ->rtp_header_extensions()); } TEST(MediaSessionDescription, CopySessionDescription) { @@ -2643,7 +2622,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) { } TEST_F(MediaSessionDescriptionFactoryTest, - TestTransportInfoOfferMultimediaCurrent) { + TestTransportInfoOfferMultimediaCurrent) { MediaSessionOptions options; AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &options); AddDataSection(cricket::DCT_RTP, RtpTransceiverDirection::kRecvOnly, @@ -2704,7 +2683,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) { } TEST_F(MediaSessionDescriptionFactoryTest, - TestTransportInfoAnswerMultimediaCurrent) { + TestTransportInfoAnswerMultimediaCurrent) { MediaSessionOptions options; AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &options); AddDataSection(cricket::DCT_RTP, RtpTransceiverDirection::kRecvOnly, @@ -2722,7 +2701,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerBundle) { } TEST_F(MediaSessionDescriptionFactoryTest, - TestTransportInfoAnswerBundleCurrent) { + TestTransportInfoAnswerBundleCurrent) { MediaSessionOptions options; AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &options); AddDataSection(cricket::DCT_RTP, RtpTransceiverDirection::kRecvOnly, @@ -2798,7 +2777,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { const AudioContentDescription* answer_audio_desc = answer_content->media_description()->as_audio(); EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), - answer_audio_desc->protocol()); + answer_audio_desc->protocol()); } // Test that we include both SDES and DTLS in the offer, but only include SDES diff --git a/pc/mediastream.cc b/pc/mediastream.cc index db410d4f4a..d5924095cd 100644 --- a/pc/mediastream.cc +++ b/pc/mediastream.cc @@ -16,8 +16,7 @@ namespace webrtc { template -static typename V::iterator FindTrack(V* vector, - const std::string& track_id) { +static typename V::iterator FindTrack(V* vector, const std::string& track_id) { typename V::iterator it = vector->begin(); for (; it != vector->end(); ++it) { if ((*it)->id() == track_id) { @@ -27,16 +26,13 @@ static typename V::iterator FindTrack(V* vector, return it; } -rtc::scoped_refptr MediaStream::Create( - const std::string& id) { +rtc::scoped_refptr MediaStream::Create(const std::string& id) { rtc::RefCountedObject* stream = new rtc::RefCountedObject(id); return stream; } -MediaStream::MediaStream(const std::string& id) - : id_(id) { -} +MediaStream::MediaStream(const std::string& id) : id_(id) {} bool MediaStream::AddTrack(AudioTrackInterface* track) { return AddTrack(&audio_tracks_, track); @@ -54,16 +50,16 @@ bool MediaStream::RemoveTrack(VideoTrackInterface* track) { return RemoveTrack(&video_tracks_, track); } -rtc::scoped_refptr -MediaStream::FindAudioTrack(const std::string& track_id) { +rtc::scoped_refptr MediaStream::FindAudioTrack( + const std::string& track_id) { AudioTrackVector::iterator it = FindTrack(&audio_tracks_, track_id); if (it == audio_tracks_.end()) return NULL; return *it; } -rtc::scoped_refptr -MediaStream::FindVideoTrack(const std::string& track_id) { +rtc::scoped_refptr MediaStream::FindVideoTrack( + const std::string& track_id) { VideoTrackVector::iterator it = FindTrack(&video_tracks_, track_id); if (it == video_tracks_.end()) return NULL; diff --git a/pc/mediastream.h b/pc/mediastream.h index ab70e778a3..63b35108b6 100644 --- a/pc/mediastream.h +++ b/pc/mediastream.h @@ -31,10 +31,10 @@ class MediaStream : public Notifier { bool AddTrack(VideoTrackInterface* track) override; bool RemoveTrack(AudioTrackInterface* track) override; bool RemoveTrack(VideoTrackInterface* track) override; - rtc::scoped_refptr - FindAudioTrack(const std::string& track_id) override; - rtc::scoped_refptr - FindVideoTrack(const std::string& track_id) override; + rtc::scoped_refptr FindAudioTrack( + const std::string& track_id) override; + rtc::scoped_refptr FindVideoTrack( + const std::string& track_id) override; AudioTrackVector GetAudioTracks() override { return audio_tracks_; } VideoTrackVector GetVideoTracks() override { return video_tracks_; } diff --git a/pc/mediastream_unittest.cc b/pc/mediastream_unittest.cc index d2e0c95cc1..b81e55c824 100644 --- a/pc/mediastream_unittest.cc +++ b/pc/mediastream_unittest.cc @@ -50,7 +50,7 @@ class MockObserver : public ObserverInterface { NotifierInterface* notifier_; }; -class MediaStreamTest: public testing::Test { +class MediaStreamTest : public testing::Test { protected: virtual void SetUp() { stream_ = MediaStream::Create(kStreamId1); @@ -75,8 +75,7 @@ class MediaStreamTest: public testing::Test { void ChangeTrack(MediaStreamTrackInterface* track) { MockObserver observer(track); - EXPECT_CALL(observer, OnChanged()) - .Times(Exactly(1)); + EXPECT_CALL(observer, OnChanged()).Times(Exactly(1)); track->set_enabled(false); EXPECT_FALSE(track->enabled()); } @@ -98,8 +97,8 @@ TEST_F(MediaStreamTest, GetTrackInfo) { ASSERT_EQ(1u, stream_->GetVideoTracks().size()); EXPECT_TRUE(stream_->GetVideoTracks()[0].get() == video_track.get()); - EXPECT_TRUE(stream_->FindVideoTrack(video_track->id()).get() - == video_track.get()); + EXPECT_TRUE(stream_->FindVideoTrack(video_track->id()).get() == + video_track.get()); video_track = stream_->GetVideoTracks()[0]; EXPECT_EQ(0, video_track->id().compare(kVideoTrackId)); EXPECT_TRUE(video_track->enabled()); @@ -111,8 +110,8 @@ TEST_F(MediaStreamTest, GetTrackInfo) { EXPECT_TRUE(audio_track->enabled()); ASSERT_EQ(1u, stream_->GetAudioTracks().size()); EXPECT_TRUE(stream_->GetAudioTracks()[0].get() == audio_track.get()); - EXPECT_TRUE(stream_->FindAudioTrack(audio_track->id()).get() - == audio_track.get()); + EXPECT_TRUE(stream_->FindAudioTrack(audio_track->id()).get() == + audio_track.get()); audio_track = stream_->GetAudioTracks()[0]; EXPECT_EQ(0, audio_track->id().compare(kAudioTrackId)); EXPECT_TRUE(audio_track->enabled()); @@ -121,8 +120,7 @@ TEST_F(MediaStreamTest, GetTrackInfo) { TEST_F(MediaStreamTest, RemoveTrack) { MockObserver observer(stream_); - EXPECT_CALL(observer, OnChanged()) - .Times(Exactly(2)); + EXPECT_CALL(observer, OnChanged()).Times(Exactly(2)); EXPECT_TRUE(stream_->RemoveTrack(audio_track_)); EXPECT_FALSE(stream_->RemoveTrack(audio_track_)); diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index 0e0e9a6210..41e4368b67 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -111,8 +111,7 @@ enum { struct SetSessionDescriptionMsg : public rtc::MessageData { explicit SetSessionDescriptionMsg( webrtc::SetSessionDescriptionObserver* observer) - : observer(observer) { - } + : observer(observer) {} rtc::scoped_refptr observer; RTCError error; @@ -130,8 +129,7 @@ struct CreateSessionDescriptionMsg : public rtc::MessageData { struct GetStatsMsg : public rtc::MessageData { GetStatsMsg(webrtc::StatsObserver* observer, webrtc::MediaStreamTrackInterface* track) - : observer(observer), track(track) { - } + : observer(observer), track(track) {} rtc::scoped_refptr observer; rtc::scoped_refptr track; }; @@ -1055,16 +1053,14 @@ RTCError PeerConnection::ValidateConfiguration( return result; } -rtc::scoped_refptr -PeerConnection::local_streams() { +rtc::scoped_refptr PeerConnection::local_streams() { RTC_CHECK(!IsUnifiedPlan()) << "local_streams is not available with Unified " "Plan SdpSemantics. Please use GetSenders " "instead."; return local_streams_; } -rtc::scoped_refptr -PeerConnection::remote_streams() { +rtc::scoped_refptr PeerConnection::remote_streams() { RTC_CHECK(!IsUnifiedPlan()) << "remote_streams is not available with Unified " "Plan SdpSemantics. Please use GetReceivers " "instead."; @@ -1695,8 +1691,7 @@ PeerConnection::ice_gathering_state() { return ice_gathering_state_; } -rtc::scoped_refptr -PeerConnection::CreateDataChannel( +rtc::scoped_refptr PeerConnection::CreateDataChannel( const std::string& label, const DataChannelInit* config) { TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); @@ -3076,7 +3071,7 @@ void PeerConnection::SetMetricObserver_n(UMAObserver* observer) { RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) { if (!worker_thread()->IsCurrent()) { return worker_thread()->Invoke( - RTC_FROM_HERE, [&](){ return SetBitrate(bitrate); }); + RTC_FROM_HERE, [&]() { return SetBitrate(bitrate); }); } const bool has_min = bitrate.min_bitrate_bps.has_value(); @@ -3096,8 +3091,7 @@ RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) { } } if (has_max) { - if (has_start && - *bitrate.max_bitrate_bps < *bitrate.start_bitrate_bps) { + if (has_start && *bitrate.max_bitrate_bps < *bitrate.start_bitrate_bps) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "max_bitrate_bps < start_bitrate_bps"); } else if (has_min && *bitrate.max_bitrate_bps < *bitrate.min_bitrate_bps) { @@ -3279,9 +3273,8 @@ void PeerConnection::Close() { transport_controller_.reset(); network_thread()->Invoke( - RTC_FROM_HERE, - rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, - port_allocator_.get())); + RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, + port_allocator_.get())); worker_thread()->Invoke(RTC_FROM_HERE, [this] { call_.reset(); @@ -4897,10 +4890,9 @@ RTCError PeerConnection::PushdownMediaDescription( continue; } std::string error; - bool success = - (source == cricket::CS_LOCAL) - ? channel->SetLocalContent(content_desc, type, &error) - : channel->SetRemoteContent(content_desc, type, &error); + bool success = (source == cricket::CS_LOCAL) + ? channel->SetLocalContent(content_desc, type, &error) + : channel->SetRemoteContent(content_desc, type, &error); if (!success) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, std::move(error)); } @@ -4918,8 +4910,7 @@ RTCError PeerConnection::PushdownMediaDescription( bool success = (source == cricket::CS_LOCAL) ? rtp_data_channel_->SetLocalContent(data_desc, type, &error) - : rtp_data_channel_->SetRemoteContent(data_desc, type, - &error); + : rtp_data_channel_->SetRemoteContent(data_desc, type, &error); if (!success) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, std::move(error)); diff --git a/pc/peerconnection_ice_unittest.cc b/pc/peerconnection_ice_unittest.cc index 3c1782c898..5cf6965a99 100644 --- a/pc/peerconnection_ice_unittest.cc +++ b/pc/peerconnection_ice_unittest.cc @@ -542,23 +542,23 @@ TEST_P(PeerConnectionIceTest, // The standard (https://tools.ietf.org/html/rfc5245#section-15.4) says that // pwd must be 22-256 characters and ufrag must be 4-256 characters. TEST_P(PeerConnectionIceTest, VerifyUfragPwdLength) { - auto set_local_description_with_ufrag_pwd_length = - [this](int ufrag_len, int pwd_len) { - auto pc = CreatePeerConnectionWithAudioVideo(); - auto offer = pc->CreateOffer(); - SetIceUfragPwd(offer.get(), std::string(ufrag_len, 'x'), - std::string(pwd_len, 'x')); - return pc->SetLocalDescription(std::move(offer)); - }; + auto set_local_description_with_ufrag_pwd_length = [this](int ufrag_len, + int pwd_len) { + auto pc = CreatePeerConnectionWithAudioVideo(); + auto offer = pc->CreateOffer(); + SetIceUfragPwd(offer.get(), std::string(ufrag_len, 'x'), + std::string(pwd_len, 'x')); + return pc->SetLocalDescription(std::move(offer)); + }; - auto set_remote_description_with_ufrag_pwd_length = - [this](int ufrag_len, int pwd_len) { - auto pc = CreatePeerConnectionWithAudioVideo(); - auto offer = pc->CreateOffer(); - SetIceUfragPwd(offer.get(), std::string(ufrag_len, 'x'), - std::string(pwd_len, 'x')); - return pc->SetRemoteDescription(std::move(offer)); - }; + auto set_remote_description_with_ufrag_pwd_length = [this](int ufrag_len, + int pwd_len) { + auto pc = CreatePeerConnectionWithAudioVideo(); + auto offer = pc->CreateOffer(); + SetIceUfragPwd(offer.get(), std::string(ufrag_len, 'x'), + std::string(pwd_len, 'x')); + return pc->SetRemoteDescription(std::move(offer)); + }; EXPECT_FALSE(set_local_description_with_ufrag_pwd_length(3, 22)); EXPECT_FALSE(set_remote_description_with_ufrag_pwd_length(3, 22)); diff --git a/pc/peerconnection_rtp_unittest.cc b/pc/peerconnection_rtp_unittest.cc index 2123eec36c..d3ae2cbaf5 100644 --- a/pc/peerconnection_rtp_unittest.cc +++ b/pc/peerconnection_rtp_unittest.cc @@ -1109,8 +1109,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackErrorIfClosed) { caller->pc()->Close(); caller->observer()->clear_negotiation_needed(); - auto result = caller->pc() - ->AddTrack(audio_track, std::vector()); + auto result = caller->pc()->AddTrack(audio_track, std::vector()); EXPECT_EQ(RTCErrorType::INVALID_STATE, result.error().type()); EXPECT_FALSE(caller->observer()->negotiation_needed()); } @@ -1122,8 +1121,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackErrorIfTrackAlreadyHasSender) { ASSERT_TRUE(caller->AddTrack(audio_track)); caller->observer()->clear_negotiation_needed(); - auto result = caller->pc() - ->AddTrack(audio_track, std::vector()); + auto result = caller->pc()->AddTrack(audio_track, std::vector()); EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); EXPECT_FALSE(caller->observer()->negotiation_needed()); } diff --git a/pc/peerconnectionendtoend_unittest.cc b/pc/peerconnectionendtoend_unittest.cc index 727fa2cf12..dae5a2e6ec 100644 --- a/pc/peerconnectionendtoend_unittest.cc +++ b/pc/peerconnectionendtoend_unittest.cc @@ -54,8 +54,7 @@ const int kMaxWait = 10000; class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>, public testing::Test { public: - typedef std::vector > - DataChannelList; + typedef std::vector> DataChannelList; explicit PeerConnectionEndToEndBaseTest(SdpSemantics sdp_semantics) { network_thread_ = rtc::Thread::CreateWithSocketServer(); @@ -114,15 +113,11 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>, const cricket::AudioOptions& audio_options, bool video, const FakeConstraints& video_constraints) { - caller_->GetAndAddUserMedia(audio, audio_options, - video, video_constraints); - callee_->GetAndAddUserMedia(audio, audio_options, - video, video_constraints); + caller_->GetAndAddUserMedia(audio, audio_options, video, video_constraints); + callee_->GetAndAddUserMedia(audio, audio_options, video, video_constraints); } - void Negotiate() { - caller_->CreateOffer(NULL); - } + void Negotiate() { caller_->CreateOffer(NULL); } void WaitForCallEstablished() { caller_->WaitForCallEstablished(); @@ -143,8 +138,8 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>, } // Tests that |dc1| and |dc2| can send to and receive from each other. - void TestDataChannelSendAndReceive( - DataChannelInterface* dc1, DataChannelInterface* dc2) { + void TestDataChannelSendAndReceive(DataChannelInterface* dc1, + DataChannelInterface* dc2) { std::unique_ptr dc1_observer( new webrtc::MockDataChannelObserver(dc1)); @@ -170,8 +165,7 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>, ASSERT_TRUE_WAIT(remote_dc_list.size() > remote_dc_index, kMaxWait); EXPECT_EQ_WAIT(DataChannelInterface::kOpen, - remote_dc_list[remote_dc_index]->state(), - kMaxWait); + remote_dc_list[remote_dc_index]->state(), kMaxWait); EXPECT_EQ(local_dc->id(), remote_dc_list[remote_dc_index]->id()); } @@ -181,8 +175,7 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>, local_dc->Close(); EXPECT_EQ_WAIT(DataChannelInterface::kClosed, local_dc->state(), kMaxWait); EXPECT_EQ_WAIT(DataChannelInterface::kClosed, - remote_dc_list[remote_dc_index]->state(), - kMaxWait); + remote_dc_list[remote_dc_index]->state(), kMaxWait); } protected: diff --git a/pc/peerconnectionfactory.cc b/pc/peerconnectionfactory.cc index 78a46b83db..10688a3e31 100644 --- a/pc/peerconnectionfactory.cc +++ b/pc/peerconnectionfactory.cc @@ -361,9 +361,9 @@ rtc::scoped_refptr PeerConnectionFactory::CreateVideoTrack( return VideoTrackProxy::Create(signaling_thread_, worker_thread_, track); } -rtc::scoped_refptr -PeerConnectionFactory::CreateAudioTrack(const std::string& id, - AudioSourceInterface* source) { +rtc::scoped_refptr PeerConnectionFactory::CreateAudioTrack( + const std::string& id, + AudioSourceInterface* source) { RTC_DCHECK(signaling_thread_->IsCurrent()); rtc::scoped_refptr track(AudioTrack::Create(id, source)); return AudioTrackProxy::Create(signaling_thread_, track); diff --git a/pc/peerconnectionfactory.h b/pc/peerconnectionfactory.h index 67f726a0f7..d1893a99b1 100644 --- a/pc/peerconnectionfactory.h +++ b/pc/peerconnectionfactory.h @@ -26,7 +26,7 @@ namespace rtc { class BasicNetworkManager; class BasicPacketSocketFactory; -} +} // namespace rtc namespace webrtc { @@ -82,9 +82,9 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { const std::string& id, VideoTrackSourceInterface* video_source) override; - rtc::scoped_refptr - CreateAudioTrack(const std::string& id, - AudioSourceInterface* audio_source) override; + rtc::scoped_refptr CreateAudioTrack( + const std::string& id, + AudioSourceInterface* audio_source) override; bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; void StopAecDump() override; diff --git a/pc/peerconnectionfactory_unittest.cc b/pc/peerconnectionfactory_unittest.cc index 66036b1873..9b1854e5ac 100644 --- a/pc/peerconnectionfactory_unittest.cc +++ b/pc/peerconnectionfactory_unittest.cc @@ -45,14 +45,12 @@ static const char kStunIceServer[] = "stun:stun.l.google.com:19302"; static const char kTurnIceServer[] = "turn:test%40hello.com@test.com:1234"; static const char kTurnIceServerWithTransport[] = "turn:test@hello.com?transport=tcp"; -static const char kSecureTurnIceServer[] = - "turns:test@hello.com?transport=tcp"; +static const char kSecureTurnIceServer[] = "turns:test@hello.com?transport=tcp"; static const char kSecureTurnIceServerWithoutTransportParam[] = "turns:test_no_transport@hello.com:443"; static const char kSecureTurnIceServerWithoutTransportAndPortParam[] = "turns:test_no_transport@hello.com"; -static const char kTurnIceServerWithNoUsernameInUri[] = - "turn:test.com:1234"; +static const char kTurnIceServerWithNoUsernameInUri[] = "turn:test.com:1234"; static const char kTurnPassword[] = "turnpassword"; static const int kDefaultStunPort = 3478; static const int kDefaultStunTlsPort = 5349; @@ -80,8 +78,8 @@ class NullPeerConnectionObserver : public PeerConnectionObserver { PeerConnectionInterface::IceConnectionState new_state) override {} void OnIceGatheringChange( PeerConnectionInterface::IceGatheringState new_state) override {} - void OnIceCandidate( - const webrtc::IceCandidateInterface* candidate) override {} + void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { + } }; } // namespace diff --git a/pc/peerconnectioninterface_unittest.cc b/pc/peerconnectioninterface_unittest.cc index ef3f317de4..5248d51428 100644 --- a/pc/peerconnectioninterface_unittest.cc +++ b/pc/peerconnectioninterface_unittest.cc @@ -485,7 +485,7 @@ void SetSsrcToZero(std::string* sdp) { const char kSdpSsrcAtributeZero[] = "a=ssrc:0"; size_t ssrc_pos = 0; while ((ssrc_pos = sdp->find(kSdpSsrcAtribute, ssrc_pos)) != - std::string::npos) { + std::string::npos) { size_t end_ssrc = sdp->find(" ", ssrc_pos); sdp->replace(ssrc_pos, end_ssrc - ssrc_pos, kSdpSsrcAtributeZero); ssrc_pos = end_ssrc; @@ -756,8 +756,8 @@ class PeerConnectionInterfaceBaseTest : public testing::Test { bool dtls; if (FindConstraint(constraints, webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, - &dtls, - nullptr) && dtls) { + &dtls, nullptr) && + dtls) { fake_certificate_generator_ = new FakeRTCCertificateGenerator(); cert_generator.reset(fake_certificate_generator_); } @@ -897,9 +897,8 @@ class PeerConnectionInterfaceBaseTest : public testing::Test { bool DoCreateOfferAnswer(std::unique_ptr* desc, bool offer, MediaConstraintsInterface* constraints) { - rtc::scoped_refptr - observer(new rtc::RefCountedObject< - MockCreateSessionDescriptionObserver>()); + rtc::scoped_refptr observer( + new rtc::RefCountedObject()); if (offer) { pc_->CreateOffer(observer, constraints); } else { @@ -923,9 +922,8 @@ class PeerConnectionInterfaceBaseTest : public testing::Test { bool DoSetSessionDescription( std::unique_ptr desc, bool local) { - rtc::scoped_refptr - observer(new rtc::RefCountedObject< - MockSetSessionDescriptionObserver>()); + rtc::scoped_refptr observer( + new rtc::RefCountedObject()); if (local) { pc_->SetLocalDescription(observer, desc.release()); } else { @@ -953,8 +951,8 @@ class PeerConnectionInterfaceBaseTest : public testing::Test { bool DoGetStats(MediaStreamTrackInterface* track) { rtc::scoped_refptr observer( new rtc::RefCountedObject()); - if (!pc_->GetStats( - observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)) + if (!pc_->GetStats(observer, track, + PeerConnectionInterface::kStatsOutputLevelStandard)) return false; EXPECT_TRUE_WAIT(observer->called(), kTimeout); return observer->called(); @@ -1797,10 +1795,10 @@ TEST_P(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); int audio_ssrc = 0; int video_ssrc = 0; - EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), - &audio_ssrc)); - EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()), - &video_ssrc)); + EXPECT_TRUE( + GetFirstSsrc(GetFirstAudioContent(offer->description()), &audio_ssrc)); + EXPECT_TRUE( + GetFirstSsrc(GetFirstVideoContent(offer->description()), &video_ssrc)); EXPECT_NE(audio_ssrc, video_ssrc); // Test CreateAnswer @@ -1809,10 +1807,10 @@ TEST_P(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); audio_ssrc = 0; video_ssrc = 0; - EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()), - &audio_ssrc)); - EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), - &video_ssrc)); + EXPECT_TRUE( + GetFirstSsrc(GetFirstAudioContent(answer->description()), &audio_ssrc)); + EXPECT_TRUE( + GetFirstSsrc(GetFirstVideoContent(answer->description()), &video_ssrc)); EXPECT_NE(audio_ssrc, video_ssrc); } @@ -2058,8 +2056,7 @@ TEST_P(PeerConnectionInterfaceTest, TestReceiveOnlyDataChannel) { std::string sdp; EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); rtc::replace_substrs(offer_label.c_str(), offer_label.length(), - receive_label.c_str(), receive_label.length(), - &sdp); + receive_label.c_str(), receive_label.length(), &sdp); CreateAnswerAsRemoteDescription(sdp); // Verify that a new incoming data channel has been created and that diff --git a/pc/proxy_unittest.cc b/pc/proxy_unittest.cc index 81f040adf6..072e606e30 100644 --- a/pc/proxy_unittest.cc +++ b/pc/proxy_unittest.cc @@ -64,26 +64,26 @@ class Fake : public FakeInterface { // Proxies for the test interface. BEGIN_PROXY_MAP(Fake) - PROXY_WORKER_THREAD_DESTRUCTOR() - PROXY_METHOD0(void, VoidMethod0) - PROXY_METHOD0(std::string, Method0) - PROXY_CONSTMETHOD0(std::string, ConstMethod0) - PROXY_WORKER_METHOD1(std::string, Method1, std::string) - PROXY_CONSTMETHOD1(std::string, ConstMethod1, std::string) - PROXY_WORKER_METHOD2(std::string, Method2, std::string, std::string) +PROXY_WORKER_THREAD_DESTRUCTOR() +PROXY_METHOD0(void, VoidMethod0) +PROXY_METHOD0(std::string, Method0) +PROXY_CONSTMETHOD0(std::string, ConstMethod0) +PROXY_WORKER_METHOD1(std::string, Method1, std::string) +PROXY_CONSTMETHOD1(std::string, ConstMethod1, std::string) +PROXY_WORKER_METHOD2(std::string, Method2, std::string, std::string) END_PROXY_MAP() // Preprocessor hack to get a proxy class a name different than FakeProxy. #define FakeProxy FakeSignalingProxy #define FakeProxyWithInternal FakeSignalingProxyWithInternal BEGIN_SIGNALING_PROXY_MAP(Fake) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD0(void, VoidMethod0) - PROXY_METHOD0(std::string, Method0) - PROXY_CONSTMETHOD0(std::string, ConstMethod0) - PROXY_METHOD1(std::string, Method1, std::string) - PROXY_CONSTMETHOD1(std::string, ConstMethod1, std::string) - PROXY_METHOD2(std::string, Method2, std::string, std::string) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_METHOD0(void, VoidMethod0) +PROXY_METHOD0(std::string, Method0) +PROXY_CONSTMETHOD0(std::string, ConstMethod0) +PROXY_METHOD1(std::string, Method1, std::string) +PROXY_CONSTMETHOD1(std::string, ConstMethod1, std::string) +PROXY_METHOD2(std::string, Method2, std::string, std::string) END_PROXY_MAP() #undef FakeProxy @@ -215,21 +215,17 @@ TEST_F(ProxyTest, VoidMethod0) { TEST_F(ProxyTest, Method0) { EXPECT_CALL(*fake_, Method0()) .Times(Exactly(1)) - .WillOnce( - DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread), - Return("Method0"))); - EXPECT_EQ("Method0", - fake_proxy_->Method0()); + .WillOnce(DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread), + Return("Method0"))); + EXPECT_EQ("Method0", fake_proxy_->Method0()); } TEST_F(ProxyTest, ConstMethod0) { EXPECT_CALL(*fake_, ConstMethod0()) .Times(Exactly(1)) - .WillOnce( - DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread), - Return("ConstMethod0"))); - EXPECT_EQ("ConstMethod0", - fake_proxy_->ConstMethod0()); + .WillOnce(DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread), + Return("ConstMethod0"))); + EXPECT_EQ("ConstMethod0", fake_proxy_->ConstMethod0()); } TEST_F(ProxyTest, WorkerMethod1) { @@ -245,9 +241,8 @@ TEST_F(ProxyTest, ConstMethod1) { const std::string arg1 = "arg1"; EXPECT_CALL(*fake_, ConstMethod1(arg1)) .Times(Exactly(1)) - .WillOnce( - DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread), - Return("ConstMethod1"))); + .WillOnce(DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread), + Return("ConstMethod1"))); EXPECT_EQ("ConstMethod1", fake_proxy_->ConstMethod1(arg1)); } @@ -275,8 +270,8 @@ class Foo : public FooInterface { }; BEGIN_OWNED_PROXY_MAP(Foo) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD0(void, Bar) +PROXY_SIGNALING_THREAD_DESTRUCTOR() +PROXY_METHOD0(void, Bar) END_PROXY_MAP() class OwnedProxyTest : public testing::Test { diff --git a/pc/rtcpmuxfilter.cc b/pc/rtcpmuxfilter.cc index 331c8df45c..dceaf465f4 100644 --- a/pc/rtcpmuxfilter.cc +++ b/pc/rtcpmuxfilter.cc @@ -14,8 +14,7 @@ namespace cricket { -RtcpMuxFilter::RtcpMuxFilter() : state_(ST_INIT), offer_enable_(false) { -} +RtcpMuxFilter::RtcpMuxFilter() : state_(ST_INIT), offer_enable_(false) {} bool RtcpMuxFilter::IsFullyActive() const { return state_ == ST_ACTIVE; diff --git a/pc/rtcstats_integrationtest.cc b/pc/rtcstats_integrationtest.cc index 8f7f978278..f0c1831c26 100644 --- a/pc/rtcstats_integrationtest.cc +++ b/pc/rtcstats_integrationtest.cc @@ -118,10 +118,10 @@ class RTCStatsIntegrationTest : public testing::Test { PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); // Get user media for audio and video - caller_->GetAndAddUserMedia(true, cricket::AudioOptions(), - true, FakeConstraints()); - callee_->GetAndAddUserMedia(true, cricket::AudioOptions(), - true, FakeConstraints()); + caller_->GetAndAddUserMedia(true, cricket::AudioOptions(), true, + FakeConstraints()); + callee_->GetAndAddUserMedia(true, cricket::AudioOptions(), true, + FakeConstraints()); // Create data channels DataChannelInit init; @@ -199,67 +199,65 @@ class RTCStatsVerifier { } } - void MarkMemberTested( - const RTCStatsMemberInterface& member, bool test_successful) { + void MarkMemberTested(const RTCStatsMemberInterface& member, + bool test_successful) { untested_members_.erase(&member); all_tests_successful_ &= test_successful; } void TestMemberIsDefined(const RTCStatsMemberInterface& member) { - EXPECT_TRUE(member.is_defined()) << - stats_->type() << "." << member.name() << "[" << stats_->id() << - "] was undefined."; + EXPECT_TRUE(member.is_defined()) + << stats_->type() << "." << member.name() << "[" << stats_->id() + << "] was undefined."; MarkMemberTested(member, member.is_defined()); } void TestMemberIsUndefined(const RTCStatsMemberInterface& member) { - EXPECT_FALSE(member.is_defined()) << - stats_->type() << "." << member.name() << "[" << stats_->id() << - "] was defined (" << member.ValueToString() << ")."; + EXPECT_FALSE(member.is_defined()) + << stats_->type() << "." << member.name() << "[" << stats_->id() + << "] was defined (" << member.ValueToString() << ")."; MarkMemberTested(member, !member.is_defined()); } - template + template void TestMemberIsPositive(const RTCStatsMemberInterface& member) { - EXPECT_TRUE(member.is_defined()) << - stats_->type() << "." << member.name() << "[" << stats_->id() << - "] was undefined."; + EXPECT_TRUE(member.is_defined()) + << stats_->type() << "." << member.name() << "[" << stats_->id() + << "] was undefined."; if (!member.is_defined()) { MarkMemberTested(member, false); return; } bool is_positive = *member.cast_to>() > T(0); - EXPECT_TRUE(is_positive) << - stats_->type() << "." << member.name() << "[" << stats_->id() << - "] was not positive (" << member.ValueToString() << ")."; + EXPECT_TRUE(is_positive) + << stats_->type() << "." << member.name() << "[" << stats_->id() + << "] was not positive (" << member.ValueToString() << ")."; MarkMemberTested(member, is_positive); } - template + template void TestMemberIsNonNegative(const RTCStatsMemberInterface& member) { - EXPECT_TRUE(member.is_defined()) << - stats_->type() << "." << member.name() << "[" << stats_->id() << - "] was undefined."; + EXPECT_TRUE(member.is_defined()) + << stats_->type() << "." << member.name() << "[" << stats_->id() + << "] was undefined."; if (!member.is_defined()) { MarkMemberTested(member, false); return; } bool is_non_negative = *member.cast_to>() >= T(0); - EXPECT_TRUE(is_non_negative) << - stats_->type() << "." << member.name() << "[" << stats_->id() << - "] was not non-negative (" << member.ValueToString() << ")."; + EXPECT_TRUE(is_non_negative) + << stats_->type() << "." << member.name() << "[" << stats_->id() + << "] was not non-negative (" << member.ValueToString() << ")."; MarkMemberTested(member, is_non_negative); } - void TestMemberIsIDReference( - const RTCStatsMemberInterface& member, - const char* expected_type) { + void TestMemberIsIDReference(const RTCStatsMemberInterface& member, + const char* expected_type) { TestMemberIsIDReference(member, expected_type, false); } - void TestMemberIsOptionalIDReference( - const RTCStatsMemberInterface& member, - const char* expected_type) { + void TestMemberIsOptionalIDReference(const RTCStatsMemberInterface& member, + const char* expected_type) { TestMemberIsIDReference(member, expected_type, true); } @@ -267,18 +265,16 @@ class RTCStatsVerifier { if (untested_members_.empty()) return all_tests_successful_; for (const RTCStatsMemberInterface* member : untested_members_) { - EXPECT_TRUE(false) << - stats_->type() << "." << member->name() << "[" << stats_->id() << - "] was not tested."; + EXPECT_TRUE(false) << stats_->type() << "." << member->name() << "[" + << stats_->id() << "] was not tested."; } return false; } private: - void TestMemberIsIDReference( - const RTCStatsMemberInterface& member, - const char* expected_type, - bool optional) { + void TestMemberIsIDReference(const RTCStatsMemberInterface& member, + const char* expected_type, + bool optional) { if (optional && !member.is_defined()) { MarkMemberTested(member, true); return; @@ -306,10 +302,11 @@ class RTCStatsVerifier { } } } - EXPECT_TRUE(valid_reference) << - stats_->type() << "." << member.name() << " is not a reference to an " << - "existing dictionary of type " << expected_type << " (" << - member.ValueToString() << ")."; + EXPECT_TRUE(valid_reference) + << stats_->type() << "." << member.name() + << " is not a reference to an " + << "existing dictionary of type " << expected_type << " (" + << member.ValueToString() << ")."; MarkMemberTested(member, valid_reference); } @@ -339,8 +336,7 @@ class RTCStatsReportVerifier { } explicit RTCStatsReportVerifier(const RTCStatsReport* report) - : report_(report) { - } + : report_(report) {} void VerifyReport(std::vector allowed_missing_stats) { std::set missing_stats = StatsTypes(); @@ -353,14 +349,14 @@ class RTCStatsReportVerifier { for (const RTCStats& stats : *report_) { missing_stats.erase(stats.type()); if (stats.type() == RTCCertificateStats::kType) { - verify_successful &= VerifyRTCCertificateStats( - stats.cast_to()); + verify_successful &= + VerifyRTCCertificateStats(stats.cast_to()); } else if (stats.type() == RTCCodecStats::kType) { - verify_successful &= VerifyRTCCodecStats( - stats.cast_to()); + verify_successful &= + VerifyRTCCodecStats(stats.cast_to()); } else if (stats.type() == RTCDataChannelStats::kType) { - verify_successful &= VerifyRTCDataChannelStats( - stats.cast_to()); + verify_successful &= + VerifyRTCDataChannelStats(stats.cast_to()); } else if (stats.type() == RTCIceCandidatePairStats::kType) { verify_successful &= VerifyRTCIceCandidatePairStats( stats.cast_to(), @@ -372,8 +368,8 @@ class RTCStatsReportVerifier { verify_successful &= VerifyRTCRemoteIceCandidateStats( stats.cast_to()); } else if (stats.type() == RTCMediaStreamStats::kType) { - verify_successful &= VerifyRTCMediaStreamStats( - stats.cast_to()); + verify_successful &= + VerifyRTCMediaStreamStats(stats.cast_to()); } else if (stats.type() == RTCMediaStreamTrackStats::kType) { verify_successful &= VerifyRTCMediaStreamTrackStats( stats.cast_to()); @@ -387,8 +383,8 @@ class RTCStatsReportVerifier { verify_successful &= VerifyRTCOutboundRTPStreamStats( stats.cast_to()); } else if (stats.type() == RTCTransportStats::kType) { - verify_successful &= VerifyRTCTransportStats( - stats.cast_to()); + verify_successful &= + VerifyRTCTransportStats(stats.cast_to()); } else { EXPECT_TRUE(false) << "Unrecognized stats type: " << stats.type(); verify_successful = false; @@ -401,24 +397,22 @@ class RTCStatsReportVerifier { EXPECT_TRUE(false) << "Missing expected stats type: " << missing; } } - EXPECT_TRUE(verify_successful) << - "One or more problems with the stats. This is the report:\n" << - report_->ToJson(); + EXPECT_TRUE(verify_successful) + << "One or more problems with the stats. This is the report:\n" + << report_->ToJson(); } - bool VerifyRTCCertificateStats( - const RTCCertificateStats& certificate) { + bool VerifyRTCCertificateStats(const RTCCertificateStats& certificate) { RTCStatsVerifier verifier(report_, &certificate); verifier.TestMemberIsDefined(certificate.fingerprint); verifier.TestMemberIsDefined(certificate.fingerprint_algorithm); verifier.TestMemberIsDefined(certificate.base64_certificate); - verifier.TestMemberIsOptionalIDReference( - certificate.issuer_certificate_id, RTCCertificateStats::kType); + verifier.TestMemberIsOptionalIDReference(certificate.issuer_certificate_id, + RTCCertificateStats::kType); return verifier.ExpectAllMembersSuccessfullyTested(); } - bool VerifyRTCCodecStats( - const RTCCodecStats& codec) { + bool VerifyRTCCodecStats(const RTCCodecStats& codec) { RTCStatsVerifier verifier(report_, &codec); verifier.TestMemberIsDefined(codec.payload_type); verifier.TestMemberIsDefined(codec.mime_type); @@ -429,8 +423,7 @@ class RTCStatsReportVerifier { return verifier.ExpectAllMembersSuccessfullyTested(); } - bool VerifyRTCDataChannelStats( - const RTCDataChannelStats& data_channel) { + bool VerifyRTCDataChannelStats(const RTCDataChannelStats& data_channel) { RTCStatsVerifier verifier(report_, &data_channel); verifier.TestMemberIsDefined(data_channel.label); verifier.TestMemberIsDefined(data_channel.protocol); @@ -444,14 +437,15 @@ class RTCStatsReportVerifier { } bool VerifyRTCIceCandidatePairStats( - const RTCIceCandidatePairStats& candidate_pair, bool is_selected_pair) { + const RTCIceCandidatePairStats& candidate_pair, + bool is_selected_pair) { RTCStatsVerifier verifier(report_, &candidate_pair); - verifier.TestMemberIsIDReference( - candidate_pair.transport_id, RTCTransportStats::kType); - verifier.TestMemberIsIDReference( - candidate_pair.local_candidate_id, RTCLocalIceCandidateStats::kType); - verifier.TestMemberIsIDReference( - candidate_pair.remote_candidate_id, RTCRemoteIceCandidateStats::kType); + verifier.TestMemberIsIDReference(candidate_pair.transport_id, + RTCTransportStats::kType); + verifier.TestMemberIsIDReference(candidate_pair.local_candidate_id, + RTCLocalIceCandidateStats::kType); + verifier.TestMemberIsIDReference(candidate_pair.remote_candidate_id, + RTCRemoteIceCandidateStats::kType); verifier.TestMemberIsDefined(candidate_pair.state); verifier.TestMemberIsNonNegative(candidate_pair.priority); verifier.TestMemberIsDefined(candidate_pair.nominated); @@ -488,11 +482,10 @@ class RTCStatsReportVerifier { return verifier.ExpectAllMembersSuccessfullyTested(); } - bool VerifyRTCIceCandidateStats( - const RTCIceCandidateStats& candidate) { + bool VerifyRTCIceCandidateStats(const RTCIceCandidateStats& candidate) { RTCStatsVerifier verifier(report_, &candidate); - verifier.TestMemberIsIDReference( - candidate.transport_id, RTCTransportStats::kType); + verifier.TestMemberIsIDReference(candidate.transport_id, + RTCTransportStats::kType); verifier.TestMemberIsDefined(candidate.is_remote); if (*candidate.is_remote) { verifier.TestMemberIsUndefined(candidate.network_type); @@ -519,12 +512,11 @@ class RTCStatsReportVerifier { return VerifyRTCIceCandidateStats(remote_candidate); } - bool VerifyRTCMediaStreamStats( - const RTCMediaStreamStats& media_stream) { + bool VerifyRTCMediaStreamStats(const RTCMediaStreamStats& media_stream) { RTCStatsVerifier verifier(report_, &media_stream); verifier.TestMemberIsDefined(media_stream.stream_identifier); - verifier.TestMemberIsIDReference( - media_stream.track_ids, RTCMediaStreamTrackStats::kType); + verifier.TestMemberIsIDReference(media_stream.track_ids, + RTCMediaStreamTrackStats::kType); return verifier.ExpectAllMembersSuccessfullyTested(); } @@ -573,8 +565,7 @@ class RTCStatsReportVerifier { verifier.TestMemberIsUndefined(media_stream_track.total_audio_energy); verifier.TestMemberIsUndefined(media_stream_track.total_samples_duration); } else { - RTC_DCHECK_EQ(*media_stream_track.kind, - RTCMediaStreamTrackKind::kAudio); + RTC_DCHECK_EQ(*media_stream_track.kind, RTCMediaStreamTrackKind::kAudio); // Video-only members should be undefined verifier.TestMemberIsUndefined(media_stream_track.frame_width); verifier.TestMemberIsUndefined(media_stream_track.frame_height); @@ -598,8 +589,8 @@ class RTCStatsReportVerifier { // test run until available or is there a way to have it always be // defined? crbug.com/627816 verifier.MarkMemberTested(media_stream_track.echo_return_loss, true); - verifier.MarkMemberTested( - media_stream_track.echo_return_loss_enhancement, true); + verifier.MarkMemberTested(media_stream_track.echo_return_loss_enhancement, + true); } // totalSamplesReceived, concealedSamples and concealmentEvents are only // present on inbound audio tracks. @@ -633,16 +624,16 @@ class RTCStatsReportVerifier { return verifier.ExpectAllMembersSuccessfullyTested(); } - void VerifyRTCRTPStreamStats( - const RTCRTPStreamStats& stream, RTCStatsVerifier* verifier) { + void VerifyRTCRTPStreamStats(const RTCRTPStreamStats& stream, + RTCStatsVerifier* verifier) { verifier->TestMemberIsDefined(stream.ssrc); verifier->TestMemberIsUndefined(stream.associate_stats_id); verifier->TestMemberIsDefined(stream.is_remote); verifier->TestMemberIsDefined(stream.media_type); - verifier->TestMemberIsIDReference( - stream.track_id, RTCMediaStreamTrackStats::kType); - verifier->TestMemberIsIDReference( - stream.transport_id, RTCTransportStats::kType); + verifier->TestMemberIsIDReference(stream.track_id, + RTCMediaStreamTrackStats::kType); + verifier->TestMemberIsIDReference(stream.transport_id, + RTCTransportStats::kType); verifier->TestMemberIsIDReference(stream.codec_id, RTCCodecStats::kType); if (stream.media_type.is_defined() && *stream.media_type == "video") { verifier->TestMemberIsNonNegative(stream.fir_count); @@ -720,20 +711,19 @@ class RTCStatsReportVerifier { return verifier.ExpectAllMembersSuccessfullyTested(); } - bool VerifyRTCTransportStats( - const RTCTransportStats& transport) { + bool VerifyRTCTransportStats(const RTCTransportStats& transport) { RTCStatsVerifier verifier(report_, &transport); verifier.TestMemberIsNonNegative(transport.bytes_sent); verifier.TestMemberIsNonNegative(transport.bytes_received); - verifier.TestMemberIsOptionalIDReference( - transport.rtcp_transport_stats_id, RTCTransportStats::kType); + verifier.TestMemberIsOptionalIDReference(transport.rtcp_transport_stats_id, + RTCTransportStats::kType); verifier.TestMemberIsDefined(transport.dtls_state); - verifier.TestMemberIsIDReference( - transport.selected_candidate_pair_id, RTCIceCandidatePairStats::kType); - verifier.TestMemberIsIDReference( - transport.local_certificate_id, RTCCertificateStats::kType); - verifier.TestMemberIsIDReference( - transport.remote_certificate_id, RTCCertificateStats::kType); + verifier.TestMemberIsIDReference(transport.selected_candidate_pair_id, + RTCIceCandidatePairStats::kType); + verifier.TestMemberIsIDReference(transport.local_certificate_id, + RTCCertificateStats::kType); + verifier.TestMemberIsIDReference(transport.remote_certificate_id, + RTCCertificateStats::kType); return verifier.ExpectAllMembersSuccessfullyTested(); } diff --git a/pc/rtcstatscollector.h b/pc/rtcstatscollector.h index 743911e5e7..bad281fc9b 100644 --- a/pc/rtcstatscollector.h +++ b/pc/rtcstatscollector.h @@ -166,8 +166,8 @@ class RTCStatsCollector : public virtual rtc::RefCountInterface, const std::vector& transceiver_stats_infos, RTCStatsReport* report) const; // Produces |RTCDataChannelStats|. - void ProduceDataChannelStats_s( - int64_t timestamp_us, RTCStatsReport* report) const; + void ProduceDataChannelStats_s(int64_t timestamp_us, + RTCStatsReport* report) const; // Produces |RTCIceCandidatePairStats| and |RTCIceCandidateStats|. void ProduceIceCandidateAndPairStats_n( int64_t timestamp_us, @@ -182,8 +182,8 @@ class RTCStatsCollector : public virtual rtc::RefCountInterface, void ProduceMediaStreamTrackStats_s(int64_t timestamp_us, RTCStatsReport* report) const; // Produces |RTCPeerConnectionStats|. - void ProducePeerConnectionStats_s( - int64_t timestamp_us, RTCStatsReport* report) const; + void ProducePeerConnectionStats_s(int64_t timestamp_us, + RTCStatsReport* report) const; // Produces |RTCInboundRTPStreamStats| and |RTCOutboundRTPStreamStats|. void ProduceRTPStreamStats_n( int64_t timestamp_us, @@ -248,8 +248,7 @@ class RTCStatsCollector : public virtual rtc::RefCountInterface, // Data recorded and maintained by the stats collector during its lifetime. // Some stats are produced from this record instead of other components. struct InternalRecord { - InternalRecord() : data_channels_opened(0), - data_channels_closed(0) {} + InternalRecord() : data_channels_opened(0), data_channels_closed(0) {} // The opened count goes up when a channel is fully opened and the closed // count goes up if a previously opened channel has fully closed. The opened diff --git a/pc/rtcstatscollector_unittest.cc b/pc/rtcstatscollector_unittest.cc index 08fa41537a..99bb88caef 100644 --- a/pc/rtcstatscollector_unittest.cc +++ b/pc/rtcstatscollector_unittest.cc @@ -127,8 +127,7 @@ std::unique_ptr CreateFakeCertificateAndInfoFromDers( info->ders = ders; for (const std::string& der : ders) { info->pems.push_back(rtc::SSLIdentity::DerToPem( - "CERTIFICATE", - reinterpret_cast(der.c_str()), + "CERTIFICATE", reinterpret_cast(der.c_str()), der.length())); } info->certificate = @@ -136,12 +135,11 @@ std::unique_ptr CreateFakeCertificateAndInfoFromDers( new rtc::FakeSSLIdentity(info->pems))); // Strip header/footer and newline characters of PEM strings. for (size_t i = 0; i < info->pems.size(); ++i) { - rtc::replace_substrs("-----BEGIN CERTIFICATE-----", 27, - "", 0, &info->pems[i]); - rtc::replace_substrs("-----END CERTIFICATE-----", 25, - "", 0, &info->pems[i]); - rtc::replace_substrs("\n", 1, - "", 0, &info->pems[i]); + rtc::replace_substrs("-----BEGIN CERTIFICATE-----", 27, "", 0, + &info->pems[i]); + rtc::replace_substrs("-----END CERTIFICATE-----", 25, "", 0, + &info->pems[i]); + rtc::replace_substrs("\n", 1, "", 0, &info->pems[i]); } // Fingerprints for the whole certificate chain, starting with leaf // certificate. @@ -172,8 +170,7 @@ std::unique_ptr CreateFakeCandidate( return candidate; } -class FakeAudioTrackForStats - : public MediaStreamTrack { +class FakeAudioTrackForStats : public MediaStreamTrack { public: static rtc::scoped_refptr Create( const std::string& id, @@ -199,8 +196,7 @@ class FakeAudioTrackForStats } }; -class FakeVideoTrackForStats - : public MediaStreamTrack { +class FakeVideoTrackForStats : public MediaStreamTrack { public: static rtc::scoped_refptr Create( const std::string& id, @@ -246,16 +242,17 @@ rtc::scoped_refptr CreateMockSender( new rtc::RefCountedObject()); EXPECT_CALL(*sender, track()).WillRepeatedly(Return(track)); EXPECT_CALL(*sender, ssrc()).WillRepeatedly(Return(ssrc)); - EXPECT_CALL(*sender, media_type()).WillRepeatedly(Return( - track->kind() == MediaStreamTrackInterface::kAudioKind - ? cricket::MEDIA_TYPE_AUDIO : cricket::MEDIA_TYPE_VIDEO)); - EXPECT_CALL(*sender, GetParameters()).WillRepeatedly(Invoke( - [ssrc]() { - RtpParameters params; - params.encodings.push_back(RtpEncodingParameters()); - params.encodings[0].ssrc = ssrc; - return params; - })); + EXPECT_CALL(*sender, media_type()) + .WillRepeatedly( + Return(track->kind() == MediaStreamTrackInterface::kAudioKind + ? cricket::MEDIA_TYPE_AUDIO + : cricket::MEDIA_TYPE_VIDEO)); + EXPECT_CALL(*sender, GetParameters()).WillRepeatedly(Invoke([ssrc]() { + RtpParameters params; + params.encodings.push_back(RtpEncodingParameters()); + params.encodings[0].ssrc = ssrc; + return params; + })); EXPECT_CALL(*sender, AttachmentId()).WillRepeatedly(Return(attachment_id)); EXPECT_CALL(*sender, stream_ids()).WillRepeatedly(Return(local_stream_ids)); return sender; @@ -272,16 +269,17 @@ rtc::scoped_refptr CreateMockReceiver( .WillRepeatedly( Return(std::vector>({}))); - EXPECT_CALL(*receiver, media_type()).WillRepeatedly(Return( - track->kind() == MediaStreamTrackInterface::kAudioKind - ? cricket::MEDIA_TYPE_AUDIO : cricket::MEDIA_TYPE_VIDEO)); - EXPECT_CALL(*receiver, GetParameters()).WillRepeatedly(Invoke( - [ssrc]() { - RtpParameters params; - params.encodings.push_back(RtpEncodingParameters()); - params.encodings[0].ssrc = ssrc; - return params; - })); + EXPECT_CALL(*receiver, media_type()) + .WillRepeatedly( + Return(track->kind() == MediaStreamTrackInterface::kAudioKind + ? cricket::MEDIA_TYPE_AUDIO + : cricket::MEDIA_TYPE_VIDEO)); + EXPECT_CALL(*receiver, GetParameters()).WillRepeatedly(Invoke([ssrc]() { + RtpParameters params; + params.encodings.push_back(RtpEncodingParameters()); + params.encodings[0].ssrc = ssrc; + return params; + })); EXPECT_CALL(*receiver, AttachmentId()).WillRepeatedly(Return(attachment_id)); return receiver; } @@ -510,8 +508,7 @@ class RTCStatsCollectorTest : public testing::Test { const CertificateInfo& certinfo) { for (size_t i = 0; i < certinfo.fingerprints.size(); ++i) { RTCCertificateStats expected_certificate_stats( - "RTCCertificate_" + certinfo.fingerprints[i], - report->timestamp_us()); + "RTCCertificate_" + certinfo.fingerprints[i], report->timestamp_us()); expected_certificate_stats.fingerprint = certinfo.fingerprints[i]; expected_certificate_stats.fingerprint_algorithm = "sha-1"; expected_certificate_stats.base64_certificate = certinfo.pems[i]; @@ -521,8 +518,8 @@ class RTCStatsCollectorTest : public testing::Test { } ASSERT_TRUE(report->Get(expected_certificate_stats.id())); EXPECT_EQ(expected_certificate_stats, - report->Get(expected_certificate_stats.id())->cast_to< - RTCCertificateStats>()); + report->Get(expected_certificate_stats.id()) + ->cast_to()); } } @@ -699,12 +696,12 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) { std::unique_ptr local_certinfo = CreateFakeCertificateAndInfoFromDers( - std::vector({ "(local) single certificate" })); + std::vector({"(local) single certificate"})); pc_->SetLocalCertificate(kTransportName, local_certinfo->certificate); std::unique_ptr remote_certinfo = CreateFakeCertificateAndInfoFromDers( - std::vector({ "(remote) single certificate" })); + std::vector({"(remote) single certificate"})); pc_->SetRemoteCertChain( kTransportName, remote_certinfo->certificate->ssl_cert_chain().UniqueCopy()); @@ -787,24 +784,24 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) { expected_outbound_video_codec.clock_rate = 1340; ASSERT_TRUE(report->Get(expected_inbound_audio_codec.id())); - EXPECT_EQ(expected_inbound_audio_codec, - report->Get(expected_inbound_audio_codec.id())->cast_to< - RTCCodecStats>()); + EXPECT_EQ( + expected_inbound_audio_codec, + report->Get(expected_inbound_audio_codec.id())->cast_to()); ASSERT_TRUE(report->Get(expected_outbound_audio_codec.id())); EXPECT_EQ(expected_outbound_audio_codec, - report->Get(expected_outbound_audio_codec.id())->cast_to< - RTCCodecStats>()); + report->Get(expected_outbound_audio_codec.id()) + ->cast_to()); ASSERT_TRUE(report->Get(expected_inbound_video_codec.id())); - EXPECT_EQ(expected_inbound_video_codec, - report->Get(expected_inbound_video_codec.id())->cast_to< - RTCCodecStats>()); + EXPECT_EQ( + expected_inbound_video_codec, + report->Get(expected_inbound_video_codec.id())->cast_to()); ASSERT_TRUE(report->Get(expected_outbound_video_codec.id())); EXPECT_EQ(expected_outbound_video_codec, - report->Get(expected_outbound_video_codec.id())->cast_to< - RTCCodecStats>()); + report->Get(expected_outbound_video_codec.id()) + ->cast_to()); } TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) { @@ -814,11 +811,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) { pc_->AddVoiceChannel("audio", kAudioTransport); std::unique_ptr audio_local_certinfo = CreateFakeCertificateAndInfoFromDers( - std::vector({ "(local) audio" })); + std::vector({"(local) audio"})); pc_->SetLocalCertificate(kAudioTransport, audio_local_certinfo->certificate); std::unique_ptr audio_remote_certinfo = CreateFakeCertificateAndInfoFromDers( - std::vector({ "(remote) audio" })); + std::vector({"(remote) audio"})); pc_->SetRemoteCertChain( kAudioTransport, audio_remote_certinfo->certificate->ssl_cert_chain().UniqueCopy()); @@ -826,11 +823,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) { pc_->AddVideoChannel("video", kVideoTransport); std::unique_ptr video_local_certinfo = CreateFakeCertificateAndInfoFromDers( - std::vector({ "(local) video" })); + std::vector({"(local) video"})); pc_->SetLocalCertificate(kVideoTransport, video_local_certinfo->certificate); std::unique_ptr video_remote_certinfo = CreateFakeCertificateAndInfoFromDers( - std::vector({ "(remote) video" })); + std::vector({"(remote) video"})); pc_->SetRemoteCertChain( kVideoTransport, video_remote_certinfo->certificate->ssl_cert_chain().UniqueCopy()); @@ -920,21 +917,21 @@ TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) { rtc::scoped_refptr report = stats_->GetStatsReport(); ASSERT_TRUE(report->Get(expected_data_channel0.id())); - EXPECT_EQ(expected_data_channel0, - report->Get(expected_data_channel0.id())->cast_to< - RTCDataChannelStats>()); + EXPECT_EQ( + expected_data_channel0, + report->Get(expected_data_channel0.id())->cast_to()); ASSERT_TRUE(report->Get(expected_data_channel1.id())); - EXPECT_EQ(expected_data_channel1, - report->Get(expected_data_channel1.id())->cast_to< - RTCDataChannelStats>()); + EXPECT_EQ( + expected_data_channel1, + report->Get(expected_data_channel1.id())->cast_to()); ASSERT_TRUE(report->Get(expected_data_channel2.id())); - EXPECT_EQ(expected_data_channel2, - report->Get(expected_data_channel2.id())->cast_to< - RTCDataChannelStats>()); + EXPECT_EQ( + expected_data_channel2, + report->Get(expected_data_channel2.id())->cast_to()); ASSERT_TRUE(report->Get(expected_data_channel3.id())); - EXPECT_EQ(expected_data_channel3, - report->Get(expected_data_channel3.id())->cast_to< - RTCDataChannelStats>()); + EXPECT_EQ( + expected_data_channel3, + report->Get(expected_data_channel3.id())->cast_to()); } TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { @@ -1000,8 +997,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { std::unique_ptr b_local = CreateFakeCandidate("42.42.42.42", 42, "b_local's protocol", rtc::ADAPTER_TYPE_WIFI, cricket::LOCAL_PORT_TYPE, 42); - RTCLocalIceCandidateStats expected_b_local( - "RTCIceCandidate_" + b_local->id(), 0); + RTCLocalIceCandidateStats expected_b_local("RTCIceCandidate_" + b_local->id(), + 0); expected_b_local.transport_id = "RTCTransport_b_0"; expected_b_local.network_type = "wifi"; expected_b_local.ip = "42.42.42.42"; @@ -1057,29 +1054,26 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { rtc::scoped_refptr report = stats_->GetStatsReport(); ASSERT_TRUE(report->Get(expected_a_local_host.id())); - EXPECT_EQ(expected_a_local_host, - report->Get(expected_a_local_host.id())->cast_to< - RTCLocalIceCandidateStats>()); + EXPECT_EQ(expected_a_local_host, report->Get(expected_a_local_host.id()) + ->cast_to()); ASSERT_TRUE(report->Get(expected_a_remote_srflx.id())); EXPECT_EQ(expected_a_remote_srflx, - report->Get(expected_a_remote_srflx.id())->cast_to< - RTCRemoteIceCandidateStats>()); + report->Get(expected_a_remote_srflx.id()) + ->cast_to()); ASSERT_TRUE(report->Get(expected_a_local_prflx.id())); - EXPECT_EQ(expected_a_local_prflx, - report->Get(expected_a_local_prflx.id())->cast_to< - RTCLocalIceCandidateStats>()); + EXPECT_EQ(expected_a_local_prflx, report->Get(expected_a_local_prflx.id()) + ->cast_to()); ASSERT_TRUE(report->Get(expected_a_remote_relay.id())); EXPECT_EQ(expected_a_remote_relay, - report->Get(expected_a_remote_relay.id())->cast_to< - RTCRemoteIceCandidateStats>()); + report->Get(expected_a_remote_relay.id()) + ->cast_to()); ASSERT_TRUE(report->Get(expected_b_local.id())); - EXPECT_EQ(expected_b_local, - report->Get(expected_b_local.id())->cast_to< - RTCLocalIceCandidateStats>()); + EXPECT_EQ( + expected_b_local, + report->Get(expected_b_local.id())->cast_to()); ASSERT_TRUE(report->Get(expected_b_remote.id())); - EXPECT_EQ(expected_b_remote, - report->Get(expected_b_remote.id())->cast_to< - RTCRemoteIceCandidateStats>()); + EXPECT_EQ(expected_b_remote, report->Get(expected_b_remote.id()) + ->cast_to()); EXPECT_TRUE(report->Get("RTCTransport_a_0")); EXPECT_TRUE(report->Get("RTCTransport_b_0")); } @@ -1219,8 +1213,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { EXPECT_FALSE(*expected_local_candidate.is_remote); ASSERT_TRUE(report->Get(expected_local_candidate.id())); EXPECT_EQ(expected_local_candidate, - report->Get(expected_local_candidate.id())->cast_to< - RTCLocalIceCandidateStats>()); + report->Get(expected_local_candidate.id()) + ->cast_to()); RTCRemoteIceCandidateStats expected_remote_candidate( *expected_pair.remote_candidate_id, report->timestamp_us()); @@ -1234,8 +1228,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { EXPECT_TRUE(*expected_remote_candidate.is_remote); ASSERT_TRUE(report->Get(expected_remote_candidate.id())); EXPECT_EQ(expected_remote_candidate, - report->Get(expected_remote_candidate.id())->cast_to< - RTCRemoteIceCandidateStats>()); + report->Get(expected_remote_candidate.id()) + ->cast_to()); } TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { @@ -1246,9 +1240,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { expected.data_channels_opened = 0; expected.data_channels_closed = 0; ASSERT_TRUE(report->Get("RTCPeerConnection")); - EXPECT_EQ(expected, - report->Get("RTCPeerConnection")->cast_to< - RTCPeerConnectionStats>()); + EXPECT_EQ( + expected, + report->Get("RTCPeerConnection")->cast_to()); } rtc::scoped_refptr dummy_channel_a = DataChannel::Create( @@ -1270,9 +1264,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { expected.data_channels_opened = 1; expected.data_channels_closed = 0; ASSERT_TRUE(report->Get("RTCPeerConnection")); - EXPECT_EQ(expected, - report->Get("RTCPeerConnection")->cast_to< - RTCPeerConnectionStats>()); + EXPECT_EQ( + expected, + report->Get("RTCPeerConnection")->cast_to()); } dummy_channel_b->SignalOpened(dummy_channel_b.get()); @@ -1286,9 +1280,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { expected.data_channels_opened = 2; expected.data_channels_closed = 1; ASSERT_TRUE(report->Get("RTCPeerConnection")); - EXPECT_EQ(expected, - report->Get("RTCPeerConnection")->cast_to< - RTCPeerConnectionStats>()); + EXPECT_EQ( + expected, + report->Get("RTCPeerConnection")->cast_to()); } // Re-opening a data channel (or opening a new data channel that is re-using @@ -1303,9 +1297,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { expected.data_channels_opened = 3; expected.data_channels_closed = 1; ASSERT_TRUE(report->Get("RTCPeerConnection")); - EXPECT_EQ(expected, - report->Get("RTCPeerConnection")->cast_to< - RTCPeerConnectionStats>()); + EXPECT_EQ( + expected, + report->Get("RTCPeerConnection")->cast_to()); } dummy_channel_a->SignalClosed(dummy_channel_a.get()); @@ -1319,9 +1313,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { expected.data_channels_opened = 3; expected.data_channels_closed = 3; ASSERT_TRUE(report->Get("RTCPeerConnection")); - EXPECT_EQ(expected, - report->Get("RTCPeerConnection")->cast_to< - RTCPeerConnectionStats>()); + EXPECT_EQ( + expected, + report->Get("RTCPeerConnection")->cast_to()); } } @@ -1335,8 +1329,8 @@ TEST_F(RTCStatsCollectorTest, rtc::scoped_refptr local_audio_track = CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "LocalAudioTrackID", MediaStreamTrackInterface::kEnded); - local_stream->AddTrack(static_cast( - local_audio_track.get())); + local_stream->AddTrack( + static_cast(local_audio_track.get())); cricket::VoiceSenderInfo voice_sender_info_ssrc1; voice_sender_info_ssrc1.local_stats.push_back(cricket::SsrcSenderInfo()); @@ -1395,8 +1389,8 @@ TEST_F(RTCStatsCollectorTest, rtc::scoped_refptr remote_audio_track = CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "RemoteAudioTrackID", MediaStreamTrackInterface::kLive); - remote_stream->AddTrack(static_cast( - remote_audio_track.get())); + remote_stream->AddTrack( + static_cast(remote_audio_track.get())); cricket::VoiceReceiverInfo voice_receiver_info; voice_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo()); @@ -1423,9 +1417,9 @@ TEST_F(RTCStatsCollectorTest, ASSERT_TRUE(report->Get(expected_remote_stream.id())) << "Did not find " << expected_remote_stream.id() << " in " << report->ToJson(); - EXPECT_EQ(expected_remote_stream, - report->Get(expected_remote_stream.id())->cast_to< - RTCMediaStreamStats>()); + EXPECT_EQ( + expected_remote_stream, + report->Get(expected_remote_stream.id())->cast_to()); RTCMediaStreamTrackStats expected_remote_audio_track( IdForType(report), report->timestamp_us(), @@ -1443,8 +1437,8 @@ TEST_F(RTCStatsCollectorTest, expected_remote_audio_track.jitter_buffer_delay = 3456; ASSERT_TRUE(report->Get(expected_remote_audio_track.id())); EXPECT_EQ(expected_remote_audio_track, - report->Get(expected_remote_audio_track.id())->cast_to< - RTCMediaStreamTrackStats>()); + report->Get(expected_remote_audio_track.id()) + ->cast_to()); } TEST_F(RTCStatsCollectorTest, @@ -1457,8 +1451,8 @@ TEST_F(RTCStatsCollectorTest, rtc::scoped_refptr local_video_track = CreateFakeTrack(cricket::MEDIA_TYPE_VIDEO, "LocalVideoTrackID", MediaStreamTrackInterface::kLive); - local_stream->AddTrack(static_cast( - local_video_track.get())); + local_stream->AddTrack( + static_cast(local_video_track.get())); cricket::VideoSenderInfo video_sender_info_ssrc1; video_sender_info_ssrc1.local_stats.push_back(cricket::SsrcSenderInfo()); @@ -1518,8 +1512,8 @@ TEST_F(RTCStatsCollectorTest, rtc::scoped_refptr remote_video_track_ssrc3 = CreateFakeTrack(cricket::MEDIA_TYPE_VIDEO, "RemoteVideoTrackID3", MediaStreamTrackInterface::kEnded); - remote_stream->AddTrack(static_cast( - remote_video_track_ssrc3.get())); + remote_stream->AddTrack( + static_cast(remote_video_track_ssrc3.get())); cricket::VideoReceiverInfo video_receiver_info_ssrc3; video_receiver_info_ssrc3.local_stats.push_back(cricket::SsrcReceiverInfo()); @@ -1551,9 +1545,9 @@ TEST_F(RTCStatsCollectorTest, expected_remote_stream.track_ids = std::vector({stats_of_track_type[0]->id()}); ASSERT_TRUE(report->Get(expected_remote_stream.id())); - EXPECT_EQ(expected_remote_stream, - report->Get(expected_remote_stream.id())->cast_to< - RTCMediaStreamStats>()); + EXPECT_EQ( + expected_remote_stream, + report->Get(expected_remote_stream.id())->cast_to()); RTCMediaStreamTrackStats expected_remote_video_track_ssrc3( stats_of_track_type[0]->id(), report->timestamp_us(), @@ -1570,8 +1564,8 @@ TEST_F(RTCStatsCollectorTest, expected_remote_video_track_ssrc3.frames_dropped = 1000 - 990; ASSERT_TRUE(report->Get(expected_remote_video_track_ssrc3.id())); EXPECT_EQ(expected_remote_video_track_ssrc3, - report->Get(expected_remote_video_track_ssrc3.id())->cast_to< - RTCMediaStreamTrackStats>()); + report->Get(expected_remote_video_track_ssrc3.id()) + ->cast_to()); } TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { @@ -1606,8 +1600,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { auto stats_of_track_type = report->GetStatsOfType(); ASSERT_EQ(1, stats_of_track_type.size()); - RTCInboundRTPStreamStats expected_audio( - "RTCInboundRTPAudioStream_1", report->timestamp_us()); + RTCInboundRTPStreamStats expected_audio("RTCInboundRTPAudioStream_1", + report->timestamp_us()); expected_audio.ssrc = 1; expected_audio.is_remote = false; expected_audio.media_type = "audio"; @@ -1661,8 +1655,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { rtc::scoped_refptr report = stats_->GetStatsReport(); - RTCInboundRTPStreamStats expected_video( - "RTCInboundRTPVideoStream_1", report->timestamp_us()); + RTCInboundRTPStreamStats expected_video("RTCInboundRTPVideoStream_1", + report->timestamp_us()); expected_video.ssrc = 1; expected_video.is_remote = false; expected_video.media_type = "video"; @@ -1725,8 +1719,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { rtc::scoped_refptr report = stats_->GetStatsReport(); - RTCOutboundRTPStreamStats expected_audio( - "RTCOutboundRTPAudioStream_1", report->timestamp_us()); + RTCOutboundRTPStreamStats expected_audio("RTCOutboundRTPAudioStream_1", + report->timestamp_us()); expected_audio.ssrc = 1; expected_audio.is_remote = false; expected_audio.media_type = "audio"; diff --git a/pc/rtpsender.cc b/pc/rtpsender.cc index c7fe83f1b2..cffcd8b612 100644 --- a/pc/rtpsender.cc +++ b/pc/rtpsender.cc @@ -554,7 +554,7 @@ void VideoRtpSender::SetVideoSend() { break; } bool success = worker_thread_->Invoke(RTC_FROM_HERE, [&] { - return media_channel_->SetVideoSend(ssrc_, &options, track_); + return media_channel_->SetVideoSend(ssrc_, &options, track_); }); RTC_DCHECK(success); } diff --git a/pc/rtpsender.h b/pc/rtpsender.h index 739ed0f3a4..62b8b59285 100644 --- a/pc/rtpsender.h +++ b/pc/rtpsender.h @@ -21,10 +21,10 @@ #include "api/mediastreaminterface.h" #include "api/rtpsenderinterface.h" -#include "rtc_base/criticalsection.h" #include "media/base/audiosource.h" #include "media/base/mediachannel.h" #include "pc/dtmfsender.h" +#include "rtc_base/criticalsection.h" namespace webrtc { diff --git a/pc/sctputils.cc b/pc/sctputils.cc index 6f0ef016d9..1dfa4db026 100644 --- a/pc/sctputils.cc +++ b/pc/sctputils.cc @@ -88,7 +88,7 @@ bool ParseDataChannelOpenMessage(const rtc::CopyOnWriteBuffer& payload, RTC_LOG(LS_WARNING) << "Could not read OPEN message protocol length."; return false; } - if (!buffer.ReadString(label, (size_t) label_length)) { + if (!buffer.ReadString(label, (size_t)label_length)) { RTC_LOG(LS_WARNING) << "Could not read OPEN message label"; return false; } @@ -165,9 +165,9 @@ bool WriteDataChannelOpenMessage(const std::string& label, } } - rtc::ByteBufferWriter buffer( - NULL, 20 + label.length() + config.protocol.length(), - rtc::ByteBuffer::ORDER_NETWORK); + rtc::ByteBufferWriter buffer(NULL, + 20 + label.length() + config.protocol.length(), + rtc::ByteBuffer::ORDER_NETWORK); // TODO(tommi): Add error handling and check resulting length. buffer.WriteUInt8(DATA_CHANNEL_OPEN_MESSAGE_TYPE); buffer.WriteUInt8(channel_type); diff --git a/pc/sctputils_unittest.cc b/pc/sctputils_unittest.cc index 86cdc47a5b..d2f2de6b6d 100644 --- a/pc/sctputils_unittest.cc +++ b/pc/sctputils_unittest.cc @@ -31,12 +31,14 @@ class SctpUtilsTest : public testing::Test { ASSERT_TRUE(buffer.ReadUInt8(&channel_type)); if (config.ordered) { - EXPECT_EQ(config.maxRetransmits > -1 ? - 0x01 : (config.maxRetransmitTime > -1 ? 0x02 : 0), + EXPECT_EQ(config.maxRetransmits > -1 + ? 0x01 + : (config.maxRetransmitTime > -1 ? 0x02 : 0), channel_type); } else { - EXPECT_EQ(config.maxRetransmits > -1 ? - 0x81 : (config.maxRetransmitTime > -1 ? 0x82 : 0x80), + EXPECT_EQ(config.maxRetransmits > -1 + ? 0x81 + : (config.maxRetransmitTime > -1 ? 0x82 : 0x80), channel_type); } @@ -44,8 +46,8 @@ class SctpUtilsTest : public testing::Test { ASSERT_TRUE(buffer.ReadUInt32(&reliability)); if (config.maxRetransmits > -1 || config.maxRetransmitTime > -1) { - EXPECT_EQ(config.maxRetransmits > -1 ? - config.maxRetransmits : config.maxRetransmitTime, + EXPECT_EQ(config.maxRetransmits > -1 ? config.maxRetransmits + : config.maxRetransmitTime, static_cast(reliability)); } @@ -75,8 +77,8 @@ TEST_F(SctpUtilsTest, WriteParseOpenMessageWithOrderedReliable) { std::string output_label; webrtc::DataChannelInit output_config; - ASSERT_TRUE(webrtc::ParseDataChannelOpenMessage( - packet, &output_label, &output_config)); + ASSERT_TRUE(webrtc::ParseDataChannelOpenMessage(packet, &output_label, + &output_config)); EXPECT_EQ(label, output_label); EXPECT_EQ(config.protocol, output_config.protocol); @@ -99,8 +101,8 @@ TEST_F(SctpUtilsTest, WriteParseOpenMessageWithMaxRetransmitTime) { std::string output_label; webrtc::DataChannelInit output_config; - ASSERT_TRUE(webrtc::ParseDataChannelOpenMessage( - packet, &output_label, &output_config)); + ASSERT_TRUE(webrtc::ParseDataChannelOpenMessage(packet, &output_label, + &output_config)); EXPECT_EQ(label, output_label); EXPECT_EQ(config.protocol, output_config.protocol); @@ -122,8 +124,8 @@ TEST_F(SctpUtilsTest, WriteParseOpenMessageWithMaxRetransmits) { std::string output_label; webrtc::DataChannelInit output_config; - ASSERT_TRUE(webrtc::ParseDataChannelOpenMessage( - packet, &output_label, &output_config)); + ASSERT_TRUE(webrtc::ParseDataChannelOpenMessage(packet, &output_label, + &output_config)); EXPECT_EQ(label, output_label); EXPECT_EQ(config.protocol, output_config.protocol); diff --git a/pc/srtpfilter.cc b/pc/srtpfilter.cc index 751668e90b..a561d3649a 100644 --- a/pc/srtpfilter.cc +++ b/pc/srtpfilter.cc @@ -26,11 +26,9 @@ namespace cricket { -SrtpFilter::SrtpFilter() { -} +SrtpFilter::SrtpFilter() {} -SrtpFilter::~SrtpFilter() { -} +SrtpFilter::~SrtpFilter() {} bool SrtpFilter::IsActive() const { return state_ >= ST_ACTIVE; @@ -82,10 +80,9 @@ bool SrtpFilter::SetProvisionalAnswer( } bool SrtpFilter::ExpectOffer(ContentSource source) { - return ((state_ == ST_INIT) || - (state_ == ST_ACTIVE) || - (state_ == ST_SENTOFFER && source == CS_LOCAL) || - (state_ == ST_SENTUPDATEDOFFER && source == CS_LOCAL) || + return ((state_ == ST_INIT) || (state_ == ST_ACTIVE) || + (state_ == ST_SENTOFFER && source == CS_LOCAL) || + (state_ == ST_SENTUPDATEDOFFER && source == CS_LOCAL) || (state_ == ST_RECEIVEDOFFER && source == CS_REMOTE) || (state_ == ST_RECEIVEDUPDATEDOFFER && source == CS_REMOTE)); } @@ -130,8 +127,8 @@ bool SrtpFilter::DoSetAnswer(const std::vector& answer_params, } else { // Need to wait for the final answer to decide if // we should go to Active state. - state_ = (source == CS_LOCAL) ? ST_SENTPRANSWER_NO_CRYPTO : - ST_RECEIVEDPRANSWER_NO_CRYPTO; + state_ = (source == CS_LOCAL) ? ST_SENTPRANSWER_NO_CRYPTO + : ST_RECEIVEDPRANSWER_NO_CRYPTO; return true; } } @@ -153,8 +150,7 @@ bool SrtpFilter::DoSetAnswer(const std::vector& answer_params, offer_params_.clear(); state_ = ST_ACTIVE; } else { - state_ = - (source == CS_LOCAL) ? ST_SENTPRANSWER : ST_RECEIVEDPRANSWER; + state_ = (source == CS_LOCAL) ? ST_SENTPRANSWER : ST_RECEIVEDPRANSWER; } return true; } diff --git a/pc/srtpfilter.h b/pc/srtpfilter.h index 977464013a..e51d9fe211 100644 --- a/pc/srtpfilter.h +++ b/pc/srtpfilter.h @@ -38,10 +38,7 @@ namespace cricket { // TODO(zhihuang): Find a better name for this class, like "SdesNegotiator". class SrtpFilter { public: - enum Mode { - PROTECT, - UNPROTECT - }; + enum Mode { PROTECT, UNPROTECT }; enum Error { ERROR_NONE, ERROR_FAIL, @@ -112,13 +109,13 @@ class SrtpFilter { size_t len); enum State { - ST_INIT, // SRTP filter unused. - ST_SENTOFFER, // Offer with SRTP parameters sent. - ST_RECEIVEDOFFER, // Offer with SRTP parameters received. + ST_INIT, // SRTP filter unused. + ST_SENTOFFER, // Offer with SRTP parameters sent. + ST_RECEIVEDOFFER, // Offer with SRTP parameters received. ST_SENTPRANSWER_NO_CRYPTO, // Sent provisional answer without crypto. // Received provisional answer without crypto. ST_RECEIVEDPRANSWER_NO_CRYPTO, - ST_ACTIVE, // Offer and answer set. + ST_ACTIVE, // Offer and answer set. // SRTP filter is active but new parameters are offered. // When the answer is set, the state transitions to ST_ACTIVE or ST_INIT. ST_SENTUPDATEDOFFER, diff --git a/pc/srtpfilter_unittest.cc b/pc/srtpfilter_unittest.cc index 342d458307..e901fcdf7c 100644 --- a/pc/srtpfilter_unittest.cc +++ b/pc/srtpfilter_unittest.cc @@ -37,18 +37,30 @@ static const char kTestKeyParamsGcm3[] = "inline:YKlABGZWMgX32xuMotrG0v0T7G83veegaVzubQ=="; static const char kTestKeyParamsGcm4[] = "inline:gJ6tWoUym2v+/F6xjr7xaxiS3QbJJozl3ZD/0A=="; -static const cricket::CryptoParams kTestCryptoParams1( - 1, "AES_CM_128_HMAC_SHA1_80", kTestKeyParams1, ""); -static const cricket::CryptoParams kTestCryptoParams2( - 1, "AES_CM_128_HMAC_SHA1_80", kTestKeyParams2, ""); -static const cricket::CryptoParams kTestCryptoParamsGcm1( - 1, "AEAD_AES_256_GCM", kTestKeyParamsGcm1, ""); -static const cricket::CryptoParams kTestCryptoParamsGcm2( - 1, "AEAD_AES_256_GCM", kTestKeyParamsGcm2, ""); -static const cricket::CryptoParams kTestCryptoParamsGcm3( - 1, "AEAD_AES_128_GCM", kTestKeyParamsGcm3, ""); -static const cricket::CryptoParams kTestCryptoParamsGcm4( - 1, "AEAD_AES_128_GCM", kTestKeyParamsGcm4, ""); +static const cricket::CryptoParams kTestCryptoParams1(1, + "AES_CM_128_HMAC_SHA1_80", + kTestKeyParams1, + ""); +static const cricket::CryptoParams kTestCryptoParams2(1, + "AES_CM_128_HMAC_SHA1_80", + kTestKeyParams2, + ""); +static const cricket::CryptoParams kTestCryptoParamsGcm1(1, + "AEAD_AES_256_GCM", + kTestKeyParamsGcm1, + ""); +static const cricket::CryptoParams kTestCryptoParamsGcm2(1, + "AEAD_AES_256_GCM", + kTestKeyParamsGcm2, + ""); +static const cricket::CryptoParams kTestCryptoParamsGcm3(1, + "AEAD_AES_128_GCM", + kTestKeyParamsGcm3, + ""); +static const cricket::CryptoParams kTestCryptoParamsGcm4(1, + "AEAD_AES_128_GCM", + kTestKeyParamsGcm4, + ""); class SrtpFilterTest : public testing::Test { protected: diff --git a/pc/statscollector.cc b/pc/statscollector.cc index 8807e61a90..fc001894d3 100644 --- a/pc/statscollector.cc +++ b/pc/statscollector.cc @@ -40,7 +40,7 @@ const char* STATSREPORT_ADAPTER_TYPE_WWAN = "wwan"; const char* STATSREPORT_ADAPTER_TYPE_VPN = "vpn"; const char* STATSREPORT_ADAPTER_TYPE_LOOPBACK = "loopback"; -template +template struct TypeForAdd { const StatsReport::StatsValueName name; const ValueType& value; @@ -133,37 +133,36 @@ void SetAudioProcessingStats(StatsReport* report, void ExtractStats(const cricket::VoiceReceiverInfo& info, StatsReport* report) { ExtractCommonReceiveProperties(info, report); const FloatForAdd floats[] = { - { StatsReport::kStatsValueNameExpandRate, info.expand_rate }, - { StatsReport::kStatsValueNameSecondaryDecodedRate, - info.secondary_decoded_rate }, - { StatsReport::kStatsValueNameSecondaryDiscardedRate, - info.secondary_discarded_rate }, - { StatsReport::kStatsValueNameSpeechExpandRate, info.speech_expand_rate }, - { StatsReport::kStatsValueNameAccelerateRate, info.accelerate_rate }, - { StatsReport::kStatsValueNamePreemptiveExpandRate, - info.preemptive_expand_rate }, - { StatsReport::kStatsValueNameTotalAudioEnergy, info.total_output_energy }, - { StatsReport::kStatsValueNameTotalSamplesDuration, - info.total_output_duration } - }; + {StatsReport::kStatsValueNameExpandRate, info.expand_rate}, + {StatsReport::kStatsValueNameSecondaryDecodedRate, + info.secondary_decoded_rate}, + {StatsReport::kStatsValueNameSecondaryDiscardedRate, + info.secondary_discarded_rate}, + {StatsReport::kStatsValueNameSpeechExpandRate, info.speech_expand_rate}, + {StatsReport::kStatsValueNameAccelerateRate, info.accelerate_rate}, + {StatsReport::kStatsValueNamePreemptiveExpandRate, + info.preemptive_expand_rate}, + {StatsReport::kStatsValueNameTotalAudioEnergy, info.total_output_energy}, + {StatsReport::kStatsValueNameTotalSamplesDuration, + info.total_output_duration}}; const IntForAdd ints[] = { - { StatsReport::kStatsValueNameCurrentDelayMs, info.delay_estimate_ms }, - { StatsReport::kStatsValueNameDecodingCNG, info.decoding_cng }, - { StatsReport::kStatsValueNameDecodingCTN, info.decoding_calls_to_neteq }, - { StatsReport::kStatsValueNameDecodingCTSG, - info.decoding_calls_to_silence_generator }, - { StatsReport::kStatsValueNameDecodingMutedOutput, - info.decoding_muted_output }, - { StatsReport::kStatsValueNameDecodingNormal, info.decoding_normal }, - { StatsReport::kStatsValueNameDecodingPLC, info.decoding_plc }, - { StatsReport::kStatsValueNameDecodingPLCCNG, info.decoding_plc_cng }, - { StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms }, - { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, - { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, - { StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd }, - { StatsReport::kStatsValueNamePreferredJitterBufferMs, - info.jitter_buffer_preferred_ms }, + {StatsReport::kStatsValueNameCurrentDelayMs, info.delay_estimate_ms}, + {StatsReport::kStatsValueNameDecodingCNG, info.decoding_cng}, + {StatsReport::kStatsValueNameDecodingCTN, info.decoding_calls_to_neteq}, + {StatsReport::kStatsValueNameDecodingCTSG, + info.decoding_calls_to_silence_generator}, + {StatsReport::kStatsValueNameDecodingMutedOutput, + info.decoding_muted_output}, + {StatsReport::kStatsValueNameDecodingNormal, info.decoding_normal}, + {StatsReport::kStatsValueNameDecodingPLC, info.decoding_plc}, + {StatsReport::kStatsValueNameDecodingPLCCNG, info.decoding_plc_cng}, + {StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms}, + {StatsReport::kStatsValueNameJitterReceived, info.jitter_ms}, + {StatsReport::kStatsValueNamePacketsLost, info.packets_lost}, + {StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd}, + {StatsReport::kStatsValueNamePreferredJitterBufferMs, + info.jitter_buffer_preferred_ms}, }; for (const auto& f : floats) @@ -176,8 +175,7 @@ void ExtractStats(const cricket::VoiceReceiverInfo& info, StatsReport* report) { info.audio_level); } - report->AddInt64(StatsReport::kStatsValueNameBytesReceived, - info.bytes_rcvd); + report->AddInt64(StatsReport::kStatsValueNameBytesReceived, info.bytes_rcvd); if (info.capture_start_ntp_time_ms >= 0) { report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, info.capture_start_ntp_time_ms); @@ -192,17 +190,16 @@ void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) { info.apm_statistics); const FloatForAdd floats[] = { - { StatsReport::kStatsValueNameTotalAudioEnergy, info.total_input_energy }, - { StatsReport::kStatsValueNameTotalSamplesDuration, - info.total_input_duration } - }; + {StatsReport::kStatsValueNameTotalAudioEnergy, info.total_input_energy}, + {StatsReport::kStatsValueNameTotalSamplesDuration, + info.total_input_duration}}; RTC_DCHECK_GE(info.audio_level, 0); const IntForAdd ints[] = { - { StatsReport::kStatsValueNameAudioInputLevel, info.audio_level}, - { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, - { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, - { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, + {StatsReport::kStatsValueNameAudioInputLevel, info.audio_level}, + {StatsReport::kStatsValueNameJitterReceived, info.jitter_ms}, + {StatsReport::kStatsValueNamePacketsLost, info.packets_lost}, + {StatsReport::kStatsValueNamePacketsSent, info.packets_sent}, }; for (const auto& f : floats) { @@ -249,8 +246,7 @@ void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) { ExtractCommonReceiveProperties(info, report); report->AddString(StatsReport::kStatsValueNameCodecImplementationName, info.decoder_implementation_name); - report->AddInt64(StatsReport::kStatsValueNameBytesReceived, - info.bytes_rcvd); + report->AddInt64(StatsReport::kStatsValueNameBytesReceived, info.bytes_rcvd); if (info.capture_start_ntp_time_ms >= 0) { report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, info.capture_start_ntp_time_ms); @@ -259,25 +255,25 @@ void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) { report->AddInt64(StatsReport::kStatsValueNameQpSum, *info.qp_sum); const IntForAdd ints[] = { - { StatsReport::kStatsValueNameCurrentDelayMs, info.current_delay_ms }, - { StatsReport::kStatsValueNameDecodeMs, info.decode_ms }, - { StatsReport::kStatsValueNameFirsSent, info.firs_sent }, - { StatsReport::kStatsValueNameFrameHeightReceived, info.frame_height }, - { StatsReport::kStatsValueNameFrameRateDecoded, info.framerate_decoded }, - { StatsReport::kStatsValueNameFrameRateOutput, info.framerate_output }, - { StatsReport::kStatsValueNameFrameRateReceived, info.framerate_rcvd }, - { StatsReport::kStatsValueNameFrameWidthReceived, info.frame_width }, - { StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms }, - { StatsReport::kStatsValueNameMaxDecodeMs, info.max_decode_ms }, - { StatsReport::kStatsValueNameMinPlayoutDelayMs, - info.min_playout_delay_ms }, - { StatsReport::kStatsValueNameNacksSent, info.nacks_sent }, - { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, - { StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd }, - { StatsReport::kStatsValueNamePlisSent, info.plis_sent }, - { StatsReport::kStatsValueNameRenderDelayMs, info.render_delay_ms }, - { StatsReport::kStatsValueNameTargetDelayMs, info.target_delay_ms }, - { StatsReport::kStatsValueNameFramesDecoded, info.frames_decoded }, + {StatsReport::kStatsValueNameCurrentDelayMs, info.current_delay_ms}, + {StatsReport::kStatsValueNameDecodeMs, info.decode_ms}, + {StatsReport::kStatsValueNameFirsSent, info.firs_sent}, + {StatsReport::kStatsValueNameFrameHeightReceived, info.frame_height}, + {StatsReport::kStatsValueNameFrameRateDecoded, info.framerate_decoded}, + {StatsReport::kStatsValueNameFrameRateOutput, info.framerate_output}, + {StatsReport::kStatsValueNameFrameRateReceived, info.framerate_rcvd}, + {StatsReport::kStatsValueNameFrameWidthReceived, info.frame_width}, + {StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms}, + {StatsReport::kStatsValueNameMaxDecodeMs, info.max_decode_ms}, + {StatsReport::kStatsValueNameMinPlayoutDelayMs, + info.min_playout_delay_ms}, + {StatsReport::kStatsValueNameNacksSent, info.nacks_sent}, + {StatsReport::kStatsValueNamePacketsLost, info.packets_lost}, + {StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd}, + {StatsReport::kStatsValueNamePlisSent, info.plis_sent}, + {StatsReport::kStatsValueNameRenderDelayMs, info.render_delay_ms}, + {StatsReport::kStatsValueNameTargetDelayMs, info.target_delay_ms}, + {StatsReport::kStatsValueNameFramesDecoded, info.frames_decoded}, }; for (const auto& i : ints) @@ -345,14 +341,14 @@ void ExtractStats(const cricket::BandwidthEstimationInfo& info, report->set_timestamp(stats_gathering_started); const IntForAdd ints[] = { - { StatsReport::kStatsValueNameAvailableSendBandwidth, - info.available_send_bandwidth }, - { StatsReport::kStatsValueNameAvailableReceiveBandwidth, - info.available_recv_bandwidth }, - { StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate }, - { StatsReport::kStatsValueNameActualEncBitrate, info.actual_enc_bitrate }, - { StatsReport::kStatsValueNameRetransmitBitrate, info.retransmit_bitrate }, - { StatsReport::kStatsValueNameTransmitBitrate, info.transmit_bitrate }, + {StatsReport::kStatsValueNameAvailableSendBandwidth, + info.available_send_bandwidth}, + {StatsReport::kStatsValueNameAvailableReceiveBandwidth, + info.available_recv_bandwidth}, + {StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate}, + {StatsReport::kStatsValueNameActualEncBitrate, info.actual_enc_bitrate}, + {StatsReport::kStatsValueNameRetransmitBitrate, info.retransmit_bitrate}, + {StatsReport::kStatsValueNameTransmitBitrate, info.transmit_bitrate}, }; for (const auto& i : ints) report->AddInt(i.name, i.value); @@ -375,7 +371,7 @@ void ExtractRemoteStats(const cricket::MediaReceiverInfo& info, // In order to use the template, the functions that are called from it, // ExtractStats and ExtractRemoteStats, must be defined and overloaded // for each type. -template +template void ExtractStatsFromList(const std::vector& data, const StatsReport::Id& transport_id, StatsCollector* collector, @@ -384,8 +380,8 @@ void ExtractStatsFromList(const std::vector& data, uint32_t ssrc = d.ssrc(); // Each track can have stats for both local and remote objects. // TODO(hta): Handle the case of multiple SSRCs per object. - StatsReport* report = collector->PrepareReport(true, ssrc, transport_id, - direction); + StatsReport* report = + collector->PrepareReport(true, ssrc, transport_id, direction); if (report) ExtractStats(d, report); @@ -529,8 +525,8 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track, if (report) reports->push_back(report); - report = reports_.Find(StatsReport::NewTypedId( - StatsReport::kStatsReportTypeTrack, track->id())); + report = reports_.Find( + StatsReport::NewTypedId(StatsReport::kStatsReportTypeTrack, track->id())); if (!report) return; @@ -549,8 +545,8 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track, } } -void -StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) { +void StatsCollector::UpdateStats( + PeerConnectionInterface::StatsOutputLevel level) { RTC_DCHECK(pc_->signaling_thread()->IsCurrent()); double time_now = GetTimeNow(); // Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of @@ -576,11 +572,10 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) { UpdateTrackReports(); } -StatsReport* StatsCollector::PrepareReport( - bool local, - uint32_t ssrc, - const StatsReport::Id& transport_id, - StatsReport::Direction direction) { +StatsReport* StatsCollector::PrepareReport(bool local, + uint32_t ssrc, + const StatsReport::Id& transport_id, + StatsReport::Direction direction) { RTC_DCHECK(pc_->signaling_thread()->IsCurrent()); StatsReport::Id id(StatsReport::NewIdWithDirection( local ? StatsReport::kStatsReportTypeSsrc @@ -652,18 +647,20 @@ StatsReport* StatsCollector::AddCertificateReports( } StatsReport* StatsCollector::AddConnectionInfoReport( - const std::string& content_name, int component, int connection_id, + const std::string& content_name, + int component, + int connection_id, const StatsReport::Id& channel_report_id, const cricket::ConnectionInfo& info) { - StatsReport::Id id(StatsReport::NewCandidatePairId(content_name, component, - connection_id)); + StatsReport::Id id( + StatsReport::NewCandidatePairId(content_name, component, connection_id)); StatsReport* report = reports_.ReplaceOrAddNew(id); report->set_timestamp(stats_gathering_started_); const BoolForAdd bools[] = { - {StatsReport::kStatsValueNameActiveConnection, info.best_connection}, - {StatsReport::kStatsValueNameReceiving, info.receiving}, - {StatsReport::kStatsValueNameWritable, info.writable}, + {StatsReport::kStatsValueNameActiveConnection, info.best_connection}, + {StatsReport::kStatsValueNameReceiving, info.receiving}, + {StatsReport::kStatsValueNameWritable, info.writable}, }; for (const auto& b : bools) report->AddBoolean(b.name, b.value); @@ -842,7 +839,7 @@ void StatsCollector::ExtractSessionInfo() { int connection_id = 0; for (const cricket::ConnectionInfo& info : - channel_iter.connection_infos) { + channel_iter.connection_infos) { StatsReport* connection_report = AddConnectionInfoReport( transport_name, channel_iter.component, connection_id++, channel_report->id(), info); diff --git a/pc/statscollector.h b/pc/statscollector.h index 1ed650d2a0..a3c5992afc 100644 --- a/pc/statscollector.h +++ b/pc/statscollector.h @@ -69,8 +69,7 @@ class StatsCollector { // of filling in |reports|. As is, there's a requirement that the caller // uses |reports| immediately without allowing any async activity on // the thread (message handling etc) and then discard the results. - void GetStats(MediaStreamTrackInterface* track, - StatsReports* reports); + void GetStats(MediaStreamTrackInterface* track, StatsReports* reports); // Prepare a local or remote SSRC report for the given ssrc. Used internally // in the ExtractStatsFromList template. @@ -107,9 +106,10 @@ class StatsCollector { std::unique_ptr cert_stats); StatsReport* AddConnectionInfoReport(const std::string& content_name, - int component, int connection_id, - const StatsReport::Id& channel_report_id, - const cricket::ConnectionInfo& info); + int component, + int connection_id, + const StatsReport::Id& channel_report_id, + const cricket::ConnectionInfo& info); void ExtractDataInfo(); void ExtractSessionInfo(); diff --git a/pc/statscollector_unittest.cc b/pc/statscollector_unittest.cc index ffb0a5a127..58fdb8002c 100644 --- a/pc/statscollector_unittest.cc +++ b/pc/statscollector_unittest.cc @@ -194,8 +194,9 @@ StatsReport::Id IdFromCertIdString(const std::string& cert_id) { // Finds the |n|-th report of type |type| in |reports|. // |n| starts from 1 for finding the first report. -const StatsReport* FindNthReportByType( - const StatsReports& reports, const StatsReport::StatsType& type, int n) { +const StatsReport* FindNthReportByType(const StatsReports& reports, + const StatsReport::StatsType& type, + int n) { for (size_t i = 0; i < reports.size(); ++i) { if (reports[i]->type() == type) { n--; @@ -222,19 +223,16 @@ std::string ExtractSsrcStatsValue(const StatsReports& reports, std::string ExtractBweStatsValue(const StatsReports& reports, StatsReport::StatsValueName name) { - return ExtractStatsValue( - StatsReport::kStatsReportTypeBwe, reports, name); + return ExtractStatsValue(StatsReport::kStatsReportTypeBwe, reports, name); } std::string DerToPem(const std::string& der) { return rtc::SSLIdentity::DerToPem( - rtc::kPemTypeCertificate, - reinterpret_cast(der.c_str()), - der.length()); + rtc::kPemTypeCertificate, + reinterpret_cast(der.c_str()), der.length()); } -std::vector DersToPems( - const std::vector& ders) { +std::vector DersToPems(const std::vector& ders) { std::vector pems(ders.size()); std::transform(ders.begin(), ders.end(), pems.begin(), DerToPem); return pems; @@ -251,16 +249,14 @@ void CheckCertChainReports(const StatsReports& reports, ASSERT_TRUE(report != NULL); std::string der_base64; - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDer, &der_base64)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDer, &der_base64)); std::string der = rtc::Base64::Decode(der_base64, rtc::Base64::DO_STRICT); EXPECT_EQ(ders[i], der); std::string fingerprint_algorithm; - EXPECT_TRUE(GetValue( - report, - StatsReport::kStatsValueNameFingerprintAlgorithm, - &fingerprint_algorithm)); + EXPECT_TRUE(GetValue(report, + StatsReport::kStatsValueNameFingerprintAlgorithm, + &fingerprint_algorithm)); // The digest algorithm for a FakeSSLCertificate is always SHA-1. std::string sha_1_str = rtc::DIGEST_SHA_1; EXPECT_EQ(sha_1_str, fingerprint_algorithm); @@ -272,8 +268,7 @@ void CheckCertChainReports(const StatsReports& reports, ++i; std::string issuer_id; - if (!GetValue(report, StatsReport::kStatsValueNameIssuerId, - &issuer_id)) { + if (!GetValue(report, StatsReport::kStatsValueNameIssuerId, &issuer_id)) { break; } @@ -283,35 +278,34 @@ void CheckCertChainReports(const StatsReports& reports, EXPECT_EQ(ders.size(), i); } -void VerifyVoiceReceiverInfoReport( - const StatsReport* report, - const cricket::VoiceReceiverInfo& info) { +void VerifyVoiceReceiverInfoReport(const StatsReport* report, + const cricket::VoiceReceiverInfo& info) { std::string value_in_report; - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameAudioOutputLevel, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameAudioOutputLevel, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.audio_level), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameBytesReceived, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameBytesReceived, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.bytes_rcvd), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameJitterReceived, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameJitterReceived, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.jitter_ms), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameJitterBufferMs, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameJitterBufferMs, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.jitter_buffer_ms), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNamePreferredJitterBufferMs, - &value_in_report)); + EXPECT_TRUE(GetValue(report, + StatsReport::kStatsValueNamePreferredJitterBufferMs, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.jitter_buffer_preferred_ms), - value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameCurrentDelayMs, &value_in_report)); + value_in_report); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameCurrentDelayMs, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.delay_estimate_ms), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameExpandRate, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameExpandRate, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.expand_rate), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameSpeechExpandRate, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameSpeechExpandRate, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.speech_expand_rate), value_in_report); EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameAccelerateRate, &value_in_report)); @@ -327,28 +321,27 @@ void VerifyVoiceReceiverInfoReport( &value_in_report)); EXPECT_EQ(rtc::ToString(info.secondary_discarded_rate), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNamePacketsReceived, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNamePacketsReceived, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.packets_rcvd), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDecodingCTSG, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingCTSG, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.decoding_calls_to_silence_generator), - value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDecodingCTN, &value_in_report)); - EXPECT_EQ(rtc::ToString(info.decoding_calls_to_neteq), - value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDecodingNormal, &value_in_report)); + value_in_report); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingCTN, + &value_in_report)); + EXPECT_EQ(rtc::ToString(info.decoding_calls_to_neteq), value_in_report); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingNormal, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.decoding_normal), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDecodingPLC, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingPLC, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.decoding_plc), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDecodingCNG, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingCNG, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.decoding_cng), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameDecodingPLCCNG, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingPLCCNG, + &value_in_report)); EXPECT_EQ(rtc::ToString(info.decoding_plc_cng), value_in_report); EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDecodingMutedOutput, &value_in_report)); @@ -357,30 +350,29 @@ void VerifyVoiceReceiverInfoReport( &value_in_report)); } - void VerifyVoiceSenderInfoReport(const StatsReport* report, const cricket::VoiceSenderInfo& sinfo) { std::string value_in_report; - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameCodecName, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameCodecName, + &value_in_report)); EXPECT_EQ(sinfo.codec_name, value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameBytesSent, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameBytesSent, + &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.bytes_sent), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNamePacketsSent, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNamePacketsSent, + &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.packets_sent), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNamePacketsLost, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNamePacketsLost, + &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.packets_lost), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameRtt, &value_in_report)); + EXPECT_TRUE( + GetValue(report, StatsReport::kStatsValueNameRtt, &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.rtt_ms), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameRtt, &value_in_report)); + EXPECT_TRUE( + GetValue(report, StatsReport::kStatsValueNameRtt, &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.rtt_ms), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameJitterReceived, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameJitterReceived, + &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.jitter_ms), value_in_report); if (sinfo.apm_statistics.delay_median_ms) { EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameEchoDelayMedian, @@ -449,8 +441,8 @@ void VerifyVoiceSenderInfoReport(const StatsReport* report, EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameAudioInputLevel, &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.audio_level), value_in_report); - EXPECT_TRUE(GetValue( - report, StatsReport::kStatsValueNameTypingNoiseState, &value_in_report)); + EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameTypingNoiseState, + &value_in_report)); std::string typing_detected = sinfo.typing_noise_detected ? "true" : "false"; EXPECT_EQ(typing_detected, value_in_report); EXPECT_TRUE(GetValue(report, @@ -564,9 +556,7 @@ class StatsCollectorForTest : public StatsCollector { explicit StatsCollectorForTest(PeerConnectionInternal* pc) : StatsCollector(pc), time_now_(19477) {} - double GetTimeNow() override { - return time_now_; - } + double GetTimeNow() override { return time_now_; } private: double time_now_; @@ -592,19 +582,19 @@ class StatsCollectorTest : public testing::Test { stats->GetStats(nullptr, reports); // Verify the existence of the track report. - const StatsReport* report = FindNthReportByType( - *reports, StatsReport::kStatsReportTypeSsrc, 1); + const StatsReport* report = + FindNthReportByType(*reports, StatsReport::kStatsReportTypeSsrc, 1); ASSERT_TRUE(report); EXPECT_EQ(stats->GetTimeNow(), report->timestamp()); - std::string track_id = ExtractSsrcStatsValue( - *reports, StatsReport::kStatsValueNameTrackId); + std::string track_id = + ExtractSsrcStatsValue(*reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(audio_track->id(), track_id); - std::string ssrc_id = ExtractSsrcStatsValue( - *reports, StatsReport::kStatsValueNameSsrc); + std::string ssrc_id = + ExtractSsrcStatsValue(*reports, StatsReport::kStatsValueNameSsrc); EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); - std::string media_type = ExtractSsrcStatsValue(*reports, - StatsReport::kStatsValueNameMediaType); + std::string media_type = + ExtractSsrcStatsValue(*reports, StatsReport::kStatsValueNameMediaType); EXPECT_EQ("audio", media_type); // Verifies the values in the track report. @@ -625,8 +615,8 @@ class StatsCollectorTest : public testing::Test { track_id = ExtractSsrcStatsValue(track_reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(audio_track->id(), track_id); - ssrc_id = ExtractSsrcStatsValue(track_reports, - StatsReport::kStatsValueNameSsrc); + ssrc_id = + ExtractSsrcStatsValue(track_reports, StatsReport::kStatsValueNameSsrc); EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); if (!voice_info.senders.empty()) { VerifyVoiceSenderInfoReport(track_report, voice_info.senders[0]); @@ -668,15 +658,14 @@ class StatsCollectorTest : public testing::Test { StatsReports reports; stats->GetStats(nullptr, &reports); - const StatsReport* channel_report = FindNthReportByType( - reports, StatsReport::kStatsReportTypeComponent, 1); + const StatsReport* channel_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeComponent, 1); EXPECT_TRUE(channel_report); // Check local certificate chain. - std::string local_certificate_id = ExtractStatsValue( - StatsReport::kStatsReportTypeComponent, - reports, - StatsReport::kStatsValueNameLocalCertificateId); + std::string local_certificate_id = + ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports, + StatsReport::kStatsValueNameLocalCertificateId); if (local_ders.size() > 0) { EXPECT_NE(kNotFound, local_certificate_id); StatsReport::Id id(IdFromCertIdString(local_certificate_id)); @@ -686,10 +675,9 @@ class StatsCollectorTest : public testing::Test { } // Check remote certificate chain. - std::string remote_certificate_id = ExtractStatsValue( - StatsReport::kStatsReportTypeComponent, - reports, - StatsReport::kStatsValueNameRemoteCertificateId); + std::string remote_certificate_id = + ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports, + StatsReport::kStatsValueNameRemoteCertificateId); if (remote_ders.size() > 0) { EXPECT_NE(kNotFound, remote_certificate_id); StatsReport::Id id(IdFromCertIdString(remote_certificate_id)); @@ -841,9 +829,9 @@ TEST_F(StatsCollectorTest, ExtractDataInfo) { EXPECT_EQ(kConnectingString, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports, StatsReport::kStatsValueNameState)); - EXPECT_EQ("", ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, - reports, - StatsReport::kStatsValueNameProtocol)); + EXPECT_EQ("", + ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports, + StatsReport::kStatsValueNameProtocol)); } // This test verifies that 64-bit counters are passed successfully. @@ -1018,8 +1006,7 @@ TEST_P(StatsCollectorTrackTest, TrackObjectExistsWithoutUpdateStats) { EXPECT_EQ(0, reports[0]->timestamp()); std::string trackValue = - ExtractStatsValue(StatsReport::kStatsReportTypeTrack, - reports, + ExtractStatsValue(StatsReport::kStatsReportTypeTrack, reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(kLocalTrackId, trackValue); } @@ -1050,8 +1037,8 @@ TEST_P(StatsCollectorTrackTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { // |reports| should contain at least one session report, one track report, // and one ssrc report. EXPECT_LE(3u, reports.size()); - const StatsReport* track_report = FindNthReportByType( - reports, StatsReport::kStatsReportTypeTrack, 1); + const StatsReport* track_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeTrack, 1); EXPECT_TRUE(track_report); // Get report for the specific |track|. @@ -1060,21 +1047,21 @@ TEST_P(StatsCollectorTrackTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { // |reports| should contain at least one session report, one track report, // and one ssrc report. EXPECT_LE(3u, reports.size()); - track_report = FindNthReportByType( - reports, StatsReport::kStatsReportTypeTrack, 1); + track_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeTrack, 1); ASSERT_TRUE(track_report); EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp()); - std::string ssrc_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameSsrc); + std::string ssrc_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameSsrc); EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); - std::string track_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameTrackId); + std::string track_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(kLocalTrackId, track_id); - std::string media_type = ExtractSsrcStatsValue(reports, - StatsReport::kStatsValueNameMediaType); + std::string media_type = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameMediaType); EXPECT_EQ("video", media_type); } @@ -1101,10 +1088,9 @@ TEST_P(StatsCollectorTrackTest, TransportObjectLinkedFromSsrcObject) { StatsReports reports; stats->GetStats(nullptr, &reports); - std::string transport_id = ExtractStatsValue( - StatsReport::kStatsReportTypeSsrc, - reports, - StatsReport::kStatsValueNameTransportId); + std::string transport_id = + ExtractStatsValue(StatsReport::kStatsReportTypeSsrc, reports, + StatsReport::kStatsValueNameTransportId); ASSERT_NE(kNotFound, transport_id); // Transport id component ID will always be 1. @@ -1136,8 +1122,8 @@ TEST_P(StatsCollectorTrackTest, RemoteSsrcInfoIsAbsent) { StatsReports reports; stats->GetStats(nullptr, &reports); - const StatsReport* remote_report = FindNthReportByType(reports, - StatsReport::kStatsReportTypeRemoteSsrc, 1); + const StatsReport* remote_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeRemoteSsrc, 1); EXPECT_FALSE(remote_report); } @@ -1165,8 +1151,8 @@ TEST_P(StatsCollectorTrackTest, RemoteSsrcInfoIsPresent) { StatsReports reports; stats->GetStats(nullptr, &reports); - const StatsReport* remote_report = FindNthReportByType(reports, - StatsReport::kStatsReportTypeRemoteSsrc, 1); + const StatsReport* remote_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeRemoteSsrc, 1); ASSERT_TRUE(remote_report); EXPECT_EQ(12345.678, remote_report->timestamp()); } @@ -1197,17 +1183,17 @@ TEST_P(StatsCollectorTrackTest, ReportsFromRemoteTrack) { // |reports| should contain at least one session report, one track report, // and one ssrc report. EXPECT_LE(3u, reports.size()); - const StatsReport* track_report = FindNthReportByType( - reports, StatsReport::kStatsReportTypeTrack, 1); + const StatsReport* track_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeTrack, 1); ASSERT_TRUE(track_report); EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp()); - std::string ssrc_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameSsrc); + std::string ssrc_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameSsrc); EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); - std::string track_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameTrackId); + std::string track_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(kRemoteTrackId, track_id); } @@ -1374,17 +1360,15 @@ TEST_F(StatsCollectorTest, NoTransport) { stats->GetStats(nullptr, &reports); // Check that the local certificate is absent. - std::string local_certificate_id = ExtractStatsValue( - StatsReport::kStatsReportTypeComponent, - reports, - StatsReport::kStatsValueNameLocalCertificateId); + std::string local_certificate_id = + ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports, + StatsReport::kStatsValueNameLocalCertificateId); ASSERT_EQ(kNotFound, local_certificate_id); // Check that the remote certificate is absent. - std::string remote_certificate_id = ExtractStatsValue( - StatsReport::kStatsReportTypeComponent, - reports, - StatsReport::kStatsValueNameRemoteCertificateId); + std::string remote_certificate_id = + ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports, + StatsReport::kStatsValueNameRemoteCertificateId); ASSERT_EQ(kNotFound, remote_certificate_id); // Check that the negotiated ciphers are absent. @@ -1530,8 +1514,8 @@ TEST_P(StatsCollectorTrackTest, GetStatsFromLocalAudioTrack) { // Verify that there is no remote report for the local audio track because // we did not set it up. - const StatsReport* remote_report = FindNthReportByType(reports, - StatsReport::kStatsReportTypeRemoteSsrc, 1); + const StatsReport* remote_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeRemoteSsrc, 1); EXPECT_TRUE(remote_report == NULL); } @@ -1580,15 +1564,15 @@ TEST_P(StatsCollectorTrackTest, GetStatsAfterRemoveAudioStream) { stats->GetStats(nullptr, &reports); // The report will exist since we don't remove them in RemoveStream(). - const StatsReport* report = FindNthReportByType( - reports, StatsReport::kStatsReportTypeSsrc, 1); + const StatsReport* report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeSsrc, 1); ASSERT_TRUE(report); EXPECT_EQ(stats->GetTimeNow(), report->timestamp()); - std::string track_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameTrackId); + std::string track_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(kLocalTrackId, track_id); - std::string ssrc_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameSsrc); + std::string ssrc_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameSsrc); EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); // Verifies the values in the track report, no value will be changed by the @@ -1641,24 +1625,24 @@ TEST_P(StatsCollectorTrackTest, LocalAndRemoteTracksWithSameSsrc) { StatsReports reports; // returned values. stats->GetStats(audio_track_.get(), &reports); - const StatsReport* track_report = FindNthReportByType( - reports, StatsReport::kStatsReportTypeSsrc, 1); + const StatsReport* track_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeSsrc, 1); ASSERT_TRUE(track_report); EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp()); - std::string track_id = ExtractSsrcStatsValue( - reports, StatsReport::kStatsValueNameTrackId); + std::string track_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(kLocalTrackId, track_id); VerifyVoiceSenderInfoReport(track_report, voice_sender_info); // Get stats for the remote track. reports.clear(); stats->GetStats(remote_track.get(), &reports); - track_report = FindNthReportByType(reports, - StatsReport::kStatsReportTypeSsrc, 1); + track_report = + FindNthReportByType(reports, StatsReport::kStatsReportTypeSsrc, 1); ASSERT_TRUE(track_report); EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp()); - track_id = ExtractSsrcStatsValue(reports, - StatsReport::kStatsValueNameTrackId); + track_id = + ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameTrackId); EXPECT_EQ(kRemoteTrackId, track_id); VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); } diff --git a/pc/streamcollection.h b/pc/streamcollection.h index 4c6f0b19c6..76317f91e1 100644 --- a/pc/streamcollection.h +++ b/pc/streamcollection.h @@ -23,20 +23,18 @@ class StreamCollection : public StreamCollectionInterface { public: static rtc::scoped_refptr Create() { rtc::RefCountedObject* implementation = - new rtc::RefCountedObject(); + new rtc::RefCountedObject(); return implementation; } static rtc::scoped_refptr Create( StreamCollection* streams) { rtc::RefCountedObject* implementation = - new rtc::RefCountedObject(streams); + new rtc::RefCountedObject(streams); return implementation; } - virtual size_t count() { - return media_streams_.size(); - } + virtual size_t count() { return media_streams_.size(); } virtual MediaStreamInterface* at(size_t index) { return media_streams_.at(index); @@ -52,8 +50,7 @@ class StreamCollection : public StreamCollectionInterface { return NULL; } - virtual MediaStreamTrackInterface* FindAudioTrack( - const std::string& id) { + virtual MediaStreamTrackInterface* FindAudioTrack(const std::string& id) { for (size_t i = 0; i < media_streams_.size(); ++i) { MediaStreamTrackInterface* track = media_streams_[i]->FindAudioTrack(id); if (track) { @@ -63,8 +60,7 @@ class StreamCollection : public StreamCollectionInterface { return NULL; } - virtual MediaStreamTrackInterface* FindVideoTrack( - const std::string& id) { + virtual MediaStreamTrackInterface* FindVideoTrack(const std::string& id) { for (size_t i = 0; i < media_streams_.size(); ++i) { MediaStreamTrackInterface* track = media_streams_[i]->FindVideoTrack(id); if (track) { @@ -96,10 +92,8 @@ class StreamCollection : public StreamCollectionInterface { protected: StreamCollection() {} explicit StreamCollection(StreamCollection* original) - : media_streams_(original->media_streams_) { - } - typedef std::vector > - StreamVector; + : media_streams_(original->media_streams_) {} + typedef std::vector > StreamVector; StreamVector media_streams_; }; diff --git a/pc/test/androidtestinitializer.cc b/pc/test/androidtestinitializer.cc index f39a3e7dd6..a67716dc23 100644 --- a/pc/test/androidtestinitializer.cc +++ b/pc/test/androidtestinitializer.cc @@ -12,7 +12,6 @@ #include - #include "rtc_base/ignore_wundef.h" // Note: this dependency is dangerous since it reaches into Chromium's base. @@ -23,7 +22,6 @@ RTC_PUSH_IGNORING_WUNDEF() #include "base/android/jni_android.h" RTC_POP_IGNORING_WUNDEF() - #include "modules/utility/include/jvm_android.h" #include "rtc_base/checks.h" diff --git a/pc/test/fakeaudiocapturemodule.cc b/pc/test/fakeaudiocapturemodule.cc index a129ae5f73..c9c19f1027 100644 --- a/pc/test/fakeaudiocapturemodule.cc +++ b/pc/test/fakeaudiocapturemodule.cc @@ -45,8 +45,7 @@ FakeAudioCaptureModule::FakeAudioCaptureModule() current_mic_level_(kMaxVolume), started_(false), next_frame_time_(0), - frames_received_(0) { -} + frames_received_(0) {} FakeAudioCaptureModule::~FakeAudioCaptureModule() { if (process_thread_) { @@ -426,7 +425,8 @@ bool FakeAudioCaptureModule::CheckRecBuffer(int value) { const size_t buffer_size_in_samples = sizeof(rec_buffer_) / kNumberBytesPerSample; for (size_t i = 0; i < buffer_size_in_samples; ++i) { - if (buffer_ptr[i] >= value) return true; + if (buffer_ptr[i] >= value) + return true; } return false; } @@ -496,10 +496,10 @@ void FakeAudioCaptureModule::ReceiveFrameP() { size_t nSamplesOut = 0; int64_t elapsed_time_ms = 0; int64_t ntp_time_ms = 0; - if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, - kNumberOfChannels, kSamplesPerSecond, - rec_buffer_, nSamplesOut, - &elapsed_time_ms, &ntp_time_ms) != 0) { + if (audio_callback_->NeedMorePlayData( + kNumberSamples, kNumberBytesPerSample, kNumberOfChannels, + kSamplesPerSecond, rec_buffer_, nSamplesOut, &elapsed_time_ms, + &ntp_time_ms) != 0) { RTC_NOTREACHED(); } RTC_CHECK(nSamplesOut == kNumberSamples); @@ -525,13 +525,10 @@ void FakeAudioCaptureModule::SendFrameP() { bool key_pressed = false; uint32_t current_mic_level = 0; MicrophoneVolume(¤t_mic_level); - if (audio_callback_->RecordedDataIsAvailable(send_buffer_, kNumberSamples, - kNumberBytesPerSample, - kNumberOfChannels, - kSamplesPerSecond, kTotalDelayMs, - kClockDriftMs, current_mic_level, - key_pressed, - current_mic_level) != 0) { + if (audio_callback_->RecordedDataIsAvailable( + send_buffer_, kNumberSamples, kNumberBytesPerSample, + kNumberOfChannels, kSamplesPerSecond, kTotalDelayMs, kClockDriftMs, + current_mic_level, key_pressed, current_mic_level) != 0) { RTC_NOTREACHED(); } SetMicrophoneVolume(current_mic_level); diff --git a/pc/test/fakeaudiocapturemodule.h b/pc/test/fakeaudiocapturemodule.h index a1709dd777..2f56ef4d5d 100644 --- a/pc/test/fakeaudiocapturemodule.h +++ b/pc/test/fakeaudiocapturemodule.h @@ -32,9 +32,8 @@ namespace rtc { class Thread; } // namespace rtc -class FakeAudioCaptureModule - : public webrtc::AudioDeviceModule, - public rtc::MessageHandler { +class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, + public rtc::MessageHandler { public: typedef uint16_t Sample; diff --git a/pc/test/fakeaudiocapturemodule_unittest.cc b/pc/test/fakeaudiocapturemodule_unittest.cc index 28d6b282a3..6ef7685347 100644 --- a/pc/test/fakeaudiocapturemodule_unittest.cc +++ b/pc/test/fakeaudiocapturemodule_unittest.cc @@ -18,15 +18,12 @@ using std::min; -class FakeAdmTest : public testing::Test, - public webrtc::AudioTransport { +class FakeAdmTest : public testing::Test, public webrtc::AudioTransport { protected: static const int kMsInSecond = 1000; FakeAdmTest() - : push_iterations_(0), - pull_iterations_(0), - rec_buffer_bytes_(0) { + : push_iterations_(0), pull_iterations_(0), rec_buffer_bytes_(0) { memset(rec_buffer_, 0, sizeof(rec_buffer_)); } @@ -50,8 +47,9 @@ class FakeAdmTest : public testing::Test, rtc::CritScope cs(&crit_); rec_buffer_bytes_ = nSamples * nBytesPerSample; if ((rec_buffer_bytes_ == 0) || - (rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples * - FakeAudioCaptureModule::kNumberBytesPerSample)) { + (rec_buffer_bytes_ > + FakeAudioCaptureModule::kNumberSamples * + FakeAudioCaptureModule::kNumberBytesPerSample)) { ADD_FAILURE(); return -1; } @@ -81,9 +79,10 @@ class FakeAdmTest : public testing::Test, rtc::CritScope cs(&crit_); ++pull_iterations_; const size_t audio_buffer_size = nSamples * nBytesPerSample; - const size_t bytes_out = RecordedDataReceived() ? - CopyFromRecBuffer(audioSamples, audio_buffer_size): - GenerateZeroBuffer(audioSamples, audio_buffer_size); + const size_t bytes_out = + RecordedDataReceived() + ? CopyFromRecBuffer(audioSamples, audio_buffer_size) + : GenerateZeroBuffer(audioSamples, audio_buffer_size); nSamplesOut = bytes_out / nBytesPerSample; *elapsed_time_ms = 0; *ntp_time_ms = 0; @@ -102,9 +101,7 @@ class FakeAdmTest : public testing::Test, rtc::scoped_refptr fake_audio_capture_module_; private: - bool RecordedDataReceived() const { - return rec_buffer_bytes_ != 0; - } + bool RecordedDataReceived() const { return rec_buffer_bytes_ != 0; } size_t GenerateZeroBuffer(void* audio_buffer, size_t audio_buffer_size) { memset(audio_buffer, 0, audio_buffer_size); return audio_buffer_size; @@ -130,9 +127,8 @@ TEST_F(FakeAdmTest, PlayoutTest) { EXPECT_EQ(0, fake_audio_capture_module_->RegisterAudioCallback(this)); bool stereo_available = false; - EXPECT_EQ(0, - fake_audio_capture_module_->StereoPlayoutIsAvailable( - &stereo_available)); + EXPECT_EQ(0, fake_audio_capture_module_->StereoPlayoutIsAvailable( + &stereo_available)); EXPECT_TRUE(stereo_available); EXPECT_NE(0, fake_audio_capture_module_->StartPlayout()); @@ -163,7 +159,7 @@ TEST_F(FakeAdmTest, RecordTest) { bool stereo_available = false; EXPECT_EQ(0, fake_audio_capture_module_->StereoRecordingIsAvailable( - &stereo_available)); + &stereo_available)); EXPECT_FALSE(stereo_available); EXPECT_NE(0, fake_audio_capture_module_->StartRecording()); diff --git a/pc/test/fakedatachannelprovider.h b/pc/test/fakedatachannelprovider.h index 7e68f5fb85..83c5cb3924 100644 --- a/pc/test/fakedatachannelprovider.h +++ b/pc/test/fakedatachannelprovider.h @@ -95,7 +95,7 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { // each value is still in connected_channels_ before calling // OnChannelReady(). This avoids problems where the set gets modified // in response to OnChannelReady(). - for (webrtc::DataChannel *ch : std::set( + for (webrtc::DataChannel* ch : std::set( connected_channels_.begin(), connected_channels_.end())) { if (connected_channels_.count(ch)) { ch->OnChannelReady(true); @@ -117,17 +117,14 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { ready_to_send_ = ready; if (ready) { std::set::iterator it; - for (it = connected_channels_.begin(); - it != connected_channels_.end(); + for (it = connected_channels_.begin(); it != connected_channels_.end(); ++it) { (*it)->OnChannelReady(true); } } } - void set_transport_error() { - transport_error_ = true; - } + void set_transport_error() { transport_error_ = true; } cricket::SendDataParams last_send_data_params() const { return last_send_data_params_; diff --git a/pc/test/fakeperiodicvideotracksource.h b/pc/test/fakeperiodicvideotracksource.h index 8cdac0e99c..ab428d806a 100644 --- a/pc/test/fakeperiodicvideotracksource.h +++ b/pc/test/fakeperiodicvideotracksource.h @@ -11,8 +11,8 @@ #ifndef PC_TEST_FAKEPERIODICVIDEOTRACKSOURCE_H_ #define PC_TEST_FAKEPERIODICVIDEOTRACKSOURCE_H_ -#include "pc/videotracksource.h" #include "pc/test/fakeperiodicvideosource.h" +#include "pc/videotracksource.h" namespace webrtc { diff --git a/pc/test/fakertccertificategenerator.h b/pc/test/fakertccertificategenerator.h index 9cc79284ea..bb56f3e5bc 100644 --- a/pc/test/fakertccertificategenerator.h +++ b/pc/test/fakertccertificategenerator.h @@ -23,64 +23,63 @@ static const rtc::RTCCertificatePEM kRsaPems[] = { rtc::RTCCertificatePEM( "-----BEGIN RSA PRIVATE KEY-----\n" - "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMYRkbhmI7kVA/rM\n" - "czsZ+6JDhDvnkF+vn6yCAGuRPV03zuRqZtDy4N4to7PZu9PjqrRl7nDMXrG3YG9y\n" - "rlIAZ72KjcKKFAJxQyAKLCIdawKRyp8RdK3LEySWEZb0AV58IadqPZDTNHHRX8dz\n" - "5aTSMsbbkZ+C/OzTnbiMqLL/vg6jAgMBAAECgYAvgOs4FJcgvp+TuREx7YtiYVsH\n" - "mwQPTum2z/8VzWGwR8BBHBvIpVe1MbD/Y4seyI2aco/7UaisatSgJhsU46/9Y4fq\n" - "2TwXH9QANf4at4d9n/R6rzwpAJOpgwZgKvdQjkfrKTtgLV+/dawvpxUYkRH4JZM1\n" - "CVGukMfKNrSVH4Ap4QJBAOJmGV1ASPnB4r4nc99at7JuIJmd7fmuVUwUgYi4XgaR\n" - "WhScBsgYwZ/JoywdyZJgnbcrTDuVcWG56B3vXbhdpMsCQQDf9zeJrjnPZ3Cqm79y\n" - "kdqANep0uwZciiNiWxsQrCHztywOvbFhdp8iYVFG9EK8DMY41Y5TxUwsHD+67zao\n" - "ZNqJAkEA1suLUP/GvL8IwuRneQd2tWDqqRQ/Td3qq03hP7e77XtF/buya3Ghclo5\n" - "54czUR89QyVfJEC6278nzA7n2h1uVQJAcG6mztNL6ja/dKZjYZye2CY44QjSlLo0\n" - "MTgTSjdfg/28fFn2Jjtqf9Pi/X+50LWI/RcYMC2no606wRk9kyOuIQJBAK6VSAim\n" - "1pOEjsYQn0X5KEIrz1G3bfCbB848Ime3U2/FWlCHMr6ch8kCZ5d1WUeJD3LbwMNG\n" - "UCXiYxSsu20QNVw=\n" - "-----END RSA PRIVATE KEY-----\n", - "-----BEGIN CERTIFICATE-----\n" - "MIIBmTCCAQKgAwIBAgIEbzBSAjANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDEwZX\n" - "ZWJSVEMwHhcNMTQwMTAyMTgyNDQ3WhcNMTQwMjAxMTgyNDQ3WjARMQ8wDQYDVQQD\n" - "EwZXZWJSVEMwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMYRkbhmI7kVA/rM\n" - "czsZ+6JDhDvnkF+vn6yCAGuRPV03zuRqZtDy4N4to7PZu9PjqrRl7nDMXrG3YG9y\n" - "rlIAZ72KjcKKFAJxQyAKLCIdawKRyp8RdK3LEySWEZb0AV58IadqPZDTNHHRX8dz\n" - "5aTSMsbbkZ+C/OzTnbiMqLL/vg6jAgMBAAEwDQYJKoZIhvcNAQELBQADgYEAUflI\n" - "VUe5Krqf5RVa5C3u/UTAOAUJBiDS3VANTCLBxjuMsvqOG0WvaYWP3HYPgrz0jXK2\n" - "LJE/mGw3MyFHEqi81jh95J+ypl6xKW6Rm8jKLR87gUvCaVYn/Z4/P3AqcQTB7wOv\n" - "UD0A8qfhfDM+LK6rPAnCsVN0NRDY3jvd6rzix9M=\n" - "-----END CERTIFICATE-----\n"), + "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMYRkbhmI7kVA/rM\n" + "czsZ+6JDhDvnkF+vn6yCAGuRPV03zuRqZtDy4N4to7PZu9PjqrRl7nDMXrG3YG9y\n" + "rlIAZ72KjcKKFAJxQyAKLCIdawKRyp8RdK3LEySWEZb0AV58IadqPZDTNHHRX8dz\n" + "5aTSMsbbkZ+C/OzTnbiMqLL/vg6jAgMBAAECgYAvgOs4FJcgvp+TuREx7YtiYVsH\n" + "mwQPTum2z/8VzWGwR8BBHBvIpVe1MbD/Y4seyI2aco/7UaisatSgJhsU46/9Y4fq\n" + "2TwXH9QANf4at4d9n/R6rzwpAJOpgwZgKvdQjkfrKTtgLV+/dawvpxUYkRH4JZM1\n" + "CVGukMfKNrSVH4Ap4QJBAOJmGV1ASPnB4r4nc99at7JuIJmd7fmuVUwUgYi4XgaR\n" + "WhScBsgYwZ/JoywdyZJgnbcrTDuVcWG56B3vXbhdpMsCQQDf9zeJrjnPZ3Cqm79y\n" + "kdqANep0uwZciiNiWxsQrCHztywOvbFhdp8iYVFG9EK8DMY41Y5TxUwsHD+67zao\n" + "ZNqJAkEA1suLUP/GvL8IwuRneQd2tWDqqRQ/Td3qq03hP7e77XtF/buya3Ghclo5\n" + "54czUR89QyVfJEC6278nzA7n2h1uVQJAcG6mztNL6ja/dKZjYZye2CY44QjSlLo0\n" + "MTgTSjdfg/28fFn2Jjtqf9Pi/X+50LWI/RcYMC2no606wRk9kyOuIQJBAK6VSAim\n" + "1pOEjsYQn0X5KEIrz1G3bfCbB848Ime3U2/FWlCHMr6ch8kCZ5d1WUeJD3LbwMNG\n" + "UCXiYxSsu20QNVw=\n" + "-----END RSA PRIVATE KEY-----\n", + "-----BEGIN CERTIFICATE-----\n" + "MIIBmTCCAQKgAwIBAgIEbzBSAjANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDEwZX\n" + "ZWJSVEMwHhcNMTQwMTAyMTgyNDQ3WhcNMTQwMjAxMTgyNDQ3WjARMQ8wDQYDVQQD\n" + "EwZXZWJSVEMwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMYRkbhmI7kVA/rM\n" + "czsZ+6JDhDvnkF+vn6yCAGuRPV03zuRqZtDy4N4to7PZu9PjqrRl7nDMXrG3YG9y\n" + "rlIAZ72KjcKKFAJxQyAKLCIdawKRyp8RdK3LEySWEZb0AV58IadqPZDTNHHRX8dz\n" + "5aTSMsbbkZ+C/OzTnbiMqLL/vg6jAgMBAAEwDQYJKoZIhvcNAQELBQADgYEAUflI\n" + "VUe5Krqf5RVa5C3u/UTAOAUJBiDS3VANTCLBxjuMsvqOG0WvaYWP3HYPgrz0jXK2\n" + "LJE/mGw3MyFHEqi81jh95J+ypl6xKW6Rm8jKLR87gUvCaVYn/Z4/P3AqcQTB7wOv\n" + "UD0A8qfhfDM+LK6rPAnCsVN0NRDY3jvd6rzix9M=\n" + "-----END CERTIFICATE-----\n"), rtc::RTCCertificatePEM( - "-----BEGIN RSA PRIVATE KEY-----\n" - "MIICXQIBAAKBgQDeYqlyJ1wuiMsi905e3X81/WA/G3ym50PIDZBVtSwZi7JVQPgj\n" - "Bl8CPZMvDh9EwB4Ji9ytA8dZZbQ4WbJWPr73zPpJSCvQqz6sOXSlenBRi72acNaQ\n" - "sOR/qPvviJx5I6Hqo4qemfnjZhAW85a5BpgrAwKgMLIQTHCTLWwVSyrDrwIDAQAB\n" - "AoGARni9eY8/hv+SX+I+05EdXt6MQXNUbQ+cSykBNCfVccLzIFEWUQMT2IHqwl6X\n" - "ShIXcq7/n1QzOAEiuzixauM3YHg4xZ1Um2Ha9a7ig5Xg4v6b43bmMkNE6LkoAtYs\n" - "qnQdfMh442b1liDud6IMb1Qk0amt3fSrgRMc547TZQVx4QECQQDxUeDm94r3p4ng\n" - "5rCLLC1K5/6HSTZsh7jatKPlz7GfP/IZlYV7iE5784/n0wRiCjZOS7hQRy/8m2Gp\n" - "pf4aZq+DAkEA6+np4d36FYikydvUrupLT3FkdRHGn/v83qOll/VmeNh+L1xMZlIP\n" - "tM26hAXCcQb7O5+J9y3cx2CAQsBS11ZXZQJAfGgTo76WG9p5UEJdXUInD2jOZPwv\n" - "XIATolxh6kXKcijLLLlSmT7KB0inNYIpzkkpee+7U1d/u6B3FriGaSHq9QJBAM/J\n" - "ICnDdLCgwNvWVraVQC3BpwSB2pswvCFwq7py94V60XFvbw80Ogc6qIv98qvQxVlX\n" - "hJIEgA/PjEi+0ng94Q0CQQDm8XSDby35gmjO+6eRmJtAjtB7nguLvrPXM6CPXRmD\n" - "sRoBocpHw6j9UdzZ6qYG0FkdXZghezXFY58ro2BYYRR3\n" - "-----END RSA PRIVATE KEY-----\n", - "-----BEGIN CERTIFICATE-----\n" - "MIICWDCCAcGgAwIBAgIJALgDjxMbBOhbMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\n" - "BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\n" - "aWRnaXRzIFB0eSBMdGQwHhcNMTUxMTEzMjIzMjEzWhcNMTYxMTEyMjIzMjEzWjBF\n" - "MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50\n" - "ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n" - "gQDeYqlyJ1wuiMsi905e3X81/WA/G3ym50PIDZBVtSwZi7JVQPgjBl8CPZMvDh9E\n" - "wB4Ji9ytA8dZZbQ4WbJWPr73zPpJSCvQqz6sOXSlenBRi72acNaQsOR/qPvviJx5\n" - "I6Hqo4qemfnjZhAW85a5BpgrAwKgMLIQTHCTLWwVSyrDrwIDAQABo1AwTjAdBgNV\n" - "HQ4EFgQUx2tbJdlcSTCepn09UdYORXKuSTAwHwYDVR0jBBgwFoAUx2tbJdlcSTCe\n" - "pn09UdYORXKuSTAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQAmp9Id\n" - "E716gHMqeBG4S2FCgVFCr0a0ugkaneQAN/c2L9CbMemEN9W6jvucUIVOtYd90dDW\n" - "lXuowWmT/JctPe3D2qt4yvYW3puECHk2tVQmrJOZiZiTRtWm6HxkmoUYHYp/DtaS\n" - "1Xe29gSTnZtI5sQCrGMzk3SGRSSs7ejLKiVDBQ==\n" - "-----END CERTIFICATE-----\n") -}; + "-----BEGIN RSA PRIVATE KEY-----\n" + "MIICXQIBAAKBgQDeYqlyJ1wuiMsi905e3X81/WA/G3ym50PIDZBVtSwZi7JVQPgj\n" + "Bl8CPZMvDh9EwB4Ji9ytA8dZZbQ4WbJWPr73zPpJSCvQqz6sOXSlenBRi72acNaQ\n" + "sOR/qPvviJx5I6Hqo4qemfnjZhAW85a5BpgrAwKgMLIQTHCTLWwVSyrDrwIDAQAB\n" + "AoGARni9eY8/hv+SX+I+05EdXt6MQXNUbQ+cSykBNCfVccLzIFEWUQMT2IHqwl6X\n" + "ShIXcq7/n1QzOAEiuzixauM3YHg4xZ1Um2Ha9a7ig5Xg4v6b43bmMkNE6LkoAtYs\n" + "qnQdfMh442b1liDud6IMb1Qk0amt3fSrgRMc547TZQVx4QECQQDxUeDm94r3p4ng\n" + "5rCLLC1K5/6HSTZsh7jatKPlz7GfP/IZlYV7iE5784/n0wRiCjZOS7hQRy/8m2Gp\n" + "pf4aZq+DAkEA6+np4d36FYikydvUrupLT3FkdRHGn/v83qOll/VmeNh+L1xMZlIP\n" + "tM26hAXCcQb7O5+J9y3cx2CAQsBS11ZXZQJAfGgTo76WG9p5UEJdXUInD2jOZPwv\n" + "XIATolxh6kXKcijLLLlSmT7KB0inNYIpzkkpee+7U1d/u6B3FriGaSHq9QJBAM/J\n" + "ICnDdLCgwNvWVraVQC3BpwSB2pswvCFwq7py94V60XFvbw80Ogc6qIv98qvQxVlX\n" + "hJIEgA/PjEi+0ng94Q0CQQDm8XSDby35gmjO+6eRmJtAjtB7nguLvrPXM6CPXRmD\n" + "sRoBocpHw6j9UdzZ6qYG0FkdXZghezXFY58ro2BYYRR3\n" + "-----END RSA PRIVATE KEY-----\n", + "-----BEGIN CERTIFICATE-----\n" + "MIICWDCCAcGgAwIBAgIJALgDjxMbBOhbMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\n" + "BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\n" + "aWRnaXRzIFB0eSBMdGQwHhcNMTUxMTEzMjIzMjEzWhcNMTYxMTEyMjIzMjEzWjBF\n" + "MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50\n" + "ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n" + "gQDeYqlyJ1wuiMsi905e3X81/WA/G3ym50PIDZBVtSwZi7JVQPgjBl8CPZMvDh9E\n" + "wB4Ji9ytA8dZZbQ4WbJWPr73zPpJSCvQqz6sOXSlenBRi72acNaQsOR/qPvviJx5\n" + "I6Hqo4qemfnjZhAW85a5BpgrAwKgMLIQTHCTLWwVSyrDrwIDAQABo1AwTjAdBgNV\n" + "HQ4EFgQUx2tbJdlcSTCepn09UdYORXKuSTAwHwYDVR0jBBgwFoAUx2tbJdlcSTCe\n" + "pn09UdYORXKuSTAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQAmp9Id\n" + "E716gHMqeBG4S2FCgVFCr0a0ugkaneQAN/c2L9CbMemEN9W6jvucUIVOtYd90dDW\n" + "lXuowWmT/JctPe3D2qt4yvYW3puECHk2tVQmrJOZiZiTRtWm6HxkmoUYHYp/DtaS\n" + "1Xe29gSTnZtI5sQCrGMzk3SGRSSs7ejLKiVDBQ==\n" + "-----END CERTIFICATE-----\n")}; // ECDSA with EC_NIST_P256. // These PEM strings were created by generating an identity with @@ -115,21 +114,19 @@ static const rtc::RTCCertificatePEM kEcdsaPems[] = { "IkzTd8/pHHkZjV0RnTT5nKSMkjzdV8MDK+alG4ZqE20EfSFz7vGQMJt6jpMzS03f\n" "nGswCgYIKoZIzj0EAwIDSAAwRQIgb/LBc8OtsC5lEDyjCP6M9xt5mwzUNrQBOFWZ\n" "1fE/g68CIQD7uoFfbiq6dTp8ZwzbwQ8jJf08KjriamqA9OW/4268Dw==\n" - "-----END CERTIFICATE-----\n") -}; + "-----END CERTIFICATE-----\n")}; class FakeRTCCertificateGenerator : public rtc::RTCCertificateGeneratorInterface, public rtc::MessageHandler { public: - typedef rtc::TypedMessageData > MessageData; + typedef rtc::TypedMessageData< + rtc::scoped_refptr > + MessageData; FakeRTCCertificateGenerator() : should_fail_(false), should_wait_(false) {} - void set_should_fail(bool should_fail) { - should_fail_ = should_fail; - } + void set_should_fail(bool should_fail) { should_fail_ = should_fail; } // If set to true, stalls the generation of the fake certificate until it is // set to false. @@ -144,8 +141,8 @@ class FakeRTCCertificateGenerator void GenerateCertificateAsync( const rtc::KeyParams& key_params, const rtc::Optional& expires_ms, - const rtc::scoped_refptr& - callback) override { + const rtc::scoped_refptr& callback) + override { // The certificates are created from constant PEM strings and use its coded // expiration time, we do not support modifying it. RTC_DCHECK(!expires_ms); @@ -169,13 +166,13 @@ class FakeRTCCertificateGenerator static rtc::scoped_refptr GenerateCertificate() { switch (rtc::KT_DEFAULT) { - case rtc::KT_RSA: - return rtc::RTCCertificate::FromPEM(kRsaPems[0]); - case rtc::KT_ECDSA: - return rtc::RTCCertificate::FromPEM(kEcdsaPems[0]); - default: - RTC_NOTREACHED(); - return nullptr; + case rtc::KT_RSA: + return rtc::RTCCertificate::FromPEM(kRsaPems[0]); + case rtc::KT_ECDSA: + return rtc::RTCCertificate::FromPEM(kEcdsaPems[0]); + default: + RTC_NOTREACHED(); + return nullptr; } } @@ -188,13 +185,13 @@ class FakeRTCCertificateGenerator const rtc::RTCCertificatePEM& get_pem(const rtc::KeyType& key_type) const { switch (key_type) { - case rtc::KT_RSA: - return kRsaPems[key_index_]; - case rtc::KT_ECDSA: - return kEcdsaPems[key_index_]; - default: - RTC_NOTREACHED(); - return kEcdsaPems[key_index_]; + case rtc::KT_RSA: + return kRsaPems[key_index_]; + case rtc::KT_ECDSA: + return kEcdsaPems[key_index_]; + default: + RTC_NOTREACHED(); + return kEcdsaPems[key_index_]; } } const std::string& get_key(const rtc::KeyType& key_type) const { diff --git a/pc/test/mock_datachannel.h b/pc/test/mock_datachannel.h index 20a4da664a..fe887146fe 100644 --- a/pc/test/mock_datachannel.h +++ b/pc/test/mock_datachannel.h @@ -21,30 +21,27 @@ namespace webrtc { class MockDataChannel : public rtc::RefCountedObject { public: MockDataChannel(int id, DataState state) - : MockDataChannel(id, "MockDataChannel", state, "udp", 0, 0, 0, 0) { - } - MockDataChannel( - int id, - const std::string& label, - DataState state, - const std::string& protocol, - uint32_t messages_sent, - uint64_t bytes_sent, - uint32_t messages_received, - uint64_t bytes_received) - : rtc::RefCountedObject( - nullptr, cricket::DCT_NONE, label) { + : MockDataChannel(id, "MockDataChannel", state, "udp", 0, 0, 0, 0) {} + MockDataChannel(int id, + const std::string& label, + DataState state, + const std::string& protocol, + uint32_t messages_sent, + uint64_t bytes_sent, + uint32_t messages_received, + uint64_t bytes_received) + : rtc::RefCountedObject(nullptr, cricket::DCT_NONE, label) { EXPECT_CALL(*this, id()).WillRepeatedly(testing::Return(id)); EXPECT_CALL(*this, state()).WillRepeatedly(testing::Return(state)); EXPECT_CALL(*this, protocol()).WillRepeatedly(testing::Return(protocol)); - EXPECT_CALL(*this, messages_sent()).WillRepeatedly( - testing::Return(messages_sent)); - EXPECT_CALL(*this, bytes_sent()).WillRepeatedly( - testing::Return(bytes_sent)); - EXPECT_CALL(*this, messages_received()).WillRepeatedly( - testing::Return(messages_received)); - EXPECT_CALL(*this, bytes_received()).WillRepeatedly( - testing::Return(bytes_received)); + EXPECT_CALL(*this, messages_sent()) + .WillRepeatedly(testing::Return(messages_sent)); + EXPECT_CALL(*this, bytes_sent()) + .WillRepeatedly(testing::Return(bytes_sent)); + EXPECT_CALL(*this, messages_received()) + .WillRepeatedly(testing::Return(messages_received)); + EXPECT_CALL(*this, bytes_received()) + .WillRepeatedly(testing::Return(bytes_received)); } MOCK_CONST_METHOD0(id, int()); MOCK_CONST_METHOD0(state, DataState()); diff --git a/pc/test/mock_peerconnection.h b/pc/test/mock_peerconnection.h index 02a3b9e953..dfd5ecc8ad 100644 --- a/pc/test/mock_peerconnection.h +++ b/pc/test/mock_peerconnection.h @@ -51,10 +51,8 @@ class MockPeerConnection factory, std::unique_ptr(), std::unique_ptr()) {} - MOCK_METHOD0(local_streams, - rtc::scoped_refptr()); - MOCK_METHOD0(remote_streams, - rtc::scoped_refptr()); + MOCK_METHOD0(local_streams, rtc::scoped_refptr()); + MOCK_METHOD0(remote_streams, rtc::scoped_refptr()); MOCK_CONST_METHOD0(GetSenders, std::vector>()); MOCK_CONST_METHOD0(GetReceivers, diff --git a/pc/test/mockpeerconnectionobservers.h b/pc/test/mockpeerconnectionobservers.h index 345a2b6613..71c1523e4d 100644 --- a/pc/test/mockpeerconnectionobservers.h +++ b/pc/test/mockpeerconnectionobservers.h @@ -303,9 +303,7 @@ class MockDataChannelObserver : public webrtc::DataChannelObserver { channel_->RegisterObserver(this); state_ = channel_->state(); } - virtual ~MockDataChannelObserver() { - channel_->UnregisterObserver(); - } + virtual ~MockDataChannelObserver() { channel_->UnregisterObserver(); } void OnBufferedAmountChange(uint64_t previous_amount) override {} @@ -342,25 +340,25 @@ class MockStatsObserver : public webrtc::StatsObserver { if (r->type() == StatsReport::kStatsReportTypeSsrc) { stats_.timestamp = r->timestamp(); GetIntValue(r, StatsReport::kStatsValueNameAudioOutputLevel, - &stats_.audio_output_level); + &stats_.audio_output_level); GetIntValue(r, StatsReport::kStatsValueNameAudioInputLevel, - &stats_.audio_input_level); + &stats_.audio_input_level); GetIntValue(r, StatsReport::kStatsValueNameBytesReceived, - &stats_.bytes_received); + &stats_.bytes_received); GetIntValue(r, StatsReport::kStatsValueNameBytesSent, - &stats_.bytes_sent); + &stats_.bytes_sent); GetInt64Value(r, StatsReport::kStatsValueNameCaptureStartNtpTimeMs, - &stats_.capture_start_ntp_time); + &stats_.capture_start_ntp_time); } else if (r->type() == StatsReport::kStatsReportTypeBwe) { stats_.timestamp = r->timestamp(); GetIntValue(r, StatsReport::kStatsValueNameAvailableReceiveBandwidth, - &stats_.available_receive_bandwidth); + &stats_.available_receive_bandwidth); } else if (r->type() == StatsReport::kStatsReportTypeComponent) { stats_.timestamp = r->timestamp(); GetStringValue(r, StatsReport::kStatsValueNameDtlsCipher, - &stats_.dtls_cipher); + &stats_.dtls_cipher); GetStringValue(r, StatsReport::kStatsValueNameSrtpCipher, - &stats_.srtp_cipher); + &stats_.srtp_cipher); } } } @@ -422,8 +420,8 @@ class MockStatsObserver : public webrtc::StatsObserver { } bool GetInt64Value(const StatsReport* report, - StatsReport::StatsValueName name, - int64_t* value) { + StatsReport::StatsValueName name, + int64_t* value) { const StatsReport::Value* v = report->FindValue(name); if (v) { // TODO(tommi): We should really just be using an int here :-/ diff --git a/pc/test/peerconnectiontestwrapper.cc b/pc/test/peerconnectiontestwrapper.cc index 3c227b8e57..4ce13f45fd 100644 --- a/pc/test/peerconnectiontestwrapper.cc +++ b/pc/test/peerconnectiontestwrapper.cc @@ -52,8 +52,8 @@ void PeerConnectionTestWrapper::Connect(PeerConnectionTestWrapper* caller, callee->SignalOnIceCandidateReady.connect( caller, &PeerConnectionTestWrapper::AddIceCandidate); - caller->SignalOnSdpReady.connect( - callee, &PeerConnectionTestWrapper::ReceiveOfferSdp); + caller->SignalOnSdpReady.connect(callee, + &PeerConnectionTestWrapper::ReceiveOfferSdp); callee->SignalOnSdpReady.connect( caller, &PeerConnectionTestWrapper::ReceiveAnswerSdp); } @@ -180,9 +180,8 @@ void PeerConnectionTestWrapper::SetLocalDescription(SdpType type, << ": SetLocalDescription " << webrtc::SdpTypeToString(type) << " " << sdp; - rtc::scoped_refptr - observer(new rtc::RefCountedObject< - MockSetSessionDescriptionObserver>()); + rtc::scoped_refptr observer( + new rtc::RefCountedObject()); peer_connection_->SetLocalDescription( observer, webrtc::CreateSessionDescription(type, sdp).release()); } @@ -193,9 +192,8 @@ void PeerConnectionTestWrapper::SetRemoteDescription(SdpType type, << ": SetRemoteDescription " << webrtc::SdpTypeToString(type) << " " << sdp; - rtc::scoped_refptr - observer(new rtc::RefCountedObject< - MockSetSessionDescriptionObserver>()); + rtc::scoped_refptr observer( + new rtc::RefCountedObject()); peer_connection_->SetRemoteDescription( observer, webrtc::CreateSessionDescription(type, sdp).release()); } @@ -251,8 +249,10 @@ bool PeerConnectionTestWrapper::CheckForVideo() { } void PeerConnectionTestWrapper::GetAndAddUserMedia( - bool audio, const cricket::AudioOptions& audio_options, - bool video, const webrtc::FakeConstraints& video_constraints) { + bool audio, + const cricket::AudioOptions& audio_options, + bool video, + const webrtc::FakeConstraints& video_constraints) { rtc::scoped_refptr stream = GetUserMedia(audio, audio_options, video, video_constraints); for (auto audio_track : stream->GetAudioTracks()) { @@ -265,8 +265,10 @@ void PeerConnectionTestWrapper::GetAndAddUserMedia( rtc::scoped_refptr PeerConnectionTestWrapper::GetUserMedia( - bool audio, const cricket::AudioOptions& audio_options, - bool video, const webrtc::FakeConstraints& video_constraints) { + bool audio, + const cricket::AudioOptions& audio_options, + bool video, + const webrtc::FakeConstraints& video_constraints) { std::string stream_id = kStreamIdBase + rtc::ToString(num_get_user_media_calls_++); rtc::scoped_refptr stream = diff --git a/pc/test/peerconnectiontestwrapper.h b/pc/test/peerconnectiontestwrapper.h index a923b585fc..ea43ad5d57 100644 --- a/pc/test/peerconnectiontestwrapper.h +++ b/pc/test/peerconnectiontestwrapper.h @@ -48,7 +48,7 @@ class PeerConnectionTestWrapper // Implements PeerConnectionObserver. void OnSignalingChange( - webrtc::PeerConnectionInterface::SignalingState new_state) override {} + webrtc::PeerConnectionInterface::SignalingState new_state) override {} void OnAddTrack( rtc::scoped_refptr receiver, const std::vector>& @@ -70,21 +70,22 @@ class PeerConnectionTestWrapper void CreateAnswer(const webrtc::MediaConstraintsInterface* constraints); void ReceiveOfferSdp(const std::string& sdp); void ReceiveAnswerSdp(const std::string& sdp); - void AddIceCandidate(const std::string& sdp_mid, int sdp_mline_index, + void AddIceCandidate(const std::string& sdp_mid, + int sdp_mline_index, const std::string& candidate); void WaitForCallEstablished(); void WaitForConnection(); void WaitForAudio(); void WaitForVideo(); - void GetAndAddUserMedia( - bool audio, const cricket::AudioOptions& audio_options, - bool video, const webrtc::FakeConstraints& video_constraints); + void GetAndAddUserMedia(bool audio, + const cricket::AudioOptions& audio_options, + bool video, + const webrtc::FakeConstraints& video_constraints); // sigslots sigslot::signal1 SignalOnIceCandidateCreated; - sigslot::signal3 SignalOnIceCandidateReady; + sigslot::signal3 + SignalOnIceCandidateReady; sigslot::signal1 SignalOnSdpCreated; sigslot::signal1 SignalOnSdpReady; sigslot::signal1 SignalOnDataChannel; @@ -96,8 +97,10 @@ class PeerConnectionTestWrapper bool CheckForAudio(); bool CheckForVideo(); rtc::scoped_refptr GetUserMedia( - bool audio, const cricket::AudioOptions& audio_options, - bool video, const webrtc::FakeConstraints& video_constraints); + bool audio, + const cricket::AudioOptions& audio_options, + bool video, + const webrtc::FakeConstraints& video_constraints); std::string name_; rtc::Thread* const network_thread_; diff --git a/pc/webrtcsdp.cc b/pc/webrtcsdp.cc index 701fbb75c1..4bfb9efa80 100644 --- a/pc/webrtcsdp.cc +++ b/pc/webrtcsdp.cc @@ -306,10 +306,14 @@ static bool ParseFmtpAttributes(const std::string& line, const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error); -static bool ParseFmtpParam(const std::string& line, std::string* parameter, - std::string* value, SdpParseError* error); -static bool ParseCandidate(const std::string& message, Candidate* candidate, - SdpParseError* error, bool is_raw); +static bool ParseFmtpParam(const std::string& line, + std::string* parameter, + std::string* value, + SdpParseError* error); +static bool ParseCandidate(const std::string& message, + Candidate* candidate, + SdpParseError* error, + bool is_raw); static bool ParseRtcpFbAttribute(const std::string& line, const MediaType media_type, MediaContentDescription* media_desc, @@ -377,8 +381,7 @@ static bool ParseFailed(const std::string& line, // Parses failure where the failing SDP line isn't know or there are multiple // failing lines. -static bool ParseFailed(const std::string& description, - SdpParseError* error) { +static bool ParseFailed(const std::string& description, SdpParseError* error) { return ParseFailed("", description, error); } @@ -486,7 +489,8 @@ static void InitAttrLine(const std::string& attribute, std::ostringstream* os) { } // Writes a SDP attribute line based on |attribute| and |value| to |message|. -static void AddAttributeLine(const std::string& attribute, int value, +static void AddAttributeLine(const std::string& attribute, + int value, std::string* message) { std::ostringstream os; InitAttrLine(attribute, &os); @@ -505,13 +509,14 @@ static bool IsLineType(const std::string& message, cmessage[line_start + 1] == kSdpDelimiterEqual); } -static bool IsLineType(const std::string& line, - const char type) { +static bool IsLineType(const std::string& line, const char type) { return IsLineType(line, type, 0); } -static bool GetLineWithType(const std::string& message, size_t* pos, - std::string* line, const char type) { +static bool GetLineWithType(const std::string& message, + size_t* pos, + std::string* line, + const char type) { if (!IsLineType(message, type, *pos)) { return false; } @@ -535,14 +540,16 @@ static bool AddSsrcLine(uint32_t ssrc_id, // a=ssrc: : std::ostringstream os; InitAttrLine(kAttributeSsrc, &os); - os << kSdpDelimiterColon << ssrc_id << kSdpDelimiterSpace - << attribute << kSdpDelimiterColon << value; + os << kSdpDelimiterColon << ssrc_id << kSdpDelimiterSpace << attribute + << kSdpDelimiterColon << value; return AddLine(os.str(), message); } // Get value only from :. -static bool GetValue(const std::string& message, const std::string& attribute, - std::string* value, SdpParseError* error) { +static bool GetValue(const std::string& message, + const std::string& attribute, + std::string* value, + SdpParseError* error) { std::string leftpart; if (!rtc::tokenize_first(message, kSdpDelimiterColon, &leftpart, value)) { return ParseFailedGetValue(message, attribute, error); @@ -557,10 +564,8 @@ static bool GetValue(const std::string& message, const std::string& attribute, } static bool CaseInsensitiveFind(std::string str1, std::string str2) { - std::transform(str1.begin(), str1.end(), str1.begin(), - ::tolower); - std::transform(str2.begin(), str2.end(), str2.begin(), - ::tolower); + std::transform(str1.begin(), str1.end(), str1.begin(), ::tolower); + std::transform(str2.begin(), str2.end(), str2.begin(), ::tolower); return str1.find(str2) != std::string::npos; } @@ -582,7 +587,7 @@ static bool GetPayloadTypeFromString(const std::string& line, int* payload_type, SdpParseError* error) { return GetValueFromString(line, s, payload_type, error) && - cricket::IsValidRtpPayloadType(*payload_type); + cricket::IsValidRtpPayloadType(*payload_type); } // Creates a StreamParams track in the case when no SSRC lines are signaled. @@ -704,10 +709,11 @@ static int GetCandidatePreferenceFromType(const std::string& type) { // The value of |component_id| currently supported are 1 (RTP) and 2 (RTCP). // TODO(deadbeef): Decide the default destination in webrtcsession and // pass it down via SessionDescription. -static void GetDefaultDestination( - const std::vector& candidates, - int component_id, std::string* port, - std::string* ip, std::string* addr_type) { +static void GetDefaultDestination(const std::vector& candidates, + int component_id, + std::string* port, + std::string* ip, + std::string* addr_type) { *addr_type = kConnectionIpv4Addrtype; *port = kDummyPort; *ip = kDummyAddress; @@ -747,8 +753,8 @@ static void GetDefaultDestination( // Gets "a=rtcp" line if found default RTCP candidate from |candidates|. static std::string GetRtcpLine(const std::vector& candidates) { std::string rtcp_line, rtcp_port, rtcp_ip, addr_type; - GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTCP, - &rtcp_port, &rtcp_ip, &addr_type); + GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTCP, &rtcp_port, + &rtcp_ip, &addr_type); // Found default RTCP candidate. // RFC 5245 // If the agent is utilizing RTCP, it MUST encode the RTCP candidate @@ -759,11 +765,8 @@ static std::string GetRtcpLine(const std::vector& candidates) { // connection-address] CRLF std::ostringstream os; InitAttrLine(kAttributeRtcp, &os); - os << kSdpDelimiterColon - << rtcp_port << " " - << kConnectionNettype << " " - << addr_type << " " - << rtcp_ip; + os << kSdpDelimiterColon << rtcp_port << " " << kConnectionNettype << " " + << addr_type << " " << rtcp_ip; rtcp_line = os.str(); return rtcp_line; } @@ -802,10 +805,11 @@ std::string SdpSerialize(const JsepSessionDescription& jdesc) { // std::ostringstream os; InitLine(kLineTypeOrigin, kSessionOriginUsername, &os); - const std::string& session_id = jdesc.session_id().empty() ? - kSessionOriginSessionId : jdesc.session_id(); - const std::string& session_version = jdesc.session_version().empty() ? - kSessionOriginSessionVersion : jdesc.session_version(); + const std::string& session_id = + jdesc.session_id().empty() ? kSessionOriginSessionId : jdesc.session_id(); + const std::string& session_version = jdesc.session_version().empty() + ? kSessionOriginSessionVersion + : jdesc.session_version(); os << " " << session_id << " " << session_version << " " << kSessionOriginNettype << " " << kSessionOriginAddrtype << " " << kSessionOriginAddress; @@ -921,8 +925,8 @@ bool SdpDeserialize(const std::string& message, session_connection_addr, desc, &candidates, error)) { delete desc; - for (std::vector::const_iterator - it = candidates.begin(); it != candidates.end(); ++it) { + for (std::vector::const_iterator it = candidates.begin(); + it != candidates.end(); ++it) { delete *it; } return false; @@ -930,8 +934,8 @@ bool SdpDeserialize(const std::string& message, jdesc->Initialize(desc, session_id, session_version); - for (std::vector::const_iterator - it = candidates.begin(); it != candidates.end(); ++it) { + for (std::vector::const_iterator it = candidates.begin(); + it != candidates.end(); ++it) { jdesc->AddCandidate(*it); delete *it; } @@ -962,8 +966,10 @@ bool SdpDeserializeCandidate(const std::string& transport_name, return true; } -bool ParseCandidate(const std::string& message, Candidate* candidate, - SdpParseError* error, bool is_raw) { +bool ParseCandidate(const std::string& message, + Candidate* candidate, + SdpParseError* error, + bool is_raw) { RTC_DCHECK(candidate != NULL); // Get the first line from |message|. @@ -997,8 +1003,8 @@ bool ParseCandidate(const std::string& message, Candidate* candidate, attribute_candidate != kAttributeCandidate) { if (is_raw) { std::ostringstream description; - description << "Expect line: " << kAttributeCandidate - << ":" << ""; + description << "Expect line: " << kAttributeCandidate << ":" + << ""; return ParseFailed(first_line, 0, description.str(), error); } else { return ParseFailedExpectLine(first_line, 0, kLineTypeAttributes, @@ -1080,8 +1086,8 @@ bool ParseCandidate(const std::string& message, Candidate* candidate, if (fields.size() >= (current_position + 2) && fields[current_position] == kAttributeCandidateRport) { int port = 0; - if (!GetValueFromString( - first_line, fields[++current_position], &port, error)) { + if (!GetValueFromString(first_line, fields[++current_position], &port, + error)) { return false; } if (!IsValidPort(port)) { @@ -1195,8 +1201,7 @@ bool ParseExtmap(const std::string& line, // RFC 5285 // a=extmap:["/"] std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); const size_t expected_min_fields = 2; if (fields.size() < expected_min_fields) { return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); @@ -1222,7 +1227,7 @@ bool ParseExtmap(const std::string& line, const size_t expected_min_fields_encrypted = expected_min_fields + 1; if (fields.size() < expected_min_fields_encrypted) { return ParseFailedExpectMinFieldNum(line, expected_min_fields_encrypted, - error); + error); } encrypted = true; @@ -1308,7 +1313,7 @@ void BuildMediaDescription(const ContentInfo* content_info, } } else { for (std::vector::const_iterator it = - data_desc->codecs().begin(); + data_desc->codecs().begin(); it != data_desc->codecs().end(); ++it) { fmt.append(" "); fmt.append(rtc::ToString(it->id)); @@ -1338,8 +1343,9 @@ void BuildMediaDescription(const ContentInfo* content_info, port = rtc::ToString(media_desc->connection_address().port()); } - rtc::SSLFingerprint* fp = (transport_info) ? - transport_info->description.identity_fingerprint.get() : NULL; + rtc::SSLFingerprint* fp = + (transport_info) ? transport_info->description.identity_fingerprint.get() + : NULL; // Add the m and c lines. InitLine(kLineTypeMedia, type, &os); @@ -1411,14 +1417,13 @@ void BuildMediaDescription(const ContentInfo* content_info, if (fp) { // Insert the fingerprint attribute. InitAttrLine(kAttributeFingerprint, &os); - os << kSdpDelimiterColon - << fp->algorithm << kSdpDelimiterSpace + os << kSdpDelimiterColon << fp->algorithm << kSdpDelimiterSpace << fp->GetRfc4572Fingerprint(); AddLine(os.str(), message); // Inserting setup attribute. if (transport_info->description.connection_role != - cricket::CONNECTIONROLE_NONE) { + cricket::CONNECTIONROLE_NONE) { // Making sure we are not using "passive" mode. cricket::ConnectionRole role = transport_info->description.connection_role; @@ -1599,8 +1604,7 @@ void BuildRtpContentAttributes(const MediaContentDescription* media_desc, uint32_t ssrc = track->ssrcs[i]; // RFC 5576 // a=ssrc: cname: - AddSsrcLine(ssrc, kSsrcAttributeCname, - track->cname, message); + AddSsrcLine(ssrc, kSsrcAttributeCname, track->cname, message); if (msid_signaling & cricket::kMsidSignalingSsrcAttribute) { // draft-alvestrand-mmusic-msid-00 @@ -1724,13 +1728,10 @@ void AddRtcpFbLines(const T& codec, std::string* message) { } } -bool AddSctpDataCodec(DataContentDescription* media_desc, - int sctp_port) { +bool AddSctpDataCodec(DataContentDescription* media_desc, int sctp_port) { for (const auto& codec : media_desc->codecs()) { if (cricket::CodecNamesEq(codec.name, cricket::kGoogleSctpDataCodecName)) { - return ParseFailed("", - "Can't have multiple sctp port attributes.", - NULL); + return ParseFailed("", "Can't have multiple sctp port attributes.", NULL); } } // Add the SCTP Port number as a pseudo-codec "port" parameter @@ -1753,9 +1754,9 @@ bool GetMinValue(const std::vector& values, int* value) { } bool GetParameter(const std::string& name, - const cricket::CodecParameterMap& params, int* value) { - std::map::const_iterator found = - params.find(name); + const cricket::CodecParameterMap& params, + int* value) { + std::map::const_iterator found = params.find(name); if (found == params.end()) { return false; } @@ -1840,14 +1841,14 @@ void BuildRtpMap(const MediaContentDescription* media_desc, } else if (media_type == cricket::MEDIA_TYPE_DATA) { const DataContentDescription* data_desc = media_desc->as_data(); for (std::vector::const_iterator it = - data_desc->codecs().begin(); + data_desc->codecs().begin(); it != data_desc->codecs().end(); ++it) { // RFC 4566 // a=rtpmap: / // [/] InitAttrLine(kAttributeRtpmap, &os); - os << kSdpDelimiterColon << it->id << " " - << it->name << "/" << it->clockrate; + os << kSdpDelimiterColon << it->id << " " << it->name << "/" + << it->clockrate; AddLine(os.str(), message); } } @@ -1883,14 +1884,10 @@ void BuildCandidate(const std::vector& candidates, } InitAttrLine(kAttributeCandidate, &os); - os << kSdpDelimiterColon - << it->foundation() << " " - << it->component() << " " - << it->protocol() << " " - << it->priority() << " " + os << kSdpDelimiterColon << it->foundation() << " " << it->component() + << " " << it->protocol() << " " << it->priority() << " " << it->address().ipaddr().ToString() << " " - << it->address().PortAsString() << " " - << kAttributeCandidateTyp << " " + << it->address().PortAsString() << " " << kAttributeCandidateTyp << " " << type << " "; // Related address @@ -1936,7 +1933,7 @@ void BuildIceOptions(const std::vector& transport_options, bool IsRtp(const std::string& protocol) { return protocol.empty() || - (protocol.find(cricket::kMediaProtocolRtpPrefix) != std::string::npos); + (protocol.find(cricket::kMediaProtocolRtpPrefix) != std::string::npos); } bool IsDtlsSctp(const std::string& protocol) { @@ -2009,19 +2006,18 @@ bool ParseSessionDescription(const std::string& message, // RFC 4566 // v= (protocol version) if (!GetLineWithType(message, pos, &line, kLineTypeVersion)) { - return ParseFailedExpectLine(message, *pos, kLineTypeVersion, - std::string(), error); + return ParseFailedExpectLine(message, *pos, kLineTypeVersion, std::string(), + error); } // RFC 4566 // o= // if (!GetLineWithType(message, pos, &line, kLineTypeOrigin)) { - return ParseFailedExpectLine(message, *pos, kLineTypeOrigin, - std::string(), error); + return ParseFailedExpectLine(message, *pos, kLineTypeOrigin, std::string(), + error); } std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); const size_t expected_fields = 6; if (fields.size() != expected_fields) { return ParseFailedExpectFieldNum(line, expected_fields, error); @@ -2106,8 +2102,8 @@ bool ParseSessionDescription(const std::string& message, return false; } } else if (HasAttribute(line, kAttributeIceUfrag)) { - if (!GetValue(line, kAttributeIceUfrag, - &(session_td->ice_ufrag), error)) { + if (!GetValue(line, kAttributeIceUfrag, &(session_td->ice_ufrag), + error)) { return false; } } else if (HasAttribute(line, kAttributeIcePwd)) { @@ -2163,8 +2159,7 @@ bool ParseGroupAttribute(const std::string& line, // RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00 // a=group:BUNDLE video voice std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); std::string semantics; if (!GetValue(fields[0], kAttributeGroup, &semantics, error)) { return false; @@ -2187,8 +2182,7 @@ static bool ParseFingerprintAttribute(const std::string& line, } std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); const size_t expected_fields = 2; if (fields.size() != expected_fields) { return ParseFailedExpectFieldNum(line, expected_fields, error); @@ -2206,11 +2200,9 @@ static bool ParseFingerprintAttribute(const std::string& line, ::tolower); // The second field is the digest value. De-hexify it. - *fingerprint = rtc::SSLFingerprint::CreateFromRfc4572( - algorithm, fields[1]); + *fingerprint = rtc::SSLFingerprint::CreateFromRfc4572(algorithm, fields[1]); if (!*fingerprint) { - return ParseFailed(line, - "Failed to create fingerprint from the digest.", + return ParseFailed(line, "Failed to create fingerprint from the digest.", error); } @@ -2306,36 +2298,23 @@ struct StaticPayloadAudioCodec { size_t channels; }; static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = { - { "PCMU", 8000, 1 }, - { "reserved", 0, 0 }, - { "reserved", 0, 0 }, - { "GSM", 8000, 1 }, - { "G723", 8000, 1 }, - { "DVI4", 8000, 1 }, - { "DVI4", 16000, 1 }, - { "LPC", 8000, 1 }, - { "PCMA", 8000, 1 }, - { "G722", 8000, 1 }, - { "L16", 44100, 2 }, - { "L16", 44100, 1 }, - { "QCELP", 8000, 1 }, - { "CN", 8000, 1 }, - { "MPA", 90000, 1 }, - { "G728", 8000, 1 }, - { "DVI4", 11025, 1 }, - { "DVI4", 22050, 1 }, - { "G729", 8000, 1 }, + {"PCMU", 8000, 1}, {"reserved", 0, 0}, {"reserved", 0, 0}, + {"GSM", 8000, 1}, {"G723", 8000, 1}, {"DVI4", 8000, 1}, + {"DVI4", 16000, 1}, {"LPC", 8000, 1}, {"PCMA", 8000, 1}, + {"G722", 8000, 1}, {"L16", 44100, 2}, {"L16", 44100, 1}, + {"QCELP", 8000, 1}, {"CN", 8000, 1}, {"MPA", 90000, 1}, + {"G728", 8000, 1}, {"DVI4", 11025, 1}, {"DVI4", 22050, 1}, + {"G729", 8000, 1}, }; -void MaybeCreateStaticPayloadAudioCodecs( - const std::vector& fmts, AudioContentDescription* media_desc) { +void MaybeCreateStaticPayloadAudioCodecs(const std::vector& fmts, + AudioContentDescription* media_desc) { if (!media_desc) { return; } RTC_DCHECK(media_desc->codecs().empty()); for (int payload_type : fmts) { - if (!media_desc->HasCodec(payload_type) && - payload_type >= 0 && + if (!media_desc->HasCodec(payload_type) && payload_type >= 0 && static_cast(payload_type) < arraysize(kStaticPayloadAudioCodecs)) { std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name; @@ -2391,11 +2370,12 @@ static C* ParseContentDescription(const std::string& message, payload_type_preferences[pt] = preference--; } std::vector codecs = media_desc->codecs(); - std::sort(codecs.begin(), codecs.end(), [&payload_type_preferences]( - const typename C::CodecType& a, - const typename C::CodecType& b) { - return payload_type_preferences[a.id] > payload_type_preferences[b.id]; - }); + std::sort(codecs.begin(), codecs.end(), + [&payload_type_preferences](const typename C::CodecType& a, + const typename C::CodecType& b) { + return payload_type_preferences[a.id] > + payload_type_preferences[b.id]; + }); media_desc->set_codecs(codecs); return media_desc; } @@ -2420,8 +2400,7 @@ bool ParseMediaDescription(const std::string& message, ++mline_index; std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); const size_t expected_min_fields = 4; if (fields.size() < expected_min_fields) { @@ -2444,7 +2423,7 @@ bool ParseMediaDescription(const std::string& message, // std::vector payload_types; if (IsRtp(protocol)) { - for (size_t j = 3 ; j < fields.size(); ++j) { + for (size_t j = 3; j < fields.size(); ++j) { // TODO(wu): Remove when below bug is fixed. // https://bugzilla.mozilla.org/show_bug.cgi?id=996329 if (fields[j].empty() && j == fields.size() - 1) { @@ -2608,8 +2587,8 @@ bool VerifyVideoCodecs(const VideoContentDescription* video_desc) { void AddParameters(const cricket::CodecParameterMap& parameters, cricket::Codec* codec) { - for (cricket::CodecParameterMap::const_iterator iter = - parameters.begin(); iter != parameters.end(); ++iter) { + for (cricket::CodecParameterMap::const_iterator iter = parameters.begin(); + iter != parameters.end(); ++iter) { codec->SetParam(iter->first, iter->second); } } @@ -2667,7 +2646,8 @@ void AddOrReplaceCodec(MediaContentDescription* content_desc, const U& codec) { // Adds or updates existing codec corresponding to |payload_type| according // to |parameters|. template -void UpdateCodec(MediaContentDescription* content_desc, int payload_type, +void UpdateCodec(MediaContentDescription* content_desc, + int payload_type, const cricket::CodecParameterMap& parameters) { // Codec might already have been populated (from rtpmap). U new_codec = GetCodecWithPayloadType(static_cast(content_desc)->codecs(), @@ -2679,7 +2659,8 @@ void UpdateCodec(MediaContentDescription* content_desc, int payload_type, // Adds or updates existing codec corresponding to |payload_type| according // to |feedback_param|. template -void UpdateCodec(MediaContentDescription* content_desc, int payload_type, +void UpdateCodec(MediaContentDescription* content_desc, + int payload_type, const cricket::FeedbackParam& feedback_param) { // Codec might already have been populated (from rtpmap). U new_codec = GetCodecWithPayloadType(static_cast(content_desc)->codecs(), @@ -2700,7 +2681,7 @@ bool PopWildcardCodec(std::vector* codecs, T* wildcard_codec) { return false; } -template +template void UpdateFromWildcardCodecs(cricket::MediaContentDescriptionImpl* desc) { auto codecs = desc->codecs(); T wildcard_codec; @@ -2713,7 +2694,8 @@ void UpdateFromWildcardCodecs(cricket::MediaContentDescriptionImpl* desc) { desc->set_codecs(codecs); } -void AddAudioAttribute(const std::string& name, const std::string& value, +void AddAudioAttribute(const std::string& name, + const std::string& value, AudioContentDescription* audio_desc) { if (value.empty()) { return; @@ -3038,8 +3020,7 @@ bool ParseContent(const std::string& message, (*it).set_username(transport->ice_ufrag); RTC_DCHECK((*it).password().empty()); (*it).set_password(transport->ice_pwd); - candidates->push_back( - new JsepIceCandidate(mline_id, mline_index, *it)); + candidates->push_back(new JsepIceCandidate(mline_id, mline_index, *it)); } return true; } @@ -3104,9 +3085,8 @@ bool ParseSsrcAttribute(const std::string& line, std::vector fields; rtc::split(value, kSdpDelimiterSpace, &fields); if (fields.size() < 1 || fields.size() > 2) { - return ParseFailed(line, - "Expected format \"msid:[ ]\".", - error); + return ParseFailed( + line, "Expected format \"msid:[ ]\".", error); } ssrc_info->stream_id = fields[0]; if (fields.size() == 2) { @@ -3132,8 +3112,7 @@ bool ParseSsrcGroupAttribute(const std::string& line, // RFC 5576 // a=ssrc-group: ... std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); const size_t expected_min_fields = 2; if (fields.size() < expected_min_fields) { return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); @@ -3158,8 +3137,7 @@ bool ParseCryptoAttribute(const std::string& line, MediaContentDescription* media_desc, SdpParseError* error) { std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); // RFC 4568 // a=crypto: [] const size_t expected_min_fields = 3; @@ -3180,8 +3158,8 @@ bool ParseCryptoAttribute(const std::string& line, if (fields.size() > 3) { session_params = fields[3]; } - media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, - session_params)); + media_desc->AddCrypto( + CryptoParams(tag, crypto_suite, key_params, session_params)); return true; } @@ -3225,8 +3203,7 @@ bool ParseRtpmapAttribute(const std::string& line, MediaContentDescription* media_desc, SdpParseError* error) { std::vector fields; - rtc::split(line.substr(kLinePrefixLength), - kSdpDelimiterSpace, &fields); + rtc::split(line.substr(kLinePrefixLength), kSdpDelimiterSpace, &fields); // RFC 4566 // a=rtpmap: /[/] const size_t expected_min_fields = 2; @@ -3268,8 +3245,7 @@ bool ParseRtpmapAttribute(const std::string& line, } if (media_type == cricket::MEDIA_TYPE_VIDEO) { VideoContentDescription* video_desc = media_desc->as_video(); - UpdateCodec(payload_type, encoding_name, - video_desc); + UpdateCodec(payload_type, encoding_name, video_desc); } else if (media_type == cricket::MEDIA_TYPE_AUDIO) { // RFC 4566 // For audio streams, indicates the number @@ -3292,8 +3268,10 @@ bool ParseRtpmapAttribute(const std::string& line, return true; } -bool ParseFmtpParam(const std::string& line, std::string* parameter, - std::string* value, SdpParseError* error) { +bool ParseFmtpParam(const std::string& line, + std::string* parameter, + std::string* value, + SdpParseError* error) { if (!rtc::tokenize_first(line, kSdpDelimiterEqual, parameter, value)) { ParseFailed(line, "Unable to parse fmtp parameter. \'=\' missing.", error); return false; @@ -3302,7 +3280,8 @@ bool ParseFmtpParam(const std::string& line, std::string* parameter, return true; } -bool ParseFmtpAttributes(const std::string& line, const MediaType media_type, +bool ParseFmtpAttributes(const std::string& line, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error) { if (media_type != cricket::MEDIA_TYPE_AUDIO && @@ -3365,7 +3344,8 @@ bool ParseFmtpAttributes(const std::string& line, const MediaType media_type, return true; } -bool ParseRtcpFbAttribute(const std::string& line, const MediaType media_type, +bool ParseRtcpFbAttribute(const std::string& line, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error) { if (media_type != cricket::MEDIA_TYPE_AUDIO && diff --git a/pc/webrtcsdp_unittest.cc b/pc/webrtcsdp_unittest.cc index 6a4d5a66e4..e7471afb58 100644 --- a/pc/webrtcsdp_unittest.cc +++ b/pc/webrtcsdp_unittest.cc @@ -16,8 +16,8 @@ #include "api/jsepsessiondescription.h" #include "media/base/mediaconstants.h" #include "media/engine/webrtcvideoengine.h" -#include "p2p/base/port.h" #include "p2p/base/p2pconstants.h" +#include "p2p/base/port.h" #include "pc/mediasession.h" #include "rtc_base/checks.h" #include "rtc_base/gunit.h" @@ -86,7 +86,8 @@ static const char kAttributeCryptoVoice[] = static const char kAttributeCryptoVideo[] = "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"; -static const char kFingerprint[] = "a=fingerprint:sha-1 " +static const char kFingerprint[] = + "a=fingerprint:sha-1 " "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n"; static const int kExtmapId = 1; static const char kExtmapUri[] = "http://example.com/082005/ext.htm#ttime"; @@ -796,15 +797,15 @@ static void InjectAfter(const std::string& line, const std::string& newlines, std::string* message) { const std::string tmp = line + newlines; - rtc::replace_substrs(line.c_str(), line.length(), - tmp.c_str(), tmp.length(), message); + rtc::replace_substrs(line.c_str(), line.length(), tmp.c_str(), tmp.length(), + message); } static void Replace(const std::string& line, const std::string& newlines, std::string* message) { - rtc::replace_substrs(line.c_str(), line.length(), - newlines.c_str(), newlines.length(), message); + rtc::replace_substrs(line.c_str(), line.length(), newlines.c_str(), + newlines.length(), message); } // Expect fail to parase |bad_sdp| and expect |bad_part| be part of the error @@ -855,7 +856,8 @@ static void ReplaceDirection(RtpTransceiverDirection direction, Replace("a=sendrecv", new_direction, message); } -static void ReplaceRejected(bool audio_rejected, bool video_rejected, +static void ReplaceRejected(bool audio_rejected, + bool video_rejected, std::string* message) { if (audio_rejected) { Replace("m=audio 9", "m=audio 0", message); @@ -998,22 +1000,20 @@ class WebRtcSdpTest : public testing::Test { candidates_.push_back(candidate11); candidates_.push_back(candidate12); - jcandidate_.reset(new JsepIceCandidate(std::string("audio_content_name"), - 0, candidate1)); + jcandidate_.reset( + new JsepIceCandidate(std::string("audio_content_name"), 0, candidate1)); // Set up JsepSessionDescription. jdesc_.Initialize(desc_.Copy(), kSessionId, kSessionVersion); std::string mline_id; int mline_index = 0; - for (size_t i = 0; i< candidates_.size(); ++i) { + for (size_t i = 0; i < candidates_.size(); ++i) { // In this test, the audio m line index will be 0, and the video m line // will be 1. bool is_video = (i > 5); mline_id = is_video ? "video_content_name" : "audio_content_name"; mline_index = is_video ? 1 : 0; - JsepIceCandidate jice(mline_id, - mline_index, - candidates_.at(i)); + JsepIceCandidate jice(mline_id, mline_index, candidates_.at(i)); jdesc_.AddCandidate(&jice); } } @@ -1141,7 +1141,8 @@ class WebRtcSdpTest : public testing::Test { AudioContentDescription* audio = new AudioContentDescription(); audio->set_rtcp_mux(true); audio->set_rtcp_reduced_size(true); - audio->AddCrypto(CryptoParams(1, "AES_CM_128_HMAC_SHA1_32", + audio->AddCrypto(CryptoParams( + 1, "AES_CM_128_HMAC_SHA1_32", "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32", "dummy_session_params")); audio->set_protocol(cricket::kMediaProtocolSavpf); @@ -1227,8 +1228,7 @@ class WebRtcSdpTest : public testing::Test { } template - void CompareMediaContentDescription(const MCD* cd1, - const MCD* cd2) { + void CompareMediaContentDescription(const MCD* cd1, const MCD* cd2) { // type EXPECT_EQ(cd1->type(), cd1->type()); @@ -1247,7 +1247,7 @@ class WebRtcSdpTest : public testing::Test { ADD_FAILURE(); return; } - for (size_t i = 0; i< cd1->cryptos().size(); ++i) { + for (size_t i = 0; i < cd1->cryptos().size(); ++i) { const CryptoParams c1 = cd1->cryptos().at(i); const CryptoParams c2 = cd2->cryptos().at(i); EXPECT_TRUE(c1.Matches(c2)); @@ -1258,13 +1258,13 @@ class WebRtcSdpTest : public testing::Test { // protocol // Use an equivalence class here, for old and new versions of the // protocol description. - if (cd1->protocol() == cricket::kMediaProtocolDtlsSctp - || cd1->protocol() == cricket::kMediaProtocolUdpDtlsSctp - || cd1->protocol() == cricket::kMediaProtocolTcpDtlsSctp) { + if (cd1->protocol() == cricket::kMediaProtocolDtlsSctp || + cd1->protocol() == cricket::kMediaProtocolUdpDtlsSctp || + cd1->protocol() == cricket::kMediaProtocolTcpDtlsSctp) { const bool cd2_is_also_dtls_sctp = - cd2->protocol() == cricket::kMediaProtocolDtlsSctp - || cd2->protocol() == cricket::kMediaProtocolUdpDtlsSctp - || cd2->protocol() == cricket::kMediaProtocolTcpDtlsSctp; + cd2->protocol() == cricket::kMediaProtocolDtlsSctp || + cd2->protocol() == cricket::kMediaProtocolUdpDtlsSctp || + cd2->protocol() == cricket::kMediaProtocolTcpDtlsSctp; EXPECT_TRUE(cd2_is_also_dtls_sctp); } else { EXPECT_EQ(cd1->protocol(), cd2->protocol()); @@ -1282,7 +1282,7 @@ class WebRtcSdpTest : public testing::Test { // extmap ASSERT_EQ(cd1->rtp_header_extensions().size(), cd2->rtp_header_extensions().size()); - for (size_t i = 0; i< cd1->rtp_header_extensions().size(); ++i) { + for (size_t i = 0; i < cd1->rtp_header_extensions().size(); ++i) { const RtpExtension ext1 = cd1->rtp_header_extensions().at(i); const RtpExtension ext2 = cd2->rtp_header_extensions().at(i); EXPECT_EQ(ext1.uri, ext2.uri); @@ -1304,7 +1304,7 @@ class WebRtcSdpTest : public testing::Test { ADD_FAILURE(); return; } - for (size_t i = 0 ; i < desc1.contents().size(); ++i) { + for (size_t i = 0; i < desc1.contents().size(); ++i) { const cricket::ContentInfo& c1 = desc1.contents().at(i); const cricket::ContentInfo& c2 = desc2.contents().at(i); // ContentInfo properties. @@ -1379,8 +1379,7 @@ class WebRtcSdpTest : public testing::Test { EXPECT_EQ(transport1.content_name, transport2.content_name); EXPECT_EQ(transport1.description.ice_ufrag, transport2.description.ice_ufrag); - EXPECT_EQ(transport1.description.ice_pwd, - transport2.description.ice_pwd); + EXPECT_EQ(transport1.description.ice_pwd, transport2.description.ice_pwd); EXPECT_EQ(transport1.description.ice_mode, transport2.description.ice_mode); if (transport1.description.identity_fingerprint) { @@ -1398,9 +1397,8 @@ class WebRtcSdpTest : public testing::Test { EXPECT_EQ(desc1.msid_supported(), desc2.msid_supported()); } - bool CompareSessionDescription( - const JsepSessionDescription& desc1, - const JsepSessionDescription& desc2) { + bool CompareSessionDescription(const JsepSessionDescription& desc1, + const JsepSessionDescription& desc2) { EXPECT_EQ(desc1.session_id(), desc2.session_id()); EXPECT_EQ(desc1.session_version(), desc2.session_version()); CompareSessionDescription(*desc1.description(), *desc2.description()); @@ -1431,16 +1429,18 @@ class WebRtcSdpTest : public testing::Test { const char ice_ufragx[] = "a=xice-ufrag"; const char ice_pwd[] = "a=ice-pwd"; const char ice_pwdx[] = "a=xice-pwd"; - rtc::replace_substrs(ice_ufrag, strlen(ice_ufrag), - ice_ufragx, strlen(ice_ufragx), sdp); - rtc::replace_substrs(ice_pwd, strlen(ice_pwd), - ice_pwdx, strlen(ice_pwdx), sdp); + rtc::replace_substrs(ice_ufrag, strlen(ice_ufrag), ice_ufragx, + strlen(ice_ufragx), sdp); + rtc::replace_substrs(ice_pwd, strlen(ice_pwd), ice_pwdx, strlen(ice_pwdx), + sdp); return true; } // Update the candidates in |jdesc| to use the given |ufrag| and |pwd|. - bool UpdateCandidateUfragPwd(JsepSessionDescription* jdesc, int mline_index, - const std::string& ufrag, const std::string& pwd) { + bool UpdateCandidateUfragPwd(JsepSessionDescription* jdesc, + int mline_index, + const std::string& ufrag, + const std::string& pwd) { std::string content_name; if (mline_index == 0) { content_name = kAudioContentName; @@ -1449,8 +1449,8 @@ class WebRtcSdpTest : public testing::Test { } else { RTC_NOTREACHED(); } - TransportInfo transport_info( - content_name, TransportDescription(ufrag, pwd)); + TransportInfo transport_info(content_name, + TransportDescription(ufrag, pwd)); SessionDescription* desc = const_cast(jdesc->description()); desc->RemoveTransportInfoByName(content_name); @@ -1459,10 +1459,8 @@ class WebRtcSdpTest : public testing::Test { const IceCandidateCollection* cc = jdesc_.candidates(i); for (size_t j = 0; j < cc->count(); ++j) { if (cc->at(j)->sdp_mline_index() == mline_index) { - const_cast(cc->at(j)->candidate()).set_username( - ufrag); - const_cast(cc->at(j)->candidate()).set_password( - pwd); + const_cast(cc->at(j)->candidate()).set_username(ufrag); + const_cast(cc->at(j)->candidate()).set_password(pwd); } } } @@ -1494,9 +1492,8 @@ class WebRtcSdpTest : public testing::Test { void AddFingerprint() { desc_.RemoveTransportInfoByName(kAudioContentName); desc_.RemoveTransportInfoByName(kVideoContentName); - rtc::SSLFingerprint fingerprint(rtc::DIGEST_SHA_1, - kIdentityDigest, - sizeof(kIdentityDigest)); + rtc::SSLFingerprint fingerprint(rtc::DIGEST_SHA_1, kIdentityDigest, + sizeof(kIdentityDigest)); EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( kAudioContentName, TransportDescription(std::vector(), kUfragVoice, kPwdVoice, @@ -1557,8 +1554,7 @@ class WebRtcSdpTest : public testing::Test { std::string new_sdp = kSdpFullString; ReplaceDirection(direction, &new_sdp); - if (!jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + if (!jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())) { return false; } @@ -1618,9 +1614,9 @@ class WebRtcSdpTest : public testing::Test { data_stream.set_stream_ids({kDataChannelLabel}); data_stream.ssrcs.push_back(kDataChannelSsrc); data_desc_->AddStream(data_stream); - data_desc_->AddCrypto(CryptoParams( - 1, "AES_CM_128_HMAC_SHA1_80", - "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); + data_desc_->AddCrypto( + CryptoParams(1, "AES_CM_128_HMAC_SHA1_80", + "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); data_desc_->set_protocol(cricket::kMediaProtocolSavpf); desc_.AddContent(kDataContentName, MediaProtocolType::kRtp, data.release()); EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( @@ -1636,8 +1632,7 @@ class WebRtcSdpTest : public testing::Test { audio_desc_->set_direction(direction); video_desc_->set_direction(direction); - if (!jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + if (!jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())) { return false; } @@ -1672,12 +1667,12 @@ class WebRtcSdpTest : public testing::Test { return true; } - void TestDeserializeExtmap(bool session_level, bool media_level, - bool encrypted) { + void TestDeserializeExtmap(bool session_level, + bool media_level, + bool encrypted) { AddExtmap(encrypted); JsepSessionDescription new_jdesc(SdpType::kOffer); - ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); JsepSessionDescription jdesc_with_extmap(SdpType::kOffer); std::string sdp_with_extmap = kSdpString; @@ -1701,8 +1696,8 @@ class WebRtcSdpTest : public testing::Test { // media level. if (session_level && media_level) { SdpParseError error; - EXPECT_FALSE(webrtc::SdpDeserialize(sdp_with_extmap, - &jdesc_with_extmap, &error)); + EXPECT_FALSE( + webrtc::SdpDeserialize(sdp_with_extmap, &jdesc_with_extmap, &error)); EXPECT_NE(std::string::npos, error.description.find("a=extmap")); } else { EXPECT_TRUE(SdpDeserialize(sdp_with_extmap, &jdesc_with_extmap)); @@ -1711,7 +1706,8 @@ class WebRtcSdpTest : public testing::Test { } void VerifyCodecParameter(const cricket::CodecParameterMap& params, - const std::string& name, int expected_value) { + const std::string& name, + int expected_value) { cricket::CodecParameterMap::const_iterator found = params.find(name); ASSERT_TRUE(found != params.end()); EXPECT_EQ(found->second, rtc::ToString(expected_value)); @@ -1812,9 +1808,9 @@ class WebRtcSdpTest : public testing::Test { "a=rtcp-fb:101 goog-remb\r\n"; std::ostringstream os; os << sdp_session_and_audio; - os << "a=rtcp-fb:" << (use_wildcard ? "*" : "111") << " nack\r\n"; + os << "a=rtcp-fb:" << (use_wildcard ? "*" : "111") << " nack\r\n"; os << sdp_video; - os << "a=rtcp-fb:" << (use_wildcard ? "*" : "101") << " ccm fir\r\n"; + os << "a=rtcp-fb:" << (use_wildcard ? "*" : "101") << " ccm fir\r\n"; std::string sdp = os.str(); // Deserialize SdpParseError error; @@ -1825,9 +1821,8 @@ class WebRtcSdpTest : public testing::Test { ASSERT_FALSE(acd->codecs().empty()); cricket::AudioCodec opus = acd->codecs()[0]; EXPECT_EQ(111, opus.id); - EXPECT_TRUE(opus.HasFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty))); + EXPECT_TRUE(opus.HasFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); const VideoContentDescription* vcd = GetFirstVideoContentDescription(jdesc_output->description()); @@ -1837,18 +1832,14 @@ class WebRtcSdpTest : public testing::Test { EXPECT_STREQ(webrtc::JsepSessionDescription::kDefaultVideoCodecName, vp8.name.c_str()); EXPECT_EQ(101, vp8.id); - EXPECT_TRUE(vp8.HasFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kParamValueEmpty))); - EXPECT_TRUE(vp8.HasFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamNack, - cricket::kRtcpFbNackParamPli))); - EXPECT_TRUE(vp8.HasFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamRemb, - cricket::kParamValueEmpty))); - EXPECT_TRUE(vp8.HasFeedbackParam( - cricket::FeedbackParam(cricket::kRtcpFbParamCcm, - cricket::kRtcpFbCcmParamFir))); + EXPECT_TRUE(vp8.HasFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); + EXPECT_TRUE(vp8.HasFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli))); + EXPECT_TRUE(vp8.HasFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty))); + EXPECT_TRUE(vp8.HasFeedbackParam(cricket::FeedbackParam( + cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir))); } // Two SDP messages can mean the same thing but be different strings, e.g. @@ -1921,10 +1912,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint); std::string sdp_with_fingerprint = kSdpString; - InjectAfter(kAttributeIcePwdVoice, - kFingerprint, &sdp_with_fingerprint); - InjectAfter(kAttributeIcePwdVideo, - kFingerprint, &sdp_with_fingerprint); + InjectAfter(kAttributeIcePwdVoice, kFingerprint, &sdp_with_fingerprint); + InjectAfter(kAttributeIcePwdVideo, kFingerprint, &sdp_with_fingerprint); EXPECT_EQ(sdp_with_fingerprint, message); } @@ -1941,10 +1930,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { std::string sdp_with_fingerprint = kSdpString; Replace(kAttributeCryptoVoice, "", &sdp_with_fingerprint); Replace(kAttributeCryptoVideo, "", &sdp_with_fingerprint); - InjectAfter(kAttributeIcePwdVoice, - kFingerprint, &sdp_with_fingerprint); - InjectAfter(kAttributeIcePwdVideo, - kFingerprint, &sdp_with_fingerprint); + InjectAfter(kAttributeIcePwdVoice, kFingerprint, &sdp_with_fingerprint); + InjectAfter(kAttributeIcePwdVideo, kFingerprint, &sdp_with_fingerprint); EXPECT_EQ(sdp_with_fingerprint, message); } @@ -1962,8 +1949,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundle) { group.AddContentName(kAudioContentName); group.AddContentName(kVideoContentName); desc_.AddGroup(group); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_bundle = kSdpFullString; @@ -1978,16 +1964,13 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBandwidth) { vcd->set_bandwidth(100 * 1000); AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); acd->set_bandwidth(50 * 1000); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_bandwidth = kSdpFullString; - InjectAfter("c=IN IP4 74.125.224.39\r\n", - "b=AS:100\r\n", + InjectAfter("c=IN IP4 74.125.224.39\r\n", "b=AS:100\r\n", &sdp_with_bandwidth); - InjectAfter("c=IN IP4 74.125.127.126\r\n", - "b=AS:50\r\n", + InjectAfter("c=IN IP4 74.125.127.126\r\n", "b=AS:50\r\n", &sdp_with_bandwidth); EXPECT_EQ(sdp_with_bandwidth, message); } @@ -2001,16 +1984,13 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIceOptions) { transport_options.push_back(kIceOption2); transport_options.push_back(kIceOption3); AddIceOptions(kVideoContentName, transport_options); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_ice_options = kSdpFullString; - InjectAfter(kAttributeIcePwdVoice, - "a=ice-options:iceoption1 iceoption3\r\n", + InjectAfter(kAttributeIcePwdVoice, "a=ice-options:iceoption1 iceoption3\r\n", &sdp_with_ice_options); - InjectAfter(kAttributeIcePwdVideo, - "a=ice-options:iceoption2 iceoption3\r\n", + InjectAfter(kAttributeIcePwdVideo, "a=ice-options:iceoption2 iceoption3\r\n", &sdp_with_ice_options); EXPECT_EQ(sdp_with_ice_options, message); } @@ -2088,11 +2068,10 @@ TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { char default_portstr[16]; char new_portstr[16]; rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d", - kDefaultSctpPort); + kDefaultSctpPort); rtc::sprintfn(new_portstr, sizeof(new_portstr), "%d", kNewPort); - rtc::replace_substrs(default_portstr, strlen(default_portstr), - new_portstr, strlen(new_portstr), - &expected_sdp); + rtc::replace_substrs(default_portstr, strlen(default_portstr), new_portstr, + strlen(new_portstr), &expected_sdp); EXPECT_EQ(expected_sdp, message); } @@ -2100,7 +2079,7 @@ TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { JsepSessionDescription jsep_desc(kDummyType); AddRtpDataChannel(); - data_desc_->set_bandwidth(100*1000); + data_desc_->set_bandwidth(100 * 1000); MakeDescriptionWithoutCandidates(&jsep_desc); std::string message = webrtc::SdpSerialize(jsep_desc); @@ -2108,8 +2087,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { expected_sdp.append(kSdpRtpDataChannelString); // Serializing data content shouldn't ignore bandwidth settings. InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n", - "b=AS:100\r\n", - &expected_sdp); + "b=AS:100\r\n", &expected_sdp); EXPECT_EQ(expected_sdp, message); } @@ -2121,10 +2099,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { std::string message = webrtc::SdpSerialize(desc_with_extmap); std::string sdp_with_extmap = kSdpString; - InjectAfter("a=mid:audio_content_name\r\n", - kExtmap, &sdp_with_extmap); - InjectAfter("a=mid:video_content_name\r\n", - kExtmap, &sdp_with_extmap); + InjectAfter("a=mid:audio_content_name\r\n", kExtmap, &sdp_with_extmap); + InjectAfter("a=mid:video_content_name\r\n", kExtmap, &sdp_with_extmap); EXPECT_EQ(sdp_with_extmap, message); } @@ -2133,8 +2109,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmapEncrypted) { bool encrypted = true; AddExtmap(encrypted); JsepSessionDescription desc_with_extmap(kDummyType); - ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), - kSessionId, kSessionVersion)); + ASSERT_TRUE( + desc_with_extmap.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); TestSerialize(desc_with_extmap); } @@ -2220,11 +2196,11 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescription) { TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutMline) { JsepSessionDescription jdesc(kDummyType); const char kSdpWithoutMline[] = - "v=0\r\n" - "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" - "s=-\r\n" - "t=0 0\r\n" - "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n"; + "v=0\r\n" + "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n"; // Deserialize EXPECT_TRUE(SdpDeserialize(kSdpWithoutMline, &jdesc)); EXPECT_EQ(0u, jdesc.description()->contents().size()); @@ -2243,8 +2219,8 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutCarriageReturn) { TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutCandidates) { // SessionDescription with desc but without candidates. JsepSessionDescription jdesc_no_candidates(kDummyType); - ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), - kSessionId, kSessionVersion)); + ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, + kSessionVersion)); JsepSessionDescription new_jdesc(kDummyType); EXPECT_TRUE(SdpDeserialize(kSdpString, &new_jdesc)); EXPECT_TRUE(CompareSessionDescription(jdesc_no_candidates, new_jdesc)); @@ -2299,8 +2275,7 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) { EXPECT_EQ("G729", g729.name); EXPECT_EQ(8000, g729.clockrate); EXPECT_EQ(18, g729.id); - cricket::CodecParameterMap::iterator found = - g729.params.find("annexb"); + cricket::CodecParameterMap::iterator found = g729.params.find("annexb"); ASSERT_TRUE(found != g729.params.end()); EXPECT_EQ(found->second, "yes"); @@ -2315,8 +2290,7 @@ TEST_F(WebRtcSdpTest, DeserializeJsepSessionDescriptionWithFingerprint) { // Add a DTLS a=fingerprint attribute to our session description. AddFingerprint(); JsepSessionDescription new_jdesc(kDummyType); - ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); JsepSessionDescription jdesc_with_fingerprint(kDummyType); @@ -2338,8 +2312,7 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBundle) { group.AddContentName(kAudioContentName); group.AddContentName(kVideoContentName); desc_.AddGroup(group); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_bundle)); } @@ -2347,20 +2320,16 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBundle) { TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBandwidth) { JsepSessionDescription jdesc_with_bandwidth(kDummyType); std::string sdp_with_bandwidth = kSdpFullString; - InjectAfter("a=mid:video_content_name\r\na=sendrecv\r\n", - "b=AS:100\r\n", + InjectAfter("a=mid:video_content_name\r\na=sendrecv\r\n", "b=AS:100\r\n", &sdp_with_bandwidth); - InjectAfter("a=mid:audio_content_name\r\na=sendrecv\r\n", - "b=AS:50\r\n", + InjectAfter("a=mid:audio_content_name\r\na=sendrecv\r\n", "b=AS:50\r\n", &sdp_with_bandwidth); - EXPECT_TRUE( - SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); + EXPECT_TRUE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); vcd->set_bandwidth(100 * 1000); AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); acd->set_bandwidth(50 * 1000); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_bandwidth)); } @@ -2368,14 +2337,11 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBandwidth) { TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithIceOptions) { JsepSessionDescription jdesc_with_ice_options(kDummyType); std::string sdp_with_ice_options = kSdpFullString; - InjectAfter(kSessionTime, - "a=ice-options:iceoption3\r\n", + InjectAfter(kSessionTime, "a=ice-options:iceoption3\r\n", &sdp_with_ice_options); - InjectAfter(kAttributeIcePwdVoice, - "a=ice-options:iceoption1\r\n", + InjectAfter(kAttributeIcePwdVoice, "a=ice-options:iceoption1\r\n", &sdp_with_ice_options); - InjectAfter(kAttributeIcePwdVideo, - "a=ice-options:iceoption2\r\n", + InjectAfter(kAttributeIcePwdVideo, "a=ice-options:iceoption2\r\n", &sdp_with_ice_options); EXPECT_TRUE(SdpDeserialize(sdp_with_ice_options, &jdesc_with_ice_options)); std::vector transport_options; @@ -2386,8 +2352,7 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithIceOptions) { transport_options.push_back(kIceOption3); transport_options.push_back(kIceOption2); AddIceOptions(kVideoContentName, transport_options); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_ice_options)); } @@ -2399,18 +2364,19 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithUfragPwd) { EXPECT_TRUE(RemoveCandidateUfragPwd(&sdp_with_ufrag_pwd)); // Add session level ufrag and pwd InjectAfter(kSessionTime, - "a=ice-pwd:session+level+icepwd\r\n" - "a=ice-ufrag:session+level+iceufrag\r\n", - &sdp_with_ufrag_pwd); + "a=ice-pwd:session+level+icepwd\r\n" + "a=ice-ufrag:session+level+iceufrag\r\n", + &sdp_with_ufrag_pwd); // Add media level ufrag and pwd for audio - InjectAfter("a=mid:audio_content_name\r\n", + InjectAfter( + "a=mid:audio_content_name\r\n", "a=ice-pwd:media+level+icepwd\r\na=ice-ufrag:media+level+iceufrag\r\n", &sdp_with_ufrag_pwd); // Update the candidate ufrag and pwd to the expected ones. - EXPECT_TRUE(UpdateCandidateUfragPwd(&jdesc_, 0, - "media+level+iceufrag", "media+level+icepwd")); - EXPECT_TRUE(UpdateCandidateUfragPwd(&jdesc_, 1, - "session+level+iceufrag", "session+level+icepwd")); + EXPECT_TRUE(UpdateCandidateUfragPwd(&jdesc_, 0, "media+level+iceufrag", + "media+level+icepwd")); + EXPECT_TRUE(UpdateCandidateUfragPwd(&jdesc_, 1, "session+level+iceufrag", + "session+level+icepwd")); EXPECT_TRUE(SdpDeserialize(sdp_with_ufrag_pwd, &jdesc_with_ufrag_pwd)); EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_ufrag_pwd)); } @@ -2497,8 +2463,8 @@ TEST_F(WebRtcSdpTest, DeserializeCandidate) { kCandidateFoundation1); std::unique_ptr jcandidate_template( new JsepIceCandidate(std::string("audio_content_name"), 0, candidate)); - EXPECT_TRUE(jcandidate.candidate().IsEquivalent( - jcandidate_template->candidate())); + EXPECT_TRUE( + jcandidate.candidate().IsEquivalent(jcandidate_template->candidate())); sdp = kSdpTcpPassiveCandidate; EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate)); sdp = kSdpTcpSOCandidate; @@ -2541,7 +2507,7 @@ TEST_F(WebRtcSdpTest, DeserializeRawCandidateAttribute) { // This test verifies that the deserialization of an invalid candidate string // fails. TEST_F(WebRtcSdpTest, DeserializeInvalidCandidiate) { - JsepIceCandidate jcandidate(kDummyMid, kDummyIndex); + JsepIceCandidate jcandidate(kDummyMid, kDummyIndex); std::string candidate_attribute = kRawCandidate; candidate_attribute.replace(0, 1, "x"); @@ -2589,14 +2555,14 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannels) { EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); // Verify with UDP/DTLS/SCTP. - sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), - strlen(kDtlsSctp), kUdpDtlsSctp); + sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), strlen(kDtlsSctp), + kUdpDtlsSctp); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); // Verify with TCP/DTLS/SCTP. - sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), - strlen(kUdpDtlsSctp), kTcpDtlsSctp); + sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), strlen(kUdpDtlsSctp), + kTcpDtlsSctp); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); } @@ -2616,14 +2582,14 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpPort) { EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); // Verify with UDP/DTLS/SCTP. - sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), - strlen(kDtlsSctp), kUdpDtlsSctp); + sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), strlen(kDtlsSctp), + kUdpDtlsSctp); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); // Verify with TCP/DTLS/SCTP. - sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), - strlen(kUdpDtlsSctp), kTcpDtlsSctp); + sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), strlen(kUdpDtlsSctp), + kTcpDtlsSctp); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); } @@ -2643,14 +2609,14 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpColonPort) { EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); // Verify with UDP/DTLS/SCTP. - sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), - strlen(kDtlsSctp), kUdpDtlsSctp); + sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), strlen(kDtlsSctp), + kUdpDtlsSctp); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); // Verify with TCP/DTLS/SCTP. - sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), - strlen(kUdpDtlsSctp), kTcpDtlsSctp); + sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), strlen(kUdpDtlsSctp), + kTcpDtlsSctp); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); } @@ -2753,8 +2719,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) { // See: https://code.google.com/p/chromium/issues/detail?id=280726 std::string sdp_with_bandwidth = kSdpString; sdp_with_bandwidth.append(kSdpRtpDataChannelString); - InjectAfter("a=mid:data_content_name\r\n", - "b=AS:100\r\n", + InjectAfter("a=mid:data_content_name\r\n", "b=AS:100\r\n", &sdp_with_bandwidth); JsepSessionDescription jdesc_with_bandwidth(kDummyType); @@ -2771,8 +2736,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) { std::string sdp_with_bandwidth = kSdpString; sdp_with_bandwidth.append(kSdpSctpDataChannelString); - InjectAfter("a=mid:data_content_name\r\n", - "b=AS:100\r\n", + InjectAfter("a=mid:data_content_name\r\n", "b=AS:100\r\n", &sdp_with_bandwidth); JsepSessionDescription jdesc_with_bandwidth(kDummyType); @@ -2782,24 +2746,21 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) { EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_with_bandwidth)); } -class WebRtcSdpExtmapTest - : public WebRtcSdpTest, public testing::WithParamInterface { -}; +class WebRtcSdpExtmapTest : public WebRtcSdpTest, + public testing::WithParamInterface {}; TEST_P(WebRtcSdpExtmapTest, - DeserializeSessionDescriptionWithSessionLevelExtmap) { + DeserializeSessionDescriptionWithSessionLevelExtmap) { bool encrypted = GetParam(); TestDeserializeExtmap(true, false, encrypted); } -TEST_P(WebRtcSdpExtmapTest, - DeserializeSessionDescriptionWithMediaLevelExtmap) { +TEST_P(WebRtcSdpExtmapTest, DeserializeSessionDescriptionWithMediaLevelExtmap) { bool encrypted = GetParam(); TestDeserializeExtmap(false, true, encrypted); } -TEST_P(WebRtcSdpExtmapTest, - DeserializeSessionDescriptionWithInvalidExtmap) { +TEST_P(WebRtcSdpExtmapTest, DeserializeSessionDescriptionWithInvalidExtmap) { bool encrypted = GetParam(); TestDeserializeExtmap(true, true, encrypted); } @@ -2897,14 +2858,18 @@ TEST_F(WebRtcSdpTest, DeserializeBrokenSdp) { const char kSdpEmptyLine[] = ""; const char kSdpMissingValue[] = "a="; - const char kSdpBrokenFingerprint[] = "a=fingerprint:sha-1 " + const char kSdpBrokenFingerprint[] = + "a=fingerprint:sha-1 " "4AAD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB"; - const char kSdpExtraField[] = "a=fingerprint:sha-1 " + const char kSdpExtraField[] = + "a=fingerprint:sha-1 " "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB XXX"; - const char kSdpMissingSpace[] = "a=fingerprint:sha-1" + const char kSdpMissingSpace[] = + "a=fingerprint:sha-1" "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB"; // MD5 is not allowed in fingerprints. - const char kSdpMd5[] = "a=fingerprint:md5 " + const char kSdpMd5[] = + "a=fingerprint:md5 " "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B"; // Broken session description @@ -2960,8 +2925,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithInvalidAttributeValue) { // bandwidth ExpectParseFailureWithNewLines("a=mid:video_content_name\r\n", - "b=AS:badvalue\r\n", - "b=AS:badvalue"); + "b=AS:badvalue\r\n", "b=AS:badvalue"); // rtcp-fb ExpectParseFailureWithNewLines("a=mid:video_content_name\r\n", "a=rtcp-fb:badvalue nack\r\n", @@ -2981,8 +2945,8 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithReorderedPltypes) { "s=-\r\n" "t=0 0\r\n" "m=audio 9 RTP/SAVPF 104 103\r\n" // Pl type 104 preferred. - "a=rtpmap:111 opus/48000/2\r\n" // Pltype 111 listed before 103 and 104 - // in the map. + "a=rtpmap:111 opus/48000/2\r\n" // Pltype 111 listed before 103 and 104 + // in the map. "a=rtpmap:103 ISAC/16000\r\n" // Pltype 103 listed before 104 in the map. "a=rtpmap:104 ISAC/32000\r\n"; @@ -3107,8 +3071,8 @@ TEST_F(WebRtcSdpTest, DeserializeVideoFmtpWithSpace) { // Deserialize SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, - &error)); + EXPECT_TRUE( + webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); const VideoContentDescription* vcd = GetFirstVideoContentDescription(jdesc_output.description()); @@ -3133,8 +3097,7 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithUnknownParameter) { codecs[0].params["unknown-future-parameter"] = "SomeFutureValue"; acd->set_codecs(codecs); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; @@ -3151,13 +3114,11 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithKnownFmtpParameter) { codecs[0].params["stereo"] = "1"; acd->set_codecs(codecs); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; - InjectAfter("a=rtpmap:111 opus/48000/2\r\n", - "a=fmtp:111 stereo=1\r\n", + InjectAfter("a=rtpmap:111 opus/48000/2\r\n", "a=fmtp:111 stereo=1\r\n", &sdp_with_fmtp); EXPECT_EQ(sdp_with_fmtp, message); } @@ -3170,8 +3131,7 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithPTimeAndMaxPTime) { codecs[0].params["maxptime"] = "120"; acd->set_codecs(codecs); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; @@ -3189,14 +3149,12 @@ TEST_F(WebRtcSdpTest, SerializeVideoFmtp) { codecs[0].params["x-google-min-bitrate"] = "10"; vcd->set_codecs(codecs); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; InjectAfter("a=rtpmap:120 VP8/90000\r\n", - "a=fmtp:120 x-google-min-bitrate=10\r\n", - &sdp_with_fmtp); + "a=fmtp:120 x-google-min-bitrate=10\r\n", &sdp_with_fmtp); EXPECT_EQ(sdp_with_fmtp, message); } @@ -3214,16 +3172,14 @@ TEST_F(WebRtcSdpTest, DeserializeAndSerializeSdpWithIceLite) { EXPECT_EQ(cricket::ICEMODE_FULL, tinfo2->description.ice_mode); // Add "a=ice-lite" and deserialize, making sure it's ICE lite. - InjectAfter(kSessionTime, - "a=ice-lite\r\n", - &sdp_with_icelite); + InjectAfter(kSessionTime, "a=ice-lite\r\n", &sdp_with_icelite); EXPECT_TRUE(SdpDeserialize(sdp_with_icelite, &jdesc_with_icelite)); desc = jdesc_with_icelite.description(); const cricket::TransportInfo* atinfo = desc->GetTransportInfoByName("audio_content_name"); EXPECT_EQ(cricket::ICEMODE_LITE, atinfo->description.ice_mode); const cricket::TransportInfo* vtinfo = - desc->GetTransportInfoByName("video_content_name"); + desc->GetTransportInfoByName("video_content_name"); EXPECT_EQ(cricket::ICEMODE_LITE, vtinfo->description.ice_mode); // Now that we know deserialization works, we can use TestSerialize to test @@ -3249,14 +3205,14 @@ TEST_F(WebRtcSdpTest, SerializeDtlsSetupAttribute) { EXPECT_EQ(cricket::CONNECTIONROLE_NONE, audio_transport_info.description.connection_role); audio_transport_info.description.connection_role = - cricket::CONNECTIONROLE_ACTIVE; + cricket::CONNECTIONROLE_ACTIVE; TransportInfo video_transport_info = *(desc_.GetTransportInfoByName(kVideoContentName)); EXPECT_EQ(cricket::CONNECTIONROLE_NONE, video_transport_info.description.connection_role); video_transport_info.description.connection_role = - cricket::CONNECTIONROLE_ACTIVE; + cricket::CONNECTIONROLE_ACTIVE; desc_.RemoveTransportInfoByName(kAudioContentName); desc_.RemoveTransportInfoByName(kVideoContentName); @@ -3264,29 +3220,23 @@ TEST_F(WebRtcSdpTest, SerializeDtlsSetupAttribute) { desc_.AddTransportInfo(audio_transport_info); desc_.AddTransportInfo(video_transport_info); - ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), - jdesc_.session_id(), + ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), jdesc_.session_version())); std::string message = webrtc::SdpSerialize(jdesc_); std::string sdp_with_dtlssetup = kSdpFullString; // Fingerprint attribute is necessary to add DTLS setup attribute. - InjectAfter(kAttributeIcePwdVoice, - kFingerprint, &sdp_with_dtlssetup); - InjectAfter(kAttributeIcePwdVideo, - kFingerprint, &sdp_with_dtlssetup); + InjectAfter(kAttributeIcePwdVoice, kFingerprint, &sdp_with_dtlssetup); + InjectAfter(kAttributeIcePwdVideo, kFingerprint, &sdp_with_dtlssetup); // Now adding |setup| attribute. - InjectAfter(kFingerprint, - "a=setup:active\r\n", &sdp_with_dtlssetup); + InjectAfter(kFingerprint, "a=setup:active\r\n", &sdp_with_dtlssetup); EXPECT_EQ(sdp_with_dtlssetup, message); } TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttribute) { JsepSessionDescription jdesc_with_dtlssetup(kDummyType); std::string sdp_with_dtlssetup = kSdpFullString; - InjectAfter(kSessionTime, - "a=setup:actpass\r\n", - &sdp_with_dtlssetup); + InjectAfter(kSessionTime, "a=setup:actpass\r\n", &sdp_with_dtlssetup); EXPECT_TRUE(SdpDeserialize(sdp_with_dtlssetup, &jdesc_with_dtlssetup)); cricket::SessionDescription* desc = jdesc_with_dtlssetup.description(); const cricket::TransportInfo* atinfo = @@ -3294,7 +3244,7 @@ TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttribute) { EXPECT_EQ(cricket::CONNECTIONROLE_ACTPASS, atinfo->description.connection_role); const cricket::TransportInfo* vtinfo = - desc->GetTransportInfoByName("video_content_name"); + desc->GetTransportInfoByName("video_content_name"); EXPECT_EQ(cricket::CONNECTIONROLE_ACTPASS, vtinfo->description.connection_role); } @@ -3303,16 +3253,11 @@ TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttribute) { // ContentInfo in SessionDescription, and vise versa for deserialization. TEST_F(WebRtcSdpTest, MediaContentOrderMaintainedRoundTrip) { JsepSessionDescription jdesc(kDummyType); - const std::string media_content_sdps[3] = { - kSdpAudioString, - kSdpVideoString, - kSdpSctpDataChannelString - }; - const cricket::MediaType media_types[3] = { - cricket::MEDIA_TYPE_AUDIO, - cricket::MEDIA_TYPE_VIDEO, - cricket::MEDIA_TYPE_DATA - }; + const std::string media_content_sdps[3] = {kSdpAudioString, kSdpVideoString, + kSdpSctpDataChannelString}; + const cricket::MediaType media_types[3] = {cricket::MEDIA_TYPE_AUDIO, + cricket::MEDIA_TYPE_VIDEO, + cricket::MEDIA_TYPE_DATA}; // Verifies all 6 permutations. for (size_t i = 0; i < 6; ++i) { diff --git a/pc/webrtcsessiondescriptionfactory.cc b/pc/webrtcsessiondescriptionfactory.cc index 46e4129949..4a6221f334 100644 --- a/pc/webrtcsessiondescriptionfactory.cc +++ b/pc/webrtcsessiondescriptionfactory.cc @@ -423,15 +423,19 @@ void WebRtcSessionDescriptionFactory::FailPendingRequests( while (!create_session_description_requests_.empty()) { const CreateSessionDescriptionRequest& request = create_session_description_requests_.front(); - PostCreateSessionDescriptionFailed(request.observer, - ((request.type == CreateSessionDescriptionRequest::kOffer) ? - "CreateOffer" : "CreateAnswer") + reason); + PostCreateSessionDescriptionFailed( + request.observer, + ((request.type == CreateSessionDescriptionRequest::kOffer) + ? "CreateOffer" + : "CreateAnswer") + + reason); create_session_description_requests_.pop(); } } void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionFailed( - CreateSessionDescriptionObserver* observer, const std::string& error) { + CreateSessionDescriptionObserver* observer, + const std::string& error) { CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg( observer, RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error))); signaling_thread_->Post(RTC_FROM_HERE, this, diff --git a/pc/webrtcsessiondescriptionfactory.h b/pc/webrtcsessiondescriptionfactory.h index 88d5727fe3..08d0122858 100644 --- a/pc/webrtcsessiondescriptionfactory.h +++ b/pc/webrtcsessiondescriptionfactory.h @@ -46,13 +46,10 @@ struct CreateSessionDescriptionRequest { kAnswer, }; - CreateSessionDescriptionRequest( - Type type, - CreateSessionDescriptionObserver* observer, - const cricket::MediaSessionOptions& options) - : type(type), - observer(observer), - options(options) {} + CreateSessionDescriptionRequest(Type type, + CreateSessionDescriptionObserver* observer, + const cricket::MediaSessionOptions& options) + : type(type), observer(observer), options(options) {} Type type; rtc::scoped_refptr observer; diff --git a/rtc_base/arraysize.h b/rtc_base/arraysize.h index f7845b5f49..bf8e6d8810 100644 --- a/rtc_base/arraysize.h +++ b/rtc_base/arraysize.h @@ -24,7 +24,8 @@ // This template function declaration is used in defining arraysize. // Note that the function doesn't need an implementation, as we only // use its type. -template char (&ArraySizeHelper(T (&array)[N]))[N]; +template +char (&ArraySizeHelper(T (&array)[N]))[N]; #define arraysize(array) (sizeof(ArraySizeHelper(array))) diff --git a/rtc_base/asyncinvoker-inl.h b/rtc_base/asyncinvoker-inl.h index 0d546b1f04..3ae2430bee 100644 --- a/rtc_base/asyncinvoker-inl.h +++ b/rtc_base/asyncinvoker-inl.h @@ -48,12 +48,10 @@ class AsyncClosure { template class FireAndForgetAsyncClosure : public AsyncClosure { public: - explicit FireAndForgetAsyncClosure(AsyncInvoker* invoker, - FunctorT&& functor) + explicit FireAndForgetAsyncClosure(AsyncInvoker* invoker, FunctorT&& functor) : AsyncClosure(invoker), functor_(std::forward(functor)) {} - virtual void Execute() { - functor_(); - } + virtual void Execute() { functor_(); } + private: typename std::decay::type functor_; }; diff --git a/rtc_base/asyncinvoker.cc b/rtc_base/asyncinvoker.cc index 7033c1a834..e255fb98fc 100644 --- a/rtc_base/asyncinvoker.cc +++ b/rtc_base/asyncinvoker.cc @@ -106,8 +106,7 @@ GuardedAsyncInvoker::GuardedAsyncInvoker() : thread_(Thread::Current()) { &GuardedAsyncInvoker::ThreadDestroyed); } -GuardedAsyncInvoker::~GuardedAsyncInvoker() { -} +GuardedAsyncInvoker::~GuardedAsyncInvoker() {} bool GuardedAsyncInvoker::Flush(uint32_t id) { CritScope cs(&crit_); diff --git a/rtc_base/asyncpacketsocket.h b/rtc_base/asyncpacketsocket.h index ca59afb806..820fe941ac 100644 --- a/rtc_base/asyncpacketsocket.h +++ b/rtc_base/asyncpacketsocket.h @@ -28,9 +28,9 @@ struct PacketTimeUpdateParams { ~PacketTimeUpdateParams(); int rtp_sendtime_extension_id = -1; // extension header id present in packet. - std::vector srtp_auth_key; // Authentication key. - int srtp_auth_tag_len = -1; // Authentication tag length. - int64_t srtp_packet_index = -1; // Required for Rtp Packet authentication. + std::vector srtp_auth_key; // Authentication key. + int srtp_auth_tag_len = -1; // Authentication tag length. + int64_t srtp_packet_index = -1; // Required for Rtp Packet authentication. }; // This structure holds meta information for the packet which is about to send @@ -57,7 +57,7 @@ struct PacketTime { PacketTime(int64_t timestamp, int64_t not_before) : timestamp(timestamp), not_before(not_before) {} - int64_t timestamp; // Receive time after socket delivers the data. + int64_t timestamp; // Receive time after socket delivers the data. // Earliest possible time the data could have arrived, indicating the // potential error in the |timestamp| value, in case the system, is busy. For @@ -93,8 +93,10 @@ class AsyncPacketSocket : public sigslot::has_slots<> { virtual SocketAddress GetRemoteAddress() const = 0; // Send a packet. - virtual int Send(const void *pv, size_t cb, const PacketOptions& options) = 0; - virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr, + virtual int Send(const void* pv, size_t cb, const PacketOptions& options) = 0; + virtual int SendTo(const void* pv, + size_t cb, + const SocketAddress& addr, const PacketOptions& options) = 0; // Close the socket. @@ -114,9 +116,12 @@ class AsyncPacketSocket : public sigslot::has_slots<> { // Emitted each time a packet is read. Used only for UDP and // connected TCP sockets. - sigslot::signal5 SignalReadPacket; + const PacketTime&> + SignalReadPacket; // Emitted each time a packet is sent. sigslot::signal2 SignalSentPacket; diff --git a/rtc_base/asyncresolverinterface.cc b/rtc_base/asyncresolverinterface.cc index 62dd36ac8d..b2880f2878 100644 --- a/rtc_base/asyncresolverinterface.cc +++ b/rtc_base/asyncresolverinterface.cc @@ -12,8 +12,7 @@ namespace rtc { -AsyncResolverInterface::AsyncResolverInterface() { -} +AsyncResolverInterface::AsyncResolverInterface() {} AsyncResolverInterface::~AsyncResolverInterface() = default; diff --git a/rtc_base/asyncsocket.cc b/rtc_base/asyncsocket.cc index b28b2f9c44..acd5415eb5 100644 --- a/rtc_base/asyncsocket.cc +++ b/rtc_base/asyncsocket.cc @@ -13,11 +13,9 @@ namespace rtc { -AsyncSocket::AsyncSocket() { -} +AsyncSocket::AsyncSocket() {} -AsyncSocket::~AsyncSocket() { -} +AsyncSocket::~AsyncSocket() {} AsyncSocketAdapter::AsyncSocketAdapter(AsyncSocket* socket) : socket_(nullptr) { Attach(socket); diff --git a/rtc_base/asyncsocket.h b/rtc_base/asyncsocket.h index c018c23f07..bf9c2822f1 100644 --- a/rtc_base/asyncsocket.h +++ b/rtc_base/asyncsocket.h @@ -31,11 +31,10 @@ class AsyncSocket : public Socket { // For example SignalReadEvent::connect will be called in AsyncUDPSocket ctor // but at the same time the SocketDispatcher maybe signaling the read event. // ready to read - sigslot::signal1 SignalReadEvent; + sigslot::signal1 SignalReadEvent; // ready to write - sigslot::signal1 SignalWriteEvent; + sigslot::signal1 + SignalWriteEvent; sigslot::signal1 SignalConnectEvent; // connected sigslot::signal2 SignalCloseEvent; // closed }; diff --git a/rtc_base/asynctcpsocket.cc b/rtc_base/asynctcpsocket.cc index 058d945cf2..3d68a2a46a 100644 --- a/rtc_base/asynctcpsocket.cc +++ b/rtc_base/asynctcpsocket.cc @@ -56,7 +56,8 @@ AsyncSocket* AsyncTCPSocketBase::ConnectSocket( return owned_socket.release(); } -AsyncTCPSocketBase::AsyncTCPSocketBase(AsyncSocket* socket, bool listen, +AsyncTCPSocketBase::AsyncTCPSocketBase(AsyncSocket* socket, + bool listen, size_t max_packet_size) : socket_(socket), listen_(listen), @@ -68,8 +69,8 @@ AsyncTCPSocketBase::AsyncTCPSocketBase(AsyncSocket* socket, bool listen, } RTC_DCHECK(socket_.get() != nullptr); - socket_->SignalConnectEvent.connect( - this, &AsyncTCPSocketBase::OnConnectEvent); + socket_->SignalConnectEvent.connect(this, + &AsyncTCPSocketBase::OnConnectEvent); socket_->SignalReadEvent.connect(this, &AsyncTCPSocketBase::OnReadEvent); socket_->SignalWriteEvent.connect(this, &AsyncTCPSocketBase::OnWriteEvent); socket_->SignalCloseEvent.connect(this, &AsyncTCPSocketBase::OnCloseEvent); @@ -129,7 +130,8 @@ void AsyncTCPSocketBase::SetError(int error) { return socket_->SetError(error); } -int AsyncTCPSocketBase::SendTo(const void *pv, size_t cb, +int AsyncTCPSocketBase::SendTo(const void* pv, + size_t cb, const SocketAddress& addr, const rtc::PacketOptions& options) { const SocketAddress& remote_address = GetRemoteAddress(); @@ -141,7 +143,7 @@ int AsyncTCPSocketBase::SendTo(const void *pv, size_t cb, return -1; } -int AsyncTCPSocketBase::SendRaw(const void * pv, size_t cb) { +int AsyncTCPSocketBase::SendRaw(const void* pv, size_t cb) { if (outbuf_.size() + cb > max_outsize_) { socket_->SetError(EMSGSIZE); return -1; @@ -263,19 +265,19 @@ void AsyncTCPSocketBase::OnCloseEvent(AsyncSocket* socket, int error) { // Binds and connects |socket| and creates AsyncTCPSocket for // it. Takes ownership of |socket|. Returns null if bind() or // connect() fail (|socket| is destroyed in that case). -AsyncTCPSocket* AsyncTCPSocket::Create( - AsyncSocket* socket, - const SocketAddress& bind_address, - const SocketAddress& remote_address) { - return new AsyncTCPSocket(AsyncTCPSocketBase::ConnectSocket( - socket, bind_address, remote_address), false); +AsyncTCPSocket* AsyncTCPSocket::Create(AsyncSocket* socket, + const SocketAddress& bind_address, + const SocketAddress& remote_address) { + return new AsyncTCPSocket( + AsyncTCPSocketBase::ConnectSocket(socket, bind_address, remote_address), + false); } AsyncTCPSocket::AsyncTCPSocket(AsyncSocket* socket, bool listen) - : AsyncTCPSocketBase(socket, listen, kBufSize) { -} + : AsyncTCPSocketBase(socket, listen, kBufSize) {} -int AsyncTCPSocket::Send(const void *pv, size_t cb, +int AsyncTCPSocket::Send(const void* pv, + size_t cb, const rtc::PacketOptions& options) { if (cb > kBufSize) { SetError(EMSGSIZE); @@ -306,7 +308,7 @@ int AsyncTCPSocket::Send(const void *pv, size_t cb, return static_cast(cb); } -void AsyncTCPSocket::ProcessInput(char * data, size_t* len) { +void AsyncTCPSocket::ProcessInput(char* data, size_t* len) { SocketAddress remote_addr(GetRemoteAddress()); while (true) { diff --git a/rtc_base/asynctcpsocket.h b/rtc_base/asynctcpsocket.h index 0a548d04cb..943e010f4d 100644 --- a/rtc_base/asynctcpsocket.h +++ b/rtc_base/asynctcpsocket.h @@ -29,8 +29,9 @@ class AsyncTCPSocketBase : public AsyncPacketSocket { ~AsyncTCPSocketBase() override; // Pure virtual methods to send and recv data. - int Send(const void *pv, size_t cb, - const rtc::PacketOptions& options) override = 0; + int Send(const void* pv, + size_t cb, + const rtc::PacketOptions& options) override = 0; virtual void ProcessInput(char* data, size_t* len) = 0; // Signals incoming connection. virtual void HandleIncomingConnection(AsyncSocket* socket) = 0; diff --git a/rtc_base/asynctcpsocket_unittest.cc b/rtc_base/asynctcpsocket_unittest.cc index 7081411930..e8fd96cb8b 100644 --- a/rtc_base/asynctcpsocket_unittest.cc +++ b/rtc_base/asynctcpsocket_unittest.cc @@ -17,9 +17,7 @@ namespace rtc { -class AsyncTCPSocketTest - : public testing::Test, - public sigslot::has_slots<> { +class AsyncTCPSocketTest : public testing::Test, public sigslot::has_slots<> { public: AsyncTCPSocketTest() : vss_(new rtc::VirtualSocketServer()), @@ -30,9 +28,7 @@ class AsyncTCPSocketTest &AsyncTCPSocketTest::OnReadyToSend); } - void OnReadyToSend(rtc::AsyncPacketSocket* socket) { - ready_to_send_ = true; - } + void OnReadyToSend(rtc::AsyncPacketSocket* socket) { ready_to_send_ = true; } protected: std::unique_ptr vss_; diff --git a/rtc_base/asyncudpsocket.cc b/rtc_base/asyncudpsocket.cc index d8e60b9a42..ba5fa88aad 100644 --- a/rtc_base/asyncudpsocket.cc +++ b/rtc_base/asyncudpsocket.cc @@ -16,9 +16,8 @@ namespace rtc { static const int BUF_SIZE = 64 * 1024; -AsyncUDPSocket* AsyncUDPSocket::Create( - AsyncSocket* socket, - const SocketAddress& bind_address) { +AsyncUDPSocket* AsyncUDPSocket::Create(AsyncSocket* socket, + const SocketAddress& bind_address) { std::unique_ptr owned_socket(socket); if (socket->Bind(bind_address) < 0) { RTC_LOG(LS_ERROR) << "Bind() failed with error " << socket->GetError(); @@ -36,8 +35,7 @@ AsyncUDPSocket* AsyncUDPSocket::Create(SocketFactory* factory, return Create(socket, bind_address); } -AsyncUDPSocket::AsyncUDPSocket(AsyncSocket* socket) - : socket_(socket) { +AsyncUDPSocket::AsyncUDPSocket(AsyncSocket* socket) : socket_(socket) { size_ = BUF_SIZE; buf_ = new char[size_]; @@ -47,7 +45,7 @@ AsyncUDPSocket::AsyncUDPSocket(AsyncSocket* socket) } AsyncUDPSocket::~AsyncUDPSocket() { - delete [] buf_; + delete[] buf_; } SocketAddress AsyncUDPSocket::GetLocalAddress() const { @@ -58,7 +56,8 @@ SocketAddress AsyncUDPSocket::GetRemoteAddress() const { return socket_->GetRemoteAddress(); } -int AsyncUDPSocket::Send(const void *pv, size_t cb, +int AsyncUDPSocket::Send(const void* pv, + size_t cb, const rtc::PacketOptions& options) { rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis(), options.info_signaled_after_sent); @@ -68,7 +67,8 @@ int AsyncUDPSocket::Send(const void *pv, size_t cb, return ret; } -int AsyncUDPSocket::SendTo(const void *pv, size_t cb, +int AsyncUDPSocket::SendTo(const void* pv, + size_t cb, const SocketAddress& addr, const rtc::PacketOptions& options) { rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis(), @@ -117,8 +117,7 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) { // TODO: Do something better like forwarding the error to the user. SocketAddress local_addr = socket_->GetLocalAddress(); RTC_LOG(LS_INFO) << "AsyncUDPSocket[" << local_addr.ToSensitiveString() - << "] receive failed with error " - << socket_->GetError(); + << "] receive failed with error " << socket_->GetError(); return; } diff --git a/rtc_base/asyncudpsocket_unittest.cc b/rtc_base/asyncudpsocket_unittest.cc index af7cc20c6a..33b3d13671 100644 --- a/rtc_base/asyncudpsocket_unittest.cc +++ b/rtc_base/asyncudpsocket_unittest.cc @@ -18,9 +18,7 @@ namespace rtc { -class AsyncUdpSocketTest - : public testing::Test, - public sigslot::has_slots<> { +class AsyncUdpSocketTest : public testing::Test, public sigslot::has_slots<> { public: AsyncUdpSocketTest() : pss_(new rtc::PhysicalSocketServer), @@ -32,9 +30,7 @@ class AsyncUdpSocketTest &AsyncUdpSocketTest::OnReadyToSend); } - void OnReadyToSend(rtc::AsyncPacketSocket* socket) { - ready_to_send_ = true; - } + void OnReadyToSend(rtc::AsyncPacketSocket* socket) { ready_to_send_ = true; } protected: std::unique_ptr pss_; diff --git a/rtc_base/atomicops.h b/rtc_base/atomicops.h index a4f9a4fe05..16fa603a4e 100644 --- a/rtc_base/atomicops.h +++ b/rtc_base/atomicops.h @@ -12,11 +12,15 @@ #define RTC_BASE_ATOMICOPS_H_ #if defined(WEBRTC_WIN) +// clang-format off +// clang formating would change include order. + // Include winsock2.h before including to maintain consistency with // win32.h. To include win32.h directly, it must be broken out into its own // build target. #include #include +// clang-format on #endif // defined(WEBRTC_WIN) namespace rtc { @@ -30,16 +34,11 @@ class AtomicOps { static int Decrement(volatile int* i) { return ::InterlockedDecrement(reinterpret_cast(i)); } - static int AcquireLoad(volatile const int* i) { - return *i; - } - static void ReleaseStore(volatile int* i, int value) { - *i = value; - } + static int AcquireLoad(volatile const int* i) { return *i; } + static void ReleaseStore(volatile int* i, int value) { *i = value; } static int CompareAndSwap(volatile int* i, int old_value, int new_value) { return ::InterlockedCompareExchange(reinterpret_cast(i), - new_value, - old_value); + new_value, old_value); } // Pointer variants. template @@ -52,12 +51,8 @@ class AtomicOps { reinterpret_cast(ptr), new_value, old_value)); } #else - static int Increment(volatile int* i) { - return __sync_add_and_fetch(i, 1); - } - static int Decrement(volatile int* i) { - return __sync_sub_and_fetch(i, 1); - } + static int Increment(volatile int* i) { return __sync_add_and_fetch(i, 1); } + static int Decrement(volatile int* i) { return __sync_sub_and_fetch(i, 1); } static int AcquireLoad(volatile const int* i) { return __atomic_load_n(i, __ATOMIC_ACQUIRE); } @@ -79,8 +74,6 @@ class AtomicOps { #endif }; - - -} +} // namespace rtc #endif // RTC_BASE_ATOMICOPS_H_ diff --git a/rtc_base/base64_unittest.cc b/rtc_base/base64_unittest.cc index 0f7c80da44..f73b39645a 100644 --- a/rtc_base/base64_unittest.cc +++ b/rtc_base/base64_unittest.cc @@ -24,257 +24,257 @@ static struct { const char* cyphertext; } base64_tests[] = { - // Basic bit patterns; - // values obtained with "echo -n '...' | uuencode -m test" + // Basic bit patterns; + // values obtained with "echo -n '...' | uuencode -m test" - { 1, "\000", "AA==" }, - { 1, "\001", "AQ==" }, - { 1, "\002", "Ag==" }, - { 1, "\004", "BA==" }, - { 1, "\010", "CA==" }, - { 1, "\020", "EA==" }, - { 1, "\040", "IA==" }, - { 1, "\100", "QA==" }, - { 1, "\200", "gA==" }, + {1, "\000", "AA=="}, + {1, "\001", "AQ=="}, + {1, "\002", "Ag=="}, + {1, "\004", "BA=="}, + {1, "\010", "CA=="}, + {1, "\020", "EA=="}, + {1, "\040", "IA=="}, + {1, "\100", "QA=="}, + {1, "\200", "gA=="}, - { 1, "\377", "/w==" }, - { 1, "\376", "/g==" }, - { 1, "\375", "/Q==" }, - { 1, "\373", "+w==" }, - { 1, "\367", "9w==" }, - { 1, "\357", "7w==" }, - { 1, "\337", "3w==" }, - { 1, "\277", "vw==" }, - { 1, "\177", "fw==" }, - { 2, "\000\000", "AAA=" }, - { 2, "\000\001", "AAE=" }, - { 2, "\000\002", "AAI=" }, - { 2, "\000\004", "AAQ=" }, - { 2, "\000\010", "AAg=" }, - { 2, "\000\020", "ABA=" }, - { 2, "\000\040", "ACA=" }, - { 2, "\000\100", "AEA=" }, - { 2, "\000\200", "AIA=" }, - { 2, "\001\000", "AQA=" }, - { 2, "\002\000", "AgA=" }, - { 2, "\004\000", "BAA=" }, - { 2, "\010\000", "CAA=" }, - { 2, "\020\000", "EAA=" }, - { 2, "\040\000", "IAA=" }, - { 2, "\100\000", "QAA=" }, - { 2, "\200\000", "gAA=" }, + {1, "\377", "/w=="}, + {1, "\376", "/g=="}, + {1, "\375", "/Q=="}, + {1, "\373", "+w=="}, + {1, "\367", "9w=="}, + {1, "\357", "7w=="}, + {1, "\337", "3w=="}, + {1, "\277", "vw=="}, + {1, "\177", "fw=="}, + {2, "\000\000", "AAA="}, + {2, "\000\001", "AAE="}, + {2, "\000\002", "AAI="}, + {2, "\000\004", "AAQ="}, + {2, "\000\010", "AAg="}, + {2, "\000\020", "ABA="}, + {2, "\000\040", "ACA="}, + {2, "\000\100", "AEA="}, + {2, "\000\200", "AIA="}, + {2, "\001\000", "AQA="}, + {2, "\002\000", "AgA="}, + {2, "\004\000", "BAA="}, + {2, "\010\000", "CAA="}, + {2, "\020\000", "EAA="}, + {2, "\040\000", "IAA="}, + {2, "\100\000", "QAA="}, + {2, "\200\000", "gAA="}, - { 2, "\377\377", "//8=" }, - { 2, "\377\376", "//4=" }, - { 2, "\377\375", "//0=" }, - { 2, "\377\373", "//s=" }, - { 2, "\377\367", "//c=" }, - { 2, "\377\357", "/+8=" }, - { 2, "\377\337", "/98=" }, - { 2, "\377\277", "/78=" }, - { 2, "\377\177", "/38=" }, - { 2, "\376\377", "/v8=" }, - { 2, "\375\377", "/f8=" }, - { 2, "\373\377", "+/8=" }, - { 2, "\367\377", "9/8=" }, - { 2, "\357\377", "7/8=" }, - { 2, "\337\377", "3/8=" }, - { 2, "\277\377", "v/8=" }, - { 2, "\177\377", "f/8=" }, + {2, "\377\377", "//8="}, + {2, "\377\376", "//4="}, + {2, "\377\375", "//0="}, + {2, "\377\373", "//s="}, + {2, "\377\367", "//c="}, + {2, "\377\357", "/+8="}, + {2, "\377\337", "/98="}, + {2, "\377\277", "/78="}, + {2, "\377\177", "/38="}, + {2, "\376\377", "/v8="}, + {2, "\375\377", "/f8="}, + {2, "\373\377", "+/8="}, + {2, "\367\377", "9/8="}, + {2, "\357\377", "7/8="}, + {2, "\337\377", "3/8="}, + {2, "\277\377", "v/8="}, + {2, "\177\377", "f/8="}, - { 3, "\000\000\000", "AAAA" }, - { 3, "\000\000\001", "AAAB" }, - { 3, "\000\000\002", "AAAC" }, - { 3, "\000\000\004", "AAAE" }, - { 3, "\000\000\010", "AAAI" }, - { 3, "\000\000\020", "AAAQ" }, - { 3, "\000\000\040", "AAAg" }, - { 3, "\000\000\100", "AABA" }, - { 3, "\000\000\200", "AACA" }, - { 3, "\000\001\000", "AAEA" }, - { 3, "\000\002\000", "AAIA" }, - { 3, "\000\004\000", "AAQA" }, - { 3, "\000\010\000", "AAgA" }, - { 3, "\000\020\000", "ABAA" }, - { 3, "\000\040\000", "ACAA" }, - { 3, "\000\100\000", "AEAA" }, - { 3, "\000\200\000", "AIAA" }, - { 3, "\001\000\000", "AQAA" }, - { 3, "\002\000\000", "AgAA" }, - { 3, "\004\000\000", "BAAA" }, - { 3, "\010\000\000", "CAAA" }, - { 3, "\020\000\000", "EAAA" }, - { 3, "\040\000\000", "IAAA" }, - { 3, "\100\000\000", "QAAA" }, - { 3, "\200\000\000", "gAAA" }, + {3, "\000\000\000", "AAAA"}, + {3, "\000\000\001", "AAAB"}, + {3, "\000\000\002", "AAAC"}, + {3, "\000\000\004", "AAAE"}, + {3, "\000\000\010", "AAAI"}, + {3, "\000\000\020", "AAAQ"}, + {3, "\000\000\040", "AAAg"}, + {3, "\000\000\100", "AABA"}, + {3, "\000\000\200", "AACA"}, + {3, "\000\001\000", "AAEA"}, + {3, "\000\002\000", "AAIA"}, + {3, "\000\004\000", "AAQA"}, + {3, "\000\010\000", "AAgA"}, + {3, "\000\020\000", "ABAA"}, + {3, "\000\040\000", "ACAA"}, + {3, "\000\100\000", "AEAA"}, + {3, "\000\200\000", "AIAA"}, + {3, "\001\000\000", "AQAA"}, + {3, "\002\000\000", "AgAA"}, + {3, "\004\000\000", "BAAA"}, + {3, "\010\000\000", "CAAA"}, + {3, "\020\000\000", "EAAA"}, + {3, "\040\000\000", "IAAA"}, + {3, "\100\000\000", "QAAA"}, + {3, "\200\000\000", "gAAA"}, - { 3, "\377\377\377", "////" }, - { 3, "\377\377\376", "///+" }, - { 3, "\377\377\375", "///9" }, - { 3, "\377\377\373", "///7" }, - { 3, "\377\377\367", "///3" }, - { 3, "\377\377\357", "///v" }, - { 3, "\377\377\337", "///f" }, - { 3, "\377\377\277", "//+/" }, - { 3, "\377\377\177", "//9/" }, - { 3, "\377\376\377", "//7/" }, - { 3, "\377\375\377", "//3/" }, - { 3, "\377\373\377", "//v/" }, - { 3, "\377\367\377", "//f/" }, - { 3, "\377\357\377", "/+//" }, - { 3, "\377\337\377", "/9//" }, - { 3, "\377\277\377", "/7//" }, - { 3, "\377\177\377", "/3//" }, - { 3, "\376\377\377", "/v//" }, - { 3, "\375\377\377", "/f//" }, - { 3, "\373\377\377", "+///" }, - { 3, "\367\377\377", "9///" }, - { 3, "\357\377\377", "7///" }, - { 3, "\337\377\377", "3///" }, - { 3, "\277\377\377", "v///" }, - { 3, "\177\377\377", "f///" }, + {3, "\377\377\377", "////"}, + {3, "\377\377\376", "///+"}, + {3, "\377\377\375", "///9"}, + {3, "\377\377\373", "///7"}, + {3, "\377\377\367", "///3"}, + {3, "\377\377\357", "///v"}, + {3, "\377\377\337", "///f"}, + {3, "\377\377\277", "//+/"}, + {3, "\377\377\177", "//9/"}, + {3, "\377\376\377", "//7/"}, + {3, "\377\375\377", "//3/"}, + {3, "\377\373\377", "//v/"}, + {3, "\377\367\377", "//f/"}, + {3, "\377\357\377", "/+//"}, + {3, "\377\337\377", "/9//"}, + {3, "\377\277\377", "/7//"}, + {3, "\377\177\377", "/3//"}, + {3, "\376\377\377", "/v//"}, + {3, "\375\377\377", "/f//"}, + {3, "\373\377\377", "+///"}, + {3, "\367\377\377", "9///"}, + {3, "\357\377\377", "7///"}, + {3, "\337\377\377", "3///"}, + {3, "\277\377\377", "v///"}, + {3, "\177\377\377", "f///"}, - // Random numbers: values obtained with - // - // #! /bin/bash - // dd bs=$1 count=1 if=/dev/random of=/tmp/bar.random - // od -N $1 -t o1 /tmp/bar.random - // uuencode -m test < /tmp/bar.random - // - // where $1 is the number of bytes (2, 3) + // Random numbers: values obtained with + // + // #! /bin/bash + // dd bs=$1 count=1 if=/dev/random of=/tmp/bar.random + // od -N $1 -t o1 /tmp/bar.random + // uuencode -m test < /tmp/bar.random + // + // where $1 is the number of bytes (2, 3) - { 2, "\243\361", "o/E=" }, - { 2, "\024\167", "FHc=" }, - { 2, "\313\252", "y6o=" }, - { 2, "\046\041", "JiE=" }, - { 2, "\145\236", "ZZ4=" }, - { 2, "\254\325", "rNU=" }, - { 2, "\061\330", "Mdg=" }, - { 2, "\245\032", "pRo=" }, - { 2, "\006\000", "BgA=" }, - { 2, "\375\131", "/Vk=" }, - { 2, "\303\210", "w4g=" }, - { 2, "\040\037", "IB8=" }, - { 2, "\261\372", "sfo=" }, - { 2, "\335\014", "3Qw=" }, - { 2, "\233\217", "m48=" }, - { 2, "\373\056", "+y4=" }, - { 2, "\247\232", "p5o=" }, - { 2, "\107\053", "Rys=" }, - { 2, "\204\077", "hD8=" }, - { 2, "\276\211", "vok=" }, - { 2, "\313\110", "y0g=" }, - { 2, "\363\376", "8/4=" }, - { 2, "\251\234", "qZw=" }, - { 2, "\103\262", "Q7I=" }, - { 2, "\142\312", "Yso=" }, - { 2, "\067\211", "N4k=" }, - { 2, "\220\001", "kAE=" }, - { 2, "\152\240", "aqA=" }, - { 2, "\367\061", "9zE=" }, - { 2, "\133\255", "W60=" }, - { 2, "\176\035", "fh0=" }, - { 2, "\032\231", "Gpk=" }, + {2, "\243\361", "o/E="}, + {2, "\024\167", "FHc="}, + {2, "\313\252", "y6o="}, + {2, "\046\041", "JiE="}, + {2, "\145\236", "ZZ4="}, + {2, "\254\325", "rNU="}, + {2, "\061\330", "Mdg="}, + {2, "\245\032", "pRo="}, + {2, "\006\000", "BgA="}, + {2, "\375\131", "/Vk="}, + {2, "\303\210", "w4g="}, + {2, "\040\037", "IB8="}, + {2, "\261\372", "sfo="}, + {2, "\335\014", "3Qw="}, + {2, "\233\217", "m48="}, + {2, "\373\056", "+y4="}, + {2, "\247\232", "p5o="}, + {2, "\107\053", "Rys="}, + {2, "\204\077", "hD8="}, + {2, "\276\211", "vok="}, + {2, "\313\110", "y0g="}, + {2, "\363\376", "8/4="}, + {2, "\251\234", "qZw="}, + {2, "\103\262", "Q7I="}, + {2, "\142\312", "Yso="}, + {2, "\067\211", "N4k="}, + {2, "\220\001", "kAE="}, + {2, "\152\240", "aqA="}, + {2, "\367\061", "9zE="}, + {2, "\133\255", "W60="}, + {2, "\176\035", "fh0="}, + {2, "\032\231", "Gpk="}, - { 3, "\013\007\144", "Cwdk" }, - { 3, "\030\112\106", "GEpG" }, - { 3, "\047\325\046", "J9Um" }, - { 3, "\310\160\022", "yHAS" }, - { 3, "\131\100\237", "WUCf" }, - { 3, "\064\342\134", "NOJc" }, - { 3, "\010\177\004", "CH8E" }, - { 3, "\345\147\205", "5WeF" }, - { 3, "\300\343\360", "wOPw" }, - { 3, "\061\240\201", "MaCB" }, - { 3, "\225\333\044", "ldsk" }, - { 3, "\215\137\352", "jV/q" }, - { 3, "\371\147\160", "+Wdw" }, - { 3, "\030\320\051", "GNAp" }, - { 3, "\044\174\241", "JHyh" }, - { 3, "\260\127\037", "sFcf" }, - { 3, "\111\045\033", "SSUb" }, - { 3, "\202\114\107", "gkxH" }, - { 3, "\057\371\042", "L/ki" }, - { 3, "\223\247\244", "k6ek" }, - { 3, "\047\216\144", "J45k" }, - { 3, "\203\070\327", "gzjX" }, - { 3, "\247\140\072", "p2A6" }, - { 3, "\124\115\116", "VE1O" }, - { 3, "\157\162\050", "b3Io" }, - { 3, "\357\223\004", "75ME" }, - { 3, "\052\117\156", "Kk9u" }, - { 3, "\347\154\000", "52wA" }, - { 3, "\303\012\142", "wwpi" }, - { 3, "\060\035\362", "MB3y" }, - { 3, "\130\226\361", "WJbx" }, - { 3, "\173\013\071", "ews5" }, - { 3, "\336\004\027", "3gQX" }, - { 3, "\357\366\234", "7/ac" }, - { 3, "\353\304\111", "68RJ" }, - { 3, "\024\264\131", "FLRZ" }, - { 3, "\075\114\251", "PUyp" }, - { 3, "\315\031\225", "zRmV" }, - { 3, "\154\201\276", "bIG+" }, - { 3, "\200\066\072", "gDY6" }, - { 3, "\142\350\267", "Yui3" }, - { 3, "\033\000\166", "GwB2" }, - { 3, "\210\055\077", "iC0/" }, - { 3, "\341\037\124", "4R9U" }, - { 3, "\161\103\152", "cUNq" }, - { 3, "\270\142\131", "uGJZ" }, - { 3, "\337\076\074", "3z48" }, - { 3, "\375\106\362", "/Uby" }, - { 3, "\227\301\127", "l8FX" }, - { 3, "\340\002\234", "4AKc" }, - { 3, "\121\064\033", "UTQb" }, - { 3, "\157\134\143", "b1xj" }, - { 3, "\247\055\327", "py3X" }, - { 3, "\340\142\005", "4GIF" }, - { 3, "\060\260\143", "MLBj" }, - { 3, "\075\203\170", "PYN4" }, - { 3, "\143\160\016", "Y3AO" }, - { 3, "\313\013\063", "ywsz" }, - { 3, "\174\236\135", "fJ5d" }, - { 3, "\103\047\026", "QycW" }, - { 3, "\365\005\343", "9QXj" }, - { 3, "\271\160\223", "uXCT" }, - { 3, "\362\255\172", "8q16" }, - { 3, "\113\012\015", "SwoN" }, + {3, "\013\007\144", "Cwdk"}, + {3, "\030\112\106", "GEpG"}, + {3, "\047\325\046", "J9Um"}, + {3, "\310\160\022", "yHAS"}, + {3, "\131\100\237", "WUCf"}, + {3, "\064\342\134", "NOJc"}, + {3, "\010\177\004", "CH8E"}, + {3, "\345\147\205", "5WeF"}, + {3, "\300\343\360", "wOPw"}, + {3, "\061\240\201", "MaCB"}, + {3, "\225\333\044", "ldsk"}, + {3, "\215\137\352", "jV/q"}, + {3, "\371\147\160", "+Wdw"}, + {3, "\030\320\051", "GNAp"}, + {3, "\044\174\241", "JHyh"}, + {3, "\260\127\037", "sFcf"}, + {3, "\111\045\033", "SSUb"}, + {3, "\202\114\107", "gkxH"}, + {3, "\057\371\042", "L/ki"}, + {3, "\223\247\244", "k6ek"}, + {3, "\047\216\144", "J45k"}, + {3, "\203\070\327", "gzjX"}, + {3, "\247\140\072", "p2A6"}, + {3, "\124\115\116", "VE1O"}, + {3, "\157\162\050", "b3Io"}, + {3, "\357\223\004", "75ME"}, + {3, "\052\117\156", "Kk9u"}, + {3, "\347\154\000", "52wA"}, + {3, "\303\012\142", "wwpi"}, + {3, "\060\035\362", "MB3y"}, + {3, "\130\226\361", "WJbx"}, + {3, "\173\013\071", "ews5"}, + {3, "\336\004\027", "3gQX"}, + {3, "\357\366\234", "7/ac"}, + {3, "\353\304\111", "68RJ"}, + {3, "\024\264\131", "FLRZ"}, + {3, "\075\114\251", "PUyp"}, + {3, "\315\031\225", "zRmV"}, + {3, "\154\201\276", "bIG+"}, + {3, "\200\066\072", "gDY6"}, + {3, "\142\350\267", "Yui3"}, + {3, "\033\000\166", "GwB2"}, + {3, "\210\055\077", "iC0/"}, + {3, "\341\037\124", "4R9U"}, + {3, "\161\103\152", "cUNq"}, + {3, "\270\142\131", "uGJZ"}, + {3, "\337\076\074", "3z48"}, + {3, "\375\106\362", "/Uby"}, + {3, "\227\301\127", "l8FX"}, + {3, "\340\002\234", "4AKc"}, + {3, "\121\064\033", "UTQb"}, + {3, "\157\134\143", "b1xj"}, + {3, "\247\055\327", "py3X"}, + {3, "\340\142\005", "4GIF"}, + {3, "\060\260\143", "MLBj"}, + {3, "\075\203\170", "PYN4"}, + {3, "\143\160\016", "Y3AO"}, + {3, "\313\013\063", "ywsz"}, + {3, "\174\236\135", "fJ5d"}, + {3, "\103\047\026", "QycW"}, + {3, "\365\005\343", "9QXj"}, + {3, "\271\160\223", "uXCT"}, + {3, "\362\255\172", "8q16"}, + {3, "\113\012\015", "SwoN"}, - // various lengths, generated by this python script: - // - // from string import lowercase as lc - // for i in range(27): - // print '{ %2d, "%s",%s "%s" },' % (i, lc[:i], ' ' * (26-i), - // lc[:i].encode('base64').strip()) + // various lengths, generated by this python script: + // + // from string import lowercase as lc + // for i in range(27): + // print '{ %2d, "%s",%s "%s" },' % (i, lc[:i], ' ' * (26-i), + // lc[:i].encode('base64').strip()) - { 0, "abcdefghijklmnopqrstuvwxyz", "" }, - { 1, "abcdefghijklmnopqrstuvwxyz", "YQ==" }, - { 2, "abcdefghijklmnopqrstuvwxyz", "YWI=" }, - { 3, "abcdefghijklmnopqrstuvwxyz", "YWJj" }, - { 4, "abcdefghijklmnopqrstuvwxyz", "YWJjZA==" }, - { 5, "abcdefghijklmnopqrstuvwxyz", "YWJjZGU=" }, - { 6, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVm" }, - { 7, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZw==" }, - { 8, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2g=" }, - { 9, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hp" }, - { 10, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpag==" }, - { 11, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpams=" }, - { 12, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamts" }, - { 13, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbQ==" }, - { 14, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW4=" }, - { 15, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5v" }, - { 16, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcA==" }, - { 17, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHE=" }, - { 18, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFy" }, - { 19, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFycw==" }, - { 20, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3Q=" }, - { 21, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1" }, - { 22, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dg==" }, - { 23, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnc=" }, - { 24, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4" }, - { 25, "abcdefghijklmnopqrstuvwxy", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eQ==" }, - { 26, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=" }, + {0, "abcdefghijklmnopqrstuvwxyz", ""}, + {1, "abcdefghijklmnopqrstuvwxyz", "YQ=="}, + {2, "abcdefghijklmnopqrstuvwxyz", "YWI="}, + {3, "abcdefghijklmnopqrstuvwxyz", "YWJj"}, + {4, "abcdefghijklmnopqrstuvwxyz", "YWJjZA=="}, + {5, "abcdefghijklmnopqrstuvwxyz", "YWJjZGU="}, + {6, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVm"}, + {7, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZw=="}, + {8, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2g="}, + {9, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hp"}, + {10, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpag=="}, + {11, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpams="}, + {12, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamts"}, + {13, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbQ=="}, + {14, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW4="}, + {15, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5v"}, + {16, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcA=="}, + {17, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHE="}, + {18, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFy"}, + {19, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFycw=="}, + {20, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3Q="}, + {21, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1"}, + {22, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dg=="}, + {23, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnc="}, + {24, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4"}, + {25, "abcdefghijklmnopqrstuvwxy", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eQ=="}, + {26, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="}, }; #if 0 static struct { @@ -328,15 +328,19 @@ static struct { } \ } -size_t Base64Escape(const unsigned char *src, size_t szsrc, char *dest, +size_t Base64Escape(const unsigned char* src, + size_t szsrc, + char* dest, size_t szdest) { std::string escaped; - Base64::EncodeFromArray((const char *)src, szsrc, &escaped); + Base64::EncodeFromArray((const char*)src, szsrc, &escaped); memcpy(dest, escaped.data(), min(escaped.size(), szdest)); return escaped.size(); } -size_t Base64Unescape(const char *src, size_t szsrc, char *dest, +size_t Base64Unescape(const char* src, + size_t szsrc, + char* dest, size_t szdest) { std::string unescaped; EXPECT_TRUE( @@ -345,7 +349,7 @@ size_t Base64Unescape(const char *src, size_t szsrc, char *dest, return unescaped.size(); } -size_t Base64Unescape(const char *src, size_t szsrc, std::string *s) { +size_t Base64Unescape(const char* src, size_t szsrc, std::string* s) { EXPECT_TRUE(Base64::DecodeFromArray(src, szsrc, Base64::DO_LAX, s, nullptr)); return s->size(); } @@ -356,7 +360,7 @@ TEST(Base64, EncodeDecodeBattery) { size_t i; // Check the short strings; this tests the math (and boundaries) - for( i = 0; i < sizeof(base64_tests) / sizeof(base64_tests[0]); ++i ) { + for (i = 0; i < sizeof(base64_tests) / sizeof(base64_tests[0]); ++i) { char encode_buffer[100]; size_t encode_length; char decode_buffer[100]; @@ -366,16 +370,15 @@ TEST(Base64, EncodeDecodeBattery) { RTC_LOG(LS_VERBOSE) << "B64: " << base64_tests[i].cyphertext; const unsigned char* unsigned_plaintext = - reinterpret_cast(base64_tests[i].plaintext); + reinterpret_cast(base64_tests[i].plaintext); cypher_length = strlen(base64_tests[i].cyphertext); // The basic escape function: memset(encode_buffer, 0, sizeof(encode_buffer)); - encode_length = Base64Escape(unsigned_plaintext, - base64_tests[i].plain_length, - encode_buffer, - sizeof(encode_buffer)); + encode_length = + Base64Escape(unsigned_plaintext, base64_tests[i].plain_length, + encode_buffer, sizeof(encode_buffer)); // Is it of the expected length? EXPECT_EQ(encode_length, cypher_length); @@ -384,10 +387,9 @@ TEST(Base64, EncodeDecodeBattery) { // If we encode it into a buffer of exactly the right length... memset(encode_buffer, 0, sizeof(encode_buffer)); - encode_length = Base64Escape(unsigned_plaintext, - base64_tests[i].plain_length, - encode_buffer, - cypher_length); + encode_length = + Base64Escape(unsigned_plaintext, base64_tests[i].plain_length, + encode_buffer, cypher_length); // Is it still of the expected length? EXPECT_EQ(encode_length, cypher_length); @@ -396,16 +398,15 @@ TEST(Base64, EncodeDecodeBattery) { // If we decode it back: memset(decode_buffer, 0, sizeof(decode_buffer)); - decode_length = Base64Unescape(encode_buffer, - cypher_length, - decode_buffer, + decode_length = Base64Unescape(encode_buffer, cypher_length, decode_buffer, sizeof(decode_buffer)); // Is it of the expected length? EXPECT_EQ(decode_length, base64_tests[i].plain_length); // Is it the expected decoded value? - EXPECT_EQ(0, memcmp(decode_buffer, base64_tests[i].plaintext, decode_length)); + EXPECT_EQ(0, + memcmp(decode_buffer, base64_tests[i].plaintext, decode_length)); // Our decoder treats the padding '=' characters at the end as // optional. If encode_buffer has any, run some additional @@ -413,16 +414,17 @@ TEST(Base64, EncodeDecodeBattery) { char* first_equals = strchr(encode_buffer, '='); if (first_equals) { // How many equals signs does the string start with? - int equals = (*(first_equals+1) == '=') ? 2 : 1; + int equals = (*(first_equals + 1) == '=') ? 2 : 1; // Try chopping off the equals sign(s) entirely. The decoder // should still be okay with this. std::string decoded2("this junk should also be ignored"); *first_equals = '\0'; - EXPECT_NE(0U, Base64Unescape(encode_buffer, first_equals-encode_buffer, - &decoded2)); + EXPECT_NE(0U, Base64Unescape(encode_buffer, first_equals - encode_buffer, + &decoded2)); EXPECT_EQ(decoded2.size(), base64_tests[i].plain_length); - EXPECT_EQ_ARRAY(decoded2.size(), decoded2.data(), base64_tests[i].plaintext, i); + EXPECT_EQ_ARRAY(decoded2.size(), decoded2.data(), + base64_tests[i].plaintext, i); size_t len; @@ -445,453 +447,901 @@ TEST(Base64, EncodeDecodeBattery) { // here's a weird case: a giant base64 encoded stream which broke our base64 // decoding. Let's test it explicitly. const char SpecificTest[] = - "/9j/4AAQSkZJRgABAgEASABIAAD/4Q0HRXhpZgAATU0AKgAAAAgADAEOAAIAAAAgAAAAngEPAAI\n" - "AAAAFAAAAvgEQAAIAAAAJAAAAwwESAAMAAAABAAEAAAEaAAUAAAABAAAAzAEbAAUAAAABAAAA1A\n" - "EoAAMAAAABAAIAAAExAAIAAAAUAAAA3AEyAAIAAAAUAAAA8AE8AAIAAAAQAAABBAITAAMAAAABA\n" - "AIAAIdpAAQAAAABAAABFAAAAsQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgAFNPTlkA\n" - "RFNDLVAyMDAAAAAASAAAAAEAAABIAAAAAUFkb2JlIFBob3Rvc2hvcCA3LjAAMjAwNzowMTozMCA\n" - "yMzoxMDowNABNYWMgT1MgWCAxMC40LjgAAByCmgAFAAAAAQAAAmqCnQAFAAAAAQAAAnKIIgADAA\n" - "AAAQACAACIJwADAAAAAQBkAACQAAAHAAAABDAyMjCQAwACAAAAFAAAAnqQBAACAAAAFAAAAo6RA\n" - "QAHAAAABAECAwCRAgAFAAAAAQAAAqKSBAAKAAAAAQAAAqqSBQAFAAAAAQAAArKSBwADAAAAAQAF\n" - "AACSCAADAAAAAQAAAACSCQADAAAAAQAPAACSCgAFAAAAAQAAArqgAAAHAAAABDAxMDCgAQADAAA\n" - "AAf//AACgAgAEAAAAAQAAAGSgAwAEAAAAAQAAAGSjAAAHAAAAAQMAAACjAQAHAAAAAQEAAACkAQ\n" - "ADAAAAAQAAAACkAgADAAAAAQAAAACkAwADAAAAAQAAAACkBgADAAAAAQAAAACkCAADAAAAAQAAA\n" - "ACkCQADAAAAAQAAAACkCgADAAAAAQAAAAAAAAAAAAAACgAAAZAAAAAcAAAACjIwMDc6MDE6MjAg\n" - "MjM6MDU6NTIAMjAwNzowMToyMCAyMzowNTo1MgAAAAAIAAAAAQAAAAAAAAAKAAAAMAAAABAAAAB\n" - "PAAAACgAAAAYBAwADAAAAAQAGAAABGgAFAAAAAQAAAxIBGwAFAAAAAQAAAxoBKAADAAAAAQACAA\n" - "ACAQAEAAAAAQAAAyICAgAEAAAAAQAACd0AAAAAAAAASAAAAAEAAABIAAAAAf/Y/+AAEEpGSUYAA\n" - "QIBAEgASAAA/+0ADEFkb2JlX0NNAAL/7gAOQWRvYmUAZIAAAAAB/9sAhAAMCAgICQgMCQkMEQsK\n" - "CxEVDwwMDxUYExMVExMYEQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAQ0LCw0\n" - "ODRAODhAUDg4OFBQODg4OFBEMDAwMDBERDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA\n" - "wMDAz/wAARCABkAGQDASIAAhEBAxEB/90ABAAH/8QBPwAAAQUBAQEBAQEAAAAAAAAAAwABAgQFB\n" - "gcICQoLAQABBQEBAQEBAQAAAAAAAAABAAIDBAUGBwgJCgsQAAEEAQMCBAIFBwYIBQMMMwEAAhED\n" - "BCESMQVBUWETInGBMgYUkaGxQiMkFVLBYjM0coLRQwclklPw4fFjczUWorKDJkSTVGRFwqN0Nhf\n" - "SVeJl8rOEw9N14/NGJ5SkhbSVxNTk9KW1xdXl9VZmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9xEAAg\n" - "IBAgQEAwQFBgcHBgU1AQACEQMhMRIEQVFhcSITBTKBkRShsUIjwVLR8DMkYuFygpJDUxVjczTxJ\n" - "QYWorKDByY1wtJEk1SjF2RFVTZ0ZeLys4TD03Xj80aUpIW0lcTU5PSltcXV5fVWZnaGlqa2xtbm\n" - "9ic3R1dnd4eXp7fH/9oADAMBAAIRAxEAPwDy7bKNTUXNLz9EaJPDWMjxH4ozhtpYwaACT8ShaaW\n" - "bW0uEc9/JFfjj0Q4Hk/PRDxwX7y47W9z/AN9Cv4+O3ILK2DcRqT2CaSvEbcl1Jbz37KG1dBldLo\n" - "qaS4l9xGjG9v6yoDAdYIaIjUk+AREgo4y5sapirb8Yl0NHHdKvBNm4yA1o5Pc+SPEFvCWqB3HZF\n" - "Hj2SbWQ/afGFP0bHP8ATY0uc4w1o1JPkkimGiS2KvqlnmBkOZQTyydzgPMM9v8A0lp4v1Nx9gF1\n" - "tpdqJaGtH/S3I0i3lISXW/8AMqnd/O2bfg2eUkqVYf/Q8zuncO4Bj7lZ+n7f5Mj5KsJcY8NUZ4d\n" - "uEDVo1HkeU0rg3Om4H2rabCWUN7DQuK1n5FWKW4uCwG92gDRJBS6exhxmMboQI+Cv4WFTQ42Bs2\n" - "fvnkkqEmy2YxoMMbpVzaz6jt+RbpHZs8lzkHqrasKkYOKP0jgDfZ4N/wDM1tNrcWfSPmRyq9uNV\n" - "DnFg2s97i7UkjxKVrq0eVz3spZsja+ASDzwsh9jnOk/JFzb3XZD3v1c4yT8UACTCniKDUnKz5Nj\n" - "G33XV1DV73BrT8dF23SejV4zg9g33cOsPb+SxVvqv9ViwNy8vS0iWs/daf8A0Y5dpTi1sADGxCR\n" - "K1o0YBEmInlXWYbDBcDLdPJXa8f71Yrx2jnUoAqLnfZK5hJaW2vdwEk5a/wD/0fN6Ia/e76IiVf\n" - "xavUL7CPpnT4LNbYXAVjuQt/AqDmNYO/Kjnoy4hr5J8SwMhrRMaeSvbsxrfUazcOw4UX0Cisem2\n" - "SBoD4+Kz8nC6llbSLCRrubJA8kwUWbUDa29X1PMa7aQWjuDC0MXMdbDbhI7eazBiUfZ6GOYRe1s\n" - "WvGgJ8Vbw2+m4Bx9s6JpNHuuGo1FF53r/SHYua61gLse0lzXeBP5rkvqx0o5vVWz7WY49QkiQSP\n" - "oN/tLoevW/ogxv0HA7tJ0AnhT+pdDGYVl/wCdcTPkGn2NU0JWNWvlgAbHV6fEqdu2gR/r2WlWwt\n" - "AA5VXAEsLXTqJafArQY5rRr9LiPBJiZsZCI1pJjxCi0j4oncSICSkWwzwkjeaSch//0vO7sP7Lm\n" - "enO9ogtd5FbPT3Q5pCpZVc4ld3Lmn3O8j9EI2BYdunKjOobMQIyI+rusc2wx4d0eutwGnHh/uQc\n" - "Ha7ladj6mVANGvcqOgz0Go7HJ12/GEHcwvB/dPY6ImbbaMaASGuIBjkN7qofs9Ubg9g7OI9p/t/\n" - "RTSmhTHr0v6eSz6UgCPP2/wAVu9Ex2V49dVY2iACB4BZeVXQ/AJ3gzGnnOi2+kACpru8flUsNmt\n" - "zHRf6xfWCnoeAfTh2ZaQKazx/Ke7+QxcKz61fWA2uuObaC4zGhaPJrXBL64ZFmR124O09ENraPK\n" - "N3/AH5GqxIrZVUyp2K2vfdkENsDnxuex9m4Ox9n82xSgNd9D+p/XR1npgseR9ppOy4Dx/NfH/CL\n" - "oQJGunmvMv8AFq3KHVcq3HkYQbD2nuSf0I/rMavSg6TLjLigQhJ7Z58v9QkmlsTOqSCn/9PzL7R\n" - "d6Qq3n0wZ2zotXpT9xLfFYvkr/S7jXeB8E0jRkhKpC3q8LcJ/kmCrTnkuAPCq4do9Q/ytVbuAeY\n" - "Gg5lQybQK+82GBqEQUA1kOHPYf3LLsoyN36G5w8iUfHxepbXE2l0cApALgLHzBq9UxhTXU5hMC1\n" - "ktnSCup6S4Ctk+C5XqVGcaHPfuiuHkeTTuWz0+9zaKiH6CC0/yXBSQ2a/MxojV57634rq+v2PLY\n" - "be1r2nsYG13/AFKxbfCBMcr0brGAzrGEwCG31ncx0SfBzf7S4+zoHUWWsJq3hz9oLfcBH77R9H+\n" - "0pA13u/qPgDp/Q6ri39JlfpXkDx+h/msWn1L6wdO6bSbcrIbU2Q0xLnSe21kuVejJspbVS5+4bd\n" - "ocBAkD/orG+tP1ar67Wy7GtZTm1SCXfRsb+a18fRe38x6SG3/44H1Z3f0y2I+l6DoSXD/8xPrDs\n" - "3enVu3bdnqN3R+//USSVo//1PLohhce+gRWS0Nsby3lRgFkKxQyW7SgUh3em5Tbq2uB9wWw1wey\n" - "J1XGV2XYdm5k7e4WzidXY9oMwo5RZ4T6Hd1ixwfp96PWbAJBVTHzK7O6Ky5oJB1HZMqmUEFlkGy\n" - "xpa4zI1Hkq31dy7bMN9BAc3HeWAnnbyxEycmuup1jiAGglZ31PyrmZ9tQg1WtNj54EHR3/S2qTH\n" - "1Yc5GgD1FFtzPdWGkd2AyflogZmRmsz6PSrbXbdo+txOrP337f3fzVo15DK2uyrTtqpBOnBKx6b\n" - "7MjJsz7tHWOAYP3WD6LU6cqGjFCNl1MmvLcxv6YtDTLSAqP27LrdtYHXFnJZI+Tp3MWg68OpDPv\n" - "UMUM2lkQBoouKQ6swjE9Nml+1sz1PW+z6xt27zuj+skrX2ZvqR5z8kkuOfdPt43/1fMm/grFG6f\n" - "Lss9JA7JG7tnZs/SfJUrfS3foJ9TvHCopJsV8nWx/t24bJn8Fo/5TjWJXMJIS+i+G36TsZ/7Q9P\n" - "8ATfzfeOFofVSZv2/zvt+O3X/v65dJPjt/BiyfN1/wn0zre79nVej/ADG8ep4x2/6Srjd6TdviF\n" - "52ko8m6/Ht9X1KnftEo+POwxzK8mSTF46vrH6T1/OEl5Okkl//Z/+0uHFBob3Rvc2hvcCAzLjAA\n" - "OEJJTQQEAAAAAAArHAIAAAIAAhwCeAAfICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAA\n" - "4QklNBCUAAAAAABD7Caa9B0wqNp2P4sxXqayFOEJJTQPqAAAAAB2wPD94bWwgdmVyc2lvbj0iMS\n" - "4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUgQ\n" - "29tcHV0ZXIvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Q\n" - "cm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk\n" - "+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1Ib3Jpem9udGFsUmVzPC9rZXk+Cgk8ZGljdD\n" - "4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCTxzdHJpbmc+Y\n" - "29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCTxrZXk+Y29tLmFwcGxlLnByaW50\n" - "LnRpY2tldC5pdGVtQXJyYXk8L2tleT4KCQk8YXJyYXk+CgkJCTxkaWN0PgoJCQkJPGtleT5jb20\n" - "uYXBwbGUucHJpbnQuUGFnZUZvcm1hdC5QTUhvcml6b250YWxSZXM8L2tleT4KCQkJCTxyZWFsPj\n" - "cyPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJC\n" - "QkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJpbmc+CgkJCQk8a2V5PmNv\n" - "bS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGRhdGU+MjAwNy0wMS0zMFQ\n" - "yMjowODo0MVo8L2RhdGU+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuc3RhdGVGbG\n" - "FnPC9rZXk+CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY3Q+CgkJPC9hcnJheT4KC\n" - "TwvZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwv\n" - "a2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4\n" - "KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS\n" - "5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KC\n" - "QkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwva2V5PgoJ\n" - "CQkJPGludGVnZXI+MTwvaW50ZWdlcj4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5\n" - "jbGllbnQ8L2tleT4KCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW\n" - "5nPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lm1vZERhdGU8L2tleT4KCQkJCTxkY\n" - "XRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQu\n" - "dGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJPGludGVnZXI+MDwvaW50ZWdlcj4KCQkJPC9kaWN\n" - "0PgoJCTwvYXJyYXk+Cgk8L2RpY3Q+Cgk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0Ll\n" - "BNU2NhbGluZzwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZ\n" - "WF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4K\n" - "CQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFycmF5Pgo\n" - "JCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1TY2FsaW5nPC\n" - "9rZXk+CgkJCQk8cmVhbD4xPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0L\n" - "mNsaWVudDwva2V5PgoJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJp\n" - "bmc+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGR\n" - "hdGU+MjAwNy0wMS0zMFQyMjowODo0MVo8L2RhdGU+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC\n" - "50aWNrZXQuc3RhdGVGbGFnPC9rZXk+CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY\n" - "3Q+CgkJPC9hcnJheT4KCTwvZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQu\n" - "UE1WZXJ0aWNhbFJlczwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V\n" - "0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cm\n" - "luZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFyc\n" - "mF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1WZXJ0\n" - "aWNhbFJlczwva2V5PgoJCQkJPHJlYWw+NzI8L3JlYWw+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcml\n" - "udC50aWNrZXQuY2xpZW50PC9rZXk+CgkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbm\n" - "FnZXI8L3N0cmluZz4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZ\n" - "Xk+CgkJCQk8ZGF0ZT4yMDA3LTAxLTMwVDIyOjA4OjQxWjwvZGF0ZT4KCQkJCTxrZXk+Y29tLmFw\n" - "cGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI\n" - "+CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5jb20uYXBwbGUucHJpbnQuUG\n" - "FnZUZvcm1hdC5QTVZlcnRpY2FsU2NhbGluZzwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwb\n" - "GUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGlu\n" - "Z21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF\n" - "5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2\n" - "VGb3JtYXQuUE1WZXJ0aWNhbFNjYWxpbmc8L2tleT4KCQkJCTxyZWFsPjE8L3JlYWw+CgkJCQk8a\n" - "2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50PC9rZXk+CgkJCQk8c3RyaW5nPmNvbS5h\n" - "cHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnR\n" - "pY2tldC5tb2REYXRlPC9rZXk+CgkJCQk8ZGF0ZT4yMDA3LTAxLTMwVDIyOjA4OjQxWjwvZGF0ZT\n" - "4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpb\n" - "nRlZ2VyPjA8L2ludGVnZXI+CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5j\n" - "b20uYXBwbGUucHJpbnQuc3ViVGlja2V0LnBhcGVyX2luZm9fdGlja2V0PC9rZXk+Cgk8ZGljdD4\n" - "KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlUmVjdDwva2\n" - "V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5P\n" - "goJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJPGtleT5j\n" - "b20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+CgkJCQk8ZGl\n" - "jdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlUm\n" - "VjdDwva2V5PgoJCQkJCTxhcnJheT4KCQkJCQkJPHJlYWw+MC4wPC9yZWFsPgoJCQkJCQk8cmVhb\n" - "D4wLjA8L3JlYWw+CgkJCQkJCTxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+NTc2PC9yZWFs\n" - "PgoJCQkJCTwvYXJyYXk+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDw\n" - "va2V5PgoJCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQ\n" - "kJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+M\n" - "jAwNy0wMS0zMFQyMjowODo0MVo8L2RhdGU+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlj\n" - "a2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCQk8L2RpY3Q\n" - "+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYX\n" - "QuUE1BZGp1c3RlZFBhcGVyUmVjdDwva2V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5wc\n" - "mludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21h\n" - "bmFnZXI8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTw\n" - "va2V5PgoJCQk8YXJyYXk+CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYW\n" - "dlRm9ybWF0LlBNQWRqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+CgkJCQkJCTxyZ\n" - "WFsPi0xODwvcmVhbD4KCQkJCQkJPHJlYWw+LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3Jl\n" - "YWw+CgkJCQkJCTxyZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+Y29tLmF\n" - "wcGxlLnByaW50LnRpY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcm\n" - "ludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQub\n" - "W9kRGF0ZTwva2V5PgoJCQkJCTxkYXRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJ\n" - "CTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWd\n" - "lcj4wPC9pbnRlZ2VyPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5Pm\n" - "NvbS5hcHBsZS5wcmludC5QYXBlckluZm8uUE1QYXBlck5hbWU8L2tleT4KCQk8ZGljdD4KCQkJP\n" - "GtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20u\n" - "YXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcml\n" - "udC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZX\n" - "k+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVBhcGVyTmFtZTwva2V5PgoJCQkJCTxzdHJpb\n" - "mc+bmEtbGV0dGVyPC9zdHJpbmc+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNs\n" - "aWVudDwva2V5PgoJCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50LnBtLlBvc3RTY3JpcHQ8L3N\n" - "0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQ\n" - "kJCTxkYXRlPjIwMDMtMDctMDFUMTc6NDk6MzZaPC9kYXRlPgoJCQkJCTxrZXk+Y29tLmFwcGxlL\n" - "nByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4xPC9pbnRlZ2VyPgoJ\n" - "CQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5\n" - "QYXBlckluZm8uUE1VbmFkanVzdGVkUGFnZVJlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb2\n" - "0uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUuc\n" - "HJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNr\n" - "ZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+Y29tLmF\n" - "wcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYWdlUmVjdDwva2V5PgoJCQkJCTxhcn\n" - "JheT4KCQkJCQkJPHJlYWw+MC4wPC9yZWFsPgoJCQkJCQk8cmVhbD4wLjA8L3JlYWw+CgkJCQkJC\n" - "TxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+NTc2PC9yZWFsPgoJCQkJCTwvYXJyYXk+CgkJ\n" - "CQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJCTxzdHJpbmc\n" - "+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLn\n" - "ByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+MjAwNy0wMS0zMFQyMjowODo0M\n" - "Vo8L2RhdGU+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5\n" - "PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCQk8L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9\n" - "kaWN0PgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYXBlcl\n" - "JlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b\n" - "3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5n\n" - "PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJ\n" - "heT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYW\n" - "RqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+CgkJCQkJCTxyZWFsPi0xODwvcmVhb\n" - "D4KCQkJCQkJPHJlYWw+LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3JlYWw+CgkJCQkJCTxy\n" - "ZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnR\n" - "pY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZX\n" - "I8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5P\n" - "goJCQkJCTxkYXRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJCTxrZXk+Y29tLmFw\n" - "cGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4wPC9pbnRlZ2V\n" - "yPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcm\n" - "ludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+CgkJPGRpY3Q+CgkJCTxrZXk+Y29tL\n" - "mFwcGxlLnByaW50LnRpY2tldC5jcmVhdG9yPC9rZXk+CgkJCTxzdHJpbmc+Y29tLmFwcGxlLnBy\n" - "aW50LnBtLlBvc3RTY3JpcHQ8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V\n" - "0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcH\n" - "BsZS5wcmludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+CgkJCQkJPHN0cmluZz5VU\n" - "yBMZXR0ZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50\n" - "PC9rZXk+CgkJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5\n" - "nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPG\n" - "RhdGU+MjAwMy0wNy0wMVQxNzo0OTozNlo8L2RhdGU+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpb\n" - "nQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjE8L2ludGVnZXI+CgkJCQk8\n" - "L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2t\n" - "ldC5BUElWZXJzaW9uPC9rZXk+CgkJPHN0cmluZz4wMC4yMDwvc3RyaW5nPgoJCTxrZXk+Y29tLm\n" - "FwcGxlLnByaW50LnRpY2tldC5wcml2YXRlTG9jazwva2V5PgoJCTxmYWxzZS8+CgkJPGtleT5jb\n" - "20uYXBwbGUucHJpbnQudGlja2V0LnR5cGU8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmlu\n" - "dC5QYXBlckluZm9UaWNrZXQ8L3N0cmluZz4KCTwvZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW5\n" - "0LnRpY2tldC5BUElWZXJzaW9uPC9rZXk+Cgk8c3RyaW5nPjAwLjIwPC9zdHJpbmc+Cgk8a2V5Pm\n" - "NvbS5hcHBsZS5wcmludC50aWNrZXQucHJpdmF0ZUxvY2s8L2tleT4KCTxmYWxzZS8+Cgk8a2V5P\n" - "mNvbS5hcHBsZS5wcmludC50aWNrZXQudHlwZTwva2V5PgoJPHN0cmluZz5jb20uYXBwbGUucHJp\n" - "bnQuUGFnZUZvcm1hdFRpY2tldDwvc3RyaW5nPgo8L2RpY3Q+CjwvcGxpc3Q+CjhCSU0D6QAAAAA\n" - "AeAADAAAASABIAAAAAALeAkD/7v/uAwYCUgNnBSgD/AACAAAASABIAAAAAALYAigAAQAAAGQAAA\n" - "ABAAMDAwAAAAF//wABAAEAAAAAAAAAAAAAAABoCAAZAZAAAAAAACAAAAAAAAAAAAAAAAAAAAAAA\n" - "AAAAAAAAAAAADhCSU0D7QAAAAAAEABIAAAAAQABAEgAAAABAAE4QklNBCYAAAAAAA4AAAAAAAAA\n" - "AAAAP4AAADhCSU0EDQAAAAAABAAAAB44QklNBBkAAAAAAAQAAAAeOEJJTQPzAAAAAAAJAAAAAAA\n" - "AAAABADhCSU0ECgAAAAAAAQAAOEJJTScQAAAAAAAKAAEAAAAAAAAAAThCSU0D9QAAAAAASAAvZm\n" - "YAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAAA\n" - "QAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP//\n" - "//////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA///\n" - "//////////////////////////wPoAAA4QklNBAgAAAAAABAAAAABAAACQAAAAkAAAAAAOEJJTQ\n" - "QeAAAAAAAEAAAAADhCSU0EGgAAAAADRQAAAAYAAAAAAAAAAAAAAGQAAABkAAAACABEAFMAQwAwA\n" - "DIAMwAyADUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAGQAAABkAAAAAAAAAAAA\n" - "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAABudWxsAAAAAgAAAAZib3VuZHN\n" - "PYmpjAAAAAQAAAAAAAFJjdDEAAAAEAAAAAFRvcCBsb25nAAAAAAAAAABMZWZ0bG9uZwAAAAAAAA\n" - "AAQnRvbWxvbmcAAABkAAAAAFJnaHRsb25nAAAAZAAAAAZzbGljZXNWbExzAAAAAU9iamMAAAABA\n" - "AAAAAAFc2xpY2UAAAASAAAAB3NsaWNlSURsb25nAAAAAAAAAAdncm91cElEbG9uZwAAAAAAAAAG\n" - "b3JpZ2luZW51bQAAAAxFU2xpY2VPcmlnaW4AAAANYXV0b0dlbmVyYXRlZAAAAABUeXBlZW51bQA\n" - "AAApFU2xpY2VUeXBlAAAAAEltZyAAAAAGYm91bmRzT2JqYwAAAAEAAAAAAABSY3QxAAAABAAAAA\n" - "BUb3AgbG9uZwAAAAAAAAAATGVmdGxvbmcAAAAAAAAAAEJ0b21sb25nAAAAZAAAAABSZ2h0bG9uZ\n" - "wAAAGQAAAADdXJsVEVYVAAAAAEAAAAAAABudWxsVEVYVAAAAAEAAAAAAABNc2dlVEVYVAAAAAEA\n" - "AAAAAAZhbHRUYWdURVhUAAAAAQAAAAAADmNlbGxUZXh0SXNIVE1MYm9vbAEAAAAIY2VsbFRleHR\n" - "URVhUAAAAAQAAAAAACWhvcnpBbGlnbmVudW0AAAAPRVNsaWNlSG9yekFsaWduAAAAB2RlZmF1bH\n" - "QAAAAJdmVydEFsaWduZW51bQAAAA9FU2xpY2VWZXJ0QWxpZ24AAAAHZGVmYXVsdAAAAAtiZ0Nvb\n" - "G9yVHlwZWVudW0AAAARRVNsaWNlQkdDb2xvclR5cGUAAAAATm9uZQAAAAl0b3BPdXRzZXRsb25n\n" - "AAAAAAAAAApsZWZ0T3V0c2V0bG9uZwAAAAAAAAAMYm90dG9tT3V0c2V0bG9uZwAAAAAAAAALcml\n" - "naHRPdXRzZXRsb25nAAAAAAA4QklNBBEAAAAAAAEBADhCSU0EFAAAAAAABAAAAAE4QklNBAwAAA\n" - "AACfkAAAABAAAAZAAAAGQAAAEsAAB1MAAACd0AGAAB/9j/4AAQSkZJRgABAgEASABIAAD/7QAMQ\n" - "WRvYmVfQ00AAv/uAA5BZG9iZQBkgAAAAAH/2wCEAAwICAgJCAwJCQwRCwoLERUPDAwPFRgTExUT\n" - "ExgRDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBDQsLDQ4NEA4OEBQODg4UFA4\n" - "ODg4UEQwMDAwMEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/AABEIAGQAZA\n" - "MBIgACEQEDEQH/3QAEAAf/xAE/AAABBQEBAQEBAQAAAAAAAAADAAECBAUGBwgJCgsBAAEFAQEBA\n" - "QEBAAAAAAAAAAEAAgMEBQYHCAkKCxAAAQQBAwIEAgUHBggFAwwzAQACEQMEIRIxBUFRYRMicYEy\n" - "BhSRobFCIyQVUsFiMzRygtFDByWSU/Dh8WNzNRaisoMmRJNUZEXCo3Q2F9JV4mXys4TD03Xj80Y\n" - "nlKSFtJXE1OT0pbXF1eX1VmZ2hpamtsbW5vY3R1dnd4eXp7fH1+f3EQACAgECBAQDBAUGBwcGBT\n" - "UBAAIRAyExEgRBUWFxIhMFMoGRFKGxQiPBUtHwMyRi4XKCkkNTFWNzNPElBhaisoMHJjXC0kSTV\n" - "KMXZEVVNnRl4vKzhMPTdePzRpSkhbSVxNTk9KW1xdXl9VZmdoaWprbG1ub2JzdHV2d3h5ent8f/\n" - "2gAMAwEAAhEDEQA/APLtso1NRc0vP0Rok8NYyPEfijOG2ljBoAJPxKFppZtbS4Rz38kV+OPRDge\n" - "T89EPHBfvLjtb3P8A30K/j47cgsrYNxGpPYJpK8RtyXUlvPfsobV0GV0uippLiX3EaMb2/rKgMB\n" - "1ghoiNST4BESCjjLmxqmKtvxiXQ0cd0q8E2bjIDWjk9z5I8QW8JaoHcdkUePZJtZD9p8YU/Rsc/\n" - "wBNjS5zjDWjUk+SSKYaJLYq+qWeYGQ5lBPLJ3OA8wz2/wDSWni/U3H2AXW2l2oloa0f9LcjSLeU\n" - "hJdb/wAyqd387Zt+DZ5SSpVh/9DzO6dw7gGPuVn6ft/kyPkqwlxjw1Rnh24QNWjUeR5TSuDc6bg\n" - "fatpsJZQ3sNC4rWfkVYpbi4LAb3aANEkFLp7GHGYxuhAj4K/hYVNDjYGzZ++eSSoSbLZjGgwxul\n" - "XNrPqO35FukdmzyXOQeqtqwqRg4o/SOAN9ng3/AMzW02txZ9I+ZHKr241UOcWDaz3uLtSSPEpWu\n" - "rR5XPeylmyNr4BIPPCyH2Oc6T8kXNvddkPe/VzjJPxQAJMKeIoNScrPk2MbfddXUNXvcGtPx0Xb\n" - "dJ6NXjOD2Dfdw6w9v5LFW+q/1WLA3Ly9LSJaz91p/wDRjl2lOLWwAMbEJErWjRgESYieVdZhsMF\n" - "wMt08ldrx/vVivHaOdSgCoud9krmElpba93ASTlr/AP/R83ohr97voiJV/Fq9QvsI+mdPgs1thc\n" - "BWO5C38CoOY1g78qOejLiGvknxLAyGtExp5K9uzGt9RrNw7DhRfQKKx6bZIGgPj4rPycLqWVtIs\n" - "JGu5skDyTBRZtQNrb1fU8xrtpBaO4MLQxcx1sNuEjt5rMGJR9noY5hF7Wxa8aAnxVvDb6bgHH2z\n" - "omk0e64ajUUXnev9Idi5rrWAux7SXNd4E/muS+rHSjm9VbPtZjj1CSJBI+g3+0uh69b+iDG/QcD\n" - "u0nQCeFP6l0MZhWX/AJ1xM+QafY1TQlY1a+WABsdXp8Sp27aBH+vZaVbC0ADlVcASwtdOolp8Ct\n" - "BjmtGv0uI8EmJmxkIjWkmPEKLSPiidxIgJKRbDPCSN5pJyH//S87uw/suZ6c72iC13kVs9PdDmk\n" - "KllVziV3cuafc7yP0QjYFh26cqM6hsxAjIj6u6xzbDHh3R663AaceH+5BwdruVp2PqZUA0a9yo6\n" - "DPQajscnXb8YQdzC8H909joiZttoxoBIa4gGOQ3uqh+z1RuD2Ds4j2n+39FNKaFMevS/p5LPpSA\n" - "I8/b/ABW70THZXj11VjaIAIHgFl5VdD8AneDMaec6Lb6QAKmu7x+VSw2a3MdF/rF9YKeh4B9OHZ\n" - "lpAprPH8p7v5DFwrPrV9YDa645toLjMaFo8mtcEvrhkWZHXbg7T0Q2to8o3f8AfkarEitlVTKnY\n" - "ra992QQ2wOfG57H2bg7H2fzbFKA130P6n9dHWemCx5H2mk7LgPH818f8IuhAka6ea8y/wAWrcod\n" - "VyrceRhBsPae5J/Qj+sxq9KDpMuMuKBCEntnny/1CSaWxM6pIKf/0/MvtF3pCrefTBnbOi1elP3\n" - "Et8Vi+Sv9LuNd4HwTSNGSEqkLerwtwn+SYKtOeS4A8Krh2j1D/K1Vu4B5gaDmVDJtAr7zYYGoRB\n" - "QDWQ4c9h/csuyjI3fobnDyJR8fF6ltcTaXRwCkAuAsfMGr1TGFNdTmEwLWS2dIK6npLgK2T4Lle\n" - "pUZxoc9+6K4eR5NO5bPT73NoqIfoILT/JcFJDZr8zGiNXnvrfiur6/Y8tht7WvaexgbXf8AUrFt\n" - "8IExyvRusYDOsYTAIbfWdzHRJ8HN/tLj7OgdRZawmreHP2gt9wEfvtH0f7SkDXe7+o+AOn9DquL\n" - "f0mV+leQPH6H+axafUvrB07ptJtyshtTZDTEudJ7bWS5V6MmyltVLn7ht2hwECQP+isb60/Vqvr\n" - "tbLsa1lObVIJd9Gxv5rXx9F7fzHpIbf/jgfVnd/TLYj6XoOhJcP/zE+sOzd6dW7dt2eo3dH7/9R\n" - "JJWj//U8uiGFx76BFZLQ2xvLeVGAWQrFDJbtKBSHd6blNura4H3BbDXB7InVcZXZdh2bmTt7hbO\n" - "J1dj2gzCjlFnhPod3WLHB+n3o9ZsAkFVMfMrs7orLmgkHUdkyqZQQWWQbLGlrjMjUeSrfV3Ltsw\n" - "30EBzcd5YCedvLETJya66nWOIAaCVnfU/KuZn21CDVa02PngQdHf9LapMfVhzkaAPUUW3M91YaR\n" - "3YDJ+WiBmZGazPo9Kttdt2j63E6s/fft/d/NWjXkMra7KtO2qkE6cErHpvsyMmzPu0dY4Bg/dYP\n" - "otTpyoaMUI2XUya8tzG/pi0NMtICo/bsut21gdcWclkj5OncxaDrw6kM+9QxQzaWRAGii4pDqzC\n" - "MT02aX7WzPU9b7PrG3bvO6P6yStfZm+pHnPySS4590+3jf/V8yb+CsUbp8uyz0kDskbu2dmz9J8\n" - "lSt9Ld+gn1O8cKikmxXydbH+3bhsmfwWj/lONYlcwkhL6L4bfpOxn/tD0/wBN/N944Wh9VJm/b/\n" - "O+347df+/rl0k+O38GLJ83X/CfTOt7v2dV6P8AMbx6njHb/pKuN3pN2+IXnaSjybr8e31fUqd+0\n" - "Sj487DHMryZJMXjq+sfpPX84SXk6SSX/9kAOEJJTQQhAAAAAABVAAAAAQEAAAAPAEEAZABvAGIA\n" - "ZQAgAFAAaABvAHQAbwBzAGgAbwBwAAAAEwBBAGQAbwBiAGUAIABQAGgAbwB0AG8AcwBoAG8AcAA\n" - "gADcALgAwAAAAAQA4QklNBAYAAAAAAAcABQAAAAEBAP/hFWdodHRwOi8vbnMuYWRvYmUuY29tL3\n" - "hhcC8xLjAvADw/eHBhY2tldCBiZWdpbj0n77u/JyBpZD0nVzVNME1wQ2VoaUh6cmVTek5UY3prY\n" - "zlkJz8+Cjw/YWRvYmUteGFwLWZpbHRlcnMgZXNjPSJDUiI/Pgo8eDp4YXBtZXRhIHhtbG5zOng9\n" - "J2Fkb2JlOm5zOm1ldGEvJyB4OnhhcHRrPSdYTVAgdG9vbGtpdCAyLjguMi0zMywgZnJhbWV3b3J\n" - "rIDEuNSc+CjxyZGY6UkRGIHhtbG5zOnJkZj0naHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi\n" - "1yZGYtc3ludGF4LW5zIycgeG1sbnM6aVg9J2h0dHA6Ly9ucy5hZG9iZS5jb20vaVgvMS4wLyc+C\n" - "gogPHJkZjpEZXNjcmlwdGlvbiBhYm91dD0ndXVpZDoyMmQwMmIwYS1iMjQ5LTExZGItOGFmOC05\n" - "MWQ1NDAzZjkyZjknCiAgeG1sbnM6cGRmPSdodHRwOi8vbnMuYWRvYmUuY29tL3BkZi8xLjMvJz4\n" - "KICA8IS0tIHBkZjpTdWJqZWN0IGlzIGFsaWFzZWQgLS0+CiA8L3JkZjpEZXNjcmlwdGlvbj4KCi\n" - "A8cmRmOkRlc2NyaXB0aW9uIGFib3V0PSd1dWlkOjIyZDAyYjBhLWIyNDktMTFkYi04YWY4LTkxZ\n" - "DU0MDNmOTJmOScKICB4bWxuczpwaG90b3Nob3A9J2h0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9z\n" - "aG9wLzEuMC8nPgogIDwhLS0gcGhvdG9zaG9wOkNhcHRpb24gaXMgYWxpYXNlZCAtLT4KIDwvcmR\n" - "mOkRlc2NyaXB0aW9uPgoKIDxyZGY6RGVzY3JpcHRpb24gYWJvdXQ9J3V1aWQ6MjJkMDJiMGEtYj\n" - "I0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5JwogIHhtbG5zOnhhcD0naHR0cDovL25zLmFkb2JlL\n" - "mNvbS94YXAvMS4wLyc+CiAgPCEtLSB4YXA6RGVzY3JpcHRpb24gaXMgYWxpYXNlZCAtLT4KIDwv\n" - "cmRmOkRlc2NyaXB0aW9uPgoKIDxyZGY6RGVzY3JpcHRpb24gYWJvdXQ9J3V1aWQ6MjJkMDJiMGE\n" - "tYjI0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5JwogIHhtbG5zOnhhcE1NPSdodHRwOi8vbnMuYW\n" - "RvYmUuY29tL3hhcC8xLjAvbW0vJz4KICA8eGFwTU06RG9jdW1lbnRJRD5hZG9iZTpkb2NpZDpwa\n" - "G90b3Nob3A6MjJkMDJiMDYtYjI0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5PC94YXBNTTpEb2N1\n" - "bWVudElEPgogPC9yZGY6RGVzY3JpcHRpb24+CgogPHJkZjpEZXNjcmlwdGlvbiBhYm91dD0ndXV\n" - "pZDoyMmQwMmIwYS1iMjQ5LTExZGItOGFmOC05MWQ1NDAzZjkyZjknCiAgeG1sbnM6ZGM9J2h0dH\n" - "A6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvJz4KICA8ZGM6ZGVzY3JpcHRpb24+CiAgIDxyZ\n" - "GY6QWx0PgogICAgPHJkZjpsaSB4bWw6bGFuZz0neC1kZWZhdWx0Jz4gICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgPC9yZGY6bGk+CiAgIDwvcmRmOkFsdD4KICA8L2RjOmRlc2NyaXB0aW9\n" - "uPgogPC9yZGY6RGVzY3JpcHRpb24+Cgo8L3JkZjpSREY+CjwveDp4YXBtZXRhPgogICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA\n" - "ogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\n" - "ICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC\n" - "AgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAg\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0ndyc/P\n" - "v/uAA5BZG9iZQBkQAAAAAH/2wCEAAQDAwMDAwQDAwQGBAMEBgcFBAQFBwgGBgcGBggKCAkJCQkI\n" - "CgoMDAwMDAoMDAwMDAwMDAwMDAwMDAwMDAwMDAwBBAUFCAcIDwoKDxQODg4UFA4ODg4UEQwMDAw\n" - "MEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/AABEIAGQAZAMBEQACEQEDEQ\n" - "H/3QAEAA3/xAGiAAAABwEBAQEBAAAAAAAAAAAEBQMCBgEABwgJCgsBAAICAwEBAQEBAAAAAAAAA\n" - "AEAAgMEBQYHCAkKCxAAAgEDAwIEAgYHAwQCBgJzAQIDEQQABSESMUFRBhNhInGBFDKRoQcVsUIj\n" - "wVLR4TMWYvAkcoLxJUM0U5KismNzwjVEJ5OjszYXVGR0w9LiCCaDCQoYGYSURUaktFbTVSga8uP\n" - "zxNTk9GV1hZWltcXV5fVmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9zhIWGh4iJiouMjY6PgpOUlZaX\n" - "mJmam5ydnp+So6SlpqeoqaqrrK2ur6EQACAgECAwUFBAUGBAgDA20BAAIRAwQhEjFBBVETYSIGc\n" - "YGRMqGx8BTB0eEjQhVSYnLxMyQ0Q4IWklMlomOywgdz0jXiRIMXVJMICQoYGSY2RRonZHRVN/Kj\n" - "s8MoKdPj84SUpLTE1OT0ZXWFlaW1xdXl9UZWZnaGlqa2xtbm9kdXZ3eHl6e3x9fn9zhIWGh4iJi\n" - "ouMjY6Pg5SVlpeYmZqbnJ2en5KjpKWmp6ipqqusra6vr/2gAMAwEAAhEDEQA/APBnplwPAdR+GB\n" - "KY6dYtNG1w39yh4+xb+zIksgEfFaRSSoIx8f7RPRRkSWQimM+lRmwWVXFWYigHxUUVoMiJM+Fj0\n" - "tg0RBegLE0Wu+3c+GTBazFCGI7HtSp9slbFYYzyoBsegw2hY1Afl3wqqRqahk+0tDgKpgu4DAUU\n" - "+HY+GRS2ePiMKtUB3G+KGuONq//Q8OzpFbW5WnxMop4k9crG5ZnZNJkEOn21utVRYw7HxZtz+OR\n" - "vdsrZ2lRtci4aVxFEQA0neg/ZXxJpTITNNuOFss0vSotYNvZ2qGRkPKSTqiU8Sdqk5SZU5Ix8XJ\n" - "NNZ8k6bp8TtM73OputUtYq0Unux/hkRkJOzZLCAN2KR+VpbtSkCBaDnIzdlWu59u+XeJTjeASk8\n" - "+juZOESEAVqx8BvU/PJibScTrTy09560hkWOGFd2YgFnPQKD19zhOSkxw2l8Vm6XAiYb8gg+k5O\n" - "9mnhoon9H3cs5s7WF5pp29OGGMFndyaAKBuTiEEPQLD8h/NDmNdYlttNkYjlbFjcXCr3LLH8II8\n" - "C2WUGviZvon/OPWkm3RNSv72SYllMkKxQRV67CQMSKYQAxMkR/wBC56d61P0heel4cYuVOXWvTp\n" - "h4Qjjf/9Hw5qBYyISaqjBV+QpvkAzKcki4HomnIxck/wBhtlR2bhunvlDywddMUl4zW+kQ9FQ8X\n" - "nfuSewrtmPkycPvc/DhMhvyegXOrWWhmLQPKlsj6xIAiLCoZkY96nv7npmJvI2XOjQFMl0fyRqM\n" - "NoxvZvrGt33wlATwiMnVnY1LEdSfuyXF3KIDmUu88w2XlnTl8raAlb2ZFfVL0jdYRtQnxc7BfDC\n" - "OaJR7nm3me5tdOtjbMvp3ZRXkV6chVQRX79hmVjgZG+jgZ5jHGhzecXF5LPL6jEjstSSaDM51Ka\n" - "6MZ9S1C0sEBe8uZo4YCBXdjxGw60wEWyEqfUHkT8vLXRJFuLdTcaqfhlvWUErtukZ3ABPUjIXTE\n" - "m3rGmeV2Tk5UKz/AG/E/wAcgZKya20C3b02kjYtH8AqCygbkUH0nLYlgUb+gbWtPbpXt/n2ybB/\n" - "/9Lw4oaVxGd+PxH3qBkGaY3KyiSP01IkiUclH8sg+LKydm6INvZvKsFu+kWtvD8LRoFNRup6moO\n" - "aqd277HsGW+XPLmn6XM17FF6l7vW4fd2Zuu+RFls2tmUNrLJb7TSBertGQGqetDkxE0na0pvtHs\n" - "QkszWyiGAG5laYlnkeMVHJj8sA5rPk+SvMepTalqlxd3B5zTOXdj/MxqafLpm5xioh5nPK5kpRG\n" - "pkcKAST0A6k5NpfUP5K/ki1ssHmHzF+71KRQ8Nud/Qibb/kYw6/yjbrXISlSH07YaHbWyxx2kXE\n" - "KACB2zHJtLI7XSelBRvH2xCpvaaTDHXkOTVBPcUG2479RlsdmJVPRtvV+ylenQ0y62FP/9PxRpo\n" - "WG5FxKKxKFDA+GVS5NsebLdFsRePc3siVW4f4QR0QVAGYeSXR2unhtZ6s60K6jt+MMSFwtF2+xX\n" - "wr7eGUGLlRPQMsE2vxQm7itxKg3VCfT2+nb8cDYaCDtfOXmCCcROrQrUhkkCHYn6emRMqZxjbLd\n" - "F1+W/4xajHzjNCtQKMffETWUdngX5p+QZ9A8xS6hbo0ui37NNDPT7DOalHpsCD08Rmyw5ARTpdV\n" - "gIPEF35MeRn80ed4S5EdrpKm9kZ15K0iH92hB7Me/tmS60vt/QrCYyekiBdgSTXcjqV9q9MokFD\n" - "N7S3aFVVR8RoK9zldqndvAY6nffr/AGYQqLhjdpCoIAZW22HavU/LJBUP9WblX0xTw7fOmWsX/9\n" - "Tw7FdvMqWkQ3Z1qfED+mQIbI77PX/LFis9vBajZm2Y+x65rMh3t30Bsze400aVaIbSLk6r8CMRT\n" - "l/NmOcllnGDD9Y8uecNfEEiXrMgDGWAyGOOu5WlB+vMrHODTlxZCdjsyFdB006VpVtLasurQxBL\n" - "64WiLI4/aFT1ANOXemV5piR2b9NiljB4yyHy9CLOVI5GJhB+CvXY9R8xmINzs5HNZ+Z96BZpbxA\n" - "fVJo39UFefwopYgL4nMiMd2qZoIn/AJx00u3t/Lt7qpp9Yv5GLf5MUTERqfbvmzBeezjd9H+VlL\n" - "wSQzBqsvOGQD7L12rXsemPNxmXQSxxIPU2nFV4HYqR1xEUWj4ZAxBryr2G+J2VGDZlLrxUH6KZA\n" - "Fkqb15VFelfwy+2FP8A/9Xxlf6AdA182Yk9eFeLxSjoVfcfSMo4uIOfkweFOnpvlWYrLEwNFAA+\n" - "nMOYdrhFvQLeSO7coBXiK8iKiv07Zj8Ac4QtNrW1njUcKcT+yAR/xGmR4WcsStLpTuPU9IFaEsV\n" - "BP3k4m2AgBzSwyQNcIwNTE1aI3wnam9O2Ug7s5Ckk/NDndeVXa2H78MqqV6jmeBp9+ZWKXqDjZ4\n" - "+gvVvy30qCy0qzsLRBCnBI2VdgUTqPvOZ7y+Q7pz+bn5q6d+VflZxZlJ/NN4ypptk5qtB9qRwDX\n" - "gn/AAx2y2ItpfKFv+eH5qNeTajJ5ovVaVywSqvEtTUKqupAA6D2y0BNPtv/AJx//M5PzL8mJeXT\n" - "L+ndPf6rqarSpkAqsnEAAeoN6DpkJRYci9lROSgSUUH9o9K5Tw0ztfSHnXkOtK9q+PHwydq//9b\n" - "yxrVoZNBtNSA5zRMPXmH8j0CLXuBmHE+qneamHpEuqYeV7pzFVTRgQK5XMNmnlb1vyyY5QA1OwJ\n" - "+eUF2seTOLu5s7azVIVAkpVn/hhnIALG73Yz5jvb1dICqzpDNIqyFD8SxH7R28cxibZCiWOsdJs\n" - "PTM6XNstPhnkjIhcHuJBVfvOCiUSn0TfWrTTLjyw8guA/PifTO3xcxxA8a5ZAbimvJP0m3p/kFF\n" - "WxhmpWQJ9NW3zZPHz5vlb/nIDVbrWfzO1RJhxGnpDaRL/khA1T7ktmSOTAJhZaAUtLawsbayl8v\n" - "xWi3Gpay0cF3HPcFRJJHJMXVrcJ8UaAFG5LWjF8tAYW9H/wCcOo9bTzxrt/owkTyksZW5gkIKvI\n" - "7k26nvyReRJHyyBWT7dWQyOWlbnK2526e1O1MqIUFE84uPLkOdK9RXI0E2/wD/1/DA1bURZLY/W\n" - "ZDZqwb0eXw7dMgIi7bjllVXsz7yNcfWC0Vd3Ip92Y2UOz0cnsPlwyx8xQ/u24sMxCadoJp9LOXk\n" - "VX/uwRUE0BI8cokbLMyoKouHu2MaKGXw7fLDwgoGSkbHpaNZyLLHRSKcFFQQRvUdMlwUFOQyLzr\n" - "ztpCaba6fPau4ijv4OURY8AjVFKV7ZZiO+7Vnh6XvXkSWNbW2WTb92KDxIFMzwHlZc3zX+fuizW\n" - "f5p3ty8XGDU4YLmCQiisyII3+4rvl8UB5ffEghRGvOm7AbnvWvjk1fen/ONPldPKP5aWOpPCfr2\n" - "uE31y6q2wbaMEn+VAMDSdyzrzj+avlHyTp0l/r2rxWFuHWJuIeacu4qFCRgsajfBwsty89/6Gr/\n" - "ACa9an+JL/hSnrfoubhXwpXpjwhaL//Q8E1AqtcAZMs8l6i1nqMa1oSVP0VynKLDmaWdSfQXl69\n" - "jF1Jv8MhDb5rpB3AO7INRRLhhGp4R05FgaGvTMU8200xS70zVDMRp2pTIOvBmB3PgQP15kxIcnD\n" - "LH/EEz0rRvOJhldr9pQtCqyd6VrShGTqw5d4ARv9jHfOGl+ZJNMluLkyenaFbiRdqFYW5nrWuwO\n" - "MKB5MdSMRxnhlu9N8p6lLFpti63FUjCtFJTrDKvse2bEDZ4XJ9RZB+YPli2/Mjy5bxoUi1a0YS2\n" - "85UOwIXiy9jRu+TBppfOF1+V3m22vrdpNPM8cs/oo0VJlUqQPjValR3+IZNNvtLS9Yu9Mi0/TJr\n" - "kyp6QhWVVCIWRATsKBemwwFrDzT87fybs/wA1bW21PRb+DTvNlgGSRp6iC8i3KJJx+y6n7D0Pwm\n" - "hxBZXT55/6Fi/Nf0PW+qWXq+t6X1X67F6vD/ftK04V/wBl344U8b//0fBapxheVh9ocV+nviqY2\n" - "/qQJDew/bioWHiuQ8m0bbvaPKGtQ6jaxSo9JloCK75gZI0Xb4sgkHo8MouoAvP94BsRmGY7uWJU\n" - "gzbypOQpNOvIdK4Nw2WCE2tXulTkjEEbdafgclxMhFBas93dwyQzsWDghlJFONKHJCZtjOFBJfy\n" - "j1y9vPL9zpbIs0WkXL2sUjA8hDXlGCRXtt07ZuYvL5KJeo6bfajbkzWkcToR8dqshZ6in2fhNK/\n" - "PDTUlXmHVvMdr5o0v9H2kdrqGpfu7m0nkY87Uf7tkKAU4/s03ynLkEBbfihx7dGT6va67LbRMNR\n" - "aKOBuUTKgIBXoK1BOYR1M3aQ0mOt9yxUeZNdtJhFapLqMluSXkg5oxJrUMW5KevQ9MmNXXNqOiH\n" - "Rr/Hmv8A1r9I/oj95w+r+j9Yf1+NP5+nXtTD+dF8tkfkOlv/0vC3ph7f0/alcVTbS4A8QibuKb5\n" - "RI05EBYRFpdX3ly79a2qYCavH/EY7TCYyMD5PSdD8+wXUSn1ArDqOhBzFlipz4ZwWbaV5htbsgF\n" - "qg9crMXKErGyYwajFGzxyHlGSePbbwyqg5UZlCaxrFpaWU95LIqrEjMAT4Dp9OShGy1ZslBhv/A\n" - "Dj9rd/a+aL+xUK+m38L3d0HrxRo2HFtu5D8c27y8t30raarbWkU+u6g4gsNORn+EcUaSh2Pc0/4\n" - "lgtAjezzbT9SutY1i782al8Nxdyotqh6xWybIg+jc5q8s+I27bFDgFPQp9RE+nrag70+L6crrZu\n" - "4jajokdv6LW/Dii1Wo61PXKQN3KPK0L+h4/rnD/K5V78a5LhXxd3/0/DMXXtwxVNtL9Xkaf3f7N\n" - "etfbKMjdjtkZ9D6ufrlK0+HpX8coF9HJ26sXvfqXrf7i/U+uften/d/wCyrmQL6uOav0pvpP8Ai\n" - "b1F+rV59+vH6a5XLhcjH4nRmY/xpxHP0/UptWvT6Mx/RbmjxWK+aP8AFf1M/pCv1Kvxen9inavf\n" - "MrFwXtzcLUeLXq5Mv/I3nz1b0v8AjofuKVry9KrUpTanOlf9jmQ68va/zH9b/COn/o7/AI431mP\n" - "65SvLh+zWvbl9rMfNfC34K4kmj9T6lD6FKclp/DNYXZx5srsPrHor6nXvkgxTPS/U+rv6dPU5mt\n" - "fngFN5ulv+l/pL/Lp/scerHo//2Q==\n"; + "/9j/4AAQSkZJRgABAgEASABIAAD/" + "4Q0HRXhpZgAATU0AKgAAAAgADAEOAAIAAAAgAAAAngEPAAI\n" + "AAAAFAAAAvgEQAAIAAAAJAAAAwwESAAMAAAABAAEAAAEaAAUAAAABAAAAzAEbAAUAAAABAAAA1" + "A\n" + "EoAAMAAAABAAIAAAExAAIAAAAUAAAA3AEyAAIAAAAUAAAA8AE8AAIAAAAQAAABBAITAAMAAAAB" + "A\n" + "AIAAIdpAAQAAAABAAABFAAAAsQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgAFNPTlk" + "A\n" + "RFNDLVAyMDAAAAAASAAAAAEAAABIAAAAAUFkb2JlIFBob3Rvc2hvcCA3LjAAMjAwNzowMTozMC" + "A\n" + "yMzoxMDowNABNYWMgT1MgWCAxMC40LjgAAByCmgAFAAAAAQAAAmqCnQAFAAAAAQAAAnKIIgADA" + "A\n" + "AAAQACAACIJwADAAAAAQBkAACQAAAHAAAABDAyMjCQAwACAAAAFAAAAnqQBAACAAAAFAAAAo6R" + "A\n" + "QAHAAAABAECAwCRAgAFAAAAAQAAAqKSBAAKAAAAAQAAAqqSBQAFAAAAAQAAArKSBwADAAAAAQA" + "F\n" + "AACSCAADAAAAAQAAAACSCQADAAAAAQAPAACSCgAFAAAAAQAAArqgAAAHAAAABDAxMDCgAQADAA" + "A\n" + "AAf//" + "AACgAgAEAAAAAQAAAGSgAwAEAAAAAQAAAGSjAAAHAAAAAQMAAACjAQAHAAAAAQEAAACkAQ\n" + "ADAAAAAQAAAACkAgADAAAAAQAAAACkAwADAAAAAQAAAACkBgADAAAAAQAAAACkCAADAAAAAQAA" + "A\n" + "ACkCQADAAAAAQAAAACkCgADAAAAAQAAAAAAAAAAAAAACgAAAZAAAAAcAAAACjIwMDc6MDE6MjA" + "g\n" + "MjM6MDU6NTIAMjAwNzowMToyMCAyMzowNTo1MgAAAAAIAAAAAQAAAAAAAAAKAAAAMAAAABAAAA" + "B\n" + "PAAAACgAAAAYBAwADAAAAAQAGAAABGgAFAAAAAQAAAxIBGwAFAAAAAQAAAxoBKAADAAAAAQACA" + "A\n" + "ACAQAEAAAAAQAAAyICAgAEAAAAAQAACd0AAAAAAAAASAAAAAEAAABIAAAAAf/Y/" + "+AAEEpGSUYAA\n" + "QIBAEgASAAA/+0ADEFkb2JlX0NNAAL/7gAOQWRvYmUAZIAAAAAB/" + "9sAhAAMCAgICQgMCQkMEQsK\n" + "CxEVDwwMDxUYExMVExMYEQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAQ0LCw" + "0\n" + "ODRAODhAUDg4OFBQODg4OFBEMDAwMDBERDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD" + "A\n" + "wMDAz/wAARCABkAGQDASIAAhEBAxEB/90ABAAH/" + "8QBPwAAAQUBAQEBAQEAAAAAAAAAAwABAgQFB\n" + "gcICQoLAQABBQEBAQEBAQAAAAAAAAABAAIDBAUGBwgJCgsQAAEEAQMCBAIFBwYIBQMMMwEAAhE" + "D\n" + "BCESMQVBUWETInGBMgYUkaGxQiMkFVLBYjM0coLRQwclklPw4fFjczUWorKDJkSTVGRFwqN0Nh" + "f\n" + "SVeJl8rOEw9N14/" + "NGJ5SkhbSVxNTk9KW1xdXl9VZmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9xEAAg\n" + "IBAgQEAwQFBgcHBgU1AQACEQMhMRIEQVFhcSITBTKBkRShsUIjwVLR8DMkYuFygpJDUxVjczTx" + "J\n" + "QYWorKDByY1wtJEk1SjF2RFVTZ0ZeLys4TD03Xj80aUpIW0lcTU5PSltcXV5fVWZnaGlqa2xtb" + "m\n" + "9ic3R1dnd4eXp7fH/" + "9oADAMBAAIRAxEAPwDy7bKNTUXNLz9EaJPDWMjxH4ozhtpYwaACT8ShaaW\n" + "bW0uEc9/JFfjj0Q4Hk/PRDxwX7y47W9z/" + "AN9Cv4+O3ILK2DcRqT2CaSvEbcl1Jbz37KG1dBldLo\n" + "qaS4l9xGjG9v6yoDAdYIaIjUk+AREgo4y5sapirb8Yl0NHHdKvBNm4yA1o5Pc+" + "SPEFvCWqB3HZF\n" + "Hj2SbWQ/" + "afGFP0bHP8ATY0uc4w1o1JPkkimGiS2KvqlnmBkOZQTyydzgPMM9v8A0lp4v1Nx9gF1\n" + "tpdqJaGtH/S3I0i3lISXW/8AMqnd/O2bfg2eUkqVYf/" + "Q8zuncO4Bj7lZ+n7f5Mj5KsJcY8NUZ4d\n" + "uEDVo1HkeU0rg3Om4H2rabCWUN7DQuK1n5FWKW4uCwG92gDRJBS6exhxmMboQI+" + "Cv4WFTQ42Bs2\n" + "fvnkkqEmy2YxoMMbpVzaz6jt+RbpHZs8lzkHqrasKkYOKP0jgDfZ4N/" + "wDM1tNrcWfSPmRyq9uNV\n" + "DnFg2s97i7UkjxKVrq0eVz3spZsja+ASDzwsh9jnOk/" + "JFzb3XZD3v1c4yT8UACTCniKDUnKz5Nj\n" + "G33XV1DV73BrT8dF23SejV4zg9g33cOsPb+SxVvqv9ViwNy8vS0iWs/" + "daf8A0Y5dpTi1sADGxCR\n" + "K1o0YBEmInlXWYbDBcDLdPJXa8f71Yrx2jnUoAqLnfZK5hJaW2vdwEk5a/wD/0fN6Ia/" + "e76IiVf\n" + "xavUL7CPpnT4LNbYXAVjuQt/AqDmNYO/" + "Kjnoy4hr5J8SwMhrRMaeSvbsxrfUazcOw4UX0Cisem2\n" + "SBoD4+" + "Kz8nC6llbSLCRrubJA8kwUWbUDa29X1PMa7aQWjuDC0MXMdbDbhI7eazBiUfZ6GOYRe1s\n" + "WvGgJ8Vbw2+m4Bx9s6JpNHuuGo1FF53r/" + "SHYua61gLse0lzXeBP5rkvqx0o5vVWz7WY49QkiQSP\n" + "oN/tLoevW/ogxv0HA7tJ0AnhT+pdDGYVl/wCdcTPkGn2NU0JWNWvlgAbHV6fEqdu2gR/" + "r2WlWwt\n" + "AA5VXAEsLXTqJafArQY5rRr9LiPBJiZsZCI1pJjxCi0j4oncSICSkWwzwkjeaSch//" + "0vO7sP7Lm\n" + "enO9ogtd5FbPT3Q5pCpZVc4ld3Lmn3O8j9EI2BYdunKjOobMQIyI+rusc2wx4d0eutwGnHh/" + "uQc\n" + "Ha7ladj6mVANGvcqOgz0Go7HJ12/GEHcwvB/dPY6ImbbaMaASGuIBjkN7qofs9Ubg9g7OI9p/" + "t/\n" + "RTSmhTHr0v6eSz6UgCPP2/wAVu9Ex2V49dVY2iACB4BZeVXQ/" + "AJ3gzGnnOi2+kACpru8flUsNmt\n" + "zHRf6xfWCnoeAfTh2ZaQKazx/" + "Ke7+QxcKz61fWA2uuObaC4zGhaPJrXBL64ZFmR124O09ENraPK\n" + "N3/AH5GqxIrZVUyp2K2vfdkENsDnxuex9m4Ox9n82xSgNd9D+p/XR1npgseR9ppOy4Dx/NfH/" + "CL\n" + "oQJGunmvMv8AFq3KHVcq3HkYQbD2nuSf0I/rMavSg6TLjLigQhJ7Z58v9QkmlsTOqSCn/" + "9PzL7R\n" + "d6Qq3n0wZ2zotXpT9xLfFYvkr/S7jXeB8E0jRkhKpC3q8LcJ/kmCrTnkuAPCq4do9Q/" + "ytVbuAeY\n" + "Gg5lQybQK+" + "82GBqEQUA1kOHPYf3LLsoyN36G5w8iUfHxepbXE2l0cApALgLHzBq9UxhTXU5hMC1\n" + "ktnSCup6S4Ctk+C5XqVGcaHPfuiuHkeTTuWz0+9zaKiH6CC0/yXBSQ2a/" + "MxojV57634rq+v2PLY\n" + "be1r2nsYG13/" + "AFKxbfCBMcr0brGAzrGEwCG31ncx0SfBzf7S4+zoHUWWsJq3hz9oLfcBH77R9H+\n" + "0pA13u/qPgDp/Q6ri39JlfpXkDx+h/" + "msWn1L6wdO6bSbcrIbU2Q0xLnSe21kuVejJspbVS5+4bd\n" + "ocBAkD/orG+tP1ar67Wy7GtZTm1SCXfRsb+a18fRe38x6SG3/44H1Z3f0y2I+l6DoSXD/" + "8xPrDs\n" + "3enVu3bdnqN3R+//USSVo//" + "1PLohhce+gRWS0Nsby3lRgFkKxQyW7SgUh3em5Tbq2uB9wWw1wey\n" + "J1XGV2XYdm5k7e4WzidXY9oMwo5RZ4T6Hd1ixwfp96PWbAJBVTHzK7O6Ky5oJB1HZMqmUEFlkG" + "y\n" + "xpa4zI1Hkq31dy7bMN9BAc3HeWAnnbyxEycmuup1jiAGglZ31PyrmZ9tQg1WtNj54EHR3/" + "S2qTH\n" + "1Yc5GgD1FFtzPdWGkd2AyflogZmRmsz6PSrbXbdo+" + "txOrP337f3fzVo15DK2uyrTtqpBOnBKx6b\n" + "7MjJsz7tHWOAYP3WD6LU6cqGjFCNl1MmvLcxv6YtDTLSAqP27LrdtYHXFnJZI+" + "Tp3MWg68OpDPv\n" + "UMUM2lkQBoouKQ6swjE9Nml+1sz1PW+z6xt27zuj+skrX2ZvqR5z8kkuOfdPt43/1fMm/" + "grFG6f\n" + "Lss9JA7JG7tnZs/SfJUrfS3foJ9TvHCopJsV8nWx/t24bJn8Fo/5TjWJXMJIS+i+G36TsZ/" + "7Q9P\n" + "8ATfzfeOFofVSZv2/zvt+O3X/v65dJPjt/BiyfN1/wn0zre79nVej/ADG8ep4x2/" + "6Srjd6TdviF\n" + "52ko8m6/Ht9X1KnftEo+POwxzK8mSTF46vrH6T1/OEl5Okkl//Z/" + "+0uHFBob3Rvc2hvcCAzLjAA\n" + "OEJJTQQEAAAAAAArHAIAAAIAAhwCeAAfICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA" + "A\n" + "4QklNBCUAAAAAABD7Caa9B0wqNp2P4sxXqayFOEJJTQPqAAAAAB2wPD94bWwgdmVyc2lvbj0iM" + "S\n" + "4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUg" + "Q\n" + "29tcHV0ZXIvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9" + "Q\n" + "cm9wZXJ0eUxpc3QtMS4wLmR0ZCI+" + "CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk\n" + "+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1Ib3Jpem9udGFsUmVzPC9rZXk+" + "Cgk8ZGljdD\n" + "4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCTxzdHJpbmc+" + "Y\n" + "29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50\n" + "LnRpY2tldC5pdGVtQXJyYXk8L2tleT4KCQk8YXJyYXk+" + "CgkJCTxkaWN0PgoJCQkJPGtleT5jb20\n" + "uYXBwbGUucHJpbnQuUGFnZUZvcm1hdC5QTUhvcml6b250YWxSZXM8L2tleT4KCQkJCTxyZWFsP" + "j\n" + "cyPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJ" + "C\n" + "QkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJpbmc+" + "CgkJCQk8a2V5PmNv\n" + "bS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGRhdGU+" + "MjAwNy0wMS0zMFQ\n" + "yMjowODo0MVo8L2RhdGU+" + "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuc3RhdGVGbG\n" + "FnPC9rZXk+CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY3Q+" + "CgkJPC9hcnJheT4KC\n" + "TwvZGljdD4KCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwv\n" + "a2V5PgoJPGRpY3Q+" + "CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4\n" + "KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvb" + "S\n" + "5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" + "CgkJPGFycmF5PgoJCQk8ZGljdD4KC\n" + "QkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwva2V5PgoJ\n" + "CQkJPGludGVnZXI+MTwvaW50ZWdlcj4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnRpY2tldC5\n" + "jbGllbnQ8L2tleT4KCQkJCTxzdHJpbmc+" + "Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW\n" + "5nPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lm1vZERhdGU8L2tleT4KCQkJCTxk" + "Y\n" + "XRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQ" + "u\n" + "dGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJPGludGVnZXI+" + "MDwvaW50ZWdlcj4KCQkJPC9kaWN\n" + "0PgoJCTwvYXJyYXk+Cgk8L2RpY3Q+" + "Cgk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0Ll\n" + "BNU2NhbGluZzwva2V5PgoJPGRpY3Q+" + "CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZ\n" + "WF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4" + "K\n" + "CQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" + "CgkJPGFycmF5Pgo\n" + "JCQk8ZGljdD4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1TY2FsaW5nPC\n" + "9rZXk+" + "CgkJCQk8cmVhbD4xPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0L\n" + "mNsaWVudDwva2V5PgoJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJ" + "p\n" + "bmc+" + "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGR\n" + "hdGU+MjAwNy0wMS0zMFQyMjowODo0MVo8L2RhdGU+" + "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC\n" + "50aWNrZXQuc3RhdGVGbGFnPC9rZXk+" + "CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY\n" + "3Q+CgkJPC9hcnJheT4KCTwvZGljdD4KCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQu\n" + "UE1WZXJ0aWNhbFJlczwva2V5PgoJPGRpY3Q+" + "CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V\n" + "0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0c" + "m\n" + "luZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" + "CgkJPGFyc\n" + "mF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1WZXJ0\n" + "aWNhbFJlczwva2V5PgoJCQkJPHJlYWw+NzI8L3JlYWw+" + "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcml\n" + "udC50aWNrZXQuY2xpZW50PC9rZXk+" + "CgkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbm\n" + "FnZXI8L3N0cmluZz4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZ\n" + "Xk+CgkJCQk8ZGF0ZT4yMDA3LTAxLTMwVDIyOjA4OjQxWjwvZGF0ZT4KCQkJCTxrZXk+" + "Y29tLmFw\n" + "cGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpbnRlZ2VyPjA8L2ludGVnZX" + "I\n" + "+CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5jb20uYXBwbGUucHJpbnQuU" + "G\n" + "FnZUZvcm1hdC5QTVZlcnRpY2FsU2NhbGluZzwva2V5PgoJPGRpY3Q+" + "CgkJPGtleT5jb20uYXBwb\n" + "GUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGl" + "u\n" + "Z21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycm" + "F\n" + "5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2\n" + "VGb3JtYXQuUE1WZXJ0aWNhbFNjYWxpbmc8L2tleT4KCQkJCTxyZWFsPjE8L3JlYWw+" + "CgkJCQk8a\n" + "2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50PC9rZXk+" + "CgkJCQk8c3RyaW5nPmNvbS5h\n" + "cHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnR\n" + "pY2tldC5tb2REYXRlPC9rZXk+" + "CgkJCQk8ZGF0ZT4yMDA3LTAxLTMwVDIyOjA4OjQxWjwvZGF0ZT\n" + "4KCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpb\n" + "nRlZ2VyPjA8L2ludGVnZXI+" + "CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5j\n" + "b20uYXBwbGUucHJpbnQuc3ViVGlja2V0LnBhcGVyX2luZm9fdGlja2V0PC9rZXk+" + "Cgk8ZGljdD4\n" + "KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlUmVjdDwva" + "2\n" + "V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5" + "P\n" + "goJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJPGtleT5" + "j\n" + "b20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+" + "CgkJCQk8ZGl\n" + "jdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlU" + "m\n" + "VjdDwva2V5PgoJCQkJCTxhcnJheT4KCQkJCQkJPHJlYWw+" + "MC4wPC9yZWFsPgoJCQkJCQk8cmVhb\n" + "D4wLjA8L3JlYWw+CgkJCQkJCTxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+" + "NTc2PC9yZWFs\n" + "PgoJCQkJCTwvYXJyYXk+" + "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDw\n" + "va2V5PgoJCQkJCTxzdHJpbmc+" + "Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQ\n" + "kJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+" + "M\n" + "jAwNy0wMS0zMFQyMjowODo0MVo8L2RhdGU+" + "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlj\n" + "a2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+" + "CgkJCQk8L2RpY3Q\n" + "+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYX\n" + "QuUE1BZGp1c3RlZFBhcGVyUmVjdDwva2V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5w" + "c\n" + "mludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21" + "h\n" + "bmFnZXI8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheT" + "w\n" + "va2V5PgoJCQk8YXJyYXk+" + "CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYW\n" + "dlRm9ybWF0LlBNQWRqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+" + "CgkJCQkJCTxyZ\n" + "WFsPi0xODwvcmVhbD4KCQkJCQkJPHJlYWw+" + "LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3Jl\n" + "YWw+CgkJCQkJCTxyZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+" + "Y29tLmF\n" + "wcGxlLnByaW50LnRpY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wc" + "m\n" + "ludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQu" + "b\n" + "W9kRGF0ZTwva2V5PgoJCQkJCTxkYXRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQk" + "J\n" + "CTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWd\n" + "lcj4wPC9pbnRlZ2VyPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5P" + "m\n" + "NvbS5hcHBsZS5wcmludC5QYXBlckluZm8uUE1QYXBlck5hbWU8L2tleT4KCQk8ZGljdD4KCQkJ" + "P\n" + "GtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20" + "u\n" + "YXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcm" + "l\n" + "udC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" + "CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZX\n" + "k+" + "Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVBhcGVyTmFtZTwva2V5PgoJCQkJCTxzdHJpb" + "\n" + "mc+bmEtbGV0dGVyPC9zdHJpbmc+" + "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNs\n" + "aWVudDwva2V5PgoJCQkJCTxzdHJpbmc+" + "Y29tLmFwcGxlLnByaW50LnBtLlBvc3RTY3JpcHQ8L3N\n" + "0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJC" + "Q\n" + "kJCTxkYXRlPjIwMDMtMDctMDFUMTc6NDk6MzZaPC9kYXRlPgoJCQkJCTxrZXk+" + "Y29tLmFwcGxlL\n" + "nByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4xPC9pbnRlZ2VyPgo" + "J\n" + "CQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC" + "5\n" + "QYXBlckluZm8uUE1VbmFkanVzdGVkUGFnZVJlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb" + "2\n" + "0uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUu" + "c\n" + "HJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWN" + "r\n" + "ZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+" + "Y29tLmF\n" + "wcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYWdlUmVjdDwva2V5PgoJCQkJCTxhc" + "n\n" + "JheT4KCQkJCQkJPHJlYWw+MC4wPC9yZWFsPgoJCQkJCQk8cmVhbD4wLjA8L3JlYWw+" + "CgkJCQkJC\n" + "TxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+NTc2PC9yZWFsPgoJCQkJCTwvYXJyYXk+" + "CgkJ\n" + "CQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJCTxzdHJpbm" + "c\n" + "+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQkJCTxrZXk+" + "Y29tLmFwcGxlLn\n" + "ByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+" + "MjAwNy0wMS0zMFQyMjowODo0M\n" + "Vo8L2RhdGU+" + "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5\n" + "PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCQk8L2RpY3Q+CgkJCTwvYXJyYXk+" + "CgkJPC9\n" + "kaWN0PgoJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYXBlcl\n" + "JlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0" + "b\n" + "3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5" + "n\n" + "PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" + "CgkJCTxhcnJ\n" + "heT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYW\n" + "RqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+" + "CgkJCQkJCTxyZWFsPi0xODwvcmVhb\n" + "D4KCQkJCQkJPHJlYWw+LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3JlYWw+" + "CgkJCQkJCTxy\n" + "ZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnR\n" + "pY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZ" + "X\n" + "I8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5" + "P\n" + "goJCQkJCTxkYXRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJCTxrZXk+" + "Y29tLmFw\n" + "cGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4wPC9pbnRlZ2" + "V\n" + "yPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wc" + "m\n" + "ludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+CgkJPGRpY3Q+CgkJCTxrZXk+" + "Y29tL\n" + "mFwcGxlLnByaW50LnRpY2tldC5jcmVhdG9yPC9rZXk+CgkJCTxzdHJpbmc+" + "Y29tLmFwcGxlLnBy\n" + "aW50LnBtLlBvc3RTY3JpcHQ8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2" + "V\n" + "0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+" + "CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcH\n" + "BsZS5wcmludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+" + "CgkJCQkJPHN0cmluZz5VU\n" + "yBMZXR0ZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW5" + "0\n" + "PC9rZXk+" + "CgkJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5\n" + "nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+" + "CgkJCQkJPG\n" + "RhdGU+MjAwMy0wNy0wMVQxNzo0OTozNlo8L2RhdGU+" + "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpb\n" + "nQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjE8L2ludGVnZXI+" + "CgkJCQk8\n" + "L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+" + "Y29tLmFwcGxlLnByaW50LnRpY2t\n" + "ldC5BUElWZXJzaW9uPC9rZXk+CgkJPHN0cmluZz4wMC4yMDwvc3RyaW5nPgoJCTxrZXk+" + "Y29tLm\n" + "FwcGxlLnByaW50LnRpY2tldC5wcml2YXRlTG9jazwva2V5PgoJCTxmYWxzZS8+" + "CgkJPGtleT5jb\n" + "20uYXBwbGUucHJpbnQudGlja2V0LnR5cGU8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcml" + "u\n" + "dC5QYXBlckluZm9UaWNrZXQ8L3N0cmluZz4KCTwvZGljdD4KCTxrZXk+" + "Y29tLmFwcGxlLnByaW5\n" + "0LnRpY2tldC5BUElWZXJzaW9uPC9rZXk+Cgk8c3RyaW5nPjAwLjIwPC9zdHJpbmc+" + "Cgk8a2V5Pm\n" + "NvbS5hcHBsZS5wcmludC50aWNrZXQucHJpdmF0ZUxvY2s8L2tleT4KCTxmYWxzZS8+" + "Cgk8a2V5P\n" + "mNvbS5hcHBsZS5wcmludC50aWNrZXQudHlwZTwva2V5PgoJPHN0cmluZz5jb20uYXBwbGUucHJ" + "p\n" + "bnQuUGFnZUZvcm1hdFRpY2tldDwvc3RyaW5nPgo8L2RpY3Q+CjwvcGxpc3Q+" + "CjhCSU0D6QAAAAA\n" + "AeAADAAAASABIAAAAAALeAkD/7v/uAwYCUgNnBSgD/" + "AACAAAASABIAAAAAALYAigAAQAAAGQAAA\n" + "ABAAMDAwAAAAF//" + "wABAAEAAAAAAAAAAAAAAABoCAAZAZAAAAAAACAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAADhCSU0D7QAAAAAAEABIAAAAAQABAEgAAAABAAE4QklNBCYAAAAAAA4AAAAAAAA" + "A\n" + "AAAAP4AAADhCSU0EDQAAAAAABAAAAB44QklNBBkAAAAAAAQAAAAeOEJJTQPzAAAAAAAJAAAAAA" + "A\n" + "AAAABADhCSU0ECgAAAAAAAQAAOEJJTScQAAAAAAAKAAEAAAAAAAAAAThCSU0D9QAAAAAASAAvZ" + "m\n" + "YAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAA" + "A\n" + "QAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP/" + "/\n" + "//////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA//" + "/\n" + "//////////////////////////" + "wPoAAA4QklNBAgAAAAAABAAAAABAAACQAAAAkAAAAAAOEJJTQ\n" + "QeAAAAAAAEAAAAADhCSU0EGgAAAAADRQAAAAYAAAAAAAAAAAAAAGQAAABkAAAACABEAFMAQwAw" + "A\n" + "DIAMwAyADUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAGQAAABkAAAAAAAAAAA" + "A\n" + "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAABudWxsAAAAAgAAAAZib3VuZH" + "N\n" + "PYmpjAAAAAQAAAAAAAFJjdDEAAAAEAAAAAFRvcCBsb25nAAAAAAAAAABMZWZ0bG9uZwAAAAAAA" + "A\n" + "AAQnRvbWxvbmcAAABkAAAAAFJnaHRsb25nAAAAZAAAAAZzbGljZXNWbExzAAAAAU9iamMAAAAB" + "A\n" + "AAAAAAFc2xpY2UAAAASAAAAB3NsaWNlSURsb25nAAAAAAAAAAdncm91cElEbG9uZwAAAAAAAAA" + "G\n" + "b3JpZ2luZW51bQAAAAxFU2xpY2VPcmlnaW4AAAANYXV0b0dlbmVyYXRlZAAAAABUeXBlZW51bQ" + "A\n" + "AAApFU2xpY2VUeXBlAAAAAEltZyAAAAAGYm91bmRzT2JqYwAAAAEAAAAAAABSY3QxAAAABAAAA" + "A\n" + "BUb3AgbG9uZwAAAAAAAAAATGVmdGxvbmcAAAAAAAAAAEJ0b21sb25nAAAAZAAAAABSZ2h0bG9u" + "Z\n" + "wAAAGQAAAADdXJsVEVYVAAAAAEAAAAAAABudWxsVEVYVAAAAAEAAAAAAABNc2dlVEVYVAAAAAE" + "A\n" + "AAAAAAZhbHRUYWdURVhUAAAAAQAAAAAADmNlbGxUZXh0SXNIVE1MYm9vbAEAAAAIY2VsbFRleH" + "R\n" + "URVhUAAAAAQAAAAAACWhvcnpBbGlnbmVudW0AAAAPRVNsaWNlSG9yekFsaWduAAAAB2RlZmF1b" + "H\n" + "QAAAAJdmVydEFsaWduZW51bQAAAA9FU2xpY2VWZXJ0QWxpZ24AAAAHZGVmYXVsdAAAAAtiZ0Nv" + "b\n" + "G9yVHlwZWVudW0AAAARRVNsaWNlQkdDb2xvclR5cGUAAAAATm9uZQAAAAl0b3BPdXRzZXRsb25" + "n\n" + "AAAAAAAAAApsZWZ0T3V0c2V0bG9uZwAAAAAAAAAMYm90dG9tT3V0c2V0bG9uZwAAAAAAAAALcm" + "l\n" + "naHRPdXRzZXRsb25nAAAAAAA4QklNBBEAAAAAAAEBADhCSU0EFAAAAAAABAAAAAE4QklNBAwAA" + "A\n" + "AACfkAAAABAAAAZAAAAGQAAAEsAAB1MAAACd0AGAAB/9j/4AAQSkZJRgABAgEASABIAAD/" + "7QAMQ\n" + "WRvYmVfQ00AAv/uAA5BZG9iZQBkgAAAAAH/" + "2wCEAAwICAgJCAwJCQwRCwoLERUPDAwPFRgTExUT\n" + "ExgRDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBDQsLDQ4NEA4OEBQODg4UFA" + "4\n" + "ODg4UEQwMDAwMEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/" + "AABEIAGQAZA\n" + "MBIgACEQEDEQH/3QAEAAf/xAE/" + "AAABBQEBAQEBAQAAAAAAAAADAAECBAUGBwgJCgsBAAEFAQEBA\n" + "QEBAAAAAAAAAAEAAgMEBQYHCAkKCxAAAQQBAwIEAgUHBggFAwwzAQACEQMEIRIxBUFRYRMicYE" + "y\n" + "BhSRobFCIyQVUsFiMzRygtFDByWSU/" + "Dh8WNzNRaisoMmRJNUZEXCo3Q2F9JV4mXys4TD03Xj80Y\n" + "nlKSFtJXE1OT0pbXF1eX1VmZ2hpamtsbW5vY3R1dnd4eXp7fH1+" + "f3EQACAgECBAQDBAUGBwcGBT\n" + "UBAAIRAyExEgRBUWFxIhMFMoGRFKGxQiPBUtHwMyRi4XKCkkNTFWNzNPElBhaisoMHJjXC0kST" + "V\n" + "KMXZEVVNnRl4vKzhMPTdePzRpSkhbSVxNTk9KW1xdXl9VZmdoaWprbG1ub2JzdHV2d3h5ent8f" + "/\n" + "2gAMAwEAAhEDEQA/" + "APLtso1NRc0vP0Rok8NYyPEfijOG2ljBoAJPxKFppZtbS4Rz38kV+OPRDge\n" + "T89EPHBfvLjtb3P8A30K/j47cgsrYNxGpPYJpK8RtyXUlvPfsobV0GV0uippLiX3EaMb2/" + "rKgMB\n" + "1ghoiNST4BESCjjLmxqmKtvxiXQ0cd0q8E2bjIDWjk9z5I8QW8JaoHcdkUePZJtZD9p8YU/" + "Rsc/\n" + "wBNjS5zjDWjUk+SSKYaJLYq+qWeYGQ5lBPLJ3OA8wz2/wDSWni/" + "U3H2AXW2l2oloa0f9LcjSLeU\n" + "hJdb/wAyqd387Zt+DZ5SSpVh/9DzO6dw7gGPuVn6ft/" + "kyPkqwlxjw1Rnh24QNWjUeR5TSuDc6bg\n" + "fatpsJZQ3sNC4rWfkVYpbi4LAb3aANEkFLp7GHGYxuhAj4K/" + "hYVNDjYGzZ++eSSoSbLZjGgwxul\n" + "XNrPqO35FukdmzyXOQeqtqwqRg4o/SOAN9ng3/" + "AMzW02txZ9I+ZHKr241UOcWDaz3uLtSSPEpWu\n" + "rR5XPeylmyNr4BIPPCyH2Oc6T8kXNvddkPe/" + "VzjJPxQAJMKeIoNScrPk2MbfddXUNXvcGtPx0Xb\n" + "dJ6NXjOD2Dfdw6w9v5LFW+q/1WLA3Ly9LSJaz91p/" + "wDRjl2lOLWwAMbEJErWjRgESYieVdZhsMF\n" + "wMt08ldrx/vVivHaOdSgCoud9krmElpba93ASTlr/AP/R83ohr97voiJV/" + "Fq9QvsI+mdPgs1thc\n" + "BWO5C38CoOY1g78qOejLiGvknxLAyGtExp5K9uzGt9RrNw7DhRfQKKx6bZIGgPj4rPycLqWVtI" + "s\n" + "JGu5skDyTBRZtQNrb1fU8xrtpBaO4MLQxcx1sNuEjt5rMGJR9noY5hF7Wxa8aAnxVvDb6bgHH2" + "z\n" + "omk0e64ajUUXnev9Idi5rrWAux7SXNd4E/muS+rHSjm9VbPtZjj1CSJBI+g3+0uh69b+iDG/" + "QcD\n" + "u0nQCeFP6l0MZhWX/" + "AJ1xM+QafY1TQlY1a+WABsdXp8Sp27aBH+vZaVbC0ADlVcASwtdOolp8Ct\n" + "BjmtGv0uI8EmJmxkIjWkmPEKLSPiidxIgJKRbDPCSN5pJyH//S87uw/" + "suZ6c72iC13kVs9PdDmk\n" + "KllVziV3cuafc7yP0QjYFh26cqM6hsxAjIj6u6xzbDHh3R663AaceH+" + "5BwdruVp2PqZUA0a9yo6\n" + "DPQajscnXb8YQdzC8H909joiZttoxoBIa4gGOQ3uqh+z1RuD2Ds4j2n+39FNKaFMevS/" + "p5LPpSA\n" + "I8/b/ABW70THZXj11VjaIAIHgFl5VdD8AneDMaec6Lb6QAKmu7x+VSw2a3MdF/" + "rF9YKeh4B9OHZ\n" + "lpAprPH8p7v5DFwrPrV9YDa645toLjMaFo8mtcEvrhkWZHXbg7T0Q2to8o3f8AfkarEitlVTKn" + "Y\n" + "ra992QQ2wOfG57H2bg7H2fzbFKA130P6n9dHWemCx5H2mk7LgPH818f8IuhAka6ea8y/" + "wAWrcod\n" + "VyrceRhBsPae5J/Qj+sxq9KDpMuMuKBCEntnny/1CSaWxM6pIKf/0/" + "MvtF3pCrefTBnbOi1elP3\n" + "Et8Vi+Sv9LuNd4HwTSNGSEqkLerwtwn+SYKtOeS4A8Krh2j1D/" + "K1Vu4B5gaDmVDJtAr7zYYGoRB\n" + "QDWQ4c9h/" + "csuyjI3fobnDyJR8fF6ltcTaXRwCkAuAsfMGr1TGFNdTmEwLWS2dIK6npLgK2T4Lle\n" + "pUZxoc9+6K4eR5NO5bPT73NoqIfoILT/JcFJDZr8zGiNXnvrfiur6/" + "Y8tht7WvaexgbXf8AUrFt\n" + "8IExyvRusYDOsYTAIbfWdzHRJ8HN/" + "tLj7OgdRZawmreHP2gt9wEfvtH0f7SkDXe7+o+AOn9DquL\n" + "f0mV+leQPH6H+axafUvrB07ptJtyshtTZDTEudJ7bWS5V6MmyltVLn7ht2hwECQP+isb60/" + "Vqvr\n" + "tbLsa1lObVIJd9Gxv5rXx9F7fzHpIbf/jgfVnd/TLYj6XoOhJcP/zE+sOzd6dW7dt2eo3dH7/" + "9R\n" + "JJWj//" + "U8uiGFx76BFZLQ2xvLeVGAWQrFDJbtKBSHd6blNura4H3BbDXB7InVcZXZdh2bmTt7hbO\n" + "J1dj2gzCjlFnhPod3WLHB+" + "n3o9ZsAkFVMfMrs7orLmgkHUdkyqZQQWWQbLGlrjMjUeSrfV3Ltsw\n" + "30EBzcd5YCedvLETJya66nWOIAaCVnfU/" + "KuZn21CDVa02PngQdHf9LapMfVhzkaAPUUW3M91YaR\n" + "3YDJ+WiBmZGazPo9Kttdt2j63E6s/fft/d/NWjXkMra7KtO2qkE6cErHpvsyMmzPu0dY4Bg/" + "dYP\n" + "otTpyoaMUI2XUya8tzG/pi0NMtICo/" + "bsut21gdcWclkj5OncxaDrw6kM+9QxQzaWRAGii4pDqzC\n" + "MT02aX7WzPU9b7PrG3bvO6P6yStfZm+pHnPySS4590+3jf/" + "V8yb+CsUbp8uyz0kDskbu2dmz9J8\n" + "lSt9Ld+gn1O8cKikmxXydbH+3bhsmfwWj/lONYlcwkhL6L4bfpOxn/tD0/wBN/N944Wh9VJm/" + "b/\n" + "O+347df+/rl0k+O38GLJ83X/CfTOt7v2dV6P8AMbx6njHb/" + "pKuN3pN2+IXnaSjybr8e31fUqd+0\n" + "Sj487DHMryZJMXjq+sfpPX84SXk6SSX/" + "9kAOEJJTQQhAAAAAABVAAAAAQEAAAAPAEEAZABvAGIA\n" + "ZQAgAFAAaABvAHQAbwBzAGgAbwBwAAAAEwBBAGQAbwBiAGUAIABQAGgAbwB0AG8AcwBoAG8AcA" + "A\n" + "gADcALgAwAAAAAQA4QklNBAYAAAAAAAcABQAAAAEBAP/" + "hFWdodHRwOi8vbnMuYWRvYmUuY29tL3\n" + "hhcC8xLjAvADw/eHBhY2tldCBiZWdpbj0n77u/" + "JyBpZD0nVzVNME1wQ2VoaUh6cmVTek5UY3prY\n" + "zlkJz8+Cjw/YWRvYmUteGFwLWZpbHRlcnMgZXNjPSJDUiI/" + "Pgo8eDp4YXBtZXRhIHhtbG5zOng9\n" + "J2Fkb2JlOm5zOm1ldGEvJyB4OnhhcHRrPSdYTVAgdG9vbGtpdCAyLjguMi0zMywgZnJhbWV3b3" + "J\n" + "rIDEuNSc+" + "CjxyZGY6UkRGIHhtbG5zOnJkZj0naHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi\n" + "1yZGYtc3ludGF4LW5zIycgeG1sbnM6aVg9J2h0dHA6Ly9ucy5hZG9iZS5jb20vaVgvMS4wLyc+" + "C\n" + "gogPHJkZjpEZXNjcmlwdGlvbiBhYm91dD0ndXVpZDoyMmQwMmIwYS1iMjQ5LTExZGItOGFmOC0" + "5\n" + "MWQ1NDAzZjkyZjknCiAgeG1sbnM6cGRmPSdodHRwOi8vbnMuYWRvYmUuY29tL3BkZi8xLjMvJz" + "4\n" + "KICA8IS0tIHBkZjpTdWJqZWN0IGlzIGFsaWFzZWQgLS0+" + "CiA8L3JkZjpEZXNjcmlwdGlvbj4KCi\n" + "A8cmRmOkRlc2NyaXB0aW9uIGFib3V0PSd1dWlkOjIyZDAyYjBhLWIyNDktMTFkYi04YWY4LTkx" + "Z\n" + "DU0MDNmOTJmOScKICB4bWxuczpwaG90b3Nob3A9J2h0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9" + "z\n" + "aG9wLzEuMC8nPgogIDwhLS0gcGhvdG9zaG9wOkNhcHRpb24gaXMgYWxpYXNlZCAtLT4KIDwvcm" + "R\n" + "mOkRlc2NyaXB0aW9uPgoKIDxyZGY6RGVzY3JpcHRpb24gYWJvdXQ9J3V1aWQ6MjJkMDJiMGEtY" + "j\n" + "I0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5JwogIHhtbG5zOnhhcD0naHR0cDovL25zLmFkb2Jl" + "L\n" + "mNvbS94YXAvMS4wLyc+" + "CiAgPCEtLSB4YXA6RGVzY3JpcHRpb24gaXMgYWxpYXNlZCAtLT4KIDwv\n" + "cmRmOkRlc2NyaXB0aW9uPgoKIDxyZGY6RGVzY3JpcHRpb24gYWJvdXQ9J3V1aWQ6MjJkMDJiMG" + "E\n" + "tYjI0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5JwogIHhtbG5zOnhhcE1NPSdodHRwOi8vbnMuY" + "W\n" + "RvYmUuY29tL3hhcC8xLjAvbW0vJz4KICA8eGFwTU06RG9jdW1lbnRJRD5hZG9iZTpkb2NpZDpw" + "a\n" + "G90b3Nob3A6MjJkMDJiMDYtYjI0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5PC94YXBNTTpEb2N" + "1\n" + "bWVudElEPgogPC9yZGY6RGVzY3JpcHRpb24+" + "CgogPHJkZjpEZXNjcmlwdGlvbiBhYm91dD0ndXV\n" + "pZDoyMmQwMmIwYS1iMjQ5LTExZGItOGFmOC05MWQ1NDAzZjkyZjknCiAgeG1sbnM6ZGM9J2h0d" + "H\n" + "A6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvJz4KICA8ZGM6ZGVzY3JpcHRpb24+" + "CiAgIDxyZ\n" + "GY6QWx0PgogICAgPHJkZjpsaSB4bWw6bGFuZz0neC1kZWZhdWx0Jz4gICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgPC9yZGY6bGk+" + "CiAgIDwvcmRmOkFsdD4KICA8L2RjOmRlc2NyaXB0aW9\n" + "uPgogPC9yZGY6RGVzY3JpcHRpb24+Cgo8L3JkZjpSREY+" + "CjwveDp4YXBtZXRhPgogICAgICAgIC\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "A\n" + "ogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAK" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" + "I\n" + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICA" + "g\n" + "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" + "A\n" + "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgI" + "C\n" + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0ndyc/" + "P\n" + "v/uAA5BZG9iZQBkQAAAAAH/" + "2wCEAAQDAwMDAwQDAwQGBAMEBgcFBAQFBwgGBgcGBggKCAkJCQkI\n" + "CgoMDAwMDAoMDAwMDAwMDAwMDAwMDAwMDAwMDAwBBAUFCAcIDwoKDxQODg4UFA4ODg4UEQwMDA" + "w\n" + "MEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/" + "AABEIAGQAZAMBEQACEQEDEQ\n" + "H/3QAEAA3/" + "xAGiAAAABwEBAQEBAAAAAAAAAAAEBQMCBgEABwgJCgsBAAICAwEBAQEBAAAAAAAAA\n" + "AEAAgMEBQYHCAkKCxAAAgEDAwIEAgYHAwQCBgJzAQIDEQQABSESMUFRBhNhInGBFDKRoQcVsUI" + "j\n" + "wVLR4TMWYvAkcoLxJUM0U5KismNzwjVEJ5OjszYXVGR0w9LiCCaDCQoYGYSURUaktFbTVSga8u" + "P\n" + "zxNTk9GV1hZWltcXV5fVmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9zhIWGh4iJiouMjY6PgpOUlZa" + "X\n" + "mJmam5ydnp+" + "So6SlpqeoqaqrrK2ur6EQACAgECAwUFBAUGBAgDA20BAAIRAwQhEjFBBVETYSIGc\n" + "YGRMqGx8BTB0eEjQhVSYnLxMyQ0Q4IWklMlomOywgdz0jXiRIMXVJMICQoYGSY2RRonZHRVN/" + "Kj\n" + "s8MoKdPj84SUpLTE1OT0ZXWFlaW1xdXl9UZWZnaGlqa2xtbm9kdXZ3eHl6e3x9fn9zhIWGh4iJ" + "i\n" + "ouMjY6Pg5SVlpeYmZqbnJ2en5KjpKWmp6ipqqusra6vr/2gAMAwEAAhEDEQA/" + "APBnplwPAdR+GB\n" + "KY6dYtNG1w39yh4+xb+zIksgEfFaRSSoIx8f7RPRRkSWQimM+lRmwWVXFWYigHxUUVoMiJM+" + "Fj0\n" + "tg0RBegLE0Wu+3c+GTBazFCGI7HtSp9slbFYYzyoBsegw2hY1Afl3wqqRqahk+" + "0tDgKpgu4DAUU\n" + "+HY+GRS2ePiMKtUB3G+KGuONq//" + "Q8OzpFbW5WnxMop4k9crG5ZnZNJkEOn21utVRYw7HxZtz+OR\n" + "vdsrZ2lRtci4aVxFEQA0neg/" + "ZXxJpTITNNuOFss0vSotYNvZ2qGRkPKSTqiU8Sdqk5SZU5Ix8XJ\n" + "NNZ8k6bp8TtM73OputUtYq0Unux/" + "hkRkJOzZLCAN2KR+VpbtSkCBaDnIzdlWu59u+XeJTjeASk8\n" + "+juZOESEAVqx8BvU/" + "PJibScTrTy09560hkWOGFd2YgFnPQKD19zhOSkxw2l8Vm6XAiYb8gg+k5O\n" + "9mnhoon9H3cs5s7WF5pp29OGGMFndyaAKBuTiEEPQLD8h/" + "NDmNdYlttNkYjlbFjcXCr3LLH8II8\n" + "C2WUGviZvon/OPWkm3RNSv72SYllMkKxQRV67CQMSKYQAxMkR/" + "wBC56d61P0heel4cYuVOXWvTp\n" + "h4Qjjf/9Hw5qBYyISaqjBV+QpvkAzKcki4HomnIxck/" + "wBhtlR2bhunvlDywddMUl4zW+kQ9FQ8X\n" + "nfuSewrtmPkycPvc/" + "DhMhvyegXOrWWhmLQPKlsj6xIAiLCoZkY96nv7npmJvI2XOjQFMl0fyRqM\n" + "NoxvZvrGt33wlATwiMnVnY1LEdSfuyXF3KIDmUu88w2XlnTl8raAlb2ZFfVL0jdYRtQnxc7BfD" + "C\n" + "OaJR7nm3me5tdOtjbMvp3ZRXkV6chVQRX79hmVjgZG+" + "jgZ5jHGhzecXF5LPL6jEjstSSaDM51Ka\n" + "6MZ9S1C0sEBe8uZo4YCBXdjxGw60wEWyEqfUHkT8vLXRJFuLdTcaqfhlvWUErtukZ3ABPUjIXT" + "E\n" + "m3rGmeV2Tk5UKz/AG/E/wAcgZKya20C3b02kjYtH8AqCygbkUH0nLYlgUb+gbWtPbpXt/" + "n2ybB/\n" + "/9Lw4oaVxGd+PxH3qBkGaY3KyiSP01IkiUclH8sg+LKydm6INvZvKsFu+" + "kWtvD8LRoFNRup6moO\n" + "aqd277HsGW+XPLmn6XM17FF6l7vW4fd2Zuu+" + "RFls2tmUNrLJb7TSBertGQGqetDkxE0na0pvtHs\n" + "QkszWyiGAG5laYlnkeMVHJj8sA5rPk+SvMepTalqlxd3B5zTOXdj/" + "MxqafLpm5xioh5nPK5kpRG\n" + "pkcKAST0A6k5NpfUP5K/ki1ssHmHzF+71KRQ8Nud/Qibb/kYw6/" + "yjbrXISlSH07YaHbWyxx2kXE\n" + "KACB2zHJtLI7XSelBRvH2xCpvaaTDHXkOTVBPcUG2479RlsdmJVPRtvV+ylenQ0y62FP/" + "9PxRpo\n" + "WG5FxKKxKFDA+GVS5NsebLdFsRePc3siVW4f4QR0QVAGYeSXR2unhtZ6s60K6jt+MMSFwtF2+" + "xX\n" + "wr7eGUGLlRPQMsE2vxQm7itxKg3VCfT2+" + "nb8cDYaCDtfOXmCCcROrQrUhkkCHYn6emRMqZxjbLd\n" + "F1+W/" + "4xajHzjNCtQKMffETWUdngX5p+QZ9A8xS6hbo0ui37NNDPT7DOalHpsCD08Rmyw5ARTpdV\n" + "gIPEF35MeRn80ed4S5EdrpKm9kZ15K0iH92hB7Me/tmS60vt/" + "QrCYyekiBdgSTXcjqV9q9MokFD\n" + "N7S3aFVVR8RoK9zldqndvAY6nffr/AGYQqLhjdpCoIAZW22HavU/LJBUP9WblX0xTw7fOmWsX/" + "9\n" + "Tw7FdvMqWkQ3Z1qfED+mQIbI77PX/" + "LFis9vBajZm2Y+x65rMh3t30Bsze400aVaIbSLk6r8CMRT\n" + "l/" + "NmOcllnGDD9Y8uecNfEEiXrMgDGWAyGOOu5WlB+" + "vMrHODTlxZCdjsyFdB006VpVtLasurQxBL\n" + "64WiLI4/" + "aFT1ANOXemV5piR2b9NiljB4yyHy9CLOVI5GJhB+CvXY9R8xmINzs5HNZ+Z96BZpbxA\n" + "fVJo39UFefwopYgL4nMiMd2qZoIn/AJx00u3t/" + "Lt7qpp9Yv5GLf5MUTERqfbvmzBeezjd9H+VlL\n" + "wSQzBqsvOGQD7L12rXsemPNxmXQSxxIPU2nFV4HYqR1xEUWj4ZAxBryr2G+" + "J2VGDZlLrxUH6KZA\n" + "Fkqb15VFelfwy+2FP8A/" + "9Xxlf6AdA182Yk9eFeLxSjoVfcfSMo4uIOfkweFOnpvlWYrLEwNFAA+\n" + "nMOYdrhFvQLeSO7coBXiK8iKiv07Zj8Ac4QtNrW1njUcKcT+yAR/" + "xGmR4WcsStLpTuPU9IFaEsV\n" + "BP3k4m2AgBzSwyQNcIwNTE1aI3wnam9O2Ug7s5Ckk/" + "NDndeVXa2H78MqqV6jmeBp9+ZWKXqDjZ4\n" + "+gvVvy30qCy0qzsLRBCnBI2VdgUTqPvOZ7y+Q7pz+bn5q6d+VflZxZlJ/" + "NN4ypptk5qtB9qRwDX\n" + "gn/AAx2y2ItpfKFv+eH5qNeTajJ5ovVaVywSqvEtTUKqupAA6D2y0BNPtv/AJx//" + "M5PzL8mJeXT\n" + "L+ndPf6rqarSpkAqsnEAAeoN6DpkJRYci9lROSgSUUH9o9K5Tw0ztfSHnXkOtK9q+PHwydq//" + "9b\n" + "yxrVoZNBtNSA5zRMPXmH8j0CLXuBmHE+" + "qneamHpEuqYeV7pzFVTRgQK5XMNmnlb1vyyY5QA1OwJ\n" + "+eUF2seTOLu5s7azVIVAkpVn/" + "hhnIALG73Yz5jvb1dICqzpDNIqyFD8SxH7R28cxibZCiWOsdJs\n" + "PTM6XNstPhnkjIhcHuJBVfvOCiUSn0TfWrTTLjyw8guA/PifTO3xcxxA8a5ZAbimvJP0m3p/" + "kFF\n" + "WxhmpWQJ9NW3zZPHz5vlb/nIDVbrWfzO1RJhxGnpDaRL/" + "khA1T7ktmSOTAJhZaAUtLawsbayl8v\n" + "xWi3Gpay0cF3HPcFRJJHJMXVrcJ8UaAFG5LWjF8tAYW9H/wCcOo9bTzxrt/" + "owkTyksZW5gkIKvI\n" + "7k26nvyReRJHyyBWT7dWQyOWlbnK2526e1O1MqIUFE84uPLkOdK9RXI0E2/wD/1/DA1bURZLY/" + "W\n" + "ZDZqwb0eXw7dMgIi7bjllVXsz7yNcfWC0Vd3Ip92Y2UOz0cnsPlwyx8xQ/" + "u24sMxCadoJp9LOXk\n" + "VX/" + "uwRUE0BI8cokbLMyoKouHu2MaKGXw7fLDwgoGSkbHpaNZyLLHRSKcFFQQRvUdMlwUFOQyLzr\n" + "ztpCaba6fPau4ijv4OURY8AjVFKV7ZZiO+7Vnh6XvXkSWNbW2WTb92KDxIFMzwHlZc3zX+" + "fuizW\n" + "f5p3ty8XGDU4YLmCQiisyII3+4rvl8UB5ffEghRGvOm7AbnvWvjk1fen/" + "ONPldPKP5aWOpPCfr2\n" + "uE31y6q2wbaMEn+VAMDSdyzrzj+avlHyTp0l/r2rxWFuHWJuIeacu4qFCRgsajfBwsty89/" + "6Gr/\n" + "ACa9an+JL/hSnrfoubhXwpXpjwhaL//" + "Q8E1AqtcAZMs8l6i1nqMa1oSVP0VynKLDmaWdSfQXl69\n" + "jF1Jv8MhDb5rpB3AO7INRRLhhGp4R05FgaGvTMU8200xS70zVDMRp2pTIOvBmB3PgQP15kxIcn" + "D\n" + "LH/" + "EEz0rRvOJhldr9pQtCqyd6VrShGTqw5d4ARv9jHfOGl+ZJNMluLkyenaFbiRdqFYW5nrWuwO\n" + "MKB5MdSMRxnhlu9N8p6lLFpti63FUjCtFJTrDKvse2bEDZ4XJ9RZB+YPli2/" + "Mjy5bxoUi1a0YS2\n" + "85UOwIXiy9jRu+TBppfOF1+V3m22vrdpNPM8cs/oo0VJlUqQPjValR3+IZNNvtLS9Yu9Mi0/" + "TJr\n" + "kyp6QhWVVCIWRATsKBemwwFrDzT87fybs/" + "wA1bW21PRb+DTvNlgGSRp6iC8i3KJJx+y6n7D0Pwm\n" + "hxBZXT55/6Fi/Nf0PW+qWXq+t6X1X67F6vD/ftK04V/wBl344U8b//" + "0fBapxheVh9ocV+nviqY2\n" + "/qQJDew/" + "bioWHiuQ8m0bbvaPKGtQ6jaxSo9JloCK75gZI0Xb4sgkHo8MouoAvP94BsRmGY7uWJU\n" + "gzbypOQpNOvIdK4Nw2WCE2tXulTkjEEbdafgclxMhFBas93dwyQzsWDghlJFONKHJCZtjOFBJf" + "y\n" + "j1y9vPL9zpbIs0WkXL2sUjA8hDXlGCRXtt07ZuYvL5KJeo6bfajbkzWkcToR8dqshZ6in2fhNK" + "/\n" + "PDTUlXmHVvMdr5o0v9H2kdrqGpfu7m0nkY87Uf7tkKAU4/" + "s03ynLkEBbfihx7dGT6va67LbRMNR\n" + "aKOBuUTKgIBXoK1BOYR1M3aQ0mOt9yxUeZNdtJhFapLqMluSXkg5oxJrUMW5KevQ9MmNXXNqOi" + "H\n" + "Rr/Hmv8A1r9I/oj95w+r+j9Yf1+NP5+nXtTD+dF8tkfkOlv/0vC3ph7f0/" + "alcVTbS4A8QibuKb5\n" + "RI05EBYRFpdX3ly79a2qYCavH/" + "EY7TCYyMD5PSdD8+wXUSn1ArDqOhBzFlipz4ZwWbaV5htbsgF\n" + "qg9crMXKErGyYwajFGzxyHlGSePbbwyqg5UZlCaxrFpaWU95LIqrEjMAT4Dp9OShGy1ZslBhv/" + "A\n" + "Dj9rd/a+aL+xUK+m38L3d0HrxRo2HFtu5D8c27y8t30raarbWkU+u6g4gsNORn+EcUaSh2Pc0/" + "4\n" + "lgtAjezzbT9SutY1i782al8Nxdyotqh6xWybIg+jc5q8s+I27bFDgFPQp9RE+nrag70+" + "L6crrZu\n" + "4jajokdv6LW/Dii1Wo61PXKQN3KPK0L+h4/rnD/K5V78a5LhXxd3/0/" + "DMXXtwxVNtL9Xkaf3f7N\n" + "etfbKMjdjtkZ9D6ufrlK0+HpX8coF9HJ26sXvfqXrf7i/U+uften/d/" + "wCyrmQL6uOav0pvpP8Ai\n" + "b1F+rV59+vH6a5XLhcjH4nRmY/xpxHP0/UptWvT6Mx/RbmjxWK+aP8AFf1M/" + "pCv1Kvxen9inavf\n" + "MrFwXtzcLUeLXq5Mv/I3nz1b0v8AjofuKVry9KrUpTanOlf9jmQ68va/zH9b/COn/o7/" + "AI431mP\n" + "65SvLh+zWvbl9rMfNfC34K4kmj9T6lD6FKclp/DNYXZx5srsPrHor6nXvkgxTPS/" + "U+rv6dPU5mt\n" + "fngFN5ulv+l/pL/Lp/scerHo//2Q==\n"; static std::string gCommandLine; @@ -901,87 +1351,85 @@ TEST(Base64, LargeSample) { char unescaped[64 * 1024]; // unescape that massive blob above - size_t size = Base64Unescape(SpecificTest, - sizeof(SpecificTest), - unescaped, - sizeof(unescaped)); + size_t size = Base64Unescape(SpecificTest, sizeof(SpecificTest), unescaped, + sizeof(unescaped)); EXPECT_EQ(size, sizeof(testbase64)); EXPECT_EQ(0, memcmp(testbase64, unescaped, sizeof(testbase64))); } -bool DecodeTest(const char* encoded, size_t expect_unparsed, - const char* decoded, Base64::DecodeFlags flags) -{ +bool DecodeTest(const char* encoded, + size_t expect_unparsed, + const char* decoded, + Base64::DecodeFlags flags) { std::string result; size_t consumed = 0, encoded_len = strlen(encoded); - bool success = Base64::DecodeFromArray(encoded, encoded_len, flags, - &result, &consumed); + bool success = + Base64::DecodeFromArray(encoded, encoded_len, flags, &result, &consumed); size_t unparsed = encoded_len - consumed; - EXPECT_EQ(expect_unparsed, unparsed) << "\"" << encoded - << "\" -> \"" << decoded - << "\""; + EXPECT_EQ(expect_unparsed, unparsed) + << "\"" << encoded << "\" -> \"" << decoded << "\""; EXPECT_STREQ(decoded, result.c_str()); return success; } -#define Flags(x,y,z) \ +#define Flags(x, y, z) \ Base64::DO_PARSE_##x | Base64::DO_PAD_##y | Base64::DO_TERM_##z TEST(Base64, DecodeParseOptions) { // Trailing whitespace - EXPECT_TRUE (DecodeTest("YWJjZA== ", 1, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA== ", 0, "abcd", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA== ", 0, "abcd", Flags(ANY, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA== ", 1, "abcd", Flags(STRICT, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA== ", 0, "abcd", Flags(WHITE, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA== ", 0, "abcd", Flags(ANY, YES, CHAR))); // Embedded whitespace EXPECT_FALSE(DecodeTest("YWJjZA= =", 3, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA= =", 0, "abcd", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA= =", 0, "abcd", Flags(ANY, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA= =", 0, "abcd", Flags(WHITE, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA= =", 0, "abcd", Flags(ANY, YES, CHAR))); // Embedded non-base64 characters EXPECT_FALSE(DecodeTest("YWJjZA=*=", 3, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_FALSE(DecodeTest("YWJjZA=*=", 3, "abcd", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA=*=", 0, "abcd", Flags(ANY, YES, CHAR))); + EXPECT_FALSE(DecodeTest("YWJjZA=*=", 3, "abcd", Flags(WHITE, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA=*=", 0, "abcd", Flags(ANY, YES, CHAR))); // Unexpected padding characters - EXPECT_FALSE(DecodeTest("YW=JjZA==", 7, "a", Flags(STRICT, YES, CHAR))); - EXPECT_FALSE(DecodeTest("YW=JjZA==", 7, "a", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YW=JjZA==", 0, "abcd", Flags(ANY, YES, CHAR))); + EXPECT_FALSE(DecodeTest("YW=JjZA==", 7, "a", Flags(STRICT, YES, CHAR))); + EXPECT_FALSE(DecodeTest("YW=JjZA==", 7, "a", Flags(WHITE, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YW=JjZA==", 0, "abcd", Flags(ANY, YES, CHAR))); } TEST(Base64, DecodePadOptions) { // Padding - EXPECT_TRUE (DecodeTest("YWJjZA==", 0, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA==", 0, "abcd", Flags(STRICT, ANY, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA==", 2, "abcd", Flags(STRICT, NO, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA==", 0, "abcd", Flags(STRICT, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA==", 0, "abcd", Flags(STRICT, ANY, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA==", 2, "abcd", Flags(STRICT, NO, CHAR))); // Incomplete padding - EXPECT_FALSE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, ANY, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, NO, CHAR))); + EXPECT_FALSE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, ANY, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, NO, CHAR))); // No padding - EXPECT_FALSE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, ANY, CHAR))); - EXPECT_TRUE (DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, NO, CHAR))); + EXPECT_FALSE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, YES, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, ANY, CHAR))); + EXPECT_TRUE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, NO, CHAR))); } TEST(Base64, DecodeTerminateOptions) { // Complete quantum - EXPECT_TRUE (DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, BUFFER))); - EXPECT_TRUE (DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, CHAR))); - EXPECT_TRUE (DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, ANY))); + EXPECT_TRUE(DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, BUFFER))); + EXPECT_TRUE(DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, CHAR))); + EXPECT_TRUE(DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, ANY))); // Complete quantum with trailing data - EXPECT_FALSE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, BUFFER))); - EXPECT_TRUE (DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, CHAR))); - EXPECT_TRUE (DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, ANY))); + EXPECT_FALSE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, BUFFER))); + EXPECT_TRUE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, CHAR))); + EXPECT_TRUE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, ANY))); // Incomplete quantum - EXPECT_FALSE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, BUFFER))); - EXPECT_FALSE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, CHAR))); - EXPECT_TRUE (DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, ANY))); + EXPECT_FALSE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, BUFFER))); + EXPECT_FALSE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, CHAR))); + EXPECT_TRUE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, ANY))); } TEST(Base64, GetNextBase64Char) { diff --git a/rtc_base/bind.h b/rtc_base/bind.h index b9f98b9dfe..9f225f1cae 100644 --- a/rtc_base/bind.h +++ b/rtc_base/bind.h @@ -77,7 +77,10 @@ namespace detail { // matches to the function prototype, but the parameters to bind have // references stripped. This trick allows the compiler to dictate the Bind // parameter types rather than deduce them. -template struct identity { typedef T type; }; +template +struct identity { + typedef T type; +}; // IsRefCounted::value will be true for types that can be used in // rtc::scoped_refptr, i.e. types that implements nullary functions AddRef() @@ -88,8 +91,12 @@ class IsRefCounted { // This is a complex implementation detail done with SFINAE. // Define types such that sizeof(Yes) != sizeof(No). - struct Yes { char dummy[1]; }; - struct No { char dummy[2]; }; + struct Yes { + char dummy[1]; + }; + struct No { + char dummy[2]; + }; // Define two overloaded template functions with return types of different // size. This way, we can use sizeof() on the return type to determine which // function the compiler would have chosen. One function will be preferred @@ -98,9 +105,10 @@ class IsRefCounted { // preferred function. template static Yes test(R* r, decltype(r->AddRef(), r->Release(), 42)); - template static No test(...); + template + static No test(...); -public: + public: // Trick the compiler to tell if it's possible to call AddRef() and Release(). static const bool value = sizeof(test((T*)nullptr, 42)) == sizeof(Yes); }; diff --git a/rtc_base/bind_unittest.cc b/rtc_base/bind_unittest.cc index 8703be4adf..ed0913fdd3 100644 --- a/rtc_base/bind_unittest.cc +++ b/rtc_base/bind_unittest.cc @@ -24,10 +24,20 @@ struct LifeTimeCheck; struct MethodBindTester { void NullaryVoid() { ++call_count; } - int NullaryInt() { ++call_count; return 1; } - int NullaryConst() const { ++call_count; return 2; } + int NullaryInt() { + ++call_count; + return 1; + } + int NullaryConst() const { + ++call_count; + return 2; + } void UnaryVoid(int dummy) { ++call_count; } - template T Identity(T value) { ++call_count; return value; } + template + T Identity(T value) { + ++call_count; + return value; + } int UnaryByPointer(int* value) const { ++call_count; return ++(*value); @@ -36,7 +46,10 @@ struct MethodBindTester { ++call_count; return ++const_cast(value); } - int Multiply(int a, int b) const { ++call_count; return a * b; } + int Multiply(int a, int b) const { + ++call_count; + return a * b; + } void RefArgument(const scoped_refptr& object) { EXPECT_TRUE(object.get() != nullptr); } @@ -44,13 +57,17 @@ struct MethodBindTester { mutable int call_count; }; -struct A { int dummy; }; -struct B: public RefCountInterface { int dummy; }; -struct C: public A, B {}; +struct A { + int dummy; +}; +struct B : public RefCountInterface { + int dummy; +}; +struct C : public A, B {}; struct D { int AddRef(); }; -struct E: public D { +struct E : public D { int Release(); }; struct F { @@ -66,9 +83,15 @@ struct LifeTimeCheck { int ref_count_; }; -int Return42() { return 42; } -int Negate(int a) { return -a; } -int Multiply(int a, int b) { return a * b; } +int Return42() { + return 42; +} +int Negate(int a) { + return -a; +} +int Multiply(int a, int b) { + return a * b; +} } // namespace @@ -76,7 +99,8 @@ int Multiply(int a, int b) { return a * b; } // compile time. #define EXPECT_IS_CAPTURED_AS_PTR(T) \ static_assert(is_same::type, T*>::value, \ - "PointerType") + "PointerTyp" \ + "e") #define EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(T) \ static_assert( \ is_same::type, scoped_refptr>::value, \ @@ -206,7 +230,9 @@ TEST(BindTest, ScopedRefPointerArgument) { namespace { -const int* Ref(const int& a) { return &a; } +const int* Ref(const int& a) { + return &a; +} } // anonymous namespace diff --git a/rtc_base/bitbuffer.cc b/rtc_base/bitbuffer.cc index 86247af697..025cfe1516 100644 --- a/rtc_base/bitbuffer.cc +++ b/rtc_base/bitbuffer.cc @@ -200,8 +200,8 @@ bool BitBuffer::ReadSignedExponentialGolomb(int32_t* val) { return true; } -void BitBuffer::GetCurrentOffset( - size_t* out_byte_offset, size_t* out_bit_offset) { +void BitBuffer::GetCurrentOffset(size_t* out_byte_offset, + size_t* out_bit_offset) { RTC_CHECK(out_byte_offset != nullptr); RTC_CHECK(out_bit_offset != nullptr); *out_byte_offset = byte_offset_; @@ -219,8 +219,7 @@ bool BitBuffer::Seek(size_t byte_offset, size_t bit_offset) { } BitBufferWriter::BitBufferWriter(uint8_t* bytes, size_t byte_count) - : BitBuffer(bytes, byte_count), writable_bytes_(bytes) { -} + : BitBuffer(bytes, byte_count), writable_bytes_(bytes) {} bool BitBufferWriter::WriteUInt8(uint8_t val) { return WriteBits(val, sizeof(uint8_t) * 8); @@ -251,8 +250,8 @@ bool BitBufferWriter::WriteBits(uint64_t val, size_t bit_count) { size_t remaining_bits_in_current_byte = 8 - bit_offset_; size_t bits_in_first_byte = std::min(bit_count, remaining_bits_in_current_byte); - *bytes = WritePartialByte( - HighestByte(val), bits_in_first_byte, *bytes, bit_offset_); + *bytes = WritePartialByte(HighestByte(val), bits_in_first_byte, *bytes, + bit_offset_); if (bit_count <= remaining_bits_in_current_byte) { // Nothing left to write, so quit early. return ConsumeBits(total_bits); diff --git a/rtc_base/bitbuffer.h b/rtc_base/bitbuffer.h index 8519414807..146577a15a 100644 --- a/rtc_base/bitbuffer.h +++ b/rtc_base/bitbuffer.h @@ -11,8 +11,8 @@ #ifndef RTC_BASE_BITBUFFER_H_ #define RTC_BASE_BITBUFFER_H_ -#include // For integer types. #include // For size_t. +#include // For integer types. #include "rtc_base/constructormagic.h" diff --git a/rtc_base/bitbuffer_unittest.cc b/rtc_base/bitbuffer_unittest.cc index abf723250a..a3f140f499 100644 --- a/rtc_base/bitbuffer_unittest.cc +++ b/rtc_base/bitbuffer_unittest.cc @@ -165,8 +165,8 @@ TEST(BitBufferTest, SetOffsetValues) { EXPECT_EQ(0u, bit_offset); EXPECT_FALSE(buffer.Seek(4, 1)); - // Disable death test on Android because it relies on fork() and doesn't play - // nicely. +// Disable death test on Android because it relies on fork() and doesn't play +// nicely. #if GTEST_HAS_DEATH_TEST #if !defined(WEBRTC_ANDROID) // Passing a null out parameter is death. diff --git a/rtc_base/buffer_unittest.cc b/rtc_base/buffer_unittest.cc index e3b7d460b0..ae976f1394 100644 --- a/rtc_base/buffer_unittest.cc +++ b/rtc_base/buffer_unittest.cc @@ -208,16 +208,16 @@ TEST(BufferTest, TestClear) { EXPECT_EQ(buf.size(), 15u); EXPECT_EQ(buf.capacity(), 15u); EXPECT_FALSE(buf.empty()); - const char *data = buf.data(); + const char* data = buf.data(); buf.Clear(); EXPECT_EQ(buf.size(), 0u); - EXPECT_EQ(buf.capacity(), 15u); // Hasn't shrunk. - EXPECT_EQ(buf.data(), data); // No reallocation. + EXPECT_EQ(buf.capacity(), 15u); // Hasn't shrunk. + EXPECT_EQ(buf.data(), data); // No reallocation. EXPECT_TRUE(buf.empty()); } TEST(BufferTest, TestLambdaSetAppend) { - auto setter = [] (rtc::ArrayView av) { + auto setter = [](rtc::ArrayView av) { for (int i = 0; i != 15; ++i) av[i] = kTestData[i]; return 15; @@ -237,7 +237,7 @@ TEST(BufferTest, TestLambdaSetAppend) { } TEST(BufferTest, TestLambdaSetAppendSigned) { - auto setter = [] (rtc::ArrayView av) { + auto setter = [](rtc::ArrayView av) { for (int i = 0; i != 15; ++i) av[i] = kTestData[i]; return 15; @@ -257,7 +257,7 @@ TEST(BufferTest, TestLambdaSetAppendSigned) { } TEST(BufferTest, TestLambdaAppendEmpty) { - auto setter = [] (rtc::ArrayView av) { + auto setter = [](rtc::ArrayView av) { for (int i = 0; i != 15; ++i) av[i] = kTestData[i]; return 15; @@ -275,7 +275,7 @@ TEST(BufferTest, TestLambdaAppendEmpty) { } TEST(BufferTest, TestLambdaAppendPartial) { - auto setter = [] (rtc::ArrayView av) { + auto setter = [](rtc::ArrayView av) { for (int i = 0; i != 7; ++i) av[i] = kTestData[i]; return 7; @@ -283,15 +283,15 @@ TEST(BufferTest, TestLambdaAppendPartial) { Buffer buf; EXPECT_EQ(buf.AppendData(15, setter), 7u); - EXPECT_EQ(buf.size(), 7u); // Size is exactly what we wrote. - EXPECT_GE(buf.capacity(), 7u); // Capacity is valid. - EXPECT_NE(buf.data(), nullptr); // Data is actually stored. + EXPECT_EQ(buf.size(), 7u); // Size is exactly what we wrote. + EXPECT_GE(buf.capacity(), 7u); // Capacity is valid. + EXPECT_NE(buf.data(), nullptr); // Data is actually stored. EXPECT_FALSE(buf.empty()); } TEST(BufferTest, TestMutableLambdaSetAppend) { uint8_t magic_number = 17; - auto setter = [magic_number] (rtc::ArrayView av) mutable { + auto setter = [magic_number](rtc::ArrayView av) mutable { for (int i = 0; i != 15; ++i) { av[i] = magic_number; ++magic_number; @@ -304,9 +304,9 @@ TEST(BufferTest, TestMutableLambdaSetAppend) { Buffer buf; EXPECT_EQ(buf.SetData(15, setter), 15u); EXPECT_EQ(buf.AppendData(15, setter), 15u); - EXPECT_EQ(buf.size(), 30u); // Size is exactly what we wrote. - EXPECT_GE(buf.capacity(), 30u); // Capacity is valid. - EXPECT_NE(buf.data(), nullptr); // Data is actually stored. + EXPECT_EQ(buf.size(), 30u); // Size is exactly what we wrote. + EXPECT_GE(buf.capacity(), 30u); // Capacity is valid. + EXPECT_NE(buf.data(), nullptr); // Data is actually stored. EXPECT_FALSE(buf.empty()); for (uint8_t i = 0; i != buf.size(); ++i) { diff --git a/rtc_base/bufferqueue.cc b/rtc_base/bufferqueue.cc index 3b082a5d25..48ff2e6d31 100644 --- a/rtc_base/bufferqueue.cc +++ b/rtc_base/bufferqueue.cc @@ -15,8 +15,7 @@ namespace rtc { BufferQueue::BufferQueue(size_t capacity, size_t default_size) - : capacity_(capacity), default_size_(default_size) { -} + : capacity_(capacity), default_size_(default_size) {} BufferQueue::~BufferQueue() { CritScope cs(&crit_); @@ -64,7 +63,8 @@ bool BufferQueue::ReadFront(void* buffer, size_t bytes, size_t* bytes_read) { return true; } -bool BufferQueue::WriteBack(const void* buffer, size_t bytes, +bool BufferQueue::WriteBack(const void* buffer, + size_t bytes, size_t* bytes_written) { CritScope cs(&crit_); if (queue_.size() == capacity_) { diff --git a/rtc_base/bytebuffer.cc b/rtc_base/bytebuffer.cc index b2d75182a4..94fc6acf08 100644 --- a/rtc_base/bytebuffer.cc +++ b/rtc_base/bytebuffer.cc @@ -34,7 +34,8 @@ ByteBufferReader::ByteBufferReader(const char* bytes, size_t len) Construct(bytes, len); } -ByteBufferReader::ByteBufferReader(const char* bytes, size_t len, +ByteBufferReader::ByteBufferReader(const char* bytes, + size_t len, ByteOrder byte_order) : ByteBuffer(byte_order) { Construct(bytes, len); @@ -63,13 +64,15 @@ void ByteBufferReader::Construct(const char* bytes, size_t len) { } bool ByteBufferReader::ReadUInt8(uint8_t* val) { - if (!val) return false; + if (!val) + return false; return ReadBytes(reinterpret_cast(val), 1); } bool ByteBufferReader::ReadUInt16(uint16_t* val) { - if (!val) return false; + if (!val) + return false; uint16_t v; if (!ReadBytes(reinterpret_cast(&v), 2)) { @@ -81,7 +84,8 @@ bool ByteBufferReader::ReadUInt16(uint16_t* val) { } bool ByteBufferReader::ReadUInt24(uint32_t* val) { - if (!val) return false; + if (!val) + return false; uint32_t v = 0; char* read_into = reinterpret_cast(&v); @@ -98,7 +102,8 @@ bool ByteBufferReader::ReadUInt24(uint32_t* val) { } bool ByteBufferReader::ReadUInt32(uint32_t* val) { - if (!val) return false; + if (!val) + return false; uint32_t v; if (!ReadBytes(reinterpret_cast(&v), 4)) { @@ -110,7 +115,8 @@ bool ByteBufferReader::ReadUInt32(uint32_t* val) { } bool ByteBufferReader::ReadUInt64(uint64_t* val) { - if (!val) return false; + if (!val) + return false; uint64_t v; if (!ReadBytes(reinterpret_cast(&v), 8)) { @@ -145,7 +151,8 @@ bool ByteBufferReader::ReadUVarint(uint64_t* val) { } bool ByteBufferReader::ReadString(std::string* val, size_t len) { - if (!val) return false; + if (!val) + return false; if (len > Length()) { return false; diff --git a/rtc_base/bytebuffer_unittest.cc b/rtc_base/bytebuffer_unittest.cc index 6140e9fbfc..718f35c8d8 100644 --- a/rtc_base/bytebuffer_unittest.cc +++ b/rtc_base/bytebuffer_unittest.cc @@ -79,8 +79,8 @@ TEST(ByteBufferTest, TestBufferLength) { } TEST(ByteBufferTest, TestReadWriteBuffer) { - ByteBufferWriter::ByteOrder orders[2] = { ByteBufferWriter::ORDER_HOST, - ByteBufferWriter::ORDER_NETWORK }; + ByteBufferWriter::ByteOrder orders[2] = {ByteBufferWriter::ORDER_HOST, + ByteBufferWriter::ORDER_NETWORK}; for (size_t i = 0; i < arraysize(orders); i++) { ByteBufferWriter buffer(orders[i]); EXPECT_EQ(orders[i], buffer.Order()); diff --git a/rtc_base/byteorder_unittest.cc b/rtc_base/byteorder_unittest.cc index 30dc5faaf8..75509de9c2 100644 --- a/rtc_base/byteorder_unittest.cc +++ b/rtc_base/byteorder_unittest.cc @@ -80,4 +80,3 @@ TEST(ByteOrderTest, TestGet) { } } // namespace rtc - diff --git a/rtc_base/callback.h b/rtc_base/callback.h index 0e035ad6a0..65b7c9cdf3 100644 --- a/rtc_base/callback.h +++ b/rtc_base/callback.h @@ -73,8 +73,9 @@ class Callback0 { public: // Default copy operations are appropriate for this class. Callback0() {} - template Callback0(const T& functor) - : helper_(new RefCountedObject< HelperImpl >(functor)) {} + template + Callback0(const T& functor) + : helper_(new RefCountedObject >(functor)) {} R operator()() { if (empty()) return R(); @@ -87,24 +88,23 @@ class Callback0 { virtual ~Helper() {} virtual R Run() = 0; }; - template struct HelperImpl : Helper { + template + struct HelperImpl : Helper { explicit HelperImpl(const T& functor) : functor_(functor) {} - virtual R Run() { - return functor_(); - } + virtual R Run() { return functor_(); } T functor_; }; scoped_refptr helper_; }; -template +template class Callback1 { public: // Default copy operations are appropriate for this class. Callback1() {} - template Callback1(const T& functor) - : helper_(new RefCountedObject< HelperImpl >(functor)) {} + template + Callback1(const T& functor) + : helper_(new RefCountedObject >(functor)) {} R operator()(P1 p1) { if (empty()) return R(); @@ -117,25 +117,23 @@ class Callback1 { virtual ~Helper() {} virtual R Run(P1 p1) = 0; }; - template struct HelperImpl : Helper { + template + struct HelperImpl : Helper { explicit HelperImpl(const T& functor) : functor_(functor) {} - virtual R Run(P1 p1) { - return functor_(p1); - } + virtual R Run(P1 p1) { return functor_(p1); } T functor_; }; scoped_refptr helper_; }; -template +template class Callback2 { public: // Default copy operations are appropriate for this class. Callback2() {} - template Callback2(const T& functor) - : helper_(new RefCountedObject< HelperImpl >(functor)) {} + template + Callback2(const T& functor) + : helper_(new RefCountedObject >(functor)) {} R operator()(P1 p1, P2 p2) { if (empty()) return R(); @@ -148,26 +146,23 @@ class Callback2 { virtual ~Helper() {} virtual R Run(P1 p1, P2 p2) = 0; }; - template struct HelperImpl : Helper { + template + struct HelperImpl : Helper { explicit HelperImpl(const T& functor) : functor_(functor) {} - virtual R Run(P1 p1, P2 p2) { - return functor_(p1, p2); - } + virtual R Run(P1 p1, P2 p2) { return functor_(p1, p2); } T functor_; }; scoped_refptr helper_; }; -template +template class Callback3 { public: // Default copy operations are appropriate for this class. Callback3() {} - template Callback3(const T& functor) - : helper_(new RefCountedObject< HelperImpl >(functor)) {} + template + Callback3(const T& functor) + : helper_(new RefCountedObject >(functor)) {} R operator()(P1 p1, P2 p2, P3 p3) { if (empty()) return R(); @@ -180,27 +175,23 @@ class Callback3 { virtual ~Helper() {} virtual R Run(P1 p1, P2 p2, P3 p3) = 0; }; - template struct HelperImpl : Helper { + template + struct HelperImpl : Helper { explicit HelperImpl(const T& functor) : functor_(functor) {} - virtual R Run(P1 p1, P2 p2, P3 p3) { - return functor_(p1, p2, p3); - } + virtual R Run(P1 p1, P2 p2, P3 p3) { return functor_(p1, p2, p3); } T functor_; }; scoped_refptr helper_; }; -template +template class Callback4 { public: // Default copy operations are appropriate for this class. Callback4() {} - template Callback4(const T& functor) - : helper_(new RefCountedObject< HelperImpl >(functor)) {} + template + Callback4(const T& functor) + : helper_(new RefCountedObject >(functor)) {} R operator()(P1 p1, P2 p2, P3 p3, P4 p4) { if (empty()) return R(); @@ -213,7 +204,8 @@ class Callback4 { virtual ~Helper() {} virtual R Run(P1 p1, P2 p2, P3 p3, P4 p4) = 0; }; - template struct HelperImpl : Helper { + template + struct HelperImpl : Helper { explicit HelperImpl(const T& functor) : functor_(functor) {} virtual R Run(P1 p1, P2 p2, P3 p3, P4 p4) { return functor_(p1, p2, p3, p4); @@ -223,18 +215,14 @@ class Callback4 { scoped_refptr helper_; }; -template +template class Callback5 { public: // Default copy operations are appropriate for this class. Callback5() {} - template Callback5(const T& functor) - : helper_(new RefCountedObject< HelperImpl >(functor)) {} + template + Callback5(const T& functor) + : helper_(new RefCountedObject >(functor)) {} R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { if (empty()) return R(); @@ -247,7 +235,8 @@ class Callback5 { virtual ~Helper() {} virtual R Run(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) = 0; }; - template struct HelperImpl : Helper { + template + struct HelperImpl : Helper { explicit HelperImpl(const T& functor) : functor_(functor) {} virtual R Run(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { return functor_(p1, p2, p3, p4, p5); diff --git a/rtc_base/callback_unittest.cc b/rtc_base/callback_unittest.cc index 26bfd5daf4..ae86a4cd06 100644 --- a/rtc_base/callback_unittest.cc +++ b/rtc_base/callback_unittest.cc @@ -19,9 +19,15 @@ namespace rtc { namespace { void f() {} -int g() { return 42; } -int h(int x) { return x * x; } -void i(int& x) { x *= x; } // NOLINT: Testing refs +int g() { + return 42; +} +int h(int x) { + return x * x; +} +void i(int& x) { + x *= x; +} // NOLINT: Testing refs struct BindTester { int a() { return 24; } diff --git a/rtc_base/compile_assert_c.h b/rtc_base/compile_assert_c.h index c83d31495d..db2e4a8116 100644 --- a/rtc_base/compile_assert_c.h +++ b/rtc_base/compile_assert_c.h @@ -16,6 +16,10 @@ // Example: // RTC_COMPILE_ASSERT(sizeof(foo) < 128); // Note: In C++, use static_assert instead! -#define RTC_COMPILE_ASSERT(expression) switch (0) {case 0: case expression:;} +#define RTC_COMPILE_ASSERT(expression) \ + switch (0) { \ + case 0: \ + case expression:; \ + } #endif // RTC_BASE_COMPILE_ASSERT_C_H_ diff --git a/rtc_base/constructormagic.h b/rtc_base/constructormagic.h index 8a953aac56..646a058ce3 100644 --- a/rtc_base/constructormagic.h +++ b/rtc_base/constructormagic.h @@ -12,8 +12,7 @@ #define RTC_BASE_CONSTRUCTORMAGIC_H_ // Put this in the declarations for a class to be unassignable. -#define RTC_DISALLOW_ASSIGN(TypeName) \ - void operator=(const TypeName&) = delete +#define RTC_DISALLOW_ASSIGN(TypeName) void operator=(const TypeName&) = delete // A macro to disallow the copy constructor and operator= functions. This should // be used in the declarations for a class. diff --git a/rtc_base/copyonwritebuffer.cc b/rtc_base/copyonwritebuffer.cc index 579dd460ba..8874ea9187 100644 --- a/rtc_base/copyonwritebuffer.cc +++ b/rtc_base/copyonwritebuffer.cc @@ -17,12 +17,10 @@ CopyOnWriteBuffer::CopyOnWriteBuffer() { } CopyOnWriteBuffer::CopyOnWriteBuffer(const CopyOnWriteBuffer& buf) - : buffer_(buf.buffer_) { -} + : buffer_(buf.buffer_) {} CopyOnWriteBuffer::CopyOnWriteBuffer(CopyOnWriteBuffer&& buf) - : buffer_(std::move(buf.buffer_)) { -} + : buffer_(std::move(buf.buffer_)) {} CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size) : buffer_(size > 0 ? new RefCountedObject(size) : nullptr) { @@ -31,8 +29,8 @@ CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size) CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size, size_t capacity) : buffer_(size > 0 || capacity > 0 - ? new RefCountedObject(size, capacity) - : nullptr) { + ? new RefCountedObject(size, capacity) + : nullptr) { RTC_DCHECK(IsConsistent()); } @@ -43,8 +41,8 @@ bool CopyOnWriteBuffer::operator==(const CopyOnWriteBuffer& buf) const { RTC_DCHECK(IsConsistent()); RTC_DCHECK(buf.IsConsistent()); return buffer_.get() == buf.buffer_.get() || - (buffer_.get() && buf.buffer_.get() && - *buffer_.get() == *buf.buffer_.get()); + (buffer_.get() && buf.buffer_.get() && + *buffer_.get() == *buf.buffer_.get()); } void CopyOnWriteBuffer::SetSize(size_t size) { @@ -59,10 +57,9 @@ void CopyOnWriteBuffer::SetSize(size_t size) { // Clone data if referenced. if (!buffer_->HasOneRef()) { - buffer_ = new RefCountedObject( - buffer_->data(), - std::min(buffer_->size(), size), - std::max(buffer_->capacity(), size)); + buffer_ = new RefCountedObject(buffer_->data(), + std::min(buffer_->size(), size), + std::max(buffer_->capacity(), size)); } buffer_->SetSize(size); RTC_DCHECK(IsConsistent()); @@ -103,10 +100,8 @@ void CopyOnWriteBuffer::CloneDataIfReferenced(size_t new_capacity) { } buffer_ = new RefCountedObject(buffer_->data(), buffer_->size(), - new_capacity); + new_capacity); RTC_DCHECK(IsConsistent()); } - - } // namespace rtc diff --git a/rtc_base/copyonwritebuffer.h b/rtc_base/copyonwritebuffer.h index c4bba874ad..467baad878 100644 --- a/rtc_base/copyonwritebuffer.h +++ b/rtc_base/copyonwritebuffer.h @@ -185,8 +185,8 @@ class CopyOnWriteBuffer { return; } - CloneDataIfReferenced(std::max(buffer_->capacity(), - buffer_->size() + size)); + CloneDataIfReferenced( + std::max(buffer_->capacity(), buffer_->size() + size)); buffer_->AppendData(data, size); RTC_DCHECK(IsConsistent()); } @@ -229,9 +229,7 @@ class CopyOnWriteBuffer { void CloneDataIfReferenced(size_t new_capacity); // Pre- and postcondition of all methods. - bool IsConsistent() const { - return (!buffer_ || buffer_->capacity() > 0); - } + bool IsConsistent() const { return (!buffer_ || buffer_->capacity() > 0); } // buffer_ is either null, or points to an rtc::Buffer with capacity > 0. scoped_refptr> buffer_; diff --git a/rtc_base/cpu_time.cc b/rtc_base/cpu_time.cc index 6c228804d9..f25b50662e 100644 --- a/rtc_base/cpu_time.cc +++ b/rtc_base/cpu_time.cc @@ -15,12 +15,12 @@ #if defined(WEBRTC_LINUX) #include #elif defined(WEBRTC_MAC) -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include #elif defined(WEBRTC_WIN) #include diff --git a/rtc_base/cpu_time_unittest.cc b/rtc_base/cpu_time_unittest.cc index ba973788ab..f4730690dc 100644 --- a/rtc_base/cpu_time_unittest.cc +++ b/rtc_base/cpu_time_unittest.cc @@ -86,10 +86,10 @@ TEST(CpuTimeTest, MAYBE_TEST(TwoThreads)) { kAllowedErrorMillisecs * kNumNanosecsPerMillisec); // Total process time is at least twice working threads' CPU time. // Therefore process and thread times are correctly related. - EXPECT_GE( - process_duration_nanos, - kWorkingThreads * (kProcessingTimeMillisecs - kAllowedErrorMillisecs) - * kNumNanosecsPerMillisec); + EXPECT_GE(process_duration_nanos, + kWorkingThreads * + (kProcessingTimeMillisecs - kAllowedErrorMillisecs) * + kNumNanosecsPerMillisec); } TEST(CpuTimeTest, MAYBE_TEST(Sleeping)) { diff --git a/rtc_base/crc32.cc b/rtc_base/crc32.cc index c214f38cc7..c70f5fef71 100644 --- a/rtc_base/crc32.cc +++ b/rtc_base/crc32.cc @@ -49,4 +49,3 @@ uint32_t UpdateCrc32(uint32_t start, const void* buf, size_t len) { } } // namespace rtc - diff --git a/rtc_base/crc32_unittest.cc b/rtc_base/crc32_unittest.cc index 576b424bd0..752bc9fff5 100644 --- a/rtc_base/crc32_unittest.cc +++ b/rtc_base/crc32_unittest.cc @@ -18,7 +18,8 @@ namespace rtc { TEST(Crc32Test, TestBasic) { EXPECT_EQ(0U, ComputeCrc32("")); EXPECT_EQ(0x352441C2U, ComputeCrc32("abc")); - EXPECT_EQ(0x171A3F5FU, + EXPECT_EQ( + 0x171A3F5FU, ComputeCrc32("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); } diff --git a/rtc_base/criticalsection.cc b/rtc_base/criticalsection.cc index b2bbd03e02..c786a40b19 100644 --- a/rtc_base/criticalsection.cc +++ b/rtc_base/criticalsection.cc @@ -22,24 +22,24 @@ CriticalSection::CriticalSection() { #if defined(WEBRTC_WIN) InitializeCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -# if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC lock_queue_ = 0; owning_thread_ = 0; recursion_ = 0; semaphore_ = dispatch_semaphore_create(0); -# else +#else pthread_mutexattr_t mutex_attribute; pthread_mutexattr_init(&mutex_attribute); pthread_mutexattr_settype(&mutex_attribute, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&mutex_, &mutex_attribute); pthread_mutexattr_destroy(&mutex_attribute); -# endif +#endif CS_DEBUG_CODE(thread_ = 0); CS_DEBUG_CODE(recursion_count_ = 0); RTC_UNUSED(thread_); RTC_UNUSED(recursion_count_); #else -# error Unsupported platform. +#error Unsupported platform. #endif } @@ -47,13 +47,13 @@ CriticalSection::~CriticalSection() { #if defined(WEBRTC_WIN) DeleteCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -# if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC dispatch_release(semaphore_); -# else - pthread_mutex_destroy(&mutex_); -# endif #else -# error Unsupported platform. + pthread_mutex_destroy(&mutex_); +#endif +#else +#error Unsupported platform. #endif } @@ -61,7 +61,7 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { #if defined(WEBRTC_WIN) EnterCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -# if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC int spin = 3000; PlatformThreadRef self = CurrentThreadRef(); bool have_lock = false; @@ -98,11 +98,11 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { owning_thread_ = self; ++recursion_; -# else +#else pthread_mutex_lock(&mutex_); -# endif +#endif -# if CS_DEBUG_CHECKS +#if CS_DEBUG_CHECKS if (!recursion_count_) { RTC_DCHECK(!thread_); thread_ = CurrentThreadRef(); @@ -110,9 +110,9 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { RTC_DCHECK(CurrentThreadIsOwner()); } ++recursion_count_; -# endif +#endif #else -# error Unsupported platform. +#error Unsupported platform. #endif } @@ -120,7 +120,7 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { #if defined(WEBRTC_WIN) return TryEnterCriticalSection(&crit_) != FALSE; #elif defined(WEBRTC_POSIX) -# if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC if (!IsThreadRefEqual(owning_thread_, CurrentThreadRef())) { if (AtomicOps::CompareAndSwap(&lock_queue_, 0, 1) != 0) return false; @@ -130,11 +130,11 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { AtomicOps::Increment(&lock_queue_); } ++recursion_; -# else +#else if (pthread_mutex_trylock(&mutex_) != 0) return false; -# endif -# if CS_DEBUG_CHECKS +#endif +#if CS_DEBUG_CHECKS if (!recursion_count_) { RTC_DCHECK(!thread_); thread_ = CurrentThreadRef(); @@ -142,10 +142,10 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { RTC_DCHECK(CurrentThreadIsOwner()); } ++recursion_count_; -# endif +#endif return true; #else -# error Unsupported platform. +#error Unsupported platform. #endif } @@ -154,13 +154,13 @@ void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() { #if defined(WEBRTC_WIN) LeaveCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -# if CS_DEBUG_CHECKS +#if CS_DEBUG_CHECKS --recursion_count_; RTC_DCHECK(recursion_count_ >= 0); if (!recursion_count_) thread_ = 0; -# endif -# if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#endif +#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC RTC_DCHECK(IsThreadRefEqual(owning_thread_, CurrentThreadRef())); RTC_DCHECK_GE(recursion_, 0); --recursion_; @@ -169,11 +169,11 @@ void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() { if (AtomicOps::Decrement(&lock_queue_) > 0 && !recursion_) dispatch_semaphore_signal(semaphore_); -# else - pthread_mutex_unlock(&mutex_); -# endif #else -# error Unsupported platform. + pthread_mutex_unlock(&mutex_); +#endif +#else +#error Unsupported platform. #endif } @@ -186,18 +186,22 @@ bool CriticalSection::CurrentThreadIsOwner() const { return crit_.OwningThread == reinterpret_cast(static_cast(GetCurrentThreadId())); #elif defined(WEBRTC_POSIX) -# if CS_DEBUG_CHECKS +#if CS_DEBUG_CHECKS return IsThreadRefEqual(thread_, CurrentThreadRef()); -# else - return true; -# endif // CS_DEBUG_CHECKS #else -# error Unsupported platform. + return true; +#endif // CS_DEBUG_CHECKS +#else +#error Unsupported platform. #endif } -CritScope::CritScope(const CriticalSection* cs) : cs_(cs) { cs_->Enter(); } -CritScope::~CritScope() { cs_->Leave(); } +CritScope::CritScope(const CriticalSection* cs) : cs_(cs) { + cs_->Enter(); +} +CritScope::~CritScope() { + cs_->Leave(); +} TryCritScope::TryCritScope(const CriticalSection* cs) : cs_(cs), locked_(cs->TryEnter()) { @@ -241,8 +245,7 @@ GlobalLock::GlobalLock() { lock_acquired = 0; } -GlobalLockScope::GlobalLockScope(GlobalLockPod* lock) - : lock_(lock) { +GlobalLockScope::GlobalLockScope(GlobalLockPod* lock) : lock_(lock) { lock_->Lock(); } diff --git a/rtc_base/criticalsection.h b/rtc_base/criticalsection.h index 6abdbe57a6..ce6fca13aa 100644 --- a/rtc_base/criticalsection.h +++ b/rtc_base/criticalsection.h @@ -18,12 +18,16 @@ #include "typedefs.h" // NOLINT(build/include) #if defined(WEBRTC_WIN) +// clang-format off +// clang formating would change include order. + // Include winsock2.h before including to maintain consistency with // win32.h. To include win32.h directly, it must be broken out into its own // build target. #include #include #include // must come after windows headers. +// clang-format on #endif // defined(WEBRTC_WIN) #if defined(WEBRTC_POSIX) @@ -66,7 +70,7 @@ class RTC_LOCKABLE CriticalSection { #if defined(WEBRTC_WIN) mutable CRITICAL_SECTION crit_; #elif defined(WEBRTC_POSIX) -# if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC // Number of times the lock has been locked + number of threads waiting. // TODO(tommi): We could use this number and subtract the recursion count // to find places where we have multiple threads contending on the same lock. @@ -78,13 +82,13 @@ class RTC_LOCKABLE CriticalSection { mutable dispatch_semaphore_t semaphore_; // The thread that currently holds the lock. Required to handle recursion. mutable PlatformThreadRef owning_thread_; -# else +#else mutable pthread_mutex_t mutex_; -# endif +#endif mutable PlatformThreadRef thread_; // Only used by RTC_DCHECKs. mutable int recursion_count_; // Only used by RTC_DCHECKs. #else // !defined(WEBRTC_WIN) && !defined(WEBRTC_POSIX) -# error Unsupported platform. +#error Unsupported platform. #endif }; @@ -113,9 +117,9 @@ class TryCritScope { #if defined(WEBRTC_WIN) _Check_return_ bool locked() const; #elif defined(WEBRTC_POSIX) - bool locked() const __attribute__ ((__warn_unused_result__)); + bool locked() const __attribute__((__warn_unused_result__)); #else // !defined(WEBRTC_WIN) && !defined(WEBRTC_POSIX) -# error Unsupported platform. +#error Unsupported platform. #endif private: const CriticalSection* const cs_; @@ -152,6 +156,6 @@ class RTC_SCOPED_LOCKABLE GlobalLockScope { RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_CRITICALSECTION_H_ +#endif // RTC_BASE_CRITICALSECTION_H_ diff --git a/rtc_base/criticalsection_unittest.cc b/rtc_base/criticalsection_unittest.cc index 6792504353..db4f9e7452 100644 --- a/rtc_base/criticalsection_unittest.cc +++ b/rtc_base/criticalsection_unittest.cc @@ -63,9 +63,8 @@ class CompareAndSwapVerifier { } } - void Finalize() { - EXPECT_EQ(1, zero_count_); - } + void Finalize() { EXPECT_EQ(1, zero_count_); } + private: int zero_count_; }; @@ -86,18 +85,14 @@ class RunnerBase : public MessageHandler { return done_event_.Wait(kLongTime); } - void SetExpectedThreadCount(int count) { - threads_active_ = count; - } + void SetExpectedThreadCount(int count) { threads_active_ = count; } int shared_value() const { return shared_value_; } protected: // Derived classes must override OnMessage, and call BeforeStart and AfterEnd // at the beginning and the end of OnMessage respectively. - void BeforeStart() { - ASSERT_TRUE(start_event_.Wait(kLongTime)); - } + void BeforeStart() { ASSERT_TRUE(start_event_.Wait(kLongTime)); } // Returns true if all threads have finished. bool AfterEnd() { @@ -168,7 +163,7 @@ class AtomicOpRunner : public RunnerBase { values.push_back(Op::AtomicOp(&shared_value_)); } - { // Add them all to the set. + { // Add them all to the set. CritScope cs(&all_values_crit_); verifier_.Verify(values); } @@ -255,8 +250,8 @@ TEST(AtomicOpsTest, Increment) { TEST(AtomicOpsTest, Decrement) { // Create and start lots of threads. - AtomicOpRunner runner( - kOperationsToRun * kNumThreads); + AtomicOpRunner runner(kOperationsToRun * + kNumThreads); std::vector> threads; StartThreads(&threads, &runner); runner.SetExpectedThreadCount(kNumThreads); @@ -305,8 +300,10 @@ TEST(CriticalSectionTest, Basic) { class PerfTestData { public: PerfTestData(int expected_count, Event* event) - : cache_line_barrier_1_(), cache_line_barrier_2_(), - expected_count_(expected_count), event_(event) { + : cache_line_barrier_1_(), + cache_line_barrier_2_(), + expected_count_(expected_count), + event_(event) { cache_line_barrier_1_[0]++; // Avoid 'is not used'. cache_line_barrier_2_[0]++; // Avoid 'is not used'. } diff --git a/rtc_base/cryptstring.cc b/rtc_base/cryptstring.cc index 421710c7c8..2c7c0c72af 100644 --- a/rtc_base/cryptstring.cc +++ b/rtc_base/cryptstring.cc @@ -34,15 +34,12 @@ void EmptyCryptStringImpl::CopyRawTo(std::vector* dest) const { dest->clear(); } -CryptString::CryptString() : impl_(new EmptyCryptStringImpl()) { -} +CryptString::CryptString() : impl_(new EmptyCryptStringImpl()) {} CryptString::CryptString(const CryptString& other) - : impl_(other.impl_->Copy()) { -} + : impl_(other.impl_->Copy()) {} -CryptString::CryptString(const CryptStringImpl& impl) : impl_(impl.Copy()) { -} +CryptString::CryptString(const CryptStringImpl& impl) : impl_(impl.Copy()) {} CryptString::~CryptString() = default; diff --git a/rtc_base/cryptstring.h b/rtc_base/cryptstring.h index c210487d90..d0e36cb169 100644 --- a/rtc_base/cryptstring.h +++ b/rtc_base/cryptstring.h @@ -23,10 +23,10 @@ class CryptStringImpl { public: virtual ~CryptStringImpl() {} virtual size_t GetLength() const = 0; - virtual void CopyTo(char * dest, bool nullterminate) const = 0; + virtual void CopyTo(char* dest, bool nullterminate) const = 0; virtual std::string UrlEncode() const = 0; - virtual CryptStringImpl * Copy() const = 0; - virtual void CopyRawTo(std::vector * dest) const = 0; + virtual CryptStringImpl* Copy() const = 0; + virtual void CopyRawTo(std::vector* dest) const = 0; }; class EmptyCryptStringImpl : public CryptStringImpl { @@ -49,7 +49,7 @@ class CryptString { CryptString(const CryptString& other); explicit CryptString(const CryptStringImpl& impl); ~CryptString(); - CryptString & operator=(const CryptString & other) { + CryptString& operator=(const CryptString& other) { if (this != &other) { impl_.reset(other.impl_->Copy()); } @@ -57,7 +57,7 @@ class CryptString { } void Clear() { impl_.reset(new EmptyCryptStringImpl()); } std::string UrlEncode() const { return impl_->UrlEncode(); } - void CopyRawTo(std::vector * dest) const { + void CopyRawTo(std::vector* dest) const { return impl_->CopyRawTo(dest); } diff --git a/rtc_base/deprecation.h b/rtc_base/deprecation.h index af776d53ff..f285ab04bb 100644 --- a/rtc_base/deprecation.h +++ b/rtc_base/deprecation.h @@ -37,7 +37,7 @@ // (https://bugs.chromium.org/p/webrtc/issues/detail?id=5368). #define RTC_DEPRECATED __declspec(deprecated) #elif defined(__GNUC__) -#define RTC_DEPRECATED __attribute__ ((__deprecated__)) +#define RTC_DEPRECATED __attribute__((__deprecated__)) #else #define RTC_DEPRECATED #endif diff --git a/rtc_base/dscp.h b/rtc_base/dscp.h index bdce466044..3c39ca66da 100644 --- a/rtc_base/dscp.h +++ b/rtc_base/dscp.h @@ -17,29 +17,29 @@ namespace rtc { enum DiffServCodePoint { DSCP_NO_CHANGE = -1, DSCP_DEFAULT = 0, // Same as DSCP_CS0 - DSCP_CS0 = 0, // The default - DSCP_CS1 = 8, // Bulk/background traffic + DSCP_CS0 = 0, // The default + DSCP_CS1 = 8, // Bulk/background traffic DSCP_AF11 = 10, DSCP_AF12 = 12, DSCP_AF13 = 14, - DSCP_CS2 = 16, + DSCP_CS2 = 16, DSCP_AF21 = 18, DSCP_AF22 = 20, DSCP_AF23 = 22, - DSCP_CS3 = 24, + DSCP_CS3 = 24, DSCP_AF31 = 26, DSCP_AF32 = 28, DSCP_AF33 = 30, - DSCP_CS4 = 32, + DSCP_CS4 = 32, DSCP_AF41 = 34, // Video DSCP_AF42 = 36, // Video DSCP_AF43 = 38, // Video - DSCP_CS5 = 40, // Video - DSCP_EF = 46, // Voice - DSCP_CS6 = 48, // Voice - DSCP_CS7 = 56, // Control messages + DSCP_CS5 = 40, // Video + DSCP_EF = 46, // Voice + DSCP_CS6 = 48, // Voice + DSCP_CS7 = 56, // Control messages }; } // namespace rtc - #endif // RTC_BASE_DSCP_H_ +#endif // RTC_BASE_DSCP_H_ diff --git a/rtc_base/event.cc b/rtc_base/event.cc index 9e38159b66..6c9639b4fe 100644 --- a/rtc_base/event.cc +++ b/rtc_base/event.cc @@ -70,8 +70,7 @@ bool Event::Wait(int milliseconds) { #endif Event::Event(bool manual_reset, bool initially_signaled) - : is_manual_reset_(manual_reset), - event_status_(initially_signaled) { + : is_manual_reset_(manual_reset), event_status_(initially_signaled) { RTC_CHECK(pthread_mutex_init(&event_mutex_, nullptr) == 0); pthread_condattr_t cond_attr; RTC_CHECK(pthread_condattr_init(&cond_attr) == 0); diff --git a/rtc_base/event_tracer.cc b/rtc_base/event_tracer.cc index 3461ec625a..31f4271d31 100644 --- a/rtc_base/event_tracer.cc +++ b/rtc_base/event_tracer.cc @@ -63,15 +63,8 @@ void EventTracer::AddTraceEvent(char phase, const unsigned long long* arg_values, unsigned char flags) { if (g_add_trace_event_ptr) { - g_add_trace_event_ptr(phase, - category_enabled, - name, - id, - num_args, - arg_names, - arg_types, - arg_values, - flags); + g_add_trace_event_ptr(phase, category_enabled, name, id, num_args, + arg_names, arg_types, arg_values, flags); } } @@ -128,8 +121,8 @@ class EventLogger final { {name, category_enabled, phase, args, timestamp, 1, thread_id}); } -// The TraceEvent format is documented here: -// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview + // The TraceEvent format is documented here: + // https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview void Log() { RTC_DCHECK(output_file_); static const int kLoggingIntervalMs = 100; diff --git a/rtc_base/event_tracer.h b/rtc_base/event_tracer.h index fc7ad046d4..4bbda579bc 100644 --- a/rtc_base/event_tracer.h +++ b/rtc_base/event_tracer.h @@ -45,27 +45,24 @@ typedef void (*AddTraceEventPtr)(char phase, // // This method must be called before any WebRTC methods. Functions // provided should be thread-safe. -void SetupEventTracer( - GetCategoryEnabledPtr get_category_enabled_ptr, - AddTraceEventPtr add_trace_event_ptr); +void SetupEventTracer(GetCategoryEnabledPtr get_category_enabled_ptr, + AddTraceEventPtr add_trace_event_ptr); // This class defines interface for the event tracing system to call // internally. Do not call these methods directly. class EventTracer { public: - static const unsigned char* GetCategoryEnabled( - const char* name); + static const unsigned char* GetCategoryEnabled(const char* name); - static void AddTraceEvent( - char phase, - const unsigned char* category_enabled, - const char* name, - unsigned long long id, - int num_args, - const char** arg_names, - const unsigned char* arg_types, - const unsigned long long* arg_values, - unsigned char flags); + static void AddTraceEvent(char phase, + const unsigned char* category_enabled, + const char* name, + unsigned long long id, + int num_args, + const char** arg_names, + const unsigned char* arg_types, + const unsigned long long* arg_values, + unsigned char flags); }; } // namespace webrtc diff --git a/rtc_base/event_tracer_unittest.cc b/rtc_base/event_tracer_unittest.cc index 25b300b271..27248e7547 100644 --- a/rtc_base/event_tracer_unittest.cc +++ b/rtc_base/event_tracer_unittest.cc @@ -17,16 +17,11 @@ namespace { class TestStatistics { public: - TestStatistics() : events_logged_(0) { - } + TestStatistics() : events_logged_(0) {} - void Reset() { - events_logged_ = 0; - } + void Reset() { events_logged_ = 0; } - void Increment() { - ++events_logged_; - } + void Increment() { ++events_logged_; } int Count() const { return events_logged_; } @@ -62,18 +57,14 @@ static void AddTraceEventHandler(char phase, namespace webrtc { TEST(EventTracerTest, EventTracerDisabled) { - { - TRACE_EVENT0("test", "EventTracerDisabled"); - } + { TRACE_EVENT0("test", "EventTracerDisabled"); } EXPECT_FALSE(TestStatistics::Get()->Count()); TestStatistics::Get()->Reset(); } TEST(EventTracerTest, ScopedTraceEvent) { SetupEventTracer(&GetCategoryEnabledHandler, &AddTraceEventHandler); - { - TRACE_EVENT0("test", "ScopedTraceEvent"); - } + { TRACE_EVENT0("test", "ScopedTraceEvent"); } EXPECT_EQ(2, TestStatistics::Get()->Count()); TestStatistics::Get()->Reset(); } diff --git a/rtc_base/event_unittest.cc b/rtc_base/event_unittest.cc index 5bb6f77b80..050619e849 100644 --- a/rtc_base/event_unittest.cc +++ b/rtc_base/event_unittest.cc @@ -41,7 +41,7 @@ TEST(EventTest, AutoReset) { } class SignalerThread { -public: + public: SignalerThread() : thread_(&ThreadFn, this, "EventPerf") {} void Start(Event* writer, Event* reader) { writer_ = writer; @@ -52,9 +52,9 @@ public: stop_event_.Set(); thread_.Stop(); } - static void ThreadFn(void *param) { + static void ThreadFn(void* param) { auto* me = static_cast(param); - while(!me->stop_event_.Wait(0)) { + while (!me->stop_event_.Wait(0)) { me->writer_->Set(); me->reader_->Wait(Event::kForever); } diff --git a/rtc_base/fakeclock.h b/rtc_base/fakeclock.h index 7cb61e5e41..2da8c616cc 100644 --- a/rtc_base/fakeclock.h +++ b/rtc_base/fakeclock.h @@ -40,6 +40,7 @@ class FakeClock : public ClockInterface { void AdvanceTimeMicros(int64_t micros) { AdvanceTime(webrtc::TimeDelta::us(micros)); } + private: CriticalSection lock_; int64_t time_ RTC_GUARDED_BY(lock_) = 0; diff --git a/rtc_base/fakenetwork.h b/rtc_base/fakenetwork.h index fd4eb615bc..8ed11646cd 100644 --- a/rtc_base/fakenetwork.h +++ b/rtc_base/fakenetwork.h @@ -28,8 +28,7 @@ const int kFakeIPv4NetworkPrefixLength = 24; const int kFakeIPv6NetworkPrefixLength = 64; // Fake network manager that allows us to manually specify the IPs to use. -class FakeNetworkManager : public NetworkManagerBase, - public MessageHandler { +class FakeNetworkManager : public NetworkManagerBase, public MessageHandler { public: FakeNetworkManager() {} @@ -54,8 +53,7 @@ class FakeNetworkManager : public NetworkManagerBase, } void RemoveInterface(const SocketAddress& iface) { - for (IfaceList::iterator it = ifaces_.begin(); - it != ifaces_.end(); ++it) { + for (IfaceList::iterator it = ifaces_.begin(); it != ifaces_.end(); ++it) { if (it->first.EqualIPs(iface)) { ifaces_.erase(it); break; @@ -79,9 +77,7 @@ class FakeNetworkManager : public NetworkManagerBase, virtual void StopUpdating() { --start_count_; } // MessageHandler interface. - virtual void OnMessage(Message* msg) { - DoUpdateNetworks(); - } + virtual void OnMessage(Message* msg) { DoUpdateNetworks(); } using NetworkManagerBase::set_enumeration_permission; using NetworkManagerBase::set_default_local_addresses; @@ -91,8 +87,7 @@ class FakeNetworkManager : public NetworkManagerBase, if (start_count_ == 0) return; std::vector networks; - for (IfaceList::iterator it = ifaces_.begin(); - it != ifaces_.end(); ++it) { + for (IfaceList::iterator it = ifaces_.begin(); it != ifaces_.end(); ++it) { int prefix_length = 0; if (it->first.ipaddr().family() == AF_INET) { prefix_length = kFakeIPv4NetworkPrefixLength; diff --git a/rtc_base/filerotatingstream.cc b/rtc_base/filerotatingstream.cc index 7108d9d281..c9a663aaff 100644 --- a/rtc_base/filerotatingstream.cc +++ b/rtc_base/filerotatingstream.cc @@ -26,8 +26,7 @@ namespace rtc { FileRotatingStream::FileRotatingStream(const std::string& dir_path, const std::string& file_prefix) - : FileRotatingStream(dir_path, file_prefix, 0, 0, kRead) { -} + : FileRotatingStream(dir_path, file_prefix, 0, 0, kRead) {} FileRotatingStream::FileRotatingStream(const std::string& dir_path, const std::string& file_prefix, @@ -78,8 +77,7 @@ FileRotatingStream::FileRotatingStream(const std::string& dir_path, } } -FileRotatingStream::~FileRotatingStream() { -} +FileRotatingStream::~FileRotatingStream() {} StreamState FileRotatingStream::GetState() const { if (mode_ == kRead && current_file_index_ < file_names_.size()) { @@ -343,8 +341,7 @@ CallSessionFileRotatingStream::CallSessionFileRotatingStream( const std::string& dir_path) : FileRotatingStream(dir_path, kLogPrefix), max_total_log_size_(0), - num_rotations_(0) { -} + num_rotations_(0) {} CallSessionFileRotatingStream::CallSessionFileRotatingStream( const std::string& dir_path, diff --git a/rtc_base/filerotatingstream_unittest.cc b/rtc_base/filerotatingstream_unittest.cc index 375d9a4067..19055162fd 100644 --- a/rtc_base/filerotatingstream_unittest.cc +++ b/rtc_base/filerotatingstream_unittest.cc @@ -31,7 +31,7 @@ void CleanupLogDirectory(const FileRotatingStream& stream) { } // namespace -#if defined (WEBRTC_ANDROID) +#if defined(WEBRTC_ANDROID) // Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364. #define MAYBE_FileRotatingStreamTest DISABLED_FileRotatingStreamTest #else @@ -202,13 +202,13 @@ TEST_F(MAYBE_FileRotatingStreamTest, GetFilePath) { } } -#if defined (WEBRTC_ANDROID) +#if defined(WEBRTC_ANDROID) // Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364. #define MAYBE_CallSessionFileRotatingStreamTest \ - DISABLED_CallSessionFileRotatingStreamTest + DISABLED_CallSessionFileRotatingStreamTest #else #define MAYBE_CallSessionFileRotatingStreamTest \ - CallSessionFileRotatingStreamTest + CallSessionFileRotatingStreamTest #endif class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test { diff --git a/rtc_base/fileutils.cc b/rtc_base/fileutils.cc index 40ec86f7a9..00375470ec 100644 --- a/rtc_base/fileutils.cc +++ b/rtc_base/fileutils.cc @@ -35,7 +35,7 @@ namespace rtc { // to the first file in the directory, and can be advanecd with Next(). This // allows you to get information about each file. - // Constructor +// Constructor DirectoryIterator::DirectoryIterator() #ifdef WEBRTC_WIN : handle_(INVALID_HANDLE_VALUE) { @@ -45,7 +45,7 @@ DirectoryIterator::DirectoryIterator() #endif } - // Destructor +// Destructor DirectoryIterator::~DirectoryIterator() { #if defined(WEBRTC_WIN) if (handle_ != INVALID_HANDLE_VALUE) @@ -56,10 +56,10 @@ DirectoryIterator::~DirectoryIterator() { #endif } - // Starts traversing a directory. - // dir is the directory to traverse - // returns true if the directory exists and is valid -bool DirectoryIterator::Iterate(const Pathname &dir) { +// Starts traversing a directory. +// dir is the directory to traverse +// returns true if the directory exists and is valid +bool DirectoryIterator::Iterate(const Pathname& dir) { directory_ = dir.pathname(); #if defined(WEBRTC_WIN) if (handle_ != INVALID_HANDLE_VALUE) @@ -84,8 +84,8 @@ bool DirectoryIterator::Iterate(const Pathname &dir) { return true; } - // Advances to the next file - // returns true if there were more files in the directory. +// Advances to the next file +// returns true if there were more files in the directory. bool DirectoryIterator::Next() { #if defined(WEBRTC_WIN) return ::FindNextFile(handle_, &data_) == TRUE; @@ -98,7 +98,7 @@ bool DirectoryIterator::Next() { #endif } - // returns true if the file currently pointed to is a directory +// returns true if the file currently pointed to is a directory bool DirectoryIterator::IsDirectory() const { #if defined(WEBRTC_WIN) return (data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FALSE; @@ -107,7 +107,7 @@ bool DirectoryIterator::IsDirectory() const { #endif } - // returns the name of the file currently pointed to +// returns the name of the file currently pointed to std::string DirectoryIterator::Name() const { #if defined(WEBRTC_WIN) return ToUtf8(data_.cFileName); @@ -119,7 +119,7 @@ std::string DirectoryIterator::Name() const { FilesystemInterface* Filesystem::default_filesystem_ = nullptr; -FilesystemInterface *Filesystem::EnsureDefaultFilesystem() { +FilesystemInterface* Filesystem::EnsureDefaultFilesystem() { if (!default_filesystem_) { #if defined(WEBRTC_WIN) default_filesystem_ = new Win32Filesystem(); diff --git a/rtc_base/fileutils.h b/rtc_base/fileutils.h index b9e8a05df7..fcbc6c3f45 100644 --- a/rtc_base/fileutils.h +++ b/rtc_base/fileutils.h @@ -42,6 +42,7 @@ class Pathname; class DirectoryIterator { friend class Filesystem; + public: // Constructor DirectoryIterator(); @@ -52,7 +53,7 @@ class DirectoryIterator { // dir is the directory to traverse // returns true if the directory exists and is valid // The iterator will point to the first entry in the directory - virtual bool Iterate(const Pathname &path); + virtual bool Iterate(const Pathname& path); // Advances to the next file // returns true if there were more files in the directory. @@ -70,8 +71,8 @@ class DirectoryIterator { WIN32_FIND_DATA data_; HANDLE handle_; #else - DIR *dir_; - struct dirent *dirent_; + DIR* dir_; + struct dirent* dirent_; struct stat stat_; #endif }; @@ -83,12 +84,12 @@ class FilesystemInterface { // This will attempt to delete the path located at filename. // It DCHECKs and returns false if the path points to a folder or a // non-existent file. - virtual bool DeleteFile(const Pathname &filename) = 0; + virtual bool DeleteFile(const Pathname& filename) = 0; // This moves a file from old_path to new_path, where "old_path" is a // plain file. This DCHECKs and returns false if old_path points to a // directory, and returns true if the function succeeds. - virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path) = 0; + virtual bool MoveFile(const Pathname& old_path, const Pathname& new_path) = 0; // Returns true if pathname refers to a directory virtual bool IsFolder(const Pathname& pathname) = 0; @@ -102,27 +103,27 @@ class FilesystemInterface { class Filesystem { public: - static FilesystemInterface *default_filesystem() { + static FilesystemInterface* default_filesystem() { RTC_DCHECK(default_filesystem_); return default_filesystem_; } - static void set_default_filesystem(FilesystemInterface *filesystem) { + static void set_default_filesystem(FilesystemInterface* filesystem) { default_filesystem_ = filesystem; } - static FilesystemInterface *swap_default_filesystem( - FilesystemInterface *filesystem) { - FilesystemInterface *cur = default_filesystem_; + static FilesystemInterface* swap_default_filesystem( + FilesystemInterface* filesystem) { + FilesystemInterface* cur = default_filesystem_; default_filesystem_ = filesystem; return cur; } - static bool DeleteFile(const Pathname &filename) { + static bool DeleteFile(const Pathname& filename) { return EnsureDefaultFilesystem()->DeleteFile(filename); } - static bool MoveFile(const Pathname &old_path, const Pathname &new_path) { + static bool MoveFile(const Pathname& old_path, const Pathname& new_path) { return EnsureDefaultFilesystem()->MoveFile(old_path, new_path); } @@ -130,7 +131,7 @@ class Filesystem { return EnsureDefaultFilesystem()->IsFolder(pathname); } - static bool IsFile(const Pathname &pathname) { + static bool IsFile(const Pathname& pathname) { return EnsureDefaultFilesystem()->IsFile(pathname); } @@ -141,7 +142,7 @@ class Filesystem { private: static FilesystemInterface* default_filesystem_; - static FilesystemInterface *EnsureDefaultFilesystem(); + static FilesystemInterface* EnsureDefaultFilesystem(); RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); }; diff --git a/rtc_base/firewallsocketserver.cc b/rtc_base/firewallsocketserver.cc index 650bb45eb7..2a28124d23 100644 --- a/rtc_base/firewallsocketserver.cc +++ b/rtc_base/firewallsocketserver.cc @@ -21,8 +21,7 @@ namespace rtc { class FirewallSocket : public AsyncSocketAdapter { public: FirewallSocket(FirewallSocketServer* server, AsyncSocket* socket, int type) - : AsyncSocketAdapter(socket), server_(server), type_(type) { - } + : AsyncSocketAdapter(socket), server_(server), type_(type) {} int Bind(const SocketAddress& addr) override { if (!server_->IsBindableIp(addr.ipaddr())) { @@ -117,9 +116,11 @@ class FirewallSocket : public AsyncSocketAdapter { FirewallSocketServer::FirewallSocketServer(SocketServer* server, FirewallManager* manager, bool should_delete_server) - : server_(server), manager_(manager), + : server_(server), + manager_(manager), should_delete_server_(should_delete_server), - udp_sockets_enabled_(true), tcp_sockets_enabled_(true), + udp_sockets_enabled_(true), + tcp_sockets_enabled_(true), tcp_listen_enabled_(true) { if (manager_) manager_->AddServer(this); @@ -135,7 +136,8 @@ FirewallSocketServer::~FirewallSocketServer() { } } -void FirewallSocketServer::AddRule(bool allow, FirewallProtocol p, +void FirewallSocketServer::AddRule(bool allow, + FirewallProtocol p, FirewallDirection d, const SocketAddress& addr) { SocketAddress any; @@ -147,8 +149,8 @@ void FirewallSocketServer::AddRule(bool allow, FirewallProtocol p, } } - -void FirewallSocketServer::AddRule(bool allow, FirewallProtocol p, +void FirewallSocketServer::AddRule(bool allow, + FirewallProtocol p, const SocketAddress& src, const SocketAddress& dst) { Rule r; @@ -217,8 +219,7 @@ void FirewallSocketServer::WakeUp() { } AsyncSocket* FirewallSocketServer::WrapSocket(AsyncSocket* sock, int type) { - if (!sock || - (type == SOCK_STREAM && !tcp_sockets_enabled_) || + if (!sock || (type == SOCK_STREAM && !tcp_sockets_enabled_) || (type == SOCK_DGRAM && !udp_sockets_enabled_)) { RTC_LOG(LS_VERBOSE) << "FirewallSocketServer socket creation denied"; delete sock; @@ -227,8 +228,7 @@ AsyncSocket* FirewallSocketServer::WrapSocket(AsyncSocket* sock, int type) { return new FirewallSocket(this, sock, type); } -FirewallManager::FirewallManager() { -} +FirewallManager::FirewallManager() {} FirewallManager::~FirewallManager() { RTC_DCHECK(servers_.empty()); @@ -245,19 +245,21 @@ void FirewallManager::RemoveServer(FirewallSocketServer* server) { servers_.end()); } -void FirewallManager::AddRule(bool allow, FirewallProtocol p, - FirewallDirection d, const SocketAddress& addr) { +void FirewallManager::AddRule(bool allow, + FirewallProtocol p, + FirewallDirection d, + const SocketAddress& addr) { CritScope scope(&crit_); - for (std::vector::const_iterator it = - servers_.begin(); it != servers_.end(); ++it) { + for (std::vector::const_iterator it = servers_.begin(); + it != servers_.end(); ++it) { (*it)->AddRule(allow, p, d, addr); } } void FirewallManager::ClearRules() { CritScope scope(&crit_); - for (std::vector::const_iterator it = - servers_.begin(); it != servers_.end(); ++it) { + for (std::vector::const_iterator it = servers_.begin(); + it != servers_.end(); ++it) { (*it)->ClearRules(); } } diff --git a/rtc_base/firewallsocketserver.h b/rtc_base/firewallsocketserver.h index 561030a4c3..0e96823ff6 100644 --- a/rtc_base/firewallsocketserver.h +++ b/rtc_base/firewallsocketserver.h @@ -48,15 +48,19 @@ class FirewallSocketServer : public SocketServer { void set_tcp_listen_enabled(bool enabled) { tcp_listen_enabled_ = enabled; } // Rules govern the behavior of Connect/Accept/Send/Recv attempts. - void AddRule(bool allow, FirewallProtocol p = FP_ANY, + void AddRule(bool allow, + FirewallProtocol p = FP_ANY, FirewallDirection d = FD_ANY, const SocketAddress& addr = SocketAddress()); - void AddRule(bool allow, FirewallProtocol p, - const SocketAddress& src, const SocketAddress& dst); + void AddRule(bool allow, + FirewallProtocol p, + const SocketAddress& src, + const SocketAddress& dst); void ClearRules(); bool Check(FirewallProtocol p, - const SocketAddress& src, const SocketAddress& dst); + const SocketAddress& src, + const SocketAddress& dst); // Set the IP addresses for which Bind will fail. By default this list is // empty. This can be used to simulate a real OS that refuses to bind to @@ -75,12 +79,12 @@ class FirewallSocketServer : public SocketServer { bool Wait(int cms, bool process_io) override; void WakeUp() override; - Socket * WrapSocket(Socket * sock, int type); - AsyncSocket * WrapSocket(AsyncSocket * sock, int type); + Socket* WrapSocket(Socket* sock, int type); + AsyncSocket* WrapSocket(AsyncSocket* sock, int type); private: - SocketServer * server_; - FirewallManager * manager_; + SocketServer* server_; + FirewallManager* manager_; CriticalSection crit_; struct Rule { bool allow; @@ -104,17 +108,18 @@ class FirewallManager { FirewallManager(); ~FirewallManager(); - void AddServer(FirewallSocketServer * server); - void RemoveServer(FirewallSocketServer * server); + void AddServer(FirewallSocketServer* server); + void RemoveServer(FirewallSocketServer* server); - void AddRule(bool allow, FirewallProtocol p = FP_ANY, + void AddRule(bool allow, + FirewallProtocol p = FP_ANY, FirewallDirection d = FD_ANY, const SocketAddress& addr = SocketAddress()); void ClearRules(); private: CriticalSection crit_; - std::vector servers_; + std::vector servers_; }; } // namespace rtc diff --git a/rtc_base/flags.cc b/rtc_base/flags.cc index a2fb7089b0..5b28794f6c 100644 --- a/rtc_base/flags.cc +++ b/rtc_base/flags.cc @@ -18,11 +18,13 @@ #include "rtc_base/stringutils.h" #if defined(WEBRTC_WIN) +// clang-format off +// clang formating would change include order. #include -#include +#include // must come after windows.h +// clang-format on #endif - namespace { bool FlagEq(const char* arg, const char* flag) { // Compare two flags for equality. @@ -43,8 +45,12 @@ namespace rtc { // ----------------------------------------------------------------------------- // Implementation of Flag -Flag::Flag(const char* file, const char* name, const char* comment, - Type type, void* variable, FlagValue default__) +Flag::Flag(const char* file, + const char* name, + const char* comment, + Type type, + void* variable, + FlagValue default__) : file_(file), name_(name), comment_(comment), @@ -54,7 +60,6 @@ Flag::Flag(const char* file, const char* name, const char* comment, FlagList::Register(this); } - void Flag::SetToDefault() { // Note that we cannot simply do '*variable_ = default_;' since // flag variables are not really of type FlagValue and thus may @@ -78,18 +83,20 @@ void Flag::SetToDefault() { FATAL() << "unreachable code"; } - static const char* Type2String(Flag::Type type) { switch (type) { - case Flag::BOOL: return "bool"; - case Flag::INT: return "int"; - case Flag::FLOAT: return "float"; - case Flag::STRING: return "string"; + case Flag::BOOL: + return "bool"; + case Flag::INT: + return "int"; + case Flag::FLOAT: + return "float"; + case Flag::STRING: + return "string"; } FATAL() << "unreachable code"; } - static void PrintFlagValue(Flag::Type type, FlagValue* p) { switch (type) { case Flag::BOOL: @@ -108,10 +115,9 @@ static void PrintFlagValue(Flag::Type type, FlagValue* p) { FATAL() << "unreachable code"; } - void Flag::Print(bool print_current_value) { printf(" --%s (%s) type: %s default: ", name_, comment_, - Type2String(type_)); + Type2String(type_)); PrintFlagValue(type_, &default_); if (print_current_value) { printf(" current value: "); @@ -120,7 +126,6 @@ void Flag::Print(bool print_current_value) { printf("\n"); } - // ----------------------------------------------------------------------------- // Implementation of FlagList @@ -145,7 +150,6 @@ void FlagList::Print(const char* file, bool print_current_value) { } } - Flag* FlagList::Lookup(const char* name) { Flag* f = list_; while (f != nullptr && !FlagEq(name, f->name())) @@ -153,10 +157,11 @@ Flag* FlagList::Lookup(const char* name) { return f; } - void FlagList::SplitArgument(const char* arg, - char* buffer, int buffer_size, - const char** name, const char** value, + char* buffer, + int buffer_size, + const char** name, + const char** value, bool* is_bool) { *name = nullptr; *value = nullptr; @@ -191,8 +196,8 @@ void FlagList::SplitArgument(const char* arg, } } - -int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv, +int FlagList::SetFlagsFromCommandLine(int* argc, + const char** argv, bool remove_flags) { // parse arguments for (int i = 1; i < *argc; /* see below */) { @@ -219,14 +224,14 @@ int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv, if (i < *argc) { value = argv[i++]; } else { - fprintf(stderr, "Error: missing value for flag %s of type %s\n", - arg, Type2String(flag->type())); + fprintf(stderr, "Error: missing value for flag %s of type %s\n", arg, + Type2String(flag->type())); return j; } } // set the flag - char empty[] = { '\0' }; + char empty[] = {'\0'}; char* endp = empty; switch (flag->type()) { case Flag::BOOL: @@ -246,8 +251,8 @@ int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv, // handle errors if ((flag->type() == Flag::BOOL && value != nullptr) || (flag->type() != Flag::BOOL && is_bool) || *endp != '\0') { - fprintf(stderr, "Error: illegal value for flag %s of type %s\n", - arg, Type2String(flag->type())); + fprintf(stderr, "Error: illegal value for flag %s of type %s\n", arg, + Type2String(flag->type())); return j; } @@ -287,15 +292,15 @@ void FlagList::Register(Flag* flag) { WindowsCommandLineArguments::WindowsCommandLineArguments() { // start by getting the command line. LPTSTR command_line = ::GetCommandLine(); - // now, convert it to a list of wide char strings. - LPWSTR *wide_argv = ::CommandLineToArgvW(command_line, &argc_); + // now, convert it to a list of wide char strings. + LPWSTR* wide_argv = ::CommandLineToArgvW(command_line, &argc_); // now allocate an array big enough to hold that many string pointers. argv_ = new char*[argc_]; // iterate over the returned wide strings; - for(int i = 0; i < argc_; ++i) { + for (int i = 0; i < argc_; ++i) { std::string s = rtc::ToUtf8(wide_argv[i], wcslen(wide_argv[i])); - char *buffer = new char[s.length() + 1]; + char* buffer = new char[s.length() + 1]; rtc::strcpyn(buffer, s.length() + 1, s.c_str()); // make sure the argv array has the right string at this point. @@ -306,7 +311,7 @@ WindowsCommandLineArguments::WindowsCommandLineArguments() { WindowsCommandLineArguments::~WindowsCommandLineArguments() { // need to free each string in the array, and then the array. - for(int i = 0; i < argc_; i++) { + for (int i = 0; i < argc_; i++) { delete[] argv_[i]; } diff --git a/rtc_base/flags.h b/rtc_base/flags.h index 5a07b1a737..33f6e5bda1 100644 --- a/rtc_base/flags.h +++ b/rtc_base/flags.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - // Originally comes from shared/commandlineflags/flags.h // Flags are defined and declared using DEFINE_xxx and DECLARE_xxx macros, @@ -65,23 +64,26 @@ union FlagValue { const char* s; }; - // Each flag can be accessed programmatically via a Flag object. class Flag { public: enum Type { BOOL, INT, FLOAT, STRING }; // Internal use only. - Flag(const char* file, const char* name, const char* comment, - Type type, void* variable, FlagValue default_); + Flag(const char* file, + const char* name, + const char* comment, + Type type, + void* variable, + FlagValue default_); // General flag information - const char* file() const { return file_; } - const char* name() const { return name_; } - const char* comment() const { return comment_; } + const char* file() const { return file_; } + const char* name() const { return name_; } + const char* comment() const { return comment_; } // Flag type - Type type() const { return type_; } + Type type() const { return type_; } // Flag variables bool* bool_variable() const { @@ -129,7 +131,7 @@ class Flag { void SetToDefault(); // Iteration support - Flag* next() const { return next_; } + Flag* next() const { return next_; } // Prints flag information. The current flag value is only printed // if print_current_value is set. @@ -149,23 +151,20 @@ class Flag { friend class FlagList; // accesses next_ }; - // Internal use only. -#define DEFINE_FLAG(type, c_type, name, default, comment) \ - /* define and initialize the flag */ \ - c_type FLAG_##name = (default); \ - /* register the flag */ \ - static rtc::Flag Flag_##name(__FILE__, #name, (comment), \ - rtc::Flag::type, &FLAG_##name, \ +#define DEFINE_FLAG(type, c_type, name, default, comment) \ + /* define and initialize the flag */ \ + c_type FLAG_##name = (default); \ + /* register the flag */ \ + static rtc::Flag Flag_##name(__FILE__, #name, (comment), rtc::Flag::type, \ + &FLAG_##name, \ rtc::FlagValue::New_##type(default)) - // Internal use only. -#define DECLARE_FLAG(c_type, name) \ - /* declare the external flag */ \ +#define DECLARE_FLAG(c_type, name) \ + /* declare the external flag */ \ extern c_type FLAG_##name - // Use the following macros to define a new flag: #define DEFINE_bool(name, default, comment) \ DEFINE_FLAG(BOOL, bool, name, default, comment) @@ -176,13 +175,11 @@ class Flag { #define DEFINE_string(name, default, comment) \ DEFINE_FLAG(STRING, const char*, name, default, comment) - // Use the following macros to declare a flag defined elsewhere: -#define DECLARE_bool(name) DECLARE_FLAG(bool, name) -#define DECLARE_int(name) DECLARE_FLAG(int, name) -#define DECLARE_float(name) DECLARE_FLAG(double, name) -#define DECLARE_string(name) DECLARE_FLAG(const char*, name) - +#define DECLARE_bool(name) DECLARE_FLAG(bool, name) +#define DECLARE_int(name) DECLARE_FLAG(int, name) +#define DECLARE_float(name) DECLARE_FLAG(double, name) +#define DECLARE_string(name) DECLARE_FLAG(const char*, name) // The global list of all flags. class FlagList { @@ -190,7 +187,7 @@ class FlagList { FlagList(); // The null-terminated list of all flags. Traverse with Flag::next(). - static Flag* list() { return list_; } + static Flag* list() { return list_; } // If file != nullptr, prints information for all flags defined in file; // otherwise prints information for all flags in all files. The current flag @@ -205,8 +202,10 @@ class FlagList { // if the arg started with "-no" or "--no". The buffer may be used to NUL- // terminate the name, it must be large enough to hold any possible name. static void SplitArgument(const char* arg, - char* buffer, int buffer_size, - const char** name, const char** value, + char* buffer, + int buffer_size, + const char** name, + const char** value, bool* is_bool); // Set the flag values by parsing the command line. If remove_flags @@ -253,10 +252,11 @@ class WindowsCommandLineArguments { ~WindowsCommandLineArguments(); int argc() { return argc_; } - char **argv() { return argv_; } + char** argv() { return argv_; } + private: int argc_; - char **argv_; + char** argv_; private: RTC_DISALLOW_COPY_AND_ASSIGN(WindowsCommandLineArguments); diff --git a/rtc_base/function_view_unittest.cc b/rtc_base/function_view_unittest.cc index 98f78d6680..d0cfeb3088 100644 --- a/rtc_base/function_view_unittest.cc +++ b/rtc_base/function_view_unittest.cc @@ -73,7 +73,7 @@ TEST(FunctionViewTest, Null) { EXPECT_FALSE(rtc::FunctionView(nullptr)); // This calls the constructor for function pointers. - EXPECT_FALSE(rtc::FunctionView(reinterpret_cast(0))); + EXPECT_FALSE(rtc::FunctionView(reinterpret_cast(0))); } // Ensure that FunctionView handles move-only arguments and return values. diff --git a/rtc_base/gtest_prod_util.h b/rtc_base/gtest_prod_util.h index dc9679f49e..0661cd7bd9 100644 --- a/rtc_base/gtest_prod_util.h +++ b/rtc_base/gtest_prod_util.h @@ -13,8 +13,8 @@ // Define our own version of FRIEND_TEST here rather than including // gtest_prod.h to avoid depending on any part of GTest in production code. -#define FRIEND_TEST_WEBRTC(test_case_name, test_name)\ -friend class test_case_name##_##test_name##_Test +#define FRIEND_TEST_WEBRTC(test_case_name, test_name) \ + friend class test_case_name##_##test_name##_Test // This file is a plain copy of Chromium's base/gtest_prod_util.h. // @@ -30,9 +30,9 @@ friend class test_case_name##_##test_name##_Test // FRIEND_TEST_ALL_PREFIXES(MyClassTest, MyMethod); // }; #define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \ - FRIEND_TEST_WEBRTC(test_case_name, test_name); \ + FRIEND_TEST_WEBRTC(test_case_name, test_name); \ FRIEND_TEST_WEBRTC(test_case_name, DISABLED_##test_name); \ - FRIEND_TEST_WEBRTC(test_case_name, FLAKY_##test_name); \ + FRIEND_TEST_WEBRTC(test_case_name, FLAKY_##test_name); \ FRIEND_TEST_WEBRTC(test_case_name, FAILS_##test_name) #endif // RTC_BASE_GTEST_PROD_UTIL_H_ diff --git a/rtc_base/gunit_prod.h b/rtc_base/gunit_prod.h index ae4157d338..bf4f9a184c 100644 --- a/rtc_base/gunit_prod.h +++ b/rtc_base/gunit_prod.h @@ -15,7 +15,7 @@ // Android doesn't use gtest at all, so anything that relies on gtest should // check this define first. #define NO_GTEST -#elif defined (GTEST_RELATIVE_PATH) +#elif defined(GTEST_RELATIVE_PATH) #include "gtest/gtest_prod.h" #else #include "testing/base/gunit_prod.h" diff --git a/rtc_base/helpers.cc b/rtc_base/helpers.cc index 89cf609d1d..02606654bd 100644 --- a/rtc_base/helpers.cc +++ b/rtc_base/helpers.cc @@ -47,10 +47,8 @@ class SecureRandomGenerator : public RandomGenerator { // A test random generator, for predictable output. class TestRandomGenerator : public RandomGenerator { public: - TestRandomGenerator() : seed_(7) { - } - ~TestRandomGenerator() override { - } + TestRandomGenerator() : seed_(7) {} + ~TestRandomGenerator() override {} bool Init(const void* seed, size_t len) override { return true; } bool Generate(void* buf, size_t len) override { for (size_t i = 0; i < len; ++i) { @@ -84,8 +82,8 @@ static const char kUuidDigit17[4] = {'8', '9', 'a', 'b'}; // This round about way of creating a global RNG is to safe-guard against // indeterminant static initialization order. std::unique_ptr& GetGlobalRng() { - static std::unique_ptr& global_rng - = *new std::unique_ptr(new SecureRandomGenerator()); + static std::unique_ptr& global_rng = + *new std::unique_ptr(new SecureRandomGenerator()); return global_rng; } @@ -123,8 +121,9 @@ std::string CreateRandomString(size_t len) { } static bool CreateRandomString(size_t len, - const char* table, int table_size, - std::string* str) { + const char* table, + int table_size, + std::string* str) { str->clear(); // Avoid biased modulo division below. if (256 % table_size) { @@ -147,10 +146,11 @@ bool CreateRandomString(size_t len, std::string* str) { return CreateRandomString(len, kBase64, 64, str); } -bool CreateRandomString(size_t len, const std::string& table, +bool CreateRandomString(size_t len, + const std::string& table, std::string* str) { - return CreateRandomString(len, table.c_str(), - static_cast(table.size()), str); + return CreateRandomString(len, table.c_str(), static_cast(table.size()), + str); } bool CreateRandomData(size_t length, std::string* data) { diff --git a/rtc_base/helpers.h b/rtc_base/helpers.h index c1abb2c8ac..d3b09cfd48 100644 --- a/rtc_base/helpers.h +++ b/rtc_base/helpers.h @@ -36,7 +36,8 @@ bool CreateRandomString(size_t length, std::string* str); // number generator failed. // For ease of implementation, the function requires that the table // size evenly divide 256; otherwise, it returns false. -bool CreateRandomString(size_t length, const std::string& table, +bool CreateRandomString(size_t length, + const std::string& table, std::string* str); // Generates (cryptographically) random data of the given length. diff --git a/rtc_base/helpers_unittest.cc b/rtc_base/helpers_unittest.cc index 9fa16a5f46..3e8729ce1f 100644 --- a/rtc_base/helpers_unittest.cc +++ b/rtc_base/helpers_unittest.cc @@ -81,10 +81,12 @@ TEST_F(RandomTest, TestCreateRandomForTest) { std::string random; EXPECT_TRUE(CreateRandomData(kRandomDataLength, &random)); EXPECT_EQ(kRandomDataLength, random.size()); - Buffer expected("\xbd\x52\x2a\x4b\x97\x93\x2f\x1c" + Buffer expected( + "\xbd\x52\x2a\x4b\x97\x93\x2f\x1c" "\xc4\x72\xab\xa2\x88\x68\x3e\xcc" "\xa3\x8d\xaf\x13\x3b\xbc\x83\xbb" - "\x16\xf1\xcf\x56\x0c\xf5\x4a\x8b", kRandomDataLength); + "\x16\xf1\xcf\x56\x0c\xf5\x4a\x8b", + kRandomDataLength); EXPECT_EQ(0, memcmp(expected.data(), random.data(), kRandomDataLength)); // Reset and make sure we get the same output. diff --git a/rtc_base/httpbase.cc b/rtc_base/httpbase.cc index ca85b57567..3e2f376a8e 100644 --- a/rtc_base/httpbase.cc +++ b/rtc_base/httpbase.cc @@ -36,9 +36,7 @@ bool MatchHeader(const char* str, size_t len, HttpHeader header) { return (len == header_len) && (_strnicmp(str, header_str, header_len) == 0); } -enum { - MSG_READ -}; +enum { MSG_READ }; ////////////////////////////////////////////////////////////////////// // HttpParser @@ -48,19 +46,18 @@ HttpParser::HttpParser() { reset(); } -HttpParser::~HttpParser() { -} +HttpParser::~HttpParser() {} -void -HttpParser::reset() { +void HttpParser::reset() { state_ = ST_LEADER; chunked_ = false; data_size_ = SIZE_UNKNOWN; } -HttpParser::ProcessResult -HttpParser::Process(const char* buffer, size_t len, size_t* processed, - HttpError* error) { +HttpParser::ProcessResult HttpParser::Process(const char* buffer, + size_t len, + size_t* processed, + HttpError* error) { *processed = 0; *error = HE_NONE; @@ -81,7 +78,7 @@ HttpParser::Process(const char* buffer, size_t len, size_t* processed, const char* line = buffer + *processed; size_t len = (pos - *processed); *processed = pos + 1; - while ((len > 0) && isspace(static_cast(line[len-1]))) { + while ((len > 0) && isspace(static_cast(line[len - 1]))) { len -= 1; } ProcessResult result = ProcessLine(line, len, error); @@ -99,14 +96,14 @@ HttpParser::Process(const char* buffer, size_t len, size_t* processed, } else { size_t available = len - *processed; if (available <= 0) { - break; // no more data + break; // no more data } if ((data_size_ != SIZE_UNKNOWN) && (available > data_size_)) { available = data_size_; } size_t read = 0; - ProcessResult result = ProcessData(buffer + *processed, available, read, - error); + ProcessResult result = + ProcessData(buffer + *processed, available, read, error); RTC_LOG(LS_VERBOSE) << "Processed data, result: " << result << " read: " << read << " err: " << error; @@ -123,104 +120,103 @@ HttpParser::Process(const char* buffer, size_t len, size_t* processed, return PR_CONTINUE; } -HttpParser::ProcessResult -HttpParser::ProcessLine(const char* line, size_t len, HttpError* error) { +HttpParser::ProcessResult HttpParser::ProcessLine(const char* line, + size_t len, + HttpError* error) { RTC_LOG_F(LS_VERBOSE) << " state: " << state_ << " line: " << std::string(line, len) << " len: " << len << " err: " << error; switch (state_) { - case ST_LEADER: - state_ = ST_HEADERS; - return ProcessLeader(line, len, error); + case ST_LEADER: + state_ = ST_HEADERS; + return ProcessLeader(line, len, error); - case ST_HEADERS: - if (len > 0) { - const char* value = strchrn(line, len, ':'); - if (!value) { - *error = HE_PROTOCOL; - return PR_COMPLETE; - } - size_t nlen = (value - line); - const char* eol = line + len; - do { - value += 1; - } while ((value < eol) && isspace(static_cast(*value))); - size_t vlen = eol - value; - if (MatchHeader(line, nlen, HH_CONTENT_LENGTH)) { - // sscanf isn't safe with strings that aren't null-terminated, and there - // is no guarantee that |value| is. - // Create a local copy that is null-terminated. - std::string value_str(value, vlen); - unsigned int temp_size; - if (sscanf(value_str.c_str(), "%u", &temp_size) != 1) { + case ST_HEADERS: + if (len > 0) { + const char* value = strchrn(line, len, ':'); + if (!value) { *error = HE_PROTOCOL; return PR_COMPLETE; } - data_size_ = static_cast(temp_size); - } else if (MatchHeader(line, nlen, HH_TRANSFER_ENCODING)) { - if ((vlen == 7) && (_strnicmp(value, "chunked", 7) == 0)) { - chunked_ = true; - } else if ((vlen == 8) && (_strnicmp(value, "identity", 8) == 0)) { - chunked_ = false; - } else { + size_t nlen = (value - line); + const char* eol = line + len; + do { + value += 1; + } while ((value < eol) && isspace(static_cast(*value))); + size_t vlen = eol - value; + if (MatchHeader(line, nlen, HH_CONTENT_LENGTH)) { + // sscanf isn't safe with strings that aren't null-terminated, and + // there is no guarantee that |value| is. Create a local copy that is + // null-terminated. + std::string value_str(value, vlen); + unsigned int temp_size; + if (sscanf(value_str.c_str(), "%u", &temp_size) != 1) { + *error = HE_PROTOCOL; + return PR_COMPLETE; + } + data_size_ = static_cast(temp_size); + } else if (MatchHeader(line, nlen, HH_TRANSFER_ENCODING)) { + if ((vlen == 7) && (_strnicmp(value, "chunked", 7) == 0)) { + chunked_ = true; + } else if ((vlen == 8) && (_strnicmp(value, "identity", 8) == 0)) { + chunked_ = false; + } else { + *error = HE_PROTOCOL; + return PR_COMPLETE; + } + } + return ProcessHeader(line, nlen, value, vlen, error); + } else { + state_ = chunked_ ? ST_CHUNKSIZE : ST_DATA; + return ProcessHeaderComplete(chunked_, data_size_, error); + } + break; + + case ST_CHUNKSIZE: + if (len > 0) { + char* ptr = nullptr; + data_size_ = strtoul(line, &ptr, 16); + if (ptr != line + len) { *error = HE_PROTOCOL; return PR_COMPLETE; } - } - return ProcessHeader(line, nlen, value, vlen, error); - } else { - state_ = chunked_ ? ST_CHUNKSIZE : ST_DATA; - return ProcessHeaderComplete(chunked_, data_size_, error); - } - break; - - case ST_CHUNKSIZE: - if (len > 0) { - char* ptr = nullptr; - data_size_ = strtoul(line, &ptr, 16); - if (ptr != line + len) { + state_ = (data_size_ == 0) ? ST_TRAILERS : ST_DATA; + } else { *error = HE_PROTOCOL; return PR_COMPLETE; } - state_ = (data_size_ == 0) ? ST_TRAILERS : ST_DATA; - } else { - *error = HE_PROTOCOL; - return PR_COMPLETE; - } - break; + break; - case ST_CHUNKTERM: - if (len > 0) { - *error = HE_PROTOCOL; - return PR_COMPLETE; - } else { - state_ = chunked_ ? ST_CHUNKSIZE : ST_DATA; - } - break; + case ST_CHUNKTERM: + if (len > 0) { + *error = HE_PROTOCOL; + return PR_COMPLETE; + } else { + state_ = chunked_ ? ST_CHUNKSIZE : ST_DATA; + } + break; - case ST_TRAILERS: - if (len == 0) { - return PR_COMPLETE; - } - // *error = onHttpRecvTrailer(); - break; + case ST_TRAILERS: + if (len == 0) { + return PR_COMPLETE; + } + // *error = onHttpRecvTrailer(); + break; - default: - RTC_NOTREACHED(); - break; + default: + RTC_NOTREACHED(); + break; } return PR_CONTINUE; } -bool -HttpParser::is_valid_end_of_input() const { +bool HttpParser::is_valid_end_of_input() const { return (state_ == ST_DATA) && (data_size_ == SIZE_UNKNOWN); } -void -HttpParser::complete(HttpError error) { +void HttpParser::complete(HttpError error) { if (state_ < ST_COMPLETE) { state_ = ST_COMPLETE; OnComplete(error); @@ -232,9 +228,9 @@ HttpParser::complete(HttpError error) { ////////////////////////////////////////////////////////////////////// class BlockingMemoryStream : public ExternalMemoryStream { -public: + public: BlockingMemoryStream(char* buffer, size_t size) - : ExternalMemoryStream(buffer, size) { } + : ExternalMemoryStream(buffer, size) {} StreamResult DoReserve(size_t size, int* error) override { return (buffer_length_ >= size) ? SR_SUCCESS : SR_BLOCK; @@ -242,8 +238,8 @@ public: }; class HttpBase::DocumentStream : public StreamInterface { -public: - DocumentStream(HttpBase* base) : base_(base), error_(HE_DEFAULT) { } + public: + DocumentStream(HttpBase* base) : base_(base), error_(HE_DEFAULT) {} StreamState GetState() const override { if (nullptr == base_) @@ -258,7 +254,8 @@ public: size_t* read, int* error) override { if (!base_) { - if (error) *error = error_; + if (error) + *error = error_; return (HE_NONE == error_) ? SR_EOS : SR_ERROR; } @@ -296,7 +293,8 @@ public: StreamResult result = SR_BLOCK; if (complete) { HttpBase* base = Disconnect(http_error); - if (error) *error = error_; + if (error) + *error = error_; result = (HE_NONE == error_) ? SR_EOS : SR_ERROR; base->complete(http_error); } @@ -306,7 +304,8 @@ public: size_t position; stream->GetPosition(&position); if (position > 0) { - if (read) *read = position; + if (read) + *read = position; result = SR_SUCCESS; } return result; @@ -316,7 +315,8 @@ public: size_t data_len, size_t* written, int* error) override { - if (error) *error = -1; + if (error) + *error = -1; return SR_ERROR; } @@ -352,7 +352,7 @@ public: return base; } -private: + private: HttpBase* base_; HttpError error_; }; @@ -372,13 +372,11 @@ HttpBase::~HttpBase() { RTC_DCHECK(HM_NONE == mode_); } -bool -HttpBase::isConnected() const { +bool HttpBase::isConnected() const { return (http_stream_ != nullptr) && (http_stream_->GetState() == SS_OPEN); } -bool -HttpBase::attach(StreamInterface* stream) { +bool HttpBase::attach(StreamInterface* stream) { if ((mode_ != HM_NONE) || (http_stream_ != nullptr) || (stream == nullptr)) { RTC_NOTREACHED(); return false; @@ -389,8 +387,7 @@ HttpBase::attach(StreamInterface* stream) { return true; } -StreamInterface* -HttpBase::detach() { +StreamInterface* HttpBase::detach() { RTC_DCHECK(HM_NONE == mode_); if (mode_ != HM_NONE) { return nullptr; @@ -403,8 +400,7 @@ HttpBase::detach() { return stream; } -void -HttpBase::send(HttpData* data) { +void HttpBase::send(HttpData* data) { RTC_DCHECK(HM_NONE == mode_); if (mode_ != HM_NONE) { return; @@ -423,8 +419,8 @@ HttpBase::send(HttpData* data) { } std::string encoding; - if (data_->hasHeader(HH_TRANSFER_ENCODING, &encoding) - && (encoding == "chunked")) { + if (data_->hasHeader(HH_TRANSFER_ENCODING, &encoding) && + (encoding == "chunked")) { chunk_data_ = true; } @@ -440,8 +436,7 @@ HttpBase::send(HttpData* data) { flush_data(); } -void -HttpBase::recv(HttpData* data) { +void HttpBase::recv(HttpData* data) { RTC_DCHECK(HM_NONE == mode_); if (mode_ != HM_NONE) { return; @@ -463,8 +458,7 @@ HttpBase::recv(HttpData* data) { } } -void -HttpBase::abort(HttpError err) { +void HttpBase::abort(HttpError err) { if (mode_ != HM_NONE) { if (http_stream_ != nullptr) { http_stream_->Close(); @@ -520,28 +514,27 @@ bool HttpBase::DoReceiveLoop(HttpError* error) { // Attempt to buffer more data. size_t read; int read_error; - StreamResult read_result = http_stream_->Read(buffer_ + len_, - sizeof(buffer_) - len_, - &read, &read_error); + StreamResult read_result = http_stream_->Read( + buffer_ + len_, sizeof(buffer_) - len_, &read, &read_error); switch (read_result) { - case SR_SUCCESS: - RTC_DCHECK(len_ + read <= sizeof(buffer_)); - len_ += read; - break; - case SR_BLOCK: - if (process_requires_more_data) { - // We're can't make progress until more data is available. - return false; - } - // Attempt to process the data already in our buffer. - break; - case SR_EOS: - // Clean close, with no error. - read_error = 0; - RTC_FALLTHROUGH(); // Fall through to HandleStreamClose. - case SR_ERROR: - *error = HandleStreamClose(read_error); - return true; + case SR_SUCCESS: + RTC_DCHECK(len_ + read <= sizeof(buffer_)); + len_ += read; + break; + case SR_BLOCK: + if (process_requires_more_data) { + // We're can't make progress until more data is available. + return false; + } + // Attempt to process the data already in our buffer. + break; + case SR_EOS: + // Clean close, with no error. + read_error = 0; + RTC_FALLTHROUGH(); // Fall through to HandleStreamClose. + case SR_ERROR: + *error = HandleStreamClose(read_error); + return true; } } else if (process_requires_more_data) { // We have too much unprocessed data in our buffer. This should only @@ -558,22 +551,21 @@ bool HttpBase::DoReceiveLoop(HttpError* error) { // necessary to call Process with an empty buffer, since the state machine // may have interrupted state transitions to complete. size_t processed; - ProcessResult process_result = Process(buffer_, len_, &processed, - error); + ProcessResult process_result = Process(buffer_, len_, &processed, error); RTC_DCHECK(processed <= len_); len_ -= processed; memmove(buffer_, buffer_ + processed, len_); switch (process_result) { - case PR_CONTINUE: - // We need more data to make progress. - process_requires_more_data = true; - break; - case PR_BLOCK: - // We're stalled on writing the processed data. - return false; - case PR_COMPLETE: - // *error already contains the correct code. - return true; + case PR_CONTINUE: + // We need more data to make progress. + process_requires_more_data = true; + break; + case PR_BLOCK: + // We're stalled on writing the processed data. + return false; + case PR_COMPLETE: + // *error already contains the correct code. + return true; } } while (++loop_count <= kMaxReadCount); @@ -581,16 +573,14 @@ bool HttpBase::DoReceiveLoop(HttpError* error) { return false; } -void -HttpBase::read_and_process_data() { +void HttpBase::read_and_process_data() { HttpError error; if (DoReceiveLoop(&error)) { complete(error); } } -void -HttpBase::flush_data() { +void HttpBase::flush_data() { RTC_DCHECK(HM_SEND == mode_); // When send_required is true, no more buffering can occur without a network @@ -632,17 +622,16 @@ HttpBase::flush_data() { } else { size_t read; int error; - StreamResult result = data_->document->Read(buffer_ + offset, - sizeof(buffer_) - reserve, - &read, &error); + StreamResult result = data_->document->Read( + buffer_ + offset, sizeof(buffer_) - reserve, &read, &error); if (result == SR_SUCCESS) { RTC_DCHECK(reserve + read <= sizeof(buffer_)); if (chunk_data_) { // Prepend the chunk length in hex. // Note: sprintfn appends a null terminator, which is why we can't // combine it with the line terminator. - sprintfn(buffer_ + len_, kChunkDigits + 1, "%.*x", - kChunkDigits, read); + sprintfn(buffer_ + len_, kChunkDigits + 1, "%.*x", kChunkDigits, + read); // Add line terminator to the chunk length. memcpy(buffer_ + len_ + kChunkDigits, "\r\n", 2); // Add line terminator to the end of the chunk. @@ -709,14 +698,13 @@ HttpBase::flush_data() { RTC_NOTREACHED(); } -bool -HttpBase::queue_headers() { +bool HttpBase::queue_headers() { RTC_DCHECK(HM_SEND == mode_); while (header_ != data_->end()) { - size_t len = sprintfn(buffer_ + len_, sizeof(buffer_) - len_, - "%.*s: %.*s\r\n", - header_->first.size(), header_->first.data(), - header_->second.size(), header_->second.data()); + size_t len = + sprintfn(buffer_ + len_, sizeof(buffer_) - len_, "%.*s: %.*s\r\n", + header_->first.size(), header_->first.data(), + header_->second.size(), header_->second.data()); if (len_ + len < sizeof(buffer_) - 3) { len_ += len; ++header_; @@ -734,8 +722,7 @@ HttpBase::queue_headers() { return false; } -void -HttpBase::do_complete(HttpError err) { +void HttpBase::do_complete(HttpError err) { RTC_DCHECK(mode_ != HM_NONE); HttpMode mode = mode_; mode_ = HM_NONE; @@ -759,8 +746,9 @@ HttpBase::do_complete(HttpError err) { // Stream Signals // -void -HttpBase::OnHttpStreamEvent(StreamInterface* stream, int events, int error) { +void HttpBase::OnHttpStreamEvent(StreamInterface* stream, + int events, + int error) { RTC_DCHECK(stream == http_stream_); if ((events & SE_OPEN) && (mode_ == HM_CONNECT)) { do_complete(); @@ -794,8 +782,7 @@ HttpBase::OnHttpStreamEvent(StreamInterface* stream, int events, int error) { } } -void -HttpBase::OnDocumentEvent(StreamInterface* stream, int events, int error) { +void HttpBase::OnDocumentEvent(StreamInterface* stream, int events, int error) { RTC_DCHECK(stream == data_->document.get()); if ((events & SE_WRITE) && (mode_ == HM_RECV)) { read_and_process_data(); @@ -818,23 +805,26 @@ HttpBase::OnDocumentEvent(StreamInterface* stream, int events, int error) { // HttpParser Implementation // -HttpParser::ProcessResult -HttpBase::ProcessLeader(const char* line, size_t len, HttpError* error) { +HttpParser::ProcessResult HttpBase::ProcessLeader(const char* line, + size_t len, + HttpError* error) { *error = data_->parseLeader(line, len); return (HE_NONE == *error) ? PR_CONTINUE : PR_COMPLETE; } -HttpParser::ProcessResult -HttpBase::ProcessHeader(const char* name, size_t nlen, const char* value, - size_t vlen, HttpError* error) { +HttpParser::ProcessResult HttpBase::ProcessHeader(const char* name, + size_t nlen, + const char* value, + size_t vlen, + HttpError* error) { std::string sname(name, nlen), svalue(value, vlen); data_->addHeader(sname, svalue); return PR_CONTINUE; } -HttpParser::ProcessResult -HttpBase::ProcessHeaderComplete(bool chunked, size_t& data_size, - HttpError* error) { +HttpParser::ProcessResult HttpBase::ProcessHeaderComplete(bool chunked, + size_t& data_size, + HttpError* error) { StreamInterface* old_docstream = doc_stream_; if (notify_) { *error = notify_->onHttpHeaderComplete(chunked, data_size); @@ -854,35 +844,35 @@ HttpBase::ProcessHeaderComplete(bool chunked, size_t& data_size, return PR_CONTINUE; } -HttpParser::ProcessResult -HttpBase::ProcessData(const char* data, size_t len, size_t& read, - HttpError* error) { +HttpParser::ProcessResult HttpBase::ProcessData(const char* data, + size_t len, + size_t& read, + HttpError* error) { if (ignore_data_ || !data_->document) { read = len; return PR_CONTINUE; } int write_error = 0; switch (data_->document->Write(data, len, &read, &write_error)) { - case SR_SUCCESS: - return PR_CONTINUE; - case SR_BLOCK: - return PR_BLOCK; - case SR_EOS: - RTC_LOG_F(LS_ERROR) << "Unexpected EOS"; - *error = HE_STREAM; - return PR_COMPLETE; - case SR_ERROR: - default: - RTC_LOG_F(LS_ERROR) << "Write error: " << write_error; - *error = HE_STREAM; - return PR_COMPLETE; + case SR_SUCCESS: + return PR_CONTINUE; + case SR_BLOCK: + return PR_BLOCK; + case SR_EOS: + RTC_LOG_F(LS_ERROR) << "Unexpected EOS"; + *error = HE_STREAM; + return PR_COMPLETE; + case SR_ERROR: + default: + RTC_LOG_F(LS_ERROR) << "Write error: " << write_error; + *error = HE_STREAM; + return PR_COMPLETE; } } -void -HttpBase::OnComplete(HttpError err) { +void HttpBase::OnComplete(HttpError err) { RTC_LOG_F(LS_VERBOSE); do_complete(err); } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/httpbase.h b/rtc_base/httpbase.h index 5ca0134c34..25a11ab0fa 100644 --- a/rtc_base/httpbase.h +++ b/rtc_base/httpbase.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef RTC_BASE_HTTPBASE_H_ #define RTC_BASE_HTTPBASE_H_ @@ -26,39 +25,51 @@ class StreamInterface; /////////////////////////////////////////////////////////////////////////////// class HttpParser { -public: + public: enum ProcessResult { PR_CONTINUE, PR_BLOCK, PR_COMPLETE }; HttpParser(); virtual ~HttpParser(); void reset(); - ProcessResult Process(const char* buffer, size_t len, size_t* processed, + ProcessResult Process(const char* buffer, + size_t len, + size_t* processed, HttpError* error); bool is_valid_end_of_input() const; void complete(HttpError err); size_t GetDataRemaining() const { return data_size_; } -protected: + protected: ProcessResult ProcessLine(const char* line, size_t len, HttpError* error); // HttpParser Interface - virtual ProcessResult ProcessLeader(const char* line, size_t len, + virtual ProcessResult ProcessLeader(const char* line, + size_t len, HttpError* error) = 0; - virtual ProcessResult ProcessHeader(const char* name, size_t nlen, - const char* value, size_t vlen, + virtual ProcessResult ProcessHeader(const char* name, + size_t nlen, + const char* value, + size_t vlen, HttpError* error) = 0; - virtual ProcessResult ProcessHeaderComplete(bool chunked, size_t& data_size, + virtual ProcessResult ProcessHeaderComplete(bool chunked, + size_t& data_size, HttpError* error) = 0; - virtual ProcessResult ProcessData(const char* data, size_t len, size_t& read, + virtual ProcessResult ProcessData(const char* data, + size_t len, + size_t& read, HttpError* error) = 0; virtual void OnComplete(HttpError err) = 0; -private: + private: enum State { - ST_LEADER, ST_HEADERS, - ST_CHUNKSIZE, ST_CHUNKTERM, ST_TRAILERS, - ST_DATA, ST_COMPLETE + ST_LEADER, + ST_HEADERS, + ST_CHUNKSIZE, + ST_CHUNKTERM, + ST_TRAILERS, + ST_DATA, + ST_COMPLETE } state_; bool chunked_; size_t data_size_; @@ -71,7 +82,7 @@ private: enum HttpMode { HM_NONE, HM_CONNECT, HM_RECV, HM_SEND }; class IHttpNotify { -public: + public: virtual ~IHttpNotify() {} virtual HttpError onHttpHeaderComplete(bool chunked, size_t& data_size) = 0; virtual void onHttpComplete(HttpMode mode, HttpError err) = 0; @@ -88,11 +99,8 @@ public: // stream interface drives I/O via calls to Read(). /////////////////////////////////////////////////////////////////////////////// -class HttpBase -: private HttpParser, - public sigslot::has_slots<> -{ -public: +class HttpBase : private HttpParser, public sigslot::has_slots<> { + public: HttpBase(); ~HttpBase() override; @@ -116,7 +124,7 @@ public: // Further calls will return null. StreamInterface* GetDocumentStream(); -protected: + protected: // Do cleanup when the http stream closes (error may be 0 for a clean // shutdown), and return the error code to signal. HttpError HandleStreamClose(int error); @@ -162,7 +170,7 @@ protected: HttpError* error) override; void OnComplete(HttpError err) override; -private: + private: class DocumentStream; friend class DocumentStream; @@ -182,6 +190,6 @@ private: /////////////////////////////////////////////////////////////////////////////// -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_HTTPBASE_H_ +#endif // RTC_BASE_HTTPBASE_H_ diff --git a/rtc_base/httpbase_unittest.cc b/rtc_base/httpbase_unittest.cc index 1b7ab7f8e9..260fb9b98a 100644 --- a/rtc_base/httpbase_unittest.cc +++ b/rtc_base/httpbase_unittest.cc @@ -17,35 +17,35 @@ namespace rtc { const char* const kHttpResponse = - "HTTP/1.1 200\r\n" - "Connection: Keep-Alive\r\n" - "Content-Type: text/plain\r\n" - "Proxy-Authorization: 42\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "00000008\r\n" - "Goodbye!\r\n" - "0\r\n\r\n"; + "HTTP/1.1 200\r\n" + "Connection: Keep-Alive\r\n" + "Content-Type: text/plain\r\n" + "Proxy-Authorization: 42\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "00000008\r\n" + "Goodbye!\r\n" + "0\r\n\r\n"; const char* const kHttpEmptyResponse = - "HTTP/1.1 200\r\n" - "Connection: Keep-Alive\r\n" - "Content-Length: 0\r\n" - "Proxy-Authorization: 42\r\n" - "\r\n"; + "HTTP/1.1 200\r\n" + "Connection: Keep-Alive\r\n" + "Content-Length: 0\r\n" + "Proxy-Authorization: 42\r\n" + "\r\n"; const char* const kHttpResponsePrefix = - "HTTP/1.1 200\r\n" - "Connection: Keep-Alive\r\n" - "Content-Type: text/plain\r\n" - "Proxy-Authorization: 42\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "8\r\n" - "Goodbye!\r\n"; + "HTTP/1.1 200\r\n" + "Connection: Keep-Alive\r\n" + "Content-Type: text/plain\r\n" + "Proxy-Authorization: 42\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "8\r\n" + "Goodbye!\r\n"; class HttpBaseTest : public testing::Test, public IHttpNotify { -public: + public: enum EventType { E_HEADER_COMPLETE, E_COMPLETE, E_CLOSED }; struct Event { EventType event; @@ -64,7 +64,7 @@ public: HttpError onHttpHeaderComplete(bool chunked, size_t& data_size) override { RTC_LOG_F(LS_VERBOSE) << "chunked: " << chunked << " size: " << data_size; - Event e = { E_HEADER_COMPLETE, chunked, data_size, HM_NONE, HE_NONE}; + Event e = {E_HEADER_COMPLETE, chunked, data_size, HM_NONE, HE_NONE}; events.push_back(e); if (obtain_stream) { ObtainDocumentStream(); @@ -73,12 +73,12 @@ public: } void onHttpComplete(HttpMode mode, HttpError err) override { RTC_LOG_F(LS_VERBOSE) << "mode: " << mode << " err: " << err; - Event e = { E_COMPLETE, false, 0, mode, err }; + Event e = {E_COMPLETE, false, 0, mode, err}; events.push_back(e); } void onHttpClosed(HttpError err) override { RTC_LOG_F(LS_VERBOSE) << "err: " << err; - Event e = { E_CLOSED, false, 0, HM_NONE, err }; + Event e = {E_CLOSED, false, 0, HM_NONE, err}; events.push_back(e); } @@ -200,7 +200,7 @@ void HttpBaseTest::VerifyDocumentStreamIsOpening() { EXPECT_EQ(SS_OPENING, http_stream->GetState()); size_t read = 0; - char buffer[5] = { 0 }; + char buffer[5] = {0}; EXPECT_EQ(SR_BLOCK, http_stream->Read(buffer, sizeof(buffer), &read, nullptr)); RTC_LOG_F(LS_VERBOSE) << "Exit"; @@ -230,7 +230,7 @@ void HttpBaseTest::ReadDocumentStreamData(const char* expected_data) { const size_t expected_length = strlen(expected_data); while (verified_length < expected_length) { size_t read = 0; - char buffer[5] = { 0 }; + char buffer[5] = {0}; size_t amt_to_read = std::min(expected_length - verified_length, sizeof(buffer)); EXPECT_EQ(SR_SUCCESS, @@ -247,7 +247,7 @@ void HttpBaseTest::VerifyDocumentStreamIsEOS() { ASSERT_TRUE(nullptr != http_stream); size_t read = 0; - char buffer[5] = { 0 }; + char buffer[5] = {0}; EXPECT_EQ(SR_EOS, http_stream->Read(buffer, sizeof(buffer), &read, nullptr)); EXPECT_EQ(SS_CLOSED, http_stream->GetState()); @@ -403,12 +403,10 @@ TEST_F(HttpBaseTest, SupportsReceiveViaStreamPull) { } TEST_F(HttpBaseTest, DISABLED_AllowsCloseStreamBeforeDocumentIsComplete) { - // TODO: Remove extra logging once test failure is understood LoggingSeverity old_sev = rtc::LogMessage::GetLogToDebug(); rtc::LogMessage::LogToDebug(LS_VERBOSE); - // Switch to pull mode ObtainDocumentStream(); VerifyDocumentStreamIsOpening(); @@ -511,7 +509,7 @@ TEST_F(HttpBaseTest, SignalsDocumentStreamCloseOnUnexpectedClose) { // Future reads give an error int error = 0; - char buffer[5] = { 0 }; + char buffer[5] = {0}; EXPECT_EQ(SR_ERROR, http_stream->Read(buffer, sizeof(buffer), nullptr, &error)); EXPECT_EQ(HE_DISCONNECTED, error); @@ -522,4 +520,4 @@ TEST_F(HttpBaseTest, SignalsDocumentStreamCloseOnUnexpectedClose) { VerifyDocumentContents(""); } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/httpcommon-inl.h b/rtc_base/httpcommon-inl.h index 70263daf88..bb72357c80 100644 --- a/rtc_base/httpcommon-inl.h +++ b/rtc_base/httpcommon-inl.h @@ -21,13 +21,15 @@ namespace rtc { // Url /////////////////////////////////////////////////////////////////////////////// -template +template void Url::do_set_url(const CTYPE* val, size_t len) { if (ascnicmp(val, "http://", 7) == 0) { - val += 7; len -= 7; + val += 7; + len -= 7; secure_ = false; } else if (ascnicmp(val, "https://", 8) == 0) { - val += 8; len -= 8; + val += 8; + len -= 8; secure_ = true; } else { clear(); @@ -42,7 +44,7 @@ void Url::do_set_url(const CTYPE* val, size_t len) { do_set_full_path(path, len - address_length); } -template +template void Url::do_set_address(const CTYPE* val, size_t len) { if (const CTYPE* at = strchrn(val, len, static_cast('@'))) { // Everything before the @ is a user:password combo, so skip it. @@ -61,7 +63,7 @@ void Url::do_set_address(const CTYPE* val, size_t len) { } } -template +template void Url::do_set_full_path(const CTYPE* val, size_t len) { const CTYPE* query = strchrn(val, len, static_cast('?')); if (!query) { @@ -78,7 +80,7 @@ void Url::do_set_full_path(const CTYPE* val, size_t len) { query_.assign(query, len - path_length); } -template +template void Url::do_get_url(string* val) const { CTYPE protocol[9]; asccpyn(protocol, arraysize(protocol), secure_ ? "https://" : "http://"); @@ -87,7 +89,7 @@ void Url::do_get_url(string* val) const { do_get_full_path(val); } -template +template void Url::do_get_address(string* val) const { val->append(host_); if (port_ != HttpDefaultPort(secure_)) { @@ -98,13 +100,13 @@ void Url::do_get_address(string* val) const { } } -template +template void Url::do_get_full_path(string* val) const { val->append(path_); val->append(query_); } -template +template bool Url::get_attribute(const string& name, string* value) const { if (query_.empty()) return false; @@ -114,7 +116,7 @@ bool Url::get_attribute(const string& name, string* value) const { return false; pos += name.length() + 1; - if ((pos > query_.length()) || (static_cast('=') != query_[pos-1])) + if ((pos > query_.length()) || (static_cast('=') != query_[pos - 1])) return false; std::string::size_type end = query_.find(static_cast('&'), pos); diff --git a/rtc_base/httpcommon.cc b/rtc_base/httpcommon.cc index f23cb63a6e..5ac1e42dbb 100644 --- a/rtc_base/httpcommon.cc +++ b/rtc_base/httpcommon.cc @@ -47,7 +47,10 @@ namespace { // int err = LibraryFunc(); // LOG(LS_ERROR) << "LibraryFunc returned: " // << GetErrorName(err, LIBRARY_ERRORS); -struct ConstantToLabel { int value; const char * label; }; +struct ConstantToLabel { + int value; + const char* label; +}; const char* LookupLabel(int value, const ConstantToLabel entries[]) { for (int i = 0; entries[i].label; ++i) { @@ -72,35 +75,36 @@ std::string GetErrorName(int err, const ConstantToLabel* err_table) { return buffer; } -#define KLABEL(x) { x, #x } -#define LASTLABEL { 0, 0 } +#define KLABEL(x) \ + { x, #x } +#define LASTLABEL \ + { 0, 0 } const ConstantToLabel SECURITY_ERRORS[] = { - KLABEL(SEC_I_COMPLETE_AND_CONTINUE), - KLABEL(SEC_I_COMPLETE_NEEDED), - KLABEL(SEC_I_CONTEXT_EXPIRED), - KLABEL(SEC_I_CONTINUE_NEEDED), - KLABEL(SEC_I_INCOMPLETE_CREDENTIALS), - KLABEL(SEC_I_RENEGOTIATE), - KLABEL(SEC_E_CERT_EXPIRED), - KLABEL(SEC_E_INCOMPLETE_MESSAGE), - KLABEL(SEC_E_INSUFFICIENT_MEMORY), - KLABEL(SEC_E_INTERNAL_ERROR), - KLABEL(SEC_E_INVALID_HANDLE), - KLABEL(SEC_E_INVALID_TOKEN), - KLABEL(SEC_E_LOGON_DENIED), - KLABEL(SEC_E_NO_AUTHENTICATING_AUTHORITY), - KLABEL(SEC_E_NO_CREDENTIALS), - KLABEL(SEC_E_NOT_OWNER), - KLABEL(SEC_E_OK), - KLABEL(SEC_E_SECPKG_NOT_FOUND), - KLABEL(SEC_E_TARGET_UNKNOWN), - KLABEL(SEC_E_UNKNOWN_CREDENTIALS), - KLABEL(SEC_E_UNSUPPORTED_FUNCTION), - KLABEL(SEC_E_UNTRUSTED_ROOT), - KLABEL(SEC_E_WRONG_PRINCIPAL), - LASTLABEL -}; + KLABEL(SEC_I_COMPLETE_AND_CONTINUE), + KLABEL(SEC_I_COMPLETE_NEEDED), + KLABEL(SEC_I_CONTEXT_EXPIRED), + KLABEL(SEC_I_CONTINUE_NEEDED), + KLABEL(SEC_I_INCOMPLETE_CREDENTIALS), + KLABEL(SEC_I_RENEGOTIATE), + KLABEL(SEC_E_CERT_EXPIRED), + KLABEL(SEC_E_INCOMPLETE_MESSAGE), + KLABEL(SEC_E_INSUFFICIENT_MEMORY), + KLABEL(SEC_E_INTERNAL_ERROR), + KLABEL(SEC_E_INVALID_HANDLE), + KLABEL(SEC_E_INVALID_TOKEN), + KLABEL(SEC_E_LOGON_DENIED), + KLABEL(SEC_E_NO_AUTHENTICATING_AUTHORITY), + KLABEL(SEC_E_NO_CREDENTIALS), + KLABEL(SEC_E_NOT_OWNER), + KLABEL(SEC_E_OK), + KLABEL(SEC_E_SECPKG_NOT_FOUND), + KLABEL(SEC_E_TARGET_UNKNOWN), + KLABEL(SEC_E_UNKNOWN_CREDENTIALS), + KLABEL(SEC_E_UNSUPPORTED_FUNCTION), + KLABEL(SEC_E_UNTRUSTED_ROOT), + KLABEL(SEC_E_WRONG_PRINCIPAL), + LASTLABEL}; #undef KLABEL #undef LASTLABEL #endif // defined(WEBRTC_WIN) @@ -110,9 +114,11 @@ const ConstantToLabel SECURITY_ERRORS[] = { // Enum - TODO: expose globally later? ////////////////////////////////////////////////////////////////////// -bool find_string(size_t& index, const std::string& needle, - const char* const haystack[], size_t max_index) { - for (index=0; index +template struct Enum { static const char** Names; static size_t Size; @@ -137,60 +143,65 @@ struct Enum { E val; inline operator E&() { return val; } - inline Enum& operator=(E rhs) { val = rhs; return *this; } + inline Enum& operator=(E rhs) { + val = rhs; + return *this; + } inline const char* name() const { return Name(val); } inline bool assign(const std::string& name) { return Parse(val, name); } - inline Enum& operator=(const std::string& rhs) { assign(rhs); return *this; } + inline Enum& operator=(const std::string& rhs) { + assign(rhs); + return *this; + } }; -#define ENUM(e,n) \ - template<> const char** Enum::Names = n; \ - template<> size_t Enum::Size = sizeof(n)/sizeof(n[0]) +#define ENUM(e, n) \ + template <> \ + const char** Enum::Names = n; \ + template <> \ + size_t Enum::Size = sizeof(n) / sizeof(n[0]) ////////////////////////////////////////////////////////////////////// // HttpCommon ////////////////////////////////////////////////////////////////////// -static const char* kHttpVersions[HVER_LAST+1] = { - "1.0", "1.1", "Unknown" -}; +static const char* kHttpVersions[HVER_LAST + 1] = {"1.0", "1.1", "Unknown"}; ENUM(HttpVersion, kHttpVersions); -static const char* kHttpVerbs[HV_LAST+1] = { - "GET", "POST", "PUT", "DELETE", "CONNECT", "HEAD" -}; +static const char* kHttpVerbs[HV_LAST + 1] = {"GET", "POST", "PUT", + "DELETE", "CONNECT", "HEAD"}; ENUM(HttpVerb, kHttpVerbs); -static const char* kHttpHeaders[HH_LAST+1] = { - "Age", - "Cache-Control", - "Connection", - "Content-Disposition", - "Content-Length", - "Content-Range", - "Content-Type", - "Cookie", - "Date", - "ETag", - "Expires", - "Host", - "If-Modified-Since", - "If-None-Match", - "Keep-Alive", - "Last-Modified", - "Location", - "Proxy-Authenticate", - "Proxy-Authorization", - "Proxy-Connection", - "Range", - "Set-Cookie", - "TE", - "Trailers", - "Transfer-Encoding", - "Upgrade", - "User-Agent", - "WWW-Authenticate", +static const char* kHttpHeaders[HH_LAST + 1] = { + "Age", + "Cache-Control", + "Connection", + "Content-Disposition", + "Content-Length", + "Content-Range", + "Content-Type", + "Cookie", + "Date", + "ETag", + "Expires", + "Host", + "If-Modified-Since", + "If-None-Match", + "Keep-Alive", + "Last-Modified", + "Location", + "Proxy-Authenticate", + "Proxy-Authorization", + "Proxy-Connection", + "Range", + "Set-Cookie", + "TE", + "Trailers", + "Transfer-Encoding", + "Upgrade", + "User-Agent", + "WWW-Authenticate", }; ENUM(HttpHeader, kHttpHeaders); @@ -219,56 +230,57 @@ bool FromString(HttpHeader& header, const std::string& str) { } bool HttpCodeHasBody(uint32_t code) { - return !HttpCodeIsInformational(code) - && (code != HC_NO_CONTENT) && (code != HC_NOT_MODIFIED); + return !HttpCodeIsInformational(code) && (code != HC_NO_CONTENT) && + (code != HC_NOT_MODIFIED); } bool HttpCodeIsCacheable(uint32_t code) { switch (code) { - case HC_OK: - case HC_NON_AUTHORITATIVE: - case HC_PARTIAL_CONTENT: - case HC_MULTIPLE_CHOICES: - case HC_MOVED_PERMANENTLY: - case HC_GONE: - return true; - default: - return false; + case HC_OK: + case HC_NON_AUTHORITATIVE: + case HC_PARTIAL_CONTENT: + case HC_MULTIPLE_CHOICES: + case HC_MOVED_PERMANENTLY: + case HC_GONE: + return true; + default: + return false; } } bool HttpHeaderIsEndToEnd(HttpHeader header) { switch (header) { - case HH_CONNECTION: - case HH_KEEP_ALIVE: - case HH_PROXY_AUTHENTICATE: - case HH_PROXY_AUTHORIZATION: - case HH_PROXY_CONNECTION: // Note part of RFC... this is non-standard header - case HH_TE: - case HH_TRAILERS: - case HH_TRANSFER_ENCODING: - case HH_UPGRADE: - return false; - default: - return true; + case HH_CONNECTION: + case HH_KEEP_ALIVE: + case HH_PROXY_AUTHENTICATE: + case HH_PROXY_AUTHORIZATION: + case HH_PROXY_CONNECTION: // Note part of RFC... this is non-standard + // header + case HH_TE: + case HH_TRAILERS: + case HH_TRANSFER_ENCODING: + case HH_UPGRADE: + return false; + default: + return true; } } bool HttpHeaderIsCollapsible(HttpHeader header) { switch (header) { - case HH_SET_COOKIE: - case HH_PROXY_AUTHENTICATE: - case HH_WWW_AUTHENTICATE: - return false; - default: - return true; + case HH_SET_COOKIE: + case HH_PROXY_AUTHENTICATE: + case HH_WWW_AUTHENTICATE: + return false; + default: + return true; } } bool HttpShouldKeepAlive(const HttpData& data) { std::string connection; - if ((data.hasHeader(HH_PROXY_CONNECTION, &connection) - || data.hasHeader(HH_CONNECTION, &connection))) { + if ((data.hasHeader(HH_PROXY_CONNECTION, &connection) || + data.hasHeader(HH_CONNECTION, &connection))) { return (_stricmp(connection.c_str(), "Keep-Alive") == 0); } return (data.version >= HVER_1_1); @@ -276,16 +288,16 @@ bool HttpShouldKeepAlive(const HttpData& data) { namespace { -inline bool IsEndOfAttributeName(size_t pos, size_t len, const char * data) { +inline bool IsEndOfAttributeName(size_t pos, size_t len, const char* data) { if (pos >= len) return true; if (isspace(static_cast(data[pos]))) return true; // The reason for this complexity is that some attributes may contain trailing // equal signs (like base64 tokens in Negotiate auth headers) - if ((pos+1 < len) && (data[pos] == '=') && - !isspace(static_cast(data[pos+1])) && - (data[pos+1] != '=')) { + if ((pos + 1 < len) && (data[pos] == '=') && + !isspace(static_cast(data[pos + 1])) && + (data[pos + 1] != '=')) { return true; } return false; @@ -293,7 +305,8 @@ inline bool IsEndOfAttributeName(size_t pos, size_t len, const char * data) { } // anonymous namespace -void HttpParseAttributes(const char * data, size_t len, +void HttpParseAttributes(const char* data, + size_t len, HttpAttributeList& attributes) { size_t pos = 0; while (true) { @@ -317,7 +330,7 @@ void HttpParseAttributes(const char * data, size_t len, // Attribute has value? if ((pos < len) && (data[pos] == '=')) { - ++pos; // Skip '=' + ++pos; // Skip '=' // Check if quoted value if ((pos < len) && (data[pos] == '"')) { while (++pos < len) { @@ -330,16 +343,16 @@ void HttpParseAttributes(const char * data, size_t len, attribute.second.append(1, data[pos]); } } else { - while ((pos < len) && - !isspace(static_cast(data[pos])) && - (data[pos] != ',')) { + while ((pos < len) && !isspace(static_cast(data[pos])) && + (data[pos] != ',')) { attribute.second.append(1, data[pos++]); } } } attributes.push_back(attribute); - if ((pos < len) && (data[pos] == ',')) ++pos; // Skip ',' + if ((pos < len) && (data[pos] == ',')) + ++pos; // Skip ',' } } @@ -374,15 +387,13 @@ bool HttpHasNthAttribute(HttpAttributeList& attributes, bool HttpDateToSeconds(const std::string& date, time_t* seconds) { const char* const kTimeZones[] = { - "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", - "A", "B", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", - "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y" - }; + "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", + "PDT", "A", "B", "C", "D", "E", "F", "G", "H", + "I", "K", "L", "M", "N", "O", "P", "Q", "R", + "S", "T", "U", "V", "W", "X", "Y"}; const int kTimeZoneOffsets[] = { - 0, 0, -5, -4, -6, -5, -7, -6, -8, -7, - -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 - }; + 0, 0, -5, -4, -6, -5, -7, -6, -8, -7, -1, -2, -3, -4, -5, -6, -7, + -8, -9, -10, -11, -12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; RTC_DCHECK(nullptr != seconds); struct tm tval; @@ -391,28 +402,48 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) { memset(month, 0, sizeof(month)); memset(zone, 0, sizeof(zone)); - if (7 != sscanf(date.c_str(), "%*3s, %d %3s %d %d:%d:%d %5c", - &tval.tm_mday, month, &tval.tm_year, - &tval.tm_hour, &tval.tm_min, &tval.tm_sec, zone)) { + if (7 != sscanf(date.c_str(), "%*3s, %d %3s %d %d:%d:%d %5c", &tval.tm_mday, + month, &tval.tm_year, &tval.tm_hour, &tval.tm_min, + &tval.tm_sec, zone)) { return false; } switch (toupper(month[2])) { - case 'N': tval.tm_mon = (month[1] == 'A') ? 0 : 5; break; - case 'B': tval.tm_mon = 1; break; - case 'R': tval.tm_mon = (month[0] == 'M') ? 2 : 3; break; - case 'Y': tval.tm_mon = 4; break; - case 'L': tval.tm_mon = 6; break; - case 'G': tval.tm_mon = 7; break; - case 'P': tval.tm_mon = 8; break; - case 'T': tval.tm_mon = 9; break; - case 'V': tval.tm_mon = 10; break; - case 'C': tval.tm_mon = 11; break; + case 'N': + tval.tm_mon = (month[1] == 'A') ? 0 : 5; + break; + case 'B': + tval.tm_mon = 1; + break; + case 'R': + tval.tm_mon = (month[0] == 'M') ? 2 : 3; + break; + case 'Y': + tval.tm_mon = 4; + break; + case 'L': + tval.tm_mon = 6; + break; + case 'G': + tval.tm_mon = 7; + break; + case 'P': + tval.tm_mon = 8; + break; + case 'T': + tval.tm_mon = 9; + break; + case 'V': + tval.tm_mon = 10; + break; + case 'C': + tval.tm_mon = 11; + break; } tval.tm_year -= 1900; time_t gmt, non_gmt = mktime(&tval); if ((zone[0] == '+') || (zone[0] == '-')) { - if (!isdigit(zone[1]) || !isdigit(zone[2]) - || !isdigit(zone[3]) || !isdigit(zone[4])) { + if (!isdigit(zone[1]) || !isdigit(zone[2]) || !isdigit(zone[3]) || + !isdigit(zone[4])) { return false; } int hours = (zone[1] - '0') * 10 + (zone[2] - '0'); @@ -426,9 +457,10 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) { } gmt = non_gmt + kTimeZoneOffsets[zindex] * 60 * 60; } - // TODO: Android should support timezone, see b/2441195 -#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID) || defined(BSD) - tm *tm_for_timezone = localtime(&gmt); +// TODO: Android should support timezone, see b/2441195 +#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID) || \ + defined(BSD) + tm* tm_for_timezone = localtime(&gmt); *seconds = gmt + tm_for_timezone->tm_gmtoff; #else #if defined(_MSC_VER) && _MSC_VER >= 1900 @@ -441,21 +473,19 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) { } std::string HttpAddress(const SocketAddress& address, bool secure) { - return (address.port() == HttpDefaultPort(secure)) - ? address.hostname() : address.ToString(); + return (address.port() == HttpDefaultPort(secure)) ? address.hostname() + : address.ToString(); } ////////////////////////////////////////////////////////////////////// // HttpData ////////////////////////////////////////////////////////////////////// -HttpData::HttpData() : version(HVER_1_1) { -} +HttpData::HttpData() : version(HVER_1_1) {} HttpData::~HttpData() = default; -void -HttpData::clear(bool release_document) { +void HttpData::clear(bool release_document) { // Clear headers first, since releasing a document may have far-reaching // effects. headers_.clear(); @@ -464,19 +494,19 @@ HttpData::clear(bool release_document) { } } -void -HttpData::copy(const HttpData& src) { +void HttpData::copy(const HttpData& src) { headers_ = src.headers_; } -void -HttpData::changeHeader(const std::string& name, const std::string& value, - HeaderCombine combine) { +void HttpData::changeHeader(const std::string& name, + const std::string& value, + HeaderCombine combine) { if (combine == HC_AUTO) { HttpHeader header; // Unrecognized headers are collapsible combine = !FromString(header, name) || HttpHeaderIsCollapsible(header) - ? HC_YES : HC_NO; + ? HC_YES + : HC_NO; } else if (combine == HC_REPLACE) { headers_.erase(name); combine = HC_NO; @@ -505,8 +535,7 @@ HttpData::iterator HttpData::clearHeader(iterator header) { return header; } -bool -HttpData::hasHeader(const std::string& name, std::string* value) const { +bool HttpData::hasHeader(const std::string& name, std::string* value) const { HeaderMap::const_iterator it = headers_.find(name); if (it == headers_.end()) { return false; @@ -542,38 +571,34 @@ void HttpData::setDocumentAndLength(StreamInterface* document) { // HttpRequestData // -void -HttpRequestData::clear(bool release_document) { +void HttpRequestData::clear(bool release_document) { verb = HV_GET; path.clear(); HttpData::clear(release_document); } -void -HttpRequestData::copy(const HttpRequestData& src) { +void HttpRequestData::copy(const HttpRequestData& src) { verb = src.verb; path = src.path; HttpData::copy(src); } -size_t -HttpRequestData::formatLeader(char* buffer, size_t size) const { +size_t HttpRequestData::formatLeader(char* buffer, size_t size) const { RTC_DCHECK(path.find(' ') == std::string::npos); return sprintfn(buffer, size, "%s %.*s HTTP/%s", ToString(verb), path.size(), path.data(), ToString(version)); } -HttpError -HttpRequestData::parseLeader(const char* line, size_t len) { +HttpError HttpRequestData::parseLeader(const char* line, size_t len) { unsigned int vmajor, vminor; int vend, dstart, dend; // sscanf isn't safe with strings that aren't null-terminated, and there is // no guarantee that |line| is. Create a local copy that is null-terminated. std::string line_str(line, len); line = line_str.c_str(); - if ((sscanf(line, "%*s%n %n%*s%n HTTP/%u.%u", - &vend, &dstart, &dend, &vmajor, &vminor) != 2) - || (vmajor != 1)) { + if ((sscanf(line, "%*s%n %n%*s%n HTTP/%u.%u", &vend, &dstart, &dend, &vmajor, + &vminor) != 2) || + (vmajor != 1)) { return HE_PROTOCOL; } if (vminor == 0) { @@ -585,7 +610,7 @@ HttpRequestData::parseLeader(const char* line, size_t len) { } std::string sverb(line, vend); if (!FromString(verb, sverb.c_str())) { - return HE_PROTOCOL; // !?! HC_METHOD_NOT_SUPPORTED? + return HE_PROTOCOL; // !?! HC_METHOD_NOT_SUPPORTED? } path.assign(line + dstart, line + dend); return HE_NONE; @@ -609,8 +634,7 @@ bool HttpRequestData::getAbsoluteUri(std::string* uri) const { } bool HttpRequestData::getRelativeUri(std::string* host, - std::string* path) const -{ + std::string* path) const { if (HV_CONNECT == verb) return false; Url url(this->path); @@ -629,15 +653,13 @@ bool HttpRequestData::getRelativeUri(std::string* host, // HttpResponseData // -void -HttpResponseData::clear(bool release_document) { +void HttpResponseData::clear(bool release_document) { scode = HC_INTERNAL_SERVER_ERROR; message.clear(); HttpData::clear(release_document); } -void -HttpResponseData::copy(const HttpResponseData& src) { +void HttpResponseData::copy(const HttpResponseData& src) { scode = src.scode; message = src.message; HttpData::copy(src); @@ -671,18 +693,16 @@ void HttpResponseData::set_error(uint32_t scode) { setHeader(HH_CONTENT_LENGTH, "0", false); } -size_t -HttpResponseData::formatLeader(char* buffer, size_t size) const { +size_t HttpResponseData::formatLeader(char* buffer, size_t size) const { size_t len = sprintfn(buffer, size, "HTTP/%s %lu", ToString(version), scode); if (!message.empty()) { - len += sprintfn(buffer + len, size - len, " %.*s", - message.size(), message.data()); + len += sprintfn(buffer + len, size - len, " %.*s", message.size(), + message.data()); } return len; } -HttpError -HttpResponseData::parseLeader(const char* line, size_t len) { +HttpError HttpResponseData::parseLeader(const char* line, size_t len) { size_t pos = 0; unsigned int vmajor, vminor, temp_scode; int temp_pos; @@ -690,16 +710,15 @@ HttpResponseData::parseLeader(const char* line, size_t len) { // no guarantee that |line| is. Create a local copy that is null-terminated. std::string line_str(line, len); line = line_str.c_str(); - if (sscanf(line, "HTTP %u%n", - &temp_scode, &temp_pos) == 1) { + if (sscanf(line, "HTTP %u%n", &temp_scode, &temp_pos) == 1) { // This server's response has no version. :( NOTE: This happens for every // response to requests made from Chrome plugins, regardless of the server's // behaviour. RTC_LOG(LS_VERBOSE) << "HTTP version missing from response"; version = HVER_UNKNOWN; - } else if ((sscanf(line, "HTTP/%u.%u %u%n", - &vmajor, &vminor, &temp_scode, &temp_pos) == 3) - && (vmajor == 1)) { + } else if ((sscanf(line, "HTTP/%u.%u %u%n", &vmajor, &vminor, &temp_scode, + &temp_pos) == 3) && + (vmajor == 1)) { // This server's response does have a version. if (vminor == 0) { version = HVER_1_0; @@ -713,7 +732,8 @@ HttpResponseData::parseLeader(const char* line, size_t len) { } scode = temp_scode; pos = static_cast(temp_pos); - while ((pos < len) && isspace(static_cast(line[pos]))) ++pos; + while ((pos < len) && isspace(static_cast(line[pos]))) + ++pos; message.assign(line + pos, len - pos); return HE_NONE; } @@ -725,7 +745,7 @@ HttpResponseData::parseLeader(const char* line, size_t len) { std::string quote(const std::string& str) { std::string result; result.push_back('"'); - for (size_t i=0; i(context); + NegotiateAuthContext* neg = static_cast(context); if (neg) { const size_t max_steps = 10; if (++neg->steps >= max_steps) { @@ -927,16 +951,18 @@ HttpAuthResult HttpAuthenticate( Base64::Decode(challenge, Base64::DO_STRICT, &decoded_challenge, nullptr)) { SecBuffer in_sec; - in_sec.pvBuffer = const_cast(decoded_challenge.data()); - in_sec.cbBuffer = static_cast(decoded_challenge.size()); + in_sec.pvBuffer = const_cast(decoded_challenge.data()); + in_sec.cbBuffer = static_cast(decoded_challenge.size()); in_sec.BufferType = SECBUFFER_TOKEN; SecBufferDesc in_buf_desc; in_buf_desc.ulVersion = 0; - in_buf_desc.cBuffers = 1; - in_buf_desc.pBuffers = &in_sec; + in_buf_desc.cBuffers = 1; + in_buf_desc.pBuffers = &in_sec; - ret = InitializeSecurityContextA(&neg->cred, &neg->ctx, spn, flags, 0, SECURITY_NATIVE_DREP, &in_buf_desc, 0, &neg->ctx, &out_buf_desc, &ret_flags, &lifetime); + ret = InitializeSecurityContextA( + &neg->cred, &neg->ctx, spn, flags, 0, SECURITY_NATIVE_DREP, + &in_buf_desc, 0, &neg->ctx, &out_buf_desc, &ret_flags, &lifetime); if (FAILED(ret)) { RTC_LOG(LS_ERROR) << "InitializeSecurityContext returned: " << GetErrorName(ret, SECURITY_ERRORS); @@ -954,11 +980,11 @@ HttpAuthResult HttpAuthenticate( if (!neg) { unsigned char userbuf[256], passbuf[256], domainbuf[16]; - SEC_WINNT_AUTH_IDENTITY_A auth_id, * pauth_id = 0; + SEC_WINNT_AUTH_IDENTITY_A auth_id, *pauth_id = 0; if (specify_credentials) { memset(&auth_id, 0, sizeof(auth_id)); - size_t len = password.GetLength()+1; - char * sensitive = new char[len]; + size_t len = password.GetLength() + 1; + char* sensitive = new char[len]; password.CopyTo(sensitive, true); std::string::size_type pos = username.find('\\'); if (pos == std::string::npos) { @@ -987,7 +1013,7 @@ HttpAuthResult HttpAuthenticate( passbuf[auth_id.PasswordLength] = 0; } ExplicitZeroMemory(sensitive, len); - delete [] sensitive; + delete[] sensitive; auth_id.User = userbuf; auth_id.Domain = domainbuf; auth_id.Password = passbuf; @@ -1009,10 +1035,12 @@ HttpAuthResult HttpAuthenticate( return HAR_IGNORE; } - //CSecBufferBundle<5, CSecBufferBase::FreeSSPI> sb_out; + // CSecBufferBundle<5, CSecBufferBase::FreeSSPI> sb_out; CtxtHandle ctx; - ret = InitializeSecurityContextA(&cred, 0, spn, flags, 0, SECURITY_NATIVE_DREP, 0, 0, &ctx, &out_buf_desc, &ret_flags, &lifetime); + ret = InitializeSecurityContextA(&cred, 0, spn, flags, 0, + SECURITY_NATIVE_DREP, 0, 0, &ctx, + &out_buf_desc, &ret_flags, &lifetime); if (FAILED(ret)) { RTC_LOG(LS_ERROR) << "InitializeSecurityContext returned: " << GetErrorName(ret, SECURITY_ERRORS); @@ -1026,7 +1054,8 @@ HttpAuthResult HttpAuthenticate( neg->steps = steps; } - if ((ret == SEC_I_COMPLETE_NEEDED) || (ret == SEC_I_COMPLETE_AND_CONTINUE)) { + if ((ret == SEC_I_COMPLETE_NEEDED) || + (ret == SEC_I_COMPLETE_AND_CONTINUE)) { ret = CompleteAuthToken(&neg->ctx, &out_buf_desc); RTC_LOG(LS_VERBOSE) << "CompleteAuthToken returned: " << GetErrorName(ret, SECURITY_ERRORS); @@ -1042,11 +1071,11 @@ HttpAuthResult HttpAuthenticate( return HAR_RESPONSE; } #endif -#endif // WEBRTC_WIN +#endif // WEBRTC_WIN return HAR_IGNORE; } ////////////////////////////////////////////////////////////////////// -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/httpcommon.h b/rtc_base/httpcommon.h index 08b9a377ab..1b8768dfd2 100644 --- a/rtc_base/httpcommon.h +++ b/rtc_base/httpcommon.h @@ -54,29 +54,31 @@ enum HttpCode { HC_SERVICE_UNAVAILABLE = 503, }; -enum HttpVersion { - HVER_1_0, HVER_1_1, HVER_UNKNOWN, - HVER_LAST = HVER_UNKNOWN -}; +enum HttpVersion { HVER_1_0, HVER_1_1, HVER_UNKNOWN, HVER_LAST = HVER_UNKNOWN }; enum HttpVerb { - HV_GET, HV_POST, HV_PUT, HV_DELETE, HV_CONNECT, HV_HEAD, + HV_GET, + HV_POST, + HV_PUT, + HV_DELETE, + HV_CONNECT, + HV_HEAD, HV_LAST = HV_HEAD }; enum HttpError { HE_NONE, - HE_PROTOCOL, // Received non-valid HTTP data - HE_DISCONNECTED, // Connection closed unexpectedly - HE_OVERFLOW, // Received too much data for internal buffers - HE_CONNECT_FAILED, // The socket failed to connect. - HE_SOCKET_ERROR, // An error occurred on a connected socket - HE_SHUTDOWN, // Http object is being destroyed - HE_OPERATION_CANCELLED, // Connection aborted locally - HE_AUTH, // Proxy Authentication Required - HE_CERTIFICATE_EXPIRED, // During SSL negotiation - HE_STREAM, // Problem reading or writing to the document - HE_CACHE, // Problem reading from cache + HE_PROTOCOL, // Received non-valid HTTP data + HE_DISCONNECTED, // Connection closed unexpectedly + HE_OVERFLOW, // Received too much data for internal buffers + HE_CONNECT_FAILED, // The socket failed to connect. + HE_SOCKET_ERROR, // An error occurred on a connected socket + HE_SHUTDOWN, // Http object is being destroyed + HE_OPERATION_CANCELLED, // Connection aborted locally + HE_AUTH, // Proxy Authentication Required + HE_CERTIFICATE_EXPIRED, // During SSL negotiation + HE_STREAM, // Problem reading or writing to the document + HE_CACHE, // Problem reading from cache HE_DEFAULT }; @@ -158,7 +160,8 @@ bool HttpShouldKeepAlive(const HttpData& data); typedef std::pair HttpAttribute; typedef std::vector HttpAttributeList; -void HttpParseAttributes(const char * data, size_t len, +void HttpParseAttributes(const char* data, + size_t len, HttpAttributeList& attributes); bool HttpHasAttribute(const HttpAttributeList& attributes, const std::string& name, @@ -192,9 +195,9 @@ std::string quote(const std::string& str); // Url ////////////////////////////////////////////////////////////////////// -template +template class Url { -public: + public: typedef typename Traits::string string; // TODO: Implement Encode/Decode @@ -218,25 +221,29 @@ public: query_.clear(); } - void set_url(const string& val) { - do_set_url(val.c_str(), val.size()); - } + void set_url(const string& val) { do_set_url(val.c_str(), val.size()); } string url() const { - string val; do_get_url(&val); return val; + string val; + do_get_url(&val); + return val; } void set_address(const string& val) { do_set_address(val.c_str(), val.size()); } string address() const { - string val; do_get_address(&val); return val; + string val; + do_get_address(&val); + return val; } void set_full_path(const string& val) { do_set_full_path(val.c_str(), val.size()); } string full_path() const { - string val; do_get_full_path(&val); return val; + string val; + do_get_full_path(&val); + return val; } void set_host(const string& val) { host_ = val; } @@ -266,7 +273,7 @@ public: bool get_attribute(const string& name, string* value) const; -private: + private: void do_set_url(const CTYPE* val, size_t len); void do_set_address(const CTYPE* val, size_t len); void do_set_full_path(const CTYPE* val, size_t len); @@ -295,13 +302,16 @@ struct HttpData { HttpData(); enum HeaderCombine { HC_YES, HC_NO, HC_AUTO, HC_REPLACE, HC_NEW }; - void changeHeader(const std::string& name, const std::string& value, + void changeHeader(const std::string& name, + const std::string& value, HeaderCombine combine); - inline void addHeader(const std::string& name, const std::string& value, + inline void addHeader(const std::string& name, + const std::string& value, bool append = true) { changeHeader(name, value, append ? HC_AUTO : HC_NO); } - inline void setHeader(const std::string& name, const std::string& value, + inline void setHeader(const std::string& name, + const std::string& value, bool overwrite = true) { changeHeader(name, value, overwrite ? HC_REPLACE : HC_NEW); } @@ -313,18 +323,10 @@ struct HttpData { // keep in mind, this may not do what you want in the face of multiple headers bool hasHeader(const std::string& name, std::string* value) const; - inline const_iterator begin() const { - return headers_.begin(); - } - inline const_iterator end() const { - return headers_.end(); - } - inline iterator begin() { - return headers_.begin(); - } - inline iterator end() { - return headers_.end(); - } + inline const_iterator begin() const { return headers_.begin(); } + inline const_iterator end() const { return headers_.end(); } + inline iterator begin() { return headers_.begin(); } + inline iterator end() { return headers_.end(); } inline const_iterator begin(const std::string& name) const { return headers_.lower_bound(name); } @@ -339,21 +341,22 @@ struct HttpData { } // Convenience methods using HttpHeader - inline void changeHeader(HttpHeader header, const std::string& value, + inline void changeHeader(HttpHeader header, + const std::string& value, HeaderCombine combine) { changeHeader(ToString(header), value, combine); } - inline void addHeader(HttpHeader header, const std::string& value, + inline void addHeader(HttpHeader header, + const std::string& value, bool append = true) { addHeader(ToString(header), value, append); } - inline void setHeader(HttpHeader header, const std::string& value, + inline void setHeader(HttpHeader header, + const std::string& value, bool overwrite = true) { setHeader(ToString(header), value, overwrite); } - inline void clearHeader(HttpHeader header) { - clearHeader(ToString(header)); - } + inline void clearHeader(HttpHeader header) { clearHeader(ToString(header)); } inline bool hasHeader(HttpHeader header, std::string* value) const { return hasHeader(ToString(header), value); } @@ -376,12 +379,12 @@ struct HttpData { virtual size_t formatLeader(char* buffer, size_t size) const = 0; virtual HttpError parseLeader(const char* line, size_t len) = 0; -protected: - virtual ~HttpData(); + protected: + virtual ~HttpData(); void clear(bool release_document); void copy(const HttpData& src); -private: + private: HeaderMap headers_; }; @@ -389,7 +392,7 @@ struct HttpRequestData : public HttpData { HttpVerb verb; std::string path; - HttpRequestData() : verb(HV_GET) { } + HttpRequestData() : verb(HV_GET) {} void clear(bool release_document); void copy(const HttpRequestData& src); @@ -405,7 +408,7 @@ struct HttpResponseData : public HttpData { uint32_t scode; std::string message; - HttpResponseData() : scode(HC_INTERNAL_SERVER_ERROR) { } + HttpResponseData() : scode(HC_INTERNAL_SERVER_ERROR) {} void clear(bool release_document); void copy(const HttpResponseData& src); @@ -433,8 +436,8 @@ struct HttpTransaction { struct HttpAuthContext { std::string auth_method; - HttpAuthContext(const std::string& auth) : auth_method(auth) { } - virtual ~HttpAuthContext() { } + HttpAuthContext(const std::string& auth) : auth_method(auth) {} + virtual ~HttpAuthContext() {} }; enum HttpAuthResult { HAR_RESPONSE, HAR_IGNORE, HAR_CREDENTIALS, HAR_ERROR }; @@ -443,15 +446,19 @@ enum HttpAuthResult { HAR_RESPONSE, HAR_IGNORE, HAR_CREDENTIALS, HAR_ERROR }; // Start by passing a null pointer, then pass the same pointer each additional // call. When the authentication attempt is finished, delete the context. // TODO(bugs.webrtc.org/8905): Change "response" to "ZeroOnFreeBuffer". -HttpAuthResult HttpAuthenticate( - const char * challenge, size_t len, - const SocketAddress& server, - const std::string& method, const std::string& uri, - const std::string& username, const CryptString& password, - HttpAuthContext *& context, std::string& response, std::string& auth_method); +HttpAuthResult HttpAuthenticate(const char* challenge, + size_t len, + const SocketAddress& server, + const std::string& method, + const std::string& uri, + const std::string& username, + const CryptString& password, + HttpAuthContext*& context, + std::string& response, + std::string& auth_method); ////////////////////////////////////////////////////////////////////// -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_HTTPCOMMON_H_ +#endif // RTC_BASE_HTTPCOMMON_H_ diff --git a/rtc_base/httpcommon_unittest.cc b/rtc_base/httpcommon_unittest.cc index 997d6e31e1..ed7f242d3f 100644 --- a/rtc_base/httpcommon_unittest.cc +++ b/rtc_base/httpcommon_unittest.cc @@ -122,8 +122,8 @@ TEST(Url, SkipsUser) { TEST(HttpResponseData, parseLeaderHttp1_0) { static const char kResponseString[] = "HTTP/1.0 200 OK"; HttpResponseData response; - EXPECT_EQ(HE_NONE, response.parseLeader(kResponseString, - sizeof(kResponseString) - 1)); + EXPECT_EQ(HE_NONE, + response.parseLeader(kResponseString, sizeof(kResponseString) - 1)); EXPECT_EQ(HVER_1_0, response.version); EXPECT_EQ(200U, response.scode); } @@ -131,8 +131,8 @@ TEST(HttpResponseData, parseLeaderHttp1_0) { TEST(HttpResponseData, parseLeaderHttp1_1) { static const char kResponseString[] = "HTTP/1.1 200 OK"; HttpResponseData response; - EXPECT_EQ(HE_NONE, response.parseLeader(kResponseString, - sizeof(kResponseString) - 1)); + EXPECT_EQ(HE_NONE, + response.parseLeader(kResponseString, sizeof(kResponseString) - 1)); EXPECT_EQ(HVER_1_1, response.version); EXPECT_EQ(200U, response.scode); } @@ -140,8 +140,8 @@ TEST(HttpResponseData, parseLeaderHttp1_1) { TEST(HttpResponseData, parseLeaderHttpUnknown) { static const char kResponseString[] = "HTTP 200 OK"; HttpResponseData response; - EXPECT_EQ(HE_NONE, response.parseLeader(kResponseString, - sizeof(kResponseString) - 1)); + EXPECT_EQ(HE_NONE, + response.parseLeader(kResponseString, sizeof(kResponseString) - 1)); EXPECT_EQ(HVER_UNKNOWN, response.version); EXPECT_EQ(200U, response.scode); } @@ -149,8 +149,8 @@ TEST(HttpResponseData, parseLeaderHttpUnknown) { TEST(HttpResponseData, parseLeaderHttpFailure) { static const char kResponseString[] = "HTTP/1.1 503 Service Unavailable"; HttpResponseData response; - EXPECT_EQ(HE_NONE, response.parseLeader(kResponseString, - sizeof(kResponseString) - 1)); + EXPECT_EQ(HE_NONE, + response.parseLeader(kResponseString, sizeof(kResponseString) - 1)); EXPECT_EQ(HVER_1_1, response.version); EXPECT_EQ(503U, response.scode); } @@ -158,8 +158,8 @@ TEST(HttpResponseData, parseLeaderHttpFailure) { TEST(HttpResponseData, parseLeaderHttpInvalid) { static const char kResponseString[] = "Durrrrr, what's HTTP?"; HttpResponseData response; - EXPECT_EQ(HE_PROTOCOL, response.parseLeader(kResponseString, - sizeof(kResponseString) - 1)); + EXPECT_EQ(HE_PROTOCOL, + response.parseLeader(kResponseString, sizeof(kResponseString) - 1)); } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/httpserver.cc b/rtc_base/httpserver.cc index c36b4327a6..0e536c3bc9 100644 --- a/rtc_base/httpserver.cc +++ b/rtc_base/httpserver.cc @@ -25,24 +25,21 @@ namespace rtc { // HttpServer /////////////////////////////////////////////////////////////////////////////// -HttpServer::HttpServer() : next_connection_id_(1), closing_(false) { -} +HttpServer::HttpServer() : next_connection_id_(1), closing_(false) {} HttpServer::~HttpServer() { if (closing_) { RTC_LOG(LS_WARNING) << "HttpServer::CloseAll has not completed"; } for (ConnectionMap::iterator it = connections_.begin(); - it != connections_.end(); - ++it) { + it != connections_.end(); ++it) { StreamInterface* stream = it->second->EndProcess(); delete stream; delete it->second; } } -int -HttpServer::HandleConnection(StreamInterface* stream) { +int HttpServer::HandleConnection(StreamInterface* stream) { int connection_id = next_connection_id_++; RTC_DCHECK(connection_id != HTTP_INVALID_CONNECTION_ID); Connection* connection = new Connection(connection_id, this); @@ -51,8 +48,7 @@ HttpServer::HandleConnection(StreamInterface* stream) { return connection_id; } -void -HttpServer::Respond(HttpServerTransaction* transaction) { +void HttpServer::Respond(HttpServerTransaction* transaction) { int connection_id = transaction->connection_id(); if (Connection* connection = Find(connection_id)) { connection->Respond(transaction); @@ -63,15 +59,13 @@ HttpServer::Respond(HttpServerTransaction* transaction) { } } -void -HttpServer::Close(int connection_id, bool force) { +void HttpServer::Close(int connection_id, bool force) { if (Connection* connection = Find(connection_id)) { connection->InitiateClose(force); } } -void -HttpServer::CloseAll(bool force) { +void HttpServer::CloseAll(bool force) { if (connections_.empty()) { SignalCloseAllComplete(this); return; @@ -83,21 +77,19 @@ HttpServer::CloseAll(bool force) { connections.push_back(it->second); } for (std::list::const_iterator it = connections.begin(); - it != connections.end(); ++it) { + it != connections.end(); ++it) { (*it)->InitiateClose(force); } } -HttpServer::Connection* -HttpServer::Find(int connection_id) { +HttpServer::Connection* HttpServer::Find(int connection_id) { ConnectionMap::iterator it = connections_.find(connection_id); if (it == connections_.end()) return nullptr; return it->second; } -void -HttpServer::Remove(int connection_id) { +void HttpServer::Remove(int connection_id) { ConnectionMap::iterator it = connections_.find(connection_id); if (it == connections_.end()) { RTC_NOTREACHED(); @@ -130,8 +122,7 @@ HttpServer::Connection::~Connection() { Thread::Current()->Dispose(current_); } -void -HttpServer::Connection::BeginProcess(StreamInterface* stream) { +void HttpServer::Connection::BeginProcess(StreamInterface* stream) { base_.notify(this); base_.attach(stream); current_ = new HttpServerTransaction(connection_id_); @@ -139,15 +130,13 @@ HttpServer::Connection::BeginProcess(StreamInterface* stream) { base_.recv(¤t_->request); } -StreamInterface* -HttpServer::Connection::EndProcess() { +StreamInterface* HttpServer::Connection::EndProcess() { base_.notify(nullptr); base_.abort(HE_DISCONNECTED); return base_.detach(); } -void -HttpServer::Connection::Respond(HttpServerTransaction* transaction) { +void HttpServer::Connection::Respond(HttpServerTransaction* transaction) { RTC_DCHECK(current_ == nullptr); current_ = transaction; if (current_->response.begin() == current_->response.end()) { @@ -155,14 +144,12 @@ HttpServer::Connection::Respond(HttpServerTransaction* transaction) { } bool keep_alive = HttpShouldKeepAlive(current_->request); current_->response.setHeader(HH_CONNECTION, - keep_alive ? "Keep-Alive" : "Close", - false); + keep_alive ? "Keep-Alive" : "Close", false); close_ = !HttpShouldKeepAlive(current_->response); base_.send(¤t_->response); } -void -HttpServer::Connection::InitiateClose(bool force) { +void HttpServer::Connection::InitiateClose(bool force) { bool request_in_progress = (HM_SEND == base_.mode()) || (nullptr == current_); if (!signalling_ && (force || !request_in_progress)) { server_->Remove(connection_id_); @@ -175,8 +162,8 @@ HttpServer::Connection::InitiateClose(bool force) { // IHttpNotify Implementation // -HttpError -HttpServer::Connection::onHttpHeaderComplete(bool chunked, size_t& data_size) { +HttpError HttpServer::Connection::onHttpHeaderComplete(bool chunked, + size_t& data_size) { if (data_size == SIZE_UNKNOWN) { data_size = 0; } @@ -189,8 +176,7 @@ HttpServer::Connection::onHttpHeaderComplete(bool chunked, size_t& data_size) { return HE_NONE; } -void -HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) { +void HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) { if (mode == HM_SEND) { RTC_DCHECK(current_ != nullptr); signalling_ = true; @@ -208,7 +194,7 @@ HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) { } else if (mode == HM_RECV) { RTC_DCHECK(current_ != nullptr); // TODO: do we need this? - //request_.document_->rewind(); + // request_.document_->rewind(); HttpServerTransaction* transaction = current_; current_ = nullptr; server_->SignalHttpRequest(server_, transaction); @@ -222,8 +208,7 @@ HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) { } } -void -HttpServer::Connection::onHttpClosed(HttpError err) { +void HttpServer::Connection::onHttpClosed(HttpError err) { server_->Remove(connection_id_); } @@ -235,13 +220,11 @@ HttpListenServer::HttpListenServer() { SignalConnectionClosed.connect(this, &HttpListenServer::OnConnectionClosed); } -HttpListenServer::~HttpListenServer() { -} +HttpListenServer::~HttpListenServer() {} int HttpListenServer::Listen(const SocketAddress& address) { - AsyncSocket* sock = - Thread::Current()->socketserver()->CreateAsyncSocket(address.family(), - SOCK_STREAM); + AsyncSocket* sock = Thread::Current()->socketserver()->CreateAsyncSocket( + address.family(), SOCK_STREAM); if (!sock) { return SOCKET_ERROR; } diff --git a/rtc_base/httpserver.h b/rtc_base/httpserver.h index 61442a93f3..e4d94445ed 100644 --- a/rtc_base/httpserver.h +++ b/rtc_base/httpserver.h @@ -29,16 +29,16 @@ class SocketAddress; const int HTTP_INVALID_CONNECTION_ID = 0; struct HttpServerTransaction : public HttpTransaction { -public: - HttpServerTransaction(int id) : connection_id_(id) { } + public: + HttpServerTransaction(int id) : connection_id_(id) {} int connection_id() const { return connection_id_; } -private: + private: int connection_id_; }; class HttpServer { -public: + public: HttpServer(); virtual ~HttpServer(); @@ -54,7 +54,7 @@ public: // the document can be set to null. Note that the transaction object is still // owened by the HttpServer at this point. sigslot::signal3 - SignalHttpRequestHeader; + SignalHttpRequestHeader; // An HTTP request has been made, and is available in the transaction object. // Populate the transaction's response, and then return the object via the @@ -66,7 +66,7 @@ public: // If you want to know when a request completes, listen to this event. sigslot::signal3 - SignalHttpRequestComplete; + SignalHttpRequestComplete; // Stop processing the connection indicated by connection_id. // Unless force is true, the server will complete sending a response that is @@ -78,9 +78,9 @@ public: // outstanding connections have closed. sigslot::signal1 SignalCloseAllComplete; -private: + private: class Connection : private IHttpNotify { - public: + public: Connection(int connection_id, HttpServer* server); ~Connection() override; @@ -106,7 +106,7 @@ private: void Remove(int connection_id); friend class Connection; - typedef std::map ConnectionMap; + typedef std::map ConnectionMap; ConnectionMap connections_; int next_connection_id_; @@ -116,7 +116,7 @@ private: ////////////////////////////////////////////////////////////////////// class HttpListenServer : public HttpServer, public sigslot::has_slots<> { -public: + public: HttpListenServer(); ~HttpListenServer() override; @@ -124,9 +124,10 @@ public: bool GetAddress(SocketAddress* address) const; void StopListening(); -private: + private: void OnReadEvent(AsyncSocket* socket); - void OnConnectionClosed(HttpServer* server, int connection_id, + void OnConnectionClosed(HttpServer* server, + int connection_id, StreamInterface* stream); std::unique_ptr listener_; @@ -136,4 +137,4 @@ private: } // namespace rtc -#endif // RTC_BASE_HTTPSERVER_H_ +#endif // RTC_BASE_HTTPSERVER_H_ diff --git a/rtc_base/httpserver_unittest.cc b/rtc_base/httpserver_unittest.cc index 5e86c885df..0dde6c5bde 100644 --- a/rtc_base/httpserver_unittest.cc +++ b/rtc_base/httpserver_unittest.cc @@ -17,59 +17,56 @@ using namespace webrtc::testing; namespace rtc { namespace { - const char* const kRequest = +const char* const kRequest = "GET /index.html HTTP/1.1\r\n" "Host: localhost\r\n" "\r\n"; - struct HttpServerMonitor : public sigslot::has_slots<> { - HttpServerTransaction* transaction; - bool server_closed, connection_closed; +struct HttpServerMonitor : public sigslot::has_slots<> { + HttpServerTransaction* transaction; + bool server_closed, connection_closed; - HttpServerMonitor(HttpServer* server) - : transaction(nullptr), server_closed(false), connection_closed(false) { - server->SignalCloseAllComplete.connect(this, - &HttpServerMonitor::OnClosed); - server->SignalHttpRequest.connect(this, &HttpServerMonitor::OnRequest); - server->SignalHttpRequestComplete.connect(this, - &HttpServerMonitor::OnRequestComplete); - server->SignalConnectionClosed.connect(this, - &HttpServerMonitor::OnConnectionClosed); - } - void OnRequest(HttpServer*, HttpServerTransaction* t) { - ASSERT_FALSE(transaction); - transaction = t; - transaction->response.set_success(); - transaction->response.setHeader(HH_CONNECTION, "Close"); - } - void OnRequestComplete(HttpServer*, HttpServerTransaction* t, int) { - ASSERT_EQ(transaction, t); - transaction = nullptr; - } - void OnClosed(HttpServer*) { - server_closed = true; - } - void OnConnectionClosed(HttpServer*, int, StreamInterface* stream) { - connection_closed = true; - delete stream; - } - }; - - void CreateClientConnection(HttpServer& server, - HttpServerMonitor& monitor, - bool send_request) { - StreamSource* client = new StreamSource; - client->SetState(SS_OPEN); - server.HandleConnection(client); - EXPECT_FALSE(monitor.server_closed); - EXPECT_FALSE(monitor.transaction); - - if (send_request) { - // Simulate a request - client->QueueString(kRequest); - EXPECT_FALSE(monitor.server_closed); - } + HttpServerMonitor(HttpServer* server) + : transaction(nullptr), server_closed(false), connection_closed(false) { + server->SignalCloseAllComplete.connect(this, &HttpServerMonitor::OnClosed); + server->SignalHttpRequest.connect(this, &HttpServerMonitor::OnRequest); + server->SignalHttpRequestComplete.connect( + this, &HttpServerMonitor::OnRequestComplete); + server->SignalConnectionClosed.connect( + this, &HttpServerMonitor::OnConnectionClosed); } + void OnRequest(HttpServer*, HttpServerTransaction* t) { + ASSERT_FALSE(transaction); + transaction = t; + transaction->response.set_success(); + transaction->response.setHeader(HH_CONNECTION, "Close"); + } + void OnRequestComplete(HttpServer*, HttpServerTransaction* t, int) { + ASSERT_EQ(transaction, t); + transaction = nullptr; + } + void OnClosed(HttpServer*) { server_closed = true; } + void OnConnectionClosed(HttpServer*, int, StreamInterface* stream) { + connection_closed = true; + delete stream; + } +}; + +void CreateClientConnection(HttpServer& server, + HttpServerMonitor& monitor, + bool send_request) { + StreamSource* client = new StreamSource; + client->SetState(SS_OPEN); + server.HandleConnection(client); + EXPECT_FALSE(monitor.server_closed); + EXPECT_FALSE(monitor.transaction); + + if (send_request) { + // Simulate a request + client->QueueString(kRequest); + EXPECT_FALSE(monitor.server_closed); + } +} } // anonymous namespace TEST(HttpServer, DoesNotSignalCloseUnlessCloseAllIsCalled) { @@ -127,4 +124,4 @@ TEST(HttpServer, SignalsCloseAfterForcedCloseAll) { EXPECT_TRUE(monitor.connection_closed); } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/ifaddrs-android.cc b/rtc_base/ifaddrs-android.cc index b713c02442..cc6cdab12c 100644 --- a/rtc_base/ifaddrs-android.cc +++ b/rtc_base/ifaddrs-android.cc @@ -64,7 +64,9 @@ int set_flags(struct ifaddrs* ifaddr) { return 0; } -int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data, +int set_addresses(struct ifaddrs* ifaddr, + ifaddrmsg* msg, + void* data, size_t len) { if (msg->ifa_family == AF_INET) { sockaddr_in* sa = new sockaddr_in; @@ -115,7 +117,9 @@ int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) { return 0; } -int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes, +int populate_ifaddrs(struct ifaddrs* ifaddr, + ifaddrmsg* msg, + void* bytes, size_t len) { if (set_ifname(ifaddr, msg->ifa_index) != 0) { return -1; @@ -156,8 +160,8 @@ int getifaddrs(struct ifaddrs** result) { while (amount_read > 0) { nlmsghdr* header = reinterpret_cast(&buf[0]); size_t header_size = static_cast(amount_read); - for ( ; NLMSG_OK(header, header_size); - header = NLMSG_NEXT(header, header_size)) { + for (; NLMSG_OK(header, header_size); + header = NLMSG_NEXT(header, header_size)) { switch (header->nlmsg_type) { case NLMSG_DONE: // Success. Return. @@ -175,7 +179,7 @@ int getifaddrs(struct ifaddrs** result) { ssize_t payload_len = IFA_PAYLOAD(header); while (RTA_OK(rta, payload_len)) { if ((address_msg->ifa_family == AF_INET && - rta->rta_type == IFA_LOCAL) || + rta->rta_type == IFA_LOCAL) || (address_msg->ifa_family == AF_INET6 && rta->rta_type == IFA_ADDRESS)) { ifaddrs* newest = new ifaddrs; diff --git a/rtc_base/ifaddrs-android.h b/rtc_base/ifaddrs-android.h index 82b4cb3006..1a5b662f06 100644 --- a/rtc_base/ifaddrs-android.h +++ b/rtc_base/ifaddrs-android.h @@ -14,7 +14,6 @@ #include #include - // Implementation of getifaddrs for Android. // Fills out a list of ifaddr structs (see below) which contain information // about every network interface available on the host. diff --git a/rtc_base/ipaddress.cc b/rtc_base/ipaddress.cc index e6a02c4a8a..c52c9a4add 100644 --- a/rtc_base/ipaddress.cc +++ b/rtc_base/ipaddress.cc @@ -9,9 +9,9 @@ */ #if defined(WEBRTC_POSIX) -#include -#include #include +#include +#include #ifdef OPENBSD #include #endif @@ -39,8 +39,8 @@ namespace rtc { // Prefixes used for categorizing IPv6 addresses. -static const in6_addr kV4MappedPrefix = {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0xFF, 0xFF, 0}}}; +static const in6_addr kV4MappedPrefix = { + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0}}}; static const in6_addr k6To4Prefix = {{{0x20, 0x02, 0}}}; static const in6_addr kTeredoPrefix = {{{0x20, 0x01, 0x00, 0x00}}}; static const in6_addr kV4CompatibilityPrefix = {{{0}}}; @@ -48,7 +48,8 @@ static const in6_addr k6BonePrefix = {{{0x3f, 0xfe, 0}}}; static const in6_addr kPrivateNetworkPrefix = {{{0xFD}}}; static bool IPIsHelper(const IPAddress& ip, - const in6_addr& tomatch, int length); + const in6_addr& tomatch, + int length); static in_addr ExtractMappedAddress(const in6_addr& addr); uint32_t IPAddress::v4AddressAsHostOrderInteger() const { @@ -73,8 +74,7 @@ size_t IPAddress::Size() const { return 0; } - -bool IPAddress::operator==(const IPAddress &other) const { +bool IPAddress::operator==(const IPAddress& other) const { if (family_ != other.family_) { return false; } @@ -87,15 +87,15 @@ bool IPAddress::operator==(const IPAddress &other) const { return family_ == AF_UNSPEC; } -bool IPAddress::operator!=(const IPAddress &other) const { +bool IPAddress::operator!=(const IPAddress& other) const { return !((*this) == other); } -bool IPAddress::operator >(const IPAddress &other) const { +bool IPAddress::operator>(const IPAddress& other) const { return (*this) != other && !((*this) < other); } -bool IPAddress::operator <(const IPAddress &other) const { +bool IPAddress::operator<(const IPAddress& other) const { // IPv4 is 'less than' IPv6 if (family_ != other.family_) { if (family_ == AF_UNSPEC) { @@ -110,7 +110,7 @@ bool IPAddress::operator <(const IPAddress &other) const { switch (family_) { case AF_INET: { return NetworkToHost32(u_.ip4.s_addr) < - NetworkToHost32(other.u_.ip4.s_addr); + NetworkToHost32(other.u_.ip4.s_addr); } case AF_INET6: { return memcmp(&u_.ip6.s6_addr, &other.u_.ip6.s6_addr, 16) < 0; @@ -195,17 +195,17 @@ IPAddress IPAddress::AsIPv6Address() const { return IPAddress(v6addr); } -bool InterfaceAddress::operator==(const InterfaceAddress &other) const { +bool InterfaceAddress::operator==(const InterfaceAddress& other) const { return ipv6_flags_ == other.ipv6_flags() && - static_cast(*this) == other; + static_cast(*this) == other; } -bool InterfaceAddress::operator!=(const InterfaceAddress &other) const { +bool InterfaceAddress::operator!=(const InterfaceAddress& other) const { return !((*this) == other); } const InterfaceAddress& InterfaceAddress::operator=( - const InterfaceAddress& other) { + const InterfaceAddress& other) { ipv6_flags_ = other.ipv6_flags_; static_cast(*this) = other; return *this; @@ -223,8 +223,8 @@ std::string InterfaceAddress::ToString() const { static bool IPIsPrivateNetworkV4(const IPAddress& ip) { uint32_t ip_in_host_order = ip.v4AddressAsHostOrderInteger(); return ((ip_in_host_order >> 24) == 10) || - ((ip_in_host_order >> 20) == ((172 << 4) | 1)) || - ((ip_in_host_order >> 16) == ((192 << 8) | 168)); + ((ip_in_host_order >> 20) == ((172 << 4) | 1)) || + ((ip_in_host_order >> 16) == ((192 << 8) | 168)); } static bool IPIsPrivateNetworkV6(const IPAddress& ip) { @@ -283,8 +283,7 @@ bool IPFromString(const std::string& str, IPAddress* out) { return true; } -bool IPFromString(const std::string& str, int flags, - InterfaceAddress* out) { +bool IPFromString(const std::string& str, int flags, InterfaceAddress* out) { IPAddress ip; if (!IPFromString(str, &ip)) { return false; @@ -416,9 +415,7 @@ int CountIPMaskBits(IPAddress mask) { bits = (i * 32); break; } - default: { - return 0; - } + default: { return 0; } } if (word_to_count == 0) { return bits; @@ -431,12 +428,18 @@ int CountIPMaskBits(IPAddress mask) { // This could also be written word_to_count &= -word_to_count, but // MSVC emits warning C4146 when negating an unsigned number. word_to_count &= ~word_to_count + 1; // Isolate lowest set bit. - if (word_to_count) zeroes--; - if (word_to_count & 0x0000FFFF) zeroes -= 16; - if (word_to_count & 0x00FF00FF) zeroes -= 8; - if (word_to_count & 0x0F0F0F0F) zeroes -= 4; - if (word_to_count & 0x33333333) zeroes -= 2; - if (word_to_count & 0x55555555) zeroes -= 1; + if (word_to_count) + zeroes--; + if (word_to_count & 0x0000FFFF) + zeroes -= 16; + if (word_to_count & 0x00FF00FF) + zeroes -= 8; + if (word_to_count & 0x0F0F0F0F) + zeroes -= 4; + if (word_to_count & 0x33333333) + zeroes -= 2; + if (word_to_count & 0x55555555) + zeroes -= 1; return bits + (32 - zeroes); } diff --git a/rtc_base/ipaddress.h b/rtc_base/ipaddress.h index c7a7e708e1..614fd8f575 100644 --- a/rtc_base/ipaddress.h +++ b/rtc_base/ipaddress.h @@ -12,10 +12,10 @@ #define RTC_BASE_IPADDRESS_H_ #if defined(WEBRTC_POSIX) -#include -#include #include #include +#include +#include #endif #if defined(WEBRTC_WIN) #include @@ -33,33 +33,29 @@ namespace rtc { enum IPv6AddressFlag { - IPV6_ADDRESS_FLAG_NONE = 0x00, + IPV6_ADDRESS_FLAG_NONE = 0x00, // Temporary address is dynamic by nature and will not carry MAC // address. - IPV6_ADDRESS_FLAG_TEMPORARY = 1 << 0, + IPV6_ADDRESS_FLAG_TEMPORARY = 1 << 0, // Temporary address could become deprecated once the preferred // lifetime is reached. It is still valid but just shouldn't be used // to create new connection. - IPV6_ADDRESS_FLAG_DEPRECATED = 1 << 1, + IPV6_ADDRESS_FLAG_DEPRECATED = 1 << 1, }; // Version-agnostic IP address class, wraps a union of in_addr and in6_addr. class IPAddress { public: - IPAddress() : family_(AF_UNSPEC) { - ::memset(&u_, 0, sizeof(u_)); - } + IPAddress() : family_(AF_UNSPEC) { ::memset(&u_, 0, sizeof(u_)); } explicit IPAddress(const in_addr& ip4) : family_(AF_INET) { memset(&u_, 0, sizeof(u_)); u_.ip4 = ip4; } - explicit IPAddress(const in6_addr& ip6) : family_(AF_INET6) { - u_.ip6 = ip6; - } + explicit IPAddress(const in6_addr& ip6) : family_(AF_INET6) { u_.ip6 = ip6; } explicit IPAddress(uint32_t ip_in_host_byte_order) : family_(AF_INET) { memset(&u_, 0, sizeof(u_)); @@ -72,7 +68,7 @@ class IPAddress { virtual ~IPAddress() {} - const IPAddress & operator=(const IPAddress& other) { + const IPAddress& operator=(const IPAddress& other) { family_ = other.family_; ::memcpy(&u_, &other.u_, sizeof(u_)); return *this; @@ -80,8 +76,8 @@ class IPAddress { bool operator==(const IPAddress& other) const; bool operator!=(const IPAddress& other) const; - bool operator <(const IPAddress& other) const; - bool operator >(const IPAddress& other) const; + bool operator<(const IPAddress& other) const; + bool operator>(const IPAddress& other) const; #ifdef UNIT_TEST inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) @@ -135,12 +131,12 @@ class InterfaceAddress : public IPAddress { : IPAddress(ip), ipv6_flags_(IPV6_ADDRESS_FLAG_NONE) {} InterfaceAddress(IPAddress addr, int ipv6_flags) - : IPAddress(addr), ipv6_flags_(ipv6_flags) {} + : IPAddress(addr), ipv6_flags_(ipv6_flags) {} InterfaceAddress(const in6_addr& ip6, int ipv6_flags) - : IPAddress(ip6), ipv6_flags_(ipv6_flags) {} + : IPAddress(ip6), ipv6_flags_(ipv6_flags) {} - const InterfaceAddress & operator=(const InterfaceAddress& other); + const InterfaceAddress& operator=(const InterfaceAddress& other); bool operator==(const InterfaceAddress& other) const; bool operator!=(const InterfaceAddress& other) const; @@ -155,8 +151,7 @@ class InterfaceAddress : public IPAddress { bool IPFromAddrInfo(struct addrinfo* info, IPAddress* out); bool IPFromString(const std::string& str, IPAddress* out); -bool IPFromString(const std::string& str, int flags, - InterfaceAddress* out); +bool IPFromString(const std::string& str, int flags, InterfaceAddress* out); bool IPIsAny(const IPAddress& ip); bool IPIsLoopback(const IPAddress& ip); bool IPIsLinkLocal(const IPAddress& ip); diff --git a/rtc_base/ipaddress_unittest.cc b/rtc_base/ipaddress_unittest.cc index 3698d3fd82..30312d0677 100644 --- a/rtc_base/ipaddress_unittest.cc +++ b/rtc_base/ipaddress_unittest.cc @@ -17,31 +17,25 @@ static const unsigned int kIPv4AddrSize = 4; static const unsigned int kIPv6AddrSize = 16; static const unsigned int kIPv4RFC1918Addr = 0xC0A80701; static const unsigned int kIPv4PublicAddr = 0x01020304; -static const unsigned int kIPv4LinkLocalAddr = 0xA9FE10C1; // 169.254.16.193 -static const in6_addr kIPv6LinkLocalAddr = {{{0xfe, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xbe, 0x30, 0x5b, 0xff, - 0xfe, 0xe5, 0x00, 0xc3}}}; -static const in6_addr kIPv6PublicAddr = {{{0x24, 0x01, 0xfa, 0x00, - 0x00, 0x04, 0x10, 0x00, - 0xbe, 0x30, 0x5b, 0xff, - 0xfe, 0xe5, 0x00, 0xc3}}}; -static const in6_addr kIPv6PublicAddr2 = {{{0x24, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x00, - 0xbe, 0x30, 0x5b, 0xff, - 0xfe, 0xe5, 0x00, 0xc3}}}; -static const in6_addr kIPv4MappedAnyAddr = {{{0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00}}}; -static const in6_addr kIPv4MappedRFC1918Addr = {{{0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, - 0xc0, 0xa8, 0x07, 0x01}}}; -static const in6_addr kIPv4MappedPublicAddr = {{{0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, - 0x01, 0x02, 0x03, 0x04}}}; +static const unsigned int kIPv4LinkLocalAddr = 0xA9FE10C1; // 169.254.16.193 +static const in6_addr kIPv6LinkLocalAddr = { + {{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x30, 0x5b, 0xff, + 0xfe, 0xe5, 0x00, 0xc3}}}; +static const in6_addr kIPv6PublicAddr = { + {{0x24, 0x01, 0xfa, 0x00, 0x00, 0x04, 0x10, 0x00, 0xbe, 0x30, 0x5b, 0xff, + 0xfe, 0xe5, 0x00, 0xc3}}}; +static const in6_addr kIPv6PublicAddr2 = { + {{0x24, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xbe, 0x30, 0x5b, 0xff, + 0xfe, 0xe5, 0x00, 0xc3}}}; +static const in6_addr kIPv4MappedAnyAddr = { + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00}}}; +static const in6_addr kIPv4MappedRFC1918Addr = { + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xc0, 0xa8, 0x07, 0x01}}}; +static const in6_addr kIPv4MappedPublicAddr = { + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x01, 0x02, 0x03, 0x04}}}; static const std::string kIPv4AnyAddrString = "0.0.0.0"; static const std::string kIPv4LoopbackAddrString = "127.0.0.1"; @@ -80,10 +74,8 @@ static const std::string kIPv6BrokenString2 = "2401:fa00:4:1000:be30:5bff:fee5:c3:1"; static const std::string kIPv6BrokenString3 = "[2401:fa00:4:1000:be30:5bff:fee5:c3]:1"; -static const std::string kIPv6BrokenString4 = - "2401::4::be30"; -static const std::string kIPv6BrokenString5 = - "2401:::4:fee5:be30"; +static const std::string kIPv6BrokenString4 = "2401::4::be30"; +static const std::string kIPv6BrokenString5 = "2401:::4:fee5:be30"; static const std::string kIPv6BrokenString6 = "2401f:fa00:4:1000:be30:5bff:fee5:c3"; static const std::string kIPv6BrokenString7 = @@ -92,24 +84,18 @@ static const std::string kIPv6BrokenString8 = "2401:fa000:4:1000:be30:5bff:fee5:c3"; static const std::string kIPv6BrokenString9 = "2401:fal0:4:1000:be30:5bff:fee5:c3"; -static const std::string kIPv6BrokenString10 = - "::ffff:192.168.7."; -static const std::string kIPv6BrokenString11 = - "::ffff:192.168.7.1.1.1"; -static const std::string kIPv6BrokenString12 = - "::fffe:192.168.7.1"; -static const std::string kIPv6BrokenString13 = - "::ffff:192.168.7.ff"; +static const std::string kIPv6BrokenString10 = "::ffff:192.168.7."; +static const std::string kIPv6BrokenString11 = "::ffff:192.168.7.1.1.1"; +static const std::string kIPv6BrokenString12 = "::fffe:192.168.7.1"; +static const std::string kIPv6BrokenString13 = "::ffff:192.168.7.ff"; static const std::string kIPv6BrokenString14 = "0x2401:fa00:4:1000:be30:5bff:fee5:c3"; -bool AreEqual(const IPAddress& addr, - const IPAddress& addr2) { +bool AreEqual(const IPAddress& addr, const IPAddress& addr2) { if ((IPIsAny(addr) != IPIsAny(addr2)) || (IPIsLoopback(addr) != IPIsLoopback(addr2)) || (IPIsPrivate(addr) != IPIsPrivate(addr2)) || - (HashIP(addr) != HashIP(addr2)) || - (addr.Size() != addr2.Size()) || + (HashIP(addr) != HashIP(addr2)) || (addr.Size() != addr2.Size()) || (addr.family() != addr2.family()) || (addr.ToString() != addr2.ToString())) { return false; @@ -130,7 +116,7 @@ bool AreEqual(const IPAddress& addr, } bool BrokenIPStringFails(const std::string& broken) { - IPAddress addr(0); // Intentionally make it v4. + IPAddress addr(0); // Intentionally make it v4. if (IPFromString(kIPv4BrokenString1, &addr)) { return false; } @@ -140,7 +126,7 @@ bool BrokenIPStringFails(const std::string& broken) { bool CheckMaskCount(const std::string& mask, int expected_length) { IPAddress addr; return IPFromString(mask, &addr) && - (expected_length == CountIPMaskBits(addr)); + (expected_length == CountIPMaskBits(addr)); } bool TryInvalidMaskCount(const std::string& mask) { @@ -154,7 +140,8 @@ bool TryInvalidMaskCount(const std::string& mask) { return true; } -bool CheckTruncateIP(const std::string& initial, int truncate_length, +bool CheckTruncateIP(const std::string& initial, + int truncate_length, const std::string& expected_result) { IPAddress addr, expected; IPFromString(initial, &addr); @@ -390,14 +377,14 @@ TEST(IPAddressTest, TestEquality) { TEST(IPAddressTest, TestComparison) { // Defined in 'ascending' order. // v6 > v4, and intra-family sorting is purely numerical - IPAddress addr0; // AF_UNSPEC - IPAddress addr1(INADDR_ANY); // 0.0.0.0 - IPAddress addr2(kIPv4PublicAddr); // 1.2.3.4 - IPAddress addr3(INADDR_LOOPBACK); // 127.0.0.1 - IPAddress addr4(kIPv4RFC1918Addr); // 192.168.7.1. - IPAddress addr5(in6addr_any); // :: - IPAddress addr6(in6addr_loopback); // ::1 - IPAddress addr7(kIPv6PublicAddr); // 2401.... + IPAddress addr0; // AF_UNSPEC + IPAddress addr1(INADDR_ANY); // 0.0.0.0 + IPAddress addr2(kIPv4PublicAddr); // 1.2.3.4 + IPAddress addr3(INADDR_LOOPBACK); // 127.0.0.1 + IPAddress addr4(kIPv4RFC1918Addr); // 192.168.7.1. + IPAddress addr5(in6addr_any); // :: + IPAddress addr6(in6addr_loopback); // ::1 + IPAddress addr7(kIPv6PublicAddr); // 2401.... IPAddress addr8(kIPv6LinkLocalAddr); // fe80.... EXPECT_TRUE(addr0 < addr1); @@ -941,8 +928,7 @@ TEST(IPAddressTest, TestToSensitiveString) { TEST(IPAddressTest, TestInterfaceAddress) { in6_addr addr; - InterfaceAddress addr1(kIPv6PublicAddr, - IPV6_ADDRESS_FLAG_TEMPORARY); + InterfaceAddress addr1(kIPv6PublicAddr, IPV6_ADDRESS_FLAG_TEMPORARY); EXPECT_EQ(addr1.ipv6_flags(), IPV6_ADDRESS_FLAG_TEMPORARY); EXPECT_EQ(addr1.family(), AF_INET6); @@ -961,18 +947,16 @@ TEST(IPAddressTest, TestInterfaceAddress) { addr = addr3.ipv6_address(); EXPECT_TRUE(IN6_ARE_ADDR_EQUAL(&addr, &kIPv6PublicAddr)); - InterfaceAddress addr4(kIPv6PublicAddr, - IPV6_ADDRESS_FLAG_DEPRECATED); + InterfaceAddress addr4(kIPv6PublicAddr, IPV6_ADDRESS_FLAG_DEPRECATED); EXPECT_NE(addr1, addr4); // When you compare them as IPAddress, since operator== // is not virtual, it'll be equal. - IPAddress *paddr1 = &addr1; - IPAddress *paddr4 = &addr4; + IPAddress* paddr1 = &addr1; + IPAddress* paddr4 = &addr4; EXPECT_EQ(*paddr1, *paddr4); - InterfaceAddress addr5(kIPv6LinkLocalAddr, - IPV6_ADDRESS_FLAG_TEMPORARY); + InterfaceAddress addr5(kIPv6LinkLocalAddr, IPV6_ADDRESS_FLAG_TEMPORARY); EXPECT_NE(addr1, addr5); } diff --git a/rtc_base/json.cc b/rtc_base/json.cc index b8071a99bd..cc40bd678d 100644 --- a/rtc_base/json.cc +++ b/rtc_base/json.cc @@ -52,8 +52,8 @@ bool GetIntFromJson(const Json::Value& in, int* out) { char* end_ptr; errno = 0; val = strtol(c_str, &end_ptr, 10); // NOLINT - ret = (end_ptr != c_str && *end_ptr == '\0' && !errno && - val >= INT_MIN && val <= INT_MAX); + ret = (end_ptr != c_str && *end_ptr == '\0' && !errno && val >= INT_MIN && + val <= INT_MAX); *out = val; } return ret; @@ -72,8 +72,7 @@ bool GetUIntFromJson(const Json::Value& in, unsigned int* out) { char* end_ptr; errno = 0; val = strtoul(c_str, &end_ptr, 10); // NOLINT - ret = (end_ptr != c_str && *end_ptr == '\0' && !errno && - val <= UINT_MAX); + ret = (end_ptr != c_str && *end_ptr == '\0' && !errno && val <= UINT_MAX); *out = val; } return ret; @@ -120,10 +119,10 @@ bool GetDoubleFromJson(const Json::Value& in, double* out) { } namespace { -template +template bool JsonArrayToVector(const Json::Value& value, bool (*getter)(const Json::Value& in, T* out), - std::vector *vec) { + std::vector* vec) { vec->clear(); if (!value.isArray()) { return false; @@ -151,8 +150,7 @@ bool JsonArrayToValueVector(const Json::Value& in, return JsonArrayToVector(in, GetValueFromJson, out); } -bool JsonArrayToIntVector(const Json::Value& in, - std::vector* out) { +bool JsonArrayToIntVector(const Json::Value& in, std::vector* out) { return JsonArrayToVector(in, GetIntFromJson, out); } @@ -166,18 +164,16 @@ bool JsonArrayToStringVector(const Json::Value& in, return JsonArrayToVector(in, GetStringFromJson, out); } -bool JsonArrayToBoolVector(const Json::Value& in, - std::vector* out) { +bool JsonArrayToBoolVector(const Json::Value& in, std::vector* out) { return JsonArrayToVector(in, GetBoolFromJson, out); } -bool JsonArrayToDoubleVector(const Json::Value& in, - std::vector* out) { +bool JsonArrayToDoubleVector(const Json::Value& in, std::vector* out) { return JsonArrayToVector(in, GetDoubleFromJson, out); } namespace { -template +template Json::Value VectorToJsonArray(const std::vector& vec) { Json::Value result(Json::arrayValue); for (size_t i = 0; i < vec.size(); ++i) { @@ -211,8 +207,7 @@ Json::Value DoubleVectorToJsonArray(const std::vector& in) { return VectorToJsonArray(in); } -bool GetValueFromJsonArray(const Json::Value& in, size_t n, - Json::Value* out) { +bool GetValueFromJsonArray(const Json::Value& in, size_t n, Json::Value* out) { if (!in.isArray() || !in.isValidIndex(static_cast(n))) { return false; } @@ -221,37 +216,33 @@ bool GetValueFromJsonArray(const Json::Value& in, size_t n, return true; } -bool GetIntFromJsonArray(const Json::Value& in, size_t n, - int* out) { +bool GetIntFromJsonArray(const Json::Value& in, size_t n, int* out) { Json::Value x; return GetValueFromJsonArray(in, n, &x) && GetIntFromJson(x, out); } -bool GetUIntFromJsonArray(const Json::Value& in, size_t n, - unsigned int* out) { +bool GetUIntFromJsonArray(const Json::Value& in, size_t n, unsigned int* out) { Json::Value x; return GetValueFromJsonArray(in, n, &x) && GetUIntFromJson(x, out); } -bool GetStringFromJsonArray(const Json::Value& in, size_t n, - std::string* out) { +bool GetStringFromJsonArray(const Json::Value& in, size_t n, std::string* out) { Json::Value x; return GetValueFromJsonArray(in, n, &x) && GetStringFromJson(x, out); } -bool GetBoolFromJsonArray(const Json::Value& in, size_t n, - bool* out) { +bool GetBoolFromJsonArray(const Json::Value& in, size_t n, bool* out) { Json::Value x; return GetValueFromJsonArray(in, n, &x) && GetBoolFromJson(x, out); } -bool GetDoubleFromJsonArray(const Json::Value& in, size_t n, - double* out) { +bool GetDoubleFromJsonArray(const Json::Value& in, size_t n, double* out) { Json::Value x; return GetValueFromJsonArray(in, n, &x) && GetDoubleFromJson(x, out); } -bool GetValueFromJsonObject(const Json::Value& in, const std::string& k, +bool GetValueFromJsonObject(const Json::Value& in, + const std::string& k, Json::Value* out) { if (!in.isObject() || !in.isMember(k)) { return false; @@ -261,31 +252,36 @@ bool GetValueFromJsonObject(const Json::Value& in, const std::string& k, return true; } -bool GetIntFromJsonObject(const Json::Value& in, const std::string& k, +bool GetIntFromJsonObject(const Json::Value& in, + const std::string& k, int* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetIntFromJson(x, out); } -bool GetUIntFromJsonObject(const Json::Value& in, const std::string& k, - unsigned int* out) { +bool GetUIntFromJsonObject(const Json::Value& in, + const std::string& k, + unsigned int* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetUIntFromJson(x, out); } -bool GetStringFromJsonObject(const Json::Value& in, const std::string& k, - std::string* out) { +bool GetStringFromJsonObject(const Json::Value& in, + const std::string& k, + std::string* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetStringFromJson(x, out); } -bool GetBoolFromJsonObject(const Json::Value& in, const std::string& k, +bool GetBoolFromJsonObject(const Json::Value& in, + const std::string& k, bool* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetBoolFromJson(x, out); } -bool GetDoubleFromJsonObject(const Json::Value& in, const std::string& k, +bool GetDoubleFromJsonObject(const Json::Value& in, + const std::string& k, double* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetDoubleFromJson(x, out); diff --git a/rtc_base/json.h b/rtc_base/json.h index 5db8bd6c90..b8e6d95918 100644 --- a/rtc_base/json.h +++ b/rtc_base/json.h @@ -34,32 +34,23 @@ bool GetBoolFromJson(const Json::Value& in, bool* out); bool GetDoubleFromJson(const Json::Value& in, double* out); // Pull values out of a JSON array. -bool GetValueFromJsonArray(const Json::Value& in, size_t n, - Json::Value* out); -bool GetIntFromJsonArray(const Json::Value& in, size_t n, - int* out); -bool GetUIntFromJsonArray(const Json::Value& in, size_t n, - unsigned int* out); -bool GetStringFromJsonArray(const Json::Value& in, size_t n, - std::string* out); -bool GetBoolFromJsonArray(const Json::Value& in, size_t n, - bool* out); -bool GetDoubleFromJsonArray(const Json::Value& in, size_t n, - double* out); +bool GetValueFromJsonArray(const Json::Value& in, size_t n, Json::Value* out); +bool GetIntFromJsonArray(const Json::Value& in, size_t n, int* out); +bool GetUIntFromJsonArray(const Json::Value& in, size_t n, unsigned int* out); +bool GetStringFromJsonArray(const Json::Value& in, size_t n, std::string* out); +bool GetBoolFromJsonArray(const Json::Value& in, size_t n, bool* out); +bool GetDoubleFromJsonArray(const Json::Value& in, size_t n, double* out); // Convert json arrays to std::vector bool JsonArrayToValueVector(const Json::Value& in, std::vector* out); -bool JsonArrayToIntVector(const Json::Value& in, - std::vector* out); +bool JsonArrayToIntVector(const Json::Value& in, std::vector* out); bool JsonArrayToUIntVector(const Json::Value& in, std::vector* out); bool JsonArrayToStringVector(const Json::Value& in, std::vector* out); -bool JsonArrayToBoolVector(const Json::Value& in, - std::vector* out); -bool JsonArrayToDoubleVector(const Json::Value& in, - std::vector* out); +bool JsonArrayToBoolVector(const Json::Value& in, std::vector* out); +bool JsonArrayToDoubleVector(const Json::Value& in, std::vector* out); // Convert std::vector to json array Json::Value ValueVectorToJsonArray(const std::vector& in); @@ -70,17 +61,23 @@ Json::Value BoolVectorToJsonArray(const std::vector& in); Json::Value DoubleVectorToJsonArray(const std::vector& in); // Pull values out of a JSON object. -bool GetValueFromJsonObject(const Json::Value& in, const std::string& k, +bool GetValueFromJsonObject(const Json::Value& in, + const std::string& k, Json::Value* out); -bool GetIntFromJsonObject(const Json::Value& in, const std::string& k, +bool GetIntFromJsonObject(const Json::Value& in, + const std::string& k, int* out); -bool GetUIntFromJsonObject(const Json::Value& in, const std::string& k, +bool GetUIntFromJsonObject(const Json::Value& in, + const std::string& k, unsigned int* out); -bool GetStringFromJsonObject(const Json::Value& in, const std::string& k, +bool GetStringFromJsonObject(const Json::Value& in, + const std::string& k, std::string* out); -bool GetBoolFromJsonObject(const Json::Value& in, const std::string& k, +bool GetBoolFromJsonObject(const Json::Value& in, + const std::string& k, bool* out); -bool GetDoubleFromJsonObject(const Json::Value& in, const std::string& k, +bool GetDoubleFromJsonObject(const Json::Value& in, + const std::string& k, double* out); // Writes out a Json value as a string. diff --git a/rtc_base/keep_ref_until_done.h b/rtc_base/keep_ref_until_done.h index 979415d131..9ba0e879eb 100644 --- a/rtc_base/keep_ref_until_done.h +++ b/rtc_base/keep_ref_until_done.h @@ -39,5 +39,4 @@ static inline Callback0 KeepRefUntilDone( } // namespace rtc - #endif // RTC_BASE_KEEP_REF_UNTIL_DONE_H_ diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc index 5e035a69d6..37d23ce492 100644 --- a/rtc_base/logging.cc +++ b/rtc_base/logging.cc @@ -29,8 +29,8 @@ static const int kMaxLogLineSize = 1024 - 60; #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) || WEBRTC_ANDROID -#include #include +#include #include #include @@ -81,7 +81,6 @@ std::ostream& GetNoopStream() { CriticalSection g_log_crit; } // namespace - ///////////////////////////////////////////////////////////////////////////// // LogMessage ///////////////////////////////////////////////////////////////////////////// @@ -128,7 +127,7 @@ LogMessage::LogMessage(const char* file, } if (file != nullptr) - print_stream_ << "(" << FilenameFromPath(file) << ":" << line << "): "; + print_stream_ << "(" << FilenameFromPath(file) << ":" << line << "): "; if (err_ctx != ERRCTX_NONE) { char tmp_buf[1024]; @@ -141,13 +140,13 @@ LogMessage::LogMessage(const char* file, #ifdef WEBRTC_WIN case ERRCTX_HRESULT: { char msgbuf[256]; - DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS; + DWORD flags = + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; if (DWORD len = FormatMessageA( flags, nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msgbuf, sizeof(msgbuf) / sizeof(msgbuf[0]), nullptr)) { while ((len > 0) && - isspace(static_cast(msgbuf[len-1]))) { + isspace(static_cast(msgbuf[len - 1]))) { msgbuf[--len] = 0; } tmp << " " << msgbuf; @@ -174,11 +173,7 @@ LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev, const char* tag) - : LogMessage(file, - line, - sev, - ERRCTX_NONE, - 0 /* err */) { + : LogMessage(file, line, sev, ERRCTX_NONE, 0 /* err */) { if (!is_noop_) { tag_ = tag; print_stream_ << tag << ": "; @@ -189,7 +184,9 @@ LogMessage::LogMessage(const char* file, // DEPRECATED. Currently only used by downstream projects that use // implementation details of logging.h. Work is ongoing to remove those // dependencies. -LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev, +LogMessage::LogMessage(const char* file, + int line, + LoggingSeverity sev, const std::string& tag) : LogMessage(file, line, sev) { if (!is_noop_) @@ -320,7 +317,7 @@ void LogMessage::ConfigureLogging(const char* params) { } else if (token == "thread") { LogThreads(); - // Logging levels + // Logging levels } else if (token == "sensitive") { current_level = LS_SENSITIVE; } else if (token == "verbose") { @@ -334,7 +331,7 @@ void LogMessage::ConfigureLogging(const char* params) { } else if (token == "none") { current_level = LS_NONE; - // Logging targets + // Logging targets } else if (token == "debug") { debug_level = current_level; } @@ -377,9 +374,8 @@ void LogMessage::OutputToDebug(const std::string& str, // On the Mac, all stderr output goes to the Console log and causes clutter. // So in opt builds, don't log to stderr unless the user specifically sets // a preference to do so. - CFStringRef key = CFStringCreateWithCString(kCFAllocatorDefault, - "logToStdErr", - kCFStringEncodingUTF8); + CFStringRef key = CFStringCreateWithCString( + kCFAllocatorDefault, "logToStdErr", kCFStringEncodingUTF8); CFStringRef domain = CFBundleGetIdentifier(CFBundleGetMainBundle()); if (key != nullptr && domain != nullptr) { Boolean exists_and_is_valid; diff --git a/rtc_base/logging.h b/rtc_base/logging.h index 8f9d440fc2..f07ed8dbfe 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -395,7 +395,9 @@ class LogMessage { // Android code should use the 'const char*' version since tags are static // and we want to avoid allocating a std::string copy per log line. RTC_DEPRECATED - LogMessage(const char* file, int line, LoggingSeverity sev, + LogMessage(const char* file, + int line, + LoggingSeverity sev, const std::string& tag); ~LogMessage(); @@ -467,7 +469,7 @@ class LogMessage { // Updates min_sev_ appropriately when debug sinks change. static void UpdateMinLogSeverity(); - // These write out the actual log messages. +// These write out the actual log messages. #if defined(WEBRTC_ANDROID) static void OutputToDebug(const std::string& msg, LoggingSeverity severity, @@ -544,17 +546,15 @@ class LogMessage { // The _F version prefixes the message with the current function name. #if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F) #define RTC_LOG_F(sev) RTC_LOG(sev) << __PRETTY_FUNCTION__ << ": " -#define RTC_LOG_T_F(sev) RTC_LOG(sev) << this << ": " \ - << __PRETTY_FUNCTION__ << ": " +#define RTC_LOG_T_F(sev) \ + RTC_LOG(sev) << this << ": " << __PRETTY_FUNCTION__ << ": " #else #define RTC_LOG_F(sev) RTC_LOG(sev) << __FUNCTION__ << ": " #define RTC_LOG_T_F(sev) RTC_LOG(sev) << this << ": " << __FUNCTION__ << ": " #endif -#define RTC_LOG_CHECK_LEVEL(sev) \ - rtc::LogCheckLevel(rtc::sev) -#define RTC_LOG_CHECK_LEVEL_V(sev) \ - rtc::LogCheckLevel(sev) +#define RTC_LOG_CHECK_LEVEL(sev) rtc::LogCheckLevel(rtc::sev) +#define RTC_LOG_CHECK_LEVEL_V(sev) rtc::LogCheckLevel(sev) inline bool LogCheckLevel(LoggingSeverity sev) { return (LogMessage::GetMinLogSeverity() <= sev); @@ -571,37 +571,32 @@ inline bool LogCheckLevel(LoggingSeverity sev) { #define RTC_LOG_T(sev) RTC_LOG(sev) << this << ": " -#define RTC_LOG_ERRNO_EX(sev, err) \ - RTC_LOG_E(sev, ERRNO, err) -#define RTC_LOG_ERRNO(sev) \ - RTC_LOG_ERRNO_EX(sev, errno) +#define RTC_LOG_ERRNO_EX(sev, err) RTC_LOG_E(sev, ERRNO, err) +#define RTC_LOG_ERRNO(sev) RTC_LOG_ERRNO_EX(sev, errno) #if defined(WEBRTC_WIN) -#define RTC_LOG_GLE_EX(sev, err) \ - RTC_LOG_E(sev, HRESULT, err) +#define RTC_LOG_GLE_EX(sev, err) RTC_LOG_E(sev, HRESULT, err) #define RTC_LOG_GLE(sev) RTC_LOG_GLE_EX(sev, static_cast(GetLastError())) -#define RTC_LOG_ERR_EX(sev, err) \ - RTC_LOG_GLE_EX(sev, err) -#define RTC_LOG_ERR(sev) \ - RTC_LOG_GLE(sev) +#define RTC_LOG_ERR_EX(sev, err) RTC_LOG_GLE_EX(sev, err) +#define RTC_LOG_ERR(sev) RTC_LOG_GLE(sev) #elif defined(__native_client__) && __native_client__ -#define RTC_LOG_ERR_EX(sev, err) \ - RTC_LOG(sev) -#define RTC_LOG_ERR(sev) \ - RTC_LOG(sev) +#define RTC_LOG_ERR_EX(sev, err) RTC_LOG(sev) +#define RTC_LOG_ERR(sev) RTC_LOG(sev) #elif defined(WEBRTC_POSIX) -#define RTC_LOG_ERR_EX(sev, err) \ - RTC_LOG_ERRNO_EX(sev, err) -#define RTC_LOG_ERR(sev) \ - RTC_LOG_ERRNO(sev) +#define RTC_LOG_ERR_EX(sev, err) RTC_LOG_ERRNO_EX(sev, err) +#define RTC_LOG_ERR(sev) RTC_LOG_ERRNO(sev) #endif // WEBRTC_WIN #ifdef WEBRTC_ANDROID namespace webrtc_logging_impl { // TODO(kwiberg): Replace these with absl::string_view. -inline const char* AdaptString(const char* str) { return str; } -inline const char* AdaptString(const std::string& str) { return str.c_str(); } +inline const char* AdaptString(const char* str) { + return str; +} +inline const char* AdaptString(const std::string& str) { + return str.c_str(); +} } // namespace webrtc_logging_impl #define RTC_LOG_TAG(sev, tag) \ diff --git a/rtc_base/logging_unittest.cc b/rtc_base/logging_unittest.cc index 5bf78edc26..8f96095a79 100644 --- a/rtc_base/logging_unittest.cc +++ b/rtc_base/logging_unittest.cc @@ -20,19 +20,17 @@ namespace rtc { template -class LogSinkImpl - : public LogSink, - public Base { +class LogSinkImpl : public LogSink, public Base { public: LogSinkImpl() {} - template + template explicit LogSinkImpl(P* p) : Base(p) {} private: void OnLogMessage(const std::string& message) override { - static_cast(this)->WriteAll( - message.data(), message.size(), nullptr, nullptr); + static_cast(this)->WriteAll(message.data(), message.size(), nullptr, + nullptr); } }; @@ -193,7 +191,6 @@ TEST(LogTest, MultipleThreads) { EXPECT_EQ(sev, LogMessage::GetLogToStream(nullptr)); } - TEST(LogTest, WallClockStartTime) { uint32_t time = LogMessage::WallClockStartTime(); // Expect the time to be in a sensible range, e.g. > 2012-01-01. diff --git a/rtc_base/logsinks.cc b/rtc_base/logsinks.cc index 229b54225f..d5febee948 100644 --- a/rtc_base/logsinks.cc +++ b/rtc_base/logsinks.cc @@ -24,16 +24,14 @@ FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path, : FileRotatingLogSink(new FileRotatingStream(log_dir_path, log_prefix, max_log_size, - num_log_files)) { -} + num_log_files)) {} FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream) : stream_(stream) { RTC_DCHECK(stream); } -FileRotatingLogSink::~FileRotatingLogSink() { -} +FileRotatingLogSink::~FileRotatingLogSink() {} void FileRotatingLogSink::OnLogMessage(const std::string& message) { if (stream_->GetState() != SS_OPEN) { @@ -58,7 +56,6 @@ CallSessionFileRotatingLogSink::CallSessionFileRotatingLogSink( new CallSessionFileRotatingStream(log_dir_path, max_total_log_size)) { } -CallSessionFileRotatingLogSink::~CallSessionFileRotatingLogSink() { -} +CallSessionFileRotatingLogSink::~CallSessionFileRotatingLogSink() {} } // namespace rtc diff --git a/rtc_base/macutils.cc b/rtc_base/macutils.cc index 21f3f3d765..2b8700f4d6 100644 --- a/rtc_base/macutils.cc +++ b/rtc_base/macutils.cc @@ -25,10 +25,11 @@ bool ToUtf8(const CFStringRef str16, std::string* str8) { return false; } size_t maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str16), - kCFStringEncodingUTF8) + 1; + kCFStringEncodingUTF8) + + 1; std::unique_ptr buffer(new char[maxlen]); - if (!buffer || !CFStringGetCString(str16, buffer.get(), maxlen, - kCFStringEncodingUTF8)) { + if (!buffer || + !CFStringGetCString(str16, buffer.get(), maxlen, kCFStringEncodingUTF8)) { return false; } str8->assign(buffer.get()); @@ -41,8 +42,7 @@ bool ToUtf16(const std::string& str8, CFStringRef* str16) { } *str16 = CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast(str8.data()), - str8.length(), kCFStringEncodingUTF8, - false); + str8.length(), kCFStringEncodingUTF8, false); return nullptr != *str16; } } // namespace rtc diff --git a/rtc_base/memory_usage.cc b/rtc_base/memory_usage.cc index 41b27ededa..a70c54753f 100644 --- a/rtc_base/memory_usage.cc +++ b/rtc_base/memory_usage.cc @@ -12,14 +12,17 @@ #if defined(WEBRTC_LINUX) #include -#include #include +#include #include #elif defined(WEBRTC_MAC) #include #elif defined(WEBRTC_WIN) +// clang-format off +// clang formating would change include order. #include -#include +#include // must come after windows.h +// clang-format on #endif #include "rtc_base/logging.h" diff --git a/rtc_base/memory_usage_unittest.cc b/rtc_base/memory_usage_unittest.cc index 87cdcef89b..9c82f98034 100644 --- a/rtc_base/memory_usage_unittest.cc +++ b/rtc_base/memory_usage_unittest.cc @@ -20,4 +20,3 @@ TEST(GetMemoryUsage, SimpleTest) { } } // namespace rtc - diff --git a/rtc_base/messagedigest.cc b/rtc_base/messagedigest.cc index 1e4c3850fb..9c10bcd486 100644 --- a/rtc_base/messagedigest.cc +++ b/rtc_base/messagedigest.cc @@ -20,8 +20,8 @@ namespace rtc { // From RFC 4572. -const char DIGEST_MD5[] = "md5"; -const char DIGEST_SHA_1[] = "sha-1"; +const char DIGEST_MD5[] = "md5"; +const char DIGEST_SHA_1[] = "sha-1"; const char DIGEST_SHA_224[] = "sha-224"; const char DIGEST_SHA_256[] = "sha-256"; const char DIGEST_SHA_384[] = "sha-384"; @@ -44,35 +44,39 @@ bool IsFips180DigestAlgorithm(const std::string& alg) { // consideration) MUST use one of the FIPS 180 algorithms (SHA-1, // SHA-224, SHA-256, SHA-384, or SHA-512) as their signature algorithm, // and thus also MUST use it to calculate certificate fingerprints." - return alg == DIGEST_SHA_1 || - alg == DIGEST_SHA_224 || - alg == DIGEST_SHA_256 || - alg == DIGEST_SHA_384 || + return alg == DIGEST_SHA_1 || alg == DIGEST_SHA_224 || + alg == DIGEST_SHA_256 || alg == DIGEST_SHA_384 || alg == DIGEST_SHA_512; } -size_t ComputeDigest(MessageDigest* digest, const void* input, size_t in_len, - void* output, size_t out_len) { +size_t ComputeDigest(MessageDigest* digest, + const void* input, + size_t in_len, + void* output, + size_t out_len) { digest->Update(input, in_len); return digest->Finish(output, out_len); } -size_t ComputeDigest(const std::string& alg, const void* input, size_t in_len, - void* output, size_t out_len) { +size_t ComputeDigest(const std::string& alg, + const void* input, + size_t in_len, + void* output, + size_t out_len) { std::unique_ptr digest(MessageDigestFactory::Create(alg)); - return (digest) ? - ComputeDigest(digest.get(), input, in_len, output, out_len) : - 0; + return (digest) ? ComputeDigest(digest.get(), input, in_len, output, out_len) + : 0; } std::string ComputeDigest(MessageDigest* digest, const std::string& input) { std::unique_ptr output(new char[digest->Size()]); - ComputeDigest(digest, input.data(), input.size(), - output.get(), digest->Size()); + ComputeDigest(digest, input.data(), input.size(), output.get(), + digest->Size()); return hex_encode(output.get(), digest->Size()); } -bool ComputeDigest(const std::string& alg, const std::string& input, +bool ComputeDigest(const std::string& alg, + const std::string& input, std::string* output) { std::unique_ptr digest(MessageDigestFactory::Create(alg)); if (!digest) { @@ -90,9 +94,12 @@ std::string ComputeDigest(const std::string& alg, const std::string& input) { // Compute a RFC 2104 HMAC: H(K XOR opad, H(K XOR ipad, text)) size_t ComputeHmac(MessageDigest* digest, - const void* key, size_t key_len, - const void* input, size_t in_len, - void* output, size_t out_len) { + const void* key, + size_t key_len, + const void* input, + size_t in_len, + void* output, + size_t out_len) { // We only handle algorithms with a 64-byte blocksize. // TODO: Add BlockSize() method to MessageDigest. size_t block_len = kBlockSize; @@ -127,27 +134,34 @@ size_t ComputeHmac(MessageDigest* digest, return digest->Finish(output, out_len); } -size_t ComputeHmac(const std::string& alg, const void* key, size_t key_len, - const void* input, size_t in_len, - void* output, size_t out_len) { +size_t ComputeHmac(const std::string& alg, + const void* key, + size_t key_len, + const void* input, + size_t in_len, + void* output, + size_t out_len) { std::unique_ptr digest(MessageDigestFactory::Create(alg)); if (!digest) { return 0; } - return ComputeHmac(digest.get(), key, key_len, - input, in_len, output, out_len); + return ComputeHmac(digest.get(), key, key_len, input, in_len, output, + out_len); } -std::string ComputeHmac(MessageDigest* digest, const std::string& key, +std::string ComputeHmac(MessageDigest* digest, + const std::string& key, const std::string& input) { std::unique_ptr output(new char[digest->Size()]); - ComputeHmac(digest, key.data(), key.size(), - input.data(), input.size(), output.get(), digest->Size()); + ComputeHmac(digest, key.data(), key.size(), input.data(), input.size(), + output.get(), digest->Size()); return hex_encode(output.get(), digest->Size()); } -bool ComputeHmac(const std::string& alg, const std::string& key, - const std::string& input, std::string* output) { +bool ComputeHmac(const std::string& alg, + const std::string& key, + const std::string& input, + std::string* output) { std::unique_ptr digest(MessageDigestFactory::Create(alg)); if (!digest) { return false; @@ -156,7 +170,8 @@ bool ComputeHmac(const std::string& alg, const std::string& key, return true; } -std::string ComputeHmac(const std::string& alg, const std::string& key, +std::string ComputeHmac(const std::string& alg, + const std::string& key, const std::string& input) { std::string output; ComputeHmac(alg, key, input, &output); diff --git a/rtc_base/messagedigest.h b/rtc_base/messagedigest.h index f80dd7aa53..fc82088543 100644 --- a/rtc_base/messagedigest.h +++ b/rtc_base/messagedigest.h @@ -52,13 +52,19 @@ bool IsFips180DigestAlgorithm(const std::string& alg); // implementation, and outputs the hash to the buffer |output|, which is // |out_len| bytes long. Returns the number of bytes written to |output| if // successful, or 0 if |out_len| was too small. -size_t ComputeDigest(MessageDigest* digest, const void* input, size_t in_len, - void* output, size_t out_len); +size_t ComputeDigest(MessageDigest* digest, + const void* input, + size_t in_len, + void* output, + size_t out_len); // Like the previous function, but creates a digest implementation based on // the desired digest name |alg|, e.g. DIGEST_SHA_1. Returns 0 if there is no // digest with the given name. -size_t ComputeDigest(const std::string& alg, const void* input, size_t in_len, - void* output, size_t out_len); +size_t ComputeDigest(const std::string& alg, + const void* input, + size_t in_len, + void* output, + size_t out_len); // Computes the hash of |input| using the |digest| hash implementation, and // returns it as a hex-encoded string. std::string ComputeDigest(MessageDigest* digest, const std::string& input); @@ -67,7 +73,8 @@ std::string ComputeDigest(MessageDigest* digest, const std::string& input); // there is no digest with the given name. std::string ComputeDigest(const std::string& alg, const std::string& input); // Like the previous function, but returns an explicit result code. -bool ComputeDigest(const std::string& alg, const std::string& input, +bool ComputeDigest(const std::string& alg, + const std::string& input, std::string* output); // Shorthand way to compute a hex-encoded hash using MD5. @@ -82,27 +89,39 @@ inline std::string MD5(const std::string& input) { // the HMAC to the buffer |output|, which is |out_len| bytes long. Returns the // number of bytes written to |output| if successful, or 0 if |out_len| was too // small. -size_t ComputeHmac(MessageDigest* digest, const void* key, size_t key_len, - const void* input, size_t in_len, - void* output, size_t out_len); +size_t ComputeHmac(MessageDigest* digest, + const void* key, + size_t key_len, + const void* input, + size_t in_len, + void* output, + size_t out_len); // Like the previous function, but creates a digest implementation based on // the desired digest name |alg|, e.g. DIGEST_SHA_1. Returns 0 if there is no // digest with the given name. -size_t ComputeHmac(const std::string& alg, const void* key, size_t key_len, - const void* input, size_t in_len, - void* output, size_t out_len); +size_t ComputeHmac(const std::string& alg, + const void* key, + size_t key_len, + const void* input, + size_t in_len, + void* output, + size_t out_len); // Computes the HMAC of |input| using the |digest| hash implementation and |key| // to key the HMAC, and returns it as a hex-encoded string. -std::string ComputeHmac(MessageDigest* digest, const std::string& key, +std::string ComputeHmac(MessageDigest* digest, + const std::string& key, const std::string& input); // Like the previous function, but creates a digest implementation based on // the desired digest name |alg|, e.g. DIGEST_SHA_1. Returns empty string if // there is no digest with the given name. -std::string ComputeHmac(const std::string& alg, const std::string& key, +std::string ComputeHmac(const std::string& alg, + const std::string& key, const std::string& input); // Like the previous function, but returns an explicit result code. -bool ComputeHmac(const std::string& alg, const std::string& key, - const std::string& input, std::string* output); +bool ComputeHmac(const std::string& alg, + const std::string& key, + const std::string& input, + std::string* output); } // namespace rtc diff --git a/rtc_base/messagedigest_unittest.cc b/rtc_base/messagedigest_unittest.cc index 4d7c338fa8..5524b18b99 100644 --- a/rtc_base/messagedigest_unittest.cc +++ b/rtc_base/messagedigest_unittest.cc @@ -17,42 +17,42 @@ namespace rtc { // Test vectors from RFC 1321. TEST(MessageDigestTest, TestMd5Digest) { // Test the string versions of the APIs. - EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", - ComputeDigest(DIGEST_MD5, "")); + EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", ComputeDigest(DIGEST_MD5, "")); EXPECT_EQ("900150983cd24fb0d6963f7d28e17f72", - ComputeDigest(DIGEST_MD5, "abc")); + ComputeDigest(DIGEST_MD5, "abc")); EXPECT_EQ("c3fcd3d76192e4007dfb496cca67e13b", - ComputeDigest(DIGEST_MD5, "abcdefghijklmnopqrstuvwxyz")); + ComputeDigest(DIGEST_MD5, "abcdefghijklmnopqrstuvwxyz")); // Test the raw buffer versions of the APIs; also check output buffer size. char output[16]; EXPECT_EQ(sizeof(output), - ComputeDigest(DIGEST_MD5, "abc", 3, output, sizeof(output))); + ComputeDigest(DIGEST_MD5, "abc", 3, output, sizeof(output))); EXPECT_EQ("900150983cd24fb0d6963f7d28e17f72", - hex_encode(output, sizeof(output))); + hex_encode(output, sizeof(output))); EXPECT_EQ(0U, - ComputeDigest(DIGEST_MD5, "abc", 3, output, sizeof(output) - 1)); + ComputeDigest(DIGEST_MD5, "abc", 3, output, sizeof(output) - 1)); } // Test vectors from RFC 3174. TEST(MessageDigestTest, TestSha1Digest) { // Test the string versions of the APIs. EXPECT_EQ("da39a3ee5e6b4b0d3255bfef95601890afd80709", - ComputeDigest(DIGEST_SHA_1, "")); + ComputeDigest(DIGEST_SHA_1, "")); EXPECT_EQ("a9993e364706816aba3e25717850c26c9cd0d89d", - ComputeDigest(DIGEST_SHA_1, "abc")); + ComputeDigest(DIGEST_SHA_1, "abc")); EXPECT_EQ("84983e441c3bd26ebaae4aa1f95129e5e54670f1", - ComputeDigest(DIGEST_SHA_1, - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); + ComputeDigest( + DIGEST_SHA_1, + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); // Test the raw buffer versions of the APIs; also check output buffer size. char output[20]; EXPECT_EQ(sizeof(output), - ComputeDigest(DIGEST_SHA_1, "abc", 3, output, sizeof(output))); + ComputeDigest(DIGEST_SHA_1, "abc", 3, output, sizeof(output))); EXPECT_EQ("a9993e364706816aba3e25717850c26c9cd0d89d", - hex_encode(output, sizeof(output))); + hex_encode(output, sizeof(output))); EXPECT_EQ(0U, - ComputeDigest(DIGEST_SHA_1, "abc", 3, output, sizeof(output) - 1)); + ComputeDigest(DIGEST_SHA_1, "abc", 3, output, sizeof(output) - 1)); } // Test that we fail properly if a bad digest algorithm is specified. @@ -66,80 +66,83 @@ TEST(MessageDigestTest, TestBadDigest) { TEST(MessageDigestTest, TestMd5Hmac) { // Test the string versions of the APIs. EXPECT_EQ("9294727a3638bb1c13f48ef8158bfc9d", - ComputeHmac(DIGEST_MD5, std::string(16, '\x0b'), "Hi There")); + ComputeHmac(DIGEST_MD5, std::string(16, '\x0b'), "Hi There")); EXPECT_EQ("750c783e6ab0b503eaa86e310a5db738", - ComputeHmac(DIGEST_MD5, "Jefe", "what do ya want for nothing?")); + ComputeHmac(DIGEST_MD5, "Jefe", "what do ya want for nothing?")); EXPECT_EQ("56be34521d144c88dbb8c733f0e8b3f6", - ComputeHmac(DIGEST_MD5, std::string(16, '\xaa'), - std::string(50, '\xdd'))); - EXPECT_EQ("697eaf0aca3a3aea3a75164746ffaa79", + ComputeHmac(DIGEST_MD5, std::string(16, '\xaa'), + std::string(50, '\xdd'))); + EXPECT_EQ( + "697eaf0aca3a3aea3a75164746ffaa79", ComputeHmac(DIGEST_MD5, - "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", - std::string(50, '\xcd'))); - EXPECT_EQ("56461ef2342edc00f9bab995690efd4c", - ComputeHmac(DIGEST_MD5, std::string(16, '\x0c'), - "Test With Truncation")); - EXPECT_EQ("6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + std::string(50, '\xcd'))); + EXPECT_EQ( + "56461ef2342edc00f9bab995690efd4c", + ComputeHmac(DIGEST_MD5, std::string(16, '\x0c'), "Test With Truncation")); + EXPECT_EQ( + "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", ComputeHmac(DIGEST_MD5, std::string(80, '\xaa'), - "Test Using Larger Than Block-Size Key - Hash Key First")); + "Test Using Larger Than Block-Size Key - Hash Key First")); EXPECT_EQ("6f630fad67cda0ee1fb1f562db3aa53e", - ComputeHmac(DIGEST_MD5, std::string(80, '\xaa'), - "Test Using Larger Than Block-Size Key and Larger " - "Than One Block-Size Data")); + ComputeHmac(DIGEST_MD5, std::string(80, '\xaa'), + "Test Using Larger Than Block-Size Key and Larger " + "Than One Block-Size Data")); // Test the raw buffer versions of the APIs; also check output buffer size. std::string key(16, '\x0b'); std::string input("Hi There"); char output[16]; EXPECT_EQ(sizeof(output), - ComputeHmac(DIGEST_MD5, key.c_str(), key.size(), - input.c_str(), input.size(), output, sizeof(output))); + ComputeHmac(DIGEST_MD5, key.c_str(), key.size(), input.c_str(), + input.size(), output, sizeof(output))); EXPECT_EQ("9294727a3638bb1c13f48ef8158bfc9d", - hex_encode(output, sizeof(output))); - EXPECT_EQ(0U, - ComputeHmac(DIGEST_MD5, key.c_str(), key.size(), - input.c_str(), input.size(), output, sizeof(output) - 1)); + hex_encode(output, sizeof(output))); + EXPECT_EQ(0U, ComputeHmac(DIGEST_MD5, key.c_str(), key.size(), input.c_str(), + input.size(), output, sizeof(output) - 1)); } // Test vectors from RFC 2202. TEST(MessageDigestTest, TestSha1Hmac) { // Test the string versions of the APIs. EXPECT_EQ("b617318655057264e28bc0b6fb378c8ef146be00", - ComputeHmac(DIGEST_SHA_1, std::string(20, '\x0b'), "Hi There")); + ComputeHmac(DIGEST_SHA_1, std::string(20, '\x0b'), "Hi There")); EXPECT_EQ("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", - ComputeHmac(DIGEST_SHA_1, "Jefe", "what do ya want for nothing?")); + ComputeHmac(DIGEST_SHA_1, "Jefe", "what do ya want for nothing?")); EXPECT_EQ("125d7342b9ac11cd91a39af48aa17b4f63f175d3", - ComputeHmac(DIGEST_SHA_1, std::string(20, '\xaa'), - std::string(50, '\xdd'))); - EXPECT_EQ("4c9007f4026250c6bc8414f9bf50c86c2d7235da", + ComputeHmac(DIGEST_SHA_1, std::string(20, '\xaa'), + std::string(50, '\xdd'))); + EXPECT_EQ( + "4c9007f4026250c6bc8414f9bf50c86c2d7235da", ComputeHmac(DIGEST_SHA_1, - "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", - std::string(50, '\xcd'))); + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + std::string(50, '\xcd'))); EXPECT_EQ("4c1a03424b55e07fe7f27be1d58bb9324a9a5a04", - ComputeHmac(DIGEST_SHA_1, std::string(20, '\x0c'), - "Test With Truncation")); - EXPECT_EQ("aa4ae5e15272d00e95705637ce8a3b55ed402112", + ComputeHmac(DIGEST_SHA_1, std::string(20, '\x0c'), + "Test With Truncation")); + EXPECT_EQ( + "aa4ae5e15272d00e95705637ce8a3b55ed402112", ComputeHmac(DIGEST_SHA_1, std::string(80, '\xaa'), - "Test Using Larger Than Block-Size Key - Hash Key First")); + "Test Using Larger Than Block-Size Key - Hash Key First")); EXPECT_EQ("e8e99d0f45237d786d6bbaa7965c7808bbff1a91", - ComputeHmac(DIGEST_SHA_1, std::string(80, '\xaa'), - "Test Using Larger Than Block-Size Key and Larger " - "Than One Block-Size Data")); + ComputeHmac(DIGEST_SHA_1, std::string(80, '\xaa'), + "Test Using Larger Than Block-Size Key and Larger " + "Than One Block-Size Data")); // Test the raw buffer versions of the APIs; also check output buffer size. std::string key(20, '\x0b'); std::string input("Hi There"); char output[20]; EXPECT_EQ(sizeof(output), - ComputeHmac(DIGEST_SHA_1, key.c_str(), key.size(), - input.c_str(), input.size(), output, sizeof(output))); + ComputeHmac(DIGEST_SHA_1, key.c_str(), key.size(), input.c_str(), + input.size(), output, sizeof(output))); EXPECT_EQ("b617318655057264e28bc0b6fb378c8ef146be00", - hex_encode(output, sizeof(output))); + hex_encode(output, sizeof(output))); EXPECT_EQ(0U, - ComputeHmac(DIGEST_SHA_1, key.c_str(), key.size(), - input.c_str(), input.size(), output, sizeof(output) - 1)); + ComputeHmac(DIGEST_SHA_1, key.c_str(), key.size(), input.c_str(), + input.size(), output, sizeof(output) - 1)); } TEST(MessageDigestTest, TestBadHmac) { diff --git a/rtc_base/messagehandler.cc b/rtc_base/messagehandler.cc index 2f580cc703..7376defaf7 100644 --- a/rtc_base/messagehandler.cc +++ b/rtc_base/messagehandler.cc @@ -17,4 +17,4 @@ MessageHandler::~MessageHandler() { MessageQueueManager::Clear(this); } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/messagehandler.h b/rtc_base/messagehandler.h index ff953f7898..df2d1ada8d 100644 --- a/rtc_base/messagehandler.h +++ b/rtc_base/messagehandler.h @@ -40,9 +40,7 @@ class FunctorMessageHandler : public MessageHandler { public: explicit FunctorMessageHandler(FunctorT&& functor) : functor_(std::forward(functor)) {} - virtual void OnMessage(Message* msg) { - result_ = functor_(); - } + virtual void OnMessage(Message* msg) { result_ = functor_(); } const ReturnT& result() const { return result_; } // Returns moved result. Should not call result() or MoveResult() again @@ -58,11 +56,8 @@ class FunctorMessageHandler : public MessageHandler { template class FunctorMessageHandler : public MessageHandler { public: - explicit FunctorMessageHandler(const FunctorT& functor) - : functor_(functor) {} - virtual void OnMessage(Message* msg) { - functor_(); - } + explicit FunctorMessageHandler(const FunctorT& functor) : functor_(functor) {} + virtual void OnMessage(Message* msg) { functor_(); } void result() const {} void MoveResult() {} @@ -70,6 +65,6 @@ class FunctorMessageHandler : public MessageHandler { FunctorT functor_; }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_MESSAGEHANDLER_H_ +#endif // RTC_BASE_MESSAGEHANDLER_H_ diff --git a/rtc_base/messagequeue.cc b/rtc_base/messagequeue.cc index 10bde2091c..035ff07066 100644 --- a/rtc_base/messagequeue.cc +++ b/rtc_base/messagequeue.cc @@ -20,7 +20,7 @@ namespace rtc { namespace { -const int kMaxMsgLatency = 150; // 150 ms +const int kMaxMsgLatency = 150; // 150 ms const int kSlowDispatchLoggingThreshold = 50; // 50 ms class RTC_SCOPED_LOCKABLE MarkProcessingCritScope { @@ -64,26 +64,26 @@ bool MessageQueueManager::IsInitialized() { MessageQueueManager::MessageQueueManager() : processing_(0) {} -MessageQueueManager::~MessageQueueManager() { -} +MessageQueueManager::~MessageQueueManager() {} -void MessageQueueManager::Add(MessageQueue *message_queue) { +void MessageQueueManager::Add(MessageQueue* message_queue) { return Instance()->AddInternal(message_queue); } -void MessageQueueManager::AddInternal(MessageQueue *message_queue) { +void MessageQueueManager::AddInternal(MessageQueue* message_queue) { CritScope cs(&crit_); // Prevent changes while the list of message queues is processed. RTC_DCHECK_EQ(processing_, 0); message_queues_.push_back(message_queue); } -void MessageQueueManager::Remove(MessageQueue *message_queue) { +void MessageQueueManager::Remove(MessageQueue* message_queue) { // If there isn't a message queue manager instance, then there isn't a queue // to remove. - if (!instance_) return; + if (!instance_) + return; return Instance()->RemoveInternal(message_queue); } -void MessageQueueManager::RemoveInternal(MessageQueue *message_queue) { +void MessageQueueManager::RemoveInternal(MessageQueue* message_queue) { // If this is the last MessageQueue, destroy the manager as well so that // we don't leak this object at program shutdown. As mentioned above, this is // not thread-safe, but this should only happen at program termination (when @@ -93,7 +93,7 @@ void MessageQueueManager::RemoveInternal(MessageQueue *message_queue) { CritScope cs(&crit_); // Prevent changes while the list of message queues is processed. RTC_DCHECK_EQ(processing_, 0); - std::vector::iterator iter; + std::vector::iterator iter; iter = std::find(message_queues_.begin(), message_queues_.end(), message_queue); if (iter != message_queues_.end()) { @@ -107,13 +107,14 @@ void MessageQueueManager::RemoveInternal(MessageQueue *message_queue) { } } -void MessageQueueManager::Clear(MessageHandler *handler) { +void MessageQueueManager::Clear(MessageHandler* handler) { // If there isn't a message queue manager instance, then there aren't any // queues to remove this handler from. - if (!instance_) return; + if (!instance_) + return; return Instance()->ClearInternal(handler); } -void MessageQueueManager::ClearInternal(MessageHandler *handler) { +void MessageQueueManager::ClearInternal(MessageHandler* handler) { // Deleted objects may cause re-entrant calls to ClearInternal. This is // allowed as the list of message queues does not change while queues are // cleared. @@ -252,7 +253,7 @@ void MessageQueue::Restart() { AtomicOps::ReleaseStore(&stop_, 0); } -bool MessageQueue::Peek(Message *pmsg, int cmsWait) { +bool MessageQueue::Peek(Message* pmsg, int cmsWait) { if (fPeekKeep_) { *pmsg = msgPeek_; return true; @@ -264,7 +265,7 @@ bool MessageQueue::Peek(Message *pmsg, int cmsWait) { return true; } -bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) { +bool MessageQueue::Get(Message* pmsg, int cmsWait, bool process_io) { // Return and clear peek if present // Always return the peek if it exists so there is Peek/Get symmetry @@ -366,8 +367,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) { return false; } -void MessageQueue::ReceiveSends() { -} +void MessageQueue::ReceiveSends() {} void MessageQueue::Post(const Location& posted_from, MessageHandler* phandler, @@ -522,7 +522,7 @@ void MessageQueue::Clear(MessageHandler* phandler, dmsgq_.reheap(); } -void MessageQueue::Dispatch(Message *pmsg) { +void MessageQueue::Dispatch(Message* pmsg) { TRACE_EVENT2("webrtc", "MessageQueue::Dispatch", "src_file_and_line", pmsg->posted_from.file_and_line(), "src_func", pmsg->posted_from.function_name()); diff --git a/rtc_base/messagequeue.h b/rtc_base/messagequeue.h index c08b860705..c156d155bf 100644 --- a/rtc_base/messagequeue.h +++ b/rtc_base/messagequeue.h @@ -39,9 +39,9 @@ class MessageQueue; class MessageQueueManager { public: - static void Add(MessageQueue *message_queue); - static void Remove(MessageQueue *message_queue); - static void Clear(MessageHandler *handler); + static void Add(MessageQueue* message_queue); + static void Remove(MessageQueue* message_queue); + static void Clear(MessageHandler* handler); // For testing purposes, we expose whether or not the MessageQueueManager // instance has been initialized. It has no other use relative to the rest of @@ -60,9 +60,9 @@ class MessageQueueManager { MessageQueueManager(); ~MessageQueueManager(); - void AddInternal(MessageQueue *message_queue); - void RemoveInternal(MessageQueue *message_queue); - void ClearInternal(MessageHandler *handler); + void AddInternal(MessageQueue* message_queue); + void RemoveInternal(MessageQueue* message_queue); + void ClearInternal(MessageHandler* handler); void ProcessAllMessageQueuesInternal(); static MessageQueueManager* instance_; @@ -88,9 +88,10 @@ class MessageData { template class TypedMessageData : public MessageData { public: - explicit TypedMessageData(const T& data) : data_(data) { } + explicit TypedMessageData(const T& data) : data_(data) {} const T& data() const { return data_; } T& data() { return data_; } + private: T data_; }; @@ -122,28 +123,30 @@ class ScopedMessageData : public MessageData { template class ScopedRefMessageData : public MessageData { public: - explicit ScopedRefMessageData(T* data) : data_(data) { } + explicit ScopedRefMessageData(T* data) : data_(data) {} const scoped_refptr& data() const { return data_; } scoped_refptr& data() { return data_; } + private: scoped_refptr data_; }; -template +template inline MessageData* WrapMessageData(const T& data) { return new TypedMessageData(data); } -template +template inline const T& UseMessageData(MessageData* data) { - return static_cast< TypedMessageData* >(data)->data(); + return static_cast*>(data)->data(); } -template +template class DisposeData : public MessageData { public: - explicit DisposeData(T* data) : data_(data) { } + explicit DisposeData(T* data) : data_(data) {} virtual ~DisposeData() { delete data_; } + private: T* data_; }; @@ -161,9 +164,9 @@ struct Message { (id == MQID_ANY || id == message_id); } Location posted_from; - MessageHandler *phandler; + MessageHandler* phandler; uint32_t message_id; - MessageData *pdata; + MessageData* pdata; int64_t ts_sensitive; }; @@ -180,9 +183,9 @@ class DelayedMessage { const Message& msg) : cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) {} - bool operator< (const DelayedMessage& dmsg) const { - return (dmsg.msTrigger_ < msTrigger_) - || ((dmsg.msTrigger_ == msTrigger_) && (dmsg.num_ < num_)); + bool operator<(const DelayedMessage& dmsg) const { + return (dmsg.msTrigger_ < msTrigger_) || + ((dmsg.msTrigger_ == msTrigger_) && (dmsg.num_ < num_)); } int64_t cmsDelay_; // for debugging @@ -229,9 +232,10 @@ class MessageQueue { // 1) A message is available (returns true) // 2) cmsWait seconds have elapsed (returns false) // 3) Stop() is called (returns false) - virtual bool Get(Message *pmsg, int cmsWait = kForever, + virtual bool Get(Message* pmsg, + int cmsWait = kForever, bool process_io = true); - virtual bool Peek(Message *pmsg, int cmsWait = 0); + virtual bool Peek(Message* pmsg, int cmsWait = 0); virtual void Post(const Location& posted_from, MessageHandler* phandler, uint32_t id = 0, @@ -256,7 +260,7 @@ class MessageQueue { virtual void Clear(MessageHandler* phandler, uint32_t id = MQID_ANY, MessageList* removed = nullptr); - virtual void Dispatch(Message *pmsg); + virtual void Dispatch(Message* pmsg); virtual void ReceiveSends(); // Amount of time until the next message can be retrieved @@ -269,7 +273,8 @@ class MessageQueue { } // Internally posts a message which causes the doomed object to be deleted - template void Dispose(T* doomed) { + template + void Dispose(T* doomed) { if (doomed) { Post(RTC_FROM_HERE, nullptr, MQID_DISPOSE, new DisposeData(doomed)); } diff --git a/rtc_base/messagequeue_unittest.cc b/rtc_base/messagequeue_unittest.cc index 9e1ba63cf3..1018a62f9f 100644 --- a/rtc_base/messagequeue_unittest.cc +++ b/rtc_base/messagequeue_unittest.cc @@ -25,7 +25,7 @@ using namespace rtc; -class MessageQueueTest: public testing::Test, public MessageQueue { +class MessageQueueTest : public testing::Test, public MessageQueue { public: MessageQueueTest() : MessageQueue(SocketServer::CreateDefault(), true) {} bool IsLocked_Worker() { @@ -47,7 +47,7 @@ class MessageQueueTest: public testing::Test, public MessageQueue { struct DeletedLockChecker { DeletedLockChecker(MessageQueueTest* test, bool* was_locked, bool* deleted) - : test(test), was_locked(was_locked), deleted(deleted) { } + : test(test), was_locked(was_locked), deleted(deleted) {} ~DeletedLockChecker() { *deleted = true; *was_locked = test->IsLocked(); @@ -68,7 +68,7 @@ static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder( q->PostAt(RTC_FROM_HERE, now - 1, nullptr, 2); Message msg; - for (size_t i=0; i<5; ++i) { + for (size_t i = 0; i < 5; ++i) { memset(&msg, 0, sizeof(msg)); EXPECT_TRUE(q->Get(&msg, 0)); EXPECT_EQ(i, msg.message_id); @@ -100,7 +100,7 @@ TEST_F(MessageQueueTest, DisposeNotLocked) { class DeletedMessageHandler : public MessageHandler { public: - explicit DeletedMessageHandler(bool* deleted) : deleted_(deleted) { } + explicit DeletedMessageHandler(bool* deleted) : deleted_(deleted) {} ~DeletedMessageHandler() override { *deleted_ = true; } void OnMessage(Message* msg) override {} @@ -110,7 +110,7 @@ class DeletedMessageHandler : public MessageHandler { TEST_F(MessageQueueTest, DiposeHandlerWithPostedMessagePending) { bool deleted = false; - DeletedMessageHandler *handler = new DeletedMessageHandler(&deleted); + DeletedMessageHandler* handler = new DeletedMessageHandler(&deleted); // First, post a dispose. Dispose(handler); // Now, post a message, which should *not* be returned by Get(). @@ -122,11 +122,14 @@ TEST_F(MessageQueueTest, DiposeHandlerWithPostedMessagePending) { struct UnwrapMainThreadScope { UnwrapMainThreadScope() : rewrap_(Thread::Current() != nullptr) { - if (rewrap_) ThreadManager::Instance()->UnwrapCurrentThread(); + if (rewrap_) + ThreadManager::Instance()->UnwrapCurrentThread(); } ~UnwrapMainThreadScope() { - if (rewrap_) ThreadManager::Instance()->WrapCurrentThread(); + if (rewrap_) + ThreadManager::Instance()->WrapCurrentThread(); } + private: bool rewrap_; }; @@ -218,9 +221,7 @@ TEST(MessageQueueManager, ProcessAllMessageQueuesWithClearedQueue) { MessageQueueManager::ProcessAllMessageQueues(); } -class RefCountedHandler - : public MessageHandler, - public rtc::RefCountInterface { +class RefCountedHandler : public MessageHandler, public rtc::RefCountInterface { public: void OnMessage(Message* msg) override {} }; diff --git a/rtc_base/nat_unittest.cc b/rtc_base/nat_unittest.cc index bbe8b65ce9..e860f520b5 100644 --- a/rtc_base/nat_unittest.cc +++ b/rtc_base/nat_unittest.cc @@ -26,15 +26,16 @@ using namespace rtc; -bool CheckReceive( - TestClient* client, bool should_receive, const char* buf, size_t size) { - return (should_receive) ? - client->CheckNextPacket(buf, size, 0) : - client->CheckNoPacket(); +bool CheckReceive(TestClient* client, + bool should_receive, + const char* buf, + size_t size) { + return (should_receive) ? client->CheckNextPacket(buf, size, 0) + : client->CheckNoPacket(); } -TestClient* CreateTestClient( - SocketFactory* factory, const SocketAddress& local_addr) { +TestClient* CreateTestClient(SocketFactory* factory, + const SocketAddress& local_addr) { return new TestClient( WrapUnique(AsyncUDPSocket::Create(factory, local_addr))); } @@ -46,10 +47,12 @@ TestClient* CreateTCPTestClient(AsyncSocket* socket) { // Tests that when sending from internal_addr to external_addrs through the // NAT type specified by nat_type, all external addrs receive the sent packet // and, if exp_same is true, all use the same mapped-address on the NAT. -void TestSend( - SocketServer* internal, const SocketAddress& internal_addr, - SocketServer* external, const SocketAddress external_addrs[4], - NATType nat_type, bool exp_same) { +void TestSend(SocketServer* internal, + const SocketAddress& internal_addr, + SocketServer* external, + const SocketAddress external_addrs[4], + NATType nat_type, + bool exp_same) { Thread th_int(internal); Thread th_ext(external); @@ -57,9 +60,8 @@ void TestSend( server_addr.SetPort(0); // Auto-select a port NATServer* nat = new NATServer(nat_type, internal, server_addr, server_addr, external, external_addrs[0]); - NATSocketFactory* natsf = new NATSocketFactory(internal, - nat->internal_udp_address(), - nat->internal_tcp_address()); + NATSocketFactory* natsf = new NATSocketFactory( + internal, nat->internal_udp_address(), nat->internal_tcp_address()); TestClient* in = CreateTestClient(natsf, internal_addr); TestClient* out[4]; @@ -98,10 +100,13 @@ void TestSend( // Tests that when sending from external_addrs to internal_addr, the packet // is delivered according to the specified filter_ip and filter_port rules. -void TestRecv( - SocketServer* internal, const SocketAddress& internal_addr, - SocketServer* external, const SocketAddress external_addrs[4], - NATType nat_type, bool filter_ip, bool filter_port) { +void TestRecv(SocketServer* internal, + const SocketAddress& internal_addr, + SocketServer* external, + const SocketAddress external_addrs[4], + NATType nat_type, + bool filter_ip, + bool filter_port) { Thread th_int(internal); Thread th_ext(external); @@ -109,9 +114,8 @@ void TestRecv( server_addr.SetPort(0); // Auto-select a port NATServer* nat = new NATServer(nat_type, internal, server_addr, server_addr, external, external_addrs[0]); - NATSocketFactory* natsf = new NATSocketFactory(internal, - nat->internal_udp_address(), - nat->internal_tcp_address()); + NATSocketFactory* natsf = new NATSocketFactory( + internal, nat->internal_udp_address(), nat->internal_tcp_address()); TestClient* in = CreateTestClient(natsf, internal_addr); TestClient* out[4]; @@ -148,31 +152,33 @@ void TestRecv( } // Tests that NATServer allocates bindings properly. -void TestBindings( - SocketServer* internal, const SocketAddress& internal_addr, - SocketServer* external, const SocketAddress external_addrs[4]) { - TestSend(internal, internal_addr, external, external_addrs, - NAT_OPEN_CONE, true); +void TestBindings(SocketServer* internal, + const SocketAddress& internal_addr, + SocketServer* external, + const SocketAddress external_addrs[4]) { + TestSend(internal, internal_addr, external, external_addrs, NAT_OPEN_CONE, + true); TestSend(internal, internal_addr, external, external_addrs, NAT_ADDR_RESTRICTED, true); TestSend(internal, internal_addr, external, external_addrs, NAT_PORT_RESTRICTED, true); - TestSend(internal, internal_addr, external, external_addrs, - NAT_SYMMETRIC, false); + TestSend(internal, internal_addr, external, external_addrs, NAT_SYMMETRIC, + false); } // Tests that NATServer filters packets properly. -void TestFilters( - SocketServer* internal, const SocketAddress& internal_addr, - SocketServer* external, const SocketAddress external_addrs[4]) { - TestRecv(internal, internal_addr, external, external_addrs, - NAT_OPEN_CONE, false, false); +void TestFilters(SocketServer* internal, + const SocketAddress& internal_addr, + SocketServer* external, + const SocketAddress external_addrs[4]) { + TestRecv(internal, internal_addr, external, external_addrs, NAT_OPEN_CONE, + false, false); TestRecv(internal, internal_addr, external, external_addrs, NAT_ADDR_RESTRICTED, true, false); TestRecv(internal, internal_addr, external, external_addrs, NAT_PORT_RESTRICTED, true, true); - TestRecv(internal, internal_addr, external, external_addrs, - NAT_SYMMETRIC, true, true); + TestRecv(internal, internal_addr, external, external_addrs, NAT_SYMMETRIC, + true, true); } bool TestConnectivity(const SocketAddress& src, const IPAddress& dst) { @@ -224,7 +230,7 @@ void TestPhysicalInternal(const SocketAddress& int_addr) { // Find an available IP with matching family. The test breaks if int_addr // can't talk to ip, so check for connectivity as well. for (std::vector::iterator it = networks.begin(); - it != networks.end(); ++it) { + it != networks.end(); ++it) { const IPAddress& ip = (*it)->GetBestIP(); if (ip.family() == int_addr.family() && TestConnectivity(int_addr, ip)) { ext_addr2.SetIP(ip); @@ -240,11 +246,8 @@ void TestPhysicalInternal(const SocketAddress& int_addr) { RTC_LOG(LS_INFO) << "selected ip " << ext_addr2.ipaddr().ToString(); SocketAddress ext_addrs[4] = { - SocketAddress(ext_addr1), - SocketAddress(ext_addr2), - SocketAddress(ext_addr1), - SocketAddress(ext_addr2) - }; + SocketAddress(ext_addr1), SocketAddress(ext_addr2), + SocketAddress(ext_addr1), SocketAddress(ext_addr2)}; std::unique_ptr int_pss(new PhysicalSocketServer()); std::unique_ptr ext_pss(new PhysicalSocketServer()); @@ -328,16 +331,13 @@ class NatTcpTest : public testing::Test, public sigslot::has_slots<> { ext_thread_->Start(); } - void OnConnectEvent(AsyncSocket* socket) { - connected_ = true; - } + void OnConnectEvent(AsyncSocket* socket) { connected_ = true; } void OnAcceptEvent(AsyncSocket* socket) { accepted_.reset(server_->Accept(nullptr)); } - void OnCloseEvent(AsyncSocket* socket, int error) { - } + void OnCloseEvent(AsyncSocket* socket, int error) {} void ConnectEvents() { server_->SignalReadEvent.connect(this, &NatTcpTest::OnAcceptEvent); diff --git a/rtc_base/natserver.cc b/rtc_base/natserver.cc index bf983fedbf..81193761a6 100644 --- a/rtc_base/natserver.cc +++ b/rtc_base/natserver.cc @@ -18,8 +18,7 @@ namespace rtc { -RouteCmp::RouteCmp(NAT* nat) : symmetric(nat->IsSymmetric()) { -} +RouteCmp::RouteCmp(NAT* nat) : symmetric(nat->IsSymmetric()) {} size_t RouteCmp::operator()(const SocketAddressPair& r) const { size_t h = r.source().Hash(); @@ -28,8 +27,8 @@ size_t RouteCmp::operator()(const SocketAddressPair& r) const { return h; } -bool RouteCmp::operator()( - const SocketAddressPair& r1, const SocketAddressPair& r2) const { +bool RouteCmp::operator()(const SocketAddressPair& r1, + const SocketAddressPair& r2) const { if (r1.source() < r2.source()) return true; if (r2.source() < r1.source()) @@ -42,8 +41,7 @@ bool RouteCmp::operator()( } AddrCmp::AddrCmp(NAT* nat) - : use_ip(nat->FiltersIP()), use_port(nat->FiltersPort()) { -} + : use_ip(nat->FiltersIP()), use_port(nat->FiltersPort()) {} size_t AddrCmp::operator()(const SocketAddress& a) const { size_t h = 0; @@ -54,8 +52,8 @@ size_t AddrCmp::operator()(const SocketAddress& a) const { return h; } -bool AddrCmp::operator()( - const SocketAddress& a1, const SocketAddress& a2) const { +bool AddrCmp::operator()(const SocketAddress& a1, + const SocketAddress& a2) const { if (use_ip && (a1.ipaddr() < a2.ipaddr())) return true; if (use_ip && (a2.ipaddr() < a1.ipaddr())) @@ -109,15 +107,15 @@ class NATProxyServerSocket : public AsyncProxyServerSocket { SignalReadEvent(this); } } - }; class NATProxyServer : public ProxyServer { public: - NATProxyServer(SocketFactory* int_factory, const SocketAddress& int_addr, - SocketFactory* ext_factory, const SocketAddress& ext_ip) - : ProxyServer(int_factory, int_addr, ext_factory, ext_ip) { - } + NATProxyServer(SocketFactory* int_factory, + const SocketAddress& int_addr, + SocketFactory* ext_factory, + const SocketAddress& ext_ip) + : ProxyServer(int_factory, int_addr, ext_factory, ext_ip) {} protected: AsyncProxyServerSocket* WrapSocket(AsyncSocket* socket) override { @@ -125,27 +123,27 @@ class NATProxyServer : public ProxyServer { } }; -NATServer::NATServer( - NATType type, SocketFactory* internal, - const SocketAddress& internal_udp_addr, - const SocketAddress& internal_tcp_addr, - SocketFactory* external, const SocketAddress& external_ip) +NATServer::NATServer(NATType type, + SocketFactory* internal, + const SocketAddress& internal_udp_addr, + const SocketAddress& internal_tcp_addr, + SocketFactory* external, + const SocketAddress& external_ip) : external_(external), external_ip_(external_ip.ipaddr(), 0) { nat_ = NAT::Create(type); udp_server_socket_ = AsyncUDPSocket::Create(internal, internal_udp_addr); udp_server_socket_->SignalReadPacket.connect(this, &NATServer::OnInternalUDPPacket); - tcp_proxy_server_ = new NATProxyServer(internal, internal_tcp_addr, external, - external_ip); + tcp_proxy_server_ = + new NATProxyServer(internal, internal_tcp_addr, external, external_ip); int_map_ = new InternalMap(RouteCmp(nat_)); ext_map_ = new ExternalMap(); } NATServer::~NATServer() { - for (InternalMap::iterator iter = int_map_->begin(); - iter != int_map_->end(); + for (InternalMap::iterator iter = int_map_->begin(); iter != int_map_->end(); iter++) delete iter->second; @@ -156,9 +154,11 @@ NATServer::~NATServer() { delete ext_map_; } -void NATServer::OnInternalUDPPacket( - AsyncPacketSocket* socket, const char* buf, size_t size, - const SocketAddress& addr, const PacketTime& packet_time) { +void NATServer::OnInternalUDPPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, + const SocketAddress& addr, + const PacketTime& packet_time) { // Read the intended destination from the wire. SocketAddress dest_addr; size_t length = UnpackAddressFromNAT(buf, size, &dest_addr); @@ -180,9 +180,11 @@ void NATServer::OnInternalUDPPacket( iter->second->socket->SendTo(buf + length, size - length, dest_addr, options); } -void NATServer::OnExternalUDPPacket( - AsyncPacketSocket* socket, const char* buf, size_t size, - const SocketAddress& remote_addr, const PacketTime& packet_time) { +void NATServer::OnExternalUDPPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, + const SocketAddress& remote_addr, + const PacketTime& packet_time) { SocketAddress local_addr = socket->GetLocalAddress(); // Find the translation for this addresses. @@ -199,9 +201,8 @@ void NATServer::OnExternalUDPPacket( // Forward this packet to the internal address. // First prepend the address in a quasi-STUN format. std::unique_ptr real_buf(new char[size + kNATEncodedIPv6AddressSize]); - size_t addrlength = PackAddressForNAT(real_buf.get(), - size + kNATEncodedIPv6AddressSize, - remote_addr); + size_t addrlength = PackAddressForNAT( + real_buf.get(), size + kNATEncodedIPv6AddressSize, remote_addr); // Copy the data part after the address. rtc::PacketOptions options; memcpy(real_buf.get() + addrlength, buf, size); @@ -228,8 +229,9 @@ bool NATServer::ShouldFilterOut(TransEntry* entry, return entry->WhitelistContains(ext_addr); } -NATServer::TransEntry::TransEntry( - const SocketAddressPair& r, AsyncUDPSocket* s, NAT* nat) +NATServer::TransEntry::TransEntry(const SocketAddressPair& r, + AsyncUDPSocket* s, + NAT* nat) : route(r), socket(s) { whitelist = new AddressSet(AddrCmp(nat)); } diff --git a/rtc_base/natserver.h b/rtc_base/natserver.h index a7b4d62520..f4cabcf0d9 100644 --- a/rtc_base/natserver.h +++ b/rtc_base/natserver.h @@ -30,8 +30,8 @@ namespace rtc { struct RouteCmp { explicit RouteCmp(NAT* nat); size_t operator()(const SocketAddressPair& r) const; - bool operator()( - const SocketAddressPair& r1, const SocketAddressPair& r2) const; + bool operator()(const SocketAddressPair& r1, + const SocketAddressPair& r2) const; bool symmetric; }; @@ -60,11 +60,12 @@ const int NAT_SERVER_TCP_PORT = 4238; class NATServer : public sigslot::has_slots<> { public: - NATServer( - NATType type, SocketFactory* internal, - const SocketAddress& internal_udp_addr, - const SocketAddress& internal_tcp_addr, - SocketFactory* external, const SocketAddress& external_ip); + NATServer(NATType type, + SocketFactory* internal, + const SocketAddress& internal_udp_addr, + const SocketAddress& internal_tcp_addr, + SocketFactory* external, + const SocketAddress& external_ip); ~NATServer() override; SocketAddress internal_udp_address() const { @@ -76,11 +77,15 @@ class NATServer : public sigslot::has_slots<> { } // Packets received on one of the networks. - void OnInternalUDPPacket(AsyncPacketSocket* socket, const char* buf, - size_t size, const SocketAddress& addr, + void OnInternalUDPPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, + const SocketAddress& addr, const PacketTime& packet_time); - void OnExternalUDPPacket(AsyncPacketSocket* socket, const char* buf, - size_t size, const SocketAddress& remote_addr, + void OnExternalUDPPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, + const SocketAddress& remote_addr, const PacketTime& packet_time); private: diff --git a/rtc_base/natsocketfactory.cc b/rtc_base/natsocketfactory.cc index ccf6148014..a707ce0259 100644 --- a/rtc_base/natsocketfactory.cc +++ b/rtc_base/natsocketfactory.cc @@ -21,7 +21,8 @@ namespace rtc { // Packs the given socketaddress into the buffer in buf, in the quasi-STUN // format that the natserver uses. // Returns 0 if an invalid address is passed. -size_t PackAddressForNAT(char* buf, size_t buf_size, +size_t PackAddressForNAT(char* buf, + size_t buf_size, const SocketAddress& remote_addr) { const IPAddress& ip = remote_addr.ipaddr(); int family = ip.family(); @@ -46,7 +47,8 @@ size_t PackAddressForNAT(char* buf, size_t buf_size, // Decodes the remote address from a packet that has been encoded with the nat's // quasi-STUN format. Returns the length of the address (i.e., the offset into // data where the original packet starts). -size_t UnpackAddressFromNAT(const char* buf, size_t buf_size, +size_t UnpackAddressFromNAT(const char* buf, + size_t buf_size, SocketAddress* remote_addr) { RTC_DCHECK(buf_size >= 8); RTC_DCHECK(buf[0] == 0); @@ -66,7 +68,6 @@ size_t UnpackAddressFromNAT(const char* buf, size_t buf_size, return 0U; } - // NATSocket class NATSocket : public AsyncSocket, public sigslot::has_slots<> { public: @@ -138,9 +139,8 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { } // This array will be too large for IPv4 packets, but only by 12 bytes. std::unique_ptr buf(new char[size + kNATEncodedIPv6AddressSize]); - size_t addrlength = PackAddressForNAT(buf.get(), - size + kNATEncodedIPv6AddressSize, - addr); + size_t addrlength = + PackAddressForNAT(buf.get(), size + kNATEncodedIPv6AddressSize, addr); size_t encoded_size = size + addrlength; memcpy(buf.get() + addrlength, data, size); int result = socket_->SendTo(buf.get(), encoded_size, server_addr_); @@ -331,9 +331,9 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { NATSocketFactory::NATSocketFactory(SocketFactory* factory, const SocketAddress& nat_udp_addr, const SocketAddress& nat_tcp_addr) - : factory_(factory), nat_udp_addr_(nat_udp_addr), - nat_tcp_addr_(nat_tcp_addr) { -} + : factory_(factory), + nat_udp_addr_(nat_udp_addr), + nat_tcp_addr_(nat_tcp_addr) {} Socket* NATSocketFactory::CreateSocket(int family, int type) { return new NATSocket(this, family, type); @@ -343,8 +343,11 @@ AsyncSocket* NATSocketFactory::CreateAsyncSocket(int family, int type) { return new NATSocket(this, family, type); } -AsyncSocket* NATSocketFactory::CreateInternalSocket(int family, int type, - const SocketAddress& local_addr, SocketAddress* nat_addr) { +AsyncSocket* NATSocketFactory::CreateInternalSocket( + int family, + int type, + const SocketAddress& local_addr, + SocketAddress* nat_addr) { if (type == SOCK_STREAM) { *nat_addr = nat_tcp_addr_; } else { @@ -363,7 +366,9 @@ NATSocketServer::Translator* NATSocketServer::GetTranslator( } NATSocketServer::Translator* NATSocketServer::AddTranslator( - const SocketAddress& ext_ip, const SocketAddress& int_ip, NATType type) { + const SocketAddress& ext_ip, + const SocketAddress& int_ip, + NATType type) { // Fail if a translator already exists with this extternal address. if (nats_.Get(ext_ip)) return nullptr; @@ -371,8 +376,7 @@ NATSocketServer::Translator* NATSocketServer::AddTranslator( return nats_.Add(ext_ip, new Translator(this, type, int_ip, server_, ext_ip)); } -void NATSocketServer::RemoveTranslator( - const SocketAddress& ext_ip) { +void NATSocketServer::RemoveTranslator(const SocketAddress& ext_ip) { nats_.Remove(ext_ip); } @@ -397,14 +401,17 @@ void NATSocketServer::WakeUp() { server_->WakeUp(); } -AsyncSocket* NATSocketServer::CreateInternalSocket(int family, int type, - const SocketAddress& local_addr, SocketAddress* nat_addr) { +AsyncSocket* NATSocketServer::CreateInternalSocket( + int family, + int type, + const SocketAddress& local_addr, + SocketAddress* nat_addr) { AsyncSocket* socket = nullptr; Translator* nat = nats_.FindClient(local_addr); if (nat) { socket = nat->internal_factory()->CreateAsyncSocket(family, type); - *nat_addr = (type == SOCK_STREAM) ? - nat->internal_tcp_address() : nat->internal_udp_address(); + *nat_addr = (type == SOCK_STREAM) ? nat->internal_tcp_address() + : nat->internal_udp_address(); } else { socket = server_->CreateAsyncSocket(family, type); } @@ -412,9 +419,11 @@ AsyncSocket* NATSocketServer::CreateInternalSocket(int family, int type, } // NATSocketServer::Translator -NATSocketServer::Translator::Translator( - NATSocketServer* server, NATType type, const SocketAddress& int_ip, - SocketFactory* ext_factory, const SocketAddress& ext_ip) +NATSocketServer::Translator::Translator(NATSocketServer* server, + NATType type, + const SocketAddress& int_ip, + SocketFactory* ext_factory, + const SocketAddress& ext_ip) : server_(server) { // Create a new private network, and a NATServer running on the private // network that bridges to the external network. Also tell the private @@ -434,7 +443,9 @@ NATSocketServer::Translator* NATSocketServer::Translator::GetTranslator( } NATSocketServer::Translator* NATSocketServer::Translator::AddTranslator( - const SocketAddress& ext_ip, const SocketAddress& int_ip, NATType type) { + const SocketAddress& ext_ip, + const SocketAddress& int_ip, + NATType type) { // Fail if a translator already exists with this extternal address. if (nats_.Get(ext_ip)) return nullptr; @@ -449,8 +460,7 @@ void NATSocketServer::Translator::RemoveTranslator( RemoveClient(ext_ip); } -bool NATSocketServer::Translator::AddClient( - const SocketAddress& int_ip) { +bool NATSocketServer::Translator::AddClient(const SocketAddress& int_ip) { // Fail if a client already exists with this internal address. if (clients_.find(int_ip) != clients_.end()) return false; @@ -459,8 +469,7 @@ bool NATSocketServer::Translator::AddClient( return true; } -void NATSocketServer::Translator::RemoveClient( - const SocketAddress& int_ip) { +void NATSocketServer::Translator::RemoveClient(const SocketAddress& int_ip) { std::set::iterator it = clients_.find(int_ip); if (it != clients_.end()) { clients_.erase(it); @@ -470,8 +479,8 @@ void NATSocketServer::Translator::RemoveClient( NATSocketServer::Translator* NATSocketServer::Translator::FindClient( const SocketAddress& int_ip) { // See if we have the requested IP, or any of our children do. - return (clients_.find(int_ip) != clients_.end()) ? - this : nats_.FindClient(int_ip); + return (clients_.find(int_ip) != clients_.end()) ? this + : nats_.FindClient(int_ip); } // NATSocketServer::TranslatorMap @@ -488,13 +497,13 @@ NATSocketServer::Translator* NATSocketServer::TranslatorMap::Get( } NATSocketServer::Translator* NATSocketServer::TranslatorMap::Add( - const SocketAddress& ext_ip, Translator* nat) { + const SocketAddress& ext_ip, + Translator* nat) { (*this)[ext_ip] = nat; return nat; } -void NATSocketServer::TranslatorMap::Remove( - const SocketAddress& ext_ip) { +void NATSocketServer::TranslatorMap::Remove(const SocketAddress& ext_ip) { TranslatorMap::iterator it = find(ext_ip); if (it != end()) { delete it->second; diff --git a/rtc_base/natsocketfactory.h b/rtc_base/natsocketfactory.h index d8512ba9c1..97961d4f9e 100644 --- a/rtc_base/natsocketfactory.h +++ b/rtc_base/natsocketfactory.h @@ -11,10 +11,10 @@ #ifndef RTC_BASE_NATSOCKETFACTORY_H_ #define RTC_BASE_NATSOCKETFACTORY_H_ -#include #include #include #include +#include #include "rtc_base/constructormagic.h" #include "rtc_base/natserver.h" @@ -30,8 +30,10 @@ const size_t kNATEncodedIPv6AddressSize = 20U; class NATInternalSocketFactory { public: virtual ~NATInternalSocketFactory() {} - virtual AsyncSocket* CreateInternalSocket(int family, int type, - const SocketAddress& local_addr, SocketAddress* nat_addr) = 0; + virtual AsyncSocket* CreateInternalSocket(int family, + int type, + const SocketAddress& local_addr, + SocketAddress* nat_addr) = 0; }; // Creates sockets that will send all traffic through a NAT, using an existing @@ -39,7 +41,8 @@ class NATInternalSocketFactory { // from a socket factory, given to the constructor. class NATSocketFactory : public SocketFactory, public NATInternalSocketFactory { public: - NATSocketFactory(SocketFactory* factory, const SocketAddress& nat_udp_addr, + NATSocketFactory(SocketFactory* factory, + const SocketAddress& nat_udp_addr, const SocketAddress& nat_tcp_addr); // SocketFactory implementation @@ -90,8 +93,10 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { // a specific NAT class Translator { public: - Translator(NATSocketServer* server, NATType type, - const SocketAddress& int_addr, SocketFactory* ext_factory, + Translator(NATSocketServer* server, + NATType type, + const SocketAddress& int_addr, + SocketFactory* ext_factory, const SocketAddress& ext_addr); ~Translator(); @@ -105,7 +110,8 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { Translator* GetTranslator(const SocketAddress& ext_ip); Translator* AddTranslator(const SocketAddress& ext_ip, - const SocketAddress& int_ip, NATType type); + const SocketAddress& int_ip, + NATType type); void RemoveTranslator(const SocketAddress& ext_ip); bool AddClient(const SocketAddress& int_ip); @@ -129,7 +135,8 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { Translator* GetTranslator(const SocketAddress& ext_ip); Translator* AddTranslator(const SocketAddress& ext_ip, - const SocketAddress& int_ip, NATType type); + const SocketAddress& int_ip, + NATType type); void RemoveTranslator(const SocketAddress& ext_ip); // SocketServer implementation @@ -154,9 +161,11 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { }; // Free-standing NAT helper functions. -size_t PackAddressForNAT(char* buf, size_t buf_size, +size_t PackAddressForNAT(char* buf, + size_t buf_size, const SocketAddress& remote_addr); -size_t UnpackAddressFromNAT(const char* buf, size_t buf_size, +size_t UnpackAddressFromNAT(const char* buf, + size_t buf_size, SocketAddress* remote_addr); } // namespace rtc diff --git a/rtc_base/nattypes.cc b/rtc_base/nattypes.cc index 29936ad848..a7af57d8c5 100644 --- a/rtc_base/nattypes.cc +++ b/rtc_base/nattypes.cc @@ -15,31 +15,31 @@ namespace rtc { class SymmetricNAT : public NAT { -public: - bool IsSymmetric() override { return true; } - bool FiltersIP() override { return true; } - bool FiltersPort() override { return true; } + public: + bool IsSymmetric() override { return true; } + bool FiltersIP() override { return true; } + bool FiltersPort() override { return true; } }; class OpenConeNAT : public NAT { -public: - bool IsSymmetric() override { return false; } - bool FiltersIP() override { return false; } - bool FiltersPort() override { return false; } + public: + bool IsSymmetric() override { return false; } + bool FiltersIP() override { return false; } + bool FiltersPort() override { return false; } }; class AddressRestrictedNAT : public NAT { -public: - bool IsSymmetric() override { return false; } - bool FiltersIP() override { return true; } - bool FiltersPort() override { return false; } + public: + bool IsSymmetric() override { return false; } + bool FiltersIP() override { return true; } + bool FiltersPort() override { return false; } }; class PortRestrictedNAT : public NAT { -public: - bool IsSymmetric() override { return false; } - bool FiltersIP() override { return true; } - bool FiltersPort() override { return true; } + public: + bool IsSymmetric() override { return false; } + bool FiltersIP() override { return true; } + bool FiltersPort() override { return true; } }; NAT* NAT::Create(NATType type) { @@ -58,4 +58,4 @@ NAT* NAT::Create(NATType type) { } } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/nattypes.h b/rtc_base/nattypes.h index 64b36d3f85..1d816ac57e 100644 --- a/rtc_base/nattypes.h +++ b/rtc_base/nattypes.h @@ -23,8 +23,8 @@ enum NATType { // Implements the rules for each specific type of NAT. class NAT { -public: - virtual ~NAT() { } + public: + virtual ~NAT() {} // Determines whether this NAT uses both source and destination address when // checking whether a mapping already exists. @@ -42,6 +42,6 @@ public: static NAT* Create(NATType type); }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_NATTYPES_H_ +#endif // RTC_BASE_NATTYPES_H_ diff --git a/rtc_base/nethelpers.cc b/rtc_base/nethelpers.cc index c41e12492a..b1221c3d00 100644 --- a/rtc_base/nethelpers.cc +++ b/rtc_base/nethelpers.cc @@ -32,13 +32,14 @@ namespace rtc { -int ResolveHostname(const std::string& hostname, int family, +int ResolveHostname(const std::string& hostname, + int family, std::vector* addresses) { #ifdef __native_client__ RTC_NOTREACHED(); RTC_LOG(LS_WARNING) << "ResolveHostname() is not implemented for NaCl"; return -1; -#else // __native_client__ +#else // __native_client__ if (!addresses) { return -1; } @@ -83,8 +84,7 @@ int ResolveHostname(const std::string& hostname, int family, } // AsyncResolver -AsyncResolver::AsyncResolver() - : SignalThread(), error_(-1) {} +AsyncResolver::AsyncResolver() : SignalThread(), error_(-1) {} AsyncResolver::~AsyncResolver() = default; @@ -117,15 +117,15 @@ void AsyncResolver::Destroy(bool wait) { } void AsyncResolver::DoWork() { - error_ = ResolveHostname(addr_.hostname().c_str(), addr_.family(), - &addresses_); + error_ = + ResolveHostname(addr_.hostname().c_str(), addr_.family(), &addresses_); } void AsyncResolver::OnWorkDone() { SignalDone(this); } -const char* inet_ntop(int af, const void *src, char* dst, socklen_t size) { +const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) { #if defined(WEBRTC_WIN) return win32_inet_ntop(af, src, dst, size); #else @@ -133,7 +133,7 @@ const char* inet_ntop(int af, const void *src, char* dst, socklen_t size) { #endif } -int inet_pton(int af, const char* src, void *dst) { +int inet_pton(int af, const char* src, void* dst) { #if defined(WEBRTC_WIN) return win32_inet_pton(af, src, dst); #else @@ -182,8 +182,8 @@ bool HasIPv6Enabled() { do { protocols.reset(new char[protbuff_size]); protocol_infos = reinterpret_cast(protocols.get()); - ret = WSCEnumProtocols(requested_protocols, protocol_infos, - &protbuff_size, &err); + ret = WSCEnumProtocols(requested_protocols, protocol_infos, &protbuff_size, + &err); } while (ret == SOCKET_ERROR && err == WSAENOBUFS); if (ret == SOCKET_ERROR) { diff --git a/rtc_base/nethelpers.h b/rtc_base/nethelpers.h index 3901df85f2..de14a067cf 100644 --- a/rtc_base/nethelpers.h +++ b/rtc_base/nethelpers.h @@ -54,8 +54,8 @@ class AsyncResolver : public SignalThread, public AsyncResolverInterface { // rtc namespaced wrappers for inet_ntop and inet_pton so we can avoid // the windows-native versions of these. -const char* inet_ntop(int af, const void *src, char* dst, socklen_t size); -int inet_pton(int af, const char* src, void *dst); +const char* inet_ntop(int af, const void* src, char* dst, socklen_t size); +int inet_pton(int af, const char* src, void* dst); bool HasIPv4Enabled(); bool HasIPv6Enabled(); diff --git a/rtc_base/network.cc b/rtc_base/network.cc index ca198819d7..4bfbd0d270 100644 --- a/rtc_base/network.cc +++ b/rtc_base/network.cc @@ -23,8 +23,8 @@ #endif // WEBRTC_POSIX #if defined(WEBRTC_WIN) -#include "rtc_base/win32.h" #include +#include "rtc_base/win32.h" #elif !defined(__native_client__) #include "rtc_base/ifaddrs_converter.h" #endif @@ -165,7 +165,8 @@ const char kPublicIPv4Host[] = "8.8.8.8"; const char kPublicIPv6Host[] = "2001:4860:4860::8888"; const int kPublicPort = 53; // DNS port. -std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix, +std::string MakeNetworkKey(const std::string& name, + const IPAddress& prefix, int prefix_length) { std::ostringstream ost; ost << name << "%" << prefix.ToString() << "/" << prefix_length; @@ -232,11 +233,9 @@ AdapterType GetAdapterTypeFromName(const char* network_name) { return ADAPTER_TYPE_UNKNOWN; } -NetworkManager::NetworkManager() { -} +NetworkManager::NetworkManager() {} -NetworkManager::~NetworkManager() { -} +NetworkManager::~NetworkManager() {} NetworkManager::EnumerationPermission NetworkManager::enumeration_permission() const { @@ -249,8 +248,7 @@ bool NetworkManager::GetDefaultLocalAddress(int family, IPAddress* addr) const { NetworkManagerBase::NetworkManagerBase() : enumeration_permission_(NetworkManager::ENUMERATION_ALLOWED), - ipv6_enabled_(true) { -} + ipv6_enabled_(true) {} NetworkManagerBase::~NetworkManagerBase() { for (const auto& kv : networks_map_) { @@ -308,8 +306,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks, // First, build a set of network-keys to the ipaddresses. for (Network* network : list) { bool might_add_to_merged_list = false; - std::string key = MakeNetworkKey(network->name(), - network->prefix(), + std::string key = MakeNetworkKey(network->name(), network->prefix(), network->prefix_length()); if (consolidated_address_list.find(key) == consolidated_address_list.end()) { @@ -460,8 +457,7 @@ BasicNetworkManager::BasicNetworkManager() start_count_(0), ignore_non_default_routes_(false) {} -BasicNetworkManager::~BasicNetworkManager() { -} +BasicNetworkManager::~BasicNetworkManager() {} void BasicNetworkManager::OnNetworksChanged() { RTC_LOG(LS_INFO) << "Network change was observed"; @@ -543,8 +539,8 @@ void BasicNetworkManager::ConvertIfAddrs(struct ifaddrs* interfaces, } int prefix_length = CountIPMaskBits(mask); prefix = TruncateIP(ip, prefix_length); - std::string key = MakeNetworkKey(std::string(cursor->ifa_name), - prefix, prefix_length); + std::string key = + MakeNetworkKey(std::string(cursor->ifa_name), prefix, prefix_length); auto iter = current_networks.find(key); if (iter == current_networks.end()) { // TODO(phoglund): Need to recognize other types as well. @@ -593,7 +589,8 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored, #elif defined(WEBRTC_WIN) unsigned int GetPrefix(PIP_ADAPTER_PREFIX prefixlist, - const IPAddress& ip, IPAddress* prefix) { + const IPAddress& ip, + IPAddress* prefix) { IPAddress current_prefix; IPAddress best_prefix; unsigned int best_length = 0; @@ -612,10 +609,10 @@ unsigned int GetPrefix(PIP_ADAPTER_PREFIX prefixlist, break; } case AF_INET6: { - sockaddr_in6* v6_addr = - reinterpret_cast(prefixlist->Address.lpSockaddr); - current_prefix = IPAddress(v6_addr->sin6_addr); - break; + sockaddr_in6* v6_addr = + reinterpret_cast(prefixlist->Address.lpSockaddr); + current_prefix = IPAddress(v6_addr->sin6_addr); + break; } default: { prefixlist = prefixlist->Next; @@ -647,8 +644,7 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored, do { adapter_info.reset(new char[buffer_size]); adapter_addrs = reinterpret_cast(adapter_info.get()); - ret = GetAdaptersAddresses(AF_UNSPEC, adapter_flags, - 0, adapter_addrs, + ret = GetAdaptersAddresses(AF_UNSPEC, adapter_flags, 0, adapter_addrs, reinterpret_cast(&buffer_size)); } while (ret == ERROR_BUFFER_OVERFLOW); if (ret != ERROR_SUCCESS) { @@ -698,9 +694,7 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored, continue; } } - default: { - continue; - } + default: { continue; } } IPAddress prefix; @@ -771,12 +765,9 @@ bool IsDefaultRoute(const std::string& network_name) { while (fs.ReadLine(&line) == SR_SUCCESS) { char iface_name[256]; unsigned int iface_ip, iface_gw, iface_mask, iface_flags; - if (sscanf(line.c_str(), - "%255s %8X %8X %4X %*d %*u %*d %8X", - iface_name, &iface_ip, &iface_gw, - &iface_flags, &iface_mask) == 5 && - network_name == iface_name && - iface_mask == 0 && + if (sscanf(line.c_str(), "%255s %8X %8X %4X %*d %*u %*d %8X", iface_name, + &iface_ip, &iface_gw, &iface_flags, &iface_mask) == 5 && + network_name == iface_name && iface_mask == 0 && (iface_flags & (RTF_UP | RTF_HOST)) == RTF_UP) { return true; } @@ -883,7 +874,7 @@ void BasicNetworkManager::OnMessage(Message* msg) { UpdateNetworksContinually(); break; } - case kSignalNetworksMessage: { + case kSignalNetworksMessage: { SignalNetworksChanged(); break; } @@ -907,8 +898,8 @@ IPAddress BasicNetworkManager::QueryDefaultLocalAddress(int family) const { if (socket->Connect(SocketAddress( family == AF_INET ? kPublicIPv4Host : kPublicIPv6Host, kPublicPort)) < 0) { - if (socket->GetError() != ENETUNREACH - && socket->GetError() != EHOSTUNREACH) { + if (socket->GetError() != ENETUNREACH && + socket->GetError() != EHOSTUNREACH) { // Ignore the expected case of "host/net unreachable" - which happens if // the network is V4- or V6-only. RTC_LOG(LS_INFO) << "Connect failed with " << socket->GetError(); diff --git a/rtc_base/network.h b/rtc_base/network.h index 49f500c297..03a097827f 100644 --- a/rtc_base/network.h +++ b/rtc_base/network.h @@ -44,7 +44,8 @@ const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK; // Makes a string key for this network. Used in the network manager's maps. // Network objects are keyed on interface name, network prefix and the // length of that prefix. -std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix, +std::string MakeNetworkKey(const std::string& name, + const IPAddress& prefix, int prefix_length); // Utility function that attempts to determine an adapter type by an interface @@ -352,7 +353,7 @@ class Network { // detected. Passing true to already_changed skips this check. bool SetIPs(const std::vector& ips, bool already_changed); // Get the list of IP Addresses associated with this network. - const std::vector& GetIPs() const { return ips_;} + const std::vector& GetIPs() const { return ips_; } // Clear the network's list of addresses. void ClearIPs() { ips_.clear(); } diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index 630e733ce5..cf1ceccaec 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -19,8 +19,8 @@ #include "rtc_base/nethelpers.h" #include "rtc_base/networkmonitor.h" #if defined(WEBRTC_POSIX) -#include #include +#include #include "rtc_base/ifaddrs_converter.h" #endif // defined(WEBRTC_POSIX) #include "rtc_base/gunit.h" @@ -75,13 +75,11 @@ bool SameNameAndPrefix(const rtc::Network& a, const rtc::Network& b) { } // namespace -class NetworkTest : public testing::Test, public sigslot::has_slots<> { +class NetworkTest : public testing::Test, public sigslot::has_slots<> { public: NetworkTest() : callback_called_(false) {} - void OnNetworksChanged() { - callback_called_ = true; - } + void OnNetworksChanged() { callback_called_ = true; } NetworkManager::Stats MergeNetworkList( BasicNetworkManager& network_manager, @@ -98,7 +96,8 @@ class NetworkTest : public testing::Test, public sigslot::has_slots<> { } NetworkManager::NetworkList GetNetworks( - const BasicNetworkManager& network_manager, bool include_ignored) { + const BasicNetworkManager& network_manager, + bool include_ignored) { NetworkManager::NetworkList list; network_manager.CreateNetworks(include_ignored, &list); return list; @@ -137,8 +136,8 @@ class NetworkTest : public testing::Test, public sigslot::has_slots<> { struct sockaddr_in6* CreateIpv6Addr(const std::string& ip_string, uint32_t scope_id) { - struct sockaddr_in6* ipv6_addr = static_cast( - malloc(sizeof(struct sockaddr_in6))); + struct sockaddr_in6* ipv6_addr = + static_cast(malloc(sizeof(struct sockaddr_in6))); memset(ipv6_addr, 0, sizeof(struct sockaddr_in6)); ipv6_addr->sin6_family = AF_INET6; ipv6_addr->sin6_scope_id = scope_id; @@ -225,10 +224,10 @@ TEST_F(NetworkTest, TestIsIgnoredNetworkIgnoresIPsStartingWith0) { // TODO(phoglund): Remove when ignore list goes away. TEST_F(NetworkTest, TestIgnoreList) { - Network ignore_me("ignore_me", "Ignore me please!", - IPAddress(0x12345600U), 24); - Network include_me("include_me", "Include me please!", - IPAddress(0x12345600U), 24); + Network ignore_me("ignore_me", "Ignore me please!", IPAddress(0x12345600U), + 24); + Network include_me("include_me", "Include me please!", IPAddress(0x12345600U), + 24); BasicNetworkManager network_manager; EXPECT_FALSE(IsIgnoredNetwork(network_manager, ignore_me)); EXPECT_FALSE(IsIgnoredNetwork(network_manager, include_me)); @@ -245,9 +244,7 @@ TEST_F(NetworkTest, DISABLED_TestCreateNetworks) { NetworkManager::NetworkList result = GetNetworks(manager, true); // We should be able to bind to any addresses we find. NetworkManager::NetworkList::iterator it; - for (it = result.begin(); - it != result.end(); - ++it) { + for (it = result.begin(); it != result.end(); ++it) { sockaddr_storage storage; memset(&storage, 0, sizeof(storage)); IPAddress ip = (*it)->GetBestIP(); @@ -258,8 +255,7 @@ TEST_F(NetworkTest, DISABLED_TestCreateNetworks) { if (fd > 0) { size_t ipsize = bindaddress.ToSockAddrStorage(&storage); EXPECT_GE(ipsize, 0U); - int success = ::bind(fd, - reinterpret_cast(&storage), + int success = ::bind(fd, reinterpret_cast(&storage), static_cast(ipsize)); #if defined(WEBRTC_WIN) if (success) @@ -280,8 +276,8 @@ TEST_F(NetworkTest, DISABLED_TestCreateNetworks) { // ALLOWED. TEST_F(NetworkTest, TestUpdateNetworks) { BasicNetworkManager manager; - manager.SignalNetworksChanged.connect( - static_cast(this), &NetworkTest::OnNetworksChanged); + manager.SignalNetworksChanged.connect(static_cast(this), + &NetworkTest::OnNetworksChanged); EXPECT_EQ(NetworkManager::ENUMERATION_ALLOWED, manager.enumeration_permission()); manager.StartUpdating(); @@ -428,8 +424,8 @@ void SetupNetworks(NetworkManager::NetworkList* list) { // Test that the basic network merging case works. TEST_F(NetworkTest, TestIPv6MergeNetworkList) { BasicNetworkManager manager; - manager.SignalNetworksChanged.connect( - static_cast(this), &NetworkTest::OnNetworksChanged); + manager.SignalNetworksChanged.connect(static_cast(this), + &NetworkTest::OnNetworksChanged); NetworkManager::NetworkList original_list; SetupNetworks(&original_list); bool changed = false; @@ -453,8 +449,8 @@ TEST_F(NetworkTest, TestIPv6MergeNetworkList) { // objects remain in the result list. TEST_F(NetworkTest, TestNoChangeMerge) { BasicNetworkManager manager; - manager.SignalNetworksChanged.connect( - static_cast(this), &NetworkTest::OnNetworksChanged); + manager.SignalNetworksChanged.connect(static_cast(this), + &NetworkTest::OnNetworksChanged); NetworkManager::NetworkList original_list; SetupNetworks(&original_list); bool changed = false; @@ -488,17 +484,16 @@ TEST_F(NetworkTest, TestNoChangeMerge) { // IP changed. TEST_F(NetworkTest, MergeWithChangedIP) { BasicNetworkManager manager; - manager.SignalNetworksChanged.connect( - static_cast(this), &NetworkTest::OnNetworksChanged); + manager.SignalNetworksChanged.connect(static_cast(this), + &NetworkTest::OnNetworksChanged); NetworkManager::NetworkList original_list; SetupNetworks(&original_list); // Make a network that we're going to change. IPAddress ip; EXPECT_TRUE(IPFromString("2401:fa01:4:1000:be30:faa:fee:faa", &ip)); IPAddress prefix = TruncateIP(ip, 64); - Network* network_to_change = new Network("test_eth0", - "Test Network Adapter 1", - prefix, 64); + Network* network_to_change = + new Network("test_eth0", "Test Network Adapter 1", prefix, 64); Network* changed_network = new Network(*network_to_change); network_to_change->AddIP(ip); IPAddress changed_ip; @@ -517,8 +512,7 @@ TEST_F(NetworkTest, MergeWithChangedIP) { manager.GetNetworks(&list); EXPECT_EQ(original_list.size(), list.size()); // Make sure the original network is still in the merged list. - EXPECT_NE(list.end(), - std::find(list.begin(), list.end(), network_to_change)); + EXPECT_NE(list.end(), std::find(list.begin(), list.end(), network_to_change)); EXPECT_EQ(changed_ip, network_to_change->GetIPs().at(0)); } @@ -526,8 +520,8 @@ TEST_F(NetworkTest, MergeWithChangedIP) { // with additional IPs (not just a replacement). TEST_F(NetworkTest, TestMultipleIPMergeNetworkList) { BasicNetworkManager manager; - manager.SignalNetworksChanged.connect( - static_cast(this), &NetworkTest::OnNetworksChanged); + manager.SignalNetworksChanged.connect(static_cast(this), + &NetworkTest::OnNetworksChanged); NetworkManager::NetworkList original_list; SetupNetworks(&original_list); bool changed = false; @@ -581,8 +575,8 @@ TEST_F(NetworkTest, TestMultipleIPMergeNetworkList) { // Test that merge correctly distinguishes multiple networks on an interface. TEST_F(NetworkTest, TestMultiplePublicNetworksOnOneInterfaceMerge) { BasicNetworkManager manager; - manager.SignalNetworksChanged.connect( - static_cast(this), &NetworkTest::OnNetworksChanged); + manager.SignalNetworksChanged.connect(static_cast(this), + &NetworkTest::OnNetworksChanged); NetworkManager::NetworkList original_list; SetupNetworks(&original_list); bool changed = false; @@ -1038,8 +1032,8 @@ TEST_F(NetworkTest, TestIPv6Selection) { ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_DEPRECATED, &ip)); // Create a network with this prefix. - Network ipv6_network( - "test_eth0", "Test NetworkAdapter", TruncateIP(ip, 64), 64); + Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip, 64), + 64); // When there is no address added, it should return an unspecified // address. diff --git a/rtc_base/nullsocketserver.cc b/rtc_base/nullsocketserver.cc index 780abf8a1b..c890c6f3dc 100644 --- a/rtc_base/nullsocketserver.cc +++ b/rtc_base/nullsocketserver.cc @@ -25,7 +25,6 @@ void NullSocketServer::WakeUp() { event_.Set(); } - rtc::Socket* NullSocketServer::CreateSocket(int /* family */, int /* type */) { RTC_NOTREACHED(); return nullptr; diff --git a/rtc_base/nullsocketserver_unittest.cc b/rtc_base/nullsocketserver_unittest.cc index e3d9952f77..f1d65eab6a 100644 --- a/rtc_base/nullsocketserver_unittest.cc +++ b/rtc_base/nullsocketserver_unittest.cc @@ -15,9 +15,7 @@ namespace rtc { static const uint32_t kTimeout = 5000U; -class NullSocketServerTest - : public testing::Test, - public MessageHandler { +class NullSocketServerTest : public testing::Test, public MessageHandler { protected: void OnMessage(Message* message) override { ss_.WakeUp(); } diff --git a/rtc_base/openssladapter.cc b/rtc_base/openssladapter.cc index 9563ab4416..9d6c7d1768 100644 --- a/rtc_base/openssladapter.cc +++ b/rtc_base/openssladapter.cc @@ -36,21 +36,21 @@ // TODO(benwright): Use a nicer abstraction for mutex. #if defined(WEBRTC_WIN) - #define MUTEX_TYPE HANDLE +#define MUTEX_TYPE HANDLE #define MUTEX_SETUP(x) (x) = CreateMutex(nullptr, FALSE, nullptr) #define MUTEX_CLEANUP(x) CloseHandle(x) #define MUTEX_LOCK(x) WaitForSingleObject((x), INFINITE) #define MUTEX_UNLOCK(x) ReleaseMutex(x) #define THREAD_ID GetCurrentThreadId() #elif defined(WEBRTC_POSIX) - #define MUTEX_TYPE pthread_mutex_t - #define MUTEX_SETUP(x) pthread_mutex_init(&(x), nullptr) - #define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x)) - #define MUTEX_LOCK(x) pthread_mutex_lock(&(x)) - #define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x)) - #define THREAD_ID pthread_self() +#define MUTEX_TYPE pthread_mutex_t +#define MUTEX_SETUP(x) pthread_mutex_init(&(x), nullptr) +#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x)) +#define MUTEX_LOCK(x) pthread_mutex_lock(&(x)) +#define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x)) +#define THREAD_ID pthread_self() #else - #error You must define mutex operations appropriate for your platform! +#error You must define mutex operations appropriate for your platform! #endif struct CRYPTO_dynlock_value { @@ -140,20 +140,20 @@ static int socket_puts(BIO* b, const char* str) { static long socket_ctrl(BIO* b, int cmd, long num, void* ptr) { // NOLINT switch (cmd) { - case BIO_CTRL_RESET: - return 0; - case BIO_CTRL_EOF: { - rtc::AsyncSocket* socket = static_cast(ptr); - // 1 means socket closed. - return (socket->GetState() == rtc::AsyncSocket::CS_CLOSED) ? 1 : 0; - } - case BIO_CTRL_WPENDING: - case BIO_CTRL_PENDING: - return 0; - case BIO_CTRL_FLUSH: - return 1; - default: - return 0; + case BIO_CTRL_RESET: + return 0; + case BIO_CTRL_EOF: { + rtc::AsyncSocket* socket = static_cast(ptr); + // 1 means socket closed. + return (socket->GetState() == rtc::AsyncSocket::CS_CLOSED) ? 1 : 0; + } + case BIO_CTRL_WPENDING: + case BIO_CTRL_PENDING: + return 0; + case BIO_CTRL_FLUSH: + return 1; + default: + return 0; } } @@ -344,7 +344,7 @@ int OpenSSLAdapter::BeginSSL() { // appear Send handles partial writes properly, though maybe we never notice // since we never send more than 16KB at once.. SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | - SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); + SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); // Enable SNI, if a hostname is supplied. if (!ssl_host_name_.empty()) { @@ -413,17 +413,17 @@ int OpenSSLAdapter::ContinueSSL() { int code = (role_ == SSL_CLIENT) ? SSL_connect(ssl_) : SSL_accept(ssl_); switch (SSL_get_error(ssl_, code)) { - case SSL_ERROR_NONE: - if (!SSLPostConnectionCheck(ssl_, ssl_host_name_)) { - RTC_LOG(LS_ERROR) << "TLS post connection check failed"; - // make sure we close the socket - Cleanup(); - // The connect failed so return -1 to shut down the socket - return -1; - } + case SSL_ERROR_NONE: + if (!SSLPostConnectionCheck(ssl_, ssl_host_name_)) { + RTC_LOG(LS_ERROR) << "TLS post connection check failed"; + // make sure we close the socket + Cleanup(); + // The connect failed so return -1 to shut down the socket + return -1; + } - state_ = SSL_CONNECTED; - AsyncSocketAdapter::OnConnectEvent(this); + state_ = SSL_CONNECTED; + AsyncSocketAdapter::OnConnectEvent(this); #if 0 // TODO(benwright): worry about this // Don't let ourselves go away during the callbacks PRefPtr lock(this); @@ -432,26 +432,26 @@ int OpenSSLAdapter::ContinueSSL() { RTC_LOG(LS_INFO) << " -- onStreamWriteable"; AsyncSocketAdapter::OnWriteEvent(this); #endif - break; + break; - case SSL_ERROR_WANT_READ: - RTC_LOG(LS_VERBOSE) << " -- error want read"; - struct timeval timeout; - if (DTLSv1_get_timeout(ssl_, &timeout)) { - int delay = timeout.tv_sec * 1000 + timeout.tv_usec/1000; + case SSL_ERROR_WANT_READ: + RTC_LOG(LS_VERBOSE) << " -- error want read"; + struct timeval timeout; + if (DTLSv1_get_timeout(ssl_, &timeout)) { + int delay = timeout.tv_sec * 1000 + timeout.tv_usec / 1000; - Thread::Current()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_TIMEOUT, - 0); - } - break; + Thread::Current()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_TIMEOUT, + 0); + } + break; - case SSL_ERROR_WANT_WRITE: - break; + case SSL_ERROR_WANT_WRITE: + break; - case SSL_ERROR_ZERO_RETURN: - default: - RTC_LOG(LS_WARNING) << "ContinueSSL -- error " << code; - return (code != 0) ? code : -1; + case SSL_ERROR_ZERO_RETURN: + default: + RTC_LOG(LS_WARNING) << "ContinueSSL -- error " << code; + return (code != 0) ? code : -1; } return 0; @@ -534,20 +534,20 @@ int OpenSSLAdapter::DoSslWrite(const void* pv, size_t cb, int* error) { int OpenSSLAdapter::Send(const void* pv, size_t cb) { switch (state_) { - case SSL_NONE: - return AsyncSocketAdapter::Send(pv, cb); + case SSL_NONE: + return AsyncSocketAdapter::Send(pv, cb); - case SSL_WAIT: - case SSL_CONNECTING: - SetError(ENOTCONN); - return SOCKET_ERROR; + case SSL_WAIT: + case SSL_CONNECTING: + SetError(ENOTCONN); + return SOCKET_ERROR; - case SSL_CONNECTED: - break; + case SSL_CONNECTED: + break; - case SSL_ERROR: - default: - return SOCKET_ERROR; + case SSL_ERROR: + default: + return SOCKET_ERROR; } int ret; @@ -614,20 +614,20 @@ int OpenSSLAdapter::SendTo(const void* pv, int OpenSSLAdapter::Recv(void* pv, size_t cb, int64_t* timestamp) { switch (state_) { - case SSL_NONE: - return AsyncSocketAdapter::Recv(pv, cb, timestamp); + case SSL_NONE: + return AsyncSocketAdapter::Recv(pv, cb, timestamp); - case SSL_WAIT: - case SSL_CONNECTING: - SetError(ENOTCONN); - return SOCKET_ERROR; + case SSL_WAIT: + case SSL_CONNECTING: + SetError(ENOTCONN); + return SOCKET_ERROR; - case SSL_CONNECTED: - break; + case SSL_CONNECTED: + break; - case SSL_ERROR: - default: - return SOCKET_ERROR; + case SSL_ERROR: + default: + return SOCKET_ERROR; } // Don't trust OpenSSL with zero byte reads @@ -691,8 +691,8 @@ Socket::ConnState OpenSSLAdapter::GetState() const { // if (signal_close_) // return CS_CONNECTED; ConnState state = socket_->GetState(); - if ((state == CS_CONNECTED) - && ((state_ == SSL_WAIT) || (state_ == SSL_CONNECTING))) + if ((state == CS_CONNECTED) && + ((state_ == SSL_WAIT) || (state_ == SSL_CONNECTING))) state = CS_CONNECTING; return state; } @@ -741,7 +741,7 @@ void OpenSSLAdapter::OnReadEvent(AsyncSocket* socket) { // Don't let ourselves go away during the callbacks // PRefPtr lock(this); // TODO(benwright): fix this - if (ssl_write_needs_read_) { + if (ssl_write_needs_read_) { AsyncSocketAdapter::OnWriteEvent(socket); } @@ -767,7 +767,7 @@ void OpenSSLAdapter::OnWriteEvent(AsyncSocket* socket) { // Don't let ourselves go away during the callbacks // PRefPtr lock(this); // TODO(benwright): fix this - if (ssl_read_needs_write_) { + if (ssl_read_needs_write_) { AsyncSocketAdapter::OnReadEvent(socket); } @@ -852,11 +852,10 @@ int OpenSSLAdapter::SSLVerifyCallback(int ok, X509_STORE_CTX* store) { #endif // Get our stream pointer from the store SSL* ssl = reinterpret_cast( - X509_STORE_CTX_get_ex_data(store, - SSL_get_ex_data_X509_STORE_CTX_idx())); + X509_STORE_CTX_get_ex_data(store, SSL_get_ex_data_X509_STORE_CTX_idx())); OpenSSLAdapter* stream = - reinterpret_cast(SSL_get_app_data(ssl)); + reinterpret_cast(SSL_get_app_data(ssl)); if (!ok && stream->ssl_cert_verifier_ != nullptr) { RTC_LOG(LS_INFO) << "Invoking SSL Verify Callback."; diff --git a/rtc_base/openssladapter.h b/rtc_base/openssladapter.h index 0de528c0a5..986f0f8265 100644 --- a/rtc_base/openssladapter.h +++ b/rtc_base/openssladapter.h @@ -81,7 +81,11 @@ class OpenSSLAdapter : public SSLAdapter, public MessageHandler { private: enum SSLState { - SSL_NONE, SSL_WAIT, SSL_CONNECTING, SSL_CONNECTED, SSL_ERROR + SSL_NONE, + SSL_WAIT, + SSL_CONNECTING, + SSL_CONNECTED, + SSL_ERROR }; enum { MSG_TIMEOUT }; diff --git a/rtc_base/openssldigest.cc b/rtc_base/openssldigest.cc index 32cd4afa16..9b644c460b 100644 --- a/rtc_base/openssldigest.cc +++ b/rtc_base/openssldigest.cc @@ -80,8 +80,7 @@ bool OpenSSLDigest::GetDigestEVP(const std::string& algorithm, return true; } -bool OpenSSLDigest::GetDigestName(const EVP_MD* md, - std::string* algorithm) { +bool OpenSSLDigest::GetDigestName(const EVP_MD* md, std::string* algorithm) { RTC_DCHECK(md != nullptr); RTC_DCHECK(algorithm != nullptr); @@ -108,7 +107,7 @@ bool OpenSSLDigest::GetDigestName(const EVP_MD* md, bool OpenSSLDigest::GetDigestSize(const std::string& algorithm, size_t* length) { - const EVP_MD *md; + const EVP_MD* md; if (!GetDigestEVP(algorithm, &md)) return false; diff --git a/rtc_base/openssldigest.h b/rtc_base/openssldigest.h index 2b65867484..c4cd1e0314 100644 --- a/rtc_base/openssldigest.h +++ b/rtc_base/openssldigest.h @@ -31,14 +31,11 @@ class OpenSSLDigest : public MessageDigest { size_t Finish(void* buf, size_t len) override; // Helper function to look up a digest's EVP by name. - static bool GetDigestEVP(const std::string &algorithm, - const EVP_MD** md); + static bool GetDigestEVP(const std::string& algorithm, const EVP_MD** md); // Helper function to look up a digest's name by EVP. - static bool GetDigestName(const EVP_MD* md, - std::string* algorithm); + static bool GetDigestName(const EVP_MD* md, std::string* algorithm); // Helper function to get the length of a digest. - static bool GetDigestSize(const std::string &algorithm, - size_t* len); + static bool GetDigestSize(const std::string& algorithm, size_t* len); private: EVP_MD_CTX* ctx_ = nullptr; diff --git a/rtc_base/opensslidentity.cc b/rtc_base/opensslidentity.cc index bb651746fa..8ae4dbe855 100644 --- a/rtc_base/opensslidentity.cc +++ b/rtc_base/opensslidentity.cc @@ -17,7 +17,7 @@ #if defined(WEBRTC_WIN) // Must be included first before openssl headers. #include "rtc_base/win32.h" // NOLINT -#endif // WEBRTC_WIN +#endif // WEBRTC_WIN #include #include @@ -267,9 +267,8 @@ SSLIdentity* OpenSSLIdentity::FromPEMStrings(const std::string& private_key, SSLIdentity* OpenSSLIdentity::FromPEMChainStrings( const std::string& private_key, const std::string& certificate_chain) { - BIO* bio = - BIO_new_mem_buf(certificate_chain.data(), - rtc::dchecked_cast(certificate_chain.size())); + BIO* bio = BIO_new_mem_buf(certificate_chain.data(), + rtc::dchecked_cast(certificate_chain.size())); if (!bio) return nullptr; BIO_set_mem_eof_return(bio, 0); diff --git a/rtc_base/opensslstreamadapter.cc b/rtc_base/opensslstreamadapter.cc index adbc0c04d0..fd54a082a7 100644 --- a/rtc_base/opensslstreamadapter.cc +++ b/rtc_base/opensslstreamadapter.cc @@ -37,7 +37,7 @@ #include "rtc_base/timeutils.h" namespace { - bool g_use_time_callback_for_testing = false; +bool g_use_time_callback_for_testing = false; } namespace rtc { @@ -77,8 +77,10 @@ struct SslCipherMapEntry { const char* rfc_name; }; -#define DEFINE_CIPHER_ENTRY_SSL3(name) {SSL3_CK_##name, "TLS_"#name} -#define DEFINE_CIPHER_ENTRY_TLS1(name) {TLS1_CK_##name, "TLS_"#name} +#define DEFINE_CIPHER_ENTRY_SSL3(name) \ + { SSL3_CK_##name, "TLS_" #name } +#define DEFINE_CIPHER_ENTRY_TLS1(name) \ + { TLS1_CK_##name, "TLS_" #name } // The "SSL_CIPHER_standard_name" function is only available in OpenSSL when // compiled with tracing, so we need to define the mapping manually here. @@ -452,7 +454,7 @@ bool OpenSSLStreamAdapter::GetDtlsSrtpCryptoSuite(int* crypto_suite) { if (state_ != SSL_CONNECTED) return false; - const SRTP_PROTECTION_PROFILE *srtp_profile = + const SRTP_PROTECTION_PROFILE* srtp_profile = SSL_get_selected_srtp_profile(ssl_); if (!srtp_profile) @@ -497,8 +499,7 @@ void OpenSSLStreamAdapter::SetMaxProtocolVersion(SSLProtocolVersion version) { ssl_max_version_ = version; } -void OpenSSLStreamAdapter::SetInitialRetransmissionTimeout( - int timeout_ms) { +void OpenSSLStreamAdapter::SetInitialRetransmissionTimeout(int timeout_ms) { RTC_DCHECK(ssl_ctx_ == nullptr); dtls_handshake_timeout_ms_ = timeout_ms; } @@ -507,31 +508,33 @@ void OpenSSLStreamAdapter::SetInitialRetransmissionTimeout( // StreamInterface Implementation // -StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, - size_t* written, int* error) { +StreamResult OpenSSLStreamAdapter::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { RTC_LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")"; switch (state_) { - case SSL_NONE: - // pass-through in clear text - return StreamAdapterInterface::Write(data, data_len, written, error); + case SSL_NONE: + // pass-through in clear text + return StreamAdapterInterface::Write(data, data_len, written, error); - case SSL_WAIT: - case SSL_CONNECTING: - return SR_BLOCK; - - case SSL_CONNECTED: - if (waiting_to_verify_peer_certificate()) { + case SSL_WAIT: + case SSL_CONNECTING: return SR_BLOCK; - } - break; - case SSL_ERROR: - case SSL_CLOSED: - default: - if (error) - *error = ssl_error_code_; - return SR_ERROR; + case SSL_CONNECTED: + if (waiting_to_verify_peer_certificate()) { + return SR_BLOCK; + } + break; + + case SSL_ERROR: + case SSL_CLOSED: + default: + if (error) + *error = ssl_error_code_; + return SR_ERROR; } // OpenSSL will return an error if we try to write zero bytes @@ -546,33 +549,35 @@ StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, int code = SSL_write(ssl_, data, checked_cast(data_len)); int ssl_error = SSL_get_error(ssl_, code); switch (ssl_error) { - case SSL_ERROR_NONE: - RTC_LOG(LS_VERBOSE) << " -- success"; - RTC_DCHECK_GT(code, 0); - RTC_DCHECK_LE(code, data_len); - if (written) - *written = code; - return SR_SUCCESS; - case SSL_ERROR_WANT_READ: - RTC_LOG(LS_VERBOSE) << " -- error want read"; - ssl_write_needs_read_ = true; - return SR_BLOCK; - case SSL_ERROR_WANT_WRITE: - RTC_LOG(LS_VERBOSE) << " -- error want write"; - return SR_BLOCK; + case SSL_ERROR_NONE: + RTC_LOG(LS_VERBOSE) << " -- success"; + RTC_DCHECK_GT(code, 0); + RTC_DCHECK_LE(code, data_len); + if (written) + *written = code; + return SR_SUCCESS; + case SSL_ERROR_WANT_READ: + RTC_LOG(LS_VERBOSE) << " -- error want read"; + ssl_write_needs_read_ = true; + return SR_BLOCK; + case SSL_ERROR_WANT_WRITE: + RTC_LOG(LS_VERBOSE) << " -- error want write"; + return SR_BLOCK; - case SSL_ERROR_ZERO_RETURN: - default: - Error("SSL_write", (ssl_error ? ssl_error : -1), 0, false); - if (error) - *error = ssl_error_code_; - return SR_ERROR; + case SSL_ERROR_ZERO_RETURN: + default: + Error("SSL_write", (ssl_error ? ssl_error : -1), 0, false); + if (error) + *error = ssl_error_code_; + return SR_ERROR; } // not reached } -StreamResult OpenSSLStreamAdapter::Read(void* data, size_t data_len, - size_t* read, int* error) { +StreamResult OpenSSLStreamAdapter::Read(void* data, + size_t data_len, + size_t* read, + int* error) { RTC_LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Read(" << data_len << ")"; switch (state_) { case SSL_NONE: @@ -699,7 +704,8 @@ StreamState OpenSSLStreamAdapter::GetState() const { // not reached } -void OpenSSLStreamAdapter::OnEvent(StreamInterface* stream, int events, +void OpenSSLStreamAdapter::OnEvent(StreamInterface* stream, + int events, int err) { int events_to_signal = 0; int signal_error = 0; @@ -717,12 +723,12 @@ void OpenSSLStreamAdapter::OnEvent(StreamInterface* stream, int events, } } } - if ((events & (SE_READ|SE_WRITE))) { + if ((events & (SE_READ | SE_WRITE))) { RTC_LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::OnEvent" << ((events & SE_READ) ? " SE_READ" : "") << ((events & SE_WRITE) ? " SE_WRITE" : ""); if (state_ == SSL_NONE) { - events_to_signal |= events & (SE_READ|SE_WRITE); + events_to_signal |= events & (SE_READ | SE_WRITE); } else if (state_ == SSL_CONNECTING) { if (int err = ContinueSSL()) { Error("ContinueSSL", err, 0, true); @@ -791,7 +797,7 @@ int OpenSSLStreamAdapter::BeginSSL() { } SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | - SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); + SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); #if !defined(OPENSSL_IS_BORINGSSL) // Specify an ECDH group for ECDHE ciphers, otherwise OpenSSL cannot @@ -849,9 +855,8 @@ int OpenSSLStreamAdapter::ContinueSSL() { Thread::Current()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_TIMEOUT, 0); - } } - break; + } break; case SSL_ERROR_WANT_WRITE: RTC_LOG(LS_VERBOSE) << " -- error want write"; @@ -927,7 +932,6 @@ void OpenSSLStreamAdapter::Cleanup(uint8_t alert) { Thread::Current()->Clear(this, MSG_TIMEOUT); } - void OpenSSLStreamAdapter::OnMessage(Message* msg) { // Process our own messages and then pass others to the superclass if (MSG_TIMEOUT == msg->message_id) { @@ -943,9 +947,8 @@ SSL_CTX* OpenSSLStreamAdapter::SetupSSLContext() { SSL_CTX* ctx = nullptr; #ifdef OPENSSL_IS_BORINGSSL - ctx = SSL_CTX_new(ssl_mode_ == SSL_MODE_DTLS ? - DTLS_method() : TLS_method()); - // Version limiting for BoringSSL will be done below. + ctx = SSL_CTX_new(ssl_mode_ == SSL_MODE_DTLS ? DTLS_method() : TLS_method()); +// Version limiting for BoringSSL will be done below. #else const SSL_METHOD* method; switch (ssl_max_version_) { @@ -991,21 +994,21 @@ SSL_CTX* OpenSSLStreamAdapter::SetupSSLContext() { return nullptr; #ifdef OPENSSL_IS_BORINGSSL - SSL_CTX_set_min_proto_version(ctx, ssl_mode_ == SSL_MODE_DTLS ? - DTLS1_VERSION : TLS1_VERSION); + SSL_CTX_set_min_proto_version( + ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_VERSION : TLS1_VERSION); switch (ssl_max_version_) { case SSL_PROTOCOL_TLS_10: - SSL_CTX_set_max_proto_version(ctx, ssl_mode_ == SSL_MODE_DTLS ? - DTLS1_VERSION : TLS1_VERSION); + SSL_CTX_set_max_proto_version( + ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_VERSION : TLS1_VERSION); break; case SSL_PROTOCOL_TLS_11: - SSL_CTX_set_max_proto_version(ctx, ssl_mode_ == SSL_MODE_DTLS ? - DTLS1_VERSION : TLS1_1_VERSION); + SSL_CTX_set_max_proto_version( + ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_VERSION : TLS1_1_VERSION); break; case SSL_PROTOCOL_TLS_12: default: - SSL_CTX_set_max_proto_version(ctx, ssl_mode_ == SSL_MODE_DTLS ? - DTLS1_2_VERSION : TLS1_2_VERSION); + SSL_CTX_set_max_proto_version( + ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION); break; } if (g_use_time_callback_for_testing) { @@ -1146,26 +1149,26 @@ struct cipher_list { // TODO(torbjorng): Perhaps add more cipher suites to these lists. static const cipher_list OK_RSA_ciphers[] = { - CDEF(ECDHE_RSA_WITH_AES_128_CBC_SHA), - CDEF(ECDHE_RSA_WITH_AES_256_CBC_SHA), - CDEF(ECDHE_RSA_WITH_AES_128_GCM_SHA256), + CDEF(ECDHE_RSA_WITH_AES_128_CBC_SHA), + CDEF(ECDHE_RSA_WITH_AES_256_CBC_SHA), + CDEF(ECDHE_RSA_WITH_AES_128_GCM_SHA256), #ifdef TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA256 - CDEF(ECDHE_RSA_WITH_AES_256_GCM_SHA256), + CDEF(ECDHE_RSA_WITH_AES_256_GCM_SHA256), #endif #ifdef TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 - CDEF(ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256), + CDEF(ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256), #endif }; static const cipher_list OK_ECDSA_ciphers[] = { - CDEF(ECDHE_ECDSA_WITH_AES_128_CBC_SHA), - CDEF(ECDHE_ECDSA_WITH_AES_256_CBC_SHA), - CDEF(ECDHE_ECDSA_WITH_AES_128_GCM_SHA256), + CDEF(ECDHE_ECDSA_WITH_AES_128_CBC_SHA), + CDEF(ECDHE_ECDSA_WITH_AES_256_CBC_SHA), + CDEF(ECDHE_ECDSA_WITH_AES_128_GCM_SHA256), #ifdef TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA256 - CDEF(ECDHE_ECDSA_WITH_AES_256_GCM_SHA256), + CDEF(ECDHE_ECDSA_WITH_AES_256_GCM_SHA256), #endif #ifdef TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 - CDEF(ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256), + CDEF(ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256), #endif }; #undef CDEF diff --git a/rtc_base/opensslstreamadapter.h b/rtc_base/opensslstreamadapter.h index 7a6e099d22..61ffc3dbfe 100644 --- a/rtc_base/opensslstreamadapter.h +++ b/rtc_base/opensslstreamadapter.h @@ -13,8 +13,8 @@ #include -#include #include +#include #include #include "rtc_base/buffer.h" @@ -125,14 +125,14 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter { // Before calling one of the StartSSL methods, data flows // in clear text. SSL_NONE, - SSL_WAIT, // waiting for the stream to open to start SSL negotiation + SSL_WAIT, // waiting for the stream to open to start SSL negotiation SSL_CONNECTING, // SSL negotiation in progress - SSL_CONNECTED, // SSL stream successfully established - SSL_ERROR, // some SSL error occurred, stream is closed - SSL_CLOSED // Clean close + SSL_CONNECTED, // SSL stream successfully established + SSL_ERROR, // some SSL error occurred, stream is closed + SSL_CLOSED // Clean close }; - enum { MSG_TIMEOUT = MSG_MAX+1}; + enum { MSG_TIMEOUT = MSG_MAX + 1 }; // The following three methods return 0 on success and a negative // error code on failure. The error code may be from OpenSSL or -1 diff --git a/rtc_base/optionsfile.cc b/rtc_base/optionsfile.cc index c3b6a6ab93..8d2d2e0df6 100644 --- a/rtc_base/optionsfile.cc +++ b/rtc_base/optionsfile.cc @@ -18,8 +18,7 @@ namespace rtc { -OptionsFile::OptionsFile(const std::string &path) : path_(path) { -} +OptionsFile::OptionsFile(const std::string& path) : path_(path) {} OptionsFile::~OptionsFile() = default; @@ -75,8 +74,8 @@ bool OptionsFile::Save() { int error; for (OptionsMap::const_iterator i = options_.begin(); i != options_.end(); ++i) { - res = stream.WriteAll(i->first.c_str(), i->first.length(), &written, - &error); + res = + stream.WriteAll(i->first.c_str(), i->first.length(), &written, &error); if (res != SR_SUCCESS) { break; } @@ -85,7 +84,7 @@ bool OptionsFile::Save() { break; } res = stream.WriteAll(i->second.c_str(), i->second.length(), &written, - &error); + &error); if (res != SR_SUCCESS) { break; } @@ -102,7 +101,7 @@ bool OptionsFile::Save() { } } -bool OptionsFile::IsLegalName(const std::string &name) { +bool OptionsFile::IsLegalName(const std::string& name) { for (size_t pos = 0; pos < name.length(); ++pos) { if (name[pos] == '\n' || name[pos] == '\\' || name[pos] == '=') { // Illegal character. @@ -113,7 +112,7 @@ bool OptionsFile::IsLegalName(const std::string &name) { return true; } -bool OptionsFile::IsLegalValue(const std::string &value) { +bool OptionsFile::IsLegalValue(const std::string& value) { for (size_t pos = 0; pos < value.length(); ++pos) { if (value[pos] == '\n' || value[pos] == '\\') { // Illegal character. @@ -125,7 +124,7 @@ bool OptionsFile::IsLegalValue(const std::string &value) { } bool OptionsFile::GetStringValue(const std::string& option, - std::string *out_val) const { + std::string* out_val) const { RTC_LOG(LS_VERBOSE) << "OptionsFile::GetStringValue " << option; if (!IsLegalName(option)) { return false; @@ -138,8 +137,7 @@ bool OptionsFile::GetStringValue(const std::string& option, return true; } -bool OptionsFile::GetIntValue(const std::string& option, - int *out_val) const { +bool OptionsFile::GetIntValue(const std::string& option, int* out_val) const { RTC_LOG(LS_VERBOSE) << "OptionsFile::GetIntValue " << option; if (!IsLegalName(option)) { return false; @@ -162,8 +160,7 @@ bool OptionsFile::SetStringValue(const std::string& option, return true; } -bool OptionsFile::SetIntValue(const std::string& option, - int value) { +bool OptionsFile::SetIntValue(const std::string& option, int value) { RTC_LOG(LS_VERBOSE) << "OptionsFile::SetIntValue " << option << ":" << value; if (!IsLegalName(option)) { return false; diff --git a/rtc_base/optionsfile.h b/rtc_base/optionsfile.h index 90976ac579..55660ff259 100644 --- a/rtc_base/optionsfile.h +++ b/rtc_base/optionsfile.h @@ -21,7 +21,7 @@ namespace rtc { // first-class options storage system. class OptionsFile { public: - OptionsFile(const std::string &path); + OptionsFile(const std::string& path); ~OptionsFile(); // Loads the file from disk, overwriting the in-memory values. @@ -38,8 +38,8 @@ class OptionsFile { private: typedef std::map OptionsMap; - static bool IsLegalName(const std::string &name); - static bool IsLegalValue(const std::string &value); + static bool IsLegalName(const std::string& name); + static bool IsLegalValue(const std::string& value); std::string path_; OptionsMap options_; diff --git a/rtc_base/optionsfile_unittest.cc b/rtc_base/optionsfile_unittest.cc index d2e3cbd8e3..fc5bc823ff 100644 --- a/rtc_base/optionsfile_unittest.cc +++ b/rtc_base/optionsfile_unittest.cc @@ -26,16 +26,18 @@ static const std::string kOptionWithNewline = "foo\nbar"; static const std::string kValueWithEquals = "baz=quux"; static const std::string kValueWithNewline = "baz\nquux"; static const std::string kEmptyString = ""; -static const char kOptionWithUtf8[] = {'O', 'p', 't', '\302', '\256', 'i', 'o', - 'n', '\342', '\204', '\242', '\0'}; // Opt(R)io(TM). -static const char kValueWithUtf8[] = {'V', 'a', 'l', '\302', '\256', 'v', 'e', - '\342', '\204', '\242', '\0'}; // Val(R)ue(TM). +static const char kOptionWithUtf8[] = {'O', 'p', 't', '\302', '\256', + 'i', 'o', 'n', '\342', '\204', + '\242', '\0'}; // Opt(R)io(TM). +static const char kValueWithUtf8[] = { + 'V', 'a', 'l', '\302', '\256', 'v', + 'e', '\342', '\204', '\242', '\0'}; // Val(R)ue(TM). static int kTestInt1 = 12345; static int kTestInt2 = 67890; static int kNegInt = -634; static int kZero = 0; -#if defined (WEBRTC_ANDROID) +#if defined(WEBRTC_ANDROID) // Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364. #define MAYBE_OptionsFileTest DISABLED_OptionsFileTest #else @@ -50,14 +52,10 @@ class MAYBE_OptionsFileTest : public testing::Test { OpenStore(); } - ~MAYBE_OptionsFileTest() override { - webrtc::test::RemoveFile(test_file_); - } + ~MAYBE_OptionsFileTest() override { webrtc::test::RemoveFile(test_file_); } protected: - void OpenStore() { - store_.reset(new OptionsFile(test_file_)); - } + void OpenStore() { store_.reset(new OptionsFile(test_file_)); } std::unique_ptr store_; diff --git a/rtc_base/pathutils.h b/rtc_base/pathutils.h index a7005fc739..9543be073f 100644 --- a/rtc_base/pathutils.h +++ b/rtc_base/pathutils.h @@ -38,7 +38,7 @@ namespace rtc { /////////////////////////////////////////////////////////////////////////////// class Pathname { -public: + public: // Folder delimiters are slash and backslash static bool IsFolderDelimiter(char ch); static char DefaultFolderDelimiter(); @@ -71,11 +71,11 @@ public: std::string filename() const; bool SetFilename(const std::string& filename); -private: + private: std::string folder_, basename_, extension_; char folder_delimiter_; }; } // namespace rtc -#endif // RTC_BASE_PATHUTILS_H_ +#endif // RTC_BASE_PATHUTILS_H_ diff --git a/rtc_base/physicalsocketserver.cc b/rtc_base/physicalsocketserver.cc index 22a3882bd4..6a23ea88fb 100644 --- a/rtc_base/physicalsocketserver.cc +++ b/rtc_base/physicalsocketserver.cc @@ -10,7 +10,7 @@ #include "rtc_base/physicalsocketserver.h" #if defined(_MSC_VER) && _MSC_VER < 1300 -#pragma warning(disable:4786) +#pragma warning(disable : 4786) #endif #ifdef MEMORY_SANITIZER @@ -18,17 +18,17 @@ #endif #if defined(WEBRTC_POSIX) -#include #include +#include #if defined(WEBRTC_USE_EPOLL) // "poll" will be used to wait for the signal dispatcher. #include #endif -#include -#include -#include -#include #include +#include +#include +#include +#include #endif #if defined(WEBRTC_WIN) @@ -63,7 +63,7 @@ #if defined(WEBRTC_POSIX) #include // for TCP_NODELAY -#define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h +#define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h typedef void* SockOptArg; #endif // WEBRTC_POSIX @@ -113,9 +113,11 @@ std::unique_ptr SocketServer::CreateDefault() { } PhysicalSocket::PhysicalSocket(PhysicalSocketServer* ss, SOCKET s) - : ss_(ss), s_(s), error_(0), - state_((s == INVALID_SOCKET) ? CS_CLOSED : CS_CONNECTED), - resolver_(nullptr) { + : ss_(ss), + s_(s), + error_(0), + state_((s == INVALID_SOCKET) ? CS_CLOSED : CS_CONNECTED), + resolver_(nullptr) { #if defined(WEBRTC_WIN) // EnsureWinsockInit() ensures that winsock is initialized. The default // version of this function doesn't do anything because winsock is @@ -250,8 +252,7 @@ int PhysicalSocket::Connect(const SocketAddress& addr) { } int PhysicalSocket::DoConnect(const SocketAddress& connect_addr) { - if ((s_ == INVALID_SOCKET) && - !Create(connect_addr.family(), SOCK_STREAM)) { + if ((s_ == INVALID_SOCKET) && !Create(connect_addr.family(), SOCK_STREAM)) { return SOCKET_ERROR; } sockaddr_storage addr_storage; @@ -316,8 +317,8 @@ int PhysicalSocket::SetOption(Option opt, int value) { } int PhysicalSocket::Send(const void* pv, size_t cb) { - int sent = DoSend(s_, reinterpret_cast(pv), - static_cast(cb), + int sent = DoSend( + s_, reinterpret_cast(pv), static_cast(cb), #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) // Suppress SIGPIPE. Without this, attempting to send on a socket whose // other end is closed will result in a SIGPIPE signal being raised to @@ -345,15 +346,15 @@ int PhysicalSocket::SendTo(const void* buffer, const SocketAddress& addr) { sockaddr_storage saddr; size_t len = addr.ToSockAddrStorage(&saddr); - int sent = DoSendTo( - s_, static_cast(buffer), static_cast(length), + int sent = + DoSendTo(s_, static_cast(buffer), static_cast(length), #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) - // Suppress SIGPIPE. See above for explanation. - MSG_NOSIGNAL, + // Suppress SIGPIPE. See above for explanation. + MSG_NOSIGNAL, #else - 0, + 0, #endif - reinterpret_cast(&saddr), static_cast(len)); + reinterpret_cast(&saddr), static_cast(len)); UpdateLastError(); MaybeRemapSendError(); // We have seen minidumps where this may be false. @@ -366,8 +367,8 @@ int PhysicalSocket::SendTo(const void* buffer, } int PhysicalSocket::Recv(void* buffer, size_t length, int64_t* timestamp) { - int received = ::recv(s_, static_cast(buffer), - static_cast(length), 0); + int received = + ::recv(s_, static_cast(buffer), static_cast(length), 0); if ((received == 0) && (length != 0)) { // Note: on graceful shutdown, recv can return 0. In this case, we // pretend it is blocking, and then signal close, so that simplifying @@ -570,20 +571,24 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) { return 0; } -SocketDispatcher::SocketDispatcher(PhysicalSocketServer *ss) +SocketDispatcher::SocketDispatcher(PhysicalSocketServer* ss) #if defined(WEBRTC_WIN) - : PhysicalSocket(ss), id_(0), signal_close_(false) + : PhysicalSocket(ss), + id_(0), + signal_close_(false) #else - : PhysicalSocket(ss) + : PhysicalSocket(ss) #endif { } -SocketDispatcher::SocketDispatcher(SOCKET s, PhysicalSocketServer *ss) +SocketDispatcher::SocketDispatcher(SOCKET s, PhysicalSocketServer* ss) #if defined(WEBRTC_WIN) - : PhysicalSocket(ss, s), id_(0), signal_close_(false) + : PhysicalSocket(ss, s), + id_(0), + signal_close_(false) #else - : PhysicalSocket(ss, s) + : PhysicalSocket(ss, s) #endif { } @@ -594,7 +599,7 @@ SocketDispatcher::~SocketDispatcher() { bool SocketDispatcher::Initialize() { RTC_DCHECK(s_ != INVALID_SOCKET); - // Must be a non-blocking +// Must be a non-blocking #if defined(WEBRTC_WIN) u_long argp = 1; ioctlsocket(s_, FIONBIO, &argp); @@ -627,7 +632,9 @@ bool SocketDispatcher::Create(int family, int type) { return false; #if defined(WEBRTC_WIN) - do { id_ = ++next_id_; } while (id_ == 0); + do { + id_ = ++next_id_; + } while (id_ == 0); #endif return true; } @@ -711,7 +718,7 @@ bool SocketDispatcher::IsDescriptorClosed() { } } -#endif // WEBRTC_POSIX +#endif // WEBRTC_POSIX uint32_t SocketDispatcher::GetRequestedEvents() { return enabled_events(); @@ -722,7 +729,7 @@ void SocketDispatcher::OnPreEvent(uint32_t ff) { state_ = CS_CONNECTED; #if defined(WEBRTC_WIN) - // We set CS_CLOSED from CheckSignalClose. +// We set CS_CLOSED from CheckSignalClose. #elif defined(WEBRTC_POSIX) if ((ff & DE_CLOSE) != 0) state_ = CS_CLOSED; @@ -802,7 +809,7 @@ void SocketDispatcher::OnEvent(uint32_t ff, int err) { #endif } -#endif // WEBRTC_POSIX +#endif // WEBRTC_POSIX #if defined(WEBRTC_USE_EPOLL) @@ -915,7 +922,7 @@ class EventDispatcher : public Dispatcher { bool IsDescriptorClosed() override { return false; } private: - PhysicalSocketServer *ss_; + PhysicalSocketServer* ss_; int afd_[2]; bool fSignaled_; CriticalSection crit_; @@ -960,9 +967,7 @@ class PosixSignalHandler { } // Returns the file descriptor to monitor for signal events. - int GetDescriptor() const { - return afd_[0]; - } + int GetDescriptor() const { return afd_[0]; } // This is called directly from our real signal handler, so it must be // signal-handler-safe. That means it cannot assume anything about the @@ -999,8 +1004,7 @@ class PosixSignalHandler { if (fcntl(afd_[1], F_SETFL, O_NONBLOCK) < 0) { RTC_LOG_ERR(LS_WARNING) << "fcntl #2 failed"; } - memset(const_cast(static_cast(received_signal_)), - 0, + memset(const_cast(static_cast(received_signal_)), 0, sizeof(received_signal_)); } @@ -1038,13 +1042,11 @@ class PosixSignalHandler { class PosixSignalDispatcher : public Dispatcher { public: - PosixSignalDispatcher(PhysicalSocketServer *owner) : owner_(owner) { + PosixSignalDispatcher(PhysicalSocketServer* owner) : owner_(owner) { owner_->Add(this); } - ~PosixSignalDispatcher() override { - owner_->Remove(this); - } + ~PosixSignalDispatcher() override { owner_->Remove(this); } uint32_t GetRequestedEvents() override { return DE_READ; } @@ -1089,23 +1091,19 @@ class PosixSignalDispatcher : public Dispatcher { handlers_[signum] = handler; } - void ClearHandler(int signum) { - handlers_.erase(signum); - } + void ClearHandler(int signum) { handlers_.erase(signum); } - bool HasHandlers() { - return !handlers_.empty(); - } + bool HasHandlers() { return !handlers_.empty(); } private: typedef std::map HandlerMap; HandlerMap handlers_; // Our owner. - PhysicalSocketServer *owner_; + PhysicalSocketServer* owner_; }; -#endif // WEBRTC_POSIX +#endif // WEBRTC_POSIX #if defined(WEBRTC_WIN) static uint32_t FlagsToEvents(uint32_t events) { @@ -1123,7 +1121,7 @@ static uint32_t FlagsToEvents(uint32_t events) { class EventDispatcher : public Dispatcher { public: - EventDispatcher(PhysicalSocketServer *ss) : ss_(ss) { + EventDispatcher(PhysicalSocketServer* ss) : ss_(ss) { hev_ = WSACreateEvent(); if (hev_) { ss_->Add(this); @@ -1164,10 +1162,8 @@ class EventDispatcher : public Dispatcher { // Sets the value of a boolean value to false when signaled. class Signaler : public EventDispatcher { public: - Signaler(PhysicalSocketServer* ss, bool* pf) - : EventDispatcher(ss), pf_(pf) { - } - ~Signaler() override { } + Signaler(PhysicalSocketServer* ss, bool* pf) : EventDispatcher(ss), pf_(pf) {} + ~Signaler() override {} void OnEvent(uint32_t ff, int err) override { if (pf_) @@ -1175,11 +1171,10 @@ class Signaler : public EventDispatcher { } private: - bool *pf_; + bool* pf_; }; -PhysicalSocketServer::PhysicalSocketServer() - : fWait_(false) { +PhysicalSocketServer::PhysicalSocketServer() : fWait_(false) { #if defined(WEBRTC_USE_EPOLL) // Since Linux 2.6.8, the size argument is ignored, but must be greater than // zero. Before that the size served as hint to the kernel for the amount of @@ -1247,7 +1242,7 @@ AsyncSocket* PhysicalSocketServer::WrapSocket(SOCKET s) { } } -void PhysicalSocketServer::Add(Dispatcher *pdispatcher) { +void PhysicalSocketServer::Add(Dispatcher* pdispatcher) { CritScope cs(&crit_); if (processing_dispatchers_) { // A dispatcher is being added while a "Wait" call is processing the @@ -1266,7 +1261,7 @@ void PhysicalSocketServer::Add(Dispatcher *pdispatcher) { #endif // WEBRTC_USE_EPOLL } -void PhysicalSocketServer::Remove(Dispatcher *pdispatcher) { +void PhysicalSocketServer::Remove(Dispatcher* pdispatcher) { CritScope cs(&crit_); if (processing_dispatchers_) { // A dispatcher is being removed while a "Wait" call is processing the @@ -1420,9 +1415,9 @@ bool PhysicalSocketServer::WaitSelect(int cmsWait, bool process_io) { FD_ZERO(&fdsRead); fd_set fdsWrite; FD_ZERO(&fdsWrite); - // Explicitly unpoison these FDs on MemorySanitizer which doesn't handle the - // inline assembly in FD_ZERO. - // http://crbug.com/344505 +// Explicitly unpoison these FDs on MemorySanitizer which doesn't handle the +// inline assembly in FD_ZERO. +// http://crbug.com/344505 #ifdef MEMORY_SANITIZER __msan_unpoison(&fdsRead, sizeof(fdsRead)); __msan_unpoison(&fdsWrite, sizeof(fdsWrite)); @@ -1509,9 +1504,8 @@ bool PhysicalSocketServer::WaitSelect(int cmsWait, bool process_io) { ptvWait->tv_usec = 0; struct timeval tvT; gettimeofday(&tvT, nullptr); - if ((tvStop.tv_sec > tvT.tv_sec) - || ((tvStop.tv_sec == tvT.tv_sec) - && (tvStop.tv_usec > tvT.tv_usec))) { + if ((tvStop.tv_sec > tvT.tv_sec) || + ((tvStop.tv_sec == tvT.tv_sec) && (tvStop.tv_usec > tvT.tv_usec))) { ptvWait->tv_sec = tvStop.tv_sec - tvT.tv_sec; ptvWait->tv_usec = tvStop.tv_usec - tvT.tv_usec; if (ptvWait->tv_usec < 0) { @@ -1801,7 +1795,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { fWait_ = true; while (fWait_) { std::vector events; - std::vector event_owners; + std::vector event_owners; events.push_back(socket_ev_); @@ -1820,8 +1814,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { if (disp->CheckSignalClose()) { // We just signalled close, don't poll this socket } else if (s != INVALID_SOCKET) { - WSAEventSelect(s, - events[0], + WSAEventSelect(s, events[0], FlagsToEvents(disp->GetRequestedEvents())); } else { events.push_back(disp->GetWSAEvent()); @@ -1845,11 +1838,9 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { } // Wait for one of the events to signal - DWORD dw = WSAWaitForMultipleEvents(static_cast(events.size()), - &events[0], - false, - static_cast(cmsNext), - false); + DWORD dw = + WSAWaitForMultipleEvents(static_cast(events.size()), &events[0], + false, static_cast(cmsNext), false); if (dw == WSA_WAIT_FAILED) { // Failed? @@ -1865,7 +1856,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { CritScope cr(&crit_); int index = dw - WSA_WAIT_EVENT_0; if (index > 0) { - --index; // The first event is the socket event + --index; // The first event is the socket event Dispatcher* disp = event_owners[index]; // The dispatcher could have been removed while waiting for events. if (dispatchers_.find(disp) != dispatchers_.end()) { @@ -1956,7 +1947,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { break; cmsElapsed = TimeSince(msStart); if ((cmsWait != kForever) && (cmsElapsed >= cmsWait)) { - break; + break; } } diff --git a/rtc_base/physicalsocketserver.h b/rtc_base/physicalsocketserver.h index 158c3d6605..ee4f936e81 100644 --- a/rtc_base/physicalsocketserver.h +++ b/rtc_base/physicalsocketserver.h @@ -26,17 +26,17 @@ #if defined(WEBRTC_POSIX) typedef int SOCKET; -#endif // WEBRTC_POSIX +#endif // WEBRTC_POSIX namespace rtc { // Event constants for the Dispatcher class. enum DispatcherEvent { - DE_READ = 0x0001, - DE_WRITE = 0x0002, + DE_READ = 0x0001, + DE_WRITE = 0x0002, DE_CONNECT = 0x0004, - DE_CLOSE = 0x0008, - DE_ACCEPT = 0x0010, + DE_CLOSE = 0x0008, + DE_ACCEPT = 0x0010, }; class Signaler; @@ -181,8 +181,12 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { virtual int DoSend(SOCKET socket, const char* buf, int len, int flags); // Make virtual so ::sendto can be overwritten in tests. - virtual int DoSendTo(SOCKET socket, const char* buf, int len, int flags, - const struct sockaddr* dest_addr, socklen_t addrlen); + virtual int DoSendTo(SOCKET socket, + const char* buf, + int len, + int flags, + const struct sockaddr* dest_addr, + socklen_t addrlen); void OnResolveResult(AsyncResolverInterface* resolver); @@ -214,8 +218,8 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { class SocketDispatcher : public Dispatcher, public PhysicalSocket { public: - explicit SocketDispatcher(PhysicalSocketServer *ss); - SocketDispatcher(SOCKET s, PhysicalSocketServer *ss); + explicit SocketDispatcher(PhysicalSocketServer* ss); + SocketDispatcher(SOCKET s, PhysicalSocketServer* ss); ~SocketDispatcher() override; bool Initialize(); @@ -254,7 +258,7 @@ class SocketDispatcher : public Dispatcher, public PhysicalSocket { int id_; bool signal_close_; int signal_err_; -#endif // WEBRTC_WIN +#endif // WEBRTC_WIN #if defined(WEBRTC_USE_EPOLL) void MaybeUpdateDispatcher(uint8_t old_events); @@ -262,6 +266,6 @@ class SocketDispatcher : public Dispatcher, public PhysicalSocket { #endif }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_PHYSICALSOCKETSERVER_H_ +#endif // RTC_BASE_PHYSICALSOCKETSERVER_H_ diff --git a/rtc_base/physicalsocketserver_unittest.cc b/rtc_base/physicalsocketserver_unittest.cc index 26200bc4a0..1e046c057e 100644 --- a/rtc_base/physicalsocketserver_unittest.cc +++ b/rtc_base/physicalsocketserver_unittest.cc @@ -8,9 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include #include +#include #include "rtc_base/gunit.h" #include "rtc_base/logging.h" @@ -39,25 +39,25 @@ class PhysicalSocketTest; class FakeSocketDispatcher : public SocketDispatcher { public: explicit FakeSocketDispatcher(PhysicalSocketServer* ss) - : SocketDispatcher(ss) { - } + : SocketDispatcher(ss) {} FakeSocketDispatcher(SOCKET s, PhysicalSocketServer* ss) - : SocketDispatcher(s, ss) { - } + : SocketDispatcher(s, ss) {} protected: SOCKET DoAccept(SOCKET socket, sockaddr* addr, socklen_t* addrlen) override; int DoSend(SOCKET socket, const char* buf, int len, int flags) override; - int DoSendTo(SOCKET socket, const char* buf, int len, int flags, - const struct sockaddr* dest_addr, socklen_t addrlen) override; + int DoSendTo(SOCKET socket, + const char* buf, + int len, + int flags, + const struct sockaddr* dest_addr, + socklen_t addrlen) override; }; class FakePhysicalSocketServer : public PhysicalSocketServer { public: - explicit FakePhysicalSocketServer(PhysicalSocketTest* test) - : test_(test) { - } + explicit FakePhysicalSocketServer(PhysicalSocketTest* test) : test_(test) {} AsyncSocket* CreateAsyncSocket(int family, int type) override { SocketDispatcher* dispatcher = new FakeSocketDispatcher(this); @@ -111,10 +111,10 @@ class PhysicalSocketTest : public SocketTest { protected: PhysicalSocketTest() - : server_(new FakePhysicalSocketServer(this)), - thread_(server_.get()), - fail_accept_(false), - max_send_size_(-1) {} + : server_(new FakePhysicalSocketServer(this)), + thread_(server_.get()), + fail_accept_(false), + max_send_size_(-1) {} void ConnectInternalAcceptError(const IPAddress& loopback); void WritableAfterPartialWrite(const IPAddress& loopback); @@ -137,8 +137,10 @@ SOCKET FakeSocketDispatcher::DoAccept(SOCKET socket, return SocketDispatcher::DoAccept(socket, addr, addrlen); } -int FakeSocketDispatcher::DoSend(SOCKET socket, const char* buf, int len, - int flags) { +int FakeSocketDispatcher::DoSend(SOCKET socket, + const char* buf, + int len, + int flags) { FakePhysicalSocketServer* ss = static_cast(socketserver()); if (ss->GetTest()->MaxSendSize() >= 0) { @@ -148,8 +150,12 @@ int FakeSocketDispatcher::DoSend(SOCKET socket, const char* buf, int len, return SocketDispatcher::DoSend(socket, buf, len, flags); } -int FakeSocketDispatcher::DoSendTo(SOCKET socket, const char* buf, int len, - int flags, const struct sockaddr* dest_addr, socklen_t addrlen) { +int FakeSocketDispatcher::DoSendTo(SOCKET socket, + const char* buf, + int len, + int flags, + const struct sockaddr* dest_addr, + socklen_t addrlen) { FakePhysicalSocketServer* ss = static_cast(socketserver()); if (ss->GetTest()->MaxSendSize() >= 0) { @@ -157,7 +163,7 @@ int FakeSocketDispatcher::DoSendTo(SOCKET socket, const char* buf, int len, } return SocketDispatcher::DoSendTo(socket, buf, len, flags, dest_addr, - addrlen); + addrlen); } TEST_F(PhysicalSocketTest, TestConnectIPv4) { @@ -280,9 +286,11 @@ void PhysicalSocketTest::WritableAfterPartialWrite(const IPAddress& loopback) { // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 #if defined(WEBRTC_WIN) -#define MAYBE_TestWritableAfterPartialWriteIPv4 DISABLED_TestWritableAfterPartialWriteIPv4 +#define MAYBE_TestWritableAfterPartialWriteIPv4 \ + DISABLED_TestWritableAfterPartialWriteIPv4 #else -#define MAYBE_TestWritableAfterPartialWriteIPv4 TestWritableAfterPartialWriteIPv4 +#define MAYBE_TestWritableAfterPartialWriteIPv4 \ + TestWritableAfterPartialWriteIPv4 #endif TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv4) { MAYBE_SKIP_IPV4; @@ -291,9 +299,11 @@ TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv4) { // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 #if defined(WEBRTC_WIN) -#define MAYBE_TestWritableAfterPartialWriteIPv6 DISABLED_TestWritableAfterPartialWriteIPv6 +#define MAYBE_TestWritableAfterPartialWriteIPv6 \ + DISABLED_TestWritableAfterPartialWriteIPv6 #else -#define MAYBE_TestWritableAfterPartialWriteIPv6 TestWritableAfterPartialWriteIPv6 +#define MAYBE_TestWritableAfterPartialWriteIPv6 \ + TestWritableAfterPartialWriteIPv6 #endif TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv6) { MAYBE_SKIP_IPV6; @@ -313,7 +323,6 @@ TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv6) { SocketTest::TestConnectWithDnsLookupFailIPv6(); } - TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectWithClosedSocketIPv4(); @@ -463,8 +472,7 @@ TEST_F(PhysicalSocketTest, } // Network binder shouldn't be used if the socket is bound to the "any" IP. -TEST_F(PhysicalSocketTest, - NetworkBinderIsNotUsedForAnyIp) { +TEST_F(PhysicalSocketTest, NetworkBinderIsNotUsedForAnyIp) { MAYBE_SKIP_IPV4; FakeNetworkBinder fake_network_binder; server_->set_network_binder(&fake_network_binder); @@ -529,7 +537,7 @@ class PosixSignalDeliveryTest : public testing::Test { } static std::vector signals_received_; - static Thread *signaled_thread_; + static Thread* signaled_thread_; std::unique_ptr ss_; }; diff --git a/rtc_base/platform_thread_types.h b/rtc_base/platform_thread_types.h index 72aaa4b546..0bc42eb2c2 100644 --- a/rtc_base/platform_thread_types.h +++ b/rtc_base/platform_thread_types.h @@ -11,7 +11,12 @@ #ifndef RTC_BASE_PLATFORM_THREAD_TYPES_H_ #define RTC_BASE_PLATFORM_THREAD_TYPES_H_ +// clang-format off +// clang formating would change include order. #if defined(WEBRTC_WIN) +// Include winsock2.h before including to maintain consistency with +// win32.h. To include win32.h directly, it must be broken out into its own +// build target. #include #include #elif defined(WEBRTC_FUCHSIA) @@ -21,6 +26,7 @@ #include #include #endif +// clang-format on namespace rtc { #if defined(WEBRTC_WIN) diff --git a/rtc_base/platform_thread_unittest.cc b/rtc_base/platform_thread_unittest.cc index d8c8995507..1661b6a999 100644 --- a/rtc_base/platform_thread_unittest.cc +++ b/rtc_base/platform_thread_unittest.cc @@ -125,4 +125,4 @@ TEST(PlatformThreadTest, DISABLED_TooBusyDeprecated) { thread.Stop(); } -} // rtc +} // namespace rtc diff --git a/rtc_base/proxy_unittest.cc b/rtc_base/proxy_unittest.cc index 7d7b6f8913..d81b3125cb 100644 --- a/rtc_base/proxy_unittest.cc +++ b/rtc_base/proxy_unittest.cc @@ -32,8 +32,8 @@ static const SocketAddress kBogusProxyIntAddr("1.2.3.4", 999); class ProxyTest : public testing::Test { public: ProxyTest() : ss_(new rtc::VirtualSocketServer()), thread_(ss_.get()) { - socks_.reset(new rtc::SocksProxyServer( - ss_.get(), kSocksProxyIntAddr, ss_.get(), kSocksProxyExtAddr)); + socks_.reset(new rtc::SocksProxyServer(ss_.get(), kSocksProxyIntAddr, + ss_.get(), kSocksProxyExtAddr)); https_.reset(new rtc::HttpListenServer()); https_->Listen(kHttpsProxyIntAddr); } @@ -52,13 +52,11 @@ class ProxyTest : public testing::Test { TEST_F(ProxyTest, TestSocks5Connect) { rtc::AsyncSocket* socket = ss()->CreateAsyncSocket(kSocksProxyIntAddr.family(), SOCK_STREAM); - rtc::AsyncSocksProxySocket* proxy_socket = - new rtc::AsyncSocksProxySocket(socket, kSocksProxyIntAddr, - "", rtc::CryptString()); + rtc::AsyncSocksProxySocket* proxy_socket = new rtc::AsyncSocksProxySocket( + socket, kSocksProxyIntAddr, "", rtc::CryptString()); // TODO: IPv6-ize these tests when proxy supports IPv6. - rtc::TestEchoServer server(Thread::Current(), - SocketAddress(INADDR_ANY, 0)); + rtc::TestEchoServer server(Thread::Current(), SocketAddress(INADDR_ANY, 0)); std::unique_ptr packet_socket( rtc::AsyncTCPSocket::Create(proxy_socket, SocketAddress(INADDR_ANY, 0), diff --git a/rtc_base/proxyinfo.cc b/rtc_base/proxyinfo.cc index a165dcad5e..c394487c1a 100644 --- a/rtc_base/proxyinfo.cc +++ b/rtc_base/proxyinfo.cc @@ -12,13 +12,12 @@ namespace rtc { -const char * ProxyToString(ProxyType proxy) { - const char * const PROXY_NAMES[] = { "none", "https", "socks5", "unknown" }; +const char* ProxyToString(ProxyType proxy) { + const char* const PROXY_NAMES[] = {"none", "https", "socks5", "unknown"}; return PROXY_NAMES[proxy]; } -ProxyInfo::ProxyInfo() : type(PROXY_NONE), autodetect(false) { -} +ProxyInfo::ProxyInfo() : type(PROXY_NONE), autodetect(false) {} ProxyInfo::~ProxyInfo() = default; -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/proxyinfo.h b/rtc_base/proxyinfo.h index 5affcd86c3..19476696a2 100644 --- a/rtc_base/proxyinfo.h +++ b/rtc_base/proxyinfo.h @@ -17,13 +17,8 @@ namespace rtc { -enum ProxyType { - PROXY_NONE, - PROXY_HTTPS, - PROXY_SOCKS5, - PROXY_UNKNOWN -}; -const char * ProxyToString(ProxyType proxy); +enum ProxyType { PROXY_NONE, PROXY_HTTPS, PROXY_SOCKS5, PROXY_UNKNOWN }; +const char* ProxyToString(ProxyType proxy); struct ProxyInfo { ProxyType type; @@ -38,6 +33,6 @@ struct ProxyInfo { ~ProxyInfo(); }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_PROXYINFO_H_ +#endif // RTC_BASE_PROXYINFO_H_ diff --git a/rtc_base/proxyserver.cc b/rtc_base/proxyserver.cc index 5ab7943c2e..55cab80975 100644 --- a/rtc_base/proxyserver.cc +++ b/rtc_base/proxyserver.cc @@ -18,12 +18,14 @@ namespace rtc { // ProxyServer -ProxyServer::ProxyServer( - SocketFactory* int_factory, const SocketAddress& int_addr, - SocketFactory* ext_factory, const SocketAddress& ext_ip) - : ext_factory_(ext_factory), ext_ip_(ext_ip.ipaddr(), 0), // strip off port - server_socket_(int_factory->CreateAsyncSocket(int_addr.family(), - SOCK_STREAM)) { +ProxyServer::ProxyServer(SocketFactory* int_factory, + const SocketAddress& int_addr, + SocketFactory* ext_factory, + const SocketAddress& ext_ip) + : ext_factory_(ext_factory), + ext_ip_(ext_ip.ipaddr(), 0), // strip off port + server_socket_( + int_factory->CreateAsyncSocket(int_addr.family(), SOCK_STREAM)) { RTC_DCHECK(server_socket_.get() != nullptr); RTC_DCHECK(int_addr.family() == AF_INET || int_addr.family() == AF_INET6); server_socket_->Bind(int_addr); @@ -32,8 +34,8 @@ ProxyServer::ProxyServer( } ProxyServer::~ProxyServer() { - for (BindingList::iterator it = bindings_.begin(); - it != bindings_.end(); ++it) { + for (BindingList::iterator it = bindings_.begin(); it != bindings_.end(); + ++it) { delete (*it); } } @@ -47,8 +49,8 @@ void ProxyServer::OnAcceptEvent(AsyncSocket* socket) { RTC_DCHECK_EQ(socket, server_socket_.get()); AsyncSocket* int_socket = socket->Accept(nullptr); AsyncProxyServerSocket* wrapped_socket = WrapSocket(int_socket); - AsyncSocket* ext_socket = ext_factory_->CreateAsyncSocket(ext_ip_.family(), - SOCK_STREAM); + AsyncSocket* ext_socket = + ext_factory_->CreateAsyncSocket(ext_ip_.family(), SOCK_STREAM); if (ext_socket) { ext_socket->Bind(ext_ip_); bindings_.push_back(new ProxyBinding(wrapped_socket, ext_socket)); @@ -68,8 +70,11 @@ void ProxyServer::OnBindingDestroyed(ProxyBinding* binding) { // ProxyBinding ProxyBinding::ProxyBinding(AsyncProxyServerSocket* int_socket, AsyncSocket* ext_socket) - : int_socket_(int_socket), ext_socket_(ext_socket), connected_(false), - out_buffer_(kBufferSize), in_buffer_(kBufferSize) { + : int_socket_(int_socket), + ext_socket_(ext_socket), + connected_(false), + out_buffer_(kBufferSize), + in_buffer_(kBufferSize) { int_socket_->SignalConnectRequest.connect(this, &ProxyBinding::OnConnectRequest); int_socket_->SignalReadEvent.connect(this, &ProxyBinding::OnInternalRead); @@ -85,7 +90,7 @@ ProxyBinding::ProxyBinding(AsyncProxyServerSocket* int_socket, ProxyBinding::~ProxyBinding() = default; void ProxyBinding::OnConnectRequest(AsyncProxyServerSocket* socket, - const SocketAddress& addr) { + const SocketAddress& addr) { RTC_DCHECK(!connected_); RTC_DCHECK(ext_socket_); ext_socket_->Connect(addr); diff --git a/rtc_base/proxyserver.h b/rtc_base/proxyserver.h index d90b09171c..37cadd0649 100644 --- a/rtc_base/proxyserver.h +++ b/rtc_base/proxyserver.h @@ -62,8 +62,10 @@ class ProxyBinding : public sigslot::has_slots<> { class ProxyServer : public sigslot::has_slots<> { public: - ProxyServer(SocketFactory* int_factory, const SocketAddress& int_addr, - SocketFactory* ext_factory, const SocketAddress& ext_ip); + ProxyServer(SocketFactory* int_factory, + const SocketAddress& int_addr, + SocketFactory* ext_factory, + const SocketAddress& ext_ip); ~ProxyServer() override; // Returns the address to which the proxy server is bound @@ -86,10 +88,12 @@ class ProxyServer : public sigslot::has_slots<> { // SocksProxyServer is a simple extension of ProxyServer to implement SOCKS. class SocksProxyServer : public ProxyServer { public: - SocksProxyServer(SocketFactory* int_factory, const SocketAddress& int_addr, - SocketFactory* ext_factory, const SocketAddress& ext_ip) - : ProxyServer(int_factory, int_addr, ext_factory, ext_ip) { - } + SocksProxyServer(SocketFactory* int_factory, + const SocketAddress& int_addr, + SocketFactory* ext_factory, + const SocketAddress& ext_ip) + : ProxyServer(int_factory, int_addr, ext_factory, ext_ip) {} + protected: AsyncProxyServerSocket* WrapSocket(AsyncSocket* socket) override; RTC_DISALLOW_COPY_AND_ASSIGN(SocksProxyServer); diff --git a/rtc_base/ratetracker.cc b/rtc_base/ratetracker.cc index 68bd8a1518..e31d26627a 100644 --- a/rtc_base/ratetracker.cc +++ b/rtc_base/ratetracker.cc @@ -79,13 +79,12 @@ double RateTracker::ComputeRateForInterval( // Only count a portion of the first bucket according to how much of the // first bucket is within the current interval. size_t total_samples = ((sample_buckets_[start_bucket] * - (bucket_milliseconds_ - milliseconds_to_skip)) + - (bucket_milliseconds_ >> 1)) / - bucket_milliseconds_; + (bucket_milliseconds_ - milliseconds_to_skip)) + + (bucket_milliseconds_ >> 1)) / + bucket_milliseconds_; // All other buckets in the interval are counted in their entirety. for (size_t i = NextBucketIndex(start_bucket); - i != NextBucketIndex(current_bucket_); - i = NextBucketIndex(i)) { + i != NextBucketIndex(current_bucket_); i = NextBucketIndex(i)) { total_samples += sample_buckets_[i]; } // Convert to samples per second. @@ -125,7 +124,8 @@ void RateTracker::AddSamples(size_t sample_count) { } // Ensure that bucket_start_time_milliseconds_ is updated appropriately if // the entire buffer of samples has been expired. - bucket_start_time_milliseconds_ += bucket_milliseconds_ * + bucket_start_time_milliseconds_ += + bucket_milliseconds_ * ((current_time - bucket_start_time_milliseconds_) / bucket_milliseconds_); // Add all samples in the bucket that includes the current time. sample_buckets_[current_bucket_] += sample_count; diff --git a/rtc_base/ratetracker_unittest.cc b/rtc_base/ratetracker_unittest.cc index cd288a336a..58102dfaae 100644 --- a/rtc_base/ratetracker_unittest.cc +++ b/rtc_base/ratetracker_unittest.cc @@ -13,7 +13,7 @@ namespace rtc { namespace { - const uint32_t kBucketIntervalMs = 100; +const uint32_t kBucketIntervalMs = 100; } // namespace class RateTrackerForTest : public RateTracker { @@ -107,7 +107,7 @@ TEST(RateTrackerTest, TestRateTrackerBasics) { EXPECT_DOUBLE_EQ(9876.0 * 10.0, tracker.ComputeRate()); EXPECT_EQ(1234U * 2 + 9876U * 55, tracker.TotalSampleCount()); EXPECT_DOUBLE_EQ((1234.0 * 2.0 + 9876.0 * 55.0) / 7.5, - tracker.ComputeTotalRate()); + tracker.ComputeTotalRate()); // Advance the clock by 500 ms. Since we sent nothing over this half-second, // the reported rate should be reduced by half. @@ -116,7 +116,7 @@ TEST(RateTrackerTest, TestRateTrackerBasics) { EXPECT_DOUBLE_EQ(9876.0 * 5.0, tracker.ComputeRate()); EXPECT_EQ(1234U * 2 + 9876U * 55, tracker.TotalSampleCount()); EXPECT_DOUBLE_EQ((1234.0 * 2.0 + 9876.0 * 55.0) / 8.0, - tracker.ComputeTotalRate()); + tracker.ComputeTotalRate()); // Rate over the last half second should be zero. EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(500)); diff --git a/rtc_base/refcounter.h b/rtc_base/refcounter.h index baf72ae2a0..3906529c25 100644 --- a/rtc_base/refcounter.h +++ b/rtc_base/refcounter.h @@ -28,8 +28,8 @@ class RefCounter { // the reference counter can be deleted. rtc::RefCountReleaseStatus DecRef() { return (rtc::AtomicOps::Decrement(&ref_count_) == 0) - ? rtc::RefCountReleaseStatus::kDroppedLastRef - : rtc::RefCountReleaseStatus::kOtherRefsRemained; + ? rtc::RefCountReleaseStatus::kDroppedLastRef + : rtc::RefCountReleaseStatus::kOtherRefsRemained; } // Return whether the reference count is one. If the reference count is used diff --git a/rtc_base/rollingaccumulator.h b/rtc_base/rollingaccumulator.h index e7d5b06226..f6215c5407 100644 --- a/rtc_base/rollingaccumulator.h +++ b/rtc_base/rollingaccumulator.h @@ -23,23 +23,17 @@ namespace rtc { // over N most recent samples. // // T is assumed to be an int, long, double or float. -template +template class RollingAccumulator { public: - explicit RollingAccumulator(size_t max_count) - : samples_(max_count) { + explicit RollingAccumulator(size_t max_count) : samples_(max_count) { Reset(); } - ~RollingAccumulator() { - } + ~RollingAccumulator() {} - size_t max_count() const { - return samples_.size(); - } + size_t max_count() const { return samples_.size(); } - size_t count() const { - return count_; - } + size_t count() const { return count_; } void Reset() { count_ = 0U; @@ -84,9 +78,7 @@ class RollingAccumulator { next_index_ = (next_index_ + 1) % max_count(); } - T ComputeSum() const { - return static_cast(sum_); - } + T ComputeSum() const { return static_cast(sum_); } double ComputeMean() const { if (count_ == 0) { @@ -97,8 +89,8 @@ class RollingAccumulator { T ComputeMax() const { if (max_stale_) { - RTC_DCHECK(count_ > 0) << - "It shouldn't be possible for max_stale_ && count_ == 0"; + RTC_DCHECK(count_ > 0) + << "It shouldn't be possible for max_stale_ && count_ == 0"; max_ = samples_[next_index_]; for (size_t i = 1u; i < count_; i++) { max_ = std::max(max_, samples_[(next_index_ + i) % max_count()]); @@ -110,8 +102,8 @@ class RollingAccumulator { T ComputeMin() const { if (min_stale_) { - RTC_DCHECK(count_ > 0) << - "It shouldn't be possible for min_stale_ && count_ == 0"; + RTC_DCHECK(count_ > 0) + << "It shouldn't be possible for min_stale_ && count_ == 0"; min_ = samples_[next_index_]; for (size_t i = 1u; i < count_; i++) { min_ = std::min(min_, samples_[(next_index_ + i) % max_count()]); diff --git a/rtc_base/rtccertificate.cc b/rtc_base/rtccertificate.cc index 2887895816..7f027ba5f8 100644 --- a/rtc_base/rtccertificate.cc +++ b/rtc_base/rtccertificate.cc @@ -22,13 +22,11 @@ scoped_refptr RTCCertificate::Create( return new RefCountedObject(identity.release()); } -RTCCertificate::RTCCertificate(SSLIdentity* identity) - : identity_(identity) { +RTCCertificate::RTCCertificate(SSLIdentity* identity) : identity_(identity) { RTC_DCHECK(identity_); } -RTCCertificate::~RTCCertificate() { -} +RTCCertificate::~RTCCertificate() {} uint64_t RTCCertificate::Expires() const { int64_t expires = ssl_certificate().CertificateExpirationTime(); @@ -57,8 +55,8 @@ RTCCertificatePEM RTCCertificate::ToPEM() const { scoped_refptr RTCCertificate::FromPEM( const RTCCertificatePEM& pem) { - std::unique_ptr identity(SSLIdentity::FromPEMStrings( - pem.private_key(), pem.certificate())); + std::unique_ptr identity( + SSLIdentity::FromPEMStrings(pem.private_key(), pem.certificate())); if (!identity) return nullptr; return new RefCountedObject(identity.release()); diff --git a/rtc_base/rtccertificate.h b/rtc_base/rtccertificate.h index f13caba4cf..d5422f8b4a 100644 --- a/rtc_base/rtccertificate.h +++ b/rtc_base/rtccertificate.h @@ -29,11 +29,9 @@ namespace rtc { // the string representations used by OpenSSL. class RTCCertificatePEM { public: - RTCCertificatePEM( - const std::string& private_key, - const std::string& certificate) - : private_key_(private_key), - certificate_(certificate) {} + RTCCertificatePEM(const std::string& private_key, + const std::string& certificate) + : private_key_(private_key), certificate_(certificate) {} const std::string& private_key() const { return private_key_; } const std::string& certificate() const { return certificate_; } diff --git a/rtc_base/rtccertificate_unittest.cc b/rtc_base/rtccertificate_unittest.cc index 7252a040b4..bb88d8a4d9 100644 --- a/rtc_base/rtccertificate_unittest.cc +++ b/rtc_base/rtccertificate_unittest.cc @@ -47,9 +47,7 @@ class RTCCertificateTest : public testing::Test { // As a result, ExpiresSeconds and HasExpiredSeconds are used instead of // RTCCertificate::Expires and ::HasExpired for ms -> s conversion. - uint64_t NowSeconds() const { - return TimeNanos() / kNumNanosecsPerSec; - } + uint64_t NowSeconds() const { return TimeNanos() / kNumNanosecsPerSec; } uint64_t ExpiresSeconds(const scoped_refptr& cert) const { uint64_t exp_ms = cert->Expires(); @@ -94,7 +92,7 @@ TEST_F(RTCCertificateTest, NewCertificateNotExpired) { EXPECT_FALSE(HasExpiredSeconds(certificate, now)); // Even without specifying the expiration time we would expect it to be valid // for at least half an hour. - EXPECT_FALSE(HasExpiredSeconds(certificate, now + 30*60)); + EXPECT_FALSE(HasExpiredSeconds(certificate, now + 30 * 60)); } TEST_F(RTCCertificateTest, UsesExpiresAskedFor) { diff --git a/rtc_base/rtccertificategenerator.cc b/rtc_base/rtccertificategenerator.cc index cacff61e35..c9847464d4 100644 --- a/rtc_base/rtccertificategenerator.cc +++ b/rtc_base/rtccertificategenerator.cc @@ -102,8 +102,7 @@ class RTCCertificateGenerationTask : public RefCountInterface, } // namespace // static -scoped_refptr -RTCCertificateGenerator::GenerateCertificate( +scoped_refptr RTCCertificateGenerator::GenerateCertificate( const KeyParams& key_params, const Optional& expires_ms) { if (!key_params.IsValid()) @@ -122,8 +121,8 @@ RTCCertificateGenerator::GenerateCertificate( // |SSLIdentity::Generate| should stop relying on |time_t|. // See bugs.webrtc.org/5720. time_t cert_lifetime_s = static_cast(expires_s); - identity = SSLIdentity::GenerateWithExpiration( - kIdentityName, key_params, cert_lifetime_s); + identity = SSLIdentity::GenerateWithExpiration(kIdentityName, key_params, + cert_lifetime_s); } if (!identity) return nullptr; @@ -131,10 +130,9 @@ RTCCertificateGenerator::GenerateCertificate( return RTCCertificate::Create(std::move(identity_sptr)); } -RTCCertificateGenerator::RTCCertificateGenerator( - Thread* signaling_thread, Thread* worker_thread) - : signaling_thread_(signaling_thread), - worker_thread_(worker_thread) { +RTCCertificateGenerator::RTCCertificateGenerator(Thread* signaling_thread, + Thread* worker_thread) + : signaling_thread_(signaling_thread), worker_thread_(worker_thread) { RTC_DCHECK(signaling_thread_); RTC_DCHECK(worker_thread_); } diff --git a/rtc_base/rtccertificategenerator.h b/rtc_base/rtccertificategenerator.h index 1f854667d5..df1be441e5 100644 --- a/rtc_base/rtccertificategenerator.h +++ b/rtc_base/rtccertificategenerator.h @@ -23,8 +23,7 @@ namespace rtc { // See |RTCCertificateGeneratorInterface::GenerateCertificateAsync|. class RTCCertificateGeneratorCallback : public RefCountInterface { public: - virtual void OnSuccess( - const scoped_refptr& certificate) = 0; + virtual void OnSuccess(const scoped_refptr& certificate) = 0; virtual void OnFailure() = 0; protected: diff --git a/rtc_base/rtccertificategenerator_unittest.cc b/rtc_base/rtccertificategenerator_unittest.cc index 9a0ad0cb8d..baf0475144 100644 --- a/rtc_base/rtccertificategenerator_unittest.cc +++ b/rtc_base/rtccertificategenerator_unittest.cc @@ -30,7 +30,7 @@ class RTCCertificateGeneratorFixture : public RTCCertificateGeneratorCallback { RTC_CHECK(signaling_thread_); RTC_CHECK(worker_thread_->Start()); generator_.reset( - new RTCCertificateGenerator(signaling_thread_, worker_thread_.get())); + new RTCCertificateGenerator(signaling_thread_, worker_thread_.get())); } ~RTCCertificateGeneratorFixture() override {} @@ -67,8 +67,7 @@ class RTCCertificateGeneratorFixture : public RTCCertificateGeneratorCallback { bool generate_async_completed_; }; -class RTCCertificateGeneratorTest - : public testing::Test { +class RTCCertificateGeneratorTest : public testing::Test { public: RTCCertificateGeneratorTest() : fixture_(new RefCountedObject()) {} @@ -81,22 +80,18 @@ class RTCCertificateGeneratorTest TEST_F(RTCCertificateGeneratorTest, GenerateECDSA) { EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate( - KeyParams::ECDSA(), - Optional())); + KeyParams::ECDSA(), Optional())); } TEST_F(RTCCertificateGeneratorTest, GenerateRSA) { EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate( - KeyParams::RSA(), - Optional())); + KeyParams::RSA(), Optional())); } TEST_F(RTCCertificateGeneratorTest, GenerateAsyncECDSA) { EXPECT_FALSE(fixture_->certificate()); fixture_->generator()->GenerateCertificateAsync( - KeyParams::ECDSA(), - Optional(), - fixture_); + KeyParams::ECDSA(), Optional(), fixture_); // Until generation has completed, the certificate is null. Since this is an // async call, generation must not have completed until we process messages // posted to this thread (which is done by |EXPECT_TRUE_WAIT|). @@ -115,8 +110,8 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithExpires) { // Generate a certificate that expires immediately. scoped_refptr cert_a = - RTCCertificateGenerator::GenerateCertificate( - KeyParams::ECDSA(), Optional(0)); + RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(), + Optional(0)); EXPECT_TRUE(cert_a); // Generate a certificate that expires in one minute. @@ -131,7 +126,7 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithExpires) { EXPECT_GT(cert_b->Expires(), cert_a->Expires()); uint64_t expires_diff = cert_b->Expires() - cert_a->Expires(); EXPECT_GE(expires_diff, kExpiresMs); - EXPECT_LE(expires_diff, kExpiresMs + 2*kGenerationTimeoutMs + 1000); + EXPECT_LE(expires_diff, kExpiresMs + 2 * kGenerationTimeoutMs + 1000); } TEST_F(RTCCertificateGeneratorTest, GenerateWithInvalidParamsShouldFail) { @@ -142,9 +137,7 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithInvalidParamsShouldFail) { invalid_params, Optional())); fixture_->generator()->GenerateCertificateAsync( - invalid_params, - Optional(), - fixture_); + invalid_params, Optional(), fixture_); EXPECT_TRUE_WAIT(fixture_->GenerateAsyncCompleted(), kGenerationTimeoutMs); EXPECT_FALSE(fixture_->certificate()); } diff --git a/rtc_base/scoped_ref_ptr.h b/rtc_base/scoped_ref_ptr.h index 8fefc73031..a583aa99b5 100644 --- a/rtc_base/scoped_ref_ptr.h +++ b/rtc_base/scoped_ref_ptr.h @@ -118,8 +118,8 @@ class scoped_refptr { // AddRef first so that self assignment should work if (p) p->AddRef(); - if (ptr_ ) - ptr_ ->Release(); + if (ptr_) + ptr_->Release(); ptr_ = p; return *this; } @@ -150,9 +150,7 @@ class scoped_refptr { *pp = p; } - void swap(scoped_refptr& r) { - swap(&r.ptr_); - } + void swap(scoped_refptr& r) { swap(&r.ptr_); } protected: T* ptr_; diff --git a/rtc_base/sequenced_task_checker_unittest.cc b/rtc_base/sequenced_task_checker_unittest.cc index 9199eb7c8f..96e655baad 100644 --- a/rtc_base/sequenced_task_checker_unittest.cc +++ b/rtc_base/sequenced_task_checker_unittest.cc @@ -26,13 +26,10 @@ namespace { // attributes that are checked at compile-time. class CompileTimeTestForGuardedBy { public: - int CalledOnSequence() RTC_RUN_ON(sequence_checker_) { - return guarded_; - } + int CalledOnSequence() RTC_RUN_ON(sequence_checker_) { return guarded_; } void CallMeFromSequence() { - RTC_DCHECK_RUN_ON(&sequence_checker_) - << "Should be called on sequence"; + RTC_DCHECK_RUN_ON(&sequence_checker_) << "Should be called on sequence"; } private: @@ -40,7 +37,6 @@ class CompileTimeTestForGuardedBy { rtc::SequencedTaskChecker sequence_checker_; }; - // Calls SequencedTaskChecker::CalledSequentially on another thread. class CallCalledSequentiallyOnThread { public: diff --git a/rtc_base/signalthread.cc b/rtc_base/signalthread.cc index 48a677e378..4ab1b5c429 100644 --- a/rtc_base/signalthread.cc +++ b/rtc_base/signalthread.cc @@ -20,10 +20,7 @@ namespace rtc { /////////////////////////////////////////////////////////////////////////////// SignalThread::SignalThread() - : main_(Thread::Current()), - worker_(this), - state_(kInit), - refcount_(1) { + : main_(Thread::Current()), worker_(this), state_(kInit), refcount_(1) { main_->SignalQueueDestroyed.connect(this, &SignalThread::OnMainThreadDestroyed); worker_.SetName("SignalThread", this); @@ -94,7 +91,7 @@ bool SignalThread::ContinueWork() { return worker_.ProcessMessages(0); } -void SignalThread::OnMessage(Message *msg) { +void SignalThread::OnMessage(Message* msg) { EnterExit ee(this); if (ST_MSG_WORKER_DONE == msg->message_id) { RTC_DCHECK(main_->IsCurrent()); diff --git a/rtc_base/signalthread.h b/rtc_base/signalthread.h index 8daaa0830e..9d140c09f2 100644 --- a/rtc_base/signalthread.h +++ b/rtc_base/signalthread.h @@ -38,9 +38,7 @@ namespace rtc { // tasks in the context of the main thread. /////////////////////////////////////////////////////////////////////////////// -class SignalThread - : public sigslot::has_slots<>, - protected MessageHandler { +class SignalThread : public sigslot::has_slots<>, protected MessageHandler { public: SignalThread(); @@ -63,7 +61,7 @@ class SignalThread void Release(); // Context: Main Thread. Signalled when work is complete. - sigslot::signal1 SignalWorkDone; + sigslot::signal1 SignalWorkDone; enum { ST_MSG_WORKER_DONE, ST_MSG_FIRST_AVAILABLE }; @@ -73,7 +71,7 @@ class SignalThread Thread* worker() { return &worker_; } // Context: Main Thread. Subclass should override to do pre-work setup. - virtual void OnWorkStart() { } + virtual void OnWorkStart() {} // Context: Worker Thread. Subclass should override to do work. virtual void DoWork() = 0; @@ -84,10 +82,10 @@ class SignalThread // Context: Worker Thread. Subclass should override when extra work is // needed to abort the worker thread. - virtual void OnWorkStop() { } + virtual void OnWorkStop() {} // Context: Main Thread. Subclass should override to do post-work cleanup. - virtual void OnWorkDone() { } + virtual void OnWorkDone() {} // Context: Any Thread. If subclass overrides, be sure to call the base // implementation. Do not use (message_id < ST_MSG_FIRST_AVAILABLE) @@ -95,11 +93,11 @@ class SignalThread private: enum State { - kInit, // Initialized, but not started - kRunning, // Started and doing work - kReleasing, // Same as running, but to be deleted when work is done - kComplete, // Work is done - kStopping, // Work is being interrupted + kInit, // Initialized, but not started + kRunning, // Started and doing work + kReleasing, // Same as running, but to be deleted when work is done + kComplete, // Work is done + kStopping, // Work is being interrupted }; class Worker : public Thread { diff --git a/rtc_base/sigslot_unittest.cc b/rtc_base/sigslot_unittest.cc index 234bf4547f..114a59f8f8 100644 --- a/rtc_base/sigslot_unittest.cc +++ b/rtc_base/sigslot_unittest.cc @@ -28,33 +28,32 @@ class SigslotDefault : public testing::Test, public sigslot::has_slots<> { sigslot::signal0<> signal_; }; -template +template class SigslotReceiver : public sigslot::has_slots { public: SigslotReceiver() : signal_(nullptr), signal_count_(0) {} - ~SigslotReceiver() { - } + ~SigslotReceiver() {} // Provide copy constructor so that tests can exercise the has_slots copy // constructor. SigslotReceiver(const SigslotReceiver&) = default; void Connect(sigslot::signal0* signal) { - if (!signal) return; + if (!signal) + return; Disconnect(); signal_ = signal; signal->connect(this, &SigslotReceiver::OnSignal); } void Disconnect() { - if (!signal_) return; + if (!signal_) + return; signal_->disconnect(this); signal_ = nullptr; } - void OnSignal() { - ++signal_count_; - } + void OnSignal() { ++signal_count_; } int signal_count() { return signal_count_; } private: @@ -62,8 +61,8 @@ class SigslotReceiver : public sigslot::has_slots { int signal_count_; }; -template +template class SigslotSlotTest : public testing::Test { protected: SigslotSlotTest() { @@ -71,12 +70,8 @@ class SigslotSlotTest : public testing::Test { TemplateIsMT(&mt_policy); } - virtual void SetUp() { - Connect(); - } - virtual void TearDown() { - Disconnect(); - } + virtual void SetUp() { Connect(); } + virtual void TearDown() { Disconnect(); } void Disconnect() { st_receiver_.Disconnect(); @@ -99,12 +94,12 @@ class SigslotSlotTest : public testing::Test { typedef SigslotSlotTest<> SigslotSTSlotTest; typedef SigslotSlotTest SigslotMTSlotTest; + sigslot::multi_threaded_local> + SigslotMTSlotTest; class multi_threaded_local_fake : public sigslot::multi_threaded_local { public: - multi_threaded_local_fake() : lock_count_(0), unlock_count_(0) { - } + multi_threaded_local_fake() : lock_count_(0), unlock_count_(0) {} void lock() { ++lock_count_; } void unlock() { ++unlock_count_; } @@ -118,8 +113,8 @@ class multi_threaded_local_fake : public sigslot::multi_threaded_local { int unlock_count_; }; -typedef SigslotSlotTest SigslotMTLockBase; +typedef SigslotSlotTest + SigslotMTLockBase; class SigslotMTLockTest : public SigslotMTLockBase { protected: @@ -329,9 +324,7 @@ class Disconnector2 : public sigslot::has_slots<> { } private: - void Disconnect() { - signal_->disconnect_all(); - } + void Disconnect() { signal_->disconnect_all(); } sigslot::signal<>* signal_; }; diff --git a/rtc_base/sigslottester.h b/rtc_base/sigslottester.h old mode 100755 new mode 100644 index 04c6302eec..646ba22953 --- a/rtc_base/sigslottester.h +++ b/rtc_base/sigslottester.h @@ -18,7 +18,6 @@ // To generate sigslottester.h from sigslottester.h.pump, execute: // /home/build/google3/third_party/gtest/scripts/pump.py sigslottester.h.pump - // SigslotTester(s) are utility classes to check if signals owned by an // object are being invoked at the right time and with the right arguments. // They are meant to be used in tests. Tests must provide "capture" pointers @@ -70,10 +69,8 @@ class SigslotTester0 : public sigslot::has_slots<> { template class SigslotTester1 : public sigslot::has_slots<> { public: - SigslotTester1(sigslot::signal1* signal, - C1* capture1) - : callback_count_(0), - capture1_(capture1) { + SigslotTester1(sigslot::signal1* signal, C1* capture1) + : callback_count_(0), capture1_(capture1) { signal->connect(this, &SigslotTester1::OnSignalCallback); } @@ -94,10 +91,8 @@ class SigslotTester1 : public sigslot::has_slots<> { template class SigslotTester2 : public sigslot::has_slots<> { public: - SigslotTester2(sigslot::signal2* signal, - C1* capture1, C2* capture2) - : callback_count_(0), - capture1_(capture1), capture2_(capture2) { + SigslotTester2(sigslot::signal2* signal, C1* capture1, C2* capture2) + : callback_count_(0), capture1_(capture1), capture2_(capture2) { signal->connect(this, &SigslotTester2::OnSignalCallback); } @@ -121,9 +116,13 @@ template class SigslotTester3 : public sigslot::has_slots<> { public: SigslotTester3(sigslot::signal3* signal, - C1* capture1, C2* capture2, C3* capture3) + C1* capture1, + C2* capture2, + C3* capture3) : callback_count_(0), - capture1_(capture1), capture2_(capture2), capture3_(capture3) { + capture1_(capture1), + capture2_(capture2), + capture3_(capture3) { signal->connect(this, &SigslotTester3::OnSignalCallback); } @@ -145,15 +144,26 @@ class SigslotTester3 : public sigslot::has_slots<> { RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester3); }; -template +template class SigslotTester4 : public sigslot::has_slots<> { public: SigslotTester4(sigslot::signal4* signal, - C1* capture1, C2* capture2, C3* capture3, C4* capture4) + C1* capture1, + C2* capture2, + C3* capture3, + C4* capture4) : callback_count_(0), - capture1_(capture1), capture2_(capture2), capture3_(capture3), - capture4_(capture4) { + capture1_(capture1), + capture2_(capture2), + capture3_(capture3), + capture4_(capture4) { signal->connect(this, &SigslotTester4::OnSignalCallback); } @@ -177,16 +187,30 @@ class SigslotTester4 : public sigslot::has_slots<> { RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester4); }; -template +template class SigslotTester5 : public sigslot::has_slots<> { public: SigslotTester5(sigslot::signal5* signal, - C1* capture1, C2* capture2, C3* capture3, C4* capture4, - C5* capture5) + C1* capture1, + C2* capture2, + C3* capture3, + C4* capture4, + C5* capture5) : callback_count_(0), - capture1_(capture1), capture2_(capture2), capture3_(capture3), - capture4_(capture4), capture5_(capture5) { + capture1_(capture1), + capture2_(capture2), + capture3_(capture3), + capture4_(capture4), + capture5_(capture5) { signal->connect(this, &SigslotTester5::OnSignalCallback); } diff --git a/rtc_base/sigslottester_unittest.cc b/rtc_base/sigslottester_unittest.cc old mode 100755 new mode 100644 diff --git a/rtc_base/socket.h b/rtc_base/socket.h index 9b5ee7f76e..5950989e34 100644 --- a/rtc_base/socket.h +++ b/rtc_base/socket.h @@ -14,10 +14,10 @@ #include #if defined(WEBRTC_POSIX) -#include -#include #include #include +#include +#include #define SOCKET_EACCES EACCES #endif @@ -183,8 +183,8 @@ class Socket { virtual int Bind(const SocketAddress& addr) = 0; virtual int Connect(const SocketAddress& addr) = 0; - virtual int Send(const void *pv, size_t cb) = 0; - virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr) = 0; + virtual int Send(const void* pv, size_t cb) = 0; + virtual int SendTo(const void* pv, size_t cb, const SocketAddress& addr) = 0; // |timestamp| is in units of microseconds. virtual int Recv(void* pv, size_t cb, int64_t* timestamp) = 0; virtual int RecvFrom(void* pv, @@ -192,26 +192,22 @@ class Socket { SocketAddress* paddr, int64_t* timestamp) = 0; virtual int Listen(int backlog) = 0; - virtual Socket *Accept(SocketAddress *paddr) = 0; + virtual Socket* Accept(SocketAddress* paddr) = 0; virtual int Close() = 0; virtual int GetError() const = 0; virtual void SetError(int error) = 0; inline bool IsBlocking() const { return IsBlockingError(GetError()); } - enum ConnState { - CS_CLOSED, - CS_CONNECTING, - CS_CONNECTED - }; + enum ConnState { CS_CLOSED, CS_CONNECTING, CS_CONNECTED }; virtual ConnState GetState() const = 0; enum Option { OPT_DONTFRAGMENT, - OPT_RCVBUF, // receive buffer size - OPT_SNDBUF, // send buffer size - OPT_NODELAY, // whether Nagle algorithm is enabled - OPT_IPV6_V6ONLY, // Whether the socket is IPv6 only. - OPT_DSCP, // DSCP code + OPT_RCVBUF, // receive buffer size + OPT_SNDBUF, // send buffer size + OPT_NODELAY, // whether Nagle algorithm is enabled + OPT_IPV6_V6ONLY, // Whether the socket is IPv6 only. + OPT_DSCP, // DSCP code OPT_RTP_SENDTIME_EXTN_ID, // This is a non-traditional socket option param. // This is specific to libjingle and will be used // if SendTime option is needed at socket level. diff --git a/rtc_base/socket_unittest.cc b/rtc_base/socket_unittest.cc index be958d303c..01ef014a6f 100644 --- a/rtc_base/socket_unittest.cc +++ b/rtc_base/socket_unittest.cc @@ -291,7 +291,7 @@ void SocketTest::ConnectWithDnsLookupInternal(const IPAddress& loopback, dns_addr.SetIP(host); EXPECT_EQ(0, client->Connect(dns_addr)); // TODO: Bind when doing DNS lookup. - //EXPECT_NE(kEmptyAddr, client->GetLocalAddress()); // Implicit Bind + // EXPECT_NE(kEmptyAddr, client->GetLocalAddress()); // Implicit Bind // Client is connecting, outcome not yet determined. EXPECT_EQ(AsyncSocket::CS_CONNECTING, client->GetState()); @@ -444,9 +444,8 @@ void SocketTest::ConnectWhileNotClosedInternal(const IPAddress& loopback) { // Try to connect again, to an unresolved hostname. // Shouldn't break anything. - EXPECT_EQ(SOCKET_ERROR, - client->Connect(SocketAddress("localhost", - server->GetLocalAddress().port()))); + EXPECT_EQ(SOCKET_ERROR, client->Connect(SocketAddress( + "localhost", server->GetLocalAddress().port()))); EXPECT_EQ(AsyncSocket::CS_CONNECTED, accepted->GetState()); EXPECT_EQ(AsyncSocket::CS_CONNECTED, client->GetState()); EXPECT_EQ(client->GetRemoteAddress(), server->GetLocalAddress()); @@ -694,8 +693,9 @@ void SocketTest::SocketServerWaitInternal(const IPAddress& loopback) { EXPECT_LT(0, accepted->Recv(buf, 1024, nullptr)); } -void SocketTest::TcpInternal(const IPAddress& loopback, size_t data_size, - ptrdiff_t max_send_size) { +void SocketTest::TcpInternal(const IPAddress& loopback, + size_t data_size, + ptrdiff_t max_send_size) { StreamSink sink; SocketAddress accept_addr; @@ -792,7 +792,7 @@ void SocketTest::TcpInternal(const IPAddress& loopback, size_t data_size, } if (recved_size >= 0) { EXPECT_LE(static_cast(recved_size), - sent_size - recv_buffer.size()); + sent_size - recv_buffer.size()); recv_buffer.AppendData(recved_data.data(), recved_size); } else { ASSERT_TRUE(receiver->IsBlocking()); @@ -858,7 +858,8 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) { // Fill the socket buffer. char buf[1024 * 16] = {0}; int sends = 0; - while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) {} + while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) { + } EXPECT_TRUE(accepted->IsBlocking()); // Wait until data is available. @@ -892,8 +893,7 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) { void SocketTest::UdpInternal(const IPAddress& loopback) { SocketAddress empty = EmptySocketAddressWithFamily(loopback.family()); // Test basic bind and connect behavior. - AsyncSocket* socket = - ss_->CreateAsyncSocket(loopback.family(), SOCK_DGRAM); + AsyncSocket* socket = ss_->CreateAsyncSocket(loopback.family(), SOCK_DGRAM); EXPECT_EQ(AsyncSocket::CS_CLOSED, socket->GetState()); EXPECT_EQ(0, socket->Bind(SocketAddress(loopback, 0))); SocketAddress addr1 = socket->GetLocalAddress(); @@ -941,8 +941,8 @@ void SocketTest::UdpReadyToSend(const IPAddress& loopback) { // RFC 5737 - The blocks 192.0.2.0/24 (TEST-NET-1) ... are provided for use in // documentation. // RFC 3849 - 2001:DB8::/32 as a documentation-only prefix. - std::string dest = (loopback.family() == AF_INET6) ? - "2001:db8::1" : "192.0.2.0"; + std::string dest = + (loopback.family() == AF_INET6) ? "2001:db8::1" : "192.0.2.0"; SocketAddress test_addr(dest, 2345); // Test send diff --git a/rtc_base/socket_unittest.h b/rtc_base/socket_unittest.h index 55df219eea..db226c40d3 100644 --- a/rtc_base/socket_unittest.h +++ b/rtc_base/socket_unittest.h @@ -21,9 +21,10 @@ namespace rtc { // socketserver, and call the SocketTest test methods. class SocketTest : public testing::Test { protected: - SocketTest() : kIPv4Loopback(INADDR_LOOPBACK), - kIPv6Loopback(in6addr_loopback), - ss_(nullptr) {} + SocketTest() + : kIPv4Loopback(INADDR_LOOPBACK), + kIPv6Loopback(in6addr_loopback), + ss_(nullptr) {} void SetUp() override; void TestConnectIPv4(); void TestConnectIPv6(); @@ -65,8 +66,9 @@ class SocketTest : public testing::Test { const IPAddress kIPv6Loopback; protected: - void TcpInternal(const IPAddress& loopback, size_t data_size, - ptrdiff_t max_send_size); + void TcpInternal(const IPAddress& loopback, + size_t data_size, + ptrdiff_t max_send_size); private: void ConnectInternal(const IPAddress& loopback); diff --git a/rtc_base/socketadapters.cc b/rtc_base/socketadapters.cc index a3004951b0..8095894420 100644 --- a/rtc_base/socketadapters.cc +++ b/rtc_base/socketadapters.cc @@ -9,11 +9,11 @@ */ #if defined(_MSC_VER) && _MSC_VER < 1300 -#pragma warning(disable:4786) +#pragma warning(disable : 4786) #endif -#include #include +#include #if defined(WEBRTC_WIN) #include @@ -37,16 +37,18 @@ namespace rtc { BufferedReadAdapter::BufferedReadAdapter(AsyncSocket* socket, size_t size) - : AsyncSocketAdapter(socket), buffer_size_(size), - data_len_(0), buffering_(false) { + : AsyncSocketAdapter(socket), + buffer_size_(size), + data_len_(0), + buffering_(false) { buffer_ = new char[buffer_size_]; } BufferedReadAdapter::~BufferedReadAdapter() { - delete [] buffer_; + delete[] buffer_; } -int BufferedReadAdapter::Send(const void *pv, size_t cb) { +int BufferedReadAdapter::Send(const void* pv, size_t cb) { if (buffering_) { // TODO: Spoof error better; Signal Writeable socket_->SetError(EWOULDBLOCK); @@ -70,7 +72,7 @@ int BufferedReadAdapter::Recv(void* pv, size_t cb, int64_t* timestamp) { if (data_len_ > 0) { memmove(buffer_, buffer_ + read, data_len_); } - pv = static_cast(pv) + read; + pv = static_cast(pv) + read; cb -= read; } @@ -95,7 +97,7 @@ void BufferedReadAdapter::BufferInput(bool on) { buffering_ = on; } -void BufferedReadAdapter::OnReadEvent(AsyncSocket * socket) { +void BufferedReadAdapter::OnReadEvent(AsyncSocket* socket) { RTC_DCHECK(socket == socket_); if (!buffering_) { @@ -124,8 +126,7 @@ void BufferedReadAdapter::OnReadEvent(AsyncSocket * socket) { AsyncProxyServerSocket::AsyncProxyServerSocket(AsyncSocket* socket, size_t buffer_size) - : BufferedReadAdapter(socket, buffer_size) { -} + : BufferedReadAdapter(socket, buffer_size) {} AsyncProxyServerSocket::~AsyncProxyServerSocket() = default; @@ -172,8 +173,7 @@ static const uint8_t kSslServerHello[] = { }; AsyncSSLSocket::AsyncSSLSocket(AsyncSocket* socket) - : BufferedReadAdapter(socket, 1024) { -} + : BufferedReadAdapter(socket, 1024) {} int AsyncSSLSocket::Connect(const SocketAddress& addr) { // Begin buffering before we connect, so that there isn't a race condition @@ -182,7 +182,7 @@ int AsyncSSLSocket::Connect(const SocketAddress& addr) { return BufferedReadAdapter::Connect(addr); } -void AsyncSSLSocket::OnConnectEvent(AsyncSocket * socket) { +void AsyncSSLSocket::OnConnectEvent(AsyncSocket* socket) { RTC_DCHECK(socket == socket_); // TODO: we could buffer output too... const int res = DirectSend(kSslClientHello, sizeof(kSslClientHello)); @@ -214,7 +214,7 @@ void AsyncSSLSocket::ProcessInput(char* data, size_t* len) { } AsyncSSLServerSocket::AsyncSSLServerSocket(AsyncSocket* socket) - : BufferedReadAdapter(socket, 1024) { + : BufferedReadAdapter(socket, 1024) { BufferInput(true); } @@ -249,10 +249,14 @@ AsyncHttpsProxySocket::AsyncHttpsProxySocket(AsyncSocket* socket, const SocketAddress& proxy, const std::string& username, const CryptString& password) - : BufferedReadAdapter(socket, 1024), proxy_(proxy), agent_(user_agent), - user_(username), pass_(password), force_connect_(false), state_(PS_ERROR), - context_(0) { -} + : BufferedReadAdapter(socket, 1024), + proxy_(proxy), + agent_(user_agent), + user_(username), + pass_(password), + force_connect_(false), + state_(PS_ERROR), + context_(0) {} AsyncHttpsProxySocket::~AsyncHttpsProxySocket() { delete context_; @@ -295,7 +299,7 @@ Socket::ConnState AsyncHttpsProxySocket::GetState() const { } } -void AsyncHttpsProxySocket::OnConnectEvent(AsyncSocket * socket) { +void AsyncHttpsProxySocket::OnConnectEvent(AsyncSocket* socket) { RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket::OnConnectEvent"; if (!ShouldIssueConnect()) { state_ = PS_TUNNEL; @@ -305,7 +309,7 @@ void AsyncHttpsProxySocket::OnConnectEvent(AsyncSocket * socket) { SendRequest(); } -void AsyncHttpsProxySocket::OnCloseEvent(AsyncSocket * socket, int err) { +void AsyncHttpsProxySocket::OnCloseEvent(AsyncSocket* socket, int err) { RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket::OnCloseEvent(" << err << ")"; if ((state_ == PS_WAIT_CLOSE) && (err == 0)) { state_ = PS_ERROR; @@ -383,7 +387,7 @@ void AsyncHttpsProxySocket::SendRequest() { RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket >> " << str; } -void AsyncHttpsProxySocket::ProcessLine(char * data, size_t len) { +void AsyncHttpsProxySocket::ProcessLine(char* data, size_t len) { RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket << " << data; if (len == 0) { @@ -404,15 +408,18 @@ void AsyncHttpsProxySocket::ProcessLine(char * data, size_t len) { if (!unknown_mechanisms_.empty() && !report) { report = true; std::string msg( - "Unable to connect to the Google Talk service due to an incompatibility " - "with your proxy.\r\nPlease help us resolve this issue by submitting the " - "following information to us using our technical issue submission form " - "at:\r\n\r\n" - "http://www.google.com/support/talk/bin/request.py\r\n\r\n" - "We apologize for the inconvenience.\r\n\r\n" - "Information to submit to Google: " - ); - //std::string msg("Please report the following information to foo@bar.com:\r\nUnknown methods: "); + "Unable to connect to the Google Talk service due to an " + "incompatibility " + "with your proxy.\r\nPlease help us resolve this issue by " + "submitting the " + "following information to us using our technical issue submission " + "form " + "at:\r\n\r\n" + "http://www.google.com/support/talk/bin/request.py\r\n\r\n" + "We apologize for the inconvenience.\r\n\r\n" + "Information to submit to Google: "); + // std::string msg("Please report the following information to + // foo@bar.com:\r\nUnknown methods: "); msg.append(unknown_mechanisms_); #if defined(WEBRTC_WIN) MessageBoxA(0, msg.c_str(), "Oops!", MB_OK); @@ -433,50 +440,49 @@ void AsyncHttpsProxySocket::ProcessLine(char * data, size_t len) { return; } switch (code) { - case 200: - // connection good! - state_ = PS_TUNNEL_HEADERS; - return; + case 200: + // connection good! + state_ = PS_TUNNEL_HEADERS; + return; #if defined(HTTP_STATUS_PROXY_AUTH_REQ) && (HTTP_STATUS_PROXY_AUTH_REQ != 407) #error Wrong code for HTTP_STATUS_PROXY_AUTH_REQ #endif - case 407: // HTTP_STATUS_PROXY_AUTH_REQ - state_ = PS_AUTHENTICATE; - return; - default: - defer_error_ = 0; - state_ = PS_ERROR_HEADERS; - return; + case 407: // HTTP_STATUS_PROXY_AUTH_REQ + state_ = PS_AUTHENTICATE; + return; + default: + defer_error_ = 0; + state_ = PS_ERROR_HEADERS; + return; } - } else if ((state_ == PS_AUTHENTICATE) - && (_strnicmp(data, "Proxy-Authenticate:", 19) == 0)) { + } else if ((state_ == PS_AUTHENTICATE) && + (_strnicmp(data, "Proxy-Authenticate:", 19) == 0)) { std::string response, auth_method; - switch (HttpAuthenticate(data + 19, len - 19, - proxy_, "CONNECT", "/", - user_, pass_, context_, response, auth_method)) { - case HAR_IGNORE: - RTC_LOG(LS_VERBOSE) << "Ignoring Proxy-Authenticate: " << auth_method; - if (!unknown_mechanisms_.empty()) - unknown_mechanisms_.append(", "); - unknown_mechanisms_.append(auth_method); - break; - case HAR_RESPONSE: - headers_ = "Proxy-Authorization: "; - headers_.append(response); - headers_.append("\r\n"); - state_ = PS_SKIP_HEADERS; - unknown_mechanisms_.clear(); - break; - case HAR_CREDENTIALS: - defer_error_ = SOCKET_EACCES; - state_ = PS_ERROR_HEADERS; - unknown_mechanisms_.clear(); - break; - case HAR_ERROR: - defer_error_ = 0; - state_ = PS_ERROR_HEADERS; - unknown_mechanisms_.clear(); - break; + switch (HttpAuthenticate(data + 19, len - 19, proxy_, "CONNECT", "/", user_, + pass_, context_, response, auth_method)) { + case HAR_IGNORE: + RTC_LOG(LS_VERBOSE) << "Ignoring Proxy-Authenticate: " << auth_method; + if (!unknown_mechanisms_.empty()) + unknown_mechanisms_.append(", "); + unknown_mechanisms_.append(auth_method); + break; + case HAR_RESPONSE: + headers_ = "Proxy-Authorization: "; + headers_.append(response); + headers_.append("\r\n"); + state_ = PS_SKIP_HEADERS; + unknown_mechanisms_.clear(); + break; + case HAR_CREDENTIALS: + defer_error_ = SOCKET_EACCES; + state_ = PS_ERROR_HEADERS; + unknown_mechanisms_.clear(); + break; + case HAR_ERROR: + defer_error_ = 0; + state_ = PS_ERROR_HEADERS; + unknown_mechanisms_.clear(); + break; } } else if (_strnicmp(data, "Content-Length:", 15) == 0) { content_length_ = strtoul(data + 15, 0, 0); @@ -515,9 +521,11 @@ AsyncSocksProxySocket::AsyncSocksProxySocket(AsyncSocket* socket, const SocketAddress& proxy, const std::string& username, const CryptString& password) - : BufferedReadAdapter(socket, 1024), state_(SS_ERROR), proxy_(proxy), - user_(username), pass_(password) { -} + : BufferedReadAdapter(socket, 1024), + state_(SS_ERROR), + proxy_(proxy), + user_(username), + pass_(password) {} AsyncSocksProxySocket::~AsyncSocksProxySocket() = default; @@ -562,8 +570,7 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { if (state_ == SS_HELLO) { uint8_t ver, method; - if (!response.ReadUInt8(&ver) || - !response.ReadUInt8(&method)) + if (!response.ReadUInt8(&ver) || !response.ReadUInt8(&method)) return; if (ver != 5) { @@ -581,8 +588,7 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { } } else if (state_ == SS_AUTH) { uint8_t ver, status; - if (!response.ReadUInt8(&ver) || - !response.ReadUInt8(&status)) + if (!response.ReadUInt8(&ver) || !response.ReadUInt8(&status)) return; if ((ver != 1) || (status != 0)) { @@ -593,10 +599,8 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { SendConnect(); } else if (state_ == SS_CONNECT) { uint8_t ver, rep, rsv, atyp; - if (!response.ReadUInt8(&ver) || - !response.ReadUInt8(&rep) || - !response.ReadUInt8(&rsv) || - !response.ReadUInt8(&atyp)) + if (!response.ReadUInt8(&ver) || !response.ReadUInt8(&rep) || + !response.ReadUInt8(&rsv) || !response.ReadUInt8(&atyp)) return; if ((ver != 5) || (rep != 0)) { @@ -607,22 +611,19 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { uint16_t port; if (atyp == 1) { uint32_t addr; - if (!response.ReadUInt32(&addr) || - !response.ReadUInt16(&port)) + if (!response.ReadUInt32(&addr) || !response.ReadUInt16(&port)) return; RTC_LOG(LS_VERBOSE) << "Bound on " << addr << ":" << port; } else if (atyp == 3) { uint8_t len; std::string addr; - if (!response.ReadUInt8(&len) || - !response.ReadString(&addr, len) || + if (!response.ReadUInt8(&len) || !response.ReadString(&addr, len) || !response.ReadUInt16(&port)) return; RTC_LOG(LS_VERBOSE) << "Bound on " << addr << ":" << port; } else if (atyp == 4) { std::string addr; - if (!response.ReadString(&addr, 16) || - !response.ReadUInt16(&port)) + if (!response.ReadString(&addr, 16) || !response.ReadUInt16(&port)) return; RTC_LOG(LS_VERBOSE) << "Bound on :" << port; } else { @@ -651,7 +652,7 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { void AsyncSocksProxySocket::SendHello() { ByteBufferWriter request; - request.WriteUInt8(5); // Socks Version + request.WriteUInt8(5); // Socks Version if (user_.empty()) { request.WriteUInt8(1); // Authentication Mechanisms request.WriteUInt8(0); // No authentication @@ -666,30 +667,30 @@ void AsyncSocksProxySocket::SendHello() { void AsyncSocksProxySocket::SendAuth() { ByteBufferWriterT> request; - request.WriteUInt8(1); // Negotiation Version + request.WriteUInt8(1); // Negotiation Version request.WriteUInt8(static_cast(user_.size())); - request.WriteString(user_); // Username + request.WriteString(user_); // Username request.WriteUInt8(static_cast(pass_.GetLength())); size_t len = pass_.GetLength() + 1; - char * sensitive = new char[len]; + char* sensitive = new char[len]; pass_.CopyTo(sensitive, true); request.WriteBytes(sensitive, pass_.GetLength()); // Password ExplicitZeroMemory(sensitive, len); - delete [] sensitive; + delete[] sensitive; DirectSend(request.Data(), request.Length()); state_ = SS_AUTH; } void AsyncSocksProxySocket::SendConnect() { ByteBufferWriter request; - request.WriteUInt8(5); // Socks Version - request.WriteUInt8(1); // CONNECT - request.WriteUInt8(0); // Reserved + request.WriteUInt8(5); // Socks Version + request.WriteUInt8(1); // CONNECT + request.WriteUInt8(0); // Reserved if (dest_.IsUnresolvedIP()) { std::string hostname = dest_.hostname(); - request.WriteUInt8(3); // DOMAINNAME + request.WriteUInt8(3); // DOMAINNAME request.WriteUInt8(static_cast(hostname.size())); - request.WriteString(hostname); // Destination Hostname + request.WriteString(hostname); // Destination Hostname } else { request.WriteUInt8(1); // IPV4 request.WriteUInt32(dest_.ip()); // Destination IP @@ -736,8 +737,7 @@ void AsyncSocksProxyServerSocket::DirectSend(const ByteBufferWriter& buf) { void AsyncSocksProxyServerSocket::HandleHello(ByteBufferReader* request) { uint8_t ver, num_methods; - if (!request->ReadUInt8(&ver) || - !request->ReadUInt8(&num_methods)) { + if (!request->ReadUInt8(&ver) || !request->ReadUInt8(&num_methods)) { Error(0); return; } @@ -767,7 +767,7 @@ void AsyncSocksProxyServerSocket::HandleHello(ByteBufferReader* request) { void AsyncSocksProxyServerSocket::SendHelloReply(uint8_t method) { ByteBufferWriter response; - response.WriteUInt8(5); // Socks Version + response.WriteUInt8(5); // Socks Version response.WriteUInt8(method); // Auth method DirectSend(response); } @@ -775,10 +775,8 @@ void AsyncSocksProxyServerSocket::SendHelloReply(uint8_t method) { void AsyncSocksProxyServerSocket::HandleAuth(ByteBufferReader* request) { uint8_t ver, user_len, pass_len; std::string user, pass; - if (!request->ReadUInt8(&ver) || - !request->ReadUInt8(&user_len) || - !request->ReadString(&user, user_len) || - !request->ReadUInt8(&pass_len) || + if (!request->ReadUInt8(&ver) || !request->ReadUInt8(&user_len) || + !request->ReadString(&user, user_len) || !request->ReadUInt8(&pass_len) || !request->ReadString(&pass, pass_len)) { Error(0); return; @@ -800,20 +798,16 @@ void AsyncSocksProxyServerSocket::HandleConnect(ByteBufferReader* request) { uint8_t ver, command, reserved, addr_type; uint32_t ip; uint16_t port; - if (!request->ReadUInt8(&ver) || - !request->ReadUInt8(&command) || - !request->ReadUInt8(&reserved) || - !request->ReadUInt8(&addr_type) || - !request->ReadUInt32(&ip) || - !request->ReadUInt16(&port)) { - Error(0); - return; + if (!request->ReadUInt8(&ver) || !request->ReadUInt8(&command) || + !request->ReadUInt8(&reserved) || !request->ReadUInt8(&addr_type) || + !request->ReadUInt32(&ip) || !request->ReadUInt16(&port)) { + Error(0); + return; } - if (ver != 5 || command != 1 || - reserved != 0 || addr_type != 1) { - Error(0); - return; + if (ver != 5 || command != 1 || reserved != 0 || addr_type != 1) { + Error(0); + return; } SignalConnectRequest(this, SocketAddress(ip, port)); @@ -826,10 +820,10 @@ void AsyncSocksProxyServerSocket::SendConnectResult(int result, return; ByteBufferWriter response; - response.WriteUInt8(5); // Socks version + response.WriteUInt8(5); // Socks version response.WriteUInt8((result != 0)); // 0x01 is generic error - response.WriteUInt8(0); // reserved - response.WriteUInt8(1); // IPv4 address + response.WriteUInt8(0); // reserved + response.WriteUInt8(1); // IPv4 address response.WriteUInt32(addr.ip()); response.WriteUInt16(addr.port()); DirectSend(response); diff --git a/rtc_base/socketadapters.h b/rtc_base/socketadapters.h index c5d1bfcabb..ad88fe6b6f 100644 --- a/rtc_base/socketadapters.h +++ b/rtc_base/socketadapters.h @@ -49,7 +49,7 @@ class BufferedReadAdapter : public AsyncSocketAdapter { void OnReadEvent(AsyncSocket* socket) override; private: - char * buffer_; + char* buffer_; size_t buffer_size_, data_len_; bool buffering_; RTC_DISALLOW_COPY_AND_ASSIGN(BufferedReadAdapter); @@ -62,8 +62,8 @@ class AsyncProxyServerSocket : public BufferedReadAdapter { public: AsyncProxyServerSocket(AsyncSocket* socket, size_t buffer_size); ~AsyncProxyServerSocket() override; - sigslot::signal2 SignalConnectRequest; + sigslot::signal2 + SignalConnectRequest; virtual void SendConnectResult(int err, const SocketAddress& addr) = 0; }; @@ -99,9 +99,11 @@ class AsyncSSLServerSocket : public BufferedReadAdapter { // Implements a socket adapter that speaks the HTTP/S proxy protocol. class AsyncHttpsProxySocket : public BufferedReadAdapter { public: - AsyncHttpsProxySocket(AsyncSocket* socket, const std::string& user_agent, - const SocketAddress& proxy, - const std::string& username, const CryptString& password); + AsyncHttpsProxySocket(AsyncSocket* socket, + const std::string& user_agent, + const SocketAddress& proxy, + const std::string& username, + const CryptString& password); ~AsyncHttpsProxySocket() override; // If connect is forced, the adapter will always issue an HTTP CONNECT to the @@ -134,10 +136,18 @@ class AsyncHttpsProxySocket : public BufferedReadAdapter { int defer_error_; bool expect_close_; enum ProxyState { - PS_INIT, PS_LEADER, PS_AUTHENTICATE, PS_SKIP_HEADERS, PS_ERROR_HEADERS, - PS_TUNNEL_HEADERS, PS_SKIP_BODY, PS_TUNNEL, PS_WAIT_CLOSE, PS_ERROR + PS_INIT, + PS_LEADER, + PS_AUTHENTICATE, + PS_SKIP_HEADERS, + PS_ERROR_HEADERS, + PS_TUNNEL_HEADERS, + PS_SKIP_BODY, + PS_TUNNEL, + PS_WAIT_CLOSE, + PS_ERROR } state_; - HttpAuthContext * context_; + HttpAuthContext* context_; std::string unknown_mechanisms_; RTC_DISALLOW_COPY_AND_ASSIGN(AsyncHttpsProxySocket); }; @@ -147,8 +157,10 @@ class AsyncHttpsProxySocket : public BufferedReadAdapter { // Implements a socket adapter that speaks the SOCKS proxy protocol. class AsyncSocksProxySocket : public BufferedReadAdapter { public: - AsyncSocksProxySocket(AsyncSocket* socket, const SocketAddress& proxy, - const std::string& username, const CryptString& password); + AsyncSocksProxySocket(AsyncSocket* socket, + const SocketAddress& proxy, + const std::string& username, + const CryptString& password); ~AsyncSocksProxySocket() override; int Connect(const SocketAddress& addr) override; @@ -166,9 +178,7 @@ class AsyncSocksProxySocket : public BufferedReadAdapter { void Error(int error); private: - enum State { - SS_INIT, SS_HELLO, SS_AUTH, SS_CONNECT, SS_TUNNEL, SS_ERROR - }; + enum State { SS_INIT, SS_HELLO, SS_AUTH, SS_CONNECT, SS_TUNNEL, SS_ERROR }; State state_; SocketAddress proxy_, dest_; std::string user_; @@ -196,7 +206,12 @@ class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { static const int kBufferSize = 1024; enum State { - SS_HELLO, SS_AUTH, SS_CONNECT, SS_CONNECT_PENDING, SS_TUNNEL, SS_ERROR + SS_HELLO, + SS_AUTH, + SS_CONNECT, + SS_CONNECT_PENDING, + SS_TUNNEL, + SS_ERROR }; State state_; RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxyServerSocket); diff --git a/rtc_base/socketaddress.cc b/rtc_base/socketaddress.cc index a58c001d32..c91846d1ba 100644 --- a/rtc_base/socketaddress.cc +++ b/rtc_base/socketaddress.cc @@ -12,9 +12,9 @@ #include "rtc_base/numerics/safe_conversions.h" #if defined(WEBRTC_POSIX) -#include -#include #include +#include +#include #if defined(OPENBSD) #include #endif @@ -204,8 +204,8 @@ bool SocketAddress::IsAnyIP() const { } bool SocketAddress::IsLoopbackIP() const { - return IPIsLoopback(ip_) || (IPIsAny(ip_) && - 0 == strcmp(hostname_.c_str(), "localhost")); + return IPIsLoopback(ip_) || + (IPIsAny(ip_) && 0 == strcmp(hostname_.c_str(), "localhost")); } bool SocketAddress::IsPrivateIP() const { @@ -234,7 +234,7 @@ bool SocketAddress::operator<(const SocketAddress& addr) const { bool SocketAddress::EqualIPs(const SocketAddress& addr) const { return (ip_ == addr.ip_) && - ((!IPIsAny(ip_) && !IPIsUnspec(ip_)) || (hostname_ == addr.hostname_)); + ((!IPIsAny(ip_) && !IPIsUnspec(ip_)) || (hostname_ == addr.hostname_)); } bool SocketAddress::EqualPorts(const SocketAddress& addr) const { @@ -293,7 +293,7 @@ static size_t ToSockAddrStorageHelper(sockaddr_storage* addr, return 0; } -size_t SocketAddress::ToDualStackSockAddrStorage(sockaddr_storage *addr) const { +size_t SocketAddress::ToDualStackSockAddrStorage(sockaddr_storage* addr) const { return ToSockAddrStorageHelper(addr, ip_.AsIPv6Address(), port_, scope_id_); } diff --git a/rtc_base/socketaddress.h b/rtc_base/socketaddress.h index f221f9b142..7095be189d 100644 --- a/rtc_base/socketaddress.h +++ b/rtc_base/socketaddress.h @@ -94,7 +94,7 @@ class SocketAddress { const IPAddress& ipaddr() const; - int family() const {return ip_.family(); } + int family() const { return ip_.family(); } // Returns the port part of this address. uint16_t port() const; @@ -104,7 +104,7 @@ class SocketAddress { // interfaces having different scope-ids for their link-local addresses. // IPv4 address do not have scope_ids and sockaddr_in structures do not have // a field for them. - int scope_id() const {return scope_id_; } + int scope_id() const { return scope_id_; } void SetScopeID(int id) { scope_id_ = id; } // Returns the 'host' portion of the address (hostname or IP) in a form @@ -154,13 +154,13 @@ class SocketAddress { bool IsUnresolvedIP() const; // Determines whether this address is identical to the given one. - bool operator ==(const SocketAddress& addr) const; - inline bool operator !=(const SocketAddress& addr) const { - return !this->operator ==(addr); + bool operator==(const SocketAddress& addr) const; + inline bool operator!=(const SocketAddress& addr) const { + return !this->operator==(addr); } // Compares based on IP and then port. - bool operator <(const SocketAddress& addr) const; + bool operator<(const SocketAddress& addr) const; // Determines whether this address has the same IP as the one given. bool EqualIPs(const SocketAddress& addr) const; diff --git a/rtc_base/socketaddress_unittest.cc b/rtc_base/socketaddress_unittest.cc index fb195b6cc1..b7a2d92d31 100644 --- a/rtc_base/socketaddress_unittest.cc +++ b/rtc_base/socketaddress_unittest.cc @@ -18,14 +18,12 @@ namespace rtc { -const in6_addr kTestV6Addr = { { {0x20, 0x01, 0x0d, 0xb8, - 0x10, 0x20, 0x30, 0x40, - 0x50, 0x60, 0x70, 0x80, - 0x90, 0xA0, 0xB0, 0xC0} } }; -const in6_addr kMappedV4Addr = { { {0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0xFF, - 0x01, 0x02, 0x03, 0x04} } }; +const in6_addr kTestV6Addr = { + {{0x20, 0x01, 0x0d, 0xb8, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, + 0x90, 0xA0, 0xB0, 0xC0}}}; +const in6_addr kMappedV4Addr = { + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0x01, 0x02, 0x03, 0x04}}}; const std::string kTestV6AddrString = "2001:db8:1020:3040:5060:7080:90a0:b0c0"; const std::string kTestV6AddrAnonymizedString = "2001:db8:1020:x:x:x:x:x"; const std::string kTestV6AddrFullString = @@ -240,16 +238,14 @@ TEST(SocketAddressTest, TestToFromSockAddrStorage) { EXPECT_FALSE(SocketAddressFromSockAddrStorage(addr_storage, nullptr)); } -bool AreEqual(const SocketAddress& addr1, - const SocketAddress& addr2) { - return addr1 == addr2 && addr2 == addr1 && - !(addr1 != addr2) && !(addr2 != addr1); +bool AreEqual(const SocketAddress& addr1, const SocketAddress& addr2) { + return addr1 == addr2 && addr2 == addr1 && !(addr1 != addr2) && + !(addr2 != addr1); } -bool AreUnequal(const SocketAddress& addr1, - const SocketAddress& addr2) { - return !(addr1 == addr2) && !(addr2 == addr1) && - addr1 != addr2 && addr2 != addr1; +bool AreUnequal(const SocketAddress& addr1, const SocketAddress& addr2) { + return !(addr1 == addr2) && !(addr2 == addr1) && addr1 != addr2 && + addr2 != addr1; } TEST(SocketAddressTest, TestEqualityOperators) { @@ -286,9 +282,7 @@ TEST(SocketAddressTest, TestEqualityOperators) { } bool IsLessThan(const SocketAddress& addr1, const SocketAddress& addr2) { - return addr1 < addr2 && - !(addr2 < addr1) && - !(addr1 == addr2); + return addr1 < addr2 && !(addr2 < addr1) && !(addr1 == addr2); } TEST(SocketAddressTest, TestComparisonOperator) { diff --git a/rtc_base/socketaddresspair.cc b/rtc_base/socketaddresspair.cc index 3e4748f421..914ffd9916 100644 --- a/rtc_base/socketaddresspair.cc +++ b/rtc_base/socketaddresspair.cc @@ -12,17 +12,15 @@ namespace rtc { -SocketAddressPair::SocketAddressPair( - const SocketAddress& src, const SocketAddress& dest) - : src_(src), dest_(dest) { -} +SocketAddressPair::SocketAddressPair(const SocketAddress& src, + const SocketAddress& dest) + : src_(src), dest_(dest) {} - -bool SocketAddressPair::operator ==(const SocketAddressPair& p) const { +bool SocketAddressPair::operator==(const SocketAddressPair& p) const { return (src_ == p.src_) && (dest_ == p.dest_); } -bool SocketAddressPair::operator <(const SocketAddressPair& p) const { +bool SocketAddressPair::operator<(const SocketAddressPair& p) const { if (src_ < p.src_) return true; if (p.src_ < src_) @@ -38,4 +36,4 @@ size_t SocketAddressPair::Hash() const { return src_.Hash() ^ dest_.Hash(); } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/socketaddresspair.h b/rtc_base/socketaddresspair.h index 8ff0ee6c48..5ff148a75d 100644 --- a/rtc_base/socketaddresspair.h +++ b/rtc_base/socketaddresspair.h @@ -19,23 +19,23 @@ namespace rtc { // identify a connection between two machines. (For UDP, this "connection" is // not maintained explicitly in a socket.) class SocketAddressPair { -public: + public: SocketAddressPair() {} SocketAddressPair(const SocketAddress& srs, const SocketAddress& dest); const SocketAddress& source() const { return src_; } const SocketAddress& destination() const { return dest_; } - bool operator ==(const SocketAddressPair& r) const; - bool operator <(const SocketAddressPair& r) const; + bool operator==(const SocketAddressPair& r) const; + bool operator<(const SocketAddressPair& r) const; size_t Hash() const; -private: + private: SocketAddress src_; SocketAddress dest_; }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_SOCKETADDRESSPAIR_H_ +#endif // RTC_BASE_SOCKETADDRESSPAIR_H_ diff --git a/rtc_base/socketfactory.h b/rtc_base/socketfactory.h index f656e5b4d5..5a5cd04333 100644 --- a/rtc_base/socketfactory.h +++ b/rtc_base/socketfactory.h @@ -17,7 +17,7 @@ namespace rtc { class SocketFactory { -public: + public: virtual ~SocketFactory() {} // Returns a new socket for blocking communication. The type can be @@ -28,6 +28,6 @@ public: virtual AsyncSocket* CreateAsyncSocket(int family, int type) = 0; }; -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_SOCKETFACTORY_H_ +#endif // RTC_BASE_SOCKETFACTORY_H_ diff --git a/rtc_base/socketstream.cc b/rtc_base/socketstream.cc index 8b4c513ea8..2ea1cec0ac 100644 --- a/rtc_base/socketstream.cc +++ b/rtc_base/socketstream.cc @@ -28,9 +28,9 @@ void SocketStream::Attach(AsyncSocket* socket) { socket_ = socket; if (socket_) { socket_->SignalConnectEvent.connect(this, &SocketStream::OnConnectEvent); - socket_->SignalReadEvent.connect(this, &SocketStream::OnReadEvent); - socket_->SignalWriteEvent.connect(this, &SocketStream::OnWriteEvent); - socket_->SignalCloseEvent.connect(this, &SocketStream::OnCloseEvent); + socket_->SignalReadEvent.connect(this, &SocketStream::OnReadEvent); + socket_->SignalWriteEvent.connect(this, &SocketStream::OnWriteEvent); + socket_->SignalCloseEvent.connect(this, &SocketStream::OnCloseEvent); } } @@ -59,8 +59,10 @@ StreamState SocketStream::GetState() const { } } -StreamResult SocketStream::Read(void* buffer, size_t buffer_len, - size_t* read, int* error) { +StreamResult SocketStream::Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { RTC_DCHECK(socket_ != nullptr); int result = socket_->Recv(buffer, buffer_len, nullptr); if (result < 0) { @@ -78,8 +80,10 @@ StreamResult SocketStream::Read(void* buffer, size_t buffer_len, return SR_EOS; } -StreamResult SocketStream::Write(const void* data, size_t data_len, - size_t* written, int* error) { +StreamResult SocketStream::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { RTC_DCHECK(socket_ != nullptr); int result = socket_->Send(data, data_len); if (result < 0) { @@ -119,5 +123,4 @@ void SocketStream::OnCloseEvent(AsyncSocket* socket, int err) { SignalEvent(this, SE_CLOSE, err); } - } // namespace rtc diff --git a/rtc_base/ssladapter_unittest.cc b/rtc_base/ssladapter_unittest.cc index 1bb979ec90..0fdb1bcec9 100644 --- a/rtc_base/ssladapter_unittest.cc +++ b/rtc_base/ssladapter_unittest.cc @@ -32,10 +32,10 @@ static const int kTimeout = 5000; static rtc::AsyncSocket* CreateSocket(const rtc::SSLMode& ssl_mode) { rtc::SocketAddress address(rtc::IPAddress(INADDR_ANY), 0); - rtc::AsyncSocket* socket = rtc::Thread::Current()-> - socketserver()->CreateAsyncSocket( - address.family(), (ssl_mode == rtc::SSL_MODE_DTLS) ? - SOCK_DGRAM : SOCK_STREAM); + rtc::AsyncSocket* socket = + rtc::Thread::Current()->socketserver()->CreateAsyncSocket( + address.family(), + (ssl_mode == rtc::SSL_MODE_DTLS) ? SOCK_DGRAM : SOCK_STREAM); socket->Bind(address); return socket; @@ -69,10 +69,10 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> { // NEVER USE THIS IN PRODUCTION CODE! ssl_adapter_->SetIgnoreBadCert(true); - ssl_adapter_->SignalReadEvent.connect(this, - &SSLAdapterTestDummyClient::OnSSLAdapterReadEvent); - ssl_adapter_->SignalCloseEvent.connect(this, - &SSLAdapterTestDummyClient::OnSSLAdapterCloseEvent); + ssl_adapter_->SignalReadEvent.connect( + this, &SSLAdapterTestDummyClient::OnSSLAdapterReadEvent); + ssl_adapter_->SignalCloseEvent.connect( + this, &SSLAdapterTestDummyClient::OnSSLAdapterCloseEvent); } void SetIgnoreBadCert(bool ignore_bad_cert) { @@ -99,9 +99,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> { return ssl_adapter_->GetState(); } - const std::string& GetReceivedData() const { - return data_; - } + const std::string& GetReceivedData() const { return data_; } int Connect(const std::string& hostname, const rtc::SocketAddress& address) { RTC_LOG(LS_INFO) << "Initiating connection with " << address.ToString(); @@ -120,9 +118,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> { return rv; } - int Close() { - return ssl_adapter_->Close(); - } + int Close() { return ssl_adapter_->Close(); } int Send(const std::string& message) { RTC_LOG(LS_INFO) << "Client sending '" << message << "'"; @@ -172,8 +168,8 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> { server_socket_.reset(CreateSocket(ssl_mode_)); if (ssl_mode_ == rtc::SSL_MODE_TLS) { - server_socket_->SignalReadEvent.connect(this, - &SSLAdapterTestDummyServer::OnServerSocketReadEvent); + server_socket_->SignalReadEvent.connect( + this, &SSLAdapterTestDummyServer::OnServerSocketReadEvent); server_socket_->Listen(1); } @@ -193,9 +189,7 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> { return "example.com"; } - const std::string& GetReceivedData() const { - return data_; - } + const std::string& GetReceivedData() const { return data_; } int Send(const std::string& message) { if (ssl_stream_adapter_ == nullptr || @@ -209,8 +203,8 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> { size_t written; int error; - rtc::StreamResult r = ssl_stream_adapter_->Write(message.data(), - message.length(), &written, &error); + rtc::StreamResult r = ssl_stream_adapter_->Write( + message.data(), message.length(), &written, &error); if (r == rtc::SR_SUCCESS) { return written; } else { @@ -280,12 +274,12 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> { unsigned char digest[20]; size_t digest_len = sizeof(digest); ssl_stream_adapter_->SetPeerCertificateDigest(rtc::DIGEST_SHA_1, digest, - digest_len); + digest_len); ssl_stream_adapter_->StartSSL(); - ssl_stream_adapter_->SignalEvent.connect(this, - &SSLAdapterTestDummyServer::OnSSLStreamAdapterEvent); + ssl_stream_adapter_->SignalEvent.connect( + this, &SSLAdapterTestDummyServer::OnSSLStreamAdapterEvent); } const rtc::SSLMode ssl_mode_; @@ -298,8 +292,7 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> { std::string data_; }; -class SSLAdapterTestBase : public testing::Test, - public sigslot::has_slots<> { +class SSLAdapterTestBase : public testing::Test, public sigslot::has_slots<> { public: explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode, const rtc::KeyParams& key_params) @@ -310,9 +303,7 @@ class SSLAdapterTestBase : public testing::Test, client_(new SSLAdapterTestDummyClient(ssl_mode_)), handshake_wait_(kTimeout) {} - void SetHandshakeWait(int wait) { - handshake_wait_ = wait; - } + void SetHandshakeWait(int wait) { handshake_wait_ = wait; } void SetIgnoreBadCert(bool ignore_bad_cert) { client_->SetIgnoreBadCert(ignore_bad_cert); @@ -361,7 +352,7 @@ class SSLAdapterTestBase : public testing::Test, // If expecting success, the client should end up in the CS_CONNECTED // state after handshake. EXPECT_EQ_WAIT(rtc::AsyncSocket::CS_CONNECTED, client_->GetState(), - handshake_wait_); + handshake_wait_); RTC_LOG(LS_INFO) << GetSSLProtocolName(ssl_mode_) << " handshake complete."; @@ -369,7 +360,7 @@ class SSLAdapterTestBase : public testing::Test, } else { // On handshake failure the client should end up in the CS_CLOSED state. EXPECT_EQ_WAIT(rtc::AsyncSocket::CS_CLOSED, client_->GetState(), - handshake_wait_); + handshake_wait_); RTC_LOG(LS_INFO) << GetSSLProtocolName(ssl_mode_) << " handshake failed."; } diff --git a/rtc_base/sslfingerprint.cc b/rtc_base/sslfingerprint.cc index dda46f18bc..b651a3d628 100644 --- a/rtc_base/sslfingerprint.cc +++ b/rtc_base/sslfingerprint.cc @@ -20,8 +20,8 @@ namespace rtc { -SSLFingerprint* SSLFingerprint::Create( - const std::string& algorithm, const rtc::SSLIdentity* identity) { +SSLFingerprint* SSLFingerprint::Create(const std::string& algorithm, + const rtc::SSLIdentity* identity) { if (!identity) { return nullptr; } @@ -29,12 +29,12 @@ SSLFingerprint* SSLFingerprint::Create( return Create(algorithm, &(identity->certificate())); } -SSLFingerprint* SSLFingerprint::Create( - const std::string& algorithm, const rtc::SSLCertificate* cert) { +SSLFingerprint* SSLFingerprint::Create(const std::string& algorithm, + const rtc::SSLCertificate* cert) { uint8_t digest_val[64]; size_t digest_len; - bool ret = cert->ComputeDigest( - algorithm, digest_val, sizeof(digest_val), &digest_len); + bool ret = cert->ComputeDigest(algorithm, digest_val, sizeof(digest_val), + &digest_len); if (!ret) { return nullptr; } @@ -43,7 +43,8 @@ SSLFingerprint* SSLFingerprint::Create( } SSLFingerprint* SSLFingerprint::CreateFromRfc4572( - const std::string& algorithm, const std::string& fingerprint) { + const std::string& algorithm, + const std::string& fingerprint) { if (algorithm.empty() || !rtc::IsFips180DigestAlgorithm(algorithm)) return nullptr; @@ -52,10 +53,8 @@ SSLFingerprint* SSLFingerprint::CreateFromRfc4572( size_t value_len; char value[rtc::MessageDigest::kMaxSize]; - value_len = rtc::hex_decode_with_delimiter(value, sizeof(value), - fingerprint.c_str(), - fingerprint.length(), - ':'); + value_len = rtc::hex_decode_with_delimiter( + value, sizeof(value), fingerprint.c_str(), fingerprint.length(), ':'); if (!value_len) return nullptr; @@ -91,15 +90,14 @@ SSLFingerprint::SSLFingerprint(const SSLFingerprint& from) : algorithm(from.algorithm), digest(from.digest) {} bool SSLFingerprint::operator==(const SSLFingerprint& other) const { - return algorithm == other.algorithm && - digest == other.digest; + return algorithm == other.algorithm && digest == other.digest; } std::string SSLFingerprint::GetRfc4572Fingerprint() const { std::string fingerprint = rtc::hex_encode_with_delimiter(digest.data(), digest.size(), ':'); - std::transform(fingerprint.begin(), fingerprint.end(), - fingerprint.begin(), ::toupper); + std::transform(fingerprint.begin(), fingerprint.end(), fingerprint.begin(), + ::toupper); return fingerprint; } diff --git a/rtc_base/sslidentity.cc b/rtc_base/sslidentity.cc index 0fab22363d..ca4cd1ce4f 100644 --- a/rtc_base/sslidentity.cc +++ b/rtc_base/sslidentity.cc @@ -108,9 +108,8 @@ bool SSLIdentity::PemToDer(const std::string& pem_type, std::string inner = pem_string.substr(body + 1, trailer - (body + 1)); - *der = Base64::Decode(inner, Base64::DO_PARSE_WHITE | - Base64::DO_PAD_ANY | - Base64::DO_TERM_BUFFER); + *der = Base64::Decode(inner, Base64::DO_PARSE_WHITE | Base64::DO_PAD_ANY | + Base64::DO_TERM_BUFFER); return true; } diff --git a/rtc_base/sslidentity_unittest.cc b/rtc_base/sslidentity_unittest.cc index e1dbe05858..132e240c2f 100644 --- a/rtc_base/sslidentity_unittest.cc +++ b/rtc_base/sslidentity_unittest.cc @@ -21,7 +21,8 @@ using rtc::SSLIdentity; -const char kTestCertificate[] = "-----BEGIN CERTIFICATE-----\n" +const char kTestCertificate[] = + "-----BEGIN CERTIFICATE-----\n" "MIIB6TCCAVICAQYwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV\n" "BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD\n" "VQQDExJUZXN0IENBICgxMDI0IGJpdCkwHhcNMDAxMDE2MjIzMTAzWhcNMDMwMTE0\n" @@ -35,36 +36,29 @@ const char kTestCertificate[] = "-----BEGIN CERTIFICATE-----\n" "itAE+OjGF+PFKbwX8Q==\n" "-----END CERTIFICATE-----\n"; -const unsigned char kTestCertSha1[] = { - 0xA6, 0xC8, 0x59, 0xEA, 0xC3, 0x7E, 0x6D, 0x33, - 0xCF, 0xE2, 0x69, 0x9D, 0x74, 0xE6, 0xF6, 0x8A, - 0x9E, 0x47, 0xA7, 0xCA}; +const unsigned char kTestCertSha1[] = {0xA6, 0xC8, 0x59, 0xEA, 0xC3, 0x7E, 0x6D, + 0x33, 0xCF, 0xE2, 0x69, 0x9D, 0x74, 0xE6, + 0xF6, 0x8A, 0x9E, 0x47, 0xA7, 0xCA}; const unsigned char kTestCertSha224[] = { - 0xd4, 0xce, 0xc6, 0xcf, 0x28, 0xcb, 0xe9, 0x77, - 0x38, 0x36, 0xcf, 0xb1, 0x3b, 0x4a, 0xd7, 0xbd, - 0xae, 0x24, 0x21, 0x08, 0xcf, 0x6a, 0x44, 0x0d, - 0x3f, 0x94, 0x2a, 0x5b}; + 0xd4, 0xce, 0xc6, 0xcf, 0x28, 0xcb, 0xe9, 0x77, 0x38, 0x36, + 0xcf, 0xb1, 0x3b, 0x4a, 0xd7, 0xbd, 0xae, 0x24, 0x21, 0x08, + 0xcf, 0x6a, 0x44, 0x0d, 0x3f, 0x94, 0x2a, 0x5b}; const unsigned char kTestCertSha256[] = { - 0x41, 0x6b, 0xb4, 0x93, 0x47, 0x79, 0x77, 0x24, - 0x77, 0x0b, 0x8b, 0x2e, 0xa6, 0x2b, 0xe0, 0xf9, - 0x0a, 0xed, 0x1f, 0x31, 0xa6, 0xf7, 0x5c, 0xa1, - 0x5a, 0xc4, 0xb0, 0xa2, 0xa4, 0x78, 0xb9, 0x76}; + 0x41, 0x6b, 0xb4, 0x93, 0x47, 0x79, 0x77, 0x24, 0x77, 0x0b, 0x8b, + 0x2e, 0xa6, 0x2b, 0xe0, 0xf9, 0x0a, 0xed, 0x1f, 0x31, 0xa6, 0xf7, + 0x5c, 0xa1, 0x5a, 0xc4, 0xb0, 0xa2, 0xa4, 0x78, 0xb9, 0x76}; const unsigned char kTestCertSha384[] = { - 0x42, 0x31, 0x9a, 0x79, 0x1d, 0xd6, 0x08, 0xbf, - 0x3b, 0xba, 0x36, 0xd8, 0x37, 0x4a, 0x9a, 0x75, - 0xd3, 0x25, 0x6e, 0x28, 0x92, 0xbe, 0x06, 0xb7, - 0xc5, 0xa0, 0x83, 0xe3, 0x86, 0xb1, 0x03, 0xfc, - 0x64, 0x47, 0xd6, 0xd8, 0xaa, 0xd9, 0x36, 0x60, - 0x04, 0xcc, 0xbe, 0x7d, 0x6a, 0xe8, 0x34, 0x49}; + 0x42, 0x31, 0x9a, 0x79, 0x1d, 0xd6, 0x08, 0xbf, 0x3b, 0xba, 0x36, 0xd8, + 0x37, 0x4a, 0x9a, 0x75, 0xd3, 0x25, 0x6e, 0x28, 0x92, 0xbe, 0x06, 0xb7, + 0xc5, 0xa0, 0x83, 0xe3, 0x86, 0xb1, 0x03, 0xfc, 0x64, 0x47, 0xd6, 0xd8, + 0xaa, 0xd9, 0x36, 0x60, 0x04, 0xcc, 0xbe, 0x7d, 0x6a, 0xe8, 0x34, 0x49}; const unsigned char kTestCertSha512[] = { - 0x51, 0x1d, 0xec, 0x02, 0x3d, 0x51, 0x45, 0xd3, - 0xd8, 0x1d, 0xa4, 0x9d, 0x43, 0xc9, 0xee, 0x32, - 0x6f, 0x4f, 0x37, 0xee, 0xab, 0x3f, 0x25, 0xdf, - 0x72, 0xfc, 0x61, 0x1a, 0xd5, 0x92, 0xff, 0x6b, - 0x28, 0x71, 0x58, 0xb3, 0xe1, 0x8a, 0x18, 0xcf, - 0x61, 0x33, 0x0e, 0x14, 0xc3, 0x04, 0xaa, 0x07, - 0xf6, 0xa5, 0xda, 0xdc, 0x42, 0x42, 0x22, 0x35, - 0xce, 0x26, 0x58, 0x4a, 0x33, 0x6d, 0xbc, 0xb6}; + 0x51, 0x1d, 0xec, 0x02, 0x3d, 0x51, 0x45, 0xd3, 0xd8, 0x1d, 0xa4, + 0x9d, 0x43, 0xc9, 0xee, 0x32, 0x6f, 0x4f, 0x37, 0xee, 0xab, 0x3f, + 0x25, 0xdf, 0x72, 0xfc, 0x61, 0x1a, 0xd5, 0x92, 0xff, 0x6b, 0x28, + 0x71, 0x58, 0xb3, 0xe1, 0x8a, 0x18, 0xcf, 0x61, 0x33, 0x0e, 0x14, + 0xc3, 0x04, 0xaa, 0x07, 0xf6, 0xa5, 0xda, 0xdc, 0x42, 0x42, 0x22, + 0x35, 0xce, 0x26, 0x58, 0x4a, 0x33, 0x6d, 0xbc, 0xb6}; // These PEM strings were created by generating an identity with // |SSLIdentity::Generate| and invoking |identity->PrivateKeyToPEMString()|, @@ -112,8 +106,7 @@ static const char kRSA_CERT_PEM[] = static const char kRSA_FINGERPRINT[] = "3C:E8:B2:70:09:CF:A9:09:5A:F4:EF:8F:8D:8A:32:FF:EA:04:91:BA:6E:D4:17:78:16" ":2A:EE:F9:9A:DD:E2:2B"; -static const char kRSA_FINGERPRINT_ALGORITHM[] = - "sha-256"; +static const char kRSA_FINGERPRINT_ALGORITHM[] = "sha-256"; static const char kRSA_BASE64_CERTIFICATE[] = "MIIBnDCCAQWgAwIBAgIJAOEHLgeWYwrpMA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNVBAMMBXRlc3" "QxMB4XDTE2MDQyNDE4MTAyMloXDTE2MDUyNTE4MTAyMlowEDEOMAwGA1UEAwwFdGVzdDEwgZ8w" @@ -147,8 +140,7 @@ static const char kECDSA_CERT_PEM[] = static const char kECDSA_FINGERPRINT[] = "9F:47:FA:88:76:3D:18:B8:00:A0:59:9D:C3:5D:34:0B:1F:B8:99:9E:68:DA:F3:A5:DA" ":50:33:A9:FF:4D:31:89"; -static const char kECDSA_FINGERPRINT_ALGORITHM[] = - "sha-256"; +static const char kECDSA_FINGERPRINT_ALGORITHM[] = "sha-256"; static const char kECDSA_BASE64_CERTIFICATE[] = "MIIBFDCBu6ADAgECAgkArpkxjw62sW4wCgYIKoZIzj0EAwIwEDEOMAwGA1UEAwwFdGVzdDMwHh" "cNMTYwNDI0MTgxNDM4WhcNMTYwNTI1MTgxNDM4WjAQMQ4wDAYDVQQDDAV0ZXN0MzBZMBMGByqG" @@ -171,19 +163,16 @@ IdentityAndInfo CreateFakeIdentityAndInfoFromDers( info.ders = ders; for (const std::string& der : ders) { info.pems.push_back(rtc::SSLIdentity::DerToPem( - "CERTIFICATE", - reinterpret_cast(der.c_str()), + "CERTIFICATE", reinterpret_cast(der.c_str()), der.length())); } info.identity.reset(new rtc::FakeSSLIdentity(info.pems)); // Strip header/footer and newline characters of PEM strings. for (size_t i = 0; i < info.pems.size(); ++i) { - rtc::replace_substrs("-----BEGIN CERTIFICATE-----", 27, - "", 0, &info.pems[i]); - rtc::replace_substrs("-----END CERTIFICATE-----", 25, - "", 0, &info.pems[i]); - rtc::replace_substrs("\n", 1, - "", 0, &info.pems[i]); + rtc::replace_substrs("-----BEGIN CERTIFICATE-----", 27, "", 0, + &info.pems[i]); + rtc::replace_substrs("-----END CERTIFICATE-----", 25, "", 0, &info.pems[i]); + rtc::replace_substrs("\n", 1, "", 0, &info.pems[i]); } // Fingerprints for the whole certificate chain, starting with leaf // certificate. @@ -427,9 +416,11 @@ TEST_F(SSLIdentityTest, PemDerConversion) { std::string der; EXPECT_TRUE(SSLIdentity::PemToDer("CERTIFICATE", kTestCertificate, &der)); - EXPECT_EQ(kTestCertificate, SSLIdentity::DerToPem( - "CERTIFICATE", - reinterpret_cast(der.data()), der.length())); + EXPECT_EQ( + kTestCertificate, + SSLIdentity::DerToPem("CERTIFICATE", + reinterpret_cast(der.data()), + der.length())); } TEST_F(SSLIdentityTest, GetSignatureDigestAlgorithm) { @@ -498,6 +489,9 @@ class SSLIdentityExpirationTest : public testing::Test { bool long_format; int64_t want; } static const data[] = { + // clang-format off + // clang formatting breaks this nice alignment + // Valid examples. {"19700101000000Z", true, 0}, {"700101000000Z", false, 0}, @@ -546,6 +540,8 @@ class SSLIdentityExpirationTest : public testing::Test { {"500101000000Z", false, -1}, // but too old for epoch {"691231235959Z", false, -1}, // too old for epoch {"19611118043000Z", false, -1}, // way too old for epoch + + // clang-format off }; unsigned char buf[20]; diff --git a/rtc_base/sslroots.h b/rtc_base/sslroots.h index 7309a0544a..0dbd19b4a9 100644 --- a/rtc_base/sslroots.h +++ b/rtc_base/sslroots.h @@ -18,6 +18,10 @@ // > python tools/sslroots/generate_sslroots.py // https://pki.google.com/roots.pem +// clang-format off +// Don't bother formatting generated code, +// also it would breaks subject/issuer lines. + /* subject:/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA */ /* issuer :/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA */ @@ -4277,4 +4281,6 @@ const size_t kSSLCertCertificateSizeList[] = { 1122, }; +// clang-format on + #endif // RTC_BASE_SSLROOTS_H_ diff --git a/rtc_base/sslstreamadapter.cc b/rtc_base/sslstreamadapter.cc index d52dc45629..746ebd5006 100644 --- a/rtc_base/sslstreamadapter.cc +++ b/rtc_base/sslstreamadapter.cc @@ -25,16 +25,16 @@ const char CS_AEAD_AES_256_GCM[] = "AEAD_AES_256_GCM"; std::string SrtpCryptoSuiteToName(int crypto_suite) { switch (crypto_suite) { - case SRTP_AES128_CM_SHA1_32: - return CS_AES_CM_128_HMAC_SHA1_32; - case SRTP_AES128_CM_SHA1_80: - return CS_AES_CM_128_HMAC_SHA1_80; - case SRTP_AEAD_AES_128_GCM: - return CS_AEAD_AES_128_GCM; - case SRTP_AEAD_AES_256_GCM: - return CS_AEAD_AES_256_GCM; - default: - return std::string(); + case SRTP_AES128_CM_SHA1_32: + return CS_AES_CM_128_HMAC_SHA1_32; + case SRTP_AES128_CM_SHA1_80: + return CS_AES_CM_128_HMAC_SHA1_80; + case SRTP_AEAD_AES_128_GCM: + return CS_AEAD_AES_128_GCM; + case SRTP_AEAD_AES_256_GCM: + return CS_AEAD_AES_256_GCM; + default: + return std::string(); } } @@ -50,30 +50,31 @@ int SrtpCryptoSuiteFromName(const std::string& crypto_suite) { return SRTP_INVALID_CRYPTO_SUITE; } -bool GetSrtpKeyAndSaltLengths(int crypto_suite, int *key_length, - int *salt_length) { +bool GetSrtpKeyAndSaltLengths(int crypto_suite, + int* key_length, + int* salt_length) { switch (crypto_suite) { - case SRTP_AES128_CM_SHA1_32: - case SRTP_AES128_CM_SHA1_80: - // SRTP_AES128_CM_HMAC_SHA1_32 and SRTP_AES128_CM_HMAC_SHA1_80 are defined - // in RFC 5764 to use a 128 bits key and 112 bits salt for the cipher. - *key_length = 16; - *salt_length = 14; - break; - case SRTP_AEAD_AES_128_GCM: - // SRTP_AEAD_AES_128_GCM is defined in RFC 7714 to use a 128 bits key and - // a 96 bits salt for the cipher. - *key_length = 16; - *salt_length = 12; - break; - case SRTP_AEAD_AES_256_GCM: - // SRTP_AEAD_AES_256_GCM is defined in RFC 7714 to use a 256 bits key and - // a 96 bits salt for the cipher. - *key_length = 32; - *salt_length = 12; - break; - default: - return false; + case SRTP_AES128_CM_SHA1_32: + case SRTP_AES128_CM_SHA1_80: + // SRTP_AES128_CM_HMAC_SHA1_32 and SRTP_AES128_CM_HMAC_SHA1_80 are defined + // in RFC 5764 to use a 128 bits key and 112 bits salt for the cipher. + *key_length = 16; + *salt_length = 14; + break; + case SRTP_AEAD_AES_128_GCM: + // SRTP_AEAD_AES_128_GCM is defined in RFC 7714 to use a 128 bits key and + // a 96 bits salt for the cipher. + *key_length = 16; + *salt_length = 12; + break; + case SRTP_AEAD_AES_256_GCM: + // SRTP_AEAD_AES_256_GCM is defined in RFC 7714 to use a 256 bits key and + // a 96 bits salt for the cipher. + *key_length = 32; + *salt_length = 12; + break; + default: + return false; } return true; } diff --git a/rtc_base/sslstreamadapter_unittest.cc b/rtc_base/sslstreamadapter_unittest.cc index ce96274600..3403bdbe72 100644 --- a/rtc_base/sslstreamadapter_unittest.cc +++ b/rtc_base/sslstreamadapter_unittest.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include #include #include @@ -135,22 +134,20 @@ class SSLDummyStreamBase : public rtc::StreamInterface, public sigslot::has_slots<> { public: SSLDummyStreamBase(SSLStreamAdapterTestBase* test, - const std::string &side, + const std::string& side, rtc::StreamInterface* in, - rtc::StreamInterface* out) : - test_base_(test), - side_(side), - in_(in), - out_(out), - first_packet_(true) { + rtc::StreamInterface* out) + : test_base_(test), side_(side), in_(in), out_(out), first_packet_(true) { in_->SignalEvent.connect(this, &SSLDummyStreamBase::OnEventIn); out_->SignalEvent.connect(this, &SSLDummyStreamBase::OnEventOut); } rtc::StreamState GetState() const override { return rtc::SS_OPEN; } - rtc::StreamResult Read(void* buffer, size_t buffer_len, - size_t* read, int* error) override { + rtc::StreamResult Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) override { rtc::StreamResult r; r = in_->Read(buffer, buffer_len, read, error); @@ -189,13 +186,17 @@ class SSLDummyStreamBase : public rtc::StreamInterface, } // Write to the outgoing FifoBuffer - rtc::StreamResult WriteData(const void* data, size_t data_len, - size_t* written, int* error) { + rtc::StreamResult WriteData(const void* data, + size_t data_len, + size_t* written, + int* error) { return out_->Write(data, data_len, written, error); } - rtc::StreamResult Write(const void* data, size_t data_len, - size_t* written, int* error) override; + rtc::StreamResult Write(const void* data, + size_t data_len, + size_t* written, + int* error) override; void Close() override { RTC_LOG(LS_INFO) << "Closing outbound stream"; @@ -215,17 +216,14 @@ class SSLDummyStreamTLS : public SSLDummyStreamBase { SSLDummyStreamTLS(SSLStreamAdapterTestBase* test, const std::string& side, rtc::FifoBuffer* in, - rtc::FifoBuffer* out) : - SSLDummyStreamBase(test, side, in, out) { - } + rtc::FifoBuffer* out) + : SSLDummyStreamBase(test, side, in, out) {} }; -class BufferQueueStream : public rtc::BufferQueue, - public rtc::StreamInterface { +class BufferQueueStream : public rtc::BufferQueue, public rtc::StreamInterface { public: BufferQueueStream(size_t capacity, size_t default_size) - : rtc::BufferQueue(capacity, default_size) { - } + : rtc::BufferQueue(capacity, default_size) {} // Implementation of abstract StreamInterface methods. @@ -233,8 +231,10 @@ class BufferQueueStream : public rtc::BufferQueue, rtc::StreamState GetState() const override { return rtc::SS_OPEN; } // Reading a buffer queue stream will either succeed or block. - rtc::StreamResult Read(void* buffer, size_t buffer_len, - size_t* read, int* error) override { + rtc::StreamResult Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) override { if (!ReadFront(buffer, buffer_len, read)) { return rtc::SR_BLOCK; } @@ -242,8 +242,10 @@ class BufferQueueStream : public rtc::BufferQueue, } // Writing to a buffer queue stream will either succeed or block. - rtc::StreamResult Write(const void* data, size_t data_len, - size_t* written, int* error) override { + rtc::StreamResult Write(const void* data, + size_t data_len, + size_t* written, + int* error) override { if (!WriteBack(data, data_len, written)) { return rtc::SR_BLOCK; } @@ -254,13 +256,9 @@ class BufferQueueStream : public rtc::BufferQueue, void Close() override {} protected: - void NotifyReadableForTest() override { - PostEvent(rtc::SE_READ, 0); - } + void NotifyReadableForTest() override { PostEvent(rtc::SE_READ, 0); } - void NotifyWritableForTest() override { - PostEvent(rtc::SE_WRITE, 0); - } + void NotifyWritableForTest() override { PostEvent(rtc::SE_WRITE, 0); } }; class SSLDummyStreamDTLS : public SSLDummyStreamBase { @@ -268,9 +266,8 @@ class SSLDummyStreamDTLS : public SSLDummyStreamBase { SSLDummyStreamDTLS(SSLStreamAdapterTestBase* test, const std::string& side, BufferQueueStream* in, - BufferQueueStream* out) : - SSLDummyStreamBase(test, side, in, out) { - } + BufferQueueStream* out) + : SSLDummyStreamBase(test, side, in, out) {} }; static const int kFifoBufferSize = 4096; @@ -372,7 +369,7 @@ class SSLStreamAdapterTestBase : public testing::Test, server_ssl_->SetIdentity(server_identity_); } - virtual void OnEvent(rtc::StreamInterface *stream, int sig, int err) { + virtual void OnEvent(rtc::StreamInterface* stream, int sig, int err) { RTC_LOG(LS_VERBOSE) << "SSLStreamAdapterTestBase::OnEvent sig=" << sig; if (sig & rtc::SE_READ) { @@ -433,10 +430,8 @@ class SSLStreamAdapterTestBase : public testing::Test, } void TestHandshake(bool expect_success = true) { - server_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : - rtc::SSL_MODE_TLS); - client_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : - rtc::SSL_MODE_TLS); + server_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : rtc::SSL_MODE_TLS); + client_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : rtc::SSL_MODE_TLS); if (!dtls_) { // Make sure we simulate a reliable network for TLS. @@ -462,8 +457,8 @@ class SSLStreamAdapterTestBase : public testing::Test, // Now run the handshake if (expect_success) { - EXPECT_TRUE_WAIT((client_ssl_->GetState() == rtc::SS_OPEN) - && (server_ssl_->GetState() == rtc::SS_OPEN), + EXPECT_TRUE_WAIT((client_ssl_->GetState() == rtc::SS_OPEN) && + (server_ssl_->GetState() == rtc::SS_OPEN), handshake_wait_); } else { EXPECT_TRUE_WAIT(client_ssl_->GetState() == rtc::SS_CLOSED, @@ -524,9 +519,11 @@ class SSLStreamAdapterTestBase : public testing::Test, } } - rtc::StreamResult DataWritten(SSLDummyStreamBase *from, const void *data, - size_t data_len, size_t *written, - int *error) { + rtc::StreamResult DataWritten(SSLDummyStreamBase* from, + const void* data, + size_t data_len, + size_t* written, + int* error) { // Randomly drop loss_ percent of packets if (rtc::CreateRandomId() % 100 < static_cast(loss_)) { RTC_LOG(LS_VERBOSE) << "Randomly dropping packet, size=" << data_len; @@ -542,7 +539,7 @@ class SSLStreamAdapterTestBase : public testing::Test, // Optionally damage application data (type 23). Note that we don't damage // handshake packets and we damage the last byte to keep the header // intact but break the MAC. - if (damage_ && (*static_cast(data) == 23)) { + if (damage_ && (*static_cast(data) == 23)) { std::vector buf(data_len); RTC_LOG(LS_VERBOSE) << "Damaging packet"; @@ -556,31 +553,19 @@ class SSLStreamAdapterTestBase : public testing::Test, return from->WriteData(data, data_len, written, error); } - void SetDelay(int delay) { - delay_ = delay; - } + void SetDelay(int delay) { delay_ = delay; } int GetDelay() { return delay_; } - void SetLoseFirstPacket(bool lose) { - lose_first_packet_ = lose; - } + void SetLoseFirstPacket(bool lose) { lose_first_packet_ = lose; } bool GetLoseFirstPacket() { return lose_first_packet_; } - void SetLoss(int percent) { - loss_ = percent; - } + void SetLoss(int percent) { loss_ = percent; } - void SetDamage() { - damage_ = true; - } + void SetDamage() { damage_ = true; } - void SetMtu(size_t mtu) { - mtu_ = mtu; - } + void SetMtu(size_t mtu) { mtu_ = mtu; } - void SetHandshakeWait(int wait) { - handshake_wait_ = wait; - } + void SetHandshakeWait(int wait) { handshake_wait_ = wait; } void SetDtlsSrtpCryptoSuites(const std::vector& ciphers, bool client) { if (client) @@ -620,28 +605,24 @@ class SSLStreamAdapterTestBase : public testing::Test, return server_ssl_->GetSslVersion(); } - bool ExportKeyingMaterial(const char *label, - const unsigned char *context, + bool ExportKeyingMaterial(const char* label, + const unsigned char* context, size_t context_len, bool use_context, bool client, - unsigned char *result, + unsigned char* result, size_t result_len) { if (client) - return client_ssl_->ExportKeyingMaterial(label, - context, context_len, - use_context, - result, result_len); + return client_ssl_->ExportKeyingMaterial(label, context, context_len, + use_context, result, result_len); else - return server_ssl_->ExportKeyingMaterial(label, - context, context_len, - use_context, - result, result_len); + return server_ssl_->ExportKeyingMaterial(label, context, context_len, + use_context, result, result_len); } // To be implemented by subclasses. virtual void WriteData() = 0; - virtual void ReadData(rtc::StreamInterface *stream) = 0; + virtual void ReadData(rtc::StreamInterface* stream) = 0; virtual void TestTransfer(int size) = 0; protected: @@ -649,12 +630,12 @@ class SSLStreamAdapterTestBase : public testing::Test, std::string client_private_key_pem_; rtc::KeyParams client_key_type_; rtc::KeyParams server_key_type_; - SSLDummyStreamBase *client_stream_; // freed by client_ssl_ destructor - SSLDummyStreamBase *server_stream_; // freed by server_ssl_ destructor + SSLDummyStreamBase* client_stream_; // freed by client_ssl_ destructor + SSLDummyStreamBase* server_stream_; // freed by server_ssl_ destructor std::unique_ptr client_ssl_; std::unique_ptr server_ssl_; - rtc::SSLIdentity *client_identity_; // freed by client_ssl_ destructor - rtc::SSLIdentity *server_identity_; // freed by server_ssl_ destructor + rtc::SSLIdentity* client_identity_; // freed by client_ssl_ destructor + rtc::SSLIdentity* server_identity_; // freed by server_ssl_ destructor int delay_; size_t mtu_; int loss_; @@ -676,8 +657,7 @@ class SSLStreamAdapterTestTLS ::testing::get<0>(GetParam()), ::testing::get<1>(GetParam())), client_buffer_(kFifoBufferSize), - server_buffer_(kFifoBufferSize) { - } + server_buffer_(kFifoBufferSize) {} void CreateStreams() override { client_stream_ = @@ -712,8 +692,8 @@ class SSLStreamAdapterTestTLS recv_stream_.GetSize(&received); EXPECT_EQ(static_cast(size), received); - EXPECT_EQ(0, memcmp(send_stream_.GetBuffer(), - recv_stream_.GetBuffer(), size)); + EXPECT_EQ(0, + memcmp(send_stream_.GetBuffer(), recv_stream_.GetBuffer(), size)); } void WriteData() override { @@ -752,7 +732,7 @@ class SSLStreamAdapterTestTLS } }; - void ReadData(rtc::StreamInterface *stream) override { + void ReadData(rtc::StreamInterface* stream) override { char buffer[1600]; size_t bread; int err2; @@ -802,12 +782,13 @@ class SSLStreamAdapterTestDTLS sent_(0) {} SSLStreamAdapterTestDTLS(const std::string& cert_pem, - const std::string& private_key_pem) : - SSLStreamAdapterTestBase(cert_pem, private_key_pem, true), - client_buffer_(kBufferCapacity, kDefaultBufferSize), - server_buffer_(kBufferCapacity, kDefaultBufferSize), - packet_size_(1000), count_(0), sent_(0) { - } + const std::string& private_key_pem) + : SSLStreamAdapterTestBase(cert_pem, private_key_pem, true), + client_buffer_(kBufferCapacity, kDefaultBufferSize), + server_buffer_(kBufferCapacity, kDefaultBufferSize), + packet_size_(1000), + count_(0), + sent_(0) {} void CreateStreams() override { client_stream_ = @@ -817,7 +798,7 @@ class SSLStreamAdapterTestDTLS } void WriteData() override { - unsigned char *packet = new unsigned char[1600]; + unsigned char* packet = new unsigned char[1600]; while (sent_ < count_) { unsigned int rand_state = sent_; @@ -842,10 +823,10 @@ class SSLStreamAdapterTestDTLS } } - delete [] packet; + delete[] packet; } - void ReadData(rtc::StreamInterface *stream) override { + void ReadData(rtc::StreamInterface* stream) override { unsigned char buffer[2000]; size_t bread; int err2; @@ -893,7 +874,7 @@ class SSLStreamAdapterTestDTLS WAIT(false, 2000); EXPECT_EQ(0U, received_.size()); } else if (loss_ == 0) { - EXPECT_EQ_WAIT(static_cast(sent_), received_.size(), 1000); + EXPECT_EQ_WAIT(static_cast(sent_), received_.size(), 1000); } else { RTC_LOG(LS_INFO) << "Sent " << sent_ << " packets; received " << received_.size(); @@ -909,9 +890,10 @@ class SSLStreamAdapterTestDTLS std::set received_; }; - -rtc::StreamResult SSLDummyStreamBase::Write(const void* data, size_t data_len, - size_t* written, int* error) { +rtc::StreamResult SSLDummyStreamBase::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { RTC_LOG(LS_VERBOSE) << "Writing to loopback " << data_len; if (first_packet_) { @@ -928,9 +910,8 @@ rtc::StreamResult SSLDummyStreamBase::Write(const void* data, size_t data_len, class SSLStreamAdapterTestDTLSFromPEMStrings : public SSLStreamAdapterTestDTLS { public: - SSLStreamAdapterTestDTLSFromPEMStrings() : - SSLStreamAdapterTestDTLS(kCERT_PEM, kRSA_PRIVATE_KEY_PEM) { - } + SSLStreamAdapterTestDTLSFromPEMStrings() + : SSLStreamAdapterTestDTLS(kCERT_PEM, kRSA_PRIVATE_KEY_PEM) {} }; // Test fixture for certificate chaining. Server will push more than one @@ -1305,28 +1286,28 @@ TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpKeyAndSaltLengths) { int key_len; int salt_len; - ASSERT_FALSE(rtc::GetSrtpKeyAndSaltLengths( - rtc::SRTP_INVALID_CRYPTO_SUITE, &key_len, &salt_len)); + ASSERT_FALSE(rtc::GetSrtpKeyAndSaltLengths(rtc::SRTP_INVALID_CRYPTO_SUITE, + &key_len, &salt_len)); - ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths( - rtc::SRTP_AES128_CM_SHA1_32, &key_len, &salt_len)); - ASSERT_EQ(128/8, key_len); - ASSERT_EQ(112/8, salt_len); + ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths(rtc::SRTP_AES128_CM_SHA1_32, + &key_len, &salt_len)); + ASSERT_EQ(128 / 8, key_len); + ASSERT_EQ(112 / 8, salt_len); - ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths( - rtc::SRTP_AES128_CM_SHA1_80, &key_len, &salt_len)); - ASSERT_EQ(128/8, key_len); - ASSERT_EQ(112/8, salt_len); + ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths(rtc::SRTP_AES128_CM_SHA1_80, + &key_len, &salt_len)); + ASSERT_EQ(128 / 8, key_len); + ASSERT_EQ(112 / 8, salt_len); - ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths( - rtc::SRTP_AEAD_AES_128_GCM, &key_len, &salt_len)); - ASSERT_EQ(128/8, key_len); - ASSERT_EQ(96/8, salt_len); + ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths(rtc::SRTP_AEAD_AES_128_GCM, + &key_len, &salt_len)); + ASSERT_EQ(128 / 8, key_len); + ASSERT_EQ(96 / 8, salt_len); - ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths( - rtc::SRTP_AEAD_AES_256_GCM, &key_len, &salt_len)); - ASSERT_EQ(256/8, key_len); - ASSERT_EQ(96/8, salt_len); + ASSERT_TRUE(rtc::GetSrtpKeyAndSaltLengths(rtc::SRTP_AEAD_AES_256_GCM, + &key_len, &salt_len)); + ASSERT_EQ(256 / 8, key_len); + ASSERT_EQ(96 / 8, salt_len); }; // Test an exporter @@ -1336,16 +1317,14 @@ TEST_P(SSLStreamAdapterTestDTLS, TestDTLSExporter) { unsigned char server_out[20]; bool result; - result = ExportKeyingMaterial(kExporterLabel, - kExporterContext, kExporterContextLen, - true, true, - client_out, sizeof(client_out)); + result = ExportKeyingMaterial(kExporterLabel, kExporterContext, + kExporterContextLen, true, true, client_out, + sizeof(client_out)); ASSERT_TRUE(result); - result = ExportKeyingMaterial(kExporterLabel, - kExporterContext, kExporterContextLen, - true, false, - server_out, sizeof(server_out)); + result = ExportKeyingMaterial(kExporterLabel, kExporterContext, + kExporterContextLen, true, false, server_out, + sizeof(server_out)); ASSERT_TRUE(result); ASSERT_TRUE(!memcmp(client_out, server_out, sizeof(client_out))); diff --git a/rtc_base/stream.cc b/rtc_base/stream.cc index 9a33e7d533..56c848a139 100644 --- a/rtc_base/stream.cc +++ b/rtc_base/stream.cc @@ -11,9 +11,9 @@ #if defined(WEBRTC_POSIX) #include #endif // WEBRTC_POSIX -#include -#include #include +#include +#include #include #include @@ -37,11 +37,12 @@ namespace rtc { /////////////////////////////////////////////////////////////////////////////// // StreamInterface /////////////////////////////////////////////////////////////////////////////// -StreamInterface::~StreamInterface() { -} +StreamInterface::~StreamInterface() {} -StreamResult StreamInterface::WriteAll(const void* data, size_t data_len, - size_t* written, int* error) { +StreamResult StreamInterface::WriteAll(const void* data, + size_t data_len, + size_t* written, + int* error) { StreamResult result = SR_SUCCESS; size_t total_written = 0, current_written; while (total_written < data_len) { @@ -56,8 +57,10 @@ StreamResult StreamInterface::WriteAll(const void* data, size_t data_len, return result; } -StreamResult StreamInterface::ReadAll(void* buffer, size_t buffer_len, - size_t* read, int* error) { +StreamResult StreamInterface::ReadAll(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { StreamResult result = SR_SUCCESS; size_t total_read = 0, current_read; while (total_read < buffer_len) { @@ -137,8 +140,7 @@ bool StreamInterface::ReserveSize(size_t size) { return true; } -StreamInterface::StreamInterface() { -} +StreamInterface::StreamInterface() {} void StreamInterface::OnMessage(Message* msg) { if (MSG_POST_EVENT == msg->message_id) { @@ -241,8 +243,10 @@ void StreamAdapterInterface::OnEvent(StreamInterface* stream, /////////////////////////////////////////////////////////////////////////////// StreamTap::StreamTap(StreamInterface* stream, StreamInterface* tap) - : StreamAdapterInterface(stream), tap_(), tap_result_(SR_SUCCESS), - tap_error_(0) { + : StreamAdapterInterface(stream), + tap_(), + tap_result_(SR_SUCCESS), + tap_error_(0) { AttachTap(tap); } @@ -263,28 +267,32 @@ StreamResult StreamTap::GetTapResult(int* error) { return tap_result_; } -StreamResult StreamTap::Read(void* buffer, size_t buffer_len, - size_t* read, int* error) { +StreamResult StreamTap::Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { size_t backup_read; if (!read) { read = &backup_read; } - StreamResult res = StreamAdapterInterface::Read(buffer, buffer_len, - read, error); + StreamResult res = + StreamAdapterInterface::Read(buffer, buffer_len, read, error); if ((res == SR_SUCCESS) && (tap_result_ == SR_SUCCESS)) { tap_result_ = tap_->WriteAll(buffer, *read, nullptr, &tap_error_); } return res; } -StreamResult StreamTap::Write(const void* data, size_t data_len, - size_t* written, int* error) { +StreamResult StreamTap::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { size_t backup_written; if (!written) { written = &backup_written; } - StreamResult res = StreamAdapterInterface::Write(data, data_len, - written, error); + StreamResult res = + StreamAdapterInterface::Write(data, data_len, written, error); if ((res == SR_SUCCESS) && (tap_result_ == SR_SUCCESS)) { tap_result_ = tap_->WriteAll(data, *written, nullptr, &tap_error_); } @@ -295,30 +303,33 @@ StreamResult StreamTap::Write(const void* data, size_t data_len, // NullStream /////////////////////////////////////////////////////////////////////////////// -NullStream::NullStream() { -} +NullStream::NullStream() {} -NullStream::~NullStream() { -} +NullStream::~NullStream() {} StreamState NullStream::GetState() const { return SS_OPEN; } -StreamResult NullStream::Read(void* buffer, size_t buffer_len, - size_t* read, int* error) { - if (error) *error = -1; +StreamResult NullStream::Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { + if (error) + *error = -1; return SR_ERROR; } -StreamResult NullStream::Write(const void* data, size_t data_len, - size_t* written, int* error) { - if (written) *written = data_len; +StreamResult NullStream::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { + if (written) + *written = data_len; return SR_SUCCESS; } -void NullStream::Close() { -} +void NullStream::Close() {} /////////////////////////////////////////////////////////////////////////////// // FileStream @@ -330,7 +341,8 @@ FileStream::~FileStream() { FileStream::Close(); } -bool FileStream::Open(const std::string& filename, const char* mode, +bool FileStream::Open(const std::string& filename, + const char* mode, int* error) { Close(); #if defined(WEBRTC_WIN) @@ -352,8 +364,10 @@ bool FileStream::Open(const std::string& filename, const char* mode, return (file_ != nullptr); } -bool FileStream::OpenShare(const std::string& filename, const char* mode, - int shflag, int* error) { +bool FileStream::OpenShare(const std::string& filename, + const char* mode, + int shflag, + int* error) { Close(); #if defined(WEBRTC_WIN) std::wstring wfilename; @@ -385,8 +399,10 @@ StreamState FileStream::GetState() const { return (file_ == nullptr) ? SS_CLOSED : SS_OPEN; } -StreamResult FileStream::Read(void* buffer, size_t buffer_len, - size_t* read, int* error) { +StreamResult FileStream::Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { if (!file_) return SR_EOS; size_t result = fread(buffer, 1, buffer_len, file_); @@ -402,8 +418,10 @@ StreamResult FileStream::Read(void* buffer, size_t buffer_len, return SR_SUCCESS; } -StreamResult FileStream::Write(const void* data, size_t data_len, - size_t* written, int* error) { +StreamResult FileStream::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { if (!file_) return SR_EOS; size_t result = fwrite(data, 1, data_len, file_); @@ -495,8 +513,10 @@ StreamState MemoryStreamBase::GetState() const { return SS_OPEN; } -StreamResult MemoryStreamBase::Read(void* buffer, size_t bytes, - size_t* bytes_read, int* error) { +StreamResult MemoryStreamBase::Read(void* buffer, + size_t bytes, + size_t* bytes_read, + int* error) { if (seek_position_ >= data_length_) { return SR_EOS; } @@ -513,8 +533,10 @@ StreamResult MemoryStreamBase::Read(void* buffer, size_t bytes, return SR_SUCCESS; } -StreamResult MemoryStreamBase::Write(const void* buffer, size_t bytes, - size_t* bytes_written, int* error) { +StreamResult MemoryStreamBase::Write(const void* buffer, + size_t bytes, + size_t* bytes_written, + int* error) { size_t available = buffer_length_ - seek_position_; if (0 == available) { // Increase buffer size to the larger of: @@ -583,7 +605,6 @@ StreamResult MemoryStreamBase::DoReserve(size_t size, int* error) { /////////////////////////////////////////////////////////////////////////////// - MemoryStream::MemoryStream() {} MemoryStream::MemoryStream(const char* data) { @@ -595,12 +616,12 @@ MemoryStream::MemoryStream(const void* data, size_t length) { } MemoryStream::~MemoryStream() { - delete [] buffer_; + delete[] buffer_; } void MemoryStream::SetData(const void* data, size_t length) { data_length_ = buffer_length_ = length; - delete [] buffer_; + delete[] buffer_; buffer_ = new char[buffer_length_]; memcpy(buffer_, data, data_length_); seek_position_ = 0; @@ -612,7 +633,7 @@ StreamResult MemoryStream::DoReserve(size_t size, int* error) { if (char* new_buffer = new char[size]) { memcpy(new_buffer, buffer_, data_length_); - delete [] buffer_; + delete[] buffer_; buffer_ = new_buffer; buffer_length_ = size; return SR_SUCCESS; @@ -626,15 +647,13 @@ StreamResult MemoryStream::DoReserve(size_t size, int* error) { /////////////////////////////////////////////////////////////////////////////// -ExternalMemoryStream::ExternalMemoryStream() { -} +ExternalMemoryStream::ExternalMemoryStream() {} ExternalMemoryStream::ExternalMemoryStream(void* data, size_t length) { SetData(data, length); } -ExternalMemoryStream::~ExternalMemoryStream() { -} +ExternalMemoryStream::~ExternalMemoryStream() {} void ExternalMemoryStream::SetData(void* data, size_t length) { data_length_ = buffer_length_ = length; @@ -647,19 +666,26 @@ void ExternalMemoryStream::SetData(void* data, size_t length) { /////////////////////////////////////////////////////////////////////////////// FifoBuffer::FifoBuffer(size_t size) - : state_(SS_OPEN), buffer_(new char[size]), buffer_length_(size), - data_length_(0), read_position_(0), owner_(Thread::Current()) { + : state_(SS_OPEN), + buffer_(new char[size]), + buffer_length_(size), + data_length_(0), + read_position_(0), + owner_(Thread::Current()) { // all events are done on the owner_ thread } FifoBuffer::FifoBuffer(size_t size, Thread* owner) - : state_(SS_OPEN), buffer_(new char[size]), buffer_length_(size), - data_length_(0), read_position_(0), owner_(owner) { + : state_(SS_OPEN), + buffer_(new char[size]), + buffer_length_(size), + data_length_(0), + read_position_(0), + owner_(owner) { // all events are done on the owner_ thread } -FifoBuffer::~FifoBuffer() { -} +FifoBuffer::~FifoBuffer() {} bool FifoBuffer::GetBuffered(size_t* size) const { CritScope cs(&crit_); @@ -686,14 +712,18 @@ bool FifoBuffer::SetCapacity(size_t size) { return true; } -StreamResult FifoBuffer::ReadOffset(void* buffer, size_t bytes, - size_t offset, size_t* bytes_read) { +StreamResult FifoBuffer::ReadOffset(void* buffer, + size_t bytes, + size_t offset, + size_t* bytes_read) { CritScope cs(&crit_); return ReadOffsetLocked(buffer, bytes, offset, bytes_read); } -StreamResult FifoBuffer::WriteOffset(const void* buffer, size_t bytes, - size_t offset, size_t* bytes_written) { +StreamResult FifoBuffer::WriteOffset(const void* buffer, + size_t bytes, + size_t offset, + size_t* bytes_written) { CritScope cs(&crit_); return WriteOffsetLocked(buffer, bytes, offset, bytes_written); } @@ -703,8 +733,10 @@ StreamState FifoBuffer::GetState() const { return state_; } -StreamResult FifoBuffer::Read(void* buffer, size_t bytes, - size_t* bytes_read, int* error) { +StreamResult FifoBuffer::Read(void* buffer, + size_t bytes, + size_t* bytes_read, + int* error) { CritScope cs(&crit_); const bool was_writable = data_length_ < buffer_length_; size_t copy = 0; @@ -727,8 +759,10 @@ StreamResult FifoBuffer::Read(void* buffer, size_t bytes, return result; } -StreamResult FifoBuffer::Write(const void* buffer, size_t bytes, - size_t* bytes_written, int* error) { +StreamResult FifoBuffer::Write(const void* buffer, + size_t bytes, + size_t* bytes_written, + int* error) { CritScope cs(&crit_); const bool was_readable = (data_length_ > 0); @@ -757,8 +791,9 @@ void FifoBuffer::Close() { const void* FifoBuffer::GetReadData(size_t* size) { CritScope cs(&crit_); - *size = (read_position_ + data_length_ <= buffer_length_) ? - data_length_ : buffer_length_ - read_position_; + *size = (read_position_ + data_length_ <= buffer_length_) + ? data_length_ + : buffer_length_ - read_position_; return &buffer_[read_position_]; } @@ -785,10 +820,11 @@ void* FifoBuffer::GetWriteBuffer(size_t* size) { read_position_ = 0; } - const size_t write_position = (read_position_ + data_length_) - % buffer_length_; - *size = (write_position > read_position_ || data_length_ == 0) ? - buffer_length_ - write_position : read_position_ - write_position; + const size_t write_position = + (read_position_ + data_length_) % buffer_length_; + *size = (write_position > read_position_ || data_length_ == 0) + ? buffer_length_ - write_position + : read_position_ - write_position; return &buffer_[write_position]; } @@ -843,8 +879,8 @@ StreamResult FifoBuffer::WriteOffsetLocked(const void* buffer, } const size_t available = buffer_length_ - data_length_ - offset; - const size_t write_position = (read_position_ + data_length_ + offset) - % buffer_length_; + const size_t write_position = + (read_position_ + data_length_ + offset) % buffer_length_; const size_t copy = std::min(bytes, available); const size_t tail_copy = std::min(copy, buffer_length_ - write_position); const char* const p = static_cast(buffer); @@ -857,25 +893,24 @@ StreamResult FifoBuffer::WriteOffsetLocked(const void* buffer, return SR_SUCCESS; } - /////////////////////////////////////////////////////////////////////////////// // StringStream - Reads/Writes to an external std::string /////////////////////////////////////////////////////////////////////////////// StringStream::StringStream(std::string* str) - : str_(*str), read_pos_(0), read_only_(false) { -} + : str_(*str), read_pos_(0), read_only_(false) {} StringStream::StringStream(const std::string& str) - : str_(const_cast(str)), read_pos_(0), read_only_(true) { -} + : str_(const_cast(str)), read_pos_(0), read_only_(true) {} StreamState StringStream::GetState() const { return SS_OPEN; } -StreamResult StringStream::Read(void* buffer, size_t buffer_len, - size_t* read, int* error) { +StreamResult StringStream::Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { size_t available = std::min(buffer_len, str_.size() - read_pos_); if (!available) return SR_EOS; @@ -886,8 +921,10 @@ StreamResult StringStream::Read(void* buffer, size_t buffer_len, return SR_SUCCESS; } -StreamResult StringStream::Write(const void* data, size_t data_len, - size_t* written, int* error) { +StreamResult StringStream::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { if (read_only_) { if (error) { *error = -1; @@ -901,8 +938,7 @@ StreamResult StringStream::Write(const void* data, size_t data_len, return SR_SUCCESS; } -void StringStream::Close() { -} +void StringStream::Close() {} bool StringStream::SetPosition(size_t position) { if (position > str_.size()) @@ -958,8 +994,7 @@ StreamReference::~StreamReference() { StreamReference::StreamReference(StreamRefCount* stream_ref_count, StreamInterface* stream) : StreamAdapterInterface(stream, false), - stream_ref_count_(stream_ref_count) { -} + stream_ref_count_(stream_ref_count) {} /////////////////////////////////////////////////////////////////////////////// diff --git a/rtc_base/stream.h b/rtc_base/stream.h index e39141dc09..d3f2f740ee 100644 --- a/rtc_base/stream.h +++ b/rtc_base/stream.h @@ -55,14 +55,12 @@ class Thread; struct StreamEventData : public MessageData { int events, error; - StreamEventData(int ev, int er) : events(ev), error(er) { } + StreamEventData(int ev, int er) : events(ev), error(er) {} }; class StreamInterface : public MessageHandler { public: - enum { - MSG_POST_EVENT = 0xF1F1, MSG_MAX = MSG_POST_EVENT - }; + enum { MSG_POST_EVENT = 0xF1F1, MSG_MAX = MSG_POST_EVENT }; ~StreamInterface() override; @@ -81,10 +79,14 @@ class StreamInterface : public MessageHandler { // block, or the stream is in SS_OPENING state. // SR_EOS: the end-of-stream has been reached, or the stream is in the // SS_CLOSED state. - virtual StreamResult Read(void* buffer, size_t buffer_len, - size_t* read, int* error) = 0; - virtual StreamResult Write(const void* data, size_t data_len, - size_t* written, int* error) = 0; + virtual StreamResult Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) = 0; + virtual StreamResult Write(const void* data, + size_t data_len, + size_t* written, + int* error) = 0; // Attempt to transition to the SS_CLOSED state. SE_CLOSE will not be // signalled as a result of this call. virtual void Close() = 0; @@ -158,7 +160,7 @@ class StreamInterface : public MessageHandler { // NOTE: This interface is being considered experimentally at the moment. It // would be used by JUDP and BandwidthStream as a way to circumvent certain // soft limits in writing. - //virtual bool ForceWrite(const void* data, size_t data_len, int* error) { + // virtual bool ForceWrite(const void* data, size_t data_len, int* error) { // if (error) *error = -1; // return false; //} @@ -208,13 +210,17 @@ class StreamInterface : public MessageHandler { // unlike Write, the argument 'written' is always set, and may be non-zero // on results other than SR_SUCCESS. The remaining arguments have the // same semantics as Write. - StreamResult WriteAll(const void* data, size_t data_len, - size_t* written, int* error); + StreamResult WriteAll(const void* data, + size_t data_len, + size_t* written, + int* error); // Similar to ReadAll. Calls Read until buffer_len bytes have been read, or // until a non-SR_SUCCESS result is returned. 'read' is always set. - StreamResult ReadAll(void* buffer, size_t buffer_len, - size_t* read, int* error); + StreamResult ReadAll(void* buffer, + size_t buffer_len, + size_t* read, + int* error); // ReadLine is a helper function which repeatedly calls Read until it hits // the end-of-line character, or something other than SR_SUCCESS. @@ -375,8 +381,10 @@ class FileStream : public StreamInterface { // The semantics of filename and mode are the same as stdio's fopen virtual bool Open(const std::string& filename, const char* mode, int* error); - virtual bool OpenShare(const std::string& filename, const char* mode, - int shflag, int* error); + virtual bool OpenShare(const std::string& filename, + const char* mode, + int shflag, + int* error); // By default, reads and writes are buffered for efficiency. Disabling // buffering causes writes to block until the bytes on disk are updated. @@ -499,14 +507,18 @@ class FifoBuffer : public StreamInterface { // is specified in number of bytes. // This method doesn't adjust read position nor the number of available // bytes, user has to call ConsumeReadData() to do this. - StreamResult ReadOffset(void* buffer, size_t bytes, size_t offset, + StreamResult ReadOffset(void* buffer, + size_t bytes, + size_t offset, size_t* bytes_read); // Write |buffer| with an offset from the current write position, offset is // specified in number of bytes. // This method doesn't adjust the number of buffered bytes, user has to call // ConsumeWriteBuffer() to do this. - StreamResult WriteOffset(const void* buffer, size_t bytes, size_t offset, + StreamResult WriteOffset(const void* buffer, + size_t bytes, + size_t offset, size_t* bytes_written); // StreamInterface methods @@ -606,6 +618,7 @@ class StringStream : public StreamInterface { class StreamReference : public StreamAdapterInterface { class StreamRefCount; + public: // Constructor for the first reference to a stream // Note: get more references through NewReference(). Use this @@ -619,8 +632,7 @@ class StreamReference : public StreamAdapterInterface { class StreamRefCount { public: explicit StreamRefCount(StreamInterface* stream) - : stream_(stream), ref_count_(1) { - } + : stream_(stream), ref_count_(1) {} void AddReference() { CritScope lock(&cs_); ++ref_count_; @@ -636,6 +648,7 @@ class StreamReference : public StreamAdapterInterface { delete this; } } + private: StreamInterface* stream_; int ref_count_; diff --git a/rtc_base/stream_unittest.cc b/rtc_base/stream_unittest.cc index 8c305c5a19..11e0be0422 100644 --- a/rtc_base/stream_unittest.cc +++ b/rtc_base/stream_unittest.cc @@ -19,7 +19,7 @@ namespace rtc { class TestStream : public StreamInterface { public: - TestStream() : pos_(0) { } + TestStream() : pos_(0) {} StreamState GetState() const override { return SS_OPEN; } @@ -53,7 +53,8 @@ class TestStream : public StreamInterface { } bool GetPosition(size_t* position) const override { - if (position) *position = pos_; + if (position) + *position = pos_; return true; } @@ -65,8 +66,7 @@ class TestStream : public StreamInterface { size_t pos_; }; -bool VerifyTestBuffer(unsigned char* buffer, size_t len, - unsigned char value) { +bool VerifyTestBuffer(unsigned char* buffer, size_t len, unsigned char value) { bool passed = true; for (size_t i = 0; i < len; ++i) { if (buffer[i] != value++) { @@ -81,7 +81,7 @@ bool VerifyTestBuffer(unsigned char* buffer, size_t len, void SeekTest(StreamInterface* stream, const unsigned char value) { size_t bytes; - unsigned char buffer[13] = { 0 }; + unsigned char buffer[13] = {0}; const size_t kBufSize = sizeof(buffer); EXPECT_EQ(stream->Read(buffer, kBufSize, &bytes, nullptr), SR_SUCCESS); @@ -176,15 +176,15 @@ TEST(FifoBufferTest, TestAll) { EXPECT_EQ(SR_SUCCESS, stream->Write(in, kSize / 2, &bytes, nullptr)); EXPECT_EQ(kSize / 2, bytes); EXPECT_EQ(SR_SUCCESS, stream->Read(out, kSize / 4, &bytes, nullptr)); - EXPECT_EQ(kSize / 4 , bytes); + EXPECT_EQ(kSize / 4, bytes); EXPECT_EQ(0, memcmp(in + kSize / 2, out, kSize / 4)); EXPECT_EQ(SR_SUCCESS, stream->Write(in, kSize / 2, &bytes, nullptr)); EXPECT_EQ(kSize / 2, bytes); EXPECT_EQ(SR_SUCCESS, stream->Read(out, kSize / 2, &bytes, nullptr)); - EXPECT_EQ(kSize / 2 , bytes); + EXPECT_EQ(kSize / 2, bytes); EXPECT_EQ(0, memcmp(in, out, kSize / 2)); EXPECT_EQ(SR_SUCCESS, stream->Read(out, kSize / 2, &bytes, nullptr)); - EXPECT_EQ(kSize / 2 , bytes); + EXPECT_EQ(kSize / 2, bytes); EXPECT_EQ(0, memcmp(in, out, kSize / 2)); // Use GetWriteBuffer to reset the read_position for the next tests diff --git a/rtc_base/string_to_number.h b/rtc_base/string_to_number.h index 4a8fb8f8e1..3a7ca58b89 100644 --- a/rtc_base/string_to_number.h +++ b/rtc_base/string_to_number.h @@ -11,8 +11,8 @@ #ifndef RTC_BASE_STRING_TO_NUMBER_H_ #define RTC_BASE_STRING_TO_NUMBER_H_ -#include #include +#include #include "api/optional.h" @@ -44,7 +44,7 @@ namespace rtc { namespace string_to_number_internal { // These must be (unsigned) long long, to match the signature of strto(u)ll. using unsigned_type = unsigned long long; // NOLINT(runtime/int) -using signed_type = long long; // NOLINT(runtime/int) +using signed_type = long long; // NOLINT(runtime/int) rtc::Optional ParseSigned(const char* str, int base); rtc::Optional ParseUnsigned(const char* str, int base); diff --git a/rtc_base/string_to_number_unittest.cc b/rtc_base/string_to_number_unittest.cc index 538ee1024b..691b26f5c1 100644 --- a/rtc_base/string_to_number_unittest.cc +++ b/rtc_base/string_to_number_unittest.cc @@ -10,9 +10,9 @@ #include "rtc_base/string_to_number.h" +#include #include #include -#include #include "rtc_base/gunit.h" diff --git a/rtc_base/stringencode.cc b/rtc_base/stringencode.cc index f2a1508dcb..8e7c6d7c95 100644 --- a/rtc_base/stringencode.cc +++ b/rtc_base/stringencode.cc @@ -22,8 +22,10 @@ namespace rtc { // String Encoding Utilities ///////////////////////////////////////////////////////////////////////////// -size_t url_decode(char * buffer, size_t buflen, - const char * source, size_t srclen) { +size_t url_decode(char* buffer, + size_t buflen, + const char* source, + size_t srclen) { if (nullptr == buffer) return srclen + 1; if (buflen <= 0) @@ -35,11 +37,9 @@ size_t url_decode(char * buffer, size_t buflen, unsigned char ch = source[srcpos++]; if (ch == '+') { buffer[bufpos++] = ' '; - } else if ((ch == '%') - && (srcpos + 1 < srclen) - && hex_decode(source[srcpos], &h1) - && hex_decode(source[srcpos+1], &h2)) - { + } else if ((ch == '%') && (srcpos + 1 < srclen) && + hex_decode(source[srcpos], &h1) && + hex_decode(source[srcpos + 1], &h2)) { buffer[bufpos++] = (h1 << 4) | h2; srcpos += 2; } else { @@ -52,7 +52,7 @@ size_t url_decode(char * buffer, size_t buflen, size_t utf8_decode(const char* source, size_t srclen, unsigned long* value) { const unsigned char* s = reinterpret_cast(source); - if ((s[0] & 0x80) == 0x00) { // Check s[0] == 0xxxxxxx + if ((s[0] & 0x80) == 0x00) { // Check s[0] == 0xxxxxxx *value = s[0]; return 1; } @@ -62,7 +62,7 @@ size_t utf8_decode(const char* source, size_t srclen, unsigned long* value) { // Accumulate the trailer byte values in value16, and combine it with the // relevant bits from s[0], once we've determined the sequence length. unsigned long value16 = (s[1] & 0x3F); - if ((s[0] & 0xE0) == 0xC0) { // Check s[0] == 110xxxxx + if ((s[0] & 0xE0) == 0xC0) { // Check s[0] == 110xxxxx *value = ((s[0] & 0x1F) << 6) | value16; return 2; } @@ -70,7 +70,7 @@ size_t utf8_decode(const char* source, size_t srclen, unsigned long* value) { return 0; } value16 = (value16 << 6) | (s[2] & 0x3F); - if ((s[0] & 0xF0) == 0xE0) { // Check s[0] == 1110xxxx + if ((s[0] & 0xF0) == 0xE0) { // Check s[0] == 1110xxxx *value = ((s[0] & 0x0F) << 12) | value16; return 3; } @@ -78,7 +78,7 @@ size_t utf8_decode(const char* source, size_t srclen, unsigned long* value) { return 0; } value16 = (value16 << 6) | (s[3] & 0x3F); - if ((s[0] & 0xF8) == 0xF0) { // Check s[0] == 11110xxx + if ((s[0] & 0xF8) == 0xF0) { // Check s[0] == 11110xxx *value = ((s[0] & 0x07) << 18) | value16; return 4; } @@ -131,13 +131,17 @@ bool hex_decode(char ch, unsigned char* val) { return true; } -size_t hex_encode(char* buffer, size_t buflen, - const char* csource, size_t srclen) { +size_t hex_encode(char* buffer, + size_t buflen, + const char* csource, + size_t srclen) { return hex_encode_with_delimiter(buffer, buflen, csource, srclen, 0); } -size_t hex_encode_with_delimiter(char* buffer, size_t buflen, - const char* csource, size_t srclen, +size_t hex_encode_with_delimiter(char* buffer, + size_t buflen, + const char* csource, + size_t srclen, char delimiter) { RTC_DCHECK(buffer); // TODO(kwiberg): estimate output size if (buflen == 0) @@ -153,8 +157,8 @@ size_t hex_encode_with_delimiter(char* buffer, size_t buflen, while (srcpos < srclen) { unsigned char ch = bsource[srcpos++]; - buffer[bufpos ] = hex_encode((ch >> 4) & 0xF); - buffer[bufpos+1] = hex_encode((ch ) & 0xF); + buffer[bufpos] = hex_encode((ch >> 4) & 0xF); + buffer[bufpos + 1] = hex_encode((ch)&0xF); bufpos += 2; // Don't write a delimiter after the last byte. @@ -177,23 +181,28 @@ std::string hex_encode(const char* source, size_t srclen) { return hex_encode_with_delimiter(source, srclen, 0); } -std::string hex_encode_with_delimiter(const char* source, size_t srclen, +std::string hex_encode_with_delimiter(const char* source, + size_t srclen, char delimiter) { const size_t kBufferSize = srclen * 3; char* buffer = STACK_ARRAY(char, kBufferSize); - size_t length = hex_encode_with_delimiter(buffer, kBufferSize, - source, srclen, delimiter); + size_t length = + hex_encode_with_delimiter(buffer, kBufferSize, source, srclen, delimiter); RTC_DCHECK(srclen == 0 || length > 0); return std::string(buffer, length); } -size_t hex_decode(char * cbuffer, size_t buflen, - const char * source, size_t srclen) { +size_t hex_decode(char* cbuffer, + size_t buflen, + const char* source, + size_t srclen) { return hex_decode_with_delimiter(cbuffer, buflen, source, srclen, 0); } -size_t hex_decode_with_delimiter(char* cbuffer, size_t buflen, - const char* source, size_t srclen, +size_t hex_decode_with_delimiter(char* cbuffer, + size_t buflen, + const char* source, + size_t srclen, char delimiter) { RTC_DCHECK(cbuffer); // TODO(kwiberg): estimate output size if (buflen == 0) @@ -234,13 +243,17 @@ size_t hex_decode_with_delimiter(char* cbuffer, size_t buflen, size_t hex_decode(char* buffer, size_t buflen, const std::string& source) { return hex_decode_with_delimiter(buffer, buflen, source, 0); } -size_t hex_decode_with_delimiter(char* buffer, size_t buflen, - const std::string& source, char delimiter) { - return hex_decode_with_delimiter(buffer, buflen, - source.c_str(), source.length(), delimiter); +size_t hex_decode_with_delimiter(char* buffer, + size_t buflen, + const std::string& source, + char delimiter) { + return hex_decode_with_delimiter(buffer, buflen, source.c_str(), + source.length(), delimiter); } -size_t transform(std::string& value, size_t maxlen, const std::string& source, +size_t transform(std::string& value, + size_t maxlen, + const std::string& source, Transform t) { char* buffer = STACK_ARRAY(char, maxlen + 1); size_t length = t(buffer, maxlen + 1, source.data(), source.length()); @@ -249,15 +262,17 @@ size_t transform(std::string& value, size_t maxlen, const std::string& source, } std::string s_transform(const std::string& source, Transform t) { - // Ask transformation function to approximate the destination size (returns upper bound) + // Ask transformation function to approximate the destination size (returns + // upper bound) size_t maxlen = t(nullptr, 0, source.data(), source.length()); - char * buffer = STACK_ARRAY(char, maxlen); + char* buffer = STACK_ARRAY(char, maxlen); size_t len = t(buffer, maxlen, source.data(), source.length()); std::string result(buffer, len); return result; } -size_t tokenize(const std::string& source, char delimiter, +size_t tokenize(const std::string& source, + char delimiter, std::vector* fields) { fields->clear(); size_t last = 0; @@ -290,9 +305,11 @@ size_t tokenize_with_empty_tokens(const std::string& source, return fields->size(); } -size_t tokenize_append(const std::string& source, char delimiter, +size_t tokenize_append(const std::string& source, + char delimiter, std::vector* fields) { - if (!fields) return 0; + if (!fields) + return 0; std::vector new_fields; tokenize(source, delimiter, &new_fields); @@ -300,15 +317,20 @@ size_t tokenize_append(const std::string& source, char delimiter, return fields->size(); } -size_t tokenize(const std::string& source, char delimiter, char start_mark, - char end_mark, std::vector* fields) { - if (!fields) return 0; +size_t tokenize(const std::string& source, + char delimiter, + char start_mark, + char end_mark, + std::vector* fields) { + if (!fields) + return 0; fields->clear(); std::string remain_source = source; while (!remain_source.empty()) { size_t start_pos = remain_source.find(start_mark); - if (std::string::npos == start_pos) break; + if (std::string::npos == start_pos) + break; std::string pre_mark; if (start_pos > 0) { pre_mark = remain_source.substr(0, start_pos - 1); @@ -316,7 +338,8 @@ size_t tokenize(const std::string& source, char delimiter, char start_mark, ++start_pos; size_t end_pos = remain_source.find(end_mark, start_pos); - if (std::string::npos == end_pos) break; + if (std::string::npos == end_pos) + break; // We have found the matching marks. First tokenize the pre-mask. Then add // the marked part as a single field. Finally, loop back for the post-mark. @@ -371,7 +394,8 @@ std::string join(const std::vector& source, char delimiter) { return joined_string; } -size_t split(const std::string& source, char delimiter, +size_t split(const std::string& source, + char delimiter, std::vector* fields) { RTC_DCHECK(fields); fields->clear(); diff --git a/rtc_base/stringencode.h b/rtc_base/stringencode.h index e5395b7edf..7042c4a416 100644 --- a/rtc_base/stringencode.h +++ b/rtc_base/stringencode.h @@ -24,8 +24,10 @@ namespace rtc { ////////////////////////////////////////////////////////////////////// // Note: in-place decoding (buffer == source) is allowed. -size_t url_decode(char * buffer, size_t buflen, - const char * source, size_t srclen); +size_t url_decode(char* buffer, + size_t buflen, + const char* source, + size_t srclen); // Convert an unsigned value from 0 to 15 to the hex character equivalent... char hex_encode(unsigned char val); @@ -33,45 +35,60 @@ char hex_encode(unsigned char val); bool hex_decode(char ch, unsigned char* val); // hex_encode shows the hex representation of binary data in ascii. -size_t hex_encode(char* buffer, size_t buflen, - const char* source, size_t srclen); +size_t hex_encode(char* buffer, + size_t buflen, + const char* source, + size_t srclen); // hex_encode, but separate each byte representation with a delimiter. // |delimiter| == 0 means no delimiter // If the buffer is too short, we return 0 -size_t hex_encode_with_delimiter(char* buffer, size_t buflen, - const char* source, size_t srclen, +size_t hex_encode_with_delimiter(char* buffer, + size_t buflen, + const char* source, + size_t srclen, char delimiter); // Helper functions for hex_encode. std::string hex_encode(const std::string& str); std::string hex_encode(const char* source, size_t srclen); -std::string hex_encode_with_delimiter(const char* source, size_t srclen, +std::string hex_encode_with_delimiter(const char* source, + size_t srclen, char delimiter); // hex_decode converts ascii hex to binary. -size_t hex_decode(char* buffer, size_t buflen, - const char* source, size_t srclen); +size_t hex_decode(char* buffer, + size_t buflen, + const char* source, + size_t srclen); // hex_decode, assuming that there is a delimiter between every byte // pair. // |delimiter| == 0 means no delimiter // If the buffer is too short or the data is invalid, we return 0. -size_t hex_decode_with_delimiter(char* buffer, size_t buflen, - const char* source, size_t srclen, +size_t hex_decode_with_delimiter(char* buffer, + size_t buflen, + const char* source, + size_t srclen, char delimiter); // Helper functions for hex_decode. size_t hex_decode(char* buffer, size_t buflen, const std::string& source); -size_t hex_decode_with_delimiter(char* buffer, size_t buflen, - const std::string& source, char delimiter); +size_t hex_decode_with_delimiter(char* buffer, + size_t buflen, + const std::string& source, + char delimiter); // Apply any suitable string transform (including the ones above) to an STL // string. Stack-allocated temporary space is used for the transformation, // so value and source may refer to the same string. -typedef size_t (*Transform)(char * buffer, size_t buflen, - const char * source, size_t srclen); -size_t transform(std::string& value, size_t maxlen, const std::string& source, +typedef size_t (*Transform)(char* buffer, + size_t buflen, + const char* source, + size_t srclen); +size_t transform(std::string& value, + size_t maxlen, + const std::string& source, Transform t); // Return the result of applying transform t to source. @@ -88,12 +105,14 @@ std::string join(const std::vector& source, char delimiter); // Splits the source string into multiple fields separated by delimiter, // with duplicates of delimiter creating empty fields. -size_t split(const std::string& source, char delimiter, +size_t split(const std::string& source, + char delimiter, std::vector* fields); // Splits the source string into multiple fields separated by delimiter, // with duplicates of delimiter ignored. Trailing delimiter ignored. -size_t tokenize(const std::string& source, char delimiter, +size_t tokenize(const std::string& source, + char delimiter, std::vector* fields); // Tokenize, including the empty tokens. @@ -102,7 +121,8 @@ size_t tokenize_with_empty_tokens(const std::string& source, std::vector* fields); // Tokenize and append the tokens to fields. Return the new size of fields. -size_t tokenize_append(const std::string& source, char delimiter, +size_t tokenize_append(const std::string& source, + char delimiter, std::vector* fields); // Splits the source string into multiple fields separated by delimiter, with @@ -112,8 +132,11 @@ size_t tokenize_append(const std::string& source, char delimiter, // \"/Library/Application Support/media content.txt\"", delimiter is ' ', and // the start_mark and end_mark are '"', this method returns two fields: // "filename" and "/Library/Application Support/media content.txt". -size_t tokenize(const std::string& source, char delimiter, char start_mark, - char end_mark, std::vector* fields); +size_t tokenize(const std::string& source, + char delimiter, + char start_mark, + char end_mark, + std::vector* fields); // Extract the first token from source as separated by delimiter, with // duplicates of delimiter ignored. Return false if the delimiter could not be @@ -126,7 +149,7 @@ bool tokenize_first(const std::string& source, // Convert arbitrary values to/from a string. template -static bool ToString(const T &t, std::string* s) { +static bool ToString(const T& t, std::string* s) { RTC_DCHECK(s); std::ostringstream oss; oss << std::boolalpha << t; @@ -144,19 +167,25 @@ static bool FromString(const std::string& s, T* t) { // Inline versions of the string conversion routines. -template +template static inline std::string ToString(const T& val) { - std::string str; ToString(val, &str); return str; + std::string str; + ToString(val, &str); + return str; } -template +template static inline T FromString(const std::string& str) { - T val; FromString(str, &val); return val; + T val; + FromString(str, &val); + return val; } -template +template static inline T FromString(const T& defaultValue, const std::string& str) { - T val(defaultValue); FromString(str, &val); return val; + T val(defaultValue); + FromString(str, &val); + return val; } ////////////////////////////////////////////////////////////////////// diff --git a/rtc_base/stringencode_unittest.cc b/rtc_base/stringencode_unittest.cc index 63d8290276..ffb90b2265 100644 --- a/rtc_base/stringencode_unittest.cc +++ b/rtc_base/stringencode_unittest.cc @@ -43,23 +43,23 @@ TEST_F(HexEncodeTest, TestWithNoDelimiter) { // Test that we can convert to/from hex with a colon delimiter. TEST_F(HexEncodeTest, TestWithDelimiter) { - enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), - data_, sizeof(data_), ':'); + enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), data_, + sizeof(data_), ':'); ASSERT_EQ(sizeof(data_) * 3 - 1, enc_res_); ASSERT_STREQ("80:81:82:83:84:85:86:87:88:89", encoded_); - dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), - encoded_, enc_res_, ':'); + dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), encoded_, + enc_res_, ':'); ASSERT_EQ(sizeof(data_), dec_res_); ASSERT_EQ(0, memcmp(data_, decoded_, dec_res_)); } // Test that encoding with one delimiter and decoding with another fails. TEST_F(HexEncodeTest, TestWithWrongDelimiter) { - enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), - data_, sizeof(data_), ':'); + enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), data_, + sizeof(data_), ':'); ASSERT_EQ(sizeof(data_) * 3 - 1, enc_res_); - dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), - encoded_, enc_res_, '/'); + dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), encoded_, + enc_res_, '/'); ASSERT_EQ(0U, dec_res_); } @@ -67,15 +67,15 @@ TEST_F(HexEncodeTest, TestWithWrongDelimiter) { TEST_F(HexEncodeTest, TestExpectedDelimiter) { enc_res_ = hex_encode(encoded_, sizeof(encoded_), data_, sizeof(data_)); ASSERT_EQ(sizeof(data_) * 2, enc_res_); - dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), - encoded_, enc_res_, ':'); + dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), encoded_, + enc_res_, ':'); ASSERT_EQ(0U, dec_res_); } // Test that encoding with a delimiter and decoding without one fails. TEST_F(HexEncodeTest, TestExpectedNoDelimiter) { - enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), - data_, sizeof(data_), ':'); + enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), data_, + sizeof(data_), ':'); ASSERT_EQ(sizeof(data_) * 3 - 1, enc_res_); dec_res_ = hex_decode(decoded_, sizeof(decoded_), encoded_, enc_res_); ASSERT_EQ(0U, dec_res_); @@ -93,8 +93,8 @@ TEST_F(HexEncodeTest, TestZeroLengthNoDelimiter) { TEST_F(HexEncodeTest, TestZeroLengthWithDelimiter) { enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(encoded_), "", 0, ':'); ASSERT_EQ(0U, enc_res_); - dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), - encoded_, enc_res_, ':'); + dec_res_ = hex_decode_with_delimiter(decoded_, sizeof(decoded_), encoded_, + enc_res_, ':'); ASSERT_EQ(0U, dec_res_); } @@ -118,15 +118,15 @@ TEST_F(HexEncodeTest, TestHelpersWithDelimiter) { // Test that encoding into a too-small output buffer (without delimiter) fails. TEST_F(HexEncodeTest, TestEncodeTooShort) { - enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(data_) * 2, - data_, sizeof(data_), 0); + enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(data_) * 2, data_, + sizeof(data_), 0); ASSERT_EQ(0U, enc_res_); } // Test that encoding into a too-small output buffer (with delimiter) fails. TEST_F(HexEncodeTest, TestEncodeWithDelimiterTooShort) { - enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(data_) * 3 - 1, - data_, sizeof(data_), ':'); + enc_res_ = hex_encode_with_delimiter(encoded_, sizeof(data_) * 3 - 1, data_, + sizeof(data_), ':'); ASSERT_EQ(0U, enc_res_); } diff --git a/rtc_base/stringize_macros_unittest.cc b/rtc_base/stringize_macros_unittest.cc index d1dea5e2bf..78e6b55b2d 100644 --- a/rtc_base/stringize_macros_unittest.cc +++ b/rtc_base/stringize_macros_unittest.cc @@ -18,15 +18,12 @@ #define PREPROCESSOR_UTIL_UNITTEST_C "foo" TEST(StringizeTest, Ansi) { - EXPECT_STREQ( - "PREPROCESSOR_UTIL_UNITTEST_A", - STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_A)); - EXPECT_STREQ( - "PREPROCESSOR_UTIL_UNITTEST_B(y)", - STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_B(y))); - EXPECT_STREQ( - "PREPROCESSOR_UTIL_UNITTEST_C", - STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_C)); + EXPECT_STREQ("PREPROCESSOR_UTIL_UNITTEST_A", + STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_A)); + EXPECT_STREQ("PREPROCESSOR_UTIL_UNITTEST_B(y)", + STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_B(y))); + EXPECT_STREQ("PREPROCESSOR_UTIL_UNITTEST_C", + STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_C)); EXPECT_STREQ("FOO", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_A)); EXPECT_STREQ("myobj->FunctionCall(y)", diff --git a/rtc_base/strings/audio_format_to_string.cc b/rtc_base/strings/audio_format_to_string.cc index 2d0b53b643..a149344198 100644 --- a/rtc_base/strings/audio_format_to_string.cc +++ b/rtc_base/strings/audio_format_to_string.cc @@ -13,40 +13,40 @@ #include "rtc_base/strings/string_builder.h" namespace rtc { - std::string ToString(const webrtc::SdpAudioFormat& saf) { - char sb_buf[1024]; - rtc::SimpleStringBuilder sb(sb_buf); - sb << "{name: " << saf.name; - sb << ", clockrate_hz: " << saf.clockrate_hz; - sb << ", num_channels: " << saf.num_channels; - sb << ", parameters: {"; - const char* sep = ""; - for (const auto& kv : saf.parameters) { - sb << sep << kv.first << ": " << kv.second; - sep = ", "; - } - sb << "}}"; - return sb.str(); - } - std::string ToString(const webrtc::AudioCodecInfo& aci) { - char sb_buf[1024]; - rtc::SimpleStringBuilder sb(sb_buf); - sb << "{sample_rate_hz: " << aci.sample_rate_hz; - sb << ", num_channels: " << aci.num_channels; - sb << ", default_bitrate_bps: " << aci.default_bitrate_bps; - sb << ", min_bitrate_bps: " << aci.min_bitrate_bps; - sb << ", max_bitrate_bps: " << aci.max_bitrate_bps; - sb << ", allow_comfort_noise: " << aci.allow_comfort_noise; - sb << ", supports_network_adaption: " << aci.supports_network_adaption; - sb << "}"; - return sb.str(); - } - std::string ToString(const webrtc::AudioCodecSpec& acs) { - char sb_buf[1024]; - rtc::SimpleStringBuilder sb(sb_buf); - sb << "{format: " << ToString(acs.format); - sb << ", info: " << ToString(acs.info); - sb << "}"; - return sb.str(); +std::string ToString(const webrtc::SdpAudioFormat& saf) { + char sb_buf[1024]; + rtc::SimpleStringBuilder sb(sb_buf); + sb << "{name: " << saf.name; + sb << ", clockrate_hz: " << saf.clockrate_hz; + sb << ", num_channels: " << saf.num_channels; + sb << ", parameters: {"; + const char* sep = ""; + for (const auto& kv : saf.parameters) { + sb << sep << kv.first << ": " << kv.second; + sep = ", "; } + sb << "}}"; + return sb.str(); +} +std::string ToString(const webrtc::AudioCodecInfo& aci) { + char sb_buf[1024]; + rtc::SimpleStringBuilder sb(sb_buf); + sb << "{sample_rate_hz: " << aci.sample_rate_hz; + sb << ", num_channels: " << aci.num_channels; + sb << ", default_bitrate_bps: " << aci.default_bitrate_bps; + sb << ", min_bitrate_bps: " << aci.min_bitrate_bps; + sb << ", max_bitrate_bps: " << aci.max_bitrate_bps; + sb << ", allow_comfort_noise: " << aci.allow_comfort_noise; + sb << ", supports_network_adaption: " << aci.supports_network_adaption; + sb << "}"; + return sb.str(); +} +std::string ToString(const webrtc::AudioCodecSpec& acs) { + char sb_buf[1024]; + rtc::SimpleStringBuilder sb(sb_buf); + sb << "{format: " << ToString(acs.format); + sb << ", info: " << ToString(acs.info); + sb << "}"; + return sb.str(); +} } // namespace rtc diff --git a/rtc_base/strings/audio_format_to_string.h b/rtc_base/strings/audio_format_to_string.h index de0ce16e66..6a4535c939 100644 --- a/rtc_base/strings/audio_format_to_string.h +++ b/rtc_base/strings/audio_format_to_string.h @@ -16,9 +16,9 @@ #include "api/audio_codecs/audio_format.h" namespace rtc { - std::string ToString(const webrtc::SdpAudioFormat& saf); - std::string ToString(const webrtc::AudioCodecInfo& saf); - std::string ToString(const webrtc::AudioCodecSpec& acs); +std::string ToString(const webrtc::SdpAudioFormat& saf); +std::string ToString(const webrtc::AudioCodecInfo& saf); +std::string ToString(const webrtc::AudioCodecSpec& acs); } // namespace rtc #endif // RTC_BASE_STRINGS_AUDIO_FORMAT_TO_STRING_H_ diff --git a/rtc_base/strings/string_builder.h b/rtc_base/strings/string_builder.h index d095385ab4..093954b361 100644 --- a/rtc_base/strings/string_builder.h +++ b/rtc_base/strings/string_builder.h @@ -55,7 +55,7 @@ class SimpleStringBuilder { // compatibility reasons. size_t size() const { return size_; } - // Allows appending a printf style formatted string. +// Allows appending a printf style formatted string. #if defined(__GNUC__) __attribute__((__format__(__printf__, 2, 3))) #endif diff --git a/rtc_base/stringutils.cc b/rtc_base/stringutils.cc index 7664bb8c54..bef128c229 100644 --- a/rtc_base/stringutils.cc +++ b/rtc_base/stringutils.cc @@ -10,8 +10,8 @@ #include #include -#include "rtc_base/stringutils.h" #include "rtc_base/checks.h" +#include "rtc_base/stringutils.h" namespace rtc { @@ -33,8 +33,8 @@ bool string_match(const char* target, const char* pattern) { return true; } while (*target) { - if ((toupper(*pattern) == toupper(*target)) - && string_match(target + 1, pattern + 1)) { + if ((toupper(*pattern) == toupper(*target)) && + string_match(target + 1, pattern + 1)) { return true; } ++target; @@ -52,25 +52,32 @@ bool string_match(const char* target, const char* pattern) { } #if defined(WEBRTC_WIN) -int ascii_string_compare(const wchar_t* s1, const char* s2, size_t n, +int ascii_string_compare(const wchar_t* s1, + const char* s2, + size_t n, CharacterTransformation transformation) { wchar_t c1, c2; while (true) { - if (n-- == 0) return 0; + if (n-- == 0) + return 0; c1 = transformation(*s1); // Double check that characters are not UTF-8 RTC_DCHECK_LT(*s2, 128); // Note: *s2 gets implicitly promoted to wchar_t c2 = transformation(*s2); - if (c1 != c2) return (c1 < c2) ? -1 : 1; - if (!c1) return 0; + if (c1 != c2) + return (c1 < c2) ? -1 : 1; + if (!c1) + return 0; ++s1; ++s2; } } -size_t asccpyn(wchar_t* buffer, size_t buflen, - const char* source, size_t srclen) { +size_t asccpyn(wchar_t* buffer, + size_t buflen, + const char* source, + size_t srclen) { if (buflen <= 0) return 0; @@ -91,11 +98,11 @@ size_t asccpyn(wchar_t* buffer, size_t buflen, #endif // WEBRTC_WIN -void replace_substrs(const char *search, +void replace_substrs(const char* search, size_t search_len, - const char *replace, + const char* replace, size_t replace_len, - std::string *s) { + std::string* s) { size_t pos = 0; while ((pos = s->find(search, pos, search_len)) != std::string::npos) { s->replace(pos, search_len, replace, replace_len); @@ -103,11 +110,11 @@ void replace_substrs(const char *search, } } -bool starts_with(const char *s1, const char *s2) { +bool starts_with(const char* s1, const char* s2) { return strncmp(s1, s2, strlen(s2)) == 0; } -bool ends_with(const char *s1, const char *s2) { +bool ends_with(const char* s1, const char* s2) { size_t s1_length = strlen(s1); size_t s2_length = strlen(s2); @@ -123,7 +130,7 @@ static const char kWhitespace[] = " \n\r\t"; std::string string_trim(const std::string& s) { std::string::size_type first = s.find_first_not_of(kWhitespace); - std::string::size_type last = s.find_last_not_of(kWhitespace); + std::string::size_type last = s.find_last_not_of(kWhitespace); if (first == std::string::npos || last == std::string::npos) { return std::string(""); diff --git a/rtc_base/stringutils.h b/rtc_base/stringutils.h index b42cfa57e0..d92ba0260f 100644 --- a/rtc_base/stringutils.h +++ b/rtc_base/stringutils.h @@ -37,7 +37,8 @@ // Generic string/memory utilities /////////////////////////////////////////////////////////////////////////////// -#define STACK_ARRAY(TYPE, LEN) static_cast(::alloca((LEN)*sizeof(TYPE))) +#define STACK_ARRAY(TYPE, LEN) \ + static_cast(::alloca((LEN) * sizeof(TYPE))) namespace rtc { @@ -88,7 +89,7 @@ namespace rtc { const size_t SIZE_UNKNOWN = static_cast(-1); -template +template struct Traits { // STL string type // typedef XXX string; @@ -105,10 +106,10 @@ inline const CTYPE* nonnull(const CTYPE* str, const CTYPE* def_str = nullptr) { return str ? str : (def_str ? def_str : Traits::empty_str()); } -template +template const CTYPE* strchr(const CTYPE* str, const CTYPE* chs) { - for (size_t i=0; str[i]; ++i) { - for (size_t j=0; chs[j]; ++j) { + for (size_t i = 0; str[i]; ++i) { + for (size_t j = 0; chs[j]; ++j) { if (str[i] == chs[j]) { return str + i; } @@ -117,9 +118,9 @@ const CTYPE* strchr(const CTYPE* str, const CTYPE* chs) { return 0; } -template +template const CTYPE* strchrn(const CTYPE* str, size_t slen, CTYPE ch) { - for (size_t i=0; i < slen && str[i]; ++i) { + for (size_t i = 0; i < slen && str[i]; ++i) { if (str[i] == ch) { return str + i; } @@ -127,7 +128,7 @@ const CTYPE* strchrn(const CTYPE* str, size_t slen, CTYPE ch) { return 0; } -template +template size_t strlenn(const CTYPE* buffer, size_t buflen) { size_t bufpos = 0; while (buffer[bufpos] && (bufpos < buflen)) { @@ -139,9 +140,11 @@ size_t strlenn(const CTYPE* buffer, size_t buflen) { // Safe versions of strncpy, strncat, snprintf and vsnprintf that always // null-terminate. -template -size_t strcpyn(CTYPE* buffer, size_t buflen, - const CTYPE* source, size_t srclen = SIZE_UNKNOWN) { +template +size_t strcpyn(CTYPE* buffer, + size_t buflen, + const CTYPE* source, + size_t srclen = SIZE_UNKNOWN) { if (buflen <= 0) return 0; @@ -155,9 +158,11 @@ size_t strcpyn(CTYPE* buffer, size_t buflen, return srclen; } -template -size_t strcatn(CTYPE* buffer, size_t buflen, - const CTYPE* source, size_t srclen = SIZE_UNKNOWN) { +template +size_t strcatn(CTYPE* buffer, + size_t buflen, + const CTYPE* source, + size_t srclen = SIZE_UNKNOWN) { if (buflen <= 0) return 0; @@ -167,8 +172,10 @@ size_t strcatn(CTYPE* buffer, size_t buflen, // Some compilers (clang specifically) require vsprintfn be defined before // sprintfn. -template -size_t vsprintfn(CTYPE* buffer, size_t buflen, const CTYPE* format, +template +size_t vsprintfn(CTYPE* buffer, + size_t buflen, + const CTYPE* format, va_list args) { int len = vsnprintf(buffer, buflen, format, args); if ((len < 0) || (static_cast(len) >= buflen)) { @@ -178,9 +185,9 @@ size_t vsprintfn(CTYPE* buffer, size_t buflen, const CTYPE* format, return len; } -template +template size_t sprintfn(CTYPE* buffer, size_t buflen, const CTYPE* format, ...); -template +template size_t sprintfn(CTYPE* buffer, size_t buflen, const CTYPE* format, ...) { va_list args; va_start(args, format); @@ -206,16 +213,22 @@ inline int ascncmp(const char* s1, const char* s2, size_t n) { inline int ascnicmp(const char* s1, const char* s2, size_t n) { return _strnicmp(s1, s2, n); } -inline size_t asccpyn(char* buffer, size_t buflen, - const char* source, size_t srclen = SIZE_UNKNOWN) { +inline size_t asccpyn(char* buffer, + size_t buflen, + const char* source, + size_t srclen = SIZE_UNKNOWN) { return strcpyn(buffer, buflen, source, srclen); } #if defined(WEBRTC_WIN) -typedef wchar_t(*CharacterTransformation)(wchar_t); -inline wchar_t identity(wchar_t c) { return c; } -int ascii_string_compare(const wchar_t* s1, const char* s2, size_t n, +typedef wchar_t (*CharacterTransformation)(wchar_t); +inline wchar_t identity(wchar_t c) { + return c; +} +int ascii_string_compare(const wchar_t* s1, + const char* s2, + size_t n, CharacterTransformation transformation); inline int asccmp(const wchar_t* s1, const char* s2) { @@ -230,8 +243,10 @@ inline int ascncmp(const wchar_t* s1, const char* s2, size_t n) { inline int ascnicmp(const wchar_t* s1, const char* s2, size_t n) { return ascii_string_compare(s1, s2, n, tolowercase); } -size_t asccpyn(wchar_t* buffer, size_t buflen, - const char* source, size_t srclen = SIZE_UNKNOWN); +size_t asccpyn(wchar_t* buffer, + size_t buflen, + const char* source, + size_t srclen = SIZE_UNKNOWN); #endif // WEBRTC_WIN @@ -239,7 +254,7 @@ size_t asccpyn(wchar_t* buffer, size_t buflen, // Traits specializations /////////////////////////////////////////////////////////////////////////////// -template<> +template <> struct Traits { typedef std::string string; inline static const char* empty_str() { return ""; } @@ -251,7 +266,7 @@ struct Traits { #if defined(WEBRTC_WIN) -template<> +template <> struct Traits { typedef std::wstring string; inline static const wchar_t* empty_str() { return L""; } @@ -297,17 +312,17 @@ inline std::string ToUtf8(const std::wstring& wstr) { #endif // WEBRTC_WIN // Replaces all occurrences of "search" with "replace". -void replace_substrs(const char *search, +void replace_substrs(const char* search, size_t search_len, - const char *replace, + const char* replace, size_t replace_len, - std::string *s); + std::string* s); // True iff s1 starts with s2. -bool starts_with(const char *s1, const char *s2); +bool starts_with(const char* s1, const char* s2); // True iff s1 ends with s2. -bool ends_with(const char *s1, const char *s2); +bool ends_with(const char* s1, const char* s2); // Remove leading and trailing whitespaces. std::string string_trim(const std::string& s); diff --git a/rtc_base/stringutils_unittest.cc b/rtc_base/stringutils_unittest.cc index bb0e7b5b0c..a6e64680bb 100644 --- a/rtc_base/stringutils_unittest.cc +++ b/rtc_base/stringutils_unittest.cc @@ -18,10 +18,10 @@ namespace rtc { TEST(string_matchTest, Matches) { EXPECT_TRUE(string_match("A.B.C.D", "a.b.c.d")); EXPECT_TRUE(string_match("www.TEST.GOOGLE.COM", "www.*.com")); - EXPECT_TRUE(string_match("127.0.0.1", "12*.0.*1")); + EXPECT_TRUE(string_match("127.0.0.1", "12*.0.*1")); EXPECT_TRUE(string_match("127.1.0.21", "12*.0.*1")); - EXPECT_FALSE(string_match("127.0.0.0", "12*.0.*1")); - EXPECT_FALSE(string_match("127.0.0.0", "12*.0.*1")); + EXPECT_FALSE(string_match("127.0.0.0", "12*.0.*1")); + EXPECT_FALSE(string_match("127.0.0.0", "12*.0.*1")); EXPECT_FALSE(string_match("127.1.1.21", "12*.0.*1")); } diff --git a/rtc_base/system/asm_defines.h b/rtc_base/system/asm_defines.h index e1c7453a9c..a7f6aad272 100644 --- a/rtc_base/system/asm_defines.h +++ b/rtc_base/system/asm_defines.h @@ -11,6 +11,10 @@ #ifndef RTC_BASE_SYSTEM_ASM_DEFINES_H_ #define RTC_BASE_SYSTEM_ASM_DEFINES_H_ +// clang-format off +// clang formatting breaks everything here, e.g. concatenating directives, +// due to absence of context via asm keyword. + #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits #endif @@ -63,4 +67,6 @@ strheq \reg1, \reg2, \num .text +// clang-format on + #endif // RTC_BASE_SYSTEM_ASM_DEFINES_H_ diff --git a/rtc_base/task_queue_gcd.cc b/rtc_base/task_queue_gcd.cc index a13e088ede..c7731dda3e 100644 --- a/rtc_base/task_queue_gcd.cc +++ b/rtc_base/task_queue_gcd.cc @@ -39,7 +39,7 @@ int TaskQueuePriorityToGCD(Priority priority) { return DISPATCH_QUEUE_PRIORITY_LOW; } } -} +} // namespace using internal::GetQueuePtrTls; using internal::AutoSetCurrentQueuePtr; diff --git a/rtc_base/task_queue_unittest.cc b/rtc_base/task_queue_unittest.cc index 51956d2f6f..cdf0d59b04 100644 --- a/rtc_base/task_queue_unittest.cc +++ b/rtc_base/task_queue_unittest.cc @@ -166,8 +166,7 @@ TEST(TaskQueueTest, PostMultipleDelayed) { std::vector> events; for (int i = 0; i < 100; ++i) { events.push_back(std::unique_ptr(new Event(false, false))); - queue.PostDelayedTask( - Bind(&CheckCurrent, events.back().get(), &queue), i); + queue.PostDelayedTask(Bind(&CheckCurrent, events.back().get(), &queue), i); } for (const auto& e : events) @@ -191,9 +190,9 @@ TEST(TaskQueueTest, PostAndReply) { TaskQueue post_queue(kPostQueue); TaskQueue reply_queue(kReplyQueue); - post_queue.PostTaskAndReply( - Bind(&CheckCurrent, nullptr, &post_queue), - Bind(&CheckCurrent, &event, &reply_queue), &reply_queue); + post_queue.PostTaskAndReply(Bind(&CheckCurrent, nullptr, &post_queue), + Bind(&CheckCurrent, &event, &reply_queue), + &reply_queue); EXPECT_TRUE(event.Wait(1000)); } @@ -372,12 +371,10 @@ TEST(TaskQueueTest, PostAndReplyDeadlock) { EXPECT_TRUE(event.Wait(1000)); } -void TestPostTaskAndReply(TaskQueue* work_queue, - Event* event) { +void TestPostTaskAndReply(TaskQueue* work_queue, Event* event) { ASSERT_FALSE(work_queue->IsCurrent()); - work_queue->PostTaskAndReply( - Bind(&CheckCurrent, nullptr, work_queue), - NewClosure([event]() { event->Set(); })); + work_queue->PostTaskAndReply(Bind(&CheckCurrent, nullptr, work_queue), + NewClosure([event]() { event->Set(); })); } // Does a PostTaskAndReply from within a task to post and reply to the current @@ -389,8 +386,7 @@ TEST(TaskQueueTest, PostAndReply2) { TaskQueue queue(kQueueName); TaskQueue work_queue(kWorkQueueName); - queue.PostTask( - Bind(&TestPostTaskAndReply, &work_queue, &event)); + queue.PostTask(Bind(&TestPostTaskAndReply, &work_queue, &event)); EXPECT_TRUE(event.Wait(1000)); } diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc index 5cc9f88d42..c1e7c4621c 100644 --- a/rtc_base/task_queue_win.cc +++ b/rtc_base/task_queue_win.cc @@ -10,13 +10,17 @@ #include "rtc_base/task_queue.h" +// clang-format off +// clang formating would change include order. + // Include winsock2.h before including to maintain consistency with // win32.h. To include win32.h directly, it must be broken out into its own // build target. #include #include -#include // Must come after windows headers. +#include // Must come after windows headers. #include // Must come after windows headers. +// clang-format on #include #include @@ -359,7 +363,7 @@ void TaskQueue::Impl::ThreadMain(void* context) { } void TaskQueue::Impl::ThreadState::RunThreadMain() { - HANDLE handles[2] = { *timer_.event_for_wait(), in_queue_ }; + HANDLE handles[2] = {*timer_.event_for_wait(), in_queue_}; while (true) { // Make sure we do an alertable wait as that's required to allow APCs to run // (e.g. required for InitializeQueueThread and stopping the thread in @@ -373,8 +377,9 @@ void TaskQueue::Impl::ThreadState::RunThreadMain() { break; } - if (result == WAIT_OBJECT_0 || (!timer_tasks_.empty() && - ::WaitForSingleObject(*timer_.event_for_wait(), 0) == WAIT_OBJECT_0)) { + if (result == WAIT_OBJECT_0 || + (!timer_tasks_.empty() && + ::WaitForSingleObject(*timer_.event_for_wait(), 0) == WAIT_OBJECT_0)) { // The multimedia timer was signaled. timer_.Cancel(); RunDueTasks(); diff --git a/rtc_base/template_util.h b/rtc_base/template_util.h index 04e5e37fc0..3c04a860d8 100644 --- a/rtc_base/template_util.h +++ b/rtc_base/template_util.h @@ -19,34 +19,47 @@ namespace rtc { // Template definitions from tr1. -template +template struct integral_constant { static const T value = v; typedef T value_type; typedef integral_constant type; }; -template const T integral_constant::value; +template +const T integral_constant::value; typedef integral_constant true_type; typedef integral_constant false_type; -template struct is_pointer : false_type {}; -template struct is_pointer : true_type {}; +template +struct is_pointer : false_type {}; +template +struct is_pointer : true_type {}; -template struct is_same : public false_type {}; -template struct is_same : true_type {}; +template +struct is_same : public false_type {}; +template +struct is_same : true_type {}; -template struct is_array : public false_type {}; -template struct is_array : public true_type {}; -template struct is_array : public true_type {}; +template +struct is_array : public false_type {}; +template +struct is_array : public true_type {}; +template +struct is_array : public true_type {}; -template struct is_non_const_reference : false_type {}; -template struct is_non_const_reference : true_type {}; -template struct is_non_const_reference : false_type {}; +template +struct is_non_const_reference : false_type {}; +template +struct is_non_const_reference : true_type {}; +template +struct is_non_const_reference : false_type {}; -template struct is_void : false_type {}; -template <> struct is_void : true_type {}; +template +struct is_void : false_type {}; +template <> +struct is_void : true_type {}; // Helper useful for converting a tuple to variadic template function // arguments. @@ -95,7 +108,7 @@ struct ConvertHelper { // is_class type_trait implementation. struct IsClassHelper { template - static YesType Test(void(C::*)(void)); + static YesType Test(void (C::*)(void)); template static NoType Test(...); @@ -111,16 +124,14 @@ template struct is_convertible : integral_constant( - internal::ConvertHelper::Create())) == - sizeof(internal::YesType)> { -}; + internal::ConvertHelper::Create())) == + sizeof(internal::YesType)> {}; template struct is_class : integral_constant(0)) == - sizeof(internal::YesType)> { -}; + sizeof(internal::YesType)> {}; } // namespace rtc diff --git a/rtc_base/testbase64.h b/rtc_base/testbase64.h index dbbdec9fe4..5dc94b6cbc 100644 --- a/rtc_base/testbase64.h +++ b/rtc_base/testbase64.h @@ -14,7 +14,2098 @@ /* This file was generated by googleclient/talk/binary2header.sh */ static unsigned char testbase64[] = { -0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xe1, 0x0d, 0x07, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x01, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x9e, 0x01, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xbe, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xc3, 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xcc, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd4, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xdc, 0x01, 0x32, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x3c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x04, 0x02, 0x13, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x02, 0xc4, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x53, 0x4f, 0x4e, 0x59, 0x00, 0x44, 0x53, 0x43, 0x2d, 0x50, 0x32, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x20, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x20, 0x37, 0x2e, 0x30, 0x00, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, 0x33, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x31, 0x30, 0x3a, 0x30, 0x34, 0x00, 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58, 0x20, 0x31, 0x30, 0x2e, 0x34, 0x2e, 0x38, 0x00, 0x00, 0x1c, 0x82, 0x9a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x6a, 0x82, 0x9d, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x72, 0x88, 0x22, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x88, 0x27, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x64, 0x00, 0x00, 0x90, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, 0x32, 0x32, 0x30, 0x90, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x7a, 0x90, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x8e, 0x91, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x00, 0x91, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xa2, 0x92, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xaa, 0x92, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xb2, 0x92, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x92, 0x08, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x92, 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xba, 0xa0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, 0x31, 0x30, 0x30, 0xa0, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0xa0, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0xa3, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0xa3, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x08, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x0a, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0a, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, 0x32, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x30, 0x35, 0x3a, 0x35, 0x32, 0x00, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, 0x32, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x30, 0x35, 0x3a, 0x35, 0x32, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x12, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x1a, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x22, 0x02, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x09, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xed, 0x00, 0x0c, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x5f, 0x43, 0x4d, 0x00, 0x02, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, 0x64, 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0c, 0x08, 0x08, 0x08, 0x09, 0x08, 0x0c, 0x09, 0x09, 0x0c, 0x11, 0x0b, 0x0a, 0x0b, 0x11, 0x15, 0x0f, 0x0c, 0x0c, 0x0f, 0x15, 0x18, 0x13, 0x13, 0x15, 0x13, 0x13, 0x18, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x01, 0x0d, 0x0b, 0x0b, 0x0d, 0x0e, 0x0d, 0x10, 0x0e, 0x0e, 0x10, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x07, 0xff, 0xc4, 0x01, 0x3f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x01, 0x04, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x07, 0x06, 0x08, 0x05, 0x03, 0x0c, 0x33, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, 0x31, 0x05, 0x41, 0x51, 0x61, 0x13, 0x22, 0x71, 0x81, 0x32, 0x06, 0x14, 0x91, 0xa1, 0xb1, 0x42, 0x23, 0x24, 0x15, 0x52, 0xc1, 0x62, 0x33, 0x34, 0x72, 0x82, 0xd1, 0x43, 0x07, 0x25, 0x92, 0x53, 0xf0, 0xe1, 0xf1, 0x63, 0x73, 0x35, 0x16, 0xa2, 0xb2, 0x83, 0x26, 0x44, 0x93, 0x54, 0x64, 0x45, 0xc2, 0xa3, 0x74, 0x36, 0x17, 0xd2, 0x55, 0xe2, 0x65, 0xf2, 0xb3, 0x84, 0xc3, 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x27, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x11, 0x00, 0x02, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x06, 0x05, 0x35, 0x01, 0x00, 0x02, 0x11, 0x03, 0x21, 0x31, 0x12, 0x04, 0x41, 0x51, 0x61, 0x71, 0x22, 0x13, 0x05, 0x32, 0x81, 0x91, 0x14, 0xa1, 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xf0, 0x33, 0x24, 0x62, 0xe1, 0x72, 0x82, 0x92, 0x43, 0x53, 0x15, 0x63, 0x73, 0x34, 0xf1, 0x25, 0x06, 0x16, 0xa2, 0xb2, 0x83, 0x07, 0x26, 0x35, 0xc2, 0xd2, 0x44, 0x93, 0x54, 0xa3, 0x17, 0x64, 0x45, 0x55, 0x36, 0x74, 0x65, 0xe2, 0xf2, 0xb3, 0x84, 0xc3, 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf2, 0xed, 0xb2, 0x8d, 0x4d, 0x45, 0xcd, 0x2f, 0x3f, 0x44, 0x68, 0x93, 0xc3, 0x58, 0xc8, 0xf1, 0x1f, 0x8a, 0x33, 0x86, 0xda, 0x58, 0xc1, 0xa0, 0x02, 0x4f, 0xc4, 0xa1, 0x69, 0xa5, 0x9b, 0x5b, 0x4b, 0x84, 0x73, 0xdf, 0xc9, 0x15, 0xf8, 0xe3, 0xd1, 0x0e, 0x07, 0x93, 0xf3, 0xd1, 0x0f, 0x1c, 0x17, 0xef, 0x2e, 0x3b, 0x5b, 0xdc, 0xff, 0x00, 0xdf, 0x42, 0xbf, 0x8f, 0x8e, 0xdc, 0x82, 0xca, 0xd8, 0x37, 0x11, 0xa9, 0x3d, 0x82, 0x69, 0x2b, 0xc4, 0x6d, 0xc9, 0x75, 0x25, 0xbc, 0xf7, 0xec, 0xa1, 0xb5, 0x74, 0x19, 0x5d, 0x2e, 0x8a, 0x9a, 0x4b, 0x89, 0x7d, 0xc4, 0x68, 0xc6, 0xf6, 0xfe, 0xb2, 0xa0, 0x30, 0x1d, 0x60, 0x86, 0x88, 0x8d, 0x49, 0x3e, 0x01, 0x11, 0x20, 0xa3, 0x8c, 0xb9, 0xb1, 0xaa, 0x62, 0xad, 0xbf, 0x18, 0x97, 0x43, 0x47, 0x1d, 0xd2, 0xaf, 0x04, 0xd9, 0xb8, 0xc8, 0x0d, 0x68, 0xe4, 0xf7, 0x3e, 0x48, 0xf1, 0x05, 0xbc, 0x25, 0xaa, 0x07, 0x71, 0xd9, 0x14, 0x78, 0xf6, 0x49, 0xb5, 0x90, 0xfd, 0xa7, 0xc6, 0x14, 0xfd, 0x1b, 0x1c, 0xff, 0x00, 0x4d, 0x8d, 0x2e, 0x73, 0x8c, 0x35, 0xa3, 0x52, 0x4f, 0x92, 0x48, 0xa6, 0x1a, 0x24, 0xb6, 0x2a, 0xfa, 0xa5, 0x9e, 0x60, 0x64, 0x39, 0x94, 0x13, 0xcb, 0x27, 0x73, 0x80, 0xf3, 0x0c, 0xf6, 0xff, 0x00, 0xd2, 0x5a, 0x78, 0xbf, 0x53, 0x71, 0xf6, 0x01, 0x75, 0xb6, 0x97, 0x6a, 0x25, 0xa1, 0xad, 0x1f, 0xf4, 0xb7, 0x23, 0x48, 0xb7, 0x94, 0x84, 0x97, 0x5b, 0xff, 0x00, 0x32, 0xa9, 0xdd, 0xfc, 0xed, 0x9b, 0x7e, 0x0d, 0x9e, 0x52, 0x4a, 0x95, 0x61, 0xff, 0xd0, 0xf3, 0x3b, 0xa7, 0x70, 0xee, 0x01, 0x8f, 0xb9, 0x59, 0xfa, 0x7e, 0xdf, 0xe4, 0xc8, 0xf9, 0x2a, 0xc2, 0x5c, 0x63, 0xc3, 0x54, 0x67, 0x87, 0x6e, 0x10, 0x35, 0x68, 0xd4, 0x79, 0x1e, 0x53, 0x4a, 0xe0, 0xdc, 0xe9, 0xb8, 0x1f, 0x6a, 0xda, 0x6c, 0x25, 0x94, 0x37, 0xb0, 0xd0, 0xb8, 0xad, 0x67, 0xe4, 0x55, 0x8a, 0x5b, 0x8b, 0x82, 0xc0, 0x6f, 0x76, 0x80, 0x34, 0x49, 0x05, 0x2e, 0x9e, 0xc6, 0x1c, 0x66, 0x31, 0xba, 0x10, 0x23, 0xe0, 0xaf, 0xe1, 0x61, 0x53, 0x43, 0x8d, 0x81, 0xb3, 0x67, 0xef, 0x9e, 0x49, 0x2a, 0x12, 0x6c, 0xb6, 0x63, 0x1a, 0x0c, 0x31, 0xba, 0x55, 0xcd, 0xac, 0xfa, 0x8e, 0xdf, 0x91, 0x6e, 0x91, 0xd9, 0xb3, 0xc9, 0x73, 0x90, 0x7a, 0xab, 0x6a, 0xc2, 0xa4, 0x60, 0xe2, 0x8f, 0xd2, 0x38, 0x03, 0x7d, 0x9e, 0x0d, 0xff, 0x00, 0xcc, 0xd6, 0xd3, 0x6b, 0x71, 0x67, 0xd2, 0x3e, 0x64, 0x72, 0xab, 0xdb, 0x8d, 0x54, 0x39, 0xc5, 0x83, 0x6b, 0x3d, 0xee, 0x2e, 0xd4, 0x92, 0x3c, 0x4a, 0x56, 0xba, 0xb4, 0x79, 0x5c, 0xf7, 0xb2, 0x96, 0x6c, 0x8d, 0xaf, 0x80, 0x48, 0x3c, 0xf0, 0xb2, 0x1f, 0x63, 0x9c, 0xe9, 0x3f, 0x24, 0x5c, 0xdb, 0xdd, 0x76, 0x43, 0xde, 0xfd, 0x5c, 0xe3, 0x24, 0xfc, 0x50, 0x00, 0x93, 0x0a, 0x78, 0x8a, 0x0d, 0x49, 0xca, 0xcf, 0x93, 0x63, 0x1b, 0x7d, 0xd7, 0x57, 0x50, 0xd5, 0xef, 0x70, 0x6b, 0x4f, 0xc7, 0x45, 0xdb, 0x74, 0x9e, 0x8d, 0x5e, 0x33, 0x83, 0xd8, 0x37, 0xdd, 0xc3, 0xac, 0x3d, 0xbf, 0x92, 0xc5, 0x5b, 0xea, 0xbf, 0xd5, 0x62, 0xc0, 0xdc, 0xbc, 0xbd, 0x2d, 0x22, 0x5a, 0xcf, 0xdd, 0x69, 0xff, 0x00, 0xd1, 0x8e, 0x5d, 0xa5, 0x38, 0xb5, 0xb0, 0x00, 0xc6, 0xc4, 0x24, 0x4a, 0xd6, 0x8d, 0x18, 0x04, 0x49, 0x88, 0x9e, 0x55, 0xd6, 0x61, 0xb0, 0xc1, 0x70, 0x32, 0xdd, 0x3c, 0x95, 0xda, 0xf1, 0xfe, 0xf5, 0x62, 0xbc, 0x76, 0x8e, 0x75, 0x28, 0x02, 0xa2, 0xe7, 0x7d, 0x92, 0xb9, 0x84, 0x96, 0x96, 0xda, 0xf7, 0x70, 0x12, 0x4e, 0x5a, 0xff, 0x00, 0xff, 0xd1, 0xf3, 0x7a, 0x21, 0xaf, 0xde, 0xef, 0xa2, 0x22, 0x55, 0xfc, 0x5a, 0xbd, 0x42, 0xfb, 0x08, 0xfa, 0x67, 0x4f, 0x82, 0xcd, 0x6d, 0x85, 0xc0, 0x56, 0x3b, 0x90, 0xb7, 0xf0, 0x2a, 0x0e, 0x63, 0x58, 0x3b, 0xf2, 0xa3, 0x9e, 0x8c, 0xb8, 0x86, 0xbe, 0x49, 0xf1, 0x2c, 0x0c, 0x86, 0xb4, 0x4c, 0x69, 0xe4, 0xaf, 0x6e, 0xcc, 0x6b, 0x7d, 0x46, 0xb3, 0x70, 0xec, 0x38, 0x51, 0x7d, 0x02, 0x8a, 0xc7, 0xa6, 0xd9, 0x20, 0x68, 0x0f, 0x8f, 0x8a, 0xcf, 0xc9, 0xc2, 0xea, 0x59, 0x5b, 0x48, 0xb0, 0x91, 0xae, 0xe6, 0xc9, 0x03, 0xc9, 0x30, 0x51, 0x66, 0xd4, 0x0d, 0xad, 0xbd, 0x5f, 0x53, 0xcc, 0x6b, 0xb6, 0x90, 0x5a, 0x3b, 0x83, 0x0b, 0x43, 0x17, 0x31, 0xd6, 0xc3, 0x6e, 0x12, 0x3b, 0x79, 0xac, 0xc1, 0x89, 0x47, 0xd9, 0xe8, 0x63, 0x98, 0x45, 0xed, 0x6c, 0x5a, 0xf1, 0xa0, 0x27, 0xc5, 0x5b, 0xc3, 0x6f, 0xa6, 0xe0, 0x1c, 0x7d, 0xb3, 0xa2, 0x69, 0x34, 0x7b, 0xae, 0x1a, 0x8d, 0x45, 0x17, 0x9d, 0xeb, 0xfd, 0x21, 0xd8, 0xb9, 0xae, 0xb5, 0x80, 0xbb, 0x1e, 0xd2, 0x5c, 0xd7, 0x78, 0x13, 0xf9, 0xae, 0x4b, 0xea, 0xc7, 0x4a, 0x39, 0xbd, 0x55, 0xb3, 0xed, 0x66, 0x38, 0xf5, 0x09, 0x22, 0x41, 0x23, 0xe8, 0x37, 0xfb, 0x4b, 0xa1, 0xeb, 0xd6, 0xfe, 0x88, 0x31, 0xbf, 0x41, 0xc0, 0xee, 0xd2, 0x74, 0x02, 0x78, 0x53, 0xfa, 0x97, 0x43, 0x19, 0x85, 0x65, 0xff, 0x00, 0x9d, 0x71, 0x33, 0xe4, 0x1a, 0x7d, 0x8d, 0x53, 0x42, 0x56, 0x35, 0x6b, 0xe5, 0x80, 0x06, 0xc7, 0x57, 0xa7, 0xc4, 0xa9, 0xdb, 0xb6, 0x81, 0x1f, 0xeb, 0xd9, 0x69, 0x56, 0xc2, 0xd0, 0x00, 0xe5, 0x55, 0xc0, 0x12, 0xc2, 0xd7, 0x4e, 0xa2, 0x5a, 0x7c, 0x0a, 0xd0, 0x63, 0x9a, 0xd1, 0xaf, 0xd2, 0xe2, 0x3c, 0x12, 0x62, 0x66, 0xc6, 0x42, 0x23, 0x5a, 0x49, 0x8f, 0x10, 0xa2, 0xd2, 0x3e, 0x28, 0x9d, 0xc4, 0x88, 0x09, 0x29, 0x16, 0xc3, 0x3c, 0x24, 0x8d, 0xe6, 0x92, 0x72, 0x1f, 0xff, 0xd2, 0xf3, 0xbb, 0xb0, 0xfe, 0xcb, 0x99, 0xe9, 0xce, 0xf6, 0x88, 0x2d, 0x77, 0x91, 0x5b, 0x3d, 0x3d, 0xd0, 0xe6, 0x90, 0xa9, 0x65, 0x57, 0x38, 0x95, 0xdd, 0xcb, 0x9a, 0x7d, 0xce, 0xf2, 0x3f, 0x44, 0x23, 0x60, 0x58, 0x76, 0xe9, 0xca, 0x8c, 0xea, 0x1b, 0x31, 0x02, 0x32, 0x23, 0xea, 0xee, 0xb1, 0xcd, 0xb0, 0xc7, 0x87, 0x74, 0x7a, 0xeb, 0x70, 0x1a, 0x71, 0xe1, 0xfe, 0xe4, 0x1c, 0x1d, 0xae, 0xe5, 0x69, 0xd8, 0xfa, 0x99, 0x50, 0x0d, 0x1a, 0xf7, 0x2a, 0x3a, 0x0c, 0xf4, 0x1a, 0x8e, 0xc7, 0x27, 0x5d, 0xbf, 0x18, 0x41, 0xdc, 0xc2, 0xf0, 0x7f, 0x74, 0xf6, 0x3a, 0x22, 0x66, 0xdb, 0x68, 0xc6, 0x80, 0x48, 0x6b, 0x88, 0x06, 0x39, 0x0d, 0xee, 0xaa, 0x1f, 0xb3, 0xd5, 0x1b, 0x83, 0xd8, 0x3b, 0x38, 0x8f, 0x69, 0xfe, 0xdf, 0xd1, 0x4d, 0x29, 0xa1, 0x4c, 0x7a, 0xf4, 0xbf, 0xa7, 0x92, 0xcf, 0xa5, 0x20, 0x08, 0xf3, 0xf6, 0xff, 0x00, 0x15, 0xbb, 0xd1, 0x31, 0xd9, 0x5e, 0x3d, 0x75, 0x56, 0x36, 0x88, 0x00, 0x81, 0xe0, 0x16, 0x5e, 0x55, 0x74, 0x3f, 0x00, 0x9d, 0xe0, 0xcc, 0x69, 0xe7, 0x3a, 0x2d, 0xbe, 0x90, 0x00, 0xa9, 0xae, 0xef, 0x1f, 0x95, 0x4b, 0x0d, 0x9a, 0xdc, 0xc7, 0x45, 0xfe, 0xb1, 0x7d, 0x60, 0xa7, 0xa1, 0xe0, 0x1f, 0x4e, 0x1d, 0x99, 0x69, 0x02, 0x9a, 0xcf, 0x1f, 0xca, 0x7b, 0xbf, 0x90, 0xc5, 0xc2, 0xb3, 0xeb, 0x57, 0xd6, 0x03, 0x6b, 0xae, 0x39, 0xb6, 0x82, 0xe3, 0x31, 0xa1, 0x68, 0xf2, 0x6b, 0x5c, 0x12, 0xfa, 0xe1, 0x91, 0x66, 0x47, 0x5d, 0xb8, 0x3b, 0x4f, 0x44, 0x36, 0xb6, 0x8f, 0x28, 0xdd, 0xff, 0x00, 0x7e, 0x46, 0xab, 0x12, 0x2b, 0x65, 0x55, 0x32, 0xa7, 0x62, 0xb6, 0xbd, 0xf7, 0x64, 0x10, 0xdb, 0x03, 0x9f, 0x1b, 0x9e, 0xc7, 0xd9, 0xb8, 0x3b, 0x1f, 0x67, 0xf3, 0x6c, 0x52, 0x80, 0xd7, 0x7d, 0x0f, 0xea, 0x7f, 0x5d, 0x1d, 0x67, 0xa6, 0x0b, 0x1e, 0x47, 0xda, 0x69, 0x3b, 0x2e, 0x03, 0xc7, 0xf3, 0x5f, 0x1f, 0xf0, 0x8b, 0xa1, 0x02, 0x46, 0xba, 0x79, 0xaf, 0x32, 0xff, 0x00, 0x16, 0xad, 0xca, 0x1d, 0x57, 0x2a, 0xdc, 0x79, 0x18, 0x41, 0xb0, 0xf6, 0x9e, 0xe4, 0x9f, 0xd0, 0x8f, 0xeb, 0x31, 0xab, 0xd2, 0x83, 0xa4, 0xcb, 0x8c, 0xb8, 0xa0, 0x42, 0x12, 0x7b, 0x67, 0x9f, 0x2f, 0xf5, 0x09, 0x26, 0x96, 0xc4, 0xce, 0xa9, 0x20, 0xa7, 0xff, 0xd3, 0xf3, 0x2f, 0xb4, 0x5d, 0xe9, 0x0a, 0xb7, 0x9f, 0x4c, 0x19, 0xdb, 0x3a, 0x2d, 0x5e, 0x94, 0xfd, 0xc4, 0xb7, 0xc5, 0x62, 0xf9, 0x2b, 0xfd, 0x2e, 0xe3, 0x5d, 0xe0, 0x7c, 0x13, 0x48, 0xd1, 0x92, 0x12, 0xa9, 0x0b, 0x7a, 0xbc, 0x2d, 0xc2, 0x7f, 0x92, 0x60, 0xab, 0x4e, 0x79, 0x2e, 0x00, 0xf0, 0xaa, 0xe1, 0xda, 0x3d, 0x43, 0xfc, 0xad, 0x55, 0xbb, 0x80, 0x79, 0x81, 0xa0, 0xe6, 0x54, 0x32, 0x6d, 0x02, 0xbe, 0xf3, 0x61, 0x81, 0xa8, 0x44, 0x14, 0x03, 0x59, 0x0e, 0x1c, 0xf6, 0x1f, 0xdc, 0xb2, 0xec, 0xa3, 0x23, 0x77, 0xe8, 0x6e, 0x70, 0xf2, 0x25, 0x1f, 0x1f, 0x17, 0xa9, 0x6d, 0x71, 0x36, 0x97, 0x47, 0x00, 0xa4, 0x02, 0xe0, 0x2c, 0x7c, 0xc1, 0xab, 0xd5, 0x31, 0x85, 0x35, 0xd4, 0xe6, 0x13, 0x02, 0xd6, 0x4b, 0x67, 0x48, 0x2b, 0xa9, 0xe9, 0x2e, 0x02, 0xb6, 0x4f, 0x82, 0xe5, 0x7a, 0x95, 0x19, 0xc6, 0x87, 0x3d, 0xfb, 0xa2, 0xb8, 0x79, 0x1e, 0x4d, 0x3b, 0x96, 0xcf, 0x4f, 0xbd, 0xcd, 0xa2, 0xa2, 0x1f, 0xa0, 0x82, 0xd3, 0xfc, 0x97, 0x05, 0x24, 0x36, 0x6b, 0xf3, 0x31, 0xa2, 0x35, 0x79, 0xef, 0xad, 0xf8, 0xae, 0xaf, 0xaf, 0xd8, 0xf2, 0xd8, 0x6d, 0xed, 0x6b, 0xda, 0x7b, 0x18, 0x1b, 0x5d, 0xff, 0x00, 0x52, 0xb1, 0x6d, 0xf0, 0x81, 0x31, 0xca, 0xf4, 0x6e, 0xb1, 0x80, 0xce, 0xb1, 0x84, 0xc0, 0x21, 0xb7, 0xd6, 0x77, 0x31, 0xd1, 0x27, 0xc1, 0xcd, 0xfe, 0xd2, 0xe3, 0xec, 0xe8, 0x1d, 0x45, 0x96, 0xb0, 0x9a, 0xb7, 0x87, 0x3f, 0x68, 0x2d, 0xf7, 0x01, 0x1f, 0xbe, 0xd1, 0xf4, 0x7f, 0xb4, 0xa4, 0x0d, 0x77, 0xbb, 0xfa, 0x8f, 0x80, 0x3a, 0x7f, 0x43, 0xaa, 0xe2, 0xdf, 0xd2, 0x65, 0x7e, 0x95, 0xe4, 0x0f, 0x1f, 0xa1, 0xfe, 0x6b, 0x16, 0x9f, 0x52, 0xfa, 0xc1, 0xd3, 0xba, 0x6d, 0x26, 0xdc, 0xac, 0x86, 0xd4, 0xd9, 0x0d, 0x31, 0x2e, 0x74, 0x9e, 0xdb, 0x59, 0x2e, 0x55, 0xe8, 0xc9, 0xb2, 0x96, 0xd5, 0x4b, 0x9f, 0xb8, 0x6d, 0xda, 0x1c, 0x04, 0x09, 0x03, 0xfe, 0x8a, 0xc6, 0xfa, 0xd3, 0xf5, 0x6a, 0xbe, 0xbb, 0x5b, 0x2e, 0xc6, 0xb5, 0x94, 0xe6, 0xd5, 0x20, 0x97, 0x7d, 0x1b, 0x1b, 0xf9, 0xad, 0x7c, 0x7d, 0x17, 0xb7, 0xf3, 0x1e, 0x92, 0x1b, 0x7f, 0xf8, 0xe0, 0x7d, 0x59, 0xdd, 0xfd, 0x32, 0xd8, 0x8f, 0xa5, 0xe8, 0x3a, 0x12, 0x5c, 0x3f, 0xfc, 0xc4, 0xfa, 0xc3, 0xb3, 0x77, 0xa7, 0x56, 0xed, 0xdb, 0x76, 0x7a, 0x8d, 0xdd, 0x1f, 0xbf, 0xfd, 0x44, 0x92, 0x56, 0x8f, 0xff, 0xd4, 0xf2, 0xe8, 0x86, 0x17, 0x1e, 0xfa, 0x04, 0x56, 0x4b, 0x43, 0x6c, 0x6f, 0x2d, 0xe5, 0x46, 0x01, 0x64, 0x2b, 0x14, 0x32, 0x5b, 0xb4, 0xa0, 0x52, 0x1d, 0xde, 0x9b, 0x94, 0xdb, 0xab, 0x6b, 0x81, 0xf7, 0x05, 0xb0, 0xd7, 0x07, 0xb2, 0x27, 0x55, 0xc6, 0x57, 0x65, 0xd8, 0x76, 0x6e, 0x64, 0xed, 0xee, 0x16, 0xce, 0x27, 0x57, 0x63, 0xda, 0x0c, 0xc2, 0x8e, 0x51, 0x67, 0x84, 0xfa, 0x1d, 0xdd, 0x62, 0xc7, 0x07, 0xe9, 0xf7, 0xa3, 0xd6, 0x6c, 0x02, 0x41, 0x55, 0x31, 0xf3, 0x2b, 0xb3, 0xba, 0x2b, 0x2e, 0x68, 0x24, 0x1d, 0x47, 0x64, 0xca, 0xa6, 0x50, 0x41, 0x65, 0x90, 0x6c, 0xb1, 0xa5, 0xae, 0x33, 0x23, 0x51, 0xe4, 0xab, 0x7d, 0x5d, 0xcb, 0xb6, 0xcc, 0x37, 0xd0, 0x40, 0x73, 0x71, 0xde, 0x58, 0x09, 0xe7, 0x6f, 0x2c, 0x44, 0xc9, 0xc9, 0xae, 0xba, 0x9d, 0x63, 0x88, 0x01, 0xa0, 0x95, 0x9d, 0xf5, 0x3f, 0x2a, 0xe6, 0x67, 0xdb, 0x50, 0x83, 0x55, 0xad, 0x36, 0x3e, 0x78, 0x10, 0x74, 0x77, 0xfd, 0x2d, 0xaa, 0x4c, 0x7d, 0x58, 0x73, 0x91, 0xa0, 0x0f, 0x51, 0x45, 0xb7, 0x33, 0xdd, 0x58, 0x69, 0x1d, 0xd8, 0x0c, 0x9f, 0x96, 0x88, 0x19, 0x99, 0x19, 0xac, 0xcf, 0xa3, 0xd2, 0xad, 0xb5, 0xdb, 0x76, 0x8f, 0xad, 0xc4, 0xea, 0xcf, 0xdf, 0x7e, 0xdf, 0xdd, 0xfc, 0xd5, 0xa3, 0x5e, 0x43, 0x2b, 0x6b, 0xb2, 0xad, 0x3b, 0x6a, 0xa4, 0x13, 0xa7, 0x04, 0xac, 0x7a, 0x6f, 0xb3, 0x23, 0x26, 0xcc, 0xfb, 0xb4, 0x75, 0x8e, 0x01, 0x83, 0xf7, 0x58, 0x3e, 0x8b, 0x53, 0xa7, 0x2a, 0x1a, 0x31, 0x42, 0x36, 0x5d, 0x4c, 0x9a, 0xf2, 0xdc, 0xc6, 0xfe, 0x98, 0xb4, 0x34, 0xcb, 0x48, 0x0a, 0x8f, 0xdb, 0xb2, 0xeb, 0x76, 0xd6, 0x07, 0x5c, 0x59, 0xc9, 0x64, 0x8f, 0x93, 0xa7, 0x73, 0x16, 0x83, 0xaf, 0x0e, 0xa4, 0x33, 0xef, 0x50, 0xc5, 0x0c, 0xda, 0x59, 0x10, 0x06, 0x8a, 0x2e, 0x29, 0x0e, 0xac, 0xc2, 0x31, 0x3d, 0x36, 0x69, 0x7e, 0xd6, 0xcc, 0xf5, 0x3d, 0x6f, 0xb3, 0xeb, 0x1b, 0x76, 0xef, 0x3b, 0xa3, 0xfa, 0xc9, 0x2b, 0x5f, 0x66, 0x6f, 0xa9, 0x1e, 0x73, 0xf2, 0x49, 0x2e, 0x39, 0xf7, 0x4f, 0xb7, 0x8d, 0xff, 0xd5, 0xf3, 0x26, 0xfe, 0x0a, 0xc5, 0x1b, 0xa7, 0xcb, 0xb2, 0xcf, 0x49, 0x03, 0xb2, 0x46, 0xee, 0xd9, 0xd9, 0xb3, 0xf4, 0x9f, 0x25, 0x4a, 0xdf, 0x4b, 0x77, 0xe8, 0x27, 0xd4, 0xef, 0x1c, 0x2a, 0x29, 0x26, 0xc5, 0x7c, 0x9d, 0x6c, 0x7f, 0xb7, 0x6e, 0x1b, 0x26, 0x7f, 0x05, 0xa3, 0xfe, 0x53, 0x8d, 0x62, 0x57, 0x30, 0x92, 0x12, 0xfa, 0x2f, 0x86, 0xdf, 0xa4, 0xec, 0x67, 0xfe, 0xd0, 0xf4, 0xff, 0x00, 0x4d, 0xfc, 0xdf, 0x78, 0xe1, 0x68, 0x7d, 0x54, 0x99, 0xbf, 0x6f, 0xf3, 0xbe, 0xdf, 0x8e, 0xdd, 0x7f, 0xef, 0xeb, 0x97, 0x49, 0x3e, 0x3b, 0x7f, 0x06, 0x2c, 0x9f, 0x37, 0x5f, 0xf0, 0x9f, 0x4c, 0xeb, 0x7b, 0xbf, 0x67, 0x55, 0xe8, 0xff, 0x00, 0x31, 0xbc, 0x7a, 0x9e, 0x31, 0xdb, 0xfe, 0x92, 0xae, 0x37, 0x7a, 0x4d, 0xdb, 0xe2, 0x17, 0x9d, 0xa4, 0xa3, 0xc9, 0xba, 0xfc, 0x7b, 0x7d, 0x5f, 0x52, 0xa7, 0x7e, 0xd1, 0x28, 0xf8, 0xf3, 0xb0, 0xc7, 0x32, 0xbc, 0x99, 0x24, 0xc5, 0xe3, 0xab, 0xeb, 0x1f, 0xa4, 0xf5, 0xfc, 0xe1, 0x25, 0xe4, 0xe9, 0x24, 0x97, 0xff, 0xd9, 0xff, 0xed, 0x2e, 0x1c, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x20, 0x33, 0x2e, 0x30, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x1c, 0x02, 0x00, 0x00, 0x02, 0x00, 0x02, 0x1c, 0x02, 0x78, 0x00, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xfb, 0x09, 0xa6, 0xbd, 0x07, 0x4c, 0x2a, 0x36, 0x9d, 0x8f, 0xe2, 0xcc, 0x57, 0xa9, 0xac, 0x85, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xea, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xb0, 0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x55, 0x54, 0x46, 0x2d, 0x38, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x2f, 0x44, 0x54, 0x44, 0x20, 0x50, 0x4c, 0x49, 0x53, 0x54, 0x20, 0x31, 0x2e, 0x30, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x54, 0x44, 0x73, 0x2f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x2d, 0x31, 0x2e, 0x30, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0x0a, 0x3c, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x48, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x48, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x32, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x4f, 0x72, 0x69, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x4f, 0x72, 0x69, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x31, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x32, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x31, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x73, 0x75, 0x62, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x61, 0x70, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x33, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x37, 0x36, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x37, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x39, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x6e, 0x61, 0x2d, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x54, 0x31, 0x37, 0x3a, 0x34, 0x39, 0x3a, 0x33, 0x36, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x33, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x37, 0x36, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x37, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x39, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x70, 0x64, 0x2e, 0x50, 0x4d, 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x70, 0x64, 0x2e, 0x50, 0x4d, 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x55, 0x53, 0x20, 0x4c, 0x65, 0x74, 0x74, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x54, 0x31, 0x37, 0x3a, 0x34, 0x39, 0x3a, 0x33, 0x36, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x30, 0x30, 0x2e, 0x32, 0x30, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2f, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x30, 0x30, 0x2e, 0x32, 0x30, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2f, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x3c, 0x2f, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x3e, 0x0a, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, 0x00, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x02, 0xde, 0x02, 0x40, 0xff, 0xee, 0xff, 0xee, 0x03, 0x06, 0x02, 0x52, 0x03, 0x67, 0x05, 0x28, 0x03, 0xfc, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd8, 0x02, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x01, 0x7f, 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x08, 0x00, 0x19, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xed, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x27, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x2f, 0x66, 0x66, 0x00, 0x01, 0x00, 0x6c, 0x66, 0x66, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x2f, 0x66, 0x66, 0x00, 0x01, 0x00, 0xa1, 0x99, 0x9a, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x35, 0x00, 0x00, 0x00, 0x01, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x03, 0x45, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x00, 0x44, 0x00, 0x53, 0x00, 0x43, 0x00, 0x30, 0x00, 0x32, 0x00, 0x33, 0x00, 0x32, 0x00, 0x35, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x75, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x63, 0x74, 0x31, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x54, 0x6f, 0x70, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x65, 0x66, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x74, 0x6f, 0x6d, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x52, 0x67, 0x68, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x06, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x73, 0x56, 0x6c, 0x4c, 0x73, 0x00, 0x00, 0x00, 0x01, 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x49, 0x44, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x45, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x6f, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00, 0x54, 0x79, 0x70, 0x65, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0a, 0x45, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x49, 0x6d, 0x67, 0x20, 0x00, 0x00, 0x00, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x63, 0x74, 0x31, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x54, 0x6f, 0x70, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x65, 0x66, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x74, 0x6f, 0x6d, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x52, 0x67, 0x68, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, 0x6c, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x75, 0x6c, 0x6c, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x73, 0x67, 0x65, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x61, 0x6c, 0x74, 0x54, 0x61, 0x67, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x63, 0x65, 0x6c, 0x6c, 0x54, 0x65, 0x78, 0x74, 0x49, 0x73, 0x48, 0x54, 0x4d, 0x4c, 0x62, 0x6f, 0x6f, 0x6c, 0x01, 0x00, 0x00, 0x00, 0x08, 0x63, 0x65, 0x6c, 0x6c, 0x54, 0x65, 0x78, 0x74, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x68, 0x6f, 0x72, 0x7a, 0x41, 0x6c, 0x69, 0x67, 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0f, 0x45, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x48, 0x6f, 0x72, 0x7a, 0x41, 0x6c, 0x69, 0x67, 0x6e, 0x00, 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x00, 0x09, 0x76, 0x65, 0x72, 0x74, 0x41, 0x6c, 0x69, 0x67, 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0f, 0x45, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x56, 0x65, 0x72, 0x74, 0x41, 0x6c, 0x69, 0x67, 0x6e, 0x00, 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x62, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x11, 0x45, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x42, 0x47, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x6f, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x09, 0x74, 0x6f, 0x70, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x6c, 0x65, 0x66, 0x74, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x72, 0x69, 0x67, 0x68, 0x74, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x09, 0xf9, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0x09, 0xdd, 0x00, 0x18, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xed, 0x00, 0x0c, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x5f, 0x43, 0x4d, 0x00, 0x02, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, 0x64, 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0c, 0x08, 0x08, 0x08, 0x09, 0x08, 0x0c, 0x09, 0x09, 0x0c, 0x11, 0x0b, 0x0a, 0x0b, 0x11, 0x15, 0x0f, 0x0c, 0x0c, 0x0f, 0x15, 0x18, 0x13, 0x13, 0x15, 0x13, 0x13, 0x18, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x01, 0x0d, 0x0b, 0x0b, 0x0d, 0x0e, 0x0d, 0x10, 0x0e, 0x0e, 0x10, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x07, 0xff, 0xc4, 0x01, 0x3f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x01, 0x04, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x07, 0x06, 0x08, 0x05, 0x03, 0x0c, 0x33, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, 0x31, 0x05, 0x41, 0x51, 0x61, 0x13, 0x22, 0x71, 0x81, 0x32, 0x06, 0x14, 0x91, 0xa1, 0xb1, 0x42, 0x23, 0x24, 0x15, 0x52, 0xc1, 0x62, 0x33, 0x34, 0x72, 0x82, 0xd1, 0x43, 0x07, 0x25, 0x92, 0x53, 0xf0, 0xe1, 0xf1, 0x63, 0x73, 0x35, 0x16, 0xa2, 0xb2, 0x83, 0x26, 0x44, 0x93, 0x54, 0x64, 0x45, 0xc2, 0xa3, 0x74, 0x36, 0x17, 0xd2, 0x55, 0xe2, 0x65, 0xf2, 0xb3, 0x84, 0xc3, 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x27, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x11, 0x00, 0x02, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x06, 0x05, 0x35, 0x01, 0x00, 0x02, 0x11, 0x03, 0x21, 0x31, 0x12, 0x04, 0x41, 0x51, 0x61, 0x71, 0x22, 0x13, 0x05, 0x32, 0x81, 0x91, 0x14, 0xa1, 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xf0, 0x33, 0x24, 0x62, 0xe1, 0x72, 0x82, 0x92, 0x43, 0x53, 0x15, 0x63, 0x73, 0x34, 0xf1, 0x25, 0x06, 0x16, 0xa2, 0xb2, 0x83, 0x07, 0x26, 0x35, 0xc2, 0xd2, 0x44, 0x93, 0x54, 0xa3, 0x17, 0x64, 0x45, 0x55, 0x36, 0x74, 0x65, 0xe2, 0xf2, 0xb3, 0x84, 0xc3, 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf2, 0xed, 0xb2, 0x8d, 0x4d, 0x45, 0xcd, 0x2f, 0x3f, 0x44, 0x68, 0x93, 0xc3, 0x58, 0xc8, 0xf1, 0x1f, 0x8a, 0x33, 0x86, 0xda, 0x58, 0xc1, 0xa0, 0x02, 0x4f, 0xc4, 0xa1, 0x69, 0xa5, 0x9b, 0x5b, 0x4b, 0x84, 0x73, 0xdf, 0xc9, 0x15, 0xf8, 0xe3, 0xd1, 0x0e, 0x07, 0x93, 0xf3, 0xd1, 0x0f, 0x1c, 0x17, 0xef, 0x2e, 0x3b, 0x5b, 0xdc, 0xff, 0x00, 0xdf, 0x42, 0xbf, 0x8f, 0x8e, 0xdc, 0x82, 0xca, 0xd8, 0x37, 0x11, 0xa9, 0x3d, 0x82, 0x69, 0x2b, 0xc4, 0x6d, 0xc9, 0x75, 0x25, 0xbc, 0xf7, 0xec, 0xa1, 0xb5, 0x74, 0x19, 0x5d, 0x2e, 0x8a, 0x9a, 0x4b, 0x89, 0x7d, 0xc4, 0x68, 0xc6, 0xf6, 0xfe, 0xb2, 0xa0, 0x30, 0x1d, 0x60, 0x86, 0x88, 0x8d, 0x49, 0x3e, 0x01, 0x11, 0x20, 0xa3, 0x8c, 0xb9, 0xb1, 0xaa, 0x62, 0xad, 0xbf, 0x18, 0x97, 0x43, 0x47, 0x1d, 0xd2, 0xaf, 0x04, 0xd9, 0xb8, 0xc8, 0x0d, 0x68, 0xe4, 0xf7, 0x3e, 0x48, 0xf1, 0x05, 0xbc, 0x25, 0xaa, 0x07, 0x71, 0xd9, 0x14, 0x78, 0xf6, 0x49, 0xb5, 0x90, 0xfd, 0xa7, 0xc6, 0x14, 0xfd, 0x1b, 0x1c, 0xff, 0x00, 0x4d, 0x8d, 0x2e, 0x73, 0x8c, 0x35, 0xa3, 0x52, 0x4f, 0x92, 0x48, 0xa6, 0x1a, 0x24, 0xb6, 0x2a, 0xfa, 0xa5, 0x9e, 0x60, 0x64, 0x39, 0x94, 0x13, 0xcb, 0x27, 0x73, 0x80, 0xf3, 0x0c, 0xf6, 0xff, 0x00, 0xd2, 0x5a, 0x78, 0xbf, 0x53, 0x71, 0xf6, 0x01, 0x75, 0xb6, 0x97, 0x6a, 0x25, 0xa1, 0xad, 0x1f, 0xf4, 0xb7, 0x23, 0x48, 0xb7, 0x94, 0x84, 0x97, 0x5b, 0xff, 0x00, 0x32, 0xa9, 0xdd, 0xfc, 0xed, 0x9b, 0x7e, 0x0d, 0x9e, 0x52, 0x4a, 0x95, 0x61, 0xff, 0xd0, 0xf3, 0x3b, 0xa7, 0x70, 0xee, 0x01, 0x8f, 0xb9, 0x59, 0xfa, 0x7e, 0xdf, 0xe4, 0xc8, 0xf9, 0x2a, 0xc2, 0x5c, 0x63, 0xc3, 0x54, 0x67, 0x87, 0x6e, 0x10, 0x35, 0x68, 0xd4, 0x79, 0x1e, 0x53, 0x4a, 0xe0, 0xdc, 0xe9, 0xb8, 0x1f, 0x6a, 0xda, 0x6c, 0x25, 0x94, 0x37, 0xb0, 0xd0, 0xb8, 0xad, 0x67, 0xe4, 0x55, 0x8a, 0x5b, 0x8b, 0x82, 0xc0, 0x6f, 0x76, 0x80, 0x34, 0x49, 0x05, 0x2e, 0x9e, 0xc6, 0x1c, 0x66, 0x31, 0xba, 0x10, 0x23, 0xe0, 0xaf, 0xe1, 0x61, 0x53, 0x43, 0x8d, 0x81, 0xb3, 0x67, 0xef, 0x9e, 0x49, 0x2a, 0x12, 0x6c, 0xb6, 0x63, 0x1a, 0x0c, 0x31, 0xba, 0x55, 0xcd, 0xac, 0xfa, 0x8e, 0xdf, 0x91, 0x6e, 0x91, 0xd9, 0xb3, 0xc9, 0x73, 0x90, 0x7a, 0xab, 0x6a, 0xc2, 0xa4, 0x60, 0xe2, 0x8f, 0xd2, 0x38, 0x03, 0x7d, 0x9e, 0x0d, 0xff, 0x00, 0xcc, 0xd6, 0xd3, 0x6b, 0x71, 0x67, 0xd2, 0x3e, 0x64, 0x72, 0xab, 0xdb, 0x8d, 0x54, 0x39, 0xc5, 0x83, 0x6b, 0x3d, 0xee, 0x2e, 0xd4, 0x92, 0x3c, 0x4a, 0x56, 0xba, 0xb4, 0x79, 0x5c, 0xf7, 0xb2, 0x96, 0x6c, 0x8d, 0xaf, 0x80, 0x48, 0x3c, 0xf0, 0xb2, 0x1f, 0x63, 0x9c, 0xe9, 0x3f, 0x24, 0x5c, 0xdb, 0xdd, 0x76, 0x43, 0xde, 0xfd, 0x5c, 0xe3, 0x24, 0xfc, 0x50, 0x00, 0x93, 0x0a, 0x78, 0x8a, 0x0d, 0x49, 0xca, 0xcf, 0x93, 0x63, 0x1b, 0x7d, 0xd7, 0x57, 0x50, 0xd5, 0xef, 0x70, 0x6b, 0x4f, 0xc7, 0x45, 0xdb, 0x74, 0x9e, 0x8d, 0x5e, 0x33, 0x83, 0xd8, 0x37, 0xdd, 0xc3, 0xac, 0x3d, 0xbf, 0x92, 0xc5, 0x5b, 0xea, 0xbf, 0xd5, 0x62, 0xc0, 0xdc, 0xbc, 0xbd, 0x2d, 0x22, 0x5a, 0xcf, 0xdd, 0x69, 0xff, 0x00, 0xd1, 0x8e, 0x5d, 0xa5, 0x38, 0xb5, 0xb0, 0x00, 0xc6, 0xc4, 0x24, 0x4a, 0xd6, 0x8d, 0x18, 0x04, 0x49, 0x88, 0x9e, 0x55, 0xd6, 0x61, 0xb0, 0xc1, 0x70, 0x32, 0xdd, 0x3c, 0x95, 0xda, 0xf1, 0xfe, 0xf5, 0x62, 0xbc, 0x76, 0x8e, 0x75, 0x28, 0x02, 0xa2, 0xe7, 0x7d, 0x92, 0xb9, 0x84, 0x96, 0x96, 0xda, 0xf7, 0x70, 0x12, 0x4e, 0x5a, 0xff, 0x00, 0xff, 0xd1, 0xf3, 0x7a, 0x21, 0xaf, 0xde, 0xef, 0xa2, 0x22, 0x55, 0xfc, 0x5a, 0xbd, 0x42, 0xfb, 0x08, 0xfa, 0x67, 0x4f, 0x82, 0xcd, 0x6d, 0x85, 0xc0, 0x56, 0x3b, 0x90, 0xb7, 0xf0, 0x2a, 0x0e, 0x63, 0x58, 0x3b, 0xf2, 0xa3, 0x9e, 0x8c, 0xb8, 0x86, 0xbe, 0x49, 0xf1, 0x2c, 0x0c, 0x86, 0xb4, 0x4c, 0x69, 0xe4, 0xaf, 0x6e, 0xcc, 0x6b, 0x7d, 0x46, 0xb3, 0x70, 0xec, 0x38, 0x51, 0x7d, 0x02, 0x8a, 0xc7, 0xa6, 0xd9, 0x20, 0x68, 0x0f, 0x8f, 0x8a, 0xcf, 0xc9, 0xc2, 0xea, 0x59, 0x5b, 0x48, 0xb0, 0x91, 0xae, 0xe6, 0xc9, 0x03, 0xc9, 0x30, 0x51, 0x66, 0xd4, 0x0d, 0xad, 0xbd, 0x5f, 0x53, 0xcc, 0x6b, 0xb6, 0x90, 0x5a, 0x3b, 0x83, 0x0b, 0x43, 0x17, 0x31, 0xd6, 0xc3, 0x6e, 0x12, 0x3b, 0x79, 0xac, 0xc1, 0x89, 0x47, 0xd9, 0xe8, 0x63, 0x98, 0x45, 0xed, 0x6c, 0x5a, 0xf1, 0xa0, 0x27, 0xc5, 0x5b, 0xc3, 0x6f, 0xa6, 0xe0, 0x1c, 0x7d, 0xb3, 0xa2, 0x69, 0x34, 0x7b, 0xae, 0x1a, 0x8d, 0x45, 0x17, 0x9d, 0xeb, 0xfd, 0x21, 0xd8, 0xb9, 0xae, 0xb5, 0x80, 0xbb, 0x1e, 0xd2, 0x5c, 0xd7, 0x78, 0x13, 0xf9, 0xae, 0x4b, 0xea, 0xc7, 0x4a, 0x39, 0xbd, 0x55, 0xb3, 0xed, 0x66, 0x38, 0xf5, 0x09, 0x22, 0x41, 0x23, 0xe8, 0x37, 0xfb, 0x4b, 0xa1, 0xeb, 0xd6, 0xfe, 0x88, 0x31, 0xbf, 0x41, 0xc0, 0xee, 0xd2, 0x74, 0x02, 0x78, 0x53, 0xfa, 0x97, 0x43, 0x19, 0x85, 0x65, 0xff, 0x00, 0x9d, 0x71, 0x33, 0xe4, 0x1a, 0x7d, 0x8d, 0x53, 0x42, 0x56, 0x35, 0x6b, 0xe5, 0x80, 0x06, 0xc7, 0x57, 0xa7, 0xc4, 0xa9, 0xdb, 0xb6, 0x81, 0x1f, 0xeb, 0xd9, 0x69, 0x56, 0xc2, 0xd0, 0x00, 0xe5, 0x55, 0xc0, 0x12, 0xc2, 0xd7, 0x4e, 0xa2, 0x5a, 0x7c, 0x0a, 0xd0, 0x63, 0x9a, 0xd1, 0xaf, 0xd2, 0xe2, 0x3c, 0x12, 0x62, 0x66, 0xc6, 0x42, 0x23, 0x5a, 0x49, 0x8f, 0x10, 0xa2, 0xd2, 0x3e, 0x28, 0x9d, 0xc4, 0x88, 0x09, 0x29, 0x16, 0xc3, 0x3c, 0x24, 0x8d, 0xe6, 0x92, 0x72, 0x1f, 0xff, 0xd2, 0xf3, 0xbb, 0xb0, 0xfe, 0xcb, 0x99, 0xe9, 0xce, 0xf6, 0x88, 0x2d, 0x77, 0x91, 0x5b, 0x3d, 0x3d, 0xd0, 0xe6, 0x90, 0xa9, 0x65, 0x57, 0x38, 0x95, 0xdd, 0xcb, 0x9a, 0x7d, 0xce, 0xf2, 0x3f, 0x44, 0x23, 0x60, 0x58, 0x76, 0xe9, 0xca, 0x8c, 0xea, 0x1b, 0x31, 0x02, 0x32, 0x23, 0xea, 0xee, 0xb1, 0xcd, 0xb0, 0xc7, 0x87, 0x74, 0x7a, 0xeb, 0x70, 0x1a, 0x71, 0xe1, 0xfe, 0xe4, 0x1c, 0x1d, 0xae, 0xe5, 0x69, 0xd8, 0xfa, 0x99, 0x50, 0x0d, 0x1a, 0xf7, 0x2a, 0x3a, 0x0c, 0xf4, 0x1a, 0x8e, 0xc7, 0x27, 0x5d, 0xbf, 0x18, 0x41, 0xdc, 0xc2, 0xf0, 0x7f, 0x74, 0xf6, 0x3a, 0x22, 0x66, 0xdb, 0x68, 0xc6, 0x80, 0x48, 0x6b, 0x88, 0x06, 0x39, 0x0d, 0xee, 0xaa, 0x1f, 0xb3, 0xd5, 0x1b, 0x83, 0xd8, 0x3b, 0x38, 0x8f, 0x69, 0xfe, 0xdf, 0xd1, 0x4d, 0x29, 0xa1, 0x4c, 0x7a, 0xf4, 0xbf, 0xa7, 0x92, 0xcf, 0xa5, 0x20, 0x08, 0xf3, 0xf6, 0xff, 0x00, 0x15, 0xbb, 0xd1, 0x31, 0xd9, 0x5e, 0x3d, 0x75, 0x56, 0x36, 0x88, 0x00, 0x81, 0xe0, 0x16, 0x5e, 0x55, 0x74, 0x3f, 0x00, 0x9d, 0xe0, 0xcc, 0x69, 0xe7, 0x3a, 0x2d, 0xbe, 0x90, 0x00, 0xa9, 0xae, 0xef, 0x1f, 0x95, 0x4b, 0x0d, 0x9a, 0xdc, 0xc7, 0x45, 0xfe, 0xb1, 0x7d, 0x60, 0xa7, 0xa1, 0xe0, 0x1f, 0x4e, 0x1d, 0x99, 0x69, 0x02, 0x9a, 0xcf, 0x1f, 0xca, 0x7b, 0xbf, 0x90, 0xc5, 0xc2, 0xb3, 0xeb, 0x57, 0xd6, 0x03, 0x6b, 0xae, 0x39, 0xb6, 0x82, 0xe3, 0x31, 0xa1, 0x68, 0xf2, 0x6b, 0x5c, 0x12, 0xfa, 0xe1, 0x91, 0x66, 0x47, 0x5d, 0xb8, 0x3b, 0x4f, 0x44, 0x36, 0xb6, 0x8f, 0x28, 0xdd, 0xff, 0x00, 0x7e, 0x46, 0xab, 0x12, 0x2b, 0x65, 0x55, 0x32, 0xa7, 0x62, 0xb6, 0xbd, 0xf7, 0x64, 0x10, 0xdb, 0x03, 0x9f, 0x1b, 0x9e, 0xc7, 0xd9, 0xb8, 0x3b, 0x1f, 0x67, 0xf3, 0x6c, 0x52, 0x80, 0xd7, 0x7d, 0x0f, 0xea, 0x7f, 0x5d, 0x1d, 0x67, 0xa6, 0x0b, 0x1e, 0x47, 0xda, 0x69, 0x3b, 0x2e, 0x03, 0xc7, 0xf3, 0x5f, 0x1f, 0xf0, 0x8b, 0xa1, 0x02, 0x46, 0xba, 0x79, 0xaf, 0x32, 0xff, 0x00, 0x16, 0xad, 0xca, 0x1d, 0x57, 0x2a, 0xdc, 0x79, 0x18, 0x41, 0xb0, 0xf6, 0x9e, 0xe4, 0x9f, 0xd0, 0x8f, 0xeb, 0x31, 0xab, 0xd2, 0x83, 0xa4, 0xcb, 0x8c, 0xb8, 0xa0, 0x42, 0x12, 0x7b, 0x67, 0x9f, 0x2f, 0xf5, 0x09, 0x26, 0x96, 0xc4, 0xce, 0xa9, 0x20, 0xa7, 0xff, 0xd3, 0xf3, 0x2f, 0xb4, 0x5d, 0xe9, 0x0a, 0xb7, 0x9f, 0x4c, 0x19, 0xdb, 0x3a, 0x2d, 0x5e, 0x94, 0xfd, 0xc4, 0xb7, 0xc5, 0x62, 0xf9, 0x2b, 0xfd, 0x2e, 0xe3, 0x5d, 0xe0, 0x7c, 0x13, 0x48, 0xd1, 0x92, 0x12, 0xa9, 0x0b, 0x7a, 0xbc, 0x2d, 0xc2, 0x7f, 0x92, 0x60, 0xab, 0x4e, 0x79, 0x2e, 0x00, 0xf0, 0xaa, 0xe1, 0xda, 0x3d, 0x43, 0xfc, 0xad, 0x55, 0xbb, 0x80, 0x79, 0x81, 0xa0, 0xe6, 0x54, 0x32, 0x6d, 0x02, 0xbe, 0xf3, 0x61, 0x81, 0xa8, 0x44, 0x14, 0x03, 0x59, 0x0e, 0x1c, 0xf6, 0x1f, 0xdc, 0xb2, 0xec, 0xa3, 0x23, 0x77, 0xe8, 0x6e, 0x70, 0xf2, 0x25, 0x1f, 0x1f, 0x17, 0xa9, 0x6d, 0x71, 0x36, 0x97, 0x47, 0x00, 0xa4, 0x02, 0xe0, 0x2c, 0x7c, 0xc1, 0xab, 0xd5, 0x31, 0x85, 0x35, 0xd4, 0xe6, 0x13, 0x02, 0xd6, 0x4b, 0x67, 0x48, 0x2b, 0xa9, 0xe9, 0x2e, 0x02, 0xb6, 0x4f, 0x82, 0xe5, 0x7a, 0x95, 0x19, 0xc6, 0x87, 0x3d, 0xfb, 0xa2, 0xb8, 0x79, 0x1e, 0x4d, 0x3b, 0x96, 0xcf, 0x4f, 0xbd, 0xcd, 0xa2, 0xa2, 0x1f, 0xa0, 0x82, 0xd3, 0xfc, 0x97, 0x05, 0x24, 0x36, 0x6b, 0xf3, 0x31, 0xa2, 0x35, 0x79, 0xef, 0xad, 0xf8, 0xae, 0xaf, 0xaf, 0xd8, 0xf2, 0xd8, 0x6d, 0xed, 0x6b, 0xda, 0x7b, 0x18, 0x1b, 0x5d, 0xff, 0x00, 0x52, 0xb1, 0x6d, 0xf0, 0x81, 0x31, 0xca, 0xf4, 0x6e, 0xb1, 0x80, 0xce, 0xb1, 0x84, 0xc0, 0x21, 0xb7, 0xd6, 0x77, 0x31, 0xd1, 0x27, 0xc1, 0xcd, 0xfe, 0xd2, 0xe3, 0xec, 0xe8, 0x1d, 0x45, 0x96, 0xb0, 0x9a, 0xb7, 0x87, 0x3f, 0x68, 0x2d, 0xf7, 0x01, 0x1f, 0xbe, 0xd1, 0xf4, 0x7f, 0xb4, 0xa4, 0x0d, 0x77, 0xbb, 0xfa, 0x8f, 0x80, 0x3a, 0x7f, 0x43, 0xaa, 0xe2, 0xdf, 0xd2, 0x65, 0x7e, 0x95, 0xe4, 0x0f, 0x1f, 0xa1, 0xfe, 0x6b, 0x16, 0x9f, 0x52, 0xfa, 0xc1, 0xd3, 0xba, 0x6d, 0x26, 0xdc, 0xac, 0x86, 0xd4, 0xd9, 0x0d, 0x31, 0x2e, 0x74, 0x9e, 0xdb, 0x59, 0x2e, 0x55, 0xe8, 0xc9, 0xb2, 0x96, 0xd5, 0x4b, 0x9f, 0xb8, 0x6d, 0xda, 0x1c, 0x04, 0x09, 0x03, 0xfe, 0x8a, 0xc6, 0xfa, 0xd3, 0xf5, 0x6a, 0xbe, 0xbb, 0x5b, 0x2e, 0xc6, 0xb5, 0x94, 0xe6, 0xd5, 0x20, 0x97, 0x7d, 0x1b, 0x1b, 0xf9, 0xad, 0x7c, 0x7d, 0x17, 0xb7, 0xf3, 0x1e, 0x92, 0x1b, 0x7f, 0xf8, 0xe0, 0x7d, 0x59, 0xdd, 0xfd, 0x32, 0xd8, 0x8f, 0xa5, 0xe8, 0x3a, 0x12, 0x5c, 0x3f, 0xfc, 0xc4, 0xfa, 0xc3, 0xb3, 0x77, 0xa7, 0x56, 0xed, 0xdb, 0x76, 0x7a, 0x8d, 0xdd, 0x1f, 0xbf, 0xfd, 0x44, 0x92, 0x56, 0x8f, 0xff, 0xd4, 0xf2, 0xe8, 0x86, 0x17, 0x1e, 0xfa, 0x04, 0x56, 0x4b, 0x43, 0x6c, 0x6f, 0x2d, 0xe5, 0x46, 0x01, 0x64, 0x2b, 0x14, 0x32, 0x5b, 0xb4, 0xa0, 0x52, 0x1d, 0xde, 0x9b, 0x94, 0xdb, 0xab, 0x6b, 0x81, 0xf7, 0x05, 0xb0, 0xd7, 0x07, 0xb2, 0x27, 0x55, 0xc6, 0x57, 0x65, 0xd8, 0x76, 0x6e, 0x64, 0xed, 0xee, 0x16, 0xce, 0x27, 0x57, 0x63, 0xda, 0x0c, 0xc2, 0x8e, 0x51, 0x67, 0x84, 0xfa, 0x1d, 0xdd, 0x62, 0xc7, 0x07, 0xe9, 0xf7, 0xa3, 0xd6, 0x6c, 0x02, 0x41, 0x55, 0x31, 0xf3, 0x2b, 0xb3, 0xba, 0x2b, 0x2e, 0x68, 0x24, 0x1d, 0x47, 0x64, 0xca, 0xa6, 0x50, 0x41, 0x65, 0x90, 0x6c, 0xb1, 0xa5, 0xae, 0x33, 0x23, 0x51, 0xe4, 0xab, 0x7d, 0x5d, 0xcb, 0xb6, 0xcc, 0x37, 0xd0, 0x40, 0x73, 0x71, 0xde, 0x58, 0x09, 0xe7, 0x6f, 0x2c, 0x44, 0xc9, 0xc9, 0xae, 0xba, 0x9d, 0x63, 0x88, 0x01, 0xa0, 0x95, 0x9d, 0xf5, 0x3f, 0x2a, 0xe6, 0x67, 0xdb, 0x50, 0x83, 0x55, 0xad, 0x36, 0x3e, 0x78, 0x10, 0x74, 0x77, 0xfd, 0x2d, 0xaa, 0x4c, 0x7d, 0x58, 0x73, 0x91, 0xa0, 0x0f, 0x51, 0x45, 0xb7, 0x33, 0xdd, 0x58, 0x69, 0x1d, 0xd8, 0x0c, 0x9f, 0x96, 0x88, 0x19, 0x99, 0x19, 0xac, 0xcf, 0xa3, 0xd2, 0xad, 0xb5, 0xdb, 0x76, 0x8f, 0xad, 0xc4, 0xea, 0xcf, 0xdf, 0x7e, 0xdf, 0xdd, 0xfc, 0xd5, 0xa3, 0x5e, 0x43, 0x2b, 0x6b, 0xb2, 0xad, 0x3b, 0x6a, 0xa4, 0x13, 0xa7, 0x04, 0xac, 0x7a, 0x6f, 0xb3, 0x23, 0x26, 0xcc, 0xfb, 0xb4, 0x75, 0x8e, 0x01, 0x83, 0xf7, 0x58, 0x3e, 0x8b, 0x53, 0xa7, 0x2a, 0x1a, 0x31, 0x42, 0x36, 0x5d, 0x4c, 0x9a, 0xf2, 0xdc, 0xc6, 0xfe, 0x98, 0xb4, 0x34, 0xcb, 0x48, 0x0a, 0x8f, 0xdb, 0xb2, 0xeb, 0x76, 0xd6, 0x07, 0x5c, 0x59, 0xc9, 0x64, 0x8f, 0x93, 0xa7, 0x73, 0x16, 0x83, 0xaf, 0x0e, 0xa4, 0x33, 0xef, 0x50, 0xc5, 0x0c, 0xda, 0x59, 0x10, 0x06, 0x8a, 0x2e, 0x29, 0x0e, 0xac, 0xc2, 0x31, 0x3d, 0x36, 0x69, 0x7e, 0xd6, 0xcc, 0xf5, 0x3d, 0x6f, 0xb3, 0xeb, 0x1b, 0x76, 0xef, 0x3b, 0xa3, 0xfa, 0xc9, 0x2b, 0x5f, 0x66, 0x6f, 0xa9, 0x1e, 0x73, 0xf2, 0x49, 0x2e, 0x39, 0xf7, 0x4f, 0xb7, 0x8d, 0xff, 0xd5, 0xf3, 0x26, 0xfe, 0x0a, 0xc5, 0x1b, 0xa7, 0xcb, 0xb2, 0xcf, 0x49, 0x03, 0xb2, 0x46, 0xee, 0xd9, 0xd9, 0xb3, 0xf4, 0x9f, 0x25, 0x4a, 0xdf, 0x4b, 0x77, 0xe8, 0x27, 0xd4, 0xef, 0x1c, 0x2a, 0x29, 0x26, 0xc5, 0x7c, 0x9d, 0x6c, 0x7f, 0xb7, 0x6e, 0x1b, 0x26, 0x7f, 0x05, 0xa3, 0xfe, 0x53, 0x8d, 0x62, 0x57, 0x30, 0x92, 0x12, 0xfa, 0x2f, 0x86, 0xdf, 0xa4, 0xec, 0x67, 0xfe, 0xd0, 0xf4, 0xff, 0x00, 0x4d, 0xfc, 0xdf, 0x78, 0xe1, 0x68, 0x7d, 0x54, 0x99, 0xbf, 0x6f, 0xf3, 0xbe, 0xdf, 0x8e, 0xdd, 0x7f, 0xef, 0xeb, 0x97, 0x49, 0x3e, 0x3b, 0x7f, 0x06, 0x2c, 0x9f, 0x37, 0x5f, 0xf0, 0x9f, 0x4c, 0xeb, 0x7b, 0xbf, 0x67, 0x55, 0xe8, 0xff, 0x00, 0x31, 0xbc, 0x7a, 0x9e, 0x31, 0xdb, 0xfe, 0x92, 0xae, 0x37, 0x7a, 0x4d, 0xdb, 0xe2, 0x17, 0x9d, 0xa4, 0xa3, 0xc9, 0xba, 0xfc, 0x7b, 0x7d, 0x5f, 0x52, 0xa7, 0x7e, 0xd1, 0x28, 0xf8, 0xf3, 0xb0, 0xc7, 0x32, 0xbc, 0x99, 0x24, 0xc5, 0xe3, 0xab, 0xeb, 0x1f, 0xa4, 0xf5, 0xfc, 0xe1, 0x25, 0xe4, 0xe9, 0x24, 0x97, 0xff, 0xd9, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x00, 0x00, 0x13, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x20, 0x00, 0x37, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0xff, 0xe1, 0x15, 0x67, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x00, 0x3c, 0x3f, 0x78, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x3d, 0x27, 0xef, 0xbb, 0xbf, 0x27, 0x20, 0x69, 0x64, 0x3d, 0x27, 0x57, 0x35, 0x4d, 0x30, 0x4d, 0x70, 0x43, 0x65, 0x68, 0x69, 0x48, 0x7a, 0x72, 0x65, 0x53, 0x7a, 0x4e, 0x54, 0x63, 0x7a, 0x6b, 0x63, 0x39, 0x64, 0x27, 0x3f, 0x3e, 0x0a, 0x3c, 0x3f, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2d, 0x78, 0x61, 0x70, 0x2d, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x20, 0x65, 0x73, 0x63, 0x3d, 0x22, 0x43, 0x52, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x3d, 0x27, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x3a, 0x6e, 0x73, 0x3a, 0x6d, 0x65, 0x74, 0x61, 0x2f, 0x27, 0x20, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x74, 0x6b, 0x3d, 0x27, 0x58, 0x4d, 0x50, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x20, 0x32, 0x2e, 0x38, 0x2e, 0x32, 0x2d, 0x33, 0x33, 0x2c, 0x20, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x31, 0x2e, 0x35, 0x27, 0x3e, 0x0a, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x52, 0x44, 0x46, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x72, 0x64, 0x66, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, 0x32, 0x2f, 0x32, 0x32, 0x2d, 0x72, 0x64, 0x66, 0x2d, 0x73, 0x79, 0x6e, 0x74, 0x61, 0x78, 0x2d, 0x6e, 0x73, 0x23, 0x27, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x69, 0x58, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x58, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x70, 0x64, 0x66, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x64, 0x66, 0x2f, 0x31, 0x2e, 0x33, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0x70, 0x64, 0x66, 0x3a, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3a, 0x43, 0x61, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x61, 0x70, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0x78, 0x61, 0x70, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x6d, 0x6d, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3a, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x3e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x3a, 0x64, 0x6f, 0x63, 0x69, 0x64, 0x3a, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x36, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x3c, 0x2f, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3a, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x64, 0x63, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x70, 0x75, 0x72, 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x64, 0x63, 0x2f, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x31, 0x2e, 0x31, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x64, 0x63, 0x3a, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x41, 0x6c, 0x74, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x6c, 0x69, 0x20, 0x78, 0x6d, 0x6c, 0x3a, 0x6c, 0x61, 0x6e, 0x67, 0x3d, 0x27, 0x78, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x27, 0x3e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x6c, 0x69, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x41, 0x6c, 0x74, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x63, 0x3a, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x52, 0x44, 0x46, 0x3e, 0x0a, 0x3c, 0x2f, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x6d, 0x65, 0x74, 0x61, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x3c, 0x3f, 0x78, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x65, 0x6e, 0x64, 0x3d, 0x27, 0x77, 0x27, 0x3f, 0x3e, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, 0x64, 0x40, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x06, 0x04, 0x03, 0x04, 0x06, 0x07, 0x05, 0x04, 0x04, 0x05, 0x07, 0x08, 0x06, 0x06, 0x07, 0x06, 0x06, 0x08, 0x0a, 0x08, 0x09, 0x09, 0x09, 0x09, 0x08, 0x0a, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x01, 0x04, 0x05, 0x05, 0x08, 0x07, 0x08, 0x0f, 0x0a, 0x0a, 0x0f, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x0d, 0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x00, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x03, 0x02, 0x06, 0x01, 0x00, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x02, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x02, 0x06, 0x07, 0x03, 0x04, 0x02, 0x06, 0x02, 0x73, 0x01, 0x02, 0x03, 0x11, 0x04, 0x00, 0x05, 0x21, 0x12, 0x31, 0x41, 0x51, 0x06, 0x13, 0x61, 0x22, 0x71, 0x81, 0x14, 0x32, 0x91, 0xa1, 0x07, 0x15, 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xe1, 0x33, 0x16, 0x62, 0xf0, 0x24, 0x72, 0x82, 0xf1, 0x25, 0x43, 0x34, 0x53, 0x92, 0xa2, 0xb2, 0x63, 0x73, 0xc2, 0x35, 0x44, 0x27, 0x93, 0xa3, 0xb3, 0x36, 0x17, 0x54, 0x64, 0x74, 0xc3, 0xd2, 0xe2, 0x08, 0x26, 0x83, 0x09, 0x0a, 0x18, 0x19, 0x84, 0x94, 0x45, 0x46, 0xa4, 0xb4, 0x56, 0xd3, 0x55, 0x28, 0x1a, 0xf2, 0xe3, 0xf3, 0xc4, 0xd4, 0xe4, 0xf4, 0x65, 0x75, 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x38, 0x48, 0x58, 0x68, 0x78, 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9, 0x2a, 0x3a, 0x4a, 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa, 0x11, 0x00, 0x02, 0x02, 0x01, 0x02, 0x03, 0x05, 0x05, 0x04, 0x05, 0x06, 0x04, 0x08, 0x03, 0x03, 0x6d, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, 0x31, 0x41, 0x05, 0x51, 0x13, 0x61, 0x22, 0x06, 0x71, 0x81, 0x91, 0x32, 0xa1, 0xb1, 0xf0, 0x14, 0xc1, 0xd1, 0xe1, 0x23, 0x42, 0x15, 0x52, 0x62, 0x72, 0xf1, 0x33, 0x24, 0x34, 0x43, 0x82, 0x16, 0x92, 0x53, 0x25, 0xa2, 0x63, 0xb2, 0xc2, 0x07, 0x73, 0xd2, 0x35, 0xe2, 0x44, 0x83, 0x17, 0x54, 0x93, 0x08, 0x09, 0x0a, 0x18, 0x19, 0x26, 0x36, 0x45, 0x1a, 0x27, 0x64, 0x74, 0x55, 0x37, 0xf2, 0xa3, 0xb3, 0xc3, 0x28, 0x29, 0xd3, 0xe3, 0xf3, 0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4, 0x65, 0x75, 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x46, 0x56, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x38, 0x48, 0x58, 0x68, 0x78, 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8, 0x39, 0x49, 0x59, 0x69, 0x79, 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9, 0x2a, 0x3a, 0x4a, 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf0, 0x67, 0xa6, 0x5c, 0x0f, 0x01, 0xd4, 0x7e, 0x18, 0x12, 0x98, 0xe9, 0xd6, 0x2d, 0x34, 0x6d, 0x70, 0xdf, 0xdc, 0xa1, 0xe3, 0xec, 0x5b, 0xfb, 0x32, 0x24, 0xb2, 0x01, 0x1f, 0x15, 0xa4, 0x52, 0x4a, 0x82, 0x31, 0xf1, 0xfe, 0xd1, 0x3d, 0x14, 0x64, 0x49, 0x64, 0x22, 0x98, 0xcf, 0xa5, 0x46, 0x6c, 0x16, 0x55, 0x71, 0x56, 0x62, 0x28, 0x07, 0xc5, 0x45, 0x15, 0xa0, 0xc8, 0x89, 0x33, 0xe1, 0x63, 0xd2, 0xd8, 0x34, 0x44, 0x17, 0xa0, 0x2c, 0x4d, 0x16, 0xbb, 0xed, 0xdc, 0xf8, 0x64, 0xc1, 0x6b, 0x31, 0x42, 0x18, 0x8e, 0xc7, 0xb5, 0x2a, 0x7d, 0xb2, 0x56, 0xc5, 0x61, 0x8c, 0xf2, 0xa0, 0x1b, 0x1e, 0x83, 0x0d, 0xa1, 0x63, 0x50, 0x1f, 0x97, 0x7c, 0x2a, 0xa9, 0x1a, 0x9a, 0x86, 0x4f, 0xb4, 0xb4, 0x38, 0x0a, 0xa6, 0x0b, 0xb8, 0x0c, 0x05, 0x14, 0xf8, 0x76, 0x3e, 0x19, 0x14, 0xb6, 0x78, 0xf8, 0x8c, 0x2a, 0xd5, 0x01, 0xdc, 0x6f, 0x8a, 0x1a, 0xe3, 0x8d, 0xab, 0xff, 0xd0, 0xf0, 0xec, 0xe9, 0x15, 0xb5, 0xb9, 0x5a, 0x7c, 0x4c, 0xa2, 0x9e, 0x24, 0xf5, 0xca, 0xc6, 0xe5, 0x99, 0xd9, 0x34, 0x99, 0x04, 0x3a, 0x7d, 0xb5, 0xba, 0xd5, 0x51, 0x63, 0x0e, 0xc7, 0xc5, 0x9b, 0x73, 0xf8, 0xe4, 0x6f, 0x76, 0xca, 0xd9, 0xda, 0x54, 0x6d, 0x72, 0x2e, 0x1a, 0x57, 0x11, 0x44, 0x40, 0x0d, 0x27, 0x7a, 0x0f, 0xd9, 0x5f, 0x12, 0x69, 0x4c, 0x84, 0xcd, 0x36, 0xe3, 0x85, 0xb2, 0xcd, 0x2f, 0x4a, 0x8b, 0x58, 0x36, 0xf6, 0x76, 0xa8, 0x64, 0x64, 0x3c, 0xa4, 0x93, 0xaa, 0x25, 0x3c, 0x49, 0xda, 0xa4, 0xe5, 0x26, 0x54, 0xe4, 0x8c, 0x7c, 0x5c, 0x93, 0x4d, 0x67, 0xc9, 0x3a, 0x6e, 0x9f, 0x13, 0xb4, 0xce, 0xf7, 0x3a, 0x9b, 0xad, 0x52, 0xd6, 0x2a, 0xd1, 0x49, 0xee, 0xc7, 0xf8, 0x64, 0x46, 0x42, 0x4e, 0xcd, 0x92, 0xc2, 0x00, 0xdd, 0x8a, 0x47, 0xe5, 0x69, 0x6e, 0xd4, 0xa4, 0x08, 0x16, 0x83, 0x9c, 0x8c, 0xdd, 0x95, 0x6b, 0xb9, 0xf6, 0xef, 0x97, 0x78, 0x94, 0xe3, 0x78, 0x04, 0xa4, 0xf3, 0xe8, 0xee, 0x64, 0xe1, 0x12, 0x10, 0x05, 0x6a, 0xc7, 0xc0, 0x6f, 0x53, 0xf3, 0xc9, 0x89, 0xb4, 0x9c, 0x4e, 0xb4, 0xf2, 0xd3, 0xde, 0x7a, 0xd2, 0x19, 0x16, 0x38, 0x61, 0x5d, 0xd9, 0x88, 0x05, 0x9c, 0xf4, 0x0a, 0x0f, 0x5f, 0x73, 0x84, 0xe4, 0xa4, 0xc7, 0x0d, 0xa5, 0xf1, 0x59, 0xba, 0x5c, 0x08, 0x98, 0x6f, 0xc8, 0x20, 0xfa, 0x4e, 0x4e, 0xf6, 0x69, 0xe1, 0xa2, 0x89, 0xfd, 0x1f, 0x77, 0x2c, 0xe6, 0xce, 0xd6, 0x17, 0x9a, 0x69, 0xdb, 0xd3, 0x86, 0x18, 0xc1, 0x67, 0x77, 0x26, 0x80, 0x28, 0x1b, 0x93, 0x88, 0x41, 0x0f, 0x40, 0xb0, 0xfc, 0x87, 0xf3, 0x43, 0x98, 0xd7, 0x58, 0x96, 0xdb, 0x4d, 0x91, 0x88, 0xe5, 0x6c, 0x58, 0xdc, 0x5c, 0x2a, 0xf7, 0x2c, 0xb1, 0xfc, 0x20, 0x8f, 0x02, 0xd9, 0x65, 0x06, 0xbe, 0x26, 0x6f, 0xa2, 0x7f, 0xce, 0x3d, 0x69, 0x26, 0xdd, 0x13, 0x52, 0xbf, 0xbd, 0x92, 0x62, 0x59, 0x4c, 0x90, 0xac, 0x50, 0x45, 0x5e, 0xbb, 0x09, 0x03, 0x12, 0x29, 0x84, 0x00, 0xc4, 0xc9, 0x11, 0xff, 0x00, 0x42, 0xe7, 0xa7, 0x7a, 0xd4, 0xfd, 0x21, 0x79, 0xe9, 0x78, 0x71, 0x8b, 0x95, 0x39, 0x75, 0xaf, 0x4e, 0x98, 0x78, 0x42, 0x38, 0xdf, 0xff, 0xd1, 0xf0, 0xe6, 0xa0, 0x58, 0xc8, 0x84, 0x9a, 0xaa, 0x30, 0x55, 0xf9, 0x0a, 0x6f, 0x90, 0x0c, 0xca, 0x72, 0x48, 0xb8, 0x1e, 0x89, 0xa7, 0x23, 0x17, 0x24, 0xff, 0x00, 0x61, 0xb6, 0x54, 0x76, 0x6e, 0x1b, 0xa7, 0xbe, 0x50, 0xf2, 0xc1, 0xd7, 0x4c, 0x52, 0x5e, 0x33, 0x5b, 0xe9, 0x10, 0xf4, 0x54, 0x3c, 0x5e, 0x77, 0xee, 0x49, 0xec, 0x2b, 0xb6, 0x63, 0xe4, 0xc9, 0xc3, 0xef, 0x73, 0xf0, 0xe1, 0x32, 0x1b, 0xf2, 0x7a, 0x05, 0xce, 0xad, 0x65, 0xa1, 0x98, 0xb4, 0x0f, 0x2a, 0x5b, 0x23, 0xeb, 0x12, 0x00, 0x88, 0xb0, 0xa8, 0x66, 0x46, 0x3d, 0xea, 0x7b, 0xfb, 0x9e, 0x99, 0x89, 0xbc, 0x8d, 0x97, 0x3a, 0x34, 0x05, 0x32, 0x5d, 0x1f, 0xc9, 0x1a, 0x8c, 0x36, 0x8c, 0x6f, 0x66, 0xfa, 0xc6, 0xb7, 0x7d, 0xf0, 0x94, 0x04, 0xf0, 0x88, 0xc9, 0xd5, 0x9d, 0x8d, 0x4b, 0x11, 0xd4, 0x9f, 0xbb, 0x25, 0xc5, 0xdc, 0xa2, 0x03, 0x99, 0x4b, 0xbc, 0xf3, 0x0d, 0x97, 0x96, 0x74, 0xe5, 0xf2, 0xb6, 0x80, 0x95, 0xbd, 0x99, 0x15, 0xf5, 0x4b, 0xd2, 0x37, 0x58, 0x46, 0xd4, 0x27, 0xc5, 0xce, 0xc1, 0x7c, 0x30, 0x8e, 0x68, 0x94, 0x7b, 0x9e, 0x6d, 0xe6, 0x7b, 0x9b, 0x5d, 0x3a, 0xd8, 0xdb, 0x32, 0xfa, 0x77, 0x65, 0x15, 0xe4, 0x57, 0xa7, 0x21, 0x55, 0x04, 0x57, 0xef, 0xd8, 0x66, 0x56, 0x38, 0x19, 0x1b, 0xe8, 0xe0, 0x67, 0x98, 0xc7, 0x1a, 0x1c, 0xde, 0x71, 0x71, 0x79, 0x2c, 0xf2, 0xfa, 0x8c, 0x48, 0xec, 0xb5, 0x24, 0x9a, 0x0c, 0xce, 0x75, 0x29, 0xae, 0x8c, 0x67, 0xd4, 0xb5, 0x0b, 0x4b, 0x04, 0x05, 0xef, 0x2e, 0x66, 0x8e, 0x18, 0x08, 0x15, 0xdd, 0x8f, 0x11, 0xb0, 0xeb, 0x4c, 0x04, 0x5b, 0x21, 0x2a, 0x7d, 0x41, 0xe4, 0x4f, 0xcb, 0xcb, 0x5d, 0x12, 0x45, 0xb8, 0xb7, 0x53, 0x71, 0xaa, 0x9f, 0x86, 0x5b, 0xd6, 0x50, 0x4a, 0xed, 0xba, 0x46, 0x77, 0x00, 0x13, 0xd4, 0x8c, 0x85, 0xd3, 0x12, 0x6d, 0xeb, 0x1a, 0x67, 0x95, 0xd9, 0x39, 0x39, 0x50, 0xac, 0xff, 0x00, 0x6f, 0xc4, 0xff, 0x00, 0x1c, 0x81, 0x92, 0xb2, 0x6b, 0x6d, 0x02, 0xdd, 0xbd, 0x36, 0x92, 0x36, 0x2d, 0x1f, 0xc0, 0x2a, 0x0b, 0x28, 0x1b, 0x91, 0x41, 0xf4, 0x9c, 0xb6, 0x25, 0x81, 0x46, 0xfe, 0x81, 0xb5, 0xad, 0x3d, 0xba, 0x57, 0xb7, 0xf9, 0xf6, 0xc9, 0xb0, 0x7f, 0xff, 0xd2, 0xf0, 0xe2, 0x86, 0x95, 0xc4, 0x67, 0x7e, 0x3f, 0x11, 0xf7, 0xa8, 0x19, 0x06, 0x69, 0x8d, 0xca, 0xca, 0x24, 0x8f, 0xd3, 0x52, 0x24, 0x89, 0x47, 0x25, 0x1f, 0xcb, 0x20, 0xf8, 0xb2, 0xb2, 0x76, 0x6e, 0x88, 0x36, 0xf6, 0x6f, 0x2a, 0xc1, 0x6e, 0xfa, 0x45, 0xad, 0xbc, 0x3f, 0x0b, 0x46, 0x81, 0x4d, 0x46, 0xea, 0x7a, 0x9a, 0x83, 0x9a, 0xa9, 0xdd, 0xbb, 0xec, 0x7b, 0x06, 0x5b, 0xe5, 0xcf, 0x2e, 0x69, 0xfa, 0x5c, 0xcd, 0x7b, 0x14, 0x5e, 0xa5, 0xee, 0xf5, 0xb8, 0x7d, 0xdd, 0x99, 0xba, 0xef, 0x91, 0x16, 0x5b, 0x36, 0xb6, 0x65, 0x0d, 0xac, 0xb2, 0x5b, 0xed, 0x34, 0x81, 0x7a, 0xbb, 0x46, 0x40, 0x6a, 0x9e, 0xb4, 0x39, 0x31, 0x13, 0x49, 0xda, 0xd2, 0x9b, 0xed, 0x1e, 0xc4, 0x24, 0xb3, 0x35, 0xb2, 0x88, 0x60, 0x06, 0xe6, 0x56, 0x98, 0x96, 0x79, 0x1e, 0x31, 0x51, 0xc9, 0x8f, 0xcb, 0x00, 0xe6, 0xb3, 0xe4, 0xf9, 0x2b, 0xcc, 0x7a, 0x94, 0xda, 0x96, 0xa9, 0x71, 0x77, 0x70, 0x79, 0xcd, 0x33, 0x97, 0x76, 0x3f, 0xcc, 0xc6, 0xa6, 0x9f, 0x2e, 0x99, 0xb9, 0xc6, 0x2a, 0x21, 0xe6, 0x73, 0xca, 0xe6, 0x4a, 0x51, 0x1a, 0x99, 0x1c, 0x28, 0x04, 0x93, 0xd0, 0x0e, 0xa4, 0xe4, 0xda, 0x5f, 0x50, 0xfe, 0x4a, 0xfe, 0x48, 0xb5, 0xb2, 0xc1, 0xe6, 0x1f, 0x31, 0x7e, 0xef, 0x52, 0x91, 0x43, 0xc3, 0x6e, 0x77, 0xf4, 0x22, 0x6d, 0xbf, 0xe4, 0x63, 0x0e, 0xbf, 0xca, 0x36, 0xeb, 0x5c, 0x84, 0xa5, 0x48, 0x7d, 0x3b, 0x61, 0xa1, 0xdb, 0x5b, 0x2c, 0x71, 0xda, 0x45, 0xc4, 0x28, 0x00, 0x81, 0xdb, 0x31, 0xc9, 0xb4, 0xb2, 0x3b, 0x5d, 0x27, 0xa5, 0x05, 0x1b, 0xc7, 0xdb, 0x10, 0xa9, 0xbd, 0xa6, 0x93, 0x0c, 0x75, 0xe4, 0x39, 0x35, 0x41, 0x3d, 0xc5, 0x06, 0xdb, 0x8e, 0xfd, 0x46, 0x5b, 0x1d, 0x98, 0x95, 0x4f, 0x46, 0xdb, 0xd5, 0xfb, 0x29, 0x5e, 0x9d, 0x0d, 0x32, 0xeb, 0x61, 0x4f, 0xff, 0xd3, 0xf1, 0x46, 0x9a, 0x16, 0x1b, 0x91, 0x71, 0x28, 0xac, 0x4a, 0x14, 0x30, 0x3e, 0x19, 0x54, 0xb9, 0x36, 0xc7, 0x9b, 0x2d, 0xd1, 0x6c, 0x45, 0xe3, 0xdc, 0xde, 0xc8, 0x95, 0x5b, 0x87, 0xf8, 0x41, 0x1d, 0x10, 0x54, 0x01, 0x98, 0x79, 0x25, 0xd1, 0xda, 0xe9, 0xe1, 0xb5, 0x9e, 0xac, 0xeb, 0x42, 0xba, 0x8e, 0xdf, 0x8c, 0x31, 0x21, 0x70, 0xb4, 0x5d, 0xbe, 0xc5, 0x7c, 0x2b, 0xed, 0xe1, 0x94, 0x18, 0xb9, 0x51, 0x3d, 0x03, 0x2c, 0x13, 0x6b, 0xf1, 0x42, 0x6e, 0xe2, 0xb7, 0x12, 0xa0, 0xdd, 0x50, 0x9f, 0x4f, 0x6f, 0xa7, 0x6f, 0xc7, 0x03, 0x61, 0xa0, 0x83, 0xb5, 0xf3, 0x97, 0x98, 0x20, 0x9c, 0x44, 0xea, 0xd0, 0xad, 0x48, 0x64, 0x90, 0x21, 0xd8, 0x9f, 0xa7, 0xa6, 0x44, 0xca, 0x99, 0xc6, 0x36, 0xcb, 0x74, 0x5d, 0x7e, 0x5b, 0xfe, 0x31, 0x6a, 0x31, 0xf3, 0x8c, 0xd0, 0xad, 0x40, 0xa3, 0x1f, 0x7c, 0x44, 0xd6, 0x51, 0xd9, 0xe0, 0x5f, 0x9a, 0x7e, 0x41, 0x9f, 0x40, 0xf3, 0x14, 0xba, 0x85, 0xba, 0x34, 0xba, 0x2d, 0xfb, 0x34, 0xd0, 0xcf, 0x4f, 0xb0, 0xce, 0x6a, 0x51, 0xe9, 0xb0, 0x20, 0xf4, 0xf1, 0x19, 0xb2, 0xc3, 0x90, 0x11, 0x4e, 0x97, 0x55, 0x80, 0x83, 0xc4, 0x17, 0x7e, 0x4c, 0x79, 0x19, 0xfc, 0xd1, 0xe7, 0x78, 0x4b, 0x91, 0x1d, 0xae, 0x92, 0xa6, 0xf6, 0x46, 0x75, 0xe4, 0xad, 0x22, 0x1f, 0xdd, 0xa1, 0x07, 0xb3, 0x1e, 0xfe, 0xd9, 0x92, 0xeb, 0x4b, 0xed, 0xfd, 0x0a, 0xc2, 0x63, 0x27, 0xa4, 0x88, 0x17, 0x60, 0x49, 0x35, 0xdc, 0x8e, 0xa5, 0x7d, 0xab, 0xd3, 0x28, 0x90, 0x50, 0xcd, 0xed, 0x2d, 0xda, 0x15, 0x55, 0x51, 0xf1, 0x1a, 0x0a, 0xf7, 0x39, 0x5d, 0xaa, 0x77, 0x6f, 0x01, 0x8e, 0xa7, 0x7d, 0xfa, 0xff, 0x00, 0x66, 0x10, 0xa8, 0xb8, 0x63, 0x76, 0x90, 0xa8, 0x20, 0x06, 0x56, 0xdb, 0x61, 0xda, 0xbd, 0x4f, 0xcb, 0x24, 0x15, 0x0f, 0xf5, 0x66, 0xe5, 0x5f, 0x4c, 0x53, 0xc3, 0xb7, 0xce, 0x99, 0x6b, 0x17, 0xff, 0xd4, 0xf0, 0xec, 0x57, 0x6f, 0x32, 0xa5, 0xa4, 0x43, 0x76, 0x75, 0xa9, 0xf1, 0x03, 0xfa, 0x64, 0x08, 0x6c, 0x8e, 0xfb, 0x3d, 0x7f, 0xcb, 0x16, 0x2b, 0x3d, 0xbc, 0x16, 0xa3, 0x66, 0x6d, 0x98, 0xfb, 0x1e, 0xb9, 0xac, 0xc8, 0x77, 0xb7, 0x7d, 0x01, 0xb3, 0x37, 0xb8, 0xd3, 0x46, 0x95, 0x68, 0x86, 0xd2, 0x2e, 0x4e, 0xab, 0xf0, 0x23, 0x11, 0x4e, 0x5f, 0xcd, 0x98, 0xe7, 0x25, 0x96, 0x71, 0x83, 0x0f, 0xd6, 0x3c, 0xb9, 0xe7, 0x0d, 0x7c, 0x41, 0x22, 0x5e, 0xb3, 0x20, 0x0c, 0x65, 0x80, 0xc8, 0x63, 0x8e, 0xbb, 0x95, 0xa5, 0x07, 0xeb, 0xcc, 0xac, 0x73, 0x83, 0x4e, 0x5c, 0x59, 0x09, 0xd8, 0xec, 0xc8, 0x57, 0x41, 0xd3, 0x4e, 0x95, 0xa5, 0x5b, 0x4b, 0x6a, 0xcb, 0xab, 0x43, 0x10, 0x4b, 0xeb, 0x85, 0xa2, 0x2c, 0x8e, 0x3f, 0x68, 0x54, 0xf5, 0x00, 0xd3, 0x97, 0x7a, 0x65, 0x79, 0xa6, 0x24, 0x76, 0x6f, 0xd3, 0x62, 0x96, 0x30, 0x78, 0xcb, 0x21, 0xf2, 0xf4, 0x22, 0xce, 0x54, 0x8e, 0x46, 0x26, 0x10, 0x7e, 0x0a, 0xf5, 0xd8, 0xf5, 0x1f, 0x31, 0x98, 0x83, 0x73, 0xb3, 0x91, 0xcd, 0x67, 0xe6, 0x7d, 0xe8, 0x16, 0x69, 0x6f, 0x10, 0x1f, 0x54, 0x9a, 0x37, 0xf5, 0x41, 0x5e, 0x7f, 0x0a, 0x29, 0x62, 0x02, 0xf8, 0x9c, 0xc8, 0x8c, 0x77, 0x6a, 0x99, 0xa0, 0x89, 0xff, 0x00, 0x9c, 0x74, 0xd2, 0xed, 0xed, 0xfc, 0xbb, 0x7b, 0xaa, 0x9a, 0x7d, 0x62, 0xfe, 0x46, 0x2d, 0xfe, 0x4c, 0x51, 0x31, 0x11, 0xa9, 0xf6, 0xef, 0x9b, 0x30, 0x5e, 0x7b, 0x38, 0xdd, 0xf4, 0x7f, 0x95, 0x94, 0xbc, 0x12, 0x43, 0x30, 0x6a, 0xb2, 0xf3, 0x86, 0x40, 0x3e, 0xcb, 0xd7, 0x6a, 0xd7, 0xb1, 0xe9, 0x8f, 0x37, 0x19, 0x97, 0x41, 0x2c, 0x71, 0x20, 0xf5, 0x36, 0x9c, 0x55, 0x78, 0x1d, 0x8a, 0x91, 0xd7, 0x11, 0x14, 0x5a, 0x3e, 0x19, 0x03, 0x10, 0x6b, 0xca, 0xbd, 0x86, 0xf8, 0x9d, 0x95, 0x18, 0x36, 0x65, 0x2e, 0xbc, 0x54, 0x1f, 0xa2, 0x99, 0x00, 0x59, 0x2a, 0x6f, 0x5e, 0x55, 0x15, 0xe9, 0x5f, 0xc3, 0x2f, 0xb6, 0x14, 0xff, 0x00, 0xff, 0xd5, 0xf1, 0x95, 0xfe, 0x80, 0x74, 0x0d, 0x7c, 0xd9, 0x89, 0x3d, 0x78, 0x57, 0x8b, 0xc5, 0x28, 0xe8, 0x55, 0xf7, 0x1f, 0x48, 0xca, 0x38, 0xb8, 0x83, 0x9f, 0x93, 0x07, 0x85, 0x3a, 0x7a, 0x6f, 0x95, 0x66, 0x2b, 0x2c, 0x4c, 0x0d, 0x14, 0x00, 0x3e, 0x9c, 0xc3, 0x98, 0x76, 0xb8, 0x45, 0xbd, 0x02, 0xde, 0x48, 0xee, 0xdc, 0xa0, 0x15, 0xe2, 0x2b, 0xc8, 0x8a, 0x8a, 0xfd, 0x3b, 0x66, 0x3f, 0x00, 0x73, 0x84, 0x2d, 0x36, 0xb5, 0xb5, 0x9e, 0x35, 0x1c, 0x29, 0xc4, 0xfe, 0xc8, 0x04, 0x7f, 0xc4, 0x69, 0x91, 0xe1, 0x67, 0x2c, 0x4a, 0xd2, 0xe9, 0x4e, 0xe3, 0xd4, 0xf4, 0x81, 0x5a, 0x12, 0xc5, 0x41, 0x3f, 0x79, 0x38, 0x9b, 0x60, 0x20, 0x07, 0x34, 0xb0, 0xc9, 0x03, 0x5c, 0x23, 0x03, 0x53, 0x13, 0x56, 0x88, 0xdf, 0x09, 0xda, 0x9b, 0xd3, 0xb6, 0x52, 0x0e, 0xec, 0xe4, 0x29, 0x24, 0xfc, 0xd0, 0xe7, 0x75, 0xe5, 0x57, 0x6b, 0x61, 0xfb, 0xf0, 0xca, 0xaa, 0x57, 0xa8, 0xe6, 0x78, 0x1a, 0x7d, 0xf9, 0x95, 0x8a, 0x5e, 0xa0, 0xe3, 0x67, 0x8f, 0xa0, 0xbd, 0x5b, 0xf2, 0xdf, 0x4a, 0x82, 0xcb, 0x4a, 0xb3, 0xb0, 0xb4, 0x41, 0x0a, 0x70, 0x48, 0xd9, 0x57, 0x60, 0x51, 0x3a, 0x8f, 0xbc, 0xe6, 0x7b, 0xcb, 0xe4, 0x3b, 0xa7, 0x3f, 0x9b, 0x9f, 0x9a, 0xba, 0x77, 0xe5, 0x5f, 0x95, 0x9c, 0x59, 0x94, 0x9f, 0xcd, 0x37, 0x8c, 0xa9, 0xa6, 0xd9, 0x39, 0xaa, 0xd0, 0x7d, 0xa9, 0x1c, 0x03, 0x5e, 0x09, 0xff, 0x00, 0x0c, 0x76, 0xcb, 0x62, 0x2d, 0xa5, 0xf2, 0x85, 0xbf, 0xe7, 0x87, 0xe6, 0xa3, 0x5e, 0x4d, 0xa8, 0xc9, 0xe6, 0x8b, 0xd5, 0x69, 0x5c, 0xb0, 0x4a, 0xab, 0xc4, 0xb5, 0x35, 0x0a, 0xaa, 0xea, 0x40, 0x03, 0xa0, 0xf6, 0xcb, 0x40, 0x4d, 0x3e, 0xdb, 0xff, 0x00, 0x9c, 0x7f, 0xfc, 0xce, 0x4f, 0xcc, 0xbf, 0x26, 0x25, 0xe5, 0xd3, 0x2f, 0xe9, 0xdd, 0x3d, 0xfe, 0xab, 0xa9, 0xaa, 0xd2, 0xa6, 0x40, 0x2a, 0xb2, 0x71, 0x00, 0x01, 0xea, 0x0d, 0xe8, 0x3a, 0x64, 0x25, 0x16, 0x1c, 0x8b, 0xd9, 0x51, 0x39, 0x28, 0x12, 0x51, 0x41, 0xfd, 0xa3, 0xd2, 0xb9, 0x4f, 0x0d, 0x33, 0xb5, 0xf4, 0x87, 0x9d, 0x79, 0x0e, 0xb4, 0xaf, 0x6a, 0xf8, 0xf1, 0xf0, 0xc9, 0xda, 0xbf, 0xff, 0xd6, 0xf2, 0xc6, 0xb5, 0x68, 0x64, 0xd0, 0x6d, 0x35, 0x20, 0x39, 0xcd, 0x13, 0x0f, 0x5e, 0x61, 0xfc, 0x8f, 0x40, 0x8b, 0x5e, 0xe0, 0x66, 0x1c, 0x4f, 0xaa, 0x9d, 0xe6, 0xa6, 0x1e, 0x91, 0x2e, 0xa9, 0x87, 0x95, 0xee, 0x9c, 0xc5, 0x55, 0x34, 0x60, 0x40, 0xae, 0x57, 0x30, 0xd9, 0xa7, 0x95, 0xbd, 0x6f, 0xcb, 0x26, 0x39, 0x40, 0x0d, 0x4e, 0xc0, 0x9f, 0x9e, 0x50, 0x5d, 0xac, 0x79, 0x33, 0x8b, 0xbb, 0x9b, 0x3b, 0x6b, 0x35, 0x48, 0x54, 0x09, 0x29, 0x56, 0x7f, 0xe1, 0x86, 0x72, 0x00, 0x2c, 0x6e, 0xf7, 0x63, 0x3e, 0x63, 0xbd, 0xbd, 0x5d, 0x20, 0x2a, 0xb3, 0xa4, 0x33, 0x48, 0xab, 0x21, 0x43, 0xf1, 0x2c, 0x47, 0xed, 0x1d, 0xbc, 0x73, 0x18, 0x9b, 0x64, 0x28, 0x96, 0x3a, 0xc7, 0x49, 0xb0, 0xf4, 0xcc, 0xe9, 0x73, 0x6c, 0xb4, 0xf8, 0x67, 0x92, 0x32, 0x21, 0x70, 0x7b, 0x89, 0x05, 0x57, 0xef, 0x38, 0x28, 0x94, 0x4a, 0x7d, 0x13, 0x7d, 0x6a, 0xd3, 0x4c, 0xb8, 0xf2, 0xc3, 0xc8, 0x2e, 0x03, 0xf3, 0xe2, 0x7d, 0x33, 0xb7, 0xc5, 0xcc, 0x71, 0x03, 0xc6, 0xb9, 0x64, 0x06, 0xe2, 0x9a, 0xf2, 0x4f, 0xd2, 0x6d, 0xe9, 0xfe, 0x41, 0x45, 0x5b, 0x18, 0x66, 0xa5, 0x64, 0x09, 0xf4, 0xd5, 0xb7, 0xcd, 0x93, 0xc7, 0xcf, 0x9b, 0xe5, 0x6f, 0xf9, 0xc8, 0x0d, 0x56, 0xeb, 0x59, 0xfc, 0xce, 0xd5, 0x12, 0x61, 0xc4, 0x69, 0xe9, 0x0d, 0xa4, 0x4b, 0xfe, 0x48, 0x40, 0xd5, 0x3e, 0xe4, 0xb6, 0x64, 0x8e, 0x4c, 0x02, 0x61, 0x65, 0xa0, 0x14, 0xb4, 0xb6, 0xb0, 0xb1, 0xb6, 0xb2, 0x97, 0xcb, 0xf1, 0x5a, 0x2d, 0xc6, 0xa5, 0xac, 0xb4, 0x70, 0x5d, 0xc7, 0x3d, 0xc1, 0x51, 0x24, 0x91, 0xc9, 0x31, 0x75, 0x6b, 0x70, 0x9f, 0x14, 0x68, 0x01, 0x46, 0xe4, 0xb5, 0xa3, 0x17, 0xcb, 0x40, 0x61, 0x6f, 0x47, 0xff, 0x00, 0x9c, 0x3a, 0x8f, 0x5b, 0x4f, 0x3c, 0x6b, 0xb7, 0xfa, 0x30, 0x91, 0x3c, 0xa4, 0xb1, 0x95, 0xb9, 0x82, 0x42, 0x0a, 0xbc, 0x8e, 0xe4, 0xdb, 0xa9, 0xef, 0xc9, 0x17, 0x91, 0x24, 0x7c, 0xb2, 0x05, 0x64, 0xfb, 0x75, 0x64, 0x32, 0x39, 0x69, 0x5b, 0x9c, 0xad, 0xb9, 0xdb, 0xa7, 0xb5, 0x3b, 0x53, 0x2a, 0x21, 0x41, 0x44, 0xf3, 0x8b, 0x8f, 0x2e, 0x43, 0x9d, 0x2b, 0xd4, 0x57, 0x23, 0x41, 0x36, 0xff, 0x00, 0xff, 0xd7, 0xf0, 0xc0, 0xd5, 0xb5, 0x11, 0x64, 0xb6, 0x3f, 0x59, 0x90, 0xd9, 0xab, 0x06, 0xf4, 0x79, 0x7c, 0x3b, 0x74, 0xc8, 0x08, 0x8b, 0xb6, 0xe3, 0x96, 0x55, 0x57, 0xb3, 0x3e, 0xf2, 0x35, 0xc7, 0xd6, 0x0b, 0x45, 0x5d, 0xdc, 0x8a, 0x7d, 0xd9, 0x8d, 0x94, 0x3b, 0x3d, 0x1c, 0x9e, 0xc3, 0xe5, 0xc3, 0x2c, 0x7c, 0xc5, 0x0f, 0xee, 0xdb, 0x8b, 0x0c, 0xc4, 0x26, 0x9d, 0xa0, 0x9a, 0x7d, 0x2c, 0xe5, 0xe4, 0x55, 0x7f, 0xee, 0xc1, 0x15, 0x04, 0xd0, 0x12, 0x3c, 0x72, 0x89, 0x1b, 0x2c, 0xcc, 0xa8, 0x2a, 0x8b, 0x87, 0xbb, 0x63, 0x1a, 0x28, 0x65, 0xf0, 0xed, 0xf2, 0xc3, 0xc2, 0x0a, 0x06, 0x4a, 0x46, 0xc7, 0xa5, 0xa3, 0x59, 0xc8, 0xb2, 0xc7, 0x45, 0x22, 0x9c, 0x14, 0x54, 0x10, 0x46, 0xf5, 0x1d, 0x32, 0x5c, 0x14, 0x14, 0xe4, 0x32, 0x2f, 0x3a, 0xf3, 0xb6, 0x90, 0x9a, 0x6d, 0xae, 0x9f, 0x3d, 0xab, 0xb8, 0x8a, 0x3b, 0xf8, 0x39, 0x44, 0x58, 0xf0, 0x08, 0xd5, 0x14, 0xa5, 0x7b, 0x65, 0x98, 0x8e, 0xfb, 0xb5, 0x67, 0x87, 0xa5, 0xef, 0x5e, 0x44, 0x96, 0x35, 0xb5, 0xb6, 0x59, 0x36, 0xfd, 0xd8, 0xa0, 0xf1, 0x20, 0x53, 0x33, 0xc0, 0x79, 0x59, 0x73, 0x7c, 0xd7, 0xf9, 0xfb, 0xa2, 0xcd, 0x67, 0xf9, 0xa7, 0x7b, 0x72, 0xf1, 0x71, 0x83, 0x53, 0x86, 0x0b, 0x98, 0x24, 0x22, 0x8a, 0xcc, 0x88, 0x23, 0x7f, 0xb8, 0xae, 0xf9, 0x7c, 0x50, 0x1e, 0x5f, 0x7c, 0x48, 0x21, 0x44, 0x6b, 0xce, 0x9b, 0xb0, 0x1b, 0x9e, 0xf5, 0xaf, 0x8e, 0x4d, 0x5f, 0x7a, 0x7f, 0xce, 0x34, 0xf9, 0x5d, 0x3c, 0xa3, 0xf9, 0x69, 0x63, 0xa9, 0x3c, 0x27, 0xeb, 0xda, 0xe1, 0x37, 0xd7, 0x2e, 0xaa, 0xdb, 0x06, 0xda, 0x30, 0x49, 0xfe, 0x54, 0x03, 0x03, 0x49, 0xdc, 0xb3, 0xaf, 0x38, 0xfe, 0x6a, 0xf9, 0x47, 0xc9, 0x3a, 0x74, 0x97, 0xfa, 0xf6, 0xaf, 0x15, 0x85, 0xb8, 0x75, 0x89, 0xb8, 0x87, 0x9a, 0x72, 0xee, 0x2a, 0x14, 0x24, 0x60, 0xb1, 0xa8, 0xdf, 0x07, 0x0b, 0x2d, 0xcb, 0xcf, 0x7f, 0xe8, 0x6a, 0xff, 0x00, 0x26, 0xbd, 0x6a, 0x7f, 0x89, 0x2f, 0xf8, 0x52, 0x9e, 0xb7, 0xe8, 0xb9, 0xb8, 0x57, 0xc2, 0x95, 0xe9, 0x8f, 0x08, 0x5a, 0x2f, 0xff, 0xd0, 0xf0, 0x4d, 0x40, 0xaa, 0xd7, 0x00, 0x64, 0xcb, 0x3c, 0x97, 0xa8, 0xb5, 0x9e, 0xa3, 0x1a, 0xd6, 0x84, 0x95, 0x3f, 0x45, 0x72, 0x9c, 0xa2, 0xc3, 0x99, 0xa5, 0x9d, 0x49, 0xf4, 0x17, 0x97, 0xaf, 0x63, 0x17, 0x52, 0x6f, 0xf0, 0xc8, 0x43, 0x6f, 0x9a, 0xe9, 0x07, 0x70, 0x0e, 0xec, 0x83, 0x51, 0x44, 0xb8, 0x61, 0x1a, 0x9e, 0x11, 0xd3, 0x91, 0x60, 0x68, 0x6b, 0xd3, 0x31, 0x4f, 0x36, 0xd3, 0x4c, 0x52, 0xef, 0x4c, 0xd5, 0x0c, 0xc4, 0x69, 0xda, 0x94, 0xc8, 0x3a, 0xf0, 0x66, 0x07, 0x73, 0xe0, 0x40, 0xfd, 0x79, 0x93, 0x12, 0x1c, 0x9c, 0x32, 0xc7, 0xfc, 0x41, 0x33, 0xd2, 0xb4, 0x6f, 0x38, 0x98, 0x65, 0x76, 0xbf, 0x69, 0x42, 0xd0, 0xaa, 0xc9, 0xde, 0x95, 0xad, 0x28, 0x46, 0x4e, 0xac, 0x39, 0x77, 0x80, 0x11, 0xbf, 0xd8, 0xc7, 0x7c, 0xe1, 0xa5, 0xf9, 0x92, 0x4d, 0x32, 0x5b, 0x8b, 0x93, 0x27, 0xa7, 0x68, 0x56, 0xe2, 0x45, 0xda, 0x85, 0x61, 0x6e, 0x67, 0xad, 0x6b, 0xb0, 0x38, 0xc2, 0x81, 0xe4, 0xc7, 0x52, 0x31, 0x1c, 0x67, 0x86, 0x5b, 0xbd, 0x37, 0xca, 0x7a, 0x94, 0xb1, 0x69, 0xb6, 0x2e, 0xb7, 0x15, 0x48, 0xc2, 0xb4, 0x52, 0x53, 0xac, 0x32, 0xaf, 0xb1, 0xed, 0x9b, 0x10, 0x36, 0x78, 0x5c, 0x9f, 0x51, 0x64, 0x1f, 0x98, 0x3e, 0x58, 0xb6, 0xfc, 0xc8, 0xf2, 0xe5, 0xbc, 0x68, 0x52, 0x2d, 0x5a, 0xd1, 0x84, 0xb6, 0xf3, 0x95, 0x0e, 0xc0, 0x85, 0xe2, 0xcb, 0xd8, 0xd1, 0xbb, 0xe4, 0xc1, 0xa6, 0x97, 0xce, 0x17, 0x5f, 0x95, 0xde, 0x6d, 0xb6, 0xbe, 0xb7, 0x69, 0x34, 0xf3, 0x3c, 0x72, 0xcf, 0xe8, 0xa3, 0x45, 0x49, 0x95, 0x4a, 0x90, 0x3e, 0x35, 0x5a, 0x95, 0x1d, 0xfe, 0x21, 0x93, 0x4d, 0xbe, 0xd2, 0xd2, 0xf5, 0x8b, 0xbd, 0x32, 0x2d, 0x3f, 0x4c, 0x9a, 0xe4, 0xca, 0x9e, 0x90, 0x85, 0x65, 0x55, 0x08, 0x85, 0x91, 0x01, 0x3b, 0x0a, 0x05, 0xe9, 0xb0, 0xc0, 0x5a, 0xc3, 0xcd, 0x3f, 0x3b, 0x7f, 0x26, 0xec, 0xff, 0x00, 0x35, 0x6d, 0x6d, 0xb5, 0x3d, 0x16, 0xfe, 0x0d, 0x3b, 0xcd, 0x96, 0x01, 0x92, 0x46, 0x9e, 0xa2, 0x0b, 0xc8, 0xb7, 0x28, 0x92, 0x71, 0xfb, 0x2e, 0xa7, 0xec, 0x3d, 0x0f, 0xc2, 0x68, 0x71, 0x05, 0x95, 0xd3, 0xe7, 0x9f, 0xfa, 0x16, 0x2f, 0xcd, 0x7f, 0x43, 0xd6, 0xfa, 0xa5, 0x97, 0xab, 0xeb, 0x7a, 0x5f, 0x55, 0xfa, 0xec, 0x5e, 0xaf, 0x0f, 0xf7, 0xed, 0x2b, 0x4e, 0x15, 0xff, 0x00, 0x65, 0xdf, 0x8e, 0x14, 0xf1, 0xbf, 0xff, 0xd1, 0xf0, 0x5a, 0xa7, 0x18, 0x5e, 0x56, 0x1f, 0x68, 0x71, 0x5f, 0xa7, 0xbe, 0x2a, 0x98, 0xdb, 0xfa, 0x90, 0x24, 0x37, 0xb0, 0xfd, 0xb8, 0xa8, 0x58, 0x78, 0xae, 0x43, 0xc9, 0xb4, 0x6d, 0xbb, 0xda, 0x3c, 0xa1, 0xad, 0x43, 0xa8, 0xda, 0xc5, 0x2a, 0x3d, 0x26, 0x5a, 0x02, 0x2b, 0xbe, 0x60, 0x64, 0x8d, 0x17, 0x6f, 0x8b, 0x20, 0x90, 0x7a, 0x3c, 0x32, 0x8b, 0xa8, 0x02, 0xf3, 0xfd, 0xe0, 0x1b, 0x11, 0x98, 0x66, 0x3b, 0xb9, 0x62, 0x54, 0x83, 0x36, 0xf2, 0xa4, 0xe4, 0x29, 0x34, 0xeb, 0xc8, 0x74, 0xae, 0x0d, 0xc3, 0x65, 0x82, 0x13, 0x6b, 0x57, 0xba, 0x54, 0xe4, 0x8c, 0x41, 0x1b, 0x75, 0xa7, 0xe0, 0x72, 0x5c, 0x4c, 0x84, 0x50, 0x5a, 0xb3, 0xdd, 0xdd, 0xc3, 0x24, 0x33, 0xb1, 0x60, 0xe0, 0x86, 0x52, 0x45, 0x38, 0xd2, 0x87, 0x24, 0x26, 0x6d, 0x8c, 0xe1, 0x41, 0x25, 0xfc, 0xa3, 0xd7, 0x2f, 0x6f, 0x3c, 0xbf, 0x73, 0xa5, 0xb2, 0x2c, 0xd1, 0x69, 0x17, 0x2f, 0x6b, 0x14, 0x8c, 0x0f, 0x21, 0x0d, 0x79, 0x46, 0x09, 0x15, 0xed, 0xb7, 0x4e, 0xd9, 0xb9, 0x8b, 0xcb, 0xe4, 0xa2, 0x5e, 0xa3, 0xa6, 0xdf, 0x6a, 0x36, 0xe4, 0xcd, 0x69, 0x1c, 0x4e, 0x84, 0x7c, 0x76, 0xab, 0x21, 0x67, 0xa8, 0xa7, 0xd9, 0xf8, 0x4d, 0x2b, 0xf3, 0xc3, 0x4d, 0x49, 0x57, 0x98, 0x75, 0x6f, 0x31, 0xda, 0xf9, 0xa3, 0x4b, 0xfd, 0x1f, 0x69, 0x1d, 0xae, 0xa1, 0xa9, 0x7e, 0xee, 0xe6, 0xd2, 0x79, 0x18, 0xf3, 0xb5, 0x1f, 0xee, 0xd9, 0x0a, 0x01, 0x4e, 0x3f, 0xb3, 0x4d, 0xf2, 0x9c, 0xb9, 0x04, 0x05, 0xb7, 0xe2, 0x87, 0x1e, 0xdd, 0x19, 0x3e, 0xaf, 0x6b, 0xae, 0xcb, 0x6d, 0x13, 0x0d, 0x45, 0xa2, 0x8e, 0x06, 0xe5, 0x13, 0x2a, 0x02, 0x01, 0x5e, 0x82, 0xb5, 0x04, 0xe6, 0x11, 0xd4, 0xcd, 0xda, 0x43, 0x49, 0x8e, 0xb7, 0xdc, 0xb1, 0x51, 0xe6, 0x4d, 0x76, 0xd2, 0x61, 0x15, 0xaa, 0x4b, 0xa8, 0xc9, 0x6e, 0x49, 0x79, 0x20, 0xe6, 0x8c, 0x49, 0xad, 0x43, 0x16, 0xe4, 0xa7, 0xaf, 0x43, 0xd3, 0x26, 0x35, 0x75, 0xcd, 0xa8, 0xe8, 0x87, 0x46, 0xbf, 0xc7, 0x9a, 0xff, 0x00, 0xd6, 0xbf, 0x48, 0xfe, 0x88, 0xfd, 0xe7, 0x0f, 0xab, 0xfa, 0x3f, 0x58, 0x7f, 0x5f, 0x8d, 0x3f, 0x9f, 0xa7, 0x5e, 0xd4, 0xc3, 0xf9, 0xd1, 0x7c, 0xb6, 0x47, 0xe4, 0x3a, 0x5b, 0xff, 0xd2, 0xf0, 0xb7, 0xa6, 0x1e, 0xdf, 0xd3, 0xf6, 0xa5, 0x71, 0x54, 0xdb, 0x4b, 0x80, 0x3c, 0x42, 0x26, 0xee, 0x29, 0xbe, 0x51, 0x23, 0x4e, 0x44, 0x05, 0x84, 0x45, 0xa5, 0xd5, 0xf7, 0x97, 0x2e, 0xfd, 0x6b, 0x6a, 0x98, 0x09, 0xab, 0xc7, 0xfc, 0x46, 0x3b, 0x4c, 0x26, 0x32, 0x30, 0x3e, 0x4f, 0x49, 0xd0, 0xfc, 0xfb, 0x05, 0xd4, 0x4a, 0x7d, 0x40, 0xac, 0x3a, 0x8e, 0x84, 0x1c, 0xc5, 0x96, 0x2a, 0x73, 0xe1, 0x9c, 0x16, 0x6d, 0xa5, 0x79, 0x86, 0xd6, 0xec, 0x80, 0x5a, 0xa0, 0xf5, 0xca, 0xcc, 0x5c, 0xa1, 0x2b, 0x1b, 0x26, 0x30, 0x6a, 0x31, 0x46, 0xcf, 0x1c, 0x87, 0x94, 0x64, 0x9e, 0x3d, 0xb6, 0xf0, 0xca, 0xa8, 0x39, 0x51, 0x99, 0x42, 0x6b, 0x1a, 0xc5, 0xa5, 0xa5, 0x94, 0xf7, 0x92, 0xc8, 0xaa, 0xb1, 0x23, 0x30, 0x04, 0xf8, 0x0e, 0x9f, 0x4e, 0x4a, 0x11, 0xb2, 0xd5, 0x9b, 0x25, 0x06, 0x1b, 0xff, 0x00, 0x38, 0xfd, 0xad, 0xdf, 0xda, 0xf9, 0xa2, 0xfe, 0xc5, 0x42, 0xbe, 0x9b, 0x7f, 0x0b, 0xdd, 0xdd, 0x07, 0xaf, 0x14, 0x68, 0xd8, 0x71, 0x6d, 0xbb, 0x90, 0xfc, 0x73, 0x6e, 0xf2, 0xf2, 0xdd, 0xf4, 0xad, 0xa6, 0xab, 0x6d, 0x69, 0x14, 0xfa, 0xee, 0xa0, 0xe2, 0x0b, 0x0d, 0x39, 0x19, 0xfe, 0x11, 0xc5, 0x1a, 0x4a, 0x1d, 0x8f, 0x73, 0x4f, 0xf8, 0x96, 0x0b, 0x40, 0x8d, 0xec, 0xf3, 0x6d, 0x3f, 0x52, 0xba, 0xd6, 0x35, 0x8b, 0xbf, 0x36, 0x6a, 0x5f, 0x0d, 0xc5, 0xdc, 0xa8, 0xb6, 0xa8, 0x7a, 0xc5, 0x6c, 0x9b, 0x22, 0x0f, 0xa3, 0x73, 0x9a, 0xbc, 0xb3, 0xe2, 0x36, 0xed, 0xb1, 0x43, 0x80, 0x53, 0xd0, 0xa7, 0xd4, 0x44, 0xfa, 0x7a, 0xda, 0x83, 0xbd, 0x3e, 0x2f, 0xa7, 0x2b, 0xad, 0x9b, 0xb8, 0x8d, 0xa8, 0xe8, 0x91, 0xdb, 0xfa, 0x2d, 0x6f, 0xc3, 0x8a, 0x2d, 0x56, 0xa3, 0xad, 0x4f, 0x5c, 0xa4, 0x0d, 0xdc, 0xa3, 0xca, 0xd0, 0xbf, 0xa1, 0xe3, 0xfa, 0xe7, 0x0f, 0xf2, 0xb9, 0x57, 0xbf, 0x1a, 0xe4, 0xb8, 0x57, 0xc5, 0xdd, 0xff, 0xd3, 0xf0, 0xcc, 0x5d, 0x7b, 0x70, 0xc5, 0x53, 0x6d, 0x2f, 0xd5, 0xe4, 0x69, 0xfd, 0xdf, 0xec, 0xd7, 0xad, 0x7d, 0xb2, 0x8c, 0x8d, 0xd8, 0xed, 0x91, 0x9f, 0x43, 0xea, 0xe7, 0xeb, 0x94, 0xad, 0x3e, 0x1e, 0x95, 0xfc, 0x72, 0x81, 0x7d, 0x1c, 0x9d, 0xba, 0xb1, 0x7b, 0xdf, 0xa9, 0x7a, 0xdf, 0xee, 0x2f, 0xd4, 0xfa, 0xe7, 0xed, 0x7a, 0x7f, 0xdd, 0xff, 0x00, 0xb2, 0xae, 0x64, 0x0b, 0xea, 0xe3, 0x9a, 0xbf, 0x4a, 0x6f, 0xa4, 0xff, 0x00, 0x89, 0xbd, 0x45, 0xfa, 0xb5, 0x79, 0xf7, 0xeb, 0xc7, 0xe9, 0xae, 0x57, 0x2e, 0x17, 0x23, 0x1f, 0x89, 0xd1, 0x99, 0x8f, 0xf1, 0xa7, 0x11, 0xcf, 0xd3, 0xf5, 0x29, 0xb5, 0x6b, 0xd3, 0xe8, 0xcc, 0x7f, 0x45, 0xb9, 0xa3, 0xc5, 0x62, 0xbe, 0x68, 0xff, 0x00, 0x15, 0xfd, 0x4c, 0xfe, 0x90, 0xaf, 0xd4, 0xab, 0xf1, 0x7a, 0x7f, 0x62, 0x9d, 0xab, 0xdf, 0x32, 0xb1, 0x70, 0x5e, 0xdc, 0xdc, 0x2d, 0x47, 0x8b, 0x5e, 0xae, 0x4c, 0xbf, 0xf2, 0x37, 0x9f, 0x3d, 0x5b, 0xd2, 0xff, 0x00, 0x8e, 0x87, 0xee, 0x29, 0x5a, 0xf2, 0xf4, 0xaa, 0xd4, 0xa5, 0x36, 0xa7, 0x3a, 0x57, 0xfd, 0x8e, 0x64, 0x3a, 0xf2, 0xf6, 0xbf, 0xcc, 0x7f, 0x5b, 0xfc, 0x23, 0xa7, 0xfe, 0x8e, 0xff, 0x00, 0x8e, 0x37, 0xd6, 0x63, 0xfa, 0xe5, 0x2b, 0xcb, 0x87, 0xec, 0xd6, 0xbd, 0xb9, 0x7d, 0xac, 0xc7, 0xcd, 0x7c, 0x2d, 0xf8, 0x2b, 0x89, 0x26, 0x8f, 0xd4, 0xfa, 0x94, 0x3e, 0x85, 0x29, 0xc9, 0x69, 0xfc, 0x33, 0x58, 0x5d, 0x9c, 0x79, 0xb2, 0xbb, 0x0f, 0xac, 0x7a, 0x2b, 0xea, 0x75, 0xef, 0x92, 0x0c, 0x53, 0x3d, 0x2f, 0xd4, 0xfa, 0xbb, 0xfa, 0x74, 0xf5, 0x39, 0x9a, 0xd7, 0xe7, 0x80, 0x53, 0x79, 0xba, 0x5b, 0xfe, 0x97, 0xfa, 0x4b, 0xfc, 0xba, 0x7f, 0xb1, 0xc7, 0xab, 0x1e, 0x8f, 0xff, 0xd9 -}; + 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, + 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xe1, 0x0d, 0x07, + 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, + 0x00, 0x08, 0x00, 0x0c, 0x01, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x9e, 0x01, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0xbe, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, + 0x00, 0x00, 0x00, 0xc3, 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0xcc, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0xd4, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0xdc, 0x01, 0x32, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0xf0, 0x01, 0x3c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0x01, 0x04, 0x02, 0x13, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x00, 0x00, 0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x02, 0xc4, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x00, 0x53, 0x4f, 0x4e, 0x59, 0x00, 0x44, 0x53, 0x43, + 0x2d, 0x50, 0x32, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x41, 0x64, + 0x6f, 0x62, 0x65, 0x20, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, + 0x70, 0x20, 0x37, 0x2e, 0x30, 0x00, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, + 0x31, 0x3a, 0x33, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x31, 0x30, 0x3a, 0x30, + 0x34, 0x00, 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58, 0x20, 0x31, + 0x30, 0x2e, 0x34, 0x2e, 0x38, 0x00, 0x00, 0x1c, 0x82, 0x9a, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x6a, 0x82, 0x9d, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x72, 0x88, 0x22, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x88, 0x27, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x64, 0x00, 0x00, 0x90, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x04, 0x30, 0x32, 0x32, 0x30, 0x90, 0x03, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x7a, 0x90, 0x04, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x8e, 0x91, 0x01, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x00, 0x91, 0x02, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xa2, 0x92, 0x04, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xaa, 0x92, 0x05, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xb2, 0x92, 0x07, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x92, 0x08, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x92, 0x0a, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xba, 0xa0, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x04, 0x30, 0x31, 0x30, 0x30, 0xa0, 0x01, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0xa0, 0x03, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0xa3, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0xa3, 0x01, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x03, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x06, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x08, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x09, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x0a, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x1c, + 0x00, 0x00, 0x00, 0x0a, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, + 0x32, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x30, 0x35, 0x3a, 0x35, 0x32, 0x00, + 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, 0x32, 0x30, 0x20, 0x32, + 0x33, 0x3a, 0x30, 0x35, 0x3a, 0x35, 0x32, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x4f, + 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x12, 0x01, 0x1b, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x1a, 0x01, 0x28, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x22, 0x02, 0x02, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x09, 0xdd, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x00, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, + 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, + 0xff, 0xed, 0x00, 0x0c, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x5f, 0x43, 0x4d, + 0x00, 0x02, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, + 0x64, 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0c, + 0x08, 0x08, 0x08, 0x09, 0x08, 0x0c, 0x09, 0x09, 0x0c, 0x11, 0x0b, 0x0a, + 0x0b, 0x11, 0x15, 0x0f, 0x0c, 0x0c, 0x0f, 0x15, 0x18, 0x13, 0x13, 0x15, + 0x13, 0x13, 0x18, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x01, 0x0d, 0x0b, 0x0b, 0x0d, 0x0e, 0x0d, 0x10, 0x0e, + 0x0e, 0x10, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, + 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, + 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, + 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x07, 0xff, 0xc4, 0x01, + 0x3f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x01, 0x05, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, + 0x00, 0x01, 0x04, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x07, 0x06, 0x08, + 0x05, 0x03, 0x0c, 0x33, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, + 0x31, 0x05, 0x41, 0x51, 0x61, 0x13, 0x22, 0x71, 0x81, 0x32, 0x06, 0x14, + 0x91, 0xa1, 0xb1, 0x42, 0x23, 0x24, 0x15, 0x52, 0xc1, 0x62, 0x33, 0x34, + 0x72, 0x82, 0xd1, 0x43, 0x07, 0x25, 0x92, 0x53, 0xf0, 0xe1, 0xf1, 0x63, + 0x73, 0x35, 0x16, 0xa2, 0xb2, 0x83, 0x26, 0x44, 0x93, 0x54, 0x64, 0x45, + 0xc2, 0xa3, 0x74, 0x36, 0x17, 0xd2, 0x55, 0xe2, 0x65, 0xf2, 0xb3, 0x84, + 0xc3, 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x27, 0x94, 0xa4, 0x85, 0xb4, 0x95, + 0xc4, 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, + 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, + 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x11, 0x00, + 0x02, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, + 0x06, 0x05, 0x35, 0x01, 0x00, 0x02, 0x11, 0x03, 0x21, 0x31, 0x12, 0x04, + 0x41, 0x51, 0x61, 0x71, 0x22, 0x13, 0x05, 0x32, 0x81, 0x91, 0x14, 0xa1, + 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xf0, 0x33, 0x24, 0x62, 0xe1, 0x72, + 0x82, 0x92, 0x43, 0x53, 0x15, 0x63, 0x73, 0x34, 0xf1, 0x25, 0x06, 0x16, + 0xa2, 0xb2, 0x83, 0x07, 0x26, 0x35, 0xc2, 0xd2, 0x44, 0x93, 0x54, 0xa3, + 0x17, 0x64, 0x45, 0x55, 0x36, 0x74, 0x65, 0xe2, 0xf2, 0xb3, 0x84, 0xc3, + 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, + 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, + 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x27, 0x37, 0x47, 0x57, 0x67, + 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, + 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf2, 0xed, 0xb2, 0x8d, + 0x4d, 0x45, 0xcd, 0x2f, 0x3f, 0x44, 0x68, 0x93, 0xc3, 0x58, 0xc8, 0xf1, + 0x1f, 0x8a, 0x33, 0x86, 0xda, 0x58, 0xc1, 0xa0, 0x02, 0x4f, 0xc4, 0xa1, + 0x69, 0xa5, 0x9b, 0x5b, 0x4b, 0x84, 0x73, 0xdf, 0xc9, 0x15, 0xf8, 0xe3, + 0xd1, 0x0e, 0x07, 0x93, 0xf3, 0xd1, 0x0f, 0x1c, 0x17, 0xef, 0x2e, 0x3b, + 0x5b, 0xdc, 0xff, 0x00, 0xdf, 0x42, 0xbf, 0x8f, 0x8e, 0xdc, 0x82, 0xca, + 0xd8, 0x37, 0x11, 0xa9, 0x3d, 0x82, 0x69, 0x2b, 0xc4, 0x6d, 0xc9, 0x75, + 0x25, 0xbc, 0xf7, 0xec, 0xa1, 0xb5, 0x74, 0x19, 0x5d, 0x2e, 0x8a, 0x9a, + 0x4b, 0x89, 0x7d, 0xc4, 0x68, 0xc6, 0xf6, 0xfe, 0xb2, 0xa0, 0x30, 0x1d, + 0x60, 0x86, 0x88, 0x8d, 0x49, 0x3e, 0x01, 0x11, 0x20, 0xa3, 0x8c, 0xb9, + 0xb1, 0xaa, 0x62, 0xad, 0xbf, 0x18, 0x97, 0x43, 0x47, 0x1d, 0xd2, 0xaf, + 0x04, 0xd9, 0xb8, 0xc8, 0x0d, 0x68, 0xe4, 0xf7, 0x3e, 0x48, 0xf1, 0x05, + 0xbc, 0x25, 0xaa, 0x07, 0x71, 0xd9, 0x14, 0x78, 0xf6, 0x49, 0xb5, 0x90, + 0xfd, 0xa7, 0xc6, 0x14, 0xfd, 0x1b, 0x1c, 0xff, 0x00, 0x4d, 0x8d, 0x2e, + 0x73, 0x8c, 0x35, 0xa3, 0x52, 0x4f, 0x92, 0x48, 0xa6, 0x1a, 0x24, 0xb6, + 0x2a, 0xfa, 0xa5, 0x9e, 0x60, 0x64, 0x39, 0x94, 0x13, 0xcb, 0x27, 0x73, + 0x80, 0xf3, 0x0c, 0xf6, 0xff, 0x00, 0xd2, 0x5a, 0x78, 0xbf, 0x53, 0x71, + 0xf6, 0x01, 0x75, 0xb6, 0x97, 0x6a, 0x25, 0xa1, 0xad, 0x1f, 0xf4, 0xb7, + 0x23, 0x48, 0xb7, 0x94, 0x84, 0x97, 0x5b, 0xff, 0x00, 0x32, 0xa9, 0xdd, + 0xfc, 0xed, 0x9b, 0x7e, 0x0d, 0x9e, 0x52, 0x4a, 0x95, 0x61, 0xff, 0xd0, + 0xf3, 0x3b, 0xa7, 0x70, 0xee, 0x01, 0x8f, 0xb9, 0x59, 0xfa, 0x7e, 0xdf, + 0xe4, 0xc8, 0xf9, 0x2a, 0xc2, 0x5c, 0x63, 0xc3, 0x54, 0x67, 0x87, 0x6e, + 0x10, 0x35, 0x68, 0xd4, 0x79, 0x1e, 0x53, 0x4a, 0xe0, 0xdc, 0xe9, 0xb8, + 0x1f, 0x6a, 0xda, 0x6c, 0x25, 0x94, 0x37, 0xb0, 0xd0, 0xb8, 0xad, 0x67, + 0xe4, 0x55, 0x8a, 0x5b, 0x8b, 0x82, 0xc0, 0x6f, 0x76, 0x80, 0x34, 0x49, + 0x05, 0x2e, 0x9e, 0xc6, 0x1c, 0x66, 0x31, 0xba, 0x10, 0x23, 0xe0, 0xaf, + 0xe1, 0x61, 0x53, 0x43, 0x8d, 0x81, 0xb3, 0x67, 0xef, 0x9e, 0x49, 0x2a, + 0x12, 0x6c, 0xb6, 0x63, 0x1a, 0x0c, 0x31, 0xba, 0x55, 0xcd, 0xac, 0xfa, + 0x8e, 0xdf, 0x91, 0x6e, 0x91, 0xd9, 0xb3, 0xc9, 0x73, 0x90, 0x7a, 0xab, + 0x6a, 0xc2, 0xa4, 0x60, 0xe2, 0x8f, 0xd2, 0x38, 0x03, 0x7d, 0x9e, 0x0d, + 0xff, 0x00, 0xcc, 0xd6, 0xd3, 0x6b, 0x71, 0x67, 0xd2, 0x3e, 0x64, 0x72, + 0xab, 0xdb, 0x8d, 0x54, 0x39, 0xc5, 0x83, 0x6b, 0x3d, 0xee, 0x2e, 0xd4, + 0x92, 0x3c, 0x4a, 0x56, 0xba, 0xb4, 0x79, 0x5c, 0xf7, 0xb2, 0x96, 0x6c, + 0x8d, 0xaf, 0x80, 0x48, 0x3c, 0xf0, 0xb2, 0x1f, 0x63, 0x9c, 0xe9, 0x3f, + 0x24, 0x5c, 0xdb, 0xdd, 0x76, 0x43, 0xde, 0xfd, 0x5c, 0xe3, 0x24, 0xfc, + 0x50, 0x00, 0x93, 0x0a, 0x78, 0x8a, 0x0d, 0x49, 0xca, 0xcf, 0x93, 0x63, + 0x1b, 0x7d, 0xd7, 0x57, 0x50, 0xd5, 0xef, 0x70, 0x6b, 0x4f, 0xc7, 0x45, + 0xdb, 0x74, 0x9e, 0x8d, 0x5e, 0x33, 0x83, 0xd8, 0x37, 0xdd, 0xc3, 0xac, + 0x3d, 0xbf, 0x92, 0xc5, 0x5b, 0xea, 0xbf, 0xd5, 0x62, 0xc0, 0xdc, 0xbc, + 0xbd, 0x2d, 0x22, 0x5a, 0xcf, 0xdd, 0x69, 0xff, 0x00, 0xd1, 0x8e, 0x5d, + 0xa5, 0x38, 0xb5, 0xb0, 0x00, 0xc6, 0xc4, 0x24, 0x4a, 0xd6, 0x8d, 0x18, + 0x04, 0x49, 0x88, 0x9e, 0x55, 0xd6, 0x61, 0xb0, 0xc1, 0x70, 0x32, 0xdd, + 0x3c, 0x95, 0xda, 0xf1, 0xfe, 0xf5, 0x62, 0xbc, 0x76, 0x8e, 0x75, 0x28, + 0x02, 0xa2, 0xe7, 0x7d, 0x92, 0xb9, 0x84, 0x96, 0x96, 0xda, 0xf7, 0x70, + 0x12, 0x4e, 0x5a, 0xff, 0x00, 0xff, 0xd1, 0xf3, 0x7a, 0x21, 0xaf, 0xde, + 0xef, 0xa2, 0x22, 0x55, 0xfc, 0x5a, 0xbd, 0x42, 0xfb, 0x08, 0xfa, 0x67, + 0x4f, 0x82, 0xcd, 0x6d, 0x85, 0xc0, 0x56, 0x3b, 0x90, 0xb7, 0xf0, 0x2a, + 0x0e, 0x63, 0x58, 0x3b, 0xf2, 0xa3, 0x9e, 0x8c, 0xb8, 0x86, 0xbe, 0x49, + 0xf1, 0x2c, 0x0c, 0x86, 0xb4, 0x4c, 0x69, 0xe4, 0xaf, 0x6e, 0xcc, 0x6b, + 0x7d, 0x46, 0xb3, 0x70, 0xec, 0x38, 0x51, 0x7d, 0x02, 0x8a, 0xc7, 0xa6, + 0xd9, 0x20, 0x68, 0x0f, 0x8f, 0x8a, 0xcf, 0xc9, 0xc2, 0xea, 0x59, 0x5b, + 0x48, 0xb0, 0x91, 0xae, 0xe6, 0xc9, 0x03, 0xc9, 0x30, 0x51, 0x66, 0xd4, + 0x0d, 0xad, 0xbd, 0x5f, 0x53, 0xcc, 0x6b, 0xb6, 0x90, 0x5a, 0x3b, 0x83, + 0x0b, 0x43, 0x17, 0x31, 0xd6, 0xc3, 0x6e, 0x12, 0x3b, 0x79, 0xac, 0xc1, + 0x89, 0x47, 0xd9, 0xe8, 0x63, 0x98, 0x45, 0xed, 0x6c, 0x5a, 0xf1, 0xa0, + 0x27, 0xc5, 0x5b, 0xc3, 0x6f, 0xa6, 0xe0, 0x1c, 0x7d, 0xb3, 0xa2, 0x69, + 0x34, 0x7b, 0xae, 0x1a, 0x8d, 0x45, 0x17, 0x9d, 0xeb, 0xfd, 0x21, 0xd8, + 0xb9, 0xae, 0xb5, 0x80, 0xbb, 0x1e, 0xd2, 0x5c, 0xd7, 0x78, 0x13, 0xf9, + 0xae, 0x4b, 0xea, 0xc7, 0x4a, 0x39, 0xbd, 0x55, 0xb3, 0xed, 0x66, 0x38, + 0xf5, 0x09, 0x22, 0x41, 0x23, 0xe8, 0x37, 0xfb, 0x4b, 0xa1, 0xeb, 0xd6, + 0xfe, 0x88, 0x31, 0xbf, 0x41, 0xc0, 0xee, 0xd2, 0x74, 0x02, 0x78, 0x53, + 0xfa, 0x97, 0x43, 0x19, 0x85, 0x65, 0xff, 0x00, 0x9d, 0x71, 0x33, 0xe4, + 0x1a, 0x7d, 0x8d, 0x53, 0x42, 0x56, 0x35, 0x6b, 0xe5, 0x80, 0x06, 0xc7, + 0x57, 0xa7, 0xc4, 0xa9, 0xdb, 0xb6, 0x81, 0x1f, 0xeb, 0xd9, 0x69, 0x56, + 0xc2, 0xd0, 0x00, 0xe5, 0x55, 0xc0, 0x12, 0xc2, 0xd7, 0x4e, 0xa2, 0x5a, + 0x7c, 0x0a, 0xd0, 0x63, 0x9a, 0xd1, 0xaf, 0xd2, 0xe2, 0x3c, 0x12, 0x62, + 0x66, 0xc6, 0x42, 0x23, 0x5a, 0x49, 0x8f, 0x10, 0xa2, 0xd2, 0x3e, 0x28, + 0x9d, 0xc4, 0x88, 0x09, 0x29, 0x16, 0xc3, 0x3c, 0x24, 0x8d, 0xe6, 0x92, + 0x72, 0x1f, 0xff, 0xd2, 0xf3, 0xbb, 0xb0, 0xfe, 0xcb, 0x99, 0xe9, 0xce, + 0xf6, 0x88, 0x2d, 0x77, 0x91, 0x5b, 0x3d, 0x3d, 0xd0, 0xe6, 0x90, 0xa9, + 0x65, 0x57, 0x38, 0x95, 0xdd, 0xcb, 0x9a, 0x7d, 0xce, 0xf2, 0x3f, 0x44, + 0x23, 0x60, 0x58, 0x76, 0xe9, 0xca, 0x8c, 0xea, 0x1b, 0x31, 0x02, 0x32, + 0x23, 0xea, 0xee, 0xb1, 0xcd, 0xb0, 0xc7, 0x87, 0x74, 0x7a, 0xeb, 0x70, + 0x1a, 0x71, 0xe1, 0xfe, 0xe4, 0x1c, 0x1d, 0xae, 0xe5, 0x69, 0xd8, 0xfa, + 0x99, 0x50, 0x0d, 0x1a, 0xf7, 0x2a, 0x3a, 0x0c, 0xf4, 0x1a, 0x8e, 0xc7, + 0x27, 0x5d, 0xbf, 0x18, 0x41, 0xdc, 0xc2, 0xf0, 0x7f, 0x74, 0xf6, 0x3a, + 0x22, 0x66, 0xdb, 0x68, 0xc6, 0x80, 0x48, 0x6b, 0x88, 0x06, 0x39, 0x0d, + 0xee, 0xaa, 0x1f, 0xb3, 0xd5, 0x1b, 0x83, 0xd8, 0x3b, 0x38, 0x8f, 0x69, + 0xfe, 0xdf, 0xd1, 0x4d, 0x29, 0xa1, 0x4c, 0x7a, 0xf4, 0xbf, 0xa7, 0x92, + 0xcf, 0xa5, 0x20, 0x08, 0xf3, 0xf6, 0xff, 0x00, 0x15, 0xbb, 0xd1, 0x31, + 0xd9, 0x5e, 0x3d, 0x75, 0x56, 0x36, 0x88, 0x00, 0x81, 0xe0, 0x16, 0x5e, + 0x55, 0x74, 0x3f, 0x00, 0x9d, 0xe0, 0xcc, 0x69, 0xe7, 0x3a, 0x2d, 0xbe, + 0x90, 0x00, 0xa9, 0xae, 0xef, 0x1f, 0x95, 0x4b, 0x0d, 0x9a, 0xdc, 0xc7, + 0x45, 0xfe, 0xb1, 0x7d, 0x60, 0xa7, 0xa1, 0xe0, 0x1f, 0x4e, 0x1d, 0x99, + 0x69, 0x02, 0x9a, 0xcf, 0x1f, 0xca, 0x7b, 0xbf, 0x90, 0xc5, 0xc2, 0xb3, + 0xeb, 0x57, 0xd6, 0x03, 0x6b, 0xae, 0x39, 0xb6, 0x82, 0xe3, 0x31, 0xa1, + 0x68, 0xf2, 0x6b, 0x5c, 0x12, 0xfa, 0xe1, 0x91, 0x66, 0x47, 0x5d, 0xb8, + 0x3b, 0x4f, 0x44, 0x36, 0xb6, 0x8f, 0x28, 0xdd, 0xff, 0x00, 0x7e, 0x46, + 0xab, 0x12, 0x2b, 0x65, 0x55, 0x32, 0xa7, 0x62, 0xb6, 0xbd, 0xf7, 0x64, + 0x10, 0xdb, 0x03, 0x9f, 0x1b, 0x9e, 0xc7, 0xd9, 0xb8, 0x3b, 0x1f, 0x67, + 0xf3, 0x6c, 0x52, 0x80, 0xd7, 0x7d, 0x0f, 0xea, 0x7f, 0x5d, 0x1d, 0x67, + 0xa6, 0x0b, 0x1e, 0x47, 0xda, 0x69, 0x3b, 0x2e, 0x03, 0xc7, 0xf3, 0x5f, + 0x1f, 0xf0, 0x8b, 0xa1, 0x02, 0x46, 0xba, 0x79, 0xaf, 0x32, 0xff, 0x00, + 0x16, 0xad, 0xca, 0x1d, 0x57, 0x2a, 0xdc, 0x79, 0x18, 0x41, 0xb0, 0xf6, + 0x9e, 0xe4, 0x9f, 0xd0, 0x8f, 0xeb, 0x31, 0xab, 0xd2, 0x83, 0xa4, 0xcb, + 0x8c, 0xb8, 0xa0, 0x42, 0x12, 0x7b, 0x67, 0x9f, 0x2f, 0xf5, 0x09, 0x26, + 0x96, 0xc4, 0xce, 0xa9, 0x20, 0xa7, 0xff, 0xd3, 0xf3, 0x2f, 0xb4, 0x5d, + 0xe9, 0x0a, 0xb7, 0x9f, 0x4c, 0x19, 0xdb, 0x3a, 0x2d, 0x5e, 0x94, 0xfd, + 0xc4, 0xb7, 0xc5, 0x62, 0xf9, 0x2b, 0xfd, 0x2e, 0xe3, 0x5d, 0xe0, 0x7c, + 0x13, 0x48, 0xd1, 0x92, 0x12, 0xa9, 0x0b, 0x7a, 0xbc, 0x2d, 0xc2, 0x7f, + 0x92, 0x60, 0xab, 0x4e, 0x79, 0x2e, 0x00, 0xf0, 0xaa, 0xe1, 0xda, 0x3d, + 0x43, 0xfc, 0xad, 0x55, 0xbb, 0x80, 0x79, 0x81, 0xa0, 0xe6, 0x54, 0x32, + 0x6d, 0x02, 0xbe, 0xf3, 0x61, 0x81, 0xa8, 0x44, 0x14, 0x03, 0x59, 0x0e, + 0x1c, 0xf6, 0x1f, 0xdc, 0xb2, 0xec, 0xa3, 0x23, 0x77, 0xe8, 0x6e, 0x70, + 0xf2, 0x25, 0x1f, 0x1f, 0x17, 0xa9, 0x6d, 0x71, 0x36, 0x97, 0x47, 0x00, + 0xa4, 0x02, 0xe0, 0x2c, 0x7c, 0xc1, 0xab, 0xd5, 0x31, 0x85, 0x35, 0xd4, + 0xe6, 0x13, 0x02, 0xd6, 0x4b, 0x67, 0x48, 0x2b, 0xa9, 0xe9, 0x2e, 0x02, + 0xb6, 0x4f, 0x82, 0xe5, 0x7a, 0x95, 0x19, 0xc6, 0x87, 0x3d, 0xfb, 0xa2, + 0xb8, 0x79, 0x1e, 0x4d, 0x3b, 0x96, 0xcf, 0x4f, 0xbd, 0xcd, 0xa2, 0xa2, + 0x1f, 0xa0, 0x82, 0xd3, 0xfc, 0x97, 0x05, 0x24, 0x36, 0x6b, 0xf3, 0x31, + 0xa2, 0x35, 0x79, 0xef, 0xad, 0xf8, 0xae, 0xaf, 0xaf, 0xd8, 0xf2, 0xd8, + 0x6d, 0xed, 0x6b, 0xda, 0x7b, 0x18, 0x1b, 0x5d, 0xff, 0x00, 0x52, 0xb1, + 0x6d, 0xf0, 0x81, 0x31, 0xca, 0xf4, 0x6e, 0xb1, 0x80, 0xce, 0xb1, 0x84, + 0xc0, 0x21, 0xb7, 0xd6, 0x77, 0x31, 0xd1, 0x27, 0xc1, 0xcd, 0xfe, 0xd2, + 0xe3, 0xec, 0xe8, 0x1d, 0x45, 0x96, 0xb0, 0x9a, 0xb7, 0x87, 0x3f, 0x68, + 0x2d, 0xf7, 0x01, 0x1f, 0xbe, 0xd1, 0xf4, 0x7f, 0xb4, 0xa4, 0x0d, 0x77, + 0xbb, 0xfa, 0x8f, 0x80, 0x3a, 0x7f, 0x43, 0xaa, 0xe2, 0xdf, 0xd2, 0x65, + 0x7e, 0x95, 0xe4, 0x0f, 0x1f, 0xa1, 0xfe, 0x6b, 0x16, 0x9f, 0x52, 0xfa, + 0xc1, 0xd3, 0xba, 0x6d, 0x26, 0xdc, 0xac, 0x86, 0xd4, 0xd9, 0x0d, 0x31, + 0x2e, 0x74, 0x9e, 0xdb, 0x59, 0x2e, 0x55, 0xe8, 0xc9, 0xb2, 0x96, 0xd5, + 0x4b, 0x9f, 0xb8, 0x6d, 0xda, 0x1c, 0x04, 0x09, 0x03, 0xfe, 0x8a, 0xc6, + 0xfa, 0xd3, 0xf5, 0x6a, 0xbe, 0xbb, 0x5b, 0x2e, 0xc6, 0xb5, 0x94, 0xe6, + 0xd5, 0x20, 0x97, 0x7d, 0x1b, 0x1b, 0xf9, 0xad, 0x7c, 0x7d, 0x17, 0xb7, + 0xf3, 0x1e, 0x92, 0x1b, 0x7f, 0xf8, 0xe0, 0x7d, 0x59, 0xdd, 0xfd, 0x32, + 0xd8, 0x8f, 0xa5, 0xe8, 0x3a, 0x12, 0x5c, 0x3f, 0xfc, 0xc4, 0xfa, 0xc3, + 0xb3, 0x77, 0xa7, 0x56, 0xed, 0xdb, 0x76, 0x7a, 0x8d, 0xdd, 0x1f, 0xbf, + 0xfd, 0x44, 0x92, 0x56, 0x8f, 0xff, 0xd4, 0xf2, 0xe8, 0x86, 0x17, 0x1e, + 0xfa, 0x04, 0x56, 0x4b, 0x43, 0x6c, 0x6f, 0x2d, 0xe5, 0x46, 0x01, 0x64, + 0x2b, 0x14, 0x32, 0x5b, 0xb4, 0xa0, 0x52, 0x1d, 0xde, 0x9b, 0x94, 0xdb, + 0xab, 0x6b, 0x81, 0xf7, 0x05, 0xb0, 0xd7, 0x07, 0xb2, 0x27, 0x55, 0xc6, + 0x57, 0x65, 0xd8, 0x76, 0x6e, 0x64, 0xed, 0xee, 0x16, 0xce, 0x27, 0x57, + 0x63, 0xda, 0x0c, 0xc2, 0x8e, 0x51, 0x67, 0x84, 0xfa, 0x1d, 0xdd, 0x62, + 0xc7, 0x07, 0xe9, 0xf7, 0xa3, 0xd6, 0x6c, 0x02, 0x41, 0x55, 0x31, 0xf3, + 0x2b, 0xb3, 0xba, 0x2b, 0x2e, 0x68, 0x24, 0x1d, 0x47, 0x64, 0xca, 0xa6, + 0x50, 0x41, 0x65, 0x90, 0x6c, 0xb1, 0xa5, 0xae, 0x33, 0x23, 0x51, 0xe4, + 0xab, 0x7d, 0x5d, 0xcb, 0xb6, 0xcc, 0x37, 0xd0, 0x40, 0x73, 0x71, 0xde, + 0x58, 0x09, 0xe7, 0x6f, 0x2c, 0x44, 0xc9, 0xc9, 0xae, 0xba, 0x9d, 0x63, + 0x88, 0x01, 0xa0, 0x95, 0x9d, 0xf5, 0x3f, 0x2a, 0xe6, 0x67, 0xdb, 0x50, + 0x83, 0x55, 0xad, 0x36, 0x3e, 0x78, 0x10, 0x74, 0x77, 0xfd, 0x2d, 0xaa, + 0x4c, 0x7d, 0x58, 0x73, 0x91, 0xa0, 0x0f, 0x51, 0x45, 0xb7, 0x33, 0xdd, + 0x58, 0x69, 0x1d, 0xd8, 0x0c, 0x9f, 0x96, 0x88, 0x19, 0x99, 0x19, 0xac, + 0xcf, 0xa3, 0xd2, 0xad, 0xb5, 0xdb, 0x76, 0x8f, 0xad, 0xc4, 0xea, 0xcf, + 0xdf, 0x7e, 0xdf, 0xdd, 0xfc, 0xd5, 0xa3, 0x5e, 0x43, 0x2b, 0x6b, 0xb2, + 0xad, 0x3b, 0x6a, 0xa4, 0x13, 0xa7, 0x04, 0xac, 0x7a, 0x6f, 0xb3, 0x23, + 0x26, 0xcc, 0xfb, 0xb4, 0x75, 0x8e, 0x01, 0x83, 0xf7, 0x58, 0x3e, 0x8b, + 0x53, 0xa7, 0x2a, 0x1a, 0x31, 0x42, 0x36, 0x5d, 0x4c, 0x9a, 0xf2, 0xdc, + 0xc6, 0xfe, 0x98, 0xb4, 0x34, 0xcb, 0x48, 0x0a, 0x8f, 0xdb, 0xb2, 0xeb, + 0x76, 0xd6, 0x07, 0x5c, 0x59, 0xc9, 0x64, 0x8f, 0x93, 0xa7, 0x73, 0x16, + 0x83, 0xaf, 0x0e, 0xa4, 0x33, 0xef, 0x50, 0xc5, 0x0c, 0xda, 0x59, 0x10, + 0x06, 0x8a, 0x2e, 0x29, 0x0e, 0xac, 0xc2, 0x31, 0x3d, 0x36, 0x69, 0x7e, + 0xd6, 0xcc, 0xf5, 0x3d, 0x6f, 0xb3, 0xeb, 0x1b, 0x76, 0xef, 0x3b, 0xa3, + 0xfa, 0xc9, 0x2b, 0x5f, 0x66, 0x6f, 0xa9, 0x1e, 0x73, 0xf2, 0x49, 0x2e, + 0x39, 0xf7, 0x4f, 0xb7, 0x8d, 0xff, 0xd5, 0xf3, 0x26, 0xfe, 0x0a, 0xc5, + 0x1b, 0xa7, 0xcb, 0xb2, 0xcf, 0x49, 0x03, 0xb2, 0x46, 0xee, 0xd9, 0xd9, + 0xb3, 0xf4, 0x9f, 0x25, 0x4a, 0xdf, 0x4b, 0x77, 0xe8, 0x27, 0xd4, 0xef, + 0x1c, 0x2a, 0x29, 0x26, 0xc5, 0x7c, 0x9d, 0x6c, 0x7f, 0xb7, 0x6e, 0x1b, + 0x26, 0x7f, 0x05, 0xa3, 0xfe, 0x53, 0x8d, 0x62, 0x57, 0x30, 0x92, 0x12, + 0xfa, 0x2f, 0x86, 0xdf, 0xa4, 0xec, 0x67, 0xfe, 0xd0, 0xf4, 0xff, 0x00, + 0x4d, 0xfc, 0xdf, 0x78, 0xe1, 0x68, 0x7d, 0x54, 0x99, 0xbf, 0x6f, 0xf3, + 0xbe, 0xdf, 0x8e, 0xdd, 0x7f, 0xef, 0xeb, 0x97, 0x49, 0x3e, 0x3b, 0x7f, + 0x06, 0x2c, 0x9f, 0x37, 0x5f, 0xf0, 0x9f, 0x4c, 0xeb, 0x7b, 0xbf, 0x67, + 0x55, 0xe8, 0xff, 0x00, 0x31, 0xbc, 0x7a, 0x9e, 0x31, 0xdb, 0xfe, 0x92, + 0xae, 0x37, 0x7a, 0x4d, 0xdb, 0xe2, 0x17, 0x9d, 0xa4, 0xa3, 0xc9, 0xba, + 0xfc, 0x7b, 0x7d, 0x5f, 0x52, 0xa7, 0x7e, 0xd1, 0x28, 0xf8, 0xf3, 0xb0, + 0xc7, 0x32, 0xbc, 0x99, 0x24, 0xc5, 0xe3, 0xab, 0xeb, 0x1f, 0xa4, 0xf5, + 0xfc, 0xe1, 0x25, 0xe4, 0xe9, 0x24, 0x97, 0xff, 0xd9, 0xff, 0xed, 0x2e, + 0x1c, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x20, 0x33, + 0x2e, 0x30, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x2b, 0x1c, 0x02, 0x00, 0x00, 0x02, 0x00, 0x02, 0x1c, 0x02, + 0x78, 0x00, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x38, + 0x42, 0x49, 0x4d, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xfb, + 0x09, 0xa6, 0xbd, 0x07, 0x4c, 0x2a, 0x36, 0x9d, 0x8f, 0xe2, 0xcc, 0x57, + 0xa9, 0xac, 0x85, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xea, 0x00, 0x00, 0x00, + 0x00, 0x1d, 0xb0, 0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20, 0x65, + 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x55, 0x54, 0x46, + 0x2d, 0x38, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, + 0x59, 0x50, 0x45, 0x20, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, + 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x41, 0x70, 0x70, + 0x6c, 0x65, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x72, 0x2f, + 0x2f, 0x44, 0x54, 0x44, 0x20, 0x50, 0x4c, 0x49, 0x53, 0x54, 0x20, 0x31, + 0x2e, 0x30, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, + 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x54, 0x44, 0x73, 0x2f, 0x50, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x2d, + 0x31, 0x2e, 0x30, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0x0a, 0x3c, 0x70, + 0x6c, 0x69, 0x73, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, + 0x50, 0x4d, 0x48, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74, 0x61, 0x6c, + 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, + 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, + 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, + 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, + 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, + 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, + 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, + 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x48, 0x6f, 0x72, 0x69, 0x7a, + 0x6f, 0x6e, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, + 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, + 0x3e, 0x37, 0x32, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, + 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, + 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, + 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, + 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, + 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, + 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, + 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, + 0x50, 0x4d, 0x4f, 0x72, 0x69, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, + 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, + 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, + 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, + 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, + 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x4f, 0x72, 0x69, 0x65, 0x6e, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, + 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, + 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, + 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, + 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, + 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, + 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, + 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, + 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x2e, 0x50, 0x4d, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, + 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, + 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, + 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, + 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, + 0x50, 0x4d, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, + 0x6c, 0x3e, 0x31, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, + 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, + 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, + 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, + 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, + 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, + 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, + 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, + 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, + 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, + 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, + 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, + 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, + 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, + 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, + 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x32, 0x3c, + 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, + 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, + 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, + 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, + 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, + 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, + 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, + 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, + 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, + 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, + 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, + 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, + 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, + 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, + 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, + 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, + 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, + 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, 0x65, + 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, + 0x3e, 0x31, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, + 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, + 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, + 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, + 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, + 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, + 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, + 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, + 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x73, 0x75, 0x62, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x61, + 0x70, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, + 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, + 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, + 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, + 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, + 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, + 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, + 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, + 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, + 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, + 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, 0x3c, + 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x33, 0x34, 0x3c, 0x2f, + 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x37, 0x36, 0x3c, 0x2f, 0x72, + 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, + 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, + 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, + 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, + 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, + 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, + 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, + 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, 0x63, + 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, + 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, + 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, + 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, + 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, + 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, + 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, + 0x3e, 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, + 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, + 0x37, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x39, + 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, + 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, + 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, + 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, + 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, + 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, + 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, + 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, + 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x50, + 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, + 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, + 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, + 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, + 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x50, 0x61, + 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x3e, 0x6e, 0x61, 0x2d, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x72, + 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, + 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, + 0x30, 0x33, 0x2d, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x54, 0x31, 0x37, 0x3a, + 0x34, 0x39, 0x3a, 0x33, 0x36, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, + 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, + 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, + 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, + 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, + 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, + 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, + 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, + 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, + 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, + 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, + 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, + 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, + 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, + 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, + 0x30, 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, + 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x33, + 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x37, 0x36, + 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, + 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, + 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, + 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, + 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, + 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, + 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, + 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, + 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, + 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, + 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, + 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, + 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, + 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, + 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, + 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, + 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, + 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, + 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, 0x38, + 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x37, 0x34, 0x3c, + 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x39, 0x34, 0x3c, 0x2f, + 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, + 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, + 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, + 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, + 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, + 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, + 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, + 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, + 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, + 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, + 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x70, 0x64, 0x2e, 0x50, 0x4d, + 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, + 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, + 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, + 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, + 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, + 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, + 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x70, 0x64, + 0x2e, 0x50, 0x4d, 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x55, 0x53, 0x20, 0x4c, + 0x65, 0x74, 0x74, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, + 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, + 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, + 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, + 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x30, 0x37, 0x2d, 0x30, + 0x31, 0x54, 0x31, 0x37, 0x3a, 0x34, 0x39, 0x3a, 0x33, 0x36, 0x5a, 0x3c, + 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, + 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, + 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, + 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x74, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x30, 0x30, 0x2e, 0x32, 0x30, 0x3c, 0x2f, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, + 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x74, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x63, + 0x6b, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x66, + 0x61, 0x6c, 0x73, 0x65, 0x2f, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, + 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, + 0x2e, 0x74, 0x79, 0x70, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, + 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, + 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x54, + 0x69, 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, + 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, + 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x30, 0x30, 0x2e, 0x32, 0x30, + 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x3c, + 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x74, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4c, 0x6f, + 0x63, 0x6b, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x66, + 0x61, 0x6c, 0x73, 0x65, 0x2f, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, + 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, + 0x74, 0x79, 0x70, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, + 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, + 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x54, 0x69, + 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x3e, 0x0a, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x3c, 0x2f, + 0x70, 0x6c, 0x69, 0x73, 0x74, 0x3e, 0x0a, 0x38, 0x42, 0x49, 0x4d, 0x03, + 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x02, 0xde, 0x02, 0x40, 0xff, + 0xee, 0xff, 0xee, 0x03, 0x06, 0x02, 0x52, 0x03, 0x67, 0x05, 0x28, 0x03, + 0xfc, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x02, 0xd8, 0x02, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x01, 0x7f, + 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x08, 0x00, 0x19, 0x01, 0x90, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x03, + 0xed, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x38, + 0x42, 0x49, 0x4d, 0x04, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, + 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1e, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x19, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x38, 0x42, 0x49, + 0x4d, 0x03, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x38, 0x42, 0x49, + 0x4d, 0x27, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x03, + 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x2f, 0x66, 0x66, 0x00, + 0x01, 0x00, 0x6c, 0x66, 0x66, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x2f, 0x66, 0x66, 0x00, 0x01, 0x00, 0xa1, 0x99, 0x9a, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x35, 0x00, 0x00, 0x00, 0x01, 0x00, 0x2d, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x03, + 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x38, + 0x42, 0x49, 0x4d, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, + 0x1a, 0x00, 0x00, 0x00, 0x00, 0x03, 0x45, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, + 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x00, 0x44, 0x00, 0x53, 0x00, + 0x43, 0x00, 0x30, 0x00, 0x32, 0x00, 0x33, 0x00, 0x32, 0x00, 0x35, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, + 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x6e, 0x75, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x4f, 0x62, 0x6a, 0x63, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x63, + 0x74, 0x31, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x54, 0x6f, + 0x70, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x4c, 0x65, 0x66, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x74, 0x6f, 0x6d, 0x6c, 0x6f, + 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x52, 0x67, + 0x68, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, + 0x00, 0x06, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x73, 0x56, 0x6c, 0x4c, 0x73, + 0x00, 0x00, 0x00, 0x01, 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x00, + 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x73, 0x6c, 0x69, 0x63, 0x65, + 0x49, 0x44, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x6c, 0x6f, 0x6e, + 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, + 0x67, 0x69, 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x45, + 0x53, 0x6c, 0x69, 0x63, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x00, + 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x6f, 0x47, 0x65, 0x6e, 0x65, 0x72, + 0x61, 0x74, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00, 0x54, 0x79, 0x70, 0x65, + 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0a, 0x45, 0x53, 0x6c, 0x69, + 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x49, 0x6d, + 0x67, 0x20, 0x00, 0x00, 0x00, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, + 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x52, 0x63, 0x74, 0x31, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x54, 0x6f, 0x70, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x65, 0x66, 0x74, 0x6c, 0x6f, + 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x74, + 0x6f, 0x6d, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, + 0x00, 0x00, 0x52, 0x67, 0x68, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, + 0x00, 0x64, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, 0x6c, 0x54, 0x45, 0x58, + 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, + 0x75, 0x6c, 0x6c, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x73, 0x67, 0x65, 0x54, 0x45, 0x58, + 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x61, + 0x6c, 0x74, 0x54, 0x61, 0x67, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x63, 0x65, 0x6c, 0x6c, 0x54, + 0x65, 0x78, 0x74, 0x49, 0x73, 0x48, 0x54, 0x4d, 0x4c, 0x62, 0x6f, 0x6f, + 0x6c, 0x01, 0x00, 0x00, 0x00, 0x08, 0x63, 0x65, 0x6c, 0x6c, 0x54, 0x65, + 0x78, 0x74, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x09, 0x68, 0x6f, 0x72, 0x7a, 0x41, 0x6c, 0x69, 0x67, + 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0f, 0x45, 0x53, 0x6c, + 0x69, 0x63, 0x65, 0x48, 0x6f, 0x72, 0x7a, 0x41, 0x6c, 0x69, 0x67, 0x6e, + 0x00, 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, + 0x00, 0x00, 0x09, 0x76, 0x65, 0x72, 0x74, 0x41, 0x6c, 0x69, 0x67, 0x6e, + 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0f, 0x45, 0x53, 0x6c, 0x69, + 0x63, 0x65, 0x56, 0x65, 0x72, 0x74, 0x41, 0x6c, 0x69, 0x67, 0x6e, 0x00, + 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, + 0x00, 0x0b, 0x62, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x79, 0x70, + 0x65, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x11, 0x45, 0x53, 0x6c, + 0x69, 0x63, 0x65, 0x42, 0x47, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x79, + 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x6f, 0x6e, 0x65, 0x00, 0x00, + 0x00, 0x09, 0x74, 0x6f, 0x70, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, + 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x6c, + 0x65, 0x66, 0x74, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, + 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x62, 0x6f, 0x74, + 0x74, 0x6f, 0x6d, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, + 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x72, 0x69, 0x67, + 0x68, 0x74, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, 0x67, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x11, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, + 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x38, + 0x42, 0x49, 0x4d, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x09, 0xf9, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, 0x00, + 0x00, 0x01, 0x2c, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0x09, 0xdd, 0x00, + 0x18, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, + 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, + 0xed, 0x00, 0x0c, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x5f, 0x43, 0x4d, 0x00, + 0x02, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, 0x64, + 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0c, 0x08, + 0x08, 0x08, 0x09, 0x08, 0x0c, 0x09, 0x09, 0x0c, 0x11, 0x0b, 0x0a, 0x0b, + 0x11, 0x15, 0x0f, 0x0c, 0x0c, 0x0f, 0x15, 0x18, 0x13, 0x13, 0x15, 0x13, + 0x13, 0x18, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x01, 0x0d, 0x0b, 0x0b, 0x0d, 0x0e, 0x0d, 0x10, 0x0e, 0x0e, + 0x10, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, 0x14, + 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, 0x08, + 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, + 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x07, 0xff, 0xc4, 0x01, 0x3f, + 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, + 0x01, 0x04, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x07, 0x06, 0x08, 0x05, + 0x03, 0x0c, 0x33, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, 0x31, + 0x05, 0x41, 0x51, 0x61, 0x13, 0x22, 0x71, 0x81, 0x32, 0x06, 0x14, 0x91, + 0xa1, 0xb1, 0x42, 0x23, 0x24, 0x15, 0x52, 0xc1, 0x62, 0x33, 0x34, 0x72, + 0x82, 0xd1, 0x43, 0x07, 0x25, 0x92, 0x53, 0xf0, 0xe1, 0xf1, 0x63, 0x73, + 0x35, 0x16, 0xa2, 0xb2, 0x83, 0x26, 0x44, 0x93, 0x54, 0x64, 0x45, 0xc2, + 0xa3, 0x74, 0x36, 0x17, 0xd2, 0x55, 0xe2, 0x65, 0xf2, 0xb3, 0x84, 0xc3, + 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x27, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, + 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, + 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, + 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x11, 0x00, 0x02, + 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x06, + 0x05, 0x35, 0x01, 0x00, 0x02, 0x11, 0x03, 0x21, 0x31, 0x12, 0x04, 0x41, + 0x51, 0x61, 0x71, 0x22, 0x13, 0x05, 0x32, 0x81, 0x91, 0x14, 0xa1, 0xb1, + 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xf0, 0x33, 0x24, 0x62, 0xe1, 0x72, 0x82, + 0x92, 0x43, 0x53, 0x15, 0x63, 0x73, 0x34, 0xf1, 0x25, 0x06, 0x16, 0xa2, + 0xb2, 0x83, 0x07, 0x26, 0x35, 0xc2, 0xd2, 0x44, 0x93, 0x54, 0xa3, 0x17, + 0x64, 0x45, 0x55, 0x36, 0x74, 0x65, 0xe2, 0xf2, 0xb3, 0x84, 0xc3, 0xd3, + 0x75, 0xe3, 0xf3, 0x46, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, 0xe4, + 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, 0x96, + 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, + 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, + 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf2, 0xed, 0xb2, 0x8d, 0x4d, + 0x45, 0xcd, 0x2f, 0x3f, 0x44, 0x68, 0x93, 0xc3, 0x58, 0xc8, 0xf1, 0x1f, + 0x8a, 0x33, 0x86, 0xda, 0x58, 0xc1, 0xa0, 0x02, 0x4f, 0xc4, 0xa1, 0x69, + 0xa5, 0x9b, 0x5b, 0x4b, 0x84, 0x73, 0xdf, 0xc9, 0x15, 0xf8, 0xe3, 0xd1, + 0x0e, 0x07, 0x93, 0xf3, 0xd1, 0x0f, 0x1c, 0x17, 0xef, 0x2e, 0x3b, 0x5b, + 0xdc, 0xff, 0x00, 0xdf, 0x42, 0xbf, 0x8f, 0x8e, 0xdc, 0x82, 0xca, 0xd8, + 0x37, 0x11, 0xa9, 0x3d, 0x82, 0x69, 0x2b, 0xc4, 0x6d, 0xc9, 0x75, 0x25, + 0xbc, 0xf7, 0xec, 0xa1, 0xb5, 0x74, 0x19, 0x5d, 0x2e, 0x8a, 0x9a, 0x4b, + 0x89, 0x7d, 0xc4, 0x68, 0xc6, 0xf6, 0xfe, 0xb2, 0xa0, 0x30, 0x1d, 0x60, + 0x86, 0x88, 0x8d, 0x49, 0x3e, 0x01, 0x11, 0x20, 0xa3, 0x8c, 0xb9, 0xb1, + 0xaa, 0x62, 0xad, 0xbf, 0x18, 0x97, 0x43, 0x47, 0x1d, 0xd2, 0xaf, 0x04, + 0xd9, 0xb8, 0xc8, 0x0d, 0x68, 0xe4, 0xf7, 0x3e, 0x48, 0xf1, 0x05, 0xbc, + 0x25, 0xaa, 0x07, 0x71, 0xd9, 0x14, 0x78, 0xf6, 0x49, 0xb5, 0x90, 0xfd, + 0xa7, 0xc6, 0x14, 0xfd, 0x1b, 0x1c, 0xff, 0x00, 0x4d, 0x8d, 0x2e, 0x73, + 0x8c, 0x35, 0xa3, 0x52, 0x4f, 0x92, 0x48, 0xa6, 0x1a, 0x24, 0xb6, 0x2a, + 0xfa, 0xa5, 0x9e, 0x60, 0x64, 0x39, 0x94, 0x13, 0xcb, 0x27, 0x73, 0x80, + 0xf3, 0x0c, 0xf6, 0xff, 0x00, 0xd2, 0x5a, 0x78, 0xbf, 0x53, 0x71, 0xf6, + 0x01, 0x75, 0xb6, 0x97, 0x6a, 0x25, 0xa1, 0xad, 0x1f, 0xf4, 0xb7, 0x23, + 0x48, 0xb7, 0x94, 0x84, 0x97, 0x5b, 0xff, 0x00, 0x32, 0xa9, 0xdd, 0xfc, + 0xed, 0x9b, 0x7e, 0x0d, 0x9e, 0x52, 0x4a, 0x95, 0x61, 0xff, 0xd0, 0xf3, + 0x3b, 0xa7, 0x70, 0xee, 0x01, 0x8f, 0xb9, 0x59, 0xfa, 0x7e, 0xdf, 0xe4, + 0xc8, 0xf9, 0x2a, 0xc2, 0x5c, 0x63, 0xc3, 0x54, 0x67, 0x87, 0x6e, 0x10, + 0x35, 0x68, 0xd4, 0x79, 0x1e, 0x53, 0x4a, 0xe0, 0xdc, 0xe9, 0xb8, 0x1f, + 0x6a, 0xda, 0x6c, 0x25, 0x94, 0x37, 0xb0, 0xd0, 0xb8, 0xad, 0x67, 0xe4, + 0x55, 0x8a, 0x5b, 0x8b, 0x82, 0xc0, 0x6f, 0x76, 0x80, 0x34, 0x49, 0x05, + 0x2e, 0x9e, 0xc6, 0x1c, 0x66, 0x31, 0xba, 0x10, 0x23, 0xe0, 0xaf, 0xe1, + 0x61, 0x53, 0x43, 0x8d, 0x81, 0xb3, 0x67, 0xef, 0x9e, 0x49, 0x2a, 0x12, + 0x6c, 0xb6, 0x63, 0x1a, 0x0c, 0x31, 0xba, 0x55, 0xcd, 0xac, 0xfa, 0x8e, + 0xdf, 0x91, 0x6e, 0x91, 0xd9, 0xb3, 0xc9, 0x73, 0x90, 0x7a, 0xab, 0x6a, + 0xc2, 0xa4, 0x60, 0xe2, 0x8f, 0xd2, 0x38, 0x03, 0x7d, 0x9e, 0x0d, 0xff, + 0x00, 0xcc, 0xd6, 0xd3, 0x6b, 0x71, 0x67, 0xd2, 0x3e, 0x64, 0x72, 0xab, + 0xdb, 0x8d, 0x54, 0x39, 0xc5, 0x83, 0x6b, 0x3d, 0xee, 0x2e, 0xd4, 0x92, + 0x3c, 0x4a, 0x56, 0xba, 0xb4, 0x79, 0x5c, 0xf7, 0xb2, 0x96, 0x6c, 0x8d, + 0xaf, 0x80, 0x48, 0x3c, 0xf0, 0xb2, 0x1f, 0x63, 0x9c, 0xe9, 0x3f, 0x24, + 0x5c, 0xdb, 0xdd, 0x76, 0x43, 0xde, 0xfd, 0x5c, 0xe3, 0x24, 0xfc, 0x50, + 0x00, 0x93, 0x0a, 0x78, 0x8a, 0x0d, 0x49, 0xca, 0xcf, 0x93, 0x63, 0x1b, + 0x7d, 0xd7, 0x57, 0x50, 0xd5, 0xef, 0x70, 0x6b, 0x4f, 0xc7, 0x45, 0xdb, + 0x74, 0x9e, 0x8d, 0x5e, 0x33, 0x83, 0xd8, 0x37, 0xdd, 0xc3, 0xac, 0x3d, + 0xbf, 0x92, 0xc5, 0x5b, 0xea, 0xbf, 0xd5, 0x62, 0xc0, 0xdc, 0xbc, 0xbd, + 0x2d, 0x22, 0x5a, 0xcf, 0xdd, 0x69, 0xff, 0x00, 0xd1, 0x8e, 0x5d, 0xa5, + 0x38, 0xb5, 0xb0, 0x00, 0xc6, 0xc4, 0x24, 0x4a, 0xd6, 0x8d, 0x18, 0x04, + 0x49, 0x88, 0x9e, 0x55, 0xd6, 0x61, 0xb0, 0xc1, 0x70, 0x32, 0xdd, 0x3c, + 0x95, 0xda, 0xf1, 0xfe, 0xf5, 0x62, 0xbc, 0x76, 0x8e, 0x75, 0x28, 0x02, + 0xa2, 0xe7, 0x7d, 0x92, 0xb9, 0x84, 0x96, 0x96, 0xda, 0xf7, 0x70, 0x12, + 0x4e, 0x5a, 0xff, 0x00, 0xff, 0xd1, 0xf3, 0x7a, 0x21, 0xaf, 0xde, 0xef, + 0xa2, 0x22, 0x55, 0xfc, 0x5a, 0xbd, 0x42, 0xfb, 0x08, 0xfa, 0x67, 0x4f, + 0x82, 0xcd, 0x6d, 0x85, 0xc0, 0x56, 0x3b, 0x90, 0xb7, 0xf0, 0x2a, 0x0e, + 0x63, 0x58, 0x3b, 0xf2, 0xa3, 0x9e, 0x8c, 0xb8, 0x86, 0xbe, 0x49, 0xf1, + 0x2c, 0x0c, 0x86, 0xb4, 0x4c, 0x69, 0xe4, 0xaf, 0x6e, 0xcc, 0x6b, 0x7d, + 0x46, 0xb3, 0x70, 0xec, 0x38, 0x51, 0x7d, 0x02, 0x8a, 0xc7, 0xa6, 0xd9, + 0x20, 0x68, 0x0f, 0x8f, 0x8a, 0xcf, 0xc9, 0xc2, 0xea, 0x59, 0x5b, 0x48, + 0xb0, 0x91, 0xae, 0xe6, 0xc9, 0x03, 0xc9, 0x30, 0x51, 0x66, 0xd4, 0x0d, + 0xad, 0xbd, 0x5f, 0x53, 0xcc, 0x6b, 0xb6, 0x90, 0x5a, 0x3b, 0x83, 0x0b, + 0x43, 0x17, 0x31, 0xd6, 0xc3, 0x6e, 0x12, 0x3b, 0x79, 0xac, 0xc1, 0x89, + 0x47, 0xd9, 0xe8, 0x63, 0x98, 0x45, 0xed, 0x6c, 0x5a, 0xf1, 0xa0, 0x27, + 0xc5, 0x5b, 0xc3, 0x6f, 0xa6, 0xe0, 0x1c, 0x7d, 0xb3, 0xa2, 0x69, 0x34, + 0x7b, 0xae, 0x1a, 0x8d, 0x45, 0x17, 0x9d, 0xeb, 0xfd, 0x21, 0xd8, 0xb9, + 0xae, 0xb5, 0x80, 0xbb, 0x1e, 0xd2, 0x5c, 0xd7, 0x78, 0x13, 0xf9, 0xae, + 0x4b, 0xea, 0xc7, 0x4a, 0x39, 0xbd, 0x55, 0xb3, 0xed, 0x66, 0x38, 0xf5, + 0x09, 0x22, 0x41, 0x23, 0xe8, 0x37, 0xfb, 0x4b, 0xa1, 0xeb, 0xd6, 0xfe, + 0x88, 0x31, 0xbf, 0x41, 0xc0, 0xee, 0xd2, 0x74, 0x02, 0x78, 0x53, 0xfa, + 0x97, 0x43, 0x19, 0x85, 0x65, 0xff, 0x00, 0x9d, 0x71, 0x33, 0xe4, 0x1a, + 0x7d, 0x8d, 0x53, 0x42, 0x56, 0x35, 0x6b, 0xe5, 0x80, 0x06, 0xc7, 0x57, + 0xa7, 0xc4, 0xa9, 0xdb, 0xb6, 0x81, 0x1f, 0xeb, 0xd9, 0x69, 0x56, 0xc2, + 0xd0, 0x00, 0xe5, 0x55, 0xc0, 0x12, 0xc2, 0xd7, 0x4e, 0xa2, 0x5a, 0x7c, + 0x0a, 0xd0, 0x63, 0x9a, 0xd1, 0xaf, 0xd2, 0xe2, 0x3c, 0x12, 0x62, 0x66, + 0xc6, 0x42, 0x23, 0x5a, 0x49, 0x8f, 0x10, 0xa2, 0xd2, 0x3e, 0x28, 0x9d, + 0xc4, 0x88, 0x09, 0x29, 0x16, 0xc3, 0x3c, 0x24, 0x8d, 0xe6, 0x92, 0x72, + 0x1f, 0xff, 0xd2, 0xf3, 0xbb, 0xb0, 0xfe, 0xcb, 0x99, 0xe9, 0xce, 0xf6, + 0x88, 0x2d, 0x77, 0x91, 0x5b, 0x3d, 0x3d, 0xd0, 0xe6, 0x90, 0xa9, 0x65, + 0x57, 0x38, 0x95, 0xdd, 0xcb, 0x9a, 0x7d, 0xce, 0xf2, 0x3f, 0x44, 0x23, + 0x60, 0x58, 0x76, 0xe9, 0xca, 0x8c, 0xea, 0x1b, 0x31, 0x02, 0x32, 0x23, + 0xea, 0xee, 0xb1, 0xcd, 0xb0, 0xc7, 0x87, 0x74, 0x7a, 0xeb, 0x70, 0x1a, + 0x71, 0xe1, 0xfe, 0xe4, 0x1c, 0x1d, 0xae, 0xe5, 0x69, 0xd8, 0xfa, 0x99, + 0x50, 0x0d, 0x1a, 0xf7, 0x2a, 0x3a, 0x0c, 0xf4, 0x1a, 0x8e, 0xc7, 0x27, + 0x5d, 0xbf, 0x18, 0x41, 0xdc, 0xc2, 0xf0, 0x7f, 0x74, 0xf6, 0x3a, 0x22, + 0x66, 0xdb, 0x68, 0xc6, 0x80, 0x48, 0x6b, 0x88, 0x06, 0x39, 0x0d, 0xee, + 0xaa, 0x1f, 0xb3, 0xd5, 0x1b, 0x83, 0xd8, 0x3b, 0x38, 0x8f, 0x69, 0xfe, + 0xdf, 0xd1, 0x4d, 0x29, 0xa1, 0x4c, 0x7a, 0xf4, 0xbf, 0xa7, 0x92, 0xcf, + 0xa5, 0x20, 0x08, 0xf3, 0xf6, 0xff, 0x00, 0x15, 0xbb, 0xd1, 0x31, 0xd9, + 0x5e, 0x3d, 0x75, 0x56, 0x36, 0x88, 0x00, 0x81, 0xe0, 0x16, 0x5e, 0x55, + 0x74, 0x3f, 0x00, 0x9d, 0xe0, 0xcc, 0x69, 0xe7, 0x3a, 0x2d, 0xbe, 0x90, + 0x00, 0xa9, 0xae, 0xef, 0x1f, 0x95, 0x4b, 0x0d, 0x9a, 0xdc, 0xc7, 0x45, + 0xfe, 0xb1, 0x7d, 0x60, 0xa7, 0xa1, 0xe0, 0x1f, 0x4e, 0x1d, 0x99, 0x69, + 0x02, 0x9a, 0xcf, 0x1f, 0xca, 0x7b, 0xbf, 0x90, 0xc5, 0xc2, 0xb3, 0xeb, + 0x57, 0xd6, 0x03, 0x6b, 0xae, 0x39, 0xb6, 0x82, 0xe3, 0x31, 0xa1, 0x68, + 0xf2, 0x6b, 0x5c, 0x12, 0xfa, 0xe1, 0x91, 0x66, 0x47, 0x5d, 0xb8, 0x3b, + 0x4f, 0x44, 0x36, 0xb6, 0x8f, 0x28, 0xdd, 0xff, 0x00, 0x7e, 0x46, 0xab, + 0x12, 0x2b, 0x65, 0x55, 0x32, 0xa7, 0x62, 0xb6, 0xbd, 0xf7, 0x64, 0x10, + 0xdb, 0x03, 0x9f, 0x1b, 0x9e, 0xc7, 0xd9, 0xb8, 0x3b, 0x1f, 0x67, 0xf3, + 0x6c, 0x52, 0x80, 0xd7, 0x7d, 0x0f, 0xea, 0x7f, 0x5d, 0x1d, 0x67, 0xa6, + 0x0b, 0x1e, 0x47, 0xda, 0x69, 0x3b, 0x2e, 0x03, 0xc7, 0xf3, 0x5f, 0x1f, + 0xf0, 0x8b, 0xa1, 0x02, 0x46, 0xba, 0x79, 0xaf, 0x32, 0xff, 0x00, 0x16, + 0xad, 0xca, 0x1d, 0x57, 0x2a, 0xdc, 0x79, 0x18, 0x41, 0xb0, 0xf6, 0x9e, + 0xe4, 0x9f, 0xd0, 0x8f, 0xeb, 0x31, 0xab, 0xd2, 0x83, 0xa4, 0xcb, 0x8c, + 0xb8, 0xa0, 0x42, 0x12, 0x7b, 0x67, 0x9f, 0x2f, 0xf5, 0x09, 0x26, 0x96, + 0xc4, 0xce, 0xa9, 0x20, 0xa7, 0xff, 0xd3, 0xf3, 0x2f, 0xb4, 0x5d, 0xe9, + 0x0a, 0xb7, 0x9f, 0x4c, 0x19, 0xdb, 0x3a, 0x2d, 0x5e, 0x94, 0xfd, 0xc4, + 0xb7, 0xc5, 0x62, 0xf9, 0x2b, 0xfd, 0x2e, 0xe3, 0x5d, 0xe0, 0x7c, 0x13, + 0x48, 0xd1, 0x92, 0x12, 0xa9, 0x0b, 0x7a, 0xbc, 0x2d, 0xc2, 0x7f, 0x92, + 0x60, 0xab, 0x4e, 0x79, 0x2e, 0x00, 0xf0, 0xaa, 0xe1, 0xda, 0x3d, 0x43, + 0xfc, 0xad, 0x55, 0xbb, 0x80, 0x79, 0x81, 0xa0, 0xe6, 0x54, 0x32, 0x6d, + 0x02, 0xbe, 0xf3, 0x61, 0x81, 0xa8, 0x44, 0x14, 0x03, 0x59, 0x0e, 0x1c, + 0xf6, 0x1f, 0xdc, 0xb2, 0xec, 0xa3, 0x23, 0x77, 0xe8, 0x6e, 0x70, 0xf2, + 0x25, 0x1f, 0x1f, 0x17, 0xa9, 0x6d, 0x71, 0x36, 0x97, 0x47, 0x00, 0xa4, + 0x02, 0xe0, 0x2c, 0x7c, 0xc1, 0xab, 0xd5, 0x31, 0x85, 0x35, 0xd4, 0xe6, + 0x13, 0x02, 0xd6, 0x4b, 0x67, 0x48, 0x2b, 0xa9, 0xe9, 0x2e, 0x02, 0xb6, + 0x4f, 0x82, 0xe5, 0x7a, 0x95, 0x19, 0xc6, 0x87, 0x3d, 0xfb, 0xa2, 0xb8, + 0x79, 0x1e, 0x4d, 0x3b, 0x96, 0xcf, 0x4f, 0xbd, 0xcd, 0xa2, 0xa2, 0x1f, + 0xa0, 0x82, 0xd3, 0xfc, 0x97, 0x05, 0x24, 0x36, 0x6b, 0xf3, 0x31, 0xa2, + 0x35, 0x79, 0xef, 0xad, 0xf8, 0xae, 0xaf, 0xaf, 0xd8, 0xf2, 0xd8, 0x6d, + 0xed, 0x6b, 0xda, 0x7b, 0x18, 0x1b, 0x5d, 0xff, 0x00, 0x52, 0xb1, 0x6d, + 0xf0, 0x81, 0x31, 0xca, 0xf4, 0x6e, 0xb1, 0x80, 0xce, 0xb1, 0x84, 0xc0, + 0x21, 0xb7, 0xd6, 0x77, 0x31, 0xd1, 0x27, 0xc1, 0xcd, 0xfe, 0xd2, 0xe3, + 0xec, 0xe8, 0x1d, 0x45, 0x96, 0xb0, 0x9a, 0xb7, 0x87, 0x3f, 0x68, 0x2d, + 0xf7, 0x01, 0x1f, 0xbe, 0xd1, 0xf4, 0x7f, 0xb4, 0xa4, 0x0d, 0x77, 0xbb, + 0xfa, 0x8f, 0x80, 0x3a, 0x7f, 0x43, 0xaa, 0xe2, 0xdf, 0xd2, 0x65, 0x7e, + 0x95, 0xe4, 0x0f, 0x1f, 0xa1, 0xfe, 0x6b, 0x16, 0x9f, 0x52, 0xfa, 0xc1, + 0xd3, 0xba, 0x6d, 0x26, 0xdc, 0xac, 0x86, 0xd4, 0xd9, 0x0d, 0x31, 0x2e, + 0x74, 0x9e, 0xdb, 0x59, 0x2e, 0x55, 0xe8, 0xc9, 0xb2, 0x96, 0xd5, 0x4b, + 0x9f, 0xb8, 0x6d, 0xda, 0x1c, 0x04, 0x09, 0x03, 0xfe, 0x8a, 0xc6, 0xfa, + 0xd3, 0xf5, 0x6a, 0xbe, 0xbb, 0x5b, 0x2e, 0xc6, 0xb5, 0x94, 0xe6, 0xd5, + 0x20, 0x97, 0x7d, 0x1b, 0x1b, 0xf9, 0xad, 0x7c, 0x7d, 0x17, 0xb7, 0xf3, + 0x1e, 0x92, 0x1b, 0x7f, 0xf8, 0xe0, 0x7d, 0x59, 0xdd, 0xfd, 0x32, 0xd8, + 0x8f, 0xa5, 0xe8, 0x3a, 0x12, 0x5c, 0x3f, 0xfc, 0xc4, 0xfa, 0xc3, 0xb3, + 0x77, 0xa7, 0x56, 0xed, 0xdb, 0x76, 0x7a, 0x8d, 0xdd, 0x1f, 0xbf, 0xfd, + 0x44, 0x92, 0x56, 0x8f, 0xff, 0xd4, 0xf2, 0xe8, 0x86, 0x17, 0x1e, 0xfa, + 0x04, 0x56, 0x4b, 0x43, 0x6c, 0x6f, 0x2d, 0xe5, 0x46, 0x01, 0x64, 0x2b, + 0x14, 0x32, 0x5b, 0xb4, 0xa0, 0x52, 0x1d, 0xde, 0x9b, 0x94, 0xdb, 0xab, + 0x6b, 0x81, 0xf7, 0x05, 0xb0, 0xd7, 0x07, 0xb2, 0x27, 0x55, 0xc6, 0x57, + 0x65, 0xd8, 0x76, 0x6e, 0x64, 0xed, 0xee, 0x16, 0xce, 0x27, 0x57, 0x63, + 0xda, 0x0c, 0xc2, 0x8e, 0x51, 0x67, 0x84, 0xfa, 0x1d, 0xdd, 0x62, 0xc7, + 0x07, 0xe9, 0xf7, 0xa3, 0xd6, 0x6c, 0x02, 0x41, 0x55, 0x31, 0xf3, 0x2b, + 0xb3, 0xba, 0x2b, 0x2e, 0x68, 0x24, 0x1d, 0x47, 0x64, 0xca, 0xa6, 0x50, + 0x41, 0x65, 0x90, 0x6c, 0xb1, 0xa5, 0xae, 0x33, 0x23, 0x51, 0xe4, 0xab, + 0x7d, 0x5d, 0xcb, 0xb6, 0xcc, 0x37, 0xd0, 0x40, 0x73, 0x71, 0xde, 0x58, + 0x09, 0xe7, 0x6f, 0x2c, 0x44, 0xc9, 0xc9, 0xae, 0xba, 0x9d, 0x63, 0x88, + 0x01, 0xa0, 0x95, 0x9d, 0xf5, 0x3f, 0x2a, 0xe6, 0x67, 0xdb, 0x50, 0x83, + 0x55, 0xad, 0x36, 0x3e, 0x78, 0x10, 0x74, 0x77, 0xfd, 0x2d, 0xaa, 0x4c, + 0x7d, 0x58, 0x73, 0x91, 0xa0, 0x0f, 0x51, 0x45, 0xb7, 0x33, 0xdd, 0x58, + 0x69, 0x1d, 0xd8, 0x0c, 0x9f, 0x96, 0x88, 0x19, 0x99, 0x19, 0xac, 0xcf, + 0xa3, 0xd2, 0xad, 0xb5, 0xdb, 0x76, 0x8f, 0xad, 0xc4, 0xea, 0xcf, 0xdf, + 0x7e, 0xdf, 0xdd, 0xfc, 0xd5, 0xa3, 0x5e, 0x43, 0x2b, 0x6b, 0xb2, 0xad, + 0x3b, 0x6a, 0xa4, 0x13, 0xa7, 0x04, 0xac, 0x7a, 0x6f, 0xb3, 0x23, 0x26, + 0xcc, 0xfb, 0xb4, 0x75, 0x8e, 0x01, 0x83, 0xf7, 0x58, 0x3e, 0x8b, 0x53, + 0xa7, 0x2a, 0x1a, 0x31, 0x42, 0x36, 0x5d, 0x4c, 0x9a, 0xf2, 0xdc, 0xc6, + 0xfe, 0x98, 0xb4, 0x34, 0xcb, 0x48, 0x0a, 0x8f, 0xdb, 0xb2, 0xeb, 0x76, + 0xd6, 0x07, 0x5c, 0x59, 0xc9, 0x64, 0x8f, 0x93, 0xa7, 0x73, 0x16, 0x83, + 0xaf, 0x0e, 0xa4, 0x33, 0xef, 0x50, 0xc5, 0x0c, 0xda, 0x59, 0x10, 0x06, + 0x8a, 0x2e, 0x29, 0x0e, 0xac, 0xc2, 0x31, 0x3d, 0x36, 0x69, 0x7e, 0xd6, + 0xcc, 0xf5, 0x3d, 0x6f, 0xb3, 0xeb, 0x1b, 0x76, 0xef, 0x3b, 0xa3, 0xfa, + 0xc9, 0x2b, 0x5f, 0x66, 0x6f, 0xa9, 0x1e, 0x73, 0xf2, 0x49, 0x2e, 0x39, + 0xf7, 0x4f, 0xb7, 0x8d, 0xff, 0xd5, 0xf3, 0x26, 0xfe, 0x0a, 0xc5, 0x1b, + 0xa7, 0xcb, 0xb2, 0xcf, 0x49, 0x03, 0xb2, 0x46, 0xee, 0xd9, 0xd9, 0xb3, + 0xf4, 0x9f, 0x25, 0x4a, 0xdf, 0x4b, 0x77, 0xe8, 0x27, 0xd4, 0xef, 0x1c, + 0x2a, 0x29, 0x26, 0xc5, 0x7c, 0x9d, 0x6c, 0x7f, 0xb7, 0x6e, 0x1b, 0x26, + 0x7f, 0x05, 0xa3, 0xfe, 0x53, 0x8d, 0x62, 0x57, 0x30, 0x92, 0x12, 0xfa, + 0x2f, 0x86, 0xdf, 0xa4, 0xec, 0x67, 0xfe, 0xd0, 0xf4, 0xff, 0x00, 0x4d, + 0xfc, 0xdf, 0x78, 0xe1, 0x68, 0x7d, 0x54, 0x99, 0xbf, 0x6f, 0xf3, 0xbe, + 0xdf, 0x8e, 0xdd, 0x7f, 0xef, 0xeb, 0x97, 0x49, 0x3e, 0x3b, 0x7f, 0x06, + 0x2c, 0x9f, 0x37, 0x5f, 0xf0, 0x9f, 0x4c, 0xeb, 0x7b, 0xbf, 0x67, 0x55, + 0xe8, 0xff, 0x00, 0x31, 0xbc, 0x7a, 0x9e, 0x31, 0xdb, 0xfe, 0x92, 0xae, + 0x37, 0x7a, 0x4d, 0xdb, 0xe2, 0x17, 0x9d, 0xa4, 0xa3, 0xc9, 0xba, 0xfc, + 0x7b, 0x7d, 0x5f, 0x52, 0xa7, 0x7e, 0xd1, 0x28, 0xf8, 0xf3, 0xb0, 0xc7, + 0x32, 0xbc, 0x99, 0x24, 0xc5, 0xe3, 0xab, 0xeb, 0x1f, 0xa4, 0xf5, 0xfc, + 0xe1, 0x25, 0xe4, 0xe9, 0x24, 0x97, 0xff, 0xd9, 0x00, 0x38, 0x42, 0x49, + 0x4d, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6f, + 0x00, 0x62, 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6f, + 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x70, + 0x00, 0x00, 0x00, 0x13, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x62, + 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x74, + 0x00, 0x6f, 0x00, 0x73, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x20, + 0x00, 0x37, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x38, + 0x42, 0x49, 0x4d, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0xff, 0xe1, 0x15, 0x67, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, + 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, + 0x2e, 0x30, 0x2f, 0x00, 0x3c, 0x3f, 0x78, 0x70, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x20, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x3d, 0x27, 0xef, 0xbb, 0xbf, + 0x27, 0x20, 0x69, 0x64, 0x3d, 0x27, 0x57, 0x35, 0x4d, 0x30, 0x4d, 0x70, + 0x43, 0x65, 0x68, 0x69, 0x48, 0x7a, 0x72, 0x65, 0x53, 0x7a, 0x4e, 0x54, + 0x63, 0x7a, 0x6b, 0x63, 0x39, 0x64, 0x27, 0x3f, 0x3e, 0x0a, 0x3c, 0x3f, + 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2d, 0x78, 0x61, 0x70, 0x2d, 0x66, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x73, 0x20, 0x65, 0x73, 0x63, 0x3d, 0x22, 0x43, + 0x52, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x6d, + 0x65, 0x74, 0x61, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x3d, + 0x27, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x3a, 0x6e, 0x73, 0x3a, 0x6d, 0x65, + 0x74, 0x61, 0x2f, 0x27, 0x20, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x74, 0x6b, + 0x3d, 0x27, 0x58, 0x4d, 0x50, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, + 0x74, 0x20, 0x32, 0x2e, 0x38, 0x2e, 0x32, 0x2d, 0x33, 0x33, 0x2c, 0x20, + 0x66, 0x72, 0x61, 0x6d, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x31, 0x2e, + 0x35, 0x27, 0x3e, 0x0a, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x52, 0x44, 0x46, + 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x72, 0x64, 0x66, 0x3d, 0x27, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, + 0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, + 0x32, 0x2f, 0x32, 0x32, 0x2d, 0x72, 0x64, 0x66, 0x2d, 0x73, 0x79, 0x6e, + 0x74, 0x61, 0x78, 0x2d, 0x6e, 0x73, 0x23, 0x27, 0x20, 0x78, 0x6d, 0x6c, + 0x6e, 0x73, 0x3a, 0x69, 0x58, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, + 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x69, 0x58, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, + 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, + 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, + 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, + 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, + 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, + 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x70, 0x64, 0x66, 0x3d, 0x27, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, + 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x64, 0x66, 0x2f, 0x31, + 0x2e, 0x33, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, + 0x20, 0x70, 0x64, 0x66, 0x3a, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, + 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, + 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, + 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, + 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, + 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, + 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, + 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, + 0x6f, 0x70, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, + 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x31, 0x2e, + 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, 0x20, + 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3a, 0x43, 0x61, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, + 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, + 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, + 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, + 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, + 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, + 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, + 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, + 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x61, + 0x70, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, + 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, + 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, + 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0x78, 0x61, 0x70, 0x3a, 0x44, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, + 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, + 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, + 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, + 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, + 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, + 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, + 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, + 0x3a, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, + 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, + 0x6d, 0x6d, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x78, 0x61, 0x70, + 0x4d, 0x4d, 0x3a, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, + 0x44, 0x3e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x3a, 0x64, 0x6f, 0x63, 0x69, + 0x64, 0x3a, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3a, + 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x36, 0x2d, 0x62, 0x32, 0x34, + 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, + 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, + 0x3c, 0x2f, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3a, 0x44, 0x6f, 0x63, 0x75, + 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, + 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, + 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, + 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, + 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, + 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, + 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x64, 0x63, 0x3d, + 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x70, 0x75, 0x72, 0x6c, + 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x64, 0x63, 0x2f, 0x65, 0x6c, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x31, 0x2e, 0x31, 0x2f, 0x27, 0x3e, 0x0a, + 0x20, 0x20, 0x3c, 0x64, 0x63, 0x3a, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x72, + 0x64, 0x66, 0x3a, 0x41, 0x6c, 0x74, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x6c, 0x69, 0x20, 0x78, 0x6d, 0x6c, 0x3a, + 0x6c, 0x61, 0x6e, 0x67, 0x3d, 0x27, 0x78, 0x2d, 0x64, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x27, 0x3e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x6c, 0x69, 0x3e, 0x0a, 0x20, 0x20, + 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x41, 0x6c, 0x74, 0x3e, 0x0a, + 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x63, 0x3a, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, + 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x52, + 0x44, 0x46, 0x3e, 0x0a, 0x3c, 0x2f, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x6d, + 0x65, 0x74, 0x61, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x3c, 0x3f, 0x78, + 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x65, 0x6e, 0x64, 0x3d, 0x27, + 0x77, 0x27, 0x3f, 0x3e, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, + 0x65, 0x00, 0x64, 0x40, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, + 0x00, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x06, + 0x04, 0x03, 0x04, 0x06, 0x07, 0x05, 0x04, 0x04, 0x05, 0x07, 0x08, 0x06, + 0x06, 0x07, 0x06, 0x06, 0x08, 0x0a, 0x08, 0x09, 0x09, 0x09, 0x09, 0x08, + 0x0a, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x01, 0x04, 0x05, 0x05, 0x08, 0x07, 0x08, + 0x0f, 0x0a, 0x0a, 0x0f, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, + 0x0e, 0x0e, 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, + 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x11, 0x00, 0x02, + 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x0d, 0xff, + 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x00, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x03, 0x02, + 0x06, 0x01, 0x00, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x02, 0x02, + 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, + 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x02, 0x06, 0x07, + 0x03, 0x04, 0x02, 0x06, 0x02, 0x73, 0x01, 0x02, 0x03, 0x11, 0x04, 0x00, + 0x05, 0x21, 0x12, 0x31, 0x41, 0x51, 0x06, 0x13, 0x61, 0x22, 0x71, 0x81, + 0x14, 0x32, 0x91, 0xa1, 0x07, 0x15, 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, + 0xe1, 0x33, 0x16, 0x62, 0xf0, 0x24, 0x72, 0x82, 0xf1, 0x25, 0x43, 0x34, + 0x53, 0x92, 0xa2, 0xb2, 0x63, 0x73, 0xc2, 0x35, 0x44, 0x27, 0x93, 0xa3, + 0xb3, 0x36, 0x17, 0x54, 0x64, 0x74, 0xc3, 0xd2, 0xe2, 0x08, 0x26, 0x83, + 0x09, 0x0a, 0x18, 0x19, 0x84, 0x94, 0x45, 0x46, 0xa4, 0xb4, 0x56, 0xd3, + 0x55, 0x28, 0x1a, 0xf2, 0xe3, 0xf3, 0xc4, 0xd4, 0xe4, 0xf4, 0x65, 0x75, + 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x66, 0x76, 0x86, 0x96, + 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, + 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x38, 0x48, 0x58, 0x68, 0x78, + 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8, 0x29, 0x39, 0x49, 0x59, + 0x69, 0x79, 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9, 0x2a, 0x3a, + 0x4a, 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa, + 0x11, 0x00, 0x02, 0x02, 0x01, 0x02, 0x03, 0x05, 0x05, 0x04, 0x05, 0x06, + 0x04, 0x08, 0x03, 0x03, 0x6d, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, + 0x12, 0x31, 0x41, 0x05, 0x51, 0x13, 0x61, 0x22, 0x06, 0x71, 0x81, 0x91, + 0x32, 0xa1, 0xb1, 0xf0, 0x14, 0xc1, 0xd1, 0xe1, 0x23, 0x42, 0x15, 0x52, + 0x62, 0x72, 0xf1, 0x33, 0x24, 0x34, 0x43, 0x82, 0x16, 0x92, 0x53, 0x25, + 0xa2, 0x63, 0xb2, 0xc2, 0x07, 0x73, 0xd2, 0x35, 0xe2, 0x44, 0x83, 0x17, + 0x54, 0x93, 0x08, 0x09, 0x0a, 0x18, 0x19, 0x26, 0x36, 0x45, 0x1a, 0x27, + 0x64, 0x74, 0x55, 0x37, 0xf2, 0xa3, 0xb3, 0xc3, 0x28, 0x29, 0xd3, 0xe3, + 0xf3, 0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4, 0x65, 0x75, 0x85, + 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x46, 0x56, 0x66, 0x76, 0x86, + 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x47, 0x57, 0x67, 0x77, 0x87, + 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x38, 0x48, 0x58, 0x68, 0x78, + 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8, 0x39, 0x49, 0x59, 0x69, + 0x79, 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9, 0x2a, 0x3a, 0x4a, + 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa, 0xff, + 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, + 0x00, 0xf0, 0x67, 0xa6, 0x5c, 0x0f, 0x01, 0xd4, 0x7e, 0x18, 0x12, 0x98, + 0xe9, 0xd6, 0x2d, 0x34, 0x6d, 0x70, 0xdf, 0xdc, 0xa1, 0xe3, 0xec, 0x5b, + 0xfb, 0x32, 0x24, 0xb2, 0x01, 0x1f, 0x15, 0xa4, 0x52, 0x4a, 0x82, 0x31, + 0xf1, 0xfe, 0xd1, 0x3d, 0x14, 0x64, 0x49, 0x64, 0x22, 0x98, 0xcf, 0xa5, + 0x46, 0x6c, 0x16, 0x55, 0x71, 0x56, 0x62, 0x28, 0x07, 0xc5, 0x45, 0x15, + 0xa0, 0xc8, 0x89, 0x33, 0xe1, 0x63, 0xd2, 0xd8, 0x34, 0x44, 0x17, 0xa0, + 0x2c, 0x4d, 0x16, 0xbb, 0xed, 0xdc, 0xf8, 0x64, 0xc1, 0x6b, 0x31, 0x42, + 0x18, 0x8e, 0xc7, 0xb5, 0x2a, 0x7d, 0xb2, 0x56, 0xc5, 0x61, 0x8c, 0xf2, + 0xa0, 0x1b, 0x1e, 0x83, 0x0d, 0xa1, 0x63, 0x50, 0x1f, 0x97, 0x7c, 0x2a, + 0xa9, 0x1a, 0x9a, 0x86, 0x4f, 0xb4, 0xb4, 0x38, 0x0a, 0xa6, 0x0b, 0xb8, + 0x0c, 0x05, 0x14, 0xf8, 0x76, 0x3e, 0x19, 0x14, 0xb6, 0x78, 0xf8, 0x8c, + 0x2a, 0xd5, 0x01, 0xdc, 0x6f, 0x8a, 0x1a, 0xe3, 0x8d, 0xab, 0xff, 0xd0, + 0xf0, 0xec, 0xe9, 0x15, 0xb5, 0xb9, 0x5a, 0x7c, 0x4c, 0xa2, 0x9e, 0x24, + 0xf5, 0xca, 0xc6, 0xe5, 0x99, 0xd9, 0x34, 0x99, 0x04, 0x3a, 0x7d, 0xb5, + 0xba, 0xd5, 0x51, 0x63, 0x0e, 0xc7, 0xc5, 0x9b, 0x73, 0xf8, 0xe4, 0x6f, + 0x76, 0xca, 0xd9, 0xda, 0x54, 0x6d, 0x72, 0x2e, 0x1a, 0x57, 0x11, 0x44, + 0x40, 0x0d, 0x27, 0x7a, 0x0f, 0xd9, 0x5f, 0x12, 0x69, 0x4c, 0x84, 0xcd, + 0x36, 0xe3, 0x85, 0xb2, 0xcd, 0x2f, 0x4a, 0x8b, 0x58, 0x36, 0xf6, 0x76, + 0xa8, 0x64, 0x64, 0x3c, 0xa4, 0x93, 0xaa, 0x25, 0x3c, 0x49, 0xda, 0xa4, + 0xe5, 0x26, 0x54, 0xe4, 0x8c, 0x7c, 0x5c, 0x93, 0x4d, 0x67, 0xc9, 0x3a, + 0x6e, 0x9f, 0x13, 0xb4, 0xce, 0xf7, 0x3a, 0x9b, 0xad, 0x52, 0xd6, 0x2a, + 0xd1, 0x49, 0xee, 0xc7, 0xf8, 0x64, 0x46, 0x42, 0x4e, 0xcd, 0x92, 0xc2, + 0x00, 0xdd, 0x8a, 0x47, 0xe5, 0x69, 0x6e, 0xd4, 0xa4, 0x08, 0x16, 0x83, + 0x9c, 0x8c, 0xdd, 0x95, 0x6b, 0xb9, 0xf6, 0xef, 0x97, 0x78, 0x94, 0xe3, + 0x78, 0x04, 0xa4, 0xf3, 0xe8, 0xee, 0x64, 0xe1, 0x12, 0x10, 0x05, 0x6a, + 0xc7, 0xc0, 0x6f, 0x53, 0xf3, 0xc9, 0x89, 0xb4, 0x9c, 0x4e, 0xb4, 0xf2, + 0xd3, 0xde, 0x7a, 0xd2, 0x19, 0x16, 0x38, 0x61, 0x5d, 0xd9, 0x88, 0x05, + 0x9c, 0xf4, 0x0a, 0x0f, 0x5f, 0x73, 0x84, 0xe4, 0xa4, 0xc7, 0x0d, 0xa5, + 0xf1, 0x59, 0xba, 0x5c, 0x08, 0x98, 0x6f, 0xc8, 0x20, 0xfa, 0x4e, 0x4e, + 0xf6, 0x69, 0xe1, 0xa2, 0x89, 0xfd, 0x1f, 0x77, 0x2c, 0xe6, 0xce, 0xd6, + 0x17, 0x9a, 0x69, 0xdb, 0xd3, 0x86, 0x18, 0xc1, 0x67, 0x77, 0x26, 0x80, + 0x28, 0x1b, 0x93, 0x88, 0x41, 0x0f, 0x40, 0xb0, 0xfc, 0x87, 0xf3, 0x43, + 0x98, 0xd7, 0x58, 0x96, 0xdb, 0x4d, 0x91, 0x88, 0xe5, 0x6c, 0x58, 0xdc, + 0x5c, 0x2a, 0xf7, 0x2c, 0xb1, 0xfc, 0x20, 0x8f, 0x02, 0xd9, 0x65, 0x06, + 0xbe, 0x26, 0x6f, 0xa2, 0x7f, 0xce, 0x3d, 0x69, 0x26, 0xdd, 0x13, 0x52, + 0xbf, 0xbd, 0x92, 0x62, 0x59, 0x4c, 0x90, 0xac, 0x50, 0x45, 0x5e, 0xbb, + 0x09, 0x03, 0x12, 0x29, 0x84, 0x00, 0xc4, 0xc9, 0x11, 0xff, 0x00, 0x42, + 0xe7, 0xa7, 0x7a, 0xd4, 0xfd, 0x21, 0x79, 0xe9, 0x78, 0x71, 0x8b, 0x95, + 0x39, 0x75, 0xaf, 0x4e, 0x98, 0x78, 0x42, 0x38, 0xdf, 0xff, 0xd1, 0xf0, + 0xe6, 0xa0, 0x58, 0xc8, 0x84, 0x9a, 0xaa, 0x30, 0x55, 0xf9, 0x0a, 0x6f, + 0x90, 0x0c, 0xca, 0x72, 0x48, 0xb8, 0x1e, 0x89, 0xa7, 0x23, 0x17, 0x24, + 0xff, 0x00, 0x61, 0xb6, 0x54, 0x76, 0x6e, 0x1b, 0xa7, 0xbe, 0x50, 0xf2, + 0xc1, 0xd7, 0x4c, 0x52, 0x5e, 0x33, 0x5b, 0xe9, 0x10, 0xf4, 0x54, 0x3c, + 0x5e, 0x77, 0xee, 0x49, 0xec, 0x2b, 0xb6, 0x63, 0xe4, 0xc9, 0xc3, 0xef, + 0x73, 0xf0, 0xe1, 0x32, 0x1b, 0xf2, 0x7a, 0x05, 0xce, 0xad, 0x65, 0xa1, + 0x98, 0xb4, 0x0f, 0x2a, 0x5b, 0x23, 0xeb, 0x12, 0x00, 0x88, 0xb0, 0xa8, + 0x66, 0x46, 0x3d, 0xea, 0x7b, 0xfb, 0x9e, 0x99, 0x89, 0xbc, 0x8d, 0x97, + 0x3a, 0x34, 0x05, 0x32, 0x5d, 0x1f, 0xc9, 0x1a, 0x8c, 0x36, 0x8c, 0x6f, + 0x66, 0xfa, 0xc6, 0xb7, 0x7d, 0xf0, 0x94, 0x04, 0xf0, 0x88, 0xc9, 0xd5, + 0x9d, 0x8d, 0x4b, 0x11, 0xd4, 0x9f, 0xbb, 0x25, 0xc5, 0xdc, 0xa2, 0x03, + 0x99, 0x4b, 0xbc, 0xf3, 0x0d, 0x97, 0x96, 0x74, 0xe5, 0xf2, 0xb6, 0x80, + 0x95, 0xbd, 0x99, 0x15, 0xf5, 0x4b, 0xd2, 0x37, 0x58, 0x46, 0xd4, 0x27, + 0xc5, 0xce, 0xc1, 0x7c, 0x30, 0x8e, 0x68, 0x94, 0x7b, 0x9e, 0x6d, 0xe6, + 0x7b, 0x9b, 0x5d, 0x3a, 0xd8, 0xdb, 0x32, 0xfa, 0x77, 0x65, 0x15, 0xe4, + 0x57, 0xa7, 0x21, 0x55, 0x04, 0x57, 0xef, 0xd8, 0x66, 0x56, 0x38, 0x19, + 0x1b, 0xe8, 0xe0, 0x67, 0x98, 0xc7, 0x1a, 0x1c, 0xde, 0x71, 0x71, 0x79, + 0x2c, 0xf2, 0xfa, 0x8c, 0x48, 0xec, 0xb5, 0x24, 0x9a, 0x0c, 0xce, 0x75, + 0x29, 0xae, 0x8c, 0x67, 0xd4, 0xb5, 0x0b, 0x4b, 0x04, 0x05, 0xef, 0x2e, + 0x66, 0x8e, 0x18, 0x08, 0x15, 0xdd, 0x8f, 0x11, 0xb0, 0xeb, 0x4c, 0x04, + 0x5b, 0x21, 0x2a, 0x7d, 0x41, 0xe4, 0x4f, 0xcb, 0xcb, 0x5d, 0x12, 0x45, + 0xb8, 0xb7, 0x53, 0x71, 0xaa, 0x9f, 0x86, 0x5b, 0xd6, 0x50, 0x4a, 0xed, + 0xba, 0x46, 0x77, 0x00, 0x13, 0xd4, 0x8c, 0x85, 0xd3, 0x12, 0x6d, 0xeb, + 0x1a, 0x67, 0x95, 0xd9, 0x39, 0x39, 0x50, 0xac, 0xff, 0x00, 0x6f, 0xc4, + 0xff, 0x00, 0x1c, 0x81, 0x92, 0xb2, 0x6b, 0x6d, 0x02, 0xdd, 0xbd, 0x36, + 0x92, 0x36, 0x2d, 0x1f, 0xc0, 0x2a, 0x0b, 0x28, 0x1b, 0x91, 0x41, 0xf4, + 0x9c, 0xb6, 0x25, 0x81, 0x46, 0xfe, 0x81, 0xb5, 0xad, 0x3d, 0xba, 0x57, + 0xb7, 0xf9, 0xf6, 0xc9, 0xb0, 0x7f, 0xff, 0xd2, 0xf0, 0xe2, 0x86, 0x95, + 0xc4, 0x67, 0x7e, 0x3f, 0x11, 0xf7, 0xa8, 0x19, 0x06, 0x69, 0x8d, 0xca, + 0xca, 0x24, 0x8f, 0xd3, 0x52, 0x24, 0x89, 0x47, 0x25, 0x1f, 0xcb, 0x20, + 0xf8, 0xb2, 0xb2, 0x76, 0x6e, 0x88, 0x36, 0xf6, 0x6f, 0x2a, 0xc1, 0x6e, + 0xfa, 0x45, 0xad, 0xbc, 0x3f, 0x0b, 0x46, 0x81, 0x4d, 0x46, 0xea, 0x7a, + 0x9a, 0x83, 0x9a, 0xa9, 0xdd, 0xbb, 0xec, 0x7b, 0x06, 0x5b, 0xe5, 0xcf, + 0x2e, 0x69, 0xfa, 0x5c, 0xcd, 0x7b, 0x14, 0x5e, 0xa5, 0xee, 0xf5, 0xb8, + 0x7d, 0xdd, 0x99, 0xba, 0xef, 0x91, 0x16, 0x5b, 0x36, 0xb6, 0x65, 0x0d, + 0xac, 0xb2, 0x5b, 0xed, 0x34, 0x81, 0x7a, 0xbb, 0x46, 0x40, 0x6a, 0x9e, + 0xb4, 0x39, 0x31, 0x13, 0x49, 0xda, 0xd2, 0x9b, 0xed, 0x1e, 0xc4, 0x24, + 0xb3, 0x35, 0xb2, 0x88, 0x60, 0x06, 0xe6, 0x56, 0x98, 0x96, 0x79, 0x1e, + 0x31, 0x51, 0xc9, 0x8f, 0xcb, 0x00, 0xe6, 0xb3, 0xe4, 0xf9, 0x2b, 0xcc, + 0x7a, 0x94, 0xda, 0x96, 0xa9, 0x71, 0x77, 0x70, 0x79, 0xcd, 0x33, 0x97, + 0x76, 0x3f, 0xcc, 0xc6, 0xa6, 0x9f, 0x2e, 0x99, 0xb9, 0xc6, 0x2a, 0x21, + 0xe6, 0x73, 0xca, 0xe6, 0x4a, 0x51, 0x1a, 0x99, 0x1c, 0x28, 0x04, 0x93, + 0xd0, 0x0e, 0xa4, 0xe4, 0xda, 0x5f, 0x50, 0xfe, 0x4a, 0xfe, 0x48, 0xb5, + 0xb2, 0xc1, 0xe6, 0x1f, 0x31, 0x7e, 0xef, 0x52, 0x91, 0x43, 0xc3, 0x6e, + 0x77, 0xf4, 0x22, 0x6d, 0xbf, 0xe4, 0x63, 0x0e, 0xbf, 0xca, 0x36, 0xeb, + 0x5c, 0x84, 0xa5, 0x48, 0x7d, 0x3b, 0x61, 0xa1, 0xdb, 0x5b, 0x2c, 0x71, + 0xda, 0x45, 0xc4, 0x28, 0x00, 0x81, 0xdb, 0x31, 0xc9, 0xb4, 0xb2, 0x3b, + 0x5d, 0x27, 0xa5, 0x05, 0x1b, 0xc7, 0xdb, 0x10, 0xa9, 0xbd, 0xa6, 0x93, + 0x0c, 0x75, 0xe4, 0x39, 0x35, 0x41, 0x3d, 0xc5, 0x06, 0xdb, 0x8e, 0xfd, + 0x46, 0x5b, 0x1d, 0x98, 0x95, 0x4f, 0x46, 0xdb, 0xd5, 0xfb, 0x29, 0x5e, + 0x9d, 0x0d, 0x32, 0xeb, 0x61, 0x4f, 0xff, 0xd3, 0xf1, 0x46, 0x9a, 0x16, + 0x1b, 0x91, 0x71, 0x28, 0xac, 0x4a, 0x14, 0x30, 0x3e, 0x19, 0x54, 0xb9, + 0x36, 0xc7, 0x9b, 0x2d, 0xd1, 0x6c, 0x45, 0xe3, 0xdc, 0xde, 0xc8, 0x95, + 0x5b, 0x87, 0xf8, 0x41, 0x1d, 0x10, 0x54, 0x01, 0x98, 0x79, 0x25, 0xd1, + 0xda, 0xe9, 0xe1, 0xb5, 0x9e, 0xac, 0xeb, 0x42, 0xba, 0x8e, 0xdf, 0x8c, + 0x31, 0x21, 0x70, 0xb4, 0x5d, 0xbe, 0xc5, 0x7c, 0x2b, 0xed, 0xe1, 0x94, + 0x18, 0xb9, 0x51, 0x3d, 0x03, 0x2c, 0x13, 0x6b, 0xf1, 0x42, 0x6e, 0xe2, + 0xb7, 0x12, 0xa0, 0xdd, 0x50, 0x9f, 0x4f, 0x6f, 0xa7, 0x6f, 0xc7, 0x03, + 0x61, 0xa0, 0x83, 0xb5, 0xf3, 0x97, 0x98, 0x20, 0x9c, 0x44, 0xea, 0xd0, + 0xad, 0x48, 0x64, 0x90, 0x21, 0xd8, 0x9f, 0xa7, 0xa6, 0x44, 0xca, 0x99, + 0xc6, 0x36, 0xcb, 0x74, 0x5d, 0x7e, 0x5b, 0xfe, 0x31, 0x6a, 0x31, 0xf3, + 0x8c, 0xd0, 0xad, 0x40, 0xa3, 0x1f, 0x7c, 0x44, 0xd6, 0x51, 0xd9, 0xe0, + 0x5f, 0x9a, 0x7e, 0x41, 0x9f, 0x40, 0xf3, 0x14, 0xba, 0x85, 0xba, 0x34, + 0xba, 0x2d, 0xfb, 0x34, 0xd0, 0xcf, 0x4f, 0xb0, 0xce, 0x6a, 0x51, 0xe9, + 0xb0, 0x20, 0xf4, 0xf1, 0x19, 0xb2, 0xc3, 0x90, 0x11, 0x4e, 0x97, 0x55, + 0x80, 0x83, 0xc4, 0x17, 0x7e, 0x4c, 0x79, 0x19, 0xfc, 0xd1, 0xe7, 0x78, + 0x4b, 0x91, 0x1d, 0xae, 0x92, 0xa6, 0xf6, 0x46, 0x75, 0xe4, 0xad, 0x22, + 0x1f, 0xdd, 0xa1, 0x07, 0xb3, 0x1e, 0xfe, 0xd9, 0x92, 0xeb, 0x4b, 0xed, + 0xfd, 0x0a, 0xc2, 0x63, 0x27, 0xa4, 0x88, 0x17, 0x60, 0x49, 0x35, 0xdc, + 0x8e, 0xa5, 0x7d, 0xab, 0xd3, 0x28, 0x90, 0x50, 0xcd, 0xed, 0x2d, 0xda, + 0x15, 0x55, 0x51, 0xf1, 0x1a, 0x0a, 0xf7, 0x39, 0x5d, 0xaa, 0x77, 0x6f, + 0x01, 0x8e, 0xa7, 0x7d, 0xfa, 0xff, 0x00, 0x66, 0x10, 0xa8, 0xb8, 0x63, + 0x76, 0x90, 0xa8, 0x20, 0x06, 0x56, 0xdb, 0x61, 0xda, 0xbd, 0x4f, 0xcb, + 0x24, 0x15, 0x0f, 0xf5, 0x66, 0xe5, 0x5f, 0x4c, 0x53, 0xc3, 0xb7, 0xce, + 0x99, 0x6b, 0x17, 0xff, 0xd4, 0xf0, 0xec, 0x57, 0x6f, 0x32, 0xa5, 0xa4, + 0x43, 0x76, 0x75, 0xa9, 0xf1, 0x03, 0xfa, 0x64, 0x08, 0x6c, 0x8e, 0xfb, + 0x3d, 0x7f, 0xcb, 0x16, 0x2b, 0x3d, 0xbc, 0x16, 0xa3, 0x66, 0x6d, 0x98, + 0xfb, 0x1e, 0xb9, 0xac, 0xc8, 0x77, 0xb7, 0x7d, 0x01, 0xb3, 0x37, 0xb8, + 0xd3, 0x46, 0x95, 0x68, 0x86, 0xd2, 0x2e, 0x4e, 0xab, 0xf0, 0x23, 0x11, + 0x4e, 0x5f, 0xcd, 0x98, 0xe7, 0x25, 0x96, 0x71, 0x83, 0x0f, 0xd6, 0x3c, + 0xb9, 0xe7, 0x0d, 0x7c, 0x41, 0x22, 0x5e, 0xb3, 0x20, 0x0c, 0x65, 0x80, + 0xc8, 0x63, 0x8e, 0xbb, 0x95, 0xa5, 0x07, 0xeb, 0xcc, 0xac, 0x73, 0x83, + 0x4e, 0x5c, 0x59, 0x09, 0xd8, 0xec, 0xc8, 0x57, 0x41, 0xd3, 0x4e, 0x95, + 0xa5, 0x5b, 0x4b, 0x6a, 0xcb, 0xab, 0x43, 0x10, 0x4b, 0xeb, 0x85, 0xa2, + 0x2c, 0x8e, 0x3f, 0x68, 0x54, 0xf5, 0x00, 0xd3, 0x97, 0x7a, 0x65, 0x79, + 0xa6, 0x24, 0x76, 0x6f, 0xd3, 0x62, 0x96, 0x30, 0x78, 0xcb, 0x21, 0xf2, + 0xf4, 0x22, 0xce, 0x54, 0x8e, 0x46, 0x26, 0x10, 0x7e, 0x0a, 0xf5, 0xd8, + 0xf5, 0x1f, 0x31, 0x98, 0x83, 0x73, 0xb3, 0x91, 0xcd, 0x67, 0xe6, 0x7d, + 0xe8, 0x16, 0x69, 0x6f, 0x10, 0x1f, 0x54, 0x9a, 0x37, 0xf5, 0x41, 0x5e, + 0x7f, 0x0a, 0x29, 0x62, 0x02, 0xf8, 0x9c, 0xc8, 0x8c, 0x77, 0x6a, 0x99, + 0xa0, 0x89, 0xff, 0x00, 0x9c, 0x74, 0xd2, 0xed, 0xed, 0xfc, 0xbb, 0x7b, + 0xaa, 0x9a, 0x7d, 0x62, 0xfe, 0x46, 0x2d, 0xfe, 0x4c, 0x51, 0x31, 0x11, + 0xa9, 0xf6, 0xef, 0x9b, 0x30, 0x5e, 0x7b, 0x38, 0xdd, 0xf4, 0x7f, 0x95, + 0x94, 0xbc, 0x12, 0x43, 0x30, 0x6a, 0xb2, 0xf3, 0x86, 0x40, 0x3e, 0xcb, + 0xd7, 0x6a, 0xd7, 0xb1, 0xe9, 0x8f, 0x37, 0x19, 0x97, 0x41, 0x2c, 0x71, + 0x20, 0xf5, 0x36, 0x9c, 0x55, 0x78, 0x1d, 0x8a, 0x91, 0xd7, 0x11, 0x14, + 0x5a, 0x3e, 0x19, 0x03, 0x10, 0x6b, 0xca, 0xbd, 0x86, 0xf8, 0x9d, 0x95, + 0x18, 0x36, 0x65, 0x2e, 0xbc, 0x54, 0x1f, 0xa2, 0x99, 0x00, 0x59, 0x2a, + 0x6f, 0x5e, 0x55, 0x15, 0xe9, 0x5f, 0xc3, 0x2f, 0xb6, 0x14, 0xff, 0x00, + 0xff, 0xd5, 0xf1, 0x95, 0xfe, 0x80, 0x74, 0x0d, 0x7c, 0xd9, 0x89, 0x3d, + 0x78, 0x57, 0x8b, 0xc5, 0x28, 0xe8, 0x55, 0xf7, 0x1f, 0x48, 0xca, 0x38, + 0xb8, 0x83, 0x9f, 0x93, 0x07, 0x85, 0x3a, 0x7a, 0x6f, 0x95, 0x66, 0x2b, + 0x2c, 0x4c, 0x0d, 0x14, 0x00, 0x3e, 0x9c, 0xc3, 0x98, 0x76, 0xb8, 0x45, + 0xbd, 0x02, 0xde, 0x48, 0xee, 0xdc, 0xa0, 0x15, 0xe2, 0x2b, 0xc8, 0x8a, + 0x8a, 0xfd, 0x3b, 0x66, 0x3f, 0x00, 0x73, 0x84, 0x2d, 0x36, 0xb5, 0xb5, + 0x9e, 0x35, 0x1c, 0x29, 0xc4, 0xfe, 0xc8, 0x04, 0x7f, 0xc4, 0x69, 0x91, + 0xe1, 0x67, 0x2c, 0x4a, 0xd2, 0xe9, 0x4e, 0xe3, 0xd4, 0xf4, 0x81, 0x5a, + 0x12, 0xc5, 0x41, 0x3f, 0x79, 0x38, 0x9b, 0x60, 0x20, 0x07, 0x34, 0xb0, + 0xc9, 0x03, 0x5c, 0x23, 0x03, 0x53, 0x13, 0x56, 0x88, 0xdf, 0x09, 0xda, + 0x9b, 0xd3, 0xb6, 0x52, 0x0e, 0xec, 0xe4, 0x29, 0x24, 0xfc, 0xd0, 0xe7, + 0x75, 0xe5, 0x57, 0x6b, 0x61, 0xfb, 0xf0, 0xca, 0xaa, 0x57, 0xa8, 0xe6, + 0x78, 0x1a, 0x7d, 0xf9, 0x95, 0x8a, 0x5e, 0xa0, 0xe3, 0x67, 0x8f, 0xa0, + 0xbd, 0x5b, 0xf2, 0xdf, 0x4a, 0x82, 0xcb, 0x4a, 0xb3, 0xb0, 0xb4, 0x41, + 0x0a, 0x70, 0x48, 0xd9, 0x57, 0x60, 0x51, 0x3a, 0x8f, 0xbc, 0xe6, 0x7b, + 0xcb, 0xe4, 0x3b, 0xa7, 0x3f, 0x9b, 0x9f, 0x9a, 0xba, 0x77, 0xe5, 0x5f, + 0x95, 0x9c, 0x59, 0x94, 0x9f, 0xcd, 0x37, 0x8c, 0xa9, 0xa6, 0xd9, 0x39, + 0xaa, 0xd0, 0x7d, 0xa9, 0x1c, 0x03, 0x5e, 0x09, 0xff, 0x00, 0x0c, 0x76, + 0xcb, 0x62, 0x2d, 0xa5, 0xf2, 0x85, 0xbf, 0xe7, 0x87, 0xe6, 0xa3, 0x5e, + 0x4d, 0xa8, 0xc9, 0xe6, 0x8b, 0xd5, 0x69, 0x5c, 0xb0, 0x4a, 0xab, 0xc4, + 0xb5, 0x35, 0x0a, 0xaa, 0xea, 0x40, 0x03, 0xa0, 0xf6, 0xcb, 0x40, 0x4d, + 0x3e, 0xdb, 0xff, 0x00, 0x9c, 0x7f, 0xfc, 0xce, 0x4f, 0xcc, 0xbf, 0x26, + 0x25, 0xe5, 0xd3, 0x2f, 0xe9, 0xdd, 0x3d, 0xfe, 0xab, 0xa9, 0xaa, 0xd2, + 0xa6, 0x40, 0x2a, 0xb2, 0x71, 0x00, 0x01, 0xea, 0x0d, 0xe8, 0x3a, 0x64, + 0x25, 0x16, 0x1c, 0x8b, 0xd9, 0x51, 0x39, 0x28, 0x12, 0x51, 0x41, 0xfd, + 0xa3, 0xd2, 0xb9, 0x4f, 0x0d, 0x33, 0xb5, 0xf4, 0x87, 0x9d, 0x79, 0x0e, + 0xb4, 0xaf, 0x6a, 0xf8, 0xf1, 0xf0, 0xc9, 0xda, 0xbf, 0xff, 0xd6, 0xf2, + 0xc6, 0xb5, 0x68, 0x64, 0xd0, 0x6d, 0x35, 0x20, 0x39, 0xcd, 0x13, 0x0f, + 0x5e, 0x61, 0xfc, 0x8f, 0x40, 0x8b, 0x5e, 0xe0, 0x66, 0x1c, 0x4f, 0xaa, + 0x9d, 0xe6, 0xa6, 0x1e, 0x91, 0x2e, 0xa9, 0x87, 0x95, 0xee, 0x9c, 0xc5, + 0x55, 0x34, 0x60, 0x40, 0xae, 0x57, 0x30, 0xd9, 0xa7, 0x95, 0xbd, 0x6f, + 0xcb, 0x26, 0x39, 0x40, 0x0d, 0x4e, 0xc0, 0x9f, 0x9e, 0x50, 0x5d, 0xac, + 0x79, 0x33, 0x8b, 0xbb, 0x9b, 0x3b, 0x6b, 0x35, 0x48, 0x54, 0x09, 0x29, + 0x56, 0x7f, 0xe1, 0x86, 0x72, 0x00, 0x2c, 0x6e, 0xf7, 0x63, 0x3e, 0x63, + 0xbd, 0xbd, 0x5d, 0x20, 0x2a, 0xb3, 0xa4, 0x33, 0x48, 0xab, 0x21, 0x43, + 0xf1, 0x2c, 0x47, 0xed, 0x1d, 0xbc, 0x73, 0x18, 0x9b, 0x64, 0x28, 0x96, + 0x3a, 0xc7, 0x49, 0xb0, 0xf4, 0xcc, 0xe9, 0x73, 0x6c, 0xb4, 0xf8, 0x67, + 0x92, 0x32, 0x21, 0x70, 0x7b, 0x89, 0x05, 0x57, 0xef, 0x38, 0x28, 0x94, + 0x4a, 0x7d, 0x13, 0x7d, 0x6a, 0xd3, 0x4c, 0xb8, 0xf2, 0xc3, 0xc8, 0x2e, + 0x03, 0xf3, 0xe2, 0x7d, 0x33, 0xb7, 0xc5, 0xcc, 0x71, 0x03, 0xc6, 0xb9, + 0x64, 0x06, 0xe2, 0x9a, 0xf2, 0x4f, 0xd2, 0x6d, 0xe9, 0xfe, 0x41, 0x45, + 0x5b, 0x18, 0x66, 0xa5, 0x64, 0x09, 0xf4, 0xd5, 0xb7, 0xcd, 0x93, 0xc7, + 0xcf, 0x9b, 0xe5, 0x6f, 0xf9, 0xc8, 0x0d, 0x56, 0xeb, 0x59, 0xfc, 0xce, + 0xd5, 0x12, 0x61, 0xc4, 0x69, 0xe9, 0x0d, 0xa4, 0x4b, 0xfe, 0x48, 0x40, + 0xd5, 0x3e, 0xe4, 0xb6, 0x64, 0x8e, 0x4c, 0x02, 0x61, 0x65, 0xa0, 0x14, + 0xb4, 0xb6, 0xb0, 0xb1, 0xb6, 0xb2, 0x97, 0xcb, 0xf1, 0x5a, 0x2d, 0xc6, + 0xa5, 0xac, 0xb4, 0x70, 0x5d, 0xc7, 0x3d, 0xc1, 0x51, 0x24, 0x91, 0xc9, + 0x31, 0x75, 0x6b, 0x70, 0x9f, 0x14, 0x68, 0x01, 0x46, 0xe4, 0xb5, 0xa3, + 0x17, 0xcb, 0x40, 0x61, 0x6f, 0x47, 0xff, 0x00, 0x9c, 0x3a, 0x8f, 0x5b, + 0x4f, 0x3c, 0x6b, 0xb7, 0xfa, 0x30, 0x91, 0x3c, 0xa4, 0xb1, 0x95, 0xb9, + 0x82, 0x42, 0x0a, 0xbc, 0x8e, 0xe4, 0xdb, 0xa9, 0xef, 0xc9, 0x17, 0x91, + 0x24, 0x7c, 0xb2, 0x05, 0x64, 0xfb, 0x75, 0x64, 0x32, 0x39, 0x69, 0x5b, + 0x9c, 0xad, 0xb9, 0xdb, 0xa7, 0xb5, 0x3b, 0x53, 0x2a, 0x21, 0x41, 0x44, + 0xf3, 0x8b, 0x8f, 0x2e, 0x43, 0x9d, 0x2b, 0xd4, 0x57, 0x23, 0x41, 0x36, + 0xff, 0x00, 0xff, 0xd7, 0xf0, 0xc0, 0xd5, 0xb5, 0x11, 0x64, 0xb6, 0x3f, + 0x59, 0x90, 0xd9, 0xab, 0x06, 0xf4, 0x79, 0x7c, 0x3b, 0x74, 0xc8, 0x08, + 0x8b, 0xb6, 0xe3, 0x96, 0x55, 0x57, 0xb3, 0x3e, 0xf2, 0x35, 0xc7, 0xd6, + 0x0b, 0x45, 0x5d, 0xdc, 0x8a, 0x7d, 0xd9, 0x8d, 0x94, 0x3b, 0x3d, 0x1c, + 0x9e, 0xc3, 0xe5, 0xc3, 0x2c, 0x7c, 0xc5, 0x0f, 0xee, 0xdb, 0x8b, 0x0c, + 0xc4, 0x26, 0x9d, 0xa0, 0x9a, 0x7d, 0x2c, 0xe5, 0xe4, 0x55, 0x7f, 0xee, + 0xc1, 0x15, 0x04, 0xd0, 0x12, 0x3c, 0x72, 0x89, 0x1b, 0x2c, 0xcc, 0xa8, + 0x2a, 0x8b, 0x87, 0xbb, 0x63, 0x1a, 0x28, 0x65, 0xf0, 0xed, 0xf2, 0xc3, + 0xc2, 0x0a, 0x06, 0x4a, 0x46, 0xc7, 0xa5, 0xa3, 0x59, 0xc8, 0xb2, 0xc7, + 0x45, 0x22, 0x9c, 0x14, 0x54, 0x10, 0x46, 0xf5, 0x1d, 0x32, 0x5c, 0x14, + 0x14, 0xe4, 0x32, 0x2f, 0x3a, 0xf3, 0xb6, 0x90, 0x9a, 0x6d, 0xae, 0x9f, + 0x3d, 0xab, 0xb8, 0x8a, 0x3b, 0xf8, 0x39, 0x44, 0x58, 0xf0, 0x08, 0xd5, + 0x14, 0xa5, 0x7b, 0x65, 0x98, 0x8e, 0xfb, 0xb5, 0x67, 0x87, 0xa5, 0xef, + 0x5e, 0x44, 0x96, 0x35, 0xb5, 0xb6, 0x59, 0x36, 0xfd, 0xd8, 0xa0, 0xf1, + 0x20, 0x53, 0x33, 0xc0, 0x79, 0x59, 0x73, 0x7c, 0xd7, 0xf9, 0xfb, 0xa2, + 0xcd, 0x67, 0xf9, 0xa7, 0x7b, 0x72, 0xf1, 0x71, 0x83, 0x53, 0x86, 0x0b, + 0x98, 0x24, 0x22, 0x8a, 0xcc, 0x88, 0x23, 0x7f, 0xb8, 0xae, 0xf9, 0x7c, + 0x50, 0x1e, 0x5f, 0x7c, 0x48, 0x21, 0x44, 0x6b, 0xce, 0x9b, 0xb0, 0x1b, + 0x9e, 0xf5, 0xaf, 0x8e, 0x4d, 0x5f, 0x7a, 0x7f, 0xce, 0x34, 0xf9, 0x5d, + 0x3c, 0xa3, 0xf9, 0x69, 0x63, 0xa9, 0x3c, 0x27, 0xeb, 0xda, 0xe1, 0x37, + 0xd7, 0x2e, 0xaa, 0xdb, 0x06, 0xda, 0x30, 0x49, 0xfe, 0x54, 0x03, 0x03, + 0x49, 0xdc, 0xb3, 0xaf, 0x38, 0xfe, 0x6a, 0xf9, 0x47, 0xc9, 0x3a, 0x74, + 0x97, 0xfa, 0xf6, 0xaf, 0x15, 0x85, 0xb8, 0x75, 0x89, 0xb8, 0x87, 0x9a, + 0x72, 0xee, 0x2a, 0x14, 0x24, 0x60, 0xb1, 0xa8, 0xdf, 0x07, 0x0b, 0x2d, + 0xcb, 0xcf, 0x7f, 0xe8, 0x6a, 0xff, 0x00, 0x26, 0xbd, 0x6a, 0x7f, 0x89, + 0x2f, 0xf8, 0x52, 0x9e, 0xb7, 0xe8, 0xb9, 0xb8, 0x57, 0xc2, 0x95, 0xe9, + 0x8f, 0x08, 0x5a, 0x2f, 0xff, 0xd0, 0xf0, 0x4d, 0x40, 0xaa, 0xd7, 0x00, + 0x64, 0xcb, 0x3c, 0x97, 0xa8, 0xb5, 0x9e, 0xa3, 0x1a, 0xd6, 0x84, 0x95, + 0x3f, 0x45, 0x72, 0x9c, 0xa2, 0xc3, 0x99, 0xa5, 0x9d, 0x49, 0xf4, 0x17, + 0x97, 0xaf, 0x63, 0x17, 0x52, 0x6f, 0xf0, 0xc8, 0x43, 0x6f, 0x9a, 0xe9, + 0x07, 0x70, 0x0e, 0xec, 0x83, 0x51, 0x44, 0xb8, 0x61, 0x1a, 0x9e, 0x11, + 0xd3, 0x91, 0x60, 0x68, 0x6b, 0xd3, 0x31, 0x4f, 0x36, 0xd3, 0x4c, 0x52, + 0xef, 0x4c, 0xd5, 0x0c, 0xc4, 0x69, 0xda, 0x94, 0xc8, 0x3a, 0xf0, 0x66, + 0x07, 0x73, 0xe0, 0x40, 0xfd, 0x79, 0x93, 0x12, 0x1c, 0x9c, 0x32, 0xc7, + 0xfc, 0x41, 0x33, 0xd2, 0xb4, 0x6f, 0x38, 0x98, 0x65, 0x76, 0xbf, 0x69, + 0x42, 0xd0, 0xaa, 0xc9, 0xde, 0x95, 0xad, 0x28, 0x46, 0x4e, 0xac, 0x39, + 0x77, 0x80, 0x11, 0xbf, 0xd8, 0xc7, 0x7c, 0xe1, 0xa5, 0xf9, 0x92, 0x4d, + 0x32, 0x5b, 0x8b, 0x93, 0x27, 0xa7, 0x68, 0x56, 0xe2, 0x45, 0xda, 0x85, + 0x61, 0x6e, 0x67, 0xad, 0x6b, 0xb0, 0x38, 0xc2, 0x81, 0xe4, 0xc7, 0x52, + 0x31, 0x1c, 0x67, 0x86, 0x5b, 0xbd, 0x37, 0xca, 0x7a, 0x94, 0xb1, 0x69, + 0xb6, 0x2e, 0xb7, 0x15, 0x48, 0xc2, 0xb4, 0x52, 0x53, 0xac, 0x32, 0xaf, + 0xb1, 0xed, 0x9b, 0x10, 0x36, 0x78, 0x5c, 0x9f, 0x51, 0x64, 0x1f, 0x98, + 0x3e, 0x58, 0xb6, 0xfc, 0xc8, 0xf2, 0xe5, 0xbc, 0x68, 0x52, 0x2d, 0x5a, + 0xd1, 0x84, 0xb6, 0xf3, 0x95, 0x0e, 0xc0, 0x85, 0xe2, 0xcb, 0xd8, 0xd1, + 0xbb, 0xe4, 0xc1, 0xa6, 0x97, 0xce, 0x17, 0x5f, 0x95, 0xde, 0x6d, 0xb6, + 0xbe, 0xb7, 0x69, 0x34, 0xf3, 0x3c, 0x72, 0xcf, 0xe8, 0xa3, 0x45, 0x49, + 0x95, 0x4a, 0x90, 0x3e, 0x35, 0x5a, 0x95, 0x1d, 0xfe, 0x21, 0x93, 0x4d, + 0xbe, 0xd2, 0xd2, 0xf5, 0x8b, 0xbd, 0x32, 0x2d, 0x3f, 0x4c, 0x9a, 0xe4, + 0xca, 0x9e, 0x90, 0x85, 0x65, 0x55, 0x08, 0x85, 0x91, 0x01, 0x3b, 0x0a, + 0x05, 0xe9, 0xb0, 0xc0, 0x5a, 0xc3, 0xcd, 0x3f, 0x3b, 0x7f, 0x26, 0xec, + 0xff, 0x00, 0x35, 0x6d, 0x6d, 0xb5, 0x3d, 0x16, 0xfe, 0x0d, 0x3b, 0xcd, + 0x96, 0x01, 0x92, 0x46, 0x9e, 0xa2, 0x0b, 0xc8, 0xb7, 0x28, 0x92, 0x71, + 0xfb, 0x2e, 0xa7, 0xec, 0x3d, 0x0f, 0xc2, 0x68, 0x71, 0x05, 0x95, 0xd3, + 0xe7, 0x9f, 0xfa, 0x16, 0x2f, 0xcd, 0x7f, 0x43, 0xd6, 0xfa, 0xa5, 0x97, + 0xab, 0xeb, 0x7a, 0x5f, 0x55, 0xfa, 0xec, 0x5e, 0xaf, 0x0f, 0xf7, 0xed, + 0x2b, 0x4e, 0x15, 0xff, 0x00, 0x65, 0xdf, 0x8e, 0x14, 0xf1, 0xbf, 0xff, + 0xd1, 0xf0, 0x5a, 0xa7, 0x18, 0x5e, 0x56, 0x1f, 0x68, 0x71, 0x5f, 0xa7, + 0xbe, 0x2a, 0x98, 0xdb, 0xfa, 0x90, 0x24, 0x37, 0xb0, 0xfd, 0xb8, 0xa8, + 0x58, 0x78, 0xae, 0x43, 0xc9, 0xb4, 0x6d, 0xbb, 0xda, 0x3c, 0xa1, 0xad, + 0x43, 0xa8, 0xda, 0xc5, 0x2a, 0x3d, 0x26, 0x5a, 0x02, 0x2b, 0xbe, 0x60, + 0x64, 0x8d, 0x17, 0x6f, 0x8b, 0x20, 0x90, 0x7a, 0x3c, 0x32, 0x8b, 0xa8, + 0x02, 0xf3, 0xfd, 0xe0, 0x1b, 0x11, 0x98, 0x66, 0x3b, 0xb9, 0x62, 0x54, + 0x83, 0x36, 0xf2, 0xa4, 0xe4, 0x29, 0x34, 0xeb, 0xc8, 0x74, 0xae, 0x0d, + 0xc3, 0x65, 0x82, 0x13, 0x6b, 0x57, 0xba, 0x54, 0xe4, 0x8c, 0x41, 0x1b, + 0x75, 0xa7, 0xe0, 0x72, 0x5c, 0x4c, 0x84, 0x50, 0x5a, 0xb3, 0xdd, 0xdd, + 0xc3, 0x24, 0x33, 0xb1, 0x60, 0xe0, 0x86, 0x52, 0x45, 0x38, 0xd2, 0x87, + 0x24, 0x26, 0x6d, 0x8c, 0xe1, 0x41, 0x25, 0xfc, 0xa3, 0xd7, 0x2f, 0x6f, + 0x3c, 0xbf, 0x73, 0xa5, 0xb2, 0x2c, 0xd1, 0x69, 0x17, 0x2f, 0x6b, 0x14, + 0x8c, 0x0f, 0x21, 0x0d, 0x79, 0x46, 0x09, 0x15, 0xed, 0xb7, 0x4e, 0xd9, + 0xb9, 0x8b, 0xcb, 0xe4, 0xa2, 0x5e, 0xa3, 0xa6, 0xdf, 0x6a, 0x36, 0xe4, + 0xcd, 0x69, 0x1c, 0x4e, 0x84, 0x7c, 0x76, 0xab, 0x21, 0x67, 0xa8, 0xa7, + 0xd9, 0xf8, 0x4d, 0x2b, 0xf3, 0xc3, 0x4d, 0x49, 0x57, 0x98, 0x75, 0x6f, + 0x31, 0xda, 0xf9, 0xa3, 0x4b, 0xfd, 0x1f, 0x69, 0x1d, 0xae, 0xa1, 0xa9, + 0x7e, 0xee, 0xe6, 0xd2, 0x79, 0x18, 0xf3, 0xb5, 0x1f, 0xee, 0xd9, 0x0a, + 0x01, 0x4e, 0x3f, 0xb3, 0x4d, 0xf2, 0x9c, 0xb9, 0x04, 0x05, 0xb7, 0xe2, + 0x87, 0x1e, 0xdd, 0x19, 0x3e, 0xaf, 0x6b, 0xae, 0xcb, 0x6d, 0x13, 0x0d, + 0x45, 0xa2, 0x8e, 0x06, 0xe5, 0x13, 0x2a, 0x02, 0x01, 0x5e, 0x82, 0xb5, + 0x04, 0xe6, 0x11, 0xd4, 0xcd, 0xda, 0x43, 0x49, 0x8e, 0xb7, 0xdc, 0xb1, + 0x51, 0xe6, 0x4d, 0x76, 0xd2, 0x61, 0x15, 0xaa, 0x4b, 0xa8, 0xc9, 0x6e, + 0x49, 0x79, 0x20, 0xe6, 0x8c, 0x49, 0xad, 0x43, 0x16, 0xe4, 0xa7, 0xaf, + 0x43, 0xd3, 0x26, 0x35, 0x75, 0xcd, 0xa8, 0xe8, 0x87, 0x46, 0xbf, 0xc7, + 0x9a, 0xff, 0x00, 0xd6, 0xbf, 0x48, 0xfe, 0x88, 0xfd, 0xe7, 0x0f, 0xab, + 0xfa, 0x3f, 0x58, 0x7f, 0x5f, 0x8d, 0x3f, 0x9f, 0xa7, 0x5e, 0xd4, 0xc3, + 0xf9, 0xd1, 0x7c, 0xb6, 0x47, 0xe4, 0x3a, 0x5b, 0xff, 0xd2, 0xf0, 0xb7, + 0xa6, 0x1e, 0xdf, 0xd3, 0xf6, 0xa5, 0x71, 0x54, 0xdb, 0x4b, 0x80, 0x3c, + 0x42, 0x26, 0xee, 0x29, 0xbe, 0x51, 0x23, 0x4e, 0x44, 0x05, 0x84, 0x45, + 0xa5, 0xd5, 0xf7, 0x97, 0x2e, 0xfd, 0x6b, 0x6a, 0x98, 0x09, 0xab, 0xc7, + 0xfc, 0x46, 0x3b, 0x4c, 0x26, 0x32, 0x30, 0x3e, 0x4f, 0x49, 0xd0, 0xfc, + 0xfb, 0x05, 0xd4, 0x4a, 0x7d, 0x40, 0xac, 0x3a, 0x8e, 0x84, 0x1c, 0xc5, + 0x96, 0x2a, 0x73, 0xe1, 0x9c, 0x16, 0x6d, 0xa5, 0x79, 0x86, 0xd6, 0xec, + 0x80, 0x5a, 0xa0, 0xf5, 0xca, 0xcc, 0x5c, 0xa1, 0x2b, 0x1b, 0x26, 0x30, + 0x6a, 0x31, 0x46, 0xcf, 0x1c, 0x87, 0x94, 0x64, 0x9e, 0x3d, 0xb6, 0xf0, + 0xca, 0xa8, 0x39, 0x51, 0x99, 0x42, 0x6b, 0x1a, 0xc5, 0xa5, 0xa5, 0x94, + 0xf7, 0x92, 0xc8, 0xaa, 0xb1, 0x23, 0x30, 0x04, 0xf8, 0x0e, 0x9f, 0x4e, + 0x4a, 0x11, 0xb2, 0xd5, 0x9b, 0x25, 0x06, 0x1b, 0xff, 0x00, 0x38, 0xfd, + 0xad, 0xdf, 0xda, 0xf9, 0xa2, 0xfe, 0xc5, 0x42, 0xbe, 0x9b, 0x7f, 0x0b, + 0xdd, 0xdd, 0x07, 0xaf, 0x14, 0x68, 0xd8, 0x71, 0x6d, 0xbb, 0x90, 0xfc, + 0x73, 0x6e, 0xf2, 0xf2, 0xdd, 0xf4, 0xad, 0xa6, 0xab, 0x6d, 0x69, 0x14, + 0xfa, 0xee, 0xa0, 0xe2, 0x0b, 0x0d, 0x39, 0x19, 0xfe, 0x11, 0xc5, 0x1a, + 0x4a, 0x1d, 0x8f, 0x73, 0x4f, 0xf8, 0x96, 0x0b, 0x40, 0x8d, 0xec, 0xf3, + 0x6d, 0x3f, 0x52, 0xba, 0xd6, 0x35, 0x8b, 0xbf, 0x36, 0x6a, 0x5f, 0x0d, + 0xc5, 0xdc, 0xa8, 0xb6, 0xa8, 0x7a, 0xc5, 0x6c, 0x9b, 0x22, 0x0f, 0xa3, + 0x73, 0x9a, 0xbc, 0xb3, 0xe2, 0x36, 0xed, 0xb1, 0x43, 0x80, 0x53, 0xd0, + 0xa7, 0xd4, 0x44, 0xfa, 0x7a, 0xda, 0x83, 0xbd, 0x3e, 0x2f, 0xa7, 0x2b, + 0xad, 0x9b, 0xb8, 0x8d, 0xa8, 0xe8, 0x91, 0xdb, 0xfa, 0x2d, 0x6f, 0xc3, + 0x8a, 0x2d, 0x56, 0xa3, 0xad, 0x4f, 0x5c, 0xa4, 0x0d, 0xdc, 0xa3, 0xca, + 0xd0, 0xbf, 0xa1, 0xe3, 0xfa, 0xe7, 0x0f, 0xf2, 0xb9, 0x57, 0xbf, 0x1a, + 0xe4, 0xb8, 0x57, 0xc5, 0xdd, 0xff, 0xd3, 0xf0, 0xcc, 0x5d, 0x7b, 0x70, + 0xc5, 0x53, 0x6d, 0x2f, 0xd5, 0xe4, 0x69, 0xfd, 0xdf, 0xec, 0xd7, 0xad, + 0x7d, 0xb2, 0x8c, 0x8d, 0xd8, 0xed, 0x91, 0x9f, 0x43, 0xea, 0xe7, 0xeb, + 0x94, 0xad, 0x3e, 0x1e, 0x95, 0xfc, 0x72, 0x81, 0x7d, 0x1c, 0x9d, 0xba, + 0xb1, 0x7b, 0xdf, 0xa9, 0x7a, 0xdf, 0xee, 0x2f, 0xd4, 0xfa, 0xe7, 0xed, + 0x7a, 0x7f, 0xdd, 0xff, 0x00, 0xb2, 0xae, 0x64, 0x0b, 0xea, 0xe3, 0x9a, + 0xbf, 0x4a, 0x6f, 0xa4, 0xff, 0x00, 0x89, 0xbd, 0x45, 0xfa, 0xb5, 0x79, + 0xf7, 0xeb, 0xc7, 0xe9, 0xae, 0x57, 0x2e, 0x17, 0x23, 0x1f, 0x89, 0xd1, + 0x99, 0x8f, 0xf1, 0xa7, 0x11, 0xcf, 0xd3, 0xf5, 0x29, 0xb5, 0x6b, 0xd3, + 0xe8, 0xcc, 0x7f, 0x45, 0xb9, 0xa3, 0xc5, 0x62, 0xbe, 0x68, 0xff, 0x00, + 0x15, 0xfd, 0x4c, 0xfe, 0x90, 0xaf, 0xd4, 0xab, 0xf1, 0x7a, 0x7f, 0x62, + 0x9d, 0xab, 0xdf, 0x32, 0xb1, 0x70, 0x5e, 0xdc, 0xdc, 0x2d, 0x47, 0x8b, + 0x5e, 0xae, 0x4c, 0xbf, 0xf2, 0x37, 0x9f, 0x3d, 0x5b, 0xd2, 0xff, 0x00, + 0x8e, 0x87, 0xee, 0x29, 0x5a, 0xf2, 0xf4, 0xaa, 0xd4, 0xa5, 0x36, 0xa7, + 0x3a, 0x57, 0xfd, 0x8e, 0x64, 0x3a, 0xf2, 0xf6, 0xbf, 0xcc, 0x7f, 0x5b, + 0xfc, 0x23, 0xa7, 0xfe, 0x8e, 0xff, 0x00, 0x8e, 0x37, 0xd6, 0x63, 0xfa, + 0xe5, 0x2b, 0xcb, 0x87, 0xec, 0xd6, 0xbd, 0xb9, 0x7d, 0xac, 0xc7, 0xcd, + 0x7c, 0x2d, 0xf8, 0x2b, 0x89, 0x26, 0x8f, 0xd4, 0xfa, 0x94, 0x3e, 0x85, + 0x29, 0xc9, 0x69, 0xfc, 0x33, 0x58, 0x5d, 0x9c, 0x79, 0xb2, 0xbb, 0x0f, + 0xac, 0x7a, 0x2b, 0xea, 0x75, 0xef, 0x92, 0x0c, 0x53, 0x3d, 0x2f, 0xd4, + 0xfa, 0xbb, 0xfa, 0x74, 0xf5, 0x39, 0x9a, 0xd7, 0xe7, 0x80, 0x53, 0x79, + 0xba, 0x5b, 0xfe, 0x97, 0xfa, 0x4b, 0xfc, 0xba, 0x7f, 0xb1, 0xc7, 0xab, + 0x1e, 0x8f, 0xff, 0xd9}; #endif // RTC_BASE_TESTBASE64_H_ diff --git a/rtc_base/testclient.cc b/rtc_base/testclient.cc index 585db77785..1df7c089ed 100644 --- a/rtc_base/testclient.cc +++ b/rtc_base/testclient.cc @@ -49,7 +49,8 @@ int TestClient::Send(const char* buf, size_t size) { return socket_->Send(buf, size, options); } -int TestClient::SendTo(const char* buf, size_t size, +int TestClient::SendTo(const char* buf, + size_t size, const SocketAddress& dest) { rtc::PacketOptions options; return socket_->SendTo(buf, size, dest, options); @@ -89,7 +90,8 @@ std::unique_ptr TestClient::NextPacket(int timeout_ms) { return packet; } -bool TestClient::CheckNextPacket(const char* buf, size_t size, +bool TestClient::CheckNextPacket(const char* buf, + size_t size, SocketAddress* addr) { bool res = false; std::unique_ptr packet = NextPacket(kTimeoutMs); @@ -138,8 +140,10 @@ int TestClient::SetOption(Socket::Option opt, int value) { return socket_->SetOption(opt, value); } -void TestClient::OnPacket(AsyncPacketSocket* socket, const char* buf, - size_t size, const SocketAddress& remote_addr, +void TestClient::OnPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, + const SocketAddress& remote_addr, const PacketTime& packet_time) { CritScope cs(&crit_); packets_.push_back(MakeUnique(remote_addr, buf, size, packet_time)); diff --git a/rtc_base/testclient.h b/rtc_base/testclient.h index c0dbe65bc8..a0d98b30d1 100644 --- a/rtc_base/testclient.h +++ b/rtc_base/testclient.h @@ -34,7 +34,7 @@ class TestClient : public sigslot::has_slots<> { virtual ~Packet(); SocketAddress addr; - char* buf; + char* buf; size_t size; PacketTime packet_time; }; @@ -93,7 +93,9 @@ class TestClient : public sigslot::has_slots<> { // Workaround for the fact that AsyncPacketSocket::GetConnState doesn't exist. Socket::ConnState GetState(); // Slot for packets read on the socket. - void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t len, + void OnPacket(AsyncPacketSocket* socket, + const char* buf, + size_t len, const SocketAddress& remote_addr, const PacketTime& packet_time); void OnReadyToSend(AsyncPacketSocket* socket); diff --git a/rtc_base/testclient_unittest.cc b/rtc_base/testclient_unittest.cc index 1d1d3f21e9..dda1daecd5 100644 --- a/rtc_base/testclient_unittest.cc +++ b/rtc_base/testclient_unittest.cc @@ -31,9 +31,9 @@ using namespace rtc; } void TestUdpInternal(const SocketAddress& loopback) { - Thread *main = Thread::Current(); - AsyncSocket* socket = main->socketserver() - ->CreateAsyncSocket(loopback.family(), SOCK_DGRAM); + Thread* main = Thread::Current(); + AsyncSocket* socket = + main->socketserver()->CreateAsyncSocket(loopback.family(), SOCK_DGRAM); socket->Bind(loopback); TestClient client(MakeUnique(socket)); @@ -45,11 +45,11 @@ void TestUdpInternal(const SocketAddress& loopback) { } void TestTcpInternal(const SocketAddress& loopback) { - Thread *main = Thread::Current(); + Thread* main = Thread::Current(); TestEchoServer server(main, loopback); - AsyncSocket* socket = main->socketserver() - ->CreateAsyncSocket(loopback.family(), SOCK_STREAM); + AsyncSocket* socket = + main->socketserver()->CreateAsyncSocket(loopback.family(), SOCK_STREAM); std::unique_ptr tcp_socket = WrapUnique(AsyncTCPSocket::Create(socket, loopback, server.address())); ASSERT_TRUE(tcp_socket != nullptr); diff --git a/rtc_base/testechoserver.h b/rtc_base/testechoserver.h index 672dda0f18..5e714eb63d 100644 --- a/rtc_base/testechoserver.h +++ b/rtc_base/testechoserver.h @@ -40,7 +40,9 @@ class TestEchoServer : public sigslot::has_slots<> { client_sockets_.push_back(packet_socket); } } - void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size, + void OnPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, const SocketAddress& remote_addr, const PacketTime& packet_time) { rtc::PacketOptions options; diff --git a/rtc_base/testutils.h b/rtc_base/testutils.h index b0003847cb..2ab4a35956 100644 --- a/rtc_base/testutils.h +++ b/rtc_base/testutils.h @@ -37,8 +37,8 @@ using namespace rtc; // event. enum StreamSinkEvent { - SSE_OPEN = SE_OPEN, - SSE_READ = SE_READ, + SSE_OPEN = SE_OPEN, + SSE_READ = SE_READ, SSE_WRITE = SE_WRITE, SSE_CLOSE = SE_CLOSE, SSE_ERROR = 16 @@ -50,15 +50,17 @@ class StreamSink : public sigslot::has_slots<> { ~StreamSink() override; void Monitor(StreamInterface* stream) { - stream->SignalEvent.connect(this, &StreamSink::OnEvent); - events_.erase(stream); + stream->SignalEvent.connect(this, &StreamSink::OnEvent); + events_.erase(stream); } void Unmonitor(StreamInterface* stream) { - stream->SignalEvent.disconnect(this); - // In case you forgot to unmonitor a previous object with this address - events_.erase(stream); + stream->SignalEvent.disconnect(this); + // In case you forgot to unmonitor a previous object with this address + events_.erase(stream); } - bool Check(StreamInterface* stream, StreamSinkEvent event, bool reset = true) { + bool Check(StreamInterface* stream, + StreamSinkEvent event, + bool reset = true) { return DoCheck(stream, event, reset); } int Events(StreamInterface* stream, bool reset = true) { @@ -66,19 +68,19 @@ class StreamSink : public sigslot::has_slots<> { } void Monitor(AsyncSocket* socket) { - socket->SignalConnectEvent.connect(this, &StreamSink::OnConnectEvent); - socket->SignalReadEvent.connect(this, &StreamSink::OnReadEvent); - socket->SignalWriteEvent.connect(this, &StreamSink::OnWriteEvent); - socket->SignalCloseEvent.connect(this, &StreamSink::OnCloseEvent); - // In case you forgot to unmonitor a previous object with this address - events_.erase(socket); + socket->SignalConnectEvent.connect(this, &StreamSink::OnConnectEvent); + socket->SignalReadEvent.connect(this, &StreamSink::OnReadEvent); + socket->SignalWriteEvent.connect(this, &StreamSink::OnWriteEvent); + socket->SignalCloseEvent.connect(this, &StreamSink::OnCloseEvent); + // In case you forgot to unmonitor a previous object with this address + events_.erase(socket); } void Unmonitor(AsyncSocket* socket) { - socket->SignalConnectEvent.disconnect(this); - socket->SignalReadEvent.disconnect(this); - socket->SignalWriteEvent.disconnect(this); - socket->SignalCloseEvent.disconnect(this); - events_.erase(socket); + socket->SignalConnectEvent.disconnect(this); + socket->SignalReadEvent.disconnect(this); + socket->SignalWriteEvent.disconnect(this); + socket->SignalCloseEvent.disconnect(this); + events_.erase(socket); } bool Check(AsyncSocket* socket, StreamSinkEvent event, bool reset = true) { return DoCheck(socket, event, reset); @@ -88,7 +90,7 @@ class StreamSink : public sigslot::has_slots<> { } private: - typedef std::map EventMap; + typedef std::map EventMap; void OnEvent(StreamInterface* stream, int events, int error) { if (error) { @@ -96,15 +98,9 @@ class StreamSink : public sigslot::has_slots<> { } AddEvents(stream, events); } - void OnConnectEvent(AsyncSocket* socket) { - AddEvents(socket, SSE_OPEN); - } - void OnReadEvent(AsyncSocket* socket) { - AddEvents(socket, SSE_READ); - } - void OnWriteEvent(AsyncSocket* socket) { - AddEvents(socket, SSE_WRITE); - } + void OnConnectEvent(AsyncSocket* socket) { AddEvents(socket, SSE_OPEN); } + void OnReadEvent(AsyncSocket* socket) { AddEvents(socket, SSE_READ); } + void OnWriteEvent(AsyncSocket* socket) { AddEvents(socket, SSE_WRITE); } void OnCloseEvent(AsyncSocket* socket, int error) { AddEvents(socket, (0 == error) ? SSE_CLOSE : SSE_ERROR); } @@ -147,25 +143,24 @@ class StreamSink : public sigslot::has_slots<> { /////////////////////////////////////////////////////////////////////////////// class StreamSource : public StreamInterface { -public: - StreamSource(); - ~StreamSource() override; + public: + StreamSource(); + ~StreamSource() override; - void Clear() { - readable_data_.clear(); - written_data_.clear(); - state_ = SS_CLOSED; - read_block_ = 0; - write_block_ = SIZE_UNKNOWN; - } - void QueueString(const char* data) { - QueueData(data, strlen(data)); + void Clear() { + readable_data_.clear(); + written_data_.clear(); + state_ = SS_CLOSED; + read_block_ = 0; + write_block_ = SIZE_UNKNOWN; } + void QueueString(const char* data) { QueueData(data, strlen(data)); } #if defined(__GNUC__) // Note: Implicit |this| argument counts as the first argument. __attribute__((__format__(__printf__, 2, 3))) #endif - void QueueStringF(const char* format, ...) { + void + QueueStringF(const char* format, ...) { va_list args; va_start(args, format); char buffer[1024]; diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 50ff4da43d..3579a45720 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -67,8 +67,8 @@ ThreadManager::ThreadManager() : main_thread_ref_(CurrentThreadRef()) { } #endif -Thread *ThreadManager::CurrentThread() { - return static_cast(pthread_getspecific(key_)); +Thread* ThreadManager::CurrentThread() { + return static_cast(pthread_getspecific(key_)); } void ThreadManager::SetCurrentThread(Thread* thread) { @@ -83,20 +83,19 @@ void ThreadManager::SetCurrentThread(Thread* thread) { #if defined(WEBRTC_WIN) ThreadManager::ThreadManager() - : key_(TlsAlloc()), main_thread_ref_(CurrentThreadRef()) { + : key_(TlsAlloc()), main_thread_ref_(CurrentThreadRef()) {} + +Thread* ThreadManager::CurrentThread() { + return static_cast(TlsGetValue(key_)); } -Thread *ThreadManager::CurrentThread() { - return static_cast(TlsGetValue(key_)); -} - -void ThreadManager::SetCurrentThread(Thread *thread) { +void ThreadManager::SetCurrentThread(Thread* thread) { RTC_DCHECK(!CurrentThread() || !thread); TlsSetValue(key_, thread); } #endif -Thread *ThreadManager::WrapCurrentThread() { +Thread* ThreadManager::WrapCurrentThread() { Thread* result = CurrentThread(); if (nullptr == result) { result = new Thread(SocketServer::CreateDefault()); @@ -118,9 +117,8 @@ bool ThreadManager::IsMainThread() { } Thread::ScopedDisallowBlockingCalls::ScopedDisallowBlockingCalls() - : thread_(Thread::Current()), - previous_state_(thread_->SetAllowBlockingCalls(false)) { -} + : thread_(Thread::Current()), + previous_state_(thread_->SetAllowBlockingCalls(false)) {} Thread::ScopedDisallowBlockingCalls::~ScopedDisallowBlockingCalls() { RTC_DCHECK(thread_->IsCurrent()); @@ -363,7 +361,7 @@ void Thread::Send(const Location& posted_from, AssertBlockingIsAllowedOnCurrentThread(); AutoThread thread; - Thread *current_thread = Thread::Current(); + Thread* current_thread = Thread::Current(); RTC_DCHECK(current_thread != nullptr); // AutoThread ensures this bool ready = false; diff --git a/rtc_base/thread.h b/rtc_base/thread.h index 568764e65b..0408a0d4d0 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h @@ -56,7 +56,7 @@ class ThreadManager { // shame to break it. It is also conceivable on Win32 that we won't even // be able to get synchronization privileges, in which case the result // will have a null handle. - Thread *WrapCurrentThread(); + Thread* WrapCurrentThread(); void UnwrapCurrentThread(); bool IsMainThread(); @@ -81,9 +81,9 @@ class ThreadManager { struct _SendMessage { _SendMessage() {} - Thread *thread; + Thread* thread; Message msg; - bool *ready; + bool* ready; }; class Runnable { @@ -135,6 +135,7 @@ class RTC_LOCKABLE Thread : public MessageQueue { public: ScopedDisallowBlockingCalls(); ~ScopedDisallowBlockingCalls(); + private: Thread* const thread_; const bool previous_state_; @@ -249,7 +250,7 @@ class RTC_LOCKABLE Thread : public MessageQueue { #if defined(WEBRTC_WIN) static DWORD WINAPI PreRun(LPVOID context); #else - static void *PreRun(void *pv); + static void* PreRun(void* pv); #endif // ThreadManager calls this instead WrapCurrent() because @@ -278,8 +279,8 @@ class RTC_LOCKABLE Thread : public MessageQueue { std::list<_SendMessage> sendlist_; std::string name_; - // TODO(tommi): Add thread checks for proper use of control methods. - // Ideally we should be able to just use PlatformThread. +// TODO(tommi): Add thread checks for proper use of control methods. +// Ideally we should be able to just use PlatformThread. #if defined(WEBRTC_POSIX) pthread_t thread_ = 0; diff --git a/rtc_base/thread_annotations_unittest.cc b/rtc_base/thread_annotations_unittest.cc index d8a4af1ac3..949f042afa 100644 --- a/rtc_base/thread_annotations_unittest.cc +++ b/rtc_base/thread_annotations_unittest.cc @@ -32,13 +32,9 @@ class RTC_SCOPED_LOCKABLE ScopeLock { class ThreadSafe { public: - ThreadSafe() { - pt_protected_by_lock_ = new int; - } + ThreadSafe() { pt_protected_by_lock_ = new int; } - ~ThreadSafe() { - delete pt_protected_by_lock_; - } + ~ThreadSafe() { delete pt_protected_by_lock_; } void LockInOrder() { beforelock_.EnterWrite(); diff --git a/rtc_base/thread_checker.h b/rtc_base/thread_checker.h index cc03b8d9b0..ad0450871a 100644 --- a/rtc_base/thread_checker.h +++ b/rtc_base/thread_checker.h @@ -32,9 +32,7 @@ namespace rtc { // right version for your build configuration. class ThreadCheckerDoNothing { public: - bool CalledOnValidThread() const { - return true; - } + bool CalledOnValidThread() const { return true; } void DetachFromThread() {} }; @@ -86,7 +84,7 @@ class RTC_SCOPED_LOCKABLE AnnounceOnThread { RTC_EXCLUSIVE_LOCK_FUNCTION(thread_like_object) {} ~AnnounceOnThread() RTC_UNLOCK_FUNCTION() {} - template + template static bool IsCurrent(const ThreadLikeObject* thread_like_object) { return thread_like_object->IsCurrent(); } @@ -163,9 +161,10 @@ class RTC_SCOPED_LOCKABLE AnnounceOnThread { // } // Document if a function expected to be called from same thread/task queue. -#define RTC_RUN_ON(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(x)) +#define RTC_RUN_ON(x) \ + RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(x)) -#define RTC_DCHECK_RUN_ON(thread_like_object) \ +#define RTC_DCHECK_RUN_ON(thread_like_object) \ rtc::internal::AnnounceOnThread thread_announcer(thread_like_object); \ RTC_DCHECK(rtc::internal::AnnounceOnThread::IsCurrent(thread_like_object)) diff --git a/rtc_base/thread_checker_impl.cc b/rtc_base/thread_checker_impl.cc index 850f2ac3cf..a9e87c67a0 100644 --- a/rtc_base/thread_checker_impl.cc +++ b/rtc_base/thread_checker_impl.cc @@ -14,11 +14,9 @@ namespace rtc { -ThreadCheckerImpl::ThreadCheckerImpl() : valid_thread_(CurrentThreadRef()) { -} +ThreadCheckerImpl::ThreadCheckerImpl() : valid_thread_(CurrentThreadRef()) {} -ThreadCheckerImpl::~ThreadCheckerImpl() { -} +ThreadCheckerImpl::~ThreadCheckerImpl() {} bool ThreadCheckerImpl::CalledOnValidThread() const { const PlatformThreadRef current_thread = CurrentThreadRef(); diff --git a/rtc_base/thread_checker_unittest.cc b/rtc_base/thread_checker_unittest.cc index ba5ac9e008..9c0942f884 100644 --- a/rtc_base/thread_checker_unittest.cc +++ b/rtc_base/thread_checker_unittest.cc @@ -38,9 +38,7 @@ class ThreadCheckerClass : public ThreadChecker { // Verifies that it was called on the same thread as the constructor. void DoStuff() { RTC_DCHECK(CalledOnValidThread()); } - void DetachFromThread() { - ThreadChecker::DetachFromThread(); - } + void DetachFromThread() { ThreadChecker::DetachFromThread(); } static void MethodOnDifferentThreadImpl(); static void DetachThenCallFromDifferentThreadImpl(); @@ -62,9 +60,7 @@ class CallDoStuffOnThread : public Thread { // New method. Needed since Thread::Join is protected, and it is called by // the TEST. - void Join() { - Thread::Join(); - } + void Join() { Thread::Join(); } private: ThreadCheckerClass* thread_checker_class_; @@ -86,9 +82,7 @@ class DeleteThreadCheckerClassOnThread : public Thread { // New method. Needed since Thread::Join is protected, and it is called by // the TEST. - void Join() { - Thread::Join(); - } + void Join() { Thread::Join(); } bool has_been_deleted() const { return !thread_checker_class_; } @@ -157,9 +151,7 @@ void ThreadCheckerClass::MethodOnDifferentThreadImpl() { #if ENABLE_THREAD_CHECKER TEST(ThreadCheckerDeathTest, MethodNotAllowedOnDifferentThreadInDebug) { - ASSERT_DEATH({ - ThreadCheckerClass::MethodOnDifferentThreadImpl(); - }, ""); + ASSERT_DEATH({ ThreadCheckerClass::MethodOnDifferentThreadImpl(); }, ""); } #else TEST(ThreadCheckerTest, MethodAllowedOnDifferentThreadInRelease) { @@ -186,9 +178,8 @@ void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() { #if ENABLE_THREAD_CHECKER TEST(ThreadCheckerDeathTest, DetachFromThreadInDebug) { - ASSERT_DEATH({ - ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl(); - }, ""); + ASSERT_DEATH({ ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl(); }, + ""); } #else TEST(ThreadCheckerTest, DetachFromThreadInRelease) { @@ -204,12 +195,12 @@ class ThreadAnnotateTest { // specific T). // TODO(danilchap): Find a way to test they do not compile when thread // annotation checks enabled. - template + template void access_var_no_annotate() { var_thread_ = 42; } - template + template void access_fun_no_annotate() { function(); } diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc index 01022e9823..74f62eb288 100644 --- a/rtc_base/thread_unittest.cc +++ b/rtc_base/thread_unittest.cc @@ -51,8 +51,10 @@ struct TestMessage : public MessageData { // Receives on a socket and sends by posting messages. class SocketClient : public TestGenerator, public sigslot::has_slots<> { public: - SocketClient(AsyncSocket* socket, const SocketAddress& addr, - Thread* post_thread, MessageHandler* phandler) + SocketClient(AsyncSocket* socket, + const SocketAddress& addr, + Thread* post_thread, + MessageHandler* phandler) : socket_(AsyncUDPSocket::Create(socket, addr)), post_thread_(post_thread), post_handler_(phandler) { @@ -63,7 +65,9 @@ class SocketClient : public TestGenerator, public sigslot::has_slots<> { SocketAddress address() const { return socket_->GetLocalAddress(); } - void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size, + void OnPacket(AsyncPacketSocket* socket, + const char* buf, + size_t size, const SocketAddress& remote_addr, const PacketTime& packet_time) { EXPECT_EQ(size, sizeof(uint32_t)); @@ -83,9 +87,7 @@ class SocketClient : public TestGenerator, public sigslot::has_slots<> { // Receives messages and sends on a socket. class MessageClient : public MessageHandler, public TestGenerator { public: - MessageClient(Thread* pth, Socket* socket) - : socket_(socket) { - } + MessageClient(Thread* pth, Socket* socket) : socket_(socket) {} ~MessageClient() override { delete socket_; } @@ -107,15 +109,10 @@ class CustomThread : public rtc::Thread { ~CustomThread() override { Stop(); } bool Start() { return false; } - bool WrapCurrent() { - return Thread::WrapCurrent(); - } - void UnwrapCurrent() { - Thread::UnwrapCurrent(); - } + bool WrapCurrent() { return Thread::WrapCurrent(); } + void UnwrapCurrent() { Thread::UnwrapCurrent(); } }; - // A thread that does nothing when it runs and signals an event // when it is destroyed. class SignalWhenDestroyedThread : public Thread { @@ -176,7 +173,11 @@ struct FunctorA { class FunctorB { public: explicit FunctorB(AtomicBool* flag) : flag_(flag) {} - void operator()() { if (flag_) *flag_ = true; } + void operator()() { + if (flag_) + *flag_ = true; + } + private: AtomicBool* flag_; }; @@ -191,7 +192,11 @@ struct FunctorD { explicit FunctorD(AtomicBool* flag) : flag_(flag) {} FunctorD(FunctorD&&) = default; FunctorD& operator=(FunctorD&&) = default; - void operator()() { if (flag_) *flag_ = true; } + void operator()() { + if (flag_) + *flag_ = true; + } + private: AtomicBool* flag_; RTC_DISALLOW_COPY_AND_ASSIGN(FunctorD); @@ -431,9 +436,7 @@ class AsyncInvokeTest : public testing::Test { protected: enum { kWaitTimeout = 1000 }; - AsyncInvokeTest() - : int_value_(0), - expected_thread_(nullptr) {} + AsyncInvokeTest() : int_value_(0), expected_thread_(nullptr) {} int int_value_; Thread* expected_thread_; @@ -580,9 +583,7 @@ class GuardedAsyncInvokeTest : public testing::Test { protected: const static int kWaitTimeout = 1000; - GuardedAsyncInvokeTest() - : int_value_(0), - expected_thread_(nullptr) {} + GuardedAsyncInvokeTest() : int_value_(0), expected_thread_(nullptr) {} int int_value_; Thread* expected_thread_; diff --git a/rtc_base/timeutils.cc b/rtc_base/timeutils.cc index 35c25c762c..f195f2ed9f 100644 --- a/rtc_base/timeutils.cc +++ b/rtc_base/timeutils.cc @@ -21,9 +21,13 @@ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif +// clang-format off +// clang formatting would put last, +// which leads to compilation failure. #include #include #include +// clang-format on #endif #include "rtc_base/checks.h" @@ -164,8 +168,8 @@ int64_t TmToSeconds(const std::tm& tm) { int min = tm.tm_min; int sec = tm.tm_sec; - bool expiry_in_leap_year = (year % 4 == 0 && - (year % 100 != 0 || year % 400 == 0)); + bool expiry_in_leap_year = + (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (year < 1970) return -1; @@ -188,13 +192,15 @@ int64_t TmToSeconds(const std::tm& tm) { // We will have added one day too much above if expiration is during a leap // year, and expiration is in January or February. - if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. + if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. day -= 1; // Combine all variables into seconds from 1970-01-01 00:00 (except |month| // which was accumulated into |day| above). - return (((static_cast - (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; + return (((static_cast(year - 1970) * 365 + day) * 24 + hour) * 60 + + min) * + 60 + + sec; } int64_t TimeUTCMicros() { @@ -214,4 +220,4 @@ int64_t TimeUTCMicros() { #endif } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/timeutils.h b/rtc_base/timeutils.h index 5eb73c70ac..48b5c8d12f 100644 --- a/rtc_base/timeutils.h +++ b/rtc_base/timeutils.h @@ -80,7 +80,6 @@ int64_t TimeMicros(); // Returns the current time in nanoseconds. int64_t TimeNanos(); - // Returns a future timestamp, 'elapsed' milliseconds from now. int64_t TimeAfter(int64_t elapsed); diff --git a/rtc_base/timeutils_unittest.cc b/rtc_base/timeutils_unittest.cc index 7b393a663c..0e1949aee3 100644 --- a/rtc_base/timeutils_unittest.cc +++ b/rtc_base/timeutils_unittest.cc @@ -33,7 +33,7 @@ TEST(TimeTest, Intervals) { // We can't depend on ts_later and ts_earlier to be exactly 500 apart // since time elapses between the calls to TimeMillis() and TimeAfter(500) - EXPECT_LE(500, TimeDiff(ts_later, ts_earlier)); + EXPECT_LE(500, TimeDiff(ts_later, ts_earlier)); EXPECT_GE(-500, TimeDiff(ts_earlier, ts_later)); // Time has elapsed since ts_earlier @@ -125,7 +125,6 @@ class TmToSeconds : public testing::Test { void TestTmToSeconds(int times) { static char mdays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 0; i < times; i++) { - // First generate something correct and check that TmToSeconds is happy. int year = rtc::CreateRandomId() % 400 + 1970; diff --git a/rtc_base/transformadapter.cc b/rtc_base/transformadapter.cc index 943a5b9672..0f9c66d041 100644 --- a/rtc_base/transformadapter.cc +++ b/rtc_base/transformadapter.cc @@ -18,21 +18,24 @@ namespace rtc { /////////////////////////////////////////////////////////////////////////////// -TransformAdapter::TransformAdapter(StreamInterface * stream, - TransformInterface * transform, +TransformAdapter::TransformAdapter(StreamInterface* stream, + TransformInterface* transform, bool direction_read) - : StreamAdapterInterface(stream), transform_(transform), - direction_read_(direction_read), state_(ST_PROCESSING), len_(0) { -} + : StreamAdapterInterface(stream), + transform_(transform), + direction_read_(direction_read), + state_(ST_PROCESSING), + len_(0) {} TransformAdapter::~TransformAdapter() { TransformAdapter::Close(); delete transform_; } -StreamResult -TransformAdapter::Read(void * buffer, size_t buffer_len, - size_t * read, int * error) { +StreamResult TransformAdapter::Read(void* buffer, + size_t buffer_len, + size_t* read, + int* error) { if (!direction_read_) return SR_EOS; @@ -44,10 +47,7 @@ TransformAdapter::Read(void * buffer, size_t buffer_len, if ((state_ == ST_PROCESSING) && (len_ < sizeof(buffer_))) { size_t subread; StreamResult result = StreamAdapterInterface::Read( - buffer_ + len_, - sizeof(buffer_) - len_, - &subread, - &error_); + buffer_ + len_, sizeof(buffer_) - len_, &subread, &error_); if (result == SR_BLOCK) { return SR_BLOCK; } else if (result == SR_ERROR) { @@ -63,21 +63,20 @@ TransformAdapter::Read(void * buffer, size_t buffer_len, // Process buffered data size_t in_len = len_; size_t out_len = buffer_len; - StreamResult result = transform_->Transform(buffer_, &in_len, - buffer, &out_len, - (state_ == ST_FLUSHING)); + StreamResult result = transform_->Transform( + buffer_, &in_len, buffer, &out_len, (state_ == ST_FLUSHING)); RTC_DCHECK(result != SR_BLOCK); if (result == SR_EOS) { // Note: Don't signal SR_EOS this iteration, unless out_len is zero state_ = ST_COMPLETE; } else if (result == SR_ERROR) { state_ = ST_ERROR; - error_ = -1; // TODO: propagate error + error_ = -1; // TODO: propagate error break; } else if ((out_len == 0) && (state_ == ST_FLUSHING)) { // If there is no output AND no more input, then something is wrong state_ = ST_ERROR; - error_ = -1; // TODO: better error code? + error_ = -1; // TODO: better error code? break; } @@ -98,9 +97,10 @@ TransformAdapter::Read(void * buffer, size_t buffer_len, return SR_ERROR; } -StreamResult -TransformAdapter::Write(const void * data, size_t data_len, - size_t * written, int * error) { +StreamResult TransformAdapter::Write(const void* data, + size_t data_len, + size_t* written, + int* error) { if (direction_read_) return SR_EOS; @@ -113,9 +113,8 @@ TransformAdapter::Write(const void * data, size_t data_len, // Process buffered data size_t in_len = data_len; size_t out_len = sizeof(buffer_) - len_; - StreamResult result = transform_->Transform(data, &in_len, - buffer_ + len_, &out_len, - (state_ == ST_FLUSHING)); + StreamResult result = transform_->Transform( + data, &in_len, buffer_ + len_, &out_len, (state_ == ST_FLUSHING)); RTC_DCHECK(result != SR_BLOCK); if (result == SR_EOS) { @@ -124,7 +123,7 @@ TransformAdapter::Write(const void * data, size_t data_len, } else if (result == SR_ERROR) { RTC_NOTREACHED(); // When this happens, think about what should be done state_ = ST_ERROR; - error_ = -1; // TODO: propagate error + error_ = -1; // TODO: propagate error break; } @@ -135,10 +134,8 @@ TransformAdapter::Write(const void * data, size_t data_len, size_t pos = 0; while (pos < len_) { size_t subwritten; - StreamResult result = StreamAdapterInterface::Write(buffer_ + pos, - len_ - pos, - &subwritten, - &error_); + StreamResult result = StreamAdapterInterface::Write( + buffer_ + pos, len_ - pos, &subwritten, &error_); if (result == SR_BLOCK) { RTC_NOTREACHED(); // We should handle this return SR_BLOCK; @@ -170,8 +167,7 @@ TransformAdapter::Write(const void * data, size_t data_len, return SR_ERROR; } -void -TransformAdapter::Close() { +void TransformAdapter::Close() { if (!direction_read_ && (state_ == ST_PROCESSING)) { state_ = ST_FLUSHING; do { @@ -194,4 +190,4 @@ bool TransformAdapter::Rewind() { return false; } -} // namespace rtc +} // namespace rtc diff --git a/rtc_base/transformadapter.h b/rtc_base/transformadapter.h index 5e8aa9a4aa..55f5a06a43 100644 --- a/rtc_base/transformadapter.h +++ b/rtc_base/transformadapter.h @@ -17,8 +17,8 @@ namespace rtc { /////////////////////////////////////////////////////////////////////////////// class TransformInterface { -public: - virtual ~TransformInterface() { } + public: + virtual ~TransformInterface() {} // Transform should convert the in_len bytes of input into the out_len-sized // output buffer. If flush is true, there will be no more data following @@ -27,8 +27,10 @@ public: // out_len contains the number of bytes ready in output. // Note: Transform should not return SR_BLOCK, as there is no asynchronous // notification available. - virtual StreamResult Transform(const void * input, size_t * in_len, - void * output, size_t * out_len, + virtual StreamResult Transform(const void* input, + size_t* in_len, + void* output, + size_t* out_len, bool flush) = 0; }; @@ -39,11 +41,11 @@ public: // etc. class TransformAdapter : public StreamAdapterInterface { -public: + public: // Note that the transformation is unidirectional, in the direction specified // by the constructor. Operations in the opposite direction result in SR_EOS. - TransformAdapter(StreamInterface * stream, - TransformInterface * transform, + TransformAdapter(StreamInterface* stream, + TransformInterface* transform, bool direction_read); ~TransformAdapter() override; @@ -64,11 +66,11 @@ public: // Transformations might not be restartable virtual bool Rewind(); -private: + private: enum State { ST_PROCESSING, ST_FLUSHING, ST_COMPLETE, ST_ERROR }; enum { BUFFER_SIZE = 1024 }; - TransformInterface * transform_; + TransformInterface* transform_; bool direction_read_; State state_; int error_; @@ -79,6 +81,6 @@ private: /////////////////////////////////////////////////////////////////////////////// -} // namespace rtc +} // namespace rtc -#endif // RTC_BASE_TRANSFORMADAPTER_H_ +#endif // RTC_BASE_TRANSFORMADAPTER_H_ diff --git a/rtc_base/type_traits.h b/rtc_base/type_traits.h index 4f004cda8b..0cb899c47f 100644 --- a/rtc_base/type_traits.h +++ b/rtc_base/type_traits.h @@ -133,7 +133,7 @@ static_assert(IsIntlike::value, ""); static_assert(!IsIntlike::value, ""); static_assert(!IsIntlike::value, ""); -} // test_enum_intlike +} // namespace test_enum_intlike } // namespace rtc diff --git a/rtc_base/unittest_main.cc b/rtc_base/unittest_main.cc index e32ca77185..df9622bd94 100644 --- a/rtc_base/unittest_main.cc +++ b/rtc_base/unittest_main.cc @@ -37,7 +37,8 @@ DEFINE_string( " will assign the group Enable to field trial WebRTC-FooFeature."); #if defined(WEBRTC_WIN) DEFINE_int(crt_break_alloc, -1, "memory allocation to break on"); -DEFINE_bool(default_error_handlers, false, +DEFINE_bool(default_error_handlers, + false, "leave the default exception/dbg handler functions in place"); void TestInvalidParameterHandler(const wchar_t* expression, @@ -90,7 +91,7 @@ int main(int argc, char* argv[]) { } #if !defined(NDEBUG) // Turn on memory leak checking on Windows. - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |_CRTDBG_LEAK_CHECK_DF); + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); if (FLAG_crt_break_alloc >= 0) { _crtBreakAlloc = FLAG_crt_break_alloc; } diff --git a/rtc_base/unixfilesystem.cc b/rtc_base/unixfilesystem.cc index a48aca1a33..023c34c8c9 100644 --- a/rtc_base/unixfilesystem.cc +++ b/rtc_base/unixfilesystem.cc @@ -57,7 +57,7 @@ UnixFilesystem::UnixFilesystem() {} UnixFilesystem::~UnixFilesystem() {} -bool UnixFilesystem::DeleteFile(const Pathname &filename) { +bool UnixFilesystem::DeleteFile(const Pathname& filename) { RTC_LOG(LS_INFO) << "Deleting file:" << filename.pathname(); if (!IsFile(filename)) { @@ -67,8 +67,8 @@ bool UnixFilesystem::DeleteFile(const Pathname &filename) { return ::unlink(filename.pathname().c_str()) == 0; } -bool UnixFilesystem::MoveFile(const Pathname &old_path, - const Pathname &new_path) { +bool UnixFilesystem::MoveFile(const Pathname& old_path, + const Pathname& new_path) { if (!IsFile(old_path)) { RTC_DCHECK(IsFile(old_path)); return false; @@ -81,7 +81,7 @@ bool UnixFilesystem::MoveFile(const Pathname &old_path, return true; } -bool UnixFilesystem::IsFolder(const Pathname &path) { +bool UnixFilesystem::IsFolder(const Pathname& path) { struct stat st; if (stat(path.pathname().c_str(), &st) < 0) return false; @@ -95,7 +95,7 @@ bool UnixFilesystem::IsFile(const Pathname& pathname) { return res == 0 && !S_ISDIR(st.st_mode); } -bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t *size) { +bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t* size) { struct stat st; if (::stat(pathname.pathname().c_str(), &st) != 0) return false; diff --git a/rtc_base/virtualsocket_unittest.cc b/rtc_base/virtualsocket_unittest.cc index 990692760b..34b227ebbb 100644 --- a/rtc_base/virtualsocket_unittest.cc +++ b/rtc_base/virtualsocket_unittest.cc @@ -100,7 +100,9 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> { ~Receiver() override { thread->Clear(this); } - void OnReadPacket(AsyncPacketSocket* s, const char* data, size_t size, + void OnReadPacket(AsyncPacketSocket* s, + const char* data, + size_t size, const SocketAddress& remote_addr, const PacketTime& packet_time) { ASSERT_EQ(socket.get(), s); @@ -282,7 +284,7 @@ class VirtualSocketServerTest : public testing::Test { // Attempt connect to listening socket EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); - EXPECT_NE(client->GetLocalAddress(), kEmptyAddr); // Implicit Bind + EXPECT_NE(client->GetLocalAddress(), kEmptyAddr); // Implicit Bind EXPECT_NE(AF_UNSPEC, client->GetLocalAddress().family()); // Implicit Bind EXPECT_NE(client->GetLocalAddress(), server->GetLocalAddress()); @@ -633,7 +635,7 @@ class VirtualSocketServerTest : public testing::Test { ss_.ProcessMessagesUntilIdle(); // First, deliver all packets in 0 ms. - char buffer[2] = { 0, 0 }; + char buffer[2] = {0, 0}; const char cNumPackets = 10; for (char i = 0; i < cNumPackets; ++i) { buffer[0] = '0' + i; @@ -937,105 +939,89 @@ TEST_F(VirtualSocketServerTest, delay_v6) { // Works, receiving socket sees 127.0.0.2. TEST_F(VirtualSocketServerTest, CanConnectFromMappedIPv6ToIPv4Any) { CrossFamilyConnectionTest(SocketAddress("::ffff:127.0.0.2", 0), - SocketAddress("0.0.0.0", 5000), - true); + SocketAddress("0.0.0.0", 5000), true); } // Fails. TEST_F(VirtualSocketServerTest, CantConnectFromUnMappedIPv6ToIPv4Any) { CrossFamilyConnectionTest(SocketAddress("::2", 0), - SocketAddress("0.0.0.0", 5000), - false); + SocketAddress("0.0.0.0", 5000), false); } // Fails. TEST_F(VirtualSocketServerTest, CantConnectFromUnMappedIPv6ToMappedIPv6) { CrossFamilyConnectionTest(SocketAddress("::2", 0), - SocketAddress("::ffff:127.0.0.1", 5000), - false); + SocketAddress("::ffff:127.0.0.1", 5000), false); } // Works. receiving socket sees ::ffff:127.0.0.2. TEST_F(VirtualSocketServerTest, CanConnectFromIPv4ToIPv6Any) { CrossFamilyConnectionTest(SocketAddress("127.0.0.2", 0), - SocketAddress("::", 5000), - true); + SocketAddress("::", 5000), true); } // Fails. TEST_F(VirtualSocketServerTest, CantConnectFromIPv4ToUnMappedIPv6) { CrossFamilyConnectionTest(SocketAddress("127.0.0.2", 0), - SocketAddress("::1", 5000), - false); + SocketAddress("::1", 5000), false); } // Works. Receiving socket sees ::ffff:127.0.0.1. TEST_F(VirtualSocketServerTest, CanConnectFromIPv4ToMappedIPv6) { CrossFamilyConnectionTest(SocketAddress("127.0.0.1", 0), - SocketAddress("::ffff:127.0.0.2", 5000), - true); + SocketAddress("::ffff:127.0.0.2", 5000), true); } // Works, receiving socket sees a result from GetNextIP. TEST_F(VirtualSocketServerTest, CanConnectFromUnboundIPv6ToIPv4Any) { CrossFamilyConnectionTest(SocketAddress("::", 0), - SocketAddress("0.0.0.0", 5000), - true); + SocketAddress("0.0.0.0", 5000), true); } // Works, receiving socket sees whatever GetNextIP gave the client. TEST_F(VirtualSocketServerTest, CanConnectFromUnboundIPv4ToIPv6Any) { CrossFamilyConnectionTest(SocketAddress("0.0.0.0", 0), - SocketAddress("::", 5000), - true); + SocketAddress("::", 5000), true); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromUnboundIPv4ToIPv6Any) { CrossFamilyDatagramTest(SocketAddress("0.0.0.0", 0), - SocketAddress("::", 5000), - true); + SocketAddress("::", 5000), true); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromMappedIPv6ToIPv4Any) { CrossFamilyDatagramTest(SocketAddress("::ffff:127.0.0.1", 0), - SocketAddress("0.0.0.0", 5000), - true); + SocketAddress("0.0.0.0", 5000), true); } TEST_F(VirtualSocketServerTest, CantSendDatagramFromUnMappedIPv6ToIPv4Any) { CrossFamilyDatagramTest(SocketAddress("::2", 0), - SocketAddress("0.0.0.0", 5000), - false); + SocketAddress("0.0.0.0", 5000), false); } TEST_F(VirtualSocketServerTest, CantSendDatagramFromUnMappedIPv6ToMappedIPv6) { CrossFamilyDatagramTest(SocketAddress("::2", 0), - SocketAddress("::ffff:127.0.0.1", 5000), - false); + SocketAddress("::ffff:127.0.0.1", 5000), false); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromIPv4ToIPv6Any) { CrossFamilyDatagramTest(SocketAddress("127.0.0.2", 0), - SocketAddress("::", 5000), - true); + SocketAddress("::", 5000), true); } TEST_F(VirtualSocketServerTest, CantSendDatagramFromIPv4ToUnMappedIPv6) { CrossFamilyDatagramTest(SocketAddress("127.0.0.2", 0), - SocketAddress("::1", 5000), - false); + SocketAddress("::1", 5000), false); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromIPv4ToMappedIPv6) { CrossFamilyDatagramTest(SocketAddress("127.0.0.1", 0), - SocketAddress("::ffff:127.0.0.2", 5000), - true); + SocketAddress("::ffff:127.0.0.2", 5000), true); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromUnboundIPv6ToIPv4Any) { CrossFamilyDatagramTest(SocketAddress("::", 0), - SocketAddress("0.0.0.0", 5000), - true); + SocketAddress("0.0.0.0", 5000), true); } TEST_F(VirtualSocketServerTest, SetSendingBlockedWithUdpSocket) { @@ -1104,7 +1090,7 @@ TEST_F(VirtualSocketServerTest, SetSendingBlockedWithTcpSocket) { TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { const uint32_t kTestMean[] = {10, 100, 333, 1000}; - const double kTestDev[] = { 0.25, 0.1, 0.01 }; + const double kTestDev[] = {0.25, 0.1, 0.01}; // TODO(deadbeef): The current code only works for 1000 data points or more. const uint32_t kTestSamples[] = {/*10, 100,*/ 1000}; for (size_t midx = 0; midx < arraysize(kTestMean); ++midx) { @@ -1114,8 +1100,7 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { const uint32_t kStdDev = static_cast(kTestDev[didx] * kTestMean[midx]); VirtualSocketServer::Function* f = - VirtualSocketServer::CreateDistribution(kTestMean[midx], - kStdDev, + VirtualSocketServer::CreateDistribution(kTestMean[midx], kStdDev, kTestSamples[sidx]); ASSERT_TRUE(nullptr != f); ASSERT_EQ(kTestSamples[sidx], f->size()); @@ -1131,13 +1116,11 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { } const double stddev = sqrt(sum_sq_dev / f->size()); EXPECT_NEAR(kTestMean[midx], mean, 0.1 * kTestMean[midx]) - << "M=" << kTestMean[midx] - << " SD=" << kStdDev - << " N=" << kTestSamples[sidx]; + << "M=" << kTestMean[midx] << " SD=" << kStdDev + << " N=" << kTestSamples[sidx]; EXPECT_NEAR(kStdDev, stddev, 0.1 * kStdDev) - << "M=" << kTestMean[midx] - << " SD=" << kStdDev - << " N=" << kTestSamples[sidx]; + << "M=" << kTestMean[midx] << " SD=" << kStdDev + << " N=" << kTestSamples[sidx]; delete f; } } diff --git a/rtc_base/virtualsocketserver.cc b/rtc_base/virtualsocketserver.cc index 55103e1789..53dad46fce 100644 --- a/rtc_base/virtualsocketserver.cc +++ b/rtc_base/virtualsocketserver.cc @@ -28,15 +28,14 @@ namespace rtc { #if defined(WEBRTC_WIN) -const in_addr kInitialNextIPv4 = { { { 0x01, 0, 0, 0 } } }; +const in_addr kInitialNextIPv4 = {{{0x01, 0, 0, 0}}}; #else // This value is entirely arbitrary, hence the lack of concern about endianness. -const in_addr kInitialNextIPv4 = { 0x01000000 }; +const in_addr kInitialNextIPv4 = {0x01000000}; #endif // Starts at ::2 so as to not cause confusion with ::1. -const in6_addr kInitialNextIPv6 = { { { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 - } } }; +const in6_addr kInitialNextIPv6 = { + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}}}; const uint16_t kFirstEphemeralPort = 49152; const uint16_t kLastEphemeralPort = 65535; @@ -65,15 +64,13 @@ enum { class Packet : public MessageData { public: Packet(const char* data, size_t size, const SocketAddress& from) - : size_(size), consumed_(0), from_(from) { + : size_(size), consumed_(0), from_(from) { RTC_DCHECK(nullptr != data); data_ = new char[size_]; memcpy(data_, data, size_); } - ~Packet() override { - delete[] data_; - } + ~Packet() override { delete[] data_; } const char* data() const { return data_ + consumed_; } size_t size() const { return size_ - consumed_; } @@ -92,7 +89,7 @@ class Packet : public MessageData { }; struct MessageAddress : public MessageData { - explicit MessageAddress(const SocketAddress& a) : addr(a) { } + explicit MessageAddress(const SocketAddress& a) : addr(a) {} SocketAddress addr; }; @@ -236,15 +233,15 @@ int VirtualSocket::Close() { } int VirtualSocket::Send(const void* pv, size_t cb) { - if (CS_CONNECTED != state_) { - error_ = ENOTCONN; - return -1; - } - if (SOCK_DGRAM == type_) { - return SendUdp(pv, cb, remote_addr_); - } else { - return SendTcp(pv, cb); - } + if (CS_CONNECTED != state_) { + error_ = ENOTCONN; + return -1; + } + if (SOCK_DGRAM == type_) { + return SendUdp(pv, cb, remote_addr_); + } else { + return SendTcp(pv, cb); + } } int VirtualSocket::SendTo(const void* pv, @@ -555,8 +552,7 @@ VirtualSocketServer::~VirtualSocketServer() { IPAddress VirtualSocketServer::GetNextIP(int family) { if (family == AF_INET) { IPAddress next_ip(next_ipv4_); - next_ipv4_.s_addr = - HostToNetwork32(NetworkToHost32(next_ipv4_.s_addr) + 1); + next_ipv4_.s_addr = HostToNetwork32(NetworkToHost32(next_ipv4_.s_addr) + 1); return next_ip; } else if (family == AF_INET6) { IPAddress next_ip(next_ipv6_); @@ -607,8 +603,8 @@ VirtualSocket* VirtualSocketServer::CreateSocketInternal(int family, int type) { void VirtualSocketServer::SetMessageQueue(MessageQueue* msg_queue) { msg_queue_ = msg_queue; if (msg_queue_) { - msg_queue_->SignalQueueDestroyed.connect(this, - &VirtualSocketServer::OnMessageQueueDestroyed); + msg_queue_->SignalQueueDestroyed.connect( + this, &VirtualSocketServer::OnMessageQueueDestroyed); } } @@ -721,8 +717,7 @@ int VirtualSocketServer::Bind(VirtualSocket* socket, SocketAddress* addr) { } VirtualSocket* VirtualSocketServer::LookupBinding(const SocketAddress& addr) { - SocketAddress normalized(addr.ipaddr().Normalized(), - addr.port()); + SocketAddress normalized(addr.ipaddr().Normalized(), addr.port()); AddressMap::iterator it = bindings_->find(normalized); if (it != bindings_->end()) { return it->second; @@ -744,8 +739,7 @@ VirtualSocket* VirtualSocketServer::LookupBinding(const SocketAddress& addr) { int VirtualSocketServer::Unbind(const SocketAddress& addr, VirtualSocket* socket) { - SocketAddress normalized(addr.ipaddr().Normalized(), - addr.port()); + SocketAddress normalized(addr.ipaddr().Normalized(), addr.port()); RTC_DCHECK((*bindings_)[normalized] == socket); bindings_->erase(bindings_->find(normalized)); return 0; @@ -756,22 +750,18 @@ void VirtualSocketServer::AddConnection(const SocketAddress& local, VirtualSocket* remote_socket) { // Add this socket pair to our routing table. This will allow // multiple clients to connect to the same server address. - SocketAddress local_normalized(local.ipaddr().Normalized(), - local.port()); - SocketAddress remote_normalized(remote.ipaddr().Normalized(), - remote.port()); + SocketAddress local_normalized(local.ipaddr().Normalized(), local.port()); + SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port()); SocketAddressPair address_pair(local_normalized, remote_normalized); - connections_->insert(std::pair(address_pair, remote_socket)); + connections_->insert(std::pair( + address_pair, remote_socket)); } VirtualSocket* VirtualSocketServer::LookupConnection( const SocketAddress& local, const SocketAddress& remote) { - SocketAddress local_normalized(local.ipaddr().Normalized(), - local.port()); - SocketAddress remote_normalized(remote.ipaddr().Normalized(), - remote.port()); + SocketAddress local_normalized(local.ipaddr().Normalized(), local.port()); + SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port()); SocketAddressPair address_pair(local_normalized, remote_normalized); ConnectionMap::iterator it = connections_->find(address_pair); return (connections_->end() != it) ? it->second : nullptr; @@ -779,10 +769,8 @@ VirtualSocket* VirtualSocketServer::LookupConnection( void VirtualSocketServer::RemoveConnection(const SocketAddress& local, const SocketAddress& remote) { - SocketAddress local_normalized(local.ipaddr().Normalized(), - local.port()); - SocketAddress remote_normalized(remote.ipaddr().Normalized(), - remote.port()); + SocketAddress local_normalized(local.ipaddr().Normalized(), local.port()); + SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port()); SocketAddressPair address_pair(local_normalized, remote_normalized); connections_->erase(address_pair); } @@ -826,7 +814,8 @@ bool VirtualSocketServer::Disconnect(VirtualSocket* socket) { } int VirtualSocketServer::SendUdp(VirtualSocket* socket, - const char* data, size_t data_size, + const char* data, + size_t data_size, const SocketAddress& remote_addr) { ++sent_packets_; if (sending_blocked_) { @@ -907,8 +896,8 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) { // is read from the recv_buffer. // Lookup the local/remote pair in the connections table. - VirtualSocket* recipient = LookupConnection(socket->local_addr_, - socket->remote_addr_); + VirtualSocket* recipient = + LookupConnection(socket->local_addr_, socket->remote_addr_); if (!recipient) { RTC_LOG(LS_VERBOSE) << "Sending data to no one."; return; @@ -1029,8 +1018,8 @@ void PrintFunction(std::vector >* f) { #endif // void VirtualSocketServer::UpdateDelayDistribution() { - Function* dist = CreateDistribution(delay_mean_, delay_stddev_, - delay_samples_); + Function* dist = + CreateDistribution(delay_mean_, delay_stddev_, delay_samples_); // We take a lock just to make sure we don't leak memory. { CritScope cs(&delay_crit_); @@ -1092,7 +1081,7 @@ uint32_t VirtualSocketServer::GetTransitDelay(Socket* socket) { struct FunctionDomainCmp { bool operator()(const VirtualSocketServer::Point& p1, - const VirtualSocketServer::Point& p2) { + const VirtualSocketServer::Point& p2) { return p1.first < p2.first; } bool operator()(double v1, const VirtualSocketServer::Point& p2) { @@ -1112,7 +1101,7 @@ VirtualSocketServer::Function* VirtualSocketServer::Accumulate(Function* f) { (*f)[i].second = v; v = v + dx * avgy; } - (*f)[f->size()-1].second = v; + (*f)[f->size() - 1].second = v; return f; } diff --git a/rtc_base/virtualsocketserver.h b/rtc_base/virtualsocketserver.h index d4c5410d95..4fa7d77a87 100644 --- a/rtc_base/virtualsocketserver.h +++ b/rtc_base/virtualsocketserver.h @@ -183,14 +183,17 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { const SocketAddress& server); // Connects the given socket to the socket at the given address - int Connect(VirtualSocket* socket, const SocketAddress& remote_addr, + int Connect(VirtualSocket* socket, + const SocketAddress& remote_addr, bool use_delay); // Sends a disconnect message to the socket at the given address bool Disconnect(VirtualSocket* socket); // Sends the given packet to the socket at the given address (if one exists). - int SendUdp(VirtualSocket* socket, const char* data, size_t data_size, + int SendUdp(VirtualSocket* socket, + const char* data, + size_t data_size, const SocketAddress& remote_addr); // Moves as much data as possible from the sender's buffer to the network diff --git a/rtc_base/weak_ptr.cc b/rtc_base/weak_ptr.cc index c76256a092..ad98c24611 100644 --- a/rtc_base/weak_ptr.cc +++ b/rtc_base/weak_ptr.cc @@ -51,8 +51,7 @@ bool WeakReference::is_valid() const { return flag_.get() && flag_->IsValid(); } -WeakReferenceOwner::WeakReferenceOwner() { -} +WeakReferenceOwner::WeakReferenceOwner() {} WeakReferenceOwner::~WeakReferenceOwner() { Invalidate(); diff --git a/rtc_base/win32.cc b/rtc_base/win32.cc index 86f8352ac5..d81d685f16 100644 --- a/rtc_base/win32.cc +++ b/rtc_base/win32.cc @@ -32,8 +32,10 @@ static int inet_pton_v6(const char* src, void* dst); // ip address). XP doesn't have its own inet_ntop, and // WSAAddressToString requires both IPv6 to be installed and for Winsock // to be initialized. -const char* win32_inet_ntop(int af, const void *src, - char* dst, socklen_t size) { +const char* win32_inet_ntop(int af, + const void* src, + char* dst, + socklen_t size) { if (!src || !dst) { return nullptr; } @@ -70,11 +72,9 @@ const char* inet_ntop_v4(const void* src, char* dst, socklen_t size) { } const struct in_addr* as_in_addr = reinterpret_cast(src); - rtc::sprintfn(dst, size, "%d.%d.%d.%d", - as_in_addr->S_un.S_un_b.s_b1, - as_in_addr->S_un.S_un_b.s_b2, - as_in_addr->S_un.S_un_b.s_b3, - as_in_addr->S_un.S_un_b.s_b4); + rtc::sprintfn(dst, size, "%d.%d.%d.%d", as_in_addr->S_un.S_un_b.s_b1, + as_in_addr->S_un.S_un_b.s_b2, as_in_addr->S_un.S_un_b.s_b3, + as_in_addr->S_un.S_un_b.s_b4); return dst; } @@ -122,8 +122,8 @@ const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { // Print IPv4 compatible and IPv4 mapped addresses using the IPv4 helper. // These addresses have an initial run of either eight zero-bytes followed // by 0xFFFF, or an initial run of ten zero-bytes. - if (runpos[0] == 1 && (maxpos == 5 || - (maxpos == 4 && as_shorts[5] == 0xFFFF))) { + if (runpos[0] == 1 && + (maxpos == 5 || (maxpos == 4 && as_shorts[5] == 0xFFFF))) { *cursor++ = ':'; *cursor++ = ':'; if (maxpos == 4) { @@ -136,9 +136,8 @@ const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { } else { for (int i = 0; i < run_array_size; ++i) { if (runpos[i] == -1) { - cursor += rtc::sprintfn(cursor, - INET6_ADDRSTRLEN - (cursor - dst), - "%x", NetworkToHost16(as_shorts[i])); + cursor += rtc::sprintfn(cursor, INET6_ADDRSTRLEN - (cursor - dst), "%x", + NetworkToHost16(as_shorts[i])); if (i != 7 && runpos[i + 1] != 1) { *cursor++ = ':'; } @@ -221,7 +220,7 @@ int inet_pton_v6(const char* src, void* dst) { // Addresses that start with "::" (i.e., a run of initial zeros) or // "::ffff:" can potentially be IPv4 mapped or compatibility addresses. // These have dotted-style IPv4 addresses on the end (e.g. "::192.168.7.1"). - if (*readcursor == ':' && *(readcursor+1) == ':' && + if (*readcursor == ':' && *(readcursor + 1) == ':' && *(readcursor + 2) != 0) { // Check for periods, which we'll take as a sign of v4 addresses. const char* addrstart = readcursor + 2; @@ -326,8 +325,8 @@ bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename) { } wchar_t* wfilename = STACK_ARRAY(wchar_t, wlen); if (0 == ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), - static_cast(utf8.length() + 1), - wfilename, wlen)) { + static_cast(utf8.length() + 1), wfilename, + wlen)) { return false; } // Replace forward slashes with backslashes @@ -368,9 +367,12 @@ bool GetOsVersion(int* major, int* minor, int* build) { OSVERSIONINFO info = {0}; info.dwOSVersionInfoSize = sizeof(info); if (GetVersionEx(&info)) { - if (major) *major = info.dwMajorVersion; - if (minor) *minor = info.dwMinorVersion; - if (build) *build = info.dwBuildNumber; + if (major) + *major = info.dwMajorVersion; + if (minor) + *minor = info.dwMinorVersion; + if (build) + *build = info.dwBuildNumber; return true; } return false; @@ -387,7 +389,6 @@ bool GetCurrentProcessIntegrityLevel(int* level) { TOKEN_MANDATORY_LABEL* til = reinterpret_cast(buf); if (GetTokenInformation(token, TokenIntegrityLevel, til, size, &size)) { - DWORD count = *GetSidSubAuthorityCount(til->Label.Sid); *level = *GetSidSubAuthority(til->Label.Sid, count - 1); ret = true; diff --git a/rtc_base/win32.h b/rtc_base/win32.h index b20f3f3268..c6bfb72083 100644 --- a/rtc_base/win32.h +++ b/rtc_base/win32.h @@ -24,17 +24,20 @@ #define NOMINMAX #endif -#include +// clang-format off +// clang formating would change include order. +#include // must come first #include +// clang-format on typedef int socklen_t; #ifndef SECURITY_MANDATORY_LABEL_AUTHORITY // Add defines that we use if we are compiling against older sdks -#define SECURITY_MANDATORY_MEDIUM_RID (0x00002000L) +#define SECURITY_MANDATORY_MEDIUM_RID (0x00002000L) #define TokenIntegrityLevel static_cast(0x19) typedef struct _TOKEN_MANDATORY_LABEL { - SID_AND_ATTRIBUTES Label; + SID_AND_ATTRIBUTES Label; } TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL; #endif // SECURITY_MANDATORY_LABEL_AUTHORITY @@ -44,8 +47,8 @@ typedef struct _TOKEN_MANDATORY_LABEL { namespace rtc { -const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size); -int win32_inet_pton(int af, const char* src, void *dst); +const char* win32_inet_ntop(int af, const void* src, char* dst, socklen_t size); +int win32_inet_pton(int af, const char* src, void* dst); // Convert a Utf8 path representation to a non-length-limited Unicode pathname. bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename); @@ -85,7 +88,7 @@ bool GetCurrentProcessIntegrityLevel(int* level); inline bool IsCurrentProcessLowIntegrity() { int level; return (GetCurrentProcessIntegrityLevel(&level) && - level < SECURITY_MANDATORY_MEDIUM_RID); + level < SECURITY_MANDATORY_MEDIUM_RID); } } // namespace rtc diff --git a/rtc_base/win32_unittest.cc b/rtc_base/win32_unittest.cc index 5ee3ff44cd..5691be46c8 100644 --- a/rtc_base/win32_unittest.cc +++ b/rtc_base/win32_unittest.cc @@ -22,8 +22,7 @@ namespace rtc { class Win32Test : public testing::Test { public: - Win32Test() { - } + Win32Test() {} }; TEST_F(Win32Test, IPv6AddressCompression) { diff --git a/rtc_base/win32filesystem.cc b/rtc_base/win32filesystem.cc index 8ca84c34bb..b500e5e629 100644 --- a/rtc_base/win32filesystem.cc +++ b/rtc_base/win32filesystem.cc @@ -33,7 +33,7 @@ namespace rtc { -bool Win32Filesystem::DeleteFile(const Pathname &filename) { +bool Win32Filesystem::DeleteFile(const Pathname& filename) { RTC_LOG(LS_INFO) << "Deleting file " << filename.pathname(); if (!IsFile(filename)) { RTC_DCHECK(IsFile(filename)); @@ -42,8 +42,8 @@ bool Win32Filesystem::DeleteFile(const Pathname &filename) { return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0; } -bool Win32Filesystem::MoveFile(const Pathname &old_path, - const Pathname &new_path) { +bool Win32Filesystem::MoveFile(const Pathname& old_path, + const Pathname& new_path) { if (!IsFile(old_path)) { RTC_DCHECK(IsFile(old_path)); return false; @@ -54,16 +54,16 @@ bool Win32Filesystem::MoveFile(const Pathname &old_path, ToUtf16(new_path.pathname()).c_str()) != 0; } -bool Win32Filesystem::IsFolder(const Pathname &path) { +bool Win32Filesystem::IsFolder(const Pathname& path) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (0 == ::GetFileAttributesEx(ToUtf16(path.pathname()).c_str(), GetFileExInfoStandard, &data)) return false; return (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == - FILE_ATTRIBUTE_DIRECTORY; + FILE_ATTRIBUTE_DIRECTORY; } -bool Win32Filesystem::IsFile(const Pathname &path) { +bool Win32Filesystem::IsFile(const Pathname& path) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (0 == ::GetFileAttributesEx(ToUtf16(path.pathname()).c_str(), GetFileExInfoStandard, &data)) @@ -71,11 +71,11 @@ bool Win32Filesystem::IsFile(const Pathname &path) { return (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; } -bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { +bool Win32Filesystem::GetFileSize(const Pathname& pathname, size_t* size) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), GetFileExInfoStandard, &data) == 0) - return false; + return false; *size = data.nFileSizeLow; return true; } diff --git a/rtc_base/win32socketinit.cc b/rtc_base/win32socketinit.cc index 5bf65468fa..ea0aae6054 100644 --- a/rtc_base/win32socketinit.cc +++ b/rtc_base/win32socketinit.cc @@ -34,9 +34,8 @@ class WinsockInitializer { if (!err_) WSACleanup(); } - int error() { - return err_; - } + int error() { return err_; } + private: int err_; }; diff --git a/rtc_base/win32socketserver.cc b/rtc_base/win32socketserver.cc index 7be7ffe2c9..cab751a631 100644 --- a/rtc_base/win32socketserver.cc +++ b/rtc_base/win32socketserver.cc @@ -10,8 +10,8 @@ #include "rtc_base/win32socketserver.h" -#include #include // NOLINT +#include #include "rtc_base/byteorder.h" #include "rtc_base/checks.h" @@ -26,7 +26,7 @@ namespace rtc { // TODO: Enable for production builds also? Use FormatMessage? #if !defined(NDEBUG) -LPCSTR WSAErrorToString(int error, LPCSTR *description_result) { +LPCSTR WSAErrorToString(int error, LPCSTR* description_result) { LPCSTR string = "Unspecified"; LPCSTR description = "Unspecified description"; switch (error) { @@ -107,8 +107,8 @@ void ReportWSAError(LPCSTR context, int error, const SocketAddress& address) {} // Win32Socket::EventSink ///////////////////////////////////////////////////////////////////////////// -#define WM_SOCKETNOTIFY (WM_USER + 50) -#define WM_DNSNOTIFY (WM_USER + 51) +#define WM_SOCKETNOTIFY (WM_USER + 50) +#define WM_DNSNOTIFY (WM_USER + 51) struct Win32Socket::DnsLookup { HANDLE handle; @@ -118,7 +118,7 @@ struct Win32Socket::DnsLookup { class Win32Socket::EventSink : public Win32Window { public: - explicit EventSink(Win32Socket * parent) : parent_(parent) { } + explicit EventSink(Win32Socket* parent) : parent_(parent) {} void Dispose(); @@ -132,7 +132,7 @@ class Win32Socket::EventSink : public Win32Window { bool OnSocketNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result); bool OnDnsNotify(WPARAM wParam, LPARAM lParam, LRESULT& result); - Win32Socket * parent_; + Win32Socket* parent_; }; void Win32Socket::EventSink::Dispose() { @@ -144,20 +144,24 @@ void Win32Socket::EventSink::Dispose() { } } -bool Win32Socket::EventSink::OnMessage(UINT uMsg, WPARAM wParam, - LPARAM lParam, LRESULT& result) { +bool Win32Socket::EventSink::OnMessage(UINT uMsg, + WPARAM wParam, + LPARAM lParam, + LRESULT& result) { switch (uMsg) { - case WM_SOCKETNOTIFY: - case WM_TIMER: - return OnSocketNotify(uMsg, wParam, lParam, result); - case WM_DNSNOTIFY: - return OnDnsNotify(wParam, lParam, result); + case WM_SOCKETNOTIFY: + case WM_TIMER: + return OnSocketNotify(uMsg, wParam, lParam, result); + case WM_DNSNOTIFY: + return OnDnsNotify(wParam, lParam, result); } return false; } -bool Win32Socket::EventSink::OnSocketNotify(UINT uMsg, WPARAM wParam, - LPARAM lParam, LRESULT& result) { +bool Win32Socket::EventSink::OnSocketNotify(UINT uMsg, + WPARAM wParam, + LPARAM lParam, + LRESULT& result) { result = 0; int wsa_event = WSAGETSELECTEVENT(lParam); @@ -174,7 +178,8 @@ bool Win32Socket::EventSink::OnSocketNotify(UINT uMsg, WPARAM wParam, return true; } -bool Win32Socket::EventSink::OnDnsNotify(WPARAM wParam, LPARAM lParam, +bool Win32Socket::EventSink::OnDnsNotify(WPARAM wParam, + LPARAM lParam, LRESULT& result) { result = 0; @@ -251,8 +256,8 @@ void Win32Socket::SetTimeout(int ms) { SocketAddress Win32Socket::GetLocalAddress() const { sockaddr_storage addr = {0}; socklen_t addrlen = sizeof(addr); - int result = ::getsockname(socket_, reinterpret_cast(&addr), - &addrlen); + int result = + ::getsockname(socket_, reinterpret_cast(&addr), &addrlen); SocketAddress address; if (result >= 0) { SocketAddressFromSockAddrStorage(addr, &address); @@ -266,8 +271,8 @@ SocketAddress Win32Socket::GetLocalAddress() const { SocketAddress Win32Socket::GetRemoteAddress() const { sockaddr_storage addr = {0}; socklen_t addrlen = sizeof(addr); - int result = ::getpeername(socket_, reinterpret_cast(&addr), - &addrlen); + int result = + ::getpeername(socket_, reinterpret_cast(&addr), &addrlen); SocketAddress address; if (result >= 0) { SocketAddressFromSockAddrStorage(addr, &address); @@ -285,8 +290,7 @@ int Win32Socket::Bind(const SocketAddress& addr) { sockaddr_storage saddr; size_t len = addr.ToSockAddrStorage(&saddr); - int err = ::bind(socket_, - reinterpret_cast(&saddr), + int err = ::bind(socket_, reinterpret_cast(&saddr), static_cast(len)); UpdateLastError(); return err; @@ -303,7 +307,7 @@ int Win32Socket::Connect(const SocketAddress& addr) { } RTC_LOG_F(LS_INFO) << "async dns lookup (" << addr.hostname() << ")"; - DnsLookup * dns = new DnsLookup; + DnsLookup* dns = new DnsLookup; if (!sink_) { // Explicitly create the sink ourselves here; we can't rely on SetAsync // because we don't have a socket_ yet. @@ -339,8 +343,7 @@ int Win32Socket::DoConnect(const SocketAddress& addr) { sockaddr_storage saddr = {0}; size_t len = addr.ToSockAddrStorage(&saddr); connect_time_ = Time(); - int result = connect(socket_, - reinterpret_cast(&saddr), + int result = connect(socket_, reinterpret_cast(&saddr), static_cast(len)); if (result != SOCKET_ERROR) { state_ = CS_CONNECTED; @@ -394,22 +397,20 @@ int Win32Socket::SetOption(Option opt, int value) { } int Win32Socket::Send(const void* buffer, size_t length) { - int sent = ::send(socket_, - reinterpret_cast(buffer), - static_cast(length), - 0); + int sent = ::send(socket_, reinterpret_cast(buffer), + static_cast(length), 0); UpdateLastError(); return sent; } -int Win32Socket::SendTo(const void* buffer, size_t length, +int Win32Socket::SendTo(const void* buffer, + size_t length, const SocketAddress& addr) { sockaddr_storage saddr; size_t addr_len = addr.ToSockAddrStorage(&saddr); - int sent = ::sendto(socket_, reinterpret_cast(buffer), - static_cast(length), 0, - reinterpret_cast(&saddr), - static_cast(addr_len)); + int sent = ::sendto( + socket_, reinterpret_cast(buffer), static_cast(length), + 0, reinterpret_cast(&saddr), static_cast(addr_len)); UpdateLastError(); return sent; } @@ -418,8 +419,8 @@ int Win32Socket::Recv(void* buffer, size_t length, int64_t* timestamp) { if (timestamp) { *timestamp = -1; } - int received = ::recv(socket_, static_cast(buffer), - static_cast(length), 0); + int received = + ::recv(socket_, static_cast(buffer), static_cast(length), 0); UpdateLastError(); if (closing_ && received <= static_cast(length)) PostClosed(); @@ -435,9 +436,9 @@ int Win32Socket::RecvFrom(void* buffer, } sockaddr_storage saddr; socklen_t addr_len = sizeof(saddr); - int received = ::recvfrom(socket_, static_cast(buffer), - static_cast(length), 0, - reinterpret_cast(&saddr), &addr_len); + int received = + ::recvfrom(socket_, static_cast(buffer), static_cast(length), + 0, reinterpret_cast(&saddr), &addr_len); UpdateLastError(); if (received != SOCKET_ERROR) SocketAddressFromSockAddrStorage(saddr, out_addr); @@ -511,8 +512,8 @@ bool Win32Socket::SetAsync(int events) { } // start the async select - if (WSAAsyncSelect(socket_, sink_->handle(), WM_SOCKETNOTIFY, events) - == SOCKET_ERROR) { + if (WSAAsyncSelect(socket_, sink_->handle(), WM_SOCKETNOTIFY, events) == + SOCKET_ERROR) { UpdateLastError(); Close(); return false; @@ -533,8 +534,8 @@ bool Win32Socket::HandleClosed(int close_error) { void Win32Socket::PostClosed() { // If we see that the buffer is indeed drained, then send the close. closing_ = false; - ::PostMessage(sink_->handle(), WM_SOCKETNOTIFY, - socket_, WSAMAKESELECTREPLY(FD_CLOSE, close_error_)); + ::PostMessage(sink_->handle(), WM_SOCKETNOTIFY, socket_, + WSAMAKESELECTREPLY(FD_CLOSE, close_error_)); } void Win32Socket::UpdateLastError() { @@ -667,9 +668,7 @@ static UINT s_wm_wakeup_id = 0; const TCHAR Win32SocketServer::kWindowName[] = L"libjingle Message Window"; Win32SocketServer::Win32SocketServer() - : wnd_(this), - posted_(false), - hdlg_(nullptr) { + : wnd_(this), posted_(false), hdlg_(nullptr) { if (s_wm_wakeup_id == 0) s_wm_wakeup_id = RegisterWindowMessage(L"WM_WAKEUP"); if (!wnd_.Create(nullptr, kWindowName, 0, 0, 0, 0, 0, 0)) { @@ -718,7 +717,7 @@ bool Win32SocketServer::Wait(int cms, bool process_io) { if (b == -1) { RTC_LOG_GLE(LS_ERROR) << "GetMessage failed."; return false; - } else if(b) { + } else if (b) { if (!hdlg_ || !IsDialogMessage(hdlg_, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -784,8 +783,10 @@ void Win32SocketServer::Pump() { } } -bool Win32SocketServer::MessageWindow::OnMessage(UINT wm, WPARAM wp, - LPARAM lp, LRESULT& lr) { +bool Win32SocketServer::MessageWindow::OnMessage(UINT wm, + WPARAM wp, + LPARAM lp, + LRESULT& lr) { bool handled = false; if (wm == s_wm_wakeup_id || (wm == WM_TIMER && wp == 1)) { ss_->Pump(); diff --git a/rtc_base/win32socketserver.h b/rtc_base/win32socketserver.h index 6f89baaf5d..0b11d644ec 100644 --- a/rtc_base/win32socketserver.h +++ b/rtc_base/win32socketserver.h @@ -75,17 +75,17 @@ class Win32Socket : public AsyncSocket { SOCKET socket_; int error_; ConnState state_; - SocketAddress addr_; // address that we connected to (see DoConnect) + SocketAddress addr_; // address that we connected to (see DoConnect) uint32_t connect_time_; bool closing_; int close_error_; class EventSink; friend class EventSink; - EventSink * sink_; + EventSink* sink_; struct DnsLookup; - DnsLookup * dns_; + DnsLookup* dns_; }; /////////////////////////////////////////////////////////////////////////////// @@ -97,9 +97,7 @@ class Win32SocketServer : public SocketServer { Win32SocketServer(); ~Win32SocketServer() override; - void set_modeless_dialog(HWND hdlg) { - hdlg_ = hdlg; - } + void set_modeless_dialog(HWND hdlg) { hdlg_ = hdlg; } // SocketServer Interface Socket* CreateSocket(int family, int type) override; @@ -117,13 +115,14 @@ class Win32SocketServer : public SocketServer { class MessageWindow : public Win32Window { public: explicit MessageWindow(Win32SocketServer* ss) : ss_(ss) {} + private: bool OnMessage(UINT msg, WPARAM wp, LPARAM lp, LRESULT& result) override; Win32SocketServer* ss_; }; static const TCHAR kWindowName[]; - MessageQueue *message_queue_; + MessageQueue* message_queue_; MessageWindow wnd_; CriticalSection cs_; bool posted_; diff --git a/rtc_base/win32window.cc b/rtc_base/win32window.cc index d71c68e12b..4290894d26 100644 --- a/rtc_base/win32window.cc +++ b/rtc_base/win32window.cc @@ -28,8 +28,14 @@ Win32Window::~Win32Window() { RTC_DCHECK(nullptr == wnd_); } -bool Win32Window::Create(HWND parent, const wchar_t* title, DWORD style, - DWORD exstyle, int x, int y, int cx, int cy) { +bool Win32Window::Create(HWND parent, + const wchar_t* title, + DWORD style, + DWORD exstyle, + int x, + int y, + int cx, + int cy) { if (wnd_) { // Window already exists. return false; @@ -37,7 +43,7 @@ bool Win32Window::Create(HWND parent, const wchar_t* title, DWORD style, if (!window_class_) { if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(&Win32Window::WndProc), &instance_)) { RTC_LOG_GLE(LS_ERROR) << "GetModuleHandleEx failed"; @@ -74,15 +80,17 @@ void Win32Window::Shutdown() { } } -bool Win32Window::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, +bool Win32Window::OnMessage(UINT uMsg, + WPARAM wParam, + LPARAM lParam, LRESULT& result) { switch (uMsg) { - case WM_CLOSE: - if (!OnClose()) { - result = 0; - return true; - } - break; + case WM_CLOSE: + if (!OnClose()) { + result = 0; + return true; + } + break; } return false; } diff --git a/rtc_base/win32window.h b/rtc_base/win32window.h index fa026d118a..e96aa350fb 100644 --- a/rtc_base/win32window.h +++ b/rtc_base/win32window.h @@ -28,22 +28,32 @@ class Win32Window { HWND handle() const { return wnd_; } - bool Create(HWND parent, const wchar_t* title, DWORD style, DWORD exstyle, - int x, int y, int cx, int cy); + bool Create(HWND parent, + const wchar_t* title, + DWORD style, + DWORD exstyle, + int x, + int y, + int cx, + int cy); void Destroy(); // Call this when your DLL unloads. static void Shutdown(); protected: - virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, + virtual bool OnMessage(UINT uMsg, + WPARAM wParam, + LPARAM lParam, LRESULT& result); virtual bool OnClose(); virtual void OnNcDestroy(); private: - static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, + static LRESULT CALLBACK WndProc(HWND hwnd, + UINT uMsg, + WPARAM wParam, LPARAM lParam); HWND wnd_; diff --git a/rtc_tools/agc/activity_metric.cc b/rtc_tools/agc/activity_metric.cc index ed48543b4a..b4ed3facb3 100644 --- a/rtc_tools/agc/activity_metric.cc +++ b/rtc_tools/agc/activity_metric.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include #include #include @@ -32,21 +31,30 @@ static const int kAgcAnalWindowSamples = 100; static const float kDefaultActivityThreshold = 0.3f; DEFINE_bool(standalone_vad, true, "enable stand-alone VAD"); -DEFINE_string(true_vad, "", "name of a file containing true VAD in 'int'" +DEFINE_string(true_vad, + "", + "name of a file containing true VAD in 'int'" " format"); -DEFINE_string(video_vad, "", "name of a file containing video VAD (activity" +DEFINE_string(video_vad, + "", + "name of a file containing video VAD (activity" " probabilities) in double format. One activity per 10ms is" " required. If no file is given the video information is not" " incorporated. Negative activity is interpreted as video is" " not adapted and the statistics are not computed during" " the learning phase. Note that the negative video activities" " are ONLY allowed at the beginning."); -DEFINE_string(result, "", "name of a file to write the results. The results" +DEFINE_string(result, + "", + "name of a file to write the results. The results" " will be appended to the end of the file. This is optional."); -DEFINE_string(audio_content, "", "name of a file where audio content is written" +DEFINE_string(audio_content, + "", + "name of a file where audio content is written" " to, in double format."); -DEFINE_float(activity_threshold, kDefaultActivityThreshold, - "Activity threshold"); +DEFINE_float(activity_threshold, + kDefaultActivityThreshold, + "Activity threshold"); DEFINE_bool(help, false, "prints this message"); namespace webrtc { @@ -61,8 +69,8 @@ namespace webrtc { static void DitherSilence(AudioFrame* frame) { ASSERT_EQ(1u, frame->num_channels_); const double kRmsSilence = 5; - const double sum_squared_silence = kRmsSilence * kRmsSilence * - frame->samples_per_channel_; + const double sum_squared_silence = + kRmsSilence * kRmsSilence * frame->samples_per_channel_; double sum_squared = 0; int16_t* frame_data = frame->mutable_data(); for (size_t n = 0; n < frame->samples_per_channel_; n++) @@ -97,21 +105,18 @@ class AgcStat { audio_content_fid_ = audio_content_fid; } - int AddAudio(const AudioFrame& frame, double p_video, - int* combined_vad) { + int AddAudio(const AudioFrame& frame, double p_video, int* combined_vad) { if (frame.num_channels_ != 1 || - frame.samples_per_channel_ != - kSampleRateHz / 100 || - frame.sample_rate_hz_ != kSampleRateHz) + frame.samples_per_channel_ != kSampleRateHz / 100 || + frame.sample_rate_hz_ != kSampleRateHz) return -1; video_vad_[video_index_++] = p_video; AudioFeatures features; const int16_t* frame_data = frame.data(); - audio_processing_->ExtractFeatures( - frame_data, frame.samples_per_channel_, &features); + audio_processing_->ExtractFeatures(frame_data, frame.samples_per_channel_, + &features); if (FLAG_standalone_vad) { - standalone_vad_->AddAudio(frame_data, - frame.samples_per_channel_); + standalone_vad_->AddAudio(frame_data, frame.samples_per_channel_); } if (features.num_frames > 0) { double p[kMaxNumFrames] = {0.5, 0.5, 0.5, 0.5}; @@ -145,9 +150,7 @@ class AgcStat { return static_cast(features.num_frames); } - void Reset() { - audio_content_->Reset(); - } + void Reset() { audio_content_->Reset(); } void SetActivityThreshold(double activity_threshold) { activity_threshold_ = activity_threshold; @@ -165,7 +168,6 @@ class AgcStat { FILE* audio_content_fid_; }; - void void_main(int argc, char* argv[]) { webrtc::AgcStat agc_stat; @@ -178,10 +180,10 @@ void void_main(int argc, char* argv[]) { FILE* true_vad_fid = NULL; ASSERT_GT(strlen(FLAG_true_vad), 0u) << "Specify the file containing true " - "VADs using --true_vad flag."; + "VADs using --true_vad flag."; true_vad_fid = fopen(FLAG_true_vad, "rb"); - ASSERT_TRUE(true_vad_fid != NULL) << "Cannot open the active list " << - FLAG_true_vad; + ASSERT_TRUE(true_vad_fid != NULL) + << "Cannot open the active list " << FLAG_true_vad; FILE* results_fid = NULL; if (strlen(FLAG_result) > 0) { @@ -199,11 +201,12 @@ void void_main(int argc, char* argv[]) { } // Open in append mode. results_fid = fopen(FLAG_result, "a"); - ASSERT_TRUE(results_fid != NULL) << "Cannot open the file, " << - FLAG_result << ", to write the results."; + ASSERT_TRUE(results_fid != NULL) + << "Cannot open the file, " << FLAG_result << ", to write the results."; // Write the header if required. if (write_header) { - fprintf(results_fid, "%% Total Active, Misdetection, " + fprintf(results_fid, + "%% Total Active, Misdetection, " "Total inactive, False Positive, On-sets, Missed segments, " "Average response\n"); } @@ -212,8 +215,9 @@ void void_main(int argc, char* argv[]) { FILE* video_vad_fid = NULL; if (strlen(FLAG_video_vad) > 0) { video_vad_fid = fopen(FLAG_video_vad, "rb"); - ASSERT_TRUE(video_vad_fid != NULL) << "Cannot open the file, " << - FLAG_video_vad << " to read video-based VAD decisions.\n"; + ASSERT_TRUE(video_vad_fid != NULL) + << "Cannot open the file, " << FLAG_video_vad + << " to read video-based VAD decisions.\n"; } // AgsStat will be the owner of this file and will close it at its @@ -221,8 +225,9 @@ void void_main(int argc, char* argv[]) { FILE* audio_content_fid = NULL; if (strlen(FLAG_audio_content) > 0) { audio_content_fid = fopen(FLAG_audio_content, "wb"); - ASSERT_TRUE(audio_content_fid != NULL) << "Cannot open file, " << - FLAG_audio_content << " to write audio-content.\n"; + ASSERT_TRUE(audio_content_fid != NULL) + << "Cannot open file, " << FLAG_audio_content + << " to write audio-content.\n"; agc_stat.set_audio_content_file(audio_content_fid); } @@ -230,8 +235,8 @@ void void_main(int argc, char* argv[]) { frame.num_channels_ = 1; frame.sample_rate_hz_ = 16000; frame.samples_per_channel_ = frame.sample_rate_hz_ / 100; - const size_t kSamplesToRead = frame.num_channels_ * - frame.samples_per_channel_; + const size_t kSamplesToRead = + frame.num_channels_ * frame.samples_per_channel_; agc_stat.SetActivityThreshold(FLAG_activity_threshold); @@ -260,16 +265,17 @@ void void_main(int argc, char* argv[]) { true_vad_fid)) << "Size mismatch between True-VAD and the PCM file.\n"; if (video_vad_fid != NULL) { - ASSERT_EQ(1u, fread(&p_video, sizeof(p_video), 1, video_vad_fid)) << - "Not enough video-based VAD probabilities."; + ASSERT_EQ(1u, fread(&p_video, sizeof(p_video), 1, video_vad_fid)) + << "Not enough video-based VAD probabilities."; } // Negative video activity indicates that the video-based VAD is not yet // adapted. Disregards the learning phase in statistics. if (p_video < 0) { if (video_adapted) { - fprintf(stderr, "Negative video probabilities ONLY allowed at the " - "beginning of the sequence, not in the middle.\n"); + fprintf(stderr, + "Negative video probabilities ONLY allowed at the " + "beginning of the sequence, not in the middle.\n"); exit(1); } continue; @@ -337,23 +343,15 @@ void void_main(int argc, char* argv[]) { if (results_fid != NULL) { fprintf(results_fid, "%4d %4d %4d %4d %4d %4d %4.0f %4.0f\n", - total_active, - total_missed_detection, - total_passive, - total_false_positive, - num_onsets, - num_not_adapted, + total_active, total_missed_detection, total_passive, + total_false_positive, num_onsets, num_not_adapted, static_cast(onset_adaptation) / (num_onsets + 1e-12), static_cast(total_false_positive_duration) / - (total_passive + 1e-12)); + (total_passive + 1e-12)); } - fprintf(stdout, "%4d %4d %4d %4d %4d %4d %4.0f %4.0f\n", - total_active, - total_missed_detection, - total_passive, - total_false_positive, - num_onsets, - num_not_adapted, + fprintf(stdout, "%4d %4d %4d %4d %4d %4d %4.0f %4.0f\n", total_active, + total_missed_detection, total_passive, total_false_positive, + num_onsets, num_not_adapted, static_cast(onset_adaptation) / (num_onsets + 1e-12), static_cast(total_false_positive_duration) / (total_passive + 1e-12)); @@ -373,16 +371,18 @@ void void_main(int argc, char* argv[]) { int main(int argc, char* argv[]) { if (argc == 1) { // Print usage information. - std::cout << - "\nCompute the number of misdetected and false-positive frames. Not\n" - " that for each frame of audio (10 ms) there should be one true\n" - " activity. If any video-based activity is given, there should also be\n" - " one probability per frame.\n" - "Run with --help for more details on available flags.\n" - "\nUsage:\n\n" - "activity_metric input_pcm [options]\n" - "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits " - "format.\n\n"; + std::cout + << "\nCompute the number of misdetected and false-positive frames. " + "Not\n" + " that for each frame of audio (10 ms) there should be one true\n" + " activity. If any video-based activity is given, there should also " + "be\n" + " one probability per frame.\n" + "Run with --help for more details on available flags.\n" + "\nUsage:\n\n" + "activity_metric input_pcm [options]\n" + "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits " + "format.\n\n"; return 0; } rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); diff --git a/rtc_tools/converter/converter.cc b/rtc_tools/converter/converter.cc index ee1316efc2..e36d405451 100644 --- a/rtc_tools/converter/converter.cc +++ b/rtc_tools/converter/converter.cc @@ -27,10 +27,7 @@ namespace webrtc { namespace test { -Converter::Converter(int width, int height) - : width_(width), - height_(height) { -} +Converter::Converter(int width, int height) : width_(width), height_(height) {} bool Converter::ConvertRGBAToI420Video(std::string frames_dir, std::string output_file_name, @@ -53,7 +50,7 @@ bool Converter::ConvertRGBAToI420Video(std::string frames_dir, int v_plane_size = VPlaneSize(); uint8_t* dst_v = new uint8_t[v_plane_size]; - int counter = 0; // Counter to form frame names. + int counter = 0; // Counter to form frame names. bool success = false; // Is conversion successful. while (true) { @@ -79,16 +76,13 @@ bool Converter::ConvertRGBAToI420Video(std::string frames_dir, } // Convert to I420 frame. - libyuv::ABGRToI420(rgba_buffer, SrcStrideFrame(), - dst_y, DstStrideY(), - dst_u, DstStrideU(), - dst_v, DstStrideV(), - width_, height_); + libyuv::ABGRToI420(rgba_buffer, SrcStrideFrame(), dst_y, DstStrideY(), + dst_u, DstStrideU(), dst_v, DstStrideV(), width_, + height_); // Add the I420 frame to the YUV video file. - success = AddYUVToFile(dst_y, y_plane_size, dst_u, u_plane_size, - dst_v, v_plane_size, output_file); - + success = AddYUVToFile(dst_y, y_plane_size, dst_u, u_plane_size, dst_v, + v_plane_size, output_file); if (!success) { fprintf(stderr, "LibYUV error during RGBA to I420 frame conversion\n"); @@ -125,14 +119,17 @@ bool Converter::AddYUVPlaneToFile(uint8_t* yuv_plane, size_t bytes_written = fwrite(yuv_plane, 1, yuv_plane_size, file); if (bytes_written != static_cast(yuv_plane_size)) { - fprintf(stderr, "Number of bytes written (%d) doesn't match size of y plane" - " (%d)\n", static_cast(bytes_written), yuv_plane_size); + fprintf(stderr, + "Number of bytes written (%d) doesn't match size of y plane" + " (%d)\n", + static_cast(bytes_written), yuv_plane_size); return false; } return true; } -bool Converter::ReadRGBAFrame(const char* input_file_name, int input_frame_size, +bool Converter::ReadRGBAFrame(const char* input_file_name, + int input_frame_size, unsigned char* buffer) { FILE* input_file = fopen(input_file_name, "rb"); if (input_file == NULL) { @@ -157,7 +154,7 @@ std::string Converter::FindFullFileName(std::string dir_name, return dir_name + SEPARATOR + file_name; } -bool Converter:: FileExists(std::string file_name_to_check) { +bool Converter::FileExists(std::string file_name_to_check) { struct STAT file_info; int result = STAT(file_name_to_check.c_str(), &file_info); return (result == 0); diff --git a/rtc_tools/converter/converter.h b/rtc_tools/converter/converter.h index bd31f7efb2..e3b3ea3f4c 100644 --- a/rtc_tools/converter/converter.h +++ b/rtc_tools/converter/converter.h @@ -27,51 +27,36 @@ class Converter { // Converts RGBA to YUV video. If the delete_frames argument is true, the // method will delete the input frames after conversion. bool ConvertRGBAToI420Video(std::string frames_dir, - std::string output_file_name, bool delete_frames); + std::string output_file_name, + bool delete_frames); private: - int width_; // Width of the video (respectively of the RGBA frames). + int width_; // Width of the video (respectively of the RGBA frames). int height_; // Height of the video (respectively of the RGBA frames). // Returns the size of the Y plane in bytes. - int YPlaneSize() const { - return width_*height_; - } + int YPlaneSize() const { return width_ * height_; } // Returns the size of the U plane in bytes. - int UPlaneSize() const { - return ((width_+1)/2)*((height_)/2); - } + int UPlaneSize() const { return ((width_ + 1) / 2) * ((height_) / 2); } // Returns the size of the V plane in bytes. - int VPlaneSize() const { - return ((width_+1)/2)*((height_)/2); - } + int VPlaneSize() const { return ((width_ + 1) / 2) * ((height_) / 2); } // Returns the number of bytes per row in the RGBA frame. - int SrcStrideFrame() const { - return width_*4; - } + int SrcStrideFrame() const { return width_ * 4; } // Returns the number of bytes in the Y plane. - int DstStrideY() const { - return width_; - } + int DstStrideY() const { return width_; } // Returns the number of bytes in the U plane. - int DstStrideU() const { - return (width_+1)/2; - } + int DstStrideU() const { return (width_ + 1) / 2; } // Returns the number of bytes in the V plane. - int DstStrideV() const { - return (width_+1)/2; - } + int DstStrideV() const { return (width_ + 1) / 2; } // Returns the size in bytes of the input RGBA frames. - int InputFrameSize() const { - return width_*height_*4; - } + int InputFrameSize() const { return width_ * height_ * 4; } // Writes the Y, U and V (in this order) planes to the file, thus adding a // raw YUV frame to the file. @@ -88,7 +73,8 @@ class Converter { // Reads a RGBA frame from input_file_name with input_frame_size size in bytes // into the buffer. - bool ReadRGBAFrame(const char* input_file_name, int input_frame_size, + bool ReadRGBAFrame(const char* input_file_name, + int input_frame_size, unsigned char* buffer); // Finds the full path name of the file - concatenates the directory and file @@ -99,7 +85,7 @@ class Converter { bool FileExists(std::string file_name_to_check); // Returns the name of the file in the form frame_, where is - // 4 zero padded (i.e. frame_0000, frame_0001, etc.). + // 4 zero padded (i.e. frame_0000, frame_0001, etc.). std::string FormFrameName(int width, int number); }; diff --git a/rtc_tools/converter/rgba_to_i420_converter.cc b/rtc_tools/converter/rgba_to_i420_converter.cc index e08dd8a6b6..9fe5141d51 100644 --- a/rtc_tools/converter/rgba_to_i420_converter.cc +++ b/rtc_tools/converter/rgba_to_i420_converter.cc @@ -28,22 +28,25 @@ */ int main(int argc, char* argv[]) { std::string program_name = argv[0]; - std::string usage = "Converts RGBA raw image files to I420 frames for YUV.\n" - "Example usage:\n" + program_name + - " --frames_dir=. --output_file=output.yuv --width=320 --height=240\n" - "IMPORTANT: If you pass the --delete_frames command line parameter, the " - "tool will delete the input frames after conversion.\n" - "Command line flags:\n" - " - width(int): Width in pixels of the frames in the input file." - " Default: -1\n" - " - height(int): Height in pixels of the frames in the input file." - " Default: -1\n" - " - frames_dir(string): The path to the directory where the frames reside." - " Default: .\n" - " - output_file(string): The output file to which frames are written." - " Default: output.yuv\n" - " - delete_frames(bool): Whether or not to delete the input frames after" - " the conversion. Default: false.\n"; + std::string usage = + "Converts RGBA raw image files to I420 frames for YUV.\n" + "Example usage:\n" + + program_name + + " --frames_dir=. --output_file=output.yuv --width=320 --height=240\n" + "IMPORTANT: If you pass the --delete_frames command line parameter, the " + "tool will delete the input frames after conversion.\n" + "Command line flags:\n" + " - width(int): Width in pixels of the frames in the input file." + " Default: -1\n" + " - height(int): Height in pixels of the frames in the input file." + " Default: -1\n" + " - frames_dir(string): The path to the directory where the frames " + "reside." + " Default: .\n" + " - output_file(string): The output file to which frames are written." + " Default: output.yuv\n" + " - delete_frames(bool): Whether or not to delete the input frames after" + " the conversion. Default: false.\n"; webrtc::test::CommandLineParser parser; @@ -76,9 +79,8 @@ int main(int argc, char* argv[]) { bool del_frames = (parser.GetFlag("delete_frames") == "true") ? true : false; webrtc::test::Converter converter(width, height); - bool success = converter.ConvertRGBAToI420Video(parser.GetFlag("frames_dir"), - parser.GetFlag("output_file"), - del_frames); + bool success = converter.ConvertRGBAToI420Video( + parser.GetFlag("frames_dir"), parser.GetFlag("output_file"), del_frames); if (success) { fprintf(stdout, "Successful conversion of RGBA frames to YUV video!\n"); diff --git a/rtc_tools/event_log_visualizer/analyzer.cc b/rtc_tools/event_log_visualizer/analyzer.cc index a8dbc30cb4..f20d301d16 100644 --- a/rtc_tools/event_log_visualizer/analyzer.cc +++ b/rtc_tools/event_log_visualizer/analyzer.cc @@ -483,7 +483,7 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLogNew& log, } } RTC_LOG(LS_INFO) << "Found " << log_segments_.size() - << " (LOG_START, LOG_END) segments in log."; + << " (LOG_START, LOG_END) segments in log."; } class BitrateObserver : public NetworkChangedObserver, @@ -641,8 +641,7 @@ void EventLogAnalyzer::CreateAudioLevelGraph(PacketDirection direction, plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); - plot->SetYAxis(-127, 0, "Audio level (dBov)", kBottomMargin, - kTopMargin); + plot->SetYAxis(-127, 0, "Audio level (dBov)", kBottomMargin, kTopMargin); plot->SetTitle(GetDirectionAsString(direction) + " audio level"); } diff --git a/rtc_tools/event_log_visualizer/main.cc b/rtc_tools/event_log_visualizer/main.cc index 802633cad3..c82295ea07 100644 --- a/rtc_tools/event_log_visualizer/main.cc +++ b/rtc_tools/event_log_visualizer/main.cc @@ -157,7 +157,6 @@ DEFINE_bool(normalize_time, void SetAllPlotFlags(bool setting); - int main(int argc, char* argv[]) { std::string program_name = argv[0]; std::string usage = @@ -381,7 +380,6 @@ int main(int argc, char* argv[]) { return 0; } - void SetAllPlotFlags(bool setting) { FLAG_plot_incoming_packet_sizes = setting; FLAG_plot_outgoing_packet_sizes = setting; diff --git a/rtc_tools/event_log_visualizer/plot_protobuf.cc b/rtc_tools/event_log_visualizer/plot_protobuf.cc index e986a74fdc..0c4c709f83 100644 --- a/rtc_tools/event_log_visualizer/plot_protobuf.cc +++ b/rtc_tools/event_log_visualizer/plot_protobuf.cc @@ -69,8 +69,8 @@ void ProtobufPlotCollection::ExportProtobuf( // TODO(terelius): Ensure that there is no way to insert plots other than // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast // here. - webrtc::analytics::Chart* protobuf_representation - = collection->add_charts(); + webrtc::analytics::Chart* protobuf_representation = + collection->add_charts(); static_cast(plot.get()) ->ExportProtobuf(protobuf_representation); } diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis.cc b/rtc_tools/frame_analyzer/reference_less_video_analysis.cc index 4e87bc9a55..3d7fd7fc48 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis.cc +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis.cc @@ -17,8 +17,10 @@ int main(int argc, char* argv[]) { // This captures the freezing metrics for reference less video analysis. std::string program_name = argv[0]; - std::string usage = "Outputs the freezing score by comparing current frame " - "with the previous frame.\nExample usage:\n" + program_name + + std::string usage = + "Outputs the freezing score by comparing current frame " + "with the previous frame.\nExample usage:\n" + + program_name + " --video_file=video_file.y4m\n" "Command line flags:\n" " - video_file(string): Path of the video " diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc index 78d10cecf9..9a7535b213 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc @@ -25,7 +25,9 @@ #define strtok_r strtok_s #endif -void get_height_width_fps(int *height, int *width, int *fps, +void get_height_width_fps(int* height, + int* width, + int* fps, const std::string& video_file) { // File header looks like : // YUV4MPEG2 W1280 H720 F25:1 Ip A0:0 C420mpeg2 XYSCSS=420MPEG2. @@ -37,8 +39,8 @@ void get_height_width_fps(int *height, int *width, int *fps, frame_header[bytes_read] = '\0'; std::string file_header_stats[5]; int no_of_stats = 0; - char *save_ptr; - char *token = strtok_r(frame_header, " ", &save_ptr); + char* save_ptr; + char* token = strtok_r(frame_header, " ", &save_ptr); while (token != NULL) { file_header_stats[no_of_stats++] = token; @@ -54,27 +56,29 @@ void get_height_width_fps(int *height, int *width, int *fps, } bool frozen_frame(std::vector psnr_per_frame, - std::vector ssim_per_frame, size_t frame) { + std::vector ssim_per_frame, + size_t frame) { if (psnr_per_frame[frame] >= PSNR_FREEZE_THRESHOLD || ssim_per_frame[frame] >= SSIM_FREEZE_THRESHOLD) return true; return false; } -std::vector find_frame_clusters(const std::vector& psnr_per_frame, - const std::vector& ssim_per_frame) { +std::vector find_frame_clusters( + const std::vector& psnr_per_frame, + const std::vector& ssim_per_frame) { std::vector identical_frame_clusters; int num_frozen = 0; size_t total_no_of_frames = psnr_per_frame.size(); for (size_t each_frame = 0; each_frame < total_no_of_frames; each_frame++) { - if (frozen_frame(psnr_per_frame, ssim_per_frame, each_frame)) { - num_frozen++; - } else if (num_frozen > 0) { - // Not frozen anymore. - identical_frame_clusters.push_back(num_frozen); - num_frozen = 0; - } + if (frozen_frame(psnr_per_frame, ssim_per_frame, each_frame)) { + num_frozen++; + } else if (num_frozen > 0) { + // Not frozen anymore. + identical_frame_clusters.push_back(num_frozen); + num_frozen = 0; + } } return identical_frame_clusters; } @@ -106,8 +110,8 @@ void print_freezing_metrics(const std::vector& psnr_per_frame, * */ size_t total_no_of_frames = psnr_per_frame.size(); - std::vector identical_frame_clusters = find_frame_clusters( - psnr_per_frame, ssim_per_frame); + std::vector identical_frame_clusters = + find_frame_clusters(psnr_per_frame, ssim_per_frame); int total_identical_frames = std::accumulate( identical_frame_clusters.begin(), identical_frame_clusters.end(), 0); size_t unique_frames = total_no_of_frames - total_identical_frames; @@ -126,7 +130,7 @@ void print_freezing_metrics(const std::vector& psnr_per_frame, printf("Print identical frame which appears in clusters : \n"); for (int cluster = 0; - cluster < static_cast(identical_frame_clusters.size()); cluster++) + cluster < static_cast(identical_frame_clusters.size()); cluster++) printf("%d ", identical_frame_clusters[cluster]); printf("\n"); } @@ -145,28 +149,22 @@ void compute_metrics(const std::string& video_file_name, uint8_t* next_frame = new uint8_t[size]; while (true) { - if (!(webrtc::test::ExtractFrameFromY4mFile (video_file_name.c_str(), - width, height, - no_of_frames, - current_frame))) { + if (!(webrtc::test::ExtractFrameFromY4mFile(video_file_name.c_str(), width, + height, no_of_frames, + current_frame))) { break; } - if (!(webrtc::test::ExtractFrameFromY4mFile (video_file_name.c_str(), - width, height, - no_of_frames + 1, - next_frame))) { + if (!(webrtc::test::ExtractFrameFromY4mFile(video_file_name.c_str(), width, + height, no_of_frames + 1, + next_frame))) { break; } - double result_psnr = webrtc::test::CalculateMetrics(webrtc::test::kPSNR, - current_frame, - next_frame, - width, height); - double result_ssim = webrtc::test::CalculateMetrics(webrtc::test::kSSIM, - current_frame, - next_frame, - width, height); + double result_psnr = webrtc::test::CalculateMetrics( + webrtc::test::kPSNR, current_frame, next_frame, width, height); + double result_ssim = webrtc::test::CalculateMetrics( + webrtc::test::kSSIM, current_frame, next_frame, width, height); psnr_per_frame->push_back(result_psnr); ssim_per_frame->push_back(result_ssim); @@ -178,7 +176,7 @@ void compute_metrics(const std::string& video_file_name, } bool check_file_extension(const std::string& video_file_name) { - if (video_file_name.substr(video_file_name.length()-3, 3) != "y4m") { + if (video_file_name.substr(video_file_name.length() - 3, 3) != "y4m") { printf("Only y4m video file format is supported. Given: %s\n", video_file_name.c_str()); return false; diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h index 1a7b1b1bd5..a1de03baf6 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h @@ -16,13 +16,16 @@ // Parse the file header to extract height, width and fps // for a given video file. -void get_height_width_fps(int *height, int *width, int *fps, +void get_height_width_fps(int* height, + int* width, + int* fps, const std::string& video_file); // Returns true if the frame is frozen based on psnr and ssim freezing // threshold values. bool frozen_frame(std::vector psnr_per_frame, - std::vector ssim_per_frame, size_t frame); + std::vector ssim_per_frame, + size_t frame); // Returns the vector of identical cluster of frames that are frozen // and appears continuously. diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc b/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc index 13ccb85422..4e20532000 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc @@ -7,8 +7,8 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#include #include +#include #include #include #include @@ -21,7 +21,7 @@ class ReferenceLessVideoAnalysisTest : public ::testing::Test { public: void SetUp() override { video_file = - webrtc::test::ResourcePath("reference_less_video_test_file", "y4m"); + webrtc::test::ResourcePath("reference_less_video_test_file", "y4m"); } std::string video_file; std::vector psnr_per_frame; @@ -62,7 +62,3 @@ TEST_F(ReferenceLessVideoAnalysisTest, CheckFileExtension) { webrtc::test::ResourcePath("video_quality_analysis_frame", "txt"); EXPECT_FALSE(check_file_extension(txt_file)); } - - - - diff --git a/rtc_tools/frame_analyzer/video_quality_analysis.cc b/rtc_tools/frame_analyzer/video_quality_analysis.cc index 502ac82601..60a4a016cc 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis.cc +++ b/rtc_tools/frame_analyzer/video_quality_analysis.cc @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include "test/testsupport/perf_test.h" @@ -35,7 +35,7 @@ int GetI420FrameSize(int width, int height) { int half_width = (width + 1) >> 1; int half_height = (height + 1) >> 1; - int y_plane = width * height; // I420 Y plane. + int y_plane = width * height; // I420 Y plane. int u_plane = half_width * half_height; // I420 U plane. int v_plane = half_width * half_height; // I420 V plane. @@ -88,7 +88,7 @@ bool GetNextStatsLine(FILE* stats_file, char* line) { line[chars] = buf; ++chars; } - line[chars-1] = '\0'; // Strip the trailing \n and put end of string. + line[chars - 1] = '\0'; // Strip the trailing \n and put end of string. return true; } @@ -112,8 +112,7 @@ bool ExtractFrameFromYuvFile(const char* i420_file_name, fseek(input_file, offset, SEEK_SET); size_t bytes_read = fread(result_frame, 1, frame_size, input_file); - if (bytes_read != static_cast(frame_size) && - ferror(input_file)) { + if (bytes_read != static_cast(frame_size) && ferror(input_file)) { fprintf(stdout, "Error while reading frame no %d from file %s\n", frame_number, i420_file_name); errors = true; @@ -144,8 +143,7 @@ bool ExtractFrameFromY4mFile(const char* y4m_file_name, size_t bytes_read = fread(frame_header, 1, Y4M_FILE_HEADER_MAX_SIZE - 1, input_file); if (bytes_read != static_cast(frame_size) && ferror(input_file)) { - fprintf(stdout, "Error while reading frame from file %s\n", - y4m_file_name); + fprintf(stdout, "Error while reading frame from file %s\n", y4m_file_name); fclose(input_file); return false; } @@ -154,7 +152,7 @@ bool ExtractFrameFromY4mFile(const char* y4m_file_name, std::size_t found = header_contents.find(Y4M_FRAME_DELIMITER); if (found == std::string::npos) { fprintf(stdout, "Corrupted Y4M header, could not find \"FRAME\" in %s\n", - header_contents.c_str()); + header_contents.c_str()); fclose(input_file); return false; } @@ -206,19 +204,17 @@ double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type, switch (video_metrics_type) { case kPSNR: // In the following: stride is determined by width. - result = libyuv::I420Psnr(src_y_a, width, src_u_a, half_width, - src_v_a, half_width, src_y_b, width, - src_u_b, half_width, src_v_b, half_width, - width, height); + result = libyuv::I420Psnr(src_y_a, width, src_u_a, half_width, src_v_a, + half_width, src_y_b, width, src_u_b, half_width, + src_v_b, half_width, width, height); // LibYuv sets the max psnr value to 128, we restrict it to 48. // In case of 0 mse in one frame, 128 can skew the results significantly. result = (result > 48.0) ? 48.0 : result; break; case kSSIM: - result = libyuv::I420Ssim(src_y_a, stride_y, src_u_a, stride_uv, - src_v_a, stride_uv, src_y_b, stride_y, - src_u_b, stride_uv, src_v_b, stride_uv, - width, height); + result = libyuv::I420Ssim(src_y_a, stride_y, src_u_a, stride_uv, src_v_a, + stride_uv, src_y_b, stride_y, src_u_b, + stride_uv, src_v_b, stride_uv, width, height); break; default: assert(false); @@ -471,7 +467,8 @@ void PrintAnalysisResults(const std::string& label, ResultsContainer* results) { PrintAnalysisResults(stdout, label, results); } -void PrintAnalysisResults(FILE* output, const std::string& label, +void PrintAnalysisResults(FILE* output, + const std::string& label, ResultsContainer* results) { SetPerfResultsOutput(output); diff --git a/rtc_tools/frame_analyzer/video_quality_analysis.h b/rtc_tools/frame_analyzer/video_quality_analysis.h index 92228fcd08..dca719d295 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis.h +++ b/rtc_tools/frame_analyzer/video_quality_analysis.h @@ -12,8 +12,8 @@ #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_QUALITY_ANALYSIS_H_ #include -#include #include +#include #include "third_party/libyuv/include/libyuv/compare.h" #include "third_party/libyuv/include/libyuv/convert.h" @@ -44,7 +44,7 @@ struct ResultsContainer { int decode_errors_test; }; -enum VideoAnalysisMetricsType {kPSNR, kSSIM}; +enum VideoAnalysisMetricsType { kPSNR, kSSIM }; // A function to run the PSNR and SSIM analysis on the test file. The test file // comprises the frames that were captured during the quality measurement test. @@ -85,7 +85,8 @@ double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type, void PrintAnalysisResults(const std::string& label, ResultsContainer* results); // Similar to the above, but will print to the specified file handle. -void PrintAnalysisResults(FILE* output, const std::string& label, +void PrintAnalysisResults(FILE* output, + const std::string& label, ResultsContainer* results); // The barcode number that means that the barcode could not be decoded. diff --git a/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc b/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc index 6143c314d5..d1edb30a19 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc +++ b/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc @@ -43,10 +43,10 @@ class VideoQualityAnalysisTest : public ::testing::Test { TEST_F(VideoQualityAnalysisTest, MatchExtractedY4mFrame) { std::string video_file = - webrtc::test::ResourcePath("reference_less_video_test_file", "y4m"); + webrtc::test::ResourcePath("reference_less_video_test_file", "y4m"); std::string extracted_frame_from_video_file = - webrtc::test::ResourcePath("video_quality_analysis_frame", "txt"); + webrtc::test::ResourcePath("video_quality_analysis_frame", "txt"); int frame_height = 720, frame_width = 1280; int frame_number = 2; @@ -57,8 +57,7 @@ TEST_F(VideoQualityAnalysisTest, MatchExtractedY4mFrame) { FILE* input_file = fopen(extracted_frame_from_video_file.c_str(), "rb"); fread(expected_frame, 1, size, input_file); - ExtractFrameFromY4mFile(video_file.c_str(), - frame_width, frame_height, + ExtractFrameFromY4mFile(video_file.c_str(), frame_width, frame_height, frame_number, result_frame); EXPECT_EQ(*expected_frame, *result_frame); @@ -92,8 +91,7 @@ TEST_F(VideoQualityAnalysisTest, GetMaxRepeatedAndSkippedFramesInvalidFile) { GetMaxRepeatedAndSkippedFrames(stats_filename_ref_, stats_filename_, &result); } -TEST_F(VideoQualityAnalysisTest, - GetMaxRepeatedAndSkippedFramesEmptyStatsFile) { +TEST_F(VideoQualityAnalysisTest, GetMaxRepeatedAndSkippedFramesEmptyStatsFile) { ResultsContainer result; std::ofstream stats_file; stats_file.open(stats_filename_ref_.c_str()); diff --git a/rtc_tools/frame_editing/frame_editing.cc b/rtc_tools/frame_editing/frame_editing.cc index 67ca9cca82..fc281e1082 100644 --- a/rtc_tools/frame_editing/frame_editing.cc +++ b/rtc_tools/frame_editing/frame_editing.cc @@ -19,46 +19,51 @@ // A command-line tool to edit a YUV-video (I420 sub-sampled). int main(int argc, char* argv[]) { std::string program_name = argv[0]; - std::string usage = "Deletes a series of frames in a yuv file." - " Only I420 is supported!\n" - "Example usage:\n" + program_name + - " --in_path=input.yuv --width=320 --height=240 --f=60 --interval=1 --l=120" - " --out_path=edited_clip.yuv\n" - "Command line flags:\n" - "--in_path(string): Path and filename to the input file\n" - "--width(int): Width in pixels of the frames in the input file." - " Default: -1\n" - "--height(int): Height in pixels of the frames in the input file." - " Default: -1\n" - "--f(int): First frame to process. Default: -1\n" - "--l(int): Last frame to process. Default: -1\n" - "Frame numbering starts at 1. The set of frames to be processed includes " - "the frame with the number and .\n" - "--interval(int): Interval specifies with what ratio the number of frames " - "should be increased or decreased with.\n" - "If you set to a positive number, frames between and " - "will be inserted times." - " If you set to a negative number then the amount of frames " - "between and will be decreased with a ratio of abs(interval)." - " Set interval=-1 if every frame between and should be " - "deleted. Set interval=-2 if every second frame should be deleted, and so " - "on. Frame numbering between and starts with 1 and frames with" - " number n where (n - 1) % interval == 0 will be kept.\n" - "Example 1:\n" - "If one clip has 10 frames (1 to 10) and you specify =4, =7 and " - "interval=2, then you will get a clip that contains frame " - "1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9 and 10.\n" - "Example 2:\n" - "If you specify f=4, l=7 and interval=-1, then you will get a clip that" - " contains frame 1, 2, 3, 8, 9 and 10.\n" - "Example 3:\n" - "If one clip has 10 frames (1 to 10), and you specify f=1, l=10 and " - " interval=-4, then you will get a clip that contains frame " - "1, 5 and 9.\n" - "No interpolation is done when up-sampling." - " Default: -1\n" - "--out_path(string): The output file to which frames are written." - " Default: output.yuv\n"; + std::string usage = + "Deletes a series of frames in a yuv file." + " Only I420 is supported!\n" + "Example usage:\n" + + program_name + + " --in_path=input.yuv --width=320 --height=240 --f=60 --interval=1 " + "--l=120" + " --out_path=edited_clip.yuv\n" + "Command line flags:\n" + "--in_path(string): Path and filename to the input file\n" + "--width(int): Width in pixels of the frames in the input file." + " Default: -1\n" + "--height(int): Height in pixels of the frames in the input file." + " Default: -1\n" + "--f(int): First frame to process. Default: -1\n" + "--l(int): Last frame to process. Default: -1\n" + "Frame numbering starts at 1. The set of frames to be processed includes " + "the frame with the number and .\n" + "--interval(int): Interval specifies with what ratio the number of " + "frames " + "should be increased or decreased with.\n" + "If you set to a positive number, frames between and " + "will be inserted times." + " If you set to a negative number then the amount of frames " + "between and will be decreased with a ratio of abs(interval)." + " Set interval=-1 if every frame between and should be " + "deleted. Set interval=-2 if every second frame should be deleted, and " + "so " + "on. Frame numbering between and starts with 1 and frames with" + " number n where (n - 1) % interval == 0 will be kept.\n" + "Example 1:\n" + "If one clip has 10 frames (1 to 10) and you specify =4, =7 and " + "interval=2, then you will get a clip that contains frame " + "1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9 and 10.\n" + "Example 2:\n" + "If you specify f=4, l=7 and interval=-1, then you will get a clip that" + " contains frame 1, 2, 3, 8, 9 and 10.\n" + "Example 3:\n" + "If one clip has 10 frames (1 to 10), and you specify f=1, l=10 and " + " interval=-4, then you will get a clip that contains frame " + "1, 5 and 9.\n" + "No interpolation is done when up-sampling." + " Default: -1\n" + "--out_path(string): The output file to which frames are written." + " Default: output.yuv\n"; webrtc::test::CommandLineParser parser; diff --git a/rtc_tools/frame_editing/frame_editing_lib.cc b/rtc_tools/frame_editing/frame_editing_lib.cc index 5af0184567..4418214b3e 100644 --- a/rtc_tools/frame_editing/frame_editing_lib.cc +++ b/rtc_tools/frame_editing/frame_editing_lib.cc @@ -20,15 +20,19 @@ namespace webrtc { -int EditFrames(const std::string& in_path, int width, int height, - int first_frame_to_process, int interval, - int last_frame_to_process, const std::string& out_path) { +int EditFrames(const std::string& in_path, + int width, + int height, + int first_frame_to_process, + int interval, + int last_frame_to_process, + const std::string& out_path) { if (last_frame_to_process < first_frame_to_process) { fprintf(stderr, "The set of frames to cut is empty! (l < f)\n"); return -10; } - FILE* in_fid = fopen(in_path.c_str() , "rb"); + FILE* in_fid = fopen(in_path.c_str(), "rb"); if (!in_fid) { fprintf(stderr, "Could not read input file: %s.\n", in_path.c_str()); return -11; @@ -51,8 +55,8 @@ int EditFrames(const std::string& in_path, int width, int height, int num_frames_read_between = 0; size_t num_bytes_read; - while ((num_bytes_read = fread(temp_buffer.get(), 1, frame_length, in_fid)) - == frame_length) { + while ((num_bytes_read = fread(temp_buffer.get(), 1, frame_length, in_fid)) == + frame_length) { num_frames_read++; if ((num_frames_read < first_frame_to_process) || (last_frame_to_process < num_frames_read)) { diff --git a/rtc_tools/frame_editing/frame_editing_lib.h b/rtc_tools/frame_editing/frame_editing_lib.h index a805a117ed..91eaa3bfec 100644 --- a/rtc_tools/frame_editing/frame_editing_lib.h +++ b/rtc_tools/frame_editing/frame_editing_lib.h @@ -31,9 +31,13 @@ namespace webrtc { // 1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9 and 10. // No interpolation is done when up-sampling. -int EditFrames(const std::string& in_path, int width, int height, - int first_frame_to_process, int interval, - int last_frame_to_process, const std::string& out_path); +int EditFrames(const std::string& in_path, + int width, + int height, + int first_frame_to_process, + int interval, + int last_frame_to_process, + const std::string& out_path); } // namespace webrtc #endif // RTC_TOOLS_FRAME_EDITING_FRAME_EDITING_LIB_H_ diff --git a/rtc_tools/frame_editing/frame_editing_unittest.cc b/rtc_tools/frame_editing/frame_editing_unittest.cc index 2cca308638..e8261b5664 100644 --- a/rtc_tools/frame_editing/frame_editing_unittest.cc +++ b/rtc_tools/frame_editing/frame_editing_unittest.cc @@ -63,14 +63,13 @@ class FrameEditingTest : public ::testing::Test { if (!feof(ref_video_fid)) { EXPECT_EQ(kFrameSize, num_bytes_read_); } - num_bytes_read_ = fread(test_buffer->get(), 1, kFrameSize, - test_video_fid); + num_bytes_read_ = + fread(test_buffer->get(), 1, kFrameSize, test_video_fid); if (!feof(test_video_fid)) { EXPECT_EQ(kFrameSize, num_bytes_read_); } if (!feof(test_video_fid) && !feof(test_video_fid)) { - EXPECT_EQ(0, memcmp(ref_buffer->get(), test_buffer->get(), - kFrameSize)); + EXPECT_EQ(0, memcmp(ref_buffer->get(), test_buffer->get(), kFrameSize)); } } // There should not be anything left in either stream. @@ -91,26 +90,26 @@ TEST_F(FrameEditingTest, ValidInPath) { const int kInterval = -1; const int kLastFrameToProcess = 240; - int result = EditFrames(reference_video_, kWidth, kHeight, - kFirstFrameToProcess, kInterval, kLastFrameToProcess, - test_video_); + int result = + EditFrames(reference_video_, kWidth, kHeight, kFirstFrameToProcess, + kInterval, kLastFrameToProcess, test_video_); EXPECT_EQ(0, result); for (int i = 1; i < kFirstFrameToProcess; ++i) { - num_bytes_read_ = fread(original_buffer_.get(), 1, kFrameSize, - original_fid_); + num_bytes_read_ = + fread(original_buffer_.get(), 1, kFrameSize, original_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); num_bytes_read_ = fread(edited_buffer_.get(), 1, kFrameSize, edited_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); - EXPECT_EQ(0, memcmp(original_buffer_.get(), edited_buffer_.get(), - kFrameSize)); + EXPECT_EQ(0, + memcmp(original_buffer_.get(), edited_buffer_.get(), kFrameSize)); } // Do not compare the frames that have been cut. for (int i = kFirstFrameToProcess; i <= kLastFrameToProcess; ++i) { - num_bytes_read_ = fread(original_buffer_.get(), 1, kFrameSize, - original_fid_); + num_bytes_read_ = + fread(original_buffer_.get(), 1, kFrameSize, original_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); } CompareToTheEnd(edited_fid_, original_fid_, &original_buffer_, @@ -122,9 +121,9 @@ TEST_F(FrameEditingTest, EmptySetToCut) { const int kInterval = -1; const int kLastFrameToProcess = 1; - int result = EditFrames(reference_video_, kWidth, kHeight, - kFirstFrameToProcess, kInterval, kLastFrameToProcess, - test_video_); + int result = + EditFrames(reference_video_, kWidth, kHeight, kFirstFrameToProcess, + kInterval, kLastFrameToProcess, test_video_); EXPECT_EQ(-10, result); } @@ -145,9 +144,9 @@ TEST_F(FrameEditingTest, DeletingEverySecondFrame) { const int kInterval = -2; const int kLastFrameToProcess = 10000; // Set kLastFrameToProcess to a large value so that all frame are processed. - int result = EditFrames(reference_video_, kWidth, kHeight, - kFirstFrameToProcess, kInterval, kLastFrameToProcess, - test_video_); + int result = + EditFrames(reference_video_, kWidth, kHeight, kFirstFrameToProcess, + kInterval, kLastFrameToProcess, test_video_); EXPECT_EQ(0, result); while (!feof(original_fid_) && !feof(edited_fid_)) { @@ -162,14 +161,13 @@ TEST_F(FrameEditingTest, DeletingEverySecondFrame) { // every second frame. // num_frames_read_ - 1 because we have deleted frame number 2, 4 , 6 etc. if ((num_frames_read_ - 1) % kInterval == -1) { - num_bytes_read_ = fread(edited_buffer_.get(), 1, kFrameSize, - edited_fid_); + num_bytes_read_ = fread(edited_buffer_.get(), 1, kFrameSize, edited_fid_); if (!feof(edited_fid_)) { EXPECT_EQ(kFrameSize, num_bytes_read_); } if (!feof(original_fid_) && !feof(edited_fid_)) { - EXPECT_EQ(0, memcmp(original_buffer_.get(), - edited_buffer_.get(), kFrameSize)); + EXPECT_EQ(0, memcmp(original_buffer_.get(), edited_buffer_.get(), + kFrameSize)); } } } @@ -180,33 +178,32 @@ TEST_F(FrameEditingTest, RepeatFrames) { const int kInterval = 2; const int kLastFrameToProcess = 240; - int result = EditFrames(reference_video_, kWidth, kHeight, - kFirstFrameToProcess, kInterval, kLastFrameToProcess, - test_video_); + int result = + EditFrames(reference_video_, kWidth, kHeight, kFirstFrameToProcess, + kInterval, kLastFrameToProcess, test_video_); EXPECT_EQ(0, result); for (int i = 1; i < kFirstFrameToProcess; ++i) { - num_bytes_read_ = fread(original_buffer_.get(), 1, kFrameSize, - original_fid_); + num_bytes_read_ = + fread(original_buffer_.get(), 1, kFrameSize, original_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); num_bytes_read_ = fread(edited_buffer_.get(), 1, kFrameSize, edited_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); - EXPECT_EQ(0, memcmp(original_buffer_.get(), edited_buffer_.get(), - kFrameSize)); + EXPECT_EQ(0, + memcmp(original_buffer_.get(), edited_buffer_.get(), kFrameSize)); } // Do not compare the frames that have been repeated. for (int i = kFirstFrameToProcess; i <= kLastFrameToProcess; ++i) { - num_bytes_read_ = fread(original_buffer_.get(), 1, kFrameSize, - original_fid_); + num_bytes_read_ = + fread(original_buffer_.get(), 1, kFrameSize, original_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); for (int i = 1; i <= kInterval; ++i) { - num_bytes_read_ = fread(edited_buffer_.get(), 1, kFrameSize, - edited_fid_); + num_bytes_read_ = fread(edited_buffer_.get(), 1, kFrameSize, edited_fid_); EXPECT_EQ(kFrameSize, num_bytes_read_); - EXPECT_EQ(0, memcmp(original_buffer_.get(), edited_buffer_.get(), - kFrameSize)); + EXPECT_EQ( + 0, memcmp(original_buffer_.get(), edited_buffer_.get(), kFrameSize)); } } CompareToTheEnd(edited_fid_, original_fid_, &original_buffer_, diff --git a/rtc_tools/network_tester/network_tester_unittest.cc b/rtc_tools/network_tester/network_tester_unittest.cc index b60a712746..c4c9e0c9a2 100644 --- a/rtc_tools/network_tester/network_tester_unittest.cc +++ b/rtc_tools/network_tester/network_tester_unittest.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifdef WEBRTC_NETWORK_TESTER_TEST_ENABLED #include "rtc_tools/network_tester/test_controller.h" diff --git a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc index 0fefb5769a..dc63aca9d7 100644 --- a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc +++ b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc @@ -21,8 +21,11 @@ #define MAX_NUM_FRAMES_PER_FILE INT_MAX -void CompareFiles(const char* reference_file_name, const char* test_file_name, - const char* results_file_name, int width, int height) { +void CompareFiles(const char* reference_file_name, + const char* test_file_name, + const char* results_file_name, + int width, + int height) { // Check if the reference_file_name ends with "y4m". bool y4m_mode = false; if (std::string(reference_file_name).find("y4m") != std::string::npos) { @@ -39,13 +42,15 @@ void CompareFiles(const char* reference_file_name, const char* test_file_name, bool read_result = true; for (int frame_counter = 0; frame_counter < MAX_NUM_FRAMES_PER_FILE; - ++frame_counter) { - read_result &= (y4m_mode) ? webrtc::test::ExtractFrameFromY4mFile( - reference_file_name, width, height, frame_counter, ref_frame): - webrtc::test::ExtractFrameFromYuvFile(reference_file_name, width, - height, frame_counter, ref_frame); - read_result &= webrtc::test::ExtractFrameFromYuvFile(test_file_name, width, - height, frame_counter, test_frame); + ++frame_counter) { + read_result &= + (y4m_mode) + ? webrtc::test::ExtractFrameFromY4mFile( + reference_file_name, width, height, frame_counter, ref_frame) + : webrtc::test::ExtractFrameFromYuvFile( + reference_file_name, width, height, frame_counter, ref_frame); + read_result &= webrtc::test::ExtractFrameFromYuvFile( + test_file_name, width, height, frame_counter, test_frame); if (!read_result) break; @@ -82,9 +87,12 @@ void CompareFiles(const char* reference_file_name, const char* test_file_name, */ int main(int argc, char* argv[]) { std::string program_name = argv[0]; - std::string usage = "Runs PSNR and SSIM on two I420 videos and write the" + std::string usage = + "Runs PSNR and SSIM on two I420 videos and write the" "results in a file.\n" - "Example usage:\n" + program_name + " --reference_file=ref.yuv " + "Example usage:\n" + + program_name + + " --reference_file=ref.yuv " "--test_file=test.yuv --results_file=results.txt --width=320 " "--height=240\n" "Command line flags:\n" diff --git a/rtc_tools/sanitizers_unittest.cc b/rtc_tools/sanitizers_unittest.cc index 4cdf5fd56f..69c11fefa1 100644 --- a/rtc_tools/sanitizers_unittest.cc +++ b/rtc_tools/sanitizers_unittest.cc @@ -39,7 +39,7 @@ TEST(SanitizersDeathTest, MemorySanitizer) { #if defined(ADDRESS_SANITIZER) void HeapUseAfterFree() { - char *buf = new char[2]; + char* buf = new char[2]; delete[] buf; buf[0] = buf[1]; } @@ -61,8 +61,7 @@ struct Base { virtual void f() {} virtual ~Base() {} }; -struct Derived : public Base { -}; +struct Derived : public Base {}; void InvalidVptr() { Base b; @@ -71,7 +70,12 @@ void InvalidVptr() { } TEST(SanitizersDeathTest, UndefinedSanitizer) { - EXPECT_DEATH({ SignedIntegerOverflow(); InvalidVptr(); }, "runtime error"); + EXPECT_DEATH( + { + SignedIntegerOverflow(); + InvalidVptr(); + }, + "runtime error"); } #endif @@ -79,8 +83,7 @@ TEST(SanitizersDeathTest, UndefinedSanitizer) { class IncrementThread : public Thread { public: explicit IncrementThread(int* value) - : Thread(rtc::MakeUnique()), - value_(value) {} + : Thread(rtc::MakeUnique()), value_(value) {} void Run() override { ++*value_; @@ -88,9 +91,7 @@ class IncrementThread : public Thread { } // Un-protect Thread::Join for the test. - void Join() { - Thread::Join(); - } + void Join() { Thread::Join(); } private: int* value_; diff --git a/rtc_tools/simple_command_line_parser.cc b/rtc_tools/simple_command_line_parser.cc index b20ba6481f..c34aa90556 100644 --- a/rtc_tools/simple_command_line_parser.cc +++ b/rtc_tools/simple_command_line_parser.cc @@ -22,7 +22,7 @@ CommandLineParser::CommandLineParser() {} CommandLineParser::~CommandLineParser() {} void CommandLineParser::Init(int argc, char** argv) { - args_ = std::vector (argv + 1, argv + argc); + args_ = std::vector(argv + 1, argv + argc); } bool CommandLineParser::IsStandaloneFlag(std::string flag) { diff --git a/rtc_tools/simple_command_line_parser_unittest.cc b/rtc_tools/simple_command_line_parser_unittest.cc index d98868aa2e..a94f9921e9 100644 --- a/rtc_tools/simple_command_line_parser_unittest.cc +++ b/rtc_tools/simple_command_line_parser_unittest.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "test/gtest.h" #include "rtc_tools/simple_command_line_parser.h" +#include "test/gtest.h" namespace webrtc { namespace test { diff --git a/rtc_tools/unpack_aecdump/unpack.cc b/rtc_tools/unpack_aecdump/unpack.cc index 2b474bfa01..0224ad5bb7 100644 --- a/rtc_tools/unpack_aecdump/unpack.cc +++ b/rtc_tools/unpack_aecdump/unpack.cc @@ -30,9 +30,11 @@ RTC_POP_IGNORING_WUNDEF() // TODO(andrew): unpack more of the data. DEFINE_string(input_file, "input", "The name of the input stream file."); -DEFINE_string(output_file, "ref_out", +DEFINE_string(output_file, + "ref_out", "The name of the reference output stream file."); -DEFINE_string(reverse_file, "reverse", +DEFINE_string(reverse_file, + "reverse", "The name of the reverse input stream file."); DEFINE_string(delay_file, "delay.int32", "The name of the delay file."); DEFINE_string(drift_file, "drift.int32", "The name of the drift file."); @@ -42,16 +44,15 @@ DEFINE_string(callorder_file, "callorder", "The name of the render/capture call order file."); DEFINE_string(settings_file, "settings.txt", "The name of the settings file."); -DEFINE_bool(full, false, - "Unpack the full set of files (normally not needed)."); +DEFINE_bool(full, false, "Unpack the full set of files (normally not needed)."); DEFINE_bool(raw, false, "Write raw data instead of a WAV file."); DEFINE_bool(text, false, "Write non-audio files as text files instead of binary files."); DEFINE_bool(help, false, "Print this message."); -#define PRINT_CONFIG(field_name) \ - if (msg.has_##field_name()) { \ +#define PRINT_CONFIG(field_name) \ + if (msg.has_##field_name()) { \ fprintf(settings_file, " " #field_name ": %d\n", msg.field_name()); \ } @@ -69,7 +70,9 @@ using audioproc::Init; namespace { -void WriteData(const void* data, size_t size, FILE* file, +void WriteData(const void* data, + size_t size, + FILE* file, const std::string& filename) { if (fwrite(data, size, 1, file) != 1) { printf("Error when writing to %s\n", filename.c_str()); @@ -88,11 +91,13 @@ void WriteCallOrderData(const bool render_call, int do_main(int argc, char* argv[]) { std::string program_name = argv[0]; - std::string usage = "Commandline tool to unpack audioproc debug files.\n" - "Example usage:\n" + program_name + " debug_dump.pb\n"; + std::string usage = + "Commandline tool to unpack audioproc debug files.\n" + "Example usage:\n" + + program_name + " debug_dump.pb\n"; - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || - FLAG_help || argc < 2) { + if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || + argc < 2) { printf("%s", usage.c_str()); if (FLAG_help) { rtc::FlagList::Print(nullptr, false); @@ -133,8 +138,8 @@ int do_main(int argc, char* argv[]) { const ReverseStream msg = event_msg.reverse_stream(); if (msg.has_data()) { if (FLAG_raw && !reverse_raw_file) { - reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) + - ".pcm")); + reverse_raw_file.reset( + new RawFile(std::string(FLAG_reverse_file) + ".pcm")); } // TODO(aluebs): Replace "num_reverse_channels * // reverse_samples_per_channel" with "msg.data().size() / @@ -142,22 +147,19 @@ int do_main(int argc, char* argv[]) { // it into stable: https://webrtc-codereview.appspot.com/15299004/ WriteIntData(reinterpret_cast(msg.data().data()), num_reverse_channels * reverse_samples_per_channel, - reverse_wav_file.get(), - reverse_raw_file.get()); + reverse_wav_file.get(), reverse_raw_file.get()); } else if (msg.channel_size() > 0) { if (FLAG_raw && !reverse_raw_file) { - reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) + - ".float")); + reverse_raw_file.reset( + new RawFile(std::string(FLAG_reverse_file) + ".float")); } std::unique_ptr data( - new const float* [num_reverse_channels]); + new const float*[num_reverse_channels]); for (size_t i = 0; i < num_reverse_channels; ++i) { data[i] = reinterpret_cast(msg.channel(i).data()); } - WriteFloatData(data.get(), - reverse_samples_per_channel, - num_reverse_channels, - reverse_wav_file.get(), + WriteFloatData(data.get(), reverse_samples_per_channel, + num_reverse_channels, reverse_wav_file.get(), reverse_raw_file.get()); } if (FLAG_full) { @@ -174,54 +176,48 @@ int do_main(int argc, char* argv[]) { const Stream msg = event_msg.stream(); if (msg.has_input_data()) { if (FLAG_raw && !input_raw_file) { - input_raw_file.reset(new RawFile(std::string(FLAG_input_file) + - ".pcm")); + input_raw_file.reset( + new RawFile(std::string(FLAG_input_file) + ".pcm")); } WriteIntData(reinterpret_cast(msg.input_data().data()), num_input_channels * input_samples_per_channel, - input_wav_file.get(), - input_raw_file.get()); + input_wav_file.get(), input_raw_file.get()); } else if (msg.input_channel_size() > 0) { if (FLAG_raw && !input_raw_file) { - input_raw_file.reset(new RawFile(std::string(FLAG_input_file) + - ".float")); + input_raw_file.reset( + new RawFile(std::string(FLAG_input_file) + ".float")); } std::unique_ptr data( - new const float* [num_input_channels]); + new const float*[num_input_channels]); for (size_t i = 0; i < num_input_channels; ++i) { data[i] = reinterpret_cast(msg.input_channel(i).data()); } - WriteFloatData(data.get(), - input_samples_per_channel, - num_input_channels, - input_wav_file.get(), + WriteFloatData(data.get(), input_samples_per_channel, + num_input_channels, input_wav_file.get(), input_raw_file.get()); } if (msg.has_output_data()) { if (FLAG_raw && !output_raw_file) { - output_raw_file.reset(new RawFile(std::string(FLAG_output_file) + - ".pcm")); + output_raw_file.reset( + new RawFile(std::string(FLAG_output_file) + ".pcm")); } WriteIntData(reinterpret_cast(msg.output_data().data()), num_output_channels * output_samples_per_channel, - output_wav_file.get(), - output_raw_file.get()); + output_wav_file.get(), output_raw_file.get()); } else if (msg.output_channel_size() > 0) { if (FLAG_raw && !output_raw_file) { - output_raw_file.reset(new RawFile(std::string(FLAG_output_file) + - ".float")); + output_raw_file.reset( + new RawFile(std::string(FLAG_output_file) + ".float")); } std::unique_ptr data( - new const float* [num_output_channels]); + new const float*[num_output_channels]); for (size_t i = 0; i < num_output_channels; ++i) { data[i] = reinterpret_cast(msg.output_channel(i).data()); } - WriteFloatData(data.get(), - output_samples_per_channel, - num_output_channels, - output_wav_file.get(), + WriteFloatData(data.get(), output_samples_per_channel, + num_output_channels, output_wav_file.get(), output_raw_file.get()); } @@ -316,8 +312,7 @@ int do_main(int argc, char* argv[]) { int output_sample_rate = msg.output_sample_rate(); fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); int reverse_sample_rate = msg.reverse_sample_rate(); - fprintf(settings_file, - " Reverse sample rate: %d\n", + fprintf(settings_file, " Reverse sample rate: %d\n", reverse_sample_rate); num_input_channels = msg.num_input_channels(); fprintf(settings_file, " Input channels: %" PRIuS "\n", @@ -340,8 +335,7 @@ int do_main(int argc, char* argv[]) { reverse_samples_per_channel = static_cast(reverse_sample_rate / 100); - input_samples_per_channel = - static_cast(input_sample_rate / 100); + input_samples_per_channel = static_cast(input_sample_rate / 100); output_samples_per_channel = static_cast(output_sample_rate / 100); @@ -350,19 +344,16 @@ int do_main(int argc, char* argv[]) { // their sample rate or number of channels. std::stringstream reverse_name; reverse_name << FLAG_reverse_file << frame_count << ".wav"; - reverse_wav_file.reset(new WavWriter(reverse_name.str(), - reverse_sample_rate, - num_reverse_channels)); + reverse_wav_file.reset(new WavWriter( + reverse_name.str(), reverse_sample_rate, num_reverse_channels)); std::stringstream input_name; input_name << FLAG_input_file << frame_count << ".wav"; - input_wav_file.reset(new WavWriter(input_name.str(), - input_sample_rate, + input_wav_file.reset(new WavWriter(input_name.str(), input_sample_rate, num_input_channels)); std::stringstream output_name; output_name << FLAG_output_file << frame_count << ".wav"; - output_wav_file.reset(new WavWriter(output_name.str(), - output_sample_rate, - num_output_channels)); + output_wav_file.reset(new WavWriter( + output_name.str(), output_sample_rate, num_output_channels)); std::stringstream callorder_name; callorder_name << FLAG_callorder_file << frame_count << ".char"; diff --git a/sdk/android/src/jni/androidmediadecoder.cc b/sdk/android/src/jni/androidmediadecoder.cc index dac45fa37b..a5f47da4af 100644 --- a/sdk/android/src/jni/androidmediadecoder.cc +++ b/sdk/android/src/jni/androidmediadecoder.cc @@ -59,20 +59,21 @@ enum { kMaxWarningLogFrames = 2 }; class MediaCodecVideoDecoder : public VideoDecoder, public rtc::MessageHandler { public: - explicit MediaCodecVideoDecoder( - JNIEnv* jni, VideoCodecType codecType, jobject render_egl_context); + explicit MediaCodecVideoDecoder(JNIEnv* jni, + VideoCodecType codecType, + jobject render_egl_context); ~MediaCodecVideoDecoder() override; - int32_t InitDecode(const VideoCodec* codecSettings, int32_t numberOfCores) - override; + int32_t InitDecode(const VideoCodec* codecSettings, + int32_t numberOfCores) override; - int32_t Decode( - const EncodedImage& inputImage, bool missingFrames, - const CodecSpecificInfo* codecSpecificInfo = NULL, - int64_t renderTimeMs = -1) override; + int32_t Decode(const EncodedImage& inputImage, + bool missingFrames, + const CodecSpecificInfo* codecSpecificInfo = NULL, + int64_t renderTimeMs = -1) override; - int32_t RegisterDecodeCompleteCallback(DecodedImageCallback* callback) - override; + int32_t RegisterDecodeCompleteCallback( + DecodedImageCallback* callback) override; int32_t Release() override; @@ -113,15 +114,15 @@ class MediaCodecVideoDecoder : public VideoDecoder, public rtc::MessageHandler { I420BufferPool decoded_frame_pool_; DecodedImageCallback* callback_; int frames_received_; // Number of frames received by decoder. - int frames_decoded_; // Number of frames decoded by decoder. + int frames_decoded_; // Number of frames decoded by decoder. // Number of decoded frames for which log information is displayed. int frames_decoded_logged_; int64_t start_time_ms_; // Start time for statistics. int current_frames_; // Number of frames in the current statistics interval. - int current_bytes_; // Encoded bytes in the current statistics interval. + int current_bytes_; // Encoded bytes in the current statistics interval. int current_decoding_time_ms_; // Overall decoding time in the current second - int current_delay_time_ms_; // Overall delay time in the current second. - int32_t max_pending_frames_; // Maximum number of pending input frames. + int current_delay_time_ms_; // Overall delay time in the current second. + int32_t max_pending_frames_; // Maximum number of pending input frames. H264BitstreamParser h264_bitstream_parser_; std::deque> pending_frame_qps_; @@ -162,7 +163,7 @@ MediaCodecVideoDecoder::~MediaCodecVideoDecoder() { } int32_t MediaCodecVideoDecoder::InitDecode(const VideoCodec* inst, - int32_t numberOfCores) { + int32_t numberOfCores) { ALOGD << "InitDecode."; if (inst == NULL) { ALOGE << "NULL VideoCodec instance"; @@ -270,8 +271,8 @@ int32_t MediaCodecVideoDecoder::ResetDecodeOnCodecThread() { ScopedLocalRefFrame local_ref_frame(jni); ALOGD << "ResetDecodeOnCodecThread Type: " << static_cast(codecType_) << ". " << codec_.width << " x " << codec_.height; - ALOGD << " Frames received: " << frames_received_ << - ". Frames decoded: " << frames_decoded_; + ALOGD << " Frames received: " << frames_received_ + << ". Frames decoded: " << frames_decoded_; inited_ = false; rtc::MessageQueueManager::Clear(this); @@ -304,8 +305,8 @@ int32_t MediaCodecVideoDecoder::ReleaseOnCodecThread() { } CheckOnCodecThread(); JNIEnv* jni = AttachCurrentThreadIfNeeded(); - ALOGD << "DecoderReleaseOnCodecThread: Frames received: " << - frames_received_ << ". Frames decoded: " << frames_decoded_; + ALOGD << "DecoderReleaseOnCodecThread: Frames received: " << frames_received_ + << ". Frames decoded: " << frames_decoded_; ScopedLocalRefFrame local_ref_frame(jni); input_buffers_.clear(); Java_MediaCodecVideoDecoder_release(jni, j_media_codec_video_decoder_); @@ -326,8 +327,8 @@ void MediaCodecVideoDecoder::CheckOnCodecThread() { void MediaCodecVideoDecoder::EnableFrameLogOnWarning() { // Log next 2 output frames. - frames_decoded_logged_ = std::max( - frames_decoded_logged_, frames_decoded_ + kMaxWarningLogFrames); + frames_decoded_logged_ = + std::max(frames_decoded_logged_, frames_decoded_ + kMaxWarningLogFrames); } int32_t MediaCodecVideoDecoder::ProcessHWErrorOnCodecThread() { @@ -381,10 +382,10 @@ int32_t MediaCodecVideoDecoder::Decode( // Check if encoded frame dimension has changed. if ((inputImage._encodedWidth * inputImage._encodedHeight > 0) && (inputImage._encodedWidth != codec_.width || - inputImage._encodedHeight != codec_.height)) { - ALOGW << "Input resolution changed from " << - codec_.width << " x " << codec_.height << " to " << - inputImage._encodedWidth << " x " << inputImage._encodedHeight; + inputImage._encodedHeight != codec_.height)) { + ALOGW << "Input resolution changed from " << codec_.width << " x " + << codec_.height << " to " << inputImage._encodedWidth << " x " + << inputImage._encodedHeight; codec_.width = inputImage._encodedWidth; codec_.height = inputImage._encodedHeight; int32_t ret; @@ -437,22 +438,22 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( if (codecType_ == kVideoCodecH264 && frames_received_ > frames_decoded_ + max_pending_frames_) { // Print warning for H.264 only - for VP8/VP9 one frame delay is ok. - ALOGW << "Decoder is too far behind. Try to drain. Received: " << - frames_received_ << ". Decoded: " << frames_decoded_; + ALOGW << "Decoder is too far behind. Try to drain. Received: " + << frames_received_ << ". Decoded: " << frames_decoded_; EnableFrameLogOnWarning(); } const int64 drain_start = rtc::TimeMillis(); while ((frames_received_ > frames_decoded_ + max_pending_frames_) && (rtc::TimeMillis() - drain_start) < kMediaCodecTimeoutMs) { if (!DeliverPendingOutputs(jni, kMediaCodecPollMs)) { - ALOGE << "DeliverPendingOutputs error. Frames received: " << - frames_received_ << ". Frames decoded: " << frames_decoded_; + ALOGE << "DeliverPendingOutputs error. Frames received: " + << frames_received_ << ". Frames decoded: " << frames_decoded_; return ProcessHWErrorOnCodecThread(); } } if (frames_received_ > frames_decoded_ + max_pending_frames_) { - ALOGE << "Output buffer dequeue timeout. Frames received: " << - frames_received_ << ". Frames decoded: " << frames_decoded_; + ALOGE << "Output buffer dequeue timeout. Frames received: " + << frames_received_ << ". Frames decoded: " << frames_decoded_; return ProcessHWErrorOnCodecThread(); } @@ -460,13 +461,13 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( int j_input_buffer_index = Java_MediaCodecVideoDecoder_dequeueInputBuffer( jni, j_media_codec_video_decoder_); if (CheckException(jni) || j_input_buffer_index < 0) { - ALOGE << "dequeueInputBuffer error: " << j_input_buffer_index << - ". Retry DeliverPendingOutputs."; + ALOGE << "dequeueInputBuffer error: " << j_input_buffer_index + << ". Retry DeliverPendingOutputs."; EnableFrameLogOnWarning(); // Try to drain the decoder. if (!DeliverPendingOutputs(jni, kMediaCodecPollMs)) { - ALOGE << "DeliverPendingOutputs error. Frames received: " << - frames_received_ << ". Frames decoded: " << frames_decoded_; + ALOGE << "DeliverPendingOutputs error. Frames received: " + << frames_received_ << ". Frames decoded: " << frames_decoded_; return ProcessHWErrorOnCodecThread(); } // Try dequeue input buffer one last time. @@ -483,11 +484,11 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( uint8_t* buffer = reinterpret_cast(jni->GetDirectBufferAddress(j_input_buffer)); RTC_CHECK(buffer) << "Indirect buffer??"; - size_t buffer_capacity = rtc::dchecked_cast( - jni->GetDirectBufferCapacity(j_input_buffer)); + size_t buffer_capacity = + rtc::dchecked_cast(jni->GetDirectBufferCapacity(j_input_buffer)); if (CheckException(jni) || buffer_capacity < inputImage._length) { - ALOGE << "Input frame size "<< inputImage._length << - " is bigger than buffer size " << buffer_capacity; + ALOGE << "Input frame size " << inputImage._length + << " is bigger than buffer size " << buffer_capacity; return ProcessHWErrorOnCodecThread(); } jlong presentation_timestamp_us = static_cast( @@ -495,11 +496,11 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( memcpy(buffer, inputImage._buffer, inputImage._length); if (frames_decoded_ < frames_decoded_logged_) { - ALOGD << "Decoder frame in # " << frames_received_ << - ". Type: " << inputImage._frameType << - ". Buffer # " << j_input_buffer_index << - ". TS: " << presentation_timestamp_us / 1000 << - ". Size: " << inputImage._length; + ALOGD << "Decoder frame in # " << frames_received_ + << ". Type: " << inputImage._frameType << ". Buffer # " + << j_input_buffer_index + << ". TS: " << presentation_timestamp_us / 1000 + << ". Size: " << inputImage._length; } // Save input image timestamps for later output. @@ -540,8 +541,8 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( return WEBRTC_VIDEO_CODEC_OK; } -bool MediaCodecVideoDecoder::DeliverPendingOutputs( - JNIEnv* jni, int dequeue_timeout_ms) { +bool MediaCodecVideoDecoder::DeliverPendingOutputs(JNIEnv* jni, + int dequeue_timeout_ms) { CheckOnCodecThread(); if (frames_received_ <= frames_decoded_) { // No need to query for output buffers - decoder is drained. @@ -638,8 +639,8 @@ bool MediaCodecVideoDecoder::DeliverPendingOutputs( jni, j_media_codec_video_decoder_); jobject output_buffer = jni->GetObjectArrayElement(output_buffers.obj(), output_buffer_index); - uint8_t* payload = reinterpret_cast(jni->GetDirectBufferAddress( - output_buffer)); + uint8_t* payload = + reinterpret_cast(jni->GetDirectBufferAddress(output_buffer)); if (CheckException(jni)) { return false; } @@ -665,15 +666,12 @@ bool MediaCodecVideoDecoder::DeliverPendingOutputs( (slice_height % 2 == 0) ? (height + 1) / 2 : height / 2; const int u_offset = uv_stride * slice_height / 2; const uint8_t* v_ptr = u_ptr + u_offset; - libyuv::CopyPlane(y_ptr, stride, - i420_buffer->MutableDataY(), i420_buffer->StrideY(), - width, height); - libyuv::CopyPlane(u_ptr, uv_stride, - i420_buffer->MutableDataU(), i420_buffer->StrideU(), - chroma_width, chroma_height); - libyuv::CopyPlane(v_ptr, uv_stride, - i420_buffer->MutableDataV(), i420_buffer->StrideV(), - chroma_width, chroma_height); + libyuv::CopyPlane(y_ptr, stride, i420_buffer->MutableDataY(), + i420_buffer->StrideY(), width, height); + libyuv::CopyPlane(u_ptr, uv_stride, i420_buffer->MutableDataU(), + i420_buffer->StrideU(), chroma_width, chroma_height); + libyuv::CopyPlane(v_ptr, uv_stride, i420_buffer->MutableDataV(), + i420_buffer->StrideV(), chroma_width, chroma_height); if (slice_height % 2 == 1) { RTC_CHECK_EQ(height, slice_height); // Duplicate the last chroma rows. @@ -707,12 +705,11 @@ bool MediaCodecVideoDecoder::DeliverPendingOutputs( } } if (frames_decoded_ < frames_decoded_logged_) { - ALOGD << "Decoder frame out # " << frames_decoded_ << - ". " << width << " x " << height << - ". Color: " << color_format << - ". TS: " << presentation_timestamps_ms << - ". DecTime: " << static_cast(decode_time_ms) << - ". DelayTime: " << static_cast(frame_delayed_ms); + ALOGD << "Decoder frame out # " << frames_decoded_ << ". " << width << " x " + << height << ". Color: " << color_format + << ". TS: " << presentation_timestamps_ms + << ". DecTime: " << static_cast(decode_time_ms) + << ". DelayTime: " << static_cast(frame_delayed_ms); } // Calculate and print decoding statistics - every 3 seconds. @@ -726,13 +723,13 @@ bool MediaCodecVideoDecoder::DeliverPendingOutputs( int current_bitrate = current_bytes_ * 8 / statistic_time_ms; int current_fps = (current_frames_ * 1000 + statistic_time_ms / 2) / statistic_time_ms; - ALOGD << "Frames decoded: " << frames_decoded_ << - ". Received: " << frames_received_ << - ". Bitrate: " << current_bitrate << " kbps" << - ". Fps: " << current_fps << - ". DecTime: " << (current_decoding_time_ms_ / current_frames_) << - ". DelayTime: " << (current_delay_time_ms_ / current_frames_) << - " for last " << statistic_time_ms << " ms."; + ALOGD << "Frames decoded: " << frames_decoded_ + << ". Received: " << frames_received_ + << ". Bitrate: " << current_bitrate << " kbps" + << ". Fps: " << current_fps + << ". DecTime: " << (current_decoding_time_ms_ / current_frames_) + << ". DelayTime: " << (current_delay_time_ms_ / current_frames_) + << " for last " << statistic_time_ms << " ms."; start_time_ms_ = rtc::TimeMillis(); current_frames_ = 0; current_bytes_ = 0; @@ -813,8 +810,8 @@ MediaCodecVideoDecoderFactory::~MediaCodecVideoDecoderFactory() { } } -void MediaCodecVideoDecoderFactory::SetEGLContext( - JNIEnv* jni, jobject egl_context) { +void MediaCodecVideoDecoderFactory::SetEGLContext(JNIEnv* jni, + jobject egl_context) { ALOGD << "MediaCodecVideoDecoderFactory::SetEGLContext"; if (egl_context_) { jni->DeleteGlobalRef(egl_context_); diff --git a/sdk/android/src/jni/androidmediaencoder.cc b/sdk/android/src/jni/androidmediaencoder.cc index 01097a99f9..de2743b6a5 100644 --- a/sdk/android/src/jni/androidmediaencoder.cc +++ b/sdk/android/src/jni/androidmediaencoder.cc @@ -76,7 +76,7 @@ __android_log_print(ANDROID_LOG_VERBOSE, TAG_ENCODER, __VA_ARGS__) #define ALOGW RTC_LOG_TAG(rtc::LS_WARNING, TAG_ENCODER) #define ALOGE RTC_LOG_TAG(rtc::LS_ERROR, TAG_ENCODER) -namespace { + namespace { // Maximum time limit between incoming frames before requesting a key frame. const int64_t kFrameDiffThresholdMs = 350; const int kMinKeyFrameInterval = 6; @@ -212,20 +212,20 @@ class MediaCodecVideoEncoder : public VideoEncoder { bool inited_; bool use_surface_; enum libyuv::FourCC encoder_fourcc_; // Encoder color space format. - uint32_t last_set_bitrate_kbps_; // Last-requested bitrate in kbps. - uint32_t last_set_fps_; // Last-requested frame rate. - int64_t current_timestamp_us_; // Current frame timestamps in us. - int frames_received_; // Number of frames received by encoder. - int frames_encoded_; // Number of frames encoded by encoder. - int frames_dropped_media_encoder_; // Number of frames dropped by encoder. + uint32_t last_set_bitrate_kbps_; // Last-requested bitrate in kbps. + uint32_t last_set_fps_; // Last-requested frame rate. + int64_t current_timestamp_us_; // Current frame timestamps in us. + int frames_received_; // Number of frames received by encoder. + int frames_encoded_; // Number of frames encoded by encoder. + int frames_dropped_media_encoder_; // Number of frames dropped by encoder. // Number of dropped frames caused by full queue. int consecutive_full_queue_frame_drops_; int64_t stat_start_time_ms_; // Start time for statistics. int current_frames_; // Number of frames in the current statistics interval. - int current_bytes_; // Encoded bytes in the current statistics interval. + int current_bytes_; // Encoded bytes in the current statistics interval. int current_acc_qp_; // Accumulated QP in the current statistics interval. int current_encoding_time_ms_; // Overall encoding time in the current second - int64_t last_input_timestamp_ms_; // Timestamp of last received yuv frame. + int64_t last_input_timestamp_ms_; // Timestamp of last received yuv frame. int64_t last_output_timestamp_ms_; // Timestamp of last encoded frame. // Holds the task while the polling loop is paused. std::unique_ptr encode_task_; @@ -753,16 +753,15 @@ bool MediaCodecVideoEncoder::MaybeReconfigureEncoder(JNIEnv* jni, frame.width() != width_ || frame.height() != height_; if (reconfigure_due_to_format) { - ALOGD << "Reconfigure encoder due to format change. " - << (use_surface_ ? - "Reconfiguring to encode from byte buffer." : - "Reconfiguring to encode from texture."); - LogStatistics(true); + ALOGD << "Reconfigure encoder due to format change. " + << (use_surface_ ? "Reconfiguring to encode from byte buffer." + : "Reconfiguring to encode from texture."); + LogStatistics(true); } if (reconfigure_due_to_size) { ALOGW << "Reconfigure encoder due to frame resolution change from " - << width_ << " x " << height_ << " to " << frame.width() << " x " - << frame.height(); + << width_ << " x " << height_ << " to " << frame.width() << " x " + << frame.height(); LogStatistics(true); width_ = frame.width(); height_ = frame.height(); @@ -1066,9 +1065,9 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) { H264::FindNaluIndices(payload, payload_size); if (nalu_idxs.empty()) { ALOGE << "Start code is not found!"; - ALOGE << "Data:" << image->_buffer[0] << " " << image->_buffer[1] - << " " << image->_buffer[2] << " " << image->_buffer[3] - << " " << image->_buffer[4] << " " << image->_buffer[5]; + ALOGE << "Data:" << image->_buffer[0] << " " << image->_buffer[1] + << " " << image->_buffer[2] << " " << image->_buffer[3] << " " + << image->_buffer[4] << " " << image->_buffer[5]; ProcessHWError(true /* reset_if_fallback_unavailable */); return false; } @@ -1122,21 +1121,21 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) { void MediaCodecVideoEncoder::LogStatistics(bool force_log) { int statistic_time_ms = rtc::TimeMillis() - stat_start_time_ms_; - if ((statistic_time_ms >= kMediaCodecStatisticsIntervalMs || force_log) - && statistic_time_ms > 0) { + if ((statistic_time_ms >= kMediaCodecStatisticsIntervalMs || force_log) && + statistic_time_ms > 0) { // Prevent division by zero. int current_frames_divider = current_frames_ != 0 ? current_frames_ : 1; int current_bitrate = current_bytes_ * 8 / statistic_time_ms; int current_fps = (current_frames_ * 1000 + statistic_time_ms / 2) / statistic_time_ms; - ALOGD << "Encoded frames: " << frames_encoded_ << - ". Bitrate: " << current_bitrate << - ", target: " << last_set_bitrate_kbps_ << " kbps" << - ", fps: " << current_fps << - ", encTime: " << (current_encoding_time_ms_ / current_frames_divider) << - ". QP: " << (current_acc_qp_ / current_frames_divider) << - " for last " << statistic_time_ms << " ms."; + ALOGD << "Encoded frames: " << frames_encoded_ + << ". Bitrate: " << current_bitrate + << ", target: " << last_set_bitrate_kbps_ << " kbps" + << ", fps: " << current_fps << ", encTime: " + << (current_encoding_time_ms_ / current_frames_divider) + << ". QP: " << (current_acc_qp_ / current_frames_divider) + << " for last " << statistic_time_ms << " ms."; stat_start_time_ms_ = rtc::TimeMillis(); current_frames_ = 0; current_bytes_ = 0; @@ -1274,8 +1273,8 @@ MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() { } } -void MediaCodecVideoEncoderFactory::SetEGLContext( - JNIEnv* jni, jobject egl_context) { +void MediaCodecVideoEncoderFactory::SetEGLContext(JNIEnv* jni, + jobject egl_context) { ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext"; if (egl_context_) { jni->DeleteGlobalRef(egl_context_); diff --git a/sdk/android/src/jni/androidvideotracksource.cc b/sdk/android/src/jni/androidvideotracksource.cc index 00a8e6dd13..1d75a4f817 100644 --- a/sdk/android/src/jni/androidvideotracksource.cc +++ b/sdk/android/src/jni/androidvideotracksource.cc @@ -23,10 +23,9 @@ namespace { const int kRequiredResolutionAlignment = 2; } // namespace -AndroidVideoTrackSource::AndroidVideoTrackSource( - rtc::Thread* signaling_thread, - JNIEnv* jni, - bool is_screencast) +AndroidVideoTrackSource::AndroidVideoTrackSource(rtc::Thread* signaling_thread, + JNIEnv* jni, + bool is_screencast) : AdaptedVideoTrackSource(kRequiredResolutionAlignment), signaling_thread_(signaling_thread), is_screencast_(is_screencast) { diff --git a/sdk/android/src/jni/jni_onload.cc b/sdk/android/src/jni/jni_onload.cc index 81cc4889c2..83c61d6a08 100644 --- a/sdk/android/src/jni/jni_onload.cc +++ b/sdk/android/src/jni/jni_onload.cc @@ -19,7 +19,7 @@ namespace webrtc { namespace jni { -extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { +extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved) { jint ret = InitGlobalJniVariables(jvm); RTC_DCHECK_GE(ret, 0); if (ret < 0) @@ -31,7 +31,7 @@ extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { return ret; } -extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM *jvm, void *reserved) { +extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM* jvm, void* reserved) { FreeGlobalClassReferenceHolder(); RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()"; } diff --git a/sdk/android/src/jni/videoencoderwrapper.cc b/sdk/android/src/jni/videoencoderwrapper.cc index f4f4347de4..ce48f56c56 100644 --- a/sdk/android/src/jni/videoencoderwrapper.cc +++ b/sdk/android/src/jni/videoencoderwrapper.cc @@ -291,9 +291,10 @@ void VideoEncoderWrapper::OnEncodedFrame(JNIEnv* jni, } }; - encoder_queue_->PostTask(Lambda{this, std::move(buffer_copy), - qp, encoded_width, encoded_height, capture_time_ns, frame_type, - rotation, complete_frame, &frame_extra_infos_, callback_}); + encoder_queue_->PostTask( + Lambda{this, std::move(buffer_copy), qp, encoded_width, encoded_height, + capture_time_ns, frame_type, rotation, complete_frame, + &frame_extra_infos_, callback_}); } int32_t VideoEncoderWrapper::HandleReturnCode(JNIEnv* jni, diff --git a/sdk/android/src/jni/videoframe.cc b/sdk/android/src/jni/videoframe.cc index b29e5cc4cb..309e2da80b 100644 --- a/sdk/android/src/jni/videoframe.cc +++ b/sdk/android/src/jni/videoframe.cc @@ -142,30 +142,60 @@ void Matrix::Rotate(VideoRotation rotation) { case kVideoRotation_0: break; case kVideoRotation_90: { - const float ROTATE_90[16] = - { elem_[4], elem_[5], elem_[6], elem_[7], - -elem_[0], -elem_[1], -elem_[2], -elem_[3], - elem_[8], elem_[9], elem_[10], elem_[11], - elem_[0] + elem_[12], elem_[1] + elem_[13], - elem_[2] + elem_[14], elem_[3] + elem_[15]}; + const float ROTATE_90[16] = {elem_[4], + elem_[5], + elem_[6], + elem_[7], + -elem_[0], + -elem_[1], + -elem_[2], + -elem_[3], + elem_[8], + elem_[9], + elem_[10], + elem_[11], + elem_[0] + elem_[12], + elem_[1] + elem_[13], + elem_[2] + elem_[14], + elem_[3] + elem_[15]}; memcpy(elem_, ROTATE_90, sizeof(elem_)); } break; case kVideoRotation_180: { - const float ROTATE_180[16] = - { -elem_[0], -elem_[1], -elem_[2], -elem_[3], - -elem_[4], -elem_[5], -elem_[6], -elem_[7], - elem_[8], elem_[9], elem_[10], elem_[11], - elem_[0] + elem_[4] + elem_[12], elem_[1] + elem_[5] + elem_[13], - elem_[2] + elem_[6] + elem_[14], elem_[3] + elem_[11]+ elem_[15]}; - memcpy(elem_, ROTATE_180, sizeof(elem_)); + const float ROTATE_180[16] = {-elem_[0], + -elem_[1], + -elem_[2], + -elem_[3], + -elem_[4], + -elem_[5], + -elem_[6], + -elem_[7], + elem_[8], + elem_[9], + elem_[10], + elem_[11], + elem_[0] + elem_[4] + elem_[12], + elem_[1] + elem_[5] + elem_[13], + elem_[2] + elem_[6] + elem_[14], + elem_[3] + elem_[11] + elem_[15]}; + memcpy(elem_, ROTATE_180, sizeof(elem_)); } break; case kVideoRotation_270: { - const float ROTATE_270[16] = - { -elem_[4], -elem_[5], -elem_[6], -elem_[7], - elem_[0], elem_[1], elem_[2], elem_[3], - elem_[8], elem_[9], elem_[10], elem_[11], - elem_[4] + elem_[12], elem_[5] + elem_[13], - elem_[6] + elem_[14], elem_[7] + elem_[15]}; + const float ROTATE_270[16] = {-elem_[4], + -elem_[5], + -elem_[6], + -elem_[7], + elem_[0], + elem_[1], + elem_[2], + elem_[3], + elem_[8], + elem_[9], + elem_[10], + elem_[11], + elem_[4] + elem_[12], + elem_[5] + elem_[13], + elem_[6] + elem_[14], + elem_[7] + elem_[15]}; memcpy(elem_, ROTATE_270, sizeof(elem_)); } break; } @@ -191,11 +221,8 @@ void Matrix::Crop(float xFraction, float yFraction, float xOffset, float yOffset) { - const float crop_matrix[16] = - {xFraction, 0, 0, 0, - 0, yFraction, 0, 0, - 0, 0, 1, 0, - xOffset, yOffset, 0, 1}; + const float crop_matrix[16] = {xFraction, 0, 0, 0, 0, yFraction, 0, 0, + 0, 0, 1, 0, xOffset, yOffset, 0, 1}; const Matrix old = *this; Multiply(crop_matrix, old.elem_, this->elem_); } diff --git a/sdk/objc/Framework/Classes/Audio/RTCAudioSession+Private.h b/sdk/objc/Framework/Classes/Audio/RTCAudioSession+Private.h index 8be8aadb0d..f163b5a133 100644 --- a/sdk/objc/Framework/Classes/Audio/RTCAudioSession+Private.h +++ b/sdk/objc/Framework/Classes/Audio/RTCAudioSession+Private.h @@ -77,14 +77,12 @@ NS_ASSUME_NONNULL_BEGIN - (NSError *)configurationErrorWithDescription:(NSString *)description; // Properties and methods for tests. -@property(nonatomic, readonly) - std::vector<__weak id > delegates; +@property(nonatomic, readonly) std::vector<__weak id > delegates; - (void)notifyDidBeginInterruption; -- (void)notifyDidEndInterruptionWithShouldResumeSession: - (BOOL)shouldResumeSession; +- (void)notifyDidEndInterruptionWithShouldResumeSession:(BOOL)shouldResumeSession; - (void)notifyDidChangeRouteWithReason:(AVAudioSessionRouteChangeReason)reason - previousRoute:(AVAudioSessionRouteDescription *)previousRoute; + previousRoute:(AVAudioSessionRouteDescription *)previousRoute; - (void)notifyMediaServicesWereLost; - (void)notifyMediaServicesWereReset; - (void)notifyDidChangeCanPlayOrRecord:(BOOL)canPlayOrRecord; diff --git a/sdk/objc/Framework/Classes/Audio/RTCNativeAudioSessionDelegateAdapter.h b/sdk/objc/Framework/Classes/Audio/RTCNativeAudioSessionDelegateAdapter.h index 487bab15fe..7fb2184260 100644 --- a/sdk/objc/Framework/Classes/Audio/RTCNativeAudioSessionDelegateAdapter.h +++ b/sdk/objc/Framework/Classes/Audio/RTCNativeAudioSessionDelegateAdapter.h @@ -26,8 +26,7 @@ class AudioSessionObserver; /** |observer| is a raw pointer and should be kept alive * for this object's lifetime. */ -- (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/Framework/Classes/Common/NSString+StdString.h b/sdk/objc/Framework/Classes/Common/NSString+StdString.h index 8bf6cc94be..7f51a9f3c6 100644 --- a/sdk/objc/Framework/Classes/Common/NSString+StdString.h +++ b/sdk/objc/Framework/Classes/Common/NSString+StdString.h @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) std::string stdString; + (std::string)stdStringForString:(NSString *)nsString; -+ (NSString *)stringForStdString:(const std::string&)stdString; ++ (NSString *)stringForStdString:(const std::string &)stdString; @end diff --git a/sdk/objc/Framework/Classes/Common/helpers.h b/sdk/objc/Framework/Classes/Common/helpers.h index ca56d51801..7fd9b34a99 100644 --- a/sdk/objc/Framework/Classes/Common/helpers.h +++ b/sdk/objc/Framework/Classes/Common/helpers.h @@ -18,7 +18,7 @@ namespace ios { bool CheckAndLogError(BOOL success, NSError* error); -NSString *NSStringFromStdString(const std::string& stdString); +NSString* NSStringFromStdString(const std::string& stdString); std::string StdStringFromNSString(NSString* nsString); // Return thread ID as a string. diff --git a/sdk/objc/Framework/Classes/Metal/RTCMTLRGBRenderer.h b/sdk/objc/Framework/Classes/Metal/RTCMTLRGBRenderer.h index de270554f5..9db422cd22 100644 --- a/sdk/objc/Framework/Classes/Metal/RTCMTLRGBRenderer.h +++ b/sdk/objc/Framework/Classes/Metal/RTCMTLRGBRenderer.h @@ -13,7 +13,8 @@ #import "RTCMTLRenderer.h" /** @abstract RGB/BGR renderer. - * @discussion This renderer handles both kCVPixelFormatType_32BGRA and kCVPixelFormatType_32ARGB. + * @discussion This renderer handles both kCVPixelFormatType_32BGRA and + * kCVPixelFormatType_32ARGB. */ NS_AVAILABLE(10_11, 9_0) @interface RTCMTLRGBRenderer : RTCMTLRenderer diff --git a/sdk/objc/Framework/Classes/Metal/RTCMTLRenderer.h b/sdk/objc/Framework/Classes/Metal/RTCMTLRenderer.h index bd1b6b7a47..f4a293b5c0 100644 --- a/sdk/objc/Framework/Classes/Metal/RTCMTLRenderer.h +++ b/sdk/objc/Framework/Classes/Metal/RTCMTLRenderer.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Protocol defining ability to render RTCVideoFrame in Metal enabled views. */ -@protocol RTCMTLRenderer +@protocol RTCMTLRenderer /** * Method to be implemented to perform actual rendering of the provided frame. @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN * Implementation of RTCMTLRenderer protocol. */ NS_AVAILABLE(10_11, 9_0) -@interface RTCMTLRenderer : NSObject +@interface RTCMTLRenderer : NSObject /** @abstract A wrapped RTCVideoRotation, or nil. @discussion When not nil, the rotation of the actual frame is ignored when rendering. diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCAudioSource+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCAudioSource+Private.h index 43aff02691..752eb66c0b 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCAudioSource+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCAudioSource+Private.h @@ -22,11 +22,11 @@ /** Initialize an RTCAudioSource from a native AudioSourceInterface. */ - (instancetype)initWithNativeAudioSource: - (rtc::scoped_refptr)nativeAudioSource + (rtc::scoped_refptr)nativeAudioSource NS_DESIGNATED_INITIALIZER; - (instancetype)initWithNativeMediaSource: - (rtc::scoped_refptr)nativeMediaSource + (rtc::scoped_refptr)nativeMediaSource type:(RTCMediaSourceType)type NS_UNAVAILABLE; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack+Private.h index 176d03faaa..7a2f2c82cd 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack+Private.h @@ -18,8 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @interface RTCAudioTrack () /** AudioTrackInterface created or passed in at construction. */ -@property(nonatomic, readonly) - rtc::scoped_refptr nativeAudioTrack; +@property(nonatomic, readonly) rtc::scoped_refptr nativeAudioTrack; /** Initialize an RTCAudioTrack with an id. */ - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Native.h b/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Native.h index f539d1ced7..64653e45f6 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Native.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Native.h @@ -18,9 +18,10 @@ NS_ASSUME_NONNULL_BEGIN /** Optional TurnCustomizer. * With this class one can modify outgoing TURN messages. - * The object passed in must remain valid until PeerConnection::Close() is called. + * The object passed in must remain valid until PeerConnection::Close() is + * called. */ -@property(nonatomic, nullable) webrtc::TurnCustomizer *turnCustomizer; +@property(nonatomic, nullable) webrtc::TurnCustomizer* turnCustomizer; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h index c572d6348f..ad57336b70 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h @@ -16,43 +16,43 @@ NS_ASSUME_NONNULL_BEGIN @interface RTCConfiguration () -+ (webrtc::PeerConnectionInterface::IceTransportsType) - nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy; ++ (webrtc::PeerConnectionInterface::IceTransportsType)nativeTransportsTypeForTransportPolicy: + (RTCIceTransportPolicy)policy; + (RTCIceTransportPolicy)transportPolicyForTransportsType: - (webrtc::PeerConnectionInterface::IceTransportsType)nativeType; + (webrtc::PeerConnectionInterface::IceTransportsType)nativeType; + (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy; + (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy: - (RTCBundlePolicy)policy; + (RTCBundlePolicy)policy; + (RTCBundlePolicy)bundlePolicyForNativePolicy: - (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy; + (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy; + (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy; + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy: - (RTCRtcpMuxPolicy)policy; + (RTCRtcpMuxPolicy)policy; + (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy: - (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy; + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy; + (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy; -+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy) - nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy; ++ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeTcpCandidatePolicyForPolicy: + (RTCTcpCandidatePolicy)policy; + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: - (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy; + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy; + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy; -+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy) - nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy; ++ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativeCandidateNetworkPolicyForPolicy: + (RTCCandidateNetworkPolicy)policy; + (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy: - (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy; + (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy; + (NSString *)stringForCandidateNetworkPolicy:(RTCCandidateNetworkPolicy)policy; @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable webrtc::PeerConnectionInterface::RTCConfiguration *)createNativeConfiguration; - (instancetype)initWithNativeConfiguration: - (const webrtc::PeerConnectionInterface::RTCConfiguration &)config NS_DESIGNATED_INITIALIZER; + (const webrtc::PeerConnectionInterface::RTCConfiguration &)config NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCDataChannel+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCDataChannel+Private.h index ca806cafb9..5ab308b10e 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCDataChannel+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCDataChannel+Private.h @@ -24,23 +24,22 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) const webrtc::DataBuffer *nativeDataBuffer; /** Initialize an RTCDataBuffer from a native DataBuffer. */ -- (instancetype)initWithNativeBuffer:(const webrtc::DataBuffer&)nativeBuffer; +- (instancetype)initWithNativeBuffer:(const webrtc::DataBuffer &)nativeBuffer; @end - @interface RTCDataChannel () /** Initialize an RTCDataChannel from a native DataChannelInterface. */ - (instancetype)initWithNativeDataChannel: - (rtc::scoped_refptr)nativeDataChannel + (rtc::scoped_refptr)nativeDataChannel NS_DESIGNATED_INITIALIZER; -+ (webrtc::DataChannelInterface::DataState) - nativeDataChannelStateForState:(RTCDataChannelState)state; ++ (webrtc::DataChannelInterface::DataState)nativeDataChannelStateForState: + (RTCDataChannelState)state; + (RTCDataChannelState)dataChannelStateForNativeState: - (webrtc::DataChannelInterface::DataState)nativeState; + (webrtc::DataChannelInterface::DataState)nativeState; + (NSString *)stringForState:(RTCDataChannelState)state; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCIceCandidate+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCIceCandidate+Private.h index 6c47a39853..47e934cbb3 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCIceCandidate+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCIceCandidate+Private.h @@ -22,15 +22,13 @@ NS_ASSUME_NONNULL_BEGIN * The native IceCandidateInterface representation of this RTCIceCandidate * object. This is needed to pass to the underlying C++ APIs. */ -@property(nonatomic, readonly) - std::unique_ptr nativeCandidate; +@property(nonatomic, readonly) std::unique_ptr nativeCandidate; /** * Initialize an RTCIceCandidate from a native IceCandidateInterface. No * ownership is taken of the native candidate. */ -- (instancetype)initWithNativeCandidate: - (const webrtc::IceCandidateInterface *)candidate; +- (instancetype)initWithNativeCandidate:(const webrtc::IceCandidateInterface *)candidate; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCIceServer+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCIceServer+Private.h index 19a845b3fe..0f6b7b7b83 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCIceServer+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCIceServer+Private.h @@ -20,12 +20,10 @@ NS_ASSUME_NONNULL_BEGIN * IceServer struct representation of this RTCIceServer object's data. * This is needed to pass to the underlying C++ APIs. */ -@property(nonatomic, readonly) - webrtc::PeerConnectionInterface::IceServer nativeServer; +@property(nonatomic, readonly) webrtc::PeerConnectionInterface::IceServer nativeServer; /** Initialize an RTCIceServer from a native IceServer. */ -- (instancetype)initWithNativeServer: - (webrtc::PeerConnectionInterface::IceServer)nativeServer; +- (instancetype)initWithNativeServer:(webrtc::PeerConnectionInterface::IceServer)nativeServer; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCIntervalRange+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCIntervalRange+Private.h index a80c99a1ae..690daf340e 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCIntervalRange+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCIntervalRange+Private.h @@ -16,12 +16,10 @@ NS_ASSUME_NONNULL_BEGIN @interface RTCIntervalRange () -@property(nonatomic, readonly) - std::unique_ptr nativeIntervalRange; +@property(nonatomic, readonly) std::unique_ptr nativeIntervalRange; - (instancetype)initWithNativeIntervalRange:(const rtc::IntervalRange &)config; @end NS_ASSUME_NONNULL_END - diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaConstraints+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaConstraints+Private.h index 1955c8c265..75cd79ba58 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaConstraints+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaConstraints+Private.h @@ -20,9 +20,8 @@ class MediaConstraints : public MediaConstraintsInterface { public: virtual ~MediaConstraints(); MediaConstraints(); - MediaConstraints( - const MediaConstraintsInterface::Constraints& mandatory, - const MediaConstraintsInterface::Constraints& optional); + MediaConstraints(const MediaConstraintsInterface::Constraints& mandatory, + const MediaConstraintsInterface::Constraints& optional); virtual const Constraints& GetMandatory() const; virtual const Constraints& GetOptional() const; @@ -33,7 +32,6 @@ class MediaConstraints : public MediaConstraintsInterface { } // namespace webrtc - NS_ASSUME_NONNULL_BEGIN @interface RTCMediaConstraints () @@ -45,9 +43,8 @@ NS_ASSUME_NONNULL_BEGIN - (std::unique_ptr)nativeConstraints; /** Return a native Constraints object representing these constraints */ -+ (webrtc::MediaConstraintsInterface::Constraints) - nativeConstraintsForConstraints: - (NSDictionary *)constraints; ++ (webrtc::MediaConstraintsInterface::Constraints)nativeConstraintsForConstraints: + (NSDictionary*)constraints; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaSource+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaSource+Private.h index 1656d16d75..f6382499fa 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaSource+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaSource+Private.h @@ -21,19 +21,15 @@ typedef NS_ENUM(NSInteger, RTCMediaSourceType) { @interface RTCMediaSource () -@property(nonatomic, readonly) - rtc::scoped_refptr nativeMediaSource; +@property(nonatomic, readonly) rtc::scoped_refptr nativeMediaSource; - (instancetype)initWithNativeMediaSource: - (rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type - NS_DESIGNATED_INITIALIZER; + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type NS_DESIGNATED_INITIALIZER; -+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState: - (RTCSourceState)state; ++ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:(RTCSourceState)state; -+ (RTCSourceState)sourceStateForNativeState: - (webrtc::MediaSourceInterface::SourceState)nativeState; ++ (RTCSourceState)sourceStateForNativeState:(webrtc::MediaSourceInterface::SourceState)nativeState; + (NSString *)stringForState:(RTCSourceState)state; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStream+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStream+Private.h index 1d0847c12c..f95d15c892 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStream+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStream+Private.h @@ -20,16 +20,14 @@ NS_ASSUME_NONNULL_BEGIN * MediaStreamInterface representation of this RTCMediaStream object. This is * needed to pass to the underlying C++ APIs. */ -@property(nonatomic, readonly) - rtc::scoped_refptr nativeMediaStream; +@property(nonatomic, readonly) rtc::scoped_refptr nativeMediaStream; /** Initialize an RTCMediaStream with an id. */ -- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory - streamId:(NSString *)streamId; +- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory streamId:(NSString *)streamId; /** Initialize an RTCMediaStream from a native MediaStreamInterface. */ - (instancetype)initWithNativeMediaStream: - (rtc::scoped_refptr)nativeMediaStream; + (rtc::scoped_refptr)nativeMediaStream; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStreamTrack+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStreamTrack+Private.h index bcf7a5f0b0..bb24216a5d 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStreamTrack+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCMediaStreamTrack+Private.h @@ -25,27 +25,25 @@ NS_ASSUME_NONNULL_BEGIN * The native MediaStreamTrackInterface passed in or created during * construction. */ -@property(nonatomic, readonly) - rtc::scoped_refptr nativeTrack; +@property(nonatomic, readonly) rtc::scoped_refptr nativeTrack; /** * Initialize an RTCMediaStreamTrack from a native MediaStreamTrackInterface. */ - (instancetype)initWithNativeTrack: - (rtc::scoped_refptr)nativeTrack - type:(RTCMediaStreamTrackType)type - NS_DESIGNATED_INITIALIZER; + (rtc::scoped_refptr)nativeTrack + type:(RTCMediaStreamTrackType)type NS_DESIGNATED_INITIALIZER; - (instancetype)initWithNativeTrack: - (rtc::scoped_refptr)nativeTrack; + (rtc::scoped_refptr)nativeTrack; - (BOOL)isEqualToTrack:(RTCMediaStreamTrack *)track; + (webrtc::MediaStreamTrackInterface::TrackState)nativeTrackStateForState: - (RTCMediaStreamTrackState)state; + (RTCMediaStreamTrackState)state; + (RTCMediaStreamTrackState)trackStateForNativeState: - (webrtc::MediaStreamTrackInterface::TrackState)nativeState; + (webrtc::MediaStreamTrackInterface::TrackState)nativeState; + (NSString *)stringForState:(RTCMediaStreamTrackState)state; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCMetricsSampleInfo+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCMetricsSampleInfo+Private.h index 48451df46a..ceaca8f53f 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCMetricsSampleInfo+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCMetricsSampleInfo+Private.h @@ -20,8 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @interface RTCMetricsSampleInfo () /** Initialize an RTCMetricsSampleInfo object from native SampleInfo. */ -- (instancetype)initWithNativeSampleInfo: - (const webrtc::metrics::SampleInfo &)info; +- (instancetype)initWithNativeSampleInfo:(const webrtc::metrics::SampleInfo &)info; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+Private.h index eae72fbb00..f533605651 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+Private.h @@ -21,13 +21,11 @@ namespace webrtc { * id and call methods on that interface. */ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { - public: PeerConnectionDelegateAdapter(RTCPeerConnection *peerConnection); virtual ~PeerConnectionDelegateAdapter(); - void OnSignalingChange( - PeerConnectionInterface::SignalingState new_state) override; + void OnSignalingChange(PeerConnectionInterface::SignalingState new_state) override; void OnAddStream(rtc::scoped_refptr stream) override; @@ -35,77 +33,68 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { void OnTrack(rtc::scoped_refptr transceiver) override; - void OnDataChannel( - rtc::scoped_refptr data_channel) override; + void OnDataChannel(rtc::scoped_refptr data_channel) override; void OnRenegotiationNeeded() override; - void OnIceConnectionChange( - PeerConnectionInterface::IceConnectionState new_state) override; + void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override; - void OnIceGatheringChange( - PeerConnectionInterface::IceGatheringState new_state) override; + void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override; void OnIceCandidate(const IceCandidateInterface *candidate) override; - void OnIceCandidatesRemoved( - const std::vector& candidates) override; + void OnIceCandidatesRemoved(const std::vector &candidates) override; void OnAddTrack(rtc::scoped_refptr receiver, - const std::vector>& streams) override; + const std::vector> &streams) override; private: __weak RTCPeerConnection *peer_connection_; }; -} // namespace webrtc - +} // namespace webrtc @interface RTCPeerConnection () /** The native PeerConnectionInterface created during construction. */ -@property(nonatomic, readonly) - rtc::scoped_refptr nativePeerConnection; +@property(nonatomic, readonly) rtc::scoped_refptr + nativePeerConnection; /** Initialize an RTCPeerConnection with a configuration, constraints, and * delegate. */ -- (instancetype)initWithFactory: - (RTCPeerConnectionFactory *)factory - configuration: - (RTCConfiguration *)configuration - constraints: - (RTCMediaConstraints *)constraints - delegate: - (nullable id)delegate +- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory + configuration:(RTCConfiguration *)configuration + constraints:(RTCMediaConstraints *)constraints + delegate:(nullable id)delegate NS_DESIGNATED_INITIALIZER; + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState: - (RTCSignalingState)state; + (RTCSignalingState)state; + (RTCSignalingState)signalingStateForNativeState: - (webrtc::PeerConnectionInterface::SignalingState)nativeState; + (webrtc::PeerConnectionInterface::SignalingState)nativeState; + (NSString *)stringForSignalingState:(RTCSignalingState)state; -+ (webrtc::PeerConnectionInterface::IceConnectionState) - nativeIceConnectionStateForState:(RTCIceConnectionState)state; ++ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState: + (RTCIceConnectionState)state; + (RTCIceConnectionState)iceConnectionStateForNativeState: - (webrtc::PeerConnectionInterface::IceConnectionState)nativeState; + (webrtc::PeerConnectionInterface::IceConnectionState)nativeState; + (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state; -+ (webrtc::PeerConnectionInterface::IceGatheringState) - nativeIceGatheringStateForState:(RTCIceGatheringState)state; ++ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState: + (RTCIceGatheringState)state; + (RTCIceGatheringState)iceGatheringStateForNativeState: - (webrtc::PeerConnectionInterface::IceGatheringState)nativeState; + (webrtc::PeerConnectionInterface::IceGatheringState)nativeState; + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state; -+ (webrtc::PeerConnectionInterface::StatsOutputLevel) - nativeStatsOutputLevelForLevel:(RTCStatsOutputLevel)level; ++ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel: + (RTCStatsOutputLevel)level; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Private.h index 1e5d1795f4..50944eecbb 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Private.h @@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN * C++ APIs. */ @property(nonatomic, readonly) - rtc::scoped_refptr nativeFactory; + rtc::scoped_refptr + nativeFactory; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters+Private.h index f33a8cf1be..c6ca462b1f 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters+Private.h @@ -20,8 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtpCodecParameters nativeParameters; /** Initialize the object with a native RtpCodecParameters structure. */ -- (instancetype)initWithNativeParameters: - (const webrtc::RtpCodecParameters &)nativeParameters; +- (instancetype)initWithNativeParameters:(const webrtc::RtpCodecParameters &)nativeParameters; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters+Private.h index 673a485689..c64501f062 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters+Private.h @@ -20,8 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtpEncodingParameters nativeParameters; /** Initialize the object with a native RtpEncodingParameters structure. */ -- (instancetype)initWithNativeParameters: - (const webrtc::RtpEncodingParameters &)nativeParameters; +- (instancetype)initWithNativeParameters:(const webrtc::RtpEncodingParameters &)nativeParameters; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpParameters+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpParameters+Private.h index 4a0daaf88e..41d1b7c601 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpParameters+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpParameters+Private.h @@ -20,8 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtpParameters nativeParameters; /** Initialize the object with a native RtpParameters structure. */ -- (instancetype)initWithNativeParameters: - (const webrtc::RtpParameters &)nativeParameters; +- (instancetype)initWithNativeParameters:(const webrtc::RtpParameters &)nativeParameters; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver+Private.h index 63bdfa3ab6..73f68f4885 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver+Private.h @@ -30,12 +30,11 @@ class RtpReceiverDelegateAdapter : public RtpReceiverObserverInterface { @interface RTCRtpReceiver () -@property(nonatomic, readonly) - rtc::scoped_refptr nativeRtpReceiver; +@property(nonatomic, readonly) rtc::scoped_refptr nativeRtpReceiver; /** Initialize an RTCRtpReceiver with a native RtpReceiverInterface. */ - (instancetype)initWithNativeRtpReceiver: - (rtc::scoped_refptr)nativeRtpReceiver + (rtc::scoped_refptr)nativeRtpReceiver NS_DESIGNATED_INITIALIZER; + (RTCRtpMediaType)mediaTypeForNativeMediaType:(cricket::MediaType)nativeMediaType; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpSender+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpSender+Private.h index e70be8349e..7164bca56f 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpSender+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpSender+Private.h @@ -16,13 +16,11 @@ NS_ASSUME_NONNULL_BEGIN @interface RTCRtpSender () -@property(nonatomic, readonly) - rtc::scoped_refptr nativeRtpSender; +@property(nonatomic, readonly) rtc::scoped_refptr nativeRtpSender; /** Initialize an RTCRtpSender with a native RtpSenderInterface. */ - (instancetype)initWithNativeRtpSender: - (rtc::scoped_refptr)nativeRtpSender - NS_DESIGNATED_INITIALIZER; + (rtc::scoped_refptr)nativeRtpSender NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h index 4c58fa726a..08a6f55c58 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN * description. */ - (instancetype)initWithNativeDescription: - (const webrtc::SessionDescriptionInterface *)nativeDescription; + (const webrtc::SessionDescriptionInterface *)nativeDescription; + (std::string)stdStringForType:(RTCSdpType)type; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoRendererAdapter+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoRendererAdapter+Private.h index bdec24d5b7..80a2140bfa 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoRendererAdapter+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoRendererAdapter+Private.h @@ -30,8 +30,7 @@ NS_ASSUME_NONNULL_BEGIN * to this interface will be adapted and passed to the RTCVideoRenderer supplied * during construction. This pointer is unsafe and owned by this class. */ -@property(nonatomic, readonly) - rtc::VideoSinkInterface *nativeVideoRenderer; +@property(nonatomic, readonly) rtc::VideoSinkInterface *nativeVideoRenderer; /** Initialize an RTCVideoRendererAdapter with an RTCVideoRenderer. */ - (instancetype)initWithNativeRenderer:(id)videoRenderer diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource+Private.h index bd424840d0..fdb45224c9 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource+Private.h @@ -22,17 +22,16 @@ NS_ASSUME_NONNULL_BEGIN * The VideoTrackSourceInterface object passed to this RTCVideoSource during * construction. */ -@property(nonatomic, readonly) - rtc::scoped_refptr - nativeVideoSource; +@property(nonatomic, readonly) rtc::scoped_refptr + nativeVideoSource; /** Initialize an RTCVideoSource from a native VideoTrackSourceInterface. */ - (instancetype)initWithNativeVideoSource: - (rtc::scoped_refptr)nativeVideoSource + (rtc::scoped_refptr)nativeVideoSource NS_DESIGNATED_INITIALIZER; - (instancetype)initWithNativeMediaSource: - (rtc::scoped_refptr)nativeMediaSource + (rtc::scoped_refptr)nativeMediaSource type:(RTCMediaSourceType)type NS_UNAVAILABLE; - (instancetype)initWithSignalingThread:(rtc::Thread *)signalingThread diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack+Private.h index 2cb6a13f25..14639be9fb 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack+Private.h @@ -17,8 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @interface RTCVideoTrack () /** VideoTrackInterface created or passed in at construction. */ -@property(nonatomic, readonly) - rtc::scoped_refptr nativeVideoTrack; +@property(nonatomic, readonly) rtc::scoped_refptr nativeVideoTrack; /** Initialize an RTCVideoTrack with its source and an id. */ - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory diff --git a/sdk/objc/Framework/Classes/Video/RTCShader.h b/sdk/objc/Framework/Classes/Video/RTCShader.h index 4d92d3dd10..67afabb1d8 100644 --- a/sdk/objc/Framework/Classes/Video/RTCShader.h +++ b/sdk/objc/Framework/Classes/Video/RTCShader.h @@ -12,9 +12,10 @@ RTC_EXTERN const char kRTCVertexShaderSource[]; -RTC_EXTERN GLuint RTCCreateShader(GLenum type, const GLchar *source); +RTC_EXTERN GLuint RTCCreateShader(GLenum type, const GLchar* source); RTC_EXTERN GLuint RTCCreateProgram(GLuint vertexShader, GLuint fragmentShader); -RTC_EXTERN GLuint RTCCreateProgramFromFragmentSource(const char fragmentShaderSource[]); +RTC_EXTERN GLuint +RTCCreateProgramFromFragmentSource(const char fragmentShaderSource[]); RTC_EXTERN BOOL RTCCreateVertexBuffer(GLuint* vertexBuffer, GLuint* vertexArray); RTC_EXTERN void RTCSetVertexData(RTCVideoRotation rotation); diff --git a/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.cc b/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.cc index 625fc53d81..a373050803 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.cc +++ b/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.cc @@ -33,7 +33,7 @@ bool H264CMSampleBufferToAnnexBBuffer( CMSampleBufferRef avcc_sample_buffer, bool is_keyframe, rtc::Buffer* annexb_buffer, - std::unique_ptr *out_header) { + std::unique_ptr* out_header) { RTC_DCHECK(avcc_sample_buffer); RTC_DCHECK(out_header); out_header->reset(nullptr); diff --git a/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h b/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h index cd81f121dc..0155882648 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h +++ b/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h @@ -33,7 +33,7 @@ bool H264CMSampleBufferToAnnexBBuffer( CMSampleBufferRef avcc_sample_buffer, bool is_keyframe, rtc::Buffer* annexb_buffer, - std::unique_ptr *out_header); + std::unique_ptr* out_header); // Converts a buffer received from RTP into a sample buffer suitable for the // VideoToolbox decoder. The RTP buffer is in annex b format whereas the sample diff --git a/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter_unittest.cc b/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter_unittest.cc index c8de64bc62..d907ef8487 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter_unittest.cc +++ b/sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter_unittest.cc @@ -25,14 +25,11 @@ static const uint8_t NALU_TEST_DATA_1[] = {0xDE, 0xAD, 0xBE, 0xEF}; TEST(H264VideoToolboxNaluTest, TestCreateVideoFormatDescription) { const uint8_t sps_pps_buffer[] = { - // SPS nalu. - 0x00, 0x00, 0x00, 0x01, - 0x27, 0x42, 0x00, 0x1E, 0xAB, 0x40, 0xF0, 0x28, 0xD3, 0x70, 0x20, 0x20, - 0x20, 0x20, - // PPS nalu. - 0x00, 0x00, 0x00, 0x01, - 0x28, 0xCE, 0x3C, 0x30 - }; + // SPS nalu. + 0x00, 0x00, 0x00, 0x01, 0x27, 0x42, 0x00, 0x1E, 0xAB, 0x40, 0xF0, 0x28, + 0xD3, 0x70, 0x20, 0x20, 0x20, 0x20, + // PPS nalu. + 0x00, 0x00, 0x00, 0x01, 0x28, 0xCE, 0x3C, 0x30}; CMVideoFormatDescriptionRef description = CreateVideoFormatDescription(sps_pps_buffer, arraysize(sps_pps_buffer)); EXPECT_TRUE(description); @@ -59,8 +56,8 @@ TEST(H264VideoToolboxNaluTest, TestCreateVideoFormatDescription) { } const uint8_t other_buffer[] = {0x00, 0x00, 0x00, 0x01, 0x28}; - EXPECT_FALSE(CreateVideoFormatDescription(other_buffer, - arraysize(other_buffer))); + EXPECT_FALSE( + CreateVideoFormatDescription(other_buffer, arraysize(other_buffer))); } TEST(AnnexBBufferReaderTest, TestReadEmptyInput) { diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCAudioSession.h b/sdk/objc/Framework/Headers/WebRTC/RTCAudioSession.h index 6c4c96ab05..15b63d39dc 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCAudioSession.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCAudioSession.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN -extern NSString * const kRTCAudioSessionErrorDomain; +extern NSString *const kRTCAudioSessionErrorDomain; /** Method that requires lock was called without lock. */ extern NSInteger const kRTCAudioSessionErrorLockRequired; /** Unknown configuration error occurred. */ @@ -46,8 +46,8 @@ RTC_EXPORT * route. */ - (void)audioSessionDidChangeRoute:(RTCAudioSession *)session - reason:(AVAudioSessionRouteChangeReason)reason - previousRoute:(AVAudioSessionRouteDescription *)previousRoute; + reason:(AVAudioSessionRouteChangeReason)reason + previousRoute:(AVAudioSessionRouteDescription *)previousRoute; /** Called on a system notification thread when AVAudioSession media server * terminates. @@ -61,8 +61,7 @@ RTC_EXPORT // TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification. -- (void)audioSession:(RTCAudioSession *)session - didChangeCanPlayOrRecord:(BOOL)canPlayOrRecord; +- (void)audioSession:(RTCAudioSession *)session didChangeCanPlayOrRecord:(BOOL)canPlayOrRecord; /** Called on a WebRTC thread when the audio device is notified to begin * playback or recording. @@ -75,8 +74,7 @@ RTC_EXPORT - (void)audioSessionDidStopPlayOrRecord:(RTCAudioSession *)session; /** Called when the AVAudioSession output volume value changes. */ -- (void)audioSession:(RTCAudioSession *)audioSession - didChangeOutputVolume:(float)outputVolume; +- (void)audioSession:(RTCAudioSession *)audioSession didChangeOutputVolume:(float)outputVolume; /** Called when the audio device detects a playout glitch. The argument is the * number of glitches detected so far in the current audio playout session. @@ -170,14 +168,10 @@ RTC_EXPORT @property(readonly) float inputGain; @property(readonly) BOOL inputGainSettable; @property(readonly) BOOL inputAvailable; -@property(readonly, nullable) - NSArray * inputDataSources; -@property(readonly, nullable) - AVAudioSessionDataSourceDescription *inputDataSource; -@property(readonly, nullable) - NSArray * outputDataSources; -@property(readonly, nullable) - AVAudioSessionDataSourceDescription *outputDataSource; +@property(readonly, nullable) NSArray *inputDataSources; +@property(readonly, nullable) AVAudioSessionDataSourceDescription *inputDataSource; +@property(readonly, nullable) NSArray *outputDataSources; +@property(readonly, nullable) AVAudioSessionDataSourceDescription *outputDataSource; @property(readonly) double sampleRate; @property(readonly) double preferredSampleRate; @property(readonly) NSInteger inputNumberOfChannels; @@ -211,8 +205,7 @@ RTC_EXPORT * AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation option is passed to * AVAudioSession. */ -- (BOOL)setActive:(BOOL)active - error:(NSError **)outError; +- (BOOL)setActive:(BOOL)active error:(NSError **)outError; // The following methods are proxies for the associated methods on // AVAudioSession. |lockForConfiguration| must be called before using them @@ -224,16 +217,11 @@ RTC_EXPORT - (BOOL)setMode:(NSString *)mode error:(NSError **)outError; - (BOOL)setInputGain:(float)gain error:(NSError **)outError; - (BOOL)setPreferredSampleRate:(double)sampleRate error:(NSError **)outError; -- (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration - error:(NSError **)outError; -- (BOOL)setPreferredInputNumberOfChannels:(NSInteger)count - error:(NSError **)outError; -- (BOOL)setPreferredOutputNumberOfChannels:(NSInteger)count - error:(NSError **)outError; -- (BOOL)overrideOutputAudioPort:(AVAudioSessionPortOverride)portOverride - error:(NSError **)outError; -- (BOOL)setPreferredInput:(AVAudioSessionPortDescription *)inPort - error:(NSError **)outError; +- (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration error:(NSError **)outError; +- (BOOL)setPreferredInputNumberOfChannels:(NSInteger)count error:(NSError **)outError; +- (BOOL)setPreferredOutputNumberOfChannels:(NSInteger)count error:(NSError **)outError; +- (BOOL)overrideOutputAudioPort:(AVAudioSessionPortOverride)portOverride error:(NSError **)outError; +- (BOOL)setPreferredInput:(AVAudioSessionPortDescription *)inPort error:(NSError **)outError; - (BOOL)setInputDataSource:(AVAudioSessionDataSourceDescription *)dataSource error:(NSError **)outError; - (BOOL)setOutputDataSource:(AVAudioSessionDataSourceDescription *)dataSource @@ -247,8 +235,7 @@ RTC_EXPORT * returned. * |lockForConfiguration| must be called first. */ -- (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration - error:(NSError **)outError; +- (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration error:(NSError **)outError; /** Convenience method that calls both setConfiguration and setActive. * |lockForConfiguration| must be called first. diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCCameraPreviewView.h b/sdk/objc/Framework/Headers/WebRTC/RTCCameraPreviewView.h index d62bb01e81..2995c9c3b1 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCCameraPreviewView.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCCameraPreviewView.h @@ -25,6 +25,6 @@ RTC_EXPORT * is assigned to AVCaptureVideoPreviewLayer async in the same * queue that the AVCaptureSession is started/stopped. */ -@property(nonatomic, strong) AVCaptureSession *captureSession; +@property(nonatomic, strong) AVCaptureSession* captureSession; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h b/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h index 3bfd60e2c2..61868c5469 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#import #import +#import #import #import diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h b/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h index b203b28156..d274530ae2 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h @@ -34,10 +34,7 @@ typedef NS_ENUM(NSInteger, RTCBundlePolicy) { }; /** Represents the rtcp mux policy. */ -typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { - RTCRtcpMuxPolicyNegotiate, - RTCRtcpMuxPolicyRequire -}; +typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { RTCRtcpMuxPolicyNegotiate, RTCRtcpMuxPolicyRequire }; /** Represents the tcp candidate policy. */ typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) { @@ -88,8 +85,7 @@ RTC_EXPORT @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; @property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy; -@property(nonatomic, assign) - RTCContinualGatheringPolicy continualGatheringPolicy; +@property(nonatomic, assign) RTCContinualGatheringPolicy continualGatheringPolicy; /** By default, the PeerConnection will use a limited number of IPv6 network * interfaces, in order to avoid too many ICE candidate pairs being created diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCDataChannel.h b/sdk/objc/Framework/Headers/WebRTC/RTCDataChannel.h index 893bd0a336..4859e04bdb 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCDataChannel.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCDataChannel.h @@ -34,7 +34,6 @@ RTC_EXPORT @end - @class RTCDataChannel; RTC_EXPORT @protocol RTCDataChannelDelegate @@ -48,12 +47,10 @@ RTC_EXPORT @optional /** The data channel's |bufferedAmount| changed. */ -- (void)dataChannel:(RTCDataChannel *)dataChannel - didChangeBufferedAmount:(uint64_t)amount; +- (void)dataChannel:(RTCDataChannel *)dataChannel didChangeBufferedAmount:(uint64_t)amount; @end - /** Represents the state of the data channel. */ typedef NS_ENUM(NSInteger, RTCDataChannelState) { RTCDataChannelStateConnecting, @@ -78,8 +75,7 @@ RTC_EXPORT @property(nonatomic, readonly) BOOL isOrdered; /** Deprecated. Use maxPacketLifeTime. */ -@property(nonatomic, readonly) NSUInteger maxRetransmitTime - DEPRECATED_ATTRIBUTE; +@property(nonatomic, readonly) NSUInteger maxRetransmitTime DEPRECATED_ATTRIBUTE; /** * The length of the time window (in milliseconds) during which transmissions diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCDataChannelConfiguration.h b/sdk/objc/Framework/Headers/WebRTC/RTCDataChannelConfiguration.h index 65f5931844..65ca8f8d56 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCDataChannelConfiguration.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCDataChannelConfiguration.h @@ -45,7 +45,7 @@ RTC_EXPORT @property(nonatomic, assign) int channelId; /** Set by the application and opaque to the WebRTC implementation. */ -@property(nonatomic) NSString *protocol; +@property(nonatomic) NSString* protocol; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h b/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h index 3dddead60e..03387471c4 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h @@ -34,8 +34,7 @@ RTC_EXPORT * @param dispatchType The queue type to dispatch on. * @param block The block to dispatch asynchronously. */ -+ (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType - block:(dispatch_block_t)block; ++ (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType block:(dispatch_block_t)block; /** Returns YES if run on queue for the dispatchType otherwise NO. * Useful for asserting that a method is run on a correct queue. diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCEAGLVideoView.h b/sdk/objc/Framework/Headers/WebRTC/RTCEAGLVideoView.h index e6e5b5fa6a..8fdd3c3c2f 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCEAGLVideoView.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCEAGLVideoView.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @class RTCEAGLVideoView; RTC_EXPORT -@protocol RTCEAGLVideoViewDelegate +@protocol RTCEAGLVideoViewDelegate @end /** diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h b/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h index 1e8a591b73..ac8a9104c1 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h @@ -52,13 +52,11 @@ RTC_EXPORT - (instancetype)init; // Create file logger with default rotation type. -- (instancetype)initWithDirPath:(NSString *)dirPath - maxFileSize:(NSUInteger)maxFileSize; +- (instancetype)initWithDirPath:(NSString *)dirPath maxFileSize:(NSUInteger)maxFileSize; - (instancetype)initWithDirPath:(NSString *)dirPath maxFileSize:(NSUInteger)maxFileSize - rotationType:(RTCFileLoggerRotationType)rotationType - NS_DESIGNATED_INITIALIZER; + rotationType:(RTCFileLoggerRotationType)rotationType NS_DESIGNATED_INITIALIZER; // Starts writing WebRTC logs to disk if not already started. Overwrites any // existing file(s). @@ -74,4 +72,3 @@ RTC_EXPORT @end NS_ASSUME_NONNULL_END - diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCIceCandidate.h b/sdk/objc/Framework/Headers/WebRTC/RTCIceCandidate.h index 3b7f3e26e5..fb5064e518 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCIceCandidate.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCIceCandidate.h @@ -42,8 +42,7 @@ RTC_EXPORT */ - (instancetype)initWithSdp:(NSString *)sdp sdpMLineIndex:(int)sdpMLineIndex - sdpMid:(nullable NSString *)sdpMid - NS_DESIGNATED_INITIALIZER; + sdpMid:(nullable NSString *)sdpMid NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCIntervalRange.h b/sdk/objc/Framework/Headers/WebRTC/RTCIntervalRange.h index 9384b15368..00508eba17 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCIntervalRange.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCIntervalRange.h @@ -18,11 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) NSInteger max; - (instancetype)init; -- (instancetype)initWithMin:(NSInteger)min - max:(NSInteger)max - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithMin:(NSInteger)min max:(NSInteger)max NS_DESIGNATED_INITIALIZER; @end NS_ASSUME_NONNULL_END - diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCLogging.h b/sdk/objc/Framework/Headers/WebRTC/RTCLogging.h index a65dcad82f..b758785115 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCLogging.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCLogging.h @@ -33,12 +33,9 @@ RTC_EXTERN NSString* RTCFileName(const char* filePath); // Some convenience macros. -#define RTCLogString(format, ...) \ - [NSString stringWithFormat:@"(%@:%d %s): " format, \ - RTCFileName(__FILE__), \ - __LINE__, \ - __FUNCTION__, \ - ##__VA_ARGS__] +#define RTCLogString(format, ...) \ + [NSString stringWithFormat:@"(%@:%d %s): " format, RTCFileName(__FILE__), \ + __LINE__, __FUNCTION__, ##__VA_ARGS__] #define RTCLogFormat(severity, format, ...) \ do { \ @@ -46,17 +43,17 @@ RTC_EXTERN NSString* RTCFileName(const char* filePath); RTCLogEx(severity, log_string); \ } while (false) -#define RTCLogVerbose(format, ...) \ - RTCLogFormat(RTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \ +#define RTCLogVerbose(format, ...) \ + RTCLogFormat(RTCLoggingSeverityVerbose, format, ##__VA_ARGS__) -#define RTCLogInfo(format, ...) \ - RTCLogFormat(RTCLoggingSeverityInfo, format, ##__VA_ARGS__) \ +#define RTCLogInfo(format, ...) \ + RTCLogFormat(RTCLoggingSeverityInfo, format, ##__VA_ARGS__) -#define RTCLogWarning(format, ...) \ - RTCLogFormat(RTCLoggingSeverityWarning, format, ##__VA_ARGS__) \ +#define RTCLogWarning(format, ...) \ + RTCLogFormat(RTCLoggingSeverityWarning, format, ##__VA_ARGS__) -#define RTCLogError(format, ...) \ - RTCLogFormat(RTCLoggingSeverityError, format, ##__VA_ARGS__) \ +#define RTCLogError(format, ...) \ + RTCLogFormat(RTCLoggingSeverityError, format, ##__VA_ARGS__) #if !defined(NDEBUG) #define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__) diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCMTLNSVideoView.h b/sdk/objc/Framework/Headers/WebRTC/RTCMTLNSVideoView.h index f82126c388..d28d554d9a 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCMTLNSVideoView.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCMTLNSVideoView.h @@ -12,7 +12,7 @@ #import "WebRTC/RTCVideoRenderer.h" NS_AVAILABLE_MAC(10.11) -@interface RTCMTLNSVideoView : NSView +@interface RTCMTLNSVideoView : NSView @property(nonatomic, weak) id delegate; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCMTLVideoView.h b/sdk/objc/Framework/Headers/WebRTC/RTCMTLVideoView.h index da1797fcf6..0615495035 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCMTLVideoView.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCMTLVideoView.h @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN NS_CLASS_AVAILABLE_IOS(9) RTC_EXPORT -@interface RTCMTLVideoView : UIView +@interface RTCMTLVideoView : UIView @property(nonatomic, weak) id delegate; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCMediaConstraints.h b/sdk/objc/Framework/Headers/WebRTC/RTCMediaConstraints.h index f93e5b5afc..fce08212e9 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCMediaConstraints.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCMediaConstraints.h @@ -15,28 +15,28 @@ NS_ASSUME_NONNULL_BEGIN /** Constraint keys for media sources. */ -RTC_EXTERN NSString * const kRTCMediaConstraintsMinAspectRatio; -RTC_EXTERN NSString * const kRTCMediaConstraintsMaxAspectRatio; -RTC_EXTERN NSString * const kRTCMediaConstraintsMaxWidth; -RTC_EXTERN NSString * const kRTCMediaConstraintsMinWidth; -RTC_EXTERN NSString * const kRTCMediaConstraintsMaxHeight; -RTC_EXTERN NSString * const kRTCMediaConstraintsMinHeight; -RTC_EXTERN NSString * const kRTCMediaConstraintsMaxFrameRate; -RTC_EXTERN NSString * const kRTCMediaConstraintsMinFrameRate; +RTC_EXTERN NSString *const kRTCMediaConstraintsMinAspectRatio; +RTC_EXTERN NSString *const kRTCMediaConstraintsMaxAspectRatio; +RTC_EXTERN NSString *const kRTCMediaConstraintsMaxWidth; +RTC_EXTERN NSString *const kRTCMediaConstraintsMinWidth; +RTC_EXTERN NSString *const kRTCMediaConstraintsMaxHeight; +RTC_EXTERN NSString *const kRTCMediaConstraintsMinHeight; +RTC_EXTERN NSString *const kRTCMediaConstraintsMaxFrameRate; +RTC_EXTERN NSString *const kRTCMediaConstraintsMinFrameRate; /** The value for this key should be a base64 encoded string containing * the data from the serialized configuration proto. */ -RTC_EXTERN NSString * const kRTCMediaConstraintsAudioNetworkAdaptorConfig; +RTC_EXTERN NSString *const kRTCMediaConstraintsAudioNetworkAdaptorConfig; /** Constraint keys for generating offers and answers. */ -RTC_EXTERN NSString * const kRTCMediaConstraintsIceRestart; -RTC_EXTERN NSString * const kRTCMediaConstraintsOfferToReceiveAudio; -RTC_EXTERN NSString * const kRTCMediaConstraintsOfferToReceiveVideo; -RTC_EXTERN NSString * const kRTCMediaConstraintsVoiceActivityDetection; +RTC_EXTERN NSString *const kRTCMediaConstraintsIceRestart; +RTC_EXTERN NSString *const kRTCMediaConstraintsOfferToReceiveAudio; +RTC_EXTERN NSString *const kRTCMediaConstraintsOfferToReceiveVideo; +RTC_EXTERN NSString *const kRTCMediaConstraintsVoiceActivityDetection; /** Constraint values for Boolean parameters. */ -RTC_EXTERN NSString * const kRTCMediaConstraintsValueTrue; -RTC_EXTERN NSString * const kRTCMediaConstraintsValueFalse; +RTC_EXTERN NSString *const kRTCMediaConstraintsValueTrue; +RTC_EXTERN NSString *const kRTCMediaConstraintsValueFalse; RTC_EXPORT @interface RTCMediaConstraints : NSObject @@ -44,10 +44,9 @@ RTC_EXPORT - (instancetype)init NS_UNAVAILABLE; /** Initialize with mandatory and/or optional constraints. */ -- (instancetype)initWithMandatoryConstraints: - (nullable NSDictionary *)mandatory - optionalConstraints: - (nullable NSDictionary *)optional +- (instancetype) + initWithMandatoryConstraints:(nullable NSDictionary *)mandatory + optionalConstraints:(nullable NSDictionary *)optional NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h b/sdk/objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h index c42f0cfb1a..aee9bdd0a0 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h @@ -22,8 +22,8 @@ typedef NS_ENUM(NSInteger, RTCMediaStreamTrackState) { NS_ASSUME_NONNULL_BEGIN -RTC_EXTERN NSString * const kRTCMediaStreamTrackKindAudio; -RTC_EXTERN NSString * const kRTCMediaStreamTrackKindVideo; +RTC_EXTERN NSString *const kRTCMediaStreamTrackKindAudio; +RTC_EXTERN NSString *const kRTCMediaStreamTrackKindVideo; RTC_EXPORT @interface RTCMediaStreamTrack : NSObject diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCMetrics.h b/sdk/objc/Framework/Headers/WebRTC/RTCMetrics.h index d22287e551..cc89888219 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCMetrics.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCMetrics.h @@ -20,5 +20,4 @@ RTC_EXTERN void RTCEnableMetrics(void); /** Gets and clears native histograms. */ -RTC_EXTERN NSArray *RTCGetAndResetMetrics(void); - +RTC_EXTERN NSArray* RTCGetAndResetMetrics(void); diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCNSGLVideoView.h b/sdk/objc/Framework/Headers/WebRTC/RTCNSGLVideoView.h index 62c79682ef..77e301f189 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCNSGLVideoView.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCNSGLVideoView.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @class RTCNSGLVideoView; -@protocol RTCNSGLVideoViewDelegate +@protocol RTCNSGLVideoViewDelegate @end @interface RTCNSGLVideoView : NSOpenGLView diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h index d9ddffbe1e..94036cc753 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h @@ -31,7 +31,7 @@ typedef NS_ENUM(NSInteger, RTCRtpMediaType); NS_ASSUME_NONNULL_BEGIN -extern NSString * const kRTCPeerConnectionErrorDomain; +extern NSString *const kRTCPeerConnectionErrorDomain; extern int const kRTCSessionDescriptionErrorCode; /** Represents the signaling state of the peer connection. */ @@ -80,14 +80,12 @@ RTC_EXPORT didChangeSignalingState:(RTCSignalingState)stateChanged; /** Called when media is received on a new stream from remote peer. */ -- (void)peerConnection:(RTCPeerConnection *)peerConnection - didAddStream:(RTCMediaStream *)stream; +- (void)peerConnection:(RTCPeerConnection *)peerConnection didAddStream:(RTCMediaStream *)stream; /** Called when a remote peer closes a stream. * This is not called when RTCSdpSemanticsUnifiedPlan is specified. */ -- (void)peerConnection:(RTCPeerConnection *)peerConnection - didRemoveStream:(RTCMediaStream *)stream; +- (void)peerConnection:(RTCPeerConnection *)peerConnection didRemoveStream:(RTCMediaStream *)stream; /** Called when negotiation is needed, for example ICE has restarted. */ - (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection; @@ -139,10 +137,8 @@ RTC_EXPORT * |senders| instead. */ @property(nonatomic, readonly) NSArray *localStreams; -@property(nonatomic, readonly, nullable) - RTCSessionDescription *localDescription; -@property(nonatomic, readonly, nullable) - RTCSessionDescription *remoteDescription; +@property(nonatomic, readonly, nullable) RTCSessionDescription *localDescription; +@property(nonatomic, readonly, nullable) RTCSessionDescription *remoteDescription; @property(nonatomic, readonly) RTCSignalingState signalingState; @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; @@ -252,25 +248,21 @@ RTC_EXPORT /** Generate an SDP offer. */ - (void)offerForConstraints:(RTCMediaConstraints *)constraints - completionHandler:(nullable void (^) - (RTCSessionDescription * _Nullable sdp, - NSError * _Nullable error))completionHandler; + completionHandler:(nullable void (^)(RTCSessionDescription *_Nullable sdp, + NSError *_Nullable error))completionHandler; /** Generate an SDP answer. */ - (void)answerForConstraints:(RTCMediaConstraints *)constraints - completionHandler:(nullable void (^) - (RTCSessionDescription * _Nullable sdp, - NSError * _Nullable error))completionHandler; + completionHandler:(nullable void (^)(RTCSessionDescription *_Nullable sdp, + NSError *_Nullable error))completionHandler; /** Apply the supplied RTCSessionDescription as the local description. */ - (void)setLocalDescription:(RTCSessionDescription *)sdp - completionHandler: - (nullable void (^)(NSError * _Nullable error))completionHandler; + completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler; /** Apply the supplied RTCSessionDescription as the remote description. */ - (void)setRemoteDescription:(RTCSessionDescription *)sdp - completionHandler: - (nullable void (^)(NSError * _Nullable error))completionHandler; + completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler; /** Limits the bandwidth allocated for all RTP streams sent by this * PeerConnection. Nil parameters will be unchanged. Setting @@ -282,8 +274,7 @@ RTC_EXPORT maxBitrateBps:(nullable NSNumber *)maxBitrateBps; /** Start or stop recording an Rtc EventLog. */ -- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath - maxSizeInBytes:(int64_t)maxSizeInBytes; +- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes; - (void)stopRtcEventLog; @end @@ -312,11 +303,9 @@ RTC_EXPORT /** Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil * statistics are gathered for all tracks. */ -- (void)statsForTrack: - (nullable RTCMediaStreamTrack *)mediaStreamTrack +- (void)statsForTrack:(nullable RTCMediaStreamTrack *)mediaStreamTrack statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel - completionHandler: - (nullable void (^)(NSArray *stats))completionHandler; + completionHandler:(nullable void (^)(NSArray *stats))completionHandler; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h index d00f6f2a5b..7f7b7e6c4c 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h @@ -46,8 +46,7 @@ RTC_EXPORT - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId; /** Initialize an RTCAudioTrack with a source and an id. */ -- (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source - trackId:(NSString *)trackId; +- (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source trackId:(NSString *)trackId; /** Initialize a generic RTCVideoSource. The RTCVideoSource should be passed to a RTCVideoCapturer * implementation, e.g. RTCCameraVideoCapturer, in order to produce frames. @@ -55,8 +54,7 @@ RTC_EXPORT - (RTCVideoSource *)videoSource; /** Initialize an RTCVideoTrack with a source and an id. */ -- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source - trackId:(NSString *)trackId; +- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source trackId:(NSString *)trackId; /** Initialize an RTCMediaStream with an id. */ - (RTCMediaStream *)mediaStreamWithStreamId:(NSString *)streamId; @@ -64,19 +62,16 @@ RTC_EXPORT /** Initialize an RTCPeerConnection with a configuration, constraints, and * delegate. */ -- (RTCPeerConnection *)peerConnectionWithConfiguration: - (RTCConfiguration *)configuration - constraints: - (RTCMediaConstraints *)constraints +- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration + constraints:(RTCMediaConstraints *)constraints delegate: - (nullable id)delegate; + (nullable id)delegate; /** Set the options to be used for subsequently created RTCPeerConnections */ - (void)setOptions:(nonnull RTCPeerConnectionFactoryOptions *)options; /** Start an AecDump recording. This API call will likely change in the future. */ -- (BOOL)startAecDumpWithFilePath:(NSString *)filePath - maxSizeInBytes:(int64_t)maxSizeInBytes; +- (BOOL)startAecDumpWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes; /* Stop an active AecDump recording */ - (void)stopAecDump; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCRtpCodecParameters.h b/sdk/objc/Framework/Headers/WebRTC/RTCRtpCodecParameters.h index 4ba03641a9..bb9aa90507 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCRtpCodecParameters.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCRtpCodecParameters.h @@ -14,22 +14,22 @@ NS_ASSUME_NONNULL_BEGIN -RTC_EXTERN const NSString * const kRTCRtxCodecName; -RTC_EXTERN const NSString * const kRTCRedCodecName; -RTC_EXTERN const NSString * const kRTCUlpfecCodecName; -RTC_EXTERN const NSString * const kRTCFlexfecCodecName; -RTC_EXTERN const NSString * const kRTCOpusCodecName; -RTC_EXTERN const NSString * const kRTCIsacCodecName; -RTC_EXTERN const NSString * const kRTCL16CodecName; -RTC_EXTERN const NSString * const kRTCG722CodecName; -RTC_EXTERN const NSString * const kRTCIlbcCodecName; -RTC_EXTERN const NSString * const kRTCPcmuCodecName; -RTC_EXTERN const NSString * const kRTCPcmaCodecName; -RTC_EXTERN const NSString * const kRTCDtmfCodecName; -RTC_EXTERN const NSString * const kRTCComfortNoiseCodecName; -RTC_EXTERN const NSString * const kRTCVp8CodecName; -RTC_EXTERN const NSString * const kRTCVp9CodecName; -RTC_EXTERN const NSString * const kRTCH264CodecName; +RTC_EXTERN const NSString *const kRTCRtxCodecName; +RTC_EXTERN const NSString *const kRTCRedCodecName; +RTC_EXTERN const NSString *const kRTCUlpfecCodecName; +RTC_EXTERN const NSString *const kRTCFlexfecCodecName; +RTC_EXTERN const NSString *const kRTCOpusCodecName; +RTC_EXTERN const NSString *const kRTCIsacCodecName; +RTC_EXTERN const NSString *const kRTCL16CodecName; +RTC_EXTERN const NSString *const kRTCG722CodecName; +RTC_EXTERN const NSString *const kRTCIlbcCodecName; +RTC_EXTERN const NSString *const kRTCPcmuCodecName; +RTC_EXTERN const NSString *const kRTCPcmaCodecName; +RTC_EXTERN const NSString *const kRTCDtmfCodecName; +RTC_EXTERN const NSString *const kRTCComfortNoiseCodecName; +RTC_EXTERN const NSString *const kRTCVp8CodecName; +RTC_EXTERN const NSString *const kRTCVp9CodecName; +RTC_EXTERN const NSString *const kRTCH264CodecName; /** Defined in http://w3c.github.io/webrtc-pc/#idl-def-RTCRtpCodecParameters */ RTC_EXPORT diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCSessionDescription.h b/sdk/objc/Framework/Headers/WebRTC/RTCSessionDescription.h index 41439804a8..7db53da8be 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCSessionDescription.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCSessionDescription.h @@ -36,8 +36,7 @@ RTC_EXPORT - (instancetype)init NS_UNAVAILABLE; /** Initialize a session description with a type and SDP string. */ -- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp NS_DESIGNATED_INITIALIZER; + (NSString *)stringForType:(RTCSdpType)type; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCTracing.h b/sdk/objc/Framework/Headers/WebRTC/RTCTracing.h index 5e7e48f294..899a57001e 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCTracing.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCTracing.h @@ -16,6 +16,6 @@ RTC_EXTERN void RTCSetupInternalTracer(void); /** Starts capture to specified file. Must be a valid writable path. * Returns YES if capture starts. */ -RTC_EXTERN BOOL RTCStartInternalCapture(NSString *filePath); +RTC_EXTERN BOOL RTCStartInternalCapture(NSString* filePath); RTC_EXTERN void RTCStopInternalCapture(void); RTC_EXTERN void RTCShutdownInternalTracer(void); diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h index c0d464e068..5bc6d66d1e 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h @@ -172,9 +172,9 @@ RTC_EXPORT DEPRECATED_MSG_ATTRIBUTE("use startDecodeWithNumberOfCores: instead"); - (NSInteger)releaseDecoder; - (NSInteger)decode:(RTCEncodedImage *)encodedImage - missingFrames:(BOOL)missingFrames - codecSpecificInfo:(nullable id)info - renderTimeMs:(int64_t)renderTimeMs; + missingFrames:(BOOL)missingFrames + codecSpecificInfo:(nullable id)info + renderTimeMs:(int64_t)renderTimeMs; - (NSString *)implementationName; // TODO(andersc): Make non-optional when `startDecodeWithSettings:numberOfCores:` is removed. diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h index d18e96dd47..d4dbf88f2b 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h @@ -69,7 +69,7 @@ RTC_EXPORT /** Encoder. */ RTC_EXPORT -@interface RTCVideoEncoderH264 : NSObject +@interface RTCVideoEncoderH264 : NSObject - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo; @@ -77,15 +77,15 @@ RTC_EXPORT /** Decoder. */ RTC_EXPORT -@interface RTCVideoDecoderH264 : NSObject +@interface RTCVideoDecoderH264 : NSObject @end /** Encoder factory. */ RTC_EXPORT -@interface RTCVideoEncoderFactoryH264 : NSObject +@interface RTCVideoEncoderFactoryH264 : NSObject @end /** Decoder factory. */ RTC_EXPORT -@interface RTCVideoDecoderFactoryH264 : NSObject +@interface RTCVideoDecoderFactoryH264 : NSObject @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrame.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrame.h index dcc4c6e7b5..cfccfa9e94 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrame.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrame.h @@ -44,7 +44,7 @@ RTC_EXPORT @property(nonatomic, readonly) id buffer; - (instancetype)init NS_UNAVAILABLE; -- (instancetype)new NS_UNAVAILABLE; +- (instancetype) new NS_UNAVAILABLE; /** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp. * Deprecated - initialize with a RTCCVPixelBuffer instead diff --git a/sdk/objc/Framework/Native/api/audio_device_module.h b/sdk/objc/Framework/Native/api/audio_device_module.h index 2c519ba534..aaeb39b18c 100644 --- a/sdk/objc/Framework/Native/api/audio_device_module.h +++ b/sdk/objc/Framework/Native/api/audio_device_module.h @@ -21,4 +21,4 @@ rtc::scoped_refptr CreateAudioDeviceModule(); } // namespace webrtc -#endif // SDK_OBJC_FRAMEWORK_NATIVE_API_AUDIO_DEVICE_MODULE_H_ +#endif // SDK_OBJC_FRAMEWORK_NATIVE_API_AUDIO_DEVICE_MODULE_H_ diff --git a/sdk/objc/Framework/Native/src/audio/audio_device_ios.h b/sdk/objc/Framework/Native/src/audio/audio_device_ios.h index 4001f49055..56326c12b7 100644 --- a/sdk/objc/Framework/Native/src/audio/audio_device_ios.h +++ b/sdk/objc/Framework/Native/src/audio/audio_device_ios.h @@ -13,14 +13,14 @@ #include -#include "sdk/objc/Framework/Headers/WebRTC/RTCMacros.h" -#include "modules/audio_device/audio_device_generic.h" #include "audio_session_observer.h" -#include "voice_processing_audio_unit.h" +#include "modules/audio_device/audio_device_generic.h" #include "rtc_base/buffer.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/thread_checker.h" +#include "sdk/objc/Framework/Headers/WebRTC/RTCMacros.h" +#include "voice_processing_audio_unit.h" RTC_FWD_DECL_OBJC_CLASS(RTCNativeAudioSessionDelegateAdapter); @@ -155,7 +155,7 @@ class AudioDeviceIOS : public AudioDeviceGeneric, AudioBufferList* io_data) override; // Handles messages from posts. - void OnMessage(rtc::Message *msg) override; + void OnMessage(rtc::Message* msg) override; bool IsInterrupted(); diff --git a/sdk/objc/Framework/Native/src/audio/audio_device_module_ios.h b/sdk/objc/Framework/Native/src/audio/audio_device_module_ios.h index 5f9bb6a41d..8e1ace44fd 100644 --- a/sdk/objc/Framework/Native/src/audio/audio_device_module_ios.h +++ b/sdk/objc/Framework/Native/src/audio/audio_device_module_ios.h @@ -20,124 +20,120 @@ #include "rtc_base/checks.h" #include "rtc_base/criticalsection.h" - namespace webrtc { class AudioDeviceGeneric; namespace ios_adm { - class AudioDeviceModuleIOS : public AudioDeviceModule { +class AudioDeviceModuleIOS : public AudioDeviceModule { + public: + int32_t AttachAudioBuffer(); - public: + AudioDeviceModuleIOS(); + ~AudioDeviceModuleIOS() override; - int32_t AttachAudioBuffer(); + // Retrieve the currently utilized audio layer + int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override; - AudioDeviceModuleIOS(); - ~AudioDeviceModuleIOS() override; + // Full-duplex transportation of PCM audio + int32_t RegisterAudioCallback(AudioTransport* audioCallback) override; - // Retrieve the currently utilized audio layer - int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override; + // Main initializaton and termination + int32_t Init() override; + int32_t Terminate() override; + bool Initialized() const override; - // Full-duplex transportation of PCM audio - int32_t RegisterAudioCallback(AudioTransport* audioCallback) override; - - // Main initializaton and termination - int32_t Init() override; - int32_t Terminate() override; - bool Initialized() const override; - - // Device enumeration - int16_t PlayoutDevices() override; - int16_t RecordingDevices() override; - int32_t PlayoutDeviceName(uint16_t index, + // Device enumeration + int16_t PlayoutDevices() override; + int16_t RecordingDevices() override; + int32_t PlayoutDeviceName(uint16_t index, + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]) override; + int32_t RecordingDeviceName(uint16_t index, char name[kAdmMaxDeviceNameSize], char guid[kAdmMaxGuidSize]) override; - int32_t RecordingDeviceName(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]) override; - // Device selection - int32_t SetPlayoutDevice(uint16_t index) override; - int32_t SetPlayoutDevice(WindowsDeviceType device) override; - int32_t SetRecordingDevice(uint16_t index) override; - int32_t SetRecordingDevice(WindowsDeviceType device) override; + // Device selection + int32_t SetPlayoutDevice(uint16_t index) override; + int32_t SetPlayoutDevice(WindowsDeviceType device) override; + int32_t SetRecordingDevice(uint16_t index) override; + int32_t SetRecordingDevice(WindowsDeviceType device) override; - // Audio transport initialization - int32_t PlayoutIsAvailable(bool* available) override; - int32_t InitPlayout() override; - bool PlayoutIsInitialized() const override; - int32_t RecordingIsAvailable(bool* available) override; - int32_t InitRecording() override; - bool RecordingIsInitialized() const override; + // Audio transport initialization + int32_t PlayoutIsAvailable(bool* available) override; + int32_t InitPlayout() override; + bool PlayoutIsInitialized() const override; + int32_t RecordingIsAvailable(bool* available) override; + int32_t InitRecording() override; + bool RecordingIsInitialized() const override; - // Audio transport control - int32_t StartPlayout() override; - int32_t StopPlayout() override; - bool Playing() const override; - int32_t StartRecording() override; - int32_t StopRecording() override; - bool Recording() const override; + // Audio transport control + int32_t StartPlayout() override; + int32_t StopPlayout() override; + bool Playing() const override; + int32_t StartRecording() override; + int32_t StopRecording() override; + bool Recording() const override; - // Audio mixer initialization - int32_t InitSpeaker() override; - bool SpeakerIsInitialized() const override; - int32_t InitMicrophone() override; - bool MicrophoneIsInitialized() const override; + // Audio mixer initialization + int32_t InitSpeaker() override; + bool SpeakerIsInitialized() const override; + int32_t InitMicrophone() override; + bool MicrophoneIsInitialized() const override; - // Speaker volume controls - int32_t SpeakerVolumeIsAvailable(bool* available) override; - int32_t SetSpeakerVolume(uint32_t volume) override; - int32_t SpeakerVolume(uint32_t* volume) const override; - int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override; - int32_t MinSpeakerVolume(uint32_t* minVolume) const override; + // Speaker volume controls + int32_t SpeakerVolumeIsAvailable(bool* available) override; + int32_t SetSpeakerVolume(uint32_t volume) override; + int32_t SpeakerVolume(uint32_t* volume) const override; + int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override; + int32_t MinSpeakerVolume(uint32_t* minVolume) const override; - // Microphone volume controls - int32_t MicrophoneVolumeIsAvailable(bool* available) override; - int32_t SetMicrophoneVolume(uint32_t volume) override; - int32_t MicrophoneVolume(uint32_t* volume) const override; - int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override; - int32_t MinMicrophoneVolume(uint32_t* minVolume) const override; + // Microphone volume controls + int32_t MicrophoneVolumeIsAvailable(bool* available) override; + int32_t SetMicrophoneVolume(uint32_t volume) override; + int32_t MicrophoneVolume(uint32_t* volume) const override; + int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override; + int32_t MinMicrophoneVolume(uint32_t* minVolume) const override; - // Speaker mute control - int32_t SpeakerMuteIsAvailable(bool* available) override; - int32_t SetSpeakerMute(bool enable) override; - int32_t SpeakerMute(bool* enabled) const override; + // Speaker mute control + int32_t SpeakerMuteIsAvailable(bool* available) override; + int32_t SetSpeakerMute(bool enable) override; + int32_t SpeakerMute(bool* enabled) const override; - // Microphone mute control - int32_t MicrophoneMuteIsAvailable(bool* available) override; - int32_t SetMicrophoneMute(bool enable) override; - int32_t MicrophoneMute(bool* enabled) const override; + // Microphone mute control + int32_t MicrophoneMuteIsAvailable(bool* available) override; + int32_t SetMicrophoneMute(bool enable) override; + int32_t MicrophoneMute(bool* enabled) const override; - // Stereo support - int32_t StereoPlayoutIsAvailable(bool* available) const override; - int32_t SetStereoPlayout(bool enable) override; - int32_t StereoPlayout(bool* enabled) const override; - int32_t StereoRecordingIsAvailable(bool* available) const override; - int32_t SetStereoRecording(bool enable) override; - int32_t StereoRecording(bool* enabled) const override; + // Stereo support + int32_t StereoPlayoutIsAvailable(bool* available) const override; + int32_t SetStereoPlayout(bool enable) override; + int32_t StereoPlayout(bool* enabled) const override; + int32_t StereoRecordingIsAvailable(bool* available) const override; + int32_t SetStereoRecording(bool enable) override; + int32_t StereoRecording(bool* enabled) const override; - // Delay information and control - int32_t PlayoutDelay(uint16_t* delayMS) const override; + // Delay information and control + int32_t PlayoutDelay(uint16_t* delayMS) const override; - bool BuiltInAECIsAvailable() const override; - int32_t EnableBuiltInAEC(bool enable) override; - bool BuiltInAGCIsAvailable() const override; - int32_t EnableBuiltInAGC(bool enable) override; - bool BuiltInNSIsAvailable() const override; - int32_t EnableBuiltInNS(bool enable) override; + bool BuiltInAECIsAvailable() const override; + int32_t EnableBuiltInAEC(bool enable) override; + bool BuiltInAGCIsAvailable() const override; + int32_t EnableBuiltInAGC(bool enable) override; + bool BuiltInNSIsAvailable() const override; + int32_t EnableBuiltInNS(bool enable) override; #if defined(WEBRTC_IOS) - int GetPlayoutAudioParameters(AudioParameters* params) const override; - int GetRecordAudioParameters(AudioParameters* params) const override; + int GetPlayoutAudioParameters(AudioParameters* params) const override; + int GetRecordAudioParameters(AudioParameters* params) const override; #endif // WEBRTC_IOS - private: - bool initialized_ = false; - std::unique_ptr audio_device_; - std::unique_ptr audio_device_buffer_; - - }; -} // namespace ios_adm -} // namespace webrtc + private: + bool initialized_ = false; + std::unique_ptr audio_device_; + std::unique_ptr audio_device_buffer_; +}; +} // namespace ios_adm +} // namespace webrtc #endif // SDK_IOS_NATIVE_API_AUDIO_DEVICE_MODULE_AUDIO_DEVICE_IOS_H_ diff --git a/stats/rtcstats.cc b/stats/rtcstats.cc index e4460bd90c..0a348e907c 100644 --- a/stats/rtcstats.cc +++ b/stats/rtcstats.cc @@ -21,7 +21,7 @@ namespace { // Produces "[a,b,c]". Works for non-vector |RTCStatsMemberInterface::Type| // types. -template +template std::string VectorToString(const std::vector& vector) { if (vector.empty()) return "[]"; @@ -36,7 +36,7 @@ std::string VectorToString(const std::vector& vector) { // Produces "[\"a\",\"b\",\"c\"]". Works for vectors of both const char* and // std::string element types. -template +template std::string VectorOfStringsToString(const std::vector& strings) { if (strings.empty()) return "[]"; @@ -118,8 +118,7 @@ std::vector RTCStats::Members() const { } std::vector -RTCStats::MembersOfThisObjectAndAncestors( - size_t additional_capacity) const { +RTCStats::MembersOfThisObjectAndAncestors(size_t additional_capacity) const { std::vector members; members.reserve(additional_capacity); return members; @@ -184,12 +183,7 @@ WEBRTC_DEFINE_RTCSTATSMEMBER(double, false, rtc::ToString(value_), ToStringAsDouble(value_)); -WEBRTC_DEFINE_RTCSTATSMEMBER(std::string, - kString, - false, - true, - value_, - value_); +WEBRTC_DEFINE_RTCSTATSMEMBER(std::string, kString, false, true, value_, value_); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector, kSequenceBool, true, diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 7b697f0f77..b711a27758 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -55,31 +55,25 @@ WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate", &issuer_certificate_id); // clang-format on -RTCCertificateStats::RTCCertificateStats( - const std::string& id, int64_t timestamp_us) - : RTCCertificateStats(std::string(id), timestamp_us) { -} +RTCCertificateStats::RTCCertificateStats(const std::string& id, + int64_t timestamp_us) + : RTCCertificateStats(std::string(id), timestamp_us) {} -RTCCertificateStats::RTCCertificateStats( - std::string&& id, int64_t timestamp_us) +RTCCertificateStats::RTCCertificateStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), fingerprint("fingerprint"), fingerprint_algorithm("fingerprintAlgorithm"), base64_certificate("base64Certificate"), - issuer_certificate_id("issuerCertificateId") { -} + issuer_certificate_id("issuerCertificateId") {} -RTCCertificateStats::RTCCertificateStats( - const RTCCertificateStats& other) +RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other) : RTCStats(other.id(), other.timestamp_us()), fingerprint(other.fingerprint), fingerprint_algorithm(other.fingerprint_algorithm), base64_certificate(other.base64_certificate), - issuer_certificate_id(other.issuer_certificate_id) { -} + issuer_certificate_id(other.issuer_certificate_id) {} -RTCCertificateStats::~RTCCertificateStats() { -} +RTCCertificateStats::~RTCCertificateStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec", @@ -91,35 +85,28 @@ WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec", &implementation); // clang-format on -RTCCodecStats::RTCCodecStats( - const std::string& id, int64_t timestamp_us) - : RTCCodecStats(std::string(id), timestamp_us) { -} +RTCCodecStats::RTCCodecStats(const std::string& id, int64_t timestamp_us) + : RTCCodecStats(std::string(id), timestamp_us) {} -RTCCodecStats::RTCCodecStats( - std::string&& id, int64_t timestamp_us) +RTCCodecStats::RTCCodecStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), payload_type("payloadType"), mime_type("mimeType"), clock_rate("clockRate"), channels("channels"), sdp_fmtp_line("sdpFmtpLine"), - implementation("implementation") { -} + implementation("implementation") {} -RTCCodecStats::RTCCodecStats( - const RTCCodecStats& other) +RTCCodecStats::RTCCodecStats(const RTCCodecStats& other) : RTCStats(other.id(), other.timestamp_us()), payload_type(other.payload_type), mime_type(other.mime_type), clock_rate(other.clock_rate), channels(other.channels), sdp_fmtp_line(other.sdp_fmtp_line), - implementation(other.implementation) { -} + implementation(other.implementation) {} -RTCCodecStats::~RTCCodecStats() { -} +RTCCodecStats::~RTCCodecStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel", @@ -133,13 +120,11 @@ WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel", &bytes_received); // clang-format on -RTCDataChannelStats::RTCDataChannelStats( - const std::string& id, int64_t timestamp_us) - : RTCDataChannelStats(std::string(id), timestamp_us) { -} +RTCDataChannelStats::RTCDataChannelStats(const std::string& id, + int64_t timestamp_us) + : RTCDataChannelStats(std::string(id), timestamp_us) {} -RTCDataChannelStats::RTCDataChannelStats( - std::string&& id, int64_t timestamp_us) +RTCDataChannelStats::RTCDataChannelStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), label("label"), protocol("protocol"), @@ -148,11 +133,9 @@ RTCDataChannelStats::RTCDataChannelStats( messages_sent("messagesSent"), bytes_sent("bytesSent"), messages_received("messagesReceived"), - bytes_received("bytesReceived") { -} + bytes_received("bytesReceived") {} -RTCDataChannelStats::RTCDataChannelStats( - const RTCDataChannelStats& other) +RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other) : RTCStats(other.id(), other.timestamp_us()), label(other.label), protocol(other.protocol), @@ -161,11 +144,9 @@ RTCDataChannelStats::RTCDataChannelStats( messages_sent(other.messages_sent), bytes_sent(other.bytes_sent), messages_received(other.messages_received), - bytes_received(other.bytes_received) { -} + bytes_received(other.bytes_received) {} -RTCDataChannelStats::~RTCDataChannelStats() { -} +RTCDataChannelStats::~RTCDataChannelStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair", @@ -195,13 +176,12 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair", &consent_responses_sent); // clang-format on -RTCIceCandidatePairStats::RTCIceCandidatePairStats( - const std::string& id, int64_t timestamp_us) - : RTCIceCandidatePairStats(std::string(id), timestamp_us) { -} +RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id, + int64_t timestamp_us) + : RTCIceCandidatePairStats(std::string(id), timestamp_us) {} -RTCIceCandidatePairStats::RTCIceCandidatePairStats( - std::string&& id, int64_t timestamp_us) +RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id, + int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), transport_id("transportId"), local_candidate_id("localCandidateId"), @@ -226,8 +206,7 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats( consent_requests_received("consentRequestsReceived"), consent_requests_sent("consentRequestsSent"), consent_responses_received("consentResponsesReceived"), - consent_responses_sent("consentResponsesSent") { -} + consent_responses_sent("consentResponsesSent") {} RTCIceCandidatePairStats::RTCIceCandidatePairStats( const RTCIceCandidatePairStats& other) @@ -255,11 +234,9 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats( consent_requests_received(other.consent_requests_received), consent_requests_sent(other.consent_requests_sent), consent_responses_received(other.consent_responses_received), - consent_responses_sent(other.consent_responses_sent) { -} + consent_responses_sent(other.consent_responses_sent) {} -RTCIceCandidatePairStats::~RTCIceCandidatePairStats() { -} +RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate", @@ -275,10 +252,10 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate", &deleted); // clang-format on -RTCIceCandidateStats::RTCIceCandidateStats( - const std::string& id, int64_t timestamp_us, bool is_remote) - : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) { -} +RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id, + int64_t timestamp_us, + bool is_remote) + : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) {} RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, @@ -308,20 +285,17 @@ RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) url(other.url), deleted(other.deleted) {} -RTCIceCandidateStats::~RTCIceCandidateStats() { -} +RTCIceCandidateStats::~RTCIceCandidateStats() {} const char RTCLocalIceCandidateStats::kType[] = "local-candidate"; -RTCLocalIceCandidateStats::RTCLocalIceCandidateStats( - const std::string& id, int64_t timestamp_us) - : RTCIceCandidateStats(id, timestamp_us, false) { -} +RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(const std::string& id, + int64_t timestamp_us) + : RTCIceCandidateStats(id, timestamp_us, false) {} -RTCLocalIceCandidateStats::RTCLocalIceCandidateStats( - std::string&& id, int64_t timestamp_us) - : RTCIceCandidateStats(std::move(id), timestamp_us, false) { -} +RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id, + int64_t timestamp_us) + : RTCIceCandidateStats(std::move(id), timestamp_us, false) {} std::unique_ptr RTCLocalIceCandidateStats::copy() const { return std::unique_ptr(new RTCLocalIceCandidateStats(*this)); @@ -333,15 +307,13 @@ const char* RTCLocalIceCandidateStats::type() const { const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate"; -RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats( - const std::string& id, int64_t timestamp_us) - : RTCIceCandidateStats(id, timestamp_us, true) { -} +RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(const std::string& id, + int64_t timestamp_us) + : RTCIceCandidateStats(id, timestamp_us, true) {} -RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats( - std::string&& id, int64_t timestamp_us) - : RTCIceCandidateStats(std::move(id), timestamp_us, true) { -} +RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id, + int64_t timestamp_us) + : RTCIceCandidateStats(std::move(id), timestamp_us, true) {} std::unique_ptr RTCRemoteIceCandidateStats::copy() const { return std::unique_ptr(new RTCRemoteIceCandidateStats(*this)); @@ -357,27 +329,21 @@ WEBRTC_RTCSTATS_IMPL(RTCMediaStreamStats, RTCStats, "stream", &track_ids); // clang-format on -RTCMediaStreamStats::RTCMediaStreamStats( - const std::string& id, int64_t timestamp_us) - : RTCMediaStreamStats(std::string(id), timestamp_us) { -} +RTCMediaStreamStats::RTCMediaStreamStats(const std::string& id, + int64_t timestamp_us) + : RTCMediaStreamStats(std::string(id), timestamp_us) {} -RTCMediaStreamStats::RTCMediaStreamStats( - std::string&& id, int64_t timestamp_us) +RTCMediaStreamStats::RTCMediaStreamStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), stream_identifier("streamIdentifier"), - track_ids("trackIds") { -} + track_ids("trackIds") {} -RTCMediaStreamStats::RTCMediaStreamStats( - const RTCMediaStreamStats& other) +RTCMediaStreamStats::RTCMediaStreamStats(const RTCMediaStreamStats& other) : RTCStats(other.id(), other.timestamp_us()), stream_identifier(other.stream_identifier), - track_ids(other.track_ids) { -} + track_ids(other.track_ids) {} -RTCMediaStreamStats::~RTCMediaStreamStats() { -} +RTCMediaStreamStats::~RTCMediaStreamStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track", @@ -408,10 +374,10 @@ WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track", &concealment_events); // clang-format on -RTCMediaStreamTrackStats::RTCMediaStreamTrackStats( - const std::string& id, int64_t timestamp_us, const char* kind) - : RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) { -} +RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(const std::string& id, + int64_t timestamp_us, + const char* kind) + : RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) {} RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id, int64_t timestamp_us, @@ -475,8 +441,7 @@ RTCMediaStreamTrackStats::RTCMediaStreamTrackStats( concealed_samples(other.concealed_samples), concealment_events(other.concealment_events) {} -RTCMediaStreamTrackStats::~RTCMediaStreamTrackStats() { -} +RTCMediaStreamTrackStats::~RTCMediaStreamTrackStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection", @@ -484,27 +449,23 @@ WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection", &data_channels_closed); // clang-format on -RTCPeerConnectionStats::RTCPeerConnectionStats( - const std::string& id, int64_t timestamp_us) - : RTCPeerConnectionStats(std::string(id), timestamp_us) { -} +RTCPeerConnectionStats::RTCPeerConnectionStats(const std::string& id, + int64_t timestamp_us) + : RTCPeerConnectionStats(std::string(id), timestamp_us) {} -RTCPeerConnectionStats::RTCPeerConnectionStats( - std::string&& id, int64_t timestamp_us) +RTCPeerConnectionStats::RTCPeerConnectionStats(std::string&& id, + int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), data_channels_opened("dataChannelsOpened"), - data_channels_closed("dataChannelsClosed") { -} + data_channels_closed("dataChannelsClosed") {} RTCPeerConnectionStats::RTCPeerConnectionStats( const RTCPeerConnectionStats& other) : RTCStats(other.id(), other.timestamp_us()), data_channels_opened(other.data_channels_opened), - data_channels_closed(other.data_channels_closed) { -} + data_channels_closed(other.data_channels_closed) {} -RTCPeerConnectionStats::~RTCPeerConnectionStats() { -} +RTCPeerConnectionStats::~RTCPeerConnectionStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp", @@ -522,13 +483,11 @@ WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp", &qp_sum); // clang-format on -RTCRTPStreamStats::RTCRTPStreamStats( - const std::string& id, int64_t timestamp_us) - : RTCRTPStreamStats(std::string(id), timestamp_us) { -} +RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id, + int64_t timestamp_us) + : RTCRTPStreamStats(std::string(id), timestamp_us) {} -RTCRTPStreamStats::RTCRTPStreamStats( - std::string&& id, int64_t timestamp_us) +RTCRTPStreamStats::RTCRTPStreamStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), ssrc("ssrc"), associate_stats_id("associateStatsId"), @@ -541,11 +500,9 @@ RTCRTPStreamStats::RTCRTPStreamStats( pli_count("pliCount"), nack_count("nackCount"), sli_count("sliCount"), - qp_sum("qpSum") { -} + qp_sum("qpSum") {} -RTCRTPStreamStats::RTCRTPStreamStats( - const RTCRTPStreamStats& other) +RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other) : RTCStats(other.id(), other.timestamp_us()), ssrc(other.ssrc), associate_stats_id(other.associate_stats_id), @@ -558,11 +515,9 @@ RTCRTPStreamStats::RTCRTPStreamStats( pli_count(other.pli_count), nack_count(other.nack_count), sli_count(other.sli_count), - qp_sum(other.qp_sum) { -} + qp_sum(other.qp_sum) {} -RTCRTPStreamStats::~RTCRTPStreamStats() { -} +RTCRTPStreamStats::~RTCRTPStreamStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL( @@ -586,13 +541,12 @@ WEBRTC_RTCSTATS_IMPL( &frames_decoded); // clang-format on -RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( - const std::string& id, int64_t timestamp_us) - : RTCInboundRTPStreamStats(std::string(id), timestamp_us) { -} +RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id, + int64_t timestamp_us) + : RTCInboundRTPStreamStats(std::string(id), timestamp_us) {} -RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( - std::string&& id, int64_t timestamp_us) +RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, + int64_t timestamp_us) : RTCRTPStreamStats(std::move(id), timestamp_us), packets_received("packetsReceived"), bytes_received("bytesReceived"), @@ -610,8 +564,7 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( burst_discard_rate("burstDiscardRate"), gap_loss_rate("gapLossRate"), gap_discard_rate("gapDiscardRate"), - frames_decoded("framesDecoded") { -} + frames_decoded("framesDecoded") {} RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( const RTCInboundRTPStreamStats& other) @@ -632,11 +585,9 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( burst_discard_rate(other.burst_discard_rate), gap_loss_rate(other.gap_loss_rate), gap_discard_rate(other.gap_discard_rate), - frames_decoded(other.frames_decoded) { -} + frames_decoded(other.frames_decoded) {} -RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() { -} +RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL( @@ -647,19 +598,17 @@ WEBRTC_RTCSTATS_IMPL( &frames_encoded); // clang-format on -RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats( - const std::string& id, int64_t timestamp_us) - : RTCOutboundRTPStreamStats(std::string(id), timestamp_us) { -} +RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id, + int64_t timestamp_us) + : RTCOutboundRTPStreamStats(std::string(id), timestamp_us) {} -RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats( - std::string&& id, int64_t timestamp_us) +RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id, + int64_t timestamp_us) : RTCRTPStreamStats(std::move(id), timestamp_us), packets_sent("packetsSent"), bytes_sent("bytesSent"), target_bitrate("targetBitrate"), - frames_encoded("framesEncoded") { -} + frames_encoded("framesEncoded") {} RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats( const RTCOutboundRTPStreamStats& other) @@ -667,11 +616,9 @@ RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats( packets_sent(other.packets_sent), bytes_sent(other.bytes_sent), target_bitrate(other.target_bitrate), - frames_encoded(other.frames_encoded) { -} + frames_encoded(other.frames_encoded) {} -RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() { -} +RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport", @@ -684,13 +631,11 @@ WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport", &remote_certificate_id); // clang-format on -RTCTransportStats::RTCTransportStats( - const std::string& id, int64_t timestamp_us) - : RTCTransportStats(std::string(id), timestamp_us) { -} +RTCTransportStats::RTCTransportStats(const std::string& id, + int64_t timestamp_us) + : RTCTransportStats(std::string(id), timestamp_us) {} -RTCTransportStats::RTCTransportStats( - std::string&& id, int64_t timestamp_us) +RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), bytes_sent("bytesSent"), bytes_received("bytesReceived"), @@ -698,11 +643,9 @@ RTCTransportStats::RTCTransportStats( dtls_state("dtlsState"), selected_candidate_pair_id("selectedCandidatePairId"), local_certificate_id("localCertificateId"), - remote_certificate_id("remoteCertificateId") { -} + remote_certificate_id("remoteCertificateId") {} -RTCTransportStats::RTCTransportStats( - const RTCTransportStats& other) +RTCTransportStats::RTCTransportStats(const RTCTransportStats& other) : RTCStats(other.id(), other.timestamp_us()), bytes_sent(other.bytes_sent), bytes_received(other.bytes_received), @@ -710,10 +653,8 @@ RTCTransportStats::RTCTransportStats( dtls_state(other.dtls_state), selected_candidate_pair_id(other.selected_candidate_pair_id), local_certificate_id(other.local_certificate_id), - remote_certificate_id(other.remote_certificate_id) { -} + remote_certificate_id(other.remote_certificate_id) {} -RTCTransportStats::~RTCTransportStats() { -} +RTCTransportStats::~RTCTransportStats() {} } // namespace webrtc diff --git a/stats/rtcstats_unittest.cc b/stats/rtcstats_unittest.cc index 7148c9fc2f..a3f005d4e6 100644 --- a/stats/rtcstats_unittest.cc +++ b/stats/rtcstats_unittest.cc @@ -42,28 +42,27 @@ class RTCChildStats : public RTCStats { WEBRTC_RTCSTATS_DECL(); RTCChildStats(const std::string& id, int64_t timestamp_us) - : RTCStats(id, timestamp_us), - child_int("childInt") {} + : RTCStats(id, timestamp_us), child_int("childInt") {} RTCStatsMember child_int; }; -WEBRTC_RTCSTATS_IMPL(RTCChildStats, RTCStats, "child-stats", - &child_int); +WEBRTC_RTCSTATS_IMPL(RTCChildStats, RTCStats, "child-stats", &child_int); class RTCGrandChildStats : public RTCChildStats { public: WEBRTC_RTCSTATS_DECL(); RTCGrandChildStats(const std::string& id, int64_t timestamp_us) - : RTCChildStats(id, timestamp_us), - grandchild_int("grandchildInt") {} + : RTCChildStats(id, timestamp_us), grandchild_int("grandchildInt") {} RTCStatsMember grandchild_int; }; -WEBRTC_RTCSTATS_IMPL(RTCGrandChildStats, RTCChildStats, "grandchild-stats", - &grandchild_int); +WEBRTC_RTCSTATS_IMPL(RTCGrandChildStats, + RTCChildStats, + "grandchild-stats", + &grandchild_int); TEST(RTCStatsTest, RTCStatsAndMembers) { RTCTestStats stats("testId", 42); @@ -123,7 +122,7 @@ TEST(RTCStatsTest, RTCStatsAndMembers) { EXPECT_EQ(*stats.m_sequence_double, sequence_double); EXPECT_EQ(*stats.m_sequence_string, sequence_string); - int32_t numbers[] = { 4, 8, 15, 16, 23, 42 }; + int32_t numbers[] = {4, 8, 15, 16, 23, 42}; std::vector numbers_sequence(&numbers[0], &numbers[6]); stats.m_sequence_int32->clear(); stats.m_sequence_int32->insert(stats.m_sequence_int32->end(), @@ -156,11 +155,11 @@ TEST(RTCStatsTest, EqualityOperator) { EXPECT_NE(stats_with_all_values.m_int32, stats_with_all_values.m_uint32); RTCTestStats one_member_different[] = { - stats_with_all_values, stats_with_all_values, stats_with_all_values, - stats_with_all_values, stats_with_all_values, stats_with_all_values, - stats_with_all_values, stats_with_all_values, stats_with_all_values, - stats_with_all_values, stats_with_all_values, stats_with_all_values, - stats_with_all_values, stats_with_all_values, + stats_with_all_values, stats_with_all_values, stats_with_all_values, + stats_with_all_values, stats_with_all_values, stats_with_all_values, + stats_with_all_values, stats_with_all_values, stats_with_all_values, + stats_with_all_values, stats_with_all_values, stats_with_all_values, + stats_with_all_values, stats_with_all_values, }; for (size_t i = 0; i < 14; ++i) { EXPECT_EQ(stats_with_all_values, one_member_different[i]); diff --git a/stats/rtcstatsreport.cc b/stats/rtcstatsreport.cc index 0918567e5d..33f6b6a121 100644 --- a/stats/rtcstatsreport.cc +++ b/stats/rtcstatsreport.cc @@ -17,17 +17,12 @@ namespace webrtc { RTCStatsReport::ConstIterator::ConstIterator( const rtc::scoped_refptr& report, StatsMap::const_iterator it) - : report_(report), - it_(it) { -} + : report_(report), it_(it) {} RTCStatsReport::ConstIterator::ConstIterator(const ConstIterator&& other) - : report_(std::move(other.report_)), - it_(std::move(other.it_)) { -} + : report_(std::move(other.report_)), it_(std::move(other.it_)) {} -RTCStatsReport::ConstIterator::~ConstIterator() { -} +RTCStatsReport::ConstIterator::~ConstIterator() {} RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++() { ++it_; @@ -63,11 +58,9 @@ rtc::scoped_refptr RTCStatsReport::Create( } RTCStatsReport::RTCStatsReport(int64_t timestamp_us) - : timestamp_us_(timestamp_us) { -} + : timestamp_us_(timestamp_us) {} -RTCStatsReport::~RTCStatsReport() { -} +RTCStatsReport::~RTCStatsReport() {} rtc::scoped_refptr RTCStatsReport::Copy() const { rtc::scoped_refptr copy = Create(timestamp_us_); @@ -78,11 +71,12 @@ rtc::scoped_refptr RTCStatsReport::Copy() const { } void RTCStatsReport::AddStats(std::unique_ptr stats) { - auto result = stats_.insert(std::make_pair(std::string(stats->id()), - std::move(stats))); - RTC_DCHECK(result.second) << - "A stats object with ID " << result.first->second->id() << " is already " - "present in this stats report."; + auto result = + stats_.insert(std::make_pair(std::string(stats->id()), std::move(stats))); + RTC_DCHECK(result.second) + << "A stats object with ID " << result.first->second->id() + << " is already " + "present in this stats report."; } const RTCStats* RTCStatsReport::Get(const std::string& id) const { diff --git a/stats/rtcstatsreport_unittest.cc b/stats/rtcstatsreport_unittest.cc index 809cae1d24..4df99e175b 100644 --- a/stats/rtcstatsreport_unittest.cc +++ b/stats/rtcstatsreport_unittest.cc @@ -21,42 +21,36 @@ class RTCTestStats1 : public RTCStats { WEBRTC_RTCSTATS_DECL(); RTCTestStats1(const std::string& id, int64_t timestamp_us) - : RTCStats(id, timestamp_us), - integer("integer") {} + : RTCStats(id, timestamp_us), integer("integer") {} RTCStatsMember integer; }; -WEBRTC_RTCSTATS_IMPL(RTCTestStats1, RTCStats, "test-stats-1", - &integer); +WEBRTC_RTCSTATS_IMPL(RTCTestStats1, RTCStats, "test-stats-1", &integer); class RTCTestStats2 : public RTCStats { public: WEBRTC_RTCSTATS_DECL(); RTCTestStats2(const std::string& id, int64_t timestamp_us) - : RTCStats(id, timestamp_us), - number("number") {} + : RTCStats(id, timestamp_us), number("number") {} RTCStatsMember number; }; -WEBRTC_RTCSTATS_IMPL(RTCTestStats2, RTCStats, "test-stats-2", - &number); +WEBRTC_RTCSTATS_IMPL(RTCTestStats2, RTCStats, "test-stats-2", &number); class RTCTestStats3 : public RTCStats { public: WEBRTC_RTCSTATS_DECL(); RTCTestStats3(const std::string& id, int64_t timestamp_us) - : RTCStats(id, timestamp_us), - string("string") {} + : RTCStats(id, timestamp_us), string("string") {} RTCStatsMember string; }; -WEBRTC_RTCSTATS_IMPL(RTCTestStats3, RTCStats, "test-stats-3", - &string); +WEBRTC_RTCSTATS_IMPL(RTCTestStats3, RTCStats, "test-stats-3", &string); TEST(RTCStatsReport, AddAndGetStats) { rtc::scoped_refptr report = RTCStatsReport::Create(1337); diff --git a/stats/test/rtcteststats.cc b/stats/test/rtcteststats.cc index 5b6dffa5b8..162f329802 100644 --- a/stats/test/rtcteststats.cc +++ b/stats/test/rtcteststats.cc @@ -12,21 +12,23 @@ namespace webrtc { -WEBRTC_RTCSTATS_IMPL(RTCTestStats, RTCStats, "test-stats", - &m_bool, - &m_int32, - &m_uint32, - &m_int64, - &m_uint64, - &m_double, - &m_string, - &m_sequence_bool, - &m_sequence_int32, - &m_sequence_uint32, - &m_sequence_int64, - &m_sequence_uint64, - &m_sequence_double, - &m_sequence_string); +WEBRTC_RTCSTATS_IMPL(RTCTestStats, + RTCStats, + "test-stats", + &m_bool, + &m_int32, + &m_uint32, + &m_int64, + &m_uint64, + &m_double, + &m_string, + &m_sequence_bool, + &m_sequence_int32, + &m_sequence_uint32, + &m_sequence_int64, + &m_sequence_uint64, + &m_sequence_double, + &m_sequence_string); RTCTestStats::RTCTestStats(const std::string& id, int64_t timestamp_us) : RTCStats(id, timestamp_us), @@ -43,8 +45,7 @@ RTCTestStats::RTCTestStats(const std::string& id, int64_t timestamp_us) m_sequence_int64("mSequenceInt64"), m_sequence_uint64("mSequenceUint64"), m_sequence_double("mSequenceDouble"), - m_sequence_string("mSequenceString") { -} + m_sequence_string("mSequenceString") {} RTCTestStats::RTCTestStats(const RTCTestStats& other) : RTCStats(other.id(), other.timestamp_us()), @@ -61,10 +62,8 @@ RTCTestStats::RTCTestStats(const RTCTestStats& other) m_sequence_int64(other.m_sequence_int64), m_sequence_uint64(other.m_sequence_uint64), m_sequence_double(other.m_sequence_double), - m_sequence_string(other.m_sequence_string) { -} + m_sequence_string(other.m_sequence_string) {} -RTCTestStats::~RTCTestStats() { -} +RTCTestStats::~RTCTestStats() {} } // namespace webrtc diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc index 00cdff02d6..fd73531d7b 100644 --- a/system_wrappers/source/clock.cc +++ b/system_wrappers/source/clock.cc @@ -223,7 +223,7 @@ Clock* Clock::GetRealTimeClock() { #elif defined(WEBRTC_POSIX) static UnixRealTimeClock clock; return &clock; -#else // defined(WEBRTC_POSIX) +#else // defined(WEBRTC_POSIX) return nullptr; #endif // !defined(WEBRTC_WIN) || defined(WEBRTC_POSIX) } diff --git a/system_wrappers/source/rtp_to_ntp_estimator.cc b/system_wrappers/source/rtp_to_ntp_estimator.cc index 21f64eca25..5af102a054 100644 --- a/system_wrappers/source/rtp_to_ntp_estimator.cc +++ b/system_wrappers/source/rtp_to_ntp_estimator.cc @@ -21,7 +21,6 @@ const size_t kNumRtcpReportsToUse = 2; // Number of parameters samples used to smooth. const size_t kNumSamplesToSmooth = 20; - // Calculates the RTP timestamp frequency from two pairs of NTP/RTP timestamps. bool CalculateFrequency(int64_t ntp_ms1, uint32_t rtp_timestamp1, diff --git a/system_wrappers/source/runtime_enabled_features_default.cc b/system_wrappers/source/runtime_enabled_features_default.cc index 31a3ff7f4e..1d040a91b0 100644 --- a/system_wrappers/source/runtime_enabled_features_default.cc +++ b/system_wrappers/source/runtime_enabled_features_default.cc @@ -13,9 +13,7 @@ #include "rtc_base/flags.h" namespace flags { -DEFINE_bool(enable_dual_stream_mode, - false, - "Enables dual video stream mode."); +DEFINE_bool(enable_dual_stream_mode, false, "Enables dual video stream mode."); } namespace webrtc { diff --git a/test/call_test.cc b/test/call_test.cc index 789f7750fd..c735e0650c 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -95,7 +95,8 @@ void CallTest::RunBaseTest(BaseTest* test) { audio_state_config.audio_device_module = fake_recv_audio_device_; recv_config.audio_state = AudioState::Create(audio_state_config); fake_recv_audio_device_->RegisterAudioCallback( - recv_config.audio_state->audio_transport()); } + recv_config.audio_state->audio_transport()); + } CreateReceiverCall(recv_config); } test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); @@ -487,8 +488,7 @@ BaseTest::BaseTest() : event_log_(RtcEventLog::CreateNull()) {} BaseTest::BaseTest(unsigned int timeout_ms) : RtpRtcpObserver(timeout_ms), event_log_(RtcEventLog::CreateNull()) {} -BaseTest::~BaseTest() { -} +BaseTest::~BaseTest() {} std::unique_ptr BaseTest::CreateCapturer() { return TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000); @@ -513,8 +513,7 @@ Call::Config BaseTest::GetReceiverCallConfig() { void BaseTest::OnRtpTransportControllerSendCreated( RtpTransportControllerSend* controller) {} -void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) { -} +void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) {} test::PacketTransport* BaseTest::CreateSendTransport( SingleThreadedTaskQueueForTesting* task_queue, @@ -571,14 +570,11 @@ void BaseTest::OnFlexfecStreamsCreated( const std::vector& receive_streams) {} void BaseTest::OnFrameGeneratorCapturerCreated( - FrameGeneratorCapturer* frame_generator_capturer) { -} + FrameGeneratorCapturer* frame_generator_capturer) {} -void BaseTest::OnStreamsStopped() { -} +void BaseTest::OnStreamsStopped() {} -SendTest::SendTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { -} +SendTest::SendTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {} bool SendTest::ShouldCreateReceivers() const { return false; @@ -586,8 +582,7 @@ bool SendTest::ShouldCreateReceivers() const { EndToEndTest::EndToEndTest() {} -EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { -} +EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {} bool EndToEndTest::ShouldCreateReceivers() const { return true; diff --git a/test/configurable_frame_size_encoder.cc b/test/configurable_frame_size_encoder.cc index 107c4cb498..4fb8df473b 100644 --- a/test/configurable_frame_size_encoder.cc +++ b/test/configurable_frame_size_encoder.cc @@ -42,8 +42,8 @@ int32_t ConfigurableFrameSizeEncoder::Encode( const VideoFrame& inputImage, const CodecSpecificInfo* codecSpecificInfo, const std::vector* frame_types) { - EncodedImage encodedImage( - buffer_.get(), current_frame_size_, max_frame_size_); + EncodedImage encodedImage(buffer_.get(), current_frame_size_, + max_frame_size_); encodedImage._completeFrame = true; encodedImage._encodedHeight = inputImage.height(); encodedImage._encodedWidth = inputImage.width(); diff --git a/test/direct_transport.cc b/test/direct_transport.cc index 4b2fd0463e..672e553dd6 100644 --- a/test/direct_transport.cc +++ b/test/direct_transport.cc @@ -42,8 +42,7 @@ DirectTransport::DirectTransport( : DirectTransport(task_queue, FakeNetworkPipe::Config(), send_call, - payload_type_map) { -} + payload_type_map) {} DirectTransport::DirectTransport( SingleThreadedTaskQueueForTesting* task_queue, @@ -139,9 +138,8 @@ void DirectTransport::SendPackets() { fake_network_->Process(); int64_t delay_ms = fake_network_->TimeUntilNextProcess(); - next_scheduled_task_ = task_queue_->PostDelayedTask([this]() { - SendPackets(); - }, delay_ms); + next_scheduled_task_ = + task_queue_->PostDelayedTask([this]() { SendPackets(); }, delay_ms); } } // namespace test } // namespace webrtc diff --git a/test/encoder_settings.cc b/test/encoder_settings.cc index 33e81b0cfc..8e21598c2d 100644 --- a/test/encoder_settings.cc +++ b/test/encoder_settings.cc @@ -123,7 +123,8 @@ void FillEncoderConfiguration(VideoCodecType codec_type, } VideoReceiveStream::Decoder CreateMatchingDecoder( - int payload_type, const std::string& payload_name) { + int payload_type, + const std::string& payload_name) { VideoReceiveStream::Decoder decoder; decoder.payload_type = payload_type; decoder.payload_name = payload_name; diff --git a/test/encoder_settings.h b/test/encoder_settings.h index 787387b777..c05ac93816 100644 --- a/test/encoder_settings.h +++ b/test/encoder_settings.h @@ -45,11 +45,13 @@ std::vector CreateVideoStreams( int height, const webrtc::VideoEncoderConfig& encoder_config); -void FillEncoderConfiguration(VideoCodecType codec_type, size_t num_streams, +void FillEncoderConfiguration(VideoCodecType codec_type, + size_t num_streams, VideoEncoderConfig* configuration); VideoReceiveStream::Decoder CreateMatchingDecoder( - int payload_type, const std::string& payload_name); + int payload_type, + const std::string& payload_name); VideoReceiveStream::Decoder CreateMatchingDecoder( const VideoSendStream::Config& config); diff --git a/test/fake_decoder.cc b/test/fake_decoder.cc index 107f537d29..eaf12d07ce 100644 --- a/test/fake_decoder.cc +++ b/test/fake_decoder.cc @@ -81,9 +81,7 @@ int32_t FakeH264Decoder::Decode(const EncodedImage& input, } ++value; } - return FakeDecoder::Decode(input, - missing_frames, - codec_specific_info, + return FakeDecoder::Decode(input, missing_frames, codec_specific_info, render_time_ms); } diff --git a/test/fake_encoder.cc b/test/fake_encoder.cc index 7f7e695992..12a77e3f9e 100644 --- a/test/fake_encoder.cc +++ b/test/fake_encoder.cc @@ -116,8 +116,8 @@ int32_t FakeEncoder::Encode(const VideoFrame& input_image, (simulcast_streams[i].minBitrate * 1000) / framerate); size_t max_stream_bits = static_cast( (simulcast_streams[i].maxBitrate * 1000) / framerate); - size_t stream_bits = (bits_available > max_stream_bits) ? max_stream_bits : - bits_available; + size_t stream_bits = + (bits_available > max_stream_bits) ? max_stream_bits : bits_available; size_t stream_bytes = (stream_bits + 7) / 8; if (keyframe) { // The first frame is a key frame and should be larger. @@ -172,7 +172,9 @@ int32_t FakeEncoder::RegisterEncodeCompleteCallback( return 0; } -int32_t FakeEncoder::Release() { return 0; } +int32_t FakeEncoder::Release() { + return 0; +} int32_t FakeEncoder::SetChannelParameters(uint32_t packet_loss, int64_t rtt) { return 0; diff --git a/test/fake_encoder.h b/test/fake_encoder.h index 2700f3d6f1..071019abf3 100644 --- a/test/fake_encoder.h +++ b/test/fake_encoder.h @@ -11,8 +11,8 @@ #ifndef TEST_FAKE_ENCODER_H_ #define TEST_FAKE_ENCODER_H_ -#include #include +#include #include "api/video_codecs/video_encoder.h" #include "common_types.h" // NOLINT(build/include) diff --git a/test/field_trial.cc b/test/field_trial.cc index 9be36c566e..c4d8b3c337 100644 --- a/test/field_trial.cc +++ b/test/field_trial.cc @@ -43,8 +43,8 @@ void ValidateFieldTrialsStringOrDie(const std::string& trials_string) { size_t name_end = trials_string.find(kPersistentStringSeparator, next_item); if (name_end == trials_string.npos || next_item == name_end) break; - size_t group_name_end = trials_string.find(kPersistentStringSeparator, - name_end + 1); + size_t group_name_end = + trials_string.find(kPersistentStringSeparator, name_end + 1); if (group_name_end == trials_string.npos || name_end + 1 == group_name_end) break; std::string name(trials_string, next_item, name_end - next_item); @@ -74,7 +74,7 @@ void ValidateFieldTrialsStringOrDie(const std::string& trials_string) { } ScopedFieldTrials::ScopedFieldTrials(const std::string& config) - : previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) { + : previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) { assert(field_trials_initiated_); field_trials_initiated_ = false; current_field_trials_ = config; diff --git a/test/field_trial.h b/test/field_trial.h index 40f7b1ba24..2d8f37561a 100644 --- a/test/field_trial.h +++ b/test/field_trial.h @@ -11,8 +11,8 @@ #ifndef TEST_FIELD_TRIAL_H_ #define TEST_FIELD_TRIAL_H_ -#include #include +#include namespace webrtc { namespace test { @@ -38,6 +38,7 @@ class ScopedFieldTrials { public: explicit ScopedFieldTrials(const std::string& config); ~ScopedFieldTrials(); + private: std::string current_field_trials_; const char* previous_field_trials_; diff --git a/test/frame_generator.h b/test/frame_generator.h index 65857af7f0..1c108b1590 100644 --- a/test/frame_generator.h +++ b/test/frame_generator.h @@ -99,8 +99,8 @@ class FrameGenerator { // Creates a frame generator that produces randomly generated slides. // frame_repeat_count determines how many times each slide is shown. - static std::unique_ptr CreateSlideGenerator( - int width, int height, int frame_repeat_count); + static std::unique_ptr + CreateSlideGenerator(int width, int height, int frame_repeat_count); }; } // namespace test } // namespace webrtc diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc index 61f96fa86f..184fdd76ef 100644 --- a/test/frame_generator_capturer.cc +++ b/test/frame_generator_capturer.cc @@ -13,13 +13,13 @@ #include #include +#include "call/video_send_stream.h" #include "rtc_base/criticalsection.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" #include "rtc_base/task_queue.h" #include "rtc_base/timeutils.h" #include "system_wrappers/include/clock.h" -#include "call/video_send_stream.h" namespace webrtc { namespace test { @@ -125,8 +125,8 @@ FrameGeneratorCapturer* FrameGeneratorCapturer::CreateSlideGenerator( int target_fps, Clock* clock) { std::unique_ptr capturer(new FrameGeneratorCapturer( - clock, FrameGenerator::CreateSlideGenerator(width, height, - frame_repeat_count), + clock, + FrameGenerator::CreateSlideGenerator(width, height, frame_repeat_count), target_fps)); if (!capturer->Init()) return nullptr; @@ -145,8 +145,7 @@ FrameGeneratorCapturer::FrameGeneratorCapturer( frame_generator_(std::move(frame_generator)), target_fps_(target_fps), first_frame_capture_time_(-1), - task_queue_("FrameGenCapQ", - rtc::TaskQueue::Priority::HIGH) { + task_queue_("FrameGenCapQ", rtc::TaskQueue::Priority::HIGH) { RTC_DCHECK(frame_generator_); RTC_DCHECK_GT(target_fps, 0); } diff --git a/test/frame_generator_unittest.cc b/test/frame_generator_unittest.cc index ba4627dc3b..14e2f291c5 100644 --- a/test/frame_generator_unittest.cc +++ b/test/frame_generator_unittest.cc @@ -169,8 +169,8 @@ TEST_F(FrameGeneratorTest, SlideGenerator) { const int kGenCount = 9; const int kRepeatCount = 3; std::unique_ptr generator( - FrameGenerator::CreateSlideGenerator( - kFrameWidth, kFrameHeight, kRepeatCount)); + FrameGenerator::CreateSlideGenerator(kFrameWidth, kFrameHeight, + kRepeatCount)); uint64_t hashes[kGenCount]; for (int i = 0; i < kGenCount; ++i) { hashes[i] = Hash(generator->NextFrame()); @@ -178,9 +178,9 @@ TEST_F(FrameGeneratorTest, SlideGenerator) { // Check that the buffer changes only every |kRepeatCount| frames. for (int i = 1; i < kGenCount; ++i) { if (i % kRepeatCount == 0) { - EXPECT_NE(hashes[i-1], hashes[i]); + EXPECT_NE(hashes[i - 1], hashes[i]); } else { - EXPECT_EQ(hashes[i-1], hashes[i]); + EXPECT_EQ(hashes[i - 1], hashes[i]); } } } diff --git a/test/frame_utils.cc b/test/frame_utils.cc index 1d5fe7c8f4..833f57162c 100644 --- a/test/frame_utils.cc +++ b/test/frame_utils.cc @@ -59,18 +59,17 @@ bool FrameBufsEqual(const rtc::scoped_refptr& f1, rtc::scoped_refptr f1_i420 = f1->ToI420(); rtc::scoped_refptr f2_i420 = f2->ToI420(); - return EqualPlane(f1_i420->DataY(), f2_i420->DataY(), - f1_i420->StrideY(), f2_i420->StrideY(), - f1_i420->width(), f1_i420->height()) && - EqualPlane(f1_i420->DataU(), f2_i420->DataU(), - f1_i420->StrideU(), f2_i420->StrideU(), - f1_i420->ChromaWidth(), f1_i420->ChromaHeight()) && - EqualPlane(f1_i420->DataV(), f2_i420->DataV(), - f1_i420->StrideV(), f2_i420->StrideV(), - f1_i420->ChromaWidth(), f1_i420->ChromaHeight()); + return EqualPlane(f1_i420->DataY(), f2_i420->DataY(), f1_i420->StrideY(), + f2_i420->StrideY(), f1_i420->width(), f1_i420->height()) && + EqualPlane(f1_i420->DataU(), f2_i420->DataU(), f1_i420->StrideU(), + f2_i420->StrideU(), f1_i420->ChromaWidth(), + f1_i420->ChromaHeight()) && + EqualPlane(f1_i420->DataV(), f2_i420->DataV(), f1_i420->StrideV(), + f2_i420->StrideV(), f1_i420->ChromaWidth(), + f1_i420->ChromaHeight()); } -rtc::scoped_refptr ReadI420Buffer(int width, int height, FILE *f) { +rtc::scoped_refptr ReadI420Buffer(int width, int height, FILE* f) { int half_width = (width + 1) / 2; rtc::scoped_refptr buffer( // Explicit stride, no padding between rows. diff --git a/test/frame_utils.h b/test/frame_utils.h index 80466e1c29..c829311199 100644 --- a/test/frame_utils.h +++ b/test/frame_utils.h @@ -40,7 +40,7 @@ bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2); bool FrameBufsEqual(const rtc::scoped_refptr& f1, const rtc::scoped_refptr& f2); -rtc::scoped_refptr ReadI420Buffer(int width, int height, FILE *); +rtc::scoped_refptr ReadI420Buffer(int width, int height, FILE*); } // namespace test } // namespace webrtc diff --git a/test/fuzzers/flexfec_sender_fuzzer.cc b/test/fuzzers/flexfec_sender_fuzzer.cc index ab08850847..8e79f95cf3 100644 --- a/test/fuzzers/flexfec_sender_fuzzer.cc +++ b/test/fuzzers/flexfec_sender_fuzzer.cc @@ -12,8 +12,8 @@ #include "modules/rtp_rtcp/include/flexfec_sender.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "modules/rtp_rtcp/source/byte_io.h" +#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/test/fuzzers/packet_buffer_fuzzer.cc b/test/fuzzers/packet_buffer_fuzzer.cc index 7f116f6162..7b52ee0fc3 100644 --- a/test/fuzzers/packet_buffer_fuzzer.cc +++ b/test/fuzzers/packet_buffer_fuzzer.cc @@ -20,7 +20,6 @@ class NullCallback : public video_coding::OnReceivedFrameCallback { } // namespace void FuzzOneInput(const uint8_t* data, size_t size) { - VCMPacket packet; NullCallback callback; SimulatedClock clock(0); diff --git a/test/fuzzers/pseudotcp_parser_fuzzer.cc b/test/fuzzers/pseudotcp_parser_fuzzer.cc index 90123c3206..bab09df715 100644 --- a/test/fuzzers/pseudotcp_parser_fuzzer.cc +++ b/test/fuzzers/pseudotcp_parser_fuzzer.cc @@ -1,12 +1,12 @@ /* -* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. -* -* 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. -*/ + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. + * + * 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. + */ #include #include @@ -30,9 +30,8 @@ class FakeIPseudoTcpNotify : public cricket::IPseudoTcpNotify { }; struct Environment { - explicit Environment(cricket::IPseudoTcpNotify* notifier): - ptcp(notifier, 0) { - } + explicit Environment(cricket::IPseudoTcpNotify* notifier) + : ptcp(notifier, 0) {} // We need the thread to avoid some uninteresting crashes, since the // production code expects there to be a thread object available. diff --git a/test/fuzzers/rtcp_receiver_fuzzer.cc b/test/fuzzers/rtcp_receiver_fuzzer.cc index 8782f0c0a8..d87e002f67 100644 --- a/test/fuzzers/rtcp_receiver_fuzzer.cc +++ b/test/fuzzers/rtcp_receiver_fuzzer.cc @@ -18,11 +18,11 @@ class NullModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp { public: void SetTmmbn(std::vector) override {} void OnRequestSendReport() override {} - void OnReceivedNack(const std::vector&) override {}; - void OnReceivedRtcpReportBlocks(const ReportBlockList&) override {}; + void OnReceivedNack(const std::vector&) override{}; + void OnReceivedRtcpReportBlocks(const ReportBlockList&) override{}; }; -} +} // namespace void FuzzOneInput(const uint8_t* data, size_t size) { NullModuleRtpRtcp rtp_rtcp_module; @@ -34,4 +34,3 @@ void FuzzOneInput(const uint8_t* data, size_t size) { receiver.IncomingPacket(data, size); } } // namespace webrtc - diff --git a/test/fuzzers/rtp_frame_reference_finder_fuzzer.cc b/test/fuzzers/rtp_frame_reference_finder_fuzzer.cc index 9c47805fce..30c4df42e4 100644 --- a/test/fuzzers/rtp_frame_reference_finder_fuzzer.cc +++ b/test/fuzzers/rtp_frame_reference_finder_fuzzer.cc @@ -62,9 +62,15 @@ class FuzzyPacketBuffer : public video_coding::PacketBuffer { explicit FuzzyPacketBuffer(DataReader* reader) : PacketBuffer(nullptr, 2, 4, nullptr), reader(reader) { switch (reader->GetNum() % 3) { - case 0: codec = kVideoCodecVP8; break; - case 1: codec = kVideoCodecVP9; break; - case 2: codec = kVideoCodecH264; break; + case 0: + codec = kVideoCodecVP8; + break; + case 1: + codec = kVideoCodecVP9; + break; + case 2: + codec = kVideoCodecH264; + break; } } diff --git a/test/fuzzers/ulpfec_generator_fuzzer.cc b/test/fuzzers/ulpfec_generator_fuzzer.cc index ba9a53af58..2536b54ac0 100644 --- a/test/fuzzers/ulpfec_generator_fuzzer.cc +++ b/test/fuzzers/ulpfec_generator_fuzzer.cc @@ -58,7 +58,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) { const size_t num_fec_packets = generator.NumAvailableFecPackets(); if (num_fec_packets > 0) { std::vector> fec_packets = - generator.GetUlpfecPacketsAsRed(kRedPayloadType, kFecPayloadType, 100); + generator.GetUlpfecPacketsAsRed(kRedPayloadType, kFecPayloadType, + 100); RTC_CHECK_EQ(num_fec_packets, fec_packets.size()); } } diff --git a/test/fuzzers/ulpfec_receiver_fuzzer.cc b/test/fuzzers/ulpfec_receiver_fuzzer.cc index 25b53edc4e..6b74f3ac95 100644 --- a/test/fuzzers/ulpfec_receiver_fuzzer.cc +++ b/test/fuzzers/ulpfec_receiver_fuzzer.cc @@ -10,8 +10,8 @@ #include -#include "modules/rtp_rtcp/include/ulpfec_receiver.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/rtp_rtcp/include/ulpfec_receiver.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" @@ -67,8 +67,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) { RTPHeader parsed_header; if (parsed_packet.Parse(packet.get(), packet_length)) { parsed_packet.GetHeader(&parsed_header); - receiver->AddReceivedRedPacket(parsed_header, packet.get(), - packet_length, 0); + receiver->AddReceivedRedPacket(parsed_header, packet.get(), packet_length, + 0); } } diff --git a/test/fuzzers/webrtc_fuzzer_main.cc b/test/fuzzers/webrtc_fuzzer_main.cc index ca4bc15c71..a52dd231be 100644 --- a/test/fuzzers/webrtc_fuzzer_main.cc +++ b/test/fuzzers/webrtc_fuzzer_main.cc @@ -20,21 +20,21 @@ void InitializeWebRtcFuzzDefaults() { if (g_initialized) return; - // Remove default logging to prevent huge slowdowns. - // TODO(pbos): Disable in Chromium: http://crbug.com/561667 +// Remove default logging to prevent huge slowdowns. +// TODO(pbos): Disable in Chromium: http://crbug.com/561667 #if !defined(WEBRTC_CHROMIUM_BUILD) rtc::LogMessage::LogToDebug(rtc::LS_NONE); #endif // !defined(WEBRTC_CHROMIUM_BUILD) g_initialized = true; } -} +} // namespace namespace webrtc { extern void FuzzOneInput(const uint8_t* data, size_t size); } // namespace webrtc -extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) { InitializeWebRtcFuzzDefaults(); webrtc::FuzzOneInput(data, size); return 0; diff --git a/test/gl/gl_renderer.cc b/test/gl/gl_renderer.cc index ef7ab9c126..10162ee056 100644 --- a/test/gl/gl_renderer.cc +++ b/test/gl/gl_renderer.cc @@ -108,5 +108,5 @@ void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) { glBindTexture(GL_TEXTURE_2D, 0); glFlush(); } -} // test -} // webrtc +} // namespace test +} // namespace webrtc diff --git a/test/gl/gl_renderer.h b/test/gl/gl_renderer.h index 382739d307..16f432b2b1 100644 --- a/test/gl/gl_renderer.h +++ b/test/gl/gl_renderer.h @@ -20,7 +20,6 @@ #include "test/video_renderer.h" #include "typedefs.h" // NOLINT(build/include) - namespace webrtc { namespace test { @@ -44,7 +43,7 @@ class GlRenderer : public VideoRenderer { void ResizeVideo(size_t width, size_t height); }; -} // test -} // webrtc +} // namespace test +} // namespace webrtc #endif // TEST_GL_GL_RENDERER_H_ diff --git a/test/ios/test_support.h b/test/ios/test_support.h index 0178fca76b..2c5b600ce8 100644 --- a/test/ios/test_support.h +++ b/test/ios/test_support.h @@ -17,7 +17,9 @@ namespace test { // This is necessary as iOS doesn't like processes without a gui // running for longer than a few seconds. void RunTestsFromIOSApp(); -void InitTestSuite(int (*test_suite)(void), int argc, char* argv[], +void InitTestSuite(int (*test_suite)(void), + int argc, + char* argv[], bool save_chartjson_result); } // namespace test diff --git a/test/linux/glx_renderer.cc b/test/linux/glx_renderer.cc index 4dbf1c97d9..aaff84bc8f 100644 --- a/test/linux/glx_renderer.cc +++ b/test/linux/glx_renderer.cc @@ -22,15 +22,14 @@ namespace webrtc { namespace test { GlxRenderer::GlxRenderer(size_t width, size_t height) - : width_(width), - height_(height), - display_(NULL), - context_(NULL) { + : width_(width), height_(height), display_(NULL), context_(NULL) { assert(width > 0); assert(height > 0); } -GlxRenderer::~GlxRenderer() { Destroy(); } +GlxRenderer::~GlxRenderer() { + Destroy(); +} bool GlxRenderer::Init(const char* window_title) { if ((display_ = XOpenDisplay(NULL)) == NULL) { @@ -41,9 +40,10 @@ bool GlxRenderer::Init(const char* window_title) { int screen = DefaultScreen(display_); XVisualInfo* vi; - int attr_list[] = { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, - None, }; + int attr_list[] = { + GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, + GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None, + }; if ((vi = glXChooseVisual(display_, screen, attr_list)) == NULL) { Destroy(); @@ -106,7 +106,8 @@ void GlxRenderer::Destroy() { } } -GlxRenderer* GlxRenderer::Create(const char* window_title, size_t width, +GlxRenderer* GlxRenderer::Create(const char* window_title, + size_t width, size_t height) { GlxRenderer* glx_renderer = new GlxRenderer(width, height); if (!glx_renderer->Init(window_title)) { @@ -174,5 +175,5 @@ void GlxRenderer::OnFrame(const webrtc::VideoFrame& frame) { abort(); } } -} // test -} // webrtc +} // namespace test +} // namespace webrtc diff --git a/test/linux/glx_renderer.h b/test/linux/glx_renderer.h index 63ef624262..ec8b3ddd6c 100644 --- a/test/linux/glx_renderer.h +++ b/test/linux/glx_renderer.h @@ -22,7 +22,8 @@ namespace test { class GlxRenderer : public GlRenderer { public: - static GlxRenderer* Create(const char* window_title, size_t width, + static GlxRenderer* Create(const char* window_title, + size_t width, size_t height); virtual ~GlxRenderer(); @@ -41,7 +42,7 @@ class GlxRenderer : public GlRenderer { Window window_; GLXContext context_; }; -} // test -} // webrtc +} // namespace test +} // namespace webrtc #endif // TEST_LINUX_GLX_RENDERER_H_ diff --git a/test/linux/video_renderer_linux.cc b/test/linux/video_renderer_linux.cc index 942848942f..da0b792a07 100644 --- a/test/linux/video_renderer_linux.cc +++ b/test/linux/video_renderer_linux.cc @@ -23,5 +23,5 @@ VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title, } return NULL; } -} // test -} // webrtc +} // namespace test +} // namespace webrtc diff --git a/test/mac/video_renderer_mac.h b/test/mac/video_renderer_mac.h index 19349c037a..e6499f07ff 100644 --- a/test/mac/video_renderer_mac.h +++ b/test/mac/video_renderer_mac.h @@ -34,7 +34,7 @@ class MacRenderer : public GlRenderer { RTC_DISALLOW_COPY_AND_ASSIGN(MacRenderer); }; -} // test -} // webrtc +} // namespace test +} // namespace webrtc #endif // TEST_MAC_VIDEO_RENDERER_MAC_H_ diff --git a/test/null_platform_renderer.cc b/test/null_platform_renderer.cc index 48e4cc0d8b..7ea604ead8 100644 --- a/test/null_platform_renderer.cc +++ b/test/null_platform_renderer.cc @@ -18,5 +18,5 @@ VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title, size_t height) { return NULL; } -} // test -} // webrtc +} // namespace test +} // namespace webrtc diff --git a/test/rtp_file_reader.cc b/test/rtp_file_reader.cc index 032ec4ea31..17d4d1447a 100644 --- a/test/rtp_file_reader.cc +++ b/test/rtp_file_reader.cc @@ -241,17 +241,17 @@ const uint32_t kPcapBOMNoSwapOrder = 0xa1b2c3d4UL; class PcapReader : public RtpFileReaderImpl { public: PcapReader() - : file_(NULL), - swap_pcap_byte_order_(false), + : file_(NULL), + swap_pcap_byte_order_(false), #ifdef WEBRTC_ARCH_BIG_ENDIAN - swap_network_byte_order_(false), + swap_network_byte_order_(false), #else - swap_network_byte_order_(true), + swap_network_byte_order_(true), #endif - read_buffer_(), - packets_by_ssrc_(), - packets_(), - next_packet_it_() { + read_buffer_(), + packets_by_ssrc_(), + packets_(), + next_packet_it_() { } virtual ~PcapReader() { @@ -304,7 +304,7 @@ class PcapReader : public RtpFileReaderImpl { printf("Total RTP/RTCP packets: %" PRIuS "\n", packets_.size()); for (SsrcMapIterator mit = packets_by_ssrc_.begin(); - mit != packets_by_ssrc_.end(); ++mit) { + mit != packets_by_ssrc_.end(); ++mit) { uint32_t ssrc = mit->first; const std::vector& packet_indices = mit->second; uint8_t pt = packets_[packet_indices[0]].rtp_header.payloadType; @@ -364,14 +364,14 @@ class PcapReader : public RtpFileReaderImpl { private: // A marker of an RTP packet within the file. struct RtpPacketMarker { - uint32_t packet_number; // One-based index (like in WireShark) + uint32_t packet_number; // One-based index (like in WireShark) uint32_t time_offset_ms; uint32_t source_ip; uint32_t dest_ip; uint16_t source_port; uint16_t dest_port; RTPHeader rtp_header; - int32_t pos_in_file; // Byte offset of payload from start of file. + int32_t pos_in_file; // Byte offset of payload from start of file. uint32_t payload_length; }; @@ -505,8 +505,8 @@ class PcapReader : public RtpFileReaderImpl { uint32_t CalcTimeDelta(uint32_t ts_sec, uint32_t ts_usec, uint32_t start_ms) { // Round to nearest ms. - uint64_t t2_ms = ((static_cast(ts_sec) * 1000000) + ts_usec + - 500) / 1000; + uint64_t t2_ms = + ((static_cast(ts_sec) * 1000000) + ts_usec + 500) / 1000; uint64_t t1_ms = static_cast(start_ms); if (t2_ms < t1_ms) { return 0; @@ -577,7 +577,7 @@ class PcapReader : public RtpFileReaderImpl { if ((!expect_network_order && swap_pcap_byte_order_) || (expect_network_order && swap_network_byte_order_)) { tmp = ((tmp >> 24) & 0x000000ff) | (tmp << 24) | - ((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000); + ((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000); } *out = tmp; return kResultSuccess; @@ -611,7 +611,7 @@ class PcapReader : public RtpFileReaderImpl { if ((!expect_network_order && swap_pcap_byte_order_) || (expect_network_order && swap_network_byte_order_)) { tmp = ((tmp >> 24) & 0x000000ff) | (tmp << 24) | - ((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000); + ((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000); } *out = tmp; return kResultSuccess; diff --git a/test/rtp_file_reader.h b/test/rtp_file_reader.h index c044d3de26..4913522ba7 100644 --- a/test/rtp_file_reader.h +++ b/test/rtp_file_reader.h @@ -36,8 +36,7 @@ class RtpFileReader { enum FileFormat { kPcap, kRtpDump, kLengthPacketInterleaved }; virtual ~RtpFileReader() {} - static RtpFileReader* Create(FileFormat format, - const std::string& filename); + static RtpFileReader* Create(FileFormat format, const std::string& filename); static RtpFileReader* Create(FileFormat format, const std::string& filename, const std::set& ssrc_filter); diff --git a/test/rtp_rtcp_observer.h b/test/rtp_rtcp_observer.h index 1f213b475c..99c8b732aa 100644 --- a/test/rtp_rtcp_observer.h +++ b/test/rtp_rtcp_observer.h @@ -14,6 +14,7 @@ #include #include +#include "call/video_send_stream.h" #include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "rtc_base/criticalsection.h" #include "rtc_base/event.h" @@ -22,7 +23,6 @@ #include "test/direct_transport.h" #include "test/gtest.h" #include "typedefs.h" // NOLINT(build/include) -#include "call/video_send_stream.h" namespace { const int kShortTimeoutMs = 500; diff --git a/test/run_loop.cc b/test/run_loop.cc index 0d00ecd5e9..dc2ec18eea 100644 --- a/test/run_loop.cc +++ b/test/run_loop.cc @@ -16,7 +16,8 @@ namespace test { void PressEnterToContinue() { puts(">> Press ENTER to continue..."); - while (getc(stdin) != '\n' && !feof(stdin)); + while (getc(stdin) != '\n' && !feof(stdin)) + ; } } // namespace test } // namespace webrtc diff --git a/test/run_test.cc b/test/run_test.cc index ba0bf34d23..9f6126cf27 100644 --- a/test/run_test.cc +++ b/test/run_test.cc @@ -15,7 +15,7 @@ namespace webrtc { namespace test { -void RunTest(void(*test)()) { +void RunTest(void (*test)()) { (*test)(); } diff --git a/test/run_test.h b/test/run_test.h index ed908570fd..bd05584365 100644 --- a/test/run_test.h +++ b/test/run_test.h @@ -14,7 +14,7 @@ namespace webrtc { namespace test { // Running a test function on a separate thread, if required by the OS. -void RunTest(void(*test)()); +void RunTest(void (*test)()); } // namespace test } // namespace webrtc diff --git a/test/single_threaded_task_queue_unittest.cc b/test/single_threaded_task_queue_unittest.cc index 5bd40d704a..392957425e 100644 --- a/test/single_threaded_task_queue_unittest.cc +++ b/test/single_threaded_task_queue_unittest.cc @@ -68,9 +68,8 @@ TEST(SingleThreadedTaskQueueForTestingTest, // queue at any given time, post one waiting task that would block the // task-queue, and unblock only after all tasks have been posted. rtc::Event rendezvous(true, false); - task_queue.PostTask([&rendezvous]() { - ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); - }); + task_queue.PostTask( + [&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); }); // Post the tasks which comprise the test. for (size_t i = 0; i < kCount; i++) { @@ -126,9 +125,8 @@ TEST(SingleThreadedTaskQueueForTestingTest, TasksExecutedInSequence) { // Prevent the chain from being set in motion before we've had time to // schedule it all, lest the queue only contain one task at a time. rtc::Event rendezvous(true, false); - task_queue.PostTask([&rendezvous]() { - ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); - }); + task_queue.PostTask( + [&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); }); for (size_t i = 0; i < 3; i++) { task_queue.PostTask([&accumulator, i]() { // |i| passed by value. @@ -139,9 +137,7 @@ TEST(SingleThreadedTaskQueueForTestingTest, TasksExecutedInSequence) { // The test will wait for the task-queue to finish. rtc::Event done(true, false); - task_queue.PostTask([&done]() { - done.Set(); - }); + task_queue.PostTask([&done]() { done.Set(); }); rendezvous.Set(); // Set the chain in motion. @@ -159,10 +155,12 @@ TEST(SingleThreadedTaskQueueForTestingTest, ExecutesPostedDelayedTask) { constexpr int64_t delay_ms = 20; static_assert(delay_ms < kMaxWaitTimeMs / 2, "Delay too long for tests."); - task_queue.PostDelayedTask([&executed, &done]() { - executed.store(true); - done.Set(); - }, delay_ms); + task_queue.PostDelayedTask( + [&executed, &done]() { + executed.store(true); + done.Set(); + }, + delay_ms); ASSERT_TRUE(done.Wait(kMaxWaitTimeMs)); EXPECT_TRUE(executed.load()); @@ -176,9 +174,7 @@ TEST(SingleThreadedTaskQueueForTestingTest, DoesNotExecuteDelayedTaskTooSoon) { constexpr int64_t delay_ms = 2000; static_assert(delay_ms < kMaxWaitTimeMs / 2, "Delay too long for tests."); - task_queue.PostDelayedTask([&executed]() { - executed.store(true); - }, delay_ms); + task_queue.PostDelayedTask([&executed]() { executed.store(true); }, delay_ms); // Wait less than is enough, make sure the task was not yet executed. rtc::Event not_done(true, false); @@ -262,16 +258,11 @@ TEST(SingleThreadedTaskQueueForTestingTest, ExternalThreadCancelsTask) { // Prevent the to-be-cancelled task from being executed before we've had // time to cancel it. rtc::Event rendezvous(true, false); - task_queue.PostTask([&rendezvous]() { - ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); - }); + task_queue.PostTask( + [&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); }); - TaskId cancelled_task_id = task_queue.PostTask([]() { - EXPECT_TRUE(false); - }); - task_queue.PostTask([&done]() { - done.Set(); - }); + TaskId cancelled_task_id = task_queue.PostTask([]() { EXPECT_TRUE(false); }); + task_queue.PostTask([&done]() { done.Set(); }); task_queue.CancelTask(cancelled_task_id); @@ -292,9 +283,8 @@ TEST(SingleThreadedTaskQueueForTestingTest, InternalThreadCancelsTask) { // Prevent the chain from being set-off before we've set everything up. rtc::Event rendezvous(true, false); - task_queue.PostTask([&rendezvous]() { - ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); - }); + task_queue.PostTask( + [&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); }); // This is the canceller-task. It takes cancelled_task_id by reference, // because the ID will only become known after the cancelled task is @@ -306,15 +296,11 @@ TEST(SingleThreadedTaskQueueForTestingTest, InternalThreadCancelsTask) { task_queue.PostTask(canceller_task); // This task will be cancelled by the task before it. - auto cancelled_task = []() { - EXPECT_TRUE(false); - }; + auto cancelled_task = []() { EXPECT_TRUE(false); }; cancelled_task_id = task_queue.PostTask(cancelled_task); // When this task runs, it will allow the test to be finished. - auto completion_marker_task = [&done]() { - done.Set(); - }; + auto completion_marker_task = [&done]() { done.Set(); }; task_queue.PostTask(completion_marker_task); rendezvous.Set(); // Set the chain in motion. diff --git a/test/test_main.cc b/test/test_main.cc index cb99564973..277d420c67 100644 --- a/test/test_main.cc +++ b/test/test_main.cc @@ -21,10 +21,12 @@ #if defined(WEBRTC_IOS) #include "test/ios/test_support.h" -DEFINE_string(NSTreatUnknownArgumentsAsOpen, "", - "Intentionally ignored flag intended for iOS simulator."); -DEFINE_string(ApplePersistenceIgnoreState, "", - "Intentionally ignored flag intended for iOS simulator."); +DEFINE_string(NSTreatUnknownArgumentsAsOpen, + "", + "Intentionally ignored flag intended for iOS simulator."); +DEFINE_string(ApplePersistenceIgnoreState, + "", + "Intentionally ignored flag intended for iOS simulator."); DEFINE_bool( save_chartjson_result, false, @@ -35,10 +37,9 @@ DEFINE_bool( #else -DEFINE_string( - isolated_script_test_output, - "", - "Intentionally ignored flag intended for Chromium."); +DEFINE_string(isolated_script_test_output, + "", + "Intentionally ignored flag intended for Chromium."); DEFINE_string( isolated_script_test_perf_output, @@ -52,7 +53,9 @@ DEFINE_string( DEFINE_bool(logs, false, "print logs to stderr"); -DEFINE_string(force_fieldtrials, "", +DEFINE_string( + force_fieldtrials, + "", "Field trials control experimental feature code which can be forced. " "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" " will assign the group Enable to field trial WebRTC-FooFeature."); @@ -82,7 +85,6 @@ int main(int argc, char* argv[]) { webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); webrtc::metrics::Enable(); - rtc::LogMessage::SetLogToStderr(FLAG_logs); #if defined(WEBRTC_IOS) diff --git a/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc index 76a635a1a4..119f6cc0ba 100644 --- a/test/testsupport/fileutils.cc +++ b/test/testsupport/fileutils.cc @@ -31,8 +31,8 @@ #endif #include // To check for directory existence. -#ifndef S_ISDIR // Not defined in stat.h on Windows. -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#ifndef S_ISDIR // Not defined in stat.h on Windows. +#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) #endif #include @@ -92,9 +92,9 @@ void SetExecutablePath(const std::string& path) { if (path.find(working_dir) != std::string::npos) { temp_path = path.substr(working_dir.length() + 1); } - // On Windows, when tests are run under memory tools like DrMemory and TSan, - // slashes occur in the path as directory separators. Make sure we replace - // such cases with backslashes in order for the paths to be correct. +// On Windows, when tests are run under memory tools like DrMemory and TSan, +// slashes occur in the path as directory separators. Make sure we replace +// such cases with backslashes in order for the paths to be correct. #ifdef WIN32 std::replace(temp_path.begin(), temp_path.end(), '/', '\\'); #endif @@ -112,8 +112,8 @@ bool FileExists(const std::string& file_name) { bool DirExists(const std::string& directory_name) { struct stat directory_info = {0}; - return stat(directory_name.c_str(), &directory_info) == 0 && S_ISDIR( - directory_info.st_mode); + return stat(directory_name.c_str(), &directory_info) == 0 && + S_ISDIR(directory_info.st_mode); } #ifdef WEBRTC_ANDROID @@ -190,11 +190,11 @@ std::string WorkingDir() { // Generate a temporary filename in a safe way. // Largely copied from talk/base/{unixfilesystem,win32filesystem}.cc. -std::string TempFilename(const std::string &dir, const std::string &prefix) { +std::string TempFilename(const std::string& dir, const std::string& prefix) { #ifdef WIN32 wchar_t filename[MAX_PATH]; - if (::GetTempFileName(rtc::ToUtf16(dir).c_str(), - rtc::ToUtf16(prefix).c_str(), 0, filename) != 0) + if (::GetTempFileName(rtc::ToUtf16(dir).c_str(), rtc::ToUtf16(prefix).c_str(), + 0, filename) != 0) return rtc::ToUtf8(filename); assert(false); return ""; @@ -202,8 +202,7 @@ std::string TempFilename(const std::string &dir, const std::string &prefix) { int len = dir.size() + prefix.size() + 2 + 6; std::unique_ptr tempname(new char[len]); - snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), - prefix.c_str()); + snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), prefix.c_str()); int fd = ::mkstemp(tempname.get()); if (fd == -1) { assert(false); @@ -279,7 +278,8 @@ bool CreateDir(const std::string& directory_name) { // Check if the path exists already: if (stat(directory_name.c_str(), &path_info) == 0) { if (!S_ISDIR(path_info.st_mode)) { - fprintf(stderr, "Path %s exists but is not a directory! Remove this " + fprintf(stderr, + "Path %s exists but is not a directory! Remove this " "file and re-run to create the directory.\n", directory_name.c_str()); return false; @@ -288,7 +288,7 @@ bool CreateDir(const std::string& directory_name) { #ifdef WIN32 return _mkdir(directory_name.c_str()) == 0; #else - return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0; + return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0; #endif } return true; @@ -296,9 +296,9 @@ bool CreateDir(const std::string& directory_name) { bool RemoveDir(const std::string& directory_name) { #ifdef WIN32 - return RemoveDirectoryA(directory_name.c_str()) != FALSE; + return RemoveDirectoryA(directory_name.c_str()) != FALSE; #else - return rmdir(directory_name.c_str()) == 0; + return rmdir(directory_name.c_str()) == 0; #endif } @@ -332,10 +332,10 @@ std::string ResourcePath(const std::string& name, std::string architecture = "32"; #endif // WEBRTC_ARCH_64_BITS - std::string resources_path = ProjectRootPath() + kResourcesDirName + - kPathDelimiter; + std::string resources_path = + ProjectRootPath() + kResourcesDirName + kPathDelimiter; std::string resource_file = resources_path + name + "_" + platform + "_" + - architecture + "." + extension; + architecture + "." + extension; if (FileExists(resource_file)) { return resource_file; } diff --git a/test/testsupport/fileutils.h b/test/testsupport/fileutils.h index af39a9457a..8cef0e36b5 100644 --- a/test/testsupport/fileutils.h +++ b/test/testsupport/fileutils.h @@ -41,7 +41,7 @@ std::string OutputPath(); // Generates an empty file with a unique name in the specified directory and // returns the file name and path. // TODO(titovartem) rename to TempFile and next method to TempFilename -std::string TempFilename(const std::string &dir, const std::string &prefix); +std::string TempFilename(const std::string& dir, const std::string& prefix); // Generates a unique file name that can be used for file creation. Doesn't // create any files. diff --git a/test/testsupport/fileutils_unittest.cc b/test/testsupport/fileutils_unittest.cc index b39be6fd5c..dc1f1bc7f7 100644 --- a/test/testsupport/fileutils_unittest.cc +++ b/test/testsupport/fileutils_unittest.cc @@ -69,19 +69,17 @@ void WriteStringInFile(const std::string& what, const std::string& file_path) { // gtest framework). class FileUtilsTest : public testing::Test { protected: - FileUtilsTest() { - } + FileUtilsTest() {} ~FileUtilsTest() override {} // Runs before the first test static void SetUpTestCase() { original_working_dir_ = webrtc::test::WorkingDir(); } - void SetUp() override { - ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); - } + void SetUp() override { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); } void TearDown() override { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); } + private: static std::string original_working_dir_; }; @@ -186,8 +184,8 @@ TEST_F(FileUtilsTest, GetFileSizeExistingFile) { webrtc::test::OutputPath(), "fileutils_unittest"); FILE* file = fopen(temp_filename.c_str(), "wb"); ASSERT_TRUE(file != NULL) << "Failed to open file: " << temp_filename; - ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0) << - "Failed to write to file: " << temp_filename; + ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0) + << "Failed to write to file: " << temp_filename; fclose(file); ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u); remove(temp_filename.c_str()); diff --git a/test/testsupport/frame_writer.h b/test/testsupport/frame_writer.h index 7556050a21..be9adb6e4a 100644 --- a/test/testsupport/frame_writer.h +++ b/test/testsupport/frame_writer.h @@ -86,7 +86,7 @@ class Y4mFrameWriterImpl : public YuvFrameWriterImpl { // LibJpeg is not available on iOS. This class will do nothing on iOS. class JpegFrameWriter { public: - JpegFrameWriter(const std::string &output_filename); + JpegFrameWriter(const std::string& output_filename); // Quality can be from 0 (worst) to 100 (best). Best quality is still lossy. // WriteFrame can be called only once. Subsequent calls will fail. bool WriteFrame(const VideoFrame& input_frame, int quality); diff --git a/test/testsupport/jpeg_frame_writer.cc b/test/testsupport/jpeg_frame_writer.cc index 4888f65aeb..537e85cfa5 100644 --- a/test/testsupport/jpeg_frame_writer.cc +++ b/test/testsupport/jpeg_frame_writer.cc @@ -10,7 +10,6 @@ #include - #include "common_types.h" // NOLINT(build/include) #include "common_video/libyuv/include/webrtc_libyuv.h" #include "rtc_base/checks.h" @@ -29,7 +28,7 @@ extern "C" { namespace webrtc { namespace test { -JpegFrameWriter::JpegFrameWriter(const std::string &output_filename) +JpegFrameWriter::JpegFrameWriter(const std::string& output_filename) : frame_written_(false), output_filename_(output_filename), output_file_(nullptr) {} diff --git a/test/testsupport/jpeg_frame_writer_ios.cc b/test/testsupport/jpeg_frame_writer_ios.cc index 567e75e254..e72fea102f 100644 --- a/test/testsupport/jpeg_frame_writer_ios.cc +++ b/test/testsupport/jpeg_frame_writer_ios.cc @@ -12,7 +12,6 @@ #include "rtc_base/logging.h" #include "test/testsupport/frame_writer.h" - namespace webrtc { namespace test { diff --git a/test/testsupport/perf_test.cc b/test/testsupport/perf_test.cc index b79c7061a6..c59c07149c 100644 --- a/test/testsupport/perf_test.cc +++ b/test/testsupport/perf_test.cc @@ -121,8 +121,7 @@ class PerfResultsLogger { } rtc::CriticalSection crit_; - FILE* output_ - RTC_GUARDED_BY(&crit_); + FILE* output_ RTC_GUARDED_BY(&crit_); std::map> graphs_ RTC_GUARDED_BY(&crit_); }; diff --git a/test/testsupport/perf_test_unittest.cc b/test/testsupport/perf_test_unittest.cc index bd8e85f4f3..ac2b8b9772 100644 --- a/test/testsupport/perf_test_unittest.cc +++ b/test/testsupport/perf_test_unittest.cc @@ -60,12 +60,9 @@ namespace test { class PerfTest : public ::testing::Test { protected: - void TearDown() override { - ClearPerfResults(); - } + void TearDown() override { ClearPerfResults(); } }; - #if defined(WEBRTC_IOS) #define MAYBE_TestPrintResult DISABLED_TestPrintResult #else diff --git a/test/testsupport/test_artifacts.cc b/test/testsupport/test_artifacts.cc index e9d31bbac1..0f7e0cd4ff 100644 --- a/test/testsupport/test_artifacts.cc +++ b/test/testsupport/test_artifacts.cc @@ -22,7 +22,7 @@ const std::string& DefaultArtifactPath() { static const std::string path = webrtc::test::OutputPath(); return path; } -} +} // namespace DEFINE_string(test_artifacts_dir, DefaultArtifactPath().c_str(), diff --git a/test/vcm_capturer.cc b/test/vcm_capturer.cc index 22631acbc6..3e4e0f63c0 100644 --- a/test/vcm_capturer.cc +++ b/test/vcm_capturer.cc @@ -10,9 +10,9 @@ #include "test/vcm_capturer.h" +#include "call/video_send_stream.h" #include "modules/video_capture/video_capture_factory.h" #include "rtc_base/logging.h" -#include "call/video_send_stream.h" namespace webrtc { namespace test { @@ -68,7 +68,6 @@ VcmCapturer* VcmCapturer::Create(size_t width, return vcm_capturer.release(); } - void VcmCapturer::Start() { rtc::CritScope lock(&crit_); started_ = true; @@ -103,7 +102,9 @@ void VcmCapturer::Destroy() { vcm_ = nullptr; } -VcmCapturer::~VcmCapturer() { Destroy(); } +VcmCapturer::~VcmCapturer() { + Destroy(); +} void VcmCapturer::OnFrame(const VideoFrame& frame) { rtc::CritScope lock(&crit_); @@ -114,5 +115,5 @@ void VcmCapturer::OnFrame(const VideoFrame& frame) { } } -} // test -} // webrtc +} // namespace test +} // namespace webrtc diff --git a/test/vcm_capturer.h b/test/vcm_capturer.h index 9d158c3fcd..524cfe4038 100644 --- a/test/vcm_capturer.h +++ b/test/vcm_capturer.h @@ -22,9 +22,8 @@ namespace webrtc { namespace test { -class VcmCapturer - : public VideoCapturer, - public rtc::VideoSinkInterface { +class VcmCapturer : public VideoCapturer, + public rtc::VideoSinkInterface { public: static VcmCapturer* Create(size_t width, size_t height, @@ -55,7 +54,7 @@ class VcmCapturer VideoCaptureCapability capability_; }; -} // test -} // webrtc +} // namespace test +} // namespace webrtc #endif // TEST_VCM_CAPTURER_H_ diff --git a/test/video_renderer.h b/test/video_renderer.h index 17815c1637..9e580f6f59 100644 --- a/test/video_renderer.h +++ b/test/video_renderer.h @@ -22,7 +22,8 @@ class VideoRenderer : public rtc::VideoSinkInterface { public: // Creates a platform-specific renderer if possible, or a null implementation // if failing. - static VideoRenderer* Create(const char* window_title, size_t width, + static VideoRenderer* Create(const char* window_title, + size_t width, size_t height); // Returns a renderer rendering to a platform specific window if possible, // NULL if none can be created. @@ -30,8 +31,10 @@ class VideoRenderer : public rtc::VideoSinkInterface { // platform renderer could not be created. This occurs, for instance, when // running without an X environment on Linux. static VideoRenderer* CreatePlatformRenderer(const char* window_title, - size_t width, size_t height); + size_t width, + size_t height); virtual ~VideoRenderer() {} + protected: VideoRenderer() {} }; diff --git a/test/win/d3d_renderer.cc b/test/win/d3d_renderer.cc index c0a65b56bb..18c6cd78a9 100644 --- a/test/win/d3d_renderer.cc +++ b/test/win/d3d_renderer.cc @@ -15,7 +15,7 @@ namespace webrtc { namespace test { -#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1) +#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX1) struct D3dCustomVertex { float x, y, z; @@ -42,9 +42,13 @@ D3dRenderer::D3dRenderer(size_t width, size_t height) RTC_DCHECK_GT(height, 0); } -D3dRenderer::~D3dRenderer() { Destroy(); } +D3dRenderer::~D3dRenderer() { + Destroy(); +} -LRESULT WINAPI D3dRenderer::WindowProc(HWND hwnd, UINT msg, WPARAM wparam, +LRESULT WINAPI D3dRenderer::WindowProc(HWND hwnd, + UINT msg, + WPARAM wparam, LPARAM lparam) { if (msg == WM_DESTROY || (msg == WM_CHAR && wparam == VK_RETURN)) { PostQuitMessage(0); @@ -68,17 +72,9 @@ void D3dRenderer::Destroy() { } bool D3dRenderer::Init(const char* window_title) { - hwnd_ = CreateWindowA(kD3DClassName, - window_title, - WS_OVERLAPPEDWINDOW, - 0, - 0, - static_cast(width_), - static_cast(height_), - NULL, - NULL, - NULL, - NULL); + hwnd_ = CreateWindowA(kD3DClassName, window_title, WS_OVERLAPPEDWINDOW, 0, 0, + static_cast(width_), static_cast(height_), + NULL, NULL, NULL, NULL); if (hwnd_ == NULL) { Destroy(); @@ -97,11 +93,8 @@ bool D3dRenderer::Init(const char* window_title) { d3d_params.SwapEffect = D3DSWAPEFFECT_COPY; IDirect3DDevice9* d3d_device; - if (d3d_->CreateDevice(D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, - hwnd_, - D3DCREATE_SOFTWARE_VERTEXPROCESSING, - &d3d_params, + if (d3d_->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd_, + D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3d_params, &d3d_device) != D3D_OK) { Destroy(); return false; @@ -112,11 +105,8 @@ bool D3dRenderer::Init(const char* window_title) { IDirect3DVertexBuffer9* vertex_buffer; const int kRectVertices = 4; if (d3d_device_->CreateVertexBuffer(kRectVertices * sizeof(D3dCustomVertex), - 0, - D3DFVF_CUSTOMVERTEX, - D3DPOOL_MANAGED, - &vertex_buffer, - NULL) != D3D_OK) { + 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, + &vertex_buffer, NULL) != D3D_OK) { Destroy(); return false; } @@ -166,22 +156,17 @@ void D3dRenderer::Resize(size_t width, size_t height) { IDirect3DTexture9* texture; d3d_device_->CreateTexture(static_cast(width_), - static_cast(height_), - 1, - 0, - D3DFMT_A8R8G8B8, - D3DPOOL_MANAGED, - &texture, - NULL); + static_cast(height_), 1, 0, D3DFMT_A8R8G8B8, + D3DPOOL_MANAGED, &texture, NULL); texture_ = texture; texture->Release(); // Vertices for the video frame to be rendered to. static const D3dCustomVertex rect[] = { - {-1.0f, -1.0f, 0.0f, 0.0f, 1.0f}, - {-1.0f, 1.0f, 0.0f, 0.0f, 0.0f}, - {1.0f, -1.0f, 0.0f, 1.0f, 1.0f}, - {1.0f, 1.0f, 0.0f, 1.0f, 0.0f}, + {-1.0f, -1.0f, 0.0f, 0.0f, 1.0f}, + {-1.0f, 1.0f, 0.0f, 0.0f, 0.0f}, + {1.0f, -1.0f, 0.0f, 1.0f, 1.0f}, + {1.0f, 1.0f, 0.0f, 1.0f, 0.0f}, }; void* buf_data; diff --git a/test/win/d3d_renderer.h b/test/win/d3d_renderer.h index 68a5a802f2..7f25aba547 100644 --- a/test/win/d3d_renderer.h +++ b/test/win/d3d_renderer.h @@ -12,7 +12,7 @@ #include #include -#pragma comment(lib, "d3d9.lib") // located in DirectX SDK +#pragma comment(lib, "d3d9.lib") // located in DirectX SDK #include "rtc_base/scoped_ref_ptr.h" #include "test/video_renderer.h" @@ -23,7 +23,8 @@ namespace test { class D3dRenderer : public VideoRenderer { public: - static D3dRenderer* Create(const char* window_title, size_t width, + static D3dRenderer* Create(const char* window_title, + size_t width, size_t height); virtual ~D3dRenderer(); @@ -32,7 +33,9 @@ class D3dRenderer : public VideoRenderer { private: D3dRenderer(size_t width, size_t height); - static LRESULT WINAPI WindowProc(HWND hwnd, UINT msg, WPARAM wparam, + static LRESULT WINAPI WindowProc(HWND hwnd, + UINT msg, + WPARAM wparam, LPARAM lparam); bool Init(const char* window_title); void Resize(size_t width, size_t height); diff --git a/test/win/run_loop_win.cc b/test/win/run_loop_win.cc index 494adc47d6..28dc9334e0 100644 --- a/test/win/run_loop_win.cc +++ b/test/win/run_loop_win.cc @@ -11,9 +11,9 @@ #include +#include #include #include -#include namespace webrtc { namespace test { diff --git a/tools_webrtc/sanitizers/lsan_suppressions_webrtc.cc b/tools_webrtc/sanitizers/lsan_suppressions_webrtc.cc index 49dee1b562..5fea62530f 100644 --- a/tools_webrtc/sanitizers/lsan_suppressions_webrtc.cc +++ b/tools_webrtc/sanitizers/lsan_suppressions_webrtc.cc @@ -21,90 +21,95 @@ // for the instructions on writing suppressions. char kLSanDefaultSuppressions[] = -// ============ Leaks in third-party code shared with Chromium ============= -// These entries are copied from build/sanitizers/lsan_suppressions.cc in -// Chromium. Please don't add new entries here unless they're present in there. + // ============ Leaks in third-party code shared with Chromium ============= + // These entries are copied from build/sanitizers/lsan_suppressions.cc in + // Chromium. Please don't add new entries here unless they're present in + // there. -// False positives in libfontconfig. http://crbug.com/39050 -"leak:libfontconfig\n" + // False positives in libfontconfig. http://crbug.com/39050 + "leak:libfontconfig\n" -// Leaks in Nvidia's libGL. -"leak:libGL.so\n" + // Leaks in Nvidia's libGL. + "leak:libGL.so\n" -// XRandR has several one time leaks. -"leak:libxrandr\n" + // XRandR has several one time leaks. + "leak:libxrandr\n" -// xrandr leak. http://crbug.com/119677 -"leak:XRRFindDisplay\n" + // xrandr leak. http://crbug.com/119677 + "leak:XRRFindDisplay\n" -// ========== Leaks in third-party code not shared with Chromium =========== + // ========== Leaks in third-party code not shared with Chromium =========== -// None known so far. + // None known so far. -// ================ Leaks in WebRTC code ================ -// PLEASE DO NOT ADD SUPPRESSIONS FOR NEW LEAKS. -// Instead, commits that introduce memory leaks should be reverted. Suppressing -// the leak is acceptable in some cases when reverting is impossible, i.e. when -// enabling leak detection for the first time for a test target with -// pre-existing leaks. + // ================ Leaks in WebRTC code ================ + // PLEASE DO NOT ADD SUPPRESSIONS FOR NEW LEAKS. + // Instead, commits that introduce memory leaks should be reverted. + // Suppressing the leak is acceptable in some cases when reverting is + // impossible, i.e. when enabling leak detection for the first time for a + // test target with pre-existing leaks. -// rtc_unittest -// https://code.google.com/p/webrtc/issues/detail?id=3827 for details. -"leak:rtc::unstarted_task_test_DoNotDeleteTask2_Test::TestBody\n" -"leak:rtc::HttpServer::HandleConnection\n" -"leak:rtc::HttpServer::Connection::onHttpHeaderComplete\n" -"leak:rtc::HttpResponseData::set_success\n" -"leak:rtc::HttpData::changeHeader\n" -// https://code.google.com/p/webrtc/issues/detail?id=4149 for details. -"leak:StartDNSLookup\n" -// https://code.google.com/p/webrtc/issues/detail?id=2527 -"leak:HangoutPubSubClientTest::HangoutPubSubClientTest\n" -"leak:MucRoomConfigTaskTest::SetUp\n" -"leak:MucRoomDiscoveryTaskTest::SetUp\n" -"leak:MucRoomLookupTaskTest::SetUp\n" -"leak:MucRoomUniqueHangoutIdTaskTest::SetUp\n" -"leak:PingTaskTest::SetUp\n" -"leak:PingXmppClient::SendStanza\n" -"leak:PubSubClientTest::PubSubClientTest\n" -"leak:PubSubTasksTest::PubSubTasksTest\n" + // rtc_unittest + // https://code.google.com/p/webrtc/issues/detail?id=3827 for details. + "leak:rtc::unstarted_task_test_DoNotDeleteTask2_Test::TestBody\n" + "leak:rtc::HttpServer::HandleConnection\n" + "leak:rtc::HttpServer::Connection::onHttpHeaderComplete\n" + "leak:rtc::HttpResponseData::set_success\n" + "leak:rtc::HttpData::changeHeader\n" + // https://code.google.com/p/webrtc/issues/detail?id=4149 for details. + "leak:StartDNSLookup\n" + // https://code.google.com/p/webrtc/issues/detail?id=2527 + "leak:HangoutPubSubClientTest::HangoutPubSubClientTest\n" + "leak:MucRoomConfigTaskTest::SetUp\n" + "leak:MucRoomDiscoveryTaskTest::SetUp\n" + "leak:MucRoomLookupTaskTest::SetUp\n" + "leak:MucRoomUniqueHangoutIdTaskTest::SetUp\n" + "leak:PingTaskTest::SetUp\n" + "leak:PingXmppClient::SendStanza\n" + "leak:PubSubClientTest::PubSubClientTest\n" + "leak:PubSubTasksTest::PubSubTasksTest\n" -// rtc_media_unittests -"leak:cricket::FakeNetworkInterface::SetOption\n" -"leak:CodecTest_TestCodecOperators_Test::TestBody\n" -"leak:VideoEngineTest*::ConstrainNewCodecBody\n" -"leak:VideoMediaChannelTest*::AddRemoveRecvStreams\n" -"leak:WebRtcVideoCapturerTest_TestCapture_Test::TestBody\n" -"leak:WebRtcVideoEngineTestFake_MultipleSendStreamsWithOneCapturer_Test::TestBody\n" -"leak:WebRtcVideoEngineTestFake_SetBandwidthInConference_Test::TestBody\n" -"leak:WebRtcVideoEngineTestFake_SetSendCodecsRejectBadFormat_Test::TestBody\n" + // rtc_media_unittests + "leak:cricket::FakeNetworkInterface::SetOption\n" + "leak:CodecTest_TestCodecOperators_Test::TestBody\n" + "leak:VideoEngineTest*::ConstrainNewCodecBody\n" + "leak:VideoMediaChannelTest*::AddRemoveRecvStreams\n" + "leak:WebRtcVideoCapturerTest_TestCapture_Test::TestBody\n" + "leak:WebRtcVideoEngineTestFake_MultipleSendStreamsWithOneCapturer_Test::" + "TestBody\n" + "leak:WebRtcVideoEngineTestFake_SetBandwidthInConference_Test::TestBody\n" + "leak:WebRtcVideoEngineTestFake_SetSendCodecsRejectBadFormat_Test::" + "TestBody\n" -// peerconnection_unittests -// https://code.google.com/p/webrtc/issues/detail?id=2528 -"leak:cricket::FakeVideoMediaChannel::~FakeVideoMediaChannel\n" -"leak:cricket::MediaSessionDescriptionFactory::CreateAnswer\n" -"leak:cricket::MediaSessionDescriptionFactory::CreateOffer\n" -"leak:DtmfSenderTest_InsertEmptyTonesToCancelPreviousTask_Test::TestBody\n" -"leak:sigslot::_signal_base2*::~_signal_base2\n" -"leak:testing::internal::CmpHelperEQ\n" -"leak:webrtc::AudioDeviceLinuxALSA::InitMicrophone\n" -"leak:webrtc::AudioDeviceLinuxALSA::InitSpeaker\n" -"leak:webrtc::CreateIceCandidate\n" -"leak:webrtc::FakeConstraints::AddOptional\n" -"leak:webrtc::WebRtcIdentityRequestObserver::OnSuccess\n" -"leak:webrtc::WebRtcSessionDescriptionFactory::InternalCreateAnswer\n" -"leak:webrtc::WebRtcSessionDescriptionFactory::InternalCreateOffer\n" -"leak:PeerConnectionInterfaceTest_SsrcInOfferAnswer_Test::TestBody\n" -"leak:PeerConnectionInterfaceTest_CloseAndTestMethods_Test::TestBody\n" -"leak:WebRtcSdpTest::TestDeserializeRtcpFb\n" -"leak:WebRtcSdpTest::TestSerialize\n" -"leak:WebRtcSdpTest_SerializeSessionDescriptionWithDataChannelAndBandwidth_Test::TestBody\n" -"leak:WebRtcSdpTest_SerializeSessionDescriptionWithBandwidth_Test::TestBody\n" -"leak:WebRtcSessionTest::SetLocalDescriptionExpectError\n" -"leak:WebRtcSessionTest_TestAVOfferWithAudioOnlyAnswer_Test::TestBody\n" + // peerconnection_unittests + // https://code.google.com/p/webrtc/issues/detail?id=2528 + "leak:cricket::FakeVideoMediaChannel::~FakeVideoMediaChannel\n" + "leak:cricket::MediaSessionDescriptionFactory::CreateAnswer\n" + "leak:cricket::MediaSessionDescriptionFactory::CreateOffer\n" + "leak:DtmfSenderTest_InsertEmptyTonesToCancelPreviousTask_Test::TestBody\n" + "leak:sigslot::_signal_base2*::~_signal_base2\n" + "leak:testing::internal::CmpHelperEQ\n" + "leak:webrtc::AudioDeviceLinuxALSA::InitMicrophone\n" + "leak:webrtc::AudioDeviceLinuxALSA::InitSpeaker\n" + "leak:webrtc::CreateIceCandidate\n" + "leak:webrtc::FakeConstraints::AddOptional\n" + "leak:webrtc::WebRtcIdentityRequestObserver::OnSuccess\n" + "leak:webrtc::WebRtcSessionDescriptionFactory::InternalCreateAnswer\n" + "leak:webrtc::WebRtcSessionDescriptionFactory::InternalCreateOffer\n" + "leak:PeerConnectionInterfaceTest_SsrcInOfferAnswer_Test::TestBody\n" + "leak:PeerConnectionInterfaceTest_CloseAndTestMethods_Test::TestBody\n" + "leak:WebRtcSdpTest::TestDeserializeRtcpFb\n" + "leak:WebRtcSdpTest::TestSerialize\n" + "leak:WebRtcSdpTest_SerializeSessionDescriptionWithDataChannelAndBandwidth_" + "Test::TestBody\n" + "leak:WebRtcSdpTest_SerializeSessionDescriptionWithBandwidth_Test::" + "TestBody\n" + "leak:WebRtcSessionTest::SetLocalDescriptionExpectError\n" + "leak:WebRtcSessionTest_TestAVOfferWithAudioOnlyAnswer_Test::TestBody\n" -// PLEASE READ ABOVE BEFORE ADDING NEW SUPPRESSIONS. + // PLEASE READ ABOVE BEFORE ADDING NEW SUPPRESSIONS. -// End of suppressions. -; // Please keep this semicolon. + // End of suppressions. + ; // Please keep this semicolon. #endif // LEAK_SANITIZER diff --git a/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc b/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc index 4868dbe792..43a0ac345b 100644 --- a/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc +++ b/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc @@ -21,55 +21,57 @@ // for the instructions on writing suppressions. char kTSanDefaultSuppressions[] = -// WebRTC specific suppressions. + // WebRTC specific suppressions. -// Split up suppressions covered previously by thread.cc and messagequeue.cc. -"race:vp8cx_remove_encoder_threads\n" -"race:third_party/libvpx/source/libvpx/vp9/common/vp9_scan.h\n" + // Split up suppressions covered previously by thread.cc and + // messagequeue.cc. + "race:vp8cx_remove_encoder_threads\n" + "race:third_party/libvpx/source/libvpx/vp9/common/vp9_scan.h\n" -// rtc_unittests -// https://code.google.com/p/webrtc/issues/detail?id=3911 for details. -"race:rtc::MessageQueueManager::Clear\n" -"race:rtc::Thread::Clear\n" -// https://code.google.com/p/webrtc/issues/detail?id=2080 -"race:rtc_base/logging.cc\n" -"race:rtc_base/sharedexclusivelock_unittest.cc\n" -"race:rtc_base/signalthread_unittest.cc\n" -// https://code.google.com/p/webrtc/issues/detail?id=4456 -"deadlock:rtc::MessageQueueManager::Clear\n" -"deadlock:rtc::MessageQueueManager::ClearInternal\n" + // rtc_unittests + // https://code.google.com/p/webrtc/issues/detail?id=3911 for details. + "race:rtc::MessageQueueManager::Clear\n" + "race:rtc::Thread::Clear\n" + // https://code.google.com/p/webrtc/issues/detail?id=2080 + "race:rtc_base/logging.cc\n" + "race:rtc_base/sharedexclusivelock_unittest.cc\n" + "race:rtc_base/signalthread_unittest.cc\n" + // https://code.google.com/p/webrtc/issues/detail?id=4456 + "deadlock:rtc::MessageQueueManager::Clear\n" + "deadlock:rtc::MessageQueueManager::ClearInternal\n" -// rtc_pc_unittests -// https://code.google.com/p/webrtc/issues/detail?id=2079 -"race:rtc_base/testclient.cc\n" -"race:rtc_base/virtualsocketserver.cc\n" -"race:talk/p2p/base/stunserver_unittest.cc\n" + // rtc_pc_unittests + // https://code.google.com/p/webrtc/issues/detail?id=2079 + "race:rtc_base/testclient.cc\n" + "race:rtc_base/virtualsocketserver.cc\n" + "race:talk/p2p/base/stunserver_unittest.cc\n" -// third_party/usrsctp -// TODO(jiayl): https://code.google.com/p/webrtc/issues/detail?id=3492 -"race:user_sctp_timer_iterate\n" + // third_party/usrsctp + // TODO(jiayl): https://code.google.com/p/webrtc/issues/detail?id=3492 + "race:user_sctp_timer_iterate\n" -// https://code.google.com/p/webrtc/issues/detail?id=5151 -"race:sctp_close\n" + // https://code.google.com/p/webrtc/issues/detail?id=5151 + "race:sctp_close\n" -// Potential deadlocks detected after roll in r6516. -// https://code.google.com/p/webrtc/issues/detail?id=3509 -"deadlock:webrtc::test::UdpSocketManagerPosixImpl::RemoveSocket\n" + // Potential deadlocks detected after roll in r6516. + // https://code.google.com/p/webrtc/issues/detail?id=3509 + "deadlock:webrtc::test::UdpSocketManagerPosixImpl::RemoveSocket\n" -// TODO(pbos): Trace events are racy due to lack of proper POD atomics. -// https://code.google.com/p/webrtc/issues/detail?id=2497 -"race:*trace_event_unique_catstatic*\n" + // TODO(pbos): Trace events are racy due to lack of proper POD atomics. + // https://code.google.com/p/webrtc/issues/detail?id=2497 + "race:*trace_event_unique_catstatic*\n" -// Race between InitCpuFlags and TestCpuFlag in libyuv. -// https://code.google.com/p/libyuv/issues/detail?id=508 -"race:InitCpuFlags\n" + // Race between InitCpuFlags and TestCpuFlag in libyuv. + // https://code.google.com/p/libyuv/issues/detail?id=508 + "race:InitCpuFlags\n" -// Test-only race due to PeerConnection::session() being virtual for testing. -// The stats collector may call session() before or after the destructor begins -// executing, which modifies the vtable. -"race:*RTCStatsIntegrationTest_GetsStatsWhileDestroyingPeerConnections_Test::TestBody\n" + // Test-only race due to PeerConnection::session() being virtual for + // testing. The stats collector may call session() before or after the + // destructor begins executing, which modifies the vtable. + "race:*RTCStatsIntegrationTest_GetsStatsWhileDestroyingPeerConnections_" + "Test::TestBody\n" -// End of suppressions. -; // Please keep this semicolon. + // End of suppressions. + ; // Please keep this semicolon. #endif // THREAD_SANITIZER diff --git a/video/call_stats.h b/video/call_stats.h index 5ca44faba5..00feb538ee 100644 --- a/video/call_stats.h +++ b/video/call_stats.h @@ -53,8 +53,7 @@ class CallStats : public Module, public RtcpRttStats { // Helper struct keeping track of the time a rtt value is reported. struct RttTime { - RttTime(int64_t new_rtt, int64_t rtt_time) - : rtt(new_rtt), time(rtt_time) {} + RttTime(int64_t new_rtt, int64_t rtt_time) : rtt(new_rtt), time(rtt_time) {} const int64_t rtt; const int64_t time; }; diff --git a/video/overuse_frame_detector.cc b/video/overuse_frame_detector.cc index 0c56be80a9..d6055c892b 100644 --- a/video/overuse_frame_detector.cc +++ b/video/overuse_frame_detector.cc @@ -195,7 +195,8 @@ class SendProcessingUsage1 : public OveruseFrameDetector::ProcessingUsage { float InitialUsageInPercent() const { // Start in between the underuse and overuse threshold. return (options_.low_encode_usage_threshold_percent + - options_.high_encode_usage_threshold_percent) / 2.0f; + options_.high_encode_usage_threshold_percent) / + 2.0f; } float InitialProcessingMs() const { @@ -442,8 +443,7 @@ CpuOveruseOptions::CpuOveruseOptions() } std::unique_ptr -OveruseFrameDetector::CreateProcessingUsage( - const CpuOveruseOptions& options) { +OveruseFrameDetector::CreateProcessingUsage(const CpuOveruseOptions& options) { std::unique_ptr instance; if (options.filter_time_ms > 0) { instance = rtc::MakeUnique(options); @@ -461,8 +461,8 @@ OveruseFrameDetector::CreateProcessingUsage( if (normal_period_ms > 0 && overuse_period_ms > 0 && underuse_period_ms > 0) { instance = rtc::MakeUnique( - std::move(instance), normal_period_ms, - overuse_period_ms, underuse_period_ms); + std::move(instance), normal_period_ms, overuse_period_ms, + underuse_period_ms); } else { RTC_LOG(LS_WARNING) << "Invalid (non-positive) normal/overuse/underuse periods: " @@ -572,7 +572,7 @@ bool OveruseFrameDetector::FrameTimeoutDetected(int64_t now_us) const { if (last_capture_time_us_ == -1) return false; return (now_us - last_capture_time_us_) > - options_.frame_timeout_interval_ms * rtc::kNumMicrosecsPerMillisec; + options_.frame_timeout_interval_ms * rtc::kNumMicrosecsPerMillisec; } void OveruseFrameDetector::ResetAll(int num_pixels) { diff --git a/video/overuse_frame_detector.h b/video/overuse_frame_detector.h index 800e53f3a3..c3f3cfa052 100644 --- a/video/overuse_frame_detector.h +++ b/video/overuse_frame_detector.h @@ -34,7 +34,7 @@ struct CpuOveruseOptions { // General settings. int frame_timeout_interval_ms; // The maximum allowed interval between two // frames before resetting estimations. - int min_frame_samples; // The minimum number of frames required. + int min_frame_samples; // The minimum number of frames required. int min_process_count; // The number of initial process times required before // triggering an overuse/underuse. int high_threshold_consecutive_count; // The number of consecutive checks diff --git a/video/overuse_frame_detector_unittest.cc b/video/overuse_frame_detector_unittest.cc index bce5642c18..3fc6c173b3 100644 --- a/video/overuse_frame_detector_unittest.cc +++ b/video/overuse_frame_detector_unittest.cc @@ -26,11 +26,11 @@ using ::testing::InvokeWithoutArgs; using ::testing::_; namespace { - const int kWidth = 640; - const int kHeight = 480; - // Corresponds to load of 15% - const int kFrameIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; - const int kProcessTimeUs = 5 * rtc::kNumMicrosecsPerMillisec; +const int kWidth = 640; +const int kHeight = 480; +// Corresponds to load of 15% +const int kFrameIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; +const int kProcessTimeUs = 5 * rtc::kNumMicrosecsPerMillisec; } // namespace class MockCpuOveruseObserver : public AdaptationObserverInterface { @@ -44,9 +44,7 @@ class MockCpuOveruseObserver : public AdaptationObserverInterface { class CpuOveruseObserverImpl : public AdaptationObserverInterface { public: - CpuOveruseObserverImpl() : - overuse_(0), - normaluse_(0) {} + CpuOveruseObserverImpl() : overuse_(0), normaluse_(0) {} virtual ~CpuOveruseObserverImpl() {} void AdaptDown(AdaptReason) { ++overuse_; } @@ -85,7 +83,9 @@ class OveruseFrameDetectorTest : public ::testing::Test, int InitialUsage() { return ((options_.low_encode_usage_threshold_percent + - options_.high_encode_usage_threshold_percent) / 2.0f) + 0.5; + options_.high_encode_usage_threshold_percent) / + 2.0f) + + 0.5; } virtual void InsertAndSendFramesWithInterval(int num_frames, @@ -143,14 +143,14 @@ class OveruseFrameDetectorTest : public ::testing::Test, // the usage. From the tests where these are used, adding another sample // doesn't affect the expected outcome (this is mainly to check initial // values and whether the overuse detector has been reset or not). - InsertAndSendFramesWithInterval(2, rtc::kNumMicrosecsPerSec, - width, height, kFrameIntervalUs); + InsertAndSendFramesWithInterval(2, rtc::kNumMicrosecsPerSec, width, height, + kFrameIntervalUs); } void TriggerOveruse(int num_times) { const int kDelayUs = 32 * rtc::kNumMicrosecsPerMillisec; for (int i = 0; i < num_times; ++i) { - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kDelayUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kDelayUs); overuse_detector_->CheckForOveruse(observer_); } } @@ -158,10 +158,10 @@ class OveruseFrameDetectorTest : public ::testing::Test, void TriggerUnderuse() { const int kDelayUs1 = 5000; const int kDelayUs2 = 6000; - InsertAndSendFramesWithInterval( - 1300, kFrameIntervalUs, kWidth, kHeight, kDelayUs1); - InsertAndSendFramesWithInterval( - 1, kFrameIntervalUs, kWidth, kHeight, kDelayUs2); + InsertAndSendFramesWithInterval(1300, kFrameIntervalUs, kWidth, kHeight, + kDelayUs1); + InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, + kDelayUs2); overuse_detector_->CheckForOveruse(observer_); } @@ -191,7 +191,6 @@ class OveruseFrameDetectorTest : public ::testing::Test, static const auto reason_ = AdaptationObserverInterface::AdaptReason::kCpu; }; - // UsagePercent() > high_encode_usage_threshold_percent => overuse. // UsagePercent() < low_encode_usage_threshold_percent => underuse. TEST_F(OveruseFrameDetectorTest, TriggerOveruse) { @@ -226,8 +225,8 @@ TEST_F(OveruseFrameDetectorTest, TriggerUnderuseWithMinProcessCount) { CpuOveruseObserverImpl overuse_observer; observer_ = nullptr; overuse_detector_->SetOptions(options_); - InsertAndSendFramesWithInterval( - 1200, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1200, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); overuse_detector_->CheckForOveruse(&overuse_observer); EXPECT_EQ(0, overuse_observer.normaluse_); clock_.AdvanceTimeMicros(kProcessIntervalUs); @@ -262,8 +261,8 @@ TEST_F(OveruseFrameDetectorTest, IncorrectConsecutiveCountTriggersNoOveruse) { TEST_F(OveruseFrameDetectorTest, ProcessingUsage) { overuse_detector_->SetOptions(options_); - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_EQ(kProcessTimeUs * 100 / kFrameIntervalUs, UsagePercent()); } @@ -271,8 +270,8 @@ TEST_F(OveruseFrameDetectorTest, ResetAfterResolutionChange) { overuse_detector_->SetOptions(options_); ForceUpdate(kWidth, kHeight); EXPECT_EQ(InitialUsage(), UsagePercent()); - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); // Verify reset (with new width/height). ForceUpdate(kWidth, kHeight + 1); @@ -283,17 +282,18 @@ TEST_F(OveruseFrameDetectorTest, ResetAfterFrameTimeout) { overuse_detector_->SetOptions(options_); ForceUpdate(kWidth, kHeight); EXPECT_EQ(InitialUsage(), UsagePercent()); - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); InsertAndSendFramesWithInterval( - 2, options_.frame_timeout_interval_ms * - rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); + 2, options_.frame_timeout_interval_ms * rtc::kNumMicrosecsPerMillisec, + kWidth, kHeight, kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); // Verify reset. InsertAndSendFramesWithInterval( - 2, (options_.frame_timeout_interval_ms + 1) * - rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); + 2, + (options_.frame_timeout_interval_ms + 1) * rtc::kNumMicrosecsPerMillisec, + kWidth, kHeight, kProcessTimeUs); ForceUpdate(kWidth, kHeight); EXPECT_EQ(InitialUsage(), UsagePercent()); } @@ -301,8 +301,8 @@ TEST_F(OveruseFrameDetectorTest, ResetAfterFrameTimeout) { TEST_F(OveruseFrameDetectorTest, MinFrameSamplesBeforeUpdating) { options_.min_frame_samples = 40; overuse_detector_->SetOptions(options_); - InsertAndSendFramesWithInterval( - 40, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(40, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_EQ(InitialUsage(), UsagePercent()); // Pass time far enough to digest all previous samples. clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerSec); @@ -313,8 +313,8 @@ TEST_F(OveruseFrameDetectorTest, MinFrameSamplesBeforeUpdating) { // Pass time far enough to digest all previous samples, 41 in total. clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerSec); - InsertAndSendFramesWithInterval( - 1, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); } @@ -326,8 +326,7 @@ TEST_F(OveruseFrameDetectorTest, InitialProcessingUsage) { TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) { overuse_detector_->SetOptions(options_); - EXPECT_CALL(mock_observer_, AdaptDown(reason_)) - .Times(testing::AtLeast(1)); + EXPECT_CALL(mock_observer_, AdaptDown(reason_)).Times(testing::AtLeast(1)); static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; static const size_t kNumFramesEncodingDelay = 3; VideoFrame frame(I420Buffer::Create(kWidth, kHeight), @@ -350,8 +349,7 @@ TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) { TEST_F(OveruseFrameDetectorTest, UpdatesExistingSamples) { // >85% encoding time should trigger overuse. overuse_detector_->SetOptions(options_); - EXPECT_CALL(mock_observer_, AdaptDown(reason_)) - .Times(testing::AtLeast(1)); + EXPECT_CALL(mock_observer_, AdaptDown(reason_)).Times(testing::AtLeast(1)); static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; static const int kDelayUs = 30 * rtc::kNumMicrosecsPerMillisec; VideoFrame frame(I420Buffer::Create(kWidth, kHeight), @@ -541,9 +539,9 @@ TEST_F(OveruseFrameDetectorTest, NoOveruseForLargeRandomFrameInterval) { overuse_detector_->OnTargetFramerateUpdated(kTargetFramerate); - InsertAndSendFramesWithRandomInterval(kNumFrames, - kMinIntervalUs, kMaxIntervalUs, - kWidth, kHeight, kEncodeTimeUs); + InsertAndSendFramesWithRandomInterval(kNumFrames, kMinIntervalUs, + kMaxIntervalUs, kWidth, kHeight, + kEncodeTimeUs); // Average usage 19%. Check that estimate is in the right ball park. // EXPECT_NEAR(UsagePercent(), 20, 10); EXPECT_NEAR(UsagePercent(), 20, 35); @@ -569,9 +567,9 @@ TEST_F(OveruseFrameDetectorTest, NoOveruseForRandomFrameIntervalWithReset) { overuse_detector_->OnTargetFramerateUpdated(kTargetFramerate); - InsertAndSendFramesWithRandomInterval(kNumFrames, - kMinIntervalUs, kMaxIntervalUs, - kWidth, kHeight, kEncodeTimeUs); + InsertAndSendFramesWithRandomInterval(kNumFrames, kMinIntervalUs, + kMaxIntervalUs, kWidth, kHeight, + kEncodeTimeUs); // Average usage 6.6%, but since the frame_timeout_interval_ms is // only 1500 ms, we often reset the estimate to the initial value. @@ -670,8 +668,8 @@ TEST_F(OveruseFrameDetectorTest2, TriggerUnderuseWithMinProcessCount) { CpuOveruseObserverImpl overuse_observer; observer_ = nullptr; overuse_detector_->SetOptions(options_); - InsertAndSendFramesWithInterval( - 1200, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1200, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); overuse_detector_->CheckForOveruse(&overuse_observer); EXPECT_EQ(0, overuse_observer.normaluse_); clock_.AdvanceTimeMicros(kProcessIntervalUs); @@ -704,8 +702,8 @@ TEST_F(OveruseFrameDetectorTest2, IncorrectConsecutiveCountTriggersNoOveruse) { TEST_F(OveruseFrameDetectorTest2, ProcessingUsage) { overuse_detector_->SetOptions(options_); - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_EQ(kProcessTimeUs * 100 / kFrameIntervalUs, UsagePercent()); } @@ -713,8 +711,8 @@ TEST_F(OveruseFrameDetectorTest2, ResetAfterResolutionChange) { overuse_detector_->SetOptions(options_); ForceUpdate(kWidth, kHeight); EXPECT_EQ(InitialUsage(), UsagePercent()); - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); // Verify reset (with new width/height). ForceUpdate(kWidth, kHeight + 1); @@ -725,17 +723,18 @@ TEST_F(OveruseFrameDetectorTest2, ResetAfterFrameTimeout) { overuse_detector_->SetOptions(options_); ForceUpdate(kWidth, kHeight); EXPECT_EQ(InitialUsage(), UsagePercent()); - InsertAndSendFramesWithInterval( - 1000, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(1000, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); InsertAndSendFramesWithInterval( - 2, options_.frame_timeout_interval_ms * - rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); + 2, options_.frame_timeout_interval_ms * rtc::kNumMicrosecsPerMillisec, + kWidth, kHeight, kProcessTimeUs); EXPECT_NE(InitialUsage(), UsagePercent()); // Verify reset. InsertAndSendFramesWithInterval( - 2, (options_.frame_timeout_interval_ms + 1) * - rtc::kNumMicrosecsPerMillisec, kWidth, kHeight, kProcessTimeUs); + 2, + (options_.frame_timeout_interval_ms + 1) * rtc::kNumMicrosecsPerMillisec, + kWidth, kHeight, kProcessTimeUs); ForceUpdate(kWidth, kHeight); EXPECT_EQ(InitialUsage(), UsagePercent()); } @@ -749,16 +748,16 @@ TEST_F(OveruseFrameDetectorTest2, ConvergesSlowly) { // Total time approximately 40 * 33ms = 1.3s, significantly less // than the 5s time constant. - InsertAndSendFramesWithInterval( - 40, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(40, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); // Should have started to approach correct load of 15%, but not very far. EXPECT_LT(UsagePercent(), InitialUsage()); EXPECT_GT(UsagePercent(), (InitialUsage() * 3 + 15) / 4); // Run for roughly 10s more, should now be closer. - InsertAndSendFramesWithInterval( - 300, kFrameIntervalUs, kWidth, kHeight, kProcessTimeUs); + InsertAndSendFramesWithInterval(300, kFrameIntervalUs, kWidth, kHeight, + kProcessTimeUs); EXPECT_NEAR(UsagePercent(), 20, 5); } @@ -770,8 +769,7 @@ TEST_F(OveruseFrameDetectorTest2, InitialProcessingUsage) { TEST_F(OveruseFrameDetectorTest2, MeasuresMultipleConcurrentSamples) { overuse_detector_->SetOptions(options_); - EXPECT_CALL(mock_observer_, AdaptDown(reason_)) - .Times(testing::AtLeast(1)); + EXPECT_CALL(mock_observer_, AdaptDown(reason_)).Times(testing::AtLeast(1)); static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; static const size_t kNumFramesEncodingDelay = 3; VideoFrame frame(I420Buffer::Create(kWidth, kHeight), @@ -794,8 +792,7 @@ TEST_F(OveruseFrameDetectorTest2, MeasuresMultipleConcurrentSamples) { TEST_F(OveruseFrameDetectorTest2, UpdatesExistingSamples) { // >85% encoding time should trigger overuse. overuse_detector_->SetOptions(options_); - EXPECT_CALL(mock_observer_, AdaptDown(reason_)) - .Times(testing::AtLeast(1)); + EXPECT_CALL(mock_observer_, AdaptDown(reason_)).Times(testing::AtLeast(1)); static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; static const int kDelayUs = 30 * rtc::kNumMicrosecsPerMillisec; VideoFrame frame(I420Buffer::Create(kWidth, kHeight), @@ -854,8 +851,7 @@ TEST_F(OveruseFrameDetectorTest2, RunOnTqNormalUsage) { TEST_F(OveruseFrameDetectorTest2, NoOveruseForLargeRandomFrameInterval) { overuse_detector_->SetOptions(options_); EXPECT_CALL(mock_observer_, AdaptDown(_)).Times(0); - EXPECT_CALL(mock_observer_, AdaptUp(reason_)) - .Times(testing::AtLeast(1)); + EXPECT_CALL(mock_observer_, AdaptUp(reason_)).Times(testing::AtLeast(1)); const int kNumFrames = 500; const int kEncodeTimeUs = 100 * rtc::kNumMicrosecsPerMillisec; @@ -863,9 +859,9 @@ TEST_F(OveruseFrameDetectorTest2, NoOveruseForLargeRandomFrameInterval) { const int kMinIntervalUs = 30 * rtc::kNumMicrosecsPerMillisec; const int kMaxIntervalUs = 1000 * rtc::kNumMicrosecsPerMillisec; - InsertAndSendFramesWithRandomInterval(kNumFrames, - kMinIntervalUs, kMaxIntervalUs, - kWidth, kHeight, kEncodeTimeUs); + InsertAndSendFramesWithRandomInterval(kNumFrames, kMinIntervalUs, + kMaxIntervalUs, kWidth, kHeight, + kEncodeTimeUs); // Average usage 19%. Check that estimate is in the right ball park. EXPECT_NEAR(UsagePercent(), 20, 10); } @@ -875,8 +871,7 @@ TEST_F(OveruseFrameDetectorTest2, NoOveruseForLargeRandomFrameInterval) { TEST_F(OveruseFrameDetectorTest2, NoOveruseForRandomFrameIntervalWithReset) { overuse_detector_->SetOptions(options_); EXPECT_CALL(mock_observer_, AdaptDown(_)).Times(0); - EXPECT_CALL(mock_observer_, AdaptUp(reason_)) - .Times(testing::AtLeast(1)); + EXPECT_CALL(mock_observer_, AdaptUp(reason_)).Times(testing::AtLeast(1)); const int kNumFrames = 500; const int kEncodeTimeUs = 100 * rtc::kNumMicrosecsPerMillisec; @@ -884,9 +879,9 @@ TEST_F(OveruseFrameDetectorTest2, NoOveruseForRandomFrameIntervalWithReset) { const int kMinIntervalUs = 30 * rtc::kNumMicrosecsPerMillisec; const int kMaxIntervalUs = 3000 * rtc::kNumMicrosecsPerMillisec; - InsertAndSendFramesWithRandomInterval(kNumFrames, - kMinIntervalUs, kMaxIntervalUs, - kWidth, kHeight, kEncodeTimeUs); + InsertAndSendFramesWithRandomInterval(kNumFrames, kMinIntervalUs, + kMaxIntervalUs, kWidth, kHeight, + kEncodeTimeUs); // Average usage 6.6%, but since the frame_timeout_interval_ms is // only 1500 ms, we often reset the estimate to the initial value. diff --git a/video/payload_router_unittest.cc b/video/payload_router_unittest.cc index 0eb898c460..54bdc46326 100644 --- a/video/payload_router_unittest.cc +++ b/video/payload_router_unittest.cc @@ -144,18 +144,15 @@ TEST(PayloadRouterTest, SendSimulcastSetActive) { encoded_image._length, nullptr, _, _)) .Times(1) .WillOnce(Return(true)); - EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); EXPECT_EQ(EncodedImageCallback::Result::OK, payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr) .error); // Inactive. payload_router.SetActive(false); - EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) - .Times(0); - EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); + EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); EXPECT_NE(EncodedImageCallback::Result::OK, payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr) .error); diff --git a/video/picture_id_tests.cc b/video/picture_id_tests.cc index c07cf8fd51..dd746f9200 100644 --- a/video/picture_id_tests.cc +++ b/video/picture_id_tests.cc @@ -259,8 +259,9 @@ class VideoStreamFactory // Use the same total bitrates when sending a single stream to avoid // lowering the bitrate estimate and requiring a subsequent rampup. - const int encoder_stream_bps = kEncoderBitrateBps / rtc::checked_cast( - encoder_config.number_of_streams); + const int encoder_stream_bps = + kEncoderBitrateBps / + rtc::checked_cast(encoder_config.number_of_streams); for (size_t i = 0; i < encoder_config.number_of_streams; ++i) { streams[i].min_bitrate_bps = encoder_stream_bps; diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index 53903cf306..dada445597 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -801,8 +801,7 @@ void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms, } void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, - uint32_t frameRate) { -} + uint32_t frameRate) {} void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe, size_t size_bytes, diff --git a/video/replay.cc b/video/replay.cc index 88a5c58448..8362f59cb4 100644 --- a/video/replay.cc +++ b/video/replay.cc @@ -107,8 +107,8 @@ static int RedPayloadTypeRtx() { // Flag for SSRC. const std::string& DefaultSsrc() { - static const std::string ssrc = std::to_string( - test::CallTest::kVideoSendSsrcs[0]); + static const std::string ssrc = + std::to_string(test::CallTest::kVideoSendSsrcs[0]); return ssrc; } DEFINE_string(ssrc, DefaultSsrc().c_str(), "Incoming SSRC"); @@ -117,8 +117,8 @@ static uint32_t Ssrc() { } const std::string& DefaultSsrcRtx() { - static const std::string ssrc_rtx = std::to_string( - test::CallTest::kSendRtxSsrcs[0]); + static const std::string ssrc_rtx = + std::to_string(test::CallTest::kSendRtxSsrcs[0]); return ssrc_rtx; } DEFINE_string(ssrc_rtx, DefaultSsrcRtx().c_str(), "Incoming RTX SSRC"); @@ -128,7 +128,9 @@ static uint32_t SsrcRtx() { // Flag for abs-send-time id. DEFINE_int(abs_send_time_id, -1, "RTP extension ID for abs-send-time"); -static int AbsSendTimeId() { return static_cast(FLAG_abs_send_time_id); } +static int AbsSendTimeId() { + return static_cast(FLAG_abs_send_time_id); +} // Flag for transmission-offset id. DEFINE_int(transmission_offset_id, @@ -157,7 +159,9 @@ static std::string DecoderBitstreamFilename() { // Flag for video codec. DEFINE_string(codec, "VP8", "Video codec"); -static std::string Codec() { return static_cast(FLAG_codec); } +static std::string Codec() { + return static_cast(FLAG_codec); +} DEFINE_bool(help, false, "Print this message."); } // namespace flags @@ -254,8 +258,8 @@ void RtpReplay() { flags::DecoderBitstreamFilename().c_str())); receive_config.pre_decode_callback = bitstream_writer.get(); } - decoder = test::CreateMatchingDecoder(flags::MediaPayloadType(), - flags::Codec()); + decoder = + test::CreateMatchingDecoder(flags::MediaPayloadType(), flags::Codec()); if (!flags::DecoderBitstreamFilename().empty()) { // Replace with a null decoder if we're writing the bitstream to a file // instead. @@ -334,10 +338,9 @@ void RtpReplay() { fprintf(stderr, "num_packets: %d\n", num_packets); for (std::map::const_iterator it = unknown_packets.begin(); - it != unknown_packets.end(); - ++it) { - fprintf( - stderr, "Packets for unknown ssrc '%u': %d\n", it->first, it->second); + it != unknown_packets.end(); ++it) { + fprintf(stderr, "Packets for unknown ssrc '%u': %d\n", it->first, + it->second); } call->DestroyVideoReceiveStream(receive_stream); @@ -366,8 +369,8 @@ int main(int argc, char* argv[]) { RTC_CHECK(ValidateSsrc(webrtc::flags::FLAG_ssrc)); RTC_CHECK(ValidateSsrc(webrtc::flags::FLAG_ssrc_rtx)); RTC_CHECK(ValidateRtpHeaderExtensionId(webrtc::flags::FLAG_abs_send_time_id)); - RTC_CHECK(ValidateRtpHeaderExtensionId( - webrtc::flags::FLAG_transmission_offset_id)); + RTC_CHECK( + ValidateRtpHeaderExtensionId(webrtc::flags::FLAG_transmission_offset_id)); RTC_CHECK(ValidateInputFilenameNotEmpty(webrtc::flags::FLAG_input_file)); webrtc::test::RunTest(webrtc::RtpReplay); diff --git a/video/report_block_stats.cc b/video/report_block_stats.cc index 4726a46745..42cd2ca4e8 100644 --- a/video/report_block_stats.cc +++ b/video/report_block_stats.cc @@ -19,16 +19,13 @@ int FractionLost(uint32_t num_lost_sequence_numbers, return 0; } return ((num_lost_sequence_numbers * 255) + (num_sequence_numbers / 2)) / - num_sequence_numbers; + num_sequence_numbers; } } // namespace - // Helper class for rtcp statistics. ReportBlockStats::ReportBlockStats() - : num_sequence_numbers_(0), - num_lost_sequence_numbers_(0) { -} + : num_sequence_numbers_(0), num_lost_sequence_numbers_(0) {} void ReportBlockStats::Store(const RtcpStatistics& rtcp_stats, uint32_t remote_ssrc, @@ -43,8 +40,8 @@ void ReportBlockStats::Store(const RtcpStatistics& rtcp_stats, block.source_ssrc = source_ssrc; uint32_t num_sequence_numbers = 0; uint32_t num_lost_sequence_numbers = 0; - StoreAndAddPacketIncrement( - block, &num_sequence_numbers, &num_lost_sequence_numbers); + StoreAndAddPacketIncrement(block, &num_sequence_numbers, + &num_lost_sequence_numbers); } RTCPReportBlock ReportBlockStats::AggregateAndStore( @@ -59,8 +56,7 @@ RTCPReportBlock ReportBlockStats::AggregateAndStore( for (; report_block != report_blocks.end(); ++report_block) { aggregate.packets_lost += report_block->packets_lost; aggregate.jitter += report_block->jitter; - StoreAndAddPacketIncrement(*report_block, - &num_sequence_numbers, + StoreAndAddPacketIncrement(*report_block, &num_sequence_numbers, &num_lost_sequence_numbers); } @@ -105,9 +101,8 @@ int ReportBlockStats::FractionLostInPercent() const { if (num_sequence_numbers_ == 0) { return -1; } - return FractionLost( - num_lost_sequence_numbers_, num_sequence_numbers_) * 100 / 255; + return FractionLost(num_lost_sequence_numbers_, num_sequence_numbers_) * 100 / + 255; } } // namespace webrtc - diff --git a/video/report_block_stats.h b/video/report_block_stats.h index 033ba7deb5..b3c7cf259b 100644 --- a/video/report_block_stats.h +++ b/video/report_block_stats.h @@ -59,4 +59,3 @@ class ReportBlockStats { } // namespace webrtc #endif // VIDEO_REPORT_BLOCK_STATS_H_ - diff --git a/video/report_block_stats_unittest.cc b/video/report_block_stats_unittest.cc index 983dcfcf34..3880c4b11a 100644 --- a/video/report_block_stats_unittest.cc +++ b/video/report_block_stats_unittest.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "test/gtest.h" #include "video/report_block_stats.h" +#include "test/gtest.h" namespace webrtc { @@ -54,8 +54,7 @@ class ReportBlockStatsTest : public ::testing::Test { ssrc12block2_.push_back(block2_2_); } - RtcpStatistics RtcpReportBlockToRtcpStatistics( - const RTCPReportBlock& stats) { + RtcpStatistics RtcpReportBlockToRtcpStatistics(const RTCPReportBlock& stats) { RtcpStatistics block; block.packets_lost = stats.packets_lost; block.fraction_lost = stats.fraction_lost; @@ -143,4 +142,3 @@ TEST_F(ReportBlockStatsTest, StoreAndGetFractionLost) { } } // namespace webrtc - diff --git a/video/rtp_streams_synchronizer.cc b/video/rtp_streams_synchronizer.cc index cc7f89308c..e46a2200c5 100644 --- a/video/rtp_streams_synchronizer.cc +++ b/video/rtp_streams_synchronizer.cc @@ -25,10 +25,9 @@ bool UpdateMeasurements(StreamSynchronization::Measurements* stream, stream->latest_timestamp = info.latest_received_capture_timestamp; stream->latest_receive_time_ms = info.latest_receive_time_ms; bool new_rtcp_sr = false; - if (!stream->rtp_to_ntp.UpdateMeasurements(info.capture_time_ntp_secs, - info.capture_time_ntp_frac, - info.capture_time_source_clock, - &new_rtcp_sr)) { + if (!stream->rtp_to_ntp.UpdateMeasurements( + info.capture_time_ntp_secs, info.capture_time_ntp_frac, + info.capture_time_source_clock, &new_rtcp_sr)) { return false; } return true; @@ -63,7 +62,7 @@ int64_t RtpStreamsSynchronizer::TimeUntilNextProcess() { RTC_DCHECK_RUN_ON(&process_thread_checker_); const int64_t kSyncIntervalMs = 1000; return kSyncIntervalMs - - (rtc::TimeNanos() - last_sync_time_) / rtc::kNumNanosecsPerMillisec; + (rtc::TimeNanos() - last_sync_time_) / rtc::kNumNanosecsPerMillisec; } void RtpStreamsSynchronizer::Process() { @@ -100,18 +99,16 @@ void RtpStreamsSynchronizer::Process() { } TRACE_COUNTER1("webrtc", "SyncCurrentVideoDelay", - video_info->current_delay_ms); + video_info->current_delay_ms); TRACE_COUNTER1("webrtc", "SyncCurrentAudioDelay", - audio_info->current_delay_ms); + audio_info->current_delay_ms); TRACE_COUNTER1("webrtc", "SyncRelativeDelay", relative_delay_ms); int target_audio_delay_ms = 0; int target_video_delay_ms = video_info->current_delay_ms; // Calculate the necessary extra audio delay and desired total video // delay to get the streams in sync. - if (!sync_->ComputeDelays(relative_delay_ms, - audio_info->current_delay_ms, - &target_audio_delay_ms, - &target_video_delay_ms)) { + if (!sync_->ComputeDelays(relative_delay_ms, audio_info->current_delay_ms, + &target_audio_delay_ms, &target_video_delay_ms)) { return; } diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index 271c56f8fc..7f267ef0c2 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -46,7 +46,7 @@ namespace { // crbug.com/752886 constexpr int kPacketBufferStartSize = 512; constexpr int kPacketBufferMaxSixe = 2048; -} +} // namespace std::unique_ptr CreateRtpRtcpModule( ReceiveStatistics* receive_statistics, @@ -403,7 +403,9 @@ void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet, } void RtpVideoStreamReceiver::ParseAndHandleEncapsulatingHeader( - const uint8_t* packet, size_t packet_length, const RTPHeader& header) { + const uint8_t* packet, + size_t packet_length, + const RTPHeader& header) { RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_task_checker_); if (header.payloadType == config_.rtp.red_payload_type) { if (packet[header.headerLength] == config_.rtp.ulpfec_payload_type) { @@ -413,8 +415,8 @@ void RtpVideoStreamReceiver::ParseAndHandleEncapsulatingHeader( NotifyReceiverOfFecPacket(header); } if (ulpfec_receiver_->AddReceivedRedPacket( - header, packet, packet_length, - config_.rtp.ulpfec_payload_type) != 0) { + header, packet, packet_length, config_.rtp.ulpfec_payload_type) != + 0) { return; } ulpfec_receiver_->ProcessReceivedFec(); @@ -543,8 +545,7 @@ bool RtpVideoStreamReceiver::IsPacketRetransmitted(const RTPHeader& header, rtp_receive_statistics_->GetStatistician(header.ssrc); if (!statistician) return false; - return !in_order && - statistician->IsRetransmitOfOldPacket(header); + return !in_order && statistician->IsRetransmitOfOldPacket(header); } void RtpVideoStreamReceiver::UpdateHistograms() { diff --git a/video/rtp_video_stream_receiver_unittest.cc b/video/rtp_video_stream_receiver_unittest.cc index f2a3cde318..2e0d2584ac 100644 --- a/video/rtp_video_stream_receiver_unittest.cc +++ b/video/rtp_video_stream_receiver_unittest.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "test/gtest.h" #include "test/gmock.h" +#include "test/gtest.h" #include "common_video/h264/h264_common.h" #include "media/base/mediaconstants.h" @@ -129,8 +129,8 @@ class RtpVideoStreamReceiverTest : public testing::Test { rtp_video_stream_receiver_ = rtc::MakeUnique( &mock_transport_, nullptr, &packet_router_, &config_, rtp_receive_statistics_.get(), nullptr, process_thread_.get(), - &mock_nack_sender_, - &mock_key_frame_request_sender_, &mock_on_complete_frame_callback_); + &mock_nack_sender_, &mock_key_frame_request_sender_, + &mock_on_complete_frame_callback_); } WebRtcRTPHeader GetDefaultPacket() { @@ -219,13 +219,14 @@ TEST_F(RtpVideoStreamReceiverTest, NoInfiniteRecursionOnEncapsulatedRedPacket) { VideoCodec codec; codec.plType = kRedPayloadType; rtp_video_stream_receiver_->AddReceiveCodec(codec, {}); - const std::vector data({0x80, // RTP version. - kRedPayloadType, // Payload type. - 0, 0, 0, 0, 0, 0, // Don't care. - 0, 0, 0x4, 0x57, // SSRC - kRedPayloadType, // RED header. - 0, 0, 0, 0, 0 // Don't care. - }); + const std::vector data({ + 0x80, // RTP version. + kRedPayloadType, // Payload type. + 0, 0, 0, 0, 0, 0, // Don't care. + 0, 0, 0x4, 0x57, // SSRC + kRedPayloadType, // RED header. + 0, 0, 0, 0, 0 // Don't care. + }); RtpPacketReceived packet; EXPECT_TRUE(packet.Parse(data.data(), data.size())); rtp_video_stream_receiver_->StartReceive(); diff --git a/video/screenshare_loopback.cc b/video/screenshare_loopback.cc index 1b2f394949..81bc34697d 100644 --- a/video/screenshare_loopback.cc +++ b/video/screenshare_loopback.cc @@ -235,9 +235,10 @@ int MinTransmitBitrateKbps() { return FLAG_min_transmit_bitrate; } -DEFINE_bool(generate_slides, - false, - "Whether to use randomly generated slides or read them from files."); +DEFINE_bool( + generate_slides, + false, + "Whether to use randomly generated slides or read them from files."); bool GenerateSlides() { return static_cast(FLAG_generate_slides); } @@ -306,8 +307,12 @@ void Loopback() { params.screenshare[0] = {true, flags::GenerateSlides(), flags::SlideChangeInterval(), flags::ScrollDuration(), flags::Slides()}; - params.analyzer = {"screenshare", 0.0, 0.0, flags::DurationSecs(), - flags::OutputFilename(), flags::GraphTitle()}; + params.analyzer = {"screenshare", + 0.0, + 0.0, + flags::DurationSecs(), + flags::OutputFilename(), + flags::GraphTitle()}; params.pipe = pipe_config; params.logging = {flags::FLAG_logs, flags::RtcEventLogName(), flags::RtpDumpName(), flags::EncodedFramePath()}; diff --git a/video/send_delay_stats.h b/video/send_delay_stats.h index 71bca2d37d..9b9e9214d9 100644 --- a/video/send_delay_stats.h +++ b/video/send_delay_stats.h @@ -15,13 +15,13 @@ #include #include +#include "call/video_send_stream.h" #include "common_types.h" // NOLINT(build/include) #include "modules/include/module_common_types.h" #include "rtc_base/criticalsection.h" #include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" #include "video/stats_counter.h" -#include "call/video_send_stream.h" namespace webrtc { diff --git a/video/send_delay_stats_unittest.cc b/video/send_delay_stats_unittest.cc index 174e70df10..65ae961a8d 100644 --- a/video/send_delay_stats_unittest.cc +++ b/video/send_delay_stats_unittest.cc @@ -107,7 +107,8 @@ TEST_F(SendDelayStatsTest, HistogramsAreUpdated) { const int64_t kDelayMs1 = 5; const int64_t kDelayMs2 = 15; const int kNumSamples = kMinRequiredPeriodicSamples * kProcessIntervalMs / - (kDelayMs1 + kDelayMs2) + 1; + (kDelayMs1 + kDelayMs2) + + 1; uint16_t id = 0; for (int i = 0; i < kNumSamples; ++i) { diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 85afbc9368..7be89b76cb 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -118,7 +118,6 @@ absl::optional GetFallbackMaxPixelsIfFieldTrialDisabled() { } } // namespace - const int SendStatisticsProxy::kStatsTimeoutMs = 5000; SendStatisticsProxy::SendStatisticsProxy( diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h index 7239e7f540..a36e9a8c9e 100644 --- a/video/send_statistics_proxy.h +++ b/video/send_statistics_proxy.h @@ -16,6 +16,7 @@ #include #include +#include "call/video_send_stream.h" #include "common_types.h" // NOLINT(build/include) #include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_coding_defines.h" @@ -28,7 +29,6 @@ #include "video/report_block_stats.h" #include "video/stats_counter.h" #include "video/video_stream_encoder.h" -#include "call/video_send_stream.h" namespace webrtc { diff --git a/video/stats_counter_unittest.cc b/video/stats_counter_unittest.cc index 3f00d24eec..32f8c8e5e1 100644 --- a/video/stats_counter_unittest.cc +++ b/video/stats_counter_unittest.cc @@ -32,8 +32,7 @@ class StatsCounterObserverImpl : public StatsCounterObserver { class StatsCounterTest : public ::testing::Test { protected: - StatsCounterTest() - : clock_(1234) {} + StatsCounterTest() : clock_(1234) {} void AddSampleAndAdvance(int sample, int interval_ms, AvgCounter* counter) { counter->Add(sample); diff --git a/video/stream_synchronization.cc b/video/stream_synchronization.cc index 6b800d1119..e39f122f93 100644 --- a/video/stream_synchronization.cc +++ b/video/stream_synchronization.cc @@ -31,8 +31,7 @@ StreamSynchronization::StreamSynchronization(int video_stream_id, : video_stream_id_(video_stream_id), audio_stream_id_(audio_stream_id), base_target_delay_ms_(0), - avg_diff_ms_(0) { -} + avg_diff_ms_(0) {} bool StreamSynchronization::ComputeRelativeDelay( const Measurements& audio_measurement, @@ -53,7 +52,8 @@ bool StreamSynchronization::ComputeRelativeDelay( return false; } // Positive diff means that video_measurement is behind audio_measurement. - *relative_delay_ms = video_measurement.latest_receive_time_ms - + *relative_delay_ms = + video_measurement.latest_receive_time_ms - audio_measurement.latest_receive_time_ms - (video_last_capture_time_ms - audio_last_capture_time_ms); if (*relative_delay_ms > kMaxDeltaDelayMs || @@ -75,11 +75,11 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms, << " for stream " << audio_stream_id_; // Calculate the difference between the lowest possible video delay and // the current audio delay. - int current_diff_ms = current_video_delay_ms - current_audio_delay_ms + - relative_delay_ms; + int current_diff_ms = + current_video_delay_ms - current_audio_delay_ms + relative_delay_ms; - avg_diff_ms_ = ((kFilterLength - 1) * avg_diff_ms_ + - current_diff_ms) / kFilterLength; + avg_diff_ms_ = + ((kFilterLength - 1) * avg_diff_ms_ + current_diff_ms) / kFilterLength; if (abs(avg_diff_ms_) < kMinDeltaMs) { // Don't adjust if the diff is within our margin. return false; @@ -124,8 +124,8 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms, } // Make sure that video is never below our target. - channel_delay_.extra_video_delay_ms = std::max( - channel_delay_.extra_video_delay_ms, base_target_delay_ms_); + channel_delay_.extra_video_delay_ms = + std::max(channel_delay_.extra_video_delay_ms, base_target_delay_ms_); int new_video_delay_ms; if (channel_delay_.extra_video_delay_ms > base_target_delay_ms_) { @@ -137,8 +137,8 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms, } // Make sure that we don't go below the extra video delay. - new_video_delay_ms = std::max( - new_video_delay_ms, channel_delay_.extra_video_delay_ms); + new_video_delay_ms = + std::max(new_video_delay_ms, channel_delay_.extra_video_delay_ms); // Verify we don't go above the maximum allowed video delay. new_video_delay_ms = @@ -154,8 +154,8 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms, } // Make sure that we don't go below the extra audio delay. - new_audio_delay_ms = std::max( - new_audio_delay_ms, channel_delay_.extra_audio_delay_ms); + new_audio_delay_ms = + std::max(new_audio_delay_ms, channel_delay_.extra_audio_delay_ms); // Verify we don't go above the maximum allowed audio delay. new_audio_delay_ms = @@ -181,13 +181,11 @@ void StreamSynchronization::SetTargetBufferingDelay(int target_delay_ms) { // Initial extra delay for audio (accounting for existing extra delay). channel_delay_.extra_audio_delay_ms += target_delay_ms - base_target_delay_ms_; - channel_delay_.last_audio_delay_ms += - target_delay_ms - base_target_delay_ms_; + channel_delay_.last_audio_delay_ms += target_delay_ms - base_target_delay_ms_; // The video delay is compared to the last value (and how much we can update // is limited by that as well). - channel_delay_.last_video_delay_ms += - target_delay_ms - base_target_delay_ms_; + channel_delay_.last_video_delay_ms += target_delay_ms - base_target_delay_ms_; channel_delay_.extra_video_delay_ms += target_delay_ms - base_target_delay_ms_; diff --git a/video/stream_synchronization_unittest.cc b/video/stream_synchronization_unittest.cc index f9ae37d0bb..d3e8e1088d 100644 --- a/video/stream_synchronization_unittest.cc +++ b/video/stream_synchronization_unittest.cc @@ -31,8 +31,7 @@ static const int kSmoothingFilter = 4 * 2; class Time { public: explicit Time(int64_t offset) - : kNtpJan1970(2208988800UL), - time_now_ms_(offset) {} + : kNtpJan1970(2208988800UL), time_now_ms_(offset) {} NtpTime GetNowNtp() const { uint32_t ntp_secs = time_now_ms_ / 1000 + kNtpJan1970; @@ -46,13 +45,9 @@ class Time { return frequency * time_now_ms_ / 1000 + offset; } - void IncreaseTimeMs(int64_t inc) { - time_now_ms_ += inc; - } + void IncreaseTimeMs(int64_t inc) { time_now_ms_ += inc; } - int64_t time_now_ms() const { - return time_now_ms_; - } + int64_t time_now_ms() const { return time_now_ms_; } private: // January 1970, in NTP seconds. @@ -87,11 +82,11 @@ class StreamSynchronizationTest : public ::testing::Test { int current_audio_delay_ms, int* extra_audio_delay_ms, int* total_video_delay_ms) { - int audio_frequency = static_cast(kDefaultAudioFrequency * - audio_clock_drift_ + 0.5); + int audio_frequency = + static_cast(kDefaultAudioFrequency * audio_clock_drift_ + 0.5); int audio_offset = 0; - int video_frequency = static_cast(kDefaultVideoFrequency * - video_clock_drift_ + 0.5); + int video_frequency = + static_cast(kDefaultVideoFrequency * video_clock_drift_ + 0.5); bool new_sr; int video_offset = 0; StreamSynchronization::Measurements audio; @@ -147,10 +142,8 @@ class StreamSynchronizationTest : public ::testing::Test { StreamSynchronization::ComputeRelativeDelay(audio, video, &relative_delay_ms); EXPECT_EQ(video_delay_ms - audio_delay_ms, relative_delay_ms); - return sync_->ComputeDelays(relative_delay_ms, - current_audio_delay_ms, - extra_audio_delay_ms, - total_video_delay_ms); + return sync_->ComputeDelays(relative_delay_ms, current_audio_delay_ms, + extra_audio_delay_ms, total_video_delay_ms); } // Simulate audio playback 300 ms after capture and video rendering 100 ms @@ -170,38 +163,32 @@ class StreamSynchronizationTest : public ::testing::Test { const int kNeteqDelayIncrease = 50; const int kNeteqDelayDecrease = 10; - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay + filtered_move, total_video_delay_ms); EXPECT_EQ(base_target_delay, extra_audio_delay_ms); current_audio_delay_ms = extra_audio_delay_ms; send_time_->IncreaseTimeMs(1000); - receive_time_->IncreaseTimeMs(1000 - std::max(audio_delay_ms, - video_delay_ms)); + receive_time_->IncreaseTimeMs(1000 - + std::max(audio_delay_ms, video_delay_ms)); // Simulate base_target_delay minimum delay in the VCM. total_video_delay_ms = base_target_delay; - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay + 2 * filtered_move, total_video_delay_ms); EXPECT_EQ(base_target_delay, extra_audio_delay_ms); current_audio_delay_ms = extra_audio_delay_ms; send_time_->IncreaseTimeMs(1000); - receive_time_->IncreaseTimeMs(1000 - std::max(audio_delay_ms, - video_delay_ms)); + receive_time_->IncreaseTimeMs(1000 - + std::max(audio_delay_ms, video_delay_ms)); // Simulate base_target_delay minimum delay in the VCM. total_video_delay_ms = base_target_delay; - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay + 3 * filtered_move, total_video_delay_ms); EXPECT_EQ(base_target_delay, extra_audio_delay_ms); @@ -209,37 +196,33 @@ class StreamSynchronizationTest : public ::testing::Test { // Simulate that NetEQ introduces some audio delay. current_audio_delay_ms = base_target_delay + kNeteqDelayIncrease; send_time_->IncreaseTimeMs(1000); - receive_time_->IncreaseTimeMs(1000 - std::max(audio_delay_ms, - video_delay_ms)); + receive_time_->IncreaseTimeMs(1000 - + std::max(audio_delay_ms, video_delay_ms)); // Simulate base_target_delay minimum delay in the VCM. total_video_delay_ms = base_target_delay; - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); filtered_move = 3 * filtered_move + - (kNeteqDelayIncrease + audio_delay_ms - video_delay_ms) / - kSmoothingFilter; + (kNeteqDelayIncrease + audio_delay_ms - video_delay_ms) / + kSmoothingFilter; EXPECT_EQ(base_target_delay + filtered_move, total_video_delay_ms); EXPECT_EQ(base_target_delay, extra_audio_delay_ms); // Simulate that NetEQ reduces its delay. current_audio_delay_ms = base_target_delay + kNeteqDelayDecrease; send_time_->IncreaseTimeMs(1000); - receive_time_->IncreaseTimeMs(1000 - std::max(audio_delay_ms, - video_delay_ms)); + receive_time_->IncreaseTimeMs(1000 - + std::max(audio_delay_ms, video_delay_ms)); // Simulate base_target_delay minimum delay in the VCM. total_video_delay_ms = base_target_delay; - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); filtered_move = filtered_move + - (kNeteqDelayDecrease + audio_delay_ms - video_delay_ms) / - kSmoothingFilter; + (kNeteqDelayDecrease + audio_delay_ms - video_delay_ms) / + kSmoothingFilter; EXPECT_EQ(base_target_delay + filtered_move, total_video_delay_ms); EXPECT_EQ(base_target_delay, extra_audio_delay_ms); @@ -252,10 +235,8 @@ class StreamSynchronizationTest : public ::testing::Test { int extra_audio_delay_ms = 0; int total_video_delay_ms = base_target_delay; - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay, total_video_delay_ms); // The audio delay is not allowed to change more than this in 1 second. @@ -265,77 +246,73 @@ class StreamSynchronizationTest : public ::testing::Test { send_time_->IncreaseTimeMs(1000); receive_time_->IncreaseTimeMs(800); - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay, total_video_delay_ms); // The audio delay is not allowed to change more than the half of the // required change in delay. - EXPECT_EQ(current_extra_delay_ms + MaxAudioDelayIncrease( - current_audio_delay_ms, - base_target_delay + video_delay_ms - audio_delay_ms), - extra_audio_delay_ms); + EXPECT_EQ(current_extra_delay_ms + + MaxAudioDelayIncrease( + current_audio_delay_ms, + base_target_delay + video_delay_ms - audio_delay_ms), + extra_audio_delay_ms); current_audio_delay_ms = extra_audio_delay_ms; current_extra_delay_ms = extra_audio_delay_ms; send_time_->IncreaseTimeMs(1000); receive_time_->IncreaseTimeMs(800); - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay, total_video_delay_ms); // The audio delay is not allowed to change more than the half of the // required change in delay. - EXPECT_EQ(current_extra_delay_ms + MaxAudioDelayIncrease( - current_audio_delay_ms, - base_target_delay + video_delay_ms - audio_delay_ms), - extra_audio_delay_ms); + EXPECT_EQ(current_extra_delay_ms + + MaxAudioDelayIncrease( + current_audio_delay_ms, + base_target_delay + video_delay_ms - audio_delay_ms), + extra_audio_delay_ms); current_extra_delay_ms = extra_audio_delay_ms; // Simulate that NetEQ for some reason reduced the delay. current_audio_delay_ms = base_target_delay + 10; send_time_->IncreaseTimeMs(1000); receive_time_->IncreaseTimeMs(800); - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay, total_video_delay_ms); // Since we only can ask NetEQ for a certain amount of extra delay, and // we only measure the total NetEQ delay, we will ask for additional delay // here to try to stay in sync. - EXPECT_EQ(current_extra_delay_ms + MaxAudioDelayIncrease( - current_audio_delay_ms, - base_target_delay + video_delay_ms - audio_delay_ms), - extra_audio_delay_ms); + EXPECT_EQ(current_extra_delay_ms + + MaxAudioDelayIncrease( + current_audio_delay_ms, + base_target_delay + video_delay_ms - audio_delay_ms), + extra_audio_delay_ms); current_extra_delay_ms = extra_audio_delay_ms; // Simulate that NetEQ for some reason significantly increased the delay. current_audio_delay_ms = base_target_delay + 350; send_time_->IncreaseTimeMs(1000); receive_time_->IncreaseTimeMs(800); - EXPECT_TRUE(DelayedStreams(audio_delay_ms, - video_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, + EXPECT_TRUE(DelayedStreams(audio_delay_ms, video_delay_ms, + current_audio_delay_ms, &extra_audio_delay_ms, &total_video_delay_ms)); EXPECT_EQ(base_target_delay, total_video_delay_ms); // The audio delay is not allowed to change more than the half of the // required change in delay. - EXPECT_EQ(current_extra_delay_ms + MaxAudioDelayIncrease( - current_audio_delay_ms, - base_target_delay + video_delay_ms - audio_delay_ms), - extra_audio_delay_ms); + EXPECT_EQ(current_extra_delay_ms + + MaxAudioDelayIncrease( + current_audio_delay_ms, + base_target_delay + video_delay_ms - audio_delay_ms), + extra_audio_delay_ms); } int MaxAudioDelayIncrease(int current_audio_delay_ms, int delay_ms) { return std::min((delay_ms - current_audio_delay_ms) / kSmoothingFilter, - static_cast(kMaxAudioDiffMs)); + static_cast(kMaxAudioDiffMs)); } int MaxAudioDelayDecrease(int current_audio_delay_ms, int delay_ms) { @@ -347,7 +324,7 @@ class StreamSynchronizationTest : public ::testing::Test { enum { kReceiveTimeOffsetMs = 43210 }; StreamSynchronization* sync_; - Time* send_time_; // The simulated clock at the sender. + Time* send_time_; // The simulated clock at the sender. Time* receive_time_; // The simulated clock at the receiver. double audio_clock_drift_; double video_clock_drift_; @@ -418,7 +395,7 @@ TEST_F(StreamSynchronizationTest, AudioDelay) { // The audio delay is not allowed to change more than the half of the required // change in delay. EXPECT_EQ(current_extra_delay_ms + - MaxAudioDelayIncrease(current_audio_delay_ms, delay_ms), + MaxAudioDelayIncrease(current_audio_delay_ms, delay_ms), extra_audio_delay_ms); current_audio_delay_ms = extra_audio_delay_ms; current_extra_delay_ms = extra_audio_delay_ms; @@ -431,7 +408,7 @@ TEST_F(StreamSynchronizationTest, AudioDelay) { // The audio delay is not allowed to change more than the half of the required // change in delay. EXPECT_EQ(current_extra_delay_ms + - MaxAudioDelayIncrease(current_audio_delay_ms, delay_ms), + MaxAudioDelayIncrease(current_audio_delay_ms, delay_ms), extra_audio_delay_ms); current_extra_delay_ms = extra_audio_delay_ms; @@ -446,7 +423,7 @@ TEST_F(StreamSynchronizationTest, AudioDelay) { // we only measure the total NetEQ delay, we will ask for additional delay // here to try to EXPECT_EQ(current_extra_delay_ms + - MaxAudioDelayIncrease(current_audio_delay_ms, delay_ms), + MaxAudioDelayIncrease(current_audio_delay_ms, delay_ms), extra_audio_delay_ms); current_extra_delay_ms = extra_audio_delay_ms; @@ -460,7 +437,7 @@ TEST_F(StreamSynchronizationTest, AudioDelay) { // The audio delay is not allowed to change more than the half of the required // change in delay. EXPECT_EQ(current_extra_delay_ms + - MaxAudioDelayDecrease(current_audio_delay_ms, delay_ms), + MaxAudioDelayDecrease(current_audio_delay_ms, delay_ms), extra_audio_delay_ms); } @@ -500,8 +477,8 @@ TEST_F(StreamSynchronizationTest, BaseDelay) { sync_->SetTargetBufferingDelay(base_target_delay_ms); // We are in sync don't change. EXPECT_FALSE(DelayedStreams(base_target_delay_ms, base_target_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, &total_video_delay_ms)); + current_audio_delay_ms, &extra_audio_delay_ms, + &total_video_delay_ms)); // Triggering another call with the same values. Delay should not be modified. base_target_delay_ms = 2000; current_audio_delay_ms = base_target_delay_ms; @@ -509,8 +486,8 @@ TEST_F(StreamSynchronizationTest, BaseDelay) { sync_->SetTargetBufferingDelay(base_target_delay_ms); // We are in sync don't change. EXPECT_FALSE(DelayedStreams(base_target_delay_ms, base_target_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, &total_video_delay_ms)); + current_audio_delay_ms, &extra_audio_delay_ms, + &total_video_delay_ms)); // Changing delay value - intended to test this module only. In practice it // would take VoE time to adapt. base_target_delay_ms = 5000; @@ -519,8 +496,8 @@ TEST_F(StreamSynchronizationTest, BaseDelay) { sync_->SetTargetBufferingDelay(base_target_delay_ms); // We are in sync don't change. EXPECT_FALSE(DelayedStreams(base_target_delay_ms, base_target_delay_ms, - current_audio_delay_ms, - &extra_audio_delay_ms, &total_video_delay_ms)); + current_audio_delay_ms, &extra_audio_delay_ms, + &total_video_delay_ms)); } TEST_F(StreamSynchronizationTest, BothDelayedAudioLaterWithBaseDelay) { diff --git a/video/test/mock_video_stream_encoder.h b/video/test/mock_video_stream_encoder.h index 37337f7fff..049b8c147f 100644 --- a/video/test/mock_video_stream_encoder.h +++ b/video/test/mock_video_stream_encoder.h @@ -29,8 +29,7 @@ class MockVideoStreamEncoder : public VideoStreamEncoderInterface { void(VideoBitrateAllocationObserver*)); MOCK_METHOD0(Stop, void()); - MOCK_METHOD2(MockedConfigureEncoder, - void(const VideoEncoderConfig&, size_t)); + MOCK_METHOD2(MockedConfigureEncoder, void(const VideoEncoderConfig&, size_t)); // gtest generates implicit copy which is not allowed on VideoEncoderConfig, // so we can't mock ConfigureEncoder directly. void ConfigureEncoder(VideoEncoderConfig config, diff --git a/video/transport_adapter.h b/video/transport_adapter.h index 0168cc5b86..dd9964f363 100644 --- a/video/transport_adapter.h +++ b/video/transport_adapter.h @@ -31,7 +31,7 @@ class TransportAdapter : public Transport { void Disable(); private: - Transport *transport_; + Transport* transport_; std::atomic enabled_; }; } // namespace internal diff --git a/video/video_loopback.cc b/video/video_loopback.cc index 0289c080a8..6405fc8646 100644 --- a/video/video_loopback.cc +++ b/video/video_loopback.cc @@ -242,8 +242,10 @@ DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction."); DEFINE_bool(audio, false, "Add audio stream"); -DEFINE_bool(audio_video_sync, false, "Sync audio and video stream (no effect if" - " audio is false)"); +DEFINE_bool(audio_video_sync, + false, + "Sync audio and video stream (no effect if" + " audio is false)"); DEFINE_bool(audio_dtx, false, "Enable audio DTX (no effect if audio is false)"); @@ -308,8 +310,12 @@ void Loopback() { params.logging = {flags::FLAG_logs, flags::FLAG_rtc_event_log_name, flags::FLAG_rtp_dump_name, flags::FLAG_encoded_frame_path}; params.screenshare[0].enabled = false; - params.analyzer = {"video", 0.0, 0.0, flags::DurationSecs(), - flags::OutputFilename(), flags::GraphTitle()}; + params.analyzer = {"video", + 0.0, + 0.0, + flags::DurationSecs(), + flags::OutputFilename(), + flags::GraphTitle()}; params.pipe = pipe_config; if (flags::NumStreams() > 1 && flags::Stream0().empty() && diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 3a174c4b17..3dbff9fe6f 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -609,13 +609,11 @@ class VideoAnalyzer : public PacketReceiver, rtc::CritScope crit(&comparison_lock_); if (comparisons_.size() < kMaxComparisons) { - comparisons_.push_back(FrameComparison(reference, render, dropped, - reference.ntp_time_ms(), - send_time_ms, recv_time_ms, - render_time_ms, encoded_size)); + comparisons_.push_back(FrameComparison( + reference, render, dropped, reference.ntp_time_ms(), send_time_ms, + recv_time_ms, render_time_ms, encoded_size)); } else { - comparisons_.push_back(FrameComparison(dropped, - reference.ntp_time_ms(), + comparisons_.push_back(FrameComparison(dropped, reference.ntp_time_ms(), send_time_ms, recv_time_ms, render_time_ms, encoded_size)); } @@ -765,7 +763,7 @@ class VideoAnalyzer : public PacketReceiver, if (worst_frame_) { test::PrintResult("min_psnr", "", test_label_.c_str(), worst_frame_->psnr, - "dB", false); + "dB", false); } if (receive_stream_ != nullptr) { @@ -773,14 +771,14 @@ class VideoAnalyzer : public PacketReceiver, } test::PrintResult("dropped_frames", "", test_label_.c_str(), - dropped_frames_, "frames", false); + dropped_frames_, "frames", false); test::PrintResult("cpu_usage", "", test_label_.c_str(), GetCpuUsagePercent(), "%", false); #if defined(WEBRTC_WIN) - // On Linux and Mac in Resident Set some unused pages may be counted. - // Therefore this metric will depend on order in which tests are run and - // will be flaky. + // On Linux and Mac in Resident Set some unused pages may be counted. + // Therefore this metric will depend on order in which tests are run and + // will be flaky. PrintResult("memory_usage", memory_usage_, " bytes"); #endif @@ -794,8 +792,8 @@ class VideoAnalyzer : public PacketReceiver, rtc::Pathname(output_dir, test_label_ + ".jpg").pathname(); RTC_LOG(LS_INFO) << "Saving worst frame to " << output_path; test::JpegFrameWriter frame_writer(output_path); - RTC_CHECK(frame_writer.WriteFrame(worst_frame_->frame, - 100 /*best quality*/)); + RTC_CHECK( + frame_writer.WriteFrame(worst_frame_->frame, 100 /*best quality*/)); } // Disable quality check for quick test, as quality checks may fail @@ -904,8 +902,9 @@ class VideoAnalyzer : public PacketReceiver, "ssim " "encode_time_ms\n"); for (const Sample& sample : samples_) { - fprintf(out, "%d %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRIuS - " %lf %lf\n", + fprintf(out, + "%d %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRIuS + " %lf %lf\n", sample.dropped, sample.input_time_ms, sample.send_time_ms, sample.recv_time_ms, sample.render_time_ms, sample.encoded_frame_size, sample.psnr, sample.ssim); @@ -1568,8 +1567,8 @@ void VideoQualityTest::SetupVideo(Transport* send_transport, VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); } else { RTC_NOTREACHED() << "Automatic scaling not supported for codec " - << params_.video[video_idx].codec - << ", stream " << video_idx; + << params_.video[video_idx].codec << ", stream " + << video_idx; } } total_streams_used += num_video_substreams; @@ -2110,9 +2109,10 @@ void VideoQualityTest::SetupAudio(Transport* transport, } audio_send_config_.send_codec_spec = AudioSendStream::Config::SendCodecSpec( kAudioSendPayloadType, - {"OPUS", 48000, 2, - {{"usedtx", (params_.audio.dtx ? "1" : "0")}, - {"stereo", "1"}}}); + {"OPUS", + 48000, + 2, + {{"usedtx", (params_.audio.dtx ? "1" : "0")}, {"stereo", "1"}}}); audio_send_config_.encoder_factory = audio_encoder_factory_; audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_); diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index f5c7e2a9c2..3b3d84fda5 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -300,10 +300,9 @@ void VideoReceiveStream::OnFrame(const VideoFrame& video_frame) { // function itself, another in GetChannel() and a third in // GetPlayoutTimestamp. Seems excessive. Anyhow, I'm assuming the function // succeeds most of the time, which leads to grabbing a fourth lock. - if (rtp_stream_sync_.GetStreamSyncOffsetInMs(video_frame.timestamp(), - video_frame.render_time_ms(), - &sync_offset_ms, - &estimated_freq_khz)) { + if (rtp_stream_sync_.GetStreamSyncOffsetInMs( + video_frame.timestamp(), video_frame.render_time_ms(), + &sync_offset_ms, &estimated_freq_khz)) { // TODO(tommi): OnSyncOffsetUpdated grabs a lock. stats_proxy_.OnSyncOffsetUpdated(sync_offset_ms, estimated_freq_khz); } @@ -389,9 +388,7 @@ absl::optional VideoReceiveStream::GetInfo() const { RtpRtcp* rtp_rtcp = rtp_video_stream_receiver_.rtp_rtcp(); RTC_DCHECK(rtp_rtcp); if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs, - &info.capture_time_ntp_frac, - nullptr, - nullptr, + &info.capture_time_ntp_frac, nullptr, nullptr, &info.capture_time_source_clock) != 0) { return absl::nullopt; } diff --git a/video/video_receive_stream_unittest.cc b/video/video_receive_stream_unittest.cc index db2ad3eb70..081bbb566d 100644 --- a/video/video_receive_stream_unittest.cc +++ b/video/video_receive_stream_unittest.cc @@ -10,8 +10,8 @@ #include -#include "test/gtest.h" #include "test/gmock.h" +#include "test/gtest.h" #include "api/video_codecs/video_decoder.h" #include "call/rtp_stream_receiver_controller.h" @@ -90,8 +90,8 @@ class VideoReceiveStreamTest : public testing::Test { config_.decoders.push_back(null_decoder); video_receive_stream_.reset(new webrtc::internal::VideoReceiveStream( - &rtp_stream_receiver_controller_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), process_thread_.get(), &call_stats_)); + &rtp_stream_receiver_controller_, kDefaultNumCpuCores, &packet_router_, + config_.Copy(), process_thread_.get(), &call_stats_)); } protected: diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index 3eb2d761a3..bb6bcb5fc7 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -16,7 +16,6 @@ namespace webrtc { - namespace { size_t CalculateMaxHeaderSize(const VideoSendStream::Config::Rtp& config) { @@ -54,7 +53,6 @@ size_t CalculateMaxHeaderSize(const VideoSendStream::Config::Rtp& config) { namespace internal { - VideoSendStream::VideoSendStream( int num_cpu_cores, ProcessThread* module_process_thread, @@ -80,8 +78,7 @@ VideoSendStream::VideoSendStream( RTC_DCHECK(config_.encoder_settings.encoder_factory); video_stream_encoder_ = rtc::MakeUnique( - num_cpu_cores, &stats_proxy_, - config_.encoder_settings, + num_cpu_cores, &stats_proxy_, config_.encoder_settings, config_.pre_encode_callback, rtc::MakeUnique(&stats_proxy_)); // TODO(srte): Initialization should not be done posted on a task queue. diff --git a/video/video_send_stream.h b/video/video_send_stream.h index a41add8e9e..a282853446 100644 --- a/video/video_send_stream.h +++ b/video/video_send_stream.h @@ -23,8 +23,8 @@ #include "rtc_base/criticalsection.h" #include "rtc_base/event.h" #include "rtc_base/task_queue.h" -#include "video/send_delay_stats.h" #include "video/payload_router.h" +#include "video/send_delay_stats.h" #include "video/send_statistics_proxy.h" #include "video/video_stream_encoder.h" diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index a11d05e3ef..2bb1cbdf64 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -67,7 +67,10 @@ class VideoSendStreamPeer { }; } // namespace test -enum VideoFormat { kGeneric, kVP8, }; +enum VideoFormat { + kGeneric, + kVP8, +}; void ExpectEqualFramesVector(const std::vector& frames1, const std::vector& frames2); @@ -1169,8 +1172,8 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, // Don't auto increment if FEC is used; continue sending frame size until // a FEC packet has been received. - FrameFragmentationTest test( - kMaxPacketSize, start, stop, format == kGeneric, with_fec); + FrameFragmentationTest test(kMaxPacketSize, start, stop, format == kGeneric, + with_fec); RunBaseTest(&test); } @@ -1357,8 +1360,7 @@ TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) { : SendTest(kDefaultTimeoutMs), clock_(Clock::GetRealTimeClock()), last_packet_time_ms_(-1), - capturer_(nullptr) { - } + capturer_(nullptr) {} private: Action OnSendRtp(const uint8_t* packet, size_t length) override { @@ -1530,12 +1532,9 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { EXPECT_EQ(1u, stats.substreams.size()); int total_bitrate_bps = stats.substreams.begin()->second.total_bitrate_bps; - test::PrintResult("bitrate_stats_", - "min_transmit_bitrate_low_remb", - "bitrate_bps", - static_cast(total_bitrate_bps), - "bps", - false); + test::PrintResult("bitrate_stats_", "min_transmit_bitrate_low_remb", + "bitrate_bps", static_cast(total_bitrate_bps), + "bps", false); if (total_bitrate_bps > kHighBitrateBps) { rtp_rtcp_->SetRemb(kRembBitrateBps, std::vector(1, header.ssrc)); @@ -2115,19 +2114,13 @@ TEST_F(VideoSendStreamTest, VideoSendStreamStopSetEncoderRateToZero) { EXPECT_TRUE(encoder.WaitForEncoderInit()); - task_queue_.SendTask([this]() { - video_send_stream_->Start(); - }); + task_queue_.SendTask([this]() { video_send_stream_->Start(); }); EXPECT_TRUE(encoder.WaitBitrateChanged(true)); - task_queue_.SendTask([this]() { - video_send_stream_->Stop(); - }); + task_queue_.SendTask([this]() { video_send_stream_->Stop(); }); EXPECT_TRUE(encoder.WaitBitrateChanged(false)); - task_queue_.SendTask([this]() { - video_send_stream_->Start(); - }); + task_queue_.SendTask([this]() { video_send_stream_->Start(); }); EXPECT_TRUE(encoder.WaitBitrateChanged(true)); task_queue_.SendTask([this]() { @@ -2707,9 +2700,10 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesH264Config) { TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) { class RtcpSenderReportTest : public test::SendTest { public: - RtcpSenderReportTest() : SendTest(kDefaultTimeoutMs), - rtp_packets_sent_(0), - media_bytes_sent_(0) {} + RtcpSenderReportTest() + : SendTest(kDefaultTimeoutMs), + rtp_packets_sent_(0), + media_bytes_sent_(0) {} private: Action OnSendRtp(const uint8_t* packet, size_t length) override { @@ -2795,8 +2789,8 @@ TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) { EXPECT_EQ(static_cast(kScreencastMaxTargetBitrateDeltaKbps), config->maxBitrate - config->targetBitrate); observation_complete_.Set(); - return test::FakeEncoder::InitEncode( - config, number_of_cores, max_payload_size); + return test::FakeEncoder::InitEncode(config, number_of_cores, + max_payload_size); } void ModifyVideoConfigs( VideoSendStream::Config* send_config, @@ -3008,8 +3002,7 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) { static const struct { int width; int height; - } kEncodedResolution[kNumStreams] = { - {241, 181}, {300, 121}, {121, 221}}; + } kEncodedResolution[kNumStreams] = {{241, 181}, {300, 121}, {121, 221}}; class ScreencastTargetBitrateTest : public test::SendTest, public test::FakeEncoder { public: @@ -3142,7 +3135,7 @@ class Vp9HeaderObserver : public test::SendTest { send_config->rtp.payload_type = kVp9PayloadType; ModifyVideoConfigsHook(send_config, receive_configs, encoder_config); encoder_config->encoder_specific_settings = new rtc::RefCountedObject< - VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings_); + VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings_); EXPECT_EQ(1u, encoder_config->number_of_streams); encoder_config->video_stream_factory = new rtc::RefCountedObject( diff --git a/video/video_stream_decoder.cc b/video/video_stream_decoder.cc index 86810dd25d..ce84c75a0e 100644 --- a/video/video_stream_decoder.cc +++ b/video/video_stream_decoder.cc @@ -40,8 +40,7 @@ VideoStreamDecoder::VideoStreamDecoder( static const int kMaxPacketAgeToNack = 450; static const int kMaxNackListSize = 250; - video_receiver_->SetNackSettings(kMaxNackListSize, - kMaxPacketAgeToNack, 0); + video_receiver_->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0); video_receiver_->RegisterReceiveCallback(this); video_receiver_->RegisterFrameTypeCallback(vcm_frame_type_callback); video_receiver_->RegisterReceiveStatisticsCallback(this); @@ -84,7 +83,7 @@ int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame, } int32_t VideoStreamDecoder::ReceivedDecodedReferenceFrame( - const uint64_t picture_id) { + const uint64_t picture_id) { RTC_NOTREACHED(); return 0; } diff --git a/video/video_stream_decoder_impl.cc b/video/video_stream_decoder_impl.cc index 1bbf943dc4..19e75a8a3b 100644 --- a/video/video_stream_decoder_impl.cc +++ b/video/video_stream_decoder_impl.cc @@ -203,11 +203,10 @@ VideoStreamDecoderImpl::DecodeResult VideoStreamDecoderImpl::DecodeNextFrame( Add(next_frame_timestamps_index_, 1); }); - int32_t decode_result = - decoder->Decode(frame->EncodedImage(), - false, // missing_frame - nullptr, // codec specific info - frame->RenderTimeMs()); + int32_t decode_result = decoder->Decode(frame->EncodedImage(), + false, // missing_frame + nullptr, // codec specific info + frame->RenderTimeMs()); return decode_result == WEBRTC_VIDEO_CODEC_OK ? kOk : kDecodeFailure; } diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 6aee7768dc..3bf45ca940 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -440,15 +440,15 @@ void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config, // when C++14 lambda is allowed. struct ConfigureEncoderTask { void operator()() { - encoder->ConfigureEncoderOnTaskQueue( - std::move(config), max_data_payload_length); + encoder->ConfigureEncoderOnTaskQueue(std::move(config), + max_data_payload_length); } VideoStreamEncoder* encoder; VideoEncoderConfig config; size_t max_data_payload_length; }; - encoder_queue_.PostTask(ConfigureEncoderTask{ - this, std::move(config), max_data_payload_length}); + encoder_queue_.PostTask( + ConfigureEncoderTask{this, std::move(config), max_data_payload_length}); } void VideoStreamEncoder::ConfigureEncoderOnTaskQueue( @@ -470,8 +470,9 @@ void VideoStreamEncoder::ConfigureEncoderOnTaskQueue( // The codec configuration depends on incoming video frame size. if (last_frame_info_) { ReconfigureEncoder(); - } else if (settings_.encoder_factory->QueryVideoEncoder( - encoder_config_.video_format).has_internal_source) { + } else if (settings_.encoder_factory + ->QueryVideoEncoder(encoder_config_.video_format) + .has_internal_source) { last_frame_info_ = VideoFrameInfo(176, 144, false); ReconfigureEncoder(); } @@ -502,8 +503,8 @@ void VideoStreamEncoder::ReconfigureEncoder() { crop_height_ = last_frame_info_->height - highest_stream_height; VideoCodec codec; - if (!VideoCodecInitializer::SetupCodec( - encoder_config_, streams, &codec, &rate_allocator_)) { + if (!VideoCodecInitializer::SetupCodec(encoder_config_, streams, &codec, + &rate_allocator_)) { RTC_LOG(LS_ERROR) << "Failed to create encoder configuration."; } @@ -573,8 +574,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { video_sender_.UpdateChannelParameters(rate_allocator_.get(), bitrate_observer_); - stats_proxy_->OnEncoderReconfigured( - encoder_config_, streams); + stats_proxy_->OnEncoderReconfigured(encoder_config_, streams); pending_encoder_reconfiguration_ = false; @@ -795,7 +795,6 @@ void VideoStreamEncoder::MaybeEncodeVideoFrame(const VideoFrame& video_frame, } initial_rampup_ = kMaxInitialFramedrop; - if (EncoderPaused()) { // Storing references to a native buffer risks blocking frame capture. if (video_frame.video_frame_buffer()->type() != diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index 0ea6deca93..76ae07e32d 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -104,12 +104,8 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, class VideoFrameInfo { public: - VideoFrameInfo(int width, - int height, - bool is_texture) - : width(width), - height(height), - is_texture(is_texture) {} + VideoFrameInfo(int width, int height, bool is_texture) + : width(width), height(height), is_texture(is_texture) {} int width; int height; bool is_texture; @@ -204,8 +200,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, vcm::VideoSender video_sender_ RTC_GUARDED_BY(&encoder_queue_); const std::unique_ptr overuse_detector_ RTC_PT_GUARDED_BY(&encoder_queue_); - std::unique_ptr quality_scaler_ - RTC_GUARDED_BY(&encoder_queue_) + std::unique_ptr quality_scaler_ RTC_GUARDED_BY(&encoder_queue_) RTC_PT_GUARDED_BY(&encoder_queue_); SendStatisticsProxy* const stats_proxy_; @@ -218,8 +213,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, std::unique_ptr encoder_ RTC_GUARDED_BY(&encoder_queue_) RTC_PT_GUARDED_BY(&encoder_queue_); std::unique_ptr rate_allocator_ - RTC_GUARDED_BY(&encoder_queue_) - RTC_PT_GUARDED_BY(&encoder_queue_); + RTC_GUARDED_BY(&encoder_queue_) RTC_PT_GUARDED_BY(&encoder_queue_); // The maximum frame rate of the current codec configuration, as determined // at the last ReconfigureEncoder() call. int max_framerate_ RTC_GUARDED_BY(&encoder_queue_); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index d83322deff..7324b80058 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -91,16 +91,16 @@ class CpuOveruseDetectorProxy : public OveruseFrameDetector { class VideoStreamEncoderUnderTest : public VideoStreamEncoder { public: - VideoStreamEncoderUnderTest(SendStatisticsProxy* stats_proxy, - const VideoSendStream::Config::EncoderSettings& settings) - : VideoStreamEncoder( - 1 /* number_of_cores */, - stats_proxy, - settings, - nullptr /* pre_encode_callback */, - std::unique_ptr( - overuse_detector_proxy_ = new CpuOveruseDetectorProxy( - stats_proxy))) {} + VideoStreamEncoderUnderTest( + SendStatisticsProxy* stats_proxy, + const VideoSendStream::Config::EncoderSettings& settings) + : VideoStreamEncoder(1 /* number_of_cores */, + stats_proxy, + settings, + nullptr /* pre_encode_callback */, + std::unique_ptr( + overuse_detector_proxy_ = + new CpuOveruseDetectorProxy(stats_proxy))) {} void PostTaskAndWait(bool down, AdaptReason reason) { rtc::Event event(false, false); @@ -115,9 +115,7 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder { // encoder queue is not blocked before we start sending it frames. void WaitUntilTaskQueueIsIdle() { rtc::Event event(false, false); - encoder_queue()->PostTask([&event] { - event.Set(); - }); + encoder_queue()->PostTask([&event] { event.Set(); }); ASSERT_TRUE(event.Wait(5000)); } @@ -159,7 +157,6 @@ class VideoStreamFactory const int framerate_; }; - class AdaptingFrameForwarder : public test::FrameForwarder { public: AdaptingFrameForwarder() : adaptation_enabled_(false) {} @@ -2560,8 +2557,8 @@ TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) { sink_.WaitForEncodedFrame(timestamp_ms); } timestamp_ms += kFrameIntervalMs; - fake_clock_.AdvanceTimeMicros( - kFrameIntervalMs * rtc::kNumMicrosecsPerMillisec); + fake_clock_.AdvanceTimeMicros(kFrameIntervalMs * + rtc::kNumMicrosecsPerMillisec); } // ...and then try to adapt again. video_stream_encoder_->TriggerCpuOveruse(); @@ -2969,9 +2966,8 @@ TEST_F(VideoStreamEncoderTest, AcceptsFullHdAdaptedDownSimulcastFrames) { int width, int height, const VideoEncoderConfig& encoder_config) override { - std::vector streams = - test::CreateVideoStreams(width - width % 4, height - height % 4, - encoder_config); + std::vector streams = test::CreateVideoStreams( + width - width % 4, height - height % 4, encoder_config); for (VideoStream& stream : streams) { stream.num_temporal_layers = num_temporal_layers_; stream.max_framerate = framerate_;