| 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 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2718 // Avoid posting any new tasks if sending was already stopped in StopSend(). | 2718 // Avoid posting any new tasks if sending was already stopped in StopSend(). |
| 2719 rtc::CritScope cs(&encoder_queue_lock_); | 2719 rtc::CritScope cs(&encoder_queue_lock_); |
| 2720 if (!encoder_queue_is_active_) { | 2720 if (!encoder_queue_is_active_) { |
| 2721 return; | 2721 return; |
| 2722 } | 2722 } |
| 2723 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); | 2723 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); |
| 2724 // TODO(henrika): try to avoid copying by moving ownership of audio frame | 2724 // TODO(henrika): try to avoid copying by moving ownership of audio frame |
| 2725 // either into pool of frames or into the task itself. | 2725 // either into pool of frames or into the task itself. |
| 2726 audio_frame->CopyFrom(audio_input); | 2726 audio_frame->CopyFrom(audio_input); |
| 2727 audio_frame->id_ = ChannelId(); | 2727 audio_frame->id_ = ChannelId(); |
| 2728 // Profile time between when the audio frame is added to the task queue (t0) |
| 2729 // and when the task is actually executed (t1). Goal is to keep track of |
| 2730 // unwanted extra latency added by the queue. |
| 2731 audio_frame->UpdateProfileTime(); |
| 2728 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( | 2732 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( |
| 2729 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); | 2733 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); |
| 2730 } | 2734 } |
| 2731 | 2735 |
| 2732 void Channel::ProcessAndEncodeAudio(const int16_t* audio_data, | 2736 void Channel::ProcessAndEncodeAudio(const int16_t* audio_data, |
| 2733 int sample_rate, | 2737 int sample_rate, |
| 2734 size_t number_of_frames, | 2738 size_t number_of_frames, |
| 2735 size_t number_of_channels) { | 2739 size_t number_of_channels) { |
| 2736 // Avoid posting as new task if sending was already stopped in StopSend(). | 2740 // Avoid posting as new task if sending was already stopped in StopSend(). |
| 2737 rtc::CritScope cs(&encoder_queue_lock_); | 2741 rtc::CritScope cs(&encoder_queue_lock_); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2757 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( | 2761 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( |
| 2758 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); | 2762 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); |
| 2759 } | 2763 } |
| 2760 | 2764 |
| 2761 void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) { | 2765 void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) { |
| 2762 RTC_DCHECK_RUN_ON(encoder_queue_); | 2766 RTC_DCHECK_RUN_ON(encoder_queue_); |
| 2763 RTC_DCHECK_GT(audio_input->samples_per_channel_, 0); | 2767 RTC_DCHECK_GT(audio_input->samples_per_channel_, 0); |
| 2764 RTC_DCHECK_LE(audio_input->num_channels_, 2); | 2768 RTC_DCHECK_LE(audio_input->num_channels_, 2); |
| 2765 RTC_DCHECK_EQ(audio_input->id_, ChannelId()); | 2769 RTC_DCHECK_EQ(audio_input->id_, ChannelId()); |
| 2766 | 2770 |
| 2771 // TODO(henrika): add comment and histogram here... |
| 2772 // dT = t1 - t0. |
| 2773 int64_t dT = audio_input->TimeSinceLastProfile(); |
| 2774 |
| 2767 if (channel_state_.Get().input_file_playing) { | 2775 if (channel_state_.Get().input_file_playing) { |
| 2768 MixOrReplaceAudioWithFile(audio_input); | 2776 MixOrReplaceAudioWithFile(audio_input); |
| 2769 } | 2777 } |
| 2770 | 2778 |
| 2771 bool is_muted = InputMute(); | 2779 bool is_muted = InputMute(); |
| 2772 AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted); | 2780 AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted); |
| 2773 | 2781 |
| 2774 if (_includeAudioLevelIndication) { | 2782 if (_includeAudioLevelIndication) { |
| 2775 size_t length = | 2783 size_t length = |
| 2776 audio_input->samples_per_channel_ * audio_input->num_channels_; | 2784 audio_input->samples_per_channel_ * audio_input->num_channels_; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 int64_t min_rtt = 0; | 3140 int64_t min_rtt = 0; |
| 3133 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3141 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3134 0) { | 3142 0) { |
| 3135 return 0; | 3143 return 0; |
| 3136 } | 3144 } |
| 3137 return rtt; | 3145 return rtt; |
| 3138 } | 3146 } |
| 3139 | 3147 |
| 3140 } // namespace voe | 3148 } // namespace voe |
| 3141 } // namespace webrtc | 3149 } // namespace webrtc |
| OLD | NEW |