| 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" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 encoder->Encode(video_frame, reference_time, encoded_frame.get()); | 44 encoder->Encode(video_frame, reference_time, encoded_frame.get()); |
| 45 encoded_frame->encode_completion_time = environment->Clock()->NowTicks(); | 45 encoded_frame->encode_completion_time = environment->Clock()->NowTicks(); |
| 46 environment->PostTask( | 46 environment->PostTask( |
| 47 CastEnvironment::MAIN, | 47 CastEnvironment::MAIN, |
| 48 FROM_HERE, | 48 FROM_HERE, |
| 49 base::Bind(frame_encoded_callback, base::Passed(&encoded_frame))); | 49 base::Bind(frame_encoded_callback, base::Passed(&encoded_frame))); |
| 50 } | 50 } |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 bool VideoEncoderImpl::IsSupported(const FrameSenderConfig& video_config) { | 54 bool VideoEncoderImpl::IsSupported(const VideoSenderConfig& video_config) { |
| 55 #ifndef OFFICIAL_BUILD | 55 #ifndef OFFICIAL_BUILD |
| 56 if (video_config.codec == CODEC_VIDEO_FAKE) | 56 if (video_config.codec == CODEC_VIDEO_FAKE) |
| 57 return true; | 57 return true; |
| 58 #endif | 58 #endif |
| 59 return video_config.codec == CODEC_VIDEO_VP8; | 59 return video_config.codec == CODEC_VIDEO_VP8; |
| 60 } | 60 } |
| 61 | 61 |
| 62 VideoEncoderImpl::VideoEncoderImpl( | 62 VideoEncoderImpl::VideoEncoderImpl( |
| 63 scoped_refptr<CastEnvironment> cast_environment, | 63 scoped_refptr<CastEnvironment> cast_environment, |
| 64 const FrameSenderConfig& video_config, | 64 const VideoSenderConfig& video_config, |
| 65 const StatusChangeCallback& status_change_cb) | 65 const StatusChangeCallback& status_change_cb) |
| 66 : cast_environment_(cast_environment) { | 66 : cast_environment_(cast_environment) { |
| 67 CHECK(cast_environment_->HasVideoThread()); | 67 CHECK(cast_environment_->HasVideoThread()); |
| 68 DCHECK(!status_change_cb.is_null()); | 68 DCHECK(!status_change_cb.is_null()); |
| 69 | 69 |
| 70 if (video_config.codec == CODEC_VIDEO_VP8) { | 70 if (video_config.codec == CODEC_VIDEO_VP8) { |
| 71 encoder_.reset(new Vp8Encoder(video_config)); | 71 encoder_.reset(new Vp8Encoder(video_config)); |
| 72 cast_environment_->PostTask(CastEnvironment::VIDEO, | 72 cast_environment_->PostTask(CastEnvironment::VIDEO, |
| 73 FROM_HERE, | 73 FROM_HERE, |
| 74 base::Bind(&InitializeEncoderOnEncoderThread, | 74 base::Bind(&InitializeEncoderOnEncoderThread, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 dynamic_config_.bit_rate = new_bit_rate; | 131 dynamic_config_.bit_rate = new_bit_rate; |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Inform the encoder to encode the next frame as a key frame. | 134 // Inform the encoder to encode the next frame as a key frame. |
| 135 void VideoEncoderImpl::GenerateKeyFrame() { | 135 void VideoEncoderImpl::GenerateKeyFrame() { |
| 136 dynamic_config_.key_frame_requested = true; | 136 dynamic_config_.key_frame_requested = true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace cast | 139 } // namespace cast |
| 140 } // namespace media | 140 } // namespace media |
| OLD | NEW |