001/*
002 * (C) Copyright 2006-2011 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 */
019
020package org.nuxeo.ecm.platform.video;
021
022import java.util.List;
023
024import org.nuxeo.ecm.core.api.Blob;
025
026/**
027 * Object wrapping a video {@code Blob} and related {@link VideoInfo}.
028 *
029 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
030 * @since 5.5
031 */
032public class Video {
033
034    protected final VideoInfo videoInfo;
035
036    protected final Blob blob;
037
038    /**
039     * Build a {@code Video} from a video {@code blob} and the related {@code videoInfo}.
040     */
041    public static Video fromBlobAndInfo(Blob blob, VideoInfo videoInfo) {
042        return new Video(blob, videoInfo);
043    }
044
045    protected Video(Blob blob, VideoInfo videoInfo) {
046        this.blob = blob;
047        this.videoInfo = videoInfo;
048    }
049
050    /**
051     * Returns the {@link VideoInfo} for this {@code Video}.
052     */
053    public VideoInfo getVideoInfo() {
054        return videoInfo;
055    }
056
057    /**
058     * Returns the duration of this {@code Video}.
059     */
060    public double getDuration() {
061        return videoInfo.getDuration();
062    }
063
064    /**
065     * Returns the width of this {@code Video}.
066     */
067    public long getWidth() {
068        return videoInfo.getWidth();
069    }
070
071    /**
072     * Returns the height of this {@code Video}.
073     */
074    public long getHeight() {
075        return videoInfo.getHeight();
076    }
077
078    /**
079     * Returns the format of this {@code Video}.
080     */
081    public String getFormat() {
082        return videoInfo.getFormat();
083    }
084
085    /**
086     * Returns the frame rate of this {@code Video}.
087     */
088    public double getFrameRate() {
089        return videoInfo.getFrameRate();
090    }
091
092    /**
093     * Returns all the {@link Stream}s of this {@code Video}.
094     */
095    public List<Stream> getStreams() {
096        return videoInfo.getStreams();
097    }
098
099    /**
100     * Returns the video {@code Blob}.
101     */
102    public Blob getBlob() {
103        return blob;
104    }
105
106}