Search in sources :

Example 11 with LiveScheduleException

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);
    }
}
Also used : NotFoundException(org.opencastproject.util.NotFoundException) LiveScheduleException(org.opencastproject.liveschedule.api.LiveScheduleException) URISyntaxException(java.net.URISyntaxException) Properties(java.util.Properties) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor)

Aggregations

LiveScheduleException (org.opencastproject.liveschedule.api.LiveScheduleException)11 URISyntaxException (java.net.URISyntaxException)7 DistributionException (org.opencastproject.distribution.api.DistributionException)6 NotFoundException (org.opencastproject.util.NotFoundException)6 Job (org.opencastproject.job.api.Job)5 MediaPackage (org.opencastproject.mediapackage.MediaPackage)4 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)4 HashSet (java.util.HashSet)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Snapshot (org.opencastproject.assetmanager.api.Snapshot)2 List (java.util.List)1 Properties (java.util.Properties)1 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)1 ARecord (org.opencastproject.assetmanager.api.query.ARecord)1 AResult (org.opencastproject.assetmanager.api.query.AResult)1 Attachment (org.opencastproject.mediapackage.Attachment)1 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)1 Publication (org.opencastproject.mediapackage.Publication)1 Track (org.opencastproject.mediapackage.Track)1