mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-17 07:37:51 +01:00

max-fr and max-fs are mandatory fields for VP8 and VP9. Add parsing as a first step to enable use of these fields. Bug: chromium:1032518 Change-Id: I4fd8f7f84f6303d646fb3f5313a02d6cf4160346 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162801 Commit-Queue: Johannes Kron <kron@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30114}
68 lines
2.3 KiB
C++
68 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2019 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 "media/base/sdp_fmtp_utils.h"
|
|
|
|
#include <string.h>
|
|
#include <map>
|
|
#include <utility>
|
|
|
|
#include "rtc_base/string_to_number.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
namespace {
|
|
// Max frame rate for VP8 and VP9 video.
|
|
const char kVPxFmtpMaxFrameRate[] = "max-fr";
|
|
// Max frame size for VP8 and VP9 video.
|
|
const char kVPxFmtpMaxFrameSize[] = "max-fs";
|
|
} // namespace
|
|
|
|
TEST(SdpFmtpUtilsTest, MaxFrameRateIsMissingOrInvalid) {
|
|
SdpVideoFormat::Parameters params;
|
|
absl::optional<int> empty = ParseSdpForVPxMaxFrameRate(params);
|
|
EXPECT_FALSE(empty);
|
|
params[kVPxFmtpMaxFrameRate] = "-1";
|
|
EXPECT_FALSE(ParseSdpForVPxMaxFrameRate(params));
|
|
params[kVPxFmtpMaxFrameRate] = "0";
|
|
EXPECT_FALSE(ParseSdpForVPxMaxFrameRate(params));
|
|
params[kVPxFmtpMaxFrameRate] = "abcde";
|
|
EXPECT_FALSE(ParseSdpForVPxMaxFrameRate(params));
|
|
}
|
|
|
|
TEST(SdpFmtpUtilsTest, MaxFrameRateIsSpecified) {
|
|
SdpVideoFormat::Parameters params;
|
|
params[kVPxFmtpMaxFrameRate] = "30";
|
|
EXPECT_EQ(ParseSdpForVPxMaxFrameRate(params), 30);
|
|
params[kVPxFmtpMaxFrameRate] = "60";
|
|
EXPECT_EQ(ParseSdpForVPxMaxFrameRate(params), 60);
|
|
}
|
|
|
|
TEST(SdpFmtpUtilsTest, MaxFrameSizeIsMissingOrInvalid) {
|
|
SdpVideoFormat::Parameters params;
|
|
absl::optional<int> empty = ParseSdpForVPxMaxFrameSize(params);
|
|
EXPECT_FALSE(empty);
|
|
params[kVPxFmtpMaxFrameSize] = "-1";
|
|
EXPECT_FALSE(ParseSdpForVPxMaxFrameSize(params));
|
|
params[kVPxFmtpMaxFrameSize] = "0";
|
|
EXPECT_FALSE(ParseSdpForVPxMaxFrameSize(params));
|
|
params[kVPxFmtpMaxFrameSize] = "abcde";
|
|
EXPECT_FALSE(ParseSdpForVPxMaxFrameSize(params));
|
|
}
|
|
|
|
TEST(SdpFmtpUtilsTest, MaxFrameSizeIsSpecified) {
|
|
SdpVideoFormat::Parameters params;
|
|
params[kVPxFmtpMaxFrameSize] = "8100"; // 1920 x 1080 / (16^2)
|
|
EXPECT_EQ(ParseSdpForVPxMaxFrameSize(params), 1920 * 1080);
|
|
params[kVPxFmtpMaxFrameSize] = "32400"; // 3840 x 2160 / (16^2)
|
|
EXPECT_EQ(ParseSdpForVPxMaxFrameSize(params), 3840 * 2160);
|
|
}
|
|
|
|
} // namespace webrtc
|