Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "remoting/client/plugin/pepper_video_renderer_3d.h" | 5 #include "remoting/client/plugin/pepper_video_renderer_3d.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/metrics/histogram_macros.h" | |
| 10 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 11 #include "ppapi/c/pp_codecs.h" | 12 #include "ppapi/c/pp_codecs.h" |
| 12 #include "ppapi/c/ppb_opengles2.h" | 13 #include "ppapi/c/ppb_opengles2.h" |
| 13 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
| 14 #include "ppapi/lib/gl/include/GLES2/gl2.h" | 15 #include "ppapi/lib/gl/include/GLES2/gl2.h" |
| 15 #include "ppapi/lib/gl/include/GLES2/gl2ext.h" | 16 #include "ppapi/lib/gl/include/GLES2/gl2ext.h" |
| 16 #include "remoting/proto/video.pb.h" | 17 #include "remoting/proto/video.pb.h" |
| 17 #include "remoting/protocol/session_config.h" | 18 #include "remoting/protocol/session_config.h" |
| 18 | 19 |
| 19 namespace remoting { | 20 namespace remoting { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { | 185 protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { |
| 185 return this; | 186 return this; |
| 186 } | 187 } |
| 187 | 188 |
| 188 void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, | 189 void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, |
| 189 const base::Closure& done) { | 190 const base::Closure& done) { |
| 190 base::ScopedClosureRunner done_runner(done); | 191 base::ScopedClosureRunner done_runner(done); |
| 191 | 192 |
| 192 // Don't need to do anything if the packet is empty. Host sends empty video | 193 // Don't need to do anything if the packet is empty. Host sends empty video |
| 193 // packets when the screen is not changing. | 194 // packets when the screen is not changing. |
| 194 if (!packet->data().size()) | 195 if (!packet->data().size()) |
|
Sergey Ulanov
2015/06/19 23:08:42
When a frame is empty it's currently not counted f
anandc
2015/06/20 01:31:32
Done.
| |
| 195 return; | 196 return; |
| 196 | 197 |
| 197 // Update statistics. | 198 // Update statistics and UMA histograms. |
| 198 stats_.video_frame_rate()->Record(1); | 199 stats_.video_frame_rate()->Record(1); |
| 199 stats_.video_bandwidth()->Record(packet->data().size()); | 200 stats_.video_bandwidth()->Record(packet->data().size()); |
| 200 if (packet->has_capture_time_ms()) | 201 if (packet->has_capture_time_ms()) { |
| 201 stats_.video_capture_ms()->Record(packet->capture_time_ms()); | 202 stats_.video_capture_ms()->Record(packet->capture_time_ms()); |
| 202 if (packet->has_encode_time_ms()) | 203 const base::TimeDelta capture_time = |
| 204 base::TimeDelta::FromInternalValue(packet->capture_time_ms()); | |
| 205 UMA_HISTOGRAM_TIMES("Chromoting.Video.CaptureLatency", capture_time); | |
| 206 } | |
| 207 if (packet->has_encode_time_ms()) { | |
| 203 stats_.video_encode_ms()->Record(packet->encode_time_ms()); | 208 stats_.video_encode_ms()->Record(packet->encode_time_ms()); |
| 209 const base::TimeDelta encode_time = | |
| 210 base::TimeDelta::FromInternalValue(packet->encode_time_ms()); | |
| 211 UMA_HISTOGRAM_TIMES("Chromoting.Video.EncodeLatency", encode_time); | |
| 212 } | |
| 204 if (packet->has_latest_event_timestamp() && | 213 if (packet->has_latest_event_timestamp() && |
| 205 packet->latest_event_timestamp() > latest_input_event_timestamp_) { | 214 packet->latest_event_timestamp() > latest_input_event_timestamp_) { |
| 206 latest_input_event_timestamp_ = packet->latest_event_timestamp(); | 215 latest_input_event_timestamp_ = packet->latest_event_timestamp(); |
| 207 base::TimeDelta round_trip_latency = | 216 base::TimeDelta round_trip_latency = |
| 208 base::Time::Now() - | 217 base::Time::Now() - |
| 209 base::Time::FromInternalValue(packet->latest_event_timestamp()); | 218 base::Time::FromInternalValue(packet->latest_event_timestamp()); |
| 210 stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds()); | 219 stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds()); |
| 220 UMA_HISTOGRAM_TIMES("Chromoting.Video.RoundTripLatency", | |
| 221 round_trip_latency); | |
| 211 } | 222 } |
| 212 | 223 |
| 213 bool resolution_changed = false; | 224 bool resolution_changed = false; |
| 214 | 225 |
| 215 if (packet->format().has_screen_width() && | 226 if (packet->format().has_screen_width() && |
| 216 packet->format().has_screen_height()) { | 227 packet->format().has_screen_height()) { |
| 217 webrtc::DesktopSize frame_size(packet->format().screen_width(), | 228 webrtc::DesktopSize frame_size(packet->format().screen_width(), |
| 218 packet->format().screen_height()); | 229 packet->format().screen_height()); |
| 219 if (!frame_size_.equals(frame_size)) { | 230 if (!frame_size_.equals(frame_size)) { |
| 220 frame_size_ = frame_size; | 231 frame_size_ = frame_size; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); | 541 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); |
| 531 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); | 542 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); |
| 532 } | 543 } |
| 533 | 544 |
| 534 void PepperVideoRenderer3D::CheckGLError() { | 545 void PepperVideoRenderer3D::CheckGLError() { |
| 535 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); | 546 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); |
| 536 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; | 547 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; |
| 537 } | 548 } |
| 538 | 549 |
| 539 } // namespace remoting | 550 } // namespace remoting |
| OLD | NEW |