| OLD | NEW |
| 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 #ifndef MEDIA_REMOTING_REMOTE_RENDERER_IMPL_H_ | 5 #ifndef MEDIA_REMOTING_REMOTE_RENDERER_IMPL_H_ |
| 6 #define MEDIA_REMOTING_REMOTE_RENDERER_IMPL_H_ | 6 #define MEDIA_REMOTING_REMOTE_RENDERER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/optional.h" | 16 #include "base/optional.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/timer/timer.h" |
| 18 #include "media/base/buffering_state.h" | 19 #include "media/base/buffering_state.h" |
| 19 #include "media/base/pipeline_status.h" | 20 #include "media/base/pipeline_status.h" |
| 20 #include "media/base/renderer.h" | 21 #include "media/base/renderer.h" |
| 21 #include "media/base/renderer_client.h" | 22 #include "media/base/renderer_client.h" |
| 22 #include "media/mojo/interfaces/remoting.mojom.h" | 23 #include "media/mojo/interfaces/remoting.mojom.h" |
| 24 #include "media/remoting/metrics.h" |
| 23 #include "media/remoting/remoting_interstitial_ui.h" | 25 #include "media/remoting/remoting_interstitial_ui.h" |
| 24 #include "media/remoting/rpc/rpc_broker.h" | 26 #include "media/remoting/rpc/rpc_broker.h" |
| 25 #include "mojo/public/cpp/system/data_pipe.h" | 27 #include "mojo/public/cpp/system/data_pipe.h" |
| 26 | 28 |
| 27 namespace media { | 29 namespace media { |
| 28 | 30 |
| 29 class RemotingRendererController; | 31 class RemotingRendererController; |
| 30 class Renderer; | 32 class Renderer; |
| 31 | 33 |
| 32 namespace remoting { | 34 namespace remoting { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const gfx::Size& canvas_size, | 139 const gfx::Size& canvas_size, |
| 138 RemotingInterstitialType interstitial_type); | 140 RemotingInterstitialType interstitial_type); |
| 139 | 141 |
| 140 // Called when |current_media_time_| is updated. | 142 // Called when |current_media_time_| is updated. |
| 141 void OnMediaTimeUpdated(); | 143 void OnMediaTimeUpdated(); |
| 142 | 144 |
| 143 // Called to update the |video_stats_queue_|. | 145 // Called to update the |video_stats_queue_|. |
| 144 void UpdateVideoStatsQueue(int video_frames_decoded, | 146 void UpdateVideoStatsQueue(int video_frames_decoded, |
| 145 int video_frames_dropped); | 147 int video_frames_dropped); |
| 146 | 148 |
| 147 // Called to clear |media_time_queue_| and |video_stats_queue_|. | 149 // Called to clear all recent measurements history and schedule resuming after |
| 148 void ResetQueues(); | 150 // a stabilization period elapses. |
| 151 void ResetMeasurements(); |
| 149 | 152 |
| 150 // Called when irregular playback is detected. | 153 // Called when a fatal runtime error occurs. |stop_trigger| is the error code |
| 151 void OnIrregularPlaybackDetected(); | 154 // handed to the RemotingRendererController. |
| 155 void OnFatalError(remoting::StopTrigger stop_trigger); |
| 152 | 156 |
| 153 // Shut down remoting session. | 157 // Called periodically to measure the data flows from the |
| 154 void OnFatalError(PipelineStatus status); | 158 // DemuxerStreamAdapters and record this information in the metrics. |
| 159 void MeasureAndRecordDataRates(); |
| 155 | 160 |
| 156 State state_; | 161 State state_; |
| 157 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 162 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 158 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 163 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 159 | 164 |
| 160 // Current renderer playback time information. | 165 // Current renderer playback time information. |
| 161 base::TimeDelta current_media_time_; | 166 base::TimeDelta current_media_time_; |
| 162 base::TimeDelta current_max_time_; | 167 base::TimeDelta current_max_time_; |
| 163 // Both |current_media_time_| and |current_max_time_| should be protected by | 168 // Both |current_media_time_| and |current_max_time_| should be protected by |
| 164 // lock because it can be accessed from both media and render main thread. | 169 // lock because it can be accessed from both media and render main thread. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 214 |
| 210 // Stores all updates on the number of video frames decoded/dropped, and the | 215 // Stores all updates on the number of video frames decoded/dropped, and the |
| 211 // local time when updated in the moving time window. This is used to check | 216 // local time when updated in the moving time window. This is used to check |
| 212 // whether too many video frames were dropped. | 217 // whether too many video frames were dropped. |
| 213 std::deque<std::tuple<base::TimeTicks, int, int>> video_stats_queue_; | 218 std::deque<std::tuple<base::TimeTicks, int, int>> video_stats_queue_; |
| 214 | 219 |
| 215 // The total number of frames decoded/dropped in the time window. | 220 // The total number of frames decoded/dropped in the time window. |
| 216 int sum_video_frames_decoded_ = 0; | 221 int sum_video_frames_decoded_ = 0; |
| 217 int sum_video_frames_dropped_ = 0; | 222 int sum_video_frames_dropped_ = 0; |
| 218 | 223 |
| 224 // Records events and measurements of interest. |
| 225 remoting::RendererMetricsRecorder metrics_recorder_; |
| 226 |
| 227 // A timer that polls the RemoteDemuxerStreamAdapters periodically to measure |
| 228 // the data flow rates for metrics. |
| 229 base::RepeatingTimer data_flow_poll_timer_; |
| 230 |
| 219 base::WeakPtrFactory<RemoteRendererImpl> weak_factory_; | 231 base::WeakPtrFactory<RemoteRendererImpl> weak_factory_; |
| 220 | 232 |
| 221 DISALLOW_COPY_AND_ASSIGN(RemoteRendererImpl); | 233 DISALLOW_COPY_AND_ASSIGN(RemoteRendererImpl); |
| 222 }; | 234 }; |
| 223 | 235 |
| 224 } // namespace media | 236 } // namespace media |
| 225 | 237 |
| 226 #endif // MEDIA_REMOTING_REMOTE_RENDERER_IMPL_H_ | 238 #endif // MEDIA_REMOTING_REMOTE_RENDERER_IMPL_H_ |
| OLD | NEW |