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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 private: | 138 private: |
140 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 139 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
141 size_t length); | 140 size_t length); |
142 DeliveryStatus DeliverRtp(MediaType media_type, | 141 DeliveryStatus DeliverRtp(MediaType media_type, |
143 const uint8_t* packet, | 142 const uint8_t* packet, |
144 size_t length, | 143 size_t length, |
145 const PacketTime& packet_time); | 144 const PacketTime& packet_time); |
146 void ConfigureSync(const std::string& sync_group) | 145 void ConfigureSync(const std::string& sync_group) |
147 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 146 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
148 | 147 |
149 VoiceEngine* voice_engine() { | |
150 internal::AudioState* audio_state = | |
151 static_cast<internal::AudioState*>(config_.audio_state.get()); | |
152 if (audio_state) | |
153 return audio_state->voice_engine(); | |
154 else | |
155 return nullptr; | |
156 } | |
157 | |
158 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | 148 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, |
159 size_t length, | 149 size_t length, |
160 const PacketTime& packet_time) | 150 const PacketTime& packet_time) |
161 SHARED_LOCKS_REQUIRED(receive_crit_); | 151 SHARED_LOCKS_REQUIRED(receive_crit_); |
162 | 152 |
163 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 153 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
164 void UpdateReceiveHistograms(); | 154 void UpdateReceiveHistograms(); |
165 void UpdateHistograms(); | 155 void UpdateHistograms(); |
166 void UpdateAggregateNetworkState(); | 156 void UpdateAggregateNetworkState(); |
167 | 157 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 | 631 |
642 bool protected_by_flexfec = false; | 632 bool protected_by_flexfec = false; |
643 { | 633 { |
644 ReadLockScoped read_lock(*receive_crit_); | 634 ReadLockScoped read_lock(*receive_crit_); |
645 protected_by_flexfec = | 635 protected_by_flexfec = |
646 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != | 636 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != |
647 flexfec_receive_ssrcs_media_.end(); | 637 flexfec_receive_ssrcs_media_.end(); |
648 } | 638 } |
649 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 639 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
650 num_cpu_cores_, protected_by_flexfec, congestion_controller_.get(), | 640 num_cpu_cores_, protected_by_flexfec, congestion_controller_.get(), |
651 &packet_router_, std::move(configuration), voice_engine(), | 641 &packet_router_, std::move(configuration), module_process_thread_.get(), |
652 module_process_thread_.get(), call_stats_.get(), &remb_); | 642 call_stats_.get(), &remb_); |
653 | 643 |
654 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 644 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
655 { | 645 { |
656 WriteLockScoped write_lock(*receive_crit_); | 646 WriteLockScoped write_lock(*receive_crit_); |
657 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 647 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
658 video_receive_ssrcs_.end()); | 648 video_receive_ssrcs_.end()); |
659 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 649 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
660 if (config.rtp.rtx_ssrc) | 650 if (config.rtp.rtx_ssrc) |
661 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; | 651 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; |
662 video_receive_streams_.insert(receive_stream); | 652 video_receive_streams_.insert(receive_stream); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 uint32_t max_padding_bitrate_bps) { | 1002 uint32_t max_padding_bitrate_bps) { |
1013 congestion_controller_->SetAllocatedSendBitrateLimits( | 1003 congestion_controller_->SetAllocatedSendBitrateLimits( |
1014 min_send_bitrate_bps, max_padding_bitrate_bps); | 1004 min_send_bitrate_bps, max_padding_bitrate_bps); |
1015 rtc::CritScope lock(&bitrate_crit_); | 1005 rtc::CritScope lock(&bitrate_crit_); |
1016 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; | 1006 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; |
1017 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; | 1007 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; |
1018 } | 1008 } |
1019 | 1009 |
1020 void Call::ConfigureSync(const std::string& sync_group) { | 1010 void Call::ConfigureSync(const std::string& sync_group) { |
1021 // Set sync only if there was no previous one. | 1011 // Set sync only if there was no previous one. |
1022 if (voice_engine() == nullptr || sync_group.empty()) | 1012 if (sync_group.empty()) |
1023 return; | 1013 return; |
1024 | 1014 |
1025 AudioReceiveStream* sync_audio_stream = nullptr; | 1015 AudioReceiveStream* sync_audio_stream = nullptr; |
1026 // Find existing audio stream. | 1016 // Find existing audio stream. |
1027 const auto it = sync_stream_mapping_.find(sync_group); | 1017 const auto it = sync_stream_mapping_.find(sync_group); |
1028 if (it != sync_stream_mapping_.end()) { | 1018 if (it != sync_stream_mapping_.end()) { |
1029 sync_audio_stream = it->second; | 1019 sync_audio_stream = it->second; |
1030 } else { | 1020 } else { |
1031 // No configured audio stream, see if we can find one. | 1021 // No configured audio stream, see if we can find one. |
1032 for (const auto& kv : audio_receive_ssrcs_) { | 1022 for (const auto& kv : audio_receive_ssrcs_) { |
(...skipping 16 matching lines...) Expand all Loading... |
1049 continue; | 1039 continue; |
1050 ++num_synced_streams; | 1040 ++num_synced_streams; |
1051 if (num_synced_streams > 1) { | 1041 if (num_synced_streams > 1) { |
1052 // TODO(pbos): Support synchronizing more than one A/V pair. | 1042 // TODO(pbos): Support synchronizing more than one A/V pair. |
1053 // https://code.google.com/p/webrtc/issues/detail?id=4762 | 1043 // https://code.google.com/p/webrtc/issues/detail?id=4762 |
1054 LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair " | 1044 LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair " |
1055 "within the same sync group. This is not supported in " | 1045 "within the same sync group. This is not supported in " |
1056 "the current implementation."; | 1046 "the current implementation."; |
1057 } | 1047 } |
1058 // Only sync the first A/V pair within this sync group. | 1048 // Only sync the first A/V pair within this sync group. |
1059 if (sync_audio_stream != nullptr && num_synced_streams == 1) { | 1049 if (num_synced_streams == 1) { |
1060 video_stream->SetSyncChannel(voice_engine(), | 1050 // sync_audio_stream may be null and that's ok. |
1061 sync_audio_stream->config().voe_channel_id); | 1051 video_stream->SetSync(sync_audio_stream); |
1062 } else { | 1052 } else { |
1063 video_stream->SetSyncChannel(voice_engine(), -1); | 1053 video_stream->SetSync(nullptr); |
1064 } | 1054 } |
1065 } | 1055 } |
1066 } | 1056 } |
1067 | 1057 |
1068 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, | 1058 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, |
1069 const uint8_t* packet, | 1059 const uint8_t* packet, |
1070 size_t length) { | 1060 size_t length) { |
1071 TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); | 1061 TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); |
1072 // TODO(pbos): Make sure it's a valid packet. | 1062 // TODO(pbos): Make sure it's a valid packet. |
1073 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 1063 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 | 1199 |
1210 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1200 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { |
1211 RTPHeader header; | 1201 RTPHeader header; |
1212 packet.GetHeader(&header); | 1202 packet.GetHeader(&header); |
1213 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1203 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), |
1214 packet.payload_size(), header); | 1204 packet.payload_size(), header); |
1215 } | 1205 } |
1216 | 1206 |
1217 } // namespace internal | 1207 } // namespace internal |
1218 } // namespace webrtc | 1208 } // namespace webrtc |
OLD | NEW |