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/external_video_encoder.h" | 5 #include "media/cast/sender/external_video_encoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Save the bitstream buffer in |stream_header_| to be sent later along | 193 // Save the bitstream buffer in |stream_header_| to be sent later along |
194 // with the first key frame. | 194 // with the first key frame. |
195 // | 195 // |
196 // TODO(miu): Should |stream_header_| be an std::ostringstream for | 196 // TODO(miu): Should |stream_header_| be an std::ostringstream for |
197 // performance reasons? | 197 // performance reasons? |
198 stream_header_.append(static_cast<const char*>(output_buffer->memory()), | 198 stream_header_.append(static_cast<const char*>(output_buffer->memory()), |
199 payload_size); | 199 payload_size); |
200 } else if (!in_progress_frame_encodes_.empty()) { | 200 } else if (!in_progress_frame_encodes_.empty()) { |
201 const InProgressFrameEncode& request = in_progress_frame_encodes_.front(); | 201 const InProgressFrameEncode& request = in_progress_frame_encodes_.front(); |
202 | 202 |
203 scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); | 203 scoped_ptr<EncodedFrame> encoded_frame(new EncodedFrame()); |
204 encoded_frame->dependency = key_frame ? EncodedFrame::KEY : | 204 encoded_frame->dependency = key_frame ? EncodedFrame::KEY : |
205 EncodedFrame::DEPENDENT; | 205 EncodedFrame::DEPENDENT; |
206 encoded_frame->frame_id = next_frame_id_++; | 206 encoded_frame->frame_id = next_frame_id_++; |
207 if (key_frame) | 207 if (key_frame) |
208 encoded_frame->referenced_frame_id = encoded_frame->frame_id; | 208 encoded_frame->referenced_frame_id = encoded_frame->frame_id; |
209 else | 209 else |
210 encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1; | 210 encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1; |
211 encoded_frame->rtp_timestamp = request.rtp_timestamp; | 211 encoded_frame->rtp_timestamp = request.rtp_timestamp; |
212 encoded_frame->reference_time = request.reference_time; | 212 encoded_frame->reference_time = request.reference_time; |
213 if (!stream_header_.empty()) { | 213 if (!stream_header_.empty()) { |
214 encoded_frame->data = stream_header_; | 214 encoded_frame->data = stream_header_; |
215 stream_header_.clear(); | 215 stream_header_.clear(); |
216 } | 216 } |
217 encoded_frame->data.append( | 217 encoded_frame->data.append( |
218 static_cast<const char*>(output_buffer->memory()), payload_size); | 218 static_cast<const char*>(output_buffer->memory()), payload_size); |
219 // TODO(miu): Compute and populate the |deadline_utilization| and | |
220 // |lossy_utilization| performance metrics in |encoded_frame|. | |
221 | 219 |
222 cast_environment_->PostTask( | 220 cast_environment_->PostTask( |
223 CastEnvironment::MAIN, | 221 CastEnvironment::MAIN, |
224 FROM_HERE, | 222 FROM_HERE, |
225 base::Bind(&LogFrameEncodedEvent, | 223 base::Bind(&LogFrameEncodedEvent, |
226 cast_environment_, | 224 cast_environment_, |
227 cast_environment_->Clock()->NowTicks(), | 225 cast_environment_->Clock()->NowTicks(), |
228 encoded_frame->rtp_timestamp, | 226 encoded_frame->rtp_timestamp, |
229 encoded_frame->frame_id)); | 227 encoded_frame->frame_id)); |
230 | 228 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 video_config(), | 464 video_config(), |
467 frame_size(), | 465 frame_size(), |
468 last_frame_id() + 1, | 466 last_frame_id() + 1, |
469 CreateEncoderStatusChangeCallback(), | 467 CreateEncoderStatusChangeCallback(), |
470 create_vea_cb_, | 468 create_vea_cb_, |
471 create_video_encode_memory_cb_)); | 469 create_video_encode_memory_cb_)); |
472 } | 470 } |
473 | 471 |
474 } // namespace cast | 472 } // namespace cast |
475 } // namespace media | 473 } // namespace media |
OLD | NEW |