| 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 <memory> |
| 9 #include <vector> |
| 10 |
| 9 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter_map.h" |
| 10 #include "content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map.h" | 13 #include "content/renderer/media/webrtc/webrtc_media_stream_track_adapter_map.h" |
| 11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 12 #include "third_party/WebKit/public/platform/WebRTCRtpSender.h" | 15 #include "third_party/WebKit/public/platform/WebRTCRtpSender.h" |
| 13 #include "third_party/webrtc/api/rtpsenderinterface.h" | 16 #include "third_party/webrtc/api/rtpsenderinterface.h" |
| 17 #include "third_party/webrtc/rtc_base/scoped_ref_ptr.h" |
| 14 | 18 |
| 15 namespace content { | 19 namespace content { |
| 16 | 20 |
| 17 // Used to surface |webrtc::RtpSenderInterface| to blink. Multiple | 21 // Used to surface |webrtc::RtpSenderInterface| to blink. Multiple |
| 18 // |RTCRtpSender|s could reference the same webrtc receiver; |id| is the value | 22 // |RTCRtpSender|s could reference the same webrtc receiver; |id| is the value |
| 19 // of the pointer to the webrtc sender. | 23 // of the pointer to the webrtc sender. |
| 20 class CONTENT_EXPORT RTCRtpSender : public blink::WebRTCRtpSender { | 24 class CONTENT_EXPORT RTCRtpSender : public blink::WebRTCRtpSender { |
| 21 public: | 25 public: |
| 22 static uintptr_t getId(const webrtc::RtpSenderInterface* webrtc_rtp_sender); | 26 static uintptr_t getId(const webrtc::RtpSenderInterface* webrtc_rtp_sender); |
| 23 | 27 |
| 24 RTCRtpSender(scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender, | 28 RTCRtpSender(rtc::scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender, |
| 25 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> | 29 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> |
| 26 track_adapter); | 30 track_adapter); |
| 31 RTCRtpSender( |
| 32 rtc::scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender, |
| 33 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> |
| 34 track_adapter, |
| 35 std::vector<std::unique_ptr<WebRtcMediaStreamAdapterMap::AdapterRef>> |
| 36 stream_adapters); |
| 27 ~RTCRtpSender() override; | 37 ~RTCRtpSender() override; |
| 28 | 38 |
| 29 uintptr_t Id() const override; | 39 uintptr_t Id() const override; |
| 30 const blink::WebMediaStreamTrack* Track() const override; | 40 const blink::WebMediaStreamTrack* Track() const override; |
| 31 | 41 |
| 42 void OnRemoved(); |
| 43 webrtc::RtpSenderInterface* webrtc_rtp_sender(); |
| 32 const webrtc::MediaStreamTrackInterface* webrtc_track() const; | 44 const webrtc::MediaStreamTrackInterface* webrtc_track() const; |
| 33 | 45 |
| 34 private: | 46 private: |
| 35 const scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender_; | 47 const rtc::scoped_refptr<webrtc::RtpSenderInterface> webrtc_rtp_sender_; |
| 36 // The track adapter is the glue between blink and webrtc layer tracks. | 48 // 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 | 49 // 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. | 50 // required as long as the webrtc layer track is in use by the sender. |
| 39 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> track_adapter_; | 51 std::unique_ptr<WebRtcMediaStreamTrackAdapterMap::AdapterRef> track_adapter_; |
| 52 // Similarly, reference needs to be kept to the stream adapters when a sender |
| 53 // is created for |addTrack| with associated stream(s). |
| 54 std::vector<std::unique_ptr<WebRtcMediaStreamAdapterMap::AdapterRef>> |
| 55 stream_adapters_; |
| 40 }; | 56 }; |
| 41 | 57 |
| 42 } // namespace content | 58 } // namespace content |
| 43 | 59 |
| 44 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ | 60 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_RTC_RTP_SENDER_H_ |
| OLD | NEW |