| 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 namespace rtc { | 41 namespace rtc { |
| 42 | 42 |
| 43 class TimestampWrapAroundHandler; | 43 class TimestampWrapAroundHandler; |
| 44 } | 44 } |
| 45 | 45 |
| 46 namespace webrtc { | 46 namespace webrtc { |
| 47 | 47 |
| 48 class AudioDeviceModule; | 48 class AudioDeviceModule; |
| 49 class Config; | 49 class Config; |
| 50 class CriticalSectionWrapper; | |
| 51 class FileWrapper; | 50 class FileWrapper; |
| 52 class PacketRouter; | 51 class PacketRouter; |
| 53 class ProcessThread; | 52 class ProcessThread; |
| 54 class ReceiveStatistics; | 53 class ReceiveStatistics; |
| 55 class RemoteNtpTimeEstimator; | 54 class RemoteNtpTimeEstimator; |
| 56 class RtcEventLog; | 55 class RtcEventLog; |
| 57 class RTPPayloadRegistry; | 56 class RTPPayloadRegistry; |
| 58 class RtpReceiver; | 57 class RtpReceiver; |
| 59 class RTPReceiverAudio; | 58 class RTPReceiverAudio; |
| 60 class RtpRtcp; | 59 class RtpRtcp; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 95 |
| 97 bool rx_apm_is_enabled; | 96 bool rx_apm_is_enabled; |
| 98 bool input_external_media; | 97 bool input_external_media; |
| 99 bool output_file_playing; | 98 bool output_file_playing; |
| 100 bool input_file_playing; | 99 bool input_file_playing; |
| 101 bool playing; | 100 bool playing; |
| 102 bool sending; | 101 bool sending; |
| 103 bool receiving; | 102 bool receiving; |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 ChannelState() : lock_(CriticalSectionWrapper::CreateCriticalSection()) { | 105 ChannelState() {} |
| 107 } | |
| 108 virtual ~ChannelState() {} | 106 virtual ~ChannelState() {} |
| 109 | 107 |
| 110 void Reset() { | 108 void Reset() { |
| 111 CriticalSectionScoped lock(lock_.get()); | 109 rtc::CritScope lock(&lock_); |
| 112 state_ = State(); | 110 state_ = State(); |
| 113 } | 111 } |
| 114 | 112 |
| 115 State Get() const { | 113 State Get() const { |
| 116 CriticalSectionScoped lock(lock_.get()); | 114 rtc::CritScope lock(&lock_); |
| 117 return state_; | 115 return state_; |
| 118 } | 116 } |
| 119 | 117 |
| 120 void SetRxApmIsEnabled(bool enable) { | 118 void SetRxApmIsEnabled(bool enable) { |
| 121 CriticalSectionScoped lock(lock_.get()); | 119 rtc::CritScope lock(&lock_); |
| 122 state_.rx_apm_is_enabled = enable; | 120 state_.rx_apm_is_enabled = enable; |
| 123 } | 121 } |
| 124 | 122 |
| 125 void SetInputExternalMedia(bool enable) { | 123 void SetInputExternalMedia(bool enable) { |
| 126 CriticalSectionScoped lock(lock_.get()); | 124 rtc::CritScope lock(&lock_); |
| 127 state_.input_external_media = enable; | 125 state_.input_external_media = enable; |
| 128 } | 126 } |
| 129 | 127 |
| 130 void SetOutputFilePlaying(bool enable) { | 128 void SetOutputFilePlaying(bool enable) { |
| 131 CriticalSectionScoped lock(lock_.get()); | 129 rtc::CritScope lock(&lock_); |
| 132 state_.output_file_playing = enable; | 130 state_.output_file_playing = enable; |
| 133 } | 131 } |
| 134 | 132 |
| 135 void SetInputFilePlaying(bool enable) { | 133 void SetInputFilePlaying(bool enable) { |
| 136 CriticalSectionScoped lock(lock_.get()); | 134 rtc::CritScope lock(&lock_); |
| 137 state_.input_file_playing = enable; | 135 state_.input_file_playing = enable; |
| 138 } | 136 } |
| 139 | 137 |
| 140 void SetPlaying(bool enable) { | 138 void SetPlaying(bool enable) { |
| 141 CriticalSectionScoped lock(lock_.get()); | 139 rtc::CritScope lock(&lock_); |
| 142 state_.playing = enable; | 140 state_.playing = enable; |
| 143 } | 141 } |
| 144 | 142 |
| 145 void SetSending(bool enable) { | 143 void SetSending(bool enable) { |
| 146 CriticalSectionScoped lock(lock_.get()); | 144 rtc::CritScope lock(&lock_); |
| 147 state_.sending = enable; | 145 state_.sending = enable; |
| 148 } | 146 } |
| 149 | 147 |
| 150 void SetReceiving(bool enable) { | 148 void SetReceiving(bool enable) { |
| 151 CriticalSectionScoped lock(lock_.get()); | 149 rtc::CritScope lock(&lock_); |
| 152 state_.receiving = enable; | 150 state_.receiving = enable; |
| 153 } | 151 } |
| 154 | 152 |
| 155 private: | 153 private: |
| 156 rtc::scoped_ptr<CriticalSectionWrapper> lock_; | 154 mutable rtc::CriticalSection lock_; |
| 157 State state_; | 155 State state_; |
| 158 }; | 156 }; |
| 159 | 157 |
| 160 class Channel: | 158 class Channel: |
| 161 public RtpData, | 159 public RtpData, |
| 162 public RtpFeedback, | 160 public RtpFeedback, |
| 163 public FileCallback, // receiving notification from file player & recorder | 161 public FileCallback, // receiving notification from file player & recorder |
| 164 public Transport, | 162 public Transport, |
| 165 public RtpAudioFeedback, | 163 public RtpAudioFeedback, |
| 166 public AudioPacketizationCallback, // receive encoded packets from the ACM | 164 public AudioPacketizationCallback, // receive encoded packets from the ACM |
| (...skipping 16 matching lines...) Expand all Loading... |
| 183 RtcEventLog* const event_log, | 181 RtcEventLog* const event_log, |
| 184 const Config& config); | 182 const Config& config); |
| 185 int32_t Init(); | 183 int32_t Init(); |
| 186 int32_t SetEngineInformation( | 184 int32_t SetEngineInformation( |
| 187 Statistics& engineStatistics, | 185 Statistics& engineStatistics, |
| 188 OutputMixer& outputMixer, | 186 OutputMixer& outputMixer, |
| 189 TransmitMixer& transmitMixer, | 187 TransmitMixer& transmitMixer, |
| 190 ProcessThread& moduleProcessThread, | 188 ProcessThread& moduleProcessThread, |
| 191 AudioDeviceModule& audioDeviceModule, | 189 AudioDeviceModule& audioDeviceModule, |
| 192 VoiceEngineObserver* voiceEngineObserver, | 190 VoiceEngineObserver* voiceEngineObserver, |
| 193 CriticalSectionWrapper* callbackCritSect); | 191 rtc::CriticalSection* callbackCritSect); |
| 194 int32_t UpdateLocalTimeStamp(); | 192 int32_t UpdateLocalTimeStamp(); |
| 195 | 193 |
| 196 void SetSink(rtc::scoped_ptr<AudioSinkInterface> sink); | 194 void SetSink(rtc::scoped_ptr<AudioSinkInterface> sink); |
| 197 | 195 |
| 198 // API methods | 196 // API methods |
| 199 | 197 |
| 200 // VoEBase | 198 // VoEBase |
| 201 int32_t StartPlayout(); | 199 int32_t StartPlayout(); |
| 202 int32_t StopPlayout(); | 200 int32_t StopPlayout(); |
| 203 int32_t StartSend(); | 201 int32_t StartSend(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 bool Sending() const | 421 bool Sending() const |
| 424 { | 422 { |
| 425 return channel_state_.Get().sending; | 423 return channel_state_.Get().sending; |
| 426 } | 424 } |
| 427 bool Receiving() const | 425 bool Receiving() const |
| 428 { | 426 { |
| 429 return channel_state_.Get().receiving; | 427 return channel_state_.Get().receiving; |
| 430 } | 428 } |
| 431 bool ExternalTransport() const | 429 bool ExternalTransport() const |
| 432 { | 430 { |
| 433 CriticalSectionScoped cs(&_callbackCritSect); | 431 rtc::CritScope cs(&_callbackCritSect); |
| 434 return _externalTransport; | 432 return _externalTransport; |
| 435 } | 433 } |
| 436 bool ExternalMixing() const | 434 bool ExternalMixing() const |
| 437 { | 435 { |
| 438 return _externalMixing; | 436 return _externalMixing; |
| 439 } | 437 } |
| 440 RtpRtcp* RtpRtcpModulePtr() const | 438 RtpRtcp* RtpRtcpModulePtr() const |
| 441 { | 439 { |
| 442 return _rtpRtcpModule.get(); | 440 return _rtpRtcpModule.get(); |
| 443 } | 441 } |
| 444 int8_t OutputEnergyLevel() const | 442 int8_t OutputEnergyLevel() const |
| 445 { | 443 { |
| 446 return _outputAudioLevel.Level(); | 444 return _outputAudioLevel.Level(); |
| 447 } | 445 } |
| 448 uint32_t Demultiplex(const AudioFrame& audioFrame); | 446 uint32_t Demultiplex(const AudioFrame& audioFrame); |
| 449 // Demultiplex the data to the channel's |_audioFrame|. The difference | 447 // Demultiplex the data to the channel's |_audioFrame|. The difference |
| 450 // between this method and the overloaded method above is that |audio_data| | 448 // between this method and the overloaded method above is that |audio_data| |
| 451 // does not go through transmit_mixer and APM. | 449 // does not go through transmit_mixer and APM. |
| 452 void Demultiplex(const int16_t* audio_data, | 450 void Demultiplex(const int16_t* audio_data, |
| 453 int sample_rate, | 451 int sample_rate, |
| 454 size_t number_of_frames, | 452 size_t number_of_frames, |
| 455 size_t number_of_channels); | 453 size_t number_of_channels); |
| 456 uint32_t PrepareEncodeAndSend(int mixingFrequency); | 454 uint32_t PrepareEncodeAndSend(int mixingFrequency); |
| 457 uint32_t EncodeAndSend(); | 455 uint32_t EncodeAndSend(); |
| 458 | 456 |
| 459 // Associate to a send channel. | 457 // Associate to a send channel. |
| 460 // Used for obtaining RTT for a receive-only channel. | 458 // Used for obtaining RTT for a receive-only channel. |
| 461 void set_associate_send_channel(const ChannelOwner& channel) { | 459 void set_associate_send_channel(const ChannelOwner& channel) { |
| 462 assert(_channelId != channel.channel()->ChannelId()); | 460 assert(_channelId != channel.channel()->ChannelId()); |
| 463 CriticalSectionScoped lock(assoc_send_channel_lock_.get()); | 461 rtc::CritScope lock(&assoc_send_channel_lock_); |
| 464 associate_send_channel_ = channel; | 462 associate_send_channel_ = channel; |
| 465 } | 463 } |
| 466 | 464 |
| 467 // Disassociate a send channel if it was associated. | 465 // Disassociate a send channel if it was associated. |
| 468 void DisassociateSendChannel(int channel_id); | 466 void DisassociateSendChannel(int channel_id); |
| 469 | 467 |
| 470 protected: | 468 protected: |
| 471 void OnIncomingFractionLoss(int fraction_lost); | 469 void OnIncomingFractionLoss(int fraction_lost); |
| 472 | 470 |
| 473 private: | 471 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 487 uint16_t sequenceNumber); | 485 uint16_t sequenceNumber); |
| 488 void RegisterReceiveCodecsToRTPModule(); | 486 void RegisterReceiveCodecsToRTPModule(); |
| 489 | 487 |
| 490 int SetRedPayloadType(int red_payload_type); | 488 int SetRedPayloadType(int red_payload_type); |
| 491 int SetSendRtpHeaderExtension(bool enable, RTPExtensionType type, | 489 int SetSendRtpHeaderExtension(bool enable, RTPExtensionType type, |
| 492 unsigned char id); | 490 unsigned char id); |
| 493 | 491 |
| 494 int32_t GetPlayoutFrequency(); | 492 int32_t GetPlayoutFrequency(); |
| 495 int64_t GetRTT(bool allow_associate_channel) const; | 493 int64_t GetRTT(bool allow_associate_channel) const; |
| 496 | 494 |
| 497 CriticalSectionWrapper& _fileCritSect; | 495 mutable rtc::CriticalSection _fileCritSect; |
| 498 CriticalSectionWrapper& _callbackCritSect; | 496 mutable rtc::CriticalSection _callbackCritSect; |
| 499 CriticalSectionWrapper& volume_settings_critsect_; | 497 mutable rtc::CriticalSection volume_settings_critsect_; |
| 500 uint32_t _instanceId; | 498 uint32_t _instanceId; |
| 501 int32_t _channelId; | 499 int32_t _channelId; |
| 502 | 500 |
| 503 ChannelState channel_state_; | 501 ChannelState channel_state_; |
| 504 | 502 |
| 505 RtcEventLog* const event_log_; | 503 RtcEventLog* const event_log_; |
| 506 | 504 |
| 507 rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_; | 505 rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_; |
| 508 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; | 506 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 509 rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; | 507 rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 537 | 535 |
| 538 // Timestamp of the audio pulled from NetEq. | 536 // Timestamp of the audio pulled from NetEq. |
| 539 uint32_t jitter_buffer_playout_timestamp_; | 537 uint32_t jitter_buffer_playout_timestamp_; |
| 540 uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); | 538 uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); |
| 541 uint32_t playout_timestamp_rtcp_; | 539 uint32_t playout_timestamp_rtcp_; |
| 542 uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); | 540 uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); |
| 543 uint32_t _numberOfDiscardedPackets; | 541 uint32_t _numberOfDiscardedPackets; |
| 544 uint16_t send_sequence_number_; | 542 uint16_t send_sequence_number_; |
| 545 uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; | 543 uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; |
| 546 | 544 |
| 547 rtc::scoped_ptr<CriticalSectionWrapper> ts_stats_lock_; | 545 mutable rtc::CriticalSection ts_stats_lock_; |
| 548 | 546 |
| 549 rtc::scoped_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; | 547 rtc::scoped_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; |
| 550 // The rtp timestamp of the first played out audio frame. | 548 // The rtp timestamp of the first played out audio frame. |
| 551 int64_t capture_start_rtp_time_stamp_; | 549 int64_t capture_start_rtp_time_stamp_; |
| 552 // The capture ntp time (in local timebase) of the first played out audio | 550 // The capture ntp time (in local timebase) of the first played out audio |
| 553 // frame. | 551 // frame. |
| 554 int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_); | 552 int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_); |
| 555 | 553 |
| 556 // uses | 554 // uses |
| 557 Statistics* _engineStatisticsPtr; | 555 Statistics* _engineStatisticsPtr; |
| 558 OutputMixer* _outputMixerPtr; | 556 OutputMixer* _outputMixerPtr; |
| 559 TransmitMixer* _transmitMixerPtr; | 557 TransmitMixer* _transmitMixerPtr; |
| 560 ProcessThread* _moduleProcessThreadPtr; | 558 ProcessThread* _moduleProcessThreadPtr; |
| 561 AudioDeviceModule* _audioDeviceModulePtr; | 559 AudioDeviceModule* _audioDeviceModulePtr; |
| 562 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base | 560 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base |
| 563 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base | 561 rtc::CriticalSection* _callbackCritSectPtr; // owned by base |
| 564 Transport* _transportPtr; // WebRtc socket or external transport | 562 Transport* _transportPtr; // WebRtc socket or external transport |
| 565 RMSLevel rms_level_; | 563 RMSLevel rms_level_; |
| 566 rtc::scoped_ptr<AudioProcessing> rx_audioproc_; // far end AudioProcessing | 564 rtc::scoped_ptr<AudioProcessing> rx_audioproc_; // far end AudioProcessing |
| 567 VoERxVadCallback* _rxVadObserverPtr; | 565 VoERxVadCallback* _rxVadObserverPtr; |
| 568 int32_t _oldVadDecision; | 566 int32_t _oldVadDecision; |
| 569 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise | 567 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise |
| 570 // VoEBase | 568 // VoEBase |
| 571 bool _externalMixing; | 569 bool _externalMixing; |
| 572 bool _mixFileWithMicrophone; | 570 bool _mixFileWithMicrophone; |
| 573 // VoEVolumeControl | 571 // VoEVolumeControl |
| 574 bool _mute; | 572 bool _mute; |
| 575 float _panLeft; | 573 float _panLeft; |
| 576 float _panRight; | 574 float _panRight; |
| 577 float _outputGain; | 575 float _outputGain; |
| 578 // VoEDtmf | 576 // VoEDtmf |
| 579 bool _playOutbandDtmfEvent; | 577 bool _playOutbandDtmfEvent; |
| 580 bool _playInbandDtmfEvent; | 578 bool _playInbandDtmfEvent; |
| 581 // VoeRTP_RTCP | 579 // VoeRTP_RTCP |
| 582 uint32_t _lastLocalTimeStamp; | 580 uint32_t _lastLocalTimeStamp; |
| 583 int8_t _lastPayloadType; | 581 int8_t _lastPayloadType; |
| 584 bool _includeAudioLevelIndication; | 582 bool _includeAudioLevelIndication; |
| 585 // VoENetwork | 583 // VoENetwork |
| 586 AudioFrame::SpeechType _outputSpeechType; | 584 AudioFrame::SpeechType _outputSpeechType; |
| 587 // VoEVideoSync | 585 // VoEVideoSync |
| 588 rtc::scoped_ptr<CriticalSectionWrapper> video_sync_lock_; | 586 mutable rtc::CriticalSection video_sync_lock_; |
| 589 uint32_t _average_jitter_buffer_delay_us GUARDED_BY(video_sync_lock_); | 587 uint32_t _average_jitter_buffer_delay_us GUARDED_BY(video_sync_lock_); |
| 590 uint32_t _previousTimestamp; | 588 uint32_t _previousTimestamp; |
| 591 uint16_t _recPacketDelayMs GUARDED_BY(video_sync_lock_); | 589 uint16_t _recPacketDelayMs GUARDED_BY(video_sync_lock_); |
| 592 // VoEAudioProcessing | 590 // VoEAudioProcessing |
| 593 bool _RxVadDetection; | 591 bool _RxVadDetection; |
| 594 bool _rxAgcIsEnabled; | 592 bool _rxAgcIsEnabled; |
| 595 bool _rxNsIsEnabled; | 593 bool _rxNsIsEnabled; |
| 596 bool restored_packet_in_use_; | 594 bool restored_packet_in_use_; |
| 597 // RtcpBandwidthObserver | 595 // RtcpBandwidthObserver |
| 598 rtc::scoped_ptr<VoERtcpObserver> rtcp_observer_; | 596 rtc::scoped_ptr<VoERtcpObserver> rtcp_observer_; |
| 599 rtc::scoped_ptr<NetworkPredictor> network_predictor_; | 597 rtc::scoped_ptr<NetworkPredictor> network_predictor_; |
| 600 // An associated send channel. | 598 // An associated send channel. |
| 601 rtc::scoped_ptr<CriticalSectionWrapper> assoc_send_channel_lock_; | 599 mutable rtc::CriticalSection assoc_send_channel_lock_; |
| 602 ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_); | 600 ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_); |
| 603 | 601 |
| 604 bool pacing_enabled_; | 602 bool pacing_enabled_; |
| 605 PacketRouter* packet_router_ = nullptr; | 603 PacketRouter* packet_router_ = nullptr; |
| 606 rtc::scoped_ptr<TransportFeedbackProxy> feedback_observer_proxy_; | 604 rtc::scoped_ptr<TransportFeedbackProxy> feedback_observer_proxy_; |
| 607 rtc::scoped_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_; | 605 rtc::scoped_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_; |
| 608 rtc::scoped_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_; | 606 rtc::scoped_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_; |
| 609 }; | 607 }; |
| 610 | 608 |
| 611 } // namespace voe | 609 } // namespace voe |
| 612 } // namespace webrtc | 610 } // namespace webrtc |
| 613 | 611 |
| 614 #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_ | 612 #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_ |
| OLD | NEW |