예제 #1
0
파일: clients.c 프로젝트: 01org/winthorpe
int clients_start(context_t *ctx)
{
    srs_plugin_t *pl;
    srs_context_t *srs;
    clients_t *clients;
    srs_client_ops_t callbacks;

    if (!ctx || !(pl = ctx->plugin) || !(srs = pl->srs) ||
        !(clients = ctx->clients))
        return -1;

    callbacks.notify_focus = notify_focus;
    callbacks.notify_command = notify_command;

    clients->srs_client = client_create(srs, SRS_CLIENT_TYPE_BUILTIN,
                                        PLUGIN_NAME, "player",
                                        commands, ncommand,
                                        PLUGIN_NAME, &callbacks, ctx);

    mrp_htbl_foreach(clients->player.name, player_register, (void *)ctx);

    client_request_focus(clients->srs_client, SRS_VOICE_FOCUS_SHARED);

    return 0;
}
예제 #2
0
static int focus_req(mrp_dbus_t *dbus, mrp_dbus_msg_t *req, void *user_data)
{
    dbusif_t      *bus = (dbusif_t *)user_data;
    srs_context_t *srs = bus->self->srs;
    const char    *id, *errmsg;
    int            focus, err;
    srs_client_t  *c;

    err = parse_focus(req, &id, &focus, &errmsg);

    if (err == 0) {
        mrp_debug("got 0x%x focus request from %s", focus, id);

        c = client_lookup_by_id(srs, id);

        if (c != NULL) {
            if (client_request_focus(c, focus))
                reply_focus(dbus, req, 0, NULL);
            else
                reply_focus(dbus, req, 1, "focus request failed");
        }
        else
            reply_focus(dbus, req, 1, "you don't exist, go away");
    }
    else
        reply_focus(dbus, req, err, errmsg);

    return TRUE;
}
예제 #3
0
static void request_focus(client_t *c, srs_req_focus_t *req)
{
    mrp_debug("received focus request from native client #%d", c->id);

    if (client_request_focus(c->c, req->focus))
        reply_focus(c, req->reqno, SRS_STATUS_OK, "OK");
    else
        reply_focus(c, req->reqno, SRS_STATUS_FAILED, "failed");
}
예제 #4
0
static int wrtc_setup(wrtc_t *wrtc)
{
    static srs_client_ops_t ops = {
        .notify_focus   = focus_cb,
        .notify_command = command_cb
    };

    srs_context_t *srs = wrtc->srs;
    char          *cmds[] = {
        (char *)wrtc->config.play,
        (char *)wrtc->config.stop,
        (char *)wrtc->config.pause,
        (char *)wrtc->config.next,
        (char *)wrtc->config.prev
    };
    int         ncmd   = (int)MRP_ARRAY_SIZE(cmds);
    const char *name   = "wrt-media-client";
    const char *appcls = "player";
    const char *id     = "wrt-media-client";

    if (!strcmp(wrtc->config.bus, "session"))
        wrtc->gdbus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
    else if (!strcmp(wrtc->config.bus, "system"))
        wrtc->gdbus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
    else {
        int flags = G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION;
        wrtc->gdbus = g_dbus_connection_new_for_address_sync(wrtc->config.bus,
                                                             flags,
                                                             NULL, NULL, NULL);
    }

    if (wrtc->gdbus == NULL)
        return FALSE;

    wrtc->gnrq = g_bus_own_name(G_BUS_TYPE_SESSION, "org.tizen.srs", 0,
                                NULL, name_acquired_cb, name_lost_cb,
                                wrtc, NULL);

    wrtc->c = client_create(srs, SRS_CLIENT_TYPE_BUILTIN,
                            name, appcls, cmds, ncmd, id, &ops, wrtc);

    if (wrtc->c == NULL) {
        wrtc_cleanup(wrtc);

        return FALSE;
    }

    client_request_focus(wrtc->c, SRS_VOICE_FOCUS_SHARED);

    return TRUE;
}