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>
|
|
|
|
#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/memory/scoped_ptr.h"
|
|
|
|
#include "packager/base/synchronization/lock.h"
|
|
|
|
#include "packager/mpd/base/mpd_notifier.h"
|
2014-05-19 21:30:58 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
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:
|
2014-05-16 23:32:10 +00:00
|
|
|
SimpleMpdNotifier(DashProfile dash_profile,
|
2014-05-30 05:01:09 +00:00
|
|
|
const MpdOptions& mpd_options,
|
2014-05-16 23:32:10 +00:00
|
|
|
const std::vector<std::string>& base_urls,
|
2014-05-19 21:30:58 +00:00
|
|
|
const std::string& output_path);
|
|
|
|
virtual ~SimpleMpdNotifier();
|
|
|
|
|
|
|
|
/// @name MpdNotifier implemetation overrides.
|
|
|
|
/// @{
|
|
|
|
virtual bool Init() OVERRIDE;
|
|
|
|
virtual bool NotifyNewContainer(const MediaInfo& media_info,
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t* id) OVERRIDE;
|
2015-06-15 21:12:42 +00:00
|
|
|
virtual bool NotifySampleDuration(uint32_t container_id,
|
|
|
|
uint32_t sample_duration) OVERRIDE;
|
2014-09-30 21:52:21 +00:00
|
|
|
virtual bool NotifyNewSegment(uint32_t id,
|
|
|
|
uint64_t start_time,
|
|
|
|
uint64_t duration,
|
|
|
|
uint64_t size) OVERRIDE;
|
2014-05-19 21:30:58 +00:00
|
|
|
virtual bool AddContentProtectionElement(
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t id,
|
2014-05-19 21:30:58 +00:00
|
|
|
const ContentProtectionElement& content_protection_element) OVERRIDE;
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
private:
|
2015-07-16 06:51:24 +00:00
|
|
|
friend SimpleMpdNotifierTest;
|
|
|
|
|
|
|
|
// Testing only method. Returns a pointer to MpdBuilder.
|
|
|
|
MpdBuilder* MpdBuilderForTesting() const {
|
|
|
|
return mpd_builder_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Testing only method. Sets mpd_builder_.
|
|
|
|
void SetMpdBuilderForTesting(scoped_ptr<MpdBuilder> mpd_builder) {
|
|
|
|
mpd_builder_ = mpd_builder.Pass();
|
|
|
|
}
|
|
|
|
|
2014-05-19 21:30:58 +00:00
|
|
|
enum ContentType {
|
|
|
|
kUnknown,
|
|
|
|
kVideo,
|
|
|
|
kAudio,
|
|
|
|
kText
|
|
|
|
};
|
|
|
|
ContentType GetContentType(const MediaInfo& media_info);
|
|
|
|
bool WriteMpdToFile();
|
|
|
|
|
|
|
|
std::string output_path_;
|
|
|
|
|
|
|
|
scoped_ptr<MpdBuilder> mpd_builder_;
|
|
|
|
|
|
|
|
base::Lock lock_;
|
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
// [type][lang] = AdaptationSet
|
|
|
|
typedef std::map<ContentType, 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);
|
|
|
|
};
|
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2014-05-19 21:30:58 +00:00
|
|
|
|
|
|
|
#endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
|