mirror of https://github.com/ossrs/srs.git
SRT: url supports multiple QueryStrings (#2908)
* SRT: parse srt url to supports multiple QueryStrings.(#2893) * SRT: url supports multiple QueryStrings by comma-separated key-value pairs with no nesting (#2893) * SRT: url supports multiple QueryStrings by comma-separated key-value pairs with no nesting (#2893) * SRT: Add comments for url. * Add utest for SRT URL parsing. * Update README. Co-authored-by: winlin <winlin@vip.126.com>pull/3040/head
parent
06cff31b24
commit
210cdf04be
@ -0,0 +1,79 @@
|
||||
//
|
||||
// Copyright (c) 2013-2021 Winlin
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
#include <srs_utest_srt.hpp>
|
||||
|
||||
#include <srs_kernel_error.hpp>
|
||||
#include <srt_conn.hpp>
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
VOID TEST(ProtocolSrtTest, SrtGetStreamInfoNormal) {
|
||||
int mode; string vhost; string subpath;
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::r=live/livestream,key1=value1,key2=value2", mode, vhost, subpath));
|
||||
EXPECT_EQ(PULL_SRT_MODE, mode);
|
||||
EXPECT_STREQ("", vhost.c_str());
|
||||
EXPECT_STREQ("live/livestream?key1=value1&key2=value2", subpath.c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::h=host.com,r=live/livestream,key1=value1,key2=value2", mode, vhost, subpath));
|
||||
EXPECT_EQ(PULL_SRT_MODE, mode);
|
||||
EXPECT_STREQ("host.com", vhost.c_str());
|
||||
EXPECT_STREQ("live/livestream?vhost=host.com&key1=value1&key2=value2", subpath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ProtocolSrtTest, SrtGetStreamInfoMethod) {
|
||||
int mode; string vhost; string subpath;
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::r=live/livestream,m=request", mode, vhost, subpath));
|
||||
EXPECT_EQ(PULL_SRT_MODE, mode);
|
||||
EXPECT_STREQ("live/livestream", subpath.c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::r=live/livestream,m=publish", mode, vhost, subpath));
|
||||
EXPECT_EQ(PUSH_SRT_MODE, mode);
|
||||
EXPECT_STREQ("live/livestream", subpath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ProtocolSrtTest, SrtGetStreamInfoCompatible) {
|
||||
int mode; string vhost; string subpath;
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::h=live/livestream,m=request", mode, vhost, subpath));
|
||||
EXPECT_EQ(PULL_SRT_MODE, mode);
|
||||
EXPECT_STREQ("", vhost.c_str());
|
||||
EXPECT_STREQ("live/livestream", subpath.c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::h=live/livestream,m=publish", mode, vhost, subpath));
|
||||
EXPECT_EQ(PUSH_SRT_MODE, mode);
|
||||
EXPECT_STREQ("", vhost.c_str());
|
||||
EXPECT_STREQ("live/livestream", subpath.c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::h=srs.srt.com.cn/live/livestream,m=request", mode, vhost, subpath));
|
||||
EXPECT_EQ(PULL_SRT_MODE, mode);
|
||||
EXPECT_STREQ("srs.srt.com.cn", vhost.c_str());
|
||||
EXPECT_STREQ("live/livestream?vhost=srs.srt.com.cn", subpath.c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(get_streamid_info("#!::h=srs.srt.com.cn/live/livestream,m=publish", mode, vhost, subpath));
|
||||
EXPECT_EQ(PUSH_SRT_MODE, mode);
|
||||
EXPECT_STREQ("srs.srt.com.cn", vhost.c_str());
|
||||
EXPECT_STREQ("live/livestream?vhost=srs.srt.com.cn", subpath.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
//
|
||||
// Copyright (c) 2013-2021 Winlin
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
|
||||
#ifndef SRS_UTEST_SRT_HPP
|
||||
#define SRS_UTEST_SRT_HPP
|
||||
|
||||
/*
|
||||
#include <srs_utest_srt.hpp>
|
||||
*/
|
||||
#include <srs_utest.hpp>
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue