I’m trying to add video streaming to an audio app and have run across some problems with the iOS build. I’m using CameraDevice to capture the video with a listener to queue and encode frames. The project works fine in MacOS, but as soon as I try it on iOS the listener is called exactly once and never again. I also hear the simulated shutter sound on the device, which would suggest that it’s just taking a still picture. The preview component works fine. This is the relevant code:
void VideoCapture::openCameraAsync( int deviceNumber )
{
SafePointer<VideoCapture> This (this);
CameraDevice::openDeviceAsync ( deviceNumber,
[This] (CameraDevice* device, const String& error) mutable
{
This->cameraDeviceOpenResult (device, error);
});
}
void VideoCapture::cameraDeviceOpenResult (CameraDevice* device, const String& error)
{
// If camera opening worked, create a preview component for it..
cameraDevice.reset (device);
if ( cameraDevice.get() != nullptr)
{
cameraDevice->addListener( this );
cameraPreviewComp.reset (cameraDevice->createViewerComponent());
addAndMakeVisible (cameraPreviewComp.get());
resized ();
DBG ( "Camera opened OK" );
}
else
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Camera open failed",
"Camera open failed, reason: " + error);
delete this;
}
}
void VideoCapture::imageReceived (const Image &image)
{
if ( image.getWidth() == 0 ) return;
Image *imageCopy = new Image ( image.rescaled ( image.getWidth()/2, image.getHeight()/2) );
encoderQueue->pushItem( imageCopy );
frameCycle=0;
}
Any ideas?