ZBLOG

简写代码 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 f...

这段代码的简写如下:

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助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:http://sdn.0voice.com/?id=4162

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?