예제 #1
0
int main(int argi, char* argv[])
{
	if(argi>1)
		{
			for(int i=1;i<argi;i++)
			{
				string sc(argv[i]);
				cout<<"opcja: "<<sc<<endl;
				if(sc.find("-demo")!=string::npos)
				{
					demo=true;
					cout<<"demo"<<endl;
				}
				if(sc.find("-h")!=string::npos)
				{
					cout<<"Konsola LOTC help"<<endl;
					cout<<"Argumenty uruchamiania:"<<endl;
					cout<<"-h wyświetla pomoc"<<endl;
					cout<<"-demo wykonuje demonstracyjne połączenie z 127.0.0.1"<<endl<<endl;
					cout<<"Podczas pracy konsoli obsługiwane są następujące polecenia:"<<endl;
					cout<<"connect adres_IP_servera	-	sprawdzenie połączenia z serwerem"<<endl;
					//cout<<"add task nazwa_pliku_lub_polecenia	-	zlecenie zadania"<<endl;
					cout<<"exit	-	polecenie zamykania konsoli"<<endl<<endl;
					return 0;
				}
			}
		}
    ConsoleClient *consoleClient = new ConsoleClient();

    consoleClient->start();

    delete consoleClient;

    return 0;
}
예제 #2
0
static EncodedJSValue JSC_HOST_CALL consoleProtoFuncRecordEnd(ExecState* exec)
{
    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    if (!client)
        return JSValue::encode(jsUndefined());

    client->recordEnd(exec, Inspector::createScriptArguments(exec, 0));
    return JSValue::encode(jsUndefined());
}
예제 #3
0
static EncodedJSValue JSC_HOST_CALL consoleProtoFuncClear(ExecState* exec)
{
    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    if (!client)
        return JSValue::encode(jsUndefined());

    client->clear(exec);
    return JSValue::encode(jsUndefined());
}
예제 #4
0
static EncodedJSValue consoleLogWithLevel(ExecState* exec, MessageLevel level)
{
    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    if (!client)
        return JSValue::encode(jsUndefined());

    client->logWithLevel(exec, Inspector::createScriptArguments(exec, 0), level);
    return JSValue::encode(jsUndefined());
}
예제 #5
0
static EncodedJSValue JSC_HOST_CALL consoleProtoFuncAssert(ExecState* exec)
{
    VM& vm = exec->vm();
    auto scope = DECLARE_THROW_SCOPE(vm);
    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    if (!client)
        return JSValue::encode(jsUndefined());

    bool condition = exec->argument(0).toBoolean(exec);
    RETURN_IF_EXCEPTION(scope, encodedJSValue());

    if (condition)
        return JSValue::encode(jsUndefined());

    client->assertion(exec, Inspector::createScriptArguments(exec, 1));
    return JSValue::encode(jsUndefined());
}
예제 #6
0
파일: main.cpp 프로젝트: belegar/tarotclub
/**
 * @brief Entry point of the dedicated game server
 */
int main(int /*argc*/, char ** /*argv[]*/)
{
    std::string homePath = System::HomePath();
    System::Initialize(); // default home path

    TLogInfo("Using home path: " + homePath);

    // Init lobby
    Lobby lobby;
    lobby.CreateTable("Console");
    Server server(lobby);

    ConsoleClient client;

    Log::SetLogPath(System::LogPath());
    Log::RegisterListener(client);

    ServerOptions options = ServerConfig::GetDefault();
    options.localHostOnly = true;

    server.Start(options); // Blocking call. On exit, quit the executable


#ifdef USE_WINDOWS_OS
    // Set the control handler so the app will be notified upon any special
    //   termination event.
    SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ControlHandler, TRUE);

    (void) _set_invalid_parameter_handler(myInvalidParameterHandler);

#ifdef _MSC_VER
    // Disable the message box for assertions.
    _CrtSetReportMode(_CRT_ASSERT, 0);
#endif

#endif

    client.Run(options.game_tcp_port);

    server.Stop();
    client.Stop();

    return 0;
}
예제 #7
0
static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec)
{
    VM& vm = exec->vm();
    auto scope = DECLARE_THROW_SCOPE(vm);
    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    if (!client)
        return JSValue::encode(jsUndefined());

    String title;
    if (exec->argumentCount() < 1)
        title =  "default"_s;
    else {
        title = valueOrDefaultLabelString(exec, exec->argument(0));
        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    }

    client->timeEnd(exec, title);
    return JSValue::encode(jsUndefined());
}
예제 #8
0
static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTakeHeapSnapshot(ExecState* exec)
{
    VM& vm = exec->vm();
    auto scope = DECLARE_THROW_SCOPE(vm);
    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    if (!client)
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (!argsCount) {
        client->takeHeapSnapshot(exec, String());
        return JSValue::encode(jsUndefined());
    }

    const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
    RETURN_IF_EXCEPTION(scope, encodedJSValue());

    client->takeHeapSnapshot(exec, title);
    return JSValue::encode(jsUndefined());
}
예제 #9
0
int main(int argc, char* argv[]) {
  std::string hostname = "192.168.16.10";

  if(argc >= 2) {
    hostname = argv[1];
  }

  ConsoleClient client;

  if(!client.Open(hostname, "scanner client")) {
    client.Log(FAILURE,"Unable to open connection !");
    return 1;
  }

  if(!client.EnableStatusInterface(true)) {
    client.Log(FAILURE,"Unable to enable status interface !");
    return 1;
  }

  if(client.SupportChannelScan()) {
    client.Log(INFO, "channel scanning supported");
  }
  else {
    client.Log(INFO, "channel scanning *NOT* supported");
    client.Close();
    return 0;
  }

  // get setup
  ChannelScannerSetup setup;
  ChannelScannerList sat;
  ChannelScannerList countries;

  if(!client.GetChannelScannerSetup(setup, sat, countries)) {
    return 1;
  }

  client.Log(INFO, "Current scanner setup:");
  client.Log(INFO, "---------------------------------");
  client.Log(INFO, "Verbosity: %i", setup.verbosity);
  client.Log(INFO, "Logfile: %i", setup.logtype);
  client.Log(INFO, "DVB Type: %i", setup.dvbtype);
  client.Log(INFO, "DVBT Inversion: %i", setup.dvbt_inversion);
  client.Log(INFO, "DVBC Inversion: %i", setup.dvbc_inversion);
  client.Log(INFO, "DVBC Symbolrate: %i", setup.dvbc_symbolrate);
  client.Log(INFO, "DVBC QAM: %i", setup.dvbc_qam);
  client.Log(INFO, "Country ID: %i", setup.countryid);
  client.Log(INFO, "Sat ID: %i", setup.satid);
  client.Log(INFO, "Scanflags: %04x", setup.flags);
  client.Log(INFO, "ATSC Type: %i", setup.atsc_type);
  client.Log(INFO, "---------------------------------");

  client.Log(INFO, "Satellites:");
  client.Log(INFO, "---------------------------------");

  for(ChannelScannerList::iterator i = sat.begin(); i != sat.end(); i++) {
    client.Log(INFO, "%06i|%8s|%s", i->first, i->second.shortname.c_str(), i->second.fullname.c_str());
  }

  client.Log(INFO, "Countries:");
  client.Log(INFO, "---------------------------------");

  for(ChannelScannerList::iterator i = countries.begin(); i != countries.end(); i++) {
    client.Log(INFO, "%06i|%8s|%s", i->first, i->second.shortname.c_str(), i->second.fullname.c_str());
  }

  // modify setup and send back
  setup.verbosity = ChannelScannerSetup::LOGLEVEL_DEFAULT;
  setup.countryid = 14; // AUSTRIA
  setup.logtype = ChannelScannerSetup::LOGTYPE_SYSLOG;
  setup.dvbtype = ChannelScannerSetup::DVBTYPE_DVBT;
  setup.flags = ChannelScannerSetup::FLAG_TV | ChannelScannerSetup::FLAG_FTA;

  if(!client.SetChannelScannerSetup(setup)) {
    client.Log(FAILURE, "Unable to set setup parameters !");
  }

  client.StartChannelScanner();

  CondWait::SleepMs(0);

  client.Close();
  return 0;
}
예제 #10
0
int main(int argc, char* argv[]) {
  std::string hostname = "192.168.16.10";
  int channel_number = 1;

  if(argc >= 2) {
    hostname = argv[1];
  }
  if(argc >= 3) {
    channel_number = atoi(argv[2]);
  }

  ConsoleClient client;

  if(!client.Open(hostname, "Demux test client")) {
    client.Log(FAILURE,"Unable to open connection !");
    return 1;
  }

  if(!client.EnableStatusInterface(true)) {
    client.Log(FAILURE,"Unable to enable status interface !");
    return 1;
  }

  client.Log(INFO, "Fetching channels ..");
  client.GetChannelsList();
  client.Log(INFO, "Got %i channels.", client.m_channels.size());

  Channel c = client.m_channels[channel_number];

  Demux demux(&client);

  TimeMs t;
  client.Log(INFO, "Opening channel #%i (%s)", channel_number, c.Name.c_str());

  if(demux.OpenChannel(hostname, c.UID) != Demux::SC_OK) {
    client.Log(FAILURE, "Unable to open channel !");
    return 1;
  }

  ConsoleClient::Packet* p = NULL;
  int firstVideoPacket = 0;
  int firstPacket = 0;
  int switchTime = t.Elapsed();

  client.Log(INFO, "Switched to channel after %i ms", switchTime);

  for(int i = 0; i < 100; i++) {
    p = demux.Read<ConsoleClient::Packet>();

    if(p == NULL) {
      break;
    }

    if(p->data != NULL) {
      if(firstPacket == 0) {
        firstPacket = t.Elapsed();
        client.Log(INFO, "Received first packet after %i ms", firstPacket);
      }
      if(firstVideoPacket == 0 && p->index == 0) {
        firstVideoPacket = t.Elapsed();
        client.Log(INFO, "Received first video packet after %i ms", firstVideoPacket);
      }
      uint32_t header = p->data[0] << 24 | p->data[1] << 16 | p->data[2] << 8 | p->data[3];
      client.Log(INFO, "Demux (index: %i length: %i bytes) Header: %08X PTS: %lli", p->index, p->length, header, p->pts);
    }

    client.FreePacket(p);
  }

  client.Log(INFO, "Stopping ...");
  t.Set(0);

  // wait for pending notifications
  if(p == NULL) {
    CondWait::SleepMs(5000);
  }

  demux.CloseChannel();
  client.Close();

  int stopTime = t.Elapsed();

  client.Log(INFO, "");
  client.Log(INFO, "Stream summary:");
  client.Log(INFO, "Channel: %i - %s", channel_number, c.Name.c_str());
  client.Log(INFO, "Switch time: %i ms", switchTime);
  client.Log(INFO, "First packet after: %i ms", firstPacket);
  client.Log(INFO, "First video after: %i ms", firstVideoPacket);

  return 0;
}
예제 #11
0
int main(int argc, char* argv[]) {
  std::string hostname = "192.168.16.10";
  int channel_number = 1;

  if(argc >= 2) {
    hostname = argv[1];
  }
  if(argc >= 3) {
    channel_number = atoi(argv[2]);
  }

  ConsoleClient client;
  Connection xvdr(&client);

  if(!xvdr.Open(hostname, "Demux test client")) {
    client.Log(FAILURE,"Unable to open connection !");
    return 1;
  }

  client.Log(INFO, "Fetching channels ..");
  xvdr.GetChannelsList();
  client.Log(INFO, "Got %i channels.", client.m_channels.size());

  Channel c = client.m_channels[channel_number];

  Demux demux(&client, NULL);

  client.Log(INFO, "Opening channel #%i", channel_number);

  if(demux.OpenChannel(hostname, c.UID) != Demux::SC_OK) {
    client.Log(FAILURE, "Unable to open channel !");
    return 1;
  }

  int ac3index = -1;
  uint32_t bitrate = 0;
  bool bFound = false;

  client.Log(INFO, "Waiting for stream properties ...");
  while(!bFound) {
    ConsoleClient::Packet* p = demux.Read<ConsoleClient::Packet>();
    client.FreePacket(p);

    // find AC3 stream

    XVDR::StreamProperties props = demux.GetStreamProperties();
    for(XVDR::StreamProperties::iterator i = props.begin(); i!= props.end(); i++) {
      if(i->second.Type == "AC3" && i->second.BitRate != 0) {
        ac3index = i->second.Index;
        bitrate = i->second.BitRate;
        client.Log(INFO, "Bitrate: %i", bitrate);
        bFound = true;
        break;
      }
    }
  }

  if(ac3index == -1) {
    client.Log(FAILURE, "AC3 stream not found !");
    demux.CloseChannel();
    xvdr.Close();
    return 1;
  }

  client.Log(INFO, "Analyzing packets (Stream #%i) ...", ac3index);

  int64_t pts = 0;
  int64_t last_pts = 0;
  double pts_diff_ms = 0;
  double gap = 0;

  for(int i = 0; i < 500; i++) {
    ConsoleClient::Packet* p = demux.Read<ConsoleClient::Packet>();

    if(p->data == NULL || p->index != ac3index)
    {
      client.FreePacket(p);
      continue;
    }

    pts = p->pts;
    if(last_pts == 0)
    {
      client.FreePacket(p);
      last_pts = pts;
      continue;
    }

    pts_diff_ms = (double)(pts - last_pts) / 1000.0;
    double audio_duration_ms = (double)(p->length * 8 * 1000) / (double)bitrate;

    gap += pts_diff_ms;
    gap -= audio_duration_ms;

    client.Log(INFO, "PTS: %lli / Difference: %.1f ms Audio Duration: %.1f ms / Gap: %.1f ms", pts, pts_diff_ms, audio_duration_ms, gap);
    last_pts = pts;

    client.FreePacket(p);
  }

  demux.CloseChannel();

  xvdr.Close();

  return 0;
}