1 /** 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef IMSMEDIA_JPEG_SOURCE_H_INCLUDED 18 #define IMSMEDIA_JPEG_SOURCE_H_INCLUDED 19 20 #include <android/asset_manager_jni.h> 21 22 class ImsMediaPauseImageSource 23 { 24 public: 25 ImsMediaPauseImageSource(); 26 ~ImsMediaPauseImageSource(); 27 28 /** 29 * @brief Based on the video resolution ( width x height ), an image asset with same 30 * resolution is loaded and converted to YUV format. 31 * 32 * @param width width of the video frames. 33 * @param height height of the video frames. 34 * @param stride stride of the video frames. 35 * 36 * @return returns true if the image is loaded and false in case of failure. 37 */ 38 bool Initialize(int width, int height, int stride); 39 40 /** 41 * @brief Image YUV buffer loaded in memory is freed. 42 */ 43 void Uninitialize(); 44 45 /** 46 * @brief Returns the Image buffer in YUV format. 47 * 48 * @param buffer Image buffer is copied to this buffer. 49 * @param len length of the input buffer. 50 * 51 * @return size of the image YUV data copied to input buffer. 52 */ 53 size_t GetYuvImage(uint8_t* buffer, size_t len); 54 55 private: 56 int mWidth, mHeight; 57 int8_t* mYuvImageBuffer; 58 size_t mBufferSize; 59 60 AAsset* getImageAsset(); 61 const char* getImageFilePath(); 62 int8_t* ConvertRgbaToYuv(int8_t* pixels, int width, int height, int stride); 63 }; 64 65 #endif // IMSMEDIA_JPEG_SOURCE_H_INCLUDED 66