-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAampMPDUtils.h
More file actions
116 lines (100 loc) · 3.5 KB
/
AampMPDUtils.h
File metadata and controls
116 lines (100 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* If not stated otherwise in this file or this component's license file the
* following copyright and licenses apply:
*
* Copyright 2023 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**************************************
* @file AampMPDUtils.h
* @brief MPD Utils for Aamp
**************************************/
#ifndef __AAMP_MPD_UTILS_H__
#define __AAMP_MPD_UTILS_H__
#include "libdash/xml/Node.h"
#include "libdash/xml/DOMParser.h"
#include <libxml/xmlreader.h>
#include <thread>
#include "AampLogManager.h"
#include "AampUtils.h"
#include "AampMPDPeriodInfo.h"
#include "AampFragmentDescriptor.hpp"
#include "AampConfig.h"
using namespace dash;
using namespace std;
using namespace dash::mpd;
using namespace dash::xml;
using namespace dash::helpers;
/**
* @brief Get xml node form reader
*
* @retval xml node
*/
Node* MPDProcessNode(xmlTextReaderPtr *reader, std::string url, bool isAd=false);
/**
* @brief Add attributes to xml node
* @param reader xmlTextReaderPtr
* @param node xml Node
*/
void AddAttributesToNode(xmlTextReaderPtr *reader, Node *node);
/**
* @brief Check if mime type is compatible with media type
* @param mimeType mime type
* @param mediaType media type
* @retval true if compatible
*/
bool IsCompatibleMimeType(const std::string& mimeType, AampMediaType mediaType);
/**
* @brief Computes the fragment duration
* @param duration of the fragment.
* @param timeScale value.
* @return - computed fragment duration in double.
*/
double ComputeFragmentDuration( uint32_t duration, uint32_t timeScale );
/**
* @fn ConstructFragmentURL
* @param[out] fragmentUrl fragment url
* @param[in] fragmentDescriptor descriptor
* @param[in] media media information string
* @param[in] config AAMP configuration
*/
void ConstructFragmentURL( std::string& fragmentUrl, const FragmentDescriptor *fragmentDescriptor, std::string media, AampConfig *config);
/**
* @brief Parse segment index box
* @note The SegmentBase indexRange attribute points to Segment Index Box location with segments and random access points.
* @param start start of box
* @param size size of box
* @param segmentIndex segment index
* @param[out] referenced_size referenced size
* @param[out] referenced_duration referenced duration
* @retval true on success
*/
bool ParseSegmentIndexBox( const uint8_t *start, size_t size, int segmentIndex, unsigned int *referenced_size, float *referenced_duration, unsigned int *firstOffset);
/**
* @brief Replace matching token with given number
* @param str String in which operation to be performed
* @param from token
* @param toNumber number to replace token
* @retval position
*/
int replace(std::string& str, const std::string& from, uint64_t toNumber );
/**
* @brief Replace matching token with given string
* @param str String in which operation to be performed
* @param from token
* @param toString string to replace token
* @retval position
*/
int replace(std::string& str, const std::string& from, const std::string& toString );
#endif /* __AAMP_MPD_UTILS_H__ */