Initial commit, pt. 22

This commit is contained in:
Dmitrii Okunev
2024-06-23 19:31:00 +01:00
parent 5da165f9f5
commit bbe098fdfb
11 changed files with 600 additions and 47 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"reflect"
"sync"
"time"
@@ -50,11 +51,12 @@ func GetStreamProfile[T StreamProfile](
if err != nil {
return nil, fmt.Errorf("unable to serialize: %w: %#+v", err, v)
}
logger.Debugf(ctx, "JSON representation: <%s>", b)
err = json.Unmarshal(b, &profile)
if err != nil {
return nil, fmt.Errorf("unable to deserialize: %w: <%s>", err, b)
}
logger.Debugf(ctx, "converted %#+v to %#+v", v, profile)
logger.Debugf(ctx, "converted %#+v (%s) to %#+v", v, v, profile)
return &profile, nil
}
@@ -68,12 +70,14 @@ func ConvertStreamProfiles[T StreamProfile](
return err
}
m[k] = *profile
logger.Debugf(ctx, "converted %#+v to %#+v", v, profile)
logger.Debugf(ctx, "converted %#+v (%s) to %#+v", v, v, profile)
}
return nil
}
type StreamControllerCommons interface {
io.Closer
SetTitle(ctx context.Context, title string) error
SetDescription(ctx context.Context, description string) error
InsertAdsCuePoint(ctx context.Context, ts time.Time, duration time.Duration) error
@@ -101,6 +105,10 @@ type abstractStreamController struct {
StreamProfileTypeValue reflect.Type
}
func (c *abstractStreamController) Close() error {
return c.StreamController.Close()
}
func (c *abstractStreamController) GetImplementation() StreamControllerCommons {
return c.StreamController
}