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

📄 jmstudio.java

📁 视频编码的一个实例程序
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * @(#)JMStudio.java	1.29 00/05/19 * * 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. */import java.util.*;import java.net.*;import java.lang.reflect.Method;import java.awt.*;import java.awt.event.*;import java.io.*;import javax.media.*;import javax.media.util.*;import javax.media.format.*;import javax.media.control.*;import javax.media.protocol.*;import javax.media.bean.playerbean.*;import javax.media.rtp.*;import javax.media.rtp.event.*;import com.sun.media.util.JMFI18N;import jmapps.ui.*;import jmapps.util.*;import jmapps.rtp.*;import jmapps.jmstudio.*;public class JMStudio extends PlayerFrame implements ItemListener,                                    ReceiveStreamListener {    private Menu                    menuRecentUrl;    private MenuItem                menuFileClose;    private MenuItem                menuFileExport;    private MenuItem                menuCapture;    private CheckboxMenuItem        menuAutoPlay;    private CheckboxMenuItem        menuAutoLoop;    private CheckboxMenuItem        menuKeepAspect;    private MenuItem                menuFullScreen;    private MenuItem                menuSnapShot;    private MenuItem                menuPlugins;    private MenuItem                menuCaptureControl;    private MenuItem                menuRtpSessionControl;    private MenuItem                menuTransmissionStats;    private Dimension               dimFrameSizeBeforeFullScreen = null;    private Window                  windowFullScreen = null;    private MouseListener           listenerMouseFullScreen;    private Control                 controlPlugins = null;    private Component               componentPlugins = null;    private FrameGrabbingControl    controlGrabber = null;    private FileDialog              dlgOpenFile = null;    private JMFRegistry             jmfRegistry = null;    private Vector                  vectorRtpFrames = null;    private SnapFrame               frameSnap = null;    private TransmissionStatsDialog dlgTransmissionStats = null;    private SessionControlDialog    dlgSessionControl = null;    private String                  strOptionalTitle = "";    private DataSource              dataSourceCurrent = null;    private String                  nameCaptureDeviceAudio = null;    private String                  nameCaptureDeviceVideo = null;    private CaptureControlsDialog   dlgCaptureControls = null;    private SessionManager          mngrSessionRtp = null;    private Vector                  vectorMngrSessions = null;    private Vector                  vectorStreams = null;    private Vector                  vectorStreamLabels = null;    public static final String APPNAME = JMFI18N.getResource ( "jmstudio.appname" );    private static final String MENU_FILE                   = JMFI18N.getResource ( "jmstudio.menu.file" );    private static final String MENU_FILE_NEWWINDOW         = JMFI18N.getResource ( "jmstudio.menu.file.newwindow" );    private static final String MENU_FILE_OPENFILE          = JMFI18N.getResource ( "jmstudio.menu.file.openfile" );    private static final String MENU_FILE_OPENURL           = JMFI18N.getResource ( "jmstudio.menu.file.openurl" );    private static final String MENU_FILE_OPENRTP           = JMFI18N.getResource ( "jmstudio.menu.file.openrtp" );    private static final String MENU_FILE_CAPTURE           = JMFI18N.getResource ( "jmstudio.menu.file.capture" );    private static final String MENU_FILE_RECENTURL         = JMFI18N.getResource ( "jmstudio.menu.file.recent" );    private static final String MENU_FILE_CLOSE             = JMFI18N.getResource ( "jmstudio.menu.file.close" );    private static final String MENU_FILE_EXPORT            = JMFI18N.getResource ( "jmstudio.menu.file.export" );    private static final String MENU_FILE_TRANSMIT          = JMFI18N.getResource ( "jmstudio.menu.file.transmit" );    private static final String MENU_FILE_PREFERENCES       = JMFI18N.getResource ( "jmstudio.menu.file.preferences" );    private static final String MENU_FILE_EXIT              = JMFI18N.getResource ( "jmstudio.menu.file.exit" );    private static final String MENU_PLAYER                 = JMFI18N.getResource ( "jmstudio.menu.player" );    private static final String MENU_PLAYER_AUTOPLAY        = JMFI18N.getResource ( "jmstudio.menu.player.autoplay" );    private static final String MENU_PLAYER_AUTOLOOP        = JMFI18N.getResource ( "jmstudio.menu.player.autoloop" );    private static final String MENU_PLAYER_KEEPASPECT      = JMFI18N.getResource ( "jmstudio.menu.player.keepaspect" );    private static final String MENU_PLAYER_FULLSCREEN      = JMFI18N.getResource ( "jmstudio.menu.player.fullscreen" );    private static final String MENU_PLAYER_SNAPSHOT        = JMFI18N.getResource ( "jmstudio.menu.player.snapshot" );    private static final String MENU_PLAYER_PLUGINS         = JMFI18N.getResource ( "jmstudio.menu.player.plugins" );    private static final String MENU_PLAYER_CAPTURE         = JMFI18N.getResource ( "jmstudio.menu.player.capturecontrols" );    private static final String MENU_PLAYER_RTPSESSION      = JMFI18N.getResource ( "jmstudio.menu.player.rtpsession" );    private static final String MENU_PLAYER_TRANSMISSION    = JMFI18N.getResource ( "jmstudio.menu.player.transmission" );    private static final String MENU_HELP                   = JMFI18N.getResource ( "jmstudio.menu.help");    private static final String MENU_HELP_ABOUT             = JMFI18N.getResource ( "jmstudio.menu.help.about");    private static Vector       vectorFrames = new Vector (); // keeps count of all open JMStudio frames    private static JMAppsCfg    cfgJMApps = null;    private static double       dDefaultScale = 1.0;    public JMStudio () {        super ( null, APPNAME );        updateMenu ();    }    public void addNotify () {        super.addNotify ();    }    public void pack () {        super.pack ();    }    protected void initFrame () {        createMenu ();        super.initFrame ();    }    private void createMenu () {        MenuBar         menu;        Menu            menuFile;        Menu            menuPlayer;        Menu            menuHelp;        MenuShortcut    shortcut;        MenuItem        itemMenu;        Vector          vector;        boolean         boolValue;        menu = new MenuBar ();        this.setMenuBar ( menu );        // menu File        menuFile = new Menu ( MENU_FILE );        menu.add ( menuFile );        shortcut = new MenuShortcut ( KeyEvent.VK_N );        itemMenu = new MenuItem ( MENU_FILE_NEWWINDOW, shortcut );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        shortcut = new MenuShortcut ( KeyEvent.VK_O );        itemMenu = new MenuItem ( MENU_FILE_OPENFILE, shortcut );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        shortcut = new MenuShortcut ( KeyEvent.VK_U );        itemMenu = new MenuItem ( MENU_FILE_OPENURL, shortcut );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        shortcut = new MenuShortcut ( KeyEvent.VK_R );        itemMenu = new MenuItem ( MENU_FILE_OPENRTP, shortcut );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        shortcut = new MenuShortcut ( KeyEvent.VK_P );        menuCapture = new MenuItem ( MENU_FILE_CAPTURE, shortcut );        menuCapture.addActionListener ( this );        menuFile.add ( menuCapture );        vector = CaptureDeviceManager.getDeviceList ( null );        if ( vector == null  ||  vector.size() < 1 )            menuCapture.setEnabled ( false );        else            menuCapture.setEnabled ( true );        menuRecentUrl = new Menu ( MENU_FILE_RECENTURL );        updateRecentUrlMenu ();        menuFile.add ( menuRecentUrl );        shortcut = new MenuShortcut ( KeyEvent.VK_W );        menuFileClose = new MenuItem ( MENU_FILE_CLOSE, shortcut );        menuFileClose.addActionListener ( this );        menuFile.add ( menuFileClose );        menuFile.addSeparator ();        shortcut = new MenuShortcut ( KeyEvent.VK_E );        menuFileExport = new MenuItem ( MENU_FILE_EXPORT, shortcut );        menuFileExport.addActionListener ( this );        menuFile.add ( menuFileExport );        shortcut = new MenuShortcut ( KeyEvent.VK_T );        itemMenu = new MenuItem ( MENU_FILE_TRANSMIT, shortcut );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        menuFile.addSeparator ();        itemMenu = new MenuItem ( MENU_FILE_PREFERENCES );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        shortcut = new MenuShortcut ( KeyEvent.VK_X );        itemMenu = new MenuItem ( MENU_FILE_EXIT, shortcut );        itemMenu.addActionListener ( this );        menuFile.add ( itemMenu );        // menu Player        menuPlayer = new Menu ( MENU_PLAYER );        menu.add ( menuPlayer );        // It's a funny thing that we have to make this kind of a call at all,        // less in this particular place. But if we don't do that here,        // Windows will screw up the frame insets and therefore the layout.        this.addNotify ();        if ( cfgJMApps != null )            boolValue = cfgJMApps.getAutoPlay ();        else            boolValue = false;        menuAutoPlay = new CheckboxMenuItem ( MENU_PLAYER_AUTOPLAY, boolValue );        menuAutoPlay.addItemListener ( this );        menuPlayer.add ( menuAutoPlay );        if ( cfgJMApps != null )            boolValue = cfgJMApps.getAutoLoop ();        else            boolValue = true;        menuAutoLoop = new CheckboxMenuItem ( MENU_PLAYER_AUTOLOOP, boolValue );        menuAutoLoop.addItemListener ( this );        menuPlayer.add ( menuAutoLoop );        if ( cfgJMApps != null )            boolValue = cfgJMApps.getKeepAspectRatio ();        else            boolValue = false;        menuKeepAspect = new CheckboxMenuItem ( MENU_PLAYER_KEEPASPECT, boolValue );        menuKeepAspect.addItemListener ( this );        menuPlayer.add ( menuKeepAspect );        menuPlayer.addSeparator ();        shortcut = new MenuShortcut ( KeyEvent.VK_F );        menuFullScreen = new MenuItem ( MENU_PLAYER_FULLSCREEN, shortcut );        menuFullScreen.addActionListener ( this );        menuPlayer.add ( menuFullScreen );        shortcut = new MenuShortcut ( KeyEvent.VK_S );        menuSnapShot = new MenuItem ( MENU_PLAYER_SNAPSHOT, shortcut );        menuSnapShot.addActionListener ( this );        menuPlayer.add ( menuSnapShot );        menuPlayer.addSeparator ();//        shortcut = new MenuShortcut ( KeyEvent.VK_V );        menuPlugins = new MenuItem ( MENU_PLAYER_PLUGINS /*, shortcut*/ );        menuPlugins.addActionListener ( this );        menuPlayer.add ( menuPlugins );//        shortcut = new MenuShortcut ( KeyEvent.VK_A );        menuCaptureControl = new MenuItem ( MENU_PLAYER_CAPTURE /*, shortcut*/ );        menuCaptureControl.addActionListener ( this );        menuPlayer.add ( menuCaptureControl );//        shortcut = new MenuShortcut ( KeyEvent.VK_I );        menuRtpSessionControl = new MenuItem ( MENU_PLAYER_RTPSESSION /*, shortcut*/ );        menuRtpSessionControl.addActionListener ( this );        menuPlayer.add ( menuRtpSessionControl );//        shortcut = new MenuShortcut ( KeyEvent.VK_M );        menuTransmissionStats = new MenuItem ( MENU_PLAYER_TRANSMISSION /*, shortcut*/ );        menuTransmissionStats.addActionListener ( this );        menuPlayer.add ( menuTransmissionStats );        // menu Help        menuHelp = new Menu ( MENU_HELP );        menu.add ( menuHelp );        shortcut = new MenuShortcut ( KeyEvent.VK_H );        itemMenu = new MenuItem ( MENU_HELP_ABOUT, shortcut );        itemMenu.addActionListener ( this );        menuHelp.add ( itemMenu );    }    public void actionPerformed ( ActionEvent event ) {        String      strCmd;        Object      objSource;        String      nameUrl;        Frame       frame;        Component   component;        strCmd = event.getActionCommand ();        objSource = event.getSource ();        if ( strCmd == null  &&  objSource instanceof MenuItem )            strCmd = ((MenuItem)objSource).getActionCommand ();        if ( strCmd == null )            return;        if ( strCmd.equals(MENU_FILE_NEWWINDOW) ) {            createNewFrame ();        }        else if ( strCmd.equals(MENU_FILE_OPENFILE) ) {

⌨️ 快捷键说明

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