180922886Sopenharmony_ci/*
280922886Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
380922886Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
480922886Sopenharmony_ci * you may not use this file except in compliance with the License.
580922886Sopenharmony_ci * You may obtain a copy of the License at
680922886Sopenharmony_ci *
780922886Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
880922886Sopenharmony_ci *
980922886Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1080922886Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1180922886Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1280922886Sopenharmony_ci * See the License for the specific language governing permissions and
1380922886Sopenharmony_ci * limitations under the License.
1480922886Sopenharmony_ci */
1580922886Sopenharmony_ci#ifndef OHOS_OHAVSESSION_METADATA_H
1680922886Sopenharmony_ci#define OHOS_OHAVSESSION_METADATA_H
1780922886Sopenharmony_ci
1880922886Sopenharmony_ci#include <string>
1980922886Sopenharmony_ci#include "native_avmetadata.h"
2080922886Sopenharmony_ci#include "native_avsession_errors.h"
2180922886Sopenharmony_ci#include "avsession_pixel_map_adapter.h"
2280922886Sopenharmony_ci#include "avmeta_data.h"
2380922886Sopenharmony_ci#include "curl/curl.h"
2480922886Sopenharmony_ci#include "image_source.h"
2580922886Sopenharmony_ci#include "pixel_map.h"
2680922886Sopenharmony_ci
2780922886Sopenharmony_cinamespace OHOS::AVSession {
2880922886Sopenharmony_ciclass OHAVMetadataBuilder {
2980922886Sopenharmony_cipublic:
3080922886Sopenharmony_ci    AVMetadata_Result SetTitle(const std::string &title);
3180922886Sopenharmony_ci    AVMetadata_Result SetArtist(const std::string &artist);
3280922886Sopenharmony_ci    AVMetadata_Result SetAuthor(const std::string &author);
3380922886Sopenharmony_ci    AVMetadata_Result SetAlbum(const std::string &album);
3480922886Sopenharmony_ci    AVMetadata_Result SetWriter(const std::string &writer);
3580922886Sopenharmony_ci    AVMetadata_Result SetComposer(const std::string &composer);
3680922886Sopenharmony_ci    AVMetadata_Result SetDuration(int64_t duration);
3780922886Sopenharmony_ci    AVMetadata_Result SetMediaImageUri(const std::string &mediaImageUri);
3880922886Sopenharmony_ci    AVMetadata_Result SetSubtitle(const std::string &subtitle);
3980922886Sopenharmony_ci    AVMetadata_Result SetDescription(const std::string &description);
4080922886Sopenharmony_ci    AVMetadata_Result SetLyric(const std::string &lyric);
4180922886Sopenharmony_ci    AVMetadata_Result SetAssetId(const std::string &assetId);
4280922886Sopenharmony_ci    AVMetadata_Result SetSkipIntervals(AVMetadata_SkipIntervals intervals);
4380922886Sopenharmony_ci    AVMetadata_Result SetDisplayTags(int32_t tags);
4480922886Sopenharmony_ci    AVMetadata_Result GenerateAVMetadata(OH_AVMetadata** avMetadata);
4580922886Sopenharmony_ci
4680922886Sopenharmony_ciprivate:
4780922886Sopenharmony_ci    static bool CurlSetRequestOptions(std::vector<std::uint8_t>& imgBuffer, const std::string uri);
4880922886Sopenharmony_ci    static bool DoDownloadInCommon(std::shared_ptr<Media::PixelMap>& pixelMap, const std::string uri);
4980922886Sopenharmony_ci    static int32_t DoDownload(AVMetaData& meta, const std::string uri);
5080922886Sopenharmony_ci    static size_t WriteCallback(std::uint8_t *ptr, size_t size, size_t nmemb, std::vector<std::uint8_t> *imgBuffer);
5180922886Sopenharmony_ci    std::string title_ = "";
5280922886Sopenharmony_ci    std::string artist_ = "";
5380922886Sopenharmony_ci    std::string author_ = "";
5480922886Sopenharmony_ci    std::string album_ = "";
5580922886Sopenharmony_ci    std::string writer_ = "";
5680922886Sopenharmony_ci    std::string composer_ = "";
5780922886Sopenharmony_ci    int64_t duration_ = 0;
5880922886Sopenharmony_ci    std::string mediaImageUri_ = "";
5980922886Sopenharmony_ci    std::string subtitle_ = "";
6080922886Sopenharmony_ci    std::string description_ = "";
6180922886Sopenharmony_ci    std::string lyric_ = "";
6280922886Sopenharmony_ci    std::string assetId_ = "";
6380922886Sopenharmony_ci    AVMetadata_SkipIntervals intervals_ = SECONDS_15;
6480922886Sopenharmony_ci    int32_t tags_ = 0;
6580922886Sopenharmony_ci    static constexpr size_t TIME_OUT_SECOND = 5;
6680922886Sopenharmony_ci    static constexpr int HTTP_ERROR_CODE = 400;
6780922886Sopenharmony_ci};
6880922886Sopenharmony_ci}
6980922886Sopenharmony_ci
7080922886Sopenharmony_ci#endif // OHOS_OHAVSESSION_METADATA_H