Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: media/cast/sender/video_encoder_impl.cc

Issue 906403006: [Cast] Size-Adaptable platform video encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed hubbe's comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 scoped_ptr<EncodedFrame> encoded_frame(new EncodedFrame()); 46 scoped_ptr<EncodedFrame> encoded_frame(new EncodedFrame());
47 encoder->Encode(video_frame, reference_time, encoded_frame.get()); 47 encoder->Encode(video_frame, reference_time, encoded_frame.get());
48 environment->PostTask( 48 environment->PostTask(
49 CastEnvironment::MAIN, 49 CastEnvironment::MAIN,
50 FROM_HERE, 50 FROM_HERE,
51 base::Bind(frame_encoded_callback, base::Passed(&encoded_frame))); 51 base::Bind(frame_encoded_callback, base::Passed(&encoded_frame)));
52 } 52 }
53 } // namespace 53 } // namespace
54 54
55 // static
56 bool VideoEncoderImpl::IsSupported(const VideoSenderConfig& video_config) {
57 #ifndef OFFICIAL_BUILD
58 if (video_config.codec == CODEC_VIDEO_FAKE)
59 return true;
60 #endif
61 return video_config.codec == CODEC_VIDEO_VP8;
62 }
63
55 VideoEncoderImpl::VideoEncoderImpl( 64 VideoEncoderImpl::VideoEncoderImpl(
56 scoped_refptr<CastEnvironment> cast_environment, 65 scoped_refptr<CastEnvironment> cast_environment,
57 const VideoSenderConfig& video_config, 66 const VideoSenderConfig& video_config,
58 const StatusChangeCallback& status_change_cb) 67 const StatusChangeCallback& status_change_cb)
59 : cast_environment_(cast_environment) { 68 : cast_environment_(cast_environment) {
60 CHECK(cast_environment_->HasVideoThread()); 69 CHECK(cast_environment_->HasVideoThread());
61 DCHECK(!status_change_cb.is_null()); 70 DCHECK(!status_change_cb.is_null());
62 71
63 if (video_config.codec == CODEC_VIDEO_VP8) { 72 if (video_config.codec == CODEC_VIDEO_VP8) {
64 encoder_.reset(new Vp8Encoder(video_config)); 73 encoder_.reset(new Vp8Encoder(video_config));
(...skipping 26 matching lines...) Expand all
91 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 100 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
92 if (encoder_) { 101 if (encoder_) {
93 cast_environment_->PostTask( 102 cast_environment_->PostTask(
94 CastEnvironment::VIDEO, 103 CastEnvironment::VIDEO,
95 FROM_HERE, 104 FROM_HERE,
96 base::Bind(&base::DeletePointer<SoftwareVideoEncoder>, 105 base::Bind(&base::DeletePointer<SoftwareVideoEncoder>,
97 encoder_.release())); 106 encoder_.release()));
98 } 107 }
99 } 108 }
100 109
101 bool VideoEncoderImpl::CanEncodeVariedFrameSizes() const {
102 // Both the VP8Encoder and FakeSoftwareVideoEncoder support calls to
103 // EncodeVideoFrame() with different frame sizes.
104 return true;
105 }
106
107 bool VideoEncoderImpl::EncodeVideoFrame( 110 bool VideoEncoderImpl::EncodeVideoFrame(
108 const scoped_refptr<media::VideoFrame>& video_frame, 111 const scoped_refptr<media::VideoFrame>& video_frame,
109 const base::TimeTicks& reference_time, 112 const base::TimeTicks& reference_time,
110 const FrameEncodedCallback& frame_encoded_callback) { 113 const FrameEncodedCallback& frame_encoded_callback) {
111 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 114 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
112 DCHECK(!video_frame->visible_rect().IsEmpty()); 115 DCHECK(!video_frame->visible_rect().IsEmpty());
113 DCHECK(!frame_encoded_callback.is_null()); 116 DCHECK(!frame_encoded_callback.is_null());
114 117
115 cast_environment_->PostTask(CastEnvironment::VIDEO, 118 cast_environment_->PostTask(CastEnvironment::VIDEO,
116 FROM_HERE, 119 FROM_HERE,
(...skipping 19 matching lines...) Expand all
136 dynamic_config_.key_frame_requested = true; 139 dynamic_config_.key_frame_requested = true;
137 } 140 }
138 141
139 // Inform the encoder to only reference frames older or equal to frame_id; 142 // Inform the encoder to only reference frames older or equal to frame_id;
140 void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) { 143 void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) {
141 dynamic_config_.latest_frame_id_to_reference = frame_id; 144 dynamic_config_.latest_frame_id_to_reference = frame_id;
142 } 145 }
143 146
144 } // namespace cast 147 } // namespace cast
145 } // namespace media 148 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_encoder_impl.h ('k') | media/cast/sender/video_encoder_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698