Ejemplo n.º 1
0
    void Sensor::stop() {
        dprintf(3, "Entering Sensor::stop\n"); 
        stopStreaming();

        if (!daemon) return;

        dprintf(3, "Cancelling outstanding requests\n");

        // Cancel as many requests as possible
        pthread_mutex_lock(&requestMutex);
        _Frame *req;
        while (daemon->requestQueue.tryPullBack(&req)) {
            delete req;
            shotsPending_--;
        }
        pthread_mutex_unlock(&requestMutex);        

        dprintf(3, "Discarding remaining frames\n");

        // Wait for the outstanding ones to complete
        while (shotsPending_) {
            delete daemon->frameQueue.pull();
            decShotsPending();
        }

        dprintf(3, "Deleting daemon\n"); 

        // Delete the daemon
        if (!daemon) return;
        delete daemon;
        daemon = NULL;

        dprintf(3, "Sensor stopped\n"); 
    }
Ejemplo n.º 2
0
void MainWindow::handleStreamingError(const QString& errorMessage)
{
    std::cerr << errorMessage.toStdString() << std::endl;
    QMessageBox::warning(this, "Error", errorMessage, QMessageBox::Ok, QMessageBox::Ok);

    stopStreaming();

}
Ejemplo n.º 3
0
void
HttpInput::onHttpTimeout()
{
    // Streamer not contactable
    emit error( Radio_ConnectionRefused, m_genericAsOfYetUndiagnosedStreamerError +
        "\n\nError: The connection timed out." );
    stopStreaming();
}
Ejemplo n.º 4
0
void MainWindow::closeEvent( QCloseEvent* closeEvt )
{
    delete desktopSelectionWindow_;
    desktopSelectionWindow_ = 0;

    stopStreaming();

    QMainWindow::closeEvent( closeEvt );
}
Ejemplo n.º 5
0
void
sigIntHandler(int sig)
{
  RTMP_ctrlC = TRUE;
  RTMP_LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig);
  if (rtmpServer)
    stopStreaming(rtmpServer);
  signal(SIGINT, SIG_DFL);
}
Ejemplo n.º 6
0
void Webcam::close()
{
	stopStreaming();
	::close(dev);

	delete imageNotifier;
	imageNotifier = 0;
	opened = false;
	allocated = false;
}
Ejemplo n.º 7
0
CameraV2::~CameraV2(void)
	{
	/* Stop streaming, just in case: */
	stopStreaming();
	
	/* Release all resources: */
	delete colorStreamReader;
	delete depthStreamReader;
	delete commandDispatcher;
	}
Ejemplo n.º 8
0
void MainWindow::shareDesktop(bool set)
{
    if( set )
    {
        startStreaming();
    }
    else
    {
        stopStreaming();
    }
}
int YARPFoBDeviceDriver::close (void)
{
	FoBResources& d = RES(system_resources);
	
	if (d.streamingStarted)
		stopStreaming(NULL);

	if (d.connected)
		birdShutDown(d.groupID);
	
	d.connected = false;
	return YARP_OK;
}
Ejemplo n.º 10
0
ScreenProvider::~ScreenProvider()
{
    if(streaming_) {
        stopStreaming();
    }

    while(future_.isRunning() || future2_.isRunning()) {} // wait threads to exit

    if(orientationSensor_) {
        orientationSensor_->stop();
        delete orientationSensor_;
    }

    munmap(framebufferinfo_.fbmmap, framebufferinfo_.fix_scrinfo.smem_len);

    if(fbDevice_ != -1){
        ::close(fbDevice_);
    }
}
Ejemplo n.º 11
0
	void
	V4LFrameSource::stop() {
		{
			RecursiveMutexLock l(m_threadMutex);
			{
				RecursiveMutexLock lock(m_runningMutex);
				if (!m_isRunning) return;

				stopStreaming();
				
				m_isRunning = false;
			}

			if (m_thread) {
				m_thread->join();
				delete m_thread;
				m_thread = NULL;
			}
		}
	}
Ejemplo n.º 12
0
TFTYPE
controlServerThread(void *unused)
{
  char ich;
  while (1)
    {
      ich = getchar();
      switch (ich)
	{
	case 'q':
	  RTMP_LogPrintf("Exiting\n");
	  stopStreaming(rtmpServer);
	  exit(0);
	  break;
	default:
	  RTMP_LogPrintf("Unknown command \'%c\', ignoring\n", ich);
	}
    }
  TFRET();
}
Ejemplo n.º 13
0
void Spotify::run()
{
    int next_timeout = 0;

    sp = spotify_ll_init(Spotify_Wrapper::sessionCallbacks());
    if (!sp) {
        return;
    }

    bool running = true;
    while (running) {
        SpotifyEvent_t ev = EVENT_NO_EVENT;
        // Get next event (or timeout)
        if (next_timeout == 0) {
            eq.get(ev);
        } else {
            if (!eq.get(ev, next_timeout)) {
                // Timed out
                ev = EVENT_TIMEOUT;
            }
        }

        switch (ev) {
        case EVENT_SPOTIFY_MAIN_TICK:
        case EVENT_TIMEOUT:
            break;

        case EVENT_LOGIN_CREDENTIALS_CHANGED:
            if (pass.isEmpty()) {
                // Try using credential blob
                sp_session_login(sp,
                                 user.toLocal8Bit().constData(),
                                 NULL,
                                 false,
                                 blob.constData());
            }
            else {
                sp_session_login(sp,
                                 user.toLocal8Bit().constData(),
                                 pass.toLocal8Bit().constData(),
                                 false,
                                 NULL);
            }
            break;

        case EVENT_LOGGED_IN:
            emit loggedIn();
            break;

        case EVENT_PLAYLIST_CONTAINER_LOADED:
            compileNewListOfPlaylists();
            break;

        case EVENT_LOGGED_OUT:
            emit loggedOut();
            break;

        case EVENT_URI_CHANGED:
            changeCurrentlyPlayingSong();
            break;

        case EVENT_PLAYLIST_IDX_CHANGED:
            changeCurrentPlaylist();
            break;

        case EVENT_METADATA_UPDATED:
            tryLoadTrack();
            break;

        case EVENT_START_PLAYBACK:
            if (!audioThread.isRunning()) {
                fprintf(stderr, "Spotify: Starting audio worker\n");

                SpotifyAudioWorker * audioWorker = new SpotifyAudioWorker(this);
                audioWorker->moveToThread(&audioThread);
                connect(&audioThread, SIGNAL(started()),
                        audioWorker, SLOT(startStreaming()));
                connect(&audioThread, SIGNAL(finished()),
                        audioWorker, SLOT(stopStreaming()));
                connect(&audioThread, SIGNAL(finished()),
                        audioWorker, SLOT(deleteLater()));
                connect(audioWorker, SIGNAL(streamingFailed()),
                        this, SIGNAL(audioStreamingFailed()));
                audioThread.start();
            }
            break;

        case EVENT_STOP_PLAYBACK:
            if (audioThread.isRunning()) {
                audioThread.quit();
                audioThread.wait();
            }
            accessMutex.lock();
            audioBuffer.close();
            readPos = 0;
            writePos = 0;
            accessMutex.unlock();
            break;

        case EVENT_END_OF_TRACK:
            sp_session_player_unload(sp);
            sp_track_release(currentTrack);
            currentURI.clear();
            nextTrack = 0;
            currentTrack = 0;
            break;

        default:
            qDebug() << "Unknown event:" << (int)ev;
            break;
        }

        do {
            sp_session_process_events(sp, &next_timeout);
        } while (next_timeout == 0);
    }
}
Ejemplo n.º 14
0
int main(int argc, char* argv[])
{
    boost::program_options::options_description desc("");
	desc.add_options()
		("multicast-address", boost::program_options::value<std::string>(),     "")
		("interface",         boost::program_options::value<std::string>(),     "")
		("rtsp-port",         boost::program_options::value<boost::uint16_t>(), "")
		("avg-bit-rate",      boost::program_options::value<int>(),             "")
		("buffer-size",       boost::program_options::value<size_t>(),          "")
	    ("stats-interval",    boost::program_options::value<size_t>(),          "");
		
    
    boost::program_options::variables_map vm;
    boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
    boost::program_options::notify(vm);

    if (vm.count("interface"))
    {
        std::string interfaceAddress = vm["interface"].as<std::string>();
        NetAddressList addresses(interfaceAddress.c_str());
        if (addresses.numAddresses() == 0)
        {
            std::cout << "Failed to find network address for \"" << interfaceAddress << "\"" << std::endl;
            return -1;
        }
        ReceivingInterfaceAddr = *(unsigned*)(addresses.firstAddress()->data());
    }
    
    char sourceAddressStr[INET_ADDRSTRLEN];
    inet_ntop(AF_INET, &(ReceivingInterfaceAddr), sourceAddressStr, sizeof(sourceAddressStr));
    std::cout << "Using source address " << sourceAddressStr << std::endl;
    
    if (vm.count("rtsp-port"))
    {
        rtspPort = vm["rtsp-port"].as<boost::uint16_t>();
    }
    else
    {
        rtspPort = 8555;
    }
    std::cout << "Using RTSP port " << rtspPort << std::endl;
    
    // Create 'groupsocks' for RTP and RTCP:
    if(vm.count("multicast-address"))
    {
        inet_pton(AF_INET, vm["multicast-address"].as<std::string>().c_str(), &(destinationAddress.s_addr));
    }
    else
    {
        inet_pton(AF_INET, "224.0.67.67", &(destinationAddress.s_addr));
    }

	if (vm.count("avg-bit-rate"))
	{
		avgBitRate = vm["avg-bit-rate"].as<int>();
	}
	else
	{
		avgBitRate = DEFAULT_AVG_BIT_RATE;
	}
    std::string bitRateString = to_human_readable_byte_count(avgBitRate, true, false);
	std::cout << "Using an average encoding bit rate of " << bitRateString << "/s per face" << std::endl;

	if (vm.count("buffer-size"))
	{
		bufferSize = vm["buffer-size"].as<size_t>();
	}
	else
	{
		bufferSize = DEFAULT_BUFFER_SIZE;
	}
	std::string bufferSizeString = to_human_readable_byte_count(bufferSize, false, false);
	std::cout << "Using a buffer size of " << bufferSizeString << std::endl;

	size_t statsInterval;
	if (vm.count("stats-interval"))
	{
		statsInterval = vm["stats-interval"].as<size_t>();
	}
	else
	{
		statsInterval = DEFAULT_STATS_INTERVAL;
	}

    av_log_set_level(AV_LOG_WARNING);
    avcodec_register_all();
    setupRTSP();
    boost::thread networkThread = boost::thread(&networkLoop);

	

    Process unityProcess(CUBEMAPEXTRACTIONPLUGIN_ID, false);
	Process thisProcess(ALLOSERVER_ID, true);

    while (true)
    {
        std::cout << "Waiting for Unity ..." << std::endl;
        unityProcess.waitForBirth();
        std::cout << "Connected to Unity :)" << std::endl;
        startStreaming();
		stats.autoSummary(boost::chrono::seconds(statsInterval),
			              AlloReceiver::statValsMaker,
						  AlloReceiver::postProcessorMaker,
						  AlloReceiver::formatStringMaker);
        unityProcess.join();
        std::cout << "Lost connection to Unity :(" << std::endl;
        stopStreaming();
		stats.stopAutoSummary();
    }

    return 0;
}
Ejemplo n.º 15
0
Streamer::~Streamer()
{
    stopStreaming();
}