generate stream key
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-12-05 11:45:42 +01:00
parent 2c89f3d0c3
commit 5e541640c1
2 changed files with 11 additions and 5 deletions

View File

@ -52,6 +52,7 @@ class StreamResource(db.Model):
parent_id = db.Column(UUID(as_uuid=True), db.ForeignKey('stream_resource.id'), nullable=True) parent_id = db.Column(UUID(as_uuid=True), db.ForeignKey('stream_resource.id'), nullable=True)
children = db.relationship('StreamResource', lazy=False) children = db.relationship('StreamResource', lazy=False)
owner_id = db.Column(db.Integer, db.ForeignKey('videon_user.id'), nullable=False) owner_id = db.Column(db.Integer, db.ForeignKey('videon_user.id'), nullable=False)
stream_key = db.Column(UUID(as_uuid=True), unique=True, nullable=False)
owner = db.relationship('VideonUser', backref=backref("stream_resource", cascade="all, delete"), lazy=False) owner = db.relationship('VideonUser', backref=backref("stream_resource", cascade="all, delete"), lazy=False)
x = db.Column(db.Integer, nullable=False) x = db.Column(db.Integer, nullable=False)
y = db.Column(db.Integer, nullable=False) y = db.Column(db.Integer, nullable=False)

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from uuid import UUID from uuid import UUID,uuid4
import datetime import datetime
from flask_jwt_extended import create_access_token, jwt_required, get_jwt_identity from flask_jwt_extended import create_access_token, jwt_required, get_jwt_identity
@ -176,12 +176,14 @@ class CreateIngestResource(Resource):
abort(417, INVALID_JSON_SCHEMA_MSG) abort(417, INVALID_JSON_SCHEMA_MSG)
ingest = StreamResource(resource_type=StreamResourceTypeEnum['INGEST'], ingest = StreamResource(resource_type=StreamResourceTypeEnum['INGEST'],
url="rtmp://zelenka.tormakristof.eu:6969/origin/asdasd", x=ingestobj['x'],y=ingestobj['y']) url="rtmp://zelenka.tormakristof.eu:6969/origin/asdasd", x=ingestobj['x'],
y=ingestobj['y'])
# username = get_jwt_identity() # username = get_jwt_identity()
username = "jozska" username = "jozska"
user = VideonUser.query.filter_by(name=username).first_or_404() user = VideonUser.query.filter_by(name=username).first_or_404()
ingest.owner_id = user.id ingest.owner_id = user.id
ingest.stream_key = str(uuid4())
try: try:
db.session.add(ingest) db.session.add(ingest)
except Exception as e: except Exception as e:
@ -220,12 +222,14 @@ class CreateRestreamResource(Resource):
abort(417, INVALID_JSON_SCHEMA_MSG) abort(417, INVALID_JSON_SCHEMA_MSG)
restream = StreamResource(resource_type=StreamResourceTypeEnum['RESTREAM'], restream = StreamResource(resource_type=StreamResourceTypeEnum['RESTREAM'],
url="rtmp://zelenka.tormakristof.eu:6969/origin/asdasd",x=restreamobj['x'],y=restreamobj['y']) url="rtmp://zelenka.tormakristof.eu:6969/origin/asdasd", x=restreamobj['x'],
y=restreamobj['y'])
# username = get_jwt_identity() # username = get_jwt_identity()
username = "jozska" username = "jozska"
user = VideonUser.query.filter_by(name=username).first_or_404() user = VideonUser.query.filter_by(name=username).first_or_404()
restream.owner_id = user.id restream.owner_id = user.id
restream.stream_key = str(uuid4())
if 'inputNeighbour' in restreamobj: if 'inputNeighbour' in restreamobj:
restream.parent_id = restreamobj['inputNeighbour'] restream.parent_id = restreamobj['inputNeighbour']
try: try:
@ -263,13 +267,14 @@ class CreateEncodeResource(Resource):
abort(417, INVALID_JSON_SCHEMA_MSG) abort(417, INVALID_JSON_SCHEMA_MSG)
encoder = StreamResource(resource_type=StreamResourceTypeEnum['ENCODE'], encoder = StreamResource(resource_type=StreamResourceTypeEnum['ENCODE'],
url="rtmp://zelenka.tormakristof.eu:6969/origin/asdasd",x=encoderobj['x'],y=encoderobj['y']) url="rtmp://zelenka.tormakristof.eu:6969/origin/asdasd", x=encoderobj['x'],
y=encoderobj['y'])
# username = get_jwt_identity() # username = get_jwt_identity()
username = "jozska" username = "jozska"
user = VideonUser.query.filter_by(name=username).first_or_404() user = VideonUser.query.filter_by(name=username).first_or_404()
encoder.owner_id = user.id encoder.owner_id = user.id
encoder.stream_key = str(uuid4())
if 'inputNeighbour' in encoderobj: if 'inputNeighbour' in encoderobj:
encoder.parent_id = encoderobj['inputNeighbour'] encoder.parent_id = encoderobj['inputNeighbour']