Skip to content

Commit

Permalink
[media] Rename SbMediaIs*Supported() functions
Browse files Browse the repository at this point in the history
`SbMediaIsAudioSupported()`, `SbMediaIsSupported()`, and
`SbMediaIsVideoSupported()` were never part of the Starboard interface.

Their Sb prefixes were removed and renamed to `MediaIsAudioSupported()`,
`MediaIsSupported()`, and `MediaIsVideoSupported()`.  They are also
moved from the global namespace into
::starboard::shared::starboard::media.

b/327287075
  • Loading branch information
xiaomings committed Jan 8, 2025
1 parent f1505ad commit e38ae20
Show file tree
Hide file tree
Showing 18 changed files with 253 additions and 147 deletions.
9 changes: 9 additions & 0 deletions starboard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ It was only used by win32 platforms
### Removed starboad/atomic.h support for C.
The existing code was migrated to C11 atomics.

### Renamed `SbMediaIs*Supported()` functions
`SbMediaIsAudioSupported()`, `SbMediaIsSupported()`, and
`SbMediaIsVideoSupported()` were never part of the Starboard interface.
Their Sb prefixes were removed and renamed to `MediaIsAudioSupported()`,
`MediaIsSupported()`, and `MediaIsVideoSupported()`. They are also moved from
the global namespace into ::starboard::shared::starboard::media. Future updates
to these functions will no longer be mentioned here as they are not part of the
Starboard interface.

## Version 16
A key update in Starboard version 16 is the adoption of POSIX APIs.
For a full overview of Starboard POSIX migrations, please refer to
Expand Down
21 changes: 15 additions & 6 deletions starboard/android/shared/media_is_audio_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
#include "starboard/configuration_constants.h"
#include "starboard/media.h"

using starboard::android::shared::MediaCapabilitiesCache;
using starboard::android::shared::SupportedAudioCodecToMimeType;
using starboard::shared::starboard::media::MimeType;
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
using ::starboard::android::shared::MediaCapabilitiesCache;
using ::starboard::android::shared::SupportedAudioCodecToMimeType;

bool MediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
if (bitrate >= kSbMediaMaxAudioBitrateInBitsPerSecond) {
return false;
}
Expand Down Expand Up @@ -80,3 +84,8 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
return MediaCapabilitiesCache::GetInstance()->IsPassthroughSupported(
audio_codec);
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
23 changes: 16 additions & 7 deletions starboard/android/shared/media_is_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
#include "starboard/media.h"
#include "starboard/shared/starboard/media/mime_type.h"

bool SbMediaIsSupported(SbMediaVideoCodec video_codec,
SbMediaAudioCodec audio_codec,
const char* key_system) {
using starboard::android::shared::IsWidevineL1;
using starboard::android::shared::IsWidevineL3;
using starboard::android::shared::MediaCapabilitiesCache;
using starboard::shared::starboard::media::MimeType;
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

bool MediaIsSupported(SbMediaVideoCodec video_codec,
SbMediaAudioCodec audio_codec,
const char* key_system) {
using ::starboard::android::shared::IsWidevineL1;
using ::starboard::android::shared::IsWidevineL3;
using ::starboard::android::shared::MediaCapabilitiesCache;

// It is possible that the |key_system| comes with extra attributes, like
// `com.widevine.alpha; encryptionscheme="cenc"`. We prepend "key_system/"
Expand Down Expand Up @@ -64,3 +68,8 @@ bool SbMediaIsSupported(SbMediaVideoCodec video_codec,

return true;
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
46 changes: 27 additions & 19 deletions starboard/android/shared/media_is_video_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,28 @@
#include "starboard/media.h"
#include "starboard/shared/starboard/media/media_util.h"

using starboard::android::shared::MaxMediaCodecOutputBuffersLookupTable;
using starboard::android::shared::MediaCapabilitiesCache;
using starboard::android::shared::SupportedVideoCodecToMimeType;
using starboard::shared::starboard::media::IsSDRVideo;
using starboard::shared::starboard::media::MimeType;

bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
const MimeType* mime_type,
int profile,
int level,
int bit_depth,
SbMediaPrimaryId primary_id,
SbMediaTransferId transfer_id,
SbMediaMatrixId matrix_id,
int frame_width,
int frame_height,
int64_t bitrate,
int fps,
bool decode_to_texture_required) {
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

using ::starboard::android::shared::MaxMediaCodecOutputBuffersLookupTable;
using ::starboard::android::shared::MediaCapabilitiesCache;
using ::starboard::android::shared::SupportedVideoCodecToMimeType;

bool MediaIsVideoSupported(SbMediaVideoCodec video_codec,
const MimeType* mime_type,
int profile,
int level,
int bit_depth,
SbMediaPrimaryId primary_id,
SbMediaTransferId transfer_id,
SbMediaMatrixId matrix_id,
int frame_width,
int frame_height,
int64_t bitrate,
int fps,
bool decode_to_texture_required) {
const bool must_support_hdr =
!IsSDRVideo(bit_depth, primary_id, transfer_id, matrix_id);
if (must_support_hdr &&
Expand Down Expand Up @@ -115,3 +118,8 @@ bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
mime, require_secure_playback, must_support_hdr, must_support_tunnel_mode,
frame_width, frame_height, bitrate, fps);
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
18 changes: 13 additions & 5 deletions starboard/linux/shared/media_is_audio_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
#include "starboard/configuration_constants.h"
#include "starboard/media.h"

using ::starboard::shared::starboard::media::MimeType;

bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

bool MediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
if (audio_codec == kSbMediaAudioCodecAac) {
return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
}
Expand Down Expand Up @@ -52,3 +55,8 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,

return false;
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
38 changes: 23 additions & 15 deletions starboard/linux/shared/media_is_video_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@
#include "starboard/shared/libde265/de265_library_loader.h"
#include "starboard/shared/starboard/media/media_util.h"

namespace starboard {
namespace shared {
namespace starboard {
namespace media {

using ::starboard::shared::de265::is_de265_supported;
using ::starboard::shared::starboard::media::IsSDRVideo;
using ::starboard::shared::starboard::media::MimeType;

bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
const MimeType* mime_type,
int profile,
int level,
int bit_depth,
SbMediaPrimaryId primary_id,
SbMediaTransferId transfer_id,
SbMediaMatrixId matrix_id,
int frame_width,
int frame_height,
int64_t bitrate,
int fps,
bool decode_to_texture_required) {
bool MediaIsVideoSupported(SbMediaVideoCodec video_codec,
const MimeType* mime_type,
int profile,
int level,
int bit_depth,
SbMediaPrimaryId primary_id,
SbMediaTransferId transfer_id,
SbMediaMatrixId matrix_id,
int frame_width,
int frame_height,
int64_t bitrate,
int fps,
bool decode_to_texture_required) {
if (!IsSDRVideo(bit_depth, primary_id, transfer_id, matrix_id)) {
if (bit_depth != 10 && bit_depth != 12) {
return false;
Expand Down Expand Up @@ -68,3 +71,8 @@ bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
frame_width <= 1920 && frame_height <= 1080 &&
bitrate <= kSbMediaMaxVideoBitrateInBitsPerSecond && fps <= 60;
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
37 changes: 22 additions & 15 deletions starboard/raspi/shared/media_is_video_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@
#include "starboard/media.h"
#include "starboard/shared/starboard/media/media_util.h"

using ::starboard::shared::starboard::media::IsSDRVideo;
using ::starboard::shared::starboard::media::MimeType;
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
const MimeType* mime_type,
int profile,
int level,
int bit_depth,
SbMediaPrimaryId primary_id,
SbMediaTransferId transfer_id,
SbMediaMatrixId matrix_id,
int frame_width,
int frame_height,
int64_t bitrate,
int fps,
bool decode_to_texture_required) {
bool MediaIsVideoSupported(SbMediaVideoCodec video_codec,
const MimeType* mime_type,
int profile,
int level,
int bit_depth,
SbMediaPrimaryId primary_id,
SbMediaTransferId transfer_id,
SbMediaMatrixId matrix_id,
int frame_width,
int frame_height,
int64_t bitrate,
int fps,
bool decode_to_texture_required) {
if (!IsSDRVideo(bit_depth, primary_id, transfer_id, matrix_id)) {
return false;
}
Expand All @@ -46,3 +48,8 @@ bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
frame_height <= 1080 &&
bitrate <= kSbMediaMaxVideoBitrateInBitsPerSecond && fps <= 30;
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
#include "starboard/configuration_constants.h"
#include "starboard/media.h"

using ::starboard::shared::starboard::media::MimeType;
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
bool MediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
if (audio_codec == kSbMediaAudioCodecAac) {
return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
}
Expand All @@ -33,3 +36,8 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,

return false;
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
#include "starboard/configuration_constants.h"
#include "starboard/media.h"

using ::starboard::shared::starboard::media::MimeType;
namespace starboard {
namespace shared {
namespace starboard {
namespace media {

bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
bool MediaIsAudioSupported(SbMediaAudioCodec audio_codec,
const MimeType* mime_type,
int64_t bitrate) {
return audio_codec == kSbMediaAudioCodecAac &&
bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
}

} // namespace media
} // namespace starboard
} // namespace shared
} // namespace starboard
Loading

0 comments on commit e38ae20

Please sign in to comment.