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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 gdk_threads_leave(); | 453 gdk_threads_leave(); |
454 } | 454 } |
455 | 455 |
456 GtkMainWnd::VideoRenderer::VideoRenderer( | 456 GtkMainWnd::VideoRenderer::VideoRenderer( |
457 GtkMainWnd* main_wnd, | 457 GtkMainWnd* main_wnd, |
458 webrtc::VideoTrackInterface* track_to_render) | 458 webrtc::VideoTrackInterface* track_to_render) |
459 : width_(0), | 459 : width_(0), |
460 height_(0), | 460 height_(0), |
461 main_wnd_(main_wnd), | 461 main_wnd_(main_wnd), |
462 rendered_track_(track_to_render) { | 462 rendered_track_(track_to_render) { |
463 rendered_track_->AddRenderer(this); | 463 rendered_track_->AddOrUpdateSink(this, rtc::VideoSinkWants()); |
464 } | 464 } |
465 | 465 |
466 GtkMainWnd::VideoRenderer::~VideoRenderer() { | 466 GtkMainWnd::VideoRenderer::~VideoRenderer() { |
467 rendered_track_->RemoveRenderer(this); | 467 rendered_track_->RemoveSink(this); |
468 } | 468 } |
469 | 469 |
470 void GtkMainWnd::VideoRenderer::SetSize(int width, int height) { | 470 void GtkMainWnd::VideoRenderer::SetSize(int width, int height) { |
471 gdk_threads_enter(); | 471 gdk_threads_enter(); |
472 | 472 |
473 if (width_ == width && height_ == height) { | 473 if (width_ == width && height_ == height) { |
474 return; | 474 return; |
475 } | 475 } |
476 | 476 |
477 width_ = width; | 477 width_ = width; |
478 height_ = height; | 478 height_ = height; |
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::RenderFrame( | 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(static_cast<int>(frame->GetWidth()), |
490 static_cast<int>(frame->GetHeight())); | 490 static_cast<int>(frame->GetHeight())); |
491 | 491 |
492 int size = width_ * height_ * 4; | 492 int size = width_ * height_ * 4; |
493 // TODO(henrike): Convert directly to RGBA | 493 // TODO(henrike): Convert directly to RGBA |
494 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, | 494 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, |
495 image_.get(), | 495 image_.get(), |
496 size, | 496 size, |
497 width_ * 4); | 497 width_ * 4); |
498 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. | 498 // 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. | 499 // The 'A' is just padding for GTK, so we can use it as temp. |
500 uint8_t* pix = image_.get(); | 500 uint8_t* pix = image_.get(); |
501 uint8_t* end = image_.get() + size; | 501 uint8_t* end = image_.get() + size; |
502 while (pix < end) { | 502 while (pix < end) { |
503 pix[3] = pix[0]; // Save B to A. | 503 pix[3] = pix[0]; // Save B to A. |
504 pix[0] = pix[2]; // Set Red. | 504 pix[0] = pix[2]; // Set Red. |
505 pix[2] = pix[3]; // Set Blue. | 505 pix[2] = pix[3]; // Set Blue. |
506 pix[3] = 0xFF; // Fixed Alpha. | 506 pix[3] = 0xFF; // Fixed Alpha. |
507 pix += 4; | 507 pix += 4; |
508 } | 508 } |
509 | 509 |
510 gdk_threads_leave(); | 510 gdk_threads_leave(); |
511 | 511 |
512 g_idle_add(Redraw, main_wnd_); | 512 g_idle_add(Redraw, main_wnd_); |
513 } | 513 } |
514 | |
515 | |
OLD | NEW |