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 #ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 10 #ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
11 #define WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 11 #define WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 #include "webrtc/api/call/transport.h" | 17 #include "webrtc/api/call/transport.h" |
18 #include "webrtc/call/call.h" | 18 #include "webrtc/call/call.h" |
19 #include "webrtc/rtc_base/sequenced_task_checker.h" | 19 #include "webrtc/rtc_base/sequenced_task_checker.h" |
20 #include "webrtc/rtc_base/thread_annotations.h" | 20 #include "webrtc/rtc_base/thread_annotations.h" |
21 #include "webrtc/test/fake_network_pipe.h" | 21 #include "webrtc/test/fake_network_pipe.h" |
| 22 #include "webrtc/test/rtp_file_writer.h" |
22 #include "webrtc/test/single_threaded_task_queue.h" | 23 #include "webrtc/test/single_threaded_task_queue.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 | 26 |
26 class Clock; | 27 class Clock; |
27 class PacketReceiver; | 28 class PacketReceiver; |
28 | 29 |
29 namespace test { | 30 namespace test { |
30 | 31 |
31 // Objects of this class are expected to be allocated and destroyed on the | 32 // Objects of this class are expected to be allocated and destroyed on the |
32 // same task-queue - the one that's passed in via the constructor. | 33 // same task-queue - the one that's passed in via the constructor. |
33 class DirectTransport : public Transport { | 34 class DirectTransport : public Transport, private PacketReceiver { |
34 public: | 35 public: |
35 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | 36 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, |
36 Call* send_call, | 37 Call* send_call, |
37 const std::map<uint8_t, MediaType>& payload_type_map); | 38 const std::map<uint8_t, MediaType>& payload_type_map); |
38 | 39 |
39 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | 40 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, |
40 const FakeNetworkPipe::Config& config, | 41 const FakeNetworkPipe::Config& config, |
41 Call* send_call, | 42 Call* send_call, |
42 const std::map<uint8_t, MediaType>& payload_type_map); | 43 const std::map<uint8_t, MediaType>& payload_type_map, |
| 44 std::unique_ptr<test::RtpFileWriter> rtp_file_writer); |
43 | 45 |
44 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, | 46 DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, |
45 const FakeNetworkPipe::Config& config, | 47 const FakeNetworkPipe::Config& config, |
46 Call* send_call, | 48 Call* send_call, |
47 std::unique_ptr<Demuxer> demuxer); | 49 std::unique_ptr<Demuxer> demuxer, |
| 50 std::unique_ptr<test::RtpFileWriter> rtp_file_writer); |
48 | 51 |
49 ~DirectTransport() override; | 52 ~DirectTransport() override; |
50 | 53 |
51 void SetConfig(const FakeNetworkPipe::Config& config); | 54 void SetConfig(const FakeNetworkPipe::Config& config); |
52 | 55 |
53 RTC_DEPRECATED void StopSending(); | 56 RTC_DEPRECATED void StopSending(); |
54 | 57 |
55 // TODO(holmer): Look into moving this to the constructor. | 58 // TODO(holmer): Look into moving this to the constructor. |
56 virtual void SetReceiver(PacketReceiver* receiver); | 59 virtual void SetReceiver(PacketReceiver* receiver); |
57 | 60 |
58 bool SendRtp(const uint8_t* data, | 61 bool SendRtp(const uint8_t* data, |
59 size_t length, | 62 size_t length, |
60 const PacketOptions& options) override; | 63 const PacketOptions& options) override; |
61 bool SendRtcp(const uint8_t* data, size_t length) override; | 64 bool SendRtcp(const uint8_t* data, size_t length) override; |
62 | 65 |
63 int GetAverageDelayMs(); | 66 int GetAverageDelayMs(); |
64 | 67 |
65 private: | 68 private: |
| 69 DeliveryStatus DeliverPacket(MediaType media_type, |
| 70 const uint8_t* packet, |
| 71 size_t length, |
| 72 const PacketTime& packet_time) override; |
| 73 |
66 void SendPackets(); | 74 void SendPackets(); |
67 | 75 |
68 Call* const send_call_; | 76 Call* const send_call_; |
69 Clock* const clock_; | 77 Clock* const clock_; |
70 | 78 |
71 // TODO(eladalon): Make |task_queue_| const. | 79 // TODO(eladalon): Make |task_queue_| const. |
72 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8125 | 80 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8125 |
73 SingleThreadedTaskQueueForTesting* task_queue_; | 81 SingleThreadedTaskQueueForTesting* task_queue_; |
74 SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_ | 82 SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_ |
75 GUARDED_BY(&sequence_checker_); | 83 GUARDED_BY(&sequence_checker_); |
76 | 84 |
77 FakeNetworkPipe fake_network_; | 85 FakeNetworkPipe fake_network_; |
78 | 86 |
79 rtc::SequencedTaskChecker sequence_checker_; | 87 rtc::SequencedTaskChecker sequence_checker_; |
| 88 |
| 89 PacketReceiver* receiver_; |
| 90 const int64_t start_ms_; |
| 91 std::unique_ptr<test::RtpFileWriter> rtp_file_writer_; |
80 }; | 92 }; |
81 } // namespace test | 93 } // namespace test |
82 } // namespace webrtc | 94 } // namespace webrtc |
83 | 95 |
84 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ | 96 #endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_ |
OLD | NEW |