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
This commit is contained in:
tommi@webrtc.org 2011-10-10 12:58:21 +00:00
parent 73ba4160f6
commit ed081a99a9
2 changed files with 34 additions and 8 deletions

View File

@ -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 @@ void AddListBoxItem(HWND listbox, const std::string& str, LPARAM item_data) {
::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 @@ void MainWnd::OnPaint() {
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 @@ void MainWnd::OnPaint() {
::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 @@ void MainWnd::HandleTabbing() {
//
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 @@ bool MainWnd::VideoRenderer::RenderFrame(const cricket::VideoFrame* frame) {
{
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,

View File

@ -117,6 +117,9 @@ class MainWnd : public MainWindow {
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 @@ class MainWnd : public MainWindow {
HWND wnd_;
BITMAPINFO bmi_;
size_t frame_width_;
size_t frame_height_;
talk_base::scoped_array<uint8> image_;
CRITICAL_SECTION buffer_lock_;
};