1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.videoeditor.impl;
23
24 public class VideoClip {
25 private final int srcId;
26 private final long start;
27 private long end;
28 // if layout regions are supported, it will be resolved and stored here,
29 // defaults to root layout
30 private String region;
31
32 /**
33 * Video clip constructor.
34 *
35 * @param id Source identifier of the video clip
36 * @param start Start time in milliseconds
37 * @param end End time in milliseconds
38 */
39 public VideoClip(int id, long start, long end) {
40 this.srcId = id;
41 this.start = start;
42 this.end = end;
43 }
44
45 /**
46 * Update the video clip's end time.
47 *
48 * @param end New end time in milliseconds.
49 */
50 void setEnd(long end) {
51 this.end = end;
52 }
53
54 void setRegion(String region) { // Regions are relative to root-layout,
55 this.region = region;
56 }
57
58 public int getSrc() {
59 return srcId;
60 }
61
62 /**
63 * Get the video clip's start time in milliseconds.
64 *
65 * @return Start time in milliseconds.
66 */
67 public long getStartInMilliseconds() {
68 return start;
69 }
70
71 /**
72 * Get the video clip's start time in fractions of seconds.
73 *
74 * @return Start time in seconds.
75 */
76 public double getStartInSeconds() {
77 return start / 1000.0;
78 }
79
80 /**
81 * Get the video clip's end time in milliseconds.
82 *
83 * @return End time in milliseconds.
84 */
85 public long getEndInMilliseconds() {
86 return end;
87 }
88
89 /**
90 * Get the video clip's end time in fractions of seconds.
91 *
92 * @return End time in seconds.
93 */
94 public double getEndInSeconds() {
95 return end / 1000.0;
96 }
97
98 public String getRegion() {
99 return region;
100 }
101
102 /**
103 * Get the video clip's duration in milliseconds.
104 *
105 * @return Duration in milliseconds.
106 */
107 public long getDurationInMilliseconds() {
108 return end - start;
109 }
110
111 /**
112 * Get the video clip's duration in fractions of seconds.
113 *
114 * @return Duration in seconds.
115 */
116 public double getDurationInSeconds() {
117 return (end - start) / 1000.0;
118 }
119
120 }