OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "remoting/base/util.h" | 12 #include "remoting/base/util.h" |
13 #include "remoting/proto/video.pb.h" | 13 #include "remoting/proto/video.pb.h" |
14 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 14 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
16 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 16 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 static uint8_t* GetPacketOutputBuffer(VideoPacket* packet, size_t size) { | 20 static uint8_t* GetPacketOutputBuffer(VideoPacket* packet, size_t size) { |
21 packet->mutable_data()->resize(size); | 21 packet->mutable_data()->resize(size); |
22 return reinterpret_cast<uint8_t*>(string_as_array(packet->mutable_data())); | 22 return reinterpret_cast<uint8_t*>(string_as_array(packet->mutable_data())); |
23 } | 23 } |
24 | 24 |
25 VideoEncoderVerbatim::VideoEncoderVerbatim() {} | 25 VideoEncoderVerbatim::VideoEncoderVerbatim() {} |
26 VideoEncoderVerbatim::~VideoEncoderVerbatim() {} | 26 VideoEncoderVerbatim::~VideoEncoderVerbatim() {} |
27 | 27 |
28 scoped_ptr<VideoPacket> VideoEncoderVerbatim::Encode( | 28 std::unique_ptr<VideoPacket> VideoEncoderVerbatim::Encode( |
29 const webrtc::DesktopFrame& frame) { | 29 const webrtc::DesktopFrame& frame) { |
30 DCHECK(frame.data()); | 30 DCHECK(frame.data()); |
31 | 31 |
32 // If nothing has changed in the frame then return NULL to indicate that | 32 // If nothing has changed in the frame then return NULL to indicate that |
33 // we don't need to actually send anything (e.g. nothing to top-off). | 33 // we don't need to actually send anything (e.g. nothing to top-off). |
34 if (frame.updated_region().is_empty()) | 34 if (frame.updated_region().is_empty()) |
35 return nullptr; | 35 return nullptr; |
36 | 36 |
37 // 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. |
38 scoped_ptr<VideoPacket> packet(helper_.CreateVideoPacket(frame)); | 38 std::unique_ptr<VideoPacket> packet(helper_.CreateVideoPacket(frame)); |
39 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VERBATIM); | 39 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VERBATIM); |
40 | 40 |
41 // Calculate output size. | 41 // Calculate output size. |
42 size_t output_size = 0; | 42 size_t output_size = 0; |
43 for (webrtc::DesktopRegion::Iterator iter(frame.updated_region()); | 43 for (webrtc::DesktopRegion::Iterator iter(frame.updated_region()); |
44 !iter.IsAtEnd(); iter.Advance()) { | 44 !iter.IsAtEnd(); iter.Advance()) { |
45 const webrtc::DesktopRect& rect = iter.rect(); | 45 const webrtc::DesktopRect& rect = iter.rect(); |
46 output_size += rect.width() * rect.height() * | 46 output_size += rect.width() * rect.height() * |
47 webrtc::DesktopFrame::kBytesPerPixel; | 47 webrtc::DesktopFrame::kBytesPerPixel; |
48 } | 48 } |
(...skipping 12 matching lines...) Expand all Loading... |
61 memcpy(out, in, row_size); | 61 memcpy(out, in, row_size); |
62 out += row_size; | 62 out += row_size; |
63 in += in_stride; | 63 in += in_stride; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 return packet; | 67 return packet; |
68 } | 68 } |
69 | 69 |
70 } // namespace remoting | 70 } // namespace remoting |
OLD | NEW |