[vlc-devel] WG: [PATCH 06/13] dash: added downloader and bitrate to chunk

Christopher Müller christopher.mueller at itec.uni-klu.ac.at
Tue Feb 14 16:33:56 CET 2012


] [PATCH 06/13] dash: added downloader and
> bitrate to chunk
> 
> Thanks for feedback!
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Hugo Beauzée-Luyssen [mailto:beauze.h at gmail.com]
> > Gesendet: Dienstag, 14. Februar 2012 16:14
> > An: Mailing list for VLC media player developers
> > Cc: Christopher Mueller
> > Betreff: Re: [vlc-devel] [PATCH 06/13] dash: added downloader and
> > bitrate to chunk
> >
> > Hi,
> >
> > On Sat, Feb 11, 2012 at 11:59 AM,  <Christopher at mailsrv.uni-
> klu.ac.at>
> > wrote:
> > > From: Christopher Mueller <christopher.mueller at itec.aau.at>
> > >
> > > ---
> > >  modules/stream_filter/dash/DASHDownloader.cpp |  108
> > > +++++++++++++++++++++++++
> > >  modules/stream_filter/dash/DASHDownloader.h   |   61
> ++++++++++++++
> > >  modules/stream_filter/dash/Modules.am         |    2 +
> > >  modules/stream_filter/dash/http/Chunk.cpp     |    8 ++
> > >  modules/stream_filter/dash/http/Chunk.h       |    3 +
> > >  5 files changed, 182 insertions(+), 0 deletions(-)
> > >  create mode 100644 modules/stream_filter/dash/DASHDownloader.cpp
> > >  create mode 100644 modules/stream_filter/dash/DASHDownloader.h
> > >
> > > diff --git a/modules/stream_filter/dash/DASHDownloader.cpp
> > > b/modules/stream_filter/dash/DASHDownloader.cpp
> > > new file mode 100644
> > > index 0000000..1e190bf
> > > --- /dev/null
> > > +++ b/modules/stream_filter/dash/DASHDownloader.cpp
> > > @@ -0,0 +1,108 @@
> > > +/*
> > > + * DASHDownloader.h
> > > +
> > >
> >
> +*********************************************************************
> > > +********
> > > + * Copyright (C) 2010 - 2011 Klagenfurt University
> > > + *
> > > + * Created on: Aug 10, 2010
> > > + * Authors: Christopher Mueller
> > > +<christopher.mueller at itec.uni-klu.ac.at>
> > > + *          Christian Timmerer
> > > +<christian.timmerer at itec.uni-klu.ac.at>
> > > + *
> > > + * This program is free software; you can redistribute it and/or
> > > +modify
> > > + * it under the terms of the GNU Lesser General Public License as
> > > +published
> > > + * by the Free Software Foundation; either version 2.1 of the
> > > +License, or
> > > + * (at your option) any later version.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > + * GNU General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General
> Public
> > > +License
> > > + * along with this program; if not, write to the Free Software
> > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
> > 02110-1301, USA.
> > > +
> > >
> >
> +*********************************************************************
> > > +********/
> > > +#ifdef HAVE_CONFIG_H
> > > +# include "config.h"
> > > +#endif
> > > +
> > > +#include "DASHDownloader.h"
> > > +
> > > +using namespace dash;
> > > +using namespace dash::http;
> > > +using namespace dash::logic;
> > > +using namespace dash::exception;
> > > +using namespace dash::buffer;
> > > +
> > > +DASHDownloader::DASHDownloader  (HTTPConnectionManager
> *conManager,
> > > +IAdaptationLogic *adaptationLogic, BlockBuffer *buffer) {
> > > +    this->t_sys                     = (thread_sys_t *)
> > > +malloc(sizeof(thread_sys_t));
> > > +    this->t_sys->conManager         = conManager;
> > > +    this->t_sys->adaptationLogic    = adaptationLogic;
> > > +    this->t_sys->buffer             = buffer; }
> > > +DASHDownloader::~DASHDownloader () {
> > > +    std::cout << "Downloader set eof" << std::endl;
> > > +    this->t_sys->buffer->setEOF(true);
> > > +    std::cout << "Downloader try to join" << std::endl;
> > > +    vlc_join(this->dashDLThread, NULL);
> > > +    free(this->t_sys);
> > > +
> > > +    std::cout << "Downloader thread joined tsys freed" <<
> > > +std::endl; }
> > > +
> > > +bool        DASHDownloader::start       () {
> > > +    if(vlc_clone(&(this->dashDLThread), download, (void*)this-
> > >t_sys,
> > > +VLC_THREAD_PRIORITY_LOW))
> > > +        return false;
> > > +
> > > +    return true;
> > > +}
> > > +void*       DASHDownloader::download    (void *thread_sys) {
> > > +    thread_sys_t            *t_sys              = (thread_sys_t *)
> > > +thread_sys;
> > > +    HTTPConnectionManager   *conManager         =
> > > +t_sys->conManager;
> > > +    IAdaptationLogic        *adaptationLogic    =
> > > +t_sys->adaptationLogic;
> > > +    BlockBuffer             *buffer             = t_sys->buffer;
> > > +    Chunk                   *currentChunk       = NULL;
> > > +    block_t                 *block              =
> > > +block_Alloc(BLOCKSIZE);
> > > +
> > > +    do
> > > +    {
> > > +        if(currentChunk == NULL)
> > > +        {
> > > +            try
> > > +            {
> > > +                currentChunk  = adaptationLogic->getNextChunk();
> > > +            }
> > > +            catch(EOFException &e)
> > > +            {
> > > +                buffer->setEOF(true);
> > > +            }
> > > +        }
> > > +        else
> > > +        {
> > > +            int ret = conManager->read(currentChunk, block-
> > >p_buffer,
> > > + block->i_buffer);
> > > +            if(ret <= 0)
> > > +            {
> > > +                currentChunk = NULL;
> > > +            }
> > > +            else
> > > +            {
> > > +                block_t *bufBlock = block_Alloc(ret);
> >
> > I don't understand why you are creating a first block, use it to
> read,
> > and then copy its content to another block?!
> > Why don't you just create a block, use it to read, and append it to
> > the block chain ?
> 
> When we allocate the block before the read call we would have to resize
> the block if the return of read is less than our blocksize.
> 
> >
> > > +                memcpy(bufBlock->p_buffer, block->p_buffer, ret);
> > > +                bufBlock->i_length = (mtime_t)((ret * 8) /
> > > + ((float)currentChunk->getBitrate() / 1000000));
> > > +
> > > +                std::cout << "Put block into buffer MilliSeconds:
> "
> > > + << bufBlock->i_length
> > > +                          << " Bytes: " << bufBlock->i_buffer
> > > +                          << " Bitrate: " <<
> > > + currentChunk->getBitrate() << std::endl;
> > > +                buffer->put(bufBlock);
> > > +            }
> > > +        }
> > > +    }while(!buffer->getEOF());
> > > +
> > > +    std::cout << "Downloader end: " << std::endl;
> > > +    block_Release(block);
> > > +
> > > +    return NULL;
> > > +}
> > > diff --git a/modules/stream_filter/dash/DASHDownloader.h
> > > b/modules/stream_filter/dash/DASHDownloader.h
> > > new file mode 100644
> > > index 0000000..11ab6d3
> > > --- /dev/null
> > > +++ b/modules/stream_filter/dash/DASHDownloader.h
> > > @@ -0,0 +1,61 @@
> > > +/*
> > > + * DASHDownloader.h
> > > +
> > >
> >
> +*********************************************************************
> > > +********
> > > + * Copyright (C) 2010 - 2011 Klagenfurt University
> > > + *
> > > + * Created on: Aug 10, 2010
> > > + * Authors: Christopher Mueller
> > > +<christopher.mueller at itec.uni-klu.ac.at>
> > > + *          Christian Timmerer
> > > +<christian.timmerer at itec.uni-klu.ac.at>
> > > + *
> > > + * This program is free software; you can redistribute it and/or
> > > +modify
> > > + * it under the terms of the GNU Lesser General Public License as
> > > +published
> > > + * by the Free Software Foundation; either version 2.1 of the
> > > +License, or
> > > + * (at your option) any later version.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > + * GNU General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General
> Public
> > > +License
> > > + * along with this program; if not, write to the Free Software
> > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
> > 02110-1301, USA.
> > > +
> > >
> >
> +*********************************************************************
> > > +********/
> > > +
> > > +#ifndef DASHDOWNLOADER_H_
> > > +#define DASHDOWNLOADER_H_
> > > +
> > > +#include "http/HTTPConnectionManager.h"
> > > +#include "adaptationlogic/IAdaptationLogic.h"
> > > +#include "exceptions/EOFException.h"
> > > +#include "buffer/BlockBuffer.h"
> > > +
> > > +#define BLOCKSIZE 32768
> > > +
> > > +#include <iostream>
> > > +
> > > +namespace dash
> > > +{
> > > +    struct thread_sys_t
> > > +    {
> > > +        dash::http::HTTPConnectionManager   *conManager;
> > > +        logic::IAdaptationLogic             *adaptationLogic;
> > > +        buffer::BlockBuffer                 *buffer;
> > > +    };
> > > +
> > > +    class DASHDownloader
> > > +    {
> > > +        public:
> > > +            DASHDownloader          (http::HTTPConnectionManager
> > > + *conManager, logic::IAdaptationLogic *adaptationLogic,
> > > + buffer::BlockBuffer *buffer);
> > > +            virtual ~DASHDownloader ();
> > > +
> > > +            bool            start       ();
> > > +            static void*    download    (void *);
> > > +
> > > +        private:
> > > +            thread_sys_t    *t_sys;
> > > +            vlc_thread_t    dashDLThread;
> > > +    };
> > > +}
> > > +
> > > +#endif /* DASHDOWNLOADER_H_ */
> > > diff --git a/modules/stream_filter/dash/Modules.am
> > > b/modules/stream_filter/dash/Modules.am
> > > index 00fb071..749dc52 100644
> > > --- a/modules/stream_filter/dash/Modules.am
> > > +++ b/modules/stream_filter/dash/Modules.am
> > > @@ -76,6 +76,8 @@ SOURCES_stream_filter_dash = \
> > >     xml/Node.cpp \
> > >     xml/Node.h \
> > >     dash.cpp \
> > > +    DASHDownloader.cpp \
> > > +    DASHDownloader.h \
> > >     DASHManager.cpp \
> > >     DASHManager.h \
> > >     $(NULL)
> > > diff --git a/modules/stream_filter/dash/http/Chunk.cpp
> > > b/modules/stream_filter/dash/http/Chunk.cpp
> > > index 5de4e9f..445d703 100644
> > > --- a/modules/stream_filter/dash/http/Chunk.cpp
> > > +++ b/modules/stream_filter/dash/http/Chunk.cpp
> > > @@ -72,3 +72,11 @@ void                Chunk::setUseByteRange
>  (bool
> > > value)
> > >  {
> > >     this->hasByteRange = value;
> > >  }
> > > +void                Chunk::setBitrate       (int bitrate) {
> > > +    this->bitrate = bitrate;
> > > +}
> > > +int                 Chunk::getBitrate       () {
> > > +    return this->bitrate;
> > > +}
> > > diff --git a/modules/stream_filter/dash/http/Chunk.h
> > > b/modules/stream_filter/dash/http/Chunk.h
> > > index c2020f8..efffa2c 100644
> > > --- a/modules/stream_filter/dash/http/Chunk.h
> > > +++ b/modules/stream_filter/dash/http/Chunk.h
> > > @@ -46,6 +46,8 @@ namespace dash
> > >                 void                addOptionalUrl  (const
> > > std::string& url);
> > >                 bool                useByteRange    ();
> > >                 void                setUseByteRange (bool value);
> > > +                void                setBitrate      (int bitrate);
> > > +                int                 getBitrate      ();
> > >
> > >             private:
> > >                 std::string                 url; @@ -53,6 +55,7 @@
> > > namespace dash
> > >                 int                         startByte;
> > >                 int                         endByte;
> > >                 bool                        hasByteRange;
> > > +                int                         bitrate;
> > >
> > >         };
> > >     }
> > > --
> > > 1.7.0.4
> > >
> >
> > Best regards,
> >
> > --
> > Hugo Beauzée-Luyssen





More information about the vlc-devel mailing list