Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: content/renderer/media/remote_media_stream_impl.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/remote_media_stream_impl.h" 5 #include "content/renderer/media/remote_media_stream_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "content/renderer/media/media_stream.h" 18 #include "content/renderer/media/media_stream.h"
19 #include "content/renderer/media/media_stream_track.h" 19 #include "content/renderer/media/media_stream_track.h"
20 #include "content/renderer/media/media_stream_video_track.h" 20 #include "content/renderer/media/media_stream_video_track.h"
21 #include "content/renderer/media/webrtc/media_stream_remote_audio_track.h"
22 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" 21 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h"
23 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 22 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
23 #include "content/renderer/media/webrtc/peer_connection_remote_audio_source.h"
24 #include "content/renderer/media/webrtc/track_observer.h" 24 #include "content/renderer/media/webrtc/track_observer.h"
25 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 25 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
26 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 26 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
27 #include "third_party/WebKit/public/platform/WebString.h" 27 #include "third_party/WebKit/public/platform/WebString.h"
28 28
29 namespace content { 29 namespace content {
30 namespace { 30 namespace {
31 31
32 template <typename WebRtcTrackVector, typename AdapterType> 32 template <typename WebRtcTrackVector, typename AdapterType>
33 void CreateAdaptersForTracks( 33 void CreateAdaptersForTracks(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 #if DCHECK_IS_ON() 232 #if DCHECK_IS_ON()
233 DCHECK(!unregistered_); 233 DCHECK(!unregistered_);
234 unregistered_ = true; 234 unregistered_ = true;
235 #endif 235 #endif
236 observed_track()->UnregisterObserver(this); 236 observed_track()->UnregisterObserver(this);
237 } 237 }
238 238
239 void RemoteAudioTrackAdapter::InitializeWebkitAudioTrack() { 239 void RemoteAudioTrackAdapter::InitializeWebkitAudioTrack() {
240 InitializeWebkitTrack(blink::WebMediaStreamSource::TypeAudio); 240 InitializeWebkitTrack(blink::WebMediaStreamSource::TypeAudio);
241 241
242 webkit_track()->source().setExtraData( 242 MediaStreamAudioSource* const source =
243 new MediaStreamRemoteAudioSource(observed_track().get())); 243 new PeerConnectionRemoteAudioSource(observed_track().get());
244 webkit_track()->setExtraData( 244 webkit_track()->source().setExtraData(source); // Takes ownership.
245 new MediaStreamRemoteAudioTrack( 245 source->ConnectToTrack(*(webkit_track()));
246 webkit_track()->source(), webkit_track()->isEnabled()));
247 } 246 }
248 247
249 void RemoteAudioTrackAdapter::OnChanged() { 248 void RemoteAudioTrackAdapter::OnChanged() {
250 main_thread_->PostTask(FROM_HERE, 249 main_thread_->PostTask(FROM_HERE,
251 base::Bind(&RemoteAudioTrackAdapter::OnChangedOnMainThread, 250 base::Bind(&RemoteAudioTrackAdapter::OnChangedOnMainThread,
252 this, observed_track()->state())); 251 this, observed_track()->state()));
253 } 252 }
254 253
255 void RemoteAudioTrackAdapter::OnChangedOnMainThread( 254 void RemoteAudioTrackAdapter::OnChangedOnMainThread(
256 webrtc::MediaStreamTrackInterface::TrackState state) { 255 webrtc::MediaStreamTrackInterface::TrackState state) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // Unregister all the audio track observers that were not used. 423 // Unregister all the audio track observers that were not used.
425 // We need to do this before destruction since the observers can't unregister 424 // We need to do this before destruction since the observers can't unregister
426 // from within the dtor due to a race. 425 // from within the dtor due to a race.
427 for (auto& track : *audio_tracks.get()) { 426 for (auto& track : *audio_tracks.get()) {
428 if (track.get()) 427 if (track.get())
429 track->Unregister(); 428 track->Unregister();
430 } 429 }
431 } 430 }
432 431
433 } // namespace content 432 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/mock_media_stream_registry.cc ('k') | content/renderer/media/rtc_peer_connection_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698