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

Side by Side Diff: webrtc/media/devices/gtkvideorenderer.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 (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 // Implementation of GtkVideoRenderer 11 // Implementation of GtkVideoRenderer
12 12
13 #include "webrtc/media/devices/gtkvideorenderer.h" 13 #include "webrtc/media/devices/gtkvideorenderer.h"
14 14
15 #include <gdk/gdk.h> 15 #include <gdk/gdk.h>
16 #include <glib.h> 16 #include <glib.h>
17 #include <gtk/gtk.h> 17 #include <gtk/gtk.h>
18 18
19 #include "webrtc/media/base/videocommon.h" 19 #include "webrtc/media/base/videocommon.h"
20 #include "webrtc/media/base/videoframe.h" 20 #include "webrtc/media/engine/webrtcvideoframe.h"
21 21
22 namespace cricket { 22 namespace cricket {
23 23
24 class ScopedGdkLock { 24 class ScopedGdkLock {
25 public: 25 public:
26 ScopedGdkLock() { 26 ScopedGdkLock() {
27 gdk_threads_enter(); 27 gdk_threads_enter();
28 } 28 }
29 29
30 ~ScopedGdkLock() { 30 ~ScopedGdkLock() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 image_.reset(new uint8_t[width * height * 4]); 75 image_.reset(new uint8_t[width * height * 4]);
76 gtk_widget_set_size_request(draw_area_, width, height); 76 gtk_widget_set_size_request(draw_area_, width, height);
77 77
78 width_ = width; 78 width_ = width;
79 height_ = height; 79 height_ = height;
80 return true; 80 return true;
81 } 81 }
82 82
83 void GtkVideoRenderer::OnFrame(const VideoFrame& video_frame) { 83 void GtkVideoRenderer::OnFrame(const VideoFrame& video_frame) {
84 const VideoFrame* frame = video_frame.GetCopyWithRotationApplied(); 84 const cricket::WebRtcVideoFrame frame(
85 webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(),
86 video_frame.rotation()),
87 webrtc::kVideoRotation_0, video_frame.timestamp_us());
85 88
86 // Need to set size as the frame might be rotated. 89 // Need to set size as the frame might be rotated.
87 if (!SetSize(frame->width(), frame->height())) { 90 if (!SetSize(frame.width(), frame.height())) {
88 return; 91 return;
89 } 92 }
90 93
91 // convert I420 frame to ABGR format, which is accepted by GTK 94 // convert I420 frame to ABGR format, which is accepted by GTK
92 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR, 95 frame.ConvertToRgbBuffer(cricket::FOURCC_ABGR,
93 image_.get(), 96 image_.get(),
94 static_cast<size_t>(frame->width()) * 97 static_cast<size_t>(frame.width()) *
95 frame->height() * 4, 98 frame.height() * 4,
96 frame->width() * 4); 99 frame.width() * 4);
97 100
98 ScopedGdkLock lock; 101 ScopedGdkLock lock;
99 102
100 if (IsClosed()) { 103 if (IsClosed()) {
101 return; 104 return;
102 } 105 }
103 106
104 // draw the ABGR image 107 // draw the ABGR image
105 gdk_draw_rgb_32_image(draw_area_->window, 108 gdk_draw_rgb_32_image(draw_area_->window,
106 draw_area_->style->fg_gc[GTK_STATE_NORMAL], 109 draw_area_->style->fg_gc[GTK_STATE_NORMAL],
107 0, 110 0,
108 0, 111 0,
109 frame->width(), 112 frame.width(),
110 frame->height(), 113 frame.height(),
111 GDK_RGB_DITHER_MAX, 114 GDK_RGB_DITHER_MAX,
112 image_.get(), 115 image_.get(),
113 frame->width() * 4); 116 frame.width() * 4);
114 117
115 // Run the Gtk main loop to refresh the window. 118 // Run the Gtk main loop to refresh the window.
116 Pump(); 119 Pump();
117 } 120 }
118 121
119 bool GtkVideoRenderer::Initialize(int width, int height) { 122 bool GtkVideoRenderer::Initialize(int width, int height) {
120 gtk_init(NULL, NULL); 123 gtk_init(NULL, NULL);
121 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); 124 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
122 draw_area_ = gtk_drawing_area_new(); 125 draw_area_ = gtk_drawing_area_new();
123 if (!window_ || !draw_area_) { 126 if (!window_ || !draw_area_) {
(...skipping 25 matching lines...) Expand all
149 } 152 }
150 153
151 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) { 154 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) {
152 return true; 155 return true;
153 } 156 }
154 157
155 return false; 158 return false;
156 } 159 }
157 160
158 } // namespace cricket 161 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/devices/gdivideorenderer.cc ('k') | webrtc/media/engine/webrtcvideoframe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698