2 * DASH MPD parsing library
6 * Copyright (C) 2012 STMicroelectronics
9 * Gianluca Gennari <gennarone@gmail.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library (COPYING); if not, write to the
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
27 #ifndef __GST_MPDPARSER_H__
28 #define __GST_MPDPARSER_H__
31 #include <gst/base/gstadapter.h>
33 #include "gstadaptivedemux.h"
35 #include "gstmpd-prelude.h"
36 #include "gstmpdhelper.h"
37 #include "gstxmlhelper.h"
38 #include "gstmpdrootnode.h"
39 #include "gstmpdbaseurlnode.h"
40 #include "gstmpdutctimingnode.h"
41 #include "gstmpdmetricsnode.h"
42 #include "gstmpdmetricsrangenode.h"
43 #include "gstmpdsnode.h"
44 #include "gstmpdsegmenttimelinenode.h"
45 #include "gstmpdsegmenttemplatenode.h"
46 #include "gstmpdsegmenturlnode.h"
47 #include "gstmpdsegmentlistnode.h"
48 #include "gstmpdsegmentbasenode.h"
49 #include "gstmpdperiodnode.h"
50 #include "gstmpdrepresentationnode.h"
51 #include "gstmpdsubrepresentationnode.h"
52 #include "gstmpdcontentcomponentnode.h"
53 #include "gstmpdadaptationsetnode.h"
54 #include "gstmpdsubsetnode.h"
55 #include "gstmpdprograminformationnode.h"
56 #include "gstmpdlocationnode.h"
57 #include "gstmpdreportingnode.h"
58 #include "gstmpdurltypenode.h"
59 #include "gstmpddescriptortypenode.h"
60 #include "gstmpdrepresentationbasenode.h"
61 #include "gstmpdmultsegmentbasenode.h"
65 typedef struct _GstActiveStream GstActiveStream;
66 typedef struct _GstStreamPeriod GstStreamPeriod;
67 typedef struct _GstMediaFragmentInfo GstMediaFragmentInfo;
68 typedef struct _GstMediaSegment GstMediaSegment;
71 #define GST_MPD_DURATION_NONE ((guint64)-1)
76 GST_STREAM_VIDEO, /* video stream (the main one) */
77 GST_STREAM_AUDIO, /* audio stream (optional) */
78 GST_STREAM_APPLICATION /* application stream (optional): for timed text/subtitles */
84 * Stream period data structure
86 struct _GstStreamPeriod
88 GstMPDPeriodNode *period; /* Stream period */
89 guint number; /* Period number */
90 GstClockTime start; /* Period start time */
91 GstClockTime duration; /* Period duration */
97 * Media segment data structure
99 struct _GstMediaSegment
101 GstMPDSegmentURLNode *SegmentURL; /* this is NULL when using a SegmentTemplate */
102 guint number; /* segment number */
103 gint repeat; /* number of extra repetitions (0 = played only once) */
104 guint64 scale_start; /* start time in timescale units */
105 guint64 scale_duration; /* duration in timescale units */
106 GstClockTime start; /* segment start time */
107 GstClockTime duration; /* segment duration */
110 struct _GstMediaFragmentInfo
117 gint64 index_range_start;
118 gint64 index_range_end;
120 gboolean discontinuity;
121 GstClockTime timestamp;
122 GstClockTime duration;
128 * Active stream data structure
130 struct _GstActiveStream
132 GstStreamMimeType mimeType; /* video/audio/application */
134 guint baseURL_idx; /* index of the baseURL used for last request */
135 gchar *baseURL; /* active baseURL used for last request */
136 gchar *queryURL; /* active queryURL used for last request */
137 guint max_bandwidth; /* max bandwidth allowed for this mimeType */
139 GstMPDAdaptationSetNode *cur_adapt_set; /* active adaptation set */
140 gint representation_idx; /* index of current representation */
141 GstMPDRepresentationNode *cur_representation; /* active representation */
142 GstMPDSegmentBaseNode *cur_segment_base; /* active segment base */
143 GstMPDSegmentListNode *cur_segment_list; /* active segment list */
144 GstMPDSegmentTemplateNode *cur_seg_template; /* active segment template */
145 gint segment_index; /* index of next sequence chunk */
146 guint segment_repeat_index; /* index of the repeat count of a segment */
147 GPtrArray *segments; /* array of GstMediaSegment */
148 GstClockTime presentationTimeOffset; /* presentation time offset of the current segment */
151 /* MPD file parsing */
152 gboolean gst_mpdparser_get_mpd_root_node (GstMPDRootNode ** mpd_root_node, const gchar * data, gint size);
153 GstMPDSegmentListNode * gst_mpdparser_get_external_segment_list (const gchar * data, gint size, GstMPDSegmentListNode * parent);
154 GList * gst_mpdparser_get_external_periods (const gchar * data, gint size);
155 GList * gst_mpdparser_get_external_adaptation_sets (const gchar * data, gint size, GstMPDPeriodNode* period);
157 /* navigation functions */
158 GstStreamMimeType gst_mpdparser_representation_get_mimetype (GstMPDAdaptationSetNode * adapt_set, GstMPDRepresentationNode * rep);
160 /* Memory management */
161 void gst_mpdparser_free_stream_period (GstStreamPeriod * stream_period);
162 void gst_mpdparser_free_media_segment (GstMediaSegment * media_segment);
163 void gst_mpdparser_free_active_stream (GstActiveStream * active_stream);
164 void gst_mpdparser_media_fragment_info_clear (GstMediaFragmentInfo * fragment);
165 /* Active stream methods*/
166 void gst_mpdparser_init_active_stream_segments (GstActiveStream * stream);
167 gchar *gst_mpdparser_get_mediaURL (GstActiveStream * stream, GstMPDSegmentURLNode * segmentURL);
168 const gchar *gst_mpdparser_get_initializationURL (GstActiveStream * stream, GstMPDURLTypeNode * InitializationURL);
169 gchar *gst_mpdparser_build_URL_from_template (const gchar * url_template, const gchar * id, guint number, guint bandwidth, guint64 time);
173 #endif /* __GST_MPDPARSER_H__ */