OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_writer.h" | 5 #include "remoting/protocol/protobuf_video_writer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/task.h" | 8 #include "base/task.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 16 matching lines...) Expand all Loading... |
27 void ProtobufVideoWriter::Init(protocol::Session* session, | 27 void ProtobufVideoWriter::Init(protocol::Session* session, |
28 const InitializedCallback& callback) { | 28 const InitializedCallback& callback) { |
29 session_ = session; | 29 session_ = session; |
30 initialized_callback_ = callback; | 30 initialized_callback_ = callback; |
31 | 31 |
32 session_->CreateStreamChannel( | 32 session_->CreateStreamChannel( |
33 kVideoChannelName, | 33 kVideoChannelName, |
34 base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this))); | 34 base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this))); |
35 } | 35 } |
36 | 36 |
| 37 bool ProtobufVideoWriter::is_connected() { |
| 38 return channel_.get() != NULL; |
| 39 } |
| 40 |
37 void ProtobufVideoWriter::OnChannelReady(net::StreamSocket* socket) { | 41 void ProtobufVideoWriter::OnChannelReady(net::StreamSocket* socket) { |
38 if (!socket) { | 42 if (!socket) { |
39 initialized_callback_.Run(false); | 43 initialized_callback_.Run(false); |
40 return; | 44 return; |
41 } | 45 } |
42 | 46 |
43 DCHECK(!channel_.get()); | 47 DCHECK(!channel_.get()); |
44 channel_.reset(socket); | 48 channel_.reset(socket); |
45 // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. | 49 // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. |
46 buffered_writer_->Init(socket, BufferedSocketWriter::WriteFailedCallback()); | 50 buffered_writer_->Init(socket, BufferedSocketWriter::WriteFailedCallback()); |
(...skipping 14 matching lines...) Expand all Loading... |
61 const base::Closure& done) { | 65 const base::Closure& done) { |
62 buffered_writer_->Write(SerializeAndFrameMessage(*packet), done); | 66 buffered_writer_->Write(SerializeAndFrameMessage(*packet), done); |
63 } | 67 } |
64 | 68 |
65 int ProtobufVideoWriter::GetPendingPackets() { | 69 int ProtobufVideoWriter::GetPendingPackets() { |
66 return buffered_writer_->GetBufferChunks(); | 70 return buffered_writer_->GetBufferChunks(); |
67 } | 71 } |
68 | 72 |
69 } // namespace protocol | 73 } // namespace protocol |
70 } // namespace remoting | 74 } // namespace remoting |
OLD | NEW |