Live video on the AT Protocol
79
fork

Configure Feed

Select the types of activity you want to include in your feed.

manifestBuilder: embed livestream and metadata records in segment

+30 -2
+30 -2
pkg/media/manifest_builder.go
··· 32 32 } 33 33 } 34 34 35 + func toObj(record any) (obj, error) { 36 + jsonBs, err := json.Marshal(record) 37 + if err != nil { 38 + return nil, fmt.Errorf("failed to marshal record: %w", err) 39 + } 40 + var o obj 41 + err = json.Unmarshal(jsonBs, &o) 42 + if err != nil { 43 + return nil, fmt.Errorf("failed to unmarshal record: %w", err) 44 + } 45 + return o, nil 46 + } 47 + 35 48 func (mb *ManifestBuilder) BuildManifest(ctx context.Context, streamerName string, start int64) ([]byte, error) { 36 - fmt.Printf("๐Ÿ” BuildManifest CALLED for %s at %d\n", streamerName, start) 37 - log.Warn(ctx, "๐Ÿ” BuildManifest ENTRY", "streamer", streamerName, "start", start) 49 + log.Debug(ctx, "๐Ÿ” BuildManifest ENTRY", "streamer", streamerName, "start", start) 38 50 // Start with base manifest 39 51 mani := obj{ 40 52 "title": fmt.Sprintf("Livestream Segment at %s", aqtime.FromMillis(start)), ··· 80 92 } else { 81 93 log.Warn(ctx, "ManifestBuilder: enhancing manifest with metadata", "did", streamerName, "contentWarnings", streamplaceMetadata.ContentWarnings, "contentRights", streamplaceMetadata.ContentRights) 82 94 mani = mb.enhanceManifestWithMetadata(mani, streamplaceMetadata, start) 95 + metadataObj, err := toObj(streamplaceMetadata) 96 + if err != nil { 97 + return nil, fmt.Errorf("failed to marshal metadata: %w", err) 98 + } 99 + mani["assertions"] = append(mani["assertions"].([]obj), obj{ 100 + "label": "place.stream.metadata.configuration", 101 + "data": metadataObj, 102 + }) 83 103 } 84 104 } else { 85 105 log.Warn(ctx, "ManifestBuilder: no metadata configuration found for streamer", "did", streamerName) ··· 100 120 } else { 101 121 if ls, ok := livestreamRecord.Record.Val.(*streamplace.Livestream); ok { 102 122 livestreamTitle = ls.Title 123 + livestreamObj, err := toObj(ls) 124 + if err != nil { 125 + return nil, fmt.Errorf("failed to marshal livestream: %w", err) 126 + } 127 + mani["assertions"] = append(mani["assertions"].([]obj), obj{ 128 + "label": "place.stream.livestream", 129 + "data": livestreamObj, 130 + }) 103 131 } 104 132 } 105 133 }