Skip to content

Commit

Permalink
adapt with the api (#195)
Browse files Browse the repository at this point in the history
* adapt with the api

* chore: update inlive-js-sdk to 0.16.0

* fix: room name changes to name

* chore: update inlive-js-sdk to 0.16.1

* refactor: use default codecs and bitrate configs from sdk

---------

Co-authored-by: Yohan Totting <[email protected]>
Co-authored-by: Faiq Naufal <[email protected]>
  • Loading branch information
3 people authored Mar 26, 2024
1 parent 8967503 commit 0a842b2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 42 deletions.
8 changes: 0 additions & 8 deletions app/(pages)/rooms/[roomID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ export default async function Page({ searchParams }: PageProps) {
});
});

const codecPreferences = hubRoomResponse?.data?.codecPreferences || [];
const bitrateConfig = {
highBitrate: hubRoomResponse?.data?.bitrates.videoHigh || 0,
midBitrate: hubRoomResponse?.data?.bitrates.videoMid || 0,
lowBitrate: hubRoomResponse?.data?.bitrates.videoLow || 0,
};
const roomType = roomData.meta ? roomData.meta.type : 'meeting';

return (
Expand All @@ -132,8 +126,6 @@ export default async function Page({ searchParams }: PageProps) {
roomType={roomType}
isModerator={isModerator}
debug={debug}
codecPreferences={codecPreferences}
bitrateConfig={bitrateConfig}
/>
</AppContainer>
);
Expand Down
10 changes: 5 additions & 5 deletions app/(server)/_features/room/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class RoomService {

for (const datachannel of this._datachannels) {
const channelResponse = await this._sdk.createDataChannel(
roomResp.data.roomId,
roomResp.data.id,
datachannel,
true
);
Expand All @@ -184,7 +184,7 @@ export class RoomService {

if (!this._roomRepo.isPersistent()) {
return {
id: roomResp.data.roomId,
id: roomResp.data.id,
createdBy: userID,
meta: { type },
name: '',
Expand All @@ -194,7 +194,7 @@ export class RoomService {

try {
const room = await this._roomRepo.addRoom({
id: roomResp.data.roomId,
id: roomResp.data.id,
createdBy: userID,
meta: { type },
});
Expand Down Expand Up @@ -235,8 +235,8 @@ export class RoomService {
const remoteRoom = await this._sdk.getRoom(roomId);
if (remoteRoom.ok) {
room = {
id: remoteRoom.data.roomId,
name: remoteRoom.data.roomName,
id: remoteRoom.data.id,
name: remoteRoom.data.name,
createdBy: 0,
} as Room;
}
Expand Down
16 changes: 1 addition & 15 deletions app/_features/room/components/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ type ViewProps = {
roomType: string;
isModerator: boolean;
debug: boolean;
codecPreferences: string[];
bitrateConfig: {
highBitrate: number;
midBitrate: number;
lowBitrate: number;
};
};

export default function View({
Expand All @@ -35,8 +29,6 @@ export default function View({
roomType,
isModerator,
debug,
codecPreferences,
bitrateConfig,
}: ViewProps) {
const [activeView, setActiveView] = useState<string>('lobby');

Expand All @@ -59,13 +51,7 @@ export default function View({

return (
<div className="bg-zinc-900 text-zinc-200">
<PeerProvider
roomID={roomID}
client={client}
debug={debug}
codecPreferences={codecPreferences}
bitrateConfig={bitrateConfig}
>
<PeerProvider roomID={roomID} client={client} debug={debug}>
<ClientProvider roomID={roomID} client={client} roomType={roomType}>
<DeviceProvider>
<ParticipantProvider>
Expand Down
10 changes: 1 addition & 9 deletions app/_features/room/contexts/peer-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,13 @@ type PeerProviderProps = {
roomID: string;
client: ClientType.ClientData;
debug: boolean;
codecPreferences: string[];
bitrateConfig: {
highBitrate: number;
midBitrate: number;
lowBitrate: number;
};
};

export function PeerProvider({
children,
roomID,
client,
debug = false,
codecPreferences = [],
bitrateConfig,
}: PeerProviderProps) {
const [peer, setPeer] = useState<Peer | null>(null);
const [connectionState, setConnectionState] =
Expand All @@ -63,7 +55,7 @@ export function PeerProvider({
setPeer(null);
}
};
}, [roomID, client, peer, codecPreferences, bitrateConfig]);
}, [roomID, client, peer]);

useEffect(() => {
const peerConnection = peer?.getPeerConnection();
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"migrate": "ts-node ./migrate.ts"
},
"dependencies": {
"@inlivedev/inlive-js-sdk": "^0.15.4",
"@inlivedev/inlive-js-sdk": "^0.16.1",
"@nextui-org/react": "^2.2.9",
"@sentry/nextjs": "^7.70.0",
"compressorjs": "^1.2.1",
Expand Down

0 comments on commit 0a842b2

Please sign in to comment.