| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/video/capture/screen/screen_capture_data.h" |
| 8 #include "remoting/base/util.h" | 9 #include "remoting/base/util.h" |
| 9 #include "remoting/capturer/capture_data.h" | |
| 10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
| 11 | 11 |
| 12 namespace remoting { | 12 namespace remoting { |
| 13 | 13 |
| 14 static const int kPacketSize = 1024 * 1024; | 14 static const int kPacketSize = 1024 * 1024; |
| 15 | 15 |
| 16 VideoEncoderVerbatim::VideoEncoderVerbatim() | 16 VideoEncoderVerbatim::VideoEncoderVerbatim() |
| 17 : screen_size_(SkISize::Make(0,0)), | 17 : screen_size_(SkISize::Make(0,0)), |
| 18 max_packet_size_(kPacketSize) { | 18 max_packet_size_(kPacketSize) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 void VideoEncoderVerbatim::SetMaxPacketSize(int size) { | 21 void VideoEncoderVerbatim::SetMaxPacketSize(int size) { |
| 22 max_packet_size_ = size; | 22 max_packet_size_ = size; |
| 23 } | 23 } |
| 24 | 24 |
| 25 VideoEncoderVerbatim::~VideoEncoderVerbatim() { | 25 VideoEncoderVerbatim::~VideoEncoderVerbatim() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void VideoEncoderVerbatim::Encode( | 28 void VideoEncoderVerbatim::Encode( |
| 29 scoped_refptr<CaptureData> capture_data, | 29 scoped_refptr<media::ScreenCaptureData> capture_data, |
| 30 bool key_frame, | 30 bool key_frame, |
| 31 const DataAvailableCallback& data_available_callback) { | 31 const DataAvailableCallback& data_available_callback) { |
| 32 capture_data_ = capture_data; | 32 capture_data_ = capture_data; |
| 33 callback_ = data_available_callback; | 33 callback_ = data_available_callback; |
| 34 encode_start_time_ = base::Time::Now(); | 34 encode_start_time_ = base::Time::Now(); |
| 35 | 35 |
| 36 const SkRegion& region = capture_data->dirty_region(); | 36 const SkRegion& region = capture_data->dirty_region(); |
| 37 SkRegion::Iterator iter(region); | 37 SkRegion::Iterator iter(region); |
| 38 while (!iter.done()) { | 38 while (!iter.done()) { |
| 39 SkIRect rect = iter.rect(); | 39 SkIRect rect = iter.rect(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 uint8* VideoEncoderVerbatim::GetOutputBuffer(VideoPacket* packet, size_t size) { | 130 uint8* VideoEncoderVerbatim::GetOutputBuffer(VideoPacket* packet, size_t size) { |
| 131 packet->mutable_data()->resize(size); | 131 packet->mutable_data()->resize(size); |
| 132 // TODO(ajwong): Is there a better way to do this at all??? | 132 // TODO(ajwong): Is there a better way to do this at all??? |
| 133 return const_cast<uint8*>(reinterpret_cast<const uint8*>( | 133 return const_cast<uint8*>(reinterpret_cast<const uint8*>( |
| 134 packet->mutable_data()->data())); | 134 packet->mutable_data()->data())); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace remoting | 137 } // namespace remoting |
| OLD | NEW |