Coder Social home page Coder Social logo

Comments (13)

JulienBreux avatar JulienBreux commented on June 16, 2024 1

Thanks a lot for this awesome complete reply :)

I can help you if you want.

Actually, we use github.com/nareix/joy4 but your code is very clear and tested ;)

from go-rtmp.

ArturFortunato avatar ArturFortunato commented on June 16, 2024 1

Hello!

Are there any updates on this? I also need to access the publishingName on the OnAudio/OnVideo listeners. Can this be done now?

Thank you!

from go-rtmp.

yutopp avatar yutopp commented on June 16, 2024 1

Sorry for the roughness, but I've added a sample that relays RTMP streams by stream name.

https://github.com/yutopp/go-rtmp/tree/master/example/server_relay_demo

It can handle multiple input streams per publishing names. Please comments if I'm missing anything.

Thanks!

from go-rtmp.

ArturFortunato avatar ArturFortunato commented on June 16, 2024 1

Hello!
Thank you so much, that seems to do the trick! I want to output the videos with WebRTC, so I still need to adapt the code and complete some things, but with RTMP it works perfectly!

I will give feedback as soon as I make it work with webRTC!

Again, thank you!

from go-rtmp.

yutopp avatar yutopp commented on June 16, 2024

Hi. Thank you for your comments!

My answers are

  1. Maybe yes. This library has not pubsub layers, thus we need implement these layers or use other middlewares to make media streaming.
    a. In addition, we need media conversion layers to read these streams from HTTP(HLS?) when they are published by RTMP.
  2. Currently it may have no way to do that by lacking of the API. Sorry ... 😭

I have been developing this library by putting emphasis on subscribing from client side and publishing to server side(for internal relay server), thus the way to publish streams to client side may be lacking.

However I can make an example for simple RTMP relay server of 1:N with improving the library in a couple days. I'll do that as soon as possible. Thank you for your patience. 🙏

from go-rtmp.

yutopp avatar yutopp commented on June 16, 2024

I'm sorry for my late. Now I'm busy with working on other tasks, and I don't have much time to do this task. 🙇‍♂️

from go-rtmp.

JulienBreux avatar JulienBreux commented on June 16, 2024

Ok. Thanks. ;)

Good luck 🍀

from go-rtmp.

yutopp avatar yutopp commented on June 16, 2024

Is this code helpful? If this is not what you intended, please let me know 🙏

type Handler struct {
	rtmp.DefaultHandler

	// value holders
	app string
	publishingName string
}

func (h *Handler) OnConnect(timestamp uint32, cmd *rtmpmsg.NetConnectionConnect) error {
	h.app = cmd.Command.App // Save values to each handler instances

	return nil
}

func (h *Handler) OnPublish(timestamp uint32, cmd *rtmpmsg.NetStreamPublish) error {
	log.Printf("App Name: %v", h.app) // Read the 'App' value saved in the handler

	h.publishingName = cmd.PublishingName // Same

	return nil
}

func (h *Handler) OnAudio(timestamp uint32, payload io.Reader) error {
	log.Printf("App Name: %v", h.publishingName) // Read the 'PublishingName' value saved in the handler
}

Thank you.

from go-rtmp.

ArturFortunato avatar ArturFortunato commented on June 16, 2024

Hello!

This will only allow for 1 publishingName, right? I need to have multiple inputs and to write audio/video only for peers watching the video publishingName

from go-rtmp.

ArturFortunato avatar ArturFortunato commented on June 16, 2024

Is it possible to pass the publishingName as a parameter of OnAudio/OnVideo?

Thank you!

from go-rtmp.

ArturFortunato avatar ArturFortunato commented on June 16, 2024

Is this code helpful? If this is not what you intended, please let me know

type Handler struct {
	rtmp.DefaultHandler

	// value holders
	app string
	publishingName string
}

func (h *Handler) OnConnect(timestamp uint32, cmd *rtmpmsg.NetConnectionConnect) error {
	h.app = cmd.Command.App // Save values to each handler instances

	return nil
}

func (h *Handler) OnPublish(timestamp uint32, cmd *rtmpmsg.NetStreamPublish) error {
	log.Printf("App Name: %v", h.app) // Read the 'App' value saved in the handler

	h.publishingName = cmd.PublishingName // Same

	return nil
}

func (h *Handler) OnAudio(timestamp uint32, payload io.Reader) error {
	log.Printf("App Name: %v", h.publishingName) // Read the 'PublishingName' value saved in the handler
}

Thank you.

@yutopp I have tested this and it only works with 1 video input. I have been trying to understand the structure of the project, but haven't been able to understand where should I store the PushingName (or another identifier) that allows me to serve multiple input streams. Can you help me?

Thank you in advance!

from go-rtmp.

yutopp avatar yutopp commented on June 16, 2024

I'm glad to hear that!

from go-rtmp.

ArturFortunato avatar ArturFortunato commented on June 16, 2024

Hi.
I have been adapting the code for webRTC output, and it worked with a single input, but as soon as I start streaming to a second publishingname, the first one freezes. I have been trying to understand your example and I cannot understand how can the server be aware of the publishingname on OnAudio/OnVideo.
I figured it should be the connection set on OnPlay (although I fail to understand virifications such as

if h.sub != nil {
		return errors.New("Cannot play on this stream")
	}

But my problem is, as the OnPlay will not be executed in my code (as it won't be an RTMP client, but a webRTC one), how can I replicate what you did here?

Thank you so much for your help 😄

from go-rtmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.