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

Removed chunk option. Made live mode use maximum payload size #862

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 2 additions & 9 deletions apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ struct LiveTransmitConfig
{
int timeout = 0;
int timeout_mode = 0;
int chunk_size = SRT_LIVE_DEF_PLSIZE;
bool quiet = false;
srt_logging::LogLevel::type loglevel = srt_logging::LogLevel::error;
set<srt_logging::LogFA> logfas;
Expand Down Expand Up @@ -169,7 +168,6 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)
o_timeout = { "t", "to", "timeout" },
o_timeout_mode = { "tm", "timeout-mode" },
o_autorecon = { "a", "auto", "autoreconnect" },
o_chunk = { "c", "chunk" },
o_bwreport = { "r", "bwreport", "report", "bandwidth-report", "bitrate-report" },
o_statsrep = { "s", "stats", "stats-report-frequency" },
o_statsout = { "statsout" },
Expand All @@ -188,7 +186,6 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)
{ o_timeout, OptionScheme::ARG_ONE },
{ o_timeout_mode, OptionScheme::ARG_ONE },
{ o_autorecon, OptionScheme::ARG_ONE },
{ o_chunk, OptionScheme::ARG_ONE },
{ o_bwreport, OptionScheme::ARG_ONE },
{ o_statsrep, OptionScheme::ARG_ONE },
{ o_statsout, OptionScheme::ARG_ONE },
Expand Down Expand Up @@ -232,7 +229,6 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)
PrintOptionHelp(o_timeout_mode, "<mode=0>", "timeout mode (0 - since app start; 1 - like 0, but cancel on connect");
#endif
PrintOptionHelp(o_autorecon, "<enabled=yes>", "auto-reconnect mode [yes|no]");
PrintOptionHelp(o_chunk, "<chunk=1316>", "max size of data read in one step");
PrintOptionHelp(o_bwreport, "<every_n_packets=0>", "bandwidth report frequency");
PrintOptionHelp(o_statsrep, "<every_n_packets=0>", "frequency of status report");
PrintOptionHelp(o_statsout, "<filename>", "output stats to file");
Expand Down Expand Up @@ -267,7 +263,6 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)

cfg.timeout = stoi(Option<OutString>(params, "0", o_timeout));
cfg.timeout_mode = stoi(Option<OutString>(params, "0", o_timeout_mode));
cfg.chunk_size = stoi(Option<OutString>(params, "1316", o_chunk));
cfg.bw_report = stoi(Option<OutString>(params, "0", o_bwreport));
cfg.stats_report = stoi(Option<OutString>(params, "0", o_statsrep));
cfg.stats_out = Option<OutString>(params, "", o_statsout);
Expand Down Expand Up @@ -339,8 +334,6 @@ int main(int argc, char** argv)
//
// Set global config variables
//
if (cfg.chunk_size != SRT_LIVE_DEF_PLSIZE)
transmit_chunk_size = cfg.chunk_size;
stats_writer = SrtStatsWriterFactory(cfg.stats_pf);
transmit_bw_report = cfg.bw_report;
transmit_stats_report = cfg.stats_report;
Expand Down Expand Up @@ -720,9 +713,9 @@ int main(int argc, char** argv)
while (dataqueue.size() < 10)
{
std::shared_ptr<bytevector> pdata(
new bytevector(cfg.chunk_size));
new bytevector(transmit_chunk_size));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the payload size of the target can be used if it is SRT and if source is STDIN. This way stdin->SRT&payload_size=1316 will be supported.
This can be determined on line 664 above, when case SRTS_CONNECTED:.
Then maybe we should not read from source until we have a target connected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If really needed for the console input, it can be also enforced by adding an attribute for the console spec URI: file://con?pkt_size=1316 (following the parameter name used by ffmpeg for UDP). This will enforce the console to read the packet up to this size.

The payload size as set to maximum in SRT will suffice anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is actually a good alternative.
file://con?pkt_size=1316

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the Source should have a packet size option instead 🤔 So you don't rely on the global transmit_chunk_size.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The application doesn't predict to have any source or target related options - other than those handled in URI. This one is actually an option specific for the console. In UDP, for example, it might be desired that this option be handled, but different way - when a single UDP reading provides more data, the application should break the transmission.


const int res = src->Read(cfg.chunk_size, *pdata, out_stats);
const int res = src->Read(transmit_chunk_size, *pdata, out_stats);

if (res == SRT_ERROR && src->uri.type() == UriParser::SRT)
{
Expand Down
12 changes: 4 additions & 8 deletions apps/transmitmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool g_stats_are_printed_to_stdout = false;
bool transmit_total_stats = false;
unsigned long transmit_bw_report = 0;
unsigned long transmit_stats_report = 0;
unsigned long transmit_chunk_size = SRT_LIVE_DEF_PLSIZE;
unsigned long transmit_chunk_size = SRT_LIVE_MAX_PLSIZE;

class FileSource: public Source
{
Expand Down Expand Up @@ -333,14 +333,10 @@ void SrtCommon::InitParameters(string host, map<string,string> par)
// Default mode is live, so check if the file mode was enforced
if (par.count("transtype") == 0 || par["transtype"] != "file")
{
// If the Live chunk size was nondefault, enforce the size.
if (transmit_chunk_size != SRT_LIVE_DEF_PLSIZE)
{
if (transmit_chunk_size > SRT_LIVE_MAX_PLSIZE)
throw std::runtime_error("Chunk size in live mode exceeds 1456 bytes; this is not supported");
if (transmit_chunk_size > SRT_LIVE_MAX_PLSIZE)
throw std::runtime_error("Chunk size in live mode exceeds 1456 bytes; this is not supported");

par["payloadsize"] = Sprint(transmit_chunk_size);
}
par["payloadsize"] = Sprint(transmit_chunk_size);
}

// Assign the others here.
Expand Down
1 change: 0 additions & 1 deletion docs/stransmit.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ shell (using quotes or backslash).
- The alarm is set up after the reading loop has started, **not when the application has started**. That is, a caller will still wait the standard timeout to connect, and a listener may wait infinitely until some peer connects; only after the connection is established is the alarm counting started. 
- **The timeout mechanism doesn't work on Windows at all.** It behaves as if the timeout was set to **-1** and it's not modifiable.
- **-timeout-mode, -tm** - timeout mode used. Default is 0 - timeout will happen after the specified time. Mode 1 cancels the timeout if the connection was established.
- **-chunk, -c** - use given size of the buffer. When 0, it uses default 1316, which is the maximum size for a single SRT sending call
- **-verbose, -v** - display additional information on the standard output. Note that it's not allowed to be combined with output specified as **file://con**
- **-stats", -stats-report-frequency, -s** - Output periodic SRT statistics reports to the standard output or file (see **-statsout**).
- **-statsout"** - SRT statistics output: filename. Without this option specified the statistics will be printed to standard output.
Expand Down
4 changes: 2 additions & 2 deletions srtcore/congctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ class FileCC : public SrtCongestionControlBase
m_bLoss = true;

const int pktsInFlight = m_parent->RTT() / m_dPktSndPeriod;
const int ackSeqno = m_iLastAck;// m_parent->sndLastDataAck();
const int sentSeqno = m_parent->sndSeqNo();
const int ackSeqno SRT_ATR_UNUSED = m_iLastAck;// m_parent->sndLastDataAck();
const int sentSeqno SRT_ATR_UNUSED = m_parent->sndSeqNo();
const int numPktsLost = m_parent->sndLossLength();
const int lost_pcent_x10 = (numPktsLost * 1000) / pktsInFlight;

Expand Down