1 /* 2 * Copyright (C) 2021 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 #ifndef I_AVMETADATAHELPER_ENGINE_H 17 #define I_AVMETADATAHELPER_ENGINE_H 18 19 #include "avmetadatahelper.h" 20 #include "i_avmetadatahelper_service.h" 21 22 namespace OHOS { 23 namespace Media { 24 class IAVMetadataHelperEngine { 25 public: 26 virtual ~IAVMetadataHelperEngine() = default; 27 28 /** 29 * Set the media source uri to use. Calling this method before the reset 30 * of the methods in this class. This method maybe time consuming. 31 * @param uri the URI of input media source. 32 * @param usage indicates which scene the avmedatahelper's instance will 33 * be used to, see {@link AVMetadataUsage}. If the usage need to be changed, 34 * this method must be called again. 35 * @return Returns {@link MSERR_OK} if the setting is successful; returns 36 * an error code otherwise. 37 */ 38 virtual int32_t SetSource(const std::string &uri, int32_t usage) = 0; 39 40 /** 41 * Retrieve the meta data associated with the specified key. This method must be 42 * called after the SetSource. 43 * @param key One of the constants listed above at the definition of {@link AVMetadataCode}. 44 * @return Returns the meta data value associate with the given key code on 45 * success; empty string on failure. 46 */ 47 virtual std::string ResolveMetadata(int32_t key) = 0; 48 49 /** 50 * Retrieve all meta data within the listed above at the definition of {@link AVMetadataCode}. 51 * This method must be called after the SetSource. 52 * @return Returns the meta data values on success; empty string on failure. 53 */ 54 virtual std::unordered_map<int32_t, std::string> ResolveMetadata() = 0; 55 56 /** 57 * Fetch the album art picture associated with the data source. If there are 58 * more than one pictures, the cover image will be returned preferably. 59 * @return Returns the a chunk of shared memory containing a picture, which can be 60 * null, if such a picture can not be fetched. 61 */ 62 virtual std::shared_ptr<AVSharedMemory> FetchArtPicture() = 0; 63 64 /** 65 * Fetch a representative video frame near a given timestamp by considering the given 66 * option if possible, and return a video frame with given parameters. This method must be 67 * called after the SetSource. 68 * @param timeMs The time position in microseconds where the frame will be fetched. 69 * When fetching the frame at the given time position, there is no guarantee that 70 * the video source has a frame located at the position. When this happens, a frame 71 * nearby will be returned. If timeUs is negative, time position and option will ignored, 72 * and any frame that the implementation considers as representative may be returned. 73 * @param option the hint about how to fetch a frame, see {@link AVMetadataQueryOption} 74 * @param param the desired configuration of returned video frame, see {@link OutputConfiguration}. 75 * @return Returns a chunk of shared memory containing a scaled video frame, which 76 * can be null, if such a frame cannot be fetched. 77 */ 78 virtual std::shared_ptr<AVSharedMemory> FetchFrameAtTime( 79 int64_t timeUs, int32_t option, const OutputConfiguration ¶m) = 0; 80 }; 81 } // namespace Media 82 } // namespace OHOS 83 84 #endif