OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "modules/peerconnection/RTCRtpSender.h" | 5 #include "modules/peerconnection/RTCRtpSender.h" |
6 | 6 |
7 #include "modules/mediastream/MediaStreamTrack.h" | 7 #include "modules/mediastream/MediaStreamTrack.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 namespace { | |
12 | |
13 bool TrackEquals(const MediaStreamTrack* track, | |
14 const WebMediaStreamTrack* web_track) { | |
15 if (track) | |
16 return web_track && web_track->Id() == static_cast<WebString>(track->id()); | |
Guido Urdaneta
2017/07/05 15:37:06
How does this static_cast actually work?
Shouldn'
hbos_chromium
2017/07/06 12:31:38
Done.
I had to do some sort of casting because ==
| |
17 return !web_track; | |
18 } | |
19 | |
20 } // namespace | |
21 | |
11 RTCRtpSender::RTCRtpSender(std::unique_ptr<WebRTCRtpSender> sender, | 22 RTCRtpSender::RTCRtpSender(std::unique_ptr<WebRTCRtpSender> sender, |
12 MediaStreamTrack* track) | 23 MediaStreamTrack* track) |
13 : sender_(std::move(sender)), track_(track) { | 24 : sender_(std::move(sender)), track_(track) { |
14 DCHECK(sender_); | 25 DCHECK(sender_); |
15 DCHECK(track_); | 26 DCHECK(track_); |
16 } | 27 } |
17 | 28 |
18 MediaStreamTrack* RTCRtpSender::track() { | 29 MediaStreamTrack* RTCRtpSender::track() { |
19 DCHECK((track_ && sender_->Track() && | 30 DCHECK(TrackEquals(track_, sender_->Track())); |
20 sender_->Track()->Id() == static_cast<WebString>(track_->id())) || | |
21 (!track_ && !sender_->Track())); | |
22 return track_; | 31 return track_; |
23 } | 32 } |
24 | 33 |
34 WebRTCRtpSender* RTCRtpSender::web_rtp_sender() { | |
35 return sender_.get(); | |
36 } | |
37 | |
38 void RTCRtpSender::SetTrack(MediaStreamTrack* track) { | |
39 DCHECK(TrackEquals(track, sender_->Track())); | |
40 track_ = track; | |
41 } | |
42 | |
25 DEFINE_TRACE(RTCRtpSender) { | 43 DEFINE_TRACE(RTCRtpSender) { |
26 visitor->Trace(track_); | 44 visitor->Trace(track_); |
27 } | 45 } |
28 | 46 |
29 } // namespace blink | 47 } // namespace blink |
OLD | NEW |