@Test public void testGetRTMPSource() throws URISyntaxException { URI noPathDelimiter = new URI("rtmp: String result = WowzaResourceStrategyImpl.getRTMPResource(noPathDelimiter); assertEquals("mp4:myvideo.mov", result); URI pathDelimiterNoExtension = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(pathDelimiterNoExtension); assertEquals("mp4:path/to/video/myvideo", result); URI pathDelimiterExtension = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(pathDelimiterExtension); assertEquals("mp4:path/to/video/myvideo.mov", result); URI pathDelimiterExtensionQueryString = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(pathDelimiterExtensionQueryString); assertEquals("mp4:path/to/video/myvideo.mov?param1=value1&param2=value2", result); URI noPathNoDelimiterFormat = new URI("rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(noPathNoDelimiterFormat); assertEquals("mp4:myvideo.mov", result); URI noPathNoDelimiterNoExtensionFormat = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(noPathNoDelimiterNoExtensionFormat); assertEquals("mp4:path/to/video/myvideo", result); URI pathNoDelimiterExtensionFormat = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(pathNoDelimiterExtensionFormat); assertEquals("mp4:path/to/video/myvideo.mov", result); URI pathNoDelimiterExtensionFormatQueryString = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(pathNoDelimiterExtensionFormatQueryString); assertEquals("mp4:path/to/video/myvideo.mov?param1=value1&param2=value2", result); URI flvWithExtension = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(flvWithExtension); assertEquals("flv:path/to/video/myvideo.flv?param1=value1&param2=value2", result); URI flvWithoutExtension = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(flvWithoutExtension); assertEquals("flv:path/to/video/myvideo?param1=value1&param2=value2", result); URI withoutFormat = new URI( "rtmp: result = WowzaResourceStrategyImpl.getRTMPResource(withoutFormat); assertEquals("path/to/video/myvideo.mp4?param1=value1&param2=value2", result); }
protected static String getRTMPResource(URI baseUri) { String stream = null; if (baseUri.toString().contains(WOWZA_STREAM_DELIMITER)) { stream = baseUri.toString().split(WOWZA_STREAM_DELIMITER)[1]; if (stream.charAt(0) == '/') { return stream.substring(1); } return stream; } else if (baseUri.getPath().contains(":")) { Pattern pattern = Pattern.compile(FIND_STREAM_FORMAT); Matcher matcher = pattern.matcher(baseUri.getPath()); if (matcher.find()) { return baseUri.getPath().substring(matcher.start()) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); } } return baseUri.getPath().substring(baseUri.getPath().indexOf("/", 1) + 1) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); }
WowzaResourceStrategyImpl implements ResourceStrategy { protected static String getRTMPResource(URI baseUri) { String stream = null; if (baseUri.toString().contains(WOWZA_STREAM_DELIMITER)) { stream = baseUri.toString().split(WOWZA_STREAM_DELIMITER)[1]; if (stream.charAt(0) == '/') { return stream.substring(1); } return stream; } else if (baseUri.getPath().contains(":")) { Pattern pattern = Pattern.compile(FIND_STREAM_FORMAT); Matcher matcher = pattern.matcher(baseUri.getPath()); if (matcher.find()) { return baseUri.getPath().substring(matcher.start()) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); } } return baseUri.getPath().substring(baseUri.getPath().indexOf("/", 1) + 1) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); } }
WowzaResourceStrategyImpl implements ResourceStrategy { protected static String getRTMPResource(URI baseUri) { String stream = null; if (baseUri.toString().contains(WOWZA_STREAM_DELIMITER)) { stream = baseUri.toString().split(WOWZA_STREAM_DELIMITER)[1]; if (stream.charAt(0) == '/') { return stream.substring(1); } return stream; } else if (baseUri.getPath().contains(":")) { Pattern pattern = Pattern.compile(FIND_STREAM_FORMAT); Matcher matcher = pattern.matcher(baseUri.getPath()); if (matcher.find()) { return baseUri.getPath().substring(matcher.start()) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); } } return baseUri.getPath().substring(baseUri.getPath().indexOf("/", 1) + 1) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); }  }
WowzaResourceStrategyImpl implements ResourceStrategy { protected static String getRTMPResource(URI baseUri) { String stream = null; if (baseUri.toString().contains(WOWZA_STREAM_DELIMITER)) { stream = baseUri.toString().split(WOWZA_STREAM_DELIMITER)[1]; if (stream.charAt(0) == '/') { return stream.substring(1); } return stream; } else if (baseUri.getPath().contains(":")) { Pattern pattern = Pattern.compile(FIND_STREAM_FORMAT); Matcher matcher = pattern.matcher(baseUri.getPath()); if (matcher.find()) { return baseUri.getPath().substring(matcher.start()) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); } } return baseUri.getPath().substring(baseUri.getPath().indexOf("/", 1) + 1) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); }  @Override String getResource(String baseUri); }
WowzaResourceStrategyImpl implements ResourceStrategy { protected static String getRTMPResource(URI baseUri) { String stream = null; if (baseUri.toString().contains(WOWZA_STREAM_DELIMITER)) { stream = baseUri.toString().split(WOWZA_STREAM_DELIMITER)[1]; if (stream.charAt(0) == '/') { return stream.substring(1); } return stream; } else if (baseUri.getPath().contains(":")) { Pattern pattern = Pattern.compile(FIND_STREAM_FORMAT); Matcher matcher = pattern.matcher(baseUri.getPath()); if (matcher.find()) { return baseUri.getPath().substring(matcher.start()) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); } } return baseUri.getPath().substring(baseUri.getPath().indexOf("/", 1) + 1) + (StringUtils.isNotBlank(baseUri.getQuery()) ? "?" + baseUri.getQuery() : ""); }  @Override String getResource(String baseUri);  }