1 /* 2 * Copyright (C) 2014 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 /** 18 * @addtogroup Media 19 * @{ 20 */ 21 22 /** 23 * @file NdkMediaMuxer.h 24 */ 25 26 /* 27 * This file defines an NDK API. 28 * Do not remove methods. 29 * Do not change method signatures. 30 * Do not change the value of constants. 31 * Do not change the size of any of the classes defined in here. 32 * Do not reference types that are not part of the NDK. 33 * Do not #include files that aren't part of the NDK. 34 */ 35 36 #ifndef _NDK_MEDIA_MUXER_H 37 #define _NDK_MEDIA_MUXER_H 38 39 #include <sys/cdefs.h> 40 #include <sys/types.h> 41 42 #include "NdkMediaCodec.h" 43 #include "NdkMediaError.h" 44 #include "NdkMediaFormat.h" 45 46 __BEGIN_DECLS 47 48 struct AMediaMuxer; 49 typedef struct AMediaMuxer AMediaMuxer; 50 51 typedef enum { 52 AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4 = 0, 53 AMEDIAMUXER_OUTPUT_FORMAT_WEBM = 1, 54 AMEDIAMUXER_OUTPUT_FORMAT_THREE_GPP = 2, 55 } OutputFormat; 56 57 #if __ANDROID_API__ >= 21 58 59 /** 60 * Create new media muxer. 61 * 62 * Available since API level 21. 63 */ 64 AMediaMuxer* AMediaMuxer_new(int fd, OutputFormat format) __INTRODUCED_IN(21); 65 66 /** 67 * Delete a previously created media muxer. 68 * 69 * Available since API level 21. 70 */ 71 media_status_t AMediaMuxer_delete(AMediaMuxer*) __INTRODUCED_IN(21); 72 73 /** 74 * Set and store the geodata (latitude and longitude) in the output file. 75 * This method should be called before AMediaMuxer_start. The geodata is stored 76 * in udta box if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, and is 77 * ignored for other output formats. 78 * The geodata is stored according to ISO-6709 standard. 79 * 80 * Both values are specified in degrees. 81 * Latitude must be in the range [-90, 90]. 82 * Longitude must be in the range [-180, 180]. 83 * 84 * Available since API level 21. 85 */ 86 media_status_t AMediaMuxer_setLocation(AMediaMuxer*, 87 float latitude, float longitude) __INTRODUCED_IN(21); 88 89 /** 90 * Sets the orientation hint for output video playback. 91 * This method should be called before AMediaMuxer_start. Calling this 92 * method will not rotate the video frame when muxer is generating the file, 93 * but add a composition matrix containing the rotation angle in the output 94 * video if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, so that a 95 * video player can choose the proper orientation for playback. 96 * Note that some video players may choose to ignore the composition matrix 97 * during playback. 98 * The angle is specified in degrees, clockwise. 99 * The supported angles are 0, 90, 180, and 270 degrees. 100 * 101 * Available since API level 21. 102 */ 103 media_status_t AMediaMuxer_setOrientationHint(AMediaMuxer*, int degrees) __INTRODUCED_IN(21); 104 105 /** 106 * Adds a track with the specified format. 107 * Returns the index of the new track or a negative value in case of failure, 108 * which can be interpreted as a media_status_t. 109 * 110 * Available since API level 21. 111 */ 112 ssize_t AMediaMuxer_addTrack(AMediaMuxer*, const AMediaFormat* format) __INTRODUCED_IN(21); 113 114 /** 115 * Start the muxer. Should be called after AMediaMuxer_addTrack and 116 * before AMediaMuxer_writeSampleData. 117 * 118 * Available since API level 21. 119 */ 120 media_status_t AMediaMuxer_start(AMediaMuxer*) __INTRODUCED_IN(21); 121 122 /** 123 * Stops the muxer. 124 * Once the muxer stops, it can not be restarted. 125 * 126 * Available since API level 21. 127 */ 128 media_status_t AMediaMuxer_stop(AMediaMuxer*) __INTRODUCED_IN(21); 129 130 /** 131 * Writes an encoded sample into the muxer. 132 * The application needs to make sure that the samples are written into 133 * the right tracks. Also, it needs to make sure the samples for each track 134 * are written in chronological order (e.g. in the order they are provided 135 * by the encoder.) 136 * 137 * Available since API level 21. 138 */ 139 media_status_t AMediaMuxer_writeSampleData(AMediaMuxer *muxer, 140 size_t trackIdx, const uint8_t *data, 141 const AMediaCodecBufferInfo *info) __INTRODUCED_IN(21); 142 143 #endif /* __ANDROID_API__ >= 21 */ 144 145 __END_DECLS 146 147 #endif // _NDK_MEDIA_MUXER_H 148 149 /** @} */ 150