bool QSpotifyAudioThreadWorker::event(QEvent *e)
{
    // Ignore timer events to have less log trashing
    if(e->type() != QEvent::Timer)
        qDebug() << "QSpotifyAudioThreadWorker::event" << e->type();
    if (e->type() == StreamingStartedEventType) {
        QMutexLocker lock(&g_mutex);
        QSpotifyStreamingStartedEvent *ev = static_cast<QSpotifyStreamingStartedEvent *>(e);
        startStreaming(ev->channels(), ev->sampleRate());
        e->accept();
        return true;
    } else if (e->type() == ResumeEventType) {
        QMutexLocker lock(&g_mutex);
        if (m_audioOutput) {
            m_audioOutput->resume();
            m_audioTimerID = startTimer(AUDIOSTREAM_UPDATE_INTERVAL);
        }
        e->accept();
        return true;
    } else if (e->type() == SuspendEventType) {
        QMutexLocker lock(&g_mutex);
        if (m_audioOutput) {
            killTimer(m_audioTimerID);
            m_audioOutput->suspend();
        }
        e->accept();
        return true;
    } else if (e->type() == AudioStopEventType) {
        QMutexLocker lock(&g_mutex);
        killTimer(m_audioTimerID);
        g_buffer.close();
        if (m_audioOutput) {
            m_audioOutput->stop();
            m_audioOutput->deleteLater();
            m_audioOutput = nullptr;
            m_iodevice = nullptr;
        }
        e->accept();
        return true;
    } else if (e->type() == ResetBufferEventType) {
        QMutexLocker lock(&g_mutex);
        if (m_audioOutput) {
            killTimer(m_audioTimerID);
            m_audioOutput->reset();
            g_buffer.reset();
            startAudioOutput();
        }
        e->accept();
        return true;
    } else if (e->type() == QEvent::Timer) {
        QTimerEvent *te = static_cast<QTimerEvent *>(e);
        if (te->timerId() == m_audioTimerID) {
            updateAudioBuffer();
            e->accept();
            return true;
        }
    }
    return QObject::event(e);
}
void MainWindow::shareDesktop(bool set)
{
    if( set )
    {
        startStreaming();
    }
    else
    {
        stopStreaming();
    }
}
Beispiel #3
0
	void
	V4LFrameSource::start() {
		{
			RecursiveMutexLock l(m_threadMutex);
			if (m_thread) {
				return;
			}

			{
				RecursiveMutexLock lock(m_runningMutex);

				startStreaming();
				
				m_isRunning = true;
			}

			m_thread = new std::thread(&V4LFrameSource::run, this);
		}
	}
Beispiel #4
0
int USBGrabber::open(const char* aDevPath, size_t *aWidth, size_t *aHeight, uint32_t *aFormat) {
  if (mFd != 0) {
    error("Device already opened");
    return 0;
  }

  // Open capture device
  mFd = v4l2_open(aDevPath, O_RDWR | O_NONBLOCK, 0);
  if (mFd < 0)
  {
    error("Cannot open capturer device\n");
    return 0;
  }

  if (!validateCaptureDevice()) return 0;
  if (!initCaptureFormat()) return 0;
  if (!setCaptureFormat(aWidth, aHeight, aFormat)) return 0;
  if (!getCaptureInfo()) return 0;
  if (!initBuffers()) return 0;
  if (!startStreaming()) return 0;

  return 1;
}
Beispiel #5
0
int
main(int argc, char **argv)
{
  int nStatus = RD_SUCCESS;

  // http streaming server
  char DEFAULT_HTTP_STREAMING_DEVICE[] = "0.0.0.0";	// 0.0.0.0 is any device

  char *rtmpStreamingDevice = DEFAULT_HTTP_STREAMING_DEVICE;	// streaming device, default 0.0.0.0
  int nRtmpStreamingPort = 1935;	// port

  RTMP_LogPrintf("RTMP Server %s\n", RTMPDUMP_VERSION);
  RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");

  RTMP_debuglevel = RTMP_LOGINFO;

  if (argc > 1 && !strcmp(argv[1], "-z"))
    RTMP_debuglevel = RTMP_LOGALL;

  // init request
  memset(&defaultRTMPRequest, 0, sizeof(RTMP_REQUEST));

  defaultRTMPRequest.rtmpport = -1;
  defaultRTMPRequest.protocol = RTMP_PROTOCOL_UNDEFINED;
  defaultRTMPRequest.bLiveStream = FALSE;	// is it a live stream? then we can't seek/resume

  defaultRTMPRequest.timeout = 300;	// timeout connection afte 300 seconds
  defaultRTMPRequest.bufferTime = 20 * 1000;


  signal(SIGINT, sigIntHandler);
#ifndef WIN32
  signal(SIGPIPE, SIG_IGN);
#endif

#ifdef _DEBUG
  netstackdump = fopen("netstackdump", "wb");
  netstackdump_read = fopen("netstackdump_read", "wb");
#endif

  InitSockets();

  // start text UI
  ThreadCreate(controlServerThread, 0);

  // start http streaming
  if ((rtmpServer =
       startStreaming(rtmpStreamingDevice, nRtmpStreamingPort)) == 0)
    {
      RTMP_Log(RTMP_LOGERROR, "Failed to start RTMP server, exiting!");
      return RD_FAILED;
    }
  RTMP_LogPrintf("Streaming on rtmp://%s:%d\n", rtmpStreamingDevice,
	    nRtmpStreamingPort);

  while (rtmpServer->state != STREAMING_STOPPED)
    {
      sleep(1);
    }
  RTMP_Log(RTMP_LOGDEBUG, "Done, exiting...");

  CleanupSockets();

#ifdef _DEBUG
  if (netstackdump != 0)
    fclose(netstackdump);
  if (netstackdump_read != 0)
    fclose(netstackdump_read);
#endif
  return nStatus;
}
Beispiel #6
0
int
main(int argc, char **argv)
{
  int nStatus = RD_SUCCESS;

  // http streaming server
  char DEFAULT_HTTP_STREAMING_DEVICE[] = "0.0.0.0";	// 0.0.0.0 is any device

  char *httpStreamingDevice = DEFAULT_HTTP_STREAMING_DEVICE;	// streaming device, default 0.0.0.0
  int nHttpStreamingPort = 80;	// port
  int opt;
  struct option longopts[] = {
    {"help", 0, NULL, 'h'},
    {"host", 1, NULL, 'n'},
    {"port", 1, NULL, 'c'},
    {"socks", 1, NULL, 'S'},
    {"protocol", 1, NULL, 'l'},
    {"playpath", 1, NULL, 'y'},
    {"rtmp", 1, NULL, 'r'},
    {"swfUrl", 1, NULL, 's'},
    {"tcUrl", 1, NULL, 't'},
    {"pageUrl", 1, NULL, 'p'},
    {"app", 1, NULL, 'a'},
#ifdef CRYPTO
    {"swfhash", 1, NULL, 'w'},
    {"swfsize", 1, NULL, 'x'},
    {"swfVfy", 1, NULL, 'W'},
    {"swfAge", 1, NULL, 'X'},
#endif
    {"auth", 1, NULL, 'u'},
    {"conn", 1, NULL, 'C'},
    {"flashVer", 1, NULL, 'f'},
    {"live", 0, NULL, 'v'},
    //{"flv",     1, NULL, 'o'},
    //{"resume",  0, NULL, 'e'},
    {"timeout", 1, NULL, 'm'},
    {"buffer", 1, NULL, 'b'},
    //{"skip",    1, NULL, 'k'},
    {"device", 1, NULL, 'D'},
    {"sport", 1, NULL, 'g'},
    {"subscribe", 1, NULL, 'd'},
    {"start", 1, NULL, 'A'},
    {"stop", 1, NULL, 'B'},
    {"token", 1, NULL, 'T'},
    {"debug", 0, NULL, 'z'},
    {"quiet", 0, NULL, 'q'},
    {"verbose", 0, NULL, 'V'},
    {0, 0, 0, 0}
  };
  RTMP_LogPrintf("HTTP-RTMP Stream Gateway %s\n", RTMPDUMP_VERSION);
  RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");

  // init request
  memset(&defaultRTMPRequest, 0, sizeof(RTMP_REQUEST));

  defaultRTMPRequest.rtmpport = -1;
  defaultRTMPRequest.protocol = RTMP_PROTOCOL_UNDEFINED;
  defaultRTMPRequest.bLiveStream = FALSE;	// is it a live stream? then we can't seek/resume

  defaultRTMPRequest.timeout = 120;	// timeout connection after 120 seconds
  defaultRTMPRequest.bufferTime = 20 * 1000;

  defaultRTMPRequest.swfAge = 30;



  signal(SIGINT, sigIntHandler);
#ifndef WIN32
  signal(SIGPIPE, SIG_IGN);
#endif

  InitSockets();

  while ((opt =
	  getopt_long(argc, argv,
		      "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:", longopts,
		      NULL)) != -1)
    {
      switch (opt)
	{
	case 'h':
	  RTMP_LogPrintf
	    ("\nThis program serves media content streamed from RTMP onto HTTP.\n\n");
	  RTMP_LogPrintf("--help|-h               Prints this help screen.\n");
	  RTMP_LogPrintf
	    ("--rtmp|-r url           URL (e.g. rtmp://host[:port]/path)\n");
	  RTMP_LogPrintf
	    ("--host|-n hostname      Overrides the hostname in the rtmp url\n");
	  RTMP_LogPrintf
	    ("--port|-c port          Overrides the port in the rtmp url\n");
	  RTMP_LogPrintf
	    ("--socks|-S host:port    Use the specified SOCKS proxy\n");
	  RTMP_LogPrintf
	    ("--protocol|-l           Overrides the protocol in the rtmp url (0 - RTMP, 2 - RTMPE)\n");
	  RTMP_LogPrintf
	    ("--playpath|-y           Overrides the playpath parsed from rtmp url\n");
	  RTMP_LogPrintf("--swfUrl|-s url         URL to player swf file\n");
	  RTMP_LogPrintf
	    ("--tcUrl|-t url          URL to played stream (default: \"rtmp://host[:port]/app\")\n");
	  RTMP_LogPrintf("--pageUrl|-p url        Web URL of played programme\n");
	  RTMP_LogPrintf("--app|-a app            Name of target app in server\n");
#ifdef CRYPTO
	  RTMP_LogPrintf
	    ("--swfhash|-w hexstring  SHA256 hash of the decompressed SWF file (32 bytes)\n");
	  RTMP_LogPrintf
	    ("--swfsize|-x num        Size of the decompressed SWF file, required for SWFVerification\n");
	  RTMP_LogPrintf
	    ("--swfVfy|-W url         URL to player swf file, compute hash/size automatically\n");
	  RTMP_LogPrintf
	    ("--swfAge|-X days        Number of days to use cached SWF hash before refreshing\n");
#endif
	  RTMP_LogPrintf
	    ("--auth|-u string        Authentication string to be appended to the connect string\n");
	  RTMP_LogPrintf
	    ("--conn|-C type:data     Arbitrary AMF data to be appended to the connect string\n");
	  RTMP_LogPrintf
	    ("                        B:boolean(0|1), S:string, N:number, O:object-flag(0|1),\n");
	  RTMP_LogPrintf
	    ("                        Z:(null), NB:name:boolean, NS:name:string, NN:name:number\n");
	  RTMP_LogPrintf
	    ("--flashVer|-f string    Flash version string (default: \"%s\")\n",
	     RTMP_DefaultFlashVer.av_val);
	  RTMP_LogPrintf
	    ("--live|-v               Get a live stream, no --resume (seeking) of live streams possible\n");
	  RTMP_LogPrintf
	    ("--subscribe|-d string   Stream name to subscribe to (otherwise defaults to playpath if live is specified)\n");
	  RTMP_LogPrintf
	    ("--timeout|-m num        Timeout connection num seconds (default: %lu)\n",
	     defaultRTMPRequest.timeout);
	  RTMP_LogPrintf
	    ("--start|-A num          Start at num seconds into stream (not valid when using --live)\n");
	  RTMP_LogPrintf
	    ("--stop|-B num           Stop at num seconds into stream\n");
	  RTMP_LogPrintf
	    ("--token|-T key          Key for SecureToken response\n");
	  RTMP_LogPrintf
	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
	     defaultRTMPRequest.bufferTime);

	  RTMP_LogPrintf
	    ("--device|-D             Streaming device ip address (default: %s)\n",
	     DEFAULT_HTTP_STREAMING_DEVICE);
	  RTMP_LogPrintf
	    ("--sport|-g              Streaming port (default: %d)\n\n",
	     nHttpStreamingPort);
	  RTMP_LogPrintf
	    ("--quiet|-q              Suppresses all command output.\n");
	  RTMP_LogPrintf("--verbose|-V            Verbose command output.\n");
	  RTMP_LogPrintf("--debug|-z              Debug level command output.\n");
	  RTMP_LogPrintf
	    ("If you don't pass parameters for swfUrl, pageUrl, or auth these properties will not be included in the connect ");
	  RTMP_LogPrintf("packet.\n\n");
	  return RD_SUCCESS;
	  break;
	  // streaming server specific options
	case 'D':
	  if (inet_addr(optarg) == INADDR_NONE)
	    {
	      RTMP_Log(RTMP_LOGERROR,
		  "Invalid binding address (requested address %s), ignoring",
		  optarg);
	    }
	  else
	    {
	      httpStreamingDevice = optarg;
	    }
	  break;
	case 'g':
	  {
	    int port = atoi(optarg);
	    if (port < 0 || port > 65535)
	      {
		RTMP_Log(RTMP_LOGERROR,
		    "Streaming port out of range (requested port %d), ignoring\n",
		    port);
	      }
	    else
	      {
		nHttpStreamingPort = port;
	      }
	    break;
	  }
	default:
	  //RTMP_LogPrintf("unknown option: %c\n", opt);
	  if (!ParseOption(opt, optarg, &defaultRTMPRequest))
	    return RD_FAILED;
	  break;
	}
    }

#ifdef _DEBUG
  netstackdump = fopen("netstackdump", "wb");
  netstackdump_read = fopen("netstackdump_read", "wb");
#endif

  // start text UI
  ThreadCreate(controlServerThread, 0);

  // start http streaming
  if ((httpServer =
       startStreaming(httpStreamingDevice, nHttpStreamingPort)) == 0)
    {
      RTMP_Log(RTMP_LOGERROR, "Failed to start HTTP server, exiting!");
      return RD_FAILED;
    }
  RTMP_LogPrintf("Streaming on http://%s:%d\n", httpStreamingDevice,
	    nHttpStreamingPort);

  while (httpServer->state != STREAMING_STOPPED)
    {
      sleep(1);
    }
  RTMP_Log(RTMP_LOGDEBUG, "Done, exiting...");

  CleanupSockets();

#ifdef _DEBUG
  if (netstackdump != 0)
    fclose(netstackdump);
  if (netstackdump_read != 0)
    fclose(netstackdump_read);
#endif
  return nStatus;
}
Beispiel #7
0
int
start_sample_rtmp_server(int argc, char **argv)
{
	int nStatus = RD_SUCCESS;
	int i;

	// http streaming server
	char DEFAULT_HTTP_STREAMING_DEVICE[] = "0.0.0.0";	// 0.0.0.0 is any device

	char *rtmpStreamingDevice = DEFAULT_HTTP_STREAMING_DEVICE;	// streaming device, default 0.0.0.0
	int nRtmpStreamingPort = 1935;	// port
	char *cert = NULL, *key = NULL;

	RTMP_LogPrintf("RTMP Server %s\n", "AVRemoteControl Build 1.0");
	RTMP_LogPrintf("(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL\n\n");

	RTMP_debuglevel = RTMP_LOGINFO;

	for (i = 1; i < argc; i++)
	{
		if (!strcmp(argv[i], "-z"))
			RTMP_debuglevel = RTMP_LOGALL;
		else if (!strcmp(argv[i], "-c") && i + 1 < argc)
			cert = argv[++i];
		else if (!strcmp(argv[i], "-k") && i + 1 < argc)
			key = argv[++i];
	}

	if (cert && key)
		sslCtx = RTMP_TLS_AllocServerContext(cert, key);

	// init request
	memset(&defaultRTMPRequest, 0, sizeof(RTMP_REQUEST));

	defaultRTMPRequest.rtmpport = -1;
	defaultRTMPRequest.protocol = RTMP_PROTOCOL_UNDEFINED;
	defaultRTMPRequest.bLiveStream = true;	// is it a live stream? then we can't seek/resume

	defaultRTMPRequest.timeout = 500;	// timeout connection after 300 seconds
	defaultRTMPRequest.bufferTime = 20 * 1000;


	signal(SIGINT, sigIntHandler);
#ifndef WIN32
	signal(SIGPIPE, SIG_IGN);
#endif

#ifdef _DEBUG
	netstackdump = fopen("netstackdump", "wb");
	netstackdump_read = fopen("netstackdump_read", "wb");
#endif

	InitSockets();

	// start text UI
	//ThreadCreate(controlServerThread, 0);
	std::thread theThread(controlServerThread);

	// start http streaming
	if ((rtmpServer =
		startStreaming(rtmpStreamingDevice, nRtmpStreamingPort)) == 0)
	{
		RTMP_Log(RTMP_LOGERROR, "Failed to start RTMP server, exiting!");
		return RD_FAILED;
	}
	RTMP_LogPrintf("Streaming on rtmp://%s:%d\n", rtmpStreamingDevice,
		nRtmpStreamingPort);

	while (rtmpServer->state != STREAMING_STOPPED)
	{
		sleep(1);
	}
	RTMP_Log(RTMP_LOGDEBUG, "Done, exiting...");

	if (sslCtx)
		RTMP_TLS_FreeServerContext(sslCtx);

	CleanupSockets();

#ifdef _DEBUG
	if (netstackdump != 0)
		fclose(netstackdump);
	if (netstackdump_read != 0)
		fclose(netstackdump_read);
#endif
	return nStatus;
}
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);
    }
}
Beispiel #9
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;
}
Beispiel #10
0
void Streamer::Update(float deltaTime, float alphaMul)
{
    CNode::Update(deltaTime, alphaMul);
    
    if (g_pInput->m_Touched) {
        if(!touched) {
            touched = true;
            x = g_pInput->m_X;
            y = g_pInput->m_Y;
        }
    }
    // Detect screen tap
    if (!g_pInput->m_Touched && g_pInput->m_PrevTouched && sceneSwitchComplete)
    {
        if(playButton->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) {
            g_pInput->Reset();
            playButton->m_X = IwGxGetScreenWidth() * 2.0;
            stopButton->m_X = IwGxGetScreenWidth() / 2.0;
			startStreaming();
			
        } else if(stopButton->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) {
            g_pInput->Reset();
            playButton->m_X = IwGxGetScreenWidth() / 2.0;
            stopButton->m_X = IwGxGetScreenWidth() * 2.0;
			pauseStreaming();
        }
        
		if(facebook->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) {
            g_pInput->Reset();
            s3eOSExecExecute("https://www.facebook.com/pages/UCCS-Radio/229529077104562", S3E_FALSE);
			
           
        } else if(twitter->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) {
            g_pInput->Reset();
            s3eOSExecExecute("https://twitter.com/uccsonlineradio", S3E_FALSE);
        }
        
		if ((labelLeft->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) || (g_pInput->m_X>g_pInput->prev_X + IwGxGetDeviceWidth() / 2)) {
			g_pInput->prev_X = g_pInput->m_X;
			sceneSwitchComplete = false;
            g_pInput->Reset();
            if(currentPage == 0) {
                CalendarScene* cal = (CalendarScene*)g_pSceneManager->Find("calscene");
                g_pSceneManager->SwitchTo(cal, 1);
                labelMain->SetText("Calendar");
                labelLeft->SetText("Events");
                labelRight->SetText("News");
                currentPage = 1;
                
            } else if(currentPage == 1) {
                EventsScene* events = (EventsScene*)g_pSceneManager->Find("eventsscene");
                g_pSceneManager->SwitchTo(events, 1);
                labelMain->SetText("Events");
                labelLeft->SetText("News");
                labelRight->SetText("Cal.");
                currentPage = 2;
                
            } else if(currentPage == 2) {
                NewsScene* news = (NewsScene*)g_pSceneManager->Find("newsscene");
                g_pSceneManager->SwitchTo(news, 1);
                labelMain->SetText("News");
                labelLeft->SetText("Cal.");
                labelRight->SetText("Events");
                currentPage = 0;
            }
            
		}
		else if ( 
			(labelRight->HitTest(g_pInput->m_X, g_pInput->m_Y) && 
			g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20
			&&
			g_pInput->m_Y < y + 20)
			|| 
			((g_pInput->m_X) < (g_pInput->prev_X - (int)IwGxGetDeviceWidth() / 2))
			) {
			g_pInput->prev_X = g_pInput->m_X;
			sceneSwitchComplete = false;
            g_pInput->Reset();
            if(currentPage == 0) {
                EventsScene* events = (EventsScene*)g_pSceneManager->Find("eventsscene");
                g_pSceneManager->SwitchTo(events, 0);
                labelMain->SetText("Events");
                labelLeft->SetText("News");
                labelRight->SetText("Cal.");
                currentPage = 2;
                
            } else if(currentPage == 1) {
                NewsScene* news = (NewsScene*)g_pSceneManager->Find("newsscene");
                g_pSceneManager->SwitchTo(news, 0);
                labelMain->SetText("News");
                labelLeft->SetText("Cal.");
                labelRight->SetText("Events");
                currentPage = 0;
                
            } else if(currentPage == 2) {
                CalendarScene* cal = (CalendarScene*)g_pSceneManager->Find("calscene");
                g_pSceneManager->SwitchTo(cal, 0);
                labelMain->SetText("Cal.");
                labelLeft->SetText("Events");
                labelRight->SetText("News");
                currentPage = 1;
                
            }
		}
		g_pInput->Reset();
        x = 0;
        y = 0;
        touched = false;
	}
    if(g_pInput->m_PrevTouched) {
        x = 0;
        y = 0;
        touched = false;
    }
}
Beispiel #11
0
/*!
	Starts playing the stream of file given in loadSound( const QString& filename ).

	The stream can be played in loop setting \a loop to true.

	The signals can be deactivated by setting \a signal to false.

	Returns true if it was possible to play the sample, otherwise false.

	\sa loadSound(), pauseSound() and stopSound().
*/
	bool Stream::playSound( bool loop, bool blockSignal )
	{		
		_loop = loop;
		blockSignals( blockSignal );
		
		qDebug() << "[Stream::playSound]"<< "------------  Stream::playSound( File: " << _filename << " Loop: " << CnotiLogManager::boolean(loop) << ")";
		
		int error = alGetError();

		if( isPlaying() )
		{
			qDebug() << "[Stream::playSound]"<< "----------------------------- ERROR sound stream is too playing... Restarting";
			
			_lastError = CS_IS_ALREADY_PLAYING;
            this->stopSound();
		}

		//
		// Reset some values
		//
		_currTime = 0;
		_pauseTime = 0;

		//
		// Gets a new source & set source volume
		//
		_uiSource = _soundMgr->checkOutSource();
		alSourcef( _uiSource, AL_GAIN, _intensity);
		
		if( !_streamingStarted )
		{
			//
			// Start Streaming
			//
			if( !startStreaming() )
			{
				alDeleteBuffers( NUMBUFFERSOGG, _uiBuffers );
				_streamingStarted = false;
				qDebug() << "[Stream::playSound]" << " ERROR streaming start failed";
				return false;
			}
		}
		else
		{
			qDebug() << "[Stream::playSound]" << "  ----------------------------- streaming already started";
		}
		//
		// PLAY 
		//
        qDebug() << "[Stream::playSound]" << "  ----------------------------- play source";
		_flagThreadSoundStopped = false;
        alSourcePlay( _uiSource );
		error = alGetError();
	    if( error != AL_NO_ERROR )
		{
            qDebug() << "[Stream::playSound]" << "  ----------------------------- ERROR openal failed";
		    alDeleteBuffers( NUMBUFFERSOGG, _uiBuffers );
		    stopSound();
			_lastError = CS_AL_ERROR;
		    return false;
        }
		emit soundPlaying( _name );
        qDebug() << "[Stream::playSound]" << "  ----------------------------- emit soundPlaying of sound: " << _name;
		//
		// THREAD
		//
		_timer->restart();
		start();
		qDebug() << "[Stream::playSound]" << "  ----------------------------- thread start";

		return true;
	}