|
|
|
@ -83,21 +83,22 @@ func loadConfPathData(ctx *gin.Context) (interface{}, error) {
@@ -83,21 +83,22 @@ func loadConfPathData(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type apiPathManager interface { |
|
|
|
|
apiPathsList(req pathAPIPathsListReq) pathAPIPathsListRes |
|
|
|
|
apiPathsList() pathAPIPathsListRes |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type apiRTSPServer interface { |
|
|
|
|
apiSessionsList(req rtspServerAPISessionsListReq) rtspServerAPISessionsListRes |
|
|
|
|
apiSessionsKick(req rtspServerAPISessionsKickReq) rtspServerAPISessionsKickRes |
|
|
|
|
apiConnsList() rtspServerAPIConnsListRes |
|
|
|
|
apiSessionsList() rtspServerAPISessionsListRes |
|
|
|
|
apiSessionsKick(string) rtspServerAPISessionsKickRes |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type apiRTMPServer interface { |
|
|
|
|
apiConnsList(req rtmpServerAPIConnsListReq) rtmpServerAPIConnsListRes |
|
|
|
|
apiConnsKick(req rtmpServerAPIConnsKickReq) rtmpServerAPIConnsKickRes |
|
|
|
|
apiConnsList() rtmpServerAPIConnsListRes |
|
|
|
|
apiConnsKick(id string) rtmpServerAPIConnsKickRes |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type apiHLSServer interface { |
|
|
|
|
apiHLSMuxersList(req hlsServerAPIMuxersListReq) hlsServerAPIMuxersListRes |
|
|
|
|
apiHLSMuxersList() hlsServerAPIMuxersListRes |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type apiParent interface { |
|
|
|
@ -162,11 +163,13 @@ func newAPI(
@@ -162,11 +163,13 @@ func newAPI(
|
|
|
|
|
group.GET("/v1/paths/list", a.onPathsList) |
|
|
|
|
|
|
|
|
|
if !interfaceIsEmpty(a.rtspServer) { |
|
|
|
|
group.GET("/v1/rtspconns/list", a.onRTSPConnsList) |
|
|
|
|
group.GET("/v1/rtspsessions/list", a.onRTSPSessionsList) |
|
|
|
|
group.POST("/v1/rtspsessions/kick/:id", a.onRTSPSessionsKick) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !interfaceIsEmpty(a.rtspsServer) { |
|
|
|
|
group.GET("/v1/rtspsconns/list", a.onRTSPSConnsList) |
|
|
|
|
group.GET("/v1/rtspssessions/list", a.onRTSPSSessionsList) |
|
|
|
|
group.POST("/v1/rtspssessions/kick/:id", a.onRTSPSSessionsKick) |
|
|
|
|
} |
|
|
|
@ -382,7 +385,17 @@ func (a *api) onConfigPathsDelete(ctx *gin.Context) {
@@ -382,7 +385,17 @@ func (a *api) onConfigPathsDelete(ctx *gin.Context) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onPathsList(ctx *gin.Context) { |
|
|
|
|
res := a.pathManager.apiPathsList(pathAPIPathsListReq{}) |
|
|
|
|
res := a.pathManager.apiPathsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, res.data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onRTSPConnsList(ctx *gin.Context) { |
|
|
|
|
res := a.rtspServer.apiConnsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
@ -392,7 +405,7 @@ func (a *api) onPathsList(ctx *gin.Context) {
@@ -392,7 +405,7 @@ func (a *api) onPathsList(ctx *gin.Context) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onRTSPSessionsList(ctx *gin.Context) { |
|
|
|
|
res := a.rtspServer.apiSessionsList(rtspServerAPISessionsListReq{}) |
|
|
|
|
res := a.rtspServer.apiSessionsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
@ -404,7 +417,7 @@ func (a *api) onRTSPSessionsList(ctx *gin.Context) {
@@ -404,7 +417,7 @@ func (a *api) onRTSPSessionsList(ctx *gin.Context) {
|
|
|
|
|
func (a *api) onRTSPSessionsKick(ctx *gin.Context) { |
|
|
|
|
id := ctx.Param("id") |
|
|
|
|
|
|
|
|
|
res := a.rtspServer.apiSessionsKick(rtspServerAPISessionsKickReq{id: id}) |
|
|
|
|
res := a.rtspServer.apiSessionsKick(id) |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusNotFound) |
|
|
|
|
return |
|
|
|
@ -413,8 +426,18 @@ func (a *api) onRTSPSessionsKick(ctx *gin.Context) {
@@ -413,8 +426,18 @@ func (a *api) onRTSPSessionsKick(ctx *gin.Context) {
|
|
|
|
|
ctx.Status(http.StatusOK) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onRTSPSConnsList(ctx *gin.Context) { |
|
|
|
|
res := a.rtspsServer.apiConnsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, res.data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onRTSPSSessionsList(ctx *gin.Context) { |
|
|
|
|
res := a.rtspsServer.apiSessionsList(rtspServerAPISessionsListReq{}) |
|
|
|
|
res := a.rtspsServer.apiSessionsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
@ -426,7 +449,7 @@ func (a *api) onRTSPSSessionsList(ctx *gin.Context) {
@@ -426,7 +449,7 @@ func (a *api) onRTSPSSessionsList(ctx *gin.Context) {
|
|
|
|
|
func (a *api) onRTSPSSessionsKick(ctx *gin.Context) { |
|
|
|
|
id := ctx.Param("id") |
|
|
|
|
|
|
|
|
|
res := a.rtspsServer.apiSessionsKick(rtspServerAPISessionsKickReq{id: id}) |
|
|
|
|
res := a.rtspsServer.apiSessionsKick(id) |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusNotFound) |
|
|
|
|
return |
|
|
|
@ -436,7 +459,7 @@ func (a *api) onRTSPSSessionsKick(ctx *gin.Context) {
@@ -436,7 +459,7 @@ func (a *api) onRTSPSSessionsKick(ctx *gin.Context) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onRTMPConnsList(ctx *gin.Context) { |
|
|
|
|
res := a.rtmpServer.apiConnsList(rtmpServerAPIConnsListReq{}) |
|
|
|
|
res := a.rtmpServer.apiConnsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
@ -448,7 +471,7 @@ func (a *api) onRTMPConnsList(ctx *gin.Context) {
@@ -448,7 +471,7 @@ func (a *api) onRTMPConnsList(ctx *gin.Context) {
|
|
|
|
|
func (a *api) onRTMPConnsKick(ctx *gin.Context) { |
|
|
|
|
id := ctx.Param("id") |
|
|
|
|
|
|
|
|
|
res := a.rtmpServer.apiConnsKick(rtmpServerAPIConnsKickReq{id: id}) |
|
|
|
|
res := a.rtmpServer.apiConnsKick(id) |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusNotFound) |
|
|
|
|
return |
|
|
|
@ -458,7 +481,7 @@ func (a *api) onRTMPConnsKick(ctx *gin.Context) {
@@ -458,7 +481,7 @@ func (a *api) onRTMPConnsKick(ctx *gin.Context) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onRTMPSConnsList(ctx *gin.Context) { |
|
|
|
|
res := a.rtmpsServer.apiConnsList(rtmpServerAPIConnsListReq{}) |
|
|
|
|
res := a.rtmpsServer.apiConnsList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
@ -470,7 +493,7 @@ func (a *api) onRTMPSConnsList(ctx *gin.Context) {
@@ -470,7 +493,7 @@ func (a *api) onRTMPSConnsList(ctx *gin.Context) {
|
|
|
|
|
func (a *api) onRTMPSConnsKick(ctx *gin.Context) { |
|
|
|
|
id := ctx.Param("id") |
|
|
|
|
|
|
|
|
|
res := a.rtmpsServer.apiConnsKick(rtmpServerAPIConnsKickReq{id: id}) |
|
|
|
|
res := a.rtmpsServer.apiConnsKick(id) |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusNotFound) |
|
|
|
|
return |
|
|
|
@ -480,7 +503,7 @@ func (a *api) onRTMPSConnsKick(ctx *gin.Context) {
@@ -480,7 +503,7 @@ func (a *api) onRTMPSConnsKick(ctx *gin.Context) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (a *api) onHLSMuxersList(ctx *gin.Context) { |
|
|
|
|
res := a.hlsServer.apiHLSMuxersList(hlsServerAPIMuxersListReq{}) |
|
|
|
|
res := a.hlsServer.apiHLSMuxersList() |
|
|
|
|
if res.err != nil { |
|
|
|
|
ctx.AbortWithStatus(http.StatusInternalServerError) |
|
|
|
|
return |
|
|
|
|