RFR: 8277309: Add support for H.265/HEVC to HTTP Live Streaming [v3]
Scott Palmer
swpalmer at gmail.com
Thu Mar 24 03:01:50 UTC 2022
On Mar 23, 2022, at 8:20 AM, Kevin Rushforth <kcr at openjdk.java.net> wrote:
>
> On Tue, 22 Mar 2022 08:54:45 GMT, Johan Vos <jvos at openjdk.org> wrote:
>
>> I wonder if we can add some simple resources that allow testing the different protocols on different platforms?
>
> I can't think of a good way to do that, especially for this feature, since it requires a web server.
Just wondering why that’s an issue, specifically for HLS. Java’s built-in web server, the old one at com.sun.net.httpserver.HttpServer (i.e. it wouldn’t need JDK 18), would work fine.
E.g. something not much more complicated than:
int port = 8888;
Path testFilesRoot = Paths.get("media");
HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
server.createContext("/hls", new HttpHandler() {
@Override
public void handle(HttpExchange exchange) throws IOException {
Path path = Paths.get(exchange.getRequestURI().getPath()).getFileName();
boolean isPlaylist = path.endsWith(".m3u8");
boolean isTS = path.endsWith(".ts");
Path assetPath = testFilesRoot.resolve(path);
byte[] data = Files.readAllBytes(assetPath);
exchange.getResponseHeaders().add("Content-Type", isPlaylist
? "application/x-mpegURL"
: isTS ? "video/MP2T" : "video/mp4");
exchange.sendResponseHeaders(200, data.length);
OutputStream os = exchange.getResponseBody();
os.write(data);
os.close();
}
});
server.start();
The content would all be short static test files, easily fitting in the byte array. You could grab something from a public domain source (just edit the paths in the .m3u8 files as needed)
Cheers,
Scott
More information about the openjfx-dev
mailing list