新增编码获取ParameterWithAttr接口

Signed-off-by: linziming <linziming2@huawei.com>
Change-Id: If81ac257e48e75a38c0f5e5e61b221dc5816a6c2
This commit is contained in:
linziming 2024-07-11 10:38:58 +00:00
parent b8f08d2a86
commit 110dfda607
27 changed files with 562 additions and 153 deletions

View File

@ -32,8 +32,8 @@ std::shared_ptr<AVCodecVideoEncoder> VideoEncoderFactory::CreateByMime(const std
int32_t ret = CreateByMime(mime, format, impl); int32_t ret = CreateByMime(mime, format, impl);
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK || impl != nullptr, nullptr, CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK || impl != nullptr, nullptr,
"AVCodec video encoder impl init failed, %{public}s", "AVCodec video encoder impl init failed, %{public}s",
AVCSErrorToString(static_cast<AVCodecServiceErrCode>(ret)).c_str()); AVCSErrorToString(static_cast<AVCodecServiceErrCode>(ret)).c_str());
return impl; return impl;
} }
@ -45,14 +45,14 @@ std::shared_ptr<AVCodecVideoEncoder> VideoEncoderFactory::CreateByName(const std
int32_t ret = CreateByName(name, format, impl); int32_t ret = CreateByName(name, format, impl);
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK || impl != nullptr, nullptr, CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK || impl != nullptr, nullptr,
"AVCodec video encoder impl init failed, %{public}s", "AVCodec video encoder impl init failed, %{public}s",
AVCSErrorToString(static_cast<AVCodecServiceErrCode>(ret)).c_str()); AVCSErrorToString(static_cast<AVCodecServiceErrCode>(ret)).c_str());
return impl; return impl;
} }
int32_t VideoEncoderFactory::CreateByMime(const std::string &mime, int32_t VideoEncoderFactory::CreateByMime(const std::string &mime, Format &format,
Format &format, std::shared_ptr<AVCodecVideoEncoder> &encoder) std::shared_ptr<AVCodecVideoEncoder> &encoder)
{ {
auto impl = std::make_shared<AVCodecVideoEncoderImpl>(); auto impl = std::make_shared<AVCodecVideoEncoderImpl>();
@ -64,8 +64,8 @@ int32_t VideoEncoderFactory::CreateByMime(const std::string &mime,
return AVCS_ERR_OK; return AVCS_ERR_OK;
} }
int32_t VideoEncoderFactory::CreateByName(const std::string &name, int32_t VideoEncoderFactory::CreateByName(const std::string &name, Format &format,
Format &format, std::shared_ptr<AVCodecVideoEncoder> &encoder) std::shared_ptr<AVCodecVideoEncoder> &encoder)
{ {
auto impl = std::make_shared<AVCodecVideoEncoderImpl>(); auto impl = std::make_shared<AVCodecVideoEncoderImpl>();
@ -247,6 +247,15 @@ int32_t AVCodecVideoEncoderImpl::SetCallback(const std::shared_ptr<MediaCodecPar
return codecClient_->SetCallback(callback); return codecClient_->SetCallback(callback);
} }
int32_t AVCodecVideoEncoderImpl::SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback)
{
CHECK_AND_RETURN_RET_LOG(codecClient_ != nullptr, AVCS_ERR_INVALID_OPERATION, "service died");
CHECK_AND_RETURN_RET_LOG(callback != nullptr, AVCS_ERR_INVALID_VAL, "callback is nullptr");
AVCODEC_SYNC_TRACE;
return codecClient_->SetCallback(callback);
}
int32_t AVCodecVideoEncoderImpl::GetInputFormat(Format &format) int32_t AVCodecVideoEncoderImpl::GetInputFormat(Format &format)
{ {
CHECK_AND_RETURN_RET_LOG(codecClient_ != nullptr, AVCS_ERR_INVALID_OPERATION, "Codec service is nullptr"); CHECK_AND_RETURN_RET_LOG(codecClient_ != nullptr, AVCS_ERR_INVALID_OPERATION, "Codec service is nullptr");

View File

@ -44,6 +44,7 @@ public:
int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback) override;
int32_t GetInputFormat(Format &format) override; int32_t GetInputFormat(Format &format) override;
int32_t Init(AVCodecType type, bool isMimeType, const std::string &name, Format &format); int32_t Init(AVCodecType type, bool isMimeType, const std::string &name, Format &format);

View File

@ -191,15 +191,30 @@ class MediaCodecParameterCallback {
public: public:
virtual ~MediaCodecParameterCallback() = default; virtual ~MediaCodecParameterCallback() = default;
/** /**
* Called when an error occurred. * Called when an input parameter becomes available.
* *
* @param index The index of the available input parmaeter. * @param index The index of the available input parameter.
* @param parameter A {@link Format} object for a input parmaeter index that contains the data. * @param parameter A {@link Format} object containing the corresponding index input parameter.
* @since 5.0 * @since 5.0
*/ */
virtual void OnInputParameterAvailable(uint32_t index, std::shared_ptr<Format> parameter) = 0; virtual void OnInputParameterAvailable(uint32_t index, std::shared_ptr<Format> parameter) = 0;
}; };
class MediaCodecParameterWithAttrCallback {
public:
virtual ~MediaCodecParameterWithAttrCallback() = default;
/**
* Called when an input parameter with attribute becomes available.
*
* @param index The index of the available input parameter.
* @param parameter A {@link Format} object containing the corresponding index input parameter.
* @param attribute A read only {@link Format} object containing the corresponding index input attribute.
* @since 5.0
*/
virtual void OnInputParameterWithAttrAvailable(uint32_t index, std::shared_ptr<Format> attribute,
std::shared_ptr<Format> parameter) = 0;
};
class SurfaceBufferExtratDataKey { class SurfaceBufferExtratDataKey {
public: public:
/** /**

View File

@ -222,6 +222,18 @@ public:
*/ */
virtual int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) = 0; virtual int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) = 0;
/**
* @brief Registers a encoder listener.
*
* This function must be called before {@link Configure}
*
* @param callback Indicates the decoder listener to register. For details, see {@link
* MediaCodecParameterWithAttrCallback}.
* @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
* @since 5.0
*/
virtual int32_t SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback) = 0;
/** /**
* @brief Gets the format of the input data that accepted by the video encoder. * @brief Gets the format of the input data that accepted by the video encoder.
* *

View File

@ -58,6 +58,7 @@ public:
virtual int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) = 0; virtual int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) = 0;
virtual int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) = 0; virtual int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) = 0;
virtual int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) = 0; virtual int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) = 0;
virtual int32_t SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback) = 0;
virtual int32_t GetInputFormat(Format &format) = 0; virtual int32_t GetInputFormat(Format &format) = 0;
virtual int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession, virtual int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession,
const bool svpFlag) const bool svpFlag)

View File

@ -114,11 +114,10 @@ int32_t CodecClient::Configure(const Format &format)
std::lock_guard<std::shared_mutex> lock(mutex_); std::lock_guard<std::shared_mutex> lock(mutex_);
CHECK_AND_RETURN_RET_LOG(codecProxy_ != nullptr, AVCS_ERR_NO_MEMORY, "Server not exist"); CHECK_AND_RETURN_RET_LOG(codecProxy_ != nullptr, AVCS_ERR_NO_MEMORY, "Server not exist");
Format format_ = format;
int32_t isSetParameterCb = (codecMode_ & CODEC_SET_PARAMETER_CALLBACK) != 0; int32_t isSetParameterCb = (codecMode_ & CODEC_SET_PARAMETER_CALLBACK) != 0;
format_.PutIntValue(Tag::VIDEO_ENCODER_ENABLE_SURFACE_INPUT_CALLBACK, isSetParameterCb); const_cast<Format &>(format).PutIntValue(Tag::VIDEO_ENCODER_ENABLE_SURFACE_INPUT_CALLBACK, isSetParameterCb);
int32_t ret = codecProxy_->Configure(format_); int32_t ret = codecProxy_->Configure(format);
EXPECT_AND_LOGI(ret == AVCS_ERR_OK, "Succeed"); EXPECT_AND_LOGI(ret == AVCS_ERR_OK, "Succeed");
if (!hasOnceConfigured_) { if (!hasOnceConfigured_) {
hasOnceConfigured_ = ret == AVCS_ERR_OK; hasOnceConfigured_ = ret == AVCS_ERR_OK;
@ -376,6 +375,8 @@ int32_t CodecClient::SetCallback(const std::shared_ptr<MediaCodecParameterCallba
CHECK_AND_RETURN_RET_LOG(callback != nullptr, AVCS_ERR_NO_MEMORY, "Callback is nullptr."); CHECK_AND_RETURN_RET_LOG(callback != nullptr, AVCS_ERR_NO_MEMORY, "Callback is nullptr.");
CHECK_AND_RETURN_RET_LOG(listenerStub_ != nullptr, AVCS_ERR_NO_MEMORY, "Listener stub is nullptr."); CHECK_AND_RETURN_RET_LOG(listenerStub_ != nullptr, AVCS_ERR_NO_MEMORY, "Listener stub is nullptr.");
CHECK_AND_RETURN_RET_LOG(!hasOnceConfigured_, AVCS_ERR_INVALID_STATE, "Need to configure encoder!"); CHECK_AND_RETURN_RET_LOG(!hasOnceConfigured_, AVCS_ERR_INVALID_STATE, "Need to configure encoder!");
CHECK_AND_RETURN_RET_LOG(paramWithAttrCallback_ == nullptr, AVCS_ERR_INVALID_STATE,
"Already set parameter with atrribute callback!");
codecMode_ |= CODEC_SET_PARAMETER_CALLBACK; codecMode_ |= CODEC_SET_PARAMETER_CALLBACK;
paramCallback_ = callback; paramCallback_ = callback;
@ -385,6 +386,22 @@ int32_t CodecClient::SetCallback(const std::shared_ptr<MediaCodecParameterCallba
return AVCS_ERR_OK; return AVCS_ERR_OK;
} }
int32_t CodecClient::SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback)
{
std::lock_guard<std::shared_mutex> lock(mutex_);
CHECK_AND_RETURN_RET_LOG(callback != nullptr, AVCS_ERR_NO_MEMORY, "Callback is nullptr.");
CHECK_AND_RETURN_RET_LOG(listenerStub_ != nullptr, AVCS_ERR_NO_MEMORY, "Listener stub is nullptr.");
CHECK_AND_RETURN_RET_LOG(!hasOnceConfigured_, AVCS_ERR_INVALID_STATE, "Need to configure encoder!");
CHECK_AND_RETURN_RET_LOG(paramCallback_ == nullptr, AVCS_ERR_INVALID_STATE, "Already set parameter callback!");
codecMode_ |= CODEC_SET_PARAMETER_CALLBACK;
paramWithAttrCallback_ = callback;
const std::shared_ptr<MediaCodecParameterWithAttrCallback> &stubCallback = shared_from_this();
listenerStub_->SetCallback(stubCallback);
AVCODEC_LOGI("Parameter callback");
return AVCS_ERR_OK;
}
int32_t CodecClient::GetInputFormat(Format &format) int32_t CodecClient::GetInputFormat(Format &format)
{ {
std::lock_guard<std::shared_mutex> lock(mutex_); std::lock_guard<std::shared_mutex> lock(mutex_);
@ -438,28 +455,40 @@ void CodecClient::OnOutputFormatChanged(const Format &format)
void CodecClient::OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVSharedMemory> buffer) void CodecClient::OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVSharedMemory> buffer)
{ {
AVCODEC_LOGD("index:%{public}u", index);
callback_->OnInputBufferAvailable(index, buffer); callback_->OnInputBufferAvailable(index, buffer);
} }
void CodecClient::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, void CodecClient::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag,
std::shared_ptr<AVSharedMemory> buffer) std::shared_ptr<AVSharedMemory> buffer)
{ {
AVCODEC_LOGD("index:%{public}u", index);
callback_->OnOutputBufferAvailable(index, info, flag, buffer); callback_->OnOutputBufferAvailable(index, info, flag, buffer);
} }
void CodecClient::OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) void CodecClient::OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer)
{ {
AVCODEC_LOGD("index:%{public}u", index);
videoCallback_->OnInputBufferAvailable(index, buffer); videoCallback_->OnInputBufferAvailable(index, buffer);
} }
void CodecClient::OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) void CodecClient::OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer)
{ {
AVCODEC_LOGD("index:%{public}u", index);
videoCallback_->OnOutputBufferAvailable(index, buffer); videoCallback_->OnOutputBufferAvailable(index, buffer);
} }
void CodecClient::OnInputParameterAvailable(uint32_t index, std::shared_ptr<Format> parameter) void CodecClient::OnInputParameterAvailable(uint32_t index, std::shared_ptr<Format> parameter)
{ {
AVCODEC_LOGD("index:%{public}u", index);
paramCallback_->OnInputParameterAvailable(index, parameter); paramCallback_->OnInputParameterAvailable(index, parameter);
} }
void CodecClient::OnInputParameterWithAttrAvailable(uint32_t index, std::shared_ptr<Format> attribute,
std::shared_ptr<Format> parameter)
{
AVCODEC_LOGD("index:%{public}u", index);
paramWithAttrCallback_->OnInputParameterWithAttrAvailable(index, attribute, parameter);
}
} // namespace MediaAVCodec } // namespace MediaAVCodec
} // namespace OHOS } // namespace OHOS

View File

@ -28,6 +28,7 @@ class CodecClientCallback;
class CodecClient : public MediaCodecCallback, class CodecClient : public MediaCodecCallback,
public AVCodecCallback, public AVCodecCallback,
public MediaCodecParameterCallback, public MediaCodecParameterCallback,
public MediaCodecParameterWithAttrCallback,
public ICodecService, public ICodecService,
public std::enable_shared_from_this<CodecClient> { public std::enable_shared_from_this<CodecClient> {
public: public:
@ -56,6 +57,7 @@ public:
int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback) override;
int32_t GetInputFormat(Format &format) override; int32_t GetInputFormat(Format &format) override;
#ifdef SUPPORT_DRM #ifdef SUPPORT_DRM
int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession, const bool svpFlag) override; int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession, const bool svpFlag) override;
@ -71,6 +73,8 @@ public:
void OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) override; void OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) override;
void OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) override; void OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) override;
void OnInputParameterAvailable(uint32_t index, std::shared_ptr<Format> parameter) override; void OnInputParameterAvailable(uint32_t index, std::shared_ptr<Format> parameter) override;
void OnInputParameterWithAttrAvailable(uint32_t index, std::shared_ptr<Format> attribute,
std::shared_ptr<Format> parameter) override;
private: private:
int32_t CreateListenerObject(); int32_t CreateListenerObject();
@ -97,6 +101,7 @@ private:
std::shared_ptr<AVCodecCallback> callback_ = nullptr; std::shared_ptr<AVCodecCallback> callback_ = nullptr;
std::shared_ptr<MediaCodecCallback> videoCallback_ = nullptr; std::shared_ptr<MediaCodecCallback> videoCallback_ = nullptr;
std::shared_ptr<MediaCodecParameterCallback> paramCallback_ = nullptr; std::shared_ptr<MediaCodecParameterCallback> paramCallback_ = nullptr;
std::shared_ptr<MediaCodecParameterWithAttrCallback> paramWithAttrCallback_ = nullptr;
std::shared_ptr<BufferConverter> converter_ = nullptr; std::shared_ptr<BufferConverter> converter_ = nullptr;
std::shared_mutex mutex_; std::shared_mutex mutex_;

View File

@ -15,6 +15,7 @@
#include "codec_listener_stub.h" #include "codec_listener_stub.h"
#include <shared_mutex> #include <shared_mutex>
#include <sstream>
#include <string> #include <string>
#include "avcodec_errors.h" #include "avcodec_errors.h"
#include "avcodec_log.h" #include "avcodec_log.h"
@ -36,16 +37,24 @@ const std::map<OHOS::Media::MemoryType, std::string> MEMORYTYPE_MAP = {
namespace OHOS { namespace OHOS {
namespace MediaAVCodec { namespace MediaAVCodec {
using namespace Media; using namespace Media;
typedef enum : uint8_t {
OWNED_BY_SERVER = 0,
OWNED_BY_USER = 1,
} BufferOwner;
typedef struct BufferElem { typedef struct BufferElem {
std::shared_ptr<AVSharedMemory> memory = nullptr; std::shared_ptr<AVSharedMemory> memory = nullptr;
std::shared_ptr<AVBuffer> buffer = nullptr; std::shared_ptr<AVBuffer> buffer = nullptr;
std::shared_ptr<Format> format = nullptr; std::shared_ptr<Format> parameter = nullptr;
std::shared_ptr<Format> attribute = nullptr;
BufferOwner owner = OWNED_BY_SERVER;
} BufferElem; } BufferElem;
typedef enum : uint8_t { typedef enum : uint8_t {
ELEM_GET_AVBUFFER, ELEM_GET_AVBUFFER,
ELEM_GET_AVMEMORY, ELEM_GET_AVMEMORY,
ELEM_GET_AVFORMAT, ELEM_GET_PARAMETER,
ELEM_GET_ATRRIBUTE,
} UpdateFilter; } UpdateFilter;
class CodecListenerStub::CodecBufferCache : public NoCopyable { class CodecListenerStub::CodecBufferCache : public NoCopyable {
@ -64,12 +73,14 @@ public:
AVCODEC_LOGE("Mark hit cache, but can find the index's cache, index: %{public}u", index); AVCODEC_LOGE("Mark hit cache, but can find the index's cache, index: %{public}u", index);
return; return;
} }
iter->second.owner = OWNED_BY_USER;
isOutput_ ? HitOutputCache(iter->second, parcel, filter) : HitInputCache(iter->second, parcel, filter);
elem = iter->second; elem = iter->second;
HitFunction(elem, parcel, filter);
return; return;
} }
if (flag_ == CacheFlag::UPDATE_CACHE) { if (flag_ == CacheFlag::UPDATE_CACHE) {
UpdateFunction(elem, parcel, filter); elem.owner = OWNED_BY_USER;
isOutput_ ? UpdateOutputCache(elem, parcel, filter) : UpdateInputCache(elem, parcel, filter);
if (iter == caches_.end()) { if (iter == caches_.end()) {
PrintLogOnUpdateBuffer(index); PrintLogOnUpdateBuffer(index);
caches_.emplace(index, elem); caches_.emplace(index, elem);
@ -95,12 +106,16 @@ public:
AVCODEC_LOGE("Get cache failed, index: %{public}u", index); AVCODEC_LOGE("Get cache failed, index: %{public}u", index);
return; return;
} }
iter->second.owner = OWNED_BY_SERVER;
elem = iter->second; elem = iter->second;
EXPECT_AND_LOGD(elem.buffer != nullptr, "%{public}s. index=%{public}d, flag=%{public}u, pts=%{public}" PRId64,
(isOutput_ ? "free output" : "push input"), index, elem.buffer->flag_, elem.buffer->pts_);
} }
void ClearCaches() void ClearCaches()
{ {
std::lock_guard<std::shared_mutex> lock(mutex_); std::lock_guard<std::shared_mutex> lock(mutex_);
PrintCachesInfo();
caches_.clear(); caches_.clear();
} }
@ -128,12 +143,36 @@ public:
inline void PrintLogOnUpdateBuffer(const uint32_t &index) inline void PrintLogOnUpdateBuffer(const uint32_t &index)
{ {
if (caches_.size() <= 1) { if (caches_.size() <= 1) {
AVCODEC_LOGI("index: %{public}u, isOutput: %{public}d", index, isOutput_); AVCODEC_LOGI("add caches. index: %{public}u, isOutput: %{public}d", index, isOutput_);
} else { } else {
AVCODEC_LOGD("index: %{public}u, isOutput: %{public}d", index, isOutput_); AVCODEC_LOGD("add caches. index: %{public}u, isOutput: %{public}d", index, isOutput_);
} }
} }
void PrintCachesInfo()
{
std::stringstream serverCaches;
std::stringstream userCaches;
serverCaches << "server(";
userCaches << "user(";
for (auto &val : caches_) {
switch (val.second.owner) {
case OWNED_BY_SERVER:
serverCaches << val.first << " ";
break;
case OWNED_BY_USER:
userCaches << val.first << " ";
break;
default:
break;
}
}
serverCaches << ")";
userCaches << ")";
AVCODEC_LOGI("%{public}s caches: %{public}s, %{public}s", (isOutput_ ? "out" : "in"), userCaches.str().c_str(),
serverCaches.str().c_str());
}
private: private:
void AVBufferToAVSharedMemory(const std::shared_ptr<AVBuffer> &buffer, std::shared_ptr<AVSharedMemory> &memory) void AVBufferToAVSharedMemory(const std::shared_ptr<AVBuffer> &buffer, std::shared_ptr<AVSharedMemory> &memory)
{ {
@ -157,43 +196,71 @@ private:
} }
} }
void ReadOutputMemory(std::shared_ptr<AVBuffer> &buffer, std::shared_ptr<AVSharedMemory> &memory) void HitInputCache(BufferElem &elem, MessageParcel &parcel, const UpdateFilter &filter)
{ {
if (converter_ != nullptr) { if (filter == ELEM_GET_AVMEMORY) {
converter_->ReadFromBuffer(buffer, memory); return;
}
bool isReadSuc = elem.buffer->ReadFromMessageParcel(parcel);
CHECK_AND_RETURN_LOG(isReadSuc, "Read input buffer from parcel failed");
elem.buffer->flag_ = 0;
if (elem.buffer->memory_ != nullptr) {
elem.buffer->memory_->SetOffset(0);
elem.buffer->memory_->SetSize(0);
}
if (filter == ELEM_GET_ATRRIBUTE) {
elem.attribute->PutLongValue(Media::Tag::MEDIA_TIME_STAMP, elem.buffer->pts_);
return;
}
if (filter == ELEM_GET_PARAMETER) {
return;
}
elem.buffer->pts_ = 0;
}
void HitOutputCache(BufferElem &elem, MessageParcel &parcel, const UpdateFilter &filter)
{
bool isReadSuc = elem.buffer->ReadFromMessageParcel(parcel);
CHECK_AND_RETURN_LOG(isReadSuc, "Read output buffer from parcel failed");
if (filter == ELEM_GET_AVMEMORY && converter_ != nullptr) {
converter_->ReadFromBuffer(elem.buffer, elem.memory);
} }
} }
void HitFunction(BufferElem &elem, MessageParcel &parcel, const UpdateFilter &filter) void UpdateInputCache(BufferElem &elem, MessageParcel &parcel, const UpdateFilter &filter)
{ {
if (!isOutput_ && (filter == ELEM_GET_AVFORMAT || filter == ELEM_GET_AVBUFFER)) { elem.buffer = AVBuffer::CreateAVBuffer();
bool isReadSuc = elem.buffer->ReadFromMessageParcel(parcel); bool isReadSuc = (elem.buffer != nullptr) && elem.buffer->ReadFromMessageParcel(parcel);
CHECK_AND_RETURN_LOG(isReadSuc, "Read buffer from parcel failed"); CHECK_AND_RETURN_LOG(isReadSuc, "Create input buffer from parcel failed");
} else if (isOutput_) { if (filter == ELEM_GET_PARAMETER) {
bool isReadSuc = elem.buffer->ReadFromMessageParcel(parcel); elem.parameter = std::make_shared<Format>();
CHECK_AND_RETURN_LOG(isReadSuc, "Read buffer from parcel failed"); elem.parameter->SetMeta(std::move(elem.buffer->meta_));
if (filter == ELEM_GET_AVMEMORY) { elem.buffer->meta_ = elem.parameter->GetMeta();
ReadOutputMemory(elem.buffer, elem.memory); } else if (filter == ELEM_GET_ATRRIBUTE) {
elem.parameter = std::make_shared<Format>();
elem.parameter->SetMeta(std::move(elem.buffer->meta_));
elem.buffer->meta_ = elem.parameter->GetMeta();
elem.attribute = std::make_shared<Format>();
elem.attribute->PutLongValue(Media::Tag::MEDIA_TIME_STAMP, elem.buffer->pts_);
} else if (filter == ELEM_GET_AVMEMORY) {
AVBufferToAVSharedMemory(elem.buffer, elem.memory);
if (converter_ != nullptr) {
converter_->SetInputBufferFormat(elem.buffer);
} }
} }
} }
void UpdateFunction(BufferElem &elem, MessageParcel &parcel, const UpdateFilter &filter) void UpdateOutputCache(BufferElem &elem, MessageParcel &parcel, const UpdateFilter &filter)
{ {
elem.buffer = AVBuffer::CreateAVBuffer(); elem.buffer = AVBuffer::CreateAVBuffer();
bool isReadSuc = (elem.buffer != nullptr) && elem.buffer->ReadFromMessageParcel(parcel); bool isReadSuc = (elem.buffer != nullptr) && elem.buffer->ReadFromMessageParcel(parcel);
CHECK_AND_RETURN_LOG(isReadSuc, "Create buffer from parcel failed"); CHECK_AND_RETURN_LOG(isReadSuc, "Create output buffer from parcel failed");
if (!isOutput_ && filter == ELEM_GET_AVFORMAT) { if (filter == ELEM_GET_AVMEMORY) {
elem.format = std::make_shared<Format>();
elem.format->SetMeta(std::move(elem.buffer->meta_));
elem.buffer->meta_ = elem.format->GetMeta();
} else if (filter == ELEM_GET_AVMEMORY) {
AVBufferToAVSharedMemory(elem.buffer, elem.memory); AVBufferToAVSharedMemory(elem.buffer, elem.memory);
if (isOutput_) { if (converter_ != nullptr) {
converter_->SetOutputBufferFormat(elem.buffer); converter_->SetOutputBufferFormat(elem.buffer);
ReadOutputMemory(elem.buffer, elem.memory); converter_->ReadFromBuffer(elem.buffer, elem.memory);
} else {
converter_->SetInputBufferFormat(elem.buffer);
} }
} }
} }
@ -277,22 +344,28 @@ int CodecListenerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa
void CodecListenerStub::OnError(AVCodecErrorType errorType, int32_t errorCode) void CodecListenerStub::OnError(AVCodecErrorType errorType, int32_t errorCode)
{ {
std::shared_ptr<MediaCodecCallback> vCb = videoCallback_.lock(); std::shared_ptr<MediaCodecCallback> vCb = videoCallback_.lock();
std::shared_ptr<AVCodecCallback> cb = callback_.lock();
if (vCb != nullptr) { if (vCb != nullptr) {
vCb->OnError(errorType, errorCode); vCb->OnError(errorType, errorCode);
} else if (cb != nullptr) { return;
}
std::shared_ptr<AVCodecCallback> cb = callback_.lock();
if (cb != nullptr) {
cb->OnError(errorType, errorCode); cb->OnError(errorType, errorCode);
return;
} }
} }
void CodecListenerStub::OnOutputFormatChanged(const Format &format) void CodecListenerStub::OnOutputFormatChanged(const Format &format)
{ {
std::shared_ptr<MediaCodecCallback> vCb = videoCallback_.lock(); std::shared_ptr<MediaCodecCallback> vCb = videoCallback_.lock();
std::shared_ptr<AVCodecCallback> cb = callback_.lock();
if (vCb != nullptr) { if (vCb != nullptr) {
vCb->OnOutputFormatChanged(format); vCb->OnOutputFormatChanged(format);
} else if (cb != nullptr) { return;
}
std::shared_ptr<AVCodecCallback> cb = callback_.lock();
if (cb != nullptr) {
cb->OnOutputFormatChanged(format); cb->OnOutputFormatChanged(format);
return;
} }
} }
@ -311,36 +384,47 @@ void CodecListenerStub::OnOutputBufferAvailable(uint32_t index, std::shared_ptr<
void CodecListenerStub::OnInputBufferAvailable(uint32_t index, MessageParcel &data) void CodecListenerStub::OnInputBufferAvailable(uint32_t index, MessageParcel &data)
{ {
BufferElem elem; BufferElem elem;
std::shared_ptr<MediaCodecParameterCallback> pCb = paramCallback_.lock(); std::shared_ptr<MediaCodecParameterCallback> paramCb = paramCallback_.lock();
if (pCb != nullptr) { if (paramCb != nullptr) {
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVFORMAT); inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_PARAMETER);
pCb->OnInputParameterAvailable(index, elem.format); paramCb->OnInputParameterAvailable(index, elem.parameter);
elem.buffer->meta_ = elem.format->GetMeta(); elem.buffer->meta_ = elem.parameter->GetMeta();
return;
}
std::shared_ptr<MediaCodecParameterWithAttrCallback> attrCb = paramWithAttrCallback_.lock();
if (attrCb != nullptr) {
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_ATRRIBUTE);
attrCb->OnInputParameterWithAttrAvailable(index, elem.attribute, elem.parameter);
elem.buffer->meta_ = elem.parameter->GetMeta();
return;
}
std::shared_ptr<MediaCodecCallback> mediaCb = videoCallback_.lock();
if (mediaCb != nullptr) {
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVBUFFER);
mediaCb->OnInputBufferAvailable(index, elem.buffer);
return; return;
} }
std::shared_ptr<MediaCodecCallback> vCb = videoCallback_.lock();
std::shared_ptr<AVCodecCallback> cb = callback_.lock(); std::shared_ptr<AVCodecCallback> cb = callback_.lock();
if (vCb != nullptr) { if (cb != nullptr) {
inputBufferCache_->ReadFromParcel(index, data, elem);
vCb->OnInputBufferAvailable(index, elem.buffer);
} else if (cb != nullptr) {
inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY); inputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY);
cb->OnInputBufferAvailable(index, elem.memory); cb->OnInputBufferAvailable(index, elem.memory);
return;
} }
} }
void CodecListenerStub::OnOutputBufferAvailable(uint32_t index, MessageParcel &data) void CodecListenerStub::OnOutputBufferAvailable(uint32_t index, MessageParcel &data)
{ {
BufferElem elem; BufferElem elem;
std::shared_ptr<MediaCodecCallback> vCb = videoCallback_.lock(); std::shared_ptr<MediaCodecCallback> mediaCb = videoCallback_.lock();
if (mediaCb != nullptr) {
outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVBUFFER);
mediaCb->OnOutputBufferAvailable(index, elem.buffer);
return;
}
std::shared_ptr<AVCodecCallback> cb = callback_.lock(); std::shared_ptr<AVCodecCallback> cb = callback_.lock();
if (vCb != nullptr) { if (cb != nullptr) {
outputBufferCache_->ReadFromParcel(index, data, elem);
vCb->OnOutputBufferAvailable(index, elem.buffer);
} else if (cb != nullptr) {
outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY); outputBufferCache_->ReadFromParcel(index, data, elem, ELEM_GET_AVMEMORY);
std::shared_ptr<AVBuffer> &buffer = elem.buffer; std::shared_ptr<AVBuffer> &buffer = elem.buffer;
AVCodecBufferInfo info; AVCodecBufferInfo info;
info.presentationTimeUs = buffer->pts_; info.presentationTimeUs = buffer->pts_;
AVCodecBufferFlag flag = static_cast<AVCodecBufferFlag>(buffer->flag_); AVCodecBufferFlag flag = static_cast<AVCodecBufferFlag>(buffer->flag_);
@ -349,6 +433,7 @@ void CodecListenerStub::OnOutputBufferAvailable(uint32_t index, MessageParcel &d
info.size = buffer->memory_->GetSize(); info.size = buffer->memory_->GetSize();
} }
cb->OnOutputBufferAvailable(index, info, flag, elem.memory); cb->OnOutputBufferAvailable(index, info, flag, elem.memory);
return;
} }
} }
@ -367,6 +452,11 @@ void CodecListenerStub::SetCallback(const std::shared_ptr<MediaCodecParameterCal
paramCallback_ = callback; paramCallback_ = callback;
} }
void CodecListenerStub::SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback)
{
paramWithAttrCallback_ = callback;
}
void CodecListenerStub::ClearListenerCache() void CodecListenerStub::ClearListenerCache()
{ {
inputBufferCache_->ClearCaches(); inputBufferCache_->ClearCaches();
@ -411,9 +501,21 @@ bool CodecListenerStub::WriteInputParameterToParcel(uint32_t index, MessageParce
{ {
BufferElem elem; BufferElem elem;
inputBufferCache_->GetBufferElem(index, elem); inputBufferCache_->GetBufferElem(index, elem);
CHECK_AND_RETURN_RET_LOG(elem.format != nullptr, false, "Get format is nullptr"); auto &param = elem.parameter;
CHECK_AND_RETURN_RET_LOG(elem.buffer != nullptr, false, "Get buffer is nullptr");
CHECK_AND_RETURN_RET_LOG(param != nullptr, false, "Get format is nullptr");
EXPECT_AND_LOGI(!(param->GetMeta()->Empty()), "index:%{public}u,pts:%{public}" PRId64 ",paramter:%{public}s", index,
elem.buffer->pts_, param->Stringify().c_str());
return elem.format->GetMeta()->ToParcel(data); return param->GetMeta()->ToParcel(data);
}
bool CodecListenerStub::WriteOutputBufferToParcel(uint32_t index, MessageParcel &data)
{
(void)data;
BufferElem elem;
outputBufferCache_->GetBufferElem(index, elem);
return true;
} }
bool CodecListenerStub::CheckGeneration(uint64_t messageGeneration) const bool CodecListenerStub::CheckGeneration(uint64_t messageGeneration) const

View File

@ -40,11 +40,13 @@ public:
void SetCallback(const std::shared_ptr<AVCodecCallback> &callback); void SetCallback(const std::shared_ptr<AVCodecCallback> &callback);
void SetCallback(const std::shared_ptr<MediaCodecCallback> &callback); void SetCallback(const std::shared_ptr<MediaCodecCallback> &callback);
void SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback); void SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback);
void SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback);
void ClearListenerCache(); void ClearListenerCache();
bool WriteInputParameterToParcel(uint32_t index, MessageParcel &data); bool WriteInputParameterToParcel(uint32_t index, MessageParcel &data);
bool WriteInputBufferToParcel(uint32_t index, MessageParcel &data); bool WriteInputBufferToParcel(uint32_t index, MessageParcel &data);
bool WriteInputMemoryToParcel(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, MessageParcel &data); bool WriteInputMemoryToParcel(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, MessageParcel &data);
bool WriteOutputBufferToParcel(uint32_t index, MessageParcel &data);
void SetMutex(std::shared_ptr<std::recursive_mutex> &mutex); void SetMutex(std::shared_ptr<std::recursive_mutex> &mutex);
void SetConverter(std::shared_ptr<BufferConverter> &converter); void SetConverter(std::shared_ptr<BufferConverter> &converter);
@ -61,6 +63,7 @@ private:
std::weak_ptr<AVCodecCallback> callback_; std::weak_ptr<AVCodecCallback> callback_;
std::weak_ptr<MediaCodecCallback> videoCallback_; std::weak_ptr<MediaCodecCallback> videoCallback_;
std::weak_ptr<MediaCodecParameterCallback> paramCallback_; std::weak_ptr<MediaCodecParameterCallback> paramCallback_;
std::weak_ptr<MediaCodecParameterWithAttrCallback> paramWithAttrCallback_;
bool needListen_ = false; bool needListen_ = false;
std::shared_ptr<std::recursive_mutex> syncMutex_; std::shared_ptr<std::recursive_mutex> syncMutex_;
std::shared_ptr<BufferConverter> converter_ = nullptr; std::shared_ptr<BufferConverter> converter_ = nullptr;

View File

@ -334,6 +334,7 @@ int32_t CodecServiceProxy::ReleaseOutputBuffer(uint32_t index, bool render)
data.WriteUint32(index); data.WriteUint32(index);
data.WriteBool(render); data.WriteBool(render);
static_cast<CodecListenerStub *>(listener_.GetRefPtr())->WriteOutputBufferToParcel(index, data);
int32_t ret = Remote()->SendRequest(static_cast<uint32_t>(CodecServiceInterfaceCode::RELEASE_OUTPUT_BUFFER), data, int32_t ret = Remote()->SendRequest(static_cast<uint32_t>(CodecServiceInterfaceCode::RELEASE_OUTPUT_BUFFER), data,
reply, option); reply, option);
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, "Send request failed"); CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, "Send request failed");

View File

@ -615,6 +615,12 @@ int32_t CodecServer::SetCallback(const std::shared_ptr<MediaCodecParameterCallba
return AVCS_ERR_UNSUPPORT; return AVCS_ERR_UNSUPPORT;
} }
int32_t CodecServer::SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback)
{
(void)callback;
return AVCS_ERR_UNSUPPORT;
}
int32_t CodecServer::GetInputFormat(Format &format) int32_t CodecServer::GetInputFormat(Format &format)
{ {
std::lock_guard<std::shared_mutex> lock(mutex_); std::lock_guard<std::shared_mutex> lock(mutex_);
@ -792,7 +798,6 @@ void CodecServer::OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffe
void CodecServer::OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) void CodecServer::OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer)
{ {
AVCODEC_LOGD("on output buffer index: %{public}d", index);
CHECK_AND_RETURN_LOG(buffer != nullptr, "buffer is nullptr!"); CHECK_AND_RETURN_LOG(buffer != nullptr, "buffer is nullptr!");
if (((codecType_ == AVCODEC_TYPE_VIDEO_ENCODER) || (codecType_ == AVCODEC_TYPE_VIDEO_DECODER)) && if (((codecType_ == AVCODEC_TYPE_VIDEO_ENCODER) || (codecType_ == AVCODEC_TYPE_VIDEO_DECODER)) &&

View File

@ -72,6 +72,7 @@ public:
int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) override; int32_t SetCallback(const std::shared_ptr<MediaCodecParameterCallback> &callback) override;
int32_t SetCallback(const std::shared_ptr<MediaCodecParameterWithAttrCallback> &callback) override;
int32_t GetInputFormat(Format &format) override; int32_t GetInputFormat(Format &format) override;
#ifdef SUPPORT_DRM #ifdef SUPPORT_DRM
int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession, int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession,

View File

@ -35,8 +35,11 @@ vcodec_unittest_cflags = [
"-Wextra", "-Wextra",
"-Wimplicit-fallthrough", "-Wimplicit-fallthrough",
"-Wsign-compare", "-Wsign-compare",
"-Wno-constant-conversion",
"-Wno-unused-function", "-Wno-unused-function",
"-Wno-unused-parameter", "-Wno-unused-parameter",
"-Dprivate=public",
"-Dprotected=public",
] ]
group("vcodec_framework_test") { group("vcodec_framework_test") {
@ -97,9 +100,11 @@ ohos_unittest("videodec_capi_unit_test") {
external_deps = [ external_deps = [
"c_utils:utils", "c_utils:utils",
"graphic_2d:librender_service_client",
"graphic_surface:surface", "graphic_surface:surface",
"graphic_surface:sync_fence", "graphic_surface:sync_fence",
"hilog:libhilog", "hilog:libhilog",
"window_manager:libwm",
] ]
if (av_codec_support_drm) { if (av_codec_support_drm) {
@ -146,6 +151,7 @@ ohos_unittest("videodec_inner_unit_test") {
external_deps = [ external_deps = [
"c_utils:utils", "c_utils:utils",
"drm_framework:drm_framework", "drm_framework:drm_framework",
"graphic_2d:librender_service_client",
"graphic_surface:surface", "graphic_surface:surface",
"graphic_surface:sync_fence", "graphic_surface:sync_fence",
"hilog:libhilog", "hilog:libhilog",
@ -274,9 +280,11 @@ ohos_unittest("videodec_hevcdec_unit_test") {
external_deps = [ external_deps = [
"c_utils:utils", "c_utils:utils",
"graphic_2d:librender_service_client",
"graphic_surface:surface", "graphic_surface:surface",
"graphic_surface:sync_fence", "graphic_surface:sync_fence",
"hilog:libhilog", "hilog:libhilog",
"window_manager:libwm",
] ]
resource_config_file = resource_config_file =
@ -308,9 +316,11 @@ ohos_unittest("videodec_stable_unit_test") {
external_deps = [ external_deps = [
"c_utils:utils", "c_utils:utils",
"graphic_2d:librender_service_client",
"graphic_surface:surface", "graphic_surface:surface",
"graphic_surface:sync_fence", "graphic_surface:sync_fence",
"hilog:libhilog", "hilog:libhilog",
"window_manager:libwm",
] ]
resource_config_file = resource_config_file =

View File

@ -206,6 +206,12 @@ int32_t VideoEncCapiMock::SetCallback(std::shared_ptr<MediaCodecParameterCallbac
return OH_VideoEncoder_RegisterParameterCallback(codec_, callback, NULL); return OH_VideoEncoder_RegisterParameterCallback(codec_, callback, NULL);
} }
int32_t VideoEncCapiMock::SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb)
{
(void)cb;
return AV_ERR_UNSUPPORT;
}
int32_t VideoEncCapiMock::Configure(std::shared_ptr<FormatMock> format) int32_t VideoEncCapiMock::Configure(std::shared_ptr<FormatMock> format)
{ {
auto formatMock = std::static_pointer_cast<AVFormatCapiMock>(format); auto formatMock = std::static_pointer_cast<AVFormatCapiMock>(format);

View File

@ -30,6 +30,7 @@ public:
int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) override; int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) override;
int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb) override; int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb) override;
int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb) override; int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb) override;
int32_t SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb) override;
int32_t Configure(std::shared_ptr<FormatMock> format) override; int32_t Configure(std::shared_ptr<FormatMock> format) override;
int32_t Start() override; int32_t Start() override;
int32_t Stop() override; int32_t Stop() override;

View File

@ -70,17 +70,31 @@ public:
void PopInQueue() void PopInQueue()
{ {
inQueue_.pop(); if (!inQueue_.empty()) {
inMemoryQueue_.pop(); inQueue_.pop();
inBufferQueue_.pop(); }
if (!inMemoryQueue_.empty()) {
inMemoryQueue_.pop();
}
if (!inBufferQueue_.empty()) {
inBufferQueue_.pop();
}
} }
void PopOutQueue() void PopOutQueue()
{ {
outQueue_.pop(); if (!outQueue_.empty()) {
outAttrQueue_.pop(); outQueue_.pop();
outMemoryQueue_.pop(); }
outBufferQueue_.pop(); if (!outAttrQueue_.empty()) {
outAttrQueue_.pop();
}
if (!outMemoryQueue_.empty()) {
outMemoryQueue_.pop();
}
if (!outBufferQueue_.empty()) {
outBufferQueue_.pop();
}
} }
}; };

View File

@ -112,6 +112,25 @@ void VideoEncParamCallbackMock::OnInputParameterAvailable(uint32_t index, std::s
} }
} }
VideoEncParamWithAttrCallbackMock::VideoEncParamWithAttrCallbackMock(
std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb)
: mockCb_(cb)
{
}
void VideoEncParamWithAttrCallbackMock::OnInputParameterWithAttrAvailable(uint32_t index,
std::shared_ptr<Format> attribute,
std::shared_ptr<Format> parameter)
{
if (mockCb_ != nullptr) {
auto parameterMock = std::make_shared<AVFormatInnerMock>();
parameterMock->format_ = std::move(*parameter);
const auto attributeMock = std::make_shared<AVFormatInnerMock>();
attributeMock->format_ = std::move(*attribute);
mockCb_->OnInputParameterWithAttrAvailable(index, attributeMock, parameterMock);
}
}
int32_t VideoEncInnerMock::SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) int32_t VideoEncInnerMock::SetCallback(std::shared_ptr<AVCodecCallbackMock> cb)
{ {
if (videoEnc_ != nullptr) { if (videoEnc_ != nullptr) {
@ -143,6 +162,16 @@ int32_t VideoEncInnerMock::SetCallback(std::shared_ptr<MediaCodecParameterCallba
return AV_ERR_UNKNOWN; return AV_ERR_UNKNOWN;
} }
int32_t VideoEncInnerMock::SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb)
{
if (videoEnc_ != nullptr) {
std::shared_ptr<VideoEncParamWithAttrCallbackMock> callback =
cb == nullptr ? nullptr : std::make_shared<VideoEncParamWithAttrCallbackMock>(cb);
return videoEnc_->SetCallback(callback);
}
return AV_ERR_UNKNOWN;
}
int32_t VideoEncInnerMock::Configure(std::shared_ptr<FormatMock> format) int32_t VideoEncInnerMock::Configure(std::shared_ptr<FormatMock> format)
{ {
if (videoEnc_ != nullptr) { if (videoEnc_ != nullptr) {

View File

@ -27,6 +27,7 @@ public:
int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) override; int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) override;
int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb) override; int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb) override;
int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb) override; int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb) override;
int32_t SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb) override;
int32_t Configure(std::shared_ptr<FormatMock> format) override; int32_t Configure(std::shared_ptr<FormatMock> format) override;
int32_t Start() override; int32_t Start() override;
int32_t Stop() override; int32_t Stop() override;
@ -85,6 +86,17 @@ public:
private: private:
std::shared_ptr<MediaCodecParameterCallbackMock> mockCb_ = nullptr; std::shared_ptr<MediaCodecParameterCallbackMock> mockCb_ = nullptr;
}; };
class VideoEncParamWithAttrCallbackMock : public MediaCodecParameterWithAttrCallback {
public:
explicit VideoEncParamWithAttrCallbackMock(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb);
~VideoEncParamWithAttrCallbackMock() = default;
void OnInputParameterWithAttrAvailable(uint32_t index, std::shared_ptr<Format> attribute,
std::shared_ptr<Format> parameter) override;
private:
std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> mockCb_ = nullptr;
};
} // namespace MediaAVCodec } // namespace MediaAVCodec
} // namespace OHOS } // namespace OHOS
#endif // VIDEO_ENC_INNER_MOCK_H #endif // VIDEO_ENC_INNER_MOCK_H

View File

@ -119,6 +119,7 @@ public:
void SetSource(const std::string &path); void SetSource(const std::string &path);
void SetSourceType(bool isH264Stream); void SetSourceType(bool isH264Stream);
bool needCheckSHA_ = false; bool needCheckSHA_ = false;
bool isAVBufferMode_ = false;
int32_t testParam_ = VCodecTestParam::SW_AVC; int32_t testParam_ = VCodecTestParam::SW_AVC;
bool renderAtTimeFlag_ = false; bool renderAtTimeFlag_ = false;
static bool needDump_; static bool needDump_;
@ -155,7 +156,6 @@ private:
uint32_t datSize_ = 0; uint32_t datSize_ = 0;
uint32_t frameInputCount_ = 0; uint32_t frameInputCount_ = 0;
uint32_t frameOutputCount_ = 0; uint32_t frameOutputCount_ = 0;
bool isAVBufferMode_ = false;
bool isSurfaceMode_ = false; bool isSurfaceMode_ = false;
bool isH264Stream_ = true; // true: H264; false: H265 bool isH264Stream_ = true; // true: H264; false: H265
int64_t time_ = 0; int64_t time_ = 0;

View File

@ -178,6 +178,28 @@ void VEncParamCallbackTest::OnInputParameterAvailable(uint32_t index, std::share
return; return;
} }
signal_->inIndexQueue_.push(index); signal_->inIndexQueue_.push(index);
signal_->inAttrQueue_.push(nullptr);
signal_->inFormatQueue_.push(parameter);
signal_->inCond_.notify_all();
}
VEncParamWithAttrCallbackTest::VEncParamWithAttrCallbackTest(std::shared_ptr<VEncSignal> signal) : signal_(signal) {}
VEncParamWithAttrCallbackTest::~VEncParamWithAttrCallbackTest() {}
void VEncParamWithAttrCallbackTest::OnInputParameterWithAttrAvailable(uint32_t index,
std::shared_ptr<FormatMock> attribute,
std::shared_ptr<FormatMock> parameter)
{
if (signal_ == nullptr) {
return;
}
unique_lock<mutex> lock(signal_->inMutex_);
if (!signal_->isRunning_.load() && !signal_->isPreparing_.load()) {
return;
}
signal_->inIndexQueue_.push(index);
signal_->inAttrQueue_.push(attribute);
signal_->inFormatQueue_.push(parameter); signal_->inFormatQueue_.push(parameter);
signal_->inCond_.notify_all(); signal_->inCond_.notify_all();
} }
@ -254,6 +276,16 @@ int32_t VideoEncSample::SetCallback(std::shared_ptr<MediaCodecParameterCallbackM
return ret; return ret;
} }
int32_t VideoEncSample::SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb)
{
if (videoEnc_ == nullptr) {
return AV_ERR_UNKNOWN;
}
int32_t ret = videoEnc_->SetCallback(cb);
isSetParamCallback_ = ret == AV_ERR_OK;
return ret;
}
int32_t VideoEncSample::Configure(std::shared_ptr<FormatMock> format) int32_t VideoEncSample::Configure(std::shared_ptr<FormatMock> format)
{ {
if (videoEnc_ == nullptr) { if (videoEnc_ == nullptr) {
@ -603,22 +635,27 @@ void VideoEncSample::InputParamLoopFunc()
int32_t index = signal_->inIndexQueue_.front(); int32_t index = signal_->inIndexQueue_.front();
auto format = signal_->inFormatQueue_.front(); auto format = signal_->inFormatQueue_.front();
UNITTEST_INFO_LOG("parameter: %s", format->DumpInfo()); auto attr = signal_->inAttrQueue_.front();
if (attr != nullptr) {
format->PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH_VENC); int64_t pts = 0;
format->PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT_VENC); EXPECT_EQ(true, attr->GetLongValue(Media::Tag::MEDIA_TIME_STAMP, pts));
format->PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12); UNITTEST_INFO_LOG("attribute: %s", attr->DumpInfo());
}
if (isTemporalScalabilitySyncIdr_ && frameInputCount_ == REQUEST_I_FRAME_NUM) { if (isTemporalScalabilitySyncIdr_ && frameInputCount_ == REQUEST_I_FRAME_NUM) {
format->PutIntValue(Media::Tag::VIDEO_REQUEST_I_FRAME, REQUEST_I_FRAME); format->PutIntValue(Media::Tag::VIDEO_REQUEST_I_FRAME, REQUEST_I_FRAME);
UNITTEST_INFO_LOG("request i frame: %s", format->DumpInfo());
} }
if (isDiscardFrame_ && (frameInputCount_ % 2) == 0) { // 2: encode half frames
format->PutIntValue(Media::Tag::VIDEO_ENCODER_PER_FRAME_DISCARD, 1);
}
UNITTEST_INFO_LOG("parameter: %s", format->DumpInfo());
int32_t ret = PushInputParameter(index); int32_t ret = PushInputParameter(index);
UNITTEST_CHECK_AND_BREAK_LOG(ret == AV_ERR_OK, "Fatal: PushInputData fail, exit"); UNITTEST_CHECK_AND_BREAK_LOG(ret == AV_ERR_OK, "Fatal: PushInputData fail, exit");
signal_->inIndexQueue_.pop(); signal_->inIndexQueue_.pop();
signal_->inFormatQueue_.pop(); signal_->inFormatQueue_.pop();
signal_->inAttrQueue_.pop();
} }
} }

View File

@ -38,12 +38,18 @@ public:
std::condition_variable outCond_; std::condition_variable outCond_;
std::queue<uint32_t> inIndexQueue_; std::queue<uint32_t> inIndexQueue_;
std::queue<uint32_t> outIndexQueue_; std::queue<uint32_t> outIndexQueue_;
// API 9
std::queue<OH_AVCodecBufferAttr> outAttrQueue_; std::queue<OH_AVCodecBufferAttr> outAttrQueue_;
std::queue<std::shared_ptr<AVMemoryMock>> inMemoryQueue_; std::queue<std::shared_ptr<AVMemoryMock>> inMemoryQueue_;
std::queue<std::shared_ptr<AVMemoryMock>> outMemoryQueue_; std::queue<std::shared_ptr<AVMemoryMock>> outMemoryQueue_;
// API 11
std::queue<std::shared_ptr<AVBufferMock>> inBufferQueue_; std::queue<std::shared_ptr<AVBufferMock>> inBufferQueue_;
std::queue<std::shared_ptr<AVBufferMock>> outBufferQueue_; std::queue<std::shared_ptr<AVBufferMock>> outBufferQueue_;
std::queue<std::shared_ptr<FormatMock>> inFormatQueue_; std::queue<std::shared_ptr<FormatMock>> inFormatQueue_;
std::queue<std::shared_ptr<FormatMock>> inAttrQueue_;
int32_t errorNum_ = 0; int32_t errorNum_ = 0;
std::atomic<bool> isRunning_ = false; std::atomic<bool> isRunning_ = false;
std::atomic<bool> isPreparing_ = true; std::atomic<bool> isPreparing_ = true;
@ -85,6 +91,17 @@ private:
std::shared_ptr<VEncSignal> signal_ = nullptr; std::shared_ptr<VEncSignal> signal_ = nullptr;
}; };
class VEncParamWithAttrCallbackTest : public MediaCodecParameterWithAttrCallbackMock {
public:
explicit VEncParamWithAttrCallbackTest(std::shared_ptr<VEncSignal> signal);
virtual ~VEncParamWithAttrCallbackTest();
void OnInputParameterWithAttrAvailable(uint32_t index, std::shared_ptr<FormatMock> attribute,
std::shared_ptr<FormatMock> parameter) override;
private:
std::shared_ptr<VEncSignal> signal_ = nullptr;
};
class VideoEncSample : public NoCopyable { class VideoEncSample : public NoCopyable {
public: public:
explicit VideoEncSample(std::shared_ptr<VEncSignal> signal); explicit VideoEncSample(std::shared_ptr<VEncSignal> signal);
@ -96,6 +113,7 @@ public:
int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb); int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb);
int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb); int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb);
int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb); int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb);
int32_t SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb);
int32_t Configure(std::shared_ptr<FormatMock> format); int32_t Configure(std::shared_ptr<FormatMock> format);
int32_t Start(); int32_t Start();
int32_t Stop(); int32_t Stop();
@ -119,6 +137,10 @@ public:
bool needCheckSHA_ = false; bool needCheckSHA_ = false;
bool needSleep_ = false; bool needSleep_ = false;
static bool needDump_; static bool needDump_;
bool isAVBufferMode_ = false;
bool isHdrVivid_ = false;
bool isTemporalScalabilitySyncIdr_ = false;
bool isDiscardFrame_ = false;
private: private:
void FlushInner(); void FlushInner();
@ -143,7 +165,7 @@ private:
void InputLoopFuncExt(); void InputLoopFuncExt();
int32_t OutputLoopInnerExt(); int32_t OutputLoopInnerExt();
int32_t InputLoopInnerExt(); int32_t InputLoopInnerExt();
void CheckFormatKey(OH_AVCodecBufferAttr attr, std::shared_ptr<AVBufferMock>buffer); void CheckFormatKey(OH_AVCodecBufferAttr attr, std::shared_ptr<AVBufferMock> buffer);
void CheckSHA(); void CheckSHA();
void PerformEosFrameAndVerifiedSHA(); void PerformEosFrameAndVerifiedSHA();
std::shared_ptr<VideoEncMock> videoEnc_ = nullptr; std::shared_ptr<VideoEncMock> videoEnc_ = nullptr;
@ -158,12 +180,9 @@ private:
std::string outSurfacePath_; std::string outSurfacePath_;
int32_t frameInputCount_ = 0; int32_t frameInputCount_ = 0;
int32_t frameOutputCount_ = 0; int32_t frameOutputCount_ = 0;
bool isAVBufferMode_ = false;
bool isFirstFrame_ = true; bool isFirstFrame_ = true;
bool isSurfaceMode_ = false; bool isSurfaceMode_ = false;
bool isHdrVivid_ = false;
bool isSetParamCallback_ = false; bool isSetParamCallback_ = false;
bool isTemporalScalabilitySyncIdr_ = false;
int64_t time_ = 0; int64_t time_ = 0;
sptr<Surface> consumer_ = nullptr; sptr<Surface> consumer_ = nullptr;
sptr<Surface> producer_ = nullptr; sptr<Surface> producer_ = nullptr;

View File

@ -15,10 +15,14 @@
#include "vdec_sample.h" #include "vdec_sample.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "../../../../../../window/window_manager/interfaces/innerkits/wm/window.h"
#include "common/native_mfmagic.h" #include "common/native_mfmagic.h"
#include "native_avcapability.h" #include "native_avcapability.h"
#include "native_avmagic.h" #include "native_avmagic.h"
#include "surface/window.h" #include "surface/window.h"
#include "surface_buffer.h"
#include "ui/rs_surface_node.h"
#include "window_option.h"
#define PRINT_HILOG #define PRINT_HILOG
#define TEST_ID sampleId_ #define TEST_ID sampleId_
@ -91,7 +95,7 @@ public:
int32_t stride = buffer->GetStride(); int32_t stride = buffer->GetStride();
int32_t pixelbytes = 1; int32_t pixelbytes = 1;
if (stride >= width * 2) { // 2 10bit per pixel 2 bytes if (stride >= width * 2) { // 2 10bit per pixel 2 bytes
pixelbytes = 2; // 2 10bit per pixel 2 bytes pixelbytes = 2; // 2 10bit per pixel 2 bytes
} }
for (int32_t i = 0; i < height * 3 / 2; ++i) { // 3: nom, 2: denom for (int32_t i = 0; i < height * 3 / 2; ++i) { // 3: nom, 2: denom
(void)signal_->outFile_->write(reinterpret_cast<char *>(buffer->GetVirAddr()) + i * stride, (void)signal_->outFile_->write(reinterpret_cast<char *>(buffer->GetVirAddr()) + i * stride,
@ -136,12 +140,27 @@ public:
{ {
TITLE_LOG; TITLE_LOG;
WindowObject obj; WindowObject obj;
if (queue_.size() >= OFFSET_8) { if (queue_.size() >= 2) { // 2: surface num
obj = queue_.front(); obj = queue_.front();
queue_.push(obj); queue_.push(obj);
queue_.pop(); queue_.pop();
return; return;
} }
VideoDecSample::isRosenWindow_ ? CreateRosenWindow(obj) : CreateDumpWindow(obj);
queue_.push(std::move(obj));
}
private:
typedef struct WindowObject {
OHNativeWindow *nativeWindow_ = nullptr;
sptr<IBufferConsumerListener> listener_ = nullptr;
sptr<Surface> consumer_ = nullptr;
sptr<Surface> producer_ = nullptr;
sptr<Rosen::Window> rosenWindow_ = nullptr;
} WindowObject;
void CreateDumpWindow(WindowObject &obj)
{
obj.consumer_ = Surface::CreateSurfaceAsConsumer(); obj.consumer_ = Surface::CreateSurfaceAsConsumer();
if (queue_.empty()) { if (queue_.empty()) {
obj.listener_ = new TestConsumerListener(obj.consumer_.GetRefPtr(), signal_, sampleId_); obj.listener_ = new TestConsumerListener(obj.consumer_.GetRefPtr(), signal_, sampleId_);
@ -155,19 +174,28 @@ public:
obj.producer_ = Surface::CreateSurfaceAsProducer(p); obj.producer_ = Surface::CreateSurfaceAsProducer(p);
obj.nativeWindow_ = CreateNativeWindowFromSurface(&obj.producer_); obj.nativeWindow_ = CreateNativeWindowFromSurface(&obj.producer_);
queue_.push(std::move(obj));
} }
private: void CreateRosenWindow(WindowObject &obj)
{
sptr<Rosen::WindowOption> option = new Rosen::WindowOption();
int32_t sizeModValue = static_cast<int32_t>(queue_.size()) % 2; // 2: surface num
Rosen::Rect rect = {720 * sizeModValue, (sampleId_ % VideoDecSample::threadNum_) * 320, 0, 0}; // 720 320: x y
option->SetWindowRect(rect);
option->SetWindowType(Rosen::WindowType::WINDOW_TYPE_FLOAT);
option->SetWindowMode(Rosen::WindowMode::WINDOW_MODE_FULLSCREEN);
std::string name = "VideoCodec_" + std::to_string(sampleId_) + "_" + std::to_string(queue_.size());
UNITTEST_CHECK_AND_RETURN_LOG(obj.rosenWindow_ != nullptr, "rosen window is nullptr.");
UNITTEST_CHECK_AND_RETURN_LOG(obj.rosenWindow_->GetSurfaceNode() != nullptr, "surface node is nullptr.");
obj.rosenWindow_->SetTurnScreenOn(!obj.rosenWindow_->IsTurnScreenOn());
obj.rosenWindow_->SetKeepScreenOn(true);
obj.rosenWindow_->Show();
obj.producer_ = obj.rosenWindow_->GetSurfaceNode()->GetSurface();
obj.nativeWindow_ = CreateNativeWindowFromSurface(&obj.producer_);
}
int32_t sampleId_; int32_t sampleId_;
std::shared_ptr<VideoDecSignal> signal_ = nullptr; std::shared_ptr<VideoDecSignal> signal_ = nullptr;
typedef struct WindowObject {
OHNativeWindow *nativeWindow_ = nullptr;
sptr<IBufferConsumerListener> listener_ = nullptr;
sptr<Surface> consumer_ = nullptr;
sptr<Surface> producer_ = nullptr;
} WindowObject;
std::queue<WindowObject> queue_; std::queue<WindowObject> queue_;
}; };
} // namespace MediaAVCodec } // namespace MediaAVCodec
@ -177,6 +205,7 @@ namespace OHOS {
namespace MediaAVCodec { namespace MediaAVCodec {
bool VideoDecSample::needDump_ = false; bool VideoDecSample::needDump_ = false;
bool VideoDecSample::isHardware_ = true; bool VideoDecSample::isHardware_ = true;
bool VideoDecSample::isRosenWindow_ = false;
uint64_t VideoDecSample::sampleTimout_ = 180; uint64_t VideoDecSample::sampleTimout_ = 180;
uint64_t VideoDecSample::threadNum_ = 1; uint64_t VideoDecSample::threadNum_ = 1;
@ -363,8 +392,6 @@ int32_t VideoDecSample::Stop()
ret = OH_VideoDecoder_Stop(codec_); ret = OH_VideoDecoder_Stop(codec_);
UNITTEST_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, ret, "OH_VideoDecoder_Stop failed"); UNITTEST_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, ret, "OH_VideoDecoder_Stop failed");
} }
ret = isSurfaceMode_ ? SetOutputSurface() : AV_ERR_OK;
UNITTEST_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, ret, "SetOutputSurface failed");
return ret; return ret;
} }
@ -377,8 +404,6 @@ int32_t VideoDecSample::Flush()
ret = OH_VideoDecoder_Flush(codec_); ret = OH_VideoDecoder_Flush(codec_);
UNITTEST_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, ret, "OH_VideoDecoder_Flush failed"); UNITTEST_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, ret, "OH_VideoDecoder_Flush failed");
} }
ret = isSurfaceMode_ ? SetOutputSurface() : AV_ERR_OK;
UNITTEST_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, ret, "SetOutputSurface failed");
return ret; return ret;
} }
@ -623,7 +648,7 @@ int32_t VideoDecSample::HandleOutputFrameInner(uint8_t *addr, OH_AVCodecBufferAt
} }
int32_t pixelbytes = 1; int32_t pixelbytes = 1;
if (stride_ >= width_ * 2) { // 2 10bit per pixel 2 bytes if (stride_ >= width_ * 2) { // 2 10bit per pixel 2 bytes
pixelbytes = 2; // 2 10bit per pixel 2 bytes pixelbytes = 2; // 2 10bit per pixel 2 bytes
} }
for (int32_t i = 0; i < heightSlice_; ++i) { for (int32_t i = 0; i < heightSlice_; ++i) {
(void)signal_->outFile_->write(reinterpret_cast<char *>(addr) + i * stride_, width_ * pixelbytes); (void)signal_->outFile_->write(reinterpret_cast<char *>(addr) + i * stride_, width_ * pixelbytes);

View File

@ -84,6 +84,7 @@ public:
static bool isHardware_; static bool isHardware_;
static bool needDump_; static bool needDump_;
static bool isRosenWindow_;
static uint64_t sampleTimout_; static uint64_t sampleTimout_;
static uint64_t threadNum_; static uint64_t threadNum_;
int32_t sampleId_ = 0; int32_t sampleId_ = 0;

View File

@ -59,6 +59,13 @@ public:
virtual void OnInputParameterAvailable(uint32_t index, std::shared_ptr<FormatMock> parameter) = 0; virtual void OnInputParameterAvailable(uint32_t index, std::shared_ptr<FormatMock> parameter) = 0;
}; };
class MediaCodecParameterWithAttrCallbackMock : public NoCopyable {
public:
virtual ~MediaCodecParameterWithAttrCallbackMock() = default;
virtual void OnInputParameterWithAttrAvailable(uint32_t index, std::shared_ptr<FormatMock> attribute,
std::shared_ptr<FormatMock> parameter) = 0;
};
class VideoDecMock : public NoCopyable { class VideoDecMock : public NoCopyable {
public: public:
virtual ~VideoDecMock() = default; virtual ~VideoDecMock() = default;
@ -91,6 +98,7 @@ public:
virtual int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) = 0; virtual int32_t SetCallback(std::shared_ptr<AVCodecCallbackMock> cb) = 0;
virtual int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb) = 0; virtual int32_t SetCallback(std::shared_ptr<MediaCodecCallbackMock> cb) = 0;
virtual int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb) = 0; virtual int32_t SetCallback(std::shared_ptr<MediaCodecParameterCallbackMock> cb) = 0;
virtual int32_t SetCallback(std::shared_ptr<MediaCodecParameterWithAttrCallbackMock> cb) = 0;
virtual int32_t Configure(std::shared_ptr<FormatMock> format) = 0; virtual int32_t Configure(std::shared_ptr<FormatMock> format) = 0;
virtual int32_t Start() = 0; virtual int32_t Start() = 0;
virtual int32_t Stop() = 0; virtual int32_t Stop() = 0;

View File

@ -1119,6 +1119,9 @@ int main(int argc, char **argv)
if (strcmp(argv[i], "--need_dump") == 0) { if (strcmp(argv[i], "--need_dump") == 0) {
VideoDecSample::needDump_ = true; VideoDecSample::needDump_ = true;
DecArgv(i, argc, argv); DecArgv(i, argc, argv);
} else if (strcmp(argv[i], "--rosen") == 0) {
VideoDecSample::isRosenWindow_ = true;
DecArgv(i, argc, argv);
} else if (strcmp(argv[i], "--fcodec") == 0) { } else if (strcmp(argv[i], "--fcodec") == 0) {
VideoDecSample::isHardware_ = false; VideoDecSample::isHardware_ = false;
DecArgv(i, argc, argv); DecArgv(i, argc, argv);

View File

@ -114,7 +114,6 @@ protected:
std::shared_ptr<FormatMock> format_ = nullptr; std::shared_ptr<FormatMock> format_ = nullptr;
std::shared_ptr<VDecCallbackTest> vdecCallback_ = nullptr; std::shared_ptr<VDecCallbackTest> vdecCallback_ = nullptr;
std::shared_ptr<VDecCallbackTestExt> vdecCallbackExt_ = nullptr; std::shared_ptr<VDecCallbackTestExt> vdecCallbackExt_ = nullptr;
bool isAVBufferMode_ = false;
#ifdef VIDEODEC_CAPI_UNIT_TEST #ifdef VIDEODEC_CAPI_UNIT_TEST
OH_AVCodec *codec_ = nullptr; OH_AVCodec *codec_ = nullptr;
#endif #endif
@ -170,7 +169,7 @@ bool TEST_SUIT::CreateVideoCodecByMime(const std::string &decMime)
bool TEST_SUIT::CreateVideoCodecByName(const std::string &decName) bool TEST_SUIT::CreateVideoCodecByName(const std::string &decName)
{ {
if (isAVBufferMode_) { if (videoDec_->isAVBufferMode_) {
if (videoDec_->CreateVideoDecMockByName(decName) == false || if (videoDec_->CreateVideoDecMockByName(decName) == false ||
videoDec_->SetCallback(vdecCallbackExt_) != AV_ERR_OK) { videoDec_->SetCallback(vdecCallbackExt_) != AV_ERR_OK) {
return false; return false;
@ -746,7 +745,7 @@ HWTEST_P(TEST_SUIT, VideoDecoder_Start_005, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_001, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_001, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -762,7 +761,7 @@ HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_001, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_002, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_002, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -781,7 +780,7 @@ HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_002, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_003, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_003, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -800,7 +799,7 @@ HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_003, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_004, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_Start_Buffer_004, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
EXPECT_NE(AV_ERR_OK, videoDec_->Start()); EXPECT_NE(AV_ERR_OK, videoDec_->Start());
@ -1032,7 +1031,7 @@ HWTEST_P(TEST_SUIT, VideoDecoder_SetSurface_003, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_SetSurface_Buffer_001, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_SetSurface_Buffer_001, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1049,7 +1048,7 @@ HWTEST_P(TEST_SUIT, VideoDecoder_SetSurface_Buffer_001, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_SetSurface_Buffer_002, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_SetSurface_Buffer_002, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1335,7 +1334,7 @@ HWTEST_F(TEST_SUIT, VideoDecoder_SetDecryptionConfig_001, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoDecoder_RenderOutputBufferAtTime_001, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoDecoder_RenderOutputBufferAtTime_001, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoDec_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());

View File

@ -139,8 +139,7 @@ protected:
std::shared_ptr<VEncCallbackTest> vencCallback_ = nullptr; std::shared_ptr<VEncCallbackTest> vencCallback_ = nullptr;
std::shared_ptr<VEncCallbackTestExt> vencCallbackExt_ = nullptr; std::shared_ptr<VEncCallbackTestExt> vencCallbackExt_ = nullptr;
std::shared_ptr<VEncParamCallbackTest> vencParamCallback_ = nullptr; std::shared_ptr<VEncParamCallbackTest> vencParamCallback_ = nullptr;
bool isAVBufferMode_ = false; std::shared_ptr<VEncParamWithAttrCallbackTest> vencParamWithAttrCallback_ = nullptr;
bool isTemporalScalabilitySyncIdr_ = false;
#ifdef VIDEOENC_CAPI_UNIT_TEST #ifdef VIDEOENC_CAPI_UNIT_TEST
OH_AVCodec *codec_ = nullptr; OH_AVCodec *codec_ = nullptr;
#endif #endif
@ -168,6 +167,9 @@ void TEST_SUIT::SetUp(void)
vencParamCallback_ = std::make_shared<VEncParamCallbackTest>(vencSignal); vencParamCallback_ = std::make_shared<VEncParamCallbackTest>(vencSignal);
ASSERT_NE(nullptr, vencParamCallback_); ASSERT_NE(nullptr, vencParamCallback_);
vencParamWithAttrCallback_ = std::make_shared<VEncParamWithAttrCallbackTest>(vencSignal);
ASSERT_NE(nullptr, vencParamWithAttrCallback_);
videoEnc_ = std::make_shared<VideoEncSample>(vencSignal); videoEnc_ = std::make_shared<VideoEncSample>(vencSignal);
ASSERT_NE(nullptr, videoEnc_); ASSERT_NE(nullptr, videoEnc_);
@ -177,8 +179,6 @@ void TEST_SUIT::SetUp(void)
void TEST_SUIT::TearDown(void) void TEST_SUIT::TearDown(void)
{ {
isAVBufferMode_ = false;
isTemporalScalabilitySyncIdr_ = false;
if (format_ != nullptr) { if (format_ != nullptr) {
format_->Destroy(); format_->Destroy();
} }
@ -201,7 +201,7 @@ bool TEST_SUIT::CreateVideoCodecByMime(const std::string &encMime)
bool TEST_SUIT::CreateVideoCodecByName(const std::string &name) bool TEST_SUIT::CreateVideoCodecByName(const std::string &name)
{ {
if (isAVBufferMode_) { if (videoEnc_->isAVBufferMode_) {
if (videoEnc_->CreateVideoEncMockByName(name) == false || if (videoEnc_->CreateVideoEncMockByName(name) == false ||
videoEnc_->SetCallback(vencCallbackExt_) != AV_ERR_OK) { videoEnc_->SetCallback(vencCallbackExt_) != AV_ERR_OK) {
return false; return false;
@ -211,9 +211,6 @@ bool TEST_SUIT::CreateVideoCodecByName(const std::string &name)
return false; return false;
} }
} }
if (isTemporalScalabilitySyncIdr_) {
videoEnc_->isTemporalScalabilitySyncIdr_ = true;
}
return true; return true;
} }
@ -362,11 +359,11 @@ HWTEST_F(TEST_SUIT, VideoEncoder_Setcallback_004, TestSize.Level1)
} }
/** /**
* @tc.name: VideoEncoder_SetParameterCallback_001 * @tc.name: VideoEncoder_Invalid_SetParameterCallback_001
* @tc.desc: video setcallback * @tc.desc: video setcallback
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterCallback_001, TestSize.Level1) HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterCallback_001, TestSize.Level1)
{ {
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName)); ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallback_)); ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallback_));
@ -379,11 +376,11 @@ HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterCallback_001, TestSize.Level1)
} }
/** /**
* @tc.name: VideoEncoder_SetParameterCallback_002 * @tc.name: VideoEncoder_Invalid_SetParameterCallback_002
* @tc.desc: video setcallback * @tc.desc: video setcallback
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterCallback_002, TestSize.Level1) HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterCallback_002, TestSize.Level1)
{ {
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName)); ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallbackExt_)); ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallbackExt_));
@ -396,28 +393,11 @@ HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterCallback_002, TestSize.Level1)
} }
/** /**
* @tc.name: VideoEncoder_SetParameterCallback_003 * @tc.name: VideoEncoder_Invalid_SetParameterCallback_003
* @tc.desc: video setcallback * @tc.desc: video setcallback
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterCallback_003, TestSize.Level1) HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterCallback_003, TestSize.Level1)
{
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
format_->PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH_VENC);
format_->PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT_VENC);
format_->PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->Configure(format_));
ASSERT_NE(AV_ERR_OK, videoEnc_->Start());
}
/**
* @tc.name: VideoEncoder_SetParameterCallback_004
* @tc.desc: video setcallback
* @tc.type: FUNC
*/
HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterCallback_004, TestSize.Level1)
{ {
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName)); ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
format_->PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH_VENC); format_->PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH_VENC);
@ -581,6 +561,88 @@ HWTEST_F(TEST_SUIT, VideoEncoder_Free_Buffer_Invalid_004, TestSize.Level1)
codec_->magic_ = AVMagic::AVCODEC_MAGIC_VIDEO_ENCODER; codec_->magic_ = AVMagic::AVCODEC_MAGIC_VIDEO_ENCODER;
} }
#else #else
/**
* @tc.name: VideoEncoder_SetParameterWithAttrCallback_001
* @tc.desc: SetParameterWithAttrCallback and check if meta has pts key-value
* @tc.type: FUNC
*/
HWTEST_F(TEST_SUIT, VideoEncoder_SetParameterWithAttrCallback_001, TestSize.Level1)
{
videoEnc_->isDiscardFrame_ = true;
CreateByNameWithParam(VCodecTestCode::HW_AVC);
SetFormatWithParam(VCodecTestCode::HW_AVC);
PrepareSource(VCodecTestCode::HW_AVC);
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->Configure(format_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->CreateInputSurface());
EXPECT_EQ(AV_ERR_OK, videoEnc_->Start());
EXPECT_EQ(AV_ERR_OK, videoEnc_->Stop());
}
/**
* @tc.name: VideoEncoder_Invalid_SetParameterWithAttrCallback_001
* @tc.desc: repeat SetParameterWithAttrCallback and test the compatibility of API9 and API10
* @tc.type: FUNC
*/
HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterWithAttrCallback_001, TestSize.Level1)
{
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallback_));
ASSERT_NE(AV_ERR_OK, videoEnc_->SetCallback(vencCallbackExt_));
}
/**
* @tc.name: VideoEncoder_Invalid_SetParameterWithAttrCallback_002
* @tc.desc: repeat SetParameterWithAttrCallback and test the compatibility of API10 and API9
* @tc.type: FUNC
*/
HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterWithAttrCallback_002, TestSize.Level1)
{
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallbackExt_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencCallbackExt_));
ASSERT_NE(AV_ERR_OK, videoEnc_->SetCallback(vencCallback_));
}
/**
* @tc.name: VideoEncoder_Invalid_SetParameterWithAttrCallback_003
* @tc.desc: start failed with SetParameterWithAttrCallback and not set surface
* @tc.type: FUNC
*/
HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterWithAttrCallback_003, TestSize.Level1)
{
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
format_->PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH_VENC);
format_->PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT_VENC);
format_->PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
ASSERT_EQ(AV_ERR_OK, videoEnc_->Configure(format_));
ASSERT_NE(AV_ERR_OK, videoEnc_->Start());
}
/**
* @tc.name: VideoEncoder_Invalid_SetParameterWithAttrCallback_004
* @tc.desc: set vencParamWithAttrCallback_ success and set vencParamCallback_ failed
* @tc.type: FUNC
*/
HWTEST_F(TEST_SUIT, VideoEncoder_Invalid_SetParameterWithAttrCallback_004, TestSize.Level1)
{
ASSERT_TRUE(videoEnc_->CreateVideoEncMockByName(g_vencName));
format_->PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH_VENC);
format_->PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT_VENC);
format_->PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
ASSERT_EQ(AV_ERR_OK, videoEnc_->SetCallback(vencParamWithAttrCallback_));
EXPECT_NE(AV_ERR_OK, videoEnc_->SetCallback(vencParamCallback_));
}
/** /**
* @tc.name: VideoEncoder_RepeatPreviousFrame_001 * @tc.name: VideoEncoder_RepeatPreviousFrame_001
* @tc.desc: key repeat previous frame is invalid * @tc.desc: key repeat previous frame is invalid
@ -796,7 +858,6 @@ HWTEST_P(TEST_SUIT, VideoEncoder_RepeatPreviousFrame_011, TestSize.Level1)
EXPECT_GE(videoEnc_->frameOutputCount_, frameOutputCountMin); EXPECT_GE(videoEnc_->frameOutputCount_, frameOutputCountMin);
} }
#endif #endif
#endif
/** /**
* @tc.name: VideoEncoder_Start_001 * @tc.name: VideoEncoder_Start_001
@ -879,7 +940,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_Start_005, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_001, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_001, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -900,7 +961,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_001, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_002, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_002, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -917,7 +978,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_002, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_003, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_003, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -934,7 +995,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_003, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_004, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_Start_Buffer_004, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
EXPECT_NE(AV_ERR_OK, videoEnc_->Start()); EXPECT_NE(AV_ERR_OK, videoEnc_->Start());
@ -1175,7 +1236,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_SetSurface_003, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_SetSurface_Buffer_001, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_SetSurface_Buffer_001, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1192,7 +1253,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_SetSurface_Buffer_001, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_SetSurface_Buffer_002, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_SetSurface_Buffer_002, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1400,7 +1461,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_002, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_003, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_003, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1421,7 +1482,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_003, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_004, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_004, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1510,7 +1571,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_008, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_009, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_009, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1638,8 +1699,8 @@ HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_015, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_016, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_016, TestSize.Level1)
{ {
isAVBufferMode_ = true; videoEnc_->isAVBufferMode_ = true;
isTemporalScalabilitySyncIdr_ = true; videoEnc_->isTemporalScalabilitySyncIdr_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());
@ -1657,7 +1718,7 @@ HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_016, TestSize.Level1)
*/ */
HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_017, TestSize.Level1) HWTEST_P(TEST_SUIT, VideoEncoder_TemporalScalability_017, TestSize.Level1)
{ {
isTemporalScalabilitySyncIdr_ = true; videoEnc_->isTemporalScalabilitySyncIdr_ = true;
CreateByNameWithParam(GetParam()); CreateByNameWithParam(GetParam());
SetFormatWithParam(GetParam()); SetFormatWithParam(GetParam());
PrepareSource(GetParam()); PrepareSource(GetParam());