From 2b02e3287584ed6582dcced9ec08b3acdece37e3 Mon Sep 17 00:00:00 2001 From: Yuri Wiitala Date: Tue, 3 Dec 2019 16:59:40 -0800 Subject: =?UTF-8?q?Flatten=20namespace=20for=20platform/=20code:=20opescre?= =?UTF-8?q?en::platform=20=E2=86=92=20openscreen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the nested "platform" namespace in the platform code. Fixes all typenames (fixing/removing using namespace statements, removing unnecessary namespace qualifiers, etc.). Also, removed the "using UdpSocketUniquePtr = std::unique_ptr<>" since the alias is no longer necessary (the smart pointer no longer does anything special at delete time). Bug: openscreen:90 Change-Id: I0e8589282b4e42530c8c1c95115078d83e3e5f16 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1948540 Reviewed-by: Jordan Bayles Reviewed-by: mark a. foltz Commit-Queue: Yuri Wiitala --- cast/common/channel/cast_socket.cc | 3 +- cast/common/channel/cast_socket.h | 25 +++++----- cast/common/channel/cast_socket_unittest.cc | 15 +++--- .../connection_namespace_handler_unittest.cc | 5 +- cast/common/channel/test/fake_cast_socket.h | 55 ++++++++++++---------- cast/common/channel/virtual_connection_router.cc | 2 + cast/common/channel/virtual_connection_router.h | 7 +-- .../channel/virtual_connection_router_unittest.cc | 5 +- cast/sender/channel/cast_auth_util.cc | 8 ++-- cast/sender/channel/cast_auth_util_unittest.cc | 6 +-- cast/sender/channel/sender_socket_factory.cc | 6 ++- cast/sender/channel/sender_socket_factory.h | 55 +++++++++++----------- cast/standalone_receiver/main.cc | 15 +++--- cast/standalone_receiver/sdl_audio_player.cc | 6 +-- cast/standalone_receiver/sdl_audio_player.h | 8 ++-- cast/standalone_receiver/sdl_glue.cc | 4 +- cast/standalone_receiver/sdl_glue.h | 4 +- cast/standalone_receiver/sdl_player_base.cc | 6 +-- cast/standalone_receiver/sdl_player_base.h | 18 +++---- cast/standalone_receiver/sdl_video_player.cc | 6 +-- cast/standalone_receiver/sdl_video_player.h | 6 +-- cast/streaming/clock_drift_smoother.h | 2 +- cast/streaming/compound_rtcp_builder.cc | 2 +- cast/streaming/compound_rtcp_builder.h | 7 ++- cast/streaming/compound_rtcp_builder_unittest.cc | 2 +- cast/streaming/compound_rtcp_parser.cc | 2 +- cast/streaming/compound_rtcp_parser.h | 6 +-- cast/streaming/compound_rtcp_parser_fuzzer.cc | 2 +- cast/streaming/compound_rtcp_parser_unittest.cc | 3 +- cast/streaming/encoded_frame.h | 2 +- cast/streaming/environment.cc | 18 +++---- cast/streaming/environment.h | 43 +++++++---------- cast/streaming/mock_compound_rtcp_parser_client.h | 2 +- cast/streaming/ntp_time.cc | 2 +- cast/streaming/ntp_time.h | 16 +++---- cast/streaming/ntp_time_unittest.cc | 4 +- cast/streaming/packet_receive_stats_tracker.cc | 2 +- cast/streaming/packet_receive_stats_tracker.h | 11 ++--- .../packet_receive_stats_tracker_unittest.cc | 2 +- cast/streaming/receiver.cc | 2 +- cast/streaming/receiver.h | 26 +++++----- cast/streaming/receiver_packet_router.cc | 2 +- cast/streaming/receiver_packet_router.h | 2 +- cast/streaming/receiver_session_unittest.cc | 6 +-- cast/streaming/receiver_unittest.cc | 14 +++--- cast/streaming/rtcp_common.cc | 2 +- cast/streaming/rtcp_common.h | 5 +- cast/streaming/rtcp_common_unittest.cc | 2 +- cast/streaming/rtcp_session.cc | 2 +- cast/streaming/rtcp_session.h | 2 +- cast/streaming/rtp_packetizer.cc | 2 +- cast/streaming/rtp_packetizer_unittest.cc | 2 +- cast/streaming/sender_report_parser_fuzzer.cc | 2 +- cast/streaming/sender_report_unittest.cc | 5 +- cast/streaming/ssrc.cc | 2 +- 55 files changed, 234 insertions(+), 237 deletions(-) (limited to 'cast') diff --git a/cast/common/channel/cast_socket.cc b/cast/common/channel/cast_socket.cc index 0e4a536e..214b50a8 100644 --- a/cast/common/channel/cast_socket.cc +++ b/cast/common/channel/cast_socket.cc @@ -13,8 +13,9 @@ namespace cast { namespace channel { using message_serialization::DeserializeResult; +using openscreen::Error; using openscreen::ErrorOr; -using openscreen::platform::TlsConnection; +using openscreen::TlsConnection; uint32_t GetNextSocketId() { static std::atomic id(1); diff --git a/cast/common/channel/cast_socket.h b/cast/common/channel/cast_socket.h index bf775543..1e5dc699 100644 --- a/cast/common/channel/cast_socket.h +++ b/cast/common/channel/cast_socket.h @@ -14,9 +14,6 @@ namespace cast { namespace channel { -using openscreen::Error; -using TlsConnection = openscreen::platform::TlsConnection; - class CastMessage; uint32_t GetNextSocketId(); @@ -24,19 +21,19 @@ uint32_t GetNextSocketId(); // Represents a simple message-oriented socket for communicating with the Cast // V2 protocol. It isn't thread-safe, so it should only be used on the same // TaskRunner thread as its TlsConnection. -class CastSocket : public TlsConnection::Client { +class CastSocket : public openscreen::TlsConnection::Client { public: class Client { public: virtual ~Client() = default; // Called when a terminal error on |socket| has occurred. - virtual void OnError(CastSocket* socket, Error error) = 0; + virtual void OnError(CastSocket* socket, openscreen::Error error) = 0; virtual void OnMessage(CastSocket* socket, CastMessage message) = 0; }; - CastSocket(std::unique_ptr connection, + CastSocket(std::unique_ptr connection, Client* client, uint32_t socket_id); ~CastSocket(); @@ -45,7 +42,7 @@ class CastSocket : public TlsConnection::Client { // write-blocked, in which case |message| will be queued. An error will be // returned if |message| cannot be serialized for any reason, even while // write-blocked. - Error SendMessage(const CastMessage& message); + openscreen::Error SendMessage(const CastMessage& message); void SetClient(Client* client); @@ -53,11 +50,13 @@ class CastSocket : public TlsConnection::Client { uint32_t socket_id() const { return socket_id_; } - // TlsConnection::Client overrides. - void OnWriteBlocked(TlsConnection* connection) override; - void OnWriteUnblocked(TlsConnection* connection) override; - void OnError(TlsConnection* connection, Error error) override; - void OnRead(TlsConnection* connection, std::vector block) override; + // openscreen::TlsConnection::Client overrides. + void OnWriteBlocked(openscreen::TlsConnection* connection) override; + void OnWriteUnblocked(openscreen::TlsConnection* connection) override; + void OnError(openscreen::TlsConnection* connection, + openscreen::Error error) override; + void OnRead(openscreen::TlsConnection* connection, + std::vector block) override; private: enum class State { @@ -67,7 +66,7 @@ class CastSocket : public TlsConnection::Client { }; Client* client_; // May never be null. - const std::unique_ptr connection_; + const std::unique_ptr connection_; std::vector read_buffer_; const uint32_t socket_id_; State state_ = State::kOpen; diff --git a/cast/common/channel/cast_socket_unittest.cc b/cast/common/channel/cast_socket_unittest.cc index 781fa384..e9df607e 100644 --- a/cast/common/channel/cast_socket_unittest.cc +++ b/cast/common/channel/cast_socket_unittest.cc @@ -35,7 +35,9 @@ class CastSocketTest : public ::testing::Test { } protected: - MockTlsConnection& connection() { return *fake_socket_.connection; } + openscreen::MockTlsConnection& connection() { + return *fake_socket_.connection; + } MockCastSocketClient& mock_client() { return fake_socket_.mock_client; } CastSocket& socket() { return fake_socket_.socket; } @@ -129,7 +131,7 @@ TEST_F(CastSocketTest, ErrorWhileEmptyingQueue) { frame_serial_, std::vector(reinterpret_cast(data), reinterpret_cast(data) + len)); - connection().OnError(Error::Code::kUnknownError); + connection().OnError(openscreen::Error::Code::kUnknownError); })); connection().OnWriteUnblocked(); @@ -142,10 +144,11 @@ TEST_F(CastSocketTest, SanitizedAddress) { EXPECT_EQ(result1[0], 1u); EXPECT_EQ(result1[1], 9u); - FakeCastSocket v6_socket(IPEndpoint{{1, 2, 3, 4}, 1025}, - IPEndpoint{{0x1819, 0x1a1b, 0x1c1d, 0x1e1f, 0x207b, - 0x7c7d, 0x7e7f, 0x8081}, - 4321}); + FakeCastSocket v6_socket( + openscreen::IPEndpoint{{1, 2, 3, 4}, 1025}, + openscreen::IPEndpoint{ + {0x1819, 0x1a1b, 0x1c1d, 0x1e1f, 0x207b, 0x7c7d, 0x7e7f, 0x8081}, + 4321}); std::array result2 = v6_socket.socket.GetSanitizedIpAddress(); EXPECT_EQ(result2[0], 128); EXPECT_EQ(result2[1], 129); diff --git a/cast/common/channel/connection_namespace_handler_unittest.cc b/cast/common/channel/connection_namespace_handler_unittest.cc index 5686fb74..17936818 100644 --- a/cast/common/channel/connection_namespace_handler_unittest.cc +++ b/cast/common/channel/connection_namespace_handler_unittest.cc @@ -30,7 +30,10 @@ class MockSocketErrorHandler : public VirtualConnectionRouter::SocketErrorHandler { public: MOCK_METHOD(void, OnClose, (CastSocket * socket), (override)); - MOCK_METHOD(void, OnError, (CastSocket * socket, Error error), (override)); + MOCK_METHOD(void, + OnError, + (CastSocket * socket, openscreen::Error error), + (override)); }; class MockVirtualConnectionPolicy diff --git a/cast/common/channel/test/fake_cast_socket.h b/cast/common/channel/test/fake_cast_socket.h index 5efcab0e..105bfe70 100644 --- a/cast/common/channel/test/fake_cast_socket.h +++ b/cast/common/channel/test/fake_cast_socket.h @@ -14,19 +14,14 @@ namespace cast { namespace channel { -using ::testing::_; -using ::testing::Invoke; -using ::testing::NiceMock; - -using openscreen::IPEndpoint; -using openscreen::platform::MockTlsConnection; -using openscreen::platform::TlsConnection; - class MockCastSocketClient final : public CastSocket::Client { public: ~MockCastSocketClient() override = default; - MOCK_METHOD(void, OnError, (CastSocket * socket, Error error), (override)); + MOCK_METHOD(void, + OnError, + (CastSocket * socket, openscreen::Error error), + (override)); MOCK_METHOD(void, OnMessage, (CastSocket * socket, CastMessage message), @@ -36,17 +31,19 @@ class MockCastSocketClient final : public CastSocket::Client { struct FakeCastSocket { FakeCastSocket() : FakeCastSocket({{10, 0, 1, 7}, 1234}, {{10, 0, 1, 9}, 4321}) {} - FakeCastSocket(const IPEndpoint& local, const IPEndpoint& remote) + FakeCastSocket(const openscreen::IPEndpoint& local, + const openscreen::IPEndpoint& remote) : local(local), remote(remote), - moved_connection(new MockTlsConnection(local, remote)), + moved_connection( + std::make_unique(local, remote)), connection(moved_connection.get()), socket(std::move(moved_connection), &mock_client, 1) {} - IPEndpoint local; - IPEndpoint remote; - std::unique_ptr moved_connection; - MockTlsConnection* connection; + openscreen::IPEndpoint local; + openscreen::IPEndpoint remote; + std::unique_ptr moved_connection; + openscreen::MockTlsConnection* connection; MockCastSocketClient mock_client; CastSocket socket; }; @@ -57,16 +54,22 @@ struct FakeCastSocket { // |mock_client|. struct FakeCastSocketPair { FakeCastSocketPair() { - std::unique_ptr> moved_connection{ - new NiceMock(local, remote)}; + using ::testing::_; + using ::testing::Invoke; + + auto moved_connection = + std::make_unique<::testing::NiceMock>( + local, remote); connection = moved_connection.get(); - socket.reset(new CastSocket(std::move(moved_connection), &mock_client, 1)); + socket = std::make_unique(std::move(moved_connection), + &mock_client, 1); - std::unique_ptr> moved_peer{ - new NiceMock(remote, local)}; + auto moved_peer = + std::make_unique<::testing::NiceMock>( + remote, local); peer_connection = moved_peer.get(); - peer_socket.reset( - new CastSocket(std::move(moved_peer), &mock_peer_client, 2)); + peer_socket = std::make_unique(std::move(moved_peer), + &mock_peer_client, 2); ON_CALL(*connection, Write(_, _)) .WillByDefault(Invoke([this](const void* data, size_t len) { @@ -83,14 +86,14 @@ struct FakeCastSocketPair { } ~FakeCastSocketPair() = default; - IPEndpoint local{{10, 0, 1, 7}, 1234}; - IPEndpoint remote{{10, 0, 1, 9}, 4321}; + openscreen::IPEndpoint local{{10, 0, 1, 7}, 1234}; + openscreen::IPEndpoint remote{{10, 0, 1, 9}, 4321}; - NiceMock* connection; + ::testing::NiceMock* connection; MockCastSocketClient mock_client; std::unique_ptr socket; - NiceMock* peer_connection; + ::testing::NiceMock* peer_connection; MockCastSocketClient mock_peer_client; std::unique_ptr peer_socket; }; diff --git a/cast/common/channel/virtual_connection_router.cc b/cast/common/channel/virtual_connection_router.cc index e141e993..85df78d9 100644 --- a/cast/common/channel/virtual_connection_router.cc +++ b/cast/common/channel/virtual_connection_router.cc @@ -14,6 +14,8 @@ namespace cast { namespace channel { +using openscreen::Error; + VirtualConnectionRouter::VirtualConnectionRouter( VirtualConnectionManager* vc_manager) : vc_manager_(vc_manager) { diff --git a/cast/common/channel/virtual_connection_router.h b/cast/common/channel/virtual_connection_router.h index 58879f0a..745995cc 100644 --- a/cast/common/channel/virtual_connection_router.h +++ b/cast/common/channel/virtual_connection_router.h @@ -43,7 +43,7 @@ class VirtualConnectionRouter final : public CastSocket::Client { class SocketErrorHandler { public: virtual void OnClose(CastSocket* socket) = 0; - virtual void OnError(CastSocket* socket, Error error) = 0; + virtual void OnError(CastSocket* socket, openscreen::Error error) = 0; }; explicit VirtualConnectionRouter(VirtualConnectionManager* vc_manager); @@ -58,10 +58,11 @@ class VirtualConnectionRouter final : public CastSocket::Client { std::unique_ptr socket); void CloseSocket(uint32_t id); - Error SendMessage(VirtualConnection virtual_conn, CastMessage&& message); + openscreen::Error SendMessage(VirtualConnection virtual_conn, + CastMessage&& message); // CastSocket::Client overrides. - void OnError(CastSocket* socket, Error error) override; + void OnError(CastSocket* socket, openscreen::Error error) override; void OnMessage(CastSocket* socket, CastMessage message) override; private: diff --git a/cast/common/channel/virtual_connection_router_unittest.cc b/cast/common/channel/virtual_connection_router_unittest.cc index 12d82f90..3c68db8b 100644 --- a/cast/common/channel/virtual_connection_router_unittest.cc +++ b/cast/common/channel/virtual_connection_router_unittest.cc @@ -23,7 +23,10 @@ class MockSocketErrorHandler : public VirtualConnectionRouter::SocketErrorHandler { public: MOCK_METHOD(void, OnClose, (CastSocket * socket), (override)); - MOCK_METHOD(void, OnError, (CastSocket * socket, Error error), (override)); + MOCK_METHOD(void, + OnError, + (CastSocket * socket, openscreen::Error error), + (override)); }; class VirtualConnectionRouterTest : public ::testing::Test { diff --git a/cast/sender/channel/cast_auth_util.cc b/cast/sender/channel/cast_auth_util.cc index 9f706259..90d63f77 100644 --- a/cast/sender/channel/cast_auth_util.cc +++ b/cast/sender/channel/cast_auth_util.cc @@ -84,11 +84,11 @@ class CastNonce { OSP_CHECK_EQ( RAND_bytes(reinterpret_cast(&nonce_[0]), kNonceSizeInBytes), 1); - nonce_generation_time_ = openscreen::platform::GetWallTimeSinceUnixEpoch(); + nonce_generation_time_ = openscreen::GetWallTimeSinceUnixEpoch(); } void EnsureNonceTimely() { - if (openscreen::platform::GetWallTimeSinceUnixEpoch() > + if (openscreen::GetWallTimeSinceUnixEpoch() > (nonce_generation_time_ + std::chrono::hours(kNonceExpirationTimeInHours))) { GenerateNonce(); @@ -233,7 +233,7 @@ ErrorOr AuthenticateChallengeReply( } result = VerifyTLSCertificateValidity( - peer_cert, openscreen::platform::GetWallTimeSinceUnixEpoch()); + peer_cert, openscreen::GetWallTimeSinceUnixEpoch()); if (!result.ok()) { return result; } @@ -354,7 +354,7 @@ ErrorOr VerifyCredentials( bool enforce_sha256_checking) { certificate::DateTime now = {}; OSP_CHECK(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); certificate::CRLPolicy policy = (enforce_revocation_checking) ? certificate::CRLPolicy::kCrlRequired : certificate::CRLPolicy::kCrlOptional; diff --git a/cast/sender/channel/cast_auth_util_unittest.cc b/cast/sender/channel/cast_auth_util_unittest.cc index 6ea4ea6a..b8a8e90c 100644 --- a/cast/sender/channel/cast_auth_util_unittest.cc +++ b/cast/sender/channel/cast_auth_util_unittest.cc @@ -157,7 +157,7 @@ TEST_F(CastAuthUtilTest, VerifySuccess) { AuthResponse auth_response = CreateAuthResponse(&signed_data, SHA256); certificate::DateTime now = {}; ASSERT_TRUE(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); ErrorOr result = VerifyCredentialsForTest( auth_response, signed_data, certificate::CRLPolicy::kCrlOptional, nullptr, nullptr, now); @@ -210,7 +210,7 @@ TEST_F(CastAuthUtilTest, VerifyUnsupportedDigest) { AuthResponse auth_response = CreateAuthResponse(&signed_data, SHA1); certificate::DateTime now = {}; ASSERT_TRUE(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); ErrorOr result = VerifyCredentialsForTest( auth_response, signed_data, certificate::CRLPolicy::kCrlOptional, nullptr, nullptr, now, true); @@ -223,7 +223,7 @@ TEST_F(CastAuthUtilTest, VerifyBackwardsCompatibleDigest) { AuthResponse auth_response = CreateAuthResponse(&signed_data, SHA1); certificate::DateTime now = {}; ASSERT_TRUE(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); ErrorOr result = VerifyCredentialsForTest( auth_response, signed_data, certificate::CRLPolicy::kCrlOptional, nullptr, nullptr, now); diff --git a/cast/sender/channel/sender_socket_factory.cc b/cast/sender/channel/sender_socket_factory.cc index 3e75c977..b185113d 100644 --- a/cast/sender/channel/sender_socket_factory.cc +++ b/cast/sender/channel/sender_socket_factory.cc @@ -12,7 +12,11 @@ namespace cast { namespace channel { -using openscreen::platform::TlsConnectOptions; +using openscreen::Error; +using openscreen::IPEndpoint; +using openscreen::TlsConnection; +using openscreen::TlsConnectionFactory; +using openscreen::TlsConnectOptions; bool operator<(const std::unique_ptr& a, uint32_t b) { diff --git a/cast/sender/channel/sender_socket_factory.h b/cast/sender/channel/sender_socket_factory.h index 63998674..c58b369a 100644 --- a/cast/sender/channel/sender_socket_factory.h +++ b/cast/sender/channel/sender_socket_factory.h @@ -20,23 +20,18 @@ namespace cast { namespace channel { -using openscreen::Error; -using openscreen::IPEndpoint; -using openscreen::IPEndpointComparator; -using openscreen::platform::TlsConnection; -using openscreen::platform::TlsConnectionFactory; - -class SenderSocketFactory final : public TlsConnectionFactory::Client, - public CastSocket::Client { +class SenderSocketFactory final + : public openscreen::TlsConnectionFactory::Client, + public CastSocket::Client { public: class Client { public: virtual void OnConnected(SenderSocketFactory* factory, - const IPEndpoint& endpoint, + const openscreen::IPEndpoint& endpoint, std::unique_ptr socket) = 0; virtual void OnError(SenderSocketFactory* factory, - const IPEndpoint& endpoint, - Error error) = 0; + const openscreen::IPEndpoint& endpoint, + openscreen::Error error) = 0; }; enum class DeviceMediaPolicy { @@ -48,35 +43,39 @@ class SenderSocketFactory final : public TlsConnectionFactory::Client, explicit SenderSocketFactory(Client* client); ~SenderSocketFactory(); - void set_factory(TlsConnectionFactory* factory) { + void set_factory(openscreen::TlsConnectionFactory* factory) { OSP_DCHECK(factory); factory_ = factory; } - void Connect(const IPEndpoint& endpoint, + void Connect(const openscreen::IPEndpoint& endpoint, DeviceMediaPolicy media_policy, CastSocket::Client* client); - // TlsConnectionFactory::Client overrides. - void OnAccepted(TlsConnectionFactory* factory, - std::vector der_x509_peer_cert, - std::unique_ptr connection) override; - void OnConnected(TlsConnectionFactory* factory, - std::vector der_x509_peer_cert, - std::unique_ptr connection) override; - void OnConnectionFailed(TlsConnectionFactory* factory, - const IPEndpoint& remote_address) override; - void OnError(TlsConnectionFactory* factory, Error error) override; + // openscreen::TlsConnectionFactory::Client overrides. + void OnAccepted( + openscreen::TlsConnectionFactory* factory, + std::vector der_x509_peer_cert, + std::unique_ptr connection) override; + void OnConnected( + openscreen::TlsConnectionFactory* factory, + std::vector der_x509_peer_cert, + std::unique_ptr connection) override; + void OnConnectionFailed( + openscreen::TlsConnectionFactory* factory, + const openscreen::IPEndpoint& remote_address) override; + void OnError(openscreen::TlsConnectionFactory* factory, + openscreen::Error error) override; private: struct PendingConnection { - IPEndpoint endpoint; + openscreen::IPEndpoint endpoint; DeviceMediaPolicy media_policy; CastSocket::Client* client; }; struct PendingAuth { - IPEndpoint endpoint; + openscreen::IPEndpoint endpoint; DeviceMediaPolicy media_policy; std::unique_ptr socket; CastSocket::Client* client; @@ -88,14 +87,14 @@ class SenderSocketFactory final : public TlsConnectionFactory::Client, friend bool operator<(uint32_t a, const std::unique_ptr& b); std::vector::iterator FindPendingConnection( - const IPEndpoint& endpoint); + const openscreen::IPEndpoint& endpoint); // CastSocket::Client overrides. - void OnError(CastSocket* socket, Error error) override; + void OnError(CastSocket* socket, openscreen::Error error) override; void OnMessage(CastSocket* socket, CastMessage message) override; Client* const client_; - TlsConnectionFactory* factory_ = nullptr; + openscreen::TlsConnectionFactory* factory_ = nullptr; std::vector pending_connections_; std::vector> pending_auth_; }; diff --git a/cast/standalone_receiver/main.cc b/cast/standalone_receiver/main.cc index 76e7a8d2..fd4676ea 100644 --- a/cast/standalone_receiver/main.cc +++ b/cast/standalone_receiver/main.cc @@ -27,10 +27,10 @@ #include "cast/standalone_receiver/dummy_player.h" #endif // defined(CAST_STREAMING_HAVE_EXTERNAL_LIBS_FOR_DEMO_APPS) +using openscreen::Clock; using openscreen::IPEndpoint; -using openscreen::platform::Clock; -using openscreen::platform::TaskRunner; -using openscreen::platform::TaskRunnerImpl; +using openscreen::TaskRunner; +using openscreen::TaskRunnerImpl; namespace cast { namespace streaming { @@ -157,9 +157,8 @@ void DemoMain(TaskRunnerImpl* task_runner) { } // namespace cast int main(int argc, const char* argv[]) { - using openscreen::platform::PlatformClientPosix; - - class PlatformClientExposingTaskRunner : public PlatformClientPosix { + class PlatformClientExposingTaskRunner + : public openscreen::PlatformClientPosix { public: explicit PlatformClientExposingTaskRunner( std::unique_ptr task_runner) @@ -170,12 +169,12 @@ int main(int argc, const char* argv[]) { } }; - openscreen::platform::SetLogLevel(openscreen::platform::LogLevel::kInfo); + openscreen::SetLogLevel(openscreen::LogLevel::kInfo); auto* const platform_client = new PlatformClientExposingTaskRunner( std::make_unique(&Clock::now)); cast::streaming::DemoMain(static_cast( - PlatformClientPosix::GetInstance()->GetTaskRunner())); + openscreen::PlatformClientPosix::GetInstance()->GetTaskRunner())); platform_client->ShutDown(); // Deletes |platform_client|. return 0; diff --git a/cast/standalone_receiver/sdl_audio_player.cc b/cast/standalone_receiver/sdl_audio_player.cc index 8a58870e..cbd99859 100644 --- a/cast/standalone_receiver/sdl_audio_player.cc +++ b/cast/standalone_receiver/sdl_audio_player.cc @@ -16,11 +16,11 @@ using std::chrono::duration_cast; using std::chrono::milliseconds; using std::chrono::seconds; +using openscreen::Clock; +using openscreen::ClockNowFunctionPtr; using openscreen::Error; using openscreen::ErrorOr; -using openscreen::platform::Clock; -using openscreen::platform::ClockNowFunctionPtr; -using openscreen::platform::TaskRunner; +using openscreen::TaskRunner; namespace cast { namespace streaming { diff --git a/cast/standalone_receiver/sdl_audio_player.h b/cast/standalone_receiver/sdl_audio_player.h index d7a4b0ea..89c37146 100644 --- a/cast/standalone_receiver/sdl_audio_player.h +++ b/cast/standalone_receiver/sdl_audio_player.h @@ -16,8 +16,8 @@ class SDLAudioPlayer : public SDLPlayerBase { public: // |error_callback| is run only if a fatal error occurs, at which point the // player has halted and set |error_status()|. - SDLAudioPlayer(openscreen::platform::ClockNowFunctionPtr now_function, - openscreen::platform::TaskRunner* task_runner, + SDLAudioPlayer(openscreen::ClockNowFunctionPtr now_function, + openscreen::TaskRunner* task_runner, Receiver* receiver, std::function error_callback); @@ -25,7 +25,7 @@ class SDLAudioPlayer : public SDLPlayerBase { private: // SDLPlayerBase implementation. - openscreen::ErrorOr RenderNextFrame( + openscreen::ErrorOr RenderNextFrame( const SDLPlayerBase::PresentableFrame& frame) final; bool RenderWhileIdle(const SDLPlayerBase::PresentableFrame* frame) final; void Present() final; @@ -38,7 +38,7 @@ class SDLAudioPlayer : public SDLPlayerBase { // The amount of time before a target presentation time to call Present(), to // account for audio buffering (the latency until samples reach the hardware). - openscreen::platform::Clock::duration approximate_lead_time_{}; + openscreen::Clock::duration approximate_lead_time_{}; // When the decoder provides planar data, this buffer is used for storing the // interleaved conversion. diff --git a/cast/standalone_receiver/sdl_glue.cc b/cast/standalone_receiver/sdl_glue.cc index 4d12b057..300b2492 100644 --- a/cast/standalone_receiver/sdl_glue.cc +++ b/cast/standalone_receiver/sdl_glue.cc @@ -8,8 +8,8 @@ #include "platform/api/time.h" #include "util/logging.h" -using openscreen::platform::Clock; -using openscreen::platform::TaskRunner; +using openscreen::Clock; +using openscreen::TaskRunner; namespace cast { namespace streaming { diff --git a/cast/standalone_receiver/sdl_glue.h b/cast/standalone_receiver/sdl_glue.h index 2900bf57..c4674211 100644 --- a/cast/standalone_receiver/sdl_glue.h +++ b/cast/standalone_receiver/sdl_glue.h @@ -18,9 +18,7 @@ #include "util/alarm.h" namespace openscreen { -namespace platform { class TaskRunner; -} // namespace platform } // namespace openscreen namespace cast { @@ -65,7 +63,7 @@ DEFINE_SDL_UNIQUE_PTR(Texture); // event is received. class SDLEventLoopProcessor { public: - SDLEventLoopProcessor(openscreen::platform::TaskRunner* task_runner, + SDLEventLoopProcessor(openscreen::TaskRunner* task_runner, std::function quit_callback); ~SDLEventLoopProcessor(); diff --git a/cast/standalone_receiver/sdl_player_base.cc b/cast/standalone_receiver/sdl_player_base.cc index 0c5e6c9c..72c9af55 100644 --- a/cast/standalone_receiver/sdl_player_base.cc +++ b/cast/standalone_receiver/sdl_player_base.cc @@ -16,11 +16,11 @@ using std::chrono::duration_cast; using std::chrono::milliseconds; +using openscreen::Clock; +using openscreen::ClockNowFunctionPtr; using openscreen::Error; using openscreen::ErrorOr; -using openscreen::platform::Clock; -using openscreen::platform::ClockNowFunctionPtr; -using openscreen::platform::TaskRunner; +using openscreen::TaskRunner; namespace cast { namespace streaming { diff --git a/cast/standalone_receiver/sdl_player_base.h b/cast/standalone_receiver/sdl_player_base.h index 34fb278e..365846db 100644 --- a/cast/standalone_receiver/sdl_player_base.h +++ b/cast/standalone_receiver/sdl_player_base.h @@ -43,7 +43,7 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { // A decoded frame and its target presentation time. struct PresentableFrame { - openscreen::platform::Clock::time_point presentation_time; + openscreen::Clock::time_point presentation_time; AVFrameUniquePtr decoded_frame; PresentableFrame(); @@ -55,8 +55,8 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { // |error_callback| is run only if a fatal error occurs, at which point the // player has halted and set |error_status()|. |media_type| should be "audio" // or "video" (only used when logging). - SDLPlayerBase(openscreen::platform::ClockNowFunctionPtr now_function, - openscreen::platform::TaskRunner* task_runner, + SDLPlayerBase(openscreen::ClockNowFunctionPtr now_function, + openscreen::TaskRunner* task_runner, Receiver* receiver, std::function error_callback, const char* media_type); @@ -68,8 +68,8 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { void OnFatalError(std::string message) final; // Renders the |frame| and returns its [possibly adjusted] presentation time. - virtual openscreen::ErrorOr - RenderNextFrame(const PresentableFrame& frame) = 0; + virtual openscreen::ErrorOr RenderNextFrame( + const PresentableFrame& frame) = 0; // Called to render when the player has no new content, and returns true if a // Present() is necessary. |frame| may be null, if it is not available. This @@ -108,7 +108,7 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { // require rendering/presenting a different output. void ResumeRendering(); - const openscreen::platform::ClockNowFunctionPtr now_; + const openscreen::ClockNowFunctionPtr now_; Receiver* const receiver_; std::function error_callback_; // Run once by OnFatalError(). const char* const media_type_; // For logging only. @@ -123,7 +123,7 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { // Queue of frames currently being decoded and decoded frames awaiting // rendering. struct PendingFrame : public PresentableFrame { - openscreen::platform::Clock::time_point start_time; + openscreen::Clock::time_point start_time; PendingFrame(); ~PendingFrame(); @@ -139,7 +139,7 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { // whenever the media (RTP) timestamps drift too much away from the rate at // which the local clock ticks. This is important for A/V synchronization. RtpTimeTicks last_sync_rtp_timestamp_{}; - openscreen::platform::Clock::time_point last_sync_reference_time_{}; + openscreen::Clock::time_point last_sync_reference_time_{}; Decoder decoder_; @@ -149,7 +149,7 @@ class SDLPlayerBase : public Receiver::Consumer, public Decoder::Client { // A cumulative moving average of recent single-frame processing times // (consume + decode + render). This is passed to the Cast Receiver so that it // can determine when to drop late frames. - openscreen::platform::Clock::duration recent_processing_time_{}; + openscreen::Clock::duration recent_processing_time_{}; // Alarms that execute the various stages of the player pipeline at certain // times. diff --git a/cast/standalone_receiver/sdl_video_player.cc b/cast/standalone_receiver/sdl_video_player.cc index 250a76c0..f91a28a1 100644 --- a/cast/standalone_receiver/sdl_video_player.cc +++ b/cast/standalone_receiver/sdl_video_player.cc @@ -9,11 +9,11 @@ #include "cast/standalone_receiver/avcodec_glue.h" #include "util/logging.h" +using openscreen::Clock; +using openscreen::ClockNowFunctionPtr; using openscreen::Error; using openscreen::ErrorOr; -using openscreen::platform::Clock; -using openscreen::platform::ClockNowFunctionPtr; -using openscreen::platform::TaskRunner; +using openscreen::TaskRunner; namespace cast { namespace streaming { diff --git a/cast/standalone_receiver/sdl_video_player.h b/cast/standalone_receiver/sdl_video_player.h index 915881ea..515649d0 100644 --- a/cast/standalone_receiver/sdl_video_player.h +++ b/cast/standalone_receiver/sdl_video_player.h @@ -16,8 +16,8 @@ class SDLVideoPlayer : public SDLPlayerBase { public: // |error_callback| is run only if a fatal error occurs, at which point the // player has halted and set |error_status()|. - SDLVideoPlayer(openscreen::platform::ClockNowFunctionPtr now_function, - openscreen::platform::TaskRunner* task_runner, + SDLVideoPlayer(openscreen::ClockNowFunctionPtr now_function, + openscreen::TaskRunner* task_runner, Receiver* receiver, SDL_Renderer* renderer, std::function error_callback); @@ -32,7 +32,7 @@ class SDLVideoPlayer : public SDLPlayerBase { // Uploads the decoded picture in |frame| to a SDL texture and draws it using // the SDL |renderer_|. - openscreen::ErrorOr RenderNextFrame( + openscreen::ErrorOr RenderNextFrame( const SDLPlayerBase::PresentableFrame& frame) final; // Makes whatever is currently drawn to the SDL |renderer_| be presented diff --git a/cast/streaming/clock_drift_smoother.h b/cast/streaming/clock_drift_smoother.h index d48d166c..783c755c 100644 --- a/cast/streaming/clock_drift_smoother.h +++ b/cast/streaming/clock_drift_smoother.h @@ -17,7 +17,7 @@ namespace streaming { // moves at a rate based on the passage of time. class ClockDriftSmoother { public: - using Clock = openscreen::platform::Clock; + using Clock = openscreen::Clock; // |time_constant| is the amount of time an impulse signal takes to decay by // ~62.6%. Interpretation: If the value passed to several Update() calls is diff --git a/cast/streaming/compound_rtcp_builder.cc b/cast/streaming/compound_rtcp_builder.cc index b3cba68b..2593e95a 100644 --- a/cast/streaming/compound_rtcp_builder.cc +++ b/cast/streaming/compound_rtcp_builder.cc @@ -15,7 +15,7 @@ #include "util/std_util.h" using openscreen::AreElementsSortedAndUnique; -using openscreen::platform::Clock; +using openscreen::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/compound_rtcp_builder.h b/cast/streaming/compound_rtcp_builder.h index 58bc62fb..a2d8e26e 100644 --- a/cast/streaming/compound_rtcp_builder.h +++ b/cast/streaming/compound_rtcp_builder.h @@ -97,9 +97,8 @@ class CompoundRtcpBuilder { // should be monotonically increasing so the consuming side (the Sender) can // determine the chronological ordering of RTCP packets. The Sender might also // use this to estimate round-trip times over the network. - absl::Span BuildPacket( - openscreen::platform::Clock::time_point send_time, - absl::Span buffer); + absl::Span BuildPacket(openscreen::Clock::time_point send_time, + absl::Span buffer); // The required buffer size to be provided to BuildPacket(). This accounts for // all the possible headers and report structures that might be included, @@ -112,7 +111,7 @@ class CompoundRtcpBuilder { // |buffer| that will ultimately contain a "compound RTCP packet." void AppendReceiverReportPacket(absl::Span* buffer); void AppendReceiverReferenceTimeReportPacket( - openscreen::platform::Clock::time_point send_time, + openscreen::Clock::time_point send_time, absl::Span* buffer); void AppendPictureLossIndicatorPacket(absl::Span* buffer); void AppendCastFeedbackPacket(absl::Span* buffer); diff --git a/cast/streaming/compound_rtcp_builder_unittest.cc b/cast/streaming/compound_rtcp_builder_unittest.cc index ab6f8c00..c86859b9 100644 --- a/cast/streaming/compound_rtcp_builder_unittest.cc +++ b/cast/streaming/compound_rtcp_builder_unittest.cc @@ -15,7 +15,7 @@ #include "gtest/gtest.h" #include "platform/api/time.h" -using openscreen::platform::Clock; +using openscreen::Clock; using testing::_; using testing::Invoke; diff --git a/cast/streaming/compound_rtcp_parser.cc b/cast/streaming/compound_rtcp_parser.cc index af5336ea..b1ea4b67 100644 --- a/cast/streaming/compound_rtcp_parser.cc +++ b/cast/streaming/compound_rtcp_parser.cc @@ -11,7 +11,7 @@ #include "util/logging.h" #include "util/std_util.h" -using openscreen::platform::Clock; +using openscreen::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/compound_rtcp_parser.h b/cast/streaming/compound_rtcp_parser.h index c9b71594..1de12c3f 100644 --- a/cast/streaming/compound_rtcp_parser.h +++ b/cast/streaming/compound_rtcp_parser.h @@ -41,7 +41,7 @@ class CompoundRtcpParser { // Called when a Receiver Reference Time Report has been parsed. virtual void OnReceiverReferenceTimeAdvanced( - openscreen::platform::Clock::time_point reference_time); + openscreen::Clock::time_point reference_time); // Called when a Receiver Report with a Report Block has been parsed. virtual void OnReceiverReport(const RtcpReportBlock& receiver_report); @@ -103,7 +103,7 @@ class CompoundRtcpParser { std::vector* packet_nacks); bool ParseExtendedReports( absl::Span in, - openscreen::platform::Clock::time_point* receiver_reference_time); + openscreen::Clock::time_point* receiver_reference_time); bool ParsePictureLossIndicator(absl::Span in, bool* picture_loss_indicator); @@ -113,7 +113,7 @@ class CompoundRtcpParser { // Tracks the latest timestamp seen from any Receiver Reference Time Report, // and uses this to ignore stale RTCP packets that arrived out-of-order and/or // late from the network. - openscreen::platform::Clock::time_point latest_receiver_timestamp_; + openscreen::Clock::time_point latest_receiver_timestamp_; }; } // namespace streaming diff --git a/cast/streaming/compound_rtcp_parser_fuzzer.cc b/cast/streaming/compound_rtcp_parser_fuzzer.cc index af5823df..addc6283 100644 --- a/cast/streaming/compound_rtcp_parser_fuzzer.cc +++ b/cast/streaming/compound_rtcp_parser_fuzzer.cc @@ -25,7 +25,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wexit-time-destructors" static RtcpSession session(kSenderSsrcInSeedCorpus, kReceiverSsrcInSeedCorpus, - openscreen::platform::Clock::time_point{}); + openscreen::Clock::time_point{}); static CompoundRtcpParser::Client client_that_ignores_everything; static CompoundRtcpParser parser(&session, &client_that_ignores_everything); #pragma clang diagnostic pop diff --git a/cast/streaming/compound_rtcp_parser_unittest.cc b/cast/streaming/compound_rtcp_parser_unittest.cc index 863953af..f09224f9 100644 --- a/cast/streaming/compound_rtcp_parser_unittest.cc +++ b/cast/streaming/compound_rtcp_parser_unittest.cc @@ -32,8 +32,7 @@ class CompoundRtcpParserTest : public testing::Test { CompoundRtcpParser* parser() { return &parser_; } private: - RtcpSession session_{kSenderSsrc, kReceiverSsrc, - openscreen::platform::Clock::now()}; + RtcpSession session_{kSenderSsrc, kReceiverSsrc, openscreen::Clock::now()}; StrictMock client_; CompoundRtcpParser parser_{&session_, &client_}; }; diff --git a/cast/streaming/encoded_frame.h b/cast/streaming/encoded_frame.h index b42b6340..cf36b61a 100644 --- a/cast/streaming/encoded_frame.h +++ b/cast/streaming/encoded_frame.h @@ -78,7 +78,7 @@ struct EncodedFrame { // (see |rtp_timestamp|, above). It is also meant to be used to synchronize // the presentation of multiple streams (e.g., audio and video), commonly // known as "lip-sync." It is NOT meant to be a mandatory/exact playout time. - openscreen::platform::Clock::time_point reference_time; + openscreen::Clock::time_point reference_time; // Playout delay for this and all future frames. Used by the Adaptive // Playout delay extension. Non-positive values means no change. diff --git a/cast/streaming/environment.cc b/cast/streaming/environment.cc index 954a2e0c..55094a4e 100644 --- a/cast/streaming/environment.cc +++ b/cast/streaming/environment.cc @@ -8,15 +8,15 @@ #include "platform/api/task_runner.h" #include "util/logging.h" +using openscreen::Clock; +using openscreen::ClockNowFunctionPtr; using openscreen::Error; using openscreen::ErrorOr; using openscreen::IPAddress; using openscreen::IPEndpoint; -using openscreen::platform::Clock; -using openscreen::platform::ClockNowFunctionPtr; -using openscreen::platform::TaskRunner; -using openscreen::platform::UdpPacket; -using openscreen::platform::UdpSocket; +using openscreen::TaskRunner; +using openscreen::UdpPacket; +using openscreen::UdpSocket; namespace cast { namespace streaming { @@ -124,10 +124,10 @@ void Environment::OnRead(UdpSocket* socket, // Ideally, the arrival time would come from the operating system's network // stack (e.g., by using the SO_TIMESTAMP sockopt on POSIX systems). However, // there would still be the problem of mapping the timestamp to a value in - // terms of platform::Clock. So, just sample the Clock here and call that the - // "arrival time." While this can add variance within the system, it should be - // minimal, assuming not too much time has elapsed between the actual packet - // receive event and the when this code here is executing. + // terms of Clock::time_point. So, just sample the Clock here and call that + // the "arrival time." While this can add variance within the system, it + // should be minimal, assuming not too much time has elapsed between the + // actual packet receive event and the when this code here is executing. const Clock::time_point arrival_time = now_function_(); UdpPacket packet = std::move(packet_or_error.value()); diff --git a/cast/streaming/environment.h b/cast/streaming/environment.h index 0bc99f2d..5fb613f5 100644 --- a/cast/streaming/environment.h +++ b/cast/streaming/environment.h @@ -16,9 +16,7 @@ #include "platform/base/ip_address.h" namespace openscreen { -namespace platform { class TaskRunner; -} // namespace platform } // namespace openscreen namespace cast { @@ -26,14 +24,13 @@ namespace streaming { // Provides the common environment for operating system resources shared by // multiple components. -class Environment : public openscreen::platform::UdpSocket::Client { +class Environment : public openscreen::UdpSocket::Client { public: class PacketConsumer { public: - virtual void OnReceivedPacket( - const openscreen::IPEndpoint& source, - openscreen::platform::Clock::time_point arrival_time, - std::vector packet) = 0; + virtual void OnReceivedPacket(const openscreen::IPEndpoint& source, + openscreen::Clock::time_point arrival_time, + std::vector packet) = 0; protected: virtual ~PacketConsumer(); @@ -42,16 +39,14 @@ class Environment : public openscreen::platform::UdpSocket::Client { // Construct with the given clock source and TaskRunner. Creates and // internally-owns a UdpSocket, and immediately binds it to the given // |local_endpoint|. - Environment(openscreen::platform::ClockNowFunctionPtr now_function, - openscreen::platform::TaskRunner* task_runner, + Environment(openscreen::ClockNowFunctionPtr now_function, + openscreen::TaskRunner* task_runner, const openscreen::IPEndpoint& local_endpoint); ~Environment() override; - openscreen::platform::ClockNowFunctionPtr now_function() const { - return now_function_; - } - openscreen::platform::TaskRunner* task_runner() const { return task_runner_; } + openscreen::ClockNowFunctionPtr now_function() const { return now_function_; } + openscreen::TaskRunner* task_runner() const { return task_runner_; } // Returns the local endpoint the socket is bound to, or the zero IPEndpoint // if socket creation/binding failed. @@ -98,25 +93,23 @@ class Environment : public openscreen::platform::UdpSocket::Client { // Common constructor that just stores the injected dependencies and does not // create a socket. Subclasses use this to provide an alternative packet // receive/send mechanism (e.g., for testing). - Environment(openscreen::platform::ClockNowFunctionPtr now_function, - openscreen::platform::TaskRunner* task_runner); + Environment(openscreen::ClockNowFunctionPtr now_function, + openscreen::TaskRunner* task_runner); private: - // openscreen::platform::UdpSocket::Client implementation. - void OnError(openscreen::platform::UdpSocket* socket, - openscreen::Error error) final; - void OnSendError(openscreen::platform::UdpSocket* socket, + // openscreen::UdpSocket::Client implementation. + void OnError(openscreen::UdpSocket* socket, openscreen::Error error) final; + void OnSendError(openscreen::UdpSocket* socket, openscreen::Error error) final; - void OnRead(openscreen::platform::UdpSocket* socket, - openscreen::ErrorOr - packet_or_error) final; + void OnRead(openscreen::UdpSocket* socket, + openscreen::ErrorOr packet_or_error) final; - const openscreen::platform::ClockNowFunctionPtr now_function_; - openscreen::platform::TaskRunner* const task_runner_; + const openscreen::ClockNowFunctionPtr now_function_; + openscreen::TaskRunner* const task_runner_; // The UDP socket bound to the local endpoint that was passed into the // constructor, or null if socket creation failed. - const std::unique_ptr socket_; + const std::unique_ptr socket_; // These are externally set/cleared. Behaviors are described in getter/setter // method comments above. diff --git a/cast/streaming/mock_compound_rtcp_parser_client.h b/cast/streaming/mock_compound_rtcp_parser_client.h index 0b16e599..4411e98a 100644 --- a/cast/streaming/mock_compound_rtcp_parser_client.h +++ b/cast/streaming/mock_compound_rtcp_parser_client.h @@ -14,7 +14,7 @@ namespace streaming { class MockCompoundRtcpParserClient : public CompoundRtcpParser::Client { public: MOCK_METHOD1(OnReceiverReferenceTimeAdvanced, - void(openscreen::platform::Clock::time_point reference_time)); + void(openscreen::Clock::time_point reference_time)); MOCK_METHOD1(OnReceiverReport, void(const RtcpReportBlock& receiver_report)); MOCK_METHOD0(OnReceiverIndicatesPictureLoss, void()); MOCK_METHOD2(OnReceiverCheckpoint, diff --git a/cast/streaming/ntp_time.cc b/cast/streaming/ntp_time.cc index d7072baf..5bead4ba 100644 --- a/cast/streaming/ntp_time.cc +++ b/cast/streaming/ntp_time.cc @@ -6,7 +6,7 @@ #include "util/logging.h" -using openscreen::platform::Clock; +using openscreen::Clock; using std::chrono::duration_cast; namespace cast { diff --git a/cast/streaming/ntp_time.h b/cast/streaming/ntp_time.h index f76dae4a..7330148c 100644 --- a/cast/streaming/ntp_time.h +++ b/cast/streaming/ntp_time.h @@ -41,8 +41,8 @@ constexpr NtpTimestamp AssembleNtpTimestamp(NtpSeconds seconds, static_cast(fraction.count()); } -// Converts between openscreen::platform::Clock::time_points and NtpTimestamps. -// The class is instantiated with the current openscreen::platform::Clock time +// Converts between openscreen::Clock::time_points and NtpTimestamps. +// The class is instantiated with the current openscreen::Clock time // and the current wall clock time, and these are used to determine a fixed // origin reference point for all conversions. Thus, to avoid introducing // unintended timing-related behaviors, only one NtpTimeConverter instance @@ -50,15 +50,13 @@ constexpr NtpTimestamp AssembleNtpTimestamp(NtpSeconds seconds, // session. class NtpTimeConverter { public: - NtpTimeConverter(openscreen::platform::Clock::time_point now, + NtpTimeConverter(openscreen::Clock::time_point now, std::chrono::seconds since_unix_epoch = - openscreen::platform::GetWallTimeSinceUnixEpoch()); + openscreen::GetWallTimeSinceUnixEpoch()); ~NtpTimeConverter(); - NtpTimestamp ToNtpTimestamp( - openscreen::platform::Clock::time_point time_point) const; - openscreen::platform::Clock::time_point ToLocalTime( - NtpTimestamp timestamp) const; + NtpTimestamp ToNtpTimestamp(openscreen::Clock::time_point time_point) const; + openscreen::Clock::time_point ToLocalTime(NtpTimestamp timestamp) const; private: // The time point on the platform clock's timeline that corresponds to @@ -68,7 +66,7 @@ class NtpTimeConverter { // can be off (with respect to each other) by even a large amount; and all // that matters is that time ticks forward at a reasonable pace from some // initial point. - const openscreen::platform::Clock::time_point start_time_; + const openscreen::Clock::time_point start_time_; const NtpSeconds since_ntp_epoch_; }; diff --git a/cast/streaming/ntp_time_unittest.cc b/cast/streaming/ntp_time_unittest.cc index 552673c0..6c72a187 100644 --- a/cast/streaming/ntp_time_unittest.cc +++ b/cast/streaming/ntp_time_unittest.cc @@ -6,7 +6,7 @@ #include "gtest/gtest.h" -using openscreen::platform::Clock; +using openscreen::Clock; using std::chrono::duration_cast; using std::chrono::microseconds; using std::chrono::milliseconds; @@ -74,7 +74,7 @@ TEST(NtpTimeConverterTest, ConvertsToNtpTimeAndBack) { // should be looked into! const Clock::time_point steady_clock_start = Clock::now(); const std::chrono::seconds wall_clock_start = - openscreen::platform::GetWallTimeSinceUnixEpoch(); + openscreen::GetWallTimeSinceUnixEpoch(); SCOPED_TRACE(::testing::Message() << "steady_clock_start.time_since_epoch().count() is " << steady_clock_start.time_since_epoch().count() diff --git a/cast/streaming/packet_receive_stats_tracker.cc b/cast/streaming/packet_receive_stats_tracker.cc index 0d7f268e..c00af536 100644 --- a/cast/streaming/packet_receive_stats_tracker.cc +++ b/cast/streaming/packet_receive_stats_tracker.cc @@ -6,7 +6,7 @@ #include -using openscreen::platform::Clock; +using openscreen::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/packet_receive_stats_tracker.h b/cast/streaming/packet_receive_stats_tracker.h index e579f76f..a13696bf 100644 --- a/cast/streaming/packet_receive_stats_tracker.h +++ b/cast/streaming/packet_receive_stats_tracker.h @@ -29,10 +29,9 @@ class PacketReceiveStatsTracker { // RtpPacketParser::ParseResult. |arrival_time| is when the packet was // received (i.e., right-off the network socket, before any // processing/parsing). - void OnReceivedValidRtpPacket( - uint16_t sequence_number, - RtpTimeTicks rtp_timestamp, - openscreen::platform::Clock::time_point arrival_time); + void OnReceivedValidRtpPacket(uint16_t sequence_number, + RtpTimeTicks rtp_timestamp, + openscreen::Clock::time_point arrival_time); // Populates *only* those fields in the given |report| that pertain to packet // loss, jitter, and the latest-known RTP packet sequence number. @@ -89,7 +88,7 @@ class PacketReceiveStatsTracker { // The time the last RTP packet was received. This is used in the computation // that updates |jitter_|. - openscreen::platform::Clock::time_point last_rtp_packet_arrival_time_; + openscreen::Clock::time_point last_rtp_packet_arrival_time_; // The RTP timestamp of the last RTP packet received. This is used in the // computation that updates |jitter_|. @@ -98,7 +97,7 @@ class PacketReceiveStatsTracker { // The interarrival jitter. See RFC 3550 spec, section 6.4.1. The Cast // Streaming spec diverges from the algorithm in the RFC spec in that it uses // different pieces of timing data to calculate this metric. - openscreen::platform::Clock::duration jitter_; + openscreen::Clock::duration jitter_; }; } // namespace streaming diff --git a/cast/streaming/packet_receive_stats_tracker_unittest.cc b/cast/streaming/packet_receive_stats_tracker_unittest.cc index 1532741f..c386a799 100644 --- a/cast/streaming/packet_receive_stats_tracker_unittest.cc +++ b/cast/streaming/packet_receive_stats_tracker_unittest.cc @@ -9,7 +9,7 @@ #include "cast/streaming/constants.h" #include "gtest/gtest.h" -using openscreen::platform::Clock; +using openscreen::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/receiver.cc b/cast/streaming/receiver.cc index 73a37eb2..b68ffd07 100644 --- a/cast/streaming/receiver.cc +++ b/cast/streaming/receiver.cc @@ -13,7 +13,7 @@ #include "util/logging.h" #include "util/std_util.h" -using openscreen::platform::Clock; +using openscreen::Clock; using std::chrono::duration_cast; using std::chrono::microseconds; diff --git a/cast/streaming/receiver.h b/cast/streaming/receiver.h index d1ea8b0c..5d786d94 100644 --- a/cast/streaming/receiver.h +++ b/cast/streaming/receiver.h @@ -143,8 +143,7 @@ class Receiver { // based on changing environmental conditions. // // Default setting: kDefaultPlayerProcessingTime - void SetPlayerProcessingTime( - openscreen::platform::Clock::duration needed_time); + void SetPlayerProcessingTime(openscreen::Clock::duration needed_time); // Propagates a "picture loss indicator" notification to the Sender, // requesting a key frame so that decode/playout can recover. It is safe to @@ -185,11 +184,10 @@ class Receiver { // Called by ReceiverPacketRouter to provide this Receiver with what looks // like a RTP/RTCP packet meant for it specifically (among other Receivers). - void OnReceivedRtpPacket(openscreen::platform::Clock::time_point arrival_time, + void OnReceivedRtpPacket(openscreen::Clock::time_point arrival_time, std::vector packet); - void OnReceivedRtcpPacket( - openscreen::platform::Clock::time_point arrival_time, - std::vector packet); + void OnReceivedRtcpPacket(openscreen::Clock::time_point arrival_time, + std::vector packet); private: // An entry in the circular queue (see |pending_frames_|). @@ -200,8 +198,7 @@ class Receiver { // at the Sender. This is computed and assigned when the RTP packet with ID // 0 is processed. Add the target playout delay to this to get the target // playout time. - absl::optional - estimated_capture_time; + absl::optional estimated_capture_time; PendingFrame(); ~PendingFrame(); @@ -256,10 +253,9 @@ class Receiver { // Sets the |consumption_alarm_| to check whether any frames are ready, // including possibly skipping over late frames in order to make not-yet-late // frames become ready. The default argument value means "without delay." - void ScheduleFrameReadyCheck( - openscreen::platform::Clock::time_point when = {}); + void ScheduleFrameReadyCheck(openscreen::Clock::time_point when = {}); - const openscreen::platform::ClockNowFunctionPtr now_; + const openscreen::ClockNowFunctionPtr now_; ReceiverPacketRouter* const packet_router_; RtcpSession rtcp_session_; SenderReportParser rtcp_parser_; @@ -277,8 +273,8 @@ class Receiver { // Not scheduled until after this Receiver has processed the first packet from // the Sender. openscreen::Alarm rtcp_alarm_; - openscreen::platform::Clock::time_point last_rtcp_send_time_ = - openscreen::platform::Clock::time_point::min(); + openscreen::Clock::time_point last_rtcp_send_time_ = + openscreen::Clock::time_point::min(); // The last Sender Report received and when the packet containing it had // arrived. This contains lip-sync timestamps used as part of the calculation @@ -286,7 +282,7 @@ class Receiver { // back to the Sender in the Receiver Reports. It is nullopt until the first // parseable Sender Report is received. absl::optional last_sender_report_; - openscreen::platform::Clock::time_point last_sender_report_arrival_time_; + openscreen::Clock::time_point last_sender_report_arrival_time_; // Tracks the offset between the Receiver's [local] clock and the Sender's // clock. This is invalid until the first Sender Report has been successfully @@ -333,7 +329,7 @@ class Receiver { // The additional time needed to decode/play-out each frame after being // consumed from this Receiver. - openscreen::platform::Clock::duration player_processing_time_ = + openscreen::Clock::duration player_processing_time_ = kDefaultPlayerProcessingTime; // Scheduled to check whether there are frames ready and, if there are, to diff --git a/cast/streaming/receiver_packet_router.cc b/cast/streaming/receiver_packet_router.cc index 5e3d17bd..456a2ce8 100644 --- a/cast/streaming/receiver_packet_router.cc +++ b/cast/streaming/receiver_packet_router.cc @@ -11,8 +11,8 @@ #include "cast/streaming/receiver.h" #include "util/logging.h" +using openscreen::Clock; using openscreen::IPEndpoint; -using openscreen::platform::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/receiver_packet_router.h b/cast/streaming/receiver_packet_router.h index 88db08a8..007f41f1 100644 --- a/cast/streaming/receiver_packet_router.h +++ b/cast/streaming/receiver_packet_router.h @@ -48,7 +48,7 @@ class ReceiverPacketRouter final : public Environment::PacketConsumer { // Environment::PacketConsumer implementation. void OnReceivedPacket(const openscreen::IPEndpoint& source, - openscreen::platform::Clock::time_point arrival_time, + openscreen::Clock::time_point arrival_time, std::vector packet) final; // Helper to return an iterator pointing to the entry corresponding to the diff --git a/cast/streaming/receiver_session_unittest.cc b/cast/streaming/receiver_session_unittest.cc index e4e0eb43..5ce7c0a2 100644 --- a/cast/streaming/receiver_session_unittest.cc +++ b/cast/streaming/receiver_session_unittest.cc @@ -9,9 +9,9 @@ #include "platform/test/fake_clock.h" #include "platform/test/fake_task_runner.h" -using openscreen::platform::Clock; -using openscreen::platform::FakeClock; -using openscreen::platform::FakeTaskRunner; +using openscreen::Clock; +using openscreen::FakeClock; +using openscreen::FakeTaskRunner; using ::testing::_; using ::testing::Invoke; diff --git a/cast/streaming/receiver_unittest.cc b/cast/streaming/receiver_unittest.cc index 2426376a..e22d3a58 100644 --- a/cast/streaming/receiver_unittest.cc +++ b/cast/streaming/receiver_unittest.cc @@ -35,17 +35,17 @@ #include "platform/test/fake_task_runner.h" #include "util/logging.h" +using openscreen::Clock; +using openscreen::ClockNowFunctionPtr; using openscreen::Error; using openscreen::ErrorOr; +using openscreen::FakeClock; +using openscreen::FakeTaskRunner; using openscreen::IPAddress; using openscreen::IPEndpoint; -using openscreen::platform::Clock; -using openscreen::platform::ClockNowFunctionPtr; -using openscreen::platform::FakeClock; -using openscreen::platform::FakeTaskRunner; -using openscreen::platform::TaskRunner; -using openscreen::platform::UdpPacket; -using openscreen::platform::UdpSocket; +using openscreen::TaskRunner; +using openscreen::UdpPacket; +using openscreen::UdpSocket; using std::chrono::duration_cast; using std::chrono::microseconds; diff --git a/cast/streaming/rtcp_common.cc b/cast/streaming/rtcp_common.cc index 30d587a2..2a48ce51 100644 --- a/cast/streaming/rtcp_common.cc +++ b/cast/streaming/rtcp_common.cc @@ -9,8 +9,8 @@ #include "cast/streaming/packet_util.h" #include "util/saturate_cast.h" +using openscreen::Clock; using openscreen::saturate_cast; -using openscreen::platform::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/rtcp_common.h b/cast/streaming/rtcp_common.h index 3b6959c0..7e7cf963 100644 --- a/cast/streaming/rtcp_common.h +++ b/cast/streaming/rtcp_common.h @@ -116,8 +116,7 @@ struct RtcpReportBlock { // Convenience helper to convert the given |local_clock_delay| to the // RtcpReportBlock::Delay timebase, then clamp and assign it to // |delay_since_last_report|. - void SetDelaySinceLastReport( - openscreen::platform::Clock::duration local_clock_delay); + void SetDelaySinceLastReport(openscreen::Clock::duration local_clock_delay); // Serializes this report block in the first |kRtcpReportBlockSize| bytes of // the given |buffer| and adjusts |buffer| to point to the first byte after @@ -139,7 +138,7 @@ struct RtcpSenderReport { // common reference clock shared by all RTP streams; 2) the RTP timestamp on // the media capture/playout timeline. Together, these are used by a Receiver // to achieve A/V synchronization across RTP streams for playout. - openscreen::platform::Clock::time_point reference_time{}; + openscreen::Clock::time_point reference_time{}; RtpTimeTicks rtp_timestamp; // The total number of RTP packets transmitted since the start of the session diff --git a/cast/streaming/rtcp_common_unittest.cc b/cast/streaming/rtcp_common_unittest.cc index 8d088c2c..9cc6a3fe 100644 --- a/cast/streaming/rtcp_common_unittest.cc +++ b/cast/streaming/rtcp_common_unittest.cc @@ -11,7 +11,7 @@ #include "gtest/gtest.h" #include "platform/api/time.h" -using openscreen::platform::Clock; +using openscreen::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/rtcp_session.cc b/cast/streaming/rtcp_session.cc index a8b8ab6a..2b4af644 100644 --- a/cast/streaming/rtcp_session.cc +++ b/cast/streaming/rtcp_session.cc @@ -11,7 +11,7 @@ namespace streaming { RtcpSession::RtcpSession(Ssrc sender_ssrc, Ssrc receiver_ssrc, - openscreen::platform::Clock::time_point start_time) + openscreen::Clock::time_point start_time) : sender_ssrc_(sender_ssrc), receiver_ssrc_(receiver_ssrc), ntp_converter_(start_time) { diff --git a/cast/streaming/rtcp_session.h b/cast/streaming/rtcp_session.h index d896cb94..33a219cb 100644 --- a/cast/streaming/rtcp_session.h +++ b/cast/streaming/rtcp_session.h @@ -21,7 +21,7 @@ class RtcpSession { // world" wall time. RtcpSession(Ssrc sender_ssrc, Ssrc receiver_ssrc, - openscreen::platform::Clock::time_point start_time); + openscreen::Clock::time_point start_time); ~RtcpSession(); Ssrc sender_ssrc() const { return sender_ssrc_; } diff --git a/cast/streaming/rtp_packetizer.cc b/cast/streaming/rtp_packetizer.cc index 675a4a97..3e0bd506 100644 --- a/cast/streaming/rtp_packetizer.cc +++ b/cast/streaming/rtp_packetizer.cc @@ -14,7 +14,7 @@ #include "util/integer_division.h" #include "util/logging.h" -using openscreen::platform::Clock; +using openscreen::Clock; namespace cast { namespace streaming { diff --git a/cast/streaming/rtp_packetizer_unittest.cc b/cast/streaming/rtp_packetizer_unittest.cc index 52b460de..dc8bf8ac 100644 --- a/cast/streaming/rtp_packetizer_unittest.cc +++ b/cast/streaming/rtp_packetizer_unittest.cc @@ -42,7 +42,7 @@ class RtpPacketizerTest : public testing::Test { frame.frame_id = frame_id; frame.referenced_frame_id = is_key_frame ? frame_id : (frame_id - 1); frame.rtp_timestamp = RtpTimeTicks() + RtpTimeDelta::FromTicks(987); - frame.reference_time = openscreen::platform::Clock::now(); + frame.reference_time = openscreen::Clock::now(); frame.new_playout_delay = new_playout_delay; std::unique_ptr buffer(new uint8_t[payload_size]); diff --git a/cast/streaming/sender_report_parser_fuzzer.cc b/cast/streaming/sender_report_parser_fuzzer.cc index 8b9d8e74..8c91a6d2 100644 --- a/cast/streaming/sender_report_parser_fuzzer.cc +++ b/cast/streaming/sender_report_parser_fuzzer.cc @@ -24,7 +24,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wexit-time-destructors" static RtcpSession session(kSenderSsrcInSeedCorpus, kReceiverSsrcInSeedCorpus, - openscreen::platform::Clock::now()); + openscreen::Clock::now()); static SenderReportParser parser(&session); #pragma clang diagnostic pop diff --git a/cast/streaming/sender_report_unittest.cc b/cast/streaming/sender_report_unittest.cc index bad2cf0a..4f757fc0 100644 --- a/cast/streaming/sender_report_unittest.cc +++ b/cast/streaming/sender_report_unittest.cc @@ -25,8 +25,7 @@ class SenderReportTest : public testing::Test { } private: - RtcpSession session_{kSenderSsrc, kReceiverSsrc, - openscreen::platform::Clock::now()}; + RtcpSession session_{kSenderSsrc, kReceiverSsrc, openscreen::Clock::now()}; SenderReportBuilder builder_{&session_}; SenderReportParser parser_{&session_}; }; @@ -120,7 +119,7 @@ TEST_F(SenderReportTest, BuildPackets) { const bool with_report_block = (i == 1); RtcpSenderReport original; - original.reference_time = openscreen::platform::Clock::now(); + original.reference_time = openscreen::Clock::now(); original.rtp_timestamp = RtpTimeTicks() + RtpTimeDelta::FromTicks(5); original.send_packet_count = 55; original.send_octet_count = 20044; diff --git a/cast/streaming/ssrc.cc b/cast/streaming/ssrc.cc index d3f24469..cb18a800 100644 --- a/cast/streaming/ssrc.cc +++ b/cast/streaming/ssrc.cc @@ -28,7 +28,7 @@ Ssrc GenerateSsrc(bool higher_priority) { // it is light-weight and does not need to produce unguessable (nor // crypto-secure) values. static std::minstd_rand generator(static_cast( - openscreen::platform::Clock::now().time_since_epoch().count())); + openscreen::Clock::now().time_since_epoch().count())); std::uniform_int_distribution distribution( higher_priority ? kHigherPriorityMin : kNormalPriorityMin, -- cgit v1.2.3