// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// GroupCallParticipantVideo represents TL type `groupCallParticipantVideo#67753ac8`.
// Info about a video stream
//
// See https://core.telegram.org/constructor/groupCallParticipantVideo for reference.
type GroupCallParticipantVideo struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the stream is currently paused
	Paused bool
	// Endpoint
	Endpoint string
	// Source groups
	SourceGroups []GroupCallParticipantVideoSourceGroup
	// Audio source ID
	//
	// Use SetAudioSource and GetAudioSource helpers.
	AudioSource int
}

// GroupCallParticipantVideoTypeID is TL type id of GroupCallParticipantVideo.
const GroupCallParticipantVideoTypeID = 0x67753ac8

// Ensuring interfaces in compile-time for GroupCallParticipantVideo.
var (
	_ bin.Encoder     = &GroupCallParticipantVideo{}
	_ bin.Decoder     = &GroupCallParticipantVideo{}
	_ bin.BareEncoder = &GroupCallParticipantVideo{}
	_ bin.BareDecoder = &GroupCallParticipantVideo{}
)

func ( *GroupCallParticipantVideo) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Paused == false) {
		return false
	}
	if !(.Endpoint == "") {
		return false
	}
	if !(.SourceGroups == nil) {
		return false
	}
	if !(.AudioSource == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *GroupCallParticipantVideo) () string {
	if  == nil {
		return "GroupCallParticipantVideo(nil)"
	}
	type  GroupCallParticipantVideo
	return fmt.Sprintf("GroupCallParticipantVideo%+v", (*))
}

// FillFrom fills GroupCallParticipantVideo from given interface.
func ( *GroupCallParticipantVideo) ( interface {
	() ( bool)
	() ( string)
	() ( []GroupCallParticipantVideoSourceGroup)
	() ( int,  bool)
}) {
	.Paused = .()
	.Endpoint = .()
	.SourceGroups = .()
	if ,  := .();  {
		.AudioSource = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GroupCallParticipantVideo) () uint32 {
	return GroupCallParticipantVideoTypeID
}

// TypeName returns name of type in TL schema.
func (*GroupCallParticipantVideo) () string {
	return "groupCallParticipantVideo"
}

// TypeInfo returns info about TL type.
func ( *GroupCallParticipantVideo) () tdp.Type {
	 := tdp.Type{
		Name: "groupCallParticipantVideo",
		ID:   GroupCallParticipantVideoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Paused",
			SchemaName: "paused",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Endpoint",
			SchemaName: "endpoint",
		},
		{
			Name:       "SourceGroups",
			SchemaName: "source_groups",
		},
		{
			Name:       "AudioSource",
			SchemaName: "audio_source",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *GroupCallParticipantVideo) () {
	if !(.Paused == false) {
		.Flags.Set(0)
	}
	if !(.AudioSource == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *GroupCallParticipantVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode groupCallParticipantVideo#67753ac8 as nil")
	}
	.PutID(GroupCallParticipantVideoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *GroupCallParticipantVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode groupCallParticipantVideo#67753ac8 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode groupCallParticipantVideo#67753ac8: field flags: %w", )
	}
	.PutString(.Endpoint)
	.PutVectorHeader(len(.SourceGroups))
	for ,  := range .SourceGroups {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode groupCallParticipantVideo#67753ac8: field source_groups element with index %d: %w", , )
		}
	}
	if .Flags.Has(1) {
		.PutInt(.AudioSource)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *GroupCallParticipantVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode groupCallParticipantVideo#67753ac8 to nil")
	}
	if  := .ConsumeID(GroupCallParticipantVideoTypeID);  != nil {
		return fmt.Errorf("unable to decode groupCallParticipantVideo#67753ac8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *GroupCallParticipantVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode groupCallParticipantVideo#67753ac8 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode groupCallParticipantVideo#67753ac8: field flags: %w", )
		}
	}
	.Paused = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode groupCallParticipantVideo#67753ac8: field endpoint: %w", )
		}
		.Endpoint = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode groupCallParticipantVideo#67753ac8: field source_groups: %w", )
		}

		if  > 0 {
			.SourceGroups = make([]GroupCallParticipantVideoSourceGroup, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  GroupCallParticipantVideoSourceGroup
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode groupCallParticipantVideo#67753ac8: field source_groups: %w", )
			}
			.SourceGroups = append(.SourceGroups, )
		}
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode groupCallParticipantVideo#67753ac8: field audio_source: %w", )
		}
		.AudioSource = 
	}
	return nil
}

// SetPaused sets value of Paused conditional field.
func ( *GroupCallParticipantVideo) ( bool) {
	if  {
		.Flags.Set(0)
		.Paused = true
	} else {
		.Flags.Unset(0)
		.Paused = false
	}
}

// GetPaused returns value of Paused conditional field.
func ( *GroupCallParticipantVideo) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetEndpoint returns value of Endpoint field.
func ( *GroupCallParticipantVideo) () ( string) {
	if  == nil {
		return
	}
	return .Endpoint
}

// GetSourceGroups returns value of SourceGroups field.
func ( *GroupCallParticipantVideo) () ( []GroupCallParticipantVideoSourceGroup) {
	if  == nil {
		return
	}
	return .SourceGroups
}

// SetAudioSource sets value of AudioSource conditional field.
func ( *GroupCallParticipantVideo) ( int) {
	.Flags.Set(1)
	.AudioSource = 
}

// GetAudioSource returns value of AudioSource conditional field and
// boolean which is true if field was set.
func ( *GroupCallParticipantVideo) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .AudioSource, true
}