Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: webrtc/api/rtpreceiver.cc

Issue 1766653002: Replace SetCapturer and SetCaptureDevice by SetSource. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/audiotrack.h"
15 #include "webrtc/api/videotrack.h" 15 #include "webrtc/api/videotrack.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 AudioRtpReceiver::AudioRtpReceiver(MediaStreamInterface* stream, 19 AudioRtpReceiver::AudioRtpReceiver(MediaStreamInterface* stream,
20 const std::string& track_id, 20 const std::string& track_id,
21 uint32_t ssrc, 21 uint32_t ssrc,
22 AudioProviderInterface* provider) 22 AudioProviderInterface* provider)
23 : id_(track_id), 23 : id_(track_id),
24 ssrc_(ssrc), 24 ssrc_(ssrc),
25 provider_(provider), 25 provider_(provider),
26 track_(AudioTrackProxy::Create( 26 track_(AudioTrackProxy::Create(
27 rtc::Thread::Current(), 27 rtc::Thread::Current(), nullptr,
28 AudioTrack::Create(track_id, 28 AudioTrack::Create(track_id,
29 RemoteAudioSource::Create(ssrc, provider)))), 29 RemoteAudioSource::Create(ssrc, provider)))),
30 cached_track_enabled_(track_->enabled()) { 30 cached_track_enabled_(track_->enabled()) {
31 RTC_DCHECK(track_->GetSource()->remote()); 31 RTC_DCHECK(track_->GetSource()->remote());
32 track_->RegisterObserver(this); 32 track_->RegisterObserver(this);
33 track_->GetSource()->RegisterAudioObserver(this); 33 track_->GetSource()->RegisterAudioObserver(this);
34 Reconfigure(); 34 Reconfigure();
35 stream->AddTrack(track_); 35 stream->AddTrack(track_);
36 } 36 }
37 37
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 rtc::Thread* worker_thread, 77 rtc::Thread* worker_thread,
78 uint32_t ssrc, 78 uint32_t ssrc,
79 VideoProviderInterface* provider) 79 VideoProviderInterface* provider)
80 : id_(track_id), 80 : id_(track_id),
81 ssrc_(ssrc), 81 ssrc_(ssrc),
82 provider_(provider), 82 provider_(provider),
83 source_(new RefCountedObject<VideoTrackSource>(&broadcaster_, 83 source_(new RefCountedObject<VideoTrackSource>(&broadcaster_,
84 worker_thread, 84 worker_thread,
85 true /* remote */)), 85 true /* remote */)),
86 track_(VideoTrackProxy::Create( 86 track_(VideoTrackProxy::Create(
87 rtc::Thread::Current(), 87 rtc::Thread::Current(), worker_thread,
88 VideoTrack::Create(track_id, source_.get()))) { 88 VideoTrack::Create(track_id, source_.get()))) {
89 source_->SetState(MediaSourceInterface::kLive); 89 source_->SetState(MediaSourceInterface::kLive);
90 provider_->SetVideoPlayout(ssrc_, true, &broadcaster_); 90 provider_->SetVideoPlayout(ssrc_, true, &broadcaster_);
91 stream->AddTrack(track_); 91 stream->AddTrack(track_);
92 } 92 }
93 93
94 VideoRtpReceiver::~VideoRtpReceiver() { 94 VideoRtpReceiver::~VideoRtpReceiver() {
95 // Since cricket::VideoRenderer is not reference counted, 95 // Since cricket::VideoRenderer is not reference counted,
96 // we need to remove it from the provider before we are deleted. 96 // we need to remove it from the provider before we are deleted.
97 Stop(); 97 Stop();
98 } 98 }
99 99
100 void VideoRtpReceiver::Stop() { 100 void VideoRtpReceiver::Stop() {
101 // TODO(deadbeef): Need to do more here to fully stop receiving packets. 101 // TODO(deadbeef): Need to do more here to fully stop receiving packets.
102 if (!provider_) { 102 if (!provider_) {
103 return; 103 return;
104 } 104 }
105 source_->SetState(MediaSourceInterface::kEnded); 105 source_->SetState(MediaSourceInterface::kEnded);
106 source_->OnSourceDestroyed(); 106 source_->OnSourceDestroyed();
107 provider_->SetVideoPlayout(ssrc_, false, nullptr); 107 provider_->SetVideoPlayout(ssrc_, false, nullptr);
108 provider_ = nullptr; 108 provider_ = nullptr;
109 } 109 }
110 110
111 } // namespace webrtc 111 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698