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
50 lines
1.3 KiB
Java
50 lines
1.3 KiB
Java
package com.ddf.vodsystem.services;
|
|
|
|
import com.ddf.vodsystem.dto.Job;
|
|
import com.ddf.vodsystem.exceptions.JobNotFound;
|
|
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
|
|
*/
|
|
@Service
|
|
public class JobRegistryService {
|
|
private static final Logger logger = LoggerFactory.getLogger(JobRegistryService.class);
|
|
private final ConcurrentHashMap<String, Job> jobs = new ConcurrentHashMap<>();
|
|
|
|
/**
|
|
* Creates and returns a new job
|
|
* @return 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;
|
|
}
|
|
|
|
/**
|
|
* Retrieves a job by its UUID.
|
|
*
|
|
* @param uuid the UUID of the job
|
|
* @return the Job object
|
|
* @throws JobNotFound if the job does not exist
|
|
*/
|
|
public Job getJob(String uuid) {
|
|
Job job = jobs.get(uuid);
|
|
|
|
if (job == null) {
|
|
throw new JobNotFound("Job not found");
|
|
}
|
|
|
|
return job;
|
|
}
|
|
} |