From 6c94e91792ee57d97d7ce2fd337f0d6cfce62324 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 28 May 2022 16:53:40 +0800 Subject: [PATCH] SRT: Refine get_srt_poller to poller. --- trunk/src/app/srs_app_srt_conn.cpp | 2 +- trunk/src/app/srs_app_srt_listener.cpp | 2 +- trunk/src/app/srs_app_srt_server.hpp | 4 ++-- trunk/src/utest/srs_utest_srt.cpp | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/trunk/src/app/srs_app_srt_conn.cpp b/trunk/src/app/srs_app_srt_conn.cpp index 8986128ed..6cf2fe779 100644 --- a/trunk/src/app/srs_app_srt_conn.cpp +++ b/trunk/src/app/srs_app_srt_conn.cpp @@ -23,7 +23,7 @@ using namespace std; SrsSrtConnection::SrsSrtConnection(SRTSOCKET srt_fd) { srt_fd_ = srt_fd; - srt_skt_ = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_fd_); + srt_skt_ = new SrsSrtSocket(_srt_eventloop->poller(), srt_fd_); } SrsSrtConnection::~SrsSrtConnection() diff --git a/trunk/src/app/srs_app_srt_listener.cpp b/trunk/src/app/srs_app_srt_listener.cpp index f3b9951f4..5931ca93d 100644 --- a/trunk/src/app/srs_app_srt_listener.cpp +++ b/trunk/src/app/srs_app_srt_listener.cpp @@ -61,7 +61,7 @@ srs_error_t SrsSrtListener::listen() return srs_error_wrap(err, "srs_srt_listen"); } - srt_skt_ = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), lfd_); + srt_skt_ = new SrsSrtSocket(_srt_eventloop->poller(), lfd_); // Accept never timeout. srt_skt_->set_recv_timeout(ST_UTIME_NO_TIMEOUT); srt_skt_->set_send_timeout(ST_UTIME_NO_TIMEOUT); diff --git a/trunk/src/app/srs_app_srt_server.hpp b/trunk/src/app/srs_app_srt_server.hpp index e3311a77a..577638aca 100644 --- a/trunk/src/app/srs_app_srt_server.hpp +++ b/trunk/src/app/srs_app_srt_server.hpp @@ -104,14 +104,14 @@ public: virtual SrsSrtServer* instance(); }; -// The srt event loop, run srt poller and wait event happeed. +// Start a coroutine to drive the SRT events with state-threads. class SrsSrtEventLoop : public ISrsCoroutineHandler { public: SrsSrtEventLoop(); virtual ~SrsSrtEventLoop(); public: - SrsSrtPoller* get_srt_poller() { return srt_poller_; } + SrsSrtPoller* poller() { return srt_poller_; } public: srs_error_t initialize(); srs_error_t start(); diff --git a/trunk/src/utest/srs_utest_srt.cpp b/trunk/src/utest/srs_utest_srt.cpp index 8abba1288..3b17debb6 100644 --- a/trunk/src/utest/srs_utest_srt.cpp +++ b/trunk/src/utest/srs_utest_srt.cpp @@ -151,7 +151,7 @@ public: return srs_error_wrap(err, "srt listen"); } - srt_socket_ = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_server_fd_); + srt_socket_ = new SrsSrtSocket(_srt_eventloop->poller(), srt_server_fd_); return err; } @@ -185,7 +185,7 @@ VOID TEST(ServiceStSRTTest, ListenConnectAccept) SRTSOCKET srt_client_fd = SRT_INVALID_SOCK; HELPER_EXPECT_SUCCESS(srs_srt_socket(&srt_client_fd)); - SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_client_fd); + SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->poller(), srt_client_fd); // No client connected, accept will timeout. SRTSOCKET srt_fd = SRT_INVALID_SOCK; @@ -209,7 +209,7 @@ VOID TEST(ServiceStSRTTest, ConnectTimeout) SRTSOCKET srt_client_fd = SRT_INVALID_SOCK; HELPER_EXPECT_SUCCESS(srs_srt_socket_with_default_option(&srt_client_fd)); - SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_client_fd); + SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->poller(), srt_client_fd); srt_client_socket->set_send_timeout(50 * SRS_UTIME_MILLISECONDS); // Client connect to server which is no listening. @@ -231,7 +231,7 @@ VOID TEST(ServiceStSRTTest, ConnectWithStreamid) SRTSOCKET srt_client_fd = SRT_INVALID_SOCK; HELPER_EXPECT_SUCCESS(srs_srt_socket_with_default_option(&srt_client_fd)); HELPER_EXPECT_SUCCESS(srs_srt_set_streamid(srt_client_fd, streamid)); - SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_client_fd); + SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->poller(), srt_client_fd); HELPER_EXPECT_SUCCESS(srt_client_socket->connect("127.0.0.1", 9000)); @@ -256,7 +256,7 @@ VOID TEST(ServiceStSRTTest, ReadWrite) SRTSOCKET srt_client_fd = SRT_INVALID_SOCK; HELPER_EXPECT_SUCCESS(srs_srt_socket_with_default_option(&srt_client_fd)); - SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_client_fd); + SrsSrtSocket* srt_client_socket = new SrsSrtSocket(_srt_eventloop->poller(), srt_client_fd); // Client connect to server HELPER_EXPECT_SUCCESS(srt_client_socket->connect(server_ip, server_port)); @@ -265,7 +265,7 @@ VOID TEST(ServiceStSRTTest, ReadWrite) SRTSOCKET srt_server_accepted_fd = SRT_INVALID_SOCK; HELPER_EXPECT_SUCCESS(srt_server.accept(&srt_server_accepted_fd)); EXPECT_NE(srt_server_accepted_fd, SRT_INVALID_SOCK); - SrsSrtSocket* srt_server_accepted_socket = new SrsSrtSocket(_srt_eventloop->get_srt_poller(), srt_server_accepted_fd); + SrsSrtSocket* srt_server_accepted_socket = new SrsSrtSocket(_srt_eventloop->poller(), srt_server_accepted_fd); if (true) { std::string content = "Hello, SRS SRT!";