Skip to content

feat(ext-image-capture): Add ext-image-capture components for screen …#761

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:treelandcommit1
Nov 27, 2025
Merged

feat(ext-image-capture): Add ext-image-capture components for screen …#761
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:treelandcommit1

Conversation

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member

…recording

  • Introduce core management classes including ExtCaptureManager, ExtCaptureSession, ExtCaptureRecorder, and ExtCaptureFrame
  • Implement ExtCaptureBridge to facilitate data transfer between the capture source and the recording process
  • Integrate support for image capture protocols to enhance overall screen recording capabilities
  • Update project configuration to include new source and header files for the ext-image-capture module
  • Lay the groundwork for advanced screen recording features integrating with Wayland protocols

特性(ext-image-capture): 添加屏幕录制相关的 ext-image-capture 组件

  • 引入核心管理类,包括 ExtCaptureManager、ExtCaptureSession、ExtCaptureRecorder 和 ExtCaptureFrame
  • 实现 ExtCaptureBridge 以促进捕获源与录制流程之间的数据传输
  • 集成图像捕获协议支持,以增强整体屏幕录制能力
  • 更新工程配置,包含 ext-image-capture 模块的新源文件和头文件

…recording

- Introduce core management classes including ExtCaptureManager, ExtCaptureSession, ExtCaptureRecorder, and ExtCaptureFrame
- Implement ExtCaptureBridge to facilitate data transfer between the capture source and the recording process
- Integrate support for image capture protocols to enhance overall screen recording capabilities
- Update project configuration to include new source and header files for the ext-image-capture module
- Lay the groundwork for advanced screen recording features integrating with Wayland protocols

特性(ext-image-capture): 添加屏幕录制相关的 ext-image-capture 组件

- 引入核心管理类,包括 ExtCaptureManager、ExtCaptureSession、ExtCaptureRecorder 和 ExtCaptureFrame
- 实现 ExtCaptureBridge 以促进捕获源与录制流程之间的数据传输
- 集成图像捕获协议支持,以增强整体屏幕录制能力
- 更新工程配置,包含 ext-image-capture 模块的新源文件和头文件
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这段代码进行审查:

  1. 代码结构和组织:
  • 代码采用了良好的模块化设计,将功能拆分为多个类:ExtCaptureBridge、ExtCaptureFrameBuffer、ExtCaptureIntegration等
  • 每个类都有明确的职责分工,符合单一职责原则
  • 使用了适当的设计模式,如Bridge模式连接不同组件
  1. 内存管理:
  • 使用了智能指针和RAII原则管理资源
  • 在析构函数中有适当的清理逻辑
  • 但存在一些潜在内存泄漏风险:
    // ExtCaptureFrame::createBuffer() 中
    d->buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, WL_SHM_FORMAT_XBGR8888);
    wl_shm_pool_destroy(pool);
    建议添加对buffer创建失败的检查
  1. 线程安全:
  • 使用QMutex保护共享资源
  • 但部分操作可能存在竞态条件:
    void ExtCaptureBridge::processFrames() {
        QMutexLocker locker(&m_processMutex);
        // ... 处理帧数据
    }
    建议对帧缓冲区的所有操作都加锁保护
  1. 错误处理:
  • 有基本的错误处理机制
  • 但可以改进:
    bool ExtCaptureRecorder::startRecording() {
        if (!isAvailable()) {
            qWarning() << "ext-image-copy-capture not available";
            emit error("Protocol not available");
            return false;
        }
    建议添加更详细的错误信息和恢复机制
  1. 性能优化:
  • 使用了帧缓冲区来减少内存分配
  • 但可能存在性能瓶颈:
    const int maxFramesPerRound = 5; // 限制每轮处理的帧数
    建议根据系统性能动态调整此值
  1. 安全性:
  • 对输入参数进行了基本验证
  • 但需要加强:
    void ExtCaptureFrameBuffer::appendBuffer() {
        if (width != m_frameWidth || height != m_frameHeight) {
            qWarning() << "Frame size mismatch";
            return;
        }
    建议添加更严格的边界检查
  1. 代码质量改进建议:

a) 添加更详细的文档注释:

/**
 * @brief 处理帧数据
 * @param maxFramesPerRound 每轮最大处理帧数
 * @return 实际处理的帧数
 */
int processFrames(int maxFramesPerRound = 5);

b) 使用枚举替代魔法数字:

enum class FrameFormat {
    XBGR8888 = 0,
    // 其他格式...
};

c) 添加配置参数的验证:

bool ExtCaptureRecorder::setFrameRate(int fps) {
    if (fps < 1 || fps > 60) {
        qWarning() << "Invalid frame rate:" << fps;
        return false;
    }
    m_frameRate = fps;
    return true;
}

d) 改进错误处理机制:

class ExtCaptureError : public std::exception {
public:
    explicit ExtCaptureError(const QString& message) : m_message(message) {}
    const char* what() const noexcept override {
        return m_message.toLocal8Bit().constData();
    }
private:
    QString m_message;
};

e) 添加性能监控:

class PerformanceMonitor {
public:
    void startFrame() { m_frameStart = std::chrono::high_resolution_clock::now(); }
    void endFrame() {
        auto duration = std::chrono::high_resolution_clock::now() - m_frameStart;
        m_frameTime = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
    }
    qint64 getFrameTime() const { return m_frameTime; }
private:
    std::chrono::time_point<std::chrono::high_resolution_clock> m_frameStart;
    qint64 m_frameTime = 0;
};
  1. 其他建议:

a) 添加单元测试
b) 使用更现代的C++特性(如std::optional替代空指针)
c) 考虑使用内存池来管理帧缓冲区
d) 添加日志级别控制
e) 实现配置系统来管理运行时参数

总体来说,代码结构清晰,功能完整,但在错误处理、性能优化和安全性方面还有改进空间。建议按照上述建议逐步改进代码质量。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit 3a366f1 into linuxdeepin:develop/snipe Nov 27, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants