Class LivestreamController
java.lang.Object
vn.edu.uit.csbu.software_design.software_design_backend.livestream.LivestreamController
@RestController
@CrossOrigin(origins="*")
@RequestMapping("/api/stream")
public class LivestreamController
extends Object
The `LivestreamController` class in Java handles streaming requests, proxies them to an Nginx
server, and includes methods for checking stream status and validating stream keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCurrentStreaming(Integer page) This Java function retrieves the current streaming accounts with an optional page parameter.isLive(Livestreams streamNameList) The function `isLive` takes a list of stream names as input and returns a list of booleans indicating whether each stream is live or not.isStreamLive(String streamName) The function checks if a specified stream is live on a livestream service.voidThe function `stream` handles streaming requests by validating the stream ID, checking if the stream is live, and proxying the request to an Nginx HLS stream if valid.voidThe function streams content from an Nginx HLS server based on a provided stream key file, with validation and proxying mechanisms in place.org.springframework.http.ResponseEntity<String> validateSteamKey(org.springframework.util.MultiValueMap<String, String> rtmpBody) Validate steam key response entity.
-
Constructor Details
-
LivestreamController
public LivestreamController()
-
-
Method Details
-
stream
@GetMapping("/watch") @ResponseStatus(OK) public void stream(jakarta.servlet.http.HttpServletResponse response, @RequestParam String streamId) The function `stream` handles streaming requests by validating the stream ID, checking if the stream is live, and proxying the request to an Nginx HLS stream if valid.- Parameters:
response- The `response` parameter in the `stream` method is an object of the `HttpServletResponse` class. It is used to manipulate the HTTP response that will be sent back to the client making the request. In this method, it is used to set headers, set content type, and write thestreamId- The `streamId` parameter in the `stream` method of the `WatchController` class is used to identify the streamer whose video stream is being requested. This parameter is passed as a request parameter in the URL when accessing the `/watch` endpoint.
-
streaming
@GetMapping("/{streamKeyFile}") public void streaming(jakarta.servlet.http.HttpServletResponse response, @PathVariable String streamKeyFile) The function streams content from an Nginx HLS server based on a provided stream key file, with validation and proxying mechanisms in place.- Parameters:
response- The `response` parameter in the `streaming` method is of type `HttpServletResponse`. It is used to manipulate the HTTP response that will be sent back to the client. In this method, it is used to set headers for allowing cross-origin requests, setting the content type of the response,streamKeyFile- The `streamKeyFile` parameter in the `streaming` method represents the unique identifier or key associated with the HLS stream that the client is requesting to stream. This identifier is used to construct the URL for the actual Nginx HLS stream that will be proxied to the client.
-
isStreamLive
@GetMapping("/isStreamLive/{streamName}") public Boolean isStreamLive(@PathVariable String streamName) The function checks if a specified stream is live on a livestream service.- Parameters:
streamName- The `streamName` parameter is a path variable that is passed in the URL to identify the specific stream for which we want to check if it is live or not.- Returns:
- A Boolean value indicating whether the stream with the given streamName is live or not.
-
isLive
The function `isLive` takes a list of stream names as input and returns a list of booleans indicating whether each stream is live or not.- Parameters:
streamNameList- The `streamNameList` parameter in the `isLive` method is of type `Livestreams`, which is expected to be passed in the request body. It likely contains a list of stream names or identifiers that you want to check for live status.- Returns:
- A list of boolean values indicating whether each stream in the provided list is live or not.
-
getCurrentStreaming
@GetMapping("/streaming") public List<accountSecureResponseDTO> getCurrentStreaming(@RequestParam(required=false) Integer page) This Java function retrieves the current streaming accounts with an optional page parameter.- Parameters:
page- The `page` parameter is used to specify the page number for retrieving the current streaming data. It is an optional parameter, as indicated by `@RequestParam(required = false)`. If the `page` parameter is not provided in the request, the default value of 1 is used.- Returns:
- The method `getCurrentStreaming` is returning a list of `accountSecureResponseDTO` objects.
-
validateSteamKey
-