chromium/third_party/openscreen/src/cast/streaming/sender_packet_router_unittest.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cast/streaming/sender_packet_router.h"

#include <chrono>

#include "cast/streaming/public/constants.h"
#include "cast/streaming/testing/mock_environment.h"
#include "cast/streaming/testing/simple_socket_subscriber.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "platform/base/ip_address.h"
#include "platform/test/fake_clock.h"
#include "platform/test/fake_task_runner.h"
#include "util/big_endian.h"
#include "util/chrono_helpers.h"
#include "util/osp_logging.h"

_;
ElementsAreArray;
Invoke;
Mock;
Return;

namespace openscreen::cast {
namespace {

const IPEndpoint kRemoteEndpoint{};

const IPEndpoint kUnexpectedEndpoint{};

// Limited burst parameters to simplify unit testing.
constexpr int kMaxPacketsPerBurst =;
constexpr auto kBurstInterval =;

constexpr Ssrc kAudioReceiverSsrc =;
constexpr Ssrc kVideoReceiverSsrc =;

const uint8_t kGarbagePacket[] =;

// clang-format off
const uint8_t kValidAudioRtcpPacket[] =;

const uint8_t kValidAudioRtpPacket[] =;
// clang-format on

// Returns a copy of an |original| RTCP packet, but with its send-to SSRC
// modified to the given |alternate_ssrc|.
std::vector<uint8_t> MakeRtcpPacketWithAlternateReceiverSsrc(
    ByteView original,
    Ssrc alternate_ssrc) {}

// Serializes the |flag| and |send_time| into the front of |buffer| so the tests
// can make unique packets and confirm their identities after passing through
// various components.
ByteBuffer MakeFakePacketWithFlag(char flag,
                                  Clock::time_point send_time,
                                  ByteBuffer buffer) {}

// Same as MakeFakePacketWithFlag(), but for tests that don't use the flag.
ByteBuffer MakeFakePacket(Clock::time_point send_time, ByteBuffer buffer) {}

// Returns the flag that was placed in the given |fake_packet|, or '?' if
// unknown.
char ParseFlag(ByteView fake_packet) {}

// Deserializes and returns the timestamp that was placed in the given |packet|
// by MakeFakePacketWithFlag().
Clock::time_point ParseTimestamp(ByteView fake_packet) {}

// Returns an empty version of |buffer|.
ByteBuffer ToEmptyPacketBuffer(Clock::time_point send_time, ByteBuffer buffer) {}

class MockSender : public SenderPacketRouter::Sender {};

class SenderPacketRouterTest : public testing::Test {};

// Tests that the SenderPacketRouter is correctly configured from the specific
// burst parameters that were passed to its constructor. This confirms internal
// calculations based on these parameters.
TEST_F(SenderPacketRouterTest, IsConfiguredFromBurstParameters) {}

TEST_F(SenderPacketRouterTest, IgnoresPacketsFromUnexpectedSources) {}

TEST_F(SenderPacketRouterTest, IgnoresInboundPacketsContainingGarbage) {}

// Note: RTP packets should be ignored since it wouldn't make sense for a
// Receiver to stream media to a Sender.
TEST_F(SenderPacketRouterTest, IgnoresInboundRtpPackets) {}

TEST_F(SenderPacketRouterTest, IgnoresInboundRtcpPacketsFromUnknownReceivers) {}

// Tests that the SenderPacketRouter forwards packets from Receivers to the
// appropriate Sender.
TEST_F(SenderPacketRouterTest, RoutesRTCPPacketsFromReceivers) {}

// Tests that the SenderPacketRouter schedules periodic RTCP packet sends,
// starting once the Sender requests the first RTCP send.
TEST_F(SenderPacketRouterTest, SchedulesPeriodicTransmissionOfRTCPPackets) {}

// Tests that the SenderPacketRouter schedules RTP packet bursts from a single
// Sender.
TEST_F(SenderPacketRouterTest, SchedulesAndTransmitsRTPBursts) {}

// Tests that the SenderPacketRouter schedules packet sends based on transmit
// prority: RTCP before RTP, and the audio Sender's packets before the video
// Sender's.
TEST_F(SenderPacketRouterTest, SchedulesAndTransmitsAccountingForPriority) {}

}  // namespace
}  // namespace openscreen::cast