Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: remoting/protocol/protobuf_video_reader.cc

Issue 10823323: Add support for multiplexed channels in remoting::protocol::Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/protobuf_video_reader.h ('k') | remoting/protocol/protobuf_video_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "remoting/protocol/channel_factory.h"
11 #include "remoting/protocol/session.h" 12 #include "remoting/protocol/session.h"
12 13
13 namespace remoting { 14 namespace remoting {
14 namespace protocol { 15 namespace protocol {
15 16
16 ProtobufVideoReader::ProtobufVideoReader(VideoPacketFormat::Encoding encoding) 17 ProtobufVideoReader::ProtobufVideoReader(VideoPacketFormat::Encoding encoding)
17 : session_(NULL), 18 : encoding_(encoding),
18 encoding_(encoding), 19 channel_factory_(NULL),
19 video_stub_(NULL) { 20 video_stub_(NULL) {
20 } 21 }
21 22
22 ProtobufVideoReader::~ProtobufVideoReader() { 23 ProtobufVideoReader::~ProtobufVideoReader() {
23 if (session_) 24 if (channel_factory_)
24 session_->CancelChannelCreation(kVideoChannelName); 25 channel_factory_->CancelChannelCreation(kVideoChannelName);
25 } 26 }
26 27
27 void ProtobufVideoReader::Init(protocol::Session* session, 28 void ProtobufVideoReader::Init(protocol::Session* session,
28 VideoStub* video_stub, 29 VideoStub* video_stub,
29 const InitializedCallback& callback) { 30 const InitializedCallback& callback) {
30 session_ = session; 31 channel_factory_ = session->GetTransportChannelFactory();
31 initialized_callback_ = callback; 32 initialized_callback_ = callback;
32 video_stub_ = video_stub; 33 video_stub_ = video_stub;
33 34
34 session_->CreateStreamChannel( 35 channel_factory_->CreateStreamChannel(
35 kVideoChannelName, 36 kVideoChannelName,
36 base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this))); 37 base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this)));
37 } 38 }
38 39
39 bool ProtobufVideoReader::is_connected() { 40 bool ProtobufVideoReader::is_connected() {
40 return channel_.get() != NULL; 41 return channel_.get() != NULL;
41 } 42 }
42 43
43 void ProtobufVideoReader::OnChannelReady(scoped_ptr<net::StreamSocket> socket) { 44 void ProtobufVideoReader::OnChannelReady(scoped_ptr<net::StreamSocket> socket) {
44 if (!socket.get()) { 45 if (!socket.get()) {
45 initialized_callback_.Run(false); 46 initialized_callback_.Run(false);
46 return; 47 return;
47 } 48 }
48 49
49 DCHECK(!channel_.get()); 50 DCHECK(!channel_.get());
50 channel_ = socket.Pass(); 51 channel_ = socket.Pass();
51 reader_.Init(channel_.get(), base::Bind(&ProtobufVideoReader::OnNewData, 52 reader_.Init(channel_.get(), base::Bind(&ProtobufVideoReader::OnNewData,
52 base::Unretained(this))); 53 base::Unretained(this)));
53 initialized_callback_.Run(true); 54 initialized_callback_.Run(true);
54 } 55 }
55 56
56 void ProtobufVideoReader::OnNewData(scoped_ptr<VideoPacket> packet, 57 void ProtobufVideoReader::OnNewData(scoped_ptr<VideoPacket> packet,
57 const base::Closure& done_task) { 58 const base::Closure& done_task) {
58 video_stub_->ProcessVideoPacket(packet.Pass(), done_task); 59 video_stub_->ProcessVideoPacket(packet.Pass(), done_task);
59 } 60 }
60 61
61 } // namespace protocol 62 } // namespace protocol
62 } // namespace remoting 63 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/protobuf_video_reader.h ('k') | remoting/protocol/protobuf_video_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698