| 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/webrtc/webrtc_media_stream_adapter.h" | 5 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/media/media_stream_audio_track.h" | 8 #include "content/renderer/media/media_stream_audio_track.h" |
| 9 #include "content/renderer/media/media_stream_track.h" | 9 #include "content/renderer/media/media_stream_track.h" |
| 10 #include "content/renderer/media/webrtc/media_stream_video_webrtc_sink.h" | 10 #include "content/renderer/media/webrtc/media_stream_video_webrtc_sink.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 void WebRtcMediaStreamAdapter::AddAudioSinkToTrack( | 103 void WebRtcMediaStreamAdapter::AddAudioSinkToTrack( |
| 104 const blink::WebMediaStreamTrack& track) { | 104 const blink::WebMediaStreamTrack& track) { |
| 105 MediaStreamAudioTrack* native_track = MediaStreamAudioTrack::From(track); | 105 MediaStreamAudioTrack* native_track = MediaStreamAudioTrack::From(track); |
| 106 if (!native_track) { | 106 if (!native_track) { |
| 107 DLOG(ERROR) << "No native track for blink audio track."; | 107 DLOG(ERROR) << "No native track for blink audio track."; |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 | 110 |
| 111 WebRtcAudioSink* audio_sink; | 111 // Non-WebRtc remote sources and local sources do not provide an instance of |
| 112 // the webrtc::AudioSourceInterface, and also do not need references to the |
| 113 // audio level calculator or audio processor passed to the sink. |
| 114 webrtc::AudioSourceInterface* source_interface = nullptr; |
| 115 WebRtcAudioSink* audio_sink = new WebRtcAudioSink( |
| 116 track.id().utf8(), source_interface, |
| 117 factory_->GetWebRtcSignalingThread()); |
| 118 |
| 112 if (auto* media_stream_source = ProcessedLocalAudioSource::From( | 119 if (auto* media_stream_source = ProcessedLocalAudioSource::From( |
| 113 MediaStreamAudioSource::From(track.source()))) { | 120 MediaStreamAudioSource::From(track.source()))) { |
| 114 audio_sink = new WebRtcAudioSink( | |
| 115 track.id().utf8(), media_stream_source->rtc_source(), | |
| 116 factory_->GetWebRtcSignalingThread()); | |
| 117 audio_sink->SetLevel(media_stream_source->audio_level()); | 121 audio_sink->SetLevel(media_stream_source->audio_level()); |
| 118 // The sink only grabs stats from the audio processor. Stats are only | 122 // The sink only grabs stats from the audio processor. Stats are only |
| 119 // available if audio processing is turned on. Therefore, only provide the | 123 // available if audio processing is turned on. Therefore, only provide the |
| 120 // sink a reference to the processor if audio processing is turned on. | 124 // sink a reference to the processor if audio processing is turned on. |
| 121 if (auto processor = media_stream_source->audio_processor()) { | 125 if (auto processor = media_stream_source->audio_processor()) { |
| 122 if (processor && processor->has_audio_processing()) | 126 if (processor && processor->has_audio_processing()) |
| 123 audio_sink->SetAudioProcessor(processor); | 127 audio_sink->SetAudioProcessor(processor); |
| 124 } | 128 } |
| 125 } else { | |
| 126 // Remote sources and other non-WebRtc local sources do not provide an | |
| 127 // instance of the webrtc::AudioSourceInterface, and also do not need | |
| 128 // references to the audio level calculator or audio processor passed to the | |
| 129 // sink. | |
| 130 webrtc::AudioSourceInterface* source_interface = nullptr; | |
| 131 audio_sink = new WebRtcAudioSink( | |
| 132 track.id().utf8(), source_interface, | |
| 133 factory_->GetWebRtcSignalingThread()); | |
| 134 } | 129 } |
| 135 | 130 |
| 136 audio_sinks_.push_back(std::unique_ptr<WebRtcAudioSink>(audio_sink)); | 131 audio_sinks_.push_back(std::unique_ptr<WebRtcAudioSink>(audio_sink)); |
| 137 native_track->AddSink(audio_sink); | 132 native_track->AddSink(audio_sink); |
| 138 webrtc_media_stream_->AddTrack(audio_sink->webrtc_audio_track()); | 133 webrtc_media_stream_->AddTrack(audio_sink->webrtc_audio_track()); |
| 139 } | 134 } |
| 140 | 135 |
| 141 void WebRtcMediaStreamAdapter::AddVideoSinkToTrack( | 136 void WebRtcMediaStreamAdapter::AddVideoSinkToTrack( |
| 142 const blink::WebMediaStreamTrack& track) { | 137 const blink::WebMediaStreamTrack& track) { |
| 143 DCHECK_EQ(track.source().getType(), blink::WebMediaStreamSource::TypeVideo); | 138 DCHECK_EQ(track.source().getType(), blink::WebMediaStreamSource::TypeVideo); |
| 144 MediaStreamVideoWebRtcSink* video_sink = | 139 MediaStreamVideoWebRtcSink* video_sink = |
| 145 new MediaStreamVideoWebRtcSink(track, factory_); | 140 new MediaStreamVideoWebRtcSink(track, factory_); |
| 146 video_sinks_.push_back( | 141 video_sinks_.push_back( |
| 147 std::unique_ptr<MediaStreamVideoWebRtcSink>(video_sink)); | 142 std::unique_ptr<MediaStreamVideoWebRtcSink>(video_sink)); |
| 148 webrtc_media_stream_->AddTrack(video_sink->webrtc_video_track()); | 143 webrtc_media_stream_->AddTrack(video_sink->webrtc_video_track()); |
| 149 } | 144 } |
| 150 | 145 |
| 151 } // namespace content | 146 } // namespace content |
| OLD | NEW |