mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-15 14:50:39 +01:00

This reverts commit 11dfff0878
.
Reason for revert: Downstream import failure.
Original change's description:
> Inform VideoEncoder of negotiated capabilities
>
> After this CL lands, an announcement will be made to
> discuss-webrtc about the deprecation of one version
> of InitEncode().
>
> Bug: webrtc:10720
> Change-Id: Ib992af0272bbb16ae16ef7e69491f365702d179e
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140884
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Commit-Queue: Elad Alon <eladalon@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28224}
TBR=sakal@webrtc.org,kwiberg@webrtc.org,eladalon@webrtc.org,kthelgason@webrtc.org,sprang@webrtc.org
Change-Id: I7f833055c67f1f879b01dd8c156ba7b8840e8747
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10720
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141411
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28225}
83 lines
2.9 KiB
C++
83 lines
2.9 KiB
C++
/*
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*
|
|
*/
|
|
|
|
#include "modules/video_coding/codecs/h264/h264_encoder_impl.h"
|
|
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
|
|
namespace {
|
|
|
|
const int kMaxPayloadSize = 1024;
|
|
const int kNumCores = 1;
|
|
|
|
void SetDefaultSettings(VideoCodec* codec_settings) {
|
|
codec_settings->codecType = kVideoCodecH264;
|
|
codec_settings->maxFramerate = 60;
|
|
codec_settings->width = 640;
|
|
codec_settings->height = 480;
|
|
// If frame dropping is false, we get a warning that bitrate can't
|
|
// be controlled for RC_QUALITY_MODE; RC_BITRATE_MODE and RC_TIMESTAMP_MODE
|
|
codec_settings->H264()->frameDroppingOn = true;
|
|
codec_settings->startBitrate = 2000;
|
|
codec_settings->maxBitrate = 4000;
|
|
}
|
|
|
|
TEST(H264EncoderImplTest, CanInitializeWithDefaultParameters) {
|
|
H264EncoderImpl encoder(cricket::VideoCodec("H264"));
|
|
VideoCodec codec_settings;
|
|
SetDefaultSettings(&codec_settings);
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize));
|
|
EXPECT_EQ(H264PacketizationMode::NonInterleaved,
|
|
encoder.PacketizationModeForTesting());
|
|
}
|
|
|
|
TEST(H264EncoderImplTest, CanInitializeWithNonInterleavedModeExplicitly) {
|
|
cricket::VideoCodec codec("H264");
|
|
codec.SetParam(cricket::kH264FmtpPacketizationMode, "1");
|
|
H264EncoderImpl encoder(codec);
|
|
VideoCodec codec_settings;
|
|
SetDefaultSettings(&codec_settings);
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize));
|
|
EXPECT_EQ(H264PacketizationMode::NonInterleaved,
|
|
encoder.PacketizationModeForTesting());
|
|
}
|
|
|
|
TEST(H264EncoderImplTest, CanInitializeWithSingleNalUnitModeExplicitly) {
|
|
cricket::VideoCodec codec("H264");
|
|
codec.SetParam(cricket::kH264FmtpPacketizationMode, "0");
|
|
H264EncoderImpl encoder(codec);
|
|
VideoCodec codec_settings;
|
|
SetDefaultSettings(&codec_settings);
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize));
|
|
EXPECT_EQ(H264PacketizationMode::SingleNalUnit,
|
|
encoder.PacketizationModeForTesting());
|
|
}
|
|
|
|
TEST(H264EncoderImplTest, CanInitializeWithRemovedParameter) {
|
|
cricket::VideoCodec codec("H264");
|
|
codec.RemoveParam(cricket::kH264FmtpPacketizationMode);
|
|
H264EncoderImpl encoder(codec);
|
|
VideoCodec codec_settings;
|
|
SetDefaultSettings(&codec_settings);
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize));
|
|
EXPECT_EQ(H264PacketizationMode::SingleNalUnit,
|
|
encoder.PacketizationModeForTesting());
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
} // namespace webrtc
|