| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/protobuf_video_reader.h" | 5 #include "remoting/protocol/protobuf_video_reader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "net/socket/stream_socket.h" | 8 #include "net/socket/stream_socket.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 channel_factory_->CancelChannelCreation(kVideoChannelName); | 25 channel_factory_->CancelChannelCreation(kVideoChannelName); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ProtobufVideoReader::Init(protocol::Session* session, | 28 void ProtobufVideoReader::Init(protocol::Session* session, |
| 29 VideoStub* video_stub, | 29 VideoStub* video_stub, |
| 30 const InitializedCallback& callback) { | 30 const InitializedCallback& callback) { |
| 31 channel_factory_ = session->GetTransportChannelFactory(); | 31 channel_factory_ = session->GetTransportChannelFactory(); |
| 32 initialized_callback_ = callback; | 32 initialized_callback_ = callback; |
| 33 video_stub_ = video_stub; | 33 video_stub_ = video_stub; |
| 34 | 34 |
| 35 channel_factory_->CreateStreamChannel( | 35 channel_factory_->CreateChannel( |
| 36 kVideoChannelName, | 36 kVideoChannelName, |
| 37 base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this))); | 37 base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this))); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool ProtobufVideoReader::is_connected() { | 40 bool ProtobufVideoReader::is_connected() { |
| 41 return channel_.get() != NULL; | 41 return channel_.get() != NULL; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void ProtobufVideoReader::OnChannelReady(scoped_ptr<net::StreamSocket> socket) { | 44 void ProtobufVideoReader::OnChannelReady(scoped_ptr<net::StreamSocket> socket) { |
| 45 if (!socket.get()) { | 45 if (!socket.get()) { |
| 46 initialized_callback_.Run(false); | 46 initialized_callback_.Run(false); |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 | 49 |
| 50 DCHECK(!channel_.get()); | 50 DCHECK(!channel_.get()); |
| 51 channel_ = socket.Pass(); | 51 channel_ = socket.Pass(); |
| 52 reader_.Init(channel_.get(), base::Bind(&ProtobufVideoReader::OnNewData, | 52 reader_.Init(channel_.get(), base::Bind(&ProtobufVideoReader::OnNewData, |
| 53 base::Unretained(this))); | 53 base::Unretained(this))); |
| 54 initialized_callback_.Run(true); | 54 initialized_callback_.Run(true); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ProtobufVideoReader::OnNewData(scoped_ptr<VideoPacket> packet, | 57 void ProtobufVideoReader::OnNewData(scoped_ptr<VideoPacket> packet, |
| 58 const base::Closure& done_task) { | 58 const base::Closure& done_task) { |
| 59 video_stub_->ProcessVideoPacket(packet.Pass(), done_task); | 59 video_stub_->ProcessVideoPacket(packet.Pass(), done_task); |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace protocol | 62 } // namespace protocol |
| 63 } // namespace remoting | 63 } // namespace remoting |
| OLD | NEW |