2727#include " api/scoped_refptr.h"
2828#include " api/sequence_checker.h"
2929#include " api/transport/rtp/rtp_source.h"
30+ #include " api/task_queue/pending_task_safety_flag.h"
3031#include " api/video/video_frame.h"
3132#include " api/video/video_sink_interface.h"
3233#include " api/video/video_source_interface.h"
4243
4344namespace webrtc {
4445
45- class VideoRtpReceiver : public RtpReceiverInternal {
46+ class VideoRtpReceiver : public RtpReceiverInternal ,
47+ public ObserverInterface {
4648 public:
4749 // An SSRC of 0 will create a receiver that will match the first SSRC it
4850 // sees. Must be called on signaling thread.
@@ -60,6 +62,9 @@ class VideoRtpReceiver : public RtpReceiverInternal {
6062
6163 scoped_refptr<VideoTrackInterface> video_track () const { return track_; }
6264
65+ // ObserverInterface implementation
66+ void OnChanged () override ;
67+
6368 // RtpReceiverInterface implementation
6469 scoped_refptr<MediaStreamTrackInterface> track () const override {
6570 return track_;
@@ -114,6 +119,8 @@ class VideoRtpReceiver : public RtpReceiverInternal {
114119 private:
115120 void RestartMediaChannel (std::optional<uint32_t > ssrc)
116121 RTC_RUN_ON(&signaling_thread_checker_);
122+ void StartMediaChannel ();
123+ void StopMediaChannel ();
117124 void RestartMediaChannel_w (std::optional<uint32_t > ssrc,
118125 MediaSourceInterface::SourceState state)
119126 RTC_RUN_ON(worker_thread_);
@@ -158,6 +165,8 @@ class VideoRtpReceiver : public RtpReceiverInternal {
158165 RTC_GUARDED_BY (&signaling_thread_checker_) = nullptr ;
159166 bool received_first_packet_ RTC_GUARDED_BY (&signaling_thread_checker_) =
160167 false;
168+
169+ bool cached_track_should_receive_ RTC_GUARDED_BY (&signaling_thread_checker_);
161170 const int attachment_id_;
162171 scoped_refptr<FrameDecryptorInterface> frame_decryptor_
163172 RTC_GUARDED_BY (worker_thread_);
@@ -173,6 +182,7 @@ class VideoRtpReceiver : public RtpReceiverInternal {
173182 // or switched.
174183 bool saved_generate_keyframe_ RTC_GUARDED_BY (worker_thread_) = false;
175184 bool saved_encoded_sink_enabled_ RTC_GUARDED_BY (worker_thread_) = false;
185+ const rtc::scoped_refptr<PendingTaskSafetyFlag> worker_thread_safety_;
176186};
177187
178188} // namespace webrtc
0 commit comments