~ubuntu-branches/ubuntu/precise/emesene/precise

« back to all changes in this revision

Viewing changes to emesene/e3/papylib/papyon/papyon/media/conference.py

  • Committer: Package Import Robot
  • Author(s): Jason Conti
  • Date: 2012-03-19 07:57:13 UTC
  • Revision ID: package-import@ubuntu.com-20120319075713-gimddquevsku39jp
Tags: 2.12.1+dfsg-1ubuntu2
* debian/control:
  - Change python-farsight to python-farstream depend.
* debian/patches/port_to_farstream.patch:
  - Rename farsight to farstream (LP: #956422)
* debian/patches/02_fix_common_errback.patch:
  - Cherry pick 3b289b25a77c6531a7de7863f049bc30ca7d4c78 from upstream
  git to fix incorrect number of arguments causing an exception.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import pygst
25
25
pygst.require('0.10')
26
26
 
27
 
import farsight
 
27
import farstream
28
28
import gobject
29
29
import gst
30
30
import logging
34
34
 
35
35
codecs_definitions = {
36
36
    "audio" : [
37
 
        (114, "x-msrta", farsight.MEDIA_TYPE_AUDIO, 16000),
38
 
        (111, "SIREN", farsight.MEDIA_TYPE_AUDIO, 16000),
39
 
        (112, "G7221", farsight.MEDIA_TYPE_AUDIO, 16000),
40
 
        (115, "x-msrta", farsight.MEDIA_TYPE_AUDIO, 8000),
41
 
        (116, "SIREN", farsight.MEDIA_TYPE_AUDIO, 8000),
42
 
        (4, "G723", farsight.MEDIA_TYPE_AUDIO, 8000),
43
 
        (8, "PCMA", farsight.MEDIA_TYPE_AUDIO, 8000),
44
 
        (0, "PCMU", farsight.MEDIA_TYPE_AUDIO, 8000),
45
 
        (97, "RED", farsight.MEDIA_TYPE_AUDIO, 8000),
46
 
        (101, "telephone-event", farsight.MEDIA_TYPE_AUDIO, 8000)
 
37
        (114, "x-msrta", farstream.MEDIA_TYPE_AUDIO, 16000),
 
38
        (111, "SIREN", farstream.MEDIA_TYPE_AUDIO, 16000),
 
39
        (112, "G7221", farstream.MEDIA_TYPE_AUDIO, 16000),
 
40
        (115, "x-msrta", farstream.MEDIA_TYPE_AUDIO, 8000),
 
41
        (116, "SIREN", farstream.MEDIA_TYPE_AUDIO, 8000),
 
42
        (4, "G723", farstream.MEDIA_TYPE_AUDIO, 8000),
 
43
        (8, "PCMA", farstream.MEDIA_TYPE_AUDIO, 8000),
 
44
        (0, "PCMU", farstream.MEDIA_TYPE_AUDIO, 8000),
 
45
        (97, "RED", farstream.MEDIA_TYPE_AUDIO, 8000),
 
46
        (101, "telephone-event", farstream.MEDIA_TYPE_AUDIO, 8000)
47
47
    ],
48
48
    "video" : [
49
 
        (121, "x-rtvc1", farsight.MEDIA_TYPE_VIDEO, 90000),
50
 
        (34, "H263", farsight.MEDIA_TYPE_VIDEO, 90000)
 
49
        (121, "x-rtvc1", farstream.MEDIA_TYPE_VIDEO, 90000),
 
50
        (34, "H263", farstream.MEDIA_TYPE_VIDEO, 90000)
51
51
    ]
52
52
}
53
53
 
54
54
types = {
55
55
    0 : None,
56
 
    farsight.CANDIDATE_TYPE_HOST  : "host",
57
 
    farsight.CANDIDATE_TYPE_SRFLX : "srflx",
58
 
    farsight.CANDIDATE_TYPE_PRFLX : "prflx",
59
 
    farsight.CANDIDATE_TYPE_RELAY : "relay"
 
56
    farstream.CANDIDATE_TYPE_HOST  : "host",
 
57
    farstream.CANDIDATE_TYPE_SRFLX : "srflx",
 
58
    farstream.CANDIDATE_TYPE_PRFLX : "prflx",
 
59
    farstream.CANDIDATE_TYPE_RELAY : "relay"
60
60
}
61
61
 
62
62
protos = {
63
 
    farsight.NETWORK_PROTOCOL_TCP : "TCP",
64
 
    farsight.NETWORK_PROTOCOL_UDP : "UDP"
 
63
    farstream.NETWORK_PROTOCOL_TCP : "TCP",
 
64
    farstream.NETWORK_PROTOCOL_UDP : "UDP"
65
65
}
66
66
 
67
67
media_names = {
68
 
    farsight.MEDIA_TYPE_AUDIO : "audio",
69
 
    farsight.MEDIA_TYPE_VIDEO : "video"
 
68
    farstream.MEDIA_TYPE_AUDIO : "audio",
 
69
    farstream.MEDIA_TYPE_VIDEO : "video"
70
70
}
71
71
 
72
72
media_types = {
73
 
    "audio" : farsight.MEDIA_TYPE_AUDIO,
74
 
    "video" : farsight.MEDIA_TYPE_VIDEO
 
73
    "audio" : farstream.MEDIA_TYPE_AUDIO,
 
74
    "video" : farstream.MEDIA_TYPE_VIDEO
75
75
}
76
76
 
77
77
 
125
125
        ret = gst.BUS_PASS
126
126
        if msg.type == gst.MESSAGE_ELEMENT:
127
127
            s = msg.structure
128
 
            if s.has_name("farsight-error"):
 
128
            if s.has_name("farstream-error"):
129
129
                logger.error("Farsight error : %s" % s['error-msg'])
130
 
            if s.has_name("farsight-codecs-changed"):
 
130
            if s.has_name("farstream-codecs-changed"):
131
131
                logger.debug("Farsight codecs changed")
132
132
                ret = gst.BUS_DROP
133
133
                ready = s["session"].get_property("codecs-ready")
136
136
                    name = media_names[s["session"].get_property("media-type")]
137
137
                    stream = self._session.get_stream(name)
138
138
                    stream.set_local_codecs(convert_fs_codecs(codecs))
139
 
            if s.has_name("farsight-new-local-candidate"):
 
139
            if s.has_name("farstream-new-local-candidate"):
140
140
                logger.debug("New local candidate")
141
141
                ret = gst.BUS_DROP
142
142
                name = media_names[s["stream"].get_property("session").get_property("media-type")]
143
143
                candidate = convert_fs_candidate(s["candidate"])
144
144
                stream = self._session.get_stream(name)
145
145
                stream.new_local_candidate(candidate)
146
 
            if s.has_name("farsight-local-candidates-prepared"):
 
146
            if s.has_name("farstream-local-candidates-prepared"):
147
147
                logger.debug("Local candidates are prepared")
148
148
                ret = gst.BUS_DROP
149
149
                type = s["stream"].get_property("session").get_property("media-type")
150
150
                name = media_names[type]
151
151
                stream = self._session.get_stream(name)
152
152
                stream.local_candidates_prepared()
153
 
            if s.has_name("farsight-new-active-candidate-pair"):
 
153
            if s.has_name("farstream-new-active-candidate-pair"):
154
154
                logger.debug("New active candidate pair")
155
155
                ret = gst.BUS_DROP
156
156
                type = s["stream"].get_property("session").get_property("media-type")
223
223
# Farsight utility functions
224
224
 
225
225
def create_notifier(pipeline, filename):
226
 
    notifier = farsight.ElementAddedNotifier()
 
226
    notifier = farstream.ElementAddedNotifier()
227
227
    notifier.add(pipeline)
228
228
    notifier.set_properties_from_file(filename)
229
229
    return notifier
246
246
def convert_media_candidates(candidates):
247
247
    fscandidates = []
248
248
    for candidate in candidates:
249
 
        proto = farsight.NETWORK_PROTOCOL_TCP
 
249
        proto = farstream.NETWORK_PROTOCOL_TCP
250
250
        if candidate.transport == "UDP":
251
 
            proto = farsight.NETWORK_PROTOCOL_UDP
 
251
            proto = farstream.NETWORK_PROTOCOL_UDP
252
252
        type = 0
253
253
        for k,v in types.iteritems():
254
254
            if v == candidate.type:
255
255
                type = k
256
 
        fscandidate = farsight.Candidate()
 
256
        fscandidate = farstream.Candidate()
257
257
        fscandidate.foundation = candidate.foundation
258
258
        fscandidate.ip = candidate.ip
259
259
        fscandidate.port = candidate.port
269
269
def build_codecs(type):
270
270
    codecs = []
271
271
    for args in codecs_definitions[type]:
272
 
        codec = farsight.Codec(*args)
 
272
        codec = farstream.Codec(*args)
273
273
        codecs.append(codec)
274
274
    return codecs
275
275
 
288
288
    fscodecs = []
289
289
    media_type = media_types[name]
290
290
    for codec in codecs:
291
 
        fscodec = farsight.Codec(
 
291
        fscodec = farstream.Codec(
292
292
            codec.payload,
293
293
            codec.encoding,
294
294
            media_type,