Chromium Code Reviews| 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 #include "webrtc/test/direct_transport.h" | 10 #include "webrtc/test/direct_transport.h" |
| 11 | 11 |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 #include "webrtc/call.h" | 14 #include "webrtc/call.h" |
| 15 #include "webrtc/system_wrappers/interface/clock.h" | 15 #include "webrtc/system_wrappers/interface/clock.h" |
| 16 | 16 |
| 17 namespace webrtc { | 17 namespace webrtc { |
| 18 namespace test { | 18 namespace test { |
| 19 | 19 |
| 20 DirectTransport::DirectTransport() | 20 DirectTransport::DirectTransport(Call* send_call) |
| 21 : packet_event_(EventWrapper::Create()), | 21 : send_call_(send_call), |
| 22 packet_event_(EventWrapper::Create()), | |
| 22 thread_( | 23 thread_( |
| 23 ThreadWrapper::CreateThread(NetworkProcess, this, "NetworkProcess")), | 24 ThreadWrapper::CreateThread(NetworkProcess, this, "NetworkProcess")), |
| 24 clock_(Clock::GetRealTimeClock()), | 25 clock_(Clock::GetRealTimeClock()), |
| 25 shutting_down_(false), | 26 shutting_down_(false), |
| 26 fake_network_(FakeNetworkPipe::Config()) { | 27 fake_network_(FakeNetworkPipe::Config()) { |
| 27 EXPECT_TRUE(thread_->Start()); | 28 EXPECT_TRUE(thread_->Start()); |
| 28 } | 29 } |
| 29 | 30 |
| 30 DirectTransport::DirectTransport(const FakeNetworkPipe::Config& config) | 31 DirectTransport::DirectTransport(const FakeNetworkPipe::Config& config, |
| 31 : packet_event_(EventWrapper::Create()), | 32 Call* send_call) |
| 33 : send_call_(send_call), | |
| 34 packet_event_(EventWrapper::Create()), | |
| 32 thread_( | 35 thread_( |
| 33 ThreadWrapper::CreateThread(NetworkProcess, this, "NetworkProcess")), | 36 ThreadWrapper::CreateThread(NetworkProcess, this, "NetworkProcess")), |
| 34 clock_(Clock::GetRealTimeClock()), | 37 clock_(Clock::GetRealTimeClock()), |
| 35 shutting_down_(false), | 38 shutting_down_(false), |
| 36 fake_network_(config) { | 39 fake_network_(config) { |
| 37 EXPECT_TRUE(thread_->Start()); | 40 EXPECT_TRUE(thread_->Start()); |
| 38 } | 41 } |
| 39 | 42 |
| 40 DirectTransport::~DirectTransport() { StopSending(); } | 43 DirectTransport::~DirectTransport() { StopSending(); } |
| 41 | 44 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 53 EXPECT_TRUE(thread_->Stop()); | 56 EXPECT_TRUE(thread_->Stop()); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void DirectTransport::SetReceiver(PacketReceiver* receiver) { | 59 void DirectTransport::SetReceiver(PacketReceiver* receiver) { |
| 57 fake_network_.SetReceiver(receiver); | 60 fake_network_.SetReceiver(receiver); |
| 58 } | 61 } |
| 59 | 62 |
| 60 bool DirectTransport::SendRtp(const uint8_t* data, | 63 bool DirectTransport::SendRtp(const uint8_t* data, |
| 61 size_t length, | 64 size_t length, |
| 62 const PacketOptions& options) { | 65 const PacketOptions& options) { |
| 66 rtc::SentPacket sent_packet(options.packet_id, clock_->TimeInMilliseconds()); | |
|
pbos-webrtc
2015/10/27 14:06:30
Move inside if()
stefan-webrtc
2015/10/27 14:33:16
Done.
| |
| 67 if (send_call_) | |
| 68 send_call_->OnSentPacket(sent_packet); | |
| 63 fake_network_.SendPacket(data, length); | 69 fake_network_.SendPacket(data, length); |
| 64 packet_event_->Set(); | 70 packet_event_->Set(); |
| 65 return true; | 71 return true; |
| 66 } | 72 } |
| 67 | 73 |
| 68 bool DirectTransport::SendRtcp(const uint8_t* data, size_t length) { | 74 bool DirectTransport::SendRtcp(const uint8_t* data, size_t length) { |
| 69 fake_network_.SendPacket(data, length); | 75 fake_network_.SendPacket(data, length); |
| 70 packet_event_->Set(); | 76 packet_event_->Set(); |
| 71 return true; | 77 return true; |
| 72 } | 78 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 87 case kEventError: | 93 case kEventError: |
| 88 // TODO(pbos): Log a warning here? | 94 // TODO(pbos): Log a warning here? |
| 89 return true; | 95 return true; |
| 90 } | 96 } |
| 91 } | 97 } |
| 92 rtc::CritScope crit(&lock_); | 98 rtc::CritScope crit(&lock_); |
| 93 return shutting_down_ ? false : true; | 99 return shutting_down_ ? false : true; |
| 94 } | 100 } |
| 95 } // namespace test | 101 } // namespace test |
| 96 } // namespace webrtc | 102 } // namespace webrtc |
| OLD | NEW |