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

Side by Side Diff: media/cast/video_receiver/video_receiver.cc

Issue 136903003: cast: Wire upp logging to be sent over RTCP between receiver and sender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge TOT Created 6 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
OLDNEW
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/logging.h" 10 #include "base/logging.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); 399 base::TimeTicks now = cast_environment_->Clock()->NowTicks();
400 if (time_incoming_packet_.is_null() || now - time_incoming_packet_ > 400 if (time_incoming_packet_.is_null() || now - time_incoming_packet_ >
401 base::TimeDelta::FromMilliseconds(kMinTimeBetweenOffsetUpdatesMs)) { 401 base::TimeDelta::FromMilliseconds(kMinTimeBetweenOffsetUpdatesMs)) {
402 if (time_incoming_packet_.is_null()) InitializeTimers(); 402 if (time_incoming_packet_.is_null()) InitializeTimers();
403 incoming_rtp_timestamp_ = rtp_header.webrtc.header.timestamp; 403 incoming_rtp_timestamp_ = rtp_header.webrtc.header.timestamp;
404 time_incoming_packet_ = now; 404 time_incoming_packet_ = now;
405 time_incoming_packet_updated_ = true; 405 time_incoming_packet_updated_ = true;
406 } 406 }
407 407
408 cast_environment_->Logging()->InsertPacketEvent(now, kPacketReceived, 408 cast_environment_->Logging()->InsertPacketEvent(now, kVideoPacketReceived,
409 rtp_header.webrtc.header.timestamp, rtp_header.frame_id, 409 rtp_header.webrtc.header.timestamp, rtp_header.frame_id,
410 rtp_header.packet_id, rtp_header.max_packet_id, payload_size); 410 rtp_header.packet_id, rtp_header.max_packet_id, payload_size);
411 411
412 bool duplicate = false; 412 bool duplicate = false;
413 bool complete = framer_->InsertPacket(payload_data, payload_size, rtp_header, 413 bool complete = framer_->InsertPacket(payload_data, payload_size, rtp_header,
414 &duplicate); 414 &duplicate);
415 415
416 if (duplicate) { 416 if (duplicate) {
417 cast_environment_->Logging()->InsertPacketEvent(now, 417 cast_environment_->Logging()->InsertPacketEvent(now,
418 kDuplicatePacketReceived, 418 kDuplicatePacketReceived,
419 rtp_header.webrtc.header.timestamp, rtp_header.frame_id, 419 rtp_header.webrtc.header.timestamp, rtp_header.frame_id,
420 rtp_header.packet_id, rtp_header.max_packet_id, payload_size); 420 rtp_header.packet_id, rtp_header.max_packet_id, payload_size);
421 // Duplicate packets are ignored. 421 // Duplicate packets are ignored.
422 return; 422 return;
423 } 423 }
424 if (!complete) return; // Video frame not complete; wait for more packets. 424 if (!complete) return; // Video frame not complete; wait for more packets.
425 if (queued_encoded_callbacks_.empty()) return; // No pending callback. 425 if (queued_encoded_callbacks_.empty()) return; // No pending callback.
426 426
427 VideoFrameEncodedCallback callback = queued_encoded_callbacks_.front(); 427 VideoFrameEncodedCallback callback = queued_encoded_callbacks_.front();
428 queued_encoded_callbacks_.pop_front(); 428 queued_encoded_callbacks_.pop_front();
429 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, 429 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE,
430 base::Bind(&VideoReceiver::GetEncodedVideoFrame, 430 base::Bind(&VideoReceiver::GetEncodedVideoFrame,
431 weak_factory_.GetWeakPtr(), callback)); 431 weak_factory_.GetWeakPtr(), callback));
432 } 432 }
433 433
434 // Send a cast feedback message. Actual message created in the framer (cast 434 // Send a cast feedback message. Actual message created in the framer (cast
435 // message builder). 435 // message builder).
436 void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) { 436 void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) {
437 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 437 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
438 // TODO(pwestin): wire up log messages. 438
439 rtcp_->SendRtcpFromRtpReceiver(&cast_message, NULL); 439 RtcpReceiverLogMessage receiver_log;
440 time_last_sent_cast_message_= cast_environment_->Clock()->NowTicks(); 440 VideoRtcpRawMap video_logs =
441 cast_environment_->Logging()->GetVideoRtcpRawData();
442
443 while (!video_logs.empty()) {
444 VideoRtcpRawMap::iterator it = video_logs.begin();
445 uint32 rtp_timestamp = it->first;
446 std::pair<VideoRtcpRawMap::iterator, VideoRtcpRawMap::iterator>
447 frame_range = video_logs.equal_range(rtp_timestamp);
448
449 RtcpReceiverFrameLogMessage frame_log(rtp_timestamp);
450
451 VideoRtcpRawMap::const_iterator event_it = frame_range.first;
452 for (; event_it != frame_range.second; ++event_it) {
453 RtcpReceiverEventLogMessage event_log_message;
454 event_log_message.type = event_it->second.type;
455 event_log_message.event_timestamp = event_it->second.timestamp;
456 event_log_message.delay_delta = event_it->second.delay_delta;
457 event_log_message.packet_id = event_it->second.packet_id;
458 frame_log.event_log_messages_.push_back(event_log_message);
459 }
460 receiver_log.push_back(frame_log);
461 video_logs.erase(rtp_timestamp);
462 }
463 base::TimeTicks now = cast_environment_->Clock()->NowTicks();
464 cast_environment_->Logging()->InsertGenericEvent(now, kVideoAckSent,
465 cast_message.ack_frame_id_);
466
467 rtcp_->SendRtcpFromRtpReceiver(&cast_message, &receiver_log);
468 time_last_sent_cast_message_= now;
441 } 469 }
442 470
443 // Cast messages should be sent within a maximum interval. Schedule a call 471 // Cast messages should be sent within a maximum interval. Schedule a call
444 // if not triggered elsewhere, e.g. by the cast message_builder. 472 // if not triggered elsewhere, e.g. by the cast message_builder.
445 void VideoReceiver::ScheduleNextCastMessage() { 473 void VideoReceiver::ScheduleNextCastMessage() {
446 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 474 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
447 base::TimeTicks send_time; 475 base::TimeTicks send_time;
448 framer_->TimeToSendNextCastMessage(&send_time); 476 framer_->TimeToSendNextCastMessage(&send_time);
449 477
450 base::TimeDelta time_to_send = send_time - 478 base::TimeDelta time_to_send = send_time -
(...skipping 26 matching lines...) Expand all
477 } 505 }
478 506
479 void VideoReceiver::SendNextRtcpReport() { 507 void VideoReceiver::SendNextRtcpReport() {
480 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 508 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
481 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL); 509 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL);
482 ScheduleNextRtcpReport(); 510 ScheduleNextRtcpReport();
483 } 511 }
484 512
485 } // namespace cast 513 } // namespace cast
486 } // namespace media 514 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/video_receiver/video_decoder_unittest.cc ('k') | media/cast/video_receiver/video_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698