Skip to content
Snippets Groups Projects
Commit 1da052eb authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

fix return values, protect unhandled cases

parent 93546e78
No related branches found
No related tags found
No related merge requests found
...@@ -222,8 +222,8 @@ void PulseLayer::startStream (void) ...@@ -222,8 +222,8 @@ void PulseLayer::startStream (void)
PulseLayer::stopStream (void) PulseLayer::stopStream (void)
{ {
_debug("PulseLayer::Stop stream\n"); _debug("PulseLayer::Stop stream\n");
pa_stream_flush( playback->pulseStream(), NULL, NULL ); //pa_stream_flush( playback->pulseStream(), NULL, NULL );
pa_stream_flush( record->pulseStream(), NULL, NULL ); //pa_stream_flush( record->pulseStream(), NULL, NULL );
flushMic(); flushMic();
... ...
......
...@@ -129,7 +129,7 @@ int Sdp::create_local_offer (){ ...@@ -129,7 +129,7 @@ int Sdp::create_local_offer (){
//sdp_addAttributes( _pool ); //sdp_addAttributes( _pool );
sdp_add_media_description( ); sdp_add_media_description( );
toString (); //toString ();
// Validate the sdp session // Validate the sdp session
status = pjmedia_sdp_validate( this->_local_offer ); status = pjmedia_sdp_validate( this->_local_offer );
...@@ -310,12 +310,16 @@ AudioCodec* Sdp::get_session_media( void ){ ...@@ -310,12 +310,16 @@ AudioCodec* Sdp::get_session_media( void ){
int nb_media; int nb_media;
int nb_codec; int nb_codec;
AudioCodec *codec = NULL; AudioCodec *codec = NULL;
std::vector<sdpMedia*> media_list;
nb_media = _session_media.size(); _debug ("sdp line 314 - get_session_media ()\n");
media_list = get_session_media_list ();
nb_media = media_list.size();
if (nb_media > 0) { if (nb_media > 0) {
nb_codec = _session_media[0]->get_media_codec_list().size(); nb_codec = media_list[0]->get_media_codec_list().size();
if (nb_codec > 0) { if (nb_codec > 0) {
codec = _session_media[0]->get_media_codec_list()[0]; codec = media_list[0]->get_media_codec_list()[0];
} }
} }
return codec; return codec;
... ...
......
...@@ -181,6 +181,8 @@ class Sdp { ...@@ -181,6 +181,8 @@ class Sdp {
void fetch_media_transport_info_from_remote_sdp (pjmedia_sdp_session *remote_sdp); void fetch_media_transport_info_from_remote_sdp (pjmedia_sdp_session *remote_sdp);
std::vector<sdpMedia*> get_session_media_list (void) { return _session_media; }
private: private:
/** Codec Map */ /** Codec Map */
std::vector<sdpMedia*> _local_media_cap; std::vector<sdpMedia*> _local_media_cap;
... ...
......
...@@ -660,8 +660,10 @@ SIPVoIPLink::onhold(const CallID& id) ...@@ -660,8 +660,10 @@ SIPVoIPLink::onhold(const CallID& id)
/* Create re-INVITE with new offer */ /* Create re-INVITE with new offer */
status = inv_session_reinvite (call, "sendonly"); status = inv_session_reinvite (call, "sendonly");
if (status != PJ_SUCCESS)
return false;
return (status == PJ_SUCCESS); return true;
} }
int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) { int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) {
...@@ -675,25 +677,29 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) { ...@@ -675,25 +677,29 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) {
if( local_sdp == NULL ){ if( local_sdp == NULL ){
_debug("! SIP Failure: unable to find local_sdp\n"); _debug("! SIP Failure: unable to find local_sdp\n");
return false; return !PJ_SUCCESS;
} }
// reinvite only if connected // reinvite only if connected
// Build the local SDP offer // Build the local SDP offer
status = call->getLocalSDP()->create_initial_offer( ); status = call->getLocalSDP()->create_initial_offer( );
if (status != PJ_SUCCESS)
return 1; // !PJ_SUCCESS
pjmedia_sdp_media_remove_all_attr(local_sdp->media[0], "sendrecv"); pjmedia_sdp_media_remove_all_attr(local_sdp->media[0], "sendrecv");
attr = pjmedia_sdp_attr_create(_pool, direction.c_str(), NULL); attr = pjmedia_sdp_attr_create(_pool, direction.c_str(), NULL);
pjmedia_sdp_media_add_attr(local_sdp->media[0], attr); pjmedia_sdp_media_add_attr(local_sdp->media[0], attr);
PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 );
// Build the reinvite request // Build the reinvite request
status = pjsip_inv_reinvite( call->getInvSession(), NULL, status = pjsip_inv_reinvite( call->getInvSession(), NULL,
local_sdp, &tdata ); local_sdp, &tdata );
PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); if (status != PJ_SUCCESS)
return 1; // !PJ_SUCCESS
// Send it // Send it
status = pjsip_inv_send_msg( call->getInvSession(), tdata ); status = pjsip_inv_send_msg( call->getInvSession(), tdata );
PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 ); if (status != PJ_SUCCESS)
return 1; // !PJ_SUCCESS
return PJ_SUCCESS; return PJ_SUCCESS;
} }
...@@ -874,10 +880,11 @@ SIPVoIPLink::getCurrentCodecName() ...@@ -874,10 +880,11 @@ SIPVoIPLink::getCurrentCodecName()
{ {
SIPCall *call; SIPCall *call;
AudioCodec *ac; AudioCodec *ac = NULL;
std::string name = ""; std::string name = "";
call = getSIPCall(Manager::instance().getCurrentCallId()); call = getSIPCall(Manager::instance().getCurrentCallId());
if (call)
ac = call->getLocalSDP()->get_session_media(); ac = call->getLocalSDP()->get_session_media();
if (ac) if (ac)
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment