Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTMP publish reject stream #149

Open
kbats183 opened this issue Aug 30, 2024 · 1 comment
Open

RTMP publish reject stream #149

kbats183 opened this issue Aug 30, 2024 · 1 comment

Comments

@kbats183
Copy link

Hello.

I am working on rtmp restreamer. Some rtmp servers can reject connection if user sends incorrect stream key. In this case, OBS shows a message like this
image

I took code from example and their method OnPublish returns only rtmp.NETSTREAM_PUBLISH_START.

How can I reject connection with incorrect stream name here?

Thank you for your answer!

@yapingcat
Copy link
Owner

please refer to this code

sess.handle.OnPublish(func(app, streamName string) rtmp.StatusCode {
		if streamName == "stream_reject" {
			return rtmp.NETCONNECT_CONNECT_REJECTED
		}
		return rtmp.NETSTREAM_PUBLISH_START
	})
sess.handle.OnStateChange(func(newState rtmp.RtmpState) {
		if newState == rtmp.STATE_RTMP_PLAY_START {

		} else if newState == rtmp.STATE_RTMP_PUBLISH_START {
			
		} else if newState == rtmp.STATE_RTMP_PUBLISH_FAILED {
			fmt.Println("publish failed")
			sess.stop()
		}
	})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants