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.

59 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2012 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "examples/peerconnection/client/defaults.h"
  11. #include <stdlib.h>
  12. #ifdef WIN32
  13. #include <winsock2.h>
  14. #else
  15. #include <unistd.h>
  16. #endif
  17. #include "rtc_base/arraysize.h"
  18. const char kAudioLabel[] = "audio_label";
  19. const char kVideoLabel[] = "video_label";
  20. const char kStreamId[] = "stream_id";
  21. const uint16_t kDefaultServerPort = 8888;
  22. std::string GetEnvVarOrDefault(const char* env_var_name,
  23. const char* default_value) {
  24. std::string value;
  25. const char* env_var = getenv(env_var_name);
  26. if (env_var)
  27. value = env_var;
  28. if (value.empty())
  29. value = default_value;
  30. return value;
  31. }
  32. std::string GetPeerConnectionString() {
  33. return GetEnvVarOrDefault("WEBRTC_CONNECT", "stun:stun.l.google.com:19302");
  34. }
  35. std::string GetDefaultServerName() {
  36. return GetEnvVarOrDefault("WEBRTC_SERVER", "localhost");
  37. }
  38. std::string GetPeerName() {
  39. char computer_name[256];
  40. std::string ret(GetEnvVarOrDefault("USERNAME", "user"));
  41. ret += '@';
  42. if (gethostname(computer_name, arraysize(computer_name)) == 0) {
  43. ret += computer_name;
  44. } else {
  45. ret += "host";
  46. }
  47. return ret;
  48. }