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 #include "content/renderer/media/media_stream_renderer_factory_impl.h" | 5 #include "content/renderer/media/media_stream_renderer_factory_impl.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/renderer/media/media_stream.h" | 8 #include "content/renderer/media/media_stream.h" |
9 #include "content/renderer/media/media_stream_audio_track.h" | 9 #include "content/renderer/media/media_stream_audio_track.h" |
10 #include "content/renderer/media/media_stream_video_renderer_sink.h" | 10 #include "content/renderer/media/media_stream_video_renderer_sink.h" |
11 #include "content/renderer/media/media_stream_video_track.h" | 11 #include "content/renderer/media/media_stream_video_track.h" |
12 #include "content/renderer/media/track_audio_renderer.h" | 12 #include "content/renderer/media/track_audio_renderer.h" |
13 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 13 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 14 #include "content/renderer/media/webrtc/peer_connection_remote_audio_source.h" |
14 #include "content/renderer/media/webrtc_audio_renderer.h" | 15 #include "content/renderer/media/webrtc_audio_renderer.h" |
15 #include "content/renderer/render_thread_impl.h" | 16 #include "content/renderer/render_thread_impl.h" |
16 #include "media/base/audio_hardware_config.h" | 17 #include "media/base/audio_hardware_config.h" |
17 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
18 #include "third_party/WebKit/public/platform/WebURL.h" | 19 #include "third_party/WebKit/public/platform/WebURL.h" |
19 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 20 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
20 #include "third_party/webrtc/api/mediastreaminterface.h" | 21 #include "third_party/webrtc/api/mediastreaminterface.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 DVLOG(1) << "MediaStreamRendererFactoryImpl::GetAudioRenderer stream:" | 103 DVLOG(1) << "MediaStreamRendererFactoryImpl::GetAudioRenderer stream:" |
103 << base::UTF16ToUTF8(base::StringPiece16(web_stream.id())); | 104 << base::UTF16ToUTF8(base::StringPiece16(web_stream.id())); |
104 | 105 |
105 // TODO(tommi): We need to fix the data flow so that | 106 // TODO(tommi): We need to fix the data flow so that |
106 // it works the same way for all track implementations, local, remote or what | 107 // it works the same way for all track implementations, local, remote or what |
107 // have you. | 108 // have you. |
108 // In this function, we should simply create a renderer object that receives | 109 // In this function, we should simply create a renderer object that receives |
109 // and mixes audio from all the tracks that belong to the media stream. | 110 // and mixes audio from all the tracks that belong to the media stream. |
110 // For now, we have separate renderers depending on if the first audio track | 111 // For now, we have separate renderers depending on if the first audio track |
111 // in the stream is local or remote. | 112 // in the stream is local or remote. |
112 MediaStreamAudioTrack* audio_track = MediaStreamAudioTrack::GetTrack( | 113 MediaStreamAudioTrack* const audio_track = |
113 audio_tracks[0]); | 114 MediaStreamAudioTrack::Get(audio_tracks[0]); |
114 if (!audio_track) { | 115 if (!audio_track) { |
115 // This can happen if the track was cloned. | 116 // This can happen if the track was cloned. |
116 // TODO(tommi, perkj): Fix cloning of tracks to handle extra data too. | 117 // TODO(tommi, perkj): Fix cloning of tracks to handle extra data too. |
117 LOG(ERROR) << "No native track for WebMediaStreamTrack."; | 118 LOG(ERROR) << "No native track for WebMediaStreamTrack."; |
118 return nullptr; | 119 return nullptr; |
119 } | 120 } |
120 | 121 |
121 // If the track has a local source, or is a remote track that does not use the | 122 // If the track has a local source, or is a remote track that does not use the |
122 // WebRTC audio pipeline, return a new TrackAudioRenderer instance. | 123 // WebRTC audio pipeline, return a new TrackAudioRenderer instance. |
123 // | 124 PeerConnectionRemoteAudioTrack* const pc_remote_audio_track = |
124 // TODO(miu): In a soon up-coming change, I'll introduce a cleaner way (i.e., | 125 PeerConnectionRemoteAudioTrack::From(audio_track); |
125 // rather than calling GetAudioAdapter()) to determine whether a remote source | 126 if (audio_track->is_local_track() || !pc_remote_audio_track) { |
126 // is via WebRTC or something else. | |
127 if (audio_track->is_local_track() || !audio_track->GetAudioAdapter()) { | |
128 // TODO(xians): Add support for the case where the media stream contains | 127 // TODO(xians): Add support for the case where the media stream contains |
129 // multiple audio tracks. | 128 // multiple audio tracks. |
130 DVLOG(1) << "Creating TrackAudioRenderer for " | 129 DVLOG(1) << "Creating TrackAudioRenderer for " |
131 << (audio_track->is_local_track() ? "local" : "remote") | 130 << (audio_track->is_local_track() ? "local" : "remote") |
132 << " track."; | 131 << " track."; |
133 return new TrackAudioRenderer(audio_tracks[0], render_frame_id, | 132 return new TrackAudioRenderer(audio_tracks[0], render_frame_id, |
134 0 /* no session_id */, device_id, | 133 0 /* no session_id */, device_id, |
135 security_origin); | 134 security_origin); |
136 } | 135 } |
137 | 136 |
(...skipping 14 matching lines...) Expand all Loading... |
152 device_id, security_origin); | 151 device_id, security_origin); |
153 | 152 |
154 if (!audio_device->SetAudioRenderer(renderer.get())) | 153 if (!audio_device->SetAudioRenderer(renderer.get())) |
155 return nullptr; | 154 return nullptr; |
156 } | 155 } |
157 | 156 |
158 return renderer->CreateSharedAudioRendererProxy(web_stream); | 157 return renderer->CreateSharedAudioRendererProxy(web_stream); |
159 } | 158 } |
160 | 159 |
161 } // namespace content | 160 } // namespace content |
OLD | NEW |