Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { IngressInput } from "livekit-server-sdk";
import app from "../../livekit.app.mjs";

export default {
key: "livekit-create-ingress-from-url",
name: "Create Ingress From URL",
description: "Create a new ingress from url in LiveKit. [See the documentation](https://docs.livekit.io/home/ingress/overview/#url-input-example).",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Ingress Name",
description: "The name of the ingress",
optional: true,
},
roomName: {
description: "The name of the room to send media to",
propDefinition: [
app,
"room",
],
},
participantIdentity: {
type: "string",
label: "Participant Identity",
description: "Unique identity of the participant",
},
participantName: {
type: "string",
label: "Participant Name",
description: "Participant display name",
optional: true,
},
participantMetadata: {
type: "string",
label: "Participant Metadata",
description: "Metadata to attach to the participant",
optional: true,
},
bypassTranscoding: {
type: "boolean",
label: "Bypass Transcoding",
description: "Whether to skip transcoding and forward the input media directly. Only supported by WHIP",
optional: true,
},
enableTranscoding: {
type: "boolean",
label: "Enable Transcoding",
description: "Whether to enable transcoding or forward the input media directly. Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.",
optional: true,
},
url: {
type: "string",
label: "URL",
description: "URL of the media to pull for ingresses of type URL",
},
},
async run({ $ }) {
const {
app,
name,
roomName,
participantIdentity,
participantName,
participantMetadata,
bypassTranscoding,
enableTranscoding,
url,
} = this;

const response = await app.createIngress({
inputType: IngressInput.URL_INPUT,
name,
roomName,
participantIdentity,
participantName,
participantMetadata,
bypassTranscoding,
enableTranscoding,
url,
});
$.export("$summary", `Successfully created ingress with ID \`${response.ingressId}\`.`);
return response;
},
};
85 changes: 85 additions & 0 deletions components/livekit/actions/create-room/create-room.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import app from "../../livekit.app.mjs";

export default {
key: "livekit-create-room",
name: "Create Room",
description: "Create a new room in LiveKit. [See the documentation](https://docs.livekit.io/home/server/managing-rooms/#create-a-room).",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Room Name",
description: "The name of the room",
},
emptyTimeout: {
type: "integer",
label: "Empty Timeout",
description: "Number of seconds to keep the room open before any participant joins",
optional: true,
},
departureTimeout: {
type: "integer",
label: "Departure Timeout",
description: "Number of seconds to keep the room open after the last participant leaves",
optional: true,
},
maxParticipants: {
type: "integer",
label: "Max Participants",
description: "Limit to the number of participants in a room at a time",
optional: true,
},
metadata: {
type: "string",
label: "Metadata",
description: "Initial room metadata",
optional: true,
},
minPlayoutDelay: {
type: "integer",
label: "Min Playout Delay",
description: "Minimum playout delay in milliseconds",
optional: true,
},
maxPlayoutDelay: {
type: "integer",
label: "Max Playout Delay",
description: "Maximum playout delay in milliseconds",
optional: true,
},
syncStreams: {
type: "boolean",
label: "Sync Streams",
description: "Improves A/V sync when min_playout_delay set to a value larger than 200ms. It will disables transceiver re-use -- this option is not recommended for rooms with frequent subscription changes",
optional: true,
},
},
async run({ $ }) {
const {
app,
name,
emptyTimeout,
departureTimeout,
maxParticipants,
metadata,
minPlayoutDelay,
maxPlayoutDelay,
syncStreams,
} = this;

const response = await app.createRoom({
name,
emptyTimeout,
departureTimeout,
maxParticipants,
metadata,
minPlayoutDelay,
maxPlayoutDelay,
syncStreams,
});
$.export("$summary", `Successfully created room with SID \`${response.sid}\`.`);
return response;
},
};
32 changes: 32 additions & 0 deletions components/livekit/actions/delete-room/delete-room.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import app from "../../livekit.app.mjs";

export default {
key: "livekit-delete-room",
name: "Delete Room",
description: "Delete a room in LiveKit. [See the documentation](https://docs.livekit.io/home/server/managing-rooms/#delete-a-room)",
version: "0.0.1",
type: "action",
props: {
app,
room: {
propDefinition: [
app,
"room",
],
},
},
async run({ $ }) {
const {
app,
room,
} = this;

await app.deleteRoom(room);

$.export("$summary", "Successfully deleted room.");

return {
success: true,
};
},
};
17 changes: 17 additions & 0 deletions components/livekit/actions/list-rooms/list-rooms.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import app from "../../livekit.app.mjs";

export default {
key: "livekit-list-rooms",
name: "List Rooms",
description: "List all rooms with LiveKit. [See the documentation](https://docs.livekit.io/home/server/managing-rooms/#list-rooms).",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
const rooms = await this.app.listRooms();
$.export("$summary", `Successfully listed \`${rooms.length}\` room(s).`);
return rooms;
},
};
7 changes: 7 additions & 0 deletions components/livekit/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const HTTPS_PREFIX = "https://";
const HTTP_PREFIX = "http://";

export default {
HTTPS_PREFIX,
HTTP_PREFIX,
};
61 changes: 56 additions & 5 deletions components/livekit/livekit.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
import {
RoomServiceClient,
IngressClient,
} from "livekit-server-sdk";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "livekit",
propDefinitions: {},
propDefinitions: {
room: {
type: "string",
label: "Room Name",
description: "The name of the room",
async options() {
const rooms = await this.listRooms();
return rooms.map(({ name }) => name);
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getHost() {
const { project_url: projectUrl } = this.$auth;

return projectUrl.startsWith(constants.HTTPS_PREFIX)
? projectUrl
: projectUrl.startsWith(constants.HTTP_PREFIX)
? projectUrl.replace(constants.HTTP_PREFIX, constants.HTTPS_PREFIX)
: `${constants.HTTPS_PREFIX}${projectUrl}`;
},
getKeys() {
const {
api_key: apiKey,
secret_key: secretKey,
} = this.$auth;
return [
apiKey,
secretKey,
];
},
getRoomClient() {
return new RoomServiceClient(this.getHost(), ...this.getKeys());
},
getIngressClient() {
return new IngressClient(this.getHost(), ...this.getKeys());
},
createRoom(args) {
return this.getRoomClient().createRoom(args);
},
listRooms(names) {
return this.getRoomClient().listRooms(names);
},
deleteRoom(room) {
return this.getRoomClient().deleteRoom(room);
},
createIngress({
inputType, ...args
} = {}) {
return this.getIngressClient().createIngress(inputType, args);
},
},
};
};
7 changes: 5 additions & 2 deletions components/livekit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/livekit",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream LiveKit Components",
"main": "livekit.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"livekit-server-sdk": "^2.8.1"
}
}
}
Loading
Loading