OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 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 | 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_RTC_RTP_SENDER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map.h" |
10 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
11 #include "third_party/WebKit/public/platform/WebRTCRtpSender.h" | 12 #include "third_party/WebKit/public/platform/WebRTCRtpSender.h" |
12 #include "third_party/webrtc/api/rtpsenderinterface.h" | 13 #include "third_party/webrtc/api/rtpsenderinterface.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 // Used to surface |webrtc::RtpSenderInterface| to blink. Multiple | 17 // Used to surface |webrtc::RtpSenderInterface| to blink. Multiple |
17 // |RTCRtpSender|s could reference the same webrtc receiver; |id| is the value | 18 // |RTCRtpSender|s could reference the same webrtc receiver; |id| is the value |
18 // of the pointer to the webrtc sender. | 19 // of the pointer to the webrtc sender. |
19 class CONTENT_EXPORT RTCRtpSender : public blink::WebRTCRtpSender { | 20 class CONTENT_EXPORT RTCRtpSender : public blink::WebRTCRtpSender { |
20 public: | 21 public: |
21 static uintptr_t getId(const webrtc::RtpSenderInterface* webrtc_rtp_sender); | 22 static uintptr_t getId(const webrtc::RtpSenderInterface* webrtc_rtp_sender); |
22 | 23 |
23 RTCRtpSender(webrtc::RtpSenderInterface* webrtc_rtp_sender, | 24 RTCRtpSender(scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender, |
24 std::unique_ptr<blink::WebMediaStreamTrack> web_track); | 25 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> |
| 26 track_adapter); |
25 ~RTCRtpSender() override; | 27 ~RTCRtpSender() override; |
26 | 28 |
27 uintptr_t Id() const override; | 29 uintptr_t Id() const override; |
28 const blink::WebMediaStreamTrack* Track() const override; | 30 const blink::WebMediaStreamTrack* Track() const override; |
29 | 31 |
30 const webrtc::MediaStreamTrackInterface* webrtc_track() const; | 32 const webrtc::MediaStreamTrackInterface* webrtc_track() const; |
31 | 33 |
32 private: | 34 private: |
33 const scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender_; | 35 const scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender_; |
34 std::unique_ptr<blink::WebMediaStreamTrack> web_track_; | 36 // The track adapter is the glue between blink and webrtc layer tracks. |
| 37 // Keeping a reference to the adapter ensures it is not disposed, as is |
| 38 // required as long as the webrtc layer track is in use by the sender. |
| 39 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> track_adapter_; |
35 }; | 40 }; |
36 | 41 |
37 } // namespace content | 42 } // namespace content |
38 | 43 |
39 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ | 44 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ |
OLD | NEW |