Exemple #1
0
rtsp_client_t *rtsp_create_client (const char *url, int *err)
{
  rtsp_client_t *info;

#ifdef _WINDOWS
  WORD wVersionRequested;
  WSADATA wsaData;
  int ret;
 
  wVersionRequested = MAKEWORD( 2, 0 );
 
  ret = WSAStartup( wVersionRequested, &wsaData );
  if ( ret != 0 ) {
    /* Tell the user that we couldn't find a usable */
    /* WinSock DLL.*/
    *err = ret;
    return (NULL);
  }
#endif
  info = rtsp_create_client_common(url, err);
  if (info == NULL) return (NULL);
  *err = rtsp_create_socket(info);
  if (*err != 0) {
    printf("Couldn't create socket %d\n", err);
    free_rtsp_client(info);
    return (NULL);
  }
  return (info);
}
Exemple #2
0
/*
 * rtsp_setup_redirect()
 * Sets up URLs, does the connect for redirects.  Need to handle
 * 300 case (multiple choices).  Imagine that if we had that, we'd just
 * loop through the body until we found a server that we could connect
 * with.
 */
int rtsp_setup_redirect (rtsp_client_t *info)
{
  rtsp_decode_t *decode;
  int ret;
  if (info->decode_response == NULL)
    return (-1);

  info->redirect_count++;
  if (info->redirect_count > 5) 
    return (-1);

  decode = info->decode_response;
  if (decode->location == NULL)
    return (-1);
  
  if (info->orig_url == NULL) {
    info->orig_url = info->url;
    info->url = NULL;
  } else {
    CHECK_AND_FREE(info->url);
  }

  CHECK_AND_FREE(info->server_name);
  rtsp_close_socket(info);

  ret = rtsp_dissect_url(info, decode->location);
  if (ret != 0) return (ret);
  
  return (rtsp_create_socket(info));

}