blob: c858095d05bd73f753da8d339fd39dc00e06e118 [file] [log] [blame]
Rasmus Brandt5e4ef772018-07-09 14:39:35 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Sergey Silkinbe0adee2019-06-26 14:11:03 +020011#include <memory>
12
13#include "absl/memory/memory.h"
Steve Anton10542f22019-01-11 09:11:00 -080014#include "media/base/media_constants.h"
Eric Stevenson0d65fb52019-06-24 13:09:50 -040015#include "sdk/android/generated_native_unittests_jni/CodecsWrapperTestHelper_jni.h"
Sergey Silkinbe0adee2019-06-26 14:11:03 +020016#include "sdk/android/native_api/codecs/wrapper.h"
17#include "sdk/android/src/jni/video_encoder_wrapper.h"
Rasmus Brandt5e4ef772018-07-09 14:39:35 +020018#include "test/gtest.h"
19
20namespace webrtc {
21namespace test {
22namespace {
23TEST(JavaCodecsWrapperTest, JavaToNativeVideoCodecInfo) {
24 JNIEnv* env = AttachCurrentThreadIfNeeded();
25 ScopedJavaLocalRef<jobject> j_video_codec_info =
26 jni::Java_CodecsWrapperTestHelper_createTestVideoCodecInfo(env);
27
28 const SdpVideoFormat video_format =
29 JavaToNativeVideoCodecInfo(env, j_video_codec_info.obj());
30
31 EXPECT_EQ(cricket::kH264CodecName, video_format.name);
32 const auto it =
33 video_format.parameters.find(cricket::kH264FmtpProfileLevelId);
34 ASSERT_NE(it, video_format.parameters.end());
35 EXPECT_EQ(cricket::kH264ProfileLevelConstrainedBaseline, it->second);
36}
Sergey Silkinbe0adee2019-06-26 14:11:03 +020037
Sergey Silkin3d642f82019-07-03 15:09:33 +020038TEST(JavaCodecsWrapperTest, JavaToNativeResolutionBitrateLimits) {
Sergey Silkinbe0adee2019-06-26 14:11:03 +020039 JNIEnv* env = AttachCurrentThreadIfNeeded();
40 ScopedJavaLocalRef<jobject> j_fake_encoder =
41 jni::Java_CodecsWrapperTestHelper_createFakeVideoEncoder(env);
42
43 auto encoder = jni::JavaToNativeVideoEncoder(env, j_fake_encoder);
44 ASSERT_TRUE(encoder);
45
Sergey Silkin3d642f82019-07-03 15:09:33 +020046 // Check that the bitrate limits correctly passed from Java to native.
47 const std::vector<VideoEncoder::ResolutionBitrateLimits> bitrate_limits =
48 encoder->GetEncoderInfo().resolution_bitrate_limits;
49 ASSERT_EQ(bitrate_limits.size(), 1u);
50 EXPECT_EQ(bitrate_limits[0].frame_size_pixels, 640 * 360);
51 EXPECT_EQ(bitrate_limits[0].min_start_bitrate_bps, 300000);
52 EXPECT_EQ(bitrate_limits[0].min_bitrate_bps, 200000);
53 EXPECT_EQ(bitrate_limits[0].max_bitrate_bps, 1000000);
Sergey Silkinbe0adee2019-06-26 14:11:03 +020054}
Rasmus Brandt5e4ef772018-07-09 14:39:35 +020055} // namespace
56} // namespace test
57} // namespace webrtc