OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_TRACK_COLLECTION_H_ | |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_TRACK_COLLECTION_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/single_thread_task_runner.h" | |
13 #include "content/common/content_export.h" | |
14 #include "content/renderer/media/webrtc/webrtc_media_stream_track_adapter.h" | |
15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | |
16 #include "third_party/webrtc/api/mediastreaminterface.h" | |
17 | |
18 namespace content { | |
19 | |
20 class PeerConnectionDependencyFactory; | |
21 | |
22 class CONTENT_EXPORT WebRtcMediaStreamTrackCollection | |
Guido Urdaneta
2017/05/22 16:14:47
Would WebRtcMediaStreamTrackMap be a more descript
hbos_chromium
2017/05/29 13:28:51
Done. Changed to WebRtcMediaStreamTrackAdapterMap.
| |
23 : public base::RefCountedThreadSafe<WebRtcMediaStreamTrackCollection> { | |
24 public: | |
25 WebRtcMediaStreamTrackCollection( | |
26 PeerConnectionDependencyFactory* const factory, | |
27 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread); | |
28 | |
29 scoped_refptr<WebRtcMediaStreamTrackAdapter> GetLocalTrack( | |
Guido Urdaneta
2017/05/22 16:14:45
Add comment. What happens if the id is not found?
hbos_chromium
2017/05/29 13:28:51
Done.
| |
30 const std::string& id) const; | |
31 // Invoke on the main thread. Newly created tracks are initialized when | |
32 // returned. | |
33 scoped_refptr<WebRtcMediaStreamTrackAdapter> GetOrCreateLocalTrack( | |
34 const blink::WebMediaStreamTrack& web_track); | |
35 bool RemoveAndUninitializeLocalTrack(const std::string& id); | |
Guido Urdaneta
2017/05/22 16:14:44
Add a comment explaining the meaning of the result
hbos_chromium
2017/05/29 13:28:50
Done.
| |
36 size_t GetLocalTrackCount() const; | |
37 | |
38 scoped_refptr<WebRtcMediaStreamTrackAdapter> GetRemoteTrack( | |
39 const std::string& id) const; | |
40 // Invoke on the webrtc signaling thread. Newly created tracks are initialized | |
Guido Urdaneta
2017/05/22 16:14:47
Since this function has no callback, the detail ab
hbos_chromium
2017/05/29 13:28:50
It is relevant because it would be an error to try
Guido Urdaneta
2017/05/30 09:02:41
Acknowledged.
| |
41 // in a post to the main thread. | |
42 scoped_refptr<WebRtcMediaStreamTrackAdapter> GetOrCreateRemoteTrack( | |
43 webrtc::MediaStreamTrackInterface* webrtc_track); | |
44 bool RemoveAndUninitializeRemoteTrack(const std::string& id); | |
45 size_t GetRemoteTrackCount() const; | |
46 | |
47 void ClearAndUninitializeTracks(); | |
Guido Urdaneta
2017/05/22 16:14:44
Since there are no versions of these methods witho
hbos_chromium
2017/05/29 13:28:50
Done. Renamed to Dispose[Local/Remote]TrackAdapter
| |
48 | |
49 protected: | |
50 friend class base::RefCountedThreadSafe<WebRtcMediaStreamTrackCollection>; | |
51 | |
52 virtual ~WebRtcMediaStreamTrackCollection(); | |
53 | |
54 private: | |
55 // Pointer to a |PeerConnectionDependencyFactory| owned by the |RenderThread|. | |
56 // It's valid for the lifetime of |RenderThread|. | |
57 PeerConnectionDependencyFactory* const factory_; | |
58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | |
59 | |
60 mutable base::Lock lock_; | |
Guido Urdaneta
2017/05/22 16:14:46
Would having a separate lock for each map have any
hbos_chromium
2017/05/29 13:28:51
Contention is unlikely. I prefer to have a single
Guido Urdaneta
2017/05/30 09:02:41
Acknowledged.
| |
61 std::map<std::string, scoped_refptr<WebRtcMediaStreamTrackAdapter>> | |
62 local_tracks_; | |
63 std::map<std::string, scoped_refptr<WebRtcMediaStreamTrackAdapter>> | |
64 remote_tracks_; | |
65 }; | |
66 | |
67 } // namespace content | |
68 | |
69 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_TRACK_COLLECTION_H_ | |
OLD | NEW |