001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Thomas Roger <troger@nuxeo.com>
016 */
017
018package org.nuxeo.ecm.platform.video;
019
020import java.util.List;
021
022import org.nuxeo.ecm.core.api.Blob;
023
024/**
025 * Object wrapping a video {@code Blob} and related {@link VideoInfo}.
026 *
027 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
028 * @since 5.5
029 */
030public class Video {
031
032    protected final VideoInfo videoInfo;
033
034    protected final Blob blob;
035
036    /**
037     * Build a {@code Video} from a video {@code blob} and the related {@code videoInfo}.
038     */
039    public static Video fromBlobAndInfo(Blob blob, VideoInfo videoInfo) {
040        return new Video(blob, videoInfo);
041    }
042
043    protected Video(Blob blob, VideoInfo videoInfo) {
044        this.blob = blob;
045        this.videoInfo = videoInfo;
046    }
047
048    /**
049     * Returns the {@link VideoInfo} for this {@code Video}.
050     */
051    public VideoInfo getVideoInfo() {
052        return videoInfo;
053    }
054
055    /**
056     * Returns the duration of this {@code Video}.
057     */
058    public double getDuration() {
059        return videoInfo.getDuration();
060    }
061
062    /**
063     * Returns the width of this {@code Video}.
064     */
065    public long getWidth() {
066        return videoInfo.getWidth();
067    }
068
069    /**
070     * Returns the height of this {@code Video}.
071     */
072    public long getHeight() {
073        return videoInfo.getHeight();
074    }
075
076    /**
077     * Returns the format of this {@code Video}.
078     */
079    public String getFormat() {
080        return videoInfo.getFormat();
081    }
082
083    /**
084     * Returns the frame rate of this {@code Video}.
085     */
086    public double getFrameRate() {
087        return videoInfo.getFrameRate();
088    }
089
090    /**
091     * Returns all the {@link Stream}s of this {@code Video}.
092     */
093    public List<Stream> getStreams() {
094        return videoInfo.getStreams();
095    }
096
097    /**
098     * Returns the video {@code Blob}.
099     */
100    public Blob getBlob() {
101        return blob;
102    }
103
104}