SegmentInformation.hpp 4.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * SegmentInformation.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 SEGMENTINFORMATION_HPP
#define SEGMENTINFORMATION_HPP

23 24 25
#ifndef __STDC_CONSTANT_MACROS
  #define __STDC_CONSTANT_MACROS
#endif
26

27 28 29 30 31
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "ICanonicalUrl.hpp"
32
#include "../tools/Properties.hpp"
33
#include "SegmentInfoCommon.h"
34 35 36
#include <vlc_common.h>
#include <vector>

37
namespace adaptative
38
{
39
    namespace playlist
40 41 42
    {
        class SegmentBase;
        class SegmentList;
43
        class SegmentTimeline;
44 45 46
        class SegmentTemplate;
        class AbstractPlaylist;
        class ISegment;
47 48 49

        /* common segment elements for period/adaptset/rep 5.3.9.1,
         * with properties inheritance */
50 51
        class SegmentInformation : public ICanonicalUrl,
                                   public TimescaleAble
52 53 54
        {
            public:
                SegmentInformation( SegmentInformation * = 0 );
55
                explicit SegmentInformation( AbstractPlaylist * );
56
                virtual ~SegmentInformation();
57
                bool canBitswitch() const;
58
                virtual mtime_t getPeriodStart() const;
59
                virtual AbstractPlaylist *getPlaylist() const;
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

                class SplitPoint
                {
                    public:
                        size_t offset;
                        mtime_t time;
                };
                void SplitUsingIndex(std::vector<SplitPoint>&);

                enum SegmentInfoType
                {
                    INFOTYPE_INIT = 0,
                    INFOTYPE_MEDIA,
                    INFOTYPE_INDEX
                };
                static const int InfoTypeCount = INFOTYPE_INDEX + 1;

77
                ISegment * getSegment(SegmentInfoType, uint64_t = 0) const;
78
                bool getSegmentNumberByTime(mtime_t, uint64_t *) const;
79
                mtime_t getPlaybackTimeBySegmentNumber(uint64_t) const;
80
                void collectTimelines(std::vector<SegmentTimeline *> *) const;
81
                virtual void mergeWith(SegmentInformation *, mtime_t);
82 83 84 85

            protected:
                std::vector<ISegment *> getSegments() const;
                std::vector<ISegment *> getSegments(SegmentInfoType) const;
86
                std::vector<SegmentInformation *> childs;
87
                SegmentInformation *parent;
88

89
            public:
90 91
                void setSegmentList(SegmentList *);
                void setSegmentBase(SegmentBase *);
92
                void setSegmentTemplate(MediaSegmentTemplate *);
93
                void setBitstreamSwitching(bool);
94 95
                virtual Url getUrlSegment() const; /* impl */
                Property<Url *> baseUrl;
96

97 98
            private:
                void init();
99 100
                SegmentBase *     inheritSegmentBase() const;
                SegmentList *     inheritSegmentList() const;
101
                MediaSegmentTemplate * inheritSegmentTemplate() const;
102 103 104

                SegmentBase     *segmentBase;
                SegmentList     *segmentList;
105
                MediaSegmentTemplate *mediaSegmentTemplate;
106 107 108 109 110 111 112

                enum BitswitchPolicy
                {
                    BITSWITCH_INHERIT,
                    BITSWITCH_YES,
                    BITSWITCH_NO
                } bitswitch_policy;
113 114 115 116 117
        };
    }
}

#endif // SEGMENTINFORMATION_HPP