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

📄 jmstudio.java

📁 视频编码的一个实例程序
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            panelContent.add ( panelVideo, BorderLayout.CENTER );            if ( compControl != null) {                panelContent.add ( compControl, BorderLayout.SOUTH );            }            if ( dimFrameSizeBeforeFullScreen != null ) {                this.setSize ( dimFrameSizeBeforeFullScreen );                this.validate ();            }            this.setVisible ( true );        }    }    private void doSnapShot () {        Buffer          bufferFrame;        BufferToImage   bufferToImage;        Image           image;	    bufferFrame = controlGrabber.grabFrame ();		bufferToImage = new BufferToImage ( (VideoFormat)bufferFrame.getFormat() );	    image = bufferToImage.createImage ( bufferFrame );	    if ( image == null )            return;		if ( frameSnap == null )		    frameSnap = new SnapFrame ( image, this );        else            frameSnap.setImage ( image );		frameSnap.setTitle ( this.getTitle() + " - " + JMFI18N.getResource("jmstudio.snapshot") );    }    protected void killCurrentView () {        if ( componentPlugins != null ) {            componentPlugins.setVisible ( false );            componentPlugins = null;        }        controlGrabber = null;        super.killCurrentView ();    }    protected void killCurrentPlayer () {        int                     i;        int                     nCount;        RTPStream               streamRtp;        SessionManager          mngrSession;        PlayerFrame             frame;        // Whatever it is, kill it        nameCaptureDeviceAudio = null;        nameCaptureDeviceVideo = null;        if ( dlgCaptureControls != null )            dlgCaptureControls.dispose ();        dlgCaptureControls = null;        if ( dlgTransmissionStats != null )            dlgTransmissionStats.dispose ();        dlgTransmissionStats = null;        if ( dlgSessionControl != null )            dlgSessionControl.dispose ();        dlgSessionControl = null;        if ( vectorRtpFrames != null ) {            nCount = vectorRtpFrames.size();            for ( i = 0;  i < nCount;  i++ ) {                frame = (PlayerFrame) vectorRtpFrames.elementAt ( i );                frame.dispose();            }            vectorRtpFrames.removeAllElements();            vectorRtpFrames = null;        }        if ( vectorStreams != null ) {            nCount = vectorStreams.size();            for ( i = 0;  i < nCount;  i++ ) {                streamRtp = (RTPStream) vectorStreams.elementAt ( i );                if ( streamRtp instanceof SendStream )                    ((SendStream)streamRtp).close ();            }            vectorStreams.removeAllElements();            vectorStreams = null;        }        if ( vectorMngrSessions != null ) {            nCount = vectorMngrSessions.size();            for ( i = 0;  i < nCount;  i++ ) {                mngrSession = (SessionManager) vectorMngrSessions.elementAt ( i );                if ( mngrSessionRtp == mngrSession )                    mngrSessionRtp = null;                mngrSession.closeSession ( "Transmission terminated" );            }            vectorMngrSessions.removeAllElements();            vectorMngrSessions = null;        }        if ( mngrSessionRtp != null ) {            mngrSessionRtp.closeSession ( "Transmission terminated" );            mngrSessionRtp = null;        }        super.killCurrentPlayer ();        if (dataSourceCurrent != null) {            if (dataSourceCurrent instanceof CDSWrapper) {                ((CDSWrapper)dataSourceCurrent).close();            }        }        dataSourceCurrent = null;        setTitle ( APPNAME );        updateMenu ();    }    private boolean closeCapture () {        String  strAction;        String  strMessage;        if ( mediaPlayerCurrent == null )            return true;        // Sun's implementation specific capture devices        if ( dataSourceCurrent != null) {            strMessage = JMFI18N.getResource ( "jmstudio.query.erooropencapture.closepreview" );            strAction = MessageDialog.createOKCancelDialog ( this, strMessage );            if ( strAction != null  &&  strAction.equals(JMDialog.ACTION_OK) ) {                killCurrentPlayer ();//                setPlaceholder ();                return true;            }            else                return false;        }        else // (probably) not a capture device            return true;    }    public void updateMenu () {        boolean     boolEnable;        boolEnable = (mediaPlayerCurrent != null);        menuFileExport.setEnabled ( boolEnable );        menuFileClose.setEnabled ( boolEnable  ||  mngrSessionRtp != null  || (vectorMngrSessions != null && !vectorMngrSessions.isEmpty()) );        menuKeepAspect.setEnabled ( boolEnable && panelVideo != null  &&  panelVideo.getVisualComponent() != null );        menuFullScreen.setEnabled ( boolEnable && panelVideo != null  &&  panelVideo.getVisualComponent() != null );        menuSnapShot.setEnabled ( boolEnable  &&  (controlGrabber != null) );        menuPlugins.setEnabled ( boolEnable  &&  (controlPlugins != null) );        menuCaptureControl.setEnabled ( boolEnable  &&  (dlgCaptureControls != null) );        menuTransmissionStats.setEnabled ( boolEnable  &&  (dlgTransmissionStats != null) );        menuRtpSessionControl.setEnabled ( boolEnable  &&  (dlgSessionControl != null) );    }    private void addToRecentUrlList ( String strUrl ) {        int     nPos;        String  strUrlType;        if ( cfgJMApps == null )            return;        nPos = strUrl.lastIndexOf ( "." );        if ( strUrl.substring(0,4).equalsIgnoreCase("rtp:") )            strUrlType = "RTP";        else if ( nPos < 1  ||  nPos == strUrl.length() - 1 )            strUrlType = "Other";        else            strUrlType = strUrl.substring(nPos+1).toUpperCase();        cfgJMApps.addRecentUrls ( strUrlType, strUrl );        updateRecentUrlMenu ();    }    private void updateRecentUrlMenu () {        int             i;        int             nSize;        Enumeration     enumUrlTypes;        Object          objUrlType;        Menu            menuUrlType;        MenuItem        menuItem;        Vector          vectorUrls;        Object          objUrl;        if ( cfgJMApps == null )            return;        menuRecentUrl.removeAll ();        enumUrlTypes = cfgJMApps.getRecentUrlTypes ();        if ( enumUrlTypes == null )            return;        while ( enumUrlTypes.hasMoreElements() ) {            objUrlType = enumUrlTypes.nextElement();            menuUrlType = new Menu ( objUrlType.toString() );            menuRecentUrl.add ( menuUrlType );            vectorUrls = cfgJMApps.getRecentUrls ( objUrlType.toString() );            if ( vectorUrls == null )                continue;            nSize = vectorUrls.size ();            for ( i = 0;  i < nSize;  i++ ) {                objUrl = vectorUrls.elementAt ( i );                menuItem = new MenuItem ( objUrl.toString() );                menuItem.setActionCommand ( MENU_FILE_RECENTURL );                menuItem.addActionListener ( this );                menuUrlType.add ( menuItem );            }        }    }    // This method loads HTTP Proxy information from the appletviewer settings.    static void initProps() {	Properties props = new Properties(System.getProperties());	props = new Properties(props);	File theUserPropertiesFile;	String sep = File.separator;	theUserPropertiesFile = new File(System.getProperty("user.home") +					 sep + ".hotjava" +					 sep + "properties");	try {	    FileInputStream in = new FileInputStream(theUserPropertiesFile);	    props.load(new BufferedInputStream(in));	    in.close();	} catch (Exception e) {	}	System.setProperties(props);    }    public static void main ( String args[] ) {        int         i;        String      strMedia;        JMStudio    jmStudio;        jmapps.ui.MessageDialog.titleDefault = APPNAME;        cfgJMApps = new JMAppsCfg ();	try {	    initProps();	} catch (Throwable t) {	    System.out.println("Unable to read Http Proxy information from the appletviewer settings");	}	        for ( i = 0;  i < args.length;  i++ ) {            if ( args[i].equals("-x") ) {                if ( args.length > i + 1 ) {                    try {                        dDefaultScale = Double.valueOf(args[i+1]).doubleValue();                        i++;                    }                    catch ( Exception exception ) {                        dDefaultScale = 1.0;                    }                }                continue;            }            strMedia = args[i];            if ( strMedia.indexOf(":") < 2 ) {                if ( strMedia.indexOf("/") != 0 )                    strMedia = "/" + strMedia;                strMedia = "file:" + strMedia;            }            jmStudio = createNewFrame ();            jmStudio.open ( strMedia );        }        if ( vectorFrames.size() < 1 ) {            jmStudio = createNewFrame ();        }    }    public static JMStudio createNewFrame () {        int         nIndex;        Point       point;        Dimension   dim;        Dimension   dimScreen;        JMStudio    jmStudio;        jmStudio = new JMStudio ();        if ( cfgJMApps != null ) {            nIndex = vectorFrames.size ();            point = cfgJMApps.getJMStudioFrameLocation ( nIndex );            dim = jmStudio.getSize ();            dimScreen = Toolkit.getDefaultToolkit().getScreenSize();            if ( point.x + dim.width > dimScreen.width )                point.x = dimScreen.width - dim.width;            if ( point.y + dim.height > dimScreen.height )                point.y = dimScreen.height - dim.height;            jmStudio.setLocation ( point );            jmStudio.setVisible ( true );            jmStudio.invalidate ();            jmStudio.pack ();        }        vectorFrames.addElement ( jmStudio );        return ( jmStudio );    }    public static void closeAll () {        int         i;        JMStudio    jmStudio;        i = vectorFrames.size();        while ( i > 0 ) {            i--;            jmStudio = (JMStudio) vectorFrames.elementAt ( i );            jmStudio.dispose();        }    }    public static void exitApllication () {        cleanUp ();        System.exit ( 0 );    }    private static void cleanUp () {        if ( cfgJMApps != null )            cfgJMApps.save();    }}

⌨️ 快捷键说明

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