?? panelparticipants.java
字號:
/* * @(#)PanelParticipants.java 1.3 00/03/20 * * Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */package jmapps.rtp;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.media.rtp.*;import javax.media.rtp.rtcp.*;import javax.media.rtp.event.*;import com.sun.media.util.JMFI18N;import com.sun.media.rtp.util.Signed;import jmapps.ui.*;public class PanelParticipants extends JMPanel implements ComponentListener, ActionListener, SessionListener, ReceiveStreamListener, RemoteListener { private SessionManager mngrSession; private TreeControl controlTree = null; private JMPanel panelView = null; private CardLayout layoutView = null; private JMPanel panelCurrentView = null; private static final int MARGINH = 6; public static final String PARTICIPANTS = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants" ); public static final String REMOTE_RECEIVE_STREAM = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.remotereceivestream" ); public static final String UNKNOWN_STREAM = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.unknownstream" ); public static final String REPORT = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.report" ); public static final String LATEST_SENDER_REPORT = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.latestsenderreport" ); public static final String REPORT_BLOCK = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.reportblock" ); public static final String REPORT_BLOCK_BY_ME = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.reportblockbyme" ); public static final String SENDER_REPORT_BLOCK = JMFI18N.getResource ( "jmstudio.rtpsessionctrl.partcipants.senderreportblock" ); public PanelParticipants ( SessionManager mngrSession ) { super (); this.mngrSession = mngrSession; try { init(); } catch (Exception e) { e.printStackTrace(); } } private void init () throws Exception { TreeNode nodeRoot; TreeNode node; JMPanel panel; this.addComponentListener ( this ); this.setLayout ( null ); controlTree = new TreeControl (); this.add ( controlTree ); layoutView = new CardLayout (); panelView = new JMPanel ( layoutView ); panelView.setEtchedBorder (); this.add ( panelView ); nodeRoot = controlTree.createRootElement ( PARTICIPANTS ); panel = new ViewParticipantList ( mngrSession ); nodeRoot.setUserData ( panel ); fillParticipantsNode ( nodeRoot ); controlTree.setCurrentElement ( nodeRoot ); nodeRoot.addActionListener ( this ); this.setViewPanel ( nodeRoot ); mngrSession.addSessionListener ( this ); mngrSession.addReceiveStreamListener ( this ); mngrSession.addRemoteListener ( this ); } public Dimension getPreferredSize () { Dimension dim; dim = new Dimension ( 480, 360 ); return ( dim ); } public void actionPerformed ( ActionEvent event ) { Object objSource; String strAction; objSource = event.getSource (); if ( objSource == null || !(objSource instanceof TreeNode) ) return; strAction = event.getActionCommand (); if ( strAction.equals(TreeNode.ACTION_NODE_ADDED) ) { } else if ( strAction.equals(TreeNode.ACTION_NODE_REMOVED) ) { removeViewPanel ( (TreeNode)objSource ); } else if ( strAction.equals(TreeNode.ACTION_NODE_EXPANDED) ) { } else if ( strAction.equals(TreeNode.ACTION_NODE_COLLAPSED) ) { } else if ( strAction.equals(TreeNode.ACTION_NODE_SETCURRENT) ) { setViewPanel ( (TreeNode)objSource ); } else if ( strAction.equals(TreeNode.ACTION_NODE_RESETCURRENT) ) { } } public void update ( SessionEvent event ) { Participant participant; if ( event instanceof NewParticipantEvent ) { participant = ((NewParticipantEvent)event).getParticipant(); addParticipant ( participant ); } } public void update ( RemoteEvent event ) { Participant participant; ReceiverReport reportReceiver; SenderReport reportSender; TreeNode node; Object objPanel; if ( event instanceof ReceiverReportEvent ){ participant = ((ReceiverReportEvent)event).getReport().getParticipant(); if ( participant != null && participant.getStreams().size() == 0 ) { node = findParticipantListNode (); if ( node != null ) { objPanel = node.getUserData (); if ( objPanel != null && objPanel instanceof ViewParticipantList ) ((ViewParticipantList)objPanel).updateFields (); reportReceiver = ((ReceiverReportEvent)event).getReport(); addReport ( participant, reportReceiver ); } } } if ( event instanceof SenderReportEvent ) { participant = ((SenderReportEvent)event).getReport().getParticipant(); if ( participant != null && participant.getStreams().size() > 0 ) { node = findParticipantListNode (); if ( node != null ) { objPanel = node.getUserData (); if ( objPanel != null && objPanel instanceof ViewParticipantList ) ((ViewParticipantList)objPanel).updateFields (); reportSender = ((SenderReportEvent)event).getReport(); addReport ( participant, reportSender ); } } } } public void update ( ReceiveStreamEvent event){ Participant participant; ReceiveStream stream; TreeNode node; Object objPanel; // if this is a timeOut or ByeEvent, we need to remove the // participants from the list of participants if ( event instanceof TimeoutEvent || event instanceof ByeEvent ) { participant = null; stream = null; if ( event instanceof TimeoutEvent && ((TimeoutEvent)event).participantLeaving() ) { participant = ((TimeoutEvent)event).getParticipant(); } if ( event instanceof ByeEvent && ((ByeEvent)event).participantLeaving() ) { participant = ((ByeEvent)event).getParticipant(); } else if ( event instanceof TimeoutEvent ) { stream = ((TimeoutEvent)event).getReceiveStream(); } else if ( event instanceof ByeEvent ) { stream = ((ByeEvent)event).getReceiveStream(); } if ( participant != null ) { removeParticipant ( participant ); } if ( stream != null ) { removeRtpStream ( stream ); } } // if this is a NewReceiveStreamEvent, from an already existant // PASSVE paritcipant, we will need to remove the // Participant from the Passive list and add it to the // active list if ( event instanceof NewReceiveStreamEvent ) { stream = ((NewReceiveStreamEvent)event).getReceiveStream(); participant = stream.getParticipant (); if ( participant == null ) return; node = findParticipantNode ( participant ); if ( node == null ) addParticipant ( participant ); addRtpStream ( participant, stream ); node = this.findParticipantListNode (); objPanel = node.getUserData(); if ( objPanel != null && (objPanel instanceof ViewParticipantList) ) ((ViewParticipantList)objPanel).updateFields (); } if ( event instanceof InactiveReceiveStreamEvent ) { // don't know what to do here } if ( event instanceof ActiveReceiveStreamEvent ) { } } public void componentResized ( ComponentEvent event ) { layoutComponents (); } public void componentMoved ( ComponentEvent event ) { } public void componentShown ( ComponentEvent event ) { } public void componentHidden ( ComponentEvent event ) { } private void fillParticipantsNode ( TreeNode nodeParent ) { int i; int nCount; Vector vectorParticipants; Vector vector; Object objParticipant; String strName; TreeNode node; JMPanel panel; // get all participants into one vector vectorParticipants = mngrSession.getRemoteParticipants (); objParticipant = mngrSession.getLocalParticipant (); if ( !vectorParticipants.contains(objParticipant) ) vectorParticipants.addElement ( objParticipant ); vector = mngrSession.getActiveParticipants (); nCount = vector.size (); for ( i = 0; i < nCount; i++ ) { objParticipant = vector.elementAt ( i ); if ( vectorParticipants.contains(objParticipant) ) continue; vectorParticipants.addElement ( objParticipant ); } vector = mngrSession.getPassiveParticipants (); nCount = vector.size (); for ( i = 0; i < nCount; i++ ) { objParticipant = vector.elementAt ( i ); if ( vectorParticipants.contains(objParticipant) ) continue; vectorParticipants.addElement ( objParticipant ); } // now fill the tree with participants from collected vector nCount = vectorParticipants.size (); for ( i = 0; i < nCount; i++ ) { objParticipant = vectorParticipants.elementAt ( i ); if ( objParticipant == null || !(objParticipant instanceof Participant) ) continue; strName = ((Participant)objParticipant).getCNAME (); node = controlTree.createSubElement ( nodeParent, strName ); panel = new ViewParticipantInfo ( mngrSession, (Participant)objParticipant ); node.setUserData ( panel ); fillParticipantInfoNode ( node, (Participant)objParticipant ); node.addActionListener ( this ); } } private void fillParticipantInfoNode ( TreeNode nodeParent, Participant participant ) { int i; int nCount; TreeNode node; Vector vectorStreams; Object objStream; Vector vectorReports; Object objReport; String strName; long lSSRC; JMPanel panel; Object objPanel; if ( participant == null ) return; vectorStreams = participant.getStreams (); nCount = vectorStreams.size (); for ( i = 0; i < nCount; i++ ) { objStream = vectorStreams.elementAt ( i ); if ( objStream == null || !(objStream instanceof RTPStream) ) continue; addRtpStream ( nodeParent, (RTPStream)objStream ); } vectorReports = participant.getReports (); nCount = vectorReports.size (); for ( i = 0; i < nCount; i++ ) { objReport = vectorReports.elementAt ( i ); if ( objReport == null || !(objReport instanceof Report) ) continue; addReport ( nodeParent, (Report)objReport ); } } private void fillStreamInfoNode ( TreeNode nodeParent, RTPStream streamRtp ) { SenderReport reportSender; TreeNode node; String strName; JMPanel panel; if ( streamRtp == null ) return; reportSender = streamRtp.getSenderReport(); if ( reportSender != null ) { strName = createStreamLatestReportNodeName (); node = controlTree.createSubElement ( nodeParent, strName ); panel = new ViewSenderReport ( mngrSession, reportSender ); node.setUserData ( panel );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -