OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_VIDEO_TRACK_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "content/public/renderer/media_stream_video_sink.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "content/public/renderer/media_stream_audio_sink.h" |
10 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" | 12 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" |
11 #include "media/base/video_frame.h" | 13 #include "media/audio/audio_parameters.h" |
12 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
13 #include "ui/gfx/size.h" | 15 |
| 16 namespace base { |
| 17 class MessageLoopProxy; |
| 18 } // namespace base |
14 | 19 |
15 namespace content { | 20 namespace content { |
16 | 21 |
17 class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, | 22 class PepperMediaStreamAudioTrackHost : public PepperMediaStreamTrackHostBase, |
18 public MediaStreamVideoSink { | 23 public MediaStreamAudioSink { |
19 public: | 24 public: |
20 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, | 25 PepperMediaStreamAudioTrackHost(RendererPpapiHost* host, |
21 PP_Instance instance, | 26 PP_Instance instance, |
22 PP_Resource resource, | 27 PP_Resource resource, |
23 const blink::WebMediaStreamTrack& track); | 28 const blink::WebMediaStreamTrack& track); |
24 | 29 |
25 private: | 30 private: |
26 virtual ~PepperMediaStreamVideoTrackHost(); | 31 virtual ~PepperMediaStreamAudioTrackHost(); |
| 32 |
| 33 void InitFramesOnMainThread(uint32_t number_of_frames, uint32_t frame_size); |
27 | 34 |
28 // PepperMediaStreamTrackHostBase overrides: | 35 // PepperMediaStreamTrackHostBase overrides: |
29 virtual void OnClose() OVERRIDE; | 36 virtual void OnClose() OVERRIDE; |
30 | 37 |
31 // MediaStreamVideoSink overrides: | 38 // MediaStreamAudioSink overrides: |
32 virtual void OnVideoFrame( | 39 virtual void OnData(const int16* audio_data, |
33 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; | 40 int sample_rate, |
| 41 int number_of_channels, |
| 42 int number_of_frames) OVERRIDE; |
| 43 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; |
34 | 44 |
35 // ResourceHost overrides: | 45 // ResourceHost overrides: |
36 virtual void DidConnectPendingHostToResource() OVERRIDE; | 46 virtual void DidConnectPendingHostToResource() OVERRIDE; |
37 | 47 |
38 blink::WebMediaStreamTrack track_; | 48 blink::WebMediaStreamTrack track_; |
39 | 49 |
40 // True if it has been added to |blink::WebMediaStreamTrack| as a sink. | 50 // True if it has been added to |blink::WebMediaStreamTrack| as a sink. |
41 bool connected_; | 51 bool connected_; |
42 | 52 |
43 // Frame size. | 53 // Timestamp of the next received audio frame. |
44 gfx::Size frame_size_; | 54 base::TimeDelta timestamp_; |
45 | 55 |
46 // Frame format. | 56 // Duration of one audio frame. |
47 media::VideoFrame::Format frame_format_; | 57 base::TimeDelta frame_duration_; |
| 58 |
| 59 media::AudioParameters audio_params_; |
48 | 60 |
49 // The size of frame pixels in bytes. | 61 // The size of frame pixels in bytes. |
50 uint32_t frame_data_size_; | 62 uint32_t frame_data_size_; |
51 | 63 |
52 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamVideoTrackHost); | 64 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; |
| 65 |
| 66 base::WeakPtrFactory<PepperMediaStreamAudioTrackHost> weak_factory_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamAudioTrackHost); |
53 }; | 69 }; |
54 | 70 |
55 } // namespace content | 71 } // namespace content |
56 | 72 |
57 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ | 73 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_AUDIO_TRACK_HOST_H_ |
OLD | NEW |