Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | |
| 7 | |
| 8 #include "base/atomicops.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "content/public/renderer/media_stream_audio_sink.h" | |
| 13 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" | |
| 14 #include "media/audio/audio_parameters.h" | |
| 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class MessageLoopProxy; | |
| 19 } // namespace base | |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 class PepperMediaStreamAudioTrackHost : public PepperMediaStreamTrackHostBase { | |
| 24 public: | |
| 25 PepperMediaStreamAudioTrackHost(RendererPpapiHost* host, | |
| 26 PP_Instance instance, | |
| 27 PP_Resource resource, | |
| 28 const blink::WebMediaStreamTrack& track); | |
| 29 | |
| 30 private: | |
| 31 // A helper class for receiving audio samples in the audio thread. | |
| 32 class AudioSink : public MediaStreamAudioSink, | |
| 33 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
| |
| 34 public: | |
| 35 explicit AudioSink(PepperMediaStreamAudioTrackHost* host); | |
| 36 virtual ~AudioSink(); | |
| 37 | |
| 38 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.
| |
| 39 | |
| 40 private: | |
| 41 void InitFramesOnMainThread(uint32_t number_of_frames, uint32_t frame_size); | |
| 42 | |
| 43 // MediaStreamAudioSink overrides: | |
| 44 // Those functions are called from the audio thread. | |
| 45 virtual void OnData(const int16* audio_data, | |
| 46 int sample_rate, | |
| 47 int number_of_channels, | |
| 48 int number_of_frames) OVERRIDE; | |
| 49 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; | |
| 50 | |
| 51 // 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
| |
| 52 PepperMediaStreamAudioTrackHost* host_; | |
| 53 | |
| 54 // Timestamp of the next received audio frame. | |
| 55 base::TimeDelta timestamp_; | |
| 56 | |
| 57 // Duration of one audio frame. | |
| 58 base::TimeDelta frame_duration_; | |
| 59 | |
| 60 media::AudioParameters audio_params_; | |
| 61 | |
| 62 // 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.
| |
| 63 uint32_t frame_data_size_; | |
| 64 | |
| 65 // Free frames can be used for sending audio samples. | |
| 66 // Each bit of |frames_| represents a frame index. | |
| 67 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
| |
| 68 | |
| 69 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(AudioSink); | |
| 72 }; | |
| 73 | |
| 74 virtual ~PepperMediaStreamAudioTrackHost(); | |
| 75 | |
| 76 // PepperMediaStreamTrackHostBase overrides: | |
| 77 virtual void OnClose() OVERRIDE; | |
| 78 | |
| 79 // MediaStreamFrameBuffer::Delegate overrides: | |
| 80 virtual bool OnNewFramePreEnqueued(int32_t index) OVERRIDE; | |
| 81 | |
| 82 // ResourceHost overrides: | |
| 83 virtual void DidConnectPendingHostToResource() OVERRIDE; | |
| 84 | |
| 85 blink::WebMediaStreamTrack track_; | |
| 86 | |
| 87 // True if it has been added to |blink::WebMediaStreamTrack| as a sink. | |
| 88 bool connected_; | |
| 89 | |
| 90 AudioSink audio_sink_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); | |
| 93 }; | |
| 94 | |
| 95 } // namespace content | |
| 96 | |
| 97 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ | |
| OLD | NEW |