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

Update receiver bandwidth print to respect pf:json #402

Merged
merged 2 commits into from
Jun 1, 2018
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
23 changes: 16 additions & 7 deletions apps/transmitmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Iface* CreateFile(const string& name) { return new typename File<Iface>::type (n


template <class PerfMonType>
void PrintSrtStats(int sid, const PerfMonType& mon)
static void PrintSrtStats(int sid, const PerfMonType& mon)
{
std::ostringstream output;

Expand Down Expand Up @@ -161,6 +161,19 @@ void PrintSrtStats(int sid, const PerfMonType& mon)
cerr << output.str() << std::flush;
}

static void PrintSrtBandwidth(double mbpsBandwidth)
{
std::ostringstream output;

if (printformat_json) {
output << "{\"bandwidth\":" << mbpsBandwidth << '}' << endl;
} else {
output << "+++/+++SRT BANDWIDTH: " << mbpsBandwidth << endl;
}

cerr << output.str() << std::flush;
}


void SrtCommon::InitParameters(string host, map<string,string> par)
{
Expand Down Expand Up @@ -601,7 +614,7 @@ bool SrtSource::Read(size_t chunk, bytevector& data)
clear_stats = false;
if ( transmit_bw_report && (counter % transmit_bw_report) == transmit_bw_report - 1 )
{
cerr << "+++/+++SRT BANDWIDTH: " << perf.mbpsBandwidth << endl;
PrintSrtBandwidth(perf.mbpsBandwidth);
}
if ( transmit_stats_report && (counter % transmit_stats_report) == transmit_stats_report - 1)
{
Expand Down Expand Up @@ -647,11 +660,7 @@ bool SrtTarget::Write(const bytevector& data)
clear_stats = false;
if ( transmit_bw_report && (counter % transmit_bw_report) == transmit_bw_report - 1 )
{
if (printformat_json) {
cerr << "{\"bandwidth\":" << perf.mbpsBandwidth << '}' << endl;
} else {
cerr << "+++/+++SRT BANDWIDTH: " << perf.mbpsBandwidth << endl;
}
PrintSrtBandwidth(perf.mbpsBandwidth);
}
if ( transmit_stats_report && (counter % transmit_stats_report) == transmit_stats_report - 1)
{
Expand Down