Decouple the common stream forwarding logic from the specific implementations

This commit is contained in:
Dmitrii Okunev
2024-10-13 02:49:00 +01:00
parent f0a8d846c7
commit 765da7c365
23 changed files with 1019 additions and 870 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/xaionaro-go/streamctl/pkg/observability"
"github.com/xaionaro-go/streamctl/pkg/streamserver/implementations/libav/recoder/types"
"github.com/xaionaro-go/streamctl/pkg/streamserver/implementations/libav/saferecoder/grpc/go/recoder_grpc"
"github.com/xaionaro-go/streamctl/pkg/streamserver/recoder"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
@@ -83,7 +84,7 @@ func (c *Client) NewInputFromURL(
}
type OutputID uint64
type OutputConfig = types.OutputConfig
type OutputConfig = recoder.OutputConfig
func (c *Client) NewOutputFromURL(
ctx context.Context,
@@ -158,10 +159,7 @@ func (c *Client) StartRecoding(
return nil
}
type RecoderStats struct {
BytesCountRead uint64
BytesCountWrote uint64
}
type RecoderStats = recoder.Stats
func (c *Client) GetRecoderStats(
ctx context.Context,

View File

@@ -15,18 +15,19 @@ import (
"github.com/facebookincubator/go-belt/tool/logger"
"github.com/xaionaro-go/streamctl/pkg/observability"
"github.com/xaionaro-go/streamctl/pkg/streamserver/implementations/libav/saferecoder/process/client"
"github.com/xaionaro-go/streamctl/pkg/streamserver/recoder"
)
type InputID = client.InputID
type InputConfig = client.InputConfig
type InputConfig = recoder.InputConfig
type OutputID = client.OutputID
type OutputConfig = client.OutputConfig
type OutputConfig = recoder.OutputConfig
type RecoderID = client.RecoderID
type RecoderConfig = client.RecoderConfig
type RecoderConfig = recoder.Config
type RecoderStats = client.RecoderStats
type RecoderStats = recoder.Stats
type Recoder struct {
*client.Client

View File

@@ -7,7 +7,7 @@ import (
"context"
"fmt"
"github.com/xaionaro-go/streamctl/pkg/streamserver/implementations/libav/recoder/types"
"github.com/xaionaro-go/streamctl/pkg/streamserver/recoder"
)
type Recoder struct {
@@ -27,13 +27,13 @@ func Run(
type Client struct{}
type InputID uint64
type InputConfig = types.InputConfig
type InputConfig = recoder.InputConfig
type OutputID uint64
type OutputConfig = types.OutputConfig
type OutputConfig = recoder.OutputConfig
type RecoderID uint64
type RecoderConfig = types.RecoderConfig
type RecoderConfig = recoder.Config
func (c *Client) NewInputFromURL(
ctx context.Context,
@@ -67,10 +67,7 @@ func (c *Client) NewRecoder(
return 0, fmt.Errorf("not compiled with libav support")
}
type RecoderStats struct {
BytesCountRead uint64
BytesCountWrote uint64
}
type RecoderStats = recoder.Stats
func (c *Client) GetRecoderStats(
ctx context.Context,

View File

@@ -6,6 +6,7 @@ import (
"github.com/xaionaro-go/streamctl/pkg/streamserver/implementations/libav/recoder/types"
"github.com/xaionaro-go/streamctl/pkg/streamserver/implementations/libav/saferecoder/process"
"github.com/xaionaro-go/streamctl/pkg/streamserver/recoder"
)
type Packet = types.Packet
@@ -61,7 +62,7 @@ func (r *Recoder) StartRecoding(
)
}
type RecoderStats = process.RecoderStats
type RecoderStats = recoder.Stats
func (r *Recoder) GetStats(ctx context.Context) (*RecoderStats, error) {
return r.Process.processBackend.Client.GetRecoderStats(ctx, r.ID)