| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef VOICE_ENGINE_CHANNEL_H_ | 11 #ifndef VOICE_ENGINE_CHANNEL_H_ |
| 12 #define VOICE_ENGINE_CHANNEL_H_ | 12 #define VOICE_ENGINE_CHANNEL_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "api/audio/audio_mixer.h" | 16 #include "api/audio/audio_mixer.h" |
| 17 #include "api/audio_codecs/audio_encoder.h" | 17 #include "api/audio_codecs/audio_encoder.h" |
| 18 #include "api/call/audio_sink.h" | 18 #include "api/call/audio_sink.h" |
| 19 #include "api/call/transport.h" | 19 #include "api/call/transport.h" |
| 20 #include "api/optional.h" | 20 #include "api/optional.h" |
| 21 #include "common_audio/resampler/include/push_resampler.h" | 21 #include "common_audio/resampler/include/push_resampler.h" |
| 22 #include "common_types.h" // NOLINT(build/include) | 22 #include "common_types.h" // NOLINT(build/include) |
| 23 #include "modules/audio_coding/acm2/codec_manager.h" | 23 #include "modules/audio_coding/acm2/codec_manager.h" |
| 24 #include "modules/audio_coding/acm2/rent_a_codec.h" | 24 #include "modules/audio_coding/acm2/rent_a_codec.h" |
| 25 #include "modules/audio_coding/include/audio_coding_module.h" | 25 #include "modules/audio_coding/include/audio_coding_module.h" |
| 26 #include "modules/audio_conference_mixer/include/audio_conference_mixer_defines.
h" | |
| 27 #include "modules/audio_processing/rms_level.h" | 26 #include "modules/audio_processing/rms_level.h" |
| 28 #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" | 27 #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" |
| 29 #include "modules/rtp_rtcp/include/rtp_header_parser.h" | 28 #include "modules/rtp_rtcp/include/rtp_header_parser.h" |
| 30 #include "modules/rtp_rtcp/include/rtp_receiver.h" | 29 #include "modules/rtp_rtcp/include/rtp_receiver.h" |
| 31 #include "modules/rtp_rtcp/include/rtp_rtcp.h" | 30 #include "modules/rtp_rtcp/include/rtp_rtcp.h" |
| 32 #include "rtc_base/criticalsection.h" | 31 #include "rtc_base/criticalsection.h" |
| 33 #include "rtc_base/event.h" | 32 #include "rtc_base/event.h" |
| 34 #include "rtc_base/thread_checker.h" | 33 #include "rtc_base/thread_checker.h" |
| 35 #include "voice_engine/audio_level.h" | 34 #include "voice_engine/audio_level.h" |
| 36 #include "voice_engine/include/voe_base.h" | 35 #include "voice_engine/include/voe_base.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 uint8_t fraction_lost; | 81 uint8_t fraction_lost; |
| 83 uint32_t cumulative_num_packets_lost; | 82 uint32_t cumulative_num_packets_lost; |
| 84 uint32_t extended_highest_sequence_number; | 83 uint32_t extended_highest_sequence_number; |
| 85 uint32_t interarrival_jitter; | 84 uint32_t interarrival_jitter; |
| 86 uint32_t last_SR_timestamp; | 85 uint32_t last_SR_timestamp; |
| 87 uint32_t delay_since_last_SR; | 86 uint32_t delay_since_last_SR; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 namespace voe { | 89 namespace voe { |
| 91 | 90 |
| 92 class OutputMixer; | |
| 93 class RtcEventLogProxy; | 91 class RtcEventLogProxy; |
| 94 class RtcpRttStatsProxy; | 92 class RtcpRttStatsProxy; |
| 95 class RtpPacketSenderProxy; | 93 class RtpPacketSenderProxy; |
| 96 class Statistics; | 94 class Statistics; |
| 97 class TransportFeedbackProxy; | 95 class TransportFeedbackProxy; |
| 98 class TransportSequenceNumberProxy; | 96 class TransportSequenceNumberProxy; |
| 99 class VoERtcpObserver; | 97 class VoERtcpObserver; |
| 100 | 98 |
| 101 // Helper class to simplify locking scheme for members that are accessed from | 99 // Helper class to simplify locking scheme for members that are accessed from |
| 102 // multiple threads. | 100 // multiple threads. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 rtc::CriticalSection lock_; | 135 rtc::CriticalSection lock_; |
| 138 State state_; | 136 State state_; |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 class Channel | 139 class Channel |
| 142 : public RtpData, | 140 : public RtpData, |
| 143 public RtpFeedback, | 141 public RtpFeedback, |
| 144 public Transport, | 142 public Transport, |
| 145 public AudioPacketizationCallback, // receive encoded packets from the | 143 public AudioPacketizationCallback, // receive encoded packets from the |
| 146 // ACM | 144 // ACM |
| 147 public MixerParticipant, // supplies output mixer with audio frames | |
| 148 public OverheadObserver { | 145 public OverheadObserver { |
| 149 public: | 146 public: |
| 150 friend class VoERtcpObserver; | 147 friend class VoERtcpObserver; |
| 151 | 148 |
| 152 enum { KNumSocketThreads = 1 }; | 149 enum { KNumSocketThreads = 1 }; |
| 153 enum { KNumberOfSocketBuffers = 8 }; | 150 enum { KNumberOfSocketBuffers = 8 }; |
| 154 virtual ~Channel(); | 151 virtual ~Channel(); |
| 155 static int32_t CreateChannel(Channel*& channel, | 152 static int32_t CreateChannel(Channel*& channel, |
| 156 int32_t channelId, | 153 int32_t channelId, |
| 157 uint32_t instanceId, | 154 uint32_t instanceId, |
| 158 const VoEBase::ChannelConfig& config); | 155 const VoEBase::ChannelConfig& config); |
| 159 Channel(int32_t channelId, | 156 Channel(int32_t channelId, |
| 160 uint32_t instanceId, | 157 uint32_t instanceId, |
| 161 const VoEBase::ChannelConfig& config); | 158 const VoEBase::ChannelConfig& config); |
| 162 int32_t Init(); | 159 int32_t Init(); |
| 163 void Terminate(); | 160 void Terminate(); |
| 164 int32_t SetEngineInformation(Statistics& engineStatistics, | 161 int32_t SetEngineInformation(Statistics& engineStatistics, |
| 165 OutputMixer& outputMixer, | |
| 166 ProcessThread& moduleProcessThread, | 162 ProcessThread& moduleProcessThread, |
| 167 AudioDeviceModule& audioDeviceModule, | 163 AudioDeviceModule& audioDeviceModule, |
| 168 VoiceEngineObserver* voiceEngineObserver, | 164 VoiceEngineObserver* voiceEngineObserver, |
| 169 rtc::CriticalSection* callbackCritSect, | 165 rtc::CriticalSection* callbackCritSect, |
| 170 rtc::TaskQueue* encoder_queue); | 166 rtc::TaskQueue* encoder_queue); |
| 171 | 167 |
| 172 void SetSink(std::unique_ptr<AudioSinkInterface> sink); | 168 void SetSink(std::unique_ptr<AudioSinkInterface> sink); |
| 173 | 169 |
| 174 // TODO(ossu): Don't use! It's only here to confirm that the decoder factory | 170 // TODO(ossu): Don't use! It's only here to confirm that the decoder factory |
| 175 // passed into AudioReceiveStream is the same as the one set when creating the | 171 // passed into AudioReceiveStream is the same as the one set when creating the |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 uint32_t rate) override; | 272 uint32_t rate) override; |
| 277 void OnIncomingSSRCChanged(uint32_t ssrc) override; | 273 void OnIncomingSSRCChanged(uint32_t ssrc) override; |
| 278 void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override; | 274 void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override; |
| 279 | 275 |
| 280 // From Transport (called by the RTP/RTCP module) | 276 // From Transport (called by the RTP/RTCP module) |
| 281 bool SendRtp(const uint8_t* data, | 277 bool SendRtp(const uint8_t* data, |
| 282 size_t len, | 278 size_t len, |
| 283 const PacketOptions& packet_options) override; | 279 const PacketOptions& packet_options) override; |
| 284 bool SendRtcp(const uint8_t* data, size_t len) override; | 280 bool SendRtcp(const uint8_t* data, size_t len) override; |
| 285 | 281 |
| 286 // From MixerParticipant | |
| 287 MixerParticipant::AudioFrameInfo GetAudioFrameWithMuted( | |
| 288 int32_t id, | |
| 289 AudioFrame* audioFrame) override; | |
| 290 int32_t NeededFrequency(int32_t id) const override; | |
| 291 | |
| 292 // From AudioMixer::Source. | 282 // From AudioMixer::Source. |
| 293 AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( | 283 AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( |
| 294 int sample_rate_hz, | 284 int sample_rate_hz, |
| 295 AudioFrame* audio_frame); | 285 AudioFrame* audio_frame); |
| 296 | 286 |
| 287 int PreferredSampleRate() const; |
| 288 |
| 297 uint32_t InstanceId() const { return _instanceId; } | 289 uint32_t InstanceId() const { return _instanceId; } |
| 298 int32_t ChannelId() const { return _channelId; } | 290 int32_t ChannelId() const { return _channelId; } |
| 299 bool Playing() const { return channel_state_.Get().playing; } | 291 bool Playing() const { return channel_state_.Get().playing; } |
| 300 bool Sending() const { return channel_state_.Get().sending; } | 292 bool Sending() const { return channel_state_.Get().sending; } |
| 301 bool ExternalTransport() const { | 293 bool ExternalTransport() const { |
| 302 rtc::CritScope cs(&_callbackCritSect); | 294 rtc::CritScope cs(&_callbackCritSect); |
| 303 return _externalTransport; | 295 return _externalTransport; |
| 304 } | 296 } |
| 305 RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); } | 297 RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); } |
| 306 int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); } | 298 int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 418 |
| 427 std::unique_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; | 419 std::unique_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; |
| 428 // The rtp timestamp of the first played out audio frame. | 420 // The rtp timestamp of the first played out audio frame. |
| 429 int64_t capture_start_rtp_time_stamp_; | 421 int64_t capture_start_rtp_time_stamp_; |
| 430 // The capture ntp time (in local timebase) of the first played out audio | 422 // The capture ntp time (in local timebase) of the first played out audio |
| 431 // frame. | 423 // frame. |
| 432 int64_t capture_start_ntp_time_ms_ RTC_GUARDED_BY(ts_stats_lock_); | 424 int64_t capture_start_ntp_time_ms_ RTC_GUARDED_BY(ts_stats_lock_); |
| 433 | 425 |
| 434 // uses | 426 // uses |
| 435 Statistics* _engineStatisticsPtr; | 427 Statistics* _engineStatisticsPtr; |
| 436 OutputMixer* _outputMixerPtr; | |
| 437 ProcessThread* _moduleProcessThreadPtr; | 428 ProcessThread* _moduleProcessThreadPtr; |
| 438 AudioDeviceModule* _audioDeviceModulePtr; | 429 AudioDeviceModule* _audioDeviceModulePtr; |
| 439 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base | 430 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base |
| 440 rtc::CriticalSection* _callbackCritSectPtr; // owned by base | 431 rtc::CriticalSection* _callbackCritSectPtr; // owned by base |
| 441 Transport* _transportPtr; // WebRtc socket or external transport | 432 Transport* _transportPtr; // WebRtc socket or external transport |
| 442 RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_); | 433 RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_); |
| 443 bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_); | 434 bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_); |
| 444 bool previous_frame_muted_ RTC_ACCESS_ON(encoder_queue_); | 435 bool previous_frame_muted_ RTC_ACCESS_ON(encoder_queue_); |
| 445 float _outputGain RTC_GUARDED_BY(volume_settings_critsect_); | 436 float _outputGain RTC_GUARDED_BY(volume_settings_critsect_); |
| 446 // VoeRTP_RTCP | 437 // VoeRTP_RTCP |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 470 |
| 480 bool encoder_queue_is_active_ RTC_GUARDED_BY(encoder_queue_lock_) = false; | 471 bool encoder_queue_is_active_ RTC_GUARDED_BY(encoder_queue_lock_) = false; |
| 481 | 472 |
| 482 rtc::TaskQueue* encoder_queue_ = nullptr; | 473 rtc::TaskQueue* encoder_queue_ = nullptr; |
| 483 }; | 474 }; |
| 484 | 475 |
| 485 } // namespace voe | 476 } // namespace voe |
| 486 } // namespace webrtc | 477 } // namespace webrtc |
| 487 | 478 |
| 488 #endif // VOICE_ENGINE_CHANNEL_H_ | 479 #endif // VOICE_ENGINE_CHANNEL_H_ |
| OLD | NEW |