public MPD parse(UriSource source, OkHttpClient httpClient) throws DashParserException {
        MPD mpd = null;

        Headers.Builder headers = new Headers.Builder();
        if(source.getHeaders() != null && !source.getHeaders().isEmpty()) {
            for(String name : source.getHeaders().keySet()) {
                headers.add(name, source.getHeaders().get(name));
            }
        }

        Uri uri = source.getUri();

        Request.Builder request = new Request.Builder()
                .url(uri.toString())
                .headers(headers.build());

        try {
            Response response = httpClient.newCall(request.build()).execute();
            if(!response.isSuccessful()) {
                throw new IOException("error requesting the MPD");
            }

            // Determine this MPD's default BaseURL by removing the last path segment (which is the MPD file)
            Uri baseUrl = Uri.parse(uri.toString().substring(0, uri.toString().lastIndexOf("/") + 1));

            // Get the current datetime from the server for live stream time syncing
            serverDate = response.headers().getDate("Date");

            // Parse the MPD file
            mpd = parse(response.body().byteStream(), baseUrl);
        } catch (IOException e) {
            Log.e(TAG, "error downloading the MPD", e);
            throw new DashParserException("error downloading the MPD", e);
        } catch (XmlPullParserException e) {
            Log.e(TAG, "error parsing the MPD", e);
            throw new DashParserException("error parsing the MPD", e);
        }

        return mpd;
    }
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
@param httpClient the http client instance to use for the request
@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