📄 exportwizard.java
字号:
/* * @(#)ExportWizard.java 1.10 00/05/12 * * 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.util.*;import java.awt.*;import java.awt.event.*;import javax.media.*;import javax.media.format.*;import javax.media.control.*;import javax.media.protocol.*;import javax.media.datasink.*;import javax.media.rtp.*;import com.sun.media.util.JMFI18N;import com.sun.media.ui.PlayerWindow;import jmapps.ui.*;import jmapps.util.*;import jmapps.jmstudio.*;public class ExportWizard extends WizardDialog implements ControllerListener, DataSinkListener { protected PanelMediaSource panelSource; protected PanelMediaTargetType panelTargetType; protected PanelMediaTargetFormat panelTargetFormat; protected PanelMediaTargetFile panelTargetFile; protected PanelMediaTargetNetwork panelTargetNetwork; protected String strTitle = JMFI18N.getResource("jmstudio.export.title"); protected Processor processor = null; protected String strTargetType = null; protected boolean boolChangedProcessor = false; protected boolean boolChangedTargetType = false; protected String strFailMessage = null; protected DataSink dataSinkSave = null; protected ProgressDialog dlgProgressSave = null; protected ProgressThread threadProgressSave = null; protected TransmitPlayerWindow playerTransmit = null; protected CaptureControlsDialog dlgCaptureControls = null; protected Vector vectorWindowsLeft = new Vector (); private JMAppsCfg cfgJMApps = null; public ExportWizard ( String strTitle, Frame frame, String strSourceUrl, JMAppsCfg cfgJMApps ) { super ( frame, strTitle, true, "logo.gif" ); this.strTitle = strTitle; this.setTitle ( strTitle ); this.cfgJMApps = cfgJMApps; panelSource.setJMStudioCfg ( cfgJMApps ); panelSource.setSourceUrl ( strSourceUrl ); panelTargetNetwork.setJMStudioCfg ( cfgJMApps ); } public ExportWizard ( Frame frame, String strSourceUrl, JMAppsCfg cfgJMApps ) { this ( JMFI18N.getResource("jmstudio.export.title"), frame, strSourceUrl, cfgJMApps ); } public Vector getWindowsLeft () { return ( vectorWindowsLeft ); } protected void init () throws Exception { super.init (); panelSource = new PanelMediaSource ( cfgJMApps ); panelTargetType = new PanelMediaTargetType (); panelTargetFormat = new PanelMediaTargetFormat (); panelTargetFile = new PanelMediaTargetFile (); panelTargetNetwork = new PanelMediaTargetNetwork ( cfgJMApps ); this.setSize ( 480, 480 ); this.setLocation ( 100, 100 ); } protected Panel getFirstPage () { return ( panelSource ); } protected Panel getLastPage () { String strTargetType; Panel panel = null; strTargetType = panelTargetType.getType (); if ( strTargetType.equals(PanelMediaTargetType.TYPE_FILE) ) panel = panelTargetFile; else if ( strTargetType.equals(PanelMediaTargetType.TYPE_NETWORK) ) panel = panelTargetNetwork; else if ( strTargetType.equals(PanelMediaTargetType.TYPE_SCREEN) ) panel = panelTargetFormat; return ( panel ); } protected Panel getNextPage ( Panel panelPage ) { Panel panelPageNext = null; String strTargetType; if ( panelPage == null ) { panelPageNext = getFirstPage (); } else if ( panelPage == panelSource ) { panelPageNext = panelTargetType; } else if ( panelPage == panelTargetType ) { panelPageNext = panelTargetFormat; } else if ( panelPage == panelTargetFormat ) { strTargetType = panelTargetType.getType (); if ( strTargetType.equals(PanelMediaTargetType.TYPE_FILE) ) panelPageNext = panelTargetFile; else if ( strTargetType.equals(PanelMediaTargetType.TYPE_NETWORK) ) panelPageNext = panelTargetNetwork; else if ( strTargetType.equals(PanelMediaTargetType.TYPE_SCREEN) ) panelPageNext = null; } else { panelPageNext = null; } return ( panelPageNext ); } protected Panel getPrevPage ( Panel panelPage ) { Panel panelPagePrev = null; if ( panelPage == null ) panelPagePrev = getLastPage (); else if ( panelPage == panelTargetNetwork ) panelPagePrev = panelTargetFormat; else if ( panelPage == panelTargetFile ) panelPagePrev = panelTargetFormat; else if ( panelPage == panelTargetFile ) panelPagePrev = panelTargetFormat; else if ( panelPage == panelTargetFormat ) panelPagePrev = panelTargetType; else if ( panelPage == panelTargetType ) panelPagePrev = panelSource; else panelPagePrev = null; return ( panelPagePrev ); } protected boolean onPageDone ( Panel panelPage ) { if ( panelPage == panelSource ) { setCursor ( new Cursor(Cursor.WAIT_CURSOR) ); processor = panelSource.createProcessor (); if ( processor != null ) { processor.addControllerListener ( this ); configureProcessor (); } setCursor ( Cursor.getDefaultCursor() ); if ( processor == null ) { panelSource.setDataSource ( null ); this.setTitle ( strTitle ); return ( false ); } boolChangedProcessor = true; this.setTitle ( strTitle + " " + panelSource.getSourceUrl() ); panelSource.SaveData (); } else if ( panelPage == panelTargetType ) { if ( strTargetType == null || !panelTargetType.getType().equals(strTargetType) ) { strTargetType = panelTargetType.getType (); boolChangedTargetType = true; } } else if ( panelPage == panelTargetNetwork ) { if ( panelTargetNetwork.checkValidFields(true) == false ) return ( false ); else panelTargetNetwork.saveData (); } return ( true ); } protected boolean onPageActivate ( Panel panelPage ) { String strContentType; if ( panelPage == panelSource ) { this.setTitle ( strTitle ); } else if ( panelPage == panelTargetFormat ) { if ( boolChangedProcessor == true || boolChangedTargetType == true ) { setCursor ( new Cursor(Cursor.WAIT_CURSOR) ); strContentType = panelSource.getDefaultContentType (); panelTargetFormat.setProcessor ( processor, strContentType, strTargetType ); boolChangedProcessor = false; boolChangedTargetType = false; setCursor ( Cursor.getDefaultCursor() ); } } else if ( panelPage == panelTargetFile ) { // ... } else if ( panelPage == panelTargetNetwork ) { panelTargetNetwork.setTracks ( panelTargetFormat.getEnabledVideoTracks(), panelTargetFormat.getEnabledAudioTracks() ); } return ( true ); } protected boolean onFinish () { boolean boolResult; setCursor ( new Cursor(Cursor.WAIT_CURSOR) ); if ( strTargetType == null ) boolResult = false; else if ( strTargetType.equals(PanelMediaTargetType.TYPE_FILE) ) boolResult = doSaveFile (); else if ( strTargetType.equals(PanelMediaTargetType.TYPE_NETWORK) ) boolResult = doTransmit (); else if ( strTargetType.equals(PanelMediaTargetType.TYPE_SCREEN) ) boolResult = doPreview (); else boolResult = false; setCursor ( Cursor.getDefaultCursor() ); return ( boolResult ); } private void configureProcessor () { boolean boolResult; if ( processor == null ) return; // wait for processor to be configured boolResult = waitForState ( processor, Processor.Configured ); if ( boolResult == false ) {// MessageDialog.createErrorDialog ( frameOwner, JMFI18N.getResource("jmstudio.error.processor.configure") + " " + strFailMessage ); MessageDialog.createErrorDialog ( frameOwner, strFailMessage ); destroyProcessor (); } } private void realizeProcessor () { boolean boolResult; if ( processor == null ) return; // wait for processor to be configured boolResult = waitForState ( processor, Processor.Realized ); if ( boolResult == false ) {// MessageDialog.createErrorDialog ( frameOwner, JMFI18N.getResource("jmstudio.error.processor.realize") + " " + strFailMessage ); MessageDialog.createErrorDialog ( frameOwner, strFailMessage ); destroyProcessor (); } } private void destroyProcessor () { if ( processor == null ) return; processor.close (); processor = null; panelSource.setDataSource ( null ); } Object stateLock = new Object(); boolean stateFailed = false; private synchronized boolean waitForState(Processor p, int state) { p.addControllerListener(new StateListener()); stateFailed = false; if (state == Processor.Configured) { p.configure(); } else if (state == Processor.Realized) { p.realize(); } while (p.getState() < state && !stateFailed) { synchronized (stateLock) { try { stateLock.wait(); } catch (InterruptedException ie) { return false; } } } return ( !stateFailed ); } private boolean doSaveFile () { int i; DataSource dsOutput; MediaLocator mediaDest; Object arrControls[]; int nMediaDuration; String strFileName; MonitorControl monitorControl = null; Component monitor = null; if ( processor == null ) return ( false ); panelTargetFormat.updateProcessorFormat (); realizeProcessor (); if ( processor == null ) return ( false ); dsOutput = processor.getDataOutput (); if ( dsOutput == null ) { MessageDialog.createErrorDialog ( frameOwner, JMFI18N.getResource("jmstudio.error.processor.creatednooutput") ); destroyProcessor (); return ( false ); } try { strFileName = panelTargetFile.getFileName (); mediaDest = new MediaLocator ( "file:" + strFileName ); dataSinkSave = Manager.createDataSink ( dsOutput, mediaDest );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -