mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
replace the placeholder of ts url in m3u8 (#2549)
This commit is contained in:
parent
b874d9c9ba
commit
93cd025e2a
2 changed files with 19 additions and 6 deletions
|
@ -63,6 +63,17 @@ void SrsHlsSegment::config_cipher(unsigned char* key,unsigned char* iv)
|
||||||
|
|
||||||
SrsEncFileWriter* fw = (SrsEncFileWriter*)writer;
|
SrsEncFileWriter* fw = (SrsEncFileWriter*)writer;
|
||||||
fw->config_cipher(key, iv);
|
fw->config_cipher(key, iv);
|
||||||
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsHlsSegment::rename()
|
||||||
|
{
|
||||||
|
if (true) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << srsu2msi(duration());
|
||||||
|
uri = srs_string_replace(uri, "[duration]", ss.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return SrsFragment::rename();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsContextId c, SrsRequest* r, string p, string t, string m, string mu, int s, srs_utime_t d)
|
SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsContextId c, SrsRequest* r, string p, string t, string m, string mu, int s, srs_utime_t d)
|
||||||
|
@ -607,6 +618,11 @@ srs_error_t SrsHlsMuxer::do_segment_close()
|
||||||
bool matchMinDuration = current->duration() >= SRS_HLS_SEGMENT_MIN_DURATION;
|
bool matchMinDuration = current->duration() >= SRS_HLS_SEGMENT_MIN_DURATION;
|
||||||
bool matchMaxDuration = current->duration() <= max_td * 2 * 1000;
|
bool matchMaxDuration = current->duration() <= max_td * 2 * 1000;
|
||||||
if (matchMinDuration && matchMaxDuration) {
|
if (matchMinDuration && matchMaxDuration) {
|
||||||
|
// rename from tmp to real path
|
||||||
|
if ((err = current->rename()) != srs_success) {
|
||||||
|
return srs_error_wrap(err, "rename");
|
||||||
|
}
|
||||||
|
|
||||||
// use async to call the http hooks, for it will cause thread switch.
|
// use async to call the http hooks, for it will cause thread switch.
|
||||||
if ((err = async->execute(new SrsDvrAsyncCallOnHls(_srs_context->get_id(), req, current->fullpath(),
|
if ((err = async->execute(new SrsDvrAsyncCallOnHls(_srs_context->get_id(), req, current->fullpath(),
|
||||||
current->uri, m3u8, m3u8_url, current->sequence_no, current->duration()))) != srs_success) {
|
current->uri, m3u8, m3u8_url, current->sequence_no, current->duration()))) != srs_success) {
|
||||||
|
@ -620,12 +636,7 @@ srs_error_t SrsHlsMuxer::do_segment_close()
|
||||||
|
|
||||||
// close the muxer of finished segment.
|
// close the muxer of finished segment.
|
||||||
srs_freep(current->tscw);
|
srs_freep(current->tscw);
|
||||||
|
|
||||||
// rename from tmp to real path
|
|
||||||
if ((err = current->rename()) != srs_success) {
|
|
||||||
return srs_error_wrap(err, "rename");
|
|
||||||
}
|
|
||||||
|
|
||||||
segments->append(current);
|
segments->append(current);
|
||||||
current = NULL;
|
current = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
virtual ~SrsHlsSegment();
|
virtual ~SrsHlsSegment();
|
||||||
public:
|
public:
|
||||||
void config_cipher(unsigned char* key,unsigned char* iv);
|
void config_cipher(unsigned char* key,unsigned char* iv);
|
||||||
|
// replace the placeholder
|
||||||
|
virtual srs_error_t rename();
|
||||||
};
|
};
|
||||||
|
|
||||||
// The hls async call: on_hls
|
// The hls async call: on_hls
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue