Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/pre-api/values.dev.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ java:
MEDIA_KIND_STREAMING_ENDPOINT_ADVANCED_SETTINGS_NAME: ap-jitp-hmcts-disable-edge-buffer
MEDIA_KIND_VOD_STREAMING_ENDPOINT: vod
MEDIA_KIND_LIVE_STREAMING_ENDPOINT: live
RTMPS_SUFFIX_ENABLED: true
# Don't modify below here
image: ${IMAGE_NAME}
ingressHost: ${SERVICE_FQDN}
1 change: 1 addition & 0 deletions charts/pre-api/values.stg.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ java:
ENABLE_NULL_DURATION_UPSERT: false
ENABLE_MIGRATED_DATA: true
MEDIA_KIND_SUBSCRIPTION_ID: 36a78cf2-290d-4621-b974-eda4a570ef70
RTMPS_SUFFIX_ENABLED: true
image: ${IMAGE_NAME}
ingressHost: ${SERVICE_FQDN}
9 changes: 9 additions & 0 deletions pre-api-stg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ definitions:
description: CaptureSessionDeletedAt
format: date-time
type: string
displayed_rtmps_link:
description: CreateCaptureSessionDisplayedRtmpsLink
type: string
finished_at:
description: CreateCaptureSessionFinishedAt
format: date-time
Expand Down Expand Up @@ -1323,6 +1326,9 @@ definitions:
description: CaptureSessionDeletedAt
format: date-time
type: string
displayed_rtmps_link:
description: CreateCaptureSessionDisplayedRtmpsLink
type: string
finished_at:
description: CreateCaptureSessionFinishedAt
format: date-time
Expand Down Expand Up @@ -1922,6 +1928,9 @@ definitions:
description:
description: LiveEventDescription
type: string
displayed_rtmps_link:
description: DisplayedRtmpsLink
type: string
id:
description: LiveEventId
type: string
Expand Down
2 changes: 1 addition & 1 deletion specs/pre-api.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,17 @@ public ResponseEntity<LiveEventDTO> getLiveEvents(@PathVariable String liveEvent
try {
CaptureSessionDTO captureSession = captureSessionService.findByLiveEventId(liveEventName);
if (captureSession.getStatus() == RecordingStatus.INITIALISING) {
captureSessionService.startCaptureSession(
CaptureSessionDTO result = captureSessionService.startCaptureSession(
captureSession.getId(),
RecordingStatus.STANDBY,
data.getInputRtmp()
);
data.setDisplayedRtmpsLink(result.getDisplayedRtmpsLink());
}
log.info("About to override RTMPS link");
if (captureSession.getStatus() == RecordingStatus.STANDBY
|| captureSession.getStatus() == RecordingStatus.RECORDING) {
data.setDisplayedRtmpsLink(captureSession.getDisplayedRtmpsLink());
}
} catch (NotFoundException e) {
log.info("Capture session for live event {} not found", liveEventName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public ResponseEntity<BookingDTO> bookingScheduledForPast(@PathVariable UUID boo
booking.setScheduledFor(Timestamp.from(booking.getScheduledFor().toInstant().minusSeconds(31536000)));
bookingRepository.save(booking);

return ResponseEntity.ok(new BookingDTO(booking));
return ResponseEntity.ok(new BookingDTO(booking, true));
}

@SneakyThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class BookingDTO {
@Schema(description = "BookingModifiedAt")
private Timestamp modifiedAt;

public BookingDTO(Booking bookingEntity) {
public BookingDTO(Booking bookingEntity, boolean rtmpsSuffixEnabled) {
this.id = bookingEntity.getId();
this.caseDTO = new CaseDTO(bookingEntity.getCaseId());
this.scheduledFor = bookingEntity.getScheduledFor();
Expand All @@ -60,7 +60,8 @@ public BookingDTO(Booking bookingEntity) {
.map(ParticipantDTO::new))
.collect(Collectors.toList());
this.captureSessions = Stream.ofNullable(bookingEntity.getCaptureSessions())
.flatMap(captureSessions -> captureSessions.stream().map(CaptureSessionDTO::new))
.flatMap(captureSessions -> captureSessions.stream()
.map(cs -> new CaptureSessionDTO(cs, rtmpsSuffixEnabled)))
.sorted(Comparator.comparing(CaptureSessionDTO::getId))
.collect(Collectors.toList());
this.shares = Stream.ofNullable(bookingEntity.getShares())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import uk.gov.hmcts.reform.preapi.enums.CaseState;

import java.sql.Timestamp;
import java.util.Locale;

import static java.lang.String.format;

@Data
@NoArgsConstructor
Expand All @@ -30,11 +33,25 @@ public class CaptureSessionDTO extends CreateCaptureSessionDTO {
@Schema(description = "CaptureSessionCaseClosedAt")
private Timestamp caseClosedAt;

public CaptureSessionDTO(CaptureSession captureSession) {
@Schema(description = "CreateCaptureSessionDisplayedRtmpsLink")
private String displayedRtmpsLink;

public CaptureSessionDTO(CaptureSession captureSession, Boolean rtmpsSuffixEnabled) {
super(captureSession);
deletedAt = captureSession.getDeletedAt();
courtName = captureSession.getBooking().getCaseId().getCourt().getName();
caseState = captureSession.getBooking().getCaseId().getState();
caseClosedAt = captureSession.getBooking().getCaseId().getClosedAt();

if (rtmpsSuffixEnabled) {
String courtPrefix = captureSession.getBooking().getCaseId().getCourt().getName()
.substring(0, 3).toUpperCase(Locale.UK);
String caseRef = captureSession.getBooking().getCaseId().getReference();

displayedRtmpsLink = format("%s/%s-%s", captureSession.getIngestAddress(), courtPrefix, caseRef);
} else {
displayedRtmpsLink = captureSession.getIngestAddress();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ public EditRequestDTO(EditRequest editRequest,
boolean includeReencodedRecordings) {
this.id = editRequest.getId();
if (includeSourceRecording) {
this.sourceRecording = new RecordingDTO(editRequest.getSourceRecording(), includeReencodedRecordings);
this.sourceRecording = new RecordingDTO(
editRequest.getSourceRecording(),
includeReencodedRecordings,
// RTMPS Suffix enabled: can always be true for edits as no longer actively recording
true
);
}
this.editInstruction = fromJson(editRequest.getEditInstruction());
this.status = editRequest.getStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public class RecordingDTO extends BaseRecordingDTO {
private EditRequestStatus editStatus;

public RecordingDTO(Recording recording) {
this(recording, true);
this(recording, true, true);
}

public RecordingDTO(Recording recording, boolean includeReencodedRecordings) {
public RecordingDTO(Recording recording, boolean includeReencodedRecordings, boolean rtmpsSuffixEnabled) {
super();
id = recording.getId();
captureSession = new CaptureSessionDTO(recording.getCaptureSession());
captureSession = new CaptureSessionDTO(recording.getCaptureSession(), rtmpsSuffixEnabled);
if (recording.getParentRecording() != null) {
parentRecordingId = recording.getParentRecording().getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class LiveEventDTO {
@Schema(description = "LiveEventInputRtmp")
private String inputRtmp;

@Schema(description = "DisplayedRtmpsLink")
private String displayedRtmpsLink;

public LiveEventDTO(MkLiveEvent liveEvent) {
id = liveEvent.getId();
name = liveEvent.getName();
Expand All @@ -48,5 +51,6 @@ public LiveEventDTO(MkLiveEvent liveEvent) {
.findFirst()
.map(LiveEventEndpoint::url)
.orElse(null);
displayedRtmpsLink = inputRtmp; // default unless overridden
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class BookingService {
private final ShareBookingService shareBookingService;
private final CaseService caseService;


private final boolean rtmpsSuffixEnabled;
private final boolean enableMigratedData;

@Autowired
Expand All @@ -62,28 +64,31 @@ public BookingService(final BookingRepository bookingRepository,
final CaptureSessionService captureSessionService,
final ShareBookingService shareBookingService,
@Lazy CaseService caseService,
@Value("${mediakind.rtmpsSuffixEnabled:false}")
boolean rtmpsSuffixEnabled,
@Value("${migration.enableMigratedData:false}") boolean enableMigratedData) {
this.bookingRepository = bookingRepository;
this.participantRepository = participantRepository;
this.caseRepository = caseRepository;
this.captureSessionService = captureSessionService;
this.shareBookingService = shareBookingService;
this.caseService = caseService;
this.rtmpsSuffixEnabled = rtmpsSuffixEnabled;
this.enableMigratedData = enableMigratedData;
}

@PreAuthorize("@authorisationService.hasBookingAccess(authentication, #id)")
@Transactional
public BookingDTO findById(UUID id) {
return bookingRepository.findByIdAndDeletedAtIsNull(id)
.map(BookingDTO::new)
.map(b -> new BookingDTO(b, rtmpsSuffixEnabled))
.orElseThrow(() -> new NotFoundException("BookingDTO not found"));
}

@Transactional
public Page<BookingDTO> findAllByCaseId(UUID caseId, Pageable pageable) {
return bookingRepository.findByCaseId_IdAndDeletedAtIsNull(caseId, pageable)
.map(BookingDTO::new);
.map(b -> new BookingDTO(b, rtmpsSuffixEnabled));
}

@Transactional
Expand Down Expand Up @@ -124,7 +129,7 @@ public Page<BookingDTO> searchBy(
enableMigratedData || auth.hasRole("ROLE_SUPER_USER"),
pageable
)
.map(BookingDTO::new);
.map(b -> new BookingDTO(b, rtmpsSuffixEnabled));
}

@Transactional
Expand Down Expand Up @@ -249,7 +254,7 @@ public void deleteCascade(Case caseEntity) {
public List<BookingDTO> findAllPastBookings() {
return bookingRepository.findAllPastUnusedBookings(Timestamp.from(Instant.now()))
.stream()
.map(BookingDTO::new)
.map(b -> new BookingDTO(b, rtmpsSuffixEnabled))
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class CaptureSessionService {
private final AzureFinalStorageService azureFinalStorageService;
private final AuditService auditService;

private final boolean rtmpsSuffixEnabled;

@Setter
private boolean enableMigratedData;

Expand All @@ -70,6 +72,8 @@ public CaptureSessionService(RecordingService recordingService,
@Lazy BookingService bookingService,
AzureFinalStorageService azureFinalStorageService,
AuditService auditService,
@Value("${mediakind.rtmpsSuffixEnabled:false}")
boolean rtmpsSuffixEnabled,
@Value("${migration.enableMigratedData:false}") boolean enableMigratedData) {
this.recordingService = recordingService;
this.captureSessionRepository = captureSessionRepository;
Expand All @@ -79,6 +83,7 @@ public CaptureSessionService(RecordingService recordingService,
this.azureFinalStorageService = azureFinalStorageService;
this.auditService = auditService;
this.enableMigratedData = enableMigratedData;
this.rtmpsSuffixEnabled = rtmpsSuffixEnabled;
}

@Transactional
Expand All @@ -88,9 +93,12 @@ public CaptureSessionDTO findByLiveEventId(String liveEventId) {
Long.parseUnsignedLong(liveEventId.substring(0, 16), 16),
Long.parseUnsignedLong(liveEventId.substring(16), 16)
);
return this.findById(liveEventUUID);
return captureSessionRepository
.findByIdAndDeletedAtIsNull(liveEventUUID)
.map(cs -> new CaptureSessionDTO(cs, rtmpsSuffixEnabled))
.orElseThrow(() -> new NotFoundException("CaptureSession: " + liveEventUUID));
} catch (Exception e) {
throw (NotFoundException) new NotFoundException("CaptureSession: " + liveEventId).initCause(e);
throw new NotFoundException("CaptureSession: " + liveEventId, e);
}
}

Expand All @@ -99,7 +107,7 @@ public CaptureSessionDTO findByLiveEventId(String liveEventId) {
public CaptureSessionDTO findById(UUID id) {
return captureSessionRepository
.findByIdAndDeletedAtIsNull(id)
.map(CaptureSessionDTO::new)
.map(cs -> new CaptureSessionDTO(cs, rtmpsSuffixEnabled))
.orElseThrow(() -> new NotFoundException("CaptureSession: " + id));
}

Expand Down Expand Up @@ -135,7 +143,7 @@ public Page<CaptureSessionDTO> searchBy(
enableMigratedData || auth.hasRole("ROLE_SUPER_USER"),
pageable
)
.map(CaptureSessionDTO::new);
.map(cs -> new CaptureSessionDTO(cs, rtmpsSuffixEnabled));
}

@Transactional
Expand Down Expand Up @@ -284,7 +292,7 @@ public CaptureSessionDTO startCaptureSession(UUID id, RecordingStatus status, St
captureSession.setIngestAddress(ingestAddress);

captureSessionRepository.save(captureSession);
return new CaptureSessionDTO(captureSession);
return new CaptureSessionDTO(captureSession, rtmpsSuffixEnabled);
}

@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = Exception.class)
Expand Down Expand Up @@ -329,7 +337,7 @@ public CaptureSessionDTO stopCaptureSession(UUID captureSessionId,
}
}
captureSessionRepository.saveAndFlush(captureSession);
return new CaptureSessionDTO(captureSession);
return new CaptureSessionDTO(captureSession, rtmpsSuffixEnabled);
}

@Transactional
Expand All @@ -344,13 +352,13 @@ public CaptureSessionDTO setCaptureSessionStatus(UUID captureSessionId, Recordin
telemetry.trackEvent(properties.toString());

captureSessionRepository.save(captureSession);
return new CaptureSessionDTO(captureSession);
return new CaptureSessionDTO(captureSession, rtmpsSuffixEnabled);
}

@Transactional
public List<CaptureSessionDTO> findAllPastIncompleteCaptureSessions() {
return captureSessionRepository.findAllPastIncompleteCaptureSessions(Timestamp.from(Instant.now())).stream()
.map(CaptureSessionDTO::new)
.map(cs -> new CaptureSessionDTO(cs, rtmpsSuffixEnabled))
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class RecordingService {
@Setter
private boolean enableMigratedData;

private final boolean rtmpsSuffixEnabled;

@Setter
private boolean hideReencodedRecordings;

Expand All @@ -64,13 +66,16 @@ public RecordingService(RecordingRepository recordingRepository,
@Lazy CaptureSessionService captureSessionService,
AzureFinalStorageService azureFinalStorageService,
@Value("${migration.enableMigratedData:false}") boolean enableMigratedData,
@Value("${mediakind.rtmpsSuffixEnabled:false}")
boolean rtmpsSuffixEnabled,
@Value("${feature-flags.hide-reencoded-recordings:true}")
boolean hideReencodedRecordings) {
this.recordingRepository = recordingRepository;
this.captureSessionRepository = captureSessionRepository;
this.captureSessionService = captureSessionService;
this.azureFinalStorageService = azureFinalStorageService;
this.enableMigratedData = enableMigratedData;
this.rtmpsSuffixEnabled = rtmpsSuffixEnabled;
this.hideReencodedRecordings = hideReencodedRecordings;
}

Expand All @@ -79,7 +84,7 @@ public RecordingService(RecordingRepository recordingRepository,
public RecordingDTO findById(UUID recordingId) {
boolean includeReencodedRecordings = canViewReencodedRecordings();
return recordingRepository.findByIdAndDeletedAtIsNull(recordingId, includeReencodedRecordings)
.map(recording -> new RecordingDTO(recording, includeReencodedRecordings))
.map(recording -> new RecordingDTO(recording, includeReencodedRecordings, rtmpsSuffixEnabled))
.orElseThrow(() -> new NotFoundException("RecordingDTO: " + recordingId));
}

Expand Down Expand Up @@ -125,7 +130,7 @@ public Page<RecordingDTO> findAll(
includeReencodedRecordings,
pageable
)
.map(recording -> new RecordingDTO(recording, includeReencodedRecordings));
.map(recording -> new RecordingDTO(recording, includeReencodedRecordings, rtmpsSuffixEnabled));
}

@Transactional
Expand Down Expand Up @@ -294,7 +299,7 @@ public void syncRecordingMetadataWithStorage(UUID recordingId) {
public List<RecordingDTO> findAllDurationNull() {
return recordingRepository.findAllByDurationIsNullAndDeletedAtIsNull()
.stream()
.map(RecordingDTO::new)
.map(r -> new RecordingDTO(r, true, true))
.toList();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ mediakind:
liveStreamingEndpoint: ${MEDIA_KIND_LIVE_STREAMING_ENDPOINT:default-live}
location: ${MEDIA_KIND_LOCATION:uksouth-4}
streaming-endpoint-advanced-settings-name: ${MEDIA_KIND_STREAMING_ENDPOINT_ADVANCED_SETTINGS_NAME:}
rtmpsSuffixEnabled: ${RTMPS_SUFFIX_ENABLED:false}

media-service: ${MEDIA_SERVICE:MediaKind}

Expand Down
Loading
Loading