Skip to content

Commit

Permalink
修复 videoframe 没有释放内存的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
bosscheng committed Aug 16, 2024
1 parent 9f06512 commit 7bde577
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 39 deletions.
1 change: 0 additions & 1 deletion demo/components/DemoPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ export default {
isResize: false,
useWCS: this.useWCS,
useMSE: this.useMSE,
wcsUseVideoRender: this.useWCS,
text: "",
// background: "bg.jpg",
loadingText: "疯狂加载中...",
Expand Down
4 changes: 1 addition & 3 deletions demo/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ wasmBinaryFile = 'https://cdn.com/decoder.wasm';
#### webcodecs 硬解码

默认是通过 `canvas` 进行渲染的

> jessibuca pro 支持 `video` 标签渲染
默认是通过 `canvas` 进行渲染的,也支持video渲染

> Pro 支持 `canvas webgl2` 进行渲染的
Expand Down
6 changes: 4 additions & 2 deletions demo/pro.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jessibuca pro 是在开源版本的基础上额外支持的深入业务解决方
| 语音通讯(设置采样位数32位或16位或8位) | 不支持 | 支持 |
| 语音通讯(设置声道单声道或双声道) | 不支持 | 支持 |
| 语音通讯(设置rtp包封装) | 不支持 | 支持 |
| 语音通讯(设置jtt包解封装 | 不支持 | 支持 |
| 语音通讯(设置jtt包解封装)[jtt介绍](https://jessibuca.com/document.html#%E5%85%B3%E4%BA%8E%E5%9B%BD%E6%A0%87-jtt-%E9%81%93%E8%B7%AF%E8%BF%90%E8%BE%93%E8%BD%A6%E8%BE%86%E5%8D%AB%E6%98%9F%E5%AE%9A%E4%BD%8D%E7%B3%BB%E7%BB%9F%E9%9F%B3%E8%A7%86%E9%A2%91%E9%80%9A%E8%AE%AF%E5%8D%8F%E8%AE%AE) | 不支持 | 支持 |
| GB28181 TF卡(录像流)流播放 [介绍](https://jessibuca.com/pro-playback.html) | 不支持 | 支持 |
| GB28181 TF卡(录像流)流播放,(2/4/8/16/32/64)倍率播放 | 不支持 | 支持 |
| GB28181 TF卡(录像流)流播放,关键帧解码播放 | 不支持 | 支持 |
Expand Down Expand Up @@ -636,10 +636,12 @@ Apple M1, M1 Pro, M1 Max, M1 Ultra 及以上
## 语音通讯

支持在web页面采集麦克风数据,支持编码格式pcm、pcma(g711a)、pcmu(g711u),支持封装成rtp包、jtt包
支持在web页面采集麦克风数据,支持编码格式pcm、pcma(g711a)、pcmu(g711u),支持封装成rtp协议包、jtt协议包

> 目前仅支持单向语音通讯,不支持双向语音通讯。(仅支持通过ws传输到服务器,不支持通过ws接收音频数据进行播放),根据国标情况,播放端是跟着音视频一起播放的,可以使用音视频播放器进行播放器音频和视频数据。
> 关于 jtt协议包的封装格式,可以参考:[jtt协议包](https://jessibuca.com/document.html#%E5%85%B3%E4%BA%8E%E5%9B%BD%E6%A0%87-jtt-%E9%81%93%E8%B7%AF%E8%BF%90%E8%BE%93%E8%BD%A6%E8%BE%86%E5%8D%AB%E6%98%9F%E5%AE%9A%E4%BD%8D%E7%B3%BB%E7%BB%9F%E9%9F%B3%E8%A7%86%E9%A2%91%E9%80%9A%E8%AE%AF%E5%8D%8F%E8%AE%AE)
## PRO AI

### 人脸识别
Expand Down
6 changes: 4 additions & 2 deletions demo/public/decoder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/public/decoder.js.map

Large diffs are not rendered by default.

Binary file modified demo/public/dist.zip
Binary file not shown.
64 changes: 55 additions & 9 deletions demo/public/jessibuca.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/public/jessibuca.js.map

Large diffs are not rendered by default.

Binary file modified demo/public/pro.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-audio.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-hard-not-wasm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-hard.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-mt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-simd-mt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-simd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/jessibuca-pro-demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/jessibuca-pro-multi-demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jessibuca.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jessibuca",
"version": "3.2.6",
"version": "3.2.8",
"scripts": {
"build": "npx cross-env NODE_ENV=production rollup -c",
"build:wasm": "python wasm/make.py --wasm && npm run build && npm run build:demo",
Expand Down
6 changes: 4 additions & 2 deletions src/audio/audioContextLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class AudioContextLoader extends Emitter {
async destroy() {
this.closeAudio();
this.resetInit();
if(this.audioContext){
if (this.audioContext) {
await this.audioContext.close();
this.audioContext = null;
}
Expand Down Expand Up @@ -318,5 +318,7 @@ export default class AudioContextLoader extends Emitter {
this.playing = true;
}


getLastVolume() {
return this._prevVolume;
}
}
2 changes: 1 addition & 1 deletion src/constant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const DEFAULT_PLAYER_OPTIONS = {
protocol: PLAYER_PLAY_PROTOCOL.fetch,
demuxType: DEMUX_TYPE.flv, // demux type
useWCS: false, //
wcsUseVideoRender: true,// 默认设置为true
wcsUseVideoRender: false,// 默认设置为true
useMSE: false, //
useOffscreen: false, //
autoWasm: true, // 自动降级到 wasm 模式
Expand Down
18 changes: 13 additions & 5 deletions src/player/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DEFAULT_PLAYER_OPTIONS, EVENTS, EVENTS_ERROR, JESSIBUCA_EVENTS,VERSION} from "../constant";
import {DEFAULT_PLAYER_OPTIONS, EVENTS, EVENTS_ERROR, JESSIBUCA_EVENTS, VERSION} from "../constant";
import Debug from "../utils/debug";
import Events from "../utils/events";
import property from './property';
Expand All @@ -7,7 +7,7 @@ import {
fpsStatus,
initPlayTimes,
isEmpty, isFalse,
isFullScreen, isMobile,isPad,
isFullScreen, isMobile, isPad,
isNotEmpty,
now, supportMediaStreamTrack,
supportMSE,
Expand Down Expand Up @@ -168,7 +168,7 @@ export default class Player extends Emitter {

events(this);
observer(this);
this.debug.log('Player', 'init and version is',VERSION);
this.debug.log('Player', 'init and version is', VERSION);

if (this._opt.useWCS) {
this.debug.log('Player', 'use WCS')
Expand Down Expand Up @@ -657,7 +657,15 @@ export default class Player extends Emitter {
* @param flag
*/
mute(flag) {
this.audio && this.audio.mute(flag)
if (this.audio) {
const prev = this.audio.getLastVolume();
this.audio.mute(flag)
if (flag) {
this._lastVolume = 0;
} else {
this._lastVolume = prev || 0.5;
}
}
}

/**
Expand Down Expand Up @@ -888,7 +896,7 @@ export default class Player extends Emitter {
return result;
}

getControlBarShow(){
getControlBarShow() {
let result = false;
if (this.control) {
result = this.control.getBarIsShow();
Expand Down
3 changes: 2 additions & 1 deletion src/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default class Video {
}

static getLoaderFactory(opt) {
if (opt.useMSE || (opt.useWCS && !opt.useOffscreen && opt.wcsUseVideoRender)) {
if (opt.useMSE ||
(opt.useWCS && !opt.useOffscreen && opt.wcsUseVideoRender)) {
return VideoLoader;
} else {
return CanvasVideoLoader;
Expand Down
2 changes: 2 additions & 0 deletions src/video/videoLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ export default class VideoLoader extends CommonLoader {
render(msg) {
if (this.vwriter) {
this.vwriter.write(msg.videoFrame);
// release memory
msg.videoFrame.close();
}
}

Expand Down

0 comments on commit 7bde577

Please sign in to comment.