| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/media/webrtc/video_destination_handler.h" | 5 #include "content/renderer/media/webrtc/video_destination_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (state() != MediaStreamVideoSource::STARTED) | 141 if (state() != MediaStreamVideoSource::STARTED) |
| 142 return; | 142 return; |
| 143 | 143 |
| 144 const base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( | 144 const base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( |
| 145 time_stamp_ns / base::Time::kNanosecondsPerMicrosecond); | 145 time_stamp_ns / base::Time::kNanosecondsPerMicrosecond); |
| 146 | 146 |
| 147 scoped_refptr<media::VideoFrame> new_frame = | 147 scoped_refptr<media::VideoFrame> new_frame = |
| 148 frame_pool_.CreateFrame(media::VideoFrame::YV12, frame_size, | 148 frame_pool_.CreateFrame(media::VideoFrame::YV12, frame_size, |
| 149 gfx::Rect(frame_size), frame_size, timestamp); | 149 gfx::Rect(frame_size), frame_size, timestamp); |
| 150 | 150 |
| 151 // TODO(magjed): Chrome OS is not ready for switching from BGRA to ARGB. | 151 libyuv::ARGBToI420(src_data, |
| 152 // Remove this once http://crbug/434007 is fixed. We have a corresponding | 152 src_stride, |
| 153 // problem when we send frames to the effects plugin in PepperVideoSourceHost. | 153 new_frame->data(media::VideoFrame::kYPlane), |
| 154 #if defined(OS_CHROMEOS) | 154 new_frame->stride(media::VideoFrame::kYPlane), |
| 155 auto libyuv_xxxx_to_i420 = &libyuv::BGRAToI420; | 155 new_frame->data(media::VideoFrame::kUPlane), |
| 156 #else | 156 new_frame->stride(media::VideoFrame::kUPlane), |
| 157 auto libyuv_xxxx_to_i420 = &libyuv::ARGBToI420; | 157 new_frame->data(media::VideoFrame::kVPlane), |
| 158 #endif | 158 new_frame->stride(media::VideoFrame::kVPlane), |
| 159 libyuv_xxxx_to_i420(src_data, | 159 width, |
| 160 src_stride, | 160 height); |
| 161 new_frame->data(media::VideoFrame::kYPlane), | |
| 162 new_frame->stride(media::VideoFrame::kYPlane), | |
| 163 new_frame->data(media::VideoFrame::kUPlane), | |
| 164 new_frame->stride(media::VideoFrame::kUPlane), | |
| 165 new_frame->data(media::VideoFrame::kVPlane), | |
| 166 new_frame->stride(media::VideoFrame::kVPlane), | |
| 167 width, | |
| 168 height); | |
| 169 | 161 |
| 170 delegate_->DeliverFrame(new_frame); | 162 delegate_->DeliverFrame(new_frame); |
| 171 } | 163 } |
| 172 | 164 |
| 173 // PpFrameWriterProxy is a helper class to make sure the user won't use | 165 // PpFrameWriterProxy is a helper class to make sure the user won't use |
| 174 // PpFrameWriter after it is released (IOW its owner - WebMediaStreamSource - | 166 // PpFrameWriter after it is released (IOW its owner - WebMediaStreamSource - |
| 175 // is released). | 167 // is released). |
| 176 class PpFrameWriterProxy : public FrameWriterInterface { | 168 class PpFrameWriterProxy : public FrameWriterInterface { |
| 177 public: | 169 public: |
| 178 explicit PpFrameWriterProxy(const base::WeakPtr<PpFrameWriter>& writer) | 170 explicit PpFrameWriterProxy(const base::WeakPtr<PpFrameWriter>& writer) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 227 |
| 236 stream.addTrack(MediaStreamVideoTrack::CreateVideoTrack( | 228 stream.addTrack(MediaStreamVideoTrack::CreateVideoTrack( |
| 237 writer, constraints, MediaStreamVideoSource::ConstraintsCallback(), | 229 writer, constraints, MediaStreamVideoSource::ConstraintsCallback(), |
| 238 track_enabled)); | 230 track_enabled)); |
| 239 | 231 |
| 240 *frame_writer = new PpFrameWriterProxy(writer->AsWeakPtr()); | 232 *frame_writer = new PpFrameWriterProxy(writer->AsWeakPtr()); |
| 241 return true; | 233 return true; |
| 242 } | 234 } |
| 243 | 235 |
| 244 } // namespace content | 236 } // namespace content |
| OLD | NEW |