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_reader.h" | 5 #include "remoting/protocol/protobuf_video_reader.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 19 matching lines...) Expand all Loading... |
30 const InitializedCallback& callback) { | 30 const InitializedCallback& callback) { |
31 session_ = session; | 31 session_ = session; |
32 initialized_callback_ = callback; | 32 initialized_callback_ = callback; |
33 video_stub_ = video_stub; | 33 video_stub_ = video_stub; |
34 | 34 |
35 session_->CreateStreamChannel( | 35 session_->CreateStreamChannel( |
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() { |
| 41 return channel_.get() != NULL; |
| 42 } |
| 43 |
40 void ProtobufVideoReader::OnChannelReady(net::StreamSocket* socket) { | 44 void ProtobufVideoReader::OnChannelReady(net::StreamSocket* socket) { |
41 if (!socket) { | 45 if (!socket) { |
42 initialized_callback_.Run(false); | 46 initialized_callback_.Run(false); |
43 return; | 47 return; |
44 } | 48 } |
45 | 49 |
46 DCHECK(!channel_.get()); | 50 DCHECK(!channel_.get()); |
47 channel_.reset(socket); | 51 channel_.reset(socket); |
48 reader_.Init(socket, base::Bind(&ProtobufVideoReader::OnNewData, | 52 reader_.Init(socket, base::Bind(&ProtobufVideoReader::OnNewData, |
49 base::Unretained(this))); | 53 base::Unretained(this))); |
50 initialized_callback_.Run(true); | 54 initialized_callback_.Run(true); |
51 } | 55 } |
52 | 56 |
53 void ProtobufVideoReader::OnNewData(VideoPacket* packet, | 57 void ProtobufVideoReader::OnNewData(VideoPacket* packet, |
54 const base::Closure& done_task) { | 58 const base::Closure& done_task) { |
55 video_stub_->ProcessVideoPacket(packet, done_task); | 59 video_stub_->ProcessVideoPacket(packet, done_task); |
56 } | 60 } |
57 | 61 |
58 } // namespace protocol | 62 } // namespace protocol |
59 } // namespace remoting | 63 } // namespace remoting |
OLD | NEW |