Compare commits

...

3 Commits

Author SHA1 Message Date
Garionion aa6d0ed864 add reflection to gRPC server
only log to file if configured
2022-02-07 11:21:59 +01:00
Garionion bcdf42b277 add logging, some bugfixing 2022-02-07 11:20:50 +01:00
Garionion 239869bfd7 add gRPC API 2022-02-07 11:19:10 +01:00
10 changed files with 225 additions and 171 deletions

View File

@ -60,9 +60,11 @@ func (s *PipelineService) StartPipeline(ctx context.Context, id *PipelineID) (*P
}
func (s *PipelineService) DeletePipeline(ctx context.Context, id *PipelineID) (*PipelineDeleteResponse, error) {
go s.Gstreamer.DeletePipeline(id.GetId())
s.Gstreamer.DeletePipeline(id.GetId())
var err error
if slot, ok := s.pipelineslotmapping[id.GetId()]; ok {
s.Lock()
defer s.Unlock()
delete(s.pipelineslotmapping, id.GetId())
var i int
for i := range s.pipelineSlots[slot] {
@ -71,9 +73,10 @@ func (s *PipelineService) DeletePipeline(ctx context.Context, id *PipelineID) (*
}
}
s.pipelineSlots[slot] = append(s.pipelineSlots[slot][:i], s.pipelineSlots[slot][i+1:]...)
s.Unlock()
} else {
err = fmt.Errorf("Pipeline %s not found", id.GetId())
}
return &PipelineDeleteResponse{PipelineId: &PipelineID{Id: id.GetId()}}, nil
return &PipelineDeleteResponse{PipelineId: &PipelineID{Id: id.GetId()}}, err
}
func (s *PipelineService) CreatePipeline(ctx context.Context, pipeline *Pipeline) (*PipelineCreationResponse, error) {
@ -94,15 +97,24 @@ func (s *PipelineService) CreatePipeline(ctx context.Context, pipeline *Pipeline
Type: pipeline.GetOutput(),
},
}
gstreamerPipeline.Overlays = s.convertRPCOverlayToGstreamerOverlay(pipeline.Overlay)
gstreamerPipeline.Create()
gstreamerPipeline.Overlays = s.convertRPCOverlayToGstreamerOverlay(pipeline.Overlays)
_, err := gstreamerPipeline.Create()
if err != nil {
log.Error().Err(err)
return nil, err
}
s.Lock()
if s.pipelineSlots == nil {
s.pipelineSlots = make(map[string][]string)
}
if _, ok := s.pipelineSlots[pipeline.GetName()]; ok {
s.pipelineSlots[pipeline.GetName()] = append(s.pipelineSlots[pipeline.GetName()], id)
} else {
s.pipelineSlots[pipeline.GetName()] = []string{id}
}
if s.pipelineslotmapping == nil {
s.pipelineslotmapping = make(map[string]string)
}
s.pipelineslotmapping[id] = pipeline.GetName()
s.Unlock()
return &PipelineCreationResponse{

View File

@ -25,10 +25,10 @@ type Pipeline struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Clip string `protobuf:"bytes,2,opt,name=clip,proto3" json:"clip,omitempty"`
Output string `protobuf:"bytes,3,opt,name=output,proto3" json:"output,omitempty"`
Overlay []*Overlay `protobuf:"bytes,4,rep,name=overlay,proto3" json:"overlay,omitempty"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Clip string `protobuf:"bytes,2,opt,name=clip,proto3" json:"clip,omitempty"`
Output string `protobuf:"bytes,3,opt,name=output,proto3" json:"output,omitempty"`
Overlays []*Overlay `protobuf:"bytes,4,rep,name=overlays,proto3" json:"overlays,omitempty"`
}
func (x *Pipeline) Reset() {
@ -84,9 +84,9 @@ func (x *Pipeline) GetOutput() string {
return ""
}
func (x *Pipeline) GetOverlay() []*Overlay {
func (x *Pipeline) GetOverlays() []*Overlay {
if x != nil {
return x.Overlay
return x.Overlays
}
return nil
}
@ -795,115 +795,115 @@ var File_api_api_proto protoreflect.FileDescriptor
var file_api_api_proto_rawDesc = []byte{
0x0a, 0x0d, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x03, 0x61, 0x70, 0x69, 0x22, 0x72, 0x0a, 0x08, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x03, 0x61, 0x70, 0x69, 0x22, 0x74, 0x0a, 0x08, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6c, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x63, 0x6c, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70,
0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74,
0x12, 0x26, 0x0a, 0x07, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x18, 0x04, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x52,
0x07, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x22, 0xb7, 0x02, 0x0a, 0x07, 0x4f, 0x76, 0x65,
0x72, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28,
0x03, 0x52, 0x01, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x18,
0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x12, 0x19,
0x0a, 0x08, 0x62, 0x6c, 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03,
0x52, 0x07, 0x62, 0x6c, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x6c, 0x65,
0x6e, 0x64, 0x5f, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x62, 0x6c,
0x65, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x12, 0x29, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18,
0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x78, 0x74, 0x72,
0x61, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72,
0x61, 0x12, 0x35, 0x0a, 0x0c, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61,
0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x65,
0x78, 0x74, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x65, 0x78,
0x74, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x38, 0x0a, 0x0d, 0x69, 0x6d, 0x61, 0x67,
0x65, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x6c,
0x61, 0x79, 0x48, 0x00, 0x52, 0x0c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x6c,
0x61, 0x79, 0x42, 0x0e, 0x0a, 0x0c, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x5f, 0x64, 0x61,
0x74, 0x61, 0x22, 0x90, 0x01, 0x0a, 0x0c, 0x45, 0x78, 0x74, 0x72, 0x61, 0x4f, 0x76, 0x65, 0x72,
0x6c, 0x61, 0x79, 0x12, 0x41, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x78,
0x74, 0x72, 0x61, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65,
0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70,
0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72,
0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x0c, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x4f, 0x76,
0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01,
0x79, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0xe8, 0x01, 0x0a, 0x0b, 0x54, 0x65, 0x78, 0x74, 0x4f, 0x76,
0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x02,
0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20, 0x01,
0x28, 0x03, 0x52, 0x01, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x6f, 0x6e,
0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x66, 0x6f,
0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x6f, 0x6e, 0x74, 0x4e,
0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x77, 0x65, 0x69, 0x67,
0x68, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x6e, 0x74, 0x57, 0x65,
0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x66, 0x6f, 0x6e, 0x74, 0x43, 0x6f,
0x6c, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68,
0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x57, 0x69, 0x64, 0x74, 0x68,
0x22, 0x4c, 0x0a, 0x18, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x72, 0x65, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b,
0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x49, 0x44, 0x52, 0x0a, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x5c,
0x0a, 0x0f, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x73, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x02,
0x69, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x02,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x6c,
0x61, 0x79, 0x52, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x73, 0x22, 0x1c, 0x0a, 0x0a,
0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x4a, 0x0a, 0x16, 0x50, 0x69,
0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70, 0x69, 0x70, 0x65,
0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x49, 0x0a, 0x15, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69,
0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c,
0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49,
0x64, 0x22, 0x48, 0x0a, 0x14, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x6f,
0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70,
0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52,
0x0a, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x4a, 0x0a, 0x16, 0x50,
0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e,
0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70, 0x69, 0x70,
0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x32, 0xd0, 0x02, 0x0a, 0x0f, 0x50, 0x69, 0x70, 0x65,
0x6c, 0x69, 0x6e, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3e, 0x0a, 0x0e, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x0d, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x1d, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0e, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x73, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69,
0x6e, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x3c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e,
0x65, 0x12, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x49, 0x44, 0x1a, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e,
0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a,
0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x70, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x0f,
0x12, 0x28, 0x0a, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x04, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79,
0x52, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x73, 0x22, 0xb7, 0x02, 0x0a, 0x07, 0x4f,
0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18,
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20,
0x01, 0x28, 0x03, 0x52, 0x01, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61,
0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79,
0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01,
0x28, 0x03, 0x52, 0x07, 0x62, 0x6c, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x62,
0x6c, 0x65, 0x6e, 0x64, 0x5f, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08,
0x62, 0x6c, 0x65, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x12, 0x29, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72,
0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x78,
0x74, 0x72, 0x61, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x78,
0x74, 0x72, 0x61, 0x12, 0x35, 0x0a, 0x0c, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x6f, 0x76, 0x65, 0x72,
0x6c, 0x61, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x54, 0x65, 0x78, 0x74, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, 0x0b, 0x74,
0x65, 0x78, 0x74, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x38, 0x0a, 0x0d, 0x69, 0x6d,
0x61, 0x67, 0x65, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x4f, 0x76, 0x65,
0x72, 0x6c, 0x61, 0x79, 0x48, 0x00, 0x52, 0x0c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4f, 0x76, 0x65,
0x72, 0x6c, 0x61, 0x79, 0x42, 0x0e, 0x0a, 0x0c, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x5f,
0x64, 0x61, 0x74, 0x61, 0x22, 0x90, 0x01, 0x0a, 0x0c, 0x45, 0x78, 0x74, 0x72, 0x61, 0x4f, 0x76,
0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x41, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74,
0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x45, 0x78, 0x74, 0x72, 0x61, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f,
0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72,
0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70,
0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x0c, 0x49, 0x6d, 0x61, 0x67, 0x65,
0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x02, 0x20, 0x01,
0x28, 0x03, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
0x52, 0x01, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0xe8, 0x01, 0x0a, 0x0b, 0x54, 0x65, 0x78, 0x74,
0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78,
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18,
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x66,
0x6f, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08,
0x66, 0x6f, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x6f, 0x6e, 0x74,
0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x6f, 0x6e,
0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x77, 0x65,
0x69, 0x67, 0x68, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x6e, 0x74,
0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63,
0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x66, 0x6f, 0x6e, 0x74,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x77, 0x69, 0x64,
0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x57, 0x69, 0x64,
0x74, 0x68, 0x22, 0x4c, 0x0a, 0x18, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x72,
0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30,
0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69,
0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64,
0x22, 0x5c, 0x0a, 0x0f, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44,
0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x73,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x76, 0x65,
0x72, 0x6c, 0x61, 0x79, 0x52, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x73, 0x22, 0x1c,
0x0a, 0x0a, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x4a, 0x0a, 0x16,
0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69,
0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70,
0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70, 0x69,
0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x49, 0x0a, 0x15, 0x50, 0x69, 0x70, 0x65,
0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70,
0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e,
0x65, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x14, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x53,
0x74, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70,
0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49,
0x44, 0x52, 0x0a, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x4a, 0x0a,
0x16, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x70, 0x69, 0x70, 0x65, 0x6c,
0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x70,
0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x32, 0xd0, 0x02, 0x0a, 0x0f, 0x50, 0x69,
0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3e, 0x0a,
0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12,
0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x1d,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x72, 0x65,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a,
0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12,
0x14, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x73, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65,
0x6c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x3c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x69, 0x70, 0x65, 0x6c,
0x69, 0x6e, 0x65, 0x12, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69,
0x6e, 0x65, 0x49, 0x44, 0x1a, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c,
0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x3a, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x70, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x12, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49,
0x44, 0x1a, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65,
0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0e,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x0f,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x1a,
0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74,
0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0e, 0x44, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x0f, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x1a, 0x1b, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f,
0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x07, 0x5a, 0x05,
0x2e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -935,7 +935,7 @@ var file_api_api_proto_goTypes = []interface{}{
nil, // 12: api.ExtraOverlay.PropertiesEntry
}
var file_api_api_proto_depIdxs = []int32{
1, // 0: api.Pipeline.overlay:type_name -> api.Overlay
1, // 0: api.Pipeline.overlays:type_name -> api.Overlay
2, // 1: api.Overlay.extra:type_name -> api.ExtraOverlay
4, // 2: api.Overlay.text_overlay:type_name -> api.TextOverlay
3, // 3: api.Overlay.image_overlay:type_name -> api.ImageOverlay

View File

@ -9,7 +9,7 @@ message Pipeline {
string name = 1;
string clip = 2;
string output = 3;
repeated Overlay overlay = 4;
repeated Overlay overlays = 4;
}
message Overlay {

View File

@ -1,6 +1,7 @@
package gstreamer
import (
"context"
"errors"
"github.com/tinyzimmer/go-glib/glib"
"github.com/tinyzimmer/go-gst/gst"
@ -10,22 +11,37 @@ var gstreamer *Gstreamer
func Init() *Gstreamer {
gst.Init(nil)
glib.NewMainLoop(glib.MainContextDefault(), true)
gstreamer = &Gstreamer{}
mainLoop := glib.NewMainLoop(glib.MainContextDefault(), false)
go mainLoop.Run()
decklink := &Decklink{
Slots: map[string]string{"one": ""},
}
gstreamer = &Gstreamer{
ctx: context.Background(),
Pipelines: map[string]*Pipeline{},
Decklink: decklink,
}
return gstreamer
}
func (g *Gstreamer) DeletePipeline(id string) {
g.Lock()
if pipeline, err := g.GetPipeline(id); err == nil {
defer g.Unlock()
if pipeline, err := g.getPipeline(id); err == nil {
delete(g.Pipelines, id)
pipeline.ctxCancel()
}
g.Unlock()
return
}
func (g *Gstreamer) GetPipeline(id string) (*Pipeline, error) {
g.RLock()
defer g.RUnlock()
return g.getPipeline(id)
}
//only use this if ressource is locked
func (g *Gstreamer) getPipeline(id string) (*Pipeline, error) {
if pipeline, ok := g.Pipelines[id]; ok {
return pipeline, nil
}

View File

@ -7,6 +7,7 @@ import (
)
func (i *InputElement) create(pipeline *gst.Pipeline, log zerolog.Logger) error {
elements := map[string]element{}
e, err := gst.NewElementWithName(i.Type, i.Name)
if err != nil {
@ -26,23 +27,28 @@ func (i *InputElement) create(pipeline *gst.Pipeline, log zerolog.Logger) error
// ====================
//====================
// DECODEBIN
e, err = gst.NewElementWithName("decodebin", fmt.Sprintf("%s-decodebin", i.Name))
// RAWVIDEOPARSE
e, err = gst.NewElementWithName("rawvideoparse", fmt.Sprintf("%s-rawvideoparse", i.Name))
if err != nil {
log.Error().Msgf("could not create decodebin for %s: %v\n", i.Name, err)
return fmt.Errorf("could not create decodebin for %s", i.Name)
log.Error().Msgf("could not create rawvideoparse for %s: %v\n", i.Name, err)
return fmt.Errorf("could not create rawvideoparse for %s", i.Name)
}
setPropertyWrapper(e, "format", "bgra")
setPropertyWrapper(e, "width", 1280)
setPropertyWrapper(e, "height", 720)
setPropertyWrapper(e, "framerate", "50")
err = pipeline.Add(e)
if err != nil {
log.Error().Msgf("could not add decodebin for %s to pipeline: %v\n", i.Name, err)
return fmt.Errorf("could not add decodebin for %s to pipeline", i.Name)
log.Error().Msgf("could not add rawvideoparse for %s to pipeline: %v\n", i.Name, err)
return fmt.Errorf("could not add rawvideoparse for %s to pipeline", i.Name)
}
decodebin := element{element: e, name: fmt.Sprintf("%s-decodebin", i.Name), prev: i.Name, next: fmt.Sprintf("%s-videoconvert", i.Name)}
elements[fmt.Sprintf("%s-decodebin", i.Name)] = decodebin
err = input.linkElementWrapper(&decodebin, log)
rawvideoparse := element{element: e, name: fmt.Sprintf("%s-rawvideoparse", i.Name), prev: i.Name, next: fmt.Sprintf("%s-videoconvert", i.Name)}
elements[fmt.Sprintf("%s-rawvideoparse", i.Name)] = rawvideoparse
err = input.linkElementWrapper(&rawvideoparse, log)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", i.Name, fmt.Sprintf("%s-decodebin", i.Name), err)
return fmt.Errorf("could not link %s to %s", i.Name, fmt.Sprintf("%s-decodebin", i.Name))
log.Error().Msgf("could not link %s to %s: %v", fmt.Sprintf("%s-rawvideoparse", i.Name), i.Name, err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-rawvideoparse", i.Name), i.Name)
}
//====================
@ -58,12 +64,12 @@ func (i *InputElement) create(pipeline *gst.Pipeline, log zerolog.Logger) error
log.Error().Msgf("could not add videoconvert for %s to pipeline: %v\n", i.Name, err)
return fmt.Errorf("could not add videoconvert for %s to pipeline", i.Name)
}
videoconvert := element{element: e, name: fmt.Sprintf("%s-videoconvert", i.Name), prev: fmt.Sprintf("%s-decodebin", i.Name), next: fmt.Sprintf("%s-videoscale", i.Name)}
videoconvert := element{element: e, name: fmt.Sprintf("%s-videoconvert", i.Name), prev: fmt.Sprintf("%s-rawvideoparse", i.Name), next: fmt.Sprintf("%s-videoscale", i.Name)}
elements[fmt.Sprintf("%s-videoconvert", i.Name)] = videoconvert
err = input.linkElementWrapper(&videoconvert, log)
err = rawvideoparse.linkElementWrapper(&videoconvert, log)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", i.Name, fmt.Sprintf("%s-videoconvert", i.Name), err)
return fmt.Errorf("could not link %s to %s", i.Name, fmt.Sprintf("%s-videoconvert", i.Name))
log.Error().Msgf("could not link %s to %s: %v\n", fmt.Sprintf("%s-videoconvert", i.Name), fmt.Sprintf("%s-decodebin", i.Name), err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videoconvert", i.Name), fmt.Sprintf("%s-decodebin", i.Name))
}
//=====================

View File

@ -23,8 +23,8 @@ func (o *OutputElement) create(pipeline *gst.Pipeline, lastElement *element, log
elements[fmt.Sprintf("%s-videoconvert", o.Name)] = videoconvert
err = lastElement.linkElementWrapper(&videoconvert, log)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", o.Name, fmt.Sprintf("%s-videoconvert", o.Name), err)
return fmt.Errorf("could not link %s to %s", o.Name, fmt.Sprintf("%s-videoconvert", o.Name))
log.Error().Msgf("could not link %s to %s: %v\n", fmt.Sprintf("%s-videoconvert", o.Name), lastElement.name, err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videoconvert", o.Name), lastElement.name)
}
e, err = gst.NewElementWithName("videoscale", fmt.Sprintf("%s-videoscale", o.Name))
@ -41,8 +41,8 @@ func (o *OutputElement) create(pipeline *gst.Pipeline, lastElement *element, log
elements[fmt.Sprintf("%s-videoscale", o.Name)] = videoscale
err = videoconvert.linkElementWrapper(&videoscale, log)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", fmt.Sprintf("%s-videoconvert", o.Name), fmt.Sprintf("%s-videoscale", o.Name), err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videoconvert", o.Name), fmt.Sprintf("%s-videoscale", o.Name))
log.Error().Msgf("could not link %s to %s: %v\n", fmt.Sprintf("%s-videoscale", o.Name), fmt.Sprintf("%s-videoconvert", o.Name), err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videoscale", o.Name), fmt.Sprintf("%s-videoconvert", o.Name))
}
e, err = gst.NewElementWithName("videorate", fmt.Sprintf("%s-videorate", o.Name))
@ -59,8 +59,8 @@ func (o *OutputElement) create(pipeline *gst.Pipeline, lastElement *element, log
elements[fmt.Sprintf("%s-videorate", o.Name)] = videorate
err = videoscale.linkElementWrapper(&videorate, log)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", fmt.Sprintf("%s-videoscale", o.Name), fmt.Sprintf("%s-videorate", o.Name), err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videoscale", o.Name), fmt.Sprintf("%s-videorate", o.Name))
log.Error().Msgf("could not link %s to %s: %v\n", fmt.Sprintf("%s-videorate", o.Name), fmt.Sprintf("%s-videoscale", o.Name), err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videorate", o.Name), fmt.Sprintf("%s-videoscale", o.Name))
}
e, err = gst.NewElementWithName(o.Type, o.Name)
@ -78,6 +78,11 @@ func (o *OutputElement) create(pipeline *gst.Pipeline, lastElement *element, log
}
output := element{element: e, name: o.Name, prev: fmt.Sprintf("%s-videoscale", o.Name)}
elements[o.Name] = output
err = videorate.linkElementWrapper(&output, log)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", o.Name, fmt.Sprintf("%s-videorate", o.Name), err)
return fmt.Errorf("could not link %s to %s", fmt.Sprintf("%s-videoscale", o.Name), fmt.Sprintf("%s-videorate", o.Name))
}
o.elements = elements

View File

@ -11,14 +11,17 @@ import (
func (p *Pipeline) Create() (chan PipelineUpdates, error) {
gstreamerLogger := log.With().Str("Component", "gstreamer").Str("Pipeline", p.Name).Logger()
gstreamerLogger.Info().Msg("Creating pipeline")
p.logger = gstreamerLogger
pipeline, err := gst.NewPipeline(p.Name)
if err != nil {
return nil, err
}
p.pipeline = pipeline
elements := map[string]element{}
gstreamerLogger.Debug().Msg("Creating input")
err = p.InputElement.create(pipeline, gstreamerLogger)
if err != nil {
return nil, err
@ -35,10 +38,20 @@ func (p *Pipeline) Create() (chan PipelineUpdates, error) {
element: overlayElement,
name: overlay.getName(),
}
lastElement.linkElementWrapper(e, gstreamerLogger)
err = pipeline.Add(overlayElement)
if err != nil {
log.Error().Msgf("could not add %s to pipeline: %v", overlay.getName(), err)
return nil, err
}
err = lastElement.linkElementWrapper(e, gstreamerLogger)
if err != nil {
log.Error().Msgf("could not link %s to %s: %v", overlay.getName(), lastElement.name, err)
return nil, err
}
lastElement = e
elements[overlay.getName()] = *lastElement
}
gstreamerLogger.Debug().Msg("Creating output")
err = p.OutputElement.create(pipeline, lastElement, gstreamerLogger)
if err != nil {
return nil, err
@ -46,19 +59,22 @@ func (p *Pipeline) Create() (chan PipelineUpdates, error) {
for name, e := range p.OutputElement.elements {
elements[name] = e
}
p.elements = elements
pipeline.GetPipelineBus().AddWatch(func(msg *gst.Message) bool {
switch msg.Type() {
case gst.MessageEOS: // When end-of-stream is received flush the pipeline and stop the main loop
p.logger.Debug().Msg("EOS received")
pipeline.BlockSetState(gst.StateNull)
case gst.MessageError: // Error messages are always fatal
err := msg.ParseError()
gstreamerLogger.Error().Msg(err.Error())
p.logger.Error().Msg(err.Error())
if debug := err.DebugString(); debug != "" {
gstreamerLogger.Debug().Msg(debug)
p.logger.Debug().Msg(debug)
}
pipeline.BlockSetState(gst.StateNull)
case gst.MessageStreamStart:
gstreamerLogger.Info().Msgf("STARTING Playout of %s", p.Name)
p.logger.Info().Msgf("STARTING Playout of %s", p.Name)
clock := pipeline.GetPipelineClock()
now := clock.GetTime()
for _, overlay := range p.Overlays {
@ -69,17 +85,6 @@ func (p *Pipeline) Create() (chan PipelineUpdates, error) {
clock.NewSingleShotID(now + overlay.getBlendOutTime()).WaitAsync(overlay.hide())
}
}
case gst.MessageStateChanged:
_, newState := msg.ParseStateChanged()
if newState == gst.StatePlaying && msg.Source() == p.Name {
gstreamerLogger.Debug().Msgf("Pipeline %s started", p.Name)
p.resizeAllTextOverlays(gstreamerLogger)
}
default:
// All messages implement a Stringer. However, this is
// typically an expensive thing to do and should be avoided.
gstreamerLogger.Debug().Msgf(msg.String())
}
return true
})
@ -97,9 +102,9 @@ func (p *Pipeline) Create() (chan PipelineUpdates, error) {
//TODO check if output is decklink
func (p *Pipeline) Start() error {
output, err := gstreamer.getDecklinkOutput(p.Name)
setPropertyWrapper(p.elements[p.OutputElement.Name].element, "device-number", output)
err = p.pipeline.SetState(gst.StatePlaying)
//output, err := gstreamer.getDecklinkOutput(p.Name)
//setPropertyWrapper(p.elements[p.OutputElement.Name].element, "device-number", output)
err := p.pipeline.SetState(gst.StatePlaying)
if err != nil {
p.logger.Error().Msgf("Failed to set pipeline %s to playing: %v", p.Name, err)
return fmt.Errorf("Failed to set pipeline %s to playing: %v", p.Name, err)
@ -116,10 +121,10 @@ func (p *Pipeline) Stop() error {
return nil
}
func (p *Pipeline) resizeAllTextOverlays(log zerolog.Logger) {
func (p *Pipeline) resizeAllTextOverlays() {
for _, overlay := range p.Overlays {
if x, ok := overlay.(*TextOverlay); ok {
go x.resizeTextOverlay(log)
go x.resizeTextOverlay(p.logger)
}
}
}

View File

@ -12,6 +12,7 @@ type Gstreamer struct {
Pipelines map[string]*Pipeline
*Decklink
ctx context.Context
sync.RWMutex
}
type Pipeline struct {

View File

@ -32,14 +32,16 @@ func (element1 *element) linkElementWrapper(element2 *element, log zerolog.Logge
}
}
if len(caps) > 0 {
log.Debug().Msgf("Linking %s to %s with caps %s", element1.name, element2.name, caps)
capabilities := gst.NewCapsFromString(caps)
err = element1.element.LinkFiltered(element2.element, capabilities)
} else {
err = element1.element.Link(element2.element)
}
if err != nil {
log.Error().Msgf("could not link %s to %s: %v\n", element2.name, element1.name, err)
return fmt.Errorf("could not link %s to %s", element2.name, element1.name)
log.Error().Msgf("could not link %s to %s: %v", element1.name, element2.name, err)
return err
}
element1.next, element2.prev = element2.name, element1.name

19
main.go
View File

@ -9,6 +9,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"net"
"os"
"time"
@ -16,7 +17,7 @@ import (
type Config struct {
Outputs []string `yaml:"outputs"`
Address string `yaml:"address" env:"ADDRESS" env-default:":3000"`
Address string `yaml:"address" env:"ADDRESS" env-default:"localhost:3000"`
LogFile string `yaml:"logfile" env:"LOGFILE" env-default:"./gstreamer-graphix.log"`
}
@ -28,19 +29,24 @@ func main() {
log.Logger = log.Output(consoleWriter).With().Timestamp().Caller().Logger()
if err := cleanenv.ReadConfig("config.toml", &cfg); err != nil {
log.Fatal().Msgf("No configfile: ", err)
log.Info().Msgf("No configfile, continuing without: ", err)
}
fset := flag.NewFlagSet("config", flag.ContinueOnError)
fset.Usage = cleanenv.FUsage(fset.Output(), &cfg, nil, fset.Usage)
fset.Parse(os.Args[1:])
l, err := os.OpenFile(cfg.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0664)
multi := zerolog.MultiLevelWriter(consoleWriter, l)
log.Logger = zerolog.New(multi).With().Timestamp().Caller().Logger()
if cfg.LogFile != "" {
l, _ := os.OpenFile(cfg.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0664)
multi := zerolog.MultiLevelWriter(consoleWriter, l)
log.Logger = zerolog.New(multi).With().Timestamp().Caller().Logger()
}
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
if log.Logger.GetLevel() == zerolog.DebugLevel {
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
}
log.Info().Msgf("listening on %s", cfg.Address)
ln, err := net.Listen("tcp", cfg.Address)
if err != nil {
log.Fatal().Err(err)
@ -51,6 +57,7 @@ func main() {
pipelineService := &api.PipelineService{Gstreamer: gst}
g := grpc.NewServer()
reflection.Register(g)
api.RegisterPipelineServiceServer(g, pipelineService)
log.Fatal().Msgf("Failed to serve: %v", g.Serve(ln))