What I have done is the following:
In MpCallFlowGraph.h, I have added a member:
IMediaEventListener* mpMediaEventListener;
I have also changed the CreateConnection() method to include this parameter
and store it.
MpConnectionID createConnection( IMediaEventListener*
pMediaEventListener );
Then in CpPhoneMediaInterface::createConnection(), I added the parameter to
the method call:
connectionId = mpFlowGraph->createConnection(pMediaEventListener);
The media event listener is in fact the SipConnection. That's the point.
Then in mprFromFile you can easily use all public SipConnection members
UtlBoolean MprFromFile::handleMessage(MpFlowGraphMsg& rMsg)
{
switch (rMsg.getMsg()) {
case PLAY_FILE:
if( ((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener != NULL )
{
((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener->onFileStart(IDevice_A
udio);
}
return handleSetup(rMsg);
break;
case STOP_FILE:
if( ((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener != NULL )
{
((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener->onFileStop(IDevice_Au
dio);
}
return handleStop();
break;
case PLAY_BUFFER:
if( ((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener != NULL )
{
((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener->onBufferStart(IDevice
_Audio);
}
return handleSetup(rMsg);
break;
case STOP_BUFFER:
if( ((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener != NULL )
{
((MpCallFlowGraph*)mpFlowGraph)->mpMediaEventListener->onBufferStop(IDevice_
Audio);
}
return handleStop();
break;
And in SipConnection.cpp you can add as many methods such as the 2 following
examples:
void SipConnection::onFileStart(IMediaEvent_DeviceTypes type)
{
UtlString callId ;
UtlString remoteAddress ;
SIPX_MEDIA_TYPE mediaType = (type == IDevice_Audio) ? MEDIA_TYPE_AUDIO :
MEDIA_TYPE_VIDEO;
getCallId(&callId);
getRemoteAddress(&remoteAddress);
CpMultiStringMessage message(CpCallManager::CP_REFIRE_MEDIA_EVENT, callId,
remoteAddress, NULL, NULL, NULL,
MEDIA_PLAYFILE_START, MEDIA_CAUSE_NORMAL, mediaType) ;
mpCallManager->postMessage(message);
}
void SipConnection::onBufferStop(IMediaEvent_DeviceTypes type)
{
UtlString callId ;
UtlString remoteAddress ;
SIPX_MEDIA_TYPE mediaType = (type == IDevice_Audio) ? MEDIA_TYPE_AUDIO :
MEDIA_TYPE_VIDEO;
getCallId(&callId);
getRemoteAddress(&remoteAddress);
CpMultiStringMessage message(CpCallManager::CP_REFIRE_MEDIA_EVENT, callId,
remoteAddress, NULL, NULL, NULL,
MEDIA_PLAYBUFFER_STOP, MEDIA_CAUSE_NORMAL, mediaType) ;
mpCallManager->postMessage(message);
}
Best regards,
stipus
----- Original Message -----
From: "Jaroslav Libak" <[EMAIL PROTECTED]>
To: "Daniel Sigurgeirsson" <[EMAIL PROTECTED]>;
<[email protected]>
Sent: Monday, May 21, 2007 6:23 PM
Subject: Re: [sipxtapi-dev] MEDIA_PLAYFILE_START,
MEDIA_PLAYFILE_STOP,MEDIA_PLAYBUFFER_START and MEDIA_PLAYB
> Daniel Sigurgeirsson wrote:
> > Hi,
> >
> > this is still not completely clear to me (but then very few things
> > are....). What I do realize (approximately) is that the flow of
> > the MEDIA_PLAYFILE_STOP message would probably be as follows:
> >
> > - MprFromFile would finish playing (either because there is no more data
> > or it was told to stop) so it will send an internal message to:
> > -> MpCallFlowGraph who would notify:
> > -> CpPhoneMediaInterface which should hold on to the IMediaEventListener
> > interface ptr passed to createConnection, this would call the onFileStop
> > function in:
> > -> SipConnection which would post the MEDIA_PLAYFILE_STOP message to:
>
> No SipConnection wouldn't post it anywhere. It would call
> Connection::fireSipXMediaEvent. Connection is parent of SipConnection.
> fireSipXMediaEvent then uses TapiMgr singleton to fire the event to
> sipxtapi - TapiMgr::getInstance().fireMediaEvent. You don't have to care
> where the message goes beyond TapiMgr unless you introduce new events or
> some new pointers into the event. Have a look at the SIP pim client
> integration patch, it adds a new event type. Look at how it works.
>
> > but I cannot find a simple way for MpCallFlowGraph to notify it's parent
> > (assuming that the relationship is like that).
> >
> MpCallFlowGraph doesn't have to notify anybody else than
> CpPhoneMediaInterface.
>
> > Also, I would really like the MEDIA_PLAYFILE_STOP message to indicate
> > how much was actually played (I know that MprFromFile stores it in the
> > mFileBufferIndex member variable, seems to be a matter of passing it as
> > a parameter with all the messages). This addition would make room for
> > functionality like pausing and then restarting, or playing a buffer,
> > pausing, and then recording from that position.
> >
> This is not a problem, you would just need to pass this new parameter to
> message when it "propagates" to SipConnection and modify the sipxtapi
> media event structure which holds all data.
>
> Jaro
>
>
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/