OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 48 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
49 #include "webrtc/system_wrappers/include/metrics.h" | 49 #include "webrtc/system_wrappers/include/metrics.h" |
50 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 50 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
51 #include "webrtc/system_wrappers/include/trace.h" | 51 #include "webrtc/system_wrappers/include/trace.h" |
52 #include "webrtc/video/call_stats.h" | 52 #include "webrtc/video/call_stats.h" |
53 #include "webrtc/video/send_delay_stats.h" | 53 #include "webrtc/video/send_delay_stats.h" |
54 #include "webrtc/video/stats_counter.h" | 54 #include "webrtc/video/stats_counter.h" |
55 #include "webrtc/video/video_receive_stream.h" | 55 #include "webrtc/video/video_receive_stream.h" |
56 #include "webrtc/video/video_send_stream.h" | 56 #include "webrtc/video/video_send_stream.h" |
57 #include "webrtc/video/vie_remb.h" | 57 #include "webrtc/video/vie_remb.h" |
58 #include "webrtc/voice_engine/include/voe_codec.h" | |
59 | 58 |
60 namespace webrtc { | 59 namespace webrtc { |
61 | 60 |
62 const int Call::Config::kDefaultStartBitrateBps = 300000; | 61 const int Call::Config::kDefaultStartBitrateBps = 300000; |
63 | 62 |
64 namespace internal { | 63 namespace internal { |
65 | 64 |
66 class Call : public webrtc::Call, | 65 class Call : public webrtc::Call, |
67 public PacketReceiver, | 66 public PacketReceiver, |
68 public RecoveredPacketReceiver, | 67 public RecoveredPacketReceiver, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 private: | 142 private: |
144 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 143 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
145 size_t length); | 144 size_t length); |
146 DeliveryStatus DeliverRtp(MediaType media_type, | 145 DeliveryStatus DeliverRtp(MediaType media_type, |
147 const uint8_t* packet, | 146 const uint8_t* packet, |
148 size_t length, | 147 size_t length, |
149 const PacketTime& packet_time); | 148 const PacketTime& packet_time); |
150 void ConfigureSync(const std::string& sync_group) | 149 void ConfigureSync(const std::string& sync_group) |
151 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 150 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
152 | 151 |
153 VoiceEngine* voice_engine() { | |
154 internal::AudioState* audio_state = | |
155 static_cast<internal::AudioState*>(config_.audio_state.get()); | |
156 if (audio_state) | |
157 return audio_state->voice_engine(); | |
158 else | |
159 return nullptr; | |
160 } | |
161 | |
162 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | 152 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, |
163 size_t length, | 153 size_t length, |
164 const PacketTime& packet_time) | 154 const PacketTime& packet_time) |
165 SHARED_LOCKS_REQUIRED(receive_crit_); | 155 SHARED_LOCKS_REQUIRED(receive_crit_); |
166 | 156 |
167 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 157 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
168 void UpdateReceiveHistograms(); | 158 void UpdateReceiveHistograms(); |
169 void UpdateHistograms(); | 159 void UpdateHistograms(); |
170 void UpdateAggregateNetworkState(); | 160 void UpdateAggregateNetworkState(); |
171 | 161 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 UpdateAggregateNetworkState(); | 627 UpdateAggregateNetworkState(); |
638 delete send_stream_impl; | 628 delete send_stream_impl; |
639 } | 629 } |
640 | 630 |
641 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 631 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
642 webrtc::VideoReceiveStream::Config configuration) { | 632 webrtc::VideoReceiveStream::Config configuration) { |
643 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 633 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
644 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 634 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
645 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 635 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
646 num_cpu_cores_, congestion_controller_.get(), &packet_router_, | 636 num_cpu_cores_, congestion_controller_.get(), &packet_router_, |
647 std::move(configuration), voice_engine(), module_process_thread_.get(), | 637 std::move(configuration), module_process_thread_.get(), call_stats_.get(), |
648 call_stats_.get(), &remb_); | 638 &remb_); |
649 | 639 |
650 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 640 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
651 { | 641 { |
652 WriteLockScoped write_lock(*receive_crit_); | 642 WriteLockScoped write_lock(*receive_crit_); |
653 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 643 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
654 video_receive_ssrcs_.end()); | 644 video_receive_ssrcs_.end()); |
655 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 645 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
656 // TODO(pbos): Configure different RTX payloads per receive payload. | 646 // TODO(pbos): Configure different RTX payloads per receive payload. |
657 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 647 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
658 config.rtp.rtx.begin(); | 648 config.rtp.rtx.begin(); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 uint32_t max_padding_bitrate_bps) { | 998 uint32_t max_padding_bitrate_bps) { |
1009 congestion_controller_->SetAllocatedSendBitrateLimits( | 999 congestion_controller_->SetAllocatedSendBitrateLimits( |
1010 min_send_bitrate_bps, max_padding_bitrate_bps); | 1000 min_send_bitrate_bps, max_padding_bitrate_bps); |
1011 rtc::CritScope lock(&bitrate_crit_); | 1001 rtc::CritScope lock(&bitrate_crit_); |
1012 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; | 1002 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; |
1013 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; | 1003 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; |
1014 } | 1004 } |
1015 | 1005 |
1016 void Call::ConfigureSync(const std::string& sync_group) { | 1006 void Call::ConfigureSync(const std::string& sync_group) { |
1017 // Set sync only if there was no previous one. | 1007 // Set sync only if there was no previous one. |
1018 if (voice_engine() == nullptr || sync_group.empty()) | 1008 if (sync_group.empty()) |
1019 return; | 1009 return; |
1020 | 1010 |
1021 AudioReceiveStream* sync_audio_stream = nullptr; | 1011 AudioReceiveStream* sync_audio_stream = nullptr; |
1022 // Find existing audio stream. | 1012 // Find existing audio stream. |
1023 const auto it = sync_stream_mapping_.find(sync_group); | 1013 const auto it = sync_stream_mapping_.find(sync_group); |
1024 if (it != sync_stream_mapping_.end()) { | 1014 if (it != sync_stream_mapping_.end()) { |
1025 sync_audio_stream = it->second; | 1015 sync_audio_stream = it->second; |
1026 } else { | 1016 } else { |
1027 // No configured audio stream, see if we can find one. | 1017 // No configured audio stream, see if we can find one. |
1028 for (const auto& kv : audio_receive_ssrcs_) { | 1018 for (const auto& kv : audio_receive_ssrcs_) { |
(...skipping 16 matching lines...) Expand all Loading... |
1045 continue; | 1035 continue; |
1046 ++num_synced_streams; | 1036 ++num_synced_streams; |
1047 if (num_synced_streams > 1) { | 1037 if (num_synced_streams > 1) { |
1048 // TODO(pbos): Support synchronizing more than one A/V pair. | 1038 // TODO(pbos): Support synchronizing more than one A/V pair. |
1049 // https://code.google.com/p/webrtc/issues/detail?id=4762 | 1039 // https://code.google.com/p/webrtc/issues/detail?id=4762 |
1050 LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair " | 1040 LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair " |
1051 "within the same sync group. This is not supported in " | 1041 "within the same sync group. This is not supported in " |
1052 "the current implementation."; | 1042 "the current implementation."; |
1053 } | 1043 } |
1054 // Only sync the first A/V pair within this sync group. | 1044 // Only sync the first A/V pair within this sync group. |
1055 if (sync_audio_stream != nullptr && num_synced_streams == 1) { | 1045 if (num_synced_streams == 1) { |
1056 video_stream->SetSyncChannel(voice_engine(), | 1046 // sync_audio_stream may be null and that's ok. |
1057 sync_audio_stream->config().voe_channel_id); | 1047 video_stream->SetSync(sync_audio_stream); |
1058 } else { | 1048 } else { |
1059 video_stream->SetSyncChannel(voice_engine(), -1); | 1049 video_stream->SetSync(nullptr); |
1060 } | 1050 } |
1061 } | 1051 } |
1062 } | 1052 } |
1063 | 1053 |
1064 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, | 1054 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, |
1065 const uint8_t* packet, | 1055 const uint8_t* packet, |
1066 size_t length) { | 1056 size_t length) { |
1067 TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); | 1057 TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); |
1068 // TODO(pbos): Make sure it's a valid packet. | 1058 // TODO(pbos): Make sure it's a valid packet. |
1069 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 1059 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 | 1196 |
1207 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1197 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { |
1208 RTPHeader header; | 1198 RTPHeader header; |
1209 packet.GetHeader(&header); | 1199 packet.GetHeader(&header); |
1210 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1200 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), |
1211 packet.payload_size(), header); | 1201 packet.payload_size(), header); |
1212 } | 1202 } |
1213 | 1203 |
1214 } // namespace internal | 1204 } // namespace internal |
1215 } // namespace webrtc | 1205 } // namespace webrtc |
OLD | NEW |