// Called from the tracker tab to display the context menu void MainWindow::showMenu(int tabIndex) { QMenu contextMenu(tr("Context menu"), this); QAction *a; // Show a different context menu for the search tab int searchIndex = ui->trackerTab->indexOf(pSearchTab); if (tabIndex == searchIndex) { QAction *searchAction = contextMenu.addAction(tr("Clear Results")); a = contextMenu.exec(QCursor::pos()); if (a == searchAction) { SqlUtilities::clearSearch(); QSettings settings("Entomologist"); settings.setValue("last-search-query", ""); pSearchTab->refreshResults(); } return; } QString trackerName = ui->trackerTab->tabText(tabIndex); Backend *b = NULL; for (int i = 0; i < mBackendList.size(); ++i) { b = mBackendList.at(i); if (trackerName == b->name()) break; } if (b == NULL) return; QString id = b->id(); QAction *editAction = contextMenu.addAction(tr("Edit")); QAction *deleteAction = contextMenu.addAction(tr("Delete")); QAction *resyncAction = contextMenu.addAction(tr("Resync")); a = contextMenu.exec(QCursor::pos()); if (a == editAction) { NewTracker t(this, true); QString tmpName = b->name(); t.setName(b->name()); t.setHost(b->url()); t.setUsername(b->username()); t.setPassword(b->password()); t.setTrackerType(b->type()); if (t.exec() == QDialog::Accepted) { bool updateName = false; if (t.data().value("name") != tmpName) updateName = true; updateTracker(id, t.data(), updateName); } } else if (a == deleteAction) { QMessageBox box; box.setText(QString("Are you sure you want to delete %1?").arg(b->name())); box.setStandardButtons(QMessageBox::Yes|QMessageBox::No); if (box.exec() == QMessageBox::Yes) { deleteTracker(id); } } else if (a == resyncAction) { mSyncPosition = mBackendList.size(); syncTracker(b); } }
// // Refill the pesBuffer // Read packet of correct PID, locate a PES start and read the whole PES packet // It cannot be bigger than 64 k in bound mode, in that case packMode=1, packLen is the leftover to read // // uint8_t dmx_demuxerTS::refill(void) { uint32_t consumed,len,pid,payload=0; uint8_t stream,substream; uint64_t count,abs,pts,dts,first; uint32_t left,cc,lenPes; _pesBufferIndex=0; _againBranch: while(1) { if(!readPacket(&pid,&left, &payload,&abs,&cc)) { printf("dmxTs: Cannot read packet (1) at %"LLX"\n",abs); return 0; } if(allPid[pid]) break; parser->forward(left); // Else skip packet } if(!payload) // Take as is... { if(pid==myPid) { // No payloadStart, read it raw _oldPesStart=_pesBufferStart; _oldPesLen=_pesBufferLen; _pesBufferStart=abs; parser->read32(left,_pesBuffer); // FIXME HACK if(TS_PacketSize==192 && left >4) { left-=4; // Remove timestamp of m2ts packet } // FIXME HACK _pesBufferLen=left; _pesPTS=ADM_NO_PTS; _pesDTS=ADM_NO_PTS; // If we are in pack mode, cut padding bits if(packMode) { if(packLen<left) { #if 1 //def 1 TS_VERBOSE printf("Dropping some bytes : %lu / %lu\n",_pesBufferLen,packLen); #endif _pesBufferLen=packLen; } #if 0 printf("at %llx, packLen=%lu minus %lu\n",_pesBufferStart,packLen,_pesBufferLen); #endif packLen-=_pesBufferLen; if(!packLen) { packMode=0; } } return 1; } // Udate info on that track updateTracker(pid,left); parser->forward(left); goto _againBranch; } // Payload present, read header #ifdef TS_VERBOSE parser->getpos(&first); printf("BF: left:%lu delta :%"LLU"\n",left,first-abs); #endif if(pid==myPid && isPsi) { if(!getInfoPSI(&consumed,&lenPes)) goto _againBranch; if(left<consumed) goto _againBranch; left-=consumed; _pesBufferStart=abs; _pesPTS=ADM_NO_PTS; _pesDTS=ADM_NO_PTS; parser->read32(left,_pesBuffer); // FIXME HACK if(TS_PacketSize==192 && left >4) { left-=4; // Remove timestamp of m2ts packet } _pesBufferLen=left; // FIXME HACK return 1; } if(!getInfoPES(&consumed,&dts,&pts,&stream,&substream,&lenPes)) { printf("dmxTs: get info failed at %"LLX"\n",abs); goto _againBranch; } #ifdef TS_VERBOSE printf("Stream :%x found at %"LLX" size :%lu\n",stream,abs,lenPes); parser->getpos(&count); printf("consumed :%lu left:%lu delta :%"LLU"\n",consumed,left,count-first); if(count-first!=consumed) printf("*** PES header length is wrong***\n"); #endif if(consumed>left) { printf("Wrong PES header at %"LLX" %lu / %lu\n",abs,consumed,left); goto _againBranch; } left-=consumed; if(myPid==pid) { if(lenPes) { packMode=1; packLen=lenPes; } else { packMode=0; } _oldPesStart=_pesBufferStart; _oldPesLen=_pesBufferLen; _pesBufferStart=abs; _pesPTS=pts; _pesDTS=dts; parser->read32(left,_pesBuffer); // FIXME HACK if(TS_PacketSize==192 && left >4) { left-=4; // Remove timestamp of m2ts packet } _pesBufferLen=left; if(packMode) { if(packLen<left) _pesBufferLen=packLen; packLen-=_pesBufferLen; if(!packLen) packMode=0; } return 1; } // update info updateTracker(pid,left); parser->forward(left); goto _againBranch; }