diff --git a/src/internal_modules/roc_address/endpoint_uri.cpp b/src/internal_modules/roc_address/network_uri.cpp similarity index 82% rename from src/internal_modules/roc_address/endpoint_uri.cpp rename to src/internal_modules/roc_address/network_uri.cpp index b440e498b..025940e2b 100644 --- a/src/internal_modules/roc_address/endpoint_uri.cpp +++ b/src/internal_modules/roc_address/network_uri.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_address/pct.h" #include "roc_address/protocol_map.h" #include "roc_core/stddefs.h" @@ -25,7 +25,7 @@ bool safe_strcmp(const char* a, const char* b) { } // namespace -EndpointUri::EndpointUri(core::IArena& arena) +NetworkUri::NetworkUri(core::IArena& arena) : invalid_parts_(0) , host_(arena) , path_(arena) @@ -33,7 +33,7 @@ EndpointUri::EndpointUri(core::IArena& arena) clear(Subset_Full); } -bool EndpointUri::is_equal(const EndpointUri& other) const { +bool NetworkUri::is_equal(const NetworkUri& other) const { if (invalid_parts_ != 0 || other.invalid_parts_ != 0) { return false; } @@ -61,7 +61,7 @@ bool EndpointUri::is_equal(const EndpointUri& other) const { return true; } -bool EndpointUri::assign(const EndpointUri& other) { +bool NetworkUri::assign(const NetworkUri& other) { clear(Subset_Full); invalidate(Subset_Full); @@ -89,7 +89,7 @@ bool EndpointUri::assign(const EndpointUri& other) { return true; } -bool EndpointUri::verify(Subset subset) const { +bool NetworkUri::verify(Subset subset) const { if (subset == Subset_Resource) { if ((invalid_parts_ & (PartPath | PartQuery)) != 0) { roc_log(LogError, "invalid endpoint uri: contains invalid parts"); @@ -138,7 +138,7 @@ bool EndpointUri::verify(Subset subset) const { return true; } -void EndpointUri::clear(Subset subset) { +void NetworkUri::clear(Subset subset) { if (subset == Subset_Full) { invalid_parts_ |= PartProto; proto_ = Proto_None; @@ -158,14 +158,14 @@ void EndpointUri::clear(Subset subset) { query_.clear(); } -void EndpointUri::invalidate(Subset subset) { +void NetworkUri::invalidate(Subset subset) { if (subset == Subset_Full) { invalid_parts_ |= (PartProto | PartHost | PartPort); } invalid_parts_ |= (PartPath | PartQuery); } -bool EndpointUri::set_proto(Protocol proto) { +bool NetworkUri::set_proto(Protocol proto) { if (ProtocolMap::instance().find_by_id(proto) == NULL) { set_invalid_(PartProto); return false; @@ -185,14 +185,14 @@ bool EndpointUri::set_proto(Protocol proto) { return true; } -Protocol EndpointUri::proto() const { +Protocol NetworkUri::proto() const { if (!part_is_valid_(PartProto)) { return Proto_None; } return proto_; } -bool EndpointUri::get_proto(Protocol& proto) const { +bool NetworkUri::get_proto(Protocol& proto) const { if (!part_is_valid_(PartProto)) { return false; } @@ -201,7 +201,7 @@ bool EndpointUri::get_proto(Protocol& proto) const { return true; } -bool EndpointUri::format_proto(core::StringBuilder& dst) const { +bool NetworkUri::format_proto(core::StringBuilder& dst) const { if (!part_is_valid_(PartProto)) { return false; } @@ -215,7 +215,7 @@ bool EndpointUri::format_proto(core::StringBuilder& dst) const { return true; } -bool EndpointUri::set_host(const char* str) { +bool NetworkUri::set_host(const char* str) { if (!str) { set_invalid_(PartHost); return false; @@ -224,7 +224,7 @@ bool EndpointUri::set_host(const char* str) { return set_host(str, strlen(str)); } -bool EndpointUri::set_host(const char* str, size_t str_len) { +bool NetworkUri::set_host(const char* str, size_t str_len) { if (!str) { set_invalid_(PartHost); return false; @@ -239,14 +239,14 @@ bool EndpointUri::set_host(const char* str, size_t str_len) { return true; } -const char* EndpointUri::host() const { +const char* NetworkUri::host() const { if (!part_is_valid_(PartHost)) { return ""; } return host_.c_str(); } -bool EndpointUri::format_host(core::StringBuilder& dst) const { +bool NetworkUri::format_host(core::StringBuilder& dst) const { if (!part_is_valid_(PartHost)) { return false; } @@ -254,7 +254,7 @@ bool EndpointUri::format_host(core::StringBuilder& dst) const { return true; } -bool EndpointUri::set_port(int port) { +bool NetworkUri::set_port(int port) { if (port == -1) { port_ = -1; @@ -284,14 +284,14 @@ bool EndpointUri::set_port(int port) { return true; } -int EndpointUri::port() const { +int NetworkUri::port() const { if (!part_is_valid_(PartPort)) { return -1; } return port_; } -bool EndpointUri::get_port(int& port) const { +bool NetworkUri::get_port(int& port) const { if (!part_is_valid_(PartPort) || port_ == -1) { return false; } @@ -300,14 +300,14 @@ bool EndpointUri::get_port(int& port) const { return true; } -const char* EndpointUri::service() const { +const char* NetworkUri::service() const { if (service_[0]) { return service_; } return NULL; } -bool EndpointUri::set_path(const char* str) { +bool NetworkUri::set_path(const char* str) { if (!str) { path_.clear(); set_valid_(PartPath); @@ -317,7 +317,7 @@ bool EndpointUri::set_path(const char* str) { return set_path(str, strlen(str)); } -bool EndpointUri::set_path(const char* str, size_t str_len) { +bool NetworkUri::set_path(const char* str, size_t str_len) { if (!str || str_len < 1) { path_.clear(); set_valid_(PartPath); @@ -333,7 +333,7 @@ bool EndpointUri::set_path(const char* str, size_t str_len) { return true; } -bool EndpointUri::set_encoded_path(const char* str) { +bool NetworkUri::set_encoded_path(const char* str) { if (!str) { path_.clear(); set_valid_(PartPath); @@ -343,7 +343,7 @@ bool EndpointUri::set_encoded_path(const char* str) { return set_encoded_path(str, strlen(str)); } -bool EndpointUri::set_encoded_path(const char* str, size_t str_len) { +bool NetworkUri::set_encoded_path(const char* str, size_t str_len) { if (!str || str_len < 1) { path_.clear(); set_valid_(PartPath); @@ -371,21 +371,21 @@ bool EndpointUri::set_encoded_path(const char* str, size_t str_len) { return true; } -const char* EndpointUri::path() const { +const char* NetworkUri::path() const { if (!part_is_valid_(PartPath) || path_.is_empty()) { return NULL; } return path_.c_str(); } -bool EndpointUri::format_encoded_path(core::StringBuilder& dst) const { +bool NetworkUri::format_encoded_path(core::StringBuilder& dst) const { if (!part_is_valid_(PartPath) || path_.is_empty()) { return false; } return pct_encode(dst, path_.c_str(), path_.len(), PctNonPath); } -bool EndpointUri::set_encoded_query(const char* str) { +bool NetworkUri::set_encoded_query(const char* str) { if (!str) { query_.clear(); set_valid_(PartQuery); @@ -395,7 +395,7 @@ bool EndpointUri::set_encoded_query(const char* str) { return set_encoded_query(str, strlen(str)); } -bool EndpointUri::set_encoded_query(const char* str, size_t str_len) { +bool NetworkUri::set_encoded_query(const char* str, size_t str_len) { if (!str || str_len < 1) { query_.clear(); set_valid_(PartQuery); @@ -411,14 +411,14 @@ bool EndpointUri::set_encoded_query(const char* str, size_t str_len) { return true; } -const char* EndpointUri::encoded_query() const { +const char* NetworkUri::encoded_query() const { if (!part_is_valid_(PartQuery) || query_.is_empty()) { return NULL; } return query_.c_str(); } -bool EndpointUri::format_encoded_query(core::StringBuilder& dst) const { +bool NetworkUri::format_encoded_query(core::StringBuilder& dst) const { if (!part_is_valid_(PartQuery) || query_.is_empty()) { return false; } @@ -426,7 +426,7 @@ bool EndpointUri::format_encoded_query(core::StringBuilder& dst) const { return true; } -void EndpointUri::set_service_from_port_(int port) { +void NetworkUri::set_service_from_port_(int port) { core::StringBuilder b(service_, sizeof(service_)); if (!b.append_uint((uint64_t)port, 10)) { @@ -434,7 +434,7 @@ void EndpointUri::set_service_from_port_(int port) { } } -bool EndpointUri::set_service_from_proto_(Protocol proto) { +bool NetworkUri::set_service_from_proto_(Protocol proto) { const ProtocolAttrs* attrs = ProtocolMap::instance().find_by_id(proto); if (!attrs) { return false; @@ -448,15 +448,15 @@ bool EndpointUri::set_service_from_proto_(Protocol proto) { return true; } -bool EndpointUri::part_is_valid_(Part part) const { +bool NetworkUri::part_is_valid_(Part part) const { return (invalid_parts_ & part) == 0; } -void EndpointUri::set_valid_(Part part) { +void NetworkUri::set_valid_(Part part) { invalid_parts_ &= ~part; } -void EndpointUri::set_invalid_(Part part) { +void NetworkUri::set_invalid_(Part part) { invalid_parts_ |= part; } diff --git a/src/internal_modules/roc_address/endpoint_uri.h b/src/internal_modules/roc_address/network_uri.h similarity index 88% rename from src/internal_modules/roc_address/endpoint_uri.h rename to src/internal_modules/roc_address/network_uri.h index e0718170c..97f57a824 100644 --- a/src/internal_modules/roc_address/endpoint_uri.h +++ b/src/internal_modules/roc_address/network_uri.h @@ -6,11 +6,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! @file roc_address/endpoint_uri.h +//! @file roc_address/network_uri.h //! @brief Network endpoint URI. -#ifndef ROC_ADDRESS_ENDPOINT_URI_H_ -#define ROC_ADDRESS_ENDPOINT_URI_H_ +#ifndef ROC_ADDRESS_NETWORK_URI_H_ +#define ROC_ADDRESS_NETWORK_URI_H_ #include "roc_address/interface.h" #include "roc_address/protocol.h" @@ -24,7 +24,7 @@ namespace roc { namespace address { //! Network endpoint URI. -class EndpointUri : public core::NonCopyable<> { +class NetworkUri : public core::NonCopyable<> { public: //! URI subset. enum Subset { @@ -33,13 +33,13 @@ class EndpointUri : public core::NonCopyable<> { }; //! Initialize empty URI. - explicit EndpointUri(core::IArena&); + explicit NetworkUri(core::IArena& arena); //! Check if URI is equivalent to another URI. - bool is_equal(const EndpointUri& other) const; + bool is_equal(const NetworkUri& other) const; //! Copy data from another URI. - ROC_ATTR_NODISCARD bool assign(const EndpointUri& other); + ROC_ATTR_NODISCARD bool assign(const NetworkUri& other); //! Check given subset of the URI. bool verify(Subset subset) const; @@ -158,7 +158,7 @@ class EndpointUri : public core::NonCopyable<> { core::StringBuffer query_; }; -//! Parse EndpointUri from string. +//! Parse NetworkUri from string. //! //! The URI should be in the following form: //! - PROTOCOL://HOST[:PORT][/PATH][?QUERY] @@ -185,9 +185,9 @@ class EndpointUri : public core::NonCopyable<> { //! This parser does not try to perform full URI validation. For example, it does not //! check that path contains only allowed symbols. If it can be parsed, it will be. ROC_ATTR_NODISCARD bool -parse_endpoint_uri(const char* str, EndpointUri::Subset subset, EndpointUri& result); +parse_network_uri(const char* str, NetworkUri::Subset subset, NetworkUri& result); -//! Format EndpointUri to string. +//! Format NetworkUri to string. //! //! Formats a normalized form of the URI. //! @@ -196,11 +196,11 @@ parse_endpoint_uri(const char* str, EndpointUri::Subset subset, EndpointUri& res //! //! @returns //! true on success or false if the buffer is too small. -ROC_ATTR_NODISCARD bool format_endpoint_uri(const EndpointUri& uri, - EndpointUri::Subset subset, - core::StringBuilder& dst); +ROC_ATTR_NODISCARD bool format_network_uri(const NetworkUri& uri, + NetworkUri::Subset subset, + core::StringBuilder& dst); } // namespace address } // namespace roc -#endif // ROC_ADDRESS_ENDPOINT_URI_H_ +#endif // ROC_ADDRESS_NETWORK_URI_H_ diff --git a/src/internal_modules/roc_address/endpoint_uri_format.cpp b/src/internal_modules/roc_address/network_uri_format.cpp similarity index 79% rename from src/internal_modules/roc_address/endpoint_uri_format.cpp rename to src/internal_modules/roc_address/network_uri_format.cpp index eb2426768..a527e86bd 100644 --- a/src/internal_modules/roc_address/endpoint_uri_format.cpp +++ b/src/internal_modules/roc_address/network_uri_format.cpp @@ -6,21 +6,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_core/panic.h" #include "roc_core/string_builder.h" namespace roc { namespace address { -bool format_endpoint_uri(const EndpointUri& u, - EndpointUri::Subset subset, - core::StringBuilder& dst) { +bool format_network_uri(const NetworkUri& u, + NetworkUri::Subset subset, + core::StringBuilder& dst) { if (!u.verify(subset)) { return false; } - if (subset == EndpointUri::Subset_Full) { + if (subset == NetworkUri::Subset_Full) { if (!u.format_proto(dst)) { return false; } @@ -37,7 +37,7 @@ bool format_endpoint_uri(const EndpointUri& u, } } - if (subset == EndpointUri::Subset_Resource) { + if (subset == NetworkUri::Subset_Resource) { if (!u.path() && !u.encoded_query()) { return false; } diff --git a/src/internal_modules/roc_address/endpoint_uri_parse.rl b/src/internal_modules/roc_address/network_uri_parse.rl similarity index 88% rename from src/internal_modules/roc_address/endpoint_uri_parse.rl rename to src/internal_modules/roc_address/network_uri_parse.rl index b29ae1896..1d2eb8480 100644 --- a/src/internal_modules/roc_address/endpoint_uri_parse.rl +++ b/src/internal_modules/roc_address/network_uri_parse.rl @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_address/protocol_map.h" #include "roc_core/log.h" #include "roc_core/panic.h" @@ -15,13 +15,13 @@ namespace roc { namespace address { %%{ - machine parse_endpoint_uri; + machine parse_network_uri; write data; }%% namespace { -bool parse_endpoint_uri_imp(const char* str, EndpointUri::Subset subset, EndpointUri& result) { +bool parse_network_uri_imp(const char* str, NetworkUri::Subset subset, NetworkUri& result) { if (!str) { roc_log(LogError, "parse endpoint uri: input string is null"); return false; @@ -69,7 +69,7 @@ bool parse_endpoint_uri_imp(const char* str, EndpointUri::Subset subset, Endpoin } action set_host { - if (subset != EndpointUri::Subset_Full) { + if (subset != NetworkUri::Subset_Full) { roc_log(LogError, "parse endpoint uri: unexpected host when parsing resource"); return false; @@ -81,7 +81,7 @@ bool parse_endpoint_uri_imp(const char* str, EndpointUri::Subset subset, Endpoin } action set_port { - if (subset != EndpointUri::Subset_Full) { + if (subset != NetworkUri::Subset_Full) { roc_log(LogError, "parse endpoint uri: unexpected port when parsing resource"); return false; @@ -136,7 +136,7 @@ bool parse_endpoint_uri_imp(const char* str, EndpointUri::Subset subset, Endpoin }%% if (!success) { - if (subset == EndpointUri::Subset_Full) { + if (subset == NetworkUri::Subset_Full) { roc_log(LogError, "parse endpoint uri: expected" " 'PROTO://HOST[:PORT][/PATH][?QUERY]',\n" @@ -153,7 +153,7 @@ bool parse_endpoint_uri_imp(const char* str, EndpointUri::Subset subset, Endpoin } if (!result.verify(subset)) { - roc_log(LogError, "parse endpoint uri: invalud uri"); + roc_log(LogError, "parse endpoint uri: invalid uri"); return false; } @@ -162,8 +162,8 @@ bool parse_endpoint_uri_imp(const char* str, EndpointUri::Subset subset, Endpoin } // namespace -bool parse_endpoint_uri(const char* str, EndpointUri::Subset subset, EndpointUri& result) { - if (!parse_endpoint_uri_imp(str, subset, result)) { +bool parse_network_uri(const char* str, NetworkUri::Subset subset, NetworkUri& result) { + if (!parse_network_uri_imp(str, subset, result)) { result.invalidate(subset); return false; } diff --git a/src/internal_modules/roc_address/endpoint_uri_to_str.cpp b/src/internal_modules/roc_address/network_uri_to_str.cpp similarity index 70% rename from src/internal_modules/roc_address/endpoint_uri_to_str.cpp rename to src/internal_modules/roc_address/network_uri_to_str.cpp index 047ad7ff6..04b6c827f 100644 --- a/src/internal_modules/roc_address/endpoint_uri_to_str.cpp +++ b/src/internal_modules/roc_address/network_uri_to_str.cpp @@ -6,21 +6,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_address/endpoint_uri_to_str.h" +#include "roc_address/network_uri_to_str.h" #include "roc_core/string_builder.h" namespace roc { namespace address { -endpoint_uri_to_str::endpoint_uri_to_str(const EndpointUri& u) { +network_uri_to_str::network_uri_to_str(const NetworkUri& u) { core::StringBuilder b(buf_, sizeof(buf_)); - if (!u.verify(EndpointUri::Subset_Full)) { + if (!u.verify(NetworkUri::Subset_Full)) { b.rewrite(""); return; } - if (!format_endpoint_uri(u, EndpointUri::Subset_Full, b)) { + if (!format_network_uri(u, NetworkUri::Subset_Full, b)) { b.rewrite(""); return; } diff --git a/src/internal_modules/roc_address/endpoint_uri_to_str.h b/src/internal_modules/roc_address/network_uri_to_str.h similarity index 56% rename from src/internal_modules/roc_address/endpoint_uri_to_str.h rename to src/internal_modules/roc_address/network_uri_to_str.h index f791ae6c4..e297a82b1 100644 --- a/src/internal_modules/roc_address/endpoint_uri_to_str.h +++ b/src/internal_modules/roc_address/network_uri_to_str.h @@ -6,23 +6,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! @file roc_address/endpoint_uri_to_str.h -//! @brief Format EndpointUri to string. +//! @file roc_address/network_uri_to_str.h +//! @brief Format NetworkUri to string. -#ifndef ROC_ADDRESS_ENDPOINT_URI_TO_STR_H_ -#define ROC_ADDRESS_ENDPOINT_URI_TO_STR_H_ +#ifndef ROC_ADDRESS_NETWORK_URI_TO_STR_H_ +#define ROC_ADDRESS_NETWORK_URI_TO_STR_H_ -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_core/noncopyable.h" namespace roc { namespace address { -//! Convert EndpointUri to string. -class endpoint_uri_to_str : public core::NonCopyable<> { +//! Convert NetworkUri to string. +class network_uri_to_str : public core::NonCopyable<> { public: //! Construct. - explicit endpoint_uri_to_str(const EndpointUri&); + explicit network_uri_to_str(const NetworkUri&); //! Get formatted string. const char* c_str() const { @@ -36,4 +36,4 @@ class endpoint_uri_to_str : public core::NonCopyable<> { } // namespace address } // namespace roc -#endif // ROC_ADDRESS_ENDPOINT_URI_TO_STR_H_ +#endif // ROC_ADDRESS_NETWORK_URI_TO_STR_H_ diff --git a/src/internal_modules/roc_ctl/basic_control_endpoint.h b/src/internal_modules/roc_ctl/basic_control_endpoint.h index 7c70f7a3e..78308f2ab 100644 --- a/src/internal_modules/roc_ctl/basic_control_endpoint.h +++ b/src/internal_modules/roc_ctl/basic_control_endpoint.h @@ -12,7 +12,7 @@ #ifndef ROC_CTL_BASIC_CONTROL_ENDPOINT_H_ #define ROC_CTL_BASIC_CONTROL_ENDPOINT_H_ -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_core/list_node.h" #include "roc_core/ref_counted.h" #include "roc_ctl/control_task.h" @@ -40,13 +40,12 @@ class BasicControlEndpoint //! Initiate asynchronous binding to local URI. //! On completion, resumes @p notify_task. - virtual bool async_bind(const address::EndpointUri& uri, - ControlTask& notify_task) = 0; + virtual bool async_bind(const address::NetworkUri& uri, ControlTask& notify_task) = 0; //! Initiate asynchronous connecting to remote URI. //! Should be called after successfull bind. //! On completion, resumes @p notify_task. - virtual bool async_connect(const address::EndpointUri& uri, + virtual bool async_connect(const address::NetworkUri& uri, ControlTask& notify_task) = 0; //! Initiate asynchronous closing of endpoint. @@ -55,7 +54,7 @@ class BasicControlEndpoint //! Add sink pipeline controlled by this endpoint. //! Should be called after successfull bind. - virtual bool attach_sink(const address::EndpointUri& uri, + virtual bool attach_sink(const address::NetworkUri& uri, pipeline::SenderLoop& sink) = 0; //! Remove sink pipeline. @@ -64,7 +63,7 @@ class BasicControlEndpoint //! Add source pipeline controlled by this endpoint. //! Should be called after successfull bind. - virtual bool attach_source(const address::EndpointUri& uri, + virtual bool attach_source(const address::NetworkUri& uri, pipeline::ReceiverLoop& source) = 0; //! Remove source pipeline. diff --git a/src/internal_modules/roc_ctl/control_loop.cpp b/src/internal_modules/roc_ctl/control_loop.cpp index 384f0628b..87144195f 100644 --- a/src/internal_modules/roc_ctl/control_loop.cpp +++ b/src/internal_modules/roc_ctl/control_loop.cpp @@ -37,7 +37,7 @@ ControlLoop::Tasks::DeleteEndpoint::DeleteEndpoint(ControlLoop::EndpointHandle e } ControlLoop::Tasks::BindEndpoint::BindEndpoint(EndpointHandle endpoint, - const address::EndpointUri& uri) + const address::NetworkUri& uri) : ControlTask(&ControlLoop::task_bind_endpoint_) , endpoint_((BasicControlEndpoint*)endpoint) , uri_(uri) @@ -45,7 +45,7 @@ ControlLoop::Tasks::BindEndpoint::BindEndpoint(EndpointHandle endpoint, } ControlLoop::Tasks::ConnectEndpoint::ConnectEndpoint(EndpointHandle endpoint, - const address::EndpointUri& uri) + const address::NetworkUri& uri) : ControlTask(&ControlLoop::task_connect_endpoint_) , endpoint_((BasicControlEndpoint*)endpoint) , uri_(uri) @@ -53,7 +53,7 @@ ControlLoop::Tasks::ConnectEndpoint::ConnectEndpoint(EndpointHandle endpoint, } ControlLoop::Tasks::AttachSink::AttachSink(EndpointHandle endpoint, - const address::EndpointUri& uri, + const address::NetworkUri& uri, pipeline::SenderLoop& sink) : ControlTask(&ControlLoop::task_attach_sink_) , endpoint_((BasicControlEndpoint*)endpoint) @@ -69,7 +69,7 @@ ControlLoop::Tasks::DetachSink::DetachSink(EndpointHandle endpoint, } ControlLoop::Tasks::AttachSource::AttachSource(EndpointHandle endpoint, - const address::EndpointUri& uri, + const address::NetworkUri& uri, pipeline::ReceiverLoop& source) : ControlTask(&ControlLoop::task_attach_source_) , endpoint_((BasicControlEndpoint*)endpoint) diff --git a/src/internal_modules/roc_ctl/control_loop.h b/src/internal_modules/roc_ctl/control_loop.h index 86e5c71c8..d77f72431 100644 --- a/src/internal_modules/roc_ctl/control_loop.h +++ b/src/internal_modules/roc_ctl/control_loop.h @@ -74,7 +74,7 @@ class ControlLoop : public ControlTaskExecutor, public core::NonCop class BindEndpoint : public ControlTask { public: //! Set task parameters. - BindEndpoint(EndpointHandle endpoint, const address::EndpointUri& uri); + BindEndpoint(EndpointHandle endpoint, const address::NetworkUri& uri); private: friend class ControlLoop; @@ -82,7 +82,7 @@ class ControlLoop : public ControlTaskExecutor, public core::NonCop enum Phase { Phase_Prologue, Phase_Epilogue }; core::SharedPtr endpoint_; - const address::EndpointUri& uri_; + const address::NetworkUri& uri_; Phase phase_; }; @@ -90,7 +90,7 @@ class ControlLoop : public ControlTaskExecutor, public core::NonCop class ConnectEndpoint : public ControlTask { public: //! Set task parameters. - ConnectEndpoint(EndpointHandle endpoint, const address::EndpointUri& uri); + ConnectEndpoint(EndpointHandle endpoint, const address::NetworkUri& uri); private: friend class ControlLoop; @@ -98,7 +98,7 @@ class ControlLoop : public ControlTaskExecutor, public core::NonCop enum Phase { Phase_Prologue, Phase_Epilogue }; core::SharedPtr endpoint_; - const address::EndpointUri& uri_; + const address::NetworkUri& uri_; Phase phase_; }; @@ -107,14 +107,14 @@ class ControlLoop : public ControlTaskExecutor, public core::NonCop public: //! Set task parameters. AttachSink(EndpointHandle endpoint, - const address::EndpointUri& uri, + const address::NetworkUri& uri, pipeline::SenderLoop& sink); private: friend class ControlLoop; core::SharedPtr endpoint_; - const address::EndpointUri& uri_; + const address::NetworkUri& uri_; pipeline::SenderLoop& sink_; }; @@ -136,14 +136,14 @@ class ControlLoop : public ControlTaskExecutor, public core::NonCop public: //! Set task parameters. AttachSource(EndpointHandle endpoint, - const address::EndpointUri& uri, + const address::NetworkUri& uri, pipeline::ReceiverLoop& source); private: friend class ControlLoop; core::SharedPtr endpoint_; - const address::EndpointUri& uri_; + const address::NetworkUri& uri_; pipeline::ReceiverLoop& source_; }; diff --git a/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.cpp b/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.cpp index 41fa79757..132da2038 100644 --- a/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.cpp +++ b/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.cpp @@ -92,7 +92,7 @@ NetworkLoop::Tasks::RemovePort::RemovePort(PortHandle handle) { } NetworkLoop::Tasks::ResolveEndpointAddress::ResolveEndpointAddress( - const address::EndpointUri& endpoint_uri) { + const address::NetworkUri& endpoint_uri) { func_ = &NetworkLoop::task_resolve_endpoint_address_; resolve_req_.endpoint_uri = &endpoint_uri; } diff --git a/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.h b/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.h index 998095773..cfaedc895 100644 --- a/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.h +++ b/src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.h @@ -172,7 +172,7 @@ class NetworkLoop : private ITerminateHandler, //! @remarks //! Gets endpoint hostname, resolves it, and writes the resolved IP address //! and the port from the endpoint to the resulting SocketAddr. - ResolveEndpointAddress(const address::EndpointUri& endpoint_uri); + ResolveEndpointAddress(const address::NetworkUri& endpoint_uri); //! Get resolved address. //! @pre diff --git a/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver.cpp b/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver.cpp index 30c7de53f..23a846725 100644 --- a/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver.cpp +++ b/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver.cpp @@ -7,7 +7,7 @@ */ #include "roc_netio/resolver.h" -#include "roc_address/endpoint_uri_to_str.h" +#include "roc_address/network_uri_to_str.h" #include "roc_address/parse_socket_addr.h" #include "roc_address/socket_addr_to_str.h" #include "roc_core/log.h" @@ -27,14 +27,14 @@ bool Resolver::async_resolve(ResolverRequest& req) { req.resolved_address.clear(); - if (!req.endpoint_uri->verify(address::EndpointUri::Subset_Full)) { + if (!req.endpoint_uri->verify(address::NetworkUri::Subset_Full)) { roc_log(LogError, "resolver: invalid endpoint"); req.success = false; return false; } roc_log(LogTrace, "resolver: starting resolving: endpoint=%s", - address::endpoint_uri_to_str(*req.endpoint_uri).c_str()); + address::network_uri_to_str(*req.endpoint_uri).c_str()); if (address::parse_socket_addr(req.endpoint_uri->host(), req.endpoint_uri->port(), req.resolved_address)) { diff --git a/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver_request.h b/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver_request.h index 3258b85f4..1d8492f47 100644 --- a/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver_request.h +++ b/src/internal_modules/roc_netio/target_libuv/roc_netio/resolver_request.h @@ -14,7 +14,7 @@ #include -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_address/socket_addr.h" namespace roc { @@ -23,7 +23,7 @@ namespace netio { //! Resolver request. struct ResolverRequest { //! Endpoint with hostname to resolve for async_resolve(). - const address::EndpointUri* endpoint_uri; + const address::NetworkUri* endpoint_uri; //! Resolved address to be filled by async_resolve(). address::SocketAddr resolved_address; diff --git a/src/internal_modules/roc_node/receiver.cpp b/src/internal_modules/roc_node/receiver.cpp index cb8178c22..ca4d13deb 100644 --- a/src/internal_modules/roc_node/receiver.cpp +++ b/src/internal_modules/roc_node/receiver.cpp @@ -7,7 +7,7 @@ */ #include "roc_node/receiver.h" -#include "roc_address/endpoint_uri_to_str.h" +#include "roc_address/network_uri_to_str.h" #include "roc_address/socket_addr_to_str.h" #include "roc_core/log.h" #include "roc_core/panic.h" @@ -111,7 +111,7 @@ bool Receiver::configure(slot_index_t slot_index, bool Receiver::bind(slot_index_t slot_index, address::Interface iface, - address::EndpointUri& uri) { + address::NetworkUri& uri) { core::Mutex::Lock lock(control_mutex_); roc_panic_if(init_status_ != status::StatusOK); @@ -121,7 +121,7 @@ bool Receiver::bind(slot_index_t slot_index, roc_log(LogInfo, "receiver node: binding %s interface of slot %lu to %s", address::interface_to_str(iface), (unsigned long)slot_index, - address::endpoint_uri_to_str(uri).c_str()); + address::network_uri_to_str(uri).c_str()); core::SharedPtr slot = get_slot_(slot_index, true); if (!slot) { @@ -142,7 +142,7 @@ bool Receiver::bind(slot_index_t slot_index, return false; } - if (!uri.verify(address::EndpointUri::Subset_Full)) { + if (!uri.verify(address::NetworkUri::Subset_Full)) { roc_log(LogError, "receiver node:" " can't bind %s interface of slot %lu:" diff --git a/src/internal_modules/roc_node/receiver.h b/src/internal_modules/roc_node/receiver.h index c0bbdf5cf..d37d60963 100644 --- a/src/internal_modules/roc_node/receiver.h +++ b/src/internal_modules/roc_node/receiver.h @@ -12,8 +12,8 @@ #ifndef ROC_NODE_RECEIVER_H_ #define ROC_NODE_RECEIVER_H_ -#include "roc_address/endpoint_uri.h" #include "roc_address/interface.h" +#include "roc_address/network_uri.h" #include "roc_address/protocol.h" #include "roc_core/attributes.h" #include "roc_core/hashmap.h" @@ -52,7 +52,7 @@ class Receiver : public Node, private pipeline::IPipelineTaskScheduler { //! Bind to local endpoint. ROC_ATTR_NODISCARD bool - bind(slot_index_t slot_index, address::Interface iface, address::EndpointUri& uri); + bind(slot_index_t slot_index, address::Interface iface, address::NetworkUri& uri); //! Remove slot. ROC_ATTR_NODISCARD bool unlink(slot_index_t slot_index); diff --git a/src/internal_modules/roc_node/sender.cpp b/src/internal_modules/roc_node/sender.cpp index de29db82b..6c9949e8c 100644 --- a/src/internal_modules/roc_node/sender.cpp +++ b/src/internal_modules/roc_node/sender.cpp @@ -7,7 +7,7 @@ */ #include "roc_node/sender.h" -#include "roc_address/endpoint_uri_to_str.h" +#include "roc_address/network_uri_to_str.h" #include "roc_address/socket_addr_to_str.h" #include "roc_core/log.h" #include "roc_core/panic.h" @@ -113,7 +113,7 @@ bool Sender::configure(slot_index_t slot_index, bool Sender::connect(slot_index_t slot_index, address::Interface iface, - const address::EndpointUri& uri) { + const address::NetworkUri& uri) { core::Mutex::Lock lock(control_mutex_); roc_panic_if(init_status_ != status::StatusOK); @@ -123,7 +123,7 @@ bool Sender::connect(slot_index_t slot_index, roc_log(LogInfo, "sender node: connecting %s interface of slot %lu to %s", address::interface_to_str(iface), (unsigned long)slot_index, - address::endpoint_uri_to_str(uri).c_str()); + address::network_uri_to_str(uri).c_str()); core::SharedPtr slot = get_slot_(slot_index, true); if (!slot) { @@ -144,7 +144,7 @@ bool Sender::connect(slot_index_t slot_index, return false; } - if (!uri.verify(address::EndpointUri::Subset_Full)) { + if (!uri.verify(address::NetworkUri::Subset_Full)) { roc_log(LogError, "sender node: can't connect %s interface of slot %lu: invalid uri", address::interface_to_str(iface), (unsigned long)slot_index); @@ -412,7 +412,7 @@ sndio::ISink& Sender::sink() { } bool Sender::check_compatibility_(address::Interface iface, - const address::EndpointUri& uri) { + const address::NetworkUri& uri) { if (used_interfaces_[iface] && used_protocols_[iface] != uri.proto()) { roc_log(LogError, "sender node: same interface of all slots should use same protocols:" @@ -426,7 +426,7 @@ bool Sender::check_compatibility_(address::Interface iface, } void Sender::update_compatibility_(address::Interface iface, - const address::EndpointUri& uri) { + const address::NetworkUri& uri) { used_interfaces_[iface] = true; used_protocols_[iface] = uri.proto(); } diff --git a/src/internal_modules/roc_node/sender.h b/src/internal_modules/roc_node/sender.h index 27f45ace0..b42a796fd 100644 --- a/src/internal_modules/roc_node/sender.h +++ b/src/internal_modules/roc_node/sender.h @@ -12,8 +12,8 @@ #ifndef ROC_NODE_SENDER_H_ #define ROC_NODE_SENDER_H_ -#include "roc_address/endpoint_uri.h" #include "roc_address/interface.h" +#include "roc_address/network_uri.h" #include "roc_address/protocol.h" #include "roc_core/allocation_policy.h" #include "roc_core/hashmap.h" @@ -54,7 +54,7 @@ class Sender : public Node, private pipeline::IPipelineTaskScheduler { //! Connect to remote endpoint. ROC_ATTR_NODISCARD bool connect(slot_index_t slot_index, address::Interface iface, - const address::EndpointUri& uri); + const address::NetworkUri& uri); //! Remove slot. ROC_ATTR_NODISCARD bool unlink(slot_index_t slot_index); @@ -133,8 +133,8 @@ class Sender : public Node, private pipeline::IPipelineTaskScheduler { } }; - bool check_compatibility_(address::Interface iface, const address::EndpointUri& uri); - void update_compatibility_(address::Interface iface, const address::EndpointUri& uri); + bool check_compatibility_(address::Interface iface, const address::NetworkUri& uri); + void update_compatibility_(address::Interface iface, const address::NetworkUri& uri); core::SharedPtr get_slot_(slot_index_t slot_index, bool auto_create); void cleanup_slot_(Slot& slot); diff --git a/src/public_api/src/endpoint.cpp b/src/public_api/src/endpoint.cpp index 31bb3789f..7e68f54e8 100644 --- a/src/public_api/src/endpoint.cpp +++ b/src/public_api/src/endpoint.cpp @@ -11,7 +11,7 @@ #include "adapters.h" #include "arena.h" -#include "roc_address/endpoint_uri.h" +#include "roc_address/network_uri.h" #include "roc_core/log.h" using namespace roc; @@ -22,8 +22,8 @@ int roc_endpoint_allocate(roc_endpoint** result) { return -1; } - address::EndpointUri* imp_endpoint = - new (api::default_arena) address::EndpointUri(api::default_arena); + address::NetworkUri* imp_endpoint = + new (api::default_arena) address::NetworkUri(api::default_arena); if (!imp_endpoint) { roc_log(LogError, "roc_endpoint_allocate(): can't allocate endpoint"); @@ -40,10 +40,10 @@ int roc_endpoint_set_uri(roc_endpoint* endpoint, const char* uri) { return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; - if (!address::parse_endpoint_uri(uri, address::EndpointUri::Subset_Full, - imp_endpoint)) { + if (!address::parse_network_uri(uri, address::NetworkUri::Subset_Full, + imp_endpoint)) { roc_log(LogError, "roc_endpoint_set_uri(): invalid arguments: invalid uri"); return -1; } @@ -58,11 +58,11 @@ int roc_endpoint_set_protocol(roc_endpoint* endpoint, roc_protocol proto) { return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; address::Protocol imp_proto; if (!api::proto_from_user(imp_proto, proto)) { - // set to invalid protocol to let EndpointUri invalidate protocol + // set to invalid protocol to let NetworkUri invalidate protocol imp_proto = address::Proto_None; } @@ -81,7 +81,7 @@ int roc_endpoint_set_host(roc_endpoint* endpoint, const char* host) { return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; if (!imp_endpoint.set_host(host)) { roc_log(LogError, "roc_endpoint_set_host(): can't set host"); @@ -97,7 +97,7 @@ int roc_endpoint_set_port(roc_endpoint* endpoint, int port) { return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; if (!imp_endpoint.set_port(port)) { roc_log(LogError, "roc_endpoint_set_port(): invalid arguments: invalid port"); @@ -114,15 +114,15 @@ int roc_endpoint_set_resource(roc_endpoint* endpoint, const char* encoded_resour return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; if (!encoded_resource) { - imp_endpoint.clear(address::EndpointUri::Subset_Resource); + imp_endpoint.clear(address::NetworkUri::Subset_Resource); return 0; } - if (!address::parse_endpoint_uri( - encoded_resource, address::EndpointUri::Subset_Resource, imp_endpoint)) { + if (!address::parse_network_uri(encoded_resource, + address::NetworkUri::Subset_Resource, imp_endpoint)) { roc_log(LogError, "roc_endpoint_set_resource(): invalid arguments: invalid resource"); return -1; @@ -137,7 +137,7 @@ int roc_endpoint_get_uri(const roc_endpoint* endpoint, char* buf, size_t* bufsz) return -1; } - const address::EndpointUri& imp_endpoint = *(const address::EndpointUri*)endpoint; + const address::NetworkUri& imp_endpoint = *(const address::NetworkUri*)endpoint; if (!bufsz) { roc_log(LogError, "roc_endpoint_get_uri(): invalid arguments: bufsz is null"); @@ -146,8 +146,7 @@ int roc_endpoint_get_uri(const roc_endpoint* endpoint, char* buf, size_t* bufsz) core::StringBuilder b(buf, *bufsz); - if (!address::format_endpoint_uri(imp_endpoint, address::EndpointUri::Subset_Full, - b)) { + if (!address::format_network_uri(imp_endpoint, address::NetworkUri::Subset_Full, b)) { roc_log(LogError, "roc_endpoint_get_uri(): endpoint uri is not set"); return -1; } @@ -171,7 +170,7 @@ int roc_endpoint_get_protocol(const roc_endpoint* endpoint, roc_protocol* proto) return -1; } - const address::EndpointUri& imp_endpoint = *(const address::EndpointUri*)endpoint; + const address::NetworkUri& imp_endpoint = *(const address::NetworkUri*)endpoint; if (!proto) { roc_log(LogError, @@ -199,7 +198,7 @@ int roc_endpoint_get_host(const roc_endpoint* endpoint, char* buf, size_t* bufsz return -1; } - const address::EndpointUri& imp_endpoint = *(const address::EndpointUri*)endpoint; + const address::NetworkUri& imp_endpoint = *(const address::NetworkUri*)endpoint; if (!bufsz) { roc_log(LogError, "roc_endpoint_get_host(): invalid arguments: bufsz is null"); @@ -231,7 +230,7 @@ int roc_endpoint_get_port(const roc_endpoint* endpoint, int* port) { return -1; } - const address::EndpointUri& imp_endpoint = *(const address::EndpointUri*)endpoint; + const address::NetworkUri& imp_endpoint = *(const address::NetworkUri*)endpoint; if (!port) { roc_log(LogError, "roc_endpoint_get_port(): invalid arguments: port is null"); @@ -253,7 +252,7 @@ int roc_endpoint_get_resource(const roc_endpoint* endpoint, char* buf, size_t* b return -1; } - const address::EndpointUri& imp_endpoint = *(const address::EndpointUri*)endpoint; + const address::NetworkUri& imp_endpoint = *(const address::NetworkUri*)endpoint; if (!bufsz) { roc_log(LogError, @@ -263,8 +262,8 @@ int roc_endpoint_get_resource(const roc_endpoint* endpoint, char* buf, size_t* b core::StringBuilder b(buf, *bufsz); - if (!address::format_endpoint_uri(imp_endpoint, address::EndpointUri::Subset_Resource, - b)) { + if (!address::format_network_uri(imp_endpoint, address::NetworkUri::Subset_Resource, + b)) { roc_log(LogDebug, "roc_endpoint_get_resource(): endpoint resource is not set"); return -1; } @@ -288,7 +287,7 @@ int roc_endpoint_deallocate(roc_endpoint* endpoint) { return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; api::default_arena.dispose_object(imp_endpoint); return 0; diff --git a/src/public_api/src/receiver.cpp b/src/public_api/src/receiver.cpp index 4a046ba8d..cfcdb8843 100644 --- a/src/public_api/src/receiver.cpp +++ b/src/public_api/src/receiver.cpp @@ -116,7 +116,7 @@ int roc_receiver_bind(roc_receiver* receiver, return -1; } - address::EndpointUri& imp_endpoint = *(address::EndpointUri*)endpoint; + address::NetworkUri& imp_endpoint = *(address::NetworkUri*)endpoint; address::Interface imp_iface; if (!api::interface_from_user(imp_iface, iface)) { diff --git a/src/public_api/src/sender.cpp b/src/public_api/src/sender.cpp index ec3c4b233..05aed4073 100644 --- a/src/public_api/src/sender.cpp +++ b/src/public_api/src/sender.cpp @@ -115,7 +115,7 @@ int roc_sender_connect(roc_sender* sender, return -1; } - const address::EndpointUri& imp_endpoint = *(const address::EndpointUri*)endpoint; + const address::NetworkUri& imp_endpoint = *(const address::NetworkUri*)endpoint; address::Interface imp_iface; if (!api::interface_from_user(imp_iface, iface)) { diff --git a/src/tests/roc_address/test_endpoint_uri.cpp b/src/tests/roc_address/test_endpoint_uri.cpp deleted file mode 100644 index 3f6a88331..000000000 --- a/src/tests/roc_address/test_endpoint_uri.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/* - * Copyright (c) 2019 Roc Streaming authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include - -#include "roc_address/endpoint_uri.h" -#include "roc_address/endpoint_uri_to_str.h" -#include "roc_core/heap_arena.h" - -namespace roc { -namespace address { - -namespace { - -core::HeapArena arena; - -} // namespace - -TEST_GROUP(endpoint_uri) {}; - -TEST(endpoint_uri, empty) { - EndpointUri u(arena); - - CHECK(!u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_None, u.proto()); - STRCMP_EQUAL("", u.host()); - LONGS_EQUAL(-1, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("", endpoint_uri_to_str(u).c_str()); -} - -TEST(endpoint_uri, fields) { - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(-1, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - STRCMP_EQUAL("/path", u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123/path", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123/", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - STRCMP_EQUAL("/", u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123/", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123/path?query", EndpointUri::Subset_Full, - u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - STRCMP_EQUAL("/path", u.path()); - STRCMP_EQUAL("query", u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123/path?query", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123?query", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - STRCMP_EQUAL("query", u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123?query", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123/?", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - STRCMP_EQUAL("/", u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123/", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123?", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123", endpoint_uri_to_str(u).c_str()); - } -} - -TEST(endpoint_uri, protocols) { - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtp://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtp://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtp+rs8m://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTP_RS8M_Source, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtp+rs8m://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rs8m://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RS8M_Repair, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rs8m://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtp+ldpc://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTP_LDPC_Source, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtp+ldpc://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("ldpc://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_LDPC_Repair, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("ldpc://host:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtcp://host:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTCP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtcp://host:123", endpoint_uri_to_str(u).c_str()); - } -} - -TEST(endpoint_uri, addresses) { - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("127.0.0.1", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://127.0.0.1:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://[::1]:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("[::1]", u.host()); - LONGS_EQUAL(123, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://[::1]:123", endpoint_uri_to_str(u).c_str()); - } -} - -TEST(endpoint_uri, assign) { - EndpointUri u1(arena); - EndpointUri u2(arena); - - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123/path?query", EndpointUri::Subset_Full, - u1)); - CHECK(u1.verify(EndpointUri::Subset_Full)); - - CHECK(u2.assign(u1)); - - LONGS_EQUAL(Proto_RTSP, u2.proto()); - STRCMP_EQUAL("127.0.0.1", u2.host()); - LONGS_EQUAL(123, u2.port()); - STRCMP_EQUAL("/path", u2.path()); - STRCMP_EQUAL("query", u2.encoded_query()); - - STRCMP_EQUAL("rtsp://127.0.0.1:123/path?query", endpoint_uri_to_str(u2).c_str()); -} - -TEST(endpoint_uri, is_equal) { - EndpointUri a1(arena); - EndpointUri a2(arena); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123/path?query", EndpointUri::Subset_Full, - a1)); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123/path?query", EndpointUri::Subset_Full, - a2)); - - EndpointUri b1(arena); - EndpointUri b2(arena); - EndpointUri b3(arena); - EndpointUri b4(arena); - CHECK(parse_endpoint_uri("rtsp://127.0.0.2:123/path?query", EndpointUri::Subset_Full, - b1)); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:124/path?query", EndpointUri::Subset_Full, - b2)); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123/patH?query", EndpointUri::Subset_Full, - b3)); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123/path?querY", EndpointUri::Subset_Full, - b4)); - - EndpointUri c1(arena); - EndpointUri c2(arena); - EndpointUri c3(arena); - EndpointUri c4(arena); - CHECK(parse_endpoint_uri("rtp://127.0.0.1:123", EndpointUri::Subset_Full, c1)); - CHECK( - parse_endpoint_uri("rtsp://127.0.0.1/path?query", EndpointUri::Subset_Full, c2)); - CHECK( - parse_endpoint_uri("rtsp://127.0.0.1:123/?query", EndpointUri::Subset_Full, c3)); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123/path", EndpointUri::Subset_Full, c4)); - - CHECK(a1.is_equal(a2)); - CHECK(a2.is_equal(a1)); - - CHECK(!a1.is_equal(b1)); - CHECK(!a1.is_equal(b2)); - CHECK(!a1.is_equal(b3)); - CHECK(!a1.is_equal(b4)); - - CHECK(!b1.is_equal(a1)); - CHECK(!b2.is_equal(a1)); - CHECK(!b3.is_equal(a1)); - CHECK(!b4.is_equal(a1)); - - CHECK(!a1.is_equal(c1)); - CHECK(!a1.is_equal(c2)); - CHECK(!a1.is_equal(c3)); - CHECK(!a1.is_equal(c4)); - - CHECK(!c1.is_equal(a1)); - CHECK(!c2.is_equal(a1)); - CHECK(!c3.is_equal(a1)); - CHECK(!c4.is_equal(a1)); -} - -TEST(endpoint_uri, omit_port) { - EndpointUri u(arena); - - CHECK(parse_endpoint_uri("rtsp://host:123", EndpointUri::Subset_Full, u)); - CHECK(parse_endpoint_uri("rtsp://host", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rtp://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp://host", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rtp+rs8m://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp+rs8m://host", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rs8m://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rs8m://host", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rtp+ldpc://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp+ldpc://host", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("ldpc://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("ldpc://host", EndpointUri::Subset_Full, u)); -} - -TEST(endpoint_uri, zero_port) { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:0", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("host", u.host()); - LONGS_EQUAL(0, u.port()); - CHECK(!u.path()); - CHECK(!u.encoded_query()); - - STRCMP_EQUAL("rtsp://host:0", endpoint_uri_to_str(u).c_str()); -} - -TEST(endpoint_uri, service) { - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1:123", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("127.0.0.1", u.host()); - LONGS_EQUAL(123, u.port()); - STRCMP_EQUAL("123", u.service()); - - STRCMP_EQUAL("rtsp://127.0.0.1:123", endpoint_uri_to_str(u).c_str()); - } - { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://127.0.0.1", EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("127.0.0.1", u.host()); - LONGS_EQUAL(-1, u.port()); - STRCMP_EQUAL("554", u.service()); - - STRCMP_EQUAL("rtsp://127.0.0.1", endpoint_uri_to_str(u).c_str()); - } -} - -TEST(endpoint_uri, non_empty_path) { - EndpointUri u(arena); - - CHECK(parse_endpoint_uri("rtsp://host:123", EndpointUri::Subset_Full, u)); - CHECK(parse_endpoint_uri("rtsp://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(parse_endpoint_uri("rtsp://host:123?query", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rtp://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp://host:123?query", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rtp+rs8m://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp+rs8m://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp+rs8m://host:123?query", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rs8m://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rs8m://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rs8m://host:123?query", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("rtp+ldpc://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp+ldpc://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp+ldpc://host:123?query", EndpointUri::Subset_Full, u)); - - CHECK(parse_endpoint_uri("ldpc://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("ldpc://host:123/path", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("ldpc://host:123?query", EndpointUri::Subset_Full, u)); -} - -TEST(endpoint_uri, percent_encoding) { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://" - "foo-bar" - ":123" - "/foo%21bar%40baz%2Fqux%3Fwee" - "?foo%21bar", - EndpointUri::Subset_Full, u)); - CHECK(u.verify(EndpointUri::Subset_Full)); - - LONGS_EQUAL(Proto_RTSP, u.proto()); - STRCMP_EQUAL("foo-bar", u.host()); - LONGS_EQUAL(123, u.port()); - STRCMP_EQUAL("/foo!bar@baz/qux?wee", u.path()); - STRCMP_EQUAL("foo%21bar", u.encoded_query()); - - STRCMP_EQUAL("rtsp://" - "foo-bar" - ":123" - "/foo!bar@baz/qux%3Fwee" - "?foo%21bar", - endpoint_uri_to_str(u).c_str()); -} - -TEST(endpoint_uri, small_buffer) { - EndpointUri u(arena); - CHECK(parse_endpoint_uri("rtsp://host:123/path?query", EndpointUri::Subset_Full, u)); - - char buf[sizeof("rtsp://host:123/path?query")]; - - { - core::StringBuilder b(buf, sizeof(buf)); - - CHECK(format_endpoint_uri(u, EndpointUri::Subset_Full, b)); - CHECK(b.is_ok()); - } - - for (size_t i = 0; i < sizeof(buf); i++) { - core::StringBuilder b(buf, i); - - CHECK(format_endpoint_uri(u, EndpointUri::Subset_Full, b)); - CHECK(!b.is_ok()); - } -} - -TEST(endpoint_uri, bad_syntax) { - EndpointUri u(arena); - - CHECK(parse_endpoint_uri("rtsp://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("bad://host:123", EndpointUri::Subset_Full, u)); - - CHECK(!parse_endpoint_uri("host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri(" rtsp://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtp ://host:123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host: 123", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:123 ", EndpointUri::Subset_Full, u)); - - CHECK(!parse_endpoint_uri("rtsp://host:port", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:-1", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:65536", EndpointUri::Subset_Full, u)); - - CHECK(!parse_endpoint_uri("rtsp://host:123path", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:123./path", EndpointUri::Subset_Full, u)); - - CHECK(!parse_endpoint_uri("rtsp://host:123/path%", EndpointUri::Subset_Full, u)); - CHECK( - !parse_endpoint_uri("rtsp://host:123/path%--path", EndpointUri::Subset_Full, u)); - - CHECK(!parse_endpoint_uri("rtsp://host:123/path?query#frag", EndpointUri::Subset_Full, - u)); - CHECK(!parse_endpoint_uri("rtsp://host:123/path?#frag", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:123/path#frag", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:123/#frag", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:123#frag", EndpointUri::Subset_Full, u)); - CHECK(!parse_endpoint_uri("rtsp://host:123#", EndpointUri::Subset_Full, u)); - - CHECK(!parse_endpoint_uri("", EndpointUri::Subset_Full, u)); -} - -} // namespace address -} // namespace roc diff --git a/src/tests/roc_address/test_network_uri.cpp b/src/tests/roc_address/test_network_uri.cpp new file mode 100644 index 000000000..b94cc2617 --- /dev/null +++ b/src/tests/roc_address/test_network_uri.cpp @@ -0,0 +1,517 @@ +/* + * Copyright (c) 2019 Roc Streaming authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "roc_address/network_uri.h" +#include "roc_address/network_uri_to_str.h" +#include "roc_core/heap_arena.h" + +namespace roc { +namespace address { + +namespace { + +core::HeapArena arena; + +} // namespace + +TEST_GROUP(network_uri) {}; + +TEST(network_uri, empty) { + NetworkUri u(arena); + + CHECK(!u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_None, u.proto()); + STRCMP_EQUAL("", u.host()); + LONGS_EQUAL(-1, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("", network_uri_to_str(u).c_str()); +} + +TEST(network_uri, fields) { + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(-1, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + STRCMP_EQUAL("/path", u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123/path", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123/", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + STRCMP_EQUAL("/", u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123/", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK( + parse_network_uri("rtsp://host:123/path?query", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + STRCMP_EQUAL("/path", u.path()); + STRCMP_EQUAL("query", u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123/path?query", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123?query", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + STRCMP_EQUAL("query", u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123?query", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123/?", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + STRCMP_EQUAL("/", u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123/", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123?", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123", network_uri_to_str(u).c_str()); + } +} + +TEST(network_uri, protocols) { + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtp://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtp://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtp+rs8m://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTP_RS8M_Source, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtp+rs8m://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rs8m://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RS8M_Repair, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rs8m://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtp+ldpc://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTP_LDPC_Source, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtp+ldpc://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("ldpc://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_LDPC_Repair, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("ldpc://host:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtcp://host:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTCP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtcp://host:123", network_uri_to_str(u).c_str()); + } +} + +TEST(network_uri, addresses) { + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://127.0.0.1:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("127.0.0.1", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://127.0.0.1:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://[::1]:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("[::1]", u.host()); + LONGS_EQUAL(123, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://[::1]:123", network_uri_to_str(u).c_str()); + } +} + +TEST(network_uri, assign) { + NetworkUri u1(arena); + NetworkUri u2(arena); + + CHECK(parse_network_uri("rtsp://127.0.0.1:123/path?query", NetworkUri::Subset_Full, + u1)); + CHECK(u1.verify(NetworkUri::Subset_Full)); + + CHECK(u2.assign(u1)); + + LONGS_EQUAL(Proto_RTSP, u2.proto()); + STRCMP_EQUAL("127.0.0.1", u2.host()); + LONGS_EQUAL(123, u2.port()); + STRCMP_EQUAL("/path", u2.path()); + STRCMP_EQUAL("query", u2.encoded_query()); + + STRCMP_EQUAL("rtsp://127.0.0.1:123/path?query", network_uri_to_str(u2).c_str()); +} + +TEST(network_uri, is_equal) { + NetworkUri a1(arena); + NetworkUri a2(arena); + CHECK(parse_network_uri("rtsp://127.0.0.1:123/path?query", NetworkUri::Subset_Full, + a1)); + CHECK(parse_network_uri("rtsp://127.0.0.1:123/path?query", NetworkUri::Subset_Full, + a2)); + + NetworkUri b1(arena); + NetworkUri b2(arena); + NetworkUri b3(arena); + NetworkUri b4(arena); + CHECK(parse_network_uri("rtsp://127.0.0.2:123/path?query", NetworkUri::Subset_Full, + b1)); + CHECK(parse_network_uri("rtsp://127.0.0.1:124/path?query", NetworkUri::Subset_Full, + b2)); + CHECK(parse_network_uri("rtsp://127.0.0.1:123/patH?query", NetworkUri::Subset_Full, + b3)); + CHECK(parse_network_uri("rtsp://127.0.0.1:123/path?querY", NetworkUri::Subset_Full, + b4)); + + NetworkUri c1(arena); + NetworkUri c2(arena); + NetworkUri c3(arena); + NetworkUri c4(arena); + CHECK(parse_network_uri("rtp://127.0.0.1:123", NetworkUri::Subset_Full, c1)); + CHECK(parse_network_uri("rtsp://127.0.0.1/path?query", NetworkUri::Subset_Full, c2)); + CHECK(parse_network_uri("rtsp://127.0.0.1:123/?query", NetworkUri::Subset_Full, c3)); + CHECK(parse_network_uri("rtsp://127.0.0.1:123/path", NetworkUri::Subset_Full, c4)); + + CHECK(a1.is_equal(a2)); + CHECK(a2.is_equal(a1)); + + CHECK(!a1.is_equal(b1)); + CHECK(!a1.is_equal(b2)); + CHECK(!a1.is_equal(b3)); + CHECK(!a1.is_equal(b4)); + + CHECK(!b1.is_equal(a1)); + CHECK(!b2.is_equal(a1)); + CHECK(!b3.is_equal(a1)); + CHECK(!b4.is_equal(a1)); + + CHECK(!a1.is_equal(c1)); + CHECK(!a1.is_equal(c2)); + CHECK(!a1.is_equal(c3)); + CHECK(!a1.is_equal(c4)); + + CHECK(!c1.is_equal(a1)); + CHECK(!c2.is_equal(a1)); + CHECK(!c3.is_equal(a1)); + CHECK(!c4.is_equal(a1)); +} + +TEST(network_uri, omit_port) { + NetworkUri u(arena); + + CHECK(parse_network_uri("rtsp://host:123", NetworkUri::Subset_Full, u)); + CHECK(parse_network_uri("rtsp://host", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rtp://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp://host", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rtp+rs8m://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp+rs8m://host", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rs8m://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rs8m://host", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rtp+ldpc://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp+ldpc://host", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("ldpc://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("ldpc://host", NetworkUri::Subset_Full, u)); +} + +TEST(network_uri, zero_port) { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:0", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("host", u.host()); + LONGS_EQUAL(0, u.port()); + CHECK(!u.path()); + CHECK(!u.encoded_query()); + + STRCMP_EQUAL("rtsp://host:0", network_uri_to_str(u).c_str()); +} + +TEST(network_uri, service) { + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://127.0.0.1:123", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("127.0.0.1", u.host()); + LONGS_EQUAL(123, u.port()); + STRCMP_EQUAL("123", u.service()); + + STRCMP_EQUAL("rtsp://127.0.0.1:123", network_uri_to_str(u).c_str()); + } + { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://127.0.0.1", NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("127.0.0.1", u.host()); + LONGS_EQUAL(-1, u.port()); + STRCMP_EQUAL("554", u.service()); + + STRCMP_EQUAL("rtsp://127.0.0.1", network_uri_to_str(u).c_str()); + } +} + +TEST(network_uri, non_empty_path) { + NetworkUri u(arena); + + CHECK(parse_network_uri("rtsp://host:123", NetworkUri::Subset_Full, u)); + CHECK(parse_network_uri("rtsp://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(parse_network_uri("rtsp://host:123?query", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rtp://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp://host:123?query", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rtp+rs8m://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp+rs8m://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp+rs8m://host:123?query", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rs8m://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rs8m://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rs8m://host:123?query", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("rtp+ldpc://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp+ldpc://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp+ldpc://host:123?query", NetworkUri::Subset_Full, u)); + + CHECK(parse_network_uri("ldpc://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("ldpc://host:123/path", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("ldpc://host:123?query", NetworkUri::Subset_Full, u)); +} + +TEST(network_uri, percent_encoding) { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://" + "foo-bar" + ":123" + "/foo%21bar%40baz%2Fqux%3Fwee" + "?foo%21bar", + NetworkUri::Subset_Full, u)); + CHECK(u.verify(NetworkUri::Subset_Full)); + + LONGS_EQUAL(Proto_RTSP, u.proto()); + STRCMP_EQUAL("foo-bar", u.host()); + LONGS_EQUAL(123, u.port()); + STRCMP_EQUAL("/foo!bar@baz/qux?wee", u.path()); + STRCMP_EQUAL("foo%21bar", u.encoded_query()); + + STRCMP_EQUAL("rtsp://" + "foo-bar" + ":123" + "/foo!bar@baz/qux%3Fwee" + "?foo%21bar", + network_uri_to_str(u).c_str()); +} + +TEST(network_uri, small_buffer) { + NetworkUri u(arena); + CHECK(parse_network_uri("rtsp://host:123/path?query", NetworkUri::Subset_Full, u)); + + char buf[sizeof("rtsp://host:123/path?query")]; + + { + core::StringBuilder b(buf, sizeof(buf)); + + CHECK(format_network_uri(u, NetworkUri::Subset_Full, b)); + CHECK(b.is_ok()); + } + + for (size_t i = 0; i < sizeof(buf); i++) { + core::StringBuilder b(buf, i); + + CHECK(format_network_uri(u, NetworkUri::Subset_Full, b)); + CHECK(!b.is_ok()); + } +} + +TEST(network_uri, bad_syntax) { + NetworkUri u(arena); + + CHECK(parse_network_uri("rtsp://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("bad://host:123", NetworkUri::Subset_Full, u)); + + CHECK(!parse_network_uri("host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri(" rtsp://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtp ://host:123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host: 123", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123 ", NetworkUri::Subset_Full, u)); + + CHECK(!parse_network_uri("rtsp://host:port", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:-1", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:65536", NetworkUri::Subset_Full, u)); + + CHECK(!parse_network_uri("rtsp://host:123path", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123./path", NetworkUri::Subset_Full, u)); + + CHECK(!parse_network_uri("rtsp://host:123/path%", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123/path%--path", NetworkUri::Subset_Full, u)); + + CHECK(!parse_network_uri("rtsp://host:123/path?query#frag", NetworkUri::Subset_Full, + u)); + CHECK(!parse_network_uri("rtsp://host:123/path?#frag", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123/path#frag", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123/#frag", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123#frag", NetworkUri::Subset_Full, u)); + CHECK(!parse_network_uri("rtsp://host:123#", NetworkUri::Subset_Full, u)); + + CHECK(!parse_network_uri("", NetworkUri::Subset_Full, u)); +} + +} // namespace address +} // namespace roc diff --git a/src/tests/roc_netio/test_resolve.cpp b/src/tests/roc_netio/test_resolve.cpp index 9d70f2490..acce94ded 100644 --- a/src/tests/roc_netio/test_resolve.cpp +++ b/src/tests/roc_netio/test_resolve.cpp @@ -25,7 +25,7 @@ core::SlabPool buffer_pool("buffer_pool", arena, MaxBufSize); core::SlabPool packet_pool("packet_pool", arena); bool resolve_endpoint_address(NetworkLoop& net_loop, - const address::EndpointUri& endpoint_uri, + const address::NetworkUri& endpoint_uri, address::SocketAddr& result_address) { NetworkLoop::Tasks::ResolveEndpointAddress task(endpoint_uri); CHECK(!task.success()); @@ -46,9 +46,9 @@ TEST(resolve, ipv4) { NetworkLoop net_loop(packet_pool, buffer_pool, arena); LONGS_EQUAL(status::StatusOK, net_loop.init_status()); - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri("rtp://127.0.0.1:123", - address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtp://127.0.0.1:123", + address::NetworkUri::Subset_Full, endpoint_uri)); address::SocketAddr address; CHECK(resolve_endpoint_address(net_loop, endpoint_uri, address)); @@ -61,9 +61,9 @@ TEST(resolve, ipv6) { NetworkLoop net_loop(packet_pool, buffer_pool, arena); LONGS_EQUAL(status::StatusOK, net_loop.init_status()); - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri("rtp://[::1]:123", - address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtp://[::1]:123", address::NetworkUri::Subset_Full, + endpoint_uri)); address::SocketAddr address; CHECK(resolve_endpoint_address(net_loop, endpoint_uri, address)); @@ -76,9 +76,9 @@ TEST(resolve, hostname) { NetworkLoop net_loop(packet_pool, buffer_pool, arena); LONGS_EQUAL(status::StatusOK, net_loop.init_status()); - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri("rtp://localhost:123", - address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtp://localhost:123", + address::NetworkUri::Subset_Full, endpoint_uri)); address::SocketAddr address; CHECK(resolve_endpoint_address(net_loop, endpoint_uri, address)); @@ -97,9 +97,9 @@ TEST(resolve, standard_port) { NetworkLoop net_loop(packet_pool, buffer_pool, arena); LONGS_EQUAL(status::StatusOK, net_loop.init_status()); - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri("rtsp://127.0.0.1", - address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtsp://127.0.0.1", address::NetworkUri::Subset_Full, + endpoint_uri)); address::SocketAddr address; CHECK(resolve_endpoint_address(net_loop, endpoint_uri, address)); @@ -112,25 +112,25 @@ TEST(resolve, bad_host) { LONGS_EQUAL(status::StatusOK, net_loop.init_status()); { // bad ipv4 - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri( - "rtp://300.0.0.1:123", address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtp://300.0.0.1:123", + address::NetworkUri::Subset_Full, endpoint_uri)); address::SocketAddr address; CHECK(!resolve_endpoint_address(net_loop, endpoint_uri, address)); } { // bad ipv6 - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri( - "rtp://[11::22::]:123", address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtp://[11::22::]:123", + address::NetworkUri::Subset_Full, endpoint_uri)); address::SocketAddr address; CHECK(!resolve_endpoint_address(net_loop, endpoint_uri, address)); } { // bad hostname - address::EndpointUri endpoint_uri(arena); - CHECK(address::parse_endpoint_uri( - "rtp://_:123", address::EndpointUri::Subset_Full, endpoint_uri)); + address::NetworkUri endpoint_uri(arena); + CHECK(address::parse_network_uri("rtp://_:123", address::NetworkUri::Subset_Full, + endpoint_uri)); address::SocketAddr address; CHECK(!resolve_endpoint_address(net_loop, endpoint_uri, address)); diff --git a/src/tests/roc_node/test_receiver.cpp b/src/tests/roc_node/test_receiver.cpp index f684243f9..d82091513 100644 --- a/src/tests/roc_node/test_receiver.cpp +++ b/src/tests/roc_node/test_receiver.cpp @@ -24,9 +24,9 @@ enum { DefaultSlot = 0 }; core::HeapArena arena; -void parse_uri(address::EndpointUri& uri, const char* str) { - CHECK(address::parse_endpoint_uri(str, address::EndpointUri::Subset_Full, uri)); - CHECK(uri.verify(address::EndpointUri::Subset_Full)); +void parse_uri(address::NetworkUri& uri, const char* str) { + CHECK(address::parse_network_uri(str, address::NetworkUri::Subset_Full, uri)); + CHECK(uri.verify(address::NetworkUri::Subset_Full)); } void write_slot_metrics(const pipeline::ReceiverSlotMetrics& slot_metrics, @@ -66,7 +66,7 @@ TEST(receiver, bind) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(source_endp.port() == 0); @@ -82,14 +82,14 @@ TEST(receiver, bind) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:0"); CHECK(source_endp1.port() == 0); CHECK(receiver.bind(0, address::Iface_AudioSource, source_endp1)); CHECK(source_endp1.port() != 0); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:0"); CHECK(source_endp2.port() == 0); @@ -113,7 +113,7 @@ TEST(receiver, configure) { LONGS_EQUAL(0, context.network_loop().num_ports()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(source_endp.port() == 0); @@ -135,14 +135,14 @@ TEST(receiver, configure) { LONGS_EQUAL(0, context.network_loop().num_ports()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:0"); CHECK(source_endp1.port() == 0); CHECK(receiver.bind(0, address::Iface_AudioSource, source_endp1)); CHECK(source_endp1.port() != 0); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:0"); CHECK(source_endp2.port() == 0); @@ -161,7 +161,7 @@ TEST(receiver, unlink) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(source_endp.port() == 0); @@ -181,14 +181,14 @@ TEST(receiver, unlink) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:0"); CHECK(source_endp1.port() == 0); CHECK(receiver.bind(0, address::Iface_AudioSource, source_endp1)); CHECK(source_endp1.port() != 0); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:0"); CHECK(source_endp2.port() == 0); @@ -208,14 +208,14 @@ TEST(receiver, unlink) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:0"); CHECK(source_endp1.port() == 0); CHECK(receiver.bind(0, address::Iface_AudioSource, source_endp1)); CHECK(source_endp1.port() != 0); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:0"); CHECK(source_endp2.port() == 0); @@ -236,10 +236,10 @@ TEST(receiver, unlink) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -257,13 +257,13 @@ TEST(receiver, unlink) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:0"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:0"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -286,7 +286,7 @@ TEST(receiver, endpoints_no_fec) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -304,13 +304,13 @@ TEST(receiver, endpoints_fec) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:0"); // fec is not supported CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:0"); // fec is not supported @@ -327,10 +327,10 @@ TEST(receiver, endpoints_fec) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:0"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -345,10 +345,10 @@ TEST(receiver, endpoints_fec) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:0"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "ldpc://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -363,10 +363,10 @@ TEST(receiver, endpoints_fec) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:0"); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+ldpc://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioRepair, repair_endp)); @@ -381,10 +381,10 @@ TEST(receiver, endpoints_fec) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -402,7 +402,7 @@ TEST(receiver, endpoints_control) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioControl, control_endp)); @@ -416,10 +416,10 @@ TEST(receiver, endpoints_control) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -435,13 +435,13 @@ TEST(receiver, endpoints_control) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:0"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:0"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -457,7 +457,7 @@ TEST(receiver, endpoints_control) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtp://127.0.0.1:0"); CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioControl, control_endp)); @@ -474,7 +474,7 @@ TEST(receiver, bind_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); CHECK(source_endp.set_proto(address::Proto_RTP)); CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -489,7 +489,7 @@ TEST(receiver, bind_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(source_endp.set_port(-1)); @@ -505,7 +505,7 @@ TEST(receiver, bind_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://invalid.:0"); CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -520,14 +520,14 @@ TEST(receiver, bind_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); LONGS_EQUAL(1, context.network_loop().num_ports()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); CHECK(control_endp.set_proto(address::Proto_RTCP)); CHECK(control_endp.set_host("127.0.0.1")); CHECK(control_endp.set_port(source_endp.port())); @@ -552,7 +552,7 @@ TEST(receiver, configure_errors) { CHECK(receiver.configure(DefaultSlot, address::Iface_AudioSource, iface_config)); CHECK(!receiver.has_broken_slots()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -574,7 +574,7 @@ TEST(receiver, configure_errors) { CHECK(receiver.configure(DefaultSlot, address::Iface_AudioSource, iface_config)); CHECK(!receiver.has_broken_slots()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); // bind to IPv4 address parse_uri(source_endp, "rtp://224.0.0.1:0"); @@ -597,7 +597,7 @@ TEST(receiver, configure_errors) { CHECK(receiver.configure(DefaultSlot, address::Iface_AudioSource, iface_config)); CHECK(!receiver.has_broken_slots()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); // bind to non-multicast address parse_uri(source_endp, "rtp://127.0.0.1:0"); @@ -616,7 +616,7 @@ TEST(receiver, flow_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -637,7 +637,7 @@ TEST(receiver, flow_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -669,7 +669,7 @@ TEST(receiver, flow_errors) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -693,10 +693,10 @@ TEST(receiver, recover) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://invalid.:0"); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:0"); CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp1)); @@ -727,10 +727,10 @@ TEST(receiver, recover) { Receiver receiver(context, receiver_config); LONGS_EQUAL(status::StatusOK, receiver.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://invalid.:0"); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:0"); CHECK(!receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp1)); @@ -772,7 +772,7 @@ TEST(receiver, metrics) { CHECK(!receiver.get_metrics(DefaultSlot, write_slot_metrics, &slot_metrics, write_party_metrics, &party_count, &party_metrics)); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:0"); CHECK(receiver.bind(DefaultSlot, address::Iface_AudioSource, source_endp)); diff --git a/src/tests/roc_node/test_sender.cpp b/src/tests/roc_node/test_sender.cpp index 45067e24f..8eca8cda3 100644 --- a/src/tests/roc_node/test_sender.cpp +++ b/src/tests/roc_node/test_sender.cpp @@ -23,9 +23,9 @@ enum { DefaultSlot = 0 }; core::HeapArena arena; -void parse_uri(address::EndpointUri& uri, const char* str) { - CHECK(address::parse_endpoint_uri(str, address::EndpointUri::Subset_Full, uri)); - CHECK(uri.verify(address::EndpointUri::Subset_Full)); +void parse_uri(address::NetworkUri& uri, const char* str) { + CHECK(address::parse_network_uri(str, address::NetworkUri::Subset_Full, uri)); + CHECK(uri.verify(address::NetworkUri::Subset_Full)); } void write_slot_metrics(const pipeline::SenderSlotMetrics& slot_metrics, void* slot_arg) { @@ -64,7 +64,7 @@ TEST(sender, connect) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -78,13 +78,13 @@ TEST(sender, connect) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:1000"); CHECK(sender.connect(0, address::Iface_AudioSource, source_endp1)); LONGS_EQUAL(1, context.network_loop().num_ports()); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:2000"); CHECK(sender.connect(1, address::Iface_AudioSource, source_endp2)); @@ -105,7 +105,7 @@ TEST(sender, configure) { LONGS_EQUAL(0, context.network_loop().num_ports()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -125,13 +125,13 @@ TEST(sender, configure) { LONGS_EQUAL(0, context.network_loop().num_ports()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:1000"); CHECK(sender.connect(0, address::Iface_AudioSource, source_endp1)); LONGS_EQUAL(1, context.network_loop().num_ports()); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:2000"); CHECK(sender.connect(1, address::Iface_AudioSource, source_endp2)); @@ -147,7 +147,7 @@ TEST(sender, unlink) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -165,13 +165,13 @@ TEST(sender, unlink) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:1000"); CHECK(sender.connect(0, address::Iface_AudioSource, source_endp1)); LONGS_EQUAL(1, context.network_loop().num_ports()); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:2000"); CHECK(sender.connect(1, address::Iface_AudioSource, source_endp2)); @@ -188,13 +188,13 @@ TEST(sender, unlink) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://127.0.0.1:1000"); CHECK(sender.connect(0, address::Iface_AudioSource, source_endp1)); LONGS_EQUAL(1, context.network_loop().num_ports()); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:2000"); CHECK(sender.connect(1, address::Iface_AudioSource, source_endp2)); @@ -212,10 +212,10 @@ TEST(sender, unlink) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1001"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1002"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -237,13 +237,13 @@ TEST(sender, unlink) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1003"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -268,7 +268,7 @@ TEST(sender, endpoints_no_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -302,14 +302,14 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); // fec is not supported CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); CHECK(sender.has_incomplete_slots()); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); // fec is not supported @@ -329,10 +329,10 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -350,7 +350,7 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+ldpc://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -367,7 +367,7 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "ldpc://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioRepair, repair_endp)); @@ -384,7 +384,7 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioRepair, repair_endp)); @@ -401,7 +401,7 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -418,7 +418,7 @@ TEST(sender, endpoints_fec) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioRepair, repair_endp)); @@ -441,16 +441,16 @@ TEST(sender, endpoints_fec_multiple_slots) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp1(arena); + address::NetworkUri repair_endp1(arena); parse_uri(repair_endp1, "rs8m://127.0.0.1:1002"); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp+rs8m://127.0.0.1:2001"); - address::EndpointUri repair_endp2(arena); + address::NetworkUri repair_endp2(arena); parse_uri(repair_endp2, "rs8m://127.0.0.1:2002"); CHECK(!sender.has_incomplete_slots()); @@ -478,7 +478,7 @@ TEST(sender, endpoints_control) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioControl, control_endp)); @@ -492,10 +492,10 @@ TEST(sender, endpoints_control) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1001"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1002"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -511,13 +511,13 @@ TEST(sender, endpoints_control) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1003"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -533,7 +533,7 @@ TEST(sender, endpoints_control) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtp://127.0.0.1:1001"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioControl, control_endp)); @@ -551,7 +551,7 @@ TEST(sender, connect_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); CHECK(source_endp.set_proto(address::Proto_RTP)); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -566,7 +566,7 @@ TEST(sender, connect_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(source_endp.set_port(-1)); @@ -582,7 +582,7 @@ TEST(sender, connect_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -590,7 +590,7 @@ TEST(sender, connect_errors) { LONGS_EQUAL(1, context.network_loop().num_ports()); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "ldpc://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioRepair, repair_endp)); @@ -605,7 +605,7 @@ TEST(sender, connect_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://invalid.:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -621,8 +621,8 @@ TEST(sender, connect_errors) { LONGS_EQUAL(status::StatusOK, sender.init_status()); netio::UdpConfig iface_config; - address::EndpointUri source_endp(arena); - address::EndpointUri repair_endp(arena); + address::NetworkUri source_endp(arena); + address::NetworkUri repair_endp(arena); CHECK(iface_config.bind_address.set_host_port_auto("127.0.0.1", 0)); parse_uri(source_endp, "rtp://127.0.0.1:1001"); @@ -657,7 +657,7 @@ TEST(sender, configure_errors) { CHECK(sender.configure(DefaultSlot, address::Iface_AudioSource, iface_config)); CHECK(!sender.has_broken_slots()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -678,7 +678,7 @@ TEST(sender, configure_errors) { CHECK(sender.configure(DefaultSlot, address::Iface_AudioSource, iface_config)); CHECK(!sender.has_broken_slots()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -699,7 +699,7 @@ TEST(sender, configure_errors) { CHECK(sender.configure(DefaultSlot, address::Iface_AudioControl, iface_config)); CHECK(!sender.has_broken_slots()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioControl, control_endp)); @@ -721,7 +721,7 @@ TEST(sender, configure_errors) { CHECK(sender.configure(DefaultSlot, address::Iface_AudioControl, iface_config)); CHECK(!sender.has_broken_slots()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); // connect to IPv4 address parse_uri(control_endp, "rtcp://224.0.0.1:1000"); @@ -744,7 +744,7 @@ TEST(sender, configure_errors) { CHECK(sender.configure(DefaultSlot, address::Iface_AudioControl, iface_config)); CHECK(!sender.has_broken_slots()); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); // connect to non-multicast address parse_uri(control_endp, "rtcp://127.0.0.1:1000"); @@ -763,7 +763,7 @@ TEST(sender, flow_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -784,7 +784,7 @@ TEST(sender, flow_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -816,7 +816,7 @@ TEST(sender, flow_errors) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -840,10 +840,10 @@ TEST(sender, recover) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://invalid.:1000"); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp1)); @@ -874,10 +874,10 @@ TEST(sender, recover) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp1(arena); + address::NetworkUri source_endp1(arena); parse_uri(source_endp1, "rtp://invalid.:1000"); - address::EndpointUri source_endp2(arena); + address::NetworkUri source_endp2(arena); parse_uri(source_endp2, "rtp://127.0.0.1:1000"); CHECK(!sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp1)); @@ -920,10 +920,10 @@ TEST(sender, port_sharing) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -935,13 +935,13 @@ TEST(sender, port_sharing) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); - address::EndpointUri control_endp(arena); + address::NetworkUri control_endp(arena); parse_uri(control_endp, "rtcp://127.0.0.1:1003"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -954,10 +954,10 @@ TEST(sender, port_sharing) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); netio::UdpConfig iface_config; @@ -975,10 +975,10 @@ TEST(sender, port_sharing) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://[::1]:1002"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); @@ -992,10 +992,10 @@ TEST(sender, port_sharing) { Sender sender(context, sender_config); LONGS_EQUAL(status::StatusOK, sender.init_status()); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp+rs8m://127.0.0.1:1001"); - address::EndpointUri repair_endp(arena); + address::NetworkUri repair_endp(arena); parse_uri(repair_endp, "rs8m://127.0.0.1:1002"); netio::UdpConfig iface_config1; @@ -1033,7 +1033,7 @@ TEST(sender, metrics) { CHECK(!sender.get_metrics(DefaultSlot, write_slot_metrics, &slot_metrics, write_party_metrics, &party_count, &party_metrics)); - address::EndpointUri source_endp(arena); + address::NetworkUri source_endp(arena); parse_uri(source_endp, "rtp://127.0.0.1:1000"); CHECK(sender.connect(DefaultSlot, address::Iface_AudioSource, source_endp)); diff --git a/src/tools/roc_recv/main.cpp b/src/tools/roc_recv/main.cpp index 30e9d8df8..7456bfa83 100644 --- a/src/tools/roc_recv/main.cpp +++ b/src/tools/roc_recv/main.cpp @@ -6,8 +6,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_address/endpoint_uri.h" #include "roc_address/io_uri.h" +#include "roc_address/network_uri.h" #include "roc_address/protocol_map.h" #include "roc_core/crash_handler.h" #include "roc_core/heap_arena.h" @@ -503,10 +503,10 @@ int main(int argc, char** argv) { } for (size_t slot = 0; slot < (size_t)args.source_given; slot++) { - address::EndpointUri endpoint(context.arena()); + address::NetworkUri endpoint(context.arena()); - if (!address::parse_endpoint_uri(args.source_arg[slot], - address::EndpointUri::Subset_Full, endpoint)) { + if (!address::parse_network_uri(args.source_arg[slot], + address::NetworkUri::Subset_Full, endpoint)) { roc_log(LogError, "can't parse --source endpoint: %s", args.source_arg[slot]); return 1; } @@ -536,10 +536,10 @@ int main(int argc, char** argv) { } for (size_t slot = 0; slot < (size_t)args.repair_given; slot++) { - address::EndpointUri endpoint(context.arena()); + address::NetworkUri endpoint(context.arena()); - if (!address::parse_endpoint_uri(args.repair_arg[slot], - address::EndpointUri::Subset_Full, endpoint)) { + if (!address::parse_network_uri(args.repair_arg[slot], + address::NetworkUri::Subset_Full, endpoint)) { roc_log(LogError, "can't parse --repair endpoint: %s", args.source_arg[slot]); return 1; } @@ -569,10 +569,10 @@ int main(int argc, char** argv) { } for (size_t slot = 0; slot < (size_t)args.control_given; slot++) { - address::EndpointUri endpoint(context.arena()); + address::NetworkUri endpoint(context.arena()); - if (!address::parse_endpoint_uri(args.control_arg[slot], - address::EndpointUri::Subset_Full, endpoint)) { + if (!address::parse_network_uri(args.control_arg[slot], + address::NetworkUri::Subset_Full, endpoint)) { roc_log(LogError, "can't parse --control endpoint: %s", args.control_arg[slot]); return 1; diff --git a/src/tools/roc_send/main.cpp b/src/tools/roc_send/main.cpp index 3315f845f..2550d2b8a 100644 --- a/src/tools/roc_send/main.cpp +++ b/src/tools/roc_send/main.cpp @@ -6,8 +6,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_address/endpoint_uri.h" #include "roc_address/io_uri.h" +#include "roc_address/network_uri.h" #include "roc_address/protocol_map.h" #include "roc_core/crash_handler.h" #include "roc_core/heap_arena.h" @@ -112,9 +112,9 @@ int main(int argc, char** argv) { } if (args.source_given) { - address::EndpointUri source_endpoint(heap_arena); - if (!address::parse_endpoint_uri( - args.source_arg[0], address::EndpointUri::Subset_Full, source_endpoint)) { + address::NetworkUri source_endpoint(heap_arena); + if (!address::parse_network_uri( + args.source_arg[0], address::NetworkUri::Subset_Full, source_endpoint)) { roc_log(LogError, "can't parse --source endpoint: %s", args.source_arg[0]); return 1; } @@ -452,10 +452,10 @@ int main(int argc, char** argv) { } for (size_t slot = 0; slot < (size_t)args.source_given; slot++) { - address::EndpointUri source_endpoint(context.arena()); - if (!address::parse_endpoint_uri(args.source_arg[slot], - address::EndpointUri::Subset_Full, - source_endpoint)) { + address::NetworkUri source_endpoint(context.arena()); + if (!address::parse_network_uri(args.source_arg[slot], + address::NetworkUri::Subset_Full, + source_endpoint)) { roc_log(LogError, "can't parse --source endpoint: %s", args.source_arg[slot]); return 1; } @@ -475,10 +475,10 @@ int main(int argc, char** argv) { } for (size_t slot = 0; slot < (size_t)args.repair_given; slot++) { - address::EndpointUri repair_endpoint(context.arena()); - if (!address::parse_endpoint_uri(args.repair_arg[slot], - address::EndpointUri::Subset_Full, - repair_endpoint)) { + address::NetworkUri repair_endpoint(context.arena()); + if (!address::parse_network_uri(args.repair_arg[slot], + address::NetworkUri::Subset_Full, + repair_endpoint)) { roc_log(LogError, "can't parse --repair endpoint: %s", args.repair_arg[slot]); return 1; } @@ -498,10 +498,10 @@ int main(int argc, char** argv) { } for (size_t slot = 0; slot < (size_t)args.control_given; slot++) { - address::EndpointUri control_endpoint(context.arena()); - if (!address::parse_endpoint_uri(args.control_arg[slot], - address::EndpointUri::Subset_Full, - control_endpoint)) { + address::NetworkUri control_endpoint(context.arena()); + if (!address::parse_network_uri(args.control_arg[slot], + address::NetworkUri::Subset_Full, + control_endpoint)) { roc_log(LogError, "can't parse --control endpoint: %s", args.control_arg[slot]); return 1;