зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1353944 - Update enums for mp4parse 0.8.0. r=kinetik
The support to namespace prefixing in moz-cheddar means we can simplify exported enum names on the rust side. However this makes for some spelling changes on the C side. MozReview-Commit-ID: 4t6NDusx0uI --HG-- extra : rebase_source : 1c1221507ce42965486d79e6809d1541f6410f55
This commit is contained in:
Родитель
3a9b45493a
Коммит
821d5fb522
|
@ -205,7 +205,7 @@ MP4AudioInfo::Update(const mp4parse_track_info* track,
|
||||||
{
|
{
|
||||||
UpdateTrackProtectedInfo(*this, audio->protected_data);
|
UpdateTrackProtectedInfo(*this, audio->protected_data);
|
||||||
|
|
||||||
if (track->codec == MP4PARSE_CODEC_OPUS) {
|
if (track->codec == mp4parse_codec_OPUS) {
|
||||||
mMimeType = NS_LITERAL_CSTRING("audio/opus");
|
mMimeType = NS_LITERAL_CSTRING("audio/opus");
|
||||||
// The Opus decoder expects the container's codec delay or
|
// The Opus decoder expects the container's codec delay or
|
||||||
// pre-skip value, in microseconds, as a 64-bit int at the
|
// pre-skip value, in microseconds, as a 64-bit int at the
|
||||||
|
@ -216,11 +216,11 @@ MP4AudioInfo::Update(const mp4parse_track_info* track,
|
||||||
LittleEndian::readUint16(audio->codec_specific_config.data + 10);
|
LittleEndian::readUint16(audio->codec_specific_config.data + 10);
|
||||||
OpusDataDecoder::AppendCodecDelay(mCodecSpecificConfig,
|
OpusDataDecoder::AppendCodecDelay(mCodecSpecificConfig,
|
||||||
mozilla::FramesToUsecs(preskip, 48000).value());
|
mozilla::FramesToUsecs(preskip, 48000).value());
|
||||||
} else if (track->codec == MP4PARSE_CODEC_AAC) {
|
} else if (track->codec == mp4parse_codec_AAC) {
|
||||||
mMimeType = MEDIA_MIMETYPE_AUDIO_AAC;
|
mMimeType = MEDIA_MIMETYPE_AUDIO_AAC;
|
||||||
} else if (track->codec == MP4PARSE_CODEC_FLAC) {
|
} else if (track->codec == mp4parse_codec_FLAC) {
|
||||||
mMimeType = MEDIA_MIMETYPE_AUDIO_FLAC;
|
mMimeType = MEDIA_MIMETYPE_AUDIO_FLAC;
|
||||||
} else if (track->codec == MP4PARSE_CODEC_MP3) {
|
} else if (track->codec == mp4parse_codec_MP3) {
|
||||||
mMimeType = MEDIA_MIMETYPE_AUDIO_MPEG;
|
mMimeType = MEDIA_MIMETYPE_AUDIO_MPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,9 +254,9 @@ MP4VideoInfo::Update(const mp4parse_track_info* track,
|
||||||
const mp4parse_track_video_info* video)
|
const mp4parse_track_video_info* video)
|
||||||
{
|
{
|
||||||
UpdateTrackProtectedInfo(*this, video->protected_data);
|
UpdateTrackProtectedInfo(*this, video->protected_data);
|
||||||
if (track->codec == MP4PARSE_CODEC_AVC) {
|
if (track->codec == mp4parse_codec_AVC) {
|
||||||
mMimeType = MEDIA_MIMETYPE_VIDEO_AVC;
|
mMimeType = MEDIA_MIMETYPE_VIDEO_AVC;
|
||||||
} else if (track->codec == MP4PARSE_CODEC_VP9) {
|
} else if (track->codec == mp4parse_codec_VP9) {
|
||||||
mMimeType = NS_LITERAL_CSTRING("video/vp9");
|
mMimeType = NS_LITERAL_CSTRING("video/vp9");
|
||||||
}
|
}
|
||||||
mTrackId = track->track_id;
|
mTrackId = track->track_id;
|
||||||
|
|
|
@ -735,11 +735,11 @@ MP4MetadataRust::MP4MetadataRust(Stream* aSource)
|
||||||
mp4parse_log(true);
|
mp4parse_log(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp4parse_error rv = mp4parse_read(mRustParser.get());
|
mp4parse_status rv = mp4parse_read(mRustParser.get());
|
||||||
MOZ_LOG(sLog, LogLevel::Debug, ("rust parser returned %d\n", rv));
|
MOZ_LOG(sLog, LogLevel::Debug, ("rust parser returned %d\n", rv));
|
||||||
Telemetry::Accumulate(Telemetry::MEDIA_RUST_MP4PARSE_SUCCESS,
|
Telemetry::Accumulate(Telemetry::MEDIA_RUST_MP4PARSE_SUCCESS,
|
||||||
rv == MP4PARSE_OK);
|
rv == mp4parse_status_OK);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
MOZ_ASSERT(rv > 0);
|
MOZ_ASSERT(rv > 0);
|
||||||
Telemetry::Accumulate(Telemetry::MEDIA_RUST_MP4PARSE_ERROR_CODE, rv);
|
Telemetry::Accumulate(Telemetry::MEDIA_RUST_MP4PARSE_ERROR_CODE, rv);
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ void
|
||||||
MP4MetadataRust::UpdateCrypto()
|
MP4MetadataRust::UpdateCrypto()
|
||||||
{
|
{
|
||||||
mp4parse_pssh_info info = {};
|
mp4parse_pssh_info info = {};
|
||||||
if (mp4parse_get_pssh_info(mRustParser.get(), &info) != MP4PARSE_OK) {
|
if (mp4parse_get_pssh_info(mRustParser.get(), &info) != mp4parse_status_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,9 +771,9 @@ TrackTypeEqual(TrackInfo::TrackType aLHS, mp4parse_track_type aRHS)
|
||||||
{
|
{
|
||||||
switch (aLHS) {
|
switch (aLHS) {
|
||||||
case TrackInfo::kAudioTrack:
|
case TrackInfo::kAudioTrack:
|
||||||
return aRHS == MP4PARSE_TRACK_TYPE_AUDIO;
|
return aRHS == mp4parse_track_type_AUDIO;
|
||||||
case TrackInfo::kVideoTrack:
|
case TrackInfo::kVideoTrack:
|
||||||
return aRHS == MP4PARSE_TRACK_TYPE_VIDEO;
|
return aRHS == mp4parse_track_type_VIDEO;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -784,7 +784,7 @@ MP4MetadataRust::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const
|
||||||
{
|
{
|
||||||
uint32_t tracks;
|
uint32_t tracks;
|
||||||
auto rv = mp4parse_get_track_count(mRustParser.get(), &tracks);
|
auto rv = mp4parse_get_track_count(mRustParser.get(), &tracks);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
MOZ_LOG(sLog, LogLevel::Warning,
|
MOZ_LOG(sLog, LogLevel::Warning,
|
||||||
("rust parser error %d counting tracks", rv));
|
("rust parser error %d counting tracks", rv));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -795,7 +795,7 @@ MP4MetadataRust::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const
|
||||||
for (uint32_t i = 0; i < tracks; ++i) {
|
for (uint32_t i = 0; i < tracks; ++i) {
|
||||||
mp4parse_track_info track_info;
|
mp4parse_track_info track_info;
|
||||||
rv = mp4parse_get_track_info(mRustParser.get(), i, &track_info);
|
rv = mp4parse_get_track_info(mRustParser.get(), i, &track_info);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (TrackTypeEqual(aType, track_info.track_type)) {
|
if (TrackTypeEqual(aType, track_info.track_type)) {
|
||||||
|
@ -811,7 +811,7 @@ MP4MetadataRust::TrackTypeToGlobalTrackIndex(mozilla::TrackInfo::TrackType aType
|
||||||
{
|
{
|
||||||
uint32_t tracks;
|
uint32_t tracks;
|
||||||
auto rv = mp4parse_get_track_count(mRustParser.get(), &tracks);
|
auto rv = mp4parse_get_track_count(mRustParser.get(), &tracks);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
return Nothing();
|
return Nothing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ MP4MetadataRust::TrackTypeToGlobalTrackIndex(mozilla::TrackInfo::TrackType aType
|
||||||
for (uint32_t i = 0; i < tracks; ++i) {
|
for (uint32_t i = 0; i < tracks; ++i) {
|
||||||
mp4parse_track_info track_info;
|
mp4parse_track_info track_info;
|
||||||
rv = mp4parse_get_track_info(mRustParser.get(), i, &track_info);
|
rv = mp4parse_get_track_info(mRustParser.get(), i, &track_info);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (TrackTypeEqual(aType, track_info.track_type)) {
|
if (TrackTypeEqual(aType, track_info.track_type)) {
|
||||||
|
@ -848,20 +848,20 @@ MP4MetadataRust::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
|
||||||
|
|
||||||
mp4parse_track_info info;
|
mp4parse_track_info info;
|
||||||
auto rv = mp4parse_get_track_info(mRustParser.get(), trackIndex.value(), &info);
|
auto rv = mp4parse_get_track_info(mRustParser.get(), trackIndex.value(), &info);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
MOZ_LOG(sLog, LogLevel::Warning, ("mp4parse_get_track_info returned %d", rv));
|
MOZ_LOG(sLog, LogLevel::Warning, ("mp4parse_get_track_info returned %d", rv));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const char* codec_string = "unrecognized";
|
const char* codec_string = "unrecognized";
|
||||||
switch (info.codec) {
|
switch (info.codec) {
|
||||||
case MP4PARSE_CODEC_UNKNOWN: codec_string = "unknown"; break;
|
case mp4parse_codec_UNKNOWN: codec_string = "unknown"; break;
|
||||||
case MP4PARSE_CODEC_AAC: codec_string = "aac"; break;
|
case mp4parse_codec_AAC: codec_string = "aac"; break;
|
||||||
case MP4PARSE_CODEC_OPUS: codec_string = "opus"; break;
|
case mp4parse_codec_OPUS: codec_string = "opus"; break;
|
||||||
case MP4PARSE_CODEC_FLAC: codec_string = "flac"; break;
|
case mp4parse_codec_FLAC: codec_string = "flac"; break;
|
||||||
case MP4PARSE_CODEC_AVC: codec_string = "h.264"; break;
|
case mp4parse_codec_AVC: codec_string = "h.264"; break;
|
||||||
case MP4PARSE_CODEC_VP9: codec_string = "vp9"; break;
|
case mp4parse_codec_VP9: codec_string = "vp9"; break;
|
||||||
case MP4PARSE_CODEC_MP3: codec_string = "mp3"; break;
|
case mp4parse_codec_MP3: codec_string = "mp3"; break;
|
||||||
}
|
}
|
||||||
MOZ_LOG(sLog, LogLevel::Debug, ("track codec %s (%u)\n",
|
MOZ_LOG(sLog, LogLevel::Debug, ("track codec %s (%u)\n",
|
||||||
codec_string, info.codec));
|
codec_string, info.codec));
|
||||||
|
@ -873,7 +873,7 @@ MP4MetadataRust::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
|
||||||
case TrackInfo::TrackType::kAudioTrack: {
|
case TrackInfo::TrackType::kAudioTrack: {
|
||||||
mp4parse_track_audio_info audio;
|
mp4parse_track_audio_info audio;
|
||||||
auto rv = mp4parse_get_track_audio_info(mRustParser.get(), trackIndex.value(), &audio);
|
auto rv = mp4parse_get_track_audio_info(mRustParser.get(), trackIndex.value(), &audio);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
MOZ_LOG(sLog, LogLevel::Warning, ("mp4parse_get_track_audio_info returned error %d", rv));
|
MOZ_LOG(sLog, LogLevel::Warning, ("mp4parse_get_track_audio_info returned error %d", rv));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -885,7 +885,7 @@ MP4MetadataRust::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
|
||||||
case TrackInfo::TrackType::kVideoTrack: {
|
case TrackInfo::TrackType::kVideoTrack: {
|
||||||
mp4parse_track_video_info video;
|
mp4parse_track_video_info video;
|
||||||
auto rv = mp4parse_get_track_video_info(mRustParser.get(), trackIndex.value(), &video);
|
auto rv = mp4parse_get_track_video_info(mRustParser.get(), trackIndex.value(), &video);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
MOZ_LOG(sLog, LogLevel::Warning, ("mp4parse_get_track_video_info returned error %d", rv));
|
MOZ_LOG(sLog, LogLevel::Warning, ("mp4parse_get_track_video_info returned error %d", rv));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -904,7 +904,7 @@ MP4MetadataRust::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
|
||||||
if (e && !e->mDuration) {
|
if (e && !e->mDuration) {
|
||||||
mp4parse_fragment_info info;
|
mp4parse_fragment_info info;
|
||||||
auto rv = mp4parse_get_fragment_info(mRustParser.get(), &info);
|
auto rv = mp4parse_get_fragment_info(mRustParser.get(), &info);
|
||||||
if (rv == MP4PARSE_OK) {
|
if (rv == mp4parse_status_OK) {
|
||||||
e->mDuration = info.fragment_duration;
|
e->mDuration = info.fragment_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,7 +935,7 @@ MP4MetadataRust::ReadTrackIndice(mp4parse_byte_data* aIndices, mozilla::TrackID
|
||||||
{
|
{
|
||||||
uint8_t fragmented = false;
|
uint8_t fragmented = false;
|
||||||
auto rv = mp4parse_is_fragmented(mRustParser.get(), aTrackID, &fragmented);
|
auto rv = mp4parse_is_fragmented(mRustParser.get(), aTrackID, &fragmented);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,7 +944,7 @@ MP4MetadataRust::ReadTrackIndice(mp4parse_byte_data* aIndices, mozilla::TrackID
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = mp4parse_get_indice_table(mRustParser.get(), aTrackID, aIndices);
|
rv = mp4parse_get_indice_table(mRustParser.get(), aTrackID, aIndices);
|
||||||
if (rv != MP4PARSE_OK) {
|
if (rv != mp4parse_status_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,12 @@ vector_reader(uint8_t* buffer, uintptr_t size, void* userdata)
|
||||||
|
|
||||||
TEST(rust, MP4MetadataEmpty)
|
TEST(rust, MP4MetadataEmpty)
|
||||||
{
|
{
|
||||||
mp4parse_error rv;
|
mp4parse_status rv;
|
||||||
mp4parse_io io;
|
mp4parse_io io;
|
||||||
|
|
||||||
// Shouldn't be able to read with no context.
|
// Shouldn't be able to read with no context.
|
||||||
rv = mp4parse_read(nullptr);
|
rv = mp4parse_read(nullptr);
|
||||||
EXPECT_EQ(rv, MP4PARSE_ERROR_BADARG);
|
EXPECT_EQ(rv, mp4parse_status_BAD_ARG);
|
||||||
|
|
||||||
// Shouldn't be able to wrap an mp4parse_io with null members.
|
// Shouldn't be able to wrap an mp4parse_io with null members.
|
||||||
io = { nullptr, nullptr };
|
io = { nullptr, nullptr };
|
||||||
|
@ -87,7 +87,7 @@ TEST(rust, MP4MetadataEmpty)
|
||||||
context = mp4parse_new(&io);
|
context = mp4parse_new(&io);
|
||||||
ASSERT_NE(context, nullptr);
|
ASSERT_NE(context, nullptr);
|
||||||
rv = mp4parse_read(context);
|
rv = mp4parse_read(context);
|
||||||
EXPECT_EQ(rv, MP4PARSE_ERROR_IO);
|
EXPECT_EQ(rv, mp4parse_status_IO);
|
||||||
mp4parse_free(context);
|
mp4parse_free(context);
|
||||||
|
|
||||||
// Short buffers should fail.
|
// Short buffers should fail.
|
||||||
|
@ -96,21 +96,21 @@ TEST(rust, MP4MetadataEmpty)
|
||||||
context = mp4parse_new(&io);
|
context = mp4parse_new(&io);
|
||||||
ASSERT_NE(context, nullptr);
|
ASSERT_NE(context, nullptr);
|
||||||
rv = mp4parse_read(context);
|
rv = mp4parse_read(context);
|
||||||
EXPECT_EQ(rv, MP4PARSE_ERROR_INVALID);
|
EXPECT_EQ(rv, mp4parse_status_INVALID);
|
||||||
mp4parse_free(context);
|
mp4parse_free(context);
|
||||||
|
|
||||||
buf.buffer.reserve(4097);
|
buf.buffer.reserve(4097);
|
||||||
context = mp4parse_new(&io);
|
context = mp4parse_new(&io);
|
||||||
ASSERT_NE(context, nullptr);
|
ASSERT_NE(context, nullptr);
|
||||||
rv = mp4parse_read(context);
|
rv = mp4parse_read(context);
|
||||||
EXPECT_EQ(rv, MP4PARSE_ERROR_INVALID);
|
EXPECT_EQ(rv, mp4parse_status_INVALID);
|
||||||
mp4parse_free(context);
|
mp4parse_free(context);
|
||||||
|
|
||||||
// Empty buffers should fail.
|
// Empty buffers should fail.
|
||||||
buf.buffer.resize(4097, 0);
|
buf.buffer.resize(4097, 0);
|
||||||
context = mp4parse_new(&io);
|
context = mp4parse_new(&io);
|
||||||
rv = mp4parse_read(context);
|
rv = mp4parse_read(context);
|
||||||
EXPECT_EQ(rv, MP4PARSE_ERROR_UNSUPPORTED);
|
EXPECT_EQ(rv, mp4parse_status_UNSUPPORTED);
|
||||||
mp4parse_free(context);
|
mp4parse_free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +130,12 @@ TEST(rust, MP4Metadata)
|
||||||
mp4parse_parser* context = mp4parse_new(&io);
|
mp4parse_parser* context = mp4parse_new(&io);
|
||||||
ASSERT_NE(nullptr, context);
|
ASSERT_NE(nullptr, context);
|
||||||
|
|
||||||
mp4parse_error rv = mp4parse_read(context);
|
mp4parse_status rv = mp4parse_read(context);
|
||||||
EXPECT_EQ(MP4PARSE_OK, rv);
|
EXPECT_EQ(mp4parse_status_OK, rv);
|
||||||
|
|
||||||
uint32_t tracks = 0;
|
uint32_t tracks = 0;
|
||||||
rv = mp4parse_get_track_count(context, &tracks);
|
rv = mp4parse_get_track_count(context, &tracks);
|
||||||
EXPECT_EQ(MP4PARSE_OK, rv);
|
EXPECT_EQ(mp4parse_status_OK, rv);
|
||||||
EXPECT_EQ(2U, tracks);
|
EXPECT_EQ(2U, tracks);
|
||||||
|
|
||||||
mp4parse_free(context);
|
mp4parse_free(context);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче