FileDocCategorySizeDatePackage
PanelMediaSource.javaAPI DocJMF 2.1.1e8634Mon May 12 12:20:32 BST 2003jmapps.export

PanelMediaSource

public class PanelMediaSource extends JMPanel implements ActionListener, TextListener

Fields Summary
private JMAppsCfg
cfgJMApps
private TextField
textSource
private Button
buttonBrowseFile
private Button
buttonBrowseCapture
private CaptureDialog
dlgCapture
private CaptureControlsDialog
dlgCaptureControls
private boolean
boolSettingCaptureSource
private String
strContentTypeDefault
private DataSource
dataSource
Constructors Summary
public PanelMediaSource(JMAppsCfg cfgJMApps)

    
          
        super ();

        this.cfgJMApps = cfgJMApps;
        try {
            init ();
        }
        catch ( Exception exception ) {
            exception.printStackTrace ();
        }
    
Methods Summary
public voidSaveData()

        String    strSourceUrl;

        strSourceUrl = textSource.getText ();
        if ( cfgJMApps != null  &&  strSourceUrl != null )
            cfgJMApps.setLastTransmitRtpSource ( strSourceUrl );
    
public voidactionPerformed(java.awt.event.ActionEvent event)

        String        strCmd;

        strCmd = event.getActionCommand ();
        if ( strCmd.equals(buttonBrowseFile.getLabel()) ) {
            browseFile ();
        }
        else if ( strCmd.equals(buttonBrowseCapture.getLabel()) ) {
            browseCapture ();
        }
    
private voidbrowseCapture()

        String     strAction;

        if ( dlgCapture == null )
            dlgCapture = new CaptureDialog ( getFrame(), cfgJMApps );
        dlgCapture.show ();
        strAction = dlgCapture.getAction ();
        if ( strAction.equals(dlgCapture.ACTION_OK) ) {
            boolSettingCaptureSource = true;
            textSource.setText ( dlgCapture.toString() );
        }
        else { // canceled
            dlgCapture = null;
        }
    
private voidbrowseFile()

        FileDialog    dlgFile;
        String          strFile;
        String        strDir;
        int           nIndex;

        strFile = textSource.getText ();
        try {
            dlgFile = new FileDialog ( getFrame(),
                        JMFI18N.getResource("jmstudio.export.source.filedialog"),
                        FileDialog.LOAD );
        }
        catch ( Exception exception ) {
            MessageDialog.createErrorDialog ( getFrame(),
                        JMFI18N.getResource("jmstudio.error.fgiledialog") );
            return;
        }

        nIndex = strFile.indexOf ( ':" );
        if ( nIndex > 0  &&  strFile.substring(0,nIndex).equalsIgnoreCase("file") ) {
            strFile = strFile.substring ( nIndex + 1 );
            dlgFile.setFile ( strFile );
        }
        dlgFile.show ();

        strFile = dlgFile.getFile ();
        strDir = dlgFile.getDirectory ();
        if ( strFile != null  &&  strFile.length() > 0 ) {
            strFile = "file:" + strDir + strFile;
            textSource.setText ( strFile );
            dlgCapture = null;
        }
    
public javax.media.ProcessorcreateProcessor()

        String          strSourceUrl;
        MediaLocator    mediaSource;
        Processor       processor = null;
        boolean         boolResult;
        String          strContentType;


        strContentTypeDefault = null;
        dlgCaptureControls = null;

        if ( dataSource == null ) {
            if ( dlgCapture != null ) {
                dataSource = dlgCapture.createCaptureDataSource ();
                // dlgCapture = null;
            }
            else {
                strSourceUrl = getSourceUrl ();
                try {
                    mediaSource = new MediaLocator ( strSourceUrl );
                    dataSource = Manager.createDataSource ( mediaSource );
                }
                catch ( Exception exception ) {
                    MessageDialog.createErrorDialog ( getFrame(),
                        JMFI18N.getResource("jmstudio.error.datasource.createfor")
                        + " \'" + strSourceUrl + "\'. ", exception );
                }
            }
        }

        if ( dataSource == null ) {
            setCursor ( Cursor.getDefaultCursor() );
            return ( null );
        }

        if ( dataSource instanceof CaptureDevice ) {
            dlgCaptureControls = new CaptureControlsDialog ( getFrame(), dataSource );
        }

        strContentType = dataSource.getContentType();
        if ( strContentType != null )
            strContentTypeDefault = (new ContentDescriptor(strContentType)).toString ();

        try {
            processor = Manager.createProcessor ( dataSource );
        }
        catch ( Exception exception ) {
            MessageDialog.createErrorDialog ( this.getFrame(),
                        JMFI18N.getResource("jmstudio.error.processor.create"),
                        exception );
            exception.printStackTrace ();
            setCursor ( Cursor.getDefaultCursor() );
            return ( null );
        }

        return ( processor );
    
public jmapps.jmstudio.CaptureControlsDialoggetCaptureControlsDialog()

        return ( dlgCaptureControls );
    
public java.lang.StringgetDefaultContentType()

        return ( strContentTypeDefault );
    
public java.lang.StringgetSourceUrl()

        String    strSourceUrl;

        strSourceUrl = textSource.getText ();
        return ( strSourceUrl );
    
private voidinit()

        Panel    panel;
        Panel    panelDescription;
        Panel    panelEntry;
        Panel    panelButtons;
        Panel    panelButtons1;
        Panel    panelButtons2;
        Label    label;


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

        panelDescription = new Panel ( new GridLayout(0,1) );
        this.add ( panelDescription, BorderLayout.NORTH );

        panelDescription.add ( new Label(JMFI18N.getResource("jmstudio.export.source.label1")) );
        panelDescription.add ( new Label(JMFI18N.getResource("jmstudio.export.source.label2")) );

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

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

        textSource = new TextField ();
        textSource.addTextListener ( this );
        panelEntry.add ( textSource, BorderLayout.CENTER );

        panelButtons1 = new Panel ( new BorderLayout(6,6) );
        panel.add ( panelButtons1, BorderLayout.CENTER );
        panelButtons2 = new Panel ( new BorderLayout(6,6) );
        panelButtons1.add ( panelButtons2, BorderLayout.NORTH );
        panelButtons = new Panel ( new GridLayout(1,0,6,6) );
        panelButtons2.add ( panelButtons, BorderLayout.WEST );

        buttonBrowseFile = new Button ( JMFI18N.getResource("jmstudio.export.source.file") );
        buttonBrowseFile.addActionListener ( this );
        panelButtons.add ( buttonBrowseFile );

        buttonBrowseCapture = new Button ( JMFI18N.getResource("jmstudio.export.source.capture") );
        buttonBrowseCapture.addActionListener ( this );
        panelButtons.add ( buttonBrowseCapture );
    
public voidsetCaptureDlg(jmapps.jmstudio.CaptureDialog cdlg)

	this.dlgCapture = cdlg;
    
public voidsetDataSource(javax.media.protocol.DataSource ds)

	    dataSource = ds;
    
public voidsetJMStudioCfg(jmapps.util.JMAppsCfg cfgJMApps)

        String  strSourceUrl = null;

        this.cfgJMApps = cfgJMApps;
        if ( cfgJMApps != null )
            strSourceUrl = cfgJMApps.getLastTransmitRtpSource ();
        if ( strSourceUrl != null )
            textSource.setText ( strSourceUrl );
    
public voidsetSourceUrl(java.lang.String strSourceUrl)

        if ( strSourceUrl != null  &&  strSourceUrl.trim().length() > 0 )
            textSource.setText ( strSourceUrl );
    
public voidtextValueChanged(java.awt.event.TextEvent event)

        Object        objectSource;

        objectSource = event.getSource ();
        if ( objectSource == textSource ) {
            if ( boolSettingCaptureSource == true )
                boolSettingCaptureSource = false;
            else
                dlgCapture = null;
            dataSource = null;
        }