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

Side by Side Diff: remoting/codec/video_encoder_verbatim.cc

Issue 1150163002: Update VideoFramePump to pass un-changed frames to encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/codec/video_encoder_verbatim.h" 5 #include "remoting/codec/video_encoder_verbatim.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "remoting/base/util.h" 10 #include "remoting/base/util.h"
11 #include "remoting/proto/video.pb.h" 11 #include "remoting/proto/video.pb.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 12 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
13 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 13 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
14 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" 14 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 static uint8_t* GetPacketOutputBuffer(VideoPacket* packet, size_t size) { 18 static uint8_t* GetPacketOutputBuffer(VideoPacket* packet, size_t size) {
19 packet->mutable_data()->resize(size); 19 packet->mutable_data()->resize(size);
20 return reinterpret_cast<uint8_t*>(string_as_array(packet->mutable_data())); 20 return reinterpret_cast<uint8_t*>(string_as_array(packet->mutable_data()));
21 } 21 }
22 22
23 VideoEncoderVerbatim::VideoEncoderVerbatim() {} 23 VideoEncoderVerbatim::VideoEncoderVerbatim() {}
24 VideoEncoderVerbatim::~VideoEncoderVerbatim() {} 24 VideoEncoderVerbatim::~VideoEncoderVerbatim() {}
25 25
26 scoped_ptr<VideoPacket> VideoEncoderVerbatim::Encode( 26 scoped_ptr<VideoPacket> VideoEncoderVerbatim::Encode(
27 const webrtc::DesktopFrame& frame) { 27 const webrtc::DesktopFrame& frame) {
28 CHECK(frame.data()); 28 DCHECK(frame.data());
29
30 // If nothing has changed in the frame then return NULL to indicate that
31 // we don't need to actually send anything (e.g. nothing to top-off).
32 if (frame.updated_region().is_empty())
33 return nullptr;
29 34
30 base::Time encode_start_time = base::Time::Now(); 35 base::Time encode_start_time = base::Time::Now();
31 36
32 // Create a VideoPacket with common fields (e.g. DPI, rects, shape) set. 37 // Create a VideoPacket with common fields (e.g. DPI, rects, shape) set.
33 scoped_ptr<VideoPacket> packet(helper_.CreateVideoPacket(frame)); 38 scoped_ptr<VideoPacket> packet(helper_.CreateVideoPacket(frame));
34 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VERBATIM); 39 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VERBATIM);
35 40
36 // Calculate output size. 41 // Calculate output size.
37 size_t output_size = 0; 42 size_t output_size = 0;
38 for (webrtc::DesktopRegion::Iterator iter(frame.updated_region()); 43 for (webrtc::DesktopRegion::Iterator iter(frame.updated_region());
(...skipping 21 matching lines...) Expand all
60 } 65 }
61 66
62 // Note the time taken to encode the pixel data. 67 // Note the time taken to encode the pixel data.
63 packet->set_encode_time_ms( 68 packet->set_encode_time_ms(
64 (base::Time::Now() - encode_start_time).InMillisecondsRoundedUp()); 69 (base::Time::Now() - encode_start_time).InMillisecondsRoundedUp());
65 70
66 return packet.Pass(); 71 return packet.Pass();
67 } 72 }
68 73
69 } // namespace remoting 74 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698