1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 12:21:55 +00:00

Support sequence header only for mp4

This commit is contained in:
winlin 2020-01-01 11:54:53 +08:00
parent c3e0dcfa9e
commit d2052fd4cd
3 changed files with 531 additions and 282 deletions

View file

@ -3884,6 +3884,11 @@ SrsMp4DecodingTime2SampleBox::~SrsMp4DecodingTime2SampleBox()
srs_error_t SrsMp4DecodingTime2SampleBox::initialize_counter()
{
srs_error_t err = srs_success;
// If only sps/pps and no frames, there is no stts entries.
if (entries.empty()) {
return err;
}
index = 0;
if (index >= entries.size()) {
@ -4005,6 +4010,11 @@ SrsMp4CompositionTime2SampleBox::~SrsMp4CompositionTime2SampleBox()
srs_error_t SrsMp4CompositionTime2SampleBox::initialize_counter()
{
srs_error_t err = srs_success;
// If only sps/pps and no frames, there is no stts entries.
if (entries.empty()) {
return err;
}
index = 0;
if (index >= entries.size()) {
@ -4812,7 +4822,7 @@ srs_error_t SrsMp4SampleManager::write(SrsMp4MovieBox* moov)
vector<SrsMp4Sample*>::iterator it;
for (it = samples.begin(); it != samples.end(); ++it) {
SrsMp4Sample* sample = *it;
if (sample->dts != sample->pts) {
if (sample->dts != sample->pts && sample->type == SrsFrameTypeVideo) {
has_cts = true;
break;
}
@ -5760,7 +5770,7 @@ srs_error_t SrsMp4Encoder::flush()
mvhd->duration_in_tbn = srs_max(vduration, aduration);
mvhd->next_track_ID = 1; // Starts from 1, increase when use it.
if (nb_videos) {
if (nb_videos || !pavcc.empty()) {
SrsMp4TrackBox* trak = new SrsMp4TrackBox();
moov->add_trak(trak);
@ -5824,7 +5834,7 @@ srs_error_t SrsMp4Encoder::flush()
avcC->avc_config = pavcc;
}
if (nb_audios) {
if (nb_audios || !pasc.empty()) {
SrsMp4TrackBox* trak = new SrsMp4TrackBox();
moov->add_trak(trak);

View file

@ -51,12 +51,18 @@ extern int _srs_tmp_port;
extern srs_utime_t _srs_tmp_timeout;
// For errors.
#define HELPER_EXPECT_SUCCESS(x) EXPECT_TRUE(srs_success == (err = x)); srs_freep(err)
#define HELPER_EXPECT_SUCCESS(x) \
if ((err = x) != srs_success) fprintf(stderr, "err %s", srs_error_desc(err).c_str()); \
EXPECT_TRUE(srs_success == err); \
srs_freep(err)
#define HELPER_EXPECT_FAILED(x) EXPECT_TRUE(srs_success != (err = x)); srs_freep(err)
// For errors, assert.
// @remark The err is leak when error, but it's ok in utest.
#define HELPER_ASSERT_SUCCESS(x) ASSERT_TRUE(srs_success == (err = x)); srs_freep(err)
#define HELPER_ASSERT_SUCCESS(x) \
if ((err = x) != srs_success) fprintf(stderr, "err %s", srs_error_desc(err).c_str()); \
ASSERT_TRUE(srs_success == err); \
srs_freep(err)
#define HELPER_ASSERT_FAILED(x) ASSERT_TRUE(srs_success != (err = x)); srs_freep(err)
// For init array data.

File diff suppressed because it is too large Load diff