deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.3k stars 307 forks source link

udp port range not work #493

Open mouuii opened 3 weeks ago

mouuii commented 3 weeks ago

I want to set the udp port range ,but doesn't work. so i change the code in rtspv2 pkg by 'replace github.com/deepch/vdk v0.0.27 => ./vdk', to use net.dail with local port as below 。 Do you have any ideal ? @deepch

func StreamServerRunStream(name string) (bool, error) {
    keyTest := time.NewTimer(20 * time.Second)
    Control := Storage.StreamControl(name)
    var preKeyTS = time.Duration(0)
    var Seq []*av.Packet
    RTSPClient, err := rtspv2.Dial(rtspv2.RTSPClientOptions{URL: Control.URL, DisableAudio: true, DialTimeout: 3 * time.Second, ReadWriteTimeout: time.Second * 5 * time.Second, Debug: Control.Debug})
    if err != nil {
        return false, errors.New("RTSP Client Error " + err.Error())
    }
    Storage.StreamStatus(name, ONLINE)
    defer func() {
        RTSPClient.Close()
        Storage.StreamStatus(name, OFFLINE)
    }()
     ... 
}

// in another repo vdk , package rtspv2
func Dial(options RTSPClientOptions) (*RTSPClient, error) {
         ...

    d := net.Dialer{Timeout: client.options.DialTimeout, LocalAddr: &net.TCPAddr{
        IP:   net.ParseIP("0.0.0.0"),
        Port: 30043,
    }}
    conn, err := d.Dial("tcp", client.pURL.Host)
    //conn, err := net.DialTimeout("tcp", client.pURL.Host, client.options.DialTimeout)
mouuii commented 2 weeks ago

ping @deepch