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

Side by Side Diff: media/cast/receiver/cast_receiver_impl.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Speculative workaround fix for win8_chromium_ng compile error. Created 4 years, 11 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 | « media/cast/receiver/cast_receiver_impl.h ('k') | media/cast/receiver/frame_receiver.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 // 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 "media/cast/receiver/cast_receiver_impl.h" 5 #include "media/cast/receiver/cast_receiver_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return; 120 return;
121 } 121 }
122 122
123 if (!audio_decoder_) { 123 if (!audio_decoder_) {
124 audio_decoder_.reset(new AudioDecoder(cast_environment_, 124 audio_decoder_.reset(new AudioDecoder(cast_environment_,
125 num_audio_channels_, 125 num_audio_channels_,
126 audio_sampling_rate_, 126 audio_sampling_rate_,
127 audio_codec_)); 127 audio_codec_));
128 } 128 }
129 const uint32_t frame_id = encoded_frame->frame_id; 129 const uint32_t frame_id = encoded_frame->frame_id;
130 const uint32_t rtp_timestamp = encoded_frame->rtp_timestamp; 130 const RtpTimeTicks rtp_timestamp = encoded_frame->rtp_timestamp;
131 const base::TimeTicks playout_time = encoded_frame->reference_time; 131 const base::TimeTicks playout_time = encoded_frame->reference_time;
132 audio_decoder_->DecodeFrame( 132 audio_decoder_->DecodeFrame(
133 std::move(encoded_frame), 133 std::move(encoded_frame),
134 base::Bind(&CastReceiverImpl::EmitDecodedAudioFrame, cast_environment_, 134 base::Bind(&CastReceiverImpl::EmitDecodedAudioFrame, cast_environment_,
135 callback, frame_id, rtp_timestamp, playout_time)); 135 callback, frame_id, rtp_timestamp, playout_time));
136 } 136 }
137 137
138 void CastReceiverImpl::DecodeEncodedVideoFrame( 138 void CastReceiverImpl::DecodeEncodedVideoFrame(
139 const VideoFrameDecodedCallback& callback, 139 const VideoFrameDecodedCallback& callback,
140 scoped_ptr<EncodedFrame> encoded_frame) { 140 scoped_ptr<EncodedFrame> encoded_frame) {
141 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 141 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
142 if (!encoded_frame) { 142 if (!encoded_frame) {
143 callback.Run( 143 callback.Run(
144 make_scoped_refptr<VideoFrame>(NULL), base::TimeTicks(), false); 144 make_scoped_refptr<VideoFrame>(NULL), base::TimeTicks(), false);
145 return; 145 return;
146 } 146 }
147 147
148 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc 148 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc
149 TRACE_EVENT_INSTANT2( 149 TRACE_EVENT_INSTANT2(
150 "cast_perf_test", "PullEncodedVideoFrame", 150 "cast_perf_test", "PullEncodedVideoFrame",
151 TRACE_EVENT_SCOPE_THREAD, 151 TRACE_EVENT_SCOPE_THREAD,
152 "rtp_timestamp", encoded_frame->rtp_timestamp, 152 "rtp_timestamp", encoded_frame->rtp_timestamp.lower_32_bits(),
153 "render_time", encoded_frame->reference_time.ToInternalValue()); 153 "render_time", encoded_frame->reference_time.ToInternalValue());
154 154
155 if (!video_decoder_) 155 if (!video_decoder_)
156 video_decoder_.reset(new VideoDecoder(cast_environment_, video_codec_)); 156 video_decoder_.reset(new VideoDecoder(cast_environment_, video_codec_));
157 const uint32_t frame_id = encoded_frame->frame_id; 157 const uint32_t frame_id = encoded_frame->frame_id;
158 const uint32_t rtp_timestamp = encoded_frame->rtp_timestamp; 158 const RtpTimeTicks rtp_timestamp = encoded_frame->rtp_timestamp;
159 const base::TimeTicks playout_time = encoded_frame->reference_time; 159 const base::TimeTicks playout_time = encoded_frame->reference_time;
160 video_decoder_->DecodeFrame( 160 video_decoder_->DecodeFrame(
161 std::move(encoded_frame), 161 std::move(encoded_frame),
162 base::Bind(&CastReceiverImpl::EmitDecodedVideoFrame, cast_environment_, 162 base::Bind(&CastReceiverImpl::EmitDecodedVideoFrame, cast_environment_,
163 callback, frame_id, rtp_timestamp, playout_time)); 163 callback, frame_id, rtp_timestamp, playout_time));
164 } 164 }
165 165
166 // static 166 // static
167 void CastReceiverImpl::EmitDecodedAudioFrame( 167 void CastReceiverImpl::EmitDecodedAudioFrame(
168 const scoped_refptr<CastEnvironment>& cast_environment, 168 const scoped_refptr<CastEnvironment>& cast_environment,
169 const AudioFrameDecodedCallback& callback, 169 const AudioFrameDecodedCallback& callback,
170 uint32_t frame_id, 170 uint32_t frame_id,
171 uint32_t rtp_timestamp, 171 RtpTimeTicks rtp_timestamp,
172 const base::TimeTicks& playout_time, 172 const base::TimeTicks& playout_time,
173 scoped_ptr<AudioBus> audio_bus, 173 scoped_ptr<AudioBus> audio_bus,
174 bool is_continuous) { 174 bool is_continuous) {
175 DCHECK(cast_environment->CurrentlyOn(CastEnvironment::MAIN)); 175 DCHECK(cast_environment->CurrentlyOn(CastEnvironment::MAIN));
176 176
177 if (audio_bus.get()) { 177 if (audio_bus.get()) {
178 // TODO(miu): This is reporting incorrect timestamp and delay. 178 // TODO(miu): This is reporting incorrect timestamp and delay.
179 // http://crbug.com/547251 179 // http://crbug.com/547251
180 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); 180 scoped_ptr<FrameEvent> playout_event(new FrameEvent());
181 playout_event->timestamp = cast_environment->Clock()->NowTicks(); 181 playout_event->timestamp = cast_environment->Clock()->NowTicks();
182 playout_event->type = FRAME_PLAYOUT; 182 playout_event->type = FRAME_PLAYOUT;
183 playout_event->media_type = AUDIO_EVENT; 183 playout_event->media_type = AUDIO_EVENT;
184 playout_event->rtp_timestamp = rtp_timestamp; 184 playout_event->rtp_timestamp = rtp_timestamp;
185 playout_event->frame_id = frame_id; 185 playout_event->frame_id = frame_id;
186 playout_event->delay_delta = playout_time - playout_event->timestamp; 186 playout_event->delay_delta = playout_time - playout_event->timestamp;
187 cast_environment->logger()->DispatchFrameEvent(std::move(playout_event)); 187 cast_environment->logger()->DispatchFrameEvent(std::move(playout_event));
188 } 188 }
189 189
190 callback.Run(std::move(audio_bus), playout_time, is_continuous); 190 callback.Run(std::move(audio_bus), playout_time, is_continuous);
191 } 191 }
192 192
193 // static 193 // static
194 void CastReceiverImpl::EmitDecodedVideoFrame( 194 void CastReceiverImpl::EmitDecodedVideoFrame(
195 const scoped_refptr<CastEnvironment>& cast_environment, 195 const scoped_refptr<CastEnvironment>& cast_environment,
196 const VideoFrameDecodedCallback& callback, 196 const VideoFrameDecodedCallback& callback,
197 uint32_t frame_id, 197 uint32_t frame_id,
198 uint32_t rtp_timestamp, 198 RtpTimeTicks rtp_timestamp,
199 const base::TimeTicks& playout_time, 199 const base::TimeTicks& playout_time,
200 const scoped_refptr<VideoFrame>& video_frame, 200 const scoped_refptr<VideoFrame>& video_frame,
201 bool is_continuous) { 201 bool is_continuous) {
202 DCHECK(cast_environment->CurrentlyOn(CastEnvironment::MAIN)); 202 DCHECK(cast_environment->CurrentlyOn(CastEnvironment::MAIN));
203 203
204 if (video_frame.get()) { 204 if (video_frame.get()) {
205 // TODO(miu): This is reporting incorrect timestamp and delay. 205 // TODO(miu): This is reporting incorrect timestamp and delay.
206 // http://crbug.com/547251 206 // http://crbug.com/547251
207 scoped_ptr<FrameEvent> playout_event(new FrameEvent()); 207 scoped_ptr<FrameEvent> playout_event(new FrameEvent());
208 playout_event->timestamp = cast_environment->Clock()->NowTicks(); 208 playout_event->timestamp = cast_environment->Clock()->NowTicks();
209 playout_event->type = FRAME_PLAYOUT; 209 playout_event->type = FRAME_PLAYOUT;
210 playout_event->media_type = VIDEO_EVENT; 210 playout_event->media_type = VIDEO_EVENT;
211 playout_event->rtp_timestamp = rtp_timestamp; 211 playout_event->rtp_timestamp = rtp_timestamp;
212 playout_event->frame_id = frame_id; 212 playout_event->frame_id = frame_id;
213 playout_event->delay_delta = playout_time - playout_event->timestamp; 213 playout_event->delay_delta = playout_time - playout_event->timestamp;
214 cast_environment->logger()->DispatchFrameEvent(std::move(playout_event)); 214 cast_environment->logger()->DispatchFrameEvent(std::move(playout_event));
215 215
216 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc 216 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc
217 TRACE_EVENT_INSTANT1( 217 TRACE_EVENT_INSTANT1(
218 "cast_perf_test", "FrameDecoded", 218 "cast_perf_test", "FrameDecoded",
219 TRACE_EVENT_SCOPE_THREAD, 219 TRACE_EVENT_SCOPE_THREAD,
220 "rtp_timestamp", rtp_timestamp); 220 "rtp_timestamp", rtp_timestamp.lower_32_bits());
221 } 221 }
222 222
223 callback.Run(video_frame, playout_time, is_continuous); 223 callback.Run(video_frame, playout_time, is_continuous);
224 } 224 }
225 225
226 } // namespace cast 226 } // namespace cast
227 } // namespace media 227 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/receiver/cast_receiver_impl.h ('k') | media/cast/receiver/frame_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698