Autopsy  4.5.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 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.corecomponents;
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;
31 import org.sleuthkit.datamodel.AbstractFile;
32 
37 public abstract class MediaViewVideoPanel extends JPanel implements FrameCapture, DataContentViewerMedia.MediaViewPanel {
38 
39  private static final Set<String> AUDIO_EXTENSIONS = new TreeSet<>(Arrays.asList(".mp3", ".wav", ".wma")); //NON-NLS
40 
41  private static final Logger logger = Logger.getLogger(MediaViewVideoPanel.class.getName());
42 
43  // 64 bit architectures
44  private static final String[] ARCH64 = new String[]{"amd64", "x86_64"}; //NON-NLS NON-NLS
45 
46  // 32 bit architectures
47  private static final String[] ARCH32 = new String[]{"x86"}; //NON-NLS
48 
57  if (is64BitJVM()) {
58  logger.log(Level.INFO, "64 bit JVM detected. Creating JavaFX Video Player."); //NON-NLS
59  return getFXImpl();
60  } else {
61  logger.log(Level.INFO, "32 bit JVM detected. Creating GStreamer Video Player."); //NON-NLS
62  return getGstImpl();
63  }
64  }
65 
71  private static boolean is64BitJVM() {
72  String arch = System.getProperty("os.arch");
73  return Arrays.asList(ARCH64).contains(arch);
74  }
75 
81  private static MediaViewVideoPanel getGstImpl() {
82  return new GstVideoPanel();
83  }
84 
90  private static MediaViewVideoPanel getFXImpl() {
91  return new FXVideoPanel();
92  }
93 
99  public abstract boolean isInited();
100 
104  abstract void reset();
105 
112  abstract void setupVideo(final AbstractFile file, final Dimension dims);
113 
119  abstract public String[] getExtensions();
120 
124  @Override
125  abstract public List<String> getMimeTypes();
126 
127  @Override
128  public List<String> getExtensionsList() {
129  return Arrays.asList(getExtensions());
130  }
131 
132  @Override
133  public boolean isSupported(AbstractFile file) {
134  String extension = file.getNameExtension();
151  if (AUDIO_EXTENSIONS.contains("." + extension) || getExtensionsList().contains("." + extension)) {
152  SortedSet<String> mimeTypes = new TreeSet<>(getMimeTypes());
153  try {
154  String mimeType = new FileTypeDetector().getMIMEType(file);
155  return mimeTypes.contains(mimeType);
157  logger.log(Level.WARNING, "Failed to look up mimetype for " + file.getName() + " using FileTypeDetector. Fallingback on AbstractFile.isMimeType", ex);
158  if (!mimeTypes.isEmpty() && file.isMimeType(mimeTypes) == AbstractFile.MimeMatchEnum.TRUE) {
159  return true;
160  }
161  }
162 
163  return getExtensionsList().contains("." + extension);
164  }
165  return false;
166  }
167 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.