ODF

Version 21 (Adrian Georgescu, 11/05/2014 11:51 am)

1 1 Adrian Georgescu
h1. ODF integration
2 1 Adrian Georgescu
3 17 Adrian Georgescu
This documents layout the changes required to support rich-text collaborative editing.
4 1 Adrian Georgescu
5 17 Adrian Georgescu
It is unclear at this stage, the mechanics of WebODF. Important items to analyse are:
6 15 Adrian Georgescu
7 15 Adrian Georgescu
 * Is a web server component required or not
8 17 Adrian Georgescu
 * How to identify/mix multiple editing flows part of the same session
9 15 Adrian Georgescu
 * How multi-party works as opposed to P2P
10 15 Adrian Georgescu
11 16 Adrian Georgescu
h2. Possible SDK changes
12 1 Adrian Georgescu
13 6 Adrian Georgescu
h3. Signaling
14 6 Adrian Georgescu
15 12 Adrian Georgescu
There is no need to alter anything related to SIP signalling. The SIP call id, which is unique for each session can be used as an identifier to group data related to same session inside the media streams. 
16 1 Adrian Georgescu
17 6 Adrian Georgescu
h3. Media
18 1 Adrian Georgescu
19 17 Adrian Georgescu
Media requires reliable transport which in SIP can only be MSRP. This provides reliable end-to-end transmission, TLS encryption and NAT traversal. Optional, OTR end-to-end encryption can be used.
20 11 Adrian Georgescu
21 7 Adrian Georgescu
h4. Variant 1
22 7 Adrian Georgescu
23 17 Adrian Georgescu
This is by far the simplest way. Establish a standard MSRP chat stream and add _'application/odf+xml'_ to the list of supported payloads by subclassing the standard Chat stream from the SDK. 
24 8 Adrian Georgescu
25 1 Adrian Georgescu
<pre>
26 10 Adrian Georgescu
class ODFChatStream(ChatStream):
27 10 Adrian Georgescu
    accept_types = ['message/cpim', 'text/*', 'application/im-iscomposing+xml', 'application/odf+xml']
28 1 Adrian Georgescu
</pre>
29 1 Adrian Georgescu
30 17 Adrian Georgescu
Then, during the session, send the data over the stream using:
31 1 Adrian Georgescu
32 1 Adrian Georgescu
<pre>
33 1 Adrian Georgescu
stream.send_message(data, content_type='application/odf+xml', timestamp=ISOTimestamp.now())
34 1 Adrian Georgescu
</pre>
35 17 Adrian Georgescu
36 19 Adrian Georgescu
On the receiving end, in the notification handler for message received:
37 17 Adrian Georgescu
38 17 Adrian Georgescu
<pre>
39 18 Adrian Georgescu
def _NH_ChatStreamGotMessage(self, stream, data):
40 18 Adrian Georgescu
    message = data.message
41 18 Adrian Georgescu
    if message.content_type == 'application/odf+xml',:
42 18 Adrian Georgescu
        # do something in the web view handling the editor
43 17 Adrian Georgescu
        return
44 17 Adrian Georgescu
</pre>
45 17 Adrian Georgescu
46 10 Adrian Georgescu
47 14 Adrian Georgescu
Optionally, one can add an attribute to the MSRP stream to signal the support for this feature inside the media stream:
48 10 Adrian Georgescu
49 10 Adrian Georgescu
<pre>
50 10 Adrian Georgescu
class ODFChatStream(ChatStream):
51 10 Adrian Georgescu
    accept_types = ['message/cpim', 'text/*', 'application/im-iscomposing+xml', 'application/odf+xml']
52 8 Adrian Georgescu
    def _create_local_media(self, uri_path):
53 1 Adrian Georgescu
        local_media = super(BlinkChatStream, self)._create_local_media(uri_path)
54 12 Adrian Georgescu
        local_media.attributes.append(SDPAttribute('features', 'odf-editor'))
55 1 Adrian Georgescu
        return local_media
56 9 Adrian Georgescu
</pre>
57 1 Adrian Georgescu
58 12 Adrian Georgescu
After session negotiation, the clients can invoke their corespondent GUI elements related to the collaborative editing when detecting _odf-editor_ feature in the remote stream. This approach will work with any MSRP chat implementation, the data will piggy-back on top of an existent chat stream in a non-disruptive way, which makes development of other end-points easy as no internal mechanisms of SIP session session initiation must be done.
59 7 Adrian Georgescu
60 1 Adrian Georgescu
h4. Variant 2
61 7 Adrian Georgescu
62 10 Adrian Georgescu
Create a complete new media type based on MSRP protocol similar to file-transfer or screen sharing. See SIP SIMPLE Client SDK MSRP streams definition:
63 1 Adrian Georgescu
64 1 Adrian Georgescu
<pre>
65 1 Adrian Georgescu
sipsimple/streams/msrp.py
66 1 Adrian Georgescu
</pre>
67 7 Adrian Georgescu
68 3 Adrian Georgescu
Example of a new type of stream
69 3 Adrian Georgescu
70 3 Adrian Georgescu
<pre>
71 3 Adrian Georgescu
class ODFStream(MSRPStreamBase):
72 3 Adrian Georgescu
    type = 'odf'
73 1 Adrian Georgescu
74 3 Adrian Georgescu
    media_type = 'odf'
75 3 Adrian Georgescu
    accept_types = ['application/odf+xml']
76 3 Adrian Georgescu
    accept_wrapped_types = ['*']
77 3 Adrian Georgescu
</pre>
78 1 Adrian Georgescu
79 1 Adrian Georgescu
Once established, the MSRP stream can cary back and forth payloads of the types specified in the stream definition. Is up to the end-points to handle the actual payloads and match various files shared through this mechanism over the same session. The SIP session id can be used to group together various flows within the same stream.
80 7 Adrian Georgescu
81 13 Adrian Georgescu
This mechanism will require similar changes in other clients that wish to implement this feature, it is more complex but have the advantage that it can be negotiated by the use of a SIP Invite where the remote party can accept or reject the session request.
82 1 Adrian Georgescu
83 6 Adrian Georgescu
h3. Presence
84 1 Adrian Georgescu
85 13 Adrian Georgescu
Optionally, SIP end-points supporting this feature can advertise this capability by publishing it using the SIP SIMPLE Presence payload. For this, the end-point capabilities must be extended to support odf as a different media type.
86 1 Adrian Georgescu
87 1 Adrian Georgescu
<pre>
88 4 Adrian Georgescu
sipsimple/payloads/caps.py
89 1 Adrian Georgescu
</pre>
90 6 Adrian Georgescu
91 20 Adrian Georgescu
92 1 Adrian Georgescu
h2. GUI changes
93 1 Adrian Georgescu
94 1 Adrian Georgescu
The GUI must handle sessions for incoming and outgoing media stream defined above by creating its own controller that it is invoked either when negotiating the session, when a proper payload arrives over the chat channel or when user clicks in the GUI to start editing.
95 1 Adrian Georgescu
96 21 Adrian Georgescu
As the code is written and maintained by a third-party, the best approach is to have a separate window. Reusing Blink chat main window for ODF may conflict with future changes made by Blink developers.
97 21 Adrian Georgescu
98 20 Adrian Georgescu
h2. Multi-party editing
99 16 Adrian Georgescu
100 20 Adrian Georgescu
SylkServer is the ideal candidate for mixing media, it has built-in web server and MSRP switch capabilities.