Chromium Code Reviews| 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_; |
|
henrika_webrtc
2016/01/21 08:50:48
Just a question. Can we skip mutable and modify th
tommi
2016/01/21 08:57:29
I think it's better to do it this way and this is
| |
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 bool Sending() const | 420 bool Sending() const |
| 423 { | 421 { |
| 424 return channel_state_.Get().sending; | 422 return channel_state_.Get().sending; |
| 425 } | 423 } |
| 426 bool Receiving() const | 424 bool Receiving() const |
| 427 { | 425 { |
| 428 return channel_state_.Get().receiving; | 426 return channel_state_.Get().receiving; |
| 429 } | 427 } |
| 430 bool ExternalTransport() const | 428 bool ExternalTransport() const |
| 431 { | 429 { |
| 432 CriticalSectionScoped cs(&_callbackCritSect); | 430 rtc::CritScope cs(&_callbackCritSect); |
| 433 return _externalTransport; | 431 return _externalTransport; |
| 434 } | 432 } |
| 435 bool ExternalMixing() const | 433 bool ExternalMixing() const |
| 436 { | 434 { |
| 437 return _externalMixing; | 435 return _externalMixing; |
| 438 } | 436 } |
| 439 RtpRtcp* RtpRtcpModulePtr() const | 437 RtpRtcp* RtpRtcpModulePtr() const |
| 440 { | 438 { |
| 441 return _rtpRtcpModule.get(); | 439 return _rtpRtcpModule.get(); |
| 442 } | 440 } |
| 443 int8_t OutputEnergyLevel() const | 441 int8_t OutputEnergyLevel() const |
| 444 { | 442 { |
| 445 return _outputAudioLevel.Level(); | 443 return _outputAudioLevel.Level(); |
| 446 } | 444 } |
| 447 uint32_t Demultiplex(const AudioFrame& audioFrame); | 445 uint32_t Demultiplex(const AudioFrame& audioFrame); |
| 448 // Demultiplex the data to the channel's |_audioFrame|. The difference | 446 // Demultiplex the data to the channel's |_audioFrame|. The difference |
| 449 // between this method and the overloaded method above is that |audio_data| | 447 // between this method and the overloaded method above is that |audio_data| |
| 450 // does not go through transmit_mixer and APM. | 448 // does not go through transmit_mixer and APM. |
| 451 void Demultiplex(const int16_t* audio_data, | 449 void Demultiplex(const int16_t* audio_data, |
| 452 int sample_rate, | 450 int sample_rate, |
| 453 size_t number_of_frames, | 451 size_t number_of_frames, |
| 454 size_t number_of_channels); | 452 size_t number_of_channels); |
| 455 uint32_t PrepareEncodeAndSend(int mixingFrequency); | 453 uint32_t PrepareEncodeAndSend(int mixingFrequency); |
| 456 uint32_t EncodeAndSend(); | 454 uint32_t EncodeAndSend(); |
| 457 | 455 |
| 458 // Associate to a send channel. | 456 // Associate to a send channel. |
| 459 // Used for obtaining RTT for a receive-only channel. | 457 // Used for obtaining RTT for a receive-only channel. |
| 460 void set_associate_send_channel(const ChannelOwner& channel) { | 458 void set_associate_send_channel(const ChannelOwner& channel) { |
| 461 assert(_channelId != channel.channel()->ChannelId()); | 459 assert(_channelId != channel.channel()->ChannelId()); |
| 462 CriticalSectionScoped lock(assoc_send_channel_lock_.get()); | 460 rtc::CritScope lock(&assoc_send_channel_lock_); |
| 463 associate_send_channel_ = channel; | 461 associate_send_channel_ = channel; |
| 464 } | 462 } |
| 465 | 463 |
| 466 // Disassociate a send channel if it was associated. | 464 // Disassociate a send channel if it was associated. |
| 467 void DisassociateSendChannel(int channel_id); | 465 void DisassociateSendChannel(int channel_id); |
| 468 | 466 |
| 469 protected: | 467 protected: |
| 470 void OnIncomingFractionLoss(int fraction_lost); | 468 void OnIncomingFractionLoss(int fraction_lost); |
| 471 | 469 |
| 472 private: | 470 private: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 486 uint16_t sequenceNumber); | 484 uint16_t sequenceNumber); |
| 487 void RegisterReceiveCodecsToRTPModule(); | 485 void RegisterReceiveCodecsToRTPModule(); |
| 488 | 486 |
| 489 int SetRedPayloadType(int red_payload_type); | 487 int SetRedPayloadType(int red_payload_type); |
| 490 int SetSendRtpHeaderExtension(bool enable, RTPExtensionType type, | 488 int SetSendRtpHeaderExtension(bool enable, RTPExtensionType type, |
| 491 unsigned char id); | 489 unsigned char id); |
| 492 | 490 |
| 493 int32_t GetPlayoutFrequency(); | 491 int32_t GetPlayoutFrequency(); |
| 494 int64_t GetRTT(bool allow_associate_channel) const; | 492 int64_t GetRTT(bool allow_associate_channel) const; |
| 495 | 493 |
| 496 CriticalSectionWrapper& _fileCritSect; | 494 mutable rtc::CriticalSection _fileCritSect; |
| 497 CriticalSectionWrapper& _callbackCritSect; | 495 mutable rtc::CriticalSection _callbackCritSect; |
| 498 CriticalSectionWrapper& volume_settings_critsect_; | 496 mutable rtc::CriticalSection volume_settings_critsect_; |
| 499 uint32_t _instanceId; | 497 uint32_t _instanceId; |
| 500 int32_t _channelId; | 498 int32_t _channelId; |
| 501 | 499 |
| 502 ChannelState channel_state_; | 500 ChannelState channel_state_; |
| 503 | 501 |
| 504 RtcEventLog* const event_log_; | 502 RtcEventLog* const event_log_; |
| 505 | 503 |
| 506 rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_; | 504 rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_; |
| 507 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; | 505 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 508 rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; | 506 rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 536 | 534 |
| 537 // Timestamp of the audio pulled from NetEq. | 535 // Timestamp of the audio pulled from NetEq. |
| 538 uint32_t jitter_buffer_playout_timestamp_; | 536 uint32_t jitter_buffer_playout_timestamp_; |
| 539 uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); | 537 uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); |
| 540 uint32_t playout_timestamp_rtcp_; | 538 uint32_t playout_timestamp_rtcp_; |
| 541 uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); | 539 uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); |
| 542 uint32_t _numberOfDiscardedPackets; | 540 uint32_t _numberOfDiscardedPackets; |
| 543 uint16_t send_sequence_number_; | 541 uint16_t send_sequence_number_; |
| 544 uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; | 542 uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; |
| 545 | 543 |
| 546 rtc::scoped_ptr<CriticalSectionWrapper> ts_stats_lock_; | 544 mutable rtc::CriticalSection ts_stats_lock_; |
| 547 | 545 |
| 548 rtc::scoped_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; | 546 rtc::scoped_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; |
| 549 // The rtp timestamp of the first played out audio frame. | 547 // The rtp timestamp of the first played out audio frame. |
| 550 int64_t capture_start_rtp_time_stamp_; | 548 int64_t capture_start_rtp_time_stamp_; |
| 551 // The capture ntp time (in local timebase) of the first played out audio | 549 // The capture ntp time (in local timebase) of the first played out audio |
| 552 // frame. | 550 // frame. |
| 553 int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_); | 551 int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_); |
| 554 | 552 |
| 555 // uses | 553 // uses |
| 556 Statistics* _engineStatisticsPtr; | 554 Statistics* _engineStatisticsPtr; |
| 557 OutputMixer* _outputMixerPtr; | 555 OutputMixer* _outputMixerPtr; |
| 558 TransmitMixer* _transmitMixerPtr; | 556 TransmitMixer* _transmitMixerPtr; |
| 559 ProcessThread* _moduleProcessThreadPtr; | 557 ProcessThread* _moduleProcessThreadPtr; |
| 560 AudioDeviceModule* _audioDeviceModulePtr; | 558 AudioDeviceModule* _audioDeviceModulePtr; |
| 561 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base | 559 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base |
| 562 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base | 560 rtc::CriticalSection* _callbackCritSectPtr; // owned by base |
| 563 Transport* _transportPtr; // WebRtc socket or external transport | 561 Transport* _transportPtr; // WebRtc socket or external transport |
| 564 RMSLevel rms_level_; | 562 RMSLevel rms_level_; |
| 565 rtc::scoped_ptr<AudioProcessing> rx_audioproc_; // far end AudioProcessing | 563 rtc::scoped_ptr<AudioProcessing> rx_audioproc_; // far end AudioProcessing |
| 566 VoERxVadCallback* _rxVadObserverPtr; | 564 VoERxVadCallback* _rxVadObserverPtr; |
| 567 int32_t _oldVadDecision; | 565 int32_t _oldVadDecision; |
| 568 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise | 566 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise |
| 569 // VoEBase | 567 // VoEBase |
| 570 bool _externalMixing; | 568 bool _externalMixing; |
| 571 bool _mixFileWithMicrophone; | 569 bool _mixFileWithMicrophone; |
| 572 // VoEVolumeControl | 570 // VoEVolumeControl |
| 573 bool _mute; | 571 bool _mute; |
| 574 float _panLeft; | 572 float _panLeft; |
| 575 float _panRight; | 573 float _panRight; |
| 576 float _outputGain; | 574 float _outputGain; |
| 577 // VoEDtmf | 575 // VoEDtmf |
| 578 bool _playOutbandDtmfEvent; | 576 bool _playOutbandDtmfEvent; |
| 579 bool _playInbandDtmfEvent; | 577 bool _playInbandDtmfEvent; |
| 580 // VoeRTP_RTCP | 578 // VoeRTP_RTCP |
| 581 uint32_t _lastLocalTimeStamp; | 579 uint32_t _lastLocalTimeStamp; |
| 582 int8_t _lastPayloadType; | 580 int8_t _lastPayloadType; |
| 583 bool _includeAudioLevelIndication; | 581 bool _includeAudioLevelIndication; |
| 584 // VoENetwork | 582 // VoENetwork |
| 585 AudioFrame::SpeechType _outputSpeechType; | 583 AudioFrame::SpeechType _outputSpeechType; |
| 586 // VoEVideoSync | 584 // VoEVideoSync |
| 587 rtc::scoped_ptr<CriticalSectionWrapper> video_sync_lock_; | 585 mutable rtc::CriticalSection video_sync_lock_; |
| 588 uint32_t _average_jitter_buffer_delay_us GUARDED_BY(video_sync_lock_); | 586 uint32_t _average_jitter_buffer_delay_us GUARDED_BY(video_sync_lock_); |
| 589 uint32_t _previousTimestamp; | 587 uint32_t _previousTimestamp; |
| 590 uint16_t _recPacketDelayMs GUARDED_BY(video_sync_lock_); | 588 uint16_t _recPacketDelayMs GUARDED_BY(video_sync_lock_); |
| 591 // VoEAudioProcessing | 589 // VoEAudioProcessing |
| 592 bool _RxVadDetection; | 590 bool _RxVadDetection; |
| 593 bool _rxAgcIsEnabled; | 591 bool _rxAgcIsEnabled; |
| 594 bool _rxNsIsEnabled; | 592 bool _rxNsIsEnabled; |
| 595 bool restored_packet_in_use_; | 593 bool restored_packet_in_use_; |
| 596 // RtcpBandwidthObserver | 594 // RtcpBandwidthObserver |
| 597 rtc::scoped_ptr<VoERtcpObserver> rtcp_observer_; | 595 rtc::scoped_ptr<VoERtcpObserver> rtcp_observer_; |
| 598 rtc::scoped_ptr<NetworkPredictor> network_predictor_; | 596 rtc::scoped_ptr<NetworkPredictor> network_predictor_; |
| 599 // An associated send channel. | 597 // An associated send channel. |
| 600 rtc::scoped_ptr<CriticalSectionWrapper> assoc_send_channel_lock_; | 598 mutable rtc::CriticalSection assoc_send_channel_lock_; |
| 601 ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_); | 599 ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_); |
| 602 | 600 |
| 603 bool pacing_enabled_; | 601 bool pacing_enabled_; |
| 604 PacketRouter* packet_router_ = nullptr; | 602 PacketRouter* packet_router_ = nullptr; |
| 605 rtc::scoped_ptr<TransportFeedbackProxy> feedback_observer_proxy_; | 603 rtc::scoped_ptr<TransportFeedbackProxy> feedback_observer_proxy_; |
| 606 rtc::scoped_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_; | 604 rtc::scoped_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_; |
| 607 rtc::scoped_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_; | 605 rtc::scoped_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_; |
| 608 }; | 606 }; |
| 609 | 607 |
| 610 } // namespace voe | 608 } // namespace voe |
| 611 } // namespace webrtc | 609 } // namespace webrtc |
| 612 | 610 |
| 613 #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_ | 611 #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_ |
| OLD | NEW |