Exemplo n.º 1
0
int hac_create_http_access(MediaPlayer* player, int port, HTTPAccess** access)
{
    HTTPAccess* newAccess;

    CALLOC_ORET(newAccess, HTTPAccess, 1);

    CHK_OFAIL(har_create_resources(&newAccess->resources));

    newAccess->control = ply_get_media_control(player);
    if (newAccess->control == NULL)
    {
        fprintf(stderr, "Media player has no control\n");
        goto fail;
    }

    newAccess->playerListener.data = newAccess;
    newAccess->playerListener.frame_displayed_event = hac_frame_displayed_event;
    newAccess->playerListener.frame_dropped_event = hac_frame_dropped_event;
    newAccess->playerListener.state_change_event = hac_state_change_event;
    newAccess->playerListener.end_of_source_event = hac_end_of_source_event;
    newAccess->playerListener.start_of_source_event = hac_start_of_source_event;
    newAccess->playerListener.player_closed = hac_player_closed;

    if (!ply_register_player_listener(player, &newAccess->playerListener))
    {
        fprintf(stderr, "Failed to register http access as player listener\n");
        goto fail;
    }

    CHK_OFAIL((newAccess->ctx = shttpd_init(NULL, "document_root", "/dev/null", NULL)) != NULL);
    shttpd_register_uri(newAccess->ctx, "/", &http_player_page, newAccess);
    shttpd_register_uri(newAccess->ctx, "/player.html", &http_player_page, newAccess);
    shttpd_register_uri(newAccess->ctx, "/index.html", &http_player_page, newAccess);
    shttpd_register_uri(newAccess->ctx, "/resources/*", &http_static_content, newAccess);
    shttpd_register_uri(newAccess->ctx, "/player/state.xml", &http_player_state_xml, newAccess);
    shttpd_register_uri(newAccess->ctx, "/player/state.txt", &http_player_state_txt, newAccess);
    shttpd_register_uri(newAccess->ctx, "/player/control/*", &http_player_control, newAccess);
    CHK_OFAIL(shttpd_listen(newAccess->ctx, port, 0));


    CHK_OFAIL(init_mutex(&newAccess->playerStateMutex));
    CHK_OFAIL(create_joinable_thread(&newAccess->httpThreadId, http_thread, newAccess));


    *access = newAccess;
    return 1;

fail:
    hac_free_http_access(&newAccess);
    return 0;
}
Exemplo n.º 2
0
void example_shttpd_addpages(struct shttpd_ctx *ctx)
{
  shttpd_register_uri( ctx, "/queries*", example_shttpd_callback, NULL );
}
Exemplo n.º 3
0
 void osmonweb_register(
   struct shttpd_ctx *ctx
 )
 {
   shttpd_register_uri(ctx, "/goforms/osmonweb*", (void *)osmonweb_form, NULL);
 }