| 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 #ifndef RTCRtpReceiver_h | 5 #ifndef RTCRtpReceiver_h |
| 6 #define RTCRtpReceiver_h | 6 #define RTCRtpReceiver_h |
| 7 | 7 |
| 8 #include <map> | |
| 9 | |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "modules/mediastream/MediaStreamTrack.h" | 9 #include "modules/mediastream/MediaStreamTrack.h" |
| 12 #include "modules/peerconnection/RTCRtpContributingSource.h" | |
| 13 #include "platform/heap/GarbageCollected.h" | 10 #include "platform/heap/GarbageCollected.h" |
| 14 #include "platform/heap/Member.h" | 11 #include "platform/heap/Member.h" |
| 15 #include "platform/heap/Visitor.h" | 12 #include "platform/heap/Visitor.h" |
| 16 #include "public/platform/WebRTCRtpReceiver.h" | 13 #include "public/platform/WebRTCRtpReceiver.h" |
| 17 | 14 |
| 18 namespace blink { | 15 namespace blink { |
| 19 | 16 |
| 20 // https://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface | 17 // https://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface |
| 21 class RTCRtpReceiver final : public GarbageCollectedFinalized<RTCRtpReceiver>, | 18 class RTCRtpReceiver final : public GarbageCollectedFinalized<RTCRtpReceiver>, |
| 22 public ScriptWrappable { | 19 public ScriptWrappable { |
| 23 DEFINE_WRAPPERTYPEINFO(); | 20 DEFINE_WRAPPERTYPEINFO(); |
| 24 | 21 |
| 25 public: | 22 public: |
| 26 // Takes ownership of the receiver. | 23 // Takes ownership of the receiver. |
| 27 RTCRtpReceiver(std::unique_ptr<WebRTCRtpReceiver>, MediaStreamTrack*); | 24 RTCRtpReceiver(std::unique_ptr<WebRTCRtpReceiver>, MediaStreamTrack*); |
| 28 | 25 |
| 29 MediaStreamTrack* track() const; | 26 MediaStreamTrack* track() const; |
| 30 const HeapVector<Member<RTCRtpContributingSource>>& getContributingSources(); | |
| 31 | |
| 32 void UpdateSourcesIfNeeded(); | |
| 33 | 27 |
| 34 DECLARE_VIRTUAL_TRACE(); | 28 DECLARE_VIRTUAL_TRACE(); |
| 35 | 29 |
| 36 private: | 30 private: |
| 37 void SetContributingSourcesNeedsUpdating(); | |
| 38 | |
| 39 std::unique_ptr<WebRTCRtpReceiver> receiver_; | 31 std::unique_ptr<WebRTCRtpReceiver> receiver_; |
| 40 Member<MediaStreamTrack> track_; | 32 Member<MediaStreamTrack> track_; |
| 41 | |
| 42 // All contributing sources that have ever been returned by | |
| 43 // |getContributingSources| that are still alive. If |UpdateSourcesIfNeeded| | |
| 44 // encounters a source that already has an associate | |
| 45 // |RTCRtpContributingSource| it will be kept up-to-date. Garbage collected | |
| 46 // sources are automatically removed from the map. | |
| 47 HeapHashMap<uint32_t, | |
| 48 WeakMember<RTCRtpContributingSource>, | |
| 49 typename DefaultHash<uint32_t>::Hash, | |
| 50 WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> | |
| 51 contributing_sources_by_source_id_; | |
| 52 // The current contributing sources (|getContributingSources|). | |
| 53 HeapVector<Member<RTCRtpContributingSource>> contributing_sources_; | |
| 54 bool contributing_sources_needs_updating_ = true; | |
| 55 }; | 33 }; |
| 56 | 34 |
| 57 } // namespace blink | 35 } // namespace blink |
| 58 | 36 |
| 59 #endif // RTCRtpReceiver_h | 37 #endif // RTCRtpReceiver_h |
| OLD | NEW |