Skip to content
Permalink
Browse files
8273096: Add support for H.265/HEVC to JavaFX Media
Reviewed-by: kcr, jvos
  • Loading branch information
Alexander Matveev committed Dec 20, 2021
1 parent 18063ad commit 1f10c63358ac4cfdbe503da823f420d224397c78
Showing with 2,058 additions and 122 deletions.
  1. +1 −1 build.gradle
  2. +6 −3 modules/javafx.media/src/main/java/com/sun/media/jfxmedia/MediaError.java
  3. +2 −1 modules/javafx.media/src/main/java/com/sun/media/jfxmedia/track/Track.java
  4. +2 −1 modules/javafx.media/src/main/java/javafx/scene/media/MediaException.java
  5. +5 −1 modules/javafx.media/src/main/java/javafx/scene/media/package.html
  6. +7 −10 modules/javafx.media/src/main/native/gstreamer/plugins/av/audiodecoder.c
  7. +4 −1 modules/javafx.media/src/main/native/gstreamer/plugins/av/avdefines.h
  8. +350 −25 modules/javafx.media/src/main/native/gstreamer/plugins/av/videodecoder.c
  9. +33 −2 modules/javafx.media/src/main/native/gstreamer/plugins/av/videodecoder.h
  10. +27 −2 modules/javafx.media/src/main/native/gstreamer/plugins/avcdecoder/avcdecoder.c
  11. +13 −19 modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/dshowwrapper.cpp
  12. +4 −2 modules/javafx.media/src/main/native/gstreamer/plugins/fxplugins.c
  13. +22 −1 modules/javafx.media/src/main/native/gstreamer/plugins/fxplugins_common.h
  14. +1,304 −0 modules/javafx.media/src/main/native/gstreamer/plugins/mfwrapper/mfwrapper.cpp
  15. +96 −0 modules/javafx.media/src/main/native/gstreamer/plugins/mfwrapper/mfwrapper.h
  16. +2 −2 modules/javafx.media/src/main/native/gstreamer/plugins/progressbuffer/progressbuffer.c
  17. +1 −1 modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile
  18. +7 −3 modules/javafx.media/src/main/native/gstreamer/projects/win/fxplugins/Makefile
  19. +2 −1 modules/javafx.media/src/main/native/jfxmedia/PipelineManagement/Track.h
  20. +78 −21 modules/javafx.media/src/main/native/jfxmedia/platform/gstreamer/GstAVPlaybackPipeline.cpp
  21. +1 −0 modules/javafx.media/src/main/native/jfxmedia/platform/gstreamer/GstAVPlaybackPipeline.h
  22. +25 −2 modules/javafx.media/src/main/native/jfxmedia/platform/gstreamer/GstAudioPlaybackPipeline.cpp
  23. +2 −11 modules/javafx.media/src/main/native/jfxmedia/platform/gstreamer/GstAudioPlaybackPipeline.h
  24. +18 −8 modules/javafx.media/src/main/native/jfxmedia/platform/gstreamer/GstPipelineFactory.cpp
  25. +3 −0 modules/javafx.media/src/main/native/jfxmedia/platform/osx/avf/AVFMediaPlayer.mm
  26. +3 −1 modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile
  27. +3 −1 modules/javafx.media/src/main/native/jfxmedia/projects/mac/Makefile
  28. +3 −1 modules/javafx.media/src/main/native/jfxmedia/projects/win/Makefile
  29. +10 −1 modules/javafx.media/src/main/native/vs_project/plugins/plugins.vcxproj
  30. +24 −0 modules/javafx.media/src/main/native/vs_project/plugins/plugins.vcxproj.filters
@@ -2944,7 +2944,7 @@ project(":media") {
// Pre-defined command line arguments
def cfgCMDArgs = ["sh", "configure"]
def commonCfgArgs = ["--enable-shared", "--disable-debug", "--disable-static", "--disable-yasm", "--disable-doc", "--disable-programs", "--disable-everything"]
def codecsCfgArgs = ["--enable-decoder=aac,mp3,mp3float,h264", "--enable-parser=aac,h264", "--enable-demuxer=aac,h264,mpegts,mpegtsraw"]
def codecsCfgArgs = ["--enable-decoder=aac,mp3,mp3float,h264,hevc", "--enable-parser=aac,h264,hevc", "--enable-demuxer=aac,h264,hevc,mpegts,mpegtsraw"]

def copyLibAVStubs = {String fromDir, String toDir ->
FileCollection config = files("config.h")
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -72,8 +72,9 @@ public enum MediaError {
ERROR_MEDIA_MP3_FORMAT_UNSUPPORTED(ERROR_BASE_MEDIA.code()+0x000A),
ERROR_MEDIA_AAC_FORMAT_UNSUPPORTED(ERROR_BASE_MEDIA.code()+0x000B),
ERROR_MEDIA_H264_FORMAT_UNSUPPORTED(ERROR_BASE_MEDIA.code()+0x000C),
ERROR_MEDIA_HLS_FORMAT_UNSUPPORTED(ERROR_BASE_MEDIA.code()+0x000D),
ERROR_MEDIA_CORRUPTED(ERROR_BASE_MEDIA.code()+0x000E),
ERROR_MEDIA_H265_FORMAT_UNSUPPORTED(ERROR_BASE_MEDIA.code()+0x000D),
ERROR_MEDIA_HLS_FORMAT_UNSUPPORTED(ERROR_BASE_MEDIA.code()+0x000E),
ERROR_MEDIA_CORRUPTED(ERROR_BASE_MEDIA.code()+0x000F),

ERROR_PIPELINE_NULL(ERROR_BASE_PIPELINE.code()+0x0001),
ERROR_PIPELINE_CREATION(ERROR_BASE_PIPELINE.code()+0x0002),
@@ -129,6 +130,8 @@ public enum MediaError {
ERROR_MEMORY_ALLOCATION(ERROR_BASE_SYSTEM.code()+0x0002),
ERROR_OS_UNSUPPORTED(ERROR_BASE_SYSTEM.code()+0x0003),
ERROR_PLATFORM_UNSUPPORTED(ERROR_BASE_SYSTEM.code()+0x0004),
ERROR_MISSING_LIBSWSCALE(ERROR_BASE_SYSTEM.code()+0x0005),
ERROR_INVALID_LIBSWSCALE(ERROR_BASE_SYSTEM.code()+0x0006),

ERROR_FUNCTION_PARAM(ERROR_BASE_FUNCTION.code()+0x0001),
ERROR_FUNCTION_PARAM_NULL(ERROR_BASE_FUNCTION.code()+0x0002),
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,7 @@
H264, // H.264 ("ISO/IEC 14496-10" standard
// or "ITU-T Recommendation H.264")
// (aka MPEG-4 part 10 video, also known as AVC)
H265,

// custom encoding
CUSTOM;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -111,6 +111,7 @@ static Type errorCodeToType(int errorCode) {
errorCode == MediaError.ERROR_MEDIA_MP3_FORMAT_UNSUPPORTED.code() ||
errorCode == MediaError.ERROR_MEDIA_AAC_FORMAT_UNSUPPORTED.code() ||
errorCode == MediaError.ERROR_MEDIA_H264_FORMAT_UNSUPPORTED.code() ||
errorCode == MediaError.ERROR_MEDIA_H265_FORMAT_UNSUPPORTED.code() ||
errorCode == MediaError.ERROR_MEDIA_HLS_FORMAT_UNSUPPORTED.code()) {
errorType = Type.MEDIA_UNSUPPORTED;
} else if(errorCode == MediaError.ERROR_MEDIA_CORRUPTED.code()) {
@@ -2,7 +2,7 @@

<!--
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,6 +75,8 @@ <h4>Supported Encoding Types</h4>
<tr><th scope="row">PCM</th><td>Audio</td><td>Uncompressed, raw audio samples</td></tr>
<tr><th scope="row">H.264/AVC</th><td>Video</td><td>H.264/MPEG-4 Part 10 / AVC (Advanced Video Coding)
video compression</td></tr>
<tr><th scope="row">H.265/HEVC</th><td>Video</td><td>H.265/MPEG-H Part 2 / HEVC (High Efficiency Video Coding)
video compression</td></tr>
</table>

<h4>Supported Container Types</h4>
@@ -101,6 +103,8 @@ <h4>Supported Container Types</h4>
<td>N/A</td><td>MP3</td><td>audio/mpeg</td><td>.mp3</td></tr>
<tr><th scope="row">MP4</th><td>MPEG-4 Part 14</td><td>H.264/AVC</td>
<td>AAC</td><td>video/mp4, audio/x-m4a, video/x-m4v</td><td>.mp4, .m4a, .m4v</td></tr>
<tr><th scope="row">MP4</th><td>MPEG-4 Part 14</td><td>H.265/HEVC</td>
<td>AAC</td><td>video/mp4, audio/x-m4a, video/x-m4v</td><td>.mp4, .m4a, .m4v</td></tr>
<tr><th scope="row">WAV</th><td>Waveform Audio Format</td><td>N/A</td>
<td>PCM</td><td>audio/x-wav</td><td>.wav</td></tr>
</table>
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -329,16 +329,13 @@ audiodecoder_sink_event(GstPad * pad, GstObject *parent, GstEvent * event) {
}

#ifdef DEBUG_OUTPUT
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gboolean update;
gdouble rate, applied_rate;
gint64 start, stop, time;

gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate, &format, &start, &stop, &time);
g_print("audiodecoder_sink_event: NEW_SEGMENT update=%s, rate=%f, format=%d, start=%ld, stop=%ld, time=%ld\n",
update ? "TRUE" : "FALSE", rate, format, start, stop, time);
GstSegment segment;
gst_event_copy_segment(event, &segment);

g_print("audiodecoder_sink_event: NEW_SEGMENT rate=%.1f, format=%d, start=%.3f, stop=%.3f, time=%.3f\n",
segment.rate, segment.format, (double)segment.start/GST_SECOND, (double)segment.stop/GST_SECOND, (double)segment.time/GST_SECOND);

break;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,5 +36,8 @@
// New Frame alloc functions were introduced in 55.28.0
#define NEW_ALLOC_FRAME (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,0))

// HEVC/H.265 support should be available in 56 and up
#define HEVC_SUPPORT (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,0,0))

#endif /* AVDEFINES_H */

1 comment on commit 1f10c63

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 1f10c63 Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.