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 "cj_avsession_media_description.h" 17 18 #include "avsession_errors.h" 19 #include "avsession_log.h" 20 #include "cj_avsession_utils.h" 21 22 namespace OHOS::AVSession { 23 FfiMediaDescriptionHelper()24FfiMediaDescriptionHelper::FfiMediaDescriptionHelper() {} 25 ~FfiMediaDescriptionHelper()26FfiMediaDescriptionHelper::~FfiMediaDescriptionHelper() {} 27 GetMediaDescriptionDisplayTags(CAVMediaDescription & mediaDescription)28int32_t FfiMediaDescriptionHelper::GetMediaDescriptionDisplayTags(CAVMediaDescription &mediaDescription) 29 { 30 std::string str(mediaDescription.mediaId); 31 if (displayTagsMap.count(str) <= 0) { 32 mediaDescription.displayTags = displayTagsMap[str]; 33 return CJNO_ERROR; 34 } 35 SLOGE("GetMediaDescriptionDisplayTags failed"); 36 return AVSESSION_ERROR; 37 } 38 SetMediaDescriptionDisplayTags(const CAVMediaDescription & mediaDescription)39int32_t FfiMediaDescriptionHelper::SetMediaDescriptionDisplayTags(const CAVMediaDescription &mediaDescription) 40 { 41 std::string str(mediaDescription.mediaId); 42 displayTagsMap[str] = mediaDescription.displayTags; 43 return CJNO_ERROR; 44 } 45 GetMediaDescriptionDataSrc(CAVMediaDescription & mediaDescription)46int32_t FfiMediaDescriptionHelper::GetMediaDescriptionDataSrc(CAVMediaDescription &mediaDescription) 47 { 48 std::string str(mediaDescription.mediaId); 49 if (dataSrcMap.count(str) <= 0) { 50 mediaDescription.dataSrc = dataSrcMap[str]; 51 return CJNO_ERROR; 52 } 53 SLOGE("GetMediaDescriptionDataSrc failed"); 54 return AVSESSION_ERROR; 55 } 56 SetMediaDescriptionDataSrc(const CAVMediaDescription & mediaDescription)57int32_t FfiMediaDescriptionHelper::SetMediaDescriptionDataSrc(const CAVMediaDescription &mediaDescription) 58 { 59 std::string str(mediaDescription.mediaId); 60 dataSrcMap[str] = mediaDescription.dataSrc; 61 return CJNO_ERROR; 62 } 63 64 } // namespace AVSession::OHOS