1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.opencastproject.mediapackage.track;
23
24 import org.opencastproject.mediapackage.MediaPackageSerializer;
25 import org.opencastproject.mediapackage.SubtitleStream;
26
27 import org.apache.commons.lang3.StringUtils;
28 import org.w3c.dom.Document;
29 import org.w3c.dom.Element;
30 import org.w3c.dom.Node;
31
32 import java.util.UUID;
33
34 import javax.xml.bind.annotation.XmlAccessType;
35 import javax.xml.bind.annotation.XmlAccessorType;
36 import javax.xml.bind.annotation.XmlType;
37 import javax.xml.xpath.XPath;
38 import javax.xml.xpath.XPathConstants;
39 import javax.xml.xpath.XPathException;
40
41
42
43
44 @XmlAccessorType(XmlAccessType.NONE)
45 @XmlType(name = "subtitle", namespace = "http://mediapackage.opencastproject.org")
46 public class SubtitleStreamImpl extends AbstractStreamImpl implements SubtitleStream {
47 public SubtitleStreamImpl() {
48 this(UUID.randomUUID().toString());
49 }
50
51 public SubtitleStreamImpl(String identifier) {
52 super(identifier);
53 }
54
55
56
57
58
59
60
61
62 public static SubtitleStreamImpl fromManifest(String streamIdHint, Node node, XPath xpath)
63 throws IllegalStateException, XPathException {
64
65 String sid = (String) xpath.evaluate("@id", node, XPathConstants.STRING);
66 if (StringUtils.isEmpty(sid)) {
67 sid = streamIdHint;
68 }
69 SubtitleStreamImpl ss = new SubtitleStreamImpl(sid);
70 partialFromManifest(ss, node, xpath);
71
72 return ss;
73 }
74
75
76
77
78
79 @Override
80 public Node toManifest(Document document, MediaPackageSerializer serializer) {
81 Element node = document.createElement("subtitle");
82 addCommonManifestElements(node, document, serializer);
83 return node;
84 }
85 }