Search in sources :

Example 11 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class RecordingConverter method startConversion.

@Override
public void startConversion(Long id) {
    Recording r = recordingDao.get(id);
    if (r == null) {
        log.warn("Conversion is NOT started. Recording with ID {} is not found", id);
        return;
    }
    try {
        log.debug("recording {}", r.getId());
        ProcessResultList logs = new ProcessResultList();
        List<File> waveFiles = new ArrayList<>();
        File streamFolder = getStreamFolder(r);
        RecordingMetaData screenMetaData = metaDataDao.getScreenByRecording(r.getId());
        if (screenMetaData == null) {
            throw new ConversionException("screenMetaData is Null recordingId " + r.getId());
        }
        if (screenMetaData.getStreamStatus() == Status.NONE) {
            printMetaInfo(screenMetaData, "StartConversion");
            throw new ConversionException("Stream has not been started, error in recording");
        }
        if (Strings.isEmpty(r.getHash())) {
            r.setHash(UUID.randomUUID().toString());
        }
        r.setStatus(Recording.Status.CONVERTING);
        r = recordingDao.update(r);
        screenMetaData = waitForTheStream(screenMetaData.getId());
        stripAudioFirstPass(r, logs, waveFiles, streamFolder);
        // Merge Wave to Full Length
        File wav = new File(streamFolder, screenMetaData.getStreamName() + "_FINAL_WAVE.wav");
        if (waveFiles.isEmpty()) {
            // create default Audio to merge it. strip to content length
            String oneSecWav = new File(getStreamsHibernateDir(), "one_second.wav").getCanonicalPath();
            // Calculate delta at beginning
            double duration = diffSeconds(r.getRecordEnd(), r.getRecordStart());
            String[] cmd = new String[] { getPathToSoX(), oneSecWav, wav.getCanonicalPath(), "pad", "0", String.valueOf(duration) };
            logs.add(ProcessHelper.executeScript("generateSampleAudio", cmd));
        } else if (waveFiles.size() == 1) {
            wav = waveFiles.get(0);
        } else {
            String[] soxArgs = mergeAudioToWaves(waveFiles, wav);
            logs.add(ProcessHelper.executeScript("mergeAudioToWaves", soxArgs));
        }
        screenMetaData.setFullWavAudioData(wav.getName());
        metaDataDao.update(screenMetaData);
        // Merge Audio with Video / Calculate resulting FLV
        String inputScreenFullFlv = new File(streamFolder, OmFileHelper.getName(screenMetaData.getStreamName(), EXTENSION_FLV)).getCanonicalPath();
        // ffmpeg -vcodec flv -qscale 9.5 -r 25 -ar 22050 -ab 32k -s 320x240
        // -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17_FINAL_WAVE.wav
        // -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17.flv
        // final1.flv
        int flvWidth = r.getWidth();
        int flvHeight = r.getHeight();
        log.debug("flvWidth -1- {}", flvWidth);
        log.debug("flvHeight -1- {}", flvHeight);
        flvWidth = (int) (16. * flvWidth / 16);
        flvHeight = (int) (16. * flvHeight / 16);
        log.debug("flvWidth -2- {}", flvWidth);
        log.debug("flvHeight -2- {}", flvHeight);
        r.setWidth(flvWidth);
        r.setHeight(flvHeight);
        String mp4path = convertToMp4(r, Arrays.asList("-itsoffset", formatMillis(diff(screenMetaData.getRecordStart(), r.getRecordStart())), "-i", inputScreenFullFlv, "-i", wav.getCanonicalPath()), logs);
        postProcess(r, mp4path, logs, waveFiles);
    } catch (Exception err) {
        log.error("[startConversion]", err);
        r.setStatus(Recording.Status.ERROR);
    }
    recordingDao.update(r);
}
Also used : RecordingMetaData(org.apache.openmeetings.db.entity.record.RecordingMetaData) ArrayList(java.util.ArrayList) Recording(org.apache.openmeetings.db.entity.record.Recording) File(java.io.File) ProcessResultList(org.apache.openmeetings.util.process.ProcessResultList)

Example 12 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class TestSubjTemplate method testTemplateGeneration.

@Test
public void testTemplateGeneration() {
    Appointment a = getAppointment();
    String[] ids = TimeZone.getAvailableIDs();
    Recording rec = new Recording();
    rec.setRoomId(5L);
    for (User u : userDao.get(0, 100)) {
        TimeZone tz = TimeZone.getTimeZone(ids[rnd.nextInt(ids.length)]);
        checkTemplate(CreatedAppointmentTemplate.get(u, a, tz, u.getLogin()));
        checkTemplate(CanceledAppointmentTemplate.get(u, a, tz, u.getLogin()));
        checkTemplate(UpdatedAppointmentTemplate.get(u, a, tz, u.getLogin()));
        checkTemplate(AppointmentReminderTemplate.get(u, a, tz));
        checkTemplate(RecordingExpiringTemplate.get(u, rec, 1L));
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) TimeZone(java.util.TimeZone) User(org.apache.openmeetings.db.entity.user.User) Recording(org.apache.openmeetings.db.entity.record.Recording) Test(org.junit.Test)

Example 13 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class RecordingResourceReference method getRecording.

private Recording getRecording(Long id, String ruid, String uid) {
    log.debug("Recording with id {} is requested", id);
    Recording r = recDao.get(id);
    if (r == null || r.getType() == Type.Folder || r.isDeleted()) {
        return null;
    }
    if (id.equals(getRecordingId())) {
        return r;
    }
    Client c = cm.get(uid);
    if (c != null && c.getRoom() != null) {
        Whiteboards wbs = wbm.get(c.getRoom().getId());
        if (wbs != null && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) {
            for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) {
                if (e.getValue().contains(r.getHash())) {
                    // item IS on WB
                    return r;
                }
            }
        }
    }
    if (r.getOwnerId() == null && r.getGroupId() == null) {
        // public
        return r;
    }
    if (r.getOwnerId() != null && getUserId().equals(r.getOwnerId())) {
        // own
        return r;
    }
    if (r.getGroupId() != null && groupUserDao.isUserInGroup(r.getGroupId(), getUserId())) {
        return r;
    }
    // external group check was added for plugin recording download
    String extType = getExternalType();
    if (extType != null) {
        User creator = userDao.get(r.getInsertedBy());
        if (extType.equals(creator.getExternalType())) {
            return r;
        }
    }
    return null;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) Recording(org.apache.openmeetings.db.entity.record.Recording) Client(org.apache.openmeetings.db.entity.basic.Client) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 14 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class RecordingStatusConverter method read.

@Override
public Recording.Status read(InputNode node) throws Exception {
    Recording.Status result = null;
    String val = node.getValue();
    try {
        result = Recording.Status.valueOf(val);
    } catch (Exception e) {
        log.warn("Failed to read recording status out of {}", val);
        result = PROCESSING.equals(val) ? Status.CONVERTING : Status.NONE;
    }
    return result;
}
Also used : Recording(org.apache.openmeetings.db.entity.record.Recording) Status(org.apache.openmeetings.db.entity.record.Recording.Status)

Example 15 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class BackupImport method importRecordings.

/*
	 * ##################### Import Recordings
	 */
private void importRecordings(File f) throws Exception {
    log.info("Meeting members import complete, starting recordings server import");
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    RegistryMatcher matcher = new RegistryMatcher();
    Serializer ser = new Persister(strategy, matcher);
    matcher.bind(Long.class, LongTransform.class);
    matcher.bind(Integer.class, IntegerTransform.class);
    registry.bind(Date.class, DateConverter.class);
    registry.bind(Recording.Status.class, RecordingStatusConverter.class);
    List<Recording> list = readList(ser, f, "flvRecordings.xml", "flvrecordings", Recording.class);
    for (Recording r : list) {
        Long recId = r.getId();
        r.setId(null);
        if (r.getRoomId() != null) {
            r.setRoomId(roomMap.get(r.getRoomId()));
        }
        if (r.getOwnerId() != null) {
            r.setOwnerId(userMap.get(r.getOwnerId()));
        }
        if (r.getMetaData() != null) {
            for (RecordingMetaData meta : r.getMetaData()) {
                meta.setId(null);
                meta.setRecording(r);
            }
        }
        if (!Strings.isEmpty(r.getHash()) && r.getHash().startsWith(RECORDING_FILE_NAME)) {
            String name = getFileName(r.getHash());
            r.setHash(UUID.randomUUID().toString());
            fileMap.put(String.format(FILE_NAME_FMT, name, EXTENSION_JPG), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_PNG));
            fileMap.put(String.format("%s.%s.%s", name, EXTENSION_FLV, EXTENSION_MP4), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_MP4));
        }
        if (Strings.isEmpty(r.getHash())) {
            r.setHash(UUID.randomUUID().toString());
        }
        r = recordingDao.update(r);
        fileItemMap.put(recId, r.getId());
    }
}
Also used : RecordingMetaData(org.apache.openmeetings.db.entity.record.RecordingMetaData) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Recording(org.apache.openmeetings.db.entity.record.Recording) Serializer(org.simpleframework.xml.Serializer)

Aggregations

Recording (org.apache.openmeetings.db.entity.record.Recording)19 ArrayList (java.util.ArrayList)4 RecordingMetaData (org.apache.openmeetings.db.entity.record.RecordingMetaData)4 User (org.apache.openmeetings.db.entity.user.User)4 File (java.io.File)3 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)3 FileItem (org.apache.openmeetings.db.entity.file.FileItem)3 Room (org.apache.openmeetings.db.entity.room.Room)3 OmFileHelper.getRecordingMetaData (org.apache.openmeetings.util.OmFileHelper.getRecordingMetaData)2 ProcessResultList (org.apache.openmeetings.util.process.ProcessResultList)2 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)2 Test (org.junit.Test)2 Serializer (org.simpleframework.xml.Serializer)2 Registry (org.simpleframework.xml.convert.Registry)2 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)2 Persister (org.simpleframework.xml.core.Persister)2 Strategy (org.simpleframework.xml.strategy.Strategy)2 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1