void cRecPlayer::scan() { struct stat s; closeFile(); m_totalLength = 0; m_fileOpen = -1; m_totalFrames = 0; cleanup(); for(int i = 0; ; i++) // i think we only need one possible loop { fileNameFromIndex(i); if(stat(m_fileName, &s) == -1) { break; } cSegment* segment = new cSegment(); segment->start = m_totalLength; segment->end = segment->start + s.st_size; m_segments.Append(segment); m_totalLength += s.st_size; INFOLOG("File %i found, size: %llu, totalLength now %llu", i, s.st_size, m_totalLength); } m_totalFrames = m_indexFile->Last(); INFOLOG("total frames: %u", m_totalFrames); }
std::vector<QString> CoreMidiDriver::getOutputPortList() { INFOLOG( "retrieving output list" ); OSStatus err = noErr; std::vector<QString> cmPortList; cmSources = MIDIGetNumberOfSources(); INFOLOG ( "Getting number of MIDI sources . . .\n" ); unsigned i; for ( i = 0; i < cmSources; i++ ) { CFStringRef H2MidiNames; cmH2Src = MIDIGetSource( i ); if ( cmH2Src == NULL ) { ERRORLOG( "Could not open input device" ); } if ( cmH2Src ) { err = MIDIObjectGetStringProperty( cmH2Src, kMIDIPropertyName, &H2MidiNames ); INFOLOG ( "Getting MIDI object string property . . .\n" ); char cmName[ 64 ]; CFStringGetCString( H2MidiNames, cmName, 64, kCFStringEncodingASCII ); INFOLOG ( "Getting MIDI object name . . .\n" ); QString h2MidiPortName = cmName; cmPortList.push_back( h2MidiPortName ); } CFRelease( H2MidiNames ); } return cmPortList; }
bool DVBAPI::ProcessArgs(int argc, char *argv[]) { static struct option long_options[] = { { "offset", required_argument, NULL, 'o' }, { "disable-exp", no_argument, NULL, 'd' }, { NULL } }; int c, option_index = 0; while ((c = getopt_long(argc, argv, "o:d", long_options, &option_index)) != -1) { switch (c) { case 'o': AdapterIndexOffset = atoi(optarg); INFOLOG("Using value %d as the adapter index offset", AdapterIndexOffset); break; case 'd': CheckExpiredCW = false; INFOLOG("CW expiration check is disabled"); break; default: return false; } } return true; }
void cLiveStreamer::sendStreamPacket(sStreamPacket *pkt) { bool bReady = IsReady(); if(!bReady || pkt == NULL || pkt->size == 0) return; // Send stream information as the first packet on startup if (IsStarting() && bReady) { // wait for first I-Frame (if enabled) if(m_waitforiframe && pkt->frametype != cStreamInfo::ftIFRAME) { return; } INFOLOG("streaming of channel started"); m_last_tick.Set(0); m_requestStreamChange = true; m_startup = false; } // send stream change on demand if(m_requestStreamChange) sendStreamChange(); // if a audio or video packet was sent, the signal is restored if(m_SignalLost && (pkt->content == cStreamInfo::scVIDEO || pkt->content == cStreamInfo::scAUDIO)) { INFOLOG("signal restored"); sendStatus(XVDR_STREAM_STATUS_SIGNALRESTORED); m_SignalLost = false; m_requestStreamChange = true; m_last_tick.Set(0); return; } if(m_SignalLost) return; // initialise stream packet MsgPacket* packet = new MsgPacket(XVDR_STREAM_MUXPKT, XVDR_CHANNEL_STREAM); packet->disablePayloadCheckSum(); // write stream data packet->put_U16(pkt->pid); packet->put_S64(pkt->pts); packet->put_S64(pkt->dts); if(m_protocolVersion >= 5) { packet->put_U32(pkt->duration); } // write frame type into unused header field clientid packet->setClientID((uint16_t)pkt->frametype); // write payload into stream packet packet->put_U32(pkt->size); packet->put_Blob(pkt->data, pkt->size); m_Queue->Add(packet); m_last_tick.Set(0); }
bool RoboTVServerConfig::Parse(const char* Name, const char* Value) { if(!strcasecmp(Name, "TimeShiftDir")) { LiveQueue::setTimeShiftDir(Value); } else if(!strcasecmp(Name, "MaxTimeShiftSize")) { LiveQueue::setBufferSize(strtoull(Value, NULL, 10)); } else if(!strcasecmp(Name, "PiconsURL")) { piconsUrl = Value; } else if(!strcasecmp(Name, "ReorderCmd")) { reorderCmd = Value; } else if(!strcasecmp(Name, "EpgImageUrl")) { INFOLOG("EPG images template URL: %s", Value); epgImageUrl = Value; } else if(!strcasecmp(Name, "SeriesFolder")) { INFOLOG("Folder for TV shows: %s", Value); seriesFolder = Value; } else if(!strcasecmp(Name, "FilterChannels")) { filterChannels = (strcmp(Value, "true") == 0); } else { return false; } return true; }
// return 0: ok // return 1: cannot activate client // return 2: cannot connect output port // return 3: Jack server not running // return 4: output port = NULL int JackOutput::connect() { INFOLOG( "connect" ); if ( jack_activate ( client ) ) { Hydrogen::get_instance()->raiseError( Hydrogen::JACK_CANNOT_ACTIVATE_CLIENT ); return 1; } bool connect_output_ports = m_bConnectOutFlag; memset( track_output_ports_L, 0, sizeof(track_output_ports_L) ); memset( track_output_ports_R, 0, sizeof(track_output_ports_R) ); #ifdef H2CORE_HAVE_LASH if ( Preferences::get_instance()->useLash() ){ LashClient* lashClient = LashClient::get_instance(); if (lashClient && lashClient->isConnected()) { // infoLog("[LASH] Sending Jack client name to LASH server"); lashClient->sendJackClientName(); if (!lashClient->isNewProject()) { connect_output_ports = false; } } } #endif if ( connect_output_ports ) { // if ( m_bConnectOutFlag ) { // connect the ports if ( jack_connect( client, jack_port_name( output_port_1 ), output_port_name_1.toLocal8Bit() ) == 0 && jack_connect ( client, jack_port_name( output_port_2 ), output_port_name_2.toLocal8Bit() ) == 0 ) { return 0; } INFOLOG( "Could not connect so saved out-ports. Connecting to first pair of in-ports" ); const char ** portnames = jack_get_ports ( client, NULL, NULL, JackPortIsInput ); if ( !portnames || !portnames[0] || !portnames[1] ) { ERRORLOG( "Could't locate two Jack input port" ); Hydrogen::get_instance()->raiseError( Hydrogen::JACK_CANNOT_CONNECT_OUTPUT_PORT ); return 2; } if ( jack_connect( client, jack_port_name( output_port_1 ), portnames[0] ) != 0 || jack_connect( client, jack_port_name( output_port_2 ), portnames[1] ) != 0 ) { ERRORLOG( "Could't connect to first pair of Jack input ports" ); Hydrogen::get_instance()->raiseError( Hydrogen::JACK_CANNOT_CONNECT_OUTPUT_PORT ); return 2; } free( portnames ); } return 0; }
cVNSIServer::cVNSIServer(int listenPort) : cThread("VNSI Server") { m_ServerPort = listenPort; Start(); INFOLOG("VNSI Server started"); INFOLOG("Channel streaming timeout: %i seconds", VNSIServerConfig.stream_timeout); return; }
void JackOutput::deactivate() { INFOLOG( "[deactivate]" ); if ( client ) { INFOLOG( "calling jack_deactivate" ); int res = jack_deactivate( client ); if ( res ) { ERRORLOG( "Error in jack_deactivate" ); } } memset( track_output_ports_L, 0, sizeof(track_output_ports_L) ); memset( track_output_ports_R, 0, sizeof(track_output_ports_R) ); }
void cTSDemuxer::SetVideoInformation(int FpsScale, int FpsRate, int Height, int Width, float Aspect, int num, int den) { // check for sane picture information if(Width < 320 || Height < 240 || num <= 0 || den <= 0 || Aspect < 0) return; // only register changed video information if(Width == m_width && Height == m_height && Aspect == m_aspect) return; INFOLOG("--------------------------------------"); INFOLOG("NEW PICTURE INFORMATION:"); INFOLOG("Picture Width: %i", Width); INFOLOG("Picture Height: %i", Height); if(num != 1 || den != 1) INFOLOG("Pixel Aspect: %i:%i", num, den); if(Aspect == 0) INFOLOG("Unknown Display Aspect Ratio"); else INFOLOG("Display Aspect Ratio: %.2f", Aspect); INFOLOG("--------------------------------------"); m_fpsscale = FpsScale; m_fpsrate = FpsRate; m_height = Height; m_width = Width; m_aspect = Aspect; m_parsed = true; m_Streamer->RequestStreamChange(); }
void SCCAMSlot::CaInfo(int tcid, int cid) { int cn = 0; for (int i = 0; caids[i]; i++) cn += 2; int n = cn + 8 + LengthSize(cn); unsigned char *p; if (!(p = frame.GetBuff(n + 1 + LengthSize(n)))) return; *p++ = 0xa0; SetSize(n, p); *p++ = tcid; *p++ = 0x90; *p++ = 0x02; *p++ = cid >> 8; *p++ = cid & 0xff; *p++ = 0x9f; *p++ = 0x80; *p++ = (unsigned char) AOT_CA_INFO; SetSize(cn, p); for (int i = 0; caids[i]; i++) { *p++ = caids[i] >> 8; *p++ = caids[i] & 0xff; } frame.Put(); INFOLOG("%s: %i.%i sending CA info", __FUNCTION__, cardIndex, slot); }
SoundLibraryImportDialog::SoundLibraryImportDialog( QWidget* pParent ) : QDialog( pParent ) , Object( __class_name ) { setupUi( this ); INFOLOG( "INIT" ); setWindowTitle( trUtf8( "Sound Library import" ) ); setFixedSize( width(), height() ); QStringList headers; headers << trUtf8( "Sound library" ) << trUtf8( "Status" ); QTreeWidgetItem* header = new QTreeWidgetItem( headers ); m_pDrumkitTree->setHeaderItem( header ); m_pDrumkitTree->header()->resizeSection( 0, 200 ); connect( m_pDrumkitTree, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem* ) ), this, SLOT( soundLibraryItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ) ); SoundLibraryNameLbl->setText( "" ); SoundLibraryInfoLbl->setText( "" ); DownloadBtn->setEnabled( false ); InstallBtn->setEnabled (false ); updateRepositoryCombo(); // force a new update //on_UpdateListBtn_clicked(); }
bool cPluginVNSIServer::Start(void) { INFOLOG("Starting vnsi server at port=%d\n", VNSIServerConfig.listen_port); Server = new cVNSIServer(VNSIServerConfig.listen_port); return true; }
void CoreAudioDriver::retrieveBufferSize(void) { UInt32 dataSize = 0; OSStatus err = 0; AudioObjectPropertyAddress propertyAddress = { kAudioDevicePropertyBufferFrameSize, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; dataSize = sizeof( m_nBufferSize ); err = AudioObjectGetPropertyData(m_outputDevice, &propertyAddress, 0, NULL, &dataSize, ( void * )&m_nBufferSize ); if ( err != noErr ) { ERRORLOG( "get BufferSize error" ); } INFOLOG( QString( "Buffersize: %1" ).arg( m_nBufferSize ) ); }
void cParser::Parse(unsigned char *data, int datasize, bool pusi) { // get available data int length = 0; uint8_t* buffer = Get(length); // do we have a sync ? int framesize = 0; if(length > m_headersize && buffer != NULL && CheckAlignmentHeader(buffer, framesize)) { if(framesize > 0 && length >= framesize) { ParsePayload(buffer, framesize); SendPayload(buffer, framesize); m_curPTS = PtsAdd(m_curPTS, m_duration); m_curDTS = PtsAdd(m_curDTS, m_duration); Del(framesize); } PutData(data, datasize, pusi); return; } // try to find sync int offset = FindAlignmentOffset(buffer, length, 0, framesize); if(offset != -1) { INFOLOG("sync found at offset %i (streamtype: %s / %i bytes in buffer / framesize: %i bytes)", offset, m_demuxer->TypeName(), Available(), framesize); Del(offset); } PutData(data, datasize, pusi); }
bool LoginController::processLogin(MsgPacket* request, MsgPacket* response) { m_protocolVersion = request->getProtocolVersion(); m_compressionLevel = request->get_U8(); const char* clientName = request->get_String(); m_statusInterfaceEnabled = request->get_U8(); if(m_protocolVersion > ROBOTV_PROTOCOLVERSION || m_protocolVersion < 7) { ERRORLOG("Client '%s' has unsupported protocol version '%u', terminating client", clientName, m_protocolVersion); return false; } INFOLOG("Welcome client '%s' with protocol version '%u'", clientName, m_protocolVersion); // Send the login reply time_t timeNow = time(NULL); struct tm* timeStruct = localtime(&timeNow); int timeOffset = timeStruct->tm_gmtoff; response->setProtocolVersion(m_protocolVersion); response->put_U32(timeNow); response->put_S32(timeOffset); response->put_String("roboTV VDR Server"); response->put_String(ROBOTV_VERSION); m_loggedIn = true; return true; }
void SndioMidiDriver::open() { char midiDevice[32]; INFOLOG("SndioMidiDriver::open"); snprintf(midiDevice, 32, (Preferences::get_instance()->m_sMidiPortName).toAscii()); if (strncmp(midiDevice, "", 1) == 0 || strncmp(midiDevice, "None", 5) == 0 || strncmp(midiDevice, "default", 8) == 0) hdl = mio_open(NULL, MIO_IN, 0); else hdl = mio_open(midiDevice, MIO_IN, 0); if (!hdl) { ERRORLOG("mio_open failed"); m_bRunning = false; return; } m_bRunning = true; pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&SndioMidiDriverThread, &attr, SndioMidiDriver_thread, ( void* )this); }
cVNSIServer::~cVNSIServer() { Cancel(); m_Status.Shutdown(); m_timers.Shutdown(); INFOLOG("VNSI Server stopped"); }
bool MovieController::processDelete(MsgPacket* request, MsgPacket* response) { const char* recid = request->get_String(); uint32_t uid = recid2uid(recid); cRecording* recording = RecordingsCache::instance().lookup(uid); if(recording == NULL) { ERRORLOG("Recording not found !"); response->put_U32(ROBOTV_RET_DATAUNKNOWN); return true; } DEBUGLOG("deleting recording: %s", recording->Name()); cRecordControl* rc = cRecordControls::GetRecordControl(recording->FileName()); if(rc != NULL) { ERRORLOG("Recording \"%s\" is in use by timer %d", recording->Name(), rc->Timer()->Index() + 1); response->put_U32(ROBOTV_RET_DATALOCKED); return true; } if(!recording->Delete()) { ERRORLOG("Error while deleting recording!"); response->put_U32(ROBOTV_RET_ERROR); return true; } Recordings.DelByName(recording->FileName()); INFOLOG("Recording \"%s\" deleted", recording->FileName()); response->put_U32(ROBOTV_RET_OK); return true; }
cDevice *cScSdDevicePlugin::Probe(int Adapter, int Frontend, uint32_t SubSystemId) { static uint32_t SubsystemIds[] = { 0x110A0000, // Fujitsu Siemens DVB-C 0x13C20000, // Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C 0x13C20001, // Technotrend/Hauppauge WinTV DVB-T rev1.X 0x13C20002, // Technotrend/Hauppauge WinTV DVB-C rev2.X 0x13C20003, // Technotrend/Hauppauge WinTV Nexus-S rev2.X 0x13C20004, // Galaxis DVB-S rev1.3 0x13C20006, // Fujitsu Siemens DVB-S rev1.6 0x13C20008, // Technotrend/Hauppauge DVB-T 0x13C2000A, // Technotrend/Hauppauge WinTV Nexus-CA rev1.X 0x13C2000E, // Technotrend/Hauppauge WinTV Nexus-S rev2.3 0x13C21002, // Technotrend/Hauppauge WinTV DVB-S rev1.3 SE 0x00000000 }; for (uint32_t *sid = SubsystemIds; *sid; sid++) { if (*sid == SubSystemId) { INFOLOG("creating SD-FF device %d/%d", Adapter, Frontend); return new cScDvbSdFfDevice(this, Adapter, Frontend, cScDevices::DvbOpen(DEV_DVB_CA, Adapter, Frontend, O_RDWR)); } } return 0; }
void cLiveQueue::Action() { INFOLOG("LiveQueue started"); // wait for first packet m_cond.Wait(0); while(Running()) { MsgPacket* p = NULL; m_lock.Lock(); // just wait if we are paused if(m_pause) { m_lock.Unlock(); m_cond.Wait(0); m_lock.Lock(); } // check packet queue if(size() > 0) { p = front(); pop(); } m_lock.Unlock(); // no packets to send if(p == NULL) { m_cond.Wait(3000); continue; } // send packet else { p->write(m_socket, 500); delete p; } } INFOLOG("LiveQueue stopped"); }
void SelectManager::loop() { int ret; char buf[1]; for (; !m_isStop;) { initFdSet(); ret = select(m_maxFd + 1, &m_readSet, &m_writeSet, NULL, NULL); if (ret == -1) { if (m_isStop) { INFOLOG("recv exit signal, exit loop"); }else { INFOLOG("EINTR"); } ERRORLOG1("select err, %s", strerror(errno)); break; } if (0 == ret) { ERRORLOG("select return 0"); break; } if (FD_ISSET(m_recvNotifyFd, &m_readSet)) { if (read(m_recvNotifyFd, buf, sizeof(buf)) == -1) { ERRORLOG1("write err, %s", strerror(errno)); } if (0 == *buf) { INFOLOG("recv exit notify, exit loop"); } if (ret == 1) continue; } handleFdSet(); } m_isStop = 2; }
void JackOutput::disconnect() { INFOLOG( "disconnect" ); deactivate(); jack_client_t *oldClient = client; client = NULL; if ( oldClient ) { INFOLOG( "calling jack_client_close" ); int res = jack_client_close( oldClient ); if ( res ) { ERRORLOG( "Error in jack_client_close" ); // FIXME: raise exception } } client = NULL; }
void JackAudioDriver::disconnect() { INFOLOG( "disconnect" ); deactivate(); jack_client_t *oldClient = m_pClient; m_pClient = NULL; if ( oldClient ) { INFOLOG( "calling jack_client_close" ); int res = jack_client_close( oldClient ); if ( res ) { ERRORLOG( "Error in jack_client_close" ); Hydrogen::get_instance()->raiseError( Hydrogen::JACK_CANNOT_CLOSE_CLIENT ); } } m_pClient = NULL; }
CoreMidiDriver::~CoreMidiDriver() { /*if ( isMidiDriverRunning ) { close(); } */ close(); INFOLOG( "DESTROY" ); }
void Drumkit::unload_samples( ) { INFOLOG( QString( "Unloading drumkit %1 instrument samples" ).arg( __name ) ); if( __samples_loaded ) { __instruments->unload_samples(); __samples_loaded = false; } }
void Drumkit::load_samples( ) { INFOLOG( QString( "Loading drumkit %1 instrument samples" ).arg( __name ) ); if( !__samples_loaded ) { __instruments->load_samples(); __samples_loaded = true; } }
int cRecPlayer::getBlock(unsigned char* buffer, uint64_t position, int amount) { // dont let the block be larger than 256 kb if (amount > 256*1024) amount = 256*1024; if ((uint64_t)amount > m_totalLength) amount = m_totalLength; if (position >= m_totalLength) return 0; if ((position + amount) > m_totalLength) amount = m_totalLength - position; // work out what block "position" is in int segmentNumber = -1; for(int i = 0; i < m_segments.Size(); i++) { if ((position >= m_segments[i]->start) && (position < m_segments[i]->end)) { segmentNumber = i; break; } } // segment not found / invalid position if (segmentNumber == -1) return 0; // open file (if not already open) if (!openFile(segmentNumber)) return 0; // work out position in current file uint64_t filePosition = position - m_segments[segmentNumber]->start; // seek to position if(lseek(m_file, filePosition, SEEK_SET) == -1) { ERRORLOG("unable to seek to position: %llu", filePosition); return 0; } // try to read the block int bytes_read = read(m_file, buffer, amount); INFOLOG("read %i bytes from file %i at position %llu", bytes_read, segmentNumber, filePosition); if(bytes_read <= 0) { return 0; } // Tell linux not to bother keeping the data in the FS cache posix_fadvise(m_file, filePosition, bytes_read, POSIX_FADV_DONTNEED); // divide and conquer if(bytes_read < amount) { bytes_read += getBlock(&buffer[bytes_read], position + bytes_read, amount - bytes_read); } return bytes_read; }
cVNSIServer::cVNSIServer(int listenPort) : cThread("VDR VNSI Server") { m_ServerPort = listenPort; if(*VNSIServerConfig.ConfigDirectory) { m_AllowedHostsFile = cString::sprintf("%s/" ALLOWED_HOSTS_FILE, *VNSIServerConfig.ConfigDirectory); } else { ERRORLOG("cVNSIServer: missing ConfigDirectory!"); m_AllowedHostsFile = cString::sprintf("/video/" ALLOWED_HOSTS_FILE); } m_ServerFD = socket(AF_INET, SOCK_STREAM, 0); if(m_ServerFD == -1) return; fcntl(m_ServerFD, F_SETFD, fcntl(m_ServerFD, F_GETFD) | FD_CLOEXEC); int one = 1; setsockopt(m_ServerFD, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(int)); struct sockaddr_in s; memset(&s, 0, sizeof(s)); s.sin_family = AF_INET; s.sin_port = htons(m_ServerPort); int x = bind(m_ServerFD, (struct sockaddr *)&s, sizeof(s)); if (x < 0) { close(m_ServerFD); INFOLOG("Unable to start VNSI Server, port already in use ?"); m_ServerFD = -1; return; } listen(m_ServerFD, 10); Start(); INFOLOG("VNSI Server started"); INFOLOG("Channel streaming timeout: %i seconds", VNSIServerConfig.stream_timeout); return; }
Drumkit* Drumkit::load( const QString& dk_dir, bool load_samples ) { INFOLOG( QString( "Load drumkit %1" ).arg( dk_dir ) ); if( !Filesystem::drumkit_valid( dk_dir ) ) { ERRORLOG( QString( "%1 is not valid drumkit" ).arg( dk_dir ) ); return NULL; } return load_file( Filesystem::drumkit_file( dk_dir ), load_samples ); }
cVnsiOsdProvider::cVnsiOsdProvider(cxSocket *socket) { cMutexLock lock(&m_Mutex); INFOLOG("new osd provider"); m_Socket = socket; m_RequestFull = true; if (VNSIServerConfig.pDevice) ((cDvbVnsiDevice*)VNSIServerConfig.pDevice)->ActivateDecoder(true); }