| 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/vp8_encoder.h" | 5 #include "media/cast/sender/vp8_encoder.h" |
| 6 | 6 |
| 7 #include "base/debug/crash_logging.h" | 7 #include "base/debug/crash_logging.h" |
| 8 #include "base/debug/dump_without_crashing.h" | 8 #include "base/debug/dump_without_crashing.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 encoded_frame->dependency = EncodedFrame::KEY; | 219 encoded_frame->dependency = EncodedFrame::KEY; |
| 220 encoded_frame->referenced_frame_id = encoded_frame->frame_id; | 220 encoded_frame->referenced_frame_id = encoded_frame->frame_id; |
| 221 } else { | 221 } else { |
| 222 encoded_frame->dependency = EncodedFrame::DEPENDENT; | 222 encoded_frame->dependency = EncodedFrame::DEPENDENT; |
| 223 // Frame dependencies could theoretically be relaxed by looking for the | 223 // Frame dependencies could theoretically be relaxed by looking for the |
| 224 // VPX_FRAME_IS_DROPPABLE flag, but in recent testing (Oct 2014), this | 224 // VPX_FRAME_IS_DROPPABLE flag, but in recent testing (Oct 2014), this |
| 225 // flag never seems to be set. | 225 // flag never seems to be set. |
| 226 encoded_frame->referenced_frame_id = last_encoded_frame_id_ - 1; | 226 encoded_frame->referenced_frame_id = last_encoded_frame_id_ - 1; |
| 227 } | 227 } |
| 228 encoded_frame->rtp_timestamp = | 228 encoded_frame->rtp_timestamp = |
| 229 TimeDeltaToRtpDelta(video_frame->timestamp(), kVideoFrequency); | 229 RtpTimeTicks::FromTimeDelta(video_frame->timestamp(), kVideoFrequency); |
| 230 encoded_frame->reference_time = reference_time; | 230 encoded_frame->reference_time = reference_time; |
| 231 encoded_frame->data.assign( | 231 encoded_frame->data.assign( |
| 232 static_cast<const uint8*>(pkt->data.frame.buf), | 232 static_cast<const uint8*>(pkt->data.frame.buf), |
| 233 static_cast<const uint8*>(pkt->data.frame.buf) + pkt->data.frame.sz); | 233 static_cast<const uint8*>(pkt->data.frame.buf) + pkt->data.frame.sz); |
| 234 break; // Done, since all data is provided in one CX_FRAME_PKT packet. | 234 break; // Done, since all data is provided in one CX_FRAME_PKT packet. |
| 235 } | 235 } |
| 236 DCHECK(!encoded_frame->data.empty()) | 236 DCHECK(!encoded_frame->data.empty()) |
| 237 << "BUG: Encoder must provide data since lagged encoding is disabled."; | 237 << "BUG: Encoder must provide data since lagged encoding is disabled."; |
| 238 | 238 |
| 239 // TODO(miu): Determine when/why encoding can produce zero-length data, | 239 // TODO(miu): Determine when/why encoding can produce zero-length data, |
| 240 // which causes crypto crashes. http://crbug.com/519022 | 240 // which causes crypto crashes. http://crbug.com/519022 |
| 241 if (!has_seen_zero_length_encoded_frame_ && encoded_frame->data.empty()) { | 241 if (!has_seen_zero_length_encoded_frame_ && encoded_frame->data.empty()) { |
| 242 has_seen_zero_length_encoded_frame_ = true; | 242 has_seen_zero_length_encoded_frame_ = true; |
| 243 | 243 |
| 244 const char kZeroEncodeDetails[] = "zero-encode-details"; | 244 const char kZeroEncodeDetails[] = "zero-encode-details"; |
| 245 const std::string details = base::StringPrintf( | 245 const std::string details = base::StringPrintf( |
| 246 "SV/%c,id=%" PRIu32 ",rtp=%" PRIu32 ",br=%d,kfr=%c", | 246 "SV/%c,id=%" PRIu32 ",rtp=%" PRIu32 ",br=%d,kfr=%c", |
| 247 encoded_frame->dependency == EncodedFrame::KEY ? 'K' : 'D', | 247 encoded_frame->dependency == EncodedFrame::KEY ? 'K' : 'D', |
| 248 encoded_frame->frame_id, encoded_frame->rtp_timestamp, | 248 encoded_frame->frame_id, encoded_frame->rtp_timestamp.lower_32_bits(), |
| 249 static_cast<int>(config_.rc_target_bitrate), | 249 static_cast<int>(config_.rc_target_bitrate), |
| 250 key_frame_requested_ ? 'Y' : 'N'); | 250 key_frame_requested_ ? 'Y' : 'N'); |
| 251 base::debug::SetCrashKeyValue(kZeroEncodeDetails, details); | 251 base::debug::SetCrashKeyValue(kZeroEncodeDetails, details); |
| 252 // Please forward crash reports to http://crbug.com/519022: | 252 // Please forward crash reports to http://crbug.com/519022: |
| 253 base::debug::DumpWithoutCrashing(); | 253 base::debug::DumpWithoutCrashing(); |
| 254 base::debug::ClearCrashKey(kZeroEncodeDetails); | 254 base::debug::ClearCrashKey(kZeroEncodeDetails); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // Compute deadline utilization as the real-world time elapsed divided by the | 257 // Compute deadline utilization as the real-world time elapsed divided by the |
| 258 // frame duration. | 258 // frame duration. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 VLOG(1) << "VP8 new rc_target_bitrate: " << new_bitrate_kbit << " kbps"; | 311 VLOG(1) << "VP8 new rc_target_bitrate: " << new_bitrate_kbit << " kbps"; |
| 312 } | 312 } |
| 313 | 313 |
| 314 void Vp8Encoder::GenerateKeyFrame() { | 314 void Vp8Encoder::GenerateKeyFrame() { |
| 315 DCHECK(thread_checker_.CalledOnValidThread()); | 315 DCHECK(thread_checker_.CalledOnValidThread()); |
| 316 key_frame_requested_ = true; | 316 key_frame_requested_ = true; |
| 317 } | 317 } |
| 318 | 318 |
| 319 } // namespace cast | 319 } // namespace cast |
| 320 } // namespace media | 320 } // namespace media |
| OLD | NEW |