Chromium Code Reviews| 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 #ifndef REMOTING_PROTOCOL_AUDIO_READER_H_ | 5 #ifndef REMOTING_PROTOCOL_AUDIO_READER_H_ |
| 6 #define REMOTING_PROTOCOL_AUDIO_READER_H_ | 6 #define REMOTING_PROTOCOL_AUDIO_READER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "remoting/proto/audio.pb.h" | 10 #include "remoting/proto/audio.pb.h" |
| 11 #include "remoting/protocol/audio_stub.h" | 11 #include "remoting/protocol/audio_stub.h" |
| 12 #include "remoting/protocol/message_reader.h" | 12 #include "remoting/protocol/message_reader.h" |
| 13 #include "remoting/protocol/channel_dispatcher_base.h" | |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 class StreamSocket; | 16 class StreamSocket; |
| 16 } // namespace net | 17 } // namespace net |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 namespace protocol { | 20 namespace protocol { |
| 20 | 21 |
| 21 class Session; | 22 class Session; |
| 22 class SessionConfig; | 23 class SessionConfig; |
| 23 | 24 |
| 24 class AudioReader { | 25 class AudioReader : public ChannelDispatcherBase { |
| 25 public: | 26 public: |
| 26 // The callback is called when initialization is finished. The | 27 // The callback is called when initialization is finished. The |
| 27 // parameter is set to true on success. | 28 // parameter is set to true on success. |
| 28 typedef base::Callback<void(bool)> InitializedCallback; | 29 typedef base::Callback<void(bool)> InitializedCallback; |
|
Wez
2012/08/18 00:30:36
Remove this.
Sergey Ulanov
2012/08/18 01:53:56
Done.
| |
| 29 | 30 |
| 30 virtual ~AudioReader(); | 31 virtual ~AudioReader(); |
| 31 | 32 |
| 33 void set_audio_stub(AudioStub* audio_stub) { audio_stub_ = audio_stub; } | |
| 34 | |
| 32 static scoped_ptr<AudioReader> Create(const SessionConfig& config); | 35 static scoped_ptr<AudioReader> Create(const SessionConfig& config); |
|
Wez
2012/08/18 00:30:36
nit: While you're improving this API, shouldn't Cr
Sergey Ulanov
2012/08/18 01:53:56
Strictly speaking the style guide says that constr
Wez
2012/08/18 21:44:06
Yes, I think that makes sense.
| |
| 33 | 36 |
| 34 // Initializies the reader. | 37 protected: |
| 35 void Init(Session* session, | 38 virtual void OnInitialized() OVERRIDE; |
| 36 AudioStub* audio_stub, | |
| 37 const InitializedCallback& callback); | |
| 38 bool is_connected(); | |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 explicit AudioReader(AudioPacket::Encoding encoding); | 41 explicit AudioReader(AudioPacket::Encoding encoding); |
| 42 | 42 |
| 43 void OnChannelReady(scoped_ptr<net::StreamSocket> socket); | |
| 44 void OnNewData(scoped_ptr<AudioPacket> packet, | 43 void OnNewData(scoped_ptr<AudioPacket> packet, |
| 45 const base::Closure& done_task); | 44 const base::Closure& done_task); |
| 46 | 45 |
| 47 Session* session_; | |
| 48 | |
| 49 InitializedCallback initialized_callback_; | |
| 50 | |
| 51 AudioPacket::Encoding encoding_; | 46 AudioPacket::Encoding encoding_; |
| 52 | 47 |
| 53 // TODO(sergeyu): Remove |channel_| and let |reader_| own it. | |
| 54 scoped_ptr<net::StreamSocket> channel_; | |
| 55 | |
| 56 ProtobufMessageReader<AudioPacket> reader_; | 48 ProtobufMessageReader<AudioPacket> reader_; |
| 57 | 49 |
| 58 // The stub that processes all received packets. | 50 // The stub that processes all received packets. |
| 59 AudioStub* audio_stub_; | 51 AudioStub* audio_stub_; |
| 60 | 52 |
| 61 DISALLOW_COPY_AND_ASSIGN(AudioReader); | 53 DISALLOW_COPY_AND_ASSIGN(AudioReader); |
| 62 }; | 54 }; |
| 63 | 55 |
| 64 } // namespace protocol | 56 } // namespace protocol |
| 65 } // namespace remoting | 57 } // namespace remoting |
| 66 | 58 |
| 67 #endif // REMOTING_PROTOCOL_AUDIO_READER_H_ | 59 #endif // REMOTING_PROTOCOL_AUDIO_READER_H_ |
| OLD | NEW |