| 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/pepper_to_video_track_adapter.h" | 5 #include "content/renderer/media/pepper_to_video_track_adapter.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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 PpFrameWriter::~PpFrameWriter() { | 115 PpFrameWriter::~PpFrameWriter() { |
| 116 DVLOG(3) << "PpFrameWriter dtor"; | 116 DVLOG(3) << "PpFrameWriter dtor"; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void PpFrameWriter::GetCurrentSupportedFormats( | 119 void PpFrameWriter::GetCurrentSupportedFormats( |
| 120 int max_requested_width, | 120 int max_requested_width, |
| 121 int max_requested_height, | 121 int max_requested_height, |
| 122 double max_requested_frame_rate, | 122 double max_requested_frame_rate, |
| 123 const VideoCaptureDeviceFormatsCB& callback) { | 123 const VideoCaptureDeviceFormatsCB& callback) { |
| 124 DCHECK(CalledOnValidThread()); | 124 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 125 DVLOG(3) << "PpFrameWriter::GetCurrentSupportedFormats()"; | 125 DVLOG(3) << "PpFrameWriter::GetCurrentSupportedFormats()"; |
| 126 // Since the input is free to change the resolution at any point in time | 126 // Since the input is free to change the resolution at any point in time |
| 127 // the supported formats are unknown. | 127 // the supported formats are unknown. |
| 128 media::VideoCaptureFormats formats; | 128 media::VideoCaptureFormats formats; |
| 129 callback.Run(formats); | 129 callback.Run(formats); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void PpFrameWriter::StartSourceImpl( | 132 void PpFrameWriter::StartSourceImpl( |
| 133 const media::VideoCaptureFormat& format, | 133 const media::VideoCaptureFormat& format, |
| 134 const blink::WebMediaConstraints& constraints, | 134 const blink::WebMediaConstraints& constraints, |
| 135 const VideoCaptureDeliverFrameCB& frame_callback) { | 135 const VideoCaptureDeliverFrameCB& frame_callback) { |
| 136 DCHECK(CalledOnValidThread()); | 136 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 137 DCHECK(!delegate_.get()); | 137 DCHECK(!delegate_.get()); |
| 138 DVLOG(3) << "PpFrameWriter::StartSourceImpl()"; | 138 DVLOG(3) << "PpFrameWriter::StartSourceImpl()"; |
| 139 delegate_ = new FrameWriterDelegate(io_task_runner(), frame_callback); | 139 delegate_ = new FrameWriterDelegate(io_task_runner(), frame_callback); |
| 140 OnStartDone(MEDIA_DEVICE_OK); | 140 OnStartDone(MEDIA_DEVICE_OK); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void PpFrameWriter::StopSourceImpl() { | 143 void PpFrameWriter::StopSourceImpl() { |
| 144 DCHECK(CalledOnValidThread()); | 144 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Note: PutFrame must copy or process image_data directly in this function, | 147 // Note: PutFrame must copy or process image_data directly in this function, |
| 148 // because it may be overwritten as soon as we return from this function. | 148 // because it may be overwritten as soon as we return from this function. |
| 149 void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data, | 149 void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data, |
| 150 int64_t time_stamp_ns) { | 150 int64_t time_stamp_ns) { |
| 151 DCHECK(CalledOnValidThread()); | 151 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 152 TRACE_EVENT0("video", "PpFrameWriter::PutFrame"); | 152 TRACE_EVENT0("video", "PpFrameWriter::PutFrame"); |
| 153 DVLOG(3) << "PpFrameWriter::PutFrame()"; | 153 DVLOG(3) << "PpFrameWriter::PutFrame()"; |
| 154 | 154 |
| 155 if (!image_data) { | 155 if (!image_data) { |
| 156 LOG(ERROR) << "PpFrameWriter::PutFrame - Called with NULL image_data."; | 156 LOG(ERROR) << "PpFrameWriter::PutFrame - Called with NULL image_data."; |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 ImageDataAutoMapper mapper(image_data); | 159 ImageDataAutoMapper mapper(image_data); |
| 160 if (!mapper.is_valid()) { | 160 if (!mapper.is_valid()) { |
| 161 LOG(ERROR) << "PpFrameWriter::PutFrame - " | 161 LOG(ERROR) << "PpFrameWriter::PutFrame - " |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 bool track_enabled = true; | 265 bool track_enabled = true; |
| 266 stream.AddTrack(MediaStreamVideoTrack::CreateVideoTrack( | 266 stream.AddTrack(MediaStreamVideoTrack::CreateVideoTrack( |
| 267 writer, MediaStreamVideoSource::ConstraintsCallback(), track_enabled)); | 267 writer, MediaStreamVideoSource::ConstraintsCallback(), track_enabled)); |
| 268 | 268 |
| 269 *frame_writer = new PpFrameWriterProxy(writer->AsWeakPtr()); | 269 *frame_writer = new PpFrameWriterProxy(writer->AsWeakPtr()); |
| 270 return true; | 270 return true; |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace content | 273 } // namespace content |
| OLD | NEW |