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

Side by Side Diff: content/renderer/media/webrtc/media_stream_remote_video_source.cc

Issue 699613002: Change DtmfSenderHandler to handle events on the signaling thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android build. Created 6 years, 1 month 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 | « content/renderer/media/webrtc/media_stream_remote_video_source.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" 5 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const media::VideoCaptureFormat& format) { 124 const media::VideoCaptureFormat& format) {
125 DCHECK(io_message_loop_->BelongsToCurrentThread()); 125 DCHECK(io_message_loop_->BelongsToCurrentThread());
126 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::DoRenderFrameOnIOThread"); 126 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::DoRenderFrameOnIOThread");
127 // TODO(hclam): Give the estimated capture time. 127 // TODO(hclam): Give the estimated capture time.
128 frame_callback_.Run(video_frame, format, base::TimeTicks()); 128 frame_callback_.Run(video_frame, format, base::TimeTicks());
129 } 129 }
130 130
131 MediaStreamRemoteVideoSource::Observer::Observer( 131 MediaStreamRemoteVideoSource::Observer::Observer(
132 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, 132 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread,
133 webrtc::VideoTrackInterface* track) 133 webrtc::VideoTrackInterface* track)
134 : main_thread_(main_thread), track_(track), state_(track->state()) { 134 : main_thread_(main_thread),
135 #if DCHECK_IS_ON
136 source_set_(false),
137 #endif
138 track_(track),
139 state_(track->state()) {
135 track->RegisterObserver(this); 140 track->RegisterObserver(this);
136 } 141 }
137 142
138 const scoped_refptr<webrtc::VideoTrackInterface>& 143 const scoped_refptr<webrtc::VideoTrackInterface>&
139 MediaStreamRemoteVideoSource::Observer::track() { 144 MediaStreamRemoteVideoSource::Observer::track() {
140 DCHECK(main_thread_->BelongsToCurrentThread()); 145 DCHECK(main_thread_->BelongsToCurrentThread());
141 return track_; 146 return track_;
142 } 147 }
143 148
144 webrtc::MediaStreamTrackInterface::TrackState 149 webrtc::MediaStreamTrackInterface::TrackState
145 MediaStreamRemoteVideoSource::Observer::state() const { 150 MediaStreamRemoteVideoSource::Observer::state() const {
146 DCHECK(main_thread_->BelongsToCurrentThread()); 151 DCHECK(main_thread_->BelongsToCurrentThread());
147 return state_; 152 return state_;
148 } 153 }
149 154
150 MediaStreamRemoteVideoSource::Observer::~Observer() { 155 MediaStreamRemoteVideoSource::Observer::~Observer() {
151 DCHECK(main_thread_->BelongsToCurrentThread()); 156 DCHECK(main_thread_->BelongsToCurrentThread());
152 track_->UnregisterObserver(this); 157 track_->UnregisterObserver(this);
153 } 158 }
154 159
155 void MediaStreamRemoteVideoSource::Observer::SetSource( 160 void MediaStreamRemoteVideoSource::Observer::SetSource(
156 const base::WeakPtr<MediaStreamRemoteVideoSource>& source) { 161 const base::WeakPtr<MediaStreamRemoteVideoSource>& source) {
157 DCHECK(main_thread_->BelongsToCurrentThread()); 162 DCHECK(main_thread_->BelongsToCurrentThread());
158 DCHECK(!source_); 163 DCHECK(!source_);
159 source_ = source; 164 source_ = source;
165 #if DCHECK_IS_ON
166 // |source_set_| means that there is a MediaStreamRemoteVideoSource that
167 // should handle all state changes. Since an Observer is always created when
168 // a remote MediaStream changes in RemoteMediaStreamImpl::Observer::OnChanged,
169 // it can happen that an Observer is created but SetSource is never called.
170 source_set_ = true;
171 #endif
160 } 172 }
161 173
162 void MediaStreamRemoteVideoSource::Observer::OnChanged() { 174 void MediaStreamRemoteVideoSource::Observer::OnChanged() {
163 webrtc::MediaStreamTrackInterface::TrackState state = track_->state(); 175 webrtc::MediaStreamTrackInterface::TrackState state = track_->state();
164 main_thread_->PostTask(FROM_HERE, 176 main_thread_->PostTask(FROM_HERE,
165 base::Bind(&MediaStreamRemoteVideoSource::Observer::OnChangedImpl, 177 base::Bind(&MediaStreamRemoteVideoSource::Observer::OnChangedImpl,
166 this, state)); 178 this, state));
167 } 179 }
168 180
169 void MediaStreamRemoteVideoSource::Observer::OnChangedImpl( 181 void MediaStreamRemoteVideoSource::Observer::OnChangedImpl(
170 webrtc::MediaStreamTrackInterface::TrackState state) { 182 webrtc::MediaStreamTrackInterface::TrackState state) {
171 DCHECK(main_thread_->BelongsToCurrentThread()); 183 DCHECK(main_thread_->BelongsToCurrentThread());
172 DCHECK(source_) << "Dropping a state change event. " << state; 184 #if DCHECK_IS_ON
185 DCHECK(source_ || !source_set_) << "Dropping a state change event. " << state;
186 #endif
173 if (source_ && state != state_) 187 if (source_ && state != state_)
174 source_->OnChanged(state); 188 source_->OnChanged(state);
175 state_ = state; 189 state_ = state;
176 } 190 }
177 191
178 MediaStreamRemoteVideoSource::MediaStreamRemoteVideoSource( 192 MediaStreamRemoteVideoSource::MediaStreamRemoteVideoSource(
179 const scoped_refptr<MediaStreamRemoteVideoSource::Observer>& observer) 193 const scoped_refptr<MediaStreamRemoteVideoSource::Observer>& observer)
180 : observer_(observer), weak_factory_(this) { 194 : observer_(observer), weak_factory_(this) {
181 observer->SetSource(weak_factory_.GetWeakPtr()); 195 observer->SetSource(weak_factory_.GetWeakPtr());
182 } 196 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 case webrtc::MediaStreamTrackInterface::kEnded: 246 case webrtc::MediaStreamTrackInterface::kEnded:
233 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); 247 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
234 break; 248 break;
235 default: 249 default:
236 NOTREACHED(); 250 NOTREACHED();
237 break; 251 break;
238 } 252 }
239 } 253 }
240 254
241 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/media_stream_remote_video_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698