mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +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 { StreamingProfile } from "@models"
|
||||||
import NewStreamingProfile from "@services/newStreamingProfile"
|
import NewStreamingProfile from "@services/newStreamingProfile"
|
||||||
|
import composeStreamingSources from "@utils/compose-streaming-sources"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@ -39,12 +40,7 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
profiles = profiles.map((profile) => {
|
profiles = profiles.map((profile) => {
|
||||||
profile.addresses = {
|
profile.addresses = composeStreamingSources(req.user.username, profile._id)
|
||||||
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`,
|
|
||||||
}
|
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
})
|
})
|
||||||
|
@ -2,8 +2,10 @@ import axios from "axios"
|
|||||||
|
|
||||||
import { StreamingCategory, StreamingProfile, User } from "@models"
|
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]}`
|
const streamingServerAPIUri = `${streamingServerAPIAddress.startsWith("https") ? "https" : "http"}://${streamingServerAPIAddress.split("://")[1]}`
|
||||||
|
|
||||||
export default async (stream_id) => {
|
export default async (stream_id) => {
|
||||||
@ -55,6 +57,8 @@ export default async (stream_id) => {
|
|||||||
|
|
||||||
user = user.toObject()
|
user = user.toObject()
|
||||||
|
|
||||||
|
const sources = composeStreamingSources(user.username, profile._id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
profile_id: profile._id,
|
profile_id: profile._id,
|
||||||
info: profile.info,
|
info: profile.info,
|
||||||
@ -64,11 +68,7 @@ export default async (stream_id) => {
|
|||||||
video,
|
video,
|
||||||
audio,
|
audio,
|
||||||
connectedClients: clients ?? 0,
|
connectedClients: clients ?? 0,
|
||||||
sources: {
|
sources: lodash.pick(sources, ["rtmp", "hls", "flv", "aac"]),
|
||||||
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`,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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