Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.0 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 - 1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dpsp.c
  6. * Content: sample direct play service provider, based on winsock
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 10/31/96 andyco created it. happy holloween!
  11. ***************************************************************************/
  12. #include "dpsp.h"
  13. // get the player data for pod. extract ip addr. use netmeeting to place call.
  14. HRESULT WINAPI SP_OpenVoice(LPDPSP_OPENVOICEDATA pod)
  15. {
  16. SOCKADDR_IN * pin;
  17. INT iAddrLen = sizeof(SOCKADDR_IN);
  18. HRESULT hr=DP_OK;
  19. DWORD dwSize = sizeof(SPPLAYERDATA);
  20. LPSPPLAYERDATA ppdTo;
  21. DWORD dwDataSize = sizeof(GLOBALDATA);
  22. LPGLOBALDATA pgd;
  23. // get the global data
  24. hr =pod->lpISP->lpVtbl->GetSPData(pod->lpISP,(LPVOID *)&pgd,&dwDataSize,DPGET_LOCAL);
  25. if (FAILED(hr) || (dwDataSize != sizeof(GLOBALDATA) ))
  26. {
  27. DPF_ERR("couldn't get SP data from DirectPlay - failing");
  28. return E_FAIL;
  29. }
  30. // tcp only!
  31. if (pgd->AddressFamily != AF_INET)
  32. {
  33. DPF_ERR("voice only supported for TCP / IP");
  34. ASSERT(FALSE);
  35. return E_FAIL;
  36. }
  37. // get to address
  38. hr = pod->lpISP->lpVtbl->GetSPPlayerData(pod->lpISP,pod->idTo,&ppdTo,&dwSize,DPGET_REMOTE);
  39. if (FAILED(hr))
  40. {
  41. ASSERT(FALSE);
  42. return hr;
  43. }
  44. pin = (SOCKADDR_IN *) DGRAM_PSOCKADDR(ppdTo);
  45. DPF(0,"calling hostname = %s\n",inet_ntoa(pin->sin_addr));
  46. hr = OpenVoice(inet_ntoa(pin->sin_addr));
  47. if (FAILED(hr))
  48. {
  49. DPF(0,"open voice failed - hr = 0x%08lx\n",hr);
  50. }
  51. else
  52. {
  53. gbVoiceOpen = TRUE;
  54. }
  55. return hr;
  56. } // SP_OpenVoice
  57. HRESULT WINAPI SP_CloseVoice(LPDPSP_CLOSEVOICEDATA pod)
  58. {
  59. HRESULT hr;
  60. hr = CloseVoice();
  61. if (FAILED(hr))
  62. {
  63. DPF(0,"close voice failed - hr = 0x%08lx\n",hr);
  64. }
  65. // even if it failed, give up on this call...
  66. gbVoiceOpen = FALSE;
  67. return hr;
  68. } // SP_CloseVoice