c++ - bufferedPercent 是如何工作的

标签 c++ video-streaming network-protocols mpeg-dash

2个问题:

1- 我试图理解Rate Based Adaptation Logic 代码(完整的 cpp 代码在底部),我不太明白什么是 getBufferedPercent 函数返回。

2- 有什么地方可以找到有关此类功能的正确文档吗?

这是 RateBasedAdaptationLogic.cpp 代码:

    #ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "RateBasedAdaptationLogic.h"

using namespace dash::logic;
using namespace dash::xml;
using namespace dash::http;
using namespace dash::mpd;

RateBasedAdaptationLogic::RateBasedAdaptationLogic  (IMPDManager *mpdManager, stream_t *stream) :
                          AbstractAdaptationLogic   (mpdManager, stream),
                          mpdManager                (mpdManager),
                          count                     (0),
                          currentPeriod             (mpdManager->getFirstPeriod()),
                          width                     (0),
                          height                    (0)
{
    this->width  = var_InheritInteger(stream, "dash-prefwidth");
    this->height = var_InheritInteger(stream, "dash-prefheight");
}

Chunk*  RateBasedAdaptationLogic::getNextChunk()
{
    if(this->mpdManager == NULL)
        return NULL;

    if(this->currentPeriod == NULL)
        return NULL;

    uint64_t bitrate = this->getBpsAvg();

    if(this->getBufferPercent() < MINBUFFER)
        bitrate = 0;

    Representation *rep = this->mpdManager->getRepresentation(this->currentPeriod, bitrate, this->width, this->height);

    if ( rep == NULL )
        return NULL;

    std::vector<Segment *> segments = this->mpdManager->getSegments(rep);

    if ( this->count == segments.size() )
    {
        this->currentPeriod = this->mpdManager->getNextPeriod(this->currentPeriod);
        this->count = 0;
        return this->getNextChunk();
    }

    if ( segments.size() > this->count )
    {
        Segment *seg = segments.at( this->count );
        Chunk *chunk = seg->toChunk();
        //In case of UrlTemplate, we must stay on the same segment.
        if ( seg->isSingleShot() == true )
            this->count++;
        seg->done();
        chunk->setCalculatedBW(this->getBpsAvg());
        return chunk;
    }
    return NULL;
}

const Representation *RateBasedAdaptationLogic::getCurrentRepresentation() const
{
    return this->mpdManager->getRepresentation( this->currentPeriod, this->getBpsAvg() );
}

最佳答案

您的问题是关于 videolan 项目的代码。您粘贴的代码是 on the videolan web server .

The videolan developers page说他们有一个 IRC channel (irc://irc.videolan.org/videolan) 和 mailing lists您可以在哪里提问。

我建议您多阅读 DASH stream_filter module 中的代码,尤其是缓冲区目录(它计算您所询问的缓冲百分比),然后在 IRC 或邮件列表上询问具体问题。

不幸的是,这段代码似乎没有注释或文档。如果正常 channel 没有帮助,您可以询问作者。他们很友好地在文件顶部的版权声明中包含了电子邮件地址。

关于c++ - bufferedPercent 是如何工作的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20184926/

相关文章:

c++ - 具有默认参数作为模板类型的函数

video-streaming - WebRTC 单向视频通话

iphone - 捕获相机和音频输入时出错

C++ 将排列结果插入 vector

c++ - 如何优化我的分布式应用程序对网络消息的排队和缓冲以提高性能?

c# - 使用 Emgu CV 捕获 RTSP

algorithm - 如何利用实时数据的所有可用带宽?

flash - HTTPS 服务的 SWF 文件可以请求非安全的 HTTP 内容吗?

security - 当页面通过 https 传递安全和非安全项目时,安全项目是否会受到损害?

c++ - 在C++中初始化结构的成员变量