Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
Suppose you are building a streaming service on top of AMS and you are charging your users based on their subscription plan.
Basic plan allows max 30 fps, max 1500 kbps bitrate and 1280x720 resolution publish
Premium plan allows max 60 fps, max 2500 kbps bitrate and 1920x1080 resolution publish
etc
AMS should allow restricting fps, bitrate, width height for all publish types through broadcast object fields.
Solution:
Add 4 new fields to broadcast object:
maxFps
maxBitrate
maxWidth
maxHeight
If user tries to publish a stream which does not comply with those values, reject the stream or cut connection after few seconds(detection might take a while for some protocols...)
Additional context and solution ideas
There was a similar feature implemented previously for RTMP but i believe after that implementation the way of RTMP ingest changed which made this feature broken and only resolution restriction is working at the moment.
Personaly i did some trials for RTSP and RTMP for maxFps and resolution.
For RTSP fps its relatively easy to implement. It can be done in prepareFromInputFormatContext method. This method already provides width and height of the stream.
Add following lines for FPS:
For RTMP its a little bit more complex and we need few seconds of streaming time to calculate FPS. Go to writeStreamPacketmethod of MuxAdaptor and add below lines:
width and height already set inside getVideoCodecParameters and current resolution restriction implementation works fine for rtmp.
Suppose you are building a streaming service on top of AMS and you are charging your users based on their subscription plan. Basic plan allows max 30 fps, max 1500 kbps bitrate and 1280x720 resolution publish Premium plan allows max 60 fps, max 2500 kbps bitrate and 1920x1080 resolution publish etc
AMS should allow restricting fps, bitrate, width height for all publish types through broadcast object fields.
Solution: Add 4 new fields to broadcast object: maxFps maxBitrate maxWidth maxHeight
If user tries to publish a stream which does not comply with those values, reject the stream or cut connection after few seconds(detection might take a while for some protocols...)
Additional context and solution ideas There was a similar feature implemented previously for RTMP but i believe after that implementation the way of RTMP ingest changed which made this feature broken and only resolution restriction is working at the moment. Personaly i did some trials for RTSP and RTMP for maxFps and resolution. For RTSP fps its relatively easy to implement. It can be done in
prepareFromInputFormatContext
method. This method already provides width and height of the stream. Add following lines for FPS:For RTMP its a little bit more complex and we need few seconds of streaming time to calculate FPS. Go to
writeStreamPacket
method of MuxAdaptor and add below lines:width and height already set inside
getVideoCodecParameters
and current resolution restriction implementation works fine for rtmp.