void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], Net::InitialisationParams* aInitParams)
{
    static const Brn kLocalhost("127.0.0.1");

    Net::Library* lib = new Net::Library(aInitParams);
    std::vector<Brn> args = OptionParser::ConvertArgs(aArgc, aArgv);

    Log::Print(
        "\n======================================================\n"
        "Overriding server name to '127.0.0.1'\n"
        "Temp hack to avoid DNS issues with OSX and Windows\n"
        "This won't be applied to Tests when run on Core platform"
        "\n======================================================\n\n"
        );
    // Note, getaddrinfo() in Windows OS port requires "127.0.0.1" be passed.
    // "localhost" is resolved to 0.0.0.0
    if(std::find(args.begin(), args.end(), Brn("-s")) != args.end() )  // only if found (ie already specified)
    {
        args.emplace_back("-s");
        args.emplace_back(kLocalhost);
    }
    TestTopology3(lib->Env(), args);
    delete lib;
}
Exemple #2
0
int main(int aArgc, char* aArgv[])
{
    OptionParser parser;

    OptionString optionRenderer("-r", "--renderer", Brn("dummy"), "Renderer module name.");
    parser.AddOption(&optionRenderer);

    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    Net::InitialisationParams* initParams = Net::InitialisationParams::Create();

    Net::Library* lib = new Net::Library(initParams);

    Net::DvStack* dvStack = lib->StartDv();

    Brhz udn("device1");

    Net::DvDeviceStandard* device = new Net::DvDeviceStandard(*dvStack, udn);

    SourceIndexHandler* sourceIndexHandler = new SourceIndexHandler();
    StandbyHandler* standbyHandler = new StandbyHandler();

    IRenderer* renderer = NULL;
    if (0 == strcmp((const char*)optionRenderer.Value().Ptr(), "dummy"))
    {
      renderer = new Dummy(lib->Env());
    }
#ifdef HAVE_VLC_VLC_H
    else
    {
      renderer = new Vlc(lib->Env());
    }
#endif

    std::vector<OpenHome::NetworkAdapter*>* subnetList = lib->CreateSubnetList();
    TIpAddress adapter = (*subnetList)[0]->Address();
    OpenHome::Net::Library::DestroySubnetList(subnetList);

    char url[1024];
    char attributes[1024];

    sprintf(url, "%d.%d.%d.%d", adapter&0xff, (adapter>>8)&0xff, (adapter>>16)&0xff, (adapter>>24)&0xff);
    Config::GetInstance().GetAbout().SetUrl(url);
    sprintf(url, "http://%s:%s/", url, kHttpPort);
    sprintf(attributes, "Info Time App:Config=%s Volume", url);
    Config::GetInstance().GetAbout().SetVersion(VERSION);

    unsigned long long size;
    const char* res = getResource("/renderer.js", &size);
    Config::GetInstance().RegisterController(res, size);
    Config::GetInstance().GetDataMapper().Append("/data/renderer.json", "renderer");

    Player* player = new Player(
        renderer,
        *device,
        *standbyHandler,
        *sourceIndexHandler,
        true,
        attributes,
        "OpenHome",
        "OpenHome Consortium",
        "http://openhome.org",
        "",
        "OpenHome Media Player",
        "",
        "",
        "",
        Config::GetInstance().GetString("device", "room").c_str(),
        Config::GetInstance().GetString("device", "name").c_str(),
        "",
        url,
        "");

    SourcePlaylist* sourcePlaylist = new SourcePlaylist(*device, kTracksMax, kProtocolInfo, *player);

    player->AddSource(sourcePlaylist);

    device->SetEnabled();

    char c = '\0';
    while (c != 'q') {
        if(scanf("%c", &c))
          ;
    }

    Log::Print("Quiting...\n");

    delete sourcePlaylist;
    delete device;
    delete sourceIndexHandler;
    delete standbyHandler;
    delete player;

    Log::Print("Exit complete\n");

    return (0);
}