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
3 // found in the LICENSE file.
5 #include "media/cast/sender/video_encoder.h"
7 #include "media/cast/sender/external_video_encoder.h"
8 #include "media/cast/sender/video_encoder_impl.h"
10 #if defined(OS_MACOSX)
11 #include "media/cast/sender/h264_vt_encoder.h"
18 scoped_ptr
<VideoEncoder
> VideoEncoder::Create(
19 const scoped_refptr
<CastEnvironment
>& cast_environment
,
20 const VideoSenderConfig
& video_config
,
21 const StatusChangeCallback
& status_change_cb
,
22 const CreateVideoEncodeAcceleratorCallback
& create_vea_cb
,
23 const CreateVideoEncodeMemoryCallback
& create_video_encode_memory_cb
) {
24 // On MacOS or IOS, attempt to use the system VideoToolbox library to
25 // perform optimized H.264 encoding.
26 #if defined(OS_MACOSX) || defined(OS_IOS)
27 if (!video_config
.use_external_encoder
&&
28 H264VideoToolboxEncoder::IsSupported(video_config
)) {
29 return scoped_ptr
<VideoEncoder
>(new H264VideoToolboxEncoder(
30 cast_environment
, video_config
, status_change_cb
));
32 #endif // defined(OS_MACOSX)
35 // If the system provides a hardware-accelerated encoder, use it.
36 if (ExternalVideoEncoder::IsSupported(video_config
)) {
37 return scoped_ptr
<VideoEncoder
>(new SizeAdaptableExternalVideoEncoder(
42 create_video_encode_memory_cb
));
45 // Attempt to use the software encoder implementation.
46 if (VideoEncoderImpl::IsSupported(video_config
)) {
47 return scoped_ptr
<VideoEncoder
>(new VideoEncoderImpl(
52 #endif // !defined(OS_IOS)
54 // No encoder implementation will suffice.
58 scoped_ptr
<VideoFrameFactory
> VideoEncoder::CreateVideoFrameFactory() {
62 void VideoEncoder::EmitFrames() {