Home | History | Annotate | Download | only in src
      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 #include "pvmf_format_type.h"
     19 
     20 #ifndef OSCL_DLL_H_INCLUDED
     21 #include "oscl_dll.h"
     22 #endif
     23 
     24 #include "pv_mime_string_utils.h"
     25 
     26 // Define entry point for this DLL
     27 OSCL_DLL_ENTRY_POINT_DEFAULT()
     28 
     29 OSCL_EXPORT_REF bool PVMFFormatType::isCompressed() const
     30 {
     31     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM) == 0) ||
     32             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM8) == 0) ||
     33             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM16) == 0) ||
     34             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM16_BE) == 0) ||
     35             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ULAW) == 0) ||
     36             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ALAW) == 0) ||
     37             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV420) == 0) ||
     38             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422) == 0) ||
     39             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422_INTERLEAVED_UYVY) == 0) ||
     40             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422_INTERLEAVED_YUYV) == 0) ||
     41             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB8) == 0) ||
     42             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB12) == 0) ||
     43             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB16) == 0) ||
     44             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB24) == 0))
     45     {
     46         // all uncompressed formats
     47         return false;
     48     }
     49 
     50     return true;
     51 }
     52 
     53 
     54 OSCL_EXPORT_REF bool PVMFFormatType::isAudio() const
     55 {
     56     //Standard audio media types from IANA.org
     57     if (oscl_strstr(iMimeStr.c_str(), "audio/") != NULL)
     58         return true;
     59 
     60     //PV internal audio media types
     61     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM) == 0) ||
     62             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM16_BE) == 0) ||
     63             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMR_IETF) == 0) ||
     64             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMRWB_IETF) == 0) ||
     65             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMR_IF2) == 0) ||
     66             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ADIF) == 0) ||
     67             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ADTS) == 0) ||
     68             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AAC_SIZEHDR) == 0) ||
     69             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MPEG4_AUDIO) == 0) ||
     70             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_3640) == 0) ||
     71             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_G726) == 0) ||
     72             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ASF_AMR) == 0) ||
     73             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ASF_MPEG4_AUDIO) == 0))
     74     {
     75         return true;
     76     }
     77 
     78     return  false;
     79 }
     80 
     81 OSCL_EXPORT_REF bool PVMFFormatType::isVideo() const
     82 {
     83     //Standard video media types from IANA
     84     if (oscl_strstr(iMimeStr.c_str(), "video/") != NULL)
     85     {
     86         // 3gp timed text has a mime as "video/3gpp-tt" we should return false in this case
     87         if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_3GPP_TIMEDTEXT) == 0))
     88         {
     89             return false;
     90         }
     91         return true;
     92     }
     93 
     94     //PV internal video media types
     95     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV420) == 0) ||
     96             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422) == 0) ||
     97             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422_INTERLEAVED_UYVY) == 0) ||
     98             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422_INTERLEAVED_YUYV) == 0) ||
     99             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB8) == 0) ||
    100             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB12) == 0) ||
    101             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB16) == 0) ||
    102             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB24) == 0) ||
    103             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_H264_VIDEO_RAW) == 0) ||
    104             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_H264_VIDEO_MP4) == 0))
    105     {
    106         return true;
    107     }
    108 
    109     return  false;
    110 }
    111 
    112 OSCL_EXPORT_REF bool PVMFFormatType::isImage() const
    113 {
    114     //Standard video media types from IANA
    115     if (oscl_strstr(iMimeStr.c_str(), "image/") != NULL)
    116         return true;
    117 
    118     //PV internal image media type
    119     if (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_M4V_IMAGE) == 0)
    120         return true;
    121 
    122     return false;
    123 }
    124 
    125 OSCL_EXPORT_REF bool PVMFFormatType::isText() const
    126 {
    127     if (oscl_strstr(iMimeStr.c_str(), "text/") != NULL)
    128         return true;
    129 
    130     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_3GPP_TIMEDTEXT) == 0))
    131     {
    132         return true;
    133     }
    134 
    135     return false;
    136 }
    137 
    138 OSCL_EXPORT_REF bool PVMFFormatType::isFile() const
    139 {
    140     //PV internal file format type
    141     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MPEG4FF) == 0) ||
    142             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_H223) == 0) ||
    143             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RTP) == 0) ||
    144             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMRFF) == 0) ||
    145             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AACFF) == 0) ||
    146             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MP3FF) == 0) ||
    147             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_WAVFF) == 0) ||
    148             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ASFFF) == 0) ||
    149             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RMFF) == 0) ||
    150             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DIVXFF) == 0) ||
    151             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MIDIFF) == 0) ||
    152             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AVIFF) == 0))
    153         return true;
    154 
    155     return false;
    156 }
    157 
    158 OSCL_EXPORT_REF bool PVMFFormatType::isRaw() const
    159 {
    160     //PV internal raw format type
    161     return (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_8BIT_RAW) == 0);
    162 }
    163 
    164 //return true if a media type is PV internal data source.
    165 OSCL_EXPORT_REF bool PVMFFormatType::isDataSource() const
    166 {
    167     //PV internal data source format type
    168     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_RTSP_URL) == 0) ||
    169             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_HTTP_URL) == 0) ||
    170             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_SDP_FILE) == 0) ||
    171             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_PVX_FILE) == 0) ||
    172             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL) == 0) ||
    173             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) == 0) ||
    174             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_RTP_PACKET_SOURCE) == 0))
    175         return true;
    176 
    177     return false;
    178 }
    179 
    180 //return true if a media type is PV user input.
    181 OSCL_EXPORT_REF bool PVMFFormatType::isUserInput() const
    182 {
    183     //PV user input format type
    184     if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_BASIC_STRING) == 0) ||
    185             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_IA5_STRING) == 0) ||
    186             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_GENERAL_STRING) == 0) ||
    187             (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_DTMF) == 0))
    188         return true;
    189 
    190     return false;
    191 }
    192