Autopsy  4.8.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MediaViewVideoPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.contentviewers;
20 
21 import java.awt.Dimension;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.Set;
25 import java.util.SortedSet;
26 import java.util.TreeSet;
27 import java.util.logging.Level;
28 import javax.swing.JPanel;
32 import org.sleuthkit.datamodel.AbstractFile;
33 
38 abstract class MediaViewVideoPanel extends JPanel implements FrameCapture, MediaFileViewer.MediaViewPanel {
39 
40  private static final Set<String> AUDIO_EXTENSIONS = new TreeSet<>(Arrays.asList(".mp3", ".wav", ".wma")); //NON-NLS
41 
42  private static final Logger logger = Logger.getLogger(MediaViewVideoPanel.class.getName());
43 
44  // 64 bit architectures
45  private static final String[] ARCH64 = new String[]{"amd64", "x86_64"}; //NON-NLS NON-NLS
46 
47  // 32 bit architectures
48  private static final String[] ARCH32 = new String[]{"x86"}; //NON-NLS
49 
57  public static MediaViewVideoPanel createVideoPanel() {
58  if (is64BitJVM()) {
59  logger.log(Level.INFO, "64 bit JVM detected. Creating JavaFX Video Player."); //NON-NLS
60  return getFXImpl();
61  } else {
62  logger.log(Level.INFO, "32 bit JVM detected. Creating GStreamer Video Player."); //NON-NLS
63  return getGstImpl();
64  }
65  }
66 
72  private static boolean is64BitJVM() {
73  String arch = System.getProperty("os.arch");
74  return Arrays.asList(ARCH64).contains(arch);
75  }
76 
82  private static MediaViewVideoPanel getGstImpl() {
83  return new GstVideoPanel();
84  }
85 
91  private static MediaViewVideoPanel getFXImpl() {
92  return new FXVideoPanel();
93  }
94 
100  public abstract boolean isInited();
101 
105  abstract void reset();
106 
113  abstract void setupVideo(final AbstractFile file, final Dimension dims);
114 
120  abstract public String[] getExtensions();
121 
125  @Override
126  abstract public List<String> getMimeTypes();
127 
128  @Override
129  public List<String> getExtensionsList() {
130  return Arrays.asList(getExtensions());
131  }
132 
133  @Override
134  public boolean isSupported(AbstractFile file) {
135  String extension = file.getNameExtension();
152  if (AUDIO_EXTENSIONS.contains("." + extension) || getExtensionsList().contains("." + extension)) {
153  SortedSet<String> mimeTypes = new TreeSet<>(getMimeTypes());
154  try {
155  String mimeType = new FileTypeDetector().getMIMEType(file);
156  return mimeTypes.contains(mimeType);
157  } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
158  logger.log(Level.WARNING, "Failed to look up mimetype for " + file.getName() + " using FileTypeDetector. Fallingback on AbstractFile.isMimeType", ex);
159  if (!mimeTypes.isEmpty() && file.isMimeType(mimeTypes) == AbstractFile.MimeMatchEnum.TRUE) {
160  return true;
161  }
162  }
163 
164  return getExtensionsList().contains("." + extension);
165  }
166  return false;
167  }
168 }

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.