mirror of
				https://github.com/kunkundi/crossdesk.git
				synced 2025-10-26 20:25:34 +08:00 
			
		
		
		
	[fix] fix OBU_TEMPORAL_DELIMITER and OBU_SEQUENCE_HEADER obu data building
This commit is contained in:
		| @@ -25,6 +25,7 @@ class ByteBufferReader { | ||||
|   bool ReadBytes(char* val, size_t len); | ||||
|   bool ReadUInt8(uint8_t* val); | ||||
|   bool ReadUVarint(uint64_t* val); | ||||
|   bool ReadUVarint2(uint64_t* val, size_t* len); | ||||
|  | ||||
|   bool Consume(size_t size); | ||||
|  | ||||
|   | ||||
| @@ -50,10 +50,13 @@ std::vector<Obu> ParseObus(uint8_t* payload, int payload_size) { | ||||
|   std::vector<Obu> result; | ||||
|   ByteBufferReader payload_reader(reinterpret_cast<const char*>(payload), | ||||
|                                   payload_size); | ||||
|   int count = 0; | ||||
|   while (payload_reader.Length() > 0) { | ||||
|     count++; | ||||
|     Obu obu; | ||||
|     bool has_ext_header = false; | ||||
|     payload_reader.ReadUInt8(&obu.header); | ||||
|     LOG_ERROR("obu.header = [{:B}]", obu.header); | ||||
|     obu.size = 1; | ||||
|     if (ObuHasExtension(obu.header)) { | ||||
|       if (payload_reader.Length() == 0) { | ||||
| @@ -83,10 +86,14 @@ std::vector<Obu> ParseObus(uint8_t* payload, int payload_size) { | ||||
|             size, payload_reader.Length()); | ||||
|         return {}; | ||||
|       } | ||||
|  | ||||
|       obu.payload = std::vector<uint8_t>( | ||||
|           reinterpret_cast<const uint8_t*>(payload_reader.Data()), | ||||
|           reinterpret_cast<const uint8_t*>(payload_reader.Data()) + size); | ||||
|       if (0 == size) { | ||||
|         obu.payload.push_back(0); | ||||
|       } else { | ||||
|         obu.payload = std::vector<uint8_t>( | ||||
|             reinterpret_cast<const uint8_t*>(payload_reader.Data()), | ||||
|             reinterpret_cast<const uint8_t*>(payload_reader.Data()) + size); | ||||
|         obu.payload.insert(obu.payload.begin(), size); | ||||
|       } | ||||
|       payload_reader.Consume(size); | ||||
|       LOG_ERROR("Has size = {}", size); | ||||
|     } | ||||
| @@ -97,10 +104,11 @@ std::vector<Obu> ParseObus(uint8_t* payload, int payload_size) { | ||||
|       obu.payload.insert(obu.payload.begin(), obu.extension_header); | ||||
|     } | ||||
|     obu.payload.insert(obu.payload.begin(), obu.header); | ||||
|     if (obu_type != kObuTypeTileList &&  // | ||||
|         obu_type != kObuTypePadding) { | ||||
|       result.push_back(obu); | ||||
|     } | ||||
|     // if (obu_type != kObuTypeTileList &&  // | ||||
|     //     obu_type != kObuTypePadding) { | ||||
|     result.push_back(obu); | ||||
|     LOG_ERROR("obu size = {}", obu.payload.size()); | ||||
|     // } | ||||
|     // if (obu_type != kObuTypeTemporalDelimiter &&  // | ||||
|     //     obu_type != kObuTypeTileList &&           // | ||||
|     //     obu_type != kObuTypePadding) { | ||||
| @@ -108,6 +116,8 @@ std::vector<Obu> ParseObus(uint8_t* payload, int payload_size) { | ||||
|     // } | ||||
|   } | ||||
|  | ||||
|   LOG_ERROR("count = [{}]", count); | ||||
|  | ||||
|   for (int i = 0; i < result.size(); i++) { | ||||
|     LOG_ERROR("[{}] Obu size = [{}], Obu type [{}|{}]", i, result[i].size, | ||||
|               ObuType(result[i].payload[0]), | ||||
|   | ||||
| @@ -519,6 +519,8 @@ void RtpCodec::Encode(VideoFrameType frame_type, uint8_t* buffer, size_t size, | ||||
|       } | ||||
|     } | ||||
|   } else if (RtpPacket::PAYLOAD_TYPE::AV1 == payload_type_) { | ||||
|     LOG_ERROR("source [{:X} {:X} {:X} {:X}], size={}", buffer[0], buffer[1], | ||||
|               buffer[2], buffer[3], size); | ||||
|     std::vector<Obu> obus = ParseObus(buffer, size); | ||||
|     // LOG_ERROR("Total size = [{}]", size); | ||||
|  | ||||
| @@ -531,6 +533,9 @@ void RtpCodec::Encode(VideoFrameType frame_type, uint8_t* buffer, size_t size, | ||||
|       // LOG_ERROR("1 [{}] Obu size = [{}], Obu type [{}]", i, obus[i].size, | ||||
|       //           ObuTypeToString((OBU_TYPE)ObuType(obus[i].header))); | ||||
|  | ||||
|       LOG_ERROR("0 output [{:X} {:X}], size={}", obus[i].payload.data()[0], | ||||
|                 obus[i].payload.data()[1], obus[i].payload.size()); | ||||
|  | ||||
|       if (obus[i].size <= MAX_NALU_LEN) { | ||||
|         RtpPacket rtp_packet; | ||||
|         rtp_packet.SetVerion(version_); | ||||
| @@ -562,9 +567,8 @@ void RtpCodec::Encode(VideoFrameType frame_type, uint8_t* buffer, size_t size, | ||||
|         rtp_packet.EncodeAv1(obus[i].payload.data(), obus[i].size); | ||||
|         // int type = (obus[i].payload[0] & 0b0'1111'000) >> 3; | ||||
|         int type = (rtp_packet.Payload()[0] & 0b0'1111'000) >> 3; | ||||
|         LOG_ERROR("!!!!! Obu type = [{}]", type); | ||||
|         LOG_ERROR("output [{:X} {:X}]", rtp_packet.Payload()[0], | ||||
|                   rtp_packet.Payload()[1]); | ||||
|         LOG_ERROR("1 output [{:X} {:X}], size={}", rtp_packet.Payload()[0], | ||||
|                   rtp_packet.Payload()[1], rtp_packet.PayloadSize()); | ||||
|  | ||||
|         packets.emplace_back(rtp_packet); | ||||
|       } else { | ||||
|   | ||||
| @@ -16,6 +16,8 @@ RtpVideoReceiver::~RtpVideoReceiver() { | ||||
| } | ||||
|  | ||||
| void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) { | ||||
|   LOG_ERROR("1 input [{:X} {:X}], size={}", rtp_packet.Payload()[0], | ||||
|             rtp_packet.Payload()[1], rtp_packet.PayloadSize()); | ||||
|   if (!rtp_statistics_) { | ||||
|     rtp_statistics_ = std::make_unique<RtpStatistics>(); | ||||
|     rtp_statistics_->Start(); | ||||
| @@ -237,8 +239,8 @@ bool RtpVideoReceiver::CheckIsH264FrameCompleted(RtpPacket& rtp_packet) { | ||||
| } | ||||
|  | ||||
| bool RtpVideoReceiver::CheckIsAv1FrameCompleted(RtpPacket& rtp_packet) { | ||||
|   LOG_ERROR("input [{:X} {:X}]", rtp_packet.Payload()[0], | ||||
|             rtp_packet.Payload()[1]); | ||||
|   LOG_ERROR("2 input [{:X} {:X}], size={}", rtp_packet.Payload()[0], | ||||
|             rtp_packet.Payload()[1], rtp_packet.PayloadSize()); | ||||
|  | ||||
|   if (rtp_packet.Av1FrameEnd()) { | ||||
|     uint16_t end_seq = rtp_packet.SequenceNumber(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user