use of org.opencastproject.liveschedule.api.LiveScheduleException in project opencast by opencast.
the class LiveScheduleServiceImpl method addLiveTracks.
void addLiveTracks(MediaPackage mp, String caName) throws LiveScheduleException {
String mpId = mp.getIdentifier().compact();
try {
// capture.device.live.resolution.WIDTHxHEIGHT=COMPLETE_STREAMING_URL, use them!
try {
Properties caProps = captureAgentService.getAgentCapabilities(caName);
if (caProps != null) {
Enumeration<Object> en = caProps.keys();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
if (key.startsWith(CA_PROPERTY_RESOLUTION_URL_PREFIX)) {
String resolution = key.substring(CA_PROPERTY_RESOLUTION_URL_PREFIX.length());
String url = caProps.getProperty(key);
// Note: only one flavor is supported in this format (the default: presenter/delivery)
MediaPackageElementFlavor flavor = MediaPackageElementFlavor.parseFlavor(DEFAULT_LIVE_TARGET_FLAVORS);
String replacedUrl = replaceVariables(mpId, caName, url, flavor, resolution);
mp.add(buildStreamingTrack(replacedUrl, flavor, streamMimeType, resolution, mp.getDuration()));
}
}
}
} catch (NotFoundException e) {
// Capture agent not found so we can't get its properties. Assume the service configuration should
// be used instead. Note that we can't schedule anything on a CA that has not registered so this is
// unlikely to happen.
}
// so use the service configuration, including stream overrides (temporary)
if (liveStreamingUrl == null)
throw new LiveScheduleException("Cannot build live tracks because '" + LIVE_STREAMING_URL + "' configuration was not set.");
if (mp.getTracks().length == 0) {
for (MediaPackageElementFlavor flavor : liveFlavors) {
for (int i = 0; i < streamResolution.length; i++) {
String uri = replaceVariables(mpId, caName, UrlSupport.concat(liveStreamingUrl.toString(), streamName), flavor, streamResolution[i]);
mp.add(buildStreamingTrack(uri, flavor, streamMimeType, streamResolution[i], mp.getDuration()));
}
}
}
} catch (URISyntaxException e) {
throw new LiveScheduleException(e);
}
}
Aggregations