diff options
-rw-r--r-- | remoting/codec/video_encoder.h | 5 | ||||
-rw-r--r-- | remoting/codec/video_encoder_verbatim.cc | 3 | ||||
-rw-r--r-- | remoting/codec/video_encoder_verbatim.h | 2 | ||||
-rw-r--r-- | remoting/codec/video_encoder_vp8.cc | 5 | ||||
-rw-r--r-- | remoting/host/video_frame_capturer_fake.cc | 5 | ||||
-rw-r--r-- | remoting/host/video_frame_capturer_linux.cc | 6 | ||||
-rw-r--r-- | remoting/host/video_frame_capturer_mac.mm | 4 | ||||
-rw-r--r-- | remoting/host/video_frame_capturer_win.cc | 15 | ||||
-rw-r--r-- | remoting/host/video_scheduler.cc | 16 | ||||
-rw-r--r-- | remoting/host/video_scheduler.h | 6 |
10 files changed, 43 insertions, 24 deletions
diff --git a/remoting/codec/video_encoder.h b/remoting/codec/video_encoder.h index b9bee8b..5cc4c10 100644 --- a/remoting/codec/video_encoder.h +++ b/remoting/codec/video_encoder.h @@ -24,9 +24,8 @@ class VideoPacket; class VideoEncoder { public: - // DataAvailableCallback is called as blocks of data are made available - // from the encoder. Data made available by the encoder is in the form - // of HostMessage to reduce the amount of memory copies. + // DataAvailableCallback is called one or more times, for each chunk the + // underlying video encoder generates. typedef base::Callback<void(scoped_ptr<VideoPacket>)> DataAvailableCallback; virtual ~VideoEncoder() {} diff --git a/remoting/codec/video_encoder_verbatim.cc b/remoting/codec/video_encoder_verbatim.cc index 25f2217..1352aa6 100644 --- a/remoting/codec/video_encoder_verbatim.cc +++ b/remoting/codec/video_encoder_verbatim.cc @@ -34,6 +34,7 @@ void VideoEncoderVerbatim::Encode( << capture_data->pixel_format(); capture_data_ = capture_data; callback_ = data_available_callback; + encode_start_time_ = base::Time::Now(); const SkRegion& region = capture_data->dirty_region(); SkRegion::Iterator iter(region); @@ -92,6 +93,8 @@ void VideoEncoderVerbatim::EncodeRect(const SkIRect& rect, bool last) { packet->mutable_data()->resize(filled); packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET); packet->set_capture_time_ms(capture_data_->capture_time_ms()); + packet->set_encode_time_ms( + (base::Time::Now() - encode_start_time_).InMillisecondsRoundedUp()); packet->set_client_sequence_number( capture_data_->client_sequence_number()); SkIPoint dpi(capture_data_->dpi()); diff --git a/remoting/codec/video_encoder_verbatim.h b/remoting/codec/video_encoder_verbatim.h index 02c5814..6477b2a 100644 --- a/remoting/codec/video_encoder_verbatim.h +++ b/remoting/codec/video_encoder_verbatim.h @@ -5,6 +5,7 @@ #ifndef REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_ #define REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_ +#include "base/time.h" #include "remoting/codec/video_encoder.h" #include "remoting/proto/video.pb.h" #include "third_party/skia/include/core/SkRect.h" @@ -44,6 +45,7 @@ class VideoEncoderVerbatim : public VideoEncoder { scoped_refptr<CaptureData> capture_data_; DataAvailableCallback callback_; + base::Time encode_start_time_; // The most recent screen size. SkISize screen_size_; diff --git a/remoting/codec/video_encoder_vp8.cc b/remoting/codec/video_encoder_vp8.cc index e133113..5370549 100644 --- a/remoting/codec/video_encoder_vp8.cc +++ b/remoting/codec/video_encoder_vp8.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/sys_info.h" +#include "base/time.h" #include "media/base/yuv_convert.h" #include "remoting/base/capture_data.h" #include "remoting/base/util.h" @@ -220,6 +221,8 @@ void VideoEncoderVp8::Encode( DCHECK_LE(32, capture_data->size().width()); DCHECK_LE(32, capture_data->size().height()); + base::Time encode_start_time = base::Time::Now(); + if (!initialized_ || (capture_data->size() != SkISize::Make(image_->w, image_->h))) { bool ret = Init(capture_data->size()); @@ -288,6 +291,8 @@ void VideoEncoderVp8::Encode( packet->mutable_format()->set_screen_width(capture_data->size().width()); packet->mutable_format()->set_screen_height(capture_data->size().height()); packet->set_capture_time_ms(capture_data->capture_time_ms()); + packet->set_encode_time_ms( + (base::Time::Now() - encode_start_time).InMillisecondsRoundedUp()); packet->set_client_sequence_number(capture_data->client_sequence_number()); SkIPoint dpi(capture_data->dpi()); if (dpi.x()) diff --git a/remoting/host/video_frame_capturer_fake.cc b/remoting/host/video_frame_capturer_fake.cc index 27b2b54..652e21a 100644 --- a/remoting/host/video_frame_capturer_fake.cc +++ b/remoting/host/video_frame_capturer_fake.cc @@ -4,6 +4,7 @@ #include "remoting/host/video_frame_capturer_fake.h" +#include "base/time.h" #include "remoting/base/capture_data.h" namespace remoting { @@ -55,6 +56,8 @@ void VideoFrameCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { } void VideoFrameCapturerFake::CaptureFrame() { + base::Time capture_start_time = base::Time::Now(); + GenerateImage(); helper_.InvalidateScreen(size_); @@ -73,6 +76,8 @@ void VideoFrameCapturerFake::CaptureFrame() { helper_.set_size_most_recent(capture_data->size()); + capture_data->set_capture_time_ms( + (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); delegate_->OnCaptureCompleted(capture_data); } diff --git a/remoting/host/video_frame_capturer_linux.cc b/remoting/host/video_frame_capturer_linux.cc index 0ecdd12..0ebbc69 100644 --- a/remoting/host/video_frame_capturer_linux.cc +++ b/remoting/host/video_frame_capturer_linux.cc @@ -14,6 +14,7 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/time.h" #include "remoting/base/capture_data.h" #include "remoting/host/differ.h" #include "remoting/host/linux/x_server_pixel_buffer.h" @@ -299,6 +300,8 @@ void VideoFrameCapturerLinux::InvalidateRegion(const SkRegion& invalid_region) { } void VideoFrameCapturerLinux::CaptureFrame() { + base::Time capture_start_time = base::Time::Now(); + // Process XEvents for XDamage and cursor shape tracking. ProcessPendingXEvents(); @@ -330,6 +333,9 @@ void VideoFrameCapturerLinux::CaptureFrame() { last_invalid_region_ = capture_data->dirty_region(); queue_.DoneWithCurrentFrame(); + + capture_data->set_capture_time_ms( + (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); delegate_->OnCaptureCompleted(capture_data); } diff --git a/remoting/host/video_frame_capturer_mac.mm b/remoting/host/video_frame_capturer_mac.mm index 859dcb7..3d0d624 100644 --- a/remoting/host/video_frame_capturer_mac.mm +++ b/remoting/host/video_frame_capturer_mac.mm @@ -298,6 +298,8 @@ void VideoFrameCapturerMac::CaptureFrame() { // Only allow captures when the display configuration is not occurring. scoped_refptr<CaptureData> data; + base::Time capture_start_time = base::Time::Now(); + // Wait until the display configuration is stable. If one or more displays // are reconfiguring then |display_configuration_capture_event_| will not be // set until the reconfiguration completes. @@ -363,6 +365,8 @@ void VideoFrameCapturerMac::CaptureFrame() { // Move the capture frame buffer queue on to the next buffer. queue_.DoneWithCurrentFrame(); + data->set_capture_time_ms( + (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); delegate_->OnCaptureCompleted(data); } diff --git a/remoting/host/video_frame_capturer_win.cc b/remoting/host/video_frame_capturer_win.cc index ffb8aee..65a3c19 100644 --- a/remoting/host/video_frame_capturer_win.cc +++ b/remoting/host/video_frame_capturer_win.cc @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/scoped_native_library.h" +#include "base/time.h" #include "base/utf_string_conversions.h" #include "base/win/scoped_gdi_object.h" #include "base/win/scoped_hdc.h" @@ -93,7 +94,8 @@ class VideoFrameCapturerWin : public VideoFrameCapturer { // Creates a CaptureData instance wrapping the current framebuffer and // notifies |delegate_|. - void CaptureRegion(const SkRegion& region); + void CaptureRegion(const SkRegion& region, + const base::Time& capture_start_time); // Captures the current screen contents into the current buffer. void CaptureImage(); @@ -240,6 +242,8 @@ void VideoFrameCapturerWin::InvalidateRegion(const SkRegion& invalid_region) { } void VideoFrameCapturerWin::CaptureFrame() { + base::Time capture_start_time = base::Time::Now(); + // Force the system to power-up display hardware, if it has been suspended. SetThreadExecutionState(ES_DISPLAY_REQUIRED); @@ -278,7 +282,7 @@ void VideoFrameCapturerWin::CaptureFrame() { // the completion callback. SkRegion invalid_region; helper_.SwapInvalidRegion(&invalid_region); - CaptureRegion(invalid_region); + CaptureRegion(invalid_region, capture_start_time); // Check for cursor shape update. CaptureCursor(); @@ -363,7 +367,9 @@ void VideoFrameCapturerWin::PrepareCaptureResources() { } } -void VideoFrameCapturerWin::CaptureRegion(const SkRegion& region) { +void VideoFrameCapturerWin::CaptureRegion( + const SkRegion& region, + const base::Time& capture_start_time) { const VideoFrame* current_buffer = queue_.current_frame(); DataPlanes planes; @@ -379,6 +385,9 @@ void VideoFrameCapturerWin::CaptureRegion(const SkRegion& region) { helper_.set_size_most_recent(data->size()); queue_.DoneWithCurrentFrame(); + + data->set_capture_time_ms( + (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); delegate_->OnCaptureCompleted(data); } diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc index 89eb4c7..305caba 100644 --- a/remoting/host/video_scheduler.cc +++ b/remoting/host/video_scheduler.cc @@ -65,11 +65,8 @@ void VideoScheduler::OnCaptureCompleted( DCHECK(capture_task_runner_->BelongsToCurrentThread()); if (capture_data) { - base::TimeDelta capture_time = base::Time::Now() - capture_start_time_; - int capture_time_ms = - static_cast<int>(capture_time.InMilliseconds()); - capture_data->set_capture_time_ms(capture_time_ms); - scheduler_.RecordCaptureTime(capture_time); + scheduler_.RecordCaptureTime( + base::TimeDelta::FromMilliseconds(capture_data->capture_time_ms())); // The best way to get this value is by binding the sequence number to // the callback when calling CaptureInvalidRects(). However the callback @@ -201,7 +198,6 @@ void VideoScheduler::CaptureNextFrame() { ScheduleNextCapture(); // And finally perform one capture. - capture_start_time_ = base::Time::Now(); capturer_->CaptureFrame(); } @@ -269,7 +265,6 @@ void VideoScheduler::EncodeFrame( return; } - encode_start_time_ = base::Time::Now(); encoder_->Encode( capture_data, false, base::Bind(&VideoScheduler::EncodedDataAvailableCallback, this)); @@ -281,11 +276,8 @@ void VideoScheduler::EncodedDataAvailableCallback( bool last = (packet->flags() & VideoPacket::LAST_PACKET) != 0; if (last) { - base::TimeDelta encode_time = base::Time::Now() - encode_start_time_; - int encode_time_ms = - static_cast<int>(encode_time.InMilliseconds()); - packet->set_encode_time_ms(encode_time_ms); - scheduler_.RecordEncodeTime(encode_time); + scheduler_.RecordEncodeTime( + base::TimeDelta::FromMilliseconds(packet->encode_time_ms())); } network_task_runner_->PostTask( diff --git a/remoting/host/video_scheduler.h b/remoting/host/video_scheduler.h index c57ad10..b8af8d0 100644 --- a/remoting/host/video_scheduler.h +++ b/remoting/host/video_scheduler.h @@ -174,12 +174,6 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, // True if capture of video frames is paused. bool is_paused_; - // Time when capture is started. - base::Time capture_start_time_; - - // Time when encode is started. - base::Time encode_start_time_; - // This is a number updated by client to trace performance. int64 sequence_number_; |