MediaStream::~MediaStream() { ELOG_DEBUG("%s message:Destructor called", toLog()); if (sending_) { close(); } ELOG_DEBUG("%s message: Destructor ended", toLog()); }
bool NicerConnection::setRemoteCandidates(const std::vector<CandidateInfo> &candidates, bool is_bundle) { std::vector<CandidateInfo> cands(candidates); auto remote_candidates_promise = std::make_shared<std::promise<void>>(); nr_ice_peer_ctx *peer = peer_; nr_ice_media_stream *stream = stream_; std::shared_ptr<NicerInterface> nicer = nicer_; async([cands, is_bundle, nicer, peer, stream, this, remote_candidates_promise] { ELOG_DEBUG("%s message: adding remote candidates (%ld)", toLog(), cands.size()); for (const CandidateInfo &cand : cands) { std::string sdp = cand.sdp; std::size_t pos = sdp.find(","); std::string candidate = sdp.substr(0, pos); ELOG_DEBUG("%s message: New remote ICE candidate (%s)", toLog(), candidate.c_str()); UINT4 r = nicer->IcePeerContextParseTrickleCandidate(peer, stream, const_cast<char *>(candidate.c_str())); if (r && r != R_ALREADY) { ELOG_WARN("%s message: Couldn't add remote ICE candidate (%s) (%d)", toLog(), candidate.c_str(), r); } } remote_candidates_promise->set_value(); }); std::future<void> remote_candidates_future = remote_candidates_promise->get_future(); std::future_status status = remote_candidates_future.wait_for(std::chrono::seconds(1)); if (status == std::future_status::timeout) { ELOG_WARN("%s message: Could not set remote candidates", toLog()); return false; } return true; }
CandidatePair NicerConnection::getSelectedPair() { auto selected_pair_promise = std::make_shared<std::promise<CandidatePair>>(); async([this, selected_pair_promise] { nr_ice_candidate *local; nr_ice_candidate *remote; nicer_->IceMediaStreamGetActive(peer_, stream_, 1, &local, &remote); CandidatePair pair; if (!local || !remote) { selected_pair_promise->set_value(CandidatePair{}); return; } pair.clientCandidateIp = getStringFromAddress(remote->addr); pair.erizoCandidateIp = getStringFromAddress(local->addr); pair.clientCandidatePort = getPortFromAddress(remote->addr); pair.erizoCandidatePort = getPortFromAddress(local->addr); pair.clientHostType = getHostTypeFromNicerCandidate(remote); pair.erizoHostType = getHostTypeFromNicerCandidate(local); ELOG_DEBUG("%s message: Client Host Type %s", toLog(), pair.clientHostType.c_str()); selected_pair_promise->set_value(pair); }); std::future<CandidatePair> selected_pair_future = selected_pair_promise->get_future(); std::future_status status = selected_pair_future.wait_for(std::chrono::seconds(1)); CandidatePair pair = selected_pair_future.get(); if (status == std::future_status::timeout) { ELOG_WARN("%s message: Could not get selected pair", toLog()); return CandidatePair{}; } return pair; }
void application::handleRequest(const reactive::http::request& request_, reactive::http::response& response_) const { reactive::web::router::parameters parameters_map; // Match the request url path to one of the registred application's // context (route + resource) for (std::size_t i = 0; i < m_resources.size(); ++i) { if (m_resources[i]->match(request_, parameters_map)) { if (!(m_resources[i]->handleRequest(request_, parameters_map, response_))) { // The fallback response depends on the handler // Here we set the status code only response_.setStatusCode(reactive::http::status::INTERNAL_SERVER_ERROR); reactive::logger::error(toLog(response_) + " error in selected request handler."); } // The first matching context is the only one used for now. reactive::logger::info(toLog(response_) + "ok, " + request_.toLog()); return; } } response_.setStatusCode(reactive::http::status::NOT_FOUND); reactive::logger::error(toLog(response_) + "no handler found for request, " + request_.toLog()); }
int parseOpts(int argc, char** argv, Settings *settings) { int option; if (argc != 7) { fprintf(stderr, "Usage: %s -h <ip> -p <port> -d <dir>\n", argv[0]); exit(EXIT_FAILURE); } while ((option = getopt(argc, argv, "h:p:d:")) != -1) { switch (option) { case 'h': toLog("IP: ", optarg); settings->ip = optarg; break; case 'p': toLog("Port: ", optarg); settings->port = (uint16_t) atoi(optarg); break; case 'd': toLog("Path: ", optarg); settings->path = optarg; break; default: fprintf(stderr, "Usage: -h <ip> -p <port> -d <directory>\n"); exit(EXIT_FAILURE); } } int pathLen = strlen(settings->path); if (settings->path[pathLen-1] == '/') settings->path[pathLen-1] = '\0'; return 0; }
ZAddAppDlg::ZAddAppDlg() :MyBaseDlg() { toLog("ZAddAppDlg: Start"); setMainWidgetTitle(lng->getString("DLG_ADD")); lbAppList = new ZListBox ( QString ( "%I%M" ), this, 0); lbAppList->setFixedWidth ( SCREEN_WHIDTH ); lbAppList->sort(true); setContentWidget ( lbAppList ); ZSoftKey *softKey = new ZSoftKey ( NULL, this, this ); softKey->setText ( ZSoftKey::LEFT, lng->getString("ADD"), ( ZSoftKey::TEXT_PRIORITY ) 0 ); softKey->setText ( ZSoftKey::RIGHT, lng->getString("CANCEL"), ( ZSoftKey::TEXT_PRIORITY ) 0 ); softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( reject() ) ); softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( accept() ) ); setCSTWidget ( softKey ); toLog("ZAddAppDlg: Build app list"); procReg( CARD_REGISTRY ); #ifdef OLD_PLATFORM procReg( USER_REGISTRY); #endif procReg( SYS_REGISTRY ); procReg( INSTALLED_DB ); toLog("ZAddAppDlg: End"); }
bool MediaStream::setRemoteSdp(std::shared_ptr<SdpInfo> sdp) { ELOG_DEBUG("%s message: setting remote SDP", toLog()); remote_sdp_ = sdp; if (remote_sdp_->videoBandwidth != 0) { ELOG_DEBUG("%s message: Setting remote BW, maxVideoBW: %u", toLog(), remote_sdp_->videoBandwidth); this->rtcp_processor_->setMaxVideoBW(remote_sdp_->videoBandwidth*1000); } if (pipeline_initialized_) { pipeline_->notifyUpdate(); return true; } bundle_ = remote_sdp_->isBundle; setVideoSourceSSRCList(remote_sdp_->video_ssrc_list); setAudioSourceSSRC(remote_sdp_->audio_ssrc); audio_enabled_ = remote_sdp_->hasAudio; video_enabled_ = remote_sdp_->hasVideo; rtcp_processor_->addSourceSsrc(getAudioSourceSSRC()); std::for_each(video_source_ssrc_list_.begin(), video_source_ssrc_list_.end(), [this] (uint32_t new_ssrc){ rtcp_processor_->addSourceSsrc(new_ssrc); }); initializePipeline(); return true; }
void NicerConnection::setupTurnServer() { if (ice_config_.turn_server.empty()) { return; } auto servers = std::unique_ptr<nr_ice_turn_server[]>(new nr_ice_turn_server[1]); nr_ice_turn_server *server = &servers[0]; nr_ice_stun_server *stun_server = &server->turn_server; memset(server, 0, sizeof(nr_ice_turn_server)); stun_server->transport = IPPROTO_UDP; stun_server->type = NR_ICE_STUN_SERVER_TYPE_ADDR; nr_transport_addr addr; nr_str_port_to_transport_addr(ice_config_.turn_server.c_str(), ice_config_.turn_port, IPPROTO_UDP, &addr); stun_server->u.addr = addr; server->username = r_strdup(const_cast<char*>(ice_config_.turn_username.c_str())); int r = r_data_create(&server->password, reinterpret_cast<UCHAR*>(const_cast<char *>(&ice_config_.turn_pass[0])), ice_config_.turn_pass.size()); if (r) { RFREE(server->username); return; } r = nicer_->IceContextSetTurnServers(ctx_, servers.get(), 1); if (r) { ELOG_WARN("%s message: Could not setup Turn", toLog()); } ELOG_DEBUG("%s message: TURN server configured", toLog()); }
void NicerConnection::startGathering() { UINT4 r = nicer_->IceGather(ctx_, &NicerConnection::gather_callback, this); if (r && r != R_WOULDBLOCK) { ELOG_WARN("%s message: Couldn't start ICE gathering", toLog()); assert(false); } ELOG_INFO("%s message: start gathering", toLog()); }
void MediaStream::read(std::shared_ptr<DataPacket> packet) { char* buf = packet->data; int len = packet->length; // PROCESS RTCP RtpHeader *head = reinterpret_cast<RtpHeader*> (buf); RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf); uint32_t recvSSRC = 0; if (!chead->isRtcp()) { recvSSRC = head->getSSRC(); } else if (chead->packettype == RTCP_Sender_PT) { // Sender Report recvSSRC = chead->getSSRC(); } // DELIVER FEEDBACK (RR, FEEDBACK PACKETS) if (chead->isFeedback()) { if (fb_sink_ != nullptr && should_send_feedback_) { fb_sink_->deliverFeedback(std::move(packet)); } } else { // RTP or RTCP Sender Report if (bundle_) { // Check incoming SSRC // Deliver data if (isVideoSourceSSRC(recvSSRC)) { parseIncomingPayloadType(buf, len, VIDEO_PACKET); video_sink_->deliverVideoData(std::move(packet)); } else if (isAudioSourceSSRC(recvSSRC)) { parseIncomingPayloadType(buf, len, AUDIO_PACKET); audio_sink_->deliverAudioData(std::move(packet)); } else { ELOG_DEBUG("%s read video unknownSSRC: %u, localVideoSSRC: %u, localAudioSSRC: %u", toLog(), recvSSRC, this->getVideoSourceSSRC(), this->getAudioSourceSSRC()); } } else { if (packet->type == AUDIO_PACKET && audio_sink_ != nullptr) { parseIncomingPayloadType(buf, len, AUDIO_PACKET); // Firefox does not send SSRC in SDP if (getAudioSourceSSRC() == 0) { ELOG_DEBUG("%s discoveredAudioSourceSSRC:%u", toLog(), recvSSRC); this->setAudioSourceSSRC(recvSSRC); } audio_sink_->deliverAudioData(std::move(packet)); } else if (packet->type == VIDEO_PACKET && video_sink_ != nullptr) { parseIncomingPayloadType(buf, len, VIDEO_PACKET); // Firefox does not send SSRC in SDP if (getVideoSourceSSRC() == 0) { ELOG_DEBUG("%s discoveredVideoSourceSSRC:%u", toLog(), recvSSRC); this->setVideoSourceSSRC(recvSSRC); } // change ssrc for RTP packets, don't touch here if RTCP video_sink_->deliverVideoData(std::move(packet)); } } // if not bundle } // if not Feedback }
bool MediaStream::setRemoteSdp(std::shared_ptr<SdpInfo> sdp) { ELOG_DEBUG("%s message: setting remote SDP", toLog()); if (!sending_) { return true; } remote_sdp_ = sdp; if (remote_sdp_->videoBandwidth != 0) { ELOG_DEBUG("%s message: Setting remote BW, maxVideoBW: %u", toLog(), remote_sdp_->videoBandwidth); this->rtcp_processor_->setMaxVideoBW(remote_sdp_->videoBandwidth*1000); } if (pipeline_initialized_) { pipeline_->notifyUpdate(); return true; } bundle_ = remote_sdp_->isBundle; auto video_ssrc_list_it = remote_sdp_->video_ssrc_map.find(getLabel()); if (video_ssrc_list_it != remote_sdp_->video_ssrc_map.end()) { setVideoSourceSSRCList(video_ssrc_list_it->second); } auto audio_ssrc_it = remote_sdp_->audio_ssrc_map.find(getLabel()); if (audio_ssrc_it != remote_sdp_->audio_ssrc_map.end()) { setAudioSourceSSRC(audio_ssrc_it->second); } if (getVideoSourceSSRCList().empty() || (getVideoSourceSSRCList().size() == 1 && getVideoSourceSSRCList()[0] == 0)) { std::vector<uint32_t> default_ssrc_list; default_ssrc_list.push_back(kDefaultVideoSinkSSRC); setVideoSourceSSRCList(default_ssrc_list); } if (getAudioSourceSSRC() == 0) { setAudioSourceSSRC(kDefaultAudioSinkSSRC); } audio_enabled_ = remote_sdp_->hasAudio; video_enabled_ = remote_sdp_->hasVideo; rtcp_processor_->addSourceSsrc(getAudioSourceSSRC()); std::for_each(video_source_ssrc_list_.begin(), video_source_ssrc_list_.end(), [this] (uint32_t new_ssrc){ rtcp_processor_->addSourceSsrc(new_ssrc); }); initializePipeline(); return true; }
void ZGui::load ( const QString fileName, bool AutoCodec ) { toLog("load ("+fileName+")"); QFile file ( fileName ); if ( file.open ( IO_ReadWrite ) )//IO_ReadOnly ) ) { //Block update edit->blockSignals(true); edit->setAutoUpdate(false); //Set def editor edit->clear(); edit->setText(""); //Detect codec if ( AutoCodec ) { //Reset all checked for (int i=0; i<CODEC_COUNT;i++) CodeMenu->setItemChecked(i,false); //Read data for detect char data[10000]; int size = file.readBlock(data, sizeof(data)); file.reset(); textCode = detectCodec(data, size); //Check codec CodeMenu->setItemChecked(textCode, true); } toLog("\tload text"); //Load file char data[ file.size() ]; file.readBlock(data, sizeof(data)); QTextCodec* codec = codecByLocalId(textCode); toLog("\tset text"); edit->setText( codec->toUnicode( data ) ); toLog("\tclose file"); file.close(); //Unblock update edit->blockSignals(false); edit->setAutoUpdate(true); #ifdef MDI setMainWidgetTitle(sFileName); buildDlgMenu(); #endif toLog("end load"); } }
void MediaStream::close() { ELOG_DEBUG("%s message:Close called", toLog()); if (!sending_) { return; } sending_ = false; video_sink_ = nullptr; audio_sink_ = nullptr; fb_sink_ = nullptr; pipeline_->close(); pipeline_.reset(); connection_.reset(); ELOG_DEBUG("%s message: Close ended", toLog()); }
SyncQtOwnCloud* SyncWindow::addAccount(QString name) { SyncQtOwnCloud *account = new SyncQtOwnCloud(name, mSharedFilters,mConfigDirectory); mAccounts.append(account); mAccountNames.append(name); // Connect the signals connect(account,SIGNAL(conflictExists(SyncQtOwnCloud*)), this,SLOT(slotConflictExists(SyncQtOwnCloud*))); connect(account,SIGNAL(conflictResolved(SyncQtOwnCloud*)), this,SLOT(slotConflictResolved(SyncQtOwnCloud*))); connect(account,SIGNAL(progressFile(qint64)), this,SLOT(slotProgressFile(qint64))); connect(account,SIGNAL(progressTotal(qint64)), this,SLOT(slotProgressTotal(qint64))); connect(account,SIGNAL(readyToSync(SyncQtOwnCloud*)), this,SLOT(slotReadyToSync(SyncQtOwnCloud*))); connect(account,SIGNAL(toLog(QString)), this,SLOT(slotToLog(QString))); connect(account,SIGNAL(toStatus(QString)), this,SLOT(slotToStatus(QString))); connect(account,SIGNAL(finishedSync(SyncQtOwnCloud*)), this,SLOT(slotFinishedSync(SyncQtOwnCloud*))); connect(account,SIGNAL(toMessage(QString,QString, QSystemTrayIcon::MessageIcon)), this,SLOT(slotToMessage(QString,QString, QSystemTrayIcon::MessageIcon))); return account; }
void MediaStream::onTransportData(std::shared_ptr<DataPacket> packet, Transport *transport) { if ((audio_sink_ == nullptr && video_sink_ == nullptr && fb_sink_ == nullptr)) { return; } if (transport->mediaType == AUDIO_TYPE) { packet->type = AUDIO_PACKET; } else if (transport->mediaType == VIDEO_TYPE) { packet->type = VIDEO_PACKET; } char* buf = packet->data; RtpHeader *head = reinterpret_cast<RtpHeader*> (buf); RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf); if (!chead->isRtcp()) { uint32_t recvSSRC = head->getSSRC(); if (isVideoSourceSSRC(recvSSRC)) { packet->type = VIDEO_PACKET; } else if (isAudioSourceSSRC(recvSSRC)) { packet->type = AUDIO_PACKET; } } if (!pipeline_initialized_) { ELOG_DEBUG("%s message: Pipeline not initialized yet.", toLog()); return; } pipeline_->read(std::move(packet)); }
void MonitoringDevice::commandGetEvent(unsigned char* _pArea){ const unsigned int EVENT_ID_OFFSET = 5; const unsigned int EVENT_FAULT_OFFSET = 7; const unsigned int EVENT_COUNT_OFFSET = 8; setFault(_pArea[EVENT_FAULT_OFFSET]); unsigned short _eventId = _pArea[EVENT_ID_OFFSET] + _pArea[EVENT_ID_OFFSET + 1] * 256; if (_eventId != eventId){ if (_pArea[EVENT_COUNT_OFFSET] != 0){ if (!SerialDebug::getSingleton().isOn()) redirectToPc(_pArea); unsigned int messageCount = firstMessage(&_pArea); for (unsigned int i = 0; i < messageCount; ++i){ if (isEventMessage(_pArea)){ toLog(_pArea); setOutputs(_pArea); } nextMessage(&_pArea); } } } eventId = _eventId; }
void MediaStream::sendPacket(std::shared_ptr<DataPacket> p) { if (!sending_) { return; } uint32_t partial_bitrate = 0; uint64_t sentVideoBytes = 0; uint64_t lastSecondVideoBytes = 0; if (rate_control_ && !slide_show_mode_) { if (p->type == VIDEO_PACKET) { if (rate_control_ == 1) { return; } now_ = clock::now(); if ((now_ - mark_) >= kBitrateControlPeriod) { mark_ = now_; lastSecondVideoBytes = sentVideoBytes; } partial_bitrate = ((sentVideoBytes - lastSecondVideoBytes) * 8) * 10; if (partial_bitrate > this->rate_control_) { return; } sentVideoBytes += p->length; } } if (!pipeline_initialized_) { ELOG_DEBUG("%s message: Pipeline not initialized yet.", toLog()); return; } pipeline_->write(std::move(p)); }
void MediaStream::close() { ELOG_DEBUG("%s message: Async close called", toLog()); std::shared_ptr<MediaStream> shared_this = shared_from_this(); asyncTask([shared_this] (std::shared_ptr<MediaStream> stream) { shared_this->syncClose(); }); }
void MediaStream::onTransportData(std::shared_ptr<DataPacket> incoming_packet, Transport *transport) { if ((audio_sink_ == nullptr && video_sink_ == nullptr && fb_sink_ == nullptr)) { return; } std::shared_ptr<DataPacket> packet = std::make_shared<DataPacket>(*incoming_packet); if (transport->mediaType == AUDIO_TYPE) { packet->type = AUDIO_PACKET; } else if (transport->mediaType == VIDEO_TYPE) { packet->type = VIDEO_PACKET; } auto stream_ptr = shared_from_this(); worker_->task([stream_ptr, packet]{ if (!stream_ptr->pipeline_initialized_) { ELOG_DEBUG("%s message: Pipeline not initialized yet.", stream_ptr->toLog()); return; } char* buf = packet->data; RtpHeader *head = reinterpret_cast<RtpHeader*> (buf); RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf); if (!chead->isRtcp()) { uint32_t recvSSRC = head->getSSRC(); if (stream_ptr->isVideoSourceSSRC(recvSSRC)) { packet->type = VIDEO_PACKET; } else if (stream_ptr->isAudioSourceSSRC(recvSSRC)) { packet->type = AUDIO_PACKET; } } stream_ptr->pipeline_->read(std::move(packet)); }); }
MediaStream::MediaStream( std::shared_ptr<WebRtcConnection> connection, const std::string& media_stream_id) : audio_enabled_{false}, video_enabled_{false}, connection_{connection}, stream_id_{media_stream_id}, bundle_{false}, pipeline_{Pipeline::create()}, audio_muted_{false}, video_muted_{false}, pipeline_initialized_{false} { setVideoSinkSSRC(kDefaultVideoSinkSSRC); setAudioSinkSSRC(kDefaultAudioSinkSSRC); ELOG_INFO("%s message: constructor, id: %s", toLog(), media_stream_id.c_str()); source_fb_sink_ = this; sink_fb_source_ = this; stats_ = connection->getStatsService(); quality_manager_ = std::make_shared<QualityManager>(); packet_buffer_ = std::make_shared<PacketBufferService>(); worker_ = connection->getWorker(); rtcp_processor_ = std::make_shared<RtcpForwarder>(static_cast<MediaSink*>(this), static_cast<MediaSource*>(this)); should_send_feedback_ = true; slide_show_mode_ = false; mark_ = clock::now(); rate_control_ = 0; sending_ = true; }
void NicerConnection::startChecking() { UINT4 r = nicer_->IcePeerContextPairCandidates(peer_); if (r) { ELOG_WARN("%s message: Error pairing candidates (%d)", toLog(), r); return; } r = nicer_->IcePeerContextStartChecks2(peer_, 1); if (r) { if (r == R_NOT_FOUND) { ELOG_DEBUG("%s message: Could not start ICE checks, assuming trickle", toLog()); } else { ELOG_WARN("%s message: Could not start peer checks", toLog()); } } ELOG_DEBUG("Checks started"); }
int ZGui::detectCodec( char * chars, int maxLen ) { toLog("\t#Maxlen: "+QString::number(maxLen) + " strlen "+QString::number(strlen(chars)) ); int ret[CODEC_COUNT]; int id=0; for (int i=0;i<(cfg_chineseCodeDetect?CODEC_COUNT-1:CODEC_COUNT-2); i++) // CODEC_COUNT-1 - GBK not be detected { ret[i] = checkCodec( chars, strlen(chars), i ); toLog("\t#CodecId: "+QString::number(i)+" res:"+QString::number(ret[i])); if ( ret[i]>ret[id] ) id = i; } return id; }
void NicerConnection::start() { async([this] { startSync(); }); std::future_status status = start_promise_.get_future().wait_for(std::chrono::seconds(5)); if (status == std::future_status::timeout) { ELOG_WARN("%s Start timed out", toLog()); } }
void NicerConnection::setRemoteCredentialsSync(const std::string& username, const std::string& password) { ELOG_DEBUG("%s message: Setting remote credentials", toLog()); std::vector<char *> attributes; std::string ufrag = std::string("ice-ufrag: ") + username; std::string pwd = std::string("ice-pwd: ") + password; attributes.push_back(const_cast<char *>(ufrag.c_str())); attributes.push_back(const_cast<char *>(pwd.c_str())); UINT4 r = nicer_->IcePeerContextParseStreamAttributes(peer_, stream_, attributes.size() ? &attributes[0] : nullptr, attributes.size()); if (r) { ELOG_WARN("%s message: Error parsing stream attributes", toLog()); return; } startChecking(); }
int UHokuyo::receiveFromDevice(char * start, int maxLng, double timeoutSec) { // poll wait time int pollTime = roundi(timeoutSec * 1000.0); // ms int n, m = maxLng; struct pollfd sickstruct; // sickstruct.fd = hfd; sickstruct.events = POLLIN; bool timeout; int result = 0; char * bp = start; // if (verbose and not laslog.isOpen()) laslog.openLog(); else if (laslog.isOpen() and not verbose) laslog.closeLog(); // receive a number of data that should include a header /* get new data */ timeout = false; while ((m > 0) and not timeout) { // Wait for data in up to 100 ms if (poll(&sickstruct, 1, pollTime) != POLLIN) // timeout or other error - return timeout = true; else { /* read up to a full message */ n = read(hfd, bp, m); if (n == -1) { // error perror("Error in read from serial line"); break; } else { // allow log if (result == 0) { // first data - timestamp dataRxTime.now(); } if ((n > 0) and laslog.isLogOpen()) toLog(bp, n, "<-", dataRxTime); // bp[n] = '\0'; m -= n; result += n; if (strstr(bp, "\n\n") != NULL) // a full message is received. break; bp = &start[result]; } } } // return result; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->label_2->hide(); ui->progressBar->setRange(0, 1000); // потому что прогресс приёма не определить logstr = tr("] <b>Запуск программы</b>"); string2log(logstr); ui->log->append(tr("можете нажать <font color=blue><b>F1</b></font>")); logstr = "-----------------------------------------"; ui->log->append(logstr); logstr = tr("<i>выберите порт и настройте его</i>"); ui->log->append(logstr); logstr = tr(""); ui->log->append(logstr); ui->lineEdit->setText(tr("выберите файл для передачи...")); ui->listenBtn->setEnabled(false); ComListener = new DemonPorta(); config = new QSettings(qApp->applicationDirPath()+"/config.ini", QSettings::IniFormat); // а просто так, впишем в конфиг нулевые значения. Реально, просто так config->setValue("port/Baud_Rate", 0); config->setValue("port/DataBits", 0); config->setValue("port/Parity", 0); config->setValue("port/StopBits", 0); config->setValue("file/fileToTransf", ""); config->setValue("file/pathForSave", "C:/"); // эта группа в лопосатых купальниках пишет в конфиг изменения настроек connect(ui->comboBox_2, SIGNAL(currentIndexChanged(QString)), this, SLOT(BaudRateChanged(QString))); connect(ui->comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(ParityChanged(int))); connect(ui->comboBox_4, SIGNAL(currentIndexChanged(QString)), this, SLOT(DataBitsChanged(QString))); connect(ui->comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(StopBitsChanged(int))); // эти ребята дают Демону пользоваться GUI'ем connect(ComListener, SIGNAL(wannaUseLog(QString)), this, SLOT(toLog(QString))); connect(ComListener, SIGNAL(setProgr(int)), this, SLOT(setProgr(int))); connect(ComListener, SIGNAL(progrFin()), this, SLOT(finProgr())); // а вот он вываливается из своей функции, чтобы крикнуть Демону, куда являться connect(this, SIGNAL(curPortHandle(HANDLE)), ComListener, SLOT(setPortHandle(HANDLE))); }
void Logger::toLogWithFormat(const char* format, ...) { std::string fmt(format); size_t n = std::count(fmt.begin(), fmt.end(), '%'); if (n > 0) { static char buf[2048]; va_list args; va_start(args, format); vsprintf(buf, format, args); va_end(args); toLog(buf); } else { toLog(format); } }
void NicerConnection::setRemoteCredentials(const std::string& username, const std::string& password) { auto promise = std::make_shared<std::promise<void>>(); async([username, password, promise, this] { setRemoteCredentialsSync(username, password); promise->set_value(); }); auto status = promise->get_future().wait_for(std::chrono::seconds(1)); if (status == std::future_status::timeout) { ELOG_WARN("%s message: Could not set remote credentials", toLog()); } }
void NicerConnection::setupStunServer() { if (ice_config_.stun_server.empty()) { return; } auto servers = std::unique_ptr<nr_ice_stun_server[]>(new nr_ice_stun_server[1]); nr_ice_stun_server *server = &servers[0]; memset(server, 0, sizeof(nr_ice_stun_server)); server->transport = IPPROTO_UDP; server->type = NR_ICE_STUN_SERVER_TYPE_ADDR; nr_transport_addr addr; nr_str_port_to_transport_addr(ice_config_.stun_server.c_str(), ice_config_.stun_port, IPPROTO_UDP, &addr); server->u.addr = addr; int r = nicer_->IceContextSetStunServers(ctx_, servers.get(), 1); if (r) { ELOG_WARN("%s meesage: Could not setup Turn", toLog()); } ELOG_DEBUG("%s message: STUN server configured", toLog()); }
void MediaStream::setSlideShowMode(bool state) { ELOG_DEBUG("%s slideShowMode: %u", toLog(), state); if (slide_show_mode_ == state) { return; } asyncTask([state] (std::shared_ptr<MediaStream> media_stream) { media_stream->stats_->getNode()[media_stream->getVideoSinkSSRC()].insertStat( "erizoSlideShow", CumulativeStat{state}); }); slide_show_mode_ = state; notifyUpdateToHandlers(); }