-
Notifications
You must be signed in to change notification settings - Fork 523
/
Copy pathsimple_mpd_notifier.h
84 lines (68 loc) · 2.84 KB
/
simple_mpd_notifier.h
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
// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
#define MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "packager/base/synchronization/lock.h"
#include "packager/mpd/base/mpd_notifier.h"
#include "packager/mpd/base/mpd_notifier_util.h"
namespace shaka {
class AdaptationSet;
class MpdBuilder;
class Representation;
struct MpdOptions;
/// A simple MpdNotifier implementation which receives muxer listener event and
/// generates an Mpd file.
class SimpleMpdNotifier : public MpdNotifier {
public:
explicit SimpleMpdNotifier(const MpdOptions& mpd_options);
~SimpleMpdNotifier() override;
/// None of the methods write out the MPD file until Flush() is called.
/// @name MpdNotifier implemetation overrides.
/// @{
bool Init() override;
bool NotifyNewContainer(const MediaInfo& media_info, uint32_t* id) override;
bool NotifySampleDuration(uint32_t container_id,
uint32_t sample_duration) override;
bool NotifyNewSegment(uint32_t container_id,
uint64_t start_time,
uint64_t duration,
uint64_t size) override;
bool NotifyCueEvent(uint32_t container_id, uint64_t timestamp) 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 NotifyMediaInfoUpdate(uint32_t container_id,
const MediaInfo& media_info) override;
bool Flush() override;
/// @}
private:
SimpleMpdNotifier(const SimpleMpdNotifier&) = delete;
SimpleMpdNotifier& operator=(const SimpleMpdNotifier&) = delete;
friend class SimpleMpdNotifierTest;
// Testing only method. Returns a pointer to MpdBuilder.
MpdBuilder* MpdBuilderForTesting() const { return mpd_builder_.get(); }
// Testing only method. Sets mpd_builder_.
void SetMpdBuilderForTesting(std::unique_ptr<MpdBuilder> mpd_builder) {
mpd_builder_ = std::move(mpd_builder);
}
// MPD output path.
std::string output_path_;
std::unique_ptr<MpdBuilder> mpd_builder_;
bool content_protection_in_adaptation_set_ = true;
base::Lock lock_;
uint32_t next_adaptation_set_id_ = 0;
// Maps Representation ID to Representation.
std::map<uint32_t, Representation*> representation_map_;
// Maps Representation ID to AdaptationSet. This is for updating the PSSH.
std::map<uint32_t, AdaptationSet*> representation_id_to_adaptation_set_;
};
} // namespace shaka
#endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_