-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add keepalive server route to Webrtc Nuxt demo app
- Loading branch information
Showing
10 changed files
with
62 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
apps/ingest-demo-nuxt/server/api/generate.ts → ...est-demo-nuxt/server/api/generate.post.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
import { defineEventHandler } from "h3" | ||
import { ApiKey, GcoreApi } from '@gcorevideo/rtckit-node' | ||
|
||
import gcore from '../utils/gcore-api' | ||
|
||
// Generate a live stream | ||
export default defineEventHandler( | ||
async (event) => { | ||
const config = useRuntimeConfig() | ||
if (event.method === 'POST') { | ||
const { name } = await readBody(event) | ||
const api = new GcoreApi( | ||
new ApiKey(config.apiKey), | ||
) | ||
api.webrtc.setCustomOptions({ | ||
const { name } = await readBody(event) | ||
const webrtc = gcore().webrtc | ||
webrtc.setCustomOptions({ | ||
qualitySetId: Number(config.qualitySetId) || null, | ||
}) | ||
const { whipEndpoint, whepEndpoint, playerUrl } = | ||
await api.webrtc.createStream( | ||
const { id, whipEndpoint, whepEndpoint, playerUrl } = | ||
await webrtc.createStream( | ||
name, | ||
) | ||
return { | ||
status: 201, | ||
body: { | ||
id, | ||
playerUrl, | ||
whepEndpoint, | ||
whipEndpoint, | ||
}, | ||
} | ||
} | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineEventHandler } from "h3"; | ||
|
||
import gcore from "../utils/gcore-api"; | ||
|
||
export default defineEventHandler(async event => { | ||
const body = await readBody(event); | ||
const id = body?.id; | ||
if (!id) { | ||
throw createError({ | ||
status: 400, | ||
}); | ||
} | ||
await gcore().webrtc.toggleStream(id, true); | ||
return { | ||
status: 204, | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ApiKey, GcoreApi } from '@gcorevideo/rtckit-node' | ||
|
||
export default function gcoreApi() { | ||
const config = useRuntimeConfig() | ||
return new GcoreApi( | ||
new ApiKey(config.apiKey), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type StreamInfo = { | ||
id: number | ||
whipEndpoint: string | ||
whepEndpoint: string | ||
playerUrl: string | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters