Esempio n. 1
0
function service_proxy_unavailable_cb($proxy, $arg)
{
    $info = gupnp_service_info_get($proxy);
    $type = $info['service_type'];
    $location = $info['location'];
    printf("Service unavailable:\n");
    printf("\ttype:     %s\n", $type);
    printf("\tlocation: %s\n", $location);
}
Esempio n. 2
0
function gupnp_service_proxy_available_cb($proxy, $arg)
{
    /* Get service info */
    $info = gupnp_service_info_get($proxy);
    if ($info['udn'] == $arg['udn']) {
        printf("Service is available\n");
        foreach ($info as $key => $value) {
            printf("\t%-30s: %s\n", $key, $value);
        }
        printf("\n");
        gupnp_service_proxy_action_browse($proxy);
        gupnp_control_point_browse_stop($arg['cp_service']);
    }
}
Esempio n. 3
0
function tvcontrol_service_proxy_available_cb($proxy, $arg)
{
    printf("Service is available\n");
    /* Get service info */
    $info = gupnp_service_info_get($proxy);
    foreach ($info as $key => $value) {
        printf("\t%-30s: %s\n", $key, $value);
    }
    printf("\n");
    $introspection = gupnp_service_info_get_introspection($proxy);
    show_state_variable($introspection, 'Power');
    show_state_variable($introspection, 'Channel');
    show_state_variable($introspection, 'Volume');
    /* Set callback for async introspection */
    gupnp_service_info_get_introspection($proxy, "tvcontrol_introspection_cb", NULL);
    /* Subscibe to service proxy */
    gupnp_service_proxy_callback_set($proxy, GUPNP_SIGNAL_SUBSCRIPTION_LOST, "tvcontrol_subscription_lost_cb", NULL);
    $subscribed = gupnp_service_proxy_get_subscribed($proxy);
    printf("Check subscribed:\n");
    printf("\tstatus: %s\n", $subscribed ? 'true' : 'false');
    if (!$subscribed) {
        printf("Set subscribed\n");
        gupnp_service_proxy_set_subscribed($proxy, true);
    }
    /* Add notify if channel will be changed */
    if (!gupnp_service_proxy_add_notify($proxy, "Channel", GUPNP_TYPE_INT, "tvcontrol_channel_changed_cb", NULL)) {
        printf("Failed to add notify\n");
    }
    printf("\n");
    if (isset($arg['args']['power'])) {
        tvcontrol_set_power($proxy, $arg['args']['power']);
    }
    if (isset($arg['args']['channel'])) {
        tvcontrol_set_channel($proxy, $arg['args']['channel']);
    }
}
Esempio n. 4
0
function tv_service_cb($proxy, $arg)
{
    echo "[CALLED] tv_service_cb()\n";
    global $proxy1;
    $proxy1 = $proxy;
    var_dump($proxy);
    var_dump($arg);
    //unset($proxy);
    unset($arg);
    //var_dump($proxy);
    var_dump($arg);
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_info_get({$proxy}) \n";
    echo "---------------------------------------------------------\n";
    $info = gupnp_service_info_get($proxy);
    echo "[RESULT]: ";
    var_dump($info);
    echo "---------------------------------------------------------\n\n";
    $value = rand(1, 100);
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_action_set({$proxy}, 'SetChannel', 'Channel', {$value}, GUPNP_TYPE_LONG) \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_proxy_action_set($proxy, 'SetChannel', 'Channel', $value, GUPNP_TYPE_LONG);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_action_get({$proxy}, 'SetChannel', 'Channel', GUPNP_TYPE_LONG) \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_proxy_action_get($proxy, 'SetChannel', 'Channel', GUPNP_TYPE_LONG);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_add_notify({$proxy}, 'Channel', GUPNP_TYPE_LONG, {$cb}, {$arg}) \n";
    echo "---------------------------------------------------------\n";
    $cb = "notify_cb";
    $arg = "notify data, channel";
    $res = gupnp_service_proxy_add_notify($proxy, 'Channel', GUPNP_TYPE_LONG, $cb, $arg);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_add_notify({$proxy}, 'Power', GUPNP_TYPE_BOOLEAN, {$cb}, {$arg}) \n";
    echo "---------------------------------------------------------\n";
    $cb = "notify_cb";
    $arg = "notify data, power";
    $res = gupnp_service_proxy_add_notify($proxy, 'Power', GUPNP_TYPE_BOOLEAN, $cb, $arg);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_get_subscribed() \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_proxy_get_subscribed($proxy);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_set_subscribed({$proxy}, true) \n";
    echo "---------------------------------------------------------\n";
    gupnp_service_proxy_set_subscribed($proxy, true);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_proxy_get_subscribed({$proxy}) \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_proxy_get_subscribed($proxy);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
}