mirror of
https://github.com/datarhei/core.git
synced 2025-10-16 13:00:37 +08:00
Add v16.7.2
This commit is contained in:
44
http/handler/api/rtmp.go
Normal file
44
http/handler/api/rtmp.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/datarhei/core/http/api"
|
||||
"github.com/datarhei/core/rtmp"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// The RTMPHandler type provides a handler for retrieving details from the RTMPHandler server
|
||||
type RTMPHandler struct {
|
||||
rtmp rtmp.Server
|
||||
}
|
||||
|
||||
// NewRTMP returns a new RTMP type. You have to provide a RTMP server instance.
|
||||
func NewRTMP(rtmp rtmp.Server) *RTMPHandler {
|
||||
return &RTMPHandler{
|
||||
rtmp: rtmp,
|
||||
}
|
||||
}
|
||||
|
||||
// ListChannels lists all currently publishing streams
|
||||
// @Summary List all publishing streams
|
||||
// @Description List all currently publishing streams
|
||||
// @ID rtmp-3-list-channels
|
||||
// @Produce json
|
||||
// @Success 200 {array} api.RTMPChannel
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v3/rtmp [get]
|
||||
func (rtmph *RTMPHandler) ListChannels(c echo.Context) error {
|
||||
channels := rtmph.rtmp.Channels()
|
||||
|
||||
list := []api.RTMPChannel{}
|
||||
|
||||
for _, c := range channels {
|
||||
list = append(list, api.RTMPChannel{
|
||||
Name: c,
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, list)
|
||||
}
|
Reference in New Issue
Block a user