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 |
| 11 #include <stdint.h> |
11 #include <string.h> | 12 #include <string.h> |
| 13 |
12 #include <algorithm> | 14 #include <algorithm> |
13 #include <map> | 15 #include <map> |
14 #include <memory> | 16 #include <memory> |
15 #include <set> | 17 #include <set> |
16 #include <utility> | 18 #include <utility> |
17 #include <vector> | 19 #include <vector> |
18 | 20 |
19 #include "webrtc/audio/audio_receive_stream.h" | 21 #include "webrtc/audio/audio_receive_stream.h" |
20 #include "webrtc/audio/audio_send_stream.h" | 22 #include "webrtc/audio/audio_send_stream.h" |
21 #include "webrtc/audio/audio_state.h" | 23 #include "webrtc/audio/audio_state.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 61 |
60 namespace webrtc { | 62 namespace webrtc { |
61 | 63 |
62 const int Call::Config::kDefaultStartBitrateBps = 300000; | 64 const int Call::Config::kDefaultStartBitrateBps = 300000; |
63 | 65 |
64 namespace internal { | 66 namespace internal { |
65 | 67 |
66 class Call : public webrtc::Call, | 68 class Call : public webrtc::Call, |
67 public PacketReceiver, | 69 public PacketReceiver, |
68 public RecoveredPacketReceiver, | 70 public RecoveredPacketReceiver, |
| 71 public FlexfecProtectionMediator, |
69 public CongestionController::Observer, | 72 public CongestionController::Observer, |
70 public BitrateAllocator::LimitObserver { | 73 public BitrateAllocator::LimitObserver { |
71 public: | 74 public: |
72 explicit Call(const Call::Config& config); | 75 explicit Call(const Call::Config& config); |
73 virtual ~Call(); | 76 virtual ~Call(); |
74 | 77 |
75 // Implements webrtc::Call. | 78 // Implements webrtc::Call. |
76 PacketReceiver* Receiver() override; | 79 PacketReceiver* Receiver() override; |
77 | 80 |
78 webrtc::AudioSendStream* CreateAudioSendStream( | 81 webrtc::AudioSendStream* CreateAudioSendStream( |
(...skipping 24 matching lines...) Expand all Loading... |
103 | 106 |
104 // Implements PacketReceiver. | 107 // Implements PacketReceiver. |
105 DeliveryStatus DeliverPacket(MediaType media_type, | 108 DeliveryStatus DeliverPacket(MediaType media_type, |
106 const uint8_t* packet, | 109 const uint8_t* packet, |
107 size_t length, | 110 size_t length, |
108 const PacketTime& packet_time) override; | 111 const PacketTime& packet_time) override; |
109 | 112 |
110 // Implements RecoveredPacketReceiver. | 113 // Implements RecoveredPacketReceiver. |
111 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; | 114 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; |
112 | 115 |
| 116 // Implements FlexfecProtectionMediator. |
| 117 bool IsProtectedByFlexfec(uint32_t ssrc) override; |
| 118 |
113 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet); | 119 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet); |
114 | 120 |
115 void SetBitrateConfig( | 121 void SetBitrateConfig( |
116 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 122 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
117 | 123 |
118 void SignalChannelNetworkState(MediaType media, NetworkState state) override; | 124 void SignalChannelNetworkState(MediaType media, NetworkState state) override; |
119 | 125 |
120 void OnTransportOverheadChanged(MediaType media, | 126 void OnTransportOverheadChanged(MediaType media, |
121 int transport_overhead_per_packet) override; | 127 int transport_overhead_per_packet) override; |
122 | 128 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 delete send_stream_impl; | 644 delete send_stream_impl; |
639 } | 645 } |
640 | 646 |
641 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 647 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
642 webrtc::VideoReceiveStream::Config configuration) { | 648 webrtc::VideoReceiveStream::Config configuration) { |
643 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 649 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
644 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 650 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
645 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 651 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
646 num_cpu_cores_, congestion_controller_.get(), &packet_router_, | 652 num_cpu_cores_, congestion_controller_.get(), &packet_router_, |
647 std::move(configuration), voice_engine(), module_process_thread_.get(), | 653 std::move(configuration), voice_engine(), module_process_thread_.get(), |
648 call_stats_.get(), &remb_); | 654 call_stats_.get(), &remb_, this /* flexfec_protection_mediator */); |
649 | 655 |
650 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 656 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
651 { | 657 { |
652 WriteLockScoped write_lock(*receive_crit_); | 658 WriteLockScoped write_lock(*receive_crit_); |
653 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 659 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
654 video_receive_ssrcs_.end()); | 660 video_receive_ssrcs_.end()); |
655 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 661 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
656 // TODO(pbos): Configure different RTX payloads per receive payload. | 662 // TODO(pbos): Configure different RTX payloads per receive payload. |
657 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 663 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
658 config.rtp.rtx.begin(); | 664 config.rtp.rtx.begin(); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 // audio packets with FlexFEC. | 1203 // audio packets with FlexFEC. |
1198 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1204 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1199 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1205 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1200 ReadLockScoped read_lock(*receive_crit_); | 1206 ReadLockScoped read_lock(*receive_crit_); |
1201 auto it = video_receive_ssrcs_.find(ssrc); | 1207 auto it = video_receive_ssrcs_.find(ssrc); |
1202 if (it == video_receive_ssrcs_.end()) | 1208 if (it == video_receive_ssrcs_.end()) |
1203 return false; | 1209 return false; |
1204 return it->second->OnRecoveredPacket(packet, length); | 1210 return it->second->OnRecoveredPacket(packet, length); |
1205 } | 1211 } |
1206 | 1212 |
| 1213 bool Call::IsProtectedByFlexfec(uint32_t ssrc) { |
| 1214 ReadLockScoped read_lock(*receive_crit_); |
| 1215 return flexfec_receive_ssrcs_media_.find(ssrc) != |
| 1216 flexfec_receive_ssrcs_media_.end(); |
| 1217 } |
| 1218 |
1207 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1219 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { |
1208 RTPHeader header; | 1220 RTPHeader header; |
1209 packet.GetHeader(&header); | 1221 packet.GetHeader(&header); |
1210 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1222 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), |
1211 packet.payload_size(), header); | 1223 packet.payload_size(), header); |
1212 } | 1224 } |
1213 | 1225 |
1214 } // namespace internal | 1226 } // namespace internal |
1215 } // namespace webrtc | 1227 } // namespace webrtc |
OLD | NEW |