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

Side by Side Diff: media/remoting/remote_renderer_impl.cc

Issue 2648303003: Media Remoting: Don't exit remoting if no enough data buffered. (Closed)
Patch Set: Addressed comments. Created 3 years, 10 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/remoting/remote_renderer_impl.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/remoting/remote_renderer_impl.h" 5 #include "media/remoting/remote_renderer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 OnFatalError(remoting::RPC_INVALID); 583 OnFatalError(remoting::RPC_INVALID);
584 return; 584 return;
585 } 585 }
586 VLOG(2) << __func__ << ": Received RPC_RC_ONBUFFERINGSTATECHANGE with state=" 586 VLOG(2) << __func__ << ": Received RPC_RC_ONBUFFERINGSTATECHANGE with state="
587 << message->rendererclient_onbufferingstatechange_rpc().state(); 587 << message->rendererclient_onbufferingstatechange_rpc().state();
588 base::Optional<::media::BufferingState> state = 588 base::Optional<::media::BufferingState> state =
589 remoting::ToMediaBufferingState( 589 remoting::ToMediaBufferingState(
590 message->rendererclient_onbufferingstatechange_rpc().state()); 590 message->rendererclient_onbufferingstatechange_rpc().state());
591 if (!state.has_value()) 591 if (!state.has_value())
592 return; 592 return;
593 if (state == BufferingState::BUFFERING_HAVE_NOTHING) {
594 is_waiting_for_buffering_ = true;
595 } else if (is_waiting_for_buffering_) {
596 is_waiting_for_buffering_ = false;
597 ResetMeasurements();
598 }
599
593 client_->OnBufferingStateChange(state.value()); 600 client_->OnBufferingStateChange(state.value());
594 } 601 }
595 602
596 void RemoteRendererImpl::OnVideoNaturalSizeChange( 603 void RemoteRendererImpl::OnVideoNaturalSizeChange(
597 std::unique_ptr<remoting::pb::RpcMessage> message) { 604 std::unique_ptr<remoting::pb::RpcMessage> message) {
598 DCHECK(media_task_runner_->BelongsToCurrentThread()); 605 DCHECK(media_task_runner_->BelongsToCurrentThread());
599 DCHECK(message); 606 DCHECK(message);
600 // Shutdown remoting session if receiving malformed RPC message. 607 // Shutdown remoting session if receiving malformed RPC message.
601 if (!message->has_rendererclient_onvideonatualsizechange_rpc()) { 608 if (!message->has_rendererclient_onvideonatualsizechange_rpc()) {
602 VLOG(1) << __func__ << " missing required RPC message"; 609 VLOG(1) << __func__ << " missing required RPC message";
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 interstitial_background_ = background_image.value(); 727 interstitial_background_ = background_image.value();
721 canvas_size_ = canvas_size; 728 canvas_size_ = canvas_size;
722 PaintRemotingInterstitial(interstitial_background_, canvas_size_, 729 PaintRemotingInterstitial(interstitial_background_, canvas_size_,
723 interstitial_type, video_renderer_sink_); 730 interstitial_type, video_renderer_sink_);
724 } 731 }
725 732
726 void RemoteRendererImpl::OnMediaTimeUpdated() { 733 void RemoteRendererImpl::OnMediaTimeUpdated() {
727 DCHECK(media_task_runner_->BelongsToCurrentThread()); 734 DCHECK(media_task_runner_->BelongsToCurrentThread());
728 if (!flush_cb_.is_null()) 735 if (!flush_cb_.is_null())
729 return; // Don't manage and check the queue when Flush() is on-going. 736 return; // Don't manage and check the queue when Flush() is on-going.
737 if (is_waiting_for_buffering_)
738 return; // Don't manage and check the queue when buffering is on-going.
730 739
731 base::TimeTicks current_time = base::TimeTicks::Now(); 740 base::TimeTicks current_time = base::TimeTicks::Now();
732 if (current_time < ignore_updates_until_time_) 741 if (current_time < ignore_updates_until_time_)
733 return; // Not stable yet. 742 return; // Not stable yet.
734 743
735 media_time_queue_.push_back( 744 media_time_queue_.push_back(
736 std::make_pair(current_time, current_media_time_)); 745 std::make_pair(current_time, current_media_time_));
737 base::TimeDelta window_duration = 746 base::TimeDelta window_duration =
738 current_time - media_time_queue_.front().first; 747 current_time - media_time_queue_.front().first;
739 if (window_duration < kTrackingWindow) 748 if (window_duration < kTrackingWindow)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 kDataFlowPollPeriod.InSecondsF()) / 866 kDataFlowPollPeriod.InSecondsF()) /
858 kBytesPerKilobit; 867 kBytesPerKilobit;
859 DCHECK_GE(kilobits_per_second, 0); 868 DCHECK_GE(kilobits_per_second, 0);
860 const base::CheckedNumeric<int> checked_kbps = kilobits_per_second; 869 const base::CheckedNumeric<int> checked_kbps = kilobits_per_second;
861 metrics_recorder_.OnVideoRateEstimate( 870 metrics_recorder_.OnVideoRateEstimate(
862 checked_kbps.ValueOrDefault(std::numeric_limits<int>::max())); 871 checked_kbps.ValueOrDefault(std::numeric_limits<int>::max()));
863 } 872 }
864 } 873 }
865 874
866 } // namespace media 875 } // namespace media
OLDNEW
« no previous file with comments | « media/remoting/remote_renderer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698