Index: remoting/protocol/protobuf_video_writer.cc |
diff --git a/remoting/protocol/protobuf_video_writer.cc b/remoting/protocol/protobuf_video_writer.cc |
index a03a4e696008e6697b3fc79ef6272421eb42b6f0..fed7eafe86d2afc3732b36265bdc8ccc28cc9397 100644 |
--- a/remoting/protocol/protobuf_video_writer.cc |
+++ b/remoting/protocol/protobuf_video_writer.cc |
@@ -1,10 +1,13 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
#include "remoting/protocol/protobuf_video_writer.h" |
+#include "base/bind.h" |
#include "base/task.h" |
+#include "net/socket/stream_socket.h" |
+#include "remoting/base/constants.h" |
#include "remoting/proto/video.pb.h" |
#include "remoting/protocol/rtp_writer.h" |
#include "remoting/protocol/session.h" |
@@ -17,18 +20,41 @@ ProtobufVideoWriter::ProtobufVideoWriter() { } |
ProtobufVideoWriter::~ProtobufVideoWriter() { } |
-void ProtobufVideoWriter::Init(protocol::Session* session) { |
+void ProtobufVideoWriter::Init(protocol::Session* session, |
+ const InitializedCallback& callback) { |
+ initialized_callback_ = callback; |
+ |
+ LOG(ERROR) << " creating channel?"; |
Wez
2011/08/04 23:49:52
nit: Errant debug logging?
Sergey Ulanov
2011/08/09 19:41:10
Done.
|
+ session->CreateStreamChannel( |
+ kVideoChannelName, |
+ base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this))); |
+} |
+ |
+void ProtobufVideoWriter::OnChannelReady(const std::string& name, |
+ net::StreamSocket* socket) { |
+ DCHECK_EQ(name, kVideoChannelName); |
+ if (!socket) { |
+ initialized_callback_.Run(false); |
+ return; |
+ } |
+ |
+ DCHECK(!channel_.get()); |
+ channel_.reset(socket); |
buffered_writer_ = new BufferedSocketWriter(); |
// TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. |
- buffered_writer_->Init(session->video_channel(), NULL); |
+ buffered_writer_->Init(socket, NULL); |
+ |
+ initialized_callback_.Run(true); |
} |
void ProtobufVideoWriter::Close() { |
buffered_writer_->Close(); |
+ channel_.reset(); |
} |
void ProtobufVideoWriter::ProcessVideoPacket(const VideoPacket* packet, |
Task* done) { |
+ LOG(ERROR) << "Writing!"; |
Wez
2011/08/04 23:49:52
nit: More errant logging?
Sergey Ulanov
2011/08/09 19:41:10
Done.
|
buffered_writer_->Write(SerializeAndFrameMessage(*packet), done); |
} |