OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 VideoWindow* window_; | 93 VideoWindow* window_; |
94 }; | 94 }; |
95 | 95 |
96 // Context: worker Thread. | 96 // Context: worker Thread. |
97 bool Initialize(); | 97 bool Initialize(); |
98 void OnPaint(); | 98 void OnPaint(); |
99 void OnSize(int width, int height, bool frame_changed); | 99 void OnSize(int width, int height, bool frame_changed); |
100 void OnRenderFrame(const VideoFrame* frame); | 100 void OnRenderFrame(const VideoFrame* frame); |
101 | 101 |
102 BITMAPINFO bmi_; | 102 BITMAPINFO bmi_; |
103 rtc::scoped_ptr<uint8[]> image_; | 103 rtc::scoped_ptr<uint8_t[]> image_; |
104 rtc::scoped_ptr<WindowThread> window_thread_; | 104 rtc::scoped_ptr<WindowThread> window_thread_; |
105 // The initial position of the window. | 105 // The initial position of the window. |
106 int initial_x_; | 106 int initial_x_; |
107 int initial_y_; | 107 int initial_y_; |
108 }; | 108 }; |
109 | 109 |
110 ///////////////////////////////////////////////////////////////////////////// | 110 ///////////////////////////////////////////////////////////////////////////// |
111 // Implementation of class VideoWindow | 111 // Implementation of class VideoWindow |
112 ///////////////////////////////////////////////////////////////////////////// | 112 ///////////////////////////////////////////////////////////////////////////// |
113 GdiVideoRenderer::VideoWindow::VideoWindow( | 113 GdiVideoRenderer::VideoWindow::VideoWindow( |
114 int x, int y, int width, int height) | 114 int x, int y, int width, int height) |
115 : initial_x_(x), | 115 : initial_x_(x), |
116 initial_y_(y) { | 116 initial_y_(y) { |
117 memset(&bmi_.bmiHeader, 0, sizeof(bmi_.bmiHeader)); | 117 memset(&bmi_.bmiHeader, 0, sizeof(bmi_.bmiHeader)); |
118 bmi_.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 118 bmi_.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
119 bmi_.bmiHeader.biPlanes = 1; | 119 bmi_.bmiHeader.biPlanes = 1; |
120 bmi_.bmiHeader.biBitCount = 32; | 120 bmi_.bmiHeader.biBitCount = 32; |
121 bmi_.bmiHeader.biCompression = BI_RGB; | 121 bmi_.bmiHeader.biCompression = BI_RGB; |
122 bmi_.bmiHeader.biWidth = width; | 122 bmi_.bmiHeader.biWidth = width; |
123 bmi_.bmiHeader.biHeight = -height; | 123 bmi_.bmiHeader.biHeight = -height; |
124 bmi_.bmiHeader.biSizeImage = width * height * 4; | 124 bmi_.bmiHeader.biSizeImage = width * height * 4; |
125 | 125 |
126 image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]); | 126 image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); |
127 } | 127 } |
128 | 128 |
129 GdiVideoRenderer::VideoWindow::~VideoWindow() { | 129 GdiVideoRenderer::VideoWindow::~VideoWindow() { |
130 // Context: caller Thread. We cannot call Destroy() since the window was | 130 // Context: caller Thread. We cannot call Destroy() since the window was |
131 // created by another thread. Instead, we send WM_CLOSE message. | 131 // created by another thread. Instead, we send WM_CLOSE message. |
132 if (handle()) { | 132 if (handle()) { |
133 SendMessage(handle(), WM_CLOSE, 0, 0); | 133 SendMessage(handle(), WM_CLOSE, 0, 0); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 width + ptDiff.x, height + ptDiff.y, false); | 230 width + ptDiff.x, height + ptDiff.y, false); |
231 UpdateWindow(handle()); | 231 UpdateWindow(handle()); |
232 ShowWindow(handle(), SW_SHOW); | 232 ShowWindow(handle(), SW_SHOW); |
233 | 233 |
234 if (frame_changed && (width != bmi_.bmiHeader.biWidth || | 234 if (frame_changed && (width != bmi_.bmiHeader.biWidth || |
235 height != -bmi_.bmiHeader.biHeight)) { | 235 height != -bmi_.bmiHeader.biHeight)) { |
236 // Update the bmi and image buffer | 236 // Update the bmi and image buffer |
237 bmi_.bmiHeader.biWidth = width; | 237 bmi_.bmiHeader.biWidth = width; |
238 bmi_.bmiHeader.biHeight = -height; | 238 bmi_.bmiHeader.biHeight = -height; |
239 bmi_.bmiHeader.biSizeImage = width * height * 4; | 239 bmi_.bmiHeader.biSizeImage = width * height * 4; |
240 image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]); | 240 image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { | 244 void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { |
245 if (!frame) { | 245 if (!frame) { |
246 return; | 246 return; |
247 } | 247 } |
248 // Convert frame to ARGB format, which is accepted by GDI | 248 // Convert frame to ARGB format, which is accepted by GDI |
249 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, image_.get(), | 249 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, image_.get(), |
250 bmi_.bmiHeader.biSizeImage, | 250 bmi_.bmiHeader.biSizeImage, |
(...skipping 19 matching lines...) Expand all Loading... |
270 | 270 |
271 bool GdiVideoRenderer::RenderFrame(const VideoFrame* frame) { | 271 bool GdiVideoRenderer::RenderFrame(const VideoFrame* frame) { |
272 if (!frame || !window_.get()) { | 272 if (!frame || !window_.get()) { |
273 return false; | 273 return false; |
274 } | 274 } |
275 return window_->RenderFrame(frame); | 275 return window_->RenderFrame(frame); |
276 } | 276 } |
277 | 277 |
278 } // namespace cricket | 278 } // namespace cricket |
279 #endif // WIN32 | 279 #endif // WIN32 |
OLD | NEW |