View Javadoc
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  
23  package org.opencastproject.metadata.mpeg7;
24  
25  import org.opencastproject.mediapackage.XmlElement;
26  
27  import java.util.Iterator;
28  
29  /**
30   * A video segment represents a temporal decomposition of the video stream that may have properties like text
31   * annotations attached to it.
32   *
33   * <pre>
34   * &lt;complexType name="SegmentType" abstract="true"&gt;
35   *   &lt;complexContent&gt;
36   *       &lt;extension base="mpeg7:DSType"&gt;
37   *           &lt;sequence&gt;
38   *               &lt;choice minOccurs="0"&gt;
39   *                   &lt;element name="MediaInformation" type="mpeg7:MediaInformationType"/&gt;
40   *                   &lt;element name="MediaInformationRef" type="mpeg7:ReferenceType"/&gt;
41   *                   &lt;element name="MediaLocator" type="mpeg7:MediaLocatorType"/&gt;
42   *               &lt;/choice&gt;
43   *               &lt;element name="StructuralUnit" type="mpeg7:ControlledTermUseType" minOccurs="0"/&gt;
44   *               &lt;choice minOccurs="0"&gt;
45   *                   &lt;element name="CreationInformation" type="mpeg7:CreationInformationType"/&gt;
46   *                   &lt;element name="CreationInformationRef" type="mpeg7:ReferenceType"/&gt;
47   *               &lt;/choice&gt;
48   *               &lt;choice minOccurs="0"&gt;
49   *                   &lt;element name="UsageInformation" type="mpeg7:UsageInformationType"/&gt;
50   *                   &lt;element name="UsageInformationRef" type="mpeg7:ReferenceType"/&gt;
51   *               &lt;/choice&gt;
52   *               &lt;element name="TextAnnotation" minOccurs="0" maxOccurs="unbounded"&gt;
53   *                   &lt;complexType&gt;
54   *                       &lt;complexContent&gt;
55   *                           &lt;extension base="mpeg7:TextAnnotationType"&gt;
56   *                               &lt;attribute name="type" use="optional"&gt;
57   *                                   &lt;simpleType&gt;
58   *                                       &lt;union memberTypes="mpeg7:termReferenceType string"/&gt;
59   *                                   &lt;/simpleType&gt;
60   *                               &lt;/attribute&gt;
61   *                           &lt;/extension&gt;
62   *                       &lt;/complexContent&gt;
63   *                   &lt;/complexType&gt;
64   *               &lt;/element&gt;
65   *               &lt;choice minOccurs="0" maxOccurs="unbounded"&gt;
66   *                   &lt;element name="Semantic" type="mpeg7:SemanticType"/&gt;
67   *                   &lt;element name="SemanticRef" type="mpeg7:ReferenceType"/&gt;
68   *               &lt;/choice&gt;
69   *               &lt;element name="MatchingHint" type="mpeg7:MatchingHintType" minOccurs="0" maxOccurs="unbounded"/&gt;
70   *               &lt;element name="PointOfView" type="mpeg7:PointOfViewType" minOccurs="0" maxOccurs="unbounded"/&gt;
71   *               &lt;element name="Relation" type="mpeg7:RelationType" minOccurs="0" maxOccurs="unbounded"/&gt;
72   *           &lt;/sequence&gt;
73   *       &lt;/extension&gt;
74   *   &lt;/complexContent&gt;
75   * &lt;/complexType&gt;
76   * </pre>
77   */
78  public interface Segment extends XmlElement {
79  
80    /** The segment type */
81    enum Type {
82      AudioSegment, VideoSegment, AudioVisualSegment
83    };
84  
85    /**
86     * Returns the segment identifier.
87     *
88     * @return the identifier
89     */
90    String getIdentifier();
91  
92    /**
93     * Sets the segment's media time constraints.
94     *
95     * @param mediaTime
96     *          the media time
97     */
98    void setMediaTime(MediaTime mediaTime);
99  
100   /**
101    * Returns the segment's time constraints.
102    *
103    * @return the media time
104    */
105   MediaTime getMediaTime();
106 
107   /**
108    * Returns <code>true</code> if the segment contains any text annotations.
109    *
110    * @return <code>true</code> if there are text annotations
111    */
112   boolean hasTextAnnotations();
113 
114   /**
115    * Returns the number of text annotations. Note that text annotations are containers themselves, containing a number
116    * of keywords and free text entries.
117    *
118    * @return the number of text annotations
119    */
120   int getTextAnnotationCount();
121 
122   /**
123    * Returns <code>true</code> if the segment contains text annotations in the specified language.
124    *
125    * @return <code>true</code> if there are text annotations
126    */
127   boolean hasTextAnnotations(String language);
128 
129   /**
130    * Returns <code>true</code> if the segment contains text annotations that satisfy the given relevance and confidence
131    * values.
132    *
133    * @return <code>true</code> if there are text annotations
134    */
135   boolean hasTextAnnotations(float relevance, float confidence);
136 
137   /**
138    * Returns <code>true</code> if the segment contains text annotations that satisfy the given relevance, confidence and
139    * language constraints.
140    *
141    * @return <code>true</code> if there are text annotations
142    */
143   boolean hasTextAnnotations(float relevance, float confidence, String language);
144 
145   /**
146    * Creates a new text annotation that will hold keywords and free text comments.
147    *
148    * @param relevance
149    *          the relevance value
150    * @param confidence
151    *          the confidence
152    * @param language
153    *          the language identifier
154    * @return the new text annotation
155    */
156   TextAnnotation createTextAnnotation(float relevance, float confidence, String language);
157 
158   /**
159    * Returns this segment's text annotations.
160    *
161    * @return the text annotations
162    */
163   Iterator<TextAnnotation> textAnnotations();
164 
165   /**
166    * Returns this segment's text annotations, sorted by relevance.
167    *
168    * @return the text annotations
169    */
170   Iterator<TextAnnotation> textAnnotationsByRelevance();
171 
172   /**
173    * Returns this segment's text annotations, sorted by relevance.
174    *
175    * @return the text annotations
176    */
177   Iterator<TextAnnotation> textAnnotationsByConfidence();
178 
179 }