当前位置: 首页>>代码示例>>C++>>正文


C++ WorkItem::run方法代码示例

本文整理汇总了C++中WorkItem::run方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkItem::run方法的具体用法?C++ WorkItem::run怎么用?C++ WorkItem::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorkItem的用法示例。


在下文中一共展示了WorkItem::run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    SimulatorState state;

    zrtp_zid_t libzrtp_zid;
    memset(&libzrtp_zid, 1, sizeof(libzrtp_zid));

    ZID libzorg_zid;
    memset(&libzorg_zid, 2, sizeof(libzorg_zid));

    uint32_t libzrtp_ssrc;
    memset(&libzrtp_ssrc, 1, sizeof(libzrtp_ssrc));

    SSRC libzorg_ssrc;
    memset(&libzorg_ssrc, 2, sizeof(libzorg_ssrc));

    // initialize libraries
    zrtp_global_t * libzrtp;
    std::auto_ptr<Instance> libzorg;

    zrtp_status_t status;
    ZORG_DECL_ERROR(e);

    zrtp_config_t libzrtp_config;
    zrtp_config_defaults(&libzrtp_config);
    libzrtp_config.lic_mode = ZRTP_LICENSE_MODE_UNLIMITED; /////////////////////
    libzrtp_config.cb.sched_cb.on_init = &libzrtp_sched_on_init;
    libzrtp_config.cb.sched_cb.on_down = &libzrtp_sched_on_down;
    libzrtp_config.cb.sched_cb.on_call_later = &libzrtp_sched_on_call_later;
    libzrtp_config.cb.sched_cb.on_cancel_call_later = &libzrtp_sched_on_cancel_call_later;
    libzrtp_config.cb.sched_cb.on_wait_call_later = &libzrtp_sched_on_wait_call_later;
    libzrtp_config.cb.misc_cb.on_send_packet = &libzrtp_misc_on_send_packet;
    status = zrtp_init(&libzrtp_config, &libzrtp);

    libzorg_CryptoSuite libzorg_crypt(e);
    std::auto_ptr<Cache> libzorg_cache(ZRTP::Impl::CreateCache(e, "./zorg_cache", &libzorg_crypt));

    SRTP::Libsrtp::Init(e);
    libzorg.reset(Instance::Create(e, &libzorg_crypt, SRTP::Libsrtp::Create(e)));

    libzorg_Interface libzorg_iface((state));

    // create sessions
    zrtp_session_t * libzrtp_session;
    std::auto_ptr<Session> libzorg_session;

    zrtp_profile_t libzrtp_profile;
    zrtp_profile_defaults(&libzrtp_profile, libzrtp);
    libzrtp_profile.autosecure = 1; ///////////////////
    status = zrtp_session_init(libzrtp, &libzrtp_profile, libzrtp_zid, 1, &libzrtp_session);
    zrtp_session_set_userdata(libzrtp_session, &state);

    Profile libzorg_profile = Profile::Default();
    libzorg_session.reset(libzorg->createSession(e, &libzorg_iface, libzorg_cache.get(), libzorg_zid, libzorg_profile));

    // create streams
    zrtp_stream_t * libzrtp_stream;
    std::auto_ptr<Stream> libzorg_stream;

    status = zrtp_stream_attach(libzrtp_session, &libzrtp_stream);
    zrtp_stream_set_userdata(libzrtp_stream, &state);

    libzrtp_IoTarget libzrtp_io_target((libzrtp_stream));
    state.setIoTargetA(&libzrtp_io_target);

    libzorg_stream.reset(libzorg_session->createStream(e, &libzorg_iface));

    libzorg_IoTarget libzorg_io_target((libzorg_stream.get()));
    state.setIoTargetB(&libzorg_io_target);

    // start streams
    status = zrtp_stream_start(libzrtp_stream, libzrtp_ssrc);
    libzorg_stream->start(e, libzorg_ssrc);

    // message loop
    for(WorkItem * item = state.dequeueTask(); item; item = state.dequeueTask())
    {
	item->run();
	delete item;
    }
}
开发者ID:DICENetworks,项目名称:zrtp-cpp,代码行数:81,代码来源:libzorg_libzrtp-interop.cpp


注:本文中的WorkItem::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。