1 /* 2 * Copyright (C) 2019 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 WRITER_UTILITY_H_ 18 #define WRITER_UTILITY_H_ 19 20 #include <fstream> 21 #include <iostream> 22 #include <vector> 23 24 #include <media/stagefright/foundation/ABuffer.h> 25 #include <media/stagefright/foundation/ADebug.h> 26 #include <media/stagefright/foundation/AMessage.h> 27 28 #include <media/stagefright/MediaAdapter.h> 29 30 #include "WriterListener.h" 31 32 #define CODEC_CONFIG_FLAG 32 33 34 constexpr uint32_t kMaxTrackCount = 2; 35 constexpr uint32_t kMaxCSDStrlen = 16; 36 constexpr uint32_t kMaxCount = 20; 37 constexpr int32_t kMimeSize = 128; 38 constexpr int32_t kDefaultInterleaveDuration = 0; 39 // Geodata is set according to ISO-6709 standard. 40 constexpr int32_t kDefaultLatitudex10000 = 500000; 41 constexpr int32_t kDefaultLongitudex10000 = 1000000; 42 constexpr float kDefaultFPS = 30.0f; 43 44 struct BufferInfo { 45 int32_t size; 46 uint32_t flags; 47 int64_t timeUs; 48 }; 49 50 struct configFormat { 51 char mime[kMimeSize]; 52 int32_t width; 53 int32_t height; 54 int32_t sampleRate; 55 int32_t channelCount; 56 }; 57 58 int32_t sendBuffersToWriter(ifstream &inputStream, vector<BufferInfo> &bufferInfo, 59 int32_t &inputFrameId, sp<MediaAdapter> ¤tTrack, int32_t offset, 60 int32_t range, bool isPaused = false, 61 sp<WriterListener> listener = nullptr); 62 63 int32_t writeHeaderBuffers(ifstream &inputStream, vector<BufferInfo> &bufferInfo, 64 int32_t &inputFrameId, sp<AMessage> &format, int32_t numCsds); 65 66 #endif // WRITER_UTILITY_H_ 67