start fixing Jingle Audio / Video

This commit is contained in:
Yann Leboulanger 2015-08-21 22:04:55 +02:00
parent 003ebf0b9d
commit 0735ec2214
3 changed files with 44 additions and 12 deletions

View File

@ -29,6 +29,7 @@
import os
import time
from gi.repository import GdkX11
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
@ -2147,16 +2148,18 @@ class ChatControl(ChatControlBase):
fixed = self.xml.get_object('outgoing_fixed')
fixed.set_no_show_all(False)
video_hbox.show_all()
out_da = self.xml.get_object('outgoing_drawingarea')
out_da.realize()
if os.name == 'nt':
out_xid = self.xml.get_object(
'outgoing_drawingarea').get_window().handle
out_xid = out_da.get_window().handle
else:
out_xid = self.xml.get_object(
'outgoing_drawingarea').get_window().xid
out_xid = out_da.get_window().get_xid()
else:
out_xid = None
video_hbox.show_all()
in_xid = self.xml.get_object('incoming_drawingarea').get_window().xid
in_da = self.xml.get_object('incoming_drawingarea')
in_da.realize()
in_xid = in_da.get_window().get_xid()
sid = gajim.connections[self.account].start_video(
self.contact.get_full_jid(), in_xid, out_xid)
else:

View File

@ -301,7 +301,7 @@ class Config:
'show_self_contact': [opt_str, 'when_other_resource', _('When is self contact row displayed. Can be "always", "when_other_resource" or "never"'), True],
'audio_input_device': [opt_str, 'autoaudiosrc ! volume name=gajim_vol'],
'audio_output_device': [opt_str, 'autoaudiosink'],
'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'],
'video_input_device': [opt_str, 'autovideosrc ! videoscale ! videoconvert'],
'video_output_device': [opt_str, 'autovideosink'],
'video_framerate': [opt_str, '', _('Optionally fix jingle output video framerate. Example: 10/1 or 25/2')],
'video_size': [opt_str, '', _('Optionally resize jingle output video. Example: 320x240')],

View File

@ -197,8 +197,7 @@ class JingleRTPContent(JingleContent):
if self.is_ready():
self.session.on_session_state_changed(self)
elif name == 'farstream-new-local-candidate':
candidate = message.get_structure().get_value('candidate').copy(
)
candidate = self.p2pstream.parse_new_local_candidate(message)[1]
self.transport.candidates.append(candidate)
if self.sent:
# FIXME: Is this case even possible?
@ -374,8 +373,11 @@ class JingleAudio(JingleRTPContent):
class JingleVideo(JingleRTPContent):
def __init__(self, session, transport=None):
def __init__(self, session, transport=None, in_xid=0, out_xid=0):
JingleRTPContent.__init__(self, session, 'video', transport)
self.in_xid = in_xid
self.out_xid = out_xid
self.out_xid_set = False
self.setup_stream()
def setup_stream(self):
@ -383,6 +385,8 @@ class JingleVideo(JingleRTPContent):
# sometimes, one window won't show up,
# sometimes it'll freeze...
JingleRTPContent.setup_stream(self, self._on_src_pad_added)
bus = self.pipeline.get_bus()
bus.connect('sync-message::element', self._on_sync_message)
# the local parts
if gajim.config.get('video_framerate'):
@ -398,17 +402,26 @@ class JingleVideo(JingleRTPContent):
video_size = 'video/x-raw,width=%s,height=%s ! ' % (w, h)
else:
video_size = ''
if gajim.config.get('video_see_self'):
tee = '! tee name=t ! queue ! videoscale ! ' + \
'video/x-raw,width=160,height=120 ! videoconvert ! ' + \
'%s t. ! queue ' % gajim.config.get(
'video_output_device')
else:
tee = ''
self.src_bin = self.make_bin_from_config('video_input_device',
'%%s ! %svideoscale ! %svideoconvert' % (framerate, video_size),
_("video input"))
'%%s %s! %svideoscale ! %svideoconvert' % (tee, framerate,
video_size), _("video input"))
#caps = gst.element_factory_make('capsfilter')
#caps.set_property('caps', gst.caps_from_string('video/x-raw-yuv, width=320, height=240'))
self.pipeline.add(self.src_bin)#, caps)
self.pipeline.set_state(Gst.State.PLAYING)
#src_bin.link(caps)
self.sink = self.make_bin_from_config('video_output_device',
'videoscale ! videoconvert ! %s force-aspect-ratio=True',
'videoscale ! videoconvert ! %s',
_("video output"))
self.pipeline.add(self.sink)
@ -418,11 +431,27 @@ class JingleVideo(JingleRTPContent):
# The following is needed for farstream to process ICE requests:
self.pipeline.set_state(Gst.State.PLAYING)
def _on_sync_message(self, bus, message):
if message.structure is None:
return False
if message.structure.get_name() == 'prepare-xwindow-id':
message.src.set_property('force-aspect-ratio', True)
imagesink = message.src
if gajim.config.get('video_see_self') and not self.out_xid_set:
imagesink.set_xwindow_id(self.out_xid)
self.out_xid_set = True
else:
imagesink.set_xwindow_id(self.in_xid)
def get_fallback_src(self):
# TODO: Use avatar?
pipeline = 'videotestsrc is-live=true ! video/x-raw,framerate=10/1 ! videoconvert'
return Gst.parse_bin_from_description(pipeline, True)
def destroy(self):
JingleRTPContent.destroy(self)
self.pipeline.get_bus().disconnect_by_func(self._on_sync_message)
def get_content(desc):
if desc['media'] == 'audio':
return JingleAudio