// Send video!!!!
// SimpleSendVideo just send a video from file path or id
424011
func (bot TgBot) SimpleSendVideo(msg Message, photo string) (res Message, err error) {
	cid := msg.Chat.ID
	var payload interface{} = SendVideoIDQuery{cid, photo, nil, nil, nil, nil}
	if looksLikePath(photo) {
		payload = SendVideoPathQuery{cid, photo, nil, nil, nil, nil}
	}
	ressm := bot.SendVideoQuery(payload)
	return splitResultInMessageError(ressm)
}
244659
func (bot TgBot) SendVideoWithKeyboardHide(cid int, photo string, caption *string, duration *int, rmi *int, rm ReplyKeyboardHide) ResultWithMessage {
	var rkm ReplyMarkupInt = rm
	return bot.SendVideo(cid, photo, caption, duration, rmi, &rkm)
}
1044180
func (r *readdcw) send(es []*event) {
	for _, e := range es {
		var syse Event
		if e.e, syse = decode(e.filter, e.action); e.e == 0 && syse == 0 {
			continue
		}
		switch {
		case e.action == syscall.FILE_ACTION_MODIFIED:
			e.ftype = fTypeUnknown
		case e.filter&uint32(dirmarker) != 0:
			e.ftype = fTypeDirectory
		default:
			e.ftype = fTypeFile
		}
		switch {
		case e.e == 0:
			e.e = syse
		case syse != 0:
			r.c <- &event{
				pathw:  e.pathw,
				name:   e.name,
				ftype:  e.ftype,
				action: e.action,
				filter: e.filter,
				e:      syse,
			}
		}
		r.c <- e
	}
}
1028267
func (s *Send) Video(vid string) *SendVideo {
	return &SendVideo{s, vid, nil, nil, nil, nil}
}
551836
func (net *Network) DidSend(sender, receiver enode.ID, proto string, code uint64) error {
	msg := &Msg{
		One:      sender,
		Other:    receiver,
		Protocol: proto,
		Code:     code,
		Received: false,
	}
	net.events.Send(NewEvent(msg))
	return nil
}
127322
func (s *StreamFramer) Send(file, fileEvent string, data []byte, offset int64) error {
	s.l.Lock()
	defer s.l.Unlock()
	// If we are not running, return the error that caused us to not run or
	// indicated that it was never started.
	if !s.running {
		return fmt.Errorf("StreamFramer not running")
	}

	// Check if not mergeable
	if !s.f.IsCleared() && (s.f.File != file || s.f.FileEvent != fileEvent) {
		// Flush the old frame
		s.send()
	}

	// Store the new data as the current frame.
	if s.f.IsCleared() {
		s.f.Offset = offset
		s.f.File = file
		s.f.FileEvent = fileEvent
	}

	// Write the data to the buffer
	s.data.Write(data)

	// Handle the delete case in which there is no data
	force := s.data.Len() == 0 && s.f.FileEvent != ""

	// Flush till we are under the max frame size
	for s.data.Len() >= s.frameSize || force {
		// Clear since are flushing the frame and capturing the file event.
		// Subsequent data frames will be flushed based on the data size alone
		// since they share the same fileevent.
		if force {
			force = false
		}

		// Ensure s.out has not already been closed by Destroy
		select {
		case <-s.exitCh:
			return nil
		default:
		}

		// Create a new frame to send it
		s.f.Data = s.readData()
		select {
		case s.out <- s.f.Copy():
		case <-s.exitCh:
			return nil
		}

		// Update the offset
		s.f.Offset += int64(len(s.f.Data))
	}

	return nil
}
941964
func (material *Material) AddVideo(filename, title, introduction string) (mediaID string, url string, err error) {
	var accessToken string
	accessToken, err = material.GetAccessToken()
	if err != nil {
		return
	}

	uri := fmt.Sprintf("%s?access_token=%s&type=video", addMaterialURL, accessToken)

	videoDesc := &reqVideo{
		Title:        title,
		Introduction: introduction,
	}
	var fieldValue []byte
	fieldValue, err = json.Marshal(videoDesc)
	if err != nil {
		return
	}

	fields := []util.MultipartFormField{
		{
			IsFile:    true,
			Fieldname: "video",
			Filename:  filename,
		},
		{
			IsFile:    true,
			Fieldname: "description",
			Value:     fieldValue,
		},
	}

	var response []byte
	response, err = util.PostMultipartForm(fields, uri)
	if err != nil {
		return
	}

	var resMaterial resAddMaterial
	err = json.Unmarshal(response, &resMaterial)
	if err != nil {
		return
	}
	if resMaterial.ErrCode != 0 {
		err = fmt.Errorf("AddMaterial error : errcode=%v , errmsg=%v", resMaterial.ErrCode, resMaterial.ErrMsg)
		return
	}
	mediaID = resMaterial.MediaID
	url = resMaterial.URL
	return
}
964958
func GetVideoInfo(value interface{}) (*VideoInfo, error) {
	switch t := value.(type) {
	case *url.URL:
		return GetVideoInfoFromURL(t)
	case string:
		u, err := url.ParseRequestURI(t)
		if err != nil {
			return GetVideoInfoFromID(t)
		}
		if u.Host == "youtu.be" {
			return GetVideoInfoFromShortURL(u)
		}
		return GetVideoInfoFromURL(u)
	default:
		return nil, fmt.Errorf("Identifier type must be a string, *url.URL, or []byte")
	}
}
1331551
func sendToLibhoney(ctx context.Context, toBeSent chan event.Event, toBeResent chan event.Event,
	delaySending chan int, doneSending chan bool) {
	for {
		// check and see if we need to back off the API because of rate limiting
		select {
		case delay := <-delaySending:
			time.Sleep(time.Duration(delay) * time.Millisecond)
		default:
		}
		// if we have events to retransmit, send those first
		select {
		case ev := <-toBeResent:
			// retransmitted events have already been sampled; always use
			// SendPresampled() for these
			sendEvent(ev)
			continue
		default:
		}
		// otherwise pick something up off the regular queue and send it
		select {
		case ev, ok := <-toBeSent:
			if !ok {
				// channel is closed
				// NOTE: any unrtransmitted retransmittable events will be dropped
				doneSending <- true
				return
			}
			sendEvent(ev)
			continue
		default:
		}
		// no events at all? chill for a sec until we get the next one
		time.Sleep(100 * time.Millisecond)
	}
}
1249275
func (bot TgBot) SimpleSendAudio(msg Message, audio string) (res Message, err error) {
	cid := msg.Chat.ID
	var payload interface{} = SendAudioIDQuery{cid, audio, nil, nil, nil, nil, nil}
	if looksLikePath(audio) {
		payload = SendAudioPathQuery{cid, audio, nil, nil, nil, nil, nil}
	}
	ressm := bot.SendAudioQuery(payload)
	return splitResultInMessageError(ressm)
}
534488
func (a *Driver) VideoStreamMode(mode int8) error {
	return a.adaptor().drone.VideoStreamMode(mode)
}
796605
func (client Client) Send(records []logfwd.Record) error {
	for _, rec := range records {
		msg, err := messageFromRecord(rec)
		if err != nil {
			return errors.Trace(err)
		}
		if err := client.Sender.Send(msg); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
1324533
func (c *Client) sendDroppedResponse(e *Event, message string) {
	c.ensureTransmission()
	r := transmission.Response{
		Err:      errors.New(message),
		Metadata: e.Metadata,
	}
	c.transmission.SendResponse(r)

}
298048
func (s *sender) trySend() {
	for s.pLink.Credit() > 0 && len(s.sending) > 0 {
		sm := s.sending[0]
		s.sending = s.sending[1:]
		s.send(sm)
	}
}
1147886
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
	return InlineQueryResultVideo{
		Type: "video",
		ID:   id,
		URL:  url,
	}
}
331762
func NewVideoUpload(chatID int64, file interface{}) VideoConfig {
	return VideoConfig{
		BaseFile: BaseFile{
			BaseChat:    BaseChat{ChatID: chatID},
			File:        file,
			UseExisting: false,
		},
	}
}
271220
func (this *Response) Sendfile(filename string, opt ...interface{}) {
	http.ServeFile(this.Writer, this.req.Request.Request, filename)
}