|
From: <dep...@us...> - 2003-03-15 22:47:33
|
Update of /cvsroot/madsserv/madsserv/src/client In directory sc8-pr-cvs1:/tmp/cvs-serv31465 Modified Files: Client.java ClientRTPManager.java DialogServer.java ErrorPopUp.java MadsservClient.java PlayerPanel.java ThreadRTPManager.java ThreadRead.java ThreadWrite.java Log Message: le client qui marche pas mal Index: Client.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/Client.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Client.java 14 Mar 2003 03:26:17 -0000 1.7 --- Client.java 15 Mar 2003 22:47:30 -0000 1.8 *************** *** 1,383 **** ! //package madsserv_planification; ! ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.awt.Component.*; ! import java.awt.TextComponent.*; ! import java.awt.Checkbox.*; ! import java.awt.CheckboxGroup.*; ! import javax.swing.*; ! ! /** ! * <p>Title: Client </p> ! * <p>Description: La Classe Client est l'interface graphique du client</p> ! * <p>Copyright: Copyright (c) 2003</p> ! * <p>Company: Madsserv Corporation</p> ! * @author Xavier Deplancq ! * @version 1.0 ! */ ! ! public class Client ! extends Frame { ! /** ! * Champs de la Classe Reencode ! */ ! ! private Container contentPane; ! private Panel panelNorth = new Panel(); ! private Panel panelCenter = new Panel(); ! private Panel panelSouth = new Panel(); ! private Panel panelEmpty = new Panel(); ! private MenuBar menuBar1 = new MenuBar(); ! private Menu menuFile = new Menu(); ! private MenuItem menuOpenURL = new MenuItem(); ! private MenuItem menuFileExit = new MenuItem(); ! private Label statusBar = new Label(); ! private Label URLLabel = new Label(); ! private Label AdLabel = new Label(); ! ! private TextField URLChoice; ! private TextField AdServer; ! private CheckboxGroup cbg = new CheckboxGroup(); ! private Checkbox formatMPEG; ! private Checkbox formatJPEG; ! private Button go; ! ! private PlayerPanel playerPanel = null; ! ! private BorderLayout borderLayout1 = new BorderLayout(); ! private GridBagLayout gridBagLayoutNorth = new GridBagLayout(); ! private GridBagLayout gridBagLayoutSouth = new GridBagLayout(); ! ! private boolean insVideo = false; ! ! private Socket mySocket = null; ! private DialogServer dialogServer; ! ! ! ! /** ! * Contructeur de la Classe Client ! */ ! ! public Client() { ! enableEvents(AWTEvent.WINDOW_EVENT_MASK); ! ! try { ! jbInit(); ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! } ! ! /** ! * setPlayerPanel crée l'interface graphique du Client ! * @param pp il s'agit d'un PlayerPanel qui est une classe que nous avons crée ! * @vid est un booleen qui nous dit si le player a cree est de la video ou de l'audio ! */ ! ! public void setPlayerPanel(PlayerPanel pp, boolean vid) { ! Panel panelTemp; ! ! if (playerPanel == null) { ! panelTemp = panelEmpty; ! } ! else ! ! { ! panelTemp = playerPanel; ! } ! System.out.println("video :" + vid); ! System.out.println("insvideo :" + insVideo); ! ! // on teste ici pour savoir si on doit cree un player video ou un player audio ! if (vid) { ! playerPanel = pp; ! contentPane.remove(panelTemp); ! contentPane.add(playerPanel, BorderLayout.CENTER); ! validate(); ! insVideo = true; ! } ! ! else if (!insVideo) { ! playerPanel = pp; ! contentPane.remove(panelTemp); ! contentPane.add(playerPanel, BorderLayout.CENTER); ! validate(); ! } ! } ! ! /** ! * jbinit lance la creation de l'interface graphique. ! */ ! private void jbInit() throws Exception { ! ! contentPane = this; ! contentPane.setLayout(borderLayout1); ! this.setSize(new Dimension(240, 320)); ! this.setTitle("Madsserv Client"); ! setAfficheStatusBar("coucou"); ! URLChoice = new TextField("file:/stud/users/promo04/carbonel/tmp/video/kiss_cool_1.mpeg"); ! AdServer = new TextField("fresnel.enst.fr:5000"); ! menuFile.setLabel("File"); ! menuOpenURL.setLabel("Open URL"); ! menuOpenURL.addActionListener(new Client_Menu_OpenURL_ActionAdapter(this)); ! menuFileExit.setLabel("Exit"); ! menuFileExit.addActionListener(new Client_menuFileExit_ActionAdapter(this)); ! menuFile.add(menuOpenURL); ! menuFile.add(menuFileExit); ! menuBar1.add(menuFile); ! this.setMenuBar(menuBar1); ! ! formatMPEG = new Checkbox("MPEG", cbg, true); ! ! formatJPEG = new Checkbox("JPEG", cbg, false); ! ! go = new Button("Go!"); ! go.setSize(new Dimension(60, 15)); ! go.addActionListener(new Client_boutongo_ActionAdapter(this)); ! ! panelNorth.setBackground(new Color(236, 233, 216)); ! panelSouth.setBackground(new Color(236, 233, 216)); ! ! panelSouth.setLayout(gridBagLayoutSouth); ! GridBagConstraints c = new GridBagConstraints(); ! c.fill = GridBagConstraints.BOTH; ! c.insets = new Insets(1, 5, 1, 5); ! c.weightx = 1.0; ! c.weighty = 1.0; ! panelSouth.add(formatMPEG, c); ! c.gridwidth = GridBagConstraints.RELATIVE; ! panelSouth.add(formatJPEG, c); ! c.weightx = 0.0; ! c.gridwidth = GridBagConstraints.REMAINDER; ! panelSouth.add(go, c); ! c.gridwidth = GridBagConstraints.REMAINDER; ! c.weightx = 0.0; ! c.gridwidth = 2; ! panelSouth.add(statusBar, c); ! ! URLLabel.setText("URL :"); ! AdLabel.setText("Serv:"); ! URLLabel.setSize(new Dimension(30, 15)); ! URLChoice.setSize(new Dimension(30, 15)); ! AdLabel.setSize(new Dimension(30, 15)); ! AdServer.setSize(new Dimension(30, 15)); ! ! panelNorth.setLayout(gridBagLayoutNorth); ! c.gridwidth = GridBagConstraints.RELATIVE; ! c.gridwidth = 1; ! c.weightx = 0.0; ! c.weighty = 1.0; ! panelNorth.add(URLLabel, c); ! c.weightx = 1.0; ! c.gridwidth = GridBagConstraints.REMAINDER; ! panelNorth.add(URLChoice, c); ! c.gridwidth = GridBagConstraints.RELATIVE; ! c.weightx = 0.0; ! panelNorth.add(AdLabel, c); ! c.weightx = 1.0; ! c.gridwidth = GridBagConstraints.RELATIVE; ! panelNorth.add(AdServer, c); ! ! contentPane.add(panelSouth, BorderLayout.SOUTH); ! contentPane.add(panelNorth, BorderLayout.NORTH); ! ! contentPane.add(panelEmpty, BorderLayout.CENTER); ! ! } ! ! /** ! * menuFileExit_actionPerformed est à l'ecoute d'un evenement signifiant l'arret du client ! * @param e c'est l'evenemet qui met fin au client ! */ ! public void menuFileExit_actionPerformed(ActionEvent e) { ! try { ! String messageToSend[] = new String[1]; ! messageToSend[0] = "fin de la connexion"; ! dialogServer.sendMessage(4, messageToSend); ! System.exit(0); ! } ! catch (Exception ex) { ! System.exit(0); ! } ! } ! ! /** ! * processWindowEvent Methode qui permet de quitter le client quand on clique pour fermer la fenetre ! * @param e c'est l'evenement qui indique que l'on a clique sur le bouton pour fermer la fenetre ! */ ! protected void processWindowEvent(WindowEvent e) { ! super.processWindowEvent(e); ! if (e.getID() == WindowEvent.WINDOW_CLOSING) { ! menuFileExit_actionPerformed(null); ! } ! } ! ! /** ! * boutongo_actionPerformed Methode qui permet de lancer la connexion lorsque l'on clique sur le bouton go ! * @param evt c'est l'evenement qui indique que l'on a clique sur le bouton go ! */ ! public void boutongo_actionPerformed(ActionEvent evt) { ! ! String[] messageToSend; ! ! if (mySocket == null) { ! try { ! mySocket = new Socket(getAddressServer(), getServerPort()); ! } ! catch (Exception e) { ! showError("Le serveur ou le port n'est pas correct"); ! } ! ! dialogServer = new DialogServer(mySocket, this); ! dialogServer.start(); ! } ! ! else { ! // if ( (mySocket.isClosed()) == false) { ! messageToSend = new String[2]; ! messageToSend[0] = getURL(); ! messageToSend[1] = getFormatPrefere(); ! ! dialogServer.sendMessage(2, messageToSend); ! /*} ! else { ! try { ! mySocket.connect(new InetSocketAddress(getAddressServer(), ! getServerPort())); ! } ! catch (Exception e) { ! } ! }*/ ! } ! } ! ! public void endConnexion() { ! dialogServer.stop(); ! mySocket = null; ! } ! ! public void showError(String messageErreur) ! { ! ErrorPopUp errorPopUp = new ErrorPopUp(messageErreur,this); ! } ! ! /** ! * getAddressServer, cette methode permet d'obtenir l'InetAddress du serveur sur lequel il faut se connecter, cette adresse est rentré à la main dans une zone de texte sur l'interface graphique du client ! * @return InetAddress du server ! */ ! public InetAddress getAddressServer() { ! String host; ! int columnPosition; ! ! host = AdServer.getText(); ! columnPosition = host.indexOf(':'); ! try { ! return (InetAddress.getByName(host.substring(0, columnPosition))); ! } ! ! catch (UnknownHostException e) { ! return (null); ! } ! } ! ! /** ! * getServerPorrt est une methode qui permet d'obtenir le Numero de port du serveur, ce numero de port est rentre dans une zone de texte sur l'interface graphique du client ! * @return int le numero du port sur lequel, on doit se connecter au serveur ! */ ! public int getServerPort() { ! String host; ! int columnPosition; ! ! host = AdServer.getText(); ! columnPosition = host.indexOf(':'); ! ! return (Integer.parseInt(host.substring(columnPosition + 1))); ! ! } ! ! /** ! * getURL permet d'obtenir l'URL du fichier multimedia que l'on souhaite visionner, cet URL est rentre dans une zone de texte sur l'interface graphique du client ! * @return String l'adresse du media demande ! */ ! public String getURL() { ! ! return (URLChoice.getText()); ! } ! ! public String getFormatPrefere() { ! ! if (formatMPEG.getState()) { ! return ("MPEG"); ! } ! ! else { ! if (formatJPEG.getState()) { ! return ("JPEG"); ! } ! else { ! return (""); ! } ! } ! ! } ! ! /** ! * setAfficheStatusBar est une methode qui permet d'afficher en bas du client un message envoye par le server ! * @param _message un message envoye sous forme de String envoye par le serveur ! */ ! public void setAfficheStatusBar(String _message) { ! statusBar.setText(_message); ! } ! ! /** ! * Client_menuFileExit_ActionAdapter, classe qui ecoute pour savoir si on clique sur le menu exit et envoie alors l'evenement ! */ ! class Client_menuFileExit_ActionAdapter ! implements ActionListener { ! Client adaptee; ! ! Client_menuFileExit_ActionAdapter(Client adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent e) { ! adaptee.menuFileExit_actionPerformed(e); ! } ! } ! ! /** ! * Client_boutongo_ActionAdapter classe qui ecoute pour savoir si on clique sur le bouton go et envoie alors l'evenement ! */ ! class Client_boutongo_ActionAdapter ! implements ActionListener { ! Client adaptee; ! ! Client_boutongo_ActionAdapter(Client adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent evt) { ! adaptee.boutongo_actionPerformed(evt); ! } ! } ! ! /** ! * Client_Menu_OpenURL_ActionAdapter classe qui ecoute pour savoir si on clique sur le bouton OpenURL et envoie alors l'evenement ! */ ! class Client_Menu_OpenURL_ActionAdapter ! implements ActionListener { ! Client adaptee; ! ! Client_Menu_OpenURL_ActionAdapter(Client adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent evt) { ! adaptee.boutongo_actionPerformed(evt); ! } ! } ! } --- 1,383 ---- ! //package madsserv_planification; ! ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.awt.Component.*; ! import java.awt.TextComponent.*; ! import java.awt.Checkbox.*; ! import java.awt.CheckboxGroup.*; ! import javax.swing.*; ! ! /** ! * <p>Title: Client </p> ! * <p>Description: La Classe Client est l'interface graphique du client</p> ! * <p>Copyright: Copyright (c) 2003</p> ! * <p>Company: Madsserv Corporation</p> ! * @author Xavier Deplancq ! * @version 1.0 ! */ ! ! public class Client ! extends Frame { ! /** ! * Champs de la Classe Reencode ! */ ! ! private Container contentPane; ! private Panel panelNorth = new Panel(); ! private Panel panelCenter = new Panel(); ! private Panel panelSouth = new Panel(); ! private Panel panelEmpty = new Panel(); ! private MenuBar menuBar1 = new MenuBar(); ! private Menu menuFile = new Menu(); ! private MenuItem menuOpenURL = new MenuItem(); ! private MenuItem menuFileExit = new MenuItem(); ! private Label statusBar = new Label(); ! private Label URLLabel = new Label(); ! private Label AdLabel = new Label(); ! ! private TextField URLChoice; ! private TextField AdServer; ! private CheckboxGroup cbg = new CheckboxGroup(); ! private Checkbox formatMPEG; ! private Checkbox formatJPEG; ! private Button go; ! ! private PlayerPanel playerPanel = null; ! ! private BorderLayout borderLayout1 = new BorderLayout(); ! private GridBagLayout gridBagLayoutNorth = new GridBagLayout(); ! private GridBagLayout gridBagLayoutSouth = new GridBagLayout(); ! ! private boolean insVideo = false; ! ! private Socket mySocket = null; ! private DialogServer dialogServer; ! ! ! ! /** ! * Contructeur de la Classe Client ! */ ! ! public Client() { ! enableEvents(AWTEvent.WINDOW_EVENT_MASK); ! ! try { ! jbInit(); ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! } ! ! /** ! * setPlayerPanel crée l'interface graphique du Client ! * @param pp il s'agit d'un PlayerPanel qui est une classe que nous avons crée ! * @vid est un booleen qui nous dit si le player a cree est de la video ou de l'audio ! */ ! ! public void setPlayerPanel(PlayerPanel pp, boolean vid) { ! Panel panelTemp; ! ! if (playerPanel == null) { ! panelTemp = panelEmpty; ! } ! else ! ! { ! panelTemp = playerPanel; ! } ! System.out.println("video :" + vid); ! System.out.println("insvideo :" + insVideo); ! ! // on teste ici pour savoir si on doit cree un player video ou un player audio ! if (vid) { ! playerPanel = pp; ! contentPane.remove(panelTemp); ! contentPane.add(playerPanel, BorderLayout.CENTER); ! validate(); ! insVideo = true; ! } ! ! else if (!insVideo) { ! playerPanel = pp; ! contentPane.remove(panelTemp); ! contentPane.add(playerPanel, BorderLayout.CENTER); ! validate(); ! } ! } ! ! /** ! * jbinit lance la creation de l'interface graphique. ! */ ! private void jbInit() throws Exception { ! ! contentPane = this; ! contentPane.setLayout(borderLayout1); ! this.setSize(new Dimension(240, 320)); ! this.setTitle("Madsserv Client"); ! setAfficheStatusBar("coucou"); ! URLChoice = new TextField("file:///c:\\temp\\kiss_cool_1.mpeg"); ! AdServer = new TextField("dronej.rezel.com:5001"); ! menuFile.setLabel("File"); ! menuOpenURL.setLabel("Open URL"); ! menuOpenURL.addActionListener(new Client_Menu_OpenURL_ActionAdapter(this)); ! menuFileExit.setLabel("Exit"); ! menuFileExit.addActionListener(new Client_menuFileExit_ActionAdapter(this)); ! menuFile.add(menuOpenURL); ! menuFile.add(menuFileExit); ! menuBar1.add(menuFile); ! this.setMenuBar(menuBar1); ! ! formatMPEG = new Checkbox("MPEG", cbg, true); ! ! formatJPEG = new Checkbox("JPEG", cbg, false); ! ! go = new Button("Go!"); ! go.setSize(new Dimension(60, 15)); ! go.addActionListener(new Client_boutongo_ActionAdapter(this)); ! ! panelNorth.setBackground(new Color(236, 233, 216)); ! panelSouth.setBackground(new Color(236, 233, 216)); ! ! panelSouth.setLayout(gridBagLayoutSouth); ! GridBagConstraints c = new GridBagConstraints(); ! c.fill = GridBagConstraints.BOTH; ! c.insets = new Insets(1, 5, 1, 5); ! c.weightx = 1.0; ! c.weighty = 1.0; ! panelSouth.add(formatMPEG, c); ! c.gridwidth = GridBagConstraints.RELATIVE; ! panelSouth.add(formatJPEG, c); ! c.weightx = 0.0; ! c.gridwidth = GridBagConstraints.REMAINDER; ! panelSouth.add(go, c); ! c.gridwidth = GridBagConstraints.REMAINDER; ! c.weightx = 0.0; ! c.gridwidth = 2; ! panelSouth.add(statusBar, c); ! ! URLLabel.setText("URL :"); ! AdLabel.setText("Serv:"); ! URLLabel.setSize(new Dimension(30, 15)); ! URLChoice.setSize(new Dimension(30, 15)); ! AdLabel.setSize(new Dimension(30, 15)); ! AdServer.setSize(new Dimension(30, 15)); ! ! panelNorth.setLayout(gridBagLayoutNorth); ! c.gridwidth = GridBagConstraints.RELATIVE; ! c.gridwidth = 1; ! c.weightx = 0.0; ! c.weighty = 1.0; ! panelNorth.add(URLLabel, c); ! c.weightx = 1.0; ! c.gridwidth = GridBagConstraints.REMAINDER; ! panelNorth.add(URLChoice, c); ! c.gridwidth = GridBagConstraints.RELATIVE; ! c.weightx = 0.0; ! panelNorth.add(AdLabel, c); ! c.weightx = 1.0; ! c.gridwidth = GridBagConstraints.RELATIVE; ! panelNorth.add(AdServer, c); ! ! contentPane.add(panelSouth, BorderLayout.SOUTH); ! contentPane.add(panelNorth, BorderLayout.NORTH); ! ! contentPane.add(panelEmpty, BorderLayout.CENTER); ! ! } ! ! /** ! * menuFileExit_actionPerformed est à l'ecoute d'un evenement signifiant l'arret du client ! * @param e c'est l'evenemet qui met fin au client ! */ ! public void menuFileExit_actionPerformed(ActionEvent e) { ! try { ! String messageToSend[] = new String[1]; ! messageToSend[0] = "fin de la connexion"; ! dialogServer.sendMessage(4, messageToSend); ! System.exit(0); ! } ! catch (Exception ex) { ! System.exit(0); ! } ! } ! ! /** ! * processWindowEvent Methode qui permet de quitter le client quand on clique pour fermer la fenetre ! * @param e c'est l'evenement qui indique que l'on a clique sur le bouton pour fermer la fenetre ! */ ! protected void processWindowEvent(WindowEvent e) { ! super.processWindowEvent(e); ! if (e.getID() == WindowEvent.WINDOW_CLOSING) { ! menuFileExit_actionPerformed(null); ! } ! } ! ! /** ! * boutongo_actionPerformed Methode qui permet de lancer la connexion lorsque l'on clique sur le bouton go ! * @param evt c'est l'evenement qui indique que l'on a clique sur le bouton go ! */ ! public void boutongo_actionPerformed(ActionEvent evt) { ! ! String[] messageToSend; ! ! if (mySocket == null) { ! try { ! mySocket = new Socket(getAddressServer(), getServerPort()); ! } ! catch (Exception e) { ! showError("serveur ou port incorrect"); ! } ! ! dialogServer = new DialogServer(mySocket, this); ! dialogServer.start(); ! } ! ! else { ! // if ( (mySocket.isClosed()) == false) { ! messageToSend = new String[2]; ! messageToSend[0] = getURL(); ! messageToSend[1] = getFormatPrefere(); ! ! dialogServer.sendMessage(2, messageToSend); ! /*} ! else { ! try { ! mySocket.connect(new InetSocketAddress(getAddressServer(), ! getServerPort())); ! } ! catch (Exception e) { ! } ! }*/ ! } ! } ! ! public void endConnexion() { ! dialogServer.stop(); ! mySocket = null; ! } ! ! public void showError(String messageErreur) ! { ! ErrorPopUp errorPopUp = new ErrorPopUp(messageErreur,this); ! } ! ! /** ! * getAddressServer, cette methode permet d'obtenir l'InetAddress du serveur sur lequel il faut se connecter, cette adresse est rentré à la main dans une zone de texte sur l'interface graphique du client ! * @return InetAddress du server ! */ ! public InetAddress getAddressServer() { ! String host; ! int columnPosition; ! ! host = AdServer.getText(); ! columnPosition = host.indexOf(':'); ! try { ! return (InetAddress.getByName(host.substring(0, columnPosition))); ! } ! ! catch (UnknownHostException e) { ! return (null); ! } ! } ! ! /** ! * getServerPorrt est une methode qui permet d'obtenir le Numero de port du serveur, ce numero de port est rentre dans une zone de texte sur l'interface graphique du client ! * @return int le numero du port sur lequel, on doit se connecter au serveur ! */ ! public int getServerPort() { ! String host; ! int columnPosition; ! ! host = AdServer.getText(); ! columnPosition = host.indexOf(':'); ! ! return (Integer.parseInt(host.substring(columnPosition + 1))); ! ! } ! ! /** ! * getURL permet d'obtenir l'URL du fichier multimedia que l'on souhaite visionner, cet URL est rentre dans une zone de texte sur l'interface graphique du client ! * @return String l'adresse du media demande ! */ ! public String getURL() { ! ! return (URLChoice.getText()); ! } ! ! public String getFormatPrefere() { ! ! if (formatMPEG.getState()) { ! return ("MPEG"); ! } ! ! else { ! if (formatJPEG.getState()) { ! return ("JPEG"); ! } ! else { ! return (""); ! } ! } ! ! } ! ! /** ! * setAfficheStatusBar est une methode qui permet d'afficher en bas du client un message envoye par le server ! * @param _message un message envoye sous forme de String envoye par le serveur ! */ ! public void setAfficheStatusBar(String _message) { ! statusBar.setText(_message); ! } ! ! /** ! * Client_menuFileExit_ActionAdapter, classe qui ecoute pour savoir si on clique sur le menu exit et envoie alors l'evenement ! */ ! class Client_menuFileExit_ActionAdapter ! implements ActionListener { ! Client adaptee; ! ! Client_menuFileExit_ActionAdapter(Client adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent e) { ! adaptee.menuFileExit_actionPerformed(e); ! } ! } ! ! /** ! * Client_boutongo_ActionAdapter classe qui ecoute pour savoir si on clique sur le bouton go et envoie alors l'evenement ! */ ! class Client_boutongo_ActionAdapter ! implements ActionListener { ! Client adaptee; ! ! Client_boutongo_ActionAdapter(Client adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent evt) { ! adaptee.boutongo_actionPerformed(evt); ! } ! } ! ! /** ! * Client_Menu_OpenURL_ActionAdapter classe qui ecoute pour savoir si on clique sur le bouton OpenURL et envoie alors l'evenement ! */ ! class Client_Menu_OpenURL_ActionAdapter ! implements ActionListener { ! Client adaptee; ! ! Client_Menu_OpenURL_ActionAdapter(Client adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent evt) { ! adaptee.boutongo_actionPerformed(evt); ! } ! } ! } Index: ClientRTPManager.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/ClientRTPManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ClientRTPManager.java 14 Mar 2003 03:26:18 -0000 1.5 --- ClientRTPManager.java 15 Mar 2003 22:47:30 -0000 1.6 *************** *** 1,604 **** ! import java.io.*; ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.util.Vector; ! ! import javax.media.*; ! import javax.media.rtp.*; ! import javax.media.rtp.event.*; ! import javax.media.rtp.rtcp.*; [...1179 lines suppressed...] ! prUsage(); ! ClientRTPManager avReceive = new ClientRTPManager(argv); ! if (!avReceive.initialize()) { ! System.err.println("Failed to initialize the sessions."); ! System.exit(-1); ! } ! // Check to see if ClientRTPManager is done. ! try { ! while (!avReceive.isDone()) ! Thread.sleep(1000); ! } catch (Exception e) {} ! System.err.println("Exiting AVReceive2"); ! } ! static void prUsage() { ! System.err.println("Usage: AVReceive2 <session> <session> ..."); ! System.err.println(" <session>: <address>/<port>/<ttl>"); ! System.exit(0); ! } ! */ ! } // end of ClientRTPManager Index: DialogServer.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/DialogServer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DialogServer.java 14 Mar 2003 03:26:18 -0000 1.6 --- DialogServer.java 15 Mar 2003 22:47:30 -0000 1.7 *************** *** 1,169 **** ! import java.util.*; ! import java.io.*; ! import java.net.*; ! import java.lang.Object.*; ! import java.lang.System.*; ! ! /** ! * DialogServer c'est la classe qui herite de la classe dialogSocket et qui gere les dialogues avec le serveur ! */ ! public class DialogServer ! extends DialogSocket { ! ! private Client client; ! private ThreadRTPManager threadRTPManager; ! private String[] sessions = new String[2]; ! /** ! * C'est le constructeur de la classe ! */ ! public DialogServer(Socket _socketServer, Client _client) { ! super(_socketServer); ! client = _client; ! clientID = -1; ! } ! ! /** ! * incomingMessage methode qui a ete declare abstraite dans DialogSocket et qui gere l'arivee de nouveaux messages du serveur ! * @param _type type de message qui arrive (c'est un entier) ! * @param _message tableau de chaine de characteres qui contient les messages du serveur ! */ ! public void incomingMessage(int _type, String[] _message) { ! int lgth = _message.length; ! int portBase = 40000; ! String[] messageToSend; ! String sessionTemp; ! Integer port1, port2; ! ! switch (_type) { ! ! case 9: { ! // if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! try { ! client.setAfficheStatusBar(_message[1]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le troisieme champ du message est incorrect"); ! } ! break; ! } ! ! case 7: { ! //if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! client.showError(_message[1]); ! ! threadRTPManager.Fermer(); ! client.endConnexion(); ! System.out.println("coucou de fin"); ! break; ! } ! ! case 5: { ! //if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! System.out.println(_message[1]); ! ! threadRTPManager.Fermer(); ! client.endConnexion(); ! System.out.println("coucou de fin"); ! break; ! } ! ! case 3: { ! // if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! /** ! *on regarde si le threadRTPManager existe, si il n'existe pas on le cree, sinon on le detruit et on en cree un nouveau ! */ ! if (threadRTPManager == null) { ! threadRTPManager = new ThreadRTPManager(sessions, client); ! threadRTPManager.start(); ! } ! ! else { ! ! threadRTPManager.Fermer(); ! threadRTPManager = null; ! System.gc(); ! threadRTPManager = new ThreadRTPManager(sessions, client); ! threadRTPManager.start(); ! } ! ! break; ! ! } ! case 1: { ! // if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! // lecture du troisieme champ du message : portBase ! try { ! portBase = Integer.parseInt(_message[1]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le troisieme champ du message est incorrect"); ! } ! ! /** ! * On stocke dans le variable sessions, l'adresse du server et les ports pour les diffusions audio et video ! */ ! sessionTemp = client.getAddressServer().getHostAddress().toString(); ! sessionTemp = sessionTemp.concat("/"); ! port1 = new Integer(portBase); ! sessionTemp = sessionTemp.concat(port1.toString()); ! sessions[0] = sessionTemp; ! sessionTemp = ""; ! sessionTemp = client.getAddressServer().getHostAddress().toString(); ! sessionTemp = sessionTemp.concat("/"); ! port2 = new Integer(portBase + 2); ! sessionTemp = sessionTemp.concat(port2.toString()); ! sessions[1] = sessionTemp; ! ! System.out.println(sessions[0]); ! System.out.println(sessions[1]); ! ! messageToSend = new String[2]; ! ! messageToSend[0] = client.getURL(); ! messageToSend[1] = client.getFormatPrefere(); ! ! sendMessage(2, messageToSend); ! } ! } ! } } --- 1,169 ---- ! import java.util.*; ! import java.io.*; ! import java.net.*; ! import java.lang.Object.*; ! import java.lang.System.*; ! ! /** ! * DialogServer c'est la classe qui herite de la classe dialogSocket et qui gere les dialogues avec le serveur ! */ ! public class DialogServer ! extends DialogSocket { ! ! private Client client; ! private ThreadRTPManager threadRTPManager; ! private String[] sessions = new String[2]; ! /** ! * C'est le constructeur de la classe ! */ ! public DialogServer(Socket _socketServer, Client _client) { ! super(_socketServer); ! client = _client; ! clientID = -1; ! } ! ! /** ! * incomingMessage methode qui a ete declare abstraite dans DialogSocket et qui gere l'arivee de nouveaux messages du serveur ! * @param _type type de message qui arrive (c'est un entier) ! * @param _message tableau de chaine de characteres qui contient les messages du serveur ! */ ! public void incomingMessage(int _type, String[] _message) { ! int lgth = _message.length; ! int portBase = 40000; ! String[] messageToSend; ! String sessionTemp; ! Integer port1, port2; ! ! switch (_type) { ! ! case 9: { ! // if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! try { ! client.setAfficheStatusBar(_message[1]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le troisieme champ du message est incorrect"); ! } ! break; ! } ! ! case 7: { ! //if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! client.showError(_message[1]); ! ! threadRTPManager.Fermer(); ! client.endConnexion(); ! System.out.println("coucou de fin"); ! break; ! } ! ! case 5: { ! //if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! System.out.println(_message[1]); ! ! threadRTPManager.Fermer(); ! client.endConnexion(); ! System.out.println("coucou de fin"); ! break; ! } ! ! case 3: { ! // if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! /** ! *on regarde si le threadRTPManager existe, si il n'existe pas on le cree, sinon on le detruit et on en cree un nouveau ! */ ! if (threadRTPManager == null) { ! threadRTPManager = new ThreadRTPManager(sessions, client); ! threadRTPManager.start(); ! } ! ! else { ! ! threadRTPManager.Fermer(); ! threadRTPManager = null; ! System.gc(); ! threadRTPManager = new ThreadRTPManager(sessions, client); ! threadRTPManager.start(); ! } ! ! break; ! ! } ! case 1: { ! // if (lgth < 2) raise exception; ! //lecture du deuxieme champ : ClientID ! try { ! clientID = Integer.parseInt(_message[0]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le deuxieme champ du message est incorrect"); ! } ! ! // lecture du troisieme champ du message : portBase ! try { ! portBase = Integer.parseInt(_message[1]); ! } ! catch (NumberFormatException e) { ! System.out.println("Le troisieme champ du message est incorrect"); ! } ! ! /** ! * On stocke dans le variable sessions, l'adresse du server et les ports pour les diffusions audio et video ! */ ! sessionTemp = client.getAddressServer().getHostAddress().toString(); ! sessionTemp = sessionTemp.concat("/"); ! port1 = new Integer(portBase); ! sessionTemp = sessionTemp.concat(port1.toString()); ! sessions[0] = sessionTemp; ! sessionTemp = ""; ! sessionTemp = client.getAddressServer().getHostAddress().toString(); ! sessionTemp = sessionTemp.concat("/"); ! port2 = new Integer(portBase + 2); ! sessionTemp = sessionTemp.concat(port2.toString()); ! sessions[1] = sessionTemp; ! ! System.out.println(sessions[0]); ! System.out.println(sessions[1]); ! ! messageToSend = new String[2]; ! ! messageToSend[0] = client.getURL(); ! messageToSend[1] = client.getFormatPrefere(); ! ! sendMessage(2, messageToSend); ! } ! } ! } } Index: ErrorPopUp.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/ErrorPopUp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ErrorPopUp.java 14 Mar 2003 03:26:18 -0000 1.2 --- ErrorPopUp.java 15 Mar 2003 22:47:30 -0000 1.3 *************** *** 1,114 **** ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.awt.Component.*; ! import java.awt.TextComponent.*; ! import java.awt.geom.Point2D.*; ! import java.awt.Point.*; ! ! /** ! * <code>ErrorPopUp</code> est une popup qui apparait lorsque des erreurs apparaissent. ! * @author Xavier Deplancq ! */ ! ! public class ErrorPopUp ! extends Frame { ! private Container contentPane; ! private Panel panelNorth = new Panel(); ! private Panel panelSouth = new Panel(); ! private Label errorMessage = new Label(); ! private BorderLayout borderLayout1 = new BorderLayout(); ! private Button OK; ! ! /** ! * Constructeur de la classe ErrorPopUp ! * @param errMessage le Message qui doit etre affiche ! * @param _client la reference du client ! */ ! ! public ErrorPopUp(String errMessage, Client _client) { ! enableEvents(AWTEvent.WINDOW_EVENT_MASK); ! ! errorMessage.setText(errMessage); ! panelNorth.add(errorMessage); ! OK = new Button("OK"); ! OK.setSize(new Dimension(60, 15)); ! OK.addActionListener(new ErrorPopUp_OK_ActionAdapter(this)); ! panelSouth.add(OK); ! contentPane = this; ! this.setSize(220, 90); ! panelNorth.setBackground(new Color(236, 233, 216)); ! panelSouth.setBackground(new Color(236, 233, 216)); ! ! contentPane.setLayout(borderLayout1); ! contentPane.add(panelNorth, borderLayout1.CENTER); ! contentPane.add(panelSouth, borderLayout1.SOUTH); ! ! //On place la boite de dialogue ! Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); ! Dimension clientSize = _client.getSize(); ! Dimension popupSize = this.getSize(); ! double clientPlaceX = _client.getX(); ! double clientPlaceY = _client.getY(); ! if (popupSize.height > clientSize.height) { ! popupSize.height = clientSize.height; ! } ! if (popupSize.width > clientSize.width) { ! popupSize.width = clientSize.width; ! } ! this.setLocation( (int) (clientPlaceX) /*+ ! ( ! clientSize.height - popupSize.height) / 2*/, ! (int) (clientPlaceY) + clientSize.width / 2); ! ! showWindow(); ! ! } ! ! /** ! * OK_actionPerformed qui sert lorsque l'on appuie sur le bouton OK ! * @param e l'evenement ! */ ! ! public void OK_actionPerformed(ActionEvent e) { ! setVisible(false); ! } ! ! /** ! * processWindowEvent c est une methode qui est appele lorsque l'on ferme la boite de dialogue ! * @param l evenement qui indique que l'on ferme la fenetre ! */ ! ! protected void processWindowEvent(WindowEvent e) { ! super.processWindowEvent(e); ! if (e.getID() == WindowEvent.WINDOW_CLOSING) { ! OK_actionPerformed(null); ! } ! } ! ! /** ! * Methode qui affiche la boite de dialogue ! */ ! ! public void showWindow() { ! setVisible(true); ! } ! ! /** ! * Classe qui ecoute si l'on appui sur le bouton OK ! */ ! ! class ErrorPopUp_OK_ActionAdapter ! implements ActionListener { ! ErrorPopUp adaptee; ! ! ErrorPopUp_OK_ActionAdapter(ErrorPopUp adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent e) { ! adaptee.OK_actionPerformed(e); ! } ! } ! ! } \ No newline at end of file --- 1,112 ---- ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.awt.Component.*; ! import java.awt.TextComponent.*; ! import java.awt.geom.Point2D.*; ! import java.awt.Point.*; ! ! /** ! * <code>ErrorPopUp</code> est une popup qui apparait lorsque des erreurs apparaissent. ! * @author Xavier Deplancq ! */ ! ! public class ErrorPopUp ! extends Frame { ! private Container contentPane; ! private Panel panelNorth = new Panel(); ! private Panel panelSouth = new Panel(); ! private Label errorMessage = new Label(); ! private BorderLayout borderLayout1 = new BorderLayout(); ! private Button OK; ! ! /** ! * Constructeur de la classe ErrorPopUp ! * @param errMessage le Message qui doit etre affiche ! * @param _client la reference du client ! */ ! ! public ErrorPopUp(String errMessage, Client _client) { ! enableEvents(AWTEvent.WINDOW_EVENT_MASK); ! ! errorMessage.setText(errMessage); ! panelNorth.add(errorMessage); ! OK = new Button("OK"); ! OK.setSize(new Dimension(60, 15)); ! OK.addActionListener(new ErrorPopUp_OK_ActionAdapter(this)); ! panelSouth.add(OK); ! contentPane = this; ! this.setSize(240, 120); ! panelNorth.setBackground(new Color(236, 233, 216)); ! panelSouth.setBackground(new Color(236, 233, 216)); ! ! contentPane.setLayout(borderLayout1); ! contentPane.add(panelNorth, borderLayout1.CENTER); ! contentPane.add(panelSouth, borderLayout1.SOUTH); ! ! //On place la boite de dialogue ! Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); ! Dimension clientSize = _client.getSize(); ! Dimension popupSize = this.getSize(); ! double clientPlaceX = _client.getX(); ! double clientPlaceY = _client.getY(); ! if (popupSize.height > clientSize.height) { ! popupSize.height = clientSize.height; ! } ! if (popupSize.width > clientSize.width) { ! popupSize.width = clientSize.width; ! } ! this.setLocation( (int) (clientPlaceX), ! (int) (clientPlaceY) + clientSize.width / 2); ! ! showWindow(); ! ! } ! ! /** ! * OK_actionPerformed qui sert lorsque l'on appuie sur le bouton OK ! * @param e l'evenement ! */ ! ! public void OK_actionPerformed(ActionEvent e) { ! setVisible(false); ! } ! ! /** ! * processWindowEvent c est une methode qui est appele lorsque l'on ferme la boite de dialogue ! * @param l evenement qui indique que l'on ferme la fenetre ! */ ! ! protected void processWindowEvent(WindowEvent e) { ! super.processWindowEvent(e); ! if (e.getID() == WindowEvent.WINDOW_CLOSING) { ! OK_actionPerformed(null); ! } ! } ! ! /** ! * Methode qui affiche la boite de dialogue ! */ ! ! public void showWindow() { ! setVisible(true); ! } ! ! /** ! * Classe qui ecoute si l'on appui sur le bouton OK ! */ ! ! class ErrorPopUp_OK_ActionAdapter ! implements ActionListener { ! ErrorPopUp adaptee; ! ! ErrorPopUp_OK_ActionAdapter(ErrorPopUp adaptee) { ! this.adaptee = adaptee; ! } ! ! public void actionPerformed(ActionEvent e) { ! adaptee.OK_actionPerformed(e); ! } ! } ! ! } Index: MadsservClient.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/MadsservClient.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MadsservClient.java 14 Mar 2003 03:26:18 -0000 1.5 --- MadsservClient.java 15 Mar 2003 22:47:30 -0000 1.6 *************** *** 1,75 **** ! //package madsserv_planification; ! ! import javax.swing.UIManager; ! import java.awt.*; ! import java.net.*; ! ! /** ! * <p>Title: MadsservClient</p> ! * <p>Description: La Classe MadsservClient contient la classe main du client du projet, c'est lui qui le lance</p> ! * <p>Copyright: Copyright (c) 2003</p> ! * <p>Company: Madsserv Corporation</p> ! * @author Xavier Deplancq ! * @version 1.0 ! **/ ! ! /** ! * MadsservClient c'est la classe MadsservClient ! */ ! public class MadsservClient { ! /** ! * champs de la classe MadsservClient ! */ ! private boolean packFrame = false; ! ! /** ! * MadsservClient constructeur de la calsse ! */ ! public MadsservClient() { ! ! Client frame = new Client(); ! ! //Validate frames that have preset sizes ! //Pack frames that have useful preferred size info, e.g. from their layout ! if (packFrame) { ! frame.pack(); ! } ! else { ! frame.validate(); ! } ! ! //on centre ici la fenetre ! Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); ! Dimension frameSize = frame.getSize(); ! if (frameSize.height > screenSize.height) { ! frameSize.height = screenSize.height; ! } ! if (frameSize.width > screenSize.width) { ! frameSize.width = screenSize.width; ! } ! frame.setLocation( (screenSize.width - frameSize.width) / 2, ! (screenSize.height - frameSize.height) / 2); ! frame.setVisible(true); ! } ! ! /** ! * Methode main de MadsservClient ! */ ! ! public static void main(String[] args) { ! try { ! UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! new MadsservClient(); ! } ! ! static void prUsage() { ! System.err.println("Usage: ClientRTPManager <session> <session> ..."); ! System.err.println(" <session>: <address>/<port>/<ttl>"); ! System.exit(0); ! } ! } --- 1,75 ---- ! //package madsserv_planification; ! ! import javax.swing.UIManager; ! import java.awt.*; ! import java.net.*; ! ! /** ! * <p>Title: MadsservClient</p> ! * <p>Description: La Classe MadsservClient contient la classe main du client du projet, c'est lui qui le lance</p> ! * <p>Copyright: Copyright (c) 2003</p> ! * <p>Company: Madsserv Corporation</p> ! * @author Xavier Deplancq ! * @version 1.0 ! **/ ! ! /** ! * MadsservClient c'est la classe MadsservClient ! */ ! public class MadsservClient { ! /** ! * champs de la classe MadsservClient ! */ ! private boolean packFrame = false; ! ! /** ! * MadsservClient constructeur de la calsse ! */ ! public MadsservClient() { ! ! Client frame = new Client(); ! ! //Validate frames that have preset sizes ! //Pack frames that have useful preferred size info, e.g. from their layout ! if (packFrame) { ! frame.pack(); ! } ! else { ! frame.validate(); ! } ! ! //on centre ici la fenetre ! Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); ! Dimension frameSize = frame.getSize(); ! if (frameSize.height > screenSize.height) { ! frameSize.height = screenSize.height; ! } ! if (frameSize.width > screenSize.width) { ! frameSize.width = screenSize.width; ! } ! frame.setLocation( (screenSize.width - frameSize.width) / 2, ! (screenSize.height - frameSize.height) / 2); ! frame.setVisible(true); ! } ! ! /** ! * Methode main de MadsservClient ! */ ! ! public static void main(String[] args) { ! try { ! UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! new MadsservClient(); ! } ! ! static void prUsage() { ! System.err.println("Usage: ClientRTPManager <session> <session> ..."); ! System.err.println(" <session>: <address>/<port>/<ttl>"); ! System.exit(0); ! } ! } Index: PlayerPanel.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/PlayerPanel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PlayerPanel.java 14 Mar 2003 03:26:18 -0000 1.4 --- PlayerPanel.java 15 Mar 2003 22:47:30 -0000 1.5 *************** *** 1,66 **** ! import java.io.*; ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.util.Vector; ! ! import javax.media.*; ! import javax.media.rtp.*; ! import javax.media.rtp.event.*; ! import javax.media.rtp.rtcp.*; ! import javax.media.protocol.*; ! import javax.media.protocol.DataSource; ! import javax.media.format.AudioFormat; ! import javax.media.format.VideoFormat; ! import javax.media.Format; ! import javax.media.format.FormatChangeEvent; ! import javax.media.control.BufferControl; ! ! /** ! * Classe playerpanel qui crée l'interphace graphique des players ! * @author : Xavier Deplancq ! */ ! public class PlayerPanel ! extends Panel { ! /** ! * champs de la classe ! */ ! private Component vc, cc; ! // champs qui est mis à true lorsque l'on doit crée l'interface du player video ! boolean video = false; ! ! PlayerPanel(Player p) { ! setLayout(new BorderLayout()); ! //on regarde si c'est un flux video qui arrive ! if ( (vc = p.getVisualComponent()) != null) { ! add("Center", vc); ! video = true; ! } ! if ( (cc = p.getControlPanelComponent()) != null) { ! add("South", cc); ! } ! } ! /** ! * getPrefferedSize methode qui retourne les dimensions du player ! * @return Dimension, celles du player ! */ ! public Dimension getPreferredSize() { ! int w = 0, h = 0; ! if (vc != null) { ! Dimension size = vc.getPreferredSize(); ! w = size.width; ! h = size.height; ! } ! if (cc != null) { ! Dimension size = cc.getPreferredSize(); ! if (w == 0) { ! w = size.width; ! } ! h += size.height; ! } ! if (w < 160) { ! w = 160; ! } ! return new Dimension(w, h); ! } ! } --- 1,66 ---- ! import java.io.*; ! import java.awt.*; ! import java.net.*; ! import java.awt.event.*; ! import java.util.Vector; ! ! import javax.media.*; ! import javax.media.rtp.*; ! import javax.media.rtp.event.*; ! import javax.media.rtp.rtcp.*; ! import javax.media.protocol.*; ! import javax.media.protocol.DataSource; ! import javax.media.format.AudioFormat; ! import javax.media.format.VideoFormat; ! import javax.media.Format; ! import javax.media.format.FormatChangeEvent; ! import javax.media.control.BufferControl; ! ! /** ! * Classe playerpanel qui crée l'interphace graphique des players ! * @author : Xavier Deplancq ! */ ! public class PlayerPanel ! extends Panel { ! /** ! * champs de la classe ! */ ! private Component vc, cc; ! // champs qui est mis à true lorsque l'on doit crée l'interface du player video ! boolean video = false; ! ! PlayerPanel(Player p) { ! setLayout(new BorderLayout()); ! //on regarde si c'est un flux video qui arrive ! if ( (vc = p.getVisualComponent()) != null) { ! add("Center", vc); ! video = true; ! } ! if ( (cc = p.getControlPanelComponent()) != null) { ! add("South", cc); ! } ! } ! /** ! * getPrefferedSize methode qui retourne les dimensions du player ! * @return Dimension, celles du player ! */ ! public Dimension getPreferredSize() { ! int w = 0, h = 0; ! if (vc != null) { ! Dimension size = vc.getPreferredSize(); ! w = size.width; ! h = size.height; ! } ! if (cc != null) { ! Dimension size = cc.getPreferredSize(); ! if (w == 0) { ! w = size.width; ! } ! h += size.height; ! } ! if (w < 160) { ! w = 160; ! } ! return new Dimension(w, h); ! } ! } Index: ThreadRTPManager.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/ThreadRTPManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ThreadRTPManager.java 14 Mar 2003 03:26:18 -0000 1.6 --- ThreadRTPManager.java 15 Mar 2003 22:47:30 -0000 1.7 *************** *** 1,51 **** ! import java.util.*; ! import java.io.*; ! import java.net.*; ! ! /** ! * ThreadRTPManager est une methode qui cree un clientRTPManager ! * @author : Xavier Deplancq ! */ ! public class ThreadRTPManager extends Thread { ! ! /** ! * champs de la classe ClientRTPManager ! */ ! private ClientRTPManager clientRTPManager; ! private Client cl; ! ! public ThreadRTPManager(String sessionServer[], Client cl) ! { ! clientRTPManager = new ClientRTPManager(sessionServer, cl); ! } ! ! /** ! * methode run de ce thread ! */ ! public void Fermer() ! { ! clientRTPManager.close(); ! } ! ! public void run() ! { ! if (!clientRTPManager.initialize()) { ! System.err.println("Failed to initialize the sessions."); ! System.exit( -1); ! } ! ! try { ! while (!clientRTPManager.isDone()) ! Thread.sleep(1000); ! } ! catch (Exception e) { ! cl.showError("La connexion n'a pas pu etre initialise"); ! } ! ! finally { ! ! System.err.println("Exiting ThreadRTPManager"); ! System.out.println(Thread.currentThread()); ! } ! } ! } --- 1,51 ---- ! import java.util.*; ! import java.io.*; ! import java.net.*; ! ! /** ! * ThreadRTPManager est une methode qui cree un clientRTPManager ! * @author : Xavier Deplancq ! */ ! public class ThreadRTPManager extends Thread { ! ! /** ! * champs de la classe ClientRTPManager ! */ ! private ClientRTPManager clientRTPManager; ! private Client cl; ! ! public ThreadRTPManager(String sessionServer[], Client cl) ! { ! clientRTPManager = new ClientRTPManager(sessionServer, cl); ! } ! ! /** ! * methode run de ce thread ! */ ! public void Fermer() ! { ! clientRTPManager.close(); ! } ! ! public void run() ! { ! if (!clientRTPManager.initialize()) { ! System.err.println("Failed to initialize the sessions."); ! System.exit( -1); ! } ! ! try { ! while (!clientRTPManager.isDone()) ! Thread.sleep(1000); ! } ! catch (Exception e) { ! cl.showError("La connexion n'a pas pu etre initialise"); ! } ! ! finally { ! ! System.err.println("Exiting ThreadRTPManager"); ! System.out.println(Thread.currentThread()); ! } ! } ! } Index: ThreadRead.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/ThreadRead.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ThreadRead.java 14 Mar 2003 03:26:18 -0000 1.3 --- ThreadRead.java 15 Mar 2003 22:47:30 -0000 1.4 *************** *** 1,98 **** ! import java.util.*; ! import java.io.*; ! import java.net.*; ! ! /** ! * <code>ThreadRead</code> definit un thread d'ecoute sur un {@link BufferedReader}. ! * Il effectue une ecoute permanente. ! * <p> ! * Il gere l'extraction du message en isolant les elements protocolaires de la ! * transmission du message. ! * @see ThreadWrite ! * @see DialogSocket ! * @author Julien Carbonell ! */ ! ! public class ThreadRead ! extends Thread { ! ! boolean end = false; ! ! // objet parent qui gere les entrees-sorties sur le socket ! protected DialogSocket parent; ! ! // BufferedReader sur lequel sont lus les messages ! protected BufferedReader binput; ! ! protected String temp = ""; ! protected String message = ""; ! protected boolean waitingMessage = true; ! protected int messageType = -1; ! ! /** ! * Constructeur de <code>ThreadRead</code>. ! * @param _name le nom du thread. ! * @param _binput le {@link BufferedReader} sur lequel lit <code>ThreadRead</code>. ! * @param _parent le {@link DialogSocket} qui gere le <code>ThreadRead</code>. ! */ ! public ThreadRead(String _name, BufferedReader _binput, ! DialogSocket _parent) { ! super(_name + _parent.getClientID()); ! parent = _parent; ! binput = _binput; ! } ! ! /** ! * Redefinit la methode <code>run</code> de la classe parent <code>Thread</code>. ! */ ! public void run() { ! try { ! while ( (temp = binput.readLine()) != null) { ! if (temp != null) { ! if (waitingMessage && (temp.charAt(0) == '#')) { ! // un nouveau message commence ! waitingMessage = false; ! } ! else { ! if (!waitingMessage && (temp.charAt(0) == '#')) { ! waitingMessage = true; ! messageType = Integer.parseInt(message.substring(0, ! message.indexOf('\n'))); ! System.out.println("Le Thread Read a recu\n" + message); ! message = message.substring(message.indexOf('\n') + 1, ! message.length() - 1); ! parent.incomingMessage(messageType, parseMessage(message)); ! message = ""; ! } ! else { ! message = message.concat(temp + "\n"); ! } ! } ! } ! ! } ! } ! /* catch (SocketTimeoutException e) { ! System.out.println(e.getMessage()); ! }*/ ! catch (Exception e) { ! e.printStackTrace(); ! } ! finally { ! try { ! // binput.close(); ! System.out.println(getName() + Thread.currentThread() + ! " : Stopped !!! "); ! } ! catch (Exception e) { ! System.out.println(e.getMessage()); ! } ! } ! ! } ! ! protected String[] parseMessage(String _message) { ! return _message.split("\n"); ! } ! } --- 1,98 ---- ! import java.util.*; ! import java.io.*; ! import java.net.*; ! ! /** ! * <code>ThreadRead</code> definit un thread d'ecoute sur un {@link BufferedReader}. ! * Il effectue une ecoute permanente. ! * <p> ! * Il gere l'extraction du message en isolant les elements protocolaires de la ! * transmission du message. ! * @see ThreadWrite ! * @see DialogSocket ! * @author Julien Carbonell ! */ ! ! public class ThreadRead ! extends Thread { ! ! boolean end = false; ! ! // objet parent qui gere les entrees-sorties sur le socket ! protected DialogSocket parent; ! ! // BufferedReader sur lequel sont lus les messages ! protected BufferedReader binput; ! ! protected String temp = ""; ! protected String message = ""; ! protected boolean waitingMessage = true; ! protected int messageType = -1; ! ! /** ! * Constructeur de <code>ThreadRead</code>. ! * @param _name le nom du thread. ! * @param _binput le {@link BufferedReader} sur lequel lit <code>ThreadRead</code>. ! * @param _parent le {@link DialogSocket} qui gere le <code>ThreadRead</code>. ! */ ! public ThreadRead(String _name, BufferedReader _binput, ! DialogSocket _parent) { ! super(_name + _parent.getClientID()); ! parent = _parent; ! binput = _binput; ! } ! ! /** ! * Redefinit la methode <code>run</code> de la classe parent <code>Thread</code>. ! */ ! public void run() { ! try { ! while ( (temp = binput.readLine()) != null) { ! if (temp != null) { ! if (waitingMessage && (temp.charAt(0) == '#')) { ! // un nouveau message commence ! waitingMessage = false; ! } ! else { ! if (!waitingMessage && (temp.charAt(0) == '#')) { ! waitingMessage = true; ! messageType = Integer.parseInt(message.substring(0, ! message.indexOf('\n'))); ! System.out.println("Le Thread Read a recu\n" + message); ! message = message.substring(message.indexOf('\n') + 1, ! message.length() - 1); ! parent.incomingMessage(messageType, parseMessage(message)); ! message = ""; ! } ! else { ! message = message.concat(temp + "\n"); ! } ! } ! } ! ! } ! } ! /* catch (SocketTimeoutException e) { ! System.out.println(e.getMessage()); ! }*/ ! catch (Exception e) { ! e.printStackTrace(); ! } ! finally { ! try { ! // binput.close(); ! System.out.println(getName() + Thread.currentThread() + ! " : Stopped !!! "); ! } ! catch (Exception e) { ! System.out.println(e.getMessage()); ! } ! } ! ! } ! ! protected String[] parseMessage(String _message) { ! return _message.split("\n"); ! } ! } Index: ThreadWrite.java =================================================================== RCS file: /cvsroot/madsserv/madsserv/src/client/ThreadWrite.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 ***... [truncated message content] |