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 |
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 "libyuv/convert_from.h" |
17 #include "webrtc/examples/peerconnection/client/defaults.h" | 18 #include "webrtc/examples/peerconnection/client/defaults.h" |
18 #include "webrtc/base/common.h" | 19 #include "webrtc/base/common.h" |
19 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
20 #include "webrtc/base/stringutils.h" | 21 #include "webrtc/base/stringutils.h" |
21 #include "webrtc/media/engine/webrtcvideoframe.h" | 22 #include "webrtc/media/engine/webrtcvideoframe.h" |
22 | 23 |
23 using rtc::sprintfn; | 24 using rtc::sprintfn; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 const cricket::VideoFrame& video_frame) { | 486 const cricket::VideoFrame& video_frame) { |
486 gdk_threads_enter(); | 487 gdk_threads_enter(); |
487 | 488 |
488 const cricket::WebRtcVideoFrame frame( | 489 const cricket::WebRtcVideoFrame frame( |
489 webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(), | 490 webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(), |
490 video_frame.rotation()), | 491 video_frame.rotation()), |
491 webrtc::kVideoRotation_0, video_frame.timestamp_us()); | 492 webrtc::kVideoRotation_0, video_frame.timestamp_us()); |
492 | 493 |
493 SetSize(frame.width(), frame.height()); | 494 SetSize(frame.width(), frame.height()); |
494 | 495 |
495 int size = width_ * height_ * 4; | 496 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( |
496 // TODO(henrike): Convert directly to RGBA | 497 frame.video_frame_buffer()); |
497 frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB, | 498 libyuv::I420ToRGBA(buffer->DataY(), buffer->StrideY(), |
498 image_.get(), | 499 buffer->DataU(), buffer->StrideU(), |
499 size, | 500 buffer->DataV(), buffer->StrideV(), |
500 width_ * 4); | 501 image_.get(), width_ * 4, |
501 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. | 502 buffer->width(), buffer->height()); |
502 // The 'A' is just padding for GTK, so we can use it as temp. | |
503 uint8_t* pix = image_.get(); | |
504 uint8_t* end = image_.get() + size; | |
505 while (pix < end) { | |
506 pix[3] = pix[0]; // Save B to A. | |
507 pix[0] = pix[2]; // Set Red. | |
508 pix[2] = pix[3]; // Set Blue. | |
509 pix[3] = 0xFF; // Fixed Alpha. | |
510 pix += 4; | |
511 } | |
512 | 503 |
513 gdk_threads_leave(); | 504 gdk_threads_leave(); |
514 | 505 |
515 g_idle_add(Redraw, main_wnd_); | 506 g_idle_add(Redraw, main_wnd_); |
516 } | 507 } |
OLD | NEW |