mmfenh/enhancedmediaclient/Plugins/DataBufferSource/src/SourceQueueItem.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This file contains the implementation of Data Buffer Queue Item.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "SourceQueueItem.h"
       
    22 #include <mmfcontrollerframework.h>
       
    23 #include "tracemacros.h"
       
    24 
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CSourceQueueItem::CSourceQueueItem
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CSourceQueueItem::CSourceQueueItem()
       
    35 : iMessage(NULL)
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CSourceQueueItem::~CSourceQueueItem
       
    41 // Destructor
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CSourceQueueItem::~CSourceQueueItem()
       
    45     {
       
    46     if(iMessage && !iMessage->IsCompleted())
       
    47         {
       
    48         iMessage->Complete(KErrCancel);
       
    49         delete iMessage;
       
    50         }
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CSourceQueueItem::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CSourceQueueItem::ConstructL(
       
    59                                   TMMFMessage& aMessage )
       
    60     {
       
    61     iMessage = new(ELeave) TMMFMessage(aMessage);
       
    62     // Read buffer attributes here
       
    63     TPckgBuf<DataBufferAttributesStruct> dataBufferAttributesStructPckg;
       
    64     TInt err = iMessage->ReadData2FromClient(dataBufferAttributesStructPckg);
       
    65     if ( err == KErrNone )
       
    66         {
       
    67         iLastBuffer = dataBufferAttributesStructPckg().iLastBuffer;
       
    68         iBufferSeqNum = dataBufferAttributesStructPckg().iBufferSeqNum;
       
    69         }
       
    70     EMC_TRACE3(_L("CSourceQueueItem::ConstructL LB[%d] err[%d]"), iLastBuffer, err);
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSourceQueueItem::NewL
       
    75 // Two-phased constructor.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CSourceQueueItem* CSourceQueueItem::NewL(
       
    79                                          TMMFMessage& aMessage )
       
    80     {
       
    81     CSourceQueueItem* self = new (ELeave) CSourceQueueItem();
       
    82     CleanupStack::PushL(self);
       
    83     self->ConstructL(aMessage);
       
    84     CleanupStack::Pop(self);
       
    85     return self;
       
    86     }
       
    87 
       
    88 void CSourceQueueItem::CompleteMessage(TInt status)
       
    89     {
       
    90     EMC_TRACE3(_L("CSourceQueueItem::CompleteMessage:BufSeqNum[%d]Status[%d]"), \
       
    91             iBufferSeqNum, status);
       
    92     if ( iMessage && !iMessage->IsCompleted())
       
    93         {
       
    94         iMessage->Complete(status);
       
    95         }
       
    96     delete iMessage;
       
    97     iMessage = NULL;
       
    98     }
       
    99 
       
   100 TInt CSourceQueueItem::DataSize()
       
   101     {
       
   102     TInt val(0);
       
   103     if (iMessage)
       
   104         val = iMessage->SizeOfData1FromClient();
       
   105     return val;
       
   106     }
       
   107 
       
   108 TInt CSourceQueueItem::ReadData(TDes8 &aDes)
       
   109     {
       
   110     TInt err(KErrNotReady);
       
   111     if (iMessage)
       
   112         {
       
   113         err = iMessage->ReadData1FromClient(aDes);
       
   114         }
       
   115     return err;
       
   116     }
       
   117 
       
   118 TBool CSourceQueueItem::IsLastBuffer()
       
   119     {
       
   120     return iLastBuffer;
       
   121     }
       
   122 
       
   123 TUint CSourceQueueItem::GetBufferSequenceNumber()
       
   124     {
       
   125     return iBufferSeqNum;
       
   126     }
       
   127 
       
   128 // End of file