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}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -38,15 +38,15 @@ class CustomSocketServer : public rtc::PhysicalSocketServer {
// 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 @@ class CustomSocketServer : public rtc::PhysicalSocketServer {
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);

View File

@ -30,7 +30,8 @@ namespace {
// 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 @@ gboolean SimulateButtonClick(gpointer button) {
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 @@ void InitializeList(GtkWidget* list) {
// 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 @@ gboolean Draw(GtkWidget* widget, cairo_t* cr, gpointer data) {
// 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 @@ bool GtkMainWnd::IsWindow() {
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 @@ MainWindow::UI GtkMainWnd::current_ui() {
return STREAMING;
}
void GtkMainWnd::StartLocalRenderer(webrtc::VideoTrackInterface* local_video) {
local_renderer_.reset(new VideoRenderer(this, local_video));
}
@ -394,7 +407,8 @@ void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) {
}
}
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 @@ void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path,
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 @@ void GtkMainWnd::VideoRenderer::SetSize(int width, int height) {
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 @@ void GtkMainWnd::VideoRenderer::OnFrame(
// 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();

View File

@ -39,8 +39,7 @@ class GtkMainWnd : public MainWindow {
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 @@ class GtkMainWnd : public MainWindow {
// 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 @@ class GtkMainWnd : public MainWindow {
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 @@ class GtkMainWnd : public MainWindow {
};
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.