Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: content/renderer/pepper/pepper_media_stream_audio_track_host.h

Issue 430943004: Return from |Configure()| asynchronously, and allow |InitBuffers()| to return errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pepper-mediastream-duration
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
49 51
50 private: 52 private:
51 // Initializes buffers on the main thread. 53 // Initializes buffers on the main thread.
52 void SetFormatOnMainThread(int bytes_per_second, int bytes_per_frame); 54 void SetFormatOnMainThread(int bytes_per_second, int bytes_per_frame);
53 55
54 void InitBuffers(); 56 void InitBuffers();
55 57
56 // Send enqueue buffer message on the main thread. 58 // Send enqueue buffer message on the main thread.
57 void SendEnqueueBufferMessageOnMainThread(int32_t index, 59 void SendEnqueueBufferMessageOnMainThread(int32_t index,
58 int32_t buffers_generation); 60 int32_t buffers_generation);
59 61
62 // Send a reply to the currently pending |Configure()| request.
63 void SendConfigureReply(int32_t result);
64
60 // MediaStreamAudioSink overrides: 65 // MediaStreamAudioSink overrides:
61 // These two functions should be called on the audio thread. 66 // These two functions should be called on the audio thread.
62 virtual void OnData(const int16* audio_data, 67 virtual void OnData(const int16* audio_data,
63 int sample_rate, 68 int sample_rate,
64 int number_of_channels, 69 int number_of_channels,
65 int number_of_frames) OVERRIDE; 70 int number_of_frames) OVERRIDE;
66 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; 71 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE;
67 72
68 // Unowned host which is available during the AudioSink's lifespan. 73 // Unowned host which is available during the AudioSink's lifespan.
69 // It is mainly used in the main thread. But the audio thread will use 74 // It is mainly used in the main thread. But the audio thread will use
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698