Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
0cb13b88
Commit
0cb13b88
authored
Jul 11, 2017
by
Sylvain Berfini
🎩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let python wrapper wrap PayloadType automatically + added sample python file from wiki
parent
9d15a757
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
18 deletions
+72
-18
tools/linphone-sample.py
tools/linphone-sample.py
+71
-0
tools/python/apixml2python/linphone.py
tools/python/apixml2python/linphone.py
+1
-1
tools/python/apixml2python/linphone_module.mustache
tools/python/apixml2python/linphone_module.mustache
+0
-17
No files found.
tools/linphone-sample.py
0 → 100644
View file @
0cb13b88
#!/usr/bin/env python
import
logging
import
signal
import
time
import
linphone
class
SecurityCamera
:
def
__init__
(
self
,
username
=
''
,
password
=
''
,
whitelist
=
[],
camera
=
''
,
snd_capture
=
''
,
snd_playback
=
''
):
self
.
quit
=
False
self
.
whitelist
=
whitelist
callbacks
=
linphone
.
Factory
.
get
().
create_core_cbs
()
callbacks
.
call_state_changed
=
self
.
call_state_changed
# Configure the linphone core
logging
.
basicConfig
(
level
=
logging
.
INFO
)
signal
.
signal
(
signal
.
SIGINT
,
self
.
signal_handler
)
linphone
.
set_log_handler
(
self
.
log_handler
)
self
.
core
=
linphone
.
Factory
.
get
().
create_core
(
callbacks
,
None
,
None
)
self
.
core
.
max_calls
=
1
self
.
core
.
echo_cancellation_enabled
=
False
self
.
core
.
video_capture_enabled
=
True
self
.
core
.
video_display_enabled
=
False
self
.
core
.
nat_policy
.
stun_server
=
'stun.linphone.org'
self
.
core
.
nat_policy
.
ice_enabled
=
True
if
len
(
camera
):
self
.
core
.
video_device
=
camera
if
len
(
snd_capture
):
self
.
core
.
capture_device
=
snd_capture
if
len
(
snd_playback
):
self
.
core
.
playback_device
=
snd_playback
self
.
configure_sip_account
(
username
,
password
)
def
signal_handler
(
self
,
signal
,
frame
):
self
.
core
.
terminate_all_calls
()
self
.
quit
=
True
def
log_handler
(
self
,
level
,
msg
):
method
=
getattr
(
logging
,
level
)
method
(
msg
)
def
call_state_changed
(
self
,
core
,
call
,
state
,
message
):
if
state
==
linphone
.
CallState
.
IncomingReceived
:
if
call
.
remote_address
.
as_string_uri_only
()
in
self
.
whitelist
:
params
=
core
.
create_call_params
(
call
)
core
.
accept_call_with_params
(
call
,
params
)
else
:
core
.
decline_call
(
call
,
linphone
.
Reason
.
Declined
)
chat_room
=
core
.
get_chat_room_from_uri
(
self
.
whitelist
[
0
])
msg
=
chat_room
.
create_message
(
call
.
remote_address_as_string
+
' tried to call'
)
chat_room
.
send_chat_message
(
msg
)
def
configure_sip_account
(
self
,
username
,
password
):
# Configure the SIP account
proxy_cfg
=
self
.
core
.
create_proxy_config
()
proxy_cfg
.
identity_address
=
self
.
core
.
create_address
(
'sip:{username}@sip.linphone.org'
.
format
(
username
=
username
))
proxy_cfg
.
server_addr
=
'sip:sip.linphone.org;transport=tls'
proxy_cfg
.
register_enabled
=
True
self
.
core
.
add_proxy_config
(
proxy_cfg
)
auth_info
=
self
.
core
.
create_auth_info
(
username
,
None
,
password
,
None
,
None
,
'sip.linphone.org'
)
self
.
core
.
add_auth_info
(
auth_info
)
def
run
(
self
):
while
not
self
.
quit
:
self
.
core
.
iterate
()
time
.
sleep
(
0.03
)
if
__name__
==
"__main__"
:
cam
=
SecurityCamera
(
username
=
'raspberry'
,
password
=
'pi'
,
whitelist
=
[
'sip:trusteduser@sip.linphone.org'
],
camera
=
'V4L2: /dev/video0'
,
snd_capture
=
'ALSA: USB Device 0x46d:0x825'
)
cam
.
run
()
tools/python/apixml2python/linphone.py
View file @
0cb13b88
...
...
@@ -1042,7 +1042,7 @@ class EventCallbackMethodDefinition(MethodDefinition):
class
LinphoneModule
(
object
):
def
__init__
(
self
,
tree
,
blacklisted_classes
,
blacklisted_events
,
blacklisted_functions
,
hand_written_codes
):
self
.
known_types
=
[
'char'
,
'int'
,
'int8_t'
,
'int16_t'
,
'int32_t'
,
'int64_t'
,
'uint8_t'
,
'uint16_t'
,
'uint32_t'
,
'uint64_t'
,
'bool_t'
,
'float'
,
'double'
,
'size_t'
,
'time_t'
,
'MSList'
,
'bctbx_list_t'
,
'MSVideoSize'
,
'LCSipTransports'
,
'PayloadType'
,
'LinphoneStatus'
]
self
.
known_types
=
[
'char'
,
'int'
,
'int8_t'
,
'int16_t'
,
'int32_t'
,
'int64_t'
,
'uint8_t'
,
'uint16_t'
,
'uint32_t'
,
'uint64_t'
,
'bool_t'
,
'float'
,
'double'
,
'size_t'
,
'time_t'
,
'MSList'
,
'bctbx_list_t'
,
'MSVideoSize'
,
'LCSipTransports'
,
'LinphoneStatus'
]
self
.
internal_instance_method_names
=
[
'destroy'
,
'ref'
,
'unref'
]
self
.
internal_property_names
=
[
'user_data'
]
self
.
bctbxlist_types
=
set
([])
...
...
tools/python/apixml2python/linphone_module.mustache
View file @
0cb13b88
...
...
@@ -332,7 +332,6 @@ static PyMethodDef pylinphone_{{enum_name}}_ModuleMethods[] = {
static PyObject * pylinphone_moduleinit(void) {
PyObject *m;
PyObject *menum_PayloadType;
PyDateTime_IMPORT;
PyEval_InitThreads();
...
...
@@ -366,22 +365,6 @@ static PyObject * pylinphone_moduleinit(void) {
}
{{/
enums
}}
MOD_DEF
(
menum_PayloadType
,
"
PayloadTypeType
",
pylinphone_PayloadTypeType_ModuleMethods
,
"
Type
of
:py:class:
`
linphone.PayloadType
`.\
n
\
n..
csv-table::
\
n
:delim:
|\
n
:header:
Value
,
Description
\
n
\
n
AudioContinuous
|\
n
AudioPacketized
|\
n
Video
|\
n
Text
|\
n
Other
|\
n
");
if
(menum_PayloadType =
=
NULL
)
return
NULL
;
Py_INCREF
(
menum_PayloadType
);
if
(
PyModule_AddObject
(
m
,
"
PayloadTypeType
",
menum_PayloadType
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
AudioContinuous
",
PAYLOAD_AUDIO_CONTINUOUS
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
AudioPacketized
",
PAYLOAD_AUDIO_PACKETIZED
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
Video
",
PAYLOAD_VIDEO
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
Text
",
PAYLOAD_TEXT
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
Other
",
PAYLOAD_OTHER
)
<
0)
return
NULL
;
//
TODO:
To
remove.
Deprecated
enum
values.
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
PAYLOAD_AUDIO_CONTINUOUS
",
PAYLOAD_AUDIO_CONTINUOUS
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
PAYLOAD_AUDIO_PACKETIZED
",
PAYLOAD_AUDIO_PACKETIZED
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
PAYLOAD_VIDEO
",
PAYLOAD_VIDEO
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
PAYLOAD_TEXT
",
PAYLOAD_TEXT
)
<
0)
return
NULL
;
if
(
PyModule_AddIntConstant
(
menum_PayloadType
,
"
PAYLOAD_OTHER
",
PAYLOAD_OTHER
)
<
0)
return
NULL
;
{{#
classes
}}
Py_INCREF
(&
pylinphone_
{{
class_name
}}
Type
);
PyModule_AddObject
(
m
,
"
{{
class_name
}}
",
(
PyObject
*
)&
pylinphone_
{{
class_name
}}
Type
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment