mirror of
				https://github.com/datarhei/core.git
				synced 2025-11-01 03:42:51 +08:00 
			
		
		
		
	 eb1cc37456
			
		
	
	eb1cc37456
	
	
	
		
			
			Commits (Ingo Oppermann): - Add experimental SRT connection stats and logs - Hide /config/reload endpoint in reade-only mode - Add SRT server - Create v16 in go.mod - Fix data races, tests, lint, and update dependencies - Add trailing slash for routed directories (datarhei/restreamer#340) - Allow relative URLs in content in static routes Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
		
			
				
	
	
		
			45 lines
		
	
	
		
			1017 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1017 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package api
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 
 | |
| 	"github.com/datarhei/core/v16/http/api"
 | |
| 	"github.com/datarhei/core/v16/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 RTMP streams
 | |
| // @Summary List all publishing RTMP streams
 | |
| // @Description List all currently publishing RTMP 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)
 | |
| }
 |