| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 PendingFrame(int frame_id) | 21 PendingFrame(int frame_id) |
| 22 : frame_id(frame_id), | 22 : frame_id(frame_id), |
| 23 done(false) {} | 23 done(false) {} |
| 24 int frame_id; | 24 int frame_id; |
| 25 bool done; | 25 bool done; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 ClientVideoDispatcher::ClientVideoDispatcher(VideoStub* video_stub) | 28 ClientVideoDispatcher::ClientVideoDispatcher(VideoStub* video_stub) |
| 29 : ChannelDispatcherBase(kVideoChannelName), | 29 : ChannelDispatcherBase(kVideoChannelName), |
| 30 video_stub_(video_stub), | 30 video_stub_(video_stub), |
| 31 parser_(base::Bind(&ClientVideoDispatcher::ProcessVideoPacket, | |
| 32 base::Unretained(this)), | |
| 33 reader()), | |
| 34 weak_factory_(this) {} | 31 weak_factory_(this) {} |
| 35 | |
| 36 ClientVideoDispatcher::~ClientVideoDispatcher() {} | 32 ClientVideoDispatcher::~ClientVideoDispatcher() {} |
| 37 | 33 |
| 38 void ClientVideoDispatcher::ProcessVideoPacket( | 34 void ClientVideoDispatcher::OnIncomingMessage( |
| 39 scoped_ptr<VideoPacket> video_packet) { | 35 scoped_ptr<CompoundBuffer> message) { |
| 36 scoped_ptr<VideoPacket> video_packet = |
| 37 ParseMessage<VideoPacket>(message.get()); |
| 38 if (!video_packet) |
| 39 return; |
| 40 |
| 40 int frame_id = video_packet->frame_id(); | 41 int frame_id = video_packet->frame_id(); |
| 41 | 42 |
| 42 if (!video_packet->has_frame_id()) { | 43 if (!video_packet->has_frame_id()) { |
| 43 video_stub_->ProcessVideoPacket(std::move(video_packet), | 44 video_stub_->ProcessVideoPacket(std::move(video_packet), |
| 44 base::Bind(&base::DoNothing)); | 45 base::Bind(&base::DoNothing)); |
| 45 return; | 46 return; |
| 46 } | 47 } |
| 47 | 48 |
| 48 PendingFramesList::iterator pending_frame = | 49 PendingFramesList::iterator pending_frame = |
| 49 pending_frames_.insert(pending_frames_.end(), PendingFrame(frame_id)); | 50 pending_frames_.insert(pending_frames_.end(), PendingFrame(frame_id)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 while (!pending_frames_.empty() && pending_frames_.front().done) { | 66 while (!pending_frames_.empty() && pending_frames_.front().done) { |
| 66 VideoAck ack_message; | 67 VideoAck ack_message; |
| 67 ack_message.set_frame_id(pending_frames_.front().frame_id); | 68 ack_message.set_frame_id(pending_frames_.front().frame_id); |
| 68 writer()->Write(SerializeAndFrameMessage(ack_message), base::Closure()); | 69 writer()->Write(SerializeAndFrameMessage(ack_message), base::Closure()); |
| 69 pending_frames_.pop_front(); | 70 pending_frames_.pop_front(); |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 | 73 |
| 73 } // namespace protocol | 74 } // namespace protocol |
| 74 } // namespace remoting | 75 } // namespace remoting |
| OLD | NEW |