1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #299, fix some bugs in dash, it works now. 3.0.88

This commit is contained in:
winlin 2019-12-27 20:47:33 +08:00
parent 043781fe81
commit d11a7b2e00
6 changed files with 220 additions and 59 deletions

View file

@ -34,6 +34,7 @@
#include <srs_core_autofree.hpp>
#include <srs_kernel_mp4.hpp>
#include <stdlib.h>
#include <sstream>
using namespace std;
@ -276,10 +277,17 @@ srs_error_t SrsMpdWriter::get_fragment(bool video, std::string& home, std::strin
srs_error_t err = srs_success;
home = fragment_home;
sn = srs_update_system_time() / fragment;
// We name the segment as advanced N segments, because when we are generating segment at the current time,
// the player may also request the current segment.
srs_assert(fragment);
int64_t number = (srs_update_system_time() / fragment + 1);
// TOOD: FIXME: Should keep the segments continuous, or player may fail.
sn = number;
// The base time aligned with sn.
basetime = sn * fragment;
if (video) {
file_name = "video-" + srs_int2str(sn) + ".m4s";
} else {
@ -292,7 +300,7 @@ srs_error_t SrsMpdWriter::get_fragment(bool video, std::string& home, std::strin
SrsDashController::SrsDashController()
{
req = NULL;
video_tack_id = 2;
video_tack_id = 0;
audio_track_id = 1;
mpd = new SrsMpdWriter();
vcurrent = acurrent = NULL;
@ -332,6 +340,10 @@ srs_error_t SrsDashController::on_publish()
fragment = _srs_config->get_dash_fragment(r->vhost);
home = _srs_config->get_dash_path(r->vhost);
if ((err = mpd->on_publish()) != srs_success) {
return srs_error_wrap(err, "mpd");
}
srs_freep(vcurrent);
vcurrent = new SrsFragmentedMp4();
if ((err = vcurrent->initialize(req, true, mpd, video_tack_id)) != srs_success) {
@ -344,10 +356,6 @@ srs_error_t SrsDashController::on_publish()
return srs_error_wrap(err, "audio fragment");
}
if ((err = mpd->on_publish()) != srs_success) {
return srs_error_wrap(err, "mpd");
}
return err;
}