| Index: webrtc/test/fake_network_pipe.h
|
| diff --git a/webrtc/test/fake_network_pipe.h b/webrtc/test/fake_network_pipe.h
|
| index adf76c3a7bae731b05b6498aa792c747d0d96797..f3cd11dcc0e66e6b1f33c6deed6567a05b4001fa 100644
|
| --- a/webrtc/test/fake_network_pipe.h
|
| +++ b/webrtc/test/fake_network_pipe.h
|
| @@ -11,14 +11,16 @@
|
| #ifndef WEBRTC_TEST_FAKE_NETWORK_PIPE_H_
|
| #define WEBRTC_TEST_FAKE_NETWORK_PIPE_H_
|
|
|
| -#include <memory>
|
| -#include <set>
|
| #include <string.h>
|
| +#include <map>
|
| +#include <memory>
|
| #include <queue>
|
| +#include <set>
|
|
|
| #include "webrtc/base/constructormagic.h"
|
| #include "webrtc/base/criticalsection.h"
|
| #include "webrtc/base/random.h"
|
| +#include "webrtc/common_types.h"
|
| #include "webrtc/typedefs.h"
|
|
|
| namespace webrtc {
|
| @@ -59,6 +61,28 @@ class NetworkPacket {
|
| int64_t arrival_time_;
|
| };
|
|
|
| +class Demuxer {
|
| + public:
|
| + virtual ~Demuxer() = default;
|
| + virtual void SetReceiver(PacketReceiver* receiver) = 0;
|
| + virtual void DeliverPacket(const NetworkPacket* packet,
|
| + const PacketTime& packet_time) = 0;
|
| +};
|
| +
|
| +class DemuxerImpl final : public Demuxer {
|
| + public:
|
| + explicit DemuxerImpl(const std::map<uint8_t, MediaType>& payload_type_map);
|
| +
|
| + void SetReceiver(PacketReceiver* receiver) override;
|
| + void DeliverPacket(const NetworkPacket* packet,
|
| + const PacketTime& packet_time) override;
|
| +
|
| + private:
|
| + PacketReceiver* packet_receiver_;
|
| + const std::map<uint8_t, MediaType> payload_type_map_;
|
| + RTC_DISALLOW_COPY_AND_ASSIGN(DemuxerImpl);
|
| +};
|
| +
|
| // Class faking a network link. This is a simple and naive solution just faking
|
| // capacity and adding an extra transport delay in addition to the capacity
|
| // introduced delay.
|
| @@ -83,15 +107,15 @@ class FakeNetworkPipe {
|
| int avg_burst_loss_length = -1;
|
| };
|
|
|
| - FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config,
|
| - MediaType media_type);
|
| FakeNetworkPipe(Clock* clock,
|
| - const FakeNetworkPipe::Config& config, MediaType media_type,
|
| + const FakeNetworkPipe::Config& config,
|
| + std::unique_ptr<Demuxer> demuxer);
|
| + FakeNetworkPipe(Clock* clock,
|
| + const FakeNetworkPipe::Config& config,
|
| + std::unique_ptr<Demuxer> demuxer,
|
| uint64_t seed);
|
| ~FakeNetworkPipe();
|
|
|
| - // Must not be called in parallel with SendPacket or Process.
|
| - void SetReceiver(PacketReceiver* receiver);
|
|
|
| // Sets a new configuration. This won't affect packets already in the pipe.
|
| void SetConfig(const FakeNetworkPipe::Config& config);
|
| @@ -99,6 +123,9 @@ class FakeNetworkPipe {
|
| // Sends a new packet to the link.
|
| void SendPacket(const uint8_t* packet, size_t packet_length);
|
|
|
| + // Must not be called in parallel with SendPacket or Process.
|
| + void SetReceiver(PacketReceiver* receiver);
|
| +
|
| // Processes the network queues and trigger PacketReceiver::IncomingPacket for
|
| // packets ready to be delivered.
|
| void Process();
|
| @@ -112,9 +139,8 @@ class FakeNetworkPipe {
|
|
|
| private:
|
| Clock* const clock_;
|
| - const MediaType media_type_;
|
| rtc::CriticalSection lock_;
|
| - PacketReceiver* packet_receiver_;
|
| + const std::unique_ptr<Demuxer> demuxer_;
|
| std::queue<NetworkPacket*> capacity_link_;
|
| Random random_;
|
|
|
|
|