mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 07:36:57 +08:00
rpicamera: support changing parameters without interrupting the stream (#1463)
This commit is contained in:
@@ -30,23 +30,17 @@ type rtmpSourceParent interface {
|
||||
}
|
||||
|
||||
type rtmpSource struct {
|
||||
ur string
|
||||
fingerprint string
|
||||
readTimeout conf.StringDuration
|
||||
writeTimeout conf.StringDuration
|
||||
parent rtmpSourceParent
|
||||
}
|
||||
|
||||
func newRTMPSource(
|
||||
ur string,
|
||||
fingerprint string,
|
||||
readTimeout conf.StringDuration,
|
||||
writeTimeout conf.StringDuration,
|
||||
parent rtmpSourceParent,
|
||||
) *rtmpSource {
|
||||
return &rtmpSource{
|
||||
ur: ur,
|
||||
fingerprint: fingerprint,
|
||||
readTimeout: readTimeout,
|
||||
writeTimeout: writeTimeout,
|
||||
parent: parent,
|
||||
@@ -58,10 +52,10 @@ func (s *rtmpSource) Log(level logger.Level, format string, args ...interface{})
|
||||
}
|
||||
|
||||
// run implements sourceStaticImpl.
|
||||
func (s *rtmpSource) run(ctx context.Context) error {
|
||||
func (s *rtmpSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan *conf.PathConf) error {
|
||||
s.Log(logger.Debug, "connecting")
|
||||
|
||||
u, err := url.Parse(s.ur)
|
||||
u, err := url.Parse(cnf.Source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -86,7 +80,7 @@ func (s *rtmpSource) run(ctx context.Context) error {
|
||||
h := sha256.New()
|
||||
h.Write(cs.PeerCertificates[0].Raw)
|
||||
hstr := hex.EncodeToString(h.Sum(nil))
|
||||
fingerprintLower := strings.ToLower(s.fingerprint)
|
||||
fingerprintLower := strings.ToLower(cnf.SourceFingerprint)
|
||||
|
||||
if hstr != fingerprintLower {
|
||||
return fmt.Errorf("server fingerprint do not match: expected %s, got %s",
|
||||
@@ -213,15 +207,19 @@ func (s *rtmpSource) run(ctx context.Context) error {
|
||||
}()
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-readDone:
|
||||
nconn.Close()
|
||||
return err
|
||||
for {
|
||||
select {
|
||||
case err := <-readDone:
|
||||
nconn.Close()
|
||||
return err
|
||||
|
||||
case <-ctx.Done():
|
||||
nconn.Close()
|
||||
<-readDone
|
||||
return nil
|
||||
case <-reloadConf:
|
||||
|
||||
case <-ctx.Done():
|
||||
nconn.Close()
|
||||
<-readDone
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user