From 68b2dad19bd6d84f18b22f967ce320b448e8a270 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sat, 30 Dec 2023 21:18:16 +0100
Subject: GLMediaPlayer/FFMPEGMediaPlayer: Add chapter metadata support and use
 com.jogamp.common.av.PTS.millisToTimeStr(..)

Chapter metadata is now supported via our FFMPEGMediaPlayer implementation.

Added public method: 'Chapters[] GLMediaPlayer.getChapters()'
---
 .../jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java   | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java')

diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index 8124ca6ca..f091056c2 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -43,7 +43,6 @@ import com.jogamp.common.av.TimeFrameI;
 import com.jogamp.common.util.IOUtil;
 import com.jogamp.common.util.PropertyAccess;
 import com.jogamp.common.util.SecurityUtil;
-import com.jogamp.common.util.VersionNumber;
 import com.jogamp.gluegen.runtime.ProcAddressTable;
 import com.jogamp.opengl.util.GLPixelStorageModes;
 import com.jogamp.opengl.util.av.GLMediaPlayer;
@@ -413,6 +412,21 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
         natives.setStream0(moviePtr, resStreamLocS, isCameraInput, vid, sizes, rw, rh, rr, aid, aMaxChannelCount, aPrefSampleRate);
     }
 
+    @Override
+    protected void updateMetadata() {
+        final Chapter[] chapters = new Chapter[natives.getChapterCount0(moviePtr)];
+        for(int i=0; i<chapters.length; ++i) {
+            chapters[i] = new Chapter(natives.getChapterID0(moviePtr, i),
+                                      natives.getChapterStartPTS0(moviePtr, i), natives.getChapterEndPTS0(moviePtr, i),
+                                      natives.getChapterTitle0(moviePtr, i));
+        }
+        this.chapters = chapters;
+    }
+    private volatile Chapter[] chapters = new Chapter[0];
+
+    @Override
+    public Chapter[] getChapters() { return chapters; }
+
     @Override
     protected final void initGLImpl(final GL gl) throws IOException, GLException {
         if(0==moviePtr) {
@@ -973,6 +987,5 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
             audioSink.enqueueData( audio_pts, sampleData, data_size);
         }
     }
-
 }
 
-- 
cgit v1.2.3