OutputIceCast::OutputIceCast() : _shout(0), _state(INVALID), _timer(new QTimer(this)) { _timer->setInterval(5000); _timer->setSingleShot(false); connect(_timer, SIGNAL(timeout()), this, SLOT(connectStream())); connect(this, SIGNAL(requestReconnect()), this, SLOT(reconnectStream()), Qt::QueuedConnection); shout_init(); }
bool CameraView::connectToVideo(std::string filename) { // Set frame label text ui->frameLabel->setText("Loading video..."); ui->deviceNumberLabel->setText( QString::fromStdString(filename.substr(filename.length()-30,filename.length()))); captureThread = new CaptureThread(sharedImageBuffer, tabId,true,id); sharedImageBuffer->start(id,true); if(captureThread->connectVideo(filename)) { isVideo = true; widthVideo = captureThread->getInputSourceWidth(); heightVideo = captureThread->getInputSourceHeight(); connectStream(); return true; } return false; }
bool CameraView::connectToCamera(int deviceNumber,int idxResolution) { // Set frame label text ui->frameLabel->setText("Connecting to camera..."); captureThread = new CaptureThread(sharedImageBuffer, tabId,true,id); sharedImageBuffer->start(id,false); ui->deviceNumberLabel->setText(QString("/dev/video%1").arg(deviceNumber)); if(captureThread->connectToCamera(deviceNumber,idxResolution)) { isVideo = false; connectStream(); capW = captureThread->getInputSourceWidth(); capH = captureThread->getInputSourceHeight(); return true; } return false; }
//////////////////////////////////////////////////// // Constructor EQPacket::EQPacket(const QString& worldopcodesxml, const QString& zoneopcodesxml, uint16_t arqSeqGiveUp, QString device, QString ip, QString mac_address, bool realtime, bool sessionTrackingFlag, bool recordPackets, int playbackPackets, int8_t playbackSpeed, QObject * parent, const char *name) : QObject (parent, name), m_packetCapture(NULL), m_vPacket(NULL), m_timer(NULL), m_busy_decoding(false), m_arqSeqGiveUp(arqSeqGiveUp), m_device(device), m_ip(ip), m_mac(mac_address), m_realtime(realtime), m_session_tracking(sessionTrackingFlag), m_recordPackets(recordPackets), m_playbackPackets(playbackPackets), m_playbackSpeed(playbackSpeed) { // create the packet type db m_packetTypeDB = new EQPacketTypeDB(); #ifdef PACKET_OPCODEDB_DIAG m_packetTypeDB->list(); #endif // create the world opcode db (with hash size of 29) m_worldOPCodeDB = new EQPacketOPCodeDB(29); // load the world opcode db if (!m_worldOPCodeDB->load(*m_packetTypeDB, worldopcodesxml)) seqFatal("Error loading '%s'!", (const char*)worldopcodesxml); #ifdef PACKET_OPCODEDB_DIAG m_worldOPCodeDB->list(); #endif //m_worldOPCodeDB->save("/tmp/worldopcodes.xml"); // create the zone opcode db (with hash size of 211) m_zoneOPCodeDB = new EQPacketOPCodeDB(211); // load the zone opcode db if (!m_zoneOPCodeDB->load(*m_packetTypeDB, zoneopcodesxml)) seqFatal("Error loading '%s'!", (const char*)zoneopcodesxml); #ifdef PACKET_OPCODEDB_DIAG m_zoneOPCodeDB->list(); #endif //m_zoneOPCodeDB->save("/tmp/zoneopcodes.xml"); // Setup the data streams // Setup client -> world stream m_client2WorldStream = new EQPacketStream(client2world, DIR_Client, m_arqSeqGiveUp, *m_worldOPCodeDB, this, "client2world"); connectStream(m_client2WorldStream); // Setup world -> client stream m_world2ClientStream = new EQPacketStream(world2client, DIR_Server, m_arqSeqGiveUp, *m_worldOPCodeDB, this, "world2client"); connectStream(m_world2ClientStream); // Setup client -> zone stream m_client2ZoneStream = new EQPacketStream(client2zone, DIR_Client, m_arqSeqGiveUp, *m_zoneOPCodeDB, this, "client2zone"); connectStream(m_client2ZoneStream); // Setup zone -> client stream m_zone2ClientStream = new EQPacketStream(zone2client, DIR_Server, m_arqSeqGiveUp, *m_zoneOPCodeDB, this, "zone2client"); connectStream(m_zone2ClientStream); // Initialize convenient streams array m_streams[client2world] = m_client2WorldStream; m_streams[world2client] = m_world2ClientStream; m_streams[client2zone] = m_client2ZoneStream; m_streams[zone2client] = m_zone2ClientStream; // no client/server ports yet m_clientPort = 0; m_serverPort = 0; struct hostent *he; struct in_addr ia; if (m_ip.isEmpty() && m_mac.isEmpty()) seqFatal("No address specified"); if (!m_ip.isEmpty()) { /* Substitute "special" IP which is interpreted to set up a different filter for picking up new sessions */ if (m_ip == "auto") inet_aton (AUTOMATIC_CLIENT_IP, &ia); else if (inet_aton (m_ip, &ia) == 0) { he = gethostbyname(m_ip); if (!he) seqFatal("Invalid address; %s", (const char*)m_ip); memcpy (&ia, he->h_addr_list[0], he->h_length); } m_client_addr = ia.s_addr; m_ip = inet_ntoa(ia); if (m_ip == AUTOMATIC_CLIENT_IP) { m_detectingClient = true; seqInfo("Listening for first client seen."); } else { m_detectingClient = false; seqInfo("Listening for client: %s", (const char*)m_ip); } } if (m_playbackPackets == PLAYBACK_OFF) { // create the pcap object and initialize, either with MAC or IP m_packetCapture = new PacketCaptureThread(); if (m_mac.length() == 17) m_packetCapture->start(m_device, m_mac, m_realtime, MAC_ADDRESS_TYPE ); else m_packetCapture->start(m_device, m_ip, m_realtime, IP_ADDRESS_TYPE ); emit filterChanged(); } else if (m_playbackPackets == PLAYBACK_FORMAT_TCPDUMP) { // Create the pcap object and initialize with the file input given m_packetCapture = new PacketCaptureThread(); const char* filename = pSEQPrefs->getPrefString("Filename", "VPacket"); m_packetCapture->startOffline(filename, m_playbackSpeed); seqInfo("Playing back packets from '%s' at speed '%d'", filename, m_playbackSpeed); } // Flag session tracking properly on streams session_tracking(sessionTrackingFlag); // if running setuid root, then give up root access, since the PacketCapture // is the only thing that needed it. if ((geteuid() == 0) && (getuid() != geteuid())) setuid(getuid()); /* Create timer object */ m_timer = new QTimer (this); if (m_playbackPackets == PLAYBACK_OFF || m_playbackPackets == PLAYBACK_FORMAT_TCPDUMP) { // Normal pcap packet handler connect (m_timer, SIGNAL (timeout ()), this, SLOT (processPackets ())); } else { // Special internal playback handler connect (m_timer, SIGNAL (timeout ()), this, SLOT (processPlaybackPackets ())); } /* setup VPacket */ m_vPacket = NULL; QString section = "VPacket"; // First param to VPacket is the filename // Second param is playback speed: 0 = fast as poss, 1 = 1X, 2 = 2X etc if (pSEQPrefs->isPreference("Filename", section)) { const char *filename = pSEQPrefs->getPrefString("Filename", section); if (m_recordPackets) { m_vPacket = new VPacket(filename, 1, true); // Must appear befire next call to getPrefString, which uses a static string seqInfo("Recording packets to '%s' for future playback", filename); if (pSEQPrefs->getPrefBool("FlushPackets", section)) m_vPacket->setFlushPacket(true); } else if (m_playbackPackets == PLAYBACK_FORMAT_SEQ) { m_vPacket = new VPacket(filename, 1, false); m_vPacket->setCompressTime(pSEQPrefs->getPrefInt("CompressTime", section, 0)); m_vPacket->setPlaybackSpeed(m_playbackSpeed); seqInfo("Playing back packets from '%s' at speed '%d'", filename, m_playbackSpeed); } } else { m_recordPackets = 0; m_playbackPackets = PLAYBACK_OFF; } }