Example #1
0
bool BinkPlayer::loadFile(const Common::String &filename) {
	_fname = filename;

	if (_demo) {
		// The demo uses a .lab suffix
		_fname += ".lab";
		return MoviePlayer::loadFile(_fname);
	}

	_fname += ".m4b";

	Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(_fname);
	if (!stream) {
		warning("BinkPlayer::loadFile(): Can't create stream for: %s", _fname.c_str());
		return false;
	}

	// set the default start of the bink video in case there is no SMUSH header
	uint32 startBinkPos = 0x0;

	// clear existing subtitles
	_subtitles.clear();

	char header[6];
	// read the first 5 bytes of the header
	stream->read(header, 5);
	header[5] = 0;

	if (!strcmp(header, "SMUSH")) {
		// handle SMUSH header
		unsigned char smushHeader[0x2000];

		// read the first part
		uint32 consumed = 16;
		stream->read(smushHeader, consumed);

		// decode the first part
		for (unsigned int i = 0; i < consumed; i++) {
			smushHeader[i] ^= 0xd2;
		}

		Common::MemoryReadStream msStart(smushHeader, consumed);
		TextSplitter tsStart("", &msStart);

		// extract the length / the start of the following BINK header
		tsStart.scanString("%d", 1, &startBinkPos);

		assert(startBinkPos < sizeof(smushHeader));

		// read the rest (5 bytes less because of the string "SMUSH" at the beginning)
		stream->read(smushHeader+consumed, startBinkPos - consumed - 5);

		// decode the reset
		for (unsigned int i = consumed; i < startBinkPos - 5; i++) {
			smushHeader[i] ^= 0xd2;
		}
		consumed = startBinkPos - 5;

		Common::MemoryReadStream msSmush(smushHeader, consumed);
		TextSplitter tsSmush("", &msSmush);

		// skip the first line which contains the length
		tsSmush.nextLine();

		tsSmush.expectString("BEGINDATA");
		while (!tsSmush.checkString("ENDOFDATA")) {
			unsigned int start, end;
			char textId[256];

			// extract single subtitle entry
			tsSmush.scanString("%d\t%d\t%s", 3, &start, &end, textId);

			Subtitle st(start, end, textId);
			_subtitles.push_back(st);
		}
		tsSmush.expectString("ENDOFDATA");
	}

	// set current subtitle index to the first subtitle
	_subtitleIndex = _subtitles.begin();

	if (!bikCheck(stream, startBinkPos)) {
		warning("BinkPlayer::loadFile(): Could not find BINK header for: %s", _fname.c_str());
		delete stream;
		return false;
	}

	Common::SeekableReadStream *bink = 0;
	bink = new Common::SeekableSubReadStream(stream, startBinkPos, stream->size(), DisposeAfterUse::YES);
	return _videoDecoder->loadStream(bink);
}
Example #2
0
Int_t  run_insert()
{

    //gDebug = 5;

    // Generate a unique RunID
    FairRunIdGenerator runID;
    UInt_t runId =  runID.generateId();

    // Create the Runtime Database ( parameter manager class )
    FairRuntimeDb* db = FairRuntimeDb::instance();

    // Set the SQL based IO as second input
    FairParTSQLIo* input_db = new FairParTSQLIo();
    input_db->SetVerbosity(1);

    // Set Global SeqNo ( Replication Global Index Base )
    //inp2->SetGlobalSeqNoIn();

    // Shutdown Mode ( True, False )
    input_db->SetShutdown(kTRUE);


    // Open first input
    input_db->open();
    db->setFirstInput(input_db);

    // Set the output=input
    db->setOutput(input_db);


    // Write a Run
    R3BDBRunInfo rInfo;
    rInfo.SetRunId(11334465);
    ValTimeStamp now;
    rInfo.SetRunTime(now);

    if (!rInfo.Commit()) cout << "-E- Error Writing Run Info " << endl;

    R3BDBRunInfo rInfo2;
    rInfo2.SetRunId(11334469);
    ValTimeStamp shifted(now.GetSec()+1,0);
    rInfo2.SetRunTime(shifted);

    if (!rInfo2.Commit()) cout << "-E- Error Writing Run Info2 " << endl;


    // Read it back in
    // make a extended query to get ConfigFileText
    ValTimeStamp tsStart(1970, 1, 1, 0, 0, 0);
    ValTimeStamp   tsEnd(2038, 1,18,19,14, 7);

    FairDbExtSqlContent extContextConfig(FairDbExtSqlContent::kStarts,tsStart,tsEnd,
                                         Detector::kLand,   // any
                                         DataType::kData); // any


    string seqSelectConfig = Form("SEQNO=%d",rInfo.GetRunId());

    FairDbReader<R3BDBRunInfo>
    rsConfig("R3BDBRUNINFO",extContextConfig,FairDb::kAnyVersion,
             seqSelectConfig.c_str());

    Int_t nConfig = rsConfig.GetNumRows();
    cout << "nConfig: = " << nConfig << endl;
    const R3BDBRunInfo* rpInfo = rsConfig.GetRow(0);

    if (rpInfo) cout << " run # " << rpInfo->GetRunId() << " has time: " << rpInfo->GetRunTime().AsString("s") << endl;

    // FairRuntimeDB deletion
    if (db) delete db;
    return 0;
}