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

[FIX] srt-test-multiplex: Fixed crash on medium error #2688

Merged
merged 1 commit into from Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 23 additions & 4 deletions testing/srt-test-multiplex.cpp
Expand Up @@ -313,7 +313,7 @@ bool PrepareStreamNames(const map<string,vector<string>>& params, bool mode_outp
return true;
}

bool SelectAndLink(SrtModel& m, string id, bool mode_output)
bool SelectAndLink(SrtModel& m, string id, bool mode_output, string& w_msg)
{
// So, we have made a connection that is now contained in m.
// For that connection we need to select appropriate stream
Expand All @@ -331,6 +331,7 @@ bool SelectAndLink(SrtModel& m, string id, bool mode_output)
{
// No medium available for that stream, ignore it.
m.Close();
w_msg = "No medium available for that stream";
return false;
}

Expand All @@ -345,20 +346,33 @@ bool SelectAndLink(SrtModel& m, string id, bool mode_output)

if ( mode_output )
{
target = Target::Create(medium);
if (!target)
{
m.Close();
w_msg = "Unable to create target medium: " + medium;
return false;
}

// Create Source out of SrtModel and Target from the given medium
auto s = new SrtSource();
s->StealFrom(m);
source.reset(s);

target = Target::Create(medium);

os << m.m_host << ":" << m.m_port << "[" << id << "]%" << sock << " -> " << medium;
thread_name = "TL>" + medium;
}
else
{
// Create Source of given medium and Target of SrtModel.
source = Source::Create(medium);
if (!source)
{
m.Close();
w_msg = "Unable to create source medium: " + medium;
return false;
}

auto t = new SrtTarget();
t->StealFrom(m);
target.reset(t);
Expand Down Expand Up @@ -607,13 +621,18 @@ int main( int argc, char** argv )
// the local resource of this id, and if this failed, simply
// close the stream and ignore it.

string msg;
// Select medium from parameters.
if (SelectAndLink(m, id, mode_output))
if (SelectAndLink((m), id, mode_output, (msg)))
{
ids.erase(id);
if (ids.empty())
break;
}
else
{
applog.Error() << "Unable to select a link for id=" << id << ": " << msg;
}

srt::ThreadName::set("main");
}
Expand Down