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/video_encoder_impl.h" | 5 #include "media/cast/sender/video_encoder_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
13 #include "media/cast/cast_defines.h" | 13 #include "media/cast/cast_defines.h" |
14 #include "media/cast/sender/fake_software_video_encoder.h" | 14 #include "media/cast/sender/fake_software_video_encoder.h" |
15 #if !defined(MEDIA_DISABLE_LIBVPX) | |
15 #include "media/cast/sender/vp8_encoder.h" | 16 #include "media/cast/sender/vp8_encoder.h" |
17 #endif // if !defined(MEDIA_DISABLE_LIBVPX) | |
16 | 18 |
17 namespace media { | 19 namespace media { |
18 namespace cast { | 20 namespace cast { |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
24 #if !defined(MEDIA_DISABLE_LIBVPX) | |
22 typedef base::Callback<void(Vp8Encoder*)> PassEncoderCallback; | 25 typedef base::Callback<void(Vp8Encoder*)> PassEncoderCallback; |
26 #endif // if !defined(MEDIA_DISABLE_LIBVPX) | |
23 | 27 |
24 void InitializeEncoderOnEncoderThread( | 28 void InitializeEncoderOnEncoderThread( |
25 const scoped_refptr<CastEnvironment>& environment, | 29 const scoped_refptr<CastEnvironment>& environment, |
26 SoftwareVideoEncoder* encoder) { | 30 SoftwareVideoEncoder* encoder) { |
27 DCHECK(environment->CurrentlyOn(CastEnvironment::VIDEO)); | 31 DCHECK(environment->CurrentlyOn(CastEnvironment::VIDEO)); |
28 encoder->Initialize(); | 32 encoder->Initialize(); |
29 } | 33 } |
30 | 34 |
31 void EncodeVideoFrameOnEncoderThread( | 35 void EncodeVideoFrameOnEncoderThread( |
32 scoped_refptr<CastEnvironment> environment, | 36 scoped_refptr<CastEnvironment> environment, |
(...skipping 30 matching lines...) Expand all Loading... | |
63 frame_encoded_callback, base::Passed(&encoded_frame))); | 67 frame_encoded_callback, base::Passed(&encoded_frame))); |
64 } | 68 } |
65 } // namespace | 69 } // namespace |
66 | 70 |
67 VideoEncoderImpl::VideoEncoderImpl( | 71 VideoEncoderImpl::VideoEncoderImpl( |
68 scoped_refptr<CastEnvironment> cast_environment, | 72 scoped_refptr<CastEnvironment> cast_environment, |
69 const VideoSenderConfig& video_config, | 73 const VideoSenderConfig& video_config, |
70 int max_unacked_frames) | 74 int max_unacked_frames) |
71 : cast_environment_(cast_environment) { | 75 : cast_environment_(cast_environment) { |
72 if (video_config.codec == CODEC_VIDEO_VP8) { | 76 if (video_config.codec == CODEC_VIDEO_VP8) { |
77 #if !defined(MEDIA_DISABLE_LIBVPX) | |
73 encoder_.reset(new Vp8Encoder(video_config, max_unacked_frames)); | 78 encoder_.reset(new Vp8Encoder(video_config, max_unacked_frames)); |
74 cast_environment_->PostTask(CastEnvironment::VIDEO, | 79 cast_environment_->PostTask(CastEnvironment::VIDEO, |
75 FROM_HERE, | 80 FROM_HERE, |
76 base::Bind(&InitializeEncoderOnEncoderThread, | 81 base::Bind(&InitializeEncoderOnEncoderThread, |
77 cast_environment, | 82 cast_environment, |
78 encoder_.get())); | 83 encoder_.get())); |
79 #ifndef OFFICIAL_BUILD | 84 #ifndef OFFICIAL_BUILD |
80 } else if (video_config.codec == CODEC_VIDEO_FAKE) { | 85 } else if (video_config.codec == CODEC_VIDEO_FAKE) { |
81 encoder_.reset(new FakeSoftwareVideoEncoder(video_config)); | 86 encoder_.reset(new FakeSoftwareVideoEncoder(video_config)); |
82 #endif | 87 #endif |
83 } else { | 88 } else { |
89 #endif // if !defined(MEDIA_DISABLE_LIBVPX) | |
brettw
2014/08/26 03:14:21
Did you mean to wrap the fake one in this block as
Alpha Left Google
2014/08/26 17:58:22
Acknowledged.
| |
84 DCHECK(false) << "Invalid config"; // Codec not supported. | 90 DCHECK(false) << "Invalid config"; // Codec not supported. |
85 } | 91 } |
86 | 92 |
87 dynamic_config_.key_frame_requested = false; | 93 dynamic_config_.key_frame_requested = false; |
88 dynamic_config_.latest_frame_id_to_reference = kStartFrameId; | 94 dynamic_config_.latest_frame_id_to_reference = kStartFrameId; |
89 dynamic_config_.bit_rate = video_config.start_bitrate; | 95 dynamic_config_.bit_rate = video_config.start_bitrate; |
90 } | 96 } |
91 | 97 |
92 VideoEncoderImpl::~VideoEncoderImpl() { | 98 VideoEncoderImpl::~VideoEncoderImpl() { |
93 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 99 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 dynamic_config_.key_frame_requested = true; | 135 dynamic_config_.key_frame_requested = true; |
130 } | 136 } |
131 | 137 |
132 // Inform the encoder to only reference frames older or equal to frame_id; | 138 // Inform the encoder to only reference frames older or equal to frame_id; |
133 void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) { | 139 void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) { |
134 dynamic_config_.latest_frame_id_to_reference = frame_id; | 140 dynamic_config_.latest_frame_id_to_reference = frame_id; |
135 } | 141 } |
136 | 142 |
137 } // namespace cast | 143 } // namespace cast |
138 } // namespace media | 144 } // namespace media |
OLD | NEW |