use of org.olat.modules.video.VideoTranscoding in project OpenOLAT by OpenOLAT.
the class VideoTranscodingDAOTest method createVideoTranscoding.
@Test
public void createVideoTranscoding() {
OLATResource resource = JunitTestHelper.createRandomResource();
// pending transcoding
VideoTranscoding vTranscoding = videoTranscodingDao.createVideoTranscoding(resource, 1080, "mp4");
Assert.assertNotNull(vTranscoding);
dbInstance.commitAndCloseSession();
// done transcoding
VideoTranscoding vTranscoding2 = videoTranscodingDao.createVideoTranscoding(resource, 720, "mp4");
Assert.assertNotNull(vTranscoding2);
vTranscoding2.setStatus(VideoTranscoding.TRANSCODING_STATUS_DONE);
vTranscoding2.setTranscoder(VideoTranscoding.TRANSCODER_LOCAL);
vTranscoding2 = videoTranscodingDao.updateTranscoding(vTranscoding2);
Assert.assertNotNull(vTranscoding2);
Assert.assertTrue(vTranscoding2.getStatus() == 100);
dbInstance.commitAndCloseSession();
// check for transcodings of resource
List<VideoTranscoding> vTranscodingList = videoTranscodingDao.getVideoTranscodings(resource);
Assert.assertNotNull(vTranscodingList);
Assert.assertEquals(2, vTranscodingList.size());
Assert.assertEquals(vTranscoding, vTranscodingList.get(0));
Assert.assertEquals(vTranscoding2, vTranscodingList.get(1));
// check for overall pending transcodings
List<VideoTranscoding> vTranscodingList2 = videoTranscodingDao.getVideoTranscodingsPendingAndInProgress();
Assert.assertNotNull(vTranscodingList2);
Assert.assertTrue(vTranscodingList2.size() >= 1);
Assert.assertTrue(vTranscodingList2.contains(vTranscoding));
}
use of org.olat.modules.video.VideoTranscoding in project OpenOLAT by OpenOLAT.
the class VideoAdminListController method initTable.
private void initTable() {
List<VideoTranscoding> videoTranscodings = videoManager.getVideoTranscodingsPendingAndInProgress();
List<TranscodingQueueTableRow> rows = new ArrayList<>();
for (VideoTranscoding videoTranscoding : videoTranscodings) {
String title = videoManager.getDisplayTitleForResolution(videoTranscoding.getResolution(), getTranslator());
String resid = String.valueOf(videoTranscoding.getVideoResource().getResourceableId());
FormLink resourceLink = uifactory.addFormLink("res_" + counter++, "viewResource", resid, resid, flc, Link.LINK + Link.NONTRANSLATED);
resourceLink.setUserObject(videoTranscoding);
FormLink deleteLink = uifactory.addFormLink("del_" + counter++, "deleteQuality", "quality.delete", "quality.delete", flc, Link.LINK);
deleteLink.setUserObject(videoTranscoding);
deleteLink.setIconLeftCSS("o_icon o_icon_delete_item o_icon-fw");
String fileSize = "";
if (videoTranscoding.getSize() != 0) {
fileSize = Formatter.formatBytes(videoTranscoding.getSize());
} else if (videoTranscoding.getStatus() == VideoTranscoding.TRANSCODING_STATUS_WAITING) {
fileSize = translate("transcoding.waiting");
} else if (videoTranscoding.getStatus() <= VideoTranscoding.TRANSCODING_STATUS_DONE) {
fileSize = translate("transcoding.processing") + ": " + videoTranscoding.getStatus() + "%";
}
RepositoryEntry videoRe = repositoryService.loadByResourceKey(videoTranscoding.getVideoResource().getKey());
if (videoRe == null)
continue;
String displayname = videoRe.getDisplayname();
String initialAuthor = videoRe.getInitialAuthor();
String fullName = userManager.getUserDisplayName(initialAuthor);
FormLink authorLink = uifactory.addFormLink("author_" + counter++, "viewAuthor", fullName, fullName, flc, Link.LINK + Link.NONTRANSLATED);
authorLink.setUserObject(initialAuthor);
Date creationDate = videoTranscoding.getCreationDate();
rows.add(new TranscodingQueueTableRow(resourceLink, displayname, creationDate, authorLink, title, fileSize, videoTranscoding.getFormat(), deleteLink));
}
tableModel.setObjects(rows);
if (flc.hasFormComponent(tableEl)) {
flc.remove(tableEl);
}
if (flc.hasFormComponent(refreshButton)) {
flc.remove(refreshButton);
}
tableEl = uifactory.addTableElement(getWindowControl(), "queue", tableModel, getTranslator(), flc);
tableEl.setCustomizeColumns(false);
tableEl.setNumOfRowsEnabled(false);
refreshButton = uifactory.addFormLink("button.refresh", flc, Link.BUTTON);
refreshButton.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
}
use of org.olat.modules.video.VideoTranscoding in project OpenOLAT by OpenOLAT.
the class VideoAdminListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink && ((FormLink) source).getCmd().equals("deleteQuality")) {
FormLink link = (FormLink) source;
VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
videoManager.deleteVideoTranscoding(videoTranscoding);
} else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewAuthor")) {
showUserInfo(ureq, baseSecurity.findIdentityByName((String) source.getUserObject()));
} else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewResource")) {
FormLink link = (FormLink) source;
VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
launch(ureq, videoTranscoding);
}
initTable();
}
use of org.olat.modules.video.VideoTranscoding in project OpenOLAT by OpenOLAT.
the class VideoAdminTranscodingController method queueCreateTranscoding.
// state orders for inexistent transcodings
private void queueCreateTranscoding(TranscodingRow source) {
List<VideoTranscoding> allVideoTranscodings = videoManager.getOneVideoResolution(source.getResolution());
Map<OLATResource, Set<Integer>> availableTranscodings = new HashMap<>();
for (VideoTranscoding videoTranscoding : allVideoTranscodings) {
if (availableTranscodings.containsKey(videoTranscoding.getVideoResource())) {
availableTranscodings.get(videoTranscoding.getVideoResource()).add(videoTranscoding.getResolution());
} else {
Set<Integer> availableresolutions = new HashSet<>();
availableresolutions.add(videoTranscoding.getResolution());
availableTranscodings.put(videoTranscoding.getVideoResource(), availableresolutions);
}
}
for (OLATResource videoResource : nativeResolutions.keySet()) {
if (availableTranscodings.get(videoResource) == null || !availableTranscodings.get(videoResource).contains(source.getResolution())) {
if (nativeResolutions.get(videoResource) >= source.getResolution()) {
videoManager.createTranscoding(videoResource, source.getResolution(), "mp4");
}
}
}
}
use of org.olat.modules.video.VideoTranscoding in project OpenOLAT by OpenOLAT.
the class VideoQualityTableFormController method initTable.
private void initTable() {
List<QualityTableRow> rows = new ArrayList<>();
VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
// Add master video file
FormLink previewMasterLink = uifactory.addFormLink("view", "viewQuality", "quality.master", "quality.master", flc, Link.LINK);
Object[] statusMaster = new Object[] { 100, Formatter.formatBytes(videoManager.getVideoFile(videoResource).length()) };
rows.add(new QualityTableRow(previewMasterLink, videoMetadata.getWidth() + "x" + videoMetadata.getHeight(), statusMaster, "mp4", null));
// Add all the transcoded versions
List<VideoTranscoding> videoTranscodings = videoManager.getVideoTranscodings(videoResource);
for (VideoTranscoding videoTranscoding : videoTranscodings) {
String title = videoManager.getDisplayTitleForResolution(videoTranscoding.getResolution(), getTranslator());
FormLink previewVersionLink = uifactory.addFormLink("res_" + count++, "viewQuality", title, title, flc, Link.LINK + Link.NONTRANSLATED);
FormLink deleteLink = uifactory.addFormLink("del_" + count++, "deleteQuality", "quality.delete", "quality.delete", flc, Link.LINK);
deleteLink.setUserObject(videoTranscoding);
deleteLink.setIconLeftCSS("o_icon o_icon_delete_item o_icon-fw");
previewVersionLink.setUserObject(videoTranscoding);
if (videoTranscoding.getStatus() < VideoTranscoding.TRANSCODING_STATUS_DONE) {
previewVersionLink.setEnabled(false);
}
int width = videoTranscoding.getWidth();
int height = videoTranscoding.getHeight();
String dimension = width + "x" + height;
String fileSize = "";
int status = videoTranscoding.getStatus();
if (videoTranscoding.getSize() != 0 && status > -1) {
fileSize = Formatter.formatBytes(videoTranscoding.getSize());
} else if (status == VideoTranscoding.TRANSCODING_STATUS_WAITING) {
fileSize = translate("transcoding.waiting");
} else if (status <= VideoTranscoding.TRANSCODING_STATUS_DONE && status > -1) {
fileSize = translate("transcoding.processing") + ": " + videoTranscoding.getStatus() + "%";
} else if (status == VideoTranscoding.TRANSCODING_STATUS_INEFFICIENT) {
fileSize = translate("transcoding.inefficient");
} else if (status == VideoTranscoding.TRANSCODING_STATUS_ERROR) {
fileSize = translate("transcoding.error");
} else if (status == VideoTranscoding.TRANSCODING_STATUS_TIMEOUT) {
fileSize = translate("transcoding.timeout");
}
Object[] statusTranscoding = new Object[] { status, fileSize };
rows.add(new QualityTableRow(previewVersionLink, dimension, statusTranscoding, videoTranscoding.getFormat(), deleteLink));
}
List<Integer> missingResolutions = videoManager.getMissingTranscodings(videoResource);
if (videoModule.isTranscodingEnabled()) {
for (Integer missingRes : missingResolutions) {
if (missingRes <= videoMetadata.getHeight()) {
String title = videoManager.getDisplayTitleForResolution(missingRes, getTranslator());
FormLink transcodeLink = uifactory.addFormLink("res_" + count++, "startTranscoding", "quality.transcode", "quality.transcode", flc, Link.LINK);
transcodeLink.setUserObject(missingRes);
transcodeLink.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
FormLink previewMissingLink = uifactory.addFormLink("res_" + count++, "viewQuality", title, title, flc, Link.LINK + Link.NONTRANSLATED);
previewMissingLink.setEnabled(false);
Object[] status = new Object[] { -1, "-" };
rows.add(new QualityTableRow(previewMissingLink, missingRes.toString(), status, "mp4", transcodeLink));
}
}
}
rows.sort(new VideoComparator());
tableModel.setObjects(rows);
if (flc.hasFormComponent(tableEl)) {
flc.remove(tableEl);
}
if (flc.hasFormComponent(refreshbtn)) {
flc.remove(refreshbtn);
}
tableEl = uifactory.addTableElement(getWindowControl(), "qualityTable", tableModel, getTranslator(), flc);
tableEl.setCustomizeColumns(false);
tableEl.setNumOfRowsEnabled(false);
refreshbtn = uifactory.addFormLink("button.refresh", flc, Link.BUTTON);
refreshbtn.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
}
Aggregations