| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/video_receiver/video_receiver.h" | 5 #include "media/cast/video_receiver/video_receiver.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 size_t payload_size, | 308 size_t payload_size, |
| 309 const RtpCastHeader& rtp_header) { | 309 const RtpCastHeader& rtp_header) { |
| 310 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 310 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 311 | 311 |
| 312 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 312 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
| 313 if (time_incoming_packet_.is_null() || | 313 if (time_incoming_packet_.is_null() || |
| 314 now - time_incoming_packet_ > | 314 now - time_incoming_packet_ > |
| 315 base::TimeDelta::FromMilliseconds(kMinTimeBetweenOffsetUpdatesMs)) { | 315 base::TimeDelta::FromMilliseconds(kMinTimeBetweenOffsetUpdatesMs)) { |
| 316 if (time_incoming_packet_.is_null()) | 316 if (time_incoming_packet_.is_null()) |
| 317 InitializeTimers(); | 317 InitializeTimers(); |
| 318 incoming_rtp_timestamp_ = rtp_header.webrtc.header.timestamp; | 318 incoming_rtp_timestamp_ = rtp_header.rtp_timestamp; |
| 319 // The following incoming packet info is used for syncing sender and | 319 // The following incoming packet info is used for syncing sender and |
| 320 // receiver clock. Use only the first packet of every frame to obtain a | 320 // receiver clock. Use only the first packet of every frame to obtain a |
| 321 // minimal value. | 321 // minimal value. |
| 322 if (rtp_header.packet_id == 0) { | 322 if (rtp_header.packet_id == 0) { |
| 323 time_incoming_packet_ = now; | 323 time_incoming_packet_ = now; |
| 324 time_incoming_packet_updated_ = true; | 324 time_incoming_packet_updated_ = true; |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 frame_id_to_rtp_timestamp_[rtp_header.frame_id & 0xff] = | 328 frame_id_to_rtp_timestamp_[rtp_header.frame_id & 0xff] = |
| 329 rtp_header.webrtc.header.timestamp; | 329 rtp_header.rtp_timestamp; |
| 330 cast_environment_->Logging()->InsertPacketEvent( | 330 cast_environment_->Logging()->InsertPacketEvent( |
| 331 now, | 331 now, |
| 332 kVideoPacketReceived, | 332 kVideoPacketReceived, |
| 333 rtp_header.webrtc.header.timestamp, | 333 rtp_header.rtp_timestamp, |
| 334 rtp_header.frame_id, | 334 rtp_header.frame_id, |
| 335 rtp_header.packet_id, | 335 rtp_header.packet_id, |
| 336 rtp_header.max_packet_id, | 336 rtp_header.max_packet_id, |
| 337 payload_size); | 337 payload_size); |
| 338 | 338 |
| 339 bool duplicate = false; | 339 bool duplicate = false; |
| 340 const bool complete = | 340 const bool complete = |
| 341 framer_.InsertPacket(payload_data, payload_size, rtp_header, &duplicate); | 341 framer_.InsertPacket(payload_data, payload_size, rtp_header, &duplicate); |
| 342 if (duplicate) { | 342 if (duplicate) { |
| 343 cast_environment_->Logging()->InsertPacketEvent( | 343 cast_environment_->Logging()->InsertPacketEvent( |
| 344 now, | 344 now, |
| 345 kDuplicateVideoPacketReceived, | 345 kDuplicateVideoPacketReceived, |
| 346 rtp_header.webrtc.header.timestamp, | 346 rtp_header.rtp_timestamp, |
| 347 rtp_header.frame_id, | 347 rtp_header.frame_id, |
| 348 rtp_header.packet_id, | 348 rtp_header.packet_id, |
| 349 rtp_header.max_packet_id, | 349 rtp_header.max_packet_id, |
| 350 payload_size); | 350 payload_size); |
| 351 // Duplicate packets are ignored. | 351 // Duplicate packets are ignored. |
| 352 return; | 352 return; |
| 353 } | 353 } |
| 354 if (!complete) | 354 if (!complete) |
| 355 return; // Video frame not complete; wait for more packets. | 355 return; // Video frame not complete; wait for more packets. |
| 356 | 356 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 414 } |
| 415 | 415 |
| 416 void VideoReceiver::SendNextRtcpReport() { | 416 void VideoReceiver::SendNextRtcpReport() { |
| 417 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 417 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 418 rtcp_.SendRtcpFromRtpReceiver(NULL, NULL); | 418 rtcp_.SendRtcpFromRtpReceiver(NULL, NULL); |
| 419 ScheduleNextRtcpReport(); | 419 ScheduleNextRtcpReport(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 } // namespace cast | 422 } // namespace cast |
| 423 } // namespace media | 423 } // namespace media |
| OLD | NEW |