001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.documentlibrary.util;
016    
017    import com.liferay.portal.kernel.repository.model.FileVersion;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    
020    import java.io.InputStream;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Sergio González
026     */
027    public class VideoProcessorUtil {
028    
029            public static void generateVideo(FileVersion fileVersion) throws Exception {
030                    getVideoProcessor().generateVideo(fileVersion);
031            }
032    
033            public static InputStream getPreviewAsStream(
034                            FileVersion fileVersion, String type)
035                    throws Exception {
036    
037                    return getVideoProcessor().getPreviewAsStream(fileVersion, type);
038            }
039    
040            public static long getPreviewFileSize(FileVersion fileVersion, String type)
041                    throws Exception {
042    
043                    return getVideoProcessor().getPreviewFileSize(fileVersion, type);
044            }
045    
046            public static InputStream getThumbnailAsStream(
047                            FileVersion fileVersion, int index)
048                    throws Exception {
049    
050                    return getVideoProcessor().getThumbnailAsStream(fileVersion, index);
051            }
052    
053            public static long getThumbnailFileSize(FileVersion fileVersion, int index)
054                    throws Exception {
055    
056                    return getVideoProcessor().getThumbnailFileSize(fileVersion, index);
057            }
058    
059            public static Set<String> getVideoMimeTypes() {
060                    return getVideoProcessor().getVideoMimeTypes();
061            }
062    
063            public static VideoProcessor getVideoProcessor() {
064                    PortalRuntimePermission.checkGetBeanProperty(VideoProcessorUtil.class);
065    
066                    return _videoProcessor;
067            }
068    
069            public static boolean hasVideo(FileVersion fileVersion) {
070                    return getVideoProcessor().hasVideo(fileVersion);
071            }
072    
073            public static boolean isSupported(String mimeType) {
074                    return getVideoProcessor().isSupported(mimeType);
075            }
076    
077            public static boolean isVideoSupported(FileVersion fileVersion) {
078                    return getVideoProcessor().isVideoSupported(fileVersion);
079            }
080    
081            public static boolean isVideoSupported(String mimeType) {
082                    return getVideoProcessor().isVideoSupported(mimeType);
083            }
084    
085            public static void trigger(FileVersion fileVersion) {
086                    getVideoProcessor().trigger(fileVersion);
087            }
088    
089            public void setVideoProcessor(VideoProcessor videoProcessor) {
090                    PortalRuntimePermission.checkSetBeanProperty(getClass());
091    
092                    _videoProcessor = videoProcessor;
093            }
094    
095            private static VideoProcessor _videoProcessor;
096    
097    }