Fix a problem with DirectShow's DataSource when the sequence connect/disconnect/connect appears.

cusax-fix
Sebastien Vincent 16 years ago
parent 614d1c55c9
commit 947ec55fd6

@ -86,6 +86,11 @@ public class DataSource extends AbstractPushBufferCaptureDevice
*/
static final int DEFAULT_HEIGHT = 480;
/**
* Last known native DirectShow format.
*/
private DSFormat nativeFormat = null;
/**
* Constructor.
*/
@ -301,7 +306,13 @@ protected Format setFormat(
{
DSFormat fmt = new DSFormat(newSize.width, newSize.height,
pixelFormat);
device.setFormat(fmt);
/* we will set native format in doStart() because in case of
* sequence connect/disconnect/connect native capture device
* can ordered its formats in different way. Thus as
* setFormat() is not called anymore by JMF it can cause
* crash because of wrong format later (typically scaling)
*/
nativeFormat = fmt;
}
}
@ -370,9 +381,16 @@ protected void doStart() throws IOException
{
if (logger.isInfoEnabled())
logger.info("start");
/* open and start capture */
device.open();
device.setDelegate(grabber);
if(nativeFormat != null)
{
device.setFormat(nativeFormat);
}
device.setDelegate(grabber);
super.doStart();
}

Loading…
Cancel
Save