summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2015-01-08 12:57:50 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-08 20:59:01 +0000
commitc258bd4b0dcde95617cada14aa5dc154d456b943 (patch)
tree1176d4a1d411b0f2331da907bf38976e0a5e1e5b
parent13cf2cfcb5325ecfff98ee8ccde723f22e606d22 (diff)
downloadchromium_src-c258bd4b0dcde95617cada14aa5dc154d456b943.zip
chromium_src-c258bd4b0dcde95617cada14aa5dc154d456b943.tar.gz
chromium_src-c258bd4b0dcde95617cada14aa5dc154d456b943.tar.bz2
Rename sequence_number to timestamp.
The sequence_number field is used to send events timestamp. That name was confusing. Renamed sequence_number to timestamp in EventMessage and latest_sequence_number to last_event_timestamp in VideoPacket. TBR=nasko@chromium.org Review URL: https://codereview.chromium.org/836183002 Cr-Commit-Position: refs/heads/master@{#310592}
-rw-r--r--remoting/client/plugin/pepper_video_renderer_3d.cc8
-rw-r--r--remoting/client/software_video_renderer.cc10
-rw-r--r--remoting/client/software_video_renderer.h4
-rw-r--r--remoting/host/chromoting_messages.h4
-rw-r--r--remoting/host/client_session.cc6
-rw-r--r--remoting/host/client_session.h4
-rw-r--r--remoting/host/video_scheduler.cc18
-rw-r--r--remoting/host/video_scheduler.h12
-rw-r--r--remoting/proto/internal.proto3
-rw-r--r--remoting/proto/video.proto6
-rw-r--r--remoting/protocol/client_event_dispatcher.cc6
-rw-r--r--remoting/protocol/connection_to_client.cc8
-rw-r--r--remoting/protocol/connection_to_client.h10
-rw-r--r--remoting/protocol/host_event_dispatcher.cc4
-rw-r--r--remoting/protocol/host_event_dispatcher.h8
-rw-r--r--remoting/protocol/message_decoder_unittest.cc2
-rw-r--r--remoting/protocol/protocol_mock_objects.h4
17 files changed, 59 insertions, 58 deletions
diff --git a/remoting/client/plugin/pepper_video_renderer_3d.cc b/remoting/client/plugin/pepper_video_renderer_3d.cc
index a969b0b..de2d65a 100644
--- a/remoting/client/plugin/pepper_video_renderer_3d.cc
+++ b/remoting/client/plugin/pepper_video_renderer_3d.cc
@@ -193,12 +193,12 @@ void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
stats_.video_capture_ms()->Record(packet->capture_time_ms());
if (packet->has_encode_time_ms())
stats_.video_encode_ms()->Record(packet->encode_time_ms());
- if (packet->has_client_sequence_number() &&
- packet->client_sequence_number() > latest_input_event_timestamp_) {
- latest_input_event_timestamp_ = packet->client_sequence_number();
+ if (packet->has_latest_event_timestamp() &&
+ packet->latest_event_timestamp() > latest_input_event_timestamp_) {
+ latest_input_event_timestamp_ = packet->latest_event_timestamp();
base::TimeDelta round_trip_latency =
base::Time::Now() -
- base::Time::FromInternalValue(packet->client_sequence_number());
+ base::Time::FromInternalValue(packet->latest_event_timestamp());
stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
}
diff --git a/remoting/client/software_video_renderer.cc b/remoting/client/software_video_renderer.cc
index 19ecab8..49c7683 100644
--- a/remoting/client/software_video_renderer.cc
+++ b/remoting/client/software_video_renderer.cc
@@ -318,7 +318,7 @@ SoftwareVideoRenderer::SoftwareVideoRenderer(
scoped_refptr<FrameConsumerProxy> consumer)
: decode_task_runner_(decode_task_runner),
core_(new Core(main_task_runner, decode_task_runner, consumer)),
- latest_sequence_number_(0),
+ latest_event_timestamp_(0),
weak_factory_(this) {
DCHECK(CalledOnValidThread());
}
@@ -361,12 +361,12 @@ void SoftwareVideoRenderer::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
stats_.video_capture_ms()->Record(packet->capture_time_ms());
if (packet->has_encode_time_ms())
stats_.video_encode_ms()->Record(packet->encode_time_ms());
- if (packet->has_client_sequence_number() &&
- packet->client_sequence_number() > latest_sequence_number_) {
- latest_sequence_number_ = packet->client_sequence_number();
+ if (packet->has_latest_event_timestamp() &&
+ packet->latest_event_timestamp() > latest_event_timestamp_) {
+ latest_event_timestamp_ = packet->latest_event_timestamp();
base::TimeDelta round_trip_latency =
base::Time::Now() -
- base::Time::FromInternalValue(packet->client_sequence_number());
+ base::Time::FromInternalValue(packet->latest_event_timestamp());
stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
}
diff --git a/remoting/client/software_video_renderer.h b/remoting/client/software_video_renderer.h
index 8327a43..6843432 100644
--- a/remoting/client/software_video_renderer.h
+++ b/remoting/client/software_video_renderer.h
@@ -72,8 +72,8 @@ class SoftwareVideoRenderer : public VideoRenderer,
ChromotingStats stats_;
- // Keep track of the most recent sequence number bounced back from the host.
- int64 latest_sequence_number_;
+ // Keep track of the latest event timestamp bounced back from the host.
+ int64 latest_event_timestamp_;
base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_;
diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h
index 477fef9..dd7ef41 100644
--- a/remoting/host/chromoting_messages.h
+++ b/remoting/host/chromoting_messages.h
@@ -160,8 +160,8 @@ IPC_STRUCT_BEGIN(SerializedDesktopFrame)
// Time spent in capture. Unit is in milliseconds.
IPC_STRUCT_MEMBER(int64, capture_time_ms)
- // Sequence number supplied by client for performance tracking.
- IPC_STRUCT_MEMBER(int64, client_sequence_number)
+ // Latest event timestamp supplied by the client for performance tracking.
+ IPC_STRUCT_MEMBER(int64, latest_event_timestamp)
// DPI for this frame.
IPC_STRUCT_MEMBER(webrtc::DesktopVector, dpi)
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 5b7daba..d86c955 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -383,13 +383,13 @@ void ClientSession::OnConnectionClosed(
event_handler_->OnSessionClosed(this);
}
-void ClientSession::OnSequenceNumberUpdated(
- protocol::ConnectionToClient* connection, int64 sequence_number) {
+void ClientSession::OnEventTimestamp(protocol::ConnectionToClient* connection,
+ int64 timestamp) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
if (video_scheduler_.get())
- video_scheduler_->UpdateSequenceNumber(sequence_number);
+ video_scheduler_->SetLatestEventTimestamp(timestamp);
}
void ClientSession::OnRouteChange(
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index 38f9753..d0e5d1d 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -123,8 +123,8 @@ class ClientSession
protocol::ConnectionToClient* connection) override;
void OnConnectionClosed(protocol::ConnectionToClient* connection,
protocol::ErrorCode error) override;
- void OnSequenceNumberUpdated(protocol::ConnectionToClient* connection,
- int64 sequence_number) override;
+ void OnEventTimestamp(protocol::ConnectionToClient* connection,
+ int64 timestamp) override;
void OnRouteChange(protocol::ConnectionToClient* connection,
const std::string& channel_name,
const protocol::TransportRoute& route) override;
diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc
index aaa31d1..f2ded20 100644
--- a/remoting/host/video_scheduler.cc
+++ b/remoting/host/video_scheduler.cc
@@ -64,7 +64,7 @@ VideoScheduler::VideoScheduler(
capture_pending_(false),
did_skip_frame_(false),
is_paused_(false),
- sequence_number_(0) {
+ latest_event_timestamp_(0) {
DCHECK(network_task_runner_->BelongsToCurrentThread());
DCHECK(capturer_);
DCHECK(mouse_cursor_monitor_);
@@ -96,7 +96,7 @@ void VideoScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
// that we don't start capturing frame n+2 before frame n is freed.
encode_task_runner_->PostTask(
FROM_HERE, base::Bind(&VideoScheduler::EncodeFrame, this,
- base::Passed(&owned_frame), sequence_number_,
+ base::Passed(&owned_frame), latest_event_timestamp_,
base::TimeTicks::Now()));
// If a frame was skipped, try to capture it again.
@@ -181,16 +181,16 @@ void VideoScheduler::Pause(bool pause) {
}
}
-void VideoScheduler::UpdateSequenceNumber(int64 sequence_number) {
+void VideoScheduler::SetLatestEventTimestamp(int64 latest_event_timestamp) {
if (!capture_task_runner_->BelongsToCurrentThread()) {
DCHECK(network_task_runner_->BelongsToCurrentThread());
capture_task_runner_->PostTask(
- FROM_HERE, base::Bind(&VideoScheduler::UpdateSequenceNumber,
- this, sequence_number));
+ FROM_HERE, base::Bind(&VideoScheduler::SetLatestEventTimestamp,
+ this, latest_event_timestamp));
return;
}
- sequence_number_ = sequence_number;
+ latest_event_timestamp_ = latest_event_timestamp;
}
void VideoScheduler::SetLosslessEncode(bool want_lossless) {
@@ -369,7 +369,7 @@ void VideoScheduler::SendCursorShape(
void VideoScheduler::EncodeFrame(
scoped_ptr<webrtc::DesktopFrame> frame,
- int64 sequence_number,
+ int64 latest_event_timestamp,
base::TimeTicks timestamp) {
DCHECK(encode_task_runner_->BelongsToCurrentThread());
@@ -377,7 +377,7 @@ void VideoScheduler::EncodeFrame(
if (!frame || frame->updated_region().is_empty()) {
capture_task_runner_->DeleteSoon(FROM_HERE, frame.release());
scoped_ptr<VideoPacket> packet(new VideoPacket());
- packet->set_client_sequence_number(sequence_number);
+ packet->set_latest_event_timestamp(latest_event_timestamp);
network_task_runner_->PostTask(
FROM_HERE,
base::Bind(
@@ -386,7 +386,7 @@ void VideoScheduler::EncodeFrame(
}
scoped_ptr<VideoPacket> packet = encoder_->Encode(*frame);
- packet->set_client_sequence_number(sequence_number);
+ packet->set_latest_event_timestamp(latest_event_timestamp);
if (g_enable_timestamps) {
packet->set_timestamp(timestamp.ToInternalValue());
diff --git a/remoting/host/video_scheduler.h b/remoting/host/video_scheduler.h
index 825f07a..3bcf277 100644
--- a/remoting/host/video_scheduler.h
+++ b/remoting/host/video_scheduler.h
@@ -114,9 +114,9 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
// only affects capture scheduling and does not stop/start the capturer.
void Pause(bool pause);
- // Updates the sequence number embedded in VideoPackets.
- // Sequence numbers are used for performance measurements.
- void UpdateSequenceNumber(int64 sequence_number);
+ // Updates event timestamp from the last event received from the client. This
+ // value is sent back to the client for roundtrip latency estimates.
+ void SetLatestEventTimestamp(int64 latest_event_timestamp);
// Sets whether the video encoder should be requested to encode losslessly,
// or to use a lossless color space (typically requiring higher bandwidth).
@@ -166,10 +166,10 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
// Encode a frame, passing generated VideoPackets to SendVideoPacket().
void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame,
- int64 sequence_number,
+ int64 latest_event_timestamp,
base::TimeTicks timestamp);
- void EncodedDataAvailableCallback(int64 sequence_number,
+ void EncodedDataAvailableCallback(int64 latest_event_timestamp,
scoped_ptr<VideoPacket> packet);
// Task runners used by this class.
@@ -213,7 +213,7 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
bool is_paused_;
// Number updated by the caller to trace performance.
- int64 sequence_number_;
+ int64 latest_event_timestamp_;
// An object to schedule capturing.
CaptureScheduler scheduler_;
diff --git a/remoting/proto/internal.proto b/remoting/proto/internal.proto
index 89c39e7..482d9fa 100644
--- a/remoting/proto/internal.proto
+++ b/remoting/proto/internal.proto
@@ -29,7 +29,8 @@ message ControlMessage {
// Defines an event message on the event channel.
message EventMessage {
- optional int64 sequence_number = 1; // Client timestamp for event.
+ // Client's timestamp used to estimate roundtrip latency.
+ optional int64 timestamp = 1;
optional KeyEvent key_event = 3;
optional MouseEvent mouse_event = 4;
diff --git a/remoting/proto/video.proto b/remoting/proto/video.proto
index cf8cb67..0ee29c9 100644
--- a/remoting/proto/video.proto
+++ b/remoting/proto/video.proto
@@ -55,9 +55,9 @@ message VideoPacket {
// Time in milliseconds spent in encoding this video frame.
optional int64 encode_time_ms = 8;
- // The most recent sequence number received from the client on the event
- // channel.
- optional int64 client_sequence_number = 9;
+ // The client's timestamp of the latest event received by the host before
+ // starting to capture this video frame.
+ optional int64 latest_event_timestamp = 9;
repeated Rect desktop_shape_rects = 10;
diff --git a/remoting/protocol/client_event_dispatcher.cc b/remoting/protocol/client_event_dispatcher.cc
index 18e2d2d..983cba6 100644
--- a/remoting/protocol/client_event_dispatcher.cc
+++ b/remoting/protocol/client_event_dispatcher.cc
@@ -33,7 +33,7 @@ void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
DCHECK(event.has_usb_keycode());
DCHECK(event.has_pressed());
EventMessage message;
- message.set_sequence_number(base::Time::Now().ToInternalValue());
+ message.set_timestamp(base::Time::Now().ToInternalValue());
message.mutable_key_event()->CopyFrom(event);
writer_.Write(SerializeAndFrameMessage(message), base::Closure());
}
@@ -41,14 +41,14 @@ void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
void ClientEventDispatcher::InjectTextEvent(const TextEvent& event) {
DCHECK(event.has_text());
EventMessage message;
- message.set_sequence_number(base::Time::Now().ToInternalValue());
+ message.set_timestamp(base::Time::Now().ToInternalValue());
message.mutable_text_event()->CopyFrom(event);
writer_.Write(SerializeAndFrameMessage(message), base::Closure());
}
void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) {
EventMessage message;
- message.set_sequence_number(base::Time::Now().ToInternalValue());
+ message.set_timestamp(base::Time::Now().ToInternalValue());
message.mutable_mouse_event()->CopyFrom(event);
writer_.Write(SerializeAndFrameMessage(message), base::Closure());
}
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
index 0da2324..2135190 100644
--- a/remoting/protocol/connection_to_client.cc
+++ b/remoting/protocol/connection_to_client.cc
@@ -50,9 +50,9 @@ void ConnectionToClient::Disconnect() {
session_->Close();
}
-void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) {
+void ConnectionToClient::OnEventTimestamp(int64 sequence_number) {
DCHECK(CalledOnValidThread());
- handler_->OnSequenceNumberUpdated(this, sequence_number);
+ handler_->OnEventTimestamp(this, sequence_number);
}
VideoStub* ConnectionToClient::video_stub() {
@@ -132,8 +132,8 @@ void ConnectionToClient::OnSessionStateChange(Session::State state) {
base::Bind(&ConnectionToClient::OnChannelInitialized,
base::Unretained(this)));
event_dispatcher_->set_input_stub(input_stub_);
- event_dispatcher_->set_sequence_number_callback(base::Bind(
- &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
+ event_dispatcher_->set_event_timestamp_callback(base::Bind(
+ &ConnectionToClient::OnEventTimestamp, base::Unretained(this)));
video_dispatcher_.reset(new HostVideoDispatcher());
video_dispatcher_->Init(
diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h
index cfbe35a..f221dcc 100644
--- a/remoting/protocol/connection_to_client.h
+++ b/remoting/protocol/connection_to_client.h
@@ -51,8 +51,8 @@ class ConnectionToClient : public base::NonThreadSafe,
ErrorCode error) = 0;
// Called when sequence number is updated.
- virtual void OnSequenceNumberUpdated(ConnectionToClient* connection,
- int64 sequence_number) = 0;
+ virtual void OnEventTimestamp(ConnectionToClient* connection,
+ int64 timestamp) = 0;
// Called on notification of a route change event, which happens when a
// channel is connected.
@@ -79,9 +79,9 @@ class ConnectionToClient : public base::NonThreadSafe,
// Disconnect the client connection.
virtual void Disconnect();
- // Update the sequence number when received from the client. EventHandler
- // will be called.
- virtual void UpdateSequenceNumber(int64 sequence_number);
+ // Callback for HostEventDispatcher to be called with a timestamp for each
+ // received event.
+ virtual void OnEventTimestamp(int64 timestamp);
// Get the stubs used by the host to transmit messages to the client.
// The stubs must not be accessed before OnConnectionAuthenticated(), or
diff --git a/remoting/protocol/host_event_dispatcher.cc b/remoting/protocol/host_event_dispatcher.cc
index 2dbca9e..3ece9bb 100644
--- a/remoting/protocol/host_event_dispatcher.cc
+++ b/remoting/protocol/host_event_dispatcher.cc
@@ -33,8 +33,8 @@ void HostEventDispatcher::OnMessageReceived(
base::ScopedClosureRunner done_runner(done_task);
- if (message->has_sequence_number() && !sequence_number_callback_.is_null())
- sequence_number_callback_.Run(message->sequence_number());
+ if (message->has_timestamp() && !event_timestamp_callback_.is_null())
+ event_timestamp_callback_.Run(message->timestamp());
if (message->has_key_event()) {
const KeyEvent& event = message->key_event();
diff --git a/remoting/protocol/host_event_dispatcher.h b/remoting/protocol/host_event_dispatcher.h
index 968db88..aaa5fe9 100644
--- a/remoting/protocol/host_event_dispatcher.h
+++ b/remoting/protocol/host_event_dispatcher.h
@@ -18,7 +18,7 @@ class InputStub;
// channel to InputStub.
class HostEventDispatcher : public ChannelDispatcherBase {
public:
- typedef base::Callback<void(int64)> SequenceNumberCallback;
+ typedef base::Callback<void(int64)> EventTimestampCallback;
HostEventDispatcher();
~HostEventDispatcher() override;
@@ -30,8 +30,8 @@ class HostEventDispatcher : public ChannelDispatcherBase {
// Set callback to notify of each message's sequence number. The
// callback cannot tear down this object.
- void set_sequence_number_callback(const SequenceNumberCallback& value) {
- sequence_number_callback_ = value;
+ void set_event_timestamp_callback(const EventTimestampCallback& value) {
+ event_timestamp_callback_ = value;
}
protected:
@@ -43,7 +43,7 @@ class HostEventDispatcher : public ChannelDispatcherBase {
const base::Closure& done_task);
InputStub* input_stub_;
- SequenceNumberCallback sequence_number_callback_;
+ EventTimestampCallback event_timestamp_callback_;
ProtobufMessageReader<EventMessage> reader_;
diff --git a/remoting/protocol/message_decoder_unittest.cc b/remoting/protocol/message_decoder_unittest.cc
index e61e9fa..ab36b17 100644
--- a/remoting/protocol/message_decoder_unittest.cc
+++ b/remoting/protocol/message_decoder_unittest.cc
@@ -34,7 +34,7 @@ static void PrepareData(uint8** buffer, int* size) {
// Then append 10 update sequences to the data.
for (int i = 0; i < 10; ++i) {
EventMessage msg;
- msg.set_sequence_number(i);
+ msg.set_timestamp(i);
msg.mutable_key_event()->set_usb_keycode(kTestKey + i);
msg.mutable_key_event()->set_pressed((i % 2) != 0);
AppendMessage(msg, &encoded_data);
diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h
index eb136ed..24db36d 100644
--- a/remoting/protocol/protocol_mock_objects.h
+++ b/remoting/protocol/protocol_mock_objects.h
@@ -59,8 +59,8 @@ class MockConnectionToClientEventHandler :
void(ConnectionToClient* connection));
MOCK_METHOD2(OnConnectionClosed, void(ConnectionToClient* connection,
ErrorCode error));
- MOCK_METHOD2(OnSequenceNumberUpdated, void(ConnectionToClient* connection,
- int64 sequence_number));
+ MOCK_METHOD2(OnEventTimestamp,
+ void(ConnectionToClient* connection, int64 timestamp));
MOCK_METHOD3(OnRouteChange, void(ConnectionToClient* connection,
const std::string& channel_name,
const TransportRoute& route));