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
"bytes"
5
"context"
6
"crypto/ecdsa"
7
-
"flag"
8
"fmt"
9
"io"
10
"os"
···
16
"stream.place/streamplace/pkg/media"
17
)
18
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
-
31
log.Debug(ctx, "Sign command: starting",
32
-
"streamer", *streamerName,
33
-
"startTime", *startTime,
34
-
"hasManifest", len(*manifestJSON) > 0)
35
36
-
keyBs, err := base58.Decode(*key)
37
if err != nil {
38
return err
39
}
40
41
-
if *streamerName == "" {
42
return fmt.Errorf("streamer name is required")
43
}
44
···
48
}
49
signer := secpSigner.ToECDSA()
50
51
-
certBs, err := os.ReadFile(*certPath)
52
if err != nil {
53
return err
54
}
···
61
ms := &media.MediaSignerLocal{
62
Signer: signer,
63
Cert: certBs,
64
-
StreamerName: *streamerName,
65
-
TAURL: *taURL,
66
AQPub: pub,
67
-
PrebuiltManifest: []byte(*manifestJSON), // Pass the manifest from parent process
68
}
69
70
-
if len(*manifestJSON) > 0 {
71
-
log.Debug(ctx, "Sign command: using provided manifest", "manifestLength", len(*manifestJSON))
72
}
73
74
inputBs, err := io.ReadAll(os.Stdin)
···
76
return err
77
}
78
79
-
mp4, err := ms.SignMP4(ctx, bytes.NewReader(inputBs), *startTime)
80
if err != nil {
81
return err
82
}
···
4
"bytes"
5
"context"
6
"crypto/ecdsa"
0
7
"fmt"
8
"io"
9
"os"
···
15
"stream.place/streamplace/pkg/media"
16
)
17
18
+
func Sign(ctx context.Context, certPath string, key string, streamerName string, taURL string, startTime int64, manifestJSON string) error {
0
0
0
0
0
0
0
0
0
0
0
19
log.Debug(ctx, "Sign command: starting",
20
+
"streamer", streamerName,
21
+
"startTime", startTime,
22
+
"hasManifest", len(manifestJSON) > 0)
23
24
+
keyBs, err := base58.Decode(key)
25
if err != nil {
26
return err
27
}
28
29
+
if streamerName == "" {
30
return fmt.Errorf("streamer name is required")
31
}
32
···
36
}
37
signer := secpSigner.ToECDSA()
38
39
+
certBs, err := os.ReadFile(certPath)
40
if err != nil {
41
return err
42
}
···
49
ms := &media.MediaSignerLocal{
50
Signer: signer,
51
Cert: certBs,
52
+
StreamerName: streamerName,
53
+
TAURL: taURL,
54
AQPub: pub,
55
+
PrebuiltManifest: []byte(manifestJSON), // Pass the manifest from parent process
56
}
57
58
+
if len(manifestJSON) > 0 {
59
+
log.Debug(ctx, "Sign command: using provided manifest", "manifestLength", len(manifestJSON))
60
}
61
62
inputBs, err := io.ReadAll(os.Stdin)
···
64
return err
65
}
66
67
+
mp4, err := ms.SignMP4(ctx, bytes.NewReader(inputBs), startTime)
68
if err != nil {
69
return err
70
}
+36
-1
pkg/cmd/streamplace.go
···
588
return &urfavecli.Command{
589
Name: "sign",
590
Usage: "sign command",
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
591
Action: func(ctx context.Context, cmd *urfavecli.Command) error {
592
-
return Sign(ctx)
0
0
0
0
0
0
0
0
593
},
594
}
595
}
···
588
return &urfavecli.Command{
589
Name: "sign",
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
+
},
618
Action: func(ctx context.Context, cmd *urfavecli.Command) error {
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
+
)
628
},
629
}
630
}