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