mmserv/tms/tmsimpl/src/tmsclientsourcebodyimpl.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 <tmsclientsourceobsrvr.h>
       
    20 #include "tmscallproxy.h"
       
    21 #include "tmsmembuffer.h"
       
    22 #include "tmsqueuehandler.h"
       
    23 #include "tmsclientsourcebodyimpl.h"
       
    24 
       
    25 using namespace TMS;
       
    26 
       
    27 TMSClientSourceBodyImpl::TMSClientSourceBodyImpl() :
       
    28     iObserver(NULL),
       
    29     iProxy(NULL)
       
    30     {
       
    31     iQueueMode = false;
       
    32     }
       
    33 
       
    34 TMSClientSourceBodyImpl::~TMSClientSourceBodyImpl()
       
    35     {
       
    36     }
       
    37 
       
    38 gint TMSClientSourceBodyImpl::Create(TMSClientSourceBody*& bodyimpl)
       
    39     {
       
    40     gint ret(TMS_RESULT_INSUFFICIENT_MEMORY);
       
    41     TMSClientSourceBodyImpl* self = new TMSClientSourceBodyImpl;
       
    42     if (self)
       
    43         {
       
    44         ret = self->PostConstruct();
       
    45         if (ret != TMS_RESULT_SUCCESS)
       
    46             {
       
    47             delete self;
       
    48             self = NULL;
       
    49             }
       
    50         }
       
    51     bodyimpl = self;
       
    52     return ret;
       
    53     }
       
    54 
       
    55 gint TMSClientSourceBodyImpl::PostConstruct()
       
    56     {
       
    57     gint ret(TMS_RESULT_SUCCESS);
       
    58     return ret;
       
    59     }
       
    60 
       
    61 gint TMSClientSourceBodyImpl::AddObserver(TMSClientSourceObserver& obsrvr,
       
    62         gpointer user_data)
       
    63     {
       
    64     gint ret(TMS_RESULT_SUCCESS);
       
    65     if (!iObserver)
       
    66         {
       
    67         iObserver = &obsrvr;
       
    68         iUserData = user_data;
       
    69         }
       
    70     else
       
    71         {
       
    72         ret = TMS_RESULT_ALREADY_EXIST;
       
    73         }
       
    74     return ret;
       
    75     }
       
    76 
       
    77 /**
       
    78  * Remove a stream observer from this stream.
       
    79  *
       
    80  * This function can be called at any time. It is recommended to remove
       
    81  * observer after calling Deinit() on stream. Else observer may receive
       
    82  * a callback that is alread dispatched.
       
    83  *
       
    84  * @param  obsrvr
       
    85  *      The listener to remove.
       
    86  *
       
    87  * @return
       
    88  *      TMS_RESULT_SUCCESS if the obsrvr is removed successfully from list.
       
    89  *      TMS_RESULT_DOES_NOT_EXIST if obsrvr is not already in the list.
       
    90  *
       
    91  */
       
    92 gint TMSClientSourceBodyImpl::RemoveObserver(TMSClientSourceObserver& obsrvr)
       
    93     {
       
    94     gint ret(TMS_RESULT_SUCCESS);
       
    95     if (&obsrvr == iObserver)
       
    96         {
       
    97         iObserver = NULL;
       
    98         }
       
    99     else
       
   100         {
       
   101         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   102         }
       
   103     return ret;
       
   104     }
       
   105 
       
   106 // In pull mode, client calls this.
       
   107 // TODO: How to identify last buffer.
       
   108 // Option 1 is to move setlast buffer to TMSBuffer interface.
       
   109 // Option 2 is to have overloaded function with another parameter.
       
   110 gint TMSClientSourceBodyImpl::BufferFilled(TMSBuffer& buffer)
       
   111     {
       
   112     // TODO send stream attributes here
       
   113     gint ret(TMS_RESULT_SUCCESS);
       
   114     ret = iProxy->BufferFilled(TMS_CALL_IP,
       
   115                                TMS_STREAM_DOWNLINK,
       
   116                                iStreamId,
       
   117                                buffer);
       
   118     return ret;
       
   119     }
       
   120 
       
   121 // Push mode
       
   122 gint TMSClientSourceBodyImpl::ProcessBuffer(TMSBuffer* /*buffer*/)
       
   123     {
       
   124     gint ret(TMS_RESULT_FEATURE_NOT_SUPPORTED);
       
   125     return ret;
       
   126     }
       
   127 
       
   128 // Indicates framework to queue ProcessBuffer. default is off
       
   129 // unsupported in pull mode??? (atleast initially)
       
   130 gint TMSClientSourceBodyImpl::SetEnqueueMode(const gboolean /*enable*/)
       
   131     {
       
   132     gint ret(TMS_RESULT_FEATURE_NOT_SUPPORTED);
       
   133     //iQueueMode = enable;
       
   134     return ret;
       
   135     }
       
   136 
       
   137 gint TMSClientSourceBodyImpl::GetEnqueueMode(gboolean& enable)
       
   138     {
       
   139     gint ret(TMS_RESULT_FEATURE_NOT_SUPPORTED);
       
   140     enable = iQueueMode;
       
   141     return ret;
       
   142     }
       
   143 
       
   144 // Sends batch data to framework and clears queue mode.
       
   145 // Valid only when queue mode is set, otherwise no-op
       
   146 gint TMSClientSourceBodyImpl::Flush()
       
   147     {
       
   148     gint ret(TMS_RESULT_FEATURE_NOT_SUPPORTED);
       
   149     return ret;
       
   150     }
       
   151 
       
   152 gint TMSClientSourceBodyImpl::GetType(TMSSourceType& sourcetype)
       
   153     {
       
   154     gint ret(TMS_RESULT_SUCCESS);
       
   155     sourcetype = TMS_SOURCE_CLIENT;
       
   156     return ret;
       
   157     }
       
   158 
       
   159 void TMSClientSourceBodyImpl::SetProxy(TMSCallProxy* aProxy, gint strmid,
       
   160         gpointer queuehandler)
       
   161     {
       
   162     iProxy = aProxy;
       
   163     iStreamId = strmid;
       
   164     ((CQueueHandler*) queuehandler)->AddObserver(*this, TMS_SOURCE_CLIENT);
       
   165     }
       
   166 
       
   167 void TMSClientSourceBodyImpl::QueueEvent(TInt aEventType, TInt aError,
       
   168         void* user_data)
       
   169     {
       
   170     if (iObserver)
       
   171         {
       
   172         switch (aEventType)
       
   173             {
       
   174             case TMS_EVENT_SOURCE_FILL_BUFFER:
       
   175                 iObserver->FillBuffer(*((TMSBuffer*) user_data));
       
   176                 break;
       
   177             case TMS_EVENT_SOURCE_PROCESSED_BUFFER:
       
   178                 iObserver->BufferProcessed((TMSBuffer*) user_data, aError);
       
   179                 break;
       
   180             default:
       
   181                 break;
       
   182             }
       
   183         }
       
   184     }
       
   185 
       
   186 // End of file