Skip to content

Commit

Permalink
Merge pull request #276 from boostcampwm-2024/feature-be-#231-live_th…
Browse files Browse the repository at this point in the history
…umbnail_url

[FEAT] 썸네일 API URL 추가 / 다시보기 등록 기준으로 정렬
  • Loading branch information
i3kae authored Dec 3, 2024
2 parents 583db30 + 4ab309e commit 0706388
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/mainServer/src/host/host.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class HostController {
sessionInfo.replay = false;
sessionInfo.startDate = new Date();
sessionInfo.streamUrl = `https://kr.object.ncloudstorage.com/web22/live/${sessionInfo.sessionKey}/index.m3u8`;
sessionInfo.liveImageUrl = `https://kr.object.ncloudstorage.com/web22/live/${sessionInfo.sessionKey}/thumbnail.png`;
this.memoryDBService.updateBySessionKey(streamKey, sessionInfo);
res.status(HttpStatus.OK).json({ 'session-key': sessionInfo.sessionKey });
} catch (error) {
Expand Down
6 changes: 5 additions & 1 deletion backend/mainServer/src/memory-db/memory-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export class MemoryDBService {
}

getBroadcastInfo<T>(size: number, dtoTransformer: (info: MemoryDbDto) => T, checker: (item: MemoryDbDto) => boolean, appender: number = 0) {
const findSession = this.db.filter(item => checker(item));
const findSession = this.db.filter(item => checker(item)).sort((a: MemoryDbDto, b: MemoryDbDto) => {
const aDate = a.endDate ? a.endDate.getTime() : 0;
const bDate = b.endDate ? b.endDate.getTime() : 0;
return aDate - bDate;
});
if (findSession.length < size) {
const findSessionRev = findSession.reverse().map((info) => dtoTransformer(info));
return [[...findSessionRev], []];
Expand Down
2 changes: 1 addition & 1 deletion backend/rtmpServer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"packageManager": "[email protected]",
"dependencies": {
"@hoeeeeeh/node-media-server": "3.0.2",
"@hoeeeeeh/node-media-server": "3.0.7",
"@types/node": "^22.9.0",
"dotenv": "^16.4.5",
"path": "0.12.7"
Expand Down
104 changes: 104 additions & 0 deletions backend/rtmpServer/src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
interface Config {
logType?: number;
rtmp?: RtmpConfig;
http?: HttpConfig;
https?: SslConfig;
trans?: TransConfig;
relay?: RelayConfig;
fission?: FissionConfig;
auth?: AuthConfig;
}

interface RtmpConfig {
port?: number;
ssl?: SslConfig;
chunk_size?: number;
gop_cache?: boolean;
ping?: number;
ping_timeout?: number;
}

interface SslConfig {
key: string;
cert: string;
port?: number;
}

interface HttpConfig {
mediaroot: string;
port?: number;
allow_origin?: string;
}

interface AuthConfig {
play?: boolean;
publish?: boolean;
secret?: string;
api?: boolean;
api_user?: string;
api_pass?: string;
}

interface TransConfig {
ffmpeg: string;
tasks: TransTaskConfig[];
}

interface RelayConfig {
tasks: RelayTaskConfig[];
ffmpeg: string;
}

interface FissionConfig {
ffmpeg: string;
tasks: FissionTaskConfig[];
}

interface TransTaskConfig {
app: string;
hls?: boolean;
hlsFlags?: string;
dash?: boolean;
dashFlags?: string;
vc?: string;
vcParam?: string[];
ac?: string;
acParam?: string[];
rtmp?: boolean;
rtmpApp?: string;
mp4?: boolean;
mp4Flags?: string;
}

interface RelayTaskConfig {
app: string;
name?: string;
mode: string;
edge: string;
rtsp_transport?: string;
appendName?: boolean;
}

interface FissionTaskConfig {
rule: string;
model: FissionTaskModel[];
}

interface FissionTaskModel {
ab: string;
vb: string;
vs: string;
vf: string;
}

declare class NodeMediaServer {
constructor(config: Config);
run(): void;
on(eventName: string, listener: (id: string, StreamPath: string, args: object) => void): void;
stop(): void;
getSession(id: string): Map<string, unknown>;
}

declare module '@hoeeeeeh/node-media-server' {
export default NodeMediaServer;
}
3 changes: 2 additions & 1 deletion backend/rtmpServer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./.dist"
}
},
"typeRoots": ["./src/types"]
}
28 changes: 23 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2689,16 +2689,18 @@ __metadata:
languageName: node
linkType: hard

"@hoeeeeeh/node-media-server@npm:3.0.2":
version: 3.0.2
resolution: "@hoeeeeeh/node-media-server@npm:3.0.2"
"@hoeeeeeh/node-media-server@npm:3.0.7":
version: 3.0.7
resolution: "@hoeeeeeh/node-media-server@npm:3.0.7"
dependencies:
"@aws-sdk/client-s3": "npm:^3.688.0"
"@types/node": "npm:^22.9.0"
basic-auth-connect: "npm:^1.0.0"
body-parser: "npm:1.20.3"
chalk: "npm:^4.1.0"
chokidar: "npm:^4.0.1"
dateformat: "npm:^4.6.3"
dotenv: "npm:^16.4.5"
express: "npm:^4.19.2"
http2-express-bridge: "npm:^1.0.7"
lodash: "npm:^4.17.21"
Expand All @@ -2707,7 +2709,7 @@ __metadata:
ws: "npm:^8.13.0"
bin:
node-media-server: bin/app.js
checksum: 10c0/45b6c240e825e1e72a1100347c99b29bdb1462fb556a8af4337f6d134a5ab99eabb9e722056b314880e1f679d8609abfd866516f2f7bd7b7838880ce0ae0da22
checksum: 10c0/54a26fddd0bef9bfc8f15c6a22d7019b379070501b793dd5a8482d434c3a9fc93e6e04428a83e1ec48a468102d7f360dcd5a371f946ea5ae4e4d6f129413bd31
languageName: node
linkType: hard

Expand Down Expand Up @@ -6236,6 +6238,15 @@ __metadata:
languageName: node
linkType: hard

"chokidar@npm:^4.0.1":
version: 4.0.1
resolution: "chokidar@npm:4.0.1"
dependencies:
readdirp: "npm:^4.0.1"
checksum: 10c0/4bb7a3adc304059810bb6c420c43261a15bb44f610d77c35547addc84faa0374265c3adc67f25d06f363d9a4571962b02679268c40de07676d260de1986efea9
languageName: node
linkType: hard

"chownr@npm:^2.0.0":
version: 2.0.0
resolution: "chownr@npm:2.0.0"
Expand Down Expand Up @@ -11447,6 +11458,13 @@ __metadata:
languageName: node
linkType: hard

"readdirp@npm:^4.0.1":
version: 4.0.2
resolution: "readdirp@npm:4.0.2"
checksum: 10c0/a16ecd8ef3286dcd90648c3b103e3826db2b766cdb4a988752c43a83f683d01c7059158d623cbcd8bdfb39e65d302d285be2d208e7d9f34d022d912b929217dd
languageName: node
linkType: hard

"readdirp@npm:~3.6.0":
version: 3.6.0
resolution: "readdirp@npm:3.6.0"
Expand Down Expand Up @@ -11831,7 +11849,7 @@ __metadata:
resolution: "rtmpServer@workspace:backend/rtmpServer"
dependencies:
"@eslint/js": "npm:^9.13.0"
"@hoeeeeeh/node-media-server": "npm:3.0.2"
"@hoeeeeeh/node-media-server": "npm:3.0.7"
"@types/node": "npm:^22.9.0"
"@typescript-eslint/eslint-plugin": "npm:^8.14.0"
"@typescript-eslint/parser": "npm:^8.14.0"
Expand Down

0 comments on commit 0706388

Please sign in to comment.