-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify style of Opus and AAC error code conversion utilities.
- Prefer `absl::string_view`. - Prefer returning `absl::Status` because the `StatusCode` was always being wrapped into one anyway. PiperOrigin-RevId: 643439926
- Loading branch information
Showing
5 changed files
with
46 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
#include "iamf/cli/codec/opus_utils.h" | ||
|
||
#include "absl/status/status.h" | ||
#include "absl/strings/str_cat.h" | ||
#include "absl/strings/string_view.h" | ||
#include "include/opus_defines.h" | ||
|
||
namespace iamf_tools { | ||
|
||
absl::StatusCode OpusErrorCodeToAbslStatusCode(int opus_error_code) { | ||
absl::Status OpusErrorCodeToAbslStatus(int opus_error_code, | ||
absl::string_view error_message) { | ||
absl::StatusCode status_code; | ||
switch (opus_error_code) { | ||
case OPUS_OK: | ||
return absl::StatusCode::kOk; | ||
return absl::OkStatus(); | ||
case OPUS_BAD_ARG: | ||
return absl::StatusCode::kInvalidArgument; | ||
status_code = absl::StatusCode::kInvalidArgument; | ||
break; | ||
case OPUS_BUFFER_TOO_SMALL: | ||
case OPUS_INVALID_STATE: | ||
return absl::StatusCode::kFailedPrecondition; | ||
status_code = absl::StatusCode::kFailedPrecondition; | ||
break; | ||
case OPUS_INTERNAL_ERROR: | ||
return absl::StatusCode::kInternal; | ||
status_code = absl::StatusCode::kInternal; | ||
break; | ||
case OPUS_INVALID_PACKET: | ||
return absl::StatusCode::kDataLoss; | ||
status_code = absl::StatusCode::kDataLoss; | ||
break; | ||
case OPUS_UNIMPLEMENTED: | ||
return absl::StatusCode::kUnimplemented; | ||
status_code = absl::StatusCode::kUnimplemented; | ||
break; | ||
case OPUS_ALLOC_FAIL: | ||
return absl::StatusCode::kResourceExhausted; | ||
status_code = absl::StatusCode::kResourceExhausted; | ||
break; | ||
default: | ||
return absl::StatusCode::kUnknown; | ||
status_code = absl::StatusCode::kUnknown; | ||
break; | ||
} | ||
return absl::Status( | ||
status_code, | ||
absl::StrCat(error_message, " opus_error_code= ", opus_error_code)); | ||
} | ||
|
||
} // namespace iamf_tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters