use of javax.media.format.VideoFormat in project qrcode by yanbe.
the class camDataSource method setMainSource.
public void setMainSource() {
setProcessing(false);
VideoFormat vidformat = new VideoFormat(VideoFormat.RGB);
Vector devices = CaptureDeviceManager.getDeviceList(vidformat);
CaptureDeviceInfo di = null;
if (devices.size() > 0) {
di = (CaptureDeviceInfo) devices.elementAt(0);
} else {
JOptionPane.showMessageDialog(parent, "Your camera is not connected", "No webcam found", JOptionPane.WARNING_MESSAGE);
return;
}
try {
ml = di.getLocator();
setMainCamSource(Manager.createDataSource(ml));
// for VGA size capture (on my envirionment)
/* setMainCamSource(JMFUtils.createCaptureDataSource(null, null,
"vfw:Microsoft WDM Image Capture (Win32):0",
di.getFormats()[di.getFormats().length-1]));
*/
} catch (Exception e) {
JOptionPane.showMessageDialog(parent, "Exception locating media: " + e.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
return;
}
}
use of javax.media.format.VideoFormat in project qrcode by yanbe.
the class mainFrame method recordToFile.
public void recordToFile(File file) {
URL movieUrl = null;
MediaLocator dest = null;
try {
movieUrl = file.toURL();
dest = new MediaLocator(movieUrl);
} catch (MalformedURLException e) {
}
recordCamSource = dataSource.cloneCamSource();
try {
recordProcessor = Manager.createProcessor(recordCamSource);
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Exception creating record processor: " + e.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
return;
} catch (NoProcessorException e) {
JOptionPane.showMessageDialog(this, "Exception creating record processor: " + e.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
return;
}
playhelper = new camStateHelper(recordProcessor);
if (!playhelper.configure(10000)) {
JOptionPane.showMessageDialog(this, "cannot configure record processor", "Error", JOptionPane.WARNING_MESSAGE);
return;
}
VideoFormat vfmt = new VideoFormat(VideoFormat.CINEPAK);
(recordProcessor.getTrackControls())[0].setFormat(vfmt);
(recordProcessor.getTrackControls())[0].setEnabled(true);
recordProcessor.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.QUICKTIME));
Control control = recordProcessor.getControl("javax.media.control.FrameRateControl");
if (control != null && control instanceof javax.media.control.FrameRateControl)
((javax.media.control.FrameRateControl) control).setFrameRate(15.0f);
if (!playhelper.realize(10000)) {
JOptionPane.showMessageDialog(this, "cannot realize processor", "Error", JOptionPane.WARNING_MESSAGE);
return;
}
try {
if (recordProcessor.getDataOutput() == null) {
JOptionPane.showMessageDialog(this, "No Data Output", "Error", JOptionPane.WARNING_MESSAGE);
return;
}
dataSink = Manager.createDataSink(recordProcessor.getDataOutput(), dest);
recordProcessor.start();
dataSink.open();
dataSink.start();
} catch (NoDataSinkException ex) {
JOptionPane.showMessageDialog(this, "No DataSink " + ex.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
} catch (IOException ex) {
JOptionPane.showMessageDialog(this, "IOException " + ex.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
}
}
use of javax.media.format.VideoFormat in project qrcode by yanbe.
the class mainFrame method checkIncoding.
public void checkIncoding(TrackControl[] track) {
for (int i = 0; i < track.length; i++) {
Format format = track[i].getFormat();
if (track[i].isEnabled() && format instanceof VideoFormat) {
Dimension size = ((VideoFormat) format).getSize();
float frameRate = ((VideoFormat) format).getFrameRate();
int w = (size.width % 8 == 0 ? size.width : (int) (size.width / 8) * 8);
int h = (size.height % 8 == 0 ? size.height : (int) (size.height / 8) * 8);
VideoFormat jpegFormat = new VideoFormat(VideoFormat.JPEG_RTP, new Dimension(w, h), Format.NOT_SPECIFIED, Format.byteArray, frameRate);
messageLabel.setText("Status: Video transmitted as: " + jpegFormat.toString());
}
}
}
use of javax.media.format.VideoFormat in project qrcode by yanbe.
the class mainFrame method setJPEGQuality.
//GEN-LAST:event_recordButtonActionPerformed
void setJPEGQuality(Player p, float val) {
Control[] cs = p.getControls();
QualityControl qc = null;
VideoFormat jpegFmt = new VideoFormat(VideoFormat.JPEG);
// the JPEG encoder.
for (int i = 0; i < cs.length; i++) {
if (cs[i] instanceof QualityControl && cs[i] instanceof Owned) {
Object owner = ((Owned) cs[i]).getOwner();
// Then check for the output format.
if (owner instanceof Codec) {
Format[] fmts = ((Codec) owner).getSupportedOutputFormats(null);
for (int j = 0; j < fmts.length; j++) {
if (fmts[j].matches(jpegFmt)) {
qc = (QualityControl) cs[i];
qc.setQuality(val);
break;
}
}
}
if (qc != null)
break;
}
}
}
Aggregations