Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.sun.media.jfxmedia.MediaError;
import com.sun.media.jfxmedia.MediaException;
import com.sun.media.jfxmediaimpl.MediaUtils;
import com.sun.javafx.PlatformUtil;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -73,6 +74,7 @@ final class HLSConnectionHolder extends ConnectionHolder {
// Seek will set this value and HLS_PROP_SEGMENT_START_TIME
// should return it if set.
private int segmentStartTimeAfterSeek = -1;
private static final boolean SEND_HEADER_WITH_EACH_SEGMENT = PlatformUtil.isWindows();
static final long HLS_VALUE_FLOAT_MULTIPLIER = 1000;
static final int HLS_PROP_GET_DURATION = 1;
static final int HLS_PROP_GET_HLS_MODE = 2;
Expand Down Expand Up @@ -368,7 +370,9 @@ private int loadNextSegment() {
} catch (IOException | URISyntaxException e) {
return -1;
}
sendHeader = false;
if (!SEND_HEADER_WITH_EACH_SEGMENT) {
sendHeader = false;
}
}

mediaFile = currentPlaylist.getNextMediaFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2026, 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
Expand Down Expand Up @@ -41,8 +41,7 @@ gboolean lite_plugins_init (GstPlugin * plugin)
!plugin_init_wavparse(plugin) ||
!plugin_init_aiff(plugin) ||
!plugin_init_app(plugin) ||
!plugin_init_audioparsers(plugin) ||
!plugin_init_qtdemux(plugin))
!plugin_init_audioparsers(plugin))
return FALSE;

#ifdef WIN32
Expand All @@ -59,7 +58,8 @@ gboolean lite_plugins_init (GstPlugin * plugin)
#ifdef LINUX
if (!plugin_init_audiofx(plugin) ||
!plugin_init_alsa(plugin) ||
!plugin_init_volume(plugin))
!plugin_init_volume(plugin) ||
!plugin_init_qtdemux(plugin))
return FALSE;
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2026, 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
Expand Down Expand Up @@ -40,7 +40,6 @@ gboolean plugin_init_wavparse (GstPlugin * plugin);
gboolean plugin_init_aiff (GstPlugin * plugin);
gboolean plugin_init_app (GstPlugin * plugin);
gboolean plugin_init_audioparsers (GstPlugin * plugin);
gboolean plugin_init_qtdemux (GstPlugin * plugin);

#ifdef WIN32
gboolean plugin_init_directsound (GstPlugin * plugin);
Expand All @@ -55,6 +54,7 @@ gboolean plugin_init_osxaudio (GstPlugin * plugin);
gboolean plugin_init_audiofx (GstPlugin * plugin);
gboolean plugin_init_alsa (GstPlugin * plugin);
gboolean plugin_init_volume (GstPlugin * plugin);
gboolean plugin_init_qtdemux (GstPlugin * plugin);
#endif

G_END_DECLS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2026, 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
Expand Down Expand Up @@ -208,7 +208,7 @@ static gboolean videodecoder_is_decoder_by_codec_id_supported(gint codec_id)
{
switch(codec_id)
{
case JFX_CODEC_ID_H265:
case JFX_CODEC_ID_HEVC:
#if HEVC_SUPPORT
return TRUE;
#else // HEVC_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,6 @@ int dshowwrapper_deliver(GstBuffer *pBuffer, sUserData *pUserData)
g_print("JFXMEDIA OUTPUT AAC -1\n");
}
#endif

// Set output buffer to NULL before delivering it, otherwise flush stop can release it right after
// we finish delivery.
pBufferOut = decoder->out_buffer[pUserData->output_index];
Expand Down Expand Up @@ -2967,7 +2966,6 @@ static GstFlowReturn dshowwrapper_chain (GstPad * pad, GstObject *parent, GstBuf
g_print("JFXMEDIA INPUT AAC -1\n");
}
#endif

if (GST_BUFFER_TIMESTAMP_IS_VALID(buf))
{
decoder->enable_pts = TRUE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2026, 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
Expand Down Expand Up @@ -33,6 +33,7 @@
#if defined(WIN32)
gboolean dshowwrapper_init(GstPlugin* dshowwrapper);
gboolean mfwrapper_init(GstPlugin* mfwrapper);
gboolean mfdemux_init(GstPlugin* mfdemux);
#endif

#ifdef STATIC_BUILD
Expand All @@ -47,6 +48,7 @@ static gboolean fxplugins_init (GstPlugin * plugin)
#if defined(WIN32)
dshowwrapper_init(plugin) &&
mfwrapper_init(plugin) &&
mfdemux_init(plugin) &&
#endif // WIN32
progress_buffer_plugin_init(plugin);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2026, 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
Expand Down Expand Up @@ -33,7 +33,9 @@ G_BEGIN_DECLS
// Custom events
enum
{
FX_EVENT_RANGE_READY = GST_EVENT_MAKE_TYPE (64, GST_EVENT_TYPE_DOWNSTREAM | GST_EVENT_TYPE_SERIALIZED)
FX_EVENT_RANGE_READY = GST_EVENT_MAKE_TYPE (64, GST_EVENT_TYPE_DOWNSTREAM | GST_EVENT_TYPE_SERIALIZED),
FX_EVENT_SEGMENT_READY = GST_EVENT_MAKE_TYPE (65, GST_EVENT_TYPE_DOWNSTREAM | GST_EVENT_TYPE_SERIALIZED),
FX_EVENT_NEXT_SEGMENT = GST_EVENT_MAKE_TYPE (66, GST_EVENT_TYPE_UPSTREAM | GST_EVENT_TYPE_SERIALIZED)
};

// Query to find out if a sinkpad supports progressive getrange
Expand All @@ -46,9 +48,9 @@ enum JFX_CODEC_ID
{
JFX_CODEC_ID_UNKNOWN = 0,
JFX_CODEC_ID_AAC,
JFX_CODEC_ID_H264, // HLS
JFX_CODEC_ID_AVC1, // MP4
JFX_CODEC_ID_H265, // MP4
JFX_CODEC_ID_H264, // HLS (H.264 with start codes)
JFX_CODEC_ID_AVC1, // MP4 (H.264 without start codes)
JFX_CODEC_ID_HEVC, // H.265 with start codes
};

// Custom error codes used by our plugins
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2026, 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
Expand Down Expand Up @@ -98,7 +98,6 @@ struct _JavaSource
// Seek helper fields
gboolean is_seekable; // property controlled
gboolean is_random_access; // property controlled
gboolean update;
gboolean discont;

guint mode; // property controlled and/or internally
Expand Down Expand Up @@ -485,7 +484,13 @@ static gboolean java_source_perform_seek(JavaSource *element, GstPad *pad, GstEv
element->position_time = 0;
}
element->discont = TRUE;
element->update = FALSE;
result = TRUE;
}
else if ((element->mode & MODE_HLS) == MODE_HLS && new_position == -1)
{
element->pending_event = GST_EVENT_EOS;
element->position = 0;
element->discont = TRUE;
result = TRUE;
}

Expand Down Expand Up @@ -543,7 +548,7 @@ static void java_source_loop(void *user_data)
next_event:
switch (element->pending_event)
{
case GST_EVENT_STREAM_START:
case GST_EVENT_STREAM_START:
{
gchar *stream_id;
GstEvent *event;
Expand All @@ -554,6 +559,42 @@ static void java_source_loop(void *user_data)
result = gst_pad_push_event (element->srcpad, event) ? GST_FLOW_OK : GST_FLOW_FLUSHING;
g_free (stream_id);

element->pending_event = GST_EVENT_CAPS;
break;
}

case GST_EVENT_CAPS:
{
// Set caps to mimetype if provided, we need to do this before pushing buffer,
// so downstream filters can configure itself correctly. Caps are set via event in GStreamer 1.0.
if (element->mimetype)
{
GstCaps *caps = NULL;
GstEvent *caps_event = NULL;
// Special case for HLS AAC elementary stream.
// It has "audio/aac" mimetype which is same as
// "audio/mpeg" mpegversion=4. We changing it here
// so downstream will undestand it.
if (strstr(element->mimetype, "audio/aac") != NULL)
{
caps = gst_caps_new_simple("audio/mpeg",
"mpegversion", G_TYPE_INT, 4,
"stream-format", G_TYPE_STRING, "adts",
NULL);
}
else
{
caps = gst_caps_new_simple(element->mimetype, NULL, NULL);
}

caps_event = gst_event_new_caps(caps);
if (caps_event)
gst_pad_push_event(element->srcpad, caps_event);
gst_caps_unref(caps);
g_free(element->mimetype);
element->mimetype = NULL;
}

element->pending_event = GST_EVENT_SEGMENT;
break;
}
Expand Down Expand Up @@ -593,8 +634,6 @@ static void java_source_loop(void *user_data)
}

gst_segment_init (&segment, GST_FORMAT_BYTES);
if (element->update)
segment.flags |= GST_SEGMENT_FLAG_UPDATE;
segment.rate = element->rate;
segment.start = ((gint64)start_time*GST_SECOND) / HLS_VALUE_FLOAT_MULTIPLIER;
segment.stop = result;
Expand All @@ -605,8 +644,6 @@ static void java_source_loop(void *user_data)
else
{
gst_segment_init (&segment, GST_FORMAT_BYTES);
if (element->update)
segment.flags |= GST_SEGMENT_FLAG_UPDATE;
segment.rate = element->rate;
segment.start = element->position;
segment.stop = element->size;
Expand All @@ -620,6 +657,7 @@ static void java_source_loop(void *user_data)

case GST_EVENT_EOS:
gst_pad_push_event (element->srcpad, gst_event_new_eos());
element->pending_event = GST_EVENT_UNKNOWN;
result = GST_FLOW_EOS;
break;

Expand Down Expand Up @@ -652,29 +690,6 @@ static void java_source_loop(void *user_data)
element->discont = FALSE;
}

// Set caps to mimetype if provided, we need to do this before pushing buffer,
// so downstream filters can configure itself correctly. Caps are set via event in GStreamer 1.0.
if (element->mimetype)
{
GstCaps *caps = NULL;
GstEvent *caps_event = NULL;
// Special case for HLS AAC elementary stream.
// It has "audio/aac" mimetype which is same as
// "audio/mpeg" mpegversion=4. We changing it here
// so downstream will undestand it.
if (strstr(element->mimetype, "audio/aac") != NULL)
caps = gst_caps_new_simple("audio/mpeg", "mpegversion", G_TYPE_INT, 4, NULL);
else
caps = gst_caps_new_simple(element->mimetype, NULL, NULL);

caps_event = gst_event_new_caps(caps);
if (caps_event)
gst_pad_push_event(element->srcpad, caps_event);
gst_caps_unref(caps);
g_free(element->mimetype);
element->mimetype = NULL;
}

result = gst_pad_push(element->srcpad, buffer);

if (element->pending_event != GST_EVENT_SEGMENT)
Expand Down Expand Up @@ -886,10 +901,6 @@ static GstStateChangeReturn java_source_change_state (GstElement *e,
element->position = 0;
element->position_time = 0;
element->discont = FALSE;
if ((element->mode & MODE_HLS) == MODE_HLS)
element->update = FALSE;
else
element->update = TRUE;
GST_PAD_STREAM_UNLOCK(element->srcpad);

g_mutex_lock(&element->lock);
Expand Down
Loading