1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +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

@ -3885,6 +3885,11 @@ srs_error_t SrsMp4DecodingTime2SampleBox::initialize_counter()
{ {
srs_error_t err = srs_success; 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; index = 0;
if (index >= entries.size()) { if (index >= entries.size()) {
return srs_error_new(ERROR_MP4_ILLEGAL_TIMESTAMP, "illegal ts, empty stts"); return srs_error_new(ERROR_MP4_ILLEGAL_TIMESTAMP, "illegal ts, empty stts");
@ -4006,6 +4011,11 @@ srs_error_t SrsMp4CompositionTime2SampleBox::initialize_counter()
{ {
srs_error_t err = srs_success; 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; index = 0;
if (index >= entries.size()) { if (index >= entries.size()) {
return srs_error_new(ERROR_MP4_ILLEGAL_TIMESTAMP, "illegal ts, empty ctts"); return srs_error_new(ERROR_MP4_ILLEGAL_TIMESTAMP, "illegal ts, empty ctts");
@ -4812,7 +4822,7 @@ srs_error_t SrsMp4SampleManager::write(SrsMp4MovieBox* moov)
vector<SrsMp4Sample*>::iterator it; vector<SrsMp4Sample*>::iterator it;
for (it = samples.begin(); it != samples.end(); ++it) { for (it = samples.begin(); it != samples.end(); ++it) {
SrsMp4Sample* sample = *it; SrsMp4Sample* sample = *it;
if (sample->dts != sample->pts) { if (sample->dts != sample->pts && sample->type == SrsFrameTypeVideo) {
has_cts = true; has_cts = true;
break; break;
} }
@ -5760,7 +5770,7 @@ srs_error_t SrsMp4Encoder::flush()
mvhd->duration_in_tbn = srs_max(vduration, aduration); mvhd->duration_in_tbn = srs_max(vduration, aduration);
mvhd->next_track_ID = 1; // Starts from 1, increase when use it. mvhd->next_track_ID = 1; // Starts from 1, increase when use it.
if (nb_videos) { if (nb_videos || !pavcc.empty()) {
SrsMp4TrackBox* trak = new SrsMp4TrackBox(); SrsMp4TrackBox* trak = new SrsMp4TrackBox();
moov->add_trak(trak); moov->add_trak(trak);
@ -5824,7 +5834,7 @@ srs_error_t SrsMp4Encoder::flush()
avcC->avc_config = pavcc; avcC->avc_config = pavcc;
} }
if (nb_audios) { if (nb_audios || !pasc.empty()) {
SrsMp4TrackBox* trak = new SrsMp4TrackBox(); SrsMp4TrackBox* trak = new SrsMp4TrackBox();
moov->add_trak(trak); moov->add_trak(trak);

View file

@ -51,12 +51,18 @@ extern int _srs_tmp_port;
extern srs_utime_t _srs_tmp_timeout; extern srs_utime_t _srs_tmp_timeout;
// For errors. // 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) #define HELPER_EXPECT_FAILED(x) EXPECT_TRUE(srs_success != (err = x)); srs_freep(err)
// For errors, assert. // For errors, assert.
// @remark The err is leak when error, but it's ok in utest. // @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) #define HELPER_ASSERT_FAILED(x) ASSERT_TRUE(srs_success != (err = x)); srs_freep(err)
// For init array data. // For init array data.

File diff suppressed because it is too large Load diff