Hi, 

> On Fri, 06 Feb 2009 at 16:55:48 +0100, Fabien LOUIS wrote:
> > In the first case, when I give the path of an existing telepathy
> > channel, which contains one stream gived by RequestStreams, the
function
> > returns me a TfChannel. But when I call "tf_channel_lookup_stream"
on
> > it, with the stream_id, I obtained a NULL value.

Le samedi 07 février 2009 à 17:32 +0100, Simon McVittie a écrit :
> Perhaps a telepathy-farsight developer can advise on this.

Thank you for your answer. 

Actually, regarding telepathy-farsight source code, I partly solved my
problem. In fact, now I create a telepathy channel with CreateChannel
and afterwards a tpfarsight.Channel with the existing telepathy channel
path.

When the channel is ready ("NewChannel" signal), I request a stream on
telepathy channel (same as before) with RequestStreams. According to
what I saw in the source, this should trigger the whole machinery,
linking the farsight channel and the telepathy channel. Then, I call
lookup_stream on tpfarsight channel, with id of the stream created on
the telepathy channel.

Beforehand, I was creating my stream while the channel was not
necessarily ready yet, perhaps it's a reason to my problem. 
This is where I stand now: I still get a NULL value when calling
lookup_stream, but now I have some debug information and errors. It
seems that some operation in gstreamer are now performed, which makes me
hoping I'm getting closer. Here is the info:

There are my traces:
***********************************************************************
[user2] New org.freedesktop.Telepathy.Channel.Type.StreamedMedia channel
(/org/freedesktop/Telepathy/Connection/gabble/jabber/fabienlouis4_40jabber_2efr_2fTelepathy/MediaChannel0)
[user2] tf_channel <tf.Channel object at 0x92f143c (TfChannel at
0x938f460)>
[user2] Get stream 1
[channel_lookup_stream] stream_id 1 et stream vaut (nil)
[user2] tf_stream None
** (test.py:18570): DEBUG: GetSessionHandlers replied: 
** (test.py:18570): DEBUG:   -
session 
/org/freedesktop/Telepathy/Connection/gabble/jabber/fabienlouis4_40jabber_2efr_2fTelepathy/MediaChannel0
** (test.py:18570): DEBUG:     type rtp
** (test.py:18570): DEBUG: adding session
handler 
/org/freedesktop/Telepathy/Connection/gabble/jabber/fabienlouis4_40jabber_2efr_2fTelepathy/MediaChannel0,
 type rtp

(test.py:18570): GStreamer-CRITICAL **: gst_object_ref: assertion
`object != NULL' failed
** (test.py:18570): DEBUG: _tf_session_dispose

** (test.py:18570): WARNING **: failed to create session: Invalid
session type
***********************************************************************

Apparently the problem occurs when creating the session.

In order to help other people, I attach my test program that reproduces
the problem.

Any idea is welcomed

Thank you very much, 
Fabien LOUIS
import gobject
import dbus.glib

import tpfarsight
import telepathy
from telepathy.interfaces import (
    CONNECTION,
    CONNECTION_MANAGER,
    CONNECTION_INTERFACE_CAPABILITIES,
    CHANNEL_TYPE_STREAMED_MEDIA,
    CONNECTION_INTERFACE_REQUESTS
)
from telepathy.constants import (
    CONNECTION_STATUS_CONNECTED,
    HANDLE_TYPE_CONTACT,
    MEDIA_STREAM_TYPE_VIDEO
)

##################################################
tf_channel = None
##################################################

def on_status_changed_user1(state, reason):
    print "[user1] New status: %s" % (state)
    
    if state == CONNECTION_STATUS_CONNECTED:
        print "[user1] Connected"
        gobject.timeout_add(2000, enable_capabilities, conn1)
        
def on_status_changed_user2(state, reason):
    print "[user2] New status: %s" % (state)
    
    if state == CONNECTION_STATUS_CONNECTED:
        print "[user2] Connected"
        gobject.timeout_add(2000, enable_capabilities, conn2)
        gobject.timeout_add(10000, create_channel, conn2)

def enable_capabilities(conn):
    conn[CONNECTION_INTERFACE_CAPABILITIES].AdvertiseCapabilities(
                            [(CHANNEL_TYPE_STREAMED_MEDIA, 15)], [])
    print "Capabilities enabled"

def create_channel(conn):
    # Request contact handle
    contact_handle = conn[CONNECTION].RequestHandles(HANDLE_TYPE_CONTACT,
                                                     ["fabienlo...@jabber.fr"])[0]    
    # Create CHANNEL_TYPE_STREAMED_MEDIA with handle
    channel_infos = conn[CONNECTION_INTERFACE_REQUESTS].CreateChannel({
                    "org.freedesktop.Telepathy.Channel.ChannelType":CHANNEL_TYPE_STREAMED_MEDIA,
                    "org.freedesktop.Telepathy.Channel.TargetHandleType":HANDLE_TYPE_CONTACT,
                    "org.freedesktop.Telepathy.Channel.TargetHandle":contact_handle})
    channel_path = channel_infos[0]
    
    # Create tfChannel with the telepathy channel path
    global tf_channel
    tf_channel = tpfarsight.Channel(connection_busname=conn.service_name,
                                    connection_path=conn.object_path,
                                    channel_path=channel_path)
            
def on_new_channel_user1(object_path, channel_type, handle_type,
                         handle, suppress_handler):
    print "[user1] New %s channel (%s)" % (channel_type, object_path)
    
def on_new_channel_user2(object_path, channel_type, handle_type,
                         handle, suppress_handler):
    print "[user2] New %s channel (%s)" % (channel_type, object_path)
    
    if channel_type == CHANNEL_TYPE_STREAMED_MEDIA:
        # When CHANNEL_TYPE_STREAMED_MEDIA is ready
        # Request contact handle
        contact_handle = conn2[CONNECTION].RequestHandles(HANDLE_TYPE_CONTACT,
                                                         ["fabienlo...@jabber.fr"])[0]
        # Get channel       
        channel = telepathy.client.channel.Channel(conn2.service_name,
                                                   object_path,
                                                   conn2.bus)
        # Request a VIDEO stream 
        streams_infos = channel[CHANNEL_TYPE_STREAMED_MEDIA].RequestStreams(contact_handle, [MEDIA_STREAM_TYPE_VIDEO])
        # Get the stream id 
        stream_id = streams_infos[0][0]
        
        global tf_channel
        print "[user2] tf_channel", tf_channel
        print "[user2] Get stream %s" % stream_id
        
        # Try to get a tfstream with the telepathy stream id
        tf_stream = tf_channel.lookup_stream(stream_id=stream_id)
        # But tf_stream is None
        print "[user2] tf_stream", tf_stream 
    
##################################################

# Get the requested manager
reg = telepathy.client.ManagerRegistry()
reg.LoadManagers()    
manager = reg.GetManager("gabble")

# Request first connection
conn_bus_name1, conn_object_path1 = \
    manager[CONNECTION_MANAGER].RequestConnection("jabber",
                                                  {"account": "fabienlo...@jabber.fr",
                                                   "password": "Viovio"})
conn1 = telepathy.client.Connection(conn_bus_name1, conn_object_path1)

# Request second connection
conn_bus_name2, conn_object_path2 = \
    manager[CONNECTION_MANAGER].RequestConnection("jabber",
                                                  {"account": "fabienlou...@jabber.fr",
                                                   "password": "Viovio"})    
conn2 = telepathy.client.Connection(conn_bus_name2, conn_object_path2)

# Listen signals
conn1[CONNECTION].connect_to_signal("NewChannel", on_new_channel_user1)
conn1[CONNECTION].connect_to_signal("StatusChanged", on_status_changed_user1)
conn2[CONNECTION].connect_to_signal("NewChannel", on_new_channel_user2)
conn2[CONNECTION].connect_to_signal("StatusChanged", on_status_changed_user2)

# Connect
conn1[CONNECTION].Connect()
conn2[CONNECTION].Connect()

# Wait
loop = gobject.MainLoop()
try:
    loop.run()
except KeyboardInterrupt:
    print 'interrupted'
_______________________________________________
telepathy mailing list
telepathy@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/telepathy

Reply via email to