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/compound_buffer.h" |
9 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
10 #include "remoting/proto/audio.pb.h" | 11 #include "remoting/proto/audio.pb.h" |
11 #include "remoting/protocol/message_serialization.h" | 12 #include "remoting/protocol/message_pipe.h" |
12 #include "remoting/protocol/session.h" | 13 #include "remoting/protocol/session.h" |
13 #include "remoting/protocol/session_config.h" | 14 #include "remoting/protocol/session_config.h" |
14 | 15 |
15 namespace remoting { | 16 namespace remoting { |
16 namespace protocol { | 17 namespace protocol { |
17 | 18 |
18 AudioWriter::AudioWriter() | 19 AudioWriter::AudioWriter() : ChannelDispatcherBase(kAudioChannelName) {} |
19 : ChannelDispatcherBase(kAudioChannelName) { | 20 AudioWriter::~AudioWriter() {} |
20 } | |
21 | |
22 AudioWriter::~AudioWriter() { | |
23 } | |
24 | 21 |
25 void AudioWriter::ProcessAudioPacket(scoped_ptr<AudioPacket> packet, | 22 void AudioWriter::ProcessAudioPacket(scoped_ptr<AudioPacket> packet, |
26 const base::Closure& done) { | 23 const base::Closure& done) { |
27 writer()->Write(SerializeAndFrameMessage(*packet), done); | 24 message_pipe()->Send(packet.get(), done); |
28 } | 25 } |
29 | 26 |
30 // static | 27 // static |
31 scoped_ptr<AudioWriter> AudioWriter::Create(const SessionConfig& config) { | 28 scoped_ptr<AudioWriter> AudioWriter::Create(const SessionConfig& config) { |
32 if (!config.is_audio_enabled()) | 29 if (!config.is_audio_enabled()) |
33 return nullptr; | 30 return nullptr; |
34 return make_scoped_ptr(new AudioWriter()); | 31 return make_scoped_ptr(new AudioWriter()); |
35 } | 32 } |
36 | 33 |
37 void AudioWriter::OnIncomingMessage(scoped_ptr<CompoundBuffer> message) { | 34 void AudioWriter::OnIncomingMessage(scoped_ptr<CompoundBuffer> message) { |
38 LOG(ERROR) << "Received unexpected message on the audio channel."; | 35 LOG(ERROR) << "Received unexpected message on the audio channel."; |
39 } | 36 } |
40 | 37 |
41 } // namespace protocol | 38 } // namespace protocol |
42 } // namespace remoting | 39 } // namespace remoting |
OLD | NEW |