Chromium Code Reviews| Index: content/renderer/pepper/pepper_media_stream_audio_track_host.h |
| diff --git a/content/renderer/pepper/pepper_media_stream_audio_track_host.h b/content/renderer/pepper/pepper_media_stream_audio_track_host.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..879390077c39f5479c571a6f086c41ce6c87809d |
| --- /dev/null |
| +++ b/content/renderer/pepper/pepper_media_stream_audio_track_host.h |
| @@ -0,0 +1,97 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| +#define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
| + |
| +#include "base/atomicops.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/public/renderer/media_stream_audio_sink.h" |
| +#include "content/renderer/pepper/pepper_media_stream_track_host_base.h" |
| +#include "media/audio/audio_parameters.h" |
| +#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| + |
| +namespace base { |
| +class MessageLoopProxy; |
| +} // namespace base |
| + |
| +namespace content { |
| + |
| +class PepperMediaStreamAudioTrackHost : public PepperMediaStreamTrackHostBase { |
| + public: |
| + PepperMediaStreamAudioTrackHost(RendererPpapiHost* host, |
| + PP_Instance instance, |
| + PP_Resource resource, |
| + const blink::WebMediaStreamTrack& track); |
| + |
| + private: |
| + // A helper class for receiving audio samples in the audio thread. |
| + class AudioSink : public MediaStreamAudioSink, |
| + public base::SupportsWeakPtr<AudioSink> { |
|
yzshen1
2014/01/29 21:28:06
Please comment about on which thread weak pointers
Peng
2014/01/31 18:54:43
Done.
yzshen1
2014/02/03 18:14:36
I couldn't find the corresponding change.
On 2014/
Peng
2014/02/03 19:21:08
I added comments about the constructor and the des
|
| + public: |
| + explicit AudioSink(PepperMediaStreamAudioTrackHost* host); |
| + virtual ~AudioSink(); |
| + |
| + void EnqueueFrame(int32_t index); |
|
yzshen1
2014/01/29 21:28:06
On which thread it is called?
Peng
2014/01/31 18:54:43
Done.
|
| + |
| + private: |
| + void InitFramesOnMainThread(uint32_t number_of_frames, uint32_t frame_size); |
| + |
| + // MediaStreamAudioSink overrides: |
| + // Those functions are called from the audio thread. |
| + virtual void OnData(const int16* audio_data, |
| + int sample_rate, |
| + int number_of_channels, |
| + int number_of_frames) OVERRIDE; |
| + virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; |
| + |
| + // Unowned host which is available during the AudioSink's lifespan. |
|
yzshen1
2014/01/29 21:28:06
Please add comment about on which thread the membe
Peng
2014/01/31 18:54:43
I added comment for members which will be only acc
|
| + PepperMediaStreamAudioTrackHost* host_; |
| + |
| + // Timestamp of the next received audio frame. |
| + base::TimeDelta timestamp_; |
| + |
| + // Duration of one audio frame. |
| + base::TimeDelta frame_duration_; |
| + |
| + media::AudioParameters audio_params_; |
| + |
| + // The size of frame pixels in bytes. |
|
yzshen1
2014/01/29 21:28:06
audio doesn't have pixels, right?
Peng
2014/01/31 18:54:43
Done.
|
| + uint32_t frame_data_size_; |
| + |
| + // Free frames can be used for sending audio samples. |
| + // Each bit of |frames_| represents a frame index. |
| + base::subtle::Atomic32 frames_; |
|
yzshen1
2014/01/29 21:28:06
Do you mean the current implementation only suppor
Peng
2014/01/31 18:54:43
Yes. I changed to Atomic64. I think it should be e
|
| + |
| + scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioSink); |
| + }; |
| + |
| + virtual ~PepperMediaStreamAudioTrackHost(); |
| + |
| + // PepperMediaStreamTrackHostBase overrides: |
| + virtual void OnClose() OVERRIDE; |
| + |
| + // MediaStreamFrameBuffer::Delegate overrides: |
| + virtual bool OnNewFramePreEnqueued(int32_t index) OVERRIDE; |
| + |
| + // ResourceHost overrides: |
| + virtual void DidConnectPendingHostToResource() OVERRIDE; |
| + |
| + blink::WebMediaStreamTrack track_; |
| + |
| + // True if it has been added to |blink::WebMediaStreamTrack| as a sink. |
| + bool connected_; |
| + |
| + AudioSink audio_sink_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |