Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jannik Hellenkamp
website
Commits
91ed667b
Commit
91ed667b
authored
Jan 04, 2018
by
Julian Rother
Browse files
Extended legacy livestream api to support job-based encoding
parent
6b930170
Changes
2
Hide whitespace changes
Inline
Side-by-side
db_schema.sql
View file @
91ed667b
...
...
@@ -176,7 +176,8 @@ CREATE TABLE IF NOT EXISTS `streams` (
`visible`
INTEGER
NOT
NULL
,
`lecture_id`
INTEGER
NOT
NULL
,
`description`
text
NOT
NULL
,
`poster`
text
NOT
NULL
`poster`
text
NOT
NULL
,
`job_id`
INTEGER
);
CREATE
TABLE
IF
NOT
EXISTS
`stream_stats`
(
`id`
INTEGER
NOT
NULL
PRIMARY
KEY
AUTOINCREMENT
,
...
...
livestreams.py
View file @
91ed667b
...
...
@@ -7,7 +7,8 @@ def livestream_thumbnail():
schedule_job
(
'thumbnail'
,
{
'lectureid'
:
str
(
v
[
'lecture_id'
]),
'path'
:
v
[
'path'
]})
@
app
.
route
(
'/internal/streaming/legacy_auth'
,
methods
=
[
'GET'
,
'POST'
])
def
streamauth
():
@
app
.
route
(
'/internal/streaming/legacy_auth/<server>'
,
methods
=
[
'GET'
,
'POST'
])
def
streamauth
(
server
=
None
):
internal
=
False
for
net
in
config
.
get
(
'FSMPI_IP_RANGES'
,
[]):
if
ip_address
(
request
.
headers
[
'X-Real-IP'
])
in
ip_network
(
net
):
...
...
@@ -33,10 +34,25 @@ def streamauth():
modify
(
"INSERT INTO streams (handle, active, visible, lecture_id, description, poster) VALUES (?, 0, 1, -1, "", "")"
,
request
.
values
[
'name'
])
except
:
pass
modify
(
"UPDATE streams SET active = 1, lecture_id = ? WHERE handle = ?"
,
match
[
'id'
],
request
.
values
[
'name'
])
if
server
:
data
=
{
'src'
:
'rtmp://%s/live/%s'
%
(
server
,
request
.
values
[
'name'
]),
'destbase'
:
'rtmp://%s/hls/%s'
%
(
server
,
request
.
values
[
'name'
])}
job_id
=
schedule_job
(
'simple_live_transcode'
,
data
,
priority
=
10
)
modify
(
"UPDATE streams SET active = 1, lecture_id = ?, job_id = ? WHERE handle = ?"
,
match
[
'id'
],
job_id
,
request
.
values
[
'name'
])
else
:
modify
(
"UPDATE streams SET active = 1, lecture_id = ? WHERE handle = ?"
,
match
[
'id'
],
request
.
values
[
'name'
])
elif
request
.
values
[
'call'
]
==
'publish_done'
:
job_id
=
query
(
'SELECT job_id FROM streams WHERE handle = ?'
,
request
.
values
[
'name'
])[
0
][
'job_id'
]
modify
(
"UPDATE streams SET active = 0 WHERE handle = ?"
,
request
.
values
[
'name'
])
if
job_id
:
cancel_job
(
job_id
)
else
:
return
'Bad request'
,
400
return
'OK'
,
200
@
job_handler
(
'simple_live_transcode'
,
state
=
'failed'
)
def
restart_failed_live_transcode
(
id
,
type
,
data
,
state
,
status
):
restart_job
(
id
)
Write
Preview
Supports
Markdown
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