OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/client_video_dispatcher.h" | 5 #include "remoting/protocol/client_video_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "net/socket/stream_socket.h" | 9 #include "net/socket/stream_socket.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 void ClientVideoDispatcher::ProcessVideoPacket( | 38 void ClientVideoDispatcher::ProcessVideoPacket( |
39 scoped_ptr<VideoPacket> video_packet, | 39 scoped_ptr<VideoPacket> video_packet, |
40 const base::Closure& done) { | 40 const base::Closure& done) { |
41 base::ScopedClosureRunner done_runner(done); | 41 base::ScopedClosureRunner done_runner(done); |
42 | 42 |
43 int frame_id = video_packet->frame_id(); | 43 int frame_id = video_packet->frame_id(); |
44 | 44 |
45 if (!video_packet->has_frame_id()) { | 45 if (!video_packet->has_frame_id()) { |
46 video_stub_->ProcessVideoPacket(video_packet.Pass(), done_runner.Release()); | 46 video_stub_->ProcessVideoPacket(std::move(video_packet), |
| 47 done_runner.Release()); |
47 return; | 48 return; |
48 } | 49 } |
49 | 50 |
50 PendingFramesList::iterator pending_frame = | 51 PendingFramesList::iterator pending_frame = |
51 pending_frames_.insert(pending_frames_.end(), PendingFrame(frame_id)); | 52 pending_frames_.insert(pending_frames_.end(), PendingFrame(frame_id)); |
52 | 53 |
53 video_stub_->ProcessVideoPacket( | 54 video_stub_->ProcessVideoPacket( |
54 video_packet.Pass(), | 55 std::move(video_packet), |
55 base::Bind(&ClientVideoDispatcher::OnPacketDone, | 56 base::Bind(&ClientVideoDispatcher::OnPacketDone, |
56 weak_factory_.GetWeakPtr(), pending_frame)); | 57 weak_factory_.GetWeakPtr(), pending_frame)); |
57 } | 58 } |
58 | 59 |
59 void ClientVideoDispatcher::OnPacketDone( | 60 void ClientVideoDispatcher::OnPacketDone( |
60 PendingFramesList::iterator pending_frame) { | 61 PendingFramesList::iterator pending_frame) { |
61 // Mark the frame as done. | 62 // Mark the frame as done. |
62 DCHECK(!pending_frame->done); | 63 DCHECK(!pending_frame->done); |
63 pending_frame->done = true; | 64 pending_frame->done = true; |
64 | 65 |
65 // Send VideoAck for all packets in the head of the queue that have finished | 66 // Send VideoAck for all packets in the head of the queue that have finished |
66 // rendering. | 67 // rendering. |
67 while (!pending_frames_.empty() && pending_frames_.front().done) { | 68 while (!pending_frames_.empty() && pending_frames_.front().done) { |
68 VideoAck ack_message; | 69 VideoAck ack_message; |
69 ack_message.set_frame_id(pending_frames_.front().frame_id); | 70 ack_message.set_frame_id(pending_frames_.front().frame_id); |
70 writer()->Write(SerializeAndFrameMessage(ack_message), base::Closure()); | 71 writer()->Write(SerializeAndFrameMessage(ack_message), base::Closure()); |
71 pending_frames_.pop_front(); | 72 pending_frames_.pop_front(); |
72 } | 73 } |
73 } | 74 } |
74 | 75 |
75 } // namespace protocol | 76 } // namespace protocol |
76 } // namespace remoting | 77 } // namespace remoting |
OLD | NEW |