Chromium Code Reviews| Index: content/renderer/media/rtc_video_encoder.cc |
| diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc |
| index 2a2891cc07fc3ee3591bd764498696fc1dcbfe70..694e4261a16197eaa95727f775dc14cbee619137 100644 |
| --- a/content/renderer/media/rtc_video_encoder.cc |
| +++ b/content/renderer/media/rtc_video_encoder.cc |
| @@ -164,6 +164,9 @@ class RTCVideoEncoder::Impl |
| ~Impl() override; |
| + // Resets the class members. |
| + void Reset(); |
| + |
| // Logs the |error| and |str| sent from |location| and NotifyError()s forward. |
| void LogAndNotifyError(const tracked_objects::Location& location, |
| const std::string& str, |
| @@ -262,14 +265,11 @@ RTCVideoEncoder::Impl::Impl(media::GpuVideoAcceleratorFactories* gpu_factories, |
| async_waiter_(NULL), |
| async_retval_(NULL), |
| input_next_frame_(NULL), |
| - input_next_frame_keyframe_(false), |
| - output_buffers_free_count_(0), |
| encoded_image_callback_(nullptr), |
| video_codec_type_(video_codec_type), |
| status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED) { |
| thread_checker_.DetachFromThread(); |
| - // Picture ID should start on a random number. |
| - picture_id_ = static_cast<uint16_t>(base::RandInt(0, 0x7FFF)); |
| + Reset(); |
|
wuchengli
2016/04/29 13:58:24
This means RTCVideoEncoder is reused after RTCVide
emircan
2016/04/29 19:37:27
Sure, reverting to earlier sounds better as the de
|
| } |
| void RTCVideoEncoder::Impl::CreateAndInitializeVEA( |
| @@ -386,6 +386,7 @@ void RTCVideoEncoder::Impl::Destroy(base::WaitableEvent* async_waiter) { |
| video_encoder_.reset(); |
| SetStatus(WEBRTC_VIDEO_CODEC_UNINITIALIZED); |
| } |
| + Reset(); |
| async_waiter->Signal(); |
| } |
| @@ -517,6 +518,16 @@ void RTCVideoEncoder::Impl::NotifyError( |
| RTCVideoEncoder::Impl::~Impl() { DCHECK(!video_encoder_); } |
| +void RTCVideoEncoder::Impl::Reset() { |
| + input_next_frame_keyframe_ = false; |
| + input_buffers_.clear(); |
| + output_buffers_.clear(); |
| + input_buffers_free_.clear(); |
| + output_buffers_free_count_ = 0; |
| + // Picture ID should start on a random number. |
| + picture_id_ = static_cast<uint16_t>(base::RandInt(0, 0x7FFF)); |
| +} |
| + |
| void RTCVideoEncoder::Impl::LogAndNotifyError( |
| const tracked_objects::Location& location, |
| const std::string& str, |