Methods Summary |
---|
protected boolean | audioEnabled()
return audioEnabled;
|
private void | closeSessions()
synchronized (closeSync) {
for (int i = 0; i < mgrs.length; i++) {
if (mgrs[i] != null) {
mgrs[i].removeTargets( "Closing session from the RTP Handler");
mgrs[i].dispose();
mgrs[i] = null;
}
}
}
|
protected void | completeConfigure()
state = javax.media.Processor.Configured;
super.completeConfigure();
|
protected void | completeRealize()
state = Realized;
super.completeRealize();
|
protected void | doClose()
closed = true;
synchronized (dataLock) {
dataLock.notify();
}
stop();
if( processor != null) {
processor.close();
}
closeSessions();
super.doClose();
|
protected synchronized boolean | doConfigure()
super.doConfigure();
try {
if (source instanceof RTPSocket) {
// this constructor will take care of initliasing and
// starting the session as well as updating the encodings
// from the RTPControl
mgrs = new RTPSessionMgr[1];
mgrs[1] = new RTPSessionMgr((RTPSocket)source);
mgrs[1].addReceiveStreamListener(this);
sources = new DataSource[1];
sources[0] = source;
formats = new Format[1];
dataReady = false;
} else {
RTPMediaLocator rml;
InetAddress ipAddr;
SessionAddress localAddr = new SessionAddress();
SessionAddress destAddr;
mgrs = new RTPSessionMgr[locators.size()];
sources = new DataSource[locators.size()];
formats = new Format[locators.size()];
dataReady = false;
for (int i = 0; i < locators.size(); i++) {
rml = (RTPMediaLocator)locators.elementAt(i);
mgrs[i] = (RTPSessionMgr) RTPManager.newInstance();
mgrs[i].addReceiveStreamListener(this);
ipAddr = InetAddress.getByName(rml.getSessionAddress());
if( ipAddr.isMulticastAddress()) {
// local and remote address pairs are identical:
localAddr= new SessionAddress( ipAddr,
rml.getSessionPort(),
rml.getTTL());
destAddr = new SessionAddress( ipAddr,
rml.getSessionPort(),
rml.getTTL());
} else {
localAddr= new SessionAddress( InetAddress.getLocalHost(),
rml.getSessionPort());
destAddr = new SessionAddress( ipAddr,
rml.getSessionPort());
}
mgrs[ i].initialize( localAddr);
mgrs[i].addTarget(destAddr);
}
}
} catch (Exception e){
Log.error("Cannot create the RTP Session: " + e.getMessage());
processError = sessionError;
return false;
}
// dont configure this meta player until the internal processor
// is configured
try{
synchronized (dataLock) {
while (!dataReady && !isInterrupted() && !closed)
dataLock.wait();
}
} catch (Exception e) {}
// If configure is being interrupted, return failure from configure.
if (closed || isInterrupted()) {
resetInterrupt();
processError = "no RTP data was received.";
return false;
}
return true;
|
protected void | doDeallocate()
processor.deallocate();
synchronized (dataLock) {
dataLock.notifyAll();
}
|
protected void | doFailedConfigure()
closeSessions();
super.doFailedConfigure();
|
protected void | doFailedRealize()
closeSessions();
super.doFailedRealize();
|
protected boolean | doRealize()
return waitForRealize(processor);
|
protected void | doStart()
super.doStart();
waitForStart(processor);
|
protected void | doStop()
super.doStop();
waitForStop(processor);
|
public javax.media.protocol.ContentDescriptor | getContentDescriptor()
super.getContentDescriptor();
return processor.getContentDescriptor();
|
public javax.media.Control[] | getControls()Return the list of controls from its slave controllers plus the
ones that this player supports.
return processor.getControls();
|
public javax.media.protocol.DataSource | getDataOutput()
super.getDataOutput();
return processor.getDataOutput();
|
protected javax.media.TimeBase | getMasterTimeBase()
return new SystemTimeBase();
|
public javax.media.protocol.ContentDescriptor[] | getSupportedContentDescriptors()
super.getSupportedContentDescriptors();
return processor.getSupportedContentDescriptors();
|
public javax.media.control.TrackControl[] | getTrackControls()
super.getTrackControls();
return processor.getTrackControls();
|
public java.awt.Component | getVisualComponent()Obtain the visiual component from the media engine.
/**
* Call the superclass method to ensure that restrictions
* on player methods are enforced
*/
super.getVisualComponent();
return processor.getVisualComponent();
|
private void | invalidateComp()
controlComp = null;
controls = null;
|
private void | sendMyEvent(javax.media.ControllerEvent e)
super.sendEvent(e);
|
public javax.media.protocol.ContentDescriptor | setContentDescriptor(javax.media.protocol.ContentDescriptor ocd)
super.setContentDescriptor(ocd);
return processor.setContentDescriptor(ocd);
|
public void | setSource(javax.media.protocol.DataSource source)
super.setSource(source);
if (source instanceof com.sun.media.protocol.rtp.DataSource){
MediaLocator ml = source.getLocator();
String mlStr = ml.getRemainder();
String str;
int start, idx;
start = 0;
while (mlStr.charAt(start) == '/")
start++;
locators = new Vector();
RTPMediaLocator rml;
try {
while (start < mlStr.length() &&
(idx = mlStr.indexOf("&", start)) != -1) {
str = mlStr.substring(start, idx);
rml = new RTPMediaLocator("rtp://" + str);
locators.addElement(rml);
start = idx+1;
}
if (start != 0)
str = mlStr.substring(start);
else
str = mlStr;
rml = new RTPMediaLocator("rtp://" + str);
locators.addElement(rml);
} catch (Exception e) {
throw new IncompatibleSourceException();
}
} else if (!(source instanceof RTPSocket)) {
throw new IncompatibleSourceException();
}
// we will set the dynamic encoding for the one
// encoding we dont use from static RTP payloads
RTPControl ctl = (RTPControl)
source.getControl("javax.media.rtp.RTPControl");
if (ctl != null)
ctl.addFormat(new AudioFormat(AudioFormat.DVI_RTP,
44100,
4,
1),
18);
|
public void | setTimeBase(javax.media.TimeBase tb)
|
public void | update(javax.media.rtp.event.ReceiveStreamEvent event)
RTPSessionMgr mgr = (RTPSessionMgr)event.getSource();
int idx;
for (idx = 0; idx < mgrs.length; idx++) {
if (mgrs[idx] == mgr)
break;
}
if (idx >= mgrs.length) {
// Something's wrong.
System.err.println("Unknown manager: " + mgr);
return;
}
if (event instanceof RemotePayloadChangeEvent) {
Log.comment("Received an RTP PayloadChangeEvent");
Log.error("The RTP processor cannot handle mid-stream payload change.\n");
sendEvent(new ControllerErrorEvent(this, "Cannot handle mid-stream payload change."));
close();
}// payload change event
if (event instanceof NewReceiveStreamEvent){
if (sources[idx] != null) {
// We've already gotten a source from this session.
return;
}
ReceiveStream stream = null;
try{
// get a handle over the ReceiveStream
stream =((NewReceiveStreamEvent)event).getReceiveStream();
sources[idx] = stream.getDataSource();
RTPControl ctl = (RTPControl)sources[idx].getControl("javax.media.rtp.RTPControl");
if (ctl != null){
formats[idx] = ctl.getFormat();
if (formats[idx] instanceof AudioFormat)
audioEnabled = true;
if (formats[idx] instanceof VideoFormat)
videoEnabled = true;
}
if (source instanceof RTPSocket)
((RTPSocket)source).setChild(sources[idx]);
else
((com.sun.media.protocol.rtp.DataSource)source).
setChild((com.sun.media.protocol.rtp.DataSource)sources[idx]);
for (int i = 0; i < sources.length; i++) {
// Return if not all sessions had yielded a source.
if (sources[i] == null)
return;
}
// We've received all the sources, let create the processor.
DataSource mixDS;
try {
mixDS = javax.media.Manager.createMergingDataSource(sources);
} catch (Exception e) {
System.err.println("Cannot merge data sources.");
return;
}
try {
processor = javax.media.Manager.createProcessor(mixDS);
} catch (Exception e) {
System.err.println("Cannot create the mix processor.");
return;
}
if (!waitForConfigure(processor))
return;
// We are done generating the internal processor.
synchronized(dataLock) {
dataReady = true;
dataLock.notifyAll();
}
} catch (Exception e){
System.err.println("NewReceiveStreamEvent exception " +
e.getMessage());
return;
}
}// instanceof newReceiveStreamEvent
|
public void | updateStats()
if ( processor != null) {
((BasicProcessor) processor).updateStats();
}
|
protected boolean | videoEnabled()
return videoEnabled;
|
private void | waitForClose(javax.media.Player p)
(new StateWaiter()).waitForClose(p);
|
private boolean | waitForConfigure(javax.media.Processor p)
return (new StateWaiter()).waitForConfigure(p);
|
private boolean | waitForRealize(javax.media.Processor p)
return (new StateWaiter()).waitForRealize(p);
|
private void | waitForStart(javax.media.Player p)
(new StateWaiter()).waitForStart(p, true);
|
private void | waitForStop(javax.media.Player p)
(new StateWaiter()).waitForStart(p, false);
|