Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions starboard/android/shared/media_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include "starboard/android/shared/media_codec.h"

#include <android/api-level.h>

#include <memory>
#include <optional>
#include <string>
Comment thread
borongc marked this conversation as resolved.
Expand Down Expand Up @@ -55,7 +53,7 @@ bool CanUseNdkMediaCodec(
return false;
}
// NDK AMediaCodec requires API level >= 28.
if (android_get_device_api_level() < 28) {
if (GetDeviceApiLevel() < kAndroidApiLevelPie) {
return false;
}

Expand Down Expand Up @@ -172,7 +170,7 @@ NonNullResult<std::unique_ptr<MediaCodec>> MediaCodec::CreateVideoMediaCodec(

// static
bool MediaCodec::IsFrameRenderedCallbackEnabled() {
return android_get_device_api_level() >= 34;
return GetDeviceApiLevel() >= kAndroidApiLevelU;
}

FrameSize::FrameSize() : FrameSize(Size(), /*has_crop_values=*/false) {}
Expand Down
22 changes: 22 additions & 0 deletions starboard/android/shared/media_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#ifndef STARBOARD_ANDROID_SHARED_MEDIA_COMMON_H_
#define STARBOARD_ANDROID_SHARED_MEDIA_COMMON_H_

#include <android/api-level.h>
#include <sys/system_properties.h>

#include <cstdlib>
#include <cstring>
#include <optional>

Expand All @@ -26,6 +30,24 @@

namespace starboard {

constexpr int kAndroidApiLevelPie = 28;
constexpr int kAndroidApiLevelU = 34;

inline int GetDeviceApiLevel() {
#if __ANDROID_API__ >= 24
return ::android_get_device_api_level();
#else
static int api_level = []() {
char sdk_version_str[PROP_VALUE_MAX] = {0};
if (__system_property_get("ro.build.version.sdk", sdk_version_str) > 0) {
return atoi(sdk_version_str);
}
return __ANDROID_API__;
}();
return api_level;
#endif
}
Comment thread
borongc marked this conversation as resolved.

inline bool IsWidevineL1(const char* key_system) {
return strcmp(key_system, "com.widevine") == 0 ||
strcmp(key_system, "com.widevine.alpha") == 0;
Expand Down
Loading