tangled
alpha
login
or
join now
stream.place
/
streamplace
Live video on the AT Protocol
74
fork
atom
overview
issues
1
pulls
pipelines
convert sign over too
Natalie B.
1 day ago
b48009b3
b3af6ade
+49
-26
2 changed files
expand all
collapse all
unified
split
pkg
cmd
sign.go
streamplace.go
+13
-25
pkg/cmd/sign.go
···
4
4
"bytes"
5
5
"context"
6
6
"crypto/ecdsa"
7
7
-
"flag"
8
7
"fmt"
9
8
"io"
10
9
"os"
···
16
15
"stream.place/streamplace/pkg/media"
17
16
)
18
17
19
19
-
func Sign(ctx context.Context) error {
20
20
-
fs := flag.NewFlagSet("streamplace", flag.ExitOnError)
21
21
-
certPath := fs.String("cert", "", "path to the certificate file")
22
22
-
key := fs.String("key", "", "base58-encoded secp256k1 private key")
23
23
-
streamerName := fs.String("streamer", "", "streamer name")
24
24
-
taURL := fs.String("ta-url", "http://timestamp.digicert.com", "timestamp authority server for signing")
25
25
-
startTime := fs.Int64("start-time", 0, "start time of the stream")
26
26
-
manifestJSON := fs.String("manifest", "", "JSON manifest to use for signing")
27
27
-
if err := fs.Parse(os.Args[2:]); err != nil {
28
28
-
return err
29
29
-
}
30
30
-
18
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
32
-
"streamer", *streamerName,
33
33
-
"startTime", *startTime,
34
34
-
"hasManifest", len(*manifestJSON) > 0)
20
20
+
"streamer", streamerName,
21
21
+
"startTime", startTime,
22
22
+
"hasManifest", len(manifestJSON) > 0)
35
23
36
36
-
keyBs, err := base58.Decode(*key)
24
24
+
keyBs, err := base58.Decode(key)
37
25
if err != nil {
38
26
return err
39
27
}
40
28
41
41
-
if *streamerName == "" {
29
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
51
-
certBs, err := os.ReadFile(*certPath)
39
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
64
-
StreamerName: *streamerName,
65
65
-
TAURL: *taURL,
52
52
+
StreamerName: streamerName,
53
53
+
TAURL: taURL,
66
54
AQPub: pub,
67
67
-
PrebuiltManifest: []byte(*manifestJSON), // Pass the manifest from parent process
55
55
+
PrebuiltManifest: []byte(manifestJSON), // Pass the manifest from parent process
68
56
}
69
57
70
70
-
if len(*manifestJSON) > 0 {
71
71
-
log.Debug(ctx, "Sign command: using provided manifest", "manifestLength", len(*manifestJSON))
58
58
+
if len(manifestJSON) > 0 {
59
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
79
-
mp4, err := ms.SignMP4(ctx, bytes.NewReader(inputBs), *startTime)
67
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
591
+
Flags: []urfavecli.Flag{
592
592
+
&urfavecli.StringFlag{
593
593
+
Name: "cert",
594
594
+
Usage: "path to the certificate file",
595
595
+
},
596
596
+
&urfavecli.StringFlag{
597
597
+
Name: "key",
598
598
+
Usage: "base58-encoded secp256k1 private key",
599
599
+
},
600
600
+
&urfavecli.StringFlag{
601
601
+
Name: "streamer",
602
602
+
Usage: "streamer name",
603
603
+
},
604
604
+
&urfavecli.StringFlag{
605
605
+
Name: "ta-url",
606
606
+
Usage: "timestamp authority server for signing",
607
607
+
Value: "http://timestamp.digicert.com",
608
608
+
},
609
609
+
&urfavecli.IntFlag{
610
610
+
Name: "start-time",
611
611
+
Usage: "start time of the stream",
612
612
+
},
613
613
+
&urfavecli.StringFlag{
614
614
+
Name: "manifest",
615
615
+
Usage: "JSON manifest to use for signing",
616
616
+
},
617
617
+
},
591
618
Action: func(ctx context.Context, cmd *urfavecli.Command) error {
592
592
-
return Sign(ctx)
619
619
+
return Sign(
620
620
+
ctx,
621
621
+
cmd.String("cert"),
622
622
+
cmd.String("key"),
623
623
+
cmd.String("streamer"),
624
624
+
cmd.String("ta-url"),
625
625
+
int64(cmd.Int("start-time")),
626
626
+
cmd.String("manifest"),
627
627
+
)
593
628
},
594
629
}
595
630
}