Commit bc8a445f authored by Danil Chapovalov's avatar Danil Chapovalov Committed by Commit Bot

Stop using webrtc::RTPFragmentationHeader in blink

it is ignored by webrtc

Bug: webrtc:6471
Change-Id: Idaae7b4520bab691e948e4671890bd3dbeeadd1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346384Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Danil Chapovalov <danilchap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796399}
parent de7b381d
...@@ -308,28 +308,6 @@ webrtc::VideoCodecType ProfileToWebRtcVideoCodecType( ...@@ -308,28 +308,6 @@ webrtc::VideoCodecType ProfileToWebRtcVideoCodecType(
return webrtc::kVideoCodecGeneric; return webrtc::kVideoCodecGeneric;
} }
// Populates struct webrtc::RTPFragmentationHeader for H264 codec.
// Each entry specifies the offset and length (excluding start code) of a NALU.
// Returns true if successful.
bool GetRTPFragmentationHeaderH264(webrtc::RTPFragmentationHeader* header,
const uint8_t* data,
uint32_t length) {
std::vector<media::H264NALU> nalu_vector;
if (!media::H264Parser::ParseNALUs(data, length, &nalu_vector)) {
// H264Parser::ParseNALUs() has logged the errors already.
return false;
}
// TODO(zijiehe): Find a right place to share the following logic between
// //content and //remoting.
header->VerifyAndAllocateFragmentationHeader(nalu_vector.size());
for (size_t i = 0; i < nalu_vector.size(); ++i) {
header->fragmentationOffset[i] = nalu_vector[i].data - data;
header->fragmentationLength[i] = static_cast<size_t>(nalu_vector[i].size);
}
return true;
}
void RecordInitEncodeUMA(int32_t init_retval, void RecordInitEncodeUMA(int32_t init_retval,
media::VideoCodecProfile profile) { media::VideoCodecProfile profile) {
UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess",
...@@ -1292,31 +1270,7 @@ void RTCVideoEncoder::Impl::ReturnEncodedImage( ...@@ -1292,31 +1270,7 @@ void RTCVideoEncoder::Impl::ReturnEncodedImage(
if (!encoded_image_callback_) if (!encoded_image_callback_)
return; return;
webrtc::RTPFragmentationHeader header; const auto result = encoded_image_callback_->OnEncodedImage(image, &info);
memset(&header, 0, sizeof(header));
switch (video_codec_type_) {
case webrtc::kVideoCodecVP8:
case webrtc::kVideoCodecVP9:
// Generate a header describing a single fragment.
header.VerifyAndAllocateFragmentationHeader(1);
header.fragmentationOffset[0] = 0;
header.fragmentationLength[0] = image.size();
break;
case webrtc::kVideoCodecH264:
if (!GetRTPFragmentationHeaderH264(&header, image.data(), image.size())) {
DLOG(ERROR) << "Failed to get RTP fragmentation header for H264";
NotifyError(
(media::VideoEncodeAccelerator::Error)WEBRTC_VIDEO_CODEC_ERROR);
return;
}
break;
default:
NOTREACHED() << "Invalid video codec type";
return;
}
const auto result =
encoded_image_callback_->OnEncodedImage(image, &info, &header);
if (result.error != webrtc::EncodedImageCallback::Result::OK) { if (result.error != webrtc::EncodedImageCallback::Result::OK) {
DVLOG(2) DVLOG(2)
<< "ReturnEncodedImage(): webrtc::EncodedImageCallback::Result.error = " << "ReturnEncodedImage(): webrtc::EncodedImageCallback::Result.error = "
......
...@@ -42,18 +42,15 @@ class EncodedImageCallbackWrapper : public webrtc::EncodedImageCallback { ...@@ -42,18 +42,15 @@ class EncodedImageCallbackWrapper : public webrtc::EncodedImageCallback {
public: public:
using EncodedCallback = base::OnceCallback<void( using EncodedCallback = base::OnceCallback<void(
const webrtc::EncodedImage& encoded_image, const webrtc::EncodedImage& encoded_image,
const webrtc::CodecSpecificInfo* codec_specific_info, const webrtc::CodecSpecificInfo* codec_specific_info)>;
const webrtc::RTPFragmentationHeader* fragmentation)>;
EncodedImageCallbackWrapper(EncodedCallback encoded_callback) EncodedImageCallbackWrapper(EncodedCallback encoded_callback)
: encoded_callback_(std::move(encoded_callback)) {} : encoded_callback_(std::move(encoded_callback)) {}
Result OnEncodedImage( Result OnEncodedImage(
const webrtc::EncodedImage& encoded_image, const webrtc::EncodedImage& encoded_image,
const webrtc::CodecSpecificInfo* codec_specific_info, const webrtc::CodecSpecificInfo* codec_specific_info) override {
const webrtc::RTPFragmentationHeader* fragmentation) override { std::move(encoded_callback_).Run(encoded_image, codec_specific_info);
std::move(encoded_callback_)
.Run(encoded_image, codec_specific_info, fragmentation);
return Result(Result::OK); return Result(Result::OK);
} }
...@@ -261,8 +258,7 @@ class RTCVideoEncoderTest ...@@ -261,8 +258,7 @@ class RTCVideoEncoderTest
void VerifyTimestamp(uint32_t rtp_timestamp, void VerifyTimestamp(uint32_t rtp_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const webrtc::EncodedImage& encoded_image, const webrtc::EncodedImage& encoded_image,
const webrtc::CodecSpecificInfo* codec_specific_info, const webrtc::CodecSpecificInfo* codec_specific_info) {
const webrtc::RTPFragmentationHeader* fragmentation) {
DVLOG(3) << __func__; DVLOG(3) << __func__;
EXPECT_EQ(rtp_timestamp, encoded_image.Timestamp()); EXPECT_EQ(rtp_timestamp, encoded_image.Timestamp());
EXPECT_EQ(capture_time_ms, encoded_image.capture_time_ms_); EXPECT_EQ(capture_time_ms, encoded_image.capture_time_ms_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment