blob: 51732ad4848ec66fc89fd0f9dae758e9c6a4c8fe [file] [log] [blame]
Donald E Curtisa8736442015-08-05 15:48:13 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "examples/peerconnection/client/defaults.h"
Donald E Curtisa8736442015-08-05 15:48:13 -070012
13#include <stdlib.h>
14#include <string.h>
15
16#ifdef WIN32
17#include <winsock2.h>
18#else
19#include <unistd.h>
20#endif
21
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "rtc_base/arraysize.h"
Donald E Curtisa8736442015-08-05 15:48:13 -070023
24const char kAudioLabel[] = "audio_label";
25const char kVideoLabel[] = "video_label";
26const char kStreamLabel[] = "stream_label";
Peter Boström0c4e06b2015-10-07 12:23:21 +020027const uint16_t kDefaultServerPort = 8888;
Donald E Curtisa8736442015-08-05 15:48:13 -070028
29std::string GetEnvVarOrDefault(const char* env_var_name,
30 const char* default_value) {
31 std::string value;
32 const char* env_var = getenv(env_var_name);
33 if (env_var)
34 value = env_var;
35
36 if (value.empty())
37 value = default_value;
38
39 return value;
40}
41
42std::string GetPeerConnectionString() {
43 return GetEnvVarOrDefault("WEBRTC_CONNECT", "stun:stun.l.google.com:19302");
44}
45
46std::string GetDefaultServerName() {
47 return GetEnvVarOrDefault("WEBRTC_SERVER", "localhost");
48}
49
50std::string GetPeerName() {
51 char computer_name[256];
Donald E Curtisa8736442015-08-05 15:48:13 -070052 std::string ret(GetEnvVarOrDefault("USERNAME", "user"));
53 ret += '@';
jbauch70625e52015-12-09 14:18:14 -080054 if (gethostname(computer_name, arraysize(computer_name)) == 0) {
55 ret += computer_name;
56 } else {
57 ret += "host";
58 }
Donald E Curtisa8736442015-08-05 15:48:13 -070059 return ret;
60}