blob: d5a29d1ad97030a383f21939ac134bcd90048ebc [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
38TEST(JavaCodecsWrapperTest, JavaToNativeResolutionBitrateThresholds) {
39 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
46 // Check that the resolution bitrate thresholds are correctly passed from Java
47 // to native.
48 const std::vector<VideoEncoder::ResolutionBitrateThresholds> thresholds =
49 encoder->GetEncoderInfo().resolution_bitrate_thresholds;
50 ASSERT_EQ(thresholds.size(), 1u);
51 EXPECT_EQ(thresholds[0].frame_size_pixels, 640 * 360);
52 EXPECT_EQ(thresholds[0].min_start_bitrate_bps, 300000);
53 EXPECT_EQ(thresholds[0].min_bitrate_bps, 200000);
54 EXPECT_EQ(thresholds[0].max_bitrate_bps, 1000000);
55}
Rasmus Brandt5e4ef772018-07-09 14:39:35 +020056} // namespace
57} // namespace test
58} // namespace webrtc