这段代码的简写如下:
if (pkt->type == VIDEO_RELAYPKG) {
recv_fps_++;
}
uint64_t cur_time = toolkit::getCurrentMillisecond(true);
if (last_print_time_ms == 0) {
last_print_time_ms = cur_time;
PrintT("CloseliOssSession::onSendMedia send first frame to clientid[%s], m_trace_id:[%s] ", _client_id.c_str(), _trace_id.c_str());
}
if (cur_time - last_print_time_ms >= 5000) {
last_print_time_ms = cur_time;
PrintT("CloseliOssSession::onSendMedia send frame fps:[%d] m_trace_id:[%s] clientid[%s]", (recv_fps_ / 5), _trace_id.c_str(), _client_id.c_str());
recv_fps_ = 0;
}
RawFrameHeader header;
fillRawHeader(pkt, header); // 根据pkt填写head内容
BufferLikeString closeli_raw_buffer;
switch (pkt->type)
{
case VIDEOCONFIG_RELAYPKG:
_video_config_buffer.clear();
_video_config_buffer.append((const char *)&header, sizeof(header));
_video_config_buffer.append(pkt->data(), pkt->size());
return;
case AUDIOCONFIG_RELAYPKG:
_audio_config_buffer.clear();
_audio_config_buffer.append((const char *)&header, sizeof(header));
_audio_config_buffer.append(pkt->data(), pkt->size());
return;
case AUDIO_RELAYPKG:
break;
case VIDEO_RELAYPKG:
{
if (pkt->sync > 0 && !_video_config_buffer.empty()) {
closeli_raw_buffer.append(_video_config_buffer);
closeli_raw_buffer.append(_audio_config_buffer);
}
}
break;
default:
return;
}
closeli_raw_buffer.append((const char *)&header, sizeof(header));
closeli_raw_buffer.append(pkt->data(), pkt->size());
注意:上述简写仅是将代码整理为更紧凑和易读的形式,并没有改变其功能。
内容由零声教学AI助手提供,问题来源于学员提问