From: Magnus H. <leg...@us...> - 2008-10-16 22:22:34
|
Update of /cvsroot/emacs-jabber/tox In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3393 Modified Files: jabber-tox.el Log Message: Rewrite codec querying Index: jabber-tox.el =================================================================== RCS file: /cvsroot/emacs-jabber/tox/jabber-tox.el,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- jabber-tox.el 16 Oct 2008 21:54:51 -0000 1.17 +++ jabber-tox.el 16 Oct 2008 22:22:28 -0000 1.18 @@ -234,45 +234,54 @@ (list nil state-data)) (t - ;; Tell tox what codecs the remote side supports - (dbus-call-method nil tox-name tox-session tox-session-interface - "SetRemoteCodecs" - 'ignore - '((array (struct int32 string byte uint32 uint32 (array (dict-entry string string))))) - (mapcar - (lambda (pt) - (jabber-xml-let-attributes - (id name clockrate channels) pt - (list id name 0 clockrate channels - (mapcar - (lambda (param) - (jabber-xml-let-attributes - (name value) param - (list name value))) - (jabber-xml-get-children pt 'parameter))))) - (plist-get state-data :payload-types))) + (let ((tox-session (plist-get state-data :tox-session))) + ;; Tell tox what codecs the remote side supports + (dbus-call-method + :session tox-name tox-session tox-session-interface + "SetRemoteCodecs" + ;;'((array (struct int32 string byte uint32 uint32 (array (dict-entry string string))))) + (mapcar + (lambda (pt) + (jabber-xml-let-attributes + (id name clockrate channels) pt + (list :struct + :int32 (string-to-number id) + :string name + :byte 0 + :uint32 clockrate + :uint32 channels + (cons + :array + (or + (mapcar + (lambda (param) + (jabber-xml-let-attributes + (name value) param + (list :dict-entry :string name :string value))) + (jabber-xml-get-children pt 'parameter)) + (list :signature "{ss}")))))) + payload-types)) - ;; Check if we have any codecs in common - (dbus-call-method nil tox-name tox-session tox-session-interface - "GetCodecIntersection" - (lexical-let ((jingle-fsm fsm)) - (lambda (dbus-fsm msg) - (ecase (dbus-message-type msg) - (:error - (fsm-send jingle-fsm - (cons :error - (dbus-error-to-string msg)))) - (:method-return - (fsm-send jingle-fsm - (cons :ok - (first (dbus-message-body-values msg))))))))) + ;; Check if we have any codecs in common + (let ((codec-intersection + (dbus-call-method + :session tox-name tox-session tox-session-interface + "GetCodecIntersection"))) + (setq state-data + (plist-put + state-data + :codec-intersection codec-intersection)) - ;; So, now we know that we stand a basic chance of fulfilling - ;; the request. Let's move on to PENDING. - ;; XXX: should we check codec intersection first? - (list :pending - (plist-put state-data :payload-types payload-types)) - )))))) + (if codec-intersection + ;; So, now we know that we stand a basic chance of fulfilling + ;; the request. Let's move on to PENDING. + (list :pending state-data) + + ;; Or, it might turn out that we don't have any codecs + ;; in common with our partner. + (jingle-send-iq state-data "session-terminate" + '(reason () (media-error))) + (list nil state-data)))))))))) (define-state jingle :wait-for-codec-intersection (fsm state-data event callback) @@ -335,7 +344,7 @@ (priority . ,(nth 7 c)) ;; how to translate type? ))) - components))))) + candidate))))) (add-to-list 'jabber-iq-set-xmlns-alist (cons jingle-ns 'jabber-jingle-incoming-iq)) |