Esempio n. 1
0
// 获取当前音量
void APW_GetVolume                  (void * session_token, unsigned int instance_id, char * channel)
{
    APW instance = get_apw_from_session_token(session_token);
    APWInternalState state = NULL;
    contex_method_call method = NULL;

    printf("Invoke: APW_GetVolume(%u, %s);\n", instance_id, channel);

    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    state = (APWInternalState)instance->internal_state;
    if (strcmp(channel, "Master") != 0) {
        AirplayResponse_Error(session_token, 600, "Argument Value Invalid");
        return;
    }

    // 将当前音量信息发送给AirplayRender:state->Volume;
}
Esempio n. 2
0
// 设置音量
void APW_SetVolume                  (void * session_token, unsigned int instance_id, char * channel, unsigned short desired_volume)
{
    APW instance = get_apw_from_session_token(session_token);
    APWInternalState state = NULL;
    contex_method_call method = NULL;

    printf("Invoke: APW_SetVolume(%u, %s, %u);\n", instance_id, channel, desired_volume);

    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    state = (APWInternalState)instance->internal_state;
    if (strcmp(channel, "Master") != 0) {
        AirplayResponse_Error(session_token, 600, "Argument Value Invalid");
        return;
    }

    method = create_method(APW_ECS_SETVOLUME, instance, session_token);
    add_method_param(method, (methods_param)desired_volume);
    call_method_through_thread_pool(instance, method);
}
Esempio n. 3
0
void apw_unlock(APW instance)
{
    if (check_this(instance) == APW_ERROR_OK) {
        APWInternalState state = (APWInternalState)instance->internal_state;
        sem_post(&state->resource_lock);
    }
}
Esempio n. 4
0
void apw_last_change_timer_event(void * object)
{
    APWInternalState state;
    APW apw         = (APW)object;
    APW_Error ec    = check_this(apw);
    if (ec != APW_ERROR_OK) {
        return;
    }
    state           = (APWInternalState)apw->internal_state;
    if (state->last_change_mask != 0) {
        fire_last_change_event(apw);
        state->last_change_mask = 0;
    }

    ILibLifeTime_AddEx(state->apw_monitor, apw, 0, &apw_last_change_timer_event, NULL);
}
Esempio n. 5
0
APW_Error APW_StateChange_Mute(APW instance, BOOL mute)
{
    APWInternalState istate;
    APW_Error err = check_this(instance);
    if (err != APW_ERROR_OK) {
        return err;
    }

    istate = (APWInternalState)instance->internal_state;
    apw_lock(instance);
    if (istate->Mute != mute) {
        istate->Mute = mute;
    }
    apw_unlock(instance);

    return APW_ERROR_OK;
}
Esempio n. 6
0
APW_Error APW_StateChange_Volume(APW instance, unsigned char volume)
{
    APWInternalState istate;
    APW_Error err = check_this(instance);
    if (err != APW_ERROR_OK) {
        return err;
    }

    istate = (APWInternalState)instance->internal_state;
    apw_lock(instance);
    if (istate->Volume != (unsigned short)volume) {
        istate->Volume = (unsigned short)volume;
    }
    apw_unlock(instance);

    return APW_ERROR_OK;
}
Esempio n. 7
0
APW_Error APW_StateChange_RelativeTimePosition(APW instance, long position, int is_notify)
{
    APWInternalState istate;
    APW_Error err = check_this(instance);
    if (err != APW_ERROR_OK) {
        return err;
    }

    istate = (APWInternalState)instance->internal_state;
    apw_lock(instance);
    if (istate->RelativeTimePosition != position) {
        istate->RelativeTimePosition = position;
    }
    apw_unlock(instance);

    return APW_ERROR_OK;
}
Esempio n. 8
0
APW_Error APW_StateChange_CurrentMediaDuration(APW instance, long duration)
{
    APWInternalState istate;
    APW_Error err = check_this(instance);
    if (err != APW_ERROR_OK) {
        return err;
    }

    istate = (APWInternalState)instance->internal_state;
    apw_lock(instance);
    if (istate->CurrentMediaDuration != duration) {
        istate->CurrentMediaDuration = duration;
    }
    apw_unlock(instance);

    return APW_ERROR_OK;
}
Esempio n. 9
0
// 拖动
void APW_Seek                       (void * session_token, unsigned int instance_id, char * units, char * target)
{
    APW instance = get_apw_from_session_token(session_token);
    contex_method_call method = NULL;
    int h = 0, m = 0, s = 0, validargs = 0;

    printf("Invoke: APW_Seek(%u, %s, %s);\n", instance_id, units, target);
    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }
    if (strcmp((const char *)units, "TRACK_NR") == 0) {
        int target_pos = atoi(target);
        method = create_method(APW_ECS_SEEKTRACK, instance, session_token);
        add_method_param(method, (methods_param)target_pos);

        call_method_through_thread_pool(instance, method);
    } else if(strcmp(units, "ABS_TIME") == 0) {
        long target_pos = atol(target);
        method = create_method(APW_ECS_SEEKMEDIATIME, instance, session_token);
        add_method_param(method, (methods_param)target_pos);

        call_method_through_thread_pool(instance, method);
    } else if(strcmp(units, "REL_TIME") == 0) {
        long target_pos = 0;
        validargs = sscanf(target, "%d:%d:%d", &h, &m, &s);
        if ( validargs != 3 ) {
            AirplayResponse_Error(session_token, 402, "Invalid Args");
            return;
        }
        target_pos = h * 3600 + m * 60 + s;

        method = create_method(APW_ECS_SEEKTRACKTIME, instance, session_token);
        add_method_param(method, (methods_param)target_pos);

        call_method_through_thread_pool(instance, method);
    } else {
        AirplayResponse_Error(session_token, 710, "Seek Mode Not Supported");
    }
}
Esempio n. 10
0
// 停止
void APW_Stop                       (void * session_token, unsigned int instance_id)
{
    APW instance = get_apw_from_session_token(session_token);
    contex_method_call method = NULL;

    printf("Invodk: APW_Stop(%u);\n", instance_id);

    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    method = create_method(APW_ECS_STOP, instance, session_token);
    call_method_through_thread_pool(instance, method);
}
Esempio n. 11
0
APW_Error APW_StateChange_TransportPlayState(APW instance, APWPlayState state)
{
    APWInternalState istate;
    APW_Error err = check_this(instance);
    if (err != APW_ERROR_OK) {
        return err;
    }
    if( (int)state < 1 || (int)state > 63) {
        return APW_ERROR_INVALIDARGUMENT;
    }
    istate = (APWInternalState)instance->internal_state;
    apw_lock(instance);
    if (istate->transport_state != state) {
        istate->transport_state = state;
        istate->last_change_mask |= EVENT_TRANSPORTSTATE;
    }
    apw_unlock(instance);

    return APW_ERROR_OK;
}
Esempio n. 12
0
// 获取当前播放位置
void APW_GetPositionInfo            (void * session_token, unsigned int instance_id)
{
    APW instance = get_apw_from_session_token(session_token);
    APWInternalState state = NULL;
    contex_method_call method = NULL;

    printf("Invoke: APW_GetPositionInfo(%u);\n", instance_id);

    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    state = (APWInternalState)instance->internal_state;
    AirplayResponse_GetPositionInfo(session_token, state->CurrentMediaDuration, state->AbsoluteTimePosition);
}
Esempio n. 13
0
// 播放
void APW_Play                       (void * session_token, unsigned int instance_id, char * speed)
{
    APW instance = get_apw_from_session_token(session_token);
    contex_method_call method = NULL;

    printf("Invoke: APW_Play(%u, %s);\n",instance_id, speed);

    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    method = create_method(APW_ECS_PLAY, instance, session_token);
    add_method_param(method, (methods_param)speed);

    call_method_through_thread_pool(instance, method);
}
Esempio n. 14
0
void APW_GetStatus(void * session_token, float * position, float * duration, float * cache_duration, int * is_playing)
{
    APW instance = get_apw_from_session_token(session_token);
    APWInternalState state = NULL;

    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    state = (APWInternalState)instance->internal_state;
    if (position != NULL) {
        *position = (float)state->AbsoluteTimePosition;
    }
    if (duration != NULL) {
        *duration = (float)state->CurrentMediaDuration;
    }
    if (cache_duration != NULL) {
        *position = (float)state->AbsoluteTimePosition;
    }
    if (is_playing != NULL) {
        *is_playing = (state->transport_state == APW_PS_Playing) ? 1: 0;
    }
}
Esempio n. 15
0
// 设置播放串
void APW_SetAVTransportURI          (void * session_token, unsigned int instance_id, char * current_uri,char * current_uri_metadata)
{
    APW instance = get_apw_from_session_token(session_token);
    contex_method_call method = NULL;

    printf("Invoke: APW_SetAVTransportURI(%u, %s, %s);\n", instance_id, current_uri, current_uri_metadata ? current_uri_metadata: "");

    if (instance_id != ~0) {
        AirplayResponse_Error(session_token, 718, "Invalid InstanceID");
        return;
    }
    if (check_this(instance) != APW_ERROR_OK) {
        AirplayResponse_Error(session_token, 501, "Action Failed");
        return;
    }

    method = create_method(APW_ECS_SETAVTRANSPORTURI, instance, session_token);
    current_uri = (current_uri ? current_uri : "");
    add_method_param(method, (methods_param)current_uri);
    current_uri_metadata = (current_uri_metadata ? current_uri_metadata : "");
    add_method_param(method, (methods_param)current_uri_metadata);

    call_method_through_thread_pool(instance, method);
}
Esempio n. 16
0
 virtual ATTR1 struct long_struct method1 ()
 {
   return check_this (1);
 }
Esempio n. 17
0
 virtual ATTR3 struct long_struct method3 ()
 {
   return check_this (3);
 }
Esempio n. 18
0
 virtual ATTR4 struct long_struct method4 ()
 {
   return check_this (4);
 }
Esempio n. 19
0
 virtual ATTR5 struct long_struct method5 ()
 {
   return check_this (5);
 }
Esempio n. 20
0
 virtual ATTR6 struct long_struct method6 ()
 {
   return check_this (6);
 }
Esempio n. 21
0
APW_Error call_method_through_thread_pool(APW instance, contex_method_call method)
{
    APWInternalState state;
    BOOL contextSwitch = FALSE;
    APW_Error err = check_this(instance);
    if (err != APW_ERROR_OK) {
        return err;
    }
    state = (APWInternalState)instance->internal_state;
    contextSwitch = TESTMASK(state->EventsOnThreadBitMask, method->method);
    switch (method->method) {
    case APW_ECS_GETAVPROTOCOLINFO:
        break;
    case APW_ECS_SETAVTRANSPORTURI:
        if (instance->Event_SetAVTransportURI != NULL && method->param_count == 2) {
            method->params[0] = (methods_param)(void *)String_Create((const char*)method->params[0]);
            method->params[1] = (methods_param)(void *)String_Create((const char*)method->params[1]);
        }
        break;
    case APW_ECS_STOP:
        break;
    case APW_ECS_PLAY:
        if (instance->Event_Play != NULL && method->param_count == 1) {
            method->params[0] = (methods_param)(void *)String_Create((const char *)method->params[0]);
        }
        break;
    case APW_ECS_PAUSE:
        break;
    case APW_ECS_SEEKTRACK:
        break;
    case APW_ECS_SEEKTRACKTIME:
        break;
    case APW_ECS_SEEKMEDIATIME:
        break;
    case APW_ECS_NEXT:
        break;
    case APW_ECS_PREVIOUS:
        break;
    case APW_ECS_SETPLAYMODE:
        break;
    case APW_ECS_SELECTPRESET:
        if (instance->Event_SelectPreset != NULL && method->param_count == 1) {
            method->params[0] = (methods_param)(void *)String_Create((const char *)method->params[0]);
        }
        break;
    case APW_ECS_SETBRIGHTNESS:
        break;
    case APW_ECS_SETCONTRAST:
        break;
    case APW_ECS_SETVOLUME:
        break;
    case APW_ECS_SETMUTE:
        break;
    default:
        return APW_ERROR_INVALIDARGUMENT;
    }

    ILibWebServer_AddRef((struct ILibWebServer_Session *)method->session);
    if (contextSwitch == TRUE) {
        ILibThreadPool_QueueUserWorkItem(instance->thread_pool, (void *)method, &callback_from_thread_pool);
    } else {
        callback_from_thread_pool(NULL, (void *)method);
    }

    return APW_ERROR_OK;
}
Esempio n. 22
0
 virtual ATTR8 struct long_struct method8 ()
 {
   return check_this (7);
 }
Esempio n. 23
0
 virtual ATTR2 struct long_struct method2 ()
 {
   return check_this (2);
 }
Esempio n. 24
0
 virtual ATTR0 struct long_struct method0 ()
 {
   return check_this (0);
 }