Пример #1
0
ptree api_call(const Remote &r, const String &api, ptree request)
{
    request.put("auth.user", r.user);
    request.put("auth.token", r.token);

    HttpRequest req = httpSettings;
    req.type = HttpRequest::POST;
    req.url = r.url + "/api/" + api;
    req.data = ptree2string(request);
    auto resp = url_request(req);
    auto ret = string2ptree(resp.response);
    if (resp.http_code != 200)
    {
        auto e = ret.get<String>("error", "");
        throw std::runtime_error(e);
    }

    return string2ptree(resp.response);
}
Пример #2
0
/**
 * @brief check is onvif or not.
 *
 * @param current_client_stream
 * @param service_uri
 * @param lookupindex
 *
 * @return 
 */
int isonvif(char *current_client_stream , char *service_uri, int  *lookupindex)
{
      
       char segments[3][100];
       char post_req[80];
       char service_name[40];
       int service_index = 0;
       int ret;
       int index_post = 0;
       int stream_index = 0;
 
       if (strncmp(current_client_stream, "POST ", 5)==0)
       {
              index_post = 0;
              stream_index = 0;
              while(current_client_stream[stream_index] != '\n' &&current_client_stream[stream_index] != '\r')
              {
                     post_req[index_post++] = current_client_stream[stream_index++];
 
              }
              post_req[index_post] = '\0';
              url_request(post_req, ' ', segments);
              index_post = 1;
              service_index = 0;
              while(segments[1][index_post] != '/' && segments[1][index_post] != '\0')
              {
                     service_name[service_index++] = segments[1][index_post++];
              }
              service_name[service_index] = '\0';
              ret = lookupservices(service_name,lookupindex);
              if(ret)
              {
                  strcpy(service_uri,segments[1]);
              }
              return ret;
       }
       else
       {
              return 0;
       }
 
}