Skip to content

Commit

Permalink
fix: setupRemoteVideo not working (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 authored Mar 13, 2023
1 parent 4a9150c commit 1eb1877
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion example/src/renderer/components/BaseComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export abstract class BaseComponent<
{enableVideo ? (
<>
<AgoraText>Click view to mirror</AgoraText>
<RtcSurfaceView canvas={{ uid }} connection={{ channelId }} />
<RtcSurfaceView canvas={{ uid }} />
</>
) : undefined}
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ export default class LocalVideoTranscoder
uid,
sourceType,
}}
connection={{ channelId }}
/>
</Card>
</List.Item>
Expand All @@ -473,7 +472,6 @@ export default class LocalVideoTranscoder
uid: 0,
sourceType: this._getVideoSourceTypeCamera(value),
}}
connection={{ channelId }}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,12 @@ export default class JoinChannelVideo
}

protected renderVideo(uid: number): ReactNode {
const { channelId, enableVideo, remoteUsers } = this.state;
const { enableVideo, remoteUsers } = this.state;
return (
<List.Item>
<Card title={`${uid === 0 ? 'Local' : 'Remote'} Uid: ${uid}`}>
<AgoraText>Click view to mirror</AgoraText>
{enableVideo ? (
<RtcSurfaceView canvas={{ uid }} connection={{ channelId }} />
) : undefined}
{enableVideo ? <RtcSurfaceView canvas={{ uid }} /> : undefined}
<AgoraButton
title={`Append`}
onPress={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ export default function JoinChannelVideo() {
<List.Item>
<Card title={`${uid === 0 ? 'Local' : 'Remote'} Uid: ${uid}`}>
<AgoraText>Click view to mirror</AgoraText>
{enableVideo ? (
<RtcSurfaceView canvas={{ uid }} connection={{ channelId }} />
) : undefined}
{enableVideo ? <RtcSurfaceView canvas={{ uid }} /> : undefined}
<AgoraButton
title={`Append`}
onPress={() => {
Expand Down
4 changes: 3 additions & 1 deletion ts/Private/internal/RtcEngineExInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
uid: number,
options: ChannelMediaOptions
): string {
AgoraEnv.defaultChannelId = channelId;
return 'RtcEngine_joinChannel2';
}

Expand Down Expand Up @@ -439,6 +440,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
userAccount: string,
options?: ChannelMediaOptions
): string {
AgoraEnv.defaultChannelId = channelId;
return options === undefined
? 'RtcEngine_joinChannelWithUserAccount'
: 'RtcEngine_joinChannelWithUserAccount2';
Expand Down Expand Up @@ -579,7 +581,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
return (
AgoraEnv.AgoraRendererManager?.setupRemoteVideo({
videoSourceType: sourceType,
channelId: '',
channelId: AgoraEnv.defaultChannelId,
uid,
view,
rendererOptions: {
Expand Down
25 changes: 11 additions & 14 deletions ts/Renderer/RendererManager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { VideoSourceType } from '../Private/AgoraBase';
import { ErrorCodeType, VideoSourceType } from '../Private/AgoraBase';
import { RenderModeType } from '../Private/AgoraMediaBase';
import {
AgoraElectronBridge,
Channel,
ChannelIdMap,
FormatRendererVideoConfig,
RENDER_MODE,
RenderConfig,
RendererVideoConfig,
RenderMap,
RENDER_MODE,
ShareVideoFrame,
UidMap,
VideoFrameCacheConfig,
Expand Down Expand Up @@ -119,7 +119,7 @@ class RendererManager {

if (!rendererConfig.view) {
logError('setRenderOptionByView: view not exist');
return -1;
return -ErrorCodeType.ErrInvalidArgument;
}

const renderList = this.getRenderers({ uid, channelId, videoSourceType });
Expand All @@ -132,7 +132,7 @@ class RendererManager {
: logWarn(
`RenderStreamType: ${videoSourceType} channelId:${channelId} uid:${uid} have no render view, you need to call this api after setView`
);
return 0;
return ErrorCodeType.ErrOk;
}

public checkWebglEnv(): boolean {
Expand Down Expand Up @@ -171,7 +171,7 @@ class RendererManager {
channelId,
uid
);
return -1;
return -ErrorCodeType.ErrInvalidArgument;
}

// ensure a render to RenderMap
Expand All @@ -189,30 +189,27 @@ class RendererManager {

// enable render
this.enableRender(true);
return 0;
return ErrorCodeType.ErrOk;
}

public setupLocalVideo(rendererConfig: RendererVideoConfig): number {
const { videoSourceType } = rendererConfig;
if (videoSourceType === VideoSourceType.VideoSourceRemote) {
logError('setupLocalVideo videoSourceType error', videoSourceType);
return -1;
return -ErrorCodeType.ErrInvalidArgument;
}
this.setupVideo({ ...rendererConfig });
return 0;
return ErrorCodeType.ErrOk;
}

public setupRemoteVideo(rendererConfig: RendererVideoConfig): number {
const { videoSourceType } = rendererConfig;
if (videoSourceType !== VideoSourceType.VideoSourceRemote) {
logError('setupRemoteVideo videoSourceType error', videoSourceType);
return -1;
return -ErrorCodeType.ErrInvalidArgument;
}
this.setupVideo({
...rendererConfig,
videoSourceType: VideoSourceType.VideoSourceRemote,
});
return 0;
this.setupVideo({ ...rendererConfig });
return ErrorCodeType.ErrOk;
}

public destroyRendererByView(view: Element): void {
Expand Down
4 changes: 4 additions & 0 deletions ts/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface AgoraEnvType {
* @ignore
*/
AgoraRendererManager?: RendererManager;
/**
* @ignore
*/
defaultChannelId?: string;
}

/**
Expand Down

0 comments on commit 1eb1877

Please sign in to comment.