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

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

Issue 1999853002: Forward the SignalFirstPacketReceived to RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modified the unit test. Created 4 years, 6 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
« no previous file with comments | « webrtc/api/rtpreceiver.h ('k') | webrtc/api/rtpreceiverinterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 17 matching lines...) Expand all
28 track_(AudioTrackProxy::Create( 28 track_(AudioTrackProxy::Create(
29 rtc::Thread::Current(), 29 rtc::Thread::Current(),
30 AudioTrack::Create(track_id, 30 AudioTrack::Create(track_id,
31 RemoteAudioSource::Create(ssrc, provider)))), 31 RemoteAudioSource::Create(ssrc, provider)))),
32 cached_track_enabled_(track_->enabled()) { 32 cached_track_enabled_(track_->enabled()) {
33 RTC_DCHECK(track_->GetSource()->remote()); 33 RTC_DCHECK(track_->GetSource()->remote());
34 track_->RegisterObserver(this); 34 track_->RegisterObserver(this);
35 track_->GetSource()->RegisterAudioObserver(this); 35 track_->GetSource()->RegisterAudioObserver(this);
36 Reconfigure(); 36 Reconfigure();
37 stream->AddTrack(track_); 37 stream->AddTrack(track_);
38 provider_->SignalFirstAudioPacketReceived.connect(
39 this, &AudioRtpReceiver::OnFirstAudioPacketReceived);
38 } 40 }
39 41
40 AudioRtpReceiver::~AudioRtpReceiver() { 42 AudioRtpReceiver::~AudioRtpReceiver() {
41 track_->GetSource()->UnregisterAudioObserver(this); 43 track_->GetSource()->UnregisterAudioObserver(this);
42 track_->UnregisterObserver(this); 44 track_->UnregisterObserver(this);
43 Stop(); 45 Stop();
44 } 46 }
45 47
46 void AudioRtpReceiver::OnChanged() { 48 void AudioRtpReceiver::OnChanged() {
47 if (cached_track_enabled_ != track_->enabled()) { 49 if (cached_track_enabled_ != track_->enabled()) {
(...skipping 28 matching lines...) Expand all
76 provider_ = nullptr; 78 provider_ = nullptr;
77 } 79 }
78 80
79 void AudioRtpReceiver::Reconfigure() { 81 void AudioRtpReceiver::Reconfigure() {
80 if (!provider_) { 82 if (!provider_) {
81 return; 83 return;
82 } 84 }
83 provider_->SetAudioPlayout(ssrc_, track_->enabled()); 85 provider_->SetAudioPlayout(ssrc_, track_->enabled());
84 } 86 }
85 87
88 void AudioRtpReceiver::SetObserver(RtpReceiverObserverInterface* observer) {
89 observer_ = observer;
90 // If received the first packet before setting the observer, call the
91 // observer.
92 if (received_first_packet_) {
93 observer_->OnFirstPacketReceived(media_type());
94 }
95 }
96
97 void AudioRtpReceiver::OnFirstAudioPacketReceived() {
98 if (observer_) {
99 observer_->OnFirstPacketReceived(media_type());
100 }
101 received_first_packet_ = true;
102 }
103
86 VideoRtpReceiver::VideoRtpReceiver(MediaStreamInterface* stream, 104 VideoRtpReceiver::VideoRtpReceiver(MediaStreamInterface* stream,
87 const std::string& track_id, 105 const std::string& track_id,
88 rtc::Thread* worker_thread, 106 rtc::Thread* worker_thread,
89 uint32_t ssrc, 107 uint32_t ssrc,
90 VideoProviderInterface* provider) 108 VideoProviderInterface* provider)
91 : id_(track_id), 109 : id_(track_id),
92 ssrc_(ssrc), 110 ssrc_(ssrc),
93 provider_(provider), 111 provider_(provider),
94 source_(new RefCountedObject<VideoTrackSource>(&broadcaster_, 112 source_(new RefCountedObject<VideoTrackSource>(&broadcaster_,
95 true /* remote */)), 113 true /* remote */)),
96 track_(VideoTrackProxy::Create( 114 track_(VideoTrackProxy::Create(
97 rtc::Thread::Current(), 115 rtc::Thread::Current(),
98 worker_thread, 116 worker_thread,
99 VideoTrack::Create( 117 VideoTrack::Create(
100 track_id, 118 track_id,
101 VideoTrackSourceProxy::Create(rtc::Thread::Current(), 119 VideoTrackSourceProxy::Create(rtc::Thread::Current(),
102 worker_thread, 120 worker_thread,
103 source_)))) { 121 source_)))) {
104 source_->SetState(MediaSourceInterface::kLive); 122 source_->SetState(MediaSourceInterface::kLive);
105 provider_->SetVideoPlayout(ssrc_, true, &broadcaster_); 123 provider_->SetVideoPlayout(ssrc_, true, &broadcaster_);
106 stream->AddTrack(track_); 124 stream->AddTrack(track_);
125 provider_->SignalFirstVideoPacketReceived.connect(
126 this, &VideoRtpReceiver::OnFirstVideoPacketReceived);
107 } 127 }
108 128
109 VideoRtpReceiver::~VideoRtpReceiver() { 129 VideoRtpReceiver::~VideoRtpReceiver() {
110 // Since cricket::VideoRenderer is not reference counted, 130 // Since cricket::VideoRenderer is not reference counted,
111 // we need to remove it from the provider before we are deleted. 131 // we need to remove it from the provider before we are deleted.
112 Stop(); 132 Stop();
113 } 133 }
114 134
115 RtpParameters VideoRtpReceiver::GetParameters() const { 135 RtpParameters VideoRtpReceiver::GetParameters() const {
116 return provider_->GetVideoRtpReceiveParameters(ssrc_); 136 return provider_->GetVideoRtpReceiveParameters(ssrc_);
117 } 137 }
118 138
119 bool VideoRtpReceiver::SetParameters(const RtpParameters& parameters) { 139 bool VideoRtpReceiver::SetParameters(const RtpParameters& parameters) {
120 TRACE_EVENT0("webrtc", "VideoRtpReceiver::SetParameters"); 140 TRACE_EVENT0("webrtc", "VideoRtpReceiver::SetParameters");
121 return provider_->SetVideoRtpReceiveParameters(ssrc_, parameters); 141 return provider_->SetVideoRtpReceiveParameters(ssrc_, parameters);
122 } 142 }
123 143
124 void VideoRtpReceiver::Stop() { 144 void VideoRtpReceiver::Stop() {
125 // TODO(deadbeef): Need to do more here to fully stop receiving packets. 145 // TODO(deadbeef): Need to do more here to fully stop receiving packets.
126 if (!provider_) { 146 if (!provider_) {
127 return; 147 return;
128 } 148 }
129 source_->SetState(MediaSourceInterface::kEnded); 149 source_->SetState(MediaSourceInterface::kEnded);
130 source_->OnSourceDestroyed(); 150 source_->OnSourceDestroyed();
131 provider_->SetVideoPlayout(ssrc_, false, nullptr); 151 provider_->SetVideoPlayout(ssrc_, false, nullptr);
132 provider_ = nullptr; 152 provider_ = nullptr;
133 } 153 }
134 154
155 void VideoRtpReceiver::SetObserver(RtpReceiverObserverInterface* observer) {
156 observer_ = observer;
157 // If received the first packet before setting the observer, call the
158 // observer.
159 if (received_first_packet_) {
160 observer_->OnFirstPacketReceived(media_type());
161 }
162 }
163
164 void VideoRtpReceiver::OnFirstVideoPacketReceived() {
165 if (observer_) {
166 observer_->OnFirstPacketReceived(media_type());
167 }
168 received_first_packet_ = true;
169 }
170
135 } // namespace webrtc 171 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/rtpreceiver.h ('k') | webrtc/api/rtpreceiverinterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698