Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Teleteaching Standalone
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ttt
Teleteaching Standalone
Commits
c5c12b78
Commit
c5c12b78
authored
Oct 06, 2009
by
petter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted changes
git-svn-id:
https://www2.in.tum.de/repos/ttt/trunk@51
0463f305-d864-43cb-8a47-61cf597d4139
parent
5f7e641a
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
628 additions
and
1464 deletions
+628
-1464
.classpath
.classpath
+0
-2
java/ttt/LectureProfile.java
java/ttt/LectureProfile.java
+4
-39
java/ttt/LectureProfileDialog.java
java/ttt/LectureProfileDialog.java
+35
-70
java/ttt/PostProcessorPanel.java
java/ttt/PostProcessorPanel.java
+2
-0
java/ttt/Recorder.java
java/ttt/Recorder.java
+14
-17
java/ttt/ScriptCreator.java
java/ttt/ScriptCreator.java
+0
-5
java/ttt/TTT.java
java/ttt/TTT.java
+1
-1
java/ttt/videoRecorder/CaptureInterface.java
java/ttt/videoRecorder/CaptureInterface.java
+0
-6
java/ttt/videoRecorder/LinuxCam.java
java/ttt/videoRecorder/LinuxCam.java
+101
-171
java/ttt/videoRecorder/OSUtils.java
java/ttt/videoRecorder/OSUtils.java
+8
-22
java/ttt/videoRecorder/OnCapture.java
java/ttt/videoRecorder/OnCapture.java
+78
-0
java/ttt/videoRecorder/TTTVideoFormat.java
java/ttt/videoRecorder/TTTVideoFormat.java
+0
-21
java/ttt/videoRecorder/VideoCreator.java
java/ttt/videoRecorder/VideoCreator.java
+49
-147
java/ttt/videoRecorder/VideoRecorder.java
java/ttt/videoRecorder/VideoRecorder.java
+121
-0
java/ttt/videoRecorder/VideoRecorderPanel.java
java/ttt/videoRecorder/VideoRecorderPanel.java
+0
-314
java/ttt/videoRecorder/VideoSettingPanel.java
java/ttt/videoRecorder/VideoSettingPanel.java
+0
-335
java/ttt/videoRecorder/Videotest.java
java/ttt/videoRecorder/Videotest.java
+62
-119
java/ttt/videoRecorder/WebCamControl.java
java/ttt/videoRecorder/WebCamControl.java
+6
-17
java/ttt/videoRecorder/WindowsCam.java
java/ttt/videoRecorder/WindowsCam.java
+147
-178
lib/v4l4j.jar
lib/v4l4j.jar
+0
-0
native/linux32/libv4l4j.so
native/linux32/libv4l4j.so
+0
-0
native/linux32/libvideo.so
native/linux32/libvideo.so
+0
-0
native/linux32/libvideo.so.0
native/linux32/libvideo.so.0
+0
-0
native/linux64/libv4l4j.so
native/linux64/libv4l4j.so
+0
-0
native/linux64/libvideo.so
native/linux64/libvideo.so
+0
-0
native/linux64/libvideo.so.0
native/linux64/libvideo.so.0
+0
-0
No files found.
.classpath
View file @
c5c12b78
...
...
@@ -9,7 +9,5 @@
<classpathentry
kind=
"lib"
path=
"lib/swing-layout-1.0.2.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/jmf-2.1.1e.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/mp3plugin.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/v4l4j.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/lti-civil.jar"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
java/ttt/LectureProfile.java
View file @
c5c12b78
...
...
@@ -45,13 +45,11 @@ public class LectureProfile {
private
int
port
=
5900
;
private
boolean
record
=
true
;
private
boolean
recordVideo
=
true
;
private
boolean
recordWebcam
=
true
;
private
boolean
recordLinearAudio
=
true
;
// linear = wav
private
boolean
loopbackRecorder
=
false
;
private
int
colorDepth
=
Constants
.
defaultColorDepth
;
private
String
RecordingCamera
;
private
ttt
.
videoRecorder
.
TTTVideoFormat
Format
;
private
float
VideoQuality
;
// used whether to show info box or not
// stored in profile because other profile might be used by other person
//
...
...
@@ -103,9 +101,7 @@ public class LectureProfile {
profile
.
loopbackRecorder
=
preferences
.
getBoolean
(
"loopback_recorder"
,
false
);
profile
.
showRecordControlsInfo
=
preferences
.
getBoolean
(
"show_record_controls_info"
,
true
);
profile
.
showRecordPlayRecordWarning
=
preferences
.
getBoolean
(
"show_record_play_record_warning"
,
true
);
profile
.
RecordingCamera
=
preferences
.
get
(
"RecordingCamera"
,
""
);
profile
.
Format
=
new
ttt
.
videoRecorder
.
TTTVideoFormat
(
preferences
.
getInt
(
"FormatWidth"
,
160
),
preferences
.
getInt
(
"FormatHeight"
,
120
));
profile
.
VideoQuality
=
preferences
.
getFloat
(
"VideoQuality"
,
0.1f
);
return
profile
;
}
}
catch
(
Exception
e
)
{
...
...
@@ -143,10 +139,7 @@ public class LectureProfile {
preferences
.
putBoolean
(
"loopback_recorder"
,
loopbackRecorder
);
preferences
.
putBoolean
(
"show_record_controls_info"
,
showRecordControlsInfo
);
preferences
.
putBoolean
(
"show_record_play_record_warning"
,
showRecordPlayRecordWarning
);
preferences
.
put
(
"RecordingCamera"
,
RecordingCamera
);
preferences
.
putFloat
(
"VideoQuality"
,
VideoQuality
);
preferences
.
putInt
(
"FormatWidth"
,
Format
.
getWidth
());
preferences
.
putInt
(
"FormatHeight"
,
Format
.
getHeight
());
preferences
.
flush
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"failed to write Lecture Profile: "
+
e
);
...
...
@@ -493,34 +486,6 @@ public class LectureProfile {
return
recordVideo
;
}
public
void
setRecordingFormat
(
ttt
.
videoRecorder
.
TTTVideoFormat
format
)
{
this
.
Format
=
format
;
}
public
String
getRecordingCamera
(){
return
RecordingCamera
;
}
public
void
setRecordingCamera
(
String
recordCameraID
)
{
this
.
RecordingCamera
=
recordCameraID
;
}
public
ttt
.
videoRecorder
.
TTTVideoFormat
getVideoFormat
(){
return
Format
;
}
public
float
getVideoQuality
(){
return
VideoQuality
;
}
public
void
setVideoQualiy
(
float
Quality
){
VideoQuality
=
Quality
;
}
public
void
setRecordVideoEnabled
(
boolean
recordVideo
)
{
this
.
recordVideo
=
recordVideo
;
}
...
...
java/ttt/LectureProfileDialog.java
View file @
c5c12b78
...
...
@@ -50,10 +50,6 @@ 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
();
...
...
@@ -214,34 +210,24 @@ public class LectureProfileDialog {
recorderCheckBox
.
setSelected
(
true
);
recorderCheckBox
.
setEnabled
(
false
);
// video recording
WebCamControl
webcam
=
null
;
final
ttt
.
videoRecorder
.
VideoSettingPanel
CameraSettings
;
JButton
CameraSettingsButton
=
new
JButton
(
"Camera Setting"
);
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
;
// video recording
final
JCheckBox
recordVideoCheckBox
=
new
JCheckBox
(
"incl. video"
);
recordVideoCheckBox
.
setToolTipText
(
"enable video recoding"
);
recordVideoCheckBox
.
setOpaque
(
false
);
recordVideoCheckBox
.
setSelected
(
true
);
recordVideoCheckBox
.
setEnabled
(
false
);
// cam recording
final
JCheckBox
camCheckBox
=
new
JCheckBox
(
"incl. Webcam"
);
camCheckBox
.
setToolTipText
(
"enable Webcam recoding"
);
camCheckBox
.
setOpaque
(
false
);
camCheckBox
.
setSelected
(
true
);
camCheckBox
.
setEnabled
(
false
);
// enable/disable according to recorder selection
recorderCheckBox
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
event
)
{
recordVideoCheckBox
.
setVisible
(
recorderCheckBox
.
isSelected
());
filenameField
.
setVisible
(
recorderCheckBox
.
isSelected
());
filenameLabel
.
setVisible
(
recorderCheckBox
.
isSelected
());
}
...
...
@@ -322,8 +308,8 @@ public class LectureProfileDialog {
panel
.
add
(
label
);
panel
.
add
(
recorderCheckBox
);
panel
.
add
(
new
JLabel
(
" "
));
//
panel.add(recordVideoCheckBox);
panel
.
add
(
recordVideoCheckBox
);
panel
.
add
(
filenameLabel
);
panel
.
add
(
filenameField
);
}
...
...
@@ -385,12 +371,13 @@ public class LectureProfileDialog {
videoRecordingPanel
.
add
(
Box
.
createVerticalStrut
(
5
));
final
JLabel
video
label
=
new
JLabel
(
"Video Recording:"
);
video
label
.
setEnabled
(
false
);
videoRecordingPanel
.
add
(
video
label
);
label
=
new
JLabel
(
"Video Recording:"
);
label
.
setEnabled
(
false
);
videoRecordingPanel
.
add
(
label
);
videoRecordingPanel
.
add
(
videoRecordingOnCheckbox
);
videoRecordingPanel
.
add
(
videoRecordingOffCheckbox
);
videoRecordingPanel
.
add
(
CameraSettingsButton
);
videoRecordingPanel
.
add
(
Box
.
createVerticalGlue
());
videoRecordingPanel
.
add
(
audioFormatLabel
);
videoRecordingPanel
.
add
(
wavRadioButton
);
...
...
@@ -443,6 +430,8 @@ public class LectureProfileDialog {
portField
.
setText
(
"5900"
);
displayDesktopCheckBox
.
setSelected
(
false
);
recorderCheckBox
.
setSelected
(
true
);
recordVideoCheckBox
.
setSelected
(
true
);
recordVideoCheckBox
.
setVisible
(
recorderCheckBox
.
isSelected
());
videoRecordingOnCheckbox
.
setSelected
(
true
);
filenameField
.
setVisible
(
recorderCheckBox
.
isSelected
());
filenameLabel
.
setVisible
(
recorderCheckBox
.
isSelected
());
...
...
@@ -470,9 +459,8 @@ public class LectureProfileDialog {
// buttons
final
JButton
okButton
=
new
JButton
(
"ok"
);
okButton
.
setEnabled
(
false
);
okButton
.
setEnabled
(
false
);
JButton
cancelButton
=
new
JButton
(
"cancel"
);
cancelButton
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
arg0
)
{
...
...
@@ -556,10 +544,6 @@ public class LectureProfileDialog {
// set values
if
(
profile
!=
null
)
{
// CameraSettings.getCameraIDs().contains(profile.getRecordingCamera());
lectureComboBox
.
setSelectedItem
(
profile
.
getLecture
());
teacherComboBox
.
setSelectedItem
(
profile
.
getTeacher
());
hostField
.
setText
(
profile
.
getHost
());
...
...
@@ -578,16 +562,10 @@ public class LectureProfileDialog {
displayDesktopCheckBox
.
setSelected
(!
loopback
);
recorderCheckBox
.
setSelected
(
profile
.
isRecordEnabled
());
// recordVideoCheckBox.setSelected(profile.isRecordVideoEnabled());
// recordVideoCheckBox.setVisible(recorderCheckBox.isSelected());
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
());
}
recordVideoCheckBox
.
setSelected
(
profile
.
isRecordVideoEnabled
());
recordVideoCheckBox
.
setVisible
(
recorderCheckBox
.
isSelected
());
videoRecordingOnCheckbox
.
setSelected
(
profile
.
isRecordVideoEnabled
());
videoRecordingOffCheckbox
.
setSelected
(!
profile
.
isRecordVideoEnabled
());
//Always use wave encoding in order to set profile.isRecordLinearAudioEnabled() to true
wavRadioButton
.
setSelected
(
true
);
mp3RadioButton
.
setSelected
(
false
);
...
...
@@ -614,17 +592,11 @@ public class LectureProfileDialog {
profile
.
setPort
(
portField
.
getNumber
()
>=
100
?
portField
.
getNumber
()
:
(
portField
.
getNumber
()
+
5900
));
profile
.
setRecordEnabled
(
recorderCheckBox
.
isSelected
());
profile
.
setRecordVideoEnabled
(
recordVideoCheckBox
.
isSelected
());
profile
.
setRecordVideoEnabled
(
videoRecordingOnCheckbox
.
isSelected
());
profile
.
setRecordLinearAudioEnabled
(
wavRadioButton
.
isSelected
());
profile
.
setLoopbackRecorder
(!
displayDesktopCheckBox
.
isSelected
());
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
());
...
...
@@ -676,18 +648,11 @@ public class LectureProfileDialog {
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"
);
videoRecordingOffCheckbox
.
setSelected
(
true
);
components
=
videoRecordingPanel
.
getComponents
();
for
(
int
i
=
0
;
i
<
components
.
length
;
i
++)
{
components
[
i
].
setEnabled
(
true
);
}
avLabel
.
setEnabled
(
true
);
audioVolumeLabel
.
setEnabled
(
true
);
recordingPathButton
.
setEnabled
(
true
);
...
...
java/ttt/PostProcessorPanel.java
View file @
c5c12b78
...
...
@@ -45,6 +45,8 @@ import javax.swing.JInternalFrame;
import
javax.swing.JOptionPane
;
import
javax.swing.ProgressMonitor
;
import
com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable
;
/**
*
* @author ziewer
...
...
java/ttt/Recorder.java
View file @
c5c12b78
...
...
@@ -61,7 +61,7 @@ public class Recorder implements MessageConsumer, Closeable {
private
DataOutputStream
out
;
private
AudioRecorder
audioVideoRecorder
;
private
VideoRecorder
Panel
VideoRecorder
;
private
VideoRecorder
VideoRecorder
;
private
LectureProfile
lectureProfile
;
...
...
@@ -330,17 +330,14 @@ public class Recorder implements MessageConsumer, Closeable {
if
(
audioVideoRecorder
!=
null
)
audioVideoRecorder
.
startRec
(
file
.
getCanonicalPath
());
//VideoRec start
//
TODO recording options
//VideoRec
Stuff
start
//
TODO VideoRecStart
if
(
lectureProfile
.
isRecordVideoEnabled
()){
VideoRecorder
=
new
VideoRecorderPanel
();
VideoRecorder
.
setRecordingFormat
(
lectureProfile
.
getVideoFormat
());
VideoRecorder
.
setRecordingCamera
(
lectureProfile
.
getRecordingCamera
());
VideoRecorder
.
setVideoQuality
(
lectureProfile
.
getVideoQuality
());
VideoRecorder
=
new
VideoRecorder
();
VideoRecorder
.
setRecordpath
(
file
.
getCanonicalPath
().
substring
(
0
,
file
.
getCanonicalPath
().
length
()-
4
));
VideoRecorder
.
Start
();
}
//VideoRecStuff end
// startime
long
starttime
=
System
.
currentTimeMillis
();
...
...
@@ -417,27 +414,27 @@ public class Recorder implements MessageConsumer, Closeable {
audioVideoRecorder
.
stopRec
();
}
//TODO VideorecStop
if
(
VideoRecorder
!=
null
)
{
if
(
closing
)
{
if
(
closing
)
{
VideoRecorder
.
close
();
VideoRecorder
=
null
;
}
else
{
VideoRecorder
=
null
;
}
else
VideoRecorder
.
Stop
();
}
}
}
out
.
flush
();
out
.
close
();
out
=
null
;
}
TTT
.
userPrefs
.
put
(
"last_opened_recording"
,
file
.
getCanonicalPath
());
System
.
out
.
println
(
"Recorder stop."
);
}
}
// modified by Ziewer - 10.05.2007
// NOTE: writes file header WITHOUT starttime
...
...
java/ttt/ScriptCreator.java
View file @
c5c12b78
...
...
@@ -37,10 +37,8 @@ import java.io.IOException;
import
java.io.PrintWriter
;
import
java.util.Date
;
import
javax.imageio.ImageIO
;
public
class
ScriptCreator
{
final
static
int
HTML_SCRIPT
=
1
;
...
...
@@ -313,9 +311,6 @@ public class ScriptCreator {
out
.
close
();
}
// css style sheet
void
writeStyleSheet
()
{
try
{
...
...
java/ttt/TTT.java
View file @
c5c12b78
...
...
@@ -1091,7 +1091,7 @@ public class TTT extends JFrame {
// TODO: position management
private
int
position
;
public
void
addInternalFrameCentered
(
JInternalFrame
frame
)
{
void
addInternalFrameCentered
(
JInternalFrame
frame
)
{
frame
.
pack
();
...
...
java/ttt/videoRecorder/CaptureInterface.java
deleted
100644 → 0
View file @
5f7e641a
package
ttt.videoRecorder
;
//handles the incoming pictures for linuxcam and windowscam
public
interface
CaptureInterface
{
public
void
onNewImage
(
byte
[]
image
,
String
RecordPath
,
float
Quality
);
}
java/ttt/videoRecorder/LinuxCam.java
View file @
c5c12b78
/**
*
* @author sigl ludwig
*
*/
package
ttt.videoRecorder
;
import
java.nio.ByteBuffer
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Vector
;
import
java.io.File
;
import
java.lang.Thread
;
import
javax.swing.ImageIcon
;
import
com.lti.civil.Image
;
import
au.edu.jcu.v4l4j.FrameGrabber
;
import
au.edu.jcu.v4l4j.ImageFormat
;
import
au.edu.jcu.v4l4j.VideoDevice
;
import
au.edu.jcu.v4l4j.ResolutionInfo.DiscreteResolution
;
import
au.edu.jcu.v4l4j.exceptions.V4L4JException
;
//This classs set and get methods are completly unfished!
public
class
LinuxCam
implements
WebCamControl
,
Runnable
{
private
CaptureInterface
CI
;
private
String
v4lSysfsPath
=
"/sys/class/video4linux/"
;
private
String
RecordPath
;
private
List
<
VideoDevice
>
system
=
new
LinkedList
<
VideoDevice
>();
private
FrameGrabber
fg
;
private
Thread
captureThread
;
int
w
=
160
,
h
=
120
;
private
boolean
CamFound
=
false
;
private
float
CompressionQuality
=
0.1f
;
public
boolean
isRecording
=
false
;
String
dev
=
"/dev/video0"
;
int
currentdev
=
0
;
public
LinuxCam
()
throws
V4L4JException
{
initializeDevices
();
}
protected
void
initializeDevices
()
throws
V4L4JException
{
for
(
Object
i
:
listV4LDeviceFiles
())
{
system
.
add
(
new
VideoDevice
(
i
.
toString
()));
}
}
/**
* Implements the capture thread: get a frame from the FrameGrabber, and
* display it
*/
public
void
run
()
{
ByteBuffer
bb
;
byte
[]
image
;
public
static
String
RecordPath
=
"C:\\TTTImplement\\"
;
private
static
VideoDevice
vd
;
private
static
FrameGrabber
fg
;
private
Thread
captureThread
;
public
static
boolean
isRecording
=
false
;
public
LinuxCam
()
throws
V4L4JException
{
String
dev
=
"/dev/video0"
;
int
w
=
160
,
h
=
120
,
std
=
0
,
channel
=
0
,
qty
=
60
;
initFrameGrabber
(
dev
,
w
,
h
,
std
,
channel
,
qty
);
}
/* Shouldn't be needed but untetested...
public void setImage(byte[] b) {
GUIMain.myLabel.setIcon(new ImageIcon(b));
}*/
/**
* is called in start by the new capture thread stuff
*/
public
void
run
(){
ByteBuffer
bb
;
byte
[]
b
;
try
{
//OnCapture.RecordPath = RecordPath;
while
(
isRecording
){
bb
=
fg
.
getFrame
();
b
=
new
byte
[
bb
.
limit
()];
bb
.
get
(
b
);
OnCapture
SafePic
=
new
OnCapture
();
SafePic
.
onNewImage
((
Image
)
new
ImageIcon
(
b
).
getImage
(),
RecordPath
);
// setImage(b);
}
}
catch
(
V4L4JException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Failed to capture image"
);
}
}
private
void
initFrameGrabber
(
String
dev
,
int
w
,
int
h
,
int
std
,
int
channel
,
int
qty
)
throws
V4L4JException
{
vd
=
new
VideoDevice
(
dev
);
fg
=
vd
.
getJPEGFrameGrabber
(
w
,
h
,
channel
,
std
,
qty
);
}
@Override
public
boolean
Start
()
{
try
{
while
(
isRecording
)
{
if
(
isRecording
)
{
bb
=
fg
.
getFrame
();
image
=
new
byte
[
bb
.
limit
()];
bb
.
get
(
image
);
CI
.
onNewImage
(
image
,
RecordPath
,
CompressionQuality
);
}
if
(!
isRecording
){
fg
.
startCapture
();
captureThread
=
new
Thread
(
this
,
"Capture Thread"
);
captureThread
.
start
();
isRecording
=
true
;
}
}
catch
(
V4L4JException
e
)
{
}
catch
(
V4L4JException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Failed to capture image"
);
}
}
private
Object
[]
listV4LDeviceFiles
()
{
Vector
<
String
>
sdev
=
new
Vector
<
String
>();
File
dir
=
new
File
(
v4lSysfsPath
);
String
[]
files
=
dir
.
list
();
for
(
String
file
:
files
)
// the following test the presence of "video" in
// each file name - not very portable - relying on HAL
// would be much better ...
if
(
file
.
indexOf
(
"video"
)
!=
-
1
)
sdev
.
add
(
"/dev/"
+
file
);
if
(
sdev
.
size
()
!=
0
)
{
CamFound
=
true
;
}
return
sdev
.
toArray
();
}
private
void
initFrameGrabber
(
int
std
,
int
channel
,
int
qty
)
throws
V4L4JException
{
fg
=
system
.
get
(
currentdev
)
.
getJPEGFrameGrabber
(
w
,
h
,
channel
,
std
,
qty
);
return
false
;
}
@Override
public
void
release
()
{
for
(
VideoDevice
x
:
system
)
{
x
.
releaseFrameGrabber
();
x
.
release
();
}
public
boolean
Stopp
()
{
if
(
isRecording
)
{
fg
.
stopCapture
();
isRecording
=
false
;
// OnCapture.ZipOnStop();
}
@Override
public
boolean
Start
()
{
if
(
CamFound
)
try
{
initFrameGrabber
(
0
,
0
,
1
);
if
(!
isRecording
)
{
fg
.
startCapture
();
captureThread
=
new
Thread
(
this
,
"Capture Thread"
);
isRecording
=
true
;
captureThread
.
start
();
}
}
catch
(
V4L4JException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
//returns the intern device id
@Override
public
boolean
Stop
()
{
if
(
isRecording
)
{
captureThread
=
null
;
isRecording
=
false
;
fg
.
stopCapture
();
fg
=
null
;
system
.
get
(
currentdev
).
releaseFrameGrabber
();
public
String
getDeviceID
(
int
Device
)
{
try
{
return
vd
.
getDeviceInfo
().
toString
();
}
catch
(
V4L4JException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
@Override
public
String
getDeviceID
(
int
Device
)
{
if
(
CamFound
)
return
"/dev/video"
+
Device
;
return
null
;
}
//it can currently handle only the default cam
@SuppressWarnings
(
"unchecked"
)
@Override
public
List
<
String
>
getDeviceList
()
{
List
<
String
>
deviselist
=
new
LinkedList
<
String
>();
if
(
CamFound
)
for
(
VideoDevice
i
:
system
)
{
try
{
deviselist
.
add
(
i
.
getDeviceInfo
().
getName
());
return
deviselist
;
}
catch
(
V4L4JException
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
public
List
getDeviceList
()
{
List
lista
=
new
LinkedList
();
lista
.
add
(
vd
.
getDevicefile
());
return
lista
;
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
List
<
TTTVideoFormat
>
getSupportedFormats
(
int
Device
)
{
currentdev
=
Device
;
List
<
TTTVideoFormat
>
SupportedFormats
=
new
LinkedList
<
TTTVideoFormat
>();
if
(
CamFound
)
try
{
for
(
ImageFormat
i
:
system
.
get
(
Device
).
getDeviceInfo
()
.
getFormatList
().
getJPEGEncodableFormats
())
{
if
(
i
.
getResolutionInfo
().
getType
().
toString
().
equals
(
"DISCRETE"
))
{
for
(
DiscreteResolution
j
:
i
.
getResolutionInfo
()
.
getDiscreteResolutions
())
{
SupportedFormats
.
add
(
new
TTTVideoFormat
(
j
.
getWidth
(),
j
.
getHeight
()));
}
}
}
if
(!
SupportedFormats
.
isEmpty
())
return
SupportedFormats
;
}
catch
(
V4L4JException
e
)
{
e
.
printStackTrace
();
}
return
null
;
public
List
getSupportedFormats
(
int
Device
)
{
List
empty
=
new
LinkedList
();
empty
.
add
(
"Width=160 Height=120"
);
return
empty
;
}
//TODO Implement set Format
@Override
public
void
setFormat
(
int
Width
,
int
Height
)
{
w
=
Width
;
h
=
Height
;
}
@Override
public
void
setSelectedCam
(
String
DeviceID
)
{
dev
=
DeviceID
;
}
@Override
public
void
setRecordPath
(
String
Path
)
{
RecordPath
=
Path
;
}
@Override
public
void
setCaptureInterface
(
CaptureInterface
OnPic
)
{
CI
=
OnPic
;
// TODO Auto-generated method stub
}
@Override
public
boolean
CameraFound
(
)
{
return
CamFound
;
public
void
SetRecordPath
(
String
path
)
{
RecordPath
=
path
;
}
@Override
public
void
setQuality
(
float
Quality
)
{
if
(
Quality
<=
1.0f
&&
Quality
>=
0.1f
)
CompressionQuality
=
Quality
;
}
@Override
public
float
getQuality
()
{
return
CompressionQuality
;
}
}
java/ttt/videoRecorder/OSUtils.java
View file @
c5c12b78
...
...
@@ -7,36 +7,22 @@ import java.util.logging.Logger;
* @author ken lti-Civil
*
*/
// detects the OS (linux/mac/windows)
public
final
class
OSUtils
{
@SuppressWarnings
(
"deprecation"
)
private
static
final
Logger
logger
=
Logger
.
global
;
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
{
public
static
WebCamControl
obtainWebcam
()
{
WebCamControl
WBC
=
null
;
String
cam
=
null
;