mmserv/tms/tmsimpl/src/tmsclientsinkbodyimpl.cpp
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2009 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: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 #include <tms.h>
       
    19 #include <tmsclientsinkobsrvr.h>
       
    20 #include "tmscallproxy.h"
       
    21 #include "tmsmembuffer.h"
       
    22 #include "tmsqueuehandler.h"
       
    23 #include "tmsclientsinkbodyimpl.h"
       
    24 
       
    25 using namespace TMS;
       
    26 
       
    27 TMSClientSinkBodyImpl::TMSClientSinkBodyImpl() :
       
    28     iObserver(NULL),
       
    29     iProxy(NULL)
       
    30     {
       
    31     }
       
    32 
       
    33 TMSClientSinkBodyImpl::~TMSClientSinkBodyImpl()
       
    34     {
       
    35     }
       
    36 
       
    37 gint TMSClientSinkBodyImpl::Create(TMSClientSinkBody*& bodyimpl)
       
    38     {
       
    39     gint ret(TMS_RESULT_INSUFFICIENT_MEMORY);
       
    40     TMSClientSinkBodyImpl* self = new TMSClientSinkBodyImpl;
       
    41     if (self)
       
    42         {
       
    43         ret = self->PostConstruct();
       
    44         if (ret != TMS_RESULT_SUCCESS)
       
    45             {
       
    46             delete self;
       
    47             self = NULL;
       
    48             }
       
    49         }
       
    50     bodyimpl = self;
       
    51     return ret;
       
    52     }
       
    53 
       
    54 gint TMSClientSinkBodyImpl::PostConstruct()
       
    55     {
       
    56     gint ret(TMS_RESULT_SUCCESS);
       
    57     return ret;
       
    58     }
       
    59 
       
    60 gint TMSClientSinkBodyImpl::AddObserver(TMSClientSinkObserver& obsrvr,
       
    61         gpointer user_data)
       
    62     {
       
    63     gint ret(TMS_RESULT_SUCCESS);
       
    64     if (!iObserver)
       
    65         {
       
    66         iObserver = &obsrvr;
       
    67         iUserData = user_data;
       
    68         }
       
    69     else
       
    70         {
       
    71         ret = TMS_RESULT_ALREADY_EXIST;
       
    72         }
       
    73     return ret;
       
    74     }
       
    75 
       
    76 gint TMSClientSinkBodyImpl::RemoveObserver(TMSClientSinkObserver& obsrvr)
       
    77     {
       
    78     gint ret(TMS_RESULT_SUCCESS);
       
    79     if (&obsrvr == iObserver)
       
    80         {
       
    81         iObserver = NULL;
       
    82         }
       
    83     else
       
    84         {
       
    85         ret = TMS_RESULT_DOES_NOT_EXIST;
       
    86         }
       
    87     return ret;
       
    88     }
       
    89 
       
    90 // Push mode
       
    91 gint TMSClientSinkBodyImpl::BufferProcessed(TMSBuffer* buffer)
       
    92     {
       
    93     // TODO send stream attributes here
       
    94     gint ret(TMS_RESULT_SUCCESS);
       
    95 
       
    96     if (iProxy)
       
    97         {
       
    98         ret = iProxy->BufferEmptied(TMS_CALL_IP,
       
    99                                     TMS_STREAM_UPLINK,
       
   100                                     1, //TODO: must use strm_id
       
   101                                     *buffer);
       
   102         }
       
   103     else
       
   104         {
       
   105         ret = TMS_RESULT_UNINITIALIZED_OBJECT;
       
   106         }
       
   107     return ret;
       
   108     }
       
   109 
       
   110 gint TMSClientSinkBodyImpl::GetType(TMSSinkType& sinktype)
       
   111     {
       
   112     gint ret(TMS_RESULT_SUCCESS);
       
   113     sinktype = TMS_SINK_CLIENT;
       
   114     return ret;
       
   115     }
       
   116 
       
   117 void TMSClientSinkBodyImpl::SetProxy(TMSCallProxy* aProxy,
       
   118         gpointer queuehandler)
       
   119     {
       
   120     iProxy = aProxy;
       
   121     if (queuehandler)
       
   122         {
       
   123         ((CQueueHandler*) queuehandler)->AddObserver(*this, TMS_SINK_CLIENT);
       
   124         }
       
   125     }
       
   126 
       
   127 void TMSClientSinkBodyImpl::QueueEvent(TInt aEventType, TInt /*aError*/,
       
   128         void* user_data)
       
   129     {
       
   130     if (iObserver)
       
   131         {
       
   132         switch (aEventType)
       
   133             {
       
   134             case TMS_EVENT_SINK_PROCESS_BUFFER:
       
   135                 iObserver->ProcessBuffer(((TMSBuffer*) user_data));
       
   136                 break;
       
   137             default:
       
   138                 break;
       
   139             }
       
   140         }
       
   141     }
       
   142 
       
   143 // End of file