OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "media/base/callback.h" | 6 #include "media/base/callback.h" |
7 #include "media/base/data_buffer.h" | |
8 #include "media/base/media.h" | 7 #include "media/base/media.h" |
9 #include "remoting/base/capture_data.h" | 8 #include "remoting/base/capture_data.h" |
10 #include "remoting/base/encoder_vp8.h" | 9 #include "remoting/base/encoder_vp8.h" |
| 10 #include "remoting/proto/video.pb.h" |
11 | 11 |
12 extern "C" { | 12 extern "C" { |
13 #define VPX_CODEC_DISABLE_COMPAT 1 | 13 #define VPX_CODEC_DISABLE_COMPAT 1 |
14 #include "third_party/libvpx/include/vpx/vpx_codec.h" | 14 #include "third_party/libvpx/include/vpx/vpx_codec.h" |
15 #include "third_party/libvpx/include/vpx/vpx_encoder.h" | 15 #include "third_party/libvpx/include/vpx/vpx_encoder.h" |
16 #include "third_party/libvpx/include/vpx/vp8cx.h" | 16 #include "third_party/libvpx/include/vpx/vp8cx.h" |
17 } | 17 } |
18 | 18 |
19 namespace remoting { | 19 namespace remoting { |
20 | 20 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 image_->stride[0] = image_->w; | 107 image_->stride[0] = image_->w; |
108 image_->stride[1] = image_->w / 2; | 108 image_->stride[1] = image_->w / 2; |
109 image_->stride[2] = image_->w / 2; | 109 image_->stride[2] = image_->w / 2; |
110 } | 110 } |
111 | 111 |
112 // And then do RGB->YUV conversion. | 112 // And then do RGB->YUV conversion. |
113 // Currently we just produce the Y channel as the average of RGB. This will | 113 // Currently we just produce the Y channel as the average of RGB. This will |
114 // giv ae gray scale image after conversion. | 114 // giv ae gray scale image after conversion. |
115 // TODO(sergeyu): Move this code to a separate routine. | 115 // TODO(sergeyu): Move this code to a separate routine. |
116 // TODO(sergeyu): Optimize this code. | 116 // TODO(sergeyu): Optimize this code. |
117 DCHECK(capture_data->pixel_format() == PIXEL_FORMAT_RGB32) | 117 DCHECK(capture_data->pixel_format() == media::VideoFrame::RGB32) |
118 << "Only RGB32 is supported"; | 118 << "Only RGB32 is supported"; |
119 uint8* in = capture_data->data_planes().data[0]; | 119 uint8* in = capture_data->data_planes().data[0]; |
120 const int in_stride = capture_data->data_planes().strides[0]; | 120 const int in_stride = capture_data->data_planes().strides[0]; |
121 uint8* y_out = yuv_image_.get(); | 121 uint8* y_out = yuv_image_.get(); |
122 uint8* u_out = yuv_image_.get() + plane_size; | 122 uint8* u_out = yuv_image_.get() + plane_size; |
123 uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4; | 123 uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4; |
124 const int out_stride = image_->stride[0]; | 124 const int out_stride = image_->stride[0]; |
125 for (int i = 0; i < capture_data->height(); ++i) { | 125 for (int i = 0; i < capture_data->height(); ++i) { |
126 for (int j = 0; j < capture_data->width(); ++j) { | 126 for (int j = 0; j < capture_data->width(); ++j) { |
127 // Since the input pixel format is RGB32, there are 4 bytes per pixel. | 127 // Since the input pixel format is RGB32, there are 4 bytes per pixel. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 got_data = true; | 190 got_data = true; |
191 message->set_data(packet->data.frame.buf, packet->data.frame.sz); | 191 message->set_data(packet->data.frame.buf, packet->data.frame.sz); |
192 break; | 192 break; |
193 default: | 193 default: |
194 break; | 194 break; |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); | 198 message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); |
199 message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET); | 199 message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET); |
200 message->mutable_format()->set_pixel_format(PIXEL_FORMAT_RGB32); | |
201 message->mutable_format()->set_x(0); | |
202 message->mutable_format()->set_y(0); | |
203 message->mutable_format()->set_width(capture_data->width()); | |
204 message->mutable_format()->set_height(capture_data->height()); | |
205 | 200 |
206 data_available_callback->Run(message); | 201 data_available_callback->Run(message); |
207 delete data_available_callback; | 202 delete data_available_callback; |
208 } | 203 } |
209 | 204 |
210 } // namespace remoting | 205 } // namespace remoting |
OLD | NEW |