コード例 #1
0
ファイル: http-client-test2.cpp プロジェクト: azalpy/sdk
void http_client_test2(void)
{
	aio_worker_init();

	pthread_t thread;
	bool running = true;
	thread_create(&thread, http_server_thread, &running);

	struct http_header_t headers[3];
	headers[0].name = "User-Agent";
	headers[0].value = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0";
	headers[1].name = "Accept-Language";
	headers[1].value = "en-US,en;q=0.5";
	headers[2].name = "Connection";
	headers[2].value = "keep-alive";

	// block IO
	void *http = http_client_create("127.0.0.1", PORT, 1);
	assert(0 == http_client_get(http, "/", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, NULL));
	assert(0 == http_client_get(http, "/img/bdlogo.png", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, NULL));
	assert(0 == http_client_get(http, "/", NULL, 0, http_client_test_onreply, NULL));
	http_client_destroy(http);

	// AIO
	int32_t ref = 0;
	http = http_client_create("127.0.0.1", PORT, 0);
	assert(0 == http_client_get(http, "/", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, &ref));
	while(1 != ref) system_sleep(1000);
	assert(0 == http_client_get(http, "/img/bdlogo.png", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, &ref));
	while(2 != ref) system_sleep(1000);
	assert(0 == http_client_get(http, "/", NULL, 0, http_client_test_onreply, &ref));
	while(3 != ref) system_sleep(1000);
	http_client_destroy(http);

	running = false;
	thread_destroy(thread);
	aio_worker_cleanup();
}
コード例 #2
0
void dash_dynamic_test(const char* ip, int port, const char* file, int width, int height)
{
    std::shared_ptr<dash_playlist_t> live(new dash_playlist_t());
    live->mpd = dash_mpd_create(DASH_DYNAMIC, dash_mpd_onsegment, live.get());
    live->name = "live";
    live->width = width;
    live->height = height;
    live->adapation_audio = live->adapation_video = -1;

    aio_worker_init(4);
	http_server_t* http = http_server_create(ip, port);
	http_server_set_handler(http, http_server_route, live.get());
	http_server_addroute("/live/", dash_server_onlive);
	http_server_addroute("/vod/", dash_server_onvod);

    // live worker
    dash_live_worker(file, live.get());
    
	http_server_destroy(http);
    aio_worker_clean(4);

    dash_mpd_destroy(live->mpd);
}