multimediacommsengine/mmcecli/src/mcesessionutility.cpp
author vnuitven <>
Mon, 06 Sep 2010 17:32:13 +0530
branchrcs
changeset 49 64c62431ac08
permissions -rw-r--r--
RCS feature support in MCE/MCC. Provides APIs to do RCS chat and file transfer as per RCS specificaitons. For both os these MCE uses the MSRP protocol.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     1
/*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     2
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     3
* All rights reserved.
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     8
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     9
* Initial Contributors:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    11
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    12
* Contributors:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    13
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    14
* Description:  
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    15
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    16
*/
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    17
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    18
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    19
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    20
#include <badesca.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    21
#include <mcesession.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    22
#include <uri8.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    23
#include <sdpcodecstringpool.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    24
#include <SdpAttributeField.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    25
#include <sdpdocument.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    26
#include "mceclilogs.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    27
#include "mcecomsession.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    28
#include "mcecommediastream.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    29
#include "mcesessionutility.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    30
#include <SdpCodecStringPool.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    31
#include <stringpool.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    32
#include "mcecommediastream.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    33
#include <mcertpsource.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    34
#include <mcemsrpsource.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    35
#include <sdpconnectionfield.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    36
#include <sdpbandwidthfield.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    37
#include <mcertpsource.h>
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    38
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    39
//# define _OPEN_SDPCODEC_STRINGPOOL  SdpCodecStringPool::OpenL()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    40
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    41
#define _CLOSE_SDPCODEC_STRINGPOOL   SdpCodecStringPool::Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    42
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    43
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    44
// ============================ MEMBER FUNCTIONS ===============================
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    45
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    46
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    47
// TMceSessionUtility::getSessionSdPLineL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    48
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    49
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    50
EXPORT_C HBufC8* TMceSessionUtility::getSessionSdPLineL(CMceSession* aSession, 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    51
        TSDPLineName aSdpLineName)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    52
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    53
    __ASSERT_ALWAYS(aSession, User::Leave(KErrArgument));    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    54
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    55
    // Ownership is tranferred to us for sessionLines
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    56
    CDesC8Array* sessionLines = static_cast<CDesC8Array*> (aSession->SessionSDPLinesL());
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    57
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    58
    if (sessionLines->MdcaCount() == 0)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    59
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    60
        MCECLI_DEBUG("TMceSessionUtility::getSessionSdPLineL: No session attributes set in the passed session \n");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    61
        sessionLines->Reset();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    62
        delete sessionLines;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    63
        return NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    64
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    65
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    66
    // Open SIP coec string pool
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    67
    TRAPD(error, SdpCodecStringPool::OpenL());
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    68
    if (error != KErrAlreadyExists && error != KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    69
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    70
        delete sessionLines;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    71
        User::Leave(error);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    72
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    73
    CSdpDocument* sdpDoc = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    74
    CleanupStack::PushL(sessionLines);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    75
    ConstructSdpDocumentL(sessionLines, sdpDoc); 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    76
    CleanupStack::Pop(sessionLines);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    77
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    78
    HBufC8* retValue = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    79
    switch(aSdpLineName)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    80
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    81
        case EVersion:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    82
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    83
            TInt value = sdpDoc->SdpVersion();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    84
            TBuf8<10> tmp;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    85
            tmp.Num(value);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    86
            retValue = tmp.AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    87
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    88
            break;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    89
         
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    90
        case ESession:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    91
            retValue = sdpDoc->SessionName().AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    92
            break;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    93
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    94
        case EInfo:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    95
            retValue = sdpDoc->Info().AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    96
            break;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    97
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    98
        case EUri:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    99
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   100
            // Ownership will not be transferred to us so shouldn't delete the pointer
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   101
            CUri8* uri = sdpDoc->Uri();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   102
            if (uri != NULL)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   103
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   104
                retValue = uri->Uri().UriDes().AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   105
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   106
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   107
            break;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   108
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   109
        case EZone:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   110
            retValue = sdpDoc->ZoneAdjustments().AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   111
            break;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   112
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   113
        default:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   114
            sessionLines->Reset();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   115
            delete sessionLines;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   116
            delete sdpDoc;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   117
            _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   118
            User::Leave(KErrNotSupported);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   119
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   120
    sessionLines->Reset();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   121
    delete sessionLines;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   122
    delete sdpDoc;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   123
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   124
    if (error == KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   125
        _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   126
    __ASSERT_ALWAYS(retValue!=NULL, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   127
    return retValue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   128
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   129
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   130
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   131
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   132
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   133
// TMceSessionUtility::getRemoteMediaSDPAttrL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   134
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   135
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   136
EXPORT_C HBufC8* TMceSessionUtility::getRemoteMediaSDPAttrL(CMceMediaStream* aStream,
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   137
                const TDesC8& aAttrName)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   138
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   139
    __ASSERT_ALWAYS(aStream, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   140
    // Ownership is not transferred to us
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   141
    CMceSession* session = aStream->Session();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   142
    __ASSERT_ALWAYS(session, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   143
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   144
	if ( (session->State() >= CMceSession::ECancelling) || 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   145
		(session->State() <= CMceSession::EIdle) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   146
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   147
        MCECLI_DEBUG(" Session state shouldn't be idle Or shouldn't be either in cancelling, terminating , terminated  \n");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   148
        User::Leave(KErrArgument);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   149
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   150
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   151
    CDesC8Array* mediaAttrs = NULL; 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   152
    mediaAttrs = aStream->FlatData()->iRemoteMediaSDPLines;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   153
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   154
    if (mediaAttrs == NULL || mediaAttrs->MdcaCount() == 0)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   155
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   156
        if (aStream->BoundStream())
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   157
			{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   158
			mediaAttrs = aStream->BoundStreamL().FlatData()->iRemoteMediaSDPLines;		
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   159
			}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   160
		}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   161
		
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   162
	if (mediaAttrs == NULL || mediaAttrs->MdcaCount() == 0)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   163
		{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   164
		// Look for the another staream of same type to extract the remote media sdp attributes
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   165
        CMceMediaStream* tempStrm;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   166
        for(TInt i=0; i<session->Streams().Count(); i++)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   167
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   168
            tempStrm = session->Streams()[i];
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   169
            if (tempStrm != aStream && (tempStrm->Type() == aStream->Type()) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   170
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   171
                mediaAttrs = tempStrm->FlatData()->iRemoteMediaSDPLines;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   172
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   173
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   174
        if (mediaAttrs == NULL || mediaAttrs->MdcaCount() == 0)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   175
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   176
            MCECLI_DEBUG("TMceSessionUtility::getRemoteMediaSDPAttrL: No Remote Media SDP attributes set to the streams \n");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   177
            return NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   178
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   179
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   180
    //_OPEN_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   181
    TRAPD(error, SdpCodecStringPool::OpenL());
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   182
    if (error != KErrAlreadyExists && error != KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   183
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   184
        User::Leave(error);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   185
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   186
    // If the attribute is found then the value will be in aValue.
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   187
    HBufC8* value = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   188
    value = FindAttributeL(mediaAttrs, aAttrName);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   189
    if (error == KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   190
        _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   191
    return value;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   192
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   193
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   194
 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   195
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   196
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   197
// TMceSessionUtility::GetLocalConnectionAddrL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   198
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   199
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   200
EXPORT_C void TMceSessionUtility::GetLocalConnectionAddrL(CMceSession* aSess, TInetAddr& aAddr)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   201
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   202
    __ASSERT_ALWAYS(aSess, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   203
    aAddr = aSess->FlatData()->iLocalIpAddress;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   204
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   205
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   206
 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   207
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   208
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   209
// TMceSessionUtility::GetRemoteConnectionAddrL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   210
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   211
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   212
EXPORT_C HBufC8* TMceSessionUtility::GetRemoteConnectionAddrL(CMceMediaStream* aStream/*, TDesC8* hostAddr*/)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   213
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   214
    CMceSession* session = aStream->Session();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   215
    __ASSERT_ALWAYS(session, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   216
    if ( (session->State() >= CMceSession::ECancelling) || 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   217
            (session->State() <= CMceSession::EIdle) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   218
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   219
        MCECLI_DEBUG("TMceSessionUtility::GetRemoteConnectionAddrL: Session state shouldn't be idle Or shouldn't be either in cancelling, terminating , terminated");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   220
        User::Leave(KErrArgument);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   221
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   222
    TBuf8<10> attrName;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   223
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   224
    if (aStream->Type() == KMceMessage)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   225
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   226
        // Get the remote end's path attribute and extracts the host number from that
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   227
        //ownership willbe transferred to us so have to free up later
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   228
        HBufC8* pathValue = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   229
        attrName.Zero();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   230
        attrName.Copy(_L8("path"));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   231
        pathValue = TMceSessionUtility::getRemoteMediaSDPAttrL(aStream, attrName);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   232
        if (NULL!=pathValue)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   233
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   234
            TUriParser8 parser;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   235
            TInt parseValue = parser.Parse(*pathValue); 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   236
                    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   237
            MCECLI_DEBUG_DVALUE("\n CMceMessageSdpCodec::SetHostAddrPortFromPathAttr: Parsed return value for MSRP URI: ", 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   238
                    parseValue);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   239
                
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   240
            User::LeaveIfError(parseValue);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   241
            //TBuf8<50> host = parser.Extract(EUriHost);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   242
            HBufC8* hostAddr = parser.Extract(EUriHost).AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   243
            delete pathValue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   244
            return hostAddr;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   245
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   246
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   247
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   248
    // check if c line exists for the m-line correspands to this stream
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   249
    attrName.Zero();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   250
    attrName.Copy(_L8("c"));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   251
    HBufC8* hostAddr = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   252
    hostAddr = TMceSessionUtility::getRemoteMediaSDPAttrL(aStream, attrName);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   253
    if (hostAddr!=NULL)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   254
        return hostAddr;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   255
    else
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   256
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   257
        TBuf<32> addr;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   258
        session->FlatData()->iRemoteIpAddress.Output(addr);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   259
        TBuf8<32> value;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   260
        value.Copy(addr);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   261
        return value.AllocL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   262
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   263
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   264
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   265
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   266
// TMceSessionUtility::GetLocalMediaPortL   
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   267
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   268
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   269
EXPORT_C void TMceSessionUtility::GetLocalMediaPortL(CMceMediaStream* aStream, TUint& aMediaPort )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   270
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   271
    MCECLI_DEBUG("TMceSessionUtility::GetLocalMediaPortL: Entry ");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   272
    __ASSERT_ALWAYS(aStream!=NULL, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   273
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   274
	if ( (aStream->Session()->State() >= CMceSession::ECancelling) || 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   275
			(aStream->Session()->State() <= CMceSession::EIdle) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   276
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   277
        MCECLI_DEBUG("TMceSessionUtility::GetRemoteConnectionAddrL :  Session state shouldn't be idle Or shouldn't be either in cancelling, terminating , terminated");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   278
        User::Leave(KErrArgument);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   279
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   280
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   281
	aMediaPort = aStream->FlatData()->LocalMediaPort();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   282
	MCECLI_DEBUG_DVALUE("TMceSessionUtility::GetLocalMediaPortL : ", aMediaPort)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   283
	MCECLI_DEBUG("TMceSessionUtility::GetLocalMediaPortL: Exit ");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   284
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   285
         
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   286
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   287
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   288
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   289
// TMceSessionUtility::GetRemoteMediaPortL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   290
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   291
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   292
EXPORT_C void TMceSessionUtility::GetRemoteMediaPortL(CMceMediaStream* aStream, 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   293
        TUint& aMediaPort )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   294
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   295
    MCECLI_DEBUG("TMceSessionUtility::GetRemoteMediaPortL: Entry ");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   296
    __ASSERT_ALWAYS(aStream!=NULL, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   297
    CMceSession* session = aStream->Session();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   298
    __ASSERT_ALWAYS(session, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   299
    if ( (session->State() >= CMceSession::ECancelling) || 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   300
            (session->State() <= CMceSession::EIdle) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   301
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   302
        MCECLI_DEBUG("TMceSessionUtility::GetRemoteConnectionAddrL :  Session state shouldn't be idle Or shouldn't be either in cancelling, terminating , terminated");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   303
        User::Leave(KErrArgument);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   304
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   305
    if (aStream->Type() == KMceMessage)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   306
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   307
        TBuf8<10> aAttrName(_L8("path"));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   308
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   309
        // Get the remote end's path attribute and extracts the port number from that
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   310
        //ownership willbe transferred to us so have to free up later
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   311
        HBufC8* pathValue = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   312
        pathValue = TMceSessionUtility::getRemoteMediaSDPAttrL(aStream, aAttrName);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   313
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   314
        if (pathValue == NULL)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   315
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   316
            aMediaPort = aStream->FlatData()->RemoteMediaPort();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   317
            return;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   318
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   319
        // 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   320
        TUriParser8 parser;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   321
        TInt parseValue = parser.Parse(pathValue->Des()); 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   322
        MCECLI_DEBUG_DVALUE("\n CMceMsrpSource::SetHostAddrPortFromPathAttr: Parsed return value for MSRP URI: ",
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   323
                parseValue);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   324
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   325
        TBuf8<10> portBuf = parser.Extract(EUriPort);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   326
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   327
        TBuf16<10> portBuf16;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   328
        portBuf16.Copy(portBuf);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   329
        TLex iLex(portBuf16);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   330
        iLex.Val(aMediaPort);  // returns the port value
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   331
        delete pathValue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   332
        return;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   333
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   334
    else
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   335
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   336
        // Get send streams  and use remotemediaport
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   337
        if ( aStream->Source()->Type() == KMceRTPSource)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   338
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   339
            // find the send stream and get the remote media port
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   340
            if (aStream->BoundStream() && 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   341
                    aStream->BoundStreamL().Source() != NULL &&
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   342
                    aStream->BoundStreamL().Source()->Type() != KMceRTPSource)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   343
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   344
                aMediaPort = aStream->BoundStreamL().FlatData()->RemoteMediaPort();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   345
                return;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   346
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   347
            // if the streams are not binded then find the send stream aong the session streams
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   348
            for (TInt i=0; i<session->Streams().Count(); i++)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   349
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   350
                if (session->Streams()[i]!=NULL && (session->Streams()[i]!=aStream) &&
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   351
                        session->Streams()[i]->Type() == aStream->Type())
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   352
                    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   353
                    if (session->Streams()[i]->Source()->Type()!=KMceRTPSource)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   354
                        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   355
                        aMediaPort = session->Streams()[i]->FlatData()->RemoteMediaPort();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   356
                        return;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   357
                        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   358
                    } // inside if
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   359
                } // For loop
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   360
            } // 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   361
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   362
    aMediaPort = aStream->FlatData()->RemoteMediaPort();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   363
    MCECLI_DEBUG_DVALUE("TMceSessionUtility::GetRemoteMediaPortL : ", aMediaPort)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   364
    MCECLI_DEBUG("TMceSessionUtility::GetRemoteMediaPortL: Exit ");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   365
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   366
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   367
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   368
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   369
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   370
// TMceSessionUtility::FindAttributeL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   371
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   372
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   373
HBufC8* TMceSessionUtility::FindAttributeL(CDesC8Array* asdpLines , const TDesC8& aAttrName)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   374
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   375
    // Put all those session level names in single DesC8 object and pass that to CSdpDocument
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   376
    TBool attrFound = EFalse; 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   377
    CSdpAttributeField* attr=NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   378
    RStringF searchAttr = SdpCodecStringPool::StringPoolL().OpenFStringL(aAttrName);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   379
    HBufC8* retValue = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   380
    for (TInt i=0; i< asdpLines->MdcaCount()&& !attrFound; i++)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   381
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   382
        TBuf8<200> attrText(asdpLines->MdcaPoint(i));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   383
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   384
        // media attrivutes can also contain 'b' &'c' lines so skip them 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   385
        _LIT8( KMceSdpConnectionLineMarker, "c=" );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   386
        _LIT8( KMceSdpBandwidthLineMarker, "b=" );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   387
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   388
        // Look for media specific conneciton(c= ) line
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   389
        if ( (attrText.Find(KMceSdpConnectionLineMarker) >= 0) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   390
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   391
            if (attrText.Find(aAttrName) >= 0) 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   392
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   393
                // get the conneciton filed value 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   394
                CSdpConnectionField* conn = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   395
                TRAPD(err, conn = CSdpConnectionField::DecodeL(attrText));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   396
                if (err != KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   397
                    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   398
                    searchAttr.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   399
                    _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   400
                    User::Leave(err);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   401
                    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   402
                __ASSERT_ALWAYS(conn!=NULL, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   403
                retValue = conn->Address().Alloc();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   404
                attrFound = ETrue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   405
                delete conn; // Free the memory for conn pointer
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   406
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   407
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   408
        // Look for media specific bandwidth(b= ) line
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   409
        else if ( (attrText.Find(KMceSdpBandwidthLineMarker) >= 0) )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   410
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   411
            if ((attrText.Find(aAttrName) >= 0))
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   412
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   413
                // get the bandwidth filed and return the value
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   414
                CSdpBandwidthField* bandWidth = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   415
                TRAPD(err, bandWidth = CSdpBandwidthField::DecodeL(attrText));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   416
                if (err != KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   417
                    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   418
                    searchAttr.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   419
                    _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   420
                    User::Leave(err);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   421
                    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   422
                __ASSERT_ALWAYS(bandWidth!=NULL, User::Leave(KErrArgument));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   423
                TBuf8<20> value;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   424
                value.Num(bandWidth->Value());
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   425
                retValue = value.Alloc();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   426
                attrFound = ETrue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   427
                delete bandWidth;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   428
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   429
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   430
        else
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   431
            // Look for media specific attribute(a= ) lines
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   432
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   433
            // Have to free up later point of time
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   434
            TRAPD(err, attr = CSdpAttributeField::DecodeL(attrText));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   435
            if (err != KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   436
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   437
                searchAttr.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   438
                _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   439
                User::Leave(err);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   440
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   441
            if (attr == NULL)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   442
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   443
                MCECLI_DEBUG("TMceSessionUtility::FindAttributeL: Error in decoding the media attribute : ");
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   444
                searchAttr.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   445
                _CLOSE_SDPCODEC_STRINGPOOL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   446
                User::Leave(KErrArgument);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   447
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   448
            if (attr->Attribute() ==  searchAttr && !attrFound)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   449
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   450
                retValue = attr->Value().Alloc();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   451
                attrFound = ETrue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   452
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   453
            delete attr;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   454
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   455
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   456
    if (attrFound == EFalse)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   457
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   458
        retValue = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   459
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   460
    searchAttr.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   461
    return retValue;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   462
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   463
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   464
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   465
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   466
// TMceSessionUtility::ConstructSdpDocumentL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   467
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   468
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   469
void TMceSessionUtility::ConstructSdpDocumentL(CDesC8Array* asdpLines, CSdpDocument*& asdpDoc)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   470
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   471
    if (asdpDoc)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   472
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   473
        delete asdpDoc;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   474
        asdpDoc = NULL;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   475
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   476
    TBuf8<1000> text; 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   477
    for(TInt i=0; i<asdpLines->MdcaCount(); i++)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   478
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   479
        TBuf8<200> temp(asdpLines->MdcaPoint(i));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   480
        text.Append( temp );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   481
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   482
    TInt leaveValue = KErrNone;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   483
    // Ownership for sdpDoc is tranferred to us.. 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   484
    TRAP(leaveValue, asdpDoc = CSdpDocument::DecodeL(text));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   485
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   486
    if (leaveValue != KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   487
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   488
        MCECLI_DEBUG_DVALUE("TMceSessionUtility::ConstructSdpDocument: Error in decoding the SdpDocument text : %d", leaveValue);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   489
        SdpCodecStringPool::Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   490
        User::Leave(leaveValue);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   491
        }    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   492
    }