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 __MUXER_H__ 18 #define __MUXER_H__ 19 20 #include <media/NdkMediaMuxer.h> 21 22 #include "BenchmarkCommon.h" 23 #include "Stats.h" 24 #include "Extractor.h" 25 26 typedef enum { 27 MUXER_OUTPUT_FORMAT_MPEG_4 = 0, 28 MUXER_OUTPUT_FORMAT_WEBM = 1, 29 MUXER_OUTPUT_FORMAT_3GPP = 2, 30 MUXER_OUTPUT_FORMAT_OGG = 4, 31 MUXER_OUTPUT_FORMAT_INVALID = 5, 32 } MUXER_OUTPUT_T; 33 34 class Muxer { 35 public: Muxer()36 Muxer() : mFormat(nullptr), mMuxer(nullptr), mStats(nullptr) { mExtractor = new Extractor(); } 37 ~Muxer()38 virtual ~Muxer() { 39 if (mStats) delete mStats; 40 if (mExtractor) delete mExtractor; 41 } 42 getStats()43 Stats *getStats() { return mStats; } getExtractor()44 Extractor *getExtractor() { return mExtractor; } 45 46 /* Muxer related utilities */ 47 int32_t initMuxer(int32_t fd, MUXER_OUTPUT_T outputFormat); 48 void deInitMuxer(); 49 void resetMuxer(); 50 51 /* Process the frames and give Muxed output */ 52 int32_t mux(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameSizes); 53 54 void dumpStatistics(string inputReference, string codecName = "", string statsFile = ""); 55 56 private: 57 AMediaFormat *mFormat; 58 AMediaMuxer *mMuxer; 59 Extractor *mExtractor; 60 Stats *mStats; 61 }; 62 63 #endif // __MUXER_H__ 64