mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine get_dash_update_period in time unit
This commit is contained in:
parent
4302ab7708
commit
12cf17ef6b
5 changed files with 15 additions and 13 deletions
|
@ -5912,9 +5912,9 @@ srs_utime_t SrsConfig::get_dash_fragment(string vhost)
|
||||||
return (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
|
return (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsConfig::get_dash_update_period(string vhost)
|
srs_utime_t SrsConfig::get_dash_update_period(string vhost)
|
||||||
{
|
{
|
||||||
static int DEFAULT = 30 * 1000;
|
static srs_utime_t DEFAULT = 30 * SRS_UTIME_SECONDS;
|
||||||
|
|
||||||
SrsConfDirective* conf = get_dash(vhost);
|
SrsConfDirective* conf = get_dash(vhost);
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
|
@ -5926,7 +5926,7 @@ int SrsConfig::get_dash_update_period(string vhost)
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)(1000 * ::atof(conf->arg0().c_str()));
|
return (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsConfig::get_dash_timeshift(string vhost)
|
int SrsConfig::get_dash_timeshift(string vhost)
|
||||||
|
|
|
@ -1151,10 +1151,10 @@ private:
|
||||||
public:
|
public:
|
||||||
// Whether DASH is enabled.
|
// Whether DASH is enabled.
|
||||||
virtual bool get_dash_enabled(std::string vhost);
|
virtual bool get_dash_enabled(std::string vhost);
|
||||||
// Get the duration of segment in milliseconds.
|
// Get the duration of segment in srs_utime_t.
|
||||||
virtual srs_utime_t get_dash_fragment(std::string vhost);
|
virtual srs_utime_t get_dash_fragment(std::string vhost);
|
||||||
// Get the period to update MPD in milliseconds.
|
// Get the period to update MPD in srs_utime_t.
|
||||||
virtual int get_dash_update_period(std::string vhost);
|
virtual srs_utime_t get_dash_update_period(std::string vhost);
|
||||||
// Get the depth of timeshift buffer in milliseconds.
|
// Get the depth of timeshift buffer in milliseconds.
|
||||||
virtual int get_dash_timeshift(std::string vhost);
|
virtual int get_dash_timeshift(std::string vhost);
|
||||||
// Get the base/home dir/path for dash, into which write files.
|
// Get the base/home dir/path for dash, into which write files.
|
||||||
|
|
|
@ -181,7 +181,7 @@ srs_error_t SrsMpdWriter::initialize(SrsRequest* r)
|
||||||
string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
|
string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
|
||||||
fragment_home = srs_path_dirname(mpd_path) + "/" + req->stream;
|
fragment_home = srs_path_dirname(mpd_path) + "/" + req->stream;
|
||||||
|
|
||||||
srs_trace("DASH: Config fragment=%d, period=%d", fragment, update_period);
|
srs_trace("DASH: Config fragment=%" PRId64 ", period=%" PRId64, fragment, update_period);
|
||||||
return srs_success;
|
return srs_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ srs_error_t SrsMpdWriter::write(SrsFormat* format)
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
// MPD is not expired?
|
// MPD is not expired?
|
||||||
if (last_update_mpd != -1 && srs_get_system_time_ms() - last_update_mpd < update_period) {
|
if (last_update_mpd != -1 && srs_get_system_time_ms() - last_update_mpd < update_period / SRS_UTIME_MILLISECONDS) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
last_update_mpd = srs_get_system_time_ms();
|
last_update_mpd = srs_get_system_time_ms();
|
||||||
|
@ -210,7 +210,7 @@ srs_error_t SrsMpdWriter::write(SrsFormat* format)
|
||||||
<< "<MPD profiles=\"urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash-if-simple\" " << endl
|
<< "<MPD profiles=\"urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash-if-simple\" " << endl
|
||||||
<< " ns1:schemaLocation=\"urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd\" " << endl
|
<< " ns1:schemaLocation=\"urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd\" " << endl
|
||||||
<< " xmlns=\"urn:mpeg:dash:schema:mpd:2011\" xmlns:ns1=\"http://www.w3.org/2001/XMLSchema-instance\" " << endl
|
<< " xmlns=\"urn:mpeg:dash:schema:mpd:2011\" xmlns:ns1=\"http://www.w3.org/2001/XMLSchema-instance\" " << endl
|
||||||
<< " type=\"dynamic\" minimumUpdatePeriod=\"PT" << update_period / 1000 << "S\" " << endl
|
<< " type=\"dynamic\" minimumUpdatePeriod=\"PT" << update_period / SRS_UTIME_SECONDS << "S\" " << endl
|
||||||
<< " timeShiftBufferDepth=\"PT" << timeshit / 1000 << "S\" availabilityStartTime=\"1970-01-01T00:00:00Z\" " << endl
|
<< " timeShiftBufferDepth=\"PT" << timeshit / 1000 << "S\" availabilityStartTime=\"1970-01-01T00:00:00Z\" " << endl
|
||||||
<< " maxSegmentDuration=\"PT" << fragment / SRS_UTIME_SECONDS << "S\" minBufferTime=\"PT" << fragment / SRS_UTIME_SECONDS << "S\" >" << endl
|
<< " maxSegmentDuration=\"PT" << fragment / SRS_UTIME_SECONDS << "S\" minBufferTime=\"PT" << fragment / SRS_UTIME_SECONDS << "S\" >" << endl
|
||||||
<< " <BaseURL>" << req->stream << "/" << "</BaseURL>" << endl
|
<< " <BaseURL>" << req->stream << "/" << "</BaseURL>" << endl
|
||||||
|
|
|
@ -86,10 +86,10 @@ private:
|
||||||
SrsRequest* req;
|
SrsRequest* req;
|
||||||
int64_t last_update_mpd;
|
int64_t last_update_mpd;
|
||||||
private:
|
private:
|
||||||
// The duration of fragment in ms.
|
// The duration of fragment in srs_utime_t.
|
||||||
srs_utime_t fragment;
|
srs_utime_t fragment;
|
||||||
// The period to update the mpd in ms.
|
// The period to update the mpd in srs_utime_t.
|
||||||
int update_period;
|
srs_utime_t update_period;
|
||||||
// The timeshift buffer depth.
|
// The timeshift buffer depth.
|
||||||
int timeshit;
|
int timeshit;
|
||||||
// The base or home dir for dash to write files.
|
// The base or home dir for dash to write files.
|
||||||
|
|
|
@ -1818,9 +1818,11 @@ VOID TEST(ConfigUnitTest, CheckDefaultValues)
|
||||||
if (true) {
|
if (true) {
|
||||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF));
|
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF));
|
||||||
EXPECT_EQ(3 * SRS_UTIME_SECONDS, conf.get_dash_fragment(""));
|
EXPECT_EQ(3 * SRS_UTIME_SECONDS, conf.get_dash_fragment(""));
|
||||||
|
EXPECT_EQ(30 * SRS_UTIME_SECONDS, conf.get_dash_update_period(""));
|
||||||
|
|
||||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{dash{dash_fragment 4;}}"));
|
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{dash{dash_fragment 4;dash_update_period 40;}}"));
|
||||||
EXPECT_EQ(4 * SRS_UTIME_SECONDS, conf.get_dash_fragment("v"));
|
EXPECT_EQ(4 * SRS_UTIME_SECONDS, conf.get_dash_fragment("v"));
|
||||||
|
EXPECT_EQ(40 * SRS_UTIME_SECONDS, conf.get_dash_update_period("v"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue