001/*
002 * (C) Copyright 2006-2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Thomas Roger <troger@nuxeo.com>
018 */
019package org.nuxeo.ecm.platform.video.service;
020
021import java.util.Collection;
022
023import org.nuxeo.ecm.core.api.DocumentModel;
024import org.nuxeo.ecm.platform.video.TranscodedVideo;
025import org.nuxeo.ecm.platform.video.Video;
026import org.nuxeo.ecm.platform.video.VideoConversionStatus;
027
028/**
029 * Service to asynchronously launch and monitor video conversions.
030 * <p>
031 *
032 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
033 * @since 5.5
034 */
035public interface VideoService {
036
037    /**
038     * Returns the available registered video conversions that can be run on a Video document.
039     */
040    Collection<VideoConversion> getAvailableVideoConversions();
041
042    /**
043     * Launch an asynchronously video conversion of the given {@code doc}.
044     *
045     * @param doc the video document to be converted
046     * @param conversionName the video conversion to use
047     */
048    void launchConversion(DocumentModel doc, String conversionName);
049
050    /**
051     * Launch all the registered automatic video conversions on the given {@code doc}.
052     *
053     * @param doc the video document to be converted
054     */
055    default void launchAutomaticConversions(DocumentModel doc) {
056        launchAutomaticConversions(doc, false);
057    }
058
059    /**
060     * Launch registered automatic video conversions on the given {@code doc}.
061     * <p>
062     * If {@code onlyMissing} is {@code true}, launch only the automatic video conversions that are not on the video
063     * document, otherwise launch all the registered automatic video conversions
064     *
065     * @param doc the video document to be converted
066     * @param onlyMissing whether to launch only the missing video conversions
067     * @since 11.5
068     */
069    void launchAutomaticConversions(DocumentModel doc, boolean onlyMissing);
070
071    /**
072     * Convert the {@code originalVideo} using the given {@code conversionName}.
073     *
074     * @param originalVideo the video to convert
075     * @param conversionName the video conversion to use
076     * @return a {@code TranscodedVideo} object of the converted video.
077     */
078    TranscodedVideo convert(Video originalVideo, String conversionName);
079
080
081    /**
082     * Returns the status of the video conversion with the given conversion name on the given document.
083     *
084     * @since 5.7.3
085     */
086    VideoConversionStatus getProgressStatus(String repositoryName, String docId, String conversionName);
087
088    /**
089     * @since 7.2
090     */
091    VideoConversion getVideoConversion(String conversionName);
092
093    /**
094     * @since 7.4
095     */
096    Configuration getConfiguration();
097
098}