Commit aa6b40bc authored by petter's avatar petter

Removed Hard-wired dependency on JNI libraries - what a pain in the A**

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@47 0463f305-d864-43cb-8a47-61cf597d4139
parent ce2b9c05
......@@ -50,6 +50,10 @@ import javax.swing.SpringLayout;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import ttt.videoRecorder.OSUtils;
import ttt.videoRecorder.WebCamControl;
import ttt.videoRecorder.OSUtils.CameraException;
public class LectureProfileDialog {
public static void showLectureProfileDialog() {
new LectureProfileDialog().show();
......@@ -211,17 +215,28 @@ public class LectureProfileDialog {
recorderCheckBox.setEnabled(false);
// video recording
final ttt.videoRecorder.VideoSettingPanel CameraSettings = new ttt.videoRecorder.VideoSettingPanel();
CameraSettings.show(false);
WebCamControl webcam = null;
final ttt.videoRecorder.VideoSettingPanel CameraSettings;
JButton CameraSettingsButton = new JButton("Camera Setting");
CameraSettingsButton.setEnabled(false);
CameraSettingsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CameraSettings.show(true);
}
});
CameraSettingsButton.setEnabled(false);
try {
webcam = OSUtils.obtainWebcam();
} catch (CameraException e) {
System.err.println("Could not connect to camera");
//e.printStackTrace();
}
if (webcam!=null) {
CameraSettings = new ttt.videoRecorder.VideoSettingPanel(webcam);
CameraSettings.show(false);
CameraSettingsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CameraSettings.show(true);
}
});
}
else CameraSettings=null;
// enable/disable according to recorder selection
......@@ -565,13 +580,13 @@ public class LectureProfileDialog {
recorderCheckBox.setSelected(profile.isRecordEnabled());
// recordVideoCheckBox.setSelected(profile.isRecordVideoEnabled());
// recordVideoCheckBox.setVisible(recorderCheckBox.isSelected());
if(CameraSettings.CamerasFound()){
videoRecordingOnCheckbox.setSelected(profile.isRecordVideoEnabled());
videoRecordingOffCheckbox.setSelected(!profile.isRecordVideoEnabled());
if( CameraSettings.getCameraIDs().contains(profile.getRecordingCamera()))
CameraSettings.setRecordingCamera(profile.getRecordingCamera());
CameraSettings.setRecordingFormat(profile.getVideoFormat());
CameraSettings.setQuality(profile.getVideoQuality());
if (CameraSettings!=null) if(CameraSettings.CamerasFound()){
videoRecordingOnCheckbox.setSelected(profile.isRecordVideoEnabled());
videoRecordingOffCheckbox.setSelected(!profile.isRecordVideoEnabled());
if( CameraSettings.getCameraIDs().contains(profile.getRecordingCamera()))
CameraSettings.setRecordingCamera(profile.getRecordingCamera());
CameraSettings.setRecordingFormat(profile.getVideoFormat());
CameraSettings.setQuality(profile.getVideoQuality());
}
//Always use wave encoding in order to set profile.isRecordLinearAudioEnabled() to true
wavRadioButton.setSelected(true);
......@@ -602,10 +617,14 @@ public class LectureProfileDialog {
profile.setRecordVideoEnabled(videoRecordingOnCheckbox.isSelected());
profile.setRecordLinearAudioEnabled(wavRadioButton.isSelected());
profile.setLoopbackRecorder(!displayDesktopCheckBox.isSelected());
profile.setRecordingFormat(CameraSettings.getRecordingFormat());
profile.setRecordingCamera(CameraSettings.getRecordingCamera());
profile.setVideoQualiy(CameraSettings.getQuality());
CameraSettings.show(false);
if (CameraSettings!=null){
profile.setRecordingFormat(CameraSettings.getRecordingFormat());
profile.setRecordingCamera(CameraSettings.getRecordingCamera());
profile.setVideoQualiy(CameraSettings.getQuality());
CameraSettings.show(false);
}
profile.storeProfile();
TTT.userPrefs.put("last_used_lecture_profile", profile.getLecture());
......@@ -657,10 +676,11 @@ public class LectureProfileDialog {
for (int i = 0; i < components.length; i++) {
components[i].setEnabled(true);
}
if(CameraSettings.CamerasFound()){
components = videoRecordingPanel.getComponents();
for (int i = 0; i < components.length; i++) {
components[i].setEnabled(true);
if(CameraSettings==null || CameraSettings.CamerasFound()){
components = videoRecordingPanel.getComponents();
for (int i = 0; i < components.length; i++) {
components[i].setEnabled(true);
}
}else{
videolabel.setText("No Camera available");
......
......@@ -45,8 +45,6 @@ import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.ProgressMonitor;
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
/**
*
* @author ziewer
......
......@@ -11,8 +11,18 @@ import java.util.logging.Logger;
public final class OSUtils {
@SuppressWarnings("deprecation")
private static final Logger logger = Logger.global;
public static WebCamControl obtainWebcam() {
public static class CameraException extends Exception {
Exception internal;
public CameraException(Exception e){
internal=e;
}
@Override
public void printStackTrace() {
System.err.println("CameraException occured because of ");
internal.printStackTrace();
}
}
public static WebCamControl obtainWebcam() throws CameraException{
WebCamControl WBC = null;
String cam = null;
if (OSUtils.isLinux()) {
......@@ -24,7 +34,9 @@ public final class OSUtils {
Class<?> clazz = Class.forName(cam);
WBC = (WebCamControl) clazz.getConstructors()[0].newInstance();
} catch (Exception e) {
e.printStackTrace();
//e.printStackTrace();
System.err.println("Exception "+e+" occured while trying to create a "+cam);
throw new CameraException(e);
}
return WBC;
}
......
......@@ -41,6 +41,8 @@ import javax.swing.JWindow;
import javax.swing.JPanel;
import ttt.videoRecorder.OSUtils.CameraException;
public class VideoRecorderPanel implements WindowListener, ActionListener {
//MyWindow is a nested class within VideoRecroderPanel
private MyWindow frame = new MyWindow();
......@@ -63,7 +65,12 @@ public class VideoRecorderPanel implements WindowListener, ActionListener {
public VideoRecorderPanel() {
WBC = OSUtils.obtainWebcam();
try {
WBC = OSUtils.obtainWebcam();
} catch (CameraException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//MyCapture is a nested class within VideoRecroderPanel
WBC.setCaptureInterface(new MyCapture());
......
......@@ -34,6 +34,7 @@ import javax.swing.JPanel;
import javax.swing.WindowConstants;
import ttt.TTT;
import ttt.videoRecorder.OSUtils.CameraException;
public class VideoSettingPanel implements ActionListener {
......@@ -78,11 +79,11 @@ public class VideoSettingPanel implements ActionListener {
}
@SuppressWarnings("unchecked")
public VideoSettingPanel() {
public VideoSettingPanel(WebCamControl webcam) {
TTT.getInstance().addInternalFrameCentered(frame);
WBC = OSUtils.obtainWebcam();
WBC=webcam;
//MySettings is a nested class within VideoSettingsPanel
WBC.setCaptureInterface(new MySettings());
......
......@@ -20,9 +20,11 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import ttt.videoRecorder.OSUtils.CameraException;
public class Videotest implements ActionListener {
public static void main(String args[]) throws IOException {
public static void main(String args[]) throws Exception {
Videotest kf = new Videotest();
kf.gui();
}
......@@ -82,7 +84,10 @@ public class Videotest implements ActionListener {
final VideoSettingPanel k = new VideoSettingPanel();
final VideoSettingPanel k;
public Videotest() throws CameraException{
k= new VideoSettingPanel(OSUtils.obtainWebcam());
}
public void videosettings() {
if (!recording) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment