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

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

Issue 965333002: Move RemoteMediaStreamAudioTrack to Separete Files Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « content/renderer/media/remote_media_stream_audio_track.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "content/renderer/media/media_stream.h" 14 #include "content/renderer/media/media_stream.h"
15 #include "content/renderer/media/media_stream_track.h" 15 #include "content/renderer/media/media_stream_track.h"
16 #include "content/renderer/media/media_stream_video_track.h" 16 #include "content/renderer/media/media_stream_video_track.h"
17 #include "content/renderer/media/remote_media_stream_audio_track.h"
17 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" 18 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h"
18 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 19 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
19 #include "content/renderer/media/webrtc/track_observer.h" 20 #include "content/renderer/media/webrtc/track_observer.h"
20 #include "third_party/WebKit/public/platform/WebString.h" 21 #include "third_party/WebKit/public/platform/WebString.h"
21 22
22 namespace content { 23 namespace content {
23 namespace { 24 namespace {
24 25
25 template <typename WebRtcTrackVector, typename AdapterType> 26 template <typename WebRtcTrackVector, typename AdapterType>
26 void CreateAdaptersForTracks( 27 void CreateAdaptersForTracks(
27 const WebRtcTrackVector& tracks, 28 const WebRtcTrackVector& tracks,
28 std::vector<scoped_refptr<AdapterType>>* observers, 29 std::vector<scoped_refptr<AdapterType>>* observers,
29 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread) { 30 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread) {
30 for (auto& track : tracks) 31 for (auto& track : tracks)
31 observers->push_back(new AdapterType(main_thread, track)); 32 observers->push_back(new AdapterType(main_thread, track));
32 } 33 }
33 34
34 template<typename VectorType> 35 template<typename VectorType>
35 bool IsTrackInVector(const VectorType& v, const std::string& id) { 36 bool IsTrackInVector(const VectorType& v, const std::string& id) {
36 for (const auto& t : v) { 37 for (const auto& t : v) {
37 if (t->id() == id) 38 if (t->id() == id)
38 return true; 39 return true;
39 } 40 }
40 return false; 41 return false;
41 } 42 }
42 } // namespace 43 } // namespace
43 44
44 // TODO(tommi): Move this class to a separate set of files.
45 class RemoteMediaStreamAudioTrack : public MediaStreamTrack {
46 public:
47 RemoteMediaStreamAudioTrack(
48 const scoped_refptr<webrtc::AudioTrackInterface>& track,
49 const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread)
50 : MediaStreamTrack(false), track_(track),
51 signaling_thread_(signaling_thread) {
52 }
53
54 ~RemoteMediaStreamAudioTrack() override {}
55
56 private:
57 void SetEnabled(bool enabled) override {
58 track_->set_enabled(enabled);
59 }
60
61 void Stop() override {
62 // Stop means that a track should be stopped permanently. But
63 // since there is no proper way of doing that on a remote track, we can
64 // at least disable the track. Blink will not call down to the content layer
65 // after a track has been stopped.
66 SetEnabled(false);
67 }
68
69 private:
70 const scoped_refptr<webrtc::AudioTrackInterface> track_;
71 const scoped_refptr<base::SingleThreadTaskRunner> signaling_thread_;
72 };
73
74 // Base class used for mapping between webrtc and blink MediaStream tracks. 45 // Base class used for mapping between webrtc and blink MediaStream tracks.
75 // An instance of a RemoteMediaStreamTrackAdapter is stored in 46 // An instance of a RemoteMediaStreamTrackAdapter is stored in
76 // RemoteMediaStreamImpl per remote audio and video track. 47 // RemoteMediaStreamImpl per remote audio and video track.
77 template<typename WebRtcMediaStreamTrackType> 48 template<typename WebRtcMediaStreamTrackType>
78 class RemoteMediaStreamTrackAdapter 49 class RemoteMediaStreamTrackAdapter
79 : public base::RefCountedThreadSafe< 50 : public base::RefCountedThreadSafe<
80 RemoteMediaStreamTrackAdapter<WebRtcMediaStreamTrackType>> { 51 RemoteMediaStreamTrackAdapter<WebRtcMediaStreamTrackType>> {
81 public: 52 public:
82 RemoteMediaStreamTrackAdapter( 53 RemoteMediaStreamTrackAdapter(
83 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, 54 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread,
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Unregister all the audio track observers that were not used. 413 // Unregister all the audio track observers that were not used.
443 // We need to do this before destruction since the observers can't unregister 414 // We need to do this before destruction since the observers can't unregister
444 // from within the dtor due to a race. 415 // from within the dtor due to a race.
445 for (auto& track : *audio_tracks.get()) { 416 for (auto& track : *audio_tracks.get()) {
446 if (track.get()) 417 if (track.get())
447 track->Unregister(); 418 track->Unregister();
448 } 419 }
449 } 420 }
450 421
451 } // namespace content 422 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/remote_media_stream_audio_track.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698