Chromium Code Reviews| Index: webrtc/test/fake_network_pipe.cc |
| diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc |
| index 103416779a7ffdc8d15f6d7685505f4c2c4a6292..ec0b245b4f49197fcaa16ddf95e2ab93e57aae8a 100644 |
| --- a/webrtc/test/fake_network_pipe.cc |
| +++ b/webrtc/test/fake_network_pipe.cc |
| @@ -19,6 +19,7 @@ |
| #include "webrtc/base/logging.h" |
| #include "webrtc/call/call.h" |
| +#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| #include "webrtc/system_wrappers/include/clock.h" |
| namespace webrtc { |
| @@ -27,17 +28,18 @@ namespace { |
| constexpr int64_t kDefaultProcessIntervalMs = 5; |
| } |
| -FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| - const FakeNetworkPipe::Config& config, |
| - MediaType media_type) |
| - : FakeNetworkPipe(clock, config, media_type, 1) {} |
| - |
| -FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| - const FakeNetworkPipe::Config& config, |
| - MediaType media_type, |
| - uint64_t seed) |
| +FakeNetworkPipe::FakeNetworkPipe( |
| + Clock* clock, |
| + const FakeNetworkPipe::Config& config, |
| + const std::map<uint8_t, MediaType>& payload_type_map) |
| + : FakeNetworkPipe(clock, config, payload_type_map, 1) {} |
| + |
| +FakeNetworkPipe::FakeNetworkPipe( |
| + Clock* clock, |
| + const FakeNetworkPipe::Config& config, |
| + const std::map<uint8_t, MediaType>& payload_type_map, |
| + uint64_t seed) |
| : clock_(clock), |
| - media_type_(media_type), |
| packet_receiver_(NULL), |
| random_(seed), |
| config_(), |
| @@ -46,7 +48,8 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| total_packet_delay_(0), |
| bursting_(false), |
| next_process_time_(clock_->TimeInMilliseconds()), |
| - last_log_time_(clock_->TimeInMilliseconds()) { |
| + last_log_time_(clock_->TimeInMilliseconds()), |
| + payload_type_map_(payload_type_map) { |
| SetConfig(config); |
| } |
| @@ -202,8 +205,21 @@ void FakeNetworkPipe::Process() { |
| while (!packets_to_deliver.empty()) { |
| NetworkPacket* packet = packets_to_deliver.front(); |
| packets_to_deliver.pop(); |
| - packet_receiver_->DeliverPacket(media_type_, packet->data(), |
| - packet->data_length(), PacketTime()); |
| + |
| + const uint8_t* const packet_data = packet->data(); |
| + const size_t packet_length = packet->data_length(); |
| + MediaType media_type = MediaType::ANY; |
| + if (!RtpHeaderParser::IsRtcp(packet_data, packet_length)) { |
| + RTC_CHECK_GE(packet_length, 2); |
| + const uint8_t pt = packet_data[1] & 0x7f; |
|
stefan-webrtc
2017/04/06 11:54:51
payload_type
|
| + std::map<uint8_t, MediaType>::const_iterator it = |
| + payload_type_map_.find(pt); |
| + RTC_CHECK(it != payload_type_map_.end()) |
|
minyue-webrtc
2017/04/06 11:33:38
I made it very strict here. All payloads have to b
perkj_webrtc
2017/04/06 13:49:53
but it will break upstream since that is not the c
minyue-webrtc
2017/04/06 18:45:10
Ok. and so, is the change of ctor definition also
perkj_webrtc
2017/04/06 19:13:14
no, the "deprecated" version is used.
|
| + << "payload type " << static_cast<int>(pt) << " unknown."; |
| + media_type = it->second; |
| + } |
| + packet_receiver_->DeliverPacket(media_type, packet_data, packet_length, |
| + PacketTime()); |
| delete packet; |
| } |