Search in sources :

Example 31 with VideoTranscoding

use of org.olat.modules.video.VideoTranscoding in project openolat by klemens.

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");
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) VideoTranscoding(org.olat.modules.video.VideoTranscoding) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 32 with VideoTranscoding

use of org.olat.modules.video.VideoTranscoding in project openolat by klemens.

the class VideoAdminErrorController method initTable.

private void initTable() {
    List<VideoTranscoding> videoTranscodings = videoManager.getFailedVideoTranscodings();
    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");
        FormLink retranscodeLink = uifactory.addFormLink("trans_" + counter++, "retranscode", "queue.retranscode", "queue.retranscode", flc, Link.LINK);
        retranscodeLink.setUserObject(videoTranscoding);
        retranscodeLink.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
        Object[] failureReason = new Object[] { -1, "" };
        if (videoTranscoding.getStatus() == VideoTranscoding.TRANSCODING_STATUS_INEFFICIENT) {
            failureReason[0] = VideoTranscoding.TRANSCODING_STATUS_INEFFICIENT;
            failureReason[1] = translate("transcoding.inefficient");
        } else if (videoTranscoding.getStatus() == VideoTranscoding.TRANSCODING_STATUS_ERROR) {
            failureReason[0] = VideoTranscoding.TRANSCODING_STATUS_ERROR;
            failureReason[1] = translate("transcoding.error");
        } else if (videoTranscoding.getStatus() == VideoTranscoding.TRANSCODING_STATUS_TIMEOUT) {
            failureReason[0] = VideoTranscoding.TRANSCODING_STATUS_TIMEOUT;
            failureReason[1] = translate("transcoding.timeout");
        }
        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();
        TranscodingQueueTableRow transcodingrow = new TranscodingQueueTableRow(resourceLink, displayname, creationDate, authorLink, title, null, videoTranscoding.getFormat(), deleteLink);
        transcodingrow.setFailureReason(failureReason);
        transcodingrow.setRetranscodeLink(retranscodeLink);
        rows.add(transcodingrow);
    }
    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");
}
Also used : VideoTranscoding(org.olat.modules.video.VideoTranscoding) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Date(java.util.Date)

Example 33 with VideoTranscoding

use of org.olat.modules.video.VideoTranscoding in project openolat by klemens.

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();
}
Also used : VideoTranscoding(org.olat.modules.video.VideoTranscoding) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 34 with VideoTranscoding

use of org.olat.modules.video.VideoTranscoding in project openolat by klemens.

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));
}
Also used : VideoTranscoding(org.olat.modules.video.VideoTranscoding) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Aggregations

VideoTranscoding (org.olat.modules.video.VideoTranscoding)34 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 OLATResource (org.olat.resource.OLATResource)8 Test (org.junit.Test)6 VideoMeta (org.olat.modules.video.VideoMeta)6 HashMap (java.util.HashMap)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VideoMediaMapper (org.olat.modules.video.manager.VideoMediaMapper)4 VideoTranscodingImpl (org.olat.modules.video.model.VideoTranscodingImpl)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Size (org.olat.core.commons.services.image.Size)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 VideoManager (org.olat.modules.video.VideoManager)2 VideoModule (org.olat.modules.video.VideoModule)2 SchedulerException (org.quartz.SchedulerException)2