Webrtc中如何展示窗口内容,同时不包含window title

Webrtc内置2种视频源捕捉器,屏幕的窗体的。它的窗体模式是带着微软视窗系统所有的window标准的标题栏的,也就是windows title。 那么怎么获取纯净的窗口内容,不要标题栏呢?

需要自己稍微计算下区域。 如下代码

重点就是 windows title 默认的高度是30个像素,代码中用startYPosition 操作。

void QLWindowCaptureImpl::OnCaptureResult (webrtc::DesktopCapturer::Result result, std::unique_ptr<webrtc::DesktopFrame> desktopframe)
{
    if (result != webrtc::DesktopCapturer::Result::SUCCESS)
    {
        return;
    }
 
    int width = desktopframe->stride () / 4;
    int startYPosition = 0;
    int height = desktopframe->size ().height ();
 
    if (QL::QLGlobalConfig::get_instance().IsHideWindowTitleInAppCaptureType())
    {
        //This is offical window title height;
        startYPosition = 30;
        height -= startYPosition;
    }
 
    if (!mI420YUVBuffer.get () || mI420YUVBuffer->width () * mI420YUVBuffer->height () < width * height)
    {
        mI420YUVBuffer = webrtc::I420Buffer::Create (width, height);
    }
 
    int stride = width;
    uint8_t* yplane = mI420YUVBuffer->MutableDataY ();
    uint8_t* uplane = mI420YUVBuffer->MutableDataU ();
    uint8_t* vplane = mI420YUVBuffer->MutableDataV ();
 
    libyuv::ConvertToI420 (desktopframe->data (), 0, yplane, stride, uplane,
                           (stride + 1) / 2, vplane, (stride + 1) / 2, 0, startYPosition,
                           width, height, width, height, libyuv::kRotate0,
                           libyuv::FOURCC_ARGB);
 
    webrtc::VideoFrame frame = webrtc::VideoFrame (mI420YUVBuffer, 0, 0, webrtc::kVideoRotation_0);
 
    //将这个VideoFrame数据压倒流中,传出去
    this->OnFrame (frame);
}

本文来自作者投稿,版权归原作者所有。如需转载,请注明出处:https://www.nxrte.com/jishu/webrtc/25940.html

(0)

相关推荐

发表回复

登录后才能评论