private AdaptationSet readAdaptationSet(MPD mpd, Period period, Uri baseUrl, XmlPullParser parser)
            throws XmlPullParserException, IOException, DashParserException {
        AdaptationSet adaptationSet = new AdaptationSet();

        adaptationSet.group = getAttributeValueInt(parser, "group");
        adaptationSet.mimeType = getAttributeValue(parser, "mimeType");
        adaptationSet.maxWidth = getAttributeValueInt(parser, "maxWidth");
        adaptationSet.maxHeight = getAttributeValueInt(parser, "maxHeight");
        adaptationSet.par = getAttributeValueRatio(parser, "par");

        SegmentTemplate segmentTemplate = null;

        int type = 0;
        while((type = parser.next()) >= 0) {
            if(type == XmlPullParser.START_TAG) {
                String tagName = parser.getName();

                if(tagName.equals("SegmentTemplate")) {
                    segmentTemplate = readSegmentTemplate(parser, baseUrl, null);
                } else if(tagName.equals("Representation")) {
                    try {
                        adaptationSet.representations.add(readRepresentation(
                                mpd, period, adaptationSet, baseUrl, parser, segmentTemplate));
                    } catch (Exception e) {
                        Log.e(TAG, "error reading representation: " + e.getMessage(), e);
                    }
                }
            } else if(type == XmlPullParser.END_TAG) {
                String tagName = parser.getName();
                if(tagName.equals("AdaptationSet")) {
                    return adaptationSet;
                }
            }
        }

        throw new DashParserException("invalid state");
    }
Parses an MPD XML file. This needs to be executed off the main thread, else a
NetworkOnMainThreadException gets thrown.
@param source the URl of an MPD XML file
@return a MPD object
@throws android.os.NetworkOnMainThreadException if executed on the main thread
MediaPlayer-DASH/src/main/java/net/protyposis/android/mediaplayer/dash/DashParser.java