notedit / media-server-go-demo

webrtc media server go demo
MIT License
212 stars 64 forks source link

webrtc-to-rtmp demo can't work #30

Open mightZhong opened 4 years ago

mightZhong commented 4 years ago

Hi , I tested the webrtc-to-rtmp demo, but it can't work. Following is my test steps

  1. change the IP set in NewRtmpPusher to my nginx-rtmp server, then go build
  2. run the executable file webrtc-to-rtmp and open the webrtc test web in chrome, I can see myself in local and remote stream.
  3. there is no log of "video frame ==========" or "audio frame ===== " print, and no rtmp stream send to my nginx-rtmp server

I wondering if there is something wrong in my steps, any suggestion is appreciated~

shelomito12 commented 4 years ago

Were you able to fix it?

After building the main media-server-go, I executed the command go build in the webrtc-to-rtmp/ directory and got the following:

$ go build
# github.com/notedit/media-server-go-demo/webrtc-to-rtmp
./server.go:124:30: cannot use func literal (type func([]byte, uint)) as type func([]byte, uint64) in argument to videoTrack.OnMediaFrame
./server.go:139:30: cannot use func literal (type func([]byte, uint)) as type func([]byte, uint64) in argument to audioTrack.OnMediaFrame
marcelhencke commented 3 years ago

@jzvi12 replace uint by uint64 in the server.go file and now it should compile

marcelhencke commented 3 years ago

In commit: f0bcbc9 in the mediaframemultiplexer.go file the callback logic was disable. Because in the media-server project (https://github.com/medooze/media-server) not the media-server-go project, some changes where made to media-server/include/media.h file.

Amongst other things the GetData() method gets overloaded in a clever way to optimize performance. But this is to much for the SWIG compiler, which then creates 3 functions, one being a switch for the other two, but returning an interface{} instead of a pointer.

What is to do:

  1. install swig: apt install swig
  2. edit media-server/include/media.h and remove follow line const BYTE* GetData() const { return buffer->GetData();} currently at line 166
  3. edit wrapper/mediaserver.i and add %include "../media-server/include/media.h" before %include "../media-server/include/acumulator.h" currently at line 965
  4. run swig -go -c++ -cgo -intgosize 64 mediaserver.i
  5. edit mediaframemultiplexer.go import fmt and unsafe and enable the code under OnMediaFrame
notedit commented 3 years ago

@marcelhencke Do you have some free time to support media-server-go developing? I am a bit busy these days.

marcelhencke commented 3 years ago

@marcelhencke Do you have some free time to support media-server-go developing? I am a bit busy these days.

I don't have much free time myself. But since I want to build on this project and I need the GStreamer support, I would be happy to support the project and maintain it's functionality.