2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2014 Google LLC. All rights reserved.
|
2014-05-19 21:30:58 +00:00
|
|
|
//
|
|
|
|
// 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>
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2014-05-19 21:30:58 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-10-09 23:21:41 +00:00
|
|
|
#include <absl/synchronization/mutex.h>
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/mpd/base/mpd_notifier.h>
|
|
|
|
#include <packager/mpd/base/mpd_notifier_util.h>
|
2014-05-19 21:30:58 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2014-05-19 21:30:58 +00:00
|
|
|
|
|
|
|
class AdaptationSet;
|
|
|
|
class MpdBuilder;
|
|
|
|
class Representation;
|
|
|
|
|
2014-05-30 05:01:09 +00:00
|
|
|
struct MpdOptions;
|
|
|
|
|
2014-05-19 21:30:58 +00:00
|
|
|
/// A simple MpdNotifier implementation which receives muxer listener event and
|
|
|
|
/// generates an Mpd file.
|
|
|
|
class SimpleMpdNotifier : public MpdNotifier {
|
|
|
|
public:
|
2017-07-27 18:49:50 +00:00
|
|
|
explicit SimpleMpdNotifier(const MpdOptions& mpd_options);
|
2015-07-22 23:40:45 +00:00
|
|
|
~SimpleMpdNotifier() override;
|
2014-05-19 21:30:58 +00:00
|
|
|
|
2017-12-19 20:02:28 +00:00
|
|
|
/// None of the methods write out the MPD file until Flush() is called.
|
2014-05-19 21:30:58 +00:00
|
|
|
/// @name MpdNotifier implemetation overrides.
|
|
|
|
/// @{
|
2015-07-22 23:40:45 +00:00
|
|
|
bool Init() override;
|
|
|
|
bool NotifyNewContainer(const MediaInfo& media_info, uint32_t* id) override;
|
2021-08-25 15:38:05 +00:00
|
|
|
bool NotifyAvailabilityTimeOffset(uint32_t container_id) override;
|
2015-07-22 23:40:45 +00:00
|
|
|
bool NotifySampleDuration(uint32_t container_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int32_t sample_duration) override;
|
2021-08-25 15:38:05 +00:00
|
|
|
bool NotifySegmentDuration(uint32_t container_id) override;
|
2018-01-03 00:10:54 +00:00
|
|
|
bool NotifyNewSegment(uint32_t container_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int64_t start_time,
|
|
|
|
int64_t duration,
|
2015-07-22 23:40:45 +00:00
|
|
|
uint64_t size) override;
|
2021-09-03 16:57:43 +00:00
|
|
|
bool NotifyCompletedSegment(uint32_t container_id,
|
|
|
|
int64_t duration,
|
|
|
|
uint64_t size) override;
|
2021-08-04 18:56:44 +00:00
|
|
|
bool NotifyCueEvent(uint32_t container_id, int64_t timestamp) override;
|
2015-07-22 23:40:45 +00:00
|
|
|
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;
|
2018-05-22 00:39:21 +00:00
|
|
|
bool NotifyMediaInfoUpdate(uint32_t container_id,
|
|
|
|
const MediaInfo& media_info) override;
|
2015-07-22 23:40:45 +00:00
|
|
|
bool Flush() override;
|
2014-05-19 21:30:58 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
private:
|
2017-12-19 20:02:28 +00:00
|
|
|
SimpleMpdNotifier(const SimpleMpdNotifier&) = delete;
|
|
|
|
SimpleMpdNotifier& operator=(const SimpleMpdNotifier&) = delete;
|
|
|
|
|
2015-07-23 19:53:23 +00:00
|
|
|
friend class SimpleMpdNotifierTest;
|
2015-07-16 06:51:24 +00:00
|
|
|
|
|
|
|
// Testing only method. Returns a pointer to MpdBuilder.
|
2017-12-19 20:02:28 +00:00
|
|
|
MpdBuilder* MpdBuilderForTesting() const { return mpd_builder_.get(); }
|
2015-07-16 06:51:24 +00:00
|
|
|
|
|
|
|
// Testing only method. Sets mpd_builder_.
|
2016-08-17 17:41:40 +00:00
|
|
|
void SetMpdBuilderForTesting(std::unique_ptr<MpdBuilder> mpd_builder) {
|
|
|
|
mpd_builder_ = std::move(mpd_builder);
|
2015-07-16 06:51:24 +00:00
|
|
|
}
|
|
|
|
|
2015-07-22 06:57:21 +00:00
|
|
|
// MPD output path.
|
2014-05-19 21:30:58 +00:00
|
|
|
std::string output_path_;
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<MpdBuilder> mpd_builder_;
|
2017-12-19 20:02:28 +00:00
|
|
|
bool content_protection_in_adaptation_set_ = true;
|
2023-08-05 03:45:21 +00:00
|
|
|
absl::Mutex lock_;
|
2014-05-19 21:30:58 +00:00
|
|
|
|
2018-01-25 23:04:59 +00:00
|
|
|
uint32_t next_adaptation_set_id_ = 0;
|
2017-12-19 20:02:28 +00:00
|
|
|
// 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_;
|
2014-05-19 21:30:58 +00:00
|
|
|
};
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-05-19 21:30:58 +00:00
|
|
|
|
|
|
|
#endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
|