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 #ifndef SDP_PARSER_H 20 #define SDP_PARSER_H 21 22 #include "oscl_types.h" 23 #include "oscl_mem.h" 24 #include "sdp_mediaparser_registry.h" 25 #include "sdp_mediaparser_factory.h" 26 #include "session_info_parser.h" 27 #include "base_media_info_parser.h" 28 #include "sdp_parsing_utils.h" 29 #include "sdp_memory.h" 30 #include "pvlogger.h" 31 32 const int MAX_PAYLOAD = 10; /*Defined arbitrarily*/ 33 const int MAX_STRING_LEN = 256; 34 35 typedef struct _SDPTrackInfo 36 { 37 mbchar codec_type[MAX_STRING_LEN]; /* MIME type of the data */ 38 int bitrate; /* data rate in kbps */ 39 int trackID; 40 uint8 majorVersion; 41 uint8 minorVersion; 42 } SDPTrackInfo; 43 44 typedef struct _playTime 45 { 46 int startTime; 47 int stopTime; 48 } playTime; 49 50 typedef struct _movieInfo 51 { 52 SDPTrackInfo TrackArray[MAX_PAYLOAD]; 53 int trackCount; 54 mbchar movieName[MAX_STRING_LEN]; 55 mbchar creationDate[MAX_STRING_LEN]; 56 playTime duration; 57 } movieInfo; 58 59 class SDP_Parser 60 { 61 private: 62 PVLogger* iLogger; 63 SDPMediaParserRegistry *& _pSDPMediaParserRegistry; 64 int mediaArrayIndex; 65 SDP_ERROR_CODE(*sessionParser)(const char *sdp_text, int length, SDPInfo& sdp); /*Used to parse session information*/ 66 bool applicationFlag; 67 68 bool parse_rtpmap(const char *start, const char *end, int& rtp_payload, 69 OsclMemoryFragment& encoding_name); 70 71 72 int validate_media_line(const char *start, const char *end, Oscl_Vector<int, SDPParserAlloc>& payload_type, uint32& portNumber); 73 74 // void print_memfrag(MemoryFragment& memfrag); 75 int convertToMilliSec(RtspRangeType range , int &startTime, int &stopTime); 76 bool isSipSdp; 77 public: 78 79 OSCL_IMPORT_REF 80 SDP_Parser(SDPMediaParserRegistry*& regTable, bool sipSdp = false); 81 82 OSCL_IMPORT_REF 83 ~SDP_Parser(); 84 85 OSCL_IMPORT_REF 86 SDP_ERROR_CODE parseSDP(const char *, int length , SDPInfo *sdp); 87 88 OSCL_IMPORT_REF 89 SDP_ERROR_CODE parseSDPDownload(const char *, int length, SDPInfo *sdp, movieInfo *mv); 90 91 OSCL_IMPORT_REF 92 int getNumberOfTracks(); 93 94 OSCL_IMPORT_REF 95 int setNumberOfTracks(int tracks); 96 97 OSCL_IMPORT_REF 98 bool allocateRegistrar(); //Used to allocate new parser. 99 100 }; 101 #endif 102