From ba378680c67893347c231a4dbd2c1d5d9822ad21 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Thu, 2 Jul 2026 19:09:07 +0100 Subject: [PATCH] feat(markers): add save endpoint with markers --- .../vodsystem/controllers/MediaController.java | 16 ++++++++++++++++ .../ddf/vodsystem/services/MediaService.java | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ddf/vodsystem/controllers/MediaController.java b/src/main/java/com/ddf/vodsystem/controllers/MediaController.java index 0d5185f..77ff18e 100644 --- a/src/main/java/com/ddf/vodsystem/controllers/MediaController.java +++ b/src/main/java/com/ddf/vodsystem/controllers/MediaController.java @@ -1,6 +1,7 @@ package com.ddf.vodsystem.controllers; import com.ddf.vodsystem.controllers.dto.ClipSectionRequest; +import com.ddf.vodsystem.controllers.dto.SaveSectionByMarkerRequest; import com.ddf.vodsystem.controllers.dto.SaveSectionRequest; import com.ddf.vodsystem.controllers.dto.UUIDResponse; import com.ddf.vodsystem.dto.Job; @@ -54,6 +55,21 @@ public class MediaController { )); } + @PostMapping("/save/markers") + public ResponseEntity> saveByMarkers( + @Valid @RequestBody SaveSectionByMarkerRequest saveSectionByMarkerRequest) throws IOException { + Job job = mediaService.saveSection( + saveSectionByMarkerRequest.startMarkerId(), + saveSectionByMarkerRequest.endMarkerId(), + saveSectionByMarkerRequest.title(), + saveSectionByMarkerRequest.description()); + return ResponseEntity.ok(new APIResponse<>( + SUCCESS, + "Section saving successfully started", + new UUIDResponse(job.getUuid()) + )); + } + @PostMapping("/clip") public ResponseEntity> clip( @RequestBody ClipSectionRequest clipSectionRequest) throws IOException { diff --git a/src/main/java/com/ddf/vodsystem/services/MediaService.java b/src/main/java/com/ddf/vodsystem/services/MediaService.java index e466230..db2a6bc 100644 --- a/src/main/java/com/ddf/vodsystem/services/MediaService.java +++ b/src/main/java/com/ddf/vodsystem/services/MediaService.java @@ -3,6 +3,7 @@ package com.ddf.vodsystem.services; import com.ddf.vodsystem.dto.ClipOptions; import com.ddf.vodsystem.dto.Job; import com.ddf.vodsystem.dto.JobState; +import com.ddf.vodsystem.entities.Marker; import com.ddf.vodsystem.entities.User; import com.ddf.vodsystem.exceptions.NotAuthenticated; import com.ddf.vodsystem.services.media.CompressionService; @@ -32,12 +33,13 @@ public class MediaService { private static final int HLS_SEGMENT_LENGTH = 3; private final StreamActionsService streamActionsService; private final VodService vodService; + private final MarkerService markerService; public MediaService(JobRegistryService jobRegistryService, DirectoryService directoryService, CompressionService compressionService, UserService userService, - ClipService clipService, StreamActionsService streamActionsService, VodService vodService) { + ClipService clipService, StreamActionsService streamActionsService, VodService vodService, MarkerService markerService) { this.jobRegistryService = jobRegistryService; this.directoryService = directoryService; this.compressionService = compressionService; @@ -45,6 +47,7 @@ public class MediaService { this.clipService = clipService; this.streamActionsService = streamActionsService; this.vodService = vodService; + this.markerService = markerService; } /** @@ -149,6 +152,18 @@ public class MediaService { ); } + public Job saveSection( + Long startMarkerId, + Long endMarkerId, + String title, + String description + ) throws IOException { + Marker start = markerService.getMarkerById(startMarkerId); + Marker end = markerService.getMarkerById(endMarkerId); + + return saveSection(start.getTimestamp(), end.getTimestamp(), title, description); + } + /** * Saves the last {@code duration} seconds of the currently authenticated user's live stream as a clip. *