⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 panelmediatargetnetwork.java

📁 里面是关于jmf编程的例子,希望能给初学者带来一些帮助
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * @(#)PanelMediaTargetNetwork.java	1.1 00/02/10 * * 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.export;
import java.awt.*;
import java.awt.event.*;

import com.sun.media.util.JMFI18N;

import jmapps.util.*;
import jmapps.ui.*;

public class PanelMediaTargetNetwork extends JMPanel implements TextListener {

    private JMAppsCfg                 cfgJMApps = null;

    private Panel       panelLabels;
    private Panel       panelAddress;
    private Panel       panelPort;
    private Panel       panelTtl;

    private TextField   arrTextVideoTrackAddress [][] = null;
    private TextField   arrTextAudioTrackAddress [][] = null;
    private TextField   arrTextVideoPort [] = null;
    private TextField   arrTextAudioPort [] = null;
    private Choice      arrComboVideoTtl [] = null;
    private Choice      arrComboAudioTtl [] = null;

    private int         nVideoCount = 0;
    private int         nAudioCount = 0;
    
    private static final int    MAX_TRACK_COUNT = 8;


    public PanelMediaTargetNetwork ( JMAppsCfg cfgJMApps ) {
    	super ();

        this.cfgJMApps = cfgJMApps;
    	try {
    	    init ();
    	}
    	catch ( Exception exception ) {
    	    exception.printStackTrace ();
    	}
    }

    public void setJMStudioCfg ( JMAppsCfg cfgJMApps ) {
        int                     i;
        JMAppsCfg.RtpData     dataRtp;


        this.cfgJMApps = cfgJMApps;
        if ( cfgJMApps == null )
            return;

    	for ( i = 0;  i < MAX_TRACK_COUNT;  i++ ) {
            dataRtp = cfgJMApps.getLastTransmitRtpData ( "Video " + (i + 1) );
            if ( dataRtp != null ) {
                arrTextVideoTrackAddress[i][0].setText ( dataRtp.strAddress0 );
                arrTextVideoTrackAddress[i][1].setText ( dataRtp.strAddress1 );
                arrTextVideoTrackAddress[i][2].setText ( dataRtp.strAddress2 );
                arrTextVideoTrackAddress[i][3].setText ( dataRtp.strAddress3 );
                arrTextVideoPort[i].setText ( dataRtp.strPort );
                arrComboVideoTtl[i].select ( dataRtp.strTtl );
            }
            dataRtp = cfgJMApps.getLastTransmitRtpData ( "Audio " + (i + 1) );
            if ( dataRtp != null ) {
                arrTextAudioTrackAddress[i][0].setText ( dataRtp.strAddress0 );
                arrTextAudioTrackAddress[i][1].setText ( dataRtp.strAddress1 );
                arrTextAudioTrackAddress[i][2].setText ( dataRtp.strAddress2 );
                arrTextAudioTrackAddress[i][3].setText ( dataRtp.strAddress3 );
                arrTextAudioPort[i].setText ( dataRtp.strPort );
                arrComboAudioTtl[i].select ( dataRtp.strTtl );
            }
        }
    }

    public String[] getVideoAddresses () {
    	int         i, j;
    	String      arrValues [];

    	arrValues = new String [nVideoCount];
    	for ( i = 0;  i < nVideoCount;  i++ ) {
    	    arrValues[i] = arrTextVideoTrackAddress[i][0].getText().trim();
            for ( j = 1;  j < 4;  j++ )
    	        arrValues[i] = arrValues[i] + "." + arrTextVideoTrackAddress[i][j].getText().trim();
    	}

    	return ( arrValues );
    }

    public String[] getAudioAddresses () {
    	int         i, j;
    	String      arrValues [];

    	arrValues = new String [nAudioCount];
    	for ( i = 0;  i < nAudioCount;  i++ ) {
    	    arrValues[i] = arrTextAudioTrackAddress[i][0].getText().trim();
            for ( j = 1;  j < 4;  j++ )
    	        arrValues[i] = arrValues[i] + "." + arrTextAudioTrackAddress[i][j].getText().trim();
    	}
    	return ( arrValues );
    }

    public String[] getVideoPorts () {
    	int         i, j;
    	String      arrValues [];

    	arrValues = new String [nVideoCount];
    	for ( i = 0;  i < nVideoCount;  i++ )
    	    arrValues[i] = arrTextVideoPort[i].getText().trim();
    	return ( arrValues );
    }

    public String[] getAudioPorts () {
    	int         i, j;
    	String      arrValues [];

    	arrValues = new String [nAudioCount];
    	for ( i = 0;  i < nAudioCount;  i++ )
    	    arrValues[i] = arrTextAudioPort[i].getText().trim();
    	return ( arrValues );
    }

    public String[] getVideoTtls () {
    	int         i, j;
        String      arrValues [];

    	arrValues = new String [nVideoCount];
    	for ( i = 0;  i < nVideoCount;  i++ )
    	    arrValues[i] = arrComboVideoTtl[i].getSelectedItem().trim();
    	return ( arrValues );
    }

    public String[] getAudioTtls () {
    	int         i, j;
    	String      arrValues [];

    	arrValues = new String [nAudioCount];
    	for ( i = 0;  i < nAudioCount;  i++ )
    	    arrValues[i] = arrComboAudioTtl[i].getSelectedItem().trim();
    	return ( arrValues );
    }

    private void init () throws Exception {
        int                     i, j;
    	Panel	                panel;
    	Panel	                panelTemp;
    	Panel	                panelDescription;
        JMAppsCfg.RtpData     dataRtp;


    	this.setLayout ( new BorderLayout(6,6) );

    	panel = new Panel ( new BorderLayout(6,6) );
    	this.add ( panel, BorderLayout.NORTH );

    	panelDescription = new Panel ( new GridLayout(0,1) );
    	panel.add ( panelDescription, BorderLayout.NORTH );
    	panelDescription.add ( new Label(JMFI18N.getResource("jmstudio.export.targetnw.label1")) );
    	panelDescription.add ( new Label(JMFI18N.getResource("jmstudio.export.targetnw.label2")) );

    	panelLabels = new Panel ( new GridLayout(0,1,6,6) );
    	panel.add ( panelLabels, BorderLayout.WEST );

    	panelAddress = new Panel ( new GridLayout(0,1,6,6) );
    	panel.add ( panelAddress, BorderLayout.CENTER );

    	panelTemp = new Panel ( new BorderLayout(6,6) );
    	panel.add ( panelTemp, BorderLayout.EAST );

    	panelPort = new Panel ( new GridLayout(0,1,6,6) );
    	panelTemp.add ( panelPort, BorderLayout.CENTER );

    	panelTtl = new Panel ( new GridLayout(0,1,6,6) );
    	panelTemp.add ( panelTtl, BorderLayout.EAST );

        arrTextVideoTrackAddress = new TextField [MAX_TRACK_COUNT][4];
        arrTextAudioTrackAddress = new TextField [MAX_TRACK_COUNT][4];
        arrTextVideoPort = new TextField [MAX_TRACK_COUNT];
        arrTextAudioPort = new TextField [MAX_TRACK_COUNT];
        arrComboVideoTtl = new Choice [MAX_TRACK_COUNT];
        arrComboAudioTtl = new Choice [MAX_TRACK_COUNT];
    	for ( i = 0;  i < MAX_TRACK_COUNT;  i++ ) {
    	    for ( j = 0;  j < 4;  j++ ) {
    	    	arrTextVideoTrackAddress[i][j] = new TextField ();
    	    	arrTextVideoTrackAddress[i][j].addTextListener ( this );
    	    	arrTextAudioTrackAddress[i][j] = new TextField ();
    	    	arrTextAudioTrackAddress[i][j].addTextListener ( this );
    	    }

            arrTextVideoPort[i] = new TextField ( 5 );
            arrTextAudioPort[i] = new TextField ( 5 );

    	    arrComboVideoTtl[i] = new Choice ();
    	    arrComboVideoTtl[i].addItem ( "1" );
    	    arrComboVideoTtl[i].addItem ( "2" );
    	    arrComboVideoTtl[i].addItem ( "3" );
    	    arrComboVideoTtl[i].addItem ( "4" );
    	    arrComboVideoTtl[i].addItem ( "8" );
    	    arrComboVideoTtl[i].addItem ( "16" );
    	    arrComboVideoTtl[i].addItem ( "32" );
    	    arrComboVideoTtl[i].addItem ( "64" );
    	    arrComboVideoTtl[i].addItem ( "128" );
    	    arrComboVideoTtl[i].addItem ( "255" );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -