// NewVideoExtractor returns a new instance of a HTML video extractor
163552
func NewVideoExtractor() VideoExtractor {
	return VideoExtractor{
		candidates: set.New(set.ThreadSafe).(*set.Set),
		movies:     set.New(set.ThreadSafe).(*set.Set),
	}
}
885270
func NewRegexpFilter(name, regexp string) RegexpFilter {
	return RegexpFilter{name: name, regexp: regexp}
}
163467
func NewDecoder(r io.ReadCloser, codec runtime.Codec) *Decoder {
	return &Decoder{
		r:       r,
		decoder: json.NewDecoder(r),
		codec:   codec,
	}
}
1124030
func (j *JSONBuiltin) NewDecoder(r io.Reader) Decoder {
	return json.NewDecoder(r)
}
931575
func (ve *VideoExtractor) GetVideos(doc *goquery.Document) *set.Set {
	var nodes *goquery.Selection
	for _, videoTag := range videoTags {
		tmpNodes := doc.Find(videoTag)
		if nodes == nil {
			nodes = tmpNodes
		} else {
			nodes.Union(tmpNodes)
		}
	}

	nodes.Each(func(i int, node *goquery.Selection) {
		tag := node.Get(0).DataAtom.String()
		var movie video
		switch tag {
		case "video":
			movie = ve.getVideoTag(node)
		case "embed":
			movie = ve.getEmbedTag(node)
		case "object":
			movie = ve.getObjectTag(node)
		case "iframe":
			movie = ve.getIFrame(node)
		}

		if movie.src != "" {
			ve.movies.Add(movie)
		}
	})

	return ve.movies
}
862177
func newExtensionHandler(params []byte, pers protocol.Perspective) tlsExtensionHandler {
	return &extensionHandler{
		ourParams:   params,
		paramsChan:  make(chan []byte),
		perspective: pers,
	}
}
179922
func NewAutoEscapeExtension() *AutoEscapeExtension {
	return &AutoEscapeExtension{
		Escapers: map[string]Escaper{
			"html":      escape.HTML,
			"html_attr": escape.HTMLAttribute,
			"js":        escape.JS,
			"css":       escape.CSS,
			"url":       escape.URLQueryParam,
		},
	}
}
1250617
func NewDecoder(s encoding.Source) encoding.Decoder {
	r := s()
	dec := framing.NewDecoder(r, json.Unmarshal)
	return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) })
}
64294
func New(uri string) (*MetaInspector, error) {
	if uri == "" {
		return nil, errors.New("Url is empty!")
	}

	u, err := url.Parse(uri)
	if err != nil {
		return nil, err
	}

	scraper, err := newScraper(fixURL(u), 20)
	if err != nil {
		return nil, err
	}

	return &MetaInspector{uri,
		u.Scheme,
		u.Host,
		root(u),
		scraper.title,
		scraper.language,
		scraper.author,
		scraper.description,
		scraper.generator,
		scraper.feed,
		scraper.charset,
		scraper.links,
		scraper.images,
		scraper.keywords,
		scraper.compatibility}, nil
}
1328114
func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{} {
	if ext, ok := req.(requestFieldsExtractor); ok {
		retMap := make(map[string]interface{})
		ext.ExtractRequestFields(retMap)
		if len(retMap) == 0 {
			return nil
		}
		return retMap
	}
	return nil
}
442988
func NewBindingInspector(mutualTLS bool, extractTLSCertHash CertHashExtractor) BindingInspector {
	if extractTLSCertHash == nil {
		panic(errors.New("extractTLSCertHash parameter is nil"))
	}
	inspectMessage := mutualTLSBinding
	if !mutualTLS {
		inspectMessage = noopBinding
	}
	return func(ctx context.Context, msg proto.Message) error {
		if msg == nil {
			return errors.New("message is nil")
		}
		return inspectMessage(ctx, extractTLSCertHash(msg))
	}
}
1348418
func NewExtractor(path string) (*Extractor, error) {
	model := C.CString(path)
	defer C.free(unsafe.Pointer(model))
	ner := C.mitie_load_named_entity_extractor(model)
	if ner == nil {
		return nil, ErrCantOpen
	}

	return &Extractor{
		ner: ner,
	}, nil
}
1299591
func (s *InputTemplate) SetVideoSelector(v *VideoSelector) *InputTemplate {
	s.VideoSelector = v
	return s
}
220962
func NewGenerator(fn string) (_ *Generator, err error) {
	avfCtx := C.avformat_alloc_context()
	cfn := C.CString(fn)
	defer C.free(unsafe.Pointer(cfn))
	if C.avformat_open_input(&avfCtx, cfn, nil, nil) != 0 {
		return nil, errors.New("can't open input stream")
	}
	defer func() {
		if err != nil {
			C.avformat_close_input(&avfCtx)
		}
	}()
	if C.avformat_find_stream_info(avfCtx, nil) < 0 {
		return nil, errors.New("can't get stream info")
	}
	duration := int64(avfCtx.duration) / 1000
	bitrate := int(avfCtx.bit_rate) / 1000
	numberOfStreams := int(avfCtx.nb_streams)
	hdr := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(avfCtx.streams)),
		Len:  numberOfStreams,
		Cap:  numberOfStreams,
	}
	streams := *(*[]*C.struct_AVStream)(unsafe.Pointer(&hdr))
	vStreamIndex := -1
	aStreamIndex := -1
	for i := 0; i < numberOfStreams; i++ {
		if streams[i].codec.codec_type == C.AVMEDIA_TYPE_VIDEO {
			vStreamIndex = i
		} else if streams[i].codec.codec_type == C.AVMEDIA_TYPE_AUDIO {
			aStreamIndex = i
		}
	}
	if vStreamIndex == -1 {
		return nil, errors.New("no video stream")
	}
	avcCtx := streams[vStreamIndex].codec
	vCodec := C.avcodec_find_decoder(avcCtx.codec_id)
	if vCodec == nil {
		return nil, errors.New("can't find decoder")
	}
	if C.avcodec_open2(avcCtx, vCodec, nil) != 0 {
		return nil, errors.New("can't initialize codec context")
	}
	width := int(avcCtx.width)
	height := int(avcCtx.height)
	fps := (float64(streams[vStreamIndex].avg_frame_rate.num) /
		float64(streams[vStreamIndex].avg_frame_rate.den))
	vCodecName := strings.ToUpper(C.GoString(vCodec.name))
	vCodecHuman := C.GoString(vCodec.long_name)

	aCodecName := ""
	aCodecHuman := ""
	if aStreamIndex != -1 {
		aacCtx := streams[aStreamIndex].codec
		aCodec := C.avcodec_find_decoder(aacCtx.codec_id)
		if aCodec != nil {
			aCodecName = strings.ToUpper(C.GoString(aCodec.name))
			aCodecHuman = C.GoString(aCodec.long_name)
		}
	}

	return &Generator{
		Filename:           fn,
		width:              width,
		height:             height,
		Duration:           duration,
		VideoCodec:         vCodecName,
		VideoCodecLongName: vCodecHuman,
		AudioCodec:         aCodecName,
		AudioCodecLongName: aCodecHuman,
		numberOfStreams:    numberOfStreams,
		vStreamIndex:       vStreamIndex,
		aStreamIndex:       aStreamIndex,
		FPS:                fps,
		Bitrate:            bitrate,
		streams:            streams,
		avfContext:         avfCtx,
		avcContext:         avcCtx,
	}, nil
}
132225
func (cfg *Config) NewDecoder(r io.Reader) *Decoder {
	return &Decoder{r, cfg}
}
1247942
func newDecoder(in io.Reader, order binary.ByteOrder) *decoder {
	dec := new(decoder)
	dec.in = in
	dec.order = order
	return dec
}
283721
func NewVideoNoteShare(chatID int64, length int, fileID string) VideoNoteConfig {
	return VideoNoteConfig{
		BaseFile: BaseFile{
			BaseChat:    BaseChat{ChatID: chatID},
			FileID:      fileID,
			UseExisting: true,
		},
		Length: length,
	}
}