Skip to content

Commit

Permalink
[apps] Fixed crash in srt-test-multiplex on medium error (#2688).
Browse files Browse the repository at this point in the history
  • Loading branch information
ethouris committed Mar 13, 2023
1 parent 1cffd2f commit 3982284
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions testing/srt-test-multiplex.cpp
Original file line number Diff line number Diff line change
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

0 comments on commit 3982284

Please sign in to comment.