Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: webrtc/examples/peerconnection/client/linux/main.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <gtk/gtk.h> 11 #include <gtk/gtk.h>
12 12
13 #include "webrtc/examples/peerconnection/client/conductor.h" 13 #include "webrtc/examples/peerconnection/client/conductor.h"
14 #include "webrtc/examples/peerconnection/client/flagdefs.h" 14 #include "webrtc/examples/peerconnection/client/flagdefs.h"
15 #include "webrtc/examples/peerconnection/client/linux/main_wnd.h" 15 #include "webrtc/examples/peerconnection/client/linux/main_wnd.h"
16 #include "webrtc/examples/peerconnection/client/peer_connection_client.h" 16 #include "webrtc/examples/peerconnection/client/peer_connection_client.h"
17 17
18 #include "webrtc/base/ssladapter.h" 18 #include "webrtc/base/ssladapter.h"
19 #include "webrtc/base/thread.h" 19 #include "webrtc/base/thread.h"
20 20
21 class CustomSocketServer : public rtc::PhysicalSocketServer { 21 class CustomSocketServer : public rtc::PhysicalSocketServer {
22 public: 22 public:
23 CustomSocketServer(rtc::Thread* thread, GtkMainWnd* wnd) 23 CustomSocketServer(rtc::Thread* thread, GtkMainWnd* wnd)
24 : thread_(thread), wnd_(wnd), conductor_(NULL), client_(NULL) {} 24 : thread_(thread), wnd_(wnd), conductor_(nullptr), client_(nullptr) {}
25 virtual ~CustomSocketServer() {} 25 virtual ~CustomSocketServer() {}
26 26
27 void set_client(PeerConnectionClient* client) { client_ = client; } 27 void set_client(PeerConnectionClient* client) { client_ = client; }
28 void set_conductor(Conductor* conductor) { conductor_ = conductor; } 28 void set_conductor(Conductor* conductor) { conductor_ = conductor; }
29 29
30 // Override so that we can also pump the GTK message loop. 30 // Override so that we can also pump the GTK message loop.
31 virtual bool Wait(int cms, bool process_io) { 31 virtual bool Wait(int cms, bool process_io) {
32 // Pump GTK events. 32 // Pump GTK events.
33 // TODO(henrike): We really should move either the socket server or UI to a 33 // TODO(henrike): We really should move either the socket server or UI to a
34 // different thread. Alternatively we could look at merging the two loops 34 // different thread. Alternatively we could look at merging the two loops
35 // by implementing a dispatcher for the socket server and/or use 35 // by implementing a dispatcher for the socket server and/or use
36 // g_main_context_set_poll_func. 36 // g_main_context_set_poll_func.
37 while (gtk_events_pending()) 37 while (gtk_events_pending())
38 gtk_main_iteration(); 38 gtk_main_iteration();
39 39
40 if (!wnd_->IsWindow() && !conductor_->connection_active() && 40 if (!wnd_->IsWindow() && !conductor_->connection_active() &&
41 client_ != NULL && !client_->is_connected()) { 41 client_ != nullptr && !client_->is_connected()) {
42 thread_->Quit(); 42 thread_->Quit();
43 } 43 }
44 return rtc::PhysicalSocketServer::Wait(0/*cms == -1 ? 1 : cms*/, 44 return rtc::PhysicalSocketServer::Wait(0/*cms == -1 ? 1 : cms*/,
45 process_io); 45 process_io);
46 } 46 }
47 47
48 protected: 48 protected:
49 rtc::Thread* thread_; 49 rtc::Thread* thread_;
50 GtkMainWnd* wnd_; 50 GtkMainWnd* wnd_;
51 Conductor* conductor_; 51 Conductor* conductor_;
52 PeerConnectionClient* client_; 52 PeerConnectionClient* client_;
53 }; 53 };
54 54
55 int main(int argc, char* argv[]) { 55 int main(int argc, char* argv[]) {
56 gtk_init(&argc, &argv); 56 gtk_init(&argc, &argv);
57 // g_type_init API is deprecated (and does nothing) since glib 2.35.0, see: 57 // g_type_init API is deprecated (and does nothing) since glib 2.35.0, see:
58 // https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html 58 // https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html
59 #if !GLIB_CHECK_VERSION(2, 35, 0) 59 #if !GLIB_CHECK_VERSION(2, 35, 0)
60 g_type_init(); 60 g_type_init();
61 #endif 61 #endif
62 // g_thread_init API is deprecated since glib 2.31.0, see release note: 62 // g_thread_init API is deprecated since glib 2.31.0, see release note:
63 // http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.ht ml 63 // http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.ht ml
64 #if !GLIB_CHECK_VERSION(2, 31, 0) 64 #if !GLIB_CHECK_VERSION(2, 31, 0)
65 g_thread_init(NULL); 65 g_thread_init(nullptr);
66 #endif 66 #endif
67 67
68 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); 68 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
69 if (FLAG_help) { 69 if (FLAG_help) {
70 rtc::FlagList::Print(NULL, false); 70 rtc::FlagList::Print(nullptr, false);
71 return 0; 71 return 0;
72 } 72 }
73 73
74 // Abort if the user specifies a port that is outside the allowed 74 // Abort if the user specifies a port that is outside the allowed
75 // range [1, 65535]. 75 // range [1, 65535].
76 if ((FLAG_port < 1) || (FLAG_port > 65535)) { 76 if ((FLAG_port < 1) || (FLAG_port > 65535)) {
77 printf("Error: %i is not a valid port.\n", FLAG_port); 77 printf("Error: %i is not a valid port.\n", FLAG_port);
78 return -1; 78 return -1;
79 } 79 }
80 80
(...skipping 11 matching lines...) Expand all
92 rtc::scoped_refptr<Conductor> conductor( 92 rtc::scoped_refptr<Conductor> conductor(
93 new rtc::RefCountedObject<Conductor>(&client, &wnd)); 93 new rtc::RefCountedObject<Conductor>(&client, &wnd));
94 socket_server.set_client(&client); 94 socket_server.set_client(&client);
95 socket_server.set_conductor(conductor); 95 socket_server.set_conductor(conductor);
96 96
97 thread->Run(); 97 thread->Run();
98 98
99 // gtk_main(); 99 // gtk_main();
100 wnd.Destroy(); 100 wnd.Destroy();
101 101
102 thread->set_socketserver(NULL); 102 thread->set_socketserver(nullptr);
103 // TODO(henrike): Run the Gtk main loop to tear down the connection. 103 // TODO(henrike): Run the Gtk main loop to tear down the connection.
104 /* 104 /*
105 while (gtk_events_pending()) { 105 while (gtk_events_pending()) {
106 gtk_main_iteration(); 106 gtk_main_iteration();
107 } 107 }
108 */ 108 */
109 rtc::CleanupSSL(); 109 rtc::CleanupSSL();
110 return 0; 110 return 0;
111 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698