Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: webrtc/examples/peerconnection/client/linux/main_wnd.cc

Issue 2285693002: New static I420Buffer::Rotate method, to replace GetCopyWithRotationApplied. (Closed)
Patch Set: Change back to static method, now in I420Buffer. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "webrtc/examples/peerconnection/client/linux/main_wnd.h" 11 #include "webrtc/examples/peerconnection/client/linux/main_wnd.h"
12 12
13 #include <gdk/gdkkeysyms.h> 13 #include <gdk/gdkkeysyms.h>
14 #include <gtk/gtk.h> 14 #include <gtk/gtk.h>
15 #include <stddef.h> 15 #include <stddef.h>
16 16
17 #include "webrtc/examples/peerconnection/client/defaults.h" 17 #include "webrtc/examples/peerconnection/client/defaults.h"
18 #include "webrtc/base/common.h" 18 #include "webrtc/base/common.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/stringutils.h" 20 #include "webrtc/base/stringutils.h"
21 #include "webrtc/media/engine/webrtcvideoframe.h"
21 22
22 using rtc::sprintfn; 23 using rtc::sprintfn;
23 24
24 namespace { 25 namespace {
25 26
26 // 27 //
27 // Simple static functions that simply forward the callback to the 28 // Simple static functions that simply forward the callback to the
28 // GtkMainWnd instance. 29 // GtkMainWnd instance.
29 // 30 //
30 31
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 width_ = width; 478 width_ = width;
478 height_ = height; 479 height_ = height;
479 image_.reset(new uint8_t[width * height * 4]); 480 image_.reset(new uint8_t[width * height * 4]);
480 gdk_threads_leave(); 481 gdk_threads_leave();
481 } 482 }
482 483
483 void GtkMainWnd::VideoRenderer::OnFrame( 484 void GtkMainWnd::VideoRenderer::OnFrame(
484 const cricket::VideoFrame& video_frame) { 485 const cricket::VideoFrame& video_frame) {
485 gdk_threads_enter(); 486 gdk_threads_enter();
486 487
487 const cricket::VideoFrame* frame = video_frame.GetCopyWithRotationApplied(); 488 const cricket::WebRtcVideoFrame frame(
489 webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(),
490 video_frame.rotation()),
491 webrtc::kVideoRotation_0, video_frame.timestamp_us());
488 492
489 SetSize(frame->width(), frame->height()); 493 SetSize(frame.width(), frame.height());
490 494
491 int size = width_ * height_ * 4; 495 int size = width_ * height_ * 4;
492 // TODO(henrike): Convert directly to RGBA 496 // TODO(henrike): Convert directly to RGBA
493 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, 497 frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB,
494 image_.get(), 498 image_.get(),
495 size, 499 size,
496 width_ * 4); 500 width_ * 4);
497 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. 501 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK.
498 // The 'A' is just padding for GTK, so we can use it as temp. 502 // The 'A' is just padding for GTK, so we can use it as temp.
499 uint8_t* pix = image_.get(); 503 uint8_t* pix = image_.get();
500 uint8_t* end = image_.get() + size; 504 uint8_t* end = image_.get() + size;
501 while (pix < end) { 505 while (pix < end) {
502 pix[3] = pix[0]; // Save B to A. 506 pix[3] = pix[0]; // Save B to A.
503 pix[0] = pix[2]; // Set Red. 507 pix[0] = pix[2]; // Set Red.
504 pix[2] = pix[3]; // Set Blue. 508 pix[2] = pix[3]; // Set Blue.
505 pix[3] = 0xFF; // Fixed Alpha. 509 pix[3] = 0xFF; // Fixed Alpha.
506 pix += 4; 510 pix += 4;
507 } 511 }
508 512
509 gdk_threads_leave(); 513 gdk_threads_leave();
510 514
511 g_idle_add(Redraw, main_wnd_); 515 g_idle_add(Redraw, main_wnd_);
512 } 516 }
OLDNEW
« no previous file with comments | « webrtc/common_video/video_frame_buffer.cc ('k') | webrtc/examples/peerconnection/client/main_wnd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698