Пример #1
0
/// Attempts to seek to the given time in ms within the file.
/// Returns true if successful, false otherwise.
bool DTSC::File::seek_time(unsigned int ms) {
  currentPositions.clear();
  if (selectedTracks.size()) {
    for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++) {
      seek_time(ms, (*it), true);
    }
  }
  return true;
}
Пример #2
0
void Editor::seek_timeExact(float seconds, bool display)
{
	for(int i = 0; i == 0 || frameTime() >= seconds - 0.5; ++i)
		seek_time(seconds - 1.0 * i, false);
	
	if(seconds - frameTime() > 5.0)
	{
		QMessageBox::critical(this, tr("Error"), tr("Exact seeking failed."));
		fprintf(stderr, "WARNING: Big gap: dest is %f, frameTime is %f\n",
			seconds, frameTime());
		seek_time(seconds, true);
		return;
	}
	
	while(frameTime() < seconds - 0.002)
		seek_nextFrame(false);
	
	if(display)
		displayCurrentFrame();
}
Пример #3
0
//查询影片信息 
int seek (movie *head) {

	int choose;
	char choice;

	do {
		printf ("***************************************************************************************\n");
		printf ("********************************************************");
		printf ("\n     **    1.Seek screening time 		**\n");
 		printf ("     **    2.Seek the movie name 		**\n ");
		printf ("    **    3.Seek the director of the movie     **\n");
                printf ("     **    4.Seek the movie time 		**\n");
		printf ("     **    0.exit 				**\n");
		printf ("********************************************************\n");
		printf ("***************************************************************************************\n");
		printf ("Please choose you want to seek:");
		scanf ("%d", &choose);
		printf ("\n");

		switch (choose) {
		
			case 1: seek_screening (head);break;
			case 2: seek_name (head);     break;
			case 3: seek_director (head); break;
			case 4: seek_time (head);     break;
			case 0:                       break;
		
		}

		printf ("\nDo you want to continue?(y/n)\n:");
		getchar();
		scanf ("%c", &choice);

	} while (choice == 'y' || choice == 'Y');

	return 1;

}
Пример #4
0
void Editor::seek_slider(int value)
{
	float time = value;
	
	seek_time(time);
}
Пример #5
0
void Editor::seek_minus30Sec()
{
	seek_time(frameTime() - 30.0);
}
Пример #6
0
void Editor::seek_minus1Second()
{
	seek_time(frameTime() - 1.0);
}
Пример #7
0
void Editor::seek_plus30Sec()
{
	seek_time(frameTime() + 30.0);
}
Пример #8
0
void Editor::seek_plus1Second()
{
	seek_time(frameTime() + 1.0);
}
Пример #9
0
int main(int argc, const char *argv[])
{
    CmdArgParser parser(argc, argv);
    parser.setHeader("Archive Data Tool version " ARCH_VERSION_TXT ", "
                     EPICS_VERSION_STRING
                      ", built " __DATE__ ", " __TIME__ "\n\n"
                     );
    parser.setArgumentsInfo("<index-file>");
    CmdArgFlag help          (parser, "help", "Show help");
    CmdArgInt  verbosity     (parser, "verbose", "<level>", "Show more info");
    CmdArgFlag info          (parser, "info", "Simple archive info");
    CmdArgFlag list_index    (parser, "list", "List channel name info");
    CmdArgString copy_index  (parser, "copy", "<new index>", "Copy channels");
    CmdArgString start_time  (parser, "start", "<time>",
                              "Format: \"mm/dd/yyyy[ hh:mm:ss[.nano-secs]]\"");
    CmdArgString end_time    (parser, "end", "<time>", "(exclusive)");
    CmdArgDouble file_limit  (parser, "file_limit", "<MB>", "File Size Limit");
    CmdArgString basename    (parser, "basename", "<string>", "Basename for new data files");
    CmdArgFlag enforce_off   (parser, "append_off", "Enforce a final 'Archive_Off' value when copying data");
    CmdArgString dir2index   (parser, "dir2index", "<dir. file>",
                              "Convert old directory file to index");
    CmdArgString index2dir   (parser, "index2dir", "<dir. file>",
                              "Convert index to old directory file");
    CmdArgInt RTreeM         (parser, "M", "<1-100>", "RTree M value");
    CmdArgFlag dump_blocks   (parser, "blocks", "List channel's data blocks");
    CmdArgFlag all_blocks    (parser, "Blocks", "List all data blocks");
    CmdArgString dotindex    (parser, "dotindex", "<dot filename>",
                              "Dump contents of RTree index into dot file");
    CmdArgString channel_name(parser, "channel", "<name>", "Channel name");
    CmdArgFlag hashinfo      (parser, "hashinfo", "Show Hash table info");
    CmdArgString seek_test   (parser, "seek", "<time>", "Perform seek test");
    CmdArgFlag test          (parser, "test", "Perform some consistency tests");

    try
    {
        // Defaults
        RTreeM.set(50);
        file_limit.set(100.0);
        // Get Arguments
        if (! parser.parse())
            return -1;
        if (help   ||   parser.getArguments().size() != 1)
        {
            parser.usage();
            return -1;
        }
        // Consistency checks
        if ((dump_blocks ||
             dotindex.get().length() > 0  ||
             seek_test.get().length() > 0)
            && channel_name.get().length() <= 0)
        {
            fprintf(stderr,
                    "Options 'blocks' and 'dotindex' require 'channel'.\n");
            return -1;
        }
        verbose = verbosity;
        stdString index_name = parser.getArgument(0);
        DataWriter::file_size_limit = (unsigned long)(file_limit*1024*1024);
        if (file_limit < 10.0)
            fprintf(stderr, "file_limit values under 10.0 MB are not useful\n");
        // Start/end time
        epicsTime *start = 0, *end = 0;
        stdString txt;
        if (start_time.get().length() > 0)
        {
            start = new epicsTime;
            string2epicsTime(start_time.get(), *start);
            if (verbose > 1)
                printf("Using start time %s\n", epicsTimeTxt(*start, txt));
        }
        if (end_time.get().length() > 0)
        {
            end = new epicsTime();
            string2epicsTime(end_time.get(), *end);
            if (verbose > 1)
                printf("Using end time   %s\n", epicsTimeTxt(*end, txt));
        }
        // Base name
        if (basename.get().length() > 0)
    	    DataWriter::data_file_name_base = basename.get();
        if (enforce_off)
    	    do_enforce_off = true;
        // What's requested?
        if (info)
    	    list_names(index_name, false);
        else if (list_index)
            list_names(index_name, true);
        else if (copy_index.get().length() > 0)
        {
            copy(index_name, copy_index, RTreeM, start, end, channel_name);
            return 0;
        }
        else if (hashinfo)
            show_hash_info(index_name);
        else if (dir2index.get().length() > 0)
        {
            convert_dir_index(RTreeM, dir2index, index_name);
            return 0;
        }
        else if (index2dir.get().length() > 0)
        {
            convert_index_dir(index_name, index2dir);
            return 0;
        }
        else if (all_blocks)
        {
            dump_all_datablocks(index_name);
            return 0;
        }
        else if (dump_blocks)
        {
            dump_datablocks(index_name, channel_name);
            return 0;
        }
        else if (dotindex.get().length() > 0)
        {
            dot_index(index_name, channel_name, dotindex);
            return 0;
        }
        else if (seek_test.get().length() > 0)
        {
            seek_time(index_name, channel_name, seek_test);
            return 0;
        }
        else if (test)
        {
            return check(index_name) ? 0 : -1;
        }
        else
        {
            parser.usage();
            return -1;
        }
    }
    catch (GenericException &e)
    {
        fprintf(stderr, "Error:\n%s\n", e.what());
    }
        
    return 0;
}
Пример #10
0
/// Reads the packet available at the current file position.
/// If the packet could not be read for any reason, the reason is printed.
/// Reading the packet means the file position is increased to the next packet.
void DTSC::File::seekNext() {
  if (!currentPositions.size()) {
    DEBUG_MSG(DLVL_WARN, "No seek positions set - returning empty packet.");
    myPack.null();
    return;
  }
  seekPos thisPos = *currentPositions.begin();
  fseek(F, thisPos.bytePos, SEEK_SET);
  if (reachedEOF()) {
    myPack.null();
    return;
  }
  clearerr(F);
  currentPositions.erase(currentPositions.begin());
  lastreadpos = ftell(F);
  if (fread(buffer, 4, 1, F) != 1) {
    if (feof(F)) {
      DEBUG_MSG(DLVL_DEVEL, "End of file reached while seeking @ %i", (int)lastreadpos);
    } else {
      DEBUG_MSG(DLVL_ERROR, "Could not seek to next @ %i", (int)lastreadpos);
    }
    myPack.null();
    return;
  }
  if (memcmp(buffer, DTSC::Magic_Header, 4) == 0) {
    seek_time(myPack.getTime(), myPack.getTrackId(), true);
    return seekNext();
  }
  long long unsigned int version = 0;
  if (memcmp(buffer, DTSC::Magic_Packet, 4) == 0) {
    version = 1;
  }
  if (memcmp(buffer, DTSC::Magic_Packet2, 4) == 0) {
    version = 2;
  }
  if (version == 0) {
    DEBUG_MSG(DLVL_ERROR, "Invalid packet header @ %#x - %.4s != %.4s @ %d", (unsigned int)lastreadpos, (char *)buffer, DTSC::Magic_Packet2, (int)lastreadpos);
    myPack.null();
    return;
  }
  if (fread(buffer, 4, 1, F) != 1) {
    DEBUG_MSG(DLVL_ERROR, "Could not read packet size @ %d", (int)lastreadpos);
    myPack.null();
    return;
  }
  long packSize = ntohl(((unsigned long *)buffer)[0]);
  char * packBuffer = (char *)malloc(packSize + 8);
  if (version == 1) {
    memcpy(packBuffer, "DTPD", 4);
  } else {
    memcpy(packBuffer, "DTP2", 4);
  }
  memcpy(packBuffer + 4, buffer, 4);
  if (fread((void *)(packBuffer + 8), packSize, 1, F) != 1) {
    DEBUG_MSG(DLVL_ERROR, "Could not read packet @ %d", (int)lastreadpos);
    myPack.null();
    free(packBuffer);
    return;
  }
  myPack.reInit(packBuffer, packSize + 8);
  free(packBuffer);
  if (metadata.merged) {
    int tempLoc = getBytePos();
    char newHeader[20];
    bool insert = false;
    seekPos tmpPos;
    if (fread((void *)newHeader, 20, 1, F) == 1) {
      if (memcmp(newHeader, DTSC::Magic_Packet2, 4) == 0) {
        tmpPos.bytePos = tempLoc;
        tmpPos.trackID = ntohl(((int *)newHeader)[2]);
        tmpPos.seekTime = 0;
        if (selectedTracks.find(tmpPos.trackID) != selectedTracks.end()) {
          tmpPos.seekTime = ((long long unsigned int)ntohl(((int *)newHeader)[3])) << 32;
          tmpPos.seekTime += ntohl(((int *)newHeader)[4]);
          insert = true;
        } else {
          long tid = myPack.getTrackId();
          for (unsigned int i = 0; i != metadata.tracks[tid].keys.size(); i++) {
            if ((unsigned long long)metadata.tracks[tid].keys[i].getTime() > myPack.getTime()) {
              tmpPos.seekTime = metadata.tracks[tid].keys[i].getTime();
              tmpPos.bytePos = metadata.tracks[tid].keys[i].getBpos();
              tmpPos.trackID = tid;
              insert = true;
              break;
            }
          }
        }
        if (currentPositions.size()) {
          for (std::set<seekPos>::iterator curPosIter = currentPositions.begin(); curPosIter != currentPositions.end(); curPosIter++) {
            if ((*curPosIter).trackID == tmpPos.trackID && (*curPosIter).seekTime >= tmpPos.seekTime) {
              insert = false;
              break;
            }
          }
        }
      }
    }
    if (insert){
      if (tmpPos.seekTime > 0xffffffffffffff00ll){
        tmpPos.seekTime = 0;
      }
      currentPositions.insert(tmpPos);
    } else {
      seek_time(myPack.getTime(), myPack.getTrackId(), true);
    }
    seek_bpos(tempLoc);
  }else{
    seek_time(thisPos.seekTime, thisPos.trackID);
    fseek(F, thisPos.bytePos, SEEK_SET);
  }
}
Пример #11
0
void DTSC::File::selectTracks(std::set<unsigned long> & tracks) {
  selectedTracks = tracks;
  currentPositions.clear();
  seek_time(0);
}