Skip to content

WIP: Agora integrationn #413

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

Merged
merged 23 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1aa9f11
agora integration initial setaup
freddysundowner Oct 7, 2023
cf0fac6
Small fixes to make it running locally
Oct 7, 2023
6ca3d4d
v
freddysundowner Oct 9, 2023
82c198b
Merge branch 'agora-integrationn' of https://github.com/lowcoder-org/…
freddysundowner Oct 9, 2023
5017338
renaming refactoring of the components
freddysundowner Oct 9, 2023
d1050eb
more meeting components name refactoring fixes
freddysundowner Oct 9, 2023
db0753f
initial-participants listview with videos
freddysundowner Oct 10, 2023
26a980a
implemented user leaving the call and removing the user from the list…
freddysundowner Oct 12, 2023
36de39c
added sharing of screen
freddysundowner Oct 12, 2023
834c825
refactored control buttons
freddysundowner Oct 12, 2023
5472d95
fixed button data fields
freddysundowner Oct 13, 2023
b808ac9
added styling of the video component
freddysundowner Oct 13, 2023
e62d64c
added meeting name to the meeting controller data field
freddysundowner Oct 13, 2023
34a001e
fixed video component styling
freddysundowner Oct 13, 2023
c78a54c
added video stream controller events
freddysundowner Oct 14, 2023
84c9749
fixed styling for VideoStream Component
Oct 15, 2023
c278c6d
finished audio/mute event on video stream component
freddysundowner Oct 16, 2023
a02fd07
Merge branch 'agora-integrationn' of https://github.com/lowcoder-org/…
freddysundowner Oct 16, 2023
d131b71
Feat: video toggle event
freddysundowner Oct 16, 2023
2dd01e5
Feat: video click event
freddysundowner Oct 16, 2023
03b21f0
refactored/cleaned the code
freddysundowner Oct 17, 2023
7420095
Fix: audio echo on the local user
freddysundowner Oct 18, 2023
447dd8e
Merge branch 'dev' into agora-integrationn
FalkWolsky Oct 18, 2023
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
Prev Previous commit
Next Next commit
renaming refactoring of the components
  • Loading branch information
freddysundowner committed Oct 9, 2023
commit 5017338e4debf346eefc831b1de5310a56e7863c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import {
import { AutoHeightControl } from "comps/controls/autoHeightControl";
import { BoolControl } from "comps/controls/boolControl";
import {
JSONObjectArrayControl,
NumberControl,
StringControl,
} from "comps/controls/codeControl";
import {
arrayStringExposingStateControl,
booleanExposingStateControl,
jsonObjectExposingStateControl,
jsonValueExposingStateControl,
Expand All @@ -39,22 +36,19 @@ import {
Section,
sectionNames,
} from "lowcoder-design";
import { useCallback, useEffect, useState } from "react";
import { useCallback, useEffect } from "react";
import { ResizeHandle } from "react-resizable";
import styled from "styled-components";
import { useUserViewMode } from "util/hooks";
import { isNumeric } from "util/stringUtils";
import { NameConfig, withExposingConfigs } from "../generators/withExposing";
import { v4 as uuidv4 } from "uuid";
import { NameConfig, withExposingConfigs } from "../../generators/withExposing";

import AgoraRTC, {
ICameraVideoTrack,
IMicrophoneAudioTrack,
IAgoraRTCClient,
IAgoraRTCRemoteUser,
IRemoteVideoTrack,
} from "agora-rtc-sdk-ng";
import { JSONObject } from "@lowcoder-ee/index.sdk";

const EventOptions = [closeEvent] as const;

Expand Down Expand Up @@ -100,24 +94,6 @@ function transToPxSize(size: string | number) {
return isNumeric(size) ? size + "px" : (size as string);
}

const PlacementOptions = [
{
label: trans("drawer.top"),
value: "top",
},
{
label: trans("drawer.right"),
value: "right",
},
{
label: trans("drawer.bottom"),
value: "bottom",
},
{
label: trans("drawer.left"),
value: "left",
},
] as const;

let client: IAgoraRTCClient = AgoraRTC.createClient({
mode: "rtc",
Expand All @@ -144,8 +120,6 @@ const turnOnMicrophone = async (flag?: boolean) => {
};

const leaveChannel = async () => {
console.log("isJoined", isJoined);

if (!client) {
console.error("Agora client is not initialized");
return;
Expand All @@ -156,19 +130,19 @@ const leaveChannel = async () => {
return;
}
if (videoTrack) {
// await turnOnCamera(false);
await turnOnCamera(false);
await client.unpublish(videoTrack);
videoTrack.stop();
}

if (audioTrack) {
// await turnOnMicrophone(false);
await turnOnMicrophone(false);
await client.unpublish(audioTrack);
audioTrack.stop();
}

await client.leave();
isJoined = false; // Update the flag to indicate that you have left the channel
isJoined = false;
};
let isJoined = false;

Expand All @@ -181,8 +155,6 @@ const joinChannel = async (appId: any, channel: any, token: any) => {
await leaveChannel();
}

// client.on("user-published", onUserPublish);

await client.join(
appId,
channel,
Expand All @@ -194,19 +166,14 @@ const joinChannel = async (appId: any, channel: any, token: any) => {
};

const publishVideo = async (appId: any, channel: any, height: any) => {
console.log("publishVideo", appId, channel, isJoined);
await turnOnCamera(true);
console.log(appId, channel);

if (!isJoined) {
await joinChannel(appId, channel, null);
}

console.log("publish videoTrack ", videoTrack);

await client.publish(videoTrack);

// turnOnCamera(true);
const mediaStreamTrack = videoTrack.getMediaStreamTrack();

if (mediaStreamTrack) {
Expand Down Expand Up @@ -276,16 +243,12 @@ let MTComp = (function () {
[dispatch, isTopBom]
);

const usersWithVideoTracks: any = {};

useEffect(() => {
console.log("nnnn ", props.participants);
}, [props.participants.value]);

useEffect(() => {
if (client) {
console.log("REGISTERING LISTNERS");

client.on(
"user-published",
async (user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => {
Expand All @@ -297,26 +260,10 @@ let MTComp = (function () {
const remoteTrack = await client.subscribe(user, mediaType);
remoteTrack.play();
}
const remoteVideoTrack = user.videoTrack;
if (remoteVideoTrack) {
props.participants.onChange([JSON.stringify(user.uid)]);
console.log("usersWithVideoTracks", props.participants);
}
}
);

client.on("user-joined", (user: IAgoraRTCRemoteUser) => {
// usersWithVideoTracks[user.uid] = { user, videoTracks: [] };
// props.participants.onChange(usersWithVideoTracks);
// console.log(
// "userJoined",
// user.uid,
// props.participants.value,
// usersWithVideoTracks
// );
// const uid = user.uid;
// usersWithVideoTracks[uid] = { user, videoTracks: [] };
});
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {});
client.on("user-offline", (uid: any, reason: any) => {
console.log(`User ${uid} left the channel.`);
});
Expand All @@ -328,13 +275,8 @@ let MTComp = (function () {
});
client.on("stream-added", (user: IAgoraRTCRemoteUser) => {
console.log("stream-added");

if (user.hasVideo) {
console.log(`Stream from user ${user.videoTrack} added.`);
}
});
}
// turnOnCamera(true);
}, [client]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,19 @@ let VideoCompBuilder = (function (props) {
suffixIcon: IconControl,
style: ButtonStyleControl,
viewRef: RefControl<HTMLElement>,
appId: withDefault(StringControl, trans("prop.appid")), ///
videokey: withDefault(StringControl, trans("prop.videokey")),
participants: arrayStringExposingStateControl("participants"),
userId: stringExposingStateControl(
"text",
trans("meeting.userId", { name: "{{currentUser.name}}" })
),
};
// const { client, videoHeight, videoWidth, setHeight, setWidth } = useAgora();

return new UICompBuilder(childrenMap, (props) => {
console.log("userId", props.userId.value);
// "afd10eabe68a4de68a76461be92c693c"
const videoRef = useRef<HTMLVideoElement>(null);
const conRef = useRef<HTMLDivElement>(null);

useEffect(() => {
onResize();
}, []);

useEffect(() => {
if (props.participants.value.length > 0) {
console.log("bbb", props.participants.value);
}
}, [props.participants.value]);

const onResize = async () => {
const container = conRef.current;
Expand All @@ -205,7 +193,6 @@ let VideoCompBuilder = (function (props) {
<Container ref={conRef} $style={props.style}>
<video
ref={videoRef}
id={props.videokey}
style={{ width: 300, height: 300 }}
></video>
</Container>
Expand All @@ -216,46 +203,6 @@ let VideoCompBuilder = (function (props) {
})
.setPropertyViewFn((children) => (
<>
{/* <Section name={sectionNames.settings}>
{children.userId.propertyView({
label: trans("meeting.userId"),
})}
{children.autoHeight.getPropertyView()}
{children.videokey.propertyView({
label: trans("prop.videokey"),
})}
</Section> */}
{/* <Section name={sectionNames.layout}>
{/* {hiddenPropertyView(children)}
</Section> */}

{/* <Section name={sectionNames.interaction}>
{children.type.propertyView({
label: trans("prop.type"),
radioButton: true,
})} */}
{/* {isDefault(children.type.getView())
? [
children.onEvent.getPropertyView(),
disabledPropertyView(children),
loadingPropertyView(children),
]
: children.form.getPropertyView()} */}
{/* </Section> */}

{/* <Section name={sectionNames.layout}>
{children.prefixIcon.propertyView({
label: trans("button.prefixIcon"),
})}
{children.suffixIcon.propertyView({
label: trans("button.suffixIcon"),
})}
{hiddenPropertyView(children)}
</Section>

<Section name={sectionNames.style}>
{children.style.getPropertyView()}
</Section> */}
</>
))
.build();
Expand All @@ -267,57 +214,8 @@ VideoCompBuilder = class extends VideoCompBuilder {
}
};

VideoCompBuilder = withMethodExposing(VideoCompBuilder, [
{
method: {
name: "audioControl",
description: trans("meeting.actionBtnDesc"),
params: [],
},
execute: (comp, values) => {
// let value = !comp.children.audioControl.getView().value;
// turnOnMicrophone(value);
// comp.children.audioControl.change(value);
},
},
// {
// method: {
// name: "videoControl",
// description: trans("meeting.actionBtnDesc"),
// params: [],
// },
// execute: (comp, values) => {
// let value = !comp.children.videoControl.getView().value;
// turnOnCamera(value);
// comp.children.videoControl.change(value);
// },
// },
// {
// method: {
// name: "startMeeting",
// description: trans("meeting.actionBtnDesc"),
// params: [],
// },
// execute: (comp, values) => {
// publishVideo(comp.children.appId.getView(), "testsdaadasdsa");
// },
// },
// {
// method: {
// name: "endCall",
// description: trans("meeting.actionBtnDesc"),
// params: [],
// },
// execute: (comp, values) => {
// let value = !comp.children.endCall.getView().value;
// leaveChannel();
// comp.children.endCall.change(value);
// },
// },
]);

export const VideoMeetingComp = withExposingConfigs(VideoCompBuilder, [
// new NameConfig("appId", trans("button.textDesc")),
new NameConfig("loading", trans("button.loadingDesc")),
...CommonNameConfig,
]);
Loading