| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/webrtc_video_renderer_adapter.h" | 5 #include "remoting/protocol/webrtc_video_renderer_adapter.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 DCHECK(task_runner_->BelongsToCurrentThread()); | 48 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void WebrtcVideoRendererAdapter::OnFrame(const cricket::VideoFrame& frame) { | 51 void WebrtcVideoRendererAdapter::OnFrame(const cricket::VideoFrame& frame) { |
| 52 // TODO(sergeyu): WebRTC calls OnFrame on a separate thread it creates. | 52 // TODO(sergeyu): WebRTC calls OnFrame on a separate thread it creates. |
| 53 // FrameConsumer normally expects to be called on the network thread, so we | 53 // FrameConsumer normally expects to be called on the network thread, so we |
| 54 // cannot call FrameConsumer::AllocateFrame() here and instead | 54 // cannot call FrameConsumer::AllocateFrame() here and instead |
| 55 // BasicDesktopFrame is created directly. This will not work correctly with | 55 // BasicDesktopFrame is created directly. This will not work correctly with |
| 56 // all FrameConsumer implementations. Fix this somehow. | 56 // all FrameConsumer implementations. Fix this somehow. |
| 57 std::unique_ptr<webrtc::DesktopFrame> rgb_frame(new webrtc::BasicDesktopFrame( | 57 std::unique_ptr<webrtc::DesktopFrame> rgb_frame(new webrtc::BasicDesktopFrame( |
| 58 webrtc::DesktopSize(frame.GetWidth(), frame.GetHeight()))); | 58 webrtc::DesktopSize(frame.width(), frame.height()))); |
| 59 | 59 |
| 60 frame.ConvertToRgbBuffer( | 60 frame.ConvertToRgbBuffer( |
| 61 output_format_fourcc_, rgb_frame->data(), | 61 output_format_fourcc_, rgb_frame->data(), |
| 62 std::abs(rgb_frame->stride()) * rgb_frame->size().height(), | 62 std::abs(rgb_frame->stride()) * rgb_frame->size().height(), |
| 63 rgb_frame->stride()); | 63 rgb_frame->stride()); |
| 64 rgb_frame->mutable_updated_region()->AddRect( | 64 rgb_frame->mutable_updated_region()->AddRect( |
| 65 webrtc::DesktopRect::MakeSize(rgb_frame->size())); | 65 webrtc::DesktopRect::MakeSize(rgb_frame->size())); |
| 66 task_runner_->PostTask( | 66 task_runner_->PostTask( |
| 67 FROM_HERE, | 67 FROM_HERE, |
| 68 base::Bind(&WebrtcVideoRendererAdapter::DrawFrame, | 68 base::Bind(&WebrtcVideoRendererAdapter::DrawFrame, |
| 69 weak_factory_.GetWeakPtr(), base::Passed(&rgb_frame))); | 69 weak_factory_.GetWeakPtr(), base::Passed(&rgb_frame))); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void WebrtcVideoRendererAdapter::DrawFrame( | 72 void WebrtcVideoRendererAdapter::DrawFrame( |
| 73 std::unique_ptr<webrtc::DesktopFrame> frame) { | 73 std::unique_ptr<webrtc::DesktopFrame> frame) { |
| 74 DCHECK(task_runner_->BelongsToCurrentThread()); | 74 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 75 frame_consumer_->DrawFrame(std::move(frame), base::Closure()); | 75 frame_consumer_->DrawFrame(std::move(frame), base::Closure()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace remoting | 78 } // namespace remoting |
| 79 } // namespace protocol | 79 } // namespace protocol |
| OLD | NEW |