Java Code Examples for org.red5.server.api.IConnection#getStringAttribute()
The following examples show how to use
org.red5.server.api.IConnection#getStringAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Application.java From red5-hls-plugin with Apache License 2.0 | 5 votes |
@Override public void appDisconnect(IConnection conn) { log.debug("appDisconnect"); // ensure that the recorded stream was completed or reject it here if (conn.hasAttribute("streamName")) { @SuppressWarnings("unused") String streamName = conn.getStringAttribute("streamName"); } super.appDisconnect(conn); }
Example 2
Source File: S3FilenameGenerator.java From red5-examples with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") public String generateFilename(IScope scope, String name, String extension, GenerationType type) { logger.debug("Get stream directory: scope={}, name={}, type={}", new Object[]{scope, name, type.toString()}); StringBuilder path = new StringBuilder(); // get the session id IConnection conn = Red5.getConnectionLocal(); if (conn.hasAttribute("sessionId")) { String sessionId = conn.getStringAttribute("sessionId"); path.append(sessionId); path.append('/'); } // add resources name path.append(name); // add extension if we have one if (extension != null){ // add extension path.append(extension); } // determine whether its playback or record if (type.equals(GenerationType.PLAYBACK)) { logger.debug("Playback path used"); // look on s3 for the file first boolean found = false; try { S3Service s3Service = new RestS3Service(awsCredentials); S3Bucket bucket = s3Service.getBucket(bucketName); String objectKey = path.toString(); S3Object file = s3Service.getObject(bucket, objectKey); if (file != null) { S3Object details = s3Service.getObjectDetails(bucket, objectKey); logger.debug("Details - key: {} content type: {}", details.getKey(), details.getContentType()); path.insert(0, bucket.getLocation()); // set found flag found = true; } } catch (S3ServiceException e) { logger.warn("Error looking up media file", e); } // use local path if (!found) { logger.debug("File was not found on S3, using local playback location"); path.insert(0, playbackPath); } } else { logger.debug("Record path used"); path.insert(0, recordPath); } String fileName = path.toString(); logger.debug("Generated filename: {}", fileName); return fileName; }