Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: WebCodecs videoDecoder #1186

Merged
merged 101 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
76b6703
chore: for electron22
guoxianzhe Apr 1, 2024
d7bd5a9
chore: optimize
guoxianzhe Apr 1, 2024
4f5282a
chore: optimize
guoxianzhe Apr 1, 2024
6f5a52f
chore: optimize
guoxianzhe Apr 1, 2024
b1dadac
chore: optimize
guoxianzhe Apr 2, 2024
9576797
chore: optimize
guoxianzhe Apr 2, 2024
32f56ec
chore: optimize
guoxianzhe Apr 2, 2024
efdd91c
chore: optimize
guoxianzhe Apr 2, 2024
9e37e84
chore: optimize
guoxianzhe Apr 3, 2024
f09605d
chore: optimize
guoxianzhe Apr 3, 2024
0118095
chore: optimize
guoxianzhe Apr 3, 2024
fd8bb96
chore: optimize
guoxianzhe Apr 3, 2024
35babb2
chore: optimize
guoxianzhe Apr 3, 2024
d0cc76f
chore: optimize
guoxianzhe Apr 3, 2024
89bc83a
chore: optimize
guoxianzhe Apr 7, 2024
73b6327
chore: optimize
guoxianzhe Apr 7, 2024
1418f3d
chore: optimize
guoxianzhe Apr 7, 2024
6516a7f
chore: optimize
guoxianzhe Apr 7, 2024
5d17e96
chore: optimize
guoxianzhe Apr 8, 2024
fc055fb
chore: optimize
guoxianzhe Apr 8, 2024
179917c
chore: optimize
guoxianzhe Apr 9, 2024
bbbac3a
chore: optimize
guoxianzhe Apr 10, 2024
257c983
chore: optimize
guoxianzhe Apr 10, 2024
28b88bc
chore: optimize
guoxianzhe Apr 10, 2024
c37b338
chore: optimize
guoxianzhe Apr 11, 2024
781faea
chore: optimize
guoxianzhe Apr 11, 2024
ca338ff
chore: optimize
guoxianzhe Apr 11, 2024
01a4137
chore: optimize
guoxianzhe Apr 12, 2024
4838842
chore: optimize
guoxianzhe Apr 12, 2024
594dfb1
chore: optimize
guoxianzhe Apr 12, 2024
2498fd2
chore: optimize
guoxianzhe Apr 12, 2024
954236b
chore: optimize
guoxianzhe Apr 12, 2024
0fd0f81
chore: optimize
guoxianzhe Apr 12, 2024
47c1702
chore: optimize
guoxianzhe Apr 12, 2024
a3ad786
chore: optimize
guoxianzhe Apr 15, 2024
e74389a
chore: optimize
guoxianzhe Apr 15, 2024
fb0d41a
chore: optimize
guoxianzhe Apr 15, 2024
b3ef481
chore: optimize
guoxianzhe Apr 15, 2024
49e6bee
chore: optimize
guoxianzhe Apr 15, 2024
fd065cb
chore: optimize
guoxianzhe Apr 15, 2024
8f70fd0
chore: optimize
guoxianzhe Apr 15, 2024
a0e3f97
chore: optimize
guoxianzhe Apr 15, 2024
a0970f4
chore: optimize
guoxianzhe Apr 15, 2024
c44361b
chore: optimize
guoxianzhe Apr 15, 2024
f32881c
chore: optimize
guoxianzhe Apr 16, 2024
bab682d
chore: optimize
guoxianzhe Apr 17, 2024
a6ebf69
chore: optimize
guoxianzhe Apr 17, 2024
f82b832
chore: optimize
guoxianzhe Apr 17, 2024
7229d08
chore: optimize
guoxianzhe Apr 17, 2024
1149331
chore: optimize
guoxianzhe Apr 17, 2024
b1525a2
chore: optimize
guoxianzhe Apr 17, 2024
39f3c93
chore: optimize
guoxianzhe Apr 17, 2024
a623a47
chore: optimize
guoxianzhe Apr 17, 2024
c0c1d81
chore: optimize
guoxianzhe Apr 18, 2024
5dd41f7
chore: optimize
guoxianzhe Apr 18, 2024
3f81441
chore: optimize
guoxianzhe Apr 18, 2024
b80f380
chore: optimize
guoxianzhe Apr 18, 2024
9039ef0
chore: optimize
guoxianzhe Apr 18, 2024
1890736
chore: optimize
guoxianzhe Apr 18, 2024
cbe5ffc
chore: optimize
guoxianzhe Apr 18, 2024
d73a6f9
chore: optimize
guoxianzhe Apr 18, 2024
5a3db35
chore: optimize
guoxianzhe Apr 18, 2024
5cb72f6
chore: optimize
guoxianzhe Apr 19, 2024
43ef0b5
chore: optimize
guoxianzhe Apr 22, 2024
f5ce76e
chore: optimize
guoxianzhe Apr 23, 2024
2a76c5a
chore: optimize
guoxianzhe Apr 24, 2024
eb04ca4
chore: optimize
guoxianzhe Apr 25, 2024
6141483
chore: optimize
guoxianzhe Apr 28, 2024
0b2109b
chore: optimize
guoxianzhe Apr 28, 2024
ee1c5e8
chore: optimize
guoxianzhe Apr 28, 2024
8670244
chore: optimize
guoxianzhe May 8, 2024
afce122
chore: optimize
guoxianzhe May 8, 2024
95047cb
chore: reconfig when width and height changed
guoxianzhe May 9, 2024
617d160
chore: optimize
guoxianzhe May 9, 2024
4257aa6
chore: optimize
guoxianzhe May 9, 2024
ebc4a07
chore: optimize
guoxianzhe May 9, 2024
53bd304
chore: optimize
guoxianzhe May 9, 2024
1af394c
chore: optimize
guoxianzhe May 9, 2024
83c89fa
chore: optimize
guoxianzhe May 9, 2024
732d62b
chore: optimize
guoxianzhe May 9, 2024
20e28a0
chore: optimize
guoxianzhe May 9, 2024
f135da7
chore: optimize
guoxianzhe May 9, 2024
c8c88f3
chore: optimize
guoxianzhe May 9, 2024
16520be
chore: optimize
guoxianzhe May 9, 2024
29aa87d
chore: optimize
guoxianzhe May 11, 2024
e800bea
chore: optimize
guoxianzhe May 11, 2024
3240684
Revert "chore: optimize"
guoxianzhe May 11, 2024
c844528
Revert "chore: optimize"
guoxianzhe May 11, 2024
06525d7
chore: optimize
guoxianzhe May 11, 2024
69a8f9b
chore: optimize
guoxianzhe May 11, 2024
74fd6c9
chore: optimize
guoxianzhe May 11, 2024
c095a46
chore: optimize
guoxianzhe May 11, 2024
15c3f71
chore: optimize
guoxianzhe May 11, 2024
0e0d394
chore: optimize
guoxianzhe May 13, 2024
5c5b50f
chore: optimize
guoxianzhe May 14, 2024
d651e75
chore: optimize
guoxianzhe May 20, 2024
29aca56
chore: release 4.2.2-build.143-rc.1
sda-rob May 20, 2024
21ab5e2
chore(example): update example to install [email protected]
sda-rob May 20, 2024
819bd26
chore: optimize
guoxianzhe May 21, 2024
f685400
chore: release 4.2.2-build.143-rc.2
sda-rob May 22, 2024
ad50e22
chore(example): update example to install [email protected]
sda-rob May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/
js/
types/
ts/Private/ti/
native/
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@
"document": false,
"HTMLElement": false,
"HTMLDivElement": false,
"RenderingContext": false,
"WebGLRenderingContext": false,
"WebGL2RenderingContext": false,
"WebGLTexture": false,
"WebGLBuffer": false,
"WebGLProgram": false,
"VideoDecoder": false,
"VideoFrame": false,
"EncodedVideoChunk":false,
"HTMLCanvasElement": false,
"ResizeObserver": false,
"name": false,
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ jobs:
yarn link agora-electron-sdk
yarn dist:mac
yarn unlink agora-electron-sdk
env:
env:
USE_HARD_LINKS: false
working-directory: example

- uses: actions/upload-artifact@v3
with:
name: AgoraRtcNgExample-mac
path: |
example/dist/Agora-Electron-API-Example-*-mac.zip
if-no-files-found: error

notification:
runs-on: ubuntu-latest
needs: [ build-windows, build-mac ]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,4 @@ docs/
types/
iris/
appId.*
native/
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@


## [4.2.2-build.143-rc.2](https://github.com/AgoraIO-Extensions/Electron-SDK/compare/v4.2.2-build.143-rc.1...v4.2.2-build.143-rc.2) (2024-05-22)

## [4.2.2-build.143-rc.1](https://github.com/AgoraIO-Extensions/Electron-SDK/compare/v4.2.2-build.141-rc.2...v4.2.2-build.143-rc.1) (2024-05-20)


### Features

* support native 4.2.2.142 ([#1178](https://github.com/AgoraIO-Extensions/Electron-SDK/issues/1178)) ([473815e](https://github.com/AgoraIO-Extensions/Electron-SDK/commit/473815eb05fc08845e394b4daf9a59c0d5096d6d))


### Reverts

* Revert "chore: optimize" ([c844528](https://github.com/AgoraIO-Extensions/Electron-SDK/commit/c844528de5cb301091d9bd39c270db86bd21fa57))
* Revert "chore: optimize" ([3240684](https://github.com/AgoraIO-Extensions/Electron-SDK/commit/3240684eb9e47e464cd321b657797139918653e2))

## [4.2.2-build.142-rc.1](https://github.com/AgoraIO-Extensions/Electron-SDK/compare/v4.2.2-build.141-rc.2...v4.2.2-build.142-rc.1) (2024-03-29)

## [4.2.2-build.141-rc.2](https://github.com/AgoraIO-Extensions/Electron-SDK/compare/v4.2.2-build.141-rc.1...v4.2.2-build.141-rc.2) (2023-12-15)
Expand Down
7 changes: 4 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"build": {
"appId": "agora.io.ElectronApiExample",
"includePdb": true,
"asar": true,
"asarUnpack": [
"node_modules/agora-electron-sdk"
Expand Down Expand Up @@ -70,10 +71,10 @@
]
},
"dependencies": {
"agora-electron-sdk": "4.2.2-build.142-rc.1",
"agora-electron-sdk": "4.2.2-build.143-rc.2",
"antd": "^4.20.3",
"download": "^8.0.0",
"ffi-napi": "^4.0.3",
"koffi": "^2.8.0",
"react": "^18.1.0",
"react-color": "^2.19.3",
"react-dom": "^18.1.0",
Expand All @@ -94,7 +95,7 @@
"@types/react-dom": "^18.0.3",
"@types/react-router-dom": "^5.1.6",
"@types/ref-napi": "^3.0.7",
"electron": "18.2.3",
"electron": "22.0.0",
"electron-builder": "^23.1.0",
"electron-webpack": "^2.8.2",
"fork-ts-checker-webpack-plugin": "^4.1.2",
Expand Down
1 change: 1 addition & 0 deletions example/src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path';
import { format as formatUrl } from 'url';

import 'agora-electron-sdk/js/Private/ipc/main.js';
import { BrowserWindow, app, ipcMain, systemPreferences } from 'electron';

const isDevelopment = process.env.NODE_ENV !== 'production';
Expand Down
1 change: 0 additions & 1 deletion example/src/renderer/components/BaseComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export abstract class BaseComponent<
<>
{!!startPreview || joinChannelSuccess
? this.renderUser({
uid: 0,
sourceType: VideoSourceType.VideoSourceCamera,
})
: undefined}
Expand Down
87 changes: 52 additions & 35 deletions example/src/renderer/components/RtcSurfaceView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
AgoraEnv,
IMediaPlayer,
IRtcEngineEx,
RtcConnection,
VideoCanvas,
VideoMirrorModeType,
VideoSourceType,
VideoViewSetupMode,
createAgoraRtcEngine,
} from 'agora-electron-sdk';
import React, { Component } from 'react';
Expand All @@ -23,6 +25,12 @@ interface State {
uniqueId: number;
}

type SetupVideoFunc =
| typeof IRtcEngineEx.prototype.setupRemoteVideoEx
| typeof IRtcEngineEx.prototype.setupRemoteVideo
| typeof IRtcEngineEx.prototype.setupLocalVideo
| typeof IMediaPlayer.prototype.setView;

export class RtcSurfaceView extends Component<Props, State> {
constructor(props: Props) {
super(props);
Expand All @@ -43,7 +51,16 @@ export class RtcSurfaceView extends Component<Props, State> {
};

componentDidMount() {
this.updateRender();
const { canvas, connection } = this.props;
this.getSetupVideoFunc().call(
this,
{
...canvas,
setupMode: VideoViewSetupMode.VideoViewSetupAdd,
view: this.getHTMLElement(),
},
connection!
);
}

shouldComponentUpdate(
Expand All @@ -59,59 +76,59 @@ export class RtcSurfaceView extends Component<Props, State> {
}

componentDidUpdate() {
this.updateRender();
this.updateRenderer();
}

componentWillUnmount() {
const dom = this.getHTMLElement();
const { canvas, connection } = this.props;

createAgoraRtcEngine().destroyRendererByView(dom);
this.getSetupVideoFunc().call(
this,
{
...canvas,
setupMode: VideoViewSetupMode.VideoViewSetupRemove,
view: this.getHTMLElement(),
},
connection!
);
}

updateRender = () => {
getSetupVideoFunc = (): SetupVideoFunc => {
const { canvas, connection } = this.props;
const { isMirror } = this.state;
const dom = this.getHTMLElement();
const engine = createAgoraRtcEngine();

let funcName:
| typeof IRtcEngineEx.prototype.setupRemoteVideoEx
| typeof IRtcEngineEx.prototype.setupRemoteVideo
| typeof IRtcEngineEx.prototype.setupLocalVideo
| typeof IMediaPlayer.prototype.setView;
let func: SetupVideoFunc;

if (canvas.sourceType === undefined) {
if (canvas.uid) {
funcName = engine.setupRemoteVideo;
func = engine.setupRemoteVideo;
} else {
funcName = engine.setupLocalVideo;
func = engine.setupLocalVideo;
}
} else if (canvas.sourceType === VideoSourceType.VideoSourceRemote) {
funcName = engine.setupRemoteVideo;
func = engine.setupRemoteVideo;
} else {
funcName = engine.setupLocalVideo;
func = engine.setupLocalVideo;
}

if (funcName === engine.setupRemoteVideo && connection) {
funcName = engine.setupRemoteVideoEx;
if (func === engine.setupRemoteVideo && connection) {
func = engine.setupRemoteVideoEx;
}

try {
engine.destroyRendererByView(dom);
} catch (e) {
console.warn(e);
}
funcName.call(
this,
{
...canvas,
mirrorMode: isMirror
? VideoMirrorModeType.VideoMirrorModeEnabled
: VideoMirrorModeType.VideoMirrorModeDisabled,
view: dom,
},
connection!
);
return func;
};

updateRenderer = () => {
const { canvas, connection } = this.props;
const { isMirror } = this.state;
AgoraEnv.AgoraRendererManager?.setRendererContext({
...canvas,
...connection,
mirrorMode: isMirror
? VideoMirrorModeType.VideoMirrorModeEnabled
: VideoMirrorModeType.VideoMirrorModeDisabled,
view: this.getHTMLElement(),
});
};

render() {
Expand All @@ -124,7 +141,7 @@ export class RtcSurfaceView extends Component<Props, State> {
onClick={() => {
this.setState((preState) => {
return { isMirror: !preState.isMirror };
}, this.updateRender);
}, this.updateRenderer);
}}
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@
{startLocalVideoTranscoder
? this.renderUser({
renderMode: RenderModeType.RenderModeFit,
uid: 0,
sourceType: VideoSourceType.VideoSourceTranscoded,
})
: undefined}
Expand Down Expand Up @@ -493,7 +492,7 @@
};
})}
value={videoDeviceId}
onValueChange={(value, index) => {

Check warning on line 495 in example/src/renderer/examples/advanced/LocalVideoTranscoder/LocalVideoTranscoder.tsx

View workflow job for this annotation

GitHub Actions / lint

'index' is defined but never used. Allowed unused args must match /^_/u
if (videoDeviceId?.indexOf(value) === -1) {
this.setState(
(preState) => {
Expand Down Expand Up @@ -576,6 +575,7 @@
canvas={{
mediaPlayerId: this.player?.getMediaPlayerId(),
sourceType: VideoSourceType.VideoSourceMediaPlayer,
renderMode: RenderModeType.RenderModeFit,
}}
/>
) : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
MediaPlayerError,
MediaPlayerEvent,
MediaPlayerState,
RenderModeType,
VideoSourceType,
createAgoraRtcEngine,
} from 'agora-electron-sdk';
Expand Down Expand Up @@ -353,6 +354,7 @@ export default class MediaPlayer
canvas={{
mediaPlayerId: this.player?.getMediaPlayerId(),
sourceType: VideoSourceType.VideoSourceMediaPlayer,
renderMode: RenderModeType.RenderModeFit,
}}
/>
) : undefined}
Expand Down
Loading
Loading