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

Unified Diff: webrtc/test/fake_encoder.h

Issue 2604403003: Make FakeEncoder and FakeH264Encoder thread safe. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/test/fake_encoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/fake_encoder.h
diff --git a/webrtc/test/fake_encoder.h b/webrtc/test/fake_encoder.h
index b81a04b43f2d9d3e4f3106688722e46ebf367a59..39c3e3e67f599d50eb9ed404aa6634e3c75d480c 100644
--- a/webrtc/test/fake_encoder.h
+++ b/webrtc/test/fake_encoder.h
@@ -47,12 +47,13 @@ class FakeEncoder : public VideoEncoder {
static const char* kImplementationName;
protected:
+ rtc::CriticalSection crit_sect_;
Clock* const clock_;
- VideoCodec config_;
- EncodedImageCallback* callback_;
- BitrateAllocation target_bitrate_;
- int max_target_bitrate_kbps_;
- int64_t last_encode_time_ms_;
+ VideoCodec config_ GUARDED_BY(crit_sect_);
+ EncodedImageCallback* callback_ GUARDED_BY(crit_sect_);
+ BitrateAllocation target_bitrate_ GUARDED_BY(crit_sect_);
+ int max_target_bitrate_kbps_ GUARDED_BY(crit_sect_);
+ int64_t last_encode_time_ms_ GUARDED_BY(crit_sect_);
uint8_t encoded_buffer_[100000];
};
@@ -69,8 +70,9 @@ class FakeH264Encoder : public FakeEncoder, public EncodedImageCallback {
const RTPFragmentationHeader* fragments) override;
private:
- EncodedImageCallback* callback_;
- int idr_counter_;
+ rtc::CriticalSection local_crit_sect_;
+ EncodedImageCallback* callback_ GUARDED_BY(local_crit_sect_);
+ int idr_counter_ GUARDED_BY(local_crit_sect_);
};
class DelayedEncoder : public test::FakeEncoder {
@@ -84,17 +86,17 @@ class DelayedEncoder : public test::FakeEncoder {
const std::vector<FrameType>* frame_types) override;
private:
- rtc::CriticalSection lock_;
- int delay_ms_ GUARDED_BY(&lock_);
+ rtc::CriticalSection local_crit_sect_;
+ int delay_ms_ GUARDED_BY(&local_crit_sect_);
};
// This class implements a multi-threaded fake encoder by posting
// FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an
// alternating fashion.
-class MultiThreadedFakeH264Encoder : public test::FakeH264Encoder {
+class MultithreadedFakeH264Encoder : public test::FakeH264Encoder {
public:
- MultiThreadedFakeH264Encoder(Clock* clock);
- virtual ~MultiThreadedFakeH264Encoder() override;
+ explicit MultithreadedFakeH264Encoder(Clock* clock);
+ virtual ~MultithreadedFakeH264Encoder() override;
int32_t Encode(const VideoFrame& input_image,
const CodecSpecificInfo* codec_specific_info,
« no previous file with comments | « no previous file | webrtc/test/fake_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698