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

Side by Side Diff: webrtc/media/devices/gtkvideorenderer.cc

Issue 1819103003: Delete cricket::VideoRenderer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 9 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
« no previous file with comments | « webrtc/media/devices/gtkvideorenderer.h ('k') | webrtc/media/devices/videorendererfactory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 if (window_) { 52 if (window_) {
53 ScopedGdkLock lock; 53 ScopedGdkLock lock;
54 gtk_widget_destroy(window_); 54 gtk_widget_destroy(window_);
55 // Run the Gtk main loop to tear down the window. 55 // Run the Gtk main loop to tear down the window.
56 Pump(); 56 Pump();
57 } 57 }
58 // Don't need to destroy draw_area_ because it is not top-level, so it is 58 // Don't need to destroy draw_area_ because it is not top-level, so it is
59 // implicitly destroyed by the above. 59 // implicitly destroyed by the above.
60 } 60 }
61 61
62 bool GtkVideoRenderer::SetSize(int width, int height, int reserved) { 62 bool GtkVideoRenderer::SetSize(int width, int height) {
63 ScopedGdkLock lock; 63 ScopedGdkLock lock;
64 64
65 // If the dimension is the same, no-op. 65 // If the dimension is the same, no-op.
66 if (width_ == width && height_ == height) { 66 if (width_ == width && height_ == height) {
67 return true; 67 return true;
68 } 68 }
69 69
70 // For the first frame, initialize the GTK window 70 // For the first frame, initialize the GTK window
71 if ((!window_ && !Initialize(width, height)) || IsClosed()) { 71 if ((!window_ && !Initialize(width, height)) || IsClosed()) {
72 return false; 72 return false;
73 } 73 }
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 bool GtkVideoRenderer::RenderFrame(const VideoFrame* video_frame) { 83 void GtkVideoRenderer::OnFrame(const VideoFrame& video_frame) {
84 if (!video_frame) { 84 const VideoFrame* frame = video_frame.GetCopyWithRotationApplied();
85 return false;
86 }
87
88 const VideoFrame* frame = video_frame->GetCopyWithRotationApplied();
89 85
90 // Need to set size as the frame might be rotated. 86 // Need to set size as the frame might be rotated.
91 if (!SetSize(frame->GetWidth(), frame->GetHeight(), 0)) { 87 if (!SetSize(frame->GetWidth(), frame->GetHeight())) {
92 return false; 88 return;
93 } 89 }
94 90
95 // convert I420 frame to ABGR format, which is accepted by GTK 91 // convert I420 frame to ABGR format, which is accepted by GTK
96 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR, 92 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR,
97 image_.get(), 93 image_.get(),
98 frame->GetWidth() * frame->GetHeight() * 4, 94 frame->GetWidth() * frame->GetHeight() * 4,
99 frame->GetWidth() * 4); 95 frame->GetWidth() * 4);
100 96
101 ScopedGdkLock lock; 97 ScopedGdkLock lock;
102 98
103 if (IsClosed()) { 99 if (IsClosed()) {
104 return false; 100 return;
105 } 101 }
106 102
107 // draw the ABGR image 103 // draw the ABGR image
108 gdk_draw_rgb_32_image(draw_area_->window, 104 gdk_draw_rgb_32_image(draw_area_->window,
109 draw_area_->style->fg_gc[GTK_STATE_NORMAL], 105 draw_area_->style->fg_gc[GTK_STATE_NORMAL],
110 0, 106 0,
111 0, 107 0,
112 frame->GetWidth(), 108 frame->GetWidth(),
113 frame->GetHeight(), 109 frame->GetHeight(),
114 GDK_RGB_DITHER_MAX, 110 GDK_RGB_DITHER_MAX,
115 image_.get(), 111 image_.get(),
116 frame->GetWidth() * 4); 112 frame->GetWidth() * 4);
117 113
118 // Run the Gtk main loop to refresh the window. 114 // Run the Gtk main loop to refresh the window.
119 Pump(); 115 Pump();
120 return true;
121 } 116 }
122 117
123 bool GtkVideoRenderer::Initialize(int width, int height) { 118 bool GtkVideoRenderer::Initialize(int width, int height) {
124 gtk_init(NULL, NULL); 119 gtk_init(NULL, NULL);
125 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); 120 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
126 draw_area_ = gtk_drawing_area_new(); 121 draw_area_ = gtk_drawing_area_new();
127 if (!window_ || !draw_area_) { 122 if (!window_ || !draw_area_) {
128 return false; 123 return false;
129 } 124 }
130 125
(...skipping 22 matching lines...) Expand all
153 } 148 }
154 149
155 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) { 150 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) {
156 return true; 151 return true;
157 } 152 }
158 153
159 return false; 154 return false;
160 } 155 }
161 156
162 } // namespace cricket 157 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/devices/gtkvideorenderer.h ('k') | webrtc/media/devices/videorendererfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698