| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/api/rtpreceiver.h" | 11 #include "webrtc/api/rtpreceiver.h" |
| 12 | 12 |
| 13 #include "webrtc/api/videosourceinterface.h" | 13 #include "webrtc/api/mediastreamtrackproxy.h" |
| 14 #include "webrtc/api/videotrack.h" |
| 14 | 15 |
| 15 namespace webrtc { | 16 namespace webrtc { |
| 16 | 17 |
| 17 AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track, | 18 AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track, |
| 18 uint32_t ssrc, | 19 uint32_t ssrc, |
| 19 AudioProviderInterface* provider) | 20 AudioProviderInterface* provider) |
| 20 : id_(track->id()), | 21 : id_(track->id()), |
| 21 track_(track), | 22 track_(track), |
| 22 ssrc_(ssrc), | 23 ssrc_(ssrc), |
| 23 provider_(provider), | 24 provider_(provider), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 provider_ = nullptr; | 59 provider_ = nullptr; |
| 59 } | 60 } |
| 60 | 61 |
| 61 void AudioRtpReceiver::Reconfigure() { | 62 void AudioRtpReceiver::Reconfigure() { |
| 62 if (!provider_) { | 63 if (!provider_) { |
| 63 return; | 64 return; |
| 64 } | 65 } |
| 65 provider_->SetAudioPlayout(ssrc_, track_->enabled()); | 66 provider_->SetAudioPlayout(ssrc_, track_->enabled()); |
| 66 } | 67 } |
| 67 | 68 |
| 68 VideoRtpReceiver::VideoRtpReceiver(VideoTrackInterface* track, | 69 VideoRtpReceiver::VideoRtpReceiver(const std::string& track_id, |
| 70 rtc::Thread* worker_thread, |
| 69 uint32_t ssrc, | 71 uint32_t ssrc, |
| 70 VideoProviderInterface* provider) | 72 VideoProviderInterface* provider) |
| 71 : id_(track->id()), track_(track), ssrc_(ssrc), provider_(provider) { | 73 : id_(track_id), |
| 72 provider_->SetVideoPlayout(ssrc_, true, track_->GetSink()); | 74 ssrc_(ssrc), |
| 75 provider_(provider), |
| 76 source_(new RefCountedObject<VideoTrackSource>(&broadcaster_, |
| 77 worker_thread, |
| 78 true /* remote */)), |
| 79 track_(VideoTrackProxy::Create( |
| 80 rtc::Thread::Current(), |
| 81 VideoTrack::Create(track_id, source_.get()))) { |
| 82 source_->SetState(MediaSourceInterface::kLive); |
| 83 // TODO(perkj): It should be enough to set the source state. All tracks |
| 84 // belonging to the same source should get its state from the source. |
| 85 // I.e. if a track has been cloned from a remote source. |
| 86 track_->set_state(webrtc::MediaStreamTrackInterface::kLive); |
| 87 provider_->SetVideoPlayout(ssrc_, true, &broadcaster_); |
| 73 } | 88 } |
| 74 | 89 |
| 75 VideoRtpReceiver::~VideoRtpReceiver() { | 90 VideoRtpReceiver::~VideoRtpReceiver() { |
| 76 // Since cricket::VideoRenderer is not reference counted, | 91 // Since cricket::VideoRenderer is not reference counted, |
| 77 // we need to remove it from the provider before we are deleted. | 92 // we need to remove it from the provider before we are deleted. |
| 78 Stop(); | 93 Stop(); |
| 79 } | 94 } |
| 80 | 95 |
| 81 void VideoRtpReceiver::Stop() { | 96 void VideoRtpReceiver::Stop() { |
| 82 // TODO(deadbeef): Need to do more here to fully stop receiving packets. | 97 // TODO(deadbeef): Need to do more here to fully stop receiving packets. |
| 83 if (!provider_) { | 98 if (!provider_) { |
| 84 return; | 99 return; |
| 85 } | 100 } |
| 101 source_->SetState(MediaSourceInterface::kEnded); |
| 102 source_->OnSourceDestroyed(); |
| 103 // TODO(perkj): It should be enough to set the source state. All tracks |
| 104 // belonging to the same source should get its state from the source. |
| 105 track_->set_state(MediaStreamTrackInterface::kEnded); |
| 86 provider_->SetVideoPlayout(ssrc_, false, nullptr); | 106 provider_->SetVideoPlayout(ssrc_, false, nullptr); |
| 87 provider_ = nullptr; | 107 provider_ = nullptr; |
| 88 } | 108 } |
| 89 | 109 |
| 90 } // namespace webrtc | 110 } // namespace webrtc |
| OLD | NEW |