Shaka Packager SDK
Loading...
Searching...
No Matches
period.h
1// Copyright 2017 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6//
8
9#ifndef PACKAGER_MPD_BASE_PERIOD_H_
10#define PACKAGER_MPD_BASE_PERIOD_H_
11
12#include <list>
13#include <map>
14#include <optional>
15
16#include <packager/mpd/base/adaptation_set.h>
17#include <packager/mpd/base/media_info.pb.h>
18#include <packager/mpd/base/xml/xml_node.h>
19
20namespace shaka {
21
22struct MpdOptions;
23
26class Period {
27 public:
28 virtual ~Period();
29
40 // TODO(kqyang): Move |content_protection_in_adaptation_set| to Period
41 // constructor.
43 const MediaInfo& media_info,
44 bool content_protection_in_adaptation_set);
45
49 std::optional<xml::XmlNode> GetXml(bool output_period_duration);
50
52 const std::list<AdaptationSet*> GetAdaptationSets() const;
53
55 double start_time_in_seconds() const { return start_time_in_seconds_; }
56
58 double duration_seconds() const { return duration_seconds_; }
59
62 duration_seconds_ = duration_seconds;
63 }
64
66 const std::map<std::string, std::list<AdaptationSet*>>& trickplay_cache()
67 const {
68 return trickplay_cache_;
69 }
70
71 protected:
77 Period(uint32_t period_id,
79 const MpdOptions& mpd_options,
80 uint32_t* representation_counter);
81
82 private:
83 Period(const Period&) = delete;
84 Period& operator=(const Period&) = delete;
85
86 friend class MpdBuilder;
87 friend class PeriodTest;
88
89 // Calls AdaptationSet constructor. For mock injection.
90 virtual std::unique_ptr<AdaptationSet> NewAdaptationSet(
91 const std::string& lang,
92 const MpdOptions& options,
93 uint32_t* representation_counter);
94
95 // Helper function to set new AdaptationSet attributes.
96 bool SetNewAdaptationSetAttributes(
97 const std::string& language,
98 const MediaInfo& media_info,
99 const std::list<AdaptationSet*>& adaptation_sets,
100 bool content_protection_in_adaptation_set,
101 AdaptationSet* new_adaptation_set);
102
103 // If processing a trick play AdaptationSet, gets the original AdaptationSet
104 // which the trick play video belongs to.It is assumed that the corresponding
105 // AdaptationSet has been created before the trick play AdaptationSet.
106 // Returns the matching AdaptationSet if found, otherwise returns nullptr;
107 // If processing non-trick play AdaptationSet, gets the trick play
108 // AdaptationSet that belongs to current AdaptationSet from trick play cache.
109 // Returns nullptr if matching trick play AdaptationSet is not found.
110 AdaptationSet* FindMatchingAdaptationSetForTrickPlay(
111 const MediaInfo& media_info,
112 bool content_protection_in_adaptation_set,
113 std::string* adaptation_set_key);
114
115 // Returns AdaptationSet key without ':trickplay' in it for trickplay
116 // AdaptationSet.
117 std::string GetAdaptationSetKeyForTrickPlay(const MediaInfo& media_info);
118
119 // FindMatchingAdaptationSetForTrickPlay
120 const uint32_t id_;
121 const double start_time_in_seconds_;
122 double duration_seconds_ = 0;
123 const MpdOptions& mpd_options_;
124 uint32_t* const representation_counter_;
125 std::list<std::unique_ptr<AdaptationSet>> adaptation_sets_;
126 // AdaptationSets grouped by a specific adaptation set grouping key.
127 // AdaptationSets with the same key contain identical parameters except
128 // ContentProtection parameters. A single AdaptationSet would be created
129 // if they contain identical ContentProtection elements. This map is only
130 // useful when ContentProtection element is placed in AdaptationSet.
131 std::map<std::string, std::list<AdaptationSet*>> adaptation_set_list_map_;
132 // Contains Trickplay AdaptationSets grouped by specific adaptation set
133 // grouping key. These AdaptationSets still have not found reference
134 // AdaptationSet.
135 std::map<std::string, std::list<AdaptationSet*>> trickplay_cache_;
136};
137
138} // namespace shaka
139
140#endif // PACKAGER_MPD_BASE_PERIOD_H_
This class generates DASH MPDs (Media Presentation Descriptions).
Definition mpd_builder.h:37
double duration_seconds() const
Definition period.h:58
void set_duration_seconds(double duration_seconds)
Set period duration.
Definition period.h:61
virtual AdaptationSet * GetOrCreateAdaptationSet(const MediaInfo &media_info, bool content_protection_in_adaptation_set)
Definition period.cc:75
std::optional< xml::XmlNode > GetXml(bool output_period_duration)
Definition period.cc:118
double start_time_in_seconds() const
Definition period.h:55
const std::map< std::string, std::list< AdaptationSet * > > & trickplay_cache() const
Definition period.h:66
const std::list< AdaptationSet * > GetAdaptationSets() const
Definition period.cc:183
All the methods that are virtual are virtual for mocking.
Defines Mpd Options.
Definition mpd_options.h:25