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

Unified Diff: remoting/codec/video_encoder_vp8.cc

Issue 23477059: Simplify VideoEncoder interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: remoting/codec/video_encoder_vp8.cc
diff --git a/remoting/codec/video_encoder_vp8.cc b/remoting/codec/video_encoder_vp8.cc
index d9c9e88025a2c302bb18cbf7f04c7e2553113d67..fa7fee3c153d4ae5b6e3190668204c78f75ad505 100644
--- a/remoting/codec/video_encoder_vp8.cc
+++ b/remoting/codec/video_encoder_vp8.cc
@@ -144,9 +144,9 @@ bool VideoEncoderVp8::Init(const webrtc::DesktopSize& size) {
return true;
}
-void VideoEncoderVp8::PrepareImage(const webrtc::DesktopFrame* frame,
+void VideoEncoderVp8::PrepareImage(const webrtc::DesktopFrame& frame,
SkRegion* updated_region) {
- if (frame->updated_region().is_empty()) {
+ if (frame.updated_region().is_empty()) {
updated_region->setEmpty();
return;
}
@@ -155,7 +155,7 @@ void VideoEncoderVp8::PrepareImage(const webrtc::DesktopFrame* frame,
// This also ensures that all rectangles have even-aligned top-left, which
// is required for ConvertRGBToYUVWithRect() to work.
std::vector<SkIRect> aligned_rects;
- for (webrtc::DesktopRegion::Iterator r(frame->updated_region());
+ for (webrtc::DesktopRegion::Iterator r(frame.updated_region());
!r.IsAtEnd(); r.Advance()) {
const webrtc::DesktopRect& rect = r.rect();
aligned_rects.push_back(AlignRect(
@@ -171,8 +171,8 @@ void VideoEncoderVp8::PrepareImage(const webrtc::DesktopFrame* frame,
SkRegion::kIntersect_Op);
// Convert the updated region to YUV ready for encoding.
- const uint8* rgb_data = frame->data();
- const int rgb_stride = frame->stride();
+ const uint8* rgb_data = frame.data();
+ const int rgb_stride = frame.stride();
const int y_stride = image_->stride[0];
DCHECK_EQ(image_->stride[1], image_->stride[2]);
const int uv_stride = image_->stride[1];
@@ -211,17 +211,16 @@ void VideoEncoderVp8::PrepareActiveMap(const SkRegion& updated_region) {
}
}
-void VideoEncoderVp8::Encode(
- const webrtc::DesktopFrame* frame,
- const DataAvailableCallback& data_available_callback) {
- DCHECK_LE(32, frame->size().width());
- DCHECK_LE(32, frame->size().height());
+scoped_ptr<VideoPacket> VideoEncoderVp8::Encode(
+ const webrtc::DesktopFrame& frame) {
+ DCHECK_LE(32, frame.size().width());
+ DCHECK_LE(32, frame.size().height());
base::Time encode_start_time = base::Time::Now();
if (!initialized_ ||
- !frame->size().equals(webrtc::DesktopSize(image_->w, image_->h))) {
- bool ret = Init(frame->size());
+ !frame.size().equals(webrtc::DesktopSize(image_->w, image_->h))) {
+ bool ret = Init(frame.size());
// TODO(hclam): Handle error better.
CHECK(ret) << "Initialization of encoder failed";
initialized_ = ret;
@@ -284,14 +283,14 @@ void VideoEncoderVp8::Encode(
packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8);
packet->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET |
VideoPacket::LAST_PARTITION);
- packet->mutable_format()->set_screen_width(frame->size().width());
- packet->mutable_format()->set_screen_height(frame->size().height());
- packet->set_capture_time_ms(frame->capture_time_ms());
+ packet->mutable_format()->set_screen_width(frame.size().width());
+ packet->mutable_format()->set_screen_height(frame.size().height());
+ packet->set_capture_time_ms(frame.capture_time_ms());
packet->set_encode_time_ms(
(base::Time::Now() - encode_start_time).InMillisecondsRoundedUp());
- if (!frame->dpi().is_zero()) {
- packet->mutable_format()->set_x_dpi(frame->dpi().x());
- packet->mutable_format()->set_y_dpi(frame->dpi().y());
+ if (!frame.dpi().is_zero()) {
+ packet->mutable_format()->set_x_dpi(frame.dpi().x());
+ packet->mutable_format()->set_y_dpi(frame.dpi().y());
}
for (SkRegion::Iterator r(updated_region); !r.done(); r.next()) {
Rect* rect = packet->add_dirty_rects();
@@ -301,7 +300,7 @@ void VideoEncoderVp8::Encode(
rect->set_height(r.rect().height());
}
- data_available_callback.Run(packet.Pass());
+ return packet.Pass();
}
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698