1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.format.* ;
import java.util.* ;
import javax.media.* ;
import javax.media.protocol.* ;
import javax.swing.JOptionPane;
import jmapps.util.StateHelper;
import org.videolan.jvlc.*;
public class Webcam extends JInternalFrame
{
private VideoFormat formatVideo ;
private Vector peri ;
private Processor processeur ;
private CaptureDeviceInfo info ;
private MediaLocator ml ;
private DataSource sourceCamera ;
private JPanel panneauBas ;
private JCheckBox muet ;
public Webcam() //CONSTRUCTEUR DE LA FENETRE WEBCAM LOCALE
{
super("Webcam locale",false, true) ;
panneauBas = new JPanel() ;
muet = new JCheckBox("Micro muet") ;
panneauBas.add(muet, BorderLayout.WEST) ;
this.setSize(170,200);
this.setVisible(true);
this.setLocation(20,20);
//ON SPECIFIEZ UN FORMAT VIDEO ICI YUV
formatVideo = new VideoFormat(VideoFormat.RGB, new Dimension(640,480),Format.NOT_SPECIFIED, Format.byteArray, (float)15.00015);
//ON RECUPERE LA LISTE DES PERIPHERIQUES DE CE FORMAT
peri = CaptureDeviceManager.getDeviceList(formatVideo);
if (peri.size() <= 0)
{
JOptionPane.showMessageDialog(this, "Aucune webcam detéctée" + peri.toString(), "Erreur", JOptionPane.ERROR_MESSAGE) ;
}
info = (CaptureDeviceInfo) peri.elementAt(0) ;
ml = info.getLocator();
try
{
sourceCamera = Manager.createDataSource(ml);
sourceCamera = Manager.createCloneableDataSource(sourceCamera);
processeur = Manager.createProcessor(sourceCamera) ;
StateHelper playhelper = new StateHelper(processeur);
playhelper.configure();
processeur.setContentDescriptor(null);
playhelper.realize();
Control control = processeur.getControl("javax.media.control.FormatControl");
if (control== null)
JOptionPane.showMessageDialog(this, "Pas ce controle", "Erreur", JOptionPane.ERROR_MESSAGE) ;
processeur.start();
this.getContentPane().add(processeur.getVisualComponent(), BorderLayout.CENTER);
this.getContentPane().add(panneauBas, BorderLayout.SOUTH);
}
catch(Exception e)
{
System.out.println("Erreur") ;
}
}
} |
Partager