1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <sstream> 17 #include <string> 18 #include "hcodec_utils.h" 19 20 namespace OHOS::MediaAVCodec { StringifyMeta(std::shared_ptr<Media::Meta> &meta)21std::string StringifyMeta(std::shared_ptr<Media::Meta> &meta) 22 { 23 std::stringstream dumpStream; 24 for (auto iter = meta->begin(); iter != meta->end(); ++iter) { 25 switch (meta->GetValueType(iter->first)) { 26 case OHOS::Media::AnyValueType::INT32_T: 27 dumpStream << iter->first << " = " << std::to_string(Media::AnyCast<int32_t>(iter->second)) << " | "; 28 break; 29 case OHOS::Media::AnyValueType::UINT32_T: 30 dumpStream << iter->first << " = " << std::to_string(Media::AnyCast<uint32_t>(iter->second)) << " | "; 31 break; 32 case OHOS::Media::AnyValueType::BOOL: 33 dumpStream << iter->first << " = " << std::to_string(Media::AnyCast<bool>(iter->second)) << " | "; 34 break; 35 case OHOS::Media::AnyValueType::DOUBLE: 36 dumpStream << iter->first << " = " << std::to_string(Media::AnyCast<double>(iter->second)) << " | "; 37 break; 38 case OHOS::Media::AnyValueType::INT64_T: 39 dumpStream << iter->first << " = " << std::to_string(Media::AnyCast<int64_t>(iter->second)) << " | "; 40 break; 41 case OHOS::Media::AnyValueType::FLOAT: 42 dumpStream << iter->first << " = " << std::to_string(Media::AnyCast<float>(iter->second)) << " | "; 43 break; 44 default: 45 dumpStream << iter->first << " = " << "unknown type | "; 46 break; 47 } 48 } 49 return dumpStream.str(); 50 } 51 } 52