mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
🐛 Fix streaming source url composition
This commit is contained in:
parent
dda39837c6
commit
ed88fd14ad
@ -1,5 +1,6 @@
|
||||
import { StreamingProfile } from "@models"
|
||||
import NewStreamingProfile from "@services/newStreamingProfile"
|
||||
import composeStreamingSources from "@utils/compose-streaming-sources"
|
||||
|
||||
export default {
|
||||
method: "GET",
|
||||
@ -39,12 +40,7 @@ export default {
|
||||
})
|
||||
|
||||
profiles = profiles.map((profile) => {
|
||||
profile.addresses = {
|
||||
ingest: process.env.STREAMING_INGEST_SERVER,
|
||||
hls: `${process.env.STREAMING_API_SERVER}/live/${req.user.username}:${profile._id}/src.m3u8`,
|
||||
flv: `${process.env.STREAMING_API_SERVER}/live/${req.user.username}:${profile._id}/src.flv`,
|
||||
aac: `${process.env.STREAMING_API_SERVER}/radio/${req.user.username}:${profile._id}/src.aac`,
|
||||
}
|
||||
profile.addresses = composeStreamingSources(req.user.username, profile._id)
|
||||
|
||||
return profile
|
||||
})
|
||||
|
@ -2,8 +2,10 @@ import axios from "axios"
|
||||
|
||||
import { StreamingCategory, StreamingProfile, User } from "@models"
|
||||
|
||||
const streamingServerAPIAddress = process.env.STREAMING_API_SERVER ?? ""
|
||||
import composeStreamingSources from "@utils/compose-streaming-sources"
|
||||
import lodash from "lodash"
|
||||
|
||||
const streamingServerAPIAddress = process.env.STREAMING_API_SERVER ?? ""
|
||||
const streamingServerAPIUri = `${streamingServerAPIAddress.startsWith("https") ? "https" : "http"}://${streamingServerAPIAddress.split("://")[1]}`
|
||||
|
||||
export default async (stream_id) => {
|
||||
@ -55,6 +57,8 @@ export default async (stream_id) => {
|
||||
|
||||
user = user.toObject()
|
||||
|
||||
const sources = composeStreamingSources(user.username, profile._id)
|
||||
|
||||
return {
|
||||
profile_id: profile._id,
|
||||
info: profile.info,
|
||||
@ -64,11 +68,7 @@ export default async (stream_id) => {
|
||||
video,
|
||||
audio,
|
||||
connectedClients: clients ?? 0,
|
||||
sources: {
|
||||
hls: `${streamingServerAPIUri}/stream/${user.username}:${profile._id}/src.m3u8`,
|
||||
flv: `${streamingServerAPIUri}/stream/${user.username}:${profile._id}/src.flv`,
|
||||
aac: `${streamingServerAPIUri}/stream/${user.username}:${profile._id}/src.aac`,
|
||||
}
|
||||
sources: lodash.pick(sources, ["rtmp", "hls", "flv", "aac"]),
|
||||
}
|
||||
})
|
||||
|
||||
|
15
packages/server/src/utils/compose-streaming-sources/index.js
Normal file
15
packages/server/src/utils/compose-streaming-sources/index.js
Normal file
@ -0,0 +1,15 @@
|
||||
const streamingServerAPIAddress = process.env.STREAMING_API_SERVER ?? ""
|
||||
|
||||
const streamingServerAPIUri = `${streamingServerAPIAddress.startsWith("https") ? "https" : "http"}://${streamingServerAPIAddress.split("://")[1]}`
|
||||
|
||||
export default (username, profile_id) => {
|
||||
const streamId = `${username}${profile_id ? `:${profile_id}` : ""}`
|
||||
|
||||
return {
|
||||
ingest: process.env.STREAMING_INGEST_SERVER,
|
||||
rtmp: `${streamingServerAPIUri}/${streamId}`,
|
||||
hls: `${streamingServerAPIUri}/stream/${streamId}/src.m3u8`,
|
||||
flv: `${streamingServerAPIUri}/stream/${streamId}/src.flv`,
|
||||
aac: `${streamingServerAPIUri}/stream/${streamId}/src.aac`,
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user