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

Bugfix: HEVC SRT stream supports multiple PPS fields. v6.0.76 (#3722)

When the srs have multiple pps in hevc.the srs can't parse for this.
problem fixed this #3604

---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: john <hondaxiao@tencent.com>
This commit is contained in:
qyt 2023-09-18 10:54:19 +08:00 committed by winlin
parent add0f369c5
commit 4362df743b
9 changed files with 127 additions and 18 deletions

View file

@ -382,7 +382,7 @@ srs_error_t SrsRawHEVCStream::pps_demux(char *frame, int nb_frame, std::string &
return err;
}
srs_error_t SrsRawHEVCStream::mux_sequence_header(std::string vps, std::string sps, std::string pps, std::string &hvcC)
srs_error_t SrsRawHEVCStream::mux_sequence_header(std::string vps, std::string sps, std::vector<std::string>& pps, std::string &hvcC)
{
srs_error_t err = srs_success;
@ -400,8 +400,13 @@ srs_error_t SrsRawHEVCStream::mux_sequence_header(std::string vps, std::string s
// sequenceParameterSetNALUnit
// use simple mode: nalu size + nalu data
int nb_packet = 23 + 5 + (int)vps.length() + 5 + (int)sps.length() + 5 + (int)pps.length();
char *packet = new char[nb_packet];
int pps_size = 0;
for (std::vector<std::string>::iterator it = pps.begin(); it != pps.end(); it++) {
pps_size += 2 + it->length();
}
int nb_packet = 23 + 5 + (int)vps.length() + 5 + (int)sps.length() + 5 + pps_size - 2;
char* packet = new char[nb_packet];
SrsAutoFreeA(char, packet);
// use stream to generate the hevc packet.
@ -495,12 +500,15 @@ srs_error_t SrsRawHEVCStream::mux_sequence_header(std::string vps, std::string s
if (true) {
// nal_type
stream.write_1bytes(SrsHevcNaluType_PPS & 0x3f);
// numOfPictureParameterSets, always 1
stream.write_2bytes(0x01);
// pictureParameterSetLength
stream.write_2bytes((int16_t)pps.length());
// pictureParameterSetNALUnit
stream.write_string(pps);
// numOfPictureParameterSets
stream.write_2bytes(pps.size());
for (std::vector<std::string>::iterator it = pps.begin(); it != pps.end(); it++) {
//pictureParameterSetLength
stream.write_2bytes((int16_t)it->length());
//pictureParameterSetNALUnit
stream.write_string(*it);
}
}
hvcC = string(packet, nb_packet);