OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // If the dimension is the same, no-op. | 82 // If the dimension is the same, no-op. |
83 if (width_ == width && height_ == height) { | 83 if (width_ == width && height_ == height) { |
84 return true; | 84 return true; |
85 } | 85 } |
86 | 86 |
87 // For the first frame, initialize the GTK window | 87 // For the first frame, initialize the GTK window |
88 if ((!window_ && !Initialize(width, height)) || IsClosed()) { | 88 if ((!window_ && !Initialize(width, height)) || IsClosed()) { |
89 return false; | 89 return false; |
90 } | 90 } |
91 | 91 |
92 image_.reset(new uint8[width * height * 4]); | 92 image_.reset(new uint8_t[width * height * 4]); |
93 gtk_widget_set_size_request(draw_area_, width, height); | 93 gtk_widget_set_size_request(draw_area_, width, height); |
94 | 94 |
95 width_ = width; | 95 width_ = width; |
96 height_ = height; | 96 height_ = height; |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 bool GtkVideoRenderer::RenderFrame(const VideoFrame* video_frame) { | 100 bool GtkVideoRenderer::RenderFrame(const VideoFrame* video_frame) { |
101 if (!video_frame) { | 101 if (!video_frame) { |
102 return false; | 102 return false; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 gtk_window_set_position(GTK_WINDOW(window_), GTK_WIN_POS_CENTER); | 148 gtk_window_set_position(GTK_WINDOW(window_), GTK_WIN_POS_CENTER); |
149 gtk_window_set_title(GTK_WINDOW(window_), "Video Renderer"); | 149 gtk_window_set_title(GTK_WINDOW(window_), "Video Renderer"); |
150 gtk_window_set_resizable(GTK_WINDOW(window_), FALSE); | 150 gtk_window_set_resizable(GTK_WINDOW(window_), FALSE); |
151 gtk_widget_set_size_request(draw_area_, width, height); | 151 gtk_widget_set_size_request(draw_area_, width, height); |
152 gtk_container_add(GTK_CONTAINER(window_), draw_area_); | 152 gtk_container_add(GTK_CONTAINER(window_), draw_area_); |
153 gtk_widget_show_all(window_); | 153 gtk_widget_show_all(window_); |
154 gtk_window_move(GTK_WINDOW(window_), initial_x_, initial_y_); | 154 gtk_window_move(GTK_WINDOW(window_), initial_x_, initial_y_); |
155 | 155 |
156 image_.reset(new uint8[width * height * 4]); | 156 image_.reset(new uint8_t[width * height * 4]); |
157 return true; | 157 return true; |
158 } | 158 } |
159 | 159 |
160 void GtkVideoRenderer::Pump() { | 160 void GtkVideoRenderer::Pump() { |
161 while (gtk_events_pending()) { | 161 while (gtk_events_pending()) { |
162 gtk_main_iteration(); | 162 gtk_main_iteration(); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 bool GtkVideoRenderer::IsClosed() const { | 166 bool GtkVideoRenderer::IsClosed() const { |
167 if (!window_) { | 167 if (!window_) { |
168 // Not initialized yet, so hasn't been closed. | 168 // Not initialized yet, so hasn't been closed. |
169 return false; | 169 return false; |
170 } | 170 } |
171 | 171 |
172 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) { | 172 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) { |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
176 return false; | 176 return false; |
177 } | 177 } |
178 | 178 |
179 } // namespace cricket | 179 } // namespace cricket |
OLD | NEW |