I try to hand write a RTMP publish / play client. The streaming server I used now is nginx with rtmp module.
My code follows the RTMP client's workflow, that something like Handshake -> Connect -> CreateStream -> Publish or Play.
It can work well when dealing simple RTMP url such as rtmp://127.0.0.1:1935/mylv/afv
But when verifying is needed, RTMP url will be rtmp://127.0.0.1:1935/mylv/afv?username=abc&password=123
rtmp {
server {
listen 1935;
chunk_size 4000;
application mylv {
live on;
hls on;
hls_path /mnt/datadisk0/uploadfile/live;
allow play all;
on_publish http://127.0.0.1:10078/user/auth;
}
}
}
/// auth.py
from flask import Flask, request, Response
app = Flask(__name__)
@app.route('/user/auth',methods=['POST'])
def auth():
user = request.form['username']
password = request.form['password']
print(user,'\t',password)
auth_user ='abc'
auth_passWord ='123'
if auth_user == user and auth_passWord == password:
return Response(response='success', status=200)
else:
return Response(status=500)
#Flask.abort(404)
return password
if __name__ == '__main__':
app.run(host='0.0.0.0', port=10078, debug=True)
How I should do to send the query part username=abc&password=123 to server?