Sends a video reply.

@param Type\Video $videoMessage

@throws Exception\AlreadySentException
494831
public function sendVideo (Type\Video $videoMessage)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $videoMessage->getType(),
                    ucfirst($videoMessage->getType()) => [
                        'MediaId' => $videoMessage->getMediaID(),
                        'ThumbMediaId' => $videoMessage->getThumbnailID(),
                    ],
                ]
            )
        );
    }
637575
public function sendVideo($openId, $mediaId, $thumbMediaId, $title = null, $description = null)
    {
        return $this->sendCustomMessage([
            'touser' => $openId,
            'msgtype' => 'video',
            'video' => [
                'media_id' => $mediaId,
                'thumb_media_id' => $thumbMediaId,
                'title' => $title,
                'description' => $description
            ]
        ]);
    }
870858
public function reply(Client $client, MessageInterface $msg)
    {
        $this->getStream('client')->send($msg, $client->getId());
        $this->remove($client);
    }
3667
public function setVideoNote($video)
	{
		if (is_string($video)) {
			$this->videoNote = $video;
		} else if (is_resource($video)) {
			$this->addMultipart("video", $video);
			$this->videoNote = "attach://video";
		} else if ($video instanceof InputFile) {
			$this->addMultipart("video", $video->getFile());
			$this->videoNote = "attach://video";
		}
	}
1016457
public function message(string $recipient, $message, array $options = []): SendResponse
    {
        $message = $this->isValidMessage($message);
        $options = $this->isValidOptions($options, $message);

        $request = new SendRequest($this->pageToken, $message, $recipient, $options);
        $response = $this->client->post('me/messages', $request->build());

        return new SendResponse($response);
    }
1236135
protected function sendVideoMsgToXmlString(WxSendVideoMsg $msg)
    {
        $formatStr = <<<XML
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%d</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Video>
<MediaId><![CDATA[%s]]></MediaId>
<Title><![CDATA[%s]]></Title>
<Description><![CDATA[%s]]></Description>
</Video>
</xml>
XML;
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getFromUserName(),
                                        strtotime($msg->getCreateTime()),
                                        $msg->getMsgType(),
                                        $msg->getMediaId(),
                                        $msg->getTitle(),
                                        $msg->getDescription()
                        );

        return $result;
    }
334237
public void unsubscribeFromVideo(String sender) throws IOException {
    JsonObject params = new JsonObject();
    params.addProperty(UNSUBSCRIBEFROMVIDEO_SENDER_PARAM, sender);
    client.sendRequest(UNSUBSCRIBEFROMVIDEO_METHOD, params);
  }
585101
private function sendReply ($reply, array $headers = [])
    {
        if ($this->sent) {
            throw new Exception\AlreadySentException();
        }

        $headers = array_merge(
            [
                'Connection: close',
                'Content-Length: ' . strlen($reply),
            ],
            $headers
        );

        $hasContentType = false;
        foreach ($headers as $headerLine) {
            if (stripos($headerLine, 'Content-Type') !== false) {
                $hasContentType = true;
                break;
            }
        }

        if (!$hasContentType) {
            $headers[] = 'Content-Type: application/xml';
        }
        
        $this->sent = true;
        $this->printReply($reply, $headers);
    }
1018345
public function setVideo(Video $video)
    {
        $this->video= $video;
        $this->setIdVideo($video->getIdVideo());
        return $this;
    }
1099585
public function send(Message $message)
    {
        /* @var AppleMessage $message */
        $buildMessage = $this->buildMessage($message);
        $this->streamSocket->connect();
        $bytesSend = $this->streamSocket->write($buildMessage);
        if (strlen($buildMessage) !== $bytesSend) {
            $this->streamSocket->disconnect();
            throw new ConnectionExceptionImpl();
        }
        usleep(self::SEND_INTERVAL);
    }
350023
protected function sendVideoMsgToJsonString(WxSendVideoMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "video":
                        {
                          "media_id":"%s",
                          "thumb_media_id":"%s",
                          "title":"%s",
                          "description":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getMediaId(),
                                        $msg->getThumbMediaId(),
                                        $msg->getTitle(),
                                        $msg->getDescription()
                        );

        return $result;
    }
164511
public function postMessage($channelId, $message, $longMessage = null, $mediaURL = null)
	{
		return $this->execute('POST', '/maniaflash/channels/%s/', array(
			$channelId,
			array(
				'message' => $message,
				'longMessage' => $longMessage,
				'mediaURL' => $mediaURL)));
	}
1148456
public function sendMessage(Message $msg)
    {
        if (is_callable($this->sendMessageFunction)) {
            call_user_func_array($this->sendMessageFunction, [$msg]);
        }
    }
1138849
public function sendAudio (Type\Audio $audioMessage)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $audioMessage->getType(),
                    ucfirst($audioMessage->getType()) => [
                        'MediaId' => $audioMessage->getMediaID(),
                    ],
                ]
            )
        );
    }
198690
@SuppressWarnings("rawtypes")
    public void pushMessage(IPipe pipe, IMessage message) throws IOException {
        if (message instanceof RTMPMessage) {
            final IRTMPEvent msg = ((RTMPMessage) message).getBody();
            // get the type
            byte dataType = msg.getDataType();
            // get the timestamp
            int timestamp = msg.getTimestamp();
            log.trace("Data type: {} timestamp: {}", dataType, timestamp);
            // if writes are delayed, queue the data and sort it by time
            if (queue == null) {
                // if we plan to use a queue, create one
                queue = new PriorityQueue<QueuedMediaData>(queueThreshold <= 0 ? 11 : queueThreshold);
            }
            QueuedMediaData queued = null;
            if (msg instanceof IStreamData) {
                if (log.isTraceEnabled()) {
                    log.trace("Stream data, body saved. Data type: {} class type: {}", dataType, msg.getClass().getName());
                }
                // ensure that our first video frame written is a key frame
                if (msg instanceof VideoData) {
                    log.debug("pushMessage video - waitForVideoKeyframe: {} gotVideoKeyframe: {}", waitForVideoKeyframe, gotVideoKeyframe);
                    if (!gotVideoKeyframe) {
                        VideoData video = (VideoData) msg;
                        if (video.getFrameType() == FrameType.KEYFRAME) {
                            log.debug("Got our first keyframe");
                            gotVideoKeyframe = true;
                        }
                        if (waitForVideoKeyframe && !gotVideoKeyframe) {
                            // skip this frame bail out
                            log.debug("Skipping video data since keyframe has not been written yet");
                            return;
                        }
                    }
                }
                queued = new QueuedMediaData(timestamp, dataType, (IStreamData) msg);
            } else {
                // XXX what type of message are we saving that has no body data??
                if (log.isTraceEnabled()) {
                    log.trace("Non-stream data, body not saved. Data type: {} class type: {}", dataType, msg.getClass().getName());
                }
                queued = new QueuedMediaData(timestamp, dataType);
            }
            if (queued != null) {
                writeLock.lock();
                try {
                    // add to the queue
                    queue.add(queued);
                } finally {
                    writeLock.unlock();
                }
            }
            int queueSize = 0;
            readLock.lock();
            try {
                queueSize = queue.size();
            } finally {
                readLock.unlock();
            }
            // initialize a writer
            if (writer == null) {
                init();
                if (msg instanceof VideoData) {
                    writeQueuedDataSlice(createTimestampLimitedSlice(msg.getTimestamp()));
                } else if (queueThreshold >= 0 && queueSize >= queueThreshold) {
                    writeQueuedDataSlice(createFixedLengthSlice(queueThreshold / (100 / percentage)));
                }
            }
        } else if (message instanceof ResetMessage) {
            startTimestamp = -1;
        } else if (log.isDebugEnabled()) {
            log.debug("Ignoring pushed message: {}", message);
        }
    }
396748
protected function startVideoStream(Video $video)
    {
        $this->curVideoStream = new Stream($video->getAudioStream());

        $this->init_file_stream_transfer(
            $video->getFileNameWithExtension('mp3'),
            // The ZIP format does not care about the file size.
            0
        );
    }
547703
@Override
    public void sendResponse(StoreStats performanceStats,
                             boolean isFromLocalZone,
                             long startTimeInMs) throws Exception {

        /*
         * Pay attention to the code below. Note that in this method we wrap a multiPart object with a mimeMessage.
         * However when writing to the outputStream we only send the multiPart object and not the entire
         * mimeMessage. This is intentional.
         *
         * In the earlier version of this code we used to create a multiPart object and just send that multiPart
         * across the wire.
         *
         * However, we later discovered that upon setting the content of a MimeBodyPart, JavaMail internally creates
         * a DataHandler object wrapping the object you passed in. The part's Content-Type header is not updated
         * immediately. In order to get the headers updated, one needs to to call MimeMessage.saveChanges() on the
         * enclosing message, which cascades down the MIME structure into a call to MimeBodyPart.updateHeaders()
         * on the body part. It's this updateHeaders call that transfers the content type from the
         * DataHandler to the part's MIME Content-Type header.
         *
         * To make sure that the Content-Type headers are being updated (without changing too much code), we decided
         * to wrap the multiPart in a mimeMessage, call mimeMessage.saveChanges() and then just send the multiPart.
         * This is to make sure multiPart's headers are updated accurately.
         */

        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
        MimeMultipart multiPart = new MimeMultipart();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        String base64Key = RestUtils.encodeVoldemortKey(key.get());
        String contentLocationKey = "/" + this.storeName + "/" + base64Key;

        for(Versioned<byte[]> versionedValue: versionedValues) {

            byte[] responseValue = versionedValue.getValue();

            VectorClock vectorClock = (VectorClock) versionedValue.getVersion();
            String eTag = RestUtils.getSerializedVectorClock(vectorClock);
            numVectorClockEntries += vectorClock.getVersionMap().size();

            // Create the individual body part for each versioned value of the
            // requested key
            MimeBodyPart body = new MimeBodyPart();
            try {
                // Add the right headers
                body.addHeader(CONTENT_TYPE, "application/octet-stream");
                body.addHeader(CONTENT_TRANSFER_ENCODING, "binary");
                body.addHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK, eTag);
                body.setContent(responseValue, "application/octet-stream");
                body.addHeader(RestMessageHeaders.CONTENT_LENGTH,
                               Integer.toString(responseValue.length));

                multiPart.addBodyPart(body);
            } catch(MessagingException me) {
                logger.error("Exception while constructing body part", me);
                outputStream.close();
                throw me;
            }

        }
        message.setContent(multiPart);
        message.saveChanges();
        try {
            multiPart.writeTo(outputStream);
        } catch(Exception e) {
            logger.error("Exception while writing multipart to output stream", e);
            outputStream.close();
            throw e;
        }
        ChannelBuffer responseContent = ChannelBuffers.dynamicBuffer();
        responseContent.writeBytes(outputStream.toByteArray());

        // Create the Response object
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);

        // Set the right headers
        response.setHeader(CONTENT_TYPE, "multipart/binary");
        response.setHeader(CONTENT_TRANSFER_ENCODING, "binary");
        response.setHeader(CONTENT_LOCATION, contentLocationKey);

        // Copy the data into the payload
        response.setContent(responseContent);
        response.setHeader(CONTENT_LENGTH, response.getContent().readableBytes());

        // Write the response to the Netty Channel
        if(logger.isDebugEnabled()) {
            String keyStr = RestUtils.getKeyHexString(this.key);
            debugLog("GET",
                     this.storeName,
                     keyStr,
                     startTimeInMs,
                     System.currentTimeMillis(),
                     numVectorClockEntries);
        }
        this.messageEvent.getChannel().write(response);

        if(performanceStats != null && isFromLocalZone) {
            recordStats(performanceStats, startTimeInMs, Tracked.GET);
        }

        outputStream.close();

    }