コード例 #1
0
ファイル: WAVStream.cpp プロジェクト: nnen/waterfall
int WAVStream::readSubchunk()
{
	string subchunkId = readString(4);
	int size = readInt32();
	
	//cerr << "CHUNK " << subchunkId << ", SIZE = " << size << endl;
	
	if (subchunkId.compare(WAVFormat::FORMAT_SUBCHUNK_ID) == 0) {
		readFormatSubchunk(size);
	} else if (subchunkId.compare(WAVFormat::INF1_SUBCHUNK_ID) == 0) {
		readInf1Subchunk(size);
	} else if (subchunkId.compare(WAVFormat::DATA_SUBCHUNK_ID) == 0) {
		if (!dataRead_) {
			startStream();
			//if (backend_.isNotNull())
			//	backend_->startStream(streamInfo_);
			dataRead_ = true;
		}
		readDataSubchunk(size);
	} else {
		readUnknownSubchunk(size);
	}
	
	return size + 4;
}
コード例 #2
0
 void CheckAllStreams(JSON::Value & data){
   long long int currTime = Util::epoch();
   for (JSON::ObjIter jit = data.ObjBegin(); jit != data.ObjEnd(); jit++){
     if ( !Util::Procs::isActive(jit->first)){
       startStream(jit->first, jit->second);
     }
     if (currTime - lastBuffer[jit->first] > 5){
       if (jit->second.isMember("error") && jit->second["error"].asString() != ""){
         jit->second["online"] = jit->second["error"];
       }else{
         jit->second["online"] = 0;
       }
     }else{
       jit->second["online"] = 1;
     }
   }
   static JSON::Value strlist;
   bool changed = false;
   if (strlist["config"] != Storage["config"]){
     strlist["config"] = Storage["config"];
     changed = true;
   }
   if (strlist["streams"] != Storage["streams"]){
     strlist["streams"] = Storage["streams"];
     changed = true;
   }
   if (changed){
     WriteFile("/tmp/mist/streamlist", strlist.toString());
   }
 }
コード例 #3
0
bool BoardFXO::KhompPvtFXO::onNewCall(K3L_EVENT *e)
{
    DBG(FUNC,PVT_FMT(_target,"(FXO) c"));
   
    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        /* we always have audio */
        call()->_flags.set(Kflags::HAS_PRE_AUDIO);

        ret = KhompPvt::onNewCall(e);

        if(!ret)
            return false;

        startListen();
        startStream();

    }
    catch(ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(target(), "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}
コード例 #4
0
void InitCycle(std::shared_ptr<NamedPipe>& pipe)
{
   auto globals = globalStruct::GetGlobals();
   if (!globals)
      return;
   auto svc = globals->GetService();
   if (!svc)
      return;
   std::atomic_store(&globals->pipe, pipe);
   StartRecv(pipe);

   svc->post([pipe, globals]()
                          {
                             if (!pipe || !pipe->IsConnected())
                                return;
                             auto strm = globals->GetStreamer();
                             if (!strm)
                                return;
                             try
                             {
                                Writer MyWriter(pipe);
                                strm->startStream(MyWriter);
                                strm->stream(MyWriter);
                             }
                             catch (NamedPipeException& ex)
                             {
                                pipe->Cleanup();
                             }
                          });
}
コード例 #5
0
ファイル: xmppstream.cpp プロジェクト: avgx/Contacts
void XmppStream::onFeatureFinished(bool ARestart)
{
	if (!ARestart)
		processFeatures();
	else
		startStream();
}
コード例 #6
0
THREAD(StreamMusic, arg)
{
	printf("\nthread started\n");
	startStream();
	for (;;) {
		NutSleep(100);
	}
}
コード例 #7
0
THREAD(stream, arg)
{
	startStream();
	for(;;)
	{
		NutSleep(100);
	}	
}
コード例 #8
0
void PluginStream::didReceiveResponse(NetscapePlugInStreamLoader* loader, const ResourceResponse& response)
{
    ASSERT(loader == m_loader);
    ASSERT(m_streamState == StreamBeforeStarted);

    m_resourceResponse = response;

    startStream();
}
コード例 #9
0
///\brief Checks all streams, restoring if needed.
///\param data The stream configuration for the server.
void CheckAllStreams(JSON::Value & data) {
    long long int currTime = Util::epoch();
    for (JSON::ObjIter jit = data.ObjBegin(); jit != data.ObjEnd(); jit++) {
        if ( !Util::Procs::isActive(jit->first)) {
            startStream(jit->first, jit->second);
        }
        if (currTime - lastBuffer[jit->first] > 5) {
            if (jit->second.isMember("source") && jit->second["source"].asString().substr(0, 1) == "/" && jit->second.isMember("error")
                    && jit->second["error"].asString() == "Available") {
                jit->second["online"] = 2;
            } else {
                if (jit->second.isMember("error") && jit->second["error"].asString() == "Available") {
                    jit->second.removeMember("error");
                }
                jit->second["online"] = 0;
            }
        } else {
            // assume all is fine
            jit->second.removeMember("error");
            jit->second["online"] = 1;
            // check if source is valid
            if (jit->second.isMember("live") && !jit->second.isMember("meta") || !jit->second["meta"]) {
                jit->second["online"] = 0;
                jit->second["error"] = "No (valid) source connected";
            } else {
                // for live streams, keep track of activity
                if (jit->second["meta"].isMember("live")) {
                    if (jit->second["meta"]["lastms"] != jit->second["lastms"]) {
                        jit->second["lastms"] = jit->second["meta"]["lastms"];
                        jit->second["last_active"] = currTime;
                    }
                    // mark stream as offline if no activity for 5 seconds
                    if (jit->second.isMember("last_active") && jit->second["last_active"].asInt() < currTime - 5) {
                        jit->second["online"] = 0;
                        jit->second["error"] = "No (valid) source connected";
                    }
                }
            }
        }
    }
    static JSON::Value strlist;
    bool changed = false;
    if (strlist["config"] != Storage["config"]) {
        strlist["config"] = Storage["config"];
        changed = true;
    }
    if (strlist["streams"] != Storage["streams"]) {
        strlist["streams"] = Storage["streams"];
        changed = true;
    }
    if (changed) {
        WriteFile("/tmp/mist/streamlist", strlist.toString());
    }
}
コード例 #10
0
///\brief Parse a given stream configuration.
///\param in The requested configuration.
///\param out The new configuration after parsing.
void CheckStreams(JSON::Value & in, JSON::Value & out) {
    bool changed = false;

    //check for new streams and updates
    for (JSON::ObjIter jit = in.ObjBegin(); jit != in.ObjEnd(); jit++) {
        if (out.isMember(jit->first)) {
            if ( !streamsEqual(jit->second, out[jit->first])) {
                Log("STRM", std::string("Updated stream ") + jit->first);
                Util::Procs::Stop(jit->first);
                startStream(jit->first, jit->second);
            }
        } else {
            Log("STRM", std::string("New stream ") + jit->first);
            startStream(jit->first, jit->second);
        }
    }

    //check for deleted streams
    for (JSON::ObjIter jit = out.ObjBegin(); jit != out.ObjEnd(); jit++) {
        if ( !in.isMember(jit->first)) {
            Log("STRM", std::string("Deleted stream ") + jit->first);
            Util::Procs::Stop(jit->first);
        }
    }

    //update old-style configurations to new-style
    for (JSON::ObjIter jit = in.ObjBegin(); jit != in.ObjEnd(); jit++) {
        if (jit->second.isMember("channel")) {
            if ( !jit->second.isMember("source")) {
                jit->second["source"] = jit->second["channel"]["URL"];
            }
            jit->second.removeMember("channel");
        }
        if (jit->second.isMember("preset")) {
            jit->second.removeMember("preset");
        }
    }

    out = in;
}
コード例 #11
0
ファイル: LiveWidget.cpp プロジェクト: IainCole/Client
void LiveWidget::streamMenuActionTriggered(QAction* action)
{
    if (!action->text().contains(':') && !action->text().contains(','))
        return;

    stopStream(this->deviceName, this->deviceChannel);

    this->useKey = action->text().contains("(Key)");
    this->deviceName = action->text().split(',').at(0).split(':').at(1).trimmed();
    this->deviceChannel = action->text().split(',').at(1).split(':').at(1).trimmed().split(' ').at(0).trimmed();

    startStream(this->deviceName, this->deviceChannel);
}
コード例 #12
0
 void CheckStreams(JSON::Value & in, JSON::Value & out){
   bool changed = false;
   for (JSON::ObjIter jit = in.ObjBegin(); jit != in.ObjEnd(); jit++){
     if (out.isMember(jit->first)){
       if ( !streamsEqual(jit->second, out[jit->first])){
         Log("STRM", std::string("Updated stream ") + jit->first);
         Util::Procs::Stop(jit->first);
         startStream(jit->first, jit->second);
       }
     }else{
       Log("STRM", std::string("New stream ") + jit->first);
       startStream(jit->first, jit->second);
     }
   }
   for (JSON::ObjIter jit = out.ObjBegin(); jit != out.ObjEnd(); jit++){
     if ( !in.isMember(jit->first)){
       Log("STRM", std::string("Deleted stream ") + jit->first);
       Util::Procs::Stop(jit->first);
     }
   }
   out = in;
 }
コード例 #13
0
bool BoardFXO::KhompPvtFXO::setupConnection()
{
    if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
    {
        DBG(FUNC,PVT_FMT(_target, "Channel already disconnected"));
        return false;
    }

    callFXO()->_flags.clear(Kflags::CALL_WAIT_SEIZE);
    callFXO()->_flags.clear(Kflags::WAIT_SEND_DTMF);

    /* if received some disconnect from 'drop collect call'
       feature of some pbx, then leave the call rock and rolling */
    //Board::board(_target.device)->_timers.del(callFXO()->_idx_disconnect);

    bool fax_detected = callFXO()->_flags.check(Kflags::FAX_DETECTED) || (callFXO()->_var_fax_adjust == T_TRUE);

    bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN || fax_detected ?
        Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() && !fax_detected : (call()->_var_dtmf_state == T_TRUE));

    bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN || fax_detected ?
        Opt::_options._echo_canceller() && !fax_detected : (call()->_var_echo_state == T_TRUE));

    bool res_auto_gain_cntrol = (call()->_var_gain_state == T_UNKNOWN || fax_detected ?
        Opt::_options._auto_gain_control() && !fax_detected : (call()->_var_gain_state == T_TRUE));

    if (!call()->_flags.check(Kflags::REALLY_CONNECTED))
    {
        obtainRX(res_out_of_band_dtmf);

        /* esvazia buffers de leitura/escrita */
        cleanupBuffers();

        if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
            dtmfSuppression(res_out_of_band_dtmf);

        if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
            echoCancellation(res_echo_cancellator);

        if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
            autoGainControl(res_auto_gain_cntrol);

        startListen(false);

        startStream();

        DBG(FUNC, PVT_FMT(_target, "(FXO) Audio callbacks initialized successfully"));
    }

    return KhompPvt::setupConnection();
}
コード例 #14
0
ファイル: brainuart.cpp プロジェクト: Daniel-Hwang/eeg
BrainUART::BrainUART(int nChannels, int frameLength, float overlap){
    this->nChannels = nChannels;
    this->SamplesPerChannel = frameLength;

    /*Open serial connection*/
    stream.fd = bbuart_init((char *)"/dev/ttyO4", B115200);
    /*Initializes data*/
    bbbuffer_create(&b, nChannels, BUFFER_SIZE);
    bbframe_create(&eeg, nChannels, frameLength, overlap);
    stream.b = &b;
    stream.f = &eeg;

    startStream();
}
コード例 #15
0
ファイル: main.c プロジェクト: kees2125/C-enbeded-software
	THREAD(AlarmCheckerThread, arg)
	{
		for (;;) {
			NutSleep(5000);
			if(CheckAlarm1())
			{
				printf("Alarm should go off\n");
				startStream();
				NutSleep(61000);
				NutThreadExit();
				printf("Exit thread and started new one...\n");
				NutThreadCreate("Bl", AlarmCheckerThread, NULL, 512);
				break;
			}else{
				printf("Alarm should not go off\n");
			}
			if(CheckAlarm2())
			{
				printf("Alarm should go off\n");
				if(IMCconfig.alarm2.mode ==0)
				{
					NutThreadCreate("Bq", AlarmBeep, NULL, 512);
				}
				else{
					startStream();
				}
				
				NutSleep(61000);
				NutThreadExit();
				printf("Exit thread and started new one...\n");
				NutThreadCreate("Bl", AlarmCheckerThread, NULL, 512);
				break;
			}else{
				printf("Alarm should not go off\n");
			}
		}
	}
コード例 #16
0
OSStatus AkVCam::PluginInterfacePrivate::DeviceStartStream(CMIOHardwarePlugInRef self,
                                                           CMIODeviceID device,
                                                           CMIOStreamID stream)
{
    AkPluginPrivateIntefaceLogID(device);
    OSStatus status = kCMIOHardwareUnspecifiedError;

    if (!self)
        return status;

    auto _self = reinterpret_cast<PluginInterfacePrivate *>(self);
    auto object = reinterpret_cast<Device *>(_self->self->findObject(device));

    if (object)
        status = object->startStream(stream);

    return status;
}
コード例 #17
0
ファイル: AudioEntryPanel.cpp プロジェクト: Blzut3/SLADE
/* AudioEntryPanel::loadEntry
 * Loads an entry into the audio entry panel
 *******************************************************************/
bool AudioEntryPanel::loadEntry(ArchiveEntry* entry)
{
	// Are we reopening the same entry? For example having looked at
	// a text file or image or any other non-audio entry, then
	// going back to the original audio entry? Then no need to do
	// abort the current song to restart it.
	if (this->entry == entry)
		return true;

	// Stop anything currently playing
	stopStream();
	resetStream();
	opened = false;

	// Enable all playback controls initially
	slider_seek->Enable();
	btn_play->Enable();
	btn_pause->Enable();

	btn_stop->Enable();
	btn_prev->Enable();
	btn_next->Enable();

	// Reset seek slider
	slider_seek->SetValue(0);

	// Delete previous temp file
	if (wxFileExists(prevfile))
		wxRemoveFile(prevfile);

	// Open new data
	this->entry = entry;
	open();

	// Autoplay if option is on
	if (snd_autoplay)
	{
		startStream();
		timer_seek->Start(10);
	}

	Refresh();
	return true;
}
コード例 #18
0
bool BoardGSM::KhompPvtGSM::setupConnection()
{
    if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
    {
        DBG(FUNC,PVT_FMT(_target, "Channel already disconnected"));
        return false;
    }

    bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN ?
                                 Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() : (call()->_var_dtmf_state == T_TRUE));

    bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN ?
                                 Opt::_options._echo_canceller() : (call()->_var_echo_state == T_TRUE));


    bool res_auto_gain_cntrol = (call()->_var_gain_state == T_UNKNOWN ?
                                 Opt::_options._auto_gain_control() : (call()->_var_gain_state == T_TRUE));


    if (!call()->_flags.check(Kflags::REALLY_CONNECTED))
    {
        obtainRX(res_out_of_band_dtmf);

        /* esvazia buffers de leitura/escrita */
        cleanupBuffers();

        if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
            dtmfSuppression(res_out_of_band_dtmf);

        if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
            echoCancellation(res_echo_cancellator);

        if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
            autoGainControl(res_auto_gain_cntrol);

        startListen(false);

        startStream();

        DBG(FUNC, PVT_FMT(_target, "(GSM) Audio callbacks initialized successfully"));
    }

    return Board::KhompPvt::setupConnection();
}
コード例 #19
0
ファイル: LiveWidget.cpp プロジェクト: IainCole/Client
void LiveWidget::toggleWindowMode()
{
    stopStream(this->deviceName, this->deviceChannel);

    if (this->windowMode)
    {
        this->windowModeAction->blockSignals(true);
        this->windowModeAction->setChecked(false);
        this->windowModeAction->blockSignals(false);

        this->liveDialog->hide();
    }
    else
    {
        this->liveDialog->visible();
    }

    this->windowMode = !this->windowMode;
    setupRenderTarget(this->windowMode);
    startStream(this->deviceName, this->deviceChannel);
}
コード例 #20
0
ファイル: readFile.c プロジェクト: snayski/School-Work
// Creates the stream, registers the data and end events and starts the stream
void readFile( void * loop ){

    gEventLoop = loop;

    void * stream = createStream( "prod", "stahp", chunk, initRead, loop );

    if (stream == NULL){
        fprintf(stderr, "cannot create stream\n");
        exit(-1);
    }
    
    // remember the stream for use in terminate function
    gStream = stream;

    registerEvent( loop, "prod", addToSum );

    registerEvent( loop, "stahp", terminate );

    // start the stream
    startStream( stream, fileName );
    
}
コード例 #21
0
ファイル: main.cpp プロジェクト: maxammann/aqueduct
void MainForm::setPlaylist() {
    const QList<QTreeWidgetItem *> &selected = links->selectedItems();

    play_list->clear();

    long size = 0;

    for (int i = 0; i < selected.size(); ++i) {
        QTreeWidgetItem *item = selected.at(i);

        // no top level items
        if (item->parent() != nullptr) {
            QListWidgetItem *listItem = new QListWidgetItem();

            listItem->setTextAlignment(Qt::AlignCenter);
            listItem->setText(item->text(Columns::NAME));
            listItem->setData(Qt::ItemDataRole::UserRole, item->data(Columns::NAME, Qt::ItemDataRole::UserRole));
            size += item->data(Columns::SIZE, Qt::ItemDataRole::UserRole).toInt();
            play_list->addItem(listItem);
        }

        for (int c = 0; c < item->childCount(); ++c) {
            QTreeWidgetItem *child = item->child(c);

            QListWidgetItem *listItem = new QListWidgetItem();

            listItem->setTextAlignment(Qt::AlignCenter);
            listItem->setText(child->text(Columns::NAME));
            listItem->setData(Qt::ItemDataRole::UserRole, child->data(Columns::NAME, Qt::ItemDataRole::UserRole));
            size += child->data(Columns::SIZE, Qt::ItemDataRole::UserRole).toInt();
            play_list->addItem(listItem);
        }
    }

    findChild<QLabel *>("stream_size_label")->setText(bytesToMB(size));

    startStream();
}
コード例 #22
0
bool BoardGSM::KhompPvtGSM::onCallSuccess(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(GSM) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        ret = KhompPvt::onCallSuccess(e);

        if (call()->_pre_answer)
        {
            dtmfSuppression(Opt::_options._out_of_band_dtmfs());

            startListen();
            startStream();
            switch_channel_mark_pre_answered(getFSChannel());
        }
    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(GSM) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }
    catch (Board::KhompPvt::InvalidSwitchChannel & err)
    {
        LOG(ERROR, PVT_FMT(target(), "(GSM) r (%s)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(GSM) r"));

    return ret;
}
コード例 #23
0
ファイル: AudioEntryPanel.cpp プロジェクト: Blzut3/SLADE
/* AudioEntryPanel::onBtnPlay
 * Called when the play button is pressed
 *******************************************************************/
void AudioEntryPanel::onBtnPlay(wxCommandEvent& e)
{
	startStream();
	timer_seek->Start(10);
}
コード例 #24
0
bool BoardFXO::KhompPvtFXO::onDtmfSendFinish(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        ret = KhompPvt::onDtmfSendFinish(e);

        if (callFXO()->_flags.check(Kflags::EARLY_RINGBACK))
        {
            callFXO()->_flags.clear(Kflags::EARLY_RINGBACK);

            /* start grabbing */
            startListen();

            /* activate resources early... */
            bool fax_detected = callFXO()->_flags.check(Kflags::FAX_DETECTED);

            bool res_out_of_band_dtmf = Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() && !fax_detected;
            bool res_echo_cancellator = Opt::_options._echo_canceller() && !fax_detected;
            bool res_auto_gain_cntrol = Opt::_options._auto_gain_control() && !fax_detected;

            if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
                dtmfSuppression(res_out_of_band_dtmf);

            if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
                echoCancellation(res_echo_cancellator);

            if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
                autoGainControl(res_auto_gain_cntrol);

            /* start sending audio if wanted so */
            if (Opt::_options._fxo_send_pre_audio())
                startStream();

            //TODO: Verificar isso aqui
            if (call()->_pre_answer)
            {
                /* tell the user we are answered! */
                switch_channel_mark_answered(getFSChannel());
                //pvt->signal_state(AST_CONTROL_ANSWER);
            }
            else
            {
                /* are we ringing, now? lets try this way! */
                switch_channel_mark_ring_ready(getFSChannel());
                //pvt->signal_state(AST_CONTROL_RINGING);
            }
        }
    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }
    catch(Board::KhompPvt::InvalidSwitchChannel & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(FXO) r (no valid channel: %s)") % err._msg.c_str());
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}
コード例 #25
0
ファイル: xmppstream.cpp プロジェクト: avgx/Contacts
void XmppStream::onConnectionConnected()
{
	FKeepAliveTimer.start(KEEP_ALIVE_TIMEOUT);
	insertXmppStanzaHandler(this,XSHO_XMPP_STREAM);
	startStream();
}