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 (!size_callback_.is_null()) | |
125 size_callback_.Run(frame->size()); | |
Jamie
2015/11/25 01:32:46
You're calling this on every capture, not just whe
Sergey Ulanov
2015/11/27 22:11:34
Done.
| |
126 | |
119 // Even when |frame| is nullptr we still need to post it to the encode thread | 127 // 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 | 128 // 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. | 129 // that we don't start capturing frame n+2 before frame n is freed. |
122 base::PostTaskAndReplyWithResult( | 130 base::PostTaskAndReplyWithResult( |
123 encode_task_runner_.get(), FROM_HERE, | 131 encode_task_runner_.get(), FROM_HERE, |
124 base::Bind(&VideoFramePump::EncodeFrame, encoder_.get(), | 132 base::Bind(&VideoFramePump::EncodeFrame, encoder_.get(), |
125 base::Passed(make_scoped_ptr(frame)), | 133 base::Passed(make_scoped_ptr(frame)), |
126 base::Passed(&captured_frame_timestamps_)), | 134 base::Passed(&captured_frame_timestamps_)), |
127 base::Bind(&VideoFramePump::OnFrameEncoded, weak_factory_.GetWeakPtr())); | 135 base::Bind(&VideoFramePump::OnFrameEncoded, weak_factory_.GetWeakPtr())); |
128 } | 136 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 } | 257 } |
250 | 258 |
251 void VideoFramePump::OnKeepAlivePacketSent() { | 259 void VideoFramePump::OnKeepAlivePacketSent() { |
252 DCHECK(thread_checker_.CalledOnValidThread()); | 260 DCHECK(thread_checker_.CalledOnValidThread()); |
253 | 261 |
254 keep_alive_timer_.Reset(); | 262 keep_alive_timer_.Reset(); |
255 } | 263 } |
256 | 264 |
257 } // namespace protocol | 265 } // namespace protocol |
258 } // namespace remoting | 266 } // namespace remoting |
OLD | NEW |