xmlrpc_value* StartSendingVideo(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int partId; char *sendVideoIp; int sendVideoPort; xmlrpc_value *rtpMap; xmlrpc_parse_value(env, param_array, "(iisiS)", &confId,&partId,&sendVideoIp,&sendVideoPort,&rtpMap); //Get the rtp map VideoCodec::RTPMap map; //Get map size int j = xmlrpc_struct_size(env,rtpMap); //Parse rtp map for (int i=0;i<j;i++) { xmlrpc_value *key, *val; const char *type; int codec; //Read member xmlrpc_struct_read_member(env,rtpMap,i,&key,&val); //Read name xmlrpc_parse_value(env,key,"s",&type); //Read value xmlrpc_parse_value(env,val,"i",&codec); //Add to map map[atoi(type)] = (VideoCodec::Type) codec; //Decrement ref counter xmlrpc_DECREF(key); xmlrpc_DECREF(val); } //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->StartSendingVideo(partId,sendVideoIp,sendVideoPort,map) != NULL; //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Error\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* MediaGatewayStartSendingText(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MediaGateway *mediaGateway = (MediaGateway *)user_data; MediaBridgeSession *session = NULL; //Parseamos int sessionId; char *sendTextIp; int sendTextPort; xmlrpc_value *rtpMap; xmlrpc_parse_value(env, param_array, "(isiS)", &sessionId,&sendTextIp,&sendTextPort,&rtpMap); //Comprobamos si ha habido error if(env->fault_occurred) return 0; //Get the rtp map TextCodec::RTPMap map; //Get map size int j = xmlrpc_struct_size(env,rtpMap); //Parse rtp map for (int i=0;i<j;i++) { xmlrpc_value *key, *val; const char *type; int codec; //Read member xmlrpc_struct_read_member(env,rtpMap,i,&key,&val); //Read name xmlrpc_parse_value(env,key,"s",&type); //Read value xmlrpc_parse_value(env,val,"i",&codec); //Add to map map[atoi(type)] = (TextCodec::Type) codec; //Decrement ref counter xmlrpc_DECREF(key); xmlrpc_DECREF(val); } //Obtenemos la referencia if(!mediaGateway->GetMediaBridgeRef(sessionId,&session)) return xmlerror(env,"La sessionerencia no existe\n"); //La borramos int res = session->StartSendingText(sendTextIp,sendTextPort,map); //Liberamos la referencia mediaGateway->ReleaseMediaBridgeRef(sessionId); //Salimos if(!res) return xmlerror(env,"Error\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* StartReceivingText(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int partId; xmlrpc_value *rtpMap; xmlrpc_parse_value(env, param_array, "(iiS)", &confId,&partId,&rtpMap); //Get the rtp map TextCodec::RTPMap map; int j = xmlrpc_struct_size(env,rtpMap); //Parse rtp map for (int i=0;i<j;i++) { xmlrpc_value *key, *val; const char *type; int codec; //Read member xmlrpc_struct_read_member(env,rtpMap,i,&key,&val); //Read name xmlrpc_parse_value(env,key,"s",&type); //Read value xmlrpc_parse_value(env,val,"i",&codec); //Add to map map[atoi(type)] = (TextCodec::Type) codec; //Decrement ref counter xmlrpc_DECREF(key); xmlrpc_DECREF(val); } //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int recTextPort = conf->StartReceivingText(partId,map); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!recTextPort) return xmlerror(env,"No se ha podido terminar la conferencia\n"); //Devolvemos el resultado return xmlok(env,xmlrpc_build_value(env,"(i)",recTextPort,recTextPort)); }
//CreateConference xmlrpc_value* CreateConference(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; UTF8Parser tagParser; //Parseamos char *str; int queueId = 0; xmlrpc_parse_value(env, param_array, "(si)", &str, &queueId); //Comprobamos si ha habido error if(env->fault_occurred) { //Try with old parameters xmlrpc_parse_value(env, param_array, "(s)", &str); //Comprobamos si ha habido error if(env->fault_occurred) //Send errro xmlerror(env,"Fault occurred\n"); } //Parse string tagParser.Parse((BYTE*)str,strlen(str)); //Creamos la conferencia int confId = mcu->CreateConference(tagParser.GetWString(),queueId); //Si error if (!confId>0) return xmlerror(env,"No se puede crear la conferencia"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conferencia borrada antes de poder iniciarse\n"); //La iniciamos int res = conf->Init(); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"No se ha podido iniciar la conferencia\n"); //Devolvemos el resultado return xmlok(env,xmlrpc_build_value(env,"(i)",confId)); }
vertex_id_t ubigraph_new_vertex() { xmlrpc_env env; char* const methodName = "ubigraph.new_vertex"; xmlrpc_value * resultP; if (!xmlrpc_initialized) init_xmlrpc(0); xmlrpc_env_init(&env); /* Make the remote procedure call */ resultP = xmlrpc_client_call(&env, ubigraph_url, methodName, "()"); if (print_err_if_fault_occurred(&env)) return UBIGRAPH_FAIL; xmlrpc_int32 status; xmlrpc_parse_value(&env, resultP, "i", &status); /* Dispose of our result value. */ xmlrpc_DECREF(resultP); if (print_err_if_fault_occurred(&env)) return UBIGRAPH_FAIL; return status; }
xmlrpc_value* SetCompositionType(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int mosaicId; int comp; int size; xmlrpc_parse_value(env, param_array, "(iiii)", &confId,&mosaicId,&comp,&size); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->SetCompositionType(mosaicId,(Mosaic::Type)comp,size); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Error\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* StopSendingAudio(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int partId; xmlrpc_parse_value(env, param_array, "(ii)", &confId,&partId); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->StopSendingAudio(partId); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"No se ha podido terminar la conferencia\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* AddConferenceToken(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { UTF8Parser parser; MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; char *str; xmlrpc_parse_value(env, param_array, "(is)", &confId, &str); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Parse string parser.Parse((BYTE*)str,strlen(str)); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos bool res = conf->AddBroadcastToken(parser.GetWString()); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Could not add pin to broadcast session\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* ResetMosaicOverlay(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int mosaicId; xmlrpc_parse_value(env, param_array, "(ii)", &confId,&mosaicId); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->ResetMosaicOverlay(mosaicId); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Could reset overlay image\n"); //Devolvemos el resultado return xmlok(env,xmlrpc_build_value(env,"(i)",mosaicId)); }
static xmlrpc_value * service_remove (xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { char *service_identifier; RCWorldService *service; xmlrpc_parse_value (env, param_array, "(s)", &service_identifier); XMLRPC_FAIL_IF_FAULT (env); service = service_lookup (service_identifier); if (!service) { xmlrpc_env_set_fault_formatted (env, RCD_RPC_FAULT_INVALID_SERVICE, "Unable to unmount service for '%s'", service_identifier); goto cleanup; } rc_world_multi_remove_subworld (RC_WORLD_MULTI (rc_get_world ()), RC_WORLD (service)); rcd_services_save (); cleanup: if (env->fault_occurred) return NULL; return xmlrpc_build_value (env, "i", 0); }
static xmlrpc_value * service_add (xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { char *service_url, *mangled_url; GError *err = NULL; xmlrpc_parse_value (env, param_array, "(s)", &service_url); XMLRPC_FAIL_IF_FAULT (env); /* We always want to download data from the site */ mangled_url = g_strconcat (service_url, "?remote_only=1", NULL); if (!rc_world_multi_mount_service (RC_WORLD_MULTI (rc_get_world ()), mangled_url, &err)) { xmlrpc_env_set_fault_formatted (env, RCD_RPC_FAULT_INVALID_SERVICE, "Unable to mount service for '%s': %s", service_url, err->message); } else rcd_services_save (); g_free (mangled_url); cleanup: if (env->fault_occurred) return NULL; return xmlrpc_build_value (env, "i", 0); }
static xmlrpc_value * you_abort_download (xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { int download_id; RCDRPCMethodData *method_data; int success; xmlrpc_value *result = NULL; xmlrpc_parse_value (env, param_array, "(i)", &download_id); if (!rc_you_transaction_is_valid (download_id)) { xmlrpc_env_set_fault (env, RCD_RPC_FAULT_INVALID_TRANSACTION_ID, "Cannot find transaction for that id"); return NULL; } method_data = rcd_rpc_get_method_data (); success = rc_you_transaction_abort (download_id, method_data->identity); if (success < 0) { xmlrpc_env_set_fault (env, RCD_RPC_FAULT_PERMISSION_DENIED, "Permission denied"); return NULL; } result = xmlrpc_build_value (env, "i", success); return result; }
xmlrpc_value* MediaGatewaySetMediaBridgeOutputToken(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { UTF8Parser parser; MediaGateway *mediaGateway = (MediaGateway *)user_data; //Parseamos int sessionId; char *str; xmlrpc_parse_value(env, param_array, "(is)", &sessionId, &str); //Comprobamos si ha habido error if(env->fault_occurred) return 0; //Parse string parser.Parse((BYTE*)str,strlen(str)); //La borramos bool res = mediaGateway->SetMediaBridgeOutputToken(sessionId,parser.GetWString()); //Salimos if(!res) return xmlerror(env,"Could not set output token to bridge session\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* MediaGatewaySendFPU(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MediaGateway *mediaGateway = (MediaGateway *)user_data; MediaBridgeSession *session = NULL; //Parseamos int sessionId; xmlrpc_parse_value(env, param_array, "(i)", &sessionId); //Comprobamos si ha habido error if(env->fault_occurred) return 0; //Obtenemos la referencia if(!mediaGateway->GetMediaBridgeRef(sessionId,&session)) return xmlerror(env,"La sessionerencia no existe\n"); //La borramos int res = session->SendFPU(); //Liberamos la referencia mediaGateway->ReleaseMediaBridgeRef(sessionId); //Salimos if(!res) return xmlerror(env,"Error\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value *tcos_lockscreen(xmlrpc_env *env, xmlrpc_value *in, void *ud) #endif { char *user; char *pass; char *login_ok; /* Parse app string */ xmlrpc_parse_value(env, in, "(ss)", &user, &pass); if (env->fault_occurred) return xmlrpc_build_value(env, "s", "params error"); /* need login first */ login_ok=validate_login(user,pass); if( strcmp(login_ok, LOGIN_OK ) != 0 ) return xmlrpc_build_value(env, "s", login_ok ); if ( strcmp(TCOS_PATH, "/sbin" ) ) job_exe(TCOS_PATH"/lockscreen"); else job_exe("lockscreen"); return xmlrpc_build_value(env, "s", "OK" ); }
xmlrpc_value* StopRecordingParticipant(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int playerId; xmlrpc_parse_value(env, param_array, "(ii)", &confId,&playerId); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->StopRecordingParticipant(playerId); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Could not stop play back in conference\n"); //Devolvemos el resultado return xmlok(env); }
xmlrpc_value* SetMute(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int partId; int media; int isMuted; xmlrpc_parse_value(env, param_array, "(iiii)", &confId, &partId, &media, &isMuted); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->SetMute(partId,(MediaFrame::Type)media,isMuted); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Could not start playback\n"); //Devolvemos el resultado return xmlok(env); }
static xmlrpc_value * users_remove (xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { char *username; gboolean rv = FALSE; xmlrpc_value *value = NULL; xmlrpc_parse_value (env, param_array, "(s)", &username); XMLRPC_FAIL_IF_FAULT (env); if (username && *username) { RCDIdentity *identity; identity = rcd_identity_lookup (username); if (identity != NULL) { rv = rcd_identity_remove (identity); rcd_identity_free (identity); } } value = xmlrpc_build_value (env, "i", rv ? 1 : 0); cleanup: return value; }
xmlrpc_value* DeleteSpy(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int spyId; xmlrpc_parse_value(env, param_array, "(ii)", &confId,&spyId); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int res = conf->DeleteSpy(spyId); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Delete spy error\n"); //Devolvemos el resultado return xmlok(env); }
static int xmlrpc_parse_struct(htsmsg_t *dst, htsmsg_t *params, char *errbuf, size_t errlen) { htsmsg_field_t *f, *g; htsmsg_t *c, *c2; const char *name; HTSMSG_FOREACH(f, params) { if(strcmp(f->hmf_name, "member") || (c = htsmsg_get_map_by_field(f)) == NULL) continue; if((name = htsmsg_get_str(c, "name")) == NULL) continue; if((c2 = htsmsg_get_map(c, "value")) == NULL) continue; g = TAILQ_FIRST(&c2->hm_fields); if(g == NULL) continue; if(xmlrpc_parse_value(dst, g, name, errbuf, errlen)) return -1; } return 0; }
xmlrpc_value* StartBroadcaster(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; xmlrpc_parse_value(env, param_array, "(i)", &confId); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //La borramos int port = conf->StartBroadcaster(); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!port) return xmlerror(env,"No se ha podido crear el watcher FLV\n"); //Devolvemos el resultado return xmlok(env,xmlrpc_build_value(env,"(i)",port)); }
static int xmlrpc_parse_array(htsmsg_t *dst, htsmsg_t *m, char *errbuf, size_t errlen) { htsmsg_t *c; htsmsg_field_t *f, *g; if((m = htsmsg_get_map(m, "data")) == NULL) { return 0; // Empty array } HTSMSG_FOREACH(f, m) { if(strcmp(f->hmf_name, "value") || (c = htsmsg_get_map_by_field(f)) == NULL) continue; g = TAILQ_FIRST(&c->hm_fields); if(g == NULL || g->hmf_type != HMF_MAP) continue; if(xmlrpc_parse_value(dst, g, NULL, errbuf, errlen)) { return -1; } } return 0; }
static htsmsg_t * xmlrpc_convert_response(htsmsg_t *xml, char *errbuf, size_t errlen) { htsmsg_t *dst, *params; htsmsg_field_t *f, *g; htsmsg_t *c; if((params = htsmsg_get_map_multi(xml, "methodResponse", "params", NULL)) == NULL) { snprintf(errbuf, errlen, "No params in reply found"); return NULL; } dst = htsmsg_create_list(); HTSMSG_FOREACH(f, params) { if(strcmp(f->hmf_name, "param") || (c = htsmsg_get_map_by_field(f)) == NULL) continue; if((c = htsmsg_get_map(c, "value")) == NULL) continue; g = TAILQ_FIRST(&c->hm_fields); if(g == NULL || g->hmf_type != HMF_MAP) continue; if(xmlrpc_parse_value(dst, g, NULL, errbuf, errlen)) { htsmsg_release(dst); return NULL; } } return dst; }
xmlrpc_value* RemoveMosaicParticipant(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { MCU *mcu = (MCU *)user_data; MultiConf *conf = NULL; //Parseamos int confId; int mosaicId; int partId; xmlrpc_parse_value(env, param_array, "(iii)", &confId,&mosaicId,&partId); //Comprobamos si ha habido error if(env->fault_occurred) xmlerror(env,"Fault occurred\n"); //Obtenemos la referencia if(!mcu->GetConferenceRef(confId,&conf)) return xmlerror(env,"Conference does not exist"); //Set slot int res = conf->RemoveMosaicParticipant(mosaicId,partId); //Liberamos la referencia mcu->ReleaseConferenceRef(confId); //Salimos if(!res) return xmlerror(env,"Error\n"); //Devolvemos el resultado return xmlok(env); }
bool ArchiveDataClient::getNames(int key, const stdString &pattern, stdVector<NameInfo> &names) { xmlrpc_value *result, *element; const char *name; xmlrpc_int32 start_sec, start_nano, end_sec, end_nano; size_t count, i, len; NameInfo info; result = xmlrpc_client_call(&env, (char *)URL, "archiver.names", "(is)", (xmlrpc_int32) key, pattern.c_str()); if (log_fault()) return false; count = xmlrpc_array_size(&env, result); names.reserve(count); for (i=0; i<count; ++i) { element = xmlrpc_array_get_item(&env, result, i); if (log_fault()) return false; xmlrpc_parse_value(&env, element, "{s:s#,s:i,s:i,s:i,s:i,*}", "name", &name, &len, "start_sec", &start_sec, "start_nano", &start_nano, "end_sec", &end_sec, "end_nano", &end_nano); if (log_fault()) return false; info.name.assign(name, len); pieces2epicsTime(start_sec, start_nano, info.start); pieces2epicsTime(end_sec, end_nano, info.end); names.push_back(info); } xmlrpc_DECREF(result); return true; }
result_t ubigraph_set_edge_attribute(edge_id_t s, const char* attribute, const char* value) { xmlrpc_env env; char* const methodName = "ubigraph.set_edge_attribute"; xmlrpc_value * resultP; if (!xmlrpc_initialized) init_xmlrpc(0); xmlrpc_env_init(&env); /* Make the remote procedure call */ resultP = xmlrpc_client_call(&env, ubigraph_url, methodName, "(iss)", (xmlrpc_int32)s, attribute, value); if (print_err_if_fault_occurred(&env)) { return UBIGRAPH_FAIL; } xmlrpc_int32 status; xmlrpc_parse_value(&env, resultP, "i", &status); /* Dispose of our result value. */ xmlrpc_DECREF(resultP); if (print_err_if_fault_occurred(&env)) return UBIGRAPH_FAIL; return status; }
bool ArchiveDataClient::getArchives(stdVector<ArchiveInfo> &archives) { xmlrpc_value *result, *element; xmlrpc_int32 key; const char *name, *path; size_t count, i, n_len, p_len; ArchiveInfo info; result = xmlrpc_client_call(&env, (char *)URL, "archiver.archives", "()"); if (log_fault()) return false; count = xmlrpc_array_size(&env, result); archives.reserve(count); for (i=0; i<count; ++i) { element = xmlrpc_array_get_item(&env, result, i); if (log_fault()) return false; xmlrpc_parse_value(&env, element, "{s:i,s:s#,s:s#,*}", "key", &key, "name", &name, &n_len, "path", &path, &p_len); if (log_fault()) return false; info.key = key; info.name.assign(name, n_len); info.path.assign(path, p_len); archives.push_back(info); } xmlrpc_DECREF(result); return true; }
//CreateSession xmlrpc_value* FLVCreateSession(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { FLVServer *flv = (FLVServer *)user_data; FLVSession *session = NULL; //Parseamos char *str; xmlrpc_parse_value(env, param_array, "(s)", &str); //Creamos la sessionerencia int sessionId = flv->CreateSession(str); //Si error if (!sessionId>0) return xmlerror(env,"No se puede crear la sessionerencia"); //Obtenemos la referencia if(!flv->GetSessionRef(sessionId,&session)) return xmlerror(env,"Conferencia borrada antes de poder iniciarse\n"); //La iniciamos int port = session->Init(); //Liberamos la referencia flv->ReleaseSessionRef(sessionId); //Salimos if(!port) return xmlerror(env,"No se ha podido iniciar la sessionerencia\n"); //Devolvemos el resultado return xmlok(env,xmlrpc_build_value(env,"(ii)",sessionId,port)); }
xmlrpc_value* FLVStopReceivingVideo(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) { FLVServer *flv = (FLVServer *)user_data; FLVSession *session = NULL; //Parseamos int sessionId; xmlrpc_parse_value(env, param_array, "(i)", &sessionId); //Comprobamos si ha habido error if(env->fault_occurred) return 0; //Obtenemos la referencia if(!flv->GetSessionRef(sessionId,&session)) return xmlerror(env,"La sessionerencia no existe\n"); //La borramos int res = session->StopReceivingVideo(); //Liberamos la referencia flv->ReleaseSessionRef(sessionId); //Salimos if(!res) return xmlerror(env,"Error\n"); //Devolvemos el resultado return xmlok(env); }
static void test_value_parse_value(void) { xmlrpc_env env; xmlrpc_value * valueP; const char * datestring = "19980717T14:08:55"; xmlrpc_env_init(&env); valueP = xmlrpc_build_value(&env, "(idb8ss#6(i){s:i}np(i))", 7, 3.14, (xmlrpc_bool)1, datestring, "hello world", "a\0b", (size_t)3, "base64 data", strlen("base64 data"), 15, "member9", 9, &valueP, -5); TEST_NO_FAULT(&env); { xmlrpc_int32 i; xmlrpc_double d; xmlrpc_bool b; const char * dt_str; const char * s1; const char * s2; size_t s2_len; const unsigned char * b64; size_t b64_len; xmlrpc_value * arrayP; xmlrpc_value * structP; void * cptr; xmlrpc_value * subvalP; xmlrpc_parse_value(&env, valueP, "(idb8ss#6ASnpV)", &i, &d, &b, &dt_str, &s1, &s2, &s2_len, &b64, &b64_len, &arrayP, &structP, &cptr, &subvalP); TEST_NO_FAULT(&env); TEST(i == 7); TEST(d == 3.14); TEST(b == (xmlrpc_bool)1); TEST(streq(dt_str, datestring)); TEST(streq(s1, "hello world")); TEST(s2_len == 3); TEST(memeq(s2, "a\0b", 3)); TEST(b64_len == strlen("base64 data")); TEST(memeq(b64, "base64 data", b64_len)); TEST(XMLRPC_TYPE_ARRAY == xmlrpc_value_type(arrayP)); TEST(XMLRPC_TYPE_STRUCT == xmlrpc_value_type(structP)); TEST(cptr == &valueP); TEST(XMLRPC_TYPE_ARRAY == xmlrpc_value_type(subvalP)); xmlrpc_DECREF(valueP); } testFailedParseValue(); xmlrpc_env_clean(&env); }