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

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

Issue 899583002: Revert of [Cast] Software encoder support for varying video frame sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 VideoEncoderImpl::VideoEncoderImpl( 55 VideoEncoderImpl::VideoEncoderImpl(
56 scoped_refptr<CastEnvironment> cast_environment, 56 scoped_refptr<CastEnvironment> cast_environment,
57 const VideoSenderConfig& video_config, 57 const VideoSenderConfig& video_config)
58 const CastInitializationCallback& initialization_cb)
59 : cast_environment_(cast_environment) { 58 : cast_environment_(cast_environment) {
60 CHECK(cast_environment_->HasVideoThread()); 59 CHECK(cast_environment_->HasVideoThread());
61 if (video_config.codec == CODEC_VIDEO_VP8) { 60 if (video_config.codec == CODEC_VIDEO_VP8) {
62 encoder_.reset(new Vp8Encoder(video_config)); 61 encoder_.reset(new Vp8Encoder(video_config));
63 cast_environment_->PostTask(CastEnvironment::VIDEO, 62 cast_environment_->PostTask(CastEnvironment::VIDEO,
64 FROM_HERE, 63 FROM_HERE,
65 base::Bind(&InitializeEncoderOnEncoderThread, 64 base::Bind(&InitializeEncoderOnEncoderThread,
66 cast_environment, 65 cast_environment,
67 encoder_.get())); 66 encoder_.get()));
68 #ifndef OFFICIAL_BUILD 67 #ifndef OFFICIAL_BUILD
69 } else if (video_config.codec == CODEC_VIDEO_FAKE) { 68 } else if (video_config.codec == CODEC_VIDEO_FAKE) {
70 encoder_.reset(new FakeSoftwareVideoEncoder(video_config)); 69 encoder_.reset(new FakeSoftwareVideoEncoder(video_config));
71 #endif 70 #endif
72 } else { 71 } else {
73 DCHECK(false) << "Invalid config"; // Codec not supported. 72 DCHECK(false) << "Invalid config"; // Codec not supported.
74 } 73 }
75 74
76 dynamic_config_.key_frame_requested = false; 75 dynamic_config_.key_frame_requested = false;
77 dynamic_config_.latest_frame_id_to_reference = kStartFrameId; 76 dynamic_config_.latest_frame_id_to_reference = kStartFrameId;
78 dynamic_config_.bit_rate = video_config.start_bitrate; 77 dynamic_config_.bit_rate = video_config.start_bitrate;
79
80 if (!initialization_cb.is_null()) {
81 cast_environment_->PostTask(
82 CastEnvironment::MAIN,
83 FROM_HERE,
84 base::Bind(initialization_cb,
85 encoder_.get() ? STATUS_VIDEO_INITIALIZED :
86 STATUS_UNSUPPORTED_VIDEO_CODEC));
87 }
88 } 78 }
89 79
90 VideoEncoderImpl::~VideoEncoderImpl() { 80 VideoEncoderImpl::~VideoEncoderImpl() {
91 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 81 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
92 if (encoder_) { 82 if (encoder_) {
93 cast_environment_->PostTask( 83 cast_environment_->PostTask(
94 CastEnvironment::VIDEO, 84 CastEnvironment::VIDEO,
95 FROM_HERE, 85 FROM_HERE,
96 base::Bind(&base::DeletePointer<SoftwareVideoEncoder>, 86 base::Bind(&base::DeletePointer<SoftwareVideoEncoder>,
97 encoder_.release())); 87 encoder_.release()));
98 } 88 }
99 } 89 }
100 90
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( 91 bool VideoEncoderImpl::EncodeVideoFrame(
108 const scoped_refptr<media::VideoFrame>& video_frame, 92 const scoped_refptr<media::VideoFrame>& video_frame,
109 const base::TimeTicks& reference_time, 93 const base::TimeTicks& reference_time,
110 const FrameEncodedCallback& frame_encoded_callback) { 94 const FrameEncodedCallback& frame_encoded_callback) {
111 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 95 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
112 DCHECK(!video_frame->visible_rect().IsEmpty());
113 DCHECK(!frame_encoded_callback.is_null());
114
115 cast_environment_->PostTask(CastEnvironment::VIDEO, 96 cast_environment_->PostTask(CastEnvironment::VIDEO,
116 FROM_HERE, 97 FROM_HERE,
117 base::Bind(&EncodeVideoFrameOnEncoderThread, 98 base::Bind(&EncodeVideoFrameOnEncoderThread,
118 cast_environment_, 99 cast_environment_,
119 encoder_.get(), 100 encoder_.get(),
120 video_frame, 101 video_frame,
121 reference_time, 102 reference_time,
122 dynamic_config_, 103 dynamic_config_,
123 frame_encoded_callback)); 104 frame_encoded_callback));
124 105
(...skipping 11 matching lines...) Expand all
136 dynamic_config_.key_frame_requested = true; 117 dynamic_config_.key_frame_requested = true;
137 } 118 }
138 119
139 // Inform the encoder to only reference frames older or equal to frame_id; 120 // Inform the encoder to only reference frames older or equal to frame_id;
140 void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) { 121 void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) {
141 dynamic_config_.latest_frame_id_to_reference = frame_id; 122 dynamic_config_.latest_frame_id_to_reference = frame_id;
142 } 123 }
143 124
144 } // namespace cast 125 } // namespace cast
145 } // namespace media 126 } // 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