Shaka Packager SDK
simple_mpd_notifier.h
1 // Copyright 2014 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 
7 #ifndef MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
8 #define MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
9 
10 #include <map>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include <absl/synchronization/mutex.h>
16 
17 #include <packager/mpd/base/mpd_notifier.h>
18 #include <packager/mpd/base/mpd_notifier_util.h>
19 
20 namespace shaka {
21 
22 class AdaptationSet;
23 class MpdBuilder;
24 class Representation;
25 
26 struct MpdOptions;
27 
31  public:
32  explicit SimpleMpdNotifier(const MpdOptions& mpd_options);
33  ~SimpleMpdNotifier() override;
34 
38  bool Init() override;
39  bool NotifyNewContainer(const MediaInfo& media_info, uint32_t* id) override;
40  bool NotifyAvailabilityTimeOffset(uint32_t container_id) override;
41  bool NotifySampleDuration(uint32_t container_id,
42  int32_t sample_duration) override;
43  bool NotifySegmentDuration(uint32_t container_id) override;
44  bool NotifyNewSegment(uint32_t container_id,
45  int64_t start_time,
46  int64_t duration,
47  uint64_t size,
48  int64_t segment_number) override;
49  bool NotifyCompletedSegment(uint32_t container_id,
50  int64_t duration,
51  uint64_t size) override;
52  bool NotifyCueEvent(uint32_t container_id, int64_t timestamp) override;
53  bool NotifyEncryptionUpdate(uint32_t container_id,
54  const std::string& drm_uuid,
55  const std::vector<uint8_t>& new_key_id,
56  const std::vector<uint8_t>& new_pssh) override;
57  bool NotifyMediaInfoUpdate(uint32_t container_id,
58  const MediaInfo& media_info) override;
59  bool Flush() override;
61 
62  private:
63  SimpleMpdNotifier(const SimpleMpdNotifier&) = delete;
64  SimpleMpdNotifier& operator=(const SimpleMpdNotifier&) = delete;
65 
66  friend class SimpleMpdNotifierTest;
67 
68  // Testing only method. Returns a pointer to MpdBuilder.
69  MpdBuilder* MpdBuilderForTesting() const { return mpd_builder_.get(); }
70 
71  // Testing only method. Sets mpd_builder_.
72  void SetMpdBuilderForTesting(std::unique_ptr<MpdBuilder> mpd_builder) {
73  mpd_builder_ = std::move(mpd_builder);
74  }
75 
76  // MPD output path.
77  std::string output_path_;
78  std::unique_ptr<MpdBuilder> mpd_builder_;
79  bool content_protection_in_adaptation_set_ = true;
80  absl::Mutex lock_;
81 
82  uint32_t next_adaptation_set_id_ = 0;
83  // Maps Representation ID to Representation.
84  std::map<uint32_t, Representation*> representation_map_;
85  // Maps Representation ID to AdaptationSet. This is for updating the PSSH.
86  std::map<uint32_t, AdaptationSet*> representation_id_to_adaptation_set_;
87 };
88 
89 } // namespace shaka
90 
91 #endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
This class generates DASH MPDs (Media Presentation Descriptions).
Definition: mpd_builder.h:37
bool NotifyNewSegment(uint32_t container_id, int64_t start_time, int64_t duration, uint64_t size, int64_t segment_number) override
bool NotifyCompletedSegment(uint32_t container_id, int64_t duration, uint64_t size) override
bool NotifySampleDuration(uint32_t container_id, int32_t sample_duration) override
bool NotifyNewContainer(const MediaInfo &media_info, uint32_t *id) override
bool NotifyCueEvent(uint32_t container_id, int64_t timestamp) override
bool NotifyMediaInfoUpdate(uint32_t container_id, const MediaInfo &media_info) override
bool NotifyEncryptionUpdate(uint32_t container_id, const std::string &drm_uuid, const std::vector< uint8_t > &new_key_id, const std::vector< uint8_t > &new_pssh) override
bool NotifySegmentDuration(uint32_t container_id) override
bool NotifyAvailabilityTimeOffset(uint32_t container_id) override
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66
Defines Mpd Options.
Definition: mpd_options.h:25