Reformat the WebRTC code base
Running clang-format with chromium's style guide.
The goal is n-fold:
* providing consistency and readability (that's what code guidelines are for)
* preventing noise with presubmit checks and git cl format
* building on the previous point: making it easier to automatically fix format issues
* you name it
Please consider using git-hyper-blame to ignore this commit.
Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc
index b86ba55..b7f06aa 100644
--- a/examples/peerconnection/client/conductor.cc
+++ b/examples/peerconnection/client/conductor.cc
@@ -41,8 +41,7 @@
: public webrtc::SetSessionDescriptionObserver {
public:
static DummySetSessionDescriptionObserver* Create() {
- return
- new rtc::RefCountedObject<DummySetSessionDescriptionObserver>();
+ return new rtc::RefCountedObject<DummySetSessionDescriptionObserver>();
}
virtual void OnSuccess() { RTC_LOG(INFO) << __FUNCTION__; }
virtual void OnFailure(webrtc::RTCError error) {
@@ -52,10 +51,7 @@
};
Conductor::Conductor(PeerConnectionClient* client, MainWindow* main_wnd)
- : peer_id_(-1),
- loopback_(false),
- client_(client),
- main_wnd_(main_wnd) {
+ : peer_id_(-1), loopback_(false), client_(client), main_wnd_(main_wnd) {
client_->RegisterObserver(this);
main_wnd->RegisterObserver(this);
}
@@ -87,15 +83,14 @@
nullptr /* audio_processing */);
if (!peer_connection_factory_) {
- main_wnd_->MessageBox("Error",
- "Failed to initialize PeerConnectionFactory", true);
+ main_wnd_->MessageBox("Error", "Failed to initialize PeerConnectionFactory",
+ true);
DeletePeerConnection();
return false;
}
if (!CreatePeerConnection(/*dtls=*/true)) {
- main_wnd_->MessageBox("Error",
- "CreatePeerConnection failed", true);
+ main_wnd_->MessageBox("Error", "CreatePeerConnection failed", true);
DeletePeerConnection();
}
@@ -363,8 +358,8 @@
RTC_DCHECK(peer_id != -1);
if (peer_connection_.get()) {
- main_wnd_->MessageBox("Error",
- "We only support connecting to one peer at a time", true);
+ main_wnd_->MessageBox(
+ "Error", "We only support connecting to one peer at a time", true);
return;
}
diff --git a/examples/peerconnection/client/conductor.h b/examples/peerconnection/client/conductor.h
index c24bbac..a038743 100644
--- a/examples/peerconnection/client/conductor.h
+++ b/examples/peerconnection/client/conductor.h
@@ -30,11 +30,10 @@
class VideoRenderer;
} // namespace cricket
-class Conductor
- : public webrtc::PeerConnectionObserver,
- public webrtc::CreateSessionDescriptionObserver,
- public PeerConnectionClientObserver,
- public MainWndCallback {
+class Conductor : public webrtc::PeerConnectionObserver,
+ public webrtc::CreateSessionDescriptionObserver,
+ public PeerConnectionClientObserver,
+ public MainWndCallback {
public:
enum CallbackID {
MEDIA_CHANNELS_INITIALIZED = 1,
diff --git a/examples/peerconnection/client/flagdefs.h b/examples/peerconnection/client/flagdefs.h
index cc66c6f..564e0e9 100644
--- a/examples/peerconnection/client/flagdefs.h
+++ b/examples/peerconnection/client/flagdefs.h
@@ -20,13 +20,19 @@
// for each platform.
DEFINE_bool(help, false, "Prints this message");
-DEFINE_bool(autoconnect, false, "Connect to the server without user "
- "intervention.");
+DEFINE_bool(autoconnect,
+ false,
+ "Connect to the server without user "
+ "intervention.");
DEFINE_string(server, "localhost", "The server to connect to.");
-DEFINE_int(port, kDefaultServerPort,
+DEFINE_int(port,
+ kDefaultServerPort,
"The port on which the server is listening.");
-DEFINE_bool(autocall, false, "Call the first available other client on "
- "the server without user intervention. Note: this flag should only be set "
- "to true on one of the two clients.");
+DEFINE_bool(
+ autocall,
+ false,
+ "Call the first available other client on "
+ "the server without user intervention. Note: this flag should only be set "
+ "to true on one of the two clients.");
#endif // EXAMPLES_PEERCONNECTION_CLIENT_FLAGDEFS_H_
diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc
index 200d487..50179c4 100644
--- a/examples/peerconnection/client/linux/main.cc
+++ b/examples/peerconnection/client/linux/main.cc
@@ -38,15 +38,15 @@
// different thread. Alternatively we could look at merging the two loops
// by implementing a dispatcher for the socket server and/or use
// g_main_context_set_poll_func.
- while (gtk_events_pending())
- gtk_main_iteration();
+ while (gtk_events_pending())
+ gtk_main_iteration();
if (!wnd_->IsWindow() && !conductor_->connection_active() &&
client_ != NULL && !client_->is_connected()) {
message_queue_->Quit();
}
- return rtc::PhysicalSocketServer::Wait(0/*cms == -1 ? 1 : cms*/,
- process_io);
+ return rtc::PhysicalSocketServer::Wait(0 /*cms == -1 ? 1 : cms*/,
+ process_io);
}
protected:
@@ -58,15 +58,15 @@
int main(int argc, char* argv[]) {
gtk_init(&argc, &argv);
- // g_type_init API is deprecated (and does nothing) since glib 2.35.0, see:
- // https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html
+// g_type_init API is deprecated (and does nothing) since glib 2.35.0, see:
+// https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html
#if !GLIB_CHECK_VERSION(2, 35, 0)
- g_type_init();
+ g_type_init();
#endif
- // g_thread_init API is deprecated since glib 2.31.0, see release note:
- // http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html
+// g_thread_init API is deprecated since glib 2.31.0, see release note:
+// http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html
#if !GLIB_CHECK_VERSION(2, 31, 0)
- g_thread_init(NULL);
+ g_thread_init(NULL);
#endif
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
diff --git a/examples/peerconnection/client/linux/main_wnd.cc b/examples/peerconnection/client/linux/main_wnd.cc
index 9b9aed2..52b0d88 100644
--- a/examples/peerconnection/client/linux/main_wnd.cc
+++ b/examples/peerconnection/client/linux/main_wnd.cc
@@ -30,7 +30,8 @@
// GtkMainWnd instance.
//
-gboolean OnDestroyedCallback(GtkWidget* widget, GdkEvent* event,
+gboolean OnDestroyedCallback(GtkWidget* widget,
+ GdkEvent* event,
gpointer data) {
reinterpret_cast<GtkMainWnd*>(data)->OnDestroyed(widget, event);
return FALSE;
@@ -45,14 +46,17 @@
return false;
}
-gboolean OnKeyPressCallback(GtkWidget* widget, GdkEventKey* key,
+gboolean OnKeyPressCallback(GtkWidget* widget,
+ GdkEventKey* key,
gpointer data) {
reinterpret_cast<GtkMainWnd*>(data)->OnKeyPress(widget, key);
return false;
}
-void OnRowActivatedCallback(GtkTreeView* tree_view, GtkTreePath* path,
- GtkTreeViewColumn* column, gpointer data) {
+void OnRowActivatedCallback(GtkTreeView* tree_view,
+ GtkTreePath* path,
+ GtkTreeViewColumn* column,
+ gpointer data) {
reinterpret_cast<GtkMainWnd*>(data)->OnRowActivated(tree_view, path, column);
}
@@ -90,8 +94,8 @@
// Adds an entry to a tree view.
void AddToList(GtkWidget* list, const gchar* str, int value) {
- GtkListStore* store = GTK_LIST_STORE(
- gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
+ GtkListStore* store =
+ GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
@@ -131,11 +135,20 @@
// GtkMainWnd implementation.
//
-GtkMainWnd::GtkMainWnd(const char* server, int port, bool autoconnect,
+GtkMainWnd::GtkMainWnd(const char* server,
+ int port,
+ bool autoconnect,
bool autocall)
- : window_(NULL), draw_area_(NULL), vbox_(NULL), server_edit_(NULL),
- port_edit_(NULL), peer_list_(NULL), callback_(NULL),
- server_(server), autoconnect_(autoconnect), autocall_(autocall) {
+ : window_(NULL),
+ draw_area_(NULL),
+ vbox_(NULL),
+ server_edit_(NULL),
+ port_edit_(NULL),
+ peer_list_(NULL),
+ callback_(NULL),
+ server_(server),
+ autoconnect_(autoconnect),
+ autocall_(autocall) {
char buffer[10];
sprintfn(buffer, sizeof(buffer), "%i", port);
port_ = buffer;
@@ -153,12 +166,13 @@
return window_ != NULL && GTK_IS_WINDOW(window_);
}
-void GtkMainWnd::MessageBox(const char* caption, const char* text,
+void GtkMainWnd::MessageBox(const char* caption,
+ const char* text,
bool is_error) {
- GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(window_),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- is_error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, "%s", text);
+ GtkWidget* dialog = gtk_message_dialog_new(
+ GTK_WINDOW(window_), GTK_DIALOG_DESTROY_WITH_PARENT,
+ is_error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s",
+ text);
gtk_window_set_title(GTK_WINDOW(dialog), caption);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -174,7 +188,6 @@
return STREAMING;
}
-
void GtkMainWnd::StartLocalRenderer(webrtc::VideoTrackInterface* local_video) {
local_renderer_.reset(new VideoRenderer(this, local_video));
}
@@ -394,7 +407,8 @@
}
}
-void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path,
+void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view,
+ GtkTreePath* path,
GtkTreeViewColumn* column) {
RTC_DCHECK(peer_list_ != NULL);
GtkTreeIter iter;
@@ -402,12 +416,12 @@
GtkTreeSelection* selection =
gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
- char* text;
- int id = -1;
- gtk_tree_model_get(model, &iter, 0, &text, 1, &id, -1);
- if (id != -1)
- callback_->ConnectToPeer(id);
- g_free(text);
+ char* text;
+ int id = -1;
+ gtk_tree_model_get(model, &iter, 0, &text, 1, &id, -1);
+ if (id != -1)
+ callback_->ConnectToPeer(id);
+ g_free(text);
}
}
@@ -519,8 +533,7 @@
gdk_threads_leave();
}
-void GtkMainWnd::VideoRenderer::OnFrame(
- const webrtc::VideoFrame& video_frame) {
+void GtkMainWnd::VideoRenderer::OnFrame(const webrtc::VideoFrame& video_frame) {
gdk_threads_enter();
rtc::scoped_refptr<webrtc::I420BufferInterface> buffer(
@@ -536,11 +549,10 @@
// This was supposed to be a call to libyuv::I420ToRGBA but it was resulting
// in a reddish video output (see https://bugs.webrtc.org/6857) because it
// was producing an unexpected byte order (ABGR, byte swapped).
- libyuv::I420ToABGR(buffer->DataY(), buffer->StrideY(),
- buffer->DataU(), buffer->StrideU(),
- buffer->DataV(), buffer->StrideV(),
- image_.get(), width_ * 4,
- buffer->width(), buffer->height());
+ libyuv::I420ToABGR(buffer->DataY(), buffer->StrideY(), buffer->DataU(),
+ buffer->StrideU(), buffer->DataV(), buffer->StrideV(),
+ image_.get(), width_ * 4, buffer->width(),
+ buffer->height());
gdk_threads_leave();
diff --git a/examples/peerconnection/client/linux/main_wnd.h b/examples/peerconnection/client/linux/main_wnd.h
index fdeee4b..a2edb74 100644
--- a/examples/peerconnection/client/linux/main_wnd.h
+++ b/examples/peerconnection/client/linux/main_wnd.h
@@ -39,8 +39,7 @@
virtual void SwitchToConnectUI();
virtual void SwitchToPeerList(const Peers& peers);
virtual void SwitchToStreamingUI();
- virtual void MessageBox(const char* caption, const char* text,
- bool is_error);
+ virtual void MessageBox(const char* caption, const char* text, bool is_error);
virtual MainWindow::UI current_ui();
virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video);
virtual void StopLocalRenderer();
@@ -67,7 +66,8 @@
// Callback when the user double clicks a peer in order to initiate a
// connection.
- void OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path,
+ void OnRowActivated(GtkTreeView* tree_view,
+ GtkTreePath* path,
GtkTreeViewColumn* column);
void OnRedraw();
@@ -86,13 +86,9 @@
const uint8_t* image() const { return image_.get(); }
- int width() const {
- return width_;
- }
+ int width() const { return width_; }
- int height() const {
- return height_;
- }
+ int height() const { return height_; }
protected:
void SetSize(int width, int height);
@@ -104,9 +100,9 @@
};
protected:
- GtkWidget* window_; // Our main window.
+ GtkWidget* window_; // Our main window.
GtkWidget* draw_area_; // The drawing surface for rendering video streams.
- GtkWidget* vbox_; // Container for the Connect UI.
+ GtkWidget* vbox_; // Container for the Connect UI.
GtkWidget* server_edit_;
GtkWidget* port_edit_;
GtkWidget* peer_list_; // The list of peers.
diff --git a/examples/peerconnection/client/main.cc b/examples/peerconnection/client/main.cc
index bcf86f1..ee70da6 100644
--- a/examples/peerconnection/client/main.cc
+++ b/examples/peerconnection/client/main.cc
@@ -17,8 +17,10 @@
#include "rtc_base/win32socketinit.h"
#include "rtc_base/win32socketserver.h"
-int PASCAL wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
- wchar_t* cmd_line, int cmd_show) {
+int PASCAL wWinMain(HINSTANCE instance,
+ HINSTANCE prev_instance,
+ wchar_t* cmd_line,
+ int cmd_show) {
rtc::EnsureWinsockInit();
rtc::Win32SocketServer w32_ss;
rtc::Win32Thread w32_thread(&w32_ss);
@@ -26,7 +28,7 @@
rtc::WindowsCommandLineArguments win_args;
int argc = win_args.argc();
- char **argv = win_args.argv();
+ char** argv = win_args.argv();
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
if (FLAG_help) {
@@ -50,7 +52,7 @@
rtc::InitializeSSL();
PeerConnectionClient client;
rtc::scoped_refptr<Conductor> conductor(
- new rtc::RefCountedObject<Conductor>(&client, &wnd));
+ new rtc::RefCountedObject<Conductor>(&client, &wnd));
// Main loop.
MSG msg;
diff --git a/examples/peerconnection/client/main_wnd.cc b/examples/peerconnection/client/main_wnd.cc
index 86f84fd..c68d314 100644
--- a/examples/peerconnection/client/main_wnd.cc
+++ b/examples/peerconnection/client/main_wnd.cc
@@ -31,8 +31,10 @@
const char kNoVideoStreams[] = "(no video streams either way)";
const char kNoIncomingStream[] = "(no incoming video)";
-void CalculateWindowSizeForText(HWND wnd, const wchar_t* text,
- size_t* width, size_t* height) {
+void CalculateWindowSizeForText(HWND wnd,
+ const wchar_t* text,
+ size_t* width,
+ size_t* height) {
HDC dc = ::GetDC(wnd);
RECT text_rc = {0};
::DrawText(dc, text, -1, &text_rc, DT_CALCRECT | DT_SINGLELINE);
@@ -42,11 +44,9 @@
::GetWindowRect(wnd, &window);
*width = text_rc.right - text_rc.left;
- *width += (window.right - window.left) -
- (client.right - client.left);
+ *width += (window.right - window.left) - (client.right - client.left);
*height = text_rc.bottom - text_rc.top;
- *height += (window.bottom - window.top) -
- (client.bottom - client.top);
+ *height += (window.bottom - window.top) - (client.bottom - client.top);
}
HFONT GetDefaultFont() {
@@ -62,18 +62,30 @@
void AddListBoxItem(HWND listbox, const std::string& str, LPARAM item_data) {
LRESULT index = ::SendMessageA(listbox, LB_ADDSTRING, 0,
- reinterpret_cast<LPARAM>(str.c_str()));
+ reinterpret_cast<LPARAM>(str.c_str()));
::SendMessageA(listbox, LB_SETITEMDATA, index, item_data);
}
} // namespace
-MainWnd::MainWnd(const char* server, int port, bool auto_connect,
+MainWnd::MainWnd(const char* server,
+ int port,
+ bool auto_connect,
bool auto_call)
- : ui_(CONNECT_TO_SERVER), wnd_(NULL), edit1_(NULL), edit2_(NULL),
- label1_(NULL), label2_(NULL), button_(NULL), listbox_(NULL),
- destroyed_(false), callback_(NULL), nested_msg_(NULL),
- server_(server), auto_connect_(auto_connect), auto_call_(auto_call) {
+ : ui_(CONNECT_TO_SERVER),
+ wnd_(NULL),
+ edit1_(NULL),
+ edit2_(NULL),
+ label1_(NULL),
+ label2_(NULL),
+ button_(NULL),
+ listbox_(NULL),
+ destroyed_(false),
+ callback_(NULL),
+ nested_msg_(NULL),
+ server_(server),
+ auto_connect_(auto_connect),
+ auto_call_(auto_call) {
char buffer[10] = {0};
sprintfn(buffer, sizeof(buffer), "%i", port);
port_ = buffer;
@@ -89,10 +101,11 @@
return false;
ui_thread_id_ = ::GetCurrentThreadId();
- wnd_ = ::CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, kClassName, L"WebRTC",
- WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, NULL, GetModuleHandle(NULL), this);
+ wnd_ =
+ ::CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, kClassName, L"WebRTC",
+ WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), this);
::SendMessage(wnd_, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()),
TRUE);
@@ -176,10 +189,10 @@
LRESULT count = ::SendMessage(listbox_, LB_GETCOUNT, 0, 0);
if (count != LB_ERR) {
// Select the last item in the list
- LRESULT selection = ::SendMessage(listbox_, LB_SETCURSEL , count - 1, 0);
+ LRESULT selection = ::SendMessage(listbox_, LB_SETCURSEL, count - 1, 0);
if (selection != LB_ERR)
- ::PostMessage(wnd_, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(listbox_),
- LBN_DBLCLK),
+ ::PostMessage(wnd_, WM_COMMAND,
+ MAKEWPARAM(GetDlgCtrlID(listbox_), LBN_DBLCLK),
reinterpret_cast<LPARAM>(listbox_));
}
}
@@ -199,7 +212,6 @@
::MessageBoxA(handle(), text, caption, flags);
}
-
void MainWnd::StartLocalRenderer(webrtc::VideoTrackInterface* local_video) {
local_renderer_.reset(new VideoRenderer(handle(), 1, 1, local_video));
}
@@ -218,7 +230,8 @@
void MainWnd::QueueUIThreadCallback(int msg_id, void* data) {
::PostThreadMessage(ui_thread_id_, UI_THREAD_CALLBACK,
- static_cast<WPARAM>(msg_id), reinterpret_cast<LPARAM>(data));
+ static_cast<WPARAM>(msg_id),
+ reinterpret_cast<LPARAM>(data));
}
void MainWnd::OnPaint() {
@@ -244,7 +257,7 @@
::SetStretchBltMode(dc_mem, HALFTONE);
// Set the map mode so that the ratio will be maintained for us.
- HDC all_dc[] = { ps.hdc, dc_mem };
+ HDC all_dc[] = {ps.hdc, dc_mem};
for (int i = 0; i < arraysize(all_dc); ++i) {
SetMapMode(all_dc[i], MM_ISOTROPIC);
SetWindowExtEx(all_dc[i], width, height, NULL);
@@ -254,35 +267,34 @@
HBITMAP bmp_mem = ::CreateCompatibleBitmap(ps.hdc, rc.right, rc.bottom);
HGDIOBJ bmp_old = ::SelectObject(dc_mem, bmp_mem);
- POINT logical_area = { rc.right, rc.bottom };
+ POINT logical_area = {rc.right, rc.bottom};
DPtoLP(ps.hdc, &logical_area, 1);
HBRUSH brush = ::CreateSolidBrush(RGB(0, 0, 0));
- RECT logical_rect = {0, 0, logical_area.x, logical_area.y };
+ RECT logical_rect = {0, 0, logical_area.x, logical_area.y};
::FillRect(dc_mem, &logical_rect, brush);
::DeleteObject(brush);
int x = (logical_area.x / 2) - (width / 2);
int y = (logical_area.y / 2) - (height / 2);
- StretchDIBits(dc_mem, x, y, width, height,
- 0, 0, width, height, image, &bmi, DIB_RGB_COLORS, SRCCOPY);
+ StretchDIBits(dc_mem, x, y, width, height, 0, 0, width, height, image,
+ &bmi, DIB_RGB_COLORS, SRCCOPY);
if ((rc.right - rc.left) > 200 && (rc.bottom - rc.top) > 200) {
const BITMAPINFO& bmi = local_renderer->bmi();
image = local_renderer->image();
int thumb_width = bmi.bmiHeader.biWidth / 4;
int thumb_height = abs(bmi.bmiHeader.biHeight) / 4;
- StretchDIBits(dc_mem,
- logical_area.x - thumb_width - 10,
- logical_area.y - thumb_height - 10,
- thumb_width, thumb_height,
- 0, 0, bmi.bmiHeader.biWidth, -bmi.bmiHeader.biHeight,
- image, &bmi, DIB_RGB_COLORS, SRCCOPY);
+ StretchDIBits(dc_mem, logical_area.x - thumb_width - 10,
+ logical_area.y - thumb_height - 10, thumb_width,
+ thumb_height, 0, 0, bmi.bmiHeader.biWidth,
+ -bmi.bmiHeader.biHeight, image, &bmi, DIB_RGB_COLORS,
+ SRCCOPY);
}
- BitBlt(ps.hdc, 0, 0, logical_area.x, logical_area.y,
- dc_mem, 0, 0, SRCCOPY);
+ BitBlt(ps.hdc, 0, 0, logical_area.x, logical_area.y, dc_mem, 0, 0,
+ SRCCOPY);
// Cleanup.
::SelectObject(dc_mem, bmp_old);
@@ -305,7 +317,7 @@
text += kNoIncomingStream;
}
::DrawTextA(ps.hdc, text.c_str(), -1, &rc,
- DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ DT_SINGLELINE | DT_CENTER | DT_VCENTER);
::SelectObject(ps.hdc, old_font);
}
} else {
@@ -393,8 +405,8 @@
// static
LRESULT CALLBACK MainWnd::WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
- MainWnd* me = reinterpret_cast<MainWnd*>(
- ::GetWindowLongPtr(hwnd, GWLP_USERDATA));
+ MainWnd* me =
+ reinterpret_cast<MainWnd*>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (!me && WM_CREATE == msg) {
CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lp);
me = reinterpret_cast<MainWnd*>(cs->lpCreateParams);
@@ -433,7 +445,7 @@
if (wnd_class_)
return true;
- WNDCLASSEX wcex = { sizeof(WNDCLASSEX) };
+ WNDCLASSEX wcex = {sizeof(WNDCLASSEX)};
wcex.style = CS_DBLCLKS;
wcex.hInstance = GetModuleHandle(NULL);
wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
@@ -445,17 +457,18 @@
return wnd_class_ != 0;
}
-void MainWnd::CreateChildWindow(HWND* wnd, MainWnd::ChildWindowID id,
- const wchar_t* class_name, DWORD control_style,
+void MainWnd::CreateChildWindow(HWND* wnd,
+ MainWnd::ChildWindowID id,
+ const wchar_t* class_name,
+ DWORD control_style,
DWORD ex_style) {
if (::IsWindow(*wnd))
return;
// Child windows are invisible at first, and shown after being resized.
DWORD style = WS_CHILD | control_style;
- *wnd = ::CreateWindowEx(ex_style, class_name, L"", style,
- 100, 100, 100, 100, wnd_,
- reinterpret_cast<HMENU>(id),
+ *wnd = ::CreateWindowEx(ex_style, class_name, L"", style, 100, 100, 100, 100,
+ wnd_, reinterpret_cast<HMENU>(id),
GetModuleHandle(NULL), NULL);
RTC_DCHECK(::IsWindow(*wnd) != FALSE);
::SendMessage(*wnd, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()),
@@ -486,11 +499,9 @@
size_t width;
size_t height;
} windows[] = {
- { label1_, L"Server" },
- { edit1_, L"XXXyyyYYYgggXXXyyyYYYggg" },
- { label2_, L":" },
- { edit2_, L"XyXyX" },
- { button_, L"Connect" },
+ {label1_, L"Server"}, {edit1_, L"XXXyyyYYYgggXXXyyyYYYggg"},
+ {label2_, L":"}, {edit2_, L"XyXyX"},
+ {button_, L"Connect"},
};
if (show) {
@@ -511,8 +522,7 @@
size_t top = y - (windows[i].height / 2);
::MoveWindow(windows[i].wnd, static_cast<int>(x), static_cast<int>(top),
static_cast<int>(windows[i].width),
- static_cast<int>(windows[i].height),
- TRUE);
+ static_cast<int>(windows[i].height), TRUE);
x += kSeparator + windows[i].width;
if (windows[i].text[0] != 'X')
::SetWindowText(windows[i].wnd, windows[i].text);
@@ -566,7 +576,9 @@
//
MainWnd::VideoRenderer::VideoRenderer(
- HWND wnd, int width, int height,
+ HWND wnd,
+ int width,
+ int height,
webrtc::VideoTrackInterface* track_to_render)
: wnd_(wnd), rendered_track_(track_to_render) {
::InitializeCriticalSection(&buffer_lock_);
@@ -577,8 +589,8 @@
bmi_.bmiHeader.biCompression = BI_RGB;
bmi_.bmiHeader.biWidth = width;
bmi_.bmiHeader.biHeight = -height;
- bmi_.bmiHeader.biSizeImage = width * height *
- (bmi_.bmiHeader.biBitCount >> 3);
+ bmi_.bmiHeader.biSizeImage =
+ width * height * (bmi_.bmiHeader.biBitCount >> 3);
rendered_track_->AddOrUpdateSink(this, rtc::VideoSinkWants());
}
@@ -596,14 +608,12 @@
bmi_.bmiHeader.biWidth = width;
bmi_.bmiHeader.biHeight = -height;
- bmi_.bmiHeader.biSizeImage = width * height *
- (bmi_.bmiHeader.biBitCount >> 3);
+ bmi_.bmiHeader.biSizeImage =
+ width * height * (bmi_.bmiHeader.biBitCount >> 3);
image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]);
}
-void MainWnd::VideoRenderer::OnFrame(
- const webrtc::VideoFrame& video_frame) {
-
+void MainWnd::VideoRenderer::OnFrame(const webrtc::VideoFrame& video_frame) {
{
AutoLock<VideoRenderer> lock(this);
@@ -616,12 +626,10 @@
SetSize(buffer->width(), buffer->height());
RTC_DCHECK(image_.get() != NULL);
- libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(),
- buffer->DataU(), buffer->StrideU(),
- buffer->DataV(), buffer->StrideV(),
+ libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), buffer->DataU(),
+ buffer->StrideU(), buffer->DataV(), buffer->StrideV(),
image_.get(),
- bmi_.bmiHeader.biWidth *
- bmi_.bmiHeader.biBitCount / 8,
+ bmi_.bmiHeader.biWidth * bmi_.bmiHeader.biBitCount / 8,
buffer->width(), buffer->height());
}
InvalidateRect(wnd_, NULL, TRUE);
diff --git a/examples/peerconnection/client/main_wnd.h b/examples/peerconnection/client/main_wnd.h
index 8edf81f..5700258 100644
--- a/examples/peerconnection/client/main_wnd.h
+++ b/examples/peerconnection/client/main_wnd.h
@@ -32,6 +32,7 @@
virtual void DisconnectFromCurrentPeer() = 0;
virtual void UIThreadCallback(int msg_id, void* data) = 0;
virtual void Close() = 0;
+
protected:
virtual ~MainWndCallback() {}
};
@@ -50,7 +51,8 @@
virtual void RegisterObserver(MainWndCallback* callback) = 0;
virtual bool IsWindow() = 0;
- virtual void MessageBox(const char* caption, const char* text,
+ virtual void MessageBox(const char* caption,
+ const char* text,
bool is_error) = 0;
virtual UI current_ui() = 0;
@@ -90,8 +92,7 @@
virtual void SwitchToConnectUI();
virtual void SwitchToPeerList(const Peers& peers);
virtual void SwitchToStreamingUI();
- virtual void MessageBox(const char* caption, const char* text,
- bool is_error);
+ virtual void MessageBox(const char* caption, const char* text, bool is_error);
virtual UI current_ui() { return ui_; }
virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video);
@@ -105,17 +106,15 @@
class VideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
public:
- VideoRenderer(HWND wnd, int width, int height,
+ VideoRenderer(HWND wnd,
+ int width,
+ int height,
webrtc::VideoTrackInterface* track_to_render);
virtual ~VideoRenderer();
- void Lock() {
- ::EnterCriticalSection(&buffer_lock_);
- }
+ void Lock() { ::EnterCriticalSection(&buffer_lock_); }
- void Unlock() {
- ::LeaveCriticalSection(&buffer_lock_);
- }
+ void Unlock() { ::LeaveCriticalSection(&buffer_lock_); }
// VideoSinkInterface implementation
void OnFrame(const webrtc::VideoFrame& frame) override;
@@ -145,6 +144,7 @@
public:
explicit AutoLock(T* obj) : obj_(obj) { obj_->Lock(); }
~AutoLock() { obj_->Unlock(); }
+
protected:
T* obj_;
};
@@ -168,8 +168,11 @@
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
static bool RegisterWindowClass();
- void CreateChildWindow(HWND* wnd, ChildWindowID id, const wchar_t* class_name,
- DWORD control_style, DWORD ex_style);
+ void CreateChildWindow(HWND* wnd,
+ ChildWindowID id,
+ const wchar_t* class_name,
+ DWORD control_style,
+ DWORD ex_style);
void CreateChildWindows();
void LayoutConnectUI(bool show);
diff --git a/examples/peerconnection/client/peer_connection_client.cc b/examples/peerconnection/client/peer_connection_client.cc
index 40dfec5..bb79d16 100644
--- a/examples/peerconnection/client/peer_connection_client.cc
+++ b/examples/peerconnection/client/peer_connection_client.cc
@@ -46,30 +46,23 @@
} // namespace
PeerConnectionClient::PeerConnectionClient()
- : callback_(NULL),
- resolver_(NULL),
- state_(NOT_CONNECTED),
- my_id_(-1) {
-}
+ : callback_(NULL), resolver_(NULL), state_(NOT_CONNECTED), my_id_(-1) {}
-PeerConnectionClient::~PeerConnectionClient() {
-}
+PeerConnectionClient::~PeerConnectionClient() {}
void PeerConnectionClient::InitSocketSignals() {
RTC_DCHECK(control_socket_.get() != NULL);
RTC_DCHECK(hanging_get_.get() != NULL);
control_socket_->SignalCloseEvent.connect(this,
- &PeerConnectionClient::OnClose);
- hanging_get_->SignalCloseEvent.connect(this,
- &PeerConnectionClient::OnClose);
+ &PeerConnectionClient::OnClose);
+ hanging_get_->SignalCloseEvent.connect(this, &PeerConnectionClient::OnClose);
control_socket_->SignalConnectEvent.connect(this,
- &PeerConnectionClient::OnConnect);
- hanging_get_->SignalConnectEvent.connect(this,
- &PeerConnectionClient::OnHangingGetConnect);
- control_socket_->SignalReadEvent.connect(this,
- &PeerConnectionClient::OnRead);
- hanging_get_->SignalReadEvent.connect(this,
- &PeerConnectionClient::OnHangingGetRead);
+ &PeerConnectionClient::OnConnect);
+ hanging_get_->SignalConnectEvent.connect(
+ this, &PeerConnectionClient::OnHangingGetConnect);
+ control_socket_->SignalReadEvent.connect(this, &PeerConnectionClient::OnRead);
+ hanging_get_->SignalReadEvent.connect(
+ this, &PeerConnectionClient::OnHangingGetRead);
}
int PeerConnectionClient::id() const {
@@ -90,7 +83,8 @@
callback_ = callback;
}
-void PeerConnectionClient::Connect(const std::string& server, int port,
+void PeerConnectionClient::Connect(const std::string& server,
+ int port,
const std::string& client_name) {
RTC_DCHECK(!server.empty());
RTC_DCHECK(!client_name.empty());
@@ -142,8 +136,8 @@
hanging_get_.reset(CreateClientSocket(server_address_.ipaddr().family()));
InitSocketSignals();
char buffer[1024];
- sprintfn(buffer, sizeof(buffer),
- "GET /sign_in?%s HTTP/1.0\r\n\r\n", client_name_.c_str());
+ sprintfn(buffer, sizeof(buffer), "GET /sign_in?%s HTTP/1.0\r\n\r\n",
+ client_name_.c_str());
onconnect_data_ = buffer;
bool ret = ConnectControlSocket();
@@ -165,11 +159,11 @@
char headers[1024];
sprintfn(headers, sizeof(headers),
- "POST /message?peer_id=%i&to=%i HTTP/1.0\r\n"
- "Content-Length: %i\r\n"
- "Content-Type: text/plain\r\n"
- "\r\n",
- my_id_, peer_id, message.length());
+ "POST /message?peer_id=%i&to=%i HTTP/1.0\r\n"
+ "Content-Length: %i\r\n"
+ "Content-Type: text/plain\r\n"
+ "\r\n",
+ my_id_, peer_id, message.length());
onconnect_data_ = headers;
onconnect_data_ += message;
return ConnectControlSocket();
@@ -197,7 +191,7 @@
if (my_id_ != -1) {
char buffer[1024];
sprintfn(buffer, sizeof(buffer),
- "GET /sign_out?peer_id=%i HTTP/1.0\r\n\r\n", my_id_);
+ "GET /sign_out?peer_id=%i HTTP/1.0\r\n\r\n", my_id_);
onconnect_data_ = buffer;
return ConnectControlSocket();
} else {
@@ -243,8 +237,8 @@
void PeerConnectionClient::OnHangingGetConnect(rtc::AsyncSocket* socket) {
char buffer[1024];
- sprintfn(buffer, sizeof(buffer),
- "GET /wait?peer_id=%i HTTP/1.0\r\n\r\n", my_id_);
+ sprintfn(buffer, sizeof(buffer), "GET /wait?peer_id=%i HTTP/1.0\r\n\r\n",
+ my_id_);
int len = static_cast<int>(strlen(buffer));
int sent = socket->Send(buffer, len);
RTC_DCHECK(sent == len);
@@ -273,7 +267,8 @@
return false;
}
-bool PeerConnectionClient::GetHeaderValue(const std::string& data, size_t eoh,
+bool PeerConnectionClient::GetHeaderValue(const std::string& data,
+ size_t eoh,
const char* header_pattern,
std::string* value) {
RTC_DCHECK(value != NULL);
@@ -331,8 +326,8 @@
size_t content_length = 0;
if (ReadIntoBuffer(socket, &control_data_, &content_length)) {
size_t peer_id = 0, eoh = 0;
- bool ok = ParseServerResponse(control_data_, content_length, &peer_id,
- &eoh);
+ bool ok =
+ ParseServerResponse(control_data_, content_length, &peer_id, &eoh);
if (ok) {
if (my_id_ == -1) {
// First response. Let's store our server assigned ID.
@@ -351,7 +346,8 @@
std::string name;
bool connected;
if (ParseEntry(control_data_.substr(pos, eol - pos), &name, &id,
- &connected) && id != my_id_) {
+ &connected) &&
+ id != my_id_) {
peers_[id] = name;
callback_->OnPeerConnected(id, name);
}
@@ -383,8 +379,8 @@
size_t content_length = 0;
if (ReadIntoBuffer(socket, ¬ification_data_, &content_length)) {
size_t peer_id = 0, eoh = 0;
- bool ok = ParseServerResponse(notification_data_, content_length,
- &peer_id, &eoh);
+ bool ok =
+ ParseServerResponse(notification_data_, content_length, &peer_id, &eoh);
if (ok) {
// Store the position where the body begins.
diff --git a/examples/peerconnection/client/peer_connection_client.h b/examples/peerconnection/client/peer_connection_client.h
index f5f87ec..08bbfb0 100644
--- a/examples/peerconnection/client/peer_connection_client.h
+++ b/examples/peerconnection/client/peer_connection_client.h
@@ -56,7 +56,8 @@
void RegisterObserver(PeerConnectionClientObserver* callback);
- void Connect(const std::string& server, int port,
+ void Connect(const std::string& server,
+ int port,
const std::string& client_name);
bool SendToPeer(int peer_id, const std::string& message);
@@ -78,14 +79,19 @@
void OnMessageFromPeer(int peer_id, const std::string& message);
// Quick and dirty support for parsing HTTP header values.
- bool GetHeaderValue(const std::string& data, size_t eoh,
- const char* header_pattern, size_t* value);
+ bool GetHeaderValue(const std::string& data,
+ size_t eoh,
+ const char* header_pattern,
+ size_t* value);
- bool GetHeaderValue(const std::string& data, size_t eoh,
- const char* header_pattern, std::string* value);
+ bool GetHeaderValue(const std::string& data,
+ size_t eoh,
+ const char* header_pattern,
+ std::string* value);
// Returns true if the whole response has been read.
- bool ReadIntoBuffer(rtc::AsyncSocket* socket, std::string* data,
+ bool ReadIntoBuffer(rtc::AsyncSocket* socket,
+ std::string* data,
size_t* content_length);
void OnRead(rtc::AsyncSocket* socket);
@@ -93,13 +99,17 @@
void OnHangingGetRead(rtc::AsyncSocket* socket);
// Parses a single line entry in the form "<name>,<id>,<connected>"
- bool ParseEntry(const std::string& entry, std::string* name, int* id,
+ bool ParseEntry(const std::string& entry,
+ std::string* name,
+ int* id,
bool* connected);
int GetResponseStatus(const std::string& response);
- bool ParseServerResponse(const std::string& response, size_t content_length,
- size_t* peer_id, size_t* eoh);
+ bool ParseServerResponse(const std::string& response,
+ size_t content_length,
+ size_t* peer_id,
+ size_t* eoh);
void OnClose(rtc::AsyncSocket* socket, int err);