| OLD | NEW |
| 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 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 image_.reset(new uint8_t[width * height * 4]); | 479 image_.reset(new uint8_t[width * height * 4]); |
| 480 gdk_threads_leave(); | 480 gdk_threads_leave(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void GtkMainWnd::VideoRenderer::OnFrame( | 483 void GtkMainWnd::VideoRenderer::OnFrame( |
| 484 const cricket::VideoFrame& video_frame) { | 484 const cricket::VideoFrame& video_frame) { |
| 485 gdk_threads_enter(); | 485 gdk_threads_enter(); |
| 486 | 486 |
| 487 const cricket::VideoFrame* frame = video_frame.GetCopyWithRotationApplied(); | 487 const cricket::VideoFrame* frame = video_frame.GetCopyWithRotationApplied(); |
| 488 | 488 |
| 489 SetSize(static_cast<int>(frame->GetWidth()), | 489 SetSize(frame->width(), frame->height()); |
| 490 static_cast<int>(frame->GetHeight())); | |
| 491 | 490 |
| 492 int size = width_ * height_ * 4; | 491 int size = width_ * height_ * 4; |
| 493 // TODO(henrike): Convert directly to RGBA | 492 // TODO(henrike): Convert directly to RGBA |
| 494 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, | 493 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, |
| 495 image_.get(), | 494 image_.get(), |
| 496 size, | 495 size, |
| 497 width_ * 4); | 496 width_ * 4); |
| 498 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. | 497 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. |
| 499 // The 'A' is just padding for GTK, so we can use it as temp. | 498 // The 'A' is just padding for GTK, so we can use it as temp. |
| 500 uint8_t* pix = image_.get(); | 499 uint8_t* pix = image_.get(); |
| 501 uint8_t* end = image_.get() + size; | 500 uint8_t* end = image_.get() + size; |
| 502 while (pix < end) { | 501 while (pix < end) { |
| 503 pix[3] = pix[0]; // Save B to A. | 502 pix[3] = pix[0]; // Save B to A. |
| 504 pix[0] = pix[2]; // Set Red. | 503 pix[0] = pix[2]; // Set Red. |
| 505 pix[2] = pix[3]; // Set Blue. | 504 pix[2] = pix[3]; // Set Blue. |
| 506 pix[3] = 0xFF; // Fixed Alpha. | 505 pix[3] = 0xFF; // Fixed Alpha. |
| 507 pix += 4; | 506 pix += 4; |
| 508 } | 507 } |
| 509 | 508 |
| 510 gdk_threads_leave(); | 509 gdk_threads_leave(); |
| 511 | 510 |
| 512 g_idle_add(Redraw, main_wnd_); | 511 g_idle_add(Redraw, main_wnd_); |
| 513 } | 512 } |
| OLD | NEW |