Skip to content

Commit

Permalink
fix kbps error bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bosscheng committed Feb 15, 2025
1 parent 2e90de1 commit 7b2a45b
Show file tree
Hide file tree
Showing 28 changed files with 233 additions and 88 deletions.
19 changes: 18 additions & 1 deletion demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,17 @@ jessibuca.toggleControlBar()
const isShow = jessibuca.getControlBarShow()
```

### kbpsToSpeed(kbps)
- **用法**: 码率转换成网速 kbps -> KB/s
- **返回**`{number}`

```js
jessibuca.on("kBps", function (data) {
console.log('kBps:', data)
// 如果想要转换成网速
const speed = jessibuca.kbpsToSpeed(data);
})
```

### on(event, callback)

Expand Down Expand Up @@ -909,12 +920,18 @@ jessibuca.on("error", function (error) {

### kBps

当前网速, 单位KB 每秒1次,
当前码率, 每秒1次,

> 码率是和网速是区分的,网速是指当前网络的下载速度,码率是指当前视频的码率。

> 1 Bps = 8 bps

```js
jessibuca.on("kBps", function (data) {
console.log('kBps:', data)
// 如果想要转换成网速
const speed = jessibuca.kbpsToSpeed(data);
})
```

Expand Down
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.
98 changes: 72 additions & 26 deletions demo/public/jessibuca.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,32 @@ declare namespace Jessibuca {
* https://github.com/langhuihui/jessibuca/issues/152 解决方案
* 例如:WebGL图像预处理默认每次取4字节的数据,但是540x960分辨率下的U、V分量宽度是540/2=270不能被4整除,导致绿屏。
*/
openWebglAlignment?: boolean
openWebglAlignment?: boolean,

/**
* webcodecs硬解码是否通过video标签渲染
*/
wcsUseVideoRender?: boolean,

/**
* 底部控制台是否自动隐藏
*/
controlAutoHide?: boolean,

/**
* 录制的视频格式
*/
recordType?: 'webm' | 'mp4',

/**
* 是否使用web全屏(旋转90度)(只会在移动端生效)。
*/
useWebFullScreen?: boolean,

/**
* 是否自动使用系统全屏
*/
autoUseSystemFullScreen?: boolean,
}
}

Expand Down Expand Up @@ -222,8 +247,8 @@ declare class Jessibuca {
jessibuca.setTimeout(10)
jessibuca.on('timeout',function(){
//
});
//
});
*/
setTimeout(): void;

Expand All @@ -249,17 +274,17 @@ declare class Jessibuca {
* 可以在pause 之后,再调用 `play()`方法就继续播放之前的流。
@example
jessibuca.pause().then(()=>{
console.log('pause success')
console.log('pause success')
jessibuca.play().then(()=>{
jessibuca.play().then(()=>{
}).catch((e)=>{
}).catch((e)=>{
})
})
}).catch((e)=>{
console.log('pause error',e);
})
}).catch((e)=>{
console.log('pause error',e);
})
*/
pause(): Promise<void>;

Expand Down Expand Up @@ -289,14 +314,20 @@ declare class Jessibuca {
@example
jessibuca.play('url').then(()=>{
console.log('play success')
}).catch((e)=>{
console.log('play error',e)
})
//
jessibuca.play()
*/
play(url?: string): Promise<void>;
console.log('play success')
}).catch((e)=>{
console.log('play error',e)
})
// 添加请求头
jessibuca.play('url',{headers:{'Authorization':'test111'}}).then(()=>{
console.log('play success')
}).catch((e)=>{
console.log('play error',e)
})
*/
play(url?: string, options?: {
headers: Object
}): Promise<void>;

/**
* 重新调整视图大小
Expand Down Expand Up @@ -427,6 +458,21 @@ declare class Jessibuca {
*/
isRecording(): boolean;

/**
* 切换底部控制条 隐藏/显示
* @param isShow
*
* @example
* jessibuca.toggleControlBar(true) // 显示
* jessibuca.toggleControlBar(false) // 隐藏
* jessibuca.toggleControlBar() // 切换 隐藏/显示
*/
toggleControlBar(isShow:boolean): void;

/**
* 获取底部控制条是否显示
*/
getControlBarShow(): boolean;

/**
* 监听 jessibuca 初始化事件
Expand Down Expand Up @@ -477,14 +523,14 @@ declare class Jessibuca {
* 错误信息
* @example
* jessibuca.on("error",function(error){
if(error === Jessibuca.ERROR.fetchError){
//
}
else if(error === Jessibuca.ERROR.webcodecsH265NotSupport){
//
}
console.log('error:',error)
})
if(error === Jessibuca.ERROR.fetchError){
//
}
else if(error === Jessibuca.ERROR.webcodecsH265NotSupport){
//
}
console.log('error:',error)
})
*/
on(event: 'error', callback: (err: Jessibuca.ERROR) => void): void;

Expand Down
41 changes: 29 additions & 12 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-f-simd-mt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/public/pro/js/decoder-pro-f-simd.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-old.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/decoder.js

Large diffs are not rendered by default.

Loading

0 comments on commit 7b2a45b

Please sign in to comment.