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/mediastreamtrackproxy.h" | 13 #include "webrtc/api/mediastreamtrackproxy.h" |
| 14 #include "webrtc/api/audiotrack.h" |
14 #include "webrtc/api/videotrack.h" | 15 #include "webrtc/api/videotrack.h" |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 | 18 |
18 AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track, | 19 AudioRtpReceiver::AudioRtpReceiver(MediaStreamInterface* stream, |
| 20 const std::string& track_id, |
19 uint32_t ssrc, | 21 uint32_t ssrc, |
20 AudioProviderInterface* provider) | 22 AudioProviderInterface* provider) |
21 : id_(track->id()), | 23 : id_(track_id), |
22 track_(track), | |
23 ssrc_(ssrc), | 24 ssrc_(ssrc), |
24 provider_(provider), | 25 provider_(provider), |
25 cached_track_enabled_(track->enabled()) { | 26 track_(AudioTrackProxy::Create( |
| 27 rtc::Thread::Current(), |
| 28 AudioTrack::Create(track_id, |
| 29 RemoteAudioSource::Create(ssrc, provider)))), |
| 30 cached_track_enabled_(track_->enabled()) { |
26 RTC_DCHECK(track_->GetSource()->remote()); | 31 RTC_DCHECK(track_->GetSource()->remote()); |
27 track_->RegisterObserver(this); | 32 track_->RegisterObserver(this); |
28 track_->GetSource()->RegisterAudioObserver(this); | 33 track_->GetSource()->RegisterAudioObserver(this); |
29 Reconfigure(); | 34 Reconfigure(); |
| 35 stream->AddTrack(track_); |
30 } | 36 } |
31 | 37 |
32 AudioRtpReceiver::~AudioRtpReceiver() { | 38 AudioRtpReceiver::~AudioRtpReceiver() { |
33 track_->GetSource()->UnregisterAudioObserver(this); | 39 track_->GetSource()->UnregisterAudioObserver(this); |
34 track_->UnregisterObserver(this); | 40 track_->UnregisterObserver(this); |
35 Stop(); | 41 Stop(); |
36 } | 42 } |
37 | 43 |
38 void AudioRtpReceiver::OnChanged() { | 44 void AudioRtpReceiver::OnChanged() { |
39 if (cached_track_enabled_ != track_->enabled()) { | 45 if (cached_track_enabled_ != track_->enabled()) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (!provider_) { | 102 if (!provider_) { |
97 return; | 103 return; |
98 } | 104 } |
99 source_->SetState(MediaSourceInterface::kEnded); | 105 source_->SetState(MediaSourceInterface::kEnded); |
100 source_->OnSourceDestroyed(); | 106 source_->OnSourceDestroyed(); |
101 provider_->SetVideoPlayout(ssrc_, false, nullptr); | 107 provider_->SetVideoPlayout(ssrc_, false, nullptr); |
102 provider_ = nullptr; | 108 provider_ = nullptr; |
103 } | 109 } |
104 | 110 |
105 } // namespace webrtc | 111 } // namespace webrtc |
OLD | NEW |