【修改说明】upload native api

Signed-off-by: yangxiaoyu <yangxiaoyu5@huawei.com>
This commit is contained in:
yangxiaoyu 2023-04-04 12:18:38 +00:00
parent 273ede4c10
commit 8af0ee31bb
3 changed files with 221 additions and 0 deletions

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "avcodec_list_impl.h"
#include "media_log.h"
#include "media_errors.h"
#include "i_media_service.h"
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "AVCodecListImpl"};
}
namespace OHOS {
namespace Media {
std::shared_ptr<AVCodecList> AVCodecListFactory::CreateAVCodecList()
{
std::shared_ptr<AVCodecListImpl> impl = std::make_shared<AVCodecListImpl>();
CHECK_AND_RETURN_RET_LOG(impl != nullptr, nullptr, "failed to new AVCodecListImpl");
int32_t ret = impl->Init();
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, nullptr, "failed to init AVCodecListImpl");
return impl;
}
int32_t AVCodecListImpl::Init()
{
codecListService_ = MediaServiceFactory::GetInstance().CreateAVCodecListService();
CHECK_AND_RETURN_RET_LOG(codecListService_ != nullptr, MSERR_UNKNOWN, "failed to create AVCodecList service");
return MSERR_OK;
}
AVCodecListImpl::AVCodecListImpl()
{
MEDIA_LOGD("AVCodecListImpl:0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
}
AVCodecListImpl::~AVCodecListImpl()
{
if (codecListService_ != nullptr) {
(void)MediaServiceFactory::GetInstance().DestroyAVCodecListService(codecListService_);
codecListService_ = nullptr;
}
MEDIA_LOGD("AVCodecListImpl:0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
}
std::string AVCodecListImpl::FindVideoDecoder(const Format &format)
{
return codecListService_->FindVideoDecoder(format);
}
std::string AVCodecListImpl::FindVideoEncoder(const Format &format)
{
return codecListService_->FindVideoEncoder(format);
}
std::string AVCodecListImpl::FindAudioDecoder(const Format &format)
{
return codecListService_->FindAudioDecoder(format);
}
std::string AVCodecListImpl::FindAudioEncoder(const Format &format)
{
return codecListService_->FindAudioEncoder(format);
}
CapabilityData AVCodecListImpl::GetCapabilityData(std::string codecName)
{
return codecListService_->GetCapabilityData(codecName);
}
} // namespace Media
} // namespace OHOS

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AVCODEC_LIST_IMPL_H
#define AVCODEC_LIST_IMPL_H
#include "avcodec_info.h"
#include "avcodec_list.h"
#include "nocopyable.h"
#include "i_avcodeclist_service.h"
namespace OHOS {
namespace Media {
class AVCodecListImpl : public AVCodecList, public NoCopyable {
public:
AVCodecListImpl();
~AVCodecListImpl();
int32_t Init();
std::string FindVideoDecoder(const Format &format) override;
std::string FindVideoEncoder(const Format &format) override;
std::string FindAudioDecoder(const Format &format) override;
std::string FindAudioEncoder(const Format &format) override;
CapabilityData GetCapabilityData(std::string codecName) override;
private:
std::shared_ptr<IAVCodecListService> codecListService_ = nullptr;
};
} // namespace Media
} // namespace OHOS
#endif // AVCODEC_LIST_IMPL_H

View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AVCODEC_LIST_H
#define AVCODEC_LIST_H
#include <cstdint>
#include <memory>
#include "avcodec_info.h"
namespace OHOS {
namespace Media {
class AVCodecList {
public:
virtual ~AVCodecList() = default;
/**
* @brief Find the supported video decoder name by format(usually contains video MIME).
* @param format Indicates a media description which contains required video decoder capability.
* @return Returns video decoder name, if not find, return empty string.
* @since 1.0
* @version 4.0
*/
virtual std::string FindVideoDecoder(const Format &format) = 0;
/**
* @brief Find the supported video encoder name by format(usually contains video MIME).
* @param format Indicates a media description which contains required video encoder capability.
* @return Returns video encoder name, if not find, return empty string.
* @since 1.0
* @version 4.0
*/
virtual std::string FindVideoEncoder(const Format &format) = 0;
/**
* @brief Find the supported audio decoder name by format(usually contains audio MIME).
* @param format Indicates a media description which contains required audio decoder capability.
* @return Returns audio decoder name, if not find, return empty string.
* @since 1.0
* @version 4.0
*/
virtual std::string FindAudioDecoder(const Format &format) = 0;
/**
* @brief Find the supported audio encoder name by format(usually contains audio MIME).
* @param format Indicates a media description which contains required audio encoder capability.
* @return Returns audio encoder name, if not find, return empty string.
* @since 1.0
* @version 4.0
*/
virtual std::string FindAudioEncoder(const Format &format) = 0;
/**
* @brief Get the capabilities by codec name
* @param codeName Codec name
* @return Returns an array of supported video decoder capability, if not find, return invalid CapabilityData.
* @since 1.0
* @version 4.0
*/
virtual CapabilityData GetCapabilityData(std::string codecName) = 0;
};
// TODO: 考虑减少这个类
class __attribute__((visibility("default"))) AVCodecListFactory {
public:
#ifdef UNSUPPORT_CODEC
static std::shared_ptr<AVCodecList> CreateAVCodecList()
{
return nullptr;
}
#else
static std::shared_ptr<AVCodecList> CreateAVCodecList();
#endif
private:
AVCodecListFactory() = default;
~AVCodecListFactory() = default;
};
} // namespace Media
} // namespace OHOS
#endif // AVCODEC_LIST_H