package com.ddf.vodsystem.controllers; import com.ddf.vodsystem.controllers.dto.StreamResponse; import com.ddf.vodsystem.dto.APIResponse; import com.ddf.vodsystem.entities.Stream; import com.ddf.vodsystem.services.StreamService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Optional; @RestController @RequestMapping("/api/v1/stream") public class StreamController { private static final Logger logger = LoggerFactory.getLogger(StreamController.class); private static final String SUCCESS = "success"; private final StreamService streamService; public StreamController(StreamService streamService) { this.streamService = streamService; } /** * Starts a new stream for the user owning the given stream key. *
* Called by nginx via its {@code on_publish} RTMP callback when a broadcast begins.
*
* @param streamKey the RTMP stream key identifying the broadcasting user
* @return {@code 200 OK} wrapping the newly started {@link Stream}
*/
// Called by nginx on_publish
@PostMapping("/start")
public ResponseEntity
* Called by nginx via its {@code on_publish_done} RTMP callback when a broadcast stops.
*
* @param streamKey the RTMP stream key identifying the broadcasting user
* @return {@code 200 OK} confirming the stream was ended
*/
// Called by nginx on_publish_done
@PostMapping("/stop")
public ResponseEntity
* Called periodically by nginx via its {@code on_update} RTMP callback.
*
* @param streamKey the RTMP stream key identifying the broadcasting user
* @return {@code 200 OK} confirming the heartbeat was recorded
*/
// Called by nginx on_update
@PostMapping("/heartbeat")
public ResponseEntity