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

📄 panelmediatargetformat.java

📁 里面是关于jmf编程的例子,希望能给初学者带来一些帮助
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return ( arrResult );    }    public void actionPerformed ( ActionEvent event ) {        String        strCmd;        Object        objectSource;        strCmd = event.getActionCommand ();        objectSource = event.getSource ();        if ( strCmd.equals(AudioFormatChooser.ACTION_TRACK_ENABLED) ) {            if ( objectSource instanceof AudioFormatChooser )                tabControl.setPageImage ( (Panel)objectSource, imageAudioEn );        }        else if ( strCmd.equals(AudioFormatChooser.ACTION_TRACK_DISABLED) ) {            if ( objectSource instanceof AudioFormatChooser )                tabControl.setPageImage ( (Panel)objectSource, imageAudioDis );        }        else if ( strCmd.equals(VideoFormatChooser.ACTION_TRACK_ENABLED) ) {            if ( objectSource instanceof VideoFormatChooser )                tabControl.setPageImage ( (Panel)objectSource, imageVideoEn );        }        else if ( strCmd.equals(VideoFormatChooser.ACTION_TRACK_DISABLED) ) {            if ( objectSource instanceof VideoFormatChooser )                tabControl.setPageImage ( (Panel)objectSource, imageVideoDis );        }    }    public void itemStateChanged ( ItemEvent event ) {        Object              objectSource;        objectSource = event.getSource ();        if ( objectSource == comboContentType ) {            changeContentType ();        }    }    private void buildPage () {        int      i;        int      nCount;        String   strContType;        Panel    panelFormat;        Panel    panel;        Label    label;        panelFormat = new Panel ( new BorderLayout(6,6) );        panelContent.add ( panelFormat, BorderLayout.NORTH );        label = new Label ( JMFI18N.getResource("jmstudio.export.format.format") );        panelFormat.add ( label, BorderLayout.WEST );        comboContentType = new Choice ();        comboContentType.addItemListener ( this );        nCount = arrContentDescriptors.length;        hashtableContentDescriptors = new Hashtable ();        for ( i = 0;  i < nCount;  i++ ) {            strContType = arrContentDescriptors[i].getContentType();            // filter            if ( !isContentTypeAllowed(strContType) )                continue;            strContType = arrContentDescriptors[i].toString ();            comboContentType.addItem ( strContType );            hashtableContentDescriptors.put ( strContType, arrContentDescriptors[i] );        }        panelFormat.add ( comboContentType, BorderLayout.CENTER );        panel = buildTrackFormatPanel ();        panelContent.add ( panel, BorderLayout.CENTER );    }    private Panel buildTrackFormatPanel () {//        Panel               panel;        AudioFormatChooser  chooserAudio;        VideoFormatChooser  chooserVideo;        int                 i;        int                 nCount;        int                 nIndexAudio;        int                 nIndexVideo;        int                 nAudioTrackCount = 0;        int                 nVideoTrackCount = 0;        Format              format;        String              strTitle;        String              strEncoding;        String              strAudio = JMFI18N.getResource("jmstudio.export.format.audio");        String              strVideo = JMFI18N.getResource("jmstudio.export.format.video");        String              strHinted = JMFI18N.getResource("jmstudio.export.format.hinted");        tabControl = new TabControl ( TabControl.ALIGN_TOP );        nIndexAudio = 0;        nIndexVideo = 0;        nAudioTrackCount = 0;        nVideoTrackCount = 0;        vectorPanelsAudio = new Vector ();        vectorPanelsVideo = new Vector ();        vectorTracksAudio = new Vector ();        vectorTracksVideo = new Vector ();        nCount = arrTrackControls.length;        for ( i = 0;  i < nCount;  i++ ) {            format = arrTrackControls[i].getFormat ();            if ( format instanceof VideoFormat )                nVideoTrackCount++;            if ( format instanceof AudioFormat )                nAudioTrackCount++;        }        for ( i = 0;  i < nCount;  i++ ) {            format = arrTrackControls[i].getFormat ();            if ( format instanceof AudioFormat ) {                if ( nAudioTrackCount < 2 )                    strTitle = new String ( strAudio );                else {                    nIndexAudio++;                    strTitle = new String ( strAudio + " " + nIndexAudio );                }                strEncoding = format.getEncoding ();                if ( strEncoding.endsWith("/rtp") )                    strTitle = strTitle + " " + strHinted;                chooserAudio = new AudioFormatChooser ( arrTrackControls[i].getSupportedFormats(), (AudioFormat)format, true, this );                chooserAudio.setTrackEnabled ( arrTrackControls[i].isEnabled() );                tabControl.addPage ( chooserAudio, strTitle, imageAudioEn );                vectorPanelsAudio.addElement ( chooserAudio );                vectorTracksAudio.addElement ( arrTrackControls[i] );            }            else if ( format instanceof VideoFormat ) {                if ( nVideoTrackCount < 2 )                    strTitle = new String ( strVideo );                else {                    nIndexVideo++;                    strTitle = new String ( strVideo + " " + nIndexVideo );                }                strEncoding = format.getEncoding ();                if ( strEncoding.endsWith("/rtp") )                    strTitle = strTitle + " " + strHinted;                chooserVideo = new VideoFormatChooser ( arrTrackControls[i].getSupportedFormats(), (VideoFormat)format, true, this );                chooserVideo.setTrackEnabled ( arrTrackControls[i].isEnabled() );                tabControl.addPage ( chooserVideo, strTitle, imageVideoEn );                vectorPanelsVideo.addElement ( chooserVideo );                vectorTracksVideo.addElement ( arrTrackControls[i] );            }        }        return ( tabControl );    }    private void changeContentType () {        int                 i;        int                 nCount;        VideoFormatChooser  panelVideo;        AudioFormatChooser  panelAudio;        TrackControl        trackControl;        String              strContentType;        ContentDescriptor   contentDescriptor;        strContentType = comboContentType.getSelectedItem ();        contentDescriptor = (ContentDescriptor) hashtableContentDescriptors.get ( strContentType );        if ( processor.setContentDescriptor(contentDescriptor) == null ) {            System.err.println ( "Error setting content descriptor on " + "processor" );        }        nCount = vectorPanelsVideo.size ();        for ( i = 0;  i < nCount;  i++ ) {            panelVideo = (VideoFormatChooser) vectorPanelsVideo.elementAt ( i );            trackControl = (TrackControl) vectorTracksVideo.elementAt ( i );            panelVideo.setSupportedFormats ( trackControl.getSupportedFormats(), (VideoFormat)trackControl.getFormat() );        }        nCount = vectorPanelsAudio.size ();        for ( i = 0;  i < nCount;  i++ ) {            panelAudio = (AudioFormatChooser) vectorPanelsAudio.elementAt ( i );            trackControl = (TrackControl) vectorTracksAudio.elementAt ( i );            panelAudio.setSupportedFormats ( trackControl.getSupportedFormats(), (AudioFormat)trackControl.getFormat() );        }    }    private boolean isContentTypeAllowed ( String strContType ) {        int        i;        boolean    boolResult = false;        String     strTypeRaw;        String     strTypeRawRtp;        if ( arrAllowContentType != null ) {            for ( i = 0;  i < arrAllowContentType.length  &&  boolResult == false;  i++ ) {                if ( arrAllowContentType[i].equalsIgnoreCase(strContType) )                    boolResult = true;            }        }        else if ( strTargetType.equals(PanelMediaTargetType.TYPE_NETWORK) ) {            strTypeRaw = ContentDescriptor.mimeTypeToPackageName ( ContentDescriptor.RAW );            strTypeRawRtp = ContentDescriptor.mimeTypeToPackageName ( ContentDescriptor.RAW_RTP );            if ( strContType.equals(strTypeRaw)  ||  strContType.equals(strTypeRawRtp) )                boolResult = true;        }        else            boolResult = true;        return ( boolResult );    }}

⌨️ 快捷键说明

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