Enables local video display for the QTKit CaptureDevice on Mac OS X.

cusax-fix
Lyubomir Marinov 16 years ago
parent 3e12b56315
commit 2f8ea6094c

@ -161,8 +161,7 @@ public int process(Buffer input, Buffer output)
final Dimension outputSize = ((VideoFormat) outputFormat).getSize();
/* rescale by preserving ratio */
final BufferedImage scaled = scalePreserveRatio(image, outputSize.width, outputSize.height); // TODO: is the size exact? what about rounding errors?
// System.out.println("scaled: " + scaled.getWidth() + "x" + scaled.getHeight());
final Buffer b = ImageToBuffer.createBuffer(scaled, ((VideoFormat) outputFormat).getFrameRate());
output.setData(b.getData());
output.setLength(b.getLength());

@ -135,7 +135,7 @@ protected DataSource createCaptureDevice()
* FIXME There is no video in calls when using the QuickTime/QTKit
* CaptureDevice so the local video support is disabled for it.
*/
if (!QuickTimeAuto.LOCATOR_PROTOCOL.equals(protocol))
// if (!QuickTimeAuto.LOCATOR_PROTOCOL.equals(protocol))
{
DataSource cloneableDataSource
= Manager.createCloneableDataSource(captureDevice);

@ -77,8 +77,12 @@ public abstract class AbstractPushBufferCaptureDevice
/**
* The <tt>PushBufferStream</tt>s through which this
* <tt>PushBufferDataSource</tt> gives access to its media data.
* <p>
* Warning: Caution is advised when directly using the field and access to
* it is to be synchronized with sync root <tt>this</tt>.
* </p>
*/
private AbstractPushBufferStream[] streams;
protected AbstractPushBufferStream[] streams;
/**
* Initializes a new <tt>AbstractPushBufferCaptureDevice</tt> instance.
@ -288,24 +292,24 @@ protected synchronized void doConnect()
*/
protected synchronized void doDisconnect()
{
if (streams != null)
try
{
for (AbstractPushBufferStream stream : streams)
stream.close();
}
finally
{
/*
* While it is not clear whether the streams can be released
* upon disconnect,
* com.imb.media.protocol.SuperCloneableDataSource gets the
* streams of the DataSource it adapts (i.e. this DataSource
* when SourceCloneable support support is to be created for it)
* before #connect().
*/
// streams = null;
}
/*
* While it is not clear whether the streams can be released upon
* disconnect, com.imb.media.protocol.SuperCloneableDataSource gets the
* streams of the DataSource it adapts (i.e. this DataSource when
* SourceCloneable support is to be created for it) before #connect().
* Unfortunately, it means that it isn't clear when the streams are to
* be disposed.
*/
// if (streams != null)
// try
// {
// for (AbstractPushBufferStream stream : streams)
// stream.close();
// }
// finally
// {
// streams = null;
// }
}
/**

@ -109,15 +109,16 @@ protected AbstractPushBufferStream createStream(
{
QuickTimeStream stream = new QuickTimeStream(formatControl);
try
{
captureSession.addOutput(stream.captureOutput);
}
catch (NSErrorException nseex)
{
logger.error("Failed to addOutput to QTCaptureSession", nseex);
throw new UndeclaredThrowableException(nseex);
}
if (captureSession != null)
try
{
captureSession.addOutput(stream.captureOutput);
}
catch (NSErrorException nseex)
{
logger.error("Failed to addOutput to QTCaptureSession", nseex);
throw new UndeclaredThrowableException(nseex);
}
return stream;
}
@ -167,6 +168,35 @@ protected void doConnect()
ioex.initCause(nseex);
throw ioex;
}
/*
* Add the QTCaptureOutputs represented by the QuickTimeStreams (if any)
* to the QTCaptureSession.
*/
synchronized (this)
{
if (streams != null)
for (AbstractPushBufferStream stream : streams)
if (stream != null)
try
{
captureSession
.addOutput(
((QuickTimeStream) stream).captureOutput);
}
catch (NSErrorException nseex)
{
logger
.error(
"Failed to addOutput to QTCaptureSession",
nseex);
IOException ioex = new IOException();
ioex.initCause(nseex);
throw ioex;
}
}
}
/**

@ -355,7 +355,7 @@ private void setCaptureOutputFormat(Format format)
{
VideoFormat videoFormat = (VideoFormat) format;
Dimension size = videoFormat.getSize();
System.err.println(format);
/*
* FIXME Mac OS X Leopard does not seem to report the size of the
* QTCaptureDevice in its formatDescriptions early in its creation.

Loading…
Cancel
Save