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

Side by Side Diff: webrtc/test/fake_encoder.h

Issue 3012853002: Update thread annotiation macros to use RTC_ prefix (Closed)
Patch Set: Rebase Created 3 years, 3 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
« no previous file with comments | « webrtc/test/fake_audio_device.h ('k') | webrtc/test/frame_generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; 44 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
45 int32_t SetRateAllocation(const BitrateAllocation& rate_allocation, 45 int32_t SetRateAllocation(const BitrateAllocation& rate_allocation,
46 uint32_t framerate) override; 46 uint32_t framerate) override;
47 const char* ImplementationName() const override; 47 const char* ImplementationName() const override;
48 int GetConfiguredInputFramerate() const; 48 int GetConfiguredInputFramerate() const;
49 49
50 static const char* kImplementationName; 50 static const char* kImplementationName;
51 51
52 protected: 52 protected:
53 Clock* const clock_; 53 Clock* const clock_;
54 VideoCodec config_ GUARDED_BY(crit_sect_); 54 VideoCodec config_ RTC_GUARDED_BY(crit_sect_);
55 EncodedImageCallback* callback_ GUARDED_BY(crit_sect_); 55 EncodedImageCallback* callback_ RTC_GUARDED_BY(crit_sect_);
56 BitrateAllocation target_bitrate_ GUARDED_BY(crit_sect_); 56 BitrateAllocation target_bitrate_ RTC_GUARDED_BY(crit_sect_);
57 int configured_input_framerate_ GUARDED_BY(crit_sect_); 57 int configured_input_framerate_ RTC_GUARDED_BY(crit_sect_);
58 int max_target_bitrate_kbps_ GUARDED_BY(crit_sect_); 58 int max_target_bitrate_kbps_ RTC_GUARDED_BY(crit_sect_);
59 bool pending_keyframe_ GUARDED_BY(crit_sect_); 59 bool pending_keyframe_ RTC_GUARDED_BY(crit_sect_);
60 rtc::CriticalSection crit_sect_; 60 rtc::CriticalSection crit_sect_;
61 61
62 uint8_t encoded_buffer_[100000]; 62 uint8_t encoded_buffer_[100000];
63 63
64 // Current byte debt to be payed over a number of frames. 64 // Current byte debt to be payed over a number of frames.
65 // The debt is acquired by keyframes overshooting the bitrate target. 65 // The debt is acquired by keyframes overshooting the bitrate target.
66 size_t debt_bytes_; 66 size_t debt_bytes_;
67 }; 67 };
68 68
69 class FakeH264Encoder : public FakeEncoder, public EncodedImageCallback { 69 class FakeH264Encoder : public FakeEncoder, public EncodedImageCallback {
70 public: 70 public:
71 explicit FakeH264Encoder(Clock* clock); 71 explicit FakeH264Encoder(Clock* clock);
72 virtual ~FakeH264Encoder() = default; 72 virtual ~FakeH264Encoder() = default;
73 73
74 int32_t RegisterEncodeCompleteCallback( 74 int32_t RegisterEncodeCompleteCallback(
75 EncodedImageCallback* callback) override; 75 EncodedImageCallback* callback) override;
76 76
77 Result OnEncodedImage(const EncodedImage& encodedImage, 77 Result OnEncodedImage(const EncodedImage& encodedImage,
78 const CodecSpecificInfo* codecSpecificInfo, 78 const CodecSpecificInfo* codecSpecificInfo,
79 const RTPFragmentationHeader* fragments) override; 79 const RTPFragmentationHeader* fragments) override;
80 80
81 private: 81 private:
82 EncodedImageCallback* callback_ GUARDED_BY(local_crit_sect_); 82 EncodedImageCallback* callback_ RTC_GUARDED_BY(local_crit_sect_);
83 int idr_counter_ GUARDED_BY(local_crit_sect_); 83 int idr_counter_ RTC_GUARDED_BY(local_crit_sect_);
84 rtc::CriticalSection local_crit_sect_; 84 rtc::CriticalSection local_crit_sect_;
85 }; 85 };
86 86
87 class DelayedEncoder : public test::FakeEncoder { 87 class DelayedEncoder : public test::FakeEncoder {
88 public: 88 public:
89 DelayedEncoder(Clock* clock, int delay_ms); 89 DelayedEncoder(Clock* clock, int delay_ms);
90 virtual ~DelayedEncoder() = default; 90 virtual ~DelayedEncoder() = default;
91 91
92 void SetDelay(int delay_ms); 92 void SetDelay(int delay_ms);
93 int32_t Encode(const VideoFrame& input_image, 93 int32_t Encode(const VideoFrame& input_image,
94 const CodecSpecificInfo* codec_specific_info, 94 const CodecSpecificInfo* codec_specific_info,
95 const std::vector<FrameType>* frame_types) override; 95 const std::vector<FrameType>* frame_types) override;
96 96
97 private: 97 private:
98 int delay_ms_ ACCESS_ON(sequence_checker_); 98 int delay_ms_ RTC_ACCESS_ON(sequence_checker_);
99 rtc::SequencedTaskChecker sequence_checker_; 99 rtc::SequencedTaskChecker sequence_checker_;
100 }; 100 };
101 101
102 // This class implements a multi-threaded fake encoder by posting 102 // This class implements a multi-threaded fake encoder by posting
103 // FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an 103 // FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an
104 // alternating fashion. The class itself does not need to be thread safe, 104 // alternating fashion. The class itself does not need to be thread safe,
105 // as it is called from the task queue in VideoStreamEncoder. 105 // as it is called from the task queue in VideoStreamEncoder.
106 class MultithreadedFakeH264Encoder : public test::FakeH264Encoder { 106 class MultithreadedFakeH264Encoder : public test::FakeH264Encoder {
107 public: 107 public:
108 explicit MultithreadedFakeH264Encoder(Clock* clock); 108 explicit MultithreadedFakeH264Encoder(Clock* clock);
109 virtual ~MultithreadedFakeH264Encoder() = default; 109 virtual ~MultithreadedFakeH264Encoder() = default;
110 110
111 int32_t InitEncode(const VideoCodec* config, 111 int32_t InitEncode(const VideoCodec* config,
112 int32_t number_of_cores, 112 int32_t number_of_cores,
113 size_t max_payload_size) override; 113 size_t max_payload_size) override;
114 114
115 int32_t Encode(const VideoFrame& input_image, 115 int32_t Encode(const VideoFrame& input_image,
116 const CodecSpecificInfo* codec_specific_info, 116 const CodecSpecificInfo* codec_specific_info,
117 const std::vector<FrameType>* frame_types) override; 117 const std::vector<FrameType>* frame_types) override;
118 118
119 int32_t EncodeCallback(const VideoFrame& input_image, 119 int32_t EncodeCallback(const VideoFrame& input_image,
120 const CodecSpecificInfo* codec_specific_info, 120 const CodecSpecificInfo* codec_specific_info,
121 const std::vector<FrameType>* frame_types); 121 const std::vector<FrameType>* frame_types);
122 122
123 int32_t Release() override; 123 int32_t Release() override;
124 124
125 protected: 125 protected:
126 class EncodeTask; 126 class EncodeTask;
127 127
128 int current_queue_ ACCESS_ON(sequence_checker_); 128 int current_queue_ RTC_ACCESS_ON(sequence_checker_);
129 std::unique_ptr<rtc::TaskQueue> queue1_ ACCESS_ON(sequence_checker_); 129 std::unique_ptr<rtc::TaskQueue> queue1_ RTC_ACCESS_ON(sequence_checker_);
130 std::unique_ptr<rtc::TaskQueue> queue2_ ACCESS_ON(sequence_checker_); 130 std::unique_ptr<rtc::TaskQueue> queue2_ RTC_ACCESS_ON(sequence_checker_);
131 rtc::SequencedTaskChecker sequence_checker_; 131 rtc::SequencedTaskChecker sequence_checker_;
132 }; 132 };
133 133
134 } // namespace test 134 } // namespace test
135 } // namespace webrtc 135 } // namespace webrtc
136 136
137 #endif // WEBRTC_TEST_FAKE_ENCODER_H_ 137 #endif // WEBRTC_TEST_FAKE_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/test/fake_audio_device.h ('k') | webrtc/test/frame_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698