mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
Implemented a safer and correct way of calling Gst.init()
This commit is contained in:
parent
1581e07ea2
commit
aa6ed94b14
@ -74,6 +74,8 @@ import org.freedesktop.gstreamer.Format;
|
|||||||
import org.freedesktop.gstreamer.GstException;
|
import org.freedesktop.gstreamer.GstException;
|
||||||
import org.freedesktop.gstreamer.event.SeekFlags;
|
import org.freedesktop.gstreamer.event.SeekFlags;
|
||||||
import org.freedesktop.gstreamer.event.SeekType;
|
import org.freedesktop.gstreamer.event.SeekType;
|
||||||
|
import org.sleuthkit.autopsy.contentviewers.utils.GstLoader;
|
||||||
|
import org.sleuthkit.autopsy.contentviewers.utils.GstLoader.GstStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a video player that is part of the Media View layered pane. It uses
|
* This is a video player that is part of the Media View layered pane. It uses
|
||||||
@ -540,23 +542,12 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
|
|||||||
if (this.isCancelled()) {
|
if (this.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting the following property causes the GST
|
GstStatus loadStatus = GstLoader.tryLoad();
|
||||||
// Java bindings to call dispose() on the GST
|
if(loadStatus == GstStatus.FAILURE) {
|
||||||
// service thread instead of running it in the GST
|
|
||||||
// Native Object Reaper thread.
|
|
||||||
System.setProperty("glib.reapOnEDT", "true");
|
|
||||||
|
|
||||||
// Initialize Gstreamer. It is safe to call this for every file.
|
|
||||||
// It was moved here from the constructor because having it happen
|
|
||||||
// earlier resulted in crashes on Linux. See JIRA-5888.
|
|
||||||
Gst.init();
|
|
||||||
|
|
||||||
if (!Gst.isInitialized()) {
|
|
||||||
logger.log(Level.INFO, "GStreamer is not initialized."); //NON-NLS
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gst.getExecutor().submit(() -> {
|
Gst.getExecutor().submit(() -> {
|
||||||
//Video is ready for playback. Create new components
|
//Video is ready for playback. Create new components
|
||||||
gstPlayBin = new PlayBin("VideoPlayer", tempFile.toURI());
|
gstPlayBin = new PlayBin("VideoPlayer", tempFile.toURI());
|
||||||
|
72
Core/src/org/sleuthkit/autopsy/contentviewers/utils/GstLoader.java
Executable file
72
Core/src/org/sleuthkit/autopsy/contentviewers/utils/GstLoader.java
Executable file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sleuthkit.autopsy.contentviewers.utils;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.freedesktop.gstreamer.Gst;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dsmyda
|
||||||
|
*/
|
||||||
|
public class GstLoader {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(GstLoader.class.getName());
|
||||||
|
private static GstStatus status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to load the gstreamer bindings. Only one attempt will be
|
||||||
|
* performed per Autopsy process. Clients should not attempt to interact
|
||||||
|
* with the gstreamer bindings unless the load was successful.
|
||||||
|
*
|
||||||
|
* @return Status - SUCCESS or FAILURE
|
||||||
|
*/
|
||||||
|
public synchronized static GstStatus tryLoad() {
|
||||||
|
// Null is our 'unknown' status. Prior to the first call, the status
|
||||||
|
// is unknown.
|
||||||
|
if (status != null) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Setting the following property causes the GST
|
||||||
|
// Java bindings to call dispose() on the GST
|
||||||
|
// service thread instead of running it in the GST
|
||||||
|
// Native Object Reaper thread.
|
||||||
|
System.setProperty("glib.reapOnEDT", "true");
|
||||||
|
Gst.init();
|
||||||
|
status = GstStatus.SUCCESS;
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
status = GstStatus.FAILURE;
|
||||||
|
MessageNotifyUtil.Message.error("A problem was encountered with"
|
||||||
|
+ "the video playback service. Video playback will"
|
||||||
|
+ " be disabled for the remainder of the session.");
|
||||||
|
logger.log(Level.WARNING, "Failed to load gsteamer bindings", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GstStatus {
|
||||||
|
SUCCESS, FAILURE
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user