2014-05-19 21:30:58 +00:00
|
|
|
// 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>
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2014-05-19 21:30:58 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2015-07-16 06:51:24 +00:00
|
|
|
#include "packager/base/gtest_prod_util.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/synchronization/lock.h"
|
|
|
|
#include "packager/mpd/base/mpd_notifier.h"
|
2015-07-22 06:57:21 +00:00
|
|
|
#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;
|
2015-07-16 06:51:24 +00:00
|
|
|
class SimpleMpdNotifierTest;
|
2014-05-19 21:30:58 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
/// @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;
|
|
|
|
bool NotifySampleDuration(uint32_t container_id,
|
|
|
|
uint32_t sample_duration) override;
|
|
|
|
bool NotifyNewSegment(uint32_t id,
|
|
|
|
uint64_t start_time,
|
|
|
|
uint64_t duration,
|
|
|
|
uint64_t size) 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 AddContentProtectionElement(
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t id,
|
2015-07-22 23:40:45 +00:00
|
|
|
const ContentProtectionElement& content_protection_element) override;
|
|
|
|
bool Flush() override;
|
2014-05-19 21:30:58 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
private:
|
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.
|
|
|
|
MpdBuilder* MpdBuilderForTesting() const {
|
|
|
|
return mpd_builder_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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_;
|
2014-05-19 21:30:58 +00:00
|
|
|
base::Lock lock_;
|
|
|
|
|
2016-03-08 19:19:12 +00:00
|
|
|
typedef std::map<std::string, AdaptationSet*> AdaptationSetMap;
|
2014-05-19 21:30:58 +00:00
|
|
|
AdaptationSetMap adaptation_set_map_;
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
typedef std::map<uint32_t, Representation*> RepresentationMap;
|
2014-05-19 21:30:58 +00:00
|
|
|
RepresentationMap representation_map_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SimpleMpdNotifier);
|
|
|
|
};
|
|
|
|
|
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_
|