Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with HarmonyOS decoding failure scenarios. #2598

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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
23 changes: 19 additions & 4 deletions src/platform/ohos/OHOSVideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@
namespace pag {
#define NV12_PLANE_COUNT 2

void OH_AVCodecOnError(OH_AVCodec*, int32_t, void*) {
void OH_AVCodecOnError(OH_AVCodec*, int32_t index, void* userData) {
if (userData == nullptr) {
return;
}
LOGE("video decoder error, index:%d \n", index);
CodecUserData* codecUserData = static_cast<CodecUserData*>(userData);
std::unique_lock<std::mutex> lock(codecUserData->outputMutex);
codecUserData->outputBufferInfoQueue.emplace(index, nullptr);
codecUserData->outputCondition.notify_all();
}

void OH_AVCodecOnStreamChanged(OH_AVCodec*, OH_AVFormat*, void*) {
Expand Down Expand Up @@ -84,9 +92,13 @@ OHOSVideoDecoder::OHOSVideoDecoder(const VideoFormat& format, bool hardware) {

OHOSVideoDecoder::~OHOSVideoDecoder() {
if (codecCategory == SOFTWARE) {
if (yuvBuffer->data[0] != nullptr) {
delete[] yuvBuffer->data[0];
delete[] yuvBuffer->data[1];
if (yuvBuffer) {
if (yuvBuffer->data[0]) {
delete[] yuvBuffer->data[0];
}
if (yuvBuffer->data[1]) {
delete[] yuvBuffer->data[1];
}
}
}
if (videoCodec != nullptr) {
Expand Down Expand Up @@ -196,6 +208,9 @@ DecodingResult OHOSVideoDecoder::onDecodeFrame() {
codecUserData->outputBufferInfoQueue.pop();
lock.unlock();
pendingFrames.remove(codecBufferInfo.attr.pts);
if (codecBufferInfo.buffer == nullptr) {
return DecodingResult::Error;
}
} else {
lock.unlock();
return DecodingResult::Success;
Expand Down