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

Unified Diff: media/cast/video_sender/video_encoder.cc

Issue 74133002: Cast: Removed unnecessary ref counters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to lock form atomic int Created 7 years, 1 month 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
Index: media/cast/video_sender/video_encoder.cc
diff --git a/media/cast/video_sender/video_encoder.cc b/media/cast/video_sender/video_encoder.cc
index 42d1a88cc2c590b488508169194ac847ec90c75e..c26f04afd6836f3bdf48426ea9b8b16f427d597c 100644
--- a/media/cast/video_sender/video_encoder.cc
+++ b/media/cast/video_sender/video_encoder.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
namespace media {
namespace cast {
@@ -16,7 +17,8 @@ VideoEncoder::VideoEncoder(scoped_refptr<CastEnvironment> cast_environment,
: video_config_(video_config),
cast_environment_(cast_environment),
skip_next_frame_(false),
- skip_count_(0) {
+ skip_count_(0),
+ weak_factory_(this) {
if (video_config.codec == kVp8) {
vp8_encoder_.reset(new Vp8Encoder(video_config, max_unacked_frames));
} else {
@@ -35,6 +37,7 @@ bool VideoEncoder::EncodeVideoFrame(
const base::TimeTicks& capture_time,
const FrameEncodedCallback& frame_encoded_callback,
const base::Closure frame_release_callback) {
+ DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
if (video_config_.codec != kVp8) return false;
if (skip_next_frame_) {
@@ -44,9 +47,9 @@ bool VideoEncoder::EncodeVideoFrame(
}
cast_environment_->PostTask(CastEnvironment::VIDEO_ENCODER, FROM_HERE,
- base::Bind(&VideoEncoder::EncodeVideoFrameEncoderThread, this,
- video_frame, capture_time, dynamic_config_, frame_encoded_callback,
- frame_release_callback));
+ base::Bind(&VideoEncoder::EncodeVideoFrameEncoderThread,
+ weak_factory_.GetWeakPtr(), video_frame, capture_time,
+ dynamic_config_, frame_encoded_callback, frame_release_callback));
dynamic_config_.key_frame_requested = false;
return true;

Powered by Google App Engine
This is Rietveld 408576698