| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/sender/h264_vt_encoder.h" | 5 #include "media/cast/sender/h264_vt_encoder.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 DISALLOW_COPY_AND_ASSIGN(VideoFrameFactoryCVPixelBufferPoolImpl); | 221 DISALLOW_COPY_AND_ASSIGN(VideoFrameFactoryCVPixelBufferPoolImpl); |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 } // namespace | 224 } // namespace |
| 225 | 225 |
| 226 H264VideoToolboxEncoder::H264VideoToolboxEncoder( | 226 H264VideoToolboxEncoder::H264VideoToolboxEncoder( |
| 227 const scoped_refptr<CastEnvironment>& cast_environment, | 227 const scoped_refptr<CastEnvironment>& cast_environment, |
| 228 const VideoSenderConfig& video_config, | 228 const VideoSenderConfig& video_config, |
| 229 const gfx::Size& frame_size, | 229 const gfx::Size& frame_size, |
| 230 const CastInitializationCallback& initialization_cb) | 230 const StatusChangeCallback& status_change_cb) |
| 231 : cast_environment_(cast_environment), | 231 : cast_environment_(cast_environment), |
| 232 | |
| 233 videotoolbox_glue_(VideoToolboxGlue::Get()), | 232 videotoolbox_glue_(VideoToolboxGlue::Get()), |
| 234 frame_id_(kStartFrameId), | 233 frame_id_(kStartFrameId), |
| 235 encode_next_frame_as_keyframe_(false) { | 234 encode_next_frame_as_keyframe_(false) { |
| 236 DCHECK(!frame_size.IsEmpty()); | 235 DCHECK(!frame_size.IsEmpty()); |
| 236 DCHECK(!status_change_cb.is_null()); |
| 237 | 237 |
| 238 CastInitializationStatus initialization_status; | 238 OperationalStatus operational_status; |
| 239 if (videotoolbox_glue_) { | 239 if (video_config.codec == CODEC_VIDEO_H264 && videotoolbox_glue_) { |
| 240 initialization_status = (Initialize(video_config, frame_size)) | 240 operational_status = Initialize(video_config, frame_size) ? |
| 241 ? STATUS_VIDEO_INITIALIZED | 241 STATUS_INITIALIZED : STATUS_INVALID_CONFIGURATION; |
| 242 : STATUS_INVALID_VIDEO_CONFIGURATION; | |
| 243 } else { | 242 } else { |
| 244 LOG(ERROR) << " VideoToolbox is not available"; | 243 operational_status = STATUS_UNSUPPORTED_CODEC; |
| 245 initialization_status = STATUS_HW_VIDEO_ENCODER_NOT_SUPPORTED; | |
| 246 } | 244 } |
| 247 if (!initialization_cb.is_null()) { | 245 cast_environment_->PostTask( |
| 248 cast_environment_->PostTask( | 246 CastEnvironment::MAIN, |
| 249 CastEnvironment::MAIN, | 247 FROM_HERE, |
| 250 FROM_HERE, | 248 base::Bind(status_change_cb, operational_status)); |
| 251 base::Bind(initialization_cb, initialization_status)); | |
| 252 } | |
| 253 } | 249 } |
| 254 | 250 |
| 255 H264VideoToolboxEncoder::~H264VideoToolboxEncoder() { | 251 H264VideoToolboxEncoder::~H264VideoToolboxEncoder() { |
| 256 Teardown(); | 252 Teardown(); |
| 257 } | 253 } |
| 258 | 254 |
| 259 bool H264VideoToolboxEncoder::Initialize( | 255 bool H264VideoToolboxEncoder::Initialize( |
| 260 const VideoSenderConfig& video_config, | 256 const VideoSenderConfig& video_config, |
| 261 const gfx::Size& frame_size) { | 257 const gfx::Size& frame_size) { |
| 262 DCHECK(thread_checker_.CalledOnValidThread()); | 258 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 CopySampleBufferToAnnexBBuffer(sbuf, &encoded_frame->data, keyframe); | 533 CopySampleBufferToAnnexBBuffer(sbuf, &encoded_frame->data, keyframe); |
| 538 | 534 |
| 539 encoder->cast_environment_->PostTask( | 535 encoder->cast_environment_->PostTask( |
| 540 CastEnvironment::MAIN, FROM_HERE, | 536 CastEnvironment::MAIN, FROM_HERE, |
| 541 base::Bind(request->frame_encoded_callback, | 537 base::Bind(request->frame_encoded_callback, |
| 542 base::Passed(&encoded_frame))); | 538 base::Passed(&encoded_frame))); |
| 543 } | 539 } |
| 544 | 540 |
| 545 } // namespace cast | 541 } // namespace cast |
| 546 } // namespace media | 542 } // namespace media |
| OLD | NEW |