* Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
* Christian Timmerer <christian.timmerer@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
+ * 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser 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.
+ * 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"
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)
+
+DASHDownloader::DASHDownloader (HTTPConnectionManager *conManager, 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 ()
{
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);
+ int ret = 0;
do
{
- if(currentChunk == NULL)
- {
- try
- {
- currentChunk = adaptationLogic->getNextChunk();
- }
- catch(EOFException &e)
- {
- buffer->setEOF(true);
- }
- }
- else
+ ret = conManager->read(block);
+ if(ret > 0)
{
- int ret = conManager->read(currentChunk, block->p_buffer, block->i_buffer);
- if(ret <= 0)
- {
- currentChunk = NULL;
- }
- else
- {
- block_t *bufBlock = block_Alloc(ret);
- memcpy(bufBlock->p_buffer, block->p_buffer, ret);
- bufBlock->i_length = (mtime_t)((ret * 8) / ((float)currentChunk->getBitrate() / 1000000));
- buffer->put(bufBlock);
- }
+ block_t *bufBlock = block_Alloc(ret);
+ memcpy(bufBlock->p_buffer, block->p_buffer, ret);
+
+ bufBlock->i_length = block->i_length;
+ buffer->put(bufBlock);
}
- }while(!buffer->getEOF());
+ }while(ret && !buffer->getEOF());
+ buffer->setEOF(true);
block_Release(block);
return NULL;