-
Notifications
You must be signed in to change notification settings - Fork 863
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
Added -pf option with values json and default (#345) #356
Merged
+75
−13
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
92be8e3
Added -pf option with values json and default
3e42694
Removed printformat_default variable, added -pf option to info printout
5f3958a
Fixed typo in PrintSrtStats json, packetsDopped -> packetsDropped
23446cd
Changed PrintSrtStats (transmitmedia.cpp) to use a stringstream to bu…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ bool clear_stats = false; | |
unsigned long transmit_bw_report = 0; | ||
unsigned long transmit_stats_report = 0; | ||
unsigned long transmit_chunk_size = SRT_LIVE_DEF_PLSIZE; | ||
bool printformat_json = false; | ||
bool printformat_default = false; | ||
|
||
class FileSource: public Source | ||
{ | ||
|
@@ -103,17 +105,57 @@ Iface* CreateFile(const string& name) { return new typename File<Iface>::type (n | |
template <class PerfMonType> | ||
void PrintSrtStats(int sid, const PerfMonType& mon) | ||
{ | ||
cerr << "======= SRT STATS: sid=" << sid << endl; | ||
cerr << "PACKETS SENT: " << setw(11) << mon.pktSent << " RECEIVED: " << setw(11) << mon.pktRecv << endl; | ||
cerr << "LOST PKT SENT: " << setw(11) << mon.pktSndLoss << " RECEIVED: " << setw(11) << mon.pktRcvLoss << endl; | ||
cerr << "REXMIT SENT: " << setw(11) << mon.pktRetrans << " RECEIVED: " << setw(11) << mon.pktRcvRetrans << endl; | ||
cerr << "DROP PKT SENT: " << setw(11) << mon.pktSndDrop << " RECEIVED: " << setw(11) << mon.pktRcvDrop << endl; | ||
cerr << "RATE SENDING: " << setw(11) << mon.mbpsSendRate << " RECEIVING: " << setw(11) << mon.mbpsRecvRate << endl; | ||
cerr << "BELATED RECEIVED: " << setw(11) << mon.pktRcvBelated << " AVG TIME: " << setw(11) << mon.pktRcvAvgBelatedTime << endl; | ||
cerr << "REORDER DISTANCE: " << setw(11) << mon.pktReorderDistance << endl; | ||
cerr << "WINDOW FLOW: " << setw(11) << mon.pktFlowWindow << " CONGESTION: " << setw(11) << mon.pktCongestionWindow << " FLIGHT: " << setw(11) << mon.pktFlightSize << endl; | ||
cerr << "LINK RTT: " << setw(9) << mon.msRTT << "ms BANDWIDTH: " << setw(7) << mon.mbpsBandwidth << "Mb/s " << endl; | ||
cerr << "BUFFERLEFT: SND: " << setw(11) << mon.byteAvailSndBuf << " RCV: " << setw(11) << mon.byteAvailRcvBuf << endl; | ||
if (printformat_json) | ||
{ | ||
cerr << "{"; | ||
cerr << "\"sid\":" << sid << ","; | ||
cerr << "\"time\":" << mon.msTimeStamp << ","; | ||
cerr << "\"window\":{"; | ||
cerr << "\"flow\":" << mon.pktFlowWindow << ","; | ||
cerr << "\"congestion\":" << mon.pktCongestionWindow << ","; | ||
cerr << "\"flight\":" << mon.pktFlightSize; | ||
cerr << "},"; | ||
cerr << "\"link\":{"; | ||
cerr << "\"rtt\":" << mon.msRTT << ","; | ||
cerr << "\"bandwidth\":" << mon.mbpsBandwidth << ","; | ||
cerr << "\"maxBandwidth\":" << mon.mbpsMaxBW; | ||
cerr << "},"; | ||
cerr << "\"send\":{"; | ||
cerr << "\"packets\":" << mon.pktSent << ","; | ||
cerr << "\"packetsLost\":" << mon.pktSndLoss << ","; | ||
cerr << "\"packetsDropped\":" << mon.pktSndDrop << ","; | ||
cerr << "\"packetsRetransmitted\":" << mon.pktRetrans << ","; | ||
cerr << "\"bytes\":" << mon.byteSent << ","; | ||
cerr << "\"bytesDropped\":" << mon.byteSndDrop << ","; | ||
cerr << "\"mbitRate\":" << mon.mbpsSendRate; | ||
cerr << "},"; | ||
cerr << "\"recv\": {"; | ||
cerr << "\"packets\":" << mon.pktRecv << ","; | ||
cerr << "\"packetsLost\":" << mon.pktRcvLoss << ","; | ||
cerr << "\"packetsDopped\":" << mon.pktRcvDrop << ","; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/packetsDopped/packetsDropped/ ? |
||
cerr << "\"packetsRetransmitted\":" << mon.pktRcvRetrans << ","; | ||
cerr << "\"packetsBelated\":" << mon.pktRcvBelated << ","; | ||
cerr << "\"bytes\":" << mon.byteRecv << ","; | ||
cerr << "\"bytesLost\":" << mon.byteRcvLoss << ","; | ||
cerr << "\"bytesDropped\":" << mon.byteRcvDrop << ","; | ||
cerr << "\"mbitRate\":" << mon.mbpsRecvRate; | ||
cerr << "}"; | ||
cerr << "}" << endl; | ||
} | ||
else | ||
{ | ||
cerr << "======= SRT STATS: sid=" << sid << endl; | ||
cerr << "PACKETS SENT: " << setw(11) << mon.pktSent << " RECEIVED: " << setw(11) << mon.pktRecv << endl; | ||
cerr << "LOST PKT SENT: " << setw(11) << mon.pktSndLoss << " RECEIVED: " << setw(11) << mon.pktRcvLoss << endl; | ||
cerr << "REXMIT SENT: " << setw(11) << mon.pktRetrans << " RECEIVED: " << setw(11) << mon.pktRcvRetrans << endl; | ||
cerr << "DROP PKT SENT: " << setw(11) << mon.pktSndDrop << " RECEIVED: " << setw(11) << mon.pktRcvDrop << endl; | ||
cerr << "RATE SENDING: " << setw(11) << mon.mbpsSendRate << " RECEIVING: " << setw(11) << mon.mbpsRecvRate << endl; | ||
cerr << "BELATED RECEIVED: " << setw(11) << mon.pktRcvBelated << " AVG TIME: " << setw(11) << mon.pktRcvAvgBelatedTime << endl; | ||
cerr << "REORDER DISTANCE: " << setw(11) << mon.pktReorderDistance << endl; | ||
cerr << "WINDOW FLOW: " << setw(11) << mon.pktFlowWindow << " CONGESTION: " << setw(11) << mon.pktCongestionWindow << " FLIGHT: " << setw(11) << mon.pktFlightSize << endl; | ||
cerr << "LINK RTT: " << setw(9) << mon.msRTT << "ms BANDWIDTH: " << setw(7) << mon.mbpsBandwidth << "Mb/s " << endl; | ||
cerr << "BUFFERLEFT: SND: " << setw(11) << mon.byteAvailSndBuf << " RCV: " << setw(11) << mon.byteAvailRcvBuf << endl; | ||
} | ||
} | ||
|
||
|
||
|
@@ -602,7 +644,11 @@ bool SrtTarget::Write(const bytevector& data) | |
clear_stats = false; | ||
if ( transmit_bw_report && (counter % transmit_bw_report) == transmit_bw_report - 1 ) | ||
{ | ||
cerr << "+++/+++SRT BANDWIDTH: " << perf.mbpsBandwidth << endl; | ||
if (printformat_json) { | ||
cerr << "{\"bandwidth\":" << perf.mbpsBandwidth << '}' << endl; | ||
} else { | ||
cerr << "+++/+++SRT BANDWIDTH: " << perf.mbpsBandwidth << endl; | ||
} | ||
} | ||
if ( transmit_stats_report && (counter % transmit_stats_report) == transmit_stats_report - 1) | ||
{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be more efficient to write JSON into std::ostringstream and then send it to std::cerr in one go. Probably regular stats should do the same. If you rather not change this now I can do the change later together with other (overdue) clean up tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't
cerr
buffer all data up until theendl
?I'll fix the typo right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't think
std::cerr
buffers data by default, at least not according to the following quote from 'http://en.cppreference.com/w/cpp/io/cerr':Maybe another way to improve the code is to do
std::cerr << std::unitbuf << ... << std::nounitbuf << std::endl
but I am not sure if this approach is much better sincestd::cerr
is shared and if something somewhere else (another thread) does a flush on it there can still be a mess.std::ostringstream
is probably still safer (and clearer) way to go.