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

📄 genericmediaservice.java

📁 jtapi for telephone
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	/* @see PlayerListener#onPause(PlayerEvent) */ 
	public void onPause(PlayerEvent playerevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof PlayerListener) {
		try {
		    ((PlayerListener)listener).onPause(playerevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/* @see RecorderListener#onPause(RecorderEvent) */ 
	public void onPause(RecorderEvent recorderevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof RecorderListener) {
		try {
		    ((RecorderListener)listener).onPause(recorderevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/* @see PlayerListener#onResume(PlayerEvent) */ 
	public void onResume(PlayerEvent playerevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof PlayerListener) {
		try {
		    ((PlayerListener)listener).onResume(playerevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/* @see RecorderListener#onResume(RecorderEvent) */ 
	public void onResume(RecorderEvent recorderevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof RecorderListener) {
		try {
		    ((RecorderListener)listener).onResume(recorderevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/* @see SignalDetectorListener#onSignalDetected(SignalDetectorEvent) */ 
	public void onSignalDetected(SignalDetectorEvent signaldetectorevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof SignalDetectorListener) {
		try {
		    ((SignalDetectorListener)listener).onSignalDetected(signaldetectorevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/* @see PlayerListener#onSpeedChange(PlayerEvent) */ 
	public void onSpeedChange(PlayerEvent playerevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof PlayerListener) {
		try {
		    ((PlayerListener)listener).onSpeedChange(playerevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/* @see PlayerListener#onVolumeChange(PlayerEvent) */ 
	public void onVolumeChange(PlayerEvent playerevent0) 
	{
	EventListener listener; 
	Iterator iter = theListeners.iterator();
	while(iter.hasNext()) {
	    listener = (EventListener)iter.next();
	    if(listener instanceof PlayerListener) {
		try {
		    ((PlayerListener)listener).onVolumeChange(playerevent0);
		} catch (Exception ex) {}
	    }
	}
	}
	/**
	 * Play a set of dtmf signals on the bound media group.
	 **/


	/* @see Player#play(String, int, RTC[], Dictionary) */ 
	public PlayerEvent play(String[] streamId, int offset, RTC[] rtcs, Dictionary optArgs)
	throws MediaResourceException 
	{
	return ((Player)checkGroup()).
	play(streamId, offset, rtcs, optArgs);
	}
	/**
	 * Play a set of dtmf signals on the bound media group.
	 **/


	/* @see Player#play(String, int, RTC[], Dictionary) */ 
	public PlayerEvent play(String streamId, int offset, RTC[] rtcs, Dictionary optArgs)
	throws MediaResourceException 
	{
	return ((Player)checkGroup()).
	play(streamId, offset, rtcs, optArgs);
	}
	/* @see Recorder#record(String, RTC[], Dictionary) */ 
	public RecorderEvent record(String string0, RTC[] rtc1, Dictionary dictionary2)
	throws MediaResourceException 
	{
	return ((Recorder)checkGroup()).
	record(string0, rtc1, dictionary2);
	}
/*
 * Release the MediaGroup with an indication that the 
 * Connection (and perhaps the Call) should be,
 * or perhaps already has been, dropped.
 * <p>
 * In general, this method will provoke framework specific processing
 * to handle the end of the call. 
 * <p>
 * @exception NotBoundException if not currently bound to a MediaGroup
 * <p>
 */
public void release() {
	// should we disconnect?
	boolean disconnect = this.getProvider().disconnectOnMediaRelease();
	Connection conn = null;
	
	if (disconnect) {
		// store the Connection
		TerminalConnection[] tcs = this.getTerminal().getTerminalConnections();
		if ((tcs != null) || (tcs.length >0))
			conn = tcs[0].getConnection();
	}
	
	this.releaseAndFree();
	
	// now, disconnect the call if the Provider thinks we should
	if (conn != null) {
		try {
			conn.disconnect();
		} catch (ResourceUnavailableException rue) {
			// fail silently -- we tried our best
		} catch (MethodNotSupportedException mnse) {
			// fail silently -- we tried our best
		} catch (InvalidStateException ise) {
			// fail silently -- we tried our best
		} catch (PrivilegeViolationException pve) {
			// fail silently -- we tried our best
		}
	}
}

/*
 * Private release. This is used both by the MediaService.release() and the
 * finalize method. This means that finalize doesn't cause a line to be dropped.
 */
private void releaseAndFree() {
	this.releaseGroup().free();
}

/*
 * Release the MediaGroup from a MediaService.
 * Note that the MediaGroup is still associated with a call.
 *
 * @exception NotBoundException if not currently bound to a MediaGroup
 */
synchronized private GenericMediaGroup releaseGroup() {
	GenericMediaGroup mg = this.checkGroup();
	this.getMgr().release(this.getTerminalName());
	this.setMediaGroup(null);
	mg.freeService();
	return mg;
}
	/*
	 * Release the bound terminal to the next waiting media service for further processing.
	 * <p>
	 * @param disposition A string that identifies the next MediaService. 
	 * @param timeout int milliseconds to wait for new service to become ready.
	 *
	 * @exception NotBoundException if not currently bound to a MediaGroup
	 * @exception MediaBindException one of NoServiceAssignedException or NoServiceReadyException
	 * @exception NoServiceAssignedException if disposition is not recognised 
	 * or is not mapped to any serviceName.
	 * @exception NoServiceReadyException if disposition is mapped to a serviceName,
	 * but none of the MediaServices registered to serviceName 
	 * are ready and do not become ready within <i>timeout</i> millisecs.
	 * @exception MediaConfigException if the MediaGroup could not be configured
	 * for the recipient service.
	 */
	synchronized
	public void releaseToService(String disposition, int timeout)
	throws MediaBindException, MediaConfigException {
		GenericMediaGroup mg = this.releaseGroup();

		// try to pass MediaGroup to next bound service
		MediaMgr mgr = this.getMgr();
		MediaService ms = mgr.unRegister(disposition);
		if (ms == null) {
			ms = mgr.waitForMediaService(mg, disposition, timeout);
			if (ms == null)
				throw new NoServiceReadyException("No MediaService registered for " + disposition);
		}
		((GenericMediaService)ms).bindToGroup(mg);
	}
	/** remove this MediaListener. */
	public void removeMediaListener(MediaListener listener) {
	 theListeners.remove(listener);
	}
	/* @see SignalDetector#retrieveSignals(int, Symbol[], RTC[], Dictionary) */ 
	public SignalDetectorEvent retrieveSignals(int int0, Symbol[] symbol1, RTC[] rtc2, Dictionary dictionary3)
	throws MediaResourceException 
	{
	return ((SignalDetector)checkGroup()).
	retrieveSignals(int0, symbol1, rtc2, dictionary3);
	}
	/* @see SignalGenerator#sendSignals(Symbol[], RTC[], Dictionary) */ 
	public SignalGeneratorEvent sendSignals(Symbol[] symbol0, RTC[] rtc1, Dictionary dictionary2)
	throws MediaResourceException 
	{
	return ((SignalGenerator)checkGroup()).
	sendSignals(symbol0, rtc1, dictionary2);
	}
	/* @see SignalGenerator#sendSignals(String, RTC[], Dictionary) */ 
	public SignalGeneratorEvent sendSignals(String string0, RTC[] rtc1, Dictionary dictionary2)
	throws MediaResourceException 
	{
	return ((SignalGenerator)checkGroup()).
	sendSignals(string0, rtc1, dictionary2);
	}
/**
 * Insert the method's description here.
 * Creation date: (2000-03-13 15:04:17)
 * @author: 
 * @param newMediaGroup net.sourceforge.gjtapi.media.GenericMediaGroup
 */
private void setMediaGroup(GenericMediaGroup newMediaGroup) {
	mediaGroup = newMediaGroup;
}
/*
 * Set the value of various parameters to the given values.
 */
public void setParameters(Dictionary params) throws NotBoundException {
	this.checkGroup().setParameters(params);
}
/*
 * Set the entire UserDictionary to a new collection of key-value pairs.
 * <p>
 * Note: 
 * setUserDictionary(null) will clear all key-value pairs from the Dictionary.
 * <p>
 * @param newDict A Dictionary whose contents is copied into the MediaGroup.
 * @exception NotBoundException if not currently bound to a MediaGroup
 */
public void setUserDictionary(Dictionary newDict) throws NotBoundException {
	this.checkGroup().setDictionary(newDict);
}
/**
 * Set the values of several UserDictionary keys.
 *
 * The values supplied in the given <code>dict</code>
 * are merged with the current UserDictionary.
 *
 * @param dict a Dictionary whose contents is merged into the UserDictionary.
 * @throws NotBoundException if not currently bound to a MediaGroup
 */
public void setUserValues(Dictionary newDict) throws NotBoundException {
	this.checkGroup();
	Dictionary dict = this.getMediaGroup().getDictionary();
	Enumeration keySet = newDict.keys();
	while (keySet.hasMoreElements()) {
		Object key = keySet.nextElement();
		dict.put(key, newDict.get(key));
	}
}
/*
 * Stop all media/resource operations currently in progress.
 * Unblocks all synchronous resource methods (all AsyncResourceEvent complete).
 * <p>
 * This is a non-blocking, one-way invocation.
 *
 * @exception NotBoundException if not currently bound to a MediaGroup
 */
public void stop() throws NotBoundException {
	String term = this.getTerminalName();
	this.getProvider().getRaw().stop(term);
}
/*
 * Trigger a RTC action.
 * <p>
 * This method allows the application to synthesize the triggering
 * of RTC actions. The RTC Condition will be rtcc_Application.
 * <p>
 * This is a non-blocking, one-way invocation.
 *
 * @param a Symbol for a recognized RTC action: rtca_<i>Action</i>
 * @exception NotBoundException if not currently bound to a MediaGroup
 */
public void triggerRTC(Symbol rtca) throws NotBoundException {
	String term = this.getTerminalName();
	this.getProvider().getRaw().triggerRTC(term, rtca);
}
}

⌨️ 快捷键说明

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