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

Side by Side Diff: content/renderer/media/webrtc/webrtc_media_stream_adapter.h

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 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 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_ADAPTER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_ADAPTER_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_ADAPTER_H_
7 7
8 #include <memory>
9 #include <vector>
10
8 #include "base/macros.h" 11 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_vector.h"
11 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
12 #include "content/renderer/media/media_stream.h" 14 #include "content/renderer/media/media_stream.h"
13 #include "third_party/WebKit/public/platform/WebMediaStream.h" 15 #include "third_party/WebKit/public/platform/WebMediaStream.h"
14 #include "third_party/webrtc/api/mediastreaminterface.h" 16 #include "third_party/webrtc/api/mediastreaminterface.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 class PeerConnectionDependencyFactory; 20 class PeerConnectionDependencyFactory;
19 class MediaStreamVideoWebRtcSink; 21 class MediaStreamVideoWebRtcSink;
22 class WebRtcAudioSink;
20 23
21 // WebRtcMediaStreamAdapter is an adapter between a blink::WebMediaStream 24 // WebRtcMediaStreamAdapter is an adapter between a blink::WebMediaStream
22 // object and a webrtc MediaStreams that is currently sent on a PeerConnection. 25 // object and a webrtc MediaStreams that is currently sent on a PeerConnection.
23 // The responsibility of the class is to create and own a representation of a 26 // The responsibility of the class is to create and own a representation of a
24 // webrtc MediaStream that can be added and removed from a RTCPeerConnection. 27 // webrtc MediaStream that can be added and removed from a RTCPeerConnection.
25 // An instance of WebRtcMediaStreamAdapter is created when a MediaStream is 28 // An instance of WebRtcMediaStreamAdapter is created when a MediaStream is
26 // added to an RTCPeerConnection object 29 // added to an RTCPeerConnection object
27 // Instances of this class is owned by the RTCPeerConnectionHandler object that 30 // Instances of this class is owned by the RTCPeerConnectionHandler object that
28 // created it. 31 // created it.
29 class CONTENT_EXPORT WebRtcMediaStreamAdapter 32 class CONTENT_EXPORT WebRtcMediaStreamAdapter
30 : NON_EXPORTED_BASE(public MediaStreamObserver) { 33 : NON_EXPORTED_BASE(public MediaStreamObserver) {
31 public: 34 public:
32 WebRtcMediaStreamAdapter(const blink::WebMediaStream& web_stream, 35 WebRtcMediaStreamAdapter(const blink::WebMediaStream& web_stream,
33 PeerConnectionDependencyFactory* factory); 36 PeerConnectionDependencyFactory* factory);
34 ~WebRtcMediaStreamAdapter() override; 37 ~WebRtcMediaStreamAdapter() override;
35 38
36 bool IsEqual(const blink::WebMediaStream& web_stream) { 39 bool IsEqual(const blink::WebMediaStream& web_stream) const {
37 return web_stream_.getExtraData() == web_stream.getExtraData(); 40 return web_stream_.getExtraData() == web_stream.getExtraData();
38 } 41 }
39 42
40 webrtc::MediaStreamInterface* webrtc_media_stream() { 43 webrtc::MediaStreamInterface* webrtc_media_stream() const {
41 return webrtc_media_stream_.get(); 44 return webrtc_media_stream_.get();
42 } 45 }
43 46
44 protected: 47 protected:
45 // MediaStreamObserver implementation. 48 // MediaStreamObserver implementation.
46 void TrackAdded(const blink::WebMediaStreamTrack& track) override; 49 void TrackAdded(const blink::WebMediaStreamTrack& track) override;
47 void TrackRemoved(const blink::WebMediaStreamTrack& track) override; 50 void TrackRemoved(const blink::WebMediaStreamTrack& track) override;
48 51
49 private: 52 private:
50 void CreateAudioTrack(const blink::WebMediaStreamTrack& track); 53 void AddAudioSinkToTrack(const blink::WebMediaStreamTrack& track);
51 void CreateVideoTrack(const blink::WebMediaStreamTrack& track); 54 void AddVideoSinkToTrack(const blink::WebMediaStreamTrack& track);
52 55
53 const blink::WebMediaStream web_stream_; 56 const blink::WebMediaStream web_stream_;
54 57
55 // Pointer to a PeerConnectionDependencyFactory, owned by the RenderThread. 58 // Pointer to a PeerConnectionDependencyFactory, owned by the RenderThread.
56 // It's valid for the lifetime of RenderThread. 59 // It's valid for the lifetime of RenderThread.
57 PeerConnectionDependencyFactory* const factory_; 60 PeerConnectionDependencyFactory* const factory_;
58 61
59 scoped_refptr<webrtc::MediaStreamInterface> webrtc_media_stream_; 62 scoped_refptr<webrtc::MediaStreamInterface> webrtc_media_stream_;
60 ScopedVector<MediaStreamVideoWebRtcSink> video_adapters_; 63 std::vector<std::unique_ptr<WebRtcAudioSink>> audio_sinks_;
64 std::vector<std::unique_ptr<MediaStreamVideoWebRtcSink>> video_sinks_;
61 65
62 DISALLOW_COPY_AND_ASSIGN (WebRtcMediaStreamAdapter); 66 DISALLOW_COPY_AND_ASSIGN (WebRtcMediaStreamAdapter);
63 }; 67 };
64 68
65 } // namespace content 69 } // namespace content
66 70
67 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_ADAPTER_H_ 71 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_MEDIA_STREAM_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698