Skip to content

Commit

Permalink
优化日志输出
Browse files Browse the repository at this point in the history
  • Loading branch information
bosscheng committed Jul 23, 2024
1 parent 67ce8f2 commit ef45092
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 47 deletions.
22 changes: 11 additions & 11 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.
20 changes: 11 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.

41 changes: 32 additions & 9 deletions demo/public/pro/multi-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@
function create() {
jessibucaMulti = new JessibucaProMulti({
container: $container,
split: 2,
split: 2,// default
isResize: false,
decoder: './js/decoder-pro.js',
debug: true,
useMSE: true,
decoderErrorAutoWasm:false,
decoderErrorAutoWasm: false,
useSIMD: true,
debugLevel: "debug",
hasAudio: false,
loadingTimeout:3,
loadingTimeoutReplayTimes:10,
loadingTimeout: 3,
loadingTimeoutReplayTimes: 10,
showBandwidth: showOperateBtns, // 显示网速
showPerformance: showOperateBtns, // 显示性能
operateBtns: {
Expand All @@ -151,8 +151,8 @@
quality: showOperateBtns,
performance: showOperateBtns,
},
draggable:$supportDraggable.checked === true,
supportDblclickContainerFullscreen:$supportContainerFullscreen.checked === true,
draggable: $supportDraggable.checked === true,
supportDblclickContainerFullscreen: $supportContainerFullscreen.checked === true,
// supportMousemoveEvent: true,
})

Expand Down Expand Up @@ -188,12 +188,33 @@
console.log(`stats-${index}`, stats);
})

jessibucaMulti.on(JessibucaProMulti.EVENTS.error, (selectedIndex,errorType,message) => {
console.error('error', selectedIndex,errorType,message);
jessibucaMulti.on(JessibucaProMulti.EVENTS.error, (selectedIndex, errorType, message) => {
console.error('error', selectedIndex, errorType, message);
})

jessibucaMulti.on(JessibucaProMulti.MULTI_EVENTS.drop, (selectedIndex, event, options) => {
console.log('drop', selectedIndex, options);
updateExtendDom();
})
}

create();
updateExtendDom();

function updateExtendDom() {
const playerUUidList = jessibucaMulti.getWindowUuidList();
playerUUidList.forEach((uuid, index) => {
const playerItem = jessibucaMulti.getWindowItem(uuid);
const player = playerItem.player;
if (player) {
player.setExtendHtml(`<div style="color: red;position: absolute;left: 20px;top: 20px;font-size: 16px">
<span>排序Index:${playerItem.order || playerItem.index}</span>
<br>
<span>Uuid:${playerItem.uuid}</span>
</div>`)
}
})
}

function play() {
var href = $playHref.value;
Expand Down Expand Up @@ -257,12 +278,14 @@
if (jessibucaMulti) {
split = Number(split);
jessibucaMulti.arrangeWindow(split);
updateExtendDom();
}
}

function updateSplitSpecial(type) {
if (jessibucaMulti) {
jessibucaMulti.arrangeWindow(type);
updateExtendDom();
}
}

Expand All @@ -283,7 +306,7 @@
function handleInitPlayerBySelectWindow() {
if (jessibucaMulti) {
jessibucaMulti.initSingle().then(() => {

updateExtendDom();
}).catch((e) => {

});
Expand Down
2 changes: 1 addition & 1 deletion dist/decoder.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": "1.0.0",
"version": "3.2.6",
"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
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const baseConfig = {
replace({
exclude: 'node_modules/**',
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
__VERSION__: JSON.stringify(require('./package.json').version),
}),
isProd && terser({
mangle: true,
Expand Down
2 changes: 2 additions & 0 deletions src/constant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const MEDIA_SOURCE_UPDATE_END_TIMEOUT = 10 * 1000

export const CONTAINER_DATA_SET_KEY = 'jessibuca'

export const VERSION = '__VERSION__'


// default player options
export const DEFAULT_PLAYER_OPTIONS = {
Expand Down
4 changes: 3 additions & 1 deletion src/jessibuca.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
EVENTS_ERROR,
JESSIBUCA_EVENTS,
PLAYER_PLAY_PROTOCOL,
SCALE_MODE_TYPE
SCALE_MODE_TYPE,
VERSION
} from "./constant";
import {
getElementDataset,
Expand Down Expand Up @@ -106,6 +107,7 @@ class Jessibuca extends Emitter {
this.events = new Events(this);
this.debug = new Debug(this);
this._initPlayer($container, _opt);
console.log(`Jessibuca version: ${VERSION}`);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion 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} 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 Down Expand Up @@ -168,6 +168,7 @@ export default class Player extends Emitter {

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

if (this._opt.useWCS) {
this.debug.log('Player', 'use WCS')
Expand Down
22 changes: 11 additions & 11 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Module.postRun = function () {
decoder: new VideoDecoder({
output: function (videoFrame) {
if (!wcsVideoDecoder.isEmitInfo) {
decoder.opt.debug && console.log('Jessibuca: [worker] Webcodecs Video Decoder initSize');
decoder.opt.debug && console.log('Jb: [worker] Webcodecs Video Decoder initSize');
postMessage({
cmd: WORKER_CMD_TYPE.initVideo,
w: videoFrame.codedWidth,
Expand Down Expand Up @@ -166,7 +166,7 @@ Module.postRun = function () {
const uData = Module.HEAPU8.subarray(u, u + qsize);
const vData = Module.HEAPU8.subarray(v, v + (qsize));
// if (isGreenYUV(Uint8Array.from(yData))) {
// decoder.opt.debug && console.log('Jessibuca: [worker]: draw offscreenCanvas is green yuv');
// decoder.opt.debug && console.log('Jb: [worker]: draw offscreenCanvas is green yuv');
// return
// }

Expand All @@ -185,7 +185,7 @@ Module.postRun = function () {
const uData = Uint8Array.from(Module.HEAPU8.subarray(u, u + qsize));
const vData = Uint8Array.from(Module.HEAPU8.subarray(v, v + (qsize)));
// if (isGreenYUV(yData)) {
// decoder.opt.debug && console.log('Jessibuca: [worker]: draw is green yuv');
// decoder.opt.debug && console.log('Jb: [worker]: draw is green yuv');
// return
// }
const outputArray = [yData, uData, vData];
Expand Down Expand Up @@ -227,13 +227,13 @@ Module.postRun = function () {
},

init: function () {
decoder.opt.debug && console.log('Jessibuca: [worker] init');
decoder.opt.debug && console.log('Jb: [worker] init');
const _doDecode = (data) => {
// decoder.opt.debug && console.log('Jessibuca: [worker]: _doDecode');
// decoder.opt.debug && console.log('Jb: [worker]: _doDecode');
if (decoder.opt.useWCS && decoder.useOffscreen() && data.type === MEDIA_TYPE.video && wcsVideoDecoder.decode) {
wcsVideoDecoder.decode(data.payload, data.ts);
} else {
// decoder.opt.debug && console.log('Jessibuca: [worker]: _doDecode wasm');
// decoder.opt.debug && console.log('Jb: [worker]: _doDecode wasm');
data.decoder.decode(data.payload, data.ts);
}
};
Expand Down Expand Up @@ -261,22 +261,22 @@ Module.postRun = function () {
} else {
var data = buffer[0];
if (this.getDelay(data.ts) === -1) {
// decoder.opt.debug && console.log('Jessibuca: [worker]: common dumex delay is -1');
// decoder.opt.debug && console.log('Jb: [worker]: common dumex delay is -1');
buffer.shift();
_doDecode(data);
} else if (this.delay > decoder.opt.videoBuffer + decoder.opt.videoBufferDelay) {
// decoder.opt.debug && console.log('Jessibuca: [worker]:', `delay is ${this.delay}, set dropping is true`);
// decoder.opt.debug && console.log('Jb: [worker]:', `delay is ${this.delay}, set dropping is true`);
this.resetDelay();
this.dropping = true;
} else {
while (buffer.length) {
data = buffer[0];
if (this.getDelay(data.ts) > decoder.opt.videoBuffer) {
// decoder.opt.debug && console.log('Jessibuca: [worker]:', `delay is ${this.delay}, decode`);
// decoder.opt.debug && console.log('Jb: [worker]:', `delay is ${this.delay}, decode`);
buffer.shift();
_doDecode(data);
} else {
// decoder.opt.debug && console.log('Jessibuca: [worker]:', `delay is ${this.delay},opt.videoBuffer is ${decoder.opt.videoBuffer}`);
// decoder.opt.debug && console.log('Jb: [worker]:', `delay is ${this.delay},opt.videoBuffer is ${decoder.opt.videoBuffer}`);
break;
}
}
Expand All @@ -289,7 +289,7 @@ Module.postRun = function () {
this.stopId = setInterval(loop, 10);
},
close: function () {
decoder.opt.debug && console.log('Jessibuca: [worker]: close');
decoder.opt.debug && console.log('Jb: [worker]: close');
clearInterval(this.stopId);
this.stopId = null;
audioDecoder.clear && audioDecoder.clear();
Expand Down

0 comments on commit ef45092

Please sign in to comment.