Commit 88537655 authored by François Cartegnie's avatar François Cartegnie 🤞

stream_filter: dash: add MP4 atoms reader

parent 75f7f4f6
......@@ -84,6 +84,8 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/mpd/SegmentTimeline.h \
stream_filter/dash/mpd/TrickModeType.cpp \
stream_filter/dash/mpd/TrickModeType.h \
stream_filter/dash/mp4/AtomsReader.cpp \
stream_filter/dash/mp4/AtomsReader.hpp \
stream_filter/dash/xml/DOMHelper.cpp \
stream_filter/dash/xml/DOMHelper.h \
stream_filter/dash/xml/DOMParser.cpp \
......@@ -98,8 +100,14 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/DASHManager.h \
stream_filter/dash/Helper.cpp \
stream_filter/dash/Helper.h
libdash_plugin_la_SOURCES += demux/mp4/libmp4.c demux/mp4/libmp4.h
libdash_plugin_la_CXXFLAGS = $(AM_CFLAGS) -I$(srcdir)/stream_filter/dash
libdash_plugin_la_LIBADD = $(SOCKET_LIBS)
libdash_plugin_la_LIBADD = $(SOCKET_LIBS) $(LIBM)
if HAVE_ZLIB
libdash_plugin_la_LIBADD += -lz
endif
stream_filter_LTLIBRARIES += libdash_plugin.la
libsmooth_plugin_la_SOURCES = \
......
#ifndef STREAM_HPP
#define STREAM_HPP
class Stream
{
public:
Stream();
};
#endif // STREAM_HPP
/*
* AtomsReader.cpp
*****************************************************************************
* Copyright (C) 2014 - VideoLAN authors
*
* 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 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.
*****************************************************************************/
#include "AtomsReader.hpp"
#include "mpd/Representation.h"
#include "mpd/MPD.h"
using namespace dash::mp4;
using namespace dash::mpd;
AtomsReader::AtomsReader(ISegment *segment_)
{
segment = segment_;
rootbox = NULL;
}
AtomsReader::~AtomsReader()
{
vlc_object_t *object = segment->getRepresentation()->getMPD()->getVLCObject();
while(rootbox && rootbox->p_first)
{
MP4_Box_t *p_next = rootbox->p_first->p_next;
MP4_BoxFree( (stream_t *)object, rootbox->p_first );
rootbox->p_first = p_next;
}
delete rootbox;
}
bool AtomsReader::parseBlock(void *buffer, size_t size)
{
if(!segment->getRepresentation())
return false;
vlc_object_t *object = segment->getRepresentation()->getMPD()->getVLCObject();
stream_t *stream = stream_MemoryNew( object, (uint8_t *)buffer, size, true);
if (stream)
{
rootbox = new MP4_Box_t;
if(!rootbox)
{
stream_Delete(stream);
return false;
}
memset(rootbox, 0, sizeof(*rootbox));
rootbox->i_type = ATOM_root;
rootbox->i_size = size;
if ( MP4_ReadBoxContainerChildren( stream, rootbox, 0 ) == 1 )
{
#ifndef NDEBUG
MP4_BoxDumpStructure(stream, rootbox);
#endif
MP4_Box_t *sidxbox = MP4_BoxGet(rootbox, "sidx");
if (sidxbox)
{
MP4_Box_data_sidx_t *sidx = sidxbox->data.p_sidx;
size_t offset = sidx->i_first_offset;
for(uint16_t i=0; i<sidx->i_reference_count; i++)
{
std::cerr << " offset " << offset << std::endl;
offset += sidx->p_items[i].i_referenced_size;
}
}
std::cerr << "index seg " << ((uint8_t *)buffer)[4] << ((uint8_t *)buffer)[5] << std::endl;
}
stream_Delete(stream);
}
return true;
}
/*
* AtomsReader.hpp
*****************************************************************************
* Copyright (C) 2014 - VideoLAN authors
*
* 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 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.
*****************************************************************************/
#ifndef ATOMSREADER_HPP
#define ATOMSREADER_HPP
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "mpd/Segment.h"
#include <vlc_common.h>
#include <vlc_stream.h>
extern "C" {
#include "../../demux/mp4/libmp4.h"
}
namespace dash
{
namespace mp4
{
class AtomsReader
{
public:
AtomsReader(dash::mpd::ISegment *);
~AtomsReader();
bool parseBlock(void *, size_t);
protected:
dash::mpd::ISegment *segment;
MP4_Box_t *rootbox;
};
}
}
#endif // ATOMSREADER_HPP
......@@ -27,6 +27,8 @@
#include "Segment.h"
#include "Representation.h"
#include "MPD.h"
#include "mp4/AtomsReader.hpp"
#include <cassert>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment