From 4691c092d79b901a11b2aac37232460a05891055 Mon Sep 17 00:00:00 2001 From: bossiel Date: Mon, 14 Jan 2013 03:49:43 +0000 Subject: [PATCH] - *Adds support for Firefox Nightly* - Fix issue 60, issue 65 and issue 66 --- SIPml.js | 182 +- call.htm | 104 +- docgen.index.html | 4 +- docs/html/_conding.html | 129 - docs/html/_introduction.html | 113 - docs/html/annotated.html | 113 - docs/html/architecture.png | Bin 17511 -> 0 bytes docs/html/bc_s.png | Bin 705 -> 0 bytes docs/html/bdwn.png | Bin 147 -> 0 bytes docs/html/bootstrap.css | 3990 ---------------- docs/html/classes.html | 118 - .../classtsip__event__invite-members.html | 111 - docs/html/classtsip__event__invite.html | 180 - .../classtsip__event__register-members.html | 111 - docs/html/classtsip__event__register.html | 187 - docs/html/classtsip__session-members.html | 120 - docs/html/classtsip__session.html | 384 -- .../classtsip__session__invite-members.html | 118 - docs/html/classtsip__session__invite.html | 383 -- .../classtsip__session__register-members.html | 113 - docs/html/classtsip__session__register.html | 193 - docs/html/classtsip__stack-members.html | 123 - docs/html/classtsip__stack.html | 593 --- docs/html/closed.png | Bin 126 -> 0 bytes docs/html/docs.css | 845 ---- docs/html/doxygen.css | 4166 ----------------- docs/html/doxygen.png | Bin 3942 -> 0 bytes docs/html/functions.html | 179 - docs/html/functions_func.html | 164 - docs/html/functions_vars.html | 129 - docs/html/global_view.png | Bin 65241 -> 0 bytes docs/html/index.html | 132 - docs/html/jquery.js | 64 - docs/html/nav_f.png | Bin 159 -> 0 bytes docs/html/nav_h.png | Bin 97 -> 0 bytes docs/html/open.png | Bin 118 -> 0 bytes .../page___setting__up_sip_m_l5_project.html | 113 - docs/html/page_avcalls.html | 133 - docs/html/page_call.html | 118 - docs/html/page_create_sip_stack.html | 152 - docs/html/page_login.html | 136 - docs/html/page_sms_like.html | 132 - docs/html/page_tsip_stack.html | 127 - docs/html/pages.html | 116 - docs/html/search/all_5f.html | 25 - docs/html/search/all_5f.js | 4 - docs/html/search/all_63.html | 25 - docs/html/search/all_63.js | 4 - docs/html/search/all_64.html | 25 - docs/html/search/all_64.js | 4 - docs/html/search/all_67.html | 25 - docs/html/search/all_67.js | 5 - docs/html/search/all_68.html | 25 - docs/html/search/all_68.js | 4 - docs/html/search/all_69.html | 25 - docs/html/search/all_69.js | 4 - docs/html/search/all_6f.html | 25 - docs/html/search/all_6f.js | 7 - docs/html/search/all_72.html | 25 - docs/html/search/all_72.js | 5 - docs/html/search/all_73.html | 25 - docs/html/search/all_73.js | 14 - docs/html/search/all_74.html | 25 - docs/html/search/all_74.js | 5 - docs/html/search/all_75.html | 25 - docs/html/search/all_75.js | 4 - docs/html/search/classes_74.html | 25 - docs/html/search/classes_74.js | 5 - docs/html/search/close.png | Bin 273 -> 0 bytes docs/html/search/functions_63.html | 25 - docs/html/search/functions_63.js | 4 - docs/html/search/functions_64.html | 25 - docs/html/search/functions_64.js | 4 - docs/html/search/functions_67.html | 25 - docs/html/search/functions_67.js | 5 - docs/html/search/functions_68.html | 25 - docs/html/search/functions_68.js | 4 - docs/html/search/functions_69.html | 25 - docs/html/search/functions_69.js | 4 - docs/html/search/functions_72.html | 25 - docs/html/search/functions_72.js | 5 - docs/html/search/functions_73.html | 25 - docs/html/search/functions_73.js | 14 - docs/html/search/functions_74.html | 25 - docs/html/search/functions_74.js | 5 - docs/html/search/functions_75.html | 25 - docs/html/search/functions_75.js | 4 - docs/html/search/mag_sel.png | Bin 563 -> 0 bytes docs/html/search/nomatches.html | 12 - docs/html/search/search.css | 238 - docs/html/search/search.js | 801 ---- docs/html/search/search_l.png | Bin 604 -> 0 bytes docs/html/search/search_m.png | Bin 158 -> 0 bytes docs/html/search/search_r.png | Bin 612 -> 0 bytes docs/html/search/variables_5f.html | 25 - docs/html/search/variables_5f.js | 4 - docs/html/search/variables_6f.html | 25 - docs/html/search/variables_6f.js | 7 - docs/html/sipml-45x51.png | Bin 6918 -> 0 bytes docs/html/tab_a.png | Bin 140 -> 0 bytes docs/html/tab_b.png | Bin 178 -> 0 bytes docs/html/tab_h.png | Bin 192 -> 0 bytes docs/html/tab_s.png | Bin 189 -> 0 bytes docs/html/tabs.css | 59 - docs/images/OSes.png | Bin 50897 -> 0 bytes docs/images/architecture.png | Bin 17511 -> 0 bytes docs/images/architecture_asterisk.png | Bin 36954 -> 0 bytes docs/images/boghe_rtcweb.png | Bin 41456 -> 0 bytes docs/images/chrome_flags.png | Bin 47535 -> 0 bytes docs/images/global_view.png | Bin 65241 -> 0 bytes docs/images/imsdroid_rtcweb.png | Bin 79545 -> 0 bytes docs/latex/Makefile | 19 - docs/latex/_conding.tex | 41 - docs/latex/_introduction.tex | 23 - docs/latex/doxygen.sty | 483 -- docs/latex/files.tex | 4 - docs/latex/index.tex | 5 - docs/latex/make.bat | 23 - .../page___setting__up_sip_m_l5_project.tex | 20 - docs/latex/page_tsip_stack.tex | 1 - docs/latex/refman.tex | 65 - docs/latex/tsip__stack_8js.tex | 94 - docs/programmer-guide-1.0.doc | Bin 900608 -> 0 bytes docs/rtf/refman.rtf | 1319 ------ docs/src/sipml5.cxx | 265 -- docs/src/tinySIP/src/api/tsip_api_invite.cxx | 0 .../src/tinySIP/src/api/tsip_api_register.cxx | 0 docs/src/tinySIP/src/tsip_session.cxx | 124 - docs/src/tinySIP/src/tsip_stack.cxx | 300 -- expert.htm | 1 + index.html | 14 +- release.sh | 2 +- release/SIPml-api.js | 4 +- release/call.htm | 104 +- release/expert.htm | 1 + release/index.html | 14 +- src/tinyMEDIA/src/tmedia_session.js | 37 +- src/tinyMEDIA/src/tmedia_session_jsep.js | 214 +- src/tinyMEDIA/src/tmedia_session_roap.js | 12 +- src/tinyMEDIA/src/tmedia_webrtc4all.js | 12 +- src/tinySAK/src/tsk_utils.js | 2 +- src/tinySIP/src/api/tsip_api_invite.js | 62 +- src/tinySIP/src/dialogs/tsip_dialog_invite.js | 53 +- .../src/dialogs/tsip_dialog_invite__server.js | 4 +- .../src/transactions/tsip_transac_ist.js | 2 +- src/tinySIP/src/tsip_event.js | 3 + src/tinySIP/src/tsip_stack.js | 8 +- tests/test_webrtc.html | 119 +- 148 files changed, 673 insertions(+), 18666 deletions(-) delete mode 100644 docs/html/_conding.html delete mode 100644 docs/html/_introduction.html delete mode 100644 docs/html/annotated.html delete mode 100644 docs/html/architecture.png delete mode 100644 docs/html/bc_s.png delete mode 100644 docs/html/bdwn.png delete mode 100644 docs/html/bootstrap.css delete mode 100644 docs/html/classes.html delete mode 100644 docs/html/classtsip__event__invite-members.html delete mode 100644 docs/html/classtsip__event__invite.html delete mode 100644 docs/html/classtsip__event__register-members.html delete mode 100644 docs/html/classtsip__event__register.html delete mode 100644 docs/html/classtsip__session-members.html delete mode 100644 docs/html/classtsip__session.html delete mode 100644 docs/html/classtsip__session__invite-members.html delete mode 100644 docs/html/classtsip__session__invite.html delete mode 100644 docs/html/classtsip__session__register-members.html delete mode 100644 docs/html/classtsip__session__register.html delete mode 100644 docs/html/classtsip__stack-members.html delete mode 100644 docs/html/classtsip__stack.html delete mode 100644 docs/html/closed.png delete mode 100644 docs/html/docs.css delete mode 100644 docs/html/doxygen.css delete mode 100644 docs/html/doxygen.png delete mode 100644 docs/html/functions.html delete mode 100644 docs/html/functions_func.html delete mode 100644 docs/html/functions_vars.html delete mode 100644 docs/html/global_view.png delete mode 100644 docs/html/index.html delete mode 100644 docs/html/jquery.js delete mode 100644 docs/html/nav_f.png delete mode 100644 docs/html/nav_h.png delete mode 100644 docs/html/open.png delete mode 100644 docs/html/page___setting__up_sip_m_l5_project.html delete mode 100644 docs/html/page_avcalls.html delete mode 100644 docs/html/page_call.html delete mode 100644 docs/html/page_create_sip_stack.html delete mode 100644 docs/html/page_login.html delete mode 100644 docs/html/page_sms_like.html delete mode 100644 docs/html/page_tsip_stack.html delete mode 100644 docs/html/pages.html delete mode 100644 docs/html/search/all_5f.html delete mode 100644 docs/html/search/all_5f.js delete mode 100644 docs/html/search/all_63.html delete mode 100644 docs/html/search/all_63.js delete mode 100644 docs/html/search/all_64.html delete mode 100644 docs/html/search/all_64.js delete mode 100644 docs/html/search/all_67.html delete mode 100644 docs/html/search/all_67.js delete mode 100644 docs/html/search/all_68.html delete mode 100644 docs/html/search/all_68.js delete mode 100644 docs/html/search/all_69.html delete mode 100644 docs/html/search/all_69.js delete mode 100644 docs/html/search/all_6f.html delete mode 100644 docs/html/search/all_6f.js delete mode 100644 docs/html/search/all_72.html delete mode 100644 docs/html/search/all_72.js delete mode 100644 docs/html/search/all_73.html delete mode 100644 docs/html/search/all_73.js delete mode 100644 docs/html/search/all_74.html delete mode 100644 docs/html/search/all_74.js delete mode 100644 docs/html/search/all_75.html delete mode 100644 docs/html/search/all_75.js delete mode 100644 docs/html/search/classes_74.html delete mode 100644 docs/html/search/classes_74.js delete mode 100644 docs/html/search/close.png delete mode 100644 docs/html/search/functions_63.html delete mode 100644 docs/html/search/functions_63.js delete mode 100644 docs/html/search/functions_64.html delete mode 100644 docs/html/search/functions_64.js delete mode 100644 docs/html/search/functions_67.html delete mode 100644 docs/html/search/functions_67.js delete mode 100644 docs/html/search/functions_68.html delete mode 100644 docs/html/search/functions_68.js delete mode 100644 docs/html/search/functions_69.html delete mode 100644 docs/html/search/functions_69.js delete mode 100644 docs/html/search/functions_72.html delete mode 100644 docs/html/search/functions_72.js delete mode 100644 docs/html/search/functions_73.html delete mode 100644 docs/html/search/functions_73.js delete mode 100644 docs/html/search/functions_74.html delete mode 100644 docs/html/search/functions_74.js delete mode 100644 docs/html/search/functions_75.html delete mode 100644 docs/html/search/functions_75.js delete mode 100644 docs/html/search/mag_sel.png delete mode 100644 docs/html/search/nomatches.html delete mode 100644 docs/html/search/search.css delete mode 100644 docs/html/search/search.js delete mode 100644 docs/html/search/search_l.png delete mode 100644 docs/html/search/search_m.png delete mode 100644 docs/html/search/search_r.png delete mode 100644 docs/html/search/variables_5f.html delete mode 100644 docs/html/search/variables_5f.js delete mode 100644 docs/html/search/variables_6f.html delete mode 100644 docs/html/search/variables_6f.js delete mode 100644 docs/html/sipml-45x51.png delete mode 100644 docs/html/tab_a.png delete mode 100644 docs/html/tab_b.png delete mode 100644 docs/html/tab_h.png delete mode 100644 docs/html/tab_s.png delete mode 100644 docs/html/tabs.css delete mode 100644 docs/images/OSes.png delete mode 100644 docs/images/architecture.png delete mode 100644 docs/images/architecture_asterisk.png delete mode 100644 docs/images/boghe_rtcweb.png delete mode 100644 docs/images/chrome_flags.png delete mode 100644 docs/images/global_view.png delete mode 100644 docs/images/imsdroid_rtcweb.png delete mode 100644 docs/latex/Makefile delete mode 100644 docs/latex/_conding.tex delete mode 100644 docs/latex/_introduction.tex delete mode 100644 docs/latex/doxygen.sty delete mode 100644 docs/latex/files.tex delete mode 100644 docs/latex/index.tex delete mode 100644 docs/latex/make.bat delete mode 100644 docs/latex/page___setting__up_sip_m_l5_project.tex delete mode 100644 docs/latex/page_tsip_stack.tex delete mode 100644 docs/latex/refman.tex delete mode 100644 docs/latex/tsip__stack_8js.tex delete mode 100644 docs/programmer-guide-1.0.doc delete mode 100644 docs/rtf/refman.rtf delete mode 100644 docs/src/sipml5.cxx delete mode 100644 docs/src/tinySIP/src/api/tsip_api_invite.cxx delete mode 100644 docs/src/tinySIP/src/api/tsip_api_register.cxx delete mode 100644 docs/src/tinySIP/src/tsip_session.cxx delete mode 100644 docs/src/tinySIP/src/tsip_stack.cxx diff --git a/SIPml.js b/SIPml.js index e01cfa8..3fec463 100644 --- a/SIPml.js +++ b/SIPml.js @@ -301,7 +301,10 @@ Adds an event listener to the target object.

SIPml.Stack - *
starting
started
stopping
stopped
failed_to_start
failed_to_stop
i_new_call
i_new_message + + *
starting
started
stopping
stopped
failed_to_start
failed_to_stop
i_new_call
i_new_message
+ m_permission_requested
m_permission_accepted
m_permission_refused + SIPml.Stack.Event '*' is used to listen for all events @@ -329,7 +332,8 @@ Adds an event listener to the target object.

SIPml.Session.Call m_early_media
m_local_hold_ok
m_local_hold_nok
m_local_resume_ok
m_local_resume_nok
m_remote_hold
m_remote_resume
- m_stream_video_local_added
m_stream_video_local_removed
m_stream_video_remote_added
m_stream_video_remote_removed + m_stream_video_local_added
m_stream_video_local_removed
m_stream_video_remote_added
m_stream_video_remote_removed
+ m_stream_audio_local_added
m_stream_audio_local_removed
m_stream_audio_remote_added
m_stream_audio_remote_removed
i_ect_new_call
o_ect_trying
o_ect_accepted
o_ect_completed
i_ect_completed
o_ect_failed
i_ect_failed
o_ect_notify
i_ect_notify
i_ect_requested SIPml.Session.Event @@ -777,53 +781,118 @@ SIPml.Stack = function (o_conf) { var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id]; if (!oSession) { switch (e.e_invite_type) { - case tsip_event_invite_type_e.I_NEW_CALL: break; - case tsip_event_invite_type_e.M_STREAM_VIDEO_LOCAL_ADDED: - case tsip_event_invite_type_e.M_STREAM_VIDEO_REMOTE_ADDED: - case tsip_event_invite_type_e.M_STREAM_VIDEO_LOCAL_REMOVED: - case tsip_event_invite_type_e.M_STREAM_VIDEO_REMOTE_REMOVED: + case tsip_event_invite_type_e.I_NEW_CALL: + case tsip_event_invite_type_e.M_STREAM_LOCAL_REQUESTED: + case tsip_event_invite_type_e.M_STREAM_LOCAL_ACCEPTED: + case tsip_event_invite_type_e.M_STREAM_LOCAL_REFUSED: + break; + + case tsip_event_invite_type_e.M_STREAM_LOCAL_ADDED: + case tsip_event_invite_type_e.M_STREAM_REMOTE_ADDED: + case tsip_event_invite_type_e.M_STREAM_LOCAL_REMOVED: + case tsip_event_invite_type_e.M_STREAM_REMOTE_REMOVED: case tsip_event_invite_type_e.I_AO_REQUEST: tsk_utils_log_info('Not notifying to session with id = ' + i_session_id + ' for event = ' + e.e_invite_type); return; + default: tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type); return; } } - var attachVideo = function (oView, oUrl) { - if (window.HTMLVideoElement && oView instanceof window.HTMLVideoElement) { - oView.src = oUrl; - } + + + var _setStream = function(o_view, o_stream, o_url, b_audio){ + if(o_stream){ + if(!b_audio && o_stream.videoTracks.length > 0){ + if (window.HTMLVideoElement && o_view instanceof window.HTMLVideoElement){ + if((o_view.src = o_url)){ + o_view.play(); + } + } + return true; + } + if(b_audio && o_stream.audioTracks.length > 0){ + if (window.HTMLAudioElement && o_view instanceof window.HTMLAudioElement){ + if((o_view.src = o_url)){ + o_view.play(); + } + } + return true; + } + } } + var attachStream = function(bLocal){ + var o_stream = bLocal ? e.o_session.get_stream_local() : e.o_session.get_stream_remote(); + var o_url = bLocal ? e.o_session.get_url_local() : e.o_session.get_url_remote(); + if(_setStream((bLocal ? oSession.videoLocal : oSession.videoRemote), o_stream, o_url, false)){ + dispatchEvent(bLocal ? 'm_stream_video_local_added' : 'm_stream_video_remote_added'); + } + if(_setStream((bLocal ? oSession.audioLocal : oSession.audioRemote), o_stream, o_url, true)){ + dispatchEvent(bLocal ? 'm_stream_audio_local_added' : 'm_stream_audio_remote_added'); + } + } + var deattachStream = function(bLocal){ + var o_stream = bLocal ? e.o_session.get_stream_local() : e.o_session.get_stream_remote(); + if(_setStream((bLocal ? oSession.videoLocal : oSession.videoRemote), o_stream, null, false)){ + dispatchEvent(bLocal ? 'm_stream_video_local_removed' : 'm_stream_video_remote_removed'); + } + if(_setStream((bLocal ? oSession.audioLocal : oSession.audioRemote), o_stream, null, true)){ + dispatchEvent(bLocal ? 'm_stream_audio_local_removed' : 'm_stream_audio_remote_removed'); + } + } + + var dispatchEvent = function (s_event_type) { + if (s_event_type) { + // 'i_new_call', 'm_permission_requested', 'm_permission_accepted' and 'm_permission_refused' are stack-level event + switch (s_event_type) { + case 'i_new_call': + case 'm_permission_requested': + case 'm_permission_accepted': + case 'm_permission_refused': + { + var oNewEvent = new SIPml.Stack.Event(s_event_type, e); + if(s_event_type == 'i_new_call'){ + oNewEvent.newSession = new SIPml.Session.Call(e.o_session); + e.o_session.o_stack.oStack.ao_sessions[i_session_id] = oNewEvent.newSession; // save session + } + e.o_session.o_stack.oStack.dispatchEvent({ s_type: s_event_type, o_value: oNewEvent }); + break; + } + default: + { + oSession.dispatchEvent({ s_type: s_event_type, o_value: new SIPml.Session.Event(oSession, s_event_type, e) }); + break; + } + } + } + } + switch (e.e_invite_type) { case tsip_event_invite_type_e.I_NEW_CALL: s_type = 'i_new_call'; break; case tsip_event_invite_type_e.I_ECT_NEW_CALL: s_type = 'i_ect_new_call'; break; case tsip_event_invite_type_e.I_AO_REQUEST: s_type = 'i_ao_request'; break; case tsip_event_invite_type_e.M_EARLY_MEDIA: s_type = 'm_early_media'; break; - case tsip_event_invite_type_e.M_STREAM_VIDEO_LOCAL_ADDED: + case tsip_event_invite_type_e.M_STREAM_LOCAL_REQUESTED: s_type = 'm_permission_requested'; break; + case tsip_event_invite_type_e.M_STREAM_LOCAL_ACCEPTED: s_type = 'm_permission_accepted'; break; + case tsip_event_invite_type_e.M_STREAM_LOCAL_REFUSED: s_type = 'm_permission_refused'; break; + case tsip_event_invite_type_e.M_STREAM_LOCAL_ADDED: { - s_type = 'm_stream_video_local_added'; - attachVideo(oSession.videoLocal, e.o_session.get_url_video_local()); - break; + return attachStream(true); } - case tsip_event_invite_type_e.M_STREAM_VIDEO_LOCAL_REMOVED: + case tsip_event_invite_type_e.M_STREAM_LOCAL_REMOVED: { - s_type = 'm_stream_video_local_removed'; - attachVideo(oSession.videoLocal, undefined); - break; + return deattachStream(true); } - case tsip_event_invite_type_e.M_STREAM_VIDEO_REMOTE_ADDED: + case tsip_event_invite_type_e.M_STREAM_REMOTE_ADDED: { - s_type = 'm_stream_video_remote_added'; - attachVideo(oSession.videoRemote, e.o_session.get_url_video_remote()); - break; + return attachStream(false); } - case tsip_event_invite_type_e.M_STREAM_VIDEO_REMOTE_REMOVED: + case tsip_event_invite_type_e.M_STREAM_REMOTE_REMOVED: { - s_type = 'm_stream_video_remote_removed'; - break; + return deattachStream(false); } case tsip_event_invite_type_e.M_LOCAL_HOLD_OK: s_type = 'm_local_hold_ok'; break; case tsip_event_invite_type_e.M_LOCAL_HOLD_NOK: s_type = 'm_local_hold_nok'; break; @@ -843,18 +912,8 @@ SIPml.Stack = function (o_conf) { default: break; } - if (s_type) { - // 'i_new_call' is stack-level event - if (s_type == 'i_new_call') { - var oNewEvent = new SIPml.Stack.Event(s_type, e); - oNewEvent.newSession = new SIPml.Session.Call(e.o_session); - e.o_session.o_stack.oStack.ao_sessions[i_session_id] = oNewEvent.newSession; // save session - e.o_session.o_stack.oStack.dispatchEvent({ s_type: s_type, o_value: oNewEvent}); - } - else { - oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) }); - } - } + // dispatch event + dispatchEvent(s_type); } } @@ -984,6 +1043,7 @@ o_registration.register() var o_audiovideo = this.newSession('call-audiovideo', { video_local: document.getElementById('video_local'), video_remote: document.getElementById('video_remote'), + audio_remote: document.getElementById('audio_remote'), sip_caps: [ {name: '+g.oma.sip-im'}, {name: '+sip.ice'}, @@ -1058,12 +1118,14 @@ Anonymous SIP Session configuration object. @property {Integer} [expires] Session timeout in seconds. @property {HTMLVideoElement} [video_local] HTMLVideoElement where to display the local video preview. This propety should be only used for video sessions. @property {HTMLVideoElement} [video_remote] HTMLVideoElement where to display the remote video stream. This propety should be only used for video sessions. +@property {HTMLAudioElement} [audio_remote] HTMLAudioElement used to playback the remote audio stream. This propety should be only used for audio sessions. @property {Array} [sip_caps] {name,value} pairs defining the SIP capabilities associated to this session. The capabilities are added to the Contact header. Please refer to rfc3840 and rfc3841 for more information. @property {Array} [sip_headers] {name,value,session} trios defining the SIP headers associated to this session. session is a boolean defining whether the header have to be added to all outgoing request or not (initial only). @example var configuration = { expires: 200, + audio_remote: document.getElementById('audio_remote'), video_local: document.getElementById('video_local'), video_remote: document.getElementById('video_remote'), sip_caps: [ @@ -1133,19 +1195,39 @@ SIPml.Session.prototype.setConfiguration = function(o_conf){ if(this instanceof SIPml.Session.Call){ this.videoLocal = o_conf.video_local; this.videoRemote = o_conf.video_remote; - if (window.HTMLVideoElement && this.videoLocal instanceof window.HTMLVideoElement) { - var oldSrc = this.videoLocal.src; - this.videoLocal.src = o_session.get_url_video_local(); - if(oldSrc != this.videoLocal.src){ - this.dispatchEvent({ s_type: 'm_stream_video_local_added', o_value: new SIPml.Session.Event(this, 'm_stream_video_local_added') }); + this.audioRemote = o_conf.audio_remote; + this.audioLocal = o_conf.audio_local; + + var _addStream = function(o_view, o_stream, o_url, b_audio){ + if(o_stream){ + if(!b_audio && o_stream.videoTracks.length > 0){ + if (window.HTMLVideoElement && o_view instanceof window.HTMLVideoElement){ + if(o_view.src == o_url) return false; // unchanged + else if(o_view.src = o_url) o_view.play(); + } + return true; + } + if(b_audio && o_stream.audioTracks.length > 0){ + if (window.HTMLAudioElement && o_view instanceof window.HTMLAudioElement){ + if(o_view.src == o_url) return false; // unchanged + else if(o_view.src = o_url) o_view.play(); + } + return true; + } } + } + + if(_addStream(this.videoLocal, o_session.get_stream_local(), o_session.get_url_local(), false)){ + this.dispatchEvent({ s_type: 'm_stream_video_local_added', o_value: new SIPml.Session.Event(this, 'm_stream_video_local_added') }); } - if (window.HTMLVideoElement && this.videoRemote instanceof window.HTMLVideoElement) { - var oldSrc = this.videoRemote.src; - this.videoRemote.src = o_session.get_url_video_remote(); - if(oldSrc != this.videoRemote.src){ - this.dispatchEvent({ s_type: 'm_stream_video_remote_added', o_value: new SIPml.Session.Event(this, 'm_stream_video_remote_added') }); - } + if(_addStream(this.videoRemote, o_session.get_stream_remote(), o_session.get_url_remote(), false)){ + this.dispatchEvent({ s_type: 'm_stream_video_remote_added', o_value: new SIPml.Session.Event(this, 'm_stream_video_remote_added') }); + } + if(_addStream(this.audioLocal, o_session.get_stream_local(), o_session.get_url_local(), false)){ + this.dispatchEvent({ s_type: 'm_stream_audio_local_added', o_value: new SIPml.Session.Event(this, 'm_stream_audio_local_added') }); + } + if(_addStream(this.audioRemote, o_session.get_stream_remote(), o_session.get_url_remote(), false)){ + this.dispatchEvent({ s_type: 'm_stream_audio_remote_added', o_value: new SIPml.Session.Event(this, 'm_stream_audio_remote_added') }); } } @@ -1322,6 +1404,7 @@ var listenerFunc = function(e){ var session = stack.newSession('call-audiovideo', { video_local: document.getElementById('video-local'), video_remote: document.getElementById('video-remote'), + audio_remote: document.getElementById('audio-remote'), events_listener: { events: '*', listener: listenerFunc }, sip_caps: [ { name: '+g.oma.sip-im' }, @@ -1358,6 +1441,7 @@ var session = stack.newSession('call-a session.call('johndoe', { video_local: document.getElementById('video-local'), video_remote: document.getElementById('video-remote'), + audio_remote: document.getElementById('audio-remote'), events_listener: { events: '*', listener: listenerFunc }, sip_caps: [ { name: '+g.oma.sip-im' }, diff --git a/call.htm b/call.htm index f6ebcb7..df363be 100644 --- a/call.htm +++ b/call.htm @@ -18,7 +18,7 @@ DEBUG VERSION: 'SIPml-api.js' RELEASE VERSION: 'release/SIPml-api.js' --> - + @@ -27,6 +27,12 @@ padding-top: 80px; padding-bottom: 40px; } + .navbar-inner-red { + background-color: #600000; + background-image: none; + background-repeat: no-repeat; + filter: none; + } .full-screen{ position: absolute; left: 0; @@ -109,7 +115,7 @@ var txtRegStatus, txtCallStatus; var btnRegister, btnUnRegister; var btnFullScreen, btnHoldResume, btnTransfer, btnKeyPad; - var videoRemote, videoLocal; + var videoRemote, videoLocal, audioRemote; var divVideo, divCallOptions; var tdVideo; var bFullScreen = false; @@ -144,6 +150,8 @@ videoLocal = document.getElementById("video_local"); videoRemote = document.getElementById("video_remote"); + audioRemote = document.getElementById("audio_remote"); + divVideo = document.getElementById("divVideo"); divCallOptions = document.getElementById("divCallOptions"); //divVideo.style.height = '0px'; @@ -359,7 +367,7 @@ enable_rtcweb_breaker: (window.localStorage ? window.localStorage.getItem('org.doubango.expert.enable_rtcweb_breaker') == "true" : false), events_listener: { events: '*', listener: onSipEventStack }, sip_headers: [ - { name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.07.01.2013' }, + { name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.2013.01.14' }, { name: 'Organization', value: 'Doubango Telecom' } ] } @@ -386,6 +394,7 @@ function sipCall() { // call configuration var oConf = { + audio_remote: audioRemote, video_local: viewVideoLocal, video_remote: viewVideoRemote, events_listener: { events: '*', listener: onSipEventSession }, @@ -552,7 +561,7 @@ } function uiVideoDisplayEvent(b_local, b_added) { - if (!bDisableVideo) { + //if (!bDisableVideo) { var o_elt_video = b_local ? videoLocal : videoRemote; if (b_added) { @@ -576,7 +585,7 @@ } fullScreen(false); } - } + //} } function uiVideoDisplayShowHide(b_show) { @@ -591,6 +600,33 @@ btnFullScreen.disabled = !b_show; } + function uiCallTerminated(s_description){ + btnCall.value = 'Call'; + btnHangUp.value = 'HangUp'; + btnHoldResume.value = 'hold'; + btnCall.disabled = false; + btnHangUp.disabled = true; + + oSipSessionCall = null; + + stopRingbackTone(); + stopRingTone(); + + txtCallStatus.innerHTML = "" + s_description + ""; + uiVideoDisplayShowHide(false); + divCallOptions.style.opacity = 0; + + if (oNotifICall) { + oNotifICall.cancel(); + oNotifICall = null; + } + + uiVideoDisplayEvent(true, false); + uiVideoDisplayEvent(false, false); + + setTimeout(function () { if (!oSipSessionCall) txtCallStatus.innerHTML = ''; }, 2500); + } + // Callback function for SIP Stacks function onSipEventStack(e /*SIPml.Stack.Event*/) { if (window.console) window.console.info('==stack event = ' + e.type); @@ -652,7 +688,7 @@ btnHangUp.disabled = false; startRingTone(); - + var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown'); txtCallStatus.innerHTML = "Incoming call from [" + sRemoteNumber + "]"; showNotifICall(sRemoteNumber); @@ -660,6 +696,21 @@ break; } + case 'm_permission_requested': + { + document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner-red'); + break; + } + case 'm_permission_accepted': + case 'm_permission_refused': + { + document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner'); + if(e.type == 'm_permission_refused'){ + uiCallTerminated('Media stream permission denied'); + } + break; + } + case 'starting': default: break; } }; @@ -713,30 +764,7 @@ txtRegStatus.innerHTML = "" + e.description + ""; } else if (e.session == oSipSessionCall) { - btnCall.value = 'Call'; - btnHangUp.value = 'HangUp'; - btnHoldResume.value = 'hold'; - btnCall.disabled = false; - btnHangUp.disabled = true; - - oSipSessionCall = null; - - stopRingbackTone(); - stopRingTone(); - - txtCallStatus.innerHTML = "" + e.description + ""; - uiVideoDisplayShowHide(false); - divCallOptions.style.opacity = 0; - - if (oNotifICall) { - oNotifICall.cancel(); - oNotifICall = null; - } - - uiVideoDisplayEvent(true, false); - uiVideoDisplayEvent(false, false); - - setTimeout(function () { if (!oSipSessionCall) txtCallStatus.innerHTML = ''; }, 2500); + uiCallTerminated(e.description); } break; } // 'terminating' | 'terminated' @@ -769,6 +797,15 @@ } break; } + + case 'm_stream_audio_local_added': + case 'm_stream_audio_local_removed': + case 'm_stream_audio_remote_added': + case 'm_stream_audio_remote_removed': + { + break; + } + case 'i_ect_new_call': { oSipSessionTransferCall = e.session; @@ -930,7 +967,7 @@