• 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 "pcma_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 SDPPCMAMediaInfoParser::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(pcma_mediaInfo), false);
36     if (NULL == memory)
37     {
38         return SDP_NO_MEMORY;
39     }
40     else
41     {
42         pcma_mediaInfo *pcmaA = OSCL_PLACEMENT_NEW(memory, pcma_mediaInfo());
43 
44         pcmaA->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 = pcmaA->alloc(sizeof(PcmaPayloadSpecificInfoType));
50             if (mem == NULL)
51             {
52                 return SDP_NO_MEMORY;
53             }
54             else
55             {
56                 PcmaPayloadSpecificInfoType* payload = OSCL_PLACEMENT_NEW(mem, PcmaPayloadSpecificInfoType(payload_vec[ii]));
57                 (void) payload;
58             }
59         }
60 
61 
62         SDP_ERROR_CODE status = baseMediaInfoParser(buff, pcmaA, index , false, false, isSipSdp);
63 
64         if (status != SDP_SUCCESS)
65         {
66             return status;
67         }
68 
69         // payloadNumber is present in the mediaInfo. get the payload
70         // Specific pointer corresponding to this payload
71         PcmaPayloadSpecificInfoType* payloadPtr = NULL;
72 
73         for (uint32 jj = 0; jj < payload_vec.size(); jj++)
74         {
75             payloadPtr = (PcmaPayloadSpecificInfoType*)pcmaA->getPayloadSpecificInfoTypePtr(payload_vec[jj]);
76             if (payloadPtr == NULL)
77                 return SDP_PAYLOAD_MISMATCH;
78 
79             payloadPtr->setSampleRate(8000);
80         }
81     }
82     return SDP_SUCCESS;
83 }
84 
85 //EnfOfFile
86 
87