Esempio n. 1
0
/**************************************************************************//**
 * Get the content length header from the response headers as an unsigned
 * 64-bit integer.
 * If the content length header is not found or badly formatted, zero is
 * returned.
 *
 * @param header_list   The response headers.
 * @return  The content length.
 */
static uint64_t io_http_get_content_length(VC_CONTAINERS_LIST_T *header_list)
{
   uint64_t content_length = 0;
   HTTP_HEADER_T header;

   header.name = CONTENT_LENGTH_NAME;
   if (header_list && vc_containers_list_find_entry(header_list, &header))
      /* coverity[secure_coding] String is null-terminated */
      sscanf(header.value, "%"PRIu64, &content_length);

   return content_length;
}
Esempio n. 2
0
/**************************************************************************//**
 * Decode a dynamic payload type from parameters.
 * Populates the track information with data for supported dynamic media types.
 *
 * @param p_ctx      The reader context.
 * @param track      The track to be updated.
 * @param param_list The URI parameter list.
 * @return  The resulting status of the function.
 */
static VC_CONTAINER_STATUS_T decode_dynamic_type(VC_CONTAINER_T *p_ctx,
      VC_CONTAINER_TRACK_T *track,
      const VC_CONTAINERS_LIST_T *param_list)
{
   VC_CONTAINER_ES_FORMAT_T *format = track->format;
   VC_CONTAINER_STATUS_T status = VC_CONTAINER_SUCCESS;
   PARAMETER_T mime_type;
   MIME_TYPE_DATA_T mime_details;

   /* Get MIME type parameter */
   mime_type.name = MIME_TYPE_NAME;
   if (!vc_containers_list_find_entry(param_list, &mime_type))
      return VC_CONTAINER_ERROR_FORMAT_INVALID;

#ifdef RTP_DEBUG
   vc_containers_list_validate(&dynamic_mime);
#endif

   /* Look up MIME type to see if it can be handled */
   mime_details.name = mime_type.value;
   if (!vc_containers_list_find_entry(&dynamic_mime, &mime_details))
      return VC_CONTAINER_ERROR_FORMAT_NOT_SUPPORTED;

   format->codec = mime_details.codec;
   format->es_type = mime_details.es_type;

   /* Default number of channels for audio is one */
   if (mime_details.es_type == VC_CONTAINER_ES_TYPE_AUDIO)
      format->type->audio.channels = 1;

   /* Lete MIME type specific parameter handler deal with any other parameters */
   status = mime_details.param_handler(p_ctx, track, param_list);

   /* Ensure that the sample rate has been set for audio formats */
   if (mime_details.es_type == VC_CONTAINER_ES_TYPE_AUDIO && !format->type->audio.sample_rate)
      return VC_CONTAINER_ERROR_FORMAT_INVALID;

   return status;
}
Esempio n. 3
0
/**************************************************************************//**
 * Check whether the server supports persistent connections.
 *
 * @param header_list   The response headers.
 * @return  The resulting status of the function.
 */
static bool io_http_check_persistent_connection(VC_CONTAINERS_LIST_T *header_list)
{
   HTTP_HEADER_T header;

   header.name = CONNECTION_NAME;
   if (header_list && vc_containers_list_find_entry(header_list, &header))
   {
      /* coverity[secure_coding] String is null-terminated */
      if (!strcasecmp(header.value, "close"))
         return false;
   }

   return true;
}
Esempio n. 4
0
/**************************************************************************//**
 * Get the accept ranges header from the response headers and verify that
 * the server accepts byte ranges..
 * If the accept ranges header is not found false is returned.
 *
 * @param header_list   The response headers.
 * @return  The resulting status of the function.
 */
static bool io_http_check_accept_range(VC_CONTAINERS_LIST_T *header_list)
{
   HTTP_HEADER_T header;

   header.name = ACCEPT_RANGES_NAME;
   if (header_list && vc_containers_list_find_entry(header_list, &header))
   {
      /* coverity[secure_coding] String is null-terminated */
      if (!strcasecmp(header.value, "bytes"))
         return true;
   }

   return false;
}
Esempio n. 5
0
/**************************************************************************//**
 * Gets the value of a parameter as an unsigned 32-bit hexadecimal integer.
 *
 * @param param_list The URI parameter list.
 * @param name       The name of the parameter.
 * @param value      Pointer to the variable to receive the value.
 * @return  True if the parameter value was read and stored correctly, false
 *          otherwise.
 */
bool rtp_get_parameter_x32(const VC_CONTAINERS_LIST_T *param_list,
      const char *name,
      uint32_t *value)
{
   PARAMETER_T param;

   param.name = name;
   if (vc_containers_list_find_entry(param_list, &param) && param.value)
   {
      char *end;

      *value = strtoul(param.value, &end, 16);
      return (end != param.value) && (*end == '\0');
   }

   return false;
}