Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apps] Receive the connection event on the client (caller) socket #597

Merged
merged 4 commits into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ int main( int argc, char** argv )
}

// IN because we care for state transitions only
int events = SRT_EPOLL_IN | SRT_EPOLL_ERR;
// OUT - to check the connection state changes
int events = SRT_EPOLL_IN | SRT_EPOLL_OUT | SRT_EPOLL_ERR;
switch(tar->uri.type())
{
case UriParser::SRT:
Expand All @@ -393,11 +394,12 @@ int main( int argc, char** argv )
}

int srtrfdslen = 2;
SRTSOCKET srtrfds[2];
int srtwfdslen = 2;
SRTSOCKET srtrwfds[4] = {SRT_INVALID_SOCK, SRT_INVALID_SOCK , SRT_INVALID_SOCK , SRT_INVALID_SOCK };
int sysrfdslen = 2;
SYSSOCKET sysrfds[2];
if (srt_epoll_wait(pollid,
&srtrfds[0], &srtrfdslen, 0, 0,
&srtrwfds[0], &srtrfdslen, &srtrwfds[2], &srtwfdslen,
100,
&sysrfds[0], &sysrfdslen, 0, 0) >= 0)
{
Expand All @@ -410,15 +412,18 @@ int main( int argc, char** argv )
}

bool doabort = false;
for (int i = 0; i < srtrfdslen; i++)
for (size_t i = 0; i < sizeof(srtrwfds) / sizeof(SRTSOCKET); i++)
{
SRTSOCKET s = srtrwfds[i];
if (s == SRT_INVALID_SOCK)
continue;

bool issource = false;
SRTSOCKET s = srtrfds[i];
if (src->GetSRTSocket() == s)
if (src && src->GetSRTSocket() == s)
{
issource = true;
}
else if (tar->GetSRTSocket() != s)
else if (tar && tar->GetSRTSocket() != s)
{
cerr << "Unexpected socket poll: " << s;
doabort = true;
Expand Down Expand Up @@ -530,6 +535,18 @@ int main( int argc, char** argv )
if (!quiet)
cerr << "SRT target connected" << endl;
tarConnected = true;
if (tar->uri.type() == UriParser::SRT)
{
const int events = SRT_EPOLL_IN | SRT_EPOLL_ERR;
// Disable OUT event polling when connected
if (srt_epoll_update_usock(pollid,
tar->GetSRTSocket(), &events))
{
cerr << "Failed to add SRT destination to poll, "
<< tar->GetSRTSocket() << endl;
return 1;
}
}
}
}

Expand Down