blob: ee3a9e1f0a9eb0089004bc5321382caeb3c27463 [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>
Donald E Curtisa8736442015-08-05 15:48:13 -070014
15#ifdef WIN32
16#include <winsock2.h>
17#else
18#include <unistd.h>
19#endif
20
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "rtc_base/arraysize.h"
Donald E Curtisa8736442015-08-05 15:48:13 -070022
23const char kAudioLabel[] = "audio_label";
24const char kVideoLabel[] = "video_label";
Seth Hampson513449e2018-03-06 09:35:56 -080025const char kStreamId[] = "stream_id";
Peter Boström0c4e06b2015-10-07 12:23:21 +020026const uint16_t kDefaultServerPort = 8888;
Donald E Curtisa8736442015-08-05 15:48:13 -070027
28std::string GetEnvVarOrDefault(const char* env_var_name,
29 const char* default_value) {
30 std::string value;
31 const char* env_var = getenv(env_var_name);
32 if (env_var)
33 value = env_var;
34
35 if (value.empty())
36 value = default_value;
37
38 return value;
39}
40
41std::string GetPeerConnectionString() {
42 return GetEnvVarOrDefault("WEBRTC_CONNECT", "stun:stun.l.google.com:19302");
43}
44
45std::string GetDefaultServerName() {
46 return GetEnvVarOrDefault("WEBRTC_SERVER", "localhost");
47}
48
49std::string GetPeerName() {
50 char computer_name[256];
Donald E Curtisa8736442015-08-05 15:48:13 -070051 std::string ret(GetEnvVarOrDefault("USERNAME", "user"));
52 ret += '@';
jbauch70625e52015-12-09 14:18:14 -080053 if (gethostname(computer_name, arraysize(computer_name)) == 0) {
54 ret += computer_name;
55 } else {
56 ret += "host";
57 }
Donald E Curtisa8736442015-08-05 15:48:13 -070058 return ret;
59}