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

Side by Side Diff: remoting/test/cyclic_frame_generator.h

Issue 2420183002: Don't use barcodes in ProtocolPerfTests (Closed)
Patch Set: . Created 4 years, 2 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
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 #ifndef REMOTING_TEST_CYCLIC_FRAME_GENERATOR_H_ 5 #ifndef REMOTING_TEST_CYCLIC_FRAME_GENERATOR_H_
6 #define REMOTING_TEST_CYCLIC_FRAME_GENERATOR_H_ 6 #define REMOTING_TEST_CYCLIC_FRAME_GENERATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/time/default_tick_clock.h" 14 #include "base/time/default_tick_clock.h"
15 #include "remoting/protocol/input_event_timestamps.h"
14 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 16 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
15 17
16 namespace remoting { 18 namespace remoting {
17 namespace test { 19 namespace test {
18 20
19 // CyclicFrameGenerator generates a sequence of frames that approximates 21 // CyclicFrameGenerator generates a sequence of frames that approximates
20 // properties of a real video stream when using a desktop applications. It 22 // properties of a real video stream when using a desktop applications. It
21 // loads a sequence of reference frames and switches between them with the 23 // loads a sequence of reference frames and switches between them with the
22 // specified frequency (every 2 seconds by default). Between reference frames it 24 // specified frequency (every 2 seconds by default). Between reference frames it
23 // also generate frames with small changes which simulate a blinking cursor. 25 // also generate frames with small changes which simulate a blinking cursor.
24 class CyclicFrameGenerator 26 class CyclicFrameGenerator : public protocol::InputEventTimestampsSource {
25 : public base::RefCountedThreadSafe<CyclicFrameGenerator> {
26 public: 27 public:
27 enum class ChangeType { 28 enum class ChangeType {
28 // No changes. 29 // No changes.
29 NO_CHANGES, 30 NO_CHANGES,
30 31
31 // Whole screen changed. 32 // Whole screen changed.
32 FULL, 33 FULL,
33 34
34 // Cursor state has changed. 35 // Cursor state has changed.
35 CURSOR, 36 CURSOR,
(...skipping 17 matching lines...) Expand all
53 void set_frame_cycle_period(base::TimeDelta frame_cycle_period) { 54 void set_frame_cycle_period(base::TimeDelta frame_cycle_period) {
54 frame_cycle_period_ = frame_cycle_period; 55 frame_cycle_period_ = frame_cycle_period;
55 } 56 }
56 57
57 void set_cursor_blink_period(base::TimeDelta cursor_blink_period) { 58 void set_cursor_blink_period(base::TimeDelta cursor_blink_period) {
58 cursor_blink_period_ = cursor_blink_period; 59 cursor_blink_period_ = cursor_blink_period;
59 } 60 }
60 61
61 void SetTickClock(base::TickClock* tick_clock); 62 void SetTickClock(base::TickClock* tick_clock);
62 63
63 // When |draw_barcode| is set to true a barcode is drawn on each generated
64 // frame. This makes it possible to call GetChangeList() to identify the frame
65 // by its content.
66 void set_draw_barcode(bool draw_barcode) { draw_barcode_ = draw_barcode; }
67
68 std::unique_ptr<webrtc::DesktopFrame> GenerateFrame( 64 std::unique_ptr<webrtc::DesktopFrame> GenerateFrame(
69 webrtc::SharedMemoryFactory* shared_memory_factory); 65 webrtc::SharedMemoryFactory* shared_memory_factory);
70 66
71 ChangeType last_frame_type() { return last_frame_type_; } 67 ChangeType last_frame_type() { return last_frame_type_; }
72 68
73 // Identifies |frame| by its content and returns list of ChangeInfo for all 69 // Identifies |frame| by its content and returns list of ChangeInfo for all
74 // changes between the frame passed to the previous GetChangeList() call and 70 // changes between the frame passed to the previous GetChangeList() call and
75 // this one. GetChangeList() must be called for the frames in the order in 71 // this one. GetChangeList() must be called for the frames in the order in
76 // which they were received, which is expected to match the order in which 72 // which they were received, which is expected to match the order in which
77 // they are generated. 73 // they are generated.
Jamie 2016/10/14 23:26:07 Please update this comment.
Sergey Ulanov 2016/10/17 22:40:26 Done.
78 ChangeInfoList GetChangeList(webrtc::DesktopFrame* frame); 74 ChangeInfoList GetChangeList(base::TimeTicks timestamp);
75
76 // InputEventTimestampsSource interface.
77 protocol::InputEventTimestamps TakeLastEventTimestamps() override;
79 78
80 private: 79 private:
81 ~CyclicFrameGenerator(); 80 ~CyclicFrameGenerator() override;
82 friend class base::RefCountedThreadSafe<CyclicFrameGenerator>; 81 friend class base::RefCountedThreadSafe<CyclicFrameGenerator>;
83 82
84 std::vector<std::unique_ptr<webrtc::DesktopFrame>> reference_frames_; 83 std::vector<std::unique_ptr<webrtc::DesktopFrame>> reference_frames_;
85 base::DefaultTickClock default_tick_clock_; 84 base::DefaultTickClock default_tick_clock_;
86 base::TickClock* clock_; 85 base::TickClock* clock_;
87 webrtc::DesktopSize screen_size_; 86 webrtc::DesktopSize screen_size_;
88 87
89 // By default switch between reference frames every 2 seconds. 88 // By default switch between reference frames every 2 seconds.
90 base::TimeDelta frame_cycle_period_ = base::TimeDelta::FromSeconds(2); 89 base::TimeDelta frame_cycle_period_ = base::TimeDelta::FromSeconds(2);
91 90
92 // By default blink the cursor 4 times per seconds. 91 // By default blink the cursor 4 times per seconds.
93 base::TimeDelta cursor_blink_period_ = base::TimeDelta::FromMilliseconds(250); 92 base::TimeDelta cursor_blink_period_ = base::TimeDelta::FromMilliseconds(250);
94 93
95 // Id of the last frame encoded on the barcode. 94 // Id of the last frame encoded on the barcode.
96 int last_frame_id_ = -1; 95 int last_frame_id_ = -1;
97 96
98 // Index of the reference frame used to render the last generated frame. 97 // Index of the reference frame used to render the last generated frame.
99 int last_reference_frame_ = -1; 98 int last_reference_frame_ = -1;
100 99
101 // True if the cursor was rendered on the last generated frame. 100 // True if the cursor was rendered on the last generated frame.
102 bool last_cursor_state_ = false; 101 bool last_cursor_state_ = false;
103 102
104 ChangeType last_frame_type_ = ChangeType::NO_CHANGES; 103 ChangeType last_frame_type_ = ChangeType::NO_CHANGES;
105 104
106 bool draw_barcode_ = false;
107
108 base::TimeTicks started_time_; 105 base::TimeTicks started_time_;
109 106
110 // frame_id of the frame passed to the last GetChangeList() call. 107 // frame_id of the frame passed to the last GetChangeList() call.
111 int last_identifier_frame_ = -1; 108 int last_identifier_frame_ = -1;
112 109
113 DISALLOW_COPY_AND_ASSIGN(CyclicFrameGenerator); 110 DISALLOW_COPY_AND_ASSIGN(CyclicFrameGenerator);
114 }; 111 };
115 112
116 } // namespace test 113 } // namespace test
117 } // namespace remoting 114 } // namespace remoting
118 115
119 #endif // REMOTING_TEST_CYCLIC_FRAME_GENERATOR_H_ 116 #endif // REMOTING_TEST_CYCLIC_FRAME_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698