1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 /** 19 * @file pvmf_format_type.h 20 * @brief This file defines known format types and MIME strings, 21 * and some utilities for converting between them. 22 * 23 */ 24 25 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED 26 #define PVMF_FORMAT_TYPE_H_INCLUDED 27 28 #ifndef OSCL_BASE_H_INCLUDED 29 #include "oscl_base.h" 30 #endif 31 32 #ifdef __cplusplus 33 #ifndef OSCL_STRING_H_INCLUDED 34 #include "oscl_string.h" 35 #endif 36 37 #ifndef OSCL_STR_PTR_LEN_H_INCLUDED 38 #include "oscl_str_ptr_len.h" 39 #endif 40 41 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED 42 #include "oscl_string_containers.h" 43 #endif 44 45 /** PvmfMimeString is used in several PVMF APIs */ 46 typedef OSCL_String PvmfMimeString; 47 #endif 48 49 // MIME string for unknown format 50 #define PVMF_MIME_FORMAT_UNKNOWN "FORMATUNKNOWN" 51 52 /** 53 ** Note on format MIME strings: 54 ** The MIME strings that start with "X" were made up by PV. 55 ** The others came from: 56 ** http://www.iana.org/assignments/media-types/index.html. 57 ** The names were chosen to match the names of the PV format 58 ** index values. 59 **/ 60 61 /* Following are the recognized formats */ 62 63 // MIME strings for uncompressed audio formats 64 #define PVMF_MIME_PCM "X-PCM-GEN" 65 #define PVMF_MIME_PCM8 "audio/L8" 66 #define PVMF_MIME_PCM16 "audio/L16" 67 #define PVMF_MIME_PCM16_BE "X-PCM16-BE" 68 #define PVMF_MIME_ULAW "audio/PCMU" 69 #define PVMF_MIME_ALAW "audio/PCMA" 70 71 // MIME strings for uncompressed video formats 72 #define PVMF_MIME_YUV420 "X-YUV-420" 73 #define PVMF_MIME_YUV422 "X-YUV-422" 74 #define PVMF_MIME_RGB8 "X-RGB-8" 75 #define PVMF_MIME_RGB12 "X-RGB-12" 76 #define PVMF_MIME_RGB16 "X-RGB-16" 77 #define PVMF_MIME_RGB24 "X-RGB-24" 78 79 // MIME strings for uncompressed sub-video formats 80 #define PVMF_MIME_YUV420_PLANAR "X-YUV-420-PLANAR" 81 #define PVMF_MIME_YUV420_PACKEDPLANAR "X-YUV-420-PACKEDPLANAR" 82 #define PVMF_MIME_YUV420_SEMIPLANAR "X-YUV-420-SEMIPLANAR" 83 #define PVMF_MIME_YUV420_PACKEDSEMIPLANAR "X-YUV-420-PACKEDSEMIPLANAR" 84 #define PVMF_MIME_YUV422_PLANAR "X-YUV-422-PLANAR" 85 #define PVMF_MIME_YUV422_PACKEDPLANAR "X-YUV-422-PACKEDPLANAR" 86 #define PVMF_MIME_YUV422_SEMIPLANAR "X-YUV-422-SEMIPLANAR" 87 #define PVMF_MIME_YUV422_PACKEDSEMIPLANAR "X-YUV-422-PACKEDSEMIPLANAR" 88 #define PVMF_MIME_YUV422_INTERLEAVED_UYVY "X-YUV-422-INTERLEAVED-UYVY" 89 #define PVMF_MIME_YUV422_INTERLEAVED_YUYV "X-YUV-422-INTERLEAVED-YUYV" 90 #define PVMF_MIME_YUV420_SEMIPLANAR_YVU "X-YUV-420-SEMIPLANAR-YUV" 91 92 // MIME strings for compressed audio formats 93 #define PVMF_MIME_AMR "audio/AMR" // Streaming AMR format, aka IETF_COMBINED_TOC 94 #define PVMF_MIME_AMRWB "audio/AMR-WB" // AMR Wide Band 95 #define PVMF_MIME_AMR_IETF "X-AMR-IETF-SEPARATE" // Today's IETF 96 #define PVMF_MIME_AMRWB_IETF "X-AMRWB-IETF-SEPARATE" // Today's IETF 97 #define PVMF_MIME_AMR_IF2 "X-AMR-IF2" 98 #define PVMF_MIME_EVRC "audio/EVRC" // Streaming EVRC format 99 #define PVMF_MIME_MP3 "audio/MPEG" 100 #define PVMF_MIME_ADIF "X-AAC-ADIF" //.aac file format 101 #define PVMF_MIME_ADTS "X-AAC-ADTS" //.aac file format 102 #define PVMF_MIME_AAC_SIZEHDR "X-AAC-SIZEHDR" 103 #define PVMF_MIME_LATM "audio/MP4A-LATM" // Streaming AAC format 104 #define PVMF_MIME_MPEG4_AUDIO "X-MPEG4-AUDIO"// MPEG4 Audio (AAC) as stored in MPEG4 File 105 #define PVMF_MIME_G723 "audio/G723" 106 #define PVMF_MIME_G726 "x-pvmf/audio/g726" 107 //WMA Audio 108 #define PVMF_MIME_WMA "audio/x-ms-wma" 109 // AMR Audio from a asf file 110 #define PVMF_MIME_ASF_AMR "x-pvmf/audio/asf-amr" 111 // real audio 112 #define PVMF_MIME_REAL_AUDIO "audio/vnd.rn-realaudio" 113 // MPEG4 Audio from a asf file 114 #define PVMF_MIME_ASF_MPEG4_AUDIO "x-pvmf/audio/asf-mpeg4-audio" 115 #define PVMF_MIME_3640 "audio/mpeg4-generic" // Streaming AAC format 116 117 // MIME strings for Compressed video formats 118 #define PVMF_MIME_M4V "video/MP4V-ES"// MPEG4 Video 119 #define PVMF_MIME_H2631998 "video/H263-1998" 120 #define PVMF_MIME_H2632000 "video/H263-2000" 121 //Raw 264 files (.264 - stored as per byte stream format) 122 #define PVMF_MIME_H264_VIDEO_RAW "X-H264-BYTE-STREAM" 123 //H264 tracks as stored in MP4/3GP files 124 #define PVMF_MIME_H264_VIDEO_MP4 "X-H264-VIDEO" 125 //H263 streamed as per RFC 3984 126 #define PVMF_MIME_H264_VIDEO "video/H264" 127 // WMV7, WMV8, WMV9 128 #define PVMF_MIME_WMV "video/x-ms-wmv" 129 // RV8, RV0 130 #define PVMF_MIME_REAL_VIDEO "video/vnd.rn-realvideo" 131 132 // MIME strings for still image formats 133 #define PVMF_MIME_M4V_IMAGE "X-M4V-IMAGE" // PV Proprietary Still Image 134 #define PVMF_MIME_IMAGE_FORMAT "image" 135 136 // MIME strings for Multiplexed formats and single-media file formats. 137 #define PVMF_MIME_MPEG4FF "video/MP4" 138 #define PVMF_MIME_H223 "X-H223" 139 #define PVMF_MIME_RTP "X-RTP" 140 #define PVMF_MIME_AMRFF "X-AMR-FF" 141 #define PVMF_MIME_AACFF "X-AAC-FF" 142 #define PVMF_MIME_MP3FF "X-MP3-FF" 143 #define PVMF_MIME_WAVFF "X-WAV-FF" 144 #define PVMF_MIME_ASFFF "x-pvmf/mux/asf" 145 #define PVMF_MIME_RMFF "x-pvmf/mux/rm" 146 #define PVMF_MIME_DIVXFF "x-pvmf/mux/divx" 147 #define PVMF_MIME_MIDIFF "application/x-midi" 148 #define PVMF_MIME_AVIFF "x-pvmf/mux/avi" 149 #define PVMF_MIME_DATA_PVRFF "video/x-pvmf-pvr " 150 151 // MIME strings for RAW data formats 152 #define PVMF_MIME_8BIT_RAW "X-RAW-8" 153 154 // MIME strings for PVMF data source types 155 #define PVMF_MIME_DATA_SOURCE_RTSP_URL "X-PVMF-DATA-SRC-RTSP-URL" 156 #define PVMF_MIME_DATA_SOURCE_RTSP_PVR_FCS_URL "X-PVMF-DATA-SRC-RTSP-PVR-FCS-URL" 157 #define PVMF_MIME_DATA_SOURCE_HTTP_URL "X-PVMF-DATA-SRC-HTTP-URL" 158 #define PVMF_MIME_DATA_SOURCE_SDP_FILE "X-PVMF-DATA-SRC-SDP-FILE" 159 #define PVMF_MIME_DATA_SOURCE_SDP_PVR_FCS_FILE "X-PVMF-DATA-SRC-SDP-PVR-FCS-FILE" 160 #define PVMF_MIME_DATA_SOURCE_SDP_BROADCAST "X-PVMF-DATA-SRC-SDP-BROADCAST" 161 #define PVMF_MIME_DATA_SOURCE_PVX_FILE "X-PVMF-DATA-SRC-PVX-FILE" 162 #define PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL "X-PVMF-DATA-SRC-MS-HTTP-STREAMING-URL" 163 #define PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL "X-PVMF-DATA-SRC-REAL-HTTP-CLOAKING-URL" 164 #define PVMF_MIME_DATA_SOURCE_RTP_PACKET_SOURCE "X-PVMF-DATA-SRC-RTP-PACKET" 165 #define PVMF_MIME_DATA_SOURCE_SHOUTCAST_URL "X-PVMF-DATA-SRC-SHOUTCAST-URL" 166 #define PVMF_MIME_DATA_SOURCE_UNKNOWN_URL "X-PVMF-DATA-SRC-UNKNOWN-URL" 167 168 169 // MIME string for miscellaneous media data formats 170 #define PVMF_MIME_3GPP_TIMEDTEXT "video/3gpp-tt" 171 172 // MIME string for protocol formats 173 #define PVMF_MIME_INET_UDP "X-PVMF-NET-INET-UDP" 174 #define PVMF_MIME_INET_TCP "X-PVMF-NET-INET-TCP" 175 #define PVMF_MIME_RTSP "X-PVMF-NET-INET-RTSP" 176 #define PVMF_MIME_RTCP "X-PVMF-NET-INET-RTCP" 177 178 // reserved for 2way 179 #define PVMF_MIME_USERINPUT_BASIC_STRING "x-pvmf/userinput/basic-string" 180 #define PVMF_MIME_USERINPUT_IA5_STRING "x-pvmf/userinput/ia5-string" 181 #define PVMF_MIME_USERINPUT_GENERAL_STRING "x-pvmf/userinput/general-string" 182 #define PVMF_MIME_USERINPUT_DTMF "x-pvmf/userinput/dtmf" 183 184 185 class PVMFFormatType 186 { 187 public: 188 // default constructor PVMFFormatType()189 PVMFFormatType() : iCompressed(false), iMimeStr(PVMF_MIME_FORMAT_UNKNOWN) 190 {} 191 192 PVMFFormatType(const char* mimeStrPtr, bool compressed = false) 193 { 194 iStr = OSCL_HeapString<OsclMemAllocator> (mimeStrPtr); 195 iMimeStr = iStr.get_cstr(); 196 iCompressed = compressed; 197 } 198 199 PVMFFormatType(const char* mimeStrPtr, int32 mimeStrLen, bool compressed = false) 200 { 201 iStr = OSCL_HeapString<OsclMemAllocator> (mimeStrPtr, mimeStrLen); 202 iMimeStr.setPtrLen(iStr.get_cstr(), iStr.get_size()); 203 iCompressed = compressed; 204 } 205 206 PVMFFormatType& operator=(const PVMFFormatType& rhs) 207 { 208 iStr = OSCL_HeapString<OsclMemAllocator> (rhs.getMIMEStrPtr(), rhs.getMIMEStrLen()); 209 iMimeStr.setPtrLen(iStr.get_cstr(), iStr.get_size()); 210 iCompressed = rhs.isCompressed(); 211 return *this; 212 } 213 214 PVMFFormatType& operator=(const char* mimeStrPtr) 215 { 216 iStr = OSCL_HeapString<OsclMemAllocator> (mimeStrPtr); 217 iMimeStr = iStr.get_cstr(); 218 return *this; 219 } 220 ~PVMFFormatType()221 virtual ~PVMFFormatType() {}; 222 223 // case insensitive comparision 224 c_bool operator==(const PVMFFormatType& rhs) const 225 { 226 return iMimeStr.isCIEquivalentTo(rhs.getStrCSumPtr()); 227 } 228 229 bool operator!=(const PVMFFormatType& rhs) const 230 { 231 return !(*this == rhs); 232 } 233 234 void setCompressed(bool compressed = false) 235 { 236 iCompressed = compressed; 237 } 238 getMIMEStrPtr()239 const char* getMIMEStrPtr() const 240 { 241 return iMimeStr.c_str(); 242 } 243 getMIMEStrLen()244 int32 getMIMEStrLen() const 245 { 246 return iMimeStr.length(); 247 } 248 getStrCSumPtr()249 const StrCSumPtrLen& getStrCSumPtr() const 250 { 251 return iMimeStr; 252 } 253 254 //return true if it is a compressed Media 255 OSCL_IMPORT_REF bool isCompressed() const; 256 257 //return true if a media type is IANA audio format or PV internal audio format. 258 OSCL_IMPORT_REF bool isAudio() const; 259 260 //return true if a media type is IANA video format or PV internal video format. 261 OSCL_IMPORT_REF bool isVideo() const; 262 263 //return true if a media type is image format or PV internal image format. 264 OSCL_IMPORT_REF bool isImage() const; 265 266 //return true if a media type is IANA text format. 267 OSCL_IMPORT_REF bool isText() const; 268 269 //return true if a media type is PV internal file format. 270 OSCL_IMPORT_REF bool isFile() const; 271 272 //return true if a media type is PV internal raw format. 273 OSCL_IMPORT_REF bool isRaw() const; 274 275 //return true if a media type is PV internal data source. 276 OSCL_IMPORT_REF bool isDataSource() const; 277 278 //return true if a media type is PV internal data source. 279 OSCL_IMPORT_REF bool isUserInput() const; 280 281 // a flag to indicate if a media type described by the MIME is compressed 282 // this value should be passed in because this class does not have the 283 // ability to determine if a given media type, especially a format from 284 // the third party??? 285 bool iCompressed; 286 287 protected: 288 // a local storage for MIME string 289 OSCL_HeapString<OsclMemAllocator> iStr; 290 StrCSumPtrLen iMimeStr; 291 292 }; 293 294 #endif 295