📄 jmstudio.java
字号:
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;
RTPSessionMgr 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 = (RTPSessionMgr) vectorMngrSessions.elementAt ( i );
if ( mngrSessionRtp == mngrSession )
mngrSessionRtp = null;
mngrSession.removeTargets( "Transmission terminated.");
mngrSession.dispose();
}
vectorMngrSessions.removeAllElements();
vectorMngrSessions = null;
}
if ( mngrSessionRtp != null ) {
mngrSessionRtp.removeTargets( "Transmission terminated.");
mngrSessionRtp.dispose();
mngrSessionRtp = null;
}
super.killCurrentPlayer ();
if (dataSourceCurrent != null) {
if (dataSourceCurrent instanceof CDSWrapper) {
((CDSWrapper)dataSourceCurrent).close();
}
}
dataSourceCurrent = null;
setTitle ( APPNAME );
killed = true;
if ( rtptimer != null && rtptimer.isAlive()) {
rtptimer.interrupt();
rtptimer = null;
}
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;
JMenu menuUrlType;
JMenuItem 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 JMenu ( 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 JMenuItem ( 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; args!=null && 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.killCurrentPlayer();
jmStudio.dispose();
}
}
public static void exitApllication () {
cleanUp ();
// System.exit ( 0 );
}
private static void cleanUp () {
if ( cfgJMApps != null )
cfgJMApps.save();
}
private Vector getEffectList(Format format) {
Vector v = PlugInManager.getPlugInList(format,
null,
PlugInManager.EFFECT);
return v;
}
private void fillEffectList(JMenu menu, Vector list) {
boolean first = true;
for (int i = 0; i < list.size(); i++) {
String className = (String) list.elementAt(i);
try {
Class cClass = Class.forName(className);
Codec codec = (Codec) cClass.newInstance();
String name = codec.getName();
if (first) {
first = false;
JCheckBoxMenuItem mi = new JCheckBoxMenuItem("None");
mi.setName("");
menu.add(mi);
mi.setState(true);
addEffectListener(mi);
}
JCheckBoxMenuItem mi = new JCheckBoxMenuItem(name);
mi.setName(className);
menu.add(mi);
mi.setState(false);
addEffectListener(mi);
} catch (Throwable t) {
}
}
}
private void addEffectListener(JCheckBoxMenuItem mi) {
mi.addItemListener( new EffectListener(mi) );
}
class WaitOnVis extends Thread {
VideoPanel vp;
MediaPlayer mp;
public WaitOnVis(VideoPanel vp, MediaPlayer mp) {
this.vp = vp;
this.mp = mp;
}
public void run() {
Component compVis = vp.getVisualComponent();
if (compVis != null) {
while (!compVis.isVisible()) {
try {
Thread.sleep(10);
} catch (InterruptedException ie) {
}
System.err.println("sleeping");
}
}
mp.prefetch();
}
}
class EffectListener implements ItemListener {
JCheckBoxMenuItem mi;
public EffectListener(JCheckBoxMenuItem mi) {
this.mi = mi;
}
public void itemStateChanged(ItemEvent ie) {
boolean state = mi.getState();
JMenu menu = (JMenu) mi.getParent();
for (int i = 0; i < menu.getItemCount(); i++) {
if (menu.getItem(i) != mi) {
((JCheckBoxMenuItem)menu.getItem(i)).setState(false);
}
}
if (state == false)
((JCheckBoxMenuItem)menu.getItem(0)).setState(true);
String name = mi.getName();
if (name == null || name.length() < 1)
name = null;
if (menu == menuAE)
audioEffect = name;
else
videoEffect = name;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -