2015-08-05 15:48:13 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright 2012 The WebRTC Project Authors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "webrtc/examples/peerconnection/client/defaults.h"
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#include <winsock2.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-11-10 23:44:30 -08:00
|
|
|
#include "webrtc/base/arraysize.h"
|
2015-08-05 15:48:13 -07:00
|
|
|
#include "webrtc/base/common.h"
|
|
|
|
|
|
|
|
|
|
const char kAudioLabel[] = "audio_label";
|
|
|
|
|
const char kVideoLabel[] = "video_label";
|
|
|
|
|
const char kStreamLabel[] = "stream_label";
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
const uint16_t kDefaultServerPort = 8888;
|
2015-08-05 15:48:13 -07:00
|
|
|
|
|
|
|
|
std::string GetEnvVarOrDefault(const char* env_var_name,
|
|
|
|
|
const char* default_value) {
|
|
|
|
|
std::string value;
|
|
|
|
|
const char* env_var = getenv(env_var_name);
|
|
|
|
|
if (env_var)
|
|
|
|
|
value = env_var;
|
|
|
|
|
|
|
|
|
|
if (value.empty())
|
|
|
|
|
value = default_value;
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string GetPeerConnectionString() {
|
|
|
|
|
return GetEnvVarOrDefault("WEBRTC_CONNECT", "stun:stun.l.google.com:19302");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string GetDefaultServerName() {
|
|
|
|
|
return GetEnvVarOrDefault("WEBRTC_SERVER", "localhost");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string GetPeerName() {
|
|
|
|
|
char computer_name[256];
|
|
|
|
|
std::string ret(GetEnvVarOrDefault("USERNAME", "user"));
|
|
|
|
|
ret += '@';
|
2015-12-09 14:18:14 -08:00
|
|
|
if (gethostname(computer_name, arraysize(computer_name)) == 0) {
|
|
|
|
|
ret += computer_name;
|
|
|
|
|
} else {
|
|
|
|
|
ret += "host";
|
|
|
|
|
}
|
2015-08-05 15:48:13 -07:00
|
|
|
return ret;
|
|
|
|
|
}
|