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

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

Issue 7508044: Remove video_channel() from Session interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 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
OLDNEW
1 // Copyright (c) 2010 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/task.h" 8 #include "base/task.h"
9 #include "net/socket/stream_socket.h"
10 #include "remoting/base/constants.h"
8 #include "remoting/proto/video.pb.h" 11 #include "remoting/proto/video.pb.h"
9 #include "remoting/protocol/rtp_writer.h" 12 #include "remoting/protocol/rtp_writer.h"
10 #include "remoting/protocol/session.h" 13 #include "remoting/protocol/session.h"
11 #include "remoting/protocol/util.h" 14 #include "remoting/protocol/util.h"
12 15
13 namespace remoting { 16 namespace remoting {
14 namespace protocol { 17 namespace protocol {
15 18
16 ProtobufVideoWriter::ProtobufVideoWriter() { } 19 ProtobufVideoWriter::ProtobufVideoWriter() { }
17 20
18 ProtobufVideoWriter::~ProtobufVideoWriter() { } 21 ProtobufVideoWriter::~ProtobufVideoWriter() { }
19 22
20 void ProtobufVideoWriter::Init(protocol::Session* session) { 23 void ProtobufVideoWriter::Init(protocol::Session* session,
24 const InitializedCallback& callback) {
25 initialized_callback_ = callback;
26
27 LOG(ERROR) << " creating channel?";
Wez 2011/08/04 23:49:52 nit: Errant debug logging?
Sergey Ulanov 2011/08/09 19:41:10 Done.
28 session->CreateStreamChannel(
29 kVideoChannelName,
30 base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this)));
31 }
32
33 void ProtobufVideoWriter::OnChannelReady(const std::string& name,
34 net::StreamSocket* socket) {
35 DCHECK_EQ(name, kVideoChannelName);
36 if (!socket) {
37 initialized_callback_.Run(false);
38 return;
39 }
40
41 DCHECK(!channel_.get());
42 channel_.reset(socket);
21 buffered_writer_ = new BufferedSocketWriter(); 43 buffered_writer_ = new BufferedSocketWriter();
22 // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. 44 // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer.
23 buffered_writer_->Init(session->video_channel(), NULL); 45 buffered_writer_->Init(socket, NULL);
46
47 initialized_callback_.Run(true);
24 } 48 }
25 49
26 void ProtobufVideoWriter::Close() { 50 void ProtobufVideoWriter::Close() {
27 buffered_writer_->Close(); 51 buffered_writer_->Close();
52 channel_.reset();
28 } 53 }
29 54
30 void ProtobufVideoWriter::ProcessVideoPacket(const VideoPacket* packet, 55 void ProtobufVideoWriter::ProcessVideoPacket(const VideoPacket* packet,
31 Task* done) { 56 Task* done) {
57 LOG(ERROR) << "Writing!";
Wez 2011/08/04 23:49:52 nit: More errant logging?
Sergey Ulanov 2011/08/09 19:41:10 Done.
32 buffered_writer_->Write(SerializeAndFrameMessage(*packet), done); 58 buffered_writer_->Write(SerializeAndFrameMessage(*packet), done);
33 } 59 }
34 60
35 int ProtobufVideoWriter::GetPendingPackets() { 61 int ProtobufVideoWriter::GetPendingPackets() {
36 return buffered_writer_->GetBufferChunks(); 62 return buffered_writer_->GetBufferChunks();
37 } 63 }
38 64
39 } // namespace protocol 65 } // namespace protocol
40 } // namespace remoting 66 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698