| 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 632   UpdateAggregateNetworkState(); | 622   UpdateAggregateNetworkState(); | 
| 633   delete send_stream_impl; | 623   delete send_stream_impl; | 
| 634 } | 624 } | 
| 635 | 625 | 
| 636 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 626 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 
| 637     webrtc::VideoReceiveStream::Config configuration) { | 627     webrtc::VideoReceiveStream::Config configuration) { | 
| 638   TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 628   TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 
| 639   RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 629   RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 
| 640   VideoReceiveStream* receive_stream = new VideoReceiveStream( | 630   VideoReceiveStream* receive_stream = new VideoReceiveStream( | 
| 641       num_cpu_cores_, congestion_controller_.get(), &packet_router_, | 631       num_cpu_cores_, congestion_controller_.get(), &packet_router_, | 
| 642       std::move(configuration), voice_engine(), module_process_thread_.get(), | 632       std::move(configuration), module_process_thread_.get(), call_stats_.get(), | 
| 643       call_stats_.get(), &remb_); | 633       &remb_); | 
| 644 | 634 | 
| 645   const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 635   const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 
| 646   { | 636   { | 
| 647     WriteLockScoped write_lock(*receive_crit_); | 637     WriteLockScoped write_lock(*receive_crit_); | 
| 648     RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 638     RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 
| 649                video_receive_ssrcs_.end()); | 639                video_receive_ssrcs_.end()); | 
| 650     video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 640     video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 
| 651     // TODO(pbos): Configure different RTX payloads per receive payload. | 641     // TODO(pbos): Configure different RTX payloads per receive payload. | 
| 652     VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 642     VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 
| 653         config.rtp.rtx.begin(); | 643         config.rtp.rtx.begin(); | 
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1004                                      uint32_t max_padding_bitrate_bps) { | 994                                      uint32_t max_padding_bitrate_bps) { | 
| 1005   congestion_controller_->SetAllocatedSendBitrateLimits( | 995   congestion_controller_->SetAllocatedSendBitrateLimits( | 
| 1006       min_send_bitrate_bps, max_padding_bitrate_bps); | 996       min_send_bitrate_bps, max_padding_bitrate_bps); | 
| 1007   rtc::CritScope lock(&bitrate_crit_); | 997   rtc::CritScope lock(&bitrate_crit_); | 
| 1008   min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; | 998   min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; | 
| 1009   configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; | 999   configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; | 
| 1010 } | 1000 } | 
| 1011 | 1001 | 
| 1012 void Call::ConfigureSync(const std::string& sync_group) { | 1002 void Call::ConfigureSync(const std::string& sync_group) { | 
| 1013   // Set sync only if there was no previous one. | 1003   // Set sync only if there was no previous one. | 
| 1014   if (voice_engine() == nullptr || sync_group.empty()) | 1004   if (sync_group.empty()) | 
| 1015     return; | 1005     return; | 
| 1016 | 1006 | 
| 1017   AudioReceiveStream* sync_audio_stream = nullptr; | 1007   AudioReceiveStream* sync_audio_stream = nullptr; | 
| 1018   // Find existing audio stream. | 1008   // Find existing audio stream. | 
| 1019   const auto it = sync_stream_mapping_.find(sync_group); | 1009   const auto it = sync_stream_mapping_.find(sync_group); | 
| 1020   if (it != sync_stream_mapping_.end()) { | 1010   if (it != sync_stream_mapping_.end()) { | 
| 1021     sync_audio_stream = it->second; | 1011     sync_audio_stream = it->second; | 
| 1022   } else { | 1012   } else { | 
| 1023     // No configured audio stream, see if we can find one. | 1013     // No configured audio stream, see if we can find one. | 
| 1024     for (const auto& kv : audio_receive_ssrcs_) { | 1014     for (const auto& kv : audio_receive_ssrcs_) { | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 1041       continue; | 1031       continue; | 
| 1042     ++num_synced_streams; | 1032     ++num_synced_streams; | 
| 1043     if (num_synced_streams > 1) { | 1033     if (num_synced_streams > 1) { | 
| 1044       // TODO(pbos): Support synchronizing more than one A/V pair. | 1034       // TODO(pbos): Support synchronizing more than one A/V pair. | 
| 1045       // https://code.google.com/p/webrtc/issues/detail?id=4762 | 1035       // https://code.google.com/p/webrtc/issues/detail?id=4762 | 
| 1046       LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair " | 1036       LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair " | 
| 1047                          "within the same sync group. This is not supported in " | 1037                          "within the same sync group. This is not supported in " | 
| 1048                          "the current implementation."; | 1038                          "the current implementation."; | 
| 1049     } | 1039     } | 
| 1050     // Only sync the first A/V pair within this sync group. | 1040     // Only sync the first A/V pair within this sync group. | 
| 1051     if (sync_audio_stream != nullptr && num_synced_streams == 1) { | 1041     if (num_synced_streams == 1) { | 
| 1052       video_stream->SetSyncChannel(voice_engine(), | 1042       // sync_audio_stream may be null and that's ok. | 
| 1053                                    sync_audio_stream->config().voe_channel_id); | 1043       video_stream->SetSync(sync_audio_stream); | 
| 1054     } else { | 1044     } else { | 
| 1055       video_stream->SetSyncChannel(voice_engine(), -1); | 1045       video_stream->SetSync(nullptr); | 
| 1056     } | 1046     } | 
| 1057   } | 1047   } | 
| 1058 } | 1048 } | 
| 1059 | 1049 | 
| 1060 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, | 1050 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, | 
| 1061                                                  const uint8_t* packet, | 1051                                                  const uint8_t* packet, | 
| 1062                                                  size_t length) { | 1052                                                  size_t length) { | 
| 1063   TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); | 1053   TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); | 
| 1064   // TODO(pbos): Make sure it's a valid packet. | 1054   // TODO(pbos): Make sure it's a valid packet. | 
| 1065   //             Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 1055   //             Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1201 | 1191 | 
| 1202 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1192 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 
| 1203   RTPHeader header; | 1193   RTPHeader header; | 
| 1204   packet.GetHeader(&header); | 1194   packet.GetHeader(&header); | 
| 1205   congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1195   congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 
| 1206                                            packet.payload_size(), header); | 1196                                            packet.payload_size(), header); | 
| 1207 } | 1197 } | 
| 1208 | 1198 | 
| 1209 }  // namespace internal | 1199 }  // namespace internal | 
| 1210 }  // namespace webrtc | 1200 }  // namespace webrtc | 
| OLD | NEW | 
|---|