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

Side by Side Diff: remoting/host/client_connection.cc

Issue 4229003: Add VideoReader and VideoWriter interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month 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/host/client_connection.h ('k') | remoting/host/mock_objects.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // TODO(hclam): Remove this header once MessageDispatcher is used. 5 // TODO(hclam): Remove this header once MessageDispatcher is used.
6 #include "remoting/base/multiple_array_input_stream.h" 6 #include "remoting/base/multiple_array_input_stream.h"
7 #include "remoting/host/client_connection.h" 7 #include "remoting/host/client_connection.h"
8 8
9 #include "google/protobuf/message.h" 9 #include "google/protobuf/message.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 DCHECK_EQ(loop_, MessageLoop::current()); 45 DCHECK_EQ(loop_, MessageLoop::current());
46 46
47 // If we are disconnected then return. 47 // If we are disconnected then return.
48 if (!connection_) 48 if (!connection_)
49 return; 49 return;
50 50
51 ChromotingHostMessage msg; 51 ChromotingHostMessage msg;
52 msg.mutable_init_client()->set_width(width); 52 msg.mutable_init_client()->set_width(width);
53 msg.mutable_init_client()->set_height(height); 53 msg.mutable_init_client()->set_height(height);
54 DCHECK(msg.IsInitialized()); 54 DCHECK(msg.IsInitialized());
55 video_writer_.SendMessage(msg); 55 control_writer_.SendMessage(msg);
56 } 56 }
57 57
58 void ClientConnection::SendVideoPacket(const VideoPacket& packet) { 58 void ClientConnection::SendVideoPacket(const VideoPacket& packet) {
59 DCHECK_EQ(loop_, MessageLoop::current()); 59 DCHECK_EQ(loop_, MessageLoop::current());
60 60
61 // If we are disconnected then return. 61 // If we are disconnected then return.
62 if (!connection_) 62 if (!connection_)
63 return; 63 return;
64 64
65 ChromotingHostMessage* message = new ChromotingHostMessage(); 65 video_writer_->SendPacket(packet);
66 // TODO(sergeyu): avoid memcopy here.
67 *message->mutable_video_packet() = packet;
68
69 video_writer_.SendMessage(*message);
70
71 delete message;
72 } 66 }
73 67
74 int ClientConnection::GetPendingUpdateStreamMessages() { 68 int ClientConnection::GetPendingUpdateStreamMessages() {
75 DCHECK_EQ(loop_, MessageLoop::current()); 69 DCHECK_EQ(loop_, MessageLoop::current());
76 return video_writer_.GetPendingMessages(); 70 return video_writer_->GetPendingPackets();
77 } 71 }
78 72
79 void ClientConnection::Disconnect() { 73 void ClientConnection::Disconnect() {
80 DCHECK_EQ(loop_, MessageLoop::current()); 74 DCHECK_EQ(loop_, MessageLoop::current());
81 75
82 // If there is a channel then close it and release the reference. 76 // If there is a channel then close it and release the reference.
83 if (connection_) { 77 if (connection_) {
84 connection_->Close(NewRunnableMethod(this, &ClientConnection::OnClosed)); 78 connection_->Close(NewRunnableMethod(this, &ClientConnection::OnClosed));
85 connection_ = NULL; 79 connection_ = NULL;
86 } 80 }
87 } 81 }
88 82
89 ClientConnection::ClientConnection() {} 83 ClientConnection::ClientConnection() {}
90 84
91 void ClientConnection::OnConnectionStateChange( 85 void ClientConnection::OnConnectionStateChange(
92 ChromotocolConnection::State state) { 86 ChromotocolConnection::State state) {
93 if (state == ChromotocolConnection::CONNECTED) { 87 if (state == ChromotocolConnection::CONNECTED) {
88 control_writer_.Init(connection_->control_channel());
94 event_reader_.Init<ChromotingClientMessage>( 89 event_reader_.Init<ChromotingClientMessage>(
95 connection_->event_channel(), 90 connection_->event_channel(),
96 NewCallback(this, &ClientConnection::OnMessageReceived)); 91 NewCallback(this, &ClientConnection::OnMessageReceived));
97 video_writer_.Init(connection_->video_channel()); 92 video_writer_.reset(VideoWriter::Create(connection_->config()));
93 video_writer_->Init(connection_);
98 } 94 }
99 95
100 loop_->PostTask(FROM_HERE, 96 loop_->PostTask(FROM_HERE,
101 NewRunnableMethod(this, &ClientConnection::StateChangeTask, state)); 97 NewRunnableMethod(this, &ClientConnection::StateChangeTask, state));
102 } 98 }
103 99
104 void ClientConnection::OnMessageReceived(ChromotingClientMessage* message) { 100 void ClientConnection::OnMessageReceived(ChromotingClientMessage* message) {
105 loop_->PostTask(FROM_HERE, 101 loop_->PostTask(FROM_HERE,
106 NewRunnableMethod(this, &ClientConnection::MessageReceivedTask, 102 NewRunnableMethod(this, &ClientConnection::MessageReceivedTask,
107 message)); 103 message));
(...skipping 26 matching lines...) Expand all
134 DCHECK_EQ(loop_, MessageLoop::current()); 130 DCHECK_EQ(loop_, MessageLoop::current());
135 DCHECK(handler_); 131 DCHECK(handler_);
136 handler_->HandleMessage(this, message); 132 handler_->HandleMessage(this, message);
137 } 133 }
138 134
139 // OnClosed() is used as a callback for ChromotocolConnection::Close(). 135 // OnClosed() is used as a callback for ChromotocolConnection::Close().
140 void ClientConnection::OnClosed() { 136 void ClientConnection::OnClosed() {
141 } 137 }
142 138
143 } // namespace remoting 139 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_connection.h ('k') | remoting/host/mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698