| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "content/public/renderer/media_stream_audio_sink.h" | 15 #include "content/public/renderer/media_stream_audio_sink.h" |
| 16 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" | 16 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" |
| 17 #include "media/audio/audio_parameters.h" | 17 #include "media/audio/audio_parameters.h" |
| 18 #include "ppapi/host/host_message_context.h" |
| 18 #include "ppapi/shared_impl/media_stream_audio_track_shared.h" | 19 #include "ppapi/shared_impl/media_stream_audio_track_shared.h" |
| 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 20 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class MessageLoopProxy; | 23 class MessageLoopProxy; |
| 23 } // namespace base | 24 } // namespace base |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 class PepperMediaStreamAudioTrackHost : public PepperMediaStreamTrackHostBase { | 28 class PepperMediaStreamAudioTrackHost : public PepperMediaStreamTrackHostBase { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 public: | 39 public: |
| 39 explicit AudioSink(PepperMediaStreamAudioTrackHost* host); | 40 explicit AudioSink(PepperMediaStreamAudioTrackHost* host); |
| 40 virtual ~AudioSink(); | 41 virtual ~AudioSink(); |
| 41 | 42 |
| 42 // Enqueues a free buffer index into |buffers_| which will be used for | 43 // Enqueues a free buffer index into |buffers_| which will be used for |
| 43 // sending audio samples to plugin. | 44 // sending audio samples to plugin. |
| 44 // This function is called on the main thread. | 45 // This function is called on the main thread. |
| 45 void EnqueueBuffer(int32_t index); | 46 void EnqueueBuffer(int32_t index); |
| 46 | 47 |
| 47 // This function is called on the main thread. | 48 // This function is called on the main thread. |
| 48 void Configure(int32_t number_of_buffers, int32_t duration); | 49 int32_t Configure(int32_t number_of_buffers, int32_t duration, |
| 50 const ppapi::host::ReplyMessageContext& context); |
| 51 |
| 52 // Send a reply to the currently pending |Configure()| request. |
| 53 void SendConfigureReply(int32_t result); |
| 49 | 54 |
| 50 private: | 55 private: |
| 51 // Initializes buffers on the main thread. | 56 // Initializes buffers on the main thread. |
| 52 void SetFormatOnMainThread(int bytes_per_second, int bytes_per_frame); | 57 void SetFormatOnMainThread(int bytes_per_second, int bytes_per_frame); |
| 53 | 58 |
| 54 void InitBuffers(); | 59 void InitBuffers(); |
| 55 | 60 |
| 56 // Send enqueue buffer message on the main thread. | 61 // Send enqueue buffer message on the main thread. |
| 57 void SendEnqueueBufferMessageOnMainThread(int32_t index, | 62 void SendEnqueueBufferMessageOnMainThread(int32_t index, |
| 58 int32_t buffers_generation); | 63 int32_t buffers_generation); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 135 |
| 131 // Number of bytes per second. | 136 // Number of bytes per second. |
| 132 int bytes_per_second_; | 137 int bytes_per_second_; |
| 133 | 138 |
| 134 // Number of bytes per frame = channels * bytes per sample. | 139 // Number of bytes per frame = channels * bytes per sample. |
| 135 int bytes_per_frame_; | 140 int bytes_per_frame_; |
| 136 | 141 |
| 137 // User-configured buffer duration, in milliseconds. | 142 // User-configured buffer duration, in milliseconds. |
| 138 int32_t user_buffer_duration_; | 143 int32_t user_buffer_duration_; |
| 139 | 144 |
| 145 // Pending |Configure()| reply context. |
| 146 ppapi::host::ReplyMessageContext pending_configure_reply_; |
| 147 |
| 140 DISALLOW_COPY_AND_ASSIGN(AudioSink); | 148 DISALLOW_COPY_AND_ASSIGN(AudioSink); |
| 141 }; | 149 }; |
| 142 | 150 |
| 143 virtual ~PepperMediaStreamAudioTrackHost(); | 151 virtual ~PepperMediaStreamAudioTrackHost(); |
| 144 | 152 |
| 145 // ResourceMessageHandler overrides: | 153 // ResourceMessageHandler overrides: |
| 146 virtual int32_t OnResourceMessageReceived( | 154 virtual int32_t OnResourceMessageReceived( |
| 147 const IPC::Message& msg, | 155 const IPC::Message& msg, |
| 148 ppapi::host::HostMessageContext* context) OVERRIDE; | 156 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 149 | 157 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 168 bool connected_; | 176 bool connected_; |
| 169 | 177 |
| 170 AudioSink audio_sink_; | 178 AudioSink audio_sink_; |
| 171 | 179 |
| 172 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); | 180 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); |
| 173 }; | 181 }; |
| 174 | 182 |
| 175 } // namespace content | 183 } // namespace content |
| 176 | 184 |
| 177 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | 185 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| OLD | NEW |