Autopsy  4.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 static java.util.Objects.nonNull;
25 import java.util.Set;
26 import java.util.SortedSet;
27 import java.util.TreeSet;
28 import java.util.logging.Level;
29 import javax.swing.JPanel;
32 import org.sleuthkit.datamodel.AbstractFile;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
39 public abstract class MediaViewVideoPanel extends JPanel implements FrameCapture, DataContentViewerMedia.MediaViewPanel {
40 
41  private static final Set<String> AUDIO_EXTENSIONS = new TreeSet<>(Arrays.asList(".mp3", ".wav", ".wma")); //NON-NLS
42 
43  private static final Logger logger = Logger.getLogger(MediaViewVideoPanel.class.getName());
44 
45  // 64 bit architectures
46  private static final String[] ARCH64 = new String[]{"amd64", "x86_64"}; //NON-NLS NON-NLS
47 
48  // 32 bit architectures
49  private static final String[] ARCH32 = new String[]{"x86"}; //NON-NLS
50 
59  if (is64BitJVM()) {
60  logger.log(Level.INFO, "64 bit JVM detected. Creating JavaFX Video Player."); //NON-NLS
61  return getFXImpl();
62  } else {
63  logger.log(Level.INFO, "32 bit JVM detected. Creating GStreamer Video Player."); //NON-NLS
64  return getGstImpl();
65  }
66  }
67 
73  private static boolean is64BitJVM() {
74  String arch = System.getProperty("os.arch");
75  return Arrays.asList(ARCH64).contains(arch);
76  }
77 
83  private static MediaViewVideoPanel getGstImpl() {
84  return new GstVideoPanel();
85  }
86 
92  private static MediaViewVideoPanel getFXImpl() {
93  return new FXVideoPanel();
94  }
95 
101  public abstract boolean isInited();
102 
106  abstract void reset();
107 
114  abstract void setupVideo(final AbstractFile file, final Dimension dims);
115 
121  abstract public String[] getExtensions();
122 
126  @Override
127  abstract public List<String> getMimeTypes();
128 
129  @Override
130  public List<String> getExtensionsList() {
131  return Arrays.asList(getExtensions());
132  }
133 
134  @Override
135  public boolean isSupported(AbstractFile file) {
136  String extension = file.getNameExtension();
153  if (AUDIO_EXTENSIONS.contains("." + extension) || getExtensionsList().contains("." + extension)) {
154  SortedSet<String> mimeTypes = new TreeSet<>(getMimeTypes());
155  try {
156  String mimeType = new FileTypeDetector().detect(file);
157  if (nonNull(mimeType)) {
158  return mimeTypes.contains(mimeType);
159  }
160  } catch (FileTypeDetector.FileTypeDetectorInitException | TskCoreException ex) {
161  logger.log(Level.WARNING, "Failed to look up mimetype for " + file.getName() + " using FileTypeDetector. Fallingback on AbstractFile.isMimeType", ex);
162  if (!mimeTypes.isEmpty() && file.isMimeType(mimeTypes) == AbstractFile.MimeMatchEnum.TRUE) {
163  return true;
164  }
165  }
166 
167  return getExtensionsList().contains("." + extension);
168  }
169  return false;
170  }
171 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:166

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.