ekiga r6078 - in trunk: . lib/engine/protocol/skel src/endpoints
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r6078 - in trunk: . lib/engine/protocol/skel src/endpoints
- Date: Fri, 21 Mar 2008 11:51:25 +0000 (GMT)
Author: jpuydt
Date: Fri Mar 21 11:51:25 2008
New Revision: 6078
URL: http://svn.gnome.org/viewvc/ekiga?rev=6078&view=rev
Log:
Cleaned up the call api
Modified:
trunk/ChangeLog
trunk/lib/engine/protocol/skel/call.h
trunk/src/endpoints/opal-call.cpp
trunk/src/endpoints/opal-call.h
Modified: trunk/lib/engine/protocol/skel/call.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call.h (original)
+++ trunk/lib/engine/protocol/skel/call.h Fri Mar 21 11:51:25 2008
@@ -27,9 +27,9 @@
/*
* call.h - description
* ------------------------------------------
- * begin : written in 2007 by Damien Sandras
+ * begin : written in 2007 by Damien Sandras
* copyright : (c) 2007 by Damien Sandras
- * description : declaration of the interface of a call handled by
+ * description : declaration of the interface of a call handled by
* the Ekiga::CallManager.
*
*/
@@ -58,29 +58,25 @@
public:
- Call ()
- {
- outgoing = false;
- re_a_bw = tr_a_bw = re_v_bw = tr_v_bw = 0.0;
- jitter = 0;
- lost_packets = late_packets = out_of_order_packets = 0.0;
+ Call ()
+ {
}
virtual ~Call () {};
enum StreamType { Audio, Video };
- /*
+ /*
* Call Management
*/
/** Hangup the call
*/
- virtual void hangup () = 0;
+ virtual void hangup () = 0;
/** Answer an incoming call
*/
- virtual void answer () = 0;
+ virtual void answer () = 0;
/** Transfer the call to the specified uri
* @param uri is the uri where to transfer the call
@@ -101,86 +97,86 @@
*/
virtual void send_dtmf (const char dtmf) = 0;
- /*
+ /*
* Call Information
*/
/** Return the call id
- * @return: the call id
+ * @return: the call id
*/
- virtual std::string get_id () = 0;
+ virtual const std::string get_id () const = 0;
/** Return the remote party name
* @return: the remote party name
*/
- virtual std::string get_remote_party_name () = 0;
+ virtual const std::string get_remote_party_name () const = 0;
/** Return the remote application
* @return: the remote application
*/
- virtual std::string get_remote_application () = 0;
+ virtual const std::string get_remote_application () const = 0;
/** Return the remote callback uri
* @return: the remote uri
*/
- virtual std::string get_remote_uri () = 0;
+ virtual const std::string get_remote_uri () const = 0;
/** Return the call duration
* @return the current call duration
*/
- virtual std::string get_call_duration () = 0;
+ virtual const std::string get_call_duration () const = 0;
/** Return information about call type
* @return true if it is an outgoing call
*/
- bool is_outgoing () { return outgoing; }
+ virtual bool is_outgoing () const = 0;
/** Return the received audio bandwidth
* @return the received audio bandwidth in kbytes/s
*/
- double get_received_audio_bandwidth () { return re_a_bw; }
+ virtual double get_received_audio_bandwidth () const = 0;
/** Return the transmitted audio bandwidth
* @return the transmitted audio bandwidth in kbytes/s
*/
- double get_transmitted_audio_bandwidth () { return tr_a_bw; }
-
+ virtual double get_transmitted_audio_bandwidth () const = 0;
+
/** Return the received video bandwidth
* @return the received video bandwidth in kbytes/s
- */
- double get_received_video_bandwidth () { return re_v_bw; }
-
+ */
+ virtual double get_received_video_bandwidth () const = 0;
+
/** Return the transmitted video bandwidth
* @return the transmitted video bandwidth in kbytes/s
*/
- double get_transmitted_video_bandwidth () { return tr_v_bw; }
+ virtual double get_transmitted_video_bandwidth () const = 0;
/** Return the jitter size
* @return the jitter size in ms
*/
- unsigned get_jitter_size () { return jitter; }
+ virtual unsigned get_jitter_size () const = 0;
- /** Return the lost packets information
+ /** Return the lost packets information
* @return the lost packets percentage
*/
- double get_lost_packets () { return lost_packets; }
-
- /** Return the late packets information
+ virtual double get_lost_packets () const = 0;
+
+ /** Return the late packets information
* @return the late packets percentage
*/
- double get_late_packets () { return late_packets; }
+ virtual double get_late_packets () const = 0;
- /** Return the out of order packets information
+ /** Return the out of order packets information
* @return the out of order packets percentage
*/
- double get_out_of_order_packets () { return out_of_order_packets; }
+ virtual double get_out_of_order_packets () const = 0;
/*
* Signals
*/
-
+
/* Signal emitted when the call is established
*/
sigc::signal<void> established;
@@ -202,7 +198,7 @@
/* Signal emitted when the call is held
*/
sigc::signal<void> held;
-
+
/* Signal emitted when the call is retrieved
*/
sigc::signal<void> retrieved;
@@ -239,31 +235,6 @@
*/
sigc::signal<void, std::string, StreamType> stream_resumed;
-
- protected :
-
- std::string remote_party_name;
- std::string remote_uri;
- std::string remote_application;
-
- bool outgoing;
-
- double re_a_bw;
- double tr_a_bw;
- double re_v_bw;
- double tr_v_bw;
- unsigned re_v_fps;
- unsigned tr_v_fps;
- unsigned tr_width;
- unsigned tr_height;
- unsigned re_width;
- unsigned re_height;
-
- unsigned jitter;
-
- double lost_packets;
- double late_packets;
- double out_of_order_packets;
};
/**
Modified: trunk/src/endpoints/opal-call.cpp
==============================================================================
--- trunk/src/endpoints/opal-call.cpp (original)
+++ trunk/src/endpoints/opal-call.cpp Fri Mar 21 11:51:25 2008
@@ -27,9 +27,9 @@
/*
* opal-call.cpp - description
* ------------------------------------------
- * begin : written in 2007 by Damien Sandras
+ * begin : written in 2007 by Damien Sandras
* copyright : (c) 2007 by Damien Sandras
- * description : declaration of the interface of a call handled by
+ * description : declaration of the interface of a call handled by
* Opal.
*
*/
@@ -54,8 +54,10 @@
using namespace Opal;
-Call::Call (OpalManager & _manager, Ekiga::ServiceCore & _core)
-: OpalCall (_manager), Ekiga::Call (), core (_core), runtime (*dynamic_cast<Ekiga::Runtime*>(core.get ("runtime")))
+Opal::Call::Call (OpalManager & _manager, Ekiga::ServiceCore & _core)
+ : OpalCall (_manager), Ekiga::Call (), core (_core),
+ runtime (*dynamic_cast<Ekiga::Runtime*>(core.get ("runtime"))),
+ outgoing(false), jitter(0)
{
re_a_bytes = tr_a_bytes = re_v_bytes = tr_v_bytes = 0.0;
last_v_tick = last_a_tick = PTime ();
@@ -67,37 +69,43 @@
lost_v =
too_late_v =
out_of_order_v = 0;
+ lost_packets = late_packets = out_of_order_packets = 0.0;
+ re_a_bw = tr_a_bw = re_v_bw = tr_v_bw = 0.0;
}
-void Call::hangup ()
+void
+Opal::Call::hangup ()
{
- if (!is_outgoing () && !IsEstablished ())
+ if (!is_outgoing () && !IsEstablished ())
Clear (OpalConnection::EndedByAnswerDenied);
else
Clear ();
}
-void Call::answer ()
+void
+Opal::Call::answer ()
{
- PThread::Create (PCREATE_NOTIFIER (OnAnswer), NULL,
- PThread::AutoDeleteThread, PThread::NormalPriority,
+ PThread::Create (PCREATE_NOTIFIER (OnAnswer), NULL,
+ PThread::AutoDeleteThread, PThread::NormalPriority,
"Opal::Call Answer Thread");
}
-void Call::transfer (std::string uri)
+void
+Opal::Call::transfer (std::string uri)
{
//FIXME
std::cout << "Should transfer to " << uri << std::endl << std::flush;
}
-void Call::toggle_hold ()
+void
+Opal::Call::toggle_hold ()
{
PSafePtr<OpalConnection> connection = NULL;
-
+
bool on_hold = false;
int i = 0;
@@ -105,20 +113,21 @@
connection = GetConnection (i);
i++;
- } while (PIsDescendant(&(*connection), OpalPCSSConnection));
+ } while (PIsDescendant(&(*connection), OpalPCSSConnection));
if (connection) {
on_hold = connection->IsConnectionOnHold ();
- if (!on_hold)
+ if (!on_hold)
connection->HoldConnection ();
- else
+ else
connection->RetrieveConnection ();
}
}
-void Call::toggle_stream_pause (StreamType type)
+void
+Opal::Call::toggle_stream_pause (StreamType type)
{
OpalMediaStreamPtr stream = NULL;
PSafePtr<OpalConnection> connection = NULL;
@@ -133,11 +142,11 @@
connection = GetConnection (i);
i++;
- } while (PIsDescendant(&(*connection), OpalPCSSConnection));
+ } while (PIsDescendant(&(*connection), OpalPCSSConnection));
if (connection != NULL) {
- stream = connection->GetMediaStream ((type == Audio)?OpalMediaFormat::DefaultAudioSessionID:OpalMediaFormat::DefaultVideoSessionID, false);
+ stream = connection->GetMediaStream ((type == Audio)?OpalMediaFormat::DefaultAudioSessionID:OpalMediaFormat::DefaultVideoSessionID, false);
if (stream != NULL) {
stream_name = std::string ((const char *) stream->GetMediaFormat ().GetEncodingName ());
@@ -154,7 +163,8 @@
}
-void Call::send_dtmf (const char dtmf)
+void
+Opal::Call::send_dtmf (const char dtmf)
{
PSafePtr<OpalConnection> connection = NULL;
@@ -164,38 +174,43 @@
connection = GetConnection (i);
i++;
- } while (PIsDescendant(&(*connection), OpalPCSSConnection));
+ } while (PIsDescendant(&(*connection), OpalPCSSConnection));
- if (connection != NULL)
+ if (connection != NULL)
connection->SendUserInputTone (dtmf, 180);
}
-std::string Call::get_id ()
+const std::string
+Opal::Call::get_id () const
{
return GetToken ();
}
-std::string Call::get_remote_party_name ()
+const std::string
+Opal::Call::get_remote_party_name () const
{
return remote_party_name;
}
-std::string Call::get_remote_application ()
+const std::string
+Opal::Call::get_remote_application () const
{
return remote_application;
}
-std::string Call::get_remote_uri ()
+const std::string
+Opal::Call::get_remote_uri () const
{
return remote_uri;
}
-std::string Call::get_call_duration ()
+const std::string
+Opal::Call::get_call_duration () const
{
std::stringstream duration;
PTimeInterval t = PTime () - start_time;
@@ -204,11 +219,12 @@
duration << setfill ('0') << setw (2) << (t.GetMinutes () % 60) << ":";
duration << setfill ('0') << setw (2) << (t.GetSeconds () % 60);
- return duration.str ();
+ return duration.str ();
}
-void Call::parse_info (OpalConnection & connection)
+void
+Opal::Call::parse_info (OpalConnection & connection)
{
char special_chars [] = "([@";
int i = 0;
@@ -220,7 +236,7 @@
if (!PIsDescendant(&connection, OpalPCSSConnection)) {
party_name = (const char *) connection.GetRemotePartyName ();
- app = (const char *) connection.GetRemoteApplication ();
+ app = (const char *) connection.GetRemoteApplication ();
uri = (const char *) connection.GetRemotePartyCallbackURL ();
start_time = connection.GetConnectionStartTime ();
@@ -247,19 +263,21 @@
}
-PBoolean Call::OnEstablished (OpalConnection & connection)
+PBoolean
+Opal::Call::OnEstablished (OpalConnection & connection)
{
if (!PIsDescendant(&connection, OpalPCSSConnection)) {
parse_info (connection);
runtime.run_in_main (established.make_slot ());
}
-
+
return OpalCall::OnEstablished (connection);
}
-void Call::OnReleased (OpalConnection & connection)
+void
+Opal::Call::OnReleased (OpalConnection & connection)
{
std::string reason;
@@ -269,7 +287,7 @@
*/
if (!PIsDescendant(&connection, OpalPCSSConnection)) {
- if (!IsEstablished ()
+ if (!IsEstablished ()
&& !is_outgoing ()
&& connection.GetCallEndReason () != OpalConnection::EndedByAnswerDenied) {
@@ -367,7 +385,9 @@
}
-OpalConnection::AnswerCallResponse Call::OnAnswerCall (OpalConnection & connection, const PString & caller)
+OpalConnection::AnswerCallResponse
+Opal::Call::OnAnswerCall (OpalConnection & connection,
+ const PString & caller)
{
remote_party_name = (const char *) caller;
@@ -379,7 +399,8 @@
}
-PBoolean Call::OnSetUp (OpalConnection & connection)
+PBoolean
+Opal::Call::OnSetUp (OpalConnection & connection)
{
parse_info (connection);
@@ -391,7 +412,8 @@
}
-void Call::OnHold (bool on_hold)
+void
+Opal::Call::OnHold (bool on_hold)
{
if (on_hold)
runtime.run_in_main (held.make_slot ());
@@ -400,7 +422,8 @@
}
-void Call::OnOpenMediaStream (OpalMediaStream & stream)
+void
+Opal::Call::OnOpenMediaStream (OpalMediaStream & stream)
{
StreamType type = (stream.GetSessionID () == OpalMediaFormat::DefaultAudioSessionID) ? Audio : Video;
bool is_transmitting = false;
@@ -408,13 +431,14 @@
stream_name = std::string ((const char *) stream.GetMediaFormat ().GetEncodingName ());
std::transform (stream_name.begin (), stream_name.end (), stream_name.begin (), (int (*) (int)) toupper);
- is_transmitting = !stream.IsSource ();
+ is_transmitting = !stream.IsSource ();
runtime.run_in_main (sigc::bind (stream_opened, stream_name, type, is_transmitting));
}
-void Call::OnClosedMediaStream (OpalMediaStream & stream)
+void
+Opal::Call::OnClosedMediaStream (OpalMediaStream & stream)
{
StreamType type = (stream.GetSessionID () == OpalMediaFormat::DefaultAudioSessionID) ? Audio : Video;
bool is_transmitting = false;
@@ -422,14 +446,15 @@
stream_name = std::string ((const char *) stream.GetMediaFormat ().GetEncodingName ());
std::transform (stream_name.begin (), stream_name.end (), stream_name.begin (), (int (*) (int)) toupper);
- is_transmitting = !stream.IsSource ();
+ is_transmitting = !stream.IsSource ();
runtime.run_in_main (sigc::bind (stream_closed, stream_name, type, is_transmitting));
}
-void Call::OnRTPStatistics (const OpalConnection & /* connection */,
- const RTP_Session & session)
+void
+Opal::Call::OnRTPStatistics (const OpalConnection & /* connection */,
+ const RTP_Session & session)
{
PWaitAndSignal m(stats_mutex); // The stats are computed from two different threads
@@ -437,7 +462,7 @@
PTimeInterval t = PTime () - last_a_tick;
if (t.GetMilliSeconds () < 500)
return;
-
+
unsigned elapsed_seconds = max ((unsigned long) t.GetMilliSeconds (), (unsigned long) 1);
double octets_received = session.GetOctetsReceived ();
double octets_sent = session.GetOctetsSent ();
@@ -445,7 +470,7 @@
re_a_bw = max ((octets_received - re_a_bytes) / elapsed_seconds, 0.0);
tr_a_bw = max ((octets_sent - tr_a_bytes) / elapsed_seconds, 0.0);
- re_a_bytes = octets_received;
+ re_a_bytes = octets_received;
tr_a_bytes = octets_sent;
last_a_tick = PTime ();
@@ -469,7 +494,7 @@
re_v_bw = max ((octets_received - re_v_bytes) / elapsed_seconds, 0.0);
tr_v_bw = max ((octets_sent - tr_v_bytes) / elapsed_seconds, 0.0);
- re_v_bytes = octets_received;
+ re_v_bytes = octets_received;
tr_v_bytes = octets_sent;
last_v_tick = PTime ();
@@ -486,7 +511,8 @@
}
-void Call::OnAnswer (PThread &, INT /*param*/)
+void
+Opal::Call::OnAnswer (PThread &, INT /*param*/)
{
PSafePtr<OpalConnection> connection = NULL;
PSafePtr<OpalPCSSConnection> conn = NULL;
@@ -499,11 +525,9 @@
connection = GetConnection (i);
i++;
- } while (!PIsDescendant(&(*connection), OpalPCSSConnection));
+ } while (!PIsDescendant(&(*connection), OpalPCSSConnection));
if (PIsDescendant(&(*connection), OpalPCSSConnection))
PDownCast (OpalPCSSConnection, &(*connection))->AcceptIncoming ();
}
}
-
-
Modified: trunk/src/endpoints/opal-call.h
==============================================================================
--- trunk/src/endpoints/opal-call.h (original)
+++ trunk/src/endpoints/opal-call.h Fri Mar 21 11:51:25 2008
@@ -27,9 +27,9 @@
/*
* opal-call.h - description
* ------------------------------------------
- * begin : written in 2007 by Damien Sandras
+ * begin : written in 2007 by Damien Sandras
* copyright : (c) 2007 by Damien Sandras
- * description : declaration of the interface of a call handled by
+ * description : declaration of the interface of a call handled by
* Opal.
*
*/
@@ -62,17 +62,17 @@
~Call () { };
- /*
+ /*
* Call Management
*/
/** Hangup the call
*/
- void hangup ();
+ void hangup ();
/** Answer an incoming call
*/
- void answer ();
+ void answer ();
/** Transfer the call to the specified uri
* @param: uri: where to transfer the call
@@ -94,42 +94,56 @@
void send_dtmf (const char dtmf);
- /*
+ /*
* Call Information
*/
/** Return the call id
* @return: the call id
*/
- std::string get_id ();
-
+ const std::string get_id () const;
+
/** Return the remote party name
* @return: the remote party name
*/
- std::string get_remote_party_name ();
+ const std::string get_remote_party_name () const;
/** Return the remote application
* @return: the remote application
*/
- std::string get_remote_application ();
+ const std::string get_remote_application () const;
/** Return the remote callback uri
* @return: the remote uri
*/
- std::string get_remote_uri ();
+ const std::string get_remote_uri () const;
/** Return the call duration
* @return: the current call duration
*/
- std::string get_call_duration ();
+ const std::string get_call_duration () const;
public:
+ /* Implementation of inherited methods
+ */
+
+ bool is_outgoing () const { return outgoing; }
+ double get_received_audio_bandwidth () const { return re_a_bw; }
+ double get_transmitted_audio_bandwidth () const { return tr_a_bw; }
+ double get_received_video_bandwidth () const { return re_v_bw; }
+ double get_transmitted_video_bandwidth () const { return tr_v_bw; }
+ unsigned get_jitter_size () const { return jitter; }
+ double get_lost_packets () const { return lost_packets; }
+ double get_late_packets () const { return late_packets; }
+ double get_out_of_order_packets () const { return out_of_order_packets; }
+
+
/*
- * Opal Callbacks
+ * Opal Callbacks
*/
void OnHold (bool on_hold);
@@ -151,7 +165,7 @@
PDECLARE_NOTIFIER (PThread, Opal::Call, OnAnswer);
-
+
/*
* Helper methods
*/
@@ -164,6 +178,30 @@
Ekiga::ServiceCore & core;
Ekiga::Runtime & runtime;
+
+ std::string remote_party_name;
+ std::string remote_uri;
+ std::string remote_application;
+
+ bool outgoing;
+
+ double re_a_bw;
+ double tr_a_bw;
+ double re_v_bw;
+ double tr_v_bw;
+ unsigned re_v_fps;
+ unsigned tr_v_fps;
+ unsigned tr_width;
+ unsigned tr_height;
+ unsigned re_width;
+ unsigned re_height;
+
+ unsigned jitter;
+
+ double lost_packets;
+ double late_packets;
+ double out_of_order_packets;
+
PMutex stats_mutex;
double re_a_bytes;
double tr_a_bytes;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]