fixed deleting/stopping video devices

This commit is contained in:
csoler 2015-09-02 22:14:04 -04:00
parent b1572c2924
commit 77c0d562fb
3 changed files with 22 additions and 6 deletions

View File

@ -157,6 +157,8 @@ void AudioInputConfig::togglePreview(bool b)
AudioInputConfig::~AudioInputConfig() AudioInputConfig::~AudioInputConfig()
{ {
disconnect( qtTick, SIGNAL( timeout ( ) ), this, SLOT( on_Tick_timeout() ) );
graph_source->stop() ; graph_source->stop() ;
graph_source->setVideoInput(NULL) ; graph_source->setVideoInput(NULL) ;
@ -350,8 +352,10 @@ void AudioInputConfig::on_qcbTransmit_currentIndexChanged(int v) {
} }
void AudioInputConfig::on_Tick_timeout() { void AudioInputConfig::on_Tick_timeout()
if (!inputAudioProcessor) { {
if (!inputAudioProcessor)
{
inputAudioProcessor = new QtSpeex::SpeexInputProcessor(); inputAudioProcessor = new QtSpeex::SpeexInputProcessor();
inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered); inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
@ -376,7 +380,7 @@ void AudioInputConfig::on_Tick_timeout() {
// also transmit encoded video // also transmit encoded video
RsVOIPDataChunk chunk ; RsVOIPDataChunk chunk ;
while(videoInput->getNextEncodedPacket(chunk)) while((!videoInput->stopped()) && videoInput->getNextEncodedPacket(chunk))
{ {
videoProcessor->receiveEncodedData(chunk) ; videoProcessor->receiveEncodedData(chunk) ;
chunk.clear() ; chunk.clear() ;

View File

@ -15,6 +15,11 @@ QVideoInputDevice::QVideoInputDevice(QWidget *parent)
_echo_output_device = NULL ; _echo_output_device = NULL ;
} }
bool QVideoInputDevice::stopped()
{
return _timer == NULL ;
}
void QVideoInputDevice::stop() void QVideoInputDevice::stop()
{ {
if(_timer != NULL) if(_timer != NULL)
@ -54,6 +59,9 @@ void QVideoInputDevice::start()
void QVideoInputDevice::grabFrame() void QVideoInputDevice::grabFrame()
{ {
if(!_timer)
return ;
IplImage *img=cvQueryFrame(_capture_device); IplImage *img=cvQueryFrame(_capture_device);
if(img == NULL) if(img == NULL)
@ -87,6 +95,9 @@ void QVideoInputDevice::grabFrame()
bool QVideoInputDevice::getNextEncodedPacket(RsVOIPDataChunk& chunk) bool QVideoInputDevice::getNextEncodedPacket(RsVOIPDataChunk& chunk)
{ {
if(!_timer)
return false ;
if(_video_processor) if(_video_processor)
return _video_processor->nextEncodedPacket(chunk) ; return _video_processor->nextEncodedPacket(chunk) ;
else else
@ -100,7 +111,8 @@ uint32_t QVideoInputDevice::currentBandwidth() const
QVideoInputDevice::~QVideoInputDevice() QVideoInputDevice::~QVideoInputDevice()
{ {
stop() ; stop() ;
_video_processor = NULL ;
} }

View File

@ -51,8 +51,8 @@ class QVideoInputDevice: public QObject
void start() ; void start() ;
void stop() ; void stop() ;
bool stopped();
protected slots: protected slots:
void grabFrame() ; void grabFrame() ;
signals: signals: