mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 22:30:40 +01:00

This reverts commit3f87250a4f
. Reason for revert: Downstream is fixed Original change's description: > Revert "Remove RTC_DISALLOW_COPY_AND_ASSIGN usages completely" > > This reverts commit5f0eb93d2a
. > > Reason for revert: Breaks downstream project. I'm going to fix that one and create a reland of this CL after. > > Original change's description: > > Remove RTC_DISALLOW_COPY_AND_ASSIGN usages completely > > > > Bug: webrtc:13555, webrtc:13082 > > Change-Id: Iff2cda6f516739419e97e975e03f77a98f74be03 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249260 > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Artem Titov <titovartem@webrtc.org> > > Commit-Queue: (Daniel.L) Byoungchan Lee <daniel.l@hpcnt.com> > > Cr-Commit-Position: refs/heads/main@{#35805} > > TBR=hta@webrtc.org,titovartem@webrtc.org,daniel.l@hpcnt.com,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I33d497f1132adfe6d151023195a388d9b7d548f9 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:13555, webrtc:13082 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249364 > Reviewed-by: Artem Titov <titovartem@webrtc.org> > Owners-Override: Artem Titov <titovartem@webrtc.org> > Reviewed-by: Andrey Logvin <landrey@webrtc.org> > Reviewed-by: Björn Terelius <terelius@webrtc.org> > Commit-Queue: Artem Titov <titovartem@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#35807} # Not skipping CQ checks because this is a reland. Bug: webrtc:13555, webrtc:13082 Change-Id: I7ef1ef3b6e3c41b1a96014aa75f003c0fcf33949 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249365 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35814}
133 lines
4.4 KiB
C++
133 lines
4.4 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
// clang-format off
|
|
// clang formating would change include order.
|
|
#include <windows.h>
|
|
#include <shellapi.h> // must come after windows.h
|
|
// clang-format on
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "absl/flags/parse.h"
|
|
#include "examples/peerconnection/client/conductor.h"
|
|
#include "examples/peerconnection/client/flag_defs.h"
|
|
#include "examples/peerconnection/client/main_wnd.h"
|
|
#include "examples/peerconnection/client/peer_connection_client.h"
|
|
#include "rtc_base/checks.h"
|
|
#include "rtc_base/ssl_adapter.h"
|
|
#include "rtc_base/string_utils.h" // For ToUtf8
|
|
#include "rtc_base/win32_socket_init.h"
|
|
#include "system_wrappers/include/field_trial.h"
|
|
#include "test/field_trial.h"
|
|
|
|
namespace {
|
|
// A helper class to translate Windows command line arguments into UTF8,
|
|
// which then allows us to just pass them to the flags system.
|
|
// This encapsulates all the work of getting the command line and translating
|
|
// it to an array of 8-bit strings; all you have to do is create one of these,
|
|
// and then call argc() and argv().
|
|
class WindowsCommandLineArguments {
|
|
public:
|
|
WindowsCommandLineArguments();
|
|
|
|
WindowsCommandLineArguments(const WindowsCommandLineArguments&) = delete;
|
|
WindowsCommandLineArguments& operator=(WindowsCommandLineArguments&) = delete;
|
|
|
|
int argc() { return argv_.size(); }
|
|
char** argv() { return argv_.data(); }
|
|
|
|
private:
|
|
// Owned argument strings.
|
|
std::vector<std::string> args_;
|
|
// Pointers, to get layout compatible with char** argv.
|
|
std::vector<char*> argv_;
|
|
};
|
|
|
|
WindowsCommandLineArguments::WindowsCommandLineArguments() {
|
|
// start by getting the command line.
|
|
LPCWSTR command_line = ::GetCommandLineW();
|
|
// now, convert it to a list of wide char strings.
|
|
int argc;
|
|
LPWSTR* wide_argv = ::CommandLineToArgvW(command_line, &argc);
|
|
|
|
// iterate over the returned wide strings;
|
|
for (int i = 0; i < argc; ++i) {
|
|
args_.push_back(rtc::ToUtf8(wide_argv[i], wcslen(wide_argv[i])));
|
|
// make sure the argv array points to the string data.
|
|
argv_.push_back(const_cast<char*>(args_.back().c_str()));
|
|
}
|
|
LocalFree(wide_argv);
|
|
}
|
|
|
|
} // namespace
|
|
int PASCAL wWinMain(HINSTANCE instance,
|
|
HINSTANCE prev_instance,
|
|
wchar_t* cmd_line,
|
|
int cmd_show) {
|
|
rtc::WinsockInitializer winsock_init;
|
|
rtc::PhysicalSocketServer ss;
|
|
rtc::AutoSocketServerThread main_thread(&ss);
|
|
|
|
WindowsCommandLineArguments win_args;
|
|
int argc = win_args.argc();
|
|
char** argv = win_args.argv();
|
|
|
|
absl::ParseCommandLine(argc, argv);
|
|
|
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
|
// the application.
|
|
const std::string forced_field_trials =
|
|
absl::GetFlag(FLAGS_force_fieldtrials);
|
|
webrtc::field_trial::InitFieldTrialsFromString(forced_field_trials.c_str());
|
|
|
|
// Abort if the user specifies a port that is outside the allowed
|
|
// range [1, 65535].
|
|
if ((absl::GetFlag(FLAGS_port) < 1) || (absl::GetFlag(FLAGS_port) > 65535)) {
|
|
printf("Error: %i is not a valid port.\n", absl::GetFlag(FLAGS_port));
|
|
return -1;
|
|
}
|
|
|
|
const std::string server = absl::GetFlag(FLAGS_server);
|
|
MainWnd wnd(server.c_str(), absl::GetFlag(FLAGS_port),
|
|
absl::GetFlag(FLAGS_autoconnect), absl::GetFlag(FLAGS_autocall));
|
|
if (!wnd.Create()) {
|
|
RTC_DCHECK_NOTREACHED();
|
|
return -1;
|
|
}
|
|
|
|
rtc::InitializeSSL();
|
|
PeerConnectionClient client;
|
|
auto conductor = rtc::make_ref_counted<Conductor>(&client, &wnd);
|
|
|
|
// Main loop.
|
|
MSG msg;
|
|
BOOL gm;
|
|
while ((gm = ::GetMessage(&msg, NULL, 0, 0)) != 0 && gm != -1) {
|
|
if (!wnd.PreTranslateMessage(&msg)) {
|
|
::TranslateMessage(&msg);
|
|
::DispatchMessage(&msg);
|
|
}
|
|
}
|
|
|
|
if (conductor->connection_active() || client.is_connected()) {
|
|
while ((conductor->connection_active() || client.is_connected()) &&
|
|
(gm = ::GetMessage(&msg, NULL, 0, 0)) != 0 && gm != -1) {
|
|
if (!wnd.PreTranslateMessage(&msg)) {
|
|
::TranslateMessage(&msg);
|
|
::DispatchMessage(&msg);
|
|
}
|
|
}
|
|
}
|
|
|
|
rtc::CleanupSSL();
|
|
return 0;
|
|
}
|