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

Unified Diff: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

Issue 2911193002: Implement timing frames. (Closed)
Patch Set: Fix uninitialized variables memcheck errors Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
diff --git a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
index 1a10ddfa62272d5d354c0f8866f772999f99218e..c47ac2eb40b8604f876f62017dc5d0df622f6fa2 100644
--- a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
+++ b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
@@ -21,8 +21,8 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/timeutils.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
-#include "webrtc/media/base/mediaconstants.h"
#include "webrtc/system_wrappers/include/metrics.h"
namespace webrtc {
@@ -167,7 +167,10 @@ H264EncoderImpl::H264EncoderImpl(const cricket::VideoCodec& codec)
number_of_cores_(0),
encoded_image_callback_(nullptr),
has_reported_init_(false),
- has_reported_error_(false) {
+ has_reported_error_(false),
+ last_timing_frame_time_ms_(0),
sprang_webrtc 2017/05/31 11:12:55 Probably a good idea to use -1 as uninitialized va
ilnik 2017/05/31 15:17:45 Done.
+ timing_frames_delay_ms_(0),
+ min_frame_size_to_force_timing_frame_bytes_(0) {
RTC_CHECK(cricket::CodecNamesEq(codec.name, cricket::kH264CodecName));
std::string packetization_mode_string;
if (codec.GetParam(cricket::kH264FmtpPacketizationMode,
@@ -231,6 +234,9 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings,
frame_dropping_on_ = codec_settings->H264().frameDroppingOn;
key_frame_interval_ = codec_settings->H264().keyFrameInterval;
max_payload_size_ = max_payload_size;
+ min_frame_size_to_force_timing_frame_bytes_ =
+ codec_settings->minFrameSizeToForceTimingFrameBytes;
+ timing_frames_delay_ms_ = codec_settings->timingFramesDelayMs;
// Codec_settings uses kbits/second; encoder uses bits/second.
max_bps_ = codec_settings->maxBitrate * 1000;
@@ -308,6 +314,7 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
ReportError();
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
+ int64_t encode_start_ms = rtc::TimeMillis();
if (!encoded_image_callback_) {
LOG(LS_WARNING) << "InitEncode() has been called, but a callback function "
<< "has not been set with RegisterEncodeCompleteCallback()";
@@ -385,6 +392,25 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
encoded_image_._length);
h264_bitstream_parser_.GetLastSliceQp(&encoded_image_.qp_);
+ // Add timing information if needed. Timing delay is counted based on
+ // capture time to ensure that simulcast encoders will mark frames on all
+ // the streams together.
+ int64_t now_ms = rtc::TimeMillis();
+ bool is_time_for_timing_frame =
+ encoded_image_.capture_time_ms_ - last_timing_frame_time_ms_ >=
+ timing_frames_delay_ms_;
+ if (is_time_for_timing_frame) {
+ last_timing_frame_time_ms_ = encoded_image_.capture_time_ms_;
+ }
+ if (is_time_for_timing_frame ||
+ encoded_image_._length >= min_frame_size_to_force_timing_frame_bytes_) {
+ encoded_image_.timing_.is_timing_frame = true;
+ encoded_image_.timing_.encode_start_ms = encode_start_ms;
+ encoded_image_.timing_.encode_finish_ms = now_ms;
+ } else {
+ encoded_image_.timing_.is_timing_frame = false;
+ }
+
sprang_webrtc 2017/05/31 11:12:55 I'm not sure you need to do this on a per codec le
ilnik 2017/05/31 15:17:45 Firstly, it will be very troublesome to update VCM
sprang_webrtc 2017/06/05 14:39:20 You can always start by having a simple method dec
ilnik 2017/06/07 14:25:03 Done.
// Deliver encoded image.
CodecSpecificInfo codec_specific;
codec_specific.codecType = kVideoCodecH264;

Powered by Google App Engine
This is Rietveld 408576698