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

Side by Side Diff: webrtc/examples/peerconnection/client/main_wnd.cc

Issue 2620303003: Replace ASSERT by RTC_DCHECK in all non-test code. (Closed)
Patch Set: Address final nits. Created 3 years, 11 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 "webrtc/examples/peerconnection/client/main_wnd.h" 11 #include "webrtc/examples/peerconnection/client/main_wnd.h"
12 12
13 #include <math.h> 13 #include <math.h>
14 14
15 #include "libyuv/convert_argb.h" 15 #include "libyuv/convert_argb.h"
16 #include "webrtc/api/video/i420_buffer.h" 16 #include "webrtc/api/video/i420_buffer.h"
17 #include "webrtc/examples/peerconnection/client/defaults.h" 17 #include "webrtc/examples/peerconnection/client/defaults.h"
18 #include "webrtc/base/arraysize.h" 18 #include "webrtc/base/arraysize.h"
19 #include "webrtc/base/checks.h"
19 #include "webrtc/base/common.h" 20 #include "webrtc/base/common.h"
20 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
21 22
22 ATOM MainWnd::wnd_class_ = 0; 23 ATOM MainWnd::wnd_class_ = 0;
23 const wchar_t MainWnd::kClassName[] = L"WebRTC_MainWnd"; 24 const wchar_t MainWnd::kClassName[] = L"WebRTC_MainWnd";
24 25
25 using rtc::sprintfn; 26 using rtc::sprintfn;
26 27
27 namespace { 28 namespace {
28 29
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 : ui_(CONNECT_TO_SERVER), wnd_(NULL), edit1_(NULL), edit2_(NULL), 73 : ui_(CONNECT_TO_SERVER), wnd_(NULL), edit1_(NULL), edit2_(NULL),
73 label1_(NULL), label2_(NULL), button_(NULL), listbox_(NULL), 74 label1_(NULL), label2_(NULL), button_(NULL), listbox_(NULL),
74 destroyed_(false), callback_(NULL), nested_msg_(NULL), 75 destroyed_(false), callback_(NULL), nested_msg_(NULL),
75 server_(server), auto_connect_(auto_connect), auto_call_(auto_call) { 76 server_(server), auto_connect_(auto_connect), auto_call_(auto_call) {
76 char buffer[10] = {0}; 77 char buffer[10] = {0};
77 sprintfn(buffer, sizeof(buffer), "%i", port); 78 sprintfn(buffer, sizeof(buffer), "%i", port);
78 port_ = buffer; 79 port_ = buffer;
79 } 80 }
80 81
81 MainWnd::~MainWnd() { 82 MainWnd::~MainWnd() {
82 ASSERT(!IsWindow()); 83 RTC_DCHECK(!IsWindow());
83 } 84 }
84 85
85 bool MainWnd::Create() { 86 bool MainWnd::Create() {
86 ASSERT(wnd_ == NULL); 87 RTC_DCHECK(wnd_ == NULL);
87 if (!RegisterWindowClass()) 88 if (!RegisterWindowClass())
88 return false; 89 return false;
89 90
90 ui_thread_id_ = ::GetCurrentThreadId(); 91 ui_thread_id_ = ::GetCurrentThreadId();
91 wnd_ = ::CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, kClassName, L"WebRTC", 92 wnd_ = ::CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, kClassName, L"WebRTC",
92 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, 93 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
93 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 94 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
94 NULL, NULL, GetModuleHandle(NULL), this); 95 NULL, NULL, GetModuleHandle(NULL), this);
95 96
96 ::SendMessage(wnd_, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()), 97 ::SendMessage(wnd_, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 140 }
140 } else if (msg->hwnd == NULL && msg->message == UI_THREAD_CALLBACK) { 141 } else if (msg->hwnd == NULL && msg->message == UI_THREAD_CALLBACK) {
141 callback_->UIThreadCallback(static_cast<int>(msg->wParam), 142 callback_->UIThreadCallback(static_cast<int>(msg->wParam),
142 reinterpret_cast<void*>(msg->lParam)); 143 reinterpret_cast<void*>(msg->lParam));
143 ret = true; 144 ret = true;
144 } 145 }
145 return ret; 146 return ret;
146 } 147 }
147 148
148 void MainWnd::SwitchToConnectUI() { 149 void MainWnd::SwitchToConnectUI() {
149 ASSERT(IsWindow()); 150 RTC_DCHECK(IsWindow());
150 LayoutPeerListUI(false); 151 LayoutPeerListUI(false);
151 ui_ = CONNECT_TO_SERVER; 152 ui_ = CONNECT_TO_SERVER;
152 LayoutConnectUI(true); 153 LayoutConnectUI(true);
153 ::SetFocus(edit1_); 154 ::SetFocus(edit1_);
154 155
155 if (auto_connect_) 156 if (auto_connect_)
156 ::PostMessage(button_, BM_CLICK, 0, 0); 157 ::PostMessage(button_, BM_CLICK, 0, 0);
157 } 158 }
158 159
159 void MainWnd::SwitchToPeerList(const Peers& peers) { 160 void MainWnd::SwitchToPeerList(const Peers& peers) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return true; 434 return true;
434 435
435 WNDCLASSEX wcex = { sizeof(WNDCLASSEX) }; 436 WNDCLASSEX wcex = { sizeof(WNDCLASSEX) };
436 wcex.style = CS_DBLCLKS; 437 wcex.style = CS_DBLCLKS;
437 wcex.hInstance = GetModuleHandle(NULL); 438 wcex.hInstance = GetModuleHandle(NULL);
438 wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1); 439 wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
439 wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); 440 wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW);
440 wcex.lpfnWndProc = &WndProc; 441 wcex.lpfnWndProc = &WndProc;
441 wcex.lpszClassName = kClassName; 442 wcex.lpszClassName = kClassName;
442 wnd_class_ = ::RegisterClassEx(&wcex); 443 wnd_class_ = ::RegisterClassEx(&wcex);
443 ASSERT(wnd_class_ != 0); 444 RTC_DCHECK(wnd_class_ != 0);
444 return wnd_class_ != 0; 445 return wnd_class_ != 0;
445 } 446 }
446 447
447 void MainWnd::CreateChildWindow(HWND* wnd, MainWnd::ChildWindowID id, 448 void MainWnd::CreateChildWindow(HWND* wnd, MainWnd::ChildWindowID id,
448 const wchar_t* class_name, DWORD control_style, 449 const wchar_t* class_name, DWORD control_style,
449 DWORD ex_style) { 450 DWORD ex_style) {
450 if (::IsWindow(*wnd)) 451 if (::IsWindow(*wnd))
451 return; 452 return;
452 453
453 // Child windows are invisible at first, and shown after being resized. 454 // Child windows are invisible at first, and shown after being resized.
454 DWORD style = WS_CHILD | control_style; 455 DWORD style = WS_CHILD | control_style;
455 *wnd = ::CreateWindowEx(ex_style, class_name, L"", style, 456 *wnd = ::CreateWindowEx(ex_style, class_name, L"", style,
456 100, 100, 100, 100, wnd_, 457 100, 100, 100, 100, wnd_,
457 reinterpret_cast<HMENU>(id), 458 reinterpret_cast<HMENU>(id),
458 GetModuleHandle(NULL), NULL); 459 GetModuleHandle(NULL), NULL);
459 ASSERT(::IsWindow(*wnd) != FALSE); 460 RTC_DCHECK(::IsWindow(*wnd) != FALSE);
460 ::SendMessage(*wnd, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()), 461 ::SendMessage(*wnd, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()),
461 TRUE); 462 TRUE);
462 } 463 }
463 464
464 void MainWnd::CreateChildWindows() { 465 void MainWnd::CreateChildWindows() {
465 // Create the child windows in tab order. 466 // Create the child windows in tab order.
466 CreateChildWindow(&label1_, LABEL1_ID, L"Static", ES_CENTER | ES_READONLY, 0); 467 CreateChildWindow(&label1_, LABEL1_ID, L"Static", ES_CENTER | ES_READONLY, 0);
467 CreateChildWindow(&edit1_, EDIT_ID, L"Edit", 468 CreateChildWindow(&edit1_, EDIT_ID, L"Edit",
468 ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, WS_EX_CLIENTEDGE); 469 ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, WS_EX_CLIENTEDGE);
469 CreateChildWindow(&label2_, LABEL2_ID, L"Static", ES_CENTER | ES_READONLY, 0); 470 CreateChildWindow(&label2_, LABEL2_ID, L"Static", ES_CENTER | ES_READONLY, 0);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 AutoLock<VideoRenderer> lock(this); 608 AutoLock<VideoRenderer> lock(this);
608 609
609 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( 610 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
610 video_frame.video_frame_buffer()); 611 video_frame.video_frame_buffer());
611 if (video_frame.rotation() != webrtc::kVideoRotation_0) { 612 if (video_frame.rotation() != webrtc::kVideoRotation_0) {
612 buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation()); 613 buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation());
613 } 614 }
614 615
615 SetSize(buffer->width(), buffer->height()); 616 SetSize(buffer->width(), buffer->height());
616 617
617 ASSERT(image_.get() != NULL); 618 RTC_DCHECK(image_.get() != NULL);
618 libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), 619 libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(),
619 buffer->DataU(), buffer->StrideU(), 620 buffer->DataU(), buffer->StrideU(),
620 buffer->DataV(), buffer->StrideV(), 621 buffer->DataV(), buffer->StrideV(),
621 image_.get(), 622 image_.get(),
622 bmi_.bmiHeader.biWidth * 623 bmi_.bmiHeader.biWidth *
623 bmi_.bmiHeader.biBitCount / 8, 624 bmi_.bmiHeader.biBitCount / 8,
624 buffer->width(), buffer->height()); 625 buffer->width(), buffer->height());
625 } 626 }
626 InvalidateRect(wnd_, NULL, TRUE); 627 InvalidateRect(wnd_, NULL, TRUE);
627 } 628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698