Ejemplo n.º 1
0
void MainWindow::loadFile(const QString &fileName) {
    source.close();
    if (!source.open(fileName)) {
        QMessageBox::warning(this, tr("Can't open file"), source.error, QMessageBox::Ok);
       return;
    }

    finder.init(source.size);
    capture.init(source.size);
    labeler.init(source.movieLocation);

    ui->actionOpen_Video->setChecked(true);
    ui->actionOpen_Device_2->setChecked(false);

    ui->pauzeButton->setEnabled(false);
    ui->continueButton->setEnabled(true);
    ui->positionSlider->setEnabled(true);
    ui->recordButton->setEnabled(true);



    videoState = PAUZE;
    stopRecord();

    // do one step so we see something on the screen
    step();
    ui->CVWindow->setImage(&whatWeSee);

    heartBeat();
}
Ejemplo n.º 2
0
void MainWindow::openDevice() {
    source.close();
    if (!source.open(settings->deviceId)) {
        QMessageBox::warning(this, tr("Can't open file"), source.error, QMessageBox::Ok);
        return;
    }

    this->setWindowTitle(QString("Sonic Gesture - device %1").arg(settings->deviceId));

    finder.init(source.size);
    capture.init(source.size);

    ui->actionOpen_Video->setChecked(false);
    ui->actionOpen_Device_2->setChecked(true);

    ui->pauzeButton->setEnabled(false);
    ui->continueButton->setEnabled(false);
    ui->positionSlider->setEnabled(false);
    ui->recordButton->setEnabled(true);
    videoState = PLAY;
    stopRecord();

    // do one step so we see something on the screen
    step();
    ui->CVWindow->setImage(&whatWeSee);

    heartBeat();
};
Ejemplo n.º 3
0
/*
 * Close the device
 *
 * DEV  - device
 *
 * Called when closing the DMAbuf               (dmabuf.c:477)
 *      after halt_xfer
 */
static void
nm256_audio_close(int dev)
{
    struct nm256_info *card = nm256_find_card (dev);
	
    if (card != NULL) {
	int w;

	if (card->dev[0] == dev)
	    w = 0;
	else if (card->dev[1] == dev)
	    w = 1;
	else
	    return;

	card->opencnt[w]--;
	if (card->opencnt[w] <= 0) {
	    card->opencnt[w] = 0;

	    if (card->dev_for_play == dev) {
		stopPlay (card);
		card->is_open_play = 0;
		card->dev_for_play = -1;
	    }

	    if (card->dev_for_record == dev) {
		stopRecord (card);
		card->is_open_record = 0;
		card->dev_for_record = -1;
	    }
	}
    }
}
Ejemplo n.º 4
0
void MainWindow::record() {
    if (recording) {
        stopRecord();
    } else {
       startRecord();
    };
};
Ejemplo n.º 5
0
highSpeed::~highSpeed()
{
	if(bRecording) stopRecord();
	if(bOpen) XsCloseCamera(hCam);
	if(bDriverLoaded) XsUnloadDriver();
	free(pix);
}
Ejemplo n.º 6
0
void V4L2Camera::stop()
{
	int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	ioctl(fd_, VIDIOC_STREAMOFF, &type);

	stopRecord();

	if (fd_ != -1) {
		close(fd_);
		fd_ = -1;
	}

	if (use_mmap_) {
		for (unsigned i = 0; i < mmap_frames_; i++) {
			if (frameptrs_[i]) {
				munmap(frameptrs_[i], frame_size_);
				frameptrs_[i] = NULL;
			}
		}
	}

	if (retbuf_) {
		delete[] retbuf_;
		retbuf_ = NULL;
	}
}
  void run()
  {
    startRecord();

    display();

    stopRecord();
  }
Ejemplo n.º 8
0
void ofApp::keyPressed(int key) {
	if(key == ' ') {
		switch(mode) {
			case PREVIEW: stopPreview(); startRecord(); break;
			case RECORD: stopRecord(); startPlayback(); break;
			case PLAYBACK: stopPlayback(); startPreview(); break;
		}
	}
}
Ejemplo n.º 9
0
/* 
 * Initialize the hardware. 
 */
static void
nm256_initHw (struct nm256_info *card)
{
    /* Reset everything. */
    nm256_writePort8 (card, 2, 0x0, 0x11);
    nm256_writePort16 (card, 2, 0x214, 0);

    stopRecord (card);
    stopPlay (card);
}
Ejemplo n.º 10
0
/* Stop the current operations associated with DEV.  */
static void
nm256_audio_reset(int dev)
{
    struct nm256_info *card = nm256_find_card (dev);

    if (card != NULL) {
	if (card->dev_for_play == dev)
	    stopPlay (card);
	if (card->dev_for_record == dev)
	    stopRecord (card);
    }
}
Ejemplo n.º 11
0
void MainWindow::startScreen() {
    stopRecord();
    source.startScreen();
    videoState = PLAY;
    ui->pauzeButton->setEnabled(false);
    ui->continueButton->setEnabled(false);
    ui->positionSlider->setEnabled(false);
    ui->recordButton->setEnabled(false);
    ui->actionOpen_Video->setChecked(false);
    ui->actionOpen_Device_2->setChecked(false);
    ui->positionSlider->setSliderPosition(0);

    // do one step so we see something on the screen
    //step();
    //ui->CVWindow->setImage(&whatWeSee);
}
SecCamera::~SecCamera()
{
    LOGI("%s()", __func__);

    if (!_isInited) {
        LOGV("%s: Can't destroy! SecCamera not inited!", __func__);
        return;
    }

    LOGE_IF(this->stopPreview() < 0,
            "ERR(%s):Fail on stopPreview()\n", __func__);

    stopRecord();
    _release();

    _isInited = false;
}
Ejemplo n.º 13
0
void DSMCall::recordFile(const string& name) {
  if (rec_file) 
    stopRecord();

  DBG("start record to '%s'\n", name.c_str());
  rec_file = new AmAudioFile();
  if(rec_file->open(name,AmAudioFile::Write)) {
    ERROR("audio file '%s' could not be opened for recording.\n", 
	  name.c_str());
    delete rec_file;
    rec_file = NULL;
    throw DSMException("file", "path", name);
    return;
  }
  setInput(rec_file); 
  CLR_ERRNO;
}
Ejemplo n.º 14
0
void V4LCamera::stop()
{
	stopRecord();

	if (fd_ != -1) {
		close(fd_);
		fd_ = -1;
	}

	if (buf_ != NULL) {
		if (use_mmap_)
			munmap(buf_, mmap_size_);
		else
			delete[] buf_;

		buf_ = NULL;
	}
}
Ejemplo n.º 15
0
void MainWindow::finished()
{
    if (!isVisible())
        return;

#ifndef Q_OS_ANDROID
    m_ffmpeg->setReadingEnabled(false);
#endif

    stopRecord();
    resetRecordPage();

    boxautostart->setEnabled(true);

    lineport->setEnabled(true);
    linemaxconnections->setEnabled(true);
    lineid->setEnabled(true);
    linepassword->setEnabled(true);

    currentIndexChanged(comboboxaudioinput->currentIndex());

    boxlisteninput->setEnabled(true);
    comboboxaudioinput->setEnabled(true);
    buttonstart->setText("Start Server");

    texteditsettings->clear();

    listconnections->clear();

    if (m_audio_lib)
        m_audio_lib->deleteLater();

    m_buffer.clear();

    setWindowTitle(TITLE);

#ifdef Q_OS_WIN
        if (m_loopback)
            m_loopback->deleteLater();
#endif
}
Ejemplo n.º 16
0
static void __exit cleanup_nm256 (void)
{
    if (loaded) {
	struct nm256_info *card;
	struct nm256_info *next_card;

	for (card = nmcard_list; card != NULL; card = next_card) {
	    stopPlay (card);
	    stopRecord (card);
	    if (card->has_irq)
		free_irq (card->irq, card);
	    nm256_release_ports (card);
	    sound_unload_mixerdev (card->mixer_oss_dev);
	    sound_unload_audiodev (card->dev[0]);
	    sound_unload_audiodev (card->dev[1]);
	    next_card = card->next_card;
	    kfree (card);
	}
	nmcard_list = NULL;
    }
    pm_unregister_all (&handle_pm_event);
}
Ejemplo n.º 17
0
static void __devinit
nm256_remove(struct pci_dev *pcidev) {
    struct nm256_info *xcard = pci_get_drvdata(pcidev);
    struct nm256_info *card,*next_card = NULL;

    for (card = nmcard_list; card != NULL; card = next_card) {
	next_card = card->next_card;
	if (card == xcard) {
	    stopPlay (card);
	    stopRecord (card);
	    if (card->has_irq)
		free_irq (card->irq, card);
	    nm256_release_ports (card);
	    sound_unload_mixerdev (card->mixer_oss_dev);
	    sound_unload_audiodev (card->dev[0]);
	    sound_unload_audiodev (card->dev[1]);
	    kfree (card);
	    break;
	}
    }
    if (nmcard_list == card)
    	nmcard_list = next_card;
}
Ejemplo n.º 18
0
static void
nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy)
{
    struct nm256_info *card = (struct nm256_info *)dev_id;
    u32 status;
    static int badintrcount = 0;

    if ((card == NULL) || (card->magsig != NM_MAGIC_SIG)) {
	printk (KERN_ERR "NM256: Bad card pointer\n");
	return;
    }

    status = nm256_readPort32 (card, 2, NM_INT_REG);

    /* Not ours. */
    if (status == 0) {
	if (badintrcount++ > 1000) {
	    printk (KERN_ERR "NM256: Releasing interrupt, over 1000 invalid interrupts\n");
	    /*
	     * I'm not sure if the best thing is to stop the card from
	     * playing or just release the interrupt (after all, we're in
	     * a bad situation, so doing fancy stuff may not be such a good
	     * idea).
	     *
	     * I worry about the card engine continuing to play noise
	     * over and over, however--that could become a very
	     * obnoxious problem.  And we know that when this usually
	     * happens things are fairly safe, it just means the user's
	     * inserted a PCMCIA card and someone's spamming us with 
	     * IRQ 9s.
	     */

	    if (card->playing)
		stopPlay (card);
	    if (card->recording)
		stopRecord (card);
	    badintrcount = 0;
	}
	return;
    }

    badintrcount = 0;

    /* Rather boring; check for individual interrupts and process them. */

    if (status & NM2_PLAYBACK_INT) {
	status &= ~NM2_PLAYBACK_INT;
	NM2_ACK_INT (card, NM2_PLAYBACK_INT);

	if (card->playing)
	    nm256_get_new_block (card);
    }

    if (status & NM2_RECORD_INT) {
	status &= ~NM2_RECORD_INT;
	NM2_ACK_INT (card, NM2_RECORD_INT);

	if (card->recording)
	    nm256_read_block (card);
    }

    if (status & NM2_MISC_INT_1) {
	u8 cbyte;

	status &= ~NM2_MISC_INT_1;
	printk (KERN_ERR "NM256: Got misc interrupt #1\n");
	NM2_ACK_INT (card, NM2_MISC_INT_1);
	cbyte = nm256_readPort8 (card, 2, 0x400);
	nm256_writePort8 (card, 2, 0x400, cbyte | 2);
    }

    if (status & NM2_MISC_INT_2) {
	u8 cbyte;

	status &= ~NM2_MISC_INT_2;
	printk (KERN_ERR "NM256: Got misc interrupt #2\n");
	NM2_ACK_INT (card, NM2_MISC_INT_2);
	cbyte = nm256_readPort8 (card, 2, 0x400);
	nm256_writePort8 (card, 2, 0x400, cbyte & ~2);
    }

    /* Unknown interrupt. */
    if (status) {
	printk (KERN_ERR "NM256: Fire in the hole! Unknown status 0x%x\n",
		status);
	/* Pray. */
	NM2_ACK_INT (card, status);
    }
}
Ejemplo n.º 19
0
void MainWindow::startPauseRecord()
{
    if (!m_audio_recorder && !m_audio_recorder_mp3)
    {
        if (QFileInfo(linerecordpath->text()).exists())
        {
            int result = msgBoxQuestion("File already exists",
                                        QString("File %0 already exists. Replace it?")
                                        .arg(QFileInfo(linerecordpath->text()).fileName()), this);

            if (result != QMessageBox::Yes)
                return;
        }
    }

    if (m_paused)
    {
        linerecordpath->setEnabled(false);
        buttonsearch->setEnabled(false);
        buttonrecordstop->setEnabled(true);

        m_format = m_audio_lib->audioFormat();
        //Change to compatible settings
        m_format.setSampleSize(16);
        m_format.setSampleType(QAudioFormat::SignedInt);

        if (!linerecordpath->text().endsWith(".mp3"))
        {
            if (!m_audio_recorder)
            {
                m_audio_recorder = new AudioRecorder(linerecordpath->text(), m_format, m_audio_lib);

                if (!m_audio_recorder->open())
                {
                    stopRecord();

                    msgBoxCritical("Error", "Error openning wave file for record!", this);

                    return;
                }
            }
        }
        else
        {
            if (!m_audio_recorder_mp3)
            {
                m_audio_recorder_mp3 = new MP3Recorder(this);

                if (!m_audio_recorder_mp3->start(linerecordpath->text(), m_format, 128))
                {
                    stopRecord();

                    msgBoxCritical("Error", "Error openning mp3 file for record!", this);

                    return;
                }
            }
        }

        connect(m_audio_lib, &AudioStreamingLibCore::veryInputData, this, &MainWindow::writeToFile);

        buttonrecord->setText("Pause");

        m_paused = false;
    }
    else
    {
        disconnect(m_audio_lib, &AudioStreamingLibCore::veryInputData, this, &MainWindow::writeToFile);

        buttonrecord->setText("Record");

        m_paused = true;
    }
}
Ejemplo n.º 20
0
// Shutdown
//----------------------------------------
ofxOpenNIRecorder::~ofxOpenNIRecorder() {
	XN_DELETE_ARR(frames);
	stopRecord(); // just to be sure.
}
Ejemplo n.º 21
0
Player::Player(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
        isStopRecord = true;

        sender = new QUdpSocket(this);

        ui->setupUi(this);
        camMode = 1;

        QImage img;
        img.load("./record.png");
        QPixmap pix = QPixmap::fromImage(img);
        ui->recordstatus->setPixmap(pix);
        ui->recordstatus->hide();

        //    QLabel *carAngle = new QLabel("车体角度");
        carSpeed_ = new Form_KM(this);

        //   QGridLayout *leftLayout = new  QGridLayout;
        //    leftLayout->addWidget(carSpeed_, 0, 0);
        //   leftLayout->addWidget(carAngle, 1, 0);

        servoAngle_ = new Form_KM(this);

        //  QLabel *servoAngle = new QLabel("驼机角度");;

        //     QGridLayout *rightLayout = new QGridLayout;
        //   rightLayout->addWidget(servoAngle_,0,0);
        //  rightLayout->addWidget(servoAngle,1,0);

        QGridLayout *newLayout = new QGridLayout;
        newLayout->addWidget(carSpeed_, 0, 0);
        newLayout->addWidget(servoAngle_, 0, 1);
        newLayout->setSpacing(340);

        newLayout->setContentsMargins(10, 10, 0, 0);

        //  newLayout->addLayout(leftLayout,0,0);
        //       newLayout->addLayout(rightLayout,0,3);

        ui->centralWidget->setLayout(newLayout);
        QPalette palette;
        palette.setBrush(QPalette::Background, QBrush(Qt::black));
        ui->centralWidget->setPalette(palette);
        ui->centralWidget->setAutoFillBackground(true);

        // QObject::connect(&thread_, SIGNAL (aSignal(int)), this, SLOT
        // (showSpeed(int)));
        // thread_.start();

        QObject::connect(&ctrlCommThread_, SIGNAL(showSpeedSignal(int)), this,
                         SLOT(showSpeed(int)));
        QObject::connect(&ctrlCommThread_, SIGNAL(showAngleSignal(int)), this,
                         SLOT(showAngleSignal(int)));
        QObject::connect(&ctrlCommThread_, SIGNAL(showTemperatureSignal(int)), this,
                         SLOT(showTemperature(int)));
        QObject::connect(&ctrlCommThread_, SIGNAL(showLeftPowerSignal(int)), this,
                         SLOT(showLeftPower(int)));
        QObject::connect(&ctrlCommThread_, SIGNAL(showRightPowerSignal(int)), this,
                         SLOT(showRightPower(int)));

        QObject::connect(&ctrlCommThread_, SIGNAL(sendLightMode(int)), this,
                         SLOT(changeCam(int)));

        ctrlCommThread_.start();

        QObject::connect(this, SIGNAL(stopRecordSignal()), &recordScreenThread_,
                         SLOT(stopRecord()));

        QSettings *configIniRead = new QSettings("xcar.ini", QSettings::IniFormat);

        QString frontCamIp = configIniRead->value("/front_camera/ip").toString();
        QString frontCamPort = configIniRead->value("/front_camera/port").toString();

        QString backCamIp = configIniRead->value("/back_camera/ip").toString();
        QString backCamPort = configIniRead->value("/back_camera/port").toString();

        delete configIniRead;

        camClient_Front.connectToHost(QHostAddress(frontCamIp.toStdString().c_str()),
                                      frontCamPort.toShort());
        camClient_Back.connectToHost(QHostAddress(backCamIp.toStdString().c_str()),
                                     backCamPort.toShort());

        camClient_Front.requestImage();
        camClient_Back.requestImage();

        camClient_Front.enableShow();
        camClient_Back.disableShow();
#if 0
        connect(&camClient_Front, SIGNAL(newImageReady(QImage)), this,
                SLOT(showNewImage(QImage)));
        connect(&camClient_Back, SIGNAL(newImageReady(QImage)), this,
                SLOT(showNewImage(QImage)));
#endif
        connect(&camClient_Front, SIGNAL(newImageReady_new(QByteArray)), this,
                SLOT(showNewImage_new(QByteArray)));
        connect(&camClient_Back, SIGNAL(newImageReady_new(QByteArray)), this,
                SLOT(showNewImage_new(QByteArray)));

        poller = new QTimer(this);
        recording = new QTimer(this);
        //  connect(poller, SIGNAL(timeout()), this, SLOT(recordScreen()));

        connect(poller, SIGNAL(timeout()), this, SLOT(change_Speed()));
        connect(recording, SIGNAL(timeout()), this, SLOT(change_recordStatus()));

        poller->start(100);
        recording->start(600);
}
Ejemplo n.º 22
0
void MainWindow::start()
{
    if (m_audio_lib)
    {
        stopRecord();

        buttonrecord->setEnabled(false);

        m_audio_lib->stop();
#ifdef Q_OS_WIN
        if (m_loopback)
            m_loopback->deleteLater();
#endif
        return;
    }

    QByteArray password = linepassword->text().toLatin1();

    if (comboboxaudioinput->count() == 0)
    {
        msgBoxCritical("Error", "No input device found", this);
        return;
    }

    bool ok = false;
    int port = lineport->text().toInt(&ok);

    if (!ok || port < 1 || port > 65535)
    {
        msgBoxCritical("Error", "Port must have a value between 1 and 65535,\n"
                                "including these values", this);

        return;
    }

    int max_connections = linemaxconnections->text().toInt(&ok);

    if (!ok || max_connections < 1)
    {
        msgBoxCritical("Error", "Enter a value equal or higher to 1 on maximum connections", this);
        return;
    }

    m_audio_lib = new AudioStreamingLibCore(this);

    StreamingInfo info;

    info.setWorkMode(StreamingInfo::StreamingWorkMode::BroadcastServer);
    info.setEncryptionEnabled(!password.isEmpty());
    info.setGetAudioEnabled(true);
    info.setListenAudioInputEnabled(boxlisteninput->isChecked());
    info.setNegotiationString(QByteArray("BroadcastTCPDemo"));
    info.setID(lineid->text().trimmed());

    QAudioDeviceInfo inputdevinfo = comboboxaudioinput->currentData().value<QAudioDeviceInfo>();

    if (inputdevinfo.isNull())
    {
#ifdef Q_OS_WIN
        if (comboboxaudioinput->currentData(Qt::UserRole + 1).value<int>() == AudioInputInfo::Loopback)
        {
            m_loopback = new QWinLoopback(this);

            connect(m_loopback, &QObject::destroyed, this, [=]
            {
                if (isVisible())
                    m_buffer.clear();
            });

            bool started = m_loopback->start();

            if (!started)
                return;

            info.setInputDeviceType(StreamingInfo::AudioDeviceType::CustomAudioDevice);
            info.setCallBackEnabled(true);

            QAudioFormat format = m_loopback->format();

            connect(m_loopback, &QWinLoopback::readyRead, this, &MainWindow::loopbackdata);
            connect(m_audio_lib, &AudioStreamingLibCore::inputData, this, &MainWindow::process);

            info.setInputAudioFormat(format);
        }
        else //FFMPEG
#endif
        {
            QAudioFormat format;

            format.setSampleSize(32);
            format.setSampleRate(48000);
            format.setChannelCount(2);
            format.setSampleType(QAudioFormat::Float);
            format.setByteOrder(QAudioFormat::LittleEndian);

            info.setInputDeviceType(StreamingInfo::AudioDeviceType::CustomAudioDevice);
            info.setCallBackEnabled(true);

            connect(m_audio_lib, &AudioStreamingLibCore::inputData, this, &MainWindow::process);

            info.setInputAudioFormat(format);
        }
    }
    else
    {
        info.setInputDeviceInfo(inputdevinfo);

        QAudioFormat format;

        format.setSampleSize(32);
        format.setSampleRate(linesamplerate->text().toInt());
        format.setChannelCount(linechannels->text().toInt());
        format.setSampleType(QAudioFormat::Float);
        format.setByteOrder(QAudioFormat::LittleEndian);

        info.setInputAudioFormat(format);
    }

    lineport->setEnabled(false);
    linemaxconnections->setEnabled(false);
    lineid->setEnabled(false);
    linepassword->setEnabled(false);
    linesamplerate->setEnabled(false);
    linechannels->setEnabled(false);

    comboboxaudioinput->setEnabled(false);
    boxlisteninput->setEnabled(false);
    buttonstart->setText("Stop Server");

    buttonrecord->setEnabled(true);

    connect(m_audio_lib, &AudioStreamingLibCore::adjustSettings, this, &MainWindow::adjustSettings);
    connect(m_audio_lib, &AudioStreamingLibCore::inputLevel, level, &LevelWidget::setlevel);
    connect(m_audio_lib, &AudioStreamingLibCore::error, this, &MainWindow::error);
    connect(m_audio_lib, &AudioStreamingLibCore::finished, this, &MainWindow::finished);
    connect(m_audio_lib, &AudioStreamingLibCore::connected, this, &MainWindow::updateConnections);
    connect(m_audio_lib, &AudioStreamingLibCore::disconnected, this, &MainWindow::updateConnections);

    m_audio_lib->start(info);

    if (info.isListenAudioInputEnabled())
        m_audio_lib->setVolume(slidervolume->value());

    m_audio_lib->listen(quint16(port), true, password, max_connections);

    boxautostart->setEnabled(false);

    if (boxautostart->isChecked())
        startPauseRecord(); //Auto start recording when server starts

#ifndef Q_OS_ANDROID
    m_ffmpeg->setReadingEnabled(true);
#endif

    QString title = QString("%0 connection(s) - %1").arg(0).arg(TITLE);

    setWindowTitle(title);
}