Skip to content

Commit 46d55c6

Browse files
authored
[apps] Added 'bind' parameter handling for applications (#2672).
1 parent 806f474 commit 46d55c6

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

apps/transmitmedia.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ void SrtCommon::InitParameters(string host, map<string,string> par)
121121
}
122122
}
123123

124+
if (par.count("bind"))
125+
{
126+
string bindspec = par.at("bind");
127+
UriParser u (bindspec, UriParser::EXPECT_HOST);
128+
if ( u.scheme() != ""
129+
|| u.path() != ""
130+
|| !u.parameters().empty()
131+
|| u.portno() == 0)
132+
{
133+
Error("Invalid syntax in 'bind' option");
134+
}
135+
136+
if (u.host() != "")
137+
par["adapter"] = u.host();
138+
par["port"] = u.port();
139+
par.erase("bind");
140+
}
141+
124142
string adapter;
125143
if (par.count("adapter"))
126144
{

docs/apps/srt-live-transmit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ srt://:5001?adapter=10.10.10.100
242242
- *port* part: remote port to connect to (mandatory)
243243
- **port** parameter: the local port to bind (default: 0 - "system autoselection")
244244
- **adapter** parameter: the local IP address to bind (default: 0.0.0.0 - "system selected device")
245+
- **bind** parameter: a shortcut to set adapter or port by specifying ADAPTER:PORT
245246

246247
```yaml
247248
srt://remote.host.com:5001

testing/testmedia.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,24 @@ void SrtCommon::InitParameters(string host, string path, map<string,string> par)
363363
#endif
364364
}
365365

366+
if (par.count("bind"))
367+
{
368+
string bindspec = par.at("bind");
369+
UriParser u (bindspec, UriParser::EXPECT_HOST);
370+
if ( u.scheme() != ""
371+
|| u.path() != ""
372+
|| !u.parameters().empty()
373+
|| u.portno() == 0)
374+
{
375+
Error("Invalid syntax in 'bind' option");
376+
}
377+
378+
if (u.host() != "")
379+
par["adapter"] = u.host();
380+
par["port"] = u.port();
381+
par.erase("bind");
382+
}
383+
366384
string adapter;
367385
if (par.count("adapter"))
368386
{
@@ -864,6 +882,7 @@ int SrtCommon::ConfigurePre(SRTSOCKET sock)
864882

865883
void SrtCommon::SetupAdapter(const string& host, int port)
866884
{
885+
Verb() << "Binding the caller socket to " << host << ":" << port << " ...";
867886
auto lsa = CreateAddr(host, port);
868887
int stat = srt_bind(m_sock, lsa.get(), sizeof lsa);
869888
if (stat == SRT_ERROR)

0 commit comments

Comments
 (0)