changeset 10793:65a4d1aeeba6

8186863: Better FLV demultiplexing playback Reviewed-by: ddehaven, kcr
author almatvee
date Thu, 28 Sep 2017 17:38:33 -0700
parents fc02cf9fe634
children 0fc9274dc8f0
files modules/javafx.media/src/main/native/gstreamer/plugins/vp6/flvmetadata.c
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.media/src/main/native/gstreamer/plugins/vp6/flvmetadata.c	Thu Sep 14 15:11:56 2017 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/plugins/vp6/flvmetadata.c	Thu Sep 28 17:38:33 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, 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
@@ -443,11 +443,6 @@
         }
     }
 
-    // pre-populate the array
-    if (keyframes->len != readSize) {
-        g_array_set_size(keyframes, readSize);
-    }
-
     for (i = 0; i < size; i++, readSize--) {
         if (!flv_script_data_read_ui8(reader, &value_type))
             return FALSE;
@@ -461,12 +456,15 @@
         }
 
         if (readSize > 0 && whichField > 0) {
-            FlvKeyframe *entry = &g_array_index(keyframes, FlvKeyframe, i);
+            FlvKeyframe entry;
             if (whichField == 1) {
-                entry->time = (GstClockTime)(double_value * GST_SECOND);
+                entry.time = (GstClockTime)(double_value * GST_SECOND);
+                entry.fileposition = 0;
             } else if (whichField == 2) {
-                entry->fileposition = (guint64)double_value;
+                entry.time = 0;
+                entry.fileposition = (guint64)double_value;
             }
+            g_array_append_vals(keyframes, &entry, 1);
         }
     }
     return TRUE;
@@ -487,7 +485,13 @@
             if (!metadata->keyframes) {
                 metadata->keyframes = g_array_new(FALSE, TRUE, sizeof(FlvKeyframe));
             }
+
             result &= flv_script_read_keyframe_array(reader, value_name, metadata->keyframes);
+
+            if (!result) {
+                g_array_free(metadata->keyframes, TRUE);
+                metadata->keyframes = NULL;
+            }
             break;
 
         default: