Commit 451da1a5 authored by ludwig's avatar ludwig

1) WindowsCam; VideoSettingPanel; OSUTils

Improved Error Handling when the Webcam Libraries couldn't load in windows

2) Recorder; LectureProfileDialog; AudioVideoMonitorPanel
> Fixed bug which prevented the record button to show up when no Audio Source was found
> Allowed Recording without Audio

TODO
Player crashes without audiofile

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@84 0463f305-d864-43cb-8a47-61cf597d4139
parent fa5ecdbe
......@@ -76,8 +76,12 @@ public class Recorder implements MessageConsumer, Closeable {
// initialize audio and video
if (lectureProfile != null){
try{
audioVideoRecorder = new AudioRecorder();
} catch (IOException e){
System.out.println("Couldn't create AudioRecorder!");
}
if(lectureProfile.isRecordVideoEnabled()){
VideoRecorder = new VideoRecorderPanel(lectureProfile.getRecordingCamera(), lectureProfile.getVideoFormat(),lectureProfile.getVideoQuality(),/*file.getCanonicalPath().substring(0, file.getCanonicalPath().length()-4)*/null);
}
......@@ -235,9 +239,20 @@ public class Recorder implements MessageConsumer, Closeable {
controlPanel = new GradientPanel();
controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
JComponent volumeLevelComponent = audioVideoRecorder.getVolumeLevelComponent();
if (volumeLevelComponent != null)
controlPanel.add(volumeLevelComponent);
JComponent volumeLevelComponent;
if (audioVideoRecorder != null) {
volumeLevelComponent = audioVideoRecorder.getVolumeLevelComponent();
if (volumeLevelComponent != null) {
controlPanel.add(volumeLevelComponent);
}
} else {
controlPanel.add(new JLabel("No Audio Rec"));
}
controlPanel.add(recordButton);
controlPanel.add(stopButton);
controlPanel.add(playButton);
......
......@@ -42,16 +42,12 @@ public class AudioVideoMonitorPanel extends JPanel {
private AudioMonitorPanel audioMonitorPanel;
public AudioVideoMonitorPanel() {
public AudioVideoMonitorPanel() throws Exception {
setOpaque(false);
try {
audioMonitorPanel = new AudioMonitorPanel(true);
} catch (Exception e) {
System.out.println("Cannot open audio monitor: " + e);
// e.printStackTrace();
}
if (audioMonitorPanel != null) {
add(audioMonitorPanel);
audioMonitorPanel.setPreferredSize(new Dimension(128, 16));
......
......@@ -408,15 +408,12 @@ public class LectureProfileDialog {
monitorPanel = new AudioVideoMonitorPanel();
avPanel.add(monitorPanel);
} catch (Exception e) {
JLabel jlabel = new JLabel("Monitor");
JLabel jlabel = new JLabel("Couldn't find Mic!");
jlabel.setEnabled(false);
panel.add(jlabel);
jlabel = new JLabel("<not available>");
jlabel.setEnabled(false);
panel.add(jlabel);
avPanel.add(jlabel);
System.out.println("Cannot open audio/video monitor: " + e);
}
avPanel.add(Box.createHorizontalGlue());
avPanel.add(videoRecordingPanel);
avPanel.add(Box.createHorizontalGlue());
......
package ttt.video;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Logger;
/**
......@@ -37,6 +38,8 @@ public final class OSUtils {
try {
Class<?> clazz = Class.forName(cam);
WBC = (WebCamControl) clazz.getConstructors()[0].newInstance();
}catch(InvocationTargetException e){
System.out.println("Webcam libraries are missing.");
} catch (Exception e) {
e.printStackTrace();
System.err.println("Exception "+e+" occured while trying to create a "+cam);
......
......@@ -75,7 +75,8 @@ public class VideoSettingPanel implements ActionListener {
TTT.getInstance().addInternalFrameCentered(frame);
try {
WBC= OSUtils.obtainWebcam();
WBC = OSUtils.obtainWebcam();
if(WBC != null){
//MySettings is a nested class within VideoSettingsPanel
WBC.setCaptureInterface(new MySettings());
......@@ -125,6 +126,8 @@ public class VideoSettingPanel implements ActionListener {
else {
lblnotice.setText("No Camera Found");
}
}
}catch(CameraException e){
lblnotice.setText("No Camera Found");
}catch(SetCameraException e){
......
......@@ -31,12 +31,13 @@ public class WindowsCam implements WebCamControl {
private int SelectedFormat; // Remembers the currently selected format
private CaptureStream StartcaptureStream; // The recording stream
private CaptureSystemFactory factory = DefaultCaptureSystemFactorySingleton.instance();
private CaptureSystem system = factory.createCaptureSystem();
private CaptureSystem system;
private boolean CamFound = false;
private float CompressionQuality = 0.1f;
@SuppressWarnings("unchecked")
public WindowsCam() throws CaptureException {
system = factory.createCaptureSystem();
system.init();
List list = system.getCaptureDeviceInfoList();
if (list.size() > 0) { // check if any camera found
......
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