multimediacommscontroller/mmccmsrpsourcesink/src/mccmsrpdatasender.cpp
author vnuitven <>
Mon, 06 Sep 2010 18:50:40 +0530
branchrcs
changeset 50 1d8943dd8be6
parent 49 64c62431ac08
permissions -rw-r--r--
changed copy right year to 2010 for all newly added files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     1
/*
50
1d8943dd8be6 changed copy right year to 2010 for all newly added files
vnuitven <>
parents: 49
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
49
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:    Provides a comfort noise generator class
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
// INCLUDE FILES
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    20
#include "mccmsrpdatasender.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    21
#include "mccmsrpsourcesinklogs.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    22
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    23
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    24
// ============================ MEMBER FUNCTIONS ===============================
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    25
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    26
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    27
// CMccMsrpDataSender::CMccMsrpDataSender
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    28
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    29
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    30
CMccMsrpDataSender::CMccMsrpDataSender( )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    31
	: CActive( EPriorityStandard )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    32
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    33
	CActiveScheduler::Add(this);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    34
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    35
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    36
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    37
// CMccMsrpDataSender::ConstructL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    38
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    39
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    40
void CMccMsrpDataSender::ConstructL()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    41
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    42
    iTimeoutTimer = CMccTimerManager::NewL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    43
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    44
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    45
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    46
// CMccMsrpDataSender::NewL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    47
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    48
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    49
CMccMsrpDataSender* CMccMsrpDataSender::NewL( )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    50
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    51
    CMccMsrpDataSender* self = 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    52
    	new ( ELeave ) CMccMsrpDataSender();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    53
    CleanupStack::PushL( self );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    54
    self->ConstructL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    55
    CleanupStack::Pop( self );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    56
    return self;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    57
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    58
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    59
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    60
// CMccMsrpDataSender::Send
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    61
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    62
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    63
void CMccMsrpDataSender::SendL( const TDesC8& aData, CMSRPSession* aMsrpSession )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    64
	{	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    65
    __MSRPSOURCESINK_CONTROLL( "CMccMsrpDataSender::Send, Entry" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    66
    __ASSERT_ALWAYS( aMsrpSession, User::Leave( KErrArgument ) );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    67
	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    68
    if ( !IsActive() )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    69
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    70
        iBuffer.Copy( aData );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    71
        SendPacketL(aMsrpSession);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    72
        __MSRPSOURCESINK_CONTROLL( "CMccMsrpDataSender::Send, Exit" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    73
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    74
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    75
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    76
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    77
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    78
// CMccRtpSender::SendPacketL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    79
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    80
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    81
void CMccMsrpDataSender::SendPacketL( CMSRPSession* aMsrpSession )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    82
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    83
    __MSRPSOURCESINK_CONTROLL( "CMccMsrpDataSender::SendPacketL, entry" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    84
    __ASSERT_ALWAYS( aMsrpSession, User::Leave( KErrArgument ) );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    85
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    86
    if ( iBuffer.Size() )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    87
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    88
        __MSRPSOURCESINK_CONTROLL( "CMccMsrpDataSender::SendBuffer, entry" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    89
        HBufC8* messageID = aMsrpSession->SendBuffer(iBuffer, _L8("text/plain"));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    90
        // message Id might be useful for the file sharing use case
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    91
        delete messageID;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    92
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    93
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    94
        iTimeoutTimer->Stop( iTimerId );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    95
        iTimerId = iTimeoutTimer->StartL( this, iTimeoutTimeMilliseconds );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    96
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    97
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    98
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    99
	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   100
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   101
// CMccMsrpDataSender::~CMccMsrpDataSender
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   102
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   103
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   104
CMccMsrpDataSender::~CMccMsrpDataSender()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   105
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   106
    Cancel();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   107
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   108
    delete iTimeoutTimer;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   109
	iMsgQueue.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   110
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   111
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   112
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   113
// CMccMsrpDataSender::DoCancel
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   114
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   115
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   116
void CMccMsrpDataSender::DoCancel()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   117
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   118
	iMsgQueue.CancelSpaceAvailable();	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   119
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   120
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   121
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   122
// CMccMsrpDataSender::RunL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   123
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   124
//	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   125
void CMccMsrpDataSender::RunL()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   126
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   127
    iMsgQueue.Send( iBuffer );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   128
    iBuffer.Zero();
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
// CMccMsrpDataSender::RunError
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   133
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   134
//	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   135
TInt CMccMsrpDataSender::RunError(TInt /*aError*/)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   136
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   137
	return KErrNone;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   138
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   139
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   140
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   141
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   142
// CMccRtpSender::InactivityTimeout
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   143
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   144
//    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   145
void CMccMsrpDataSender::TimerExpiredL( 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   146
    TMccTimerId /*aTimerId*/, TAny* /*aTimerParam*/ )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   147
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   148
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   149
/*    if ( iTimeoutTimeMilliseconds > KMccRtpSendTimeoutLongMillisecs )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   150
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   151
        // Timeout value is so long that if sending of one rtp packet really
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   152
        // took so long, receiver will have big problems and it's better
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   153
        // to drop all frames queued in order to avoid delay increase 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   154
        // at receiver side.
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   155
        Clear();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   156
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   157
    else
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   158
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   159
        // Sending timeout, cancel send and discard that packet
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   160
        Cancel();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   161
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   162
        // Do also cleanup of related packets as those are useless as this 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   163
        // packet is removed because of timeout
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   164
        RemovePacket( ETrue ); 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   165
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   166
        // Send next packet anyway
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   167
        TRAPD( err, SendPacketL() )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   168
        if ( err )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   169
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   170
            ErrorReport( err );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   171
            }
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
    }