DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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/gtest_prod_util.h"
16 #include "packager/base/synchronization/lock.h"
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 class SimpleMpdNotifierTest;
26 
27 struct MpdOptions;
28 
32  public:
33  explicit SimpleMpdNotifier(const MpdOptions& mpd_options);
34  ~SimpleMpdNotifier() override;
35 
38  bool Init() override;
39  bool NotifyNewContainer(const MediaInfo& media_info, uint32_t* id) override;
40  bool NotifySampleDuration(uint32_t container_id,
41  uint32_t sample_duration) override;
42  bool NotifyNewSegment(uint32_t id,
43  uint64_t start_time,
44  uint64_t duration,
45  uint64_t size) 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;
51  uint32_t id,
52  const ContentProtectionElement& content_protection_element) override;
53  bool Flush() override;
55 
56  private:
57  friend class SimpleMpdNotifierTest;
58 
59  // Testing only method. Returns a pointer to MpdBuilder.
60  MpdBuilder* MpdBuilderForTesting() const {
61  return mpd_builder_.get();
62  }
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  base::Lock lock_;
73 
74  typedef std::map<std::string, AdaptationSet*> AdaptationSetMap;
75  AdaptationSetMap adaptation_set_map_;
76 
77  typedef std::map<uint32_t, Representation*> RepresentationMap;
78  RepresentationMap representation_map_;
79 
80  DISALLOW_COPY_AND_ASSIGN(SimpleMpdNotifier);
81 };
82 
83 } // namespace shaka
84 
85 #endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
This class generates DASH MPDs (Media Presentation Descriptions).
Definition: mpd_builder.h:54
bool AddContentProtectionElement(uint32_t id, const ContentProtectionElement &content_protection_element) override
bool NotifyNewSegment(uint32_t id, uint64_t start_time, uint64_t duration, uint64_t size) override
bool NotifySampleDuration(uint32_t container_id, uint32_t sample_duration) 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
Defines Mpd Options.
Definition: mpd_options.h:25
bool NotifyNewContainer(const MediaInfo &media_info, uint32_t *id) override