• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "pcmu_media_info_parser.h"
19 #include "oscl_string_utils.h"
20 #include "oscl_string_containers.h"
21 
22 SDP_ERROR_CODE
parseMediaInfo(const char * buff,const int index,SDPInfo * sdp,payloadVector payload_vec,bool isSipSdp,int alt_id,bool alt_def_id)23 SDPPCMUMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
24 {
25     OSCL_UNUSED_ARG(alt_id);
26     OSCL_UNUSED_ARG(alt_def_id);
27 
28     const char *current_start = buff; //Pointer to the beginning of the media text
29     const char *end = buff + index;   //Pointer to the end of the media text
30 
31     (void) current_start;
32     (void) end;
33 
34     //Allocate media info class here
35     void *memory = sdp->alloc(sizeof(pcmu_mediaInfo), false);
36     if (NULL == memory)
37     {
38         return SDP_NO_MEMORY;
39     }
40     else
41     {
42         pcmu_mediaInfo *pcmuA = OSCL_PLACEMENT_NEW(memory, pcmu_mediaInfo());
43 
44         pcmuA->setMediaInfoID(sdp->getMediaObjectIndex());
45 
46         // Allocate memory to the payload specific objects
47         for (uint32 ii = 0; ii < payload_vec.size(); ii++)
48         {
49             void* mem = pcmuA->alloc(sizeof(PcmuPayloadSpecificInfoType));
50             if (mem == NULL)
51             {
52                 return SDP_NO_MEMORY;
53             }
54             else
55             {
56                 PcmuPayloadSpecificInfoType* payload = OSCL_PLACEMENT_NEW(mem, PcmuPayloadSpecificInfoType(payload_vec[ii]));
57                 (void) payload;
58             }
59         }
60 
61 
62         SDP_ERROR_CODE status = baseMediaInfoParser(buff, pcmuA, index , false, false, isSipSdp);
63         if (status != SDP_SUCCESS)
64         {
65             return status;
66         }
67 
68         // payloadNumber is present in the mediaInfo. get the payload
69         // Specific pointer corresponding to this payload
70         PcmuPayloadSpecificInfoType* payloadPtr = NULL;
71 
72         for (uint32 jj = 0; jj < payload_vec.size(); jj++)
73         {
74             payloadPtr = (PcmuPayloadSpecificInfoType*)pcmuA->getPayloadSpecificInfoTypePtr(payload_vec[jj]);
75             if (payloadPtr == NULL)
76                 return SDP_PAYLOAD_MISMATCH;
77 
78             payloadPtr->setSampleRate(8000);
79         }
80     }
81     return SDP_SUCCESS;
82 }
83 
84 //EndOfFile
85 
86