1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opencastproject.composer.api;
22
23 import java.util.Comparator;
24
25
26
27
28
29
30
31
32
33
34 public class VideoClip implements Comparable<VideoClip>, Comparator<VideoClip> {
35 private final int srcId;
36 private final long start;
37 private long end;
38
39
40 public VideoClip(int indx, double start, double end) {
41 this.srcId = indx;
42 this.start = (long) (start * 1000);
43 this.end = (long) (end * 1000);
44 }
45
46 public VideoClip(int indx, long start, long end) {
47 this.srcId = indx;
48 this.start = start;
49 this.end = end;
50 }
51
52 public void setEnd(double newend) {
53 this.end = (long) (newend * 1000.0);
54 }
55
56 public void setEnd(long newend) {
57 this.end = newend;
58 }
59
60 public int getSrc() {
61 return srcId;
62 }
63
64 public double getStart() {
65 return start / 1000.0;
66 }
67
68 public double getEnd() {
69 return end / 1000.0;
70 }
71
72 public long getStartMS() {
73 return start;
74 }
75
76 public long getEndMS() {
77 return end;
78 }
79
80 public double getDuration() {
81 return (end - start) / 1000.0;
82 }
83
84 public long getDurationMS() {
85 return end - start;
86 }
87
88
89 @Override
90 public String toString() {
91 return "VideoClip [srcId=" + srcId + ", start=" + start + ", end=" + end + "]";
92 }
93
94
95 @Override
96 public int compareTo(VideoClip other) {
97 return (int) (start - other.getStartMS());
98 }
99
100 @Override
101 public int compare(VideoClip o1, VideoClip o2) {
102 return (int) (o1.getStartMS() - o2.getStartMS());
103 }
104
105 }