refactor(media): consolidate upload/edit/download into MediaService
Merge UploadService, EditService, JobOrchestrationService, and
DownloadService into a single MediaService with a unified Job lifecycle
(READY → PROCESSING → SUCCEEDED/FAILED via JobState enum).
- Add MediaController (/api/v1/media) exposing compress, save, and clip
- Add JobController (/api/v1/job) for status polling and file download
- Move clip/thumbnail download into ClipController (/{id}/media, /{id}/thumbnail)
- Move stream saveSection/clip from StreamService into MediaService
- Simplify Job DTO: remove dual ClipOptions/files, add ProgressTracker and download file
- Refactor JobRegistryService.add() → generateJob() to co-locate creation and registration
- Wire FFmpeg out_time_ms progress parsing into StreamActionsService via CommandRunner
- Rename GET /api/v1/auth/user → GET /api/v1/user/me
- Delete DownloadController, MetadataController, UploadController
This commit is contained in:
@@ -6,12 +6,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* In-memory store for {@link Job} instances, keyed by job UUID.
|
||||
* Provides add/lookup only — actual job processing is handled by
|
||||
* {@link JobOrchestrationService}.
|
||||
* Provides add/lookup only
|
||||
*/
|
||||
@Service
|
||||
public class JobRegistryService {
|
||||
@@ -19,13 +19,16 @@ public class JobRegistryService {
|
||||
private final ConcurrentHashMap<String, Job> jobs = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Adds a new job to the job map.
|
||||
*
|
||||
* @param job the job to add
|
||||
* Creates and returns a new job
|
||||
* @return Job
|
||||
*/
|
||||
public void add(Job job) {
|
||||
logger.info("Added job: {}", job.getUuid());
|
||||
jobs.put(job.getUuid(), job);
|
||||
public Job generateJob() {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Job job = new Job(uuid);
|
||||
|
||||
jobs.put(uuid, job);
|
||||
logger.info("New job with UUID {} created", uuid);
|
||||
return job;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user