本文整理汇总了C++中SrsSharedPtrMessage::is_audio方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsSharedPtrMessage::is_audio方法的具体用法?C++ SrsSharedPtrMessage::is_audio怎么用?C++ SrsSharedPtrMessage::is_audio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrsSharedPtrMessage
的用法示例。
在下文中一共展示了SrsSharedPtrMessage::is_audio方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cache
int SrsGopCache::cache(SrsSharedPtrMessage* __msg)
{
int ret = ERROR_SUCCESS;
if (!enable_gop_cache) {
srs_verbose("gop cache is disabled.");
return ret;
}
// the gop cache know when to gop it.
SrsSharedPtrMessage* msg = __msg;
// disable gop cache when not h.264
if (!SrsFlvCodec::video_is_h264(msg->payload, msg->size)) {
srs_info("gop donot cache video for none h.264");
return ret;
}
// got video, update the video count if acceptable
if (msg->is_video()) {
cached_video_count++;
audio_after_last_video_count = 0;
}
// no acceptable video or pure audio, disable the cache.
if (pure_audio()) {
srs_verbose("ignore any frame util got a h264 video frame.");
return ret;
}
// ok, gop cache enabled, and got an audio.
if (msg->is_audio()) {
audio_after_last_video_count++;
}
// clear gop cache when pure audio count overflow
if (audio_after_last_video_count > __SRS_PURE_AUDIO_GUESS_COUNT) {
srs_warn("clear gop cache for guess pure audio overflow");
clear();
return ret;
}
// clear gop cache when got key frame
if (msg->is_video() && SrsFlvCodec::video_is_keyframe(msg->payload, msg->size)) {
srs_info("clear gop cache when got keyframe. vcount=%d, count=%d",
cached_video_count, (int)gop_cache.size());
clear();
// curent msg is video frame, so we set to 1.
cached_video_count = 1;
}
// cache the frame.
gop_cache.push_back(msg->copy());
return ret;
}
示例2: streaming_send_messages
int SrsLiveStream::streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs)
{
int ret = ERROR_SUCCESS;
for (int i = 0; i < nb_msgs; i++) {
SrsSharedPtrMessage* msg = msgs[i];
if (msg->is_audio()) {
ret = enc->write_audio(msg->timestamp, msg->payload, msg->size);
} else if (msg->is_video()) {
ret = enc->write_video(msg->timestamp, msg->payload, msg->size);
} else {
ret = enc->write_metadata(msg->timestamp, msg->payload, msg->size);
}
if (ret != ERROR_SUCCESS) {
return ret;
}
}
return ret;
}