File tree Expand file tree Collapse file tree
common/modules/live-contest Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,3 +20,25 @@ export class GetContestAllBroadcasterInfoRespDTOItem {
2020export class GetContestAllBroadcasterInfoRespDTO {
2121 public broadcasters : Record < string , GetContestAllBroadcasterInfoRespDTOItem > ;
2222}
23+
24+ export class GetContestAllShotInfoReqDTO {
25+ @FromQuery ( )
26+ @IsString ( )
27+ @IsNotEmpty ( )
28+ public uca : string ;
29+ }
30+
31+ export class GetContestAllShotInfoRespDTOItem {
32+ public shotId : string ;
33+ public shotName : string ;
34+ public status : 'ready' | 'broadcasting' ;
35+ public tracks : {
36+ trackId : string ;
37+ type : 'video' | 'audio' ;
38+ } [ ] ;
39+ public broadcastingTrackIds : string [ ] ;
40+ }
41+
42+ export class GetContestAllShotInfoRespDTO {
43+ public shots : Record < string , GetContestAllShotInfoRespDTOItem > ;
44+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import AuthGuard from '@server/guards/auth.guard';
55import {
66 GetContestAllBroadcasterInfoReqDTO ,
77 GetContestAllBroadcasterInfoRespDTO ,
8+ GetContestAllShotInfoReqDTO ,
9+ GetContestAllShotInfoRespDTO ,
810} from '@common/modules/live-contest/live-contest.dto' ;
911import LiveContestService from './live-contest.service' ;
1012
@@ -29,4 +31,16 @@ export default class LiveContestController {
2931 broadcasters : res ,
3032 } ;
3133 }
34+
35+ @Get ( )
36+ @UseGuards ( AuthGuard )
37+ @Contract ( GetContestAllShotInfoReqDTO , GetContestAllShotInfoRespDTO )
38+ public async getContestAllShotInfo (
39+ @Data ( ) data : GetContestAllShotInfoReqDTO ,
40+ ) : Promise < GetContestAllShotInfoRespDTO > {
41+ const res = await this . service . getAllShotStoreInfo ( data . uca ) ;
42+ return {
43+ shots : res ,
44+ } ;
45+ }
3246}
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export interface ShotStoreTrackItem {
4949export type ShotStoreTracks = ShotStoreTrackItem [ ] ;
5050
5151export interface ShotStoreInfo {
52+ shotId : string ;
5253 shotName : string ;
5354 status : 'ready' | 'broadcasting' ;
5455 tracks : ShotStoreTrackItem [ ] ;
@@ -251,4 +252,16 @@ export default class LiveContestService {
251252 }
252253 this . shotStoreMap . get ( uca ) ! . delete ( shotId ) ;
253254 }
255+
256+ public getAllShotStoreInfo ( uca : string ) : Record < string , ShotStoreInfo > {
257+ if ( ! this . shotStoreMap . has ( uca ) ) {
258+ return { } ;
259+ }
260+ const res = this . shotStoreMap . get ( uca ) ! ;
261+ const obj : Record < string , ShotStoreInfo > = { } ;
262+ res . forEach ( ( value , key ) => {
263+ obj [ key ] = value ;
264+ } ) ;
265+ return obj ;
266+ }
254267}
Original file line number Diff line number Diff line change @@ -613,6 +613,7 @@ export default class SocketIOServer {
613613 socket . join ( this . getShotLogicRoomKey ( uca , id ) ) ;
614614
615615 this . liveContestService . setShotStore ( uca , id , {
616+ shotId : id ,
616617 shotName : data . shotName ,
617618 status : 'ready' ,
618619 tracks : data . tracks ,
@@ -631,7 +632,7 @@ export default class SocketIOServer {
631632 mediaRoom . peers . set ( id , shotPeer ) ;
632633 mediaRoom . shots . set ( id , shotPeer ) ;
633634
634- console . log ( `[socket] [/shot] [confirmReady] [${ uca } :${ id } ] joined shot: ${ id } ` ) ;
635+ console . log ( `[socket] [/shot] [confirmReady] [${ uca } :${ id } ] joined shot: ${ data . shotName } ` ) ;
635636
636637 return {
637638 transport : {
@@ -952,6 +953,7 @@ export default class SocketIOServer {
952953 room . peers . delete ( id ) ;
953954 }
954955 }
956+ this . liveContestService . delShotStore ( uca , id ) ;
955957 }
956958}
957959
You can’t perform that action at this time.
0 commit comments