| 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/video_frame_pump.h" | 5 #include "remoting/protocol/video_frame_pump.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 void VideoFramePump::SetLosslessColor(bool want_lossless) { | 99 void VideoFramePump::SetLosslessColor(bool want_lossless) { |
| 100 DCHECK(thread_checker_.CalledOnValidThread()); | 100 DCHECK(thread_checker_.CalledOnValidThread()); |
| 101 | 101 |
| 102 encode_task_runner_->PostTask( | 102 encode_task_runner_->PostTask( |
| 103 FROM_HERE, base::Bind(&VideoEncoder::SetLosslessColor, | 103 FROM_HERE, base::Bind(&VideoEncoder::SetLosslessColor, |
| 104 base::Unretained(encoder_.get()), want_lossless)); | 104 base::Unretained(encoder_.get()), want_lossless)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void VideoFramePump::SetSizeCallback(const SizeCallback& size_callback) { |
| 108 DCHECK(thread_checker_.CalledOnValidThread()); |
| 109 size_callback_ = size_callback; |
| 110 } |
| 111 |
| 107 webrtc::SharedMemory* VideoFramePump::CreateSharedMemory(size_t size) { | 112 webrtc::SharedMemory* VideoFramePump::CreateSharedMemory(size_t size) { |
| 108 DCHECK(thread_checker_.CalledOnValidThread()); | 113 DCHECK(thread_checker_.CalledOnValidThread()); |
| 109 return nullptr; | 114 return nullptr; |
| 110 } | 115 } |
| 111 | 116 |
| 112 void VideoFramePump::OnCaptureCompleted(webrtc::DesktopFrame* frame) { | 117 void VideoFramePump::OnCaptureCompleted(webrtc::DesktopFrame* frame) { |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | 118 DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 | 119 |
| 115 capture_scheduler_.OnCaptureCompleted(); | 120 capture_scheduler_.OnCaptureCompleted(); |
| 116 | 121 |
| 117 captured_frame_timestamps_->capture_ended_time = base::TimeTicks::Now(); | 122 captured_frame_timestamps_->capture_ended_time = base::TimeTicks::Now(); |
| 118 | 123 |
| 124 if (frame && !frame_size_.equals(frame->size())) { |
| 125 frame_size_ = frame->size(); |
| 126 if (!size_callback_.is_null()) |
| 127 size_callback_.Run(frame_size_); |
| 128 } |
| 129 |
| 119 // Even when |frame| is nullptr we still need to post it to the encode thread | 130 // Even when |frame| is nullptr we still need to post it to the encode thread |
| 120 // to make sure frames are freed in the same order they are received and | 131 // to make sure frames are freed in the same order they are received and |
| 121 // that we don't start capturing frame n+2 before frame n is freed. | 132 // that we don't start capturing frame n+2 before frame n is freed. |
| 122 base::PostTaskAndReplyWithResult( | 133 base::PostTaskAndReplyWithResult( |
| 123 encode_task_runner_.get(), FROM_HERE, | 134 encode_task_runner_.get(), FROM_HERE, |
| 124 base::Bind(&VideoFramePump::EncodeFrame, encoder_.get(), | 135 base::Bind(&VideoFramePump::EncodeFrame, encoder_.get(), |
| 125 base::Passed(make_scoped_ptr(frame)), | 136 base::Passed(make_scoped_ptr(frame)), |
| 126 base::Passed(&captured_frame_timestamps_)), | 137 base::Passed(&captured_frame_timestamps_)), |
| 127 base::Bind(&VideoFramePump::OnFrameEncoded, weak_factory_.GetWeakPtr())); | 138 base::Bind(&VideoFramePump::OnFrameEncoded, weak_factory_.GetWeakPtr())); |
| 128 } | 139 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 260 } |
| 250 | 261 |
| 251 void VideoFramePump::OnKeepAlivePacketSent() { | 262 void VideoFramePump::OnKeepAlivePacketSent() { |
| 252 DCHECK(thread_checker_.CalledOnValidThread()); | 263 DCHECK(thread_checker_.CalledOnValidThread()); |
| 253 | 264 |
| 254 keep_alive_timer_.Reset(); | 265 keep_alive_timer_.Reset(); |
| 255 } | 266 } |
| 256 | 267 |
| 257 } // namespace protocol | 268 } // namespace protocol |
| 258 } // namespace remoting | 269 } // namespace remoting |
| OLD | NEW |