Live video on the AT Protocol

convert sign over too

+49 -26
+13 -25
pkg/cmd/sign.go
··· 4 4 "bytes" 5 5 "context" 6 6 "crypto/ecdsa" 7 - "flag" 8 7 "fmt" 9 8 "io" 10 9 "os" ··· 16 15 "stream.place/streamplace/pkg/media" 17 16 ) 18 17 19 - func Sign(ctx context.Context) error { 20 - fs := flag.NewFlagSet("streamplace", flag.ExitOnError) 21 - certPath := fs.String("cert", "", "path to the certificate file") 22 - key := fs.String("key", "", "base58-encoded secp256k1 private key") 23 - streamerName := fs.String("streamer", "", "streamer name") 24 - taURL := fs.String("ta-url", "http://timestamp.digicert.com", "timestamp authority server for signing") 25 - startTime := fs.Int64("start-time", 0, "start time of the stream") 26 - manifestJSON := fs.String("manifest", "", "JSON manifest to use for signing") 27 - if err := fs.Parse(os.Args[2:]); err != nil { 28 - return err 29 - } 30 - 18 + func Sign(ctx context.Context, certPath string, key string, streamerName string, taURL string, startTime int64, manifestJSON string) error { 31 19 log.Debug(ctx, "Sign command: starting", 32 - "streamer", *streamerName, 33 - "startTime", *startTime, 34 - "hasManifest", len(*manifestJSON) > 0) 20 + "streamer", streamerName, 21 + "startTime", startTime, 22 + "hasManifest", len(manifestJSON) > 0) 35 23 36 - keyBs, err := base58.Decode(*key) 24 + keyBs, err := base58.Decode(key) 37 25 if err != nil { 38 26 return err 39 27 } 40 28 41 - if *streamerName == "" { 29 + if streamerName == "" { 42 30 return fmt.Errorf("streamer name is required") 43 31 } 44 32 ··· 48 36 } 49 37 signer := secpSigner.ToECDSA() 50 38 51 - certBs, err := os.ReadFile(*certPath) 39 + certBs, err := os.ReadFile(certPath) 52 40 if err != nil { 53 41 return err 54 42 } ··· 61 49 ms := &media.MediaSignerLocal{ 62 50 Signer: signer, 63 51 Cert: certBs, 64 - StreamerName: *streamerName, 65 - TAURL: *taURL, 52 + StreamerName: streamerName, 53 + TAURL: taURL, 66 54 AQPub: pub, 67 - PrebuiltManifest: []byte(*manifestJSON), // Pass the manifest from parent process 55 + PrebuiltManifest: []byte(manifestJSON), // Pass the manifest from parent process 68 56 } 69 57 70 - if len(*manifestJSON) > 0 { 71 - log.Debug(ctx, "Sign command: using provided manifest", "manifestLength", len(*manifestJSON)) 58 + if len(manifestJSON) > 0 { 59 + log.Debug(ctx, "Sign command: using provided manifest", "manifestLength", len(manifestJSON)) 72 60 } 73 61 74 62 inputBs, err := io.ReadAll(os.Stdin) ··· 76 64 return err 77 65 } 78 66 79 - mp4, err := ms.SignMP4(ctx, bytes.NewReader(inputBs), *startTime) 67 + mp4, err := ms.SignMP4(ctx, bytes.NewReader(inputBs), startTime) 80 68 if err != nil { 81 69 return err 82 70 }
+36 -1
pkg/cmd/streamplace.go
··· 588 588 return &urfavecli.Command{ 589 589 Name: "sign", 590 590 Usage: "sign command", 591 + Flags: []urfavecli.Flag{ 592 + &urfavecli.StringFlag{ 593 + Name: "cert", 594 + Usage: "path to the certificate file", 595 + }, 596 + &urfavecli.StringFlag{ 597 + Name: "key", 598 + Usage: "base58-encoded secp256k1 private key", 599 + }, 600 + &urfavecli.StringFlag{ 601 + Name: "streamer", 602 + Usage: "streamer name", 603 + }, 604 + &urfavecli.StringFlag{ 605 + Name: "ta-url", 606 + Usage: "timestamp authority server for signing", 607 + Value: "http://timestamp.digicert.com", 608 + }, 609 + &urfavecli.IntFlag{ 610 + Name: "start-time", 611 + Usage: "start time of the stream", 612 + }, 613 + &urfavecli.StringFlag{ 614 + Name: "manifest", 615 + Usage: "JSON manifest to use for signing", 616 + }, 617 + }, 591 618 Action: func(ctx context.Context, cmd *urfavecli.Command) error { 592 - return Sign(ctx) 619 + return Sign( 620 + ctx, 621 + cmd.String("cert"), 622 + cmd.String("key"), 623 + cmd.String("streamer"), 624 + cmd.String("ta-url"), 625 + int64(cmd.Int("start-time")), 626 + cmd.String("manifest"), 627 + ) 593 628 }, 594 629 } 595 630 }