npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hysc/boom-cpp-plugin

v1.0.14

Published

cppAudioPlugin-mac // mac 插件

Downloads

21

Readme

文件说明

cppAudioPlugin-mac // mac 插件

cppAudioPlugin-win32 // windows 插件

cppplugin // js bridge层

依赖说明

该项目依赖于外部库的 electronelectron-log。请在使用前安装对应的依赖。

该项目使用了.node文件,所以需要在electron主进程中使用对应的node-loader去处理该文件。请对照使用的webpack或者vite版本去安装对应的包。 webpack参考配置如下:

...
    module: {
    rules: [{
        test: /\.node$/,
        loader: 'node-loader',
        options: {
            name: '[name].[ext]'
        }
    }]
}
...

功能

该插件目前存在三个功能 高度和boom 的web-sdk 耦合

- 一个是将指定的窗口弹出到最上层,传入一个窗口id

- 一个是采集系统的声音

- 一个是检测窗口的变化,主要是用来处理ppt播放之后导致webrtc本身拿不到变化之后的视频流的问题

使用

打包文件

在打包的时候,需要将对应的插件文件打包到对应的目录下面,比如mac的插件文件,需要打包到mac的目录下面,windows的插件文件,需要打包到windows的目录下面。

packages.json 中的配置

...
"mac": {
    "extraFiles": [
        {
          "from": "node_modules/@hysc/boom-cpp-plugin/cppAudioPlugin-mac",
          "to": "Frameworks/node_modules/@hysc/boom-cpp-plugin/cppAudioPlugin-mac"
        },
    ],
    ...
},
...
// 目标产物是32位 cppAudioPlugin-win32 
// 目标产物是64位 cppAudioPlugin-win64
"win": {
    "extraFiles": [
    "node_modules/@hysc/boom-cpp-plugin/cppAudioPlugin-win32"
    ],
...
}

在electron主进程中使用

import CppPluginBridge from '@hysc/boom-cpp-plugin'

/**
*   
如果是集成了boom sdk, 在render-msg 事件里面去做处理
会有两个单独的code 去做这个处理
一个是 10110 代表采集系统或者对应窗口的声音,目前只对windows生效
一个是10113 代表去处理窗口变化检测
*/

/**
 * cpp插件不允许在没有销毁的情况下在同一个进程中初始化两次
 * 所以,如果视频会议应用销毁之后,一定要销毁当前的cpp插件
 * 目前在会议内只有在共享屏幕的时候,用到了该插件,所以在共享屏幕结束之后,需要销毁该插件
 * render-msg 事件中,需要处理两个code, 销毁的情况
 * 10110 
 * 10113 
 * 还有一个是需要在render-share-msg 关闭屏幕分享相关窗口的时候,需要销毁
 * 
 */

// 在需要的地方初始化
// main.js 中定义一个全局的变量去存储该插件的实例
let mCppPlugin

// 屏幕分享相关消息
...
ipcMain.on('render-share-msg', (e, args) => {
    logger.log('render-share-msg, type:', args.code)
    if (args.code === 0) {
        // 关闭屏幕分享相关的窗口
        if (mainWindow) {
            ...
            if (mCppPlugin) {
                mCppPlugin.destroy()
                mCppPlugin = null
            }
            ...
        }
    }
})
...

// 在 render-msg 事件中去做处理
...
// 采集对应窗口的音频流数据
else if (data.code === 10110) {
    // mainWindow 是视频会议窗口创建出来的实例
    if (mainWindow) {
        if (isWindows()) {
            const isStart = data.isStart
            logger.log('get audio from cpp plugin', isStart)
            if (isStart) {
                if (!mCppPlugin) {
                    mCppPlugin = new CppPluginBridge()
                    //绑定视频会议窗口,用来 通过 webContents 传递信息给sdk,进行通信
                    mCppPlugin.bindTargetWindow(mainWindow)
                }
                // 初始化插件,引用对应的cpp插件进行初始化,如果初始化失败,则代表cpp插件不可用
                // 如果是windows init 参数传入 'x64' 表示使用的是64位的插件版本, 默认是32位的
                mCppPlugin.init()
                // 设置音频采集回调,在这里面去接收采集到的音频数据,然后发给sdk
                mCppPlugin.setAudioPluginEventCallback()
                /**
                 * 开启声音采集
                 * 
                 *  sourceId 指定窗口ID,设置为0表示采集当前运行进程本身
                    第二个参数表示采集模式,true表示只采集指定窗口进程 false表示采集除了本地窗口进程 的声音
                    */
                
                mCppPlugin.startAudioCapture(0, false)
            } else {
                // 取消采集,销毁插件
                if (mCppPlugin) {
                    mCppPlugin.destroy()
                    mCppPlugin = null
                }
            }
        }
    }
}

// 窗口是否全屏的检测
else if (data.code === 10113) {
    let { sourceId, isStart, sourceName } = data
    if (isStart) {
        // 共享整个屏幕不需要处理
        const isFullScreen = sourceId.startsWith('screen')
        if (isFullScreen) {
            return
        }
        sourceId = sourceId.split(':')[1]
        logger.log('开始窗口是否全屏检测', sourceId, isStart, isWindows())
        if (sourceId) {
            logger.log('start detect window size change')
            if (!mCppPlugin) {
                mCppPlugin = new CppPluginBridge()
                mCppPlugin.bindTargetWindow(mainWindow)
            }
            mCppPlugin.init()
            mCppPlugin.setWinPluginEventCallBack()
            mCppPlugin.startWindowDetector(sourceId, sourceName)
            mCppPlugin.bringWindowToTop(sourceId)
        }
    } else {
        logger.log('stop detect window size change')
        if (mCppPlugin) {
            mCppPlugin.destroy()
            mCppPlugin = null
        }
    }
}
...

将arm架构和 x64架构 合成 一个文件

lipo -create cppAudioPlugin-mac/bjy_electron_plugin-x86.node cppAudioPlugin-mac/bjy_electron_plugin-arm.node -output cppAudioPlugin-mac/bjy_electron_plugin.node