• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "test_metadata.h"
17 #include <fcntl.h>
18 #include <iostream>
19 #include "directory_ex.h"
20 
21 using namespace std;
22 using namespace OHOS;
23 using namespace Media;
24 
TestMetadata()25 TestMetadata::TestMetadata()
26 {
27 }
28 
~TestMetadata()29 TestMetadata::~TestMetadata()
30 {
31 }
32 
MetaDataSetSource(const string & path,std::shared_ptr<AVMetadataHelper> avmetadata)33 int32_t TestMetadata::MetaDataSetSource(const string &path, std::shared_ptr<AVMetadataHelper> avmetadata)
34 {
35     int32_t fdMetaDataSetSource = open(path.c_str(), O_RDONLY);
36     if (fdMetaDataSetSource < 0) {
37         (void)close(fdMetaDataSetSource);
38         return -1;
39     }
40     int64_t offsetMetaDataSetSource = 0;
41     struct stat64 buffer;
42     if (fstat64(fdMetaDataSetSource, &buffer) != 0) {
43         (void)close(fdMetaDataSetSource);
44         return -1;
45     }
46     int64_t sizeMetaDataSetSource = static_cast<int64_t>(buffer.st_size);
47     int32_t usageMetaDataSetSource = AVMetadataUsage::AV_META_USAGE_PIXEL_MAP;
48     int32_t retSetSource = avmetadata -> SetSource(fdMetaDataSetSource,
49         offsetMetaDataSetSource, sizeMetaDataSetSource, usageMetaDataSetSource);
50     if (retSetSource != 0) {
51         (void)close(fdMetaDataSetSource);
52         return -1;
53     }
54     return 0;
55 }