Print info about the local and remote resolution in the Windows client.
Review URL: http://webrtc-codereview.appspot.com/212001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@721 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/peerconnection/samples/client/main_wnd.cc b/peerconnection/samples/client/main_wnd.cc
index 519479e..5829015 100644
--- a/peerconnection/samples/client/main_wnd.cc
+++ b/peerconnection/samples/client/main_wnd.cc
@@ -14,6 +14,7 @@
 
 #include "talk/base/common.h"
 #include "talk/base/logging.h"
+#include "talk/base/stringutils.h"
 
 ATOM MainWnd::wnd_class_ = 0;
 const wchar_t MainWnd::kClassName[] = L"WebRTC_MainWnd";
@@ -62,6 +63,15 @@
   ::SendMessageA(listbox, LB_SETITEMDATA, index, item_data);
 }
 
+void DrawWhiteText(HDC dc, const RECT& rect, const char* text, int flags) {
+  HGDIOBJ old_font = ::SelectObject(dc, GetDefaultFont());
+  ::SetTextColor(dc, RGB(0xff, 0xff, 0xff));
+  ::SetBkMode(dc, TRANSPARENT);
+  RECT rc = rect;
+  ::DrawTextA(dc, text, -1, &rc, flags);
+  ::SelectObject(dc, old_font);
+}
+
 }  // namespace
 
 MainWnd::MainWnd()
@@ -256,6 +266,18 @@
       BitBlt(ps.hdc, 0, 0, logical_area.x, logical_area.y,
              dc_mem, 0, 0, SRCCOPY);
 
+      // Print the resolutions.
+      char buffer[1024];
+      talk_base::sprintfn(buffer, sizeof(buffer),
+          "Remote: %u x %u.  Local: %u x %u.",
+          remote_video_->frame_height(),
+          remote_video_->frame_width(),
+          local_video_->frame_height(),
+          local_video_->frame_width());
+
+      SetMapMode(ps.hdc, MM_TEXT);
+      DrawWhiteText(ps.hdc, rc, buffer, DT_SINGLELINE);
+
       // Cleanup.
       ::SelectObject(dc_mem, bmp_old);
       ::DeleteObject(bmp_mem);
@@ -266,19 +288,15 @@
       ::FillRect(ps.hdc, &rc, brush);
       ::DeleteObject(brush);
 
-      HGDIOBJ old_font = ::SelectObject(ps.hdc, GetDefaultFont());
-      ::SetTextColor(ps.hdc, RGB(0xff, 0xff, 0xff));
-      ::SetBkMode(ps.hdc, TRANSPARENT);
-
       std::string text(kConnecting);
       if (!local_video_->image()) {
         text += kNoVideoStreams;
       } else {
         text += kNoIncomingStream;
       }
-      ::DrawTextA(ps.hdc, text.c_str(), -1, &rc,
-          DT_SINGLELINE | DT_CENTER | DT_VCENTER);
-      ::SelectObject(ps.hdc, old_font);
+
+      DrawWhiteText(ps.hdc, rc, text.c_str(),
+                    DT_SINGLELINE | DT_CENTER | DT_VCENTER);
     }
   } else {
     HBRUSH brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
@@ -536,7 +554,7 @@
 //
 
 MainWnd::VideoRenderer::VideoRenderer(HWND wnd, int width, int height)
-    : wnd_(wnd) {
+    : wnd_(wnd), frame_width_(0), frame_height_(0) {
   ::InitializeCriticalSection(&buffer_lock_);
   ZeroMemory(&bmi_, sizeof(bmi_));
   bmi_.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -572,6 +590,9 @@
   {
     AutoLock<VideoRenderer> lock(this);
 
+    frame_height_ = frame->GetHeight();
+    frame_width_ = frame->GetWidth();
+
     ASSERT(image_.get() != NULL);
     frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, image_.get(),
         bmi_.bmiHeader.biSizeImage,
diff --git a/peerconnection/samples/client/main_wnd.h b/peerconnection/samples/client/main_wnd.h
index 5149bf5..9ec32e2 100644
--- a/peerconnection/samples/client/main_wnd.h
+++ b/peerconnection/samples/client/main_wnd.h
@@ -117,6 +117,9 @@
     const BITMAPINFO& bmi() const { return bmi_; }
     const uint8* image() const { return image_.get(); }
 
+    size_t frame_width() const { return frame_width_; }
+    size_t frame_height() const { return frame_height_; }
+
    protected:
     enum {
       SET_SIZE,
@@ -125,6 +128,8 @@
 
     HWND wnd_;
     BITMAPINFO bmi_;
+    size_t frame_width_;
+    size_t frame_height_;
     talk_base::scoped_array<uint8> image_;
     CRITICAL_SECTION buffer_lock_;
   };