OLD | NEW |
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/audio_writer.h" | 5 #include "remoting/protocol/audio_writer.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/audio.pb.h" | 10 #include "remoting/proto/audio.pb.h" |
11 #include "remoting/protocol/message_serialization.h" | 11 #include "remoting/protocol/message_serialization.h" |
12 #include "remoting/protocol/session.h" | 12 #include "remoting/protocol/session.h" |
13 #include "remoting/protocol/session_config.h" | 13 #include "remoting/protocol/session_config.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 namespace protocol { | 16 namespace protocol { |
17 | 17 |
18 AudioWriter::AudioWriter() | 18 AudioWriter::AudioWriter() |
19 : ChannelDispatcherBase(kAudioChannelName) { | 19 : ChannelDispatcherBase(kAudioChannelName) { |
20 } | 20 } |
21 | 21 |
22 AudioWriter::~AudioWriter() { | 22 AudioWriter::~AudioWriter() { |
23 } | 23 } |
24 | 24 |
25 void AudioWriter::OnInitialized() { | |
26 // TODO(sergeyu): Provide a non-null WriteFailedCallback for the writer. | |
27 buffered_writer_.Init( | |
28 channel(), BufferedSocketWriter::WriteFailedCallback()); | |
29 } | |
30 | |
31 void AudioWriter::ProcessAudioPacket(scoped_ptr<AudioPacket> packet, | 25 void AudioWriter::ProcessAudioPacket(scoped_ptr<AudioPacket> packet, |
32 const base::Closure& done) { | 26 const base::Closure& done) { |
33 buffered_writer_.Write(SerializeAndFrameMessage(*packet), done); | 27 writer()->Write(SerializeAndFrameMessage(*packet), done); |
34 } | 28 } |
35 | 29 |
36 // static | 30 // static |
37 scoped_ptr<AudioWriter> AudioWriter::Create(const SessionConfig& config) { | 31 scoped_ptr<AudioWriter> AudioWriter::Create(const SessionConfig& config) { |
38 if (!config.is_audio_enabled()) | 32 if (!config.is_audio_enabled()) |
39 return nullptr; | 33 return nullptr; |
40 return make_scoped_ptr(new AudioWriter()); | 34 return make_scoped_ptr(new AudioWriter()); |
41 } | 35 } |
42 | 36 |
43 } // namespace protocol | 37 } // namespace protocol |
44 } // namespace remoting | 38 } // namespace remoting |
OLD | NEW |