WebrtcでH 264 start codeを追加

1702 ワード

以前のバージョンでは、57などのバージョンは、この関数によって実現されました.
size_t VCMSessionInfo::Insert(const uint8_t* buffer,
                              size_t length,
                              bool insert_start_code,
                              uint8_t* frame_buffer)

 
 
次のバージョンでは、次のようになります.
H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream(     VCMPacket* packet)
 
 
//ここで実行が完了したらpacket_に追加buffer_を選択して設定できます.
int32_t RtpVideoStreamReceiver::OnReceivedPayloadData(     const uint8_t* payload_data,     size_t payload_size,     const WebRtcRTPHeader* rtp_header,     const absl::optional& generic_descriptor,     bool is_recovered) {
......
  if (packet.codec() == kVideoCodecH264) {    //Only when we start to receive packets will we know what payload type    //that will be used. When we know the payload type insert the correct    //sps/pps into the tracker.     if (packet.payloadType != last_payload_type_) {       last_payload_type_ = packet.payloadType;       InsertSpsPpsIntoTracker(packet.payloadType);     }
    switch (tracker_.CopyAndFixBitstream(&packet)) {       case video_coding::H264SpsPpsTracker::kRequestKeyframe:         keyframe_request_sender_->RequestKeyFrame();         RTC_FALLTHROUGH();       case video_coding::H264SpsPpsTracker::kDrop:         return 0;       case video_coding::H264SpsPpsTracker::kInsert:         break;     }
  } else {     uint8_t* data = new uint8_t[packet.sizeBytes];     memcpy(data, packet.dataPtr, packet.sizeBytes);     packet.dataPtr = data;   }
  packet_buffer_->InsertPacket(&packet);   return 0; }